3#include "dcon_generated.hpp"
26 const dcon::cb_type_id cbt = retrieve<dcon::cb_type_id>(
state,
parent);
27 frame =
state.world.cb_type_get_sprite_index(cbt) - 1;
34 dcon::cb_type_id content = retrieve<dcon::cb_type_id>(
state,
parent);
35 dcon::nation_id target = retrieve<dcon::nation_id>(
state,
parent);
40 if(
state.world.nation_get_infamy(
state.local_player_nation) + cb_infamy >=
state.defines.badboy_limit) {
54 const dcon::cb_type_id content = retrieve<dcon::cb_type_id>(
state,
parent);
63 dcon::cb_type_id content = retrieve<dcon::cb_type_id>(
state,
parent);
64 dcon::nation_id target = retrieve<dcon::nation_id>(
state,
parent);
68 if(
state.world.nation_get_infamy(
state.local_player_nation) + cb_infamy >=
state.defines.badboy_limit) {
80 if(
name ==
"wargoal_icon") {
81 return make_element_by_type<cb_wargoal_icon>(
state,
id);
82 }
else if(
name ==
"select_cb") {
83 return make_element_by_type<cb_wargoal_button>(
state,
id);
93 return "cb_type_item";
99 dcon::nation_id content = retrieve<dcon::nation_id>(
state,
parent);
100 state.world.for_each_cb_type([&](dcon::cb_type_id cb) {
111 auto content = retrieve<dcon::cb_type_id>(
state,
parent);
112 auto target_nation = retrieve<dcon::nation_id>(
state,
parent);
118 auto content = retrieve<dcon::cb_type_id>(
state,
parent);
119 auto target_nation = retrieve<dcon::nation_id>(
state,
parent);
129 auto fab_time = std::ceil(100.0f / (
state.defines.cb_generation_base_speed * fat_cb.get_construction_speed() * (
state.world.nation_get_modifier_values(
state.local_player_nation, sys::national_mod_offsets::cb_generation_speed_modifier) + 1.0f)));
130 auto target_nation = retrieve<dcon::nation_id>(
state,
parent);
131 if(fat_cb.is_valid()) {
156 dcon::cb_type_id root_cb{};
160 if(
name ==
"background") {
161 auto ptr = make_element_by_type<draggable_target>(
state,
id);
164 }
else if(
name ==
"diplo_makecb_bg") {
165 return make_element_by_type<image_element_base>(
state,
id);
166 }
else if(
name ==
"title") {
167 return make_element_by_type<make_cb_title>(
state,
id);
168 }
else if(
name ==
"description") {
169 return make_element_by_type<diplomacy_make_cb_desc>(
state,
id);
170 }
else if(
name ==
"leftshield") {
171 return make_element_by_type<nation_player_flag>(
state,
id);
172 }
else if(
name ==
"rightshield") {
173 return make_element_by_type<flag_button>(
state,
id);
174 }
else if(
name ==
"agreebutton") {
175 return make_element_by_type<diplomacy_make_cb_button>(
state,
id);
176 }
else if(
name ==
"declinebutton") {
177 return make_element_by_type<generic_close_button>(
state,
id);
178 }
else if(
name ==
"cb_list") {
179 return make_element_by_type<diplomacy_make_cb_listbox>(
state,
id);
187 root_cb = any_cast<element_selection_wrapper<dcon::cb_type_id>>(payload).data;
190 }
else if(payload.holds_type<dcon::cb_type_id>()) {
191 payload.emplace<dcon::cb_type_id>(root_cb);
212 int32_t discovered = 0;
213 state.world.for_each_technology([&](dcon::technology_id
id) {
218 if(
state.world.nation_get_active_technologies(n,
id))
236 int32_t discovered = 0;
237 state.world.for_each_technology([&](dcon::technology_id
id) {
242 if(
state.world.nation_get_active_technologies(n,
id))
265 auto mod =
state.world.nation_get_modifier_values(n, sys::national_mod_offsets::war_exhaustion);
269 }
else if(mod == 0) {
285 auto content = retrieve<dcon::nation_id>(
state,
parent);
287 if(content == window_content)
293 auto content = retrieve<dcon::nation_id>(
state,
parent);
299 int32_t total_influence_shares = 0;
300 auto n = fatten(
state.world,
state.local_player_nation);
302 for(
auto rel :
state.world.nation_get_gp_relationship_as_great_power(
state.local_player_nation)) {
306 total_influence_shares += 1;
309 total_influence_shares += 2;
312 total_influence_shares += 3;
321 auto rel = fatten(
state.world,
state.world.get_gp_relationship_by_gp_influence_pair(target,
state.local_player_nation));
336 if(total_influence_shares > 0) {
337 float total_gain =
state.defines.base_greatpower_daily_influence
338 * (1.0f + n.get_modifier_values(sys::national_mod_offsets::influence_modifier))
339 * (1.0f + n.get_modifier_values(sys::national_mod_offsets::influence));
344 auto gp_invest =
state.world.unilateral_relationship_get_foreign_investment(
345 state.world.get_unilateral_relationship_by_unilateral_pair(target, n));
348 ?
state.defines.discredit_influence_gain_factor
350 float neighbor_factor =
bool(
state.world.get_nation_adjacency_by_nation_adjacency_pair(n, target))
351 ?
state.defines.neighbour_bonus_influence_percent
354 ?
state.defines.sphere_neighbour_bonus_influence_percent
356 float continent_factor =
357 n.get_capital().get_continent() !=
state.world.nation_get_capital(target).get_continent()
358 ?
state.defines.other_continent_bonus_influence_percent
360 float puppet_factor =
361 fatten(
state.world,
state.world.nation_get_overlord_as_subject(target)).get_ruler() == n
362 ?
state.defines.puppet_bonus_influence_percent
364 float relationship_factor =
365 state.world.diplomatic_relation_get_value(
state.world.get_diplomatic_relation_by_diplomatic_pair(n, target)) /
state.defines.relation_influence_modifier;
367 float investment_factor =
369 ?
state.defines.investment_influence_defense * gp_invest / total_fi
373 ?
state.defines.large_population_influence_penalty *
state.world.nation_get_demographics(target,
demographics::total) /
state.defines.large_population_influence_penalty_chunk
380 float total_multiplier = 1.0f + discredit_factor + neighbor_factor + sphere_neighbor_factor + continent_factor + puppet_factor + relationship_factor + investment_factor + pop_factor + score_factor;
382 auto gain_amount = std::max(0.0f, base_shares * total_multiplier);
400 if(discredit_factor != 0 || neighbor_factor != 0 || sphere_neighbor_factor != 0 || continent_factor != 0 || puppet_factor != 0 || relationship_factor != 0 || investment_factor != 0 || pop_factor != 0 || score_factor != 0) {
404 if(discredit_factor != 0) {
407 if(neighbor_factor != 0) {
410 if(sphere_neighbor_factor != 0) {
413 if(continent_factor != 0) {
416 if(puppet_factor != 0) {
419 if(relationship_factor != 0) {
422 if(investment_factor != 0) {
425 if(pop_factor != 0) {
428 if(score_factor != 0) {
436 static std::string_view get_prio_key(
uint8_t f) {
439 return "diplomacy_prio_none";
441 return "diplomacy_prio_low";
443 return "diplomacy_prio_middle";
445 return "diplomacy_prio_high";
447 return "diplomacy_prio_none";
453 auto nation_id = retrieve<dcon::nation_id>(
state,
parent);
455 auto rel =
state.world.get_gp_relationship_by_gp_influence_pair(nation_id,
state.local_player_nation);
456 uint8_t rel_flags = bool(rel) ?
state.world.gp_relationship_get_status(rel) : 0;
480 auto nation_id = retrieve<dcon::nation_id>(
state,
parent);
482 auto rel =
state.world.get_gp_relationship_by_gp_influence_pair(nation_id,
state.local_player_nation);
483 uint8_t rel_flags = bool(rel) ?
state.world.gp_relationship_get_status(rel) : 0;
501 auto nation_id = retrieve<dcon::nation_id>(
state,
parent);
502 auto rel =
state.world.get_gp_relationship_by_gp_influence_pair(nation_id,
state.local_player_nation);
503 uint8_t rel_flags = bool(rel) ?
state.world.gp_relationship_get_status(rel) : 0;
527 auto nation_id = retrieve<dcon::nation_id>(
state,
parent);
548 auto const n = retrieve<dcon::nation_id>(
state,
parent);
549 auto const rel =
state.world.get_unilateral_relationship_by_unilateral_pair(n,
state.local_player_nation);
550 return state.world.unilateral_relationship_get_interested_in_alliance(rel);
553 auto const n = retrieve<dcon::nation_id>(
state,
parent);
558 auto const n = retrieve<dcon::nation_id>(
state,
parent);
577 if(
name ==
"country_select") {
578 return make_element_by_type<diplomacy_country_select>(
state,
id);
579 }
else if(
name ==
"country_flag") {
580 auto ptr = make_element_by_type<flag_button>(
state,
id);
581 ptr->base_data.position.y -= 2;
583 }
else if(
name ==
"country_name") {
584 return make_element_by_type<generic_name_text<dcon::nation_id>>(
state, id);
585 }
else if(
name ==
"country_prio") {
586 auto ptr = make_element_by_type<diplomacy_priority_button>(
state,
id);
588 auto btn = make_element_by_type<diplomacy_country_interested_in_alliance>(
state,
"alice_interested_in_alliance");
589 btn->base_data.position = ptr->base_data.position;
590 btn->base_data.position.x -= btn->base_data.size.x;
594 }
else if(
name ==
"country_boss_flag") {
595 return make_element_by_type<nation_overlord_flag>(
state,
id);
596 }
else if(
name ==
"country_prestige") {
597 return make_element_by_type<nation_prestige_rank_text>(
state,
id);
598 }
else if(
name ==
"country_economic") {
599 return make_element_by_type<nation_industry_rank_text>(
state,
id);
600 }
else if(
name ==
"country_military") {
601 return make_element_by_type<nation_military_rank_text>(
state,
id);
602 }
else if(
name ==
"country_total") {
603 return make_element_by_type<nation_rank_text>(
state,
id);
604 }
else if(
name ==
"country_opinion") {
605 return make_element_by_type<nation_player_opinion_text>(
state,
id);
606 }
else if(
name ==
"country_relation") {
607 return make_element_by_type<nation_player_relations_text>(
state,
id);
608 }
else if(
name.substr(0, 10) ==
"country_gp") {
609 auto ptr = make_element_by_type<nation_gp_opinion_text>(
state,
id);
610 ptr->rank = uint16_t(std::stoi(std::string{
name.substr(10)}));
625 return "diplomacy_country_info";
628 auto current_filter = retrieve< country_filter_setting>(
state,
parent);
629 auto current_sort = retrieve<country_sort_setting>(
state,
parent);
632 state.world.for_each_nation([&](dcon::nation_id
id) {
633 if(
state.world.nation_get_owned_province_count(
id) != 0) {
634 bool passes_filter = country_category_filter_check(state, current_filter.general_category, state.local_player_nation, id);
635 bool right_continent = !current_filter.continent || state.world.nation_get_capital(id).get_continent() == current_filter.continent;
636 if(passes_filter && right_continent)
637 row_contents.push_back(id);
648 auto n = any_cast<dip_make_nation_visible>(payload).data;
659 if(i < current_vis || i >= current_vis + vis_count) {
674 auto cb = retrieve<military::available_cb>(
state,
parent);
675 dcon::cb_type_id content = cb.cb_type;
676 frame =
state.world.cb_type_get_sprite_index(content) - 1;
678 auto conditions =
state.world.cb_type_get_can_use(cb.cb_type);
691 auto cb = retrieve<military::available_cb>(
state,
parent);
696 auto conditions =
state.world.cb_type_get_can_use(cb.cb_type);
708 if(
name ==
"wargoal_icon") {
709 return make_element_by_type<cb_icon>(
state,
id);
726 auto content = retrieve<dcon::nation_id>(
state,
parent);
727 if(!content || content ==
state.local_player_nation)
730 auto one_cbs =
state.world.nation_get_available_cbs(
state.local_player_nation);
731 for(
auto& cb : one_cbs)
732 if(cb.target == content)
735 for(
auto cb :
state.world.in_cb_type) {
756 auto content = retrieve<dcon::nation_id>(
state,
parent);
760 if(content && content !=
state.local_player_nation && war) {
761 for(
auto wg :
state.world.war_get_wargoals_attached(war)) {
762 if(wg.get_wargoal().get_added_by() ==
state.local_player_nation && wg.get_wargoal().get_target_nation() == content) {
764 wg.get_wargoal().get_secondary_nation(),
765 wg.get_wargoal().get_associated_tag(),
766 wg.get_wargoal().get_associated_state(),
767 wg.get_wargoal().get_type()
782 auto content = retrieve<dcon::nation_id>(
state,
parent);
787 if(
state.cheat_data.always_allow_wargoals) {
792 if(content ==
state.local_player_nation) {
796 if(
state.world.nation_get_diplomatic_points(
state.local_player_nation) <
state.defines.addwargoal_diplomatic_cost) {
809 for(
auto cb_type :
state.world.in_cb_type) {
811 bool cb_fabbed =
false;
812 for(
auto& fab_cb :
state.world.nation_get_available_cbs(
state.local_player_nation)) {
813 if(fab_cb.cb_type == cb_type && fab_cb.target == content) {
825 if(
state.world.war_get_is_great(w)) {
826 if(jingoism_perc >=
state.defines.wargoal_jingoism_requirement *
state.defines.gw_wargoal_jingoism_requirement_mod) {
831 if(jingoism_perc >=
state.defines.wargoal_jingoism_requirement) {
859 auto content = retrieve<dcon::nation_id>(
state,
parent);
860 if(content ==
state.local_player_nation) {
865 if(
state.defines.addwargoal_diplomatic_cost > 0) {
878 for(
auto cb_type :
state.world.in_cb_type) {
881 for(
auto& fab_cb :
state.world.nation_get_available_cbs(
state.local_player_nation)) {
882 if(fab_cb.cb_type == cb_type && fab_cb.target == content) {
898 if(
state.world.war_get_is_great(w)) {
909 auto pc =
state.world.nation_get_primary_culture(retrieve<dcon::nation_id>(
state,
parent));
910 auto pr =
state.world.nation_get_religion(retrieve<dcon::nation_id>(
state,
parent));
920 auto content = retrieve<dcon::nation_id>(
state,
parent);
931 for(
const auto ac :
state.world.in_culture) {
932 if(
state.world.nation_get_accepted_cultures(n, ac)) {
948 for(
const auto c :
state.world.in_culture) {
949 if(
state.world.nation_get_accepted_cultures(n, c))
977 auto target = retrieve<dcon::nation_id>(
state,
parent);
986 auto target = retrieve<dcon::nation_id>(
state,
parent);
987 auto rel =
state.world.get_gp_relationship_by_gp_influence_pair(target, gp);
1002 auto target = retrieve<dcon::nation_id>(
state,
parent);
1011 auto target = retrieve<dcon::nation_id>(
state,
parent);
1012 auto rel =
state.world.get_gp_relationship_by_gp_influence_pair(target, gp);
1026 auto target = retrieve<dcon::nation_id>(
state,
parent);
1035 auto target = retrieve<dcon::nation_id>(
state,
parent);
1044 auto target = retrieve<dcon::nation_id>(
state,
parent);
1054 return state.world.nation_get_identity_from_identity_holder(gp);
1067 if(
name ==
"country_flag") {
1068 return make_element_by_type<great_power_detail_flag>(
state,
id);
1069 }
else if(
name ==
"nongp_country_opinion") {
1070 return make_element_by_type<great_power_opinion_detail>(
state,
id);
1071 }
else if(
name ==
"nongp_country_influence") {
1072 return make_element_by_type<great_power_influence_detail>(
state,
id);
1073 }
else if(
name ==
"nongp_country_invest") {
1074 return make_element_by_type<great_power_investment_detail>(
state,
id);
1075 }
else if(
name ==
"country_discredited") {
1076 return make_element_by_type<gp_detail_discredited>(
state,
id);
1077 }
else if(
name ==
"country_banned_embassy") {
1078 return make_element_by_type<gp_detail_banned>(
state,
id);
1099 dcon::overlord_id overlord =
state.world.nation_get_overlord_as_subject(content);
1100 dcon::nation_id overlord_nation =
state.world.overlord_get_ruler(overlord);
1102 if(
state.world.nation_get_is_substate(content)) {
1104 }
else if(overlord_nation) {
1120 std::array<element_base*, 7> gp_elements;
1121 std::array<element_base*, 9> non_gp_elements;
1122 std::array<element_base*, 21> war_elements;
1129 auto win = make_element_by_type<great_power_inf_detail>(
state,
state.ui_state.
defs_by_name.find(
state.lookup_key(
"diplomacy_non_gp_extra_info"))->second.definition);
1130 win->gp_num = int32_t(i);
1131 win->base_data.position = sub_window_top_left;
1132 win->base_data.position.
x += win->base_data.size.x * int16_t(i / row_count);
1133 win->base_data.position.y += win->base_data.size.y * int16_t(i % row_count);
1134 non_gp_elements[1 + i] = win.get();
1140 if(
name ==
"gp_extra_info_bg") {
1141 auto ptr = make_element_by_type<image_element_base>(
state,
id);
1142 gp_elements[0] = ptr.get();
1144 }
else if(
name ==
"country_gp_friendly_label") {
1145 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
1146 gp_elements[1] = ptr.get();
1148 }
else if(
name ==
"country_gp_cordial_label") {
1149 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
1150 gp_elements[2] = ptr.get();
1152 }
else if(
name ==
"country_gp_sphere_label") {
1153 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
1154 gp_elements[3] = ptr.get();
1156 }
else if(
name ==
"country_gp_friendly") {
1157 auto ptr = make_element_by_type<overlapping_friendly_flags>(
state,
id);
1158 ptr->base_data.position.y -= 8 - 1;
1159 gp_elements[4] = ptr.get();
1161 }
else if(
name ==
"country_gp_cordial") {
1162 auto ptr = make_element_by_type<overlapping_cordial_flags>(
state,
id);
1163 ptr->base_data.position.y -= 8 - 1;
1164 gp_elements[5] = ptr.get();
1166 }
else if(
name ==
"country_gp_sphere") {
1167 auto ptr = make_element_by_type<overlapping_sphere_flags>(
state,
id);
1168 ptr->base_data.position.y -= 8 - 1;
1169 gp_elements[6] = ptr.get();
1171 }
else if(
name ==
"nongp_extra_info_bg") {
1172 auto ptr = make_element_by_type<image_element_base>(
state,
id);
1173 non_gp_elements[0] = ptr.get();
1174 auto const& def =
state.ui_defs.gui[
state.ui_state.
defs_by_name.find(
state.lookup_key(
"diplomacy_non_gp_extra_fact_pos"))->second.definition];
1175 sub_window_top_left = def.position;
1177 }
else if(
name ==
"country_flag") {
1178 return make_element_by_type<flag_button>(
state,
id);
1179 }
else if(
name ==
"country_flag_overlay") {
1180 return make_element_by_type<nation_flag_frame>(
state,
id);
1181 }
else if(
name ==
"country_name") {
1182 return make_element_by_type<generic_name_text<dcon::nation_id>>(
state, id);
1183 }
else if(
name ==
"country_status") {
1184 auto ptr = make_element_by_type<nation_status_diplomacy_window<dcon::nation_id>>(
state, id);
1186 }
else if(
name ==
"selected_nation_totalrank") {
1187 return make_element_by_type<nation_rank_text>(
state,
id);
1188 }
else if(
name ==
"ideology_icon") {
1189 return make_element_by_type<nation_ruling_party_ideology_plupp>(
state,
id);
1190 }
else if(
name ==
"country_party") {
1191 return make_element_by_type<nation_ruling_party_text>(
state,
id);
1192 }
else if(
name ==
"country_gov") {
1193 return make_element_by_type<nation_government_type_text>(
state,
id);
1194 }
else if(
name ==
"country_tech") {
1195 return make_element_by_type<national_tech_school>(
state,
id);
1196 }
else if(
name ==
"our_relation_icon") {
1197 auto ptr = make_element_by_type<image_element_base>(
state,
id);
1198 country_relation_icon = ptr.
get();
1200 }
else if(
name ==
"our_relation") {
1201 auto ptr = make_element_by_type<nation_player_relations_text>(
state,
id);
1202 country_relation = ptr.
get();
1204 }
else if(
name ==
"country_prestige") {
1205 return make_element_by_type<nation_prestige_text>(
state,
id);
1206 }
else if(
name ==
"selected_prestige_rank") {
1207 return make_element_by_type<nation_prestige_rank_text>(
state,
id);
1208 }
else if(
name ==
"country_economic") {
1209 return make_element_by_type<nation_industry_score_text>(
state,
id);
1210 }
else if(
name ==
"selected_industry_rank") {
1211 return make_element_by_type<nation_industry_rank_text>(
state,
id);
1212 }
else if(
name ==
"country_military") {
1213 return make_element_by_type<nation_military_score_text>(
state,
id);
1214 }
else if(
name ==
"selected_military_rank") {
1215 return make_element_by_type<nation_military_rank_text>(
state,
id);
1216 }
else if(
name ==
"country_total") {
1217 return make_element_by_type<nation_total_score_text>(
state,
id);
1218 }
else if(
name ==
"selected_total_rank") {
1219 return make_element_by_type<nation_rank_text>(
state,
id);
1220 }
else if(
name ==
"country_population") {
1221 return make_element_by_type<nation_population_text>(
state,
id);
1222 }
else if(
name ==
"country_primary_cultures") {
1223 return make_element_by_type<nation_primary_culture>(
state,
id);
1224 }
else if(
name ==
"country_accepted_cultures") {
1225 return make_element_by_type<nation_accepted_cultures>(
state,
id);
1226 }
else if(
name ==
"war_extra_info_bg") {
1227 auto ptr = make_element_by_type<image_element_base>(
state,
id);
1228 war_elements[0] = ptr.get();
1230 }
else if(
name ==
"country_wars") {
1231 auto ptr = make_element_by_type<overlapping_enemy_flags>(
state,
id);
1232 ptr->base_data.position.y -= 8 - 1;
1233 war_elements[1] = ptr.get();
1235 }
else if(
name ==
"country_wars_text") {
1236 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
1237 war_elements[2] = ptr.get();
1239 }
else if(
name ==
"country_allies_text") {
1240 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
1241 war_elements[3] = ptr.get();
1243 }
else if(
name ==
"country_protected_text") {
1244 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
1245 war_elements[4] = ptr.get();
1247 }
else if(
name ==
"country_truce_text") {
1248 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
1249 war_elements[5] = ptr.get();
1251 }
else if(
name ==
"country_cb_text") {
1252 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
1253 war_elements[6] = ptr.get();
1255 }
else if(
name ==
"infamy_icon") {
1256 auto ptr = make_element_by_type<image_element_base>(
state,
id);
1257 war_elements[7] = ptr.get();
1259 }
else if(
name ==
"warexhastion_icon") {
1260 auto ptr = make_element_by_type<image_element_base>(
state,
id);
1261 war_elements[8] = ptr.get();
1263 }
else if(
name ==
"brigade_icon") {
1264 auto ptr = make_element_by_type<image_element_base>(
state,
id);
1265 war_elements[9] = ptr.get();
1267 }
else if(
name ==
"ships_icon") {
1268 auto ptr = make_element_by_type<image_element_base>(
state,
id);
1269 war_elements[10] = ptr.get();
1271 }
else if(
name ==
"country_allies") {
1272 auto ptr = make_element_by_type<overlapping_ally_flags>(
state,
id);
1273 ptr->base_data.position.y -= 8 - 1;
1274 war_elements[11] = ptr.get();
1276 }
else if(
name ==
"country_protected") {
1277 auto ptr = make_element_by_type<overlapping_sphere_flags>(
state,
id);
1278 ptr->base_data.position.y -= 8 - 1;
1279 war_elements[12] = ptr.get();
1281 }
else if(
name ==
"country_truce") {
1282 auto ptr = make_element_by_type<overlapping_truce_flags>(
state,
id);
1283 ptr->base_data.position.y -= 8 - 1;
1284 war_elements[13] = ptr.get();
1286 }
else if(
name ==
"current_wargoals") {
1287 auto ptr = make_element_by_type<overlapping_active_wargoals>(
state,
id);
1288 war_elements[14] = ptr.get();
1290 }
else if(
name ==
"country_cb") {
1291 auto ptr = make_element_by_type<overlapping_wargoals>(
state,
id);
1292 war_elements[15] = ptr.get();
1294 }
else if(
name ==
"infamy_text") {
1295 auto ptr = make_element_by_type<nation_infamy_text>(
state,
id);
1296 war_elements[16] = ptr.get();
1298 }
else if(
name ==
"warexhastion_text") {
1299 auto ptr = make_element_by_type<diplomacy_war_exhaustion>(
state,
id);
1300 war_elements[17] = ptr.get();
1302 }
else if(
name ==
"brigade_text") {
1303 auto ptr = make_element_by_type<diplomacy_nation_armies_text>(
state,
id);
1304 war_elements[18] = ptr.get();
1306 }
else if(
name ==
"ships_text") {
1307 auto ptr = make_element_by_type<diplomacy_nation_navies_text>(
state,
id);
1308 war_elements[19] = ptr.get();
1310 }
else if(
name ==
"add_wargoal") {
1311 auto ptr = make_element_by_type<diplomacy_action_add_wargoal_button>(
state,
id);
1312 war_elements[20] = ptr.get();
1314 }
else if(
name ==
"selected_military_icon") {
1315 return make_element_by_type<military_score_icon>(
state,
id);
1322 auto content = retrieve<dcon::nation_id>(
state,
parent);
1325 auto active_tab = retrieve<dip_tab_request>(
state,
parent).tab;
1328 for(
auto p : gp_elements) {
1330 p->set_visible(
state,
false);
1332 for(
auto p : non_gp_elements) {
1334 p->set_visible(
state,
false);
1336 for(
auto p : war_elements) {
1338 p->set_visible(
state,
true);
1341 for(
auto p : gp_elements) {
1343 p->set_visible(
state,
true);
1345 for(
auto p : non_gp_elements) {
1347 p->set_visible(
state,
false);
1349 for(
auto p : war_elements) {
1351 p->set_visible(
state,
false);
1354 for(
auto p : gp_elements) {
1356 p->set_visible(
state,
false);
1358 for(
auto p : non_gp_elements) {
1360 p->set_visible(
state,
true);
1362 for(
auto p : war_elements) {
1364 p->set_visible(
state,
false);
1375 dcon::war_id w = retrieve<dcon::war_id>(
state,
parent);
1377 row_contents.push_back(war.get_primary_attacker().get_identity_from_identity_holder().id);
1378 for(
auto o : war.get_war_participant())
1379 if(o.get_is_attacker() ==
true && o.get_nation() != war.get_primary_attacker())
1380 row_contents.push_back(o.get_nation().get_identity_from_identity_holder().id);
1388 dcon::war_id w = retrieve<dcon::war_id>(
state,
parent);
1390 row_contents.push_back(war.get_primary_defender().get_identity_from_identity_holder().id);
1391 for(
auto o : war.get_war_participant())
1392 if(o.get_is_attacker() ==
false && o.get_nation() != war.get_primary_defender())
1393 row_contents.push_back(o.get_nation().get_identity_from_identity_holder().id);
1398template<
bool IsAttacker>
1402 dcon::war_id content = retrieve<dcon::war_id>(
state,
parent);
1405 int32_t strength = 0;
1406 for(
auto o : fat_id.get_war_participant())
1407 if(o.get_is_attacker() == IsAttacker)
1408 strength += int32_t(o.get_nation().get_military_score());
1417 dcon::war_id content = retrieve<dcon::war_id>(
state,
parent);
1426 for(
auto o : fat_id.get_war_participant()) {
1427 if(o.get_is_attacker() == IsAttacker) {
1433 auto strength = int32_t(o.get_nation().get_military_score());
1450 dcon::war_id war_id = retrieve<dcon::war_id>(
state,
parent);
1455 dcon::war_id war_id = retrieve<dcon::war_id>(
state,
parent);
1465 dcon::nation_id nation_id = retrieve<dcon::nation_id>(
state,
parent);
1466 dcon::war_id w = retrieve<dcon::war_id>(
state,
parent);
1468 if(!
state.world.war_get_is_great(w)) {
1477 if(
state.defines.min_months_to_intervene > 0) {
1486 if(!
state.world.war_get_is_great(w)) {
1487 auto defender =
state.world.war_get_primary_defender(w);
1488 auto rel_w_defender =
state.world.get_gp_relationship_by_gp_influence_pair(defender,
state.local_player_nation);
1505 auto primary_on_side =
B ?
state.world.war_get_primary_attacker(w) :
state.world.war_get_primary_defender(w);
1506 auto rel =
state.world.get_diplomatic_relation_by_diplomatic_pair(primary_on_side,
state.local_player_nation);
1510 bool any_in_sphere =
false;
1511 bool any_allied =
false;
1512 bool any_armies =
false;
1514 for(
auto p :
state.world.war_get_war_participant(w)) {
1515 if(p.get_is_attacker() !=
B) {
1516 if(p.get_nation().get_in_sphere_of() ==
state.local_player_nation)
1517 any_in_sphere =
true;
1519 auto irel =
state.world.get_diplomatic_relation_by_diplomatic_pair(p.get_nation(),
state.local_player_nation);
1520 if(
state.world.diplomatic_relation_get_are_allied(irel))
1523 for(
auto prov : p.get_nation().get_province_ownership()) {
1524 for(
auto arm : prov.get_province().get_army_location()) {
1525 if(arm.get_army().get_controller_from_army_control() ==
state.local_player_nation)
1543 auto wg = retrieve<dcon::wargoal_id>(
state,
parent);
1544 frame =
state.world.cb_type_get_sprite_index(
state.world.wargoal_get_type(wg)) - 1;
1552 auto wg = retrieve<dcon::wargoal_id>(
state,
parent);
1553 auto cb =
state.world.wargoal_get_type(wg);
1559 if(
state.world.wargoal_get_associated_state(wg)) {
1562 if(
state.world.wargoal_get_associated_tag(wg)) {
1564 }
else if(
state.world.wargoal_get_secondary_nation(wg)) {
1567 if(
state.world.wargoal_get_ticking_war_score(wg) != 0) {
1585 auto const start_date =
state.world.war_get_start_date(
state.world.wargoal_get_war_from_wargoals_attached(wg));
1586 auto const end_date = start_date + int32_t(
state.defines.tws_grace_period_days);
1591 if(end_date <=
state.current_date) {
1604 if(
name ==
"wargoal_icon") {
1605 return make_element_by_type<wargoal_icon>(
state,
id);
1623 dcon::war_id content = retrieve<dcon::war_id>(
state,
parent);
1624 for(
auto wg :
state.world.war_get_wargoals_attached(content)) {
1672 auto bar_pos = retrieve<war_bar_position>(
state,
parent);
1676 auto x_pos = int16_t((
float(attacker_cost) / 200.0f + 0.5f) *
float(bar_pos.width));
1686 auto bar_pos = retrieve<war_bar_position>(
state,
parent);
1690 auto x_pos = int16_t((
float(-defender_cost) / 200.0f + 0.5f) *
float(bar_pos.width));
1700 if(
state.world.war_get_is_great(war)) {
1702 }
else if(
state.world.war_get_is_crisis_war(war)) {
1731 if(
name ==
"diplo_war_entrybg") {
1732 return make_element_by_type<war_bg>(
state,
id);
1733 }
else if(
name ==
"war_name") {
1734 return make_element_by_type<war_name_text>(
state,
id);
1735 }
else if(
name ==
"attackers_mil_strength") {
1736 auto ptr = make_element_by_type<war_side_strength_text<true>>(
state, id);
1737 ptr->base_data.position.y -= 4;
1739 }
else if(
name ==
"defenders_mil_strength") {
1740 auto ptr = make_element_by_type<war_side_strength_text<false>>(
state, id);
1741 ptr->base_data.position.y -= 4;
1743 }
else if(
name ==
"warscore") {
1744 auto ptr = make_element_by_type<war_score_progress_bar>(
state,
id);
1748 }
if(
name ==
"diplo_warscore_marker1") {
1749 return make_element_by_type<attacker_peace_goal>(
state,
id);
1750 }
else if(
name ==
"diplo_warscore_marker2") {
1751 return make_element_by_type<defender_peace_goal>(
state,
id);
1752 }
else if(
name ==
"warscore_text") {
1753 auto ptr = make_element_by_type<war_score_text>(
state,
id);
1754 ptr->base_data.position.y -= 2;
1756 }
else if(
name ==
"attackers") {
1757 auto ptr = make_element_by_type<overlapping_attacker_flags>(
state,
id);
1758 ptr->base_data.position.y -= 8 - 2;
1760 }
else if(
name ==
"defenders") {
1761 auto ptr = make_element_by_type<overlapping_defender_flags>(
state,
id);
1762 ptr->base_data.position.y -= 8 - 2;
1764 }
else if(
name ==
"attackers_wargoals") {
1765 return make_element_by_type<diplomacy_war_overlapping_wargoals<true>>(
state, id);
1766 }
else if(
name ==
"defenders_wargoals") {
1767 return make_element_by_type<diplomacy_war_overlapping_wargoals<false>>(
state, id);
1768 }
else if(
name ==
"join_attackers") {
1769 return make_element_by_type<diplomacy_join_war_button<true>>(
state, id);
1770 }
else if(
name ==
"join_defenders") {
1771 return make_element_by_type<diplomacy_join_war_button<false>>(
state, id);
1789 const dcon::nation_id content = retrieve<dcon::nation_id>(
state,
parent);
1791 frame = fat.get_constructing_cb_type().get_sprite_index() - 1;
1799 const dcon::nation_id content = retrieve<dcon::nation_id>(
state,
parent);
1812 const dcon::nation_id content = retrieve<dcon::nation_id>(
state,
parent);
1814 progress = (fat.get_constructing_cb_progress() / 100.0f);
1822 auto fab_by = retrieve<dcon::nation_id>(
state,
parent);
1823 auto target =
state.world.nation_get_constructing_cb_target(fab_by);
1827 auto rem_progress = 100.0f -
state.world.nation_get_constructing_cb_progress(fab_by);
1828 auto daily_progress =
state.defines.cb_generation_base_speed *
state.world.nation_get_constructing_cb_type(fab_by).get_construction_speed()* (
state.world.nation_get_modifier_values(fab_by, sys::national_mod_offsets::cb_generation_speed_modifier) + 1.0f);
1829 auto days = int32_t(std::ceil(rem_progress / daily_progress));
1840 const dcon::nation_id content = retrieve<dcon::nation_id>(
state,
parent);
1843 row_contents.push_back(fat.get_identity_from_identity_holder().id);
1851 const dcon::nation_id content = retrieve<dcon::nation_id>(
state,
parent);
1854 row_contents.push_back(fat.get_constructing_cb_target().get_identity_from_identity_holder().id);
1862 const dcon::nation_id content = retrieve<dcon::nation_id>(
state,
parent);
1863 if(content !=
state.local_player_nation) {
1871 const dcon::nation_id content = retrieve<dcon::nation_id>(
state,
parent);
1884 auto just_progress =
state.world.nation_get_constructing_cb_progress(retrieve<dcon::nation_id>(
state,
parent));
1897 if(
name ==
"diplo_cb_entrybg") {
1898 return make_element_by_type<image_element_base>(
state,
id);
1899 }
else if(
name ==
"cb_type_icon") {
1900 return make_element_by_type<justifying_cb_type_icon>(
state,
id);
1901 }
else if(
name ==
"cb_progress") {
1902 return make_element_by_type<justifying_cb_progress>(
state,
id);
1903 }
else if(
name ==
"cb_progress_text") {
1904 return make_element_by_type<cb_progress_text>(
state,
id);
1905 }
else if(
name ==
"attackers") {
1906 auto ptr = make_element_by_type<justifying_attacker_flag>(
state,
id);
1907 ptr->base_data.position.y -= 7;
1909 }
else if(
name ==
"defenders") {
1910 auto ptr = make_element_by_type<justifying_defender_flag>(
state,
id);
1911 ptr->base_data.position.y -= 7;
1913 }
else if(
name ==
"cancel") {
1914 return make_element_by_type<diplomacy_casus_belli_cancel_button>(
state,
id);
1924 return "diplomacy_cb_info_player";
1935 for(
const auto id :
state.world.in_nation) {
1936 if(
id ==
state.local_player_nation &&
dcon::fatten(
state.world,
state.local_player_nation).get_constructing_cb_type().is_valid()) {
1941 for(
const auto id :
state.world.in_nation) {
1942 if(
id !=
state.local_player_nation &&
dcon::fatten(
state.world,
id).get_constructing_cb_is_discovered()) {
1953 if(
name ==
"cb_listbox") {
1954 auto ptr = make_element_by_type<diplomacy_casus_belli_listbox>(
state,
id);
1955 ptr->base_data.position.x -= 400;
1966 return "diplomacy_war_info";
1974 auto in_a = military::get_role(state, a, state.local_player_nation) != military::war_role::none;
1975 auto in_b = military::get_role(state, b, state.local_player_nation) != military::war_role::none;
1979 return state.world.war_get_start_date(a) < state.world.war_get_start_date(b);
1991 if(
name ==
"country_name") {
1992 return make_element_by_type<generic_name_text<dcon::nation_id>>(
state, id);
1993 }
else if(
name ==
"country_flag") {
1994 return make_element_by_type<flag_button>(
state,
id);
1995 }
else if(
name ==
"country_puppets") {
1996 auto ptr = make_element_by_type<overlapping_sphere_flags>(
state,
id);
1997 ptr->base_data.position.y -= 8;
1999 }
else if(
name ==
"gp_prestige") {
2000 return make_element_by_type<nation_prestige_text>(
state,
id);
2001 }
else if(
name ==
"gp_economic") {
2002 return make_element_by_type<nation_industry_score_text>(
state,
id);
2003 }
else if(
name ==
"gp_military") {
2004 return make_element_by_type<nation_military_score_text>(
state,
id);
2005 }
else if(
name ==
"gp_total") {
2006 return make_element_by_type<nation_total_score_text>(
state,
id);
2013 if(payload.holds_type<dcon::nation_id>()) {
2015 return message_result::consumed;
2017 return window_element_base::get(
state, payload);
2040 checkbox_button::on_update(
state);
2048 simple_text_element_base::on_create(
state);
2069 std::vector<diplomacy_greatpower_info*> gp_infos{};
2070 std::vector<element_base*> action_buttons{};
2072 dcon::nation_id facts_nation_id{};
2077 template<
typename T>
2079 auto ptr = make_element_by_type<T>(
state,
state.ui_state.
defs_by_name.find(
state.lookup_key(
"diplomacy_option"))->second.definition);
2080 ptr->base_data.position = offset;
2081 action_buttons.push_back(ptr.get());
2082 add_child_to_front(std::move(ptr));
2087 generic_tabbed_window::on_create(
state);
2092 xy_pair gp_info_offset = base_gp_info_offset;
2094 auto ptr = make_element_by_type<diplomacy_greatpower_info>(
state,
2096 ptr->base_data.position = gp_info_offset;
2099 gp_info_offset.
y += ptr->base_data.size.y;
2100 if(i + 1 ==
uint8_t(
state.defines.great_nations_count) / 2) {
2101 gp_info_offset.
y = base_gp_info_offset.
y;
2102 gp_info_offset.
x += (ptr->base_data.size.x / 2) + 62;
2104 gp_infos.push_back(ptr.get());
2105 add_child_to_front(std::move(ptr));
2112 xy_pair options_offset = options_base_offset;
2113 add_action_button<diplomacy_action_window<diplomacy_action_ally_button>>(
state, options_offset);
2114 options_offset.
y += options_size.
y;
2115 add_action_button<diplomacy_action_window<diplomacy_action_call_ally_button>>(
state, options_offset);
2116 options_offset.
y += options_size.
y;
2117 add_action_button<diplomacy_action_window<diplomacy_action_military_access_button>>(
state, options_offset);
2118 options_offset.
y += options_size.
y;
2119 add_action_button<diplomacy_action_window<diplomacy_action_give_military_access_button>>(
state, options_offset);
2120 options_offset.
y += options_size.
y;
2121 add_action_button<diplomacy_action_window<diplomacy_action_increase_relations_button>>(
state, options_offset);
2122 options_offset.
y += options_size.
y;
2123 add_action_button<diplomacy_action_window<diplomacy_action_decrease_relations_button>>(
state, options_offset);
2124 options_offset.
y += options_size.
y;
2125 add_action_button<diplomacy_action_window<diplomacy_action_war_subisides_button>>(
state, options_offset);
2126 options_offset.
y += options_size.
y;
2127 add_action_button<diplomacy_action_window<diplomacy_action_declare_war_button>>(
state, options_offset);
2128 options_offset.
y += options_size.
y;
2129 add_action_button<diplomacy_action_window<diplomacy_action_release_subject_button>>(
state, options_offset);
2131 options_offset.
x += options_size.
x;
2132 options_offset.
y = options_base_offset.
y;
2133 add_action_button<diplomacy_action_window<diplomacy_action_discredit_button>>(
state, options_offset);
2134 options_offset.
y += options_size.
y;
2135 add_action_button<diplomacy_action_window<diplomacy_action_expel_advisors_button>>(
state, options_offset);
2136 options_offset.
y += options_size.
y;
2137 add_action_button<diplomacy_action_window<diplomacy_action_ban_embassy_button>>(
state, options_offset);
2138 options_offset.
y += options_size.
y;
2139 add_action_button<diplomacy_action_window<diplomacy_action_increase_opinion_button>>(
state, options_offset);
2140 options_offset.
y += options_size.
y;
2141 add_action_button<diplomacy_action_window<diplomacy_action_decrease_opinion_button>>(
state, options_offset);
2142 options_offset.
y += options_size.
y;
2143 add_action_button<diplomacy_action_window<diplomacy_action_add_to_sphere_button>>(
state, options_offset);
2144 options_offset.
y += options_size.
y;
2145 add_action_button<diplomacy_action_window<diplomacy_action_remove_from_sphere_button>>(
state, options_offset);
2146 options_offset.
y += options_size.
y;
2147 add_action_button<diplomacy_action_window<diplomacy_action_justify_war_button>>(
state, options_offset);
2148 options_offset.
y += options_size.
y;
2149 add_action_button<diplomacy_action_window<diplomacy_action_state_transfer_button>>(
state, options_offset);
2151 auto new_win1 = make_element_by_type<diplomacy_action_dialog_window>(
state,
2153 new_win1->set_visible(
state,
false);
2154 action_dialog_win = new_win1.
get();
2155 add_child_to_front(std::move(new_win1));
2157 auto new_win2 = make_element_by_type<diplomacy_gp_action_dialog_window>(
state,
2159 new_win2->set_visible(
state,
false);
2160 gp_action_dialog_win = new_win2.
get();
2161 add_child_to_front(std::move(new_win2));
2163 auto new_win3 = make_element_by_type<diplomacy_declare_war_dialog>(
state,
2165 new_win3->set_visible(
state,
false);
2166 declare_war_win = new_win3.
get();
2167 add_child_to_front(std::move(new_win3));
2170 auto new_winc = make_element_by_type<offer_war_goal_dialog>(
state,
2172 new_winc->set_visible(
state,
false);
2173 offer_goal_win = new_winc.
get();
2174 add_child_to_front(std::move(new_winc));
2177 auto new_win4 = make_element_by_type<diplomacy_setup_peace_dialog>(
state,
2179 new_win4->set_visible(
state,
false);
2180 setup_peace_win = new_win4.
get();
2181 add_child_to_front(std::move(new_win4));
2183 auto new_win5 = make_element_by_type<diplomacy_make_cb_window>(
state,
2185 new_win5->set_visible(
state,
false);
2186 make_cb_win = new_win5.
get();
2187 add_child_to_front(std::move(new_win5));
2189 auto new_win6 = make_element_by_type<crisis_resolution_dialog>(
state,
2191 new_win6->set_visible(
state,
false);
2192 crisis_backdown_win = new_win6.
get();
2193 add_child_to_front(std::move(new_win6));
2195 if(
state.great_nations.size() > 1) {
2197 impl_get(
state, payload);
2200 set_visible(
state,
false);
2205 send<diplomacy_window_tab>(
state,
this, diplomacy_window_tab::great_powers);
2210 if(
name ==
"main_bg") {
2211 return make_element_by_type<image_element_base>(
state,
id);
2212 }
else if(
name ==
"bg_diplomacy") {
2213 return make_element_by_type<opaque_element_base>(
state,
id);
2214 }
else if(
name ==
"close_button") {
2215 return make_element_by_type<generic_close_button>(
state,
id);
2216 }
else if(
name ==
"gp_info") {
2217 auto ptr = make_element_by_type<generic_tab_button<diplomacy_window_tab>>(
state, id);
2218 ptr->target = diplomacy_window_tab::great_powers;
2220 }
else if(
name ==
"gp_info_text") {
2221 return make_element_by_type<gp_tab_text>(
state,
id);
2222 }
else if(
name ==
"war_info") {
2223 auto ptr = make_element_by_type<generic_tab_button<diplomacy_window_tab>>(
state, id);
2224 ptr->target = diplomacy_window_tab::wars;
2226 }
else if(
name ==
"cb_info") {
2227 auto ptr = make_element_by_type<generic_tab_button<diplomacy_window_tab>>(
state, id);
2228 ptr->target = diplomacy_window_tab::casus_belli;
2230 }
else if(
name ==
"crisis_info") {
2231 return make_element_by_type<crisis_tab_button>(
state,
id);
2232 }
else if(
name ==
"filter_all") {
2233 return make_element_by_type<category_filter_button<country_list_filter::all>>(
state, id);
2234 }
else if(
name ==
"filter_enemies") {
2235 return make_element_by_type<category_filter_button<country_list_filter::enemies>>(
state, id);
2236 }
else if(
name ==
"filter_allies") {
2237 return make_element_by_type<category_filter_button<country_list_filter::allies>>(
state, id);
2238 }
else if(
name ==
"filter_neighbours") {
2239 return make_element_by_type<category_filter_button<country_list_filter::neighbors>>(
state, id);
2240 }
else if(
name ==
"filter_sphere") {
2241 return make_element_by_type<category_filter_button<country_list_filter::sphere>>(
state, id);
2242 }
else if(
name ==
"cb_info_win") {
2243 auto ptr = make_element_by_type<diplomacy_casus_belli_window>(
state,
id);
2245 casus_belli_window = ptr.
get();
2246 ptr->set_visible(
state,
false);
2248 }
else if(
name ==
"crisis_info_win") {
2249 auto ptr = make_element_by_type<diplomacy_crisis_info_window>(
state,
id);
2250 crisis_window = ptr.
get();
2251 ptr->set_visible(
state,
false);
2253 }
else if(
name ==
"country_listbox") {
2254 auto ptr = make_element_by_type<diplomacy_country_listbox>(
state,
id);
2255 country_listbox = ptr.
get();
2257 }
else if(
name ==
"war_listbox") {
2258 auto ptr = make_element_by_type<diplomacy_war_listbox>(
state,
id);
2259 war_listbox = ptr.
get();
2262 }
else if(
name ==
"diplomacy_country_facts") {
2263 auto ptr = make_element_by_type<diplomacy_country_facts>(
state,
id);
2264 country_facts = ptr.
get();
2266 }
else if(
name ==
"sort_by_country") {
2267 auto ptr = make_element_by_type<country_sort_button<country_list_sort::country>>(
state, id);
2269 }
else if(
name ==
"sort_by_boss") {
2270 auto ptr = make_element_by_type<country_sort_button<country_list_sort::boss>>(
state, id);
2271 ptr->base_data.position.y -= 1;
2273 }
else if(
name ==
"sort_by_prestige") {
2274 auto ptr = make_element_by_type<country_sort_button<country_list_sort::prestige_rank>>(
state, id);
2275 ptr->base_data.position.y -= 1;
2277 }
else if(
name ==
"sort_by_economic") {
2278 auto ptr = make_element_by_type<country_sort_button<country_list_sort::economic_rank>>(
state, id);
2279 ptr->base_data.position.y -= 1;
2281 }
else if(
name ==
"sort_by_military") {
2282 auto ptr = make_element_by_type<country_sort_button<country_list_sort::military_rank>>(
state, id);
2283 ptr->base_data.position.y -= 1;
2285 }
else if(
name ==
"sort_by_total") {
2286 auto ptr = make_element_by_type<country_sort_button<country_list_sort::total_rank>>(
state, id);
2287 ptr->base_data.position.y -= 1;
2289 }
else if(
name ==
"sort_by_relation") {
2290 auto ptr = make_element_by_type<country_sort_button<country_list_sort::relation>>(
state, id);
2291 ptr->base_data.position.y -= 1;
2293 }
else if(
name ==
"sort_by_opinion") {
2294 return make_element_by_type<country_sort_button<country_list_sort::opinion>>(
state, id);
2295 }
else if(
name ==
"sort_by_prio") {
2296 return make_element_by_type<country_sort_button<country_list_sort::priority>>(
state, id);
2297 }
else if(
name.substr(0, 14) ==
"sort_by_gpflag") {
2298 auto ptr = make_element_by_type<diplomacy_sort_nation_gp_flag>(
state,
id);
2299 ptr->rank = uint16_t(std::stoi(std::string{
name.substr(14)}));
2300 ptr->base_data.position.y -= 2;
2302 }
else if(
name.substr(0, 10) ==
"sort_by_gp") {
2303 auto ptr = make_element_by_type<country_sort_button<country_list_sort::gp_influence>>(
state, id);
2304 ptr->offset =
uint8_t(std::stoi(std::string{
name.substr(10)}));
2305 ptr->base_data.position.y -= 2;
2307 }
else if(
name.length() >= 7 &&
name.substr(0, 7) ==
"filter_") {
2308 auto const filter_name =
name.substr(7);
2309 auto ptr = make_element_by_type<continent_filter_button>(
state,
id);
2310 auto k =
state.lookup_key(filter_name);
2312 for(
auto m :
state.world.in_modifier) {
2313 if(m.get_name() == k) {
2329 for(
auto e : gp_infos)
2330 e->set_visible(
state,
false);
2345 auto enum_val = any_cast<diplomacy_window_tab>(payload);
2348 case diplomacy_window_tab::great_powers:
2349 for(
auto e : gp_infos)
2350 e->set_visible(
state,
true);
2352 case diplomacy_window_tab::wars:
2355 case diplomacy_window_tab::casus_belli:
2358 case diplomacy_window_tab::crisis:
2364 active_tab = enum_val;
2366 return message_result::consumed;
2369 return message_result::consumed;
2372 return message_result::consumed;
2375 return message_result::consumed;
2377 auto new_sort = any_cast<element_selection_wrapper<country_list_sort>>(payload).data;
2379 sort.
sort = new_sort;
2381 return message_result::consumed;
2383 auto temp = any_cast<country_list_filter>(payload);
2384 filter.general_category = filter.general_category !=
temp ?
temp : country_list_filter::all;
2386 return message_result::consumed;
2387 }
else if(payload.holds_type<dcon::modifier_id>()) {
2388 auto temp_c = any_cast<dcon::modifier_id>(payload);
2389 filter.continent = filter.continent == temp_c ? dcon::modifier_id{} : temp_c;
2391 return message_result::consumed;
2392 }
else if(payload.holds_type<dcon::nation_id>()) {
2393 payload.emplace<dcon::nation_id>(facts_nation_id);
2394 return message_result::consumed;
2396 facts_nation_id = any_cast<element_selection_wrapper<dcon::nation_id>>(payload).data;
2398 impl_on_update(
state);
2399 return message_result::consumed;
2401 auto offer_to = any_cast<open_offer_window>(payload).to;
2408 auto action = any_cast<trigger_gp_choice>(payload).action;
2422 auto v = any_cast<diplomacy_action>(payload);
2429 Cyto::Any new_payload = facts_nation_id;
2432 case diplomacy_action::add_to_sphere:
2435 case diplomacy_action::military_access:
2438 case diplomacy_action::cancel_military_access:
2441 case diplomacy_action::give_military_access:
2444 case diplomacy_action::cancel_give_military_access:
2447 case diplomacy_action::increase_relations:
2450 case diplomacy_action::decrease_relations:
2453 case diplomacy_action::war_subsidies:
2456 case diplomacy_action::cancel_war_subsidies:
2459 case diplomacy_action::ally:
2462 case diplomacy_action::cancel_ally:
2465 case diplomacy_action::call_ally:
2466 for(
auto war_par : fat.get_war_participant()) {
2471 case diplomacy_action::remove_from_sphere:
2477 case diplomacy_action::declare_war:
2478 case diplomacy_action::add_wargoal:
2484 case diplomacy_action::make_peace:
2491 case diplomacy_action::justify_war:
2496 case diplomacy_action::crisis_backdown:
2501 case diplomacy_action::crisis_support:
2510 return message_result::consumed;
dcon::text_key get_name() noexcept
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
void on_update(sys::state &state) noexcept override
message_result impl_set(sys::state &state, Cyto::Any &payload) noexcept final
void add_child_to_front(std::unique_ptr< element_base > child) noexcept final
void impl_on_update(sys::state &state) noexcept override
void open_window(sys::state &state)
message_result get(sys::state &state, Cyto::Any &payload) 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_create(sys::state &state) noexcept override
void on_create(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::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
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
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
bool is_active(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
std::string_view get_row_element_name() override
void on_update(sys::state &state) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
void button_action(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 reset_window(sys::state &state)
dcon::nation_id action_target
gp_choice_actions current_action
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
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
void populate_layout(sys::state &state, text::endless_layout &contents) 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
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
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 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 open_window(sys::state &state)
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
void button_action(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void on_create(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
war_bar_position bar_position
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
std::string_view get_row_element_name() 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 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
void on_hide(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 hide_tabs(sys::state &state)
virtual message_result get(sys::state &state, Cyto::Any &payload) noexcept
virtual void on_create(sys::state &state) noexcept
void set_visible(sys::state &state, bool vis)
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
void on_update(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) 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
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
void on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
virtual dcon::national_identity_id get_current_nation(sys::state &state) 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_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 populate_flags(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 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
void populate_flags(sys::state &state) noexcept override
std::vector< dcon::cb_type_id > row_contents
std::vector< diplomacy_country_info * > row_windows
standard_listbox_scrollbar< diplomacy_country_info, dcon::nation_id > * list_scrollbar
void update(sys::state &state)
void on_create(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
void on_update(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void reset_window(sys::state &state, dcon::nation_id offer_to)
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
void on_update(sys::state &state) noexcept override
std::string_view get_row_element_name() override
void populate_flags(sys::state &state) override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void populate_flags(sys::state &state) override
std::vector< military::available_cb > row_contents
void update(sys::state &state)
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 set_text(sys::state &state, std::string const &new_text)
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
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
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_create(sys::state &state) noexcept override
bool can_intervene_in_war(sys::state &state, dcon::nation_id source, dcon::war_id w, bool for_attacker)
void give_war_subsidies(sys::state &state, dcon::nation_id source, dcon::nation_id target)
bool can_cancel_cb_fabrication(sys::state &state, dcon::nation_id source)
@ ask_for_military_access
@ cancel_given_military_access
@ change_influence_priority
@ toggle_interested_in_alliance
bool can_fabricate_cb(sys::state &state, dcon::nation_id source, dcon::nation_id target, dcon::cb_type_id type)
bool can_toggle_interested_in_alliance(sys::state &state, dcon::nation_id asker, dcon::nation_id target)
bool can_change_influence_priority(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target, uint8_t priority)
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
constexpr dcon::demographics_key total(0)
dcon::demographics_key to_key(sys::state const &state, dcon::pop_type_id v)
constexpr uint32_t is_not_constructing_cb
constexpr uint32_t always
bool cb_conditions_satisfied(sys::state &state, dcon::nation_id actor, dcon::nation_id target, dcon::cb_type_id cb)
float primary_warscore(sys::state &state, dcon::war_id w)
float truce_break_cb_infamy(sys::state &state, dcon::cb_type_id t)
int32_t total_regiments(sys::state &state, dcon::nation_id n)
int32_t defender_peace_cost(sys::state &state, dcon::war_id war)
bool has_truce_with(sys::state &state, dcon::nation_id attacker, dcon::nation_id target)
int32_t attacker_peace_cost(sys::state &state, dcon::war_id war)
bool is_attacker(sys::state &state, dcon::war_id w, dcon::nation_id n)
bool joining_as_attacker_would_break_truce(sys::state &state, dcon::nation_id a, dcon::war_id w)
float primary_warscore_from_blockades(sys::state &state, dcon::war_id w)
float cb_infamy(sys::state const &state, dcon::cb_type_id t)
dcon::war_id find_war_between(sys::state const &state, dcon::nation_id a, dcon::nation_id b)
float primary_warscore_from_battles(sys::state &state, dcon::war_id w)
float primary_warscore_from_occupation(sys::state &state, dcon::war_id w)
bool are_at_war(sys::state const &state, dcon::nation_id a, dcon::nation_id b)
bool defenders_have_non_status_quo_wargoal(sys::state const &state, dcon::war_id w)
float primary_warscore_from_war_goals(sys::state &state, dcon::war_id w)
int32_t total_ships(sys::state &state, dcon::nation_id n)
bool joining_war_does_not_violate_constraints(sys::state const &state, dcon::nation_id a, dcon::war_id w, bool as_attacker)
std::string get_war_name(sys::state &, dcon::war_id)
bool can_add_always_cb_to_war(sys::state &state, dcon::nation_id actor, dcon::nation_id target, dcon::cb_type_id cb, dcon::war_id w)
bool defenders_have_status_quo_wargoal(sys::state const &state, dcon::war_id w)
constexpr uint8_t is_banned
constexpr uint8_t level_friendly
constexpr uint8_t is_discredited
constexpr uint8_t priority_zero
constexpr uint8_t priority_three
constexpr uint8_t priority_mask
constexpr uint8_t priority_one
constexpr uint8_t level_mask
constexpr uint8_t priority_two
bool is_great_power(sys::state const &state, dcon::nation_id id)
bool is_involved_in_crisis(sys::state const &state, dcon::nation_id n)
float get_foreign_investment(sys::state &state, dcon::nation_id n)
float get_base_shares(sys::state &state, dcon::gp_relationship_id gp, float total_gain, int32_t total_influence_shares)
bool has_sphere_neighbour(sys::state &state, dcon::nation_id n, dcon::nation_id target)
dcon::nation_id get_nth_great_power(sys::state const &state, uint16_t n)
float prestige_score(sys::state const &state, dcon::nation_id n)
bool can_accumulate_influence_with(sys::state &state, dcon::nation_id gp, dcon::nation_id target, dcon::gp_relationship_id rel)
uint32_t pack_color(float r, float g, float b)
void add_to_layout_box(sys::state &state, layout_base &dest, layout_box &box, embedded_flag ico)
std::string format_money(float num)
std::string get_name_as_string(sys::state &state, T t)
layout_box open_layout_box(layout_base &dest, int32_t indent)
void localised_format_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view key, text::substitution_map const &sub)
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)
void add_divider_to_layout_box(sys::state &state, layout_base &dest, layout_box &box)
ankerl::unordered_dense::map< uint32_t, substitution > substitution_map
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
dcon::text_key get_name(sys::state &state, dcon::nation_id id)
std::string format_percentage(float num, size_t digits)
std::string get_influence_level_name(sys::state const &state, uint8_t v)
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)
int32_t to_generic(dcon::province_id v)
bool evaluate(sys::state &state, dcon::trigger_key key, int32_t primary, int32_t this_slot, int32_t from_slot)
void sort_countries(sys::state &state, std::vector< dcon::nation_id > &list, country_list_sort sort, bool sort_ascend)
void send(sys::state &state, element_base *parent, T value)
void trigger_description(sys::state &state, text::layout_base &layout, dcon::trigger_key k, int32_t primary_slot=-1, int32_t this_slot=-1, int32_t from_slot=-1)
std::string get_status_text(sys::state &state, dcon::nation_id nation_id)
void explain_influence(sys::state &state, dcon::nation_id target, text::columnar_layout &contents)
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)
ui::diplomacy_window_tab tab
ankerl::unordered_dense::map< dcon::text_key, element_target, hash_text_key > defs_by_name
element_base * diplomacy_subwindow