1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 14:53:01 +08:00

Make operation run asynchronously

This commit is contained in:
Dean Herbert 2019-03-01 10:09:03 +09:00
parent 798bc1306b
commit acc2113027

View File

@ -8,20 +8,15 @@ using osu.Game.Overlays.Dialog;
using osu.Game.Scoring; using osu.Game.Scoring;
using System; using System;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
namespace osu.Game.Screens.Select namespace osu.Game.Screens.Select
{ {
public class BeatmapClearScoresDialog : PopupDialog public class BeatmapClearScoresDialog : PopupDialog
{ {
private ScoreManager manager; private ScoreManager scoreManager;
[BackgroundDependencyLoader] public BeatmapClearScoresDialog(BeatmapInfo beatmap, Action onCompletion)
private void load(ScoreManager scoreManager)
{
manager = scoreManager;
}
public BeatmapClearScoresDialog(BeatmapInfo beatmap, Action refresh)
{ {
BodyText = $@"{beatmap.Metadata?.Artist} - {beatmap.Metadata?.Title}"; BodyText = $@"{beatmap.Metadata?.Artist} - {beatmap.Metadata?.Title}";
Icon = FontAwesome.fa_eraser; Icon = FontAwesome.fa_eraser;
@ -33,8 +28,8 @@ namespace osu.Game.Screens.Select
Text = @"Yes. Please.", Text = @"Yes. Please.",
Action = () => Action = () =>
{ {
manager.Delete(manager.QueryScores(s => !s.DeletePending && s.Beatmap.ID == beatmap.ID).ToList()); Task.Run(() => scoreManager.Delete(scoreManager.QueryScores(s => !s.DeletePending && s.Beatmap.ID == beatmap.ID).ToList()))
refresh(); .ContinueWith(t => Schedule(onCompletion));
} }
}, },
new PopupDialogCancelButton new PopupDialogCancelButton
@ -43,5 +38,11 @@ namespace osu.Game.Screens.Select
}, },
}; };
} }
[BackgroundDependencyLoader]
private void load(ScoreManager scoreManager)
{
this.scoreManager = scoreManager;
}
} }
} }