1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 14:13:18 +08:00

added confirmation dialog for Delete ALL beatmaps

This commit is contained in:
Aergwyn 2017-12-08 14:27:07 +01:00
parent 7584c7df53
commit c97646bea6
3 changed files with 59 additions and 3 deletions

View File

@ -0,0 +1,46 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Overlays.Dialog;
namespace osu.Game.Overlays.Settings.Sections.Maintenance
{
public class DeleteAllBeatmapsDialog : PopupDialog
{
private BeatmapManager manager;
[BackgroundDependencyLoader]
private void load(BeatmapManager beatmapManager)
{
manager = beatmapManager;
}
public DeleteAllBeatmapsDialog(Action deleteAction)
{
BodyText = "Everything?";
Icon = FontAwesome.fa_trash_o;
HeaderText = @"Confirm deletion of";
Buttons = new PopupDialogButton[]
{
new PopupDialogOkButton
{
Text = @"Yes. Go for it.",
Action = deleteAction
},
new PopupDialogCancelButton
{
Text = @"No! Abort mission!",
},
};
}
}
}

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq;
using System.Threading.Tasks;
using osu.Framework.Allocation;
@ -16,11 +17,15 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
private TriangleButton deleteButton;
private TriangleButton restoreButton;
private DialogOverlay dialogOverlay;
protected override string Header => "General";
[BackgroundDependencyLoader]
private void load(BeatmapManager beatmaps)
private void load(BeatmapManager beatmaps, DialogOverlay dialog)
{
dialogOverlay = dialog;
Children = new Drawable[]
{
importButton = new SettingsButton
@ -38,8 +43,12 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
Text = "Delete ALL beatmaps",
Action = () =>
{
deleteButton.Enabled.Value = false;
Task.Run(() => beatmaps.DeleteAll()).ContinueWith(t => Schedule(() => deleteButton.Enabled.Value = true));
Action deletion = delegate
{
deleteButton.Enabled.Value = false;
Task.Run(() => beatmaps.DeleteAll()).ContinueWith(t => Schedule(() => deleteButton.Enabled.Value = true));
};
dialogOverlay?.Push(new DeleteAllBeatmapsDialog(deletion));
}
},
restoreButton = new SettingsButton

View File

@ -300,6 +300,7 @@
<Compile Include="Overlays\Profile\Sections\Ranks\PaginatedScoreContainer.cs" />
<Compile Include="Overlays\Profile\Sections\Ranks\DrawableTotalScore.cs" />
<Compile Include="Overlays\Profile\Sections\Ranks\ScoreModsContainer.cs" />
<Compile Include="Overlays\Settings\Sections\Maintenance\DeleteAllBeatmapsDialog.cs" />
<Compile Include="Overlays\Settings\SettingsButton.cs" />
<Compile Include="Screens\Edit\Components\BottomBarContainer.cs" />
<Compile Include="Screens\Edit\Components\PlaybackControl.cs" />