From e79ba9a1299fc54728d9762af30e5e38a02f0e4b Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Wed, 5 Feb 2020 17:41:57 +0100 Subject: [PATCH] Add alwaysShowDecimals param to FormatAccuracy This allows us to specify whether we want it to show decimal places if accuracy is 100%. --- osu.Game/Utils/FormatUtils.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Utils/FormatUtils.cs b/osu.Game/Utils/FormatUtils.cs index b3758b3375..f0b8b470f1 100644 --- a/osu.Game/Utils/FormatUtils.cs +++ b/osu.Game/Utils/FormatUtils.cs @@ -7,18 +7,18 @@ namespace osu.Game.Utils { /// /// Turns the provided accuracy into a percentage with 2 decimal places. - /// Omits all decimal places when equals 1d. /// /// The accuracy to be formatted + /// Whether to show decimal places if equals 1d /// formatted accuracy in percentage - public static string FormatAccuracy(this double accuracy) => accuracy == 1 ? "100%" : $"{accuracy:0.00%}"; + public static string FormatAccuracy(this double accuracy, bool alwaysShowDecimals = false) => accuracy == 1 && !alwaysShowDecimals ? "100%" : $"{accuracy:0.00%}"; /// /// Turns the provided accuracy into a percentage with 2 decimal places. - /// Omits all decimal places when equals 100m. /// /// The accuracy to be formatted + /// Whether to show decimal places if equals 100m /// formatted accuracy in percentage - public static string FormatAccuracy(this decimal accuracy) => accuracy == 100 ? "100%" : $"{accuracy:0.00}%"; + public static string FormatAccuracy(this decimal accuracy, bool alwaysShowDecimals = false) => accuracy == 100 && !alwaysShowDecimals ? "100%" : $"{accuracy:0.00}%"; } }