diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp index 25912d63..a9bbe718 100644 --- a/Editor/Editor.cpp +++ b/Editor/Editor.cpp @@ -39,13 +39,7 @@ #include "src/EditorApplication.h" -struct LaunchSettings -{ - int32_t monitor = -1; - Vector2 resolution = { 1920, 1080 }; - std::string windowTitle = "Nuake Editor "; - std::string projectPath; -}; +#include "LaunchSettings.h" std::vector ParseArguments(int argc, char* argv[]) @@ -133,5 +127,5 @@ Nuake::Application* Nuake::CreateApplication(int argc, char** argv) specification.Name += "(DEBUG BUILD)"; #endif - return new EditorApplication(specification); + return new EditorApplication(specification, launchSettings); } diff --git a/Editor/LaunchSettings.h b/Editor/LaunchSettings.h new file mode 100644 index 00000000..546faf69 --- /dev/null +++ b/Editor/LaunchSettings.h @@ -0,0 +1,11 @@ +#pragma once +#include +#include + +struct LaunchSettings +{ + int32_t monitor = 1; + Nuake::Vector2 resolution = { 1920, 1080 }; + std::string windowTitle = "Nuake Editor "; + std::string projectPath; +}; diff --git a/Editor/src/EditorApplication.cpp b/Editor/src/EditorApplication.cpp index befff116..2791b4fe 100644 --- a/Editor/src/EditorApplication.cpp +++ b/Editor/src/EditorApplication.cpp @@ -16,7 +16,35 @@ void EditorApplication::OnInit() m_Window = Engine::GetCurrentWindow(); m_Window->SetSize({ m_Specification.WindowWidth, m_Specification.WindowHeight }); m_Window->SetTitle(m_Specification.Name); + m_Window->SetMonitor(1); + if (!m_LaunchSettings.projectPath.empty()) + { + if (FileSystem::FileExists(m_LaunchSettings.projectPath, true)) + { + const std::string projectPath = m_LaunchSettings.projectPath; + + FileSystem::SetRootDirectory(FileSystem::GetParentPath(projectPath)); + + auto project = Project::New(); + auto projectFileData = FileSystem::ReadFile(projectPath, true); + Logger::Log("Reading file project: " + projectFileData, "window", VERBOSE); + try + { + Logger::Log("Starting deserializing", "window", VERBOSE); + project->Deserialize(json::parse(projectFileData)); + project->FullPath = projectPath; + + Engine::LoadProject(project); + } + catch (std::exception exception) + { + Logger::Log("Error loading project: " + projectPath, "editor", CRITICAL); + Logger::Log(exception.what()); + } + } + } + PushLayer(CreateScope()); } diff --git a/Editor/src/EditorApplication.h b/Editor/src/EditorApplication.h index 7b05080e..646ecb3f 100644 --- a/Editor/src/EditorApplication.h +++ b/Editor/src/EditorApplication.h @@ -6,6 +6,7 @@ #include "Misc/GizmoDrawer.h" #include "Commands/CommandBuffer.h" +#include "../LaunchSettings.h" using namespace NuakeEditor; @@ -15,9 +16,10 @@ private: CommandBuffer mCommandBuffer; public: - EditorApplication(const Nuake::ApplicationSpecification& specification) + EditorApplication(const Nuake::ApplicationSpecification& specification, const LaunchSettings& launchSettings) : Application(specification), - m_Editor(nullptr) + m_Editor(nullptr), + m_LaunchSettings(launchSettings) { } @@ -28,4 +30,5 @@ public: private: Nuake::EditorInterface* m_Editor; + LaunchSettings m_LaunchSettings; }; \ No newline at end of file diff --git a/Editor/src/Windows/EditorInterface.cpp b/Editor/src/Windows/EditorInterface.cpp index 03ef592d..243430fe 100644 --- a/Editor/src/Windows/EditorInterface.cpp +++ b/Editor/src/Windows/EditorInterface.cpp @@ -68,6 +68,7 @@ namespace Nuake { { Logger::Log("Creating editor windows", "window", VERBOSE); filesystem = new FileSystemUI(this); + _WelcomeWindow = new WelcomeWindow(this); _audioWindow = new AudioWindow(); @@ -2007,9 +2008,9 @@ namespace Nuake { } ImGui::PopStyleVar(); - if (AutoScroll) + if (AutoScroll && ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) { - ImGui::SetScrollY(ImGui::GetScrollMaxY()); + ImGui::SetScrollHereY(1.0f); } ImGui::EndTable();