diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs b/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs index 2b11546a4b..933771321c 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs @@ -3,6 +3,7 @@ using System; using System.Linq; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Localisation; using osu.Game.Beatmaps; @@ -61,14 +62,13 @@ namespace osu.Game.Rulesets.Osu.Mods private partial class ApproachRateSettingsControl : DifficultyAdjustSettingsControl { - protected override Drawable CreateControl() => new SliderControl(SliderDisplayCurrent, + protected override RoundedSliderBar CreateSlider(BindableNumber current) => new ApproachRateSlider { RelativeSizeAxes = Axes.X, - Current = SliderDisplayCurrent, + Current = current, KeyboardStep = 0.1f, - } - ); + }; /// /// A slider bar with more detailed approach rate info for its given value diff --git a/osu.Game/Rulesets/Mods/DifficultyAdjustSettingsControl.cs b/osu.Game/Rulesets/Mods/DifficultyAdjustSettingsControl.cs index 1e66b1966f..d04d7636ec 100644 --- a/osu.Game/Rulesets/Mods/DifficultyAdjustSettingsControl.cs +++ b/osu.Game/Rulesets/Mods/DifficultyAdjustSettingsControl.cs @@ -27,16 +27,16 @@ namespace osu.Game.Rulesets.Mods /// When the mod is overriding a default, this will match the value of . /// When there is no override (ie. is null), this value will match the beatmap provided default via . /// - protected readonly BindableNumber SliderDisplayCurrent = new BindableNumber(); + private readonly BindableNumber sliderDisplayCurrent = new BindableNumber(); - protected override Drawable CreateControl() => new SliderControl(SliderDisplayCurrent, - new RoundedSliderBar - { - RelativeSizeAxes = Axes.X, - Current = SliderDisplayCurrent, - KeyboardStep = 0.1f, - } - ); + protected sealed override Drawable CreateControl() => new SliderControl(sliderDisplayCurrent, CreateSlider); + + protected virtual RoundedSliderBar CreateSlider(BindableNumber current) => new RoundedSliderBar + { + RelativeSizeAxes = Axes.X, + Current = current, + KeyboardStep = 0.1f, + }; /// /// Guards against beatmap values displayed on slider bars being transferred to user override. @@ -53,7 +53,7 @@ namespace osu.Game.Rulesets.Mods // Intercept and extract the internal number bindable from DifficultyBindable. // This will provide bounds and precision specifications for the slider bar. difficultyBindable = (DifficultyBindable)value.GetBoundCopy(); - SliderDisplayCurrent.BindTo(difficultyBindable.CurrentNumber); + sliderDisplayCurrent.BindTo(difficultyBindable.CurrentNumber); base.Current = difficultyBindable; } @@ -66,7 +66,7 @@ namespace osu.Game.Rulesets.Mods Current.BindValueChanged(_ => updateCurrentFromSlider()); beatmap.BindValueChanged(_ => updateCurrentFromSlider(), true); - SliderDisplayCurrent.BindValueChanged(number => + sliderDisplayCurrent.BindValueChanged(number => { // this handles the transfer of the slider value to the main bindable. // as such, should be skipped if the slider is being updated via updateFromDifficulty(). @@ -80,7 +80,7 @@ namespace osu.Game.Rulesets.Mods if (Current.Value != null) { // a user override has been added or updated. - SliderDisplayCurrent.Value = Current.Value.Value; + sliderDisplayCurrent.Value = Current.Value.Value; return; } @@ -91,11 +91,11 @@ namespace osu.Game.Rulesets.Mods return; isInternalChange = true; - SliderDisplayCurrent.Value = difficultyBindable.ReadCurrentFromDifficulty(difficulty); + sliderDisplayCurrent.Value = difficultyBindable.ReadCurrentFromDifficulty(difficulty); isInternalChange = false; } - protected partial class SliderControl : CompositeDrawable, IHasCurrentValue + private partial class SliderControl : CompositeDrawable, IHasCurrentValue { // This is required as SettingsItem relies heavily on this bindable for internal use. // The actual update flow is done via the bindable provided in the constructor. @@ -107,11 +107,11 @@ namespace osu.Game.Rulesets.Mods set => current.Current = value; } - public SliderControl(BindableNumber currentNumber, RoundedSliderBar slider) + public SliderControl(BindableNumber currentNumber, Func, RoundedSliderBar> createSlider) { InternalChildren = new Drawable[] { - slider + createSlider(currentNumber) }; AutoSizeAxes = Axes.Y;