diff --git a/src/MusicWheelItem.cpp b/src/MusicWheelItem.cpp index a3c3d09550..be069e6269 100644 --- a/src/MusicWheelItem.cpp +++ b/src/MusicWheelItem.cpp @@ -345,40 +345,48 @@ void MusicWheelItem::RefreshGrades() Profile *pProfile = PROFILEMAN->GetProfile(ps); - HighScoreList *pHSL = NULL; - /* quick hack to make the highest grade for any difficulty show up, + /* Quick hack to make the highest grade for any difficulty show up, should make optional later, also should make it descend through the difficulties and stop once a valid grade has been hit - Mina*/ - Grade agP; + + HighScoreList *pHSL = NULL; + HighScoreList *BestpHSL = NULL; + Difficulty dcBest = Difficulty_Invalid; if( PROFILEMAN->IsPersistentProfile(ps) && dc != Difficulty_Invalid ) { if (pWID->m_pSong) { - FOREACH_ENUM(Difficulty, i) { + FOREACH_ENUM_N(Difficulty, 6, i) { Steps* pSteps = SongUtil::GetStepsByDifficulty(pWID->m_pSong, st, i); if (pSteps != NULL) { pHSL = &pProfile->GetStepsHighScoreList(pWID->m_pSong, pSteps); - Grade ag = pHSL->HighGrade; - agP = min(ag,agP); + + if (BestpHSL == NULL) + BestpHSL = pHSL; + + if (static_cast(BestpHSL->HighGrade) >= static_cast(pHSL->HighGrade)) { + dcBest = i; + BestpHSL = pHSL; + } } } } - else if( pWID->m_pCourse ) { const Trail *pTrail = pWID->m_pCourse->GetTrail( st, dc ); if( pTrail != NULL ) - pHSL = &pProfile->GetCourseHighScoreList( pWID->m_pCourse, pTrail ); + BestpHSL = &pProfile->GetCourseHighScoreList( pWID->m_pCourse, pTrail ); } } Message msg( "SetGrade" ); msg.SetParam( "PlayerNumber", p ); - if( pHSL ) + if( BestpHSL ) { - msg.SetParam( "Grade", agP ); - msg.SetParam( "NumTimesPlayed", pHSL->GetNumTimesPlayed() ); + msg.SetParam( "Grade", BestpHSL->HighGrade); + msg.SetParam( "Difficulty", DifficultyToString(dcBest)); + msg.SetParam( "NumTimesPlayed", BestpHSL->GetNumTimesPlayed() ); } m_pGradeDisplay[p]->HandleMessage( msg ); }