From dcedc4b8eae16c5ebfc8e7b651f24df0108cf48b Mon Sep 17 00:00:00 2001 From: emerycp Date: Sat, 22 Jul 2023 02:45:29 -0400 Subject: [PATCH 1/2] NK-136 - Reordered Context Menu, Renamed Items, Load Scene --- Editor/src/Windows/FileSystemUI.cpp | 64 +++++++++++++++++------------ Nuake/src/Resource/Project.cpp | 2 +- 2 files changed, 39 insertions(+), 27 deletions(-) diff --git a/Editor/src/Windows/FileSystemUI.cpp b/Editor/src/Windows/FileSystemUI.cpp index 32bd6785..9cc69f15 100644 --- a/Editor/src/Windows/FileSystemUI.cpp +++ b/Editor/src/Windows/FileSystemUI.cpp @@ -144,28 +144,32 @@ namespace Nuake ImGui::OpenPopup(hoverMenuId.c_str()); m_hasClickedOnFile = true; } - + + const std::string openScene = "Open Scene" + std::string("##") + hoverMenuId; + bool shouldOpenScene = false; + + if (ImGui::BeginPopup(hoverMenuId.c_str())) { - if (ImGui::MenuItem("Show in File Explorer")) + if (file->GetExtension() != ".scene") { - OS::ShowInFileExplorer(file->GetAbsolutePath()); - } - - if(file->GetExtension() == ".wren") - { - ImGui::Separator(); - - if(ImGui::MenuItem("Open...")) + if (ImGui::MenuItem("Open in Editor")) { OS::OpenIn(file->GetAbsolutePath()); } } + else + { + if (ImGui::MenuItem("Load Scene")) + { + shouldOpenScene = true; + } + } + + ImGui::Separator(); if (ImGui::BeginMenu("Copy")) { - ImGui::Separator(); - if (ImGui::MenuItem("Full Path")) { OS::CopyToClipboard(file->GetAbsolutePath()); @@ -179,27 +183,30 @@ namespace Nuake ImGui::EndPopup(); } - if(file->GetExtension() != ".project") + if (ImGui::MenuItem("Delete")) { - ImGui::Separator(); - - // TODO: Add to a 'Edit' menu with File Rename, etc. - - if (ImGui::MenuItem("Delete")) + if(FileSystem::RemoveFile(file->GetAbsolutePath()) != 0) { - if(FileSystem::RemoveFile(file->GetAbsolutePath()) != 0) - { - Logger::Log("Failed to remove file: " + file->GetRelativePath(), "editor", CRITICAL); - } - RefreshFileBrowser(); + Logger::Log("Failed to remove file: " + file->GetRelativePath(), "editor", CRITICAL); } + RefreshFileBrowser(); + } + + if (ImGui::MenuItem("Rename")) + { + + } + + ImGui::Separator(); + + if (ImGui::MenuItem("Show in File Explorer")) + { + OS::ShowInFileExplorer(file->GetAbsolutePath()); } ImGui::EndPopup(); } - const std::string openScene = "Open Scene" + std::string("##") + hoverMenuId; - if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) { if (file->GetExtension() == ".scene") @@ -208,7 +215,12 @@ namespace Nuake } } - if (PopupHelper::DefineDialog(openScene, "Open the scene? \n Changes will not be saved.")) + if (shouldOpenScene) + { + PopupHelper::Confirmation(openScene); + } + + if (PopupHelper::DefineDialog(openScene, " Open the scene? \n Changes will not be saved.")) { Ref scene = Scene::New(); const std::string projectPath = file->GetAbsolutePath(); diff --git a/Nuake/src/Resource/Project.cpp b/Nuake/src/Resource/Project.cpp index 45a9e6be..09709e65 100644 --- a/Nuake/src/Resource/Project.cpp +++ b/Nuake/src/Resource/Project.cpp @@ -43,7 +43,7 @@ namespace Nuake void Project::SaveAs(const std::string& FullPath) { json j = Serialize(); - std::string serialized_string = j.dump(); + std::string serialized_string = j.dump(4); // TODO: Use file interface here... // Write to file. From 76ff18036731930a4ad6c6db7d9ac12d046dbf4d Mon Sep 17 00:00:00 2001 From: emerycp Date: Sat, 22 Jul 2023 11:40:49 -0400 Subject: [PATCH 2/2] NK-136 - Added Disabled Delete Menu Item, Disabled Rename --- Editor/src/Windows/FileSystemUI.cpp | 32 +++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/Editor/src/Windows/FileSystemUI.cpp b/Editor/src/Windows/FileSystemUI.cpp index 9cc69f15..bba1f1c7 100644 --- a/Editor/src/Windows/FileSystemUI.cpp +++ b/Editor/src/Windows/FileSystemUI.cpp @@ -183,19 +183,39 @@ namespace Nuake ImGui::EndPopup(); } - if (ImGui::MenuItem("Delete")) + if (file->GetExtension() != ".project") { - if(FileSystem::RemoveFile(file->GetAbsolutePath()) != 0) + if (ImGui::MenuItem("Delete")) { - Logger::Log("Failed to remove file: " + file->GetRelativePath(), "editor", CRITICAL); - } - RefreshFileBrowser(); - } + if (FileSystem::RemoveFile(file->GetAbsolutePath()) != 0) + { + Logger::Log("Failed to remove file: " + file->GetRelativePath(), "editor", CRITICAL); + } + RefreshFileBrowser(); + } + } + else + { + ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1, 1, 1, 0.2f)); + ImGui::MenuItem("Delete"); + ImGui::PopStyleColor(); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f); + ImGui::TextUnformatted("The file you're trying to delete is currently loaded by the game engine."); + ImGui::PopTextWrapPos(); + ImGui::EndTooltip(); + } + } + + ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1, 1, 1, 0.2f)); if (ImGui::MenuItem("Rename")) { } + ImGui::PopStyleColor(); ImGui::Separator();