mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 06:42:56 +08:00
Use Bindable for ScoresContainer
This commit is contained in:
parent
3655f88180
commit
32b2f5e330
@ -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();
|
||||
|
@ -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();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user