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 (percentage of screen)
84 windowSettings_.minWindowWidthPct = config.Read("MinWindowWidthPct", 42L);
85 windowSettings_.minWindowHeightPct = config.Read("MinWindowHeightPct", 56L);
86 windowSettings_.maxWindowWidthPct = config.Read("MaxWindowWidthPct", -1L);
87 windowSettings_.maxWindowHeightPct = config.Read("MaxWindowHeightPct", -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 mainPanelSettings_.showMinimap = config.ReadBool("ShowMinimap", true);
183 mainPanelSettings_.showCanvasBreadcrumb = config.ReadBool("ShowCanvasBreadcrumb", true);
184
185 // Load behavior tree view settings
186 config.SetPath("/BehaviorTreeView");
187 behaviorTreeViewSettings_.zoomStepSize = config.ReadDouble("ZoomStepSize", 0.1);
188 behaviorTreeViewSettings_.mouseWheelSensitivity = config.ReadDouble("MouseWheelSensitivity", 1.0);
189 behaviorTreeViewSettings_.zoomFollowsCursor = config.ReadBool("ZoomFollowsCursor", true);
190 behaviorTreeViewSettings_.resetViewHotkey = config.Read("ResetViewHotkey", "R");
191 behaviorTreeViewSettings_.panSensitivity = config.ReadDouble("PanSensitivity", 1.51);
192 behaviorTreeViewSettings_.panKey = config.Read("PanKey", "Middle Mouse Button");
193 behaviorTreeViewSettings_.enableSmoothPanning = config.ReadBool("EnableSmoothPanning", false);
194 behaviorTreeViewSettings_.panSmoothness = config.ReadDouble("PanSmoothness", 30.0);
195 behaviorTreeViewSettings_.panStepSize = config.ReadDouble("PanStepSize", 40.0);
196 behaviorTreeViewSettings_.centerOnNodeHotkey = config.Read("CenterOnNodeHotkey", "C");
197 behaviorTreeViewSettings_.deleteNodeHotkey = config.Read("DeleteNodeHotkey", "Delete");
198 behaviorTreeViewSettings_.panUpHotkey = config.Read("PanUpHotkey", "Up");
199 behaviorTreeViewSettings_.panDownHotkey = config.Read("PanDownHotkey", "Down");
200 behaviorTreeViewSettings_.panLeftHotkey = config.Read("PanLeftHotkey", "Left");
201 behaviorTreeViewSettings_.panRightHotkey = config.Read("PanRightHotkey", "Right");
202
203 // Load debug text - Coordinate System Info settings
204 behaviorTreeViewSettings_.showCoordinateInfo = config.ReadBool("ShowCoordinateInfo", true);
205 behaviorTreeViewSettings_.coordinateInfoFontSize = config.Read("CoordinateInfoFontSize", 9L);
206 r = config.Read("CoordinateInfoR", 200L);
207 g = config.Read("CoordinateInfoG", 200L);
208 b = config.Read("CoordinateInfoB", 200L);
209 behaviorTreeViewSettings_.coordinateInfoColor = EmberCore::Color(r, g, b);
210 behaviorTreeViewSettings_.coordinateInfoAnchor =
211 static_cast<TextAnchor>(config.Read("CoordinateInfoAnchor", 0L));
212 behaviorTreeViewSettings_.coordinateInfoX = config.Read("CoordinateInfoX", 10L);
213 behaviorTreeViewSettings_.coordinateInfoY = config.Read("CoordinateInfoY", 10L);
214
215 // Load debug text - Selected Node Info settings
216 behaviorTreeViewSettings_.showSelectedNodeInfo = config.ReadBool("ShowSelectedNodeInfo", true);
217 behaviorTreeViewSettings_.selectedNodeInfoFontSize = config.Read("SelectedNodeInfoFontSize", 9L);
218 r = config.Read("SelectedNodeInfoR", 100L);
219 g = config.Read("SelectedNodeInfoG", 150L);
220 b = config.Read("SelectedNodeInfoB", 255L);
221 behaviorTreeViewSettings_.selectedNodeInfoColor = EmberCore::Color(r, g, b);
222 behaviorTreeViewSettings_.selectedNodeInfoAnchor =
223 static_cast<TextAnchor>(config.Read("SelectedNodeInfoAnchor", 0L));
224 behaviorTreeViewSettings_.selectedNodeInfoX = config.Read("SelectedNodeInfoX", 10L);
225 behaviorTreeViewSettings_.selectedNodeInfoY = config.Read("SelectedNodeInfoY", 30L);
226
227 // Load debug text - Tree Statistics Info settings
228 behaviorTreeViewSettings_.showTreeInfo = config.ReadBool("ShowTreeInfo", true);
229 behaviorTreeViewSettings_.treeInfoFontSize = config.Read("TreeInfoFontSize", 9L);
230 r = config.Read("TreeInfoR", 150L);
231 g = config.Read("TreeInfoG", 200L);
232 b = config.Read("TreeInfoB", 150L);
233 behaviorTreeViewSettings_.treeInfoColor = EmberCore::Color(r, g, b);
234 behaviorTreeViewSettings_.treeInfoAnchor = static_cast<TextAnchor>(config.Read("TreeInfoAnchor", 0L));
235 behaviorTreeViewSettings_.treeInfoX = config.Read("TreeInfoX", 10L);
236 behaviorTreeViewSettings_.treeInfoY = config.Read("TreeInfoY", 50L);
237
238 // Load debug text - FPS Display settings
239 behaviorTreeViewSettings_.showFPS = config.ReadBool("ShowFPS", true);
240 behaviorTreeViewSettings_.fpsFontSize = config.Read("FPSFontSize", 9L);
241 r = config.Read("FPSR", 255L);
242 g = config.Read("FPSG", 200L);
243 b = config.Read("FPSB", 100L);
245 behaviorTreeViewSettings_.fpsAnchor = static_cast<TextAnchor>(config.Read("FPSAnchor", 0L));
246 behaviorTreeViewSettings_.fpsX = config.Read("FPSX", 10L);
247 behaviorTreeViewSettings_.fpsY = config.Read("FPSY", 70L);
248
249 // Load debug text - Controls Help Text settings
250 behaviorTreeViewSettings_.showControlsHelp = config.ReadBool("ShowControlsHelp", true);
251 behaviorTreeViewSettings_.controlsHelpFontSize = config.Read("ControlsHelpFontSize", 11L);
252 r = config.Read("ControlsHelpR", 85L);
253 g = config.Read("ControlsHelpG", 87L);
254 b = config.Read("ControlsHelpB", 83L);
255 behaviorTreeViewSettings_.controlsHelpColor = EmberCore::Color(r, g, b);
256 behaviorTreeViewSettings_.controlsHelpAnchor =
257 static_cast<TextAnchor>(config.Read("ControlsHelpAnchor", 2L)); // Default to Bottom-Left
258 behaviorTreeViewSettings_.controlsHelpX = config.Read("ControlsHelpX", 10L);
259 behaviorTreeViewSettings_.controlsHelpY = config.Read("ControlsHelpY", 25L);
260
261 // Load bottom panel settings
262 config.SetPath("/BottomPanel");
263
264 // Panel layout settings
265 bottomPanelSettings_.defaultPanelHeightPct = config.Read("DefaultPanelHeightPct", 25L);
266 bottomPanelSettings_.defaultPanelHeightEnabled = config.ReadBool("DefaultPanelHeightEnabled", true);
267 bottomPanelSettings_.minimumPanelHeightPct = config.Read("MinimumPanelHeightPct", 15L);
268 bottomPanelSettings_.minimumPanelHeightEnabled = config.ReadBool("MinimumPanelHeightEnabled", true);
269 wxString startupStateStr = config.Read("PanelStartupState", "Show");
270 bottomPanelSettings_.panelStartupState = StringToPanelStartupState(startupStateStr.ToStdString());
271 bottomPanelSettings_.lastPanelVisible = config.ReadBool("LastPanelVisible", true);
272
273 // Tab bar settings
274 bottomPanelSettings_.showTabCloseButtons = config.ReadBool("ShowTabCloseButtons", true);
275
276 // Behavior settings
277 bottomPanelSettings_.rememberLastTab = config.ReadBool("RememberLastTab", true);
278 bottomPanelSettings_.allowPanelCollapse = config.ReadBool("AllowPanelCollapse", true);
279 bottomPanelSettings_.lastActiveTab = config.Read("LastActiveTab", "FileExplorer").ToStdString();
280
281 // Load lastOpenTabs as a comma-separated list
282 wxString lastOpenTabsStr = config.Read("LastOpenTabs", "FileExplorer,Log");
283 bottomPanelSettings_.lastOpenTabs.clear();
284 wxStringTokenizer tokenizer(lastOpenTabsStr, ",");
285 while (tokenizer.HasMoreTokens()) {
286 wxString token = tokenizer.GetNextToken().Trim().Trim(false);
287 if (!token.IsEmpty()) {
288 bottomPanelSettings_.lastOpenTabs.push_back(token.ToStdString());
289 }
290 }
291
292 // File Explorer general settings
293 bottomPanelSettings_.showBreadcrumb = config.ReadBool("ShowBreadcrumb", true);
294 bottomPanelSettings_.showHistory = config.ReadBool("ShowHistory", true);
295 wxString startPathModeStr = config.Read("StartPathMode", "ExecutableDirectory");
296 bottomPanelSettings_.startPathMode = StringToStartPathMode(startPathModeStr.ToStdString());
297 bottomPanelSettings_.customStartPath = config.Read("CustomStartPath", "").ToStdString();
298
299 // Tree View settings
300 config.SetPath("/BottomPanel/TreeView");
301 bottomPanelSettings_.treeView.showHiddenFiles = config.ReadBool("ShowHiddenFiles", false);
302 bottomPanelSettings_.treeView.showFileExtensions = config.ReadBool("ShowFileExtensions", true);
303 wxString treeViewSortByStr = config.Read("SortFilesBy", "Name");
304 bottomPanelSettings_.treeView.sortFilesBy = StringToSortBy(treeViewSortByStr.ToStdString());
305 wxString treeItemSizeStr = config.Read("ItemSize", "Medium");
306 bottomPanelSettings_.treeView.itemSize = StringToTreeItemSize(treeItemSizeStr.ToStdString());
307
308 // Grid View settings
309 config.SetPath("/BottomPanel/GridView");
310 bottomPanelSettings_.gridView.showHiddenFiles = config.ReadBool("ShowHiddenFiles", false);
311 bottomPanelSettings_.gridView.showFileExtensions = config.ReadBool("ShowFileExtensions", true);
312 wxString gridSortByStr = config.Read("SortFilesBy", "Name");
313 bottomPanelSettings_.gridView.sortFilesBy = StringToSortBy(gridSortByStr.ToStdString());
314 wxString iconSizeStr = config.Read("IconSize", "Medium");
315 bottomPanelSettings_.gridView.iconSize = StringToIconSize(iconSizeStr.ToStdString());
316
317 // Log Tab settings
318 config.SetPath("/BottomPanel/LogTab");
319 bottomPanelSettings_.logTab.defaultLevelFilter = config.ReadLong("DefaultLevelFilter", 3);
320 bottomPanelSettings_.logTab.autoScrollEnabled = config.ReadBool("AutoScrollEnabled", true);
321 bottomPanelSettings_.logTab.maxLogEntries = config.ReadLong("MaxLogEntries", 2000);
322 wxString logFontSizeStr = config.Read("FontSize", "Medium");
323 bottomPanelSettings_.logTab.fontSize = StringToLogFontSize(logFontSizeStr.ToStdString());
324
325 // Color settings
326 bottomPanelSettings_.logTab.enableGuiColors = config.ReadBool("EnableGuiColors", true);
327 bottomPanelSettings_.logTab.enableConsoleColors = config.ReadBool("EnableConsoleColors", true);
328
329 // Log level colors
330 config.SetPath("/BottomPanel/LogTab/Colors");
331 bottomPanelSettings_.logTab.traceColor.r = config.ReadLong("TraceR", 128);
332 bottomPanelSettings_.logTab.traceColor.g = config.ReadLong("TraceG", 128);
333 bottomPanelSettings_.logTab.traceColor.b = config.ReadLong("TraceB", 128);
334 bottomPanelSettings_.logTab.infoColor.r = config.ReadLong("InfoR", 100);
335 bottomPanelSettings_.logTab.infoColor.g = config.ReadLong("InfoG", 200);
336 bottomPanelSettings_.logTab.infoColor.b = config.ReadLong("InfoB", 100);
337 bottomPanelSettings_.logTab.warningColor.r = config.ReadLong("WarningR", 230);
338 bottomPanelSettings_.logTab.warningColor.g = config.ReadLong("WarningG", 180);
339 bottomPanelSettings_.logTab.warningColor.b = config.ReadLong("WarningB", 50);
340 bottomPanelSettings_.logTab.errorColor.r = config.ReadLong("ErrorR", 230);
341 bottomPanelSettings_.logTab.errorColor.g = config.ReadLong("ErrorG", 80);
342 bottomPanelSettings_.logTab.errorColor.b = config.ReadLong("ErrorB", 80);
343 bottomPanelSettings_.logTab.criticalColor.r = config.ReadLong("CriticalR", 255);
344 bottomPanelSettings_.logTab.criticalColor.g = config.ReadLong("CriticalG", 50);
345 bottomPanelSettings_.logTab.criticalColor.b = config.ReadLong("CriticalB", 50);
346
347 // Reset path for next section
348 config.SetPath("/");
349
350 // Load global side panel settings (currently empty, reserved for future use)
351 config.SetPath("/SidePanel");
352 // Future global settings that affect all panels would be loaded here
353 config.SetPath("/");
354
355 // Load left panel settings
356 config.SetPath("/LeftPanel");
357
358 // Panel layout settings
359 leftPanelSettings_.defaultPanelWidthPct = config.ReadLong("DefaultPanelWidthPct", 20);
360 leftPanelSettings_.defaultPanelWidthEnabled = config.ReadBool("DefaultPanelWidthEnabled", true);
361 leftPanelSettings_.minimumPanelWidthPct = config.ReadLong("MinimumPanelWidthPct", 10);
362 leftPanelSettings_.minimumPanelWidthEnabled = config.ReadBool("MinimumPanelWidthEnabled", true);
363 wxString leftPanelStartupStr = config.Read("PanelStartupState", "Show");
364 leftPanelSettings_.panelStartupState = StringToPanelStartupState(leftPanelStartupStr.ToStdString());
365 leftPanelSettings_.lastPanelVisible = config.ReadBool("LastPanelVisible", true);
366
367 // Tab bar settings
368 leftPanelSettings_.showTabCloseButtons = config.ReadBool("ShowTabCloseButtons", true);
369
370 // Behavior settings
371 leftPanelSettings_.rememberLastTab = config.ReadBool("RememberLastTab", true);
372 leftPanelSettings_.allowPanelCollapse = config.ReadBool("AllowPanelCollapse", true);
373 leftPanelSettings_.defaultActiveTab = config.Read("DefaultActiveTab", "Navigator").ToStdString();
374 leftPanelSettings_.lastActiveTab = config.Read("LastActiveTab", "Navigator").ToStdString();
375
376 // Load lastOpenTabs as a comma-separated list
377 wxString leftOpenTabsStr = config.Read("LastOpenTabs", "Hierarchy");
378 leftPanelSettings_.lastOpenTabs.clear();
379 wxStringTokenizer leftTokenizer(leftOpenTabsStr, ",");
380 while (leftTokenizer.HasMoreTokens()) {
381 wxString token = leftTokenizer.GetNextToken().Trim().Trim(false);
382 if (!token.IsEmpty()) {
383 leftPanelSettings_.lastOpenTabs.push_back(token.ToStdString());
384 }
385 }
386
387 config.SetPath("/");
388
389 // Load right panel settings
390 config.SetPath("/RightPanel");
391
392 // Panel layout settings
393 rightPanelSettings_.defaultPanelWidthPct = config.ReadLong("DefaultPanelWidthPct", 20);
394 rightPanelSettings_.defaultPanelWidthEnabled = config.ReadBool("DefaultPanelWidthEnabled", true);
395 rightPanelSettings_.minimumPanelWidthPct = config.ReadLong("MinimumPanelWidthPct", 10);
396 rightPanelSettings_.minimumPanelWidthEnabled = config.ReadBool("MinimumPanelWidthEnabled", true);
397 wxString rightPanelStartupStr = config.Read("PanelStartupState", "Show");
398 rightPanelSettings_.panelStartupState = StringToPanelStartupState(rightPanelStartupStr.ToStdString());
399 rightPanelSettings_.lastPanelVisible = config.ReadBool("LastPanelVisible", true);
400
401 // Tab bar settings
402 rightPanelSettings_.showTabCloseButtons = config.ReadBool("ShowTabCloseButtons", true);
403
404 // Behavior settings
405 rightPanelSettings_.rememberLastTab = config.ReadBool("RememberLastTab", true);
406 rightPanelSettings_.allowPanelCollapse = config.ReadBool("AllowPanelCollapse", true);
407 rightPanelSettings_.defaultActiveTab = config.Read("DefaultActiveTab", "Properties").ToStdString();
408 rightPanelSettings_.lastActiveTab = config.Read("LastActiveTab", "Properties").ToStdString();
409
410 // Load lastOpenTabs as a comma-separated list
411 wxString rightOpenTabsStr = config.Read("LastOpenTabs", "Properties");
412 rightPanelSettings_.lastOpenTabs.clear();
413 wxStringTokenizer rightTokenizer(rightOpenTabsStr, ",");
414 while (rightTokenizer.HasMoreTokens()) {
415 wxString token = rightTokenizer.GetNextToken().Trim().Trim(false);
416 if (!token.IsEmpty()) {
417 rightPanelSettings_.lastOpenTabs.push_back(token.ToStdString());
418 }
419 }
420
421 // Reset path for next section
422 config.SetPath("/");
423
424 // Load parser settings
425 config.SetPath("/Parser");
426 parserSettings_.autoLoadLastFile = config.ReadBool("AutoLoadLastFile", false);
427 parserSettings_.lastOpenedFilePath = config.Read("LastOpenedFilePath", "").ToStdString();
428 parserSettings_.defaultFileEncoding = config.Read("DefaultFileEncoding", "UTF-8").ToStdString();
429 parserSettings_.showParseWarnings = config.ReadBool("ShowParseWarnings", true);
430
431 // Load performance settings
432 config.SetPath("/Performance");
433
434 // Rendering settings
435 performanceSettings_.enableVSync = config.ReadBool("EnableVSync", true);
436 performanceSettings_.hardwareAcceleration = config.ReadBool("HardwareAcceleration", true);
437 performanceSettings_.enableDoubleBuffering = config.ReadBool("EnableDoubleBuffering", true);
438 performanceSettings_.enableAntiAliasing = config.ReadBool("EnableAntiAliasing", true);
439 performanceSettings_.enableTextAntiAliasing = config.ReadBool("EnableTextAntiAliasing", true);
440 performanceSettings_.enablePartialRedraws = config.ReadBool("EnablePartialRedraws", true);
441 performanceSettings_.enableBackgroundErase = config.ReadBool("EnableBackgroundErase", false);
442
443 // Viewport culling settings
444 performanceSettings_.enableViewportCulling = config.ReadBool("EnableViewportCulling", true);
445 performanceSettings_.viewportCullingMargin = config.Read("ViewportCullingMargin", 500L);
446
447 wxString fpsLimitStr = config.Read("FPSLimit", "FPS_60");
448 performanceSettings_.fpsLimit = StringToFPSLimit(fpsLimitStr.ToStdString());
449
450 // UI responsiveness settings
451 performanceSettings_.enableIdleProcessing = config.ReadBool("EnableIdleProcessing", true);
452
453 LOG_INFO("AppPreferences", "Preferences loaded successfully");
454 return true;
455 } catch (const std::exception &e) {
456 LOG_ERROR("AppPreferences", "Error loading preferences: " + std::string(e.what()));
457 return false;
458 }
459}
460
462 LOG_INFO("AppPreferences", "Saving preferences to: " + filename);
463
464 try {
465 // Ensure directory exists
466 wxFileName fn(filename);
467 if (!fn.DirExists()) {
468 if (!fn.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL)) {
469 LOG_ERROR("AppPreferences", "Failed to create config directory");
470 return false;
471 }
472 }
473
474 wxFileConfig config(wxEmptyString, wxEmptyString, filename, wxEmptyString,
475 wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH);
476
477 // Save window settings
478 config.SetPath("/Window");
479 config.Write("WindowX", windowSettings_.windowX);
480 config.Write("WindowY", windowSettings_.windowY);
481 config.Write("WindowWidth", windowSettings_.windowWidth);
482 config.Write("WindowHeight", windowSettings_.windowHeight);
483 config.Write("StartupMode", wxString(StartupModeToString(windowSettings_.startupMode)));
484 config.Write("MaximizeHotkey", wxString(windowSettings_.maximizeHotkey));
485
486 // File menu hotkeys
487 config.Write("NewProjectHotkey", wxString(windowSettings_.newProjectHotkey));
488 config.Write("OpenProjectHotkey", wxString(windowSettings_.openProjectHotkey));
489 config.Write("OpenFileHotkey", wxString(windowSettings_.openFileHotkey));
490 config.Write("SaveHotkey", wxString(windowSettings_.saveHotkey));
491 config.Write("SaveAsHotkey", wxString(windowSettings_.saveAsHotkey));
492
493 // View menu hotkeys
494 config.Write("ResetUIHotkey", wxString(windowSettings_.resetUIHotkey));
495
496 // Settings menu hotkeys
497 config.Write("PreferencesHotkey", wxString(windowSettings_.preferencesHotkey));
498 config.Write("ParserConfigHotkey", wxString(windowSettings_.parserConfigHotkey));
499
500 config.Write("Theme", wxString(ThemeModeToString(windowSettings_.theme)));
501 config.Write("AccentColorR", static_cast<long>(windowSettings_.accentColor.r));
502 config.Write("AccentColorG", static_cast<long>(windowSettings_.accentColor.g));
503 config.Write("AccentColorB", static_cast<long>(windowSettings_.accentColor.b));
504
505 // Window appearance and behavior
506 config.Write("ShowStatusBar", windowSettings_.showStatusBar);
507 config.Write("ShowPanelCaptions", windowSettings_.showPanelCaptions);
508 config.Write("AlwaysOnTop", windowSettings_.alwaysOnTop);
509
510 // Window constraints (percentage of screen)
511 config.Write("MinWindowWidthPct", windowSettings_.minWindowWidthPct);
512 config.Write("MinWindowHeightPct", windowSettings_.minWindowHeightPct);
513 config.Write("MaxWindowWidthPct", windowSettings_.maxWindowWidthPct);
514 config.Write("MaxWindowHeightPct", windowSettings_.maxWindowHeightPct);
515 config.Write("EnforceAspectRatio", windowSettings_.enforceAspectRatio);
516 config.Write("AspectRatio", windowSettings_.aspectRatio);
517
518 // Save main panel settings
519 config.SetPath("/MainPanel");
520 config.Write("DefaultZoomLevel", mainPanelSettings_.defaultZoomLevel);
521 config.Write("ShowGrid", mainPanelSettings_.showGrid);
522 config.Write("GridSize", mainPanelSettings_.gridSize);
523 config.Write("GridBackgroundR", static_cast<long>(mainPanelSettings_.gridBackgroundColor.r));
524 config.Write("GridBackgroundG", static_cast<long>(mainPanelSettings_.gridBackgroundColor.g));
525 config.Write("GridBackgroundB", static_cast<long>(mainPanelSettings_.gridBackgroundColor.b));
526 config.Write("GridLineR", static_cast<long>(mainPanelSettings_.gridLineColor.r));
527 config.Write("GridLineG", static_cast<long>(mainPanelSettings_.gridLineColor.g));
528 config.Write("GridLineB", static_cast<long>(mainPanelSettings_.gridLineColor.b));
529 config.Write("SnapToGrid", mainPanelSettings_.snapToGrid);
530 config.Write("CanvasBackgroundR", static_cast<long>(mainPanelSettings_.canvasBackgroundColor.r));
531 config.Write("CanvasBackgroundG", static_cast<long>(mainPanelSettings_.canvasBackgroundColor.g));
532 config.Write("CanvasBackgroundB", static_cast<long>(mainPanelSettings_.canvasBackgroundColor.b));
533 config.Write("ConnectionLineR", static_cast<long>(mainPanelSettings_.connectionLineColor.r));
534 config.Write("ConnectionLineG", static_cast<long>(mainPanelSettings_.connectionLineColor.g));
535 config.Write("ConnectionLineB", static_cast<long>(mainPanelSettings_.connectionLineColor.b));
536 config.Write("HighlightPathToSelected", mainPanelSettings_.highlightPathToSelected);
537 config.Write("PathHighlightR", static_cast<long>(mainPanelSettings_.pathHighlightColor.r));
538 config.Write("PathHighlightG", static_cast<long>(mainPanelSettings_.pathHighlightColor.g));
539 config.Write("PathHighlightB", static_cast<long>(mainPanelSettings_.pathHighlightColor.b));
540 config.Write("IdleNodeBgR", static_cast<long>(mainPanelSettings_.idleNodeBgColor.r));
541 config.Write("IdleNodeBgG", static_cast<long>(mainPanelSettings_.idleNodeBgColor.g));
542 config.Write("IdleNodeBgB", static_cast<long>(mainPanelSettings_.idleNodeBgColor.b));
543 config.Write("IdleNodeBorderR", static_cast<long>(mainPanelSettings_.idleNodeBorderColor.r));
544 config.Write("IdleNodeBorderG", static_cast<long>(mainPanelSettings_.idleNodeBorderColor.g));
545 config.Write("IdleNodeBorderB", static_cast<long>(mainPanelSettings_.idleNodeBorderColor.b));
546 config.Write("IdleNodeTextR", static_cast<long>(mainPanelSettings_.idleNodeTextColor.r));
547 config.Write("IdleNodeTextG", static_cast<long>(mainPanelSettings_.idleNodeTextColor.g));
548 config.Write("IdleNodeTextB", static_cast<long>(mainPanelSettings_.idleNodeTextColor.b));
549 config.Write("SelectedNodeBgTint", static_cast<long>(mainPanelSettings_.selectedNodeBgTint * 100));
550 config.Write("HoveredNodeBgTint", static_cast<long>(mainPanelSettings_.hoveredNodeBgTint * 100));
551 config.Write("SelectedNodeR", static_cast<long>(mainPanelSettings_.selectedNodeColor.r));
552 config.Write("SelectedNodeG", static_cast<long>(mainPanelSettings_.selectedNodeColor.g));
553 config.Write("SelectedNodeB", static_cast<long>(mainPanelSettings_.selectedNodeColor.b));
554 config.Write("HoveredNodeR", static_cast<long>(mainPanelSettings_.hoveredNodeColor.r));
555 config.Write("HoveredNodeG", static_cast<long>(mainPanelSettings_.hoveredNodeColor.g));
556 config.Write("HoveredNodeB", static_cast<long>(mainPanelSettings_.hoveredNodeColor.b));
557 config.Write("SelectedNodeTextR", static_cast<long>(mainPanelSettings_.selectedNodeTextColor.r));
558 config.Write("SelectedNodeTextG", static_cast<long>(mainPanelSettings_.selectedNodeTextColor.g));
559 config.Write("SelectedNodeTextB", static_cast<long>(mainPanelSettings_.selectedNodeTextColor.b));
560 config.Write("HoveredNodeTextR", static_cast<long>(mainPanelSettings_.hoveredNodeTextColor.r));
561 config.Write("HoveredNodeTextG", static_cast<long>(mainPanelSettings_.hoveredNodeTextColor.g));
562 config.Write("HoveredNodeTextB", static_cast<long>(mainPanelSettings_.hoveredNodeTextColor.b));
563 config.Write("SelectedNodeInfoR", static_cast<long>(mainPanelSettings_.selectedNodeInfoColor.r));
564 config.Write("SelectedNodeInfoG", static_cast<long>(mainPanelSettings_.selectedNodeInfoColor.g));
565 config.Write("SelectedNodeInfoB", static_cast<long>(mainPanelSettings_.selectedNodeInfoColor.b));
566 config.Write("HoveredNodeInfoR", static_cast<long>(mainPanelSettings_.hoveredNodeInfoColor.r));
567 config.Write("HoveredNodeInfoG", static_cast<long>(mainPanelSettings_.hoveredNodeInfoColor.g));
568 config.Write("HoveredNodeInfoB", static_cast<long>(mainPanelSettings_.hoveredNodeInfoColor.b));
569 config.Write("MaxScenes", mainPanelSettings_.maxScenes);
570 config.Write("CloseConfirmation",
571 wxString(CloseConfirmationModeToString(mainPanelSettings_.closeConfirmation)));
572 config.Write("NextSceneHotkey", wxString(mainPanelSettings_.nextSceneHotkey));
573 config.Write("PreviousSceneHotkey", wxString(mainPanelSettings_.previousSceneHotkey));
574 config.Write("ShowMinimap", mainPanelSettings_.showMinimap);
575 config.Write("ShowCanvasBreadcrumb", mainPanelSettings_.showCanvasBreadcrumb);
576
577 // Save behavior tree view settings
578 config.SetPath("/BehaviorTreeView");
579 config.Write("ZoomStepSize", behaviorTreeViewSettings_.zoomStepSize);
580 config.Write("MouseWheelSensitivity", behaviorTreeViewSettings_.mouseWheelSensitivity);
581 config.Write("ZoomFollowsCursor", behaviorTreeViewSettings_.zoomFollowsCursor);
582 config.Write("ResetViewHotkey", wxString(behaviorTreeViewSettings_.resetViewHotkey));
583 config.Write("PanSensitivity", behaviorTreeViewSettings_.panSensitivity);
584 config.Write("PanKey", wxString(behaviorTreeViewSettings_.panKey));
585 config.Write("EnableSmoothPanning", behaviorTreeViewSettings_.enableSmoothPanning);
586 config.Write("PanSmoothness", behaviorTreeViewSettings_.panSmoothness);
587 config.Write("PanStepSize", behaviorTreeViewSettings_.panStepSize);
588 config.Write("CenterOnNodeHotkey", wxString(behaviorTreeViewSettings_.centerOnNodeHotkey));
589 config.Write("DeleteNodeHotkey", wxString(behaviorTreeViewSettings_.deleteNodeHotkey));
590 config.Write("PanUpHotkey", wxString(behaviorTreeViewSettings_.panUpHotkey));
591 config.Write("PanDownHotkey", wxString(behaviorTreeViewSettings_.panDownHotkey));
592 config.Write("PanLeftHotkey", wxString(behaviorTreeViewSettings_.panLeftHotkey));
593 config.Write("PanRightHotkey", wxString(behaviorTreeViewSettings_.panRightHotkey));
594
595 // Save debug text - Coordinate System Info settings
596 config.Write("ShowCoordinateInfo", behaviorTreeViewSettings_.showCoordinateInfo);
597 config.Write("CoordinateInfoFontSize", behaviorTreeViewSettings_.coordinateInfoFontSize);
598 config.Write("CoordinateInfoR", static_cast<long>(behaviorTreeViewSettings_.coordinateInfoColor.r));
599 config.Write("CoordinateInfoG", static_cast<long>(behaviorTreeViewSettings_.coordinateInfoColor.g));
600 config.Write("CoordinateInfoB", static_cast<long>(behaviorTreeViewSettings_.coordinateInfoColor.b));
601 config.Write("CoordinateInfoAnchor", static_cast<int>(behaviorTreeViewSettings_.coordinateInfoAnchor));
602 config.Write("CoordinateInfoX", behaviorTreeViewSettings_.coordinateInfoX);
603 config.Write("CoordinateInfoY", behaviorTreeViewSettings_.coordinateInfoY);
604
605 // Save debug text - Selected Node Info settings
606 config.Write("ShowSelectedNodeInfo", behaviorTreeViewSettings_.showSelectedNodeInfo);
607 config.Write("SelectedNodeInfoFontSize", behaviorTreeViewSettings_.selectedNodeInfoFontSize);
608 config.Write("SelectedNodeInfoR", static_cast<long>(behaviorTreeViewSettings_.selectedNodeInfoColor.r));
609 config.Write("SelectedNodeInfoG", static_cast<long>(behaviorTreeViewSettings_.selectedNodeInfoColor.g));
610 config.Write("SelectedNodeInfoB", static_cast<long>(behaviorTreeViewSettings_.selectedNodeInfoColor.b));
611 config.Write("SelectedNodeInfoAnchor", static_cast<int>(behaviorTreeViewSettings_.selectedNodeInfoAnchor));
612 config.Write("SelectedNodeInfoX", behaviorTreeViewSettings_.selectedNodeInfoX);
613 config.Write("SelectedNodeInfoY", behaviorTreeViewSettings_.selectedNodeInfoY);
614
615 // Save debug text - Tree Statistics Info settings
616 config.Write("ShowTreeInfo", behaviorTreeViewSettings_.showTreeInfo);
617 config.Write("TreeInfoFontSize", behaviorTreeViewSettings_.treeInfoFontSize);
618 config.Write("TreeInfoR", static_cast<long>(behaviorTreeViewSettings_.treeInfoColor.r));
619 config.Write("TreeInfoG", static_cast<long>(behaviorTreeViewSettings_.treeInfoColor.g));
620 config.Write("TreeInfoB", static_cast<long>(behaviorTreeViewSettings_.treeInfoColor.b));
621 config.Write("TreeInfoAnchor", static_cast<int>(behaviorTreeViewSettings_.treeInfoAnchor));
622 config.Write("TreeInfoX", behaviorTreeViewSettings_.treeInfoX);
623 config.Write("TreeInfoY", behaviorTreeViewSettings_.treeInfoY);
624
625 // Save debug text - FPS Display settings
626 config.Write("ShowFPS", behaviorTreeViewSettings_.showFPS);
627 config.Write("FPSFontSize", behaviorTreeViewSettings_.fpsFontSize);
628 config.Write("FPSR", static_cast<long>(behaviorTreeViewSettings_.fpsColor.r));
629 config.Write("FPSG", static_cast<long>(behaviorTreeViewSettings_.fpsColor.g));
630 config.Write("FPSB", static_cast<long>(behaviorTreeViewSettings_.fpsColor.b));
631 config.Write("FPSAnchor", static_cast<int>(behaviorTreeViewSettings_.fpsAnchor));
632 config.Write("FPSX", behaviorTreeViewSettings_.fpsX);
633 config.Write("FPSY", behaviorTreeViewSettings_.fpsY);
634
635 // Save debug text - Controls Help Text settings
636 config.Write("ShowControlsHelp", behaviorTreeViewSettings_.showControlsHelp);
637 config.Write("ControlsHelpFontSize", behaviorTreeViewSettings_.controlsHelpFontSize);
638 config.Write("ControlsHelpR", static_cast<long>(behaviorTreeViewSettings_.controlsHelpColor.r));
639 config.Write("ControlsHelpG", static_cast<long>(behaviorTreeViewSettings_.controlsHelpColor.g));
640 config.Write("ControlsHelpB", static_cast<long>(behaviorTreeViewSettings_.controlsHelpColor.b));
641 config.Write("ControlsHelpAnchor", static_cast<int>(behaviorTreeViewSettings_.controlsHelpAnchor));
642 config.Write("ControlsHelpX", behaviorTreeViewSettings_.controlsHelpX);
643 config.Write("ControlsHelpY", behaviorTreeViewSettings_.controlsHelpY);
644
645 // Save bottom panel settings
646 config.SetPath("/BottomPanel");
647
648 // Panel layout settings
649 config.Write("DefaultPanelHeightPct", bottomPanelSettings_.defaultPanelHeightPct);
650 config.Write("DefaultPanelHeightEnabled", bottomPanelSettings_.defaultPanelHeightEnabled);
651 config.Write("MinimumPanelHeightPct", bottomPanelSettings_.minimumPanelHeightPct);
652 config.Write("MinimumPanelHeightEnabled", bottomPanelSettings_.minimumPanelHeightEnabled);
653 config.Write("PanelStartupState", wxString(PanelStartupStateToString(bottomPanelSettings_.panelStartupState)));
654 config.Write("LastPanelVisible", bottomPanelSettings_.lastPanelVisible);
655
656 // Tab bar settings
657 config.Write("ShowTabCloseButtons", bottomPanelSettings_.showTabCloseButtons);
658
659 // Behavior settings
660 config.Write("RememberLastTab", bottomPanelSettings_.rememberLastTab);
661 config.Write("AllowPanelCollapse", bottomPanelSettings_.allowPanelCollapse);
662 config.Write("LastActiveTab", wxString(bottomPanelSettings_.lastActiveTab));
663
664 // Save lastOpenTabs as a comma-separated list
665 wxString bottomOpenTabsStr;
666 for (size_t i = 0; i < bottomPanelSettings_.lastOpenTabs.size(); ++i) {
667 if (i > 0)
668 bottomOpenTabsStr += ",";
669 bottomOpenTabsStr += wxString(bottomPanelSettings_.lastOpenTabs[i]);
670 }
671 config.Write("LastOpenTabs", bottomOpenTabsStr);
672
673 // File Explorer general settings
674 config.Write("ShowBreadcrumb", bottomPanelSettings_.showBreadcrumb);
675 config.Write("ShowHistory", bottomPanelSettings_.showHistory);
676 config.Write("StartPathMode", wxString(StartPathModeToString(bottomPanelSettings_.startPathMode)));
677 config.Write("CustomStartPath", wxString(bottomPanelSettings_.customStartPath));
678
679 // Tree View settings
680 config.SetPath("/BottomPanel/TreeView");
681 config.Write("ShowHiddenFiles", bottomPanelSettings_.treeView.showHiddenFiles);
682 config.Write("ShowFileExtensions", bottomPanelSettings_.treeView.showFileExtensions);
683 config.Write("SortFilesBy", wxString(SortByToString(bottomPanelSettings_.treeView.sortFilesBy)));
684 config.Write("ItemSize", wxString(TreeItemSizeToString(bottomPanelSettings_.treeView.itemSize)));
685
686 // Grid View settings
687 config.SetPath("/BottomPanel/GridView");
688 config.Write("ShowHiddenFiles", bottomPanelSettings_.gridView.showHiddenFiles);
689 config.Write("ShowFileExtensions", bottomPanelSettings_.gridView.showFileExtensions);
690 config.Write("SortFilesBy", wxString(SortByToString(bottomPanelSettings_.gridView.sortFilesBy)));
691 config.Write("IconSize", wxString(IconSizeToString(bottomPanelSettings_.gridView.iconSize)));
692
693 // Log Tab settings
694 config.SetPath("/BottomPanel/LogTab");
695 config.Write("DefaultLevelFilter", bottomPanelSettings_.logTab.defaultLevelFilter);
696 config.Write("AutoScrollEnabled", bottomPanelSettings_.logTab.autoScrollEnabled);
697 config.Write("MaxLogEntries", bottomPanelSettings_.logTab.maxLogEntries);
698 config.Write("FontSize", wxString(LogFontSizeToString(bottomPanelSettings_.logTab.fontSize)));
699
700 // Color settings
701 config.Write("EnableGuiColors", bottomPanelSettings_.logTab.enableGuiColors);
702 config.Write("EnableConsoleColors", bottomPanelSettings_.logTab.enableConsoleColors);
703
704 // Log level colors
705 config.SetPath("/BottomPanel/LogTab/Colors");
706 config.Write("TraceR", bottomPanelSettings_.logTab.traceColor.r);
707 config.Write("TraceG", bottomPanelSettings_.logTab.traceColor.g);
708 config.Write("TraceB", bottomPanelSettings_.logTab.traceColor.b);
709 config.Write("InfoR", bottomPanelSettings_.logTab.infoColor.r);
710 config.Write("InfoG", bottomPanelSettings_.logTab.infoColor.g);
711 config.Write("InfoB", bottomPanelSettings_.logTab.infoColor.b);
712 config.Write("WarningR", bottomPanelSettings_.logTab.warningColor.r);
713 config.Write("WarningG", bottomPanelSettings_.logTab.warningColor.g);
714 config.Write("WarningB", bottomPanelSettings_.logTab.warningColor.b);
715 config.Write("ErrorR", bottomPanelSettings_.logTab.errorColor.r);
716 config.Write("ErrorG", bottomPanelSettings_.logTab.errorColor.g);
717 config.Write("ErrorB", bottomPanelSettings_.logTab.errorColor.b);
718 config.Write("CriticalR", bottomPanelSettings_.logTab.criticalColor.r);
719 config.Write("CriticalG", bottomPanelSettings_.logTab.criticalColor.g);
720 config.Write("CriticalB", bottomPanelSettings_.logTab.criticalColor.b);
721
722 // Reset path for next section
723 config.SetPath("/BottomPanel");
724
725 // Save global side panel settings (currently empty, reserved for future use)
726 config.SetPath("/SidePanel");
727 // Future global settings that affect all panels would be saved here
728 config.SetPath("/");
729
730 // Save left panel settings
731 config.SetPath("/LeftPanel");
732
733 // Panel layout settings
734 config.Write("DefaultPanelWidthPct", leftPanelSettings_.defaultPanelWidthPct);
735 config.Write("DefaultPanelWidthEnabled", leftPanelSettings_.defaultPanelWidthEnabled);
736 config.Write("MinimumPanelWidthPct", leftPanelSettings_.minimumPanelWidthPct);
737 config.Write("MinimumPanelWidthEnabled", leftPanelSettings_.minimumPanelWidthEnabled);
738 config.Write("PanelStartupState", wxString(PanelStartupStateToString(leftPanelSettings_.panelStartupState)));
739 config.Write("LastPanelVisible", leftPanelSettings_.lastPanelVisible);
740
741 // Tab bar settings
742 config.Write("ShowTabCloseButtons", leftPanelSettings_.showTabCloseButtons);
743
744 // Behavior settings
745 config.Write("RememberLastTab", leftPanelSettings_.rememberLastTab);
746 config.Write("AllowPanelCollapse", leftPanelSettings_.allowPanelCollapse);
747 config.Write("DefaultActiveTab", wxString(leftPanelSettings_.defaultActiveTab));
748 config.Write("LastActiveTab", wxString(leftPanelSettings_.lastActiveTab));
749
750 // Save lastOpenTabs as a comma-separated list
751 wxString leftOpenTabsStr;
752 for (size_t i = 0; i < leftPanelSettings_.lastOpenTabs.size(); ++i) {
753 if (i > 0)
754 leftOpenTabsStr += ",";
755 leftOpenTabsStr += wxString(leftPanelSettings_.lastOpenTabs[i]);
756 }
757 config.Write("LastOpenTabs", leftOpenTabsStr);
758
759 config.SetPath("/");
760
761 // Save right panel settings
762 config.SetPath("/RightPanel");
763
764 // Panel layout settings
765 config.Write("DefaultPanelWidthPct", rightPanelSettings_.defaultPanelWidthPct);
766 config.Write("DefaultPanelWidthEnabled", rightPanelSettings_.defaultPanelWidthEnabled);
767 config.Write("MinimumPanelWidthPct", rightPanelSettings_.minimumPanelWidthPct);
768 config.Write("MinimumPanelWidthEnabled", rightPanelSettings_.minimumPanelWidthEnabled);
769 config.Write("PanelStartupState", wxString(PanelStartupStateToString(rightPanelSettings_.panelStartupState)));
770 config.Write("LastPanelVisible", rightPanelSettings_.lastPanelVisible);
771
772 // Tab bar settings
773 config.Write("ShowTabCloseButtons", rightPanelSettings_.showTabCloseButtons);
774
775 // Behavior settings
776 config.Write("RememberLastTab", rightPanelSettings_.rememberLastTab);
777 config.Write("AllowPanelCollapse", rightPanelSettings_.allowPanelCollapse);
778 config.Write("DefaultActiveTab", wxString(rightPanelSettings_.defaultActiveTab));
779 config.Write("LastActiveTab", wxString(rightPanelSettings_.lastActiveTab));
780
781 // Save lastOpenTabs as a comma-separated list
782 wxString rightOpenTabsStr;
783 for (size_t i = 0; i < rightPanelSettings_.lastOpenTabs.size(); ++i) {
784 if (i > 0)
785 rightOpenTabsStr += ",";
786 rightOpenTabsStr += wxString(rightPanelSettings_.lastOpenTabs[i]);
787 }
788 config.Write("LastOpenTabs", rightOpenTabsStr);
789
790 // Save parser settings
791 config.SetPath("/Parser");
792 config.Write("AutoLoadLastFile", parserSettings_.autoLoadLastFile);
793 config.Write("LastOpenedFilePath", wxString(parserSettings_.lastOpenedFilePath));
794 config.Write("DefaultFileEncoding", wxString(parserSettings_.defaultFileEncoding));
795 config.Write("ShowParseWarnings", parserSettings_.showParseWarnings);
796
797 // Save performance settings
798 config.SetPath("/Performance");
799
800 // Rendering settings
801 config.Write("EnableVSync", performanceSettings_.enableVSync);
802 config.Write("HardwareAcceleration", performanceSettings_.hardwareAcceleration);
803 config.Write("EnableDoubleBuffering", performanceSettings_.enableDoubleBuffering);
804 config.Write("EnableAntiAliasing", performanceSettings_.enableAntiAliasing);
805 config.Write("EnableTextAntiAliasing", performanceSettings_.enableTextAntiAliasing);
806 config.Write("EnablePartialRedraws", performanceSettings_.enablePartialRedraws);
807 config.Write("EnableBackgroundErase", performanceSettings_.enableBackgroundErase);
808
809 // Viewport culling settings
810 config.Write("EnableViewportCulling", performanceSettings_.enableViewportCulling);
811 config.Write("ViewportCullingMargin", performanceSettings_.viewportCullingMargin);
812
813 config.Write("FPSLimit", wxString(FPSLimitToString(performanceSettings_.fpsLimit)));
814
815 // UI responsiveness settings
816 config.Write("EnableIdleProcessing", performanceSettings_.enableIdleProcessing);
817
818 config.Flush();
819
820 LOG_INFO("AppPreferences", "Preferences saved successfully");
821 return true;
822 } catch (const std::exception &e) {
823 LOG_ERROR("AppPreferences", "Error saving preferences: " + std::string(e.what()));
824 return false;
825 }
826}
827
828// Enum conversion helpers
830 if (str == "Light")
831 return ThemeMode::Light;
832 return ThemeMode::Dark;
833}
834
836 switch (mode) {
837 case ThemeMode::Light:
838 return "Light";
839 case ThemeMode::Dark:
840 return "Dark";
841 default:
842 return "Dark";
843 }
844}
845
847 if (str == "Maximized")
849 return StartupMode::Normal;
850}
851
853 switch (mode) {
855 return "Maximized";
857 return "Normal";
858 default:
859 return "Normal";
860 }
861}
862
864 if (str == "Date")
865 return SortBy::Date;
866 if (str == "Size")
867 return SortBy::Size;
868 if (str == "Type")
869 return SortBy::Type;
870 return SortBy::Name;
871}
872
874 switch (sort) {
875 case SortBy::Date:
876 return "Date";
877 case SortBy::Size:
878 return "Size";
879 case SortBy::Type:
880 return "Type";
881 case SortBy::Name:
882 return "Name";
883 default:
884 return "Name";
885 }
886}
887
889 if (str == "Small")
890 return IconSize::Small;
891 if (str == "Large")
892 return IconSize::Large;
893 return IconSize::Medium;
894}
895
897 switch (size) {
898 case IconSize::Small:
899 return "Small";
900 case IconSize::Large:
901 return "Large";
902 case IconSize::Medium:
903 return "Medium";
904 default:
905 return "Medium";
906 }
907}
908
910 if (str == "Small")
911 return TreeItemSize::Small;
912 if (str == "Large")
913 return TreeItemSize::Large;
915}
916
918 switch (size) {
920 return "Small";
922 return "Large";
924 return "Medium";
925 default:
926 return "Medium";
927 }
928}
929
931 if (str == "Small")
932 return LogFontSize::Small;
933 if (str == "Large")
934 return LogFontSize::Large;
935 return LogFontSize::Medium;
936}
937
939 switch (size) {
941 return "Small";
943 return "Large";
945 return "Medium";
946 default:
947 return "Medium";
948 }
949}
950
952 if (str == "CustomPath")
955}
956
958 switch (mode) {
960 return "ExecutableDirectory";
962 return "CustomPath";
963 default:
964 return "ExecutableDirectory";
965 }
966}
967
969 if (str == "FPS_30")
970 return FPSLimit::FPS_30;
971 if (str == "FPS_120")
972 return FPSLimit::FPS_120;
973 if (str == "Unlimited")
974 return FPSLimit::Unlimited;
975 return FPSLimit::FPS_60;
976}
977
979 switch (limit) {
980 case FPSLimit::FPS_30:
981 return "FPS_30";
982 case FPSLimit::FPS_60:
983 return "FPS_60";
985 return "FPS_120";
987 return "Unlimited";
988 default:
989 return "FPS_60";
990 }
991}
992
994 if (str == "AlwaysAsk")
996 if (str == "NeverAsk")
998 if (str == "AskIfUnsaved")
1000 return CloseConfirmationMode::AskIfUnsaved; // Default
1001}
1002
1004 switch (mode) {
1006 return "AlwaysAsk";
1008 return "NeverAsk";
1010 return "AskIfUnsaved";
1011 default:
1012 return "AskIfUnsaved";
1013 }
1014}
1015
1017 if (str == "Hide")
1019 if (str == "RememberLast")
1022}
1023
1025 switch (state) {
1027 return "Show";
1029 return "Hide";
1031 return "RememberLast";
1032 default:
1033 return "Show";
1034 }
1035}
1036
1037// Singleton implementation
1039 static AppPreferencesManager instance;
1040 return instance;
1041}
1042
1044 const auto &prefs = GetInstance().GetPreferences();
1045 const auto &color = prefs.GetWindowSettings().accentColor;
1046 return wxColour(color.r, color.g, color.b);
1047}
1048
1049} // 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...