diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs b/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs index 5eb41ff189..c09e108b5a 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs @@ -20,7 +20,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(DifficultyAdjustSettingsControl))] + [SettingSource("Approach Rate", "Override a beatmap's set AR.", LAST_SETTING_ORDER + 1, SettingControlType = typeof(ApproachRateDifficultyAdjustSettingsControl))] public DifficultyBindable ApproachRate { get; } = new DifficultyBindable { Precision = 0.1f, diff --git a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs index e5f5f97eb7..cf3cb3b734 100644 --- a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs +++ b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs @@ -82,7 +82,7 @@ namespace osu.Game.Graphics.UserInterface channel.Play(); } - private LocalisableString getTooltipText(T value) + protected LocalisableString getTooltipText(T value) { if (CurrentNumber.IsInteger) return value.ToInt32(NumberFormatInfo.InvariantInfo).ToString("N0"); diff --git a/osu.Game/Rulesets/Mods/ApproachRateDifficultyAdjustSettingsControl.cs b/osu.Game/Rulesets/Mods/ApproachRateDifficultyAdjustSettingsControl.cs new file mode 100644 index 0000000000..21cde7d8e2 --- /dev/null +++ b/osu.Game/Rulesets/Mods/ApproachRateDifficultyAdjustSettingsControl.cs @@ -0,0 +1,36 @@ +// 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 a941c0a1db..62fc299c68 100644 --- a/osu.Game/Rulesets/Mods/DifficultyAdjustSettingsControl.cs +++ b/osu.Game/Rulesets/Mods/DifficultyAdjustSettingsControl.cs @@ -27,9 +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 . /// - private 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, + KeyboardStep = 0.1f, + } + ); /// /// Guards against beatmap values displayed on slider bars being transferred to user override. @@ -88,7 +95,7 @@ namespace osu.Game.Rulesets.Mods isInternalChange = false; } - private partial class SliderControl : CompositeDrawable, IHasCurrentValue + protected 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. @@ -100,16 +107,11 @@ namespace osu.Game.Rulesets.Mods set => current.Current = value; } - public SliderControl(BindableNumber currentNumber) + public SliderControl(BindableNumber currentNumber, RoundedSliderBar slider) { InternalChildren = new Drawable[] { - new RoundedSliderBar - { - RelativeSizeAxes = Axes.X, - Current = currentNumber, - KeyboardStep = 0.1f, - } + slider }; AutoSizeAxes = Axes.Y;