1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 17:57:29 +08:00

Fix improper handling of decimal separator in "form" number boxes / sliders

Spotted in passing in
https://discord.com/channels/188630481301012481/1097318920991559880/1291693852981329981.
This commit is contained in:
Bartłomiej Dach 2024-10-04 13:12:25 +02:00
parent 4fc0aae486
commit 45a6a743a2
No known key found for this signature in database
2 changed files with 13 additions and 4 deletions

View File

@ -1,6 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.Globalization;
namespace osu.Game.Graphics.UserInterfaceV2 namespace osu.Game.Graphics.UserInterfaceV2
{ {
public partial class FormNumberBox : FormTextBox public partial class FormNumberBox : FormTextBox
@ -18,7 +20,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
public bool AllowDecimals { get; init; } public bool AllowDecimals { get; init; }
protected override bool CanAddCharacter(char character) protected override bool CanAddCharacter(char character)
=> char.IsAsciiDigit(character) || (AllowDecimals && character == '.'); => char.IsAsciiDigit(character) || (AllowDecimals && CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator.Contains(character));
} }
} }
} }

View File

@ -17,6 +17,7 @@ using osu.Framework.Input;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Localisation;
using osu.Game.Overlays; using osu.Game.Overlays;
namespace osu.Game.Graphics.UserInterfaceV2 namespace osu.Game.Graphics.UserInterfaceV2
@ -83,8 +84,10 @@ namespace osu.Game.Graphics.UserInterfaceV2
[Resolved] [Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!; private OverlayColourProvider colourProvider { get; set; } = null!;
private readonly Bindable<Language> currentLanguage = new Bindable<Language>();
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours, OsuGame? game)
{ {
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
Height = 50; Height = 50;
@ -150,6 +153,9 @@ namespace osu.Game.Graphics.UserInterfaceV2
}, },
}, },
}; };
if (game != null)
currentLanguage.BindTo(game.CurrentLanguage);
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -164,10 +170,11 @@ namespace osu.Game.Graphics.UserInterfaceV2
slider.IsDragging.BindValueChanged(_ => updateState()); slider.IsDragging.BindValueChanged(_ => updateState());
currentLanguage.BindValueChanged(_ => Schedule(updateValueDisplay));
current.BindValueChanged(_ => current.BindValueChanged(_ =>
{ {
updateState(); updateState();
updateTextBoxFromSlider(); updateValueDisplay();
}, true); }, true);
} }
@ -258,7 +265,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
background.Colour = colourProvider.Background5; background.Colour = colourProvider.Background5;
} }
private void updateTextBoxFromSlider() private void updateValueDisplay()
{ {
if (updatingFromTextBox) return; if (updatingFromTextBox) return;