From 48e9ff0f22af27a49467fdd0fd7aa8546bf0dfbe Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 18 Jan 2006 20:45:05 +0000 Subject: [PATCH] move "first update" stuff into ScreenGameplay::BeginScreen --- stepmania/src/ScreenGameplay.cpp | 114 +++++++++++++++---------------- stepmania/src/ScreenGameplay.h | 1 + 2 files changed, 58 insertions(+), 57 deletions(-) diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 77125907a0..5b5b0282a6 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -806,10 +806,6 @@ void ScreenGameplay::Init() this->SortByDrawOrder(); m_GiveUpTimer.SetZero(); - - // Get the transitions rolling on the first update. - // We can't do this in the constructor because ScreenGameplay is constructed - // in the middle of ScreenStage. } // @@ -1470,6 +1466,63 @@ void ScreenGameplay::UpdateSongPosition( float fDeltaTime ) GAMESTATE->UpdateSongPosition( fSeconds+fAdjust, GAMESTATE->m_pCurSong->m_Timing, tm+fAdjust ); } +void ScreenGameplay::BeginScreen() +{ + ScreenWithMenuElements::BeginScreen(); + + if( GAMESTATE->m_pCurSong == NULL ) + return; + + SOUND->PlayOnceFromAnnouncer( "gameplay intro" ); // crowd cheer + + // + // Get the transitions rolling + // + if( GAMESTATE->m_bDemonstrationOrJukebox ) + { + StartPlayingSong( 0, 0 ); // *kick* (no transitions) + } + else if( NSMAN->useSMserver ) + { + //If we're using networking, we must not have any + //delay. If we do this can cause inconsistancy + //on different computers and differet themes + + StartPlayingSong( 0, 0 ); + m_pSoundMusic->Stop(); + + float startOffset = g_fNetStartOffset; + + NSMAN->StartRequest(1); + + RageSoundParams p; + p.m_bAccurateSync = true; + p.SetPlaybackRate( 1.0 ); //Force 1.0 playback speed + p.StopMode = RageSoundParams::M_CONTINUE; + p.m_StartSecond = startOffset; + m_pSoundMusic->Play( &p ); + + UpdateSongPosition(0); + } + else + { + float fMinTimeToMusic = m_In.GetLengthSeconds(); // start of m_Ready + float fMinTimeToNotes = fMinTimeToMusic + m_Ready.GetLengthSeconds() + m_Go.GetLengthSeconds()+2; // end of Go + + /* + * Tell the music to start, but don't actually make any noise for + * at least 2.5 (or 1.5) seconds. (This is so we scroll on screen smoothly.) + * + * This is only a minimum: the music might be started later, to meet + * the minimum-time-to-notes value. If you're writing song data, + * and you want to make sure we get ideal timing here, make sure there's + * a bit of space at the beginning of the music with no steps. + */ + + /*float delay =*/ StartPlayingSong( fMinTimeToNotes, fMinTimeToMusic ); + } +} + void ScreenGameplay::Update( float fDeltaTime ) { if( GAMESTATE->m_pCurSong == NULL ) @@ -1481,59 +1534,6 @@ void ScreenGameplay::Update( float fDeltaTime ) return; } - if( m_bFirstUpdate ) - { - SOUND->PlayOnceFromAnnouncer( "gameplay intro" ); // crowd cheer - - // - // Get the transitions rolling - // - if( GAMESTATE->m_bDemonstrationOrJukebox ) - { - StartPlayingSong( 0, 0 ); // *kick* (no transitions) - } - else if ( NSMAN->useSMserver ) - { - //If we're using networking, we must not have any - //delay. If we do this can cause inconsistancy - //on different computers and differet themes - - StartPlayingSong( 0, 0 ); - m_pSoundMusic->Stop(); - - float startOffset = g_fNetStartOffset; - - NSMAN->StartRequest(1); - - RageSoundParams p; - p.m_bAccurateSync = true; - p.SetPlaybackRate( 1.0 ); //Force 1.0 playback speed - p.StopMode = RageSoundParams::M_CONTINUE; - p.m_StartSecond = startOffset; - m_pSoundMusic->Play( &p ); - - UpdateSongPosition(0); - } - else - { - float fMinTimeToMusic = m_In.GetLengthSeconds(); // start of m_Ready - float fMinTimeToNotes = fMinTimeToMusic + m_Ready.GetLengthSeconds() + m_Go.GetLengthSeconds()+2; // end of Go - - /* - * Tell the music to start, but don't actually make any noise for - * at least 2.5 (or 1.5) seconds. (This is so we scroll on screen smoothly.) - * - * This is only a minimum: the music might be started later, to meet - * the minimum-time-to-notes value. If you're writing song data, - * and you want to make sure we get ideal timing here, make sure there's - * a bit of space at the beginning of the music with no steps. - */ - - /*float delay =*/ StartPlayingSong( fMinTimeToNotes, fMinTimeToMusic ); - } - } - - UpdateSongPosition( fDeltaTime ); if( m_bZeroDeltaOnNextUpdate ) diff --git a/stepmania/src/ScreenGameplay.h b/stepmania/src/ScreenGameplay.h index eb0ca2b968..156999328e 100644 --- a/stepmania/src/ScreenGameplay.h +++ b/stepmania/src/ScreenGameplay.h @@ -100,6 +100,7 @@ public: ScreenGameplay(); virtual void Init(); virtual ~ScreenGameplay(); + virtual void BeginScreen(); virtual void Update( float fDeltaTime ); virtual void Input( const InputEventPlus &input );