1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-28 03:07:19 +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:
Dean Herbert 2018-01-12 19:08:50 +09:00 committed by GitHub
commit 2a0a0e3b48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 13 deletions

@ -1 +1 @@
Subproject commit a6090d3f6f03eaf9a3f643cf1ef3db96384c62ff Subproject commit 49b563e2cf170eb19006b98dd5b69c2398362d9e

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System; using System;
using System.Globalization;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Allocation; using osu.Framework.Allocation;
@ -17,7 +18,7 @@ using osu.Framework.Graphics.Shapes;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {
public class OsuSliderBar<T> : SliderBar<T>, IHasTooltip, IHasAccentColour public class OsuSliderBar<T> : SliderBar<T>, IHasTooltip, IHasAccentColour
where T : struct, IEquatable<T> where T : struct, IEquatable<T>, IComparable, IConvertible
{ {
private SampleChannel sample; private SampleChannel sample;
private double lastSampleTime; private double lastSampleTime;
@ -32,18 +33,25 @@ namespace osu.Game.Graphics.UserInterface
get get
{ {
var bindableDouble = CurrentNumber as BindableNumber<double>; 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)) var floatMinValue = bindableDouble?.MinValue ?? bindableFloat.MinValue;
return bindableDouble.Value.ToString(@"P0"); var floatMaxValue = bindableDouble?.MaxValue ?? bindableFloat.MaxValue;
return bindableDouble.Value.ToString(@"n1");
if (floatMaxValue == 1 && (floatMinValue == 0 || floatMinValue == -1))
return floatValue.Value.ToString("P0");
return floatValue.Value.ToString("N1");
} }
var bindableInt = CurrentNumber as BindableNumber<int>; var bindableInt = CurrentNumber as BindableNumber<int>;
if (bindableInt != null) if (bindableInt != null)
return bindableInt.Value.ToString(@"n0"); return bindableInt.Value.ToString("N0");
return Current.Value.ToString(); return Current.Value.ToString(CultureInfo.InvariantCulture);
} }
} }

View File

@ -4,19 +4,18 @@
using System; using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Settings namespace osu.Game.Overlays.Settings
{ {
public class SettingsSlider<T> : SettingsSlider<T, OsuSliderBar<T>> 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> public class SettingsSlider<T, U> : SettingsItem<T>
where T : struct, IEquatable<T> where T : struct, IEquatable<T>, IComparable, IConvertible
where U : SliderBar<T>, new() where U : OsuSliderBar<T>, new()
{ {
protected override Drawable CreateControl() => new U protected override Drawable CreateControl() => new U
{ {

View File

@ -11,7 +11,7 @@ using osu.Game.Overlays.Settings;
namespace osu.Game.Screens.Play.ReplaySettings namespace osu.Game.Screens.Play.ReplaySettings
{ {
public class ReplaySliderBar<T> : SettingsSlider<T> public class ReplaySliderBar<T> : SettingsSlider<T>
where T : struct, IEquatable<T> where T : struct, IEquatable<T>, IComparable, IConvertible
{ {
protected override Drawable CreateControl() => new Sliderbar protected override Drawable CreateControl() => new Sliderbar
{ {
@ -21,6 +21,8 @@ namespace osu.Game.Screens.Play.ReplaySettings
private class Sliderbar : OsuSliderBar<T> private class Sliderbar : OsuSliderBar<T>
{ {
public override string TooltipText => $"{CurrentNumber.Value}";
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {