mirror of
https://github.com/ppy/osu
synced 2025-02-19 11:56:58 +00:00
Add alwaysShowDecimals param to FormatAccuracy
This allows us to specify whether we want it to show decimal places if accuracy is 100%.
This commit is contained in:
parent
fa3934ddb4
commit
e79ba9a129
@ -7,18 +7,18 @@ namespace osu.Game.Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// Turns the provided accuracy into a percentage with 2 decimal places.
|
||||
/// Omits all decimal places when <paramref name="accuracy"/> equals 1d.
|
||||
/// </summary>
|
||||
/// <param name="accuracy">The accuracy to be formatted</param>
|
||||
/// <param name="alwaysShowDecimals">Whether to show decimal places if <paramref name="accuracy"/> equals 1d</param>
|
||||
/// <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, bool alwaysShowDecimals = false) => accuracy == 1 && !alwaysShowDecimals ? "100%" : $"{accuracy:0.00%}";
|
||||
|
||||
/// <summary>
|
||||
/// Turns the provided accuracy into a percentage with 2 decimal places.
|
||||
/// Omits all decimal places when <paramref name="accuracy"/> equals 100m.
|
||||
/// </summary>
|
||||
/// <param name="accuracy">The accuracy to be formatted</param>
|
||||
/// <param name="alwaysShowDecimals">Whether to show decimal places if <paramref name="accuracy"/> equals 100m</param>
|
||||
/// <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, bool alwaysShowDecimals = false) => accuracy == 100 && !alwaysShowDecimals ? "100%" : $"{accuracy:0.00}%";
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user