From bed5a64ee2182e3d2c99b87fa57dd3d53512c926 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sun, 15 Oct 2017 16:15:35 +0800 Subject: [PATCH 1/4] Construct DwarableScore using null weight. --- osu.Game/Overlays/Profile/Sections/RanksSection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Profile/Sections/RanksSection.cs b/osu.Game/Overlays/Profile/Sections/RanksSection.cs index d7df239003..3b2c9d83ed 100644 --- a/osu.Game/Overlays/Profile/Sections/RanksSection.cs +++ b/osu.Game/Overlays/Profile/Sections/RanksSection.cs @@ -155,7 +155,7 @@ namespace osu.Game.Overlays.Profile.Sections { missing.Hide(); foreach (OnlineScore score in scores) - scoreContainer.Add(new DrawableScore(score, includeWeigth ? Math.Pow(0.95, scoreContainer.Count) : -1) + scoreContainer.Add(new DrawableScore(score, includeWeigth ? Math.Pow(0.95, scoreContainer.Count) : (double?)null) { RelativeSizeAxes = Axes.X, Height = 60, From 192ebe776f3d12e73606ad7b0255babdc8e257ae Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sun, 15 Oct 2017 16:30:52 +0800 Subject: [PATCH 2/4] Use localisation engine instead of asking current culture directly. --- osu.Game/Overlays/Profile/ProfileHeader.cs | 2 +- osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 973769a114..b033503141 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -402,7 +402,7 @@ namespace osu.Game.Overlays.Profile scoreText.Add(createScoreText("Ranked Score")); scoreNumberText.Add(createScoreNumberText(user.Statistics.RankedScore.ToString(@"#,0"))); scoreText.Add(createScoreText("Accuracy")); - scoreNumberText.Add(createScoreNumberText($"{user.Statistics.Accuracy.ToString("0.##", CultureInfo.CurrentCulture)}%")); + scoreNumberText.Add(createScoreNumberText($"{user.Statistics.Accuracy.ToString("0.##")}%")); scoreText.Add(createScoreText("Play Count")); scoreNumberText.Add(createScoreNumberText(user.Statistics.PlayCount.ToString(@"#,0"))); scoreText.Add(createScoreText("Total Score")); diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs index 52b68e7b30..b2961aad59 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs @@ -92,7 +92,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks { stats.Add(new OsuSpriteText { - Text = $"weighted: {Math.Round(score.PP * weight ?? 0)}pp ({weight.Value.ToString("0%", CultureInfo.CurrentCulture)})", + Current = locale.Format($"weighted: {score.PP * weight ?? 0:0}pp ({weight:0%})"), Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Colour = colour.GrayA, From 9b3676c5623970c8a9a99b34647339c7ea6c5e4e Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sun, 15 Oct 2017 16:44:15 +0800 Subject: [PATCH 3/4] Use format string for double instead of Math.Round. --- osu.Game/Overlays/BeatmapSet/SuccessRate.cs | 2 +- osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs | 7 ++++--- osu.Game/Screens/Select/BeatmapInfoWedge.cs | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/SuccessRate.cs b/osu.Game/Overlays/BeatmapSet/SuccessRate.cs index 26335aac9b..c2e1a7b660 100644 --- a/osu.Game/Overlays/BeatmapSet/SuccessRate.cs +++ b/osu.Game/Overlays/BeatmapSet/SuccessRate.cs @@ -31,7 +31,7 @@ namespace osu.Game.Overlays.BeatmapSet beatmap = value; var rate = (float)beatmap.OnlineInfo.PassCount / beatmap.OnlineInfo.PlayCount; - successPercent.Text = $"{Math.Round(rate * 100)}%"; + successPercent.Text = rate.ToString("P0"); successRate.Length = rate; percentContainer.ResizeWidthTo(successRate.Length, 250, Easing.InOutCubic); diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs index b2961aad59..5162c350e8 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs @@ -79,9 +79,10 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks [BackgroundDependencyLoader] private void load(OsuColour colour, LocalisationEngine locale, BeatmapSetOverlay beatmapSetOverlay) { + double pp = score.PP ?? 0; stats.Add(new OsuSpriteText { - Text = $"{Math.Round(score.PP ?? 0)}pp", + Text = $"{pp:0}pp", Anchor = Anchor.TopRight, Origin = Anchor.TopRight, TextSize = 18, @@ -92,7 +93,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks { 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, Origin = Anchor.TopRight, Colour = colour.GrayA, @@ -103,7 +104,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks stats.Add(new OsuSpriteText { - Text = "accuracy: " + score.Accuracy.ToString("0.00%"), + Text = $"accuracy: {score.Accuracy:P2}", Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Colour = colour.GrayA, diff --git a/osu.Game/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs index 3b26f7bffc..dc3b012328 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs @@ -232,9 +232,9 @@ namespace osu.Game.Screens.Select double bpmMax = beatmap.ControlPointInfo.BPMMaximum; 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 From 06fe8745945ce602666a1947c4638928debfaab8 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sun, 15 Oct 2017 16:53:30 +0800 Subject: [PATCH 4/4] CI fixes. --- osu.Game/Overlays/BeatmapSet/SuccessRate.cs | 1 - osu.Game/Overlays/Profile/ProfileHeader.cs | 3 +-- osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs | 2 -- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/SuccessRate.cs b/osu.Game/Overlays/BeatmapSet/SuccessRate.cs index c2e1a7b660..9402ed82f4 100644 --- a/osu.Game/Overlays/BeatmapSet/SuccessRate.cs +++ b/osu.Game/Overlays/BeatmapSet/SuccessRate.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index b033503141..22e34be34c 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -17,7 +17,6 @@ using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Users; using System.Diagnostics; -using System.Globalization; using System.Collections.Generic; using osu.Framework.Graphics.Cursor; @@ -402,7 +401,7 @@ namespace osu.Game.Overlays.Profile scoreText.Add(createScoreText("Ranked Score")); scoreNumberText.Add(createScoreNumberText(user.Statistics.RankedScore.ToString(@"#,0"))); scoreText.Add(createScoreText("Accuracy")); - scoreNumberText.Add(createScoreNumberText($"{user.Statistics.Accuracy.ToString("0.##")}%")); + scoreNumberText.Add(createScoreNumberText($"{user.Statistics.Accuracy:0.##}%")); scoreText.Add(createScoreText("Play Count")); scoreNumberText.Add(createScoreNumberText(user.Statistics.PlayCount.ToString(@"#,0"))); scoreText.Add(createScoreText("Total Score")); diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs index 5162c350e8..af336c2529 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs @@ -13,9 +13,7 @@ using osu.Game.Rulesets.Mods; using osu.Game.Screens.Select.Leaderboards; using System.Linq; using osu.Framework.Localisation; -using System.Globalization; using osu.Game.Rulesets.Scoring; -using System; using osu.Game.Rulesets.UI; namespace osu.Game.Overlays.Profile.Sections.Ranks