merge PlayCommand2 and PlayCommand so that Actor derivities only have to override one method to get the correct behavior
This commit is contained in:
+2
-12
@@ -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<CString, apActorCommands>::const_iterator it = m_mapNameToCommands.find( sCommandName );
|
||||
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
@@ -207,13 +207,13 @@ void ActorFrame::DrawPrimitives()
|
||||
void ActorFrame::RunCommandsOnChildren( const LuaReference& cmds )
|
||||
{
|
||||
for( unsigned i=0; i<m_SubActors.size(); i++ )
|
||||
m_SubActors[i]->RunCommands( 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; i<m_SubActors.size(); i++ )
|
||||
m_SubActors[i]->RunCommandsOnLeaves( 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; i<m_SubActors.size(); i++ )
|
||||
{
|
||||
Actor* pActor = m_SubActors[i];
|
||||
pActor->PlayCommand( sCommandName );
|
||||
pActor->PlayCommand( sCommandName, this );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<Actor*> m_SubActors;
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ class GenreDisplay : public HelpDisplay
|
||||
public:
|
||||
GenreDisplay();
|
||||
~GenreDisplay();
|
||||
void PlayCommand( const CString &sCommandName );
|
||||
void PlayCommand( const CString &sCommandName, Actor* pParent );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -89,7 +89,7 @@ void MenuTimer::Update( float fDeltaTime )
|
||||
if( iCrossed <= WARNING_START )
|
||||
{
|
||||
for( int i=0; i<NUM_MENU_TIMER_TEXTS; i++ )
|
||||
m_text[i].RunCommands2( WARNING_COMMAND.GetValue(iCrossed), this );
|
||||
m_text[i].RunCommands( WARNING_COMMAND.GetValue(iCrossed), this );
|
||||
}
|
||||
|
||||
if( iCrossed <= WARNING_BEEP_START && m_soundBeep.IsLoaded() )
|
||||
|
||||
@@ -127,12 +127,12 @@ void PaneDisplay::Load( const CString &sType, PlayerNumber pn )
|
||||
|
||||
m_textContents[p].LoadFromFont( THEME->GetPathF("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] );
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user