25 #include "eng3d/ui/image.hpp"
26 #include "eng3d/ui/label.hpp"
27 #include "eng3d/ui/progress_bar.hpp"
28 #include "eng3d/string.hpp"
29 #include "eng3d/camera.hpp"
30 #include "eng3d/color.hpp"
42 :
UI::Div(0, 0, 100, 30, _parent),
50 select_border_texture = s.tex_man.load(s.package_man.get_unique(
"gfx/border_sharp2.png"));
55 this->make_widget<UI::Image>(1, 1, this->
width - 1, this->
height - 1,
"gfx/drop_shadow.png");
60 gs.client_state.unselect_unit(this->unit_id);
62 gs.client_state.select_unit(this->unit_id);
68 this->flag_img =
new UI::Image(1, 1, 38, 28, nation_flag,
this);
71 this->make_widget<UI::Image>(1, 1, 38, 28,
"gfx/drop_shadow.png");
74 this->size_label =
new UI::Div(41, 1, 48, 28,
this);
83 this->unit_id = _unit.
get_id();
85 const auto& camera = *map.
camera;
86 auto unit_pos = _unit.
get_pos();
87 auto screen_pos = camera.get_tile_screen_pos(unit_pos);
89 this->
x = screen_pos.x - this->
width / 2;
90 this->
y = screen_pos.y - this->
height / 2;
100 if(relation.is_allied()) {
102 }
else if(relation.has_war) {
121 :
UI::Window(0, -200, 400, 200),
123 unit_id{ _unit.get_id() }
137 auto& unit_type = this->gs.
world->unit_types[unit.type_id];
140 auto& flex_column = this->make_widget<UI::Div>(0, 0, this->
width, this->
height);
143 auto& target_lab = flex_column.make_widget<
UI::Label>(0, 0,
" ");
146 auto target_id = current_unit.get_target_province_id();
147 if(current_unit.has_target_province()) {
148 const auto& target_province = this->gs.
world->provinces[target_id];
154 target_lab.on_each_tick(target_lab);
156 auto& size_lab = flex_column.make_widget<
UI::Label>(0, 0,
" ");
161 size_lab.on_each_tick(size_lab);
163 auto& experience_lab = flex_column.make_widget<
UI::Label>(0, 0,
" ");
168 experience_lab.on_each_tick(experience_lab);
170 auto& attdef_lab = flex_column.make_widget<
UI::Label>(0, 0,
" ");
173 auto& current_type = this->gs.
world->unit_types[current_unit.type_id];
176 attdef_lab.on_each_tick(attdef_lab);
178 auto& debug_lab = flex_column.make_widget<
UI::Label>(0, 0,
" ");
181 auto& current_type = this->gs.
world->unit_types[current_unit.type_id];
184 debug_lab.on_each_tick(debug_lab);
bool is_selected_unit(UnitId id) const
static State & get_instance()
std::shared_ptr< Eng3D::Texture > get_nation_flag(const Nation &nation)
UI::Widget * lower_left_panel
UnitView(GameState &_gs, Unit &unit)
std::unique_ptr< Eng3D::Camera > camera
std::vector< std::shared_ptr< Eng3D::Texture > > nation_flags
std::shared_ptr< Eng3D::Texture > texture
Image widget, can display pictures or effects on the screen.
Simple widget for drawing text on the screen, no multiline support.
void set_value(const float _value)
void set_close_btn_function(std::function< void(Widget &)> on_click)
Roughly a batallion, consisting of approximately 500 soldiers each.
glm::vec2 get_pos() const
Eng3D::Freelist< Unit > units
Nation::Relation & get_relation(NationId a, NationId b)
T::Id get_id(const T &obj) const
Get the id of an object, this is a template for all types except for tiles and locally-stored types (...
std::string string_format(const std::string_view format, Args &&... args)
String formatter.
std::string translate_format(const std::string_view format, Args &&... args)
String formatter, with translation.
Primitive color type used through the engine.
constexpr static Color rgba8(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha)
Create a color from RGBA components.
constexpr bool is_invalid() const
Checks if the current id is invalid.
constexpr Id get_id() const
constexpr static Id invalid()
Returns an invalid id.
A basic widget without any presets.