Merge pull request #7763 from TheWildTree/fix-accuracy-format

Make accuracy formatting more consistent
This commit is contained in:
Dean Herbert 2020-02-08 12:24:26 +09:00 committed by GitHub
commit 023c807530
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 9 deletions

View File

@ -3,6 +3,7 @@
using System; using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Utils;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {
@ -29,10 +30,7 @@ namespace osu.Game.Graphics.UserInterface
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) => AccentColour = colours.BlueLighter; private void load(OsuColour colours) => AccentColour = colours.BlueLighter;
protected override string FormatCount(double count) protected override string FormatCount(double count) => count.FormatAccuracy();
{
return $@"{count:P2}";
}
protected override double GetProportionalDuration(double currentValue, double newValue) protected override double GetProportionalDuration(double currentValue, double newValue)
{ {

View File

@ -9,6 +9,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Utils;
namespace osu.Game.Screens.Play.Break namespace osu.Game.Screens.Play.Break
{ {
@ -85,6 +86,6 @@ namespace osu.Game.Screens.Play.Break
{ {
} }
protected override string Format(double count) => $@"{count:P2}"; protected override string Format(double count) => count.FormatAccuracy();
} }
} }

View File

@ -7,18 +7,16 @@ namespace osu.Game.Utils
{ {
/// <summary> /// <summary>
/// Turns the provided accuracy into a percentage with 2 decimal places. /// Turns the provided accuracy into a percentage with 2 decimal places.
/// Omits all decimal places when <paramref name="accuracy"/> equals 1d.
/// </summary> /// </summary>
/// <param name="accuracy">The accuracy to be formatted</param> /// <param name="accuracy">The accuracy to be formatted</param>
/// <returns>formatted accuracy in percentage</returns> /// <returns>formatted accuracy in percentage</returns>
public static string FormatAccuracy(this double accuracy) => accuracy == 1 ? "100%" : $"{accuracy:0.00%}"; public static string FormatAccuracy(this double accuracy) => $"{accuracy:0.00%}";
/// <summary> /// <summary>
/// Turns the provided accuracy into a percentage with 2 decimal places. /// Turns the provided accuracy into a percentage with 2 decimal places.
/// Omits all decimal places when <paramref name="accuracy"/> equals 100m.
/// </summary> /// </summary>
/// <param name="accuracy">The accuracy to be formatted</param> /// <param name="accuracy">The accuracy to be formatted</param>
/// <returns>formatted accuracy in percentage</returns> /// <returns>formatted accuracy in percentage</returns>
public static string FormatAccuracy(this decimal accuracy) => accuracy == 100 ? "100%" : $"{accuracy:0.00}%"; public static string FormatAccuracy(this decimal accuracy) => $"{accuracy:0.00}%";
} }
} }