Add ScreenWithMenuElements::FirstUpdateCommand, a Lua expression
that gets called on first update. Note the difference between using ThemeMetric<LuaExpression> and ThemeMetric<ActorCommands>: with ActorCommands, you get the special, backwards-compatible parsing; with LuaExpression, only a regular expression is parsed. You can still only (cleanly) call one function, since "return" is prepended: if you say "f() g()", it'll try to run "return f() g()". I tried having a separate type for "expression" and "script", but it seems confusing to have some metrics parsed as scripts and some as expressions, allowing multiple functions in only specific metrics. If you want to do that much, it's cleaner to create a function and call it, anyway. If you just want to add diagnostics quickly, you can say "Foo=(function() x() y() z() end)()". (I might revisit this later.)
This commit is contained in:
@@ -19,10 +19,11 @@
|
||||
ScreenWithMenuElements::ScreenWithMenuElements( CString sClassName ) : Screen( sClassName )
|
||||
{
|
||||
LOG->Trace( "ScreenWithMenuElements::ScreenWithMenuElements()" );
|
||||
|
||||
|
||||
m_MenuTimer = new MenuTimer;
|
||||
m_textHelp = new HelpDisplay;
|
||||
|
||||
m_FirstUpdateCommand.Load( sClassName, "FirstUpdateCommand" );
|
||||
|
||||
LOG->Trace( "MenuElements::MenuElements()" );
|
||||
|
||||
@@ -112,6 +113,17 @@ ScreenWithMenuElements::~ScreenWithMenuElements()
|
||||
SAFE_DELETE( m_textHelp );
|
||||
}
|
||||
|
||||
void ScreenWithMenuElements::Update( float fDeltaTime )
|
||||
{
|
||||
if( m_bFirstUpdate )
|
||||
{
|
||||
/* Evaluate FirstUpdateCommand. */
|
||||
this->RunCommands( m_FirstUpdateCommand );
|
||||
}
|
||||
|
||||
Screen::Update( fDeltaTime );
|
||||
}
|
||||
|
||||
void ScreenWithMenuElements::ResetTimer()
|
||||
{
|
||||
if( TIMER_SECONDS > 0.0f && (PREFSMAN->m_bMenuTimer || FORCE_TIMER) && !GAMESTATE->m_bEditing )
|
||||
|
||||
Reference in New Issue
Block a user