From 8a04a3eeebf411249d95e2ed85557d0bed15d47b Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 17 Feb 2005 06:13:23 +0000 Subject: [PATCH] Add ScreenWithMenuElements::FirstUpdateCommand, a Lua expression that gets called on first update. Note the difference between using ThemeMetric and ThemeMetric: 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.) --- stepmania/src/ScreenWithMenuElements.cpp | 14 +++++++++++++- stepmania/src/ScreenWithMenuElements.h | 3 +++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/stepmania/src/ScreenWithMenuElements.cpp b/stepmania/src/ScreenWithMenuElements.cpp index 1e3ada9f75..7ab09f6397 100644 --- a/stepmania/src/ScreenWithMenuElements.cpp +++ b/stepmania/src/ScreenWithMenuElements.cpp @@ -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 ) diff --git a/stepmania/src/ScreenWithMenuElements.h b/stepmania/src/ScreenWithMenuElements.h index 77faecadbd..3ed8baa398 100644 --- a/stepmania/src/ScreenWithMenuElements.h +++ b/stepmania/src/ScreenWithMenuElements.h @@ -7,6 +7,7 @@ #include "ActorUtil.h" #include "RageSound.h" #include "MemoryCardDisplay.h" +#include "ThemeMetric.h" class MenuTimer; class HelpDisplay; @@ -17,6 +18,7 @@ public: ScreenWithMenuElements( CString sName ); virtual ~ScreenWithMenuElements(); + void Update( float fDeltaTime ); void StartTransitioning( ScreenMessage smSendWhenDone ); void Back( ScreenMessage smSendWhenDone ); bool IsTransitioning(); @@ -34,6 +36,7 @@ protected: AutoActor m_autoFooter; HelpDisplay *m_textHelp; AutoActor m_sprOverlay; + ThemeMetric m_FirstUpdateCommand; Transition m_In; Transition m_Out;