mirror of
https://github.com/ppy/osu.git
synced 2025-03-21 16:37:18 +08:00
Merge pull request #1856 from smoogipoo/sliderbar-tooltip-precision
Fix up replay playback speed slider having a different tooltip than the displayed number
This commit is contained in:
commit
2a0a0e3b48
@ -1 +1 @@
|
||||
Subproject commit a6090d3f6f03eaf9a3f643cf1ef3db96384c62ff
|
||||
Subproject commit 49b563e2cf170eb19006b98dd5b69c2398362d9e
|
@ -2,6 +2,7 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
@ -17,7 +18,7 @@ using osu.Framework.Graphics.Shapes;
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class OsuSliderBar<T> : SliderBar<T>, IHasTooltip, IHasAccentColour
|
||||
where T : struct, IEquatable<T>
|
||||
where T : struct, IEquatable<T>, IComparable, IConvertible
|
||||
{
|
||||
private SampleChannel sample;
|
||||
private double lastSampleTime;
|
||||
@ -32,18 +33,25 @@ namespace osu.Game.Graphics.UserInterface
|
||||
get
|
||||
{
|
||||
var bindableDouble = CurrentNumber as BindableNumber<double>;
|
||||
if (bindableDouble != null)
|
||||
var bindableFloat = CurrentNumber as BindableNumber<float>;
|
||||
var floatValue = bindableDouble?.Value ?? bindableFloat?.Value;
|
||||
|
||||
if (floatValue != null)
|
||||
{
|
||||
if (bindableDouble.MaxValue == 1 && (bindableDouble.MinValue == 0 || bindableDouble.MinValue == -1))
|
||||
return bindableDouble.Value.ToString(@"P0");
|
||||
return bindableDouble.Value.ToString(@"n1");
|
||||
var floatMinValue = bindableDouble?.MinValue ?? bindableFloat.MinValue;
|
||||
var floatMaxValue = bindableDouble?.MaxValue ?? bindableFloat.MaxValue;
|
||||
|
||||
if (floatMaxValue == 1 && (floatMinValue == 0 || floatMinValue == -1))
|
||||
return floatValue.Value.ToString("P0");
|
||||
|
||||
return floatValue.Value.ToString("N1");
|
||||
}
|
||||
|
||||
var bindableInt = CurrentNumber as BindableNumber<int>;
|
||||
if (bindableInt != null)
|
||||
return bindableInt.Value.ToString(@"n0");
|
||||
return bindableInt.Value.ToString("N0");
|
||||
|
||||
return Current.Value.ToString();
|
||||
return Current.Value.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,19 +4,18 @@
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
public class SettingsSlider<T> : SettingsSlider<T, OsuSliderBar<T>>
|
||||
where T : struct, IEquatable<T>
|
||||
where T : struct, IEquatable<T>, IComparable, IConvertible
|
||||
{
|
||||
}
|
||||
|
||||
public class SettingsSlider<T, U> : SettingsItem<T>
|
||||
where T : struct, IEquatable<T>
|
||||
where U : SliderBar<T>, new()
|
||||
where T : struct, IEquatable<T>, IComparable, IConvertible
|
||||
where U : OsuSliderBar<T>, new()
|
||||
{
|
||||
protected override Drawable CreateControl() => new U
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ using osu.Game.Overlays.Settings;
|
||||
namespace osu.Game.Screens.Play.ReplaySettings
|
||||
{
|
||||
public class ReplaySliderBar<T> : SettingsSlider<T>
|
||||
where T : struct, IEquatable<T>
|
||||
where T : struct, IEquatable<T>, IComparable, IConvertible
|
||||
{
|
||||
protected override Drawable CreateControl() => new Sliderbar
|
||||
{
|
||||
@ -21,6 +21,8 @@ namespace osu.Game.Screens.Play.ReplaySettings
|
||||
|
||||
private class Sliderbar : OsuSliderBar<T>
|
||||
{
|
||||
public override string TooltipText => $"{CurrentNumber.Value}";
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user