diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index cacb91c023..47172ea93e 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -848,12 +848,7 @@ void Actor::AddRotationR( float rot ) RageQuatMultiply( &DestTweenState().quat, DestTweenState().quat, RageQuatFromR(rot) ); } -void Actor::RunCommands( const LuaReference& cmds ) -{ - RunCommands2( cmds, NULL ); -} - -void Actor::RunCommands2( const LuaReference& cmds, Actor *pParent ) +void Actor::RunCommands( const LuaReference& cmds, Actor *pParent ) { // function cmds.PushSelf( LUA->L ); @@ -1064,12 +1059,7 @@ const apActorCommands& Actor::GetCommand( const CString &sCommandName ) const return it->second; } -void Actor::PlayCommand( const CString &sCommandName ) -{ - PlayCommand2( sCommandName, NULL ); -} - -void Actor::PlayCommand2( const CString &sCommandName, Actor *pParent ) +void Actor::PlayCommand( const CString &sCommandName, Actor *pParent ) { map::const_iterator it = m_mapNameToCommands.find( sCommandName ); diff --git a/stepmania/src/Actor.h b/stepmania/src/Actor.h index 93835b8082..b32a4119b7 100644 --- a/stepmania/src/Actor.h +++ b/stepmania/src/Actor.h @@ -337,13 +337,11 @@ public: void AddCommand( const CString &sCmdName, apActorCommands apac ); bool HasCommand( const CString &sCmdName ); const apActorCommands& GetCommand( const CString &sCommandName ) const; - virtual void PlayCommand( const CString &sCommandName ); - virtual void PlayCommand2( const CString &sCommandName, Actor *pParent ); - virtual void RunCommands( const LuaReference& cmds ); - virtual void RunCommands2( const LuaReference& cmds, Actor *pParent ); - void RunCommands( const apActorCommands& cmds ) { this->RunCommands( *cmds ); } // convenience - void RunCommands2( const apActorCommands& cmds, Actor *pParent ) { this->RunCommands2( *cmds, pParent ); } // convenience - virtual void RunCommandsOnLeaves( const LuaReference& cmds ) { RunCommands(cmds); } + virtual void PlayCommand( const CString &sCommandName, Actor *pParent = NULL ); + virtual void RunCommands( const LuaReference& cmds, Actor *pParent = NULL ); + void RunCommands( const apActorCommands& cmds, Actor *pParent = NULL ) { this->RunCommands( *cmds, pParent ); } // convenience + // If we're a leaf, then execute this command. + virtual void RunCommandsOnLeaves( const LuaReference& cmds, Actor *pParent = NULL ) { RunCommands(cmds,pParent); } static float GetCommandsLengthSeconds( const LuaReference& cmds ); static float GetCommandsLengthSeconds( const apActorCommands& cmds ) { return GetCommandsLengthSeconds( *cmds ); } // convenience @@ -567,7 +565,7 @@ public: static int hidden( T* p, lua_State *L ) { p->SetHidden(!!IArg(1)); return 0; } static int hibernate( T* p, lua_State *L ) { p->SetHibernate(FArg(1)); return 0; } static int draworder( T* p, lua_State *L ) { p->SetDrawOrder(IArg(1)); return 0; } - static int playcommand( T* p, lua_State *L ) { p->PlayCommand(SArg(1)); return 0; } + static int playcommand( T* p, lua_State *L ) { p->PlayCommand(SArg(1),NULL); return 0; } static int queuecommand( T* p, lua_State *L ) { p->QueueCommand(SArg(1)); return 0; } static int queuemessage( T* p, lua_State *L ) { p->QueueMessage(SArg(1)); return 0; } diff --git a/stepmania/src/ActorFrame.cpp b/stepmania/src/ActorFrame.cpp index 29b0b0b57f..0127b7e391 100644 --- a/stepmania/src/ActorFrame.cpp +++ b/stepmania/src/ActorFrame.cpp @@ -207,13 +207,13 @@ void ActorFrame::DrawPrimitives() void ActorFrame::RunCommandsOnChildren( const LuaReference& cmds ) { for( unsigned i=0; iRunCommands( cmds ); + m_SubActors[i]->RunCommands( cmds, this ); } -void ActorFrame::RunCommandsOnLeaves( const LuaReference& cmds ) +void ActorFrame::RunCommandsOnLeaves( const LuaReference& cmds, Actor* pParent ) { for( unsigned i=0; iRunCommandsOnLeaves( cmds ); + m_SubActors[i]->RunCommandsOnLeaves( cmds, this ); } void ActorFrame::UpdateInternal( float fDeltaTime ) @@ -294,12 +294,12 @@ void ActorFrame::DeleteAllChildren() m_SubActors.clear(); } -void ActorFrame::RunCommands( const LuaReference& cmds ) +void ActorFrame::RunCommands( const LuaReference& cmds, Actor* pParent ) { if( m_bPropagateCommands ) RunCommandsOnChildren( cmds ); else - Actor::RunCommands( cmds ); + Actor::RunCommands( cmds, pParent ); } void ActorFrame::SetPropagateCommands( bool b ) @@ -307,40 +307,11 @@ void ActorFrame::SetPropagateCommands( bool b ) m_bPropagateCommands = b; } -/* -void ActorFrame::HandleCommand( const Command &command ) -{ - BeginHandleArgs; - - const CString& sName = command.GetName(); - do - { - if( sName=="propagate" ) - { - m_bPropagateCommands = bArg(1); - RunCommandOnChildren( command ); - } - else - { - Actor::HandleCommand( command ); - break; - } - EndHandleArgs; - } while(0); - - // By default, don't propograte most commands to children; it makes no sense - // to run "x,50" recursively. If m_bPropagateCommands is set, propagate all - // commands. - if( m_bPropagateCommands && sName!="propagate" ) - RunCommandOnChildren( command ); -} -*/ - -void ActorFrame::PlayCommand( const CString &sCommandName ) +void ActorFrame::PlayCommand( const CString &sCommandName, Actor* pParent ) { // HACK: Don't propogate Init. It gets called once for every Actor when the // Actor is loaded, and we don't want to call it again. - Actor::PlayCommand( sCommandName ); + Actor::PlayCommand( sCommandName, pParent ); if( sCommandName == "Init" ) return; @@ -348,7 +319,7 @@ void ActorFrame::PlayCommand( const CString &sCommandName ) for( unsigned i=0; iPlayCommand( sCommandName ); + pActor->PlayCommand( sCommandName, this ); } } diff --git a/stepmania/src/ActorFrame.h b/stepmania/src/ActorFrame.h index 25c4f849d2..30ddbeb43e 100644 --- a/stepmania/src/ActorFrame.h +++ b/stepmania/src/ActorFrame.h @@ -68,8 +68,8 @@ public: // void PushSelf( lua_State *L ); virtual void RunCommandsOnChildren( const LuaReference& cmds ); /* but not on self */ - virtual void RunCommandsOnChildren( const apActorCommands& cmds ) { RunCommandsOnChildren( *cmds ); } // convenience - virtual void RunCommandsOnLeaves( const LuaReference& cmds ); /* but not on self */ + void RunCommandsOnChildren( const apActorCommands& cmds ) { this->RunCommandsOnChildren( *cmds ); } // convenience + virtual void RunCommandsOnLeaves( const LuaReference& cmds, Actor* pParent ); /* but not on self */ virtual void UpdateInternal( float fDeltaTime ); virtual void DrawPrimitives(); @@ -93,9 +93,9 @@ public: /* Amount of time until all tweens (and all children's tweens) have stopped: */ virtual float GetTweenTimeLeft() const; - virtual void PlayCommand( const CString &sCommandName ); - virtual void RunCommands( const LuaReference& cmds ); - void RunCommands( const apActorCommands& cmds ) { ActorFrame::RunCommands( *cmds ); } // convenience + virtual void PlayCommand( const CString &sCommandName, Actor* pParent = NULL ); + virtual void RunCommands( const LuaReference& cmds, Actor* pParent = NULL ); + void RunCommands( const apActorCommands& cmds, Actor *pParent = NULL ) { this->RunCommands( *cmds, pParent ); } // convenience protected: vector m_SubActors; diff --git a/stepmania/src/ActorUtil.cpp b/stepmania/src/ActorUtil.cpp index 7c5cf513a4..5f2d5d33bc 100644 --- a/stepmania/src/ActorUtil.cpp +++ b/stepmania/src/ActorUtil.cpp @@ -351,7 +351,7 @@ void ActorUtil::LoadCommand( Actor& actor, const CString &sType, const CString & actor.AddCommand( sCommandName, THEME->GetMetricA(sType,actor.GetName()+sCommandName+"Command") ); } -void ActorUtil::LoadAndPlayCommand( Actor& actor, const CString &sType, const CString &sCommandName ) +void ActorUtil::LoadAndPlayCommand( Actor& actor, const CString &sType, const CString &sCommandName, Actor* pParent ) { // HACK: It's very often that we command things to TweenOffScreen // that we aren't drawing. We know that an Actor is not being @@ -379,7 +379,7 @@ void ActorUtil::LoadAndPlayCommand( Actor& actor, const CString &sType, const CS LoadCommand( actor, sType, sCommandName ); } - actor.PlayCommand( sCommandName ); + actor.PlayCommand( sCommandName, pParent ); } void ActorUtil::LoadAllCommands( Actor& actor, const CString &sType ) diff --git a/stepmania/src/ActorUtil.h b/stepmania/src/ActorUtil.h index 8fbdfb8de6..def347ea40 100644 --- a/stepmania/src/ActorUtil.h +++ b/stepmania/src/ActorUtil.h @@ -46,25 +46,23 @@ namespace ActorUtil void SetXY( Actor& actor, const CString &sType ); - inline void SetXY( Actor* pActor, const CString &sType ) { SetXY( *pActor, sType ); } - void LoadCommand( Actor& actor, const CString &sType, const CString &sCommandName ); - void LoadAndPlayCommand( Actor& actor, const CString &sType, const CString &sCommandName ); + void LoadAndPlayCommand( Actor& actor, const CString &sType, const CString &sCommandName, Actor* pParent = NULL ); void LoadAllCommands( Actor& actor, const CString &sType ); - - inline void OnCommand( Actor& actor, const CString &sType ) { LoadAndPlayCommand( actor, sType, "On" ); } + inline void OnCommand( Actor& actor, const CString &sType, Actor* pParent = NULL ) { LoadAndPlayCommand( actor, sType, "On", pParent ); } inline void OffCommand( Actor& actor, const CString &sType ) { LoadAndPlayCommand( actor, sType, "Off" ); } - inline void SetXYAndOnCommand( Actor& actor, const CString &sType ) + inline void SetXYAndOnCommand( Actor& actor, const CString &sType, Actor* pParent = NULL ) { SetXY( actor, sType ); - OnCommand( actor, sType ); + OnCommand( actor, sType, pParent ); } /* convenience */ - inline void LoadAndPlayCommand( Actor* pActor, const CString &sType, const CString &sCommandName ) { if(pActor) LoadAndPlayCommand( *pActor, sType, sCommandName ); } - inline void OnCommand( Actor* pActor, const CString &sType ) { if(pActor) OnCommand( *pActor, sType ); } + inline void SetXY( Actor* pActor, const CString &sType ) { SetXY( *pActor, sType ); } + inline void LoadAndPlayCommand( Actor* pActor, const CString &sType, const CString &sCommandName, Actor* pParent = NULL ) { if(pActor) LoadAndPlayCommand( *pActor, sType, sCommandName, pParent ); } + inline void OnCommand( Actor* pActor, const CString &sType, Actor* pParent = NULL ) { if(pActor) OnCommand( *pActor, sType, pParent ); } inline void OffCommand( Actor* pActor, const CString &sType ) { if(pActor) OffCommand( *pActor, sType ); } - inline void SetXYAndOnCommand( Actor* pActor, const CString &sType ) { if(pActor) SetXYAndOnCommand( *pActor, sType ); } + inline void SetXYAndOnCommand( Actor* pActor, const CString &sType, Actor* pParent = NULL ) { if(pActor) SetXYAndOnCommand( *pActor, sType, pParent ); } // Return a Sprite, BitmapText, or Model depending on the file type Actor* LoadFromActorFile( const CString& sAniDir, const XNode* pNode ); diff --git a/stepmania/src/DifficultyList.cpp b/stepmania/src/DifficultyList.cpp index 859f52a055..a68c29e789 100644 --- a/stepmania/src/DifficultyList.cpp +++ b/stepmania/src/DifficultyList.cpp @@ -208,8 +208,8 @@ void DifficultyList::PositionItems() if( m_Lines[m].m_Meter.GetDestY() != row.m_fY || m_Lines[m].m_Meter.DestTweenState().diffuse[0][3] != fDiffuseAlpha ) { - m_Lines[m].m_Meter.RunCommands( MOVE_COMMAND ); - m_Lines[m].m_Meter.RunCommandsOnChildren( MOVE_COMMAND ); + m_Lines[m].m_Meter.RunCommands( MOVE_COMMAND.GetValue() ); + m_Lines[m].m_Meter.RunCommandsOnChildren( MOVE_COMMAND.GetValue() ); } m_Lines[m].m_Meter.SetY( row.m_fY ); diff --git a/stepmania/src/HelpDisplay.cpp b/stepmania/src/HelpDisplay.cpp index e131252ac6..23520d767d 100644 --- a/stepmania/src/HelpDisplay.cpp +++ b/stepmania/src/HelpDisplay.cpp @@ -144,7 +144,7 @@ GenreDisplay::~GenreDisplay() { } -void GenreDisplay::PlayCommand( const CString &sCommandName ) +void GenreDisplay::PlayCommand( const CString &sCommandName, Actor* pParent ) { if( sCommandName == MessageToString(MESSAGE_CURRENT_SONG_CHANGED) ) { @@ -185,7 +185,7 @@ void GenreDisplay::PlayCommand( const CString &sCommandName ) } else { - Actor::PlayCommand( sCommandName ); + Actor::PlayCommand( sCommandName, pParent ); } } diff --git a/stepmania/src/HelpDisplay.h b/stepmania/src/HelpDisplay.h index 7e14ac899b..855a620f00 100644 --- a/stepmania/src/HelpDisplay.h +++ b/stepmania/src/HelpDisplay.h @@ -41,7 +41,7 @@ class GenreDisplay : public HelpDisplay public: GenreDisplay(); ~GenreDisplay(); - void PlayCommand( const CString &sCommandName ); + void PlayCommand( const CString &sCommandName, Actor* pParent ); }; #endif diff --git a/stepmania/src/MenuTimer.cpp b/stepmania/src/MenuTimer.cpp index 21c05e817d..063cf2ab80 100644 --- a/stepmania/src/MenuTimer.cpp +++ b/stepmania/src/MenuTimer.cpp @@ -89,7 +89,7 @@ void MenuTimer::Update( float fDeltaTime ) if( iCrossed <= WARNING_START ) { for( int i=0; iGetPathF("PaneDisplay","text") ); m_textContents[p].SetName( ssprintf("%sText", g_Contents[p].name) ); - ActorUtil::SetXYAndOnCommand( m_textContents[p], sType ); + ActorUtil::SetXYAndOnCommand( m_textContents[p], sType, this ); m_ContentsFrame.AddChild( &m_textContents[p] ); m_Labels[p].Load( THEME->GetPathG("PaneDisplay",CString(g_Contents[p].name)+" label") ); m_Labels[p]->SetName( ssprintf("%sLabel", g_Contents[p].name) ); - ActorUtil::SetXYAndOnCommand( m_Labels[p], sType ); + ActorUtil::SetXYAndOnCommand( m_Labels[p], sType, this ); m_ContentsFrame.AddChild( m_Labels[p] ); } diff --git a/stepmania/src/ScoreDisplayAliveTime.cpp b/stepmania/src/ScoreDisplayAliveTime.cpp index 6d3192e9c5..762c5b2b5f 100644 --- a/stepmania/src/ScoreDisplayAliveTime.cpp +++ b/stepmania/src/ScoreDisplayAliveTime.cpp @@ -41,11 +41,11 @@ void ScoreDisplayAliveTime::Update( float fDelta ) BitmapText::Update( fDelta ); } -void ScoreDisplayAliveTime::PlayCommand( const CString &sCommandName ) +void ScoreDisplayAliveTime::PlayCommand( const CString &sCommandName, Actor* pParent ) { // TODO: Add handling of GoalComplete message - BitmapText::PlayCommand( sCommandName ); + BitmapText::PlayCommand( sCommandName, pParent ); } void ScoreDisplayAliveTime::UpdateNumber() diff --git a/stepmania/src/ScoreDisplayAliveTime.h b/stepmania/src/ScoreDisplayAliveTime.h index c2ff911f84..d0f6c72ad4 100644 --- a/stepmania/src/ScoreDisplayAliveTime.h +++ b/stepmania/src/ScoreDisplayAliveTime.h @@ -31,7 +31,7 @@ public: void LoadFromNode( const CString& sDir, const XNode* pNode ); - void PlayCommand( const CString &sCommandName ); + void PlayCommand( const CString &sCommandName, Actor* pParent ); void UpdateNumber(); diff --git a/stepmania/src/ScoreDisplayCalories.cpp b/stepmania/src/ScoreDisplayCalories.cpp index 693557e722..b1dfde2b77 100644 --- a/stepmania/src/ScoreDisplayCalories.cpp +++ b/stepmania/src/ScoreDisplayCalories.cpp @@ -50,14 +50,14 @@ void ScoreDisplayCalories::Update( float fDelta ) RollingNumbers::Update( fDelta ); } -void ScoreDisplayCalories::PlayCommand( const CString &sCommandName ) +void ScoreDisplayCalories::PlayCommand( const CString &sCommandName, Actor* pParent ) { if( sCommandName == m_sMessageOnStep ) { UpdateNumber(); } - RollingNumbers::PlayCommand( sCommandName ); + RollingNumbers::PlayCommand( sCommandName, pParent ); } void ScoreDisplayCalories::UpdateNumber() diff --git a/stepmania/src/ScoreDisplayCalories.h b/stepmania/src/ScoreDisplayCalories.h index 31c7dcfeb7..3c582dc0e2 100644 --- a/stepmania/src/ScoreDisplayCalories.h +++ b/stepmania/src/ScoreDisplayCalories.h @@ -30,7 +30,7 @@ public: void LoadFromNode( const CString& sDir, const XNode* pNode ); - void PlayCommand( const CString &sCommandName ); + void PlayCommand( const CString &sCommandName, Actor* pParent ); void UpdateNumber(); diff --git a/stepmania/src/TextBanner.cpp b/stepmania/src/TextBanner.cpp index 5062a2b40c..fdb54c3bda 100644 --- a/stepmania/src/TextBanner.cpp +++ b/stepmania/src/TextBanner.cpp @@ -61,15 +61,15 @@ void TextBanner::LoadFromString( if( bTwoLines ) { - m_textTitle.RunCommands2( TWO_LINES_TITLE_COMMAND, this ); - m_textSubTitle.RunCommands2( TWO_LINES_SUBTITLE_COMMAND, this ); - m_textArtist.RunCommands2( TWO_LINES_ARTIST_COMMAND, this ); + m_textTitle.RunCommands( TWO_LINES_TITLE_COMMAND, this ); + m_textSubTitle.RunCommands( TWO_LINES_SUBTITLE_COMMAND, this ); + m_textArtist.RunCommands( TWO_LINES_ARTIST_COMMAND, this ); } else { - m_textTitle.RunCommands2( THREE_LINES_TITLE_COMMAND, this ); - m_textSubTitle.RunCommands2( THREE_LINES_SUBTITLE_COMMAND, this ); - m_textArtist.RunCommands2( THREE_LINES_ARTIST_COMMAND, this ); + m_textTitle.RunCommands( THREE_LINES_TITLE_COMMAND, this ); + m_textSubTitle.RunCommands( THREE_LINES_SUBTITLE_COMMAND, this ); + m_textArtist.RunCommands( THREE_LINES_ARTIST_COMMAND, this ); } }