The Battle for Wesnoth  1.17.0-dev
campaign_selection.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2021
3  by Mark de Wever <koraq@xs4all.nl>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
20 
22 
23 #include <boost/dynamic_bitset.hpp>
24 
25 namespace gui2::dialogs
26 {
27 
28 /**
29  * @ingroup GUIWindowDefinitionWML
30  *
31  * This shows the dialog which allows the user to choose which campaign to play.
32  * Key |Type |Mandatory|Description
33  * ------------------|-----------------|---------|-----------
34  * campaign_list | @ref listbox |yes |A listbox that contains all available campaigns.
35  * icon | @ref image |no |The icon for the campaign.
36  * name | control |no |The name of the campaign.
37  * victory | @ref 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.
38  * campaign_details | @ref multi_page |yes |A multi page widget that shows more details for the selected campaign.
39  * image | @ref image |no |The image for the campaign.
40  * description | control |no |The description of the campaign.
41  */
43 {
45 public:
46  /**
47  * RNG mode selection values.
48  *
49  * @note The contents of this enum must match the order of the options
50  * defined in the WML for the "rng_menu" widget of this dialog.
51  */
52  enum RNG_MODE
53  {
57  };
58 
60  : engine_(eng)
61  , choice_(-1)
63  , mod_states_()
64  , page_ids_()
65  , difficulties_()
68  , currently_sorted_asc_(true)
69  {
70  set_restore(true);
71  }
72 
73  /***** ***** ***** setters / getters for members ***** ****** *****/
74 
75  int get_choice() const
76  {
77  return choice_;
78  }
79 
81  {
82  return rng_mode_;
83  }
84 
85  const std::string& get_difficulty() const
86  {
87  return current_difficulty_;
88  }
89 
90 private:
91  /** Called when another campaign is selected. */
92  void campaign_selected();
93 
94  /** Called when the difficulty selection changes. */
95  void difficulty_selected();
96 
97  virtual const std::string& window_id() const override;
98 
99  virtual void pre_show(window& window) override;
100 
101  virtual void post_show(window& window) override;
102 
103  void sort_campaigns(CAMPAIGN_ORDER order, bool ascending);
104 
105  void add_campaign_to_tree(const config& campaign) const;
106 
108 
109  void mod_toggled();
110 
111  void filter_text_changed(const std::string& text);
112 
114 
115  /** The chosen campaign. */
116  int choice_;
117 
118  /** whether the player checked the "Deterministic" checkbox. */
120 
121  boost::dynamic_bitset<> mod_states_;
122 
123  std::vector<std::string> page_ids_;
124 
125  std::vector<std::string> difficulties_;
126 
127  std::string current_difficulty_;
128 
130 
132 
133  std::vector<std::string> last_search_words_;
134 };
135 
136 } // namespace dialogs
virtual const std::string & window_id() const override
The id of the window to build.
void add_campaign_to_tree(const config &campaign) const
This shows the dialog which allows the user to choose which campaign to play.
void campaign_selected()
Called when another campaign is selected.
void filter_text_changed(const std::string &text)
campaign_selection(ng::create_engine &eng)
void difficulty_selected()
Called when the difficulty selection changes.
const std::string & get_difficulty() const
RNG_MODE rng_mode_
whether the player checked the "Deterministic" checkbox.
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
void sort_campaigns(CAMPAIGN_ORDER order, bool ascending)
std::vector< std::string > page_ids_
void toggle_sorting_selection(CAMPAIGN_ORDER order)
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
std::vector< std::string > difficulties_
RNG_MODE
RNG mode selection values.
Abstract base class for all modal dialogs.
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:61
base class of top level items, the only item which needs to store the final canvases to draw on...
Definition: window.hpp:65
void set_restore(const bool restore)
std::vector< std::string > last_search_words_