mirror of
https://github.com/ppy/osu.git
synced 2024-11-13 16:47:46 +08:00
Add helper method for properly formatting score multiplier in ModUtils
This commit is contained in:
parent
bca0600482
commit
7cfb786b1a
@ -5,6 +5,8 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions.LocalisationExtensions;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
@ -226,5 +228,21 @@ namespace osu.Game.Utils
|
||||
|
||||
return proposedWereValid;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Given a value of a score multiplier, returns a string version with special handling for a value near 1.00x.
|
||||
/// </summary>
|
||||
/// <param name="scoreMultiplier">The value of the score multiplier.</param>
|
||||
/// <returns>A formatted score multiplier with a trailing "x" symbol</returns>
|
||||
public static LocalisableString FormatScoreMultiplier(double scoreMultiplier)
|
||||
{
|
||||
// Round multiplier values away from 1.00x to two significant digits.
|
||||
if (scoreMultiplier > 1)
|
||||
scoreMultiplier = Math.Ceiling(scoreMultiplier * 100) / 100;
|
||||
else
|
||||
scoreMultiplier = Math.Floor(scoreMultiplier * 100) / 100;
|
||||
|
||||
return scoreMultiplier.ToLocalisableString("0.00x");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user