This commit is contained in:
Glenn Maynard
2005-06-08 21:50:55 +00:00
parent 935675cef6
commit 0422d2b1c5
2 changed files with 19 additions and 21 deletions
+18 -20
View File
@@ -1,7 +1,6 @@
#include "global.h"
#include "LyricDisplay.h"
#include "ScreenDimensions.h"
#include "GameState.h"
#include "ThemeMetric.h"
@@ -9,7 +8,7 @@ static ThemeMetric<apActorCommands> IN_COMMAND ("LyricDisplay","InCommand");
static ThemeMetric<apActorCommands> OUT_COMMAND ("LyricDisplay","OutCommand");
static ThemeMetric<RageColor> WIPE_DIM_FACTOR ("LyricDisplay","WipeDimFactor");
static float g_TweenInTime, g_TweenOutTime;
static float g_fTweenInTime, g_fTweenOutTime;
LyricDisplay::LyricDisplay()
{
@@ -17,7 +16,7 @@ LyricDisplay::LyricDisplay()
{
m_textLyrics[i].LoadFromFont( THEME->GetPathF("LyricDisplay","text") );
m_textLyrics[i].SetDiffuse( RageColor(1,1,1,1) );
this->AddChild(&m_textLyrics[i]);
this->AddChild( &m_textLyrics[i] );
}
Init();
@@ -30,8 +29,8 @@ void LyricDisplay::Init()
m_iCurLyricNumber = 0;
/* Update global cache: */
g_TweenInTime = Actor::GetCommandsLengthSeconds(IN_COMMAND);
g_TweenOutTime = Actor::GetCommandsLengthSeconds(OUT_COMMAND);
g_fTweenInTime = Actor::GetCommandsLengthSeconds( IN_COMMAND );
g_fTweenOutTime = Actor::GetCommandsLengthSeconds( OUT_COMMAND );
m_fLastSecond = -500;
}
@@ -47,14 +46,13 @@ void LyricDisplay::Update( float fDeltaTime )
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;
const Song *song = GAMESTATE->m_pCurSong;
const float fStartTime = (song->m_LyricSegments[m_iCurLyricNumber].m_fStartTime) - g_TweenInTime;
const Song *pSong = GAMESTATE->m_pCurSong;
const float fStartTime = (pSong->m_LyricSegments[m_iCurLyricNumber].m_fStartTime) - g_fTweenInTime;
if(GAMESTATE->m_fMusicSeconds < fStartTime)
if( GAMESTATE->m_fMusicSeconds < fStartTime )
return;
const float MaxDisplayTime = 10;
@@ -63,22 +61,22 @@ void LyricDisplay::Update( float fDeltaTime )
/* 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())
EndTime = song->m_LyricSegments[m_iCurLyricNumber+1].m_fStartTime;
float fEndTime;
if( m_iCurLyricNumber+1 < GAMESTATE->m_pCurSong->m_LyricSegments.size() )
fEndTime = pSong->m_LyricSegments[m_iCurLyricNumber+1].m_fStartTime;
else
EndTime = song->GetElapsedTimeFromBeat( song->m_fLastBeat );
fEndTime = pSong->GetElapsedTimeFromBeat( pSong->m_fLastBeat );
const float Distance = EndTime - song->m_LyricSegments[m_iCurLyricNumber].m_fStartTime;
const float TweenBufferTime = g_TweenInTime + g_TweenOutTime;
const float fDistance = fEndTime - pSong->m_LyricSegments[m_iCurLyricNumber].m_fStartTime;
const float fTweenBufferTime = g_fTweenInTime + g_fTweenOutTime;
fShowLength = min(fShowLength, Distance - TweenBufferTime);
fShowLength = min(fShowLength, 3);
fShowLength = min( fShowLength, fDistance - fTweenBufferTime );
fShowLength = min( fShowLength, 3 );
/* 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 = max( fShowLength, 0 );
// make lyrics show faster a larger song rates.
fShowLength /= GAMESTATE->m_SongOptions.m_fMusicRate;
@@ -97,14 +95,14 @@ void LyricDisplay::Update( float fDeltaTime )
const float fZoom = min( 1.0f, float(SCREEN_WIDTH)/(m_textLyrics[i].GetZoomedWidth()+1) );
m_textLyrics[i].StopTweening();
m_textLyrics[i].SetZoomX(fZoom);
m_textLyrics[i].SetZoomX( fZoom );
RageColor color = GAMESTATE->m_pCurSong->m_LyricSegments[m_iCurLyricNumber].m_Color;
if( i==0 )
color *= WIPE_DIM_FACTOR;
m_textLyrics[i].SetDiffuse(color);
m_textLyrics[i].SetDiffuse( color );
/* Crop the bottom layer of text away as we crop the top layer on. That
* prevents overdraw, which reduces AA quality. */
+1 -1
View File
@@ -9,7 +9,7 @@ class LyricDisplay: public ActorFrame
{
public:
LyricDisplay();
void Update(float fDeltaTime);
void Update( float fDeltaTime );
/* Call when song changes: */
void Init();