From 64f3bb1ad4bbe1bd129de70500898a6aaddf52d8 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Wed, 1 Mar 2023 22:03:58 -0500 Subject: [PATCH] Can now use launch argument to load project directly --- Editor/Editor.cpp | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp index b8a8037b..b047563a 100644 --- a/Editor/Editor.cpp +++ b/Editor/Editor.cpp @@ -1,15 +1,13 @@ #include -#include -#include "src/Core/Input.h" +#include +#include #include #include #include #include "src/Windows/EditorInterface.h" - - #include #include #include @@ -25,9 +23,10 @@ #include "src/UI/UserInterface.h" #include "src/NewEditor.h" #include -#include "src/Actions/EditorSelection.h" +#include "src/Actions/EditorSelection.h" #include "src/Misc/GizmoDrawer.h" +#include "src/Windows/FileSystemUI.h" const std::string WindowTitle = "Nuake Editor"; @@ -50,6 +49,13 @@ int main(int argc, char* argv[]) } } + bool shouldLoadProject = false; + if (!playMode && argc > 1) + { + shouldLoadProject = true; + projectPath = std::string(argv[1]); + } + if (playMode) { Nuake::Engine::Init(); @@ -57,7 +63,7 @@ int main(int argc, char* argv[]) editor.BuildFonts(); Ref project = Nuake::Project::New(); - FileSystem::SetRootDirectory(projectPath + "/../"); + FileSystem::SetRootDirectory(projectPath ); project->FullPath = projectPath; project->Deserialize(FileSystem::ReadFile(projectPath, true)); @@ -99,6 +105,24 @@ int main(int argc, char* argv[]) GizmoDrawer gizmoDrawer = GizmoDrawer(); + FileSystem::SetRootDirectory(projectPath + "/../"); + + auto project = Project::New(); + auto projectFileData = FileSystem::ReadFile(projectPath, true); + try + { + project->Deserialize(projectFileData); + project->FullPath = projectPath; + + Engine::LoadProject(project); + + editor.filesystem->m_CurrentDirectory = Nuake::FileSystem::RootDirectory; + } + catch (std::exception exception) + { + Logger::Log("Error loading project: " + projectPath, CRITICAL); + Logger::Log(exception.what()); + } while (!window->ShouldClose()) { Nuake::Engine::Tick();