The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
unit_preview_pane.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 - 2025
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
18
19#include "units/types.hpp"
21
22#include <string>
23
24class unit;
25
26namespace gui2
27{
28
29// ------------ WIDGET -----------{
30
31class button;
32class drawing;
33class image;
34class label;
35class tree_view;
36class tree_view_node;
37
38namespace implementation
39{
40 struct builder_unit_preview_pane;
41}
42
44{
46
47public:
49
50 /** Displays the stats of a specified unit type */
51 void set_display_data(const unit_type& type);
52
53 /** Displays the stats of a specific unit */
54 void set_display_data(const unit& u);
55
56 /** Sets the facing of the unit image */
57 void set_image_mods(const std::string& mods);
58
59 /** Callback for the profile button */
61
62 /** See @ref styled_widget::set_active. */
63 virtual void set_active(const bool active) override;
64
65 /** See @ref styled_widget::get_active. */
66 virtual bool get_active() const override;
67
68 /** See @ref styled_widget::get_state. */
69 virtual unsigned get_state() const override;
70
71protected:
72 /**
73 * Initializes the internal sub-widget pointers.
74 * Should be called when building the window, so the pointers
75 * are initialized when set_display_data() is called.
76 */
77 void finalize_setup();
78
79private:
81
85
89
92
94
95 std::string image_mods_;
96
97 template<typename T> // This is only a template to avoid including units/attack.hpp
99 T attacks,
100 const int attacks_left,
101 const int max_attacks,
102 tree_view_node& parent_node);
103
104 enum state_t {
105 ENABLED
106 };
107
108public:
109 /** Static type getter that does not rely on the widget being constructed. */
110 static const std::string& type();
111
112private:
113 /** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
114 virtual const std::string& get_control_type() const override;
115
116 /** See @ref container_base::set_self_active. */
117 virtual void set_self_active(const bool active) override;
118
119};
120
121// }---------- DEFINITION ---------{
122
124{
125
126 explicit unit_preview_pane_definition(const config& cfg);
127
129 {
130 explicit resolution(const config& cfg);
131
133 };
134};
135
136// }---------- BUILDER -----------{
137
138namespace implementation
139{
140
142{
143 explicit builder_unit_preview_pane(const config& cfg);
144
146
147 virtual std::unique_ptr<widget> build() const override;
148
149 std::string image_mods;
150};
151
152} // namespace implementation
153
154// }------------ END --------------
155
156} // namespace gui2
A config object defines a single node in a WML file, with access to child nodes.
Definition config.hpp:157
Simple push button.
Definition button.hpp:36
A generic container base class.
void profile_button_callback()
Callback for the profile button.
virtual void set_active(const bool active) override
See styled_widget::set_active.
void set_display_data(const unit_type &type)
Displays the stats of a specified unit type.
virtual bool get_active() const override
See styled_widget::get_active.
void set_image_mods(const std::string &mods)
Sets the facing of the unit image.
virtual void set_self_active(const bool active) override
See container_base::set_self_active.
void print_attack_details(T attacks, const int attacks_left, const int max_attacks, tree_view_node &parent_node)
static const std::string & type()
Static type getter that does not rely on the widget being constructed.
virtual unsigned get_state() const override
See styled_widget::get_state.
virtual const std::string & get_control_type() const override
Inherited from styled_widget, implemented by REGISTER_WIDGET.
utils::optional_reference< const unit_type > current_type_
void finalize_setup()
Initializes the internal sub-widget pointers.
A single unit type that the player may recruit.
Definition types.hpp:43
This class represents a single unit of a specific type.
Definition unit.hpp:39
A simple wrapper class for optional reference types.
const config * cfg
std::string label
What to show in the filter's drop-down list.
Definition manager.cpp:201
Generic file dialog.
std::shared_ptr< builder_grid > builder_grid_ptr
Functions to load and save images from/to disk.
Contains the implementation details for lexical_cast and shouldn't be used directly.
virtual std::unique_ptr< widget > build() const=0
virtual std::unique_ptr< widget > build() const override