Exemple #1
0
/*
========================
idSWF::DefineEditText
========================
*/
void idSWF::DefineEditText( idSWFBitStream & bitstream ) {
	uint16 characterID = bitstream.ReadU16();
	idSWFDictionaryEntry * entry = AddDictionaryEntry( characterID, SWF_DICT_EDITTEXT );
	if ( entry == NULL ) {
		return;
	}
	idSWFEditText * edittext = entry->edittext;
	bitstream.ReadRect( edittext->bounds );
	bitstream.ResetBits();
	bool hasText = bitstream.ReadBool();
	bool wordWrap = bitstream.ReadBool();
	bool multiline = bitstream.ReadBool();
	bool password = bitstream.ReadBool();
	bool readonly = bitstream.ReadBool();
	bool hasTextColor = bitstream.ReadBool();
	bool hasMaxLength = bitstream.ReadBool();
	bool hasFont = bitstream.ReadBool();
	bool hasFontClass = bitstream.ReadBool();
	bool autoSize = bitstream.ReadBool();
	bool hasLayout = bitstream.ReadBool();
	bool noSelect = bitstream.ReadBool();
	bool border = bitstream.ReadBool();
	bool wasStatic = bitstream.ReadBool();
	bool html = bitstream.ReadBool();
	bool useOutlines = bitstream.ReadBool();
	if ( hasFont ) {
		edittext->fontID = bitstream.ReadU16();
		edittext->fontHeight = bitstream.ReadU16();
	}
	if ( hasFontClass ) {
		idStr fontClass = bitstream.ReadString();
	}
	if ( hasTextColor ) {
		bitstream.ReadColorRGBA( edittext->color );
	}
	if ( hasMaxLength ) {
		edittext->maxLength = bitstream.ReadU16();
	}
	if ( hasLayout ) {
		edittext->align = (swfEditTextAlign_t)bitstream.ReadU8();
		edittext->leftMargin = bitstream.ReadU16();
		edittext->rightMargin = bitstream.ReadU16();
		edittext->indent = bitstream.ReadU16();
		edittext->leading = bitstream.ReadS16();
	}
	edittext->variable = bitstream.ReadString();
	if ( hasText ) {
		const char * text = bitstream.ReadString();
		idStr initialText;

		// convert html tags if necessary
		for ( int i = 0; text[i] != 0; i++ ) {
			if ( text[i] == '<' ) {
				if ( i != 0 && text[i+1] == 'p' ) {
					initialText.Append( '\n' );
				}
				for ( ; text[i] != 0 && text[i] != '>'; i++ ) {
				}
				continue;
			}
			byte tc = (byte)text[i];
			if ( tc == '&' ) {
				idStr special;
				for ( i++; text[i] != 0 && text[i] != ';'; i++ ) {
					special.Append( text[i] );
				}
				if ( special.Icmp( "amp" ) == 0 ) {
					tc = '&';
				} else if ( special.Icmp( "apos" ) == 0 ) {
					tc = '\'';
				} else if ( special.Icmp( "lt" ) == 0 ) {
					tc = '<';
				} else if ( special.Icmp( "gt" ) == 0 ) {
					tc = '>';
				} else if ( special.Icmp( "quot" ) == 0 ) {
					tc = '\"';
				}
			}
			initialText.Append( tc );
		}
		edittext->initialText = initialText;
	}
	edittext->flags |= wordWrap ? SWF_ET_WORDWRAP : 0;
	edittext->flags |= multiline ? SWF_ET_MULTILINE : 0;
	edittext->flags |= password ? SWF_ET_PASSWORD : 0;
	edittext->flags |= readonly ? SWF_ET_READONLY : 0;
	edittext->flags |= autoSize ? SWF_ET_AUTOSIZE : 0;
	edittext->flags |= border ? SWF_ET_BORDER : 0;
}
/*
========================
idSWFShapeParser::ParseShapes
========================
*/
void idSWFShapeParser::ParseShapes( idSWFBitStream& bitstream1, idSWFBitStream* bitstream2, bool swap )
{
	int32 pen1X = 0;
	int32 pen1Y = 0;
	int32 pen2X = 0;
	int32 pen2Y = 0;
	
	uint8 fillStyle0 = 0;
	uint8 fillStyle1 = 0;
	uint8 lineStyle = 0;
	
	uint16 baseFillStyle = 0;
	uint16 baseLineStyle = 0;
	
	uint8 numBits = bitstream1.ReadU8();
	uint8 numFillBits1 = numBits >> 4;
	uint8 numLineBits1 = numBits & 0xF;
	
	uint8 numFillBits2 = 0;
	uint8 numLineBits2 = 0;
	
	if( bitstream2 )
	{
		numBits = bitstream2->ReadU8();
		numFillBits2 = numBits >> 4;
		numLineBits2 = numBits & 0xF;
	}
	
	while( true )
	{
		if( !bitstream1.ReadBool() )
		{
			bool stateNewStyles = bitstream1.ReadBool();
			bool stateLineStyle = bitstream1.ReadBool();
			bool stateFillStyle1 = bitstream1.ReadBool();
			bool stateFillStyle0 = bitstream1.ReadBool();
			bool stateMoveTo = bitstream1.ReadBool();
			if( ( stateNewStyles || stateLineStyle || stateFillStyle1 || stateFillStyle0 || stateMoveTo ) == false )
			{
				// end record
				if( bitstream2 )
				{
					uint8 flags = bitstream2->ReadU( 6 );
					if( flags != 0 )
					{
						idLib::Warning( "idSWFShapeParser: morph stream 1 ends before 2" );
						break;
					}
				}
				break;
			}
			if( stateMoveTo )
			{
				uint8 moveBits = bitstream1.ReadU( 5 );
				pen1X = bitstream1.ReadS( moveBits );
				pen1Y = bitstream1.ReadS( moveBits );
			}
			if( stateFillStyle0 )
			{
				fillStyle0 = bitstream1.ReadU( numFillBits1 );
			}
			if( stateFillStyle1 )
			{
				fillStyle1 = bitstream1.ReadU( numFillBits1 );
			}
			if( stateLineStyle )
			{
				lineStyle = bitstream1.ReadU( numLineBits1 );
			}
			if( stateNewStyles )
			{
				baseFillStyle = fillDraws.Num();
				baseLineStyle = lineDraws.Num();
				ReadFillStyle( bitstream1 );
				numBits = bitstream1.ReadU8();
				numFillBits1 = numBits >> 4;
				numLineBits1 = numBits & 0xF;
			}
			if( bitstream2 )
			{
				bool isEdge = bitstream2->ReadBool();
				if( isEdge )
				{
					idLib::Warning( "idSWFShapeParser: morph stream 1 defines style change, but stream 2 does not" );
					break;
				}
				bool stateNewStyles = bitstream2->ReadBool();
				bool stateLineStyle = bitstream2->ReadBool();
				bool stateFillStyle1 = bitstream2->ReadBool();
				bool stateFillStyle0 = bitstream2->ReadBool();
				bool stateMoveTo = bitstream2->ReadBool();
				if( stateMoveTo )
				{
					uint8 moveBits = bitstream2->ReadU( 5 );
					pen2X = bitstream2->ReadS( moveBits );
					pen2Y = bitstream2->ReadS( moveBits );
				}
				if( stateFillStyle0 )
				{
					if( bitstream2->ReadU( numFillBits2 ) != fillStyle0 )
					{
						idLib::Warning( "idSWFShapeParser: morph stream 2 defined a different fillStyle0 from stream 1" );
						break;
					}
				}
				if( stateFillStyle1 )
				{
					if( bitstream2->ReadU( numFillBits2 ) != fillStyle1 )
					{
						idLib::Warning( "idSWFShapeParser: morph stream 2 defined a different fillStyle1 from stream 1" );
						break;
					}
				}
				if( stateLineStyle )
				{
					if( bitstream2->ReadU( numLineBits2 ) != lineStyle )
					{
						idLib::Warning( "idSWFShapeParser: morph stream 2 defined a different lineStyle from stream 1" );
						break;
					}
				}
				if( stateNewStyles )
				{
					idLib::Warning( "idSWFShapeParser: morph stream 2 defines new styles" );
					break;
				}
			}
		}
		else
		{