The Battle for Wesnoth  1.15.1+dev
campaign_selection.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2018 by Mark de Wever <koraq@xs4all.nl>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #pragma once
16 
19 
21 
22 #include <boost/dynamic_bitset.hpp>
23 
24 namespace gui2
25 {
26 namespace dialogs
27 {
28 
30 {
32 public:
34  : engine_(eng)
35  , choice_(-1)
36  , deterministic_(false)
37  , mod_states_()
38  , page_ids_()
40  , currently_sorted_asc_(true)
41  {
42  set_restore(true);
43  }
44 
45  /***** ***** ***** setters / getters for members ***** ****** *****/
46 
47  int get_choice() const
48  {
49  return choice_;
50  }
51 
52  bool get_deterministic() const
53  {
54  return deterministic_;
55  }
56 
57 private:
58  /** Called when another campaign is selected. */
60 
61  /** Inherited from modal_dialog, implemented by REGISTER_DIALOG. */
62  virtual const std::string& window_id() const override;
63 
64  /** Inherited from modal_dialog. */
65  virtual void pre_show(window& window) override;
66 
67  /** Inherited from modal_dialog. */
68  virtual void post_show(window& window) override;
69 
70  void sort_campaigns(window& window, CAMPAIGN_ORDER order, bool ascending);
71 
72  void add_campaign_to_tree(window& window, const config& campaign);
73 
74  void toggle_sorting_selection(window& window, CAMPAIGN_ORDER order);
75 
76  void mod_toggled(window& window);
77 
78  void filter_text_changed(text_box_base* textbox, const std::string &text);
79 
81 
82  /** The chosen campaign. */
83  int choice_;
84 
85  /** whether the player checked the "Deterministic" checkbox. */
87 
88  boost::dynamic_bitset<> mod_states_;
89 
90  std::vector<std::string> page_ids_;
91 
93 
95 
96  std::vector<std::string> last_search_words_;
97 };
98 
99 } // namespace dialogs
100 } // namespace gui2
void campaign_selected(window &window)
Called when another campaign is selected.
virtual const std::string & window_id() const override
Inherited from modal_dialog, implemented by REGISTER_DIALOG.
Abstract base class for text items.
Generic file dialog.
Definition: field-fwd.hpp:22
void toggle_sorting_selection(window &window, CAMPAIGN_ORDER order)
campaign_selection(ng::create_engine &eng)
virtual void post_show(window &window) override
Inherited from modal_dialog.
void sort_campaigns(window &window, CAMPAIGN_ORDER order, bool ascending)
Various uncategorised dialogs.
std::vector< std::string > page_ids_
virtual void pre_show(window &window) override
Inherited from modal_dialog.
void filter_text_changed(text_box_base *textbox, const std::string &text)
Abstract base class for all modal dialogs.
bool deterministic_
whether the player checked the "Deterministic" checkbox.
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:92
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:63
void set_restore(const bool restore)
std::vector< std::string > last_search_words_
void add_campaign_to_tree(window &window, const config &campaign)