The Battle for Wesnoth  1.19.5+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 
44  //return value for opening addon manager
45  const static int OPEN_ADDON_MANAGER = 3;
46 
49  , engine_(eng)
50  , choice_(-1)
52  , mod_states_()
53  , page_ids_()
54  , difficulties_()
57  , currently_sorted_asc_(true)
58  , mod_ids_()
59  {
60  }
61 
62  /***** ***** ***** setters / getters for members ***** ****** *****/
63 
64  int get_choice() const
65  {
66  return choice_;
67  }
68 
70  {
71  return rng_mode_;
72  }
73 
74  const std::string& get_difficulty() const
75  {
76  return current_difficulty_;
77  }
78 
79 private:
80  /** Called when another campaign is selected. */
81  void campaign_selected();
82 
83  /** Called when the difficulty selection changes. */
84  void difficulty_selected();
85 
86  virtual const std::string& window_id() const override;
87 
88  virtual void pre_show() override;
89 
90  void proceed();
91 
92  void sort_campaigns(CAMPAIGN_ORDER order, bool ascending);
93 
94  void add_campaign_to_tree(const config& campaign);
95 
97 
98  void mod_toggled();
99 
100  void filter_text_changed(const std::string& text);
101 
103 
104  /** The chosen campaign. */
105  int choice_;
106 
107  /** whether the player checked the "Deterministic" checkbox. */
109 
110  boost::dynamic_bitset<> mod_states_;
111 
112  std::vector<std::string> page_ids_;
113 
114  std::vector<std::string> difficulties_;
115 
116  std::string current_difficulty_;
117 
119 
121 
122  std::vector<std::string> last_search_words_;
123 
124  inline const static std::string missing_campaign_ = "////missing-campaign////";
125  inline const static std::string addons_ = "////addons////";
126 
127  std::vector<std::string> mod_ids_;
128 };
129 
130 } // namespace dialogs
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:172
void toggle_sorting_selection(CAMPAIGN_ORDER order)
RNG_MODE rng_mode_
whether the player checked the "Deterministic" checkbox.
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_
virtual void pre_show() override
Actions to be taken before showing the window.
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.
std::vector< std::string > last_search_words_
std::vector< std::string > page_ids_
Abstract base class for all modal dialogs.