diff --git a/osu.Game/Rulesets/Mods/DifficultyAdjustSettingsControl.cs b/osu.Game/Rulesets/Mods/DifficultyAdjustSettingsControl.cs index ef2b88846a..05a36d3d31 100644 --- a/osu.Game/Rulesets/Mods/DifficultyAdjustSettingsControl.cs +++ b/osu.Game/Rulesets/Mods/DifficultyAdjustSettingsControl.cs @@ -16,9 +16,13 @@ namespace osu.Game.Rulesets.Mods [Resolved] private IBindable beatmap { get; set; } - protected readonly BindableNumber CurrentNumber = new BindableNumber(); + /// + /// Used to track the display value on the setting slider. + /// This can either be a user override or the beatmap default (when is null). + /// + private readonly BindableNumber displayNumber = new BindableNumber(); - protected override Drawable CreateControl() => new ControlDrawable(CurrentNumber); + protected override Drawable CreateControl() => new ControlDrawable(displayNumber); private bool isInternalChange; @@ -31,7 +35,10 @@ namespace osu.Game.Rulesets.Mods { // intercept and extract the DifficultyBindable. difficultyBindable = (DifficultyBindable)value; - CurrentNumber.BindTo(difficultyBindable.CurrentNumber); + + // this bind is used to transfer bounds/precision only. + displayNumber.BindTo(difficultyBindable.CurrentNumber); + base.Current = value; } } @@ -40,18 +47,18 @@ namespace osu.Game.Rulesets.Mods { base.LoadComplete(); - beatmap.BindValueChanged(b => - { - updateFromDifficulty(); - }, true); + beatmap.BindValueChanged(b => updateFromDifficulty(), true); Current.BindValueChanged(current => { + // the user override has changed; transfer the correct value to the visual display. if (current.NewValue == null) updateFromDifficulty(); + else + displayNumber.Value = current.NewValue.Value; }); - CurrentNumber.BindValueChanged(number => + displayNumber.BindValueChanged(number => { if (!isInternalChange) Current.Value = number.NewValue; @@ -67,8 +74,9 @@ namespace osu.Game.Rulesets.Mods if (Current.Value == null) { + // ensure the beatmap's value is not transferred as a user override. isInternalChange = true; - CurrentNumber.Value = difficultyBindable.ReadFromDifficulty(difficulty); + displayNumber.Value = difficultyBindable.ReadFromDifficulty(difficulty); isInternalChange = false; } } @@ -77,6 +85,8 @@ namespace osu.Game.Rulesets.Mods { private readonly BindableWithCurrent current = new BindableWithCurrent(); + // Mainly just for fulfilling the interface requirements. + // The actual update flow is done via the provided number. public Bindable Current { get => current.Current;