From 81bf2cf8ffe819e90cafad3884622b0da6727348 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 27 Feb 2005 03:21:18 +0000 Subject: [PATCH] add queuemessage --- stepmania/src/Actor.cpp | 14 +++++++++++++- stepmania/src/Actor.h | 3 +++ stepmania/src/ActorCommands.cpp | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index 79e7efa9f1..a75c08535b 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -359,7 +359,10 @@ void Actor::UpdateTweening( float fDeltaTime ) // Execute the command in this tween (if any). if( TS.sCommandName.size() ) { - this->PlayCommand( TS.sCommandName ); + if( TS.sCommandName.Left(1) == "!" ) + MESSAGEMAN->Broadcast( TS.sCommandName.substr(1) ); + else + this->PlayCommand( TS.sCommandName ); } } @@ -1028,6 +1031,15 @@ void Actor::QueueCommand( const CString& sCommandName ) DestTweenState().sCommandName = sCommandName; } +void Actor::QueueMessage( const CString& sMessageName ) +{ + // Hack: use "!" as a marker to broadcast a command, instead of playing a + // command, so we don't have to add yet another element to every tween + // state for this rarely-used command. + BeginTweening( 0, TWEEN_LINEAR ); + DestTweenState().sCommandName = "!" + sMessageName; +} + void Actor::AddCommand( const CString &sCmdName, apActorCommands apac ) { m_mapNameToCommands[sCmdName] = apac; diff --git a/stepmania/src/Actor.h b/stepmania/src/Actor.h index 328051471d..ad306eba36 100644 --- a/stepmania/src/Actor.h +++ b/stepmania/src/Actor.h @@ -196,6 +196,7 @@ public: void StopTweening(); void Sleep( float time ); void QueueCommand( const CString& sCommandName ); + void QueueMessage( const CString& sMessageName ); virtual void FinishTweening(); virtual void HurryTweening( float factor ); // Let ActorFrame and BGAnimation override @@ -529,6 +530,7 @@ public: 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 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; } static void Register(lua_State *L) { ADD_METHOD( sleep ) @@ -620,6 +622,7 @@ public: ADD_METHOD( draworder ) ADD_METHOD( playcommand ) ADD_METHOD( queuecommand ) + ADD_METHOD( queuemessage ) Luna::Register( L ); } }; diff --git a/stepmania/src/ActorCommands.cpp b/stepmania/src/ActorCommands.cpp index 41073bcae8..fda0f88eac 100644 --- a/stepmania/src/ActorCommands.cpp +++ b/stepmania/src/ActorCommands.cpp @@ -41,6 +41,7 @@ ActorCommands::ActorCommands( const CString &sCommands ) sName == "cullmode" || sName == "playcommand" || sName == "queuecommand" || + sName == "queuemessage" || sName == "settext"; for( unsigned i=1; i