The Battle for Wesnoth  1.19.0-dev
campaign_selection.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2024
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 
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 
60  , engine_(eng)
61  , choice_(-1)
63  , mod_states_()
64  , page_ids_()
65  , difficulties_()
68  , currently_sorted_asc_(true)
69  , mod_ids_()
70  {
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);
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  inline const static std::string missing_campaign_ = "////missing-campaign////";
136 
137  std::vector<std::string> mod_ids_;
138 };
139 
140 } // namespace dialogs
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:159
This shows the dialog which allows the user to choose which campaign to play.
void toggle_sorting_selection(CAMPAIGN_ORDER order)
RNG_MODE rng_mode_
whether the player checked the "Deterministic" checkbox.
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
void difficulty_selected()
Called when the difficulty selection changes.
std::vector< std::string > mod_ids_
std::vector< std::string > difficulties_
const std::string & get_difficulty() const
RNG_MODE
RNG mode selection values.
static const std::string missing_campaign_
void sort_campaigns(CAMPAIGN_ORDER order, bool ascending)
campaign_selection(ng::create_engine &eng)
virtual const std::string & window_id() const override
The ID of the window to build.
void add_campaign_to_tree(const config &campaign)
void filter_text_changed(const std::string &text)
void campaign_selected()
Called when another campaign is selected.
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
std::vector< std::string > last_search_words_
std::vector< std::string > page_ids_
Abstract base class for all modal dialogs.
base class of top level items, the only item which needs to store the final canvases to draw on.
Definition: window.hpp:63