Project Alice
Loading...
Searching...
No Matches
gui_common_elements.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "dcon_generated.hpp"
4#include "demographics.hpp"
5#include "economy.hpp"
6#include "gui_graphics.hpp"
8#include "military.hpp"
9#include "nations.hpp"
10#include "politics.hpp"
12#include "rebels.hpp"
13#include "system_state.hpp"
14#include "text.hpp"
15#include "triggers.hpp"
16#include <unordered_map>
17#include <vector>
18
19namespace ui {
20
21typedef std::variant< std::monostate, dcon::nation_id, dcon::state_instance_id, dcon::province_id> pop_list_filter;
22
24 country,
25 boss,
31 opinion,
36 gp_influence = 0x40,
37 gp_investment = 0x80
38};
39
40// Filters used on both production and diplomacy tabs for the country lists
42 all,
44 sphere,
45 enemies,
46 allies,
47 find_allies, // Used only by diplo window
50 deselect_all, // Used only by message filter window
51 best_guess, // Used only by message filter window
53};
54
55bool country_category_filter_check(sys::state& state, country_list_filter filt, dcon::nation_id a, dcon::nation_id b);
56void sort_countries(sys::state& state, std::vector<dcon::nation_id>& list, country_list_sort sort, bool sort_ascend);
57
58void open_build_foreign_factory(sys::state& state, dcon::state_instance_id st);
59void open_foreign_investment(sys::state& state, dcon::nation_id n);
60
61std::string get_status_text(sys::state& state, dcon::nation_id nation_id);
62
63template<country_list_sort Sort>
65public:
67 void button_action(sys::state& state) noexcept override {
69 }
70};
71
73 void button_action(sys::state& state) noexcept override {
75 }
76};
77
79
80template<class T, class K>
81class generic_settable_element : public T {
82public:
84
85 message_result set(sys::state& state, Cyto::Any& payload) noexcept override {
86 if(payload.holds_type<K>()) {
87 content = any_cast<K>(payload);
88 T::impl_on_update(state);
90 }
92 }
93};
94
95template<class T>
97public:
98 void on_update(sys::state& state) noexcept override {
99 T content = retrieve<T>(state, parent);
100 auto fat_id = dcon::fatten(state.world, content);
102 }
103};
104
105template<class T>
107public:
108 void on_update(sys::state& state) noexcept override {
109 T content = retrieve<T>(state, parent);
114 auto fat_id = dcon::fatten(state.world, content);
115 auto box = text::open_layout_box(container);
116 text::add_to_layout_box(state, container, box, fat_id.get_name(), text::substitution_map{});
117 text::close_layout_box(container, box);
118 }
119};
120
122public:
123 virtual void populate_layout(sys::state& state, text::endless_layout& contents) noexcept { }
124
125 void on_update(sys::state& state) noexcept override {
127 switch(base_data.data.text.get_alignment()) {
130 break;
133 break;
134 default:
135 break;
136 }
137 auto border = base_data.data.text.border_size;
138
140 auto container = text::create_endless_layout(state,
143 border.x,
144 border.y,
145 int16_t(base_data.size.x - border.x * 2),
146 int16_t(base_data.size.y - border.y * 2),
148 0,
149 align,
150 color,
151 false});
152 populate_layout(state, container);
153 }
154};
155
157public:
158 virtual void populate_layout(sys::state& state, text::endless_layout& contents) noexcept { }
159
160 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
161 auto old_handle = base_data.data.text_common.font_handle;
162 if(!state.user_settings.use_classic_fonts) {
163 base_data.data.text_common.font_handle &= ~(0x01 << 7);
164 auto old_value = base_data.data.text_common.font_handle & 0x3F;
166 base_data.data.text_common.font_handle |= (old_value - 2);
167 }
170 }
171 void on_update(sys::state& state) noexcept override {
173 switch(base_data.data.text.get_alignment()) {
176 break;
179 break;
180 default:
181 break;
182 }
183 auto border = base_data.data.text.border_size;
184
186
187 auto old_handle = base_data.data.text_common.font_handle;
188 if(!state.user_settings.use_classic_fonts) {
189 base_data.data.text_common.font_handle &= ~(0x01 << 7);
190 auto old_value = base_data.data.text_common.font_handle & 0x3F;
192 base_data.data.text_common.font_handle |= (old_value - 2);
193 }
194 auto container = text::create_endless_layout(state,
197 border.x,
198 border.y,
199 int16_t(base_data.size.x - border.x * 2),
200 int16_t(base_data.size.y - border.y * 2),
202 0,
203 align,
204 color,
205 false});
206 populate_layout(state, container);
208 }
209};
210
211template<typename T>
213public:
214 virtual void populate_layout(sys::state& state, text::endless_layout& contents, T id) noexcept { }
215
216 void on_update(sys::state& state) noexcept override {
218 switch(base_data.data.text.get_alignment()) {
221 break;
224 break;
225 default:
226 break;
227 }
228 auto border = base_data.data.text.border_size;
229
230 auto content = retrieve<T>(state, parent);
232 auto container = text::create_endless_layout(state,
235 border.x,
236 border.y,
237 int16_t(base_data.size.x - border.x * 2),
238 int16_t(base_data.size.y - border.y * 2),
240 0,
241 align,
242 color,
243 false});
244 populate_layout(state, container, content);
245 }
246};
247
249public:
252
253 void on_reset_text(sys::state& state) noexcept override {
254 auto actual_size = base_data.size.x;
257 base_data.size.x = actual_size;
258 }
259 void on_create(sys::state& state) noexcept override {
264 }
269 }
270 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
272 }
273};
274
276public:
277 void on_update(sys::state& state) noexcept override {
278 auto content = retrieve<dcon::state_instance_id>(state, parent);
280 }
281};
282
284public:
285 void on_update(sys::state& state) noexcept override {
286 auto content = retrieve<dcon::state_instance_id>(state, parent);
287 int32_t count = economy::state_factory_count(state, content, state.local_player_nation);
288 auto txt = std::to_string(count) + "/" + std::to_string(int32_t(state.defines.factories_per_state));
289 set_text(state, txt);
290 }
291};
292
294public:
295 void on_update(sys::state& state) noexcept override {
296 auto content = retrieve<dcon::state_instance_id>(state, parent);
298 }
299};
300
302public:
303 void on_update(sys::state& state) noexcept override {
304 auto content = retrieve<dcon::state_instance_id>(state, parent);
305 auto total_pop = state.world.state_instance_get_demographics(content, demographics::total);
306 auto aristocrat_key = demographics::to_key(state, state.culture_definitions.aristocrat);
307 auto aristocrat_amount = state.world.state_instance_get_demographics(content, aristocrat_key);
308 auto txt = text::format_percentage(total_pop > 0 ? aristocrat_amount / total_pop : 0.0f, 1);
309 set_text(state, txt);
310 }
311};
312
314public:
315 void on_update(sys::state& state) noexcept override {
316 auto content = retrieve<dcon::state_instance_id>(state, parent);
317 auto total_pop = state.world.state_instance_get_demographics(content, demographics::total);
319 }
320};
321
323public:
324 virtual std::string get_text(sys::state& state, dcon::movement_id movement_id) noexcept {
325 return "";
326 }
327
328 void on_update(sys::state& state) noexcept override {
329 auto content = retrieve<dcon::movement_id>(state, parent);
330 set_text(state, get_text(state, content));
331 }
332};
333
335public:
336 std::string get_text(sys::state& state, dcon::movement_id movement_id) noexcept override {
337 auto size = state.world.movement_get_pop_support(movement_id);
338 return text::prettify(int64_t(size));
339 }
340};
341
343public:
344 std::string get_text(sys::state& state, dcon::movement_id movement_id) noexcept override {
345 auto radicalism = state.world.movement_get_radicalism(movement_id);
347 }
348};
349
351public:
352 void on_update(sys::state& state) noexcept override {
353 auto mid = retrieve<dcon::movement_id>(state, parent);
354 auto issue = state.world.movement_get_associated_issue_option(mid);
355 if(issue)
356 set_text(state, text::produce_simple_string(state, issue.get_movement_name()));
357 else
358 set_text(state, "");
359 }
360
363 }
364
365 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
366 auto mid = retrieve<dcon::movement_id>(state, parent);
367 auto issue = state.world.movement_get_associated_issue_option(mid);
368 text::add_line(state, contents, "reform_movement_desc", text::variable_type::reform, state.world.issue_option_get_name(issue));
369 }
370};
371
373public:
374 virtual void populate_layout(sys::state& state, text::endless_layout& contents, dcon::movement_id movement_id) noexcept { }
375
376 void on_update(sys::state& state) noexcept override {
377 auto content = retrieve<dcon::movement_id>(state, parent);
379 auto container =
381 populate_layout(state, container, content);
382 }
383};
384
386public:
387 void populate_layout(sys::state& state, text::endless_layout& contents, dcon::movement_id movement_id) noexcept override {
388 auto fat_id = dcon::fatten(state.world, movement_id);
389 auto independence_target = fat_id.get_associated_independence();
390 if(!independence_target)
391 return;
392
393 auto box = text::open_layout_box(contents);
395 if(independence_target.get_cultural_union_of().id) {
396 std::string movement_adj = text::get_adjective_as_string(state, independence_target);
397 text::add_to_substitution_map(sub, text::variable_type::country_adj, std::string_view(movement_adj));
398 text::localised_format_box(state, contents, box, std::string_view("nationalist_union_movement"), sub);
399 } else {
400 std::string movement_adj = text::get_adjective_as_string(state, independence_target);
401 text::add_to_substitution_map(sub, text::variable_type::country, std::string_view(movement_adj));
402 text::localised_format_box(state, contents, box, std::string_view("nationalist_liberation_movement"), sub);
403 }
404 text::close_layout_box(contents, box);
405 }
406
409 }
410
411 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
412 auto mid = retrieve<dcon::movement_id>(state, parent);
413 auto independence_target = state.world.movement_get_associated_independence(mid);
414 if(!independence_target)
415 return;
416 if(state.world.national_identity_get_cultural_union_of(independence_target)) {
417 text::add_line(state, contents, "NATIONALIST_UNION_MOVEMENT_DESC", text::variable_type::reform, state.world.national_identity_get_name(independence_target));
418 } else {
419 text::add_line(state, contents, "NATIONALIST_LIBERATION_MOVEMENT_DESC", text::variable_type::reform, state.world.national_identity_get_name(independence_target));
420 }
421 }
422};
423
425public:
426 virtual std::string get_text(sys::state& state, dcon::rebel_faction_id rebel_faction_id) noexcept {
427 return "";
428 }
429
430 void on_update(sys::state& state) noexcept override {
431 auto content = retrieve<dcon::rebel_faction_id>(state, parent);
432 set_text(state, get_text(state, content));
433 }
434};
435
437public:
438 void on_update(sys::state& state) noexcept override {
439 auto content = retrieve<dcon::nation_id>(state, parent);
440 if(state.world.nation_get_is_substate(content))
442 else
444 }
445};
446
448public:
449 virtual std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept {
450 return "";
451 }
452
453 void on_update(sys::state& state) noexcept override {
454 auto content = retrieve<dcon::nation_id>(state, parent);
455 set_text(state, get_text(state, content));
456 }
457};
458
460public:
461 uint16_t rank = 0;
462 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
463 auto const great_power_id = nations::get_nth_great_power(state, rank);
464 if(!bool(great_power_id))
465 return "0";
466 auto great_power_rel = state.world.get_gp_relationship_by_gp_influence_pair(nation_id, great_power_id);
467 auto fat_id = dcon::fatten(state.world, great_power_rel);
468 auto influence = fat_id.get_influence();
469 return std::to_string(int32_t(influence));
470 }
471};
472
474public:
475 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
476 auto uni_rel = state.world.get_unilateral_relationship_by_unilateral_pair(nation_id, state.local_player_nation);
477 auto fat_id = dcon::fatten(state.world, uni_rel);
478 return text::format_money(fat_id.get_foreign_investment());
479 }
480};
481
483public:
484 uint16_t rank = 0;
485 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
486 auto const great_power_id = nations::get_nth_great_power(state, rank);
487 if(!bool(great_power_id))
488 return text::format_money(0.f);
489 auto uni_rel = state.world.get_unilateral_relationship_by_unilateral_pair(nation_id, great_power_id);
490 auto fat_id = dcon::fatten(state.world, uni_rel);
491 return text::format_money(fat_id.get_foreign_investment());
492 }
493};
494
496public:
497 dcon::national_identity_id get_current_nation(sys::state& state) noexcept override {
498 dcon::nation_id sphereling_id = retrieve<dcon::nation_id>(state, parent);
499 auto ovr_id = state.world.nation_get_in_sphere_of(sphereling_id);
500 return ovr_id.get_identity_from_identity_holder();
501 }
502
503 void on_update(sys::state& state) noexcept override {
505 }
506 void button_action(sys::state& state) noexcept override {
509 }
510 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
513 }
514 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
516 flag_button::update_tooltip(state, x, y, contents);
517 }
518};
519
521public:
522 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
523 return std::to_string(int32_t(nations::prestige_score(state, nation_id)));
524 }
525};
526
528public:
529 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
530 auto fat_id = dcon::fatten(state.world, nation_id);
531 return std::to_string(int32_t(fat_id.get_industrial_score()));
532 }
533
536 }
537
538 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
539 auto n = retrieve<dcon::nation_id>(state, parent);
540 if(state.world.nation_get_owned_province_count(n) == 0)
541 return;
542
543 auto iweight = state.defines.investment_score_factor;
544 for(auto si : state.world.nation_get_state_ownership(n)) {
545 float total_level = 0;
546 float worker_total =
547 si.get_state().get_demographics(demographics::to_employment_key(state, state.culture_definitions.primary_factory_worker)) +
548 si.get_state().get_demographics(demographics::to_employment_key(state, state.culture_definitions.secondary_factory_worker));
549 float total_factory_capacity = 0;
550 province::for_each_province_in_state_instance(state, si.get_state(), [&](dcon::province_id p) {
551 for(auto f : state.world.province_get_factory_location(p)) {
552 total_factory_capacity +=
553 float(f.get_factory().get_level() * f.get_factory().get_building_type().get_base_workforce());
554 total_level += float(f.get_factory().get_level());
555 }
556 });
557 float per_state = 4.0f * total_level * std::max(std::min(1.0f, worker_total / total_factory_capacity), 0.05f);
558 if(per_state > 0.f) {
559 auto box = text::open_layout_box(contents);
560 text::layout_box name_entry = box;
562 text::layout_box workers_entry = box;
563 text::layout_box max_workers_entry = box;
564 text::layout_box score_box = box;
565
566 name_entry.x_size /= 10;
567 text::add_to_layout_box(state, contents, name_entry, text::get_short_state_name(state, si.get_state()).substr(0, 20), text::text_color::yellow);
568
569 level_entry.x_position += 150;
570 text::add_to_layout_box(state, contents, level_entry, text::int_wholenum{ int32_t(total_level) });
571
572 workers_entry.x_position += 180;
573 text::add_to_layout_box(state, contents, workers_entry, text::int_wholenum{ int32_t(worker_total) });
574
575 max_workers_entry.x_position += 250;
576 text::add_to_layout_box(state, contents, max_workers_entry, text::int_wholenum{ int32_t(total_factory_capacity) });
577
578 score_box.x_position += 350;
579 text::add_to_layout_box(state, contents, score_box, text::fp_two_places{ per_state });
580
581 //text::localised_format_box(state, contents, box, std::string_view("alice_indscore_1"), sub);
582 text::add_to_layout_box(state, contents, box, std::string(" "));
583 text::close_layout_box(contents, box);
584 }
585 }
586 float total_invest = nations::get_foreign_investment(state, n);
587 if(total_invest > 0.f) {
588 text::add_line(state, contents, "industry_score_explain_2", text::variable_type::x, text::fp_four_places{ iweight });
589 for(auto ur : state.world.nation_get_unilateral_relationship_as_source(n)) {
590 if(ur.get_foreign_investment() > 0.f) {
593 text::add_to_substitution_map(sub, text::variable_type::y, text::fp_currency{ ur.get_foreign_investment() });
594 auto box = text::open_layout_box(contents);
595 text::localised_format_box(state, contents, box, std::string_view("industry_score_explain_3"), sub);
596 text::close_layout_box(contents, box);
597 }
598 }
599 }
600 }
601};
602
604public:
605 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
606 auto fat_id = dcon::fatten(state.world, nation_id);
607 return std::to_string(int32_t(fat_id.get_military_score()));
608 }
609
611 return tooltip_behavior::variable_tooltip;
612 }
613
614 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
615 auto n = retrieve<dcon::nation_id>(state, parent);
616 auto recruitable = state.world.nation_get_recruitable_regiments(n);
617 auto active_regs = state.world.nation_get_active_regiments(n);
618 auto is_disarmed = state.world.nation_get_disarmed_until(n) > state.current_date;
619 auto disarm_factor = is_disarmed ? state.defines.disarmament_army_hit : 1.f;
620 auto supply_mod = std::max(state.world.nation_get_modifier_values(n, sys::national_mod_offsets::supply_consumption) + 1.0f, 0.1f);
621 auto avg_land_score = state.world.nation_get_averge_land_unit_score(n);
622 auto gen_range = state.world.nation_get_leader_loyalty(n);
623 auto num_capital_ships = state.world.nation_get_capital_ship_score(n);
624 text::add_line(state, contents, "military_score_explain_1", text::variable_type::x, text::fp_two_places{ num_capital_ships });
625 text::add_line(state, contents, "military_score_explain_2", text::variable_type::x, text::int_wholenum{ recruitable });
626 text::add_line(state, contents, "military_score_explain_3", text::variable_type::x, text::int_wholenum{ active_regs });
627 text::add_line_with_condition(state, contents, "military_score_explain_4", is_disarmed, text::variable_type::x, text::fp_two_places{ state.defines.disarmament_army_hit });
628 text::add_line(state, contents, "military_score_explain_5", text::variable_type::x, text::fp_two_places{ supply_mod });
629 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::supply_consumption, true);
630 text::add_line(state, contents, "military_score_explain_6", text::variable_type::x, text::fp_two_places{ avg_land_score });
631 //text::add_line(state, contents, "military_score_explain_7", text::variable_type::x, text::fp_two_places{ num_leaders });
632 }
633};
634
636public:
637 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
638 auto fat_id = dcon::fatten(state.world, nation_id);
639 return std::to_string(
640 int32_t(nations::prestige_score(state, nation_id) + fat_id.get_industrial_score() + fat_id.get_military_score()));
641 }
642};
643
645public:
646 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
648 }
649};
650
652public:
653 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
654 float population = state.world.nation_get_demographics(nation_id, demographics::total);
655 return text::format_float(economy::gdp_adjusted(state, nation_id) / population * 1000000.f);
656 }
657};
658
660public:
661 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
663 }
664};
665
667public:
668 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
669 auto fat_id = dcon::fatten(state.world, nation_id);
670 return std::to_string(fat_id.get_prestige_rank());
671 }
672};
673
675public:
676 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
677 auto fat_id = dcon::fatten(state.world, nation_id);
678 return std::to_string(fat_id.get_industrial_rank());
679 }
680};
681
683public:
684 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
685 auto fat_id = dcon::fatten(state.world, nation_id);
686 return std::to_string(fat_id.get_military_rank());
687 }
688};
689
691public:
692 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
693 auto fat_id = dcon::fatten(state.world, nation_id);
694 return std::to_string(fat_id.get_rank());
695 }
696};
697
699public:
700 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
701 return get_status_text(state, nation_id);
702 }
703};
704
706public:
707 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
708 auto ruling_party = state.world.nation_get_ruling_party(nation_id);
709 auto ideology = state.world.political_party_get_ideology(ruling_party);
710 return text::get_name_as_string(state, ideology);
711 }
712};
713
715public:
716 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
717 auto fat_id = dcon::fatten(state.world, nation_id);
718 return text::get_name_as_string(state, fat_id.get_ruling_party());
719 }
720
722 return tooltip_behavior::variable_tooltip;
723 }
724
725 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
726 auto nation_id = retrieve<dcon::nation_id>(state, parent);
727 auto fat_id = dcon::fatten(state.world, nation_id);
728 std::string ruling_party = text::get_name_as_string(state, fat_id.get_ruling_party());
729 ruling_party = ruling_party + " (" + text::get_name_as_string(state, state.world.political_party_get_ideology(state.world.nation_get_ruling_party(nation_id))) + ")";
730 {
731 auto box = text::open_layout_box(contents, 0);
732 text::localised_single_sub_box(state, contents, box, std::string_view("topbar_ruling_party"), text::variable_type::curr, std::string_view(ruling_party));
734 text::close_layout_box(contents, box);
735 }
736 for(auto pi : state.culture_definitions.party_issues) {
737 reform_description(state, contents, state.world.political_party_get_party_issues(fat_id.get_ruling_party(), pi));
739 }
740 }
741};
742
744public:
745 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
746 auto fat_id = dcon::fatten(state.world, nation_id);
747 auto gov_type_id = fat_id.get_government_type();
748 auto gov_name_seq = state.world.government_type_get_name(gov_type_id);
749 return text::produce_simple_string(state, gov_name_seq);
750 }
751
753 return tooltip_behavior::variable_tooltip;
754 }
755
756 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
757 auto n = retrieve<dcon::nation_id>(state, parent);
758 auto box = text::open_layout_box(contents);
762 text::add_to_substitution_map(sub, text::variable_type::capital, state.world.nation_get_capital(n));
763 text::add_to_substitution_map(sub, text::variable_type::continentname, state.world.modifier_get_name(state.world.province_get_continent(state.world.nation_get_capital(n))));
764 text::add_to_layout_box(state, contents, box, state.world.government_type_get_desc(state.world.nation_get_government_type(n)), sub);
765 text::close_layout_box(contents, box);
766 }
767};
768
770public:
771 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
772 auto fat_id = dcon::fatten(state.world, nation_id);
773 if(bool(fat_id.get_in_sphere_of().id)) {
774 return text::produce_simple_string(state, "rel_sphere_of_influence") + ":";
775 } else {
776 return text::produce_simple_string(state, "diplomacy_sphere_label");
777 }
778 }
779};
780
782public:
783 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
784 auto fat_id = dcon::fatten(state.world, nation_id);
785 auto puppets_iter = state.world.nation_get_overlord_as_ruler(nation_id);
786 if(puppets_iter.begin() < puppets_iter.end()) {
787 return text::produce_simple_string(state, "country_puppets_list");
788 } else if(fat_id.get_is_substate()) {
789 return text::produce_simple_string(state, "substate_of_nocolor") + ":";
790 } else {
791 return text::produce_simple_string(state, "satellite_of_nocolor") + ":";
792 }
793 }
794};
795
797public:
798 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
799 auto gp_rel_id = state.world.get_gp_relationship_by_gp_influence_pair(nation_id, state.local_player_nation);
800 if(bool(gp_rel_id)) {
801 auto const status = state.world.gp_relationship_get_status(gp_rel_id);
803 }
804 return text::produce_simple_string(state, "rel_neutral");
805 }
806};
807
809public:
810 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
811 uint32_t num_factories = 0;
812 for(auto si : state.world.nation_get_state_ownership(nation_id)) {
813 province::for_each_province_in_state_instance(state, si.get_state(), [&](dcon::province_id p) {
814 num_factories +=
815 uint32_t(state.world.province_get_factory_location(p).end() - state.world.province_get_factory_location(p).begin());
816 });
817 }
818 return std::to_string(num_factories);
819 }
820};
821
823public:
824 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
825 size_t num_provinces = 0;
826 for(auto si : state.world.nation_get_state_ownership(nation_id))
827 province::for_each_province_in_state_instance(state, si.get_state(), [&](dcon::province_id p) { ++num_provinces; });
828 return std::to_string(num_provinces);
829 }
830};
831
833public:
834 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
835 auto rel = state.world.get_diplomatic_relation_by_diplomatic_pair(nation_id, state.local_player_nation);
836 auto fat_rel = dcon::fatten(state.world, rel);
837 return std::to_string(int32_t(fat_rel.get_value()));
838 }
839};
840
842public:
843 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
844 auto militancy = state.world.nation_get_demographics(nation_id, demographics::militancy);
845 auto total_pop = state.world.nation_get_demographics(nation_id, demographics::total);
846 return text::format_float(militancy / total_pop);
847 }
848};
849
851public:
852 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
853 auto consciousness = state.world.nation_get_demographics(nation_id, demographics::consciousness);
854 auto total_pop = state.world.nation_get_demographics(nation_id, demographics::total);
855 return text::format_float(consciousness / total_pop);
856 }
857};
858
860public:
861 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
862 auto fcp = nations::free_colonial_points(state, nation_id);
863 auto mcp = nations::max_colonial_points(state, nation_id);
864 return text::format_ratio(fcp, mcp);
865 }
866};
867
869public:
870 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
871 auto budget = nations::get_treasury(state, nation_id);
872 return text::format_money(budget);
873 }
874};
875
877public:
878 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
879 auto budget = nations::get_bank_funds(state, nation_id);
880 return text::format_money(budget);
881 }
882};
883
885public:
886 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
887 auto budget = nations::get_debt(state, nation_id);
888 return text::format_money(budget);
889 }
890};
891
893public:
894 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
895 auto budget = economy::interest_payment(state, nation_id);
896 return text::format_money(budget);
897 }
898};
899
901public:
902 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
903 auto literacy = state.world.nation_get_demographics(nation_id, demographics::literacy);
904 auto total_pop = std::max(1.0f, state.world.nation_get_demographics(nation_id, demographics::total));
905 return text::format_percentage(literacy / total_pop, 1);
906 }
907};
908
910public:
911 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
912 auto fat_id = dcon::fatten(state.world, nation_id);
913 return text::format_float(fat_id.get_infamy(), 2);
914 }
915};
916
918public:
919 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
920 auto total_pop = state.world.nation_get_demographics(nation_id, demographics::total);
921 return text::prettify(int64_t(total_pop));
922 }
923};
924
926public:
927 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
928 auto tech_id = nations::current_research(state, nation_id);
929 if(tech_id) {
930 return text::get_name_as_string(state, dcon::fatten(state.world, tech_id));
931 }
932 return "?R" + text::produce_simple_string(state, "tb_tech_no_current");
933 }
934};
935
937public:
938 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
939 auto points = nations::daily_research_points(state, nation_id);
940 return text::format_float(points, 2);
941 }
942};
943
945public:
946 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
947 auto points = state.world.nation_get_research_points(nation_id);
948 return text::format_float(points, 1);
949 }
950};
951
953public:
954
955 void on_create(sys::state& state) noexcept override {
956 top_left_extension = ui::xy_pair{ 25, 3 };
957 bottom_right_extension = ui::xy_pair{ -10, 2 };
958 expanded_hitbox_text::on_create(state);
959 }
960
961 void on_update(sys::state& state) noexcept override {
962 auto points = nations::suppression_points(state, retrieve<dcon::nation_id>(state, parent));
963 set_text(state, text::format_float(points, 1));
964 }
965
967 return tooltip_behavior::variable_tooltip;
968 }
969
970 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
971 auto n = retrieve<dcon::nation_id>(state, parent);
972
973 auto base = state.defines.suppression_points_gain_base;
974 auto nmod = state.world.nation_get_modifier_values(n, sys::national_mod_offsets::suppression_points_modifier) + 1.0f;
975 auto bmod = state.world.nation_get_demographics(n, demographics::to_key(state, state.culture_definitions.bureaucrat)) /
976 std::max(state.world.nation_get_demographics(n, demographics::total), 1.0f) * state.defines.suppress_bureaucrat_factor;
977
978 text::add_line(state, contents, "sup_point_gain", text::variable_type::val, text::fp_two_places{base * nmod * bmod});
980 text::add_line(state, contents, "sup_point_explain", text::variable_type::x, text::fp_two_places{base},
982
984 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::suppression_points_modifier, true);
985 }
986};
987
989public:
990 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
991 auto available = nations::max_national_focuses(state, nation_id);
992 auto in_use = nations::national_focuses_in_use(state, nation_id);
993 return text::format_ratio(in_use, available);
994 }
995};
996
998public:
999 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
1000 auto points = nations::diplomatic_points(state, nation_id);
1001 return text::format_float(points, 0);
1002 }
1003};
1004
1006public:
1007 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
1008 int32_t sum = 0;
1009 auto fat_id = dcon::fatten(state.world, nation_id);
1010 for(auto prov_own : fat_id.get_province_ownership_as_nation()) {
1011 auto prov = prov_own.get_province();
1013 }
1014 return std::to_string(sum);
1015 }
1016};
1017
1019public:
1020 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
1021 auto available = state.world.nation_get_recruitable_regiments(nation_id);
1022 auto in_use = state.world.nation_get_active_regiments(nation_id);
1023 return text::format_ratio(in_use, available);
1024 }
1025};
1026
1028public:
1029 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
1030 auto available = military::naval_supply_points(state, nation_id);
1031 auto in_use = military::naval_supply_points_used(state, nation_id);
1032 return text::format_ratio(in_use, available);
1033 }
1034};
1035
1037public:
1038 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
1040 }
1041};
1042
1044public:
1045 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
1046 return text::prettify(military::total_ships(state, nation_id));
1047 }
1048};
1049
1051public:
1052 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
1053 auto points = nations::leadership_points(state, nation_id);
1054 return text::format_float(points, 1);
1055 }
1056};
1057
1059public:
1060 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
1062 // yes, the original localisation says "refroms"
1063 return text::produce_simple_string(state, "politics_can_do_social_refroms");
1064 } else {
1065 return text::produce_simple_string(state, "politics_can_not_do_social_refroms");
1066 }
1067 }
1068};
1069
1071public:
1072 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
1074 // yes, the original localisation says "refroms"
1075 return text::produce_simple_string(state, "politics_can_do_political_refroms");
1076 } else {
1077 return text::produce_simple_string(state, "politics_can_not_do_political_refroms");
1078 }
1079 }
1080};
1081
1083public:
1084 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
1085 auto fat_id = dcon::fatten(state.world, nation_id);
1086 return text::produce_simple_string(state, fat_id.get_national_value().get_name());
1087 }
1088};
1089
1091public:
1092 void on_update(sys::state& state) noexcept override {
1093 auto n = retrieve<dcon::nation_id>(state, parent);
1094 auto mod_id = state.world.nation_get_tech_school(n);
1095 if(bool(mod_id)) {
1096 set_text(state, text::produce_simple_string(state, state.world.modifier_get_name(mod_id)));
1097 } else {
1098 set_text(state, text::produce_simple_string(state, "traditional_academic"));
1099 }
1100 }
1102 return tooltip_behavior::variable_tooltip;
1103 }
1104
1105 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1106 auto n = state.local_player_nation;
1107 auto mod_id = state.world.nation_get_tech_school(retrieve<dcon::nation_id>(state, parent));
1108 if(bool(mod_id)) {
1109 auto box = text::open_layout_box(contents, 0);
1110 text::add_to_layout_box(state, contents, box, state.world.modifier_get_name(mod_id), text::text_color::yellow);
1111 if(auto desc = state.world.modifier_get_desc(mod_id); state.key_is_localized(desc)) {
1115 text::add_to_substitution_map(sub, text::variable_type::capital, state.world.nation_get_capital(n));
1116 text::add_to_substitution_map(sub, text::variable_type::continentname, state.world.modifier_get_name(state.world.province_get_continent(state.world.nation_get_capital(n))));
1117 text::add_to_layout_box(state, contents, box, state.world.modifier_get_desc(mod_id), sub);
1118 }
1119 text::close_layout_box(contents, box);
1120 modifier_description(state, contents, mod_id);
1121 }
1122 }
1123};
1124
1126public:
1127 virtual int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept {
1128 return 0;
1129 }
1130
1131 void on_update(sys::state& state) noexcept override {
1132 auto n = retrieve<dcon::nation_id>(state, parent);
1133 frame = get_icon_frame(state, n);
1134 }
1135};
1136
1137
1139public:
1140 void on_update(sys::state& state) noexcept override {
1141 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1142 progress = state.world.nation_get_modifier_values(nation_id, sys::national_mod_offsets::civilization_progress_modifier);
1143 }
1145 return tooltip_behavior::variable_tooltip;
1146 }
1147
1148 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1149 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1150 {
1151 auto box = text::open_layout_box(contents);
1152 text::localised_format_box(state, contents, box, "modifier_civilization_progress");
1153 text::add_to_layout_box(state, contents, box, std::string_view{ ": " });
1154 text::add_to_layout_box(state, contents, box, text::fp_percentage{ state.world.nation_get_modifier_values(nation_id, sys::national_mod_offsets::civilization_progress_modifier) }, text::text_color::green);
1155 text::close_layout_box(contents, box);
1156 }
1157 active_modifiers_description(state, contents, nation_id, 15, sys::national_mod_offsets::civilization_progress_modifier, false);
1158 }
1159};
1160
1162public:
1163 void on_update(sys::state& state) noexcept override {
1164 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1165 auto tech_id = nations::current_research(state, nation_id);
1166 if(bool(tech_id)) {
1167 progress = state.world.nation_get_research_points(nation_id) / culture::effective_technology_cost(state, state.current_date.to_ymd(state.start_date).year, state.local_player_nation, tech_id);
1168 } else {
1169 progress = 0.f;
1170 }
1171 }
1173 return tooltip_behavior::variable_tooltip;
1174 }
1175 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1176 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1177 auto tech_id = nations::current_research(state, nation_id);
1178
1179 if(tech_id) {
1180 text::add_line(state, contents, "technologyview_research_tooltip",
1181 text::variable_type::tech, state.world.technology_get_name(tech_id),
1183 text::add_line(state, contents, "technologyview_research_invested_tooltip",
1184 text::variable_type::invested, int64_t(state.world.nation_get_research_points(nation_id)),
1185 text::variable_type::cost, int64_t(culture::effective_technology_cost(state, state.ui_date.to_ymd(state.start_date).year, nation_id, tech_id)));
1186 } else {
1187 text::add_line(state, contents, "technologyview_no_research_tooltip");
1188 }
1189 }
1190};
1191
1193public:
1194 virtual int32_t get_icon_frame(sys::state& state, dcon::state_instance_id state_instance_id) noexcept {
1195 return 0;
1196 }
1197
1198 void on_update(sys::state& state) noexcept override {
1199 auto state_instance_id = retrieve<dcon::state_instance_id>(state, parent);
1200 frame = get_icon_frame(state, state_instance_id);
1201 }
1202};
1203
1205public:
1206 virtual int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept {
1207 return 0;
1208 }
1209
1210 void on_update(sys::state& state) noexcept override {
1211 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1212 frame = get_icon_frame(state, nation_id);
1213 }
1214};
1215
1217public:
1218 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1219 auto status = nations::get_status(state, nation_id);
1220 return std::min(3, int32_t(status));
1221 }
1222};
1223
1225public:
1226 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1227 return int32_t(!nations::has_social_reform_available(state, nation_id));
1228 }
1229};
1230
1232public:
1233 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1234 return int32_t(!nations::has_political_reform_available(state, nation_id));
1235 }
1236};
1237
1239public:
1240 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1241 return int32_t(politics::get_military_reform_multiplier(state, nation_id) <= 0.f);
1242 }
1243};
1244
1246public:
1247 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1248 return int32_t(politics::get_economic_reform_multiplier(state, nation_id) <= 0.f);
1249 }
1250};
1251
1253public:
1254 void on_update(sys::state& state) noexcept override {
1255 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1256 auto ruling_party = state.world.nation_get_ruling_party(nation_id);
1257 auto ideology = state.world.political_party_get_ideology(ruling_party);
1258 color = state.world.ideology_get_color(ideology);
1259 }
1260};
1261
1263public:
1264 dcon::national_identity_id get_current_nation(sys::state& state) noexcept override {
1265 auto fat_id = dcon::fatten(state.world, state.local_player_nation);
1266 return fat_id.get_identity_from_identity_holder();
1267 }
1268};
1269
1271public:
1272 uint16_t rank = 0;
1273 dcon::national_identity_id get_current_nation(sys::state& state) noexcept override {
1274 auto const nat_id = nations::get_nth_great_power(state, rank);
1275 if(!bool(nat_id))
1276 return dcon::national_identity_id{};
1277 auto fat_id = dcon::fatten(state.world, nat_id);
1278 return fat_id.get_identity_from_identity_holder();
1279 }
1280};
1281
1283public:
1284 void on_update(sys::state& state) noexcept override {
1285 auto ideology_id = retrieve<dcon::ideology_id>(state, parent);
1286 color = state.world.ideology_get_color(ideology_id);
1287 }
1288};
1289
1291public:
1292 void on_update(sys::state& state) noexcept override {
1293 auto province = retrieve<dcon::province_id>(state, parent);
1294 auto nation = retrieve<dcon::nation_id>(state, parent);
1295
1296 if(province) {
1297 auto fat_id = dcon::fatten(state.world, province);
1298 if(fat_id.get_province_ownership().get_nation().get_is_mobilized()) {
1299 frame = 1;
1300 } else {
1301 frame = 0;
1302 }
1303 } else if (nation) {
1304 auto fat_id = dcon::fatten(state.world, nation);
1305 if(fat_id.get_is_mobilized()) {
1306 frame = 1;
1307 } else {
1308 frame = 0;
1309 }
1310 }
1311
1312 }
1313};
1314
1316public:
1317 dcon::pop_type_id type{};
1318
1319 void set_type(sys::state& state, dcon::pop_type_id t) {
1320 type = t;
1321 frame = int32_t(state.world.pop_type_get_sprite(t) - 1);
1322 }
1323
1325 return tooltip_behavior::tooltip;
1326 }
1327
1328 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1329 auto name = state.world.pop_type_get_name(type);
1330 auto box = text::open_layout_box(contents, 0);
1331 text::add_to_layout_box(state, contents, box, name);
1332 text::close_layout_box(contents, box);
1333 }
1334};
1335
1337public:
1338 void on_update(sys::state& state) noexcept override {
1339 auto content = retrieve<dcon::pop_type_id>(state, parent);
1340 auto fat_id = dcon::fatten(state.world, content);
1341 frame = int32_t(fat_id.get_sprite() - 1);
1342 }
1343
1345 return tooltip_behavior::variable_tooltip;
1346 }
1347
1348 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1349 auto content = retrieve<dcon::pop_type_id>(state, parent);
1350 auto name = state.world.pop_type_get_name(content);
1351 auto box = text::open_layout_box(contents, 0);
1352 text::add_to_layout_box(state, contents, box, name);
1353 text::close_layout_box(contents, box);
1354 }
1355};
1357public:
1358 void on_update(sys::state& state) noexcept override {
1359 auto content = retrieve<dcon::religion_id>(state, parent);
1360 auto fat_id = dcon::fatten(state.world, content);
1361 frame = int32_t(fat_id.get_icon() - 1);
1362 }
1363};
1364
1366public:
1367 void on_update(sys::state& state) noexcept override {
1368 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1369 auto ideology_id = retrieve<dcon::ideology_id>(state, parent);
1370 if(nation_id && ideology_id) {
1371 auto percentage = .01f * state.world.nation_get_upper_house(nation_id, ideology_id);
1372 set_text(state, text::format_percentage(percentage, 1));
1373 }
1374 }
1375};
1376
1377class upper_house_piechart : public piechart<dcon::ideology_id> {
1378protected:
1379 void on_update(sys::state& state) noexcept override {
1380 auto nat_id = retrieve<dcon::nation_id>(state, parent);
1381 distribution.clear();
1382 for(auto id : state.world.in_ideology) {
1383 distribution.emplace_back(id.id, float(state.world.nation_get_upper_house(nat_id, id)));
1384 }
1385 update_chart(state);
1386 }
1387};
1388
1389class voter_ideology_piechart : public piechart<dcon::ideology_id> {
1390protected:
1391 void on_update(sys::state& state) noexcept override {
1392 auto nat_id = retrieve<dcon::nation_id>(state, parent);
1393 distribution.clear();
1394 for(auto id : state.world.in_ideology) {
1395 distribution.emplace_back(id.id, 0.0f);
1396 }
1397 for(auto p : state.world.nation_get_province_ownership(nat_id)) {
1398 for(auto pop_loc : state.world.province_get_pop_location(p.get_province())) {
1399 auto pop_id = pop_loc.get_pop();
1400 float vote_size = politics::pop_vote_weight(state, pop_id, nat_id);
1401 if(vote_size > 0) {
1402 state.world.for_each_ideology([&](dcon::ideology_id iid) {
1403 auto dkey = pop_demographics::to_key(state, iid);
1404 distribution[iid.index()].value += state.world.pop_get_demographics(pop_id.id, dkey) * vote_size;
1405 });
1406 }
1407 }
1408 }
1409
1410 update_chart(state);
1411 }
1412};
1413
1415public:
1416 void on_update(sys::state& state) noexcept override {
1417 auto province_id = retrieve<dcon::province_id>(state, parent);
1418 auto total_pop = state.world.province_get_demographics(province_id, demographics::total);
1419 set_text(state, text::prettify(int32_t(total_pop)));
1420 }
1421};
1422
1424public:
1425 void on_update(sys::state& state) noexcept override {
1426 auto province_id = retrieve<dcon::province_id>(state, parent);
1427 auto militancy = state.world.province_get_demographics(province_id, demographics::militancy);
1428 auto total_pop = state.world.province_get_demographics(province_id, demographics::total);
1429 set_text(state, text::format_float(militancy / total_pop));
1430 }
1431};
1432
1434public:
1435 void on_update(sys::state& state) noexcept override {
1436 auto province_id = retrieve<dcon::province_id>(state, parent);
1437 auto consciousness = state.world.province_get_demographics(province_id, demographics::consciousness);
1438 auto total_pop = state.world.province_get_demographics(province_id, demographics::total);
1439 set_text(state, text::format_float(consciousness / total_pop));
1440 }
1441};
1442
1444public:
1445 void on_update(sys::state& state) noexcept override {
1446 auto province_id = retrieve<dcon::province_id>(state, parent);
1447 auto literacy = state.world.province_get_demographics(province_id, demographics::literacy);
1448 auto total_pop = state.world.province_get_demographics(province_id, demographics::total);
1449 set_text(state, text::format_percentage(literacy / total_pop, 1));
1450 }
1451};
1452
1453
1455public:
1456 void on_update(sys::state& state) noexcept override {
1457 auto province_id = retrieve<dcon::province_id>(state, parent);
1458 set_text(state, text::get_name_as_string(state, state.world.province_get_dominant_culture(province_id)));
1459 }
1460};
1462public:
1463 void on_update(sys::state& state) noexcept override {
1464 auto province_id = retrieve<dcon::province_id>(state, parent);
1465 set_text(state, text::get_name_as_string(state, state.world.province_get_dominant_religion(province_id)));
1466 }
1467};
1469public:
1470 void on_update(sys::state& state) noexcept override {
1471 auto province_id = retrieve<dcon::province_id>(state, parent);
1472 set_text(state, text::get_name_as_string(state, state.world.province_get_dominant_issue_option(province_id)));
1473 }
1474};
1476public:
1477 void on_update(sys::state& state) noexcept override {
1478 auto province_id = retrieve<dcon::province_id>(state, parent);
1479 set_text(state, text::get_name_as_string(state, state.world.province_get_dominant_ideology(province_id)));
1480 }
1481};
1482
1484public:
1485 void on_update(sys::state& state) noexcept override {
1486 auto province_id = retrieve<dcon::province_id>(state, parent);
1487 set_text(state, text::get_province_state_name(state, province_id));
1488 }
1489};
1490
1492public:
1493 void on_update(sys::state& state) noexcept override {
1494 auto province_id = retrieve<dcon::province_id>(state, parent);
1495 set_text(state, text::get_name_as_string(state, state.world.province_get_rgo(province_id)));
1496 }
1497};
1498
1500public:
1501 void on_update(sys::state& state) noexcept override {
1502 auto province_id = retrieve<dcon::province_id>(state, parent);
1503 set_text(state, text::format_float(province::rgo_production_quantity(state, province_id, state.world.province_get_rgo(province_id)), 3));
1504 }
1505
1506 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1507 auto p = retrieve<dcon::province_id>(state, parent);
1508
1509 auto n = state.world.province_get_nation_from_province_ownership(p);
1510
1511 state.world.for_each_commodity([&](dcon::commodity_id c) {
1512 auto production = province::rgo_production_quantity(state, p, c);
1513
1514 if(production < 0.0001f) {
1515 return;
1516 }
1517
1518 auto base_box = text::open_layout_box(contents);
1519 auto name_box = base_box;
1520 name_box.x_size = 75;
1521 auto production_box = base_box;
1522 production_box.x_position += 120.f;
1523
1525 text::add_to_layout_box(state, contents, production_box, text::format_money(production));
1526 text::add_to_layout_box(state, contents, base_box, std::string(" "));
1527 text::close_layout_box(contents, base_box);
1528 });
1529 }
1530};
1531
1533public:
1534 void on_update(sys::state& state) noexcept override {
1535 auto province_id = retrieve<dcon::province_id>(state, parent);
1536 set_text(state, text::format_money(province::rgo_income(state, province_id)));
1537 }
1538
1540 return tooltip_behavior::variable_tooltip;
1541 }
1542
1543 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1544 auto p = retrieve<dcon::province_id>(state, parent);
1545
1546 auto n = state.world.province_get_nation_from_province_ownership(p);
1547
1548 state.world.for_each_commodity([&](dcon::commodity_id c) {
1549 auto profit = state.world.province_get_rgo_profit_per_good(p, c);
1550
1551 if(profit < 0.0001f) {
1552 return;
1553 }
1554
1555 auto base_box = text::open_layout_box(contents);
1556 auto name_box = base_box;
1557 name_box.x_size = 75;
1558 auto profit_box = base_box;
1559 profit_box.x_position += 120.f;
1560
1562 text::add_to_layout_box(state, contents, profit_box, text::format_money(profit));
1563 text::add_to_layout_box(state, contents, base_box, std::string(" "));
1564 text::close_layout_box(contents, base_box);
1565 });
1566 }
1567};
1568
1570public:
1571 void on_update(sys::state& state) noexcept override {
1572 auto province_id = retrieve<dcon::province_id>(state, parent);
1573 set_text(state, text::prettify(int32_t(province::land_employment(state, province_id))));
1574 }
1575
1577 return tooltip_behavior::variable_tooltip;
1578 }
1579
1580 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1581 auto p = retrieve<dcon::province_id>(state, parent);
1582
1583 auto n = state.world.province_get_nation_from_province_ownership(p);
1584
1585 auto row_1 = text::open_layout_box(contents);
1586 auto col_1 = row_1;
1587 col_1.x_size = 75;
1588 auto col_2 = row_1;
1589 col_2.x_position += 90.f;
1590 auto col_3 = row_1;
1591 col_3.x_position += 180.f;
1592 auto col_4 = row_1;
1593 col_4.x_position += 250.f;
1594 text::add_to_layout_box(state, contents, col_1, std::string_view("Good"));
1595 text::add_to_layout_box(state, contents, col_2, std::string_view("Employed"));
1596 text::add_to_layout_box(state, contents, col_3, std::string_view("Max"));
1597 text::add_to_layout_box(state, contents, col_4, std::string_view("Profit"));
1598 text::add_to_layout_box(state, contents, row_1, std::string_view(" "));
1599 text::close_layout_box(contents, row_1);
1600
1601 state.world.for_each_commodity([&](dcon::commodity_id c) {
1602 auto rgo_employment = state.world.province_get_rgo_employment_per_good(p, c);
1603 auto current_employment = int64_t(rgo_employment);
1604 auto max_employment = int64_t(economy::rgo_max_employment(state, n, p, c));
1605 auto expected_profit = economy::rgo_expected_worker_norm_profit(state, p, n, c);
1606
1607 if(max_employment < 1.f) {
1608 return;
1609 }
1610 auto base_box = text::open_layout_box(contents);
1611 auto name_box = base_box;
1612 name_box.x_size = 75;
1613 auto employment_box = base_box;
1614 employment_box.x_position += 120.f;
1615 auto max_employment_box = base_box;
1616 max_employment_box.x_position += 180.f;
1617 auto expected_profit_box = base_box;
1618 expected_profit_box.x_position += 250.f;
1619
1621
1622
1623 text::add_to_layout_box(state, contents, employment_box, current_employment);
1624 text::add_to_layout_box(state, contents, max_employment_box, max_employment);
1625 text::add_to_layout_box(state, contents, expected_profit_box, text::format_money(expected_profit));
1626
1627 text::add_to_layout_box(state, contents, base_box, std::string(" "));
1628 text::close_layout_box(contents, base_box);
1629 });
1630
1631 auto rgo_employment = state.world.province_get_subsistence_employment(p);
1632 auto current_employment = int64_t(rgo_employment);
1633 auto max_employment = int64_t(economy::subsistence_max_pseudoemployment(state, n, p));
1634 auto expected_profit = 0.f;
1635
1636 auto base_box = text::open_layout_box(contents);
1637 auto name_box = base_box;
1638 name_box.x_size = 75;
1639 auto employment_box = base_box;
1640 employment_box.x_position += 120.f;
1641 auto max_employment_box = base_box;
1642 max_employment_box.x_position += 180.f;
1643 auto expected_profit_box = base_box;
1644 expected_profit_box.x_position += 250.f;
1645
1646 text::add_to_layout_box(state, contents, name_box, std::string_view("Subsistence"));
1647
1648 text::add_to_layout_box(state, contents, employment_box, current_employment);
1649 text::add_to_layout_box(state, contents, max_employment_box, max_employment);
1650 text::add_to_layout_box(state, contents, expected_profit_box, text::format_money(expected_profit));
1651
1652 text::add_to_layout_box(state, contents, base_box, std::string(" "));
1653 text::close_layout_box(contents, base_box);
1654
1655 active_modifiers_description(state, contents, p, 15, sys::provincial_mod_offsets::mine_rgo_size, false);
1656 if(auto owner = state.world.province_get_nation_from_province_ownership(p); owner)
1657 active_modifiers_description(state, contents, owner, 15, sys::national_mod_offsets::mine_rgo_size, false);
1658 active_modifiers_description(state, contents, p, 15, sys::provincial_mod_offsets::farm_rgo_size, false);
1659 if(auto owner = state.world.province_get_nation_from_province_ownership(p); owner)
1660 active_modifiers_description(state, contents, owner, 15, sys::national_mod_offsets::farm_rgo_size, false);
1661 }
1662};
1663
1665public:
1666 void on_update(sys::state& state) noexcept override {
1667 auto province_id = retrieve<dcon::province_id>(state, parent);
1668 set_text(state, text::format_float(economy::rgo_total_effective_size(state, state.world.province_get_nation_from_province_ownership(province_id), province_id), 2));
1669 }
1670};
1671
1673public:
1674 void on_update(sys::state& state) noexcept override {
1675 auto factory_id = retrieve<dcon::factory_id>(state, parent);
1676 auto flid = state.world.factory_get_factory_location_as_factory(factory_id);
1677 auto pid = state.world.factory_location_get_province(flid);
1678 auto sdef = state.world.province_get_state_from_abstract_state_membership(pid);
1679 dcon::state_instance_id sid{};
1680 state.world.for_each_state_instance([&](dcon::state_instance_id id) {
1681 if(state.world.state_instance_get_definition(id) == sdef)
1682 sid = id;
1683 });
1684 set_text(state, text::get_dynamic_state_name(state, sid));
1685 }
1686};
1688public:
1689 void on_update(sys::state& state) noexcept override {
1690 auto factory_id = retrieve<dcon::factory_id>(state, parent);
1691 auto cid = state.world.factory_get_building_type(factory_id).get_output();
1692 set_text(state, text::get_name_as_string(state, cid));
1693 }
1694};
1696public:
1697 void on_update(sys::state& state) noexcept override {
1698 auto factory_id = retrieve<dcon::factory_id>(state, parent);
1699 set_text(state, text::format_float(state.world.factory_get_actual_production(factory_id), 2));
1700 }
1701};
1703public:
1704 void on_update(sys::state& state) noexcept override {
1705 auto factory_id = retrieve<dcon::factory_id>(state, parent);
1706 set_text(state, text::format_float(state.world.factory_get_full_profit(factory_id), 2));
1707 }
1708};
1710public:
1711 void on_update(sys::state& state) noexcept override {
1712 auto factory_id = retrieve<dcon::factory_id>(state, parent);
1714 }
1715};
1717public:
1718 void on_create(sys::state& state) noexcept override {
1719 base_data.size.x += int16_t(20);
1720 }
1721 void on_update(sys::state& state) noexcept override {
1722 auto factory_id = retrieve<dcon::factory_id>(state, parent);
1723 set_text(state, std::to_string(uint32_t(state.world.factory_get_level(factory_id))));
1724 }
1725};
1727public:
1728 void on_update(sys::state& state) noexcept override {
1729 auto content = retrieve<dcon::factory_id>(state, parent);
1730
1731 auto profit = state.world.factory_get_full_profit(content);
1732 bool is_positive = profit >= 0.f;
1733 auto text = (is_positive ? "+" : "") + text::format_float(profit, 2);
1734 // Create colour
1735 auto contents = text::create_endless_layout(state, internal_layout,
1736 text::layout_parameters{0, 0, static_cast<int16_t>(base_data.size.x), static_cast<int16_t>(base_data.size.y),
1737 base_data.data.text.font_handle, 0, text::alignment::left, text::text_color::black, true});
1738 auto box = text::open_layout_box(contents);
1739 text::add_to_layout_box(state, contents, box, text,
1741 text::close_layout_box(contents, box);
1742 }
1743};
1745public:
1746 void on_update(sys::state& state) noexcept override {
1747 auto content = retrieve<dcon::factory_id>(state, parent);
1748 float profit = state.world.factory_get_full_profit(content);
1749
1750 if(profit > 0.f) {
1751 frame = 0;
1752 } else if (profit < 0.f) {
1753 frame = 1;
1754 } else {
1755 frame = 2; //empty frame
1756 }
1757 }
1758};
1760public:
1761 void on_update(sys::state& state) noexcept override {
1762 auto content = retrieve<dcon::factory_id>(state, parent);
1763 frame = economy::factory_priority(state, content);
1764 }
1765};
1766
1768public:
1769 void on_update(sys::state& state) noexcept override {
1770 frame = int32_t(state.world.commodity_get_icon(retrieve<dcon::commodity_id>(state, parent)));
1771 }
1773 return tooltip_behavior::variable_tooltip;
1774 }
1775
1776 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1777 auto com = retrieve<dcon::commodity_id>(state, parent);
1778 if(!com)
1779 return;
1780
1781 auto n = retrieve<dcon::nation_id>(state, parent);
1782 auto p = retrieve<dcon::province_id>(state, parent);
1783
1784 auto box = text::open_layout_box(contents, 0);
1785 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, state.world.commodity_get_name(com)), text::text_color::yellow);
1786 text::close_layout_box(contents, box);
1787
1788 // Nation modifiers
1789 if(bool(n)) {
1790 auto commodity_mod_description = [&](float value, std::string_view locale_base_name, std::string_view locale_farm_base_name) {
1791 if(value == 0.f)
1792 return;
1793 auto box = text::open_layout_box(contents, 0);
1794 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, state.world.commodity_get_name(com)), text::text_color::white);
1795 text::add_space_to_layout_box(state, contents, box);
1796 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, state.world.commodity_get_is_mine(com) ? locale_base_name : locale_farm_base_name), text::text_color::white);
1797 text::add_to_layout_box(state, contents, box, std::string{ ":" }, text::text_color::white);
1798 text::add_space_to_layout_box(state, contents, box);
1799 auto color = value > 0.f ? text::text_color::green : text::text_color::red;
1800 text::add_to_layout_box(state, contents, box, (value > 0.f ? "+" : "") + text::format_percentage(value, 1), color);
1801 text::close_layout_box(contents, box);
1802 };
1803 commodity_mod_description(state.world.nation_get_factory_goods_output(n, com), "tech_output", "tech_output");
1804 commodity_mod_description(state.world.nation_get_rgo_goods_output(n, com), "tech_mine_output", "tech_farm_output");
1805 commodity_mod_description(state.world.nation_get_rgo_size(n, com), "tech_mine_size", "tech_farm_size");
1806 }
1807 if(state.world.commodity_get_key_factory(com)) {
1808 if(bool(n)) {
1809 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::factory_output, true);
1810 }
1811 if(bool(p)) {
1812 active_modifiers_description(state, contents, p, 0, sys::provincial_mod_offsets::local_factory_output, true);
1813 }
1814 if(bool(n)) {
1815 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::factory_throughput, true);
1816 }
1817 if(bool(p)) {
1818 active_modifiers_description(state, contents, p, 0, sys::provincial_mod_offsets::local_factory_throughput, true);
1819 }
1820 } else {
1821 if(state.world.commodity_get_is_mine(com)) {
1822 if(bool(n)) {
1823 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::mine_rgo_eff, true);
1824 }
1825 if(bool(p)) {
1826 active_modifiers_description(state, contents, p, 0, sys::provincial_mod_offsets::mine_rgo_eff, true);
1827 }
1828 if(bool(n)) {
1829 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::mine_rgo_size, true);
1830 }
1831 if(bool(p)) {
1832 active_modifiers_description(state, contents, p, 0, sys::provincial_mod_offsets::mine_rgo_size, true);
1833 }
1834 } else {
1835 if(bool(n)) {
1836 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::farm_rgo_eff, true);
1837 }
1838 if(bool(p)) {
1839 active_modifiers_description(state, contents, p, 0, sys::provincial_mod_offsets::farm_rgo_eff, true);
1840 }
1841 if(bool(n)) {
1842 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::farm_rgo_size, true);
1843 }
1844 if(bool(p)) {
1845 active_modifiers_description(state, contents, p, 0, sys::provincial_mod_offsets::farm_rgo_size, true);
1846 }
1847 }
1848 }
1849
1850 for(const auto tid : state.world.in_technology) {
1851 if(state.world.nation_get_active_technologies(n, tid)) {
1852 bool have_header = false;
1853 auto commodity_technology_mod_description = [&](auto const& list, std::string_view locale_base_name, std::string_view locale_farm_base_name) {
1854 for(const auto mod : list) {
1855 if(mod.type != com || mod.amount == 0.f)
1856 return;
1857 auto box = text::open_layout_box(contents, 0);
1858 if(!have_header) {
1859 text::add_to_layout_box(state, contents, box, state.world.technology_get_name(tid), text::text_color::yellow);
1861 have_header = true;
1862 }
1863 auto name = state.world.commodity_get_name(mod.type);
1864 text::add_to_layout_box(state, contents, box, name);
1865 text::add_space_to_layout_box(state, contents, box);
1866 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, state.world.commodity_get_is_mine(mod.type) ? locale_base_name : locale_farm_base_name), text::text_color::white);
1867 text::add_to_layout_box(state, contents, box, std::string{ ":" }, text::text_color::white);
1868 text::add_space_to_layout_box(state, contents, box);
1869 auto color = mod.amount > 0.f ? text::text_color::green : text::text_color::red;
1870 text::add_to_layout_box(state, contents, box, (mod.amount > 0.f ? "+" : "") + text::format_percentage(mod.amount, 1), color);
1871 text::close_layout_box(contents, box);
1872 }
1873 };
1874 commodity_technology_mod_description(state.world.technology_get_factory_goods_output(tid), "tech_output", "tech_output");
1875 commodity_technology_mod_description(state.world.technology_get_rgo_goods_output(tid), "tech_mine_output", "tech_farm_output");
1876 commodity_technology_mod_description(state.world.technology_get_rgo_size(tid), "tech_mine_size", "tech_farm_size");
1877 }
1878 }
1879 for(const auto iid : state.world.in_invention) {
1880 if(state.world.nation_get_active_inventions(n, iid)) {
1881 bool have_header = false;
1882 auto commodity_invention_mod_description = [&](auto const& list, std::string_view locale_base_name, std::string_view locale_farm_base_name) {
1883 for(const auto mod : list) {
1884 if(mod.type != com || mod.amount == 0.f)
1885 return;
1886 auto box = text::open_layout_box(contents, 0);
1887 if(!have_header) {
1888 text::add_to_layout_box(state, contents, box, state.world.invention_get_name(iid), text::text_color::yellow);
1890 have_header = true;
1891 }
1892 auto name = state.world.commodity_get_name(mod.type);
1893 text::add_to_layout_box(state, contents, box, name);
1894 text::add_space_to_layout_box(state, contents, box);
1895 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, state.world.commodity_get_is_mine(mod.type) ? locale_base_name : locale_farm_base_name), text::text_color::white);
1896 text::add_to_layout_box(state, contents, box, std::string{ ":" }, text::text_color::white);
1897 text::add_space_to_layout_box(state, contents, box);
1898 auto color = mod.amount > 0.f ? text::text_color::green : text::text_color::red;
1899 text::add_to_layout_box(state, contents, box, (mod.amount > 0.f ? "+" : "") + text::format_percentage(mod.amount, 1), color);
1900 text::close_layout_box(contents, box);
1901 }
1902 };
1903 commodity_invention_mod_description(state.world.invention_get_factory_goods_output(iid), "tech_output", "tech_output");
1904 commodity_invention_mod_description(state.world.invention_get_rgo_goods_output(iid), "tech_mine_output", "tech_farm_output");
1905 commodity_invention_mod_description(state.world.invention_get_rgo_size(iid), "tech_mine_size", "tech_farm_size");
1906 }
1907 }
1908 }
1909};
1910
1911// -----------------------------------------------------------------------------
1912// National focuses
1913
1915
1917public:
1918 void on_update(sys::state& state) noexcept override {
1919 auto nfid = retrieve<dcon::national_focus_id>(state, parent);
1920 auto sid = retrieve<dcon::state_instance_id>(state, parent);
1921 disabled = !command::can_set_national_focus(state, state.local_player_nation, sid, nfid);
1922 frame = state.world.national_focus_get_icon(nfid) - 1;
1923 }
1924
1926 return tooltip_behavior::variable_tooltip;
1927 }
1928
1929 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1930 auto content = retrieve<dcon::national_focus_id>(state, parent);
1931 if(bool(content)) {
1932 auto sid = retrieve<dcon::state_instance_id>(state, parent);
1933 auto fat_si = dcon::fatten(state.world, sid);
1934 auto fat_nf = dcon::fatten(state.world, content);
1935
1936 auto box = text::open_layout_box(contents, 0);
1937 text::add_to_layout_box(state, contents, box, sid);
1939 text::add_to_layout_box(state, contents, box, state.world.national_focus_get_name(content), text::substitution_map{});
1941 auto color = text::text_color::white;
1942 if(fat_nf.get_promotion_type()) {
1943 //Is the NF not optimal? Recolor it
1944 if(fat_nf.get_promotion_type() == state.culture_definitions.clergy) {
1945 if((fat_si.get_demographics(demographics::to_key(state, fat_nf.get_promotion_type())) / fat_si.get_demographics(demographics::total)) > state.defines.max_clergy_for_literacy) {
1946 color = text::text_color::red;
1947 }
1948 } else if(fat_nf.get_promotion_type() == state.culture_definitions.bureaucrat) {
1949 if(province::state_admin_efficiency(state, fat_si.id) >= 1.f) {
1950 color = text::text_color::red;
1951 }
1952 }
1953 auto full_str = text::format_percentage(fat_si.get_demographics(demographics::to_key(state, fat_nf.get_promotion_type())) / fat_si.get_demographics(demographics::total));
1954 text::add_to_layout_box(state, contents, box, std::string_view(full_str), color);
1955 }
1956 text::close_layout_box(contents, box);
1957 if(auto mid = state.world.national_focus_get_modifier(content); mid) {
1958 modifier_description(state, contents, mid, 15);
1959 }
1960 auto state_cap = state.world.state_instance_get_capital(sid);
1961 ui::trigger_description(state, contents, state.world.national_focus_get_limit(content), trigger::to_generic(state_cap), trigger::to_generic(state.local_player_nation), -1);
1962 }
1963 }
1964
1965 void button_action(sys::state& state) noexcept override {
1966 auto content = retrieve<dcon::state_instance_id>(state, parent);
1967 auto nat_focus = retrieve<dcon::national_focus_id>(state, parent);
1968 command::set_national_focus(state, state.local_player_nation, content, nat_focus);
1970 }
1971};
1972
1973class national_focus_item : public listbox_row_element_base<dcon::national_focus_id> {
1974public:
1975 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1976 if(name == "focus_icon") {
1977 return make_element_by_type<national_focus_icon>(state, id);
1978 } else {
1979 return nullptr;
1980 }
1981 }
1982};
1983
1984class national_focus_category_list : public overlapping_listbox_element_base<national_focus_item, dcon::national_focus_id> {
1985public:
1986 std::string_view get_row_element_name() override {
1987 return "focus_item";
1988 }
1989};
1990
1992private:
1993 simple_text_element_base* category_label = nullptr;
1994 national_focus_category_list* focus_list = nullptr;
1995
1996public:
1997 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1998 if(name == "name") {
1999 auto ptr = make_element_by_type<simple_text_element_base>(state, id);
2000 category_label = ptr.get();
2001 return ptr;
2002 } else if(name == "focus_icons") {
2003 auto ptr = make_element_by_type<national_focus_category_list>(state, id);
2004 focus_list = ptr.get();
2005 return ptr;
2006 } else {
2007 return nullptr;
2008 }
2009 }
2010
2011 message_result set(sys::state& state, Cyto::Any& payload) noexcept override {
2012 if(payload.holds_type<nations::focus_type>()) {
2013 auto category = any_cast<nations::focus_type>(payload);
2014 if(category_label)
2015 category_label->set_text(state, text::get_focus_category_name(state, category));
2016
2017 if(focus_list) {
2018 focus_list->row_contents.clear();
2019 state.world.for_each_national_focus([&](dcon::national_focus_id focus_id) {
2020 auto fat_id = dcon::fatten(state.world, focus_id);
2021 if(fat_id.get_type() == uint8_t(category))
2022 focus_list->row_contents.push_back(focus_id);
2023 });
2024 focus_list->update(state);
2025 }
2026 return message_result::consumed;
2027 } else {
2028 return message_result::unseen;
2029 }
2030 }
2031};
2032
2034public:
2035 void button_action(sys::state& state) noexcept override {
2036 auto content = retrieve<dcon::state_instance_id>(state, parent);
2037 command::set_national_focus(state, state.local_player_nation, content, dcon::national_focus_id{});
2039 }
2040};
2041
2043public:
2044 void on_create(sys::state& state) noexcept override {
2045 window_element_base::on_create(state);
2046 auto start = make_element_by_type<window_element_base>(state, "focuscategory_start");
2047 auto current_pos = start->base_data.position;
2048 auto step = make_element_by_type<window_element_base>(state, "focuscategory_step");
2049 auto step_y = step->base_data.position.y;
2050
2052 auto ptr = make_element_by_type<national_focus_category>(state, "focus_category");
2053 ptr->base_data.position = current_pos;
2054 current_pos = xy_pair{current_pos.x, int16_t(current_pos.y + step_y)};
2055
2056 Cyto::Any foc_type_payload = nations::focus_type(i);
2057 ptr->impl_set(state, foc_type_payload);
2058
2059 add_child_to_front(std::move(ptr));
2060 }
2061 }
2062
2063 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
2064 if(name == "close_button") {
2065 return make_element_by_type<generic_close_button>(state, id);
2066 } else if(name == "background") {
2067 return make_element_by_type<draggable_target>(state, id);
2068 } else if(name == "cancel_button") {
2069 return make_element_by_type<national_focus_remove_button>(state, id);
2070 } else {
2071 return nullptr;
2072 }
2073 }
2074 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
2075 if(payload.holds_type<close_focus_window_notification>()) {
2076 set_visible(state, false);
2077 return message_result::consumed;
2078 }
2079 return window_element_base::get(state, payload);
2080 }
2081};
2082
2084public:
2085 void on_update(sys::state& state) noexcept override {
2086 auto content = retrieve<military::wg_summary>(state, parent).cb;
2087 frame = state.world.cb_type_get_sprite_index(content) - 1;
2088 }
2089
2091 return tooltip_behavior::variable_tooltip;
2092 }
2093
2094 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
2095 auto wg = retrieve<military::wg_summary>(state, parent);
2096 text::add_line(state, contents, state.world.cb_type_get_name(wg.cb));
2097
2099 if(wg.state) {
2100 text::add_line(state, contents, "war_goal_3", text::variable_type::x, wg.state);
2101 }
2102 if(wg.wg_tag) {
2103 text::add_line(state, contents, "war_goal_4", text::variable_type::x, wg.wg_tag);
2104 } else if(wg.secondary_nation) {
2105 text::add_line(state, contents, "war_goal_4", text::variable_type::x, wg.secondary_nation);
2106 }
2107 }
2108};
2109
2110class overlapping_wg_icon : public listbox_row_element_base<military::wg_summary> {
2111public:
2112 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
2113 if(name == "wargoal_icon") {
2114 return make_element_by_type<wg_icon>(state, id);
2115 } else {
2116 return nullptr;
2117 }
2118 }
2119};
2120
2122public:
2123 void on_update(sys::state& state) noexcept override {
2124 auto content = retrieve<military::full_wg>(state, parent).cb;
2125 frame = state.world.cb_type_get_sprite_index(content) - 1;
2126 }
2127
2129 return tooltip_behavior::variable_tooltip;
2130 }
2131
2132 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
2133 auto wg = retrieve<military::full_wg>(state, parent);
2134 text::add_line(state, contents, state.world.cb_type_get_name(wg.cb));
2135
2137 text::add_line(state, contents, "war_goal_1", text::variable_type::x, wg.added_by);
2138 text::add_line(state, contents, "war_goal_2", text::variable_type::x, wg.target_nation);
2139 if(wg.state) {
2140 text::add_line(state, contents, "war_goal_3", text::variable_type::x, wg.state);
2141 }
2142 if(wg.wg_tag) {
2143 text::add_line(state, contents, "war_goal_4", text::variable_type::x, wg.wg_tag);
2144 } else if(wg.secondary_nation) {
2145 text::add_line(state, contents, "war_goal_4", text::variable_type::x, wg.secondary_nation);
2146 }
2147 }
2148};
2149
2150class overlapping_full_wg_icon : public listbox_row_element_base<military::full_wg> {
2151public:
2152 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
2153 if(name == "wargoal_icon") {
2154 return make_element_by_type<full_wg_icon>(state, id);
2155 } else {
2156 return nullptr;
2157 }
2158 }
2159};
2160
2162public:
2163 void on_create(sys::state& state) noexcept override {
2164 button_element_base::on_create(state);
2165 frame = 1;
2166 }
2167
2168 void on_update(sys::state& state) noexcept override {
2169 auto content = retrieve<dcon::state_instance_id>(state, parent);
2170 disabled = !command::can_upgrade_colony_to_state(state, state.local_player_nation, content);
2171 }
2172
2173 void button_action(sys::state& state) noexcept override {
2174 auto content = retrieve<dcon::state_instance_id>(state, parent);
2175 command::upgrade_colony_to_state(state, state.local_player_nation, content);
2176 }
2177
2179 return tooltip_behavior::variable_tooltip;
2180 }
2181
2182 void update_tooltip(sys::state& state, int32_t x, int32_t t, text::columnar_layout& contents) noexcept override {
2183 auto state_instance_id = retrieve<dcon::state_instance_id>(state, parent);
2184
2185 auto box = text::open_layout_box(contents, 0);
2186 text::localised_format_box(state, contents, box, std::string_view("pw_colony"));
2187 text::add_divider_to_layout_box(state, contents, box);
2188
2190 text::add_to_substitution_map(sub1, text::variable_type::num, text::fp_one_place{ state.defines.state_creation_admin_limit * 100.f });
2191 float total_pop = state.world.state_instance_get_demographics(state_instance_id, demographics::total);
2192 float b_size = province::state_accepted_bureaucrat_size(state, state_instance_id);
2194 text::localised_format_box(state, contents, box, std::string_view("pw_colony_no_state"), sub1);
2198 text::localised_format_box(state, contents, box, std::string_view("pw_cant_upgrade_to_state"), sub2);
2199
2200 text::close_layout_box(contents, box);
2201 }
2202};
2203
2205 country_list_filter general_category = country_list_filter::all;
2206 dcon::modifier_id continent;
2207};
2209 country_list_sort sort = country_list_sort::country;
2210 bool sort_ascend = true;
2211};
2212
2213template<country_list_filter category>
2215public:
2216 void button_action(sys::state& state) noexcept final {
2217 send(state, parent, category);
2218 if constexpr(category == country_list_filter::all) {
2219 send(state, parent, dcon::modifier_id{});
2220 }
2221 }
2222
2223 void button_right_action(sys::state& state) noexcept final {
2224 if constexpr(category == country_list_filter::allies) {
2225 send(state, parent, country_list_filter::find_allies);
2226 } else if constexpr(category == country_list_filter::sphere) {
2227 send(state, parent, country_list_filter::influenced);
2228 } else if constexpr(category == country_list_filter::neighbors) {
2229 send(state, parent, country_list_filter::neighbors_no_vassals);
2230 } else {
2231 send(state, parent, category);
2232 if constexpr(category == country_list_filter::all) {
2233 send(state, parent, dcon::modifier_id{});
2234 }
2235 }
2236 }
2237
2238 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
2239 auto filter_settings = retrieve<country_filter_setting>(state, parent);
2240 auto t_category = filter_settings.general_category;
2241 switch(t_category) {
2242 case country_list_filter::influenced:
2243 t_category = country_list_filter::sphere;
2244 break;
2245 case country_list_filter::find_allies:
2246 t_category = country_list_filter::allies;
2247 break;
2248 case country_list_filter::neighbors_no_vassals:
2249 t_category = country_list_filter::neighbors;
2250 break;
2251 default:
2252 break;
2253 }
2254 disabled = t_category != category;
2255 button_element_base::render(state, x, y);
2256 disabled = false;
2257 }
2258
2260 return tooltip_behavior::variable_tooltip;
2261 }
2262
2263 void update_tooltip(sys::state& state, int32_t x, int32_t t, text::columnar_layout& contents) noexcept override {
2264 switch(category) {
2265 case country_list_filter::all:
2266 text::add_line(state, contents, "filter_all");
2267 break;
2268 case country_list_filter::neighbors:
2269 case country_list_filter::neighbors_no_vassals:
2270 text::add_line(state, contents, "filter_neighbors");
2271 break;
2272 case country_list_filter::sphere:
2273 case country_list_filter::influenced:
2274 text::add_line(state, contents, "filter_sphere");
2275 break;
2276 case country_list_filter::enemies:
2277 text::add_line(state, contents, "filter_enemies");
2278 break;
2279 case country_list_filter::find_allies:
2280 case country_list_filter::allies:
2281 text::add_line(state, contents, "filter_allies");
2282 break;
2283 case country_list_filter::best_guess:
2284 text::add_line(state, contents, "filter_best_guess");
2285 break;
2286 default:
2287 break;
2288 }
2289 }
2290};
2291
2293public:
2294 dcon::modifier_id continent;
2295
2296 void button_action(sys::state& state) noexcept final {
2297 send(state, parent, continent);
2298 }
2299
2300 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
2301 auto filter_settings = retrieve<country_filter_setting>(state, parent);
2302 disabled = filter_settings.continent != continent;
2303 button_element_base::render(state, x, y);
2304 disabled = false;
2305 }
2306};
2307
2309 void button_action(sys::state& state) noexcept final {
2311 }
2312};
2313
2315 void button_action(sys::state& state) noexcept final {
2317 }
2318
2319 void on_update(sys::state& state) noexcept override {
2320 if(state.selected_army_group) {
2321 disabled = false;
2322 } else {
2323 disabled = true;
2324 }
2325 }
2326};
2327
2329 void button_action(sys::state& state) noexcept final {
2331 }
2332};
2333
2334} // namespace ui
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void button_right_action(sys::state &state) noexcept final
void button_action(sys::state &state) noexcept final
void update_tooltip(sys::state &state, int32_t x, int32_t t, text::columnar_layout &contents) 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 button_action(sys::state &state) noexcept final
void button_action(sys::state &state) noexcept override
element_base * parent
virtual message_result get(sys::state &state, Cyto::Any &payload) noexcept
element_data base_data
void on_reset_text(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
void on_update(sys::state &state) 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
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 on_update(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 set_type(sys::state &state, dcon::pop_type_id t)
void button_action(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
virtual void set_current_nation(sys::state &state, dcon::national_identity_id identity) noexcept
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 void populate_layout(sys::state &state, text::endless_layout &contents, T id) noexcept
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
message_result set(sys::state &state, Cyto::Any &payload) 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
void populate_layout(sys::state &state, text::endless_layout &contents, dcon::movement_id movement_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
std::string get_text(sys::state &state, dcon::movement_id movement_id) noexcept override
std::string get_text(sys::state &state, dcon::movement_id movement_id) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
int32_t get_icon_frame(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
int32_t get_icon_frame(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
int32_t get_icon_frame(sys::state &state, dcon::nation_id nation_id) noexcept override
int32_t get_icon_frame(sys::state &state, dcon::nation_id nation_id) 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
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
dcon::national_identity_id get_current_nation(sys::state &state) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
void on_update(sys::state &state) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) 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
std::string get_text(sys::state &state, dcon::nation_id nation_id) 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
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) 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
tooltip_behavior has_tooltip(sys::state &state) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
dcon::national_identity_id get_current_nation(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 button_action(sys::state &state) noexcept override
dcon::national_identity_id get_current_nation(sys::state &state) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
void on_update(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
std::string get_text(sys::state &state, dcon::nation_id nation_id) 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
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
std::string get_text(sys::state &state, dcon::nation_id nation_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
tooltip_behavior has_tooltip(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
std::string get_text(sys::state &state, dcon::nation_id nation_id) 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
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 set(sys::state &state, Cyto::Any &payload) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void button_action(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
tooltip_behavior has_tooltip(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 button_action(sys::state &state) 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
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 update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) 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
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
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t t, text::columnar_layout &contents) 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 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
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 on_update(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
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 on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
virtual void populate_layout(sys::state &state, text::endless_layout &contents) noexcept
void on_update(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
virtual void populate_layout(sys::state &state, text::endless_layout &contents) noexcept
void on_update(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void set_text(sys::state &state, std::string const &new_text)
void on_reset_text(sys::state &state) noexcept override
virtual void populate_layout(sys::state &state, text::endless_layout &contents, dcon::movement_id movement_id) noexcept
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
virtual std::string get_text(sys::state &state, dcon::movement_id movement_id) noexcept
void on_update(sys::state &state) noexcept override
virtual int32_t get_icon_frame(sys::state &state, dcon::nation_id nation_id) noexcept
void on_update(sys::state &state) noexcept override
virtual int32_t get_icon_frame(sys::state &state, dcon::nation_id nation_id) noexcept
virtual std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
virtual std::string get_text(sys::state &state, dcon::rebel_faction_id rebel_faction_id) noexcept
virtual int32_t get_icon_frame(sys::state &state, dcon::state_instance_id state_instance_id) noexcept
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 on_update(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 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 update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
bool can_upgrade_colony_to_state(sys::state &state, dcon::nation_id source, dcon::state_instance_id si)
Definition: commands.cpp:1547
bool can_set_national_focus(sys::state &state, dcon::nation_id source, dcon::state_instance_id target_state, dcon::national_focus_id focus)
Definition: commands.cpp:118
void set_national_focus(sys::state &state, dcon::nation_id source, dcon::state_instance_id target_state, dcon::national_focus_id focus)
Definition: commands.cpp:107
float effective_technology_cost(sys::state &state, uint32_t current_year, dcon::nation_id target_nation, dcon::technology_id tech_id)
Definition: culture.cpp:904
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
float calculate_nation_sol(sys::state &state, dcon::nation_id nation_id)
constexpr dcon::demographics_key total(0)
dcon::demographics_key to_key(sys::state const &state, dcon::pop_type_id v)
constexpr dcon::demographics_key consciousness(3)
dcon::demographics_key to_employment_key(sys::state const &state, dcon::pop_type_id v)
constexpr dcon::demographics_key literacy(5)
constexpr dcon::demographics_key militancy(4)
float rgo_total_effective_size(sys::state &state, dcon::nation_id n, dcon::province_id p)
Definition: economy.cpp:930
int32_t state_factory_count(sys::state &state, dcon::state_instance_id sid, dcon::nation_id n)
Definition: economy.cpp:4892
float gdp_adjusted(sys::state &state, dcon::nation_id n)
Definition: economy.cpp:103
int32_t factory_priority(sys::state const &state, dcon::factory_id f)
Definition: economy.cpp:1003
float rgo_expected_worker_norm_profit(sys::state &state, dcon::province_id p, dcon::nation_id n, dcon::commodity_id c)
Definition: economy.cpp:1777
float subsistence_max_pseudoemployment(sys::state &state, dcon::nation_id n, dcon::province_id p)
Definition: economy.cpp:938
float rgo_max_employment(sys::state &state, dcon::nation_id n, dcon::province_id p, dcon::commodity_id c)
Definition: economy.cpp:950
float factory_total_employment(sys::state const &state, dcon::factory_id f)
Definition: economy.cpp:1120
float interest_payment(sys::state &state, dcon::nation_id n)
Definition: economy.cpp:62
void switch_scene(sys::state &state, scene_id ui_scene)
Definition: game_scene.cpp:13
int32_t naval_supply_points_used(sys::state &state, dcon::nation_id n)
Definition: military.cpp:1074
int32_t total_regiments(sys::state &state, dcon::nation_id n)
Definition: military.cpp:24
int32_t mobilized_regiments_possible_from_province(sys::state &state, dcon::province_id p)
Definition: military.cpp:959
int32_t total_ships(sys::state &state, dcon::nation_id n)
Definition: military.cpp:27
int32_t naval_supply_points(sys::state &state, dcon::nation_id n)
Definition: military.cpp:1071
status get_status(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:580
int32_t free_colonial_points(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:739
bool has_political_reform_available(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:805
float get_foreign_investment(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:314
focus_type
Definition: nations.hpp:40
float diplomatic_points(sys::state const &state, dcon::nation_id n)
Definition: nations.cpp:645
bool has_social_reform_available(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:817
float get_debt(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1050
float suppression_points(sys::state const &state, dcon::nation_id n)
Definition: nations.cpp:610
dcon::nation_id get_nth_great_power(sys::state const &state, uint16_t n)
Definition: nations.cpp:57
float prestige_score(sys::state const &state, dcon::nation_id n)
Definition: nations.cpp:396
float leadership_points(sys::state const &state, dcon::nation_id n)
Definition: nations.cpp:614
float daily_research_points(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:254
float get_bank_funds(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1046
sys::date get_research_end_date(sys::state &state, dcon::technology_id tech_id, dcon::nation_id n)
Definition: nations.cpp:599
int32_t national_focuses_in_use(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:634
dcon::technology_id current_research(sys::state const &state, dcon::nation_id n)
Definition: nations.cpp:606
int32_t max_national_focuses(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:618
float get_treasury(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1042
int32_t max_colonial_points(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:747
float pop_vote_weight(sys::state &state, dcon::pop_id p, dcon::nation_id n)
Definition: politics.cpp:450
float get_military_reform_multiplier(sys::state &state, dcon::nation_id n)
Definition: politics.cpp:263
float get_economic_reform_multiplier(sys::state &state, dcon::nation_id n)
Definition: politics.cpp:278
dcon::pop_demographics_key to_key(sys::state const &state, dcon::ideology_id v)
void for_each_province_in_state_instance(sys::state &state, dcon::state_instance_id s, F const &func)
float state_accepted_bureaucrat_size(sys::state &state, dcon::state_instance_id id)
Definition: province.cpp:490
float rgo_production_quantity(sys::state &state, dcon::province_id id, dcon::commodity_id c)
Definition: province.cpp:473
float land_employment(sys::state &state, dcon::province_id id)
Definition: province.cpp:459
float rgo_income(sys::state &state, dcon::province_id id)
Definition: province.cpp:470
float colony_integration_cost(sys::state &state, dcon::state_instance_id id)
Definition: province.cpp:609
float state_admin_efficiency(sys::state &state, dcon::state_instance_id id)
Definition: province.cpp:503
Definition: bmfont.cpp:118
void add_line_break_to_layout_box(sys::state &state, layout_base &dest, layout_box &box)
Definition: text.cpp:1147
void add_to_layout_box(sys::state &state, layout_base &dest, layout_box &box, embedded_flag ico)
Definition: text.cpp:1165
std::string format_money(float num)
Definition: text.cpp:1029
std::string get_focus_category_name(sys::state const &state, nations::focus_type category)
Definition: text.cpp:909
std::string get_name_as_string(sys::state &state, T t)
Definition: text.hpp:954
std::string format_ratio(int32_t left, int32_t right)
Definition: text.cpp:1064
layout_box open_layout_box(layout_base &dest, int32_t indent)
Definition: text.cpp:1799
alignment
Definition: text.hpp:36
void localised_single_sub_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view key, variable_type subkey, substitution value)
Definition: text.cpp:1888
void localised_format_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view key, text::substitution_map const &sub)
Definition: text.cpp:1880
bool is_black_from_font_id(uint16_t id)
Definition: fonts.cpp:127
std::string prettify(int64_t num)
Definition: text.cpp:762
endless_layout create_endless_layout(sys::state &state, layout &dest, layout_parameters const &params)
Definition: text.cpp:1100
std::string format_float(float num, size_t digits)
Definition: text.cpp:981
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
Definition: text.cpp:1899
std::string get_short_state_name(sys::state &state, dcon::state_instance_id state_id)
Definition: text.cpp:821
void add_line_with_condition(sys::state &state, layout_base &dest, std::string_view key, bool condition_met, int32_t indent)
Definition: text.cpp:1955
void add_line_break_to_layout(sys::state &state, columnar_layout &dest)
Definition: text.cpp:1152
void add_to_substitution_map(substitution_map &mp, variable_type key, substitution value)
Definition: text.cpp:1068
void add_divider_to_layout_box(sys::state &state, layout_base &dest, layout_box &box)
Definition: text.cpp:2098
dcon::text_key get_adjective(sys::state &state, dcon::nation_id id)
Definition: text.cpp:890
std::string get_dynamic_state_name(sys::state &state, dcon::state_instance_id state_id)
Definition: text.cpp:837
ankerl::unordered_dense::map< uint32_t, substitution > substitution_map
Definition: text.hpp:794
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
Definition: text.cpp:617
std::string get_adjective_as_string(sys::state &state, T t)
Definition: text.hpp:958
std::string format_percentage(float num, size_t digits)
Definition: text.cpp:977
std::string get_influence_level_name(sys::state const &state, uint8_t v)
Definition: text.cpp:958
void add_space_to_layout_box(sys::state &state, layout_base &dest, layout_box &box)
Definition: text.cpp:1788
std::string get_province_state_name(sys::state &state, dcon::province_id prov_id)
Definition: text.cpp:864
void close_layout_box(columnar_layout &dest, layout_box &box)
Definition: text.cpp:1807
int32_t to_generic(dcon::province_id v)
Definition: triggers.hpp:12
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)
void sort_countries(sys::state &state, std::vector< dcon::nation_id > &list, country_list_sort sort, bool sort_ascend)
tooltip_behavior
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)
@ country
Definition: gui_event.hpp:122
@ count
Definition: gui_event.hpp:126
std::variant< std::monostate, dcon::nation_id, dcon::state_instance_id, dcon::province_id > pop_list_filter
message_result
std::string get_status_text(sys::state &state, dcon::nation_id nation_id)
void open_foreign_investment(sys::state &state, dcon::nation_id n)
void open_build_foreign_factory(sys::state &state, dcon::state_instance_id st)
bool country_category_filter_check(sys::state &state, country_list_filter filt, dcon::nation_id a, dcon::nation_id b)
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)
uint uint32_t
uchar uint8_t
int32_t x_size
Definition: text.hpp:827
float x_position
Definition: text.hpp:830
element_type get_element_type() const
union ui::element_data::internal_data data
alignment get_alignment() const
xy_pair border_size