1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-30 06:12:58 +08:00

Fix editor not prompting before saving beatmap for export

This commit is contained in:
Dean Herbert 2023-10-25 14:33:06 +09:00
parent 34505b3933
commit 6934e045df
No known key found for this signature in database
3 changed files with 31 additions and 20 deletions

View File

@ -138,7 +138,7 @@ namespace osu.Game.Tests.Visual.Editing
InputManager.MoveMouseTo(button); InputManager.MoveMouseTo(button);
InputManager.Click(MouseButton.Left); InputManager.Click(MouseButton.Left);
}); });
AddUntilStep("save prompt shown", () => DialogOverlay.CurrentDialog is SaveBeforeGameplayTestDialog); AddUntilStep("save prompt shown", () => DialogOverlay.CurrentDialog is SaveRequiredPopupDialog);
AddStep("dismiss prompt", () => AddStep("dismiss prompt", () =>
{ {
@ -165,7 +165,7 @@ namespace osu.Game.Tests.Visual.Editing
InputManager.MoveMouseTo(button); InputManager.MoveMouseTo(button);
InputManager.Click(MouseButton.Left); InputManager.Click(MouseButton.Left);
}); });
AddUntilStep("save prompt shown", () => DialogOverlay.CurrentDialog is SaveBeforeGameplayTestDialog); AddUntilStep("save prompt shown", () => DialogOverlay.CurrentDialog is SaveRequiredPopupDialog);
AddStep("save changes", () => DialogOverlay.CurrentDialog.PerformOkAction()); AddStep("save changes", () => DialogOverlay.CurrentDialog.PerformOkAction());

View File

@ -425,7 +425,7 @@ namespace osu.Game.Screens.Edit
{ {
if (HasUnsavedChanges) if (HasUnsavedChanges)
{ {
dialogOverlay.Push(new SaveBeforeGameplayTestDialog(() => dialogOverlay.Push(new SaveRequiredPopupDialog("The beatmap will be saved in order to test it.", () =>
{ {
if (!Save()) return; if (!Save()) return;
@ -1018,25 +1018,36 @@ namespace osu.Game.Screens.Edit
{ {
var exportItems = new List<MenuItem> var exportItems = new List<MenuItem>
{ {
new EditorMenuItem(EditorStrings.ExportForEditing, MenuItemType.Standard, exportBeatmap) { Action = { Disabled = !RuntimeInfo.IsDesktop } }, new EditorMenuItem(EditorStrings.ExportForEditing, MenuItemType.Standard, () => exportBeatmap(false)) { Action = { Disabled = !RuntimeInfo.IsDesktop } },
new EditorMenuItem(EditorStrings.ExportForCompatibility, MenuItemType.Standard, exportLegacyBeatmap) { Action = { Disabled = !RuntimeInfo.IsDesktop } }, new EditorMenuItem(EditorStrings.ExportForCompatibility, MenuItemType.Standard, () => exportBeatmap(true)) { Action = { Disabled = !RuntimeInfo.IsDesktop } },
}; };
return new EditorMenuItem(CommonStrings.Export) { Items = exportItems }; return new EditorMenuItem(CommonStrings.Export) { Items = exportItems };
} }
private void exportBeatmap() private void exportBeatmap(bool legacy)
{ {
if (!Save()) return; if (HasUnsavedChanges)
{
dialogOverlay.Push(new SaveRequiredPopupDialog("The beatmap will be saved in order to export it.", () =>
{
if (!Save()) return;
beatmapManager.Export(Beatmap.Value.BeatmapSetInfo); runExport();
} }));
}
else
{
runExport();
}
private void exportLegacyBeatmap() void runExport()
{ {
if (!Save()) return; if (legacy)
beatmapManager.ExportLegacy(Beatmap.Value.BeatmapSetInfo);
beatmapManager.ExportLegacy(Beatmap.Value.BeatmapSetInfo); else
beatmapManager.Export(Beatmap.Value.BeatmapSetInfo);
}
} }
/// <summary> /// <summary>

View File

@ -1,17 +1,17 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Overlays.Dialog; using osu.Game.Overlays.Dialog;
namespace osu.Game.Screens.Edit.GameplayTest namespace osu.Game.Screens.Edit
{ {
public partial class SaveBeforeGameplayTestDialog : PopupDialog public partial class SaveRequiredPopupDialog : PopupDialog
{ {
public SaveBeforeGameplayTestDialog(Action saveAndPreview) public SaveRequiredPopupDialog(string headerText, Action saveAndAction)
{ {
HeaderText = "The beatmap will be saved in order to test it."; HeaderText = headerText;
Icon = FontAwesome.Regular.Save; Icon = FontAwesome.Regular.Save;
@ -20,7 +20,7 @@ namespace osu.Game.Screens.Edit.GameplayTest
new PopupDialogOkButton new PopupDialogOkButton
{ {
Text = "Sounds good, let's go!", Text = "Sounds good, let's go!",
Action = saveAndPreview Action = saveAndAction
}, },
new PopupDialogCancelButton new PopupDialogCancelButton
{ {