| 215 | } |
| 216 | |
| 217 | void 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 | |
| 270 | void MainProgram::set_vsync_value(int vsyncValue) { |
| 271 | if(!SDL_GL_SetSwapInterval(vsyncValue)) { |
no test coverage detected