Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix duplicate difficulty & performance calculation when changing mods #222

Merged
merged 4 commits into from
Oct 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions PerformanceCalculatorGUI/Screens/SimulateScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -524,23 +524,10 @@ protected override void Dispose(bool isDisposing)

private void modsChanged(ValueChangedEvent<IReadOnlyList<Mod>> mods)
{
void updateMissesTextboxes()
{
if (ruleset.Value.ShortName == "osu")
{
// Large tick misses and slider tail misses are only relevant in PP if slider head accuracy exists
if (mods.NewValue.OfType<OsuModClassic>().Any(m => m.NoSliderHeadAccuracy.Value))
{
missesContainer.Content = new[] { new[] { missesTextBox } };
missesContainer.ColumnDimensions = [new Dimension()];
}
else
{
missesContainer.Content = new[] { new[] { missesTextBox, largeTickMissesTextBox, sliderTailMissesTextBox } };
missesContainer.ColumnDimensions = [new Dimension(), new Dimension(), new Dimension()];
}
}
}
// Hotfix for preventing a difficulty and performance calculation from being trigger twice,
// as the mod overlay for some reason triggers a ValueChanged twice per mod change.
if (mods.OldValue.SequenceEqual(mods.NewValue))
return;

modSettingChangeTracker?.Dispose();

Expand All @@ -564,6 +551,24 @@ void updateMissesTextboxes()
calculateDifficulty();
updateCombo(false);
calculatePerformance();

void updateMissesTextboxes()
{
if (ruleset.Value.ShortName == "osu")
{
// Large tick misses and slider tail misses are only relevant in PP if slider head accuracy exists
if (mods.NewValue.OfType<OsuModClassic>().Any(m => m.NoSliderHeadAccuracy.Value))
{
missesContainer.Content = new[] { new[] { missesTextBox } };
missesContainer.ColumnDimensions = [new Dimension()];
}
else
{
missesContainer.Content = new[] { new[] { missesTextBox, largeTickMissesTextBox, sliderTailMissesTextBox } };
missesContainer.ColumnDimensions = [new Dimension(), new Dimension(), new Dimension()];
}
}
}
}

private void resetBeatmap()
Expand Down Expand Up @@ -697,7 +702,8 @@ private void calculatePerformance()
if (ruleset.Value.OnlineID != -1)
{
// official rulesets can generate more precise hits from accuracy
statistics = RulesetHelper.GenerateHitResultsForRuleset(ruleset.Value, accuracyTextBox.Value.Value / 100.0, beatmap, missesTextBox.Value.Value, countMeh, countGood, largeTickMissesTextBox.Value.Value, sliderTailMissesTextBox.Value.Value);
statistics = RulesetHelper.GenerateHitResultsForRuleset(ruleset.Value, accuracyTextBox.Value.Value / 100.0, beatmap, missesTextBox.Value.Value, countMeh, countGood,
largeTickMissesTextBox.Value.Value, sliderTailMissesTextBox.Value.Value);

accuracy = RulesetHelper.GetAccuracyForRuleset(ruleset.Value, statistics);
}
Expand Down
Loading