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
1245 return tooltip_behavior::tooltip;
1246 }
1247
1248 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1249 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1250
1251 auto box = text::open_layout_box(contents, 0);
1252
1253 auto val = politics::get_military_reform_multiplier(state, nation_id) - 1.0f;
1254 text::add_line(state, contents, "alice_unciv_reform_cost", text::variable_type::x, text::fp_percentage_one_place{ val });
1255 }
1256};
1257
1259public:
1260 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1261 return int32_t(politics::get_economic_reform_multiplier(state, nation_id) >= 0.f);
1262 }
1263
1265 return tooltip_behavior::tooltip;
1266 }
1267
1268 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1269 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1270
1271 auto box = text::open_layout_box(contents, 0);
1272
1273 auto val = politics::get_economic_reform_multiplier(state, nation_id) - 1.0f;
1274 text::add_line(state, contents, "alice_unciv_reform_cost", text::variable_type::x, text::fp_percentage_one_place{ val });
1275 }
1276};
1277
1279public:
1280 void on_update(sys::state& state) noexcept override {
1281 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1282 auto ruling_party = state.world.nation_get_ruling_party(nation_id);
1283 auto ideology = state.world.political_party_get_ideology(ruling_party);
1284 color = state.world.ideology_get_color(ideology);
1285 }
1286};
1287
1289public:
1290 dcon::national_identity_id get_current_nation(sys::state& state) noexcept override {
1291 auto fat_id = dcon::fatten(state.world, state.local_player_nation);
1292 return fat_id.get_identity_from_identity_holder();
1293 }
1294};
1295
1297public:
1298 uint16_t rank = 0;
1299 dcon::national_identity_id get_current_nation(sys::state& state) noexcept override {
1300 auto const nat_id = nations::get_nth_great_power(state, rank);
1301 if(!bool(nat_id))
1302 return dcon::national_identity_id{};
1303 auto fat_id = dcon::fatten(state.world, nat_id);
1304 return fat_id.get_identity_from_identity_holder();
1305 }
1306};
1307
1309public:
1310 void on_update(sys::state& state) noexcept override {
1311 auto ideology_id = retrieve<dcon::ideology_id>(state, parent);
1312 color = state.world.ideology_get_color(ideology_id);
1313 }
1314};
1315
1317public:
1318 void on_update(sys::state& state) noexcept override {
1319 auto province = retrieve<dcon::province_id>(state, parent);
1320 auto nation = retrieve<dcon::nation_id>(state, parent);
1321
1322 if(province) {
1323 auto fat_id = dcon::fatten(state.world, province);
1324 if(fat_id.get_province_ownership().get_nation().get_is_mobilized()) {
1325 frame = 1;
1326 } else {
1327 frame = 0;
1328 }
1329 } else if (nation) {
1330 auto fat_id = dcon::fatten(state.world, nation);
1331 if(fat_id.get_is_mobilized()) {
1332 frame = 1;
1333 } else {
1334 frame = 0;
1335 }
1336 }
1337
1338 }
1339};
1340
1342public:
1343 dcon::pop_type_id type{};
1344
1345 void set_type(sys::state& state, dcon::pop_type_id t) {
1346 type = t;
1347 frame = int32_t(state.world.pop_type_get_sprite(t) - 1);
1348 }
1349
1351 return tooltip_behavior::tooltip;
1352 }
1353
1354 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1355 auto name = state.world.pop_type_get_name(type);
1356 auto box = text::open_layout_box(contents, 0);
1357 text::add_to_layout_box(state, contents, box, name);
1358 text::close_layout_box(contents, box);
1359 }
1360};
1361
1363public:
1364 void on_update(sys::state& state) noexcept override {
1365 auto content = retrieve<dcon::pop_type_id>(state, parent);
1366 auto fat_id = dcon::fatten(state.world, content);
1367 frame = int32_t(fat_id.get_sprite() - 1);
1368 }
1369
1371 return tooltip_behavior::variable_tooltip;
1372 }
1373
1374 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1375 auto content = retrieve<dcon::pop_type_id>(state, parent);
1376 auto name = state.world.pop_type_get_name(content);
1377 auto box = text::open_layout_box(contents, 0);
1378 text::add_to_layout_box(state, contents, box, name);
1379 text::close_layout_box(contents, box);
1380 }
1381};
1383public:
1384 void on_update(sys::state& state) noexcept override {
1385 auto content = retrieve<dcon::religion_id>(state, parent);
1386 auto fat_id = dcon::fatten(state.world, content);
1387 frame = int32_t(fat_id.get_icon() - 1);
1388 }
1389};
1390
1392public:
1393 void on_update(sys::state& state) noexcept override {
1394 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1395 auto ideology_id = retrieve<dcon::ideology_id>(state, parent);
1396 if(nation_id && ideology_id) {
1397 auto percentage = .01f * state.world.nation_get_upper_house(nation_id, ideology_id);
1398 set_text(state, text::format_percentage(percentage, 1));
1399 }
1400 }
1401};
1402
1403class upper_house_piechart : public piechart<dcon::ideology_id> {
1404protected:
1405 void on_update(sys::state& state) noexcept override {
1406 auto nat_id = retrieve<dcon::nation_id>(state, parent);
1407 distribution.clear();
1408 for(auto id : state.world.in_ideology) {
1409 distribution.emplace_back(id.id, float(state.world.nation_get_upper_house(nat_id, id)));
1410 }
1411 update_chart(state);
1412 }
1413};
1414
1415class voter_ideology_piechart : public piechart<dcon::ideology_id> {
1416protected:
1417 void on_update(sys::state& state) noexcept override {
1418 auto nat_id = retrieve<dcon::nation_id>(state, parent);
1419 distribution.clear();
1420 for(auto id : state.world.in_ideology) {
1421 distribution.emplace_back(id.id, 0.0f);
1422 }
1423 for(auto p : state.world.nation_get_province_ownership(nat_id)) {
1424 for(auto pop_loc : state.world.province_get_pop_location(p.get_province())) {
1425 auto pop_id = pop_loc.get_pop();
1426 float vote_size = politics::pop_vote_weight(state, pop_id, nat_id);
1427 if(vote_size > 0) {
1428 state.world.for_each_ideology([&](dcon::ideology_id iid) {
1429 auto dkey = pop_demographics::to_key(state, iid);
1430 distribution[iid.index()].value += pop_demographics::get_demo(state, pop_id.id, dkey) * vote_size;
1431 });
1432 }
1433 }
1434 }
1435
1436 update_chart(state);
1437 }
1438};
1439
1441public:
1442 void on_update(sys::state& state) noexcept override {
1443 auto province_id = retrieve<dcon::province_id>(state, parent);
1444 auto total_pop = state.world.province_get_demographics(province_id, demographics::total);
1445 set_text(state, text::prettify(int32_t(total_pop)));
1446 }
1447};
1448
1450public:
1451 void on_update(sys::state& state) noexcept override {
1452 auto province_id = retrieve<dcon::province_id>(state, parent);
1453 auto militancy = state.world.province_get_demographics(province_id, demographics::militancy);
1454 auto total_pop = state.world.province_get_demographics(province_id, demographics::total);
1455 set_text(state, text::format_float(militancy / total_pop));
1456 }
1457};
1458
1460public:
1461 void on_update(sys::state& state) noexcept override {
1462 auto province_id = retrieve<dcon::province_id>(state, parent);
1463 auto consciousness = state.world.province_get_demographics(province_id, demographics::consciousness);
1464 auto total_pop = state.world.province_get_demographics(province_id, demographics::total);
1465 set_text(state, text::format_float(consciousness / total_pop));
1466 }
1467};
1468
1470public:
1471 void on_update(sys::state& state) noexcept override {
1472 auto province_id = retrieve<dcon::province_id>(state, parent);
1473 auto literacy = state.world.province_get_demographics(province_id, demographics::literacy);
1474 auto total_pop = state.world.province_get_demographics(province_id, demographics::total);
1475 set_text(state, text::format_percentage(literacy / total_pop, 1));
1476 }
1477};
1478
1479
1481public:
1482 void on_update(sys::state& state) noexcept override {
1483 auto province_id = retrieve<dcon::province_id>(state, parent);
1484 set_text(state, text::get_name_as_string(state, state.world.province_get_dominant_culture(province_id)));
1485 }
1486};
1488public:
1489 void on_update(sys::state& state) noexcept override {
1490 auto province_id = retrieve<dcon::province_id>(state, parent);
1491 set_text(state, text::get_name_as_string(state, state.world.province_get_dominant_religion(province_id)));
1492 }
1493};
1495public:
1496 void on_update(sys::state& state) noexcept override {
1497 auto province_id = retrieve<dcon::province_id>(state, parent);
1498 set_text(state, text::get_name_as_string(state, state.world.province_get_dominant_issue_option(province_id)));
1499 }
1500};
1502public:
1503 void on_update(sys::state& state) noexcept override {
1504 auto province_id = retrieve<dcon::province_id>(state, parent);
1505 set_text(state, text::get_name_as_string(state, state.world.province_get_dominant_ideology(province_id)));
1506 }
1507};
1508
1510public:
1511 void on_update(sys::state& state) noexcept override {
1512 auto province_id = retrieve<dcon::province_id>(state, parent);
1513 set_text(state, text::get_province_state_name(state, province_id));
1514 }
1515};
1516
1518public:
1519 void on_update(sys::state& state) noexcept override {
1520 auto province_id = retrieve<dcon::province_id>(state, parent);
1521 set_text(state, text::get_name_as_string(state, state.world.province_get_rgo(province_id)));
1522 }
1523};
1524
1526public:
1527 void on_update(sys::state& state) noexcept override {
1528 auto province_id = retrieve<dcon::province_id>(state, parent);
1529 set_text(state, text::format_float(province::rgo_production_quantity(state, province_id, state.world.province_get_rgo(province_id)), 3));
1530 }
1531
1532 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1533 auto p = retrieve<dcon::province_id>(state, parent);
1534
1535 auto n = state.world.province_get_nation_from_province_ownership(p);
1536
1537 state.world.for_each_commodity([&](dcon::commodity_id c) {
1538 auto production = province::rgo_production_quantity(state, p, c);
1539
1540 if(production < 0.0001f) {
1541 return;
1542 }
1543
1544 auto base_box = text::open_layout_box(contents);
1545 auto name_box = base_box;
1546 name_box.x_size = 75;
1547 auto production_box = base_box;
1548 production_box.x_position += 120.f;
1549
1551 text::add_to_layout_box(state, contents, production_box, text::format_money(production));
1552 text::add_to_layout_box(state, contents, base_box, std::string(" "));
1553 text::close_layout_box(contents, base_box);
1554 });
1555 }
1556};
1557
1559public:
1560 void on_update(sys::state& state) noexcept override {
1561 auto province_id = retrieve<dcon::province_id>(state, parent);
1562 set_text(state, text::format_money(province::rgo_income(state, province_id)));
1563 }
1564
1566 return tooltip_behavior::variable_tooltip;
1567 }
1568
1569 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1570 auto p = retrieve<dcon::province_id>(state, parent);
1571
1572 auto n = state.world.province_get_nation_from_province_ownership(p);
1573
1574 state.world.for_each_commodity([&](dcon::commodity_id c) {
1575 auto profit = state.world.province_get_rgo_profit_per_good(p, c);
1576
1577 if(profit < 0.0001f) {
1578 return;
1579 }
1580
1581 auto base_box = text::open_layout_box(contents);
1582 auto name_box = base_box;
1583 name_box.x_size = 75;
1584 auto profit_box = base_box;
1585 profit_box.x_position += 120.f;
1586
1588 text::add_to_layout_box(state, contents, profit_box, text::format_money(profit));
1589 text::add_to_layout_box(state, contents, base_box, std::string(" "));
1590 text::close_layout_box(contents, base_box);
1591 });
1592 }
1593};
1594
1596public:
1597 void on_update(sys::state& state) noexcept override {
1598 auto province_id = retrieve<dcon::province_id>(state, parent);
1599 set_text(state, text::prettify(int32_t(province::land_employment(state, province_id))));
1600 }
1601
1603 return tooltip_behavior::variable_tooltip;
1604 }
1605
1606 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1607 auto p = retrieve<dcon::province_id>(state, parent);
1608
1609 auto n = state.world.province_get_nation_from_province_ownership(p);
1610 auto s = state.world.province_get_state_membership(p);
1611 auto m = state.world.state_instance_get_market_from_local_market(s);
1612
1613 auto row_1 = text::open_layout_box(contents);
1614 auto col_1 = row_1;
1615 col_1.x_size = 75;
1616 auto col_2 = row_1;
1617 col_2.x_position += 90.f;
1618 auto col_3 = row_1;
1619 col_3.x_position += 180.f;
1620 auto col_4 = row_1;
1621 col_4.x_position += 250.f;
1622 text::add_to_layout_box(state, contents, col_1, std::string_view("Good"));
1623 text::add_to_layout_box(state, contents, col_2, std::string_view("Employed"));
1624 text::add_to_layout_box(state, contents, col_3, std::string_view("Max"));
1625 text::add_to_layout_box(state, contents, col_4, std::string_view("Profit"));
1626 text::add_to_layout_box(state, contents, row_1, std::string_view(" "));
1627 text::close_layout_box(contents, row_1);
1628
1629 state.world.for_each_commodity([&](dcon::commodity_id c) {
1630 auto rgo_employment = state.world.province_get_rgo_employment_per_good(p, c);
1631 auto current_employment = int64_t(rgo_employment);
1632 auto max_employment = int64_t(economy::rgo_max_employment(state, n, p, c));
1633 auto expected_profit = economy::rgo_expected_worker_norm_profit(state, p, m, n, c);
1634
1635 if(max_employment < 1.f) {
1636 return;
1637 }
1638 auto base_box = text::open_layout_box(contents);
1639 auto name_box = base_box;
1640 name_box.x_size = 75;
1641 auto employment_box = base_box;
1642 employment_box.x_position += 120.f;
1643 auto max_employment_box = base_box;
1644 max_employment_box.x_position += 180.f;
1645 auto expected_profit_box = base_box;
1646 expected_profit_box.x_position += 250.f;
1647
1649
1650
1651 text::add_to_layout_box(state, contents, employment_box, current_employment);
1652 text::add_to_layout_box(state, contents, max_employment_box, max_employment);
1653 text::add_to_layout_box(state, contents, expected_profit_box, text::format_money(expected_profit));
1654
1655 text::add_to_layout_box(state, contents, base_box, std::string(" "));
1656 text::close_layout_box(contents, base_box);
1657 });
1658
1659 auto rgo_employment = state.world.province_get_subsistence_employment(p);
1660 auto current_employment = int64_t(rgo_employment);
1661 auto max_employment = int64_t(economy::subsistence_max_pseudoemployment(state, n, p));
1662 auto expected_profit = 0.f;
1663
1664 auto base_box = text::open_layout_box(contents);
1665 auto name_box = base_box;
1666 name_box.x_size = 75;
1667 auto employment_box = base_box;
1668 employment_box.x_position += 120.f;
1669 auto max_employment_box = base_box;
1670 max_employment_box.x_position += 180.f;
1671 auto expected_profit_box = base_box;
1672 expected_profit_box.x_position += 250.f;
1673
1674 text::add_to_layout_box(state, contents, name_box, std::string_view("Subsistence"));
1675
1676 text::add_to_layout_box(state, contents, employment_box, current_employment);
1677 text::add_to_layout_box(state, contents, max_employment_box, max_employment);
1678 text::add_to_layout_box(state, contents, expected_profit_box, text::format_money(expected_profit));
1679
1680 text::add_to_layout_box(state, contents, base_box, std::string(" "));
1681 text::close_layout_box(contents, base_box);
1682
1683 active_modifiers_description(state, contents, p, 15, sys::provincial_mod_offsets::mine_rgo_size, false);
1684 if(auto owner = state.world.province_get_nation_from_province_ownership(p); owner)
1685 active_modifiers_description(state, contents, owner, 15, sys::national_mod_offsets::mine_rgo_size, false);
1686 active_modifiers_description(state, contents, p, 15, sys::provincial_mod_offsets::farm_rgo_size, false);
1687 if(auto owner = state.world.province_get_nation_from_province_ownership(p); owner)
1688 active_modifiers_description(state, contents, owner, 15, sys::national_mod_offsets::farm_rgo_size, false);
1689 }
1690};
1691
1693public:
1694 void on_update(sys::state& state) noexcept override {
1695 auto province_id = retrieve<dcon::province_id>(state, parent);
1696 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));
1697 }
1698};
1699
1701public:
1702 void on_update(sys::state& state) noexcept override {
1703 auto factory_id = retrieve<dcon::factory_id>(state, parent);
1704 auto flid = state.world.factory_get_factory_location_as_factory(factory_id);
1705 auto pid = state.world.factory_location_get_province(flid);
1706 auto sdef = state.world.province_get_state_from_abstract_state_membership(pid);
1707 dcon::state_instance_id sid{};
1708 state.world.for_each_state_instance([&](dcon::state_instance_id id) {
1709 if(state.world.state_instance_get_definition(id) == sdef)
1710 sid = id;
1711 });
1712 set_text(state, text::get_dynamic_state_name(state, sid));
1713 }
1714};
1716public:
1717 void on_update(sys::state& state) noexcept override {
1718 auto factory_id = retrieve<dcon::factory_id>(state, parent);
1719 auto cid = state.world.factory_get_building_type(factory_id).get_output();
1720 set_text(state, text::get_name_as_string(state, cid));
1721 }
1722};
1724public:
1725 void on_update(sys::state& state) noexcept override {
1726 auto factory_id = retrieve<dcon::factory_id>(state, parent);
1727 set_text(state, text::format_float(state.world.factory_get_actual_production(factory_id), 2));
1728 }
1729};
1731public:
1732 void on_update(sys::state& state) noexcept override {
1733 auto factory_id = retrieve<dcon::factory_id>(state, parent);
1734 set_text(state, text::format_float(state.world.factory_get_full_profit(factory_id), 2));
1735 }
1736};
1738public:
1739 void on_update(sys::state& state) noexcept override {
1740 auto factory_id = retrieve<dcon::factory_id>(state, parent);
1742 }
1743};
1745public:
1746 void on_create(sys::state& state) noexcept override {
1747 base_data.size.x += int16_t(20);
1748 }
1749 void on_update(sys::state& state) noexcept override {
1750 auto factory_id = retrieve<dcon::factory_id>(state, parent);
1751 set_text(state, std::to_string(uint32_t(state.world.factory_get_level(factory_id))));
1752 }
1753};
1755public:
1756 void on_update(sys::state& state) noexcept override {
1757 auto content = retrieve<dcon::factory_id>(state, parent);
1758
1759 auto profit = state.world.factory_get_full_profit(content);
1760 bool is_positive = profit >= 0.f;
1761 auto text = (is_positive ? "+" : "") + text::format_float(profit, 2);
1762 // Create colour
1763 auto contents = text::create_endless_layout(state, internal_layout,
1764 text::layout_parameters{0, 0, static_cast<int16_t>(base_data.size.x), static_cast<int16_t>(base_data.size.y),
1765 base_data.data.text.font_handle, 0, text::alignment::left, text::text_color::black, true});
1766 auto box = text::open_layout_box(contents);
1767 text::add_to_layout_box(state, contents, box, text,
1769 text::close_layout_box(contents, box);
1770 }
1771};
1773public:
1774 void on_update(sys::state& state) noexcept override {
1775 auto content = retrieve<dcon::factory_id>(state, parent);
1776 float profit = state.world.factory_get_full_profit(content);
1777
1778 if(profit > 0.f) {
1779 frame = 0;
1780 } else if (profit < 0.f) {
1781 frame = 1;
1782 } else {
1783 frame = 2; //empty frame
1784 }
1785 }
1786};
1788public:
1789 void on_update(sys::state& state) noexcept override {
1790 auto content = retrieve<dcon::factory_id>(state, parent);
1791 frame = economy::factory_priority(state, content);
1792 }
1793};
1794
1796public:
1797 void on_update(sys::state& state) noexcept override {
1798 frame = int32_t(state.world.commodity_get_icon(retrieve<dcon::commodity_id>(state, parent)));
1799 }
1801 return tooltip_behavior::variable_tooltip;
1802 }
1803
1804 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1805 auto com = retrieve<dcon::commodity_id>(state, parent);
1806 if(!com)
1807 return;
1808
1809 auto n = retrieve<dcon::nation_id>(state, parent);
1810 auto p = retrieve<dcon::province_id>(state, parent);
1811
1812 auto box = text::open_layout_box(contents, 0);
1813 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, state.world.commodity_get_name(com)), text::text_color::yellow);
1814 text::close_layout_box(contents, box);
1815
1816 // Nation modifiers
1817 if(bool(n)) {
1818 auto commodity_mod_description = [&](float value, std::string_view locale_base_name, std::string_view locale_farm_base_name) {
1819 if(value == 0.f)
1820 return;
1821 auto box = text::open_layout_box(contents, 0);
1822 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, state.world.commodity_get_name(com)), text::text_color::white);
1823 text::add_space_to_layout_box(state, contents, box);
1824 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);
1825 text::add_to_layout_box(state, contents, box, std::string{ ":" }, text::text_color::white);
1826 text::add_space_to_layout_box(state, contents, box);
1827 auto color = value > 0.f ? text::text_color::green : text::text_color::red;
1828 text::add_to_layout_box(state, contents, box, (value > 0.f ? "+" : "") + text::format_percentage(value, 1), color);
1829 text::close_layout_box(contents, box);
1830 };
1831 commodity_mod_description(state.world.nation_get_factory_goods_output(n, com), "tech_output", "tech_output");
1832 commodity_mod_description(state.world.nation_get_rgo_goods_output(n, com), "tech_mine_output", "tech_farm_output");
1833 commodity_mod_description(state.world.nation_get_rgo_size(n, com), "tech_mine_size", "tech_farm_size");
1834 }
1836 if(bool(n)) {
1837 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::factory_output, true);
1838 }
1839 if(bool(p)) {
1840 active_modifiers_description(state, contents, p, 0, sys::provincial_mod_offsets::local_factory_output, true);
1841 }
1842 if(bool(n)) {
1843 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::factory_throughput, true);
1844 }
1845 if(bool(p)) {
1846 active_modifiers_description(state, contents, p, 0, sys::provincial_mod_offsets::local_factory_throughput, true);
1847 }
1848 } else {
1849 if(state.world.commodity_get_is_mine(com)) {
1850 if(bool(n)) {
1851 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::mine_rgo_eff, true);
1852 }
1853 if(bool(p)) {
1854 active_modifiers_description(state, contents, p, 0, sys::provincial_mod_offsets::mine_rgo_eff, true);
1855 }
1856 if(bool(n)) {
1857 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::mine_rgo_size, true);
1858 }
1859 if(bool(p)) {
1860 active_modifiers_description(state, contents, p, 0, sys::provincial_mod_offsets::mine_rgo_size, true);
1861 }
1862 } else {
1863 if(bool(n)) {
1864 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::farm_rgo_eff, true);
1865 }
1866 if(bool(p)) {
1867 active_modifiers_description(state, contents, p, 0, sys::provincial_mod_offsets::farm_rgo_eff, true);
1868 }
1869 if(bool(n)) {
1870 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::farm_rgo_size, true);
1871 }
1872 if(bool(p)) {
1873 active_modifiers_description(state, contents, p, 0, sys::provincial_mod_offsets::farm_rgo_size, true);
1874 }
1875 }
1876 }
1877
1878 for(const auto tid : state.world.in_technology) {
1879 if(state.world.nation_get_active_technologies(n, tid)) {
1880 bool have_header = false;
1881 auto commodity_technology_mod_description = [&](auto const& list, std::string_view locale_base_name, std::string_view locale_farm_base_name) {
1882 for(const auto mod : list) {
1883 if(mod.type != com || mod.amount == 0.f)
1884 return;
1885 auto box = text::open_layout_box(contents, 0);
1886 if(!have_header) {
1887 text::add_to_layout_box(state, contents, box, state.world.technology_get_name(tid), text::text_color::yellow);
1889 have_header = true;
1890 }
1891 auto name = state.world.commodity_get_name(mod.type);
1892 text::add_to_layout_box(state, contents, box, name);
1893 text::add_space_to_layout_box(state, contents, box);
1894 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);
1895 text::add_to_layout_box(state, contents, box, std::string{ ":" }, text::text_color::white);
1896 text::add_space_to_layout_box(state, contents, box);
1897 auto color = mod.amount > 0.f ? text::text_color::green : text::text_color::red;
1898 text::add_to_layout_box(state, contents, box, (mod.amount > 0.f ? "+" : "") + text::format_percentage(mod.amount, 1), color);
1899 text::close_layout_box(contents, box);
1900 }
1901 };
1902 commodity_technology_mod_description(state.world.technology_get_factory_goods_output(tid), "tech_output", "tech_output");
1903 commodity_technology_mod_description(state.world.technology_get_rgo_goods_output(tid), "tech_mine_output", "tech_farm_output");
1904 commodity_technology_mod_description(state.world.technology_get_rgo_size(tid), "tech_mine_size", "tech_farm_size");
1905 }
1906 }
1907 for(const auto iid : state.world.in_invention) {
1908 if(state.world.nation_get_active_inventions(n, iid)) {
1909 bool have_header = false;
1910 auto commodity_invention_mod_description = [&](auto const& list, std::string_view locale_base_name, std::string_view locale_farm_base_name) {
1911 for(const auto mod : list) {
1912 if(mod.type != com || mod.amount == 0.f)
1913 return;
1914 auto box = text::open_layout_box(contents, 0);
1915 if(!have_header) {
1916 text::add_to_layout_box(state, contents, box, state.world.invention_get_name(iid), text::text_color::yellow);
1918 have_header = true;
1919 }
1920 auto name = state.world.commodity_get_name(mod.type);
1921 text::add_to_layout_box(state, contents, box, name);
1922 text::add_space_to_layout_box(state, contents, box);
1923 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);
1924 text::add_to_layout_box(state, contents, box, std::string{ ":" }, text::text_color::white);
1925 text::add_space_to_layout_box(state, contents, box);
1926 auto color = mod.amount > 0.f ? text::text_color::green : text::text_color::red;
1927 text::add_to_layout_box(state, contents, box, (mod.amount > 0.f ? "+" : "") + text::format_percentage(mod.amount, 1), color);
1928 text::close_layout_box(contents, box);
1929 }
1930 };
1931 commodity_invention_mod_description(state.world.invention_get_factory_goods_output(iid), "tech_output", "tech_output");
1932 commodity_invention_mod_description(state.world.invention_get_rgo_goods_output(iid), "tech_mine_output", "tech_farm_output");
1933 commodity_invention_mod_description(state.world.invention_get_rgo_size(iid), "tech_mine_size", "tech_farm_size");
1934 }
1935 }
1936 }
1937};
1938
1939// -----------------------------------------------------------------------------
1940// National focuses
1941
1943
1945public:
1946 void on_update(sys::state& state) noexcept override {
1947 auto nfid = retrieve<dcon::national_focus_id>(state, parent);
1948 auto sid = retrieve<dcon::state_instance_id>(state, parent);
1949 disabled = !command::can_set_national_focus(state, state.local_player_nation, sid, nfid);
1950 frame = state.world.national_focus_get_icon(nfid) - 1;
1951 }
1952
1954 return tooltip_behavior::variable_tooltip;
1955 }
1956
1957 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1958 auto content = retrieve<dcon::national_focus_id>(state, parent);
1959 if(bool(content)) {
1960 auto sid = retrieve<dcon::state_instance_id>(state, parent);
1961 auto fat_si = dcon::fatten(state.world, sid);
1962 auto fat_nf = dcon::fatten(state.world, content);
1963
1964 auto box = text::open_layout_box(contents, 0);
1965 text::add_to_layout_box(state, contents, box, sid);
1967 text::add_to_layout_box(state, contents, box, state.world.national_focus_get_name(content), text::substitution_map{});
1969 auto color = text::text_color::white;
1970 if(fat_nf.get_promotion_type()) {
1971 //Is the NF not optimal? Recolor it
1972 if(fat_nf.get_promotion_type() == state.culture_definitions.clergy) {
1973 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) {
1974 color = text::text_color::red;
1975 }
1976 } else if(fat_nf.get_promotion_type() == state.culture_definitions.bureaucrat) {
1977 if(province::state_admin_efficiency(state, fat_si.id) >= 1.f) {
1978 color = text::text_color::red;
1979 }
1980 }
1981 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));
1982 text::add_to_layout_box(state, contents, box, std::string_view(full_str), color);
1983 }
1984 text::close_layout_box(contents, box);
1985 if(auto mid = state.world.national_focus_get_modifier(content); mid) {
1986 modifier_description(state, contents, mid, 15);
1987 }
1988 auto state_cap = state.world.state_instance_get_capital(sid);
1989 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);
1990 }
1991 }
1992
1993 void button_action(sys::state& state) noexcept override {
1994 auto content = retrieve<dcon::state_instance_id>(state, parent);
1995 auto nat_focus = retrieve<dcon::national_focus_id>(state, parent);
1996 command::set_national_focus(state, state.local_player_nation, content, nat_focus);
1998 }
1999};
2000
2001class national_focus_item : public listbox_row_element_base<dcon::national_focus_id> {
2002public:
2003 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
2004 if(name == "focus_icon") {
2005 return make_element_by_type<national_focus_icon>(state, id);
2006 } else {
2007 return nullptr;
2008 }
2009 }
2010};
2011
2012class national_focus_category_list : public overlapping_listbox_element_base<national_focus_item, dcon::national_focus_id> {
2013public:
2014 std::string_view get_row_element_name() override {
2015 return "focus_item";
2016 }
2017};
2018
2020private:
2021 simple_text_element_base* category_label = nullptr;
2022 national_focus_category_list* focus_list = nullptr;
2023
2024public:
2025 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
2026 if(name == "name") {
2027 auto ptr = make_element_by_type<simple_text_element_base>(state, id);
2028 category_label = ptr.get();
2029 return ptr;
2030 } else if(name == "focus_icons") {
2031 auto ptr = make_element_by_type<national_focus_category_list>(state, id);
2032 focus_list = ptr.get();
2033 return ptr;
2034 } else {
2035 return nullptr;
2036 }
2037 }
2038
2039 message_result set(sys::state& state, Cyto::Any& payload) noexcept override {
2040 if(payload.holds_type<nations::focus_type>()) {
2041 auto category = any_cast<nations::focus_type>(payload);
2042 if(category_label)
2043 category_label->set_text(state, text::get_focus_category_name(state, category));
2044
2045 if(focus_list) {
2046 focus_list->row_contents.clear();
2047 state.world.for_each_national_focus([&](dcon::national_focus_id focus_id) {
2048 auto fat_id = dcon::fatten(state.world, focus_id);
2049 if(fat_id.get_type() == uint8_t(category))
2050 focus_list->row_contents.push_back(focus_id);
2051 });
2052 focus_list->update(state);
2053 }
2054 return message_result::consumed;
2055 } else {
2056 return message_result::unseen;
2057 }
2058 }
2059};
2060
2062public:
2063 void button_action(sys::state& state) noexcept override {
2064 auto content = retrieve<dcon::state_instance_id>(state, parent);
2065 command::set_national_focus(state, state.local_player_nation, content, dcon::national_focus_id{});
2067 }
2068};
2069
2071public:
2072 void on_create(sys::state& state) noexcept override {
2073 window_element_base::on_create(state);
2074 auto start = make_element_by_type<window_element_base>(state, "focuscategory_start");
2075 auto current_pos = start->base_data.position;
2076 auto step = make_element_by_type<window_element_base>(state, "focuscategory_step");
2077 auto step_y = step->base_data.position.y;
2078
2080 auto ptr = make_element_by_type<national_focus_category>(state, "focus_category");
2081 ptr->base_data.position = current_pos;
2082 current_pos = xy_pair{current_pos.x, int16_t(current_pos.y + step_y)};
2083
2084 Cyto::Any foc_type_payload = nations::focus_type(i);
2085 ptr->impl_set(state, foc_type_payload);
2086
2087 add_child_to_front(std::move(ptr));
2088 }
2089 }
2090
2091 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
2092 if(name == "close_button") {
2093 return make_element_by_type<generic_close_button>(state, id);
2094 } else if(name == "background") {
2095 return make_element_by_type<draggable_target>(state, id);
2096 } else if(name == "cancel_button") {
2097 return make_element_by_type<national_focus_remove_button>(state, id);
2098 } else {
2099 return nullptr;
2100 }
2101 }
2102 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
2103 if(payload.holds_type<close_focus_window_notification>()) {
2104 set_visible(state, false);
2105 return message_result::consumed;
2106 }
2107 return window_element_base::get(state, payload);
2108 }
2109};
2110
2112public:
2113 void on_update(sys::state& state) noexcept override {
2114 auto content = retrieve<military::wg_summary>(state, parent).cb;
2115 frame = state.world.cb_type_get_sprite_index(content) - 1;
2116 }
2117
2119 return tooltip_behavior::variable_tooltip;
2120 }
2121
2122 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
2123 auto wg = retrieve<military::wg_summary>(state, parent);
2124 text::add_line(state, contents, state.world.cb_type_get_name(wg.cb));
2125
2127 if(wg.state) {
2128 text::add_line(state, contents, "war_goal_3", text::variable_type::x, wg.state);
2129 }
2130 if(wg.wg_tag) {
2131 text::add_line(state, contents, "war_goal_4", text::variable_type::x, wg.wg_tag);
2132 } else if(wg.secondary_nation) {
2133 text::add_line(state, contents, "war_goal_4", text::variable_type::x, wg.secondary_nation);
2134 }
2135 }
2136};
2137
2138class overlapping_wg_icon : public listbox_row_element_base<military::wg_summary> {
2139public:
2140 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
2141 if(name == "wargoal_icon") {
2142 return make_element_by_type<wg_icon>(state, id);
2143 } else {
2144 return nullptr;
2145 }
2146 }
2147};
2148
2150public:
2151 void on_update(sys::state& state) noexcept override {
2152 auto content = retrieve<sys::full_wg>(state, parent).cb;
2153 frame = state.world.cb_type_get_sprite_index(content) - 1;
2154 }
2155
2157 return tooltip_behavior::variable_tooltip;
2158 }
2159
2160 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
2161 auto wg = retrieve<sys::full_wg>(state, parent);
2162 text::add_line(state, contents, state.world.cb_type_get_name(wg.cb));
2163
2165 text::add_line(state, contents, "war_goal_1", text::variable_type::x, wg.added_by);
2166 text::add_line(state, contents, "war_goal_2", text::variable_type::x, wg.target_nation);
2167 if(wg.state) {
2168 text::add_line(state, contents, "war_goal_3", text::variable_type::x, wg.state);
2169 }
2170 if(wg.wg_tag) {
2171 text::add_line(state, contents, "war_goal_4", text::variable_type::x, wg.wg_tag);
2172 } else if(wg.secondary_nation) {
2173 text::add_line(state, contents, "war_goal_4", text::variable_type::x, wg.secondary_nation);
2174 }
2175 }
2176};
2177
2179public:
2180 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
2181 if(name == "wargoal_icon") {
2182 return make_element_by_type<full_wg_icon>(state, id);
2183 } else {
2184 return nullptr;
2185 }
2186 }
2187};
2188
2190public:
2191 void on_create(sys::state& state) noexcept override {
2192 button_element_base::on_create(state);
2193 frame = 1;
2194 }
2195
2196 void on_update(sys::state& state) noexcept override {
2197 auto content = retrieve<dcon::state_instance_id>(state, parent);
2198 disabled = !command::can_upgrade_colony_to_state(state, state.local_player_nation, content);
2199 }
2200
2201 void button_action(sys::state& state) noexcept override {
2202 auto content = retrieve<dcon::state_instance_id>(state, parent);
2203 command::upgrade_colony_to_state(state, state.local_player_nation, content);
2204 }
2205
2207 return tooltip_behavior::variable_tooltip;
2208 }
2209
2210 void update_tooltip(sys::state& state, int32_t x, int32_t t, text::columnar_layout& contents) noexcept override {
2211 auto state_instance_id = retrieve<dcon::state_instance_id>(state, parent);
2212
2213 auto box = text::open_layout_box(contents, 0);
2214 text::localised_format_box(state, contents, box, std::string_view("pw_colony"));
2215 text::add_divider_to_layout_box(state, contents, box);
2216
2218 text::add_to_substitution_map(sub1, text::variable_type::num, text::fp_one_place{ state.defines.state_creation_admin_limit * 100.f });
2219 float total_pop = state.world.state_instance_get_demographics(state_instance_id, demographics::total);
2220 float b_size = province::state_accepted_bureaucrat_size(state, state_instance_id);
2222 text::localised_format_box(state, contents, box, std::string_view("pw_colony_no_state"), sub1);
2226 text::localised_format_box(state, contents, box, std::string_view("pw_cant_upgrade_to_state"), sub2);
2227
2228 text::close_layout_box(contents, box);
2229 }
2230};
2231
2233 country_list_filter general_category = country_list_filter::all;
2234 dcon::modifier_id continent;
2235};
2237 country_list_sort sort = country_list_sort::country;
2238 bool sort_ascend = true;
2239};
2240
2241template<country_list_filter category>
2243public:
2244 void button_action(sys::state& state) noexcept final {
2245 send(state, parent, category);
2246 if constexpr(category == country_list_filter::all) {
2247 send(state, parent, dcon::modifier_id{});
2248 }
2249 }
2250
2251 void button_right_action(sys::state& state) noexcept final {
2252 if constexpr(category == country_list_filter::allies) {
2253 send(state, parent, country_list_filter::find_allies);
2254 } else if constexpr(category == country_list_filter::sphere) {
2255 send(state, parent, country_list_filter::influenced);
2256 } else if constexpr(category == country_list_filter::neighbors) {
2257 send(state, parent, country_list_filter::neighbors_no_vassals);
2258 } else {
2259 send(state, parent, category);
2260 if constexpr(category == country_list_filter::all) {
2261 send(state, parent, dcon::modifier_id{});
2262 }
2263 }
2264 }
2265
2266 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
2267 auto filter_settings = retrieve<country_filter_setting>(state, parent);
2268 auto t_category = filter_settings.general_category;
2269 switch(t_category) {
2270 case country_list_filter::influenced:
2271 t_category = country_list_filter::sphere;
2272 break;
2273 case country_list_filter::find_allies:
2274 t_category = country_list_filter::allies;
2275 break;
2276 case country_list_filter::neighbors_no_vassals:
2277 t_category = country_list_filter::neighbors;
2278 break;
2279 default:
2280 break;
2281 }
2282 disabled = t_category != category;
2283 button_element_base::render(state, x, y);
2284 disabled = false;
2285 }
2286
2288 return tooltip_behavior::variable_tooltip;
2289 }
2290
2291 void update_tooltip(sys::state& state, int32_t x, int32_t t, text::columnar_layout& contents) noexcept override {
2292 switch(category) {
2293 case country_list_filter::all:
2294 text::add_line(state, contents, "filter_all");
2295 break;
2296 case country_list_filter::neighbors:
2297 case country_list_filter::neighbors_no_vassals:
2298 text::add_line(state, contents, "filter_neighbors");
2299 break;
2300 case country_list_filter::sphere:
2301 case country_list_filter::influenced:
2302 text::add_line(state, contents, "filter_sphere");
2303 break;
2304 case country_list_filter::enemies:
2305 text::add_line(state, contents, "filter_enemies");
2306 break;
2307 case country_list_filter::find_allies:
2308 case country_list_filter::allies:
2309 text::add_line(state, contents, "filter_allies");
2310 break;
2311 case country_list_filter::best_guess:
2312 text::add_line(state, contents, "filter_best_guess");
2313 break;
2314 default:
2315 break;
2316 }
2317 }
2318};
2319
2321public:
2322 dcon::modifier_id continent;
2323
2324 void button_action(sys::state& state) noexcept final {
2325 send(state, parent, continent);
2326 }
2327
2328 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
2329 auto filter_settings = retrieve<country_filter_setting>(state, parent);
2330 disabled = filter_settings.continent != continent;
2331 button_element_base::render(state, x, y);
2332 disabled = false;
2333 }
2334};
2335
2337 void button_action(sys::state& state) noexcept final {
2339 }
2340};
2341
2343 void button_action(sys::state& state) noexcept final {
2345 }
2346
2347 void on_update(sys::state& state) noexcept override {
2348 if(state.selected_army_group) {
2349 disabled = false;
2350 } else {
2351 disabled = true;
2352 }
2353 }
2354};
2355
2357 void button_action(sys::state& state) noexcept final {
2359 }
2360};
2361
2362} // 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
tooltip_behavior has_tooltip(sys::state &state) noexcept override
int32_t get_icon_frame(sys::state &state, dcon::nation_id nation_id) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
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
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
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:1576
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:122
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:111
float effective_technology_cost(sys::state &state, uint32_t current_year, dcon::nation_id target_nation, dcon::technology_id tech_id)
Definition: culture.cpp:969
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:1802
int32_t state_factory_count(sys::state &state, dcon::state_instance_id sid, dcon::nation_id n)
Definition: economy.cpp:8347
int32_t factory_priority(sys::state const &state, dcon::factory_id f)
Definition: economy.cpp:1885
float rgo_expected_worker_norm_profit(sys::state &state, dcon::province_id p, dcon::market_id m, dcon::nation_id n, dcon::commodity_id c)
Definition: economy.cpp:2764
float subsistence_max_pseudoemployment(sys::state &state, dcon::nation_id n, dcon::province_id p)
Definition: economy.cpp:1810
float rgo_max_employment(sys::state &state, dcon::nation_id n, dcon::province_id p, dcon::commodity_id c)
Definition: economy.cpp:1822
float factory_total_employment(sys::state const &state, dcon::factory_id f)
Definition: economy.cpp:2029
float interest_payment(sys::state &state, dcon::nation_id n)
Definition: economy.cpp:808
std::vector< dcon::factory_type_id > commodity_get_factory_types_as_output(sys::state const &state, dcon::commodity_id output_good)
Definition: economy.cpp:883
float gdp_adjusted(sys::state &state, dcon::market_id n)
Definition: economy.cpp:846
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:1252
int32_t total_regiments(sys::state &state, dcon::nation_id n)
Definition: military.cpp:25
int32_t mobilized_regiments_possible_from_province(sys::state &state, dcon::province_id p)
Definition: military.cpp:1137
int32_t total_ships(sys::state &state, dcon::nation_id n)
Definition: military.cpp:28
int32_t naval_supply_points(sys::state &state, dcon::nation_id n)
Definition: military.cpp:1249
status get_status(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1145
int32_t free_colonial_points(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1304
bool has_political_reform_available(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1370
float get_foreign_investment(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:884
focus_type
Definition: nations.hpp:44
float diplomatic_points(sys::state const &state, dcon::nation_id n)
Definition: nations.cpp:1210
bool has_social_reform_available(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1382
float get_debt(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1615
float suppression_points(sys::state const &state, dcon::nation_id n)
Definition: nations.cpp:1175
dcon::nation_id get_nth_great_power(sys::state const &state, uint16_t n)
Definition: nations.cpp:75
float prestige_score(sys::state const &state, dcon::nation_id n)
Definition: nations.cpp:961
float leadership_points(sys::state const &state, dcon::nation_id n)
Definition: nations.cpp:1179
float daily_research_points(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:741
float get_bank_funds(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1611
sys::date get_research_end_date(sys::state &state, dcon::technology_id tech_id, dcon::nation_id n)
Definition: nations.cpp:1164
int32_t national_focuses_in_use(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1199
dcon::technology_id current_research(sys::state const &state, dcon::nation_id n)
Definition: nations.cpp:1171
int32_t max_national_focuses(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1183
float get_treasury(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1607
int32_t max_colonial_points(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1312
float pop_vote_weight(sys::state &state, dcon::pop_id p, dcon::nation_id n)
Definition: politics.cpp:477
float get_military_reform_multiplier(sys::state &state, dcon::nation_id n)
Definition: politics.cpp:293
float get_economic_reform_multiplier(sys::state &state, dcon::nation_id n)
Definition: politics.cpp:308
dcon::pop_demographics_key to_key(sys::state const &state, dcon::ideology_id v)
float get_demo(sys::state const &state, dcon::pop_id p, dcon::pop_demographics_key k)
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:540
float rgo_production_quantity(sys::state &state, dcon::province_id id, dcon::commodity_id c)
Definition: province.cpp:523
float land_employment(sys::state &state, dcon::province_id id)
Definition: province.cpp:509
float rgo_income(sys::state &state, dcon::province_id id)
Definition: province.cpp:520
float colony_integration_cost(sys::state &state, dcon::state_instance_id id)
Definition: province.cpp:659
float state_admin_efficiency(sys::state &state, dcon::state_instance_id id)
Definition: province.cpp:553
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:957
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:1823
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:1912
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:1904
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:1923
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:1979
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:2122
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:797
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:961
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:1812
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:1831
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)
table::column< dcon::commodity_id > rgo_employment
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
Holds important data about the game world, state, and other data regarding windowing,...
int32_t x_size
Definition: text.hpp:830
float x_position
Definition: text.hpp:833
element_type get_element_type() const
union ui::element_data::internal_data data
alignment get_alignment() const
xy_pair border_size