Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
InspectorPanel.cpp
Go to the documentation of this file.
1/*
2 * Olympe Blueprint Editor - Inspector Panel Implementation
3 */
4
5#include "InspectorPanel.h"
6#include "BlueprintEditor.h"
8#include "NodeGraphManager.h"
10#include "../third_party/imgui/imgui.h"
11#include <iostream>
12#include <string>
13#include <cstring>
14
15namespace Olympe
16{
20
24
26 {
27 std::cout << "[InspectorPanel] Initialized\n";
28 }
29
31 {
32 std::cout << "[InspectorPanel] Shutdown\n";
33 }
34
36 {
37 ImGui::Begin("Inspector");
38
40
41 switch (context)
42 {
45 break;
46
49 break;
50
53 break;
54
56 default:
57 ImGui::Text("No selection");
58 ImGui::TextWrapped("Select an entity or asset file to inspect its properties.");
59 break;
60 }
61
62 ImGui::End();
63 }
64
66 {
67 // C) Priority 1: Entity selection from BlueprintEditor backend
68 if (BlueprintEditor::Get().HasSelectedEntity())
69 {
71 }
72
73 // Priority 2: Asset file selection from BlueprintEditor backend
74 if (BlueprintEditor::Get().HasSelectedAsset())
75 {
77 }
78
79 // Check if a graph node is selected
80 // For now, we'll assume no node selection (would need to track in NodeGraphPanel)
81
83 }
84
86 {
87 ImGui::Text("Node Properties");
88 ImGui::Separator();
89
90 // This would show properties of the selected graph node
91 // Would require selected node tracking in NodeGraphPanel
92
93 ImGui::Text("Node inspector coming soon...");
94 }
95
97 {
98 // C) Get selected entity from BlueprintEditor backend
100
101 if (selectedEntity == 0) // INVALID_ENTITY_ID
102 {
103 ImGui::Text("No entity selected");
104 ImGui::TextWrapped("Select an entity from the Asset Browser or Entities panel to inspect its properties.");
105 return;
106 }
107
109
110 ImGui::Text("Entity: %s", info.name.c_str());
111 ImGui::Text("ID: %llu", selectedEntity);
112 ImGui::Separator();
113
114 // Show components
115 ImGui::Text("Components:");
116
118
119 if (components.empty())
120 {
121 ImGui::Text(" (no components)");
122 }
123 else
124 {
125 for (const auto& componentType : components)
126 {
127 if (ImGui::CollapsingHeader(componentType.c_str()))
128 {
130 }
131 }
132 }
133 }
134
135 void InspectorPanel::RenderComponentProperties(uint64_t entityId, const std::string& componentType)
136 {
137 auto properties = EntityInspectorManager::Get().GetComponentProperties(entityId, componentType);
138
139 if (properties.empty())
140 {
141 ImGui::Text(" (no editable properties)");
142 return;
143 }
144
145 for (auto& prop : properties)
146 {
147 ImGui::PushID(prop.name.c_str());
148
149 if (prop.type == "float")
150 {
151 float value = std::stof(prop.value);
152 if (ImGui::DragFloat(prop.name.c_str(), &value, 1.0f))
153 {
154 // Update property
156 entityId, componentType, prop.name, std::to_string(value)
157 );
158 }
159 }
160 else if (prop.type == "int")
161 {
162 int value = std::stoi(prop.value);
163 if (ImGui::DragInt(prop.name.c_str(), &value))
164 {
166 entityId, componentType, prop.name, std::to_string(value)
167 );
168 }
169 }
170 else if (prop.type == "bool")
171 {
172 bool value = (prop.value == "true" || prop.value == "1");
173 if (ImGui::Checkbox(prop.name.c_str(), &value))
174 {
176 entityId, componentType, prop.name, value ? "true" : "false"
177 );
178 }
179 }
180 else if (prop.type == "string")
181 {
182 char buffer[256];
183 strncpy_s(buffer, prop.value.c_str(), sizeof(buffer) - 1);
184 buffer[sizeof(buffer) - 1] = '\0';
185
186 if (ImGui::InputText(prop.name.c_str(), buffer, sizeof(buffer)))
187 {
189 entityId, componentType, prop.name, buffer
190 );
191 }
192 }
193 else
194 {
195 // Default: display as text
196 ImGui::Text("%s: %s", prop.name.c_str(), prop.value.c_str());
197 }
198
199 ImGui::PopID();
200 }
201 }
202
204 {
205 // Get selected asset path from BlueprintEditor backend
207
208 if (selectedAssetPath.empty())
209 {
210 ImGui::Text("No asset selected");
211 return;
212 }
213
214 // Get asset metadata from backend
216
217 // Extract filename from path
218 size_t lastSlash = selectedAssetPath.find_last_of("/\\");
219 std::string filename = (lastSlash != std::string::npos)
220 ? selectedAssetPath.substr(lastSlash + 1)
222
223 ImGui::TextColored(ImVec4(0.5f, 0.8f, 1.0f, 1.0f), "Asset: %s", filename.c_str());
224 ImGui::Separator();
225
226 if (!metadata.isValid)
227 {
228 ImGui::TextColored(ImVec4(1.0f, 0.3f, 0.3f, 1.0f), "Invalid or malformed asset");
229 if (!metadata.errorMessage.empty())
230 {
231 ImGui::TextWrapped("Error: %s", metadata.errorMessage.c_str());
232 }
233 return;
234 }
235
236 // Display asset type
237 ImGui::Text("Type: %s", metadata.type.c_str());
238
239 // Display name and description if available
240 if (!metadata.name.empty())
241 {
242 ImGui::Text("Name: %s", metadata.name.c_str());
243 }
244
245 if (!metadata.description.empty())
246 {
247 ImGui::Separator();
248 ImGui::TextWrapped("Description: %s", metadata.description.c_str());
249 }
250
251 ImGui::Separator();
252
253 // Type-specific information
254 if (metadata.type == "BehaviorTree" || metadata.type == "HFSM")
255 {
256 ImGui::Text("Nodes: %d", metadata.nodeCount);
257
258 if (!metadata.nodes.empty() && ImGui::CollapsingHeader("Node List"))
259 {
260 ImGui::Indent();
261 for (const auto& node : metadata.nodes)
262 {
263 ImGui::BulletText("%s", node.c_str());
264 }
265 ImGui::Unindent();
266 }
267
268 ImGui::Separator();
269 if (ImGui::Button("Open in Node Graph Editor"))
270 {
272 }
273 }
274 else if (metadata.type == "EntityBlueprint")
275 {
276 ImGui::Text("Components: %d", metadata.componentCount);
277
278 if (!metadata.components.empty() && ImGui::CollapsingHeader("Component List"))
279 {
280 ImGui::Indent();
281 for (const auto& comp : metadata.components)
282 {
283 ImGui::BulletText("%s", comp.c_str());
284 }
285 ImGui::Unindent();
286 }
287 }
288
289 // Full file path at the bottom
290 ImGui::Separator();
291 ImGui::TextDisabled("Path: %s", selectedAssetPath.c_str());
292 }
293}
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
std::string GetSelectedAssetPath() const
AssetMetadata GetAssetMetadata(const std::string &filepath)
uint64_t GetSelectedEntity() const
void OpenGraphInEditor(const std::string &assetPath)
static BlueprintEditor & Get()
std::vector< std::string > GetEntityComponents(EntityID entity) const
static EntityInspectorManager & Get()
EntityInfo GetEntityInfo(EntityID entity) const
std::vector< ComponentPropertyInfo > GetComponentProperties(EntityID entity, const std::string &componentType)
bool SetComponentProperty(EntityID entity, const std::string &componentType, const std::string &propertyName, const std::string &value)
void RenderComponentProperties(uint64_t entityId, const std::string &componentType)
InspectorContext DetermineContext()
std::vector< std::string > components
std::vector< std::string > nodes