/* ======================== idSWFSpriteInstance::PlaceObject2 ======================== */ void idSWFSpriteInstance::PlaceObject2( idSWFBitStream & bitstream ) { c_PlaceObject2++; uint64 flags = bitstream.ReadU8(); int depth = bitstream.ReadU16(); int characterID = -1; if ( ( flags & PlaceFlagHasCharacter ) != 0 ) { characterID = bitstream.ReadU16(); } swfDisplayEntry_t * display = NULL; if ( ( flags & PlaceFlagMove ) != 0 ) { // modify an existing entry display = FindDisplayEntry( depth ); if ( display == NULL ) { idLib::Warning( "PlaceObject2: trying to modify entry %d, which doesn't exist", depth ); return; } if ( characterID >= 0 ) { // We are very picky about what kind of objects can change characters // Shapes can become other shapes, but sprites can never change if ( display->spriteInstance || display->textInstance ) { idLib::Warning( "PlaceObject2: Trying to change the character of a sprite after it's been created" ); return; } idSWFDictionaryEntry * dictEntry = sprite->swf->FindDictionaryEntry( characterID ); if ( dictEntry != NULL ) { if ( dictEntry->type == SWF_DICT_SPRITE || dictEntry->type == SWF_DICT_EDITTEXT ) { idLib::Warning( "PlaceObject2: Trying to change the character of a shape to a sprite" ); return; } } display->characterID = characterID; } } else { if ( characterID < 0 ) { idLib::Warning( "PlaceObject2: Trying to create a new object without a character" ); return; } // create a new entry display = AddDisplayEntry( depth, characterID ); if ( display == NULL ) { idLib::Warning( "PlaceObject2: trying to create a new entry at %d, but an item already exists there", depth ); return; } } if ( ( flags & PlaceFlagHasMatrix ) != 0 ) { bitstream.ReadMatrix( display->matrix ); } if ( ( flags & PlaceFlagHasColorTransform ) != 0 ) { bitstream.ReadColorXFormRGBA( display->cxf ); } if ( ( flags & PlaceFlagHasRatio ) != 0 ) { display->ratio = bitstream.ReadU16() * ( 1.0f / 65535.0f ); } if ( ( flags & PlaceFlagHasName ) != 0 ) { idStr name = bitstream.ReadString(); if ( display->spriteInstance ) { display->spriteInstance->name = name; scriptObject->Set( name, display->spriteInstance->GetScriptObject() ); } else if ( display->textInstance ) { scriptObject->Set( name, display->textInstance->GetScriptObject() ); } } if ( ( flags & PlaceFlagHasClipDepth ) != 0 ) { display->clipDepth = bitstream.ReadU16(); } if ( ( flags & PlaceFlagHasClipActions ) != 0 ) { // FIXME: clip actions } }
/* ======================== 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; }
/* ======================== idSWFSpriteInstance::PlaceObject3 ======================== */ void idSWFSpriteInstance::PlaceObject3( idSWFBitStream & bitstream ) { c_PlaceObject3++; uint64 flags1 = bitstream.ReadU8(); uint64 flags2 = bitstream.ReadU8(); uint16 depth = bitstream.ReadU16(); if ( ( flags2 & PlaceFlagHasClassName ) != 0 || ( ( ( flags2 & PlaceFlagHasImage ) != 0 ) && ( ( flags1 & PlaceFlagHasCharacter ) != 0 ) ) ) { bitstream.ReadString(); // ignored } int characterID = -1; if ( ( flags1 & PlaceFlagHasCharacter ) != 0 ) { characterID = bitstream.ReadU16(); } swfDisplayEntry_t * display = NULL; if ( ( flags1 & PlaceFlagMove ) != 0 ) { // modify an existing entry display = FindDisplayEntry( depth ); if ( display == NULL ) { idLib::Warning( "PlaceObject3: trying to modify entry %d, which doesn't exist", depth ); return; } if ( characterID >= 0 ) { // We are very picky about what kind of objects can change characters // Shapes can become other shapes, but sprites can never change if ( display->spriteInstance || display->textInstance ) { idLib::Warning( "PlaceObject3: Trying to change the character of a sprite after it's been created" ); return; } idSWFDictionaryEntry * dictEntry = sprite->swf->FindDictionaryEntry( characterID ); if ( dictEntry != NULL ) { if ( dictEntry->type == SWF_DICT_SPRITE || dictEntry->type == SWF_DICT_EDITTEXT ) { idLib::Warning( "PlaceObject3: Trying to change the character of a shape to a sprite" ); return; } } display->characterID = characterID; } } else { if ( characterID < 0 ) { idLib::Warning( "PlaceObject3: Trying to create a new object without a character" ); return; } // create a new entry display = AddDisplayEntry( depth, characterID ); if ( display == NULL ) { idLib::Warning( "PlaceObject3: trying to create a new entry at %d, but an item already exists there", depth ); return; } } if ( ( flags1 & PlaceFlagHasMatrix ) != 0 ) { bitstream.ReadMatrix( display->matrix ); } if ( ( flags1 & PlaceFlagHasColorTransform ) != 0 ) { bitstream.ReadColorXFormRGBA( display->cxf ); } if ( ( flags1 & PlaceFlagHasRatio ) != 0 ) { display->ratio = bitstream.ReadU16() * ( 1.0f / 65535.0f ); } if ( ( flags1 & PlaceFlagHasName ) != 0 ) { idStr name = bitstream.ReadString(); if ( display->spriteInstance ) { display->spriteInstance->name = name; scriptObject->Set( name, display->spriteInstance->GetScriptObject() ); } else if ( display->textInstance ) { scriptObject->Set( name, display->textInstance->GetScriptObject() ); } } if ( ( flags1 & PlaceFlagHasClipDepth ) != 0 ) { display->clipDepth = bitstream.ReadU16(); } if ( ( flags2 & PlaceFlagHasFilterList ) != 0 ) { // we don't support filters and because the filter list is variable length we // can't support anything after the filter list either (blend modes and clip actions) idLib::Warning( "PlaceObject3: has filters" ); return; } if ( ( flags2 & PlaceFlagHasBlendMode ) != 0 ) { display->blendMode = bitstream.ReadU8(); } if ( ( flags1 & PlaceFlagHasClipActions ) != 0 ) { // FIXME: } }
/* =================== idSWF::Metadata =================== */ void idSWF::Metadata( idSWFBitStream& bitstream ) { bitstream.ReadString(); // XML string }