MCPcopy Create free account
hub / github.com/XorTroll/Goldleaf / Load

Method Load

Goldleaf/source/cfg/cfg_Settings.cpp:131–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129 }
130
131 void Settings::Load() {
132 _CFG_ENSURE_SETTING(this->json_settings, general, GeneralSettings);
133 _CFG_ENSURE_SETTING(this->json_settings, ui, UiSettings);
134 _CFG_ENSURE_SETTING(this->json_settings, fs, FsSettings);
135 _CFG_ENSURE_SETTING(this->json_settings, installs, InstallsSettings);
136 _CFG_ENSURE_SETTING(this->json_settings, exports, ExportsSettings);
137 _CFG_ENSURE_SETTING(this->json_settings, web, WebSettings);
138
139 const auto err = glz::read_file_json<PartialJsonOptions{}>(this->json_settings, "sdmc:/" GLEAF_PATH_SETTINGS_FILE, std::string{});
140 if(err) {
141 GLEAF_WARN_FMT("Failed to read settings JSON: %d (%s)", (u32)err.ec, err.custom_error_message.data());
142 }
143
144 if(this->json_settings.general.value().language.has_value()) {
145 this->lang = GetLanguageByCode(this->json_settings.general.value().language.value());
146 }
147 else {
148 this->lang = Language::Auto;
149 }
150
151 ColorSetId sys_color_set_id;
152 GLEAF_RC_ASSERT(setsysGetColorSetId(&sys_color_set_id));
153 this->is_light_mode = sys_color_set_id == ColorSetId_Light;
154
155 if(this->json_settings.ui.value().light_color_scheme.has_value()) {
156 ParseColorScheme(this->json_settings.ui.value().light_color_scheme.value(), this->light_color_scheme, DefaultLightScheme);
157 }
158 else {
159 this->light_color_scheme = DefaultLightScheme;
160 }
161
162 if(this->json_settings.ui.value().dark_color_scheme.has_value()) {
163 ParseColorScheme(this->json_settings.ui.value().dark_color_scheme.value(), this->dark_color_scheme, DefaultDarkScheme);
164 }
165 else {
166 this->dark_color_scheme = DefaultDarkScheme;
167 }
168
169 #define _CFG_CLAMP_FS_BUFFER_SIZE(mod, name) \
170 if(this->json_settings.mod.value().name.value() > 12_MB) { \
171 this->json_settings.mod.value().name.value() = 12_MB; \
172 } \
173
174 _CFG_CLAMP_FS_BUFFER_SIZE(installs, copy_buffer_max_size);
175 _CFG_CLAMP_FS_BUFFER_SIZE(exports, decrypt_buffer_max_size);
176 }
177
178 void Settings::Save() {
179 this->json_settings.general.value().language = GetLanguageCode(this->lang);

Callers 1

mainFunction · 0.45

Calls 2

GetLanguageByCodeFunction · 0.85
ParseColorSchemeFunction · 0.85

Tested by

no test coverage detected