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);
37 dcon::state_definition_id target_state = retrieve<dcon::state_definition_id>(
state,
parent);
43 if(
state.world.nation_get_infamy(
state.local_player_nation) + cb_infamy >=
state.defines.badboy_limit) {
52 if (selected == content) {
61 const dcon::cb_type_id content = retrieve<dcon::cb_type_id>(
state,
parent);
70 dcon::cb_type_id content = retrieve<dcon::cb_type_id>(
state,
parent);
71 dcon::nation_id target = retrieve<dcon::nation_id>(
state,
parent);
75 if(
state.world.nation_get_infamy(
state.local_player_nation) + cb_infamy >=
state.defines.badboy_limit) {
87 if(
name ==
"wargoal_icon") {
88 return make_element_by_type<cb_wargoal_icon>(
state,
id);
89 }
else if(
name ==
"select_cb") {
90 return make_element_by_type<cb_wargoal_button>(
state,
id);
100 return "cb_type_item";
105 dcon::nation_id content = retrieve<dcon::nation_id>(
state,
parent);
106 state.world.for_each_cb_type([&](dcon::cb_type_id cb) {
117 auto content = retrieve<dcon::cb_type_id>(
state,
parent);
118 auto target_nation = retrieve<dcon::nation_id>(
state,
parent);
119 auto target_state = retrieve<dcon::state_definition_id>(
state,
parent);
125 auto wargoal_decided_upon = retrieve<bool>(
state,
parent);
127 if(!wargoal_decided_upon) {
131 auto content = retrieve<dcon::cb_type_id>(
state,
parent);
132 auto target_nation = retrieve<dcon::nation_id>(
state,
parent);
133 auto target_state = retrieve<dcon::state_definition_id>(
state,
parent);
143 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)));
144 auto target_nation = retrieve<dcon::nation_id>(
state,
parent);
145 auto target_state = retrieve<dcon::state_definition_id>(
state,
parent);
147 if(fat_cb.is_valid()) {
179 dcon::cb_type_id root_cb{};
180 dcon::state_definition_id target_state = dcon::state_definition_id{};
185 if(
name ==
"background") {
186 auto ptr = make_element_by_type<draggable_target>(
state,
id);
189 }
else if(
name ==
"diplo_makecb_bg") {
190 return make_element_by_type<image_element_base>(
state,
id);
191 }
else if(
name ==
"title") {
192 return make_element_by_type<make_cb_title>(
state,
id);
193 }
else if(
name ==
"description") {
194 return make_element_by_type<diplomacy_make_cb_desc>(
state,
id);
195 }
else if(
name ==
"leftshield") {
196 return make_element_by_type<nation_player_flag>(
state,
id);
197 }
else if(
name ==
"rightshield") {
198 return make_element_by_type<flag_button>(
state,
id);
199 }
else if(
name ==
"agreebutton") {
200 return make_element_by_type<diplomacy_make_cb_button>(
state,
id);
201 }
else if(
name ==
"declinebutton") {
202 return make_element_by_type<generic_close_button>(
state,
id);
203 }
else if(
name ==
"cb_list") {
204 return make_element_by_type<diplomacy_make_cb_listbox>(
state,
id);
211 target_state = dcon::state_definition_id{};
216 dcon::nation_id target = retrieve<dcon::nation_id>(
state,
parent);
217 auto cb_to_use = root_cb;
218 target_state = dcon::state_definition_id{};
222 auto actor =
state.local_player_nation;
223 dcon::cb_type_id cb = cb_to_use;
225 auto allowed_substate_regions =
state.world.cb_type_get_allowed_substate_regions(cb);
226 if(allowed_substate_regions) {
227 for(
auto v :
state.world.nation_get_overlord_as_ruler(target)) {
228 if(v.get_subject().get_is_substate()) {
229 for(
auto si :
state.world.nation_get_state_ownership(target)) {
231 auto def = si.get_state().get_definition().id;
242 auto allowed_states =
state.world.cb_type_get_allowed_states(cb);
243 if(
auto ac =
state.world.cb_type_get_allowed_countries(cb); ac) {
244 auto in_nation = target;
245 auto target_identity =
state.world.nation_get_identity_from_identity_holder(target);
246 for(
auto si :
state.world.nation_get_state_ownership(target)) {
248 auto def = si.get_state().get_definition().id;
255 for(
auto si :
state.world.nation_get_state_ownership(target)) {
257 auto def = si.get_state().get_definition().id;
271 target_state = dcon::state_definition_id{};
272 cb_to_use = dcon::cb_type_id{};
276 state.start_state_selection(seldata);
281 root_cb = any_cast<element_selection_wrapper<dcon::cb_type_id>>(payload).data;
290 }
else if(payload.holds_type<
bool>()) {
293 }
else if(payload.holds_type<dcon::cb_type_id>()) {
294 payload.emplace<dcon::cb_type_id>(root_cb);
297 else if(payload.holds_type<dcon::state_definition_id>()) {
298 payload.emplace<dcon::state_definition_id>(target_state);
319 int32_t discovered = 0;
320 state.world.for_each_technology([&](dcon::technology_id
id) {
325 if(
state.world.nation_get_active_technologies(n,
id))
343 int32_t discovered = 0;
344 state.world.for_each_technology([&](dcon::technology_id
id) {
349 if(
state.world.nation_get_active_technologies(n,
id))
372 auto mod =
state.world.nation_get_modifier_values(n, sys::national_mod_offsets::war_exhaustion);
376 }
else if(mod == 0) {
392 auto content = retrieve<dcon::nation_id>(
state,
parent);
394 if(content == window_content)
400 auto content = retrieve<dcon::nation_id>(
state,
parent);
406 int32_t total_influence_shares = 0;
407 auto n = fatten(
state.world,
state.local_player_nation);
409 for(
auto rel :
state.world.nation_get_gp_relationship_as_great_power(
state.local_player_nation)) {
413 total_influence_shares += 1;
416 total_influence_shares += 2;
419 total_influence_shares += 3;
428 auto rel = fatten(
state.world,
state.world.get_gp_relationship_by_gp_influence_pair(target,
state.local_player_nation));
443 if(total_influence_shares > 0) {
444 float total_gain =
state.defines.base_greatpower_daily_influence
445 * (1.0f + n.get_modifier_values(sys::national_mod_offsets::influence_modifier))
446 * (1.0f + n.get_modifier_values(sys::national_mod_offsets::influence));
451 auto gp_invest =
state.world.unilateral_relationship_get_foreign_investment(
452 state.world.get_unilateral_relationship_by_unilateral_pair(target, n));
455 ?
state.defines.discredit_influence_gain_factor
457 float neighbor_factor =
bool(
state.world.get_nation_adjacency_by_nation_adjacency_pair(n, target))
458 ?
state.defines.neighbour_bonus_influence_percent
461 ?
state.defines.sphere_neighbour_bonus_influence_percent
463 float continent_factor =
464 n.get_capital().get_continent() !=
state.world.nation_get_capital(target).get_continent()
465 ?
state.defines.other_continent_bonus_influence_percent
467 float puppet_factor =
468 fatten(
state.world,
state.world.nation_get_overlord_as_subject(target)).get_ruler() == n
469 ?
state.defines.puppet_bonus_influence_percent
471 float relationship_factor =
472 state.world.diplomatic_relation_get_value(
state.world.get_diplomatic_relation_by_diplomatic_pair(n, target)) /
state.defines.relation_influence_modifier;
474 float investment_factor =
476 ?
state.defines.investment_influence_defense * gp_invest / total_fi
480 ?
state.defines.large_population_influence_penalty *
state.world.nation_get_demographics(target,
demographics::total) /
state.defines.large_population_influence_penalty_chunk
487 float total_multiplier = 1.0f + discredit_factor + neighbor_factor + sphere_neighbor_factor + continent_factor + puppet_factor + relationship_factor + investment_factor + pop_factor + score_factor;
489 auto gain_amount = std::max(0.0f, base_shares * total_multiplier);
507 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) {
511 if(discredit_factor != 0) {
514 if(neighbor_factor != 0) {
517 if(sphere_neighbor_factor != 0) {
520 if(continent_factor != 0) {
523 if(puppet_factor != 0) {
526 if(relationship_factor != 0) {
529 if(investment_factor != 0) {
532 if(pop_factor != 0) {
535 if(score_factor != 0) {
543 static std::string_view get_prio_key(
uint8_t f) {
546 return "diplomacy_prio_none";
548 return "diplomacy_prio_low";
550 return "diplomacy_prio_middle";
552 return "diplomacy_prio_high";
554 return "diplomacy_prio_none";
560 auto nation_id = retrieve<dcon::nation_id>(
state,
parent);
562 auto rel =
state.world.get_gp_relationship_by_gp_influence_pair(nation_id,
state.local_player_nation);
563 uint8_t rel_flags = bool(rel) ?
state.world.gp_relationship_get_status(rel) : 0;
587 auto nation_id = retrieve<dcon::nation_id>(
state,
parent);
589 auto rel =
state.world.get_gp_relationship_by_gp_influence_pair(nation_id,
state.local_player_nation);
590 uint8_t rel_flags = bool(rel) ?
state.world.gp_relationship_get_status(rel) : 0;
608 auto nation_id = retrieve<dcon::nation_id>(
state,
parent);
609 auto rel =
state.world.get_gp_relationship_by_gp_influence_pair(nation_id,
state.local_player_nation);
610 uint8_t rel_flags = bool(rel) ?
state.world.gp_relationship_get_status(rel) : 0;
634 auto nation_id = retrieve<dcon::nation_id>(
state,
parent);
655 auto const n = retrieve<dcon::nation_id>(
state,
parent);
656 auto const rel =
state.world.get_unilateral_relationship_by_unilateral_pair(n,
state.local_player_nation);
657 return state.world.unilateral_relationship_get_interested_in_alliance(rel);
660 auto const n = retrieve<dcon::nation_id>(
state,
parent);
665 auto const n = retrieve<dcon::nation_id>(
state,
parent);
684 if(
name ==
"country_select") {
685 return make_element_by_type<diplomacy_country_select>(
state,
id);
686 }
else if(
name ==
"country_flag") {
687 auto ptr = make_element_by_type<flag_button>(
state,
id);
688 ptr->base_data.position.y -= 2;
690 }
else if(
name ==
"country_name") {
691 return make_element_by_type<generic_name_text<dcon::nation_id>>(
state, id);
692 }
else if(
name ==
"country_prio") {
693 auto ptr = make_element_by_type<diplomacy_priority_button>(
state,
id);
695 auto btn = make_element_by_type<diplomacy_country_interested_in_alliance>(
state,
"alice_interested_in_alliance");
696 btn->base_data.position = ptr->base_data.position;
697 btn->base_data.position.x -= btn->base_data.size.x;
701 }
else if(
name ==
"country_boss_flag") {
702 return make_element_by_type<nation_overlord_flag>(
state,
id);
703 }
else if(
name ==
"country_prestige") {
704 return make_element_by_type<nation_prestige_rank_text>(
state,
id);
705 }
else if(
name ==
"country_economic") {
706 return make_element_by_type<nation_industry_rank_text>(
state,
id);
707 }
else if(
name ==
"country_military") {
708 return make_element_by_type<nation_military_rank_text>(
state,
id);
709 }
else if(
name ==
"country_total") {
710 return make_element_by_type<nation_rank_text>(
state,
id);
711 }
else if(
name ==
"country_opinion") {
712 return make_element_by_type<nation_player_opinion_text>(
state,
id);
713 }
else if(
name ==
"country_relation") {
714 return make_element_by_type<nation_player_relations_text>(
state,
id);
715 }
else if(
name.substr(0, 10) ==
"country_gp") {
716 auto ptr = make_element_by_type<nation_gp_opinion_text>(
state,
id);
717 ptr->rank = uint16_t(std::stoi(std::string{
name.substr(10)}));
732 return "diplomacy_country_info";
735 auto current_filter = retrieve< country_filter_setting>(
state,
parent);
736 auto current_sort = retrieve<country_sort_setting>(
state,
parent);
739 state.world.for_each_nation([&](dcon::nation_id
id) {
740 if(
state.world.nation_get_owned_province_count(
id) != 0) {
741 bool passes_filter = country_category_filter_check(state, current_filter.general_category, state.local_player_nation, id);
742 bool right_continent = !current_filter.continent || state.world.nation_get_capital(id).get_continent() == current_filter.continent;
743 if(passes_filter && right_continent)
744 row_contents.push_back(id);
755 auto n = any_cast<dip_make_nation_visible>(payload).data;
766 if(i < current_vis || i >= current_vis + vis_count) {
781 auto cb = retrieve<military::available_cb>(
state,
parent);
782 dcon::cb_type_id content = cb.cb_type;
783 frame =
state.world.cb_type_get_sprite_index(content) - 1;
785 auto conditions =
state.world.cb_type_get_can_use(cb.cb_type);
798 auto cb = retrieve<military::available_cb>(
state,
parent);
803 auto conditions =
state.world.cb_type_get_can_use(cb.cb_type);
815 if(
name ==
"wargoal_icon") {
816 return make_element_by_type<cb_icon>(
state,
id);
833 auto content = retrieve<dcon::nation_id>(
state,
parent);
834 if(!content || content ==
state.local_player_nation)
837 auto one_cbs =
state.world.nation_get_available_cbs(
state.local_player_nation);
838 for(
auto& cb : one_cbs)
839 if(cb.target == content)
842 for(
auto cb :
state.world.in_cb_type) {
863 auto content = retrieve<dcon::nation_id>(
state,
parent);
867 if(content && content !=
state.local_player_nation && war) {
868 for(
auto wg :
state.world.war_get_wargoals_attached(war)) {
869 if(wg.get_wargoal().get_added_by() ==
state.local_player_nation && wg.get_wargoal().get_target_nation() == content) {
871 wg.get_wargoal().get_secondary_nation(),
872 wg.get_wargoal().get_associated_tag(),
873 wg.get_wargoal().get_associated_state(),
874 wg.get_wargoal().get_type()
889 auto content = retrieve<dcon::nation_id>(
state,
parent);
894 if(
state.cheat_data.always_allow_wargoals) {
899 if(content ==
state.local_player_nation) {
903 if(
state.world.nation_get_diplomatic_points(
state.local_player_nation) <
state.defines.addwargoal_diplomatic_cost) {
916 for(
auto cb_type :
state.world.in_cb_type) {
918 bool cb_fabbed =
false;
919 for(
auto& fab_cb :
state.world.nation_get_available_cbs(
state.local_player_nation)) {
920 if(fab_cb.cb_type == cb_type && fab_cb.target == content) {
932 if(
state.world.war_get_is_great(w)) {
933 if(jingoism_perc >=
state.defines.wargoal_jingoism_requirement *
state.defines.gw_wargoal_jingoism_requirement_mod) {
938 if(jingoism_perc >=
state.defines.wargoal_jingoism_requirement) {
966 auto content = retrieve<dcon::nation_id>(
state,
parent);
967 if(content ==
state.local_player_nation) {
972 if(
state.defines.addwargoal_diplomatic_cost > 0) {
985 for(
auto cb_type :
state.world.in_cb_type) {
988 for(
auto& fab_cb :
state.world.nation_get_available_cbs(
state.local_player_nation)) {
989 if(fab_cb.cb_type == cb_type && fab_cb.target == content) {
1005 if(
state.world.war_get_is_great(w)) {
1016 auto pc =
state.world.nation_get_primary_culture(retrieve<dcon::nation_id>(
state,
parent));
1017 auto pr =
state.world.nation_get_religion(retrieve<dcon::nation_id>(
state,
parent));
1027 auto content = retrieve<dcon::nation_id>(
state,
parent);
1035 auto n = retrieve<dcon::nation_id>(
state,
parent);
1038 for(
const auto ac :
state.world.in_culture) {
1039 if(
state.world.nation_get_accepted_cultures(n, ac)) {
1054 auto n = retrieve<dcon::nation_id>(
state,
parent);
1055 for(
const auto c :
state.world.in_culture) {
1056 if(
state.world.nation_get_accepted_cultures(n, c))
1084 auto target = retrieve<dcon::nation_id>(
state,
parent);
1093 auto target = retrieve<dcon::nation_id>(
state,
parent);
1094 auto rel =
state.world.get_gp_relationship_by_gp_influence_pair(target, gp);
1109 auto target = retrieve<dcon::nation_id>(
state,
parent);
1118 auto target = retrieve<dcon::nation_id>(
state,
parent);
1119 auto rel =
state.world.get_gp_relationship_by_gp_influence_pair(target, gp);
1133 auto target = retrieve<dcon::nation_id>(
state,
parent);
1142 auto target = retrieve<dcon::nation_id>(
state,
parent);
1151 auto target = retrieve<dcon::nation_id>(
state,
parent);
1161 return state.world.nation_get_identity_from_identity_holder(gp);
1174 if(
name ==
"country_flag") {
1175 return make_element_by_type<great_power_detail_flag>(
state,
id);
1176 }
else if(
name ==
"nongp_country_opinion") {
1177 return make_element_by_type<great_power_opinion_detail>(
state,
id);
1178 }
else if(
name ==
"nongp_country_influence") {
1179 return make_element_by_type<great_power_influence_detail>(
state,
id);
1180 }
else if(
name ==
"nongp_country_invest") {
1181 return make_element_by_type<great_power_investment_detail>(
state,
id);
1182 }
else if(
name ==
"country_discredited") {
1183 return make_element_by_type<gp_detail_discredited>(
state,
id);
1184 }
else if(
name ==
"country_banned_embassy") {
1185 return make_element_by_type<gp_detail_banned>(
state,
id);
1206 dcon::overlord_id overlord =
state.world.nation_get_overlord_as_subject(content);
1207 dcon::nation_id overlord_nation =
state.world.overlord_get_ruler(overlord);
1209 if(
state.world.nation_get_is_substate(content)) {
1211 }
else if(overlord_nation) {
1227 std::array<element_base*, 7> gp_elements;
1228 std::array<element_base*, 9> non_gp_elements;
1229 std::array<element_base*, 21> war_elements;
1236 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);
1237 win->gp_num = int32_t(i);
1238 win->base_data.position = sub_window_top_left;
1239 win->base_data.position.
x += win->base_data.size.x * int16_t(i / row_count);
1240 win->base_data.position.y += win->base_data.size.y * int16_t(i % row_count);
1241 non_gp_elements[1 + i] = win.get();
1247 if(
name ==
"gp_extra_info_bg") {
1248 auto ptr = make_element_by_type<image_element_base>(
state,
id);
1249 gp_elements[0] = ptr.get();
1251 }
else if(
name ==
"country_gp_friendly_label") {
1252 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
1253 gp_elements[1] = ptr.get();
1255 }
else if(
name ==
"country_gp_cordial_label") {
1256 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
1257 gp_elements[2] = ptr.get();
1259 }
else if(
name ==
"country_gp_sphere_label") {
1260 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
1261 gp_elements[3] = ptr.get();
1263 }
else if(
name ==
"country_gp_friendly") {
1264 auto ptr = make_element_by_type<overlapping_friendly_flags>(
state,
id);
1265 ptr->base_data.position.y -= 8 - 1;
1266 gp_elements[4] = ptr.get();
1268 }
else if(
name ==
"country_gp_cordial") {
1269 auto ptr = make_element_by_type<overlapping_cordial_flags>(
state,
id);
1270 ptr->base_data.position.y -= 8 - 1;
1271 gp_elements[5] = ptr.get();
1273 }
else if(
name ==
"country_gp_sphere") {
1274 auto ptr = make_element_by_type<overlapping_sphere_flags>(
state,
id);
1275 ptr->base_data.position.y -= 8 - 1;
1276 gp_elements[6] = ptr.get();
1278 }
else if(
name ==
"nongp_extra_info_bg") {
1279 auto ptr = make_element_by_type<image_element_base>(
state,
id);
1280 non_gp_elements[0] = ptr.get();
1281 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];
1282 sub_window_top_left = def.position;
1284 }
else if(
name ==
"country_flag") {
1285 return make_element_by_type<flag_button>(
state,
id);
1286 }
else if(
name ==
"country_flag_overlay") {
1287 return make_element_by_type<nation_flag_frame>(
state,
id);
1288 }
else if(
name ==
"country_name") {
1289 return make_element_by_type<generic_name_text<dcon::nation_id>>(
state, id);
1290 }
else if(
name ==
"country_status") {
1291 auto ptr = make_element_by_type<nation_status_diplomacy_window<dcon::nation_id>>(
state, id);
1293 }
else if(
name ==
"selected_nation_totalrank") {
1294 return make_element_by_type<nation_rank_text>(
state,
id);
1295 }
else if(
name ==
"ideology_icon") {
1296 return make_element_by_type<nation_ruling_party_ideology_plupp>(
state,
id);
1297 }
else if(
name ==
"country_party") {
1298 return make_element_by_type<nation_ruling_party_text>(
state,
id);
1299 }
else if(
name ==
"country_gov") {
1300 return make_element_by_type<nation_government_type_text>(
state,
id);
1301 }
else if(
name ==
"country_tech") {
1302 return make_element_by_type<national_tech_school>(
state,
id);
1303 }
else if(
name ==
"our_relation_icon") {
1304 auto ptr = make_element_by_type<image_element_base>(
state,
id);
1305 country_relation_icon = ptr.
get();
1307 }
else if(
name ==
"our_relation") {
1308 auto ptr = make_element_by_type<nation_player_relations_text>(
state,
id);
1309 country_relation = ptr.
get();
1311 }
else if(
name ==
"country_prestige") {
1312 return make_element_by_type<nation_prestige_text>(
state,
id);
1313 }
else if(
name ==
"selected_prestige_rank") {
1314 return make_element_by_type<nation_prestige_rank_text>(
state,
id);
1315 }
else if(
name ==
"country_economic") {
1316 return make_element_by_type<nation_industry_score_text>(
state,
id);
1317 }
else if(
name ==
"selected_industry_rank") {
1318 return make_element_by_type<nation_industry_rank_text>(
state,
id);
1319 }
else if(
name ==
"country_military") {
1320 return make_element_by_type<nation_military_score_text>(
state,
id);
1321 }
else if(
name ==
"selected_military_rank") {
1322 return make_element_by_type<nation_military_rank_text>(
state,
id);
1323 }
else if(
name ==
"country_total") {
1324 return make_element_by_type<nation_total_score_text>(
state,
id);
1325 }
else if(
name ==
"selected_total_rank") {
1326 return make_element_by_type<nation_rank_text>(
state,
id);
1327 }
else if(
name ==
"country_population") {
1328 return make_element_by_type<nation_population_text>(
state,
id);
1329 }
else if(
name ==
"country_primary_cultures") {
1330 return make_element_by_type<nation_primary_culture>(
state,
id);
1331 }
else if(
name ==
"country_accepted_cultures") {
1332 return make_element_by_type<nation_accepted_cultures>(
state,
id);
1333 }
else if(
name ==
"war_extra_info_bg") {
1334 auto ptr = make_element_by_type<image_element_base>(
state,
id);
1335 war_elements[0] = ptr.get();
1337 }
else if(
name ==
"country_wars") {
1338 auto ptr = make_element_by_type<overlapping_enemy_flags>(
state,
id);
1339 ptr->base_data.position.y -= 8 - 1;
1340 war_elements[1] = ptr.get();
1342 }
else if(
name ==
"country_wars_text") {
1343 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
1344 war_elements[2] = ptr.get();
1346 }
else if(
name ==
"country_allies_text") {
1347 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
1348 war_elements[3] = ptr.get();
1350 }
else if(
name ==
"country_protected_text") {
1351 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
1352 war_elements[4] = ptr.get();
1354 }
else if(
name ==
"country_truce_text") {
1355 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
1356 war_elements[5] = ptr.get();
1358 }
else if(
name ==
"country_cb_text") {
1359 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
1360 war_elements[6] = ptr.get();
1362 }
else if(
name ==
"infamy_icon") {
1363 auto ptr = make_element_by_type<image_element_base>(
state,
id);
1364 war_elements[7] = ptr.get();
1366 }
else if(
name ==
"warexhastion_icon") {
1367 auto ptr = make_element_by_type<image_element_base>(
state,
id);
1368 war_elements[8] = ptr.get();
1370 }
else if(
name ==
"brigade_icon") {
1371 auto ptr = make_element_by_type<image_element_base>(
state,
id);
1372 war_elements[9] = ptr.get();
1374 }
else if(
name ==
"ships_icon") {
1375 auto ptr = make_element_by_type<image_element_base>(
state,
id);
1376 war_elements[10] = ptr.get();
1378 }
else if(
name ==
"country_allies") {
1379 auto ptr = make_element_by_type<overlapping_ally_flags>(
state,
id);
1380 ptr->base_data.position.y -= 8 - 1;
1381 war_elements[11] = ptr.get();
1383 }
else if(
name ==
"country_protected") {
1384 auto ptr = make_element_by_type<overlapping_sphere_flags>(
state,
id);
1385 ptr->base_data.position.y -= 8 - 1;
1386 war_elements[12] = ptr.get();
1388 }
else if(
name ==
"country_truce") {
1389 auto ptr = make_element_by_type<overlapping_truce_flags>(
state,
id);
1390 ptr->base_data.position.y -= 8 - 1;
1391 war_elements[13] = ptr.get();
1393 }
else if(
name ==
"current_wargoals") {
1394 auto ptr = make_element_by_type<overlapping_active_wargoals>(
state,
id);
1395 war_elements[14] = ptr.get();
1397 }
else if(
name ==
"country_cb") {
1398 auto ptr = make_element_by_type<overlapping_wargoals>(
state,
id);
1399 war_elements[15] = ptr.get();
1401 }
else if(
name ==
"infamy_text") {
1402 auto ptr = make_element_by_type<nation_infamy_text>(
state,
id);
1403 war_elements[16] = ptr.get();
1405 }
else if(
name ==
"warexhastion_text") {
1406 auto ptr = make_element_by_type<diplomacy_war_exhaustion>(
state,
id);
1407 war_elements[17] = ptr.get();
1409 }
else if(
name ==
"brigade_text") {
1410 auto ptr = make_element_by_type<diplomacy_nation_armies_text>(
state,
id);
1411 war_elements[18] = ptr.get();
1413 }
else if(
name ==
"ships_text") {
1414 auto ptr = make_element_by_type<diplomacy_nation_navies_text>(
state,
id);
1415 war_elements[19] = ptr.get();
1417 }
else if(
name ==
"add_wargoal") {
1418 auto ptr = make_element_by_type<diplomacy_action_add_wargoal_button>(
state,
id);
1419 war_elements[20] = ptr.get();
1421 }
else if(
name ==
"selected_military_icon") {
1422 return make_element_by_type<military_score_icon>(
state,
id);
1429 auto content = retrieve<dcon::nation_id>(
state,
parent);
1432 auto active_tab = retrieve<dip_tab_request>(
state,
parent).tab;
1435 for(
auto p : gp_elements) {
1437 p->set_visible(
state,
false);
1439 for(
auto p : non_gp_elements) {
1441 p->set_visible(
state,
false);
1443 for(
auto p : war_elements) {
1445 p->set_visible(
state,
true);
1448 for(
auto p : gp_elements) {
1450 p->set_visible(
state,
true);
1452 for(
auto p : non_gp_elements) {
1454 p->set_visible(
state,
false);
1456 for(
auto p : war_elements) {
1458 p->set_visible(
state,
false);
1461 for(
auto p : gp_elements) {
1463 p->set_visible(
state,
false);
1465 for(
auto p : non_gp_elements) {
1467 p->set_visible(
state,
true);
1469 for(
auto p : war_elements) {
1471 p->set_visible(
state,
false);
1482 dcon::war_id w = retrieve<dcon::war_id>(
state,
parent);
1484 row_contents.push_back(war.get_primary_attacker().get_identity_from_identity_holder().id);
1485 for(
auto o : war.get_war_participant())
1486 if(o.get_is_attacker() ==
true && o.get_nation() != war.get_primary_attacker())
1487 row_contents.push_back(o.get_nation().get_identity_from_identity_holder().id);
1495 dcon::war_id w = retrieve<dcon::war_id>(
state,
parent);
1497 row_contents.push_back(war.get_primary_defender().get_identity_from_identity_holder().id);
1498 for(
auto o : war.get_war_participant())
1499 if(o.get_is_attacker() ==
false && o.get_nation() != war.get_primary_defender())
1500 row_contents.push_back(o.get_nation().get_identity_from_identity_holder().id);
1505template<
bool IsAttacker>
1509 dcon::war_id content = retrieve<dcon::war_id>(
state,
parent);
1512 int32_t strength = 0;
1513 for(
auto o : fat_id.get_war_participant())
1514 if(o.get_is_attacker() == IsAttacker)
1515 strength += int32_t(o.get_nation().get_military_score());
1524 dcon::war_id content = retrieve<dcon::war_id>(
state,
parent);
1533 for(
auto o : fat_id.get_war_participant()) {
1534 if(o.get_is_attacker() == IsAttacker) {
1540 auto strength = int32_t(o.get_nation().get_military_score());
1557 dcon::war_id war_id = retrieve<dcon::war_id>(
state,
parent);
1562 dcon::war_id war_id = retrieve<dcon::war_id>(
state,
parent);
1572 dcon::nation_id nation_id = retrieve<dcon::nation_id>(
state,
parent);
1573 dcon::war_id w = retrieve<dcon::war_id>(
state,
parent);
1575 if(!
state.world.war_get_is_great(w)) {
1584 if(
state.defines.min_months_to_intervene > 0) {
1593 if(!
state.world.war_get_is_great(w)) {
1594 auto defender =
state.world.war_get_primary_defender(w);
1595 auto rel_w_defender =
state.world.get_gp_relationship_by_gp_influence_pair(defender,
state.local_player_nation);
1612 auto primary_on_side =
B ?
state.world.war_get_primary_attacker(w) :
state.world.war_get_primary_defender(w);
1613 auto rel =
state.world.get_diplomatic_relation_by_diplomatic_pair(primary_on_side,
state.local_player_nation);
1617 bool any_in_sphere =
false;
1618 bool any_allied =
false;
1619 bool any_armies =
false;
1621 for(
auto p :
state.world.war_get_war_participant(w)) {
1622 if(p.get_is_attacker() !=
B) {
1623 if(p.get_nation().get_in_sphere_of() ==
state.local_player_nation)
1624 any_in_sphere =
true;
1626 auto irel =
state.world.get_diplomatic_relation_by_diplomatic_pair(p.get_nation(),
state.local_player_nation);
1627 if(
state.world.diplomatic_relation_get_are_allied(irel))
1630 for(
auto prov : p.get_nation().get_province_ownership()) {
1631 for(
auto arm : prov.get_province().get_army_location()) {
1632 if(arm.get_army().get_controller_from_army_control() ==
state.local_player_nation)
1650 auto wg = retrieve<dcon::wargoal_id>(
state,
parent);
1651 frame =
state.world.cb_type_get_sprite_index(
state.world.wargoal_get_type(wg)) - 1;
1659 auto wg = retrieve<dcon::wargoal_id>(
state,
parent);
1660 auto cb =
state.world.wargoal_get_type(wg);
1666 if(
state.world.wargoal_get_associated_state(wg)) {
1669 if(
state.world.wargoal_get_associated_tag(wg)) {
1671 }
else if(
state.world.wargoal_get_secondary_nation(wg)) {
1674 if(
state.world.wargoal_get_ticking_war_score(wg) != 0) {
1692 auto const start_date =
state.world.war_get_start_date(
state.world.wargoal_get_war_from_wargoals_attached(wg));
1693 auto const end_date = start_date + int32_t(
state.defines.tws_grace_period_days);
1698 if(end_date <=
state.current_date) {
1711 if(
name ==
"wargoal_icon") {
1712 return make_element_by_type<wargoal_icon>(
state,
id);
1730 dcon::war_id content = retrieve<dcon::war_id>(
state,
parent);
1731 for(
auto wg :
state.world.war_get_wargoals_attached(content)) {
1779 auto bar_pos = retrieve<war_bar_position>(
state,
parent);
1783 auto x_pos = int16_t((
float(attacker_cost) / 200.0f + 0.5f) *
float(bar_pos.width));
1793 auto bar_pos = retrieve<war_bar_position>(
state,
parent);
1797 auto x_pos = int16_t((
float(-defender_cost) / 200.0f + 0.5f) *
float(bar_pos.width));
1807 if(
state.world.war_get_is_great(war)) {
1809 }
else if(
state.world.war_get_is_crisis_war(war)) {
1838 if(
name ==
"diplo_war_entrybg") {
1839 return make_element_by_type<war_bg>(
state,
id);
1840 }
else if(
name ==
"war_name") {
1841 return make_element_by_type<war_name_text>(
state,
id);
1842 }
else if(
name ==
"attackers_mil_strength") {
1843 auto ptr = make_element_by_type<war_side_strength_text<true>>(
state, id);
1844 ptr->base_data.position.y -= 4;
1846 }
else if(
name ==
"defenders_mil_strength") {
1847 auto ptr = make_element_by_type<war_side_strength_text<false>>(
state, id);
1848 ptr->base_data.position.y -= 4;
1850 }
else if(
name ==
"warscore") {
1851 auto ptr = make_element_by_type<war_score_progress_bar>(
state,
id);
1855 }
if(
name ==
"diplo_warscore_marker1") {
1856 return make_element_by_type<attacker_peace_goal>(
state,
id);
1857 }
else if(
name ==
"diplo_warscore_marker2") {
1858 return make_element_by_type<defender_peace_goal>(
state,
id);
1859 }
else if(
name ==
"warscore_text") {
1860 auto ptr = make_element_by_type<war_score_text>(
state,
id);
1861 ptr->base_data.position.y -= 2;
1863 }
else if(
name ==
"attackers") {
1864 auto ptr = make_element_by_type<overlapping_attacker_flags>(
state,
id);
1865 ptr->base_data.position.y -= 8 - 2;
1867 }
else if(
name ==
"defenders") {
1868 auto ptr = make_element_by_type<overlapping_defender_flags>(
state,
id);
1869 ptr->base_data.position.y -= 8 - 2;
1871 }
else if(
name ==
"attackers_wargoals") {
1872 return make_element_by_type<diplomacy_war_overlapping_wargoals<true>>(
state, id);
1873 }
else if(
name ==
"defenders_wargoals") {
1874 return make_element_by_type<diplomacy_war_overlapping_wargoals<false>>(
state, id);
1875 }
else if(
name ==
"join_attackers") {
1876 return make_element_by_type<diplomacy_join_war_button<true>>(
state, id);
1877 }
else if(
name ==
"join_defenders") {
1878 return make_element_by_type<diplomacy_join_war_button<false>>(
state, id);
1896 const dcon::nation_id content = retrieve<dcon::nation_id>(
state,
parent);
1898 frame = fat.get_constructing_cb_type().get_sprite_index() - 1;
1906 const dcon::nation_id content = retrieve<dcon::nation_id>(
state,
parent);
1925 const dcon::nation_id content = retrieve<dcon::nation_id>(
state,
parent);
1927 progress = (fat.get_constructing_cb_progress() / 100.0f);
1935 auto fab_by = retrieve<dcon::nation_id>(
state,
parent);
1936 auto target =
state.world.nation_get_constructing_cb_target(fab_by);
1940 auto rem_progress = 100.0f -
state.world.nation_get_constructing_cb_progress(fab_by);
1941 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);
1942 auto days = int32_t(std::ceil(rem_progress / daily_progress));
1953 const dcon::nation_id content = retrieve<dcon::nation_id>(
state,
parent);
1956 row_contents.push_back(fat.get_identity_from_identity_holder().id);
1964 const dcon::nation_id content = retrieve<dcon::nation_id>(
state,
parent);
1967 row_contents.push_back(fat.get_constructing_cb_target().get_identity_from_identity_holder().id);
1975 const dcon::nation_id content = retrieve<dcon::nation_id>(
state,
parent);
1976 if(content !=
state.local_player_nation) {
1984 const dcon::nation_id content = retrieve<dcon::nation_id>(
state,
parent);
1997 auto just_progress =
state.world.nation_get_constructing_cb_progress(retrieve<dcon::nation_id>(
state,
parent));
2010 if(
name ==
"diplo_cb_entrybg") {
2011 return make_element_by_type<image_element_base>(
state,
id);
2012 }
else if(
name ==
"cb_type_icon") {
2013 return make_element_by_type<justifying_cb_type_icon>(
state,
id);
2014 }
else if(
name ==
"cb_progress") {
2015 return make_element_by_type<justifying_cb_progress>(
state,
id);
2016 }
else if(
name ==
"cb_progress_text") {
2017 return make_element_by_type<cb_progress_text>(
state,
id);
2018 }
else if(
name ==
"attackers") {
2019 auto ptr = make_element_by_type<justifying_attacker_flag>(
state,
id);
2020 ptr->base_data.position.y -= 7;
2022 }
else if(
name ==
"defenders") {
2023 auto ptr = make_element_by_type<justifying_defender_flag>(
state,
id);
2024 ptr->base_data.position.y -= 7;
2026 }
else if(
name ==
"cancel") {
2027 return make_element_by_type<diplomacy_casus_belli_cancel_button>(
state,
id);
2037 return "diplomacy_cb_info_player";
2048 for(
const auto id :
state.world.in_nation) {
2049 if(
id ==
state.local_player_nation &&
dcon::fatten(
state.world,
state.local_player_nation).get_constructing_cb_type().is_valid()) {
2054 for(
const auto id :
state.world.in_nation) {
2055 if(
id !=
state.local_player_nation &&
dcon::fatten(
state.world,
id).get_constructing_cb_is_discovered()) {
2066 if(
name ==
"cb_listbox") {
2067 auto ptr = make_element_by_type<diplomacy_casus_belli_listbox>(
state,
id);
2068 ptr->base_data.position.x -= 400;
2079 return "diplomacy_war_info";
2087 auto in_a = military::get_role(state, a, state.local_player_nation) != military::war_role::none;
2088 auto in_b = military::get_role(state, b, state.local_player_nation) != military::war_role::none;
2092 return state.world.war_get_start_date(a) < state.world.war_get_start_date(b);
2104 if(
name ==
"country_name") {
2105 return make_element_by_type<generic_name_text<dcon::nation_id>>(
state, id);
2106 }
else if(
name ==
"country_flag") {
2107 return make_element_by_type<flag_button>(
state,
id);
2108 }
else if(
name ==
"country_puppets") {
2109 auto ptr = make_element_by_type<overlapping_sphere_flags>(
state,
id);
2110 ptr->base_data.position.y -= 8;
2112 }
else if(
name ==
"gp_prestige") {
2113 return make_element_by_type<nation_prestige_text>(
state,
id);
2114 }
else if(
name ==
"gp_economic") {
2115 return make_element_by_type<nation_industry_score_text>(
state,
id);
2116 }
else if(
name ==
"gp_military") {
2117 return make_element_by_type<nation_military_score_text>(
state,
id);
2118 }
else if(
name ==
"gp_total") {
2119 return make_element_by_type<nation_total_score_text>(
state,
id);
2126 if(payload.holds_type<dcon::nation_id>()) {
2128 return message_result::consumed;
2130 return window_element_base::get(
state, payload);
2153 checkbox_button::on_update(
state);
2161 simple_text_element_base::on_create(
state);
2187 &diplomacy_action_ally_button_s,
2188 &diplomacy_action_call_ally_button_s,
2189 &diplomacy_action_military_access_button_s,
2190 &diplomacy_action_give_military_access_button_s,
2191 &diplomacy_action_increase_relations_button_s,
2192 &diplomacy_action_decrease_relations_button_s,
2193 &diplomacy_action_war_subisides_button_s,
2194 &diplomacy_action_declare_war_button_s,
2195 &diplomacy_action_release_subject_button_s
2198 &diplomacy_action_discredit_button_s,
2199 &diplomacy_action_expel_advisors_button_s,
2200 &diplomacy_action_ban_embassy_button_s,
2201 &diplomacy_action_increase_opinion_button_s,
2202 &diplomacy_action_decrease_opinion_button_s,
2203 &diplomacy_action_add_to_sphere_button_s,
2204 &diplomacy_action_remove_from_sphere_button_s,
2205 &diplomacy_action_justify_war_button_s,
2206 &diplomacy_action_state_transfer_button_s
2211 auto i = retrieve<int16_t>(
state, parent);
2212 auto target = retrieve<dcon::nation_id>(
state, parent);
2214 if (leftcolumnlogics[i]) {
2216 base_data.data.button.txt = curlogic->
get_name(
state, target);
2218 button_element_base::on_reset_text(
state);
2223 auto i = retrieve<int16_t>(
state, parent);
2224 auto target = retrieve<dcon::nation_id>(
state, parent);
2226 if (leftcolumnlogics[i]) {
2233 return tooltip_behavior::variable_tooltip;
2237 auto i = retrieve<int16_t>(
state, parent);
2238 auto target = retrieve<dcon::nation_id>(
state, parent);
2240 if(leftcolumnlogics[i]) {
2246 void render(
sys::state&
state, int32_t x, int32_t y)
noexcept override {
2247 auto i = retrieve<int16_t>(
state, parent);
2249 if(leftcolumnlogics[i])
2250 button_element_base::render(
state, x, y);
2257 auto i = retrieve<int16_t>(
state, parent);
2258 auto target = retrieve<dcon::nation_id>(
state, parent);
2262 base_data.data.button.txt = curlogic->
get_name(
state, target);
2264 button_element_base::on_reset_text(
state);
2269 auto i = retrieve<int16_t>(
state, parent);
2270 auto target = retrieve<dcon::nation_id>(
state, parent);
2279 return tooltip_behavior::variable_tooltip;
2283 auto i = retrieve<int16_t>(
state, parent);
2284 auto target = retrieve<dcon::nation_id>(
state, parent);
2292 void render(
sys::state&
state, int32_t x, int32_t y)
noexcept override {
2293 auto i = retrieve<int16_t>(
state, parent);
2296 button_element_base::render(
state, x, y);
2302 template<
typename T>
2304 auto ptr = make_element_by_type<T>(
state,
state.ui_state.
defs_by_name.find(
state.lookup_key(
"diplomacy_option"))->second.definition);
2305 ptr->base_data.position = offset;
2311 auto i = retrieve<int16_t>(
state, parent);
2316 if(
name ==
"action_option_1") {
2317 return add_action_button<diplomacy_action_window<diplomacy_action_btn_left>>(
state, options_offset);
2318 }
else if(
name ==
"action_option_2") {
2320 options_offset.
x += options_size.
x;
2321 return add_action_button<diplomacy_action_window<diplomacy_action_btn_right>>(
state, options_offset);
2331 return "diplomacy_actions_list_entry";
2337 row_contents.clear();
2340 row_contents.push_back(i);
2364 std::vector<diplomacy_greatpower_info*> gp_infos{};
2366 dcon::nation_id facts_nation_id{};
2374 generic_tabbed_window::on_create(
state);
2379 xy_pair gp_info_offset = base_gp_info_offset;
2381 auto ptr = make_element_by_type<diplomacy_greatpower_info>(
state,
2383 ptr->base_data.position = gp_info_offset;
2386 gp_info_offset.
y += ptr->base_data.size.y;
2387 if(i + 1 ==
uint8_t(
state.defines.great_nations_count) / 2) {
2388 gp_info_offset.
y = base_gp_info_offset.
y;
2389 gp_info_offset.
x += (ptr->base_data.size.x / 2) + 62;
2391 gp_infos.push_back(ptr.get());
2392 add_child_to_front(std::move(ptr));
2400 auto ptr = make_element_by_type<diplo_actions_listbox>(
state,
state.ui_state.
defs_by_name.find(
state.lookup_key(
"diplomacy_actions_list"))->second.definition);
2401 ptr->base_data.position = options_base_offset;
2402 add_child_to_front(std::move(ptr));
2404 auto new_win1 = make_element_by_type<diplomacy_action_dialog_window>(
state,
2406 new_win1->set_visible(
state,
false);
2407 action_dialog_win = new_win1.
get();
2408 add_child_to_front(std::move(new_win1));
2410 auto new_win2 = make_element_by_type<diplomacy_gp_action_dialog_window>(
state,
2412 new_win2->set_visible(
state,
false);
2413 gp_action_dialog_win = new_win2.
get();
2414 add_child_to_front(std::move(new_win2));
2416 auto new_win3 = make_element_by_type<diplomacy_declare_war_dialog>(
state,
2418 new_win3->set_visible(
state,
false);
2419 declare_war_win = new_win3.
get();
2420 add_child_to_front(std::move(new_win3));
2423 auto new_winc = make_element_by_type<offer_war_goal_dialog>(
state,
2425 new_winc->set_visible(
state,
false);
2426 offer_goal_win = new_winc.
get();
2427 add_child_to_front(std::move(new_winc));
2430 auto new_win4 = make_element_by_type<diplomacy_setup_peace_dialog>(
state,
2432 new_win4->set_visible(
state,
false);
2433 setup_peace_win = new_win4.
get();
2434 add_child_to_front(std::move(new_win4));
2436 auto new_win5 = make_element_by_type<diplomacy_make_cb_window>(
state,
2438 new_win5->set_visible(
state,
false);
2439 make_cb_win = new_win5.
get();
2440 add_child_to_front(std::move(new_win5));
2442 auto new_win6 = make_element_by_type<crisis_resolution_dialog>(
state,
2444 new_win6->set_visible(
state,
false);
2445 crisis_backdown_win = new_win6.
get();
2446 add_child_to_front(std::move(new_win6));
2448 auto new_winc7 = make_element_by_type<crisis_add_wargoal_window>(
state,
2450 new_winc7->set_visible(
state,
false);
2451 crisis_add_wargoal_win = new_winc7.
get();
2452 add_child_to_front(std::move(new_winc7));
2454 if(
state.great_nations.size() > 1) {
2456 impl_get(
state, payload);
2459 set_visible(
state,
false);
2464 send<diplomacy_window_tab>(
state,
this, diplomacy_window_tab::great_powers);
2469 if(
name ==
"main_bg") {
2470 return make_element_by_type<image_element_base>(
state,
id);
2471 }
else if(
name ==
"bg_diplomacy") {
2472 return make_element_by_type<opaque_element_base>(
state,
id);
2473 }
else if(
name ==
"close_button") {
2474 return make_element_by_type<generic_close_button>(
state,
id);
2475 }
else if(
name ==
"gp_info") {
2476 auto ptr = make_element_by_type<generic_tab_button<diplomacy_window_tab>>(
state, id);
2477 ptr->target = diplomacy_window_tab::great_powers;
2479 }
else if(
name ==
"gp_info_text") {
2480 return make_element_by_type<gp_tab_text>(
state,
id);
2481 }
else if(
name ==
"war_info") {
2482 auto ptr = make_element_by_type<generic_tab_button<diplomacy_window_tab>>(
state, id);
2483 ptr->target = diplomacy_window_tab::wars;
2485 }
else if(
name ==
"cb_info") {
2486 auto ptr = make_element_by_type<generic_tab_button<diplomacy_window_tab>>(
state, id);
2487 ptr->target = diplomacy_window_tab::casus_belli;
2489 }
else if(
name ==
"crisis_info") {
2490 return make_element_by_type<crisis_tab_button>(
state,
id);
2491 }
else if(
name ==
"filter_all") {
2492 return make_element_by_type<category_filter_button<country_list_filter::all>>(
state, id);
2493 }
else if(
name ==
"filter_enemies") {
2494 return make_element_by_type<category_filter_button<country_list_filter::enemies>>(
state, id);
2495 }
else if(
name ==
"filter_allies") {
2496 return make_element_by_type<category_filter_button<country_list_filter::allies>>(
state, id);
2497 }
else if(
name ==
"filter_neighbours") {
2498 return make_element_by_type<category_filter_button<country_list_filter::neighbors>>(
state, id);
2499 }
else if(
name ==
"filter_sphere") {
2500 return make_element_by_type<category_filter_button<country_list_filter::sphere>>(
state, id);
2501 }
else if(
name ==
"cb_info_win") {
2502 auto ptr = make_element_by_type<diplomacy_casus_belli_window>(
state,
id);
2504 casus_belli_window = ptr.
get();
2505 ptr->set_visible(
state,
false);
2507 }
else if(
name ==
"crisis_info_win") {
2508 auto ptr = make_element_by_type<diplomacy_crisis_info_window>(
state,
id);
2509 crisis_window = ptr.
get();
2510 ptr->set_visible(
state,
false);
2512 }
else if(
name ==
"country_listbox") {
2513 auto ptr = make_element_by_type<diplomacy_country_listbox>(
state,
id);
2514 country_listbox = ptr.
get();
2516 }
else if(
name ==
"war_listbox") {
2517 auto ptr = make_element_by_type<diplomacy_war_listbox>(
state,
id);
2518 war_listbox = ptr.
get();
2521 }
else if(
name ==
"diplomacy_country_facts") {
2522 auto ptr = make_element_by_type<diplomacy_country_facts>(
state,
id);
2523 country_facts = ptr.
get();
2525 }
else if(
name ==
"sort_by_country") {
2526 auto ptr = make_element_by_type<country_sort_button<country_list_sort::country>>(
state, id);
2528 }
else if(
name ==
"sort_by_boss") {
2529 auto ptr = make_element_by_type<country_sort_button<country_list_sort::boss>>(
state, id);
2530 ptr->base_data.position.y -= 1;
2532 }
else if(
name ==
"sort_by_prestige") {
2533 auto ptr = make_element_by_type<country_sort_button<country_list_sort::prestige_rank>>(
state, id);
2534 ptr->base_data.position.y -= 1;
2536 }
else if(
name ==
"sort_by_economic") {
2537 auto ptr = make_element_by_type<country_sort_button<country_list_sort::economic_rank>>(
state, id);
2538 ptr->base_data.position.y -= 1;
2540 }
else if(
name ==
"sort_by_military") {
2541 auto ptr = make_element_by_type<country_sort_button<country_list_sort::military_rank>>(
state, id);
2542 ptr->base_data.position.y -= 1;
2544 }
else if(
name ==
"sort_by_total") {
2545 auto ptr = make_element_by_type<country_sort_button<country_list_sort::total_rank>>(
state, id);
2546 ptr->base_data.position.y -= 1;
2548 }
else if(
name ==
"sort_by_relation") {
2549 auto ptr = make_element_by_type<country_sort_button<country_list_sort::relation>>(
state, id);
2550 ptr->base_data.position.y -= 1;
2552 }
else if(
name ==
"sort_by_opinion") {
2553 return make_element_by_type<country_sort_button<country_list_sort::opinion>>(
state, id);
2554 }
else if(
name ==
"sort_by_prio") {
2555 return make_element_by_type<country_sort_button<country_list_sort::priority>>(
state, id);
2556 }
else if(
name.substr(0, 14) ==
"sort_by_gpflag") {
2557 auto ptr = make_element_by_type<diplomacy_sort_nation_gp_flag>(
state,
id);
2558 ptr->rank = uint16_t(std::stoi(std::string{
name.substr(14)}));
2559 ptr->base_data.position.y -= 2;
2561 }
else if(
name.substr(0, 10) ==
"sort_by_gp") {
2562 auto ptr = make_element_by_type<country_sort_button<country_list_sort::gp_influence>>(
state, id);
2563 ptr->offset =
uint8_t(std::stoi(std::string{
name.substr(10)}));
2564 ptr->base_data.position.y -= 2;
2566 }
else if(
name.length() >= 7 &&
name.substr(0, 7) ==
"filter_") {
2567 auto const filter_name =
name.substr(7);
2568 auto ptr = make_element_by_type<continent_filter_button>(
state,
id);
2569 auto k =
state.lookup_key(filter_name);
2571 for(
auto m :
state.world.in_modifier) {
2572 if(m.get_name() == k) {
2588 for(
auto e : gp_infos)
2589 e->set_visible(
state,
false);
2604 auto enum_val = any_cast<diplomacy_window_tab>(payload);
2607 case diplomacy_window_tab::great_powers:
2608 for(
auto e : gp_infos)
2609 e->set_visible(
state,
true);
2611 case diplomacy_window_tab::wars:
2614 case diplomacy_window_tab::casus_belli:
2617 case diplomacy_window_tab::crisis:
2623 active_tab = enum_val;
2625 return message_result::consumed;
2628 return message_result::consumed;
2631 return message_result::consumed;
2634 return message_result::consumed;
2636 auto new_sort = any_cast<element_selection_wrapper<country_list_sort>>(payload).data;
2638 sort.
sort = new_sort;
2640 return message_result::consumed;
2642 auto temp = any_cast<country_list_filter>(payload);
2643 filter.general_category = filter.general_category !=
temp ?
temp : country_list_filter::all;
2645 return message_result::consumed;
2646 }
else if(payload.holds_type<dcon::modifier_id>()) {
2647 auto temp_c = any_cast<dcon::modifier_id>(payload);
2648 filter.continent = filter.continent == temp_c ? dcon::modifier_id{} : temp_c;
2650 return message_result::consumed;
2651 }
else if(payload.holds_type<dcon::nation_id>()) {
2652 payload.emplace<dcon::nation_id>(facts_nation_id);
2653 return message_result::consumed;
2655 facts_nation_id = any_cast<element_selection_wrapper<dcon::nation_id>>(payload).data;
2657 impl_on_update(
state);
2658 return message_result::consumed;
2660 auto offer_to = any_cast<open_offer_window>(payload).to;
2667 auto action = any_cast<trigger_gp_choice>(payload).action;
2681 auto v = any_cast<diplomacy_action>(payload);
2688 Cyto::Any new_payload = facts_nation_id;
2691 case diplomacy_action::add_to_sphere:
2694 case diplomacy_action::military_access:
2697 case diplomacy_action::cancel_military_access:
2700 case diplomacy_action::give_military_access:
2703 case diplomacy_action::cancel_give_military_access:
2706 case diplomacy_action::increase_relations:
2709 case diplomacy_action::decrease_relations:
2712 case diplomacy_action::war_subsidies:
2715 case diplomacy_action::cancel_war_subsidies:
2718 case diplomacy_action::ally:
2721 case diplomacy_action::cancel_ally:
2724 case diplomacy_action::call_ally:
2725 for(
auto war_par : fat.get_war_participant()) {
2730 case diplomacy_action::remove_from_sphere:
2736 case diplomacy_action::declare_war:
2737 case diplomacy_action::add_wargoal:
2743 case diplomacy_action::make_peace:
2750 case diplomacy_action::justify_war:
2756 case diplomacy_action::crisis_backdown:
2761 case diplomacy_action::crisis_support:
2763 case diplomacy_action::crisis_add_wargoal:
2775 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
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
void reset_window(sys::state &state)
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::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::unique_ptr< T > add_action_button(sys::state &state, xy_pair offset) noexcept
virtual dcon::text_key get_name(sys::state &state, dcon::nation_id target)
virtual void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents, dcon::nation_id target)
virtual bool is_available(sys::state &state, dcon::nation_id target)
virtual void button_action(sys::state &state, dcon::nation_id target, ui::element_base *parent)
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
void select_state(sys::state &state)
bool wargoal_decided_upon
void reset_window(sys::state &state)
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_fabricate_cb(sys::state &state, dcon::nation_id source, dcon::nation_id target, dcon::cb_type_id type, dcon::state_definition_id target_state)
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_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)
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)
float truce_break_cb_infamy(sys::state &state, dcon::cb_type_id t, dcon::nation_id target, dcon::state_definition_id cb_state)
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)
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 cb_infamy(sys::state &state, dcon::cb_type_id t, dcon::nation_id target, dcon::state_definition_id cb_state)
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)
bool war_goal_would_be_duplicate(sys::state &state, dcon::nation_id source, dcon::war_id w, dcon::nation_id target, dcon::cb_type_id cb_type, dcon::state_definition_id cb_state, dcon::national_identity_id cb_tag, dcon::nation_id cb_secondary_nation)
bool cb_requires_selection_of_a_state(sys::state const &state, dcon::cb_type_id t)
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)
diplomacy_action_btn_logic * rightcolumnlogics[DiplomaticActionsRows]
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)
const int DiplomaticActionsRows
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)
std::vector< dcon::state_definition_id > selectable_states
std::function< void(sys::state &, dcon::state_definition_id)> on_select
std::function< void(sys::state &)> on_cancel
Holds important data about the game world, state, and other data regarding windowing,...
ui::diplomacy_window_tab tab
ankerl::unordered_dense::map< dcon::text_key, element_target, hash_text_key > defs_by_name
element_base * diplomacy_subwindow