From 77ece5a414f34fe4b0d13b95d2d8f4cf1fdba0ae Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Sun, 13 Oct 2013 17:44:25 -0400 Subject: [PATCH] Process FT_Xml as legacy actors Everything from here on out is edge cases. --- src/ActorUtil.cpp | 22 ++++++++++++++++++++++ src/Background.cpp | 10 +++++++++- src/Foreground.cpp | 8 +++++++- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/ActorUtil.cpp b/src/ActorUtil.cpp index a8053a0d82..29046e9f19 100644 --- a/src/ActorUtil.cpp +++ b/src/ActorUtil.cpp @@ -37,6 +37,9 @@ void ActorUtil::Register( const RString& sClassName, CreateActorFn pfn ) (*g_pmapRegistrees)[sClassName] = pfn; } +/* Resolves actor paths a la LoadActor("..."), with autowildcarding and .redir + * files. Returns a path *within* the Rage filesystem, unlike the FILEMAN + * function of the same name. */ bool ActorUtil::ResolvePath( RString &sPath, const RString &sName ) { CollapsePath( sPath ); @@ -311,10 +314,28 @@ Actor* ActorUtil::MakeActor( const RString &sPath_, Actor *pParentActor ) Actor *pRet = ActorUtil::LoadFromNode( pNode.get(), pParentActor ); return pRet; } + case FT_Xml: + { + // Legacy actors; only supported in quirks mode + if ( !PREFSMAN->m_bQuirksMode ) + return new Actor; + + XNode xml; + if ( !XmlFileUtil::LoadFromFileShowErrors(xml, sPath) ) + return new Actor; + XmlFileUtil::CompileXNodeTree( &xml, sPath ); + XmlFileUtil::AnnotateXNodeTree( &xml, sPath ); + return LoadFromNode( &xml, pParentActor ); + } case FT_Directory: { if( sPath.Right(1) != "/" ) sPath += '/'; + + RString sXml = sPath + "default.xml"; + if (DoesFileExist(sXml)) + return MakeActor(sXml, pParentActor); + XNode xml; xml.AppendAttr( "Class", "BGAnimation" ); xml.AppendAttr( "AniDir", sPath ); @@ -491,6 +512,7 @@ FileType ActorUtil::GetFileType( const RString &sPath ) sExt.MakeLower(); if( sExt=="lua" ) return FT_Lua; + else if(sExt=="xml") return FT_Xml; else if( sExt=="png" || sExt=="jpg" || diff --git a/src/Background.cpp b/src/Background.cpp index d4614f0528..1dcccecb84 100644 --- a/src/Background.cpp +++ b/src/Background.cpp @@ -335,11 +335,19 @@ bool BackgroundImpl::Layer::CreateBackground( const Song *pSong, const Backgroun case FT_Movie: sEffect = SBE_StretchNormal; break; - case FT_Directory: case FT_Lua: case FT_Model: sEffect = SBE_UpperLeft; break; + case FT_Xml: + sEffect = SBE_Centered; + break; + case FT_Directory: + if( DoesFileExist(vsResolved[0] + "/default.lua") ) + sEffect = SBE_UpperLeft; + else + sEffect = SBE_Centered; + break; } } ASSERT( !sEffect.empty() ); diff --git a/src/Foreground.cpp b/src/Foreground.cpp index d14ce0d107..38d73b6ff1 100644 --- a/src/Foreground.cpp +++ b/src/Foreground.cpp @@ -2,6 +2,7 @@ #include "Foreground.h" #include "RageUtil.h" #include "GameState.h" +#include "PrefsManager.h" #include "RageTextureManager.h" #include "ActorUtil.h" #include "Song.h" @@ -34,13 +35,18 @@ void Foreground::LoadFromSong( const Song *pSong ) { const BackgroundChange &change = *bgc; RString sBGName = change.m_def.m_sFile1, - sLuaFile = pSong->GetSongDir() + sBGName + "/default.lua"; + sLuaFile = pSong->GetSongDir() + sBGName + "/default.lua", + sXmlFile = pSong->GetSongDir() + sBGName + "/default.xml"; LoadedBGA bga; if ( DoesFileExist( sLuaFile ) ) { bga.m_bga = ActorUtil::MakeActor( sLuaFile, this ); } + else if ( PREFSMAN->m_bQuirksMode && DoesFileExist( sXmlFile ) ) + { + bga.m_bga = ActorUtil::MakeActor( sXmlFile, this ); + } else { bga.m_bga = ActorUtil::MakeActor( pSong->GetSongDir() + sBGName, this );