diff --git a/stepmania/src/UnlockManager.cpp b/stepmania/src/UnlockManager.cpp index 79ba5540bf..8338aa239d 100644 --- a/stepmania/src/UnlockManager.cpp +++ b/stepmania/src/UnlockManager.cpp @@ -7,24 +7,26 @@ #include "UnlockManager.h" #include "SongManager.h" #include "GameState.h" -#include "MsdFile.h" #include "ProfileManager.h" +#include "ThemeManager.h" UnlockManager* UNLOCKMAN = NULL; // global and accessable from anywhere in our program -#define UNLOCKS_PATH "Data/Unlocks.dat" +#define UNLOCK_NAMES THEME->GetMetric ("Unlocks","UnlockNames") +#define UNLOCK(sLineName) THEME->GetMetric ("Unlocks",ssprintf("Unlock%s",sLineName.c_str())) static CString UnlockTypeNames[NUM_UNLOCK_TYPES] = { - "ArcadePointsAccumulated", - "DancePointsAccumulated", - "SongPointsAccumulated", - "ExtraStagesCleared", - "ExtraStagesFailed", - "TotalToastysSeen", - "TotalStagesCleared" + "ArcadePoints", + "DancePoints", + "SongPoints", + "ExtraCleared", + "ExtraFailed", + "Toasties", + "StagesCleared" }; XToString(UnlockType); +StringToX(UnlockType); UnlockManager::UnlockManager() { @@ -218,101 +220,52 @@ bool UnlockEntry::IsLocked() const return true; } -static const char *g_ShortUnlockNames[NUM_UNLOCK_TYPES] = -{ - "AP", - "DP", - "SP", - "EC", - "EF", - "!!", - "CS" -}; - -static UnlockType StringToUnlockType( const CString &s ) -{ - for( int i = 0; i < NUM_UNLOCK_TYPES; ++i ) - if( g_ShortUnlockNames[i] == s ) - return (UnlockType) i; - return UNLOCK_INVALID; -} - -bool UnlockManager::Load() +void UnlockManager::Load() { LOG->Trace( "UnlockManager::Load()" ); - - if( !IsAFile(UNLOCKS_PATH) ) - return false; - MsdFile msd; - if( !msd.ReadFile( UNLOCKS_PATH ) ) + CStringArray asUnlockNames; + split( UNLOCK_NAMES, ",", asUnlockNames ); + if( asUnlockNames.empty() ) + return; + + for( unsigned i = 0; i < asUnlockNames.size(); ++i ) { - LOG->Warn( "Error opening file '%s' for reading: %s.", UNLOCKS_PATH, msd.GetError().c_str() ); - return false; - } + const CString &sUnlockName = asUnlockNames[i]; + CString sUnlock = UNLOCK(sUnlockName); - for( unsigned i=0; iWarn("Got \"%s\" tag with no parameters", sValueName.c_str()); - continue; - } - - if( !stricmp(sParams[0],"ROULETTE") ) - { - for( unsigned j = 1; j < sParams.params.size(); ++j ) - m_RouletteCodes.insert( atoi(sParams[j]) ); - continue; - } - - if( stricmp(sParams[0],"UNLOCK") ) - { - LOG->Warn("Unrecognized unlock tag \"%s\", ignored.", sValueName.c_str()); - continue; - } + Commands vCommands; + ParseCommands( sUnlock, vCommands ); UnlockEntry current; - current.m_sSongName = sParams[1]; - LOG->Trace("Song entry: %s", current.m_sSongName.c_str() ); + bool bRoulette = false; - CStringArray UnlockTypes; - split( sParams[2], ",", UnlockTypes ); - - for( unsigned j=0; jTrace( "%s", str.c_str() ); } - return true; + return; } float UnlockManager::PointsUntilNextUnlock( UnlockType t ) const @@ -354,16 +307,16 @@ void UnlockManager::UpdateSongs() { m_SongEntries[i].m_pSong = NULL; m_SongEntries[i].m_pCourse = NULL; - m_SongEntries[i].m_pSong = SONGMAN->FindSong( m_SongEntries[i].m_sSongName ); - if( m_SongEntries[i].m_pSong == NULL ) - m_SongEntries[i].m_pCourse = SONGMAN->FindCourse( m_SongEntries[i].m_sSongName ); + if( m_SongEntries[i].m_sSongName != "" ) + m_SongEntries[i].m_pSong = SONGMAN->FindSong( m_SongEntries[i].m_sSongName ); + if( m_SongEntries[i].m_pSong == NULL ) + m_SongEntries[i].m_pCourse = SONGMAN->FindCourse( m_SongEntries[i].m_sSongName ); // display warning on invalid song entry - if (m_SongEntries[i].m_pSong == NULL && - m_SongEntries[i].m_pCourse == NULL) + if( m_SongEntries[i].m_pSong == NULL && m_SongEntries[i].m_pCourse == NULL ) { - LOG->Warn("Unlock: Cannot find a matching entry for \"%s\"", m_SongEntries[i].m_sSongName.c_str() ); - m_SongEntries.erase(m_SongEntries.begin() + i); + LOG->Warn( "Unlock: Cannot find a matching entry for \"%s\"", m_SongEntries[i].m_sSongName.c_str() ); + m_SongEntries.erase( m_SongEntries.begin() + i ); --i; } } diff --git a/stepmania/src/UnlockManager.h b/stepmania/src/UnlockManager.h index 937ff19e42..42d86b236a 100644 --- a/stepmania/src/UnlockManager.h +++ b/stepmania/src/UnlockManager.h @@ -91,7 +91,7 @@ public: private: // read unlocks - bool Load(); + void Load(); const UnlockEntry *FindSong( const Song *pSong ) const; const UnlockEntry *FindCourse( const Course *pCourse ) const;