The Battle for Wesnoth  1.19.2+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 
28 {
30 public:
31  /**
32  * RNG mode selection values.
33  *
34  * @note The contents of this enum must match the order of the options
35  * defined in the WML for the "rng_menu" widget of this dialog.
36  */
37  enum RNG_MODE
38  {
42  };
43 
46  , engine_(eng)
47  , choice_(-1)
49  , mod_states_()
50  , page_ids_()
51  , difficulties_()
54  , currently_sorted_asc_(true)
55  , mod_ids_()
56  {
57  }
58 
59  /***** ***** ***** setters / getters for members ***** ****** *****/
60 
61  int get_choice() const
62  {
63  return choice_;
64  }
65 
67  {
68  return rng_mode_;
69  }
70 
71  const std::string& get_difficulty() const
72  {
73  return current_difficulty_;
74  }
75 
76 private:
77  /** Called when another campaign is selected. */
78  void campaign_selected();
79 
80  /** Called when the difficulty selection changes. */
81  void difficulty_selected();
82 
83  virtual const std::string& window_id() const override;
84 
85  virtual void pre_show(window& window) override;
86 
87  virtual void post_show(window& window) override;
88 
89  void sort_campaigns(CAMPAIGN_ORDER order, bool ascending);
90 
91  void add_campaign_to_tree(const config& campaign);
92 
94 
95  void mod_toggled();
96 
97  void filter_text_changed(const std::string& text);
98 
100 
101  /** The chosen campaign. */
102  int choice_;
103 
104  /** whether the player checked the "Deterministic" checkbox. */
106 
107  boost::dynamic_bitset<> mod_states_;
108 
109  std::vector<std::string> page_ids_;
110 
111  std::vector<std::string> difficulties_;
112 
113  std::string current_difficulty_;
114 
116 
118 
119  std::vector<std::string> last_search_words_;
120 
121  inline const static std::string missing_campaign_ = "////missing-campaign////";
122 
123  std::vector<std::string> mod_ids_;
124 };
125 
126 } // namespace dialogs
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:159
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:61