1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 07:42:57 +08:00

Use synchronous total score retrieval for bindable

This commit is contained in:
smoogipoo 2021-08-31 20:43:50 +09:00
parent bfcadcc4ac
commit cfcf3d7507

View File

@ -195,9 +195,6 @@ namespace osu.Game.Scoring
{
public readonly Bindable<ScoringMode> ScoringMode = new Bindable<ScoringMode>();
private readonly ScoreInfo score;
private readonly ScoreManager scoreManager;
/// <summary>
/// Creates a new <see cref="TotalScoreBindable"/>.
/// </summary>
@ -205,20 +202,7 @@ namespace osu.Game.Scoring
/// <param name="scoreManager">The <see cref="ScoreManager"/>.</param>
public TotalScoreBindable(ScoreInfo score, ScoreManager scoreManager)
{
this.score = score;
this.scoreManager = scoreManager;
ScoringMode.BindValueChanged(onScoringModeChanged, true);
}
private CancellationTokenSource difficultyCancellationSource;
private void onScoringModeChanged(ValueChangedEvent<ScoringMode> mode)
{
difficultyCancellationSource?.Cancel();
difficultyCancellationSource = new CancellationTokenSource();
scoreManager.GetTotalScoreAsync(score, difficultyCancellationSource.Token).ContinueWith(s => Value = s.Result, TaskContinuationOptions.OnlyOnRanToCompletion);
ScoringMode.BindValueChanged(_ => Value = scoreManager.GetTotalScore(score), true);
}
}