The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
mp_options_helper.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2008 - 2025
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
19
20
21namespace gui2
22{
23
24class styled_widget;
25class menu_button;
26class toggle_button;
27class tree_view;
28class tree_view_node;
29class window;
30
31namespace dialogs
32{
33
35{
36public:
38
39 void update_all_options();
40
42 void update_era_options();
43 void update_mod_options();
44
46
47 void set_options(const config& new_options);
48
49private:
51 {
52 std::string level_type;
53 std::string id;
54
55 friend bool operator<(const option_source& a, const option_source& b)
56 {
57 return std::tie(a.level_type, a.id) < std::tie(b.level_type, b.id);
58 }
59 };
60
61 int remove_nodes_for_type(const std::string& type);
62
64
65 template <typename T>
66 std::pair<T*, config::attribute_value> add_node_and_get_widget(
67 tree_view_node& option_node, const std::string& id, data_map& data, const config& cfg);
68
69 void display_custom_options(const std::string& type, int node_position, const config& data);
70
71 template<typename T>
72 void update_options_data_map(T* widget, const option_source& source);
74
75 // NOTE: this cannot be an overload of update_options_data_map since that's a templated function
77
78 void reset_options_data(const option_source& source, bool& handled, bool& halt);
79
81
83
86
87 using node_vector = std::vector<tree_view_node*>;
88
90 {
92
95
97 return (*this).position < data.position;
98 }
99 };
100
101 std::map<std::string, type_node_data> node_data_map_;
102
103 std::vector<option_source> visible_options_;
104 std::map<std::string, config> options_data_;
105};
106
107} // namespace dialogs
108} // namespace gui2
A config object defines a single node in a WML file, with access to child nodes.
Definition config.hpp:157
std::map< std::string, config > options_data_
void reset_options_data(const option_source &source, bool &handled, bool &halt)
void set_options(const config &new_options)
void update_options_data_map(toggle_button *widget, const option_source &source)
void update_options_data_map_menu_button(menu_button *widget, const option_source &source, const config &cfg)
void display_custom_options(const std::string &type, int node_position, const config &data)
std::map< std::string, type_node_data > node_data_map_
std::vector< tree_view_node * > node_vector
std::pair< T *, config::attribute_value > add_node_and_get_widget(tree_view_node &option_node, const std::string &id, data_map &data, const config &cfg)
std::vector< option_source > visible_options_
int remove_nodes_for_type(const std::string &type)
void update_options_data_map(T *widget, const option_source &source)
Base class for all widgets.
Definition widget.hpp:55
base class of top level items, the only item which needs to store the final canvases to draw on.
Definition window.hpp:59
const config * cfg
Various uncategorised dialogs.
Generic file dialog.
std::map< std::string, widget_item > widget_data
Definition widget.hpp:36
std::string_view data
Definition picture.cpp:188
friend bool operator<(const option_source &a, const option_source &b)
#define b