fix machine profile saving

This commit is contained in:
Chris Danford
2003-12-08 06:41:30 +00:00
parent a914544718
commit a93fbd11bd
4 changed files with 109 additions and 17 deletions
+18 -7
View File
@@ -167,6 +167,8 @@ void GameState::EndGame()
if( iPlaySeconds < 0 )
iPlaySeconds = 0;
Profile* pMachineProfile = PROFILEMAN->GetMachineProfile();
for( int p=0; p<NUM_PLAYERS; p++ )
{
int iGameplaySeconds = 0;
@@ -174,19 +176,28 @@ void GameState::EndGame()
iGameplaySeconds += m_vPlayedStageStats[i].fAliveSeconds[p];
Profile* pProfile = PROFILEMAN->GetProfile( (PlayerNumber)p );
if( pProfile==NULL )
continue;
Profile* pPlayerProfile = PROFILEMAN->GetProfile( (PlayerNumber)p );
pProfile->m_iTotalPlaySeconds += iPlaySeconds;
pProfile->m_iTotalGameplaySeconds += iGameplaySeconds;
pProfile->m_iTotalPlays++;
pProfile->m_iCurrentCombo =
pMachineProfile->m_iTotalPlaySeconds += iPlaySeconds;
pMachineProfile->m_iTotalGameplaySeconds += iGameplaySeconds;
if( pPlayerProfile )
pPlayerProfile->m_iTotalPlaySeconds += iPlaySeconds;
if( pPlayerProfile )
pPlayerProfile->m_iTotalGameplaySeconds += iGameplaySeconds;
if( pPlayerProfile )
pPlayerProfile->m_iTotalPlays++;
if( pPlayerProfile )
pPlayerProfile->m_iCurrentCombo =
PREFSMAN->m_bComboContinuesBetweenSongs ?
GAMESTATE->m_CurStageStats.iCurCombo[p] :
0;
}
pMachineProfile->m_iTotalPlays++;
pMachineProfile->m_iCurrentCombo = 0;
BOOKKEEPER->WriteToDisk();
PROFILEMAN->SaveMachineScoresToDisk();
}
+84 -10
View File
@@ -128,6 +128,8 @@ bool ProfileManager::LoadProfile( PlayerNumber pn, CString sProfileDir, bool bIs
bool ProfileManager::CreateProfile( CString sProfileDir, CString sName )
{
ASSERT( !sName.empty() );
bool bResult;
Profile pro;
@@ -345,6 +347,8 @@ bool ProfileManager::DeleteLocalProfile( CString sProfileID )
void ProfileManager::SaveMachineScoresToDisk()
{
m_MachineProfile.SaveToIni( MACHINE_PROFILE_DIR PROFILE_FILE );
SaveCategoryScoresToFile( MACHINE_PROFILE_DIR CATEGORY_SCORES_FILE, MEMORY_CARD_MACHINE );
SaveSongScoresToFile( MACHINE_PROFILE_DIR SONG_SCORES_FILE, MEMORY_CARD_MACHINE );
SaveCourseScoresToFile( MACHINE_PROFILE_DIR COURSE_SCORES_FILE, MEMORY_CARD_MACHINE );
@@ -589,6 +593,12 @@ void ProfileManager::InitMachineScoresFromDisk()
ReadCategoryScoresFromFile( MACHINE_PROFILE_DIR CATEGORY_SCORES_FILE, MEMORY_CARD_MACHINE );
ReadSongScoresFromFile( MACHINE_PROFILE_DIR SONG_SCORES_FILE, MEMORY_CARD_MACHINE );
ReadCourseScoresFromFile( MACHINE_PROFILE_DIR COURSE_SCORES_FILE, MEMORY_CARD_MACHINE );
if( !m_MachineProfile.LoadFromIni(MACHINE_PROFILE_DIR PROFILE_FILE) )
{
CreateProfile(MACHINE_PROFILE_DIR, "Machine");
m_MachineProfile.LoadFromIni(MACHINE_PROFILE_DIR PROFILE_FILE);
}
}
void ProfileManager::ReadSM300NoteScores()
@@ -858,6 +868,19 @@ static CString HTMLQuoteDoubleQuotes( CString str )
void ProfileManager::SaveStatsWebPageToFile( CString fn, MemoryCard mc )
{
//
// Get Profile
//
Profile* pProfile;
if( mc == MEMORY_CARD_MACHINE )
pProfile = GetMachineProfile();
else
pProfile = GetProfile( (PlayerNumber)mc );
ASSERT(pProfile);
//
// Open file
//
RageFile f;
if( !f.Open( fn, RageFile::WRITE ) )
{
@@ -865,6 +888,15 @@ void ProfileManager::SaveStatsWebPageToFile( CString fn, MemoryCard mc )
return;
}
//
// Make local song list
//
vector<Song*> vpSongs = SONGMAN->GetAllSongs();
SortSongPointerArrayByGroupAndTitle( vpSongs );
//
// print HTML headers
//
f.PutLine( "<html>" );
f.PutLine( "<head>" );
f.PutLine( "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\">" );
@@ -872,35 +904,77 @@ void ProfileManager::SaveStatsWebPageToFile( CString fn, MemoryCard mc )
f.PutLine( "</head>" );
f.PutLine( "<body>" );
vector<Song*> vpSongs = SONGMAN->GetAllSongs();
SortSongPointerArrayByGroupAndTitle( vpSongs );
//
// Print table of contents
//
f.PutLine( "<h1><a name='Table of Contents'>Table of Contents</a></h1><br>\n" );
f.PutLine( "<a href='#My Statistics'>My Statistics</a><br>\n" );
f.PutLine( "<a href='#Song/Steps List'>Song/Steps List</a><br>\n" );
f.PutLine( "<a href='#Difficulty Table'>Difficulty Table</a><br>\n" );
f.PutLine( "<br>\n" );
//
// Print My Statistics
//
f.PutLine( "<h1><a name='My Statistics'>My Statistics</a></h1><br><a href='#Table of Contents'>top</a>\n" );
f.PutLine( "<table border='1'>" );
#define PRINT_STAT_S(szName,sVal) f.Write( ssprintf("<tr><td>%s</td><td>%s</td></tr>\n",szName,sVal.c_str()) )
#define PRINT_STAT_B(szName,bVal) f.Write( ssprintf("<tr><td>%s</td><td>%s</td></tr>\n",szName,bVal?"yes":"no") )
#define PRINT_STAT_I(szName,iVal) f.Write( ssprintf("<tr><td>%s</td><td>%d</td></tr>\n",szName,iVal) )
if( pProfile->m_sLastUsedHighScoreName.empty() )
PRINT_STAT_S( "Name", pProfile->m_sName );
else
PRINT_STAT_S( "Name", pProfile->m_sLastUsedHighScoreName );
PRINT_STAT_B( "UsingProfileDefaultModifiers", pProfile->m_bUsingProfileDefaultModifiers );
PRINT_STAT_S( "DefaultModifiers", pProfile->m_sDefaultModifiers );
PRINT_STAT_I( "TotalPlays", pProfile->m_iTotalPlays );
PRINT_STAT_I( "TotalPlaySeconds", pProfile->m_iTotalPlaySeconds );
PRINT_STAT_I( "TotalGameplaySeconds", pProfile->m_iTotalGameplaySeconds );
PRINT_STAT_I( "CurrentCombo", pProfile->m_iCurrentCombo );
//#undef PRINT_STAT_S
//#undef PRINT_STAT_B
//#undef PRINT_STAT_I
f.PutLine( "</table>\n<br>" );
//
// Print song list
//
f.PutLine( "<table border='1'>" );
f.PutLine( "<h1><a name='Song/Steps List'>Song/Steps List</a></h1><a href='#Table of Contents'>top</a><br>\n" );
for( unsigned i=0; i<vpSongs.size(); i++ )
{
Song* pSong = vpSongs[i];
f.Write( "<tr>" );
f.PutLine( "<table border='1'>" );
/* XXX: We can't call pSong->HasBanner on every song; it'll effectively re-traverse the entire
* song directory tree checking if each banner file really exists.
*
* (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.) */
/* Don't print the song banner anyway since this is going on the memory card. -Chris */
//CString sImagePath = pSong->HasBanner() ? pSong->GetBannerPath() : (pSong->HasBackground() ? pSong->GetBackgroundPath() : "" );
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()) );
f.PutLine( "</tr>" );
PRINT_STAT_S( "MainTitle", pSong->GetTranslitMainTitle() );
PRINT_STAT_S( "SubTitle", pSong->GetTranslitSubTitle() );
PRINT_STAT_S( "Artist", pSong->GetTranslitArtist() );
//
// Print Steps list
//
vector<Steps*> vpSteps = pSong->GetAllSteps();
for( unsigned j=0; j<vpSteps.size(); j++ )
{
Steps* pSteps = vpSteps[j];
if( pSteps->IsAutogen() )
continue;
PRINT_STAT_S( "Difficulty", DifficultyToString(pSteps->GetDifficulty()) );
}
f.PutLine( "</table>\n<br>" );
}
f.PutLine( "</table>\n<br>" );
//
// Print steps tables
//
f.PutLine( "<h1><a name='Difficulty Table'>Difficulty Table</a></h1><a href='#Table of Contents'>top</a><br>\n" );
for( int g=0; g<NUM_GAMES; g++ )
{
Game game = (Game)g;
+6
View File
@@ -1021,6 +1021,12 @@ bool HandleGlobalInputs( DeviceInput DeviceI, InputEventType type, GameInput Gam
{
THEME->ReloadMetrics();
TEXTUREMAN->ReloadAll();
// HACK: Also save bookkeeping and profile info for debugging
// so we don't have to play through a whole song to get new output.
BOOKKEEPER->WriteToDisk();
PROFILEMAN->SaveMachineScoresToDisk();
SCREENMAN->SystemMessage( "Reloaded metrics and textures" );
return true;
}
+1
View File
@@ -243,6 +243,7 @@ public:
bool SongCompleteForStyle( const StyleDef *st ) const;
bool SongHasNotesType( StepsType nt ) const;
bool SongHasNotesTypeAndDifficulty( StepsType nt, Difficulty dc ) const;
const vector<Steps*>& GetAllSteps() const { return m_apNotes; }
void GetSteps( vector<Steps*>& arrayAddTo, StepsType nt, Difficulty dc = DIFFICULTY_INVALID, int iMeterLow = -1, int iMeterHigh = -1, CString sDescription = "", bool bIncludeAutoGen = true ) const;
Steps* GetStepsByDifficulty( StepsType nt, Difficulty dc, bool bIncludeAutoGen = true ) const;
Steps* GetStepsByMeter( StepsType nt, int iMeterLow, int iMeterHigh, bool bIncludeAutoGen = true ) const;