mirror of
https://github.com/ppy/osu.git
synced 2025-01-18 06:22:56 +08:00
Add FormatStarRating()
method util
This commit is contained in:
parent
3035e8435d
commit
e95dc2b308
@ -15,6 +15,7 @@ using osu.Game.Graphics;
|
||||
using osu.Game.Models;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Utils;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -207,7 +208,7 @@ namespace osu.Game.Tournament.Components
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new DiffPiece(stats),
|
||||
new DiffPiece(("Star Rating", $"{beatmap.StarRating:0.00}{srExtra}"))
|
||||
new DiffPiece(("Star Rating", $"{beatmap.StarRating.FormatStarRating()}{srExtra}"))
|
||||
}
|
||||
},
|
||||
new FillFlowContainer
|
||||
|
@ -5,7 +5,6 @@ using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Extensions.LocalisationExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
@ -14,6 +13,7 @@ using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Utils;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -156,7 +156,7 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
|
||||
displayedStars.BindValueChanged(s =>
|
||||
{
|
||||
starsText.Text = s.NewValue < 0 ? "-" : s.NewValue.ToLocalisableString("0.00");
|
||||
starsText.Text = s.NewValue < 0 ? "-" : s.NewValue.FormatStarRating();
|
||||
|
||||
background.Colour = colours.ForStarDifficulty(s.NewValue);
|
||||
|
||||
|
@ -21,6 +21,7 @@ using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Utils;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.BeatmapSet
|
||||
@ -185,7 +186,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
OnHovered = beatmap =>
|
||||
{
|
||||
showBeatmap(beatmap);
|
||||
starRating.Text = beatmap.StarRating.ToLocalisableString(@"0.00");
|
||||
starRating.Text = beatmap.StarRating.FormatStarRating();
|
||||
starRatingContainer.FadeIn(100);
|
||||
},
|
||||
OnClicked = beatmap => { Beatmap.Value = beatmap; },
|
||||
|
@ -226,7 +226,7 @@ namespace osu.Game.Skinning.Components
|
||||
return computeDifficulty().ApproachRate.ToLocalisableString(@"0.##");
|
||||
|
||||
case BeatmapAttribute.StarRating:
|
||||
return (starDifficulty?.Stars ?? 0).ToLocalisableString(@"F2");
|
||||
return (starDifficulty?.Stars ?? 0).FormatStarRating();
|
||||
|
||||
case BeatmapAttribute.MaxPP:
|
||||
return Math.Round(starDifficulty?.PerformanceAttributes?.Total ?? 0, MidpointRounding.AwayFromZero).ToLocalisableString();
|
||||
|
@ -32,6 +32,12 @@ namespace osu.Game.Utils
|
||||
/// <param name="rank">The rank/position to be formatted.</param>
|
||||
public static string FormatRank(this int rank) => rank.ToMetric(decimals: rank < 100_000 ? 1 : 0);
|
||||
|
||||
/// <summary>
|
||||
/// Formats the supplied star rating in a consistent, simplified way.
|
||||
/// </summary>
|
||||
/// <param name="starRating">The star rating to be formatted.</param>
|
||||
public static LocalisableString FormatStarRating(this double starRating) => starRating.ToLocalisableString("0.00");
|
||||
|
||||
/// <summary>
|
||||
/// Finds the number of digits after the decimal.
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user