mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:57:36 +08:00
Localise accuracy display.
This commit is contained in:
parent
00ec229bde
commit
ff3d38de6f
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Utils;
|
using osu.Game.Utils;
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
Current.Value = DisplayedCount = 1.0f;
|
Current.Value = DisplayedCount = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string FormatCount(double count) => count.FormatAccuracy();
|
protected override LocalisableString FormatCount(double count) => count.FormatAccuracy();
|
||||||
|
|
||||||
protected override double GetProportionalDuration(double currentValue, double newValue)
|
protected override double GetProportionalDuration(double currentValue, double newValue)
|
||||||
{
|
{
|
||||||
|
@ -10,6 +10,7 @@ using System.Collections.Generic;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using osu.Framework.Localisation;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.Graphics.UserInterface
|
||||||
{
|
{
|
||||||
@ -137,8 +138,8 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
/// Used to format counts.
|
/// Used to format counts.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="count">Count to format.</param>
|
/// <param name="count">Count to format.</param>
|
||||||
/// <returns>Count formatted as a string.</returns>
|
/// <returns>Count formatted as a localisable string.</returns>
|
||||||
protected virtual string FormatCount(T count)
|
protected virtual LocalisableString FormatCount(T count)
|
||||||
{
|
{
|
||||||
return count.ToString();
|
return count.ToString();
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.Graphics.UserInterface
|
||||||
@ -37,7 +38,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
return currentValue > newValue ? currentValue - newValue : newValue - currentValue;
|
return currentValue > newValue ? currentValue - newValue : newValue - currentValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string FormatCount(double count)
|
protected override LocalisableString FormatCount(double count)
|
||||||
{
|
{
|
||||||
string format = new string('0', RequiredDisplayDigits.Value);
|
string format = new string('0', RequiredDisplayDigits.Value);
|
||||||
|
|
||||||
|
@ -372,10 +372,10 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
public class LeaderboardScoreStatistic
|
public class LeaderboardScoreStatistic
|
||||||
{
|
{
|
||||||
public IconUsage Icon;
|
public IconUsage Icon;
|
||||||
public string Value;
|
public LocalisableString Value;
|
||||||
public string Name;
|
public string Name;
|
||||||
|
|
||||||
public LeaderboardScoreStatistic(IconUsage icon, string name, string value)
|
public LeaderboardScoreStatistic(IconUsage icon, string name, LocalisableString value)
|
||||||
{
|
{
|
||||||
Icon = icon;
|
Icon = icon;
|
||||||
Name = name;
|
Name = name;
|
||||||
|
@ -9,6 +9,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
@ -204,7 +205,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
this.text = text;
|
this.text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Text
|
public LocalisableString Text
|
||||||
{
|
{
|
||||||
set => text.Text = value;
|
set => text.Text = value;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ using System.ComponentModel.DataAnnotations.Schema;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
@ -34,7 +35,7 @@ namespace osu.Game.Scoring
|
|||||||
public double Accuracy { get; set; }
|
public double Accuracy { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public string DisplayAccuracy => Accuracy.FormatAccuracy();
|
public LocalisableString DisplayAccuracy => Accuracy.FormatAccuracy();
|
||||||
|
|
||||||
[JsonProperty(@"pp")]
|
[JsonProperty(@"pp")]
|
||||||
public double? PP { get; set; }
|
public double? PP { get; set; }
|
||||||
|
@ -7,6 +7,7 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Utils;
|
using osu.Game.Utils;
|
||||||
@ -63,7 +64,7 @@ namespace osu.Game.Screens.Play.Break
|
|||||||
valueText.Text = newText;
|
valueText.Text = newText;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual string Format(T count)
|
protected virtual LocalisableString Format(T count)
|
||||||
{
|
{
|
||||||
if (count is Enum countEnum)
|
if (count is Enum countEnum)
|
||||||
return countEnum.GetDescription();
|
return countEnum.GetDescription();
|
||||||
@ -86,6 +87,6 @@ namespace osu.Game.Screens.Play.Break
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string Format(double count) => count.FormatAccuracy();
|
protected override LocalisableString Format(double count) => count.FormatAccuracy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
@ -31,7 +32,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
Current.BindTo(scoreProcessor.Combo);
|
Current.BindTo(scoreProcessor.Combo);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string FormatCount(int count)
|
protected override LocalisableString FormatCount(int count)
|
||||||
{
|
{
|
||||||
return $@"{count}x";
|
return $@"{count}x";
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// 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 osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
@ -44,7 +45,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics
|
|||||||
|
|
||||||
protected override Easing RollingEasing => AccuracyCircle.ACCURACY_TRANSFORM_EASING;
|
protected override Easing RollingEasing => AccuracyCircle.ACCURACY_TRANSFORM_EASING;
|
||||||
|
|
||||||
protected override string FormatCount(double count) => count.FormatAccuracy();
|
protected override LocalisableString FormatCount(double count) => count.FormatAccuracy();
|
||||||
|
|
||||||
protected override OsuSpriteText CreateSpriteText() => base.CreateSpriteText().With(s =>
|
protected override OsuSpriteText CreateSpriteText() => base.CreateSpriteText().With(s =>
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// 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 osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
@ -26,7 +27,7 @@ namespace osu.Game.Screens.Ranking.Expanded
|
|||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string FormatCount(long count) => count.ToString("N0");
|
protected override LocalisableString FormatCount(long count) => count.ToString("N0");
|
||||||
|
|
||||||
protected override OsuSpriteText CreateSpriteText() => base.CreateSpriteText().With(s =>
|
protected override OsuSpriteText CreateSpriteText() => base.CreateSpriteText().With(s =>
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Utils;
|
using osu.Game.Utils;
|
||||||
using static osu.Game.Users.User;
|
using static osu.Game.Users.User;
|
||||||
@ -45,7 +46,7 @@ namespace osu.Game.Users
|
|||||||
public double Accuracy;
|
public double Accuracy;
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public string DisplayAccuracy => (Accuracy / 100).FormatAccuracy();
|
public LocalisableString DisplayAccuracy => (Accuracy / 100).FormatAccuracy();
|
||||||
|
|
||||||
[JsonProperty(@"play_count")]
|
[JsonProperty(@"play_count")]
|
||||||
public int PlayCount;
|
public int PlayCount;
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
// 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 System;
|
||||||
using System.Globalization;
|
|
||||||
using Humanizer;
|
using Humanizer;
|
||||||
|
using osu.Framework.Localisation;
|
||||||
|
|
||||||
namespace osu.Game.Utils
|
namespace osu.Game.Utils
|
||||||
{
|
{
|
||||||
@ -13,9 +13,8 @@ namespace osu.Game.Utils
|
|||||||
/// Turns the provided accuracy into a percentage with 2 decimal places.
|
/// Turns the provided accuracy into a percentage with 2 decimal places.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="accuracy">The accuracy to be formatted.</param>
|
/// <param name="accuracy">The accuracy to be formatted.</param>
|
||||||
/// <param name="formatProvider">An optional format provider.</param>
|
|
||||||
/// <returns>formatted accuracy in percentage</returns>
|
/// <returns>formatted accuracy in percentage</returns>
|
||||||
public static string FormatAccuracy(this double accuracy, IFormatProvider formatProvider = null)
|
public static LocalisableString FormatAccuracy(this double accuracy)
|
||||||
{
|
{
|
||||||
// for the sake of display purposes, we don't want to show a user a "rounded up" percentage to the next whole number.
|
// for the sake of display purposes, we don't want to show a user a "rounded up" percentage to the next whole number.
|
||||||
// ie. a score which gets 89.99999% shouldn't ever show as 90%.
|
// ie. a score which gets 89.99999% shouldn't ever show as 90%.
|
||||||
@ -23,7 +22,7 @@ namespace osu.Game.Utils
|
|||||||
// percentile with a non-matching grade is confusing.
|
// percentile with a non-matching grade is confusing.
|
||||||
accuracy = Math.Floor(accuracy * 10000) / 10000;
|
accuracy = Math.Floor(accuracy * 10000) / 10000;
|
||||||
|
|
||||||
return accuracy.ToString("0.00%", formatProvider ?? CultureInfo.CurrentCulture);
|
return accuracy.ToLocalisableString("0.00%");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user