Move request inside the ScoresContainer again

This commit is contained in:
Andrei Zavatski
2019-07-10 19:40:29 +03:00
parent a041421e0d
commit 953d32366c
3 changed files with 68 additions and 42 deletions

View File

@ -11,7 +11,6 @@ using osu.Framework.Input.Events;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Overlays.BeatmapSet;
using osu.Game.Overlays.BeatmapSet.Scores;
@ -29,15 +28,8 @@ namespace osu.Game.Overlays
private RulesetStore rulesets;
private readonly ScoresContainer scoreContainer;
private GetScoresRequest getScoresRequest;
private readonly Bindable<BeatmapSetInfo> beatmapSet = new Bindable<BeatmapSetInfo>();
[Resolved]
private IAPIProvider api { get; set; }
// receive input outside our bounds so we can trigger a close event on ourselves.
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
@ -45,6 +37,8 @@ namespace osu.Game.Overlays
{
OsuScrollContainer scroll;
Info info;
ScoresContainer scoreContainer;
Children = new Drawable[]
{
new Box
@ -77,34 +71,12 @@ namespace osu.Game.Overlays
Header.Picker.Beatmap.ValueChanged += b =>
{
info.Beatmap = b.NewValue;
getScores(b.NewValue);
scoreContainer.Beatmap = b.NewValue;
scroll.ScrollToStart();
};
}
private void getScores(BeatmapInfo beatmap)
{
getScoresRequest?.Cancel();
getScoresRequest = null;
if (beatmap?.OnlineBeatmapID.HasValue != true)
{
scoreContainer.Scores = null;
return;
}
scoreContainer.Loading = true;
getScoresRequest = new GetScoresRequest(beatmap, beatmap.Ruleset);
getScoresRequest.Success += scores => Schedule(() =>
{
scoreContainer.Scores = scores;
scoreContainer.Loading = false;
});
api.Queue(getScoresRequest);
}
[BackgroundDependencyLoader]
private void load(RulesetStore rulesets)
{