From be7fc5d0d12531ce9bdd46fa59b9c3f92d4bee73 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 7 Dec 2003 08:19:10 +0000 Subject: [PATCH] more stats cleanup --- stepmania/src/PrefsManager.cpp | 4 +- stepmania/src/PrefsManager.h | 2 +- stepmania/src/ProfileManager.cpp | 59 ++++++++++++-------------- stepmania/src/ProfileManager.h | 10 ++--- stepmania/src/ScreenProfileOptions.cpp | 32 +++++++------- stepmania/src/StepMania.cpp | 2 +- 6 files changed, 52 insertions(+), 57 deletions(-) diff --git a/stepmania/src/PrefsManager.cpp b/stepmania/src/PrefsManager.cpp index f55ddc98a6..93589db985 100644 --- a/stepmania/src/PrefsManager.cpp +++ b/stepmania/src/PrefsManager.cpp @@ -353,7 +353,7 @@ void PrefsManager::ReadGlobalPrefsFromDisk() for( int p=0; p &asProfileIDsOut ) +void ProfileManager::GetLocalProfileIDs( vector &asProfileIDsOut ) { GetDirListing( USER_PROFILES_DIR "*", asProfileIDsOut, true, false ); } -void ProfileManager::GetMachineProfileNames( vector &asNamesOut ) +void ProfileManager::GetLocalProfileNames( vector &asNamesOut ) { CStringArray vsProfileIDs; - GetMachineProfileIDs( vsProfileIDs ); + GetLocalProfileIDs( vsProfileIDs ); for( unsigned i=0; im_sDefaultMachineProfileID[pn]; + CString sProfileID = PREFSMAN->m_sDefaultLocalProfileID[pn]; if( sProfileID.empty() ) { m_sProfileDir[pn] = ""; @@ -262,17 +263,16 @@ bool Profile::SaveToIni( CString sIniPath ) return true; } -bool ProfileManager::CreateMachineProfile( CString sName ) +bool ProfileManager::CreateLocalProfile( CString sName ) { - if( sName.empty() ) - sName = "Machine"; + ASSERT( !sName.empty() ); // // Find a free directory name in the profiles directory // CString sProfileID, sProfileDir; const int MAX_TRIES = 1000; - int i; + int i; for( i=0; iTrace("SongManager::SaveCategoryRankingsToFile"); - RageFile f(fn); - if (!f.IsOpen() || f.GetError() != 0) + RageFile f; + if( !f.Open(fn, RageFile::WRITE) ) return; FileWrite( f, CATEGORY_RANKING_VERSION ); @@ -733,8 +733,8 @@ void ProfileManager::SaveCourseScoresToFile( CString fn, MemoryCard mc ) { LOG->Trace("SongManager::SaveCourseScoresToFile"); - RageFile f(fn); - if (!f.IsOpen() || f.GetError() != 0) + RageFile f; + if( !f.Open(fn, RageFile::WRITE) ) return; FileWrite( f, COURSE_SCORES_VERSION ); @@ -789,8 +789,8 @@ void ProfileManager::SaveSongScoresToFile( CString fn, MemoryCard mc ) { LOG->Trace("SongManager::SaveSongScoresToFile %s", fn.c_str()); - RageFile f(fn); - if (!f.IsOpen() || f.GetError() != 0) + RageFile f; + if( !f.Open(fn, RageFile::WRITE) ) return; FileWrite( f, STEPS_SCORES_VERSION ); @@ -918,12 +918,7 @@ void ProfileManager::SaveStatsWebPageToFile( CString fn, MemoryCard mc ) * (Note for testing this: remember that we'll cache directories for a time; this is only slow if * the directory cache expires before we get here.) */ //CString sImagePath = pSong->HasBanner() ? pSong->GetBannerPath() : (pSong->HasBackground() ? pSong->GetBackgroundPath() : "" ); - CString sImagePath = pSong->GetBannerPath(); - if( sImagePath.empty() ) - f.Write( " " ); - else - f.Write( ssprintf("", HTMLQuoteDoubleQuotes(sImagePath).c_str()) ); - + f.Write( " " ); f.Write( ssprintf("%s
", pSong->GetTranslitMainTitle().c_str()) ); f.Write( ssprintf("%s
", pSong->GetTranslitSubTitle().c_str()) ); f.Write( ssprintf("%s", pSong->GetTranslitArtist().c_str()) ); diff --git a/stepmania/src/ProfileManager.h b/stepmania/src/ProfileManager.h index 540cef4c5f..643d0ba8d6 100644 --- a/stepmania/src/ProfileManager.h +++ b/stepmania/src/ProfileManager.h @@ -41,14 +41,14 @@ public: ProfileManager(); ~ProfileManager(); - bool CreateMachineProfile( CString sName ); - bool RenameMachineProfile( CString sProfileID, CString sNewName ); - bool DeleteMachineProfile( CString sProfileID ); + bool CreateLocalProfile( CString sName ); + bool RenameLocalProfile( CString sProfileID, CString sNewName ); + bool DeleteLocalProfile( CString sProfileID ); bool CreateMemoryCardProfile( CString sName ); - void GetMachineProfileIDs( vector &asProfileIDsOut ); - void GetMachineProfileNames( vector &asNamesOut ); + void GetLocalProfileIDs( vector &asProfileIDsOut ); + void GetLocalProfileNames( vector &asNamesOut ); bool LoadFirstAvailableProfile( PlayerNumber pn ); bool IsMemoryCardInserted( PlayerNumber pn ); diff --git a/stepmania/src/ScreenProfileOptions.cpp b/stepmania/src/ScreenProfileOptions.cpp index 0c56b55c51..6e114e554a 100644 --- a/stepmania/src/ScreenProfileOptions.cpp +++ b/stepmania/src/ScreenProfileOptions.cpp @@ -53,19 +53,19 @@ ScreenProfileOptions::ScreenProfileOptions( CString sClassName ) : ScreenOptions g_ProfileOptionsLines[PO_PLAYER1].choices.clear(); g_ProfileOptionsLines[PO_PLAYER1].choices.push_back( "-NONE-" ); - PROFILEMAN->GetMachineProfileNames( g_ProfileOptionsLines[PO_PLAYER1].choices ); + PROFILEMAN->GetLocalProfileNames( g_ProfileOptionsLines[PO_PLAYER1].choices ); g_ProfileOptionsLines[PO_PLAYER2].choices.clear(); g_ProfileOptionsLines[PO_PLAYER2].choices.push_back( "-NONE-" ); - PROFILEMAN->GetMachineProfileNames( g_ProfileOptionsLines[PO_PLAYER2].choices ); + PROFILEMAN->GetLocalProfileNames( g_ProfileOptionsLines[PO_PLAYER2].choices ); g_ProfileOptionsLines[PO_DELETE_].choices.clear(); g_ProfileOptionsLines[PO_DELETE_].choices.push_back( "-NONE-" ); - PROFILEMAN->GetMachineProfileNames( g_ProfileOptionsLines[PO_DELETE_].choices ); + PROFILEMAN->GetLocalProfileNames( g_ProfileOptionsLines[PO_DELETE_].choices ); g_ProfileOptionsLines[PO_RENAME_].choices.clear(); g_ProfileOptionsLines[PO_RENAME_].choices.push_back( "-NONE-" ); - PROFILEMAN->GetMachineProfileNames( g_ProfileOptionsLines[PO_RENAME_].choices ); + PROFILEMAN->GetLocalProfileNames( g_ProfileOptionsLines[PO_RENAME_].choices ); if( PREFSMAN->m_sMemoryCardDir[PLAYER_1].empty() ) g_ProfileOptionsLines[PO_CARD_DIR_1].choices[0] = "-NOT SET IN INI-"; @@ -88,21 +88,21 @@ ScreenProfileOptions::ScreenProfileOptions( CString sClassName ) : ScreenOptions void ScreenProfileOptions::ImportOptions() { vector vsProfiles; - PROFILEMAN->GetMachineProfileIDs( vsProfiles ); + PROFILEMAN->GetLocalProfileIDs( vsProfiles ); CStringArray::iterator iter; iter = find( vsProfiles.begin(), vsProfiles.end(), - PREFSMAN->m_sDefaultMachineProfileID[PLAYER_1] ); + PREFSMAN->m_sDefaultLocalProfileID[PLAYER_1] ); if( iter != vsProfiles.end() ) m_iSelectedOption[0][PO_PLAYER1] = iter - vsProfiles.begin() + 1; iter = find( vsProfiles.begin(), vsProfiles.end(), - PREFSMAN->m_sDefaultMachineProfileID[PLAYER_2] ); + PREFSMAN->m_sDefaultLocalProfileID[PLAYER_2] ); if( iter != vsProfiles.end() ) m_iSelectedOption[0][PO_PLAYER2] = iter - vsProfiles.begin() + 1; } @@ -110,17 +110,17 @@ void ScreenProfileOptions::ImportOptions() void ScreenProfileOptions::ExportOptions() { vector vsProfiles; - PROFILEMAN->GetMachineProfileIDs( vsProfiles ); + PROFILEMAN->GetLocalProfileIDs( vsProfiles ); if( m_iSelectedOption[0][PO_PLAYER1] > 0 ) - PREFSMAN->m_sDefaultMachineProfileID[PLAYER_1] = vsProfiles[m_iSelectedOption[0][PO_PLAYER1]-1]; + PREFSMAN->m_sDefaultLocalProfileID[PLAYER_1] = vsProfiles[m_iSelectedOption[0][PO_PLAYER1]-1]; else - PREFSMAN->m_sDefaultMachineProfileID[PLAYER_1] = ""; + PREFSMAN->m_sDefaultLocalProfileID[PLAYER_1] = ""; if( m_iSelectedOption[0][PO_PLAYER2] > 0 ) - PREFSMAN->m_sDefaultMachineProfileID[PLAYER_2] = vsProfiles[m_iSelectedOption[0][PO_PLAYER2]-1]; + PREFSMAN->m_sDefaultLocalProfileID[PLAYER_2] = vsProfiles[m_iSelectedOption[0][PO_PLAYER2]-1]; else - PREFSMAN->m_sDefaultMachineProfileID[PLAYER_2] = ""; + PREFSMAN->m_sDefaultLocalProfileID[PLAYER_2] = ""; } void ScreenProfileOptions::GoToPrevState() @@ -145,7 +145,7 @@ void ScreenProfileOptions::HandleScreenMessage( const ScreenMessage SM ) if( !ScreenTextEntry::s_bCancelledLast ) { CString sNewName = ScreenTextEntry::s_sLastAnswer; - bool bResult = PROFILEMAN->CreateMachineProfile( sNewName ); + bool bResult = PROFILEMAN->CreateLocalProfile( sNewName ); if( bResult ) SCREENMAN->SetNewScreen( "ScreenProfileOptions" ); // reload else @@ -156,7 +156,7 @@ void ScreenProfileOptions::HandleScreenMessage( const ScreenMessage SM ) if( !ScreenTextEntry::s_bCancelledLast ) { CString sNewName = ScreenTextEntry::s_sLastAnswer; - bool bResult = PROFILEMAN->RenameMachineProfile( sProfileID, sNewName ); + bool bResult = PROFILEMAN->RenameLocalProfile( sProfileID, sNewName ); if( bResult ) SCREENMAN->SetNewScreen( "ScreenProfileOptions" ); // reload else @@ -166,7 +166,7 @@ void ScreenProfileOptions::HandleScreenMessage( const ScreenMessage SM ) case SM_DoneDeleting: if( ScreenPrompt::s_bLastAnswer ) { - bool bResult = PROFILEMAN->DeleteMachineProfile( sProfileID ); + bool bResult = PROFILEMAN->DeleteLocalProfile( sProfileID ); if( bResult ) SCREENMAN->SetNewScreen( "ScreenProfileOptions" ); // reload else @@ -209,7 +209,7 @@ void ScreenProfileOptions::MenuStart( PlayerNumber pn, const InputEventType type CString ScreenProfileOptions::GetSelectedProfileID() { vector vsProfiles; - PROFILEMAN->GetMachineProfileIDs( vsProfiles ); + PROFILEMAN->GetLocalProfileIDs( vsProfiles ); if( m_iSelectedOption[0][m_iCurrentRow[0]]==0 ) return ""; diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index 9d0305e2fb..f9a5c6f1b7 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -837,7 +837,6 @@ int main(int argc, char* argv[]) SOUNDMAN = new RageSoundManager(PREFSMAN->m_sSoundDrivers); SOUNDMAN->SetPrefs(PREFSMAN->m_fSoundVolume); SOUND = new RageSounds; - PROFILEMAN = new ProfileManager; BOOKKEEPER = new Bookkeeper; LIGHTSMAN = new LightsManager(PREFSMAN->m_sLightsDriver); INPUTFILTER = new InputFilter; @@ -848,6 +847,7 @@ int main(int argc, char* argv[]) /* depends on SONGINDEX: */ SONGMAN = new SongManager( loading_window ); // this takes a long time to load + PROFILEMAN = new ProfileManager; // must load after SONGMAN delete loading_window; // destroy this before init'ing Display DISPLAY = CreateDisplay();