| 1304 | } |
| 1305 | |
| 1306 | void EditorSettings::create() { |
| 1307 | if (singleton.ptr()) { |
| 1308 | ERR_PRINT("Can't recreate EditorSettings as it already exists."); |
| 1309 | return; |
| 1310 | } |
| 1311 | |
| 1312 | String config_file_path; |
| 1313 | Ref<ConfigFile> extra_config = memnew(ConfigFile); |
| 1314 | |
| 1315 | if (!EditorPaths::get_singleton()) { |
| 1316 | ERR_PRINT("Bug (please report): EditorPaths haven't been initialized, EditorSettings cannot be created properly."); |
| 1317 | goto fail; |
| 1318 | } |
| 1319 | |
| 1320 | if (EditorPaths::get_singleton()->is_self_contained()) { |
| 1321 | Error err = extra_config->load(EditorPaths::get_singleton()->get_self_contained_file()); |
| 1322 | if (err != OK) { |
| 1323 | ERR_PRINT("Can't load extra config from path: " + EditorPaths::get_singleton()->get_self_contained_file()); |
| 1324 | } |
| 1325 | } |
| 1326 | |
| 1327 | if (EditorPaths::get_singleton()->are_paths_valid()) { |
| 1328 | // Validate editor config file. |
| 1329 | ERR_FAIL_COND(!DirAccess::dir_exists_absolute(EditorPaths::get_singleton()->get_config_dir())); |
| 1330 | |
| 1331 | config_file_path = get_existing_settings_path(); |
| 1332 | if (!FileAccess::exists(config_file_path)) { |
| 1333 | config_file_path = get_newest_settings_path(); |
| 1334 | goto fail; |
| 1335 | } |
| 1336 | |
| 1337 | singleton = ResourceLoader::load(config_file_path, "EditorSettings"); |
| 1338 | if (singleton.is_null()) { |
| 1339 | ERR_PRINT("Could not load editor settings from path: " + config_file_path); |
| 1340 | config_file_path = get_newest_settings_path(); |
| 1341 | goto fail; |
| 1342 | } |
| 1343 | |
| 1344 | singleton->set_path(get_newest_settings_path()); // Settings can be loaded from older version file, so make sure it's newest. |
| 1345 | singleton->save_changed_setting = true; |
| 1346 | |
| 1347 | print_verbose("EditorSettings: Load OK!"); |
| 1348 | |
| 1349 | singleton->setup_language(); |
| 1350 | singleton->setup_network(); |
| 1351 | singleton->load_favorites_and_recent_dirs(); |
| 1352 | singleton->update_text_editor_themes_list(); |
| 1353 | #ifndef DISABLE_DEPRECATED |
| 1354 | singleton->_remove_deprecated_settings(); |
| 1355 | #endif |
| 1356 | |
| 1357 | return; |
| 1358 | } |
| 1359 | |
| 1360 | fail: |
| 1361 | // patch init projects |
| 1362 | String exe_path = OS::get_singleton()->get_executable_path().get_base_dir(); |
| 1363 |
nothing calls this directly
no test coverage detected