MCPcopy Create free account
hub / github.com/ErrorAtLine0/infinipaint / load_config

Method load_config

src/MainProgram.cpp:217–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215}
216
217void MainProgram::load_config() {
218 conf.currentSearchPath = homePath;
219 using json = nlohmann::json;
220
221 try {
222 json j(nlohmann::json::parse(read_file_to_string(conf.configPath / "config.json")));
223
224 VersionNumber version(0, 0, 1);
225 try {
226 std::string versionStr;
227 j.at("version").get_to(versionStr);
228 auto optVersion = version_str_to_version_numbers(versionStr);
229 if(optVersion.has_value())
230 version = optVersion.value();
231 }
232 catch(...) {}
233
234 try {
235 conf.set_config_json(input, j["settings"], version);
236 }
237 catch(...) {}
238#ifndef __EMSCRIPTEN__
239 try {
240 j.at("window").at("size").get_to(window.size);
241 window.writtenSize = window.size;
242 j.at("window").at("pos").get_to(window.pos);
243 window.writtenPos = window.pos;
244 j.at("window").at("maximized").get_to(window.maximized);
245 j.at("window").at("fullscreen").get_to(window.fullscreen);
246 }
247 catch(...) {}
248 try {
249 j.at("fileselectorpath").get_to(conf.currentSearchPath);
250 }
251 catch(...) {
252 conf.currentSearchPath = homePath;
253 }
254#endif
255 try {
256 j.at("toolConfig").get_to(toolConfig);
257 }
258 catch(...) {}
259 } catch(...) {}
260 conf.load_palettes();
261 g.load_theme(conf.configPath, conf.themeCurrentlyLoaded);
262 conf.load_licenses();
263
264 NetLibrary::copy_default_p2p_config_to_path(conf.configPath / "p2p.json");
265 NetLibrary::init_config(conf.configPath / "p2p.json");
266
267 update_display_names();
268}
269
270void MainProgram::set_vsync_value(int vsyncValue) {
271 if(!SDL_GL_SetSwapInterval(vsyncValue)) {

Callers 1

SDL_AppInitFunction · 0.80

Calls 10

parseFunction · 0.85
read_file_to_stringFunction · 0.85
get_toMethod · 0.80
set_config_jsonMethod · 0.80
load_palettesMethod · 0.80
load_themeMethod · 0.80
load_licensesMethod · 0.80
atMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected