Skip to content

Commit

Permalink
fix musicwheel setting grades for filtered difficulties on wheel
Browse files Browse the repository at this point in the history
  • Loading branch information
poco0317 committed Nov 6, 2021
1 parent c3747c6 commit a341052
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions src/Etterna/Actor/Menus/MusicWheelItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,23 +314,38 @@ MusicWheelItem::RefreshGrades()
Difficulty dcBest = Difficulty_Invalid;
if (pWID->m_pSong != nullptr) {
bool hasCurrentStyleSteps = false;
auto& allSteps = pWID->m_pSong->GetChartsMatchingFilter();
std::unordered_map<Difficulty, std::vector<Steps*>> difficultyToSteps{
NUM_Difficulty
};
for (auto& s : allSteps) {
auto d = s->GetDifficulty();
if (difficultyToSteps.count(d) == 0u) {
std::vector<Steps*> v;
difficultyToSteps[d] = v;
}
difficultyToSteps[d].push_back(s);
}
FOREACH_ENUM_N(Difficulty, 6, i)
{
Steps* pSteps =
SongUtil::GetStepsByDifficulty(pWID->m_pSong, st, i);
if (pSteps != nullptr) {
hasCurrentStyleSteps = true;
Grade dcg = SCOREMAN->GetBestGradeFor(pSteps->GetChartKey());
if (gradeBest >= dcg) {
dcBest = i;
gradeBest = dcg;
if (difficultyToSteps.count(i) == 0u)
continue;
auto& stepslist = difficultyToSteps[i];
for (auto& s : stepslist) {
if (s->m_StepsType == st) {
hasCurrentStyleSteps = true;
Grade dcg =
SCOREMAN->GetBestGradeFor(s->GetChartKey());
if (gradeBest >= dcg) {
dcBest = i;
gradeBest = dcg;
}
}
}
}
// If no grade was found for the current style/stepstype
if (!hasCurrentStyleSteps) {
// Get the best grade among all steps
auto& allSteps = pWID->m_pSong->GetAllSteps();
for (auto& stepsPtr : allSteps) {
if (stepsPtr->m_StepsType ==
st) // Skip already checked steps of type st
Expand Down

0 comments on commit a341052

Please sign in to comment.