33 LOG_INFO(
"AppPreferences",
"Loading preferences from: " + filename);
35 if (!wxFile::Exists(filename)) {
36 LOG_WARNING(
"AppPreferences",
"Preferences file does not exist: " + filename);
41 wxFileConfig config(wxEmptyString, wxEmptyString, filename, wxEmptyString,
42 wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH);
45 config.SetPath(
"/Window");
51 wxString startupModeStr = config.Read(
"StartupMode",
"Normal");
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");
61 windowSettings_.saveAsHotkey = config.Read(
"SaveAsHotkey",
"Ctrl+Shift+S");
64 windowSettings_.resetUIHotkey = config.Read(
"ResetUIHotkey",
"Ctrl+Shift+R");
67 windowSettings_.preferencesHotkey = config.Read(
"PreferencesHotkey",
"Ctrl+,");
68 windowSettings_.parserConfigHotkey = config.Read(
"ParserConfigHotkey",
"Ctrl+Shift+P");
70 wxString themeStr = config.Read(
"Theme",
"Dark");
73 long r = config.Read(
"AccentColorR", 100L);
74 long g = config.Read(
"AccentColorG", 149L);
75 long b = config.Read(
"AccentColorB", 237L);
80 windowSettings_.showPanelCaptions = config.ReadBool(
"ShowPanelCaptions",
false);
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);
92 config.SetPath(
"/MainPanel");
98 r = config.Read(
"GridBackgroundR", 45L);
99 g = config.Read(
"GridBackgroundG", 45L);
100 b = config.Read(
"GridBackgroundB", 45L);
103 r = config.Read(
"GridLineR", 54L);
104 g = config.Read(
"GridLineG", 54L);
105 b = config.Read(
"GridLineB", 54L);
110 r = config.Read(
"CanvasBackgroundR", 50L);
111 g = config.Read(
"CanvasBackgroundG", 50L);
112 b = config.Read(
"CanvasBackgroundB", 50L);
115 r = config.Read(
"ConnectionLineR", 255L);
116 g = config.Read(
"ConnectionLineG", 255L);
117 b = config.Read(
"ConnectionLineB", 255L);
120 mainPanelSettings_.highlightPathToSelected = config.ReadBool(
"HighlightPathToSelected",
true);
122 r = config.Read(
"PathHighlightR", 144L);
123 g = config.Read(
"PathHighlightG", 238L);
124 b = config.Read(
"PathHighlightB", 144L);
127 r = config.Read(
"IdleNodeBgR", 75L);
128 g = config.Read(
"IdleNodeBgG", 75L);
129 b = config.Read(
"IdleNodeBgB", 75L);
132 r = config.Read(
"IdleNodeBorderR", 120L);
133 g = config.Read(
"IdleNodeBorderG", 120L);
134 b = config.Read(
"IdleNodeBorderB", 120L);
137 r = config.Read(
"IdleNodeTextR", 180L);
138 g = config.Read(
"IdleNodeTextG", 180L);
139 b = config.Read(
"IdleNodeTextB", 180L);
142 mainPanelSettings_.selectedNodeBgTint =
static_cast<float>(config.Read(
"SelectedNodeBgTint", -33L)) / 100.0f;
143 mainPanelSettings_.hoveredNodeBgTint =
static_cast<float>(config.Read(
"HoveredNodeBgTint", -13L)) / 100.0f;
145 r = config.Read(
"SelectedNodeR", 48L);
146 g = config.Read(
"SelectedNodeG", 92L);
147 b = config.Read(
"SelectedNodeB", 222L);
150 r = config.Read(
"HoveredNodeR", 144L);
151 g = config.Read(
"HoveredNodeG", 238L);
152 b = config.Read(
"HoveredNodeB", 144L);
155 r = config.Read(
"SelectedNodeTextR", 255L);
156 g = config.Read(
"SelectedNodeTextG", 255L);
157 b = config.Read(
"SelectedNodeTextB", 255L);
160 r = config.Read(
"HoveredNodeTextR", 255L);
161 g = config.Read(
"HoveredNodeTextG", 255L);
162 b = config.Read(
"HoveredNodeTextB", 255L);
165 r = config.Read(
"SelectedNodeInfoR", 200L);
166 g = config.Read(
"SelectedNodeInfoG", 200L);
167 b = config.Read(
"SelectedNodeInfoB", 200L);
170 r = config.Read(
"HoveredNodeInfoR", 200L);
171 g = config.Read(
"HoveredNodeInfoG", 200L);
172 b = config.Read(
"HoveredNodeInfoB", 200L);
177 wxString closeConfirmStr = config.Read(
"CloseConfirmation",
"AskIfUnsaved");
181 mainPanelSettings_.previousSceneHotkey = config.Read(
"PreviousSceneHotkey",
"Ctrl+Shift+Tab");
183 mainPanelSettings_.showCanvasBreadcrumb = config.ReadBool(
"ShowCanvasBreadcrumb",
true);
186 config.SetPath(
"/BehaviorTreeView");
206 r = config.Read(
"CoordinateInfoR", 200L);
207 g = config.Read(
"CoordinateInfoG", 200L);
208 b = config.Read(
"CoordinateInfoB", 200L);
211 static_cast<TextAnchor>(config.Read(
"CoordinateInfoAnchor", 0L));
218 r = config.Read(
"SelectedNodeInfoR", 100L);
219 g = config.Read(
"SelectedNodeInfoG", 150L);
220 b = config.Read(
"SelectedNodeInfoB", 255L);
223 static_cast<TextAnchor>(config.Read(
"SelectedNodeInfoAnchor", 0L));
230 r = config.Read(
"TreeInfoR", 150L);
231 g = config.Read(
"TreeInfoG", 200L);
232 b = config.Read(
"TreeInfoB", 150L);
241 r = config.Read(
"FPSR", 255L);
242 g = config.Read(
"FPSG", 200L);
243 b = config.Read(
"FPSB", 100L);
252 r = config.Read(
"ControlsHelpR", 85L);
253 g = config.Read(
"ControlsHelpG", 87L);
254 b = config.Read(
"ControlsHelpB", 83L);
257 static_cast<TextAnchor>(config.Read(
"ControlsHelpAnchor", 2L));
262 config.SetPath(
"/BottomPanel");
266 bottomPanelSettings_.defaultPanelHeightEnabled = config.ReadBool(
"DefaultPanelHeightEnabled",
true);
268 bottomPanelSettings_.minimumPanelHeightEnabled = config.ReadBool(
"MinimumPanelHeightEnabled",
true);
269 wxString startupStateStr = config.Read(
"PanelStartupState",
"Show");
279 bottomPanelSettings_.lastActiveTab = config.Read(
"LastActiveTab",
"FileExplorer").ToStdString();
282 wxString lastOpenTabsStr = config.Read(
"LastOpenTabs",
"FileExplorer,Log");
284 wxStringTokenizer tokenizer(lastOpenTabsStr,
",");
285 while (tokenizer.HasMoreTokens()) {
286 wxString token = tokenizer.GetNextToken().Trim().Trim(
false);
287 if (!token.IsEmpty()) {
295 wxString startPathModeStr = config.Read(
"StartPathMode",
"ExecutableDirectory");
300 config.SetPath(
"/BottomPanel/TreeView");
303 wxString treeViewSortByStr = config.Read(
"SortFilesBy",
"Name");
305 wxString treeItemSizeStr = config.Read(
"ItemSize",
"Medium");
309 config.SetPath(
"/BottomPanel/GridView");
312 wxString gridSortByStr = config.Read(
"SortFilesBy",
"Name");
314 wxString iconSizeStr = config.Read(
"IconSize",
"Medium");
318 config.SetPath(
"/BottomPanel/LogTab");
322 wxString logFontSizeStr = config.Read(
"FontSize",
"Medium");
330 config.SetPath(
"/BottomPanel/LogTab/Colors");
351 config.SetPath(
"/SidePanel");
356 config.SetPath(
"/LeftPanel");
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");
368 leftPanelSettings_.showTabCloseButtons = config.ReadBool(
"ShowTabCloseButtons",
true);
373 leftPanelSettings_.defaultActiveTab = config.Read(
"DefaultActiveTab",
"Navigator").ToStdString();
374 leftPanelSettings_.lastActiveTab = config.Read(
"LastActiveTab",
"Navigator").ToStdString();
377 wxString leftOpenTabsStr = config.Read(
"LastOpenTabs",
"Hierarchy");
379 wxStringTokenizer leftTokenizer(leftOpenTabsStr,
",");
380 while (leftTokenizer.HasMoreTokens()) {
381 wxString token = leftTokenizer.GetNextToken().Trim().Trim(
false);
382 if (!token.IsEmpty()) {
390 config.SetPath(
"/RightPanel");
394 rightPanelSettings_.defaultPanelWidthEnabled = config.ReadBool(
"DefaultPanelWidthEnabled",
true);
396 rightPanelSettings_.minimumPanelWidthEnabled = config.ReadBool(
"MinimumPanelWidthEnabled",
true);
397 wxString rightPanelStartupStr = config.Read(
"PanelStartupState",
"Show");
407 rightPanelSettings_.defaultActiveTab = config.Read(
"DefaultActiveTab",
"Properties").ToStdString();
408 rightPanelSettings_.lastActiveTab = config.Read(
"LastActiveTab",
"Properties").ToStdString();
411 wxString rightOpenTabsStr = config.Read(
"LastOpenTabs",
"Properties");
413 wxStringTokenizer rightTokenizer(rightOpenTabsStr,
",");
414 while (rightTokenizer.HasMoreTokens()) {
415 wxString token = rightTokenizer.GetNextToken().Trim().Trim(
false);
416 if (!token.IsEmpty()) {
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);
432 config.SetPath(
"/Performance");
447 wxString fpsLimitStr = config.Read(
"FPSLimit",
"FPS_60");
453 LOG_INFO(
"AppPreferences",
"Preferences loaded successfully");
455 }
catch (
const std::exception &e) {
456 LOG_ERROR(
"AppPreferences",
"Error loading preferences: " + std::string(e.what()));
462 LOG_INFO(
"AppPreferences",
"Saving preferences to: " + filename);
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");
474 wxFileConfig config(wxEmptyString, wxEmptyString, filename, wxEmptyString,
475 wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH);
478 config.SetPath(
"/Window");
484 config.Write(
"MaximizeHotkey", wxString(
windowSettings_.maximizeHotkey));
487 config.Write(
"NewProjectHotkey", wxString(
windowSettings_.newProjectHotkey));
488 config.Write(
"OpenProjectHotkey", wxString(
windowSettings_.openProjectHotkey));
489 config.Write(
"OpenFileHotkey", wxString(
windowSettings_.openFileHotkey));
494 config.Write(
"ResetUIHotkey", wxString(
windowSettings_.resetUIHotkey));
497 config.Write(
"PreferencesHotkey", wxString(
windowSettings_.preferencesHotkey));
498 config.Write(
"ParserConfigHotkey", wxString(
windowSettings_.parserConfigHotkey));
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));
512 config.Write(
"MinWindowHeightPct",
windowSettings_.minWindowHeightPct);
514 config.Write(
"MaxWindowHeightPct",
windowSettings_.maxWindowHeightPct);
515 config.Write(
"EnforceAspectRatio",
windowSettings_.enforceAspectRatio);
519 config.SetPath(
"/MainPanel");
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));
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));
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));
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));
570 config.Write(
"CloseConfirmation",
573 config.Write(
"PreviousSceneHotkey", wxString(
mainPanelSettings_.previousSceneHotkey));
578 config.SetPath(
"/BehaviorTreeView");
646 config.SetPath(
"/BottomPanel");
665 wxString bottomOpenTabsStr;
668 bottomOpenTabsStr +=
",";
671 config.Write(
"LastOpenTabs", bottomOpenTabsStr);
680 config.SetPath(
"/BottomPanel/TreeView");
687 config.SetPath(
"/BottomPanel/GridView");
694 config.SetPath(
"/BottomPanel/LogTab");
705 config.SetPath(
"/BottomPanel/LogTab/Colors");
723 config.SetPath(
"/BottomPanel");
726 config.SetPath(
"/SidePanel");
731 config.SetPath(
"/LeftPanel");
735 config.Write(
"DefaultPanelWidthEnabled",
leftPanelSettings_.defaultPanelWidthEnabled);
737 config.Write(
"MinimumPanelWidthEnabled",
leftPanelSettings_.minimumPanelWidthEnabled);
751 wxString leftOpenTabsStr;
754 leftOpenTabsStr +=
",";
757 config.Write(
"LastOpenTabs", leftOpenTabsStr);
762 config.SetPath(
"/RightPanel");
782 wxString rightOpenTabsStr;
785 rightOpenTabsStr +=
",";
788 config.Write(
"LastOpenTabs", rightOpenTabsStr);
791 config.SetPath(
"/Parser");
793 config.Write(
"LastOpenedFilePath", wxString(
parserSettings_.lastOpenedFilePath));
794 config.Write(
"DefaultFileEncoding", wxString(
parserSettings_.defaultFileEncoding));
798 config.SetPath(
"/Performance");
820 LOG_INFO(
"AppPreferences",
"Preferences saved successfully");
822 }
catch (
const std::exception &e) {
823 LOG_ERROR(
"AppPreferences",
"Error saving preferences: " + std::string(e.what()));