6#include "dcon_generated.hpp"
28 auto nat_val =
state.world.nation_get_national_value(nation_id);
29 return nat_val.get_icon();
37 auto nation_id = retrieve<dcon::nation_id>(
state,
parent);
39 if(
auto name = fat_id.get_national_value().get_name();
state.key_is_localized(
name)) {
44 auto mod_id = fat_id.get_national_value().id;
59 auto plurality =
state.world.nation_get_plurality(nation_id);
60 return std::to_string(int32_t(plurality)) +
'%';
87 auto revanchism =
state.world.nation_get_revanchism(nation_id);
88 return std::to_string(int32_t(revanchism * 100.0f)) +
'%';
112 if(
name ==
"ideology_icon") {
113 return make_element_by_type<ideology_plupp>(
state,
id);
114 }
else if(
name ==
"ideology_name") {
115 return make_element_by_type<generic_name_text<dcon::ideology_id>>(
state, id);
116 }
else if(
name ==
"ideology_perc") {
117 return make_element_by_type<nation_ideology_percentage_text>(
state,
id);
138 return "ideology_option_window";
144 state.world.for_each_ideology([&](dcon::ideology_id ideology_id) {
145 if(
state.world.nation_get_upper_house(
state.local_player_nation, ideology_id) > 0.f)
154 auto option = retrieve<dcon::issue_option_id>(
state,
parent);
161 auto option = retrieve<dcon::issue_option_id>(
state,
parent);
169 if(
name ==
"issue_group") {
170 return make_element_by_type<generic_name_text<dcon::issue_id>>(
state, id);
171 }
else if(
name ==
"issue_name") {
172 return make_element_by_type<issue_option_text>(
state,
id);
179 if(payload.holds_type<dcon::issue_id>()) {
180 payload.emplace<dcon::issue_id>(
state.world.issue_option_get_parent_issue(
content).id);
190 return "party_issue_option_window";
195 auto party = retrieve<dcon::political_party_id>(
state,
parent);
197 for(
auto& issue :
state.culture_definitions.party_issues) {
198 auto issue_option =
state.world.political_party_get_party_issues(party, issue);
211 auto political_party_id = retrieve<dcon::political_party_id>(
state,
parent);
220 auto political_party_id = retrieve<dcon::political_party_id>(
state,
parent);
239 auto party = retrieve<dcon::political_party_id>(
state,
parent);
250 for(
auto pi :
state.culture_definitions.party_issues) {
255 if(
state.world.political_party_get_trigger(party)) {
269 if(
name ==
"party_name") {
270 return make_element_by_type<politics_choose_party_button>(
state,
id);
271 }
else if(
name ==
"party_icon") {
272 return make_element_by_type<ideology_plupp>(
state,
id);
273 }
else if(
name ==
"issue_listbox") {
274 return make_element_by_type<politics_party_issues_listbox>(
state,
id);
281 if(payload.holds_type<dcon::ideology_id>()) {
282 payload.emplace<dcon::ideology_id>(
state.world.political_party_get_ideology(
content));
292 return "party_window";
310 if(
name ==
"all_party_window_close") {
311 return make_element_by_type<generic_close_button>(
state,
id);
312 }
else if(
name ==
"party_listbox") {
313 return make_element_by_type<politics_all_party_listbox>(
state,
id);
326 auto party =
state.world.nation_get_ruling_party(
state.local_player_nation);
331 if(all_party_window ==
nullptr) {
332 auto ptr = make_element_by_type<politics_all_party_window>(
state,
"all_party_window");
338 if(all_party_window && all_party_window->
is_visible()) {
358 for(
auto pi :
state.culture_definitions.party_issues) {
373 if(
name ==
"politics_selectparty_entrybg") {
374 return make_element_by_type<invisible_element>(
state,
id);
375 }
else if(
name ==
"party_name") {
376 return make_element_by_type<politics_change_party_button>(
state,
id);
377 }
else if(
name ==
"party_icon") {
378 return make_element_by_type<nation_ruling_party_ideology_plupp>(
state,
id);
379 }
else if(
name ==
"issue_listbox") {
380 return make_element_by_type<politics_party_issues_listbox>(
state,
id);
387 if(payload.holds_type<dcon::political_party_id>()) {
388 payload.emplace<dcon::political_party_id>(
state.world.nation_get_ruling_party(
state.local_player_nation));
430 auto content = retrieve<dcon::issue_option_id>(
state,
parent);
452 if(
name ==
"issue_name") {
453 return make_element_by_type<generic_name_text<dcon::issue_option_id>>(
state, id);
454 }
else if(
name ==
"people_perc") {
455 return make_element_by_type<issue_option_popular_support>(
state,
id);
456 }
else if(
name ==
"voters_perc") {
457 return make_element_by_type<issue_option_voter_support>(
state,
id);
467 return "issue_option_window";
472 state.world.for_each_issue_option([&](dcon::issue_option_id io_id) {
row_contents.push_back(io_id); });
522 if(
name ==
"country_modifier_icon") {
523 return make_element_by_type<national_modifier_icon>(
state,
id);
542 return "country_modifier_item";
545 subwindow.
mod = content;
550 for(
auto mods :
state.world.nation_get_current_modifiers(
state.local_player_nation)) {
554 for(
auto tm :
state.national_definitions.triggered_modifiers) {
555 if(tm.trigger_condition && tm.linked_modifier) {
556 auto trigger_condition_satisfied =
558 if(trigger_condition_satisfied)
585 dcon::nation_id release_nation_id{};
591 auto ptr = make_element_by_type<politics_ruling_party_window>(
state,
"party_window");
595 auto ptr = make_element_by_type<politics_release_nation_window>(
state,
"releaseconfirm");
596 release_win = ptr.
get();
602 if(
name ==
"main_bg") {
603 return make_element_by_type<image_element_base>(
state,
id);
604 }
else if(
name ==
"bg_politics") {
605 return make_element_by_type<opaque_element_base>(
state,
id);
606 }
else if(
name ==
"close_button") {
607 return make_element_by_type<generic_close_button>(
state,
id);
608 }
else if(
name ==
"reforms_tab") {
609 auto ptr = make_element_by_type<generic_tab_button<politics_window_tab>>(
state, id);
612 }
else if(
name ==
"movements_tab") {
613 auto ptr = make_element_by_type<generic_tab_button<politics_window_tab>>(
state, id);
616 }
else if(
name ==
"decisions_tab") {
617 auto ptr = make_element_by_type<generic_tab_button<politics_window_tab>>(
state, id);
620 }
else if(
name ==
"release_nations_tab") {
621 auto ptr = make_element_by_type<generic_tab_button<politics_window_tab>>(
state, id);
624 }
else if(
name ==
"reforms_window") {
625 auto ptr = make_element_by_type<reforms_window>(
state,
id);
626 reforms_win = ptr.
get();
627 ptr->set_visible(
state,
true);
629 }
else if(
name ==
"movements_window") {
630 auto ptr = make_element_by_type<movements_window>(
state,
id);
631 movements_win = ptr.
get();
632 ptr->set_visible(
state,
false);
634 }
else if(
name ==
"decision_window") {
635 auto ptr = make_element_by_type<decision_window>(
state,
id);
636 decision_win = ptr.
get();
637 ptr->set_visible(
state,
false);
639 }
else if(
name ==
"release_nation") {
640 auto ptr = make_element_by_type<release_nation_window>(
state,
id);
641 release_nation_win = ptr.
get();
642 ptr->set_visible(
state,
false);
644 }
else if(
name ==
"unciv_reforms_window") {
645 auto ptr = make_element_by_type<unciv_reforms_window>(
state,
id);
646 unciv_reforms_win = ptr.
get();
647 ptr->set_visible(
state,
false);
649 }
else if(
name ==
"country_modifier_overlappingbox") {
650 return make_element_by_type<national_modifiers>(
state,
id);
651 }
else if(
name ==
"government_name") {
652 return make_element_by_type<nation_government_type_text>(
state,
id);
653 }
else if(
name ==
"government_desc") {
654 return make_element_by_type<nation_government_description_text>(
state,
id);
655 }
else if(
name ==
"national_value") {
656 return make_element_by_type<nation_national_value_icon>(
state,
id);
657 }
else if(
name ==
"plurality_value") {
658 return make_element_by_type<nation_plurality_text>(
state,
id);
659 }
else if(
name ==
"revanchism_value") {
660 return make_element_by_type<nation_revanchism_text>(
state,
id);
661 }
else if(
name ==
"can_do_social_reforms") {
662 return make_element_by_type<nation_can_do_social_reform_text>(
state,
id);
663 }
else if(
name ==
"social_reforms_bock") {
664 return make_element_by_type<nation_can_do_social_reform_icon>(
state,
id);
665 }
else if(
name ==
"can_do_political_reforms") {
666 return make_element_by_type<nation_can_do_political_reform_text>(
state,
id);
667 }
else if(
name ==
"political_reforms_bock") {
668 return make_element_by_type<nation_can_do_political_reform_icon>(
state,
id);
669 }
else if(
name ==
"chart_upper_house") {
670 return make_element_by_type<upper_house_piechart>(
state,
id);
671 }
else if(
name ==
"chart_voters_ideologies") {
672 return make_element_by_type<voter_ideology_piechart>(
state,
id);
673 }
else if(
name ==
"chart_people_ideologies") {
674 return make_element_by_type<ideology_piechart<dcon::nation_id>>(
state, id);
675 }
else if(
name ==
"upperhouse_ideology_listbox") {
676 return make_element_by_type<politics_upper_house_listbox>(
state,
id);
677 }
else if(
name ==
"unciv_overlay") {
678 return make_element_by_type<politics_unciv_overlay>(
state,
id);
679 }
else if(
name ==
"hold_election") {
680 return make_element_by_type<politics_hold_election_button>(
state,
id);
681 }
else if(
name ==
"issue_listbox") {
682 auto ptr = make_element_by_type<politics_issue_support_listbox>(
state,
id);
683 issues_listbox = ptr.
get();
685 }
else if(
name ==
"sort_by_issue_name") {
686 auto ptr = make_element_by_type<politics_issue_sort_button>(
state,
id);
689 }
else if(
name ==
"sort_by_people") {
690 auto ptr = make_element_by_type<politics_issue_sort_button>(
state,
id);
693 }
else if(
name ==
"sort_by_voters") {
694 auto ptr = make_element_by_type<politics_issue_sort_button>(
state,
id);
702 if(
state.world.nation_get_is_civilized(
state.local_player_nation) && unciv_reforms_win->
is_visible()) {
705 }
else if(!
state.world.nation_get_is_civilized(
state.local_player_nation) && reforms_win->
is_visible()) {
721 auto enum_val = any_cast<politics_window_tab>(payload);
725 if(
state.world.nation_get_is_civilized(
state.local_player_nation)) {
745 }
else if(payload.holds_type<dcon::nation_id>()) {
746 payload.emplace<dcon::nation_id>(
state.local_player_nation);
749 payload.emplace<dcon::nation_id>(release_nation_id);
752 release_nation_id = any_cast<release_emplace_wrapper>(payload).content;
757 auto enum_val = any_cast<politics_issue_sort_order>(payload);
761 [&](dcon::issue_option_id a, dcon::issue_option_id b) {
762 auto a_name = text::get_name_as_string(state, dcon::fatten(state.world, a));
763 auto b_name = text::get_name_as_string(state, dcon::fatten(state.world, b));
764 return a_name < b_name;
770 [&](dcon::issue_option_id a, dcon::issue_option_id b) {
771 auto a_support = politics::get_popular_support(state, state.local_player_nation, a);
772 auto b_support = politics::get_popular_support(state, state.local_player_nation, b);
773 return a_support > b_support;
779 [&](dcon::issue_option_id a, dcon::issue_option_id b) {
780 auto a_support = politics::get_voter_support(state, state.local_player_nation, a);
781 auto b_support = politics::get_voter_support(state, state.local_player_nation, b);
782 return a_support > b_support;
void add_child_to_front(std::unique_ptr< element_base > child) noexcept final
void move_child_to_front(element_base *child) noexcept final
void impl_on_update(sys::state &state) noexcept override
virtual message_result get(sys::state &state, Cyto::Any &payload) noexcept
virtual void add_child_to_front(std::unique_ptr< element_base > child) noexcept
virtual void on_create(sys::state &state) noexcept
void set_visible(sys::state &state, bool vis)
politics_window_tab active_tab
std::string get_text(sys::state &state, dcon::issue_option_id issue_option_id) noexcept override
std::string get_text(sys::state &state, dcon::issue_option_id issue_option_id) noexcept override
std::vector< dcon::ideology_id > row_contents
void update(sys::state &state)
void on_create(sys::state &state) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
dcon::issue_option_id content
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
void populate_layout(sys::state &state, text::endless_layout &contents, dcon::nation_id nation_id) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
int32_t get_icon_frame(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
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
tooltip_behavior has_tooltip(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
std::string get_text(sys::state &state, dcon::nation_id nation_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
bool get_horizontal_flip(sys::state &state) noexcept override
void on_update(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
std::string_view get_row_element_name() override
void update_subwindow(sys::state &state, national_modifier_win &subwindow, sys::dated_modifier content) override
void on_update(sys::state &state) noexcept override
std::vector< sys::dated_modifier > row_contents
void update(sys::state &state)
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
std::string_view get_row_element_name() 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_update(sys::state &state) noexcept override
void button_action(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::string_view get_row_element_name() 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::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
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
int32_t get_icon_frame(sys::state &state, dcon::nation_id nation_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::string_view get_row_element_name() override
void on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void hide_sub_windows(sys::state &state)
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 set_text(sys::state &state, std::string const &new_text)
virtual std::string get_text(sys::state &state, dcon::issue_option_id issue_option_id) noexcept
void on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
bool can_appoint_ruling_party(sys::state &state, dcon::nation_id source, dcon::political_party_id p)
bool can_start_election(sys::state &state, dcon::nation_id source)
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
constexpr dcon::demographics_key total(0)
constexpr dcon::demographics_key consciousness(3)
void get_active_political_parties(sys::state &state, dcon::nation_id n, std::vector< dcon::political_party_id > &parties)
float get_voter_support(sys::state &state, dcon::nation_id nation, dcon::issue_option_id issue_option)
sys::date next_election_date(sys::state &state, dcon::nation_id nation)
bool can_appoint_ruling_party(sys::state &state, dcon::nation_id nation)
float get_popular_support(sys::state &state, dcon::nation_id nation, dcon::issue_option_id issue_option)
bool has_elections(sys::state &state, dcon::nation_id nation)
bool is_election_ongoing(sys::state &state, dcon::nation_id nation)
void add_line_break_to_layout_box(sys::state &state, layout_base &dest, layout_box &box)
void add_to_layout_box(sys::state &state, layout_base &dest, layout_box &box, embedded_flag ico)
layout_box open_layout_box(layout_base &dest, int32_t indent)
std::string date_to_string(sys::state &state, sys::date date)
void localised_single_sub_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view key, variable_type subkey, substitution value)
void localised_format_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view key, text::substitution_map const &sub)
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
void add_line_break_to_layout(sys::state &state, columnar_layout &dest)
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
std::string format_percentage(float num, size_t digits)
void add_space_to_layout_box(sys::state &state, layout_base &dest, layout_box &box)
void close_layout_box(columnar_layout &dest, layout_box &box)
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 modifier_description(sys::state &state, text::layout_base &layout, dcon::modifier_id mid, int32_t indentation=0)
void reform_description(sys::state &state, text::columnar_layout &contents, dcon::issue_option_id ref)
politics_issue_sort_order
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)
ankerl::unordered_dense::map< dcon::text_key, element_target, hash_text_key > defs_by_name