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:
Glenn Maynard
2005-02-17 06:13:23 +00:00
parent 01ae30ddd9
commit 8a04a3eeeb
2 changed files with 16 additions and 1 deletions
+13 -1
View File
@@ -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 )