Project Alice
Loading...
Searching...
No Matches
map_tooltip.cpp
Go to the documentation of this file.
1#include "map_tooltip.hpp"
2#include "demographics.hpp"
3#include "rebels.hpp"
4#include "commands.hpp"
5#include "unit_tooltip.hpp"
6
7namespace ui {
8
9float selected_relative_attrition_amount(sys::state& state, dcon::nation_id n, std::vector<dcon::army_id>& list, dcon::province_id prov) {
10 float total_army_weight = 0.f;
11 for(auto army : list) {
12 auto ar = dcon::fatten(state.world, army);
13 if(ar.get_black_flag() == false && ar.get_is_retreating() == false && !bool(ar.get_navy_from_army_transport())) {
14 for(auto rg : ar.get_army_membership()) {
15 total_army_weight += 3.0f * rg.get_regiment().get_strength();
16 }
17 }
18 }
19 for(auto ar : state.world.province_get_army_location(prov)) {
20 if(ar.get_army().get_black_flag() == false && ar.get_army().get_is_retreating() == false && !bool(ar.get_army().get_navy_from_army_transport())) {
21 for(auto rg : ar.get_army().get_army_membership()) {
22 total_army_weight += 3.0f * rg.get_regiment().get_strength();
23 }
24 }
25 }
26 auto prov_attrition_mod = state.world.province_get_modifier_values(prov, sys::provincial_mod_offsets::attrition);
27 auto army_controller = dcon::fatten(state.world, n);
28 auto supply_limit = military::supply_limit_in_province(state, army_controller, prov);
29 auto attrition_mod = 1.0f + army_controller.get_modifier_values(sys::national_mod_offsets::land_attrition);
30 float greatest_hostile_fort = 0.0f;
31 for(auto adj : state.world.province_get_province_adjacency(prov)) {
33 auto other = adj.get_connected_provinces(0) != prov ? adj.get_connected_provinces(0) : adj.get_connected_provinces(1);
34 if(other.get_building_level(uint8_t(economy::province_building_type::fort)) > 0) {
35 if(military::are_at_war(state, army_controller, other.get_nation_from_province_control())) {
36 greatest_hostile_fort = std::max(greatest_hostile_fort, float(other.get_building_level(uint8_t(economy::province_building_type::fort))));
37 }
38 }
39 }
40 }
41 return total_army_weight * attrition_mod - (supply_limit + prov_attrition_mod + greatest_hostile_fort) > 0;
42}
43
44void country_name_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) {
45 auto fat = dcon::fatten(state.world, prov);
46 auto owner = fat.get_nation_from_province_ownership();
47 auto box = text::open_layout_box(contents);
48
49 if(state.cheat_data.show_province_id_tooltip) {
50 text::localised_format_box(state, contents, box, "province_id", text::substitution_map{});
51 text::add_to_layout_box(state, contents, box, std::string_view(":"));
53 text::add_to_layout_box(state, contents, box, prov.index());
55 text::localised_format_box(state, contents, box, "nation_tag", text::substitution_map{});
56 text::add_to_layout_box(state, contents, box, std::string_view(":"));
58 text::add_to_layout_box(state, contents, box, nations::int_to_tag(owner.get_identity_from_identity_holder().get_identifying_int()));
60 text::localised_format_box(state, contents, box, "province_sorting_distance", text::substitution_map{});
61 text::add_to_layout_box(state, contents, box, std::string_view(":"));
63 text::add_to_layout_box(state, contents, box, text::fp_four_places{ province::sorting_distance(state, state.map_state.selected_province, prov) });
65
67 }
68
69 if(owner) {
70 text::add_to_layout_box(state, contents, box, fat.get_name());
71 text::add_to_layout_box(state, contents, box, std::string_view{ " (" });
72 text::add_to_layout_box(state, contents, box, text::embedded_flag{ state.world.nation_get_identity_from_identity_holder(owner) });
74 text::add_to_layout_box(state, contents, box, text::get_name(state, owner.id));
75 text::add_to_layout_box(state, contents, box, std::string_view{ ")" });
76 } else {
77 text::add_to_layout_box(state, contents, box, fat.get_name());
78 }
79 text::close_layout_box(contents, box);
80
81 if(state.selected_armies.size() > 0) {
82 text::add_line(state, contents, "alice_supply_limit_desc", text::variable_type::x, text::int_wholenum{ military::supply_limit_in_province(state, state.local_player_nation, fat) });
83 ui::active_modifiers_description(state, contents, state.local_player_nation, 0, sys::national_mod_offsets::supply_limit, true);
84 ui::active_modifiers_description(state, contents, fat, 0, sys::provincial_mod_offsets::supply_limit, true);
85
86 // Supply in the target province tooltip
87 for(const auto a : state.selected_armies) {
88 auto controller = dcon::fatten(state.world, state.local_player_nation);
91 auto tag_str = std::string("@") + nations::int_to_tag(controller.get_identity_from_identity_holder().get_identifying_int()) + "@(A)";
92 text::add_to_substitution_map(sub, text::variable_type::m, std::string_view{ tag_str });
97 auto resolved = text::resolve_string_substitution(state, "alice_unit_relative_attrition", sub);
98 box = text::open_layout_box(contents);
99 text::add_unparsed_text_to_layout_box(state, contents, box, resolved);
100
101 // Army arrival time tooltip
102 auto army = dcon::fatten(state.world, a);
103 auto path = command::calculate_army_path(state, state.local_player_nation, a, army.get_location_from_army_location(), prov);
104 auto curprov = army.get_army_location().get_location().id;
105
106 if (path.size() == 0) { /* No available route */ }
107
108 else if(army.get_arrival_time() && *(army.get_path().end()) == prov) {
110 text::add_to_substitution_map(sub, text::variable_type::date, army.get_arrival_time());
111 resolved = " " + text::resolve_string_substitution(state, "unit_arrival_time_text", sub);
112 text::add_to_layout_box(state, contents, box, resolved, text::text_color::white);
113 }
114 else {
115 auto dt = state.current_date;
116
117 for(const auto provonpath : path) {
118 dt += military::movement_time_from_to(state, a, curprov, provonpath);
119 curprov = provonpath;
120 }
121
124
125 resolved = " " + text::resolve_string_substitution(state, "unit_arrival_time_text", sub);
126
127 if(state.current_date + 15 > dt) {
128 text::add_to_layout_box(state, contents, box, resolved, text::text_color::green);
129 }
130 else if(state.current_date + 30 < dt) {
131 text::add_to_layout_box(state, contents, box, resolved, text::text_color::red);
132 }
133 else {
134 text::add_to_layout_box(state, contents, box, resolved, text::text_color::yellow);
135 }
136 }
137
138 text::close_layout_box(contents, box);
139 }
140 } else if(state.selected_navies.size() > 0) {
141 text::add_line(state, contents, "alice_supply_limit_desc", text::variable_type::x, text::int_wholenum{ military::supply_limit_in_province(state, state.local_player_nation, fat) });
142 ui::active_modifiers_description(state, contents, state.local_player_nation, 0, sys::national_mod_offsets::supply_limit, true);
143 ui::active_modifiers_description(state, contents, fat, 0, sys::provincial_mod_offsets::supply_limit, true);
144
145 for(const auto n : state.selected_navies) {
146 auto navy = dcon::fatten(state.world, n);
148 auto path = command::calculate_navy_path(state, state.local_player_nation, n, navy.get_location_from_navy_location(), prov);
149 auto curprov = navy.get_navy_location().get_location().id;
150
151 /* No available route */
152 if(path.size() == 0 && prov != curprov) {
153 }
154 else {
155 box = text::open_layout_box(contents);
156
158 auto unit_name = state.to_string_view(navy.get_name());
163
164 auto base_str = text::resolve_string_substitution(state, "ol_unit_standing_text", sub);
165 text::add_to_layout_box(state, contents, box, base_str, text::text_color::white);
166
167 // Navy arrival time tooltip
168 // Zero arrival time to current province
169 if(prov == curprov) {
170 }
171 else if(navy.get_arrival_time() && *(navy.get_path().end()) == prov) {
173 text::add_to_substitution_map(sub, text::variable_type::date, navy.get_arrival_time());
174 auto resolved = " " + text::resolve_string_substitution(state, "unit_arrival_time_text", sub);
175 text::add_to_layout_box(state, contents, box, resolved, text::text_color::white);
176 } else {
177 auto dt = state.current_date;
178
179 for(const auto provonpath : path) {
180 dt += military::movement_time_from_to(state, n, curprov, provonpath);
181 curprov = provonpath;
182 }
183
186
187 auto resolved = " " + text::resolve_string_substitution(state, "unit_arrival_time_text", sub);
188
189 if(state.current_date + 15 > dt) {
190 text::add_to_layout_box(state, contents, box, resolved, text::text_color::green);
191 } else if(state.current_date + 30 < dt) {
192 text::add_to_layout_box(state, contents, box, resolved, text::text_color::red);
193 } else {
194 text::add_to_layout_box(state, contents, box, resolved, text::text_color::yellow);
195 }
196 }
197
198 text::close_layout_box(contents, box);
199 }
200 }
201 }
202}
203
204// 19 out of 22 (2 cant be finished so 21 of 22) finished
205
206void terrain_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) { // Done
207 auto fat = dcon::fatten(state.world, prov);
208 country_name_box(state, contents, prov);
209 auto box = text::open_layout_box(contents);
210 text::add_to_layout_box(state, contents, box, fat.get_terrain().get_name());
213 text::close_layout_box(contents, box);
214
215 if(fat.get_terrain().id) {
216 ui::modifier_description(state, contents, fat.get_terrain().id);
217 }
218}
219
220void political_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) { // Done
221 country_name_box(state, contents, prov);
222 if(auto n = state.world.province_get_nation_from_province_control(prov); n && n != state.world.province_get_nation_from_province_ownership(prov)) {
223 auto fat_id = dcon::fatten(state.world, n);
224 auto box = text::open_layout_box(contents);
225 text::add_to_layout_box(state, contents, box, text::embedded_flag{ state.world.nation_get_identity_from_identity_holder(n) });
226 text::add_space_to_layout_box(state, contents, box);
228 text::close_layout_box(contents, box);
229 } else if(auto rf = state.world.province_get_rebel_faction_from_province_rebel_control(prov); rf) {
230 auto fat_id = dcon::fatten(state.world, rf);
231 auto box = text::open_layout_box(contents);
232 text::add_to_layout_box(state, contents, box, text::embedded_flag{ state.national_definitions.rebel_id });
233 text::add_space_to_layout_box(state, contents, box);
234 auto name = rebel::rebel_name(state, rf);
235 text::add_to_layout_box(state, contents, box, std::string_view{ name });
236 text::close_layout_box(contents, box);
237 }
238}
239
240void militancy_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) { // Done
241 auto fat = dcon::fatten(state.world, prov);
242 country_name_box(state, contents, prov);
243
244 if(prov.value < state.province_definitions.first_sea_province.value) {
246 ui::active_modifiers_description(state, contents, prov, 0, sys::provincial_mod_offsets::pop_militancy_modifier, true);
247 ui::active_modifiers_description(state, contents, state.world.province_control_get_nation(state.world.province_get_province_control_as_province(prov)), 0, sys::national_mod_offsets::core_pop_militancy_modifier, true);
248 ui::active_modifiers_description(state, contents, state.world.province_control_get_nation(state.world.province_get_province_control_as_province(prov)), 0, sys::national_mod_offsets::global_pop_militancy_modifier, true);
249 ui::active_modifiers_description(state, contents, state.world.province_control_get_nation(state.world.province_get_province_control_as_province(prov)), 0, sys::national_mod_offsets::non_accepted_pop_militancy_modifier, true);
250 }
251}
252
253void diplomatic_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) { // Done
254 auto fat = dcon::fatten(state.world, prov);
255 country_name_box(state, contents, prov);
256
257 if(prov.value < state.province_definitions.first_sea_province.value) {
258 auto box = text::open_layout_box(contents);
259 dcon::nation_fat_id nationundermouse = fat.get_nation_from_province_ownership();
260 //if(selectednation.get_is_great_power() && fat.get_nation_from_province_ownership() != selectednation) {
261 if(nationundermouse) {
262 dcon::nation_fat_id selectednation = (dcon::fatten(state.world, state.map_state.selected_province).get_nation_from_province_ownership().is_valid()) ?
263 dcon::fatten(state.world, state.map_state.selected_province).get_nation_from_province_ownership() :
264 dcon::fatten(state.world, state.local_player_nation);
265 uint8_t level = uint8_t(nations::influence::get_level(state, selectednation, fat.get_nation_from_province_ownership()));
266 level = level & nations::influence::level_mask;
267 if(nationundermouse.get_overlord_as_subject().get_ruler() == selectednation && nationundermouse.get_is_substate()) {
268 text::localised_format_box(state, contents, box, std::string_view("diplo_they_substate"));
270 } else if(selectednation.get_overlord_as_subject().get_ruler() == nationundermouse && selectednation.get_is_substate()) {
271 text::localised_format_box(state, contents, box, std::string_view("diplo_we_substate"));
273 } else if(nationundermouse.get_overlord_as_subject().get_ruler() == selectednation && !nationundermouse.get_is_substate()) {
274 text::localised_format_box(state, contents, box, std::string_view("diplo_they_satellite"));
276 } else if(selectednation.get_overlord_as_subject().get_ruler() == nationundermouse && !selectednation.get_is_substate()) {
277 text::localised_format_box(state, contents, box, std::string_view("diplo_we_satellite"));
279 } else if(selectednation.get_is_great_power() && nationundermouse != selectednation) {
280 text::add_to_layout_box(state, contents, box, fat.get_nation_from_province_ownership().id);
281 text::add_to_layout_box(state, contents, box, std::string_view(": "));
282 auto str = text::get_influence_level_name(state, level);
283 text::add_to_layout_box(state, contents, box, std::string_view(str));
285 }
286 text::localised_format_box(state, contents, box, std::string_view("following_have_claims"));
288 for(auto c : fat.get_core()) {
289 text::add_to_layout_box(state, contents, box, std::string_view("• "));
290 text::add_to_layout_box(state, contents, box, text::embedded_flag{ c.get_identity().id });
291 text::add_to_layout_box(state, contents, box, c.get_identity().get_name());
293 }
294 text::close_layout_box(contents, box);
295 }
296 }
297}
298
299void region_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) { // Done
300 auto fat = dcon::fatten(state.world, prov);
301 country_name_box(state, contents, prov);
302
303 if(prov.value < state.province_definitions.first_sea_province.value) {
304 auto box = text::open_layout_box(contents);
308 text::add_to_substitution_map(sub, text::variable_type::continentname, fat.get_continent().get_name());
309 text::localised_format_box(state, contents, box, std::string_view("mapmode_tooltip_state_entry"), sub);
310 text::close_layout_box(contents, box);
311 }
312}
313
314void infrastructure_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) { // Done, doesnt appear to produce same results as V2 though
315 auto fat = dcon::fatten(state.world, prov);
316 country_name_box(state, contents, prov);
317
318 if(prov.value < state.province_definitions.first_sea_province.value) {
319 auto box = text::open_layout_box(contents);
320 text::add_to_layout_box(state, contents, box, fat.get_rgo().get_name(), text::text_color::yellow);
321 int32_t current_rails_lvl = state.world.province_get_building_level(prov, uint8_t(economy::province_building_type::railroad));
322 int32_t max_local_rails_lvl = state.world.nation_get_max_building_level(fat.get_nation_from_province_ownership().id, uint8_t(economy::province_building_type::railroad));
324 text::localised_single_sub_box(state, contents, box, std::string_view("infra_level_here"), text::variable_type::val, uint16_t(float(current_rails_lvl) / float(max_local_rails_lvl)));
325 text::close_layout_box(contents, box);
326 }
327}
328
329void colonial_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) { // Done
330 auto fat = dcon::fatten(state.world, prov);
331 country_name_box(state, contents, prov);
332
333 if(prov.value < state.province_definitions.first_sea_province.value) {
334 auto box = text::open_layout_box(contents);
335 if(fat.get_is_coast()) {
337 text::add_to_substitution_map(sub, text::variable_type::val, std::string_view(text::format_float(province::direct_distance(state, dcon::fatten(state.world, state.local_player_nation).get_capital().id, prov), 0)));
338 text::localised_format_box(state, contents, box, std::string_view("colonial_range"), sub);
339 }
341 text::add_to_layout_box(state, contents, box, fat.get_rgo().get_name(), text::text_color::yellow);
342 text::close_layout_box(contents, box);
343
344 auto distance = province::direct_distance(state, dcon::fatten(state.world, state.local_player_nation).get_capital().id, prov);
345 if(!province::can_start_colony(state, state.local_player_nation, fat.get_state_from_abstract_state_membership().id)) {
346 if(fat.get_life_rating() > state.world.nation_get_modifier_values(state.local_player_nation, sys::national_mod_offsets::colonial_life_rating)) {
347 ui::active_modifiers_description(state, contents, state.local_player_nation, 0, sys::national_mod_offsets::colonial_life_rating, false);
348 }
349 if(province::has_an_owner(state, prov)) {
350 auto box3 = text::open_layout_box(contents);
352 text::localised_format_box(state, contents, box3, std::string_view("colonize_settled"));
354 text::close_layout_box(contents, box3);
355 } else if(distance > state.economy_definitions.building_definitions[int32_t(economy::province_building_type::naval_base)].colonial_range) {
356 auto box2 = text::open_layout_box(contents);
358 text::localised_format_box(state, contents, box2, std::string_view("colonize_closest_base_to_far"));
359 text::close_layout_box(contents, box2);
360 }
361 }
362 auto box4 = text::open_layout_box(contents);
363
364 for(auto coloniser : fat.get_state_from_abstract_state_membership().get_colonization()) {
366 text::add_to_layout_box(state, contents, box4, coloniser.get_colonizer().id, text::text_color::yellow);
367 text::add_to_layout_box(state, contents, box4, std::string_view(": "), text::text_color::white);
368 text::add_to_layout_box(state, contents, box4, text::format_float(coloniser.get_level(), 0), text::text_color::yellow);
369 }
370
371 text::close_layout_box(contents, box4);
372 }
373}
374
375void admin_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) { // Done
376 auto fat = dcon::fatten(state.world, prov);
377 country_name_box(state, contents, prov);
378
379 if(prov.value < state.province_definitions.first_sea_province.value) {
380 auto box = text::open_layout_box(contents);
381 text::localised_single_sub_box(state, contents, box, std::string_view("provinceview_admin"), text::variable_type::value, text::fp_one_place{ province::state_admin_efficiency(state, fat.get_state_membership().id) * 100.0f });
382 text::close_layout_box(contents, box);
383 if(fat.get_crime()) {
385 text::add_line(state, contents, state.culture_definitions.crimes[fat.get_crime()].name);
386 ui::modifier_description(state, contents, state.culture_definitions.crimes[fat.get_crime()].modifier);
387 }
388 }
389}
390
391void recruitment_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) { // TODO
392 auto fat = dcon::fatten(state.world, prov);
393 country_name_box(state, contents, prov);
394
395 if(prov.value < state.province_definitions.first_sea_province.value) {
396 auto box = text::open_layout_box(contents);
397
398 auto max_regiments = military::regiments_max_possible_from_province(state, prov);
399 auto created_regiments = military::regiments_created_from_province(state, prov);
401
402 if(fat.get_nation_from_province_ownership().id.value == state.local_player_nation.value) {
403 if(max_regiments == 0) {
404 text::localised_format_box(state, contents, box, std::string_view("solmp_no_soldier_pops"));
405 } else if(created_regiments < max_regiments) {
409 text::localised_format_box(state, contents, box, std::string_view("solmp_details"), sub);
410 } else {
414 text::localised_format_box(state, contents, box, std::string_view("solmp_details"), sub);
415 }
416 //text::localised_format_box(state, contents, box, std::string_view("solmp_over_recruited"));
417 }
418
419 text::close_layout_box(contents, box);
420 }
421}
422
423void nationalfocus_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) { // TODO - Need new
424 auto fat = dcon::fatten(state.world, prov);
425 country_name_box(state, contents, prov);
426
427 if(prov.value < state.province_definitions.first_sea_province.value) {
428 auto box = text::open_layout_box(contents);
429 if(fat.get_state_membership().get_owner_focus()) {
430 text::localised_format_box(state, contents, box, std::string_view("pw_national_focus"));
431 text::add_to_layout_box(state, contents, box, fat.get_state_membership().get_owner_focus().get_name(), text::text_color::yellow);
432 modifier_description(state, contents, fat.get_state_membership().get_owner_focus().get_modifier());
433 }
434 text::close_layout_box(contents, box);
435 }
436}
437
438void rgooutput_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) { // Done
439 auto fat = dcon::fatten(state.world, prov);
440 country_name_box(state, contents, prov);
441
442 if(prov.value < state.province_definitions.first_sea_province.value) {
443 auto box = text::open_layout_box(contents);
444 text::add_to_layout_box(state, contents, box, fat.get_rgo().get_name(), text::text_color::yellow);
445 text::close_layout_box(contents, box);
446 }
447}
448
449void population_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) { // Done
450 auto fat = dcon::fatten(state.world, prov);
451 country_name_box(state, contents, prov);
452
453 if(prov.value < state.province_definitions.first_sea_province.value) {
454 auto box = text::open_layout_box(contents);
455 text::localised_single_sub_box(state, contents, box, std::string_view("population_density_at_province"), text::variable_type::prov, (
456 text::produce_simple_string(state, fat.get_name()) +
457 ": " +
458 text::format_float(fat.get_demographics(demographics::total), 0) +
459 " (" +
460 text::prettify(int64_t(fat.get_demographics(demographics::total))) +
461 ")"
462 ));
463 text::close_layout_box(contents, box);
464 }
465}
466
467void nationality_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) { // Done
468 auto fat = dcon::fatten(state.world, prov);
469 country_name_box(state, contents, prov);
470
471 if(prov.value < state.province_definitions.first_sea_province.value) {
472 auto box = text::open_layout_box(contents);
473
474 text::localised_single_sub_box(state, contents, box, std::string_view("mapmode_tooltip_culture_majorities"), text::variable_type::prov, prov);
475
476 std::vector<dcon::culture_fat_id> cultures;
477 for(auto pop : fat.get_pop_location()) {
478 if(std::find(cultures.begin(), cultures.end(), pop.get_pop().get_culture()) == cultures.end()) {
479 cultures.push_back(pop.get_pop().get_culture());
480 }
481 }
482 std::sort(cultures.begin(), cultures.end(), [&](auto a, auto b) {return fat.get_demographics(demographics::to_key(state, a.id)) > fat.get_demographics(demographics::to_key(state, b.id)); });
483 for(size_t i = 0; i < cultures.size(); i++) {
485 text::add_space_to_layout_box(state, contents, box);
486 text::add_to_layout_box(state, contents, box, cultures[i].get_name(), text::text_color::yellow);
487 text::add_space_to_layout_box(state, contents, box);
488 text::add_to_layout_box(state, contents, box, std::string_view("("), text::text_color::white);
489 text::add_to_layout_box(state, contents, box, text::format_percentage(fat.get_demographics(demographics::to_key(state, cultures[i].id)) / fat.get_demographics(demographics::total)), text::text_color::white);
490 text::add_to_layout_box(state, contents, box, std::string_view(")"), text::text_color::white);
491 }
492
493 text::close_layout_box(contents, box);
494 }
495}
496
497void sphere_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) { // Done
498 auto fat = dcon::fatten(state.world, prov);
499 country_name_box(state, contents, prov);
500
501 if(prov.value < state.province_definitions.first_sea_province.value) {
502 auto box = text::open_layout_box(contents);
503 if(fat.get_nation_from_province_ownership().get_is_great_power()) {
504 text::localised_single_sub_box(state, contents, box, std::string_view("sphere_of_infl_great_power"), text::variable_type::country, fat.get_nation_from_province_ownership().id);
505 } else {
506 if(fat.get_nation_from_province_ownership().get_in_sphere_of().is_valid()) {
508 text::add_to_substitution_map(sub, text::variable_type::country1, fat.get_nation_from_province_ownership().id);
509 text::add_to_substitution_map(sub, text::variable_type::country2, fat.get_nation_from_province_ownership().get_in_sphere_of());
510 text::localised_format_box(state, contents, box, std::string_view("sphere_of_infl_is_in_sphere"), sub);
511 }
512
513 bool bHasDisplayedHeader = false;
514 for(auto gpr : fat.get_nation_from_province_ownership().get_gp_relationship_as_influence_target()) {
515 if(!bHasDisplayedHeader) {
517 text::localised_single_sub_box(state, contents, box, std::string_view("sphere_of_infl_is_infl_by"), text::variable_type::country, fat.get_nation_from_province_ownership());
519 bHasDisplayedHeader = true;
520 }
521 text::add_to_layout_box(state, contents, box, gpr.get_great_power().id, text::text_color::yellow);
522 text::add_to_layout_box(state, contents, box, (
523 " (" +
524 text::format_float(gpr.get_influence(), 0) +
525 ")"
528 }
529 }
530 text::close_layout_box(contents, box);
531 }
532}
533
534void supply_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) { // Done
535 auto fat = dcon::fatten(state.world, prov);
536 country_name_box(state, contents, prov);
537
538 if(prov.value < state.province_definitions.first_sea_province.value) {
539 auto box = text::open_layout_box(contents);
540 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, "provinceview_supply_limit") + " ");
541 text::add_to_layout_box(state, contents, box, military::supply_limit_in_province(state, fat.get_nation_from_province_ownership().id, prov), text::text_color::yellow);
544 text::add_space_to_layout_box(state, contents, box);
545 text::add_to_layout_box(state, contents, box, text::format_float(state.world.province_get_modifier_values(prov, sys::provincial_mod_offsets::supply_limit), 1), text::text_color::yellow);
547
548 // "Borrowed" from military.cpp
549 auto prov_controller = state.world.province_get_nation_from_province_control(prov);
550 auto self_controlled = prov_controller == state.local_player_nation;
551 if(state.world.province_get_nation_from_province_ownership(prov) == state.local_player_nation && self_controlled) {
553 text::add_space_to_layout_box(state, contents, box);
556 } else if(auto dip_rel = state.world.get_diplomatic_relation_by_diplomatic_pair(prov_controller, state.local_player_nation); state.world.diplomatic_relation_get_are_allied(dip_rel) || fat.get_nation_from_province_control().get_overlord_as_subject().get_ruler() == state.local_player_nation) {
558 text::add_space_to_layout_box(state, contents, box);
561 } else if(auto uni_rel = state.world.get_unilateral_relationship_by_unilateral_pair(prov_controller, state.local_player_nation); state.world.unilateral_relationship_get_military_access(uni_rel)) {
563 text::add_space_to_layout_box(state, contents, box);
566 } else if(bool(state.world.get_core_by_prov_tag_key(prov, state.world.nation_get_identity_from_identity_holder(state.local_player_nation)))) {
568 text::add_space_to_layout_box(state, contents, box);
571 } else if(state.world.province_get_siege_progress(prov) > 0.0f) {
573 text::add_space_to_layout_box(state, contents, box);
576 }
577 text::close_layout_box(contents, box);
578 }
579}
580
581void party_loyalty_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) { // Done
582 auto fat = dcon::fatten(state.world, prov);
583 country_name_box(state, contents, prov);
584
585 if(prov.value < state.province_definitions.first_sea_province.value) {
586 auto box = text::open_layout_box(contents);
587 text::localised_single_sub_box(state, contents, box, std::string_view("party_loyalty_desc_header"), text::variable_type::prov, prov);
588 std::vector<dcon::political_party_id> active_parties;
589 nations::get_active_political_parties(state, fat.get_nation_from_province_ownership(), active_parties);
590 for(auto party : active_parties) {
592 auto loyalty = state.world.province_get_party_loyalty(prov, dcon::fatten(state.world, party).get_ideology().id);
593 if(loyalty > 0) {
594 text::add_to_layout_box(state, contents, box, std::string_view("("), text::text_color::green);
595 text::add_to_layout_box(state, contents, box, dcon::fatten(state.world, party).get_ideology().get_name(), text::text_color::green);
596 text::add_to_layout_box(state, contents, box, std::string_view(") "), text::text_color::green);
597 } else {
598 text::add_to_layout_box(state, contents, box, std::string_view("("), text::text_color::yellow);
599 text::add_to_layout_box(state, contents, box, dcon::fatten(state.world, party).get_ideology().get_name(), text::text_color::yellow);
600 text::add_to_layout_box(state, contents, box, std::string_view(") "), text::text_color::yellow);
601 }
603 text::add_space_to_layout_box(state, contents, box);
605 }
606 text::close_layout_box(contents, box);
607 }
608}
609
610void rank_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) { // Done
611 auto fat = dcon::fatten(state.world, prov);
612 country_name_box(state, contents, prov);
613
614 if(prov.value < state.province_definitions.first_sea_province.value) {
615 auto box = text::open_layout_box(contents);
616 switch(nations::get_status(state, fat.get_nation_from_province_ownership().id)) {
618 {
619 text::localised_single_sub_box(state, contents, box, std::string_view("sphere_of_infl_great_power"), text::variable_type::country, fat.get_nation_from_province_ownership().id);
621 break;
622 }
624 {
625 text::localised_single_sub_box(state, contents, box, std::string_view("world_ranking_secondary_power"), text::variable_type::country, fat.get_nation_from_province_ownership().id);
627 break;
628 }
629 default:
631 break;
632 };
633 text::localised_format_box(state, contents, box, std::string_view("world_ranking"));
634 text::add_space_to_layout_box(state, contents, box);
635 text::add_to_layout_box(state, contents, box, fat.get_nation_from_province_ownership().get_rank(), text::text_color::yellow);
636 text::close_layout_box(contents, box);
637 }
638}
639
640void migration_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) { // TODO - Needs Migration Map
641 auto fat = dcon::fatten(state.world, prov);
642 auto owner = fat.get_nation_from_province_ownership();
643
644 if(owner) {
645 {
646 auto box = text::open_layout_box(contents);
647 text::localised_format_box(state, contents, box, "im_em_header");
648 text::add_to_layout_box(state, contents, box, text::embedded_flag{ state.world.nation_get_identity_from_identity_holder(owner) });
649 text::add_space_to_layout_box(state, contents, box);
650 text::add_to_layout_box(state, contents, box, text::get_name(state, owner.id));
651 text::close_layout_box(contents, box);
652 }
653 struct nation_and_value {
654 float v;
655 dcon::nation_id n;
656 };
657
658 static dcon::nation_id last_owner;
659 static sys::date last_checked;
660 static std::vector<float> last_value;
661 static std::vector<nation_and_value> positive_vals;
662 static std::vector<nation_and_value> neg_vals;
663 static float total_pos = 0.0f;
664 static float total_neg = 0.0f;
665
666 auto d = state.ui_date;
667 if(d != last_checked || last_owner != owner) {
668 last_checked = d;
669 last_owner = owner;
670 total_pos = 0.0f;
671 total_neg = 0.0f;
672
674 positive_vals.clear();
675 neg_vals.clear();
676 for(uint32_t i = uint32_t(last_value.size()); i-- > 0; ) {
677 dcon::nation_id in{ dcon::nation_id::value_base_t(i) };
678 if(last_value[i] > 0.0f) {
679 positive_vals.push_back(nation_and_value{ last_value[i],in });
680 total_pos += last_value[i];
681 } else if(last_value[i] < 0.0f) {
682 neg_vals.push_back(nation_and_value{ last_value[i],in });
683 total_neg += last_value[i];
684 }
685 }
686
687 std::sort(positive_vals.begin(), positive_vals.end(), [](nation_and_value const& a, nation_and_value const& b) {
688 return a.v > b.v;
689 });
690 std::sort(neg_vals.begin(), neg_vals.end(), [](nation_and_value const& a, nation_and_value const& b) {
691 return a.v < b.v;
692 });
693 }
694
696 text::add_line(state, contents, "monthly_immigration_lab");
697 float total_accounted_for = 0.0f;
698 for(uint32_t i = 0; i < positive_vals.size() && i < 10; ++i) {
699 total_accounted_for += positive_vals[i].v;
700 auto box = text::open_layout_box(contents);
701
702 text::add_to_layout_box(state, contents, box, int64_t(positive_vals[i].v), text::text_color::green);
703 text::add_space_to_layout_box(state, contents, box);
704 text::add_to_layout_box(state, contents, box, text::embedded_flag{ state.world.nation_get_identity_from_identity_holder(positive_vals[i].n) });
705 text::add_space_to_layout_box(state, contents, box);
706 text::add_to_layout_box(state, contents, box, text::get_name(state, positive_vals[i].n));
707
708 text::close_layout_box(contents, box);
709 }
710 if(total_pos - total_accounted_for >= 1.0f) {
711 auto box = text::open_layout_box(contents);
712 text::add_to_layout_box(state, contents, box, int64_t(total_pos - total_accounted_for), text::text_color::green);
713 text::add_space_to_layout_box(state, contents, box);
714 text::localised_format_box(state, contents, box, "pop_other_cult");
715 text::close_layout_box(contents, box);
716 }
717
719 text::add_line(state, contents, "monthly_emigration_lab");
720 total_accounted_for = 0.0f;
721 for(uint32_t i = 0; i < neg_vals.size() && i < 10; ++i) {
722 total_accounted_for += neg_vals[i].v;
723 auto box = text::open_layout_box(contents);
724
725 text::add_to_layout_box(state, contents, box, int64_t(-neg_vals[i].v), text::text_color::red);
726 text::add_space_to_layout_box(state, contents, box);
727 text::add_to_layout_box(state, contents, box, text::embedded_flag{ state.world.nation_get_identity_from_identity_holder(neg_vals[i].n) });
728 text::add_space_to_layout_box(state, contents, box);
729 text::add_to_layout_box(state, contents, box, text::get_name(state, neg_vals[i].n));
730
731 text::close_layout_box(contents, box);
732 }
733 if(total_neg - total_accounted_for <= -1.0f) {
734 auto box = text::open_layout_box(contents);
735 text::add_to_layout_box(state, contents, box, int64_t(-(total_neg - total_accounted_for)), text::text_color::red);
736 text::add_space_to_layout_box(state, contents, box);
737 text::localised_format_box(state, contents, box, "pop_other_cult");
738 text::close_layout_box(contents, box);
739 }
740 } else {
741
742 }
743}
744
745void civilsation_level_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) { //Done
746 auto fat = dcon::fatten(state.world, prov);
747 country_name_box(state, contents, prov);
748
749 if(prov.value < state.province_definitions.first_sea_province.value) {
750 auto box = text::open_layout_box(contents);
751
752 switch(nations::get_status(state, fat.get_nation_from_province_ownership().id)) {
754 {
755 text::localised_format_box(state, contents, box, std::string_view("diplomacy_greatnation_status"));
756 break;
757 }
759 {
760 text::localised_format_box(state, contents, box, std::string_view("diplomacy_colonialnation_status"));
761 break;
762 }
764 {
765 text::localised_format_box(state, contents, box, std::string_view("diplomacy_civilizednation_status"));
766 // Civil
767 break;
768 }
770 {
771 text::localised_format_box(state, contents, box, std::string_view("diplomacy_almost_western_nation_status"));
773 auto civpro = state.world.nation_get_modifier_values(fat.get_nation_from_province_ownership().id, sys::national_mod_offsets::civilization_progress_modifier);
774 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, std::string_view("modifier_civilization_progress")) + ": ");
776 // ???
777 break;
778 }
780 {
781 text::localised_format_box(state, contents, box, std::string_view("diplomacy_uncivilizednation_status"));
783 auto civpro = state.world.nation_get_modifier_values(fat.get_nation_from_province_ownership().id, sys::national_mod_offsets::civilization_progress_modifier);
784 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, std::string_view("modifier_civilization_progress")) + ": ");
786 // Nothing
787 break;
788 }
790 {
791 text::localised_format_box(state, contents, box, std::string_view("diplomacy_primitivenation_status"));
793 auto civpro = state.world.nation_get_modifier_values(fat.get_nation_from_province_ownership().id, sys::national_mod_offsets::civilization_progress_modifier);
794 text::add_to_layout_box(state, contents, box, text::produce_simple_string(state, std::string_view("modifier_civilization_progress")) + ": ");
796 // Nothing
797 break;
798 }
799 default:
800 break;
801 };
802
803 text::close_layout_box(contents, box);
804 }
805}
806
807void relation_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) { //Done
808 auto fat = dcon::fatten(state.world, prov);
809 country_name_box(state, contents, prov);
810
811 if(prov.value < state.province_definitions.first_sea_province.value) {
812 auto box = text::open_layout_box(contents);
813
814 if(dcon::fatten(state.world, state.map_state.selected_province).is_valid()
815 && dcon::fatten(state.world, state.map_state.selected_province).get_nation_from_province_ownership() != fat.get_nation_from_province_ownership()) {
817 auto rel = state.world.get_diplomatic_relation_by_diplomatic_pair(fat.get_nation_from_province_ownership().id, dcon::fatten(state.world, state.map_state.selected_province).get_nation_from_province_ownership());
818 auto fat_rel = dcon::fatten(state.world, rel);
819 text::add_to_substitution_map(sub, text::variable_type::country1, dcon::fatten(state.world, state.map_state.selected_province).get_nation_from_province_ownership().id);
820 text::add_to_substitution_map(sub, text::variable_type::country2, fat.get_nation_from_province_ownership().id);
821 text::add_to_substitution_map(sub, text::variable_type::relation, int32_t(fat_rel.get_value()));
822 text::localised_format_box(state, contents, box, std::string_view("relation_between"), sub);
823
824 } else if(!dcon::fatten(state.world, state.map_state.selected_province).is_valid()
825 && dcon::fatten(state.world, state.local_player_nation) != fat.get_nation_from_province_ownership()) {
827 auto rel = state.world.get_diplomatic_relation_by_diplomatic_pair(fat.get_nation_from_province_ownership().id, state.local_player_nation);
828 auto fat_rel = dcon::fatten(state.world, rel);
830 text::add_to_substitution_map(sub, text::variable_type::country2, fat.get_nation_from_province_ownership().id);
831 text::add_to_substitution_map(sub, text::variable_type::relation, int32_t(fat_rel.get_value()));
832 text::localised_format_box(state, contents, box, std::string_view("relation_between"), sub);
833 }
834
835 text::close_layout_box(contents, box);
836 }
837}
838
839void crisis_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) { // Done
840 auto fat = dcon::fatten(state.world, prov);
841 country_name_box(state, contents, prov);
842
843 if(prov.value < state.province_definitions.first_sea_province.value) {
844 auto box = text::open_layout_box(contents);
845 text::localised_single_sub_box(state, contents, box, std::string_view("flashpoint_tension"), text::variable_type::value, std::to_string(int32_t(fat.get_state_membership().get_flashpoint_tension())));
846 text::close_layout_box(contents, box);
847 }
848}
849
850void naval_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) { // Done
851 auto fat = dcon::fatten(state.world, prov);
852 country_name_box(state, contents, prov);
853
854 if(prov.value < state.province_definitions.first_sea_province.value
855 && fat.get_nation_from_province_ownership().id.value == state.local_player_nation.value
856 && fat.get_is_coast()) {
857 auto box = text::open_layout_box(contents);
858 if(fat.get_building_level(uint8_t(economy::province_building_type::naval_base)) == 0) {
859 dcon::province_id navalprov{};
860 for(auto p : fat.get_state_from_abstract_state_membership().get_abstract_state_membership()) {
861 if(dcon::fatten(state.world, p).get_province().get_building_level(uint8_t(economy::province_building_type::naval_base)) != 0) {
862 navalprov = p.get_province().id;
863 break;
864 }
865 }
866 if(dcon::fatten(state.world, navalprov).is_valid()) {
867 text::localised_single_sub_box(state, contents, box, std::string_view("mapmode_naval_tooltip_in_other"), text::variable_type::prov, navalprov);
868 } else {
870 text::localised_format_box(state, contents, box, std::string_view("mapmode_naval_tooltip_under_con"));
871 } else {
872 text::localised_format_box(state, contents, box, std::string_view("mapmode_naval_tooltip_no_base"));
873 }
874 }
875 } else {
876 text::localised_single_sub_box(state, contents, box, std::string_view("mapmode_naval_tooltip_level"), text::variable_type::lvl, fat.get_building_level(uint8_t(economy::province_building_type::naval_base)));
881 text::localised_format_box(state, contents, box, std::string_view("mapmode_naval_tooltip_cap"), sub);
882 }
883
884 if(province::is_overseas(state, prov)) {
886 text::localised_format_box(state, contents, box, std::string_view("naval_base_overseas_limit"));
887 }
888
889 text::close_layout_box(contents, box);
890 }
891}
892
893void religion_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) { // Done
894 auto fat = dcon::fatten(state.world, prov);
895 country_name_box(state, contents, prov);
896
897 if(prov.value < state.province_definitions.first_sea_province.value) {
898 auto box = text::open_layout_box(contents);
899
900 text::localised_single_sub_box(state, contents, box, std::string_view("mapmode_tooltip_religion_majorities"), text::variable_type::prov, prov);
901
902 std::vector<dcon::religion_fat_id> religions;
903 for(auto pop : fat.get_pop_location()) {
904 if(std::find(religions.begin(), religions.end(), pop.get_pop().get_religion()) == religions.end()) {
905 religions.push_back(pop.get_pop().get_religion());
906 }
907 }
908 std::sort(religions.begin(), religions.end(), [&](auto a, auto b) {return fat.get_demographics(demographics::to_key(state, a.id)) > fat.get_demographics(demographics::to_key(state, b.id)); });
909 //for(size_t i = religions.size(); i > 0; i--) {
910 for(size_t i = 0; i < religions.size(); i++) {
912 text::add_space_to_layout_box(state, contents, box);
913 text::add_to_layout_box(state, contents, box, religions[i].get_name(), text::text_color::yellow);
914 text::add_space_to_layout_box(state, contents, box);
915 text::add_to_layout_box(state, contents, box, std::string_view("("), text::text_color::white);
916 text::add_to_layout_box(state, contents, box, text::format_percentage(fat.get_demographics(demographics::to_key(state, religions[i].id)) / fat.get_demographics(demographics::total)), text::text_color::white);
917 text::add_to_layout_box(state, contents, box, std::string_view(")"), text::text_color::white);
918 }
919
920 text::close_layout_box(contents, box);
921 }
922}
923
924void issues_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) {
925 auto fat = dcon::fatten(state.world, prov);
926 country_name_box(state, contents, prov);
927
928 if(prov.value < state.province_definitions.first_sea_province.value) {
929 auto box = text::open_layout_box(contents);
930
931 text::localised_single_sub_box(state, contents, box, std::string_view("mapmode_tooltip_dominant_issues"), text::variable_type::prov, prov);
932
933 std::vector<dcon::issue_option_fat_id> issues;
934 state.world.for_each_issue_option([&](dcon::issue_option_id id) {
935 if(fat.get_demographics(demographics::to_key(state, id)) > 0) {
936 issues.push_back(dcon::fatten(state.world, id));
937 }
938 });
939 std::sort(issues.begin(), issues.end(), [&](auto a, auto b) {return fat.get_demographics(demographics::to_key(state, a)) > fat.get_demographics(demographics::to_key(state, b)); });
940 for(size_t i = 0; i < std::min(static_cast<size_t>(5), issues.size()); i++) {
942 text::add_space_to_layout_box(state, contents, box);
943 text::add_to_layout_box(state, contents, box, issues[i].get_name(), text::text_color::yellow);
944 text::add_space_to_layout_box(state, contents, box);
945 text::add_to_layout_box(state, contents, box, std::string_view("("), text::text_color::white);
946 text::add_to_layout_box(state, contents, box, text::format_percentage(fat.get_demographics(demographics::to_key(state, issues[i].id)) / fat.get_demographics(demographics::total)), text::text_color::white);
947 text::add_to_layout_box(state, contents, box, std::string_view(")"), text::text_color::white);
948 }
949
950 text::close_layout_box(contents, box);
951 }
952}
953
954void income_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) {
955 auto fat = dcon::fatten(state.world, prov);
956 country_name_box(state, contents, prov);
957
958 if(prov.value < state.province_definitions.first_sea_province.value) {
959 auto box = text::open_layout_box(contents);
960 float savings = 0.f;
961 for(auto pop : fat.get_pop_location()) {
962 savings += pop.get_pop().get_savings();
963 }
964 text::localised_single_sub_box(state, contents, box, std::string_view("mapmode_tooltip_total_income"), text::variable_type::prov, prov);
966 text::close_layout_box(contents, box);
967 }
968}
969
970void ideology_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) {
971 auto fat = dcon::fatten(state.world, prov);
972 country_name_box(state, contents, prov);
973
974 if(prov.value < state.province_definitions.first_sea_province.value) {
975 auto box = text::open_layout_box(contents);
976
977 text::localised_single_sub_box(state, contents, box, std::string_view("mapmode_tooltip_dominant_ideology"), text::variable_type::prov, prov);
978
979 std::vector<dcon::ideology_fat_id> ideologies;
980 float total_pops = state.world.province_get_demographics(prov, demographics::total);
981 state.world.for_each_ideology([&](dcon::ideology_id id) {
982 if(fat.get_demographics(demographics::to_key(state, id)) > 0) {
983 ideologies.push_back(dcon::fatten(state.world, id));
984 }
985 });
986 std::sort(ideologies.begin(), ideologies.end(), [&](auto a, auto b) {return fat.get_demographics(demographics::to_key(state, a.id)) > fat.get_demographics(demographics::to_key(state, b.id)); });
987 for(size_t i = 0; i < ideologies.size(); i++) {
989 text::add_space_to_layout_box(state, contents, box);
990 text::add_to_layout_box(state, contents, box, ideologies[i].get_name(), text::text_color::yellow);
991 text::add_space_to_layout_box(state, contents, box);
992 text::add_to_layout_box(state, contents, box, std::string_view("("), text::text_color::white);
993 text::add_to_layout_box(state, contents, box, text::format_percentage(fat.get_demographics(demographics::to_key(state, ideologies[i].id)) / fat.get_demographics(demographics::total)), text::text_color::white);
994 text::add_to_layout_box(state, contents, box, std::string_view(")"), text::text_color::white);
995 }
996
997 text::close_layout_box(contents, box);
998 }
999}
1000
1001void con_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) {
1002 auto fat = dcon::fatten(state.world, prov);
1003 country_name_box(state, contents, prov);
1004
1005 if(prov.value < state.province_definitions.first_sea_province.value) {
1006 float average_con = (fat.get_demographics(demographics::total) == 0.f ? 0.f : fat.get_demographics(demographics::consciousness) / fat.get_demographics(demographics::total));
1007 text::add_line(state, contents, "mapmode_tooltip_con_average", text::variable_type::val, text::fp_one_place{ average_con });
1008 ui::active_modifiers_description(state, contents, prov, 0, sys::provincial_mod_offsets::pop_consciousness_modifier, true);
1009 ui::active_modifiers_description(state, contents, state.world.province_control_get_nation(state.world.province_get_province_control_as_province(prov)), 0, sys::national_mod_offsets::core_pop_consciousness_modifier, true);
1010 ui::active_modifiers_description(state, contents, state.world.province_control_get_nation(state.world.province_get_province_control_as_province(prov)), 0, sys::national_mod_offsets::global_pop_consciousness_modifier, true);
1011 ui::active_modifiers_description(state, contents, state.world.province_control_get_nation(state.world.province_get_province_control_as_province(prov)), 0, sys::national_mod_offsets::non_accepted_pop_consciousness_modifier, true);
1012 }
1013}
1014
1015void employment_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) {
1016 auto fat = dcon::fatten(state.world, prov);
1017 country_name_box(state, contents, prov);
1018
1019 if(prov.value < state.province_definitions.first_sea_province.value) {
1020 auto box = text::open_layout_box(contents);
1021
1022 float employment_rate = fat.get_demographics(demographics::employable) == 0.f ? 0.f : (fat.get_demographics(demographics::employed) / fat.get_demographics(demographics::employable));
1023
1024 text::localised_format_box(state, contents, box, std::string_view("mapmode_tooltip_total_employment"));
1026
1027 text::close_layout_box(contents, box);
1028 }
1029}
1030
1031void literacy_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) {
1032 auto fat = dcon::fatten(state.world, prov);
1033 country_name_box(state, contents, prov);
1034
1035 if(prov.value < state.province_definitions.first_sea_province.value) {
1036 auto box = text::open_layout_box(contents);
1037
1038 float literacy_rate = fat.get_demographics(demographics::total) == 0.f ? 0.f : (fat.get_demographics(demographics::literacy) / fat.get_demographics(demographics::total));
1039
1040 text::localised_format_box(state, contents, box, std::string_view("mapmode_tooltip_literacy_rate"));
1042
1043 text::close_layout_box(contents, box);
1044 }
1045}
1046
1047void factory_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) {
1048 auto fat = dcon::fatten(state.world, prov);
1049 country_name_box(state, contents, prov);
1050
1051 if(prov.value < state.province_definitions.first_sea_province.value && fat.get_nation_from_province_ownership()) {
1052 auto box = text::open_layout_box(contents);
1053
1054 auto region = fat.get_state_membership();
1055
1056 text::localised_single_sub_box(state, contents, box, std::string_view("mapmode_tooltip_factory_count"), text::variable_type::state, text::get_province_state_name(state, prov));
1057
1058 std::vector<dcon::factory_fat_id> factories;
1059 for(auto m : fat.get_state_from_abstract_state_membership().get_abstract_state_membership()) {
1060 auto p = m.get_province();
1061 if(p.get_nation_from_province_ownership() == fat.get_nation_from_province_ownership()) {
1062 for(auto f : p.get_factory_location()) {
1063 factories.push_back(f.get_factory());
1064 }
1065 }
1066 }
1067 std::sort(factories.begin(), factories.end(), [&](auto a, auto b) {return a.get_level() > b.get_level(); });
1068
1070 for(size_t i = 0; i < factories.size(); i++) {
1072 text::add_space_to_layout_box(state, contents, box);
1073 text::add_to_layout_box(state, contents, box, factories[i].get_building_type().get_name(), text::text_color::yellow);
1074 text::add_space_to_layout_box(state, contents, box);
1075 text::add_to_layout_box(state, contents, box, std::string_view("("), text::text_color::white);
1076 text::add_to_layout_box(state, contents, box, factories[i].get_level(),text::text_color::white);
1077 text::add_to_layout_box(state, contents, box, std::string_view(")"), text::text_color::white);
1078 }
1079
1080 text::close_layout_box(contents, box);
1081 }
1082}
1083
1084void fort_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) {
1085 auto fat = dcon::fatten(state.world, prov);
1086 country_name_box(state, contents, prov);
1087
1088
1089 if(prov.value < state.province_definitions.first_sea_province.value) {
1090 if(fat.get_building_level(uint8_t(economy::province_building_type::fort)) > 0) {
1091 auto box = text::open_layout_box(contents);
1092 text::localised_format_box(state, contents, box, std::string_view("mapmode_tooltip_fort_level"));
1094 text::close_layout_box(contents, box);
1095 }
1097 auto box3 = text::open_layout_box(contents);
1098 text::localised_format_box(state, contents, box3, std::string_view("mapmode_tooltip_fort_being_built"));
1099 text::close_layout_box(contents, box3);
1100 }
1101 if(province::can_build_fort(state, fat.id, state.local_player_nation)) {
1102 auto box3 = text::open_layout_box(contents);
1103 text::localised_format_box(state, contents, box3, std::string_view("mapmode_tooltip_can_build_fort"));
1104 text::close_layout_box(contents, box3);
1105 }
1106 }
1107}
1108
1109void growth_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) {
1110 auto fat = dcon::fatten(state.world, prov);
1111 country_name_box(state, contents, prov);
1112
1113 if(prov.value < state.province_definitions.first_sea_province.value) {
1114 auto box = text::open_layout_box(contents);
1115
1116 text::localised_format_box(state, contents, box, std::string_view("mapmode_tooltip_population_change"));
1118
1119 text::close_layout_box(contents, box);
1120 }
1121}
1122
1123void revolt_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) {
1124 auto fat = dcon::fatten(state.world, prov);
1125 country_name_box(state, contents, prov);
1126
1127 if(prov.value < state.province_definitions.first_sea_province.value) {
1128 auto total_rebels = 0.f;
1129 std::vector<std::pair<dcon::rebel_faction_id, float>> rebel_factions;
1130 for(auto pop : fat.get_pop_location()) {
1131 if(pop.get_pop().get_pop_rebellion_membership().get_rebel_faction()) {
1132 auto fid = pop.get_pop().get_pop_rebellion_membership().get_rebel_faction().id;
1133 auto rebel_pop = pop.get_pop().get_size();
1134 auto f = std::find_if(rebel_factions.begin(), rebel_factions.end(), [fid](const auto& pair) {
1135 return pair.first == fid;
1136 });
1137 if(f != rebel_factions.end()) {
1138 f->second += rebel_pop;
1139 } else {
1140 rebel_factions.push_back(std::make_pair(fid, rebel_pop));
1141 }
1142 total_rebels += pop.get_pop().get_size();
1143 }
1144 }
1145 std::sort(rebel_factions.begin(), rebel_factions.end(), [&](auto a, auto b) {return a.second > b.second; });
1146
1147 auto box = text::open_layout_box(contents);
1148
1149 if(total_rebels <= 0.f) {
1150 text::localised_format_box(state, contents, box, std::string_view("mapmode_tooltip_rebels_none"));
1151 } else {
1152 text::localised_format_box(state, contents, box, std::string_view("mapmode_tooltip_rebels_amount"));
1153 text::add_to_layout_box(state, contents, box, text::prettify(int64_t(total_rebels)), text::text_color::yellow);
1154
1155 for(size_t i = 0; i < rebel_factions.size(); i++) {
1157 text::add_space_to_layout_box(state, contents, box);
1158 text::add_to_layout_box(state, contents, box, rebel::rebel_name(state, rebel_factions[i].first), text::text_color::yellow);
1159 text::add_space_to_layout_box(state, contents, box);
1160 text::add_to_layout_box(state, contents, box, std::string_view("("), text::text_color::white);
1161 text::add_to_layout_box(state, contents, box, text::prettify(int64_t(rebel_factions[i].second)), text::text_color::white);
1162 text::add_to_layout_box(state, contents, box, std::string_view(")"), text::text_color::white);
1163 }
1164 }
1165
1166 text::close_layout_box(contents, box);
1167 }
1168}
1169
1170void players_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) {
1171 auto fat = dcon::fatten(state.world, prov);
1172 country_name_box(state, contents, prov);
1173 if(prov.value < state.province_definitions.first_sea_province.value) {
1174 auto n = state.world.province_get_nation_from_province_ownership(prov);
1175 if(n) {
1176 auto box = text::open_layout_box(contents);
1178
1180 auto nickname = state.world.mp_player_get_nickname(p);
1182 if(n == state.local_player_nation) {
1183 if(state.network_mode == sys::network_mode_type::single_player) {
1184 text::localised_format_box(state, contents, box, std::string_view("mapmode_tooltip_34_you_sp"), sub);
1185 } else {
1186 text::localised_format_box(state, contents, box, std::string_view("mapmode_tooltip_34_you"), sub);
1187 }
1188 } else if(state.world.nation_get_is_player_controlled(n)) {
1189 text::localised_format_box(state, contents, box, std::string_view("mapmode_tooltip_34"), sub);
1190 }
1191 if(!state.world.nation_get_is_player_controlled(n)) {
1192 text::localised_format_box(state, contents, box, std::string_view("mapmode_tooltip_34_ai"), sub);
1193 }
1194 text::close_layout_box(contents, box);
1195 }
1196 }
1197}
1198void life_needs_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) {
1199 auto fat = dcon::fatten(state.world, prov);
1200 country_name_box(state, contents, prov);
1201 if(prov.value < state.province_definitions.first_sea_province.value) {
1202 float value = 0.f;
1203 float total = 0.f;
1204 for(const auto pl : state.world.province_get_pop_location_as_province(prov)) {
1205 value += pop_demographics::get_life_needs(state, pl.get_pop()) * pl.get_pop().get_size();
1206 total += pl.get_pop().get_size();
1207 }
1208 if(total > 0.f) {
1209 float ratio = value / total;
1210 auto box = text::open_layout_box(contents);
1213 text::localised_format_box(state, contents, box, std::string_view("mapmode_tooltip_35"), sub);
1214 text::close_layout_box(contents, box);
1215 }
1216 }
1217}
1218void everyday_needs_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) {
1219 auto fat = dcon::fatten(state.world, prov);
1220 country_name_box(state, contents, prov);
1221 if(prov.value < state.province_definitions.first_sea_province.value) {
1222 float value = 0.f;
1223 float total = 0.f;
1224 for(const auto pl : state.world.province_get_pop_location_as_province(prov)) {
1225 value += pop_demographics::get_everyday_needs(state, pl.get_pop()) * pl.get_pop().get_size();
1226 total += pl.get_pop().get_size();
1227 }
1228 if(total > 0.f) {
1229 float ratio = value / total;
1230 auto box = text::open_layout_box(contents);
1233 text::localised_format_box(state, contents, box, std::string_view("mapmode_tooltip_36"), sub);
1234 text::close_layout_box(contents, box);
1235 }
1236 }
1237}
1238void luxury_needs_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) {
1239 auto fat = dcon::fatten(state.world, prov);
1240 country_name_box(state, contents, prov);
1241 if(prov.value < state.province_definitions.first_sea_province.value) {
1242 float value = 0.f;
1243 float total = 0.f;
1244 for(const auto pl : state.world.province_get_pop_location_as_province(prov)) {
1245 value += pop_demographics::get_luxury_needs(state, pl.get_pop()) * pl.get_pop().get_size();
1246 total += pl.get_pop().get_size();
1247 }
1248 if(total > 0.f) {
1249 float ratio = value / total;
1250 auto box = text::open_layout_box(contents);
1253 text::localised_format_box(state, contents, box, std::string_view("mapmode_tooltip_37"), sub);
1254 text::close_layout_box(contents, box);
1255 }
1256 }
1257}
1258void officers_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) {
1259 auto fat = dcon::fatten(state.world, prov);
1260 country_name_box(state, contents, prov);
1261 if(prov.value < state.province_definitions.first_sea_province.value) {
1262 float value = state.world.province_get_demographics(prov, demographics::to_key(state, state.culture_definitions.officers));
1263 float total = state.world.province_get_demographics(prov, demographics::total);
1264 float ratio = value / std::max(1.f, total);
1265 auto box = text::open_layout_box(contents);
1270 text::localised_format_box(state, contents, box, std::string_view("mapmode_tooltip_38"), sub);
1271 text::close_layout_box(contents, box);
1272 }
1273}
1274void ctc_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) {
1275 auto fat = dcon::fatten(state.world, prov);
1276 country_name_box(state, contents, prov);
1277 if(prov.value < state.province_definitions.first_sea_province.value) {
1278 float total_pw = state.world.province_get_demographics(prov, demographics::to_key(state, state.culture_definitions.primary_factory_worker));
1279 float total_sw = state.world.province_get_demographics(prov, demographics::to_key(state, state.culture_definitions.secondary_factory_worker));
1280 float ratio = total_pw / std::max(1.f, total_pw + total_sw);
1281 auto box = text::open_layout_box(contents);
1287 text::localised_format_box(state, contents, box, std::string_view("mapmode_tooltip_39"), sub);
1288 text::close_layout_box(contents, box);
1289 }
1290}
1291void life_rating_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) {
1292 auto fat = dcon::fatten(state.world, prov);
1293 country_name_box(state, contents, prov);
1294 if(prov.value < state.province_definitions.first_sea_province.value) {
1295 auto box = text::open_layout_box(contents);
1297 text::add_to_substitution_map(sub, text::variable_type::x, text::pretty_integer{ int32_t(state.world.province_get_life_rating(prov)) });
1298 text::localised_format_box(state, contents, box, std::string_view("mapmode_tooltip_40"), sub);
1299 text::close_layout_box(contents, box);
1300 }
1301}
1302void crime_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) {
1303 auto fat = dcon::fatten(state.world, prov);
1304 country_name_box(state, contents, prov);
1305 if(prov.value < state.province_definitions.first_sea_province.value && state.world.province_get_crime(prov)) {
1306 auto box = text::open_layout_box(contents);
1308 text::add_to_substitution_map(sub, text::variable_type::x, state.culture_definitions.crimes[state.world.province_get_crime(prov)].name);
1309 text::localised_format_box(state, contents, box, std::string_view("mapmode_tooltip_41"), sub);
1310 text::close_layout_box(contents, box);
1311 ui::modifier_description(state, contents, state.culture_definitions.crimes[state.world.province_get_crime(prov)].modifier);
1312 }
1313}
1314void rally_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) {
1315 auto fat = dcon::fatten(state.world, prov);
1316 country_name_box(state, contents, prov);
1317 if(prov.value < state.province_definitions.first_sea_province.value) {
1318 text::add_line_with_condition(state, contents, "mapmode_tooltip_42_1", state.world.province_get_land_rally_point(prov));
1319 text::add_line_with_condition(state, contents, "mapmode_tooltip_42_2", state.world.province_get_naval_rally_point(prov));
1320 }
1321}
1322void workforce_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) {
1323 auto fat = dcon::fatten(state.world, prov);
1324 country_name_box(state, contents, prov);
1325 if(prov.value < state.province_definitions.first_sea_province.value) {
1326 {
1327 auto box = text::open_layout_box(contents);
1328 text::localised_format_box(state, contents, box, std::string_view("mapmode_tooltip_43"));
1329 text::close_layout_box(contents, box);
1330 }
1331 float total = state.world.province_get_demographics(prov, demographics::total);
1332 for(const auto pt : state.world.in_pop_type) {
1333 float value = state.world.province_get_demographics(prov, demographics::to_key(state, pt));
1334 if(value > 0.f) {
1335 auto box = text::open_layout_box(contents);
1336 text::add_to_layout_box(state, contents, box, pt.get_name(), text::text_color::white);
1337 text::add_to_layout_box(state, contents, box, std::string_view(":"), text::text_color::white);
1338 text::add_space_to_layout_box(state, contents, box);
1340 text::add_space_to_layout_box(state, contents, box);
1341 text::add_to_layout_box(state, contents, box, std::string_view("("), text::text_color::yellow);
1343 text::add_to_layout_box(state, contents, box, std::string_view(")"), text::text_color::yellow);
1344 text::close_layout_box(contents, box);
1345 }
1346 }
1347 }
1348}
1349void mobilization_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) {
1350 auto fat = dcon::fatten(state.world, prov);
1351 country_name_box(state, contents, prov);
1352 if(prov.value < state.province_definitions.first_sea_province.value) {
1355 auto box = text::open_layout_box(contents);
1359 if(max == 0) {
1360 text::localised_format_box(state, contents, box, std::string_view("mapmode_tooltip_44_2"), sub);
1361 } else {
1362 text::localised_format_box(state, contents, box, std::string_view("mapmode_tooltip_44"), sub);
1363 }
1364 text::close_layout_box(contents, box);
1365 }
1366}
1367
1368void picking_map_tt_box(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) { // Done
1369 country_name_box(state, contents, prov);
1370 if(auto n = state.world.province_get_nation_from_province_ownership(prov); n) {
1371 auto fat_id = dcon::fatten(state.world, n);
1372 auto box = text::open_layout_box(contents);
1375 auto total = fat_id.get_demographics(demographics::total);
1376 if(total > 0.f) {
1377 {
1380 text::localised_format_box(state, contents, box, std::string_view("alice_pnt_pops"), sub);
1382 }
1383 {
1384 auto value = fat_id.get_demographics(demographics::rich_total);
1388 text::localised_format_box(state, contents, box, std::string_view("alice_pnt_rpops"), sub);
1390 }
1391 {
1392 auto value = fat_id.get_demographics(demographics::middle_total);
1396 text::localised_format_box(state, contents, box, std::string_view("alice_pnt_mpops"), sub);
1398 }
1399 {
1400 auto value = fat_id.get_demographics(demographics::poor_total);
1404 text::localised_format_box(state, contents, box, std::string_view("alice_pnt_ppops"), sub);
1406 }
1407 }
1408 if(fat_id.get_primary_culture()) {
1410 text::add_to_substitution_map(sub, text::variable_type::x, fat_id.get_primary_culture().get_name());
1411 text::localised_format_box(state, contents, box, std::string_view("alice_pnt_culture"), sub);
1413 }
1414 if(fat_id.get_religion()) {
1416 text::add_to_substitution_map(sub, text::variable_type::x, fat_id.get_religion().get_name());
1417 text::localised_format_box(state, contents, box, std::string_view("alice_pnt_religion"), sub);
1419 }
1420 if(fat_id.get_dominant_religion()) {
1422 text::add_to_substitution_map(sub, text::variable_type::x, fat_id.get_dominant_religion().get_name());
1423 text::localised_format_box(state, contents, box, std::string_view("alice_pnt_dominant_religion"), sub);
1425 }
1426 if(fat_id.get_dominant_ideology()) {
1428 text::add_to_substitution_map(sub, text::variable_type::x, fat_id.get_dominant_ideology().get_name());
1429 text::localised_format_box(state, contents, box, std::string_view("alice_pnt_dominant_ideology"), sub);
1431 }
1433 text::close_layout_box(contents, box);
1434 }
1435}
1436
1437void populate_map_tooltip(sys::state& state, text::columnar_layout& contents, dcon::province_id prov) {
1438 if(state.current_scene.overwrite_map_tooltip) {
1439 picking_map_tt_box(state, contents, prov);
1440 return;
1441 }
1442
1443 switch(state.map_state.active_map_mode) {
1445 terrain_map_tt_box(state, contents, prov);
1446 break;
1448 political_map_tt_box(state, contents, prov);
1449 break;
1451 political_map_tt_box(state, contents, prov);
1452 break;
1454 revolt_map_tt_box(state, contents, prov);
1455 break;
1457 diplomatic_map_tt_box(state, contents, prov);
1458 break;
1460 region_map_tt_box(state, contents, prov);
1461 break;
1463 infrastructure_map_tt_box(state, contents, prov);
1464 break;
1466 colonial_map_tt_box(state, contents, prov);
1467 break;
1469 admin_map_tt_box(state, contents, prov);
1470 break;
1472 recruitment_map_tt_box(state, contents, prov);
1473 break;
1475 nationalfocus_map_tt_box(state, contents, prov);
1476 break;
1478 rgooutput_map_tt_box(state, contents, prov);
1479 break;
1481 population_map_tt_box(state, contents, prov);
1482 break;
1484 nationality_map_tt_box(state, contents, prov);
1485 break;
1487 sphere_map_tt_box(state, contents, prov);
1488 break;
1490 supply_map_tt_box(state, contents, prov);
1491 break;
1493 party_loyalty_map_tt_box(state, contents, prov);
1494 break;
1496 rank_map_tt_box(state, contents, prov);
1497 break;
1499 migration_map_tt_box(state, contents, prov);
1500 break;
1502 civilsation_level_map_tt_box(state, contents, prov);
1503 break;
1505 relation_map_tt_box(state, contents, prov);
1506 break;
1508 crisis_map_tt_box(state, contents, prov);
1509 break;
1511 naval_map_tt_box(state, contents, prov);
1512 break;
1514 religion_map_tt_box(state, contents, prov);
1515 break;
1517 issues_map_tt_box(state, contents, prov);
1518 break;
1520 income_map_tt_box(state, contents, prov);
1521 break;
1523 ideology_map_tt_box(state, contents, prov);
1524 break;
1526 con_map_tt_box(state, contents, prov);
1527 break;
1529 employment_map_tt_box(state, contents, prov);
1530 break;
1532 literacy_map_tt_box(state, contents, prov);
1533 break;
1535 factory_map_tt_box(state, contents, prov);
1536 break;
1538 fort_map_tt_box(state, contents, prov);
1539 break;
1541 growth_map_tt_box(state, contents, prov);
1542 break;
1544 militancy_map_tt_box(state, contents, prov);
1545 break;
1546 //even newer mapmodes
1548 players_map_tt_box(state, contents, prov);
1549 break;
1551 life_needs_map_tt_box(state, contents, prov);
1552 break;
1554 everyday_needs_map_tt_box(state, contents, prov);
1555 break;
1557 luxury_needs_map_tt_box(state, contents, prov);
1558 break;
1560 life_rating_map_tt_box(state, contents, prov);
1561 break;
1563 ctc_map_tt_box(state, contents, prov);
1564 break;
1566 mobilization_map_tt_box(state, contents, prov);
1567 break;
1569 officers_map_tt_box(state, contents, prov);
1570 break;
1572 crime_map_tt_box(state, contents, prov);
1573 break;
1575 rally_map_tt_box(state, contents, prov);
1576 break;
1578 workforce_map_tt_box(state, contents, prov);
1579 break;
1580 default:
1581 break;
1582 };
1583}
1584
1585}
dcon::text_key get_name() noexcept
std::vector< dcon::province_id > calculate_navy_path(sys::state &state, dcon::nation_id source, dcon::navy_id n, dcon::province_id last_province, dcon::province_id dest)
Definition: commands.cpp:3541
std::vector< dcon::province_id > calculate_army_path(sys::state &state, dcon::nation_id source, dcon::army_id a, dcon::province_id last_province, dcon::province_id dest)
Definition: commands.cpp:3303
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
void estimate_directed_immigration(sys::state &state, dcon::nation_id n, std::vector< float > &national_amounts)
constexpr dcon::demographics_key middle_total(21)
constexpr dcon::demographics_key total(0)
dcon::demographics_key to_key(sys::state const &state, dcon::pop_type_id v)
constexpr dcon::demographics_key employable(1)
constexpr dcon::demographics_key consciousness(3)
constexpr dcon::demographics_key rich_total(22)
constexpr dcon::demographics_key poor_total(20)
constexpr dcon::demographics_key employed(2)
float get_monthly_pop_increase(sys::state &state, dcon::pop_id ids)
constexpr dcon::demographics_key literacy(5)
int32_t regiments_under_construction_in_province(sys::state &state, dcon::province_id p)
Definition: military.cpp:986
int32_t mobilized_regiments_created_from_province(sys::state &state, dcon::province_id p)
Definition: military.cpp:833
uint32_t naval_supply_from_naval_base(sys::state &state, dcon::province_id prov, dcon::nation_id nation)
Definition: military.cpp:1256
int32_t regiments_created_from_province(sys::state &state, dcon::province_id p)
Definition: military.cpp:823
int32_t mobilized_regiments_possible_from_province(sys::state &state, dcon::province_id p)
Definition: military.cpp:1137
bool are_at_war(sys::state const &state, dcon::nation_id a, dcon::nation_id b)
Definition: military.cpp:649
int32_t supply_limit_in_province(sys::state &state, dcon::nation_id n, dcon::province_id p)
Definition: military.cpp:794
int32_t movement_time_from_to(sys::state &state, dcon::army_id a, dcon::province_id from, dcon::province_id to)
Definition: military.cpp:4258
int32_t regiments_max_possible_from_province(sys::state &state, dcon::province_id p)
Definition: military.cpp:885
int32_t naval_supply_points(sys::state &state, dcon::nation_id n)
Definition: military.cpp:1249
constexpr uint8_t level_mask
Definition: nations.hpp:167
int32_t get_level(sys::state &state, dcon::nation_id gp, dcon::nation_id target)
Definition: nations.cpp:25
status get_status(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1145
std::string int_to_tag(uint32_t v)
Definition: nations.hpp:14
void get_active_political_parties(sys::state &state, dcon::nation_id n, std::vector< dcon::political_party_id > &parties)
Definition: nations.cpp:1457
dcon::mp_player_id find_country_player(sys::state &state, dcon::nation_id nation)
Definition: network.cpp:702
float get_luxury_needs(sys::state const &state, dcon::pop_id p)
float get_life_needs(sys::state const &state, dcon::pop_id p)
float get_everyday_needs(sys::state const &state, dcon::pop_id p)
constexpr uint8_t impassible_bit
Definition: constants.hpp:595
constexpr uint8_t coastal_bit
Definition: constants.hpp:594
float direct_distance(sys::state &state, dcon::province_id a, dcon::province_id b)
Definition: province.cpp:1745
float sorting_distance(sys::state &state, dcon::province_id a, dcon::province_id b)
Definition: province.cpp:1752
bool has_an_owner(sys::state &state, dcon::province_id id)
Definition: province.cpp:502
bool has_naval_base_being_built(sys::state &state, dcon::province_id id)
Definition: province.cpp:434
bool is_overseas(sys::state const &state, dcon::province_id ids)
Definition: province.cpp:19
bool can_build_fort(sys::state &state, dcon::province_id id, dcon::nation_id n)
Definition: province.cpp:420
bool can_start_colony(sys::state &state, dcon::nation_id n, dcon::state_definition_id d)
Definition: province.cpp:1255
bool has_fort_being_built(sys::state &state, dcon::province_id id)
Definition: province.cpp:413
float revolt_risk(sys::state &state, dcon::province_id id)
Definition: province.cpp:611
float state_admin_efficiency(sys::state &state, dcon::state_instance_id id)
Definition: province.cpp:553
std::string rebel_name(sys::state &state, dcon::rebel_faction_id reb)
Definition: rebels.cpp:1276
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 resolve_string_substitution(sys::state &state, dcon::text_key source_text, substitution_map const &mp)
Definition: text.cpp:2137
layout_box open_layout_box(layout_base &dest, int32_t indent)
Definition: text.cpp:1823
void add_unparsed_text_to_layout_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view sv, substitution_map const &mp)
Definition: text.cpp:1612
void localised_single_sub_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view key, variable_type subkey, substitution value)
Definition: text.cpp:1912
void localised_format_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view key, text::substitution_map const &sub)
Definition: text.cpp:1904
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:1923
void add_line_with_condition(sys::state &state, layout_base &dest, std::string_view key, bool condition_met, int32_t indent)
Definition: text.cpp:1979
void add_line_break_to_layout(sys::state &state, columnar_layout &dest)
Definition: text.cpp:1152
void add_to_substitution_map(substitution_map &mp, variable_type key, substitution value)
Definition: text.cpp:1068
void add_divider_to_layout_box(sys::state &state, layout_base &dest, layout_box &box)
Definition: text.cpp:2122
ankerl::unordered_dense::map< uint32_t, substitution > substitution_map
Definition: text.hpp:797
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
Definition: text.cpp:617
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
std::string get_influence_level_name(sys::state const &state, uint8_t v)
Definition: text.cpp:958
void add_space_to_layout_box(sys::state &state, layout_base &dest, layout_box &box)
Definition: text.cpp:1812
std::string get_province_state_name(sys::state &state, dcon::province_id prov_id)
Definition: text.cpp:864
std::string prettify_currency(float num)
Definition: text.cpp:702
void close_layout_box(columnar_layout &dest, layout_box &box)
Definition: text.cpp:1831
void terrain_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void life_needs_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
unitamounts calc_amounts_from_navy(sys::state &state, dcon::navy_fat_id navy)
void colonial_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void workforce_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void modifier_description(sys::state &state, text::layout_base &layout, dcon::modifier_id mid, int32_t indentation=0)
void recruitment_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void picking_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void country_name_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
Definition: map_tooltip.cpp:44
void populate_map_tooltip(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void income_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void factory_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void diplomatic_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void employment_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void party_loyalty_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void rally_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void fort_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void ideology_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void life_rating_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void crime_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
unitamounts calc_amounts_from_army(sys::state &state, dcon::army_fat_id army)
Definition: unit_tooltip.cpp:7
void officers_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void political_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void admin_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void population_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void literacy_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void relation_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void naval_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void mobilization_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void con_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void nationalfocus_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void civilsation_level_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void issues_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void supply_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void infrastructure_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void militancy_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void revolt_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void ctc_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void nationality_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void region_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void growth_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void luxury_needs_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void rank_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void crisis_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void sphere_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void rgooutput_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void religion_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void migration_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
void players_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
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)
float selected_relative_attrition_amount(sys::state &state, dcon::nation_id n, std::vector< dcon::army_id > &list, dcon::province_id prov)
Definition: map_tooltip.cpp:9
void everyday_needs_map_tt_box(sys::state &state, text::columnar_layout &contents, dcon::province_id prov)
uint uint32_t
uchar uint8_t
Holds important data about the game world, state, and other data regarding windowing,...