More abstraction.

This commit is contained in:
Jason Felds
2011-06-30 02:10:58 -04:00
parent 80d3618b8e
commit 5940bdeddb
13 changed files with 26 additions and 32 deletions
+3 -4
View File
@@ -577,9 +577,8 @@ void BackgroundImpl::LoadFromSong( const Song* pSong )
else // pSong doesn't have an animation plan
{
Layer &layer = m_Layer[0];
const TimingData &t = pSong->m_SongTiming;
float firstBeat = t.GetBeatFromElapsedTime(pSong->firstSecond);
float lastBeat = t.GetBeatFromElapsedTime(pSong->lastSecond);
float firstBeat = pSong->GetFirstBeat();
float lastBeat = pSong->GetLastBeat();
LoadFromRandom( firstBeat, lastBeat, BackgroundChange() );
@@ -645,7 +644,7 @@ void BackgroundImpl::LoadFromSong( const Song* pSong )
continue;
float fStartBeat = change.m_fStartBeat;
float fEndBeat = pSong->m_SongTiming.GetBeatFromElapsedTime(pSong->lastSecond);
float fEndBeat = pSong->GetLastBeat();
if( i+1 < mainlayer.m_aBGChanges.size() )
fEndBeat = mainlayer.m_aBGChanges[i+1].m_fStartBeat;
+2 -4
View File
@@ -166,8 +166,7 @@ void DancingCharacters::LoadNextSong()
m_fThisCameraEndBeat = 0;
ASSERT( GAMESTATE->m_pCurSong );
Song &s = *GAMESTATE->m_pCurSong;
m_fThisCameraEndBeat = s.m_SongTiming.GetBeatFromElapsedTime(s.firstSecond);
m_fThisCameraEndBeat = GAMESTATE->m_pCurSong->GetFirstBeat();
FOREACH_PlayerNumber( p )
if( GAMESTATE->IsPlayerEnabled(p) )
@@ -213,8 +212,7 @@ void DancingCharacters::Update( float fDelta )
bWasGameplayStarting = bGameplayStarting;
static float fLastBeat = GAMESTATE->m_Position.m_fSongBeat;
Song &s = *GAMESTATE->m_pCurSong;
float firstBeat = s.m_SongTiming.GetBeatFromElapsedTime(s.firstSecond);
float firstBeat = GAMESTATE->m_pCurSong->GetFirstBeat();
float fThisBeat = GAMESTATE->m_Position.m_fSongBeat;
if( fLastBeat < firstBeat && fThisBeat >= firstBeat )
{
+1 -1
View File
@@ -992,7 +992,7 @@ float GameState::GetSongPercent( float beat ) const
{
// 0 = first step; 1 = last step
float curTime = this->m_pCurSong->m_SongTiming.GetElapsedTimeFromBeat(beat);
return (curTime - m_pCurSong->firstSecond) / m_pCurSong->lastSecond;
return (curTime - m_pCurSong->GetFirstSecond()) / m_pCurSong->GetLastSecond();
}
int GameState::GetNumStagesLeft( PlayerNumber pn ) const
+1 -1
View File
@@ -122,7 +122,7 @@ void Inventory::Update( float fDelta )
Song &song = *GAMESTATE->m_pCurSong;
// use items if this player is CPU-controlled
if( m_pPlayerState->m_PlayerController != PC_HUMAN &&
GAMESTATE->m_Position.m_fSongBeat < song.m_SongTiming.GetBeatFromElapsedTime(song.lastSecond) )
GAMESTATE->m_Position.m_fSongBeat < song.GetLastBeat() )
{
// every 1 seconds, try to use an item
int iLastSecond = (int)(RageTimer::GetTimeSinceStartFast() - fDelta);
+1 -1
View File
@@ -59,7 +59,7 @@ void LyricDisplay::Update( float fDeltaTime )
if( m_iCurLyricNumber+1 < GAMESTATE->m_pCurSong->m_LyricSegments.size() )
fEndTime = pSong->m_LyricSegments[m_iCurLyricNumber+1].m_fStartTime;
else
fEndTime = pSong->lastSecond;
fEndTime = pSong->GetLastSecond();
const float fDistance = fEndTime - pSong->m_LyricSegments[m_iCurLyricNumber].m_fStartTime;
const float fTweenBufferTime = IN_LENGTH.GetValue() + OUT_LENGTH.GetValue();
+2 -2
View File
@@ -73,8 +73,8 @@ void SongMeterDisplay::Update( float fDeltaTime )
{
if( GAMESTATE->m_pCurSong )
{
float fSongStartSeconds = GAMESTATE->m_pCurSong->firstSecond;
float fSongEndSeconds = GAMESTATE->m_pCurSong->lastSecond;
float fSongStartSeconds = GAMESTATE->m_pCurSong->GetFirstSecond();
float fSongEndSeconds = GAMESTATE->m_pCurSong->GetLastSecond();
float fPercentPositionSong = SCALE( GAMESTATE->m_Position.m_fMusicSeconds, fSongStartSeconds, fSongEndSeconds, 0.0f, 1.0f );
CLAMP( fPercentPositionSong, 0, 1 );
+1 -1
View File
@@ -1090,7 +1090,7 @@ void SMLoader::TidyUpData( Song &song, bool bFromCache )
if( bFromCache )
break;
float lastBeat = song.m_SongTiming.GetBeatFromElapsedTime(song.lastSecond);
float lastBeat = song.GetLastBeat();
/* If BGChanges already exist after the last beat, don't add the
* background in the middle. */
if( !bg.empty() && bg.back().m_fStartBeat-0.0001f >= lastBeat )
+1 -1
View File
@@ -410,7 +410,7 @@ bool SSCLoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach
out.firstSecond = StringToFloat( sParams[1] );
}
else if( sValueName=="LASTBEAT" )
else if( sValueName=="LASTSECOND" )
{
if( bFromCache )
out.lastSecond = StringToFloat( sParams[1] );
+2 -2
View File
@@ -147,8 +147,8 @@ bool NotesWriterJson::WriteSong( const RString &sFile, const Song &out, bool bWr
else
root["Selectable"] = "YES";
root["FirstBeat"] = out.m_SongTiming.GetBeatFromElapsedTime(out.firstSecond);
root["LastBeat"] = out.m_SongTiming.GetBeatFromElapsedTime(out.lastSecond);
root["FirstBeat"] = out.GetFirstBeat();
root["LastBeat"] = out.GetLastBeat();
root["SongFileName"] = out.m_sSongFileName;
root["HasMusic"] = out.m_bHasMusic;
root["HasBanner"] = out.m_bHasBanner;
+2 -2
View File
@@ -368,8 +368,8 @@ bool NotesWriterSSC::Write( RString sPath, const Song &out, const vector<Steps*>
if( bSavingCache )
{
f.PutLine( ssprintf( "// cache tags:" ) );
f.PutLine( ssprintf( "#FIRSTSECOND:%.6f;", out.firstSecond ) );
f.PutLine( ssprintf( "#LASTSECOND:%.6f;", out.lastSecond ) );
f.PutLine( ssprintf( "#FIRSTSECOND:%.6f;", out.GetFirstSecond() ) );
f.PutLine( ssprintf( "#LASTSECOND:%.6f;", out.GetLastSecond() ) );
f.PutLine( ssprintf( "#SONGFILENAME:%s;", out.m_sSongFileName.c_str() ) );
f.PutLine( ssprintf( "#HASMUSIC:%i;", out.m_bHasMusic ) );
f.PutLine( ssprintf( "#HASBANNER:%i;", out.m_bHasBanner ) );
+2 -2
View File
@@ -4713,12 +4713,12 @@ float ScreenEdit::GetMaximumBeatForNewNote() const
case EditMode_Home:
{
Song &s = *GAMESTATE->m_pCurSong;
TimingData &timing = s.m_SongTiming;
float fEndBeat = timing.GetBeatFromElapsedTime(s.lastSecond);
float fEndBeat = s.GetLastBeat();
/* Round up to the next measure end. Some songs end on weird beats
* mid-measure, and it's odd to have movement capped to these weird
* beats. */
TimingData &timing = s.m_SongTiming;
float playerBeat = GetAppropriatePosition().m_fSongBeat;
int beatsPerMeasure = timing.GetTimeSignatureSegmentAtBeat( playerBeat ).GetNum();
fEndBeat += beatsPerMeasure;
+5 -8
View File
@@ -1329,7 +1329,7 @@ void ScreenGameplay::StartPlayingSong( float fMinTimeToNotes, float fMinTimeToMu
p.StopMode = RageSoundParams::M_CONTINUE;
{
const float fFirstSecond = GAMESTATE->m_pCurSong->firstSecond;
const float fFirstSecond = GAMESTATE->m_pCurSong->GetFirstSecond();
float fStartDelay = fMinTimeToNotes - fFirstSecond;
fStartDelay = max( fStartDelay, fMinTimeToMusic );
p.m_StartSecond = -fStartDelay;
@@ -1412,8 +1412,7 @@ void ScreenGameplay::PlayAnnouncer( RString type, float fSeconds )
if( m_DancingState != STATE_DANCING )
return;
if(GAMESTATE->m_pCurSong == NULL || // this will be true on ScreenDemonstration sometimes
GAMESTATE->m_Position.m_fSongBeat <
GAMESTATE->m_pCurSong->m_SongTiming.GetBeatFromElapsedTime(GAMESTATE->m_pCurSong->firstSecond) )
GAMESTATE->m_Position.m_fSongBeat < GAMESTATE->m_pCurSong->GetFirstBeat())
return;
if( m_fTimeSinceLastDancingComment < fSeconds )
@@ -1488,7 +1487,7 @@ bool ScreenGameplay::AllAreFailing()
void ScreenGameplay::GetMusicEndTiming( float &fSecondsToStartFadingOutMusic, float &fSecondsToStartTransitioningOut )
{
float fLastStepSeconds = GAMESTATE->m_pCurSong->lastSecond;
float fLastStepSeconds = GAMESTATE->m_pCurSong->GetLastSecond();
fLastStepSeconds += Player::GetMaxStepDistanceSeconds();
float fTransitionLength;
@@ -1698,10 +1697,8 @@ void ScreenGameplay::Update( float fDeltaTime )
STATSMAN->m_CurStageStats.m_fGameplaySeconds += fUnscaledDeltaTime;
float curBeat = GAMESTATE->m_Position.m_fSongBeat;
Song &s = *GAMESTATE->m_pCurSong;
TimingData &timing = s.m_SongTiming;
if( curBeat >= timing.GetBeatFromElapsedTime(s.firstSecond) && curBeat < timing.GetBeatFromElapsedTime(s.lastSecond) )
if( curBeat >= s.GetFirstBeat() && curBeat < s.GetLastBeat() )
{
STATSMAN->m_CurStageStats.m_fStepsSeconds += fUnscaledDeltaTime;
@@ -1983,7 +1980,7 @@ void ScreenGameplay::UpdateLights()
// Before the first beat of the song, all cabinet lights solid on (except for menu buttons).
Song &s = *GAMESTATE->m_pCurSong;
bool bOverrideCabinetBlink = (GAMESTATE->m_Position.m_fSongBeat < s.m_SongTiming.GetBeatFromElapsedTime(s.firstSecond));
bool bOverrideCabinetBlink = (GAMESTATE->m_Position.m_fSongBeat < s.GetFirstBeat());
FOREACH_CabinetLight( cl )
bBlinkCabinetLight[cl] |= bOverrideCabinetBlink;
+3 -3
View File
@@ -529,7 +529,7 @@ void Song::TidyUpData( bool bFromCache )
if( m_fMusicSampleStartSeconds+m_fMusicSampleLengthSeconds > this->m_fMusicLengthSeconds )
{
// Attempt to get a reasonable default.
int iBeat = lrintf(this->m_SongTiming.GetBeatFromElapsedTime(this->lastSecond)/2);
int iBeat = lrintf(this->m_SongTiming.GetBeatFromElapsedTime(this->GetLastSecond())/2);
iBeat -= iBeat%4;
m_fMusicSampleStartSeconds = timing.GetElapsedTimeFromBeat( (float)iBeat );
}
@@ -818,7 +818,7 @@ void Song::TranslateTitles()
void Song::ReCalculateRadarValuesAndLastBeat( bool bFromCache )
{
if( bFromCache && this->firstSecond >= 0 && this->lastSecond > 0 )
if( bFromCache && this->GetFirstSecond() >= 0 && this->GetLastSecond() > 0 )
{
// this is loaded from cache, then we just have to calculate the radar values.
for( unsigned i=0; i<m_vpSteps.size(); i++ )
@@ -1481,7 +1481,7 @@ bool Song::HasSignificantBpmChangesOrStops() const
float Song::GetStepsSeconds() const
{
return this->lastSecond - this->firstSecond;
return this->GetLastSecond() - this->GetFirstSecond();
}
bool Song::IsLong() const