From 57e3c2fc80e9a1245a3a38b7972a43665d99acad Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Thu, 30 Jun 2011 02:19:37 -0400 Subject: [PATCH] Use accessor functions instead of direct calls. --- src/NotesLoaderSSC.cpp | 6 +++--- src/NotesWriterSM.cpp | 5 +++-- src/NotesWriterSSC.cpp | 4 ++-- src/ScreenEdit.cpp | 8 ++++---- src/Song.cpp | 25 +++++++++++++++++++++++++ src/Song.h | 18 ++++++++++++------ 6 files changed, 49 insertions(+), 17 deletions(-) diff --git a/src/NotesLoaderSSC.cpp b/src/NotesLoaderSSC.cpp index 1f4314a31a..258d1ae5d7 100644 --- a/src/NotesLoaderSSC.cpp +++ b/src/NotesLoaderSSC.cpp @@ -270,7 +270,7 @@ bool SSCLoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach else if (sValueName == "LASTSECONDHINT") { - out.specifiedLastSecond = StringToFloat(sParams[1]); + out.SetSpecifiedLastSecond(StringToFloat(sParams[1])); } else if( sValueName=="MUSICBYTES" ) @@ -407,13 +407,13 @@ bool SSCLoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach else if (sValueName=="FIRSTSECOND") { if( bFromCache ) - out.firstSecond = StringToFloat( sParams[1] ); + out.SetFirstSecond(StringToFloat(sParams[1])); } else if( sValueName=="LASTSECOND" ) { if( bFromCache ) - out.lastSecond = StringToFloat( sParams[1] ); + out.SetLastSecond(StringToFloat(sParams[1])); } else if( sValueName=="SONGFILENAME" ) diff --git a/src/NotesWriterSM.cpp b/src/NotesWriterSM.cpp index 06934bb06e..48db17d8ff 100644 --- a/src/NotesWriterSM.cpp +++ b/src/NotesWriterSM.cpp @@ -66,8 +66,9 @@ static void WriteGlobalTags( RageFile &f, Song &out ) f.PutLine( ssprintf( "#OFFSET:%.3f;", out.m_SongTiming.m_fBeat0OffsetInSeconds ) ); f.PutLine( ssprintf( "#SAMPLESTART:%.3f;", out.m_fMusicSampleStartSeconds ) ); f.PutLine( ssprintf( "#SAMPLELENGTH:%.3f;", out.m_fMusicSampleLengthSeconds ) ); - if( out.specifiedLastSecond > 0 ) - f.PutLine( ssprintf("#LASTBEATHINT:%.3f;", out.m_SongTiming.GetBeatFromElapsedTime(out.specifiedLastSecond)) ); + float specBeat = out.GetSpecifiedLastBeat(); + if( specBeat > 0 ) + f.PutLine( ssprintf("#LASTBEATHINT:%.3f;", specBeat) ); f.Write( "#SELECTABLE:" ); switch(out.m_SelectionDisplay) diff --git a/src/NotesWriterSSC.cpp b/src/NotesWriterSSC.cpp index 364361dd74..bad8a1690e 100644 --- a/src/NotesWriterSSC.cpp +++ b/src/NotesWriterSSC.cpp @@ -232,8 +232,8 @@ static void WriteGlobalTags( RageFile &f, const Song &out ) WriteTimingTags( f, out.m_SongTiming, true ); - if( out.specifiedLastSecond > 0 ) - f.PutLine( ssprintf("#LASTSECONDHINT:%.6f;", out.specifiedLastSecond) ); + if( out.GetSpecifiedLastSecond() > 0 ) + f.PutLine( ssprintf("#LASTSECONDHINT:%.6f;", out.GetSpecifiedLastSecond()) ); FOREACH_BackgroundLayer( b ) { diff --git a/src/ScreenEdit.cpp b/src/ScreenEdit.cpp index 1ac2c39f78..08e53a6aea 100644 --- a/src/ScreenEdit.cpp +++ b/src/ScreenEdit.cpp @@ -3436,7 +3436,7 @@ static void ChangeBeat0Offset( const RString &sNew ) static void ChangeLastSecondHint( const RString &sNew ) { Song &s = *GAMESTATE->m_pCurSong; - s.specifiedLastSecond = StringToFloat(sNew); + s.SetSpecifiedLastSecond(StringToFloat(sNew)); } static void ChangePreviewStart( const RString &sNew ) @@ -3737,7 +3737,7 @@ void ScreenEdit::HandleMainMenuChoice( MainMenuChoice c, const vector &iAns g_SongInformation.rows[main_title_transliteration].SetOneUnthemedChoice( pSong->m_sMainTitleTranslit ); g_SongInformation.rows[sub_title_transliteration].SetOneUnthemedChoice( pSong->m_sSubTitleTranslit ); g_SongInformation.rows[artist_transliteration].SetOneUnthemedChoice( pSong->m_sArtistTranslit ); - g_SongInformation.rows[last_second_hint].SetOneUnthemedChoice( ssprintf("%.6f", pSong->specifiedLastSecond) ); + g_SongInformation.rows[last_second_hint].SetOneUnthemedChoice( ssprintf("%.6f", pSong->GetSpecifiedLastSecond()) ); g_SongInformation.rows[preview_start].SetOneUnthemedChoice( ssprintf("%.6f", pSong->m_fMusicSampleStartSeconds) ); g_SongInformation.rows[preview_length].SetOneUnthemedChoice( ssprintf("%.6f", pSong->m_fMusicSampleLengthSeconds) ); g_SongInformation.rows[display_bpm].iDefaultChoice = pSong->m_DisplayBPMType; @@ -4134,7 +4134,7 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, const vector &iAns { TimingData &timing = GetAppropriateTiming(); Song &s = *GAMESTATE->m_pCurSong; - s.specifiedLastSecond = timing.GetElapsedTimeFromBeat(GetBeat()); + s.SetSpecifiedLastSecond(timing.GetElapsedTimeFromBeat(GetBeat())); break; } case undo: @@ -4255,7 +4255,7 @@ void ScreenEdit::HandleSongInformationChoice( SongInformationChoice c, const vec break; case last_second_hint: ScreenTextEntry::TextEntry( SM_None, ENTER_LAST_SECOND_HINT, - ssprintf("%.6f", pSong->specifiedLastSecond), 20, + ssprintf("%.6f", pSong->GetSpecifiedLastSecond()), 20, ScreenTextEntry::FloatValidate, ChangeLastSecondHint, NULL ); break; case preview_start: diff --git a/src/Song.cpp b/src/Song.cpp index f39b853b48..87eaf91058 100644 --- a/src/Song.cpp +++ b/src/Song.cpp @@ -120,6 +120,31 @@ float Song::GetLastBeat() const return this->m_SongTiming.GetBeatFromElapsedTime(this->lastSecond); } +float Song::GetSpecifiedLastSecond() const +{ + return this->specifiedLastSecond; +} + +float Song::GetSpecifiedLastBeat() const +{ + return this->m_SongTiming.GetBeatFromElapsedTime(this->specifiedLastSecond); +} + +void Song::SetFirstSecond(const float f) +{ + this->firstSecond = f; +} + +void Song::SetLastSecond(const float f) +{ + this->lastSecond = f; +} + +void Song::SetSpecifiedLastSecond(const float f) +{ + this->specifiedLastSecond = f; +} + // Reset to an empty song. void Song::Reset() { diff --git a/src/Song.h b/src/Song.h index b64d9daf9c..279cb8e5b9 100644 --- a/src/Song.h +++ b/src/Song.h @@ -233,12 +233,6 @@ public: /** @brief The length of the music file. */ float m_fMusicLengthSeconds; - /** @brief The first second that a note is hit. */ - float firstSecond; - /** @brief The last second that a note is hit. */ - float lastSecond; - /** @brief The last second of the song for playing purposes. */ - float specifiedLastSecond; float m_fMusicSampleStartSeconds; float m_fMusicSampleLengthSeconds; DisplayBPM m_DisplayBPMType; @@ -298,9 +292,21 @@ public: float GetFirstSecond() const; float GetLastBeat() const; float GetLastSecond() const; + float GetSpecifiedLastBeat() const; + float GetSpecifiedLastSecond() const; + + void SetFirstSecond(const float f); + void SetLastSecond(const float f); + void SetSpecifiedLastSecond(const float f); typedef vector VBackgroundChange; private: + /** @brief The first second that a note is hit. */ + float firstSecond; + /** @brief The last second that a note is hit. */ + float lastSecond; + /** @brief The last second of the song for playing purposes. */ + float specifiedLastSecond; /** * @brief The background changes (sorted by layer) that are for this Song. *