Ember
Loading...
Searching...
No Matches
BehaviorTreeProjectDialog.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <string>
5#include <vector>
6#include <wx/listctrl.h>
7#include <wx/notebook.h>
8#include <wx/scrolwin.h>
9#include <wx/splitter.h>
10#include <wx/stc/stc.h>
11#include <wx/timer.h>
12#include <wx/treectrl.h>
13#include <wx/wx.h>
14
15// Forward declarations
16namespace EmberCore {
19} // namespace EmberCore
20
31class BehaviorTreeProjectDialog : public wxDialog {
32 public:
38 explicit BehaviorTreeProjectDialog(wxWindow *parent,
39 std::shared_ptr<EmberCore::BehaviorTreeProject> project = nullptr);
41
45 std::shared_ptr<EmberCore::BehaviorTreeProject> GetProject() const { return m_project; }
46
50 bool IsProjectValid() const { return m_isValid; }
51
52 private:
53 // UI Creation methods
54 void CreateLayout();
55 wxPanel *CreateLeftPanel(wxWindow *parent);
56 wxPanel *CreateRightPanel(wxWindow *parent);
57
58 // Tab creation methods
59 wxPanel *CreateResourcesTab(wxNotebook *notebook);
60 wxPanel *CreateValidationTab(wxNotebook *notebook);
61 wxPanel *CreatePreviewTab(wxNotebook *notebook);
62 wxPanel *CreateBlackboardTab(wxNotebook *notebook);
63
64 // Event handlers - Project settings
65 void OnProjectNameChanged(wxCommandEvent &event);
66 void OnDescriptionChanged(wxCommandEvent &event);
67 void OnProfileSelected(wxCommandEvent &event);
68
69 // Event handlers - Resource management
70 void OnAddFiles(wxCommandEvent &event);
71 void OnAddFolder(wxCommandEvent &event);
72 void OnRemoveFiles(wxCommandEvent &event);
73 void OnClearFiles(wxCommandEvent &event);
74 void OnResourceSelected(wxListEvent &event);
75 void OnResourceActivated(wxListEvent &event);
76
77 // Event handlers - Validation
78 void OnValidate(wxCommandEvent &event);
79 void OnRefreshPreview(wxCommandEvent &event);
80
81 // Event handlers - Dialog buttons
82 void OnCreate(wxCommandEvent &event);
83 void OnCancel(wxCommandEvent &event);
84 void OnSave(wxCommandEvent &event);
85
86 // Helper methods
87 void LoadProfileList();
88 void UpdateResourceList();
90 void UpdateTreePreview();
94 void DrawFileStructureDiagram(wxDC &dc);
95 void DrawBlackboardDiagram(wxDC &dc);
96 void OnStructurePanelClick(wxMouseEvent &event);
97 void LoadXMLPreview(const std::string &filepath, int highlightLine = -1);
98 void LoadTreePreview(const std::string &filepath, const std::string &treeId);
99 void LoadBlackboardPreview(const std::string &filepath, const std::string &blackboardId);
100 void OnPreviewFilterChanged(wxCommandEvent &event);
101 void UpdateBlackboardTab();
102
103 // Validation helpers
104 bool IsValidProjectName(const wxString &name) const;
105 void OnPulseTimer(wxTimerEvent &event);
107 wxColour InterpolateColor(const wxColour &color1, const wxColour &color2, float t);
108
109 // Resource validation helpers
110 wxString GetResourceStatusIcon(bool valid) const;
111 void SetResourceItemStatus(long item, bool valid, int treeCount);
112
113 // Populate from existing project
114 void PopulateFromProject();
115
116 private:
117 // Project data
118 std::shared_ptr<EmberCore::BehaviorTreeProject> m_project;
120 bool m_isEditMode; // true if editing existing project
121
122 // Left panel - Project settings
123 wxTextCtrl *m_projectName;
126
127 // Right panel - Tabs
128 wxNotebook *m_notebook;
129
130 // Resources tab
131 wxListCtrl *m_resourceList;
132 wxButton *m_addFilesBtn;
133 wxButton *m_addFolderBtn;
136 wxStaticText *m_resourceCountLabel;
137
138 // Validation tab
140 wxButton *m_validateBtn;
141 wxStaticText *m_validationStatus;
142 wxStaticBitmap *m_validationIcon;
145
146 // Preview tab
147 wxScrolledWindow *m_fileStructurePanel; // File structure diagram (scrollable)
148 wxStyledTextCtrl *m_xmlPreviewPanel; // XML content preview (read-only with line numbers)
149 wxTextCtrl *m_warningDetailsPanel; // Warning/Error details (only visible when warning clicked)
150
151 // Preview filters
159 wxStaticText *m_treeCountLabel;
160
161 // Clickable item tracking
165 wxRect rect;
166 std::string identifier; // filename, tree_id, blackboard_id, or warning text
167 std::string filepath; // for trees, blackboards, and warnings
168 int line_number; // for warnings (-1 if not applicable)
169 };
170 std::vector<ClickableItem> m_clickableItems;
171
172 // Blackboard tab
173 wxScrolledWindow *m_blackboardPanel;
174
175 // Bottom buttons
176 wxButton *m_createBtn;
177 wxButton *m_cancelBtn;
178
179 // Validation state
180 std::unique_ptr<EmberCore::ProjectValidationReport> m_lastValidationReport;
181 bool m_validationStale; // true if resources/profile changed since last validation
182 wxString m_lastValidatedParserProfile; // track parser profile changes
183
184 // Image list for resource status icons
186
187 // Last used directory for file dialogs (persists across dialog opens)
188 static wxString s_lastUsedDirectory;
189
190 // Field highlighting for validation
191 wxTimer *m_pulseTimer;
193 wxColour m_normalBg;
195
196 int m_selectedItemIndex; // Index of currently selected item (-1 if none)
197
199
200 // Control IDs
201 enum {
205
211
214
217
219 };
220};
BehaviorTreeProjectDialog(wxWindow *parent, std::shared_ptr< EmberCore::BehaviorTreeProject > project=nullptr)
Construct a new dialog for creating/editing a project.
void OnResourceSelected(wxListEvent &event)
void SetResourceItemStatus(long item, bool valid, int treeCount)
void OnProfileSelected(wxCommandEvent &event)
void LoadTreePreview(const std::string &filepath, const std::string &treeId)
void OnClearFiles(wxCommandEvent &event)
wxPanel * CreatePreviewTab(wxNotebook *notebook)
wxPanel * CreateValidationTab(wxNotebook *notebook)
void OnValidate(wxCommandEvent &event)
wxColour InterpolateColor(const wxColour &color1, const wxColour &color2, float t)
wxPanel * CreateBlackboardTab(wxNotebook *notebook)
void OnDescriptionChanged(wxCommandEvent &event)
wxPanel * CreateRightPanel(wxWindow *parent)
void OnCancel(wxCommandEvent &event)
void OnSave(wxCommandEvent &event)
void OnPulseTimer(wxTimerEvent &event)
void OnProjectNameChanged(wxCommandEvent &event)
std::vector< ClickableItem > m_clickableItems
void OnStructurePanelClick(wxMouseEvent &event)
void OnResourceActivated(wxListEvent &event)
void OnRefreshPreview(wxCommandEvent &event)
void LoadBlackboardPreview(const std::string &filepath, const std::string &blackboardId)
std::unique_ptr< EmberCore::ProjectValidationReport > m_lastValidationReport
void GenerateColoredValidationReport(const EmberCore::ProjectValidationReport &report)
void LoadXMLPreview(const std::string &filepath, int highlightLine=-1)
void OnCreate(wxCommandEvent &event)
bool IsProjectValid() const
Check if the project configuration is valid.
void OnPreviewFilterChanged(wxCommandEvent &event)
std::shared_ptr< EmberCore::BehaviorTreeProject > m_project
void OnAddFolder(wxCommandEvent &event)
std::shared_ptr< EmberCore::BehaviorTreeProject > GetProject() const
Get the configured project (after dialog is closed with OK)
wxPanel * CreateLeftPanel(wxWindow *parent)
bool IsValidProjectName(const wxString &name) const
wxPanel * CreateResourcesTab(wxNotebook *notebook)
void OnAddFiles(wxCommandEvent &event)
wxString GetResourceStatusIcon(bool valid) const
void OnRemoveFiles(wxCommandEvent &event)
Represents a BehaviorTree project containing multiple XML resources.
Main types header for EmberCore.
Complete validation report for a project.