5#include <wx/fileconf.h>
6#include <wx/filename.h>
16 LOG_INFO(
"Config",
"Resetting configuration to defaults");
35 LOG_INFO(
"Config",
"Loading configuration from: " + filename);
37 if (!wxFile::Exists(filename)) {
38 LOG_WARNING(
"Config",
"Configuration file does not exist: " + filename);
43 wxFileConfig config(filename);
46 config.SetPath(
"/Sync");
47 syncSettings_.enableHierarchyToScene = config.ReadBool(
"EnableHierarchyToScene",
true);
48 syncSettings_.enableSceneToHierarchy = config.ReadBool(
"EnableSceneToHierarchy",
true);
49 syncSettings_.enableAutoCenter = config.ReadBool(
"EnableAutoCenter",
true);
50 syncSettings_.enableSelectionHighlight = config.ReadBool(
"EnableSelectionHighlight",
true);
51 syncSettings_.enableHoverEffects = config.ReadBool(
"EnableHoverEffects",
true);
52 syncSettings_.centerWithAnimation = config.ReadBool(
"CenterWithAnimation",
false);
53 syncSettings_.centeringSpeed = config.ReadDouble(
"CenteringSpeed", 1.0);
54 syncSettings_.preventSyncLoops = config.ReadBool(
"PreventSyncLoops",
true);
57 config.SetPath(
"/Visual");
58 visualSettings_.selectionBorderWidth = config.ReadLong(
"SelectionBorderWidth", 3);
59 visualSettings_.hoverBorderWidth = config.ReadLong(
"HoverBorderWidth", 2);
60 visualSettings_.highlightOpacity = config.ReadDouble(
"HighlightOpacity", 1.0);
61 visualSettings_.enableAnimations = config.ReadBool(
"EnableAnimations",
true);
62 visualSettings_.animationDuration = config.ReadLong(
"AnimationDuration", 200);
65 config.SetPath(
"/Interaction");
68 interactionSettings_.enableKeyboardNavigation = config.ReadBool(
"EnableKeyboardNavigation",
true);
70 interactionSettings_.requireCtrlForMultiSelect = config.ReadBool(
"RequireCtrlForMultiSelect",
true);
75 config.SetPath(
"/Debug");
76 debugSettings_.enableSyncLogging = config.ReadBool(
"EnableSyncLogging",
false);
77 debugSettings_.enablePerformanceMetrics = config.ReadBool(
"EnablePerformanceMetrics",
false);
78 debugSettings_.enableDebugOverlay = config.ReadBool(
"EnableDebugOverlay",
false);
79 debugSettings_.verboseLogging = config.ReadBool(
"VerboseLogging",
false);
84 LOG_INFO(
"Config",
"Configuration loaded successfully");
86 }
catch (
const std::exception &e) {
87 LOG_ERROR(
"Config",
"Error loading configuration: " + std::string(e.what()));
93 LOG_INFO(
"Config",
"Saving configuration to: " + filename);
96 wxFileName fn(filename);
98 if (!fn.DirExists()) {
99 fn.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);
102 wxFileConfig config(filename);
105 config.SetPath(
"/Sync");
106 config.Write(
"EnableHierarchyToScene",
syncSettings_.enableHierarchyToScene);
107 config.Write(
"EnableSceneToHierarchy",
syncSettings_.enableSceneToHierarchy);
108 config.Write(
"EnableAutoCenter",
syncSettings_.enableAutoCenter);
109 config.Write(
"EnableSelectionHighlight",
syncSettings_.enableSelectionHighlight);
110 config.Write(
"EnableHoverEffects",
syncSettings_.enableHoverEffects);
111 config.Write(
"CenterWithAnimation",
syncSettings_.centerWithAnimation);
112 config.Write(
"CenteringSpeed",
syncSettings_.centeringSpeed);
113 config.Write(
"PreventSyncLoops",
syncSettings_.preventSyncLoops);
116 config.SetPath(
"/Visual");
117 config.Write(
"SelectionBorderWidth",
visualSettings_.selectionBorderWidth);
124 config.SetPath(
"/Interaction");
134 config.SetPath(
"/Debug");
135 config.Write(
"EnableSyncLogging",
debugSettings_.enableSyncLogging);
136 config.Write(
"EnablePerformanceMetrics",
debugSettings_.enablePerformanceMetrics);
137 config.Write(
"EnableDebugOverlay",
debugSettings_.enableDebugOverlay);
142 LOG_INFO(
"Config",
"Configuration saved successfully");
144 }
catch (
const std::exception &e) {
145 LOG_ERROR(
"Config",
"Error saving configuration: " + std::string(e.what()));
157 LOG_WARNING(
"Config",
"UnregisterChangeCallback not fully implemented");
161 bool changed =
false;
163 if (
syncSettings_.enableHierarchyToScene != hierarchyToScene) {
169 if (
syncSettings_.enableSceneToHierarchy != sceneToHierarchy) {
176 LOG_INFO(
"Config",
"Sync settings updated - H→S: " + std::to_string(hierarchyToScene) +
177 ", S→H: " + std::to_string(sceneToHierarchy));
182 bool changed =
false;
197 LOG_INFO(
"Config",
"Centering settings updated - Enabled: " + std::to_string(enabled) +
198 ", Animated: " + std::to_string(animated));
206 LOG_INFO(
"Config",
"Highlighting enabled: " + std::to_string(enabled));
214 LOG_INFO(
"Config",
"Debug mode: " + std::to_string(enabled));
220 std::vector<std::string> errors;
224 errors.push_back(
"Centering speed must be between 0.1 and 5.0");
229 errors.push_back(
"Selection border width must be between 1 and 10");
232 errors.push_back(
"Highlight opacity must be between 0.0 and 1.0");
235 errors.push_back(
"Animation duration must be between 50 and 2000 ms");
240 errors.push_back(
"Double-click speed must be between 100 and 2000 ms");
249 callback(category, setting);
250 }
catch (
const std::exception &e) {
251 LOG_ERROR(
"Config",
"Error in change callback: " + std::string(e.what()));
277 return hierarchyToScene ?
config_.GetSyncSettings().enableHierarchyToScene
278 :
config_.GetSyncSettings().enableSceneToHierarchy;
284 return config_.GetSyncSettings().enableSelectionHighlight;
#define LOG_ERROR(category, message)
#define LOG_WARNING(category, message)
#define LOG_INFO(category, message)
BehaviorTreeConfigManager()=default
bool IsCenteringEnabled() const
static BehaviorTreeConfigManager & GetInstance()
bool IsHighlightingEnabled() const
bool IsSyncEnabled(bool hierarchyToScene) const
BehaviorTreeConfig config_
void UnregisterChangeCallback(const ConfigChangeCallback &callback)
VisualSettings visualSettings_
std::function< void(const std::string &category, const std::string &setting)> ConfigChangeCallback
InteractionSettings interactionSettings_
std::vector< ConfigChangeCallback > changeCallbacks_
bool LoadFromFile(const EmberCore::String &filename)
void NotifyChange(const std::string &category, const std::string &setting)
void SetDebugMode(bool enabled)
bool SaveToFile(const EmberCore::String &filename) const
void SetSyncEnabled(bool hierarchyToScene, bool sceneToHierarchy)
SyncSettings syncSettings_
bool ValidateSettings() const
std::vector< std::string > GetValidationErrors() const
DebugSettings debugSettings_
void SetHighlightingEnabled(bool enabled)
void SetCenteringEnabled(bool enabled, bool animated=false)
void RegisterChangeCallback(const ConfigChangeCallback &callback)
Main types header for EmberCore.
std::string String
Framework-agnostic string type.
Debugging and development settings.
Interaction behavior configuration settings.
Synchronization configuration settings.
Visual appearance configuration settings.