osu/osu.Game/Screens/Select/BeatmapClearScoresDialog.cs

44 lines
1.5 KiB
C#
Raw Normal View History

2019-03-01 01:52:53 +00:00
// 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.
2019-01-04 19:13:32 +00:00
using osu.Framework.Allocation;
using osu.Game.Beatmaps;
using osu.Game.Overlays.Dialog;
using osu.Game.Scoring;
using System;
using System.Linq;
2019-03-01 01:09:03 +00:00
using System.Threading.Tasks;
using osu.Framework.Graphics.Sprites;
2019-01-04 19:13:32 +00:00
namespace osu.Game.Screens.Select
{
2019-01-04 19:32:52 +00:00
public class BeatmapClearScoresDialog : PopupDialog
2019-01-04 19:13:32 +00:00
{
[Resolved]
private ScoreManager scoreManager { get; set; }
2019-01-04 19:13:32 +00:00
2021-10-02 15:55:29 +00:00
public BeatmapClearScoresDialog(BeatmapInfo beatmapInfo, Action onCompletion)
2019-01-04 19:13:32 +00:00
{
2021-10-02 15:55:29 +00:00
BodyText = $@"{beatmapInfo.Metadata?.Artist} - {beatmapInfo.Metadata?.Title}";
2019-04-02 10:55:24 +00:00
Icon = FontAwesome.Solid.Eraser;
2019-03-01 00:49:36 +00:00
HeaderText = @"Clearing all local scores. Are you sure?";
2019-01-04 19:13:32 +00:00
Buttons = new PopupDialogButton[]
{
new PopupDialogOkButton
{
Text = @"Yes. Please.",
Action = () =>
{
2021-10-02 15:55:29 +00:00
Task.Run(() => scoreManager.Delete(scoreManager.QueryScores(s => !s.DeletePending && s.Beatmap.ID == beatmapInfo.ID).ToList()))
.ContinueWith(_ => onCompletion);
2019-01-04 19:13:32 +00:00
}
},
new PopupDialogCancelButton
{
Text = @"No, I'm still attached.",
},
};
}
}
}