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