From 4ffbb042e26685988d39f069b96a7f8bb20d8ed3 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Sat, 30 Sep 2023 14:27:57 -0400 Subject: [PATCH] Added menu to add entities in the scene inspector --- Editor/src/Windows/EditorInterface.cpp | 124 +++++++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/Editor/src/Windows/EditorInterface.cpp b/Editor/src/Windows/EditorInterface.cpp index 0437a929..7aa815aa 100644 --- a/Editor/src/Windows/EditorInterface.cpp +++ b/Editor/src/Windows/EditorInterface.cpp @@ -1240,6 +1240,105 @@ namespace Nuake { std::string title = ICON_FA_TREE + std::string(" Hierarchy"); if (ImGui::Begin(title.c_str())) { + if (UI::PrimaryButton("Add Entity")) + { + ImGui::OpenPopup("create_entity_popup"); + } + + if (ImGui::BeginPopup("create_entity_popup")) + { + if (ImGui::MenuItem("Empty")) + { + Engine::GetCurrentScene()->CreateEntity("Empty"); + } + + if(ImGui::BeginMenu("3D")) + { + if (ImGui::MenuItem("Camera")) + { + Engine::GetCurrentScene()->CreateEntity("Camera").AddComponent(); + } + if (ImGui::MenuItem("Model")) + { + Engine::GetCurrentScene()->CreateEntity("Model").AddComponent(); + } + if (ImGui::MenuItem("Skinned Model")) + { + Engine::GetCurrentScene()->CreateEntity("Skinned Model").AddComponent(); + } + if (ImGui::MenuItem("Sprite")) + { + Engine::GetCurrentScene()->CreateEntity("Sprite").AddComponent(); + } + if (ImGui::MenuItem("Light")) + { + Engine::GetCurrentScene()->CreateEntity("Light").AddComponent(); + } + if (ImGui::MenuItem("Quake Map")) + { + Engine::GetCurrentScene()->CreateEntity("Quake Map").AddComponent(); + } + ImGui::EndMenu(); + } + + if (ImGui::BeginMenu("Physics")) + { + if (ImGui::MenuItem("Character Controller")) + { + Engine::GetCurrentScene()->CreateEntity("Character Controller").AddComponent(); + } + if (ImGui::MenuItem("Rigid Body")) + { + Engine::GetCurrentScene()->CreateEntity("Rigid Body").AddComponent(); + } + ImGui::EndMenu(); + } + + if (ImGui::BeginMenu("Colliders")) + { + if (ImGui::MenuItem("Box Collider")) + { + Engine::GetCurrentScene()->CreateEntity("Box Collider").AddComponent(); + } + if (ImGui::MenuItem("Sphere Collider")) + { + Engine::GetCurrentScene()->CreateEntity("Sphere Collider").AddComponent(); + } + if (ImGui::MenuItem("Capsule Collider")) + { + Engine::GetCurrentScene()->CreateEntity("Capsule Collider").AddComponent(); + } + if (ImGui::MenuItem("Cylinder Collider")) + { + Engine::GetCurrentScene()->CreateEntity("Cylinder Collider").AddComponent(); + } + if (ImGui::MenuItem("Mesh Collider")) + { + Engine::GetCurrentScene()->CreateEntity("Mesh Collider").AddComponent(); + } + ImGui::EndMenu(); + } + + if (ImGui::BeginMenu("Audio")) + { + if (ImGui::MenuItem("Audio Emitter")) + { + Engine::GetCurrentScene()->CreateEntity("Audio Emitter").AddComponent(); + } + ImGui::EndMenu(); + } + + if (ImGui::BeginMenu("Script")) + { + if (ImGui::MenuItem("Script")) + { + Engine::GetCurrentScene()->CreateEntity("Script").AddComponent(); + } + } + + ImGui::EndPopup(); + } + // Draw a tree of entities. ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(26.f / 255.0f, 26.f / 255.0f, 26.f / 255.0f, 1)); if (ImGui::BeginChild("Scene tree", ImGui::GetContentRegionAvail(), false)) @@ -1864,6 +1963,31 @@ namespace Nuake { entityTypeName = "Prefab"; } + if (entity.HasComponent()) + { + entityTypeName = "Audio Emitter"; + } + + if (entity.HasComponent()) + { + entityTypeName = "Particle Emitter"; + } + + if (entity.HasComponent()) + { + entityTypeName = "Quake Map"; + } + + if (entity.HasComponent()) + { + entityTypeName = "Model"; + } + + if (entity.HasComponent()) + { + entityTypeName = "Skinned Model"; + } + return entityTypeName; }