The Battle for Wesnoth  1.19.18+dev
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 
26 namespace {
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 
44 namespace gui2
45 {
46 
47 class listbox;
48 class menu_button;
49 class text_box;
50 
51 namespace dialogs
52 {
53 
55 {
56 public:
58 
59  /** The display function -- see @ref modal_dialog for more information. */
61 
62 private:
63  virtual const std::string& window_id() const override;
64 
65  virtual void pre_show() override;
66  virtual void post_show() override;
67 
68  /** Initializers */
69  void initialize_callbacks();
70  void set_resolution_list(menu_button& res_list);
74 
75  template<bool(*toggle_getter)(), bool(*toggle_setter)(bool), int(*vol_getter)(), void(*vol_setter)(int)>
76  void initialize_sound_option_group(const std::string& id_suffix);
77 
78  void apply_pixel_scale();
79 
81 
82  void add_friend_list_entry(const bool is_friend, text_box& textbox);
83  void remove_friend_list_entry(listbox& friends_list, text_box& textbox);
84 
85  void on_friends_list_select(listbox& list, text_box& textbox);
87 
88  /** Callback for selection changes */
90 
91  /** Special callback functions */
92  void handle_res_select();
93  void handle_theme_select();
96  void add_hotkey_callback(listbox& hotkeys);
97  void remove_hotkey_callback(listbox& hotkeys);
100 
102 
103  std::vector<point> resolutions_;
104  std::vector<theme_info> themes_;
105  std::vector<std::string> gui2_themes_;
106 
110 
111  std::vector<double> accl_speeds_;
112 
113  std::vector<const hotkey::hotkey_command*> visible_hotkeys_;
114 
115  std::set<hotkey::HOTKEY_CATEGORY> visible_categories_;
116 
117  // The page/tab index pairs for setting visible pages
118  const std::pair<int, int>& initial_index_;
119 };
120 
121 } // namespace dialogs
122 } // namespace gui2
Abstract base class for all modal dialogs.
void set_theme_list(menu_button &theme_list)
void remove_hotkey_callback(listbox &hotkeys)
const std::pair< int, int > & initial_index_
void set_resolution_list(menu_button &res_list)
void on_advanced_prefs_list_select(listbox &tree)
Callback for selection changes.
preferences_dialog(const pref_constants::PREFERENCE_VIEW initial_view=pref_constants::VIEW_DEFAULT)
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_
virtual const std::string & window_id() const override
The display function – see modal_dialog for more information.
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 update_friends_list_controls(listbox &list)
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)
void initialize_sound_option_group(const std::string &id_suffix)
void add_hotkey_callback(listbox &hotkeys)
group< pref_constants::lobby_joins > lobby_joins_group
void set_gui2_theme_list(menu_button &theme_list)
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.