The Battle for Wesnoth  1.15.2+dev
unit_recruit.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2016 - 2018 by the Battle for Wesnoth Project https://www.wesnoth.org/
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY.
10 
11  See the COPYING file for more details.
12 */
13 
14 #pragma once
15 
18 
19 class unit_type;
20 class team;
21 
22 namespace gui2
23 {
24 namespace dialogs
25 {
26 
27 class unit_recruit : public modal_dialog
28 {
29 public:
30  /// @param recruit_map maps unit typs to strings. The strings are ""
31  /// if the unit can be recalled and an error message string otherwise.
32  unit_recruit(std::map<const unit_type*, t_string>& recruit_map, team& team);
33 
35  {
36  return selected_index_ < 0 ? nullptr : recruit_list_[selected_index_];
37  }
38 
39 private:
40  /** Inherited from modal_dialog, implemented by REGISTER_DIALOG. */
41  virtual const std::string& window_id() const override;
42 
43  /** Inherited from modal_dialog. */
44  virtual void pre_show(window& window) override;
45  virtual void post_show(window& window) override;
46 
47  void list_item_clicked(window& window);
48  void filter_text_changed(text_box_base* textbox, const std::string& text);
49 
50  void show_help();
51 
52  /// A vector of unit types in the order listed in the UI. Used by unit_recruit::post_show.
53  std::vector<const unit_type*> recruit_list_;
54  std::map<const unit_type*, t_string>& recruit_map_;
55 
56  team& team_;
57 
59 
60  std::vector<std::string> last_words_;
61 };
62 
63 } // namespace dialogs
64 } // namespace gui2
Abstract base class for text items.
const unit_type * get_selected_unit_type() const
unit_recruit(std::map< const unit_type *, t_string > &recruit_map, team &team)
virtual const std::string & window_id() const override
Inherited from modal_dialog, implemented by REGISTER_DIALOG.
A single unit type that the player may recruit.
Definition: types.hpp:42
std::vector< const unit_type * > recruit_list_
A vector of unit types in the order listed in the UI. Used by unit_recruit::post_show.
Generic file dialog.
Definition: field-fwd.hpp:22
This class stores all the data for a single &#39;side&#39; (in game nomenclature).
Definition: team.hpp:44
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
virtual void pre_show(window &window) override
Inherited from modal_dialog.
Various uncategorised dialogs.
void list_item_clicked(window &window)
Abstract base class for all modal dialogs.
void filter_text_changed(text_box_base *textbox, const std::string &text)
std::vector< std::string > last_words_
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:62
std::map< const unit_type *, t_string > & recruit_map_