mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Move request inside the ScoresContainer again
This commit is contained in:
@ -11,6 +11,9 @@ using osuTK;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
|
||||
namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
{
|
||||
@ -24,6 +27,40 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
private readonly FillFlowContainer topScoresContainer;
|
||||
private readonly LoadingAnimation loadingAnimation;
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
private GetScoresRequest getScoresRequest;
|
||||
|
||||
private APILegacyScores scores;
|
||||
|
||||
protected APILegacyScores Scores
|
||||
{
|
||||
get => scores;
|
||||
set
|
||||
{
|
||||
scores = value;
|
||||
|
||||
updateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
private BeatmapInfo beatmap;
|
||||
|
||||
public BeatmapInfo Beatmap
|
||||
{
|
||||
get => beatmap;
|
||||
set
|
||||
{
|
||||
if (beatmap == value)
|
||||
return;
|
||||
|
||||
beatmap = value;
|
||||
|
||||
getScores(beatmap);
|
||||
}
|
||||
}
|
||||
|
||||
public ScoresContainer()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
@ -75,7 +112,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
updateDisplay();
|
||||
}
|
||||
|
||||
public bool Loading
|
||||
private bool loading
|
||||
{
|
||||
set
|
||||
{
|
||||
@ -86,17 +123,26 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
}
|
||||
}
|
||||
|
||||
private APILegacyScores scores;
|
||||
|
||||
public APILegacyScores Scores
|
||||
private void getScores(BeatmapInfo beatmap)
|
||||
{
|
||||
get => scores;
|
||||
set
|
||||
{
|
||||
scores = value;
|
||||
getScoresRequest?.Cancel();
|
||||
getScoresRequest = null;
|
||||
|
||||
updateDisplay();
|
||||
if (beatmap?.OnlineBeatmapID.HasValue != true)
|
||||
{
|
||||
Scores = null;
|
||||
return;
|
||||
}
|
||||
|
||||
loading = true;
|
||||
|
||||
getScoresRequest = new GetScoresRequest(beatmap, beatmap.Ruleset);
|
||||
getScoresRequest.Success += scores => Schedule(() =>
|
||||
{
|
||||
Scores = scores;
|
||||
loading = false;
|
||||
});
|
||||
api.Queue(getScoresRequest);
|
||||
}
|
||||
|
||||
private void updateDisplay()
|
||||
|
Reference in New Issue
Block a user