mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 20:03:22 +08:00
adds new diffsetting control that shows millisecond values for approach rate override
This commit is contained in:
parent
3db0d0d341
commit
2ab11ab568
@ -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,
|
||||
|
@ -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");
|
||||
|
@ -0,0 +1,36 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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,
|
||||
}
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// A slider bar with more detailed approach rate info for its given value
|
||||
/// </summary>
|
||||
public partial class ApproachRateSlider : RoundedSliderBar<float>
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -27,9 +27,16 @@ namespace osu.Game.Rulesets.Mods
|
||||
/// When the mod is overriding a default, this will match the value of <see cref="Current"/>.
|
||||
/// When there is no override (ie. <see cref="Current"/> is null), this value will match the beatmap provided default via <see cref="updateCurrentFromSlider"/>.
|
||||
/// </remarks>
|
||||
private readonly BindableNumber<float> sliderDisplayCurrent = new BindableNumber<float>();
|
||||
protected readonly BindableNumber<float> sliderDisplayCurrent = new BindableNumber<float>();
|
||||
|
||||
protected override Drawable CreateControl() => new SliderControl(sliderDisplayCurrent);
|
||||
protected override Drawable CreateControl() => new SliderControl(sliderDisplayCurrent,
|
||||
new RoundedSliderBar<float>
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Current = sliderDisplayCurrent,
|
||||
KeyboardStep = 0.1f,
|
||||
}
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// 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<float?>
|
||||
protected partial class SliderControl : CompositeDrawable, IHasCurrentValue<float?>
|
||||
{
|
||||
// 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<float> currentNumber)
|
||||
public SliderControl(BindableNumber<float> currentNumber, RoundedSliderBar<float> slider)
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new RoundedSliderBar<float>
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Current = currentNumber,
|
||||
KeyboardStep = 0.1f,
|
||||
}
|
||||
slider
|
||||
};
|
||||
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
Loading…
Reference in New Issue
Block a user