From a5d40aad79c72aef38f39a134150a3ec06d79a5a Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Mon, 17 Jan 2005 04:08:08 +0000 Subject: [PATCH] fix default.xml loading add Condition check in LoadFromActorFile --- stepmania/src/ActorFrame.cpp | 13 +++++++++--- stepmania/src/ActorUtil.cpp | 32 +++++++++++++++++++++++++----- stepmania/src/BGAnimationLayer.cpp | 2 ++ stepmania/src/NoteDisplay.cpp | 3 +++ 4 files changed, 42 insertions(+), 8 deletions(-) diff --git a/stepmania/src/ActorFrame.cpp b/stepmania/src/ActorFrame.cpp index 810f3e938b..c5fe8c49ef 100644 --- a/stepmania/src/ActorFrame.cpp +++ b/stepmania/src/ActorFrame.cpp @@ -30,7 +30,8 @@ void ActorFrame::LoadFromNode( const CString &sDir, const XNode* pNode ) FOREACH_CONST_Child( pChildren, pChild ) { Actor* pChildActor = LoadFromActorFile( sDir, *pChild ); - AddChild( pChildActor ); + if( pChildActor ) + AddChild( pChildActor ); } } } @@ -158,7 +159,10 @@ float ActorFrame::GetTweenTimeLeft() const float m = Actor::GetTweenTimeLeft(); for( unsigned i=0; iGetTweenTimeLeft()); + { + const Actor* pActor = m_SubActors[i]; + m = max(m, m_fHibernateSecondsLeft + pActor->GetTweenTimeLeft()); + } return m; @@ -230,7 +234,10 @@ void ActorFrame::PlayCommand( const CString &sCommandName ) Actor::PlayCommand( sCommandName ); for( unsigned i=0; iPlayCommand( sCommandName ); + { + Actor* pActor = m_SubActors[i]; + pActor->PlayCommand( sCommandName ); + } } /* diff --git a/stepmania/src/ActorUtil.cpp b/stepmania/src/ActorUtil.cpp index b793c7f6ca..7ed8b05ac3 100644 --- a/stepmania/src/ActorUtil.cpp +++ b/stepmania/src/ActorUtil.cpp @@ -14,12 +14,23 @@ #include "Course.h" #include "XmlFile.h" #include "FontCharAliases.h" +#include "LuaHelpers.h" #include "arch/Dialog/Dialog.h" Actor* LoadFromActorFile( const CString& sAniDir, const XNode& layer ) { + { + CString expr; + if( layer.GetAttrValue("Condition",expr) ) + { + if( !Lua::RunExpressionB(expr) ) + return NULL; + } + } + + Actor* pActor = NULL; // fill this in before we return // Element name is the type in XML. @@ -46,9 +57,15 @@ Actor* LoadFromActorFile( const CString& sAniDir, const XNode& layer ) if( sType == "BGAnimation" ) { - BGAnimation *pBGA = new BGAnimation; - pBGA->LoadFromNode( sAniDir, layer ); - pActor = pBGA; + BGAnimation *p = new BGAnimation; + p->LoadFromNode( sAniDir, layer ); + pActor = p; + } + else if( sType == "ActorFrame" ) + { + ActorFrame *p = new ActorFrame; + p->LoadFromNode( sAniDir, &layer ); + pActor = p; } else if( sType == "BitmapText" ) { @@ -174,6 +191,7 @@ retry: /* XXX: We need to do a theme search, since the file we're loading might * be overridden by the theme. */ CString sNewPath = sAniDir+sFile; + CollapsePath( sNewPath ); // If we know this is an exact match, don't bother with the GetDirListing; // it's causing problems with partial matching BGAnimation directory names. @@ -227,13 +245,15 @@ retry: sNewPath = DerefRedir( sNewPath ); pActor = MakeActor( sNewPath ); + if( pActor == NULL ) + return NULL; } + ASSERT( pActor ); // we should have filled this in above // TODO: LoadFromNode should be called when we still have a pointer to the derived type. pActor->LoadFromNode( &layer ); - ASSERT( pActor ); // we should have filled this in above return pActor; } @@ -287,7 +307,9 @@ Actor* MakeActor( const RageTextureID &ID ) /* Do this last, to avoid the IsADirectory in most cases. */ else if( IsADirectory(ID.filename) ) { - const CString& sDir = ID.filename; + CString sDir = ID.filename; + if( sDir.Right(1) != "/" ) + sDir += '/'; CString sIni = sDir + "BGAnimation.ini"; CString sXml = sDir + "default.xml"; diff --git a/stepmania/src/BGAnimationLayer.cpp b/stepmania/src/BGAnimationLayer.cpp index c8a4c44ac6..e2c8498013 100644 --- a/stepmania/src/BGAnimationLayer.cpp +++ b/stepmania/src/BGAnimationLayer.cpp @@ -495,6 +495,8 @@ void BGAnimationLayer::LoadFromNode( const CString& sAniDir_, const XNode& layer for( int i=0; iAddChild( pActor ); pActor->SetXY( randomf(float(FullScreenRectF.left),float(FullScreenRectF.right)), randomf(float(FullScreenRectF.top),float(FullScreenRectF.bottom)) ); diff --git a/stepmania/src/NoteDisplay.cpp b/stepmania/src/NoteDisplay.cpp index 38710ff185..c8cd3264e4 100644 --- a/stepmania/src/NoteDisplay.cpp +++ b/stepmania/src/NoteDisplay.cpp @@ -128,7 +128,10 @@ static NoteResource *MakeNoteResource( const CString &sPath, bool bSpriteOnly ) pRes->m_pActor = pSprite; } else + { pRes->m_pActor = MakeActor( sPath ); + ASSERT( pRes->m_pActor ); + } g_NoteResource[sPath] = pRes; it = g_NoteResource.find( sPath );