From bf0aa78d4de2991aa6486ed706e163d6f67b9a8a Mon Sep 17 00:00:00 2001 From: emerycp Date: Fri, 21 Jul 2023 22:04:58 -0400 Subject: [PATCH 1/2] NK-74 - Double click to open scene --- Editor/src/Windows/FileSystemUI.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Editor/src/Windows/FileSystemUI.cpp b/Editor/src/Windows/FileSystemUI.cpp index 934f94c7..2056ed0b 100644 --- a/Editor/src/Windows/FileSystemUI.cpp +++ b/Editor/src/Windows/FileSystemUI.cpp @@ -10,6 +10,7 @@ #include "EditorInterface.h" #include +#include "../Misc/PopupHelper.h" namespace Nuake { @@ -178,6 +179,30 @@ namespace Nuake ImGui::EndPopup(); } + std::string openScene = "Open Scene" + std::string("##") + hoverMenuId; + + if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) + { + if (file->GetExtension() == ".scene") + { + PopupHelper::Confirmation(openScene); + } + } + + if (PopupHelper::DefineDialog(openScene, "Open the scene? \n Changes will not be saved.")) + { + Ref scene = Scene::New(); + std::string projectPath = file->GetAbsolutePath(); + if (!scene->Deserialize(FileSystem::ReadFile(projectPath, true))) + { + Logger::Log("Error failed loading scene: " + projectPath, CRITICAL); + return; + } + + scene->Path = FileSystem::AbsoluteToRelative(projectPath); + Engine::LoadScene(scene); + } + ImGui::Text(file->GetName().c_str()); ImGui::PopFont(); } From 01db1970a8ea71fb67676896e0b8b53eb5a96647 Mon Sep 17 00:00:00 2001 From: emerycp Date: Fri, 21 Jul 2023 22:15:31 -0400 Subject: [PATCH 2/2] NK-74 - PR Comments --- Editor/src/Windows/FileSystemUI.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Editor/src/Windows/FileSystemUI.cpp b/Editor/src/Windows/FileSystemUI.cpp index 2056ed0b..55d690ef 100644 --- a/Editor/src/Windows/FileSystemUI.cpp +++ b/Editor/src/Windows/FileSystemUI.cpp @@ -179,7 +179,7 @@ namespace Nuake ImGui::EndPopup(); } - std::string openScene = "Open Scene" + std::string("##") + hoverMenuId; + const std::string openScene = "Open Scene" + std::string("##") + hoverMenuId; if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) { @@ -192,7 +192,7 @@ namespace Nuake if (PopupHelper::DefineDialog(openScene, "Open the scene? \n Changes will not be saved.")) { Ref scene = Scene::New(); - std::string projectPath = file->GetAbsolutePath(); + const std::string projectPath = file->GetAbsolutePath(); if (!scene->Deserialize(FileSystem::ReadFile(projectPath, true))) { Logger::Log("Error failed loading scene: " + projectPath, CRITICAL);