2019-03-01 09:52:53 +08: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-05 03:13:32 +08: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 09:09:03 +08:00
|
|
|
|
using System.Threading.Tasks;
|
2019-03-27 18:29:27 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
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}";
|
2019-04-02 18:55:24 +08:00
|
|
|
|
Icon = FontAwesome.Solid.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()))
|
2019-03-01 19:52:34 +08:00
|
|
|
|
.ContinueWith(_ => 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
|
|
|
|
|
2019-12-17 11:25:28 +08:00
|
|
|
|
public BeatmapClearScoresDialog(ScoreInfo score, Action onCompletion)
|
|
|
|
|
{
|
|
|
|
|
string accuracy = string.Format(score?.Accuracy % 1 == 0 ? @"{0:P0}" : @"{0:P2}", score?.Accuracy);
|
|
|
|
|
|
|
|
|
|
BodyText = $@"{score?.Beatmap?.Metadata?.Artist} - {score?.Beatmap?.Metadata?.Title} {Environment.NewLine} {score?.User} - Rank: {score?.Rank} - Max Combo: {score?.MaxCombo} - {accuracy} - {score?.Date.Date.ToShortDateString()}";
|
|
|
|
|
|
|
|
|
|
Icon = FontAwesome.Solid.Eraser;
|
|
|
|
|
HeaderText = @"Clearing this local score. Are you sure?";
|
|
|
|
|
Buttons = new PopupDialogButton[]
|
|
|
|
|
{
|
|
|
|
|
new PopupDialogOkButton
|
|
|
|
|
{
|
|
|
|
|
Text = @"Yes. Please.",
|
2019-12-18 04:56:30 +08:00
|
|
|
|
Action = (() => scoreManager.Delete(score)) + onCompletion
|
2019-12-17 11:25:28 +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
|
|
|
|
}
|
|
|
|
|
}
|