mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 14:12:56 +08:00
Merge pull request #17073 from peppy/add-offset-adjust-tooltip-text
Add tooltip text for offset adjustment slider
This commit is contained in:
commit
faddc20dca
@ -148,7 +148,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
CurrentNumber.BindValueChanged(current => updateTooltipText(current.NewValue), true);
|
CurrentNumber.BindValueChanged(current => TooltipText = getTooltipText(current.NewValue), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
@ -178,7 +178,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
{
|
{
|
||||||
base.OnUserChange(value);
|
base.OnUserChange(value);
|
||||||
playSample(value);
|
playSample(value);
|
||||||
updateTooltipText(value);
|
TooltipText = getTooltipText(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void playSample(T value)
|
private void playSample(T value)
|
||||||
@ -203,28 +203,22 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
channel.Play();
|
channel.Play();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateTooltipText(T value)
|
private LocalisableString getTooltipText(T value)
|
||||||
{
|
{
|
||||||
if (CurrentNumber.IsInteger)
|
if (CurrentNumber.IsInteger)
|
||||||
TooltipText = value.ToInt32(NumberFormatInfo.InvariantInfo).ToString("N0");
|
return value.ToInt32(NumberFormatInfo.InvariantInfo).ToString("N0");
|
||||||
else
|
|
||||||
{
|
|
||||||
double floatValue = value.ToDouble(NumberFormatInfo.InvariantInfo);
|
|
||||||
|
|
||||||
if (DisplayAsPercentage)
|
double floatValue = value.ToDouble(NumberFormatInfo.InvariantInfo);
|
||||||
{
|
|
||||||
TooltipText = floatValue.ToString("0%");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
decimal decimalPrecision = normalise(CurrentNumber.Precision.ToDecimal(NumberFormatInfo.InvariantInfo), max_decimal_digits);
|
|
||||||
|
|
||||||
// Find the number of significant digits (we could have less than 5 after normalize())
|
if (DisplayAsPercentage)
|
||||||
int significantDigits = FormatUtils.FindPrecision(decimalPrecision);
|
return floatValue.ToString("0%");
|
||||||
|
|
||||||
TooltipText = floatValue.ToString($"N{significantDigits}");
|
decimal decimalPrecision = normalise(CurrentNumber.Precision.ToDecimal(NumberFormatInfo.InvariantInfo), max_decimal_digits);
|
||||||
}
|
|
||||||
}
|
// Find the number of significant digits (we could have less than 5 after normalize())
|
||||||
|
int significantDigits = FormatUtils.FindPrecision(decimalPrecision);
|
||||||
|
|
||||||
|
return floatValue.ToString($"N{significantDigits}");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateAfterChildren()
|
protected override void UpdateAfterChildren()
|
||||||
|
@ -29,6 +29,16 @@ namespace osu.Game.Localisation
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static LocalisableString CalibrateUsingLastPlay => new TranslatableString(getKey(@"calibrate_using_last_play"), @"Calibrate using last play");
|
public static LocalisableString CalibrateUsingLastPlay => new TranslatableString(getKey(@"calibrate_using_last_play"), @"Calibrate using last play");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "(hit objects appear later)"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString HitObjectsAppearLater => new TranslatableString(getKey(@"hit_objects_appear_later"), @"(hit objects appear later)");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "(hit objects appear earlier)"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString HitObjectsAppearEarlier => new TranslatableString(getKey(@"hit_objects_appear_earlier"), @"(hit objects appear earlier)");
|
||||||
|
|
||||||
private static string getKey(string key) => $@"{prefix}:{key}";
|
private static string getKey(string key) => $@"{prefix}:{key}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,14 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Localisation;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
@ -72,7 +74,7 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
|||||||
Spacing = new Vector2(10),
|
Spacing = new Vector2(10),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new PlayerSliderBar<double>
|
new OffsetSliderBar
|
||||||
{
|
{
|
||||||
KeyboardStep = 5,
|
KeyboardStep = 5,
|
||||||
LabelText = BeatmapOffsetControlStrings.BeatmapOffset,
|
LabelText = BeatmapOffsetControlStrings.BeatmapOffset,
|
||||||
@ -89,6 +91,28 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class OffsetSliderBar : PlayerSliderBar<double>
|
||||||
|
{
|
||||||
|
protected override Drawable CreateControl() => new CustomSliderBar();
|
||||||
|
|
||||||
|
protected class CustomSliderBar : SliderBar
|
||||||
|
{
|
||||||
|
public override LocalisableString TooltipText =>
|
||||||
|
Current.Value == 0
|
||||||
|
? new TranslatableString("_", @"{0} ms", base.TooltipText)
|
||||||
|
: new TranslatableString("_", @"{0} ms {1}", base.TooltipText, getEarlyLateText(Current.Value));
|
||||||
|
|
||||||
|
private LocalisableString getEarlyLateText(double value)
|
||||||
|
{
|
||||||
|
Debug.Assert(value != 0);
|
||||||
|
|
||||||
|
return value > 0
|
||||||
|
? BeatmapOffsetControlStrings.HitObjectsAppearLater
|
||||||
|
: BeatmapOffsetControlStrings.HitObjectsAppearEarlier;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
@ -15,13 +15,15 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
|||||||
{
|
{
|
||||||
public OsuSliderBar<T> Bar => (OsuSliderBar<T>)Control;
|
public OsuSliderBar<T> Bar => (OsuSliderBar<T>)Control;
|
||||||
|
|
||||||
protected override Drawable CreateControl() => new SliderBar
|
protected override Drawable CreateControl() => new SliderBar();
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X
|
|
||||||
};
|
|
||||||
|
|
||||||
private class SliderBar : OsuSliderBar<T>
|
protected class SliderBar : OsuSliderBar<T>
|
||||||
{
|
{
|
||||||
|
public SliderBar()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user