1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Tidy up dialog and deletion flow

This commit is contained in:
Dean Herbert 2022-09-02 17:07:09 +09:00
parent 605108c938
commit 9fd8067e11
3 changed files with 41 additions and 67 deletions

View File

@ -0,0 +1,18 @@
// 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 System;
using osu.Game.Beatmaps;
using osu.Game.Overlays.Dialog;
namespace osu.Game.Screens.Edit
{
public class DeleteDifficultyConfirmationDialog : DeleteConfirmationDialog
{
public DeleteDifficultyConfirmationDialog(BeatmapInfo beatmapInfo, Action deleteAction)
{
BodyText = $"\"{beatmapInfo.DifficultyName}\" difficulty";
DeleteAction = deleteAction;
}
}
}

View File

@ -879,35 +879,6 @@ namespace osu.Game.Screens.Edit
clock.SeekForward(!trackPlaying, amount);
}
private void exportBeatmap()
{
Save();
new LegacyBeatmapExporter(storage).Export(Beatmap.Value.BeatmapSetInfo);
}
private void deleteDifficulty()
{
dialogOverlay?.Push(new PromptForDifficultyDeleteDialog(confirmDifficultyHide, confirmDifficultyDelete, () => { }));
}
private void confirmDifficultyHide()
{
var current = playableBeatmap.BeatmapInfo;
if (current is null) return;
beatmapManager.Hide(current);
switchBeatmapOrExit(current.BeatmapSet);
}
private void confirmDifficultyDelete()
{
var current = playableBeatmap.BeatmapInfo;
if (current is null) return;
beatmapManager.DeleteDifficultyImmediately(current);
switchBeatmapOrExit(current.BeatmapSet);
}
private void switchBeatmapOrExit([CanBeNull] BeatmapSetInfo setInfo)
{
if (setInfo is null || setInfo.Beatmaps.Count() <= 1)
@ -948,6 +919,29 @@ namespace osu.Game.Screens.Edit
return fileMenuItems;
}
private void exportBeatmap()
{
Save();
new LegacyBeatmapExporter(storage).Export(Beatmap.Value.BeatmapSetInfo);
}
private void deleteDifficulty()
{
if (dialogOverlay == null)
delete();
else
dialogOverlay.Push(new DeleteDifficultyConfirmationDialog(Beatmap.Value.BeatmapInfo, delete));
void delete()
{
var current = playableBeatmap.BeatmapInfo;
if (current is null) return;
beatmapManager.DeleteDifficultyImmediately(current);
switchBeatmapOrExit(current.BeatmapSet);
}
}
private EditorMenuItem createDifficultyCreationMenu()
{
var rulesetItems = new List<MenuItem>();

View File

@ -1,38 +0,0 @@
// 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 System;
using osu.Framework.Graphics.Sprites;
using osu.Game.Overlays.Dialog;
namespace osu.Game.Screens.Edit
{
public class PromptForDifficultyDeleteDialog : PopupDialog
{
public PromptForDifficultyDeleteDialog(Action hide, Action delete, Action cancel)
{
HeaderText = "Are you sure you want to delete this difficulty?";
Icon = FontAwesome.Regular.TrashAlt;
Buttons = new PopupDialogButton[]
{
new PopupDialogOkButton
{
Text = @"Hide this difficulty instead (recommended)",
Action = hide
},
new PopupDialogDangerousButton
{
Text = @"Yes, DELETE this difficulty!",
Action = delete
},
new PopupDialogCancelButton
{
Text = @"Oops, continue editing",
Action = cancel
},
};
}
}
}