Move binary paths setup to game_config_manager class.
This commit is contained in:
parent
9ce42ce9bd
commit
2863818293
3 changed files with 16 additions and 24 deletions
|
@ -71,7 +71,7 @@ void game_config_manager::clear_cache_defines()
|
|||
|
||||
bool game_config_manager::init_config(const bool force, const bool jump_to_editor)
|
||||
{
|
||||
load_game_cfg(true, force);
|
||||
load_game_cfg(true, true, force);
|
||||
|
||||
// make sure that multiplayer mode is set if command line parameter is selected
|
||||
if (cmdline_opts_.multiplayer)
|
||||
|
@ -93,7 +93,6 @@ bool game_config_manager::init_config(const bool force, const bool jump_to_edito
|
|||
hotkey::set_scope_active(hotkey::SCOPE_GAME);
|
||||
|
||||
hotkey::load_hotkeys(game_config(), true);
|
||||
paths_manager_.set_paths(game_config());
|
||||
::init_textdomains(game_config());
|
||||
about::set_about(game_config());
|
||||
ai::configuration::init(game_config());
|
||||
|
@ -101,7 +100,7 @@ bool game_config_manager::init_config(const bool force, const bool jump_to_edito
|
|||
return true;
|
||||
}
|
||||
|
||||
void game_config_manager::load_game_cfg(const bool clear_cache_defines, const bool force)
|
||||
void game_config_manager::load_game_cfg(const bool set_bin_paths, const bool clear_cache_defines, const bool force)
|
||||
{
|
||||
if (clear_cache_defines)
|
||||
cache_.clear_defines();
|
||||
|
@ -272,6 +271,10 @@ void game_config_manager::load_game_cfg(const bool clear_cache_defines, const bo
|
|||
e.message + _("' (The game will now exit)"));
|
||||
throw;
|
||||
}
|
||||
|
||||
// set binary paths
|
||||
if (set_bin_paths)
|
||||
paths_manager_.set_paths(game_config());
|
||||
}
|
||||
|
||||
void game_config_manager::reload_changed_game_config(const bool jump_to_editor)
|
||||
|
|
|
@ -23,7 +23,6 @@ class config;
|
|||
|
||||
class game_config_manager
|
||||
{
|
||||
friend class game_controller;
|
||||
|
||||
public:
|
||||
game_config_manager(const commandline_options& cmdline_opts, game_display& disp);
|
||||
|
@ -37,12 +36,9 @@ public:
|
|||
void clear_cache_defines();
|
||||
|
||||
bool init_config(const bool force = false, const bool jump_to_editor = false);
|
||||
void load_game_cfg(const bool clear_cache_defines = true, const bool force = false);
|
||||
void load_game_cfg(const bool set_bin_paths, const bool clear_cache_defines, const bool force = false);
|
||||
void reload_changed_game_config(const bool jump_to_editor = false);
|
||||
|
||||
protected:
|
||||
binary_paths_manager& bin_paths_manager() { return paths_manager_; }
|
||||
|
||||
private:
|
||||
game_config_manager(const game_config_manager&);
|
||||
|
||||
|
|
|
@ -296,9 +296,7 @@ bool game_controller::play_test()
|
|||
state_.classification().campaign_define = "TEST";
|
||||
resources::config_manager->add_cache_define("TEST");
|
||||
|
||||
resources::config_manager->load_game_cfg(false);
|
||||
|
||||
resources::config_manager->bin_paths_manager().set_paths(game_config());
|
||||
resources::config_manager->load_game_cfg(true, false);
|
||||
|
||||
try {
|
||||
play_game(disp(),state_,game_config());
|
||||
|
@ -316,7 +314,7 @@ bool game_controller::play_screenshot_mode()
|
|||
}
|
||||
|
||||
resources::config_manager->add_define("EDITOR");
|
||||
resources::config_manager->load_game_cfg();
|
||||
resources::config_manager->load_game_cfg(false, true);
|
||||
const binary_paths_manager bin_paths_manager(game_config());
|
||||
::init_textdomains(game_config());
|
||||
|
||||
|
@ -346,13 +344,12 @@ bool game_controller::load_game()
|
|||
}
|
||||
|
||||
try {
|
||||
resources::config_manager->load_game_cfg();
|
||||
resources::config_manager->load_game_cfg(true, true);
|
||||
} catch(config::error&) {
|
||||
resources::config_manager->load_game_cfg();
|
||||
resources::config_manager->load_game_cfg(false, true);
|
||||
return false;
|
||||
}
|
||||
|
||||
resources::config_manager->bin_paths_manager().set_paths(game_config());
|
||||
load.set_gamestate();
|
||||
|
||||
} catch(load_game_cancelled_exception&) {
|
||||
|
@ -729,11 +726,9 @@ bool game_controller::play_multiplayer()
|
|||
|
||||
/* do */ {
|
||||
resources::config_manager->add_define(state_.classification().campaign_define);
|
||||
resources::config_manager->load_game_cfg();
|
||||
resources::config_manager->load_game_cfg(true, true);
|
||||
events::discard_input(); // prevent the "keylogger" effect
|
||||
cursor::set(cursor::NORMAL);
|
||||
// update binary paths
|
||||
resources::config_manager->bin_paths_manager().set_paths(game_config());
|
||||
clear_binary_paths_cache();
|
||||
}
|
||||
|
||||
|
@ -804,11 +799,9 @@ bool game_controller::play_multiplayer_commandline()
|
|||
state_.classification().campaign_define = "MULTIPLAYER";
|
||||
|
||||
resources::config_manager->add_define(state_.classification().campaign_define);
|
||||
resources::config_manager->load_game_cfg();
|
||||
resources::config_manager->load_game_cfg(true, true);
|
||||
events::discard_input(); // prevent the "keylogger" effect
|
||||
cursor::set(cursor::NORMAL);
|
||||
// update binary paths
|
||||
resources::config_manager->bin_paths_manager().set_paths(game_config());
|
||||
clear_binary_paths_cache();
|
||||
|
||||
config game_data;
|
||||
|
@ -854,9 +847,9 @@ void game_controller::launch_game(RELOAD_GAME_DATA reload)
|
|||
resources::config_manager->add_define(*i);
|
||||
}
|
||||
try {
|
||||
resources::config_manager->load_game_cfg(false);
|
||||
resources::config_manager->load_game_cfg(false, false);
|
||||
} catch(config::error&) {
|
||||
resources::config_manager->load_game_cfg();
|
||||
resources::config_manager->load_game_cfg(false, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -902,7 +895,7 @@ editor::EXIT_STATUS game_controller::start_editor(const std::string& filename)
|
|||
{
|
||||
while(true){
|
||||
resources::config_manager->add_define("EDITOR");
|
||||
resources::config_manager->load_game_cfg();
|
||||
resources::config_manager->load_game_cfg(false, true);
|
||||
const binary_paths_manager bin_paths_manager(game_config());
|
||||
::init_textdomains(game_config());
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue