The Battle for Wesnoth  1.19.5+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 #include "utils/optional_fwd.hpp"
26 
29 {
30  friend class game_config_view;
31 public:
32  game_config_manager(const commandline_options& cmdline_opts);
34 
37 
39  {
40  /** Always reload config */
42  /** Don't reload if the previous defines equal the new defines */
44  /** Don't reload if the previous defines include the new defines */
46  };
47 
48  const game_config_view& game_config() const { return game_config_view_; }
49  const preproc_map& old_defines_map() const { return old_defines_map_; }
50  const std::shared_ptr<terrain_type_data>& terrain_types() const { return tdata_; }
51  std::vector<achievement_group>& get_achievements() { return achievements_.get_list(); }
52 
53  bool init_game_config(FORCE_RELOAD_CONFIG force_reload);
55 
57  void load_game_config_for_game(const game_classification& classification, const std::string& scenario_id);
58  void load_game_config_for_create(bool is_mp, bool is_test = false);
59 
60  static game_config_manager * get();
61 
62 private:
63  void set_enabled_addon(std::set<std::string> addon_ids);
64  void set_enabled_addon_all();
65 
66  void load_game_config(bool reload_everything, const game_classification* classification, const std::string& scenario_id);
67 
68  void load_game_config_with_loadscreen(FORCE_RELOAD_CONFIG force_reload, const game_classification* classification, const std::string& scenario_id);
69 
70  // load_game_config() helper functions.
71  void load_addons_cfg();
73  void set_unit_data();
74 
76 
79 
80  std::map<std::string, config> addon_cfgs_;
81  std::set<std::string> active_addons_;
82 
84 
86 
88 
89  std::shared_ptr<terrain_type_data> tdata_;
90 
92 };
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:172
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)
@ 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)
game_config_manager & operator=(const game_config_manager &)=delete
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_
game_config_manager(const game_config_manager &)=delete
const std::shared_ptr< terrain_type_data > & terrain_types() const
std::vector< achievement_group > & get_achievements()
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 ...
Definitions for the interface to Wesnoth Markup Language (WML).
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:438