Project Alice
Loading...
Searching...
No Matches
gui_map_icons.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "dcon_generated.hpp"
5#include "gui_graphics.hpp"
6#include "province.hpp"
7#include "text.hpp"
8#include "unit_tooltip.hpp"
9#include "gui_land_combat.hpp"
10#include "gui_naval_combat.hpp"
11
12namespace ui {
13
14inline constexpr float big_counter_cutoff = 15.0f;
15inline constexpr float prov_details_cutoff = 18.0f;
16
19};
20
21template<bool IsNear>
23 bool visible = false;
24
25 void on_update(sys::state& state) noexcept override {
26 visible = retrieve<int32_t>(state, parent) > 0;
27 frame = int32_t(retrieve<outline_color>(state, parent));
28 }
29
30 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
31 if(visible && (state.map_state.get_zoom() >= big_counter_cutoff) == IsNear)
33 }
34 mouse_probe impl_probe_mouse(sys::state& state, int32_t x, int32_t y, mouse_probe_type type) noexcept override {
35 if(visible && (state.map_state.get_zoom() >= big_counter_cutoff) == IsNear)
37 else
38 return mouse_probe{ nullptr, ui::xy_pair{} };
39 }
40 void button_shift_action(sys::state& state) noexcept override {
41 if(visible && (state.map_state.get_zoom() >= big_counter_cutoff) == IsNear)
43 }
44 void button_action(sys::state& state) noexcept override {
45 if(visible && (state.map_state.get_zoom() >= big_counter_cutoff) == IsNear)
47 }
48};
49
50template<bool IsNear>
52 bool visible = false;
53
54 void on_update(sys::state& state) noexcept override {
55 visible = retrieve<int32_t>(state, parent) == 0;
56 frame = int32_t(retrieve<outline_color>(state, parent));
57 }
58
59 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
60 if(visible && (state.map_state.get_zoom() >= big_counter_cutoff) == IsNear)
62 }
63};
64
66public:
67 bool visible = false;
68 int32_t level = 1;
69
70 void on_update(sys::state& state) noexcept override {
71 auto prov = retrieve<dcon::province_id>(state, parent);
72 auto port_level = state.world.province_get_building_level(prov, uint8_t(economy::province_building_type::naval_base));
73 visible = port_level >= level;
74 frame = int32_t(retrieve<outline_color>(state, parent));
75 }
76 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
77 if(visible && state.map_state.get_zoom() >= big_counter_cutoff)
79 }
80};
81
82template<bool IsNear>
84public:
85 void on_update(sys::state& state) noexcept override {
86 int32_t count = retrieve<int32_t>(state, parent);
88 if(count <= 0) {
89 set_text(state, "");
90 } else {
91 set_text(state, std::to_string(count));
92 }
93 }
94 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
95 if((state.map_state.get_zoom() >= big_counter_cutoff) == IsNear)
97 }
98};
99
101public:
102 bool visible = true;
103 bool populated = false;
104 float map_x = 0;
105 float map_y = 0;
106 dcon::province_id port_for;
108 int32_t displayed_count = 0;
109
110 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
111 if(name == "level1") {
112 auto ptr = make_element_by_type<port_level_bar>(state, id);
113 ptr->level = 1;
114 return ptr;
115 } else if(name == "level2") {
116 auto ptr = make_element_by_type<port_level_bar>(state, id);
117 ptr->level = 2;
118 return ptr;
119 } else if(name == "level3") {
120 auto ptr = make_element_by_type<port_level_bar>(state, id);
121 ptr->level = 3;
122 return ptr;
123 } else if(name == "level4") {
124 auto ptr = make_element_by_type<port_level_bar>(state, id);
125 ptr->level = 4;
126 return ptr;
127 } else if(name == "level5") {
128 auto ptr = make_element_by_type<port_level_bar>(state, id);
129 ptr->level = 5;
130 return ptr;
131 } else if(name == "level6") {
132 auto ptr = make_element_by_type<port_level_bar>(state, id);
133 ptr->level = 6;
134 return ptr;
135 } else if(name == "ship_count") {
136 return make_element_by_type<port_ship_count<true>>(state, id);
137 } else if(name == "port_minimized") {
138 return make_element_by_type<port_sm_bg<true>>(state, id);
139 } else if(name == "port_expanded") {
140 return make_element_by_type<port_ex_bg<true>>(state, id);
141 } else if(name == "port_collapsed_small") {
142 return make_element_by_type<port_ex_bg<false>>(state, id);
143 } else if(name == "port_collapsed_small_icon") {
144 return make_element_by_type<port_sm_bg<false>>(state, id);
145 } else if(name == "collapsed_ship_count") {
146 return make_element_by_type<port_ship_count<false>>(state, id);
147 } else {
148 return nullptr;
149 }
150 }
151
152 void set_province(sys::state& state, dcon::province_id p) {
153 port_for = p;
154
155 auto adj = state.world.get_province_adjacency_by_province_pair(p, state.world.province_get_port_to(p));
156 assert(adj);
157 auto id = adj.index();
158 auto& border = state.map_state.map_data.borders[id];
159 auto& vertex = state.map_state.map_data.border_vertices[border.start_index + border.count / 2];
160
161 map_x = vertex.position.x;
162 map_y = vertex.position.y;
163 }
164
165 void on_update(sys::state& state) noexcept override {
166
167 auto navies = state.world.province_get_navy_location(port_for);
168 if(state.world.province_get_building_level(port_for, uint8_t(economy::province_building_type::naval_base)) == 0 && navies.begin() == navies.end()) {
169 populated = false;
170 return;
171 }
172
173 populated = true;
174 displayed_count = 0;
175
176 if(navies.begin() == navies.end()) {
177 auto controller = state.world.province_get_nation_from_province_control(port_for);
178 if(controller == state.local_player_nation) {
180 } else if(!controller || military::are_at_war(state, controller, state.local_player_nation)) {
182 } else if(military::are_allied_in_war(state, controller, state.local_player_nation)) {
184 } else {
186 }
187 } else {
188 bool player_navy = false;
189 bool allied_navy = false;
190 bool enemy_navy = false;
191 bool selected_navy = false;
192 for(auto n : navies) {
193 auto controller = n.get_navy().get_controller_from_navy_control();
194 if(state.is_selected(n.get_navy())) {
195 selected_navy = true;
196 } else if(controller == state.local_player_nation) {
197 player_navy = true;
198 } else if(!controller || military::are_at_war(state, controller, state.local_player_nation)) {
199 enemy_navy = true;
200 } else if(military::are_allied_in_war(state, controller, state.local_player_nation)) {
201 allied_navy = true;;
202 }
203
204 auto srange = n.get_navy().get_navy_membership();
205 int32_t num_ships = int32_t(srange.end() - srange.begin());
206 displayed_count += num_ships;
207 }
208
209 if(selected_navy) {
211 } else if(player_navy) {
213 } else if(enemy_navy) {
215 } else if(allied_navy) {
217 } else {
219 }
220 }
221
222 }
223
224 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
225 if(populated) {
226 glm::vec2 map_pos(map_x, 1.0f - map_y);
227 auto screen_size =
228 glm::vec2{ float(state.x_size / state.user_settings.ui_scale), float(state.y_size / state.user_settings.ui_scale) };
229 glm::vec2 screen_pos;
230 if(!state.map_state.map_to_screen(state, map_pos, screen_size, screen_pos)) {
231 visible = false;
232 return;
233 }
234 if(!state.map_state.visible_provinces[province::to_map_id(port_for)]) {
235 visible = false;
236 return;
237 }
238 visible = true;
239
240 auto new_position = xy_pair{ int16_t(screen_pos.x), int16_t(screen_pos.y) };
242 window_element_base::impl_render(state, new_position.x, new_position.y);
243 }
244 }
245
246 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
247 if(payload.holds_type<dcon::province_id>()) {
248 payload.emplace<dcon::province_id>(port_for);
250 } else if(payload.holds_type<outline_color>()) {
251 payload.emplace<outline_color>(color);
253 } else if(payload.holds_type<int32_t>()) {
254 payload.emplace<int32_t>(displayed_count);
256 } else if(payload.holds_type< toggle_unit_grid>()) {
257 auto with_shift = any_cast<toggle_unit_grid>(payload).with_shift;
258
259 if(state.ui_state.unit_details_box->for_province == port_for && state.ui_state.unit_details_box->is_visible() == true) {
260 state.ui_state.unit_details_box->set_visible(state, false);
261 if(!with_shift) {
262 state.selected_armies.clear();
263 state.selected_navies.clear();
264 } else {
265 for(auto n : state.world.province_get_navy_location(port_for)) {
266 state.deselect(n.get_navy().id);
267 }
268 }
269 } else {
270 if(!with_shift) {
271 state.selected_armies.clear();
272 state.selected_navies.clear();
273 }
274
275 for(auto n : state.world.province_get_navy_location(port_for)) {
276 //if(n.get_navy().get_controller_from_navy_control() == state.local_player_nation) {
277 state.select(n.get_navy().id);
278 // Hide province window when navy is clicked.
279 if(state.ui_state.province_window) {
280 state.ui_state.province_window->set_visible(state, false);
281 state.map_state.set_selected_province(dcon::province_id{});
282 }
283 //}
284 }
285
287 location.x -= 18;
288 location.y -= 18;
289 state.ui_state.unit_details_box->open(state, location, ui::xy_pair{int16_t(63), int16_t(36)}, port_for, true);
290 }
291
293 }
295 }
296
297 mouse_probe impl_probe_mouse(sys::state& state, int32_t x, int32_t y, mouse_probe_type type) noexcept override {
298 if(visible && populated)
300 else
301 return mouse_probe{ nullptr, ui::xy_pair{} };
302 }
303};
304
306 float top_left_value = 0.0f;
307 float top_right_value = 0.0f;
308 float top_left_org_value = 0.0f;
310 float battle_progress = 0.0f;
311 dcon::nation_id top_left_nation;
312 dcon::nation_id top_right_nation;
313 dcon::rebel_faction_id top_left_rebel;
314 dcon::rebel_faction_id top_right_rebel;
315 int8_t top_left_status = 0;
316 int8_t top_dig_in = -1;
317 int8_t top_right_dig_in = -1;
318 int8_t right_frames = 0;
319 int8_t colors_used = 0;
320 int8_t common_unit_1 = -1;
321 int8_t common_unit_2 = -1;
322 std::array<outline_color, 5> colors;
323 bool is_army = false;
327 bool player_is_attacker = false;
328};
329
331public:
332 void on_update(sys::state& state) noexcept override {
333 auto prov = retrieve<dcon::province_id>(state, parent);
334 progress = state.world.province_get_siege_progress(prov);
335 }
336};
337
339public:
340 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
341 if(name == "progress") {
342 return make_element_by_type<prov_map_siege_bar>(state, id);
343 } else {
344 return nullptr;
345 }
346 }
347
348 mouse_probe impl_probe_mouse(sys::state& state, int32_t x, int32_t y, mouse_probe_type type) noexcept override {
349 if(state.map_state.get_zoom() >= big_counter_cutoff)
351 else
353 }
354 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
355 if(state.map_state.get_zoom() >= big_counter_cutoff)
357 else
359 }
360};
361
363public:
364 void on_update(sys::state& state) noexcept override {
365 top_display_parameters* params = retrieve<top_display_parameters*>(state, parent);
366 progress = params->battle_progress;
367 }
368 message_result test_mouse(sys::state& state, int32_t x, int32_t y, mouse_probe_type type) noexcept override {
370 }
371 message_result on_lbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override {
372 sound::play_interface_sound(state, sound::get_click_sound(state), state.user_settings.interface_volume * state.user_settings.master_volume);
373
374 auto prov = retrieve<dcon::province_id>(state, parent);
375 for(auto b : state.world.province_get_land_battle_location(prov)) {
376 auto w = b.get_battle().get_war_from_land_battle_in_war();
377 if(!w) {
378 land_combat_window* win = static_cast<land_combat_window*>(state.ui_state.army_combat_window);
379 win->battle = b.get_battle();
380 if(state.ui_state.army_combat_window->is_visible()) {
382 } else {
383 state.ui_state.army_combat_window->set_visible(state, true);
384 if(state.ui_state.province_window) {
385 state.ui_state.province_window->set_visible(state, false);
386 state.map_state.set_selected_province(dcon::province_id{});
387 }
388 if(state.ui_state.naval_combat_window) {
389 state.ui_state.naval_combat_window->set_visible(state, false);
390 }
391 }
393 } else if(military::get_role(state, w, state.local_player_nation) != military::war_role::none) {
394 land_combat_window* win = static_cast<land_combat_window*>(state.ui_state.army_combat_window);
395 win->battle = b.get_battle();
396 if(state.ui_state.army_combat_window->is_visible()) {
398 } else {
399 state.ui_state.army_combat_window->set_visible(state, true);
400 if(state.ui_state.province_window) {
401 state.ui_state.province_window->set_visible(state, false);
402 state.map_state.set_selected_province(dcon::province_id{});
403 }
404 if(state.ui_state.naval_combat_window) {
405 state.ui_state.naval_combat_window->set_visible(state, false);
406 }
407 }
409 }
410 }
411 for(auto b : state.world.province_get_naval_battle_location(prov)) {
412 auto w = b.get_battle().get_war_from_naval_battle_in_war();
413
414 if(military::get_role(state, w, state.local_player_nation) != military::war_role::none) {
416 win->battle = b.get_battle();
417 if(state.ui_state.naval_combat_window->is_visible()) {
419 } else {
421 if(state.ui_state.province_window) {
422 state.ui_state.province_window->set_visible(state, false);
423 state.map_state.set_selected_province(dcon::province_id{});
424 }
425 if(state.ui_state.army_combat_window) {
426 state.ui_state.army_combat_window->set_visible(state, false);
427 }
428 }
430 }
431 }
432
434 }
435};
436
438public:
439 void on_create(sys::state& state) noexcept override {
441 frame = 1;
442 }
443 };
444
446public:
447 void on_update(sys::state& state) noexcept override {
448 top_display_parameters* params = retrieve<top_display_parameters*>(state, parent);
450
451 auto cas = params->attacker_casualties * state.defines.pop_size_per_regiment;
452 cas = floor(cas);
453
454 if(cas < 5) {
455 set_text(state, "");
456 } else {
457 set_text(state, '-' + std::to_string(int32_t(cas)));
458 }
459
460 }
461 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
462 top_display_parameters* params = retrieve<top_display_parameters*>(state, parent);
463 auto player_involved_battle = params->player_involved_battle;
464 auto player_is_attacker = params->player_is_attacker;
465
466 if(state.map_state.get_zoom() >= big_counter_cutoff) {
467 if(player_involved_battle && player_is_attacker) {
468 color_text_element::render(state, x - 14, y - 80);
469 } else if (player_involved_battle && !player_is_attacker) {
470 color_text_element::render(state, x + 55, y - 80);
471 }
472 } else {
473 if(player_involved_battle && player_is_attacker) {
474 color_text_element::render(state, x - 14, y - 38);
475 } else if(player_involved_battle && !player_is_attacker) {
476 color_text_element::render(state, x + 55, y - 38);
477 }
478 }
479
480 }
481};
482
484public:
485 void on_update(sys::state& state) noexcept override {
486 top_display_parameters* params = retrieve<top_display_parameters*>(state, parent);
488
489 auto cas = params->defender_casualties * state.defines.pop_size_per_regiment;
490 cas = floor(cas);
491
492 if (cas < 5) {
493 set_text(state, "");
494 } else {
495 set_text(state, '-' + std::to_string(int32_t(cas)));
496 }
497
498 }
499 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
500 top_display_parameters* params = retrieve<top_display_parameters*>(state, parent);
501 auto player_involved_battle = params->player_involved_battle;
502 auto player_is_attacker = params->player_is_attacker;
503
504 if(state.map_state.get_zoom() >= big_counter_cutoff) {
505 if (player_involved_battle && player_is_attacker)
506 color_text_element::render(state, x + 55, y - 80);
507 else if (player_involved_battle && !player_is_attacker)
508 color_text_element::render(state, x - 14, y - 80);
509 } else {
510 if (player_involved_battle && player_is_attacker)
511 color_text_element::render(state, x + 55, y - 38);
512 else if (player_involved_battle && !player_is_attacker)
513 color_text_element::render(state, x - 14, y - 38);
514 }
515 }
516};
517
519public:
520 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
521 if(name == "progress") {
522 return make_element_by_type<prov_map_battle_bar>(state, id);
523 } else if(name == "overlay_right") {
524 return make_element_by_type<prov_map_br_overlay>(state, id);
525 } else if(name == "defender_casualties") {
526 return make_element_by_type <tl_defender_casualties>(state, id);
527 } else if(name == "attacker_casualties") {
528 return make_element_by_type <tl_attacker_casualties>(state, id);
529 } else {
530 return nullptr;
531 }
532 }
533
534 mouse_probe impl_probe_mouse(sys::state& state, int32_t x, int32_t y, mouse_probe_type type) noexcept override {
535 if(state.map_state.get_zoom() >= big_counter_cutoff)
537 else
539 }
540 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
541 if(state.map_state.get_zoom() >= big_counter_cutoff)
543 else
545 }
546};
547
549public:
550 void on_create(sys::state& state) noexcept override {
552 frame = int32_t(outline_color::red);
553 }
554};
555
557public:
558 int32_t number = 0;
559 bool visible = false;
560
561 void on_update(sys::state& state) noexcept override {
562 top_display_parameters* params = retrieve<top_display_parameters*>(state, parent);
563 visible = params->right_frames > number;
564 }
565
566 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
567 if(visible)
569 }
570};
571
572class tr_org_bar : public progress_bar {
573public:
574 void on_update(sys::state& state) noexcept override {
575 top_display_parameters* params = retrieve<top_display_parameters*>(state, parent);
577 }
578};
579
581public:
582 void on_create(sys::state& state) noexcept override {
584 frame = 6;
585 }
586};
587
589public:
590 bool visible = false;
591
592 void on_update(sys::state& state) noexcept override {
593 top_display_parameters* params = retrieve<top_display_parameters*>(state, parent);
594 if(params->top_right_dig_in >= 0) {
595 frame = params->top_right_dig_in;
596 visible = true;
597 } else {
598 visible = false;
599 }
600 }
601
602 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
603 if(visible)
605 }
606};
607
609public:
610 void on_update(sys::state& state) noexcept override {
611 top_display_parameters* params = retrieve<top_display_parameters*>(state, parent);
612 auto strength = params->top_right_value;
613 if(params->is_army) {
614 strength *= state.defines.pop_size_per_regiment;
615 strength = floor(strength);
616 }
617 set_text(state, text::prettify(int32_t(strength)));
618 }
619};
620
622public:
623 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
624 if(payload.holds_type<dcon::nation_id>()) {
625 top_display_parameters* params = retrieve<top_display_parameters*>(state, parent);
626 if(params)
627 payload.emplace<dcon::nation_id>(params->top_right_nation);
628 else
629 payload.emplace<dcon::nation_id>(dcon::nation_id{});
631 } else if(payload.holds_type<dcon::rebel_faction_id>()) {
632 top_display_parameters* params = retrieve<top_display_parameters*>(state, parent);
633 if(params)
634 payload.emplace<dcon::rebel_faction_id>(params->top_right_rebel);
635 else
636 payload.emplace<dcon::rebel_faction_id>(dcon::rebel_faction_id{});
638 }
640 }
641};
642
644public:
645 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
646 if(name == "controller_flag") {
647 return make_element_by_type<tr_controller_flag>(state, id);
648 } else if(name == "strength") {
649 return make_element_by_type<tr_strength>(state, id);
650 } else if(name == "dig_in") {
651 return make_element_by_type<tr_dig_in>(state, id);
652 } else if(name == "status") {
653 return make_element_by_type<tr_status>(state, id);
654 } else if(name == "org_bar") {
655 return make_element_by_type<tr_org_bar>(state, id);
656 } else if(name == "edge1") {
657 auto ptr = make_element_by_type<tr_edge>(state, id);
658 ptr->number = 1;
659 return ptr;
660 } else if(name == "edge2") {
661 auto ptr = make_element_by_type<tr_edge>(state, id);
662 ptr->number = 2;
663 return ptr;
664 } else if(name == "edge3") {
665 auto ptr = make_element_by_type<tr_edge>(state, id);
666 ptr->number = 3;
667 return ptr;
668 } else if(name == "edge4") {
669 auto ptr = make_element_by_type<tr_edge>(state, id);
670 ptr->number = 4;
671 return ptr;
672 } else if(name == "frame_bg") {
673 return make_element_by_type<tr_frame_bg>(state, id);
674 } else {
675 return nullptr;
676 }
677 }
678
679 mouse_probe impl_probe_mouse(sys::state& state, int32_t x, int32_t y, mouse_probe_type type) noexcept override {
680 if(state.map_state.get_zoom() >= big_counter_cutoff)
682 else
683 return mouse_probe{ nullptr, ui::xy_pair{0,0} };
684 }
685 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
686 if(state.map_state.get_zoom() >= big_counter_cutoff)
688 }
689};
690
692public:
693 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
694 if(name == "controller_flag") {
695 return make_element_by_type<tr_controller_flag>(state, id);
696 } else if(name == "strength") {
697 return make_element_by_type<tr_strength>(state, id);
698 } else if(name == "frame_bg") {
699 return make_element_by_type<tr_frame_bg>(state, id);
700 } else {
701 return nullptr;
702 }
703 }
704
705 mouse_probe impl_probe_mouse(sys::state& state, int32_t x, int32_t y, mouse_probe_type type) noexcept override {
706 if(state.map_state.get_zoom() < big_counter_cutoff)
708 else
709 return mouse_probe{ nullptr, ui::xy_pair{0,0}};
710 }
711 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
712 if(state.map_state.get_zoom() < big_counter_cutoff)
714 }
715};
716
718public:
719 int32_t number = 0;
720 bool visible = false;
721
722 void on_update(sys::state& state) noexcept override {
723 top_display_parameters* params = retrieve<top_display_parameters*>(state, parent);
724 if(number >= params->colors_used) {
725 visible = false;
726 } else {
727 frame = int32_t(params->colors[number]);
728 visible = true;
729 }
730 }
731
732 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
733 if(visible)
735 }
736};
737
739public:
740 void on_update(sys::state& state) noexcept override {
741 top_display_parameters* params = retrieve<top_display_parameters*>(state, parent);
742 frame = int32_t(params->colors[0]);
743 }
744 void button_action(sys::state& state) noexcept override {
745 send(state, parent, toggle_unit_grid{ false });
746 }
747 void button_shift_action(sys::state& state) noexcept override {
749 }
752 }
753 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
754 populate_unit_tooltip(state, contents, retrieve<dcon::province_id>(state, parent));
755 }
756};
757
758class tl_org_bar : public progress_bar {
759public:
760 void on_update(sys::state& state) noexcept override {
761 top_display_parameters* params = retrieve<top_display_parameters*>(state, parent);
763 }
764};
765
767public:
768 void on_update(sys::state& state) noexcept override {
769 top_display_parameters* params = retrieve<top_display_parameters*>(state, parent);
770
771 if(params->top_left_status >= 0) {
772 frame = params->top_left_status;
773 } else {
774 frame = 0;
775 }
776 }
777};
778
780public:
781 void on_update(sys::state& state) noexcept override {
782 top_display_parameters* params = retrieve<top_display_parameters*>(state, parent);
783 auto strength = params->top_left_value;
784 if(params->is_army) {
785 strength *= state.defines.pop_size_per_regiment;
786 strength = floor(strength);
787 }
788 set_text(state, text::prettify(int32_t(strength)));
789
790 }
791};
792
794public:
795 bool visible = false;
796
797 void on_update(sys::state& state) noexcept override {
798 top_display_parameters* params = retrieve<top_display_parameters*>(state, parent);
799 if(params->top_dig_in >= 0) {
800 frame = params->top_dig_in;
801 visible = true;
802 } else {
803 visible = false;
804 }
805 }
806
807 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
808 if(visible)
810 }
811};
812
814public:
815 bool visible = true;
816
817 void on_update(sys::state& state) noexcept override {
818 top_display_parameters* params = retrieve<top_display_parameters*>(state, parent);
819 if(params->common_unit_1 >= 0) {
820 frame = params->common_unit_1;
821 visible = true;
822 } else {
823 visible = false;
824 }
825 }
826 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
827 if(visible)
829 }
830};
831
833public:
834 bool visible = true;
835
836 void on_update(sys::state& state) noexcept override {
837 top_display_parameters* params = retrieve<top_display_parameters*>(state, parent);
838 if(params->common_unit_2 >= 0) {
839 frame = params->common_unit_2;
840 visible = true;
841 } else {
842 visible = false;
843 }
844 }
845 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
846 if(visible)
848 }
849};
850
851
852
854public:
855 bool visible = true;
856
857 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
858 if(payload.holds_type<dcon::nation_id>()) {
859 top_display_parameters* params = retrieve<top_display_parameters*>(state, parent);
860 if(params)
861 payload.emplace<dcon::nation_id>(params->top_left_nation);
862 else
863 payload.emplace<dcon::nation_id>(dcon::nation_id{});
865 } else if(payload.holds_type<dcon::rebel_faction_id>()) {
866 top_display_parameters* params = retrieve<top_display_parameters*>(state, parent);
867 if(params)
868 payload.emplace<dcon::rebel_faction_id>(params->top_left_rebel);
869 else
870 payload.emplace<dcon::rebel_faction_id>(dcon::rebel_faction_id{});
872 }
874 }
875
876 void on_update(sys::state& state) noexcept override {
877 top_display_parameters* params = retrieve<top_display_parameters*>(state, parent);
878
879 visible = params->top_left_nation != state.local_player_nation;
880 if(visible)
882 }
883 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
884 if(visible)
886 }
887 mouse_probe impl_probe_mouse(sys::state& state, int32_t x, int32_t y, mouse_probe_type type) noexcept override {
888 if(visible)
890 else
891 return mouse_probe{ nullptr, ui::xy_pair{} };
892 }
893};
894
896public:
897 dcon::national_identity_id get_current_nation(sys::state& state) noexcept override {
898 top_display_parameters* params = retrieve<top_display_parameters*>(state, parent);
899 if(params)
900 return state.world.nation_get_identity_from_identity_holder(params->top_left_nation);
901 return dcon::national_identity_id{};
902 }
903
904 void on_update(sys::state& state) noexcept override {
906 top_display_parameters* params = retrieve<top_display_parameters*>(state, parent);
907 if(params) {
908 dcon::rebel_faction_id faction = params->top_left_rebel;
909 if(faction)
911 }
912 }
913};
914
916 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
917 if(name == "controller_flag") {
918 return make_element_by_type<tl_controller_flag>(state, id);
919 } else if(name == "strength") {
920 return make_element_by_type<tl_strength>(state, id);
921 } else if(name == "unit_1") {
922 return make_element_by_type<tl_unit_1>(state, id);
923 } else if(name == "unit_2") {
924 return make_element_by_type<tl_unit_2>(state, id);
925 } else if(name == "dig_in") {
926 return make_element_by_type<tl_dig_in>(state, id);
927 } else if(name == "status") {
928 return make_element_by_type<tl_status>(state, id);
929 } else if(name == "org_bar") {
930 return make_element_by_type<tl_org_bar>(state, id);
931 } else if(name == "edge1") {
932 auto ptr = make_element_by_type<tl_edge>(state, id);
933 ptr->number = 1;
934 return ptr;
935 } else if(name == "edge2") {
936 auto ptr = make_element_by_type<tl_edge>(state, id);
937 ptr->number = 2;
938 return ptr;
939 } else if(name == "edge3") {
940 auto ptr = make_element_by_type<tl_edge>(state, id);
941 ptr->number = 3;
942 return ptr;
943 } else if(name == "edge4") {
944 auto ptr = make_element_by_type<tl_edge>(state, id);
945 ptr->number = 4;
946 return ptr;
947 } else if(name == "frame_bg") {
948 return make_element_by_type<tl_frame_bg>(state, id);
949 } else {
950 return nullptr;
951 }
952 }
953
954 mouse_probe impl_probe_mouse(sys::state& state, int32_t x, int32_t y, mouse_probe_type type) noexcept override {
955 if(state.map_state.get_zoom() >= big_counter_cutoff)
957 else
958 return mouse_probe{ nullptr, ui::xy_pair{0,0} };
959 }
960 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
961 if(state.map_state.get_zoom() >= big_counter_cutoff)
963 }
964};
965
967 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
968 if(name == "controller_flag") {
969 return make_element_by_type<tl_sm_controller_flag>(state, id);
970 } else if(name == "strength") {
971 return make_element_by_type<tl_strength>(state, id);
972 } else if(name == "frame_bg") {
973 return make_element_by_type<tl_frame_bg>(state, id);
974 } else {
975 return nullptr;
976 }
977 }
978
979 mouse_probe impl_probe_mouse(sys::state& state, int32_t x, int32_t y, mouse_probe_type type) noexcept override {
980 if(state.map_state.get_zoom() < big_counter_cutoff)
982 else
983 return mouse_probe{ nullptr, ui::xy_pair{0,0} };
984 }
985 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
986 if(state.map_state.get_zoom() < big_counter_cutoff)
988 }
989};
990
991/*
992class select_army_group_button : public button_element_base {
993 void button_action(sys::state& state) noexcept override {
994 auto info = retrieve<dcon::automated_army_group_id>(state, parent);
995 state.select_army_group(info);
996 }
997
998 void on_update(sys::state& state) noexcept override {
999 auto info = retrieve<dcon::automated_army_group_id>(state, parent);
1000
1001 if(state.selected_army_group != nullptr) {
1002 if(info != nullptr) {
1003 if(info->hq == state.selected_army_group->hq) {
1004 frame = 1;
1005 return;
1006 }
1007 }
1008 }
1009 frame = 0;
1010 }
1011};
1012*/
1013
1015 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1016 if(name == "frame_bg") {
1017 return make_element_by_type<select_army_group_button>(state, id);
1018 } else {
1019 return nullptr;
1020 }
1021 }
1022
1023 //mouse_probe impl_probe_mouse(sys::state& state, int32_t x, int32_t y, mouse_probe_type type) noexcept override {
1024 // return window_element_base::impl_probe_mouse(state, x, y, type);
1025 //}
1026 //void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
1027 // window_element_base::impl_render(state, x, y);
1028 //}
1029
1030 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
1031 if(payload.holds_type<dcon::automated_army_group_id>()) {
1032 payload.emplace<dcon::automated_army_group_id>(retrieve<dcon::automated_army_group_id>(state, parent));
1034 }
1036 }
1037};
1038
1040public:
1041 bool populated = false;
1042 bool visible = true;
1043
1044 dcon::automated_army_group_id info {};
1045
1047 dcon::province_id prov;
1049
1051
1052 void on_create(sys::state& state) noexcept override {
1055 }
1056
1057 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1058 if(name == "main_army_group_icon") {
1059 auto ptr = make_element_by_type<army_group_icon>(state, id);
1060 main_icon = ptr.get();
1061 return ptr;
1062 } else {
1063 return nullptr;
1064 }
1065 }
1066
1067 void impl_on_update(sys::state& state) noexcept override {
1069
1070 for(auto& c : children) {
1071 if(c->is_visible()) {
1072 c->impl_on_update(state);
1073 }
1074 }
1075 }
1076
1077 void on_update(sys::state& state) noexcept override {
1078 populated = false;
1079
1080 state.world.for_each_automated_army_group([&](dcon::automated_army_group_id item) {
1081 auto hq = state.world.automated_army_group_get_hq(item);
1082 if(hq == prov) {
1083 info = item;
1084 populated = true;
1085 }
1086 });
1087 }
1088
1089 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
1090 if(populated) {
1091 auto mid_point = state.world.province_get_mid_point(prov);
1092 auto map_pos = state.map_state.normalize_map_coord(mid_point);
1093 auto screen_size = glm::vec2{ float(state.x_size / state.user_settings.ui_scale), float(state.y_size / state.user_settings.ui_scale) };
1094 glm::vec2 screen_pos;
1095 if(!state.map_state.map_to_screen(state, map_pos, screen_size, screen_pos)) {
1096 visible = false;
1097 return;
1098 }
1099 if(!state.map_state.visible_provinces[province::to_map_id(prov)]) {
1100 visible = false;
1101 return;
1102 }
1103 visible = true;
1104
1105 auto new_position = xy_pair{ int16_t(screen_pos.x), int16_t(screen_pos.y) };
1107 window_element_base::impl_render(state, new_position.x, new_position.y);
1108 }
1109 }
1110
1111 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
1112 if(payload.holds_type<dcon::automated_army_group_id>()) {
1113 if(populated) payload.emplace<dcon::automated_army_group_id>(info);
1115 }
1117 }
1118};
1119
1121public:
1122 bool visible = true;
1123 bool populated = false;
1124
1125 dcon::province_id prov;
1132
1134
1135 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1136 if(name == "top_unit_icon") {
1137 auto ptr = make_element_by_type<top_unit_icon>(state, id);
1138 top_icon = ptr.get();
1139 return ptr;
1140 } else if(name == "top_right_unit_icon") {
1141 auto ptr = make_element_by_type<top_right_unit_icon>(state, id);
1142 top_right_icon = ptr.get();
1143 return ptr;
1144 } else if(name == "small_top_unit_icon") {
1145 auto ptr = make_element_by_type<small_top_unit_icon>(state, id);
1146 small_top_icon = ptr.get();
1147 return ptr;
1148 } else if(name == "small_top_right_unit_icon") {
1149 auto ptr = make_element_by_type<small_top_right_unit_icon>(state, id);
1150 small_top_right_icon = ptr.get();
1151 return ptr;
1152 } else if(name == "siege") {
1153 auto ptr = make_element_by_type<map_siege>(state, id);
1154 siege = ptr.get();
1155 return ptr;
1156 } else if(name == "battle") {
1157 auto ptr = make_element_by_type<map_battle>(state, id);
1158 battle = ptr.get();
1159 return ptr;
1160 } else {
1161 return nullptr;
1162 }
1163 }
1164
1165 void impl_on_update(sys::state& state) noexcept override {
1167 if(!populated)
1168 return;
1169
1170 for(auto& c : children) {
1171 if(c->is_visible()) {
1172 c->impl_on_update(state);
1173 }
1174 }
1175 }
1176
1177 void on_update(sys::state& state) noexcept override {
1178
1179 bool found_selected = false;
1180 bool all_selected = true;
1181 bool found_ally = false;
1182 bool found_enemy = false;
1183 bool found_other = false;
1184
1185 if(prov.index() < state.province_definitions.first_sea_province.index()) {
1186 populated = false;
1187 for(auto a : state.world.province_get_army_location(prov)) {
1188 if(!(a.get_army().get_navy_from_army_transport())) {
1189
1190 auto controller = a.get_army().get_controller_from_army_control().id;
1191
1192 if(state.is_selected(a.get_army()) && controller == state.local_player_nation)
1193 found_selected = true;
1194 else if(controller == state.local_player_nation)
1195 all_selected = false;
1196 else if(!controller || military::are_at_war(state, controller, state.local_player_nation))
1197 found_enemy = true;
1198 else if(military::are_allied_in_war(state, controller, state.local_player_nation))
1199 found_ally = true;
1200 else
1201 found_other = true;
1202
1203 populated = true;
1204 }
1205 }
1206 if(!populated) {
1207 return;
1208 }
1209 } else {
1210 populated = true;
1211 auto navies = state.world.province_get_navy_location(prov);
1212 if(navies.begin() == navies.end()) {
1213 populated = false;
1214 return;
1215 } else {
1216 for(auto n : navies) {
1217 auto controller = n.get_navy().get_controller_from_navy_control().id;
1218 if(state.is_selected(n.get_navy()) && controller == state.local_player_nation)
1219 found_selected = true;
1220 else if(controller == state.local_player_nation)
1221 all_selected = false;
1222 else if(!controller || military::are_at_war(state, controller, state.local_player_nation))
1223 found_enemy = true;
1224 else if(military::are_allied_in_war(state, controller, state.local_player_nation))
1225 found_ally = true;
1226 else
1227 found_other = true;
1228 }
1229 }
1230 if(!populated) {
1231 return;
1232 }
1233 }
1234
1235
1236 bool player_involved_battle = false;
1237 dcon::land_battle_id lbattle;
1238 dcon::naval_battle_id nbattle;
1239 for(auto b : state.world.province_get_land_battle_location(prov)) {
1240 auto w = b.get_battle().get_war_from_land_battle_in_war();
1241 if(!w) { //rebels
1242 player_involved_battle = true;
1243 lbattle = b.get_battle();
1245 break;
1246 } else if(military::get_role(state, w, state.local_player_nation) != military::war_role::none) { //in a war
1247 player_involved_battle = true;
1249 lbattle = b.get_battle();
1250 break;
1251 }
1252 }
1253 if(!player_involved_battle) {
1254 for(auto b : state.world.province_get_naval_battle_location(prov)) {
1255 auto w = b.get_battle().get_war_from_naval_battle_in_war();
1256 if(military::get_role(state, w, state.local_player_nation) != military::war_role::none) {
1257 player_involved_battle = true;
1258 nbattle = b.get_battle();
1259 break;
1260 }
1261 }
1262 }
1263
1264 display.colors_used = 0;
1265
1266 if(found_selected) {
1269 }
1270 if(!all_selected) {
1273 }
1274 if(!player_involved_battle) {
1275 if(found_enemy) {
1278 }
1279 }
1280 if(found_ally) {
1283 }
1284 if(found_other) {
1287 }
1288
1289 static std::vector<int32_t> by_icon_count;
1290 for(auto& i : by_icon_count)
1291 i = 0;
1292
1293
1295 display.top_dig_in = -1;
1300 display.top_left_value = 0.0f;
1301 display.top_right_value = 0.0f;
1305 display.is_army = false;
1306
1310
1311
1312 if(lbattle) {
1313 display.is_army = true;
1314 float max_str = 0.0f;
1315 float max_opp_str = 0.0f;
1316 int32_t total_count = 0;
1317 int32_t total_opp_count = 0;
1318
1319 auto w = state.world.land_battle_get_war_from_land_battle_in_war(lbattle);
1320 bool player_is_attacker = w ? military::is_attacker(state, w, state.local_player_nation) : false;
1321
1322 bool land_battle_attacker_is_player = false;
1323 if (player_is_attacker && state.world.land_battle_get_war_attacker_is_attacker(lbattle))
1324 land_battle_attacker_is_player = true;
1325 else if (!player_is_attacker && !state.world.land_battle_get_war_attacker_is_attacker(lbattle))
1326 land_battle_attacker_is_player = true;
1327
1328 display.player_is_attacker = land_battle_attacker_is_player;
1329
1331
1332 display.attacker_casualties = state.world.land_battle_get_attacker_casualties(lbattle);
1333 display.defender_casualties = state.world.land_battle_get_defender_casualties(lbattle);
1334
1335 for(auto ar : state.world.land_battle_get_army_battle_participation(lbattle)) {
1336 auto controller = ar.get_army().get_controller_from_army_control();
1337
1338 if(!controller || military::is_attacker(state, w, controller) != player_is_attacker) { // opposed
1340 float str = 0.0f;
1341 for(auto m : state.world.army_get_army_membership(ar.get_army())) {
1342 ++total_opp_count;
1343
1344 str += m.get_regiment().get_strength();
1345 display.top_right_value += m.get_regiment().get_strength();
1346 display.top_right_org_value += m.get_regiment().get_org();
1347 }
1348
1349 auto dig_in = ar.get_army().get_dig_in();
1350 if(display.top_right_dig_in == -1) {
1351 display.top_right_dig_in = int8_t(dig_in);
1352 } else {
1353 display.top_right_dig_in = std::min(display.top_right_dig_in, int8_t(dig_in));
1354 }
1355
1356 if(str > max_opp_str) {
1357 max_opp_str = str;
1358 display.top_right_nation = controller;
1359 display.top_right_rebel = ar.get_army().get_controller_from_army_rebel_control();
1360 }
1361 } else { // same side
1362 float str = 0.0f;
1363 for(auto m : state.world.army_get_army_membership(ar.get_army())) {
1364 auto icon = state.military_definitions.unit_base_definitions[m.get_regiment().get_type()].icon - 1;
1365 if(uint32_t(icon) >= by_icon_count.size()) {
1366 by_icon_count.resize(icon + 1, 0);
1367 }
1368 ++(by_icon_count[icon]);
1369 ++total_count;
1370
1371 str += m.get_regiment().get_strength();
1372 display.top_left_value += m.get_regiment().get_strength();
1373 display.top_left_org_value += m.get_regiment().get_org();
1374 }
1375
1376 auto dig_in = ar.get_army().get_dig_in();
1377 if(display.top_dig_in == -1) {
1378 display.top_dig_in = int8_t(dig_in);
1379 } else {
1380 display.top_dig_in = std::min(display.top_dig_in, int8_t(dig_in));
1381 }
1382
1383 if(str > max_str) {
1384 max_str = str;
1385 display.top_left_nation = controller;
1386 display.top_left_rebel = dcon::rebel_faction_id{};
1387 }
1388 }
1389 }
1390
1391 display.top_left_org_value /= float(total_count);
1392 display.top_right_org_value /= float(total_opp_count);
1393
1394 int32_t areg = 0;
1395 int32_t breg = 0;
1396
1397 for(auto reg : state.world.land_battle_get_reserves(lbattle)) {
1398 if((reg.flags & military::reserve_regiment::is_attacking) != 0)
1399 ++areg;
1400 else
1401 ++breg;
1402 }
1403
1404 auto& att_back = state.world.land_battle_get_attacker_back_line(lbattle);
1405 auto& def_back = state.world.land_battle_get_defender_back_line(lbattle);
1406 auto& att_front = state.world.land_battle_get_attacker_front_line(lbattle);
1407 auto& def_front = state.world.land_battle_get_defender_front_line(lbattle);
1408 for(auto r : att_back) {
1409 if(r)
1410 ++areg;
1411 }
1412 for(auto r : att_front) {
1413 if(r)
1414 ++areg;
1415 }
1416 for(auto r : def_back) {
1417 if(r)
1418 ++breg;
1419 }
1420 for(auto r : def_front) {
1421 if(r)
1422 ++breg;
1423 }
1424 if(state.world.land_battle_get_war_attacker_is_attacker(lbattle) == player_is_attacker) {
1425 display.battle_progress = float(areg) / float(areg + breg);
1426 } else {
1427 display.battle_progress = float(breg) / float(areg + breg);
1428 }
1429
1430 battle->set_visible(state, true);
1431 siege->set_visible(state, false);
1436 }
1437 else if(nbattle) {
1438 float max_str = 0.0f;
1439 float max_opp_str = 0.0f;
1440 int32_t total_count = 0;
1441 int32_t total_opp_count = 0;
1442
1443 auto w = state.world.naval_battle_get_war_from_naval_battle_in_war(nbattle);
1444 bool player_is_attacker = w ? military::is_attacker(state, w, state.local_player_nation) : false;
1445
1447
1448 for(auto ar : state.world.naval_battle_get_navy_battle_participation(nbattle)) {
1449 auto controller = ar.get_navy().get_controller_from_navy_control();
1450 if(!controller || military::is_attacker(state, w, controller) != player_is_attacker) { // opposed
1452
1453 float str = 0.0f;
1454 for(auto m : state.world.navy_get_navy_membership(ar.get_navy())) {
1455 ++total_opp_count;
1456
1457 str += m.get_ship().get_strength();
1458 display.top_right_value += m.get_ship().get_strength();
1459 display.top_right_org_value += m.get_ship().get_org();
1460 }
1461
1462 if(str > max_opp_str) {
1463 max_opp_str = str;
1464 display.top_right_nation = controller;
1465 display.top_right_rebel = dcon::rebel_faction_id{};
1466 }
1467 } else { // same side
1468 float str = 0.0f;
1469 for(auto m : state.world.navy_get_navy_membership(ar.get_navy())) {
1470 auto icon = state.military_definitions.unit_base_definitions[m.get_ship().get_type()].icon - 1;
1471 if(uint32_t(icon) >= by_icon_count.size()) {
1472 by_icon_count.resize(icon + 1, 0);
1473 }
1474 ++(by_icon_count[icon]);
1475 ++total_count;
1476
1477 str += m.get_ship().get_strength();
1478 display.top_left_value += m.get_ship().get_strength();
1479 display.top_left_org_value += m.get_ship().get_org();
1480 }
1481
1482 if(str > max_str) {
1483 max_str = str;
1484 display.top_left_nation = controller;
1485 display.top_left_rebel = dcon::rebel_faction_id{};
1486 }
1487 }
1488 }
1489
1490 display.top_left_org_value /= float(total_count);
1491 display.top_right_org_value /= float(total_opp_count);
1492
1493 int32_t attacker_ships = 0;
1494 int32_t defender_ships = 0;
1495
1496 auto slots = state.world.naval_battle_get_slots(nbattle);
1497
1498 for(uint32_t j = slots.size(); j-- > 0;) {
1499 switch(slots[j].flags & military::ship_in_battle::mode_mask) {
1504 if((slots[j].flags & military::ship_in_battle::is_attacking) != 0)
1505 ++attacker_ships;
1506 else
1507 ++defender_ships;
1508 break;
1509 default:
1510 break;
1511 }
1512 }
1513
1514 if(state.world.naval_battle_get_war_attacker_is_attacker(nbattle) == player_is_attacker) {
1515 display.battle_progress = float(attacker_ships) / float(attacker_ships + defender_ships);
1516 } else {
1517 display.battle_progress = float(defender_ships) / float(attacker_ships + defender_ships);
1518 }
1519
1520 battle->set_visible(state, true);
1521 siege->set_visible(state, false);
1526 }
1527 else if(prov.index() < state.province_definitions.first_sea_province.index()) {
1528 std::function<bool(dcon::army_id)> filter;
1529
1531 display.top_left_nation = state.local_player_nation;
1532 display.top_left_rebel = dcon::rebel_faction_id{};
1533 filter = [&](dcon::army_id a) { return state.world.army_get_controller_from_army_control(a) == state.local_player_nation && state.is_selected(a); };
1534 } else if(display.colors[0] == outline_color::blue) {
1535 display.top_left_nation = state.local_player_nation;
1536 display.top_left_rebel = dcon::rebel_faction_id{};
1537 filter = [&](dcon::army_id a) { return state.world.army_get_controller_from_army_control(a) == state.local_player_nation && !state.is_selected(a); };
1538 } else if(display.colors[0] == outline_color::cyan) {
1539 filter = [&](dcon::army_id a) {
1540 auto n = state.world.army_get_controller_from_army_control(a);
1541 return n != state.local_player_nation && military::are_allied_in_war(state, n, state.local_player_nation);
1542 };
1543 } else if(display.colors[0] == outline_color::red) {
1544 filter = [&](dcon::army_id a) {
1545 auto n = state.world.army_get_controller_from_army_control(a);
1546 return !n || military::are_at_war(state, n, state.local_player_nation);
1547 };
1548 } else if(display.colors[0] == outline_color::gray) {
1549 filter = [&](dcon::army_id a) {
1550 auto n = state.world.army_get_controller_from_army_control(a);
1551 return n != state.local_player_nation && !military::are_allied_in_war(state, n, state.local_player_nation) && !military::are_at_war(state, n, state.local_player_nation);
1552 };
1553 }
1554
1555 float max_str = 0.0f;
1556
1557 int32_t total_count = 0;
1558 int32_t ucount = 0;
1559
1560 for(auto a : state.world.province_get_army_location(prov)) {
1561 if(!(a.get_army().get_navy_from_army_transport()) && filter(a.get_army())) {
1562 ++ucount;
1563 float str = 0.0f;
1564 for(auto m : state.world.army_get_army_membership(a.get_army())) {
1565 auto icon = state.military_definitions.unit_base_definitions[m.get_regiment().get_type()].icon - 1;
1566 icon = std::max(icon, 0);
1567 if(uint32_t(icon) >= by_icon_count.size()) {
1568 by_icon_count.resize(icon + 1, 0);
1569 }
1570 ++(by_icon_count[icon]);
1571 ++total_count;
1572
1573 str += m.get_regiment().get_strength();
1574 display.is_army = true;
1575 display.top_left_value += m.get_regiment().get_strength();
1576 display.top_left_org_value += m.get_regiment().get_org();
1577 }
1578
1579 auto frame = status_frame(state, a.get_army());
1580 if(display.top_left_status == -1) {
1581 display.top_left_status = int8_t(frame);
1582 } else if(display.top_left_status == int8_t(frame)) {
1583
1584 } else {
1586 }
1587
1588 auto dig_in = a.get_army().get_dig_in();
1589 if(display.top_dig_in == -1) {
1590 display.top_dig_in = int8_t(dig_in);
1591 } else {
1592 display.top_dig_in = std::min(display.top_dig_in, int8_t(dig_in));
1593 }
1594
1595 if(str > max_str) {
1596 max_str = str;
1597 display.top_left_nation = state.world.army_get_controller_from_army_control(a.get_army());
1598 display.top_left_rebel = state.world.army_get_controller_from_army_rebel_control(a.get_army());
1599 }
1600 }
1601 }
1602
1603 if(ucount > 1 && display.colors_used == 1) {
1604 display.colors_used = 2;
1605 display.colors[1] = display.colors[0];
1606 }
1607
1608 display.top_left_org_value /= float(total_count);
1609
1610 battle->set_visible(state, false);
1611 siege->set_visible(state, state.world.province_get_siege_progress(prov) > 0.f);
1616 } else {
1617 std::function<bool(dcon::navy_id)> filter;
1618 display.top_left_rebel = dcon::rebel_faction_id{};
1619
1621 display.top_left_nation = state.local_player_nation;
1622 filter = [&](dcon::navy_id a) { return state.world.navy_get_controller_from_navy_control(a) == state.local_player_nation && state.is_selected(a); };
1623 } else if(display.colors[0] == outline_color::blue) {
1624 display.top_left_nation = state.local_player_nation;
1625 filter = [&](dcon::navy_id a) { return state.world.navy_get_controller_from_navy_control(a) == state.local_player_nation && !state.is_selected(a); };
1626 } else if(display.colors[0] == outline_color::cyan) {
1627 filter = [&](dcon::navy_id a) {
1628 auto n = state.world.navy_get_controller_from_navy_control(a);
1629 return n != state.local_player_nation && military::are_allied_in_war(state, n, state.local_player_nation);
1630 };
1631 } else if(display.colors[0] == outline_color::red) {
1632 filter = [&](dcon::navy_id a) {
1633 auto n = state.world.navy_get_controller_from_navy_control(a);
1634 return military::are_at_war(state, n, state.local_player_nation);
1635 };
1636 } else if(display.colors[0] == outline_color::gray) {
1637 filter = [&](dcon::navy_id a) {
1638 auto n = state.world.navy_get_controller_from_navy_control(a);
1639 return n != state.local_player_nation && !military::are_allied_in_war(state, n, state.local_player_nation) && !military::are_at_war(state, n, state.local_player_nation);
1640 };
1641 }
1642
1643 float max_str = 0.0f;
1644 int32_t total_count = 0;
1645 int32_t ucount = 0;
1646
1647 for(auto a : state.world.province_get_navy_location(prov)) {
1648 if(filter(a.get_navy())) {
1649 ++ucount;
1650 float str = 0.0f;
1651 for(auto m : state.world.navy_get_navy_membership(a.get_navy())) {
1652 auto icon = state.military_definitions.unit_base_definitions[m.get_ship().get_type()].icon - 1;
1653 if(uint32_t(icon) >= by_icon_count.size()) {
1654 by_icon_count.resize(icon + 1, 0);
1655 }
1656 ++(by_icon_count[icon]);
1657 ++total_count;
1658
1659 str += m.get_ship().get_strength();
1660 display.top_left_value += m.get_ship().get_strength();
1661 display.top_left_org_value += m.get_ship().get_org();
1662 }
1663
1664 auto frame = status_frame(state, a.get_navy());
1665 if(display.top_left_status == -1) {
1666 display.top_left_status = int8_t(frame);
1667 } else if(display.top_left_status == int8_t(frame)) {
1668
1669 } else {
1671 }
1672
1673 if(str > max_str) {
1674 max_str = str;
1675 display.top_left_nation = state.world.navy_get_controller_from_navy_control(a.get_navy());
1676 }
1677 }
1678 }
1679
1680 if(ucount > 1 && display.colors_used == 1) {
1681 display.colors_used = 2;
1682 display.colors[1] = display.colors[0];
1683 }
1684
1685 display.top_left_org_value /= float(total_count);
1686
1687 battle->set_visible(state, false);
1688 siege->set_visible(state, state.world.province_get_siege_progress(prov) > 0);
1693 }
1694
1695 if(display.top_left_nation == state.local_player_nation) {
1696 int32_t max_index = 0;
1697 for(uint32_t i = 1; i < by_icon_count.size(); ++i) {
1698 if(by_icon_count[i] > by_icon_count[max_index])
1699 max_index = int32_t(i);
1700 }
1701 display.common_unit_1 = int8_t(max_index);
1702
1703 if(by_icon_count.size() > 0) {
1704 by_icon_count[max_index] = 0;
1705 max_index = 0;
1706 for(uint32_t i = 1; i < by_icon_count.size(); ++i) {
1707 if(by_icon_count[i] > by_icon_count[max_index])
1708 max_index = int32_t(i);
1709 }
1710 if(by_icon_count[max_index] > 0)
1711 display.common_unit_2 = int8_t(max_index);
1712 }
1713 }
1714 }
1715
1716
1717 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
1718 if(populated) {
1719 auto mid_point = state.world.province_get_mid_point(prov);
1720 auto map_pos = state.map_state.normalize_map_coord(mid_point);
1721 auto screen_size = glm::vec2{ float(state.x_size / state.user_settings.ui_scale), float(state.y_size / state.user_settings.ui_scale) };
1722 glm::vec2 screen_pos;
1723 if(!state.map_state.map_to_screen(state, map_pos, screen_size, screen_pos)) {
1724 visible = false;
1725 return;
1726 }
1727 if(!state.map_state.visible_provinces[province::to_map_id(prov)]) {
1728 visible = false;
1729 return;
1730 }
1731 visible = true;
1732
1733 auto new_position = xy_pair{ int16_t(screen_pos.x), int16_t(screen_pos.y) };
1735 window_element_base::impl_render(state, new_position.x, new_position.y);
1736 }
1737 }
1738
1739 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
1740 if(payload.holds_type<dcon::province_id>()) {
1741 payload.emplace<dcon::province_id>(prov);
1743 } else if(payload.holds_type<top_display_parameters*>()) {
1744 payload.emplace<top_display_parameters*>(&display);
1746 } else if(payload.holds_type< toggle_unit_grid>()) {
1747 auto with_shift = any_cast<toggle_unit_grid>(payload).with_shift;
1748
1749 if(state.ui_state.unit_details_box->for_province == prov && state.ui_state.unit_details_box->is_visible() == true) {
1750 state.ui_state.unit_details_box->set_visible(state, false);
1751 if(!with_shift) {
1752 state.selected_armies.clear();
1753 state.selected_navies.clear();
1754 } else {
1755 if(prov.index() >= state.province_definitions.first_sea_province.index()) {
1756 for(auto n : state.world.province_get_navy_location(prov)) {
1757 state.deselect(n.get_navy().id);
1758 }
1759 } else {
1760 for(auto n : state.world.province_get_army_location(prov)) {
1761 state.deselect(n.get_army().id);
1762 }
1763 }
1764 }
1765 } else {
1766 if(!with_shift) {
1767 state.selected_armies.clear();
1768 state.selected_navies.clear();
1769 }
1770
1771 if(prov.index() >= state.province_definitions.first_sea_province.index()) {
1772 for(auto n : state.world.province_get_navy_location(prov)) {
1773 // if(state.world.navy_get_controller_from_navy_control(n.get_navy()) == state.local_player_nation) {
1774 state.select(n.get_navy().id);
1775 // Hide province window when navy is clicked.
1776 if(state.ui_state.province_window) {
1777 state.ui_state.province_window->set_visible(state, false);
1778 state.map_state.set_selected_province(dcon::province_id{});
1779 }
1780 // }
1781 }
1782 } else {
1783 for(auto n : state.world.province_get_army_location(prov)) {
1784 if(!(n.get_army().get_navy_from_army_transport()) /* && n.get_army().get_controller_from_army_control() == state.local_player_nation */) {
1785 state.select(n.get_army().id);
1786 // Hide province window when army is clicked.
1787 if(state.ui_state.province_window) {
1788 state.ui_state.province_window->set_visible(state, false);
1789 state.map_state.set_selected_province(dcon::province_id{});
1790 }
1791 }
1792 }
1793 }
1794
1796 if(state.map_state.get_zoom() >= big_counter_cutoff) {
1797 int32_t height = 60;
1798 int32_t left = -30;
1799 int32_t right = 31;
1800 if(siege->is_visible()) {
1801 height = 80;
1802 right = 48;
1803 left = -49;
1804 } else if(battle->is_visible()) {
1805 height = 80;
1806 right = 62;
1807 left = -62;
1808 }
1809 location.x += int16_t(left);
1810 location.y -= 30;
1811 state.ui_state.unit_details_box->open(state, location, ui::xy_pair{int16_t(right - left), int16_t(height)}, prov, false);
1812 } else {
1813 if(siege->is_visible()) {
1814 location.x -= 49;
1815 location.y -= 10;
1816 state.ui_state.unit_details_box->open(state, location, ui::xy_pair{int16_t(97), int16_t(39)}, prov, false);
1817 } else if(battle->is_visible()) {
1818 location.x -= 62;
1819 location.y -= 10;
1820 state.ui_state.unit_details_box->open(state, location, ui::xy_pair{int16_t(124), int16_t(39)}, prov, false);
1821 } else {
1822 location.x -= 30;
1823 location.y -= 10;
1824 state.ui_state.unit_details_box->open(state, location, ui::xy_pair{int16_t(60), int16_t(19)}, prov, false);
1825 }
1826 }
1827 }
1828
1830 }
1832 }
1833
1834 mouse_probe impl_probe_mouse(sys::state& state, int32_t x, int32_t y, mouse_probe_type type) noexcept override {
1835 if(visible && populated)
1837 else
1838 return mouse_probe{ nullptr, ui::xy_pair{} };
1839 }
1840};
1841
1843public:
1844 void on_update(sys::state& state) noexcept override {
1845 auto p = retrieve<dcon::province_id>(state, parent);
1846 frame = 6 - state.world.province_get_building_level(p, uint8_t(economy::province_building_type::railroad));
1847 }
1848};
1850public:
1851 void on_update(sys::state& state) noexcept override {
1852 auto p = retrieve<dcon::province_id>(state, parent);
1853 frame = 6 - state.world.province_get_building_level(p, uint8_t(economy::province_building_type::fort));
1854 }
1855};
1856
1858public:
1861
1862 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
1863 if(last_update != state.ui_date) {
1864 cached_level = '0' + state.world.province_get_building_level(retrieve<dcon::province_id>(state, parent), uint8_t(economy::province_building_type::bank));
1865 last_update = state.ui_date;
1866 }
1868 ogl::color3f color{ 0.f, 0.f, 0.f };
1869 //ogl::render_text(state, &cached_level, 1, ogl::color_modification::none, float(x + 16 + 1.0f), float(y + 1.0f), color, 1);
1870 }
1871};
1872
1874public:
1877
1878 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
1879 if(last_update != state.ui_date) {
1880 cached_level = '0' + state.world.province_get_building_level(retrieve<dcon::province_id>(state, parent), uint8_t(economy::province_building_type::university));
1881 last_update = state.ui_date;
1882 }
1884 ogl::color3f color{ 0.f, 0.f, 0.f };
1885 //ogl::render_text(state, &cached_level, 1, ogl::color_modification::none, float(x + 16 + 1.0f), float(y + 1.0f), color, 1);
1886 }
1887};
1888
1890public:
1891
1892 dcon::province_id prov;
1894 bool visible = false;
1895
1903
1904 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1905 if(name == "capital_icon") {
1906 auto ptr = make_element_by_type<image_element_base>(state, id);
1907 capital_icon = ptr.get();
1908 return ptr;
1909 } else if(name == "rail_icon") {
1910 auto ptr = make_element_by_type<image_element_base>(state, id);
1911 rails_icon = ptr.get();
1912 return ptr;
1913 } else if(name == "rail_dots") {
1914 auto ptr = make_element_by_type<map_pv_rail_dots>(state, id);
1915 rails_dots = ptr.get();
1916 return ptr;
1917 } else if(name == "fort_icon") {
1918 auto ptr = make_element_by_type<image_element_base>(state, id);
1919 fort_icon = ptr.get();
1920 return ptr;
1921 } else if(name == "fort_dots") {
1922 auto ptr = make_element_by_type<map_pv_fort_dots>(state, id);
1923 fort_dots = ptr.get();
1924 return ptr;
1925 } else if(name == "bank_icon") {
1926 auto ptr = make_element_by_type<map_pv_bank>(state, id);
1927 bank_icon = ptr.get();
1928 return ptr;
1929 } else if(name == "university_icon") {
1930 auto ptr = make_element_by_type<map_pv_university>(state, id);
1931 unv_icon = ptr.get();
1932 return ptr;
1933 } else {
1934 return nullptr;
1935 }
1936 }
1937
1938 void impl_on_update(sys::state& state) noexcept override {
1939 if(!visible)
1940 return;
1941 if(last_update && state.ui_date == last_update)
1942 return;
1943
1944 last_update = state.ui_date;
1946
1947 for(auto& c : children) {
1948 if(c->is_visible()) {
1949 c->impl_on_update(state);
1950 }
1951 }
1952 }
1953
1954 void on_update(sys::state& state) noexcept override {
1955 int32_t rows = 0;
1956 if(state.world.nation_get_capital(state.world.province_get_nation_from_province_ownership(prov)) == prov) {
1958 ++rows;
1959 } else {
1961 }
1962 if(state.world.province_get_building_level(prov, uint8_t(economy::province_building_type::railroad)) != 0) {
1963 ++rows;
1966 } else {
1967 rails_icon->set_visible(state, false);
1968 rails_dots->set_visible(state, false);
1969 }
1970 if(state.world.province_get_building_level(prov, uint8_t(economy::province_building_type::fort)) != 0) {
1971 ++rows;
1972 fort_icon->set_visible(state, true);
1973 fort_dots->set_visible(state, true);
1974 } else {
1975 fort_icon->set_visible(state, false);
1976 fort_dots->set_visible(state, false);
1977 }
1978 if((state.economy_definitions.building_definitions[uint32_t(economy::province_building_type::university)].defined && state.world.province_get_building_level(prov, uint8_t(economy::province_building_type::university)) != 0)
1979 || (state.economy_definitions.building_definitions[uint32_t(economy::province_building_type::bank)].defined && state.world.province_get_building_level(prov, uint8_t(economy::province_building_type::bank)) != 0)) {
1980 ++rows;
1981 } else {
1982 bank_icon->set_visible(state, false);
1983 unv_icon->set_visible(state, false);
1984 }
1985
1986 auto top = (-16 * rows) / 2;
1987 if(state.world.nation_get_capital(state.world.province_get_nation_from_province_ownership(prov)) == prov) {
1988 capital_icon->base_data.position.y = int16_t(top - 2);
1989 capital_icon->base_data.position.x = int16_t(-10);
1990 top += 16;
1991 }
1992 if(state.world.province_get_building_level(prov, uint8_t(economy::province_building_type::railroad)) != 0) {
1993 rails_icon->base_data.position.y = int16_t(top );
1994 rails_dots->base_data.position.y = int16_t(top);
1995 int32_t total_width = 18 + 2 + 3 + 4 * state.world.province_get_building_level(prov, uint8_t(economy::province_building_type::railroad));
1996 rails_icon->base_data.position.x = int16_t(-total_width / 2);
1997 rails_dots->base_data.position.x = int16_t(20 -total_width / 2);
1998 top += 16;
1999 }
2000 if(state.world.province_get_building_level(prov, uint8_t(economy::province_building_type::fort)) != 0) {
2001 fort_icon->base_data.position.y = int16_t(top);
2002 fort_dots->base_data.position.y = int16_t(top);
2003 int32_t total_width = 18 + 2 + 3 + 4 * state.world.province_get_building_level(prov, uint8_t(economy::province_building_type::fort));
2004 fort_icon->base_data.position.x = int16_t(-total_width / 2);
2005 fort_dots->base_data.position.x = int16_t(20 - total_width / 2);
2006 top += 16;
2007 }
2008 if((state.economy_definitions.building_definitions[uint32_t(economy::province_building_type::university)].defined && state.world.province_get_building_level(prov, uint8_t(economy::province_building_type::university)) != 0)
2009 || (state.economy_definitions.building_definitions[uint32_t(economy::province_building_type::bank)].defined && state.world.province_get_building_level(prov, uint8_t(economy::province_building_type::bank)) != 0)) {
2010
2011
2012 if((state.economy_definitions.building_definitions[uint32_t(economy::province_building_type::university)].defined && state.world.province_get_building_level(prov, uint8_t(economy::province_building_type::university)) != 0)
2013 && (state.economy_definitions.building_definitions[uint32_t(economy::province_building_type::bank)].defined && state.world.province_get_building_level(prov, uint8_t(economy::province_building_type::bank)) != 0)) {
2014
2015 unv_icon->base_data.position.y = int16_t(top);
2016 unv_icon->base_data.position.x = int16_t(0);
2017 bank_icon->base_data.position.y = int16_t(top);
2018 bank_icon->base_data.position.x = int16_t(-32);
2019 bank_icon->set_visible(state, true);
2020 unv_icon->set_visible(state, true);
2021 } else if(state.economy_definitions.building_definitions[uint32_t(economy::province_building_type::university)].defined && state.world.province_get_building_level(prov, uint8_t(economy::province_building_type::university)) != 0) {
2022
2023 unv_icon->base_data.position.y = int16_t(top);
2024 unv_icon->base_data.position.x = int16_t(-16);
2025 bank_icon->set_visible(state, false);
2026 unv_icon->set_visible(state, true);
2027 } else if(state.economy_definitions.building_definitions[uint32_t(economy::province_building_type::bank)].defined && state.world.province_get_building_level(prov, uint8_t(economy::province_building_type::bank)) != 0) {
2028
2029 bank_icon->base_data.position.y = int16_t(top);
2030 bank_icon->base_data.position.x = int16_t(-16);
2031 bank_icon->set_visible(state, true);
2032 unv_icon->set_visible(state, false);
2033 }
2034 }
2035 }
2036
2037 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
2038 auto mid_point = state.world.province_get_mid_point(prov);
2039 auto map_pos = state.map_state.normalize_map_coord(mid_point);
2040 auto screen_size = glm::vec2{ float(state.x_size / state.user_settings.ui_scale), float(state.y_size / state.user_settings.ui_scale) };
2041 glm::vec2 screen_pos;
2042
2043 if(!state.map_state.map_to_screen(state, map_pos, screen_size, screen_pos)) {
2044 visible = false;
2045 return;
2046 }
2047
2048 if(screen_pos.x < -32 || screen_pos.y < -32 || screen_pos.x > state.ui_state.root->base_data.size.x + 32 || screen_pos.y > state.ui_state.root->base_data.size.y + 32) {
2049 visible = false;
2050 return;
2051 }
2052 if(visible == false) {
2053 visible = true;
2055 }
2056
2057
2058 auto new_position = xy_pair{ int16_t(screen_pos.x), int16_t(screen_pos.y) };
2060
2061 window_element_base::impl_render(state, new_position.x, new_position.y);
2062 }
2063
2064 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
2065 if(payload.holds_type<dcon::province_id>()) {
2066 payload.emplace<dcon::province_id>(prov);
2068 }
2070 }
2071
2072 mouse_probe impl_probe_mouse(sys::state& state, int32_t x, int32_t y, mouse_probe_type type) noexcept override {
2073 return mouse_probe{ nullptr, ui::xy_pair{} };
2074 }
2075};
2076
2078public:
2079 dcon::province_id content{};
2080 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
2081 auto mid_point = state.world.province_get_mid_point(content);
2082 auto map_pos = state.map_state.normalize_map_coord(mid_point);
2083 auto screen_size =
2084 glm::vec2{float(state.x_size / state.user_settings.ui_scale), float(state.y_size / state.user_settings.ui_scale)};
2085 glm::vec2 screen_pos;
2086 if(!state.map_state.map_to_screen(state, map_pos, screen_size, screen_pos))
2087 return;
2088 auto new_position = xy_pair{int16_t(screen_pos.x - base_data.size.x / 2), int16_t(screen_pos.y - base_data.size.y / 2)};
2090 image_element_base::impl_render(state, new_position.x, new_position.y);
2091 }
2092 void on_update(sys::state& state) noexcept override {
2093 auto cid = state.world.province_get_rgo(content).id;
2094 frame = int32_t(state.world.commodity_get_icon(cid));
2095 }
2096};
2097} // namespace ui
ANY_ALWAYS_INLINE bool holds_type() const noexcept
Definition: cyto_any.hpp:429
T & emplace(Args &&... args)
Definition: cyto_any.hpp:373
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void impl_on_update(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
void impl_render(sys::state &state, int32_t x, int32_t y) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
dcon::automated_army_group_id info
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_create(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
std::vector< std::unique_ptr< element_base > > children
element_base * parent
virtual message_result get(sys::state &state, Cyto::Any &payload) noexcept
virtual void impl_on_update(sys::state &state) noexcept
virtual void impl_render(sys::state &state, int32_t x, int32_t y) noexcept
bool is_visible() const
element_data base_data
void set_visible(sys::state &state, bool vis)
virtual mouse_probe impl_probe_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept
void on_update(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
virtual void set_current_nation(sys::state &state, dcon::national_identity_id identity) noexcept
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_create(sys::state &state) noexcept override
dcon::land_battle_id battle
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
mouse_probe impl_probe_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
void impl_render(sys::state &state, int32_t x, int32_t y) noexcept override
void render(sys::state &state, int32_t x, int32_t y) 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
mouse_probe impl_probe_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void impl_render(sys::state &state, int32_t x, int32_t y) noexcept override
dcon::naval_battle_id battle
message_result test_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_update(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_update(sys::state &state) noexcept override
outline_color color
mouse_probe impl_probe_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
void on_update(sys::state &state) noexcept override
void impl_render(sys::state &state, int32_t x, int32_t y) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void set_province(sys::state &state, dcon::province_id p)
dcon::province_id port_for
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
message_result test_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
message_result on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
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 impl_render(sys::state &state, int32_t x, int32_t y) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_update(sys::state &state) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
void impl_on_update(sys::state &state) noexcept override
mouse_probe impl_probe_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
void on_update(sys::state &state) noexcept override
dcon::province_id content
void impl_render(sys::state &state, int32_t x, int32_t y) noexcept override
void set_text(sys::state &state, std::string const &new_text)
void impl_render(sys::state &state, int32_t x, int32_t y) noexcept override
mouse_probe impl_probe_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_update(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_update(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
mouse_probe impl_probe_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
void on_update(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_update(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_update(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void button_shift_action(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void button_action(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
dcon::national_identity_id get_current_nation(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
void on_update(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
mouse_probe impl_probe_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
void impl_render(sys::state &state, int32_t x, int32_t y) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
void on_update(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_update(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
void on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void on_update(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
element_base * small_top_icon
element_base * top_right_icon
dcon::province_id prov
mouse_probe impl_probe_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
element_base * small_top_right_icon
void impl_render(sys::state &state, int32_t x, int32_t y) noexcept override
void impl_on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
top_display_parameters display
void on_create(sys::state &state) noexcept override
#define assert(condition)
Definition: debug.h:74
bool are_allied_in_war(sys::state const &state, dcon::nation_id a, dcon::nation_id b)
Definition: military.cpp:662
war_role get_role(sys::state const &state, dcon::war_id w, dcon::nation_id n)
Definition: military.cpp:2501
bool is_attacker(sys::state &state, dcon::war_id w, dcon::nation_id n)
Definition: military.cpp:2493
bool are_at_war(sys::state const &state, dcon::nation_id a, dcon::nation_id b)
Definition: military.cpp:649
GLuint get_rebel_flag_handle(sys::state &state, dcon::rebel_faction_id faction)
Definition: texture.cpp:1010
constexpr uint16_t to_map_id(dcon::province_id id)
Definition: province.hpp:10
void play_interface_sound(sys::state &state, audio_instance &s, float volume)
Definition: sound_nix.cpp:203
audio_instance & get_click_sound(sys::state &state)
Definition: sound_nix.cpp:263
key_modifiers
Definition: constants.hpp:156
std::string prettify(int64_t num)
Definition: text.cpp:762
constexpr float prov_details_cutoff
int32_t status_frame(sys::state &state, dcon::army_id a)
tooltip_behavior
void send(sys::state &state, element_base *parent, T value)
void populate_unit_tooltip(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
@ count
Definition: gui_event.hpp:126
message_result
constexpr float big_counter_cutoff
xy_pair get_absolute_non_mirror_location(sys::state &state, element_base const &node)
uint uint32_t
uchar uint8_t
static constexpr uint16_t is_attacking
Definition: military.hpp:73
static constexpr uint16_t mode_engaged
Definition: military.hpp:43
static constexpr uint16_t mode_approaching
Definition: military.hpp:42
static constexpr uint16_t mode_seeking
Definition: military.hpp:41
static constexpr uint16_t mode_retreating
Definition: military.hpp:44
static constexpr uint16_t mode_mask
Definition: military.hpp:40
static constexpr uint16_t is_attacking
Definition: military.hpp:48
Holds important data about the game world, state, and other data regarding windowing,...
std::unique_ptr< grid_box > unit_details_box
std::unique_ptr< element_base > root
element_base * naval_combat_window
element_base * province_window
element_base * army_combat_window
dcon::rebel_faction_id top_left_rebel
dcon::nation_id top_left_nation
dcon::nation_id top_right_nation
std::array< outline_color, 5 > colors
dcon::rebel_faction_id top_right_rebel