The Battle for Wesnoth  1.17.0-dev
advanced.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2020 - 2021
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 <functional>
21 #include <string>
22 #include <vector>
23 
24 class game_config_view;
25 
26 namespace preferences
27 {
29 {
30 public:
31  explicit advanced_manager(const game_config_view& gc);
32 
34 
35  struct option
36  {
37  option(const config& pref);
38 
39  enum class avd_type { TOGGLE, SLIDER, COMBO, SPECIAL };
40 
41  /** The preference type. */
43 
44  /** Displayed name. */
46 
47  /** Displayed description. */
49 
50  /** The actual field saved in the prefs file and by which this preference may be accessed. */
51  std::string field;
52 
53  /** The full config, including type-specific options. */
55  };
56 
57  const std::vector<option>& get_preferences() const
58  {
59  return prefs;
60  }
61 
62 private:
63  std::vector<option> prefs;
64 };
65 
66 /** Initializes the manager singleton. */
68 
69 using advanced_pref_list = std::vector<advanced_manager::option>;
70 
71 /** Gets a list of the available advanced preferences. */
73 
74 } // namespace preferences
const advanced_pref_list & get_advanced_preferences()
Gets a list of the available advanced preferences.
Definition: advanced.cpp:77
t_string name
Displayed name.
Definition: advanced.hpp:45
std::vector< advanced_manager::option > advanced_pref_list
Definition: advanced.hpp:69
Definitions for the interface to Wesnoth Markup Language (WML).
std::string field
The actual field saved in the prefs file and by which this preference may be accessed.
Definition: advanced.hpp:51
config cfg
The full config, including type-specific options.
Definition: advanced.hpp:54
const std::vector< option > & get_preferences() const
Definition: advanced.hpp:57
avd_type type
The preference type.
Definition: advanced.hpp:42
Modify, read and display user preferences.
std::vector< option > prefs
Definition: advanced.hpp:63
advanced_manager(const game_config_view &gc)
Definition: advanced.cpp:30
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:61
void init_advanced_manager(const game_config_view &gc)
Initializes the manager singleton.
Definition: advanced.cpp:72
t_string description
Displayed description.
Definition: advanced.hpp:48