From 5641cf3ebd7e8d9a3c001f71f913df3ced84ec73 Mon Sep 17 00:00:00 2001 From: Abdiel Lopez <48071553+PaperPrototype@users.noreply.github.com> Date: Sat, 11 Jul 2026 19:02:17 -0400 Subject: [PATCH] CTRL + S prompts saving default Untitled Scene in blank project --- Prowl.Editor/Core/EditorApplication.cs | 40 ++++++++------------------ Prowl.Editor/Projects/SaveManager.cs | 8 ++++++ 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/Prowl.Editor/Core/EditorApplication.cs b/Prowl.Editor/Core/EditorApplication.cs index 0e2e5ca8b..08a8e5791 100644 --- a/Prowl.Editor/Core/EditorApplication.cs +++ b/Prowl.Editor/Core/EditorApplication.cs @@ -249,6 +249,10 @@ public override void Initialize() } if (EditorSceneManager.Save()) return Loc.Get("save.scene", new { name = Runtime.Resources.Scene.Current?.Name ?? "Untitled" }); + + // No path yet - prompt for one, but never interrupt an unattended auto-save. + if (!SaveManager.IsAutoSave) + PromptSaveAs(); return null; }; SaveManager.OnSave += () => @@ -1308,6 +1312,7 @@ public void OpenPanelInstance(DockPanel panel, float width = 800, float height = /// public bool IsPanelOpen(Type panelType) => FindOpenPanel(panelType) != null; + /// Prompt for a scene file path and save the current scene there. private void PromptSaveAs() { if (Project.Current == null) return; @@ -1317,9 +1322,12 @@ private void PromptSaveAs() string rel = EditorAssetDatabase.NormalizePath( System.IO.Path.GetRelativePath(Project.Current.AssetsPath, path)); if (!rel.EndsWith(".scene")) rel += ".scene"; - EditorSceneManager.SaveAs(rel); + + if (EditorSceneManager.SaveAs(rel)) + Toasts.Success(Loc.Get("save.saved"), + Loc.Get("save.scene", new { name = Runtime.Resources.Scene.Current?.Name ?? "Untitled" })); }, Project.Current.AssetsPath, - new[] { "*.scene" }, new[] { "Scene Files (*.scene)" }); + new[] { "*.scene" }, new[] { Loc.Get("editor.filter_scene") }); } // ================================================================ @@ -1348,33 +1356,9 @@ private void RegisterMenus() MenuRegistry.Register($"{file}/{Loc.Get("menu.file.save_scene")}", () => { if (!EditorSceneManager.Save()) - { - // No path yet prompt Save As - if (Project.Current == null) return; - EditorApplication.OpenFileDialog(FileDialogMode.Save, path => - { - if (path == null || Project.Current == null) return; - string rel = EditorAssetDatabase.NormalizePath( - System.IO.Path.GetRelativePath(Project.Current.AssetsPath, path)); - if (!rel.EndsWith(".scene")) rel += ".scene"; - EditorSceneManager.SaveAs(rel); - }, Project.Current.AssetsPath, - new[] { "*.scene" }, new[] { Loc.Get("editor.filter_scene") }); - } - }); - MenuRegistry.Register($"{file}/{Loc.Get("menu.file.save_scene_as")}", () => - { - if (Project.Current == null) return; - EditorApplication.OpenFileDialog(FileDialogMode.Save, path => - { - if (path == null || Project.Current == null) return; - string rel = EditorAssetDatabase.NormalizePath( - System.IO.Path.GetRelativePath(Project.Current.AssetsPath, path)); - if (!rel.EndsWith(".scene")) rel += ".scene"; - EditorSceneManager.SaveAs(rel); - }, Project.Current.AssetsPath, - new[] { "*.scene" }, new[] { Loc.Get("editor.filter_scene") }); + PromptSaveAs(); }); + MenuRegistry.Register($"{file}/{Loc.Get("menu.file.save_scene_as")}", () => PromptSaveAs()); MenuRegistry.RegisterSeparator(file); MenuRegistry.Register($"{file}/{Loc.Get("menu.file.open_project")}", () => ReturnToLauncher()); MenuRegistry.RegisterSeparator(file); diff --git a/Prowl.Editor/Projects/SaveManager.cs b/Prowl.Editor/Projects/SaveManager.cs index 87e0eb3a4..b5a315fee 100644 --- a/Prowl.Editor/Projects/SaveManager.cs +++ b/Prowl.Editor/Projects/SaveManager.cs @@ -38,6 +38,13 @@ public static class SaveManager /// Whether auto-save is enabled. public static bool AutoSaveEnabled = true; + /// + /// True while handlers are running as part of an auto-save rather than a + /// manual Ctrl+S. Handlers should check this before showing user-facing prompts (e.g. a Save As + /// dialog for a never-saved scene) - auto-save must never interrupt the user unattended. + /// + public static bool IsAutoSave { get; private set; } + private static double _timeSinceLastSave; private static bool _saveRequestedThisFrame; @@ -82,6 +89,7 @@ public static void RequestSave(bool isAutoSave = false) if (_saveRequestedThisFrame) return; _saveRequestedThisFrame = true; _timeSinceLastSave = 0; + IsAutoSave = isAutoSave; if (OnSave == null) return;