10static std::vector<base_event_window*> pending_closure;
13 dcon::nation_id target_nation{};
14 dcon::nation_id from_nation{};
15 dcon::province_id target_province{};
16 dcon::province_id from_province{};
17 dcon::state_instance_id target_state{};
18 dcon::state_instance_id from_state{};
19 dcon::province_id target_capital{};
20 dcon::province_id from_capital{};
21 int32_t target_pop = 0;
24 int32_t from_slot = -1;
27 int32_t primary_slot = -1;
30 if(std::holds_alternative<event::pending_human_n_event>(phe)) {
31 auto const& e = std::get<event::pending_human_n_event>(phe);
34 target_capital =
state.world.nation_get_capital(target_nation);
35 target_province = target_capital;
37 target_state =
state.world.province_get_state_membership(target_province);
41 from_slot = e.from_slot;
43 primary_slot = e.primary_slot;
46 }
else if(std::holds_alternative<event::pending_human_f_n_event>(phe)) {
47 auto const& e = std::get<event::pending_human_f_n_event>(phe);
50 target_capital =
state.world.nation_get_capital(target_nation);
51 target_province = target_capital;
52 target_state =
state.world.province_get_state_membership(target_province);
55 }
else if(std::holds_alternative<event::pending_human_p_event>(phe)) {
56 auto const& e = std::get<event::pending_human_p_event>(phe);
57 target_nation =
state.world.province_get_nation_from_province_ownership(e.p);
58 target_state =
state.world.province_get_state_membership(e.p);
59 target_capital =
state.world.state_instance_get_capital(target_state);
60 target_province = e.p;
63 from_slot = e.from_slot;
66 }
else if(std::holds_alternative<event::pending_human_f_p_event>(phe)) {
67 auto const& e = std::get<event::pending_human_f_p_event>(phe);
68 target_nation =
state.world.province_get_nation_from_province_ownership(e.p);
69 target_state =
state.world.province_get_state_membership(e.p);
70 target_capital =
state.world.state_instance_get_capital(target_state);
71 target_province = e.p;
79 from_capital =
state.world.nation_get_capital(from_nation);
83 from_province =
state.world.state_instance_get_capital(from_state);
87 from_state =
state.world.province_get_state_membership(from_province);
90 from_province =
state.world.nation_get_capital(from_nation);
91 from_state =
state.world.province_get_state_membership(from_province);
97 from_nation =
state.world.state_instance_get_nation_from_state_ownership(from_state);
98 from_capital =
state.world.state_instance_get_capital(from_state);
104 from_province =
state.world.state_instance_get_capital(from_state);
110 from_capital = from_province;
111 from_state =
state.world.province_get_state_membership(from_province);
112 from_nation =
state.world.province_get_nation_from_province_ownership(from_province);
135 auto pc =
state.world.nation_get_primary_culture(target_nation);
140 auto sm =
state.world.nation_get_in_sphere_of(target_nation);
143 auto smpc =
state.world.nation_get_primary_culture(sm);
192 auto first_names =
state.world.culture_get_first_names(
state.world.nation_get_primary_culture(target_nation));
193 if(first_names.size() > 0) {
194 auto first_name = first_names.at(
rng::reduce(
uint32_t(names_pair.high), first_names.size()));
195 auto last_names =
state.world.culture_get_last_names(
state.world.nation_get_primary_culture(target_nation));
196 if(last_names.size() > 0) {
203 if(
auto fl =
state.world.province_get_factory_location_as_province(target_province); fl.begin() != fl.end()) {
216 if(
auto plist =
state.world.nation_get_province_ownership(target_nation); plist.begin() != plist.end()) {
217 auto plist_size =
uint32_t(plist.end() - plist.begin());
225 auto index = retrieve<int32_t>(
state, parent);
229 if(std::holds_alternative<event::pending_human_n_event>(content)) {
230 auto const& phe = std::get<event::pending_human_n_event>(content);
231 opt =
state.world.national_event_get_options(std::get<event::pending_human_n_event>(content).e)[index];
233 }
else if(std::holds_alternative<event::pending_human_f_n_event>(content)) {
234 auto const& phe = std::get<event::pending_human_f_n_event>(content);
235 opt =
state.world.free_national_event_get_options(std::get<event::pending_human_f_n_event>(content).e)[index];
237 }
else if(std::holds_alternative<event::pending_human_p_event>(content)) {
238 auto const& phe = std::get<event::pending_human_p_event>(content);
239 opt =
state.world.provincial_event_get_options(std::get<event::pending_human_p_event>(content).e)[index];
241 }
else if(std::holds_alternative<event::pending_human_f_p_event>(content)) {
242 auto const& phe = std::get<event::pending_human_f_p_event>(content);
243 opt =
state.world.free_provincial_event_get_options(std::get<event::pending_human_f_p_event>(content).e)[index];
252 auto index = retrieve<int32_t>(
state, parent);
254 if(std::holds_alternative<event::pending_human_n_event>(content)) {
255 auto const& phe = std::get<event::pending_human_n_event>(content);
256 state.world.national_event_set_auto_choice(phe.e,
uint8_t(index + 1));
258 }
else if(std::holds_alternative<event::pending_human_f_n_event>(content)) {
259 auto const& phe = std::get<event::pending_human_f_n_event>(content);
260 state.world.free_national_event_set_auto_choice(phe.e,
uint8_t(index + 1));
262 }
else if(std::holds_alternative<event::pending_human_p_event>(content)) {
263 auto const& phe = std::get<event::pending_human_p_event>(content);
264 state.world.provincial_event_set_auto_choice(phe.e,
uint8_t(index + 1));
266 }
else if(std::holds_alternative<event::pending_human_f_p_event>(content)) {
267 auto const& phe = std::get<event::pending_human_f_p_event>(content);
268 state.world.free_provincial_event_set_auto_choice(phe.e,
uint8_t(index + 1));
276 auto index = retrieve<int32_t>(
state, parent);
278 if(std::holds_alternative<event::pending_human_n_event>(content)) {
279 auto const& phe = std::get<event::pending_human_n_event>(content);
285 }
else if(std::holds_alternative<event::pending_human_f_n_event>(content)) {
286 auto const& phe = std::get<event::pending_human_f_n_event>(content);
292 }
else if(std::holds_alternative<event::pending_human_p_event>(content)) {
293 auto const& phe = std::get<event::pending_human_p_event>(content);
299 }
else if(std::holds_alternative<event::pending_human_f_p_event>(content)) {
300 auto const& phe = std::get<event::pending_human_f_p_event>(content);
311 auto index = retrieve<int32_t>(
state, parent);
312 if(std::holds_alternative<event::pending_human_n_event>(content)) {
313 auto phe = std::get<event::pending_human_n_event>(content);
315 }
else if(std::holds_alternative<event::pending_human_f_n_event>(content)) {
316 auto phe = std::get<event::pending_human_f_n_event>(content);
318 }
else if(std::holds_alternative<event::pending_human_p_event>(content)) {
319 auto phe = std::get<event::pending_human_p_event>(content);
321 }
else if(std::holds_alternative<event::pending_human_f_p_event>(content)) {
322 auto phe = std::get<event::pending_human_f_p_event>(content);
330 if(std::holds_alternative<event::pending_human_n_event>(content))
331 base_data.data.image.gfx_object =
state.world.national_event_get_image(std::get<event::pending_human_n_event>(content).e);
332 else if(std::holds_alternative<event::pending_human_f_n_event>(content))
333 base_data.data.image.gfx_object =
state.world.free_national_event_get_image(std::get<event::pending_human_f_n_event>(content).e);
337 base_data.size.y = 200;
338 base_data.size.x -= 11;
348 delegate->base_data.data.text.font_handle, 0, text::alignment::left, delegate->black_text ? text::text_color::black : text::text_color::white, false});
351 dcon::text_key description{};
352 if(std::holds_alternative<event::pending_human_n_event>(content)) {
353 auto phe = std::get<event::pending_human_n_event>(content);
354 description =
state.world.national_event_get_description(phe.e);
356 }
else if(std::holds_alternative<event::pending_human_f_n_event>(content)) {
357 auto phe = std::get<event::pending_human_f_n_event>(content);
358 description =
state.world.free_national_event_get_description(phe.e);
360 }
else if(std::holds_alternative<event::pending_human_p_event>(content)) {
361 auto phe = std::get<event::pending_human_p_event>(content);
362 description =
state.world.provincial_event_get_description(phe.e);
364 }
else if(std::holds_alternative<event::pending_human_f_p_event>(content)) {
365 auto phe = std::get<event::pending_human_f_p_event>(content);
366 description =
state.world.free_provincial_event_get_description(phe.e);
374 if(std::holds_alternative<event::pending_human_n_event>(content)) {
375 auto phe = std::get<event::pending_human_n_event>(content);
376 auto imm =
state.world.national_event_get_immediate_effect(phe.e);
379 for(
auto& l : delegate->internal_layout.contents) {
384 }
else if(std::holds_alternative<event::pending_human_f_n_event>(content)) {
385 auto phe = std::get<event::pending_human_f_n_event>(content);
386 auto imm =
state.world.free_national_event_get_immediate_effect(phe.e);
389 for(
auto& l : delegate->internal_layout.contents) {
394 }
else if(std::holds_alternative<event::pending_human_p_event>(content)) {
395 auto phe = std::get<event::pending_human_p_event>(content);
396 auto imm =
state.world.provincial_event_get_immediate_effect(phe.e);
399 for(
auto& l : delegate->internal_layout.contents) {
404 }
else if(std::holds_alternative<event::pending_human_f_p_event>(content)) {
405 auto phe = std::get<event::pending_human_f_p_event>(content);
406 auto imm =
state.world.free_provincial_event_get_immediate_effect(phe.e);
409 for(
auto& l : delegate->internal_layout.contents) {
416 calibrate_scrollbar(
state);
428 dcon::text_key
name{};
429 if(std::holds_alternative<event::pending_human_n_event>(content)) {
430 auto phe = std::get<event::pending_human_n_event>(content);
431 name =
state.world.national_event_get_name(phe.e);
433 }
else if(std::holds_alternative<event::pending_human_f_n_event>(content)) {
434 auto phe = std::get<event::pending_human_f_n_event>(content);
435 name =
state.world.free_national_event_get_name(phe.e);
437 }
else if(std::holds_alternative<event::pending_human_p_event>(content)) {
438 auto phe = std::get<event::pending_human_p_event>(content);
439 name =
state.world.provincial_event_get_name(phe.e);
441 }
else if(std::holds_alternative<event::pending_human_f_p_event>(content)) {
442 auto phe = std::get<event::pending_human_f_p_event>(content);
443 name =
state.world.free_provincial_event_get_name(phe.e);
458 if(
state.cheat_data.show_province_id_tooltip) {
460 if(std::holds_alternative<event::pending_human_p_event>(content)) {
461 auto phe = std::get<event::pending_human_p_event>(content);
465 }
else if(std::holds_alternative<event::pending_human_n_event>(content)) {
466 auto phe = std::get<event::pending_human_n_event>(content);
470 }
else if(std::holds_alternative<event::pending_human_f_p_event>(content)) {
471 auto phe = std::get<event::pending_human_f_p_event>(content);
475 }
else if(std::holds_alternative<event::pending_human_f_n_event>(content)) {
476 auto phe = std::get<event::pending_human_f_n_event>(content);
488 if(std::holds_alternative<event::pending_human_p_event>(content) || std::holds_alternative<event::pending_human_n_event>(content)) {
492 }
else if(std::holds_alternative<event::pending_human_f_p_event>(content)) {
493 auto phe = std::get<event::pending_human_f_p_event>(content);
496 }
else if(std::holds_alternative<event::pending_human_f_n_event>(content)) {
497 auto phe = std::get<event::pending_human_f_n_event>(content);
510 if(std::holds_alternative<event::pending_human_p_event>(content) || std::holds_alternative<event::pending_human_n_event>(content)) {
514 }
else if(std::holds_alternative<event::pending_human_f_p_event>(content)) {
515 auto phe = std::get<event::pending_human_f_p_event>(content);
516 auto mod =
state.world.free_provincial_event_get_mtth(phe.e);
521 }
else if(std::holds_alternative<event::pending_human_f_n_event>(content)) {
522 auto phe = std::get<event::pending_human_f_n_event>(content);
523 auto mod =
state.world.free_national_event_get_mtth(phe.e);
532 auto iid = retrieve<dcon::issue_id>(
state, parent);
538 if(std::holds_alternative<event::pending_human_n_event>(content)) {
539 auto n =
dcon::fatten(
state.world, std::get<event::pending_human_n_event>(content).n);
541 }
else if(std::holds_alternative<event::pending_human_f_n_event>(content)) {
542 auto n =
dcon::fatten(
state.world, std::get<event::pending_human_f_n_event>(content).n);
544 }
else if(std::holds_alternative<event::pending_human_p_event>(content)) {
545 auto p =
dcon::fatten(
state.world, std::get<event::pending_human_p_event>(content).p);
546 auto n = p.get_nation_from_province_ownership();
548 }
else if(std::holds_alternative<event::pending_human_f_p_event>(content)) {
549 auto p =
dcon::fatten(
state.world, std::get<event::pending_human_f_p_event>(content).p);
550 auto n = p.get_nation_from_province_ownership();
557 if(std::holds_alternative<event::pending_human_n_event>(content)) {
558 auto n =
dcon::fatten(
state.world, std::get<event::pending_human_n_event>(content).n);
560 }
else if(std::holds_alternative<event::pending_human_f_n_event>(content)) {
561 auto n =
dcon::fatten(
state.world, std::get<event::pending_human_f_n_event>(content).n);
563 }
else if(std::holds_alternative<event::pending_human_p_event>(content)) {
564 auto p =
dcon::fatten(
state.world, std::get<event::pending_human_p_event>(content).p);
565 auto n = p.get_nation_from_province_ownership();
567 }
else if(std::holds_alternative<event::pending_human_f_p_event>(content)) {
568 auto p =
dcon::fatten(
state.world, std::get<event::pending_human_f_p_event>(content).p);
569 auto n = p.get_nation_from_province_ownership();
575 row_contents.clear();
577 if(std::holds_alternative<event::pending_human_n_event>(content)) {
578 auto e = std::get<event::pending_human_n_event>(content).e;
582 row_contents.push_back(i);
584 }
else if(std::holds_alternative<event::pending_human_f_n_event>(content)) {
585 auto e = std::get<event::pending_human_f_n_event>(content).e;
589 row_contents.push_back(i);
591 }
else if(std::holds_alternative<event::pending_human_p_event>(content)) {
592 auto e = std::get<event::pending_human_p_event>(content).e;
596 row_contents.push_back(i);
598 }
else if(std::holds_alternative<event::pending_human_f_p_event>(content)) {
599 auto e = std::get<event::pending_human_f_p_event>(content).e;
603 row_contents.push_back(i);
612 move_child_to_front(
image);
617 auto ptr = make_element_by_type<event_requirements_icon>(
state,
state.ui_state.
defs_by_name.find(
state.lookup_key(
"alice_event_requirements"))->second.definition);
618 ptr->base_data.position.y = int16_t(355);
619 ptr->base_data.position.x += int16_t(ptr->base_data.size.x + 140);
620 add_child_to_front(std::move(ptr));
623 auto ptr = make_element_by_type<event_odds_icon>(
state,
state.ui_state.
defs_by_name.find(
state.lookup_key(
"alice_event_odds"))->second.definition);
624 ptr->base_data.position.y = int16_t(355);
625 ptr->base_data.position.x += int16_t(ptr->base_data.size.x * 2 + 140);
626 add_child_to_front(std::move(ptr));
631 auto ptr = make_element_by_type<provincial_event_listbox>(
state,
state.ui_state.
defs_by_name.find(
state.lookup_key(
"alice_povince_event_opts_list"))->second.definition);
632 ptr->base_data.position = cur_offset;
633 ptr->base_data.position.
y -= 150;
634 add_child_to_front(std::move(ptr));
638 auto ptr = make_element_by_type<event_requirements_icon>(
state,
state.ui_state.
defs_by_name.find(
state.lookup_key(
"alice_event_requirements"))->second.definition);
639 ptr->base_data.position.y = 20;
640 ptr->base_data.position.x += ptr->base_data.size.x;
641 add_child_to_front(std::move(ptr));
644 auto ptr = make_element_by_type<event_odds_icon>(
state,
state.ui_state.
defs_by_name.find(
state.lookup_key(
"alice_event_odds"))->second.definition);
645 ptr->base_data.position.y = 20;
646 ptr->base_data.position.x += ptr->base_data.size.x * 2;
647 add_child_to_front(std::move(ptr));
651 auto ptr = make_element_by_type<national_election_event_listbox>(
state,
state.ui_state.
defs_by_name.find(
state.lookup_key(
"alice_election_event_opts_list"))->second.definition);
652 ptr->base_data.position = cur_offset;
653 ptr->base_data.position.
y += 5;
654 add_child_to_front(std::move(ptr));
656 auto ptr = make_element_by_type<national_event_listbox>(
state,
state.ui_state.
defs_by_name.find(
state.lookup_key(
"alice_nation_event_opts_list"))->second.definition);
657 ptr->base_data.position = cur_offset;
658 ptr->base_data.position.
y += 5;
659 add_child_to_front(std::move(ptr));
668 if(std::holds_alternative<event::pending_human_n_event>(content)) {
670 }
else if(std::holds_alternative<event::pending_human_f_n_event>(content)) {
672 }
else if(std::holds_alternative<event::pending_human_p_event>(content)) {
674 }
else if(std::holds_alternative<event::pending_human_f_p_event>(content)) {
683 dcon::gfx_object_id gid;
690 auto& gfx_def =
state.ui_defs.gfx[gid];
692 auto& mask_tex =
state.open_gl.asset_textures[dcon::texture_id(gfx_def.type_dependent - 1)];
695 gfx_def.is_vertically_flipped(),
696 state.world.locale_get_native_rtl(
state.font_collection.get_current_locale()));
708 return state.world.nation_get_identity_from_identity_holder(n);
718 dcon::gfx_object_id gid;
725 auto& gfx_def =
state.ui_defs.gfx[gid];
727 auto& mask_tex =
state.open_gl.asset_textures[dcon::texture_id(gfx_def.type_dependent - 1)];
746 return state.world.nation_get_identity_from_identity_holder(n);
758 if(std::holds_alternative<event::pending_human_p_event>(content)) {
760 }
else if(std::holds_alternative<event::pending_human_f_p_event>(content)) {
767 dcon::province_id prov{};
768 if(std::holds_alternative<event::pending_human_p_event>(content)) {
769 prov = std::get<event::pending_human_p_event>(content).p;
770 }
else if(std::holds_alternative<event::pending_human_f_p_event>(content)) {
771 prov = std::get<event::pending_human_f_p_event>(content).p;
773 if(!prov || prov.value >=
state.province_definitions.first_sea_province.value)
777 state.map_state.set_selected_province(prov);
781 state.map_state.center_map_on_province(
state, prov);
795 if(
name ==
"issue_name") {
796 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
799 }
else if(
name ==
"voters_perc") {
800 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
801 issvalue = ptr.
get();
821 return "ew_issue_option_window";
826 auto content = retrieve<dcon::issue_id>(
state,
parent);
827 state.world.for_each_issue_option([&](dcon::issue_option_id
id) {
829 row_contents.push_back(id);
840 if(
name ==
"legend_color") {
841 return make_element_by_type<ideology_plupp>(
state,
id);
842 }
else if(
name ==
"legend_title") {
843 return make_element_by_type<generic_name_text<dcon::political_party_id>>(
state, id);
844 }
else if(
name ==
"legend_desc") {
845 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
846 ptr->base_data.position.x += 4;
847 partyvalue = ptr.
get();
849 }
else if(
name ==
"legend_value") {
850 return make_element_by_type<invisible_element>(
state,
id);
857 auto issid = retrieve<dcon::issue_id>(
state,
parent);
862 if(payload.holds_type<dcon::ideology_id>()) {
863 payload.emplace<dcon::ideology_id>(
state.world.political_party_get_ideology(
content));
889 if(
name ==
"legend_color") {
890 return make_element_by_type<ideology_plupp>(
state,
id);
891 }
else if(
name ==
"legend_title") {
892 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
895 }
else if(
name ==
"legend_desc") {
896 return make_element_by_type<simple_text_element_base>(
state,
id);
897 }
else if(
name ==
"legend_value") {
898 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
899 ptr->base_data.position.x += 3;
916 if(payload.holds_type<dcon::ideology_id>()) {
917 payload.emplace<dcon::ideology_id>(
state.world.political_party_get_ideology(
content));
955 std::vector<dcon::political_party_id> parties;
957 for(
auto ppid :
state.world.in_political_party) {
960 for(
auto ppid : parties) {
962 distribution[ppid.index()].value +=
state.world.nation_get_demographics(n, dkey) / total;
977 if(
name ==
"issue_name") {
978 return make_element_by_type<generic_name_text<dcon::issue_option_id>>(
state, id);
979 }
else if(
name ==
"people_perc") {
980 return make_element_by_type<issue_option_popular_support>(
state,
id);
981 }
else if(
name ==
"voters_perc") {
982 return make_element_by_type<issue_option_voter_support>(
state,
id);
989 row_contents.clear();
990 auto iid = retrieve<dcon::issue_id>(
state, parent);
991 for(
const auto ioid :
state.world.in_issue_option) {
992 if(ioid.get_parent_issue() == iid)
993 row_contents.push_back(ioid);
999 if(
name ==
"background") {
1000 return make_element_by_type<draggable_target>(
state,
id);
1001 }
else if(
name ==
"title") {
1002 return make_element_by_type<event_name_text>(
state,
id);
1003 }
else if(
name ==
"description") {
1004 return make_element_by_type<event_desc_text>(
state,
id);
1005 }
else if(
name ==
"event_images") {
1006 auto ptr = make_element_by_type<event_image>(
state,
id);
1009 }
else if(
name ==
"event_separator_image") {
1010 auto ptr = make_element_by_type<image_element_base>(
state,
id);
1012 ptr->base_data.position.y = cur_offset.
y;
1013 ptr->base_data.position.y -= 150;
1015 }
else if(
name ==
"date") {
1016 return make_element_by_type<event_date_text>(
state,
id);
1017 }
else if(
name ==
"state_name") {
1018 return make_element_by_type<event_state_name_text>(
state,
id);
1019 }
else if(
name ==
"subtitle") {
1020 return make_element_by_type<event_subtitle_text>(
state,
id);
1021 }
else if(
name ==
"population_amount") {
1022 return make_element_by_type<event_population_amount_text>(
state,
id);
1023 }
else if(
name ==
"country_flag1") {
1024 return make_element_by_type<major_event_left_flag>(
state,
id);
1025 }
else if(
name ==
"country_flag2") {
1026 return make_element_by_type<major_event_right_flag>(
state,
id);
1027 }
else if(
name ==
"province") {
1028 return make_element_by_type<event_province_text>(
state,
id);
1029 }
else if(
name ==
"perc_of_parlament") {
1030 return make_element_by_type<nation_ruling_party_ideology_text>(
state,
id);
1031 }
else if(
name ==
"parties_listbox") {
1032 return make_element_by_type<election_parties_listbox>(
state,
id);
1033 }
else if(
name ==
"chart_ideology") {
1034 return make_element_by_type<election_voter_ideology_piechart>(
state,
id);
1035 }
else if(
name ==
"chart_popularity") {
1036 return make_element_by_type<election_party_popularity_piechart>(
state,
id);
1037 }
else if(
name ==
"popularity_listbox") {
1038 return make_element_by_type<election_popularity_listbox>(
state,
id);
1039 }
else if(
name ==
"sort_by_issue_name") {
1040 auto ptr = make_element_by_type<politics_issue_sort_button>(
state,
id);
1043 }
else if(
name ==
"sort_by_people") {
1044 auto ptr = make_element_by_type<politics_issue_sort_button>(
state,
id);
1047 }
else if(
name ==
"sort_by_voters") {
1048 auto ptr = make_element_by_type<politics_issue_sort_button>(
state,
id);
1051 }
else if(
name ==
"issues_listbox") {
1052 auto ptr = make_element_by_type<elections_issue_option_listbox>(
state,
id);
1053 issues_listbox = ptr.get();
1060 if(payload.holds_type<dcon::nation_id>()) {
1061 payload.emplace<dcon::nation_id>(
state.local_player_nation);
1063 }
else if(payload.holds_type<dcon::issue_id>()) {
1064 if(std::holds_alternative<event::pending_human_n_event>(event_data)) {
1065 auto e = std::get<event::pending_human_n_event>(event_data).e;
1067 payload.emplace<dcon::issue_id>(iid);
1071 if(std::holds_alternative<event::pending_human_n_event>(event_data))
1072 payload.emplace<
event_data_wrapper>(std::get<event::pending_human_n_event>(event_data));
1073 else if(std::holds_alternative<event::pending_human_f_n_event>(event_data))
1074 payload.emplace<
event_data_wrapper>(std::get<event::pending_human_f_n_event>(event_data));
1075 else if(std::holds_alternative<event::pending_human_p_event>(event_data))
1076 payload.emplace<
event_data_wrapper>(std::get<event::pending_human_p_event>(event_data));
1077 else if(std::holds_alternative<event::pending_human_f_p_event>(event_data))
1078 payload.emplace<
event_data_wrapper>(std::get<event::pending_human_f_p_event>(event_data));
1081 set_visible(
state,
false);
1082 auto uptr =
state.ui_state.
root->remove_child(
this);
1084 auto slot =
uint8_t(get_pool_slot());
1085 std::unique_ptr<base_event_window> ptr(
static_cast<base_event_window*
>(uptr.release()));
1086 event_pool[slot].push_back(std::move(ptr));
1087 --pending_events[slot];
1091 auto enum_val = any_cast<politics_issue_sort_order>(payload);
1094 std::sort(issues_listbox->row_contents.begin(), issues_listbox->row_contents.end(),
1095 [&](dcon::issue_option_id a, dcon::issue_option_id b) {
1096 auto a_name = text::get_name_as_string(state, dcon::fatten(state.world, a));
1097 auto b_name = text::get_name_as_string(state, dcon::fatten(state.world, b));
1098 return a_name < b_name;
1100 issues_listbox->update(
state);
1103 std::sort(issues_listbox->row_contents.begin(), issues_listbox->row_contents.end(),
1104 [&](dcon::issue_option_id a, dcon::issue_option_id b) {
1105 auto a_support = politics::get_popular_support(state, state.local_player_nation, a);
1106 auto b_support = politics::get_popular_support(state, state.local_player_nation, b);
1107 return a_support > b_support;
1109 issues_listbox->update(
state);
1112 std::sort(issues_listbox->row_contents.begin(), issues_listbox->row_contents.end(),
1113 [&](dcon::issue_option_id a, dcon::issue_option_id b) {
1114 auto a_support = politics::get_voter_support(state, state.local_player_nation, a);
1115 auto b_support = politics::get_voter_support(state, state.local_player_nation, b);
1116 return a_support > b_support;
1118 issues_listbox->update(
state);
1127 if(std::holds_alternative<event::pending_human_n_event>(event_data)) {
1129 pending_closure.push_back(
this);
1131 }
else if(std::holds_alternative<event::pending_human_f_n_event>(event_data)) {
1133 pending_closure.push_back(
this);
1135 }
else if(std::holds_alternative<event::pending_human_p_event>(event_data)) {
1137 pending_closure.push_back(
this);
1139 }
else if(std::holds_alternative<event::pending_human_f_p_event>(event_data)) {
1141 pending_closure.push_back(
this);
1147 for(
auto e : pending_closure)
1149 pending_closure.clear();
1153 for(
auto const& slot_pool : ui::event_pool) {
1154 for(
auto const& win : slot_pool) {
1155 pending_closure.push_back(win.get());
1170 auto const slot =
uint8_t(e_slot);
1171 if(event_pool[slot].empty()) {
1172 auto new_elm = ui::make_element_by_type<T>(
state, T::window_element_name);
1173 auto ptr = new_elm.get();
1174 T* actual =
static_cast<T*
>(ptr);
1175 actual->event_data = dat;
1176 actual->impl_on_update(
state);
1177 state.ui_state.
root->add_child_to_front(std::move(new_elm));
1179 std::unique_ptr<base_event_window> ptr = std::move(event_pool[slot].back());
1180 event_pool[slot].pop_back();
1181 ptr->event_data = dat;
1182 if(!ptr->is_visible())
1183 ptr->base_data.position =
state.ui_defs.gui[
state.ui_state.
defs_by_name.find(
state.lookup_key(T::window_element_name))->second.definition].position;
1184 ptr->set_visible(
state,
true);
1185 state.ui_state.
root->add_child_to_front(std::move(ptr));
1191 if(std::holds_alternative<event::pending_human_n_event>(dat)) {
1193 auto e = std::get<event::pending_human_n_event>(dat).e;
1194 if(
state.world.national_event_get_is_major(e)) {
1199 }
else if(std::holds_alternative<event::pending_human_f_n_event>(dat)) {
1201 auto e = std::get<event::pending_human_f_n_event>(dat).e;
1202 if(
state.world.free_national_event_get_is_major(e)) {
1205 }
else if(std::holds_alternative<event::pending_human_p_event>(dat)) {
1207 }
else if(std::holds_alternative<event::pending_human_f_p_event>(dat)) {
1212 new_event_window_1<national_event_window>(
state, dat, slot);
1215 new_event_window_1<national_major_event_window>(
state, dat, slot);
1218 new_event_window_1<national_election_event_window>(
state, dat, slot);
1221 new_event_window_1<provincial_event_window>(
state, dat, slot);
1226 ++pending_events[
uint8_t(slot)];
dcon::text_key get_name() noexcept
year_month_day to_ymd(absolute_time_point base) const noexcept
constexpr date() noexcept=default
void on_update(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
message_result get(sys::state &state, Cyto::Any &payload) 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
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::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 on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
simple_text_element_base * partyname
void on_update(sys::state &state) noexcept override
simple_text_element_base * partyvalue
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
void on_update(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_update(sys::state &state) noexcept override
std::string_view get_row_element_name() override
void on_update(sys::state &state) noexcept override
virtual message_result get(sys::state &state, Cyto::Any &payload) noexcept
virtual void on_create(sys::state &state) noexcept
void on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void 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
message_result on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
message_result test_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
void on_update(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
std::vector< dcon::issue_option_id > row_contents
void update(sys::state &state)
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
dcon::issue_option_id content
dcon::national_identity_id get_current_nation(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void button_action(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_create(sys::state &state) noexcept override
dcon::national_identity_id get_current_nation(sys::state &state) noexcept override
void update_chart(sys::state &state)
std::vector< entry > distribution
void on_create(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void set_text(sys::state &state, std::string const &new_text)
void on_create(sys::state &state) noexcept override
void make_event_choice(sys::state &state, event::pending_human_n_event const &e, uint8_t option_id)
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)
int32_t state_factory_count(sys::state &state, dcon::state_instance_id sid, dcon::nation_id n)
constexpr int32_t expiration_in_days
dcon::issue_id get_election_event_issue(sys::state &state, dcon::national_event_id e)
bool is_valid_option(sys::event_option const &opt)
constexpr float zoom_very_close
void get_active_political_parties(sys::state &state, dcon::nation_id n, std::vector< dcon::political_party_id > &parties)
void render_masked_rect(sys::state const &state, color_modification enabled, float x, float y, float width, float height, GLuint texture_handle, GLuint mask_texture_handle, ui::rotation r, bool flipped, bool rtl)
void render_textured_rect(sys::state const &state, color_modification enabled, float x, float y, float width, float height, GLuint texture_handle, ui::rotation r, bool flipped, bool rtl)
GLuint get_texture_handle(sys::state &state, dcon::texture_id id, bool keep_data)
random_pair get_random_pair(sys::state const &state, uint32_t value_in)
uint32_t reduce(uint32_t value_in, uint32_t upper_bound)
void play_interface_sound(sys::state &state, audio_instance &s, float volume)
audio_instance & get_click_sound(sys::state &state)
constexpr int32_t max_event_options
@ crisisdefender_continent
@ crisisattacker_continent
void add_to_layout_box(sys::state &state, layout_base &dest, layout_box &box, embedded_flag ico)
std::string resolve_string_substitution(sys::state &state, dcon::text_key source_text, substitution_map const &mp)
layout_box open_layout_box(layout_base &dest, int32_t indent)
std::string date_to_string(sys::state &state, sys::date date)
void localised_format_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view key, text::substitution_map const &sub)
std::string prettify(int64_t num)
endless_layout create_endless_layout(sys::state &state, layout &dest, layout_parameters const ¶ms)
dcon::text_key get_ruler_title(sys::state &state, dcon::nation_id n)
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
void add_to_substitution_map(substitution_map &mp, variable_type key, substitution value)
dcon::text_key get_adjective(sys::state &state, dcon::nation_id id)
uint16_t name_into_font_id(sys::state &state, std::string_view txt)
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)
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)
dcon::state_instance_id to_state(int32_t v)
dcon::province_id to_prov(int32_t v)
dcon::nation_id to_nation(int32_t v)
void multiplicative_value_modifier_description(sys::state &state, text::layout_base &layout, dcon::value_modifier_key modifier, int32_t primary, int32_t this_slot, int32_t from_slot)
void effect_description(sys::state &state, text::layout_base &layout, dcon::effect_key k, int32_t primary_slot, int32_t this_slot, int32_t from_slot, uint32_t r_lo, uint32_t r_hi)
politics_issue_sort_order
void new_event_window_1(sys::state &state, event_data_wrapper &dat, event_pool_slot e_slot)
void send(sys::state &state, element_base *parent, T value)
void close_expired_event_windows(sys::state &state)
void populate_event_submap(sys::state &state, text::substitution_map &sub, std::variant< event::pending_human_n_event, event::pending_human_f_n_event, event::pending_human_p_event, event::pending_human_f_p_event > const &phe) noexcept
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)
void clear_event_windows(sys::state &state)
ogl::color_modification get_color_modification(bool is_under_mouse, bool is_disabled, bool is_interactable)
bool events_pause_test(sys::state &state)
std::variant< event::pending_human_n_event, event::pending_human_f_n_event, event::pending_human_p_event, event::pending_human_f_p_event > event_data_wrapper
void new_event_window(sys::state &state, event_data_wrapper dat)
element_type get_element_type() const
rotation get_rotation() const
union ui::element_data::internal_data data
dcon::gfx_object_id gfx_object
ankerl::unordered_dense::map< dcon::text_key, element_target, hash_text_key > defs_by_name
std::unique_ptr< element_base > root
element_base * province_window
element_base * under_mouse