Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
AssetInfoPanel.cpp
Go to the documentation of this file.
1/*
2 * Olympe Blueprint Editor - Asset Info Panel Implementation
3 * Frontend component that uses BlueprintEditor backend for asset metadata
4 */
5
6#include "AssetInfoPanel.h"
7#include "BlueprintEditor.h"
8#include "../third_party/imgui/imgui.h"
9#include <iostream>
10
11namespace Olympe
12{
14 : m_CurrentAsset(nullptr)
15 {
16 }
17
19 {
20 // Don't delete m_CurrentAsset as it's managed by backend cache
21 }
22
23 void AssetInfoPanel::LoadAsset(const std::string& filepath)
24 {
25 Clear();
26
27 m_LoadedFilepath = filepath;
28
29 // Get asset metadata from backend
30 static AssetMetadata cachedMetadata; // Static to keep data alive
33
34 std::cout << "AssetInfoPanel: Loaded asset info from backend: " << filepath << std::endl;
35 }
36
38 {
39 m_CurrentAsset = nullptr;
40 m_LoadedFilepath.clear();
41 }
42
44 {
45 if (ImGui::Begin("Asset Info"))
46 {
47 if (!HasAsset())
48 {
49 ImGui::TextColored(ImVec4(0.6f, 0.6f, 0.6f, 1.0f), "No asset selected");
50 ImGui::Text("Select an asset from the Asset Browser to view details.");
51 }
52 else if (!m_CurrentAsset->isValid)
53 {
55 }
56 else
57 {
58 // Render based on asset type
59 if (m_CurrentAsset->type == "EntityBlueprint")
60 {
62 }
63 else if (m_CurrentAsset->type == "BehaviorTree")
64 {
66 }
67 else
68 {
70 }
71 }
72 }
73 ImGui::End();
74 }
75
77 {
78 ImGui::TextColored(ImVec4(0.4f, 0.8f, 0.4f, 1.0f), "Entity Blueprint");
79 ImGui::Separator();
80
81 ImGui::Text("Name: %s", m_CurrentAsset->name.c_str());
82
83 if (!m_CurrentAsset->description.empty())
84 {
85 ImGui::Text("Description:");
86 ImGui::TextWrapped("%s", m_CurrentAsset->description.c_str());
87 }
88
89 ImGui::Spacing();
90 ImGui::Text("Components: %d", m_CurrentAsset->componentCount);
91
92 if (!m_CurrentAsset->components.empty())
93 {
94 if (ImGui::CollapsingHeader("Component List"))
95 {
96 for (const auto& comp : m_CurrentAsset->components)
97 {
98 ImGui::BulletText("%s", comp.c_str());
99 }
100 }
101 }
102
103 ImGui::Spacing();
104 ImGui::Separator();
105 ImGui::TextColored(ImVec4(0.5f, 0.5f, 0.5f, 1.0f), "File: %s", m_CurrentAsset->filepath.c_str());
106 }
107
109 {
110 ImGui::TextColored(ImVec4(0.4f, 0.6f, 0.9f, 1.0f), "Behavior Tree");
111 ImGui::Separator();
112
113 ImGui::Text("Name: %s", m_CurrentAsset->name.c_str());
114
115 if (!m_CurrentAsset->description.empty())
116 {
117 ImGui::TextWrapped("%s", m_CurrentAsset->description.c_str());
118 }
119
120 ImGui::Spacing();
121 ImGui::Text("Nodes: %d", m_CurrentAsset->nodeCount);
122
123 if (!m_CurrentAsset->nodes.empty())
124 {
125 if (ImGui::CollapsingHeader("Node List"))
126 {
127 for (const auto& node : m_CurrentAsset->nodes)
128 {
129 ImGui::BulletText("%s", node.c_str());
130 }
131 }
132 }
133
134 ImGui::Spacing();
135 ImGui::Separator();
136 ImGui::TextColored(ImVec4(0.5f, 0.5f, 0.5f, 1.0f), "File: %s", m_CurrentAsset->filepath.c_str());
137 }
138
140 {
141 ImGui::TextColored(ImVec4(0.8f, 0.8f, 0.4f, 1.0f), "%s", m_CurrentAsset->type.c_str());
142 ImGui::Separator();
143
144 ImGui::Text("Name: %s", m_CurrentAsset->name.c_str());
145
146 if (!m_CurrentAsset->description.empty())
147 {
148 ImGui::Text("Description:");
149 ImGui::TextWrapped("%s", m_CurrentAsset->description.c_str());
150 }
151
152 ImGui::Spacing();
153 ImGui::Separator();
154 ImGui::TextColored(ImVec4(0.5f, 0.5f, 0.5f, 1.0f), "File: %s", m_CurrentAsset->filepath.c_str());
155 }
156
158 {
159 ImGui::TextColored(ImVec4(1.0f, 0.3f, 0.3f, 1.0f), "Error Loading Asset");
160 ImGui::Separator();
161
162 ImGui::Text("File: %s", m_CurrentAsset->filepath.c_str());
163 ImGui::Spacing();
164 ImGui::TextColored(ImVec4(1.0f, 0.5f, 0.5f, 1.0f), "Error:");
165 ImGui::TextWrapped("%s", m_CurrentAsset->errorMessage.c_str());
166 ImGui::Spacing();
167 ImGui::TextColored(ImVec4(0.8f, 0.8f, 0.4f, 1.0f),
168 "The JSON file may be corrupted or malformed. Please check the file syntax.");
169 }
170
172 {
173 return m_CurrentAsset != nullptr;
174 }
175}
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
void LoadAsset(const std::string &filepath)
AssetMetadata * m_CurrentAsset
AssetMetadata GetAssetMetadata(const std::string &filepath)
static BlueprintEditor & Get()
std::vector< std::string > components
std::vector< std::string > nodes