diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index 795e95804e..48eb264d3d 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -4262,4 +4262,6 @@ LevelP1OnCommand=addy,-140 LevelP2OnCommand=addy,-140 [ProfileManager] -StatsTitle=StepMania Statistics +StatsTitle=StepMania Data +StatsFooter=generated by StepMania +StatsURL= diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index 1811bf8fe2..8f19975f9b 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -1056,20 +1056,20 @@ void SortCoursePointerArrayByAvgDifficulty( vector &apCourses ) } -void SortCoursePointerArrayByMostPlayed( vector &arrayCoursePointers, ProfileSlot slot ) +void SortCoursePointerArrayByNumPlays( vector &arrayCoursePointers, ProfileSlot slot, bool bDescending ) { Profile* pProfile = PROFILEMAN->GetProfile(slot); if( pProfile == NULL ) return; // nothing to do since we don't have data - SortCoursePointerArrayByMostPlayed( arrayCoursePointers, pProfile ); + SortCoursePointerArrayByNumPlays( arrayCoursePointers, pProfile, bDescending ); } -void SortCoursePointerArrayByMostPlayed( vector &arrayCoursePointers, const Profile* pProfile ) +void SortCoursePointerArrayByNumPlays( vector &arrayCoursePointers, const Profile* pProfile, bool bDescending ) { ASSERT( pProfile ); for(unsigned i = 0; i < arrayCoursePointers.size(); ++i) course_sort_val[arrayCoursePointers[i]] = (float) pProfile->GetCourseNumTimesPlayed(arrayCoursePointers[i]); - stable_sort( arrayCoursePointers.begin(), arrayCoursePointers.end(), CompareCoursePointersBySortValueDescending ); + stable_sort( arrayCoursePointers.begin(), arrayCoursePointers.end(), bDescending ? CompareCoursePointersBySortValueDescending : CompareCoursePointersBySortValueAscending ); course_sort_val.clear(); } diff --git a/stepmania/src/Course.h b/stepmania/src/Course.h index d746726baf..91b4e0b668 100644 --- a/stepmania/src/Course.h +++ b/stepmania/src/Course.h @@ -166,8 +166,8 @@ void SortCoursePointerArrayByType( vector &apCourses ); void SortCoursePointerArrayByAvgDifficulty( vector &apCourses ); void SortCoursePointerArrayByTotalDifficulty( vector &apCourses ); void SortCoursePointerArrayByRanking( vector &apCourses ); -void SortCoursePointerArrayByMostPlayed( vector &arrayCoursePointers, ProfileSlot slot ); -void SortCoursePointerArrayByMostPlayed( vector &arrayCoursePointers, const Profile* pProfile ); +void SortCoursePointerArrayByNumPlays( vector &arrayCoursePointers, ProfileSlot slot, bool bDescending ); +void SortCoursePointerArrayByNumPlays( vector &arrayCoursePointers, const Profile* pProfile, bool bDescending ); void MoveRandomToEnd( vector &apCourses ); diff --git a/stepmania/src/CryptManager.cpp b/stepmania/src/CryptManager.cpp index 91db41e194..fb04569042 100644 --- a/stepmania/src/CryptManager.cpp +++ b/stepmania/src/CryptManager.cpp @@ -121,3 +121,8 @@ void CryptManager::DigestFile(const char *filename) // cout << "\nMD5: "; // md5Filter.TransferTo(encoder); } + +CString CryptManager::GetPublicKeyFileName() +{ + return PUBLIC_KEY_PATH; +} diff --git a/stepmania/src/CryptManager.h b/stepmania/src/CryptManager.h index 29995b4d88..bc6709dfc8 100644 --- a/stepmania/src/CryptManager.h +++ b/stepmania/src/CryptManager.h @@ -13,6 +13,8 @@ public: static bool VerifyFile( CString sPath ); static void DigestFile(const char *filename); + + static CString GetPublicKeyFileName(); }; extern CryptManager* CRYPTMAN; // global and accessable from anywhere in our program diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 288fa365c2..9091970b9e 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -266,7 +266,7 @@ void GameState::EndGame() CHECKPOINT; BOOKKEEPER->WriteToDisk(); - PROFILEMAN->SaveMachineScoresToDisk(); + PROFILEMAN->SaveMachineProfile(); for( p=0; p::const_iterator iter = m_StepsHighScores.find( pSteps ); if( iter == m_StepsHighScores.end() ) - { return 0; - } else - { - int iTotalNumTimesPlayed = 0; - for( unsigned st = 0; st < NUM_STEPS_TYPES; ++st ) - iTotalNumTimesPlayed += iter->second.hs.iNumTimesPlayed; - return iTotalNumTimesPlayed; - } + return iter->second.hs.iNumTimesPlayed; } void Profile::IncrementStepsPlayCount( const Steps* pSteps ) @@ -294,6 +288,8 @@ bool Profile::LoadAllFromDir( CString sDir ) bool Profile::SaveAllToDir( CString sDir ) const { + m_sLastMachinePlayed = PREFSMAN->m_sMachineName; + // Delete old files after saving new ones so we don't try to load old // and make duplicate records. // If the save fails, the delete will fail too... probably :-) @@ -305,6 +301,7 @@ bool Profile::SaveAllToDir( CString sDir ) const SaveCategoryScoresToDir( sDir ); DeleteCategoryScoresFromDirSM390a12( sDir ); SaveStatsWebPageToDir( sDir ); + SaveMachinePublicKeyToDir( sDir ); return bResult; } @@ -342,6 +339,9 @@ bool Profile::LoadGeneralDataFromDir( CString sDir ) ini.GetValue( "Profile", "TotalPlaySeconds", m_iTotalPlaySeconds ); ini.GetValue( "Profile", "TotalGameplaySeconds", m_iTotalGameplaySeconds ); ini.GetValue( "Profile", "CurrentCombo", m_iCurrentCombo ); + ini.GetValue( "Profile", "WeightPounds", m_fWeightPounds ); + ini.GetValue( "Profile", "CaloriesBurned", m_fCaloriesBurned ); + ini.GetValue( "Profile", "LastMachinePlayed", m_sLastMachinePlayed ); unsigned i; for( i=0; iGetMachineProfile(); + + if( bThisIsMachineProfile ) { SaveMachineHtmlToDir( sDir, this ); -// SavePlayerHtmlToDir( sDir, this, PROFILEMAN->GetMachineProfile() ); // remove this when done debugging + SavePlayerHtmlToDir( sDir+"temp/", this, PROFILEMAN->GetMachineProfile() ); // remove this when done debugging } else { SavePlayerHtmlToDir( sDir, this, PROFILEMAN->GetMachineProfile() ); } } + +void Profile::SaveMachinePublicKeyToDir( CString sDir ) const +{ + FileCopy( CRYPTMAN->GetPublicKeyFileName(), "public.key.rsa" ); +} diff --git a/stepmania/src/Profile.h b/stepmania/src/Profile.h index 3b9983ea8e..67900aba6c 100644 --- a/stepmania/src/Profile.h +++ b/stepmania/src/Profile.h @@ -34,7 +34,7 @@ public: // // smart accessors // - CString GetDisplayName(); + CString GetDisplayName() const; CString GetDisplayCaloriesBurned(); int GetTotalNumSongsPlayed(); static CString GetProfileDisplayNameFromDir( CString sDir ); @@ -43,7 +43,6 @@ public: // // General data // - bool m_bIsMachineProfile; CString m_sName; CString m_sLastUsedHighScoreName; bool m_bUsingProfileDefaultModifiers; @@ -54,6 +53,7 @@ public: int m_iCurrentCombo; float m_fWeightPounds; int m_fCaloriesBurned; + mutable CString m_sLastMachinePlayed; // mutable because we overwrite this on save, and I don't want to remove const from the whole save chain. -Chris int m_iNumSongsPlayedByPlayMode[NUM_PLAY_MODES]; int m_iNumSongsPlayedByStyle[NUM_STYLES]; int m_iNumSongsPlayedByDifficulty[NUM_DIFFICULTIES]; @@ -146,6 +146,8 @@ public: void DeleteCategoryScoresFromDirSM390a12( CString sDir ) const; void SaveStatsWebPageToDir( CString sDir ) const; + + void SaveMachinePublicKeyToDir( CString sDir ) const; }; diff --git a/stepmania/src/ProfileHtml.cpp b/stepmania/src/ProfileHtml.cpp index e25880c107..c63b3bd21c 100644 --- a/stepmania/src/ProfileHtml.cpp +++ b/stepmania/src/ProfileHtml.cpp @@ -27,6 +27,7 @@ #define STYLE_CSS "style.css" #define STATS_TITLE THEME->GetMetric("ProfileManager","StatsTitle") +#define STATS_FOOTER THEME->GetMetric("ProfileManager","StatsFooter") static int g_Level = 1; @@ -141,6 +142,8 @@ void PrintStatistics( RageFile &f, const Profile *pProfile, CString sTitle, vect TABLE_LINE2( "TotalPlaySeconds", pProfile->m_iTotalPlaySeconds ); TABLE_LINE2( "TotalGameplaySeconds", pProfile->m_iTotalGameplaySeconds ); TABLE_LINE2( "CurrentCombo", pProfile->m_iCurrentCombo ); + TABLE_LINE2( "CaloriesBurned", pProfile->m_fCaloriesBurned ); + TABLE_LINE2( "LastMachinePlayed", pProfile->m_sLastMachinePlayed ); END_TABLE; } PRINT_CLOSE(f); @@ -201,35 +204,63 @@ void PrintPopularity( RageFile &f, const Profile *pProfile, CString sTitle, vect { PRINT_OPEN(f, sTitle ); { - // Songs by popularity - { - unsigned uNumToShow = min( vpSongs.size(), (unsigned)100 ); + SortSongPointerArrayByNumPlays( vpSongs, pProfile, true ); + Song* pSongPopularThreshold = vpSongs[ vpSongs.size()*2/3 ]; + int iPopularNumPlaysThreshold = pProfile->GetSongNumTimesPlayed(pSongPopularThreshold); + + // unplayed songs are always considered unpopular + if( iPopularNumPlaysThreshold == 0 ) + iPopularNumPlaysThreshold = 1; - SortSongPointerArrayByMostPlayed( vpSongs, pProfile ); - PRINT_OPEN(f, "Songs by Popularity" ); + unsigned uMaxToShow = min( vpSongs.size(), (unsigned)100 ); + + { + PRINT_OPEN(f, "Most Popular Songs" ); { BEGIN_TABLE(1); - for( unsigned i=0; iGetFullDisplayTitle(), pProfile->GetSongNumTimesPlayed(pSong) ); + int iNumTimesPlayed = pProfile->GetSongNumTimesPlayed(pSong); + if( iNumTimesPlayed == 0 || iNumTimesPlayed < iPopularNumPlaysThreshold ) // not popular + break; // done searching + TABLE_LINE3(i+1, pSong->GetFullDisplayTitle(), iNumTimesPlayed ); + } + END_TABLE; + } + PRINT_CLOSE(f); + } + + { + SortSongPointerArrayByNumPlays( vpSongs, pProfile, false ); + PRINT_OPEN(f, "Least Popular Songs" ); + { + BEGIN_TABLE(1); + for( unsigned i=0; iGetSongNumTimesPlayed(pSong); + if( iNumTimesPlayed >= iPopularNumPlaysThreshold ) // not unpopular + break; // done searching + TABLE_LINE3(i+1, pSong->GetFullDisplayTitle(), iNumTimesPlayed ); } END_TABLE; } PRINT_CLOSE(f); } - // Steps by popularity { unsigned uNumToShow = min( vpAllSteps.size(), (unsigned)100 ); - SortStepsPointerArrayByMostPlayed( vpAllSteps, pProfile ); - PRINT_OPEN(f, "Steps by Popularity" ); + SortStepsPointerArrayByNumPlays( vpAllSteps, pProfile, true ); + PRINT_OPEN(f, "Most Popular Steps" ); { BEGIN_TABLE(1); for( unsigned i=0; iGetStepsNumTimesPlayed(pSteps)==0 ) + continue; // skip Song* pSong = mapStepsToSong[pSteps]; CString s; s += pSong->GetFullDisplayTitle(); @@ -244,12 +275,11 @@ void PrintPopularity( RageFile &f, const Profile *pProfile, CString sTitle, vect PRINT_CLOSE(f); } - // Course by popularity { unsigned uNumToShow = min( vpCourses.size(), (unsigned)100 ); - SortCoursePointerArrayByMostPlayed( vpCourses, pProfile ); - PRINT_OPEN(f, "Courses by Popularity" ); + SortCoursePointerArrayByNumPlays( vpCourses, pProfile, true ); + PRINT_OPEN(f, "Most Popular Courses" ); { BEGIN_TABLE(2); for( unsigned i=0; iGetSongNumTimesPlayed(pSong); + if( iNumTimesPlayed == 0 ) + return; // skip + vector vpSteps = pSong->GetAllSteps(); - /* XXX: We can't call pSong->HasBanner on every song; it'll effectively re-traverse the estire - * 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 prist the song banner anyway since this is going on the memory card. -Chris */ - //CString sImagePath = pSong->HasBanner() ? pSong->GetBannerPath() : (pSong->HasBackground() ? pSong->GetBackgroundPath() : "" ); PRINT_OPEN(f, pSong->GetFullDisplayTitle() ); { BEGIN_TABLE(2); - TABLE_LINE2( "NumTimesPlayed", pProfile->GetSongNumTimesPlayed(pSong) ); + TABLE_LINE2( "NumTimesPlayed", iNumTimesPlayed ); END_TABLE; // @@ -344,6 +371,9 @@ void PrintHighScoresForSong( RageFile &f, const Profile *pProfile, Song* pSong ) Steps* pSteps = vpSteps[j]; if( pSteps->IsAutogen() ) continue; // skip autogen + if( pProfile->GetStepsNumTimesPlayed(pSteps)==0 ) + continue; // skip + const HighScoreList &hsl = pProfile->GetStepsHighScoreList( pSteps ); CString s = GAMEMAN->NotesTypeToString(pSteps->m_StepsType) + @@ -692,6 +722,13 @@ function expandIt(whichEl)\n\ STATS_TITLE.c_str(), STYLE_CSS ) ); } + CString sType; + switch( saveType ) + { + case SAVE_TYPE_PLAYER: sType = "Player: "; break; + case SAVE_TYPE_MACHINE: sType = "Machine: "; break; + } + CString sName = pProfile->m_sLastUsedHighScoreName.empty() ? pProfile->m_sName : @@ -700,18 +737,20 @@ STATS_TITLE.c_str(), STYLE_CSS ) ); CString sTime = ctime( <ime ); f.Write( ssprintf( - "

%s

for %s
%s
\n", - STATS_TITLE.c_str(), sName.c_str(), sTime.c_str() ) ); + "

%s

%s %s
%s
\n", + STATS_TITLE.c_str(), sType.c_str(), sName.c_str(), sTime.c_str() ) ); + CString sPlayerName = pProfile->GetDisplayName(); + CString sMachineName = pProfileMachine->GetDisplayName(); switch( saveType ) { case SAVE_TYPE_PLAYER: - PrintStatistics( f, pProfile, "Personal Statistics", vpSongs, vpAllSteps, vStepsTypesToShow, mapStepsToSong, vpCourses ); - PrintPopularity( f, pProfile, "Personal Popularity", vpSongs, vpAllSteps, vStepsTypesToShow, mapStepsToSong, vpCourses ); - PrintHighScores( f, pProfile, "Personal High Scores", vpSongs, vpAllSteps, vStepsTypesToShow, mapStepsToSong, vpCourses ); - PrintPopularity( f, pProfileMachine, "Last Machine Popularity", vpSongs, vpAllSteps, vStepsTypesToShow, mapStepsToSong, vpCourses ); - PrintHighScores( f, pProfileMachine, "Last Machine High Scores", vpSongs, vpAllSteps, vStepsTypesToShow, mapStepsToSong, vpCourses ); + PrintStatistics( f, pProfile, sPlayerName+"'s Statistics", vpSongs, vpAllSteps, vStepsTypesToShow, mapStepsToSong, vpCourses ); + PrintPopularity( f, pProfile, sPlayerName+"'s Popularity", vpSongs, vpAllSteps, vStepsTypesToShow, mapStepsToSong, vpCourses ); + PrintHighScores( f, pProfile, sPlayerName+"'s High Scores", vpSongs, vpAllSteps, vStepsTypesToShow, mapStepsToSong, vpCourses ); + PrintPopularity( f, pProfileMachine, sMachineName+"'s Popularity", vpSongs, vpAllSteps, vStepsTypesToShow, mapStepsToSong, vpCourses ); + PrintHighScores( f, pProfileMachine, sMachineName+"'s High Scores", vpSongs, vpAllSteps, vStepsTypesToShow, mapStepsToSong, vpCourses ); break; case SAVE_TYPE_MACHINE: PrintStatistics( f, pProfile, "Statistics", vpSongs, vpAllSteps, vStepsTypesToShow, mapStepsToSong, vpCourses ); @@ -725,6 +764,8 @@ STATS_TITLE.c_str(), STYLE_CSS ) ); ASSERT(0); } + f.PutLine( ssprintf("\n", STATS_FOOTER.c_str()) ); + f.PutLine( "" ); f.PutLine( "" ); diff --git a/stepmania/src/ProfileManager.cpp b/stepmania/src/ProfileManager.cpp index 84d3d0279c..f02aec64e5 100644 --- a/stepmania/src/ProfileManager.cpp +++ b/stepmania/src/ProfileManager.cpp @@ -56,12 +56,12 @@ ProfileManager::ProfileManager() for( int p=0; p &asProfileIDsOut ) @@ -290,15 +290,20 @@ bool ProfileManager::DeleteLocalProfile( CString sProfileID ) return FILEMAN->Remove( sProfileDir ); } -void ProfileManager::SaveMachineScoresToDisk() const +void ProfileManager::SaveMachineProfile() { + // If the machine name has changed, make sure we use the new name. + // It's important that this name be applied before the Player profiles + // are saved, so that the Player's profiles show the right machine name. + m_MachineProfile.m_sName = PREFSMAN->m_sMachineName; + m_MachineProfile.SaveAllToDir( MACHINE_PROFILE_DIR ); } -void ProfileManager::InitMachineScoresFromDisk() +void ProfileManager::LoadMachineProfile() { // read old style notes scores // ReadSM300NoteScores(); @@ -308,6 +313,9 @@ void ProfileManager::InitMachineScoresFromDisk() CreateProfile(MACHINE_PROFILE_DIR, "Machine"); m_MachineProfile.LoadAllFromDir( MACHINE_PROFILE_DIR ); } + + // If the machine name has changed, make sure we use the new name + m_MachineProfile.m_sName = PREFSMAN->m_sMachineName; } /* diff --git a/stepmania/src/ProfileManager.h b/stepmania/src/ProfileManager.h index 9071599e87..97098f945a 100644 --- a/stepmania/src/ProfileManager.h +++ b/stepmania/src/ProfileManager.h @@ -38,6 +38,10 @@ public: bool SaveProfile( PlayerNumber pn ); void UnloadProfile( PlayerNumber pn ); + // + // High scores + // + void LoadMachineProfile(); void SaveMachineProfile(); bool IsUsingProfile( PlayerNumber pn ) { return !m_sProfileDir[pn].empty(); } @@ -67,11 +71,6 @@ public: bool ProfileWasLoadedFromMemoryCard( PlayerNumber pn ); - // - // High scores - // - void InitMachineScoresFromDisk(); - void SaveMachineScoresToDisk() const; // // Song stats diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index 8a3f80c19d..f4eeb1fac8 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -1300,7 +1300,7 @@ void ScreenEvaluation::Input( const DeviceInput& DeviceI, const InputEventType t /* XXX: What's the difference between this and StyleI.player? */ /* StyleI won't be valid if it's a menu button that's pressed. * There's got to be a better way of doing this. -Chris */ - CString sDir = PROFILEMAN->GetProfileDir((ProfileSlot)pn); + CString sDir = PROFILEMAN->GetProfileDir((ProfileSlot)pn) + "Screenshots/"; SaveScreenshot( sDir, true, true ); m_bSavedScreenshot[pn] = true; return; // handled diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index 926ab9b1fa..92ffa4e163 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -1367,20 +1367,20 @@ bool CompareSongPointersBySortValueDescending(const Song *pSong1, const Song *pS return song_sort_val[pSong1] > song_sort_val[pSong2]; } -void SortSongPointerArrayByMostPlayed( vector &arraySongPointers, ProfileSlot slot ) +void SortSongPointerArrayByNumPlays( vector &arraySongPointers, ProfileSlot slot, bool bDescending ) { Profile* pProfile = PROFILEMAN->GetProfile(slot); if( pProfile == NULL ) return; // nothing to do since we don't have data - SortSongPointerArrayByMostPlayed( arraySongPointers, pProfile ); + SortSongPointerArrayByNumPlays( arraySongPointers, pProfile, bDescending ); } -void SortSongPointerArrayByMostPlayed( vector &arraySongPointers, const Profile* pProfile ) +void SortSongPointerArrayByNumPlays( vector &arraySongPointers, const Profile* pProfile, bool bDescending ) { ASSERT( pProfile ); for(unsigned i = 0; i < arraySongPointers.size(); ++i) song_sort_val[arraySongPointers[i]] = ssprintf("%9i", pProfile->GetSongNumTimesPlayed(arraySongPointers[i])); - stable_sort( arraySongPointers.begin(), arraySongPointers.end(), CompareSongPointersBySortValueDescending ); + stable_sort( arraySongPointers.begin(), arraySongPointers.end(), bDescending ? CompareSongPointersBySortValueDescending : CompareSongPointersBySortValueAscending ); song_sort_val.clear(); } diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index 21baf13dce..215357f3d9 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -104,7 +104,9 @@ void SongManager::Reload() { FlushDirCache(); - PROFILEMAN->SaveMachineScoresToDisk(); + // save scores before unloading songs, of the scores will be lost + PROFILEMAN->SaveMachineProfile(); + FreeSongs(); FreeCourses(); @@ -118,7 +120,9 @@ void SongManager::Reload() InitSongsFromDisk(NULL); InitCoursesFromDisk(NULL); InitAutogenCourses(); - PROFILEMAN->InitMachineScoresFromDisk(); + + // reload scores afterward + PROFILEMAN->LoadMachineProfile(); PREFSMAN->m_bFastLoad = OldVal; } @@ -870,10 +874,10 @@ void SongManager::UpdateBestAndShuffled() for( int i = 0; i < NUM_PROFILE_SLOTS; ++i ) { m_pBestSongs[i] = m_pSongs; - SortSongPointerArrayByMostPlayed( m_pBestSongs[i], (ProfileSlot) i ); + SortSongPointerArrayByNumPlays( m_pBestSongs[i], (ProfileSlot) i, true ); m_pBestCourses[i] = m_pCourses; - SortCoursePointerArrayByMostPlayed( m_pBestCourses[i], (ProfileSlot) i ); + SortCoursePointerArrayByNumPlays( m_pBestCourses[i], (ProfileSlot) i, true ); } // update shuffled diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index 12cb276a56..9cb47065bd 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -1191,7 +1191,7 @@ bool HandleGlobalInputs( DeviceInput DeviceI, InputEventType type, GameInput Gam // 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(); + PROFILEMAN->SaveMachineProfile(); /* If we're in screen test mode, reload the screen. */ if( PREFSMAN->m_bScreenTestMode ) diff --git a/stepmania/src/Steps.cpp b/stepmania/src/Steps.cpp index b114e4630b..f786837d20 100644 --- a/stepmania/src/Steps.cpp +++ b/stepmania/src/Steps.cpp @@ -328,20 +328,20 @@ bool CompareStepsPointersBySortValueDescending(const Steps *pSteps1, const Steps return steps_sort_val[pSteps1] > steps_sort_val[pSteps2]; } -void SortStepsPointerArrayByMostPlayed( vector &vStepsPointers, ProfileSlot slot ) +void SortStepsPointerArrayByNumPlays( vector &vStepsPointers, ProfileSlot slot, bool bDescending ) { Profile* pProfile = PROFILEMAN->GetProfile(slot); if( pProfile == NULL ) return; // nothing to do since we don't have data - SortStepsPointerArrayByMostPlayed( vStepsPointers, pProfile ); + SortStepsPointerArrayByNumPlays( vStepsPointers, pProfile, bDescending ); } -void SortStepsPointerArrayByMostPlayed( vector &vStepsPointers, const Profile* pProfile ) +void SortStepsPointerArrayByNumPlays( vector &vStepsPointers, const Profile* pProfile, bool bDecending ) { ASSERT( pProfile ); for(unsigned i = 0; i < vStepsPointers.size(); ++i) steps_sort_val[vStepsPointers[i]] = ssprintf("%9i", pProfile->GetStepsNumTimesPlayed(vStepsPointers[i])); - stable_sort( vStepsPointers.begin(), vStepsPointers.end(), CompareStepsPointersBySortValueDescending ); + stable_sort( vStepsPointers.begin(), vStepsPointers.end(), bDecending ? CompareStepsPointersBySortValueDescending : CompareStepsPointersBySortValueAscending ); steps_sort_val.clear(); } diff --git a/stepmania/src/Steps.h b/stepmania/src/Steps.h index c607956bfb..74110e531d 100644 --- a/stepmania/src/Steps.h +++ b/stepmania/src/Steps.h @@ -90,7 +90,7 @@ bool CompareNotesPointersByDifficulty(const Steps *pNotes1, const Steps *pNotes2 void SortNotesArrayByDifficulty( vector &arrayNotess ); bool CompareStepsPointersByTypeAndDifficulty(const Steps *pStep1, const Steps *pStep2); void SortStepsByTypeAndDifficulty( vector &arraySongPointers ); -void SortStepsPointerArrayByMostPlayed( vector &vStepsPointers, ProfileSlot slot ); -void SortStepsPointerArrayByMostPlayed( vector &vStepsPointers, const Profile* pProfile ); +void SortStepsPointerArrayByNumPlays( vector &vStepsPointers, ProfileSlot slot, bool bDescending ); +void SortStepsPointerArrayByNumPlays( vector &vStepsPointers, const Profile* pProfile, bool bDescending ); #endif diff --git a/stepmania/src/song.h b/stepmania/src/song.h index 6666630c89..04fdd1cccd 100644 --- a/stepmania/src/song.h +++ b/stepmania/src/song.h @@ -210,8 +210,8 @@ void SortSongPointerArrayByGrade( vector &arraySongPointers ); void SortSongPointerArrayByArtist( vector &arraySongPointers ); void SortSongPointerArrayByGroupAndDifficulty( vector &arraySongPointers ); void SortSongPointerArrayByGroupAndTitle( vector &arraySongPointers ); -void SortSongPointerArrayByMostPlayed( vector &arraySongPointers, ProfileSlot slot ); -void SortSongPointerArrayByMostPlayed( vector &arraySongPointers, const Profile* pProfile ); +void SortSongPointerArrayByNumPlays( vector &arraySongPointers, ProfileSlot slot, bool bDescending ); +void SortSongPointerArrayByNumPlays( vector &arraySongPointers, const Profile* pProfile, bool bDescending ); void SortSongPointerArrayByMeter( vector &arraySongPointers, Difficulty dc ); CString GetSectionNameFromSongAndSort( const Song* pSong, SongSortOrder so ); void SortSongPointerArrayBySectionName( vector &arraySongPointers, SongSortOrder so );