1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-05 16:02:56 +08:00

Allow external use of offset text explanation

This commit is contained in:
Dean Herbert 2023-12-23 20:46:12 +09:00
parent 27a9dcc5a1
commit 7e9522a722
No known key found for this signature in database

View File

@ -233,12 +233,10 @@ namespace osu.Game.Screens.Play.PlayerSettings
{ {
case GlobalAction.IncreaseOffset: case GlobalAction.IncreaseOffset:
Current.Value += amount; Current.Value += amount;
return true; return true;
case GlobalAction.DecreaseOffset: case GlobalAction.DecreaseOffset:
Current.Value -= amount; Current.Value -= amount;
return true; return true;
} }
@ -249,25 +247,29 @@ namespace osu.Game.Screens.Play.PlayerSettings
{ {
} }
public static LocalisableString GetOffsetExplanatoryText(double offset)
{
return offset == 0
? LocalisableString.Interpolate($@"{offset:0.0} ms")
: LocalisableString.Interpolate($@"{offset:0.0} ms {getEarlyLateText(offset)}");
LocalisableString getEarlyLateText(double value)
{
Debug.Assert(value != 0);
return value > 0
? BeatmapOffsetControlStrings.HitObjectsAppearEarlier
: BeatmapOffsetControlStrings.HitObjectsAppearLater;
}
}
public partial class OffsetSliderBar : PlayerSliderBar<double> public partial class OffsetSliderBar : PlayerSliderBar<double>
{ {
protected override Drawable CreateControl() => new CustomSliderBar(); protected override Drawable CreateControl() => new CustomSliderBar();
protected partial class CustomSliderBar : SliderBar protected partial class CustomSliderBar : SliderBar
{ {
public override LocalisableString TooltipText => public override LocalisableString TooltipText => GetOffsetExplanatoryText(Current.Value);
Current.Value == 0
? LocalisableString.Interpolate($@"{base.TooltipText} ms")
: LocalisableString.Interpolate($@"{base.TooltipText} ms {getEarlyLateText(Current.Value)}");
private LocalisableString getEarlyLateText(double value)
{
Debug.Assert(value != 0);
return value > 0
? BeatmapOffsetControlStrings.HitObjectsAppearEarlier
: BeatmapOffsetControlStrings.HitObjectsAppearLater;
}
} }
} }
} }