diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index cb844d2035..610ba95aec 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -36,6 +36,7 @@ const int DIFFICULT_METER_CHANGE = 2; /* Maximum lower value of ranges when difficult: */ const int MAX_BOTTOM_RANGE = 10; + /* -1 is the default parameter of a few Course calls; leaving it out indicates * to use GAMESTATE->m_bDifficultCourses. */ static bool IsDifficult( int Difficult ) @@ -1035,3 +1036,11 @@ void SortCoursePointerArrayByMostPlayed( vector &arrayCoursePointers, M stable_sort( arrayCoursePointers.begin(), arrayCoursePointers.end(), CompareCoursePointersBySortValueDescending ); course_sort_val.clear(); } + +bool Course::MemCardData::HighScore::operator>=( const HighScore& other ) const +{ + if( PREFSMAN->m_bPercentageScoring ) + return fPercentDP >= other.fPercentDP; + else + return iScore >= other.iScore; +} diff --git a/stepmania/src/Course.h b/stepmania/src/Course.h index 1327d5ec1b..c65e3ceea6 100644 --- a/stepmania/src/Course.h +++ b/stepmania/src/Course.h @@ -147,20 +147,19 @@ public: struct HighScore { - int iScore; - float fSurviveTime; CString sName; + int iScore; + float fPercentDP; + float fSurviveTime; HighScore() { iScore = 0; + fPercentDP = 0; fSurviveTime = 0; } - bool operator>=( const HighScore& other ) const - { - return iScore >= other.iScore; - } + bool operator>=( const HighScore& other ) const; }; vector vHighScores; diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 66511c6601..7a98954659 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -1000,11 +1000,9 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector &asFeatsO feat.Type = RankingFeats::SONG; feat.Feat = ssprintf("MR #%d in %s %s", j+1, pSong->GetTranslitMainTitle().c_str(), DifficultyToString(pSteps->GetDifficulty()).c_str() ); feat.pStringToFill = &vMachineHighScores[j].sName; - feat.g = vMachineHighScores[j].grade; - if( PREFSMAN->m_bPercentageScoring ) - feat.Score = vMachineHighScores[j].fPercentDP; - else - feat.Score = (float) vMachineHighScores[j].iScore; + feat.grade = vMachineHighScores[j].grade; + feat.fPercentDP = vMachineHighScores[j].fPercentDP; + feat.iScore = vMachineHighScores[j].iScore; if( pSong->HasBanner() ) feat.Banner = pSong->GetBannerPath(); @@ -1023,8 +1021,9 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector &asFeatsO feat.Type = RankingFeats::SONG; feat.Feat = ssprintf("PR #%d in %s %s", j+1, pSong->GetTranslitMainTitle().c_str(), DifficultyToString(pSteps->GetDifficulty()).c_str() ); feat.pStringToFill = &vPersonalHighScores[j].sName; - feat.g = vPersonalHighScores[j].grade; - feat.Score = (float) vPersonalHighScores[j].iScore; + feat.grade = vPersonalHighScores[j].grade; + feat.fPercentDP = vMachineHighScores[j].fPercentDP; + feat.iScore = vMachineHighScores[j].iScore; // XXX: temporary hack if( pSong->HasBackground() ) @@ -1052,11 +1051,12 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector &asFeatsO continue; RankingFeats feat; - feat.Type = RankingFeats::RANKING; + feat.Type = RankingFeats::CATEGORY; feat.Feat = ssprintf("MR #%d in Type %c (%d)", j+1, 'A'+i, stats.iMeter[pn] ); feat.pStringToFill = &vHighScores[j].sName; - feat.g = GRADE_NO_DATA; - feat.Score = (float) vHighScores[j].iScore; + feat.grade = GRADE_NO_DATA; + feat.iScore = (float) vHighScores[j].iScore; + feat.fPercentDP = (float) vHighScores[j].fPercentDP; asFeatsOut.push_back( feat ); } } @@ -1071,11 +1071,12 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector &asFeatsO continue; RankingFeats feat; - feat.Type = RankingFeats::RANKING; + feat.Type = RankingFeats::CATEGORY; feat.Feat = ssprintf("PR #%d in Type %c (%d)", j+1, 'A'+i, stats.iMeter[pn] ); feat.pStringToFill = &vHighScores[j].sName; - feat.g = GRADE_NO_DATA; - feat.Score = (float) vHighScores[j].iScore; + feat.grade = GRADE_NO_DATA; + feat.iScore = (float) vHighScores[j].iScore; + feat.fPercentDP = (float) vHighScores[j].fPercentDP; asFeatsOut.push_back( feat ); } } @@ -1102,8 +1103,9 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector &asFeatsO feat.Type = RankingFeats::COURSE; feat.Feat = ssprintf("No. %d in %s", i+1, pCourse->m_sName.c_str() ); feat.pStringToFill = &vHighScores[i].sName; - feat.g = GRADE_NO_DATA; - feat.Score = (float) vHighScores[i].iScore; + feat.grade = GRADE_NO_DATA; + feat.iScore = vHighScores[i].iScore; + feat.fPercentDP = vHighScores[i].fPercentDP; if( pCourse->HasBanner() ) feat.Banner = pCourse->m_sBannerPath; asFeatsOut.push_back( feat ); diff --git a/stepmania/src/GameState.h b/stepmania/src/GameState.h index 82cba2f52e..e192524508 100644 --- a/stepmania/src/GameState.h +++ b/stepmania/src/GameState.h @@ -247,10 +247,11 @@ public: // struct RankingFeats { - enum { SONG, COURSE, RANKING } Type; + enum { SONG, COURSE, CATEGORY } Type; - float Score; - Grade g; + Grade grade; + int iScore; + float fPercentDP; CString Banner; CString Feat; CString *pStringToFill; diff --git a/stepmania/src/ProfileManager.cpp b/stepmania/src/ProfileManager.cpp index d8fbb1365b..9fd6868014 100644 --- a/stepmania/src/ProfileManager.cpp +++ b/stepmania/src/ProfileManager.cpp @@ -49,11 +49,11 @@ ProfileManager* PROFILEMAN = NULL; // global and accessable from anywhere in our #define USER_PROFILES_DIR "Data/LocalProfiles/" #define MACHINE_PROFILE_DIR "Data/MachineProfile/" -const int CATEGORY_RANKING_VERSION = 5; +const int CATEGORY_RANKING_VERSION = 6; const int SONG_SCORES_VERSION = 9; -const int COURSE_SCORES_VERSION = 7; +const int COURSE_SCORES_VERSION = 8; -#define STATS_TITLE THEME->GetMetric("ProfileManager","StatsTitle") +#define STATS_TITLE THEME->GetMetric("ProfileManager","StatsTitle") static const char *MemCardDirs[NUM_PLAYERS] = { @@ -547,11 +547,18 @@ void ProfileManager::ReadCategoryScoresFromDir( CString sDir, MemoryCard mc ) CString sName; if( !FileRead(f, sName) ) WARN_AND_RETURN; + int iScore; if( !FileRead(f, iScore) ) WARN_AND_RETURN; + + float fPercentDP; + if( !FileRead(f, fPercentDP) ) + WARN_AND_RETURN; + m_CategoryDatas[mc][st][rc].vHighScores[l].sName = sName; m_CategoryDatas[mc][st][rc].vHighScores[l].iScore = iScore; + m_CategoryDatas[mc][st][rc].vHighScores[l].fPercentDP = fPercentDP; } } } @@ -624,6 +631,10 @@ void ProfileManager::ReadCourseScoresFromDir( CString sDir, MemoryCard mc ) if( !FileRead(f, iScore) ) WARN_AND_RETURN; + float fPercentDP; + if( !FileRead(f, fPercentDP) ) + WARN_AND_RETURN; + float fSurviveTime; if( !FileRead(f, fSurviveTime) ) WARN_AND_RETURN; @@ -632,6 +643,7 @@ void ProfileManager::ReadCourseScoresFromDir( CString sDir, MemoryCard mc ) { pCourse->m_MemCardDatas[st][mc].vHighScores[l].sName = sName; pCourse->m_MemCardDatas[st][mc].vHighScores[l].iScore = iScore; + pCourse->m_MemCardDatas[st][mc].vHighScores[l].fPercentDP = fPercentDP; pCourse->m_MemCardDatas[st][mc].vHighScores[l].fSurviveTime = fSurviveTime; } } @@ -754,6 +766,7 @@ void ProfileManager::SaveCategoryScoresToDir( CString sDir, MemoryCard mc ) FileWrite( f, m_CategoryDatas[mc][st][rc].vHighScores[l].sName ); FileWrite( f, m_CategoryDatas[mc][st][rc].vHighScores[l].iScore ); + FileWrite( f, m_CategoryDatas[mc][st][rc].vHighScores[l].fPercentDP ); } } } @@ -813,6 +826,7 @@ void ProfileManager::SaveCourseScoresToDir( CString sDir, MemoryCard mc ) FileWrite( f, pCourse->m_MemCardDatas[st][mc].vHighScores[l].sName ); FileWrite( f, pCourse->m_MemCardDatas[st][mc].vHighScores[l].iScore ); + FileWrite( f, pCourse->m_MemCardDatas[st][mc].vHighScores[l].fPercentDP ); FileWrite( f, pCourse->m_MemCardDatas[st][mc].vHighScores[l].fSurviveTime ); } } @@ -1333,3 +1347,11 @@ void ProfileManager::SaveStatsWebPageToDir( CString sDir, MemoryCard mc ) CopyFile2( sStyleFile, sDir+STYLE_CSS_FILE ); } + +bool ProfileManager::CategoryData::HighScore::operator>=( const HighScore& other ) const +{ + if( PREFSMAN->m_bPercentageScoring ) + return fPercentDP >= other.fPercentDP; + else + return iScore >= other.iScore; +} diff --git a/stepmania/src/ProfileManager.h b/stepmania/src/ProfileManager.h index f45b0fadeb..daa329c621 100644 --- a/stepmania/src/ProfileManager.h +++ b/stepmania/src/ProfileManager.h @@ -98,18 +98,17 @@ public: { struct HighScore { - int iScore; CString sName; + int iScore; + float fPercentDP; HighScore() { iScore = 0; + fPercentDP = 0; } - bool operator>=( const HighScore& other ) const - { - return iScore >= other.iScore; - } + bool operator>=( const HighScore& other ) const; }; vector vHighScores; diff --git a/stepmania/src/ScreenNameEntryTraditional.cpp b/stepmania/src/ScreenNameEntryTraditional.cpp index 6af59cad70..d7cd08cac9 100644 --- a/stepmania/src/ScreenNameEntryTraditional.cpp +++ b/stepmania/src/ScreenNameEntryTraditional.cpp @@ -227,26 +227,23 @@ ScreenNameEntryTraditional::ScreenNameEntryTraditional( CString sClassName ) : S this->AddChild( &m_sprBanner[p][i] ); } - if( feat.g != GRADE_NO_DATA ) + if( feat.grade != GRADE_NO_DATA ) { m_Grade[p][i].SetName( ssprintf("GradeP%i",p+1) ); m_Grade[p][i].Load( THEME->GetPathToG("ScreenNameEntryTraditional grades") ); - m_Grade[p][i].SetGrade( (PlayerNumber)p, feat.g ); + m_Grade[p][i].SetGrade( (PlayerNumber)p, feat.grade ); SET_ON( m_Grade[p][i] ); this->AddChild( &m_Grade[p][i] ); } - if( feat.Score != 0 ) - { - m_textScore[p][i].SetName( ssprintf("ScoreP%i",p+1) ); - m_textScore[p][i].LoadFromFont( THEME->GetPathToF("ScreenNameEntryTraditional score") ); - if( PREFSMAN->m_bPercentageScoring ) - m_textScore[p][i].SetText( ssprintf("%.2f%%", feat.Score*100) ); - else - m_textScore[p][i].SetText( ssprintf("%.0f", feat.Score) ); - SET_ON( m_textScore[p][i] ); - this->AddChild( &m_textScore[p][i] ); - } + m_textScore[p][i].SetName( ssprintf("ScoreP%i",p+1) ); + m_textScore[p][i].LoadFromFont( THEME->GetPathToF("ScreenNameEntryTraditional score") ); + if( PREFSMAN->m_bPercentageScoring ) + m_textScore[p][i].SetText( ssprintf("%.2f%%", feat.fPercentDP*100) ); + else + m_textScore[p][i].SetText( ssprintf("%.0f", feat.iScore) ); + SET_ON( m_textScore[p][i] ); + this->AddChild( &m_textScore[p][i] ); if( feat.Feat != "" ) { diff --git a/stepmania/src/Steps.cpp b/stepmania/src/Steps.cpp index 4692b5cbe7..4507eba059 100644 --- a/stepmania/src/Steps.cpp +++ b/stepmania/src/Steps.cpp @@ -25,7 +25,7 @@ #include "GameManager.h" #include "NoteDataUtil.h" #include "ProfileManager.h" - +#include "PrefsManager.h" Steps::Steps() { @@ -349,7 +349,10 @@ void SortStepsByTypeAndDifficulty( vector &arraySongPointers ) bool Steps::MemCardData::HighScore::operator>=( const Steps::MemCardData::HighScore& other ) const { - return iScore >= other.iScore; + if( PREFSMAN->m_bPercentageScoring ) + return fPercentDP >= other.fPercentDP; + else + return iScore >= other.iScore; /* Make sure we treat AAAA as higher than AAA, even though the score * is the same. * @@ -391,3 +394,4 @@ void Steps::AddHighScore( PlayerNumber pn, MemCardData::HighScore hs, int &iPers iPersonalIndexOut = -1; m_MemCardDatas[MEMORY_CARD_MACHINE].AddHighScore( hs, iMachineIndexOut ); } +