From 9e0a1e08aa42f96acdd8ba94c5305adaa82e2412 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 18 May 2003 22:37:20 +0000 Subject: [PATCH] Fix lyrics in courses --- stepmania/src/LyricDisplay.cpp | 33 +++++++++++++++++++++------------ stepmania/src/LyricDisplay.h | 1 + 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/stepmania/src/LyricDisplay.cpp b/stepmania/src/LyricDisplay.cpp index 99bdd6b8d2..023bd37e06 100644 --- a/stepmania/src/LyricDisplay.cpp +++ b/stepmania/src/LyricDisplay.cpp @@ -26,12 +26,18 @@ void LyricDisplay::Init() /* Update global cache: */ g_TweenInTime = Actor::GetCommandLength(IN_COMMAND); g_TweenOutTime = Actor::GetCommandLength(OUT_COMMAND); + m_fLastSecond = -500; } void LyricDisplay::Update( float fDeltaTime ) { ActorFrame::Update( fDeltaTime ); + /* If the song has changed (in a course), reset. */ + if( GAMESTATE->m_fMusicSeconds < m_fLastSecond ) + Init(); + m_fLastSecond = GAMESTATE->m_fMusicSeconds; + // Make sure we don't go over the array's boundry if( m_iCurLyricNumber >= GAMESTATE->m_pCurSong->m_LyricSegments.size() ) return; @@ -46,21 +52,24 @@ void LyricDisplay::Update( float fDeltaTime ) float fShowLength = MaxDisplayTime; + /* Clamp this lyric to the beginning of the next, the end of the music, + * or 5 seconds. */ + float EndTime; if(m_iCurLyricNumber+1 < GAMESTATE->m_pCurSong->m_LyricSegments.size()) - { - /* Clamp this lyric to the beginning of the next. */ - const float Distance = - song->m_LyricSegments[m_iCurLyricNumber+1].m_fStartTime - - song->m_LyricSegments[m_iCurLyricNumber].m_fStartTime; - const float TweenBufferTime = g_TweenInTime + g_TweenOutTime; + EndTime = song->m_LyricSegments[m_iCurLyricNumber+1].m_fStartTime; + else + EndTime = song->GetElapsedTimeFromBeat( song->m_fLastBeat ); - fShowLength = min(fShowLength, Distance - TweenBufferTime); + const float Distance = EndTime - song->m_LyricSegments[m_iCurLyricNumber].m_fStartTime; + const float TweenBufferTime = g_TweenInTime + g_TweenOutTime; - /* If it's negative, two lyrics are so close together that there's no time - * to tween properly. Lyrics should never be this brief, anyway, so just - * skip it. */ - fShowLength = max(fShowLength, 0); - } + fShowLength = min(fShowLength, Distance - TweenBufferTime); + fShowLength = min(fShowLength, 5); + + /* If it's negative, two lyrics are so close together that there's no time + * to tween properly. Lyrics should never be this brief, anyway, so just + * skip it. */ + fShowLength = max(fShowLength, 0); m_textLyrics.SetText( GAMESTATE->m_pCurSong->m_LyricSegments[m_iCurLyricNumber].m_sLyric ); diff --git a/stepmania/src/LyricDisplay.h b/stepmania/src/LyricDisplay.h index 37f82b9d50..4e64b0653e 100644 --- a/stepmania/src/LyricDisplay.h +++ b/stepmania/src/LyricDisplay.h @@ -16,6 +16,7 @@ public: private: BitmapText m_textLyrics; unsigned m_iCurLyricNumber; + float m_fLastSecond; }; #endif