From 59b59214e9134b191f45e78a5558b1c96900c50d Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 22 Mar 2005 22:53:39 +0000 Subject: [PATCH] fix attract music logic --- stepmania/src/ScreenAttract.cpp | 20 ++++++++++++-------- stepmania/src/ScreenAttract.h | 1 + stepmania/src/ScreenWithMenuElements.cpp | 15 ++++++++++----- stepmania/src/ScreenWithMenuElements.h | 2 ++ 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/stepmania/src/ScreenAttract.cpp b/stepmania/src/ScreenAttract.cpp index e7ee8b4721..6f7d2f2a1c 100644 --- a/stepmania/src/ScreenAttract.cpp +++ b/stepmania/src/ScreenAttract.cpp @@ -108,15 +108,19 @@ void ScreenAttract::AttractInput( const DeviceInput& DeviceI, const InputEventTy // Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); } +void ScreenAttract::StartPlayingMusic() +{ + if( !GAMESTATE->IsTimeToPlayAttractSounds() ) + { + SOUND->PlayMusic( "" ); // stop music + return; + } + + ScreenWithMenuElements::StartPlayingMusic(); +} + void ScreenAttract::Update( float fDelta ) { - if( IsFirstUpdate() ) - { - if( GAMESTATE->IsTimeToPlayAttractSounds() ) - SOUND->PlayMusic( THEME->GetPathS(m_sName,"music") ); - else - SOUND->PlayMusic( "" ); // stop music - } ScreenWithMenuElements::Update(fDelta); } @@ -135,7 +139,7 @@ void ScreenAttract::HandleScreenMessage( const ScreenMessage SM ) * going to interrupt it when we fade in, stop the old music before we fade out. */ bool bMusicChanging = false; if( PLAY_MUSIC ) - bMusicChanging = THEME->GetPathS(NEXT_SCREEN,"music") != THEME->GetPathS(m_sName,"music",true); // GetPath optional on the next screen because it may not have music. + bMusicChanging = THEME->GetPathS(m_sName,"music") != THEME->GetPathS(NEXT_SCREEN,"music",true); // GetPath optional on the next screen because it may not have music. if( bMusicChanging ) SOUND->PlayMusic( "" ); // stop the music diff --git a/stepmania/src/ScreenAttract.h b/stepmania/src/ScreenAttract.h index aecaf8a3ea..79b0013930 100644 --- a/stepmania/src/ScreenAttract.h +++ b/stepmania/src/ScreenAttract.h @@ -19,6 +19,7 @@ public: virtual void HandleScreenMessage( const ScreenMessage SM ); protected: + virtual void StartPlayingMusic(); }; diff --git a/stepmania/src/ScreenWithMenuElements.cpp b/stepmania/src/ScreenWithMenuElements.cpp index 6b54fd6df3..e1d3a05334 100644 --- a/stepmania/src/ScreenWithMenuElements.cpp +++ b/stepmania/src/ScreenWithMenuElements.cpp @@ -122,6 +122,14 @@ ScreenWithMenuElements::~ScreenWithMenuElements() SAFE_DELETE( m_textHelp ); } +void ScreenWithMenuElements::StartPlayingMusic() +{ + /* Some screens should leave the music alone (eg. ScreenPlayerOptions music + * sample left over from ScreenSelectMusic). */ + if( PLAY_MUSIC ) + SOUND->PlayMusic( THEME->GetPathS(m_sName,"music") ); +} + void ScreenWithMenuElements::Update( float fDeltaTime ) { if( m_bFirstUpdate ) @@ -130,11 +138,8 @@ void ScreenWithMenuElements::Update( float fDeltaTime ) * Play sounds after so loading so we don't thrash while loading files. */ SOUND->PlayOnceFromDir( ANNOUNCER->GetPathTo(m_sName+" intro") ); - /* Some screens should leave the music alone (eg. ScreenPlayerOptions music - * sample left over from ScreenSelectMusic). */ - if( PLAY_MUSIC ) - SOUND->PlayMusic( THEME->GetPathS(m_sName,"music") ); - + StartPlayingMusic(); + /* Evaluate FirstUpdateCommand. */ this->RunCommands( FIRST_UPDATE_COMMAND ); } diff --git a/stepmania/src/ScreenWithMenuElements.h b/stepmania/src/ScreenWithMenuElements.h index d3f9d2fc6b..627fe9557a 100644 --- a/stepmania/src/ScreenWithMenuElements.h +++ b/stepmania/src/ScreenWithMenuElements.h @@ -29,6 +29,8 @@ public: void ResetTimer(); protected: + virtual void StartPlayingMusic(); + AutoActor m_sprUnderlay; AutoActor m_autoHeader; Sprite m_sprStyleIcon;