Use format string for double instead of Math.Round.

This commit is contained in:
Huo Yaoyuan
2017-10-15 16:44:15 +08:00
committed by Dean Herbert
parent f837117495
commit c2836a8393
3 changed files with 7 additions and 6 deletions

View File

@ -31,7 +31,7 @@ namespace osu.Game.Overlays.BeatmapSet
beatmap = value; beatmap = value;
var rate = (float)beatmap.OnlineInfo.PassCount / beatmap.OnlineInfo.PlayCount; var rate = (float)beatmap.OnlineInfo.PassCount / beatmap.OnlineInfo.PlayCount;
successPercent.Text = $"{Math.Round(rate * 100)}%"; successPercent.Text = rate.ToString("P0");
successRate.Length = rate; successRate.Length = rate;
percentContainer.ResizeWidthTo(successRate.Length, 250, Easing.InOutCubic); percentContainer.ResizeWidthTo(successRate.Length, 250, Easing.InOutCubic);

View File

@ -79,9 +79,10 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colour, LocalisationEngine locale, BeatmapSetOverlay beatmapSetOverlay) private void load(OsuColour colour, LocalisationEngine locale, BeatmapSetOverlay beatmapSetOverlay)
{ {
double pp = score.PP ?? 0;
stats.Add(new OsuSpriteText stats.Add(new OsuSpriteText
{ {
Text = $"{Math.Round(score.PP ?? 0)}pp", Text = $"{pp:0}pp",
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
TextSize = 18, TextSize = 18,
@ -92,7 +93,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
{ {
stats.Add(new OsuSpriteText stats.Add(new OsuSpriteText
{ {
Current = locale.Format($"weighted: {score.PP * weight ?? 0:0}pp ({weight:0%})"), Text = $"weighted: {pp * weight:0}pp ({weight:P0})",
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
Colour = colour.GrayA, Colour = colour.GrayA,
@ -103,7 +104,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
stats.Add(new OsuSpriteText stats.Add(new OsuSpriteText
{ {
Text = "accuracy: " + score.Accuracy.ToString("0.00%"), Text = $"accuracy: {score.Accuracy:P2}",
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
Colour = colour.GrayA, Colour = colour.GrayA,

View File

@ -232,9 +232,9 @@ namespace osu.Game.Screens.Select
double bpmMax = beatmap.ControlPointInfo.BPMMaximum; double bpmMax = beatmap.ControlPointInfo.BPMMaximum;
double bpmMin = beatmap.ControlPointInfo.BPMMinimum; double bpmMin = beatmap.ControlPointInfo.BPMMinimum;
if (Precision.AlmostEquals(bpmMin, bpmMax)) return Math.Round(bpmMin) + "bpm"; if (Precision.AlmostEquals(bpmMin, bpmMax)) return $"{bpmMin:0}bpm";
return Math.Round(bpmMin) + "-" + Math.Round(bpmMax) + "bpm (mostly " + Math.Round(beatmap.ControlPointInfo.BPMMode) + "bpm)"; return $"{bpmMin:0}-{bpmMax:0}bpm (mostly {beatmap.ControlPointInfo.BPMMode:0}bpm)";
} }
public class InfoLabel : Container public class InfoLabel : Container