The Battle for Wesnoth  1.19.7+dev
unit_create.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2024
3  by Iris Morelle <shadowm2006@gmail.com>
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 #include "gui/widgets/group.hpp"
20 #include "units/race.hpp"
21 
22 #include <string>
23 #include <vector>
24 
25 class unit_type;
26 
27 namespace gui2
28 {
29 
30 
31 namespace dialogs
32 {
33 
34 class unit_create : public modal_dialog
35 {
36 public:
37  unit_create();
38 
39  /** Unit type choice from the user. */
40  const std::string& choice() const
41  {
42  return choice_;
43  }
44 
45  /** Whether the user actually chose a unit type or not. */
46  bool no_choice() const
47  {
48  return choice_.empty();
49  }
50 
51  /** Gender choice from the user. */
53  {
54  return gender_;
55  }
56 
57  /** Variation choice from the user. */
58  std::string variation() const
59  {
60  return variation_;
61  }
62 
63 private:
64  std::vector<const unit_type*> units_;
65 
67 
68  std::string choice_;
69 
70  std::string variation_;
71 
72  virtual const std::string& window_id() const override;
73 
74  virtual void pre_show() override;
75 
76  virtual void post_show() override;
77 
78  /** Callbacks */
79  void list_item_clicked();
80  void filter_text_changed(const std::string& text);
83 
84  void update_displayed_type();
85 
87 };
88 } // namespace dialogs
89 } // namespace gui2
Abstract base class for all modal dialogs.
virtual void pre_show() override
Actions to be taken before showing the window.
Definition: unit_create.cpp:52
unit_race::GENDER gender_
Definition: unit_create.hpp:66
group< unit_race::GENDER > gender_toggle
Definition: unit_create.hpp:86
unit_race::GENDER gender()
Gender choice from the user.
Definition: unit_create.hpp:52
bool no_choice() const
Whether the user actually chose a unit type or not.
Definition: unit_create.hpp:46
void list_item_clicked()
Callbacks.
std::string variation() const
Variation choice from the user.
Definition: unit_create.hpp:58
void filter_text_changed(const std::string &text)
virtual void post_show() override
Actions to be taken after the window has been shown.
void gender_toggle_callback(const unit_race::GENDER val)
const std::string & choice() const
Unit type choice from the user.
Definition: unit_create.hpp:40
std::vector< const unit_type * > units_
Definition: unit_create.hpp:64
virtual const std::string & window_id() const override
The ID of the window to build.
A single unit type that the player may recruit.
Definition: types.hpp:43
Various uncategorised dialogs.
Generic file dialog.