From bc184683ca5d42169c79fb0968c8c4dfd29c4ee7 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Fri, 5 Nov 2004 06:43:12 +0000 Subject: [PATCH] allow Lua expressions in ActorCommand parameters --- stepmania/src/Actor.cpp | 2 +- stepmania/src/ActorCommands.cpp | 12 ++++++------ stepmania/src/ActorCommands.h | 12 ++++++------ stepmania/src/ScreenManager.cpp | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index 45bb1ae041..496de5cca7 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -624,7 +624,7 @@ void Actor::Command( CString sCommands ) sCommands.MakeLower(); vector vCommands; - ParseCommands( sCommands, vCommands ); + ParseCommands( sCommands, vCommands ); for( unsigned i=0; iHandleCommand( vCommands[i] ); diff --git a/stepmania/src/ActorCommands.cpp b/stepmania/src/ActorCommands.cpp index c9ecfc1f1d..becd52fd11 100644 --- a/stepmania/src/ActorCommands.cpp +++ b/stepmania/src/ActorCommands.cpp @@ -3,6 +3,8 @@ #include "RageUtil.h" #include "RageLog.h" #include "arch/Dialog/Dialog.h" +#include "LuaHelpers.h" + void IncorrectActorParametersWarning( const ParsedCommand &command, int iMaxIndexAccessed ) { @@ -12,13 +14,11 @@ void IncorrectActorParametersWarning( const ParsedCommand &command, int iMaxInde Dialog::OK( sError ); } -void ParsedCommandToken::Set( const CString &sToken ) +void ParsedCommandToken::Set( const CString &sParam ) { - s = sToken; - f = strtof( sToken, NULL ); - i = atoi( sToken ); - b = i != 0; - bColorIsValid = c.FromString( sToken ); + s = sParam; + f = Lua::RunExpressionF( sParam ); + bColorIsValid = c.FromString( sParam ); } void ParsedCommand::Set( const CString &sCommand ) diff --git a/stepmania/src/ActorCommands.h b/stepmania/src/ActorCommands.h index c6289acc90..5badc1bf56 100644 --- a/stepmania/src/ActorCommands.h +++ b/stepmania/src/ActorCommands.h @@ -7,19 +7,19 @@ struct ParsedCommandToken { - void Set( const CString &sToken ); // fill in all the different types + void Set( const CString &sParam ); // fill in all the different types CString s; float f; - int i; - bool b; RageColor c; // HTML-type color which is packed into one parameter - bool bColorIsValid; // true if c is a valid HTML-type color + // true if c is a valid HTML-type color. Otherwise, this value is the red component + // and the next 3 params are the other components. + bool bColorIsValid; operator const CString () const { return s; }; operator const float () const { return f; }; - operator const int () const { return i; }; - operator const bool () const { return b; }; + operator const int () const { return (int)f; }; + operator const bool () const { return ((int)f)!=0; }; operator const RageColor () const { return c; }; }; diff --git a/stepmania/src/ScreenManager.cpp b/stepmania/src/ScreenManager.cpp index da6a53e39b..3a2ac4be7b 100644 --- a/stepmania/src/ScreenManager.cpp +++ b/stepmania/src/ScreenManager.cpp @@ -135,7 +135,7 @@ void ScreenSystemLayer::ReloadCreditsText() m_textMessage.SetName( "Message" ); SET_XY_AND_ON_COMMAND( m_textMessage ); - m_textStats.LoadFromFont( THEME->GetPathToF("ScreenSystemLayer stats") ); + m_textStats.LoadFromFont( THEME->GetPathToF("ScreenSystemLayer stats") ); m_textStats.SetName( "Stats" ); SET_XY_AND_ON_COMMAND( m_textStats );