LuaHelpers::RunExpressionB
This commit is contained in:
@@ -118,7 +118,7 @@ Actor* ActorUtil::LoadFromActorFile( const CString& sAniDir, const XNode* pNode
|
||||
CString expr;
|
||||
if( pNode->GetAttrValue("Condition",expr) )
|
||||
{
|
||||
if( !LUA->RunExpressionB(expr) )
|
||||
if( !LuaHelpers::RunExpressionB(expr) )
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ void BGAnimation::AddLayersFromAniDir( const CString &_sAniDir, const IniFile& i
|
||||
CString expr;
|
||||
if( ini.GetValue( "BGAnimation", "Condition", expr ) || ini.GetValue( "BGAnimation", "Cond", expr ) )
|
||||
{
|
||||
if( !LUA->RunExpressionB( expr ) )
|
||||
if( !LuaHelpers::RunExpressionB( expr ) )
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -73,7 +73,7 @@ void BGAnimation::AddLayersFromAniDir( const CString &_sAniDir, const IniFile& i
|
||||
CString expr;
|
||||
if( pKey->GetAttrValue("Condition",expr) )
|
||||
{
|
||||
if( !LUA->RunExpressionB( expr ) )
|
||||
if( !LuaHelpers::RunExpressionB( expr ) )
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -376,7 +376,7 @@ void BGAnimationLayer::LoadFromNode( const CString& sDir, const XNode* pNode )
|
||||
CString expr;
|
||||
if( pNode->GetAttrValue("Cond",expr) || pNode->GetAttrValue("Condition",expr) )
|
||||
{
|
||||
if( !LUA->RunExpressionB(expr) )
|
||||
if( !LuaHelpers::RunExpressionB(expr) )
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -668,7 +668,7 @@ bool BGAnimationLayer::EarlyAbortDraw()
|
||||
return false;
|
||||
|
||||
// TODO: Is it ok to evaluate this every frame?
|
||||
if( !LUA->RunExpressionB(m_sDrawCond) )
|
||||
if( !LuaHelpers::RunExpressionB(m_sDrawCond) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
@@ -300,10 +300,15 @@ bool LuaHelpers::RunScript( Lua *L, const CString &sExpression, const CString &s
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LuaManager::RunExpressionB( const CString &str )
|
||||
bool LuaHelpers::RunExpressionB( const CString &str )
|
||||
{
|
||||
Lua *L = LUA->Get();
|
||||
|
||||
if( !LuaHelpers::RunScript(L, "return " + str, "", 1) )
|
||||
{
|
||||
LUA->Release(L);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Don't accept a function as a return value. */
|
||||
if( lua_isfunction( L, -1 ) )
|
||||
@@ -311,6 +316,7 @@ bool LuaManager::RunExpressionB( const CString &str )
|
||||
|
||||
bool result = !!lua_toboolean( L, -1 );
|
||||
lua_pop( L, 1 );
|
||||
LUA->Release(L);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,6 @@ public:
|
||||
void ResetState();
|
||||
|
||||
/* Run an expression in the global environment, returning the given type. */
|
||||
bool RunExpressionB( const CString &str );
|
||||
float RunExpressionF( const CString &str );
|
||||
int RunExpressionI( const CString &str );
|
||||
bool RunExpressionS( const CString &str, CString &sOut );
|
||||
@@ -104,6 +103,9 @@ namespace LuaHelpers
|
||||
/* Read the table at the top of the stack back into a vector. */
|
||||
void ReadArrayFromTableB( Lua *L, vector<bool> &aOut );
|
||||
|
||||
/* Run an expression in the global environment, returning the given type. */
|
||||
bool RunExpressionB( const CString &str );
|
||||
|
||||
template<class T>
|
||||
void ReadArrayFromTable( vector<T> &aOut, lua_State *L )
|
||||
{
|
||||
|
||||
@@ -739,7 +739,7 @@ bool ThemeManager::GetMetricB( const CString &sClassName, const CString &sValueN
|
||||
|
||||
LUA->PrepareExpression( sValue );
|
||||
|
||||
return LUA->RunExpressionB( sValue );
|
||||
return LuaHelpers::RunExpressionB( sValue );
|
||||
}
|
||||
|
||||
RageColor ThemeManager::GetMetricC( const CString &sClassName, const CString &sValueName )
|
||||
|
||||
Reference in New Issue
Block a user