44 if constexpr(std::is_same_v<T, dcon::army_id>) {
46 }
else if constexpr(std::is_same_v<T, dcon::navy_id>) {
61 if constexpr(std::is_same_v<T, dcon::army_id>) {
66 state.select(content);
71 if constexpr(std::is_same_v<T, dcon::army_id>) {
92 if constexpr(std::is_same_v<T, dcon::army_id>) {
102 if constexpr(std::is_same_v<T, dcon::army_id>) {
151 if constexpr(std::is_same_v<T, dcon::army_id>) {
153 set_text(
state, std::string(
state.to_string_view(fat.get_general_from_army_leadership().get_name())));
156 set_text(
state, std::string(
state.to_string_view(fat.get_admiral_from_navy_leadership().get_name())));
172 if constexpr(std::is_same_v<T, dcon::army_id>) {
173 lid =
state.world.army_get_general_from_army_leadership(unit);
175 lid =
state.world.navy_get_admiral_from_navy_leadership(unit);
185 if constexpr(std::is_same_v<T, dcon::army_id>) {
210 if constexpr(std::is_same_v<T, dcon::army_id>) {
211 lid =
state.world.army_get_general_from_army_leadership(unit);
214 lid =
state.world.navy_get_admiral_from_navy_leadership(unit);
218 auto pculture =
state.world.nation_get_primary_culture(
state.local_player_nation);
219 auto ltype = pculture.get_group_from_culture_group_membership().get_leader();
222 auto admiral =
state.world.leader_get_is_admiral(lid);
224 auto arange = ltype.get_admirals();
225 if(arange.size() > 0) {
234 auto grange = ltype.get_generals();
235 if(grange.size() > 0) {
259 if constexpr(std::is_same_v<T, dcon::army_id>) {
260 lid =
state.world.army_get_general_from_army_leadership(unit);
262 lid =
state.world.navy_get_admiral_from_navy_leadership(unit);
272 if constexpr(std::is_same_v<T, dcon::army_id>) {
285 if constexpr(std::is_same_v<T, dcon::army_id>) {
303 if constexpr(std::is_same_v<T, dcon::army_id>) {
305 state.map_state.center_map_on_province(
state, p);
308 state.map_state.center_map_on_province(
state, p);
319 float total_strength = 0.0f;
320 int32_t unit_count = 0;
321 if constexpr(std::is_same_v<T, dcon::army_id>) {
322 state.world.army_for_each_army_membership_as_army(content, [&](dcon::army_membership_id nmid) {
324 total_strength += regiment.get_strength();
328 state.world.navy_for_each_navy_membership_as_navy(content, [&](dcon::navy_membership_id nmid) {
330 total_strength += ship.get_strength();
334 total_strength /=
static_cast<float>(unit_count);
344 float total_strength = 0.0f;
345 int32_t unit_count = 0;
346 if constexpr(std::is_same_v<T, dcon::army_id>) {
347 state.world.army_for_each_army_membership_as_army(content, [&](dcon::army_membership_id nmid) {
349 total_strength += regiment.get_strength();
353 state.world.navy_for_each_navy_membership_as_navy(content, [&](dcon::navy_membership_id nmid) {
355 total_strength += ship.get_strength();
359 total_strength /=
static_cast<float>(unit_count);
374 float total_org = 0.0f;
375 int32_t unit_count = 0;
376 if constexpr(std::is_same_v<T, dcon::army_id>) {
377 state.world.army_for_each_army_membership_as_army(content, [&](dcon::army_membership_id nmid) {
379 total_org += regiment.get_org();
383 state.world.navy_for_each_navy_membership_as_navy(content, [&](dcon::navy_membership_id nmid) {
385 total_org += ship.get_org();
389 total_org /=
static_cast<float>(unit_count);
399 float total_org = 0.0f;
400 int32_t unit_count = 0;
401 if constexpr(std::is_same_v<T, dcon::army_id>) {
402 state.world.army_for_each_army_membership_as_army(content, [&](dcon::army_membership_id nmid) {
404 total_org += regiment.get_org();
408 state.world.navy_for_each_navy_membership_as_navy(content, [&](dcon::navy_membership_id nmid) {
410 total_org += ship.get_org();
414 total_org /=
static_cast<float>(unit_count);
421 if constexpr(std::is_same_v<T, dcon::army_id>) {
433 if constexpr(std::is_same_v<T, dcon::regiment_id>) {
434 auto regiment = retrieve<dcon::regiment_id>(
state,
parent);
435 frame = int(
state.world.regiment_get_experience(regiment) * 10);
437 auto ship = retrieve<dcon::ship_id>(
state,
parent);
438 frame = int(
state.world.ship_get_experience(ship) * 10);
443 if constexpr(std::is_same_v<T, dcon::regiment_id>) {
444 auto regiment = retrieve<dcon::regiment_id>(
state,
parent);
445 frame = int(
state.world.regiment_get_experience(regiment) * 10);
447 auto ship = retrieve<dcon::ship_id>(
state,
parent);
448 frame = int(
state.world.ship_get_experience(ship) * 10);
457 if constexpr(std::is_same_v<T, dcon::regiment_id>) {
458 auto regiment = retrieve<dcon::regiment_id>(
state,
parent);
459 auto exp =
state.world.regiment_get_experience(regiment);
466 auto ship = retrieve<dcon::ship_id>(
state,
parent);
467 auto exp =
state.world.ship_get_experience(ship);
482 int32_t total_strength = 0;
483 if constexpr(std::is_same_v<T, dcon::army_id>) {
484 state.world.army_for_each_army_membership_as_army(content, [&](dcon::army_membership_id nmid) {
486 total_strength += int32_t(regiment.get_strength() *
state.defines.pop_size_per_regiment);
489 state.world.navy_for_each_navy_membership_as_navy(content, [&](dcon::navy_membership_id nmid) {
533 if constexpr(std::is_same_v<T, dcon::army_id>) {
534 if(
state.world.army_get_controller_from_army_control(content) ==
state.local_player_nation) {
540 if(
state.world.navy_get_controller_from_navy_control(content) ==
state.local_player_nation) {
549 dcon::gfx_object_id gid;
556 auto const& gfx_def =
state.ui_defs.gfx[gid];
557 if(gfx_def.primary_texture_handle) {
558 if(gfx_def.number_of_frames > 1) {
564 state.world.locale_get_native_rtl(
state.font_collection.get_current_locale()));
570 state.world.locale_get_native_rtl(
state.font_collection.get_current_locale()));
579 dcon::gfx_object_id disband_gfx{};
587 if constexpr(std::is_same_v<T, dcon::army_id>) {
588 auto win2 = make_element_by_type<unit_reorg_window<T, dcon::regiment_id>>(
state,
state.ui_state.
defs_by_name.find(
state.lookup_key(
"reorg_window"))->second.definition);
590 win2->set_visible(
state,
false);
594 auto win2 = make_element_by_type<unit_reorg_window<T, dcon::ship_id>>(
state,
state.ui_state.
defs_by_name.find(
state.lookup_key(
"reorg_window"))->second.definition);
596 win2->set_visible(
state,
false);
602 if(disband_too_small_btn && disband_gfx) {
608 if(
name ==
"unitpanel_bg") {
609 return make_element_by_type<unit_panel_dynamic_tinted_bg<T>>(
state, id);
610 }
else if(
name ==
"leader_prestige_icon") {
611 return make_element_by_type<invisible_element>(
state,
id);
612 }
else if(
name ==
"leader_prestige_bar") {
613 return make_element_by_type<leader_prestige_progress_bar<T>>(
state, id);
614 }
else if(
name ==
"prestige_bar_frame") {
615 return make_element_by_type<image_element_base>(
state,
id);
616 }
else if(
name ==
"unitname") {
617 auto ptr = make_element_by_type<unit_selection_unit_name_text<T>>(
state, id);
618 ptr->base_data.position.x += 9;
619 ptr->base_data.position.y += 4;
621 }
else if(
name ==
"only_unit_from_selection_button") {
622 return make_element_by_type<invisible_element>(
state,
id);
623 }
else if(
name ==
"remove_unit_from_selection_button") {
624 return make_element_by_type<unit_selection_close_button>(
state,
id);
625 }
else if(
name ==
"newunitbutton") {
626 return make_element_by_type<unit_selection_new_unit_button<T>>(
state, id);
627 }
else if(
name ==
"splitinhalf") {
628 return make_element_by_type<unit_selection_split_in_half_button<T>>(
state, id);
629 }
else if(
name ==
"disbandbutton") {
630 auto ptr = make_element_by_type<unit_selection_disband_button<T>>(
state, id);
631 disband_gfx = ptr->base_data.data.button.button_image;
633 }
else if(
name ==
"disbandtoosmallbutton") {
634 if constexpr(std::is_same_v<T, dcon::army_id>) {
635 auto ptr = make_element_by_type<unit_selection_disband_too_small_button>(
state,
id);
636 disband_too_small_btn = ptr.
get();
639 return make_element_by_type<invisible_element>(
state,
id);
641 }
else if(
name ==
"str_bar") {
642 return make_element_by_type<unit_selection_str_bar<T>>(
state, id);
643 }
else if(
name ==
"org_bar") {
644 return make_element_by_type<unit_selection_org_bar<T>>(
state, id);
645 }
else if(
name ==
"unitattrition_icon") {
646 return make_element_by_type<unit_selection_attrition_icon<T>>(
state, id);
647 }
else if(
name ==
"unitattrition") {
648 return make_element_by_type<unit_selection_attrition_amount<T>>(
state, id);
649 }
else if(
name ==
"unitstrength") {
650 return make_element_by_type<unit_selection_total_str_text<T>>(
state, id);
651 }
else if(
name ==
"unitlocation") {
652 return make_element_by_type<unit_selection_unit_location_text<T>>(
state, id);
653 }
else if(
name ==
"unit_location_button") {
654 return make_element_by_type<unit_selection_unit_location_button<T>>(
state, id);
655 }
else if(
name ==
"unitleader") {
656 return make_element_by_type<unit_selection_leader_name<T>>(
state, id);
657 }
else if(
name ==
"leader_button") {
658 return make_element_by_type<unit_selection_change_leader_button<T>>(
state, id);
659 }
else if(
name ==
"unit_activity") {
660 return make_element_by_type<image_element_base>(
state,
id);
661 }
else if(
name ==
"leader_photo") {
662 return make_element_by_type<unit_selection_leader_image<T>>(
state, id);
670 auto action = any_cast<element_selection_wrapper<unitpanel_action>>(payload).data;
696template<std::
size_t N>
703 if(
name ==
"unit_amount") {
704 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
705 unitamount_text = ptr.
get();
707 }
else if(
name ==
"unit_strength") {
708 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
709 unitstrength_text = ptr.
get();
711 }
else if(
name ==
"unit_icon") {
712 auto ptr = make_element_by_type<image_element_base>(
state,
id);
722 uint16_t totalunits = 0;
725 if(
state.selected_army_group) {
726 auto group = fatten(
state.world,
state.selected_army_group);
727 for(
auto regiment_membership : group.get_automated_army_group_membership_regiment()) {
728 auto fat = regiment_membership.get_regiment().get_regiment_from_automation();
729 auto strenght = fat.get_strength() *
state.defines.pop_size_per_regiment;
732 dcon::unit_type_id utid = fat.get_type();
734 if constexpr(N == 0) {
739 }
else if constexpr(N == 1) {
744 }
else if constexpr(N == 2) {
758template<std::
size_t N>
765 if(
name ==
"unit_amount") {
766 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
767 unitamount_text = ptr.
get();
769 }
else if(
name ==
"unit_strength") {
770 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
771 unitstrength_text = ptr.
get();
773 }
else if(
name ==
"unit_icon") {
774 auto ptr = make_element_by_type<image_element_base>(
state,
id);
787 if(
state.selected_army_group) {
788 auto army_group = fatten(
state.world,
state.selected_army_group);
790 for(
auto navy_membership : army_group.get_automated_army_group_membership_navy()) {
791 auto fat = navy_membership.get_navy();
793 for(
auto n : fat.get_navy_membership()) {
794 dcon::unit_type_id utid = n.get_ship().get_type();
796 if constexpr(N == 0) {
800 }
else if constexpr(N == 1) {
804 }
else if constexpr(N == 2) {
818template<
class T, std::
size_t N>
825 if(
name ==
"unit_amount") {
826 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
827 unitamount_text = ptr.
get();
829 }
else if(
name ==
"unit_strength") {
830 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
831 unitstrength_text = ptr.
get();
833 }
else if(
name ==
"unit_icon") {
834 auto ptr = make_element_by_type<image_element_base>(
state,
id);
835 if constexpr(std::is_same_v<T, dcon::army_id>) {
850 auto content = any_cast<T>(payload);
853 if constexpr(std::is_same_v<T, dcon::army_id>) {
856 uint16_t totalunits = 0;
858 for(
auto n : fat.get_army_membership()) {
859 dcon::unit_type_id utid = n.get_regiment().get_type();
861 if constexpr(N == 0) {
864 totalpops +=
uint32_t(
state.world.regiment_get_strength(n.get_regiment().id) *
state.defines.pop_size_per_regiment);
866 }
else if constexpr(N == 1) {
869 totalpops +=
uint32_t(
state.world.regiment_get_strength(n.get_regiment().id) *
state.defines.pop_size_per_regiment);
871 }
else if constexpr(N == 2) {
874 totalpops +=
uint32_t(
state.world.regiment_get_strength(n.get_regiment().id) *
state.defines.pop_size_per_regiment);
883 for(
auto n : fat.get_navy_membership()) {
884 dcon::unit_type_id utid = n.get_ship().get_type();
886 if constexpr(N == 0) {
890 }
else if constexpr(N == 1) {
894 }
else if constexpr(N == 2) {
909 if(
name ==
"select") {
910 return make_element_by_type<image_element_base>(
state,
id);
911 }
else if(
name ==
"select_naval") {
912 return make_element_by_type<invisible_element>(
state,
id);
913 }
else if(
name ==
"sunit_icon") {
914 return make_element_by_type<subunit_details_type_icon<dcon::regiment_id>>(
state, id);
915 }
else if(
name ==
"subunit_name") {
916 return make_element_by_type<subunit_details_name<dcon::regiment_id>>(
state, id);
917 }
else if(
name ==
"subunit_type") {
918 return make_element_by_type<subunit_details_type_text<dcon::regiment_id>>(
state, id);
919 }
else if(
name ==
"subunit_amount") {
920 return make_element_by_type<subunit_details_regiment_amount>(
state,
id);
921 }
else if(
name ==
"subunit_amount_naval") {
922 return make_element_by_type<invisible_element>(
state,
id);
923 }
else if(
name ==
"connected_pop") {
924 return make_element_by_type<regiment_pop_icon>(
state,
id);
925 }
else if(
name ==
"rebel_faction") {
926 return make_element_by_type<invisible_element>(
state,
id);
927 }
else if(
name ==
"unit_experience") {
928 return make_element_by_type<unit_experience_bar<dcon::regiment_id>>(
state, id);
929 }
else if(
name ==
"org_bar") {
930 return make_element_by_type<subunit_organisation_progress_bar<dcon::regiment_id>>(
state, id);
931 }
else if(
name ==
"str_bar") {
932 return make_element_by_type<subunit_strength_progress_bar<dcon::regiment_id>>(
state, id);
942 if(
name ==
"select") {
943 return make_element_by_type<invisible_element>(
state,
id);
944 }
else if(
name ==
"select_naval") {
945 return make_element_by_type<image_element_base>(
state,
id);
946 }
else if(
name ==
"sunit_icon") {
947 return make_element_by_type<subunit_details_type_icon<dcon::ship_id>>(
state, id);
948 }
else if(
name ==
"subunit_name") {
949 return make_element_by_type<subunit_details_name<dcon::ship_id>>(
state, id);
950 }
else if(
name ==
"subunit_type") {
951 return make_element_by_type<subunit_details_type_text<dcon::ship_id>>(
state, id);
952 }
else if(
name ==
"subunit_amount") {
953 return make_element_by_type<invisible_element>(
state,
id);
954 }
else if(
name ==
"subunit_amount_naval") {
955 return make_element_by_type<subunit_details_ship_amount>(
state,
id);
956 }
else if(
name ==
"connected_pop") {
957 return make_element_by_type<invisible_element>(
state,
id);
958 }
else if(
name ==
"rebel_faction") {
959 return make_element_by_type<invisible_element>(
state,
id);
960 }
else if(
name ==
"unit_experience") {
961 return make_element_by_type<unit_experience_bar<dcon::ship_id>>(
state, id);
962 }
else if(
name ==
"org_bar") {
963 return make_element_by_type<subunit_organisation_progress_bar<dcon::ship_id>>(
state, id);
964 }
else if(
name ==
"str_bar") {
965 return make_element_by_type<subunit_strength_progress_bar<dcon::ship_id>>(
state, id);
978 return "subunit_entry";
988 auto content = retrieve<dcon::army_id>(
state,
parent);
990 state.world.army_for_each_army_membership_as_army(content, [&](dcon::army_membership_id amid) {
991 auto rid =
state.world.army_membership_get_regiment(amid);
995 auto av = state.world.regiment_get_type(a).index();
996 auto bv = state.world.regiment_get_type(b).index();
1000 return a.index() < b.index();
1008 return "subunit_entry";
1018 auto content = retrieve<dcon::navy_id>(
state,
parent);
1020 state.world.navy_for_each_navy_membership_as_navy(content, [&](dcon::navy_membership_id nmid) {
1021 auto sid =
state.world.navy_membership_get_ship(nmid);
1025 auto av = state.world.ship_get_type(a).index();
1026 auto bv = state.world.ship_get_type(b).index();
1030 return a.index() < b.index();
1042 auto p =
state.world.army_get_location_from_army_location(a);
1043 int32_t max_cap = 0;
1044 for(
auto n :
state.world.province_get_navy_location(p)) {
1045 if(n.get_navy().get_controller_from_navy_control() ==
state.local_player_nation &&
1046 !
bool(n.get_navy().get_battle_from_navy_battle_participation())) {
1052 auto regs =
state.world.army_get_army_membership(a);
1053 int32_t army_cap = int32_t(regs.end() - regs.begin());
1054 int32_t to_split = army_cap - max_cap;
1056 std::array<dcon::regiment_id, command::num_packed_units> data;
1058 data.fill(dcon::regiment_id{});
1059 for(
auto reg :
state.world.army_get_army_membership(a)) {
1063 data[i] = reg.get_regiment();
1067 data.fill(dcon::regiment_id{});
1084 auto p =
state.world.army_get_location_from_army_location(a);
1085 visible = !bool(
state.world.army_get_navy_from_army_transport(a));
1089 int32_t max_cap = 0;
1090 for(
auto n :
state.world.province_get_navy_location(p)) {
1091 if(n.get_navy().get_controller_from_navy_control() ==
state.local_player_nation &&
1092 !
bool(n.get_navy().get_battle_from_navy_battle_participation())) {
1110 auto loc =
state.world.army_get_location_from_army_location(n);
1135 auto tprted =
state.world.army_get_navy_from_army_transport(n);
1136 auto loc =
state.world.army_get_location_from_army_location(n);
1140 if(loc.index() >=
state.province_definitions.first_sea_province.index()) {
1152 auto tprted =
state.world.army_get_navy_from_army_transport(n);
1153 auto loc =
state.world.army_get_location_from_army_location(n);
1173 auto tprted =
state.world.navy_get_army_transport(n);
1174 std::vector<dcon::army_id> tmp;
1175 for(
auto t : tprted)
1176 tmp.push_back(t.get_army());
1183 auto tprted =
state.world.navy_get_army_transport(n);
1184 auto loc =
state.world.navy_get_location_from_navy_location(n);
1186 if(tprted.begin() == tprted.end() || loc.index() >=
state.province_definitions.first_sea_province.index()) {
1199 auto tprted =
state.world.navy_get_army_transport(n);
1200 auto loc =
state.world.navy_get_location_from_navy_location(n);
1221 auto txt = std::to_string(tfree) +
" (" + std::to_string(tcap) +
")";
1237 visible = !
state.world.army_get_is_rebel_hunter(a) &&
state.world.army_get_controller_from_army_control(a) ==
state.local_player_nation;
1263 visible =
state.world.army_get_is_rebel_hunter(a) &&
state.world.army_get_controller_from_army_control(a) ==
state.local_player_nation;
1287 return state.world.army_get_is_ai_controlled(retrieve<dcon::army_id>(
state,
parent));
1301 disabled =
state.world.army_get_controller_from_army_control(a) !=
state.local_player_nation;
1308 auto army = retrieve<dcon::army_id>(
state,
parent);
1309 auto navy = retrieve<dcon::navy_id>(
state,
parent);
1313 auto owner =
state.local_player_nation;
1315 float spending_level = .0f;
1319 spending_level = float(
state.world.nation_get_land_spending(owner)) / 100.0f;
1322 spending_level = float(
state.world.nation_get_naval_spending(owner)) / 100.0f;
1328 float max_supply = 0.0f;
1329 float actual_supply = 0.0f;
1332 auto nations_commodity_spending =
state.world.nation_get_spending_level(owner);
1334 for(
uint32_t i = 0; i < total_commodities; ++i) {
1339 dcon::commodity_id c{ dcon::commodity_id::value_base_t(i) };
1341 auto satisfaction =
state.world.nation_get_demand_satisfaction(owner, c);
1345 actual_supply += commodities.
commodity_amounts[i] * satisfaction * nations_commodity_spending * spending_level;
1348 float median_supply = max_supply > 0.0f ? actual_supply / max_supply : 0.0f;
1358 auto army = retrieve<dcon::army_id>(
state,
parent);
1359 auto navy = retrieve<dcon::navy_id>(
state,
parent);
1362 float spending_level = .0f;
1363 auto owner =
state.local_player_nation;
1367 spending_level = float(
state.world.nation_get_land_spending(owner)) / 100.0f;
1370 spending_level = float(
state.world.nation_get_naval_spending(owner)) / 100.0f;
1376 float max_supply = 0.0f;
1377 float actual_supply = 0.0f;
1379 auto nations_commodity_spending =
state.world.nation_get_spending_level(owner);
1380 for(
uint32_t i = 0; i < total_commodities; ++i) {
1384 dcon::commodity_id c{ dcon::commodity_id::value_base_t(i) };
1386 auto satisfaction =
state.world.nation_get_demand_satisfaction(owner, c);
1390 actual_supply += commodities.
commodity_amounts[i] * satisfaction * nations_commodity_spending * spending_level;
1393 float median_supply = max_supply > 0.0f ? actual_supply / max_supply : 0.0f;
1398 dcon::commodity_id c{ dcon::commodity_id::value_base_t(i) };
1399 float satisfaction =
state.world.nation_get_demand_satisfaction(owner, c);
1401 float actual_commodity = commodities.
commodity_amounts[i] * satisfaction * nations_commodity_spending * spending_level;
1403 int32_t display_satisfaction = int32_t(satisfaction * 100);
1405 if(satisfaction == 1 || satisfaction >= 0.95) {
1406 text::add_line(
state, contents,
"unit_current_supply_high",
text::variable_type::what,
state.world.commodity_get_name(commodities.
commodity_type[i]),
text::variable_type::val,
text::fp_three_places{ actual_commodity },
text::variable_type::value,
text::fp_three_places{ wanted_commodity },
text::variable_type::total, display_satisfaction);
1407 }
else if (satisfaction < 0.95 && satisfaction >= 0.5) {
1408 text::add_line(
state, contents,
"unit_current_supply_mid",
text::variable_type::what,
state.world.commodity_get_name(commodities.
commodity_type[i]),
text::variable_type::val,
text::fp_three_places{ actual_commodity },
text::variable_type::value,
text::fp_three_places{ wanted_commodity },
text::variable_type::total, display_satisfaction);
1410 text::add_line(
state, contents,
"unit_current_supply_low",
text::variable_type::what,
state.world.commodity_get_name(commodities.
commodity_type[i]),
text::variable_type::val,
text::fp_three_places{ actual_commodity },
text::variable_type::value,
text::fp_three_places{ wanted_commodity },
text::variable_type::total, display_satisfaction);
1437 for(dcon::unit_type_id::value_base_t i = 0; i <
state.military_definitions.unit_base_definitions.size(); i++) {
1444 auto const utid = dcon::unit_type_id(i);
1446 std::string padding = i < 10 ?
"0" :
"";
1450 std::string description =
"@*" + padding + std::to_string(i);
1460 std::vector<dcon::province_id> provinces;
1469 auto army = retrieve<dcon::army_id>(
state,
parent);
1470 auto army_location =
state.world.army_get_location_from_army_location(army);
1472 state.fill_vector_of_connected_provinces(army_location,
true,
provinces);
1476 std::array<uint8_t, sys::macro_builder_template::max_types> current_distribution;
1477 current_distribution.fill(0);
1479 for(
auto reg :
state.world.army_get_army_membership(army)) {
1480 current_distribution[reg.get_regiment().get_type().index()] += 1;
1483 state.build_up_to_template_land(
1487 current_distribution
1493 std::unique_ptr<element_base> make_child(
sys::state&
state, std::string_view
name, dcon::gui_def_id
id)
noexcept override {
1494 if(
name ==
"composition") {
1495 return make_element_by_type<main_template_composition_label>(
state,
id);
1496 }
else if(
name ==
"background") {
1497 return make_element_by_type< apply_template_to_army_location_button>(
state,
id);
1511 if constexpr(std::is_same_v<T, dcon::army_id>) {
1512 auto ptr = make_element_by_type<unit_details_ai_controlled>(
state,
"alice_enable_ai_controlled");
1518 if(
name ==
"load_button" && std::is_same_v<T, dcon::army_id>) {
1519 if constexpr(std::is_same_v<T, dcon::army_id>) {
1520 return make_element_by_type<unit_details_load_army_button>(
state,
id);
1522 return make_element_by_type<invisible_element>(
state,
id);
1524 }
else if(
name ==
"unload_button") {
1525 if constexpr(std::is_same_v<T, dcon::army_id>) {
1526 return make_element_by_type<unit_details_unload_army_button>(
state,
id);
1528 return make_element_by_type<unit_details_unload_navy_button>(
state,
id);
1530 }
else if(
name ==
"enable_rebel_button") {
1531 if constexpr(std::is_same_v<T, dcon::army_id>) {
1532 return make_element_by_type<unit_details_hunt_rebels>(
state,
id);
1534 return make_element_by_type<invisible_element>(
state,
id);
1536 }
else if(
name ==
"disable_rebel_button") {
1537 if constexpr(std::is_same_v<T, dcon::army_id>) {
1538 return make_element_by_type<unit_details_dont_hunt_rebels>(
state,
id);
1540 return make_element_by_type<invisible_element>(
state,
id);
1542 }
else if(
name ==
"attach_unit_button"
1543 ||
name ==
"detach_unit_button"
1544 ||
name ==
"select_land") {
1546 return make_element_by_type<invisible_element>(
state,
id);
1547 }
else if(
name ==
"header") {
1548 if constexpr(std::is_same_v<T, dcon::army_id>) {
1549 return make_element_by_type<invisible_element>(
state,
id);
1551 return make_element_by_type< navy_transport_text>(
state,
id);
1553 }
else if(
name ==
"alice_build_up_to_template_window") {
1554 if constexpr(std::is_same_v<T, dcon::army_id>) {
1555 return make_element_by_type<apply_template_container>(
state,
id);
1557 return make_element_by_type<invisible_element>(
state,
id);
1590 auto win = make_element_by_type<unit_details_type_item<T, 0>>(
state,
1592 win->base_data.position.x = base_position.
x + (0 * base_offset.
x);
1593 win->base_data.position.y = base_position.
y + (0 * base_offset.
y);
1597 auto win = make_element_by_type<unit_details_type_item<T, 1>>(
state,
1599 win->base_data.position.x = base_position.
x + (1 * base_offset.
x);
1600 win->base_data.position.y = base_position.
y + (1 * base_offset.
y);
1604 auto win = make_element_by_type<unit_details_type_item<T, 2>>(
state,
1606 win->base_data.position.x = base_position.
x + (2 * base_offset.
x);
1607 win->base_data.position.y = base_position.
y + (2 * base_offset.
y);
1612 if constexpr(std::is_same_v<T, dcon::army_id>) {
1613 auto ptr = make_element_by_type<unit_details_army_listbox>(
state,
1615 ptr->base_data.position.y = base_position.
y + item_offset.
y + (3 * base_offset.
y) + 72 - 32;
1616 ptr->base_data.size.y += 32;
1619 auto ptr = make_element_by_type<unit_details_navy_listbox>(
state,
1621 ptr->base_data.position.y = base_position.
y + item_offset.
y + (3 * base_offset.
y) + 72 - 32;
1622 ptr->base_data.size.y += 32;
1627 auto ptr = make_element_by_type<unit_details_buttons<T>>(
state,
1635 make_element_by_type<unit_selection_panel<T>>(
state,
state.ui_state.
defs_by_name.find(
state.lookup_key(
"unitpanel"))->second.definition);
1636 unit_selection_win = ptr.
get();
1637 ptr->base_data.position.y = -80;
1643 if(
name ==
"unit_bottom_bg") {
1644 return make_element_by_type<unit_panel_dynamic_tinted_bg<T>>(
state, id);
1645 }
else if(
name ==
"icon_speed") {
1646 return make_element_by_type<image_element_base>(
state,
id);
1647 }
else if(
name ==
"speed") {
1648 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
1649 unitspeed_text = ptr.
get();
1651 }
else if(
name ==
"icon_recon") {
1652 auto ptr = make_element_by_type<image_element_base>(
state,
id);
1653 unitrecon_icon = ptr.
get();
1655 }
else if(
name ==
"recon") {
1656 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
1657 unitrecon_text = ptr.
get();
1659 }
else if(
name ==
"icon_engineer") {
1660 auto ptr = make_element_by_type<image_element_base>(
state,
id);
1661 unitengineer_icon = ptr.
get();
1663 }
else if(
name ==
"engineer") {
1664 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
1665 unitengineer_text = ptr.
get();
1667 }
else if(
name ==
"icon_supplies_small") {
1668 return make_element_by_type<image_element_base>(
state,
id);
1669 }
else if(
name ==
"supply_status") {
1670 auto ptr = make_element_by_type<unit_supply_bar>(
state,
id);
1671 unitsupply_bar = ptr.
get();
1673 }
else if(
name ==
"unitstatus_dugin") {
1674 auto ptr = make_element_by_type<image_element_base>(
state,
id);
1675 unitdugin_icon = ptr.
get();
1683 if constexpr(std::is_same_v<T, dcon::navy_id>) {
1692 }
else if constexpr(std::is_same_v<T, dcon::army_id>) {
1705 if(payload.holds_type<T>()) {
1709 unit_id = any_cast<element_selection_wrapper<T>>(payload).data;
1713 auto content = any_cast<element_selection_wrapper<dcon::leader_id>>(payload).data;
1714 if constexpr(std::is_same_v<T, dcon::army_id>) {
1721 auto content = any_cast<element_selection_wrapper<unitpanel_action>>(payload).data;
1727 state.selected_armies.clear();
1728 state.selected_navies.clear();
1730 state.game_state_updated.store(
true, std::memory_order_release);
1754 if(
state.selected_armies.size() > 0) {
1755 auto first =
state.selected_armies[0];
1756 for(
uint32_t i = 1; i <
state.selected_armies.size(); ++i) {
1760 if(
state.selected_navies.size() > 0) {
1761 auto first =
state.selected_navies[0];
1762 for(
uint32_t i = 1; i <
state.selected_navies.size(); ++i) {
1771 if(
state.selected_armies.size() > 0) {
1773 auto first =
state.selected_armies[0];
1775 for(
uint32_t i = 1; i <
state.selected_armies.size(); ++i) {
1782 if(
state.selected_navies.size() > 0) {
1783 auto first =
state.selected_navies[0];
1785 for(
uint32_t i = 1; i <
state.selected_navies.size(); ++i) {
1798 state.selected_armies.clear();
1799 state.selected_navies.clear();
1800 state.game_state_updated.store(
true, std::memory_order_release);
1807 for(
auto a :
state.selected_armies) {
1810 for(
auto a :
state.selected_navies) {
1827 if(std::holds_alternative<dcon::army_id>(foru)) {
1828 state.selected_armies.clear();
1829 state.selected_navies.clear();
1830 state.select(std::get<dcon::army_id>(foru));
1831 }
else if(std::holds_alternative<dcon::navy_id>(foru)) {
1832 state.selected_armies.clear();
1833 state.selected_navies.clear();
1834 state.select(std::get<dcon::navy_id>(foru));
1839 if(std::holds_alternative<dcon::army_id>(foru)) {
1840 state.deselect(std::get<dcon::army_id>(foru));
1841 }
else if(std::holds_alternative<dcon::navy_id>(foru)) {
1842 state.deselect(std::get<dcon::navy_id>(foru));
1852 if(std::holds_alternative<dcon::army_id>(foru)) {
1853 auto a = std::get<dcon::army_id>(foru);
1854 for(
auto r :
state.world.army_get_army_membership(a)) {
1855 total += r.get_regiment().get_strength() *
state.defines.pop_size_per_regiment;
1858 }
else if(std::holds_alternative<dcon::navy_id>(foru)) {
1859 auto a = std::get<dcon::navy_id>(foru);
1860 for(
auto r :
state.world.navy_get_navy_membership(a)) {
1861 total += r.get_ship().get_strength();
1869 bool visible =
false;
1872 if(std::holds_alternative<dcon::army_id>(foru)) {
1873 auto a = std::get<dcon::army_id>(foru);
1875 }
else if(std::holds_alternative<dcon::navy_id>(foru)) {
1876 auto a = std::get<dcon::navy_id>(foru);
1882 void render(
sys::state&
state, int32_t x, int32_t y)
noexcept override {
1890 float current = 0.0f;
1893 if(std::holds_alternative<dcon::army_id>(foru)) {
1894 auto a = std::get<dcon::army_id>(foru);
1895 for(
auto r :
state.world.army_get_army_membership(a)) {
1896 current += r.get_regiment().get_org();
1899 }
else if(std::holds_alternative<dcon::navy_id>(foru)) {
1900 auto a = std::get<dcon::navy_id>(foru);
1901 for(
auto r :
state.world.navy_get_navy_membership(a)) {
1902 current += r.get_ship().get_org();
1906 progress = total > 0.0f ? current / total : 0.0f;
1916 if(std::holds_alternative<dcon::army_id>(foru)) {
1918 }
else if(std::holds_alternative<dcon::navy_id>(foru)) {
1926 float current = 0.0f;
1929 if(std::holds_alternative<dcon::army_id>(foru)) {
1930 auto a = std::get<dcon::army_id>(foru);
1931 for(
auto r :
state.world.army_get_army_membership(a)) {
1932 current += r.get_regiment().get_strength();
1935 }
else if(std::holds_alternative<dcon::navy_id>(foru)) {
1936 auto a = std::get<dcon::navy_id>(foru);
1937 for(
auto r :
state.world.navy_get_navy_membership(a)) {
1938 current += r.get_ship().get_strength();
1942 progress = total > 0.0f ? current / total : 0.0f;
1954 if(std::holds_alternative<dcon::army_id>(foru)) {
1956 }
else if(std::holds_alternative<dcon::navy_id>(foru)) {
1962 if(std::holds_alternative<dcon::army_id>(foru)) {
1964 }
else if(std::holds_alternative<dcon::navy_id>(foru)) {
1980 if(std::holds_alternative<dcon::army_id>(foru)) {
1981 state.deselect(std::get<dcon::army_id>(foru));
1982 }
else if(std::holds_alternative<dcon::navy_id>(foru)) {
1983 state.deselect(std::get<dcon::navy_id>(foru));
1998 if(std::holds_alternative<dcon::army_id>(foru)) {
2000 }
else if(std::holds_alternative<dcon::navy_id>(foru)) {
2007 if(std::holds_alternative<dcon::army_id>(foru)) {
2009 }
else if(std::holds_alternative<dcon::navy_id>(foru)) {
2034 if(std::holds_alternative<dcon::army_id>(foru)) {
2036 }
else if(std::holds_alternative<dcon::navy_id>(foru)) {
2046 if(std::holds_alternative<dcon::army_id>(foru)) {
2048 }
else if(std::holds_alternative<dcon::navy_id>(foru)) {
2058 if(std::holds_alternative<dcon::army_id>(foru)) {
2060 }
else if(std::holds_alternative<dcon::navy_id>(foru)) {
2071 if(std::holds_alternative<dcon::army_id>(foru)) {
2072 auto a = std::get<dcon::army_id>(foru);
2073 for(
auto r :
state.world.army_get_army_membership(a)) {
2078 }
else if(std::holds_alternative<dcon::navy_id>(foru)) {
2079 auto a = std::get<dcon::navy_id>(foru);
2080 for(
auto r :
state.world.navy_get_navy_membership(a)) {
2096 if(std::holds_alternative<dcon::army_id>(foru)) {
2097 auto a = std::get<dcon::army_id>(foru);
2098 for(
auto r :
state.world.army_get_army_membership(a)) {
2103 }
else if(std::holds_alternative<dcon::navy_id>(foru)) {
2104 auto a = std::get<dcon::navy_id>(foru);
2105 for(
auto r :
state.world.navy_get_navy_membership(a)) {
2121 if(std::holds_alternative<dcon::army_id>(foru)) {
2122 auto a = std::get<dcon::army_id>(foru);
2123 for(
auto r :
state.world.army_get_army_membership(a)) {
2128 }
else if(std::holds_alternative<dcon::navy_id>(foru)) {
2129 auto a = std::get<dcon::navy_id>(foru);
2130 for(
auto r :
state.world.navy_get_navy_membership(a)) {
2144 dcon::province_id loc;
2146 if(std::holds_alternative<dcon::army_id>(foru)) {
2147 auto a = std::get<dcon::army_id>(foru);
2148 loc =
state.world.army_get_location_from_army_location(a);
2149 }
else if(std::holds_alternative<dcon::navy_id>(foru)) {
2150 auto a = std::get<dcon::navy_id>(foru);
2151 loc =
state.world.navy_get_location_from_navy_location(a);
2172 dcon::leader_id lid;
2173 if(std::holds_alternative<dcon::army_id>(foru)) {
2174 lid =
state.world.army_get_general_from_army_leadership(std::get<dcon::army_id>(foru));
2176 }
else if(std::holds_alternative<dcon::navy_id>(foru)) {
2177 lid =
state.world.navy_get_admiral_from_navy_leadership(std::get<dcon::navy_id>(foru));
2181 auto pculture =
state.world.nation_get_primary_culture(
state.local_player_nation);
2182 auto ltype = pculture.get_group_from_culture_group_membership().get_leader();
2185 auto admiral =
state.world.leader_get_is_admiral(lid);
2187 auto arange = ltype.get_admirals();
2188 if(arange.size() > 0) {
2198 auto grange = ltype.get_generals();
2199 if(grange.size() > 0) {
2223 dcon::leader_id lid;
2224 if(std::holds_alternative<dcon::army_id>(foru)) {
2225 lid =
state.world.army_get_general_from_army_leadership(std::get<dcon::army_id>(foru));
2226 }
else if(std::holds_alternative<dcon::navy_id>(foru)) {
2227 lid =
state.world.navy_get_admiral_from_navy_leadership(std::get<dcon::navy_id>(foru));
2237 if(std::holds_alternative<dcon::army_id>(foru)) {
2248 if(
name ==
"unitpanel_bg") {
2249 return make_element_by_type<whole_panel_button>(
state,
id);
2250 }
else if(
name ==
"leader_photo") {
2251 return make_element_by_type<multi_selection_leader_image>(
state,
id);
2252 }
else if(
name ==
"unitstrength") {
2253 return make_element_by_type <u_row_strength> (
state,
id);
2254 }
else if(
name ==
"unitattrition_icon") {
2255 return make_element_by_type<u_row_attrit_icon>(
state,
id);
2256 }
else if(
name ==
"org_bar") {
2257 return make_element_by_type<u_row_org_bar>(
state,
id);
2258 }
else if(
name ==
"str_bar") {
2259 return make_element_by_type<u_row_str_bar>(
state,
id);
2260 }
else if(
name ==
"disbandbutton") {
2261 return make_element_by_type<u_row_disband>(
state,
id);
2262 }
else if(
name ==
"splitinhalf") {
2263 return make_element_by_type<u_row_split>(
state,
id);
2264 }
else if(
name ==
"newunitbutton") {
2265 return make_element_by_type<u_row_new>(
state,
id);
2266 }
else if(
name ==
"remove_unit_from_selection_button") {
2267 return make_element_by_type<u_row_remove>(
state,
id);
2268 }
else if(
name ==
"unit_inf") {
2269 return make_element_by_type<u_row_inf>(
state,
id);
2270 }
else if(
name ==
"unit_inf_count") {
2271 return make_element_by_type<u_row_inf_count>(
state,
id);
2272 }
else if(
name ==
"unit_cav") {
2273 return make_element_by_type<u_row_cav>(
state,
id);
2274 }
else if(
name ==
"unit_cav_count") {
2275 return make_element_by_type<u_row_cav_count>(
state,
id);
2276 }
else if(
name ==
"unit_art") {
2277 return make_element_by_type<u_row_art>(
state,
id);
2278 }
else if(
name ==
"unit_art_count") {
2279 return make_element_by_type<u_row_art_count>(
state,
id);
2280 }
else if(
name ==
"location") {
2281 return make_element_by_type<u_row_location>(
state,
id);
2291 return "alice_unit_row";
2295 for(
auto i :
state.selected_armies)
2297 for(
auto i :
state.selected_navies)
2304 bool visible =
true;
2307 for(
auto i :
state.selected_armies) {
2308 if(
state.world.army_get_is_ai_controlled(i) ==
false)
2315 visible =
state.selected_navies.empty();
2325 for(
auto i :
state.selected_armies) {
2326 if(
state.world.army_get_is_ai_controlled(i) ==
false) {
2331 for(
auto a :
state.selected_armies) {
2335 if(!
state.world.army_get_is_ai_controlled(a)) {
2351 auto ptr = make_element_by_type<multi_unit_details_ai_controlled>(
state,
"alice_enable_ai_controlled_multi");
2356 if(
name ==
"desc") {
2357 return make_element_by_type<units_selected_text>(
state,
id);
2358 }
else if(
name ==
"mergebutton") {
2359 return make_element_by_type<merge_all_button>(
state,
id);
2360 }
else if(
name ==
"close_multiunit") {
2361 return make_element_by_type<deselect_all_button> (
state,
id);
2362 }
else if(
name ==
"disband_multiunit") {
2363 return make_element_by_type<disband_all_button>(
state,
id);
2364 }
else if(
name ==
"unit_listbox") {
2365 return make_element_by_type<selected_unit_list>(
state,
id);
2380 return !(*
this == o);
2390 auto regiment_type_data = retrieve<army_group_unit_type_info_optional>(
state,
parent);
2391 if(!std::holds_alternative<std::monostate>(regiment_type_data)) {
2392 frame =
state.military_definitions.unit_base_definitions[std::get<army_group_unit_type_info>(regiment_type_data).id].icon - 1;
2399 auto regiment_type_data = retrieve<army_group_unit_type_info_optional>(
state,
parent);
2400 if(!std::holds_alternative<std::monostate>(regiment_type_data)) {
2401 auto name_string_def =
state.military_definitions.unit_base_definitions[std::get<army_group_unit_type_info>(regiment_type_data).id].name;
2409 auto regiment_type_data = retrieve<army_group_unit_type_info_optional>(
state,
parent);
2410 if(!std::holds_alternative<std::monostate>(regiment_type_data)) {
2411 set_text(
state, std::to_string(std::get<army_group_unit_type_info>(regiment_type_data).amount));
2421 if(
name ==
"alice_army_group_unit_type_entry_icon") {
2422 return make_element_by_type<unit_type_row_image>(
state,
id);
2423 }
else if(
name ==
"alice_army_group_unit_type_entry_name") {
2424 return make_element_by_type<unit_type_row_label>(
state,
id);
2425 }
else if(
name ==
"alice_army_group_unit_type_entry_amount") {
2426 return make_element_by_type<unit_type_row_amount>(
state,
id);
2432 if(!std::holds_alternative<std::monostate>(
display_unit)) {
2438 if(!std::holds_alternative<std::monostate>(
display_unit)) {
2460 auto def =
state.ui_state.
defs_by_name.find(
state.lookup_key(
"alice_army_group_unit_type_grid_item"))->second.definition;
2462 uint8_t additional_padding = 5;
2465 auto win = make_element_by_type<unit_type_grid_item>(
state, def);
2466 win->base_data.position.x = int16_t(additional_padding);
2467 win->base_data.position.y = int16_t(3);
2472 auto win = make_element_by_type<unit_type_grid_item>(
state, def);
2473 win->base_data.position.x = int16_t(additional_padding * 2 + win->base_data.size.x);
2474 win->base_data.position.y = int16_t(3);
2479 auto win = make_element_by_type<unit_type_grid_item>(
state, def);
2480 win->base_data.position.x = int16_t(additional_padding * 3 + win->base_data.size.x * 2);
2481 win->base_data.position.y = int16_t(3);
2501 return "alice_army_group_unit_type_row";
2507 std::vector<uint32_t> regiments_by_type{ };
2508 regiments_by_type.resize(
state.military_definitions.unit_base_definitions.size() + 2);
2510 if(
state.selected_army_group) {
2511 auto group = fatten(
state.world,
state.selected_army_group);
2513 for(
auto regiment_membership : group.get_automated_army_group_membership_regiment()) {
2514 auto regiment = regiment_membership.get_regiment().get_regiment_from_automation();
2515 auto type = regiment.get_type();
2517 regiments_by_type[
type.index()] += 1;
2520 for(
auto navy_membership : group.get_automated_army_group_membership_navy()) {
2521 for(
auto ship_membership :
state.world.navy_get_navy_membership(navy_membership.get_navy())) {
2522 auto type = ship_membership.get_ship().get_type();
2524 regiments_by_type[
type.index()] += 1;
2530 size_t unit_types =
state.military_definitions.unit_base_definitions.size();
2531 for(
size_t i = 2; i < unit_types; i += 3) {
2534 for(
size_t j = 0; (j + i < unit_types) && (j < 3); j += 1) {
2535 dcon::unit_type_id type_id{ dcon::unit_type_id::value_base_t(j + i) };
2539 .amount = regiments_by_type[type_id.index()]
2542 content_of_grid_row[j] = new_item;
2556 return "alice_unit_row";
2560 if(
state.selected_army_group) {
2562 for(
auto navy_membership : group.get_automated_army_group_membership_navy()) {
2575 xy_pair base_position = { 15, 0 };
2576 uint16_t base_offset = 95;
2579 auto win = make_element_by_type<selected_army_group_land_details_item<0>>(
state,
2581 win->base_data.position.
x = base_position.
x + (0 * base_offset);
2585 auto win = make_element_by_type<selected_army_group_land_details_item<1>>(
state,
2587 win->base_data.position.x = base_position.
x + (1 * base_offset);
2591 auto win = make_element_by_type<selected_army_group_land_details_item<2>>(
state,
2593 win->base_data.position.x = base_position.
x + (2 * base_offset);
2598 auto win = make_element_by_type<selected_army_group_sea_details_item<0>>(
state,
2600 win->base_data.position.x = base_position.
x + (0 * base_offset);
2601 win->base_data.position.y = 40;
2605 auto win = make_element_by_type<selected_army_group_sea_details_item<1>>(
state,
2607 win->base_data.position.x = base_position.
x + (1 * base_offset);
2608 win->base_data.position.y = 40;
2612 auto win = make_element_by_type<selected_army_group_sea_details_item<2>>(
state,
2614 win->base_data.position.x = base_position.
x + (2 * base_offset);
2615 win->base_data.position.y = 40;
2624 if(
name ==
"alice_army_group_unit_listbox") {
2625 return make_element_by_type<selected_army_group_land_units_list>(
state,
id);
2639 state.game_state_updated.store(
true, std::memory_order_release);
2668 state.game_state_updated.store(
true, std::memory_order_release);
2696 state.game_state_updated.store(
true, std::memory_order_release);
2718 for(
auto item :
state.selected_armies) {
2719 state.world.for_each_automated_army_group([&](dcon::automated_army_group_id group) {
2720 state.remove_army_army_group_clean(group, item);
2722 state.add_army_to_army_group(
state.selected_army_group, item);
2724 for(
auto item :
state.selected_navies) {
2725 state.world.for_each_automated_army_group([&](dcon::automated_army_group_id group) {
2726 state.remove_navy_from_army_group(group, item);
2728 state.add_navy_to_army_group(
state.selected_army_group, item);
2733 if(
state.selected_army_group) {
2751 if(
state.selected_army_group) {
2752 for(
auto item :
state.selected_armies) {
2753 state.remove_army_army_group_clean(
state.selected_army_group, item);
2755 for(
auto item :
state.selected_navies) {
2756 state.remove_navy_from_army_group(
state.selected_army_group, item);
2762 if(
state.selected_army_group) {
2780 auto selected =
state.map_state.selected_province;
2782 state.new_army_group(selected);
2787 if(
state.map_state.selected_province) {
2797 auto selected =
state.selected_army_group;
2799 state.delete_army_group(selected);
2804 if(
state.selected_army_group) {
2815 auto content = retrieve<dcon::automated_army_group_id>(
state,
parent);
2816 auto hq =
state.world.automated_army_group_get_hq(content);
2823 auto info = retrieve<dcon::automated_army_group_id>(
state,
parent);
2824 state.select_army_group(info);
2828 auto info = retrieve<dcon::automated_army_group_id>(
state,
parent);
2831 if(
state.selected_army_group) {
2833 auto local_hq =
state.world.automated_army_group_get_hq(info);
2834 auto selected_hq =
state.world.automated_army_group_get_hq(
state.selected_army_group);
2835 if(local_hq == selected_hq) {
2846 std::unique_ptr<element_base> make_child(
sys::state&
state, std::string_view
name, dcon::gui_def_id
id)
noexcept override {
2847 if(
name ==
"alice_select_army_group_button") {
2848 return make_element_by_type<select_army_group_button>(
state,
id);
2849 }
else if(
name ==
"alice_army_group_location") {
2850 return make_element_by_type<army_group_location>(
state,
id);
2860 return "alice_army_group_entry";
2864 state.world.for_each_automated_army_group([&](dcon::automated_army_group_id item) {
2872 std::unique_ptr<element_base> make_child(
sys::state&
state, std::string_view
name, dcon::gui_def_id
id)
noexcept override {
2873 if(
name ==
"alice_army_group_listbox") {
2874 return make_element_by_type<army_groups_list>(
state,
id);
2882 std::unique_ptr<element_base> make_child(
sys::state&
state, std::string_view
name, dcon::gui_def_id
id)
noexcept override {
2883 if(
name ==
"alice_armygroup_new_button") {
2884 return make_element_by_type<new_army_group_button>(
state,
id);
2885 }
else if(
name ==
"alice_armygroup_delete_button") {
2886 return make_element_by_type<delete_army_group_button>(
state,
id);
2887 }
else if(
name ==
"alice_battleplanner_remove_selected") {
2888 return make_element_by_type<remove_selected_units_from_army_group_button>(
state,
id);
2889 }
else if(
name ==
"alice_army_group_listbox_wrapper") {
2890 return make_element_by_type<army_groups_list_wrapper>(
state,
id);
2898 std::unique_ptr<element_base> make_child(
sys::state&
state, std::string_view
name, dcon::gui_def_id
id)
noexcept override {
2899 if(
name ==
"alice_battleplanner_add_selected") {
2900 return make_element_by_type<add_selected_units_to_army_group_button>(
state,
id);
2901 }
if(
name ==
"alice_battleplanner_remove_selected") {
2902 return make_element_by_type<remove_selected_units_from_army_group_button>(
state,
id);
2912 if(
name ==
"alice_armygroup_defend_button") {
2913 return make_element_by_type<toggle_defend_order_button>(
state,
id);
2914 }
else if(
name ==
"alice_armygroup_enforce_control_button") {
2915 return make_element_by_type<toggle_enforce_control_order_button>(
state,
id);
2916 }
else if(
name ==
"alice_armygroup_naval_travel_origin_button") {
2917 return make_element_by_type<toggle_ferry_origin_order_button>(
state,
id);
2918 }
else if(
name ==
"alice_armygroup_go_to_selection") {
2919 return make_element_by_type<go_to_battleplanner_selection_button>(
state,
id);
2929 if(
name ==
"alice_army_group_regiments_list_header") {
2930 return make_element_by_type<army_group_details_window_header>(
state,
id);
2932 if(
name ==
"alice_army_group_control") {
2933 return make_element_by_type<army_group_control_window>(
state,
id);
2935 if(
name ==
"alice_army_group_unit_listbox_wrapper") {
2936 return make_element_by_type<army_group_details_window_body>(
state,
id);
dcon::text_key get_name() noexcept
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_update(sys::state &state) noexcept override
std::string_view get_row_element_name() override
void on_update(sys::state &state) noexcept override
void add_child_to_front(std::unique_ptr< element_base > child) noexcept final
void impl_on_update(sys::state &state) noexcept override
virtual message_result test_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept
virtual message_result get(sys::state &state, Cyto::Any &payload) noexcept
virtual void on_update(sys::state &state) noexcept
virtual void impl_render(sys::state &state, int32_t x, int32_t y) noexcept
message_result impl_get(sys::state &state, Cyto::Any &payload) noexcept
virtual void on_create(sys::state &state) noexcept
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 render(sys::state &state, int32_t x, int32_t y) noexcept override
std::vector< dcon::regiment_id > row_contents
void update(sys::state &state)
void on_create(sys::state &state) noexcept override
army_group_unit_type_info_grid_row content
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
void on_create(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
dcon::gfx_object_id default_img
void button_action(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 update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void button_action(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
bool is_active(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
void on_update(sys::state &state) noexcept override
std::string_view get_row_element_name() 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
void on_update(sys::state &state) noexcept override
std::string_view get_row_element_name() 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
std::string_view get_row_element_name() override
void on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void set_text(sys::state &state, std::string const &new_text)
text::layout internal_layout
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
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 on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void on_update(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
bool is_active(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
std::string_view get_row_element_name() override
void on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
message_result test_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
void on_update(sys::state &state) noexcept override
message_result test_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void button_action(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
std::string_view get_row_element_name() 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
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
void on_update(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void on_create(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 on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
dcon::gfx_object_id default_img
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void on_update(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
window_element_base * reorg_window
void on_create(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
window_element_base * combat_window
void on_update(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
army_group_unit_type_info_optional display_unit
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
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
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
std::array< unit_type_grid_item *, 3 > grid_items
void on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
constexpr size_t num_packed_units
bool can_change_admiral(sys::state &state, dcon::nation_id source, dcon::navy_id a, dcon::leader_id l)
void toggle_rebel_hunting(sys::state &state, dcon::nation_id source, dcon::army_id a)
bool can_change_general(sys::state &state, dcon::nation_id source, dcon::army_id a, dcon::leader_id l)
bool can_delete_army(sys::state &state, dcon::nation_id source, dcon::army_id a)
void mark_regiments_to_split(sys::state &state, dcon::nation_id source, std::array< dcon::regiment_id, num_packed_units > const &list)
void evenly_split_army(sys::state &state, dcon::nation_id source, dcon::army_id a)
bool can_evenly_split_army(sys::state &state, dcon::nation_id source, dcon::army_id a)
bool can_evenly_split_navy(sys::state &state, dcon::nation_id source, dcon::navy_id a)
bool can_disband_undermanned_regiments(sys::state &state, dcon::nation_id source, dcon::army_id a)
void disband_undermanned_regiments(sys::state &state, dcon::nation_id source, dcon::army_id a)
bool can_merge_navies(sys::state &state, dcon::nation_id source, dcon::navy_id a, dcon::navy_id b)
bool can_split_navy(sys::state &state, dcon::nation_id source, dcon::navy_id a)
bool can_delete_navy(sys::state &state, dcon::nation_id source, dcon::navy_id a)
bool can_split_army(sys::state &state, dcon::nation_id source, dcon::army_id a)
void evenly_split_navy(sys::state &state, dcon::nation_id source, dcon::navy_id a)
bool can_merge_armies(sys::state &state, dcon::nation_id source, dcon::army_id a, dcon::army_id b)
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
int32_t free_transport_capacity(sys::state &state, dcon::navy_id n)
float effective_army_speed(sys::state &state, dcon::army_id a)
float attrition_amount(sys::state &state, dcon::navy_id a)
economy::commodity_set get_required_supply(sys::state &state, dcon::nation_id owner, dcon::army_id army)
bool can_embark_onto_sea_tile(sys::state &state, dcon::nation_id from, dcon::province_id p, dcon::army_id a)
bool will_recieve_attrition(sys::state &state, dcon::navy_id a)
float effective_navy_speed(sys::state &state, dcon::navy_id n)
int32_t transport_capacity(sys::state &state, dcon::navy_id n)
void render_tinted_subsprite(sys::state const &state, int frame, int total_frames, float x, float y, float width, float height, float r, float g, float b, GLuint texture_handle, ui::rotation rot, bool flipped, bool rtl)
GLuint get_texture_handle(sys::state &state, dcon::texture_id id, bool keep_data)
void render_tinted_textured_rect(sys::state const &state, float x, float y, float width, float height, float r, float g, float b, GLuint texture_handle, ui::rotation rot, bool flipped, bool rtl)
uint32_t reduce(uint32_t value_in, uint32_t upper_bound)
uint64_t get_random(sys::state const &state, uint32_t value_in)
float blue_from_int(uint32_t v)
float green_from_int(uint32_t v)
uint32_t pack_color(float r, float g, float b)
float red_from_int(uint32_t v)
void add_to_layout_box(sys::state &state, layout_base &dest, layout_box &box, embedded_flag ico)
std::string resolve_string_substitution(sys::state &state, dcon::text_key source_text, substitution_map const &mp)
std::string get_name_as_string(sys::state &state, T t)
layout_box open_layout_box(layout_base &dest, int32_t indent)
void add_unparsed_text_to_layout_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view sv, substitution_map const &mp)
void localised_format_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view key, text::substitution_map const &sub)
std::string prettify(int64_t num)
endless_layout create_endless_layout(sys::state &state, layout &dest, layout_parameters const ¶ms)
std::string format_float(float num, size_t digits)
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
void add_line_with_condition(sys::state &state, layout_base &dest, std::string_view key, bool condition_met, int32_t indent)
void add_line_break_to_layout(sys::state &state, columnar_layout &dest)
void add_to_substitution_map(substitution_map &mp, variable_type key, substitution value)
std::string format_wholenum(int32_t num)
ankerl::unordered_dense::map< uint32_t, substitution > substitution_map
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
std::string format_percentage(float num, size_t digits)
void add_space_to_layout_box(sys::state &state, layout_base &dest, layout_box &box)
void close_layout_box(columnar_layout &dest, layout_box &box)
void open_leader_selection(sys::state &state, dcon::army_id a, dcon::navy_id v, int32_t x, int32_t y)
std::array< army_group_unit_type_info_optional, 3 > army_group_unit_type_info_grid_row
void send(sys::state &state, element_base *parent, T value)
std::variant< std::monostate, army_group_unit_type_info > army_group_unit_type_info_optional
void display_leader_full(sys::state &state, dcon::leader_id lid, text::layout_base &contents, int32_t indent)
xy_pair get_absolute_non_mirror_location(sys::state &state, element_base const &node)
void active_modifiers_description(sys::state &state, text::layout_base &layout, dcon::nation_id n, int32_t identation, dcon::national_modifier_value nmid, bool header)
float commodity_amounts[set_size]
dcon::commodity_id commodity_type[set_size]
static constexpr uint32_t set_size
uint8_t amounts[max_types]
bool operator!=(army_group_unit_type_info const &o) const
bool operator==(army_group_unit_type_info const &o) const
element_type get_element_type() const
rotation get_rotation() const
union ui::element_data::internal_data data
dcon::gfx_object_id gfx_object
sys::macro_builder_template main_template
ankerl::unordered_dense::map< dcon::text_key, element_target, hash_text_key > defs_by_name