Project Alice
Loading...
Searching...
No Matches
gui_land_combat.hpp
Go to the documentation of this file.
1#pragma once
2
5#include "military.hpp"
6
7namespace ui {
8
9
11 dcon::gfx_object_id def;
12
13 void on_update(sys::state& state) noexcept override {
14 if(!def)
16
17 auto b = retrieve<dcon::land_battle_id>(state, parent);
18 auto lid = state.world.land_battle_get_general_from_attacking_general(b);
19
20 if(!lid) {
22 return;
23 }
24
25 auto owner = state.world.leader_get_nation_from_leader_loyalty(lid);
26 auto pculture = state.world.nation_get_primary_culture(owner);
27 auto ltype = pculture.get_group_from_culture_group_membership().get_leader();
28
29 if(ltype) {
30 auto grange = ltype.get_generals();
31 if(grange.size() > 0) {
32 auto rval = rng::get_random(state, uint32_t(state.world.leader_get_since(lid).value), uint32_t(lid.value));
33 auto in_range = rng::reduce(uint32_t(rval), grange.size());
34 base_data.data.image.gfx_object = grange[in_range];
35 }
36 }
37 }
38
39 tooltip_behavior has_tooltip(sys::state& state) noexcept override {
41 }
42
43 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
44 auto b = retrieve<dcon::land_battle_id>(state, parent);
45 auto lid = state.world.land_battle_get_general_from_attacking_general(b);
46
47 if(lid)
48 display_leader_attributes(state, lid, contents, 0);
49 else
50 text::add_line(state, contents, "no_leader");
51 }
52};
54 dcon::gfx_object_id def;
55
56 void on_update(sys::state& state) noexcept override {
57 if(!def)
59
60 auto b = retrieve<dcon::land_battle_id>(state, parent);
61 auto lid = state.world.land_battle_get_general_from_defending_general(b);
62
63 if(!lid) {
65 return;
66 }
67
68 auto owner = state.world.leader_get_nation_from_leader_loyalty(lid);
69 auto pculture = state.world.nation_get_primary_culture(owner);
70 auto ltype = pculture.get_group_from_culture_group_membership().get_leader();
71
72 if(ltype) {
73 auto grange = ltype.get_generals();
74 if(grange.size() > 0) {
75 auto rval = rng::get_random(state, uint32_t(state.world.leader_get_since(lid).value), uint32_t(lid.value));
76 auto in_range = rng::reduce(uint32_t(rval), grange.size());
77 base_data.data.image.gfx_object = grange[in_range];
78 }
79 }
80 }
81
82 tooltip_behavior has_tooltip(sys::state& state) noexcept override {
84 }
85
86 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
87 auto b = retrieve<dcon::land_battle_id>(state, parent);
88 auto lid = state.world.land_battle_get_general_from_defending_general(b);
89
90 if(lid)
91 display_leader_attributes(state, lid, contents, 0);
92 else
93 text::add_line(state, contents, "no_leader");
94 }
95};
96
98public:
99 void on_update(sys::state& state) noexcept override {
100 auto b = retrieve<dcon::land_battle_id>(state, parent);
101 auto lid = state.world.land_battle_get_general_from_attacking_general(b);
102
103 if(lid) {
104 auto name = state.to_string_view(state.world.leader_get_name(lid));
105 set_text(state, std::string(name));
106 } else {
107 set_text(state, "");
108 }
109 }
110};
112public:
113 void on_update(sys::state& state) noexcept override {
114 auto b = retrieve<dcon::land_battle_id>(state, parent);
115 auto lid = state.world.land_battle_get_general_from_defending_general(b);
116
117 if(lid) {
118 auto name = state.to_string_view(state.world.leader_get_name(lid));
119 set_text(state, std::string(name));
120 } else {
121 set_text(state, "");
122 }
123 }
124};
125
127public:
128
129 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
130 dcon::gfx_object_id gid;
135 }
136 if(gid && flag_texture_handle > 0) {
137 auto& gfx_def = state.ui_defs.gfx[gid];
138 auto mask_handle = ogl::get_texture_handle(state, dcon::texture_id(gfx_def.type_dependent - 1), true);
139 auto& mask_tex = state.open_gl.asset_textures[dcon::texture_id(gfx_def.type_dependent - 1)];
141 float(y), float(base_data.size.x), float(base_data.size.y), flag_texture_handle, mask_handle, base_data.get_rotation(),
142 gfx_def.is_vertically_flipped(),
143 false);
144 }
146 }
147
148 void on_create(sys::state& state) noexcept override {
149 std::swap(base_data.size.x, base_data.size.y);
150 base_data.position.x += int16_t(4);
152 }
153 dcon::national_identity_id get_current_nation(sys::state& state) noexcept override {
154 auto b = retrieve<dcon::land_battle_id>(state, parent);
156 return state.world.nation_get_identity_from_identity_holder(n);
157 }
158};
160public:
161 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
162 dcon::gfx_object_id gid;
167 }
168 if(gid && flag_texture_handle > 0) {
169 auto& gfx_def = state.ui_defs.gfx[gid];
170 auto mask_handle = ogl::get_texture_handle(state, dcon::texture_id(gfx_def.type_dependent - 1), true);
171 auto& mask_tex = state.open_gl.asset_textures[dcon::texture_id(gfx_def.type_dependent - 1)];
173 float(y), float(base_data.size.x), float(base_data.size.y), flag_texture_handle, mask_handle, base_data.get_rotation(),
174 gfx_def.is_vertically_flipped(),
175 false);
176 }
178 }
179
180 void on_create(sys::state& state) noexcept override {
181 std::swap(base_data.size.x, base_data.size.y);
182 base_data.position.x += int16_t(4);
184 }
185 dcon::national_identity_id get_current_nation(sys::state& state) noexcept override {
186 auto b = retrieve<dcon::land_battle_id>(state, parent);
188 return state.world.nation_get_identity_from_identity_holder(n);
189 }
190};
191
193public:
194 void on_update(sys::state& state) noexcept override {
195 auto b = retrieve<dcon::land_battle_id>(state, parent);
196 auto w = state.world.land_battle_get_war_from_land_battle_in_war(b);
197 float count = 0.0f;
198 float total = 0.0f;
199 for(auto a : state.world.land_battle_get_army_battle_participation(b)) {
200 auto owner = a.get_army().get_controller_from_army_control();
201 bool battle_attacker = false;
202 if(w) {
203 battle_attacker = (military::get_role(state, w, owner) == military::war_role::attacker) == state.world.land_battle_get_war_attacker_is_attacker(b);
204 } else {
205 battle_attacker = !bool(owner) == state.world.land_battle_get_war_attacker_is_attacker(b);
206 }
207 if(battle_attacker == false) {
208 for(auto r : a.get_army().get_army_membership()) {
209 ++count;
210 total += r.get_regiment().get_org();
211 }
212 }
213 }
214 progress = count > 0 ? total / count : 0.0f;
215 }
216};
218public:
219 void on_update(sys::state& state) noexcept override {
220 auto b = retrieve<dcon::land_battle_id>(state, parent);
221 auto w = state.world.land_battle_get_war_from_land_battle_in_war(b);
222 float count = 0.0f;
223 float total = 0.0f;
224 for(auto a : state.world.land_battle_get_army_battle_participation(b)) {
225 auto owner = a.get_army().get_controller_from_army_control();
226 bool battle_attacker = false;
227 if(w) {
228 battle_attacker = (military::get_role(state, w, owner) == military::war_role::attacker) == state.world.land_battle_get_war_attacker_is_attacker(b);
229 } else {
230 battle_attacker = !bool(owner) == state.world.land_battle_get_war_attacker_is_attacker(b);
231 }
232 if(battle_attacker == false) {
233 for(auto r : a.get_army().get_army_membership()) {
234 ++count;
235 total += r.get_regiment().get_strength();
236 }
237 }
238 }
239 progress = count > 0 ? total / count : 0.0f;
240 }
241};
243public:
244 void on_update(sys::state& state) noexcept override {
245 auto b = retrieve<dcon::land_battle_id>(state, parent);
246 auto w = state.world.land_battle_get_war_from_land_battle_in_war(b);
247 float count = 0.0f;
248 float total = 0.0f;
249 for(auto a : state.world.land_battle_get_army_battle_participation(b)) {
250 auto owner = a.get_army().get_controller_from_army_control();
251 bool battle_attacker = false;
252 if(w) {
253 battle_attacker = (military::get_role(state, w, owner) == military::war_role::attacker) == state.world.land_battle_get_war_attacker_is_attacker(b);
254 } else {
255 battle_attacker = !bool(owner) == state.world.land_battle_get_war_attacker_is_attacker(b);
256 }
257 if(battle_attacker == true) {
258 for(auto r : a.get_army().get_army_membership()) {
259 ++count;
260 total += r.get_regiment().get_org();
261 }
262 }
263 }
264 progress = count > 0 ? total / count : 0.0f;
265 }
266};
268public:
269 void on_update(sys::state& state) noexcept override {
270 auto b = retrieve<dcon::land_battle_id>(state, parent);
271 auto w = state.world.land_battle_get_war_from_land_battle_in_war(b);
272 float count = 0.0f;
273 float total = 0.0f;
274 for(auto a : state.world.land_battle_get_army_battle_participation(b)) {
275 auto owner = a.get_army().get_controller_from_army_control();
276 bool battle_attacker = false;
277 if(w) {
278 battle_attacker = (military::get_role(state, w, owner) == military::war_role::attacker) == state.world.land_battle_get_war_attacker_is_attacker(b);
279 } else {
280 battle_attacker = !bool(owner) == state.world.land_battle_get_war_attacker_is_attacker(b);
281 }
282 if(battle_attacker == true) {
283 for(auto r : a.get_army().get_army_membership()) {
284 ++count;
285 total += r.get_regiment().get_strength();
286 }
287 }
288 }
289 progress = count > 0 ? total / count : 0.0f;
290 }
291};
292
294public:
295 void on_update(sys::state& state) noexcept override {
296 auto b = retrieve<dcon::land_battle_id>(state, parent);
297 auto w = state.world.land_battle_get_war_from_land_battle_in_war(b);
298 float count = 0.0f;
299 float total = 0.0f;
300 for(auto a : state.world.land_battle_get_army_battle_participation(b)) {
301 auto owner = a.get_army().get_controller_from_army_control();
302 bool battle_attacker = false;
303 if(w) {
304 battle_attacker = (military::get_role(state, w, owner) == military::war_role::attacker) == state.world.land_battle_get_war_attacker_is_attacker(b);
305 } else {
306 battle_attacker = !bool(owner) == state.world.land_battle_get_war_attacker_is_attacker(b);
307 }
308 if(battle_attacker == false) {
309 for(auto r : a.get_army().get_army_membership()) {
310 ++count;
311 total += r.get_regiment().get_org();
312 }
313 }
314 }
315 set_text(state, text::format_percentage(count > 0 ? total / count : 0.0f, 1));
316 }
317};
319public:
320 void on_update(sys::state& state) noexcept override {
321 auto b = retrieve<dcon::land_battle_id>(state, parent);
322 auto w = state.world.land_battle_get_war_from_land_battle_in_war(b);
323 float count = 0.0f;
324 float total = 0.0f;
325 for(auto a : state.world.land_battle_get_army_battle_participation(b)) {
326 auto owner = a.get_army().get_controller_from_army_control();
327 bool battle_attacker = false;
328 if(w) {
329 battle_attacker = (military::get_role(state, w, owner) == military::war_role::attacker) == state.world.land_battle_get_war_attacker_is_attacker(b);
330 } else {
331 battle_attacker = !bool(owner) == state.world.land_battle_get_war_attacker_is_attacker(b);
332 }
333 if(battle_attacker == false) {
334 for(auto r : a.get_army().get_army_membership()) {
335 ++count;
336 total += r.get_regiment().get_strength();
337 }
338 }
339 }
340 set_text(state, text::format_percentage(count > 0 ? total / count : 0.0f, 1));
341 }
342};
344public:
345 void on_update(sys::state& state) noexcept override {
346 auto b = retrieve<dcon::land_battle_id>(state, parent);
347 auto w = state.world.land_battle_get_war_from_land_battle_in_war(b);
348 float count = 0.0f;
349 float total = 0.0f;
350 for(auto a : state.world.land_battle_get_army_battle_participation(b)) {
351 auto owner = a.get_army().get_controller_from_army_control();
352 bool battle_attacker = false;
353 if(w) {
354 battle_attacker = (military::get_role(state, w, owner) == military::war_role::attacker) == state.world.land_battle_get_war_attacker_is_attacker(b);
355 } else {
356 battle_attacker = !bool(owner) == state.world.land_battle_get_war_attacker_is_attacker(b);
357 }
358 if(battle_attacker == true) {
359 for(auto r : a.get_army().get_army_membership()) {
360 ++count;
361 total += r.get_regiment().get_org();
362 }
363 }
364 }
365 set_text(state, text::format_percentage(count > 0 ? total / count : 0.0f, 1));
366 }
367};
369public:
370 void on_update(sys::state& state) noexcept override {
371 auto b = retrieve<dcon::land_battle_id>(state, parent);
372 auto w = state.world.land_battle_get_war_from_land_battle_in_war(b);
373 float count = 0.0f;
374 float total = 0.0f;
375 for(auto a : state.world.land_battle_get_army_battle_participation(b)) {
376 auto owner = a.get_army().get_controller_from_army_control();
377 bool battle_attacker = false;
378 if(w) {
379 battle_attacker = (military::get_role(state, w, owner) == military::war_role::attacker) == state.world.land_battle_get_war_attacker_is_attacker(b);
380 } else {
381 battle_attacker = !bool(owner) == state.world.land_battle_get_war_attacker_is_attacker(b);
382 }
383 if(battle_attacker == true) {
384 for(auto r : a.get_army().get_army_membership()) {
385 ++count;
386 total += r.get_regiment().get_strength();
387 }
388 }
389 }
390 set_text(state, text::format_percentage(count > 0 ? total / count : 0.0f, 1));
391 }
392};
393
394template<int32_t index>
396public:
397 void on_create(sys::state& state) noexcept override {
399 frame = index;
400 }
401};
402
403template<bool IsAttacker, military::unit_type Type>
405public:
406 void on_update(sys::state& state) noexcept override {
407 auto b = retrieve<dcon::land_battle_id>(state, parent);
408 auto w = state.world.land_battle_get_war_from_land_battle_in_war(b);
409 float total = 0.0f;
410 float full_total = 0.0f;
411 for(auto a : state.world.land_battle_get_army_battle_participation(b)) {
412 auto owner = a.get_army().get_controller_from_army_control();
413 bool battle_attacker = false;
414 if(w) {
415 battle_attacker = (military::get_role(state, w, owner) == military::war_role::attacker) == state.world.land_battle_get_war_attacker_is_attacker(b);
416 } else {
417 battle_attacker = !bool(owner) == state.world.land_battle_get_war_attacker_is_attacker(b);
418 }
419 if(battle_attacker == IsAttacker) {
420 for(auto r : a.get_army().get_army_membership()) {
421 auto t = r.get_regiment().get_type();
422 if(t) {
423 if(state.military_definitions.unit_base_definitions[t].type == Type || (Type == military::unit_type::support && state.military_definitions.unit_base_definitions[t].type == military::unit_type::special)) {
424 total += r.get_regiment().get_strength();
425 full_total += 1.f;
426 }
427 }
428 }
429 }
430 }
431
432 auto color = text::text_color::dark_red;
433 if(full_total != 0.f && total != 0.f) {
434 if(total / full_total >= 0.75f) {
436 } else if(total / full_total <= 0.25f) {
438 } else {
440 }
441 }
443 auto box = text::open_layout_box(contents);
444 text::add_to_layout_box(state, contents, box, text::prettify(uint64_t(total * state.defines.pop_size_per_regiment)), color);
445 text::close_layout_box(contents, box);
446 }
447};
448
449enum class lc_mod_type {
451};
454 int32_t value = 0;
455};
456
458public:
459 void on_update(sys::state& state) noexcept override {
460 lc_modifier_data dat = retrieve< lc_modifier_data>(state, parent);
461 switch(dat.type) {
463 frame = 3;
464 break;
466 frame = 2;
467 break;
469 frame = 0;
470 break;
472 frame = 1;
473 break;
475 frame = 4;
476 break;
477 case lc_mod_type::gas:
478 frame = 5;
479 break;
480 default:
481 break;
482 }
483 }
486 }
487
488 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
489 lc_modifier_data dat = retrieve< lc_modifier_data>(state, parent);
490 switch(dat.type) {
492 text::add_line(state, contents, "combat_terrain");
493 break;
495 text::add_line(state, contents, "combat_crossing");
496 break;
498 text::add_line(state, contents, "combat_dice");
499 break;
501 text::add_line(state, contents, "combat_digin");
502 break;
504 text::add_line(state, contents, "combat_leader_mod");
505 break;
506 case lc_mod_type::gas:
507 text::add_line(state, contents, "combat_gas");
508 break;
509 default:
510 break;
511 }
512 }
513};
514
516 void on_update(sys::state& state) noexcept override {
517 lc_modifier_data dat = retrieve< lc_modifier_data>(state, parent);
518 set_text(state, std::to_string(dat.value));
519 }
520};
521
523public:
525
526 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
527 if(name == "modifier_icon") {
528 return make_element_by_type<lc_modifier_icon>(state, id);
529 } else if(name == "modifier_value") {
530 return make_element_by_type<lc_modifier_value>(state, id);
531 } else {
532 return nullptr;
533 }
534 }
535
536 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
537 if(payload.holds_type<lc_modifier_data>()) {
538 payload.emplace<lc_modifier_data>(data);
540 }
542 }
543};
544
545class defender_combat_modifiers : public overlapping_listbox_element_base<lc_modifier, lc_modifier_data> {
546 std::string_view get_row_element_name() override {
547 return "alice_combat_modifier";
548 }
549 void update_subwindow(sys::state& state, lc_modifier& subwindow, lc_modifier_data content) override {
550 subwindow.data = content;
551 }
552 void on_update(sys::state& state) noexcept override {
553 row_contents.clear();
554
555 auto b = retrieve<dcon::land_battle_id>(state, parent);
556 auto both_dice = state.world.land_battle_get_dice_rolls(b);
557 auto defender_mods = state.world.land_battle_get_defender_bonus(b);
558 auto dig_in_value = defender_mods & military::defender_bonus_dig_in_mask;
559
560 auto attacking_nation = military::get_land_battle_lead_attacker(state, b);
561 auto defending_nation = military::get_land_battle_lead_defender(state, b);
562
563 bool defender_gas =
564 state.world.nation_get_has_gas_attack(defending_nation) && !state.world.nation_get_has_gas_defense(attacking_nation);
565
566 auto defender_dice = (both_dice >> 4) & 0x0F;
567
568 auto location = state.world.land_battle_get_location_from_land_battle_location(b);
569 auto terrain_bonus = state.world.province_get_modifier_values(location, sys::provincial_mod_offsets::defense);
570
571 auto defender_per = state.world.leader_get_personality(state.world.land_battle_get_general_from_defending_general(b));
572 auto defender_bg = state.world.leader_get_background(state.world.land_battle_get_general_from_defending_general(b));
573
574 auto defence_bonus =
575 int32_t(state.world.leader_trait_get_defense(defender_per) + state.world.leader_trait_get_defense(defender_bg));
576
577 row_contents.push_back(lc_modifier_data{ lc_mod_type::dice, defender_dice });
578 if(dig_in_value != 0)
579 row_contents.push_back(lc_modifier_data{ lc_mod_type::digin, dig_in_value });
580 if(terrain_bonus != 0)
581 row_contents.push_back(lc_modifier_data{ lc_mod_type::terrain, int32_t(terrain_bonus) });
582 if(defence_bonus != 0)
583 row_contents.push_back(lc_modifier_data{ lc_mod_type::leader, defence_bonus });
584 if(defender_gas)
585 row_contents.push_back(lc_modifier_data{ lc_mod_type::gas, int32_t(state.defines.gas_attack_modifier) });
586
587 update(state);
588 }
589};
590class attacker_combat_modifiers : public overlapping_listbox_element_base<lc_modifier, lc_modifier_data> {
591 std::string_view get_row_element_name() override {
592 return "alice_combat_modifier";
593 }
594 void update_subwindow(sys::state& state, lc_modifier& subwindow, lc_modifier_data content) override {
595 subwindow.data = content;
596 }
597 void on_update(sys::state& state) noexcept override {
598 row_contents.clear();
599
600 auto b = retrieve<dcon::land_battle_id>(state, parent);
601 auto both_dice = state.world.land_battle_get_dice_rolls(b);
602 auto defender_mods = state.world.land_battle_get_defender_bonus(b);
603 auto crossing_value = defender_mods & military::defender_bonus_crossing_mask;
604
605 auto attacking_nation = military::get_land_battle_lead_attacker(state, b);
606 auto defending_nation = military::get_land_battle_lead_defender(state, b);
607
608 bool attacker_gas =
609 state.world.nation_get_has_gas_attack(attacking_nation) && !state.world.nation_get_has_gas_defense(defending_nation);
610 bool defender_gas =
611 state.world.nation_get_has_gas_attack(defending_nation) && !state.world.nation_get_has_gas_defense(attacking_nation);
612
613 int32_t crossing_adjustment =
614 (crossing_value == military::defender_bonus_crossing_none ? 0 : (crossing_value == military::defender_bonus_crossing_river ? -1 : -2));
615
616 auto attacker_dice = both_dice & 0x0F;
617
618 auto attacker_per = state.world.leader_get_personality(state.world.land_battle_get_general_from_attacking_general(b));
619 auto attacker_bg = state.world.leader_get_background(state.world.land_battle_get_general_from_attacking_general(b));
620
621 auto attack_bonus =
622 int32_t(state.world.leader_trait_get_attack(attacker_per) + state.world.leader_trait_get_attack(attacker_bg));
623
624 row_contents.push_back(lc_modifier_data{lc_mod_type::dice, attacker_dice });
625 if(crossing_adjustment != 0)
626 row_contents.push_back(lc_modifier_data{ lc_mod_type::river, crossing_adjustment });
627 if(attack_bonus != 0)
628 row_contents.push_back(lc_modifier_data{ lc_mod_type::leader, attack_bonus });
629 if(attacker_gas)
630 row_contents.push_back(lc_modifier_data{ lc_mod_type::gas, int32_t(state.defines.gas_attack_modifier) });
631
632 update(state);
633 }
634};
635
637public:
638 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
639 if(name == "shield") {
640 return make_element_by_type<lc_defender_flag>(state, id);
641 } else if(name == "leader_icon") {
642 return make_element_by_type<lc_defending_leader_img>(state, id);
643 } else if(name == "leader_name") {
644 return make_element_by_type<lc_defending_leader_name>(state, id);
645 } else if(name == "morale") {
646 auto ptr = make_element_by_type<lc_defender_org>(state, id);
647 ptr->base_data.position.y -= 1; // Nudge
648 return ptr;
649 } else if(name == "strength") {
650 auto ptr = make_element_by_type<lc_defender_str>(state, id);
651 ptr->base_data.position.y -= 1; // Nudge
652 return ptr;
653 } else if(name == "morale_text") {
654 return make_element_by_type<lc_defender_org_txt>(state, id);
655 } else if(name == "strength_text") {
656 return make_element_by_type<lc_defender_str_txt>(state, id);
657 } else if(name == "unit_type_1") {
658 return make_element_by_type<lc_static_icon<0>>(state, id);
659 } else if(name == "unit_type_2") {
660 return make_element_by_type<lc_static_icon<1>>(state, id);
661 } else if(name == "unit_type_3") {
662 return make_element_by_type<lc_static_icon<2>>(state, id);
663 } else if(name == "unit_type_1_value") {
664 return make_element_by_type<lc_unit_strength_txt<false, military::unit_type::infantry>>(state, id);
665 } else if(name == "unit_type_2_value") {
666 return make_element_by_type<lc_unit_strength_txt<false, military::unit_type::cavalry>>(state, id);
667 } else if(name == "unit_type_3_value") {
668 return make_element_by_type<lc_unit_strength_txt<false, military::unit_type::support>>(state, id);
669 } else if(name == "modifiers") {
670 return make_element_by_type<defender_combat_modifiers>(state, id);
671 } else {
672 return nullptr;
673 }
674 }
675};
676
678public:
679 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
680 if(name == "shield") {
681 return make_element_by_type<lc_attacker_flag>(state, id);
682 } else if(name == "leader_icon") {
683 return make_element_by_type<lc_attacker_leader_img>(state, id);
684 } else if(name == "leader_name") {
685 return make_element_by_type<lc_attacking_leader_name>(state, id);
686 } else if(name == "morale") {
687 auto ptr = make_element_by_type<lc_attacker_org>(state, id);
688 ptr->base_data.position.y -= 1; // Nudge
689 return ptr;
690 } else if(name == "strength") {
691 auto ptr = make_element_by_type<lc_attacker_str>(state, id);
692 ptr->base_data.position.y -= 1; // Nudge
693 return ptr;
694 } else if(name == "morale_text") {
695 return make_element_by_type<lc_attacker_org_txt>(state, id);
696 } else if(name == "strength_text") {
697 return make_element_by_type<lc_attacker_str_txt>(state, id);
698 } else if(name == "unit_type_1") {
699 return make_element_by_type<lc_static_icon<0>>(state, id);
700 } else if(name == "unit_type_2") {
701 return make_element_by_type<lc_static_icon<1>>(state, id);
702 } else if(name == "unit_type_3") {
703 return make_element_by_type<lc_static_icon<2>>(state, id);
704 } else if(name == "unit_type_1_value") {
705 return make_element_by_type<lc_unit_strength_txt<true, military::unit_type::infantry>>(state, id);
706 } else if(name == "unit_type_2_value") {
707 return make_element_by_type<lc_unit_strength_txt<true, military::unit_type::cavalry>>(state, id);
708 } else if(name == "unit_type_3_value") {
709 return make_element_by_type<lc_unit_strength_txt<true, military::unit_type::support>>(state, id);
710 } else if(name == "modifiers") {
711 return make_element_by_type<attacker_combat_modifiers>(state, id);
712 } else {
713 return nullptr;
714 }
715 }
716};
717
719public:
720 void on_update(sys::state& state) noexcept override {
721 disabled = !command::can_retreat_from_land_battle(state, state.local_player_nation, retrieve<dcon::land_battle_id>(state, parent));
722 }
723 void button_action(sys::state& state) noexcept override {
724 command::retreat_from_land_battle(state, state.local_player_nation, retrieve<dcon::land_battle_id>(state, parent));
725 }
728 }
729 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
730 auto b = retrieve<dcon::land_battle_id>(state, parent);
731 text::add_line(state, contents, "alice_retreat");
732 text::add_line_with_condition(state, contents, "alice_retreat_1",
733 state.world.land_battle_get_start_date(b) + military::days_before_retreat < state.current_date,
735 text::add_line_with_condition(state, contents, "alice_retreat_2",
736 state.local_player_nation == military::get_land_battle_lead_attacker(state, b)
737 || state.local_player_nation == military::get_land_battle_lead_defender(state, b));
738 }
739};
740
742public:
743 void on_update(sys::state& state) noexcept override {
744 auto b = retrieve<dcon::land_battle_id>(state, parent);
745 auto loc = state.world.land_battle_get_location_from_land_battle_location(b);
746 auto name = state.world.province_get_name(loc);
748 set_text(state, txt);
749 }
750};
751
752enum class regiment_rank {
754};
755
757public:
759 int32_t slot = 0;
760 bool visible = false;
761
762 void on_update(sys::state& state) noexcept override {
763 auto color_from_nation = [&](dcon::nation_id n) {
764 if(n)
765 return state.world.nation_get_color(n);
766 else
767 return sys::pack_color(128, 128, 128);
768 };
769
770 auto b = retrieve<dcon::land_battle_id>(state, parent);
771 switch(rank) {
773 {
774 auto& row = state.world.land_battle_get_attacker_front_line(b);
775 auto reg = row.at(slot);
776 if(!reg) {
777 visible = false;
778 } else {
779 visible = true;
780 auto type = state.world.regiment_get_type(reg);
781 if(type) {
782 if(state.military_definitions.unit_base_definitions[type].type == military::unit_type::infantry) {
783 frame = 0;
784 } else if(state.military_definitions.unit_base_definitions[type].type == military::unit_type::cavalry) {
785 frame = 1;
786 } else if(state.military_definitions.unit_base_definitions[type].type == military::unit_type::special) {
787 frame = 2;
788 } else if(state.military_definitions.unit_base_definitions[type].type == military::unit_type::support) {
789 frame = 3;
790 }
791 }
792 color = color_from_nation(state.world.army_get_controller_from_army_control(state.world.regiment_get_army_from_army_membership(reg)));
793 }
794 }
795 break;
797 {
798 auto& row = state.world.land_battle_get_attacker_back_line(b);
799 auto reg = row.at(slot);
800 if(!reg) {
801 visible = false;
802 } else {
803 visible = true;
804 auto type = state.world.regiment_get_type(reg);
805 if(type) {
806 if(state.military_definitions.unit_base_definitions[type].type == military::unit_type::infantry) {
807 frame = 0;
808 } else if(state.military_definitions.unit_base_definitions[type].type == military::unit_type::cavalry) {
809 frame = 1;
810 } else if(state.military_definitions.unit_base_definitions[type].type == military::unit_type::special) {
811 frame = 2;
812 } else if(state.military_definitions.unit_base_definitions[type].type == military::unit_type::support) {
813 frame = 3;
814 }
815 }
816 color = color_from_nation(state.world.army_get_controller_from_army_control(state.world.regiment_get_army_from_army_membership(reg)));
817 }
818 }
819 break;
821 {
822 auto& row = state.world.land_battle_get_defender_front_line(b);
823 auto reg = row.at(slot);
824 if(!reg) {
825 visible = false;
826 } else {
827 visible = true;
828 auto type = state.world.regiment_get_type(reg);
829 if(type) {
830 if(state.military_definitions.unit_base_definitions[type].type == military::unit_type::infantry) {
831 frame = 0;
832 } else if(state.military_definitions.unit_base_definitions[type].type == military::unit_type::cavalry) {
833 frame = 1;
834 } else if(state.military_definitions.unit_base_definitions[type].type == military::unit_type::special) {
835 frame = 2;
836 } else if(state.military_definitions.unit_base_definitions[type].type == military::unit_type::support) {
837 frame = 3;
838 }
839 }
840 color = color_from_nation(state.world.army_get_controller_from_army_control(state.world.regiment_get_army_from_army_membership(reg)));
841 }
842 }
843 break;
845 {
846 auto& row = state.world.land_battle_get_defender_back_line(b);
847 auto reg = row.at(slot);
848 if(!reg) {
849 visible = false;
850 } else {
851 visible = true;
852 auto type = state.world.regiment_get_type(reg);
853 if(type) {
854 if(state.military_definitions.unit_base_definitions[type].type == military::unit_type::infantry) {
855 frame = 0;
856 } else if(state.military_definitions.unit_base_definitions[type].type == military::unit_type::cavalry) {
857 frame = 1;
858 } else if(state.military_definitions.unit_base_definitions[type].type == military::unit_type::special) {
859 frame = 2;
860 } else if(state.military_definitions.unit_base_definitions[type].type == military::unit_type::support) {
861 frame = 3;
862 }
863 }
864 color = color_from_nation(state.world.army_get_controller_from_army_control(state.world.regiment_get_army_from_army_membership(reg)));
865 }
866 }
867 break;
868 default:
869 break;
870 }
871 }
872
873 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
874 if(visible)
876 }
877
880 }
881 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
882 auto b = retrieve<dcon::land_battle_id>(state, parent);
883 dcon::regiment_id reg{};
884 switch(rank) {
886 reg = state.world.land_battle_get_attacker_front_line(b).at(slot);
887 break;
889 reg = state.world.land_battle_get_attacker_back_line(b).at(slot);
890 break;
892 reg = state.world.land_battle_get_defender_front_line(b).at(slot);
893 break;
895 reg = state.world.land_battle_get_defender_back_line(b).at(slot);
896 break;
897 default:
898 break;
899 }
900 auto utid = state.world.regiment_get_type(reg);
901 if(reg && utid) {
902 auto p = state.world.land_battle_get_location_from_land_battle_location(b);
903
904 auto box = text::open_layout_box(contents);
906 auto n = state.world.army_get_controller_from_army_control(state.world.regiment_get_army_from_army_membership(reg));
907 std::string tag_str = "";
908 if(bool(n)) {
909 tag_str = std::string("@") + nations::int_to_tag(dcon::fatten(state.world, n).get_identity_from_identity_holder().get_identifying_int());
911 text::add_to_substitution_map(sub, text::variable_type::m, std::string_view{ tag_str });
912 } else {
913 auto rf = state.world.army_get_controller_from_army_rebel_control(state.world.regiment_get_army_from_army_membership(reg));
914 if(bool(rf)) {
915 n = state.world.rebellion_within_get_ruler(state.world.rebel_faction_get_rebellion_within(rf));
916 if(!bool(n))
917 n = state.world.national_identity_get_nation_from_identity_holder(state.national_definitions.rebel_id);
918 }
919 tag_str = std::string("@") + nations::int_to_tag(dcon::fatten(state.world, n).get_identity_from_identity_holder().get_identifying_int());
920 tag_str += " " + rebel::rebel_name(state, rf);
921 text::add_to_substitution_map(sub, text::variable_type::m, std::string_view{ tag_str });
922 }
923 text::add_to_substitution_map(sub, text::variable_type::name, state.to_string_view(state.world.regiment_get_name(reg)));
924 text::add_to_substitution_map(sub, text::variable_type::type, state.military_definitions.unit_base_definitions[utid].name);
927 text::localised_format_box(state, contents, box, "alice_regiment_battle_info", sub);
928 text::close_layout_box(contents, box);
929
930 if(state.world.nation_get_unit_stats(n, utid).reconnaissance_or_fire_range > 0) {
931 text::add_line(state, contents, "unit_recon", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(n, utid).reconnaissance_or_fire_range, 2));
932 }
933 if(state.world.nation_get_unit_stats(n, utid).siege_or_torpedo_attack > 0) {
934 text::add_line(state, contents, "unit_siege", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(n, utid).siege_or_torpedo_attack, 2));
935 }
936 text::add_line(state, contents, "unit_attack", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(n, utid).attack_or_gun_power, 2));
937 text::add_line(state, contents, "unit_defence", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(n, utid).defence_or_hull, 2));
938 text::add_line(state, contents, "unit_discipline", text::variable_type::x, text::format_percentage(state.military_definitions.unit_base_definitions[utid].discipline_or_evasion, 0));
939 if(state.military_definitions.unit_base_definitions[utid].support > 0) {
940 text::add_line(state, contents, "unit_support", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(n, utid).support, 0));
941 }
942 text::add_line(state, contents, "unit_maneuver", text::variable_type::x, text::format_float(state.military_definitions.unit_base_definitions[utid].maneuver, 0));
943 text::add_line(state, contents, "unit_max_speed", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(n, utid).maximum_speed, 2));
944 text::add_line(state, contents, "unit_supply_consumption", text::variable_type::x, text::format_percentage(state.world.nation_get_unit_stats(n, utid).supply_consumption, 0));
945
946 }
947 }
948};
949
951public:
952 dcon::land_battle_id battle;
953
954 void on_create(sys::state& state) noexcept override {
956 state.ui_state.army_combat_window = this;
957
958 auto def = state.ui_state.defs_by_name.find(state.lookup_key("counter"))->second.definition;
959 for(int32_t i = 0; i < 30; ++i) {
960 int32_t s = (i < 15) ? 28 - i * 2 : (i - 15) * 2 + 1;
961 {
962 auto win = make_element_by_type<counter_ico>(state, def);
963 win->slot = s;
965 win->base_data.position.x = int16_t(21 + i * 12);
966 win->base_data.position.y = int16_t(231);
967 add_child_to_front(std::move(win));
968 }
969 {
970 auto win = make_element_by_type<counter_ico>(state, def);
971 win->slot = s;
973 win->base_data.position.x = int16_t(21 + i * 12);
974 win->base_data.position.y = int16_t(231 + 12);
975 add_child_to_front(std::move(win));
976 }
977 {
978 auto win = make_element_by_type<counter_ico>(state, def);
979 win->slot = s;
981 win->base_data.position.x = int16_t(21 + i * 12);
982 win->base_data.position.y = int16_t(321);
983 add_child_to_front(std::move(win));
984 }
985 {
986 auto win = make_element_by_type<counter_ico>(state, def);
987 win->slot = s;
989 win->base_data.position.x = int16_t(21 + i * 12);
990 win->base_data.position.y = int16_t(321 + 12);
991 add_child_to_front(std::move(win));
992 }
993 }
994
995 }
996
997 void on_update(sys::state& state) noexcept override {
998 sound::play_effect(state, sound::get_random_land_battle_sound(state), state.user_settings.effects_volume * state.user_settings.master_volume);
999 }
1000
1001 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1002 if(name == "combat_bg") {
1003 return make_element_by_type<opaque_element_base>(state, id);
1004 } else if(name == "combat_terrain1") {
1005 return make_element_by_type<province_terrain_image>(state, id);
1006 } else if(name == "label_battlename") {
1007 return make_element_by_type<lbattle_name>(state, id);
1008 } else if(name == "combat_retreat") {
1009 return make_element_by_type<lc_retreat_button>(state, id);
1010 } else if(name == "closebutton") {
1011 return make_element_by_type<generic_close_button>(state, id);
1012 } else if(name == "attacker") {
1013 return make_element_by_type<land_combat_attacker_window>(state, id);
1014 } else if(name == "defender") {
1015 return make_element_by_type<land_combat_defender_window>(state, id);
1016
1017 } else {
1018 return nullptr;
1019 }
1020 }
1021
1022 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
1023 if(payload.holds_type<dcon::land_battle_id>()) {
1024 payload.emplace<dcon::land_battle_id>(battle);
1026 } else if(payload.holds_type<dcon::province_id>()) {
1027 payload.emplace<dcon::province_id>(state.world.land_battle_get_location_from_land_battle_location(battle));
1029 }
1030 return window_element_base::get(state, payload);
1031 }
1032};
1033
1034//===============================================================================================================================
1035
1037 bool visible = true;
1038 void on_update(sys::state& state) noexcept override {
1039 visible = !(retrieve< military::land_battle_report*>(state, parent)->player_on_winning_side);
1040 }
1041 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
1042 if(visible)
1044 }
1045};
1047 bool visible = true;
1048 void on_update(sys::state& state) noexcept override {
1049 visible = (retrieve< military::land_battle_report*>(state, parent)->player_on_winning_side);
1050 }
1051 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
1052 if(visible)
1054 }
1055};
1057 void on_update(sys::state& state) noexcept override {
1058 auto loc = retrieve< military::land_battle_report*>(state, parent)->location;
1059 auto name = state.world.province_get_name(loc);
1060 auto txt = text::produce_simple_string(state, "battle_of") + " " + text::produce_simple_string(state, name);
1061 set_text(state, txt);
1062 }
1063};
1064
1066 dcon::gfx_object_id def;
1067
1068 void on_update(sys::state& state) noexcept override {
1069 if(!def)
1071
1072 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1073 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1074 dcon::leader_id lid = we_are_attacker ? report->attacking_general : report->defending_general;
1075
1076 if(!lid) {
1078 return;
1079 }
1080
1081 auto owner = state.world.leader_get_nation_from_leader_loyalty(lid);
1082 auto pculture = state.world.nation_get_primary_culture(owner);
1083 auto ltype = pculture.get_group_from_culture_group_membership().get_leader();
1084
1085 if(ltype) {
1086 auto grange = ltype.get_generals();
1087 if(grange.size() > 0) {
1088 auto rval = rng::get_random(state, uint32_t(state.world.leader_get_since(lid).value), uint32_t(lid.value));
1089 auto in_range = rng::reduce(uint32_t(rval), grange.size());
1090 base_data.data.image.gfx_object = grange[in_range];
1091 }
1092 }
1093 }
1094
1095 tooltip_behavior has_tooltip(sys::state& state) noexcept override {
1097 }
1098
1099 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1100 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1101 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1102 dcon::leader_id lid = we_are_attacker ? report->attacking_general : report->defending_general;
1103
1104 if(lid)
1105 display_leader_attributes(state, lid, contents, 0);
1106 else
1107 text::add_line(state, contents, "no_leader");
1108 }
1109};
1111public:
1112 void on_update(sys::state& state) noexcept override {
1113 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1114 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1115 dcon::leader_id lid = we_are_attacker ? report->attacking_general : report->defending_general;
1116
1117 if(lid) {
1118 auto name = state.to_string_view(state.world.leader_get_name(lid));
1119 set_text(state, std::string(name));
1120 } else {
1122 }
1123 }
1124};
1126 dcon::gfx_object_id def;
1127
1128 void on_update(sys::state& state) noexcept override {
1129 if(!def)
1131
1132 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1133 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1134 dcon::leader_id lid = !we_are_attacker ? report->attacking_general : report->defending_general;
1135
1136 if(!lid) {
1138 return;
1139 }
1140
1141 auto owner = state.world.leader_get_nation_from_leader_loyalty(lid);
1142 auto pculture = state.world.nation_get_primary_culture(owner);
1143 auto ltype = pculture.get_group_from_culture_group_membership().get_leader();
1144
1145 if(ltype) {
1146 auto grange = ltype.get_generals();
1147 if(grange.size() > 0) {
1148 auto rval = rng::get_random(state, uint32_t(state.world.leader_get_since(lid).value), uint32_t(lid.value));
1149 auto in_range = rng::reduce(uint32_t(rval), grange.size());
1150 base_data.data.image.gfx_object = grange[in_range];
1151 }
1152 }
1153 }
1154
1155 tooltip_behavior has_tooltip(sys::state& state) noexcept override {
1157 }
1158
1159 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1160 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1161 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1162 dcon::leader_id lid = !we_are_attacker ? report->attacking_general : report->defending_general;
1163
1164 if(lid)
1165 display_leader_attributes(state, lid, contents, 0);
1166 else
1167 text::add_line(state, contents, "no_leader");
1168 }
1169};
1171public:
1172 void on_update(sys::state& state) noexcept override {
1173 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1174 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1175 dcon::leader_id lid = !we_are_attacker ? report->attacking_general : report->defending_general;
1176
1177 if(lid) {
1178 auto name = state.to_string_view(state.world.leader_get_name(lid));
1179 set_text(state, std::string(name));
1180 } else {
1182 }
1183 }
1184};
1186public:
1187 void on_update(sys::state& state) noexcept override {
1188 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1189 auto prestige_value = report->prestige_effect;
1190 set_text(state, text::format_float(prestige_value, 2));
1191 if(prestige_value > 0) {
1193 } else if(prestige_value < 0) {
1195 } else {
1197 }
1198 }
1199};
1201public:
1202 void on_update(sys::state& state) noexcept override {
1203 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1204 auto prestige_value = -report->prestige_effect;
1205 set_text(state, text::format_float(prestige_value, 2));
1206 if(prestige_value > 0) {
1208 } else if(prestige_value < 0) {
1210 } else {
1212 }
1213 }
1214};
1216 void on_update(sys::state& state) noexcept override {
1217 set_text(state, "");
1218 }
1219};
1221 void on_update(sys::state& state) noexcept override {
1222 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1223 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1224 auto value = we_are_attacker ? report->attacker_infantry : report->defender_infantry;
1225 set_text(state, text::prettify(int64_t(value * state.defines.pop_size_per_regiment)));
1226 }
1227};
1229 void on_update(sys::state& state) noexcept override {
1230 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1231 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1232 auto value = we_are_attacker ? report->attacker_cavalry : report->defender_cavalry;
1233 set_text(state, text::prettify(int64_t(value * state.defines.pop_size_per_regiment)));
1234 }
1235};
1237 void on_update(sys::state& state) noexcept override {
1238 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1239 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1240 auto value = we_are_attacker ? report->attacker_support : report->defender_support;
1241 set_text(state, text::prettify(int64_t(value * state.defines.pop_size_per_regiment)));
1242 }
1243};
1245 void on_update(sys::state& state) noexcept override {
1246 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1247 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1248 auto value = !we_are_attacker ? report->attacker_infantry : report->defender_infantry;
1249 set_text(state, text::prettify(int64_t(value * state.defines.pop_size_per_regiment)));
1250 }
1251};
1253 void on_update(sys::state& state) noexcept override {
1254 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1255 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1256 auto value = !we_are_attacker ? report->attacker_cavalry : report->defender_cavalry;
1257 set_text(state, text::prettify(int64_t(value * state.defines.pop_size_per_regiment)));
1258 }
1259};
1261 void on_update(sys::state& state) noexcept override {
1262 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1263 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1264 auto value = !we_are_attacker ? report->attacker_support : report->defender_support;
1265 set_text(state, text::prettify(int64_t(value * state.defines.pop_size_per_regiment)));
1266 }
1267};
1269 void on_update(sys::state& state) noexcept override {
1270 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1271 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1272 auto value = we_are_attacker ? std::min(report->attacker_infantry, report->attacker_infantry_losses) : std::min(report->defender_infantry, report->defender_infantry_losses);
1273 set_text(state, text::prettify(-int64_t(value * state.defines.pop_size_per_regiment)));
1274 }
1275};
1277 void on_update(sys::state& state) noexcept override {
1278 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1279 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1280 auto value = we_are_attacker ? std::min(report->attacker_cavalry, report->attacker_cavalry_losses) : std::min(report->defender_cavalry, report->defender_cavalry_losses);
1281 set_text(state, text::prettify(-int64_t(value * state.defines.pop_size_per_regiment)));
1282 }
1283};
1285 void on_update(sys::state& state) noexcept override {
1286 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1287 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1288 auto value = we_are_attacker ? std::min(report->attacker_support, report->attacker_support_losses) : std::min(report->defender_support, report->defender_support_losses);
1289 set_text(state, text::prettify(-int64_t(value * state.defines.pop_size_per_regiment)));
1290 }
1291};
1293 void on_update(sys::state& state) noexcept override {
1294 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1295 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1296 auto value = !we_are_attacker ? std::min(report->attacker_infantry, report->attacker_infantry_losses) : std::min(report->defender_infantry, report->defender_infantry_losses);
1297 set_text(state, text::prettify(-int64_t(value * state.defines.pop_size_per_regiment)));
1298 }
1299};
1301 void on_update(sys::state& state) noexcept override {
1302 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1303 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1304 auto value = !we_are_attacker ? std::min(report->attacker_cavalry, report->attacker_cavalry_losses) : std::min(report->defender_cavalry, report->defender_cavalry_losses);
1305 set_text(state, text::prettify(-int64_t(value * state.defines.pop_size_per_regiment)));
1306 }
1307};
1309 void on_update(sys::state& state) noexcept override {
1310 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1311 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1312 auto value = !we_are_attacker ? std::min(report->attacker_support, report->attacker_support_losses) : std::min(report->defender_support, report->defender_support_losses);
1313 set_text(state, text::prettify(-int64_t(value * state.defines.pop_size_per_regiment)));
1314 }
1315};
1317 void on_update(sys::state& state) noexcept override {
1318 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1319 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1320 auto value = we_are_attacker ? std::max(report->attacker_infantry - report->attacker_infantry_losses, 0.0f) : std::max(report->defender_infantry - report->defender_infantry_losses, 0.0f);
1321 set_text(state, text::prettify(int64_t(value * state.defines.pop_size_per_regiment)));
1322 }
1323};
1325 void on_update(sys::state& state) noexcept override {
1326 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1327 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1328 auto value = we_are_attacker ? std::max(report->attacker_cavalry - report->attacker_cavalry_losses, 0.0f) : std::max(report->defender_cavalry - report->defender_cavalry_losses, 0.0f);
1329 set_text(state, text::prettify(int64_t(value * state.defines.pop_size_per_regiment)));
1330 }
1331};
1333 void on_update(sys::state& state) noexcept override {
1334 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1335 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1336 auto value = we_are_attacker ? std::max(report->attacker_support - report->attacker_support_losses, 0.0f) : std::max(report->defender_support - report->defender_support_losses, 0.0f);
1337 set_text(state, text::prettify(int64_t(value * state.defines.pop_size_per_regiment)));
1338 }
1339};
1341 void on_update(sys::state& state) noexcept override {
1342 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1343 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1344 auto value = !we_are_attacker ? std::max(report->attacker_infantry - report->attacker_infantry_losses, 0.0f) : std::max(report->defender_infantry - report->defender_infantry_losses, 0.0f);
1345 set_text(state, text::prettify(int64_t(value * state.defines.pop_size_per_regiment)));
1346 }
1347};
1349 void on_update(sys::state& state) noexcept override {
1350 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1351 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1352 auto value = !we_are_attacker ? std::max(report->attacker_cavalry - report->attacker_cavalry_losses, 0.0f) : std::max(report->defender_cavalry - report->defender_cavalry_losses, 0.0f);
1353 set_text(state, text::prettify(int64_t(value * state.defines.pop_size_per_regiment)));
1354 }
1355};
1357 void on_update(sys::state& state) noexcept override {
1358 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1359 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1360 auto value = !we_are_attacker ? std::max(report->attacker_support - report->attacker_support_losses, 0.0f) : std::max(report->defender_support - report->defender_support_losses, 0.0f);
1361 set_text(state, text::prettify(int64_t(value * state.defines.pop_size_per_regiment)));
1362 }
1363};
1364
1366 void on_update(sys::state& state) noexcept override {
1367 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1368 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1369 auto value = we_are_attacker ? report->attacker_infantry + report->attacker_cavalry + report->attacker_support : report->defender_infantry + report->defender_cavalry + report->defender_support;
1370 set_text(state, text::prettify(int64_t(value * state.defines.pop_size_per_regiment)));
1371 }
1372};
1374 void on_update(sys::state& state) noexcept override {
1375 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1376 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1377 auto value = we_are_attacker ? std::min(report->attacker_infantry + report->attacker_cavalry + report->attacker_support, report->attacker_infantry_losses + report->attacker_cavalry_losses + report->attacker_support_losses) : std::min(report->defender_infantry + report->defender_cavalry + report->defender_support, report->defender_infantry_losses + report->defender_cavalry_losses + report->defender_support_losses);
1378 set_text(state, text::prettify(-int64_t(value * state.defines.pop_size_per_regiment)));
1379 }
1380};
1382 void on_update(sys::state& state) noexcept override {
1383 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1384 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1385 auto value = we_are_attacker ? std::max(report->attacker_infantry + report->attacker_cavalry + report->attacker_support - (report->attacker_infantry_losses + report->attacker_cavalry_losses + report->attacker_support_losses), 0.0f) : std::max(report->defender_infantry + report->defender_cavalry + report->defender_support - (report->defender_infantry_losses + report->defender_cavalry_losses + report->defender_support_losses), 0.0f);
1386 set_text(state, text::prettify(int64_t(value * state.defines.pop_size_per_regiment)));
1387 }
1388};
1390 void on_update(sys::state& state) noexcept override {
1391 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1392 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1393 auto value = !we_are_attacker ? report->attacker_infantry + report->attacker_cavalry + report->attacker_support : report->defender_infantry + report->defender_cavalry + report->defender_support;
1394 set_text(state, text::prettify(int64_t(value * state.defines.pop_size_per_regiment)));
1395 }
1396};
1398 void on_update(sys::state& state) noexcept override {
1399 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1400 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1401 auto value = !we_are_attacker ? std::min(report->attacker_infantry + report->attacker_cavalry + report->attacker_support, report->attacker_infantry_losses + report->attacker_cavalry_losses + report->attacker_support_losses) : std::min(report->defender_infantry + report->defender_cavalry + report->defender_support, report->defender_infantry_losses + report->defender_cavalry_losses + report->defender_support_losses);
1402 set_text(state, text::prettify(-int64_t(value * state.defines.pop_size_per_regiment)));
1403 }
1404};
1406 void on_update(sys::state& state) noexcept override {
1407 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1408 bool we_are_attacker = (report->attacker_won == report->player_on_winning_side);
1409 auto value = !we_are_attacker ? std::max(report->attacker_infantry + report->attacker_cavalry + report->attacker_support - (report->attacker_infantry_losses + report->attacker_cavalry_losses + report->attacker_support_losses), 0.0f) : std::max(report->defender_infantry + report->defender_cavalry + report->defender_support - (report->defender_infantry_losses + report->defender_cavalry_losses + report->defender_support_losses), 0.0f);
1410 set_text(state, text::prettify(int64_t(value * state.defines.pop_size_per_regiment)));
1411 }
1412};
1414 void button_action(sys::state& state) noexcept override {
1415 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1416 auto prov = report->location;
1417 if(prov && prov.value < state.province_definitions.first_sea_province.value) {
1418 state.map_state.set_selected_province(prov);
1419 static_cast<ui::province_view_window*>(state.ui_state.province_window)->set_active_province(state, prov);
1420 if(state.map_state.get_zoom() < map::zoom_very_close)
1421 state.map_state.zoom = map::zoom_very_close;
1422 state.map_state.center_map_on_province(state, prov);
1423 }
1424 }
1425};
1426
1428 void button_action(sys::state& state) noexcept override;
1429};
1431 void on_update(sys::state& state) noexcept override {
1432 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1433 if(report->player_on_winning_side) {
1436 } else {
1439 }
1440 }
1441};
1443 void on_update(sys::state& state) noexcept override {
1444 military::land_battle_report* report = retrieve< military::land_battle_report*>(state, parent);
1445 if(report->player_on_winning_side) {
1446 set_text(state, std::string("+") + text::format_float(report->warscore_effect, 1));
1448 } else {
1451 }
1452 }
1453};
1454
1456public:
1458 static std::vector<std::unique_ptr<ui::land_combat_end_popup>> land_reports_pool;
1459
1460
1461 message_result get(sys::state& state, Cyto::Any& payload) noexcept override;
1463 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override;
1464};
1465
1466inline std::vector<std::unique_ptr<ui::land_combat_end_popup>> land_combat_end_popup::land_reports_pool;
1467
1469 if(payload.holds_type<military::land_battle_report*>()) {
1470 payload.emplace<military::land_battle_report*>(&report);
1472 }
1473 return window_element_base::get(state, payload);
1474}
1475
1477 if(land_reports_pool.empty()) {
1478 auto new_elm = ui::make_element_by_type<ui::land_combat_end_popup>(state, "endoflandcombatpopup");
1479 auto ptr = new_elm.get();
1480 land_combat_end_popup* actual = static_cast<land_combat_end_popup*>(ptr);
1481 actual->report = r;
1482 actual->impl_on_update(state);
1483 state.ui_state.root->add_child_to_front(std::move(new_elm));
1484 } else {
1485 std::unique_ptr<land_combat_end_popup> ptr = std::move(land_reports_pool.back());
1486 land_reports_pool.pop_back();
1487 ptr->report = r;
1488 ptr->set_visible(state, true);
1489 state.ui_state.root->add_child_to_front(std::move(ptr));
1490 }
1491}
1492
1493inline std::unique_ptr<element_base> land_combat_end_popup::make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept {
1494 if(name == "background") {
1495 return make_element_by_type<draggable_target>(state, id);
1496 } else if(name == "combat_end_land_lost") {
1497 return make_element_by_type<lc_loss_image>(state, id);
1498 } else if(name == "combat_end_land_won") {
1499 return make_element_by_type<lc_win_image>(state, id);
1500 } else if(name == "line1") {
1501 return make_element_by_type<lc_result_battle_name>(state, id);
1502 } else if(name == "ourleader_photo") {
1503 return make_element_by_type<lc_our_leader_img>(state, id);
1504 } else if(name == "ourleader") {
1505 return make_element_by_type<lc_our_leader_name>(state, id);
1506 } else if(name == "prestige_number") {
1507 return make_element_by_type<lc_our_prestige>(state, id);
1508 } else if(name == "we_number") {
1509 return make_element_by_type<lc_empty_text>(state, id);
1510 } else if(name == "enemyleader_photo") {
1511 return make_element_by_type<lc_their_leader_img>(state, id);
1512 } else if(name == "enemyleader") {
1513 return make_element_by_type<lc_their_leader_name>(state, id);
1514 } else if(name == "prestige_number2") {
1515 return make_element_by_type<lc_their_prestige>(state, id);
1516 } else if(name == "we_number2") {
1517 return make_element_by_type<lc_empty_text>(state, id);
1518 } else if(name == "our_unit_type_1") {
1519 return make_element_by_type<lc_static_icon<0>>(state, id);
1520 } else if(name == "our_unit_type_1_1_text") {
1521 return make_element_by_type<lc_o_initial_inf>(state, id);
1522 } else if(name == "our_unit_type_1_2_text") {
1523 return make_element_by_type<lc_o_loss_inf>(state, id);
1524 } else if(name == "our_unit_type_1_3_text") {
1525 return make_element_by_type<lc_o_rem_inf>(state, id);
1526 } else if(name == "our_unit_type_2") {
1527 return make_element_by_type<lc_static_icon<1>>(state, id);
1528 } else if(name == "our_unit_type_2_1_text") {
1529 return make_element_by_type<lc_o_initial_cav>(state, id);
1530 } else if(name == "our_unit_type_2_2_text") {
1531 return make_element_by_type<lc_o_loss_cav>(state, id);
1532 } else if(name == "our_unit_type_2_3_text") {
1533 return make_element_by_type<lc_o_rem_cav>(state, id);
1534 } else if(name == "our_unit_type_3") {
1535 return make_element_by_type<lc_static_icon<2>>(state, id);
1536 } else if(name == "our_unit_type_3_1_text") {
1537 return make_element_by_type<lc_o_initial_art>(state, id);
1538 } else if(name == "our_unit_type_3_2_text") {
1539 return make_element_by_type<lc_o_loss_art>(state, id);
1540 } else if(name == "our_unit_type_3_3_text") {
1541 return make_element_by_type<lc_o_rem_art>(state, id);
1542 } else if(name == "enemy_unit_type_1") {
1543 return make_element_by_type<lc_static_icon<0>>(state, id);
1544 } else if(name == "enemy_unit_type_1_1_text") {
1545 return make_element_by_type<lc_t_initial_inf>(state, id);
1546 } else if(name == "enemy_unit_type_1_2_text") {
1547 return make_element_by_type<lc_t_loss_inf>(state, id);
1548 } else if(name == "enemy_unit_type_1_3_text") {
1549 return make_element_by_type<lc_t_rem_inf>(state, id);
1550 } else if(name == "enemy_unit_type_2") {
1551 return make_element_by_type<lc_static_icon<1>>(state, id);
1552 } else if(name == "enemy_unit_type_2_1_text") {
1553 return make_element_by_type<lc_t_initial_cav>(state, id);
1554 } else if(name == "enemy_unit_type_2_2_text") {
1555 return make_element_by_type<lc_t_loss_cav>(state, id);
1556 } else if(name == "enemy_unit_type_2_3_text") {
1557 return make_element_by_type<lc_t_rem_cav>(state, id);
1558 } else if(name == "enemy_unit_type_3") {
1559 return make_element_by_type<lc_static_icon<2>>(state, id);
1560 } else if(name == "enemy_unit_type_3_1_text") {
1561 return make_element_by_type<lc_t_initial_art>(state, id);
1562 } else if(name == "enemy_unit_type_3_2_text") {
1563 return make_element_by_type<lc_t_loss_art>(state, id);
1564 } else if(name == "enemy_unit_type_3_3_text") {
1565 return make_element_by_type<lc_t_rem_art>(state, id);
1566 } else if(name == "our_total_armies") {
1567 return make_element_by_type<lc_o_initial_total>(state, id);
1568 } else if(name == "our_total_loss") {
1569 return make_element_by_type<lc_o_loss_total>(state, id);
1570 } else if(name == "our_total_left") {
1571 return make_element_by_type<lc_o_rem_total>(state, id);
1572 } else if(name == "enemy_total_armies") {
1573 return make_element_by_type<lc_t_initial_total>(state, id);
1574 } else if(name == "enemy_total_loss") {
1575 return make_element_by_type<lc_t_loss_total>(state, id);
1576 } else if(name == "enemy_total_left") {
1577 return make_element_by_type<lc_t_rem_total>(state, id);
1578 } else if(name == "agreebutton") {
1579 auto ptr = make_element_by_type<lc_close_button>(state, id);
1580 ptr->base_data.position.y += 146; // Nudge
1581 return ptr;
1582 } else if(name == "declinebutton") {
1583 auto ptr = make_element_by_type<lc_goto_location_button>(state, id);
1584 ptr->base_data.position.y += 146; // Nudge
1585 ptr->set_button_text(state, text::produce_simple_string(state, "landbattleover_btn3"));
1586 return ptr;
1587 } else if(name == "centerok") {
1588 return make_element_by_type<invisible_element>(state, id);
1589 } else if(name == "warscore") {
1590 auto ptr = make_element_by_type<lc_warscore>(state, id);
1591 return ptr;
1592 } else if(name == "winorlose") {
1593 auto ptr = make_element_by_type<lc_win_lose>(state, id);
1594 return ptr;
1595 } else {
1596 return nullptr;
1597 }
1598}
1599
1600inline void lc_close_button::button_action(sys::state& state) noexcept {
1601 parent->set_visible(state, false);
1602 auto uptr = state.ui_state.root->remove_child(parent);
1603 assert(uptr);
1604 std::unique_ptr<land_combat_end_popup> ptr(static_cast<land_combat_end_popup*>(uptr.release()));
1605 land_combat_end_popup::land_reports_pool.push_back(std::move(ptr));
1606}
1607
1608
1609} // namespace ui
void add_child_to_front(std::unique_ptr< element_base > child) noexcept final
void impl_on_update(sys::state &state) noexcept override
regiment_rank rank
void on_update(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
element_base * parent
virtual message_result get(sys::state &state, Cyto::Any &payload) noexcept
element_data base_data
void on_create(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_create(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
static void make_new_report(sys::state &state, military::land_battle_report const &r)
military::land_battle_report report
static std::vector< std::unique_ptr< ui::land_combat_end_popup > > land_reports_pool
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
dcon::land_battle_id battle
void on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
dcon::national_identity_id get_current_nation(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
dcon::national_identity_id get_current_nation(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
lc_modifier_data data
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void set_text(sys::state &state, std::string const &new_text)
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_create(sys::state &state) noexcept override
#define assert(condition)
Definition: debug.h:74
void retreat_from_land_battle(sys::state &state, dcon::nation_id source, dcon::land_battle_id b)
Definition: commands.cpp:4228
bool can_retreat_from_land_battle(sys::state &state, dcon::nation_id source, dcon::land_battle_id b)
Definition: commands.cpp:4237
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
constexpr float zoom_very_close
Definition: constants.hpp:606
constexpr uint8_t defender_bonus_crossing_none
Definition: military.hpp:88
constexpr uint8_t defender_bonus_crossing_river
Definition: military.hpp:89
war_role get_role(sys::state const &state, dcon::war_id w, dcon::nation_id n)
Definition: military.cpp:2242
constexpr uint8_t defender_bonus_dig_in_mask
Definition: military.hpp:91
dcon::nation_id get_land_battle_lead_attacker(sys::state &state, dcon::land_battle_id b)
Definition: military.cpp:4279
constexpr uint8_t defender_bonus_crossing_mask
Definition: military.hpp:87
constexpr int32_t days_before_retreat
Definition: military.hpp:257
dcon::nation_id get_land_battle_lead_defender(sys::state &state, dcon::land_battle_id b)
Definition: military.cpp:4310
std::string int_to_tag(uint32_t v)
Definition: nations.hpp:10
void render_masked_rect(sys::state const &state, color_modification enabled, float x, float y, float width, float height, GLuint texture_handle, GLuint mask_texture_handle, ui::rotation r, bool flipped, bool rtl)
GLuint get_texture_handle(sys::state &state, dcon::texture_id id, bool keep_data)
Definition: texture.cpp:665
std::string rebel_name(sys::state &state, dcon::rebel_faction_id reb)
Definition: rebels.cpp:1274
uint32_t reduce(uint32_t value_in, uint32_t upper_bound)
Definition: prng.cpp:46
uint64_t get_random(sys::state const &state, uint32_t value_in)
Definition: prng.cpp:8
audio_instance & get_random_land_battle_sound(sys::state &state)
Definition: sound_nix.cpp:397
void play_effect(sys::state &state, audio_instance &s, float volume)
Definition: sound_nix.cpp:198
uint32_t pack_color(float r, float g, float b)
void add_to_layout_box(sys::state &state, layout_base &dest, layout_box &box, embedded_flag ico)
Definition: text.cpp:1165
layout_box open_layout_box(layout_base &dest, int32_t indent)
Definition: text.cpp:1799
void localised_format_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view key, text::substitution_map const &sub)
Definition: text.cpp:1880
std::string prettify(int64_t num)
Definition: text.cpp:762
endless_layout create_endless_layout(sys::state &state, layout &dest, layout_parameters const &params)
Definition: text.cpp:1100
std::string format_float(float num, size_t digits)
Definition: text.cpp:981
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
Definition: text.cpp:1899
void add_line_with_condition(sys::state &state, layout_base &dest, std::string_view key, bool condition_met, int32_t indent)
Definition: text.cpp:1955
void add_to_substitution_map(substitution_map &mp, variable_type key, substitution value)
Definition: text.cpp:1068
ankerl::unordered_dense::map< uint32_t, substitution > substitution_map
Definition: text.hpp:794
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
Definition: text.cpp:617
dcon::text_key get_name(sys::state &state, dcon::nation_id id)
Definition: text.cpp:880
std::string format_percentage(float num, size_t digits)
Definition: text.cpp:977
void close_layout_box(columnar_layout &dest, layout_box &box)
Definition: text.cpp:1807
void display_leader_attributes(sys::state &state, dcon::leader_id lid, text::layout_base &contents, int32_t indent)
tooltip_behavior
@ count
Definition: gui_event.hpp:126
message_result
ogl::color_modification get_color_modification(bool is_under_mouse, bool is_disabled, bool is_interactable)
uint uint32_t
ulong uint64_t
dcon::leader_id attacking_general
Definition: military.hpp:245
dcon::leader_id defending_general
Definition: military.hpp:246
dcon::province_id location
Definition: military.hpp:251
dcon::gfx_object_id button_image
element_type get_element_type() const
rotation get_rotation() const
union ui::element_data::internal_data data
dcon::gfx_object_id gfx_object
ankerl::unordered_dense::map< dcon::text_key, element_target, hash_text_key > defs_by_name
std::unique_ptr< element_base > root
element_base * province_window
element_base * army_combat_window
element_base * under_mouse