more stats cleanup

This commit is contained in:
Chris Danford
2003-12-07 08:19:10 +00:00
parent d4da0ad3db
commit be7fc5d0d1
6 changed files with 52 additions and 57 deletions
+2 -2
View File
@@ -353,7 +353,7 @@ void PrefsManager::ReadGlobalPrefsFromDisk()
for( int p=0; p<NUM_PLAYERS; p++ )
{
ini.GetValue( "Options", ssprintf("DefaultMachineProfileIDP%d",p+1), m_sDefaultMachineProfileID[p] );
ini.GetValue( "Options", ssprintf("DefaultLocalProfileIDP%d",p+1), m_sDefaultLocalProfileID[p] );
ini.GetValue( "Options", ssprintf("MemoryCardDirP%d",p+1), m_sMemoryCardDir[p] );
FixSlashesInPlace( m_sMemoryCardDir[p] );
ini.GetValue( "Options", ssprintf("MemoryCardMountCommandP%d",p+1), m_sMemoryCardMountCommand[p] );
@@ -509,7 +509,7 @@ void PrefsManager::SaveGlobalPrefsToDisk() const
for( int p=0; p<NUM_PLAYERS; p++ )
{
ini.SetValue( "Options", ssprintf("DefaultMachineProfileIDP%d",p+1), m_sDefaultMachineProfileID[p] );
ini.SetValue( "Options", ssprintf("DefaultLocalProfileIDP%d",p+1), m_sDefaultLocalProfileID[p] );
ini.SetValue( "Options", ssprintf("MemoryCardDirP%d",p+1), m_sMemoryCardDir[p] );
ini.SetValue( "Options", ssprintf("MemoryCardMountCommandP%d",p+1), m_sMemoryCardMountCommand[p] );
}
+1 -1
View File
@@ -119,7 +119,7 @@ public:
int m_iEndlessNumStagesUntilBreak;
int m_iEndlessBreakLength;
CString m_sLanguage;
CString m_sDefaultMachineProfileID[NUM_PLAYERS];
CString m_sDefaultLocalProfileID[NUM_PLAYERS];
CString m_sMemoryCardDir[NUM_PLAYERS];
CString m_sMemoryCardMountCommand[NUM_PLAYERS];
int m_iCenterImageTranslateX;
+27 -32
View File
@@ -25,6 +25,7 @@
#include "Course.h"
#include "GameManager.h"
#include "ProductInfo.h"
#include "RageUtil.h"
ProfileManager* PROFILEMAN = NULL; // global and accessable from anywhere in our program
@@ -41,7 +42,7 @@ ProfileManager* PROFILEMAN = NULL; // global and accessable from anywhere in our
#define SM_300_STATISTICS_FILE BASE_PATH "statistics.ini"
#define USER_PROFILES_DIR BASE_PATH "Data" SLASH "UserProfiles" SLASH
#define USER_PROFILES_DIR BASE_PATH "Data" SLASH "LocalProfiles" SLASH
#define MACHINE_PROFILE_DIR BASE_PATH "Data" SLASH "MachineProfile" SLASH
const int CATEGORY_RANKING_VERSION = 4;
@@ -74,15 +75,15 @@ ProfileManager::~ProfileManager()
SaveMachineScoresToDisk();
}
void ProfileManager::GetMachineProfileIDs( vector<CString> &asProfileIDsOut )
void ProfileManager::GetLocalProfileIDs( vector<CString> &asProfileIDsOut )
{
GetDirListing( USER_PROFILES_DIR "*", asProfileIDsOut, true, false );
}
void ProfileManager::GetMachineProfileNames( vector<CString> &asNamesOut )
void ProfileManager::GetLocalProfileNames( vector<CString> &asNamesOut )
{
CStringArray vsProfileIDs;
GetMachineProfileIDs( vsProfileIDs );
GetLocalProfileIDs( vsProfileIDs );
for( unsigned i=0; i<vsProfileIDs.size(); i++ )
{
CString sProfileID = vsProfileIDs[i];
@@ -141,7 +142,7 @@ bool ProfileManager::CreateProfile( CString sProfileDir, CString sName )
bool ProfileManager::LoadDefaultProfileFromMachine( PlayerNumber pn )
{
CString sProfileID = PREFSMAN->m_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; i<MAX_TRIES; i++ )
{
sProfileID = ssprintf("%08d",i);
@@ -296,7 +296,7 @@ bool ProfileManager::CreateMachineProfile( CString sName )
return true;
}
bool ProfileManager::RenameMachineProfile( CString sProfileID, CString sNewName )
bool ProfileManager::RenameLocalProfile( CString sProfileID, CString sNewName )
{
ASSERT( !sProfileID.empty() );
@@ -316,7 +316,7 @@ bool ProfileManager::RenameMachineProfile( CString sProfileID, CString sNewName
return true;
}
bool ProfileManager::DeleteMachineProfile( CString sProfileID )
bool ProfileManager::DeleteLocalProfile( CString sProfileID )
{
// delete all files in profile dir
CString sProfileDir = USER_PROFILES_DIR + sProfileID;
@@ -423,9 +423,9 @@ void FileWrite(RageFile& f, float fWrite)
void ProfileManager::ReadSongScoresFromFile( CString fn, MemoryCard mc )
{
RageFile f(fn);
if (!f.IsOpen() || f.GetError() != 0)
return; /* don't warn if it just doesn't exist */
RageFile f;
if( !f.Open(fn, RageFile::READ) )
return;
int version;
if( !FileRead(f, version) )
@@ -518,9 +518,9 @@ void ProfileManager::ReadSongScoresFromFile( CString fn, MemoryCard mc )
void ProfileManager::ReadCategoryScoresFromFile( CString fn, MemoryCard mc )
{
RageFile f(fn);
if (!f.IsOpen() || f.GetError() != 0)
return; /* don't warn if it just doesn't exist */
RageFile f;
if( !f.Open(fn, RageFile::READ) )
return;
int version;
if( !FileRead(f, version) )
@@ -550,9 +550,9 @@ void ProfileManager::ReadCategoryScoresFromFile( CString fn, MemoryCard mc )
void ProfileManager::ReadCourseScoresFromFile( CString fn, MemoryCard mc )
{
RageFile f(fn);
if (!f.IsOpen() || f.GetError() != 0)
return; /* don't warn if it just doesn't exist */
RageFile f;
if( !f.Open(fn, RageFile::READ) )
return;
int version;
if( !FileRead(f, version) )
@@ -705,8 +705,8 @@ void ProfileManager::SaveCategoryScoresToFile( CString fn, MemoryCard mc )
{
LOG->Trace("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( "<td> </td>" );
else
f.Write( ssprintf("<td><img src=\"%s\" width='120'></td>", HTMLQuoteDoubleQuotes(sImagePath).c_str()) );
f.Write( "<td> </td>" );
f.Write( ssprintf("<td>%s<br>", pSong->GetTranslitMainTitle().c_str()) );
f.Write( ssprintf("<font size='-1'>%s</font><br>", pSong->GetTranslitSubTitle().c_str()) );
f.Write( ssprintf("<font size='-1'><i>%s</i></font></td>", pSong->GetTranslitArtist().c_str()) );
+5 -5
View File
@@ -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<CString> &asProfileIDsOut );
void GetMachineProfileNames( vector<CString> &asNamesOut );
void GetLocalProfileIDs( vector<CString> &asProfileIDsOut );
void GetLocalProfileNames( vector<CString> &asNamesOut );
bool LoadFirstAvailableProfile( PlayerNumber pn );
bool IsMemoryCardInserted( PlayerNumber pn );
+16 -16
View File
@@ -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<CString> 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<CString> 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<CString> vsProfiles;
PROFILEMAN->GetMachineProfileIDs( vsProfiles );
PROFILEMAN->GetLocalProfileIDs( vsProfiles );
if( m_iSelectedOption[0][m_iCurrentRow[0]]==0 )
return "";
+1 -1
View File
@@ -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();