-
-
Notifications
You must be signed in to change notification settings - Fork 989
/
mp_options_helper.hpp
91 lines (66 loc) · 2.42 KB
/
mp_options_helper.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
Copyright (C) 2008 - 2016 by the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#ifndef GUI_DIALOGS_MP_OPTIONS_HELPER_HPP_INCLUDED
#define GUI_DIALOGS_MP_OPTIONS_HELPER_HPP_INCLUDED
#include "game_initialization/create_engine.hpp"
#include "gui/widgets/generator.hpp"
class config;
namespace gui2
{
class tcontrol;
class tmenu_button;
class ttoggle_button;
class ttree_view;
class ttree_view_node;
class twindow;
class tmp_options_helper
{
public:
tmp_options_helper(twindow& window, ng::create_engine& create_engine);
void update_options_list();
const config get_options_config();
private:
struct option_source {
std::string level_type;
std::string id;
friend bool operator<(const option_source& a, const option_source& b) {
return a.level_type < b.level_type && a.id < b.id;
}
};
using data_map = std::map<std::string, string_map>;
template <typename T>
std::pair<T*, config::attribute_value> add_node_and_get_widget(
ttree_view_node& option_node, const std::string& id, data_map& data, const config& cfg);
void display_custom_options(std::string&& type, const config& data);
template<typename T>
void update_options_data_map(T* widget, const option_source& source);
void update_options_data_map(ttoggle_button* widget, const option_source& source);
// NOTE: this cannot be an overload of update_options_data_map since that's a templated function
void update_options_data_map_menu_button(tmenu_button* widget, const option_source& source, const config& cfg);
void reset_options_data(const option_source& source, bool& handled, bool& halt);
ttree_view& options_tree_;
tcontrol& no_options_notice_;
using option_map = std::map<std::string, config::attribute_value>;
std::vector<option_source> visible_options_;
std::map<option_source, option_map> options_data_;
ng::create_engine& create_engine_;
public:
const std::vector<option_source>& get_visible_options() const
{
return visible_options_;
}
std::map<option_source, option_map>& get_options_data()
{
return options_data_;
}
};
} // namespace gui2
#endif