Esempio n. 1
0
/*
 * Adds a block to a movie.
 * This function adds a block or character to a movieclip.
 * returns a SWFDisplayItem 
 */
SWFDisplayItem
SWFMovieClip_add(SWFMovieClip clip, SWFBlock block)
{
	if ( SWFBlock_getType(block) == SWF_DEFINEBITS ||
			 SWFBlock_getType(block) == SWF_DEFINEBITSJPEG2 ||
			 SWFBlock_getType(block) == SWF_DEFINEBITSJPEG3 ||
			 SWFBlock_getType(block) == SWF_DEFINELOSSLESS ||
			 SWFBlock_getType(block) == SWF_DEFINELOSSLESS2 )
	{
		block = (SWFBlock)newSWFShapeFromBitmap((SWFBitmap)block, SWFFILL_TILED_BITMAP);
	}

	if ( SWFBlock_isCharacter(block) )
	{
		SWFCharacter_getDependencies((SWFCharacter)block,
																 &CHARACTER(clip)->dependencies,
																 &CHARACTER(clip)->nDependencies);

		SWFCharacter_addDependency((SWFCharacter)clip, (SWFCharacter)block);

		SWFCharacter_setFinished((SWFCharacter)block);

		return SWFDisplayList_add(clip->displayList, clip->blockList, (SWFCharacter)block);
	}
	else
	{
		/* XXX - make sure it's a legit block for a sprite */
		SWFBlockList_addBlock(clip->blockList, block);
	}

	return NULL;
}
Esempio n. 2
0
File: button.c Progetto: cran/R2SWF
/* adds a character 
 * Add a character to a button for given states
 * possible states:
 * SWFBUTTON_HIT
 * SWFBUTTON_DOWN
 * SWFBUTTON_OVER
 * SWFBUTTON_UP
 * states can be combined using the binary or operator
 * returns a SWFButtonRecord object which can be further modified.
 */
SWFButtonRecord
SWFButton_addCharacter(SWFButton button /* button object */, 
                       SWFCharacter character /* character to be added */, 
                       byte state /* state description */)
{
	SWFMatrix m;
	SWFButtonRecord record;
	SWFCharacter **depsPtr = &CHARACTER(button)->dependencies;
	int *depCount = &CHARACTER(button)->nDependencies;
	
	if ( SWFCharacter_isFinished((SWFCharacter)button) )
	{
		SWF_warn("Can't alter a button after it's been added to another character");
		return NULL;
	}

	SWFCharacter_getDependencies(character, depsPtr, depCount);
	SWFCharacter_addDependency((SWFCharacter)button, character);
	SWFCharacter_setFinished(character);
	
	m = newSWFMatrix(1.0, 0, 0, 1.0, 0, 0);
	record = newSWFButtonRecord(state, character, 0, m);
	SWFButton_addRecord(button, record);
	return record;
}
Esempio n. 3
0
/*
 * Adds a block to a movie.
 * This function adds a block or character to a movie.
 * Do not use this function. Use SWFMovie_add instead
 * returns a SWFDisplayItem 
 */
SWFDisplayItem
SWFMovie_add_internal(SWFMovie movie /* movie to which the block will be added */,
                      SWFMovieBlockType ublock /* block to add to the movie */)
{
	SWFBlock block = ublock.block;
	if ( block == NULL )
		return NULL;

	/* if they're trying to add a raw bitmap, we'll be nice and turn
		 it into a shape */

	if ( SWFBlock_getType(block) == SWF_DEFINEBITS ||
			 SWFBlock_getType(block) == SWF_DEFINEBITSJPEG2 ||
			 SWFBlock_getType(block) == SWF_DEFINEBITSJPEG3 ||
			 SWFBlock_getType(block) == SWF_DEFINELOSSLESS ||
			 SWFBlock_getType(block) == SWF_DEFINELOSSLESS2 )
	{
		block = (SWFBlock)newSWFShapeFromBitmap((SWFBitmap)block, SWFFILL_TILED_BITMAP);
	}

	/* if it's a text object, we need to translate fonts into font characters */

	if ( SWFBlock_getType(block) == SWF_DEFINETEXT ||
			 SWFBlock_getType(block) == SWF_DEFINETEXT2 )
	{
		SWFMovie_resolveTextFonts(movie, (SWFText)block);
	}

	if ( SWFBlock_getType(block) == SWF_DEFINEEDITTEXT)
	{
		SWFMovie_resolveTextfieldFont(movie, (SWFTextField)block);
	}

	// not nice but has to be done!
	if ( SWFBlock_getType(block) == SWF_INITACTION)
	{
		SWFInitAction init = (SWFInitAction)block;
		SWFMovieClip mc = SWFInitAction_getMovieClip(init);
		if(mc != NULL)
			SWFMovie_addBlock(movie, (SWFBlock)mc);
	} 
	
	if ( SWFBlock_isCharacter(block) )
	{
		
		SWFCharacter_setFinished((SWFCharacter)block);
		SWFMovie_addCharacterDependencies(movie, (SWFCharacter)block);

		return SWFDisplayList_add(movie->displayList, 
			movie->blockList, (SWFCharacter)block);
	}
	else
		SWFMovie_addBlock(movie, block);

	return NULL;
}
Esempio n. 4
0
File: button.c Progetto: cran/R2SWF
/* adds a shape character 
 * Add a shape character to a button for given states
 * possible states:
 * SWFBUTTON_HIT  
 * SWFBUTTON_DOWN  
 * SWFBUTTON_OVER
 * SWFBUTTON_UP
 * states can be combined using the binary or operator    
 * deprecated! use SWFButton_addCharacter instead
 */
void SWFButton_addShape(SWFButton button, SWFCharacter character, byte flags)
{
	SWFMatrix m;
	SWF_warnOnce("SWFButton_addShape is deprecated\nUse SWFButton_addCharacter instead\n");
	if ( SWFCharacter_isFinished((SWFCharacter)button) )
		SWF_error("Can't alter a button after it's been added to another character");

	m = newSWFMatrix(1.0, 0, 0, 1.0, 0, 0);

	SWFCharacter_getDependencies((SWFCharacter)character,
									 &CHARACTER(button)->dependencies,
									 &CHARACTER(button)->nDependencies);

	SWFCharacter_addDependency((SWFCharacter)button, (SWFCharacter)character);

	SWFCharacter_setFinished(character);
	SWFButton_addRecord(button, newSWFButtonRecord(flags, character, 0, m));
}
Esempio n. 5
0
/* 
 * This function replaces a displayable character with a new one.
 * Do not use this function. Use SWFMovie_replace instead!
 * returns 0 on success 
 */
int
SWFMovie_replace_internal(SWFMovie movie, SWFDisplayItem item, SWFMovieBlockType ublock)
{
	SWFBlock block = ublock.block;
	if(block == NULL || item == NULL)
		return -1;

	if ( SWFBlock_getType(block) == SWF_DEFINEBITS ||
			 SWFBlock_getType(block) == SWF_DEFINEBITSJPEG2 ||
			 SWFBlock_getType(block) == SWF_DEFINEBITSJPEG3 ||
			 SWFBlock_getType(block) == SWF_DEFINELOSSLESS ||
			 SWFBlock_getType(block) == SWF_DEFINELOSSLESS2 )
	{
		block = (SWFBlock)newSWFShapeFromBitmap((SWFBitmap)block, SWFFILL_TILED_BITMAP);
	}

	/* if it's a text object, we need to translate fonts into font characters */

	if ( SWFBlock_getType(block) == SWF_DEFINETEXT ||
			 SWFBlock_getType(block) == SWF_DEFINETEXT2 )
	{
		SWFMovie_resolveTextFonts(movie, (SWFText)block);
	}

	if ( SWFBlock_getType(block) == SWF_DEFINEEDITTEXT)
	{
		SWFMovie_resolveTextfieldFont(movie, (SWFTextField)block);
	}
	
	if ( SWFBlock_isCharacter(block) )
	{
		SWFCharacter_setFinished((SWFCharacter)block);
		SWFMovie_addCharacterDependencies(movie, (SWFCharacter)block);

		SWFDisplayItem_replace(item, (SWFCharacter)block);
		return 0;
	}

	SWF_warn("SWFMovie_replace: only characters can be replaced\n");
	return -1;
}