Ember
Loading...
Searching...
No Matches
AppPreferences.cpp
Go to the documentation of this file.
2#include "Utils/Logger.h"
4#include <wx/colour.h>
5#include <wx/file.h>
6#include <wx/fileconf.h>
7#include <wx/filename.h>
8#include <wx/tokenzr.h>
9
10namespace EmberForge {
11
13 // Defaults are set in the struct definitions
14}
15
27
29 return ResourcePath::Get("config/app_preferences.conf").ToStdString();
30}
31
33 LOG_INFO("AppPreferences", "Loading preferences from: " + filename);
34
35 if (!wxFile::Exists(filename)) {
36 LOG_WARNING("AppPreferences", "Preferences file does not exist: " + filename);
37 return false;
38 }
39
40 try {
41 wxFileConfig config(wxEmptyString, wxEmptyString, filename, wxEmptyString,
42 wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH);
43
44 // Load window settings
45 config.SetPath("/Window");
46 windowSettings_.windowX = config.Read("WindowX", -1L);
47 windowSettings_.windowY = config.Read("WindowY", -1L);
48 windowSettings_.windowWidth = config.Read("WindowWidth", 1280L);
49 windowSettings_.windowHeight = config.Read("WindowHeight", 720L);
50
51 wxString startupModeStr = config.Read("StartupMode", "Normal");
52 windowSettings_.startupMode = StringToStartupMode(startupModeStr.ToStdString());
53
54 windowSettings_.maximizeHotkey = config.Read("MaximizeHotkey", "F11");
55
56 // File menu hotkeys
57 windowSettings_.newProjectHotkey = config.Read("NewProjectHotkey", "Ctrl+Shift+N");
58 windowSettings_.openProjectHotkey = config.Read("OpenProjectHotkey", "Ctrl+Shift+O");
59 windowSettings_.openFileHotkey = config.Read("OpenFileHotkey", "Ctrl+O");
60 windowSettings_.saveHotkey = config.Read("SaveHotkey", "Ctrl+S");
61 windowSettings_.saveAsHotkey = config.Read("SaveAsHotkey", "Ctrl+Shift+S");
62
63 // View menu hotkeys
64 windowSettings_.resetUIHotkey = config.Read("ResetUIHotkey", "Ctrl+Shift+R");
65
66 // Settings menu hotkeys
67 windowSettings_.preferencesHotkey = config.Read("PreferencesHotkey", "Ctrl+,");
68 windowSettings_.parserConfigHotkey = config.Read("ParserConfigHotkey", "Ctrl+Shift+P");
69
70 wxString themeStr = config.Read("Theme", "Dark");
71 windowSettings_.theme = StringToThemeMode(themeStr.ToStdString());
72
73 long r = config.Read("AccentColorR", 100L);
74 long g = config.Read("AccentColorG", 149L);
75 long b = config.Read("AccentColorB", 237L);
76 windowSettings_.accentColor = EmberCore::Color(r, g, b);
77
78 // Window appearance and behavior
79 windowSettings_.showStatusBar = config.ReadBool("ShowStatusBar", true);
80 windowSettings_.showPanelCaptions = config.ReadBool("ShowPanelCaptions", false);
81 windowSettings_.alwaysOnTop = config.ReadBool("AlwaysOnTop", false);
82
83 // Window constraints
84 windowSettings_.minWindowWidth = config.Read("MinWindowWidth", 800L);
85 windowSettings_.minWindowHeight = config.Read("MinWindowHeight", 600L);
86 windowSettings_.maxWindowWidth = config.Read("MaxWindowWidth", -1L);
87 windowSettings_.maxWindowHeight = config.Read("MaxWindowHeight", -1L);
88 windowSettings_.enforceAspectRatio = config.ReadBool("EnforceAspectRatio", false);
89 windowSettings_.aspectRatio = config.ReadDouble("AspectRatio", 16.0 / 9.0);
90
91 // Load main panel settings
92 config.SetPath("/MainPanel");
93 windowSettings_.windowWidth = config.Read("WindowWidth", 1280L);
94 mainPanelSettings_.defaultZoomLevel = config.ReadDouble("DefaultZoomLevel", 1.0);
95 mainPanelSettings_.showGrid = config.ReadBool("ShowGrid", true);
96 mainPanelSettings_.gridSize = config.Read("GridSize", 20L);
97
98 r = config.Read("GridBackgroundR", 45L);
99 g = config.Read("GridBackgroundG", 45L);
100 b = config.Read("GridBackgroundB", 45L);
101 mainPanelSettings_.gridBackgroundColor = EmberCore::Color(r, g, b);
102
103 r = config.Read("GridLineR", 54L);
104 g = config.Read("GridLineG", 54L);
105 b = config.Read("GridLineB", 54L);
106 mainPanelSettings_.gridLineColor = EmberCore::Color(r, g, b);
107
108 mainPanelSettings_.snapToGrid = config.ReadBool("SnapToGrid", false);
109
110 r = config.Read("CanvasBackgroundR", 50L);
111 g = config.Read("CanvasBackgroundG", 50L);
112 b = config.Read("CanvasBackgroundB", 50L);
113 mainPanelSettings_.canvasBackgroundColor = EmberCore::Color(r, g, b);
114
115 r = config.Read("ConnectionLineR", 255L);
116 g = config.Read("ConnectionLineG", 255L);
117 b = config.Read("ConnectionLineB", 255L);
118 mainPanelSettings_.connectionLineColor = EmberCore::Color(r, g, b);
119
120 mainPanelSettings_.highlightPathToSelected = config.ReadBool("HighlightPathToSelected", true);
121
122 r = config.Read("PathHighlightR", 144L);
123 g = config.Read("PathHighlightG", 238L);
124 b = config.Read("PathHighlightB", 144L);
125 mainPanelSettings_.pathHighlightColor = EmberCore::Color(r, g, b);
126
127 r = config.Read("IdleNodeBgR", 75L);
128 g = config.Read("IdleNodeBgG", 75L);
129 b = config.Read("IdleNodeBgB", 75L);
130 mainPanelSettings_.idleNodeBgColor = EmberCore::Color(r, g, b);
131
132 r = config.Read("IdleNodeBorderR", 120L);
133 g = config.Read("IdleNodeBorderG", 120L);
134 b = config.Read("IdleNodeBorderB", 120L);
135 mainPanelSettings_.idleNodeBorderColor = EmberCore::Color(r, g, b);
136
137 r = config.Read("IdleNodeTextR", 180L);
138 g = config.Read("IdleNodeTextG", 180L);
139 b = config.Read("IdleNodeTextB", 180L);
140 mainPanelSettings_.idleNodeTextColor = EmberCore::Color(r, g, b);
141
142 mainPanelSettings_.selectedNodeBgTint = static_cast<float>(config.Read("SelectedNodeBgTint", -33L)) / 100.0f;
143 mainPanelSettings_.hoveredNodeBgTint = static_cast<float>(config.Read("HoveredNodeBgTint", -13L)) / 100.0f;
144
145 r = config.Read("SelectedNodeR", 48L);
146 g = config.Read("SelectedNodeG", 92L);
147 b = config.Read("SelectedNodeB", 222L);
148 mainPanelSettings_.selectedNodeColor = EmberCore::Color(r, g, b);
149
150 r = config.Read("HoveredNodeR", 144L);
151 g = config.Read("HoveredNodeG", 238L);
152 b = config.Read("HoveredNodeB", 144L);
153 mainPanelSettings_.hoveredNodeColor = EmberCore::Color(r, g, b);
154
155 r = config.Read("SelectedNodeTextR", 255L);
156 g = config.Read("SelectedNodeTextG", 255L);
157 b = config.Read("SelectedNodeTextB", 255L);
158 mainPanelSettings_.selectedNodeTextColor = EmberCore::Color(r, g, b);
159
160 r = config.Read("HoveredNodeTextR", 255L);
161 g = config.Read("HoveredNodeTextG", 255L);
162 b = config.Read("HoveredNodeTextB", 255L);
163 mainPanelSettings_.hoveredNodeTextColor = EmberCore::Color(r, g, b);
164
165 r = config.Read("SelectedNodeInfoR", 200L);
166 g = config.Read("SelectedNodeInfoG", 200L);
167 b = config.Read("SelectedNodeInfoB", 200L);
168 mainPanelSettings_.selectedNodeInfoColor = EmberCore::Color(r, g, b);
169
170 r = config.Read("HoveredNodeInfoR", 200L);
171 g = config.Read("HoveredNodeInfoG", 200L);
172 b = config.Read("HoveredNodeInfoB", 200L);
173 mainPanelSettings_.hoveredNodeInfoColor = EmberCore::Color(r, g, b);
174
175 mainPanelSettings_.maxScenes = config.Read("MaxScenes", 10L);
176
177 wxString closeConfirmStr = config.Read("CloseConfirmation", "AskIfUnsaved");
178 mainPanelSettings_.closeConfirmation = StringToCloseConfirmationMode(closeConfirmStr.ToStdString());
179
180 mainPanelSettings_.nextSceneHotkey = config.Read("NextSceneHotkey", "Ctrl+Tab");
181 mainPanelSettings_.previousSceneHotkey = config.Read("PreviousSceneHotkey", "Ctrl+Shift+Tab");
182
183 // Load behavior tree view settings
184 config.SetPath("/BehaviorTreeView");
185 behaviorTreeViewSettings_.zoomStepSize = config.ReadDouble("ZoomStepSize", 0.1);
186 behaviorTreeViewSettings_.mouseWheelSensitivity = config.ReadDouble("MouseWheelSensitivity", 1.0);
187 behaviorTreeViewSettings_.zoomFollowsCursor = config.ReadBool("ZoomFollowsCursor", true);
188 behaviorTreeViewSettings_.resetViewHotkey = config.Read("ResetViewHotkey", "R");
189 behaviorTreeViewSettings_.panSensitivity = config.ReadDouble("PanSensitivity", 1.51);
190 behaviorTreeViewSettings_.panKey = config.Read("PanKey", "Middle Mouse Button");
191 behaviorTreeViewSettings_.enableSmoothPanning = config.ReadBool("EnableSmoothPanning", false);
192 behaviorTreeViewSettings_.panSmoothness = config.ReadDouble("PanSmoothness", 30.0);
193 behaviorTreeViewSettings_.panStepSize = config.ReadDouble("PanStepSize", 40.0);
194 behaviorTreeViewSettings_.centerOnNodeHotkey = config.Read("CenterOnNodeHotkey", "C");
195 behaviorTreeViewSettings_.deleteNodeHotkey = config.Read("DeleteNodeHotkey", "Delete");
196 behaviorTreeViewSettings_.panUpHotkey = config.Read("PanUpHotkey", "Up");
197 behaviorTreeViewSettings_.panDownHotkey = config.Read("PanDownHotkey", "Down");
198 behaviorTreeViewSettings_.panLeftHotkey = config.Read("PanLeftHotkey", "Left");
199 behaviorTreeViewSettings_.panRightHotkey = config.Read("PanRightHotkey", "Right");
200
201 // Load debug text - Coordinate System Info settings
202 behaviorTreeViewSettings_.showCoordinateInfo = config.ReadBool("ShowCoordinateInfo", true);
203 behaviorTreeViewSettings_.coordinateInfoFontSize = config.Read("CoordinateInfoFontSize", 9L);
204 r = config.Read("CoordinateInfoR", 200L);
205 g = config.Read("CoordinateInfoG", 200L);
206 b = config.Read("CoordinateInfoB", 200L);
207 behaviorTreeViewSettings_.coordinateInfoColor = EmberCore::Color(r, g, b);
208 behaviorTreeViewSettings_.coordinateInfoAnchor =
209 static_cast<TextAnchor>(config.Read("CoordinateInfoAnchor", 0L));
210 behaviorTreeViewSettings_.coordinateInfoX = config.Read("CoordinateInfoX", 10L);
211 behaviorTreeViewSettings_.coordinateInfoY = config.Read("CoordinateInfoY", 10L);
212
213 // Load debug text - Selected Node Info settings
214 behaviorTreeViewSettings_.showSelectedNodeInfo = config.ReadBool("ShowSelectedNodeInfo", true);
215 behaviorTreeViewSettings_.selectedNodeInfoFontSize = config.Read("SelectedNodeInfoFontSize", 9L);
216 r = config.Read("SelectedNodeInfoR", 100L);
217 g = config.Read("SelectedNodeInfoG", 150L);
218 b = config.Read("SelectedNodeInfoB", 255L);
219 behaviorTreeViewSettings_.selectedNodeInfoColor = EmberCore::Color(r, g, b);
220 behaviorTreeViewSettings_.selectedNodeInfoAnchor =
221 static_cast<TextAnchor>(config.Read("SelectedNodeInfoAnchor", 0L));
222 behaviorTreeViewSettings_.selectedNodeInfoX = config.Read("SelectedNodeInfoX", 10L);
223 behaviorTreeViewSettings_.selectedNodeInfoY = config.Read("SelectedNodeInfoY", 30L);
224
225 // Load debug text - Tree Statistics Info settings
226 behaviorTreeViewSettings_.showTreeInfo = config.ReadBool("ShowTreeInfo", true);
227 behaviorTreeViewSettings_.treeInfoFontSize = config.Read("TreeInfoFontSize", 9L);
228 r = config.Read("TreeInfoR", 150L);
229 g = config.Read("TreeInfoG", 200L);
230 b = config.Read("TreeInfoB", 150L);
231 behaviorTreeViewSettings_.treeInfoColor = EmberCore::Color(r, g, b);
232 behaviorTreeViewSettings_.treeInfoAnchor = static_cast<TextAnchor>(config.Read("TreeInfoAnchor", 0L));
233 behaviorTreeViewSettings_.treeInfoX = config.Read("TreeInfoX", 10L);
234 behaviorTreeViewSettings_.treeInfoY = config.Read("TreeInfoY", 50L);
235
236 // Load debug text - FPS Display settings
237 behaviorTreeViewSettings_.showFPS = config.ReadBool("ShowFPS", true);
238 behaviorTreeViewSettings_.fpsFontSize = config.Read("FPSFontSize", 9L);
239 r = config.Read("FPSR", 255L);
240 g = config.Read("FPSG", 200L);
241 b = config.Read("FPSB", 100L);
243 behaviorTreeViewSettings_.fpsAnchor = static_cast<TextAnchor>(config.Read("FPSAnchor", 0L));
244 behaviorTreeViewSettings_.fpsX = config.Read("FPSX", 10L);
245 behaviorTreeViewSettings_.fpsY = config.Read("FPSY", 70L);
246
247 // Load debug text - Controls Help Text settings
248 behaviorTreeViewSettings_.showControlsHelp = config.ReadBool("ShowControlsHelp", true);
249 behaviorTreeViewSettings_.controlsHelpFontSize = config.Read("ControlsHelpFontSize", 11L);
250 r = config.Read("ControlsHelpR", 85L);
251 g = config.Read("ControlsHelpG", 87L);
252 b = config.Read("ControlsHelpB", 83L);
253 behaviorTreeViewSettings_.controlsHelpColor = EmberCore::Color(r, g, b);
254 behaviorTreeViewSettings_.controlsHelpAnchor =
255 static_cast<TextAnchor>(config.Read("ControlsHelpAnchor", 2L)); // Default to Bottom-Left
256 behaviorTreeViewSettings_.controlsHelpX = config.Read("ControlsHelpX", 10L);
257 behaviorTreeViewSettings_.controlsHelpY = config.Read("ControlsHelpY", 25L);
258
259 // Load bottom panel settings
260 config.SetPath("/BottomPanel");
261
262 // Panel layout settings
263 bottomPanelSettings_.defaultPanelHeight = config.Read("DefaultPanelHeight", 600L);
264 bottomPanelSettings_.defaultPanelHeightEnabled = config.ReadBool("DefaultPanelHeightEnabled", true);
265 bottomPanelSettings_.minimumPanelHeight = config.Read("MinimumPanelHeight", 500L);
266 bottomPanelSettings_.minimumPanelHeightEnabled = config.ReadBool("MinimumPanelHeightEnabled", true);
267 wxString startupStateStr = config.Read("PanelStartupState", "Show");
268 bottomPanelSettings_.panelStartupState = StringToPanelStartupState(startupStateStr.ToStdString());
269 bottomPanelSettings_.lastPanelVisible = config.ReadBool("LastPanelVisible", true);
270
271 // Tab bar settings
272 bottomPanelSettings_.showTabCloseButtons = config.ReadBool("ShowTabCloseButtons", true);
273
274 // Behavior settings
275 bottomPanelSettings_.rememberLastTab = config.ReadBool("RememberLastTab", true);
276 bottomPanelSettings_.allowPanelCollapse = config.ReadBool("AllowPanelCollapse", true);
277 bottomPanelSettings_.lastActiveTab = config.Read("LastActiveTab", "FileExplorer").ToStdString();
278
279 // Load lastOpenTabs as a comma-separated list
280 wxString lastOpenTabsStr = config.Read("LastOpenTabs", "FileExplorer,Log");
281 bottomPanelSettings_.lastOpenTabs.clear();
282 wxStringTokenizer tokenizer(lastOpenTabsStr, ",");
283 while (tokenizer.HasMoreTokens()) {
284 wxString token = tokenizer.GetNextToken().Trim().Trim(false);
285 if (!token.IsEmpty()) {
286 bottomPanelSettings_.lastOpenTabs.push_back(token.ToStdString());
287 }
288 }
289
290 // File Explorer general settings
291 bottomPanelSettings_.showBreadcrumb = config.ReadBool("ShowBreadcrumb", true);
292 bottomPanelSettings_.showHistory = config.ReadBool("ShowHistory", true);
293 wxString startPathModeStr = config.Read("StartPathMode", "ExecutableDirectory");
294 bottomPanelSettings_.startPathMode = StringToStartPathMode(startPathModeStr.ToStdString());
295 bottomPanelSettings_.customStartPath = config.Read("CustomStartPath", "").ToStdString();
296
297 // Tree View settings
298 config.SetPath("/BottomPanel/TreeView");
299 bottomPanelSettings_.treeView.showHiddenFiles = config.ReadBool("ShowHiddenFiles", false);
300 bottomPanelSettings_.treeView.showFileExtensions = config.ReadBool("ShowFileExtensions", true);
301 wxString treeViewSortByStr = config.Read("SortFilesBy", "Name");
302 bottomPanelSettings_.treeView.sortFilesBy = StringToSortBy(treeViewSortByStr.ToStdString());
303 wxString treeItemSizeStr = config.Read("ItemSize", "Medium");
304 bottomPanelSettings_.treeView.itemSize = StringToTreeItemSize(treeItemSizeStr.ToStdString());
305
306 // Grid View settings
307 config.SetPath("/BottomPanel/GridView");
308 bottomPanelSettings_.gridView.showHiddenFiles = config.ReadBool("ShowHiddenFiles", false);
309 bottomPanelSettings_.gridView.showFileExtensions = config.ReadBool("ShowFileExtensions", true);
310 wxString gridSortByStr = config.Read("SortFilesBy", "Name");
311 bottomPanelSettings_.gridView.sortFilesBy = StringToSortBy(gridSortByStr.ToStdString());
312 wxString iconSizeStr = config.Read("IconSize", "Medium");
313 bottomPanelSettings_.gridView.iconSize = StringToIconSize(iconSizeStr.ToStdString());
314
315 // Log Tab settings
316 config.SetPath("/BottomPanel/LogTab");
317 bottomPanelSettings_.logTab.defaultLevelFilter = config.ReadLong("DefaultLevelFilter", 3);
318 bottomPanelSettings_.logTab.autoScrollEnabled = config.ReadBool("AutoScrollEnabled", true);
319 bottomPanelSettings_.logTab.maxLogEntries = config.ReadLong("MaxLogEntries", 2000);
320 wxString logFontSizeStr = config.Read("FontSize", "Medium");
321 bottomPanelSettings_.logTab.fontSize = StringToLogFontSize(logFontSizeStr.ToStdString());
322
323 // Color settings
324 bottomPanelSettings_.logTab.enableGuiColors = config.ReadBool("EnableGuiColors", true);
325 bottomPanelSettings_.logTab.enableConsoleColors = config.ReadBool("EnableConsoleColors", true);
326
327 // Log level colors
328 config.SetPath("/BottomPanel/LogTab/Colors");
329 bottomPanelSettings_.logTab.traceColor.r = config.ReadLong("TraceR", 128);
330 bottomPanelSettings_.logTab.traceColor.g = config.ReadLong("TraceG", 128);
331 bottomPanelSettings_.logTab.traceColor.b = config.ReadLong("TraceB", 128);
332 bottomPanelSettings_.logTab.infoColor.r = config.ReadLong("InfoR", 100);
333 bottomPanelSettings_.logTab.infoColor.g = config.ReadLong("InfoG", 200);
334 bottomPanelSettings_.logTab.infoColor.b = config.ReadLong("InfoB", 100);
335 bottomPanelSettings_.logTab.warningColor.r = config.ReadLong("WarningR", 230);
336 bottomPanelSettings_.logTab.warningColor.g = config.ReadLong("WarningG", 180);
337 bottomPanelSettings_.logTab.warningColor.b = config.ReadLong("WarningB", 50);
338 bottomPanelSettings_.logTab.errorColor.r = config.ReadLong("ErrorR", 230);
339 bottomPanelSettings_.logTab.errorColor.g = config.ReadLong("ErrorG", 80);
340 bottomPanelSettings_.logTab.errorColor.b = config.ReadLong("ErrorB", 80);
341 bottomPanelSettings_.logTab.criticalColor.r = config.ReadLong("CriticalR", 255);
342 bottomPanelSettings_.logTab.criticalColor.g = config.ReadLong("CriticalG", 50);
343 bottomPanelSettings_.logTab.criticalColor.b = config.ReadLong("CriticalB", 50);
344
345 // Reset path for next section
346 config.SetPath("/");
347
348 // Load global side panel settings (currently empty, reserved for future use)
349 config.SetPath("/SidePanel");
350 // Future global settings that affect all panels would be loaded here
351 config.SetPath("/");
352
353 // Load left panel settings
354 config.SetPath("/LeftPanel");
355
356 // Panel layout settings
357 leftPanelSettings_.defaultPanelWidth = config.ReadLong("DefaultPanelWidth", 250);
358 leftPanelSettings_.defaultPanelWidthEnabled = config.ReadBool("DefaultPanelWidthEnabled", true);
359 leftPanelSettings_.minimumPanelWidth = config.ReadLong("MinimumPanelWidth", 150);
360 leftPanelSettings_.minimumPanelWidthEnabled = config.ReadBool("MinimumPanelWidthEnabled", true);
361 wxString leftPanelStartupStr = config.Read("PanelStartupState", "Show");
362 leftPanelSettings_.panelStartupState = StringToPanelStartupState(leftPanelStartupStr.ToStdString());
363 leftPanelSettings_.lastPanelVisible = config.ReadBool("LastPanelVisible", true);
364
365 // Tab bar settings
366 leftPanelSettings_.showTabCloseButtons = config.ReadBool("ShowTabCloseButtons", true);
367
368 // Behavior settings
369 leftPanelSettings_.rememberLastTab = config.ReadBool("RememberLastTab", true);
370 leftPanelSettings_.allowPanelCollapse = config.ReadBool("AllowPanelCollapse", true);
371 leftPanelSettings_.defaultActiveTab = config.Read("DefaultActiveTab", "Hierarchy").ToStdString();
372 leftPanelSettings_.lastActiveTab = config.Read("LastActiveTab", "Hierarchy").ToStdString();
373
374 // Load lastOpenTabs as a comma-separated list
375 wxString leftOpenTabsStr = config.Read("LastOpenTabs", "Hierarchy");
376 leftPanelSettings_.lastOpenTabs.clear();
377 wxStringTokenizer leftTokenizer(leftOpenTabsStr, ",");
378 while (leftTokenizer.HasMoreTokens()) {
379 wxString token = leftTokenizer.GetNextToken().Trim().Trim(false);
380 if (!token.IsEmpty()) {
381 leftPanelSettings_.lastOpenTabs.push_back(token.ToStdString());
382 }
383 }
384
385 // Scene Hierarchy Tab settings
386 config.SetPath("/LeftPanel/SceneHierarchyTab");
387 // Display settings
388 leftPanelSettings_.sceneHierarchy.showSearchBar = config.ReadBool("ShowSearchBar", true);
389 leftPanelSettings_.sceneHierarchy.showNodeIcons = config.ReadBool("ShowNodeIcons", true);
390 leftPanelSettings_.sceneHierarchy.showTreeLines = config.ReadBool("ShowTreeLines", false);
391 leftPanelSettings_.sceneHierarchy.treeIndentationSize = config.Read("TreeIndentationSize", 16L);
392 leftPanelSettings_.sceneHierarchy.iconSize = config.Read("IconSize", 16L);
393 leftPanelSettings_.sceneHierarchy.fontSize = config.Read("FontSize", 9L);
394 // Color settings
395 leftPanelSettings_.sceneHierarchy.backgroundColorR = config.Read("BackgroundColorR", 50L);
396 leftPanelSettings_.sceneHierarchy.backgroundColorG = config.ReadLong("BackgroundColorG", 50L);
397 leftPanelSettings_.sceneHierarchy.backgroundColorB = config.ReadLong("BackgroundColorB", 50L);
398 leftPanelSettings_.sceneHierarchy.textColorR = config.ReadLong("TextColorR", 255L);
399 leftPanelSettings_.sceneHierarchy.textColorG = config.ReadLong("TextColorG", 255L);
400 leftPanelSettings_.sceneHierarchy.textColorB = config.ReadLong("TextColorB", 255L);
401 leftPanelSettings_.sceneHierarchy.selectionColorR = config.ReadLong("SelectionColorR", 70L);
402 leftPanelSettings_.sceneHierarchy.selectionColorG = config.ReadLong("SelectionColorG", 130L);
403 leftPanelSettings_.sceneHierarchy.selectionColorB = config.ReadLong("SelectionColorB", 180L);
404 // Behavior settings
405 leftPanelSettings_.sceneHierarchy.autoExpandOnLoad = config.ReadBool("AutoExpandOnLoad", true);
406 leftPanelSettings_.sceneHierarchy.syncSelectionWithCanvas = config.ReadBool("SyncSelectionWithCanvas", true);
407 leftPanelSettings_.sceneHierarchy.liveSearch = config.ReadBool("LiveSearch", true);
408 leftPanelSettings_.sceneHierarchy.doubleClickAction =
409 static_cast<SceneHierarchyTabSettings::ClickAction>(config.ReadLong("DoubleClickAction", 0L));
410 leftPanelSettings_.sceneHierarchy.ctrlClickAction = static_cast<SceneHierarchyTabSettings::ClickAction>(
411 config.ReadLong("CtrlClickAction", 2L)); // Default: CenterInCanvas
412 // Context menu settings
413 leftPanelSettings_.sceneHierarchy.showAddChildOption = config.ReadBool("ShowAddChildOption", true);
414 leftPanelSettings_.sceneHierarchy.showDeleteOption = config.ReadBool("ShowDeleteOption", true);
415 leftPanelSettings_.sceneHierarchy.showRenameOption = config.ReadBool("ShowRenameOption", true);
416 leftPanelSettings_.sceneHierarchy.showDuplicateOption = config.ReadBool("ShowDuplicateOption", true);
417 // Performance settings
418 leftPanelSettings_.sceneHierarchy.rememberExpandedNodes = config.ReadBool("RememberExpandedNodes", true);
419
420 config.SetPath("/");
421
422 // Load right panel settings
423 config.SetPath("/RightPanel");
424
425 // Panel layout settings
426 rightPanelSettings_.defaultPanelWidth = config.ReadLong("DefaultPanelWidth", 450);
427 rightPanelSettings_.defaultPanelWidthEnabled = config.ReadBool("DefaultPanelWidthEnabled", true);
428 rightPanelSettings_.minimumPanelWidth = config.ReadLong("MinimumPanelWidth", 350);
429 rightPanelSettings_.minimumPanelWidthEnabled = config.ReadBool("MinimumPanelWidthEnabled", true);
430 wxString rightPanelStartupStr = config.Read("PanelStartupState", "Show");
431 rightPanelSettings_.panelStartupState = StringToPanelStartupState(rightPanelStartupStr.ToStdString());
432 rightPanelSettings_.lastPanelVisible = config.ReadBool("LastPanelVisible", true);
433
434 // Tab bar settings
435 rightPanelSettings_.showTabCloseButtons = config.ReadBool("ShowTabCloseButtons", true);
436
437 // Behavior settings
438 rightPanelSettings_.rememberLastTab = config.ReadBool("RememberLastTab", true);
439 rightPanelSettings_.allowPanelCollapse = config.ReadBool("AllowPanelCollapse", true);
440 rightPanelSettings_.defaultActiveTab = config.Read("DefaultActiveTab", "Tool").ToStdString();
441 rightPanelSettings_.lastActiveTab = config.Read("LastActiveTab", "Tool").ToStdString();
442
443 // Load lastOpenTabs as a comma-separated list
444 wxString rightOpenTabsStr = config.Read("LastOpenTabs", "Tool");
445 rightPanelSettings_.lastOpenTabs.clear();
446 wxStringTokenizer rightTokenizer(rightOpenTabsStr, ",");
447 while (rightTokenizer.HasMoreTokens()) {
448 wxString token = rightTokenizer.GetNextToken().Trim().Trim(false);
449 if (!token.IsEmpty()) {
450 rightPanelSettings_.lastOpenTabs.push_back(token.ToStdString());
451 }
452 }
453
454 // Reset path for next section
455 config.SetPath("/");
456
457 // Load parser settings
458 config.SetPath("/Parser");
459 parserSettings_.autoLoadLastFile = config.ReadBool("AutoLoadLastFile", false);
460 parserSettings_.lastOpenedFilePath = config.Read("LastOpenedFilePath", "").ToStdString();
461 parserSettings_.defaultFileEncoding = config.Read("DefaultFileEncoding", "UTF-8").ToStdString();
462 parserSettings_.showParseWarnings = config.ReadBool("ShowParseWarnings", true);
463
464 // Load performance settings
465 config.SetPath("/Performance");
466
467 // Rendering settings
468 performanceSettings_.enableVSync = config.ReadBool("EnableVSync", true);
469 performanceSettings_.hardwareAcceleration = config.ReadBool("HardwareAcceleration", true);
470 performanceSettings_.enableDoubleBuffering = config.ReadBool("EnableDoubleBuffering", true);
471 performanceSettings_.enableAntiAliasing = config.ReadBool("EnableAntiAliasing", true);
472 performanceSettings_.enableTextAntiAliasing = config.ReadBool("EnableTextAntiAliasing", true);
473 performanceSettings_.enablePartialRedraws = config.ReadBool("EnablePartialRedraws", true);
474 performanceSettings_.enableBackgroundErase = config.ReadBool("EnableBackgroundErase", false);
475
476 // Viewport culling settings
477 performanceSettings_.enableViewportCulling = config.ReadBool("EnableViewportCulling", true);
478 performanceSettings_.viewportCullingMargin = config.Read("ViewportCullingMargin", 500L);
479
480 wxString fpsLimitStr = config.Read("FPSLimit", "FPS_60");
481 performanceSettings_.fpsLimit = StringToFPSLimit(fpsLimitStr.ToStdString());
482
483 // UI responsiveness settings
484 performanceSettings_.enableIdleProcessing = config.ReadBool("EnableIdleProcessing", true);
485
486 LOG_INFO("AppPreferences", "Preferences loaded successfully");
487 return true;
488 } catch (const std::exception &e) {
489 LOG_ERROR("AppPreferences", "Error loading preferences: " + std::string(e.what()));
490 return false;
491 }
492}
493
495 LOG_INFO("AppPreferences", "Saving preferences to: " + filename);
496
497 try {
498 // Ensure directory exists
499 wxFileName fn(filename);
500 if (!fn.DirExists()) {
501 if (!fn.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL)) {
502 LOG_ERROR("AppPreferences", "Failed to create config directory");
503 return false;
504 }
505 }
506
507 wxFileConfig config(wxEmptyString, wxEmptyString, filename, wxEmptyString,
508 wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH);
509
510 // Save window settings
511 config.SetPath("/Window");
512 config.Write("WindowX", windowSettings_.windowX);
513 config.Write("WindowY", windowSettings_.windowY);
514 config.Write("WindowWidth", windowSettings_.windowWidth);
515 config.Write("WindowHeight", windowSettings_.windowHeight);
516 config.Write("StartupMode", wxString(StartupModeToString(windowSettings_.startupMode)));
517 config.Write("MaximizeHotkey", wxString(windowSettings_.maximizeHotkey));
518
519 // File menu hotkeys
520 config.Write("NewProjectHotkey", wxString(windowSettings_.newProjectHotkey));
521 config.Write("OpenProjectHotkey", wxString(windowSettings_.openProjectHotkey));
522 config.Write("OpenFileHotkey", wxString(windowSettings_.openFileHotkey));
523 config.Write("SaveHotkey", wxString(windowSettings_.saveHotkey));
524 config.Write("SaveAsHotkey", wxString(windowSettings_.saveAsHotkey));
525
526 // View menu hotkeys
527 config.Write("ResetUIHotkey", wxString(windowSettings_.resetUIHotkey));
528
529 // Settings menu hotkeys
530 config.Write("PreferencesHotkey", wxString(windowSettings_.preferencesHotkey));
531 config.Write("ParserConfigHotkey", wxString(windowSettings_.parserConfigHotkey));
532
533 config.Write("Theme", wxString(ThemeModeToString(windowSettings_.theme)));
534 config.Write("AccentColorR", static_cast<long>(windowSettings_.accentColor.r));
535 config.Write("AccentColorG", static_cast<long>(windowSettings_.accentColor.g));
536 config.Write("AccentColorB", static_cast<long>(windowSettings_.accentColor.b));
537
538 // Window appearance and behavior
539 config.Write("ShowStatusBar", windowSettings_.showStatusBar);
540 config.Write("ShowPanelCaptions", windowSettings_.showPanelCaptions);
541 config.Write("AlwaysOnTop", windowSettings_.alwaysOnTop);
542
543 // Window constraints
544 config.Write("MinWindowWidth", windowSettings_.minWindowWidth);
545 config.Write("MinWindowHeight", windowSettings_.minWindowHeight);
546 config.Write("MaxWindowWidth", windowSettings_.maxWindowWidth);
547 config.Write("MaxWindowHeight", windowSettings_.maxWindowHeight);
548 config.Write("EnforceAspectRatio", windowSettings_.enforceAspectRatio);
549 config.Write("AspectRatio", windowSettings_.aspectRatio);
550
551 // Save main panel settings
552 config.SetPath("/MainPanel");
553 config.Write("DefaultZoomLevel", mainPanelSettings_.defaultZoomLevel);
554 config.Write("ShowGrid", mainPanelSettings_.showGrid);
555 config.Write("GridSize", mainPanelSettings_.gridSize);
556 config.Write("GridBackgroundR", static_cast<long>(mainPanelSettings_.gridBackgroundColor.r));
557 config.Write("GridBackgroundG", static_cast<long>(mainPanelSettings_.gridBackgroundColor.g));
558 config.Write("GridBackgroundB", static_cast<long>(mainPanelSettings_.gridBackgroundColor.b));
559 config.Write("GridLineR", static_cast<long>(mainPanelSettings_.gridLineColor.r));
560 config.Write("GridLineG", static_cast<long>(mainPanelSettings_.gridLineColor.g));
561 config.Write("GridLineB", static_cast<long>(mainPanelSettings_.gridLineColor.b));
562 config.Write("SnapToGrid", mainPanelSettings_.snapToGrid);
563 config.Write("CanvasBackgroundR", static_cast<long>(mainPanelSettings_.canvasBackgroundColor.r));
564 config.Write("CanvasBackgroundG", static_cast<long>(mainPanelSettings_.canvasBackgroundColor.g));
565 config.Write("CanvasBackgroundB", static_cast<long>(mainPanelSettings_.canvasBackgroundColor.b));
566 config.Write("ConnectionLineR", static_cast<long>(mainPanelSettings_.connectionLineColor.r));
567 config.Write("ConnectionLineG", static_cast<long>(mainPanelSettings_.connectionLineColor.g));
568 config.Write("ConnectionLineB", static_cast<long>(mainPanelSettings_.connectionLineColor.b));
569 config.Write("HighlightPathToSelected", mainPanelSettings_.highlightPathToSelected);
570 config.Write("PathHighlightR", static_cast<long>(mainPanelSettings_.pathHighlightColor.r));
571 config.Write("PathHighlightG", static_cast<long>(mainPanelSettings_.pathHighlightColor.g));
572 config.Write("PathHighlightB", static_cast<long>(mainPanelSettings_.pathHighlightColor.b));
573 config.Write("IdleNodeBgR", static_cast<long>(mainPanelSettings_.idleNodeBgColor.r));
574 config.Write("IdleNodeBgG", static_cast<long>(mainPanelSettings_.idleNodeBgColor.g));
575 config.Write("IdleNodeBgB", static_cast<long>(mainPanelSettings_.idleNodeBgColor.b));
576 config.Write("IdleNodeBorderR", static_cast<long>(mainPanelSettings_.idleNodeBorderColor.r));
577 config.Write("IdleNodeBorderG", static_cast<long>(mainPanelSettings_.idleNodeBorderColor.g));
578 config.Write("IdleNodeBorderB", static_cast<long>(mainPanelSettings_.idleNodeBorderColor.b));
579 config.Write("IdleNodeTextR", static_cast<long>(mainPanelSettings_.idleNodeTextColor.r));
580 config.Write("IdleNodeTextG", static_cast<long>(mainPanelSettings_.idleNodeTextColor.g));
581 config.Write("IdleNodeTextB", static_cast<long>(mainPanelSettings_.idleNodeTextColor.b));
582 config.Write("SelectedNodeBgTint", static_cast<long>(mainPanelSettings_.selectedNodeBgTint * 100));
583 config.Write("HoveredNodeBgTint", static_cast<long>(mainPanelSettings_.hoveredNodeBgTint * 100));
584 config.Write("SelectedNodeR", static_cast<long>(mainPanelSettings_.selectedNodeColor.r));
585 config.Write("SelectedNodeG", static_cast<long>(mainPanelSettings_.selectedNodeColor.g));
586 config.Write("SelectedNodeB", static_cast<long>(mainPanelSettings_.selectedNodeColor.b));
587 config.Write("HoveredNodeR", static_cast<long>(mainPanelSettings_.hoveredNodeColor.r));
588 config.Write("HoveredNodeG", static_cast<long>(mainPanelSettings_.hoveredNodeColor.g));
589 config.Write("HoveredNodeB", static_cast<long>(mainPanelSettings_.hoveredNodeColor.b));
590 config.Write("SelectedNodeTextR", static_cast<long>(mainPanelSettings_.selectedNodeTextColor.r));
591 config.Write("SelectedNodeTextG", static_cast<long>(mainPanelSettings_.selectedNodeTextColor.g));
592 config.Write("SelectedNodeTextB", static_cast<long>(mainPanelSettings_.selectedNodeTextColor.b));
593 config.Write("HoveredNodeTextR", static_cast<long>(mainPanelSettings_.hoveredNodeTextColor.r));
594 config.Write("HoveredNodeTextG", static_cast<long>(mainPanelSettings_.hoveredNodeTextColor.g));
595 config.Write("HoveredNodeTextB", static_cast<long>(mainPanelSettings_.hoveredNodeTextColor.b));
596 config.Write("SelectedNodeInfoR", static_cast<long>(mainPanelSettings_.selectedNodeInfoColor.r));
597 config.Write("SelectedNodeInfoG", static_cast<long>(mainPanelSettings_.selectedNodeInfoColor.g));
598 config.Write("SelectedNodeInfoB", static_cast<long>(mainPanelSettings_.selectedNodeInfoColor.b));
599 config.Write("HoveredNodeInfoR", static_cast<long>(mainPanelSettings_.hoveredNodeInfoColor.r));
600 config.Write("HoveredNodeInfoG", static_cast<long>(mainPanelSettings_.hoveredNodeInfoColor.g));
601 config.Write("HoveredNodeInfoB", static_cast<long>(mainPanelSettings_.hoveredNodeInfoColor.b));
602 config.Write("MaxScenes", mainPanelSettings_.maxScenes);
603 config.Write("CloseConfirmation",
604 wxString(CloseConfirmationModeToString(mainPanelSettings_.closeConfirmation)));
605 config.Write("NextSceneHotkey", wxString(mainPanelSettings_.nextSceneHotkey));
606 config.Write("PreviousSceneHotkey", wxString(mainPanelSettings_.previousSceneHotkey));
607
608 // Save behavior tree view settings
609 config.SetPath("/BehaviorTreeView");
610 config.Write("ZoomStepSize", behaviorTreeViewSettings_.zoomStepSize);
611 config.Write("MouseWheelSensitivity", behaviorTreeViewSettings_.mouseWheelSensitivity);
612 config.Write("ZoomFollowsCursor", behaviorTreeViewSettings_.zoomFollowsCursor);
613 config.Write("ResetViewHotkey", wxString(behaviorTreeViewSettings_.resetViewHotkey));
614 config.Write("PanSensitivity", behaviorTreeViewSettings_.panSensitivity);
615 config.Write("PanKey", wxString(behaviorTreeViewSettings_.panKey));
616 config.Write("EnableSmoothPanning", behaviorTreeViewSettings_.enableSmoothPanning);
617 config.Write("PanSmoothness", behaviorTreeViewSettings_.panSmoothness);
618 config.Write("PanStepSize", behaviorTreeViewSettings_.panStepSize);
619 config.Write("CenterOnNodeHotkey", wxString(behaviorTreeViewSettings_.centerOnNodeHotkey));
620 config.Write("DeleteNodeHotkey", wxString(behaviorTreeViewSettings_.deleteNodeHotkey));
621 config.Write("PanUpHotkey", wxString(behaviorTreeViewSettings_.panUpHotkey));
622 config.Write("PanDownHotkey", wxString(behaviorTreeViewSettings_.panDownHotkey));
623 config.Write("PanLeftHotkey", wxString(behaviorTreeViewSettings_.panLeftHotkey));
624 config.Write("PanRightHotkey", wxString(behaviorTreeViewSettings_.panRightHotkey));
625
626 // Save debug text - Coordinate System Info settings
627 config.Write("ShowCoordinateInfo", behaviorTreeViewSettings_.showCoordinateInfo);
628 config.Write("CoordinateInfoFontSize", behaviorTreeViewSettings_.coordinateInfoFontSize);
629 config.Write("CoordinateInfoR", static_cast<long>(behaviorTreeViewSettings_.coordinateInfoColor.r));
630 config.Write("CoordinateInfoG", static_cast<long>(behaviorTreeViewSettings_.coordinateInfoColor.g));
631 config.Write("CoordinateInfoB", static_cast<long>(behaviorTreeViewSettings_.coordinateInfoColor.b));
632 config.Write("CoordinateInfoAnchor", static_cast<int>(behaviorTreeViewSettings_.coordinateInfoAnchor));
633 config.Write("CoordinateInfoX", behaviorTreeViewSettings_.coordinateInfoX);
634 config.Write("CoordinateInfoY", behaviorTreeViewSettings_.coordinateInfoY);
635
636 // Save debug text - Selected Node Info settings
637 config.Write("ShowSelectedNodeInfo", behaviorTreeViewSettings_.showSelectedNodeInfo);
638 config.Write("SelectedNodeInfoFontSize", behaviorTreeViewSettings_.selectedNodeInfoFontSize);
639 config.Write("SelectedNodeInfoR", static_cast<long>(behaviorTreeViewSettings_.selectedNodeInfoColor.r));
640 config.Write("SelectedNodeInfoG", static_cast<long>(behaviorTreeViewSettings_.selectedNodeInfoColor.g));
641 config.Write("SelectedNodeInfoB", static_cast<long>(behaviorTreeViewSettings_.selectedNodeInfoColor.b));
642 config.Write("SelectedNodeInfoAnchor", static_cast<int>(behaviorTreeViewSettings_.selectedNodeInfoAnchor));
643 config.Write("SelectedNodeInfoX", behaviorTreeViewSettings_.selectedNodeInfoX);
644 config.Write("SelectedNodeInfoY", behaviorTreeViewSettings_.selectedNodeInfoY);
645
646 // Save debug text - Tree Statistics Info settings
647 config.Write("ShowTreeInfo", behaviorTreeViewSettings_.showTreeInfo);
648 config.Write("TreeInfoFontSize", behaviorTreeViewSettings_.treeInfoFontSize);
649 config.Write("TreeInfoR", static_cast<long>(behaviorTreeViewSettings_.treeInfoColor.r));
650 config.Write("TreeInfoG", static_cast<long>(behaviorTreeViewSettings_.treeInfoColor.g));
651 config.Write("TreeInfoB", static_cast<long>(behaviorTreeViewSettings_.treeInfoColor.b));
652 config.Write("TreeInfoAnchor", static_cast<int>(behaviorTreeViewSettings_.treeInfoAnchor));
653 config.Write("TreeInfoX", behaviorTreeViewSettings_.treeInfoX);
654 config.Write("TreeInfoY", behaviorTreeViewSettings_.treeInfoY);
655
656 // Save debug text - FPS Display settings
657 config.Write("ShowFPS", behaviorTreeViewSettings_.showFPS);
658 config.Write("FPSFontSize", behaviorTreeViewSettings_.fpsFontSize);
659 config.Write("FPSR", static_cast<long>(behaviorTreeViewSettings_.fpsColor.r));
660 config.Write("FPSG", static_cast<long>(behaviorTreeViewSettings_.fpsColor.g));
661 config.Write("FPSB", static_cast<long>(behaviorTreeViewSettings_.fpsColor.b));
662 config.Write("FPSAnchor", static_cast<int>(behaviorTreeViewSettings_.fpsAnchor));
663 config.Write("FPSX", behaviorTreeViewSettings_.fpsX);
664 config.Write("FPSY", behaviorTreeViewSettings_.fpsY);
665
666 // Save debug text - Controls Help Text settings
667 config.Write("ShowControlsHelp", behaviorTreeViewSettings_.showControlsHelp);
668 config.Write("ControlsHelpFontSize", behaviorTreeViewSettings_.controlsHelpFontSize);
669 config.Write("ControlsHelpR", static_cast<long>(behaviorTreeViewSettings_.controlsHelpColor.r));
670 config.Write("ControlsHelpG", static_cast<long>(behaviorTreeViewSettings_.controlsHelpColor.g));
671 config.Write("ControlsHelpB", static_cast<long>(behaviorTreeViewSettings_.controlsHelpColor.b));
672 config.Write("ControlsHelpAnchor", static_cast<int>(behaviorTreeViewSettings_.controlsHelpAnchor));
673 config.Write("ControlsHelpX", behaviorTreeViewSettings_.controlsHelpX);
674 config.Write("ControlsHelpY", behaviorTreeViewSettings_.controlsHelpY);
675
676 // Save bottom panel settings
677 config.SetPath("/BottomPanel");
678
679 // Panel layout settings
680 config.Write("DefaultPanelHeight", bottomPanelSettings_.defaultPanelHeight);
681 config.Write("DefaultPanelHeightEnabled", bottomPanelSettings_.defaultPanelHeightEnabled);
682 config.Write("MinimumPanelHeight", bottomPanelSettings_.minimumPanelHeight);
683 config.Write("MinimumPanelHeightEnabled", bottomPanelSettings_.minimumPanelHeightEnabled);
684 config.Write("PanelStartupState", wxString(PanelStartupStateToString(bottomPanelSettings_.panelStartupState)));
685 config.Write("LastPanelVisible", bottomPanelSettings_.lastPanelVisible);
686
687 // Tab bar settings
688 config.Write("ShowTabCloseButtons", bottomPanelSettings_.showTabCloseButtons);
689
690 // Behavior settings
691 config.Write("RememberLastTab", bottomPanelSettings_.rememberLastTab);
692 config.Write("AllowPanelCollapse", bottomPanelSettings_.allowPanelCollapse);
693 config.Write("LastActiveTab", wxString(bottomPanelSettings_.lastActiveTab));
694
695 // Save lastOpenTabs as a comma-separated list
696 wxString bottomOpenTabsStr;
697 for (size_t i = 0; i < bottomPanelSettings_.lastOpenTabs.size(); ++i) {
698 if (i > 0)
699 bottomOpenTabsStr += ",";
700 bottomOpenTabsStr += wxString(bottomPanelSettings_.lastOpenTabs[i]);
701 }
702 config.Write("LastOpenTabs", bottomOpenTabsStr);
703
704 // File Explorer general settings
705 config.Write("ShowBreadcrumb", bottomPanelSettings_.showBreadcrumb);
706 config.Write("ShowHistory", bottomPanelSettings_.showHistory);
707 config.Write("StartPathMode", wxString(StartPathModeToString(bottomPanelSettings_.startPathMode)));
708 config.Write("CustomStartPath", wxString(bottomPanelSettings_.customStartPath));
709
710 // Tree View settings
711 config.SetPath("/BottomPanel/TreeView");
712 config.Write("ShowHiddenFiles", bottomPanelSettings_.treeView.showHiddenFiles);
713 config.Write("ShowFileExtensions", bottomPanelSettings_.treeView.showFileExtensions);
714 config.Write("SortFilesBy", wxString(SortByToString(bottomPanelSettings_.treeView.sortFilesBy)));
715 config.Write("ItemSize", wxString(TreeItemSizeToString(bottomPanelSettings_.treeView.itemSize)));
716
717 // Grid View settings
718 config.SetPath("/BottomPanel/GridView");
719 config.Write("ShowHiddenFiles", bottomPanelSettings_.gridView.showHiddenFiles);
720 config.Write("ShowFileExtensions", bottomPanelSettings_.gridView.showFileExtensions);
721 config.Write("SortFilesBy", wxString(SortByToString(bottomPanelSettings_.gridView.sortFilesBy)));
722 config.Write("IconSize", wxString(IconSizeToString(bottomPanelSettings_.gridView.iconSize)));
723
724 // Log Tab settings
725 config.SetPath("/BottomPanel/LogTab");
726 config.Write("DefaultLevelFilter", bottomPanelSettings_.logTab.defaultLevelFilter);
727 config.Write("AutoScrollEnabled", bottomPanelSettings_.logTab.autoScrollEnabled);
728 config.Write("MaxLogEntries", bottomPanelSettings_.logTab.maxLogEntries);
729 config.Write("FontSize", wxString(LogFontSizeToString(bottomPanelSettings_.logTab.fontSize)));
730
731 // Color settings
732 config.Write("EnableGuiColors", bottomPanelSettings_.logTab.enableGuiColors);
733 config.Write("EnableConsoleColors", bottomPanelSettings_.logTab.enableConsoleColors);
734
735 // Log level colors
736 config.SetPath("/BottomPanel/LogTab/Colors");
737 config.Write("TraceR", bottomPanelSettings_.logTab.traceColor.r);
738 config.Write("TraceG", bottomPanelSettings_.logTab.traceColor.g);
739 config.Write("TraceB", bottomPanelSettings_.logTab.traceColor.b);
740 config.Write("InfoR", bottomPanelSettings_.logTab.infoColor.r);
741 config.Write("InfoG", bottomPanelSettings_.logTab.infoColor.g);
742 config.Write("InfoB", bottomPanelSettings_.logTab.infoColor.b);
743 config.Write("WarningR", bottomPanelSettings_.logTab.warningColor.r);
744 config.Write("WarningG", bottomPanelSettings_.logTab.warningColor.g);
745 config.Write("WarningB", bottomPanelSettings_.logTab.warningColor.b);
746 config.Write("ErrorR", bottomPanelSettings_.logTab.errorColor.r);
747 config.Write("ErrorG", bottomPanelSettings_.logTab.errorColor.g);
748 config.Write("ErrorB", bottomPanelSettings_.logTab.errorColor.b);
749 config.Write("CriticalR", bottomPanelSettings_.logTab.criticalColor.r);
750 config.Write("CriticalG", bottomPanelSettings_.logTab.criticalColor.g);
751 config.Write("CriticalB", bottomPanelSettings_.logTab.criticalColor.b);
752
753 // Reset path for next section
754 config.SetPath("/BottomPanel");
755
756 // Save global side panel settings (currently empty, reserved for future use)
757 config.SetPath("/SidePanel");
758 // Future global settings that affect all panels would be saved here
759 config.SetPath("/");
760
761 // Save left panel settings
762 config.SetPath("/LeftPanel");
763
764 // Panel layout settings
765 config.Write("DefaultPanelWidth", leftPanelSettings_.defaultPanelWidth);
766 config.Write("DefaultPanelWidthEnabled", leftPanelSettings_.defaultPanelWidthEnabled);
767 config.Write("MinimumPanelWidth", leftPanelSettings_.minimumPanelWidth);
768 config.Write("MinimumPanelWidthEnabled", leftPanelSettings_.minimumPanelWidthEnabled);
769 config.Write("PanelStartupState", wxString(PanelStartupStateToString(leftPanelSettings_.panelStartupState)));
770 config.Write("LastPanelVisible", leftPanelSettings_.lastPanelVisible);
771
772 // Tab bar settings
773 config.Write("ShowTabCloseButtons", leftPanelSettings_.showTabCloseButtons);
774
775 // Behavior settings
776 config.Write("RememberLastTab", leftPanelSettings_.rememberLastTab);
777 config.Write("AllowPanelCollapse", leftPanelSettings_.allowPanelCollapse);
778 config.Write("DefaultActiveTab", wxString(leftPanelSettings_.defaultActiveTab));
779 config.Write("LastActiveTab", wxString(leftPanelSettings_.lastActiveTab));
780
781 // Save lastOpenTabs as a comma-separated list
782 wxString leftOpenTabsStr;
783 for (size_t i = 0; i < leftPanelSettings_.lastOpenTabs.size(); ++i) {
784 if (i > 0)
785 leftOpenTabsStr += ",";
786 leftOpenTabsStr += wxString(leftPanelSettings_.lastOpenTabs[i]);
787 }
788 config.Write("LastOpenTabs", leftOpenTabsStr);
789
790 // Scene Hierarchy Tab settings
791 config.SetPath("/LeftPanel/SceneHierarchyTab");
792 // Display settings
793 config.Write("ShowSearchBar", leftPanelSettings_.sceneHierarchy.showSearchBar);
794 config.Write("ShowNodeIcons", leftPanelSettings_.sceneHierarchy.showNodeIcons);
795 config.Write("ShowTreeLines", leftPanelSettings_.sceneHierarchy.showTreeLines);
796 config.Write("TreeIndentationSize", leftPanelSettings_.sceneHierarchy.treeIndentationSize);
797 config.Write("IconSize", leftPanelSettings_.sceneHierarchy.iconSize);
798 config.Write("FontSize", leftPanelSettings_.sceneHierarchy.fontSize);
799 // Color settings
800 config.Write("BackgroundColorR", leftPanelSettings_.sceneHierarchy.backgroundColorR);
801 config.Write("BackgroundColorG", leftPanelSettings_.sceneHierarchy.backgroundColorG);
802 config.Write("BackgroundColorB", leftPanelSettings_.sceneHierarchy.backgroundColorB);
803 config.Write("TextColorR", leftPanelSettings_.sceneHierarchy.textColorR);
804 config.Write("TextColorG", leftPanelSettings_.sceneHierarchy.textColorG);
805 config.Write("TextColorB", leftPanelSettings_.sceneHierarchy.textColorB);
806 config.Write("SelectionColorR", leftPanelSettings_.sceneHierarchy.selectionColorR);
807 config.Write("SelectionColorG", leftPanelSettings_.sceneHierarchy.selectionColorG);
808 config.Write("SelectionColorB", leftPanelSettings_.sceneHierarchy.selectionColorB);
809 // Behavior settings
810 config.Write("AutoExpandOnLoad", leftPanelSettings_.sceneHierarchy.autoExpandOnLoad);
811 config.Write("SyncSelectionWithCanvas", leftPanelSettings_.sceneHierarchy.syncSelectionWithCanvas);
812 config.Write("LiveSearch", leftPanelSettings_.sceneHierarchy.liveSearch);
813 config.Write("DoubleClickAction", static_cast<long>(leftPanelSettings_.sceneHierarchy.doubleClickAction));
814 config.Write("CtrlClickAction", static_cast<long>(leftPanelSettings_.sceneHierarchy.ctrlClickAction));
815 // Context menu settings
816 config.Write("ShowAddChildOption", leftPanelSettings_.sceneHierarchy.showAddChildOption);
817 config.Write("ShowDeleteOption", leftPanelSettings_.sceneHierarchy.showDeleteOption);
818 config.Write("ShowRenameOption", leftPanelSettings_.sceneHierarchy.showRenameOption);
819 config.Write("ShowDuplicateOption", leftPanelSettings_.sceneHierarchy.showDuplicateOption);
820 // Performance settings
821 config.Write("RememberExpandedNodes", leftPanelSettings_.sceneHierarchy.rememberExpandedNodes);
822
823 config.SetPath("/");
824
825 // Save right panel settings
826 config.SetPath("/RightPanel");
827
828 // Panel layout settings
829 config.Write("DefaultPanelWidth", rightPanelSettings_.defaultPanelWidth);
830 config.Write("DefaultPanelWidthEnabled", rightPanelSettings_.defaultPanelWidthEnabled);
831 config.Write("MinimumPanelWidth", rightPanelSettings_.minimumPanelWidth);
832 config.Write("MinimumPanelWidthEnabled", rightPanelSettings_.minimumPanelWidthEnabled);
833 config.Write("PanelStartupState", wxString(PanelStartupStateToString(rightPanelSettings_.panelStartupState)));
834 config.Write("LastPanelVisible", rightPanelSettings_.lastPanelVisible);
835
836 // Tab bar settings
837 config.Write("ShowTabCloseButtons", rightPanelSettings_.showTabCloseButtons);
838
839 // Behavior settings
840 config.Write("RememberLastTab", rightPanelSettings_.rememberLastTab);
841 config.Write("AllowPanelCollapse", rightPanelSettings_.allowPanelCollapse);
842 config.Write("DefaultActiveTab", wxString(rightPanelSettings_.defaultActiveTab));
843 config.Write("LastActiveTab", wxString(rightPanelSettings_.lastActiveTab));
844
845 // Save lastOpenTabs as a comma-separated list
846 wxString rightOpenTabsStr;
847 for (size_t i = 0; i < rightPanelSettings_.lastOpenTabs.size(); ++i) {
848 if (i > 0)
849 rightOpenTabsStr += ",";
850 rightOpenTabsStr += wxString(rightPanelSettings_.lastOpenTabs[i]);
851 }
852 config.Write("LastOpenTabs", rightOpenTabsStr);
853
854 // Save parser settings
855 config.SetPath("/Parser");
856 config.Write("AutoLoadLastFile", parserSettings_.autoLoadLastFile);
857 config.Write("LastOpenedFilePath", wxString(parserSettings_.lastOpenedFilePath));
858 config.Write("DefaultFileEncoding", wxString(parserSettings_.defaultFileEncoding));
859 config.Write("ShowParseWarnings", parserSettings_.showParseWarnings);
860
861 // Save performance settings
862 config.SetPath("/Performance");
863
864 // Rendering settings
865 config.Write("EnableVSync", performanceSettings_.enableVSync);
866 config.Write("HardwareAcceleration", performanceSettings_.hardwareAcceleration);
867 config.Write("EnableDoubleBuffering", performanceSettings_.enableDoubleBuffering);
868 config.Write("EnableAntiAliasing", performanceSettings_.enableAntiAliasing);
869 config.Write("EnableTextAntiAliasing", performanceSettings_.enableTextAntiAliasing);
870 config.Write("EnablePartialRedraws", performanceSettings_.enablePartialRedraws);
871 config.Write("EnableBackgroundErase", performanceSettings_.enableBackgroundErase);
872
873 // Viewport culling settings
874 config.Write("EnableViewportCulling", performanceSettings_.enableViewportCulling);
875 config.Write("ViewportCullingMargin", performanceSettings_.viewportCullingMargin);
876
877 config.Write("FPSLimit", wxString(FPSLimitToString(performanceSettings_.fpsLimit)));
878
879 // UI responsiveness settings
880 config.Write("EnableIdleProcessing", performanceSettings_.enableIdleProcessing);
881
882 config.Flush();
883
884 LOG_INFO("AppPreferences", "Preferences saved successfully");
885 return true;
886 } catch (const std::exception &e) {
887 LOG_ERROR("AppPreferences", "Error saving preferences: " + std::string(e.what()));
888 return false;
889 }
890}
891
892// Enum conversion helpers
894 if (str == "Light")
895 return ThemeMode::Light;
896 return ThemeMode::Dark;
897}
898
900 switch (mode) {
901 case ThemeMode::Light:
902 return "Light";
903 case ThemeMode::Dark:
904 return "Dark";
905 default:
906 return "Dark";
907 }
908}
909
911 if (str == "Maximized")
913 return StartupMode::Normal;
914}
915
917 switch (mode) {
919 return "Maximized";
921 return "Normal";
922 default:
923 return "Normal";
924 }
925}
926
928 if (str == "Date")
929 return SortBy::Date;
930 if (str == "Size")
931 return SortBy::Size;
932 if (str == "Type")
933 return SortBy::Type;
934 return SortBy::Name;
935}
936
938 switch (sort) {
939 case SortBy::Date:
940 return "Date";
941 case SortBy::Size:
942 return "Size";
943 case SortBy::Type:
944 return "Type";
945 case SortBy::Name:
946 return "Name";
947 default:
948 return "Name";
949 }
950}
951
953 if (str == "Small")
954 return IconSize::Small;
955 if (str == "Large")
956 return IconSize::Large;
957 return IconSize::Medium;
958}
959
961 switch (size) {
962 case IconSize::Small:
963 return "Small";
964 case IconSize::Large:
965 return "Large";
966 case IconSize::Medium:
967 return "Medium";
968 default:
969 return "Medium";
970 }
971}
972
974 if (str == "Small")
975 return TreeItemSize::Small;
976 if (str == "Large")
977 return TreeItemSize::Large;
979}
980
982 switch (size) {
984 return "Small";
986 return "Large";
988 return "Medium";
989 default:
990 return "Medium";
991 }
992}
993
995 if (str == "Small")
996 return LogFontSize::Small;
997 if (str == "Large")
998 return LogFontSize::Large;
999 return LogFontSize::Medium;
1000}
1001
1003 switch (size) {
1004 case LogFontSize::Small:
1005 return "Small";
1006 case LogFontSize::Large:
1007 return "Large";
1009 return "Medium";
1010 default:
1011 return "Medium";
1012 }
1013}
1014
1016 if (str == "CustomPath")
1019}
1020
1022 switch (mode) {
1024 return "ExecutableDirectory";
1026 return "CustomPath";
1027 default:
1028 return "ExecutableDirectory";
1029 }
1030}
1031
1033 if (str == "FPS_30")
1034 return FPSLimit::FPS_30;
1035 if (str == "FPS_120")
1036 return FPSLimit::FPS_120;
1037 if (str == "Unlimited")
1038 return FPSLimit::Unlimited;
1039 return FPSLimit::FPS_60;
1040}
1041
1043 switch (limit) {
1044 case FPSLimit::FPS_30:
1045 return "FPS_30";
1046 case FPSLimit::FPS_60:
1047 return "FPS_60";
1048 case FPSLimit::FPS_120:
1049 return "FPS_120";
1051 return "Unlimited";
1052 default:
1053 return "FPS_60";
1054 }
1055}
1056
1058 if (str == "AlwaysAsk")
1060 if (str == "NeverAsk")
1062 if (str == "AskIfUnsaved")
1064 return CloseConfirmationMode::AskIfUnsaved; // Default
1065}
1066
1068 switch (mode) {
1070 return "AlwaysAsk";
1072 return "NeverAsk";
1074 return "AskIfUnsaved";
1075 default:
1076 return "AskIfUnsaved";
1077 }
1078}
1079
1081 if (str == "Hide")
1083 if (str == "RememberLast")
1086}
1087
1089 switch (state) {
1091 return "Show";
1093 return "Hide";
1095 return "RememberLast";
1096 default:
1097 return "Show";
1098 }
1099}
1100
1101// Singleton implementation
1103 static AppPreferencesManager instance;
1104 return instance;
1105}
1106
1108 const auto &prefs = GetInstance().GetPreferences();
1109 const auto &color = prefs.GetWindowSettings().accentColor;
1110 return wxColour(color.r, color.g, color.b);
1111}
1112
1113} // namespace EmberForge
#define LOG_ERROR(category, message)
Definition Logger.h:116
#define LOG_WARNING(category, message)
Definition Logger.h:115
#define LOG_INFO(category, message)
Definition Logger.h:114
Centralized resource path management for EmberForge.
static wxColour GetAccentColor()
Get the accent color as a wxColour for UI elements.
static AppPreferencesManager & GetInstance()
BehaviorTreeViewSettings behaviorTreeViewSettings_
static std::string StartupModeToString(StartupMode mode)
StartupMode
Startup mode enumeration.
FPSLimit
Frame rate limit options.
PanelStartupState
Panel startup state options.
static LogFontSize StringToLogFontSize(const std::string &str)
SortBy
File sorting criteria.
bool SaveToFile(const EmberCore::String &filename) const
CloseConfirmationMode
Close confirmation behavior for scenes.
IconSize
Icon size for grid view.
static std::string ThemeModeToString(ThemeMode mode)
static std::string SortByToString(SortBy sort)
LeftPanelSettings leftPanelSettings_
BottomPanelSettings bottomPanelSettings_
TreeItemSize
Tree item size (affects icon and row height)
static StartPathMode StringToStartPathMode(const std::string &str)
TextAnchor
Text anchor position for debug info overlay.
static PanelStartupState StringToPanelStartupState(const std::string &str)
static std::string LogFontSizeToString(LogFontSize size)
RightPanelSettings rightPanelSettings_
PerformanceSettings performanceSettings_
static TreeItemSize StringToTreeItemSize(const std::string &str)
static std::string FPSLimitToString(FPSLimit limit)
static FPSLimit StringToFPSLimit(const std::string &str)
static std::string IconSizeToString(IconSize size)
MainPanelSettings mainPanelSettings_
static IconSize StringToIconSize(const std::string &str)
ThemeMode
Theme mode enumeration.
bool LoadFromFile(const EmberCore::String &filename)
static CloseConfirmationMode StringToCloseConfirmationMode(const std::string &str)
SidePanelSettings sidePanelSettings_
StartPathMode
Default start path behavior.
LogFontSize
Log tab font size.
WindowSettings & GetWindowSettings()
static StartupMode StringToStartupMode(const std::string &str)
static EmberCore::String GetDefaultConfigPath()
static std::string CloseConfirmationModeToString(CloseConfirmationMode mode)
static SortBy StringToSortBy(const std::string &str)
static ThemeMode StringToThemeMode(const std::string &str)
static std::string TreeItemSizeToString(TreeItemSize size)
static std::string PanelStartupStateToString(PanelStartupState state)
static std::string StartPathModeToString(StartPathMode mode)
static wxString Get(const wxString &relativePath)
Get the full path to a resource file.
std::string String
Framework-agnostic string type.
Definition String.h:14
RGBA color with 8-bit components.
Definition Color.h:10
Behavior Tree View specific settings.
Main panel (scene view) settings.
Global side panel settings (applies to all panels that inherit from SidePanel) Reserved for future us...