From 31403daa2078b5023a91958d919d273b9dbef1a9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 29 Oct 2021 15:14:52 +0900 Subject: [PATCH] Change `DrawableProfileScore` to use `APIScoreInfo` --- .../Visual/Online/TestSceneScoresContainer.cs | 29 ++++---- .../Online/TestSceneUserProfileScores.cs | 72 +++++++++---------- .../Sections/Ranks/DrawableProfileScore.cs | 18 ++--- .../Ranks/DrawableProfileWeightedScore.cs | 4 +- .../Sections/Ranks/PaginatedScoreContainer.cs | 4 +- 5 files changed, 65 insertions(+), 62 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneScoresContainer.cs b/osu.Game.Tests/Visual/Online/TestSceneScoresContainer.cs index 991be33917..23899154c4 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneScoresContainer.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneScoresContainer.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Utils; +using osu.Game.Online.API; using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays; using osu.Game.Overlays.BeatmapSet.Scores; @@ -61,10 +62,10 @@ namespace osu.Game.Tests.Visual.Online }, Mods = new[] { - new OsuModDoubleTime().Acronym, - new OsuModHidden().Acronym, - new OsuModFlashlight().Acronym, - new OsuModHardRock().Acronym, + new APIMod { Acronym = new OsuModDoubleTime().Acronym }, + new APIMod { Acronym = new OsuModHidden().Acronym }, + new APIMod { Acronym = new OsuModFlashlight().Acronym }, + new APIMod { Acronym = new OsuModHardRock().Acronym }, }, Rank = ScoreRank.XH, PP = 200, @@ -86,9 +87,9 @@ namespace osu.Game.Tests.Visual.Online }, Mods = new[] { - new OsuModDoubleTime().Acronym, - new OsuModHidden().Acronym, - new OsuModFlashlight().Acronym, + new APIMod { Acronym = new OsuModDoubleTime().Acronym }, + new APIMod { Acronym = new OsuModHidden().Acronym }, + new APIMod { Acronym = new OsuModFlashlight().Acronym }, }, Rank = ScoreRank.S, PP = 190, @@ -110,8 +111,8 @@ namespace osu.Game.Tests.Visual.Online }, Mods = new[] { - new OsuModDoubleTime().Acronym, - new OsuModHidden().Acronym, + new APIMod { Acronym = new OsuModDoubleTime().Acronym }, + new APIMod { Acronym = new OsuModHidden().Acronym }, }, Rank = ScoreRank.B, PP = 180, @@ -133,7 +134,7 @@ namespace osu.Game.Tests.Visual.Online }, Mods = new[] { - new OsuModDoubleTime().Acronym, + new APIMod { Acronym = new OsuModDoubleTime().Acronym }, }, Rank = ScoreRank.C, PP = 170, @@ -226,10 +227,10 @@ namespace osu.Game.Tests.Visual.Online }, Mods = new[] { - new OsuModDoubleTime().Acronym, - new OsuModHidden().Acronym, - new OsuModFlashlight().Acronym, - new OsuModHardRock().Acronym, + new APIMod { Acronym = new OsuModDoubleTime().Acronym }, + new APIMod { Acronym = new OsuModHidden().Acronym }, + new APIMod { Acronym = new OsuModFlashlight().Acronym }, + new APIMod { Acronym = new OsuModHardRock().Acronym }, }, Rank = ScoreRank.XH, PP = 200, diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserProfileScores.cs b/osu.Game.Tests/Visual/Online/TestSceneUserProfileScores.cs index 513631a221..fac350ea57 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneUserProfileScores.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserProfileScores.cs @@ -2,16 +2,16 @@ // See the LICENCE file in the repository root for full licence text. using System; -using osu.Game.Overlays.Profile.Sections.Ranks; -using osu.Framework.Graphics; -using osu.Game.Scoring; -using osu.Framework.Graphics.Containers; -using osuTK; -using osu.Game.Beatmaps; -using osu.Game.Rulesets.Mods; -using osu.Game.Rulesets.Osu.Mods; -using osu.Game.Overlays; using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Online.API; +using osu.Game.Online.API.Requests.Responses; +using osu.Game.Overlays; +using osu.Game.Overlays.Profile.Sections.Ranks; +using osu.Game.Rulesets.Osu.Mods; +using osu.Game.Scoring; +using osuTK; namespace osu.Game.Tests.Visual.Online { @@ -19,79 +19,79 @@ namespace osu.Game.Tests.Visual.Online { public TestSceneUserProfileScores() { - var firstScore = new ScoreInfo + var firstScore = new APIScoreInfo { PP = 1047.21, Rank = ScoreRank.SH, - BeatmapInfo = new BeatmapInfo + Beatmap = new APIBeatmap { - Metadata = new BeatmapMetadata + BeatmapSet = { Title = "JUSTadICE (TV Size)", - Artist = "Oomori Seiko" + Artist = "Oomori Seiko", }, - Version = "Extreme" + DifficultyName = "Extreme" }, Date = DateTimeOffset.Now, - Mods = new Mod[] + Mods = new[] { - new OsuModHidden(), - new OsuModHardRock(), - new OsuModDoubleTime() + new APIMod { Acronym = new OsuModHidden().Acronym }, + new APIMod { Acronym = new OsuModHardRock().Acronym }, + new APIMod { Acronym = new OsuModDoubleTime().Acronym }, }, Accuracy = 0.9813 }; - var secondScore = new ScoreInfo + var secondScore = new APIScoreInfo { PP = 134.32, Rank = ScoreRank.A, - BeatmapInfo = new BeatmapInfo + Beatmap = new APIBeatmap { - Metadata = new BeatmapMetadata + BeatmapSet = { Title = "Triumph & Regret", - Artist = "typeMARS" + Artist = "typeMARS", }, - Version = "[4K] Regret" + DifficultyName = "[4K] Regret" }, Date = DateTimeOffset.Now, - Mods = new Mod[] + Mods = new[] { - new OsuModHardRock(), - new OsuModDoubleTime(), + new APIMod { Acronym = new OsuModHardRock().Acronym }, + new APIMod { Acronym = new OsuModDoubleTime().Acronym }, }, Accuracy = 0.998546 }; - var thirdScore = new ScoreInfo + var thirdScore = new APIScoreInfo { PP = 96.83, Rank = ScoreRank.S, - BeatmapInfo = new BeatmapInfo + Beatmap = new APIBeatmap { - Metadata = new BeatmapMetadata + BeatmapSet = { Title = "Idolize", - Artist = "Creo" + Artist = "Creo", }, - Version = "Insane" + DifficultyName = "Insane" }, Date = DateTimeOffset.Now, Accuracy = 0.9726 }; - var noPPScore = new ScoreInfo + var noPPScore = new APIScoreInfo { Rank = ScoreRank.B, - BeatmapInfo = new BeatmapInfo + Beatmap = new APIBeatmap { - Metadata = new BeatmapMetadata + BeatmapSet = { Title = "C18H27NO3(extend)", - Artist = "Team Grimoire" + Artist = "Team Grimoire", }, - Version = "[4K] Cataclysmic Hypernova" + DifficultyName = "[4K] Cataclysmic Hypernova" }, Date = DateTimeOffset.Now, Accuracy = 0.55879 diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs index 7bfa2ee51e..ca5534dbc2 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs @@ -12,9 +12,11 @@ using osu.Framework.Localisation; using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.Leaderboards; +using osu.Game.Rulesets; using osu.Game.Rulesets.UI; -using osu.Game.Scoring; +using osu.Game.Utils; using osuTK; namespace osu.Game.Overlays.Profile.Sections.Ranks @@ -26,7 +28,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks private const float performance_background_shear = 0.45f; - protected readonly ScoreInfo Score; + protected readonly APIScoreInfo Score; [Resolved] private OsuColour colours { get; set; } @@ -34,7 +36,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks [Resolved] private OverlayColourProvider colourProvider { get; set; } - public DrawableProfileScore(ScoreInfo score) + public DrawableProfileScore(APIScoreInfo score) { Score = score; @@ -43,7 +45,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks } [BackgroundDependencyLoader] - private void load() + private void load(RulesetStore rulesets) { AddInternal(new ProfileItemContainer { @@ -79,7 +81,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks Spacing = new Vector2(0, 2), Children = new Drawable[] { - new ScoreBeatmapMetadataContainer(Score.BeatmapInfo), + new ScoreBeatmapMetadataContainer(Score.Beatmap), new FillFlowContainer { AutoSizeAxes = Axes.Both, @@ -89,7 +91,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks { new OsuSpriteText { - Text = $"{Score.BeatmapInfo.Version}", + Text = $"{Score.Beatmap.DifficultyName}", Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular), Colour = colours.Yellow }, @@ -129,7 +131,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks Origin = Anchor.CentreRight, Direction = FillDirection.Horizontal, Spacing = new Vector2(2), - Children = Score.Mods.Select(mod => new ModIcon(mod) + Children = Score.Mods.Select(mod => new ModIcon(rulesets.GetRuleset(Score.RulesetID).CreateInstance().CreateModFromAcronym(mod.Acronym)) { Scale = new Vector2(0.35f) }).ToList(), @@ -198,7 +200,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks RelativeSizeAxes = Axes.Y, Child = new OsuSpriteText { - Text = Score.DisplayAccuracy, + Text = Score.Accuracy.FormatAccuracy(), Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true), Colour = colours.Yellow, Anchor = Anchor.CentreLeft, diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileWeightedScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileWeightedScore.cs index f77464ecb9..e653be5cfa 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileWeightedScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileWeightedScore.cs @@ -6,8 +6,8 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Resources.Localisation.Web; -using osu.Game.Scoring; using osuTK; namespace osu.Game.Overlays.Profile.Sections.Ranks @@ -16,7 +16,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks { private readonly double weight; - public DrawableProfileWeightedScore(ScoreInfo score, double weight) + public DrawableProfileWeightedScore(APIScoreInfo score, double weight) : base(score) { this.weight = weight; diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs index 1fb6100a28..cde386bc7b 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs @@ -69,10 +69,10 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks switch (type) { default: - return new DrawableProfileScore(model.CreateScoreInfo(Rulesets)); + return new DrawableProfileScore(model); case ScoreType.Best: - return new DrawableProfileWeightedScore(model.CreateScoreInfo(Rulesets), Math.Pow(0.95, drawableItemIndex++)); + return new DrawableProfileWeightedScore(model, Math.Pow(0.95, drawableItemIndex++)); } } }