mirror of
https://github.com/ppy/osu.git
synced 2025-02-12 19:32:55 +08:00
Fix comma separator support not actually working
This commit is contained in:
parent
85821e4473
commit
49a878dc20
@ -1,6 +1,7 @@
|
|||||||
// 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;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
@ -29,6 +30,9 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
{
|
{
|
||||||
UseCommaSeparator = useCommaSeparator;
|
UseCommaSeparator = useCommaSeparator;
|
||||||
|
|
||||||
|
if (useCommaSeparator && leading > 0)
|
||||||
|
throw new ArgumentException("Should not mix leading zeroes and comma separators as it doesn't make sense");
|
||||||
|
|
||||||
RequiredDisplayDigits.Value = leading;
|
RequiredDisplayDigits.Value = leading;
|
||||||
RequiredDisplayDigits.BindValueChanged(_ => UpdateDisplay());
|
RequiredDisplayDigits.BindValueChanged(_ => UpdateDisplay());
|
||||||
}
|
}
|
||||||
@ -41,14 +45,15 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
protected override LocalisableString FormatCount(double count)
|
protected override LocalisableString FormatCount(double count)
|
||||||
{
|
{
|
||||||
string format = new string('0', RequiredDisplayDigits.Value);
|
string format = new string('0', RequiredDisplayDigits.Value);
|
||||||
|
var output = ((long)count).ToString(format);
|
||||||
|
|
||||||
if (UseCommaSeparator)
|
if (UseCommaSeparator)
|
||||||
{
|
{
|
||||||
for (int i = format.Length - 3; i > 0; i -= 3)
|
for (int i = output.Length - 3; i > 0; i -= 3)
|
||||||
format = format.Insert(i, @",");
|
output = output.Insert(i, @",");
|
||||||
}
|
}
|
||||||
|
|
||||||
return ((long)count).ToString(format);
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override OsuSpriteText CreateSpriteText()
|
protected override OsuSpriteText CreateSpriteText()
|
||||||
|
Loading…
Reference in New Issue
Block a user