The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
preferences_dialog.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 - 2025
3 by Charles Dang <exodia339gmail.com>
4 Copyright (C) 2011, 2015 by Iris Morelle <shadowm2006@gmail.com>
5 Part of the Battle for Wesnoth Project https://www.wesnoth.org/
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY.
13
14 See the COPYING file for more details.
15*/
16#pragma once
17
19#include "gui/widgets/group.hpp"
22#include "theme.hpp"
23
24// This file is not named preferences.hpp in order -I conflicts with src/preferences.hpp.
25
26namespace {
27 /**
28 * Map containing page mappings that can be used to set the initially displayed page
29 * of the dialog. The pair is in an 0-indexed toplevel stack/substack format, where
30 * the first is the list of main Preference categories (such as General and Display)
31 * and the second is any sub-stack found on that page.
32 *
33 * TODO: this isn't the most optimal solution, since if the order or number of pages
34 * in either stack changes, this map needs to be updated. Optimally the stacked_widget
35 * widget would allow specifying page by string id, but that would require changes to
36 * generator. It's something to look into, however.
37 */
38 static std::map<pref_constants::PREFERENCE_VIEW, std::pair<int,int>> pef_view_map {
41 };
42}
43
44namespace gui2
45{
46
47class listbox;
48class menu_button;
49class text_box;
50
51namespace dialogs
52{
53
55{
56public:
57 /**
58 * @param initial_view Which page/tab to show initially.
59 * @param allow_gui2_theme_change Whether the GUI2 theme selector should be interactive.
60 * Switching the GUI2 theme only takes effect for windows
61 * built after the switch, so it's only useful (and only
62 * enabled) when Preferences is opened from the title screen,
63 * which rebuilds itself afterwards. Elsewhere the control is
64 * shown but greyed out.
65 */
67 bool allow_gui2_theme_change = false);
68
69 /** The display function -- see @ref modal_dialog for more information. */
71
72private:
73 virtual const std::string& window_id() const override;
74
75 virtual void pre_show() override;
76 virtual void post_show() override;
77
78 /** Initializers */
80 void set_resolution_list(menu_button& res_list);
84
85 template<typename ToggleGet, typename ToggleSet, typename VolumeGet, typename VolumeSet>
87 const std::string& id_suffix,
88 ToggleGet&& toggle_getter,
89 ToggleSet&& toggle_setter,
90 VolumeGet&& volume_getter,
91 VolumeSet&& volume_setter);
92
93 void apply_pixel_scale();
94
96
97 void add_friend_list_entry(const bool is_friend, text_box& textbox);
98 void remove_friend_list_entry(listbox& friends_list, text_box& textbox);
99
100 void on_friends_list_select(listbox& list, text_box& textbox);
102
103 /** Callback for selection changes */
104 void on_advanced_prefs_list_select(listbox& tree, const bool initial = false);
105
106 /** Special callback functions */
107 void handle_res_select();
108 void handle_theme_select();
113 void add_hotkey_callback(listbox& hotkeys);
114 void remove_hotkey_callback(listbox& hotkeys);
117
119
120 std::vector<point> resolutions_;
121 std::vector<theme_info> themes_;
122 std::vector<std::string> gui2_themes_;
123
128
129 std::vector<double> accl_speeds_;
130
131 std::vector<const hotkey::hotkey_command*> visible_hotkeys_;
132
133 std::set<hotkey::HOTKEY_CATEGORY> visible_categories_;
134
135 // The page/tab index pairs for setting visible pages
136 const std::pair<int, int>& initial_index_;
137};
138
139} // namespace dialogs
140} // namespace gui2
Abstract base class for all modal dialogs.
void set_theme_list(menu_button &theme_list)
void on_advanced_prefs_list_select(listbox &tree, const bool initial=false)
Callback for selection changes.
void remove_hotkey_callback(listbox &hotkeys)
const std::pair< int, int > & initial_index_
void set_resolution_list(menu_button &res_list)
void initialize_sound_option_group(const std::string &id_suffix, ToggleGet &&toggle_getter, ToggleSet &&toggle_setter, VolumeGet &&volume_getter, VolumeSet &&volume_setter)
void on_friends_list_select(listbox &list, text_box &textbox)
void add_friend_list_entry(const bool is_friend, text_box &textbox)
std::vector< const hotkey::hotkey_command * > visible_hotkeys_
widget_data get_friends_list_row_data(const preferences::acquaintance &entry)
virtual void post_show() override
Actions to be taken after the window has been shown.
std::set< hotkey::HOTKEY_CATEGORY > visible_categories_
void handle_res_select()
Special callback functions.
std::vector< std::string > gui2_themes_
virtual void pre_show() override
Actions to be taken before showing the window.
void remove_friend_list_entry(listbox &friends_list, text_box &textbox)
group< pref_constants::lobby_joins > lobby_joins_group
void set_gui2_theme_list(menu_button &theme_list)
virtual const std::string & window_id() const override
The display function – see modal_dialog for more information.
The listbox class.
Definition listbox.hpp:41
A widget that allows the user to input text in single line.
Definition text_box.hpp:125
#define DEFINE_SIMPLE_DISPLAY_WRAPPER(dialog)
Adds a bare-bones static display function to a dialog class that immediately invokes the dialogs's mo...
Various uncategorised dialogs.
Generic file dialog.
std::map< std::string, widget_item > widget_data
Definition widget.hpp:36
Definitions related to theme-support.