Project Alice
Loading...
Searching...
No Matches
gui_province_window.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "dcon_generated.hpp"
4#include "demographics.hpp"
7#include "gui_graphics.hpp"
9#include "nations.hpp"
10#include "province.hpp"
11#include "system_state.hpp"
12#include "text.hpp"
16#include "nations_templates.hpp"
17
18namespace ui {
19
20
22public:
23 void on_update(sys::state& state) noexcept override {
24 auto p = retrieve<dcon::province_id>(state, parent);
25 frame = (state.world.province_get_land_rally_point(retrieve<dcon::province_id>(state, parent))) ? 1 : 0;
26 disabled = state.world.province_get_nation_from_province_ownership(p) != state.local_player_nation;
27 }
28 void button_action(sys::state& state) noexcept override {
29 auto p = retrieve<dcon::province_id>(state, parent);
30 command::set_rally_point(state, state.local_player_nation, p, false, !state.world.province_get_land_rally_point(p));
31 }
34 }
35 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
36 text::add_line(state, contents, "rally_point_enable_info");
37 }
38};
39
41public:
42 void on_update(sys::state& state) noexcept override {
43 auto p = retrieve<dcon::province_id>(state, parent);
44 frame = state.world.province_get_naval_rally_point(p) ? 1 : 0;
45 disabled = !(state.world.province_get_is_coast(p)) || state.world.province_get_nation_from_province_ownership(p) != state.local_player_nation;
46 }
47 void button_action(sys::state& state) noexcept override {
48 auto p = retrieve<dcon::province_id>(state, parent);
49 command::set_rally_point(state, state.local_player_nation, p, true, !state.world.province_get_naval_rally_point(p));
50 }
53 }
54 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
55 text::add_line(state, contents, "rally_point_enable_info");
56 }
57};
58
60public:
61 void on_create(sys::state& state) noexcept override {
63 disabled = true;
64 }
67 }
68 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
69 text::add_line(state, contents, "alice_merge_rally_point_why");
70 }
71};
72
74public:
75
76 void on_update(sys::state& state) noexcept override {
77 auto prov_id = retrieve<dcon::province_id>(state, parent);
78 progress = state.world.province_get_life_rating(prov_id) / 100.f;
79 }
80
83 }
84
85 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
86 dcon::province_id prov_id = retrieve<dcon::province_id>(state, parent);
87
88 text::add_line(state, contents, "provinceview_liferating", text::variable_type::value, int64_t(state.world.province_get_life_rating(prov_id)));
90 text::add_line(state, contents, "col_liferate_techs");
91 for(auto i : state.world.in_invention) {
92 auto mod = i.get_modifier();
94 if(mod.get_national_values().offsets[j] == sys::national_mod_offsets::colonial_life_rating) {
95 auto box = text::open_layout_box(contents);
96 text::add_to_layout_box(state, contents, box, i.get_name(), state.world.nation_get_active_inventions(state.local_player_nation, i) ? text::text_color::green : text::text_color::red);
97
98 dcon::technology_id containing_tech;
99 auto lim_trigger_k = i.get_limit();
100 trigger::recurse_over_triggers(state.trigger_data.data() + state.trigger_data_indices[lim_trigger_k.index() + 1],
101 [&](uint16_t* tval) {
102 if((tval[0] & trigger::code_mask) == trigger::technology)
103 containing_tech = trigger::payload(tval[1]).tech_id;
104 });
105
106 if(containing_tech) {
107 text::add_to_layout_box(state, contents, box, std::string_view{ " (" });
108 text::add_to_layout_box(state, contents, box, state.world.technology_get_name(containing_tech), state.world.nation_get_active_technologies(state.local_player_nation, containing_tech) ? text::text_color::green : text::text_color::red);
109 text::add_to_layout_box(state, contents, box, std::string_view{ ")" });
110 }
111 text::close_layout_box(contents, box);
112 break;
113 }
114 }
115 }
116 }
117};
118
120public:
123 }
124
125 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
126 auto box = text::open_layout_box(contents, 0);
127 text::localised_format_box(state, contents, box, std::string_view("provinceview_totalpop"));
128 text::close_layout_box(contents, box);
129 }
130};
131
133public:
134 void on_update(sys::state& state) noexcept override {
135 auto fat_id = dcon::fatten(state.world, retrieve<dcon::province_id>(state, parent));
136 frame = fat_id.get_rgo().get_icon();
137 }
138
141 }
142
143 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
144 auto prov = retrieve<dcon::province_id>(state, parent);
145 auto rgo = state.world.province_get_rgo(prov);
146 text::add_line(state, contents, state.world.commodity_get_name(rgo));
147 }
148};
149
151public:
152 void button_action(sys::state& state) noexcept override {
153 state.map_state.set_selected_province(dcon::province_id{});
155 }
156};
157
159public:
160 void button_action(sys::state& state) noexcept override {
161 dcon::province_id province_id = retrieve<dcon::province_id>(state, parent);
162 if(state.ui_state.population_subwindow != nullptr) {
163 Cyto::Any fl_payload = pop_list_filter(province_id);
164 state.ui_state.population_subwindow->impl_set(state, fl_payload);
165 if(state.ui_state.topbar_subwindow != nullptr)
166 state.ui_state.topbar_subwindow->set_visible(state, false);
169 state.ui_state.root->move_child_to_front(state.ui_state.population_subwindow);
170 // ui_state.population_subwindow->impl_get(*this, fl_payload);
171 }
172 }
175 }
176 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
177 dcon::province_id province_id = retrieve<dcon::province_id>(state, parent);
179 text::add_to_substitution_map(sub_map, text::variable_type::loc, state.world.province_get_name(province_id));
180 auto box = text::open_layout_box(contents, 0);
181 text::localised_format_box(state, contents, box, std::string_view("pw_open_popscreen"), sub_map);
182 text::close_layout_box(contents, box);
183 }
184};
185
187public:
188 void on_update(sys::state& state) noexcept override {
189 dcon::province_id province_id = retrieve<dcon::province_id>(state, parent);
190 auto fat_id = dcon::fatten(state.world, province_id);
191 auto terrain_id = fat_id.get_terrain().id;
192 auto terrain_image = state.province_definitions.terrain_to_gfx_map[terrain_id];
194 base_data.data.image.gfx_object = terrain_image;
195 }
196 }
197
200 }
201
202 void update_tooltip(sys::state& state, int32_t x, int32_t t, text::columnar_layout& contents) noexcept override {
203 dcon::province_id province_id = retrieve<dcon::province_id>(state, parent);
204 auto fat_id = dcon::fatten(state.world, province_id);
205 //terrain
206 if(auto name = fat_id.get_terrain().get_name(); name) {
207 auto box = text::open_layout_box(contents, 0);
209 text::close_layout_box(contents, box);
210 }
211 if(auto mod_id = fat_id.get_terrain().id; mod_id) {
212 modifier_description(state, contents, mod_id);
213 }
214 //climate
215 if(auto name = fat_id.get_climate().get_name(); name) {
216 auto box = text::open_layout_box(contents, 0);
218 text::close_layout_box(contents, box);
219 }
220 if(auto mod_id = fat_id.get_climate().id; mod_id) {
221 modifier_description(state, contents, mod_id);
222 }
223 //continent
224 if(auto name = fat_id.get_continent().get_name(); name) {
225 auto box = text::open_layout_box(contents, 0);
227 text::close_layout_box(contents, box);
228 }
229 if(auto mod_id = fat_id.get_continent().id; mod_id) {
230 modifier_description(state, contents, mod_id);
231 }
232 }
233};
234
236public:
237 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
238 auto prov = retrieve<dcon::province_id>(state, parent);
239 if(state.world.state_instance_get_flashpoint_tag(state.world.province_get_state_membership(prov))) {
241 } else {
242 // no flashpoint
243 }
244 }
245
248 }
249
250 void update_tooltip(sys::state& state, int32_t x, int32_t t, text::columnar_layout& contents) noexcept override {
251 dcon::province_id prov = retrieve<dcon::province_id>(state, parent);
252 if(!state.world.state_instance_get_flashpoint_tag(state.world.province_get_state_membership(prov)))
253 return;
254
255 text::substitution_map sub_map{};
256 text::add_to_substitution_map(sub_map, text::variable_type::value, text::fp_two_places{ state.world.state_instance_get_flashpoint_tension(state.world.province_get_state_membership(prov)) });
257 auto box = text::open_layout_box(contents, 0);
258 text::localised_format_box(state, contents, box, std::string_view("flashpoint_tension"), sub_map);
259 text::close_layout_box(contents, box);
260 }
261};
262
264public:
265 dcon::national_identity_id get_current_nation(sys::state& state) noexcept override {
266 if(parent) {
267 dcon::province_id province_id = retrieve<dcon::province_id>(state, parent);
268 auto fat_id = dcon::fatten(state.world, province_id);
269 return state.world.nation_get_identity_from_identity_holder(fat_id.get_province_control_as_province().get_nation().id);
270 }
271 return dcon::national_identity_id{};
272 }
273
274 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
275 dcon::province_id province_id = retrieve<dcon::province_id>(state, parent);
276 auto prov_fat = dcon::fatten(state.world, province_id);
277 auto controller = prov_fat.get_province_control_as_province().get_nation();
278 auto rebel_faction = prov_fat.get_province_rebel_control_as_province().get_rebel_faction();
279 if(!controller && !rebel_faction)
280 return;
282 }
283
286 }
287
288 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
289 dcon::province_id province_id = retrieve<dcon::province_id>(state, parent);
290 auto prov_fat = dcon::fatten(state.world, province_id);
291 auto controller = prov_fat.get_province_control_as_province().get_nation();
292 auto rebel_faction = prov_fat.get_province_rebel_control_as_province().get_rebel_faction();
293 if(!controller && !rebel_faction)
294 return;
295 auto box = text::open_layout_box(contents, 0);
296 text::localised_format_box(state, contents, box, std::string_view("pv_controller"));
297 text::add_space_to_layout_box(state, contents, box);
298 if(controller) {
299 text::add_to_layout_box(state, contents, box, text::get_name(state, controller));
300 } else {
301 text::add_to_layout_box(state, contents, box, rebel::rebel_name(state, rebel_faction));
302 }
303 text::close_layout_box(contents, box);
304 }
305};
306
308public:
309 int32_t get_icon_frame(sys::state& state) noexcept {
310 auto content = retrieve<dcon::state_instance_id>(state, parent);
311 if(state.world.state_instance_get_nation_from_flashpoint_focus(content) == state.local_player_nation)
312 return state.world.national_focus_get_icon(state.national_definitions.flashpoint_focus) - 1;
313 return bool(state.world.state_instance_get_owner_focus(content).id)
314 ? state.world.state_instance_get_owner_focus(content).get_icon() - 1
315 : 0;
316 }
317
318 void on_update(sys::state& state) noexcept override {
319 auto content = retrieve<dcon::state_instance_id>(state, parent);
320 disabled = true;
321 for(auto nfid : state.world.in_national_focus) {
322 disabled = command::can_set_national_focus(state, state.local_player_nation, content, nfid) ? false : disabled;
323 }
324 if(state.world.state_instance_get_nation_from_flashpoint_focus(content) == state.local_player_nation)
325 disabled = false;
327 }
328
329 void button_action(sys::state& state) noexcept override;
330 void button_right_action(sys::state& state) noexcept override {
331 auto content = retrieve<dcon::state_instance_id>(state, parent);
332 command::set_national_focus(state, state.local_player_nation, content, dcon::national_focus_id{});
333 }
336 }
337
338 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
339 auto box = text::open_layout_box(contents, 0);
340
341 auto sid = retrieve<dcon::state_instance_id>(state, parent);
342 auto fat_si = dcon::fatten(state.world, sid);
343 text::add_to_layout_box(state, contents, box, sid);
345 auto content = state.world.state_instance_get_owner_focus(sid);
346 if(bool(content)) {
347 auto fat_nf = dcon::fatten(state.world, content);
348 text::add_to_layout_box(state, contents, box, state.world.national_focus_get_name(content), text::substitution_map{});
350 auto color = text::text_color::white;
351 if(fat_nf.get_promotion_type()) {
352 //Is the NF not optimal? Recolor it
353 if(fat_nf.get_promotion_type() == state.culture_definitions.clergy) {
354 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) {
355 color = text::text_color::red;
356 }
357 } else if(fat_nf.get_promotion_type() == state.culture_definitions.bureaucrat) {
358 if(province::state_admin_efficiency(state, fat_si.id) > state.defines.max_bureaucracy_percentage) {
359 color = text::text_color::red;
360 }
361 }
362 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));
363 text::add_to_layout_box(state, contents, box, std::string_view(full_str), color);
364 }
365 }
366 text::close_layout_box(contents, box);
367 if(auto mid = state.world.national_focus_get_modifier(content); mid) {
368 modifier_description(state, contents, mid, 15);
369 }
370 text::add_line(state, contents, "alice_nf_controls");
371 }
372};
373
374
376public:
377 void on_update(sys::state& state) noexcept override {
378 sys::dated_modifier mod = retrieve< sys::dated_modifier>(state, parent);
379 if(mod.mod_id) {
380 frame = state.world.modifier_get_icon(mod.mod_id) - 1;
381 }
382 }
383
386 }
387
388 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
389 sys::dated_modifier mod = retrieve< sys::dated_modifier>(state, parent);
390 if(mod.mod_id) {
391 auto p = retrieve<dcon::province_id>(state, parent);
392 auto n = state.world.province_get_nation_from_province_ownership(p);
393 auto box = text::open_layout_box(contents, 0);
394 text::add_to_layout_box(state, contents, box, state.world.modifier_get_name(mod.mod_id), text::text_color::yellow);
396 if(auto desc = state.world.modifier_get_desc(mod.mod_id); state.key_is_localized(desc)) {
400 text::add_to_substitution_map(sub, text::variable_type::capital, state.world.nation_get_capital(n));
401 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))));
403 text::add_to_layout_box(state, contents, box, desc, sub);
404 }
405 text::close_layout_box(contents, box);
406 modifier_description(state, contents, mod.mod_id, 15);
407 }
408 if(mod.expiration) {
409 text::add_line(state, contents, "expires_on", text::variable_type::date, mod.expiration);
410 }
411 }
412};
413
415public:
417
418 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
419 if(name == "modifier") {
420 return make_element_by_type<province_modifier_icon>(state, id);
421 } else {
422 return nullptr;
423 }
424 }
425
426 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
427 if(payload.holds_type<sys::dated_modifier>()) {
428 payload.emplace<sys::dated_modifier>(mod);
430 }
432 }
433
434};
435
436class province_modifiers : public overlapping_listbox_element_base<province_modifier_win, sys::dated_modifier> {
437public:
438 std::string_view get_row_element_name() override {
439 return "prov_state_modifier";
440 }
442 subwindow.mod = content;
443 }
444 void on_update(sys::state& state) noexcept override {
445 row_contents.clear();
446
447 auto prov = retrieve<dcon::province_id>(state, parent);
448 if(prov) {
449 for(auto mods : state.world.province_get_current_modifiers(prov)) {
450 row_contents.push_back(mods);
451 }
452 }
453 update(state);
454 }
455};
456
458public:
459 void on_update(sys::state& state) noexcept override {
460 auto p = retrieve<dcon::province_id>(state, parent);
461 disabled = !command::can_move_capital(state, state.local_player_nation, p);
462 }
463
464 void button_action(sys::state& state) noexcept override {
465 auto p = retrieve<dcon::province_id>(state, parent);
466 command::move_capital(state, state.local_player_nation, p);
467 }
468
471 }
472
473 void update_tooltip(sys::state& state, int32_t x, int32_t t, text::columnar_layout& contents) noexcept override {
474 auto source = state.local_player_nation;
475 auto p = retrieve<dcon::province_id>(state, parent);
476 text::add_line(state, contents, "alice_mvcap_1");
477 text::add_line_with_condition(state, contents, "alice_mvcap_2", !(state.current_crisis != sys::crisis_type::none));
478 text::add_line_with_condition(state, contents, "alice_mvcap_3", !(state.world.nation_get_is_at_war(source)));
479 text::add_line_with_condition(state, contents, "alice_mvcap_4", !(state.world.nation_get_capital(source) == p));
480 text::add_line_with_condition(state, contents, "alice_mvcap_5", !(state.world.province_get_is_colonial(p)));
481 text::add_line_with_condition(state, contents, "alice_mvcap_6", !(state.world.province_get_continent(state.world.nation_get_capital(source)) != state.world.province_get_continent(p)));
482 text::add_line_with_condition(state, contents, "alice_mvcap_7", !(nations::nation_accepts_culture(state, source, state.world.province_get_dominant_culture(p)) == false));
483 text::add_line_with_condition(state, contents, "alice_mvcap_8", !(state.world.province_get_siege_progress(p) > 0.f));
484 text::add_line_with_condition(state, contents, "alice_mvcap_9", !(state.world.province_get_siege_progress(state.world.nation_get_capital(source)) > 0.f));
485 text::add_line_with_condition(state, contents, "alice_mvcap_10", !(state.world.province_get_nation_from_province_ownership(p) != source));
486 text::add_line_with_condition(state, contents, "alice_mvcap_11", !(state.world.province_get_nation_from_province_control(p) != source));
487 text::add_line_with_condition(state, contents, "alice_mvcap_12", !(state.world.province_get_is_owner_core(p) == false));
488 }
489};
490
492private:
493 fixed_pop_type_icon* slave_icon = nullptr;
494 province_colony_button* colony_button = nullptr;
495
496public:
497 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
498 if(name == "state_name") {
499 return make_element_by_type<province_state_name_text>(state, id);
500 } else if(name == "province_name") {
501 return make_element_by_type<generic_name_text<dcon::province_id>>(state, id);
502 } else if(name == "prov_terrain") {
503 return make_element_by_type<province_terrain_image>(state, id);
504 } else if(name == "province_modifiers") {
505 return make_element_by_type<province_modifiers>(state, id);
506 } else if(name == "slave_state_icon") {
507 auto ptr = make_element_by_type<fixed_pop_type_icon>(state, id);
508 slave_icon = ptr.get();
509 ptr->set_type(state, state.culture_definitions.slaves);
510 return ptr;
511 } else if(name == "admin_icon") {
512 auto ptr = make_element_by_type<fixed_pop_type_icon>(state, id);
513 ptr->set_type(state, state.culture_definitions.bureaucrat);
514 return ptr;
515 } else if(name == "owner_icon") {
516 auto ptr = make_element_by_type<fixed_pop_type_icon>(state, id);
517 ptr->set_type(state, state.culture_definitions.aristocrat);
518 return ptr;
519 } else if(name == "controller_flag") {
520 return make_element_by_type<province_controller_flag>(state, id);
521 } else if(name == "flashpoint_indicator") {
522 return make_element_by_type<province_flashpoint_indicator>(state, id);
523 } else if(name == "occupation_progress") {
524 return make_element_by_type<invisible_element>(state, id);
525 } else if(name == "occupation_icon") {
526 return make_element_by_type<invisible_element>(state, id);
527 } else if(name == "occupation_flag") {
528 return make_element_by_type<invisible_element>(state, id);
529 } else if(name == "colony_button") {
530 auto btn = make_element_by_type<province_colony_button>(state, id);
531 colony_button = btn.get();
532 return btn;
533 } else if(name == "alice_move_capital") {
534 return make_element_by_type<province_move_capital_button>(state, id);
535 } else if(name == "national_focus") {
536 return make_element_by_type<province_national_focus_button>(state, id);
537 } else if(name == "admin_efficiency") {
538 return make_element_by_type<state_admin_efficiency_text>(state, id);
539 } else if(name == "owner_presence") {
540 return make_element_by_type<state_aristocrat_presence_text>(state, id);
541 } else if(name == "liferating") {
542 return make_element_by_type<province_liferating>(state, id);
543 } else {
544 return nullptr;
545 }
546 }
547
548 void on_update(sys::state& state) noexcept override {
549 dcon::province_id prov_id = retrieve<dcon::province_id>(state, parent);
550 dcon::province_fat_id fat_id = dcon::fatten(state.world, prov_id);
551 colony_button->set_visible(state, fat_id.get_is_colonial());
552 slave_icon->set_visible(state, fat_id.get_is_slave());
553 }
554};
555
557public:
558 void button_action(sys::state& state) noexcept override {
559 state.open_diplomacy(retrieve<dcon::nation_id>(state, parent));
560 }
561};
562
564private:
565 void populate(sys::state& state, dcon::province_id prov_id) {
566 row_contents.clear();
567 auto fat_id = dcon::fatten(state.world, prov_id);
568 fat_id.for_each_core_as_province([&](dcon::core_id core_id) {
569 auto core_fat_id = dcon::fatten(state.world, core_id);
570 auto identity = core_fat_id.get_identity();
571 row_contents.push_back(identity.id);
572 });
573 update(state);
574 }
575
576public:
577 void on_update(sys::state& state) noexcept override {
578 populate(state, retrieve<dcon::province_id>(state, parent));
579 }
580};
581
582template<economy::province_building_type Value>
584public:
585 void on_update(sys::state& state) noexcept override {
586 auto prov_id = retrieve<dcon::province_id>(state, parent);
587 auto fat_id = dcon::fatten(state.world, prov_id);
588 frame = fat_id.get_building_level(uint8_t(Value));
589 }
590};
591template<economy::province_building_type Value>
593public:
594 void on_update(sys::state& state) noexcept override {
595 auto content = retrieve<dcon::province_id>(state, parent);
596 disabled = !command::can_begin_province_building_construction(state, state.local_player_nation, content, Value);
597 }
598
599 void button_action(sys::state& state) noexcept override {
600 auto content = retrieve<dcon::province_id>(state, parent);
601 command::begin_province_building_construction(state, state.local_player_nation, content, Value);
602 }
603 virtual void button_shift_action(sys::state& state) noexcept override {
604 if constexpr(Value == economy::province_building_type::naval_base) {
606 } else {
607 auto pid = retrieve<dcon::province_id>(state, parent);
608 auto si = state.world.province_get_state_membership(pid);
609 if(si) {
610 province::for_each_province_in_state_instance(state, si, [&](dcon::province_id p) {
611 if(command::can_begin_province_building_construction(state, state.local_player_nation, p, Value))
612 command::begin_province_building_construction(state, state.local_player_nation, p, Value);
613 });
614 }
615 }
616 }
617 virtual void button_shift_right_action(sys::state& state) noexcept override {
618 auto content = retrieve<dcon::province_id>(state, parent);
619 auto within_nation = state.world.province_get_nation_from_province_ownership(content);
620 for(auto p : state.world.nation_get_province_ownership(within_nation)) {
621 if(command::can_begin_province_building_construction(state, state.local_player_nation, p.get_province(), Value))
622 command::begin_province_building_construction(state, state.local_player_nation, p.get_province(), Value);
623 }
624 }
625
628 }
629
630 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
631 auto id = retrieve<dcon::province_id>(state, parent);
632
633 int32_t current_lvl = state.world.province_get_building_level(id, uint8_t(Value));
634 int32_t max_local_lvl = state.world.nation_get_max_building_level(state.local_player_nation, uint8_t(Value));
635 if constexpr(Value == economy::province_building_type::fort) {
636 text::add_line_with_condition(state, contents, "fort_build_tt_1", state.world.province_get_nation_from_province_control(id) == state.local_player_nation);
638
639 int32_t min_build = int32_t(state.world.province_get_modifier_values(id, sys::provincial_mod_offsets::min_build_fort));
640 text::add_line_with_condition(state, contents, "fort_build_tt_3", (max_local_lvl - current_lvl - min_build > 0), text::variable_type::x, int64_t(current_lvl), text::variable_type::n, int64_t(min_build), text::variable_type::y, int64_t(max_local_lvl));
641
642 } else if constexpr(Value == economy::province_building_type::naval_base) {
643 text::add_line_with_condition(state, contents, "fort_build_tt_1", state.world.province_get_nation_from_province_control(id) == state.local_player_nation);
645 text::add_line_with_condition(state, contents, "nb_build_tt_1", state.world.province_get_is_coast(id));
646
647 int32_t min_build = int32_t(state.world.province_get_modifier_values(id, sys::provincial_mod_offsets::min_build_naval_base));
648
649 auto si = state.world.province_get_state_membership(id);
650 text::add_line_with_condition(state, contents, "nb_build_tt_2", current_lvl > 0 || !si.get_naval_base_is_taken());
651
652 text::add_line_with_condition(state, contents, "fort_build_tt_3", (max_local_lvl - current_lvl - min_build > 0), text::variable_type::x, int64_t(current_lvl), text::variable_type::n, int64_t(min_build), text::variable_type::y, int64_t(max_local_lvl));
653
654 } else {
655 text::add_line_with_condition(state, contents, "fort_build_tt_1", state.world.province_get_nation_from_province_control(id) == state.local_player_nation);
657
658 auto rules = state.world.nation_get_combined_issue_rules(state.local_player_nation);
659 text::add_line_with_condition(state, contents, "rr_build_tt_1", (rules & issue_rule::build_railway) != 0);
660
661 int32_t min_build = 0;
662 if constexpr(Value == economy::province_building_type::railroad) {
663 min_build = int32_t(state.world.province_get_modifier_values(id, sys::provincial_mod_offsets::min_build_railroad));
664 } else if constexpr(Value == economy::province_building_type::bank) {
665 min_build = int32_t(state.world.province_get_modifier_values(id, sys::provincial_mod_offsets::min_build_bank));
666 } else if constexpr(Value == economy::province_building_type::university) {
667 min_build = int32_t(state.world.province_get_modifier_values(id, sys::provincial_mod_offsets::min_build_university));
668 }
669 text::add_line_with_condition(state, contents, "fort_build_tt_3", (max_local_lvl - current_lvl - min_build > 0), text::variable_type::x, int64_t(current_lvl), text::variable_type::n, int64_t(min_build), text::variable_type::y, int64_t(max_local_lvl));
670 }
671 modifier_description(state, contents, state.economy_definitions.building_definitions[uint8_t(Value)].province_modifier);
672 text::add_line(state, contents, "alice_province_building_build");
673 }
674};
675
676template<economy::province_building_type Value>
678public:
679 void on_create(sys::state& state) noexcept override {
681 base_data.position.y -= 2;
682 }
683
684 void on_update(sys::state& state) noexcept override {
685 auto content = retrieve<dcon::province_id>(state, parent);
687 }
688
689
692 }
693
694 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
695 auto prov = retrieve<dcon::province_id>(state, parent);
696
697 for(auto pb_con : state.world.province_get_province_building_construction(prov)) {
698 if(pb_con.get_type() == uint8_t(Value)) {
699 auto& goods = state.economy_definitions.building_definitions[int32_t(Value)].cost;
700 auto& cgoods = pb_con.get_purchased_goods();
701
702 float admin_eff = state.world.nation_get_administrative_efficiency(pb_con.get_nation());
703 float admin_cost_factor = pb_con.get_is_pop_project() ? 1.0f : 2.0f - admin_eff;
704
705 for(uint32_t i = 0; i < economy::commodity_set::set_size; ++i) {
706 if(goods.commodity_type[i]) {
707 auto box = text::open_layout_box(contents, 0);
708 text::add_to_layout_box(state, contents, box, state.world.commodity_get_name(goods.commodity_type[i]));
709 text::add_to_layout_box(state, contents, box, std::string_view{ ": " });
710 text::add_to_layout_box(state, contents, box, text::fp_one_place{ cgoods.commodity_amounts[i] });
711 text::add_to_layout_box(state, contents, box, std::string_view{ " / " });
712 text::add_to_layout_box(state, contents, box, text::fp_one_place{ goods.commodity_amounts[i] * admin_cost_factor });
713 text::close_layout_box(contents, box);
714 }
715 }
716
717 return;
718 }
719 }
720 }
721};
722
723template<economy::province_building_type Value>
725 button_element_base* expand_button = nullptr;
726 image_element_base* under_construction_icon = nullptr;
727 element_base* building_progress = nullptr;
728 element_base* expanding_text = nullptr;
729
730 std::string get_icon_name() noexcept {
731 switch(Value) {
733 return "build_icon0";
735 return "build_icon1";
737 return "build_icon2";
739 return "build_icon3";
741 return "build_icon4";
742 default:
743 return "build_icon0";
744 }
745 }
746
747 bool is_being_built(sys::state& state, dcon::province_id id) noexcept {
748 for(auto pb : state.world.province_get_province_building_construction(id))
749 if(economy::province_building_type(pb.get_type()) == Value)
750 return true;
751 return false;
752 }
753
754public:
755 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
756 if(name == get_icon_name()) {
757 return make_element_by_type<province_building_icon<Value>>(state, id);
758 } else if(name == "underconstruction_icon") {
759 auto ptr = make_element_by_type<image_element_base>(state, id);
760 under_construction_icon = ptr.get();
761 return ptr;
762 } else if(name == "building_progress") {
763 auto ptr = make_element_by_type<province_building_progress<Value>>(state, id);
764 building_progress = ptr.get();
765 return ptr;
766 } else if(name == "expand_text") {
767 auto ptr = make_element_by_type<simple_text_element_base>(state, id);
768 expanding_text = ptr.get();
769 return ptr;
770 } else if(name == "expand") {
771 auto ptr = make_element_by_type<province_building_expand_button<Value>>(state, id);
772 expand_button = ptr.get();
773 return ptr;
774 } else if(name == "description") {
775 auto ptr = make_element_by_type<simple_text_element_base>(state, id);
777 return ptr;
778 } else if(name.substr(0, 10) == "build_icon") {
779 return make_element_by_type<invisible_element>(state, id);
780 } else {
781 return nullptr;
782 }
783 }
784
785 void on_update(sys::state& state) noexcept override {
786 auto content = retrieve<dcon::province_id>(state, parent);
787 expand_button->set_visible(state, !is_being_built(state, content));
788 under_construction_icon->set_visible(state, is_being_built(state, content));
789 building_progress->set_visible(state, is_being_built(state, content));
790 expanding_text->set_visible(state, is_being_built(state, content));
791 }
792};
793
794//
795// Selector
796//
798public:
799 void on_update(sys::state& state) noexcept override {
800 auto p = retrieve<dcon::province_id>(state, parent);
801 disabled = !command::can_toggle_select_province(state, state.local_player_nation, p);
802
803 bool found = false;
804 for(auto m : state.world.province_get_current_modifiers(p)) {
805 if(m.mod_id == state.economy_definitions.selector_modifier) {
806 found = true;
807 break;
808 }
809 }
810
811 if(found) {
813 } else {
815 }
816 }
817 void button_action(sys::state& state) noexcept override {
818 auto content = retrieve<dcon::province_id>(state, parent);
819 command::toggle_select_province(state, state.local_player_nation, content);
820 }
821 virtual void button_shift_action(sys::state& state) noexcept override {
822 auto pid = retrieve<dcon::province_id>(state, parent);
823 auto si = state.world.province_get_state_membership(pid);
824 if(si) {
825 province::for_each_province_in_state_instance(state, si, [&](dcon::province_id p) {
826 command::toggle_select_province(state, state.local_player_nation, p);
827 });
828 }
829 }
830};
832public:
833 void on_update(sys::state& state) noexcept override {
834 auto p = retrieve<dcon::province_id>(state, parent);
835 frame = 0;
836 for(auto m : state.world.province_get_current_modifiers(p)) {
837 if(m.mod_id == state.economy_definitions.selector_modifier) {
838 frame = 1;
839 break;
840 }
841 }
842 }
843};
845public:
846 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
847 if(name == "underconstruction_icon"
848 || name == "building_progress"
849 || name == "expand_text") {
850 return make_element_by_type<invisible_element>(state, id);
851 } else if(name == "expand") {
852 return make_element_by_type<province_selector_button>(state, id);
853 } else if(name == "description") {
854 auto ptr = make_element_by_type<simple_text_element_base>(state, id);
855 ptr->set_text(state, text::produce_simple_string(state, "province_selector"));
856 return ptr;
857 } else if(name.substr(0, 10) == "build_icon") {
858 int32_t value = name[10] - '0';
859 int32_t num_buildings = 0;
860 for(auto& def : state.economy_definitions.building_definitions) {
861 if(def.defined)
862 num_buildings++;
863 }
864 if(value == num_buildings) {
865 return make_element_by_type<province_selector_image>(state, id);
866 }
867 return make_element_by_type<invisible_element>(state, id);
868 } else {
869 return nullptr;
870 }
871 }
872};
873
874//
875// Immigrator
876//
878public:
879 void on_update(sys::state& state) noexcept override {
880 auto p = retrieve<dcon::province_id>(state, parent);
882
883 bool found = false;
884 for(auto m : state.world.province_get_current_modifiers(p)) {
885 if(m.mod_id == state.economy_definitions.immigrator_modifier) {
886 found = true;
887 break;
888 }
889 }
890
891 if(found) {
893 } else {
895 }
896 }
897 void button_action(sys::state& state) noexcept override {
898 auto content = retrieve<dcon::province_id>(state, parent);
899 command::toggle_immigrator_province(state, state.local_player_nation, content);
900 }
901 virtual void button_shift_action(sys::state& state) noexcept override {
902 auto pid = retrieve<dcon::province_id>(state, parent);
903 auto si = state.world.province_get_state_membership(pid);
904 if(si) {
905 province::for_each_province_in_state_instance(state, si, [&](dcon::province_id p) {
906 command::toggle_immigrator_province(state, state.local_player_nation, p);
907 });
908 }
909 }
910};
912public:
913 void on_update(sys::state& state) noexcept override {
914 auto p = retrieve<dcon::province_id>(state, parent);
915 frame = 0;
916 for(auto m : state.world.province_get_current_modifiers(p)) {
917 if(m.mod_id == state.economy_definitions.immigrator_modifier) {
918 frame = 1;
919 break;
920 }
921 }
922 }
923};
925public:
926 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
927 if(name == "underconstruction_icon"
928 || name == "building_progress"
929 || name == "expand_text") {
930 return make_element_by_type<invisible_element>(state, id);
931 } else if(name == "expand") {
932 return make_element_by_type<province_immigrator_button>(state, id);
933 } else if(name == "description") {
934 auto ptr = make_element_by_type<simple_text_element_base>(state, id);
935 ptr->set_text(state, text::produce_simple_string(state, "province_immigrator"));
936 return ptr;
937 } else if(name.substr(0, 10) == "build_icon") {
938 int32_t value = name[10] - '0';
939 int32_t num_buildings = 0;
940 for(auto& def : state.economy_definitions.building_definitions) {
941 if(def.defined)
942 num_buildings++;
943 }
944 if(value == num_buildings + 1) {
945 return make_element_by_type<province_immigrator_image>(state, id);
946 }
947 return make_element_by_type<invisible_element>(state, id);
948 } else {
949 return nullptr;
950 }
951 }
952};
953
955public:
956 void button_action(sys::state& state) noexcept override {
957 auto content = retrieve<dcon::province_id>(state, parent);
959 }
960 virtual void button_shift_action(sys::state& state) noexcept override {
961 auto pid = retrieve<dcon::province_id>(state, parent);
962 auto si = state.world.province_get_state_membership(pid);
963 if(si) {
964 province::for_each_province_in_state_instance(state, si, [&](dcon::province_id p) {
966 });
967 }
968 }
969 virtual void button_shift_right_action(sys::state& state) noexcept override {
970 auto pid = retrieve<dcon::province_id>(state, parent);
971 auto n = state.world.province_get_nation_from_province_ownership(pid);
972 for(auto p : state.world.nation_get_province_ownership(n)) {
974 }
975 }
976 void on_update(sys::state& state) noexcept override {
977 auto content = retrieve<dcon::province_id>(state, parent);
980 }
981};
982
984public:
987 }
988};
989
990template<economy::province_building_type Value>
992public:
995 }
996 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
997 auto box = text::open_layout_box(contents, 0);
998 switch(Value) {
1000 text::localised_format_box(state, contents, box, std::string_view("pv_railroad"));
1001 break;
1003 text::localised_format_box(state, contents, box, std::string_view("pv_fort"));
1004 break;
1006 text::localised_format_box(state, contents, box, std::string_view("pv_navalbase"));
1007 break;
1009 text::localised_format_box(state, contents, box, std::string_view("pv_bank"));
1010 break;
1012 text::localised_format_box(state, contents, box, std::string_view("pv_university"));
1013 break;
1014 default:
1015 break;
1016 }
1017 text::close_layout_box(contents, box);
1018 }
1019};
1020
1022public:
1023 void button_action(sys::state& state) noexcept override {
1024 auto content = retrieve<dcon::province_id>(state, parent);
1025 if(content) {
1026 open_build_foreign_factory(state, state.world.province_get_state_membership(content));
1027 }
1028
1029 }
1030
1031 void on_update(sys::state& state) noexcept override {
1032 auto content = retrieve<dcon::province_id>(state, parent);
1033 disabled = true;
1034
1035 if(!content)
1036 return;
1037
1038 for(auto ft : state.world.in_factory_type) {
1040 state.world.province_get_state_membership(content), ft, false)) {
1041
1042 disabled = false;
1043 return;
1044 }
1045 }
1046 }
1047};
1048
1050public:
1051 void on_update(sys::state& state) noexcept override {
1052 auto province_id = retrieve<dcon::province_id>(state, parent);
1053 auto supply = int32_t(military::peacetime_attrition_limit(state, state.local_player_nation, province_id));
1054 set_text(state, std::to_string(supply));
1055 }
1056
1057 // TODO: needs an explanation of where the value comes from
1058};
1059
1061public:
1062 void on_update(sys::state& state) noexcept override {
1063 auto prov = retrieve<dcon::province_id>(state, parent);
1065 }
1066};
1067
1069public:
1070 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1071 if(name == "building_progress") {
1072 return make_element_by_type<rr_investment_progress>(state, id);
1073 } else {
1074 return nullptr;
1075 }
1076 }
1077 void impl_render(sys::state& state, int32_t x, int32_t y) noexcept override {
1078 auto prov = retrieve<dcon::province_id>(state, parent);
1081 }
1082 }
1083 message_result test_mouse(sys::state& state, int32_t x, int32_t y, mouse_probe_type type) noexcept override {
1084 auto prov = retrieve<dcon::province_id>(state, parent);
1088 }
1089};
1090
1092private:
1093 province_country_flag_button* country_flag_button = nullptr;
1094 culture_piechart<dcon::province_id>* culture_chart = nullptr;
1095 ideology_piechart<dcon::province_id>* ideology_chart = nullptr;
1096 workforce_piechart<dcon::province_id>* workforce_chart = nullptr;
1097
1098public:
1099 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1100 if(name == "country_name") {
1101 return make_element_by_type<generic_name_text<dcon::nation_id>>(state, id);
1102 } else if(name == "country_flag") {
1103 auto ptr = make_element_by_type<province_country_flag_button>(state, id);
1104 country_flag_button = ptr.get();
1105 return ptr;
1106 } else if(name == "country_gov") {
1107 return make_element_by_type<nation_government_type_text>(state, id);
1108 } else if(name == "country_party") {
1109 return make_element_by_type<nation_ruling_party_text>(state, id);
1110 } else if(name == "country_prestige") {
1111 return make_element_by_type<nation_prestige_text>(state, id);
1112 } else if(name == "country_economic") {
1113 return make_element_by_type<nation_industry_score_text>(state, id);
1114 } else if(name == "country_military") {
1115 return make_element_by_type<nation_military_score_text>(state, id);
1116 } else if(name == "country_total") {
1117 return make_element_by_type<nation_total_score_text>(state, id);
1118 } else if(name == "selected_prestige_rank") {
1119 return make_element_by_type<nation_prestige_rank_text>(state, id);
1120 } else if(name == "selected_industry_rank") {
1121 return make_element_by_type<nation_industry_rank_text>(state, id);
1122 } else if(name == "selected_military_rank") {
1123 return make_element_by_type<nation_military_rank_text>(state, id);
1124 } else if(name == "selected_total_rank") {
1125 return make_element_by_type<nation_rank_text>(state, id);
1126 } else if(name == "country_status") {
1127 return make_element_by_type<nation_status_text>(state, id);
1128 } else if(name == "country_flag_overlay") {
1129 return make_element_by_type<nation_flag_frame>(state, id);
1130 } else if(name == "total_population") {
1131 return make_element_by_type<province_population>(state, id);
1132 } else if(name == "sphere_label") {
1133 return make_element_by_type<nation_sphere_list_label>(state, id);
1134 } else if(name == "puppet_label") {
1135 return make_element_by_type<nation_puppet_list_label>(state, id);
1136 } else if(name == "our_relation") {
1137 return make_element_by_type<nation_player_relations_text>(state, id);
1138 } else if(name == "workforce_chart") {
1139 auto ptr = make_element_by_type<workforce_piechart<dcon::province_id>>(state, id);
1140 workforce_chart = ptr.get();
1141 return ptr;
1142 } else if(name == "ideology_chart") {
1143 auto ptr = make_element_by_type<ideology_piechart<dcon::province_id>>(state, id);
1144 ideology_chart = ptr.get();
1145 return ptr;
1146 } else if(name == "culture_chart") {
1147 auto ptr = make_element_by_type<culture_piechart<dcon::province_id>>(state, id);
1148 culture_chart = ptr.get();
1149 return ptr;
1150 } else if(name == "goods_type") {
1151 return make_element_by_type<province_rgo>(state, id);
1152 } else if(name == "build_icon_fort") {
1153 return make_element_by_type<province_view_foreign_building_icon<economy::province_building_type::fort>>(state, id);
1154 } else if(name == "build_icon_navalbase") {
1155 return make_element_by_type<province_view_foreign_building_icon<economy::province_building_type::naval_base>>(state, id);
1156 } else if(name == "build_icon_infra") {
1157 return make_element_by_type<province_view_foreign_building_icon<economy::province_building_type::railroad>>(state, id);
1158 } else if(name == "build_icon_bank") {
1159 return make_element_by_type<province_view_foreign_building_icon<economy::province_building_type::bank>>(state, id);
1160 } else if(name == "build_icon_university") {
1161 return make_element_by_type<province_view_foreign_building_icon<economy::province_building_type::university>>(state, id);
1162 } else if(name == "infra_progress_win") {
1163 return make_element_by_type<rr_invest_inwdow>(state, id);
1164 } else if(name == "invest_build_infra") {
1165 return make_element_by_type<province_invest_railroad_button>(state, id);
1166 } else if(name == "invest_factory_button") {
1167 return make_element_by_type<province_invest_factory_button>(state, id);
1168 } else if(name == "sphere_targets") {
1169 return make_element_by_type<overlapping_sphere_flags>(state, id);
1170 } else if(name == "puppet_targets") {
1171 return make_element_by_type<overlapping_puppet_flags>(state, id);
1172 } else if(name == "allied_targets") {
1173 return make_element_by_type<overlapping_ally_flags>(state, id);
1174 } else if(name == "war_targets") {
1175 return make_element_by_type<overlapping_enemy_flags>(state, id);
1176 } else if(name == "send_diplomat") {
1177 return make_element_by_type<province_send_diplomat_button>(state, id);
1178 } else if(name == "core_icons") {
1179 return make_element_by_type<province_core_flags>(state, id);
1180 } else if(name == "supply_limit") {
1181 return make_element_by_type<province_supply_limit_text>(state, id);
1182 } else if (name == "selected_military_icon") {
1183 auto ptr = make_element_by_type<military_score_icon>(state, id);
1184 return ptr;
1185 } else if(name == "rallypoint_checkbox") {
1186 return make_element_by_type<land_rally_point>(state, id);
1187 } else if(name == "rallypoint_checkbox_naval") {
1188 return make_element_by_type<naval_rally_point>(state, id);
1189 } else if(name == "rallypoint_merge_checkbox" || name == "rallypoint_merge_checkbox_naval") {
1190 return make_element_by_type<merge_rally_point>(state, id);
1191 } else {
1192 return nullptr;
1193 }
1194 }
1195
1196 void on_update(sys::state& state) noexcept override {
1197 auto prov_id = retrieve<dcon::province_id>(state, parent);
1198 dcon::province_fat_id fat_id = dcon::fatten(state.world, prov_id);
1199 auto nation_id = fat_id.get_nation_from_province_ownership();
1200 if(!bool(nation_id) || nation_id.id == state.local_player_nation) {
1201 set_visible(state, false);
1202 } else {
1203 country_flag_button->impl_on_update(state);
1204 culture_chart->impl_on_update(state);
1205 workforce_chart->impl_on_update(state);
1206 ideology_chart->impl_on_update(state);
1207 set_visible(state, true);
1208 }
1209 }
1210};
1211
1212void province_owner_rgo_draw_tooltip(sys::state& state, text::columnar_layout& contents, dcon::province_id prov_id) noexcept;
1213
1215public:
1218 }
1219 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1220 auto prov_id = retrieve<dcon::province_id>(state, parent);
1221 province_owner_rgo_draw_tooltip(state, contents, prov_id);
1222 }
1223};
1224
1226public:
1229 }
1230 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1231 auto prov_id = retrieve<dcon::province_id>(state, parent);
1232 province_owner_rgo_draw_tooltip(state, contents, prov_id);
1233 }
1234};
1235
1237public:
1240 }
1241 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1242 auto prov_id = retrieve<dcon::province_id>(state, parent);
1243 province_owner_rgo_draw_tooltip(state, contents, prov_id);
1244 }
1245};
1246
1248public:
1249 void on_update(sys::state& state) noexcept override {
1250 auto province = retrieve<dcon::province_id>(state, parent);
1252 auto employment_ratio = province::land_employment(state, province) / (max_emp + 1.f);
1253 frame = int32_t(10.f * employment_ratio);
1254 }
1257 }
1258 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1259 auto prov_id = retrieve<dcon::province_id>(state, parent);
1260 auto owner = state.world.province_get_nation_from_province_ownership(prov_id);
1261 auto max_emp = province::land_maximum_employment(state, prov_id);
1262 auto employment_ratio = province::land_employment(state, prov_id) / (max_emp + 1.f);
1263
1264 bool is_mine = state.world.commodity_get_is_mine(state.world.province_get_rgo(prov_id));
1265 float const min_wage_factor = economy::pop_min_wage_factor(state, owner);
1266 float farmer_min_wage = economy::pop_farmer_min_wage(state, owner, min_wage_factor);
1267 float laborer_min_wage = economy::pop_laborer_min_wage(state, owner, min_wage_factor);
1268 float expected_min_wage = is_mine ? laborer_min_wage : farmer_min_wage;
1269
1270 auto box = text::open_layout_box(contents);
1271 text::add_to_layout_box(state, contents, box, int64_t(std::ceil(employment_ratio * max_emp)));
1272 text::add_to_layout_box(state, contents, box, std::string_view{" / "});
1273 text::add_to_layout_box(state, contents, box, int64_t(std::ceil(max_emp)));
1274
1275 text::close_layout_box(contents, box);
1276 }
1277};
1278
1280public:
1283 }
1284 void on_update(sys::state& state) noexcept override {
1285 auto prov_id = retrieve<dcon::province_id>(state, parent);
1286 auto fat_id = dcon::fatten(state.world, prov_id);
1287 frame = fat_id.get_crime().index() + 1;
1288 }
1289 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1290 auto province = retrieve<dcon::province_id>(state, parent);
1291 auto crime = state.world.province_get_crime(province);
1292 if(crime) {
1293 modifier_description(state, contents, state.culture_definitions.crimes[crime].modifier);
1294 }
1295 }
1296};
1297
1299public:
1300 void on_update(sys::state& state) noexcept override {
1301 auto province_id = retrieve<dcon::province_id>(state, parent);
1302 auto fat_id = dcon::fatten(state.world, province_id);
1303 auto crime_id = fat_id.get_crime();
1304 if(crime_id) {
1305 set_text(state, text::produce_simple_string(state, state.culture_definitions.crimes[crime_id].name));
1306 } else {
1307 set_text(state, "");
1308 }
1309 }
1310
1313 }
1314 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1315 auto province = retrieve<dcon::province_id>(state, parent);
1316 auto crime = state.world.province_get_crime(province);
1317 if(crime) {
1318 modifier_description(state, contents, state.culture_definitions.crimes[crime].modifier);
1319 }
1320 }
1321};
1322
1324public:
1325 void on_update(sys::state& state) noexcept override {
1326 auto province_id = retrieve<dcon::province_id>(state, parent);
1328 }
1329
1330 /*
1331 // TODO: explain where the value comes from
1332 tooltip_behavior has_tooltip(sys::state& state) noexcept override {
1333 return tooltip_behavior::variable_tooltip;
1334 }
1335
1336 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1337 auto content = retrieve<dcon::province_id>(state, parent);
1338 auto box = text::open_layout_box(contents, 0);
1339 text::localised_single_sub_box(state, contents, box, std::string_view("provinceview_crimefight"), text::variable_type::value, text::fp_one_place{province::crime_fighting_efficiency(state, content) * 100});
1340 text::close_layout_box(contents, box);
1341 }
1342 */
1343
1346 }
1347 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1348 auto content = retrieve<dcon::province_id>(state, parent);
1349 ui::active_modifiers_description(state, contents, state.world.province_control_get_nation(state.world.province_get_province_control_as_province(content)), 0, sys::national_mod_offsets::administrative_efficiency_modifier, true);
1350 }
1351};
1352
1354public:
1355 void on_update(sys::state& state) noexcept override {
1356 auto province_id = retrieve<dcon::province_id>(state, parent);
1358 }
1361 }
1362 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1363 auto content = retrieve<dcon::province_id>(state, parent);
1365 ui::active_modifiers_description(state, contents, state.world.province_control_get_nation(state.world.province_get_province_control_as_province(content)), 0, sys::national_mod_offsets::core_pop_militancy_modifier, true);
1366 ui::active_modifiers_description(state, contents, state.world.province_control_get_nation(state.world.province_get_province_control_as_province(content)), 0, sys::national_mod_offsets::global_pop_militancy_modifier, true);
1367 ui::active_modifiers_description(state, contents, state.world.province_control_get_nation(state.world.province_get_province_control_as_province(content)), 0, sys::national_mod_offsets::non_accepted_pop_militancy_modifier, true);
1368 }
1369};
1370
1372public:
1373 void on_update(sys::state& state) noexcept override {
1374 auto province_id = retrieve<dcon::province_id>(state, parent);
1375 set_text(state, text::format_percentage(state.world.province_get_rgo_employment(province_id), 1));
1376 }
1379 }
1380 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1381 auto content = retrieve<dcon::province_id>(state, parent);
1382 ui::active_modifiers_description(state, contents, content, 0, sys::provincial_mod_offsets::farm_rgo_eff, true);
1383 ui::active_modifiers_description(state, contents, content, 0, sys::provincial_mod_offsets::farm_rgo_size, true);
1384 ui::active_modifiers_description(state, contents, content, 0, sys::provincial_mod_offsets::mine_rgo_eff, true);
1385 ui::active_modifiers_description(state, contents, content, 0, sys::provincial_mod_offsets::mine_rgo_size, true);
1386 ui::active_modifiers_description(state, contents, content, 0, sys::provincial_mod_offsets::local_rgo_input, true);
1387 ui::active_modifiers_description(state, contents, content, 0, sys::provincial_mod_offsets::local_rgo_output, true);
1388 ui::active_modifiers_description(state, contents, content, 0, sys::provincial_mod_offsets::local_rgo_throughput, true);
1389 ui::active_modifiers_description(state, contents, state.world.province_control_get_nation(state.world.province_get_province_control_as_province(content)), 0, sys::national_mod_offsets::rgo_input, true);
1390 ui::active_modifiers_description(state, contents, state.world.province_control_get_nation(state.world.province_get_province_control_as_province(content)), 0, sys::national_mod_offsets::rgo_output, true);
1391 ui::active_modifiers_description(state, contents, state.world.province_control_get_nation(state.world.province_get_province_control_as_province(content)), 0, sys::national_mod_offsets::rgo_throughput, true);
1392 ui::active_modifiers_description(state, contents, state.world.province_control_get_nation(state.world.province_get_province_control_as_province(content)), 0, sys::national_mod_offsets::farm_rgo_eff, true);
1393 ui::active_modifiers_description(state, contents, state.world.province_control_get_nation(state.world.province_get_province_control_as_province(content)), 0, sys::national_mod_offsets::farm_rgo_size, true);
1394 ui::active_modifiers_description(state, contents, state.world.province_control_get_nation(state.world.province_get_province_control_as_province(content)), 0, sys::national_mod_offsets::mine_rgo_eff, true);
1395 ui::active_modifiers_description(state, contents, state.world.province_control_get_nation(state.world.province_get_province_control_as_province(content)), 0, sys::national_mod_offsets::mine_rgo_size, true);
1396 }
1397};
1398
1400public:
1401 void on_update(sys::state& state) noexcept override {
1402 auto province_id = retrieve<dcon::province_id>(state, parent);
1403 auto migration = state.world.province_get_daily_net_migration(province_id);
1404 auto immigration = state.world.province_get_daily_net_immigration(province_id);
1405 set_text(state, text::prettify(int32_t(migration - immigration)));
1406 }
1409 }
1410 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1411 auto content = retrieve<dcon::province_id>(state, parent);
1412 ui::active_modifiers_description(state, contents, content, 0, sys::provincial_mod_offsets::immigrant_attract, true);
1413 ui::active_modifiers_description(state, contents, content, 0, sys::provincial_mod_offsets::immigrant_push, true);
1414 if(state.world.province_get_is_colonial(content)) {
1415 ui::active_modifiers_description(state, contents, state.world.province_control_get_nation(state.world.province_get_province_control_as_province(content)), 0, sys::national_mod_offsets::colonial_migration, true);
1416 }
1417 ui::active_modifiers_description(state, contents, state.world.province_control_get_nation(state.world.province_get_province_control_as_province(content)), 0, sys::national_mod_offsets::global_immigrant_attract, true);
1418 }
1419};
1420
1422public:
1423 void on_update(sys::state& state) noexcept override {
1424 auto province_id = retrieve<dcon::province_id>(state, parent);
1426 }
1429 }
1430 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1431 auto content = retrieve<dcon::province_id>(state, parent);
1432 ui::active_modifiers_description(state, contents, content, 0, sys::provincial_mod_offsets::population_growth, true);
1433 ui::active_modifiers_description(state, contents, state.world.province_control_get_nation(state.world.province_get_province_control_as_province(content)), 0, sys::national_mod_offsets::pop_growth, true);
1434 }
1435};
1436
1438public:
1439 void on_update(sys::state& state) noexcept override {
1440 auto province_id = retrieve<dcon::province_id>(state, parent);
1441 auto built = military::regiments_created_from_province(state, province_id);
1442 auto max_possible = military::regiments_max_possible_from_province(state, province_id);
1443 set_text(state, text::format_ratio(built, max_possible));
1444 }
1445};
1446
1448private:
1449 culture_piechart<dcon::province_id>* culture_chart = nullptr;
1450 ideology_piechart<dcon::province_id>* ideology_chart = nullptr;
1451 workforce_piechart<dcon::province_id>* workforce_chart = nullptr;
1452
1453public:
1454 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1455 if(name == "goods_type") {
1456 return make_element_by_type<province_owner_rgo>(state, id);
1457 } else if(name == "open_popscreen") {
1458 return make_element_by_type<province_pop_button>(state, id);
1459 } else if(name == "total_population") {
1460 return make_element_by_type<province_population>(state, id);
1461 } else if(name == "workforce_chart") {
1462 auto ptr = make_element_by_type<workforce_piechart<dcon::province_id>>(state, id);
1463 workforce_chart = ptr.get();
1464 return ptr;
1465 } else if(name == "ideology_chart") {
1466 auto ptr = make_element_by_type<ideology_piechart<dcon::province_id>>(state, id);
1467 ideology_chart = ptr.get();
1468 return ptr;
1469 } else if(name == "culture_chart") {
1470 auto ptr = make_element_by_type<culture_piechart<dcon::province_id>>(state, id);
1471 culture_chart = ptr.get();
1472 return ptr;
1473 } else if(name == "core_icons") {
1474 return make_element_by_type<province_core_flags>(state, id);
1475 } else if(name == "supply_limit") {
1476 return make_element_by_type<province_supply_limit_text>(state, id);
1477 } else if(name == "crime_icon") {
1478 return make_element_by_type<province_crime_icon>(state, id);
1479 } else if(name == "crime_name") {
1480 return make_element_by_type<province_crime_name_text>(state, id);
1481 } else if(name == "crimefight_percent") {
1482 return make_element_by_type<province_crime_fighting_text>(state, id);
1483 } else if(name == "rebel_percent") {
1484 return make_element_by_type<province_rebel_percent_text>(state, id);
1485 } else if(name == "employment_ratio") {
1486 return make_element_by_type<province_rgo_employment_progress_icon>(state, id);
1487 } else if(name == "rgo_population") {
1488 return make_element_by_type<province_rgo_workers_text>(state, id);
1489 } else if(name == "rgo_percent") {
1490 return make_element_by_type<province_rgo_employment_percent_text>(state, id);
1491 } else if(name == "produced") {
1492 return make_element_by_type<province_owner_goods_produced_text>(state, id);
1493 } else if(name == "income") {
1494 return make_element_by_type<province_owner_income_text>(state, id);
1495 } else if(name == "growth") {
1496 return make_element_by_type<province_pop_growth_text>(state, id);
1497 } else if(name == "migration") {
1498 return make_element_by_type<province_migration_text>(state, id);
1499 } else if(name == "build_factory_button") {
1500 return make_element_by_type<province_build_new_factory>(state, id);
1501 } else {
1502 return nullptr;
1503 }
1504 }
1505
1506 void on_update(sys::state& state) noexcept override {
1507 auto prov_id = retrieve<dcon::province_id>(state, parent);
1508 dcon::province_fat_id fat_id = dcon::fatten(state.world, prov_id);
1509 auto nation_id = fat_id.get_nation_from_province_ownership();
1510 if(bool(nation_id) && nation_id.id == state.local_player_nation) {
1511 culture_chart->impl_on_update(state);
1512 workforce_chart->impl_on_update(state);
1513 ideology_chart->impl_on_update(state);
1514 set_visible(state, true);
1515 } else {
1516 set_visible(state, false);
1517 }
1518 }
1519};
1520
1522public:
1523 void on_update(sys::state& state) noexcept override {
1524 progress = 0.f;
1525 float amount = 0.f;
1526 float total = 0.f;
1527 auto p = retrieve<dcon::province_id>(state, parent);
1528 for(auto pop : dcon::fatten(state.world, p).get_pop_location()) {
1529 if(pop.get_pop().get_poptype() == state.culture_definitions.soldiers) {
1530 auto lcs = pop.get_pop().get_province_land_construction();
1531 for(const auto lc : lcs) {
1532 auto& base_cost = state.military_definitions.unit_base_definitions[lc.get_type()].build_cost;
1533 auto& current_purchased = lc.get_purchased_goods();
1534 for(uint32_t i = 0; i < economy::commodity_set::set_size; ++i) {
1535 if(base_cost.commodity_type[i]) {
1536 amount += current_purchased.commodity_amounts[i];
1537 total += base_cost.commodity_amounts[i];
1538 } else {
1539 break;
1540 }
1541 }
1542 }
1543 }
1544 }
1545 if(total > 0.f) {
1546 progress = amount / total;
1547 }
1548 }
1549};
1551public:
1552 void on_update(sys::state& state) noexcept override {
1553 progress = 0.f;
1554 float amount = 0.f;
1555 float total = 0.f;
1556 auto p = retrieve<dcon::province_id>(state, parent);
1557 auto ncs = state.world.province_get_province_naval_construction(p);
1558 for(auto nc : ncs) {
1559 auto& base_cost = state.military_definitions.unit_base_definitions[nc.get_type()].build_cost;
1560 auto& current_purchased = nc.get_purchased_goods();
1561 for(uint32_t i = 0; i < economy::commodity_set::set_size; ++i) {
1562 if(base_cost.commodity_type[i]) {
1563 amount += current_purchased.commodity_amounts[i];
1564 total += base_cost.commodity_amounts[i];
1565 } else {
1566 break;
1567 }
1568 }
1569 }
1570 if(total > 0.f) {
1571 progress = amount / total;
1572 }
1573 }
1574};
1575
1577public:
1578 void on_update(sys::state& state) noexcept override {
1579 float amount = 0.f;
1580 float total = 0.f;
1581 auto p = retrieve<dcon::province_id>(state, parent);
1582 for(auto pop : dcon::fatten(state.world, p).get_pop_location()) {
1583 if(pop.get_pop().get_poptype() == state.culture_definitions.soldiers) {
1584 auto lcs = pop.get_pop().get_province_land_construction();
1585 for(const auto lc : lcs) {
1586 auto& base_cost = state.military_definitions.unit_base_definitions[lc.get_type()].build_cost;
1587 auto& current_purchased = lc.get_purchased_goods();
1588 for(uint32_t i = 0; i < economy::commodity_set::set_size; ++i) {
1589 if(base_cost.commodity_type[i]) {
1590 amount += current_purchased.commodity_amounts[i];
1591 total += base_cost.commodity_amounts[i];
1592 } else {
1593 break;
1594 }
1595 }
1596 }
1597 }
1598 }
1599 set_text(state, text::format_percentage(total > 0.f ? amount / total : 0.f));
1600 }
1601};
1603public:
1604 void on_update(sys::state& state) noexcept override {
1605 float amount = 0.f;
1606 float total = 0.f;
1607 auto p = retrieve<dcon::province_id>(state, parent);
1608 auto ncs = state.world.province_get_province_naval_construction(p);
1609 for(auto nc : ncs) {
1610 auto& base_cost = state.military_definitions.unit_base_definitions[nc.get_type()].build_cost;
1611 auto& current_purchased = nc.get_purchased_goods();
1612 for(uint32_t i = 0; i < economy::commodity_set::set_size; ++i) {
1613 if(base_cost.commodity_type[i]) {
1614 amount += current_purchased.commodity_amounts[i];
1615 total += base_cost.commodity_amounts[i];
1616 } else {
1617 break;
1618 }
1619 }
1620 }
1621 set_text(state, text::format_percentage(total > 0.f ? amount / total : 0.f));
1622 }
1623};
1624
1625
1626template<typename T>
1628public:
1629 void on_update(sys::state& state) noexcept override {
1630 disabled = true;
1631 //
1632 auto p = retrieve<dcon::province_id>(state, parent);
1633 for(uint8_t i = 2; i < state.military_definitions.unit_base_definitions.size(); i++) {
1634 auto utid = dcon::unit_type_id(i);
1635 auto const& def = state.military_definitions.unit_base_definitions[utid];
1636 if(!def.active && !state.world.nation_get_active_unit(state.local_player_nation, utid))
1637 continue;
1638 if(def.is_land != std::is_same_v<T, dcon::army_id>)
1639 continue;
1640 if constexpr(std::is_same_v<T, dcon::army_id>) {
1641 for(const auto c : state.world.in_culture) {
1642 if(command::can_start_land_unit_construction(state, state.local_player_nation, p, c, utid)) {
1643 for(auto pl : state.world.province_get_pop_location_as_province(p)) {
1644 if(pl.get_pop().get_culture() == c) {
1645 if(pl.get_pop().get_poptype() == state.culture_definitions.soldiers && state.world.pop_get_size(pl.get_pop()) >= state.defines.pop_min_size_for_regiment) {
1646 disabled = false;
1647 break;
1648 }
1649 }
1650 }
1651 } else {
1652 //not disabled when there are constructions
1653 for(auto pl : state.world.province_get_pop_location_as_province(p)) {
1654 auto lc = pl.get_pop().get_province_land_construction();
1655 if(lc.begin() != lc.end()) {
1656 disabled = false;
1657 break;
1658 }
1659 }
1660 }
1661 if(!disabled)
1662 break;
1663 }
1664 } else {
1665 disabled = !command::can_start_naval_unit_construction(state, state.local_player_nation, p, utid);
1666 }
1667 if(!disabled)
1668 break;
1669 }
1670 }
1671
1672 void button_action(sys::state& state) noexcept override {
1673 if(state.ui_state.build_province_unit_window) {
1675 Cyto::Any payload = Cyto::any_cast<T>(T{});
1676 state.ui_state.build_province_unit_window->impl_get(state, payload);
1677 }
1678 }
1679};
1680
1682public:
1683 void on_create(sys::state& state) noexcept override {
1685 int16_t y_offset = 1;
1686 {
1687 auto ptr = make_element_by_type<province_building_window<economy::province_building_type::fort>>(state, "building");
1688 ptr->base_data.position.y = y_offset;
1689 y_offset += 35;
1690 add_child_to_front(std::move(ptr));
1691 }
1692 {
1693 auto ptr = make_element_by_type<province_building_window<economy::province_building_type::naval_base>>(state, "building");
1694 ptr->base_data.position.y = y_offset;
1695 y_offset += 35;
1696 add_child_to_front(std::move(ptr));
1697 }
1698 {
1699 auto ptr = make_element_by_type<province_building_window<economy::province_building_type::railroad>>(state, "building");
1700 ptr->base_data.position.y = y_offset;
1701 y_offset += 35;
1702 add_child_to_front(std::move(ptr));
1703 }
1704 if(state.economy_definitions.building_definitions[int32_t(economy::province_building_type::bank)].defined) {
1705 auto ptr = make_element_by_type<province_building_window<economy::province_building_type::bank>>(state, "building");
1706 ptr->base_data.position.y = y_offset;
1707 y_offset += 35;
1708 add_child_to_front(std::move(ptr));
1709 }
1710 if(state.economy_definitions.building_definitions[int32_t(economy::province_building_type::university)].defined) {
1711 auto ptr = make_element_by_type<province_building_window<economy::province_building_type::university>>(state, "building");
1712 ptr->base_data.position.y = y_offset;
1713 y_offset += 35;
1714 add_child_to_front(std::move(ptr));
1715 }
1716 if(bool(state.economy_definitions.selector_modifier)) {
1717 auto ptr = make_element_by_type<province_selector_window>(state, "building");
1718 ptr->base_data.position.y = y_offset;
1719 y_offset += 35;
1720 add_child_to_front(std::move(ptr));
1721 }
1722 if(bool(state.economy_definitions.immigrator_modifier)) {
1723 auto ptr = make_element_by_type<province_immigrator_window>(state, "building");
1724 ptr->base_data.position.y = y_offset;
1725 y_offset += 35;
1726 add_child_to_front(std::move(ptr));
1727 }
1728 }
1729
1730 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1731 if(name == "army_size") {
1732 return make_element_by_type<province_army_size_text>(state, id);
1733 } else if(name == "army_progress") {
1734 return make_element_by_type<province_army_progress>(state, id);
1735 } else if(name == "navy_progress") {
1736 return make_element_by_type<province_navy_progress>(state, id);
1737 } else if(name == "rallypoint_checkbox") {
1738 return make_element_by_type<land_rally_point>(state, id);
1739 } else if(name == "rallypoint_checkbox_naval") {
1740 return make_element_by_type<naval_rally_point>(state, id);
1741 } else if(name == "rallypoint_merge_checkbox" || name == "rallypoint_merge_checkbox_naval") {
1742 return make_element_by_type<merge_rally_point>(state, id);
1743 } else if(name == "build_army") {
1744 return make_element_by_type<province_build_unit<dcon::army_id>>(state, id);
1745 } else if(name == "build_navy") {
1746 return make_element_by_type<province_build_unit<dcon::navy_id>>(state, id);
1747 } else if(name == "army_text") {
1748 return make_element_by_type<province_army_progress_text>(state, id);
1749 } else if(name == "navy_text") {
1750 return make_element_by_type<province_navy_progress_text>(state, id);
1751 } else {
1752 return nullptr;
1753 }
1754 }
1755
1756 void on_update(sys::state& state) noexcept override {
1757 auto prov_id = retrieve<dcon::province_id>(state, parent);
1758 dcon::province_fat_id fat_id = dcon::fatten(state.world, prov_id);
1759 auto nation_id = fat_id.get_nation_from_province_ownership();
1760 if(bool(nation_id) && nation_id.id == state.local_player_nation) {
1761 set_visible(state, true);
1762 } else {
1763 set_visible(state, false);
1764 }
1765 }
1766};
1767
1769public:
1770 void button_action(sys::state& state) noexcept override {
1771 auto content = retrieve<dcon::province_id>(state, parent);
1772 command::finish_colonization(state, state.local_player_nation, content);
1773 state.ui_state.province_window->set_visible(state, false);
1774 state.map_state.set_selected_province(dcon::province_id{});
1775 }
1776
1777 void on_update(sys::state& state) noexcept override {
1778 auto content = retrieve<dcon::province_id>(state, parent);
1779 disabled = !command::can_finish_colonization(state, state.local_player_nation, content);
1780 }
1781};
1782
1784public:
1785 void button_action(sys::state& state) noexcept override {
1786 auto content = retrieve<dcon::province_id>(state, parent);
1787 command::abandon_colony(state, state.local_player_nation, content);
1788 }
1789
1790 void on_update(sys::state& state) noexcept override {
1791 auto content = retrieve<dcon::province_id>(state, parent);
1792 disabled = !command::can_abandon_colony(state, state.local_player_nation, content);
1793 }
1794};
1795
1797public:
1798 void button_action(sys::state& state) noexcept override {
1799 auto content = retrieve<dcon::province_id>(state, parent);
1800 command::invest_in_colony(state, state.local_player_nation, content);
1801 }
1802
1803 void on_update(sys::state& state) noexcept override {
1804 auto content = retrieve<dcon::province_id>(state, parent);
1805 disabled = !command::can_invest_in_colony(state, state.local_player_nation, content);
1806 }
1807
1810 }
1811
1812 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1813 auto province = retrieve<dcon::province_id>(state, parent);
1814 auto sdef = state.world.province_get_state_from_abstract_state_membership(province);
1815 auto col = retrieve<dcon::colonization_id>(state, parent);
1816
1817 if(!province::is_colonizing(state, state.local_player_nation, sdef)) {
1818 text::add_line(state, contents, "col_start_title");
1820
1821 text::add_line_with_condition(state, contents, "col_start_1", state.world.state_definition_get_colonization_stage(sdef) <= uint8_t(1));
1822 text::add_line_with_condition(state, contents, "col_start_2", state.world.nation_get_rank(state.local_player_nation) <= uint16_t(state.defines.colonial_rank), text::variable_type::x, uint16_t(state.defines.colonial_rank));
1823 text::add_line_with_condition(state, contents, "col_start_3", state.crisis_colony != sdef);
1824
1825 bool war_participant = false;
1826 for(auto par : state.world.war_get_war_participant(state.crisis_war)) {
1827 if(par.get_nation() == state.local_player_nation)
1828 war_participant = true;
1829 }
1830 text::add_line_with_condition(state, contents, "col_start_4", !war_participant);
1831
1832 float max_life_rating = -1.0f;
1833 for(auto p : state.world.state_definition_get_abstract_state_membership(sdef)) {
1834 if(!p.get_province().get_nation_from_province_ownership()) {
1835 max_life_rating = std::max(max_life_rating, float(p.get_province().get_life_rating()));
1836 }
1837 }
1838
1839 text::add_line_with_condition(state, contents, "col_start_5",
1840 state.defines.colonial_liferating + state.world.nation_get_modifier_values(state.local_player_nation, sys::national_mod_offsets::colonial_life_rating) <= max_life_rating,
1841 text::variable_type::x, int64_t(state.defines.colonial_liferating + state.world.nation_get_modifier_values(state.local_player_nation, sys::national_mod_offsets::colonial_life_rating)),
1842 text::variable_type::y, int64_t(max_life_rating));
1843 text::add_line(state, contents, "col_start_6", text::variable_type::x, int64_t(state.defines.colonial_liferating), 15);
1844 active_modifiers_description(state, contents, state.local_player_nation, 15, sys::national_mod_offsets::colonial_life_rating, false);
1845
1846 auto colonizers = state.world.state_definition_get_colonization(sdef);
1847 auto num_colonizers = colonizers.end() - colonizers.begin();
1848
1849 text::add_line_with_condition(state, contents, "col_start_7", num_colonizers < 4);
1850
1851 bool adjacent = [&]() {
1852 for(auto p : state.world.state_definition_get_abstract_state_membership(sdef)) {
1853 if(!p.get_province().get_nation_from_province_ownership()) {
1854 for(auto adj : p.get_province().get_province_adjacency()) {
1855 auto indx = adj.get_connected_provinces(0) != p.get_province() ? 0 : 1;
1856 auto o = adj.get_connected_provinces(indx).get_nation_from_province_ownership();
1857 if(o == state.local_player_nation)
1858 return true;
1859 if(o.get_overlord_as_subject().get_ruler() == state.local_player_nation)
1860 return true;
1861 }
1862 }
1863 }
1864 return false;
1865 }();
1866
1867 bool reachable_by_sea = false;
1868
1869 dcon::province_id coastal_target = [&]() {
1870 for(auto p : state.world.state_definition_get_abstract_state_membership(sdef)) {
1871 if(!p.get_province().get_nation_from_province_ownership()) {
1872 if(p.get_province().get_is_coast())
1873 return p.get_province().id;
1874 }
1875 }
1876 return dcon::province_id{};
1877 }();
1878
1879 if(!adjacent && coastal_target && state.world.nation_get_central_ports(state.local_player_nation) != 0) {
1880 for(auto p : state.world.nation_get_province_ownership(state.local_player_nation)) {
1881 if(auto nb_level = p.get_province().get_building_level(uint8_t(economy::province_building_type::naval_base)); nb_level > 0 && p.get_province().get_nation_from_province_control() == state.local_player_nation) {
1882 if(province::direct_distance(state, p.get_province(), coastal_target) <= province::world_circumference * 0.075f * nb_level) {
1883 reachable_by_sea = true;
1884 break;
1885 }
1886 }
1887 }
1888 }
1889
1890 text::add_line_with_condition(state, contents, "col_start_8", adjacent || reachable_by_sea);
1891
1892 auto free_points = nations::free_colonial_points(state, state.local_player_nation);
1893 auto required_points = int32_t(state.defines.colonization_interest_cost_initial + (adjacent ? state.defines.colonization_interest_cost_neighbor_modifier : 0.0f));
1894
1895 text::add_line_with_condition(state, contents, "col_start_9", free_points > required_points, text::variable_type::x, required_points);
1896 } else {
1897 text::add_line(state, contents, "col_invest_title");
1899
1900 text::add_line_with_condition(state, contents, "col_invest_1", state.world.nation_get_rank(state.local_player_nation) <= uint16_t(state.defines.colonial_rank), text::variable_type::x, uint16_t(state.defines.colonial_rank));
1901
1902 text::add_line_with_condition(state, contents, "col_invest_2", state.crisis_colony != sdef);
1903
1904 bool war_participant = false;
1905 for(auto par : state.world.war_get_war_participant(state.crisis_war)) {
1906 if(par.get_nation() == state.local_player_nation)
1907 war_participant = true;
1908 }
1909 text::add_line_with_condition(state, contents, "col_invest_3", !war_participant);
1910
1911 auto crange = state.world.state_definition_get_colonization(sdef);
1912 auto last_investment = state.world.colonization_get_last_investment(col);
1913
1914 if(crange.end() - crange.begin() <= 1) { // no competition
1916 text::add_line(state, contents, "col_invest_4", text::variable_type::x, last_investment + int32_t(state.defines.colonization_days_for_initial_investment));
1917 } else {
1918 text::add_line_with_condition(state, contents, "col_invest_5", last_investment + int32_t(state.defines.colonization_days_between_investment) <= state.current_date,
1919 text::variable_type::x, int32_t(state.defines.colonization_days_between_investment),
1920 text::variable_type::y, last_investment + int32_t(state.defines.colonization_days_between_investment));
1921
1922 auto free_points = nations::free_colonial_points(state, state.local_player_nation);
1923 int32_t point_cost = 0;
1924 if(state.world.state_definition_get_colonization_stage(sdef) == 1) {
1925 point_cost = int32_t(state.defines.colonization_interest_cost);
1926 } else if(state.world.colonization_get_level(col) <= 4) {
1927 point_cost = int32_t(state.defines.colonization_influence_cost);
1928 } else {
1929 point_cost = int32_t(state.defines.colonization_extra_guard_cost * (state.world.colonization_get_level(col) - 4) + state.defines.colonization_influence_cost);
1930 }
1931
1932 text::add_line_with_condition(state, contents, "col_invest_6", free_points >= point_cost, text::variable_type::x, point_cost);
1933 }
1934 }
1935 }
1936};
1937
1939private:
1940 image_element_base* progressicon = nullptr;
1941 button_element_base* investbutton = nullptr;
1942public:
1943 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1944 if(name == "progress_icon") {
1945 auto ptr = make_element_by_type<image_element_base>(state, id);
1946 progressicon = ptr.get();
1947 return ptr;
1948 } else if(name == "progress_button") {
1949 auto ptr = make_element_by_type<colony_invest_button>(state, id);
1950 investbutton = ptr.get();
1951 return ptr;
1952 } else {
1953 return nullptr;
1954 }
1955 }
1956
1957 void on_update(sys::state& state) noexcept override {
1958 if(content >= 0) {
1959 progressicon->frame = content;
1960 investbutton->set_visible(state, false);
1961 progressicon->set_visible(state, true);
1962 } else {
1963 investbutton->frame = -(content + 1);
1964 investbutton->set_visible(state, true);
1965 progressicon->set_visible(state, false);
1966 }
1967 }
1968};
1969
1970class colonisation_listbox : public overlapping_listbox_element_base<level_entry, int8_t> {
1971protected:
1972 std::string_view get_row_element_name() override {
1973 return "level_entry";
1974 }
1975
1976public:
1977 void on_update(sys::state& state) noexcept override {
1978 auto content = retrieve<dcon::colonization_id>(state, parent);
1979
1980 row_contents.clear();
1981
1982 if(!content) {
1983 row_contents.push_back(int8_t(-1));
1984 } else {
1985 auto province = retrieve<dcon::province_id>(state, parent);
1986 auto stage = state.world.state_definition_get_colonization_stage(state.world.province_get_state_from_abstract_state_membership(province));
1987
1988 auto fat_colony = dcon::fatten(state.world, content);
1989
1990 if(stage == 3) {
1991 row_contents.push_back(int8_t(0));
1992 row_contents.push_back(int8_t(1));
1993 row_contents.push_back(int8_t(2));
1994 row_contents.push_back(int8_t(3));
1995 row_contents.push_back(int8_t(4));
1996 } else if(fat_colony.get_colonizer() == state.local_player_nation) {
1997 int8_t i = 0;
1998 for(; i < 4 && i < int32_t(fat_colony.get_level()); ++i) {
1999 row_contents.push_back(i);
2000 }
2001 row_contents.push_back(int8_t(-(i + 1)));
2002 } else {
2003 for(int8_t i = 0; i < 5 && i < int32_t(fat_colony.get_level()); ++i) {
2004 row_contents.push_back(i);
2005 }
2006 }
2007 }
2008 update(state);
2009 }
2010};
2011
2013public:
2014 void on_update(sys::state& state) noexcept override {
2015 auto col = retrieve<dcon::colonization_id>(state, parent);
2016 auto level = state.world.colonization_get_level(col);
2017 if(level < 5)
2018 set_text(state, "");
2019 else
2020 set_text(state, std::to_string(level - 4));
2021 }
2022};
2023
2024class colonist_entry : public listbox_row_element_base<dcon::colonization_id> {
2025public:
2026 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
2027 if(name == "controller_flag") {
2028 return make_element_by_type<flag_button>(state, id);
2029 } else if(name == "levels") {
2030 return make_element_by_type<colonisation_listbox>(state, id);
2031 } else if(name == "progress_counter") {
2032 return make_element_by_type<colonization_level_number>(state, id);
2033 } else {
2034 return nullptr;
2035 }
2036 }
2037
2038 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
2039 if(payload.holds_type<dcon::national_identity_id>()) {
2040 if(content)
2041 payload.emplace<dcon::national_identity_id>(dcon::fatten(state.world, content).get_colonizer().get_identity_from_identity_holder().id);
2042 else
2043 payload.emplace<dcon::national_identity_id>(state.world.nation_get_identity_from_identity_holder(state.local_player_nation));
2045 }
2047 }
2048};
2049
2050class colonist_listbox : public listbox_element_base<colonist_entry, dcon::colonization_id> {
2051protected:
2052 std::string_view get_row_element_name() override {
2053 return "colonist_item";
2054 }
2055
2056public:
2057 void on_update(sys::state& state) noexcept override {
2058
2059 auto prov = retrieve<dcon::province_id>(state, parent);
2060 auto fat_def = dcon::fatten(state.world, state.world.province_get_state_from_abstract_state_membership(prov));
2061
2062 row_contents.clear();
2063
2064 bool found_player = false;
2065 int32_t existing_colonizers = 0;
2066 for(auto colony : fat_def.get_colonization()) {
2067 if(colony.get_colonizer().id == state.local_player_nation) {
2068 found_player = true;
2069 }
2070 row_contents.push_back(colony.id);
2071 ++existing_colonizers;
2072 }
2073
2074 if(!found_player && (existing_colonizers == 0 || (fat_def.get_colonization_stage() == 1 && existing_colonizers < 4))) {
2075 row_contents.push_back(dcon::colonization_id{});
2076 }
2077
2078 update(state);
2079 }
2080};
2081
2083public:
2084 void on_update(sys::state& state) noexcept override {
2085 auto content = retrieve<dcon::state_instance_id>(state, parent);
2086 progress = dcon::fatten(state.world, content).get_definition().get_colonization_temperature();
2087 }
2088};
2089
2091private:
2092 simple_text_element_base* population_box = nullptr;
2093 culture_piechart<dcon::province_id>* culture_chart = nullptr;
2094
2095public:
2096 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
2097 if(name == "total_population") {
2098 auto ptr = make_element_by_type<simple_text_element_base>(state, id);
2099 population_box = ptr.get();
2100 return ptr;
2101 } else if(name == "culture_chart") {
2102 auto ptr = make_element_by_type<culture_piechart<dcon::province_id>>(state, id);
2103 culture_chart = ptr.get();
2104 return ptr;
2105 } else if(name == "goods_type") {
2106 return make_element_by_type<province_rgo>(state, id);
2107 } else if(name == "colonize_button") {
2108 return make_element_by_type<province_protectorate_button>(state, id);
2109 } else if(name == "withdraw_button") {
2110 return make_element_by_type<province_withdraw_button>(state, id);
2111 } else if(name == "colonist_list") {
2112 return make_element_by_type<colonist_listbox>(state, id);
2113 } else if(name == "crisis_temperature") {
2114 return make_element_by_type<province_colonisation_temperature>(state, id);
2115 } else if(name == "rallypoint_checkbox") {
2116 return make_element_by_type<land_rally_point>(state, id);
2117 } else if(name == "rallypoint_checkbox_naval") {
2118 return make_element_by_type<naval_rally_point>(state, id);
2119 } else if(name == "rallypoint_merge_checkbox" || name == "rallypoint_merge_checkbox_naval") {
2120 return make_element_by_type<merge_rally_point>(state, id);
2121 } else {
2122 return nullptr;
2123 }
2124 }
2125
2126 void on_update(sys::state& state) noexcept override {
2127 auto prov_id = retrieve<dcon::province_id>(state, parent);
2128 dcon::province_fat_id fat_id = dcon::fatten(state.world, prov_id);
2129 auto nation_id = fat_id.get_nation_from_province_ownership();
2130 if(bool(nation_id)) {
2131 set_visible(state, false);
2132 } else {
2133 auto total_pop = state.world.province_get_demographics(prov_id, demographics::total);
2134 population_box->set_text(state, text::prettify(int32_t(total_pop)));
2135 culture_chart->on_update(state);
2136 set_visible(state, true);
2137 }
2138 }
2139};
2140
2142private:
2143 dcon::province_id active_province{};
2144 province_window_header* header_window = nullptr;
2145 province_view_foreign_details* foreign_details_window = nullptr;
2146 province_view_statistics* local_details_window = nullptr;
2147 province_view_buildings* local_buildings_window = nullptr;
2148 province_window_colony* colony_window = nullptr;
2149 element_base* nf_win = nullptr;
2150
2151public:
2152 void on_create(sys::state& state) noexcept override {
2154 state.ui_state.province_window = this;
2155 set_visible(state, false);
2156 //
2157 auto ptr = make_element_by_type<build_unit_province_window>(state, "build_unit_view");
2158 state.ui_state.build_province_unit_window = ptr.get();
2159 add_child_to_front(std::move(ptr));
2160 }
2161
2162 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
2163 if(name == "close_button") {
2164 return make_element_by_type<province_close_button>(state, id);
2165 } else if(name == "background") {
2166 return make_element_by_type<draggable_target>(state, id);
2167 } else if(name == "province_view_header") {
2168 auto ptr = make_element_by_type<province_window_header>(state, id);
2169 header_window = ptr.get();
2170 return ptr;
2171 } else if(name == "province_other") {
2172 auto ptr = make_element_by_type<province_view_foreign_details>(state, id);
2173 ptr->set_visible(state, false);
2174 foreign_details_window = ptr.get();
2175 return ptr;
2176 } else if(name == "province_colony") {
2177 auto ptr = make_element_by_type<province_window_colony>(state, id);
2178 ptr->set_visible(state, false);
2179 colony_window = ptr.get();
2180 return ptr;
2181 } else if(name == "province_statistics") {
2182 auto ptr = make_element_by_type<province_view_statistics>(state, id);
2183 local_details_window = ptr.get();
2184 ptr->set_visible(state, false);
2185 return ptr;
2186 } else if(name == "province_buildings") {
2187 auto ptr = make_element_by_type<province_view_buildings>(state, id);
2188 local_buildings_window = ptr.get();
2189 ptr->set_visible(state, false);
2190 return ptr;
2191 } else if(name == "national_focus_window") {
2192 auto ptr = make_element_by_type<national_focus_window>(state, id);
2193 ptr->set_visible(state, false);
2194 nf_win = ptr.get();
2195 return ptr;
2196 } else {
2197 return nullptr;
2198 }
2199 }
2200
2201 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
2202 if(payload.holds_type<dcon::province_id>()) {
2203 payload.emplace<dcon::province_id>(active_province);
2205 } else if(payload.holds_type<dcon::nation_id>()) {
2206 dcon::nation_id nid = dcon::fatten(state.world, active_province).get_nation_from_province_ownership();
2207 payload.emplace<dcon::nation_id>(nid);
2209 } else if(payload.holds_type<dcon::state_instance_id>()) {
2210 dcon::state_instance_id sid = dcon::fatten(state.world, active_province).get_state_membership();
2211 payload.emplace<dcon::state_instance_id>(sid);
2213 }
2215 }
2216
2217 void set_active_province(sys::state& state, dcon::province_id map_province) {
2218 if(bool(map_province)) {
2219 active_province = map_province;
2220 if(!is_visible())
2221 set_visible(state, true);
2222 else
2224 } else {
2225 set_visible(state, false);
2226 }
2227 }
2228
2229 void on_update(sys::state& state) noexcept override {
2230 header_window->impl_on_update(state);
2231 foreign_details_window->impl_on_update(state);
2232 local_details_window->impl_on_update(state);
2233 local_buildings_window->impl_on_update(state);
2234 colony_window->impl_on_update(state);
2235
2236 //Hide unit builder if not our province
2237 auto n = state.world.province_get_nation_from_province_ownership(active_province);
2238 if(state.ui_state.build_province_unit_window && state.ui_state.build_province_unit_window->is_visible() && n != state.local_player_nation) {
2240 }
2241 }
2242
2244};
2245
2246} // namespace ui
void set_button_text(sys::state &state, std::string const &new_text)
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
std::string_view get_row_element_name() override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
std::string_view get_row_element_name() override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void button_action(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 add_child_to_front(std::unique_ptr< element_base > child) noexcept final
void impl_on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
virtual message_result impl_set(sys::state &state, Cyto::Any &payload) noexcept
element_base * parent
virtual message_result get(sys::state &state, Cyto::Any &payload) noexcept
virtual void impl_on_update(sys::state &state) noexcept
virtual void impl_render(sys::state &state, int32_t x, int32_t y) noexcept
bool is_visible() const
message_result impl_get(sys::state &state, Cyto::Any &payload) noexcept
virtual void on_create(sys::state &state) noexcept
element_data base_data
void set_visible(sys::state &state, bool vis)
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void button_action(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void 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 button_action(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
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_create(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
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 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 button_action(sys::state &state) noexcept override
virtual void button_shift_right_action(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
virtual void button_shift_action(sys::state &state) noexcept override
void button_action(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 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
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_update(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
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
dcon::national_identity_id get_current_nation(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_update(sys::state &state) noexcept override
tooltip_behavior has_tooltip(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
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 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 update_tooltip(sys::state &state, int32_t x, int32_t t, text::columnar_layout &contents) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
virtual void button_shift_action(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void button_action(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
virtual void button_shift_action(sys::state &state) noexcept override
virtual void button_shift_right_action(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void 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 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::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
void on_update(sys::state &state) noexcept override
std::string_view get_row_element_name() override
void update_subwindow(sys::state &state, province_modifier_win &subwindow, sys::dated_modifier content) 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
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) noexcept
void on_update(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void button_right_action(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
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 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
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
void on_update(sys::state &state) noexcept override
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
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 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 update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) 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 on_update(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
virtual void button_shift_action(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void button_action(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 t, text::columnar_layout &contents) noexcept override
void on_update(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_create(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
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
void on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
void set_active_province(sys::state &state, dcon::province_id map_province)
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_update(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_update(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_update(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
message_result test_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
void impl_render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_update(sys::state &state) noexcept override
void set_text(sys::state &state, std::string const &new_text)
message_result test_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
void on_create(sys::state &state) noexcept override
bool can_begin_factory_building_construction(sys::state &state, dcon::nation_id source, dcon::state_instance_id location, dcon::factory_type_id type, bool is_upgrade)
Definition: commands.cpp:491
bool can_begin_province_building_construction(sys::state &state, dcon::nation_id source, dcon::province_id p, economy::province_building_type type)
Definition: commands.cpp:402
bool can_set_national_focus(sys::state &state, dcon::nation_id source, dcon::state_instance_id target_state, dcon::national_focus_id focus)
Definition: commands.cpp:118
bool can_abandon_colony(sys::state &state, dcon::nation_id source, dcon::province_id pr)
Definition: commands.cpp:1608
bool can_move_capital(sys::state &state, dcon::nation_id source, dcon::province_id p)
Definition: commands.cpp:4384
void set_national_focus(sys::state &state, dcon::nation_id source, dcon::state_instance_id target_state, dcon::national_focus_id focus)
Definition: commands.cpp:107
bool can_toggle_select_province(sys::state &state, dcon::nation_id source, dcon::province_id prov)
Definition: commands.cpp:3769
bool can_start_land_unit_construction(sys::state &state, dcon::nation_id source, dcon::province_id location, dcon::culture_id soldier_culture, dcon::unit_type_id type, dcon::province_id template_province)
Definition: commands.cpp:679
bool can_invest_in_colony(sys::state &state, dcon::nation_id source, dcon::province_id p)
Definition: commands.cpp:1562
bool can_finish_colonization(sys::state &state, dcon::nation_id source, dcon::province_id p)
Definition: commands.cpp:1631
bool can_toggle_immigrator_province(sys::state &state, dcon::nation_id source, dcon::province_id prov)
Definition: commands.cpp:3788
bool can_start_naval_unit_construction(sys::state &state, dcon::nation_id source, dcon::province_id location, dcon::unit_type_id type, dcon::province_id template_province)
Definition: commands.cpp:620
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
constexpr dcon::demographics_key total(0)
dcon::demographics_key to_key(sys::state const &state, dcon::pop_type_id v)
float get_monthly_pop_increase(sys::state &state, dcon::pop_id ids)
construction_status province_building_construction(sys::state &state, dcon::province_id p, province_building_type t)
Definition: economy.cpp:4832
std::string_view province_building_type_get_name(economy::province_building_type v)
Definition: economy.hpp:56
float pop_min_wage_factor(sys::state &state, dcon::nation_id n)
Definition: economy.cpp:2813
float pop_farmer_min_wage(sys::state &state, dcon::nation_id n, float min_wage_factor)
Definition: economy.cpp:2818
float pop_laborer_min_wage(sys::state &state, dcon::nation_id n, float min_wage_factor)
Definition: economy.cpp:2825
province_building_type
Definition: constants.hpp:578
constexpr uint32_t build_railway
Definition: culture.hpp:38
bool province_is_under_siege(sys::state const &state, dcon::province_id ids)
Definition: military.cpp:453
int32_t regiments_created_from_province(sys::state &state, dcon::province_id p)
Definition: military.cpp:647
int32_t regiments_max_possible_from_province(sys::state &state, dcon::province_id p)
Definition: military.cpp:709
float peacetime_attrition_limit(sys::state &state, dcon::nation_id n, dcon::province_id prov)
Definition: military.cpp:4949
int32_t free_colonial_points(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:739
auto nation_accepts_culture(sys::state const &state, T ids, U cul_ids)
float direct_distance(sys::state &state, dcon::province_id a, dcon::province_id b)
Definition: province.cpp:1555
bool is_colonizing(sys::state &state, dcon::nation_id n, dcon::state_definition_id d)
Definition: province.cpp:1014
void for_each_province_in_state_instance(sys::state &state, dcon::state_instance_id s, F const &func)
float crime_fighting_efficiency(sys::state &state, dcon::province_id id)
Definition: province.cpp:536
bool has_railroads_being_built(sys::state &state, dcon::province_id id)
Definition: province.cpp:309
float land_maximum_employment(sys::state &state, dcon::province_id id)
Definition: province.cpp:455
float land_employment(sys::state &state, dcon::province_id id)
Definition: province.cpp:459
constexpr float world_circumference
Definition: province.hpp:8
float revolt_risk(sys::state &state, dcon::province_id id)
Definition: province.cpp:561
float state_admin_efficiency(sys::state &state, dcon::state_instance_id id)
Definition: province.cpp:503
std::string rebel_name(sys::state &state, dcon::rebel_faction_id reb)
Definition: rebels.cpp:1274
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_ratio(int32_t left, int32_t right)
Definition: text.cpp:1064
layout_box open_layout_box(layout_base &dest, int32_t indent)
Definition: text.cpp:1799
void localised_format_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view key, text::substitution_map const &sub)
Definition: text.cpp:1880
std::string prettify(int64_t num)
Definition: text.cpp:762
std::string format_float(float num, size_t digits)
Definition: text.cpp:981
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
Definition: text.cpp:1899
void add_line_with_condition(sys::state &state, layout_base &dest, std::string_view key, bool condition_met, int32_t indent)
Definition: text.cpp:1955
void add_line_break_to_layout(sys::state &state, columnar_layout &dest)
Definition: text.cpp:1152
void add_to_substitution_map(substitution_map &mp, variable_type key, substitution value)
Definition: text.cpp:1068
dcon::text_key get_adjective(sys::state &state, dcon::nation_id id)
Definition: text.cpp:890
ankerl::unordered_dense::map< uint32_t, substitution > substitution_map
Definition: text.hpp:794
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
Definition: text.cpp:617
dcon::text_key get_name(sys::state &state, dcon::nation_id id)
Definition: text.cpp:880
std::string format_percentage(float num, size_t digits)
Definition: text.cpp:977
void add_space_to_layout_box(sys::state &state, layout_base &dest, layout_box &box)
Definition: text.cpp:1788
void close_layout_box(columnar_layout &dest, layout_box &box)
Definition: text.cpp:1807
uint16_t * recurse_over_triggers(uint16_t *source, T const &f)
void modifier_description(sys::state &state, text::layout_base &layout, dcon::modifier_id mid, int32_t indentation=0)
tooltip_behavior
std::variant< std::monostate, dcon::nation_id, dcon::state_instance_id, dcon::province_id > pop_list_filter
message_result
void open_build_foreign_factory(sys::state &state, dcon::state_instance_id st)
void province_owner_rgo_draw_tooltip(sys::state &state, text::columnar_layout &contents, dcon::province_id prov_id) noexcept
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
static constexpr uint32_t set_size
sys::date expiration
Definition: modifiers.hpp:321
dcon::modifier_id mod_id
Definition: modifiers.hpp:322
static constexpr uint32_t modifier_definition_size
Definition: modifiers.hpp:231
element_type get_element_type() const
union ui::element_data::internal_data data
dcon::gfx_object_id gfx_object
element_base * topbar_subwindow
std::unique_ptr< element_base > root
element_base * province_window
element_base * population_subwindow
element_base * build_province_unit_window