From e6fad601cc2106e983d13ba9a2383f8500b917ba Mon Sep 17 00:00:00 2001 From: Micahel Kelly Date: Wed, 27 Jul 2022 19:15:43 +1000 Subject: [PATCH] Adds delete difficulty option to editor --- osu.Game/Screens/Edit/Editor.cs | 18 ++++++++++ .../Edit/PromptForDifficultyDeleteDialog.cs | 33 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 osu.Game/Screens/Edit/PromptForDifficultyDeleteDialog.cs diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 3e3940c5ba..5cee634fd8 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -849,6 +849,20 @@ namespace osu.Game.Screens.Edit new LegacyBeatmapExporter(storage).Export(Beatmap.Value.BeatmapSetInfo); } + private void deleteDifficulty() + { + dialogOverlay?.Push(new PromptForDifficultyDeleteDialog(confirmDifficultyDelete, () => { })); + } + + private void confirmDifficultyDelete() + { + var current = playableBeatmap.BeatmapInfo; + if (current is null) return; + + beatmapManager.Hide(current); + this.Exit(); + } + private void updateLastSavedHash() { lastSavedHash = changeHandler?.CurrentStateHash; @@ -869,6 +883,10 @@ namespace osu.Game.Screens.Edit fileMenuItems.Add(createDifficultyCreationMenu()); fileMenuItems.Add(createDifficultySwitchMenu()); + fileMenuItems.Add(new EditorMenuItemSpacer()); + + fileMenuItems.Add(new EditorMenuItem("Delete difficulty", MenuItemType.Standard, deleteDifficulty)); + fileMenuItems.Add(new EditorMenuItemSpacer()); fileMenuItems.Add(new EditorMenuItem("Exit", MenuItemType.Standard, this.Exit)); return fileMenuItems; diff --git a/osu.Game/Screens/Edit/PromptForDifficultyDeleteDialog.cs b/osu.Game/Screens/Edit/PromptForDifficultyDeleteDialog.cs new file mode 100644 index 0000000000..abf66d7a5b --- /dev/null +++ b/osu.Game/Screens/Edit/PromptForDifficultyDeleteDialog.cs @@ -0,0 +1,33 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using osu.Framework.Graphics.Sprites; +using osu.Game.Overlays.Dialog; + +namespace osu.Game.Screens.Edit +{ + public class PromptForDifficultyDeleteDialog : PopupDialog + { + public PromptForDifficultyDeleteDialog(Action delete, Action cancel) + { + HeaderText = "Are you sure you want to delete this difficulty?"; + + Icon = FontAwesome.Regular.Save; + + Buttons = new PopupDialogButton[] + { + new PopupDialogDangerousButton + { + Text = @"Yes delete this difficulty!", + Action = delete + }, + new PopupDialogCancelButton + { + Text = @"Oops, continue editing", + Action = cancel + }, + }; + } + } +}