mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
Track changes to mod settings in beatmap difficulty cache with 100ms debouncing
This commit is contained in:
parent
0291cd5ae2
commit
32ba525555
@ -14,6 +14,7 @@ using osu.Framework.Lists;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
@ -56,12 +57,28 @@ namespace osu.Game.Beatmaps
|
||||
[Resolved]
|
||||
private Bindable<IReadOnlyList<Mod>> currentMods { get; set; }
|
||||
|
||||
private ModSettingChangeTracker modSettingChangeTracker;
|
||||
private ScheduledDelegate debouncedModSettingsChange;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
currentRuleset.BindValueChanged(_ => updateTrackedBindables());
|
||||
currentMods.BindValueChanged(_ => updateTrackedBindables(), true);
|
||||
|
||||
currentMods.BindValueChanged(mods =>
|
||||
{
|
||||
modSettingChangeTracker?.Dispose();
|
||||
|
||||
updateTrackedBindables();
|
||||
|
||||
modSettingChangeTracker = new ModSettingChangeTracker(mods.NewValue);
|
||||
modSettingChangeTracker.SettingChanged += _ =>
|
||||
{
|
||||
debouncedModSettingsChange?.Cancel();
|
||||
debouncedModSettingsChange = Scheduler.AddDelayed(updateTrackedBindables, 100);
|
||||
};
|
||||
}, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -84,7 +101,7 @@ namespace osu.Game.Beatmaps
|
||||
/// Retrieves a bindable containing the star difficulty of a <see cref="BeatmapInfo"/> with a given <see cref="RulesetInfo"/> and <see cref="Mod"/> combination.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The bindable will not update to follow the currently-selected ruleset and mods.
|
||||
/// The bindable will not update to follow the currently-selected ruleset and mods or its settings.
|
||||
/// </remarks>
|
||||
/// <param name="beatmapInfo">The <see cref="BeatmapInfo"/> to get the difficulty of.</param>
|
||||
/// <param name="rulesetInfo">The <see cref="RulesetInfo"/> to get the difficulty with. If <c>null</c>, the <paramref name="beatmapInfo"/>'s ruleset is used.</param>
|
||||
@ -275,6 +292,8 @@ namespace osu.Game.Beatmaps
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
modSettingChangeTracker?.Dispose();
|
||||
|
||||
cancelTrackedBindableUpdate();
|
||||
updateScheduler?.Dispose();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user