| 5414 | } |
| 5415 | |
| 5416 | void Engine::LoadConfigFile() { |
| 5417 | static const int kBufSize = 512; |
| 5418 | char defaults_path[kBufSize]; |
| 5419 | if (FindFilePath("Data/defaults.txt", defaults_path, kBufSize, kDataPaths | kModPaths) == -1) { |
| 5420 | FatalError("Error", "Working directory is probably not set correctly -- could not find defaults.txt in Data folder"); |
| 5421 | } |
| 5422 | default_config.Load(defaults_path); |
| 5423 | |
| 5424 | std::string config_path = GetConfigPath(); |
| 5425 | if (!config.Load(config_path)) { |
| 5426 | // If no config file, then load defaults file, and create config file from that |
| 5427 | if (!config.Load(defaults_path)) { |
| 5428 | std::string abs_path = AbsPathFromRel("/Data"); |
| 5429 | FatalError("Error", "Working directory is probably not set correctly -- could not find config.txt or defaults.txt in Data folder: %s", abs_path.c_str()); |
| 5430 | } |
| 5431 | config.Save(config_path); |
| 5432 | } else { |
| 5433 | // If config file is found, then fill in missing values with the defaults |
| 5434 | Config old_config = config; |
| 5435 | config.Load(defaults_path, true); |
| 5436 | if (old_config != config) { |
| 5437 | config.Save(config_path); |
| 5438 | } |
| 5439 | } |
| 5440 | |
| 5441 | config.GetRef("menu_player_config") = 0; |
| 5442 | |
| 5443 | Graphics::Instance()->SetFromConfig(config); |
| 5444 | Input::Instance()->SetFromConfig(config); |
| 5445 | // Textures::Instance()->SetProcessPoolsEnabled(config["background_process_pool"].toNumber<bool>()); |
| 5446 | ActiveCameras::Get()->SetAutoCamera(config["auto_camera"].toNumber<bool>()); |
| 5447 | DebugDrawAux::Instance()->visible_sound_spheres = config["visible_sound_spheres"].toNumber<bool>(); |
| 5448 | g_albedo_only = config["albedo_only"].toNumber<bool>(); |
| 5449 | g_disable_fog = config["disable_fog"].toNumber<int>(); |
| 5450 | g_no_reflection_capture = config["no_reflection_capture"].toNumber<bool>(); |
| 5451 | g_no_decals = config["no_decals"].toNumber<bool>(); |
| 5452 | g_no_decal_elements = config["no_decal_elements"].toNumber<bool>(); |
| 5453 | g_no_detailmaps = config["no_detailmaps"].toNumber<bool>(); |
| 5454 | g_single_pass_shadow_cascade = config["single_pass_shadow_cascade"].toNumber<bool>(); |
| 5455 | sound.SetMusicVolume(config["music_volume"].toNumber<float>()); |
| 5456 | sound.SetMasterVolume(config["master_volume"].toNumber<float>()); |
| 5457 | std::string extra_data_path = config["extra_data_path"].str(); |
| 5458 | |
| 5459 | // Only care about data path if it's specified. |
| 5460 | if (extra_data_path.length() > 0) { |
| 5461 | if (CheckFileAccess(extra_data_path.c_str())) { |
| 5462 | AddPath(extra_data_path.c_str(), kDataPaths); |
| 5463 | } else { |
| 5464 | std::stringstream ss; |
| 5465 | ss << "Could not find: " << extra_data_path << std::endl |
| 5466 | << " Check extra_data_path in config file"; |
| 5467 | DisplayError("Warning", ss.str().c_str(), _ok, false); |
| 5468 | } |
| 5469 | } else { |
| 5470 | LOGE << "No extra_data_path was specified." << std::endl; |
| 5471 | } |
| 5472 | |
| 5473 | Shaders::Instance()->shader_dir_path = "Data/GLSL/"; |
nothing calls this directly
no test coverage detected