Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
ValidationPanel.cpp
Go to the documentation of this file.
1/*
2 * Olympe Blueprint Editor - Validation Panel Implementation
3 */
4
5#include "ValidationPanel.h"
6#include "NodeGraphManager.h"
7#include "BlueprintEditor.h"
8#include "../third_party/imgui/imgui.h"
9#include <iostream>
10#include "BlueprintValidator.h"
11
12namespace Olympe
13{
17
21
23 {
24 std::cout << "[ValidationPanel] Initialized\n";
25 }
26
28 {
29 std::cout << "[ValidationPanel] Shutdown\n";
30 }
31
33 {
34 ImGui::Begin("Validation");
35
36 // Auto-validate checkbox
37 ImGui::Checkbox("Auto-validate", &m_AutoValidate);
38 ImGui::SameLine();
39
40 // Manual validate button
41 if (ImGui::Button("Validate Now"))
42 {
44 }
45
46 ImGui::Separator();
47
48 // Show summary
50
51 ImGui::Separator();
52
53 // Show error list
55
56 ImGui::End();
57
58 // Auto-validation
60 {
61 // Validate every few seconds
62 float currentTime = (float) ImGui::GetTime();
64 {
67 }
68 }
69 }
70
72 {
73 m_Errors.clear();
74
76 if (!graph)
77 {
78 return;
79 }
80
82
83 if (!m_Errors.empty())
84 {
85 std::cout << "[ValidationPanel] Found " << m_Errors.size() << " validation errors\n";
86 }
87 }
88
90 {
91 for (const ValidationError& error : m_Errors)
92 {
93 if (error.severity == ErrorSeverity::Error || error.severity == ErrorSeverity::Critical)
94 return true;
95 }
96 return false;
97 }
98
100 {
101 for (const ValidationError& error : m_Errors)
102 {
103 if (error.severity == ErrorSeverity::Critical)
104 return true;
105 }
106 return false;
107 }
108
110 {
115
116 if (m_Errors.empty())
117 {
118 ImGui::TextColored(ImVec4(0.0f, 1.0f, 0.0f, 1.0f), "-> No validation errors");
119 return;
120 }
121
122 ImGui::Text("Validation Summary:");
123
124 if (criticalCount > 0)
125 {
127 " Critical: %d", criticalCount);
128 }
129
130 if (errorCount > 0)
131 {
133 " Errors: %d", errorCount);
134 }
135
136 if (warningCount > 0)
137 {
139 " Warnings: %d", warningCount);
140 }
141
142 if (infoCount > 0)
143 {
145 " Info: %d", infoCount);
146 }
147 }
148
150 {
151 if (m_Errors.empty())
152 {
153 return;
154 }
155
156 ImGui::BeginChild("ErrorList", ImVec2(0, 0), true);
157
158 for (size_t i = 0; i < m_Errors.size(); ++i)
159 {
161
164
165 // Severity badge
166 ImGui::PushStyleColor(ImGuiCol_Text, color);
167 ImGui::Text("[%s]", severityStr);
168 ImGui::PopStyleColor();
169
170 ImGui::SameLine();
171
172 // Error message (clickable)
173 bool isSelected = (m_SelectedErrorIndex == (int)i);
174
175 std::string label = error.message;
176 if (!error.nodeName.empty())
177 {
178 label = error.nodeName + ": " + label;
179 }
180
181 if (ImGui::Selectable(label.c_str(), isSelected))
182 {
185 }
186
187 // Tooltip with more details
188 if (ImGui::IsItemHovered())
189 {
190 ImGui::BeginTooltip();
191 if (error.nodeId >= 0)
192 {
193 ImGui::Text("Node ID: %d", error.nodeId);
194 }
195 if (!error.category.empty())
196 {
197 ImGui::Text("Category: %s", error.category.c_str());
198 }
199 ImGui::Text("Severity: %s", severityStr);
200 ImGui::Separator();
201 ImGui::TextWrapped("%s", error.message.c_str());
202 ImGui::EndTooltip();
203 }
204 }
205
206 ImGui::EndChild();
207 }
208
210 {
211 if (error.nodeId >= 0)
212 {
213 // TODO: Focus on the node in the graph editor
214 // This would require adding a method to NodeGraphPanel to focus on a specific node
215 std::cout << "[ValidationPanel] Clicked on error for node " << error.nodeId << std::endl;
216 }
217 }
218}
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
int GetErrorCount(const std::vector< ValidationError > &errors, ErrorSeverity severity) const
static ImVec4 SeverityToColor(ErrorSeverity severity)
static const char * SeverityToString(ErrorSeverity severity)
std::vector< ValidationError > ValidateGraph(const NodeGraph *graph)
static NodeGraphManager & Get()
BlueprintValidator m_Validator
std::vector< ValidationError > m_Errors
void OnErrorClicked(const ValidationError &error)