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
898 dcon::national_identity_id get_current_nation(sys::state& state) noexcept override {
899 top_display_parameters* params = retrieve<top_display_parameters*>(state, parent);
900 if(params)
901 return state.world.nation_get_identity_from_identity_holder(params->top_left_nation);
902 return dcon::national_identity_id{};
903 }
904};
905
907 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
908 if(name == "controller_flag") {
909 return make_element_by_type<tl_controller_flag>(state, id);
910 } else if(name == "strength") {
911 return make_element_by_type<tl_strength>(state, id);
912 } else if(name == "unit_1") {
913 return make_element_by_type<tl_unit_1>(state, id);
914 } else if(name == "unit_2") {
915 return make_element_by_type<tl_unit_2>(state, id);
916 } else if(name == "dig_in") {
917 return make_element_by_type<tl_dig_in>(state, id);
918 } else if(name == "status") {
919 return make_element_by_type<tl_status>(state, id);
920 } else if(name == "org_bar") {
921 return make_element_by_type<tl_org_bar>(state, id);
922 } else if(name == "edge1") {
923 auto ptr = make_element_by_type<tl_edge>(state, id);
924 ptr->number = 1;
925 return ptr;
926 } else if(name == "edge2") {
927 auto ptr = make_element_by_type<tl_edge>(state, id);
928 ptr->number = 2;
929 return ptr;
930 } else if(name == "edge3") {
931 auto ptr = make_element_by_type<tl_edge>(state, id);
932 ptr->number = 3;
933 return ptr;
934 } else if(name == "edge4") {
935 auto ptr = make_element_by_type<tl_edge>(state, id);
936 ptr->number = 4;
937 return ptr;
938 } else if(name == "frame_bg") {
939 return make_element_by_type<tl_frame_bg>(state, id);
940 } else {
941 return nullptr;
942 }
943 }
944
945 mouse_probe impl_probe_mouse(sys::state& state, int32_t x, int32_t y, mouse_probe_type type) noexcept override {
946 if(state.map_state.get_zoom() >= big_counter_cutoff)
948 else
949 return mouse_probe{ nullptr, ui::xy_pair{0,0} };
950 }
951 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
952 if(state.map_state.get_zoom() >= big_counter_cutoff)
954 }
955};
956
958 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
959 if(name == "controller_flag") {
960 return make_element_by_type<tl_sm_controller_flag>(state, id);
961 } else if(name == "strength") {
962 return make_element_by_type<tl_strength>(state, id);
963 } else if(name == "frame_bg") {
964 return make_element_by_type<tl_frame_bg>(state, id);
965 } else {
966 return nullptr;
967 }
968 }
969
970 mouse_probe impl_probe_mouse(sys::state& state, int32_t x, int32_t y, mouse_probe_type type) noexcept override {
971 if(state.map_state.get_zoom() < big_counter_cutoff)
973 else
974 return mouse_probe{ nullptr, ui::xy_pair{0,0} };
975 }
976 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
977 if(state.map_state.get_zoom() < big_counter_cutoff)
979 }
980};
981
982/*
983class select_army_group_button : public button_element_base {
984 void button_action(sys::state& state) noexcept override {
985 auto info = retrieve<dcon::automated_army_group_id>(state, parent);
986 state.select_army_group(info);
987 }
988
989 void on_update(sys::state& state) noexcept override {
990 auto info = retrieve<dcon::automated_army_group_id>(state, parent);
991
992 if(state.selected_army_group != nullptr) {
993 if(info != nullptr) {
994 if(info->hq == state.selected_army_group->hq) {
995 frame = 1;
996 return;
997 }
998 }
999 }
1000 frame = 0;
1001 }
1002};
1003*/
1004
1006 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1007 if(name == "frame_bg") {
1008 return make_element_by_type<select_army_group_button>(state, id);
1009 } else {
1010 return nullptr;
1011 }
1012 }
1013
1014 //mouse_probe impl_probe_mouse(sys::state& state, int32_t x, int32_t y, mouse_probe_type type) noexcept override {
1015 // return window_element_base::impl_probe_mouse(state, x, y, type);
1016 //}
1017 //void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
1018 // window_element_base::impl_render(state, x, y);
1019 //}
1020
1021 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
1022 if(payload.holds_type<dcon::automated_army_group_id>()) {
1023 payload.emplace<dcon::automated_army_group_id>(retrieve<dcon::automated_army_group_id>(state, parent));
1025 }
1027 }
1028};
1029
1031public:
1032 bool populated = false;
1033 bool visible = true;
1034
1035 dcon::automated_army_group_id info {};
1036
1038 dcon::province_id prov;
1040
1042
1043 void on_create(sys::state& state) noexcept override {
1046 }
1047
1048 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1049 if(name == "main_army_group_icon") {
1050 auto ptr = make_element_by_type<army_group_icon>(state, id);
1051 main_icon = ptr.get();
1052 return ptr;
1053 } else {
1054 return nullptr;
1055 }
1056 }
1057
1058 void impl_on_update(sys::state& state) noexcept override {
1060
1061 for(auto& c : children) {
1062 if(c->is_visible()) {
1063 c->impl_on_update(state);
1064 }
1065 }
1066 }
1067
1068 void on_update(sys::state& state) noexcept override {
1069 populated = false;
1070
1071 state.world.for_each_automated_army_group([&](dcon::automated_army_group_id item) {
1072 auto hq = state.world.automated_army_group_get_hq(item);
1073 if(hq == prov) {
1074 info = item;
1075 populated = true;
1076 }
1077 });
1078 }
1079
1080 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
1081 if(populated) {
1082 auto mid_point = state.world.province_get_mid_point(prov);
1083 auto map_pos = state.map_state.normalize_map_coord(mid_point);
1084 auto screen_size = glm::vec2{ float(state.x_size / state.user_settings.ui_scale), float(state.y_size / state.user_settings.ui_scale) };
1085 glm::vec2 screen_pos;
1086 if(!state.map_state.map_to_screen(state, map_pos, screen_size, screen_pos)) {
1087 visible = false;
1088 return;
1089 }
1090 if(!state.map_state.visible_provinces[province::to_map_id(prov)]) {
1091 visible = false;
1092 return;
1093 }
1094 visible = true;
1095
1096 auto new_position = xy_pair{ int16_t(screen_pos.x), int16_t(screen_pos.y) };
1098 window_element_base::impl_render(state, new_position.x, new_position.y);
1099 }
1100 }
1101
1102 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
1103 if(payload.holds_type<dcon::automated_army_group_id>()) {
1104 if(populated) payload.emplace<dcon::automated_army_group_id>(info);
1106 }
1108 }
1109};
1110
1112public:
1113 bool visible = true;
1114 bool populated = false;
1115
1116 dcon::province_id prov;
1123
1125
1126 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1127 if(name == "top_unit_icon") {
1128 auto ptr = make_element_by_type<top_unit_icon>(state, id);
1129 top_icon = ptr.get();
1130 return ptr;
1131 } else if(name == "top_right_unit_icon") {
1132 auto ptr = make_element_by_type<top_right_unit_icon>(state, id);
1133 top_right_icon = ptr.get();
1134 return ptr;
1135 } else if(name == "small_top_unit_icon") {
1136 auto ptr = make_element_by_type<small_top_unit_icon>(state, id);
1137 small_top_icon = ptr.get();
1138 return ptr;
1139 } else if(name == "small_top_right_unit_icon") {
1140 auto ptr = make_element_by_type<small_top_right_unit_icon>(state, id);
1141 small_top_right_icon = ptr.get();
1142 return ptr;
1143 } else if(name == "siege") {
1144 auto ptr = make_element_by_type<map_siege>(state, id);
1145 siege = ptr.get();
1146 return ptr;
1147 } else if(name == "battle") {
1148 auto ptr = make_element_by_type<map_battle>(state, id);
1149 battle = ptr.get();
1150 return ptr;
1151 } else {
1152 return nullptr;
1153 }
1154 }
1155
1156 void impl_on_update(sys::state& state) noexcept override {
1158 if(!populated)
1159 return;
1160
1161 for(auto& c : children) {
1162 if(c->is_visible()) {
1163 c->impl_on_update(state);
1164 }
1165 }
1166 }
1167
1168 void on_update(sys::state& state) noexcept override {
1169
1170 bool found_selected = false;
1171 bool all_selected = true;
1172 bool found_ally = false;
1173 bool found_enemy = false;
1174 bool found_other = false;
1175
1176 if(prov.index() < state.province_definitions.first_sea_province.index()) {
1177 populated = false;
1178 for(auto a : state.world.province_get_army_location(prov)) {
1179 if(!(a.get_army().get_navy_from_army_transport())) {
1180
1181 auto controller = a.get_army().get_controller_from_army_control().id;
1182
1183 if(state.is_selected(a.get_army()) && controller == state.local_player_nation)
1184 found_selected = true;
1185 else if(controller == state.local_player_nation)
1186 all_selected = false;
1187 else if(!controller || military::are_at_war(state, controller, state.local_player_nation))
1188 found_enemy = true;
1189 else if(military::are_allied_in_war(state, controller, state.local_player_nation))
1190 found_ally = true;
1191 else
1192 found_other = true;
1193
1194 populated = true;
1195 }
1196 }
1197 if(!populated) {
1198 return;
1199 }
1200 } else {
1201 populated = true;
1202 auto navies = state.world.province_get_navy_location(prov);
1203 if(navies.begin() == navies.end()) {
1204 populated = false;
1205 return;
1206 } else {
1207 for(auto n : navies) {
1208 auto controller = n.get_navy().get_controller_from_navy_control().id;
1209 if(state.is_selected(n.get_navy()) && controller == state.local_player_nation)
1210 found_selected = true;
1211 else if(controller == state.local_player_nation)
1212 all_selected = false;
1213 else if(!controller || military::are_at_war(state, controller, state.local_player_nation))
1214 found_enemy = true;
1215 else if(military::are_allied_in_war(state, controller, state.local_player_nation))
1216 found_ally = true;
1217 else
1218 found_other = true;
1219 }
1220 }
1221 if(!populated) {
1222 return;
1223 }
1224 }
1225
1226
1227 bool player_involved_battle = false;
1228 dcon::land_battle_id lbattle;
1229 dcon::naval_battle_id nbattle;
1230 for(auto b : state.world.province_get_land_battle_location(prov)) {
1231 auto w = b.get_battle().get_war_from_land_battle_in_war();
1232 if(!w) { //rebels
1233 player_involved_battle = true;
1234 lbattle = b.get_battle();
1236 break;
1237 } else if(military::get_role(state, w, state.local_player_nation) != military::war_role::none) { //in a war
1238 player_involved_battle = true;
1240 lbattle = b.get_battle();
1241 break;
1242 }
1243 }
1244 if(!player_involved_battle) {
1245 for(auto b : state.world.province_get_naval_battle_location(prov)) {
1246 auto w = b.get_battle().get_war_from_naval_battle_in_war();
1247 if(military::get_role(state, w, state.local_player_nation) != military::war_role::none) {
1248 player_involved_battle = true;
1249 nbattle = b.get_battle();
1250 break;
1251 }
1252 }
1253 }
1254
1255 display.colors_used = 0;
1256
1257 if(found_selected) {
1260 }
1261 if(!all_selected) {
1264 }
1265 if(!player_involved_battle) {
1266 if(found_enemy) {
1269 }
1270 }
1271 if(found_ally) {
1274 }
1275 if(found_other) {
1278 }
1279
1280 static std::vector<int32_t> by_icon_count;
1281 for(auto& i : by_icon_count)
1282 i = 0;
1283
1284
1286 display.top_dig_in = -1;
1291 display.top_left_value = 0.0f;
1292 display.top_right_value = 0.0f;
1296 display.is_army = false;
1297
1301
1302
1303 if(lbattle) {
1304 display.is_army = true;
1305 float max_str = 0.0f;
1306 float max_opp_str = 0.0f;
1307 int32_t total_count = 0;
1308 int32_t total_opp_count = 0;
1309
1310 auto w = state.world.land_battle_get_war_from_land_battle_in_war(lbattle);
1311 bool player_is_attacker = w ? military::is_attacker(state, w, state.local_player_nation) : false;
1312
1313 bool land_battle_attacker_is_player = false;
1314 if (player_is_attacker && state.world.land_battle_get_war_attacker_is_attacker(lbattle))
1315 land_battle_attacker_is_player = true;
1316 else if (!player_is_attacker && !state.world.land_battle_get_war_attacker_is_attacker(lbattle))
1317 land_battle_attacker_is_player = true;
1318
1319 display.player_is_attacker = land_battle_attacker_is_player;
1320
1322
1323 display.attacker_casualties = state.world.land_battle_get_attacker_casualties(lbattle);
1324 display.defender_casualties = state.world.land_battle_get_defender_casualties(lbattle);
1325
1326 for(auto ar : state.world.land_battle_get_army_battle_participation(lbattle)) {
1327 auto controller = ar.get_army().get_controller_from_army_control();
1328
1329 if(!controller || military::is_attacker(state, w, controller) != player_is_attacker) { // opposed
1331 float str = 0.0f;
1332 for(auto m : state.world.army_get_army_membership(ar.get_army())) {
1333 ++total_opp_count;
1334
1335 str += m.get_regiment().get_strength();
1336 display.top_right_value += m.get_regiment().get_strength();
1337 display.top_right_org_value += m.get_regiment().get_org();
1338 }
1339
1340 auto dig_in = ar.get_army().get_dig_in();
1341 if(display.top_right_dig_in == -1) {
1342 display.top_right_dig_in = int8_t(dig_in);
1343 } else {
1344 display.top_right_dig_in = std::min(display.top_right_dig_in, int8_t(dig_in));
1345 }
1346
1347 if(str > max_opp_str) {
1348 max_opp_str = str;
1349 display.top_right_nation = controller;
1350 display.top_right_rebel = ar.get_army().get_controller_from_army_rebel_control();
1351 }
1352 } else { // same side
1353 float str = 0.0f;
1354 for(auto m : state.world.army_get_army_membership(ar.get_army())) {
1355 auto icon = state.military_definitions.unit_base_definitions[m.get_regiment().get_type()].icon - 1;
1356 if(uint32_t(icon) >= by_icon_count.size()) {
1357 by_icon_count.resize(icon + 1, 0);
1358 }
1359 ++(by_icon_count[icon]);
1360 ++total_count;
1361
1362 str += m.get_regiment().get_strength();
1363 display.top_left_value += m.get_regiment().get_strength();
1364 display.top_left_org_value += m.get_regiment().get_org();
1365 }
1366
1367 auto dig_in = ar.get_army().get_dig_in();
1368 if(display.top_dig_in == -1) {
1369 display.top_dig_in = int8_t(dig_in);
1370 } else {
1371 display.top_dig_in = std::min(display.top_dig_in, int8_t(dig_in));
1372 }
1373
1374 if(str > max_str) {
1375 max_str = str;
1376 display.top_left_nation = controller;
1377 display.top_left_rebel = dcon::rebel_faction_id{};
1378 }
1379 }
1380 }
1381
1382 display.top_left_org_value /= float(total_count);
1383 display.top_right_org_value /= float(total_opp_count);
1384
1385 int32_t areg = 0;
1386 int32_t breg = 0;
1387
1388 for(auto reg : state.world.land_battle_get_reserves(lbattle)) {
1389 if((reg.flags & military::reserve_regiment::is_attacking) != 0)
1390 ++areg;
1391 else
1392 ++breg;
1393 }
1394
1395 auto& att_back = state.world.land_battle_get_attacker_back_line(lbattle);
1396 auto& def_back = state.world.land_battle_get_defender_back_line(lbattle);
1397 auto& att_front = state.world.land_battle_get_attacker_front_line(lbattle);
1398 auto& def_front = state.world.land_battle_get_defender_front_line(lbattle);
1399 for(auto r : att_back) {
1400 if(r)
1401 ++areg;
1402 }
1403 for(auto r : att_front) {
1404 if(r)
1405 ++areg;
1406 }
1407 for(auto r : def_back) {
1408 if(r)
1409 ++breg;
1410 }
1411 for(auto r : def_front) {
1412 if(r)
1413 ++breg;
1414 }
1415 if(state.world.land_battle_get_war_attacker_is_attacker(lbattle) == player_is_attacker) {
1416 display.battle_progress = float(areg) / float(areg + breg);
1417 } else {
1418 display.battle_progress = float(breg) / float(areg + breg);
1419 }
1420
1421 battle->set_visible(state, true);
1422 siege->set_visible(state, false);
1427 }
1428 else if(nbattle) {
1429 float max_str = 0.0f;
1430 float max_opp_str = 0.0f;
1431 int32_t total_count = 0;
1432 int32_t total_opp_count = 0;
1433
1434 auto w = state.world.naval_battle_get_war_from_naval_battle_in_war(nbattle);
1435 bool player_is_attacker = w ? military::is_attacker(state, w, state.local_player_nation) : false;
1436
1438
1439 for(auto ar : state.world.naval_battle_get_navy_battle_participation(nbattle)) {
1440 auto controller = ar.get_navy().get_controller_from_navy_control();
1441 if(!controller || military::is_attacker(state, w, controller) != player_is_attacker) { // opposed
1443
1444 float str = 0.0f;
1445 for(auto m : state.world.navy_get_navy_membership(ar.get_navy())) {
1446 ++total_opp_count;
1447
1448 str += m.get_ship().get_strength();
1449 display.top_right_value += m.get_ship().get_strength();
1450 display.top_right_org_value += m.get_ship().get_org();
1451 }
1452
1453 if(str > max_opp_str) {
1454 max_opp_str = str;
1455 display.top_right_nation = controller;
1456 display.top_right_rebel = dcon::rebel_faction_id{};
1457 }
1458 } else { // same side
1459 float str = 0.0f;
1460 for(auto m : state.world.navy_get_navy_membership(ar.get_navy())) {
1461 auto icon = state.military_definitions.unit_base_definitions[m.get_ship().get_type()].icon - 1;
1462 if(uint32_t(icon) >= by_icon_count.size()) {
1463 by_icon_count.resize(icon + 1, 0);
1464 }
1465 ++(by_icon_count[icon]);
1466 ++total_count;
1467
1468 str += m.get_ship().get_strength();
1469 display.top_left_value += m.get_ship().get_strength();
1470 display.top_left_org_value += m.get_ship().get_org();
1471 }
1472
1473 if(str > max_str) {
1474 max_str = str;
1475 display.top_left_nation = controller;
1476 display.top_left_rebel = dcon::rebel_faction_id{};
1477 }
1478 }
1479 }
1480
1481 display.top_left_org_value /= float(total_count);
1482 display.top_right_org_value /= float(total_opp_count);
1483
1484 int32_t attacker_ships = 0;
1485 int32_t defender_ships = 0;
1486
1487 auto slots = state.world.naval_battle_get_slots(nbattle);
1488
1489 for(uint32_t j = slots.size(); j-- > 0;) {
1490 switch(slots[j].flags & military::ship_in_battle::mode_mask) {
1495 if((slots[j].flags & military::ship_in_battle::is_attacking) != 0)
1496 ++attacker_ships;
1497 else
1498 ++defender_ships;
1499 break;
1500 default:
1501 break;
1502 }
1503 }
1504
1505 if(state.world.naval_battle_get_war_attacker_is_attacker(nbattle) == player_is_attacker) {
1506 display.battle_progress = float(attacker_ships) / float(attacker_ships + defender_ships);
1507 } else {
1508 display.battle_progress = float(defender_ships) / float(attacker_ships + defender_ships);
1509 }
1510
1511 battle->set_visible(state, true);
1512 siege->set_visible(state, false);
1517 }
1518 else if(prov.index() < state.province_definitions.first_sea_province.index()) {
1519 std::function<bool(dcon::army_id)> filter;
1520
1522 display.top_left_nation = state.local_player_nation;
1523 display.top_left_rebel = dcon::rebel_faction_id{};
1524 filter = [&](dcon::army_id a) { return state.world.army_get_controller_from_army_control(a) == state.local_player_nation && state.is_selected(a); };
1525 } else if(display.colors[0] == outline_color::blue) {
1526 display.top_left_nation = state.local_player_nation;
1527 display.top_left_rebel = dcon::rebel_faction_id{};
1528 filter = [&](dcon::army_id a) { return state.world.army_get_controller_from_army_control(a) == state.local_player_nation && !state.is_selected(a); };
1529 } else if(display.colors[0] == outline_color::cyan) {
1530 filter = [&](dcon::army_id a) {
1531 auto n = state.world.army_get_controller_from_army_control(a);
1532 return n != state.local_player_nation && military::are_allied_in_war(state, n, state.local_player_nation);
1533 };
1534 } else if(display.colors[0] == outline_color::red) {
1535 filter = [&](dcon::army_id a) {
1536 auto n = state.world.army_get_controller_from_army_control(a);
1537 return !n || military::are_at_war(state, n, state.local_player_nation);
1538 };
1539 } else if(display.colors[0] == outline_color::gray) {
1540 filter = [&](dcon::army_id a) {
1541 auto n = state.world.army_get_controller_from_army_control(a);
1542 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);
1543 };
1544 }
1545
1546 float max_str = 0.0f;
1547
1548 int32_t total_count = 0;
1549 int32_t ucount = 0;
1550
1551 for(auto a : state.world.province_get_army_location(prov)) {
1552 if(!(a.get_army().get_navy_from_army_transport()) && filter(a.get_army())) {
1553 ++ucount;
1554 float str = 0.0f;
1555 for(auto m : state.world.army_get_army_membership(a.get_army())) {
1556 auto icon = state.military_definitions.unit_base_definitions[m.get_regiment().get_type()].icon - 1;
1557 icon = std::max(icon, 0);
1558 if(uint32_t(icon) >= by_icon_count.size()) {
1559 by_icon_count.resize(icon + 1, 0);
1560 }
1561 ++(by_icon_count[icon]);
1562 ++total_count;
1563
1564 str += m.get_regiment().get_strength();
1565 display.is_army = true;
1566 display.top_left_value += m.get_regiment().get_strength();
1567 display.top_left_org_value += m.get_regiment().get_org();
1568 }
1569
1570 auto frame = status_frame(state, a.get_army());
1571 if(display.top_left_status == -1) {
1572 display.top_left_status = int8_t(frame);
1573 } else if(display.top_left_status == int8_t(frame)) {
1574
1575 } else {
1577 }
1578
1579 auto dig_in = a.get_army().get_dig_in();
1580 if(display.top_dig_in == -1) {
1581 display.top_dig_in = int8_t(dig_in);
1582 } else {
1583 display.top_dig_in = std::min(display.top_dig_in, int8_t(dig_in));
1584 }
1585
1586 if(str > max_str) {
1587 max_str = str;
1588 display.top_left_nation = state.world.army_get_controller_from_army_control(a.get_army());
1589 display.top_left_rebel = state.world.army_get_controller_from_army_rebel_control(a.get_army());
1590 }
1591 }
1592 }
1593
1594 if(ucount > 1 && display.colors_used == 1) {
1595 display.colors_used = 2;
1596 display.colors[1] = display.colors[0];
1597 }
1598
1599 display.top_left_org_value /= float(total_count);
1600
1601 battle->set_visible(state, false);
1602 siege->set_visible(state, state.world.province_get_siege_progress(prov) > 0.f);
1607 } else {
1608 std::function<bool(dcon::navy_id)> filter;
1609 display.top_left_rebel = dcon::rebel_faction_id{};
1610
1612 display.top_left_nation = state.local_player_nation;
1613 filter = [&](dcon::navy_id a) { return state.world.navy_get_controller_from_navy_control(a) == state.local_player_nation && state.is_selected(a); };
1614 } else if(display.colors[0] == outline_color::blue) {
1615 display.top_left_nation = state.local_player_nation;
1616 filter = [&](dcon::navy_id a) { return state.world.navy_get_controller_from_navy_control(a) == state.local_player_nation && !state.is_selected(a); };
1617 } else if(display.colors[0] == outline_color::cyan) {
1618 filter = [&](dcon::navy_id a) {
1619 auto n = state.world.navy_get_controller_from_navy_control(a);
1620 return n != state.local_player_nation && military::are_allied_in_war(state, n, state.local_player_nation);
1621 };
1622 } else if(display.colors[0] == outline_color::red) {
1623 filter = [&](dcon::navy_id a) {
1624 auto n = state.world.navy_get_controller_from_navy_control(a);
1625 return military::are_at_war(state, n, state.local_player_nation);
1626 };
1627 } else if(display.colors[0] == outline_color::gray) {
1628 filter = [&](dcon::navy_id a) {
1629 auto n = state.world.navy_get_controller_from_navy_control(a);
1630 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);
1631 };
1632 }
1633
1634 float max_str = 0.0f;
1635 int32_t total_count = 0;
1636 int32_t ucount = 0;
1637
1638 for(auto a : state.world.province_get_navy_location(prov)) {
1639 if(filter(a.get_navy())) {
1640 ++ucount;
1641 float str = 0.0f;
1642 for(auto m : state.world.navy_get_navy_membership(a.get_navy())) {
1643 auto icon = state.military_definitions.unit_base_definitions[m.get_ship().get_type()].icon - 1;
1644 if(uint32_t(icon) >= by_icon_count.size()) {
1645 by_icon_count.resize(icon + 1, 0);
1646 }
1647 ++(by_icon_count[icon]);
1648 ++total_count;
1649
1650 str += m.get_ship().get_strength();
1651 display.top_left_value += m.get_ship().get_strength();
1652 display.top_left_org_value += m.get_ship().get_org();
1653 }
1654
1655 auto frame = status_frame(state, a.get_navy());
1656 if(display.top_left_status == -1) {
1657 display.top_left_status = int8_t(frame);
1658 } else if(display.top_left_status == int8_t(frame)) {
1659
1660 } else {
1662 }
1663
1664 if(str > max_str) {
1665 max_str = str;
1666 display.top_left_nation = state.world.navy_get_controller_from_navy_control(a.get_navy());
1667 }
1668 }
1669 }
1670
1671 if(ucount > 1 && display.colors_used == 1) {
1672 display.colors_used = 2;
1673 display.colors[1] = display.colors[0];
1674 }
1675
1676 display.top_left_org_value /= float(total_count);
1677
1678 battle->set_visible(state, false);
1679 siege->set_visible(state, state.world.province_get_siege_progress(prov) > 0);
1684 }
1685
1686 if(display.top_left_nation == state.local_player_nation) {
1687 int32_t max_index = 0;
1688 for(uint32_t i = 1; i < by_icon_count.size(); ++i) {
1689 if(by_icon_count[i] > by_icon_count[max_index])
1690 max_index = int32_t(i);
1691 }
1692 display.common_unit_1 = int8_t(max_index);
1693
1694 if(by_icon_count.size() > 0) {
1695 by_icon_count[max_index] = 0;
1696 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 if(by_icon_count[max_index] > 0)
1702 display.common_unit_2 = int8_t(max_index);
1703 }
1704 }
1705 }
1706
1707
1708 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
1709 if(populated) {
1710 auto mid_point = state.world.province_get_mid_point(prov);
1711 auto map_pos = state.map_state.normalize_map_coord(mid_point);
1712 auto screen_size = glm::vec2{ float(state.x_size / state.user_settings.ui_scale), float(state.y_size / state.user_settings.ui_scale) };
1713 glm::vec2 screen_pos;
1714 if(!state.map_state.map_to_screen(state, map_pos, screen_size, screen_pos)) {
1715 visible = false;
1716 return;
1717 }
1718 if(!state.map_state.visible_provinces[province::to_map_id(prov)]) {
1719 visible = false;
1720 return;
1721 }
1722 visible = true;
1723
1724 auto new_position = xy_pair{ int16_t(screen_pos.x), int16_t(screen_pos.y) };
1726 window_element_base::impl_render(state, new_position.x, new_position.y);
1727 }
1728 }
1729
1730 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
1731 if(payload.holds_type<dcon::province_id>()) {
1732 payload.emplace<dcon::province_id>(prov);
1734 } else if(payload.holds_type<top_display_parameters*>()) {
1735 payload.emplace<top_display_parameters*>(&display);
1737 } else if(payload.holds_type< toggle_unit_grid>()) {
1738 auto with_shift = any_cast<toggle_unit_grid>(payload).with_shift;
1739
1740 if(state.ui_state.unit_details_box->for_province == prov && state.ui_state.unit_details_box->is_visible() == true) {
1741 state.ui_state.unit_details_box->set_visible(state, false);
1742 if(!with_shift) {
1743 state.selected_armies.clear();
1744 state.selected_navies.clear();
1745 } else {
1746 if(prov.index() >= state.province_definitions.first_sea_province.index()) {
1747 for(auto n : state.world.province_get_navy_location(prov)) {
1748 state.deselect(n.get_navy().id);
1749 }
1750 } else {
1751 for(auto n : state.world.province_get_army_location(prov)) {
1752 state.deselect(n.get_army().id);
1753 }
1754 }
1755 }
1756 } else {
1757 if(!with_shift) {
1758 state.selected_armies.clear();
1759 state.selected_navies.clear();
1760 }
1761
1762 if(prov.index() >= state.province_definitions.first_sea_province.index()) {
1763 for(auto n : state.world.province_get_navy_location(prov)) {
1764 // if(state.world.navy_get_controller_from_navy_control(n.get_navy()) == state.local_player_nation) {
1765 state.select(n.get_navy().id);
1766 // Hide province window when navy is clicked.
1767 if(state.ui_state.province_window) {
1768 state.ui_state.province_window->set_visible(state, false);
1769 state.map_state.set_selected_province(dcon::province_id{});
1770 }
1771 // }
1772 }
1773 } else {
1774 for(auto n : state.world.province_get_army_location(prov)) {
1775 if(!(n.get_army().get_navy_from_army_transport()) /* && n.get_army().get_controller_from_army_control() == state.local_player_nation */) {
1776 state.select(n.get_army().id);
1777 // Hide province window when army is clicked.
1778 if(state.ui_state.province_window) {
1779 state.ui_state.province_window->set_visible(state, false);
1780 state.map_state.set_selected_province(dcon::province_id{});
1781 }
1782 }
1783 }
1784 }
1785
1787 if(state.map_state.get_zoom() >= big_counter_cutoff) {
1788 int32_t height = 60;
1789 int32_t left = -30;
1790 int32_t right = 31;
1791 if(siege->is_visible()) {
1792 height = 80;
1793 right = 48;
1794 left = -49;
1795 } else if(battle->is_visible()) {
1796 height = 80;
1797 right = 62;
1798 left = -62;
1799 }
1800 location.x += int16_t(left);
1801 location.y -= 30;
1802 state.ui_state.unit_details_box->open(state, location, ui::xy_pair{int16_t(right - left), int16_t(height)}, prov, false);
1803 } else {
1804 if(siege->is_visible()) {
1805 location.x -= 49;
1806 location.y -= 10;
1807 state.ui_state.unit_details_box->open(state, location, ui::xy_pair{int16_t(97), int16_t(39)}, prov, false);
1808 } else if(battle->is_visible()) {
1809 location.x -= 62;
1810 location.y -= 10;
1811 state.ui_state.unit_details_box->open(state, location, ui::xy_pair{int16_t(124), int16_t(39)}, prov, false);
1812 } else {
1813 location.x -= 30;
1814 location.y -= 10;
1815 state.ui_state.unit_details_box->open(state, location, ui::xy_pair{int16_t(60), int16_t(19)}, prov, false);
1816 }
1817 }
1818 }
1819
1821 }
1823 }
1824
1825 mouse_probe impl_probe_mouse(sys::state& state, int32_t x, int32_t y, mouse_probe_type type) noexcept override {
1826 if(visible && populated)
1828 else
1829 return mouse_probe{ nullptr, ui::xy_pair{} };
1830 }
1831};
1832
1834public:
1835 void on_update(sys::state& state) noexcept override {
1836 auto p = retrieve<dcon::province_id>(state, parent);
1837 frame = 6 - state.world.province_get_building_level(p, uint8_t(economy::province_building_type::railroad));
1838 }
1839};
1841public:
1842 void on_update(sys::state& state) noexcept override {
1843 auto p = retrieve<dcon::province_id>(state, parent);
1844 frame = 6 - state.world.province_get_building_level(p, uint8_t(economy::province_building_type::fort));
1845 }
1846};
1847
1849public:
1852
1853 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
1854 if(last_update != state.ui_date) {
1855 cached_level = '0' + state.world.province_get_building_level(retrieve<dcon::province_id>(state, parent), uint8_t(economy::province_building_type::bank));
1856 last_update = state.ui_date;
1857 }
1859 ogl::color3f color{ 0.f, 0.f, 0.f };
1860 //ogl::render_text(state, &cached_level, 1, ogl::color_modification::none, float(x + 16 + 1.0f), float(y + 1.0f), color, 1);
1861 }
1862};
1863
1865public:
1868
1869 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
1870 if(last_update != state.ui_date) {
1871 cached_level = '0' + state.world.province_get_building_level(retrieve<dcon::province_id>(state, parent), uint8_t(economy::province_building_type::university));
1872 last_update = state.ui_date;
1873 }
1875 ogl::color3f color{ 0.f, 0.f, 0.f };
1876 //ogl::render_text(state, &cached_level, 1, ogl::color_modification::none, float(x + 16 + 1.0f), float(y + 1.0f), color, 1);
1877 }
1878};
1879
1881public:
1882
1883 dcon::province_id prov;
1885 bool visible = false;
1886
1894
1895 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1896 if(name == "capital_icon") {
1897 auto ptr = make_element_by_type<image_element_base>(state, id);
1898 capital_icon = ptr.get();
1899 return ptr;
1900 } else if(name == "rail_icon") {
1901 auto ptr = make_element_by_type<image_element_base>(state, id);
1902 rails_icon = ptr.get();
1903 return ptr;
1904 } else if(name == "rail_dots") {
1905 auto ptr = make_element_by_type<map_pv_rail_dots>(state, id);
1906 rails_dots = ptr.get();
1907 return ptr;
1908 } else if(name == "fort_icon") {
1909 auto ptr = make_element_by_type<image_element_base>(state, id);
1910 fort_icon = ptr.get();
1911 return ptr;
1912 } else if(name == "fort_dots") {
1913 auto ptr = make_element_by_type<map_pv_fort_dots>(state, id);
1914 fort_dots = ptr.get();
1915 return ptr;
1916 } else if(name == "bank_icon") {
1917 auto ptr = make_element_by_type<map_pv_bank>(state, id);
1918 bank_icon = ptr.get();
1919 return ptr;
1920 } else if(name == "university_icon") {
1921 auto ptr = make_element_by_type<map_pv_university>(state, id);
1922 unv_icon = ptr.get();
1923 return ptr;
1924 } else {
1925 return nullptr;
1926 }
1927 }
1928
1929 void impl_on_update(sys::state& state) noexcept override {
1930 if(!visible)
1931 return;
1932 if(last_update && state.ui_date == last_update)
1933 return;
1934
1935 last_update = state.ui_date;
1937
1938 for(auto& c : children) {
1939 if(c->is_visible()) {
1940 c->impl_on_update(state);
1941 }
1942 }
1943 }
1944
1945 void on_update(sys::state& state) noexcept override {
1946 int32_t rows = 0;
1947 if(state.world.nation_get_capital(state.world.province_get_nation_from_province_ownership(prov)) == prov) {
1949 ++rows;
1950 } else {
1952 }
1953 if(state.world.province_get_building_level(prov, uint8_t(economy::province_building_type::railroad)) != 0) {
1954 ++rows;
1957 } else {
1958 rails_icon->set_visible(state, false);
1959 rails_dots->set_visible(state, false);
1960 }
1961 if(state.world.province_get_building_level(prov, uint8_t(economy::province_building_type::fort)) != 0) {
1962 ++rows;
1963 fort_icon->set_visible(state, true);
1964 fort_dots->set_visible(state, true);
1965 } else {
1966 fort_icon->set_visible(state, false);
1967 fort_dots->set_visible(state, false);
1968 }
1969 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)
1970 || (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)) {
1971 ++rows;
1972 } else {
1973 bank_icon->set_visible(state, false);
1974 unv_icon->set_visible(state, false);
1975 }
1976
1977 auto top = (-16 * rows) / 2;
1978 if(state.world.nation_get_capital(state.world.province_get_nation_from_province_ownership(prov)) == prov) {
1979 capital_icon->base_data.position.y = int16_t(top - 2);
1980 capital_icon->base_data.position.x = int16_t(-10);
1981 top += 16;
1982 }
1983 if(state.world.province_get_building_level(prov, uint8_t(economy::province_building_type::railroad)) != 0) {
1984 rails_icon->base_data.position.y = int16_t(top );
1985 rails_dots->base_data.position.y = int16_t(top);
1986 int32_t total_width = 18 + 2 + 3 + 4 * state.world.province_get_building_level(prov, uint8_t(economy::province_building_type::railroad));
1987 rails_icon->base_data.position.x = int16_t(-total_width / 2);
1988 rails_dots->base_data.position.x = int16_t(20 -total_width / 2);
1989 top += 16;
1990 }
1991 if(state.world.province_get_building_level(prov, uint8_t(economy::province_building_type::fort)) != 0) {
1992 fort_icon->base_data.position.y = int16_t(top);
1993 fort_dots->base_data.position.y = int16_t(top);
1994 int32_t total_width = 18 + 2 + 3 + 4 * state.world.province_get_building_level(prov, uint8_t(economy::province_building_type::fort));
1995 fort_icon->base_data.position.x = int16_t(-total_width / 2);
1996 fort_dots->base_data.position.x = int16_t(20 - total_width / 2);
1997 top += 16;
1998 }
1999 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)
2000 || (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)) {
2001
2002
2003 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)
2004 && (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)) {
2005
2006 unv_icon->base_data.position.y = int16_t(top);
2007 unv_icon->base_data.position.x = int16_t(0);
2008 bank_icon->base_data.position.y = int16_t(top);
2009 bank_icon->base_data.position.x = int16_t(-32);
2010 bank_icon->set_visible(state, true);
2011 unv_icon->set_visible(state, true);
2012 } 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) {
2013
2014 unv_icon->base_data.position.y = int16_t(top);
2015 unv_icon->base_data.position.x = int16_t(-16);
2016 bank_icon->set_visible(state, false);
2017 unv_icon->set_visible(state, true);
2018 } 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) {
2019
2020 bank_icon->base_data.position.y = int16_t(top);
2021 bank_icon->base_data.position.x = int16_t(-16);
2022 bank_icon->set_visible(state, true);
2023 unv_icon->set_visible(state, false);
2024 }
2025 }
2026 }
2027
2028 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
2029 auto mid_point = state.world.province_get_mid_point(prov);
2030 auto map_pos = state.map_state.normalize_map_coord(mid_point);
2031 auto screen_size = glm::vec2{ float(state.x_size / state.user_settings.ui_scale), float(state.y_size / state.user_settings.ui_scale) };
2032 glm::vec2 screen_pos;
2033
2034 if(!state.map_state.map_to_screen(state, map_pos, screen_size, screen_pos)) {
2035 visible = false;
2036 return;
2037 }
2038
2039 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) {
2040 visible = false;
2041 return;
2042 }
2043 if(visible == false) {
2044 visible = true;
2046 }
2047
2048
2049 auto new_position = xy_pair{ int16_t(screen_pos.x), int16_t(screen_pos.y) };
2051
2052 window_element_base::impl_render(state, new_position.x, new_position.y);
2053 }
2054
2055 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
2056 if(payload.holds_type<dcon::province_id>()) {
2057 payload.emplace<dcon::province_id>(prov);
2059 }
2061 }
2062
2063 mouse_probe impl_probe_mouse(sys::state& state, int32_t x, int32_t y, mouse_probe_type type) noexcept override {
2064 return mouse_probe{ nullptr, ui::xy_pair{} };
2065 }
2066};
2067
2069public:
2070 dcon::province_id content{};
2071 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
2072 auto mid_point = state.world.province_get_mid_point(content);
2073 auto map_pos = state.map_state.normalize_map_coord(mid_point);
2074 auto screen_size =
2075 glm::vec2{float(state.x_size / state.user_settings.ui_scale), float(state.y_size / state.user_settings.ui_scale)};
2076 glm::vec2 screen_pos;
2077 if(!state.map_state.map_to_screen(state, map_pos, screen_size, screen_pos))
2078 return;
2079 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)};
2081 image_element_base::impl_render(state, new_position.x, new_position.y);
2082 }
2083 void on_update(sys::state& state) noexcept override {
2084 auto cid = state.world.province_get_rgo(content).id;
2085 frame = int32_t(state.world.commodity_get_icon(cid));
2086 }
2087};
2088} // 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
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
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:486
war_role get_role(sys::state const &state, dcon::war_id w, dcon::nation_id n)
Definition: military.cpp:2242
bool is_attacker(sys::state &state, dcon::war_id w, dcon::nation_id n)
Definition: military.cpp:2234
bool are_at_war(sys::state const &state, dcon::nation_id a, dcon::nation_id b)
Definition: military.cpp:475
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
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