eliminate redundant INI read
This commit is contained in:
@@ -34,21 +34,9 @@ static bool CompareLayerNames( const CString& s1, const CString& s2 )
|
|||||||
return i1 < i2;
|
return i1 < i2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BGAnimation::AddLayersFromAniDir( const CString &_sAniDir, vector<Actor*> &layersAddTo, bool bGeneric )
|
void BGAnimation::AddLayersFromAniDir( const CString &_sAniDir, const IniFile& ini, bool bGeneric )
|
||||||
{
|
{
|
||||||
if( _sAniDir.empty() )
|
const CString& sAniDir = _sAniDir;
|
||||||
return;
|
|
||||||
|
|
||||||
CString sAniDir = _sAniDir;
|
|
||||||
if( sAniDir.Right(1) != "/" )
|
|
||||||
sAniDir += "/";
|
|
||||||
|
|
||||||
ASSERT_M( IsADirectory(sAniDir), sAniDir + " isn't a directory" );
|
|
||||||
|
|
||||||
CString sPathToIni = sAniDir + "BGAnimation.ini";
|
|
||||||
|
|
||||||
IniFile ini;
|
|
||||||
ini.ReadFile( sPathToIni );
|
|
||||||
|
|
||||||
{
|
{
|
||||||
CString expr;
|
CString expr;
|
||||||
@@ -90,14 +78,24 @@ void BGAnimation::AddLayersFromAniDir( const CString &_sAniDir, vector<Actor*> &
|
|||||||
sImportDir = sAniDir + sImportDir;
|
sImportDir = sAniDir + sImportDir;
|
||||||
CollapsePath( sImportDir );
|
CollapsePath( sImportDir );
|
||||||
|
|
||||||
AddLayersFromAniDir( sImportDir, layersAddTo, bGeneric );
|
if( sImportDir.Right(1) != "/" )
|
||||||
|
sImportDir += "/";
|
||||||
|
|
||||||
|
ASSERT_M( IsADirectory(sImportDir), sImportDir + " isn't a directory" );
|
||||||
|
|
||||||
|
CString sPathToIni = sImportDir + "BGAnimation.ini";
|
||||||
|
|
||||||
|
IniFile ini2;
|
||||||
|
ini2.ReadFile( sPathToIni );
|
||||||
|
|
||||||
|
AddLayersFromAniDir( sImportDir, ini2, bGeneric );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 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 );
|
||||||
layersAddTo.push_back( pLayer );
|
this->AddChild( pLayer );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,11 +119,10 @@ void BGAnimation::LoadFromAniDir( const CString &_sAniDir, bool bGeneric )
|
|||||||
if( DoesFileExist(sPathToIni) )
|
if( DoesFileExist(sPathToIni) )
|
||||||
{
|
{
|
||||||
// This is a new style BGAnimation (using .ini)
|
// This is a new style BGAnimation (using .ini)
|
||||||
|
|
||||||
IniFile ini;
|
IniFile ini;
|
||||||
ini.ReadFile( sPathToIni );
|
ini.ReadFile( sPathToIni );
|
||||||
|
|
||||||
AddLayersFromAniDir( sAniDir, m_SubActors, bGeneric ); // TODO: Check for circular load
|
AddLayersFromAniDir( sAniDir, ini, bGeneric ); // TODO: Check for circular load
|
||||||
|
|
||||||
XNode* pBGAnimation = ini.GetChild( "BGAnimation" );
|
XNode* pBGAnimation = ini.GetChild( "BGAnimation" );
|
||||||
XNode dummy;
|
XNode dummy;
|
||||||
@@ -146,7 +143,6 @@ void BGAnimation::LoadFromAniDir( const CString &_sAniDir, bool bGeneric )
|
|||||||
}
|
}
|
||||||
|
|
||||||
LoadFromNode( sAniDir, *pBGAnimation );
|
LoadFromNode( sAniDir, *pBGAnimation );
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -197,6 +193,7 @@ void BGAnimation::LoadFromNode( const CString &sDir, const XNode& node )
|
|||||||
cmd.Load( "PlayCommand,Init" );
|
cmd.Load( "PlayCommand,Init" );
|
||||||
this->RunCommandOnChildren( cmd );
|
this->RunCommandOnChildren( cmd );
|
||||||
|
|
||||||
|
|
||||||
/* 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;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "ActorScroller.h"
|
#include "ActorScroller.h"
|
||||||
|
|
||||||
struct XNode;
|
struct XNode;
|
||||||
|
class IniFile;
|
||||||
|
|
||||||
class BGAnimation : public ActorScroller
|
class BGAnimation : public ActorScroller
|
||||||
{
|
{
|
||||||
@@ -21,7 +22,7 @@ public:
|
|||||||
void LoadFromNode( const CString &sDir, const XNode& node );
|
void LoadFromNode( const CString &sDir, const XNode& node );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void AddLayersFromAniDir( const CString &_sAniDir, vector<Actor*> &layersAddTo, bool bGeneric );
|
void AddLayersFromAniDir( const CString &_sAniDir, const IniFile& ini, bool bGeneric );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user