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