The Battle for Wesnoth  1.15.12+dev
advanced.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2020 by the Battle for Wesnoth Project https://www.wesnoth.org/
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY.
10 
11  See the COPYING file for more details.
12 */
13 
14 #pragma once
15 
16 #include "config.hpp"
17 #include "tstring.hpp"
18 
19 #include <functional>
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
const advanced_pref_list & get_advanced_preferences()
Gets a list of the available advanced preferences.
Definition: advanced.cpp:76
t_string name
Displayed name.
Definition: advanced.hpp:44
std::vector< advanced_manager::option > advanced_pref_list
Definition: advanced.hpp:68
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:50
config cfg
The full config, including type-specific options.
Definition: advanced.hpp:53
const std::vector< option > & get_preferences() const
Definition: advanced.hpp:56
avd_type type
The preference type.
Definition: advanced.hpp:41
Modify, read and display user preferences.
std::vector< option > prefs
Definition: advanced.hpp:62
advanced_manager(const game_config_view &gc)
Definition: advanced.cpp:29
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:59
void init_advanced_manager(const game_config_view &gc)
Initializes the manager singleton.
Definition: advanced.cpp:71
t_string description
Displayed description.
Definition: advanced.hpp:47