diff --git a/stepmania/src/MenuElements.cpp b/stepmania/src/MenuElements.cpp index ab0445b228..3db324ebe0 100644 --- a/stepmania/src/MenuElements.cpp +++ b/stepmania/src/MenuElements.cpp @@ -16,10 +16,10 @@ #include "GameConstantsAndTypes.h" #include "PrefsManager.h" #include "RageLog.h" -#include "RageLog.h" #include "GameManager.h" #include "GameState.h" #include "ThemeManager.h" +#include "MenuTimer.h" #define TIMER_SECONDS THEME->GetMetricI(m_sName,"TimerSeconds") @@ -28,6 +28,12 @@ MenuElements::MenuElements() { + m_MenuTimer = new MenuTimer; +} + +MenuElements::~MenuElements() +{ + delete m_MenuTimer; } void MenuElements::Load( CString sClassName ) @@ -59,13 +65,13 @@ void MenuElements::Load( CString sClassName ) m_bTimerEnabled = (TIMER_SECONDS != -1); if( m_bTimerEnabled ) { - m_MenuTimer.SetName( "Timer" ); + m_MenuTimer->SetName( "Timer" ); UtilOnCommand( m_MenuTimer, "MenuElements" ); if( TIMER_SECONDS > 0 && PREFSMAN->m_bMenuTimer && !GAMESTATE->m_bEditing ) - m_MenuTimer.SetSeconds( TIMER_SECONDS ); + m_MenuTimer->SetSeconds( TIMER_SECONDS ); else - m_MenuTimer.Disable(); - this->AddChild( &m_MenuTimer ); + m_MenuTimer->Disable(); + this->AddChild( m_MenuTimer ); } m_autoFooter.Load( THEME->GetPathToG(m_sName+" footer") ); @@ -105,8 +111,8 @@ void MenuElements::StartTransitioning( ScreenMessage smSendWhenDone ) { if( m_bTimerEnabled ) { - m_MenuTimer.SetSeconds( 0 ); - m_MenuTimer.Stop(); + m_MenuTimer->SetSeconds( 0 ); + m_MenuTimer->Stop(); UtilOffCommand( m_MenuTimer, "MenuElements" ); } @@ -137,7 +143,7 @@ void MenuElements::Back( ScreenMessage smSendWhenDone ) if( m_Back.IsTransitioning() ) return; // ignore - m_MenuTimer.Stop(); + m_MenuTimer->Stop(); m_Back.StartTransitioning( smSendWhenDone ); m_soundBack.Play(); } @@ -154,7 +160,7 @@ void MenuElements::DrawTopLayer() m_autoHeader->Draw(); m_sprStyleIcon.Draw(); if( m_bTimerEnabled ) - m_MenuTimer.Draw(); + m_MenuTimer->Draw(); m_autoFooter->Draw(); m_textHelp.Draw(); m_In.Draw(); @@ -177,3 +183,9 @@ bool MenuElements::IsTransitioning() { return m_In.IsTransitioning() || m_Out.IsTransitioning() || m_Back.IsTransitioning(); } + +void MenuElements::StopTimer() +{ + m_MenuTimer->Stop(); +} + diff --git a/stepmania/src/MenuElements.h b/stepmania/src/MenuElements.h index 6dabd2e8ec..69906be1ba 100644 --- a/stepmania/src/MenuElements.h +++ b/stepmania/src/MenuElements.h @@ -14,17 +14,18 @@ #include "Screen.h" #include "Sprite.h" -#include "MenuTimer.h" #include "Transition.h" #include "HelpDisplay.h" #include "BGAnimation.h" #include "ActorUtil.h" +#include "RageSound.h" - +class MenuTimer; class MenuElements : public ActorFrame { public: MenuElements(); + virtual ~MenuElements(); virtual void DrawPrimitives(); @@ -39,6 +40,8 @@ public: bool IsTransitioning(); bool m_bTimerEnabled; + void StopTimer(); + public: // let owner tinker with these objects CString m_sName; @@ -47,7 +50,7 @@ public: // let owner tinker with these objects AutoActor m_autoHeader; Sprite m_sprStyleIcon; - MenuTimer m_MenuTimer; + MenuTimer *m_MenuTimer; AutoActor m_autoFooter; HelpDisplay m_textHelp; diff --git a/stepmania/src/ScreenEz2SelectMusic.cpp b/stepmania/src/ScreenEz2SelectMusic.cpp index 43d2e16585..c760a3be06 100644 --- a/stepmania/src/ScreenEz2SelectMusic.cpp +++ b/stepmania/src/ScreenEz2SelectMusic.cpp @@ -27,6 +27,7 @@ #include "ActorUtil.h" #include "RageTextureManager.h" #include "AnnouncerManager.h" +#include "MenuTimer.h" #define SCROLLING_LIST_X THEME->GetMetricF("ScreenEz2SelectMusic","ScrollingListX") #define SCROLLING_LIST_Y THEME->GetMetricF("ScreenEz2SelectMusic","ScrollingListY") @@ -399,7 +400,7 @@ void ScreenEz2SelectMusic::HandleScreenMessage( const ScreenMessage SM ) void ScreenEz2SelectMusic::MenuRight( PlayerNumber pn, const InputEventType type ) { - m_Menu.m_MenuTimer.Stall(); + m_Menu.m_MenuTimer->Stall(); m_MusicBannerWheel.BannersRight(); for(int i=i_SkipAheadOffset; i>0; i--) m_MusicBannerWheel.BannersRight(); @@ -437,7 +438,7 @@ void ScreenEz2SelectMusic::TweenOffScreen() void ScreenEz2SelectMusic::MenuLeft( PlayerNumber pn, const InputEventType type ) { - m_Menu.m_MenuTimer.Stall(); + m_Menu.m_MenuTimer->Stall(); m_MusicBannerWheel.BannersLeft(); for(int i=i_SkipAheadOffset; i>0; i--) m_MusicBannerWheel.BannersLeft(); diff --git a/stepmania/src/ScreenEz2SelectPlayer.cpp b/stepmania/src/ScreenEz2SelectPlayer.cpp index f9d1759ce1..c5407857f8 100644 --- a/stepmania/src/ScreenEz2SelectPlayer.cpp +++ b/stepmania/src/ScreenEz2SelectPlayer.cpp @@ -21,6 +21,7 @@ Andrew Livy #include "RageException.h" #include "RageTimer.h" #include "ThemeManager.h" +#include "MenuTimer.h" /* Constants */ @@ -237,9 +238,9 @@ void ScreenEz2SelectPlayer::MenuStart( PlayerNumber pn ) else { // give the other player a little time to join - m_Menu.m_MenuTimer.SetSeconds( 1 ); - m_Menu.m_MenuTimer.Start(); - m_Menu.m_MenuTimer.EnableStealth( SILENT_WAIT ); // do we wanna make the timer 'quiet' ? + m_Menu.m_MenuTimer->SetSeconds( 1 ); + m_Menu.m_MenuTimer->Start(); + m_Menu.m_MenuTimer->EnableStealth( SILENT_WAIT ); // do we wanna make the timer 'quiet' ? } } diff --git a/stepmania/src/ScreenProfileOptions.cpp b/stepmania/src/ScreenProfileOptions.cpp index 3e702b0e80..bff8032254 100644 --- a/stepmania/src/ScreenProfileOptions.cpp +++ b/stepmania/src/ScreenProfileOptions.cpp @@ -81,7 +81,6 @@ ScreenProfileOptions::ScreenProfileOptions( CString sClassName ) : ScreenOptions INPUTMODE_TOGETHER, g_ProfileOptionsLines, NUM_PROFILE_OPTIONS_LINES ); - m_Menu.m_MenuTimer.Disable(); SOUND->PlayMusic( THEME->GetPathToS("ScreenMachineOptions music") ); } diff --git a/stepmania/src/ScreenSelectCharacter.cpp b/stepmania/src/ScreenSelectCharacter.cpp index c41fb579bf..83da623103 100644 --- a/stepmania/src/ScreenSelectCharacter.cpp +++ b/stepmania/src/ScreenSelectCharacter.cpp @@ -379,7 +379,7 @@ void ScreenSelectCharacter::MenuStart( PlayerNumber pn ) GAMESTATE->m_pCurCharacters[p] = pChar; } - m_Menu.m_MenuTimer.Stop(); + m_Menu.StopTimer(); TweenOffScreen(); this->PostScreenMessage( SM_BeginFadingOut, SLEEP_AFTER_TWEEN_OFF_SECONDS ); } diff --git a/stepmania/src/ScreenSelectDifficulty.cpp b/stepmania/src/ScreenSelectDifficulty.cpp index 6bcdb59f96..47557e3821 100644 --- a/stepmania/src/ScreenSelectDifficulty.cpp +++ b/stepmania/src/ScreenSelectDifficulty.cpp @@ -140,7 +140,7 @@ void ScreenSelectDifficulty::HandleScreenMessage( const ScreenMessage SM ) case SM_BeginFadingOut: TweenOffScreen(); SCREENMAN->PostMessageToTopScreen( SM_AllDoneChoosing, SLEEP_AFTER_TWEEN_OFF_SECONDS ); // nofify parent that we're finished - m_Menu.m_MenuTimer.Stop(); + m_Menu.StopTimer(); break; } } diff --git a/stepmania/src/ScreenSelectDifficultyEX.cpp b/stepmania/src/ScreenSelectDifficultyEX.cpp index 2e33e97003..ff57629ab4 100644 --- a/stepmania/src/ScreenSelectDifficultyEX.cpp +++ b/stepmania/src/ScreenSelectDifficultyEX.cpp @@ -166,7 +166,7 @@ void ScreenSelectDifficultyEX::HandleScreenMessage( const ScreenMessage SM ) case SM_BeginFadingOut: TweenOffScreen(); SCREENMAN->PostMessageToTopScreen( SM_AllDoneChoosing, SLEEP_AFTER_TWEEN_OFF_SECONDS ); // nofify parent that we're finished - m_Menu.m_MenuTimer.Stop(); + m_Menu.StopTimer(); break; } } diff --git a/stepmania/src/ScreenSelectGroup.cpp b/stepmania/src/ScreenSelectGroup.cpp index a1fdf46130..506d27760b 100644 --- a/stepmania/src/ScreenSelectGroup.cpp +++ b/stepmania/src/ScreenSelectGroup.cpp @@ -26,6 +26,7 @@ #include "ActorUtil.h" #include "GameState.h" #include "UnlockSystem.h" +#include "MenuTimer.h" #define BANNER_WIDTH THEME->GetMetricF("ScreenSelectGroup","BannerWidth") #define BANNER_HEIGHT THEME->GetMetricF("ScreenSelectGroup","BannerHeight") @@ -263,7 +264,7 @@ void ScreenSelectGroup::MenuStart( PlayerNumber pn ) return; m_soundSelect.PlayRandom(); - m_Menu.m_MenuTimer.Stop(); + m_Menu.m_MenuTimer->Stop(); m_bChosen = true; GAMESTATE->m_pCurSong = NULL; diff --git a/stepmania/src/ScreenSelectMaster.cpp b/stepmania/src/ScreenSelectMaster.cpp index c579c8cd21..dd1461c6a1 100644 --- a/stepmania/src/ScreenSelectMaster.cpp +++ b/stepmania/src/ScreenSelectMaster.cpp @@ -189,7 +189,7 @@ void ScreenSelectMaster::HandleScreenMessage( const ScreenMessage SM ) case SM_BeginFadingOut: float fSecs = TweenOffScreen(); SCREENMAN->PostMessageToTopScreen( SM_AllDoneChoosing, fSecs ); // nofify parent that we're finished - m_Menu.m_MenuTimer.Stop(); + m_Menu.StopTimer(); break; } } diff --git a/stepmania/src/ScreenSelectMusic.cpp b/stepmania/src/ScreenSelectMusic.cpp index 8348195a4a..ab6f8ac58e 100644 --- a/stepmania/src/ScreenSelectMusic.cpp +++ b/stepmania/src/ScreenSelectMusic.cpp @@ -35,6 +35,7 @@ #include "RageTextureManager.h" #include "Course.h" #include "ProfileManager.h" +#include "MenuTimer.h" const int NUM_SCORE_DIGITS = 9; @@ -695,12 +696,12 @@ void ScreenSelectMusic::HandleScreenMessage( const ScreenMessage SM ) if( m_MusicWheel.IsRouletting() ) { MenuStart(PLAYER_INVALID); - m_Menu.m_MenuTimer.SetSeconds( 15 ); + m_Menu.m_MenuTimer->SetSeconds( 15 ); } else if( m_MusicWheel.GetSelectedType() != TYPE_SONG ) { m_MusicWheel.StartRoulette(); - m_Menu.m_MenuTimer.SetSeconds( 15 ); + m_Menu.m_MenuTimer->SetSeconds( 15 ); } else { @@ -961,7 +962,7 @@ void ScreenSelectMusic::SwitchToPreferredDifficulty() void ScreenSelectMusic::AfterMusicChange() { if( !m_MusicWheel.IsRouletting() ) - m_Menu.m_MenuTimer.Stall(); + m_Menu.m_MenuTimer->Stall(); Song* pSong = m_MusicWheel.GetSelectedSong(); if( pSong )