Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
EntitiesPanel.cpp
Go to the documentation of this file.
1/*
2 * Olympe Blueprint Editor - Entities Panel Implementation
3 */
4
5#include "EntitiesPanel.h"
6#include "BlueprintEditor.h"
8#include "../third_party/imgui/imgui.h"
9#include <iostream>
10
11namespace Olympe
12{
17
21
23 {
24 std::cout << "[EntitiesPanel] Initialized\n";
25 }
26
28 {
29 std::cout << "[EntitiesPanel] Shutdown\n";
30 }
31
33 {
34 ImGui::Begin("Runtime Entities");
35
36 // Header with entity count
38 ImGui::Text("Entities: %zu", entityCount);
39
40 ImGui::Separator();
41
42 // Filter input
43 ImGui::Text("Filter:");
44 ImGui::SameLine();
45 ImGui::InputText("##EntityFilter", m_FilterBuffer, sizeof(m_FilterBuffer));
46
47 ImGui::Separator();
48
49 // Entity list
51
52 ImGui::End();
53 }
54
56 {
57 if (!EntityInspectorManager::Get().IsInitialized())
58 {
59 ImGui::Text("Entity inspector not initialized.");
60 return;
61 }
62
63 // Get all entities
64 std::vector<EntityInfo> entities = EntityInspectorManager::Get().GetAllEntityInfo();
65
66 // Apply filter if any
67 std::string filter(m_FilterBuffer);
68
69 ImGui::BeginChild("EntityListScroll", ImVec2(0, 0), true);
70
71 for (const auto& entityInfo : entities)
72 {
73 // Apply name filter
74 if (!filter.empty() && entityInfo.name.find(filter) == std::string::npos)
75 continue;
76
78 }
79
80 ImGui::EndChild();
81 }
82
83 void EntitiesPanel::RenderEntityItem(uint64_t entityId, const std::string& entityName)
84 {
85 // C) Use BlueprintEditor backend for selection state
86 bool isSelected = (BlueprintEditor::Get().GetSelectedEntity() == entityId);
87
88 // Selectable entity item
89 if (ImGui::Selectable(entityName.c_str(), isSelected))
90 {
91 // C) Set selection in BlueprintEditor backend - this will synchronize all panels
93 }
94
95 // Context menu
96 if (ImGui::BeginPopupContextItem())
97 {
98 ImGui::Text("Entity: %s", entityName.c_str());
99 ImGui::Separator();
100
101 if (ImGui::MenuItem("Select"))
102 {
104 }
105
106 // Note: Destroy would require access to World
107 // if (ImGui::MenuItem("Destroy"))
108 // {
109 // World::Get().DestroyEntity(entityId);
110 // }
111
112 ImGui::EndPopup();
113 }
114
115 // Show component count on hover
116 if (ImGui::IsItemHovered())
117 {
118 auto components = EntityInspectorManager::Get().GetEntityComponents(entityId);
119 ImGui::BeginTooltip();
120 ImGui::Text("Entity ID: %llu", entityId);
121 ImGui::Text("Components: %zu", components.size());
122 if (!components.empty())
123 {
124 ImGui::Separator();
125 for (const auto& comp : components)
126 {
127 ImGui::BulletText("%s", comp.c_str());
128 }
129 }
130 ImGui::EndTooltip();
131 }
132 }
133}
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
void SetSelectedEntity(uint64_t entityId)
uint64_t GetSelectedEntity() const
static BlueprintEditor & Get()
void RenderEntityItem(uint64_t entityId, const std::string &entityName)
std::vector< std::string > GetEntityComponents(EntityID entity) const
static EntityInspectorManager & Get()
std::vector< EntityInfo > GetAllEntityInfo() const