mirror of
https://github.com/ppy/osu.git
synced 2024-11-15 12:27:26 +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:
parent
4fc0aae486
commit
45a6a743a2
@ -1,6 +1,8 @@
|
||||
// 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.
|
||||
|
||||
using System.Globalization;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterfaceV2
|
||||
{
|
||||
public partial class FormNumberBox : FormTextBox
|
||||
@ -18,7 +20,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
public bool AllowDecimals { get; init; }
|
||||
|
||||
protected override bool CanAddCharacter(char character)
|
||||
=> char.IsAsciiDigit(character) || (AllowDecimals && character == '.');
|
||||
=> char.IsAsciiDigit(character) || (AllowDecimals && CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator.Contains(character));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ using osu.Framework.Input;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterfaceV2
|
||||
@ -83,8 +84,10 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||
|
||||
private readonly Bindable<Language> currentLanguage = new Bindable<Language>();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
private void load(OsuColour colours, OsuGame? game)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = 50;
|
||||
@ -150,6 +153,9 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
if (game != null)
|
||||
currentLanguage.BindTo(game.CurrentLanguage);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -164,10 +170,11 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
|
||||
slider.IsDragging.BindValueChanged(_ => updateState());
|
||||
|
||||
currentLanguage.BindValueChanged(_ => Schedule(updateValueDisplay));
|
||||
current.BindValueChanged(_ =>
|
||||
{
|
||||
updateState();
|
||||
updateTextBoxFromSlider();
|
||||
updateValueDisplay();
|
||||
}, true);
|
||||
}
|
||||
|
||||
@ -258,7 +265,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
background.Colour = colourProvider.Background5;
|
||||
}
|
||||
|
||||
private void updateTextBoxFromSlider()
|
||||
private void updateValueDisplay()
|
||||
{
|
||||
if (updatingFromTextBox) return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user