The Battle for Wesnoth  1.19.0-dev
game_config_manager.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2013 - 2024
3  by Andrius Silinskas <silinskas.andrius@gmail.com>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
18 #include "achievements.hpp"
19 #include "commandline_options.hpp"
20 #include "config.hpp"
21 #include "config_cache.hpp"
22 #include "filesystem.hpp"
23 #include "game_config_view.hpp"
24 #include "terrain/type_data.hpp"
25 
26 
29 {
30  friend class game_config_view;
31 public:
32  game_config_manager(const commandline_options& cmdline_opts);
35  {
36  /** Always reload config */
38  /** Don't reload if the previous defines equal the new defines */
40  /** Don't reload if the previous defines include the new defines */
42  };
43 
44  const game_config_view& game_config() const { return game_config_view_; }
45  const preproc_map& old_defines_map() const { return old_defines_map_; }
46  const std::shared_ptr<terrain_type_data>& terrain_types() const { return tdata_; }
47  std::vector<achievement_group>& get_achievements() { return achievements_.get_list(); }
48 
49  bool init_game_config(FORCE_RELOAD_CONFIG force_reload);
51 
53  void load_game_config_for_game(const game_classification& classification, const std::string& scenario_id);
54  void load_game_config_for_create(bool is_mp, bool is_test = false);
55 
56  static game_config_manager * get();
57 
58 
59 private:
60  void set_enabled_addon(std::set<std::string> addon_ids);
61  void set_enabled_addon_all();
64 
65  void load_game_config(bool reload_everything, const game_classification* classification, const std::string& scenario_id);
66 
67  void load_game_config_with_loadscreen(FORCE_RELOAD_CONFIG force_reload, const game_classification* classification, const std::string& scenario_id);
68 
69  // load_game_config() helper functions.
70  void load_addons_cfg();
72  void set_unit_data();
73 
75 
78 
79  std::map<std::string, config> addon_cfgs_;
80  std::set<std::string> active_addons_;
81 
83 
85 
87 
88  std::shared_ptr<terrain_type_data> tdata_;
89 
91 };
This class is responsible for reading all available achievements from mainline's and any add-ons' ach...
std::vector< achievement_group > & get_list()
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:159
Singleton class to manage game config file caching.
void load_game_config_with_loadscreen(FORCE_RELOAD_CONFIG force_reload, const game_classification *classification, const std::string &scenario_id)
game_config_manager(const game_config_manager &)
@ FORCE_RELOAD
Always reload config.
@ NO_INCLUDE_RELOAD
Don't reload if the previous defines include the new defines.
@ NO_FORCE_RELOAD
Don't reload if the previous defines equal the new defines.
std::map< std::string, config > addon_cfgs_
bool init_game_config(FORCE_RELOAD_CONFIG force_reload)
static game_config_manager * get()
void load_game_config_for_game(const game_classification &classification, const std::string &scenario_id)
void load_game_config(bool reload_everything, const game_classification *classification, const std::string &scenario_id)
std::set< std::string > active_addons_
void load_game_config_for_create(bool is_mp, bool is_test=false)
filesystem::binary_paths_manager paths_manager_
game_config_view game_config_view_
const preproc_map & old_defines_map() const
game_config::config_cache & cache_
std::shared_ptr< terrain_type_data > tdata_
const std::shared_ptr< terrain_type_data > & terrain_types() const
std::vector< achievement_group > & get_achievements()
void operator=(const game_config_manager &)
game_config_manager(const commandline_options &cmdline_opts)
void set_enabled_addon(std::set< std::string > addon_ids)
const game_config_view & game_config() const
const commandline_options & cmdline_opts_
A class grating read only view to a vector of config objects, viewed as one config with all children ...
Declarations for File-IO.
game_classification * classification
Definition: resources.cpp:34
std::map< std::string, struct preproc_define > preproc_map
The paths manager is responsible for recording the various paths that binary files may be located at.
Definition: filesystem.hpp:398