The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
gui2::tpreferences Class Reference

#include <preferences_dialog.hpp>

Inheritance diagram for gui2::tpreferences:
Inheritance graph

Public Types

typedef std::vector< const
hotkey::hotkey_command * > 
t_visible_hotkeys
 

Public Member Functions

 tpreferences (CVideo &video, const config &game_cfg)
 Constructor. More...
 
void set_selected_index (std::pair< int, int > index)
 
- Public Member Functions inherited from gui2::tdialog
 tdialog ()
 
virtual ~tdialog ()
 
bool show (CVideo &video, const unsigned auto_close_time=0)
 Shows the window. More...
 
int get_retval () const
 
void set_always_save_fields (const bool always_save_fields)
 
void set_restore (const bool restore)
 

Static Public Member Functions

static bool display (CVideo &video, const config &game_cfg)
 The display function – see tdialog for more information. More...
 

Private Types

typedef std::pair< std::vector
< std::string >, std::vector
< std::string > > 
combo_data
 

Private Member Functions

virtual const std::stringwindow_id () const
 Inherited from tdialog, implemented by REGISTER_DIALOG. More...
 
void pre_show (twindow &window)
 Inherited from tdialog. More...
 
void post_show (twindow &)
 Actions to be taken after the window has been shown. More...
 
void initialize_members (twindow &window)
 Initializers. More...
 
void initialize_tabs (twindow &window, tlistbox &selector, const int index)
 
void setup_friends_list (twindow &window)
 
void setup_hotkey_list (twindow &window)
 
void add_friend_list_entry (const bool is_friend, ttext_box &textbox, twindow &window)
 
void edit_friend_list_entry (tlistbox &friends, ttext_box &textbox)
 
void remove_friend_list_entry (tlistbox &friends_list, ttext_box &textbox, twindow &window)
 
void add_tab (tlistbox &tab_bar, const std::string &label)
 
void add_pager_row (tlistbox &selector, const std::string &icon, const std::string &label)
 
void set_visible_page (twindow &window, unsigned int page, const std::string &pager_id)
 
void on_page_select (twindow &window)
 Callback for selection changes. More...
 
void on_tab_select (twindow &window)
 
void on_advanced_prefs_list_select (tlistbox &tree, twindow &window)
 
void handle_res_select (twindow &window)
 Special callback functions. More...
 
void fullscreen_toggle_callback (twindow &window)
 
void accl_speed_slider_callback (tslider &slider)
 
void max_autosaves_slider_callback (tslider &slider, tcontrol &status_label)
 
void font_scaling_slider_callback (tslider &slider)
 
void animate_map_toggle_callback (ttoggle_button &toggle, ttoggle_button &toggle_water)
 
void add_hotkey_callback (tlistbox &hotkeys)
 
void remove_hotkey_callback (tlistbox &hotkeys)
 
void default_hotkey_callback (twindow &window)
 
void setup_single_toggle (const std::string &widget_id, const bool start_value, std::function< void(bool)> callback, twidget &find_in, const bool inverted=false)
 Sets the initial state and callback for a simple bool-state toggle button In the callback, the bool value of the widget is passeed to the setter. More...
 
void single_toggle_callback (const ttoggle_button &widget, std::function< void(bool)> setter, const bool inverted)
 
void setup_toggle_slider_pair (const std::string &toggle_widget, const std::string &slider_widget, const bool toggle_start_value, const int slider_state_value, std::function< void(bool)> toggle_callback, std::function< void(int)> slider_callback, twidget &find_in)
 Sets the initial state and callback for a bool-state toggle button/slider pair. More...
 
void toggle_slider_pair_callback (const ttoggle_button &toggle_widget, tslider &slider_widget, std::function< void(bool)> setter)
 
void setup_single_slider (const std::string &widget_id, const int start_value, std::function< void(int)> slider_callback, twidget &find_in)
 Sets the initial state and callback for a standalone slider In the callback, int value of the widget is passeed to the setter. More...
 
void single_slider_callback (const tslider &widget, std::function< void(int)> setter)
 
void setup_combobox (const std::string &widget_id, const combo_data &options, const unsigned start_value, std::function< void(std::string)> callback, twidget &find_in)
 Sets the initial state and callback for a combobox. More...
 
void simple_combobox_callback (const tcombobox &widget, std::function< void(std::string)> setter, std::vector< std::string > &vec)
 
template<typename T >
void setup_radio_toggle (const std::string &toggle_id, const T &enum_value, const int start_value, tgroup< T > &group, std::function< void(int)> callback, twindow &window)
 
template<typename T >
void toggle_radio_callback (tgroup< T > &group, std::function< void(int)> setter)
 
template<typename T >
void bind_status_label (T &parent, const std::string &label_id, twidget &find_in)
 Sets up a label that always displays the value of another widget. More...
 
void bind_status_label (tslider &parent, const std::string &label_id, twidget &find_in, const std::string &suffix="")
 
template<typename T >
void status_label_callback (T &parent_widget, tcontrol &label_widget, const std::string &suffix="")
 

Private Attributes

tgroup< preferences::LOBBY_JOINSlobby_joins_group
 Sets the a radio button group Since (so far) there is only one group of these, the code is speciliazed. More...
 
MAKE_ENUM(ADVANCED_PREF_TYPE,(TOGGLE,"boolean")(SLIDER,"int")(COMBO,"combo")(SPECIAL,"custom"))
std std::vector< config
adv_preferences_cfg_
 
std::vector< std::stringfriend_names_
 
int last_selected_item_
 
std::vector< t_stringaccl_speeds_
 
t_visible_hotkeys visible_hotkeys_
 
int font_scaling_
 
std::pair< int, intindex_
 

Additional Inherited Members

- Protected Member Functions inherited from gui2::tdialog
tfield_boolregister_bool (const std::string &id, const bool mandatory, const std::function< bool()> &callback_load_value=std::function< bool()>(), const std::function< void(const bool)> &callback_save_value=std::function< void(const bool)>(), const std::function< void(twidget &)> &callback_change=std::function< void(twidget &)>())
 Creates a new boolean field. More...
 
tfield_boolregister_bool (const std::string &id, const bool mandatory, bool &linked_variable, const std::function< void(twidget &)> &callback_change=std::function< void(twidget &)>())
 Creates a new boolean field. More...
 
tfield_integerregister_integer (const std::string &id, const bool mandatory, const std::function< int()> &callback_load_value=std::function< int()>(), const std::function< void(const int)> &callback_save_value=std::function< void(const int)>())
 Creates a new integer field. More...
 
tfield_integerregister_integer (const std::string &id, const bool mandatory, int &linked_variable)
 Creates a new integer field. More...
 
tfield_textregister_text (const std::string &id, const bool mandatory, const std::function< std::string()> &callback_load_value=std::function< std::string()>(), const std::function< void(const std::string &)> &callback_save_value=std::function< void(const std::string &)>(), const bool capture_focus=false)
 Creates a new text field. More...
 
tfield_textregister_text (const std::string &id, const bool mandatory, std::string &linked_variable, const bool capture_focus=false)
 Creates a new text field. More...
 
tfield_labelregister_label (const std::string &id, const bool mandatory, const std::string &text, const bool use_markup=false)
 Registers a new control as a label. More...
 
tfield_labelregister_image (const std::string &id, const bool mandatory, const std::string &filename)
 Registers a new control as image. More...
 

Detailed Description

Definition at line 41 of file preferences_dialog.hpp.

Member Typedef Documentation

typedef std::pair<std::vector<std::string>, std::vector<std::string> > gui2::tpreferences::combo_data
private

Definition at line 150 of file preferences_dialog.hpp.

Definition at line 56 of file preferences_dialog.hpp.

Constructor & Destructor Documentation

gui2::tpreferences::tpreferences ( CVideo video,
const config game_cfg 
)

Constructor.

Definition at line 112 of file preferences_dialog.cpp.

Referenced by display().

Member Function Documentation

void gui2::tpreferences::accl_speed_slider_callback ( tslider slider)
private
void gui2::tpreferences::add_friend_list_entry ( const bool  is_friend,
ttext_box textbox,
twindow window 
)
private
void gui2::tpreferences::add_hotkey_callback ( tlistbox hotkeys)
private
void gui2::tpreferences::add_pager_row ( tlistbox selector,
const std::string icon,
const std::string label 
)
private

Definition at line 1069 of file preferences_dialog.cpp.

References gui2::tlistbox::add_row().

void gui2::tpreferences::add_tab ( tlistbox tab_bar,
const std::string label 
)
private

Definition at line 1077 of file preferences_dialog.cpp.

References gui2::tlistbox::add_row().

void gui2::tpreferences::animate_map_toggle_callback ( ttoggle_button toggle,
ttoggle_button toggle_water 
)
private
template<typename T >
void gui2::tpreferences::bind_status_label ( T &  parent,
const std::string label_id,
twidget find_in 
)
private

Sets up a label that always displays the value of another widget.

Definition at line 294 of file preferences_dialog.cpp.

References gui2::disambiguate_widget_value(), and gui2::tcontrol::set_label().

void gui2::tpreferences::bind_status_label ( tslider parent,
const std::string label_id,
twidget find_in,
const std::string suffix = "" 
)
private
void gui2::tpreferences::default_hotkey_callback ( twindow window)
private
static bool gui2::tpreferences::display ( CVideo video,
const config game_cfg 
)
inlinestatic

The display function – see tdialog for more information.

Definition at line 50 of file preferences_dialog.hpp.

References tpreferences().

void gui2::tpreferences::edit_friend_list_entry ( tlistbox friends,
ttext_box textbox 
)
private
void gui2::tpreferences::font_scaling_slider_callback ( tslider slider)
private

Definition at line 1254 of file preferences_dialog.cpp.

References gui2::tslider::get_value().

Referenced by initialize_members().

void gui2::tpreferences::fullscreen_toggle_callback ( twindow window)
private
void gui2::tpreferences::handle_res_select ( twindow window)
private

Special callback functions.

Definition at line 1226 of file preferences_dialog.cpp.

References gui2::tcombobox::get_value(), events::raise_resize_event(), and gui2::set_resolution_list().

Referenced by initialize_members().

void gui2::tpreferences::initialize_members ( twindow window)
private

Initializers.

Sets up states and callbacks for each of the widgets.

Definition at line 434 of file preferences_dialog.cpp.

References preferences::_set_iconize_list(), preferences::_set_lobby_joins(), preferences::_set_sort_list(), accl_speed_slider_callback(), add_friend_list_entry(), add_hotkey_callback(), preferences::animate_map(), animate_map_toggle_callback(), preferences::animate_water(), preferences::autosavemax(), preferences::bell_volume(), bind_void(), preferences::chat_lines(), preferences::chat_timestamping(), config::child_range(), gui2::tcombobox::connect_click_handler(), gui2::event::connect_signal_mouse_left_click(), gui2::event::connect_signal_notify_modified(), default_hotkey_callback(), preferences::delete_saves(), preferences::disable_auto_moves(), gui2::tmp_alerts_options::display(), gui2::tgame_cache_options::display(), edit_friend_list_entry(), preferences::enable_whiteboard_mode_on_start(), gui2::event::find(), preferences::font_scaling(), font_scaling_slider_callback(), gui2::fullscreen(), fullscreen_toggle_callback(), gui2::get_advanced_row_grid(), gui2::get_max_autosaves_status_label(), gui2::tselectable_::get_value_bool(), preferences::grid(), handle_res_select(), gui2::twidget::tvisible::hidden, preferences::hide_whiteboard(), preferences::iconize_list(), preferences::idle_anim(), preferences::idle_anim_rate(), int(), preferences::interrupt_when_ally_sighted(), gui2::twidget::tvisible::invisible, lexical_cast(), preferences::lobby_joins(), gui2::make_dialog_callback(), max_autosaves_slider_callback(), preferences::music_on(), preferences::music_volume(), on_advanced_prefs_list_select(), preferences::remember_password(), remove_friend_list_entry(), remove_hotkey_callback(), preferences::save_replays(), preferences::scroll_speed(), game_config::images::selected, preferences::set(), gui2::tcombobox::set_active(), preferences::set_animate_water(), preferences::set_bell_volume(), preferences::set_chat_lines(), preferences::set_chat_timestamping(), gui2::tlistbox::set_column_order(), gui2::tcontrol::set_definition(), preferences::set_delete_saves(), preferences::set_disable_auto_moves(), preferences::set_enable_whiteboard_mode_on_start(), preferences::set_grid(), preferences::set_hide_whiteboard(), gui2::twidget::set_id(), preferences::set_idle_anim(), preferences::set_idle_anim_rate(), preferences::set_interrupt_when_ally_sighted(), gui2::set_label(), gui2::tslider::set_maximum_value(), gui2::tslider::set_minimum_value(), preferences::set_music(), preferences::set_music_volume(), preferences::set_remember_password(), gui2::set_resolution_list(), preferences::set_save_replays(), preferences::set_scroll_speed(), preferences::set_show_ai_moves(), preferences::set_show_floating_labels(), preferences::set_show_haloes(), preferences::set_show_side_colors(), preferences::set_show_standing_animations(), preferences::set_sound(), preferences::set_sound_volume(), gui2::tscrollbar_::set_step_size(), preferences::set_turbo(), preferences::set_turn_bell(), preferences::set_turn_dialog(), preferences::set_UI_sound(), preferences::set_UI_volume(), gui2::tcontrol::set_use_markup(), gui2::tslider::set_value(), gui2::ttoggle_button::set_value(), gui2::twidget::set_visible(), preferences::set_whisper_friends_only(), preferences::show_ai_moves(), preferences::SHOW_ALL, preferences::show_floating_labels(), preferences::SHOW_FRIENDS, preferences::show_haloes(), preferences::SHOW_NONE, preferences::show_side_colors(), preferences::show_standing_animations(), preferences::show_theme_dialog(), preferences::show_wesnothd_server_search(), preferences::sort_list(), preferences::sound_on(), preferences::sound_volume(), gui2::tgrid::swap_child(), toggle_slider_pair_callback(), preferences::turbo(), preferences::turbo_speed(), game_config::sounds::turn_bell, preferences::turn_dialog(), preferences::UI_sound_on(), preferences::UI_volume(), gui2::twidget::tvisible::visible, and preferences::whisper_friends_only().

void gui2::tpreferences::initialize_tabs ( twindow window,
tlistbox selector,
const int  index 
)
private
void gui2::tpreferences::max_autosaves_slider_callback ( tslider slider,
tcontrol status_label 
)
private
void gui2::tpreferences::on_advanced_prefs_list_select ( tlistbox tree,
twindow window 
)
private
void gui2::tpreferences::on_page_select ( twindow window)
private

Callback for selection changes.

Definition at line 1275 of file preferences_dialog.cpp.

Referenced by pre_show().

void gui2::tpreferences::on_tab_select ( twindow window)
private

Definition at line 1282 of file preferences_dialog.cpp.

Referenced by initialize_tabs().

void gui2::tpreferences::post_show ( twindow window)
privatevirtual

Actions to be taken after the window has been shown.

At this point the registered fields already stored their values (if the OK has been pressed).

Parameters
windowThe window which has been shown.

Reimplemented from gui2::tdialog.

Definition at line 1289 of file preferences_dialog.cpp.

References hotkey::save_hotkeys(), and preferences::set_font_scaling().

void gui2::tpreferences::pre_show ( twindow window)
privatevirtual
void gui2::tpreferences::remove_friend_list_entry ( tlistbox friends_list,
ttext_box textbox,
twindow window 
)
private
void gui2::tpreferences::remove_hotkey_callback ( tlistbox hotkeys)
private
void gui2::tpreferences::set_selected_index ( std::pair< int, int index)
inline

Definition at line 58 of file preferences_dialog.hpp.

References index_.

Referenced by preferences::show_preferences_dialog().

void gui2::tpreferences::set_visible_page ( twindow window,
unsigned int  page,
const std::string pager_id 
)
private

Definition at line 1173 of file preferences_dialog.cpp.

void gui2::tpreferences::setup_combobox ( const std::string widget_id,
const combo_data options,
const unsigned  start_value,
std::function< void(std::string)>  callback,
twidget find_in 
)
private

Sets the initial state and callback for a combobox.

Definition at line 254 of file preferences_dialog.cpp.

References gui2::event::connect_signal_mouse_left_click(), gui2::tcontrol::set_use_markup(), gui2::tcombobox::set_values(), and simple_combobox_callback().

void gui2::tpreferences::setup_friends_list ( twindow window)
private
void gui2::tpreferences::setup_hotkey_list ( twindow window)
private
template<typename T >
void gui2::tpreferences::setup_radio_toggle ( const std::string toggle_id,
const T &  enum_value,
const int  start_value,
tgroup< T > &  group,
std::function< void(int)>  callback,
twindow window 
)
private
void gui2::tpreferences::setup_single_slider ( const std::string widget_id,
const int  start_value,
std::function< void(int)>  slider_callback,
twidget find_in 
)
private

Sets the initial state and callback for a standalone slider In the callback, int value of the widget is passeed to the setter.

Definition at line 239 of file preferences_dialog.cpp.

References gui2::event::connect_signal_notify_modified(), gui2::tslider::set_value(), and single_slider_callback().

void gui2::tpreferences::setup_single_toggle ( const std::string widget_id,
const bool  start_value,
std::function< void(bool)>  callback,
twidget find_in,
const bool  inverted = false 
)
private

Sets the initial state and callback for a simple bool-state toggle button In the callback, the bool value of the widget is passeed to the setter.

Definition at line 193 of file preferences_dialog.cpp.

References gui2::event::connect_signal_mouse_left_click(), gui2::ttoggle_button::set_value(), and single_toggle_callback().

void gui2::tpreferences::setup_toggle_slider_pair ( const std::string toggle_widget,
const std::string slider_widget,
const bool  toggle_start_value,
const int  slider_state_value,
std::function< void(bool)>  toggle_callback,
std::function< void(int)>  slider_callback,
twidget find_in 
)
private

Sets the initial state and callback for a bool-state toggle button/slider pair.

In the callback, the slider is set to active/inactive based on the button's value, which is also passed to the setter.

Definition at line 210 of file preferences_dialog.cpp.

References gui2::event::connect_signal_mouse_left_click(), gui2::event::connect_signal_notify_modified(), gui2::ttoggle_button::set_value(), single_slider_callback(), and toggle_slider_pair_callback().

void gui2::tpreferences::simple_combobox_callback ( const tcombobox widget,
std::function< void(std::string)>  setter,
std::vector< std::string > &  vec 
)
private

Definition at line 1200 of file preferences_dialog.cpp.

References gui2::tcombobox::get_value().

Referenced by setup_combobox().

void gui2::tpreferences::single_slider_callback ( const tslider widget,
std::function< void(int)>  setter 
)
private

Definition at line 1194 of file preferences_dialog.cpp.

References gui2::tslider::get_value().

Referenced by setup_single_slider(), and setup_toggle_slider_pair().

void gui2::tpreferences::single_toggle_callback ( const ttoggle_button widget,
std::function< void(bool)>  setter,
const bool  inverted 
)
private

Definition at line 1178 of file preferences_dialog.cpp.

References gui2::tselectable_::get_value_bool().

Referenced by setup_single_toggle().

template<typename T >
void gui2::tpreferences::status_label_callback ( T &  parent_widget,
tcontrol label_widget,
const std::string suffix = "" 
)
private
template<typename T >
void gui2::tpreferences::toggle_radio_callback ( tgroup< T > &  group,
std::function< void(int)>  setter 
)
private
void gui2::tpreferences::toggle_slider_pair_callback ( const ttoggle_button toggle_widget,
tslider slider_widget,
std::function< void(bool)>  setter 
)
private
virtual const std::string& gui2::tpreferences::window_id ( ) const
privatevirtual

Inherited from tdialog, implemented by REGISTER_DIALOG.

Implements gui2::tdialog.

Member Data Documentation

std::vector<t_string> gui2::tpreferences::accl_speeds_
private

Definition at line 219 of file preferences_dialog.hpp.

MAKE_ENUM (ADVANCED_PREF_TYPE, (TOGGLE, "boolean") (SLIDER, "int") (COMBO, "combo") (SPECIAL, "custom") ) std std::vector<config> gui2::tpreferences::adv_preferences_cfg_
private

Definition at line 206 of file preferences_dialog.hpp.

int gui2::tpreferences::font_scaling_
private

Definition at line 224 of file preferences_dialog.hpp.

std::vector<std::string> gui2::tpreferences::friend_names_
private

Definition at line 215 of file preferences_dialog.hpp.

std::pair<int, int> gui2::tpreferences::index_
private

Definition at line 227 of file preferences_dialog.hpp.

Referenced by set_selected_index().

int gui2::tpreferences::last_selected_item_
private

Definition at line 217 of file preferences_dialog.hpp.

tgroup<preferences::LOBBY_JOINS> gui2::tpreferences::lobby_joins_group
private

Sets the a radio button group Since (so far) there is only one group of these, the code is speciliazed.

If (at a later date) more groups need to be added, this will have to be generalized.

Definition at line 171 of file preferences_dialog.hpp.

t_visible_hotkeys gui2::tpreferences::visible_hotkeys_
private

Definition at line 220 of file preferences_dialog.hpp.


The documentation for this class was generated from the following files: