11 return state.world.nation_get_identity_from_identity_holder(
state.primary_crisis_attacker);
21 auto first_wg =
state.crisis_attacker_wargoals.at(0);
22 if(first_wg.cb ==
state.military_definitions.crisis_colony) {
23 auto colonizers =
state.world.state_definition_get_colonization(first_wg.state);
24 if(colonizers.begin() != colonizers.end()) {
25 auto attacking_colonizer = (*colonizers.begin()).get_colonizer();
26 return state.world.nation_get_identity_from_identity_holder(attacking_colonizer);
28 }
else if(first_wg.cb ==
state.military_definitions.liberate) {
29 return first_wg.wg_tag;
31 return dcon::national_identity_id{};
35 auto first_wg =
state.crisis_attacker_wargoals.at(0);
36 if(first_wg.cb ==
state.military_definitions.crisis_colony) {
37 auto colonizers =
state.world.state_definition_get_colonization(first_wg.state);
38 if(colonizers.begin() != colonizers.end()) {
39 auto attacking_colonizer = (*colonizers.begin()).get_colonizer();
40 show = attacking_colonizer !=
state.primary_crisis_attacker;
44 }
else if(first_wg.cb ==
state.military_definitions.liberate) {
45 show = first_wg.wg_tag !=
state.world.nation_get_identity_from_identity_holder(
state.primary_crisis_attacker);
81 void render(
sys::state&
state, int32_t x, int32_t y)
noexcept override {
100 for(
auto& i :
state.crisis_participants) {
101 if(i.id ==
state.local_player_nation) {
125 void render(
sys::state&
state, int32_t x, int32_t y)
noexcept override {
144 for(
auto& i :
state.crisis_participants) {
145 if(i.id ==
state.local_player_nation) {
162 show =
state.local_player_nation ==
state.primary_crisis_attacker;
169 void render(
sys::state&
state, int32_t x, int32_t y)
noexcept override {
185 show =
state.local_player_nation ==
state.primary_crisis_defender;
192 void render(
sys::state&
state, int32_t x, int32_t y)
noexcept override {
208 show =
state.local_player_nation ==
state.primary_crisis_attacker;
209 disabled =
state.world.nation_get_diplomatic_points(
state.local_player_nation) < 1.0f;
224 void render(
sys::state&
state, int32_t x, int32_t y)
noexcept override {
240 show =
state.local_player_nation ==
state.primary_crisis_defender;
241 disabled =
state.world.nation_get_diplomatic_points(
state.local_player_nation) < 1.0f;
256 void render(
sys::state&
state, int32_t x, int32_t y)
noexcept override {
271 auto wg_ready = retrieve<check_wg_completion>(
state,
parent).done;
276 auto ni = retrieve<dcon::national_identity_id>(
state,
parent);
279 state.local_player_nation,
280 retrieve<get_target>(state, parent).n,
281 state.world.national_identity_get_nation_from_identity_holder(ni),
283 retrieve<dcon::state_definition_id>(state, parent),
284 retrieve<dcon::cb_type_id>(state, parent)
289 auto ni = retrieve<dcon::national_identity_id>(
state,
parent);
291 state.local_player_nation,
292 retrieve<get_target>(state, parent).n,
293 state.world.national_identity_get_nation_from_identity_holder(ni),
295 retrieve<dcon::state_definition_id>(state, parent),
296 retrieve<dcon::cb_type_id>(state, parent)
306 auto wg_ready = retrieve<check_wg_completion>(
state,
parent).done;
320 dcon::nation_id offer_made_to;
321 dcon::nation_id wargoal_against;
322 dcon::cb_type_id cb_to_use;
323 dcon::state_definition_id target_state;
324 dcon::national_identity_id secondary_tag_identity;
325 dcon::national_identity_id wg_tag;
327 bool wargoal_decided_upon =
false;
333 dcon::nation_id target = wargoal_against;
334 auto actor =
state.local_player_nation;
335 dcon::cb_type_id cb = cb_to_use;
336 auto allowed_substate_regions =
state.world.cb_type_get_allowed_substate_regions(cb);
337 if(allowed_substate_regions) {
338 for(
auto v :
state.world.nation_get_overlord_as_ruler(target)) {
339 if(v.get_subject().get_is_substate()) {
340 auto secondary_tag =
state.world.national_identity_get_nation_from_identity_holder(secondary_tag_identity);
341 for(
auto si :
state.world.nation_get_state_ownership(target)) {
348 si.get_state().get_definition(),
357 auto allowed_states =
state.world.cb_type_get_allowed_states(cb);
358 if(
auto allowed_countries =
state.world.cb_type_get_allowed_countries(cb); allowed_countries) {
359 auto secondary_tag =
state.world.national_identity_get_nation_from_identity_holder(secondary_tag_identity);
360 for(
auto si :
state.world.nation_get_state_ownership(target)) {
367 si.get_state().get_definition(),
374 for(
auto si :
state.world.nation_get_state_ownership(target)) {
375 auto secondary_tag =
state.world.national_identity_get_nation_from_identity_holder(secondary_tag_identity);
383 si.get_state().get_definition(),
393 wargoal_decided_upon =
true;
399 target_state = dcon::state_definition_id{};
405 cb_to_use = dcon::cb_type_id{};
406 wargoal_decided_upon =
false;
413 state.start_state_selection(seldata);
417 wargoal_against = dcon::nation_id{};
418 offer_made_to =
state.local_player_nation;
419 cb_to_use = dcon::cb_type_id{};
420 target_state = dcon::state_definition_id{};
421 secondary_tag_identity = dcon::national_identity_id{};
422 wargoal_decided_upon =
false;
431 if(
name ==
"background") {
432 auto ptr = make_element_by_type<draggable_target>(
state,
id);
435 }
else if(
name ==
"leftshield") {
436 return make_element_by_type<nation_player_flag>(
state,
id);
437 }
else if(
name ==
"rightshield") {
438 return make_element_by_type<flag_button>(
state,
id);
439 }
else if(
name ==
"title") {
440 return make_element_by_type<wargoal_offer_title>(
state,
id);
441 }
else if(
name ==
"description") {
442 return make_element_by_type<wargoal_offer_description1>(
state,
id);
443 }
else if(
name ==
"wargoal_add_effect") {
444 return make_element_by_type<wargoal_offer_add_window>(
state,
id);
445 }
else if(
name ==
"wargoal_success_effect" ||
name ==
"wargoal_failure_effect") {
446 return make_element_by_type<invisible_element>(
state,
id);
447 }
else if(
name ==
"description2") {
448 return make_element_by_type<wargoal_offer_description2>(
state,
id);
449 }
else if(
name ==
"acceptance") {
450 return make_element_by_type<simple_text_element_base>(
state,
id);
451 }
else if(
name ==
"call_allies_checkbox") {
452 return make_element_by_type<invisible_element>(
state,
id);
453 }
if(
name ==
"call_allies_checkbox") {
454 return make_element_by_type<invisible_element>(
state,
id);
455 }
else if(
name ==
"run_conference_checkbox") {
456 return make_element_by_type<invisible_element>(
state,
id);
457 }
else if(
name ==
"agreebutton") {
458 return make_element_by_type<crisis_add_wargoal_confirm_button>(
state,
id);
459 }
else if(
name ==
"declinebutton") {
460 return make_element_by_type<cancel_pick_wg_button>(
state,
id);
461 }
else if(
name ==
"wargoal_setup") {
462 auto ptr = make_element_by_type<wargoal_target_country_select_window>(
state,
id);
463 wargoal_target_win = ptr.
get();
464 ptr->set_visible(
state,
true);
466 }
else if(
name ==
"wargoal_state_select") {
467 return make_element_by_type<invisible_element>(
state,
id);
468 }
else if(
name ==
"wargoal_country_select") {
470 auto ptr = make_element_by_type<wargoal_offer_setup_window>(
state,
id);
471 wargoal_setup_win = ptr.
get();
472 ptr->set_visible(
state,
false);
476 auto ptr = make_element_by_type<wargoal_offer_country_select_window>(
state,
id);
477 wargoal_country_win = ptr.
get();
478 ptr->set_visible(
state,
false);
487 if(payload.holds_type<dcon::nation_id>()) {
488 payload.emplace<dcon::nation_id>(offer_made_to);
497 cb_to_use = any_cast<element_selection_wrapper<dcon::cb_type_id>>(payload).data;
499 wargoal_against = dcon::nation_id{};
500 cb_to_use = dcon::cb_type_id{};
501 target_state = dcon::state_definition_id{};
502 secondary_tag_identity = dcon::national_identity_id{};
503 wargoal_decided_upon =
false;
521 wargoal_decided_upon =
true;
530 secondary_tag_identity = any_cast<element_selection_wrapper<dcon::national_identity_id>>(payload).data;
532 if(secondary_tag_identity) {
544 wargoal_decided_upon =
true;
547 wargoal_decided_upon =
false;
548 cb_to_use = dcon::cb_type_id{};
558 wargoal_against = any_cast<set_target>(payload).n;
559 if(wargoal_against) {
560 wargoal_decided_upon =
false;
561 cb_to_use = dcon::cb_type_id{};
568 }
else if(payload.holds_type<dcon::cb_type_id>()) {
569 payload.emplace<dcon::cb_type_id>(cb_to_use);
571 }
else if(payload.holds_type<dcon::state_definition_id>()) {
572 payload.emplace<dcon::state_definition_id>(target_state);
574 }
else if(payload.holds_type<dcon::national_identity_id>()) {
575 payload.emplace<dcon::national_identity_id>(secondary_tag_identity);
593 for(
uint32_t i = 0; i <
state.crisis_participants.size(); i++) {
594 if(!
state.crisis_participants[i].id)
597 if(
state.crisis_participants[i].supports_attacker && !
state.crisis_participants[i].merely_interested &&
state.crisis_participants[i].id !=
state.primary_crisis_attacker) {
599 row_contents.push_back(content.get_identity_from_identity_holder().id);
616 for(
auto wg :
state.crisis_attacker_wargoals) {
633 if(
name ==
"country_flag") {
634 return make_element_by_type<diplomacy_crisis_attacker_flag>(
state,
id);
635 }
else if(
name ==
"sponsored_flag") {
636 return make_element_by_type<diplomacy_crisis_sponsored_attacker_flag>(
state,
id);
637 }
else if(
name ==
"country_name") {
638 return make_element_by_type<diplomacy_crisis_attacker_name>(
state,
id);
639 }
else if(
name ==
"wargoals") {
640 return make_element_by_type<crisis_attacker_wargoals>(
state,
id);
641 }
else if(
name ==
"backers") {
642 auto ptr = make_element_by_type<diplomacy_crisis_attacker_backers>(
state,
id);
643 ptr->base_data.position.y -= 6;
645 }
else if(
name ==
"support_side") {
646 return make_element_by_type<support_attacker_button>(
state,
id);
647 }
else if(
name ==
"back_down") {
648 return make_element_by_type<propose_defender_solution_button>(
state,
id);
649 }
else if(
name ==
"crisis_add_wg") {
650 return make_element_by_type<attacker_add_wg_button>(
state,
id);
660 return state.world.nation_get_identity_from_identity_holder(
state.primary_crisis_defender);
669 auto first_wg =
state.crisis_attacker_wargoals.at(0);
671 if(first_wg.cb ==
state.military_definitions.crisis_colony) {
672 auto colonizers =
state.world.state_definition_get_colonization(first_wg.state);
673 if(colonizers.end() - colonizers.begin() >= 2) {
674 auto def_colonizer = (*(colonizers.begin() + 1)).get_colonizer();
675 return state.world.nation_get_identity_from_identity_holder(def_colonizer);
677 }
else if(first_wg.cb ==
state.military_definitions.liberate) {
678 return first_wg.wg_tag;
680 return dcon::national_identity_id{};
685 auto first_wg =
state.crisis_attacker_wargoals.at(0);
687 if(first_wg.cb ==
state.military_definitions.crisis_colony) {
688 auto colonizers =
state.world.state_definition_get_colonization(first_wg.state);
689 if(colonizers.end() - colonizers.begin() >= 2) {
690 auto def_colonizer = (*(colonizers.begin() + 1)).get_colonizer();
691 show = def_colonizer !=
state.primary_crisis_defender;
695 }
else if(first_wg.cb ==
state.military_definitions.liberate) {
696 show = first_wg.target_nation !=
state.primary_crisis_defender;
731 for(
uint32_t i = 0; i <
state.crisis_participants.size(); i++) {
732 if(!
state.crisis_participants[i].id)
735 if(!
state.crisis_participants[i].supports_attacker && !
state.crisis_participants[i].merely_interested &&
state.crisis_participants[i].id !=
state.primary_crisis_defender) {
737 row_contents.push_back(content.get_identity_from_identity_holder().id);
755 for(
auto wg :
state.crisis_defender_wargoals) {
779 if(
name ==
"country_flag") {
780 return make_element_by_type<diplomacy_crisis_defender_flag>(
state,
id);
781 }
else if(
name ==
"sponsored_flag") {
782 return make_element_by_type<diplomacy_crisis_sponsored_defender_flag>(
state,
id);
783 }
else if(
name ==
"country_name") {
784 return make_element_by_type<diplomacy_crisis_defender_name>(
state,
id);
785 }
else if(
name ==
"wargoals") {
786 return make_element_by_type<crisis_defender_wargoals>(
state,
id);
787 }
else if(
name ==
"backers") {
788 auto ptr = make_element_by_type<diplomacy_crisis_defender_backers>(
state,
id);
789 ptr->base_data.position.y -= 6;
791 }
else if(
name ==
"support_side") {
792 return make_element_by_type<support_defender_button>(
state,
id);
793 }
else if(
name ==
"back_down") {
794 return make_element_by_type<propose_attacker_solution_button>(
state,
id);
795 }
else if(
name ==
"crisis_add_wg") {
796 return make_element_by_type<defender_add_wg_button>(
state,
id);
806 auto first_wg =
state.crisis_attacker_wargoals.at(0);
814 auto first_wg =
state.crisis_attacker_wargoals.at(0);
815 if (first_wg.cb ==
state.military_definitions.liberate) {
818 if(
state.world.nation_get_owned_province_count(
state.world.national_identity_get_nation_from_identity_holder(first_wg.wg_tag)) > 0) {
824 else if(first_wg.cb ==
state.military_definitions.crisis_colony) {
849 switch(
state.current_crisis_state) {
872 return state.world.nation_get_identity_from_identity_holder(n);
929 if(
name ==
"country_flag") {
930 return make_element_by_type<interested_flag>(
state,
id);
931 }
else if(
name ==
"make_offer") {
932 return make_element_by_type<make_offer_button>(
state,
id);
939 if(payload.holds_type<dcon::nation_id>()) {
942 for(
auto& par:
state.crisis_participants) {
945 if(par.merely_interested) {
953 payload.emplace<dcon::nation_id>(n);
962 for(
auto& par :
state.crisis_participants) {
965 if(par.merely_interested) {
991 if(
name ==
"join_button") {
992 return make_element_by_type<join_crisis_button>(
state,
id);
1000 if(!
state.world.nation_get_is_great_power(
state.local_player_nation))
1025 auto ptr = make_element_by_type<diplomacy_crisis_interested_container>(
state,
state.ui_state.
defs_by_name.find(
state.lookup_key(
"fence_sitter_entry"))->second.definition);
1026 ptr->base_data.position.x = int16_t(0);
1027 ptr->base_data.position.y = int16_t(0);
1032 auto ptr = make_element_by_type<diplomacy_crisis_interested_container>(
state,
state.ui_state.
defs_by_name.find(
state.lookup_key(
"fence_sitter_entry"))->second.definition);
1033 ptr->base_data.position.x = int16_t(70 * 1);
1034 ptr->base_data.position.y = int16_t(0);
1039 auto ptr = make_element_by_type<diplomacy_crisis_interested_container>(
state,
state.ui_state.
defs_by_name.find(
state.lookup_key(
"fence_sitter_entry"))->second.definition);
1040 ptr->base_data.position.x = int16_t(70 * 2);
1041 ptr->base_data.position.y = int16_t(0);
1046 auto ptr = make_element_by_type<diplomacy_crisis_interested_container>(
state,
state.ui_state.
defs_by_name.find(
state.lookup_key(
"fence_sitter_entry"))->second.definition);
1047 ptr->base_data.position.x = int16_t(0);
1048 ptr->base_data.position.y = int16_t(75);
1053 auto ptr = make_element_by_type<diplomacy_crisis_interested_container>(
state,
state.ui_state.
defs_by_name.find(
state.lookup_key(
"fence_sitter_entry"))->second.definition);
1054 ptr->base_data.position.x = int16_t(70 * 1);
1055 ptr->base_data.position.y = int16_t(75);
1060 auto ptr = make_element_by_type<diplomacy_crisis_interested_container>(
state,
state.ui_state.
defs_by_name.find(
state.lookup_key(
"fence_sitter_entry"))->second.definition);
1061 ptr->base_data.position.x = int16_t(70 * 2);
1062 ptr->base_data.position.y = int16_t(75);
1067 auto ptr = make_element_by_type<diplomacy_crisis_join_container>(
state,
state.ui_state.
defs_by_name.find(
state.lookup_key(
"join_fence_sitter_entry"))->second.definition);
1068 ptr->base_data.position.x = int16_t(70 * 2 - 3);
1069 ptr->base_data.position.y = int16_t(58);
1079 if(
name ==
"crisis_title") {
1080 return make_element_by_type<diplomacy_crisis_title_text>(
state,
id);
1081 }
else if(
name ==
"crisis_sub_title") {
1082 return make_element_by_type<diplomacy_crisis_subtitle_text>(
state,
id);
1083 }
else if(
name ==
"crisis_temperature") {
1084 return make_element_by_type<diplomacy_crisis_temperature_bar>(
state,
id);
1085 }
else if(
name ==
"crisis_status_label") {
1086 return make_element_by_type<diplomacy_crisis_status_text>(
state,
id);
1087 }
else if(
name ==
"attacker_win") {
1088 return make_element_by_type<diplomacy_crisis_attacker_window>(
state,
id);
1089 }
else if(
name ==
"defender_win") {
1090 return make_element_by_type<diplomacy_crisis_defender_window>(
state,
id);
1091 }
else if(
name ==
"fence_sitters_win") {
1092 return make_element_by_type< diplomacy_crisis_interested_window>(
state,
id);
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)
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
std::string_view get_row_element_name() override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
std::string_view get_row_element_name() override
void populate_flags(sys::state &state) noexcept override
dcon::national_identity_id get_current_nation(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
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) noexcept override
dcon::national_identity_id get_current_nation(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
std::function< void(generic_callback_button &, sys::state &)> on_add_wg_update
std::function< void(generic_callback_button &, sys::state &)> on_add_wg_action
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
mouse_probe impl_probe_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
void impl_render(sys::state &state, int32_t x, int32_t y) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
void on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
mouse_probe impl_probe_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
void impl_render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
virtual message_result get(sys::state &state, Cyto::Any &payload) noexcept
virtual void impl_render(sys::state &state, int32_t x, int32_t y) noexcept
void set_visible(sys::state &state, bool vis)
virtual mouse_probe impl_probe_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept
dcon::national_identity_id get_current_nation(sys::state &state) noexcept override
std::vector< dcon::national_identity_id > row_contents
void update(sys::state &state)
void set_text(sys::state &state, std::string const &new_text)
void on_create(sys::state &state) noexcept override
void queue_crisis_add_wargoal(sys::state &state, dcon::nation_id source, sys::full_wg wg)
bool can_take_sides_in_crisis(sys::state &state, dcon::nation_id source, bool join_attacker)
bool crisis_can_add_wargoal(sys::state &state, dcon::nation_id source, sys::full_wg wg)
@ become_interested_in_crisis
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
bool cb_requires_selection_of_a_valid_nation(sys::state const &state, dcon::cb_type_id t)
bool cb_requires_selection_of_a_liberatable_tag(sys::state const &state, dcon::cb_type_id t)
bool cb_requires_selection_of_a_state(sys::state const &state, dcon::cb_type_id t)
bool is_committed_in_crisis(sys::state const &state, dcon::nation_id n)
bool is_involved_in_crisis(sys::state const &state, dcon::nation_id n)
std::string resolve_string_substitution(sys::state &state, dcon::text_key source_text, substitution_map const &mp)
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)
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)
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 send(sys::state &state, element_base *parent, T value)
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,...
ankerl::unordered_dense::map< dcon::text_key, element_target, hash_text_key > defs_by_name