From 85c9e8a89e0327a09f5d2cf04eda71929e95b89b Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 13 Apr 2003 06:29:02 +0000 Subject: [PATCH] repositioned MenuElements "play sound on first update" hack inside of Transition where it belongs --- stepmania/src/CodeDetector.cpp | 4 +--- stepmania/src/MenuElements.cpp | 10 +--------- stepmania/src/MenuElements.h | 2 -- stepmania/src/ScreenDemonstration.cpp | 2 +- stepmania/src/ScreenManager.cpp | 2 ++ stepmania/src/ScreenSandbox.cpp | 18 ++++++++++++++++++ stepmania/src/ScreenSandbox.h | 6 ++++++ stepmania/src/ScreenSelectGroup.cpp | 2 -- stepmania/src/ScreenTitleMenu.cpp | 1 + stepmania/src/Transition.cpp | 19 ++++++++++++++----- 10 files changed, 44 insertions(+), 22 deletions(-) diff --git a/stepmania/src/CodeDetector.cpp b/stepmania/src/CodeDetector.cpp index a8eeaa1bd3..49cc9c3f6b 100644 --- a/stepmania/src/CodeDetector.cpp +++ b/stepmania/src/CodeDetector.cpp @@ -138,7 +138,7 @@ bool CodeDetector::DetectAndAdjustMusicOptions( GameController controller ) const StyleDef* pStyleDef = GAMESTATE->GetCurrentStyleDef(); PlayerNumber pn = pStyleDef->ControllerToPlayerNumber( controller ); - for( int c=0; cm_PlayerOptions[pn].m_bHoldNotes, true, false ); break; case CODE_DARK: FLOAT_TOGGLE( GAMESTATE->m_PlayerOptions[pn].m_fDark ); break; case CODE_CANCEL_ALL: GAMESTATE->m_PlayerOptions[pn].Init(); break; - default: - ASSERT(0); // unhandled code } return true; // don't check any more } diff --git a/stepmania/src/MenuElements.cpp b/stepmania/src/MenuElements.cpp index 4fbed41bc0..229e5bc7a5 100644 --- a/stepmania/src/MenuElements.cpp +++ b/stepmania/src/MenuElements.cpp @@ -94,19 +94,11 @@ void MenuElements::Load( CString sClassName, bool bEnableTimer, bool bLoadStyleI m_soundBack.Load( THEME->GetPathToS("Common back") ); - m_bStartedTransitionIn = false; + m_In.StartTransitioning(); } void MenuElements::Update( float fDeltaTime ) { - if(!m_bStartedTransitionIn) - { - /* Start the transition on the first update, not in the ctor, so - * we don't play a sound while our parent is still loading. */ - m_bStartedTransitionIn = true; - m_In.StartTransitioning( SM_None ); - } - ActorFrame::Update(fDeltaTime); } diff --git a/stepmania/src/MenuElements.h b/stepmania/src/MenuElements.h index e6c9cac96b..91edd7bd2b 100644 --- a/stepmania/src/MenuElements.h +++ b/stepmania/src/MenuElements.h @@ -54,8 +54,6 @@ public: // let owner tinker with these objects Transition m_Back; RageSound m_soundBack; - - bool m_bStartedTransitionIn; }; #endif diff --git a/stepmania/src/ScreenDemonstration.cpp b/stepmania/src/ScreenDemonstration.cpp index 122556d69e..6afbc63f86 100644 --- a/stepmania/src/ScreenDemonstration.cpp +++ b/stepmania/src/ScreenDemonstration.cpp @@ -52,7 +52,7 @@ ScreenDemonstration::ScreenDemonstration() : ScreenJukebox( PrepareForDemonstrat if( GAMESTATE->m_pCurSong == NULL ) // we didn't find a song. { - this->PostScreenMessage( SM_GoToNextScreen, 0 ); // Abort demonstration. + HandleScreenMessage( SM_GoToNextScreen ); // Abort demonstration. return; } diff --git a/stepmania/src/ScreenManager.cpp b/stepmania/src/ScreenManager.cpp index 7a7b2582cd..1656902502 100644 --- a/stepmania/src/ScreenManager.cpp +++ b/stepmania/src/ScreenManager.cpp @@ -332,6 +332,8 @@ void ScreenManager::Update( float fDeltaTime ) else pScreen->Update( fDeltaTime ); + // TODO: If a new Screen is set during this Update, that new screen is Drawn + // before it's first Update. m_SystemLayer->Update( fDeltaTime ); EmptyDeleteQueue(); diff --git a/stepmania/src/ScreenSandbox.cpp b/stepmania/src/ScreenSandbox.cpp index 2ec66f75f4..e146af1b46 100644 --- a/stepmania/src/ScreenSandbox.cpp +++ b/stepmania/src/ScreenSandbox.cpp @@ -17,6 +17,7 @@ #include "ScreenSandbox.h" #include "GameConstantsAndTypes.h" +#include "ThemeManager.h" ScreenSandbox::ScreenSandbox() : Screen("ScreenSandbox") @@ -32,6 +33,10 @@ ScreenSandbox::ScreenSandbox() : Screen("ScreenSandbox") obj.SetXY(CENTER_X, CENTER_Y); // obj.SetZoom(50); this->AddChild(&obj); + + this->AddChild( &m_In ); + + this->AddChild( &m_Out ); } void ScreenSandbox::HandleScreenMessage( const ScreenMessage SM ) @@ -40,9 +45,22 @@ void ScreenSandbox::HandleScreenMessage( const ScreenMessage SM ) void ScreenSandbox::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ) { + Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); } void ScreenSandbox::Update( float fDeltaTime ) { Screen::Update(fDeltaTime); } + +void ScreenSandbox::MenuLeft( PlayerNumber pn ) +{ + m_In.Load( THEME->GetPathToB("_menu in") ); + m_In.StartTransitioning(); +} + +void ScreenSandbox::MenuRight( PlayerNumber pn ) +{ + m_Out.Load( THEME->GetPathToB("_menu out") ); + m_Out.StartTransitioning(); +} \ No newline at end of file diff --git a/stepmania/src/ScreenSandbox.h b/stepmania/src/ScreenSandbox.h index 2ba551c2dc..176af958f2 100644 --- a/stepmania/src/ScreenSandbox.h +++ b/stepmania/src/ScreenSandbox.h @@ -14,6 +14,7 @@ #include "Screen.h" #include "Sample3dObject.h" #include "Quad.h" +#include "Transition.h" class ScreenSandbox : public Screen { @@ -23,9 +24,14 @@ public: virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ); virtual void HandleScreenMessage( const ScreenMessage SM ); + void MenuLeft( PlayerNumber pn ); + void MenuRight( PlayerNumber pn ); + void Update(float f); Sample3dObject obj; Quad m_quad; + Transition m_In; + Transition m_Out; }; diff --git a/stepmania/src/ScreenSelectGroup.cpp b/stepmania/src/ScreenSelectGroup.cpp index 995efbb34c..a84fb7eef0 100644 --- a/stepmania/src/ScreenSelectGroup.cpp +++ b/stepmania/src/ScreenSelectGroup.cpp @@ -32,8 +32,6 @@ #define BANNER_WIDTH THEME->GetMetricF("ScreenSelectGroup","BannerWidth") #define BANNER_HEIGHT THEME->GetMetricF("ScreenSelectGroup","BannerHeight") #define SLEEP_AFTER_TWEEN_OFF_SECONDS THEME->GetMetricF("ScreenSelectGroup","SleepAfterTweenOffSeconds") -#define HELP_TEXT THEME->GetMetric ("ScreenSelectGroup","HelpText") -#define TIMER_SECONDS THEME->GetMetricI("ScreenSelectGroup","TimerSeconds") #define NEXT_SCREEN THEME->GetMetric ("ScreenSelectGroup","NextScreen") diff --git a/stepmania/src/ScreenTitleMenu.cpp b/stepmania/src/ScreenTitleMenu.cpp index 16a4c8fc57..5b30a2b4ba 100644 --- a/stepmania/src/ScreenTitleMenu.cpp +++ b/stepmania/src/ScreenTitleMenu.cpp @@ -55,6 +55,7 @@ ScreenTitleMenu::ScreenTitleMenu() : Screen("ScreenTitleMenu") { LOG->Trace( "ScreenTitleMenu::ScreenTitleMenu()" ); + GAMESTATE->Reset(); GAMESTATE->m_bPlayersCanJoin = true; CodeDetector::RefreshCacheItems(); diff --git a/stepmania/src/Transition.cpp b/stepmania/src/Transition.cpp index c51d57670f..ea70e868de 100644 --- a/stepmania/src/Transition.cpp +++ b/stepmania/src/Transition.cpp @@ -51,15 +51,20 @@ void Transition::Update( float fDeltaTime ) if( m_State == transitioning ) { + /* Start the transition on the first update, not in the ctor, so + * we don't play a sound while our parent is still loading. */ + if( m_fSecsIntoTransition==0 ) // first update + m_sound.PlayRandom(); + m_BGAnimation.Update( fDeltaTime ); if( m_fSecsIntoTransition > m_BGAnimation.GetLengthSeconds() ) // over { + SCREENMAN->SendMessageToTopScreen( m_MessageToSendWhenDone ); m_fSecsIntoTransition = 0.0; m_State = finished; - SCREENMAN->SendMessageToTopScreen( m_MessageToSendWhenDone ); } - - m_fSecsIntoTransition += fDeltaTime; + else + m_fSecsIntoTransition += fDeltaTime; } } @@ -67,8 +72,13 @@ void Transition::DrawPrimitives() { // Unless we're transitioning, don't draw because we'll waste resources drawing things // that aren't visible. -Chris - if( m_State != transitioning ) + switch( m_State ) + { +// case waiting: +// return; + case finished: return; + } m_BGAnimation.Draw(); } @@ -78,7 +88,6 @@ void Transition::StartTransitioning( ScreenMessage send_when_done ) ASSERT( m_State == waiting ); // can't call this more than once m_MessageToSendWhenDone = send_when_done; m_State = transitioning; - m_sound.PlayRandom(); m_fSecsIntoTransition = 0.0; }