2012-11-26 18:58:24 +00:00
|
|
|
/*
|
|
|
|
===========================================================================
|
|
|
|
|
|
|
|
Doom 3 BFG Edition GPL Source Code
|
2012-11-28 15:47:07 +00:00
|
|
|
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
|
|
|
|
|
|
|
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
|
|
|
|
|
|
|
===========================================================================
|
|
|
|
*/
|
|
|
|
#pragma hdrstop
|
2012-12-22 15:18:19 +00:00
|
|
|
#include "precompiled.h"
|
2012-11-26 18:58:24 +00:00
|
|
|
#include "../renderer/Font.h"
|
|
|
|
|
|
|
|
#pragma warning(disable: 4355) // 'this' : used in base member initializer list
|
|
|
|
|
|
|
|
#define BSWF_VERSION 16 // bumped to 16 for storing atlas image dimensions for unbuffered loads
|
|
|
|
#define BSWF_MAGIC ( ( 'B' << 24 ) | ( 'S' << 16 ) | ( 'W' << 8 ) | BSWF_VERSION )
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
idSWF::LoadSWF
|
|
|
|
===================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
bool idSWF::LoadSWF( const char* fullpath )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
idFile* rawfile = fileSystem->OpenFileRead( fullpath );
|
|
|
|
if( rawfile == NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idLib::Printf( "SWF File not found %s\n", fullpath );
|
|
|
|
return false;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
swfHeader_t header;
|
|
|
|
rawfile->Read( &header, sizeof( header ) );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( header.W != 'W' || header.S != 'S' )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idLib::Warning( "Wrong signature bytes" );
|
|
|
|
delete rawfile;
|
|
|
|
return false;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( header.version > 9 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idLib::Warning( "Unsupported version %d", header.version );
|
|
|
|
delete rawfile;
|
|
|
|
return false;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
bool compressed;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( header.compression == 'F' )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
compressed = false;
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else if( header.compression == 'C' )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
compressed = true;
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idLib::Warning( "Unsupported compression type %c", header.compression );
|
|
|
|
delete rawfile;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
idSwap::Little( header.fileLength );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// header.fileLength somewhat annoyingly includes the size of the header
|
2012-11-28 15:47:07 +00:00
|
|
|
uint32 fileLength2 = header.fileLength - ( uint32 )sizeof( swfHeader_t );
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// slurp the raw file into a giant array, which is somewhat atrocious when loading from the preload since it's already an idFile_Memory
|
2012-11-28 15:47:07 +00:00
|
|
|
byte* fileData = ( byte* )Mem_Alloc( fileLength2, TAG_SWF );
|
2012-11-26 18:58:24 +00:00
|
|
|
size_t fileSize = rawfile->Read( fileData, fileLength2 );
|
|
|
|
delete rawfile;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( compressed )
|
|
|
|
{
|
|
|
|
byte* uncompressed = ( byte* )Mem_Alloc( fileLength2, TAG_SWF );
|
|
|
|
if( !Inflate( fileData, ( int )fileSize, uncompressed, fileLength2 ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idLib::Warning( "Inflate error" );
|
|
|
|
Mem_Free( uncompressed );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
Mem_Free( fileData );
|
|
|
|
fileData = uncompressed;
|
|
|
|
}
|
|
|
|
idSWFBitStream bitstream( fileData, fileLength2, false );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
swfRect_t frameSize;
|
|
|
|
bitstream.ReadRect( frameSize );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( !frameSize.tl.Compare( vec2_zero ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idLib::Warning( "Invalid frameSize top left" );
|
|
|
|
Mem_Free( fileData );
|
|
|
|
return false;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
frameWidth = frameSize.br.x;
|
|
|
|
frameHeight = frameSize.br.y;
|
|
|
|
frameRate = bitstream.ReadU16();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// parse everything
|
|
|
|
mainsprite->Load( bitstream, true );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// now that all images have been loaded, write out the combined image
|
|
|
|
idStr atlasFileName = "generated/";
|
|
|
|
atlasFileName += fullpath;
|
|
|
|
atlasFileName.SetFileExtension( ".tga" );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
WriteSwfImageAtlas( atlasFileName );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
Mem_Free( fileData );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
idSWF::LoadBinary
|
|
|
|
===================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
bool idSWF::LoadBinary( const char* bfilename, ID_TIME_T sourceTime )
|
|
|
|
{
|
|
|
|
idFile* f = fileSystem->OpenFileReadMemory( bfilename );
|
|
|
|
if( f == NULL || f->Length() <= 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
uint32 magic = 0;
|
|
|
|
ID_TIME_T btimestamp = 0;
|
|
|
|
f->ReadBig( magic );
|
|
|
|
f->ReadBig( btimestamp );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( magic != BSWF_MAGIC || ( !fileSystem->InProductionMode() && sourceTime != btimestamp ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
delete f;
|
|
|
|
return false;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
f->ReadBig( frameWidth );
|
|
|
|
f->ReadBig( frameHeight );
|
|
|
|
f->ReadBig( frameRate );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( mouseX == -1 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
mouseX = ( frameWidth / 2 );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( mouseY == -1 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
mouseY = ( frameHeight / 2 );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
mainsprite->Read( f );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
int num = 0;
|
|
|
|
f->ReadBig( num );
|
|
|
|
dictionary.SetNum( num );
|
2012-11-28 15:47:07 +00:00
|
|
|
for( int i = 0; i < dictionary.Num(); i++ )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
f->ReadBig( dictionary[i].type );
|
2012-11-28 15:47:07 +00:00
|
|
|
switch( dictionary[i].type )
|
|
|
|
{
|
|
|
|
case SWF_DICT_IMAGE:
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idStr imageName;
|
|
|
|
f->ReadString( imageName );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( imageName[0] == '.' )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// internal image in the atlas
|
|
|
|
dictionary[i].material = NULL;
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
dictionary[i].material = declManager->FindMaterial( imageName );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
for( int j = 0 ; j < 2 ; j++ )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
f->ReadBig( dictionary[i].imageSize[j] );
|
|
|
|
f->ReadBig( dictionary[i].imageAtlasOffset[j] );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
for( int j = 0 ; j < 4 ; j++ )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
f->ReadBig( dictionary[i].channelScale[j] );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SWF_DICT_MORPH:
|
2012-11-28 15:47:07 +00:00
|
|
|
case SWF_DICT_SHAPE:
|
|
|
|
{
|
|
|
|
dictionary[i].shape = new( TAG_SWF ) idSWFShape;
|
|
|
|
idSWFShape* shape = dictionary[i].shape;
|
2012-11-26 18:58:24 +00:00
|
|
|
f->ReadBig( shape->startBounds.tl );
|
|
|
|
f->ReadBig( shape->startBounds.br );
|
|
|
|
f->ReadBig( shape->endBounds.tl );
|
|
|
|
f->ReadBig( shape->endBounds.br );
|
2012-11-28 15:47:07 +00:00
|
|
|
f->ReadBig( num );
|
|
|
|
shape->fillDraws.SetNum( num );
|
|
|
|
for( int d = 0; d < shape->fillDraws.Num(); d++ )
|
|
|
|
{
|
|
|
|
idSWFShapeDrawFill& fillDraw = shape->fillDraws[d];
|
2012-11-26 18:58:24 +00:00
|
|
|
f->ReadBig( fillDraw.style.type );
|
|
|
|
f->ReadBig( fillDraw.style.subType );
|
|
|
|
f->Read( &fillDraw.style.startColor, 4 );
|
|
|
|
f->Read( &fillDraw.style.endColor, 4 );
|
2012-11-28 15:47:07 +00:00
|
|
|
f->ReadBigArray( ( float* )&fillDraw.style.startMatrix, 6 );
|
|
|
|
f->ReadBigArray( ( float* )&fillDraw.style.endMatrix, 6 );
|
2012-11-26 18:58:24 +00:00
|
|
|
f->ReadBig( fillDraw.style.gradient.numGradients );
|
2012-11-28 15:47:07 +00:00
|
|
|
for( int g = 0; g < fillDraw.style.gradient.numGradients; g++ )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
f->ReadBig( fillDraw.style.gradient.gradientRecords[g].startRatio );
|
|
|
|
f->ReadBig( fillDraw.style.gradient.gradientRecords[g].endRatio );
|
|
|
|
f->Read( &fillDraw.style.gradient.gradientRecords[g].startColor, 4 );
|
|
|
|
f->Read( &fillDraw.style.gradient.gradientRecords[g].endColor, 4 );
|
|
|
|
}
|
|
|
|
f->ReadBig( fillDraw.style.focalPoint );
|
|
|
|
f->ReadBig( fillDraw.style.bitmapID );
|
2012-11-28 15:47:07 +00:00
|
|
|
f->ReadBig( num );
|
|
|
|
fillDraw.startVerts.SetNum( num );
|
2012-11-26 18:58:24 +00:00
|
|
|
f->ReadBigArray( fillDraw.startVerts.Ptr(), fillDraw.startVerts.Num() );
|
2012-11-28 15:47:07 +00:00
|
|
|
f->ReadBig( num );
|
|
|
|
fillDraw.endVerts.SetNum( num );
|
2012-11-26 18:58:24 +00:00
|
|
|
f->ReadBigArray( fillDraw.endVerts.Ptr(), fillDraw.endVerts.Num() );
|
2012-11-28 15:47:07 +00:00
|
|
|
f->ReadBig( num );
|
|
|
|
fillDraw.indices.SetNum( num );
|
2012-11-26 18:58:24 +00:00
|
|
|
f->ReadBigArray( fillDraw.indices.Ptr(), fillDraw.indices.Num() );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
f->ReadBig( num );
|
|
|
|
shape->lineDraws.SetNum( num );
|
|
|
|
for( int d = 0; d < shape->lineDraws.Num(); d++ )
|
|
|
|
{
|
|
|
|
idSWFShapeDrawLine& lineDraw = shape->lineDraws[d];
|
2012-11-26 18:58:24 +00:00
|
|
|
f->ReadBig( lineDraw.style.startWidth );
|
|
|
|
f->ReadBig( lineDraw.style.endWidth );
|
|
|
|
f->Read( &lineDraw.style.startColor, 4 );
|
|
|
|
f->Read( &lineDraw.style.endColor, 4 );
|
2012-11-28 15:47:07 +00:00
|
|
|
f->ReadBig( num );
|
|
|
|
lineDraw.startVerts.SetNum( num );
|
2012-11-26 18:58:24 +00:00
|
|
|
f->ReadBigArray( lineDraw.startVerts.Ptr(), lineDraw.startVerts.Num() );
|
2012-11-28 15:47:07 +00:00
|
|
|
f->ReadBig( num );
|
|
|
|
lineDraw.endVerts.SetNum( num );
|
2012-11-26 18:58:24 +00:00
|
|
|
f->ReadBigArray( lineDraw.endVerts.Ptr(), lineDraw.endVerts.Num() );
|
2012-11-28 15:47:07 +00:00
|
|
|
f->ReadBig( num );
|
|
|
|
lineDraw.indices.SetNum( num );
|
2012-11-26 18:58:24 +00:00
|
|
|
f->ReadBigArray( lineDraw.indices.Ptr(), lineDraw.indices.Num() );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
case SWF_DICT_SPRITE:
|
|
|
|
{
|
|
|
|
dictionary[i].sprite = new( TAG_SWF ) idSWFSprite( this );
|
2012-11-26 18:58:24 +00:00
|
|
|
dictionary[i].sprite->Read( f );
|
|
|
|
break;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
case SWF_DICT_FONT:
|
|
|
|
{
|
|
|
|
dictionary[i].font = new( TAG_SWF ) idSWFFont;
|
|
|
|
idSWFFont* font = dictionary[i].font;
|
2012-11-26 18:58:24 +00:00
|
|
|
idStr fontName;
|
|
|
|
f->ReadString( fontName );
|
|
|
|
font->fontID = renderSystem->RegisterFont( fontName );
|
|
|
|
f->ReadBig( font->ascent );
|
|
|
|
f->ReadBig( font->descent );
|
|
|
|
f->ReadBig( font->leading );
|
2012-11-28 15:47:07 +00:00
|
|
|
f->ReadBig( num );
|
|
|
|
font->glyphs.SetNum( num );
|
|
|
|
for( int g = 0; g < font->glyphs.Num(); g++ )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
f->ReadBig( font->glyphs[g].code );
|
|
|
|
f->ReadBig( font->glyphs[g].advance );
|
2012-11-28 15:47:07 +00:00
|
|
|
f->ReadBig( num );
|
|
|
|
font->glyphs[g].verts.SetNum( num );
|
2012-11-26 18:58:24 +00:00
|
|
|
f->ReadBigArray( font->glyphs[g].verts.Ptr(), font->glyphs[g].verts.Num() );
|
2012-11-28 15:47:07 +00:00
|
|
|
f->ReadBig( num );
|
|
|
|
font->glyphs[g].indices.SetNum( num );
|
2012-11-26 18:58:24 +00:00
|
|
|
f->ReadBigArray( font->glyphs[g].indices.Ptr(), font->glyphs[g].indices.Num() );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
case SWF_DICT_TEXT:
|
|
|
|
{
|
|
|
|
dictionary[i].text = new( TAG_SWF ) idSWFText;
|
|
|
|
idSWFText* text = dictionary[i].text;
|
2012-11-26 18:58:24 +00:00
|
|
|
f->ReadBig( text->bounds.tl );
|
|
|
|
f->ReadBig( text->bounds.br );
|
2012-11-28 15:47:07 +00:00
|
|
|
f->ReadBigArray( ( float* )&text->matrix, 6 );
|
|
|
|
f->ReadBig( num );
|
|
|
|
text->textRecords.SetNum( num );
|
|
|
|
for( int t = 0; t < text->textRecords.Num(); t++ )
|
|
|
|
{
|
|
|
|
idSWFTextRecord& textRecord = text->textRecords[t];
|
2012-11-26 18:58:24 +00:00
|
|
|
f->ReadBig( textRecord.fontID );
|
|
|
|
f->Read( &textRecord.color, 4 );
|
|
|
|
f->ReadBig( textRecord.xOffset );
|
|
|
|
f->ReadBig( textRecord.yOffset );
|
|
|
|
f->ReadBig( textRecord.textHeight );
|
|
|
|
f->ReadBig( textRecord.firstGlyph );
|
|
|
|
f->ReadBig( textRecord.numGlyphs );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
f->ReadBig( num );
|
|
|
|
text->glyphs.SetNum( num );
|
|
|
|
for( int g = 0; g < text->glyphs.Num(); g++ )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
f->ReadBig( text->glyphs[g].index );
|
|
|
|
f->ReadBig( text->glyphs[g].advance );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
case SWF_DICT_EDITTEXT:
|
|
|
|
{
|
|
|
|
dictionary[i].edittext = new( TAG_SWF ) idSWFEditText;
|
|
|
|
idSWFEditText* edittext = dictionary[i].edittext;
|
2012-11-26 18:58:24 +00:00
|
|
|
f->ReadBig( edittext->bounds.tl );
|
|
|
|
f->ReadBig( edittext->bounds.br );
|
|
|
|
f->ReadBig( edittext->flags );
|
|
|
|
f->ReadBig( edittext->fontID );
|
|
|
|
f->ReadBig( edittext->fontHeight );
|
|
|
|
f->Read( &edittext->color, 4 );
|
|
|
|
f->ReadBig( edittext->maxLength );
|
|
|
|
f->ReadBig( edittext->align );
|
|
|
|
f->ReadBig( edittext->leftMargin );
|
|
|
|
f->ReadBig( edittext->rightMargin );
|
|
|
|
f->ReadBig( edittext->indent );
|
|
|
|
f->ReadBig( edittext->leading );
|
|
|
|
f->ReadString( edittext->variable );
|
|
|
|
f->ReadString( edittext->initialText );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delete f;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
idSWF::WriteBinary
|
|
|
|
===================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idSWF::WriteBinary( const char* bfilename )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idFileLocal file( fileSystem->OpenFileWrite( bfilename, "fs_basepath" ) );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( file == NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
file->WriteBig( BSWF_MAGIC );
|
|
|
|
file->WriteBig( timestamp );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
file->WriteBig( frameWidth );
|
|
|
|
file->WriteBig( frameHeight );
|
|
|
|
file->WriteBig( frameRate );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
mainsprite->Write( file );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
file->WriteBig( dictionary.Num() );
|
2012-11-28 15:47:07 +00:00
|
|
|
for( int i = 0; i < dictionary.Num(); i++ )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
file->WriteBig( dictionary[i].type );
|
2012-11-28 15:47:07 +00:00
|
|
|
switch( dictionary[i].type )
|
|
|
|
{
|
|
|
|
case SWF_DICT_IMAGE:
|
|
|
|
{
|
|
|
|
if( dictionary[i].material )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
file->WriteString( dictionary[i].material->GetName() );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
file->WriteString( "." );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
for( int j = 0 ; j < 2 ; j++ )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
file->WriteBig( dictionary[i].imageSize[j] );
|
|
|
|
file->WriteBig( dictionary[i].imageAtlasOffset[j] );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
for( int j = 0 ; j < 4 ; j++ )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
file->WriteBig( dictionary[i].channelScale[j] );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SWF_DICT_MORPH:
|
2012-11-28 15:47:07 +00:00
|
|
|
case SWF_DICT_SHAPE:
|
|
|
|
{
|
|
|
|
idSWFShape* shape = dictionary[i].shape;
|
2012-11-26 18:58:24 +00:00
|
|
|
file->WriteBig( shape->startBounds.tl );
|
|
|
|
file->WriteBig( shape->startBounds.br );
|
|
|
|
file->WriteBig( shape->endBounds.tl );
|
|
|
|
file->WriteBig( shape->endBounds.br );
|
|
|
|
file->WriteBig( shape->fillDraws.Num() );
|
2012-11-28 15:47:07 +00:00
|
|
|
for( int d = 0; d < shape->fillDraws.Num(); d++ )
|
|
|
|
{
|
|
|
|
idSWFShapeDrawFill& fillDraw = shape->fillDraws[d];
|
2012-11-26 18:58:24 +00:00
|
|
|
file->WriteBig( fillDraw.style.type );
|
|
|
|
file->WriteBig( fillDraw.style.subType );
|
|
|
|
file->Write( &fillDraw.style.startColor, 4 );
|
|
|
|
file->Write( &fillDraw.style.endColor, 4 );
|
2012-11-28 15:47:07 +00:00
|
|
|
file->WriteBigArray( ( float* )&fillDraw.style.startMatrix, 6 );
|
|
|
|
file->WriteBigArray( ( float* )&fillDraw.style.endMatrix, 6 );
|
2012-11-26 18:58:24 +00:00
|
|
|
file->WriteBig( fillDraw.style.gradient.numGradients );
|
2012-11-28 15:47:07 +00:00
|
|
|
for( int g = 0; g < fillDraw.style.gradient.numGradients; g++ )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
file->WriteBig( fillDraw.style.gradient.gradientRecords[g].startRatio );
|
|
|
|
file->WriteBig( fillDraw.style.gradient.gradientRecords[g].endRatio );
|
|
|
|
file->Write( &fillDraw.style.gradient.gradientRecords[g].startColor, 4 );
|
|
|
|
file->Write( &fillDraw.style.gradient.gradientRecords[g].endColor, 4 );
|
|
|
|
}
|
|
|
|
file->WriteBig( fillDraw.style.focalPoint );
|
|
|
|
file->WriteBig( fillDraw.style.bitmapID );
|
|
|
|
file->WriteBig( fillDraw.startVerts.Num() );
|
|
|
|
file->WriteBigArray( fillDraw.startVerts.Ptr(), fillDraw.startVerts.Num() );
|
|
|
|
file->WriteBig( fillDraw.endVerts.Num() );
|
|
|
|
file->WriteBigArray( fillDraw.endVerts.Ptr(), fillDraw.endVerts.Num() );
|
|
|
|
file->WriteBig( fillDraw.indices.Num() );
|
|
|
|
file->WriteBigArray( fillDraw.indices.Ptr(), fillDraw.indices.Num() );
|
|
|
|
}
|
|
|
|
file->WriteBig( shape->lineDraws.Num() );
|
2012-11-28 15:47:07 +00:00
|
|
|
for( int d = 0; d < shape->lineDraws.Num(); d++ )
|
|
|
|
{
|
|
|
|
idSWFShapeDrawLine& lineDraw = shape->lineDraws[d];
|
2012-11-26 18:58:24 +00:00
|
|
|
file->WriteBig( lineDraw.style.startWidth );
|
|
|
|
file->WriteBig( lineDraw.style.endWidth );
|
|
|
|
file->Write( &lineDraw.style.startColor, 4 );
|
|
|
|
file->Write( &lineDraw.style.endColor, 4 );
|
|
|
|
file->WriteBig( lineDraw.startVerts.Num() );
|
|
|
|
file->WriteBigArray( lineDraw.startVerts.Ptr(), lineDraw.startVerts.Num() );
|
|
|
|
file->WriteBig( lineDraw.endVerts.Num() );
|
|
|
|
file->WriteBigArray( lineDraw.endVerts.Ptr(), lineDraw.endVerts.Num() );
|
|
|
|
file->WriteBig( lineDraw.indices.Num() );
|
|
|
|
file->WriteBigArray( lineDraw.indices.Ptr(), lineDraw.indices.Num() );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
case SWF_DICT_SPRITE:
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
dictionary[i].sprite->Write( file );
|
|
|
|
break;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
case SWF_DICT_FONT:
|
|
|
|
{
|
|
|
|
idSWFFont* font = dictionary[i].font;
|
2012-11-26 18:58:24 +00:00
|
|
|
file->WriteString( font->fontID->GetName() );
|
|
|
|
file->WriteBig( font->ascent );
|
|
|
|
file->WriteBig( font->descent );
|
|
|
|
file->WriteBig( font->leading );
|
|
|
|
file->WriteBig( font->glyphs.Num() );
|
2012-11-28 15:47:07 +00:00
|
|
|
for( int g = 0; g < font->glyphs.Num(); g++ )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
file->WriteBig( font->glyphs[g].code );
|
|
|
|
file->WriteBig( font->glyphs[g].advance );
|
|
|
|
file->WriteBig( font->glyphs[g].verts.Num() );
|
|
|
|
file->WriteBigArray( font->glyphs[g].verts.Ptr(), font->glyphs[g].verts.Num() );
|
|
|
|
file->WriteBig( font->glyphs[g].indices.Num() );
|
|
|
|
file->WriteBigArray( font->glyphs[g].indices.Ptr(), font->glyphs[g].indices.Num() );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
case SWF_DICT_TEXT:
|
|
|
|
{
|
|
|
|
idSWFText* text = dictionary[i].text;
|
2012-11-26 18:58:24 +00:00
|
|
|
file->WriteBig( text->bounds.tl );
|
|
|
|
file->WriteBig( text->bounds.br );
|
2012-11-28 15:47:07 +00:00
|
|
|
file->WriteBigArray( ( float* )&text->matrix, 6 );
|
2012-11-26 18:58:24 +00:00
|
|
|
file->WriteBig( text->textRecords.Num() );
|
2012-11-28 15:47:07 +00:00
|
|
|
for( int t = 0; t < text->textRecords.Num(); t++ )
|
|
|
|
{
|
|
|
|
idSWFTextRecord& textRecord = text->textRecords[t];
|
2012-11-26 18:58:24 +00:00
|
|
|
file->WriteBig( textRecord.fontID );
|
|
|
|
file->Write( &textRecord.color, 4 );
|
|
|
|
file->WriteBig( textRecord.xOffset );
|
|
|
|
file->WriteBig( textRecord.yOffset );
|
|
|
|
file->WriteBig( textRecord.textHeight );
|
|
|
|
file->WriteBig( textRecord.firstGlyph );
|
|
|
|
file->WriteBig( textRecord.numGlyphs );
|
|
|
|
}
|
|
|
|
file->WriteBig( text->glyphs.Num() );
|
2012-11-28 15:47:07 +00:00
|
|
|
for( int g = 0; g < text->glyphs.Num(); g++ )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
file->WriteBig( text->glyphs[g].index );
|
|
|
|
file->WriteBig( text->glyphs[g].advance );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
case SWF_DICT_EDITTEXT:
|
|
|
|
{
|
|
|
|
idSWFEditText* edittext = dictionary[i].edittext;
|
2012-11-26 18:58:24 +00:00
|
|
|
file->WriteBig( edittext->bounds.tl );
|
|
|
|
file->WriteBig( edittext->bounds.br );
|
|
|
|
file->WriteBig( edittext->flags );
|
|
|
|
file->WriteBig( edittext->fontID );
|
|
|
|
file->WriteBig( edittext->fontHeight );
|
|
|
|
file->Write( &edittext->color, 4 );
|
|
|
|
file->WriteBig( edittext->maxLength );
|
|
|
|
file->WriteBig( edittext->align );
|
|
|
|
file->WriteBig( edittext->leftMargin );
|
|
|
|
file->WriteBig( edittext->rightMargin );
|
|
|
|
file->WriteBig( edittext->indent );
|
|
|
|
file->WriteBig( edittext->leading );
|
|
|
|
file->WriteString( edittext->variable );
|
|
|
|
file->WriteString( edittext->initialText );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|