1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Merge pull request #25223 from peppy/prompt-before-save-for-export

Fix editor not prompting before saving beatmap for export
This commit is contained in:
Bartłomiej Dach 2023-10-25 12:03:26 +02:00 committed by GitHub
commit 5e059a362f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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.Click(MouseButton.Left);
});
AddUntilStep("save prompt shown", () => DialogOverlay.CurrentDialog is SaveBeforeGameplayTestDialog);
AddUntilStep("save prompt shown", () => DialogOverlay.CurrentDialog is SaveRequiredPopupDialog);
AddStep("dismiss prompt", () =>
{
@ -165,7 +165,7 @@ namespace osu.Game.Tests.Visual.Editing
InputManager.MoveMouseTo(button);
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());

View File

@ -425,7 +425,7 @@ namespace osu.Game.Screens.Edit
{
if (HasUnsavedChanges)
{
dialogOverlay.Push(new SaveBeforeGameplayTestDialog(() =>
dialogOverlay.Push(new SaveRequiredPopupDialog("The beatmap will be saved in order to test it.", () =>
{
if (!Save()) return;
@ -1018,25 +1018,36 @@ namespace osu.Game.Screens.Edit
{
var exportItems = new List<MenuItem>
{
new EditorMenuItem(EditorStrings.ExportForEditing, MenuItemType.Standard, exportBeatmap) { Action = { Disabled = !RuntimeInfo.IsDesktop } },
new EditorMenuItem(EditorStrings.ExportForCompatibility, MenuItemType.Standard, exportLegacyBeatmap) { Action = { Disabled = !RuntimeInfo.IsDesktop } },
new EditorMenuItem(EditorStrings.ExportForEditing, MenuItemType.Standard, () => exportBeatmap(false)) { Action = { Disabled = !RuntimeInfo.IsDesktop } },
new EditorMenuItem(EditorStrings.ExportForCompatibility, MenuItemType.Standard, () => exportBeatmap(true)) { Action = { Disabled = !RuntimeInfo.IsDesktop } },
};
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()
{
if (!Save()) return;
beatmapManager.ExportLegacy(Beatmap.Value.BeatmapSetInfo);
void runExport()
{
if (legacy)
beatmapManager.ExportLegacy(Beatmap.Value.BeatmapSetInfo);
else
beatmapManager.Export(Beatmap.Value.BeatmapSetInfo);
}
}
/// <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.
using System;
using osu.Framework.Graphics.Sprites;
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;
@ -20,7 +20,7 @@ namespace osu.Game.Screens.Edit.GameplayTest
new PopupDialogOkButton
{
Text = "Sounds good, let's go!",
Action = saveAndPreview
Action = saveAndAction
},
new PopupDialogCancelButton
{