The Battle for Wesnoth  1.15.0+dev
unit_preview_pane.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 
17 
18 #include <string>
19 
20 class unit;
21 class unit_type;
22 
23 namespace gui2
24 {
25 
26 // ------------ WIDGET -----------{
27 
28 class button;
29 class image;
30 class label;
31 class tree_view;
32 class tree_view_node;
33 
34 namespace implementation
35 {
36  struct builder_unit_preview_pane;
37 }
38 
40 {
42 
43 public:
45 
46  /** Displays the stats of a specified unit type */
47  void set_displayed_type(const unit_type& type);
48 
49  /** Displays the stats of a specific unit */
50  void set_displayed_unit(const unit& u);
51 
52  /** Sets the facing of the unit image */
53  void set_image_mods(const std::string& mods);
54 
55  /** Callback for the profile button */
56  void profile_button_callback();
57 
58  /** See @ref styled_widget::set_active. */
59  virtual void set_active(const bool active) override;
60 
61  /** See @ref styled_widget::get_active. */
62  virtual bool get_active() const override;
63 
64  /** See @ref styled_widget::get_state. */
65  virtual unsigned get_state() const override;
66 
67 protected:
68  /**
69  * Initializes the internal sub-widget pointers.
70  * Should be called when building the window, so the pointers
71  * are initialized when set_displayed_type() is called.
72  */
73  void finalize_setup();
74 
75 private:
76  std::string current_type_;
77 
81 
85 
88 
90 
91  std::string image_mods_;
92 
93  template<typename T> // This is only a template to avoid including units/attack.hpp
94  void print_attack_details(T attacks, tree_view_node& parent_node);
95 
96  enum state_t {
97  ENABLED
98  };
99 
100 public:
101  /** Static type getter that does not rely on the widget being constructed. */
102  static const std::string& type();
103 
104 private:
105  /** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
106  virtual const std::string& get_control_type() const override;
107 
108  /** See @ref container_base::set_self_active. */
109  virtual void set_self_active(const bool active) override;
110 
111 };
112 
113 // }---------- DEFINITION ---------{
114 
116 {
117 
118  explicit unit_preview_pane_definition(const config& cfg);
119 
121  {
122  explicit resolution(const config& cfg);
123 
125  };
126 };
127 
128 // }---------- BUILDER -----------{
129 
130 namespace implementation
131 {
132 
134 {
135 public:
136  explicit builder_unit_preview_pane(const config& cfg);
137 
139 
140  widget* build() const;
141 
142 private:
143  const std::string image_mods_;
144 };
145 
146 } // namespace implementation
147 
148 // }------------ END --------------
149 
150 } // namespace gui2
Base class of a resolution, contains the common keys for a resolution.
virtual widget * build() const =0
This class represents a single unit of a specific type.
Definition: unit.hpp:99
Base class for all widgets.
Definition: widget.hpp:47
styled_widget * label_details_
Label showing a text.
Definition: label.hpp:32
A single unit type that the player may recruit.
Definition: types.hpp:42
Generic file dialog.
Definition: field-fwd.hpp:22
window * build(const builder_window::window_resolution *definition)
Builds a window.
Base class for all visible items.
A generic container base class.
this module manages the cache of images.
Simple push button.
Definition: button.hpp:35
point resolution()
Definition: general.cpp:373
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:92
std::shared_ptr< builder_grid > builder_grid_ptr
Contains the implementation details for lexical_cast and shouldn&#39;t be used directly.