Add "Import" feature to BGAnimations

This commit is contained in:
Chris Danford
2003-10-14 17:05:10 +00:00
parent b8545459fe
commit 278e7cd57d
+43 -8
View File
@@ -19,6 +19,7 @@
#include "RageUtil.h" #include "RageUtil.h"
#include "song.h" #include "song.h"
#include "ThemeManager.h" #include "ThemeManager.h"
#include "RageFile.h"
const int MAX_LAYERS = 100; const int MAX_LAYERS = 100;
@@ -48,20 +49,18 @@ void BGAnimation::LoadFromStaticGraphic( CString sPath )
m_Layers.push_back( pLayer ); m_Layers.push_back( pLayer );
} }
void BGAnimation::LoadFromAniDir( CString sAniDir ) void AddLayersFromAniDir( CString sAniDir, vector<BGAnimationLayer*> &layersAddTo )
{ {
Unload(); if( sAniDir.empty() )
return;
if( !sAniDir.empty() && sAniDir.Right(1) != SLASH ) if( sAniDir.Right(1) != SLASH )
sAniDir += SLASH; sAniDir += SLASH;
RAGE_ASSERT_M( IsADirectory(sAniDir), sAniDir + " isn't a directory" ); RAGE_ASSERT_M( IsADirectory(sAniDir), sAniDir + " isn't a directory" );
CString sPathToIni = sAniDir + "BGAnimation.ini"; CString sPathToIni = sAniDir + "BGAnimation.ini";
if( DoesFileExist(sPathToIni) )
{
// This is a new style BGAnimation (using .ini)
IniFile ini(sPathToIni); IniFile ini(sPathToIni);
ini.ReadFile(); ini.ReadFile();
@@ -72,15 +71,51 @@ void BGAnimation::LoadFromAniDir( CString sAniDir )
const IniFile::key* pKey = ini.GetKey( sLayer ); const IniFile::key* pKey = ini.GetKey( sLayer );
if( pKey == NULL ) if( pKey == NULL )
continue; // skip continue; // skip
CString sImportDir;
if( ini.GetValue(sLayer, "Import", sImportDir) )
{
// import a whole BGAnimation
sImportDir = sAniDir + sImportDir;
CollapsePath( sImportDir );
AddLayersFromAniDir( sImportDir, layersAddTo );
}
else
{
// import a single layer
BGAnimationLayer* pLayer = new BGAnimationLayer; BGAnimationLayer* pLayer = new BGAnimationLayer;
pLayer->LoadFromIni( sAniDir, sLayer ); pLayer->LoadFromIni( sAniDir, sLayer );
m_Layers.push_back( pLayer ); layersAddTo.push_back( pLayer );
}
} }
}
void BGAnimation::LoadFromAniDir( CString sAniDir )
{
Unload();
if( sAniDir.empty() )
return;
if( sAniDir.Right(1) != SLASH )
sAniDir += SLASH;
RAGE_ASSERT_M( IsADirectory(sAniDir), sAniDir + " isn't a directory" );
CString sPathToIni = sAniDir + "BGAnimation.ini";
if( DoesFileExist(sPathToIni) )
{
// This is a new style BGAnimation (using .ini)
AddLayersFromAniDir( sAniDir, m_Layers ); // TODO: Check for circular load
IniFile ini(sPathToIni);
ini.ReadFile();
if( !ini.GetValue( "BGAnimation", "LengthSeconds", m_fLengthSeconds ) ) if( !ini.GetValue( "BGAnimation", "LengthSeconds", m_fLengthSeconds ) )
{ {
m_fLengthSeconds = 0; m_fLengthSeconds = 0;
for( i=0; (unsigned)i < m_Layers.size(); i++ ) for( int i=0; (unsigned)i < m_Layers.size(); i++ )
m_fLengthSeconds = max(m_fLengthSeconds, m_Layers[i]->GetMaxTweenTimeLeft()); m_fLengthSeconds = max(m_fLengthSeconds, m_Layers[i]->GetMaxTweenTimeLeft());
} }
} }