diff --git a/src/ActorUtil.cpp b/src/ActorUtil.cpp index 7a8f6bb8cc..a381ba32e1 100644 --- a/src/ActorUtil.cpp +++ b/src/ActorUtil.cpp @@ -307,7 +307,7 @@ bool ActorUtil::GetAttrPath( const XNode *pNode, const RString &sName, RString & apActorCommands ActorUtil::ParseActorCommands( const RString &sCommands, const RString &sName ) { Lua *L = LUA->Get(); - LuaHelpers::ParseCommandList( L, sCommands, sName ); + LuaHelpers::ParseCommandList( L, sCommands, sName, false ); LuaReference *pRet = new LuaReference; pRet->SetFromStack( L ); LUA->Release( L ); diff --git a/src/Command.cpp b/src/Command.cpp index 74ef49c8c4..a0332f037b 100644 --- a/src/Command.cpp +++ b/src/Command.cpp @@ -87,10 +87,13 @@ RString Commands::GetOriginalCommandString() const return s; } -void ParseCommands( const RString &sCommands, Commands &vCommandsOut ) +void ParseCommands( const RString &sCommands, Commands &vCommandsOut, bool bLegacy ) { vector vsCommands; - SplitWithQuotes( sCommands, ';', vsCommands, true ); // do ignore empty + if( bLegacy ) + split( sCommands, ";", vsCommands, true ); + else + SplitWithQuotes( sCommands, ';', vsCommands, true ); // do ignore empty vCommandsOut.v.resize( vsCommands.size() ); for( unsigned i=0; i 0 && sCommands[0] == '\033' ) @@ -854,18 +854,35 @@ void LuaHelpers::ParseCommandList( Lua *L, const RString &sCommands, const RStri else { Commands cmds; - ParseCommands( sCommands, cmds ); + ParseCommands( sCommands, cmds, bLegacy ); // Convert cmds to a Lua function ostringstream s; s << "return function(self)\n"; + if( bLegacy ) + s << "\tparent = self:GetParent();\n"; + FOREACH_CONST( Command, cmds.v, c ) { const Command& cmd = (*c); - RString local_sName = cmd.GetName(); - s << "\tself:" << local_sName << "("; + RString sCmdName = cmd.GetName(); + if( bLegacy ) + sCmdName.MakeLower(); + s << "\tself:" << sCmdName << "("; + + bool bFirstParamIsString = bLegacy && ( + sCmdName == "horizalign" || + sCmdName == "vertalign" || + sCmdName == "effectclock" || + sCmdName == "blend" || + sCmdName == "ztestmode" || + sCmdName == "cullmode" || + sCmdName == "playcommand" || + sCmdName == "queuecommand" || + sCmdName == "queuemessage" || + sCmdName == "settext"); for( unsigned i=1; i &aOut ); - void ParseCommandList( lua_State *L, const RString &sCommands, const RString &sName ); + void ParseCommandList( lua_State *L, const RString &sCommands, const RString &sName, bool bLegacy ); XNode *GetLuaInformation(); diff --git a/src/OptionsList.cpp b/src/OptionsList.cpp index 24c78e8e4e..e7c5c66d56 100644 --- a/src/OptionsList.cpp +++ b/src/OptionsList.cpp @@ -214,7 +214,7 @@ void OptionsList::Load( RString sType, PlayerNumber pn ) RString sRowCommands = LINE(sLineName); Commands cmds; - ParseCommands( sRowCommands, cmds ); + ParseCommands( sRowCommands, cmds, false ); OptionRowHandler *pHand = OptionRowHandlerUtil::Make( cmds ); if( pHand == NULL ) diff --git a/src/ScreenOptionsMaster.cpp b/src/ScreenOptionsMaster.cpp index 039450739c..9ce88793fb 100644 --- a/src/ScreenOptionsMaster.cpp +++ b/src/ScreenOptionsMaster.cpp @@ -54,7 +54,7 @@ void ScreenOptionsMaster::Init() RString sRowCommands = LINE(sLineName); Commands cmds; - ParseCommands( sRowCommands, cmds ); + ParseCommands( sRowCommands, cmds, false ); OptionRowHandler *pHand = OptionRowHandlerUtil::Make( cmds ); if( pHand == NULL ) diff --git a/src/ThemeManager.cpp b/src/ThemeManager.cpp index fee5283983..ecdf20efd3 100644 --- a/src/ThemeManager.cpp +++ b/src/ThemeManager.cpp @@ -1030,7 +1030,7 @@ void ThemeManager::PushMetric( Lua *L, const RString &sMetricsGroup, const RStri RString sName = ssprintf( "%s::%s", sMetricsGroup.c_str(), sValueName.c_str() ); if( EndsWith(sValueName, "Command") ) { - LuaHelpers::ParseCommandList( L, sValue, sName ); + LuaHelpers::ParseCommandList( L, sValue, sName, false ); } else { diff --git a/src/XmlFileUtil.cpp b/src/XmlFileUtil.cpp index 4bcfe0e40f..8a3561af5c 100644 --- a/src/XmlFileUtil.cpp +++ b/src/XmlFileUtil.cpp @@ -580,7 +580,8 @@ namespace if( EndsWith(sName, "Command") ) { - LuaHelpers::ParseCommandList( L, sExpression, sFile ); + // Use legacy parsing + LuaHelpers::ParseCommandList( L, sExpression, sFile, true ); } else if( sExpression.size() > 0 && sExpression[0] == '@' ) {