6#include "absl/strings/str_format.h"
8#include "imgui/imgui.h"
18 if (config_dir_status.ok()) {
22 "Could not determine config directory. Using local.");
31 LOG_INFO(
"UserSettings",
"Settings file not found, creating defaults at: %s",
38 return absl::OkStatus();
41 std::istringstream ss(data);
43 while (std::getline(ss, line)) {
44 size_t eq_pos = line.find(
'=');
45 if (eq_pos == std::string::npos)
48 std::string key = line.substr(0, eq_pos);
49 std::string val = line.substr(eq_pos + 1);
52 if (key ==
"font_global_scale") {
54 }
else if (key ==
"backup_rom") {
56 }
else if (key ==
"save_new_auto") {
58 }
else if (key ==
"autosave_enabled") {
60 }
else if (key ==
"autosave_interval") {
62 }
else if (key ==
"recent_files_limit") {
64 }
else if (key ==
"last_rom_path") {
66 }
else if (key ==
"last_project_path") {
68 }
else if (key ==
"show_welcome_on_startup") {
70 }
else if (key ==
"restore_last_session") {
72 }
else if (key ==
"prefer_hmagic_sprite_names") {
76 else if (key ==
"backup_before_save") {
78 }
else if (key ==
"default_editor") {
82 else if (key ==
"vsync") {
84 }
else if (key ==
"target_fps") {
86 }
else if (key ==
"cache_size_mb") {
88 }
else if (key ==
"undo_history_size") {
92 else if (key ==
"ai_provider") {
94 }
else if (key ==
"ollama_url") {
96 }
else if (key ==
"gemini_api_key") {
98 }
else if (key ==
"ai_temperature") {
100 }
else if (key ==
"ai_max_tokens") {
102 }
else if (key ==
"ai_proactive") {
104 }
else if (key ==
"ai_auto_learn") {
106 }
else if (key ==
"ai_multimodal") {
110 else if (key ==
"log_level") {
112 }
else if (key ==
"log_to_file") {
114 }
else if (key ==
"log_file_path") {
116 }
else if (key ==
"log_ai_requests") {
118 }
else if (key ==
"log_rom_operations") {
120 }
else if (key ==
"log_gui_automation") {
122 }
else if (key ==
"log_proposals") {
126 else if (key.substr(0, 15) ==
"panel_shortcut.") {
127 std::string panel_id = key.substr(15);
131 else if (key.substr(0, 14) ==
"card_shortcut.") {
132 std::string panel_id = key.substr(14);
136 else if (key ==
"sidebar_visible") {
138 }
else if (key ==
"sidebar_panel_expanded") {
140 }
else if (key ==
"sidebar_active_category") {
144 else if (key ==
"show_status_bar") {
149 }
catch (
const std::exception& e) {
150 return absl::InternalError(
151 absl::StrFormat(
"Failed to load user settings: %s", e.what()));
153 return absl::OkStatus();
158 std::ostringstream ss;
206 ss <<
"panel_shortcut." << panel_id <<
"=" << shortcut <<
"\n";
218 }
catch (
const std::exception& e) {
219 return absl::InternalError(
220 absl::StrFormat(
"Failed to save user settings: %s", e.what()));
222 return absl::OkStatus();
std::string settings_file_path_
#define LOG_WARN(category, format,...)
#define LOG_INFO(category, format,...)
void SaveFile(const std::string &filename, const std::string &contents)
std::string LoadFile(const std::string &filename)
Loads the entire contents of a file into a string.
std::string gemini_api_key
std::unordered_map< std::string, std::string > panel_shortcuts
bool sidebar_panel_expanded
bool show_welcome_on_startup
std::string sidebar_active_category
std::string last_project_path
std::string log_file_path
std::string last_rom_path
bool prefer_hmagic_sprite_names
bool restore_last_session