The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
unit_create.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2016 by Ignacio R. Morelle <[email protected]>
3  Part of the Battle for Wesnoth Project http://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 #ifndef GUI_DIALOGS_UNIT_CREATE_HPP_INCLUDED
16 #define GUI_DIALOGS_UNIT_CREATE_HPP_INCLUDED
17 
18 #include "gui/dialogs/dialog.hpp"
19 #include "gui/widgets/group.hpp"
20 #include "units/race.hpp"
21 
22 #include <string>
23 #include <vector>
24 
25 class display;
26 class unit_type;
27 
28 namespace gui2
29 {
30 
31 class ttext_;
32 
33 class tunit_create : public tdialog
34 {
35 public:
36  tunit_create();
37 
38  /** Unit type choice from the user. */
39  const std::string& choice() const
40  {
41  return choice_;
42  }
43 
44  /** Whether the user actually chose a unit type or not. */
45  bool no_choice() const
46  {
47  return choice_.empty();
48  }
49 
50  /** Gender choice from the user. */
52  {
53  return gender_;
54  }
55 
56 private:
57  std::vector<const unit_type*> units_;
58 
60 
62 
63  std::vector<std::string> last_words_;
64 
65  /** Inherited from tdialog, implemented by REGISTER_DIALOG. */
66  virtual const std::string& window_id() const;
67 
68  /** Inherited from tdialog. */
69  void pre_show(twindow& window);
70 
71  bool compare_type(unsigned i1, unsigned i2) const;
72  bool compare_race(unsigned i1, unsigned i2) const;
73  bool compare_type_rev(unsigned i1, unsigned i2) const;
74  bool compare_race_rev(unsigned i1, unsigned i2) const;
75 
76  /** Inherited from tdialog. */
77  void post_show(twindow& window);
78 
79  /** Callbacks */
80  void list_item_clicked(twindow& window);
81  void filter_text_changed(ttext_* textbox, const std::string& text);
82  void gender_toggle_callback(twindow& window);
83 
85 };
86 }
87 
88 #endif /* ! GUI_DIALOGS_UNIT_CREATE_HPP_INCLUDED */
std::string choice_
Definition: unit_create.hpp:61
std::vector< const unit_type * > units_
Definition: unit_create.hpp:57
void gender_toggle_callback(twindow &window)
bool compare_race(unsigned i1, unsigned i2) const
std::vector< std::string > last_words_
Definition: unit_create.hpp:63
void filter_text_changed(ttext_ *textbox, const std::string &text)
const std::string & choice() const
Unit type choice from the user.
Definition: unit_create.hpp:39
void list_item_clicked(twindow &window)
Callbacks.
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:62
A class inherited from ttext_box that displays its input as stars.
Definition: field-fwd.hpp:23
Abstract base class for all dialogs.
Definition: dialog.hpp:121
bool compare_race_rev(unsigned i1, unsigned i2) const
bool no_choice() const
Whether the user actually chose a unit type or not.
Definition: unit_create.hpp:45
void pre_show(twindow &window)
Inherited from tdialog.
Definition: unit_create.cpp:90
virtual const std::string & window_id() const
Inherited from tdialog, implemented by REGISTER_DIALOG.
bool compare_type(unsigned i1, unsigned i2) const
unit_race::GENDER gender_
Definition: unit_create.hpp:59
bool compare_type_rev(unsigned i1, unsigned i2) const
unit_race::GENDER gender()
Gender choice from the user.
Definition: unit_create.hpp:51
GLsizei const GLcharARB ** string
Definition: glew.h:4503
tgroup< unit_race::GENDER > gender_toggle
Definition: unit_create.hpp:84
Abstract base class for text items.
Definition: text.hpp:43
void post_show(twindow &window)
Inherited from tdialog.