From ec9fccee1231ca1bea67999d948cc8738c424104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20L=C3=BCbe=C3=9F?= Date: Sun, 2 Aug 2026 15:59:38 +0200 Subject: [PATCH] Don't touch LastOpenedScenes when we didn't save --- GlitchyEditor/src/EditorLayer.bf | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/GlitchyEditor/src/EditorLayer.bf b/GlitchyEditor/src/EditorLayer.bf index 4a2e47c..19073ce 100644 --- a/GlitchyEditor/src/EditorLayer.bf +++ b/GlitchyEditor/src/EditorLayer.bf @@ -1044,19 +1044,26 @@ namespace GlitchyEditor return; } + bool savedScene; + if (SceneFilePath.IsWhiteSpace) { - SaveCurrentSceneAs(); + savedScene = SaveCurrentSceneAs(); } else { SaveScene(_editorScene, SceneFilePath); + // TODO: SaveScene can probably fail too! + savedScene = true; } - // Note: We only update the last opened scene if the CURRENT scene is saved, NOT when ANY scene is saved. - String relativePath = scope .(); - Path.GetRelativePath(SceneFilePath, _currentProject.WorkspacePath, relativePath); - _currentProject.UserSettings.LastOpenedScene = relativePath; + if (savedScene) + { + // Note: We only update the last opened scene if the CURRENT scene is saved, NOT when ANY scene is saved. + String relativePath = scope .(); + Path.GetRelativePath(SceneFilePath, _currentProject.WorkspacePath, relativePath); + _currentProject.UserSettings.LastOpenedScene = relativePath; + } } /// Saves the given scene with the specified file name. @@ -1067,15 +1074,15 @@ namespace GlitchyEditor } /// Opens a save file dialog and saves the scene at the user specified location. - private void SaveCurrentSceneAs() + private bool SaveCurrentSceneAs() { if (_currentProject == null) - return; + return false; if (!CanSaveScene) { Log.ClientLogger.Error("Scene can't be saved while playing the game!"); - return; + return false; } SaveFileDialog sfd = scope .(); @@ -1086,7 +1093,11 @@ namespace GlitchyEditor { SceneFilePath = sfd.FileNames[0]; SaveCurrentScene(); + + return true; } + + return false; } /// Opens a open file dialog and load the scene selected by the user specified.