make Actor LoadFromNode signatures consistent

This commit is contained in:
Chris Danford
2005-01-17 05:28:16 +00:00
parent adab436231
commit cda4c3b04a
10 changed files with 66 additions and 64 deletions
+1 -1
View File
@@ -63,7 +63,7 @@ Actor::Actor()
m_bFirstUpdate = true; m_bFirstUpdate = true;
} }
void Actor::LoadFromNode( const XNode* pNode ) void Actor::LoadFromNode( const CString& sDir, const XNode* pNode )
{ {
// Load Name, if any. // Load Name, if any.
pNode->GetAttrValue( "Name", m_sName ); pNode->GetAttrValue( "Name", m_sName );
+1 -1
View File
@@ -19,7 +19,7 @@ public:
Actor(); Actor();
virtual ~Actor() {} virtual ~Actor() {}
virtual void Reset(); virtual void Reset();
void LoadFromNode( const XNode* pNode ); void LoadFromNode( const CString& sDir, const XNode* pNode );
static void SetBGMTime( float fTime, float fBeat ) { g_fCurrentBGMTime = fTime; g_fCurrentBGMBeat = fBeat; } static void SetBGMTime( float fTime, float fBeat ) { g_fCurrentBGMTime = fTime; g_fCurrentBGMBeat = fBeat; }
+3 -3
View File
@@ -17,9 +17,9 @@ ActorFrame::~ActorFrame()
DeleteAllChildren(); DeleteAllChildren();
} }
void ActorFrame::LoadFromNode( const CString &sDir, const XNode* pNode ) void ActorFrame::LoadFromNode( const CString& sDir, const XNode* pNode )
{ {
Actor::LoadFromNode( pNode ); Actor::LoadFromNode( sDir, pNode );
// //
// Load children // Load children
@@ -29,7 +29,7 @@ void ActorFrame::LoadFromNode( const CString &sDir, const XNode* pNode )
{ {
FOREACH_CONST_Child( pChildren, pChild ) FOREACH_CONST_Child( pChildren, pChild )
{ {
Actor* pChildActor = LoadFromActorFile( sDir, *pChild ); Actor* pChildActor = LoadFromActorFile( sDir, pChild );
if( pChildActor ) if( pChildActor )
AddChild( pChildActor ); AddChild( pChildActor );
} }
+1 -1
View File
@@ -11,7 +11,7 @@ public:
ActorFrame(); ActorFrame();
virtual ~ActorFrame(); virtual ~ActorFrame();
void LoadFromNode( const CString &sDir, const XNode* pNode ); void LoadFromNode( const CString& sDir, const XNode* pNode );
virtual void AddChild( Actor* pActor ); virtual void AddChild( Actor* pActor );
virtual void RemoveChild( Actor* pActor ); virtual void RemoveChild( Actor* pActor );
+17 -15
View File
@@ -19,11 +19,13 @@
#include "arch/Dialog/Dialog.h" #include "arch/Dialog/Dialog.h"
Actor* LoadFromActorFile( const CString& sAniDir, const XNode& layer ) Actor* LoadFromActorFile( const CString& sAniDir, const XNode* pNode )
{ {
ASSERT( pNode );
{ {
CString expr; CString expr;
if( layer.GetAttrValue("Condition",expr) ) if( pNode->GetAttrValue("Condition",expr) )
{ {
if( !Lua::RunExpressionB(expr) ) if( !Lua::RunExpressionB(expr) )
return NULL; return NULL;
@@ -35,15 +37,15 @@ Actor* LoadFromActorFile( const CString& sAniDir, const XNode& layer )
// Element name is the type in XML. // Element name is the type in XML.
// Type= is the name in INI. // Type= is the name in INI.
CString sType = layer.m_sName; CString sType = pNode->m_sName;
layer.GetAttrValue( "Type", sType ); pNode->GetAttrValue( "Type", sType );
CString sFile; CString sFile;
layer.GetAttrValue( "File", sFile ); pNode->GetAttrValue( "File", sFile );
FixSlashesInPlace( sFile ); FixSlashesInPlace( sFile );
CString sText; CString sText;
bool bHasText = layer.GetAttrValue( "Text", sText ); bool bHasText = pNode->GetAttrValue( "Text", sText );
// backward compatibility hacks // backward compatibility hacks
if( bHasText ) if( bHasText )
@@ -58,13 +60,13 @@ Actor* LoadFromActorFile( const CString& sAniDir, const XNode& layer )
if( sType == "BGAnimation" ) if( sType == "BGAnimation" )
{ {
BGAnimation *p = new BGAnimation; BGAnimation *p = new BGAnimation;
p->LoadFromNode( sAniDir, layer ); p->LoadFromNode( sAniDir, pNode );
pActor = p; pActor = p;
} }
else if( sType == "ActorFrame" ) else if( sType == "ActorFrame" )
{ {
ActorFrame *p = new ActorFrame; ActorFrame *p = new ActorFrame;
p->LoadFromNode( sAniDir, &layer ); p->LoadFromNode( sAniDir, pNode );
pActor = p; pActor = p;
} }
else if( sType == "BitmapText" ) else if( sType == "BitmapText" )
@@ -83,7 +85,7 @@ Actor* LoadFromActorFile( const CString& sAniDir, const XNode& layer )
* commas or semicolons. It's useful to be able to refer to fonts in the real * commas or semicolons. It's useful to be able to refer to fonts in the real
* theme font dirs, too. */ * theme font dirs, too. */
CString sAlttext; CString sAlttext;
layer.GetAttrValue("AltText", sAlttext ); pNode->GetAttrValue("AltText", sAlttext );
ThemeManager::EvaluateString( sText ); ThemeManager::EvaluateString( sText );
ThemeManager::EvaluateString( sAlttext ); ThemeManager::EvaluateString( sAlttext );
@@ -252,7 +254,7 @@ retry:
ASSERT( pActor ); // we should have filled this in above ASSERT( pActor ); // we should have filled this in above
// TODO: LoadFromNode should be called when we still have a pointer to the derived type. // TODO: LoadFromNode should be called when we still have a pointer to the derived type.
pActor->LoadFromNode( &layer ); pActor->LoadFromNode( sAniDir, pNode );
return pActor; return pActor;
} }
@@ -267,7 +269,7 @@ Actor* MakeActor( const RageTextureID &ID )
XNode xml; XNode xml;
xml.LoadFromFile( ID.filename ); xml.LoadFromFile( ID.filename );
CString sDir = Dirname( ID.filename ); CString sDir = Dirname( ID.filename );
return LoadFromActorFile( sDir, xml ); return LoadFromActorFile( sDir, &xml );
} }
else if( sExt=="actor" ) else if( sExt=="actor" )
{ {
@@ -278,11 +280,11 @@ Actor* MakeActor( const RageTextureID &ID )
CString sDir = Dirname( ID.filename ); CString sDir = Dirname( ID.filename );
const XNode* pLayer = ini.GetChild( "Actor" ); const XNode* pNode = ini.GetChild( "Actor" );
if( pLayer == NULL ) if( pNode == NULL )
RageException::Throw( "The file '%s' doesn't have layer 'Actor'.", ID.filename.c_str() ); RageException::Throw( "The file '%s' doesn't have layer 'Actor'.", ID.filename.c_str() );
return LoadFromActorFile( sDir, *pLayer ); return LoadFromActorFile( sDir, pNode );
} }
else if( sExt=="png" || else if( sExt=="png" ||
sExt=="jpg" || sExt=="jpg" ||
@@ -317,7 +319,7 @@ Actor* MakeActor( const RageTextureID &ID )
{ {
XNode xml; XNode xml;
xml.LoadFromFile( sXml ); xml.LoadFromFile( sXml );
return LoadFromActorFile( sDir, xml ); return LoadFromActorFile( sDir, &xml );
} }
else else
{ {
+1 -1
View File
@@ -33,7 +33,7 @@ inline void UtilOffCommand( Actor* pActor, const CString &sScreenName ) { if(pAc
inline void UtilSetXYAndOnCommand( Actor* pActor, const CString &sScreenName ) { if(pActor) UtilSetXYAndOnCommand( *pActor, sScreenName ); } inline void UtilSetXYAndOnCommand( Actor* pActor, const CString &sScreenName ) { if(pActor) UtilSetXYAndOnCommand( *pActor, sScreenName ); }
// Return a Sprite, BitmapText, or Model depending on the file type // Return a Sprite, BitmapText, or Model depending on the file type
Actor* LoadFromActorFile( const CString& sAniDir, const XNode& layer ); Actor* LoadFromActorFile( const CString& sAniDir, const XNode* pNode );
Actor* MakeActor( const RageTextureID &ID ); Actor* MakeActor( const RageTextureID &ID );
+7 -7
View File
@@ -94,7 +94,7 @@ void BGAnimation::AddLayersFromAniDir( const CString &_sAniDir, const IniFile& i
{ {
// import as a single layer // import as a single layer
BGAnimationLayer* pLayer = new BGAnimationLayer( bGeneric ); BGAnimationLayer* pLayer = new BGAnimationLayer( bGeneric );
pLayer->LoadFromNode( sAniDir, *pKey ); pLayer->LoadFromNode( sAniDir, pKey );
this->AddChild( pLayer ); this->AddChild( pLayer );
} }
} }
@@ -142,7 +142,7 @@ void BGAnimation::LoadFromAniDir( const CString &_sAniDir, bool bGeneric )
pScrollerNode->m_attrs.clear(); pScrollerNode->m_attrs.clear();
} }
LoadFromNode( sAniDir, *pBGAnimation ); LoadFromNode( sAniDir, pBGAnimation );
} }
else else
{ {
@@ -174,12 +174,12 @@ void BGAnimation::LoadFromAniDir( const CString &_sAniDir, bool bGeneric )
} }
} }
void BGAnimation::LoadFromNode( const CString &sDir, const XNode& node ) void BGAnimation::LoadFromNode( const CString& sDir, const XNode* pNode )
{ {
DEBUG_ASSERT( node.m_sName == "BGAnimation" ); DEBUG_ASSERT( pNode->m_sName == "BGAnimation" );
CString sInitCommand; CString sInitCommand;
if( node.GetAttrValue( "InitCommand", sInitCommand ) ) if( pNode->GetAttrValue( "InitCommand", sInitCommand ) )
{ {
/* There's an InitCommand. Run it now. This can be used to eg. change Z to /* There's an InitCommand. Run it now. This can be used to eg. change Z to
* modify draw order between BGAs in a Foreground. Most things should be done * modify draw order between BGAs in a Foreground. Most things should be done
@@ -187,7 +187,7 @@ void BGAnimation::LoadFromNode( const CString &sDir, const XNode& node )
this->RunCommands( ParseCommands(sInitCommand) ); this->RunCommands( ParseCommands(sInitCommand) );
} }
ActorScroller::LoadFromNode( sDir, &node ); ActorScroller::LoadFromNode( sDir, pNode );
Command cmd; Command cmd;
cmd.Load( "PlayCommand,Init" ); cmd.Load( "PlayCommand,Init" );
@@ -197,7 +197,7 @@ void BGAnimation::LoadFromNode( const CString &sDir, const XNode& node )
/* Backwards-compatibility: if a "LengthSeconds" value is present, create a dummy /* Backwards-compatibility: if a "LengthSeconds" value is present, create a dummy
* actor that sleeps for the given length of time. This will extend GetTweenTimeLeft. */ * actor that sleeps for the given length of time. This will extend GetTweenTimeLeft. */
float fLengthSeconds = 0; float fLengthSeconds = 0;
if( node.GetAttrValue( "LengthSeconds", fLengthSeconds ) ) if( pNode->GetAttrValue( "LengthSeconds", fLengthSeconds ) )
{ {
Actor *pActor = new Actor; Actor *pActor = new Actor;
pActor->SetHidden( true ); pActor->SetHidden( true );
+1 -1
View File
@@ -19,7 +19,7 @@ public:
void Unload(); void Unload();
void LoadFromAniDir( const CString &sAniDir, bool bGeneric=true ); void LoadFromAniDir( const CString &sAniDir, bool bGeneric=true );
void LoadFromNode( const CString &sDir, const XNode& node ); void LoadFromNode( const CString& sDir, const XNode* pNode );
protected: protected:
void AddLayersFromAniDir( const CString &_sAniDir, const IniFile& ini, bool bGeneric ); void AddLayersFromAniDir( const CString &_sAniDir, const IniFile& ini, bool bGeneric );
+33 -33
View File
@@ -359,9 +359,9 @@ void BGAnimationLayer::LoadFromAniLayerFile( const CString& sPath )
m_SubActors[i]->SetBlendMode( BLEND_ADD ); m_SubActors[i]->SetBlendMode( BLEND_ADD );
} }
void BGAnimationLayer::LoadFromNode( const CString& sAniDir_, const XNode& layer ) void BGAnimationLayer::LoadFromNode( const CString& sDir, const XNode* pNode )
{ {
CString sAniDir = sAniDir_; CString sAniDir = sDir;
Init(); Init();
if( sAniDir.Right(1) != "/" ) if( sAniDir.Right(1) != "/" )
@@ -374,7 +374,7 @@ void BGAnimationLayer::LoadFromNode( const CString& sAniDir_, const XNode& layer
{ {
CString expr; CString expr;
if( layer.GetAttrValue("Cond",expr) || layer.GetAttrValue("Condition",expr) ) if( pNode->GetAttrValue("Cond",expr) || pNode->GetAttrValue("Condition",expr) )
{ {
if( !Lua::RunExpressionB( expr ) ) if( !Lua::RunExpressionB( expr ) )
return; return;
@@ -384,12 +384,12 @@ void BGAnimationLayer::LoadFromNode( const CString& sAniDir_, const XNode& layer
bool bStretch = false; bool bStretch = false;
{ {
CString type = "sprite"; CString type = "sprite";
layer.GetAttrValue( "Type", type ); pNode->GetAttrValue( "Type", type );
type.MakeLower(); type.MakeLower();
/* The preferred way of stretching a sprite to fit the screen is "Type=sprite" /* The preferred way of stretching a sprite to fit the screen is "Type=sprite"
* and "stretch=1". "type=1" is for backwards-compatibility. */ * and "stretch=1". "type=1" is for backwards-compatibility. */
layer.GetAttrValue( "Stretch", bStretch ); pNode->GetAttrValue( "Stretch", bStretch );
// Check for string match first, then do integer match. // Check for string match first, then do integer match.
// "if(atoi(type)==0)" was matching against all string matches. // "if(atoi(type)==0)" was matching against all string matches.
@@ -425,51 +425,51 @@ void BGAnimationLayer::LoadFromNode( const CString& sAniDir_, const XNode& layer
} }
} }
layer.GetAttrValue( "FOV", m_fFOV ); pNode->GetAttrValue( "FOV", m_fFOV );
layer.GetAttrValue( "Lighting", m_bLighting ); pNode->GetAttrValue( "Lighting", m_bLighting );
layer.GetAttrValue( "TexCoordVelocityX", m_fTexCoordVelocityX ); pNode->GetAttrValue( "TexCoordVelocityX", m_fTexCoordVelocityX );
layer.GetAttrValue( "TexCoordVelocityY", m_fTexCoordVelocityY ); pNode->GetAttrValue( "TexCoordVelocityY", m_fTexCoordVelocityY );
layer.GetAttrValue( "DrawCond", m_sDrawCond ); pNode->GetAttrValue( "DrawCond", m_sDrawCond );
// compat: // compat:
layer.GetAttrValue( "StretchTexCoordVelocityX", m_fTexCoordVelocityX ); pNode->GetAttrValue( "StretchTexCoordVelocityX", m_fTexCoordVelocityX );
layer.GetAttrValue( "StretchTexCoordVelocityY", m_fTexCoordVelocityY ); pNode->GetAttrValue( "StretchTexCoordVelocityY", m_fTexCoordVelocityY );
// particle and tile stuff // particle and tile stuff
float fZoomMin = 1; float fZoomMin = 1;
float fZoomMax = 1; float fZoomMax = 1;
layer.GetAttrValue( "ZoomMin", fZoomMin ); pNode->GetAttrValue( "ZoomMin", fZoomMin );
layer.GetAttrValue( "ZoomMax", fZoomMax ); pNode->GetAttrValue( "ZoomMax", fZoomMax );
float fVelocityXMin = 10, fVelocityXMax = 10; float fVelocityXMin = 10, fVelocityXMax = 10;
float fVelocityYMin = 0, fVelocityYMax = 0; float fVelocityYMin = 0, fVelocityYMax = 0;
float fVelocityZMin = 0, fVelocityZMax = 0; float fVelocityZMin = 0, fVelocityZMax = 0;
float fOverrideSpeed = 0; // 0 means don't override speed float fOverrideSpeed = 0; // 0 means don't override speed
layer.GetAttrValue( "VelocityXMin", fVelocityXMin ); pNode->GetAttrValue( "VelocityXMin", fVelocityXMin );
layer.GetAttrValue( "VelocityXMax", fVelocityXMax ); pNode->GetAttrValue( "VelocityXMax", fVelocityXMax );
layer.GetAttrValue( "VelocityYMin", fVelocityYMin ); pNode->GetAttrValue( "VelocityYMin", fVelocityYMin );
layer.GetAttrValue( "VelocityYMax", fVelocityYMax ); pNode->GetAttrValue( "VelocityYMax", fVelocityYMax );
layer.GetAttrValue( "VelocityZMin", fVelocityZMin ); pNode->GetAttrValue( "VelocityZMin", fVelocityZMin );
layer.GetAttrValue( "VelocityZMax", fVelocityZMax ); pNode->GetAttrValue( "VelocityZMax", fVelocityZMax );
layer.GetAttrValue( "OverrideSpeed", fOverrideSpeed ); pNode->GetAttrValue( "OverrideSpeed", fOverrideSpeed );
int iNumParticles = 10; int iNumParticles = 10;
layer.GetAttrValue( "NumParticles", iNumParticles ); pNode->GetAttrValue( "NumParticles", iNumParticles );
layer.GetAttrValue( "ParticlesBounce", m_bParticlesBounce ); pNode->GetAttrValue( "ParticlesBounce", m_bParticlesBounce );
layer.GetAttrValue( "TilesStartX", m_fTilesStartX ); pNode->GetAttrValue( "TilesStartX", m_fTilesStartX );
layer.GetAttrValue( "TilesStartY", m_fTilesStartY ); pNode->GetAttrValue( "TilesStartY", m_fTilesStartY );
layer.GetAttrValue( "TilesSpacingX", m_fTilesSpacingX ); pNode->GetAttrValue( "TilesSpacingX", m_fTilesSpacingX );
layer.GetAttrValue( "TilesSpacingY", m_fTilesSpacingY ); pNode->GetAttrValue( "TilesSpacingY", m_fTilesSpacingY );
layer.GetAttrValue( "TileVelocityX", m_fTileVelocityX ); pNode->GetAttrValue( "TileVelocityX", m_fTileVelocityX );
layer.GetAttrValue( "TileVelocityY", m_fTileVelocityY ); pNode->GetAttrValue( "TileVelocityY", m_fTileVelocityY );
switch( m_Type ) switch( m_Type )
{ {
case TYPE_SPRITE: case TYPE_SPRITE:
{ {
Actor* pActor = LoadFromActorFile( sAniDir, layer ); Actor* pActor = LoadFromActorFile( sAniDir, pNode );
this->AddChild( pActor ); this->AddChild( pActor );
if( bStretch ) if( bStretch )
pActor->StretchTo( FullScreenRectF ); pActor->StretchTo( FullScreenRectF );
@@ -485,7 +485,7 @@ void BGAnimationLayer::LoadFromNode( const CString& sAniDir_, const XNode& layer
case TYPE_PARTICLES: case TYPE_PARTICLES:
{ {
CString sFile; CString sFile;
layer.GetAttrValue( "File", sFile ); pNode->GetAttrValue( "File", sFile );
FixSlashesInPlace( sFile ); FixSlashesInPlace( sFile );
CString sPath = sAniDir+sFile; CString sPath = sAniDir+sFile;
@@ -516,7 +516,7 @@ void BGAnimationLayer::LoadFromNode( const CString& sAniDir_, const XNode& layer
case TYPE_TILES: case TYPE_TILES:
{ {
CString sFile; CString sFile;
layer.GetAttrValue( "File", sFile ); pNode->GetAttrValue( "File", sFile );
FixSlashesInPlace( sFile ); FixSlashesInPlace( sFile );
CString sPath = sAniDir+sFile; CString sPath = sAniDir+sFile;
@@ -548,7 +548,7 @@ void BGAnimationLayer::LoadFromNode( const CString& sAniDir_, const XNode& layer
} }
bool bStartOnRandomFrame = false; bool bStartOnRandomFrame = false;
layer.GetAttrValue( "StartOnRandomFrame", bStartOnRandomFrame ); pNode->GetAttrValue( "StartOnRandomFrame", bStartOnRandomFrame );
if( bStartOnRandomFrame ) if( bStartOnRandomFrame )
{ {
for( unsigned i=0; i<m_SubActors.size(); i++ ) for( unsigned i=0; i<m_SubActors.size(); i++ )
+1 -1
View File
@@ -18,7 +18,7 @@ public:
void Unload(); void Unload();
void LoadFromAniLayerFile( const CString& sPath ); void LoadFromAniLayerFile( const CString& sPath );
void LoadFromNode( const CString& sAniDir, const XNode& layer ); void LoadFromNode( const CString& sDir, const XNode* pNode );
void Update( float fDeltaTime ); void Update( float fDeltaTime );
void DrawPrimitives(); void DrawPrimitives();