fix machine profile saving
This commit is contained in:
@@ -167,6 +167,8 @@ void GameState::EndGame()
|
|||||||
if( iPlaySeconds < 0 )
|
if( iPlaySeconds < 0 )
|
||||||
iPlaySeconds = 0;
|
iPlaySeconds = 0;
|
||||||
|
|
||||||
|
Profile* pMachineProfile = PROFILEMAN->GetMachineProfile();
|
||||||
|
|
||||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||||
{
|
{
|
||||||
int iGameplaySeconds = 0;
|
int iGameplaySeconds = 0;
|
||||||
@@ -174,19 +176,28 @@ void GameState::EndGame()
|
|||||||
iGameplaySeconds += m_vPlayedStageStats[i].fAliveSeconds[p];
|
iGameplaySeconds += m_vPlayedStageStats[i].fAliveSeconds[p];
|
||||||
|
|
||||||
|
|
||||||
Profile* pProfile = PROFILEMAN->GetProfile( (PlayerNumber)p );
|
Profile* pPlayerProfile = PROFILEMAN->GetProfile( (PlayerNumber)p );
|
||||||
if( pProfile==NULL )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
pProfile->m_iTotalPlaySeconds += iPlaySeconds;
|
pMachineProfile->m_iTotalPlaySeconds += iPlaySeconds;
|
||||||
pProfile->m_iTotalGameplaySeconds += iGameplaySeconds;
|
pMachineProfile->m_iTotalGameplaySeconds += iGameplaySeconds;
|
||||||
pProfile->m_iTotalPlays++;
|
|
||||||
pProfile->m_iCurrentCombo =
|
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 ?
|
PREFSMAN->m_bComboContinuesBetweenSongs ?
|
||||||
GAMESTATE->m_CurStageStats.iCurCombo[p] :
|
GAMESTATE->m_CurStageStats.iCurCombo[p] :
|
||||||
0;
|
0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pMachineProfile->m_iTotalPlays++;
|
||||||
|
pMachineProfile->m_iCurrentCombo = 0;
|
||||||
|
|
||||||
|
|
||||||
BOOKKEEPER->WriteToDisk();
|
BOOKKEEPER->WriteToDisk();
|
||||||
PROFILEMAN->SaveMachineScoresToDisk();
|
PROFILEMAN->SaveMachineScoresToDisk();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,6 +128,8 @@ bool ProfileManager::LoadProfile( PlayerNumber pn, CString sProfileDir, bool bIs
|
|||||||
|
|
||||||
bool ProfileManager::CreateProfile( CString sProfileDir, CString sName )
|
bool ProfileManager::CreateProfile( CString sProfileDir, CString sName )
|
||||||
{
|
{
|
||||||
|
ASSERT( !sName.empty() );
|
||||||
|
|
||||||
bool bResult;
|
bool bResult;
|
||||||
|
|
||||||
Profile pro;
|
Profile pro;
|
||||||
@@ -345,6 +347,8 @@ bool ProfileManager::DeleteLocalProfile( CString sProfileID )
|
|||||||
|
|
||||||
void ProfileManager::SaveMachineScoresToDisk()
|
void ProfileManager::SaveMachineScoresToDisk()
|
||||||
{
|
{
|
||||||
|
m_MachineProfile.SaveToIni( MACHINE_PROFILE_DIR PROFILE_FILE );
|
||||||
|
|
||||||
SaveCategoryScoresToFile( MACHINE_PROFILE_DIR CATEGORY_SCORES_FILE, MEMORY_CARD_MACHINE );
|
SaveCategoryScoresToFile( MACHINE_PROFILE_DIR CATEGORY_SCORES_FILE, MEMORY_CARD_MACHINE );
|
||||||
SaveSongScoresToFile( MACHINE_PROFILE_DIR SONG_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 );
|
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 );
|
ReadCategoryScoresFromFile( MACHINE_PROFILE_DIR CATEGORY_SCORES_FILE, MEMORY_CARD_MACHINE );
|
||||||
ReadSongScoresFromFile( MACHINE_PROFILE_DIR SONG_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 );
|
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()
|
void ProfileManager::ReadSM300NoteScores()
|
||||||
@@ -858,6 +868,19 @@ static CString HTMLQuoteDoubleQuotes( CString str )
|
|||||||
|
|
||||||
void ProfileManager::SaveStatsWebPageToFile( CString fn, MemoryCard mc )
|
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;
|
RageFile f;
|
||||||
if( !f.Open( fn, RageFile::WRITE ) )
|
if( !f.Open( fn, RageFile::WRITE ) )
|
||||||
{
|
{
|
||||||
@@ -865,6 +888,15 @@ void ProfileManager::SaveStatsWebPageToFile( CString fn, MemoryCard mc )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Make local song list
|
||||||
|
//
|
||||||
|
vector<Song*> vpSongs = SONGMAN->GetAllSongs();
|
||||||
|
SortSongPointerArrayByGroupAndTitle( vpSongs );
|
||||||
|
|
||||||
|
//
|
||||||
|
// print HTML headers
|
||||||
|
//
|
||||||
f.PutLine( "<html>" );
|
f.PutLine( "<html>" );
|
||||||
f.PutLine( "<head>" );
|
f.PutLine( "<head>" );
|
||||||
f.PutLine( "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\">" );
|
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( "</head>" );
|
||||||
f.PutLine( "<body>" );
|
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
|
// 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++ )
|
for( unsigned i=0; i<vpSongs.size(); i++ )
|
||||||
{
|
{
|
||||||
Song* pSong = vpSongs[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
|
/* 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.
|
* 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
|
* (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.) */
|
* 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() : "" );
|
//CString sImagePath = pSong->HasBanner() ? pSong->GetBannerPath() : (pSong->HasBackground() ? pSong->GetBackgroundPath() : "" );
|
||||||
f.Write( "<td> </td>" );
|
PRINT_STAT_S( "MainTitle", pSong->GetTranslitMainTitle() );
|
||||||
f.Write( ssprintf("<td>%s<br>", pSong->GetTranslitMainTitle().c_str()) );
|
PRINT_STAT_S( "SubTitle", pSong->GetTranslitSubTitle() );
|
||||||
f.Write( ssprintf("<font size='-1'>%s</font><br>", pSong->GetTranslitSubTitle().c_str()) );
|
PRINT_STAT_S( "Artist", pSong->GetTranslitArtist() );
|
||||||
f.Write( ssprintf("<font size='-1'><i>%s</i></font></td>", pSong->GetTranslitArtist().c_str()) );
|
|
||||||
f.PutLine( "</tr>" );
|
//
|
||||||
|
// 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
|
// 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++ )
|
for( int g=0; g<NUM_GAMES; g++ )
|
||||||
{
|
{
|
||||||
Game game = (Game)g;
|
Game game = (Game)g;
|
||||||
|
|||||||
@@ -1021,6 +1021,12 @@ bool HandleGlobalInputs( DeviceInput DeviceI, InputEventType type, GameInput Gam
|
|||||||
{
|
{
|
||||||
THEME->ReloadMetrics();
|
THEME->ReloadMetrics();
|
||||||
TEXTUREMAN->ReloadAll();
|
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" );
|
SCREENMAN->SystemMessage( "Reloaded metrics and textures" );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -243,6 +243,7 @@ public:
|
|||||||
bool SongCompleteForStyle( const StyleDef *st ) const;
|
bool SongCompleteForStyle( const StyleDef *st ) const;
|
||||||
bool SongHasNotesType( StepsType nt ) const;
|
bool SongHasNotesType( StepsType nt ) const;
|
||||||
bool SongHasNotesTypeAndDifficulty( StepsType nt, Difficulty dc ) 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;
|
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* GetStepsByDifficulty( StepsType nt, Difficulty dc, bool bIncludeAutoGen = true ) const;
|
||||||
Steps* GetStepsByMeter( StepsType nt, int iMeterLow, int iMeterHigh, bool bIncludeAutoGen = true ) const;
|
Steps* GetStepsByMeter( StepsType nt, int iMeterLow, int iMeterHigh, bool bIncludeAutoGen = true ) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user