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 <vector>
7
8#include "absl/status/status.h"
9
10namespace yaze {
11namespace editor {
12
17 public:
18 struct Preferences {
19 struct AiHost {
20 std::string id;
21 std::string label;
22 std::string base_url;
23 std::string api_type; // openai, ollama, gemini, lmstudio, grpc
24 bool supports_vision = false;
25 bool supports_tools = true;
26 bool supports_streaming = true;
27 bool allow_insecure = false;
28 std::string api_key; // Optional plaintext key (desktop/non-keychain)
29 std::string credential_id; // Keychain reference (never store secrets here)
30 };
31
33 std::string name;
34 std::string model;
35 float temperature = 0.25f;
36 float top_p = 0.95f;
38 bool supports_vision = false;
39 bool supports_tools = true;
40 };
41
42 // General
43 float font_global_scale = 1.0f;
44 bool backup_rom = false;
45 bool save_new_auto = true;
46 bool autosave_enabled = true;
47 float autosave_interval = 300.0f;
49 std::string last_rom_path;
50 std::string last_project_path;
54
55 // Accessibility / interaction
56 bool reduced_motion = false;
57 int switch_motion_profile = 1; // 0=Snappy, 1=Standard, 2=Relaxed
58
59 // Editor Behavior
60 bool backup_before_save = true;
61 int default_editor = 0; // 0=None, 1=Overworld, 2=Dungeon, 3=Graphics
62
63 // Performance
64 bool vsync = true;
65 int target_fps = 60;
66 int cache_size_mb = 512;
68
69 // AI Agent
70 int ai_provider = 0; // Legacy default provider (0=Ollama, 1=Gemini, 2=Mock)
71 std::string ai_model;
72 std::string ollama_url = "http://localhost:11434";
73 std::string gemini_api_key;
74 std::string openai_api_key;
75 std::string anthropic_api_key;
76 float ai_temperature = 0.7f;
77 int ai_max_tokens = 2048;
78 bool ai_proactive = true;
79 bool ai_auto_learn = true;
80 bool ai_multimodal = true;
81 std::vector<AiHost> ai_hosts;
82 std::string active_ai_host_id;
83 std::vector<AiModelProfile> ai_profiles;
84 std::string active_ai_profile;
86 std::vector<std::string> ai_model_paths;
87
88 // CLI Logging
89 int log_level = 1; // 0=Debug, 1=Info, 2=Warning, 3=Error, 4=Fatal
90 bool log_to_file = false;
91 std::string log_file_path;
92 bool log_ai_requests = true;
93 bool log_rom_operations = true;
94 bool log_gui_automation = true;
95 bool log_proposals = true;
96
97 // Filesystem (iOS + remote workflows)
98 std::vector<std::string> project_root_paths;
100 bool use_files_app = true;
101 bool use_icloud_sync = true;
102
103 // Shortcut Overrides
104 // Maps panel_id -> shortcut string (e.g., "dungeon.room_selector" -> "Ctrl+Shift+R")
105 std::unordered_map<std::string, std::string> panel_shortcuts;
106 // Maps global action id -> shortcut string (e.g., "Open", "Save")
107 std::unordered_map<std::string, std::string> global_shortcuts;
108 // Maps editor-scoped action id -> shortcut string (keyed by editor namespace)
109 std::unordered_map<std::string, std::string> editor_shortcuts;
110
111 // Sidebar State
112 bool sidebar_visible = true; // Controls Activity Bar visibility
113 bool sidebar_panel_expanded = true; // Controls Side Panel visibility
114 float sidebar_panel_width = 0.0f; // 0 = responsive default
117 std::string sidebar_active_category; // Last active category
118
119 // Status Bar
120 bool show_status_bar = false; // Show status bar at bottom (disabled by default)
121
122 // Panel Visibility State (per editor type)
123 // Maps editor_type_name -> (panel_id -> visible)
124 // e.g., "Overworld" -> {"overworld.tile16_selector" -> true, ...}
125 std::unordered_map<std::string, std::unordered_map<std::string, bool>>
127
128 // Pinned panels (persists across sessions)
129 // Maps panel_id -> pinned
130 std::unordered_map<std::string, bool> pinned_panels;
131 std::unordered_map<std::string, float> right_panel_widths;
132
133 // Named layouts (user-saved workspace configurations)
134 // Maps layout_name -> (panel_id -> visible)
135 std::unordered_map<std::string, std::unordered_map<std::string, bool>>
137 };
138
139 UserSettings();
140
141 absl::Status Load();
142 absl::Status Save();
143
144 // Applies a one-time layout defaults migration when target_revision is newer
145 // than persisted settings. Returns true when defaults were reset.
146 bool ApplyPanelLayoutDefaultsRevision(int target_revision);
147
148 static constexpr int kLatestPanelLayoutDefaultsRevision = 4;
149
150 Preferences& prefs() { return prefs_; }
151 const Preferences& prefs() const { return prefs_; }
152
153 private:
157};
158
159} // namespace editor
160} // namespace yaze
161
162#endif // YAZE_APP_EDITOR_SYSTEM_USER_SETTINGS_H_
Manages user preferences and settings persistence.
const Preferences & prefs() const
bool ApplyPanelLayoutDefaultsRevision(int target_revision)
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_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