mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 22:19:30 +08:00
Merge pull request #7726 from EVAST9919/rankings-spotlights-table
Add API to get rankings data for selected spotlight
This commit is contained in:
commit
e119040d5d
@ -68,6 +68,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddStep("Mania scores", () => createScoreTable(new ManiaRuleset().RulesetInfo));
|
||||
AddStep("Taiko country scores", () => createCountryTable(new TaikoRuleset().RulesetInfo));
|
||||
AddStep("Catch US performance page 10", () => createPerformanceTable(new CatchRuleset().RulesetInfo, "US", 10));
|
||||
AddStep("Osu spotlight table (chart 271)", () => createSpotlightTable(new OsuRuleset().RulesetInfo, 271));
|
||||
}
|
||||
|
||||
private void createCountryTable(RulesetInfo ruleset, int page = 1)
|
||||
@ -112,6 +113,20 @@ namespace osu.Game.Tests.Visual.Online
|
||||
api.Queue(request);
|
||||
}
|
||||
|
||||
private void createSpotlightTable(RulesetInfo ruleset, int spotlight)
|
||||
{
|
||||
onLoadStarted();
|
||||
|
||||
request = new GetSpotlightRankingsRequest(ruleset, spotlight);
|
||||
((GetSpotlightRankingsRequest)request).Success += rankings => Schedule(() =>
|
||||
{
|
||||
var table = new ScoresTable(1, rankings.Users);
|
||||
loadTable(table);
|
||||
});
|
||||
|
||||
api.Queue(request);
|
||||
}
|
||||
|
||||
private void onLoadStarted()
|
||||
{
|
||||
loading.Show();
|
||||
|
30
osu.Game/Online/API/Requests/GetSpotlightRankingsRequest.cs
Normal file
30
osu.Game/Online/API/Requests/GetSpotlightRankingsRequest.cs
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.IO.Network;
|
||||
using osu.Game.Rulesets;
|
||||
|
||||
namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public class GetSpotlightRankingsRequest : GetRankingsRequest<GetSpotlightRankingsResponse>
|
||||
{
|
||||
private readonly int spotlight;
|
||||
|
||||
public GetSpotlightRankingsRequest(RulesetInfo ruleset, int spotlight)
|
||||
: base(ruleset, 1)
|
||||
{
|
||||
this.spotlight = spotlight;
|
||||
}
|
||||
|
||||
protected override WebRequest CreateWebRequest()
|
||||
{
|
||||
var req = base.CreateWebRequest();
|
||||
|
||||
req.AddParameter("spotlight", spotlight.ToString());
|
||||
|
||||
return req;
|
||||
}
|
||||
|
||||
protected override string TargetPostfix() => "charts";
|
||||
}
|
||||
}
|
22
osu.Game/Online/API/Requests/GetSpotlightRankingsResponse.cs
Normal file
22
osu.Game/Online/API/Requests/GetSpotlightRankingsResponse.cs
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public class GetSpotlightRankingsResponse
|
||||
{
|
||||
[JsonProperty("ranking")]
|
||||
public List<UserStatistics> Users;
|
||||
|
||||
[JsonProperty("spotlight")]
|
||||
public APISpotlight Spotlight;
|
||||
|
||||
[JsonProperty("beatmapsets")]
|
||||
public List<APIBeatmapSet> BeatmapSets;
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Users;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Overlays.Rankings.Tables
|
||||
{
|
||||
@ -44,9 +45,9 @@ namespace osu.Game.Overlays.Rankings.Tables
|
||||
new ColoredRowText { Text = $@"{item.PlayCount:N0}", },
|
||||
}.Concat(CreateUniqueContent(item)).Concat(new[]
|
||||
{
|
||||
new ColoredRowText { Text = $@"{item.GradesCount.SS + item.GradesCount.SSPlus:N0}", },
|
||||
new ColoredRowText { Text = $@"{item.GradesCount.S + item.GradesCount.SPlus:N0}", },
|
||||
new ColoredRowText { Text = $@"{item.GradesCount.A:N0}", }
|
||||
new ColoredRowText { Text = $@"{item.GradesCount[ScoreRank.XH] + item.GradesCount[ScoreRank.X]:N0}", },
|
||||
new ColoredRowText { Text = $@"{item.GradesCount[ScoreRank.SH] + item.GradesCount[ScoreRank.S]:N0}", },
|
||||
new ColoredRowText { Text = $@"{item.GradesCount[ScoreRank.A]:N0}", }
|
||||
}).ToArray();
|
||||
|
||||
protected abstract TableColumn[] CreateUniqueHeaders();
|
||||
|
@ -30,7 +30,7 @@ namespace osu.Game.Users
|
||||
public decimal? PP;
|
||||
|
||||
[JsonProperty(@"pp_rank")] // the API sometimes only returns this value in condensed user responses
|
||||
private int rank
|
||||
private int? rank
|
||||
{
|
||||
set => Ranks.Global = value;
|
||||
}
|
||||
@ -71,13 +71,13 @@ namespace osu.Game.Users
|
||||
public struct Grades
|
||||
{
|
||||
[JsonProperty(@"ssh")]
|
||||
public int SSPlus;
|
||||
public int? SSPlus;
|
||||
|
||||
[JsonProperty(@"ss")]
|
||||
public int SS;
|
||||
|
||||
[JsonProperty(@"sh")]
|
||||
public int SPlus;
|
||||
public int? SPlus;
|
||||
|
||||
[JsonProperty(@"s")]
|
||||
public int S;
|
||||
@ -92,13 +92,13 @@ namespace osu.Game.Users
|
||||
switch (rank)
|
||||
{
|
||||
case ScoreRank.XH:
|
||||
return SSPlus;
|
||||
return SSPlus ?? 0;
|
||||
|
||||
case ScoreRank.X:
|
||||
return SS;
|
||||
|
||||
case ScoreRank.SH:
|
||||
return SPlus;
|
||||
return SPlus ?? 0;
|
||||
|
||||
case ScoreRank.S:
|
||||
return S;
|
||||
|
Loading…
Reference in New Issue
Block a user