From 469a4226815e8527dfaa29f4f7babe4079ea7438 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Wed, 17 Dec 2025 03:29:43 +0200 Subject: [PATCH] Add `-lastproject` editor command-line option to open the last project --- Source/Editor/Editor.cpp | 7 +++++++ Source/Engine/Engine/CommandLine.cpp | 1 + Source/Engine/Engine/CommandLine.h | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/Source/Editor/Editor.cpp b/Source/Editor/Editor.cpp index 92c15f591..e82be1128 100644 --- a/Source/Editor/Editor.cpp +++ b/Source/Editor/Editor.cpp @@ -537,6 +537,13 @@ int32 Editor::LoadProduct() if (FileSystem::FileExists(lastProjectSettingPath)) File::ReadAllText(lastProjectSettingPath, lastProjectPath); + // Try to open the last project when requested + if (projectPath.IsEmpty() && CommandLine::Options.LastProject.IsTrue()) + { + if (!lastProjectPath.IsEmpty() && FileSystem::DirectoryExists(lastProjectPath)) + projectPath = lastProjectPath; + } + // Missing project case if (projectPath.IsEmpty()) { diff --git a/Source/Engine/Engine/CommandLine.cpp b/Source/Engine/Engine/CommandLine.cpp index 229b18834..a717a45a2 100644 --- a/Source/Engine/Engine/CommandLine.cpp +++ b/Source/Engine/Engine/CommandLine.cpp @@ -155,6 +155,7 @@ bool CommandLine::Parse(const Char* cmdLine) PARSE_BOOL_SWITCH("-clearcache ", ClearCache); PARSE_BOOL_SWITCH("-clearcooker ", ClearCookerCache); PARSE_ARG_SWITCH("-project ", Project); + PARSE_BOOL_SWITCH("-lastproject ", LastProject); PARSE_BOOL_SWITCH("-new ", NewProject); PARSE_BOOL_SWITCH("-genprojectfiles ", GenProjectFiles); PARSE_ARG_SWITCH("-build ", Build); diff --git a/Source/Engine/Engine/CommandLine.h b/Source/Engine/Engine/CommandLine.h index 76ff83472..77a573a0a 100644 --- a/Source/Engine/Engine/CommandLine.h +++ b/Source/Engine/Engine/CommandLine.h @@ -147,6 +147,11 @@ public: /// String Project; + /// + /// -lastproject (Opens the last project) + /// + Nullable LastProject; + /// /// -new (generates the project files inside the specified project folder or uses current workspace folder) ///