diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs b/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs index c09e108b5a..2b11546a4b 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs @@ -1,14 +1,18 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using System.Linq; +using osu.Framework.Graphics; +using osu.Framework.Localisation; using osu.Game.Beatmaps; using osu.Game.Configuration; +using osu.Game.Graphics.UserInterface; using osu.Game.Rulesets.Mods; namespace osu.Game.Rulesets.Osu.Mods { - public class OsuModDifficultyAdjust : ModDifficultyAdjust + public partial class OsuModDifficultyAdjust : ModDifficultyAdjust { [SettingSource("Circle Size", "Override a beatmap's set CS.", FIRST_SETTING_ORDER - 1, SettingControlType = typeof(DifficultyAdjustSettingsControl))] public DifficultyBindable CircleSize { get; } = new DifficultyBindable @@ -20,7 +24,7 @@ namespace osu.Game.Rulesets.Osu.Mods ReadCurrentFromDifficulty = diff => diff.CircleSize, }; - [SettingSource("Approach Rate", "Override a beatmap's set AR.", LAST_SETTING_ORDER + 1, SettingControlType = typeof(ApproachRateDifficultyAdjustSettingsControl))] + [SettingSource("Approach Rate", "Override a beatmap's set AR.", LAST_SETTING_ORDER + 1, SettingControlType = typeof(ApproachRateSettingsControl))] public DifficultyBindable ApproachRate { get; } = new DifficultyBindable { Precision = 0.1f, @@ -54,5 +58,31 @@ namespace osu.Game.Rulesets.Osu.Mods if (CircleSize.Value != null) difficulty.CircleSize = CircleSize.Value.Value; if (ApproachRate.Value != null) difficulty.ApproachRate = ApproachRate.Value.Value; } + + private partial class ApproachRateSettingsControl : DifficultyAdjustSettingsControl + { + protected override Drawable CreateControl() => new SliderControl(SliderDisplayCurrent, + new ApproachRateSlider + { + RelativeSizeAxes = Axes.X, + Current = SliderDisplayCurrent, + KeyboardStep = 0.1f, + } + ); + + /// + /// A slider bar with more detailed approach rate info for its given value + /// + public partial class ApproachRateSlider : RoundedSliderBar + { + public override LocalisableString TooltipText => + $"{base.TooltipText} ({millisecondsFromApproachRate(Current.Value, 1.0f)} ms)"; + + private double millisecondsFromApproachRate(float value, float clockRate) + { + return Math.Round(1800 - Math.Min(value, 5) * 120 - (value >= 5 ? (value - 5) * 150 : 0) / clockRate); + } + } + } } } diff --git a/osu.Game/Rulesets/Mods/ApproachRateDifficultyAdjustSettingsControl.cs b/osu.Game/Rulesets/Mods/ApproachRateDifficultyAdjustSettingsControl.cs deleted file mode 100644 index 21cde7d8e2..0000000000 --- a/osu.Game/Rulesets/Mods/ApproachRateDifficultyAdjustSettingsControl.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using System; -using osu.Framework.Graphics; -using osu.Framework.Localisation; -using osu.Game.Graphics.UserInterface; - -namespace osu.Game.Rulesets.Mods -{ - public partial class ApproachRateDifficultyAdjustSettingsControl : DifficultyAdjustSettingsControl - { - protected override Drawable CreateControl() => new SliderControl(sliderDisplayCurrent, - new ApproachRateSlider - { - RelativeSizeAxes = Axes.X, - Current = sliderDisplayCurrent, - KeyboardStep = 0.1f, - } - ); - - /// - /// A slider bar with more detailed approach rate info for its given value - /// - public partial class ApproachRateSlider : RoundedSliderBar - { - public override LocalisableString TooltipText => - $"{base.TooltipText} ({millisecondsFromApproachRate(Current.Value, 1.0f)} ms)"; - - private double millisecondsFromApproachRate(float value, float clockRate) - { - return Math.Round(1800 - Math.Min(value, 5) * 120 - (value >= 5 ? (value - 5) * 150 : 0) / clockRate); - } - } - } -} diff --git a/osu.Game/Rulesets/Mods/DifficultyAdjustSettingsControl.cs b/osu.Game/Rulesets/Mods/DifficultyAdjustSettingsControl.cs index 62fc299c68..1e66b1966f 100644 --- a/osu.Game/Rulesets/Mods/DifficultyAdjustSettingsControl.cs +++ b/osu.Game/Rulesets/Mods/DifficultyAdjustSettingsControl.cs @@ -27,13 +27,13 @@ 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(); + protected readonly BindableNumber SliderDisplayCurrent = new BindableNumber(); - protected override Drawable CreateControl() => new SliderControl(sliderDisplayCurrent, + protected override Drawable CreateControl() => new SliderControl(SliderDisplayCurrent, new RoundedSliderBar { RelativeSizeAxes = Axes.X, - Current = sliderDisplayCurrent, + Current = SliderDisplayCurrent, KeyboardStep = 0.1f, } ); @@ -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,7 +91,7 @@ namespace osu.Game.Rulesets.Mods return; isInternalChange = true; - sliderDisplayCurrent.Value = difficultyBindable.ReadCurrentFromDifficulty(difficulty); + SliderDisplayCurrent.Value = difficultyBindable.ReadCurrentFromDifficulty(difficulty); isInternalChange = false; }