evaluate enums directly
This commit is contained in:
@@ -83,12 +83,8 @@ void ActorFrame::LoadFromNode( const RString& sDir, const XNode* pNode )
|
||||
|
||||
pNode->GetAttrValue( "UpdateRate", m_fUpdateRate );
|
||||
pNode->GetAttrValue( "FOV", m_fFOV );
|
||||
|
||||
RString s;
|
||||
if( pNode->GetAttrValue( "VanishX", s ) )
|
||||
m_fVanishX = LuaHelpers::RunExpressionF( s );
|
||||
if( pNode->GetAttrValue( "VanishY", s ) )
|
||||
m_fVanishY = LuaHelpers::RunExpressionF( s );
|
||||
pNode->GetAttrValue( "VanishX", m_fVanishX );
|
||||
pNode->GetAttrValue( "VanishY", m_fVanishY );
|
||||
m_bOverrideLighting = pNode->GetAttrValue( "Lighting", m_bLighting );
|
||||
}
|
||||
|
||||
|
||||
@@ -180,12 +180,9 @@ Actor* ActorUtil::LoadFromNode( const RString& sDir, const XNode* pNode, Actor *
|
||||
ASSERT( pNode );
|
||||
|
||||
{
|
||||
RString expr;
|
||||
if( pNode->GetAttrValue("Condition",expr) )
|
||||
{
|
||||
if( !LuaHelpers::RunExpressionB(expr) )
|
||||
return NULL;
|
||||
}
|
||||
bool bCond;
|
||||
if( pNode->GetAttrValue("Condition", bCond) && !bCond )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Load Params
|
||||
|
||||
@@ -52,12 +52,9 @@ void BGAnimation::AddLayersFromAniDir( const RString &_sAniDir, const XNode *pNo
|
||||
RString sImportDir;
|
||||
if( pKey->GetAttrValue("Import", sImportDir) )
|
||||
{
|
||||
RString expr;
|
||||
if( pKey->GetAttrValue("Condition",expr) )
|
||||
{
|
||||
if( !LuaHelpers::RunExpressionB( expr ) )
|
||||
continue;
|
||||
}
|
||||
bool bCond;
|
||||
if( pKey->GetAttrValue("Condition",bCond) && !bCond )
|
||||
continue;
|
||||
|
||||
// import a whole BGAnimation
|
||||
sImportDir = sAniDir + sImportDir;
|
||||
|
||||
@@ -370,12 +370,9 @@ void BGAnimationLayer::LoadFromNode( const RString& sDir, const XNode* pNode )
|
||||
CHECKPOINT_M( ssprintf( "BGAnimationLayer::LoadFromIni \"%s\"", sAniDir.c_str() ) );
|
||||
|
||||
{
|
||||
RString expr;
|
||||
if( pNode->GetAttrValue("Condition", expr) )
|
||||
{
|
||||
if( !LuaHelpers::RunExpressionB(expr) )
|
||||
return;
|
||||
}
|
||||
bool bCond;
|
||||
if( pNode->GetAttrValue("Condition", bCond) && !bCond )
|
||||
return;
|
||||
}
|
||||
|
||||
bool bStretch = false;
|
||||
|
||||
@@ -544,11 +544,6 @@ float LuaHelpers::RunExpressionF( const RString &str )
|
||||
return result;
|
||||
}
|
||||
|
||||
int LuaHelpers::RunExpressionI( const RString &str )
|
||||
{
|
||||
return (int) LuaHelpers::RunExpressionF(str);
|
||||
}
|
||||
|
||||
void LuaHelpers::RunExpressionS( const RString &str, RString &sOut )
|
||||
{
|
||||
Lua *L = LUA->Get();
|
||||
|
||||
@@ -70,7 +70,6 @@ namespace LuaHelpers
|
||||
/* Run an expression in the global environment, returning the given type. */
|
||||
bool RunExpressionB( const RString &str );
|
||||
float RunExpressionF( const RString &str );
|
||||
int RunExpressionI( const RString &str );
|
||||
void RunExpressionS( const RString &str, RString &sOut );
|
||||
|
||||
/* If sStr begins with @, evaluate the rest as an expression and store the result over sStr. */
|
||||
|
||||
@@ -110,10 +110,12 @@ void PaneDisplay::LoadFromNode( const RString &sDir, const XNode *pNode )
|
||||
b = pNode->GetAttrValue( "MetricsGroup", sMetricsGroup );
|
||||
ASSERT( b );
|
||||
|
||||
RString sPlayerNumber;
|
||||
b = pNode->GetAttrValue( "PlayerNumber", sPlayerNumber );
|
||||
Lua *L = LUA->Get();
|
||||
b = pNode->PushAttrValue( L, "PlayerNumber" );
|
||||
ASSERT( b );
|
||||
PlayerNumber pn = (PlayerNumber) LuaHelpers::RunExpressionI(sPlayerNumber);
|
||||
PlayerNumber pn;
|
||||
LuaHelpers::Pop( L, pn );
|
||||
LUA->Release( L );
|
||||
|
||||
Load( sMetricsGroup, pn );
|
||||
|
||||
|
||||
@@ -25,12 +25,9 @@ void RollingNumbers::LoadFromNode( const RString& sDir, const XNode* pNode )
|
||||
ThemeManager::EvaluateString( m_sFormat );
|
||||
pNode->GetAttrValue( "ApproachSeconds", m_fApproachSeconds );
|
||||
|
||||
RString sTargetNumber;
|
||||
if( pNode->GetAttrValue( "TargetNumber", sTargetNumber ) )
|
||||
{
|
||||
float fTargetNumber = LuaHelpers::RunExpressionF(sTargetNumber);
|
||||
float fTargetNumber;
|
||||
if( pNode->GetAttrValue( "TargetNumber", fTargetNumber ) )
|
||||
SetTargetNumber( fTargetNumber );
|
||||
}
|
||||
|
||||
UpdateText();
|
||||
}
|
||||
|
||||
@@ -25,10 +25,11 @@ void ScoreDisplayAliveTime::LoadFromNode( const RString& sDir, const XNode* pNod
|
||||
BitmapText::LoadFromNode( sDir, pNode );
|
||||
|
||||
{
|
||||
RString sPlayerNumber;
|
||||
bool b = pNode->GetAttrValue( "PlayerNumber", sPlayerNumber );
|
||||
Lua *L = LUA->Get();
|
||||
bool b = pNode->PushAttrValue( L, "PlayerNumber" );
|
||||
ASSERT( b );
|
||||
m_PlayerNumber = (PlayerNumber) LuaHelpers::RunExpressionI(sPlayerNumber);
|
||||
LuaHelpers::Pop( L, m_PlayerNumber );
|
||||
LUA->Release( L );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,10 +27,11 @@ void ScoreDisplayCalories::LoadFromNode( const RString& sDir, const XNode* pNode
|
||||
RollingNumbers::LoadFromNode( sDir, pNode );
|
||||
|
||||
{
|
||||
RString sPlayerNumber;
|
||||
bool b = pNode->GetAttrValue( "PlayerNumber", sPlayerNumber );
|
||||
Lua *L = LUA->Get();
|
||||
bool b = pNode->PushAttrValue( L, "PlayerNumber" );
|
||||
ASSERT( b );
|
||||
m_PlayerNumber = (PlayerNumber) LuaHelpers::RunExpressionI(sPlayerNumber);
|
||||
LuaHelpers::Pop( L, m_PlayerNumber );
|
||||
LUA->Release( L );
|
||||
}
|
||||
|
||||
m_sMessageOnStep = ssprintf("StepP%d",m_PlayerNumber+1);
|
||||
|
||||
Reference in New Issue
Block a user