mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 09:57:21 +09: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.Beatmaps;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.BeatmapSet.Scores
|
namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||||
{
|
{
|
||||||
@ -20,6 +21,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
{
|
{
|
||||||
private const int spacing = 15;
|
private const int spacing = 15;
|
||||||
|
|
||||||
|
public readonly Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
|
||||||
|
|
||||||
private readonly Box background;
|
private readonly Box background;
|
||||||
private readonly ScoreTable scoreTable;
|
private readonly ScoreTable scoreTable;
|
||||||
private readonly FillFlowContainer topScoresContainer;
|
private readonly FillFlowContainer topScoresContainer;
|
||||||
@ -30,22 +33,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
|
|
||||||
private GetScoresRequest getScoresRequest;
|
private GetScoresRequest getScoresRequest;
|
||||||
|
|
||||||
private BeatmapInfo beatmap;
|
|
||||||
|
|
||||||
public BeatmapInfo Beatmap
|
|
||||||
{
|
|
||||||
get => beatmap;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (beatmap == value)
|
|
||||||
return;
|
|
||||||
|
|
||||||
beatmap = value;
|
|
||||||
|
|
||||||
getScores(beatmap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected APILegacyScores Scores
|
protected APILegacyScores Scores
|
||||||
{
|
{
|
||||||
set
|
set
|
||||||
@ -125,18 +112,24 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
background.Colour = colours.Gray2;
|
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?.Cancel();
|
||||||
getScoresRequest = null;
|
getScoresRequest = null;
|
||||||
|
|
||||||
Scores = null;
|
Scores = null;
|
||||||
|
|
||||||
if (beatmap?.OnlineBeatmapID.HasValue != true || beatmap.Status <= BeatmapSetOnlineStatus.Pending)
|
if (beatmap.NewValue?.OnlineBeatmapID.HasValue != true || beatmap.NewValue.Status <= BeatmapSetOnlineStatus.Pending)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
loadingAnimation.Show();
|
loadingAnimation.Show();
|
||||||
getScoresRequest = new GetScoresRequest(beatmap, beatmap.Ruleset);
|
getScoresRequest = new GetScoresRequest(beatmap.NewValue, beatmap.NewValue.Ruleset);
|
||||||
getScoresRequest.Success += scores =>
|
getScoresRequest.Success += scores =>
|
||||||
{
|
{
|
||||||
loadingAnimation.Hide();
|
loadingAnimation.Hide();
|
||||||
|
@ -59,7 +59,10 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
Header = new Header(),
|
Header = new Header(),
|
||||||
info = new Info(),
|
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 =>
|
Header.Picker.Beatmap.ValueChanged += b =>
|
||||||
{
|
{
|
||||||
info.Beatmap = b.NewValue;
|
info.Beatmap = b.NewValue;
|
||||||
scoreContainer.Beatmap = b.NewValue;
|
|
||||||
|
|
||||||
scroll.ScrollToStart();
|
scroll.ScrollToStart();
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user