From 46c7457ab5278f191e0849bff954d78f0ec3df86 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 19 Mar 2003 17:43:11 +0000 Subject: [PATCH] move lyric updating into a separate function (trying to debug a crash; 6+ levels of indentation makes that hard) --- stepmania/src/ScreenGameplay.cpp | 103 ++++++++++++++++--------------- stepmania/src/ScreenGameplay.h | 1 + 2 files changed, 54 insertions(+), 50 deletions(-) diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index b8cc4eab44..3531eb73b4 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -774,6 +774,58 @@ bool ScreenGameplay::IsTimeToPlayTicks() const return bAnyoneHasANote; } +void ScreenGameplay::UpdateLyrics( float fDeltaTime ) +{ + // + // Check if we should show lyrics now + // + if( !m_bHasLyrics ) + return; + + m_fLyricsTime += fDeltaTime; + float fStartTime = (GAMESTATE->m_pCurSong->m_LyricSegments[m_iCurLyricNumber].m_fStartTime); + + // Make sure we don't go over the array's boundry + if( m_iCurLyricNumber <= GAMESTATE->m_pCurSong->m_LyricSegments.size() ) + { + // Check if it's time to animate the old lyrics to off-screen + if( (fStartTime - m_fLyricsTime) <= .30 || (fStartTime - m_fLyricsTime) <= -.30f) + { + m_textLyrics.FadeOff( 0, "foldy", .20f); + } + + if( m_fLyricsTime >= fStartTime ) + { + /*I figure for longer lines of text, the Lyric display object should + be scaled down, if needed, by the .ScaleTo() function. But somehow + it jus ain't working for me at all.. anyone able to do this + properly?? We prolly should also add detection of where to put + the Lyric object, if the arrows are on reverse? Jus an idea, + but it kinda defeats the purpose of the Lyric object X/Y being a + theme element :) + + BTW: Once the function is done, this will also be where the color + of this lyric block will be set -- Miryokuteki */ + //m_textLyrics.SetDiffuse(COLOR HERE); + + /*if( GAMESTATE->m_pCurSong->m_LyricSegments[m_iCurLyricNumber].m_sLyric == "" || GAMESTATE->m_pCurSong->m_LyricSegments[m_iCurLyricNumber].m_sLyric == " " ) + { + For some reason, once this fades off, it never comes back when + it's called! -- Miryokuteki + + m_textLyrics.FadeOff( 0, "fade", .10f ); + m_iCurLyricNumber++; + } + else + { + */ + m_textLyrics.FadeOn( 0, "foldy", .20f ); + m_textLyrics.SetText( GAMESTATE->m_pCurSong->m_LyricSegments[m_iCurLyricNumber].m_sLyric ); + m_iCurLyricNumber++; + //} + } + } +} void ScreenGameplay::Update( float fDeltaTime ) { @@ -841,56 +893,7 @@ void ScreenGameplay::Update( float fDeltaTime ) switch( m_DancingState ) { case STATE_DANCING: - - // - // Check if we should show lyrics now - // - if( (m_bHasLyrics) ) // Every song without lyrics would crash here.. bug fix -- Miryokuteki - { - m_fLyricsTime += fDeltaTime; - float fStartTime = (GAMESTATE->m_pCurSong->m_LyricSegments[m_iCurLyricNumber].m_fStartTime); - - // Make sure we don't go over the array's boundry - if( m_iCurLyricNumber <= GAMESTATE->m_pCurSong->m_LyricSegments.size() ) - { - // Check if it's time to animate the old lyrics to off-screen - if( (fStartTime - m_fLyricsTime) <= .30 || (fStartTime - m_fLyricsTime) <= -.30f) - { - m_textLyrics.FadeOff( 0, "foldy", .20f); - } - - if( m_fLyricsTime >= fStartTime ) - { - /*I figure for longer lines of text, the Lyric display object should - be scaled down, if needed, by the .ScaleTo() function. But somehow - it jus ain't working for me at all.. anyone able to do this - properly?? We prolly should also add detection of where to put - the Lyric object, if the arrows are on reverse? Jus an idea, - but it kinda defeats the purpose of the Lyric object X/Y being a - theme element :) - - BTW: Once the function is done, this will also be where the color - of this lyric block will be set -- Miryokuteki */ - //m_textLyrics.SetDiffuse(COLOR HERE); - - /*if( GAMESTATE->m_pCurSong->m_LyricSegments[m_iCurLyricNumber].m_sLyric == "" || GAMESTATE->m_pCurSong->m_LyricSegments[m_iCurLyricNumber].m_sLyric == " " ) - { - For some reason, once this fades off, it never comes back when - it's called! -- Miryokuteki - - m_textLyrics.FadeOff( 0, "fade", .10f ); - m_iCurLyricNumber++; - } - else - { - */ - m_textLyrics.FadeOn( 0, "foldy", .20f ); - m_textLyrics.SetText( GAMESTATE->m_pCurSong->m_LyricSegments[m_iCurLyricNumber].m_sLyric ); - m_iCurLyricNumber++; - //} - } - } - } + UpdateLyrics(fDeltaTime); // // Update players' alive time diff --git a/stepmania/src/ScreenGameplay.h b/stepmania/src/ScreenGameplay.h index dae9946525..a2fa6c88a2 100644 --- a/stepmania/src/ScreenGameplay.h +++ b/stepmania/src/ScreenGameplay.h @@ -75,6 +75,7 @@ protected: bool AllAreFailing(); bool AllFailedEarlier(); bool IsTimeToPlayTicks() const; + void UpdateLyrics( float fDeltaTime ); enum DancingState { STATE_INTRO = 0, // not allowed to press Back