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