1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 10:07:36 +08:00

Use Bindable for ScoresContainer

This commit is contained in:
Andrei Zavatski 2019-11-11 18:10:25 +03:00
parent 3655f88180
commit 32b2f5e330
2 changed files with 16 additions and 21 deletions

View File

@ -13,6 +13,7 @@ using osu.Game.Online.API.Requests.Responses;
using osu.Game.Beatmaps;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Framework.Bindables;
namespace osu.Game.Overlays.BeatmapSet.Scores
{
@ -20,6 +21,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{
private const int spacing = 15;
public readonly Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
private readonly Box background;
private readonly ScoreTable scoreTable;
private readonly FillFlowContainer topScoresContainer;
@ -30,22 +33,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
private GetScoresRequest getScoresRequest;
private BeatmapInfo beatmap;
public BeatmapInfo Beatmap
{
get => beatmap;
set
{
if (beatmap == value)
return;
beatmap = value;
getScores(beatmap);
}
}
protected APILegacyScores Scores
{
set
@ -125,18 +112,24 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
background.Colour = colours.Gray2;
}
private void getScores(BeatmapInfo beatmap)
protected override void LoadComplete()
{
base.LoadComplete();
Beatmap.BindValueChanged(getScores, true);
}
private void getScores(ValueChangedEvent<BeatmapInfo> beatmap)
{
getScoresRequest?.Cancel();
getScoresRequest = null;
Scores = null;
if (beatmap?.OnlineBeatmapID.HasValue != true || beatmap.Status <= BeatmapSetOnlineStatus.Pending)
if (beatmap.NewValue?.OnlineBeatmapID.HasValue != true || beatmap.NewValue.Status <= BeatmapSetOnlineStatus.Pending)
return;
loadingAnimation.Show();
getScoresRequest = new GetScoresRequest(beatmap, beatmap.Ruleset);
getScoresRequest = new GetScoresRequest(beatmap.NewValue, beatmap.NewValue.Ruleset);
getScoresRequest.Success += scores =>
{
loadingAnimation.Hide();

View File

@ -59,7 +59,10 @@ namespace osu.Game.Overlays
{
Header = new Header(),
info = new Info(),
scoreContainer = new ScoresContainer(),
scoreContainer = new ScoresContainer
{
Beatmap = { BindTarget = Header.Picker.Beatmap }
}
},
},
},
@ -71,7 +74,6 @@ namespace osu.Game.Overlays
Header.Picker.Beatmap.ValueChanged += b =>
{
info.Beatmap = b.NewValue;
scoreContainer.Beatmap = b.NewValue;
scroll.ScrollToStart();
};