Skip to content

Commit

Permalink
Merge pull request #222 from minisbett/fix-duplicate-calculations
Browse files Browse the repository at this point in the history
fix duplicate difficulty & performance calculation when changing mods
  • Loading branch information
smoogipoo authored Oct 23, 2024
2 parents 27dbd33 + ca6ede4 commit 156867c
Showing 1 changed file with 24 additions and 18 deletions.
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

0 comments on commit 156867c

Please sign in to comment.