From 7f92311f1208c40380c713c7e1da6c7245be0304 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Mon, 16 Sep 2024 12:46:15 -0400 Subject: [PATCH] Fixed crash when ctrl-s in project browser haha --- Editor/src/Windows/EditorInterface.cpp | 47 +++++++++++++------------ Editor/src/Windows/EditorInterface.h | 1 + Editor/src/Windows/NewProjectWindow.cpp | 2 +- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/Editor/src/Windows/EditorInterface.cpp b/Editor/src/Windows/EditorInterface.cpp index db3cfe73..bbf4a430 100644 --- a/Editor/src/Windows/EditorInterface.cpp +++ b/Editor/src/Windows/EditorInterface.cpp @@ -3039,29 +3039,6 @@ namespace Nuake { return; } - // Shortcuts - if(ImGui::IsKeyDown(ImGuiKey_LeftCtrl)) - { - if(ImGui::IsKeyPressed(ImGuiKey_S)) - { - Engine::GetProject()->Save(); - Engine::GetCurrentScene()->Save(); - - } - else if(ImGui::IsKeyPressed(ImGuiKey_O)) - { - OpenScene(); - - Selection = EditorSelection(); - } - else if(ImGui::IsKeyDown(ImGuiKey_LeftShift) && ImGui::IsKeyPressed(ImGuiKey_S)) - { - std::string savePath = FileDialog::SaveFile("*.project"); - Engine::GetProject()->SaveAs(savePath); - - Selection = EditorSelection(); - } - } if (_WelcomeWindow->IsProjectQueued() && frameCount > 0) { @@ -3087,6 +3064,30 @@ namespace Nuake { m_ProjectSettingsWindow->Init(Engine::GetProject()); } + // Shortcuts + if(ImGui::IsKeyDown(ImGuiKey_LeftCtrl)) + { + if(ImGui::IsKeyPressed(ImGuiKey_S)) + { + Engine::GetProject()->Save(); + Engine::GetCurrentScene()->Save(); + + } + else if(ImGui::IsKeyPressed(ImGuiKey_O)) + { + OpenScene(); + + Selection = EditorSelection(); + } + else if(ImGui::IsKeyDown(ImGuiKey_LeftShift) && ImGui::IsKeyPressed(ImGuiKey_S)) + { + std::string savePath = FileDialog::SaveFile("*.project"); + Engine::GetProject()->SaveAs(savePath); + + Selection = EditorSelection(); + } + } + pInterface.m_CurrentProject = Engine::GetProject(); m_ProjectSettingsWindow->Draw(); diff --git a/Editor/src/Windows/EditorInterface.h b/Editor/src/Windows/EditorInterface.h index 5b2ca572..2b116dac 100644 --- a/Editor/src/Windows/EditorInterface.h +++ b/Editor/src/Windows/EditorInterface.h @@ -68,6 +68,7 @@ namespace Nuake AudioWindow* _audioWindow; FileSystemUI* filesystem; + bool isNewProject = false; static EditorSelection Selection; EditorSelectionPanel SelectionPanel; TrenchbroomConfiguratorWindow m_TrenchhbroomConfigurator; diff --git a/Editor/src/Windows/NewProjectWindow.cpp b/Editor/src/Windows/NewProjectWindow.cpp index c5f9d156..b17d60d9 100644 --- a/Editor/src/Windows/NewProjectWindow.cpp +++ b/Editor/src/Windows/NewProjectWindow.cpp @@ -243,7 +243,7 @@ namespace Nuake window->Maximize(); m_Editor->filesystem->m_CurrentDirectory = Nuake::FileSystem::RootDirectory; - + m_Editor->isNewProject = true; m_HasCreatedProject = true; } }