mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 08:20:00 +09:00
Add respective query params to GetScoreRequest based on selected tab.
This commit is contained in:
@ -10,19 +10,22 @@ using osu.Game.Rulesets;
|
|||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
using osu.Game.Rulesets.Replays;
|
using osu.Game.Rulesets.Replays;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osu.Game.Screens.Select.Leaderboards;
|
||||||
|
|
||||||
namespace osu.Game.Online.API.Requests
|
namespace osu.Game.Online.API.Requests
|
||||||
{
|
{
|
||||||
public class GetScoresRequest : APIRequest<GetScoresResponse>
|
public class GetScoresRequest : APIRequest<GetScoresResponse>
|
||||||
{
|
{
|
||||||
private readonly BeatmapInfo beatmap;
|
private readonly BeatmapInfo beatmap;
|
||||||
|
private readonly LeaderboardScope scope;
|
||||||
|
|
||||||
public GetScoresRequest(BeatmapInfo beatmap)
|
public GetScoresRequest(BeatmapInfo beatmap, LeaderboardScope scope = LeaderboardScope.Global)
|
||||||
{
|
{
|
||||||
if (!beatmap.OnlineBeatmapID.HasValue)
|
if (!beatmap.OnlineBeatmapID.HasValue)
|
||||||
throw new InvalidOperationException($"Cannot lookup a beatmap's scores without having a populated {nameof(BeatmapInfo.OnlineBeatmapID)}.");
|
throw new InvalidOperationException($"Cannot lookup a beatmap's scores without having a populated {nameof(BeatmapInfo.OnlineBeatmapID)}.");
|
||||||
|
|
||||||
this.beatmap = beatmap;
|
this.beatmap = beatmap;
|
||||||
|
this.scope = scope;
|
||||||
|
|
||||||
Success += onSuccess;
|
Success += onSuccess;
|
||||||
}
|
}
|
||||||
@ -33,7 +36,25 @@ namespace osu.Game.Online.API.Requests
|
|||||||
score.ApplyBeatmap(beatmap);
|
score.ApplyBeatmap(beatmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string Target => $@"beatmaps/{beatmap.OnlineBeatmapID}/scores";
|
private string mapScopeToQuery()
|
||||||
|
{
|
||||||
|
switch(scope)
|
||||||
|
{
|
||||||
|
case LeaderboardScope.Global:
|
||||||
|
return @"?type=global";
|
||||||
|
|
||||||
|
case LeaderboardScope.Friends:
|
||||||
|
return @"?type=friend";
|
||||||
|
|
||||||
|
case LeaderboardScope.Country:
|
||||||
|
return @"?type=country";
|
||||||
|
|
||||||
|
default:
|
||||||
|
return String.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string Target => $@"beatmaps/{beatmap.OnlineBeatmapID}/scores{mapScopeToQuery()}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GetScoresResponse
|
public class GetScoresResponse
|
||||||
|
@ -52,6 +52,7 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
Details.Hide();
|
Details.Hide();
|
||||||
|
Leaderboard.Scope = (LeaderboardScope) tab - 1;
|
||||||
Leaderboard.Show();
|
Leaderboard.Show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,19 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private LeaderboardScope scope = LeaderboardScope.Global;
|
||||||
|
public LeaderboardScope Scope
|
||||||
|
{
|
||||||
|
get { return scope; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == scope) return;
|
||||||
|
|
||||||
|
scope = value;
|
||||||
|
updateScores();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Leaderboard()
|
public Leaderboard()
|
||||||
{
|
{
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
@ -120,6 +133,11 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
{
|
{
|
||||||
if (!IsLoaded) return;
|
if (!IsLoaded) return;
|
||||||
|
|
||||||
|
if (Scope == LeaderboardScope.Local)
|
||||||
|
{
|
||||||
|
// TODO: get local scores from wherever here.
|
||||||
|
}
|
||||||
|
|
||||||
Scores = null;
|
Scores = null;
|
||||||
getScoresRequest?.Cancel();
|
getScoresRequest?.Cancel();
|
||||||
|
|
||||||
@ -127,7 +145,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
|
|
||||||
loading.Show();
|
loading.Show();
|
||||||
|
|
||||||
getScoresRequest = new GetScoresRequest(Beatmap);
|
getScoresRequest = new GetScoresRequest(Beatmap, Scope);
|
||||||
getScoresRequest.Success += r =>
|
getScoresRequest.Success += r =>
|
||||||
{
|
{
|
||||||
Scores = r.Scores;
|
Scores = r.Scores;
|
||||||
@ -165,4 +183,12 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum LeaderboardScope
|
||||||
|
{
|
||||||
|
Local,
|
||||||
|
Country,
|
||||||
|
Global,
|
||||||
|
Friends,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user