Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
AIEditorGUI.h
Go to the documentation of this file.
1/**
2 * @file AIEditorGUI.h
3 * @brief Main GUI class for AI Editor (Phase 1.3)
4 * @author Olympe Engine
5 * @date 2026-02-18
6 *
7 * @details
8 * Provides complete AI Editor interface with:
9 * - 3-panel layout (AssetBrowser, NodeGraph, Inspector)
10 * - Integration with NodeGraphCore and AIGraphPlugin_BT
11 * - AI-specific panels (Blackboard, Senses, Runtime Debug)
12 * - Full CRUD workflow for Behavior Trees
13 */
14
15#pragma once
16
17#include "../../NodeGraphCore/NodeGraphCore.h"
18#include "../../NodeGraphCore/GraphDocument.h"
19#include "../../NodeGraphCore/NodeGraphManager.h"
20#include "../../NodeGraphCore/CommandSystem.h"
21#include "../../NodeGraphCore/Commands/ToggleNodeBreakpointCommand.h"
22#include "../../NodeGraphCore/BlackboardSystem.h"
23#include "../AIGraphPlugin_BT/BTNodeRegistry.h"
24#include "../AIGraphPlugin_BT/BTNodePalette.h"
25#include "BlackboardPanel.h"
26#include <string>
27#include <memory>
28#include <vector>
29
30namespace Olympe {
31namespace AI {
32
33/**
34 * @class AIEditorGUI
35 * @brief Main AI Editor GUI class
36 *
37 * @details
38 * Manages the complete AI Editor interface. Integrates NodeGraphCore
39 * for graph management and AIGraphPlugin_BT for BT-specific functionality.
40 */
42public:
43 // Friend class to allow menu access
44 friend class AIEditorMenus;
45
48
49 /**
50 * @brief Initialize the editor
51 * @return true if successful
52 */
53 bool Initialize();
54
55 /**
56 * @brief Shutdown and cleanup
57 */
58 void Shutdown();
59
60 /**
61 * @brief Render the complete UI
62 */
63 void Render();
64
65 /**
66 * @brief Update (called per frame)
67 * @param deltaTime Time since last frame
68 */
69 void Update(float deltaTime);
70
71 /**
72 * @brief Check if editor is active
73 */
74 bool IsActive() const { return m_isActive; }
75
76 /**
77 * @brief Set editor active state
78 */
80
81 /**
82 * @brief Get command stack for undo/redo
83 */
85
86private:
87 // ========================================================================
88 // Core Rendering
89 // ========================================================================
90
91 /**
92 * @brief Render main menu bar
93 */
94 void RenderMenuBar();
95
96 /**
97 * @brief Render asset browser panel (left)
98 */
99 void RenderAssetBrowser();
100
101 /**
102 * @brief Render node graph panel (center)
103 */
104 void RenderNodeGraph();
105
106 /**
107 * @brief Render inspector panel (right)
108 */
109 void RenderInspector();
110
111 // ========================================================================
112 // Menu Actions
113 // ========================================================================
114
115 void MenuAction_NewBT();
116 void MenuAction_NewHFSM();
117 void MenuAction_Open();
118 void MenuAction_Save();
119 void MenuAction_SaveAs();
120 void MenuAction_Close();
121 void MenuAction_Undo();
122 void MenuAction_Redo();
123 void MenuAction_Cut();
124 void MenuAction_Copy();
125 void MenuAction_Paste();
126 void MenuAction_Delete();
133 void MenuAction_About();
135
136 // ========================================================================
137 // Node Graph Rendering
138 // ========================================================================
139
140 /**
141 * @brief Render node graph with ImNodes
142 */
144
145 /**
146 * @brief Render a single node
147 * @param nodeId Node to render
148 */
149 void RenderNode(NodeGraph::NodeId nodeId);
150
151 /**
152 * @brief Render connections between nodes
153 */
154 void RenderConnections();
155
156 /**
157 * @brief Handle node creation from palette
158 */
159 void HandleNodeCreation();
160
161 /**
162 * @brief Handle node selection
163 */
164 void HandleNodeSelection();
165
166 /**
167 * @brief Handle link creation
168 */
169 void HandleLinkCreation();
170
171 // ========================================================================
172 // AI-Specific Panels
173 // ========================================================================
174
175 /**
176 * @brief Render blackboard inspector panel
177 */
179
180 /**
181 * @brief Render AI senses debug panel
182 */
183 void RenderSensesPanel();
184
185 /**
186 * @brief Render runtime debug panel (entity list + execution)
187 */
189
190 // ========================================================================
191 // Asset Browser
192 // ========================================================================
193
194 /**
195 * @brief Scan directory for AI graphs
196 */
197 void ScanAIGraphDirectory(const std::string& directory);
198
199 /**
200 * @brief Render asset entry
201 * @param filename Filename to render
202 * @param fullPath Full path to file
203 */
204 void RenderAssetEntry(const std::string& filename, const std::string& fullPath);
205
206 // ========================================================================
207 // Helper Methods
208 // ========================================================================
209
210 /**
211 * @brief Extract directory from filepath
212 * @param filepath Full file path
213 * @return Directory path without filename
214 */
215 static std::string ExtractDirectory(const std::string& filepath);
216
217 /**
218 * @brief Extract filename from filepath
219 * @param filepath Full file path
220 * @return Filename without directory
221 */
222 static std::string ExtractFilename(const std::string& filepath);
223
224 /**
225 * @brief Check if string ends with suffix
226 * @param str String to check
227 * @param suffix Suffix to look for
228 * @return true if str ends with suffix
229 */
230 static bool EndsWith(const std::string& str, const std::string& suffix);
231
232 // ========================================================================
233 // State
234 // ========================================================================
235
241
242 // Panel state
244 std::vector<std::string> m_assetFiles;
245
246 // File dialog state
247 std::string m_lastOpenPath;
248 std::string m_lastSavePath;
249
250 // Node palette
251 std::unique_ptr<BTNodePalette> m_nodePalette;
252
253 // Blackboard panel (Phase 2.1)
255
256 // Command system for undo/redo
258
259 // ImNodes context
261
262 // Current selection
263 std::vector<int> m_selectedNodeIds;
264 std::vector<int> m_selectedLinkIds;
265};
266
267} // namespace AI
268} // namespace Olympe
ImGui panel for editing blackboard variables (Phase 2.1)
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Main AI Editor GUI class.
Definition AIEditorGUI.h:41
static std::string ExtractDirectory(const std::string &filepath)
Extract directory from filepath.
void RenderInspector()
Render inspector panel (right)
void HandleNodeCreation()
Handle node creation from palette.
void RenderNodeGraphCanvas()
Render node graph with ImNodes.
std::unique_ptr< BTNodePalette > m_nodePalette
std::vector< int > m_selectedLinkIds
void Shutdown()
Shutdown and cleanup.
std::vector< std::string > m_assetFiles
static bool EndsWith(const std::string &str, const std::string &suffix)
Check if string ends with suffix.
static std::string ExtractFilename(const std::string &filepath)
Extract filename from filepath.
void RenderRuntimeDebugPanel()
Render runtime debug panel (entity list + execution)
void Render()
Render the complete UI.
void RenderNode(NodeGraph::NodeId nodeId)
Render a single node.
void HandleLinkCreation()
Handle link creation.
void RenderBlackboardPanel()
Render blackboard inspector panel.
BlackboardPanel m_blackboardPanel
void RenderMenuBar()
Render main menu bar.
void RenderSensesPanel()
Render AI senses debug panel.
NodeGraph::CommandStack & GetCommandStack()
Get command stack for undo/redo.
Definition AIEditorGUI.h:84
void HandleNodeSelection()
Handle node selection.
void SetActive(bool active)
Set editor active state.
Definition AIEditorGUI.h:79
void RenderNodeGraph()
Render node graph panel (center)
void RenderConnections()
Render connections between nodes.
std::vector< int > m_selectedNodeIds
void RenderAssetEntry(const std::string &filename, const std::string &fullPath)
Render asset entry.
void ScanAIGraphDirectory(const std::string &directory)
Scan directory for AI graphs.
void Update(float deltaTime)
Update (called per frame)
bool Initialize()
Initialize the editor.
bool IsActive() const
Check if editor is active.
Definition AIEditorGUI.h:74
void RenderAssetBrowser()
Render asset browser panel (left)
NodeGraph::CommandStack m_commandStack
Static menu helper functions.
Full-featured ImGui panel for editing BlackboardSystem variables.
Manages undo/redo stacks for commands.
< Provides AssetID and INVALID_ASSET_ID