yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
user_settings.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_SYSTEM_USER_SETTINGS_H_
2#define YAZE_APP_EDITOR_SYSTEM_USER_SETTINGS_H_
3
4#include <string>
5#include <unordered_map>
6#include <unordered_set>
7#include <utility>
8#include <vector>
9
10#include "absl/status/status.h"
11
12namespace yaze {
13namespace editor {
14
19 public:
20 struct Preferences {
21 struct AiHost {
22 std::string id;
23 std::string label;
24 std::string base_url;
25 std::string api_type; // openai, ollama, gemini, lmstudio, grpc
26 bool supports_vision = false;
27 bool supports_tools = true;
28 bool supports_streaming = true;
29 bool allow_insecure = false;
30 std::string api_key; // Optional plaintext key (desktop/non-keychain)
31 std::string
32 credential_id; // Keychain reference (never store secrets here)
33 };
34
36 std::string name;
37 std::string model;
38 float temperature = 0.25f;
39 float top_p = 0.95f;
41 bool supports_vision = false;
42 bool supports_tools = true;
43 };
44
45 // General
46 float font_global_scale = 1.0f;
47 bool backup_rom = false;
48 bool save_new_auto = true;
49 bool autosave_enabled = true;
50 float autosave_interval = 300.0f;
52 std::string last_rom_path;
53 std::string last_project_path;
57
58 // Welcome screen animation preferences. Match the defaults hard-coded in
59 // WelcomeScreen so first-run behavior is unchanged.
65
66 // Accessibility / interaction
67 bool reduced_motion = false;
68 int switch_motion_profile = 1; // 0=Snappy, 1=Standard, 2=Relaxed
69
70 // Theme (last applied theme persists across restart; empty = default)
71 std::string last_theme_name;
72
73 // Editor Behavior
74 bool backup_before_save = true;
75 int default_editor = 0; // 0=None, 1=Overworld, 2=Dungeon, 3=Graphics
76
77 // Performance
78 bool vsync = true;
79 int target_fps = 60;
80 int cache_size_mb = 512;
82
83 // AI Agent
85 0; // Legacy default provider (0=Ollama, 1=Gemini, 2=Mock)
86 std::string ai_model;
87 std::string ollama_url = "http://localhost:11434";
88 std::string gemini_api_key;
89 std::string openai_api_key;
90 std::string anthropic_api_key;
91 float ai_temperature = 0.7f;
92 int ai_max_tokens = 2048;
93 bool ai_proactive = true;
94 bool ai_auto_learn = true;
95 bool ai_multimodal = true;
96 std::vector<AiHost> ai_hosts;
97 std::string active_ai_host_id;
98 std::vector<AiModelProfile> ai_profiles;
99 std::string active_ai_profile;
101 std::vector<std::string> ai_model_paths;
102
103 // CLI Logging
104 int log_level = 1; // 0=Debug, 1=Info, 2=Warning, 3=Error, 4=Fatal
105 bool log_to_file = false;
106 std::string log_file_path;
107 bool log_ai_requests = true;
110 bool log_proposals = true;
111
112 // Filesystem (iOS + remote workflows)
113 std::vector<std::string> project_root_paths;
115 bool use_files_app = true;
116 bool use_icloud_sync = true;
117
118 // Shortcut Overrides
119 // Maps panel_id -> shortcut string (e.g., "dungeon.room_selector" -> "Ctrl+Shift+R")
120 std::unordered_map<std::string, std::string> panel_shortcuts;
121 // Maps global action id -> shortcut string (e.g., "Open", "Save")
122 std::unordered_map<std::string, std::string> global_shortcuts;
123 // Maps editor-scoped action id -> shortcut string (keyed by editor namespace)
124 std::unordered_map<std::string, std::string> editor_shortcuts;
125
126 // Sidebar State
127 bool sidebar_visible = true; // Controls Activity Bar visibility
128 bool sidebar_panel_expanded = true; // Controls Side Panel visibility
129 float sidebar_panel_width = 0.0f; // 0 = responsive default
132 std::string sidebar_active_category; // Last active category
133
134 // Sidebar customization (Phase 4): user-controlled category order,
135 // hidden set (filtered out of the rail), and pinned set (pinned-first).
136 std::vector<std::string> sidebar_order;
137 std::unordered_set<std::string> sidebar_hidden;
138 std::unordered_set<std::string> sidebar_pinned;
139
140 // Status Bar
142 false; // Show status bar at bottom (disabled by default)
143
144 // Panel Visibility State (per editor type)
145 // Maps editor_type_name -> (panel_id -> visible)
146 // e.g., "Overworld" -> {"overworld.tile16_selector" -> true, ...}
147 std::unordered_map<std::string, std::unordered_map<std::string, bool>>
149
150 // Pinned panels (persists across sessions)
151 // Maps panel_id -> pinned
152 std::unordered_map<std::string, bool> pinned_panels;
153 std::unordered_map<std::string, float> right_panel_widths;
154
155 // Named layouts (user-saved workspace configurations)
156 // Maps layout_name -> (panel_id -> visible)
157 std::unordered_map<std::string, std::unordered_map<std::string, bool>>
159 };
160
161 UserSettings();
162
163 absl::Status Load();
164 absl::Status Save();
165
166 // Applies a one-time layout defaults migration when target_revision is newer
167 // than persisted settings. Returns true when defaults were reset.
168 bool ApplyPanelLayoutDefaultsRevision(int target_revision);
169
170 static constexpr int kLatestPanelLayoutDefaultsRevision = 12;
171
172 Preferences& prefs() { return prefs_; }
173 const Preferences& prefs() const { return prefs_; }
174
175 // Testing hook: redirect Load/Save to a caller-specified path. Production
176 // code should never call this; it only exists so unit tests can exercise
177 // JSON round-trip without touching the user's real settings file.
178 void SetSettingsFilePathForTesting(std::string path) {
179 settings_file_path_ = std::move(path);
180 }
181
182 private:
186};
187
188} // namespace editor
189} // namespace yaze
190
191#endif // YAZE_APP_EDITOR_SYSTEM_USER_SETTINGS_H_
Manages user preferences and settings persistence.
const Preferences & prefs() const
bool ApplyPanelLayoutDefaultsRevision(int target_revision)
void SetSettingsFilePathForTesting(std::string path)
static constexpr int kLatestPanelLayoutDefaultsRevision
std::string legacy_settings_file_path_
std::vector< std::string > project_root_paths
std::unordered_map< std::string, std::string > panel_shortcuts
std::unordered_map< std::string, std::unordered_map< std::string, bool > > saved_layouts
std::vector< AiModelProfile > ai_profiles
std::unordered_set< std::string > sidebar_pinned
std::vector< std::string > sidebar_order
std::unordered_map< std::string, float > right_panel_widths
std::unordered_map< std::string, std::string > editor_shortcuts
std::vector< std::string > ai_model_paths
std::unordered_map< std::string, std::string > global_shortcuts
std::unordered_map< std::string, std::unordered_map< std::string, bool > > panel_visibility_state
std::unordered_map< std::string, bool > pinned_panels
std::unordered_set< std::string > sidebar_hidden