diff --git a/stepmania/src/ActorUtil.cpp b/stepmania/src/ActorUtil.cpp index 180bc2f8da..89fcfbd804 100644 --- a/stepmania/src/ActorUtil.cpp +++ b/stepmania/src/ActorUtil.cpp @@ -16,6 +16,7 @@ #include "RageTextureManager.h" #include "SongManager.h" #include "Course.h" +#include "XmlFile.h" #include "FontCharAliases.h" #include "arch/Dialog/Dialog.h" @@ -39,10 +40,12 @@ Actor* LoadFromActorFile( const CString &sIniPath, const CString &sLayer ) Actor* LoadFromActorFile( const CString& sAniDir, const XNode& layer ) { - Actor* pActor = NULL; // fill this in before we return; + Actor* pActor = NULL; // fill this in before we return + + CString sType = layer.m_sName; + if( sType.empty() ) + layer.GetAttrValue( "Type", sType ); - CString sType; - layer.GetAttrValue( "Type", sType ); CString sFile; layer.GetAttrValue( "File", sFile ); FixSlashesInPlace( sFile ); @@ -51,6 +54,12 @@ Actor* LoadFromActorFile( const CString& sAniDir, const XNode& layer ) { pActor = new SongCreditDisplay; } + else if( sType == "BGAnimation" ) + { + BGAnimation *pBGA = new BGAnimation; + pBGA->LoadFromNode( sAniDir, layer ); + pActor = pBGA; + } else { @@ -274,7 +283,14 @@ Actor* MakeActor( const RageTextureID &ID ) CString sExt = GetExtension( ID.filename ); sExt.MakeLower(); - if( sExt=="actor" ) + if( sExt=="xml" ) + { + XNode xml; + xml.LoadFromFile( ID.filename ); + CString sDir = Dirname( ID.filename ); + return LoadFromActorFile( sDir, xml ); + } + else if( sExt=="actor" ) { return LoadFromActorFile( ID.filename ); } diff --git a/stepmania/src/BGAnimation.cpp b/stepmania/src/BGAnimation.cpp index 3af4e89b90..7faece7076 100644 --- a/stepmania/src/BGAnimation.cpp +++ b/stepmania/src/BGAnimation.cpp @@ -30,7 +30,7 @@ void BGAnimation::Unload() DeleteAllChildren(); } -void BGAnimation::LoadFromStaticGraphic( CString sPath ) +void BGAnimation::LoadFromStaticGraphic( const CString &sPath ) { Unload(); @@ -51,11 +51,12 @@ static bool CompareLayerNames( const CString& s1, const CString& s2 ) return i1 < i2; } -void AddLayersFromAniDir( CString sAniDir, vector &layersAddTo, bool Generic ) +void AddLayersFromAniDir( const CString &_sAniDir, vector &layersAddTo, bool Generic ) { - if( sAniDir.empty() ) + if( _sAniDir.empty() ) return; + CString sAniDir = _sAniDir; if( sAniDir.Right(1) != "/" ) sAniDir += "/"; @@ -118,13 +119,14 @@ void AddLayersFromAniDir( CString sAniDir, vector &layersAddTo, bool Gen } } -void BGAnimation::LoadFromAniDir( CString sAniDir ) +void BGAnimation::LoadFromAniDir( const CString &_sAniDir ) { Unload(); - if( sAniDir.empty() ) + if( _sAniDir.empty() ) return; + CString sAniDir = _sAniDir; if( sAniDir.Right(1) != "/" ) sAniDir += "/"; @@ -139,34 +141,19 @@ void BGAnimation::LoadFromAniDir( CString sAniDir ) IniFile ini; ini.ReadFile( sPathToIni ); - if( !ini.GetValue( "BGAnimation", "LengthSeconds", m_fLengthSeconds ) ) - { - /* XXX: if m_bGeneric, simply constructing the BG layer won't run "On", - * so at this point GetMaxTweenTimeLeft is probably 0 */ - m_fLengthSeconds = this->GetTweenTimeLeft(); - } + + const XNode* pBGAnimation = ini.GetChild( "BGAnimation" ); + XNode dummy; + dummy.m_sName = "BGAnimation"; + if( pBGAnimation == NULL ) + pBGAnimation = &dummy; + LoadFromNode( sAniDir, *pBGAnimation ); bool bUseScroller; if( ini.GetValue( "BGAnimation", "UseScroller", bUseScroller ) && bUseScroller ) { ActorScroller::LoadFromIni( ini, "Scroller" ); } - - CString sInitCommand; - if( ini.GetValue( "BGAnimation", "InitCommand", sInitCommand ) ) - { - /* 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 - * in metrics.ini commands, not here. */ - this->RunCommands( ParseCommands(sInitCommand) ); - } - - Command cmd; - cmd.Load( "PlayCommand,Init" ); - this->RunCommandOnChildren( cmd ); - - if( !m_bGeneric ) - PlayCommand( "On" ); } else { @@ -198,7 +185,7 @@ void BGAnimation::LoadFromAniDir( CString sAniDir ) } } -void BGAnimation::LoadFromMovie( CString sMoviePath ) +void BGAnimation::LoadFromMovie( const CString &sMoviePath ) { Unload(); @@ -207,7 +194,7 @@ void BGAnimation::LoadFromMovie( CString sMoviePath ) AddChild( pLayer ); } -void BGAnimation::LoadFromVisualization( CString sVisPath ) +void BGAnimation::LoadFromVisualization( const CString &sVisPath ) { Unload(); BGAnimationLayer* pLayer; @@ -224,6 +211,46 @@ void BGAnimation::LoadFromVisualization( CString sVisPath ) AddChild( pLayer ); } +void BGAnimation::LoadFromNode( const CString &sDir, const XNode& node ) +{ + DEBUG_ASSERT( node.m_sName == "BGAnimation" ); + + + if( !node.GetAttrValue( "LengthSeconds", m_fLengthSeconds ) ) + { + /* XXX: if m_bGeneric, simply constructing the BG layer won't run "On", + * so at this point GetMaxTweenTimeLeft is probably 0 */ + m_fLengthSeconds = this->GetTweenTimeLeft(); + } + + CString sInitCommand; + if( node.GetAttrValue( "InitCommand", sInitCommand ) ) + { + /* 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 + * in metrics.ini commands, not here. */ + this->RunCommands( ParseCommands(sInitCommand) ); + } + + const XNode* pChildren = node.GetChild("children"); + if( pChildren ) + { + FOREACH_CONST_Child( pChildren, pChild ) + { + Actor* pChildActor = LoadFromActorFile( sDir, *pChild ); + AddChild( pChildActor ); + } + } + + + Command cmd; + cmd.Load( "PlayCommand,Init" ); + this->RunCommandOnChildren( cmd ); + + if( !m_bGeneric ) + PlayCommand( "On" ); +} + /* * (c) 2001-2004 Ben Nordstrom, Chris Danford * All rights reserved. diff --git a/stepmania/src/BGAnimation.h b/stepmania/src/BGAnimation.h index 724d440c95..6f8c6edde7 100644 --- a/stepmania/src/BGAnimation.h +++ b/stepmania/src/BGAnimation.h @@ -7,6 +7,8 @@ * is used for many things other than backgrounds. */ #include "ActorScroller.h" +struct XNode; + class BGAnimation : public ActorScroller { public: @@ -15,10 +17,11 @@ public: void Unload(); - void LoadFromStaticGraphic( CString sPath ); - void LoadFromAniDir( CString sAniDir ); - void LoadFromMovie( CString sMoviePath ); - void LoadFromVisualization( CString sMoviePath ); + void LoadFromStaticGraphic( const CString &sPath ); + void LoadFromAniDir( const CString &sAniDir ); + void LoadFromMovie( const CString &sMoviePath ); + void LoadFromVisualization( const CString &sMoviePath ); + void LoadFromNode( const CString &sDir, const XNode& node ); float GetLengthSeconds() const { return m_fLengthSeconds; } diff --git a/stepmania/src/BGAnimationLayer.cpp b/stepmania/src/BGAnimationLayer.cpp index af5e02fc28..424d3a1fc6 100644 --- a/stepmania/src/BGAnimationLayer.cpp +++ b/stepmania/src/BGAnimationLayer.cpp @@ -819,6 +819,7 @@ void BGAnimationLayer::PlayCommand( const CString &sCommandName ) ActorFrame::PlayCommand( sCommandName ); } + /* * (c) 2001-2004 Ben Nordstrom, Chris Danford, Glenn Maynard * All rights reserved. diff --git a/stepmania/src/NoteSkinManager.cpp b/stepmania/src/NoteSkinManager.cpp index 04625b052f..fa944b0914 100644 --- a/stepmania/src/NoteSkinManager.cpp +++ b/stepmania/src/NoteSkinManager.cpp @@ -290,6 +290,7 @@ CString NoteSkinManager::GetPathToFromDir( const CString &sDir, const CString &s CStringArray matches; // fill this with the possible files GetDirListing( sDir+sFileName+"*.redir", matches, false, true ); + GetDirListing( sDir+sFileName+"*.xml", matches, false, true ); GetDirListing( sDir+sFileName+"*.actor", matches, false, true ); GetDirListing( sDir+sFileName+"*.model", matches, false, true ); GetDirListing( sDir+sFileName+"*.txt", matches, false, true ); diff --git a/stepmania/src/ThemeManager.cpp b/stepmania/src/ThemeManager.cpp index 18b4ce28c2..425e5ba5a3 100644 --- a/stepmania/src/ThemeManager.cpp +++ b/stepmania/src/ThemeManager.cpp @@ -333,10 +333,10 @@ try_element_again: for( unsigned p = 0; p < asPaths.size(); ++p ) { - static const char *masks[NUM_ELEMENT_CATEGORIES][12] = { + static const char *masks[NUM_ELEMENT_CATEGORIES][13] = { { "", NULL }, { "ini", NULL }, - { "actor", "sprite", "png", "jpg", "bmp", "gif","avi", "mpg", "mpeg", "txt", "", NULL}, + { "xml", "actor", "sprite", "png", "jpg", "bmp", "gif","avi", "mpg", "mpeg", "txt", "", NULL}, { "png", NULL }, { "mp3", "ogg", "wav", NULL }, { "sm", NULL },