diff --git a/stepmania/src/ActorFrame.cpp b/stepmania/src/ActorFrame.cpp index 19ecfbe964..cf692787e0 100644 --- a/stepmania/src/ActorFrame.cpp +++ b/stepmania/src/ActorFrame.cpp @@ -19,31 +19,6 @@ LUA_REGISTER_CLASS( ActorFrame ) * that string instead create an ActorFrameAutoDeleteChildren object. */ //REGISTER_ACTOR_CLASS( ActorFrame ) -class ActorFrameAutoDeleteChildren : public ActorFrame -{ -public: - ActorFrameAutoDeleteChildren() { DeleteChildrenWhenDone(true); } - void LoadFromNode( const CString& sDir, const XNode* pNode ) - { - ActorFrame::LoadFromNode( sDir, pNode ); - - // - // Load children - // - const XNode* pChildren = pNode->GetChild("children"); - if( pChildren ) - { - FOREACH_CONST_Child( pChildren, pChild ) - { - Actor* pChildActor = ActorUtil::LoadFromActorFile( sDir, pChild ); - if( pChildActor ) - AddChild( pChildActor ); - } - SortByDrawOrder(); - } - } - -}; REGISTER_ACTOR_CLASS_WITH_NAME( ActorFrameAutoDeleteChildren, ActorFrame ) @@ -72,6 +47,27 @@ void ActorFrame::LoadFromNode( const CString& sDir, const XNode* pNode ) m_bOverrideLighting = pNode->GetAttrValue( "Lighting", m_bLighting ); } +void ActorFrame::LoadChildrenFromNode( const CString& sDir, const XNode* pNode ) +{ + // Shoudn't be calling this unless we're going to delete our children. + ASSERT( m_bDeleteChildren ); + + // + // Load children + // + const XNode* pChildren = pNode->GetChild("children"); + if( pChildren ) + { + FOREACH_CONST_Child( pChildren, pChild ) + { + Actor* pChildActor = ActorUtil::LoadFromActorFile( sDir, pChild ); + if( pChildActor ) + AddChild( pChildActor ); + } + SortByDrawOrder(); + } +} + void ActorFrame::AddChild( Actor* pActor ) { #if _DEBUG diff --git a/stepmania/src/ActorFrame.h b/stepmania/src/ActorFrame.h index 7423b2bc9e..0e943866a6 100644 --- a/stepmania/src/ActorFrame.h +++ b/stepmania/src/ActorFrame.h @@ -27,6 +27,7 @@ public: virtual ~ActorFrame(); void LoadFromNode( const CString& sDir, const XNode* pNode ); + void LoadChildrenFromNode( const CString& sDir, const XNode* pNode ); virtual void AddChild( Actor* pActor ); virtual void RemoveChild( Actor* pActor ); @@ -79,6 +80,18 @@ protected: bool m_bLighting; }; +class ActorFrameAutoDeleteChildren : public ActorFrame +{ +public: + ActorFrameAutoDeleteChildren() { DeleteChildrenWhenDone(true); } + void LoadFromNode( const CString& sDir, const XNode* pNode ) + { + ActorFrame::LoadFromNode( sDir, pNode ); + + LoadChildrenFromNode( sDir, pNode ); + } +}; + #endif /* diff --git a/stepmania/src/ActorScroller.cpp b/stepmania/src/ActorScroller.cpp index 39132c5bdd..b5be7357fc 100644 --- a/stepmania/src/ActorScroller.cpp +++ b/stepmania/src/ActorScroller.cpp @@ -6,6 +6,16 @@ #include "IniFile.h" #include "arch/Dialog/Dialog.h" #include "RageLog.h" +#include "ActorUtil.h" + +/* Tricky: We need ActorFrames created in XML to auto delete their children. + * We don't want classes that derive from ActorFrame to auto delete their + * children. The name "ActorFrame" is widely used in XML, so we'll have + * that string instead create an ActorFrameAutoDeleteChildren object. + */ +//REGISTER_ACTOR_CLASS( ActorScroller ) +REGISTER_ACTOR_CLASS_WITH_NAME( ActorScrollerAutoDeleteChildren, ActorScroller ) + ActorScroller::ActorScroller() { diff --git a/stepmania/src/ActorScroller.h b/stepmania/src/ActorScroller.h index 086f934b5d..3416a0a20e 100644 --- a/stepmania/src/ActorScroller.h +++ b/stepmania/src/ActorScroller.h @@ -46,6 +46,18 @@ protected: RageVector3 m_vTranslateTerm2; }; +class ActorScrollerAutoDeleteChildren : public ActorScroller +{ +public: + ActorScrollerAutoDeleteChildren() { DeleteChildrenWhenDone(true); } + void LoadFromNode( const CString& sDir, const XNode* pNode ) + { + ActorScroller::LoadFromNode( sDir, pNode ); + + LoadChildrenFromNode( sDir, pNode ); + } +}; + #endif /* diff --git a/stepmania/src/BGAnimation.cpp b/stepmania/src/BGAnimation.cpp index cc6905cbbe..4cbdd356e0 100644 --- a/stepmania/src/BGAnimation.cpp +++ b/stepmania/src/BGAnimation.cpp @@ -181,7 +181,7 @@ void BGAnimation::LoadFromNode( const CString& sDir, const XNode* pNode ) { DEBUG_ASSERT( pNode->m_sName == "BGAnimation" ); - ActorScroller::LoadFromNode( sDir, pNode ); + ActorScrollerAutoDeleteChildren::LoadFromNode( sDir, pNode ); this->RunCommandsOnChildren( ActorCommands("PlayCommand,Init") ); diff --git a/stepmania/src/BGAnimation.h b/stepmania/src/BGAnimation.h index 4edce0ff4d..6b1a4891d6 100644 --- a/stepmania/src/BGAnimation.h +++ b/stepmania/src/BGAnimation.h @@ -10,7 +10,7 @@ struct XNode; class IniFile; -class BGAnimation : public ActorScroller +class BGAnimation : public ActorScrollerAutoDeleteChildren { public: BGAnimation();