From 2cfd54ca0d577da1872f74b92c83596a6001e1d1 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 11 Nov 2019 18:27:48 +0300 Subject: [PATCH] Handle scope changing --- .../BeatmapSet/Scores/ScoresContainer.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index acf0f08956..8058d0fc0f 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -15,6 +15,7 @@ using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Framework.Bindables; using osu.Game.Rulesets; +using osu.Game.Screens.Select.Leaderboards; namespace osu.Game.Overlays.BeatmapSet.Scores { @@ -24,6 +25,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores public readonly Bindable Beatmap = new Bindable(); private readonly Bindable ruleset = new Bindable(); + private readonly Bindable scope = new Bindable(); private readonly Box background; private readonly ScoreTable scoreTable; @@ -97,7 +99,10 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Spacing = new Vector2(0, spacing), Children = new Drawable[] { - new LeaderboardScopeSelector(), + new LeaderboardScopeSelector + { + Current = { BindTarget = scope } + }, modSelector = new LeaderboardModSelector { Ruleset = { BindTarget = ruleset } @@ -135,6 +140,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores protected override void LoadComplete() { base.LoadComplete(); + scope.BindValueChanged(_ => getScores()); Beatmap.BindValueChanged(onBeatmapChanged, true); } @@ -147,21 +153,21 @@ namespace osu.Game.Overlays.BeatmapSet.Scores else ruleset.Value = beatmapRuleset; - getScores(beatmap.NewValue); + getScores(); } - private void getScores(BeatmapInfo beatmap) + private void getScores() { getScoresRequest?.Cancel(); getScoresRequest = null; Scores = null; - if (beatmap?.OnlineBeatmapID.HasValue != true || beatmap.Status <= BeatmapSetOnlineStatus.Pending) + if (Beatmap.Value?.OnlineBeatmapID.HasValue != true || Beatmap.Value.Status <= BeatmapSetOnlineStatus.Pending) return; loadingAnimation.Show(); - getScoresRequest = new GetScoresRequest(beatmap, beatmap.Ruleset); + getScoresRequest = new GetScoresRequest(Beatmap.Value, Beatmap.Value.Ruleset, scope.Value); getScoresRequest.Success += scores => { loadingAnimation.Hide();