The Battle for Wesnoth  1.17.0-dev
game_config_manager.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2013 - 2021
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 "commandline_options.hpp"
19 #include "config.hpp"
20 #include "config_cache.hpp"
21 #include "filesystem.hpp"
22 #include "game_config_view.hpp"
23 #include "terrain/type_data.hpp"
24 #include <optional>
25 
28 {
29  friend class game_config_view;
30 public:
31  game_config_manager(const commandline_options& cmdline_opts);
34  {
35  /** Always reload config */
37  /** Don't reload if the previous defines equal the new defines */
39  /** Don't reload if the previous defines include the new defines */
41  };
42 
43  const game_config_view& game_config() const { return game_config_view_; }
44  const preproc_map& old_defines_map() const { return old_defines_map_; }
45  const std::shared_ptr<terrain_type_data> & terrain_types() const { return tdata_; }
46 
47  bool init_game_config(FORCE_RELOAD_CONFIG force_reload);
49 
51  void load_game_config_for_game(const game_classification& classification, const std::string& scenario_id);
52  void load_game_config_for_create(bool is_mp, bool is_test = false);
53 
54  static game_config_manager * get();
55 
56 
57 private:
58  void set_enabled_addon(std::set<std::string> addon_ids);
59  void set_enabled_addon_all();
61  void operator=(const game_config_manager&);
62 
63  void load_game_config(bool reload_everything);
64 
66  game_classification const* classification = nullptr, std::optional<std::set<std::string>> active_addons = {});
67 
68  // load_game_config() helper functions.
69  void load_addons_cfg();
71  void set_unit_data();
72 
74 
77 
78  std::map<std::string, config> addon_cfgs_;
79  std::optional<std::set<std::string>> active_addons_;
80 
82 
84 
86 
87  std::shared_ptr<terrain_type_data> tdata_;
88 };
Don&#39;t reload if the previous defines include the new defines.
game_classification * classification
Definition: resources.cpp:35
filesystem::binary_paths_manager paths_manager_
The paths manager is responsible for recording the various paths that binary files may be located at...
Definition: filesystem.hpp:400
void load_game_config_for_game(const game_classification &classification, const std::string &scenario_id)
Don&#39;t reload if the previous defines equal the new defines.
Definitions for the interface to Wesnoth Markup Language (WML).
const std::shared_ptr< terrain_type_data > & terrain_types() const
std::optional< std::set< std::string > > active_addons_
const game_config_view & game_config() const
game_config_view game_config_view_
void set_enabled_addon(std::set< std::string > addon_ids)
void load_game_config_for_create(bool is_mp, bool is_test=false)
Declarations for File-IO.
void operator=(const game_config_manager &)
game_config_manager(const commandline_options &cmdline_opts)
const preproc_map & old_defines_map() const
void load_game_config(bool reload_everything)
const commandline_options & cmdline_opts_
game_config::config_cache & cache_
std::map< std::string, struct preproc_define > preproc_map
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:61
void load_game_config_with_loadscreen(FORCE_RELOAD_CONFIG force_reload, game_classification const *classification=nullptr, std::optional< std::set< std::string >> active_addons={})
bool init_game_config(FORCE_RELOAD_CONFIG force_reload)
std::map< std::string, config > addon_cfgs_
std::shared_ptr< terrain_type_data > tdata_
Singleton class to manage game config file caching.