The Battle for Wesnoth  1.19.8+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 
22 
23 #include <boost/dynamic_bitset.hpp>
24 
25 namespace gui2::dialogs
26 {
27 
29 {
31 public:
32  /**
33  * RNG mode selection values.
34  *
35  * @note The contents of this enum must match the order of the options
36  * defined in the WML for the "rng_menu" widget of this dialog.
37  */
38  enum RNG_MODE
39  {
43  };
44 
45  //return value for opening addon manager
46  const static int OPEN_ADDON_MANAGER = 3;
47 
49 
50  /***** ***** ***** setters / getters for members ***** ****** *****/
51 
52  int get_choice() const
53  {
54  return choice_;
55  }
56 
58  {
59  return rng_mode_;
60  }
61 
62  const std::string& get_difficulty() const
63  {
64  return current_difficulty_;
65  }
66 
67 private:
68  /** Called when another campaign is selected. */
69  void campaign_selected();
70 
71  /** Called when the difficulty selection changes. */
72  void difficulty_selected();
73 
74  virtual const std::string& window_id() const override;
75 
76  virtual void pre_show() override;
77 
78  void proceed();
79 
80  void sort_campaigns(CAMPAIGN_ORDER order, bool ascending);
81 
82  void add_campaign_to_tree(const config& campaign);
83 
85 
86  void mod_toggled();
87 
88  void filter_text_changed(const std::string& text);
89 
91 
92  /** The chosen campaign. */
93  int choice_;
94 
95  /** whether the player checked the "Deterministic" checkbox. */
97 
98  boost::dynamic_bitset<> mod_states_;
99 
100  std::vector<std::string> page_ids_;
101 
102  std::vector<std::string> difficulties_;
103 
104  std::string current_difficulty_;
105 
107 
109 
110  std::vector<std::string> last_search_words_;
111 
112  inline const static std::string missing_campaign_ = "////missing-campaign////";
113  inline const static std::string addons_ = "////addons////";
114 
115  std::vector<std::string> mod_ids_;
116 };
117 
118 } // namespace dialogs
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:158
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.