The Battle for Wesnoth  1.19.0+dev
advanced.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2020 - 2024
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #pragma once
16 
17 #include "config.hpp"
18 #include "tstring.hpp"
19 
20 #include <string>
21 #include <vector>
22 
23 class game_config_view;
24 
25 namespace preferences
26 {
28 {
29 public:
30  explicit advanced_manager(const game_config_view& gc);
31 
33 
34  struct option
35  {
36  option(const config& pref);
37 
38  enum class avd_type { TOGGLE, SLIDER, COMBO, SPECIAL };
39 
40  /** The preference type. */
42 
43  /** Displayed name. */
45 
46  /** Displayed description. */
48 
49  /** The actual field saved in the prefs file and by which this preference may be accessed. */
50  std::string field;
51 
52  /** The full config, including type-specific options. */
54  };
55 
56  const std::vector<option>& get_preferences() const
57  {
58  return prefs;
59  }
60 
61 private:
62  std::vector<option> prefs;
63 };
64 
65 /** Initializes the manager singleton. */
67 
68 using advanced_pref_list = std::vector<advanced_manager::option>;
69 
70 /** Gets a list of the available advanced preferences. */
72 
73 } // namespace preferences
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:159
A class grating read only view to a vector of config objects, viewed as one config with all children ...
const std::vector< option > & get_preferences() const
Definition: advanced.hpp:56
advanced_manager(const game_config_view &gc)
Definition: advanced.cpp:31
std::vector< option > prefs
Definition: advanced.hpp:62
Modify, read and display user preferences.
std::vector< advanced_manager::option > advanced_pref_list
Definition: advanced.hpp:68
void init_advanced_manager(const game_config_view &gc)
Initializes the manager singleton.
Definition: advanced.cpp:82
const advanced_pref_list & get_advanced_preferences()
Gets a list of the available advanced preferences.
Definition: advanced.cpp:87
config cfg
The full config, including type-specific options.
Definition: advanced.hpp:53
avd_type type
The preference type.
Definition: advanced.hpp:41
std::string field
The actual field saved in the prefs file and by which this preference may be accessed.
Definition: advanced.hpp:50
t_string description
Displayed description.
Definition: advanced.hpp:47
t_string name
Displayed name.
Definition: advanced.hpp:44