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 1 commit
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
5 changes: 5 additions & 0 deletions PerformanceCalculatorGUI/Screens/SimulateScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,11 @@ protected override void Dispose(bool isDisposing)

private void modsChanged(ValueChangedEvent<IReadOnlyList<Mod>> mods)
{
// 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.Count == mods.NewValue.Count)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't that disable recalculation when you're change mod settings?

Copy link
Contributor Author

@minisbett minisbett Oct 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mod settings are unaffected, they are being tracked by a separate piece of code.

modSettingChangeTracker = new ModSettingChangeTracker(mods.NewValue);
modSettingChangeTracker.SettingChanged += m =>
{
debouncedStatisticsUpdate?.Cancel();
debouncedStatisticsUpdate = Scheduler.AddDelayed(() =>
{
calculateDifficulty();
calculatePerformance();
}, 100);
};

minisbett marked this conversation as resolved.
Show resolved Hide resolved
return;

modSettingChangeTracker?.Dispose();

if (working is null)
Expand Down
Loading