From f9b12e9e8eac2b7e547437bc80eb0e679a55952a Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 9 Jul 2003 04:46:24 +0000 Subject: [PATCH] simplify --- stepmania/src/MusicWheel.cpp | 4 ++-- stepmania/src/ScreenUnlock.cpp | 8 ++++++-- stepmania/src/UnlockSystem.cpp | 11 +++++++++++ stepmania/src/UnlockSystem.h | 8 ++++++-- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/stepmania/src/MusicWheel.cpp b/stepmania/src/MusicWheel.cpp index 3a63d17b76..73913eba53 100644 --- a/stepmania/src/MusicWheel.cpp +++ b/stepmania/src/MusicWheel.cpp @@ -316,7 +316,7 @@ void MusicWheel::GetSongList(vector &arraySongs, SongSortOrder so, CStrin continue; if( so==SORT_ROULETTE && !pSong->RouletteDisplayed() ) continue; - if( so==SORT_ROULETTE && GAMESTATE->m_pUnlockingSys->SongIsRoulette( pSong->GetFullTranslitTitle() ) ) + if( so==SORT_ROULETTE && GAMESTATE->m_pUnlockingSys->SongIsRoulette( pSong ) ) continue; } @@ -328,7 +328,7 @@ void MusicWheel::GetSongList(vector &arraySongs, SongSortOrder so, CStrin // If we're using unlocks, check it here to prevent from being shown if( PREFSMAN->m_bUseUnlockSystem ) { - pSong->m_bIsLocked = GAMESTATE->m_pUnlockingSys->SongIsLocked( pSong->GetFullTranslitTitle() ); + pSong->m_bIsLocked = GAMESTATE->m_pUnlockingSys->SongIsLocked( pSong ); if( pSong->m_bIsLocked ) { continue; } } arraySongs.push_back( pSong ); diff --git a/stepmania/src/ScreenUnlock.cpp b/stepmania/src/ScreenUnlock.cpp index 6ff263c0ae..43fcf8c2e7 100644 --- a/stepmania/src/ScreenUnlock.cpp +++ b/stepmania/src/ScreenUnlock.cpp @@ -16,6 +16,7 @@ #include "GameState.h" #include "RageLog.h" #include "UnlockSystem.h" +#include "SongManager.h" ScreenUnlock::ScreenUnlock() : ScreenAttract("ScreenUnlock") { @@ -33,8 +34,11 @@ ScreenUnlock::ScreenUnlock() : ScreenAttract("ScreenUnlock") Unlocks[i].SetName( ssprintf("Unlock%d",i) ); SET_XY( Unlocks[i] ); - const bool SongIsLocked = GAMESTATE->m_pUnlockingSys->SongIsLocked - (THEME->GetMetric("ScreenUnlock", ssprintf("Unlock%dSong", i))); + Song *pSong = SONGMAN->FindSong("", THEME->GetMetric("ScreenUnlock", ssprintf("Unlock%dSong", i)) ); + if( pSong == NULL ) + continue; + + const bool SongIsLocked = GAMESTATE->m_pUnlockingSys->SongIsLocked( pSong ); if ( !SongIsLocked ) this->AddChild(&Unlocks[i]); } diff --git a/stepmania/src/UnlockSystem.cpp b/stepmania/src/UnlockSystem.cpp index 36d43a1b9f..5c3b37e2cf 100644 --- a/stepmania/src/UnlockSystem.cpp +++ b/stepmania/src/UnlockSystem.cpp @@ -13,6 +13,7 @@ #include "global.h" #include "PrefsManager.h" #include "RageLog.h" +#include "Song.h" #include "RageException.h" #include "RageUtil.h" #include "UnlockSystem.h" @@ -27,6 +28,16 @@ UnlockSystem::UnlockSystem() } +bool UnlockSystem::SongIsLocked( const Song *song ) +{ + return SongIsLocked( song->GetFullTranslitTitle() ); +} + +bool UnlockSystem::SongIsRoulette( const Song *song ) +{ + return SongIsRoulette( song->GetFullTranslitTitle() ); +} + bool UnlockSystem::SongIsLocked( CString sSongName ) { sSongName.MakeUpper(); //Avoid case-sensitive problems diff --git a/stepmania/src/UnlockSystem.h b/stepmania/src/UnlockSystem.h index d427c65fba..0acfa19005 100644 --- a/stepmania/src/UnlockSystem.h +++ b/stepmania/src/UnlockSystem.h @@ -17,6 +17,8 @@ enum UnlockTypes { UNLOCK_AP, UNLOCK_DP, UNLOCK_SP, UNLOCK_EC, UNLOCK_EF, UNLOCK_SC, UNLOCK_TT, UNLOCK_RO}; +class Song; + struct SongEntry { CString m_sSongName; /* Name of the song in the DWI/SM file itself.. This allows @@ -50,8 +52,8 @@ class UnlockSystem public: UnlockSystem(); float NumPointsUntilNextUnlock(); - bool SongIsLocked( CString sSongName ); - bool SongIsRoulette( CString sSongName ); + bool SongIsLocked( const Song *song ); + bool SongIsRoulette( const Song *song ); bool LoadFromDATFile( CString sPath ); vector m_SongEntries; // All locked songs are stored here @@ -68,6 +70,8 @@ public: private: void SortSongEntriesArray(); // sorts unlocks bool ParseRow(CString text, CString &type, float &qty, CString &songname); + bool SongIsLocked( CString sSongName ); + bool SongIsRoulette( CString sSongName ); };