25 #include "eng3d/ui/image.hpp"
26 #include "eng3d/ui/progress_bar.hpp"
27 #include "eng3d/camera.hpp"
28 #include "eng3d/color.hpp"
42 :
UI::Div(0, 0, 188, 30, _parent),
50 this->left_flag_img =
new UI::Image(1, 1, 38, 28, gs.tex_man.get_white(),
this);
51 this->left_size_label =
new UI::Div(41, 1, 48, 28,
this);
55 if(this->province ==
nullptr)
return;
56 const auto& battle = this->province->
battle;
57 if(!battle.active)
return;
61 for(
const auto unit_id : attacker_unit_ids) {
62 const auto& unit = g_world.unit_manager.units[unit_id];
63 unit_size += unit.size;
68 this->right_flag_img =
new UI::Image(139, 1, 38, 28, gs.tex_man.get_white(),
this);
69 this->right_size_label =
new UI::Div(90, 1, 48, 28,
this);
73 if(this->province ==
nullptr)
return;
74 const auto& battle = this->province->
battle;
75 if(!battle.active)
return;
79 for(
const auto unit_id : defender_unit_ids) {
80 const auto& unit = g_world.unit_manager.units[unit_id];
81 unit_size += unit.size;
88 this->province = &_province;
89 const auto& battle = this->province->
battle;
90 const auto& camera = *map.
camera;
91 const auto battle_pos = province->
get_pos();
92 const auto screen_pos = camera.get_tile_screen_pos(battle_pos);
94 this->
x = screen_pos.x - this->
width / 2;
95 this->
y = screen_pos.y - this->
height / 2;
99 const auto attacker_unit_ids = battle.get_attacker_unit_ids();
100 if(!attacker_unit_ids.empty()) {
101 auto left_nation_flag = gs.
get_nation_flag(gs.world->nations[gs.world->unit_manager.units[attacker_unit_ids[0]].owner_id]);
103 this->left_size_label->
on_each_tick(*this->left_size_label);
106 const auto defender_unit_ids = battle.get_defender_unit_ids();
107 if(!defender_unit_ids.empty()) {
108 auto right_nation_flag = gs.get_nation_flag(gs.world->nations[gs.world->unit_manager.units[defender_unit_ids[0]].owner_id]);
110 this->right_size_label->
on_each_tick(*this->right_size_label);
static State & get_instance()
std::shared_ptr< Eng3D::Texture > get_nation_flag(const Nation &nation)
std::unique_ptr< Eng3D::Camera > camera
A single province, which is used to simulate economy in a "bulk-tiles" way instead of doing economica...
glm::vec2 get_pos() const
struct Province::Battle battle
Image widget, can display pictures or effects on the screen.
std::string string_format(const std::string_view format, Args &&... args)
String formatter.
Primitive color type used through the engine.
std::vector< UnitId > get_attacker_unit_ids() const
std::vector< UnitId > get_defender_unit_ids() const
A basic widget without any presets.