diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index 251b4b0f99..07fa327121 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -52,6 +52,8 @@ void Actor::Reset() m_ZTestMode = ZTEST_OFF; m_bZWrite = false; m_CullMode = CULL_NONE; + + m_mapNameToCommands.clear(); } Actor::Actor() @@ -623,9 +625,16 @@ void Actor::AddRotationR( float rot ) RageQuatMultiply( &DestTweenState().quat, DestTweenState().quat, RageQuatFromR(rot) ); } -void Actor::RunCommands( const Commands &vCommands ) +void Actor::AddCommands( const CString sName, const Commands &cmds ) { - FOREACH_CONST( Command, vCommands.v, c ) + CString sKey = sName; + sKey.MakeLower(); + m_mapNameToCommands[sKey] = cmds; +} + +void Actor::RunCommands( const Commands &cmds ) +{ + FOREACH_CONST( Command, cmds.v, c ) this->HandleCommand( *c ); } @@ -768,10 +777,10 @@ void Actor::HandleCommand( const Command &command ) EndHandleArgs; } -float Actor::GetCommandsLengthSeconds( const Commands &vCommands ) +float Actor::GetCommandsLengthSeconds( const Commands &cmds ) { Actor temp; - temp.RunCommands(vCommands); + temp.RunCommands(cmds); return temp.GetTweenTimeLeft(); } @@ -913,6 +922,18 @@ void Actor::QueueCommand( Command command ) DestTweenState().command = command; } +void Actor::PlayCommand( const CString &sCommandName ) +{ + CString sKey = sCommandName; + sKey.MakeLower(); + map::const_iterator it = m_mapNameToCommands.find( sKey ); + + if( it == m_mapNameToCommands.end() ) + return; + + RunCommands( it->second ); +} + /* * (c) 2001-2004 Chris Danford * All rights reserved. diff --git a/stepmania/src/Actor.h b/stepmania/src/Actor.h index e7f44c3935..3beb828a7a 100644 --- a/stepmania/src/Actor.h +++ b/stepmania/src/Actor.h @@ -6,6 +6,7 @@ #include "RageTypes.h" #include "Command.h" #include +#include #define DRAW_ORDER_BEFORE_EVERYTHING -100 #define DRAW_ORDER_TRANSITIONS 100 @@ -303,9 +304,10 @@ public: // // Commands // - void RunCommands( const Commands &vCommands ); + void AddCommands( const CString sName, const Commands &cmds ); + void RunCommands( const Commands &cmds ); virtual void HandleCommand( const Command &command ); // derivable - static float GetCommandsLengthSeconds( const Commands &vCommands ); + static float GetCommandsLengthSeconds( const Commands &cmds ); // // Animation @@ -320,8 +322,7 @@ public: // virtual void GainFocus( float fRate, bool bRewindMovie, bool bLoop ) {} virtual void LoseFocus() {} - virtual void PlayCommand( const CString &sCommandName ) {} - virtual void PlayOffCommand( const CString &sCommandName ) {} + virtual void PlayCommand( const CString &sCommandName ); protected: @@ -403,6 +404,11 @@ protected: // global state // static float g_fCurrentBGMTime, g_fCurrentBGMBeat; + + // + // commands + // + map m_mapNameToCommands; }; #endif