1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 21:07:33 +08:00

Use local bindable

This commit is contained in:
Dean Herbert 2017-12-21 23:48:35 +09:00
parent 4bd2c7e95f
commit 65e6206d06

View File

@ -18,6 +18,7 @@ using osu.Game.Rulesets.Scoring;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests;
using System.Linq; using System.Linq;
using osu.Framework.Configuration;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Framework.Logging; using osu.Framework.Logging;
@ -35,6 +36,8 @@ namespace osu.Game.Screens.Select.Leaderboards
private FillFlowContainer<LeaderboardScore> scrollFlow; private FillFlowContainer<LeaderboardScore> scrollFlow;
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
public Action<Score> ScoreSelected; public Action<Score> ScoreSelected;
private readonly LoadingAnimation loading; private readonly LoadingAnimation loading;
@ -185,7 +188,9 @@ namespace osu.Game.Screens.Select.Leaderboards
this.osuGame = osuGame; this.osuGame = osuGame;
if (osuGame != null) if (osuGame != null)
osuGame.Ruleset.ValueChanged += handleRulesetChange; ruleset.BindTo(osuGame.Ruleset);
ruleset.ValueChanged += r => updateScores();
if (api != null) if (api != null)
api.OnStateChange += handleApiStateChange; api.OnStateChange += handleApiStateChange;
@ -195,17 +200,12 @@ namespace osu.Game.Screens.Select.Leaderboards
{ {
base.Dispose(isDisposing); base.Dispose(isDisposing);
if (osuGame != null)
osuGame.Ruleset.ValueChanged -= handleRulesetChange;
if (api != null) if (api != null)
api.OnStateChange -= handleApiStateChange; api.OnStateChange -= handleApiStateChange;
} }
private GetScoresRequest getScoresRequest; private GetScoresRequest getScoresRequest;
private void handleRulesetChange(RulesetInfo ruleset) => updateScores();
private void handleApiStateChange(APIState oldState, APIState newState) private void handleApiStateChange(APIState oldState, APIState newState)
{ {
if (Scope == LeaderboardScope.Local) if (Scope == LeaderboardScope.Local)