mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 09:57:21 +09:00
Add cancellation support
This commit is contained in:
parent
37a659b2af
commit
5cdc8d2e7b
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -135,9 +136,13 @@ namespace osu.Game.Scoring
|
|||||||
}
|
}
|
||||||
|
|
||||||
private IBindable<StarDifficulty> difficultyBindable;
|
private IBindable<StarDifficulty> difficultyBindable;
|
||||||
|
private CancellationTokenSource difficultyCancellationSource;
|
||||||
|
|
||||||
private void onScoringModeChanged(ValueChangedEvent<ScoringMode> mode)
|
private void onScoringModeChanged(ValueChangedEvent<ScoringMode> mode)
|
||||||
{
|
{
|
||||||
|
difficultyCancellationSource?.Cancel();
|
||||||
|
difficultyCancellationSource = null;
|
||||||
|
|
||||||
if (score.Beatmap == null)
|
if (score.Beatmap == null)
|
||||||
{
|
{
|
||||||
Value = score.TotalScore;
|
Value = score.TotalScore;
|
||||||
@ -156,7 +161,7 @@ namespace osu.Game.Scoring
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We can compute the max combo locally after the async beatmap difficulty computation.
|
// We can compute the max combo locally after the async beatmap difficulty computation.
|
||||||
difficultyBindable = difficulties().GetBindableDifficulty(score.Beatmap, score.Ruleset, score.Mods);
|
difficultyBindable = difficulties().GetBindableDifficulty(score.Beatmap, score.Ruleset, score.Mods, (difficultyCancellationSource = new CancellationTokenSource()).Token);
|
||||||
difficultyBindable.BindValueChanged(d => updateScore(d.NewValue.MaxCombo), true);
|
difficultyBindable.BindValueChanged(d => updateScore(d.NewValue.MaxCombo), true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user