The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
campaign_selection.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2009 - 2025
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
23
24#include <boost/dynamic_bitset.hpp>
25
26namespace gui2::dialogs
27{
28
30{
32public:
33 /**
34 * RNG mode selection values.
35 *
36 * @note The contents of this enum must match the order of the options
37 * defined in the WML for the "rng_menu" widget of this dialog.
38 */
45
46 //return value for opening addon manager
47 const static int OPEN_ADDON_MANAGER = 3;
48
50
51 /***** ***** ***** setters / getters for members ***** ****** *****/
52
53 int get_choice() const
54 {
55 return choice_;
56 }
57
59 {
60 return rng_mode_;
61 }
62
63 const std::string& get_difficulty() const
64 {
66 }
67
68 /** Fills the given difficulty menu with options from the given campaign. Returns false if the campaign has no difficulties. */
69 static bool set_difficulty_list(menu_button& diff_menu, const config& campaign, const std::string& selected = "");
70
71 /** Selects the given RNG menu's option for the given random_mode. */
72 static void select_rng_option(menu_button& rng_menu, const std::string& random_mode);
73
74 /** Returns the random_mode for the given RNG menu's selected option. */
75 static std::string get_selected_rng_option(const menu_button& rng_menu);
76
77private:
78 /** Called when an item in the left-hand pane (the tree view) is selected. */
79 void campaign_selected();
80
81 /** Called when the difficulty selection changes. */
83
84 virtual const std::string& window_id() const override;
85
86 virtual void pre_show() override;
87 virtual void post_show() 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. */
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
112
114
116
117 std::vector<std::string> last_search_words_;
118
119 std::vector<std::string> mod_ids_;
120};
121
122} // namespace dialogs
A config object defines a single node in a WML file, with access to child nodes.
Definition config.hpp:157
void toggle_sorting_selection(CAMPAIGN_ORDER order)
RNG_MODE rng_mode_
whether the player checked the "Deterministic" checkbox.
const std::string & get_difficulty() const
void difficulty_selected()
Called when the difficulty selection changes.
static std::string get_selected_rng_option(const menu_button &rng_menu)
Returns the random_mode for the given RNG menu's selected option.
static void select_rng_option(menu_button &rng_menu, const std::string &random_mode)
Selects the given RNG menu's option for the given random_mode.
std::vector< std::string > mod_ids_
virtual void pre_show() override
Actions to be taken before showing the window.
void sort_campaigns(CAMPAIGN_ORDER order, bool ascending)
static bool set_difficulty_list(menu_button &diff_menu, const config &campaign, const std::string &selected="")
Fills the given difficulty menu with options from the given campaign.
virtual void post_show() override
Actions to be taken after the window has been shown.
void add_campaign_to_tree(const config &campaign)
void filter_text_changed(const std::string &text)
virtual const std::string & window_id() const override
The ID of the window to build.
void campaign_selected()
Called when an item in the left-hand pane (the tree view) is selected.
std::vector< std::string > last_search_words_
std::vector< std::string > page_ids_
Abstract base class for all modal dialogs.