|
5 | 5 | using osu.Framework.Allocation; |
6 | 6 | using osu.Framework.Bindables; |
7 | 7 | using osu.Framework.Extensions.Color4Extensions; |
| 8 | +using osu.Framework.Extensions.LocalisationExtensions; |
8 | 9 | using osu.Framework.Graphics; |
9 | 10 | using osu.Framework.Graphics.Containers; |
10 | 11 | using osu.Framework.Graphics.Shapes; |
@@ -54,20 +55,14 @@ public float MinRange |
54 | 55 | } |
55 | 56 |
|
56 | 57 | /// <summary> |
57 | | - /// Lower bound display for when it is set to its default value. |
| 58 | + /// Lower bound display for when it is set to its default value, or null to display the value directly. |
58 | 59 | /// </summary> |
59 | | - public string DefaultStringLowerBound { get; init; } = string.Empty; |
| 60 | + public LocalisableString? DefaultStringLowerBound { get; init; } |
60 | 61 |
|
61 | 62 | /// <summary> |
62 | | - /// Upper bound display for when it is set to its default value. |
| 63 | + /// Upper bound display for when it is set to its default value, or null to display the value directly. |
63 | 64 | /// </summary> |
64 | | - public string DefaultStringUpperBound { get; init; } = string.Empty; |
65 | | - |
66 | | - public LocalisableString DefaultTooltipLowerBound { get; init; } = string.Empty; |
67 | | - |
68 | | - public LocalisableString DefaultTooltipUpperBound { get; init; } = string.Empty; |
69 | | - |
70 | | - public string TooltipSuffix { get; init; } = string.Empty; |
| 65 | + public LocalisableString? DefaultStringUpperBound { get; init; } |
71 | 66 |
|
72 | 67 | private float minRange = 0.1f; |
73 | 68 |
|
@@ -144,19 +139,15 @@ private void load(OverlayColourProvider colourProvider) |
144 | 139 | { |
145 | 140 | d.KeyboardStep = 0.1f; |
146 | 141 | d.RelativeSizeAxes = Axes.X; |
147 | | - d.TooltipSuffix = TooltipSuffix; |
148 | 142 | d.DefaultString = DefaultStringUpperBound; |
149 | | - d.DefaultTooltip = DefaultTooltipUpperBound; |
150 | 143 | d.NubWidth = NubWidth; |
151 | 144 | d.Current = upperBound; |
152 | 145 | }), |
153 | 146 | LowerBoundSlider = CreateBoundSlider(false).With(d => |
154 | 147 | { |
155 | 148 | d.KeyboardStep = 0.1f; |
156 | 149 | d.RelativeSizeAxes = Axes.X; |
157 | | - d.TooltipSuffix = TooltipSuffix; |
158 | 150 | d.DefaultString = DefaultStringLowerBound; |
159 | | - d.DefaultTooltip = DefaultTooltipLowerBound; |
160 | 151 | d.NubWidth = NubWidth; |
161 | 152 | d.Current = lowerBound; |
162 | 153 | }), |
@@ -188,14 +179,20 @@ protected partial class BoundSliderBar : ShearedSliderBar<double> |
188 | 179 |
|
189 | 180 | public new ShearedNub Nub => base.Nub; |
190 | 181 |
|
191 | | - public string? DefaultString; |
192 | | - public LocalisableString? DefaultTooltip; |
193 | | - public string? TooltipSuffix; |
| 182 | + public LocalisableString? DefaultString; |
194 | 183 |
|
195 | 184 | public float NubWidth { get; set; } = ShearedNub.HEIGHT; |
196 | 185 |
|
197 | | - public override LocalisableString TooltipText => |
198 | | - (Current.IsDefault ? DefaultTooltip : Current.Value.ToString($@"0.## {TooltipSuffix}")) ?? Current.Value.ToString($@"0.## {TooltipSuffix}"); |
| 186 | + public override LocalisableString TooltipText |
| 187 | + { |
| 188 | + get |
| 189 | + { |
| 190 | + if (Current.IsDefault) |
| 191 | + return string.Empty; |
| 192 | + |
| 193 | + return Current.Value.ToLocalisableString(@"N1"); |
| 194 | + } |
| 195 | + } |
199 | 196 |
|
200 | 197 | protected OsuSpriteText NubText { get; private set; } = null!; |
201 | 198 |
|
@@ -245,8 +242,10 @@ protected override void LoadComplete() |
245 | 242 |
|
246 | 243 | protected virtual void UpdateDisplay(double value) |
247 | 244 | { |
248 | | - string defaultString = DefaultString ?? value.ToString("N1"); |
249 | | - NubText.Text = Current.IsDefault ? defaultString : value.ToString("N1"); |
| 245 | + if (Current.IsDefault && DefaultString != null) |
| 246 | + NubText.Text = DefaultString.Value; |
| 247 | + else |
| 248 | + NubText.Text = value.ToLocalisableString(@"N1"); |
250 | 249 | } |
251 | 250 |
|
252 | 251 | public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) |
|
0 commit comments