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);
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");
184 config.SetPath(
"/BehaviorTreeView");
204 r = config.Read(
"CoordinateInfoR", 200L);
205 g = config.Read(
"CoordinateInfoG", 200L);
206 b = config.Read(
"CoordinateInfoB", 200L);
209 static_cast<TextAnchor>(config.Read(
"CoordinateInfoAnchor", 0L));
216 r = config.Read(
"SelectedNodeInfoR", 100L);
217 g = config.Read(
"SelectedNodeInfoG", 150L);
218 b = config.Read(
"SelectedNodeInfoB", 255L);
221 static_cast<TextAnchor>(config.Read(
"SelectedNodeInfoAnchor", 0L));
228 r = config.Read(
"TreeInfoR", 150L);
229 g = config.Read(
"TreeInfoG", 200L);
230 b = config.Read(
"TreeInfoB", 150L);
239 r = config.Read(
"FPSR", 255L);
240 g = config.Read(
"FPSG", 200L);
241 b = config.Read(
"FPSB", 100L);
250 r = config.Read(
"ControlsHelpR", 85L);
251 g = config.Read(
"ControlsHelpG", 87L);
252 b = config.Read(
"ControlsHelpB", 83L);
255 static_cast<TextAnchor>(config.Read(
"ControlsHelpAnchor", 2L));
260 config.SetPath(
"/BottomPanel");
264 bottomPanelSettings_.defaultPanelHeightEnabled = config.ReadBool(
"DefaultPanelHeightEnabled",
true);
266 bottomPanelSettings_.minimumPanelHeightEnabled = config.ReadBool(
"MinimumPanelHeightEnabled",
true);
267 wxString startupStateStr = config.Read(
"PanelStartupState",
"Show");
277 bottomPanelSettings_.lastActiveTab = config.Read(
"LastActiveTab",
"FileExplorer").ToStdString();
280 wxString lastOpenTabsStr = config.Read(
"LastOpenTabs",
"FileExplorer,Log");
282 wxStringTokenizer tokenizer(lastOpenTabsStr,
",");
283 while (tokenizer.HasMoreTokens()) {
284 wxString token = tokenizer.GetNextToken().Trim().Trim(
false);
285 if (!token.IsEmpty()) {
293 wxString startPathModeStr = config.Read(
"StartPathMode",
"ExecutableDirectory");
298 config.SetPath(
"/BottomPanel/TreeView");
301 wxString treeViewSortByStr = config.Read(
"SortFilesBy",
"Name");
303 wxString treeItemSizeStr = config.Read(
"ItemSize",
"Medium");
307 config.SetPath(
"/BottomPanel/GridView");
310 wxString gridSortByStr = config.Read(
"SortFilesBy",
"Name");
312 wxString iconSizeStr = config.Read(
"IconSize",
"Medium");
316 config.SetPath(
"/BottomPanel/LogTab");
320 wxString logFontSizeStr = config.Read(
"FontSize",
"Medium");
328 config.SetPath(
"/BottomPanel/LogTab/Colors");
349 config.SetPath(
"/SidePanel");
354 config.SetPath(
"/LeftPanel");
358 leftPanelSettings_.defaultPanelWidthEnabled = config.ReadBool(
"DefaultPanelWidthEnabled",
true);
360 leftPanelSettings_.minimumPanelWidthEnabled = config.ReadBool(
"MinimumPanelWidthEnabled",
true);
361 wxString leftPanelStartupStr = config.Read(
"PanelStartupState",
"Show");
366 leftPanelSettings_.showTabCloseButtons = config.ReadBool(
"ShowTabCloseButtons",
true);
371 leftPanelSettings_.defaultActiveTab = config.Read(
"DefaultActiveTab",
"Hierarchy").ToStdString();
372 leftPanelSettings_.lastActiveTab = config.Read(
"LastActiveTab",
"Hierarchy").ToStdString();
375 wxString leftOpenTabsStr = config.Read(
"LastOpenTabs",
"Hierarchy");
377 wxStringTokenizer leftTokenizer(leftOpenTabsStr,
",");
378 while (leftTokenizer.HasMoreTokens()) {
379 wxString token = leftTokenizer.GetNextToken().Trim().Trim(
false);
380 if (!token.IsEmpty()) {
386 config.SetPath(
"/LeftPanel/SceneHierarchyTab");
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);
395 leftPanelSettings_.sceneHierarchy.backgroundColorR = config.Read(
"BackgroundColorR", 50L);
396 leftPanelSettings_.sceneHierarchy.backgroundColorG = config.ReadLong(
"BackgroundColorG", 50L);
397 leftPanelSettings_.sceneHierarchy.backgroundColorB = config.ReadLong(
"BackgroundColorB", 50L);
401 leftPanelSettings_.sceneHierarchy.selectionColorR = config.ReadLong(
"SelectionColorR", 70L);
402 leftPanelSettings_.sceneHierarchy.selectionColorG = config.ReadLong(
"SelectionColorG", 130L);
403 leftPanelSettings_.sceneHierarchy.selectionColorB = config.ReadLong(
"SelectionColorB", 180L);
405 leftPanelSettings_.sceneHierarchy.autoExpandOnLoad = config.ReadBool(
"AutoExpandOnLoad",
true);
406 leftPanelSettings_.sceneHierarchy.syncSelectionWithCanvas = config.ReadBool(
"SyncSelectionWithCanvas",
true);
411 config.ReadLong(
"CtrlClickAction", 2L));
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);
418 leftPanelSettings_.sceneHierarchy.rememberExpandedNodes = config.ReadBool(
"RememberExpandedNodes",
true);
423 config.SetPath(
"/RightPanel");
427 rightPanelSettings_.defaultPanelWidthEnabled = config.ReadBool(
"DefaultPanelWidthEnabled",
true);
429 rightPanelSettings_.minimumPanelWidthEnabled = config.ReadBool(
"MinimumPanelWidthEnabled",
true);
430 wxString rightPanelStartupStr = config.Read(
"PanelStartupState",
"Show");
440 rightPanelSettings_.defaultActiveTab = config.Read(
"DefaultActiveTab",
"Tool").ToStdString();
444 wxString rightOpenTabsStr = config.Read(
"LastOpenTabs",
"Tool");
446 wxStringTokenizer rightTokenizer(rightOpenTabsStr,
",");
447 while (rightTokenizer.HasMoreTokens()) {
448 wxString token = rightTokenizer.GetNextToken().Trim().Trim(
false);
449 if (!token.IsEmpty()) {
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);
465 config.SetPath(
"/Performance");
480 wxString fpsLimitStr = config.Read(
"FPSLimit",
"FPS_60");
486 LOG_INFO(
"AppPreferences",
"Preferences loaded successfully");
488 }
catch (
const std::exception &e) {
489 LOG_ERROR(
"AppPreferences",
"Error loading preferences: " + std::string(e.what()));
495 LOG_INFO(
"AppPreferences",
"Saving preferences to: " + filename);
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");
507 wxFileConfig config(wxEmptyString, wxEmptyString, filename, wxEmptyString,
508 wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH);
511 config.SetPath(
"/Window");
517 config.Write(
"MaximizeHotkey", wxString(
windowSettings_.maximizeHotkey));
520 config.Write(
"NewProjectHotkey", wxString(
windowSettings_.newProjectHotkey));
521 config.Write(
"OpenProjectHotkey", wxString(
windowSettings_.openProjectHotkey));
522 config.Write(
"OpenFileHotkey", wxString(
windowSettings_.openFileHotkey));
527 config.Write(
"ResetUIHotkey", wxString(
windowSettings_.resetUIHotkey));
530 config.Write(
"PreferencesHotkey", wxString(
windowSettings_.preferencesHotkey));
531 config.Write(
"ParserConfigHotkey", wxString(
windowSettings_.parserConfigHotkey));
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));
548 config.Write(
"EnforceAspectRatio",
windowSettings_.enforceAspectRatio);
552 config.SetPath(
"/MainPanel");
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));
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));
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));
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));
603 config.Write(
"CloseConfirmation",
606 config.Write(
"PreviousSceneHotkey", wxString(
mainPanelSettings_.previousSceneHotkey));
609 config.SetPath(
"/BehaviorTreeView");
677 config.SetPath(
"/BottomPanel");
696 wxString bottomOpenTabsStr;
699 bottomOpenTabsStr +=
",";
702 config.Write(
"LastOpenTabs", bottomOpenTabsStr);
711 config.SetPath(
"/BottomPanel/TreeView");
718 config.SetPath(
"/BottomPanel/GridView");
725 config.SetPath(
"/BottomPanel/LogTab");
736 config.SetPath(
"/BottomPanel/LogTab/Colors");
754 config.SetPath(
"/BottomPanel");
757 config.SetPath(
"/SidePanel");
762 config.SetPath(
"/LeftPanel");
766 config.Write(
"DefaultPanelWidthEnabled",
leftPanelSettings_.defaultPanelWidthEnabled);
768 config.Write(
"MinimumPanelWidthEnabled",
leftPanelSettings_.minimumPanelWidthEnabled);
782 wxString leftOpenTabsStr;
785 leftOpenTabsStr +=
",";
788 config.Write(
"LastOpenTabs", leftOpenTabsStr);
791 config.SetPath(
"/LeftPanel/SceneHierarchyTab");
796 config.Write(
"TreeIndentationSize",
leftPanelSettings_.sceneHierarchy.treeIndentationSize);
811 config.Write(
"SyncSelectionWithCanvas",
leftPanelSettings_.sceneHierarchy.syncSelectionWithCanvas);
813 config.Write(
"DoubleClickAction",
static_cast<long>(
leftPanelSettings_.sceneHierarchy.doubleClickAction));
814 config.Write(
"CtrlClickAction",
static_cast<long>(
leftPanelSettings_.sceneHierarchy.ctrlClickAction));
816 config.Write(
"ShowAddChildOption",
leftPanelSettings_.sceneHierarchy.showAddChildOption);
819 config.Write(
"ShowDuplicateOption",
leftPanelSettings_.sceneHierarchy.showDuplicateOption);
821 config.Write(
"RememberExpandedNodes",
leftPanelSettings_.sceneHierarchy.rememberExpandedNodes);
826 config.SetPath(
"/RightPanel");
846 wxString rightOpenTabsStr;
849 rightOpenTabsStr +=
",";
852 config.Write(
"LastOpenTabs", rightOpenTabsStr);
855 config.SetPath(
"/Parser");
857 config.Write(
"LastOpenedFilePath", wxString(
parserSettings_.lastOpenedFilePath));
858 config.Write(
"DefaultFileEncoding", wxString(
parserSettings_.defaultFileEncoding));
862 config.SetPath(
"/Performance");
884 LOG_INFO(
"AppPreferences",
"Preferences saved successfully");
886 }
catch (
const std::exception &e) {
887 LOG_ERROR(
"AppPreferences",
"Error saving preferences: " + std::string(e.what()));