1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-17 02:12:54 +08:00
osu-lazer/osu.Game/Screens/Select/BeatmapClearScoresDialog.cs
2021-10-04 17:35:53 +09:00

44 lines
1.5 KiB
C#

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Game.Beatmaps;
using osu.Game.Overlays.Dialog;
using osu.Game.Scoring;
using System;
using System.Linq;
using System.Threading.Tasks;
using osu.Framework.Graphics.Sprites;
namespace osu.Game.Screens.Select
{
public class BeatmapClearScoresDialog : PopupDialog
{
[Resolved]
private ScoreManager scoreManager { get; set; }
public BeatmapClearScoresDialog(BeatmapInfo beatmapInfo, Action onCompletion)
{
BodyText = $@"{beatmapInfo.Metadata?.Artist} - {beatmapInfo.Metadata?.Title}";
Icon = FontAwesome.Solid.Eraser;
HeaderText = @"Clearing all local scores. Are you sure?";
Buttons = new PopupDialogButton[]
{
new PopupDialogOkButton
{
Text = @"Yes. Please.",
Action = () =>
{
Task.Run(() => scoreManager.Delete(scoreManager.QueryScores(s => !s.DeletePending && s.BeatmapInfo.ID == beatmapInfo.ID).ToList()))
.ContinueWith(_ => onCompletion);
}
},
new PopupDialogCancelButton
{
Text = @"No, I'm still attached.",
},
};
}
}
}