From e4c11140e0b190e0971bf335421ed3e320c9d9f0 Mon Sep 17 00:00:00 2001 From: antopilo Date: Wed, 20 Nov 2024 01:30:57 -0500 Subject: [PATCH] Better UI --- Editor/src/Misc/GizmoDrawer.cpp | 2 +- Editor/src/Windows/EditorInterface.cpp | 6 ++++- Editor/src/Windows/EditorSelectionPanel.cpp | 27 +++++++++++++++++++++ Nuake/src/Resource/Project.cpp | 2 ++ Nuake/src/Resource/Project.h | 2 ++ 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/Editor/src/Misc/GizmoDrawer.cpp b/Editor/src/Misc/GizmoDrawer.cpp index 172a3f1c..d65f4347 100644 --- a/Editor/src/Misc/GizmoDrawer.cpp +++ b/Editor/src/Misc/GizmoDrawer.cpp @@ -223,7 +223,7 @@ void GizmoDrawer::DrawShapes(Ref scene, bool occluded) { using namespace Nuake; RenderCommand::Enable(RendererEnum::DEPTH_TEST); - glLineWidth(3.0f); + glLineWidth(2.0f); auto navMeshVolumeView = scene->m_Registry.view(); for (auto e : navMeshVolumeView) diff --git a/Editor/src/Windows/EditorInterface.cpp b/Editor/src/Windows/EditorInterface.cpp index 3b3f3172..b5231c4a 100644 --- a/Editor/src/Windows/EditorInterface.cpp +++ b/Editor/src/Windows/EditorInterface.cpp @@ -200,7 +200,11 @@ namespace Nuake { { // Centered Window title ImVec2 currentCursorPos = ImGui::GetCursorPos(); - const std::string title = "Nuake Engine - " + Engine::GetProject()->Name; + std::string title = "Nuake Engine - " + Engine::GetProject()->Name; + + if (Engine::GetProject()->IsDirty) + title += "*"; + ImVec2 textSize = ImGui::CalcTextSize(title.c_str()); ImGui::SetCursorPos(ImVec2(ImGui::GetWindowWidth() * 0.5f - textSize.x * 0.5f - ImGui::GetStyle().WindowPadding.x / 2.0f, 2.0f + windowPadding.y + 6.0f)); ImGui::Text(title.c_str()); // Draw title diff --git a/Editor/src/Windows/EditorSelectionPanel.cpp b/Editor/src/Windows/EditorSelectionPanel.cpp index df0cdc83..afef0437 100644 --- a/Editor/src/Windows/EditorSelectionPanel.cpp +++ b/Editor/src/Windows/EditorSelectionPanel.cpp @@ -210,8 +210,24 @@ void EditorSelectionPanel::DrawAddComponentMenu(Nuake::Entity entity) using namespace Nuake; if (entity.HasComponent()) { + UIFont* boldIconFont = new UIFont(Fonts::Icons); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 8.0f); + ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 4.0f); + ImGui::Text(ICON_FA_BOX); + delete boldIconFont; + + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 2.0f); + ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 4.0f); + ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0, 0, 0, 0)); + UIFont* boldFont = new UIFont(Fonts::Bold); auto& entityName = entity.GetComponent().Name; + + ImGuiTextSTD("##Name", entityName); + delete boldFont; + + ImGui::PopStyleColor(); } } @@ -754,6 +770,7 @@ void EditorSelectionPanel::DrawComponent(Nuake::Entity& entity, entt::meta_any& entity.RemoveComponent(componentType); ImGui::PopStyleVar(); delete boldFont; + Engine::GetProject()->IsDirty = true; } else if (headerOpened) { @@ -872,6 +889,7 @@ void EditorSelectionPanel::DrawFieldTypeFloat(entt::meta_data& field, entt::meta if (ImGui::DragFloat(controlId.c_str(), &floatProxy, stepSize, min, max)) { field.set(component, floatProxy); + Engine::GetProject()->IsDirty = true; } } else @@ -901,6 +919,7 @@ void EditorSelectionPanel::DrawFieldTypeBool(entt::meta_data& field, entt::meta_ if (ImGui::Checkbox(controlId.c_str(), &boolProxy)) { field.set(component, boolProxy); + Engine::GetProject()->IsDirty = true; } } else @@ -929,6 +948,7 @@ void EditorSelectionPanel::DrawFieldTypeVector3(entt::meta_data& field, entt::me if (ImGuiHelper::DrawVec3(controlId, vec3Ptr, 0.5f, 100.0, 0.01f)) { field.set(component, *vec3Ptr); + Engine::GetProject()->IsDirty = true; } ImGui::PopID(); @@ -954,6 +974,7 @@ void EditorSelectionPanel::DrawFieldTypeVector2(entt::meta_data& field, entt::me if (ImGuiHelper::DrawVec2(controlId, vec2Ptr, 0.5f, 100.0, 0.01f)) { field.set(component, *vec2Ptr); + Engine::GetProject()->IsDirty = true; } ImGui::PopID(); @@ -978,6 +999,11 @@ void EditorSelectionPanel::DrawFieldTypeString(entt::meta_data& field, entt::met std::string fieldValProxy = *fieldValPtr; std::string controlId = std::string("##") + displayName; ImGui::InputText(controlId.c_str(), &fieldValProxy); + + if (fieldValProxy != fieldVal) + { + Engine::GetProject()->IsDirty = true; + } } else { @@ -1016,6 +1042,7 @@ void EditorSelectionPanel::DrawFieldTypeResourceFile(entt::meta_data& field, ent const std::string fullPath = std::string(payloadFilePath, 256); const Ref file = FileSystem::GetFile(FileSystem::AbsoluteToRelative(fullPath)); field.set(component, ResourceFile{ file }); + Engine::GetProject()->IsDirty = true; } ImGui::EndDragDropTarget(); } diff --git a/Nuake/src/Resource/Project.cpp b/Nuake/src/Resource/Project.cpp index 350d39a9..659f9722 100644 --- a/Nuake/src/Resource/Project.cpp +++ b/Nuake/src/Resource/Project.cpp @@ -52,6 +52,8 @@ namespace Nuake json j = Serialize(); std::string serialized_string = j.dump(4); + IsDirty = false; + // TODO: Use file interface here... // Write to file. std::ofstream projectFile; diff --git a/Nuake/src/Resource/Project.h b/Nuake/src/Resource/Project.h index 7b9072bb..fa974365 100644 --- a/Nuake/src/Resource/Project.h +++ b/Nuake/src/Resource/Project.h @@ -40,6 +40,8 @@ namespace Nuake std::string Description; std::string FullPath; + bool IsDirty = false; + ProjectSettings Settings; // Path of the trenchbroom .exe folder