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.");
32 "Settings file not found, creating defaults at: %s",
39 return absl::OkStatus();
42 std::istringstream ss(data);
44 while (std::getline(ss, line)) {
45 size_t eq_pos = line.find(
'=');
46 if (eq_pos == std::string::npos)
49 std::string key = line.substr(0, eq_pos);
50 std::string val = line.substr(eq_pos + 1);
53 if (key ==
"font_global_scale") {
55 }
else if (key ==
"backup_rom") {
57 }
else if (key ==
"save_new_auto") {
59 }
else if (key ==
"autosave_enabled") {
61 }
else if (key ==
"autosave_interval") {
63 }
else if (key ==
"recent_files_limit") {
65 }
else if (key ==
"last_rom_path") {
67 }
else if (key ==
"last_project_path") {
69 }
else if (key ==
"show_welcome_on_startup") {
71 }
else if (key ==
"restore_last_session") {
73 }
else if (key ==
"prefer_hmagic_sprite_names") {
77 else if (key ==
"backup_before_save") {
79 }
else if (key ==
"default_editor") {
83 else if (key ==
"vsync") {
85 }
else if (key ==
"target_fps") {
87 }
else if (key ==
"cache_size_mb") {
89 }
else if (key ==
"undo_history_size") {
93 else if (key ==
"ai_provider") {
95 }
else if (key ==
"ollama_url") {
97 }
else if (key ==
"gemini_api_key") {
99 }
else if (key ==
"ai_temperature") {
101 }
else if (key ==
"ai_max_tokens") {
103 }
else if (key ==
"ai_proactive") {
105 }
else if (key ==
"ai_auto_learn") {
107 }
else if (key ==
"ai_multimodal") {
111 else if (key ==
"log_level") {
113 }
else if (key ==
"log_to_file") {
115 }
else if (key ==
"log_file_path") {
117 }
else if (key ==
"log_ai_requests") {
119 }
else if (key ==
"log_rom_operations") {
121 }
else if (key ==
"log_gui_automation") {
123 }
else if (key ==
"log_proposals") {
127 else if (key.substr(0, 15) ==
"panel_shortcut.") {
128 std::string panel_id = key.substr(15);
132 else if (key.substr(0, 14) ==
"card_shortcut.") {
133 std::string panel_id = key.substr(14);
137 else if (key ==
"sidebar_visible") {
139 }
else if (key ==
"sidebar_panel_expanded") {
141 }
else if (key ==
"sidebar_active_category") {
145 else if (key ==
"show_status_bar") {
150 }
catch (
const std::exception& e) {
151 return absl::InternalError(
152 absl::StrFormat(
"Failed to load user settings: %s", e.what()));
154 return absl::OkStatus();
159 std::ostringstream ss;
173 ss <<
"prefer_hmagic_sprite_names="
207 ss <<
"panel_shortcut." << panel_id <<
"=" << shortcut <<
"\n";
220 }
catch (
const std::exception& e) {
221 return absl::InternalError(
222 absl::StrFormat(
"Failed to save user settings: %s", e.what()));
224 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