From 56a0316a8ad253d4c9a64f4c1a0424b7cf8f3afd Mon Sep 17 00:00:00 2001 From: Ben Anderson Date: Sat, 23 Oct 2004 14:38:08 +0000 Subject: [PATCH] Optimization, and slightly more professional-looking behavior for the song progress meter. --- stepmania/src/ScreenGameplay.cpp | 24 ++++++++++++------------ stepmania/src/ScreenGameplay.h | 4 ++++ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 9ee7a2da3d..68066f2124 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -1065,6 +1065,12 @@ void ScreenGameplay::LoadNextSong() m_bZeroDeltaOnNextUpdate = true; + // (Re)Calculate the song position meter + m_fSongPosMeterOffset = GAMESTATE->m_pCurSong->m_Timing.GetElapsedTimeFromBeat( + GAMESTATE->m_pCurSong->m_fFirstBeat ); + m_fSongPosMeterEnd = ( GAMESTATE->m_pCurSong->m_Timing.GetElapsedTimeFromBeat( + GAMESTATE->m_pCurSong->m_fLastBeat ) - m_fSongPosMeterOffset ); + // // Load cabinet lights data // @@ -1592,19 +1598,13 @@ void ScreenGameplay::Update( float fDeltaTime ) // // update song position meter // - // Because most songs have a leadout, consider the last beat to be the - // end of the song as far as the meter is concerned. So, get the time of - // the last beat of the song. - // - // XXX My hunch tells me doing this every update will slow things down, - // but at least it's somewhat accurate. We probably should do this - // when the meter inits, shove it in a variable somewhere, and go by - // that. At least it's better than blind fudging... - float fMusicLengthSeconds = - GAMESTATE->m_pCurSong->m_Timing.GetElapsedTimeFromBeat( - GAMESTATE->m_pCurSong->m_fLastBeat ); + // IMHHO, The song position bar is best used to represent where in the + // step sequence the players are. It looks "better" that way, showing a + // song "depleting" as the players wear on. So, it starts "ticking" at + // the first arrow and winds down to the very end. + float fPercentPositionSong = ( GAMESTATE->m_fMusicSeconds - m_fSongPosMeterOffset ) / + m_fSongPosMeterEnd; - float fPercentPositionSong = GAMESTATE->m_fMusicSeconds / fMusicLengthSeconds; CLAMP( fPercentPositionSong, 0, 1 ); m_meterSongPosition.SetPercent( fPercentPositionSong ); diff --git a/stepmania/src/ScreenGameplay.h b/stepmania/src/ScreenGameplay.h index eee0cc9e92..d38d0bc0d3 100644 --- a/stepmania/src/ScreenGameplay.h +++ b/stepmania/src/ScreenGameplay.h @@ -179,6 +179,10 @@ protected: BeginnerHelper m_BeginnerHelper; NoteData m_CabinetLightsNoteData; + +private: + float m_fSongPosMeterEnd; + float m_fSongPosMeterOffset; };