The Battle for Wesnoth  1.15.13+dev
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
gui2::dialogs::campaign_selection Class Reference

This shows the dialog which allows the user to choose which campaign to play. More...

#include <campaign_selection.hpp>

Inheritance diagram for gui2::dialogs::campaign_selection:

Public Types

enum  RNG_MODE { RNG_DEFAULT, RNG_SAVE_SEED, RNG_BIASED }
 RNG mode selection values. More...
 

Public Member Functions

 campaign_selection (ng::create_engine &eng)
 
int get_choice () const
 
RNG_MODE get_rng_mode () const
 
const std::string & get_difficulty () const
 
- Public Member Functions inherited from gui2::dialogs::modal_dialog
 modal_dialog ()
 
virtual ~modal_dialog ()
 
bool show (const unsigned auto_close_time=0)
 Shows the window. More...
 
windowget_window () const
 Returns a pointer to the dialog's window. More...
 
int get_retval () const
 Returns the cached window exit code. More...
 
void set_retval (int retval)
 Convenience wrapper to set the window's exit code. More...
 
void set_always_save_fields (const bool always_save_fields)
 
void set_restore (const bool restore)
 
void set_allow_plugin_skip (const bool allow_plugin_skip)
 
void set_show_even_without_video (const bool show_even_without_video)
 

Private Types

enum  CAMPAIGN_ORDER { RANK, DATE, NAME }
 

Private Member Functions

void campaign_selected ()
 Called when another campaign is selected. More...
 
void difficulty_selected ()
 Called when the difficulty selection changes. More...
 
virtual const std::string & window_id () const override
 The id of the window to build. More...
 
virtual void pre_show (window &window) override
 Actions to be taken before showing the window. More...
 
virtual void post_show (window &window) override
 Actions to be taken after the window has been shown. More...
 
void sort_campaigns (CAMPAIGN_ORDER order, bool ascending)
 
void add_campaign_to_tree (const config &campaign) const
 
void toggle_sorting_selection (CAMPAIGN_ORDER order)
 
void mod_toggled ()
 
void filter_text_changed (const std::string &text)
 

Private Attributes

ng::create_engineengine_
 
int choice_
 The chosen campaign. More...
 
RNG_MODE rng_mode_
 whether the player checked the "Deterministic" checkbox. More...
 
boost::dynamic_bitset mod_states_
 
std::vector< std::string > page_ids_
 
std::vector< std::string > difficulties_
 
std::string current_difficulty_
 
CAMPAIGN_ORDER current_sorting_
 
bool currently_sorted_asc_
 
std::vector< std::string > last_search_words_
 

Additional Inherited Members

- Protected Member Functions inherited from gui2::dialogs::modal_dialog
field_boolregister_bool (const std::string &id, const bool mandatory, const std::function< bool()> callback_load_value=nullptr, const std::function< void(bool)> callback_save_value=nullptr, const std::function< void(widget &)> callback_change=nullptr, const bool initial_fire=false)
 Creates a new boolean field. More...
 
field_boolregister_bool (const std::string &id, const bool mandatory, bool &linked_variable, const std::function< void(widget &)> callback_change=nullptr, const bool initial_fire=false)
 Creates a new boolean field. More...
 
field_integerregister_integer (const std::string &id, const bool mandatory, const std::function< int()> callback_load_value=nullptr, const std::function< void(int)> callback_save_value=nullptr)
 Creates a new integer field. More...
 
field_integerregister_integer (const std::string &id, const bool mandatory, int &linked_variable)
 Creates a new integer field. More...
 
field_textregister_text (const std::string &id, const bool mandatory, const std::function< std::string()> callback_load_value=nullptr, const std::function< void(const std::string &)> callback_save_value=nullptr, const bool capture_focus=false)
 Creates a new text field. More...
 
field_textregister_text (const std::string &id, const bool mandatory, std::string &linked_variable, const bool capture_focus=false)
 Creates a new text field. More...
 
field_labelregister_label (const std::string &id, const bool mandatory, const std::string &text, const bool use_markup=false)
 Registers a new styled_widget as a label. More...
 
field_labelregister_image (const std::string &id, const bool mandatory, const std::string &filename)
 Registers a new styled_widget as image. More...
 
- Protected Attributes inherited from gui2::dialogs::modal_dialog
std::unique_ptr< windowwindow_
 The window object build for this dialog. More...
 

Detailed Description

This shows the dialog which allows the user to choose which campaign to play.

Key Type MandatoryDescription
campaign_list listbox yes A listbox that contains all available campaigns.
icon image no The icon for the campaign.
name control no The name of the campaign.
victory image no The icon to show when the user finished the campaign. The engine determines whether or not the user has finished the campaign and sets the visible flag for the widget accordingly.
campaign_details multi_page yes A multi page widget that shows more details for the selected campaign.
image image no The image for the campaign.
description control no The description of the campaign.

Definition at line 41 of file campaign_selection.hpp.

Member Enumeration Documentation

◆ CAMPAIGN_ORDER

Enumerator
RANK 
DATE 
NAME 

Definition at line 43 of file campaign_selection.hpp.

◆ RNG_MODE

RNG mode selection values.

Note
The contents of this enum must match the order of the options defined in the WML for the "rng_menu" widget of this dialog.
Enumerator
RNG_DEFAULT 
RNG_SAVE_SEED 
RNG_BIASED 

Definition at line 51 of file campaign_selection.hpp.

Constructor & Destructor Documentation

◆ campaign_selection()

gui2::dialogs::campaign_selection::campaign_selection ( ng::create_engine eng)
inlineexplicit

Definition at line 58 of file campaign_selection.hpp.

References gui2::dialogs::modal_dialog::set_restore().

Member Function Documentation

◆ add_campaign_to_tree()

void gui2::dialogs::campaign_selection::add_campaign_to_tree ( const config campaign) const
private

◆ campaign_selected()

void gui2::dialogs::campaign_selection::campaign_selected ( )
private

◆ difficulty_selected()

void gui2::dialogs::campaign_selection::difficulty_selected ( )
private

Called when the difficulty selection changes.

Definition at line 141 of file campaign_selection.cpp.

References current_difficulty_, difficulties_, and gui2::dialogs::modal_dialog::get_window().

Referenced by get_difficulty(), and pre_show().

◆ filter_text_changed()

void gui2::dialogs::campaign_selection::filter_text_changed ( const std::string &  text)
private

◆ get_choice()

int gui2::dialogs::campaign_selection::get_choice ( ) const
inline

Definition at line 74 of file campaign_selection.hpp.

References choice_.

◆ get_difficulty()

const std::string& gui2::dialogs::campaign_selection::get_difficulty ( ) const
inline

◆ get_rng_mode()

RNG_MODE gui2::dialogs::campaign_selection::get_rng_mode ( ) const
inline

Definition at line 79 of file campaign_selection.hpp.

References rng_mode_.

Referenced by sp::select_campaign().

◆ mod_toggled()

void gui2::dialogs::campaign_selection::mod_toggled ( )
private

◆ post_show()

void gui2::dialogs::campaign_selection::post_show ( window window)
overrideprivatevirtual

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::dialogs::modal_dialog.

Definition at line 425 of file campaign_selection.cpp.

References ng::create_engine::active_mods(), choice_, gui2::tree_view::empty(), engine_, gui2::widget::id(), page_ids_, RNG_BIASED, RNG_DEFAULT, rng_mode_, gui2::tree_view::selected_item(), and preferences::set_modifications().

Referenced by get_difficulty().

◆ pre_show()

void gui2::dialogs::campaign_selection::pre_show ( window window)
overrideprivatevirtual

◆ sort_campaigns()

void gui2::dialogs::campaign_selection::sort_campaigns ( campaign_selection::CAMPAIGN_ORDER  order,
bool  ascending 
)
private

◆ toggle_sorting_selection()

void gui2::dialogs::campaign_selection::toggle_sorting_selection ( CAMPAIGN_ORDER  order)
private

◆ window_id()

virtual const std::string& gui2::dialogs::campaign_selection::window_id ( ) const
overrideprivatevirtual

The id of the window to build.

Implements gui2::dialogs::modal_dialog.

Referenced by get_difficulty().

Member Data Documentation

◆ choice_

int gui2::dialogs::campaign_selection::choice_
private

The chosen campaign.

Definition at line 115 of file campaign_selection.hpp.

Referenced by get_choice(), and post_show().

◆ current_difficulty_

std::string gui2::dialogs::campaign_selection::current_difficulty_
private

Definition at line 126 of file campaign_selection.hpp.

Referenced by difficulty_selected(), and get_difficulty().

◆ current_sorting_

CAMPAIGN_ORDER gui2::dialogs::campaign_selection::current_sorting_
private

Definition at line 128 of file campaign_selection.hpp.

Referenced by filter_text_changed(), and toggle_sorting_selection().

◆ currently_sorted_asc_

bool gui2::dialogs::campaign_selection::currently_sorted_asc_
private

Definition at line 130 of file campaign_selection.hpp.

Referenced by filter_text_changed(), and toggle_sorting_selection().

◆ difficulties_

std::vector<std::string> gui2::dialogs::campaign_selection::difficulties_
private

Definition at line 124 of file campaign_selection.hpp.

Referenced by difficulty_selected().

◆ engine_

ng::create_engine& gui2::dialogs::campaign_selection::engine_
private

Definition at line 112 of file campaign_selection.hpp.

Referenced by mod_toggled(), post_show(), pre_show(), and sort_campaigns().

◆ last_search_words_

std::vector<std::string> gui2::dialogs::campaign_selection::last_search_words_
private

Definition at line 132 of file campaign_selection.hpp.

Referenced by filter_text_changed(), and sort_campaigns().

◆ mod_states_

boost::dynamic_bitset gui2::dialogs::campaign_selection::mod_states_
private

Definition at line 120 of file campaign_selection.hpp.

Referenced by mod_toggled(), and pre_show().

◆ page_ids_

std::vector<std::string> gui2::dialogs::campaign_selection::page_ids_
private

Definition at line 122 of file campaign_selection.hpp.

Referenced by post_show(), and pre_show().

◆ rng_mode_

RNG_MODE gui2::dialogs::campaign_selection::rng_mode_
private

whether the player checked the "Deterministic" checkbox.

Definition at line 118 of file campaign_selection.hpp.

Referenced by get_rng_mode(), and post_show().


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