1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 04:05:35 +08:00

Change DrawableProfileScore to use APIScoreInfo

This commit is contained in:
Dean Herbert 2021-10-29 15:14:52 +09:00
parent 17a83f701a
commit 31403daa20
5 changed files with 65 additions and 62 deletions

View File

@ -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,

View File

@ -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

View File

@ -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,

View File

@ -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;

View File

@ -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++));
}
}
}