1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-19 05:57:19 +08:00

Merge pull request #19192 from tsunyoku/fix-user-profile-overlay

Update profile web overlay to use `SoloScoreInfo`
This commit is contained in:
Salman Ahmed 2022-07-18 12:08:02 +03:00 committed by GitHub
commit b6750961a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 35 additions and 18 deletions

View File

@ -21,7 +21,7 @@ namespace osu.Game.Tests.Visual.Online
{
public TestSceneUserProfileScores()
{
var firstScore = new APIScore
var firstScore = new SoloScoreInfo
{
PP = 1047.21,
Rank = ScoreRank.SH,
@ -34,7 +34,7 @@ namespace osu.Game.Tests.Visual.Online
},
DifficultyName = "Extreme"
},
Date = DateTimeOffset.Now,
EndedAt = DateTimeOffset.Now,
Mods = new[]
{
new APIMod { Acronym = new OsuModHidden().Acronym },
@ -44,7 +44,7 @@ namespace osu.Game.Tests.Visual.Online
Accuracy = 0.9813
};
var secondScore = new APIScore
var secondScore = new SoloScoreInfo
{
PP = 134.32,
Rank = ScoreRank.A,
@ -57,7 +57,7 @@ namespace osu.Game.Tests.Visual.Online
},
DifficultyName = "[4K] Regret"
},
Date = DateTimeOffset.Now,
EndedAt = DateTimeOffset.Now,
Mods = new[]
{
new APIMod { Acronym = new OsuModHardRock().Acronym },
@ -66,7 +66,7 @@ namespace osu.Game.Tests.Visual.Online
Accuracy = 0.998546
};
var thirdScore = new APIScore
var thirdScore = new SoloScoreInfo
{
PP = 96.83,
Rank = ScoreRank.S,
@ -79,11 +79,11 @@ namespace osu.Game.Tests.Visual.Online
},
DifficultyName = "Insane"
},
Date = DateTimeOffset.Now,
EndedAt = DateTimeOffset.Now,
Accuracy = 0.9726
};
var noPPScore = new APIScore
var noPPScore = new SoloScoreInfo
{
Rank = ScoreRank.B,
Beatmap = new APIBeatmap
@ -95,7 +95,7 @@ namespace osu.Game.Tests.Visual.Online
},
DifficultyName = "[4K] Cataclysmic Hypernova"
},
Date = DateTimeOffset.Now,
EndedAt = DateTimeOffset.Now,
Accuracy = 0.55879
};

View File

@ -10,7 +10,7 @@ using osu.Game.Rulesets;
namespace osu.Game.Online.API.Requests
{
public class GetUserScoresRequest : PaginatedAPIRequest<List<APIScore>>
public class GetUserScoresRequest : PaginatedAPIRequest<List<SoloScoreInfo>>
{
private readonly long userId;
private readonly ScoreType type;

View File

@ -82,6 +82,23 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty("user")]
public APIUser? User { get; set; }
[JsonProperty("beatmap")]
public APIBeatmap? Beatmap { get; set; }
[JsonProperty("beatmapset")]
public APIBeatmapSet? BeatmapSet
{
set
{
// in the deserialisation case we need to ferry this data across.
// the order of properties returned by the API guarantees that the beatmap is populated by this point.
if (!(Beatmap is APIBeatmap apiBeatmap))
throw new InvalidOperationException("Beatmap set metadata arrived before beatmap metadata in response");
apiBeatmap.BeatmapSet = value;
}
}
[JsonProperty("pp")]
public double? PP { get; set; }

View File

@ -31,7 +31,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
private const float performance_background_shear = 0.45f;
protected readonly APIScore Score;
protected readonly SoloScoreInfo Score;
[Resolved]
private OsuColour colours { get; set; }
@ -39,7 +39,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
[Resolved]
private OverlayColourProvider colourProvider { get; set; }
public DrawableProfileScore(APIScore score)
public DrawableProfileScore(SoloScoreInfo score)
{
Score = score;
@ -98,7 +98,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular),
Colour = colours.Yellow
},
new DrawableDate(Score.Date, 12)
new DrawableDate(Score.EndedAt, 12)
{
Colour = colourProvider.Foreground1
}
@ -138,7 +138,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
{
var ruleset = rulesets.GetRuleset(Score.RulesetID) ?? throw new InvalidOperationException($"Ruleset with ID of {Score.RulesetID} not found locally");
return new ModIcon(ruleset.CreateInstance().CreateModFromAcronym(mod.Acronym))
return new ModIcon(mod.ToMod(ruleset.CreateInstance()))
{
Scale = new Vector2(0.35f)
};

View File

@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
{
private readonly double weight;
public DrawableProfileWeightedScore(APIScore score, double weight)
public DrawableProfileWeightedScore(SoloScoreInfo score, double weight)
: base(score)
{
this.weight = weight;

View File

@ -17,7 +17,7 @@ using APIUser = osu.Game.Online.API.Requests.Responses.APIUser;
namespace osu.Game.Overlays.Profile.Sections.Ranks
{
public class PaginatedScoreContainer : PaginatedProfileSubsection<APIScore>
public class PaginatedScoreContainer : PaginatedProfileSubsection<SoloScoreInfo>
{
private readonly ScoreType type;
@ -54,7 +54,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
}
}
protected override void OnItemsReceived(List<APIScore> items)
protected override void OnItemsReceived(List<SoloScoreInfo> items)
{
if (CurrentPage == null || CurrentPage?.Offset == 0)
drawableItemIndex = 0;
@ -62,12 +62,12 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
base.OnItemsReceived(items);
}
protected override APIRequest<List<APIScore>> CreateRequest(PaginationParameters pagination) =>
protected override APIRequest<List<SoloScoreInfo>> CreateRequest(PaginationParameters pagination) =>
new GetUserScoresRequest(User.Value.Id, type, pagination);
private int drawableItemIndex;
protected override Drawable CreateDrawableItem(APIScore model)
protected override Drawable CreateDrawableItem(SoloScoreInfo model)
{
switch (type)
{