diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index 6dca1701a2..2906855c9f 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -2469,7 +2469,10 @@ StopMusicOnBack=1 WarningStart=6 WarningBeepStart=5 MaxStallSeconds=30 -OnCommand=stoptweening;shadowlength,0;zoomx,1 +Text1OnCommand=stoptweening;shadowlength,0;zoomx,1;addx,-16 +Text1FormatFunction=function(fSeconds) fSeconds=math.ceil(fSeconds); local digit = math.floor(fSeconds/10); return ""..digit end +Text2OnCommand=stoptweening;shadowlength,0;zoomx,1;addx,16 +Text2FormatFunction=function(fSeconds) fSeconds=math.ceil(fSeconds); local digit = math.mod(fSeconds,10); return ""..digit end WarningCommand6=stoptweening;sleep,0.8;linear,0.2;zoomx,0 WarningCommand5=stoptweening;linear,0.2;zoomx,1;sleep,0.6;linear,0.2;zoomx,0;glowshift;effectperiod,0.15;effectcolor1,1,0,0,0;effectcolor2,1,0,0,1 WarningCommand4=stoptweening;linear,0.2;zoomx,1;sleep,0.6;linear,0.2;zoomx,0 diff --git a/stepmania/src/MenuTimer.cpp b/stepmania/src/MenuTimer.cpp index 9a3c0a72f1..9ec5800858 100644 --- a/stepmania/src/MenuTimer.cpp +++ b/stepmania/src/MenuTimer.cpp @@ -9,13 +9,15 @@ #include "Font.h" #include "GameSoundManager.h" #include "ThemeMetric.h" +#include "ActorUtil.h" CString WARNING_COMMAND_NAME( size_t i ) { return ssprintf("WarningCommand%d",int(i)); } static const ThemeMetric WARNING_START ("MenuTimer","WarningStart"); static const ThemeMetric WARNING_BEEP_START ("MenuTimer","WarningBeepStart"); static const ThemeMetric MAX_STALL_SECONDS ("MenuTimer","MaxStallSeconds"); -static const ThemeMetric ON_COMMAND ("MenuTimer","OnCommand"); +static const ThemeMetric TEXT1_FORMAT_FUNCTION ("MenuTimer","Text1FormatFunction"); +static const ThemeMetric TEXT2_FORMAT_FUNCTION ("MenuTimer","Text2FormatFunction"); static const float TIMER_PAUSE_SECONDS = 99; @@ -26,15 +28,15 @@ MenuTimer::MenuTimer() : m_fStallSecondsLeft = MAX_STALL_SECONDS; m_bPaused = false; - m_textDigit1.LoadFromFont( THEME->GetPathF("MenuTimer","numbers") ); - m_textDigit2.LoadFromFont( THEME->GetPathF("MenuTimer","numbers") ); + for( int i=0; iGetPathF("MenuTimer","numbers") ); + m_text[i].SetName( ssprintf("Text%d",i+1) ); + ActorUtil::OnCommand( m_text[i], "MenuTimer" ); + this->AddChild( &m_text[i] ); - const float fCharWidth = (float) m_textDigit1.m_pFont->GetLineWidthInSourcePixels(L"0"); - m_textDigit1.SetX( -fCharWidth/2 ); - m_textDigit2.SetX( +fCharWidth/2 ); - - this->AddChild( &m_textDigit1 ); - this->AddChild( &m_textDigit2 ); + m_exprFormatText[i].SetFromExpression( i==0 ? TEXT1_FORMAT_FUNCTION : TEXT2_FORMAT_FUNCTION ); + } SetSeconds( TIMER_PAUSE_SECONDS ); @@ -48,8 +50,10 @@ void MenuTimer::EnableStealth( bool bStealth ) else m_soundBeep.Load( THEME->GetPathS("MenuTimer","tick") ); // reload the sound - m_textDigit1.SetHidden( bStealth ); - m_textDigit2.SetHidden( bStealth ); + for( int i=0; iPostMessageToTopScreen( SM_MenuTimer, 0 ); - m_textDigit1.SetEffectNone(); - m_textDigit2.SetEffectNone(); + for( int i=0; iL ); + ASSERT( !lua_isnil(LUA->L, -1) ); - m_textDigit1.SetText( ssprintf("%d",iDigit1) ); - m_textDigit2.SetText( ssprintf("%d",iDigit2) ); + // 1st parameter + LuaHelpers::Push( fSeconds, LUA->L ); + + // call function with 1 argument and 1 result + lua_call(LUA->L, 1, 1); + + CString sText; + LuaHelpers::FromStack( sText, -1, LUA->L ); + + m_text[i].SetText( sText ); + } } /* diff --git a/stepmania/src/MenuTimer.h b/stepmania/src/MenuTimer.h index d6b112cb26..b6abd67bc9 100644 --- a/stepmania/src/MenuTimer.h +++ b/stepmania/src/MenuTimer.h @@ -31,10 +31,13 @@ protected: float m_fStallSeconds, m_fStallSecondsLeft; bool m_bPaused; - void SetText( int iSeconds ); + void SetText( float fSeconds ); - BitmapText m_textDigit1; - BitmapText m_textDigit2; +#define NUM_MENU_TIMER_TEXTS 2 + + BitmapText m_text[NUM_MENU_TIMER_TEXTS]; + + LuaExpression m_exprFormatText[NUM_MENU_TIMER_TEXTS]; RageSound m_soundBeep;