From bf0aa78d4de2991aa6486ed706e163d6f67b9a8a Mon Sep 17 00:00:00 2001 From: emerycp Date: Fri, 21 Jul 2023 22:04:58 -0400 Subject: [PATCH] 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(); }