LuaHelpers::RunExpressionB

This commit is contained in:
Glenn Maynard
2005-06-16 06:23:59 +00:00
parent 914acb4b7b
commit 6a8940d5a4
6 changed files with 16 additions and 8 deletions
+1 -1
View File
@@ -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;
}
}
+2 -2
View File
@@ -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;
}
+2 -2
View File
@@ -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;
+7 -1
View File
@@ -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;
}
+3 -1
View File
@@ -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 )
{
+1 -1
View File
@@ -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 )