fix default.xml loading
add Condition check in LoadFromActorFile
This commit is contained in:
@@ -30,6 +30,7 @@ void ActorFrame::LoadFromNode( const CString &sDir, const XNode* pNode )
|
|||||||
FOREACH_CONST_Child( pChildren, pChild )
|
FOREACH_CONST_Child( pChildren, pChild )
|
||||||
{
|
{
|
||||||
Actor* pChildActor = LoadFromActorFile( sDir, *pChild );
|
Actor* pChildActor = LoadFromActorFile( sDir, *pChild );
|
||||||
|
if( pChildActor )
|
||||||
AddChild( pChildActor );
|
AddChild( pChildActor );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,7 +159,10 @@ float ActorFrame::GetTweenTimeLeft() const
|
|||||||
float m = Actor::GetTweenTimeLeft();
|
float m = Actor::GetTweenTimeLeft();
|
||||||
|
|
||||||
for( unsigned i=0; i<m_SubActors.size(); i++ )
|
for( unsigned i=0; i<m_SubActors.size(); i++ )
|
||||||
m = max(m, m_fHibernateSecondsLeft + m_SubActors[i]->GetTweenTimeLeft());
|
{
|
||||||
|
const Actor* pActor = m_SubActors[i];
|
||||||
|
m = max(m, m_fHibernateSecondsLeft + pActor->GetTweenTimeLeft());
|
||||||
|
}
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
|
|
||||||
@@ -230,7 +234,10 @@ void ActorFrame::PlayCommand( const CString &sCommandName )
|
|||||||
Actor::PlayCommand( sCommandName );
|
Actor::PlayCommand( sCommandName );
|
||||||
|
|
||||||
for( unsigned i=0; i<m_SubActors.size(); i++ )
|
for( unsigned i=0; i<m_SubActors.size(); i++ )
|
||||||
m_SubActors[i]->PlayCommand( sCommandName );
|
{
|
||||||
|
Actor* pActor = m_SubActors[i];
|
||||||
|
pActor->PlayCommand( sCommandName );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -14,12 +14,23 @@
|
|||||||
#include "Course.h"
|
#include "Course.h"
|
||||||
#include "XmlFile.h"
|
#include "XmlFile.h"
|
||||||
#include "FontCharAliases.h"
|
#include "FontCharAliases.h"
|
||||||
|
#include "LuaHelpers.h"
|
||||||
|
|
||||||
#include "arch/Dialog/Dialog.h"
|
#include "arch/Dialog/Dialog.h"
|
||||||
|
|
||||||
|
|
||||||
Actor* LoadFromActorFile( const CString& sAniDir, const XNode& layer )
|
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
|
Actor* pActor = NULL; // fill this in before we return
|
||||||
|
|
||||||
// Element name is the type in XML.
|
// Element name is the type in XML.
|
||||||
@@ -46,9 +57,15 @@ Actor* LoadFromActorFile( const CString& sAniDir, const XNode& layer )
|
|||||||
|
|
||||||
if( sType == "BGAnimation" )
|
if( sType == "BGAnimation" )
|
||||||
{
|
{
|
||||||
BGAnimation *pBGA = new BGAnimation;
|
BGAnimation *p = new BGAnimation;
|
||||||
pBGA->LoadFromNode( sAniDir, layer );
|
p->LoadFromNode( sAniDir, layer );
|
||||||
pActor = pBGA;
|
pActor = p;
|
||||||
|
}
|
||||||
|
else if( sType == "ActorFrame" )
|
||||||
|
{
|
||||||
|
ActorFrame *p = new ActorFrame;
|
||||||
|
p->LoadFromNode( sAniDir, &layer );
|
||||||
|
pActor = p;
|
||||||
}
|
}
|
||||||
else if( sType == "BitmapText" )
|
else if( sType == "BitmapText" )
|
||||||
{
|
{
|
||||||
@@ -174,6 +191,7 @@ retry:
|
|||||||
/* XXX: We need to do a theme search, since the file we're loading might
|
/* XXX: We need to do a theme search, since the file we're loading might
|
||||||
* be overridden by the theme. */
|
* be overridden by the theme. */
|
||||||
CString sNewPath = sAniDir+sFile;
|
CString sNewPath = sAniDir+sFile;
|
||||||
|
CollapsePath( sNewPath );
|
||||||
|
|
||||||
// If we know this is an exact match, don't bother with the GetDirListing;
|
// If we know this is an exact match, don't bother with the GetDirListing;
|
||||||
// it's causing problems with partial matching BGAnimation directory names.
|
// it's causing problems with partial matching BGAnimation directory names.
|
||||||
@@ -227,13 +245,15 @@ retry:
|
|||||||
sNewPath = DerefRedir( sNewPath );
|
sNewPath = DerefRedir( sNewPath );
|
||||||
|
|
||||||
pActor = MakeActor( 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.
|
// TODO: LoadFromNode should be called when we still have a pointer to the derived type.
|
||||||
pActor->LoadFromNode( &layer );
|
pActor->LoadFromNode( &layer );
|
||||||
|
|
||||||
ASSERT( pActor ); // we should have filled this in above
|
|
||||||
return pActor;
|
return pActor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,7 +307,9 @@ Actor* MakeActor( const RageTextureID &ID )
|
|||||||
/* Do this last, to avoid the IsADirectory in most cases. */
|
/* Do this last, to avoid the IsADirectory in most cases. */
|
||||||
else if( IsADirectory(ID.filename) )
|
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 sIni = sDir + "BGAnimation.ini";
|
||||||
CString sXml = sDir + "default.xml";
|
CString sXml = sDir + "default.xml";
|
||||||
|
|
||||||
|
|||||||
@@ -495,6 +495,8 @@ void BGAnimationLayer::LoadFromNode( const CString& sAniDir_, const XNode& layer
|
|||||||
for( int i=0; i<iNumParticles; i++ )
|
for( int i=0; i<iNumParticles; i++ )
|
||||||
{
|
{
|
||||||
Actor* pActor = MakeActor( sPath );
|
Actor* pActor = MakeActor( sPath );
|
||||||
|
if( pActor == NULL )
|
||||||
|
continue;
|
||||||
this->AddChild( pActor );
|
this->AddChild( pActor );
|
||||||
pActor->SetXY( randomf(float(FullScreenRectF.left),float(FullScreenRectF.right)),
|
pActor->SetXY( randomf(float(FullScreenRectF.left),float(FullScreenRectF.right)),
|
||||||
randomf(float(FullScreenRectF.top),float(FullScreenRectF.bottom)) );
|
randomf(float(FullScreenRectF.top),float(FullScreenRectF.bottom)) );
|
||||||
|
|||||||
@@ -128,7 +128,10 @@ static NoteResource *MakeNoteResource( const CString &sPath, bool bSpriteOnly )
|
|||||||
pRes->m_pActor = pSprite;
|
pRes->m_pActor = pSprite;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
pRes->m_pActor = MakeActor( sPath );
|
pRes->m_pActor = MakeActor( sPath );
|
||||||
|
ASSERT( pRes->m_pActor );
|
||||||
|
}
|
||||||
|
|
||||||
g_NoteResource[sPath] = pRes;
|
g_NoteResource[sPath] = pRes;
|
||||||
it = g_NoteResource.find( sPath );
|
it = g_NoteResource.find( sPath );
|
||||||
|
|||||||
Reference in New Issue
Block a user