Simplify: Move LoadChildrenFromNode into ActorFrame::LoadFromNode.

This also makes loading consistent between ActorFrame, ActorScroller and DActorScroller.
Previously, we ran ActorFrame::LoadFromNode before adding children, which caused InitCommand
to be run before adding children.
This commit is contained in:
Glenn Maynard
2005-10-07 02:55:47 +00:00
parent f875098dac
commit 91815ef03e
4 changed files with 9 additions and 25 deletions
+3
View File
@@ -69,6 +69,9 @@ ActorFrame::ActorFrame( const ActorFrame &cpy ):
void ActorFrame::LoadFromNode( const CString& sDir, const XNode* pNode )
{
if( AutoLoadChildren() )
LoadChildrenFromNode( sDir, pNode );
Actor::LoadFromNode( sDir, pNode );
pNode->GetAttrValue( "UpdateRate", m_fUpdateRate );
+4 -7
View File
@@ -13,7 +13,6 @@ public:
virtual ~ActorFrame();
void LoadFromNode( const CString& sDir, const XNode* pNode );
void LoadChildrenFromNode( const CString& sDir, const XNode* pNode );
virtual Actor *Copy() const;
virtual void AddChild( Actor* pActor );
@@ -27,6 +26,7 @@ public:
void SortByDrawOrder();
void SetDrawByZPosition( bool b );
virtual bool AutoLoadChildren() const { return false; } // derived classes override to automatically LoadChildrenFromNode
void DeleteChildrenWhenDone( bool bDelete=true ) { m_bDeleteChildren = bDelete; }
void DeleteAllChildren();
@@ -66,6 +66,8 @@ public:
void RunCommands( const apActorCommands& cmds, Actor *pParent = NULL ) { this->RunCommands( *cmds, pParent ); } // convenience
protected:
void LoadChildrenFromNode( const CString& sDir, const XNode* pNode );
vector<Actor*> m_SubActors;
bool m_bPropagateCommands;
bool m_bDeleteChildren;
@@ -84,12 +86,7 @@ class ActorFrameAutoDeleteChildren : public ActorFrame
{
public:
ActorFrameAutoDeleteChildren() { DeleteChildrenWhenDone(true); }
void LoadFromNode( const CString& sDir, const XNode* pNode )
{
ActorFrame::LoadFromNode( sDir, pNode );
LoadChildrenFromNode( sDir, pNode );
}
virtual bool AutoLoadChildren() const { return true; }
virtual Actor *Copy() const;
};
+1 -9
View File
@@ -78,15 +78,7 @@ class ActorScrollerAutoDeleteChildren : public ActorScroller
{
public:
ActorScrollerAutoDeleteChildren() { DeleteChildrenWhenDone(true); }
void LoadFromNode( const CString& sDir, const XNode* pNode )
{
// Load children. ActorScroller doesn't do this, because it
// can be a base class for other objects that don't want to load
// from <children>.
LoadChildrenFromNode( sDir, pNode );
ActorScroller::LoadFromNode( sDir, pNode );
}
virtual bool AutoLoadChildren() const { return true; }
virtual Actor *Copy() const;
};
+1 -9
View File
@@ -23,15 +23,7 @@ class DynamicActorScrollerAutoDeleteChildren: public DynamicActorScroller
{
public:
DynamicActorScrollerAutoDeleteChildren() { DeleteChildrenWhenDone(true); }
void LoadFromNode( const CString& sDir, const XNode* pNode )
{
// Load children. ActorScroller doesn't do this, because it
// can be a base class for other objects that don't want to load
// from <children>.
LoadChildrenFromNode( sDir, pNode );
DynamicActorScroller::LoadFromNode( sDir, pNode );
}
virtual bool AutoLoadChildren() const { return true; }
virtual Actor *Copy() const;
};