Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "discard unsaved changes" operation to beatmap editor #32240

Merged
merged 3 commits into from
Mar 6, 2025

Conversation

bdach
Copy link
Collaborator

@bdach bdach commented Mar 5, 2025

2025-03-05.14-23-38.mp4

Apparently useful in modding workflows when you want to test out a few different variants of a thing.

Re-uses Ctrl-L binding from stable. Some folks may argue that the dialog makes the hotkey pointless, but I really do want to protect users from accidental data loss, and also if you want to power through it quickly, you can hit the 1 key when the dialog shows, which will bypass the hold-to-activate period (which wasn't intentional, but so many people want a bypass at this point that we're probably keeping that behaviour for power users).


@bdach bdach self-assigned this Mar 5, 2025
Apparently useful in modding workflows when you want to test out a few
different variants of a thing.

Re-uses `Ctrl-L` binding from stable. Some folks may argue that the
dialog makes the hotkey pointless, but I really do want to protect
users from accidental data loss, and also if you want to power through
it quickly, you can hit the 1 key when the dialog shows, which will
bypass the hold-to-activate period (which wasn't intentional, but so
many people want a bypass at this point that we're probably keeping that
behaviour for power users).
@bdach bdach force-pushed the discard-unsaved-changes branch from d8b634c to 3f461c0 Compare March 5, 2025 13:34
@@ -391,6 +392,10 @@ private void load(OsuConfigManager config)
{
undoMenuItem = new EditorMenuItem(CommonStrings.Undo, MenuItemType.Standard, Undo) { Hotkey = new Hotkey(PlatformAction.Undo) },
redoMenuItem = new EditorMenuItem(CommonStrings.Redo, MenuItemType.Standard, Redo) { Hotkey = new Hotkey(PlatformAction.Redo) },
discardChangesMenuItem = new EditorMenuItem("Discard unsaved changes", MenuItemType.Destructive, DiscardUnsavedChanges)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you intend to localise this one?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Editor needs a full localisation pass anyway (including figuring out how to make localisations of ruleset strings, by the way) so if I'm honest I kinda don't care about localisation there that much.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only asked because you added a localisable string for it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated to use the new localisation.

I have one remaining concern: I'd expect this to be under the file menu, not edit (historical reasoning):

diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs
index 80e1a656de..f56380a34d 100644
--- a/osu.Game/Screens/Edit/Editor.cs
+++ b/osu.Game/Screens/Edit/Editor.cs
@@ -392,10 +392,6 @@ private void load(OsuConfigManager config)
                                         {
                                             undoMenuItem = new EditorMenuItem(CommonStrings.Undo, MenuItemType.Standard, Undo) { Hotkey = new Hotkey(PlatformAction.Undo) },
                                             redoMenuItem = new EditorMenuItem(CommonStrings.Redo, MenuItemType.Standard, Redo) { Hotkey = new Hotkey(PlatformAction.Redo) },
-                                            discardChangesMenuItem = new EditorMenuItem(GlobalActionKeyBindingStrings.EditorDiscardUnsavedChanges, MenuItemType.Destructive, DiscardUnsavedChanges)
-                                            {
-                                                Hotkey = new Hotkey(GlobalAction.EditorDiscardUnsavedChanges)
-                                            },
                                             new OsuMenuItemSpacer(),
                                             cutMenuItem = new EditorMenuItem(CommonStrings.Cut, MenuItemType.Standard, Cut) { Hotkey = new Hotkey(PlatformAction.Cut) },
                                             copyMenuItem = new EditorMenuItem(CommonStrings.Copy, MenuItemType.Standard, Copy) { Hotkey = new Hotkey(PlatformAction.Copy) },
@@ -1273,6 +1269,11 @@ private IEnumerable<MenuItem> createFileMenuItems()
             saveRelatedMenuItems.Add(save);
             yield return save;
 
+            yield return discardChangesMenuItem = new EditorMenuItem(GlobalActionKeyBindingStrings.EditorDiscardUnsavedChanges, MenuItemType.Destructive, DiscardUnsavedChanges)
+            {
+                Hotkey = new Hotkey(GlobalAction.EditorDiscardUnsavedChanges)
+            };
+
             if (RuntimeInfo.OS != RuntimeInfo.Platform.Android)
             {
                 var export = createExportMenu();

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it to edit because I wanted it to be next to undo/redo as related, but 🤷

smoogipoo
smoogipoo previously approved these changes Mar 6, 2025
Copy link
Contributor

@smoogipoo smoogipoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm otherwise

@smoogipoo smoogipoo requested a review from peppy March 6, 2025 03:45
@peppy peppy merged commit 1506037 into ppy:master Mar 6, 2025
6 of 9 checks passed
@bdach bdach deleted the discard-unsaved-changes branch March 6, 2025 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants