mirror of
https://github.com/ppy/osu
synced 2025-01-24 23:03:14 +00:00
Use asynchronous loading
This commit is contained in:
parent
764513feea
commit
d83d93ee66
@ -10,6 +10,7 @@ using osu.Game.Online.API.Requests.Responses;
|
|||||||
using osu.Game.Online.Leaderboards;
|
using osu.Game.Online.Leaderboards;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Select.Details
|
namespace osu.Game.Screens.Select.Details
|
||||||
{
|
{
|
||||||
@ -66,6 +67,8 @@ namespace osu.Game.Screens.Select.Details
|
|||||||
Score.BindValueChanged(onScoreChanged);
|
Score.BindValueChanged(onScoreChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CancellationTokenSource loadScoreCancellation;
|
||||||
|
|
||||||
private void onScoreChanged(ValueChangedEvent<APILegacyUserTopScoreInfo> score)
|
private void onScoreChanged(ValueChangedEvent<APILegacyUserTopScoreInfo> score)
|
||||||
{
|
{
|
||||||
var newScore = score.NewValue;
|
var newScore = score.NewValue;
|
||||||
@ -76,12 +79,17 @@ namespace osu.Game.Screens.Select.Details
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
scoreContainer.Child = new LeaderboardScore(newScore.Score, newScore.Position)
|
scoreContainer.Clear();
|
||||||
|
loadScoreCancellation?.Cancel();
|
||||||
|
|
||||||
|
LoadComponentAsync(new LeaderboardScore(newScore.Score, newScore.Position)
|
||||||
{
|
{
|
||||||
Action = () => ScoreSelected?.Invoke(newScore.Score)
|
Action = () => ScoreSelected?.Invoke(newScore.Score)
|
||||||
};
|
}, drawableScore =>
|
||||||
|
{
|
||||||
Show();
|
scoreContainer.Child = drawableScore;
|
||||||
|
Show();
|
||||||
|
}, (loadScoreCancellation = new CancellationTokenSource()).Token);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PopIn()
|
protected override void PopIn()
|
||||||
|
Loading…
Reference in New Issue
Block a user