1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 16:27:26 +08:00
osu-lazer/osu.Game/Screens/Select/BeatmapClearScoresDialog.cs

49 lines
1.6 KiB
C#
Raw Normal View History

2019-01-05 03:13:32 +08:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Overlays.Dialog;
using osu.Game.Scoring;
using System;
using System.Linq;
2019-03-01 09:09:03 +08:00
using System.Threading.Tasks;
2019-01-05 03:13:32 +08:00
namespace osu.Game.Screens.Select
{
2019-01-05 03:32:52 +08:00
public class BeatmapClearScoresDialog : PopupDialog
2019-01-05 03:13:32 +08:00
{
2019-03-01 09:09:03 +08:00
private ScoreManager scoreManager;
2019-01-05 03:13:32 +08:00
2019-03-01 09:09:03 +08:00
public BeatmapClearScoresDialog(BeatmapInfo beatmap, Action onCompletion)
2019-01-05 03:13:32 +08:00
{
BodyText = $@"{beatmap.Metadata?.Artist} - {beatmap.Metadata?.Title}";
Icon = FontAwesome.fa_eraser;
2019-03-01 08:49:36 +08:00
HeaderText = @"Clearing all local scores. Are you sure?";
2019-01-05 03:13:32 +08:00
Buttons = new PopupDialogButton[]
{
new PopupDialogOkButton
{
Text = @"Yes. Please.",
Action = () =>
{
2019-03-01 09:09:03 +08:00
Task.Run(() => scoreManager.Delete(scoreManager.QueryScores(s => !s.DeletePending && s.Beatmap.ID == beatmap.ID).ToList()))
.ContinueWith(t => Schedule(onCompletion));
2019-01-05 03:13:32 +08:00
}
},
new PopupDialogCancelButton
{
Text = @"No, I'm still attached.",
},
};
}
2019-03-01 09:09:03 +08:00
[BackgroundDependencyLoader]
private void load(ScoreManager scoreManager)
{
this.scoreManager = scoreManager;
}
2019-01-05 03:13:32 +08:00
}
}