Project Alice
Loading...
Searching...
No Matches
gui_topbar.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "demographics.hpp"
10#include "gui_trade_window.hpp"
13#include "gui_chat_window.hpp"
16#include "nations.hpp"
17#include "politics.hpp"
18#include "rebels.hpp"
19#include "system_state.hpp"
20#include "text.hpp"
21#include "gui_event.hpp"
22
23#include "gui_armygroups.hpp"
24
25namespace ui {
26
27class topbar_nation_name : public generic_name_text<dcon::nation_id> {
28public:
31 }
32
33 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
34 if(state.cheat_data.show_province_id_tooltip) {
35 auto box = text::open_layout_box(contents);
36 text::add_to_layout_box(state, contents, box, std::string_view("Nation ID:"));
38 text::add_to_layout_box(state, contents, box, std::to_string(state.local_player_nation.value));
39 text::close_layout_box(contents, box);
40 }
41 }
42};
43
45public:
46 void on_update(sys::state& state) noexcept override {
47 set_text(state, std::to_string(int32_t(nations::prestige_score(state, retrieve<dcon::nation_id>(state, parent)))));
48 }
51 }
52
53 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
54 auto nation_id = retrieve<dcon::nation_id>(state, parent);
55 auto box = text::open_layout_box(contents, 0);
56 text::localised_format_box(state, contents, box, std::string_view("rank_prestige"), text::substitution_map{});
58 switch(nations::get_status(state, nation_id)) {
60 text::localised_format_box(state, contents, box, std::string_view("diplomacy_greatnation_status"), text::substitution_map{});
61 break;
63 text::localised_format_box(state, contents, box, std::string_view("diplomacy_colonialnation_status"), text::substitution_map{});
64 break;
66 text::localised_format_box(state, contents, box, std::string_view("diplomacy_civilizednation_status"), text::substitution_map{});
67 break;
69 text::localised_format_box(state, contents, box, std::string_view("diplomacy_almost_western_nation_status"), text::substitution_map{});
70 break;
72 text::localised_format_box(state, contents, box, std::string_view("diplomacy_uncivilizednation_status"), text::substitution_map{});
73 break;
75 text::localised_format_box(state, contents, box, std::string_view("diplomacy_primitivenation_status"), text::substitution_map{});
76 break;
77 default:
78 break;
79 };
80 text::close_layout_box(contents, box);
82 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::prestige, true);
84 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::permanent_prestige, true);
85 }
86};
87
89public:
92 }
93
94 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
95 auto nation_id = retrieve<dcon::nation_id>(state, parent);
96 auto box = text::open_layout_box(contents, 0);
97 text::localised_format_box(state, contents, box, std::string_view("rank_industry"), text::substitution_map{});
99 text::localised_format_box(state, contents, box, std::string_view("rank_industry_d"), text::substitution_map{});
100 text::close_layout_box(contents, box);
101 }
102};
103
105public:
108 }
109
110 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
111 auto nation_id = retrieve<dcon::nation_id>(state, parent);
112 auto box = text::open_layout_box(contents, 0);
113 text::localised_format_box(state, contents, box, std::string_view("rank_military"), text::substitution_map{});
115 text::localised_format_box(state, contents, box, std::string_view("rank_military_d"), text::substitution_map{});
116 text::close_layout_box(contents, box);
117 }
118};
119
121public:
124 }
125
126 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
127 auto nation_id = retrieve<dcon::nation_id>(state, parent);
128
130 std::string value;
132 text::add_to_substitution_map(sub, text::variable_type::value, std::string_view(value));
133 auto box = text::open_layout_box(contents, 0);
134 text::localised_format_box(state, contents, box, std::string_view("colonial_points"), sub);
136 text::localised_format_box(state, contents, box, std::string_view("explain_colonial_points"), sub);
138 text::localised_format_box(state, contents, box, std::string_view("available_colonial_power"), sub);
140 text::localised_format_box(state, contents, box, std::string_view("colonial_points_from_technology"), sub);
141 text::add_space_to_layout_box(state, contents, box);
144 text::localised_format_box(state, contents, box, std::string_view("colonial_points_from_naval_bases"), sub);
145 text::add_space_to_layout_box(state, contents, box);
148 text::localised_format_box(state, contents, box, std::string_view("colonial_points_from_ships"), sub);
149 text::add_space_to_layout_box(state, contents, box);
152 text::localised_format_box(state, contents, box, std::string_view("used_colonial_maintenance"), sub);
153 text::add_space_to_layout_box(state, contents, box);
155 text::close_layout_box(contents, box);
156 }
157};
158
160public:
162
163 void on_create(sys::state& state) noexcept override {
166 }
167
168 void on_update(sys::state& state) noexcept override {
169 std::vector<float> datapoints(size_t(32));
170 for(size_t i = 0; i < state.player_data_cache.treasury_record.size(); ++i)
171 datapoints[i] = state.player_data_cache.treasury_record[(state.ui_date.value + 1 + i) % 32] - state.player_data_cache.treasury_record[(state.ui_date.value + 0 + i) % 32];
172 datapoints[datapoints.size() - 1] = state.player_data_cache.treasury_record[(state.ui_date.value + 1 + 31) % 32] - state.player_data_cache.treasury_record[(state.ui_date.value + 0 + 31) % 32];
173 datapoints[0] = datapoints[1]; // otherwise you will store the difference between two non-consecutive days here
175 }
176};
177
179public:
180 void on_create(sys::state& state) noexcept override {
184 }
185
186 void on_update(sys::state& state) noexcept override {
187 auto n = retrieve<dcon::nation_id>(state, parent);
188 auto literacy = state.world.nation_get_demographics(n, demographics::literacy);
189 auto total_pop = std::max(1.0f, state.world.nation_get_demographics(n, demographics::total));
191 }
192
195 }
196
197 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
198 auto nation_id = retrieve<dcon::nation_id>(state, parent);
199
200 auto box = text::open_layout_box(contents, 0);
202 auto literacy_change = demographics::get_estimated_literacy_change(state, nation_id);
204 auto total = state.world.nation_get_demographics(nation_id, demographics::total);
205 auto avg_literacy = text::format_percentage(total != 0.f ? (state.world.nation_get_demographics(nation_id, demographics::literacy) / total) : 0.f, 1);
206 text::add_to_substitution_map(sub, text::variable_type::avg, std::string_view(avg_literacy));
207 text::localised_format_box(state, contents, box, std::string_view("topbar_avg_literacy"), sub);
209 text::localised_format_box(state, contents, box, std::string_view("topbar_avg_change"), sub);
210 text::close_layout_box(contents, box);
211 }
212};
213
215public:
216 void on_create(sys::state& state) noexcept override {
220 }
221 void on_update(sys::state& state) noexcept override {
222 set_text(state, text::format_float(state.world.nation_get_infamy(retrieve<dcon::nation_id>(state, parent)), 2));
223 }
226 }
227
228 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
229 auto nation_id = retrieve<dcon::nation_id>(state, parent);
230 auto box = text::open_layout_box(contents, 0);
231 auto fat_id = dcon::fatten(state.world, nation_id);
232 text::localised_format_box(state, contents, box, "infamy");
233 text::add_to_layout_box(state, contents, box, std::string_view(":"));
234 text::add_space_to_layout_box(state, contents, box);
235 text::add_to_layout_box(state, contents, box, text::fp_two_places{fat_id.get_infamy()});
236 text::add_to_layout_box(state, contents, box, std::string_view("/"));
237 text::add_to_layout_box(state, contents, box, text::fp_two_places{state.defines.badboy_limit});
239 text::localised_format_box(state, contents, box, "badboy_dro_1");
240 text::close_layout_box(contents, box);
241 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::badboy, false);
242 }
243};
244
246public:
247 void on_update(sys::state& state) noexcept override {
248 auto n = retrieve<dcon::nation_id>(state, parent);
249 auto total_pop = state.world.nation_get_demographics(n, demographics::total);
250
251 auto pop_amount = state.player_data_cache.population_record[state.ui_date.value % 32];
252 auto pop_change = state.ui_date.value <= 32
253 ? (state.ui_date.value <= 2 ? 0.0f : pop_amount - state.player_data_cache.population_record[2])
254 : (pop_amount - state.player_data_cache.population_record[(state.ui_date.value - 30) % 32]);
255
257 if(pop_change == 0)
259
262 auto box = text::open_layout_box(layout, 0);
263 text::add_to_layout_box(state, layout, box, text::prettify(int32_t(total_pop)));
264 text::add_to_layout_box(state, layout, box, std::string(" ("));
265 if(pop_change > 0) {
266 text::add_to_layout_box(state, layout, box, std::string("+"), text::text_color::green);
267 }
268 text::add_to_layout_box(state, layout, box, text::pretty_integer{int64_t(pop_change)}, color);
269 text::add_to_layout_box(state, layout, box, std::string(")"));
270 text::close_layout_box(layout, box);
271 }
274 }
275 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
276
277 auto nation_id = retrieve<dcon::nation_id>(state, parent);
278
279 auto pop_amount = state.player_data_cache.population_record[state.ui_date.value % 32];
280 auto pop_change = state.ui_date.value <= 30 ? 0.0f : (pop_amount - state.player_data_cache.population_record[(state.ui_date.value - 30) % 32]);
281
282 text::add_line(state, contents, "pop_growth_topbar_3", text::variable_type::curr, text::pretty_integer{ int64_t(state.world.nation_get_demographics(nation_id, demographics::total)) });
283 text::add_line(state, contents, "pop_growth_topbar_2", text::variable_type::x, text::pretty_integer{ int64_t(pop_change) });
285 text::add_line(state, contents, "pop_growth_topbar_4", text::variable_type::val, text::pretty_integer{ int64_t(state.world.nation_get_demographics(nation_id, demographics::total) * 4) });
286
288
289 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::pop_growth, true);
290 }
291
292};
293
295public:
296 void on_update(sys::state& state) noexcept override {
297 auto n = retrieve<dcon::nation_id>(state, parent);
298
301 auto box = text::open_layout_box(layout, 0);
302
303 auto current_day_record = state.player_data_cache.treasury_record[state.ui_date.value % 32];
304 auto previous_day_record = state.player_data_cache.treasury_record[(state.ui_date.value + 31) % 32];
305 auto change = current_day_record - previous_day_record;
306
308 text::add_to_layout_box(state, layout, box, std::string(" ("));
309 if(change > 0) {
310 text::add_to_layout_box(state, layout, box, std::string("+"), text::text_color::green);
312 } else if(change == 0) {
314 } else {
316 }
317 text::add_to_layout_box(state, layout, box, std::string(")"));
318
319 text::close_layout_box(layout, box);
320 }
321
324 }
325 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
326 /*
327 // SCHOMBERT: A good portion of this is wrong because it is showing maximum values for some of these expense categories
328 // rather than my scaling them to what the actual spending settings are
329
330 auto nation_id = retrieve<dcon::nation_id>(state, parent);
331
332 text::substitution_map sub{};
333
334 auto total_income = economy::estimate_tax_income_by_strata(state, nation_id, culture::pop_strata::poor);
335 total_income += economy::estimate_tax_income_by_strata(state, nation_id, culture::pop_strata::middle);
336 total_income += economy::estimate_tax_income_by_strata(state, nation_id, culture::pop_strata::rich);
337 total_income += economy::estimate_gold_income(state, nation_id);
338
339 auto total_expense = economy::estimate_construction_spending(state, nation_id);
340 total_expense += economy::estimate_land_spending(state, nation_id);
341 total_expense += economy::estimate_naval_spending(state, nation_id);
342 total_expense += economy::estimate_social_spending(state, nation_id);
343 total_expense += economy::estimate_pop_payouts_by_income_type(state, nation_id, culture::income_type::education);
344 total_expense += economy::estimate_pop_payouts_by_income_type(state, nation_id, culture::income_type::administration);
345 total_expense += economy::estimate_pop_payouts_by_income_type(state, nation_id, culture::income_type::military);
346 total_expense += economy::interest_payment(state, nation_id);
347 total_expense += economy::estimate_subsidy_spending(state, nation_id);
348
349 text::add_to_substitution_map(sub, text::variable_type::yesterday,
350 text::fp_one_place{ nations::get_yesterday_income(state, nation_id) });
351 text::add_to_substitution_map(sub, text::variable_type::cash, text::fp_one_place{ nations::get_treasury(state, nation_id) });
352
353 {
354 auto box = text::open_layout_box(contents, 0);
355 text::localised_format_box(state, contents, box, std::string_view("topbar_funds"), sub); // $YESTERDAY && $CASH
356 text::close_layout_box(contents, box);
357 }
358 text::add_line_break_to_layout(state, contents);
359
360 text::add_line(state, contents, std::string_view("budget_total_income"), text::variable_type::val, text::fp_three_places{ total_income }); // $VAL
361 text::add_line(state, contents, std::string_view("taxes_poor"), text::variable_type::val, text::fp_one_place{ economy::estimate_tax_income_by_strata(state, nation_id, culture::pop_strata::poor) }); // $VAL
362 text::add_line(state, contents, std::string_view("taxes_middle"), text::variable_type::val,
363 text::fp_one_place{ economy::estimate_tax_income_by_strata(state, nation_id, culture::pop_strata::middle) }); // $VAL
364 text::add_line(state, contents, std::string_view("taxes_rich"), text::variable_type::val,
365 text::fp_one_place{ economy::estimate_tax_income_by_strata(state, nation_id, culture::pop_strata::rich) }); // $VAL
366 text::add_line(state, contents, std::string_view("tariffs_income"), text::variable_type::val,
367 text::fp_one_place{ economy::estimate_tariff_income(state, nation_id) }); // $VAL
368 text::add_line(state, contents, std::string_view("budget_exports")); // $VAL TODO
369 text::add_line(state, contents, std::string_view("budget_gold"), text::variable_type::val, text::fp_one_place{ economy::estimate_gold_income(state, nation_id) }); // $VAL
370 text::add_line(state, contents, std::string_view("budget_total_expense"), text::variable_type::val,
371 text::fp_three_places{ -total_expense }); // $VAL TODO
372 text::add_line(state, contents, std::string_view("budget_expense_slider_education"),
373 text::variable_type::val,
374 text::fp_three_places{
375 -economy::estimate_pop_payouts_by_income_type(state, nation_id, culture::income_type::education) }); // $VAL
376 text::add_line(state, contents, std::string_view("budget_slider_administration"),
377 text::variable_type::val,
378 text::fp_three_places{
379 -economy::estimate_pop_payouts_by_income_type(state, nation_id, culture::income_type::administration) }); // $VAL
380 text::add_line(state, contents, std::string_view("budget_slider_social_spending"),
381 text::variable_type::val,
382 text::fp_three_places{
383 -economy::estimate_social_spending(state, nation_id) }); // $VAL - presumably loan payments == interest (?)
384 text::add_line(state, contents, std::string_view("budget_slider_military_spending"),
385 text::variable_type::val,
386 text::fp_two_places{
387 -economy::estimate_pop_payouts_by_income_type(state, nation_id, culture::income_type::military) }); // $VAL
388 text::add_line(state, contents, std::string_view("budget_interest"), text::variable_type::val,
389 text::fp_one_place{
390 -economy::interest_payment(state, nation_id) }); // $VAL - presumably loan payments == interest (?)
391 text::add_line(state, contents, std::string_view("budget_imports"), text::variable_type::val,
392 text::fp_one_place{ -economy::nation_total_imports(state,
393 nation_id) }); // $VAL - presumably nation_total_imports is for national stockpile (?)
394
395 text::add_line_break_to_layout(state, contents);
396
397 text::add_line(state, contents, std::string_view("topbar_projected_income"), text::variable_type::val,
398 text::fp_two_places{ economy::estimate_daily_income(state, nation_id) });
399
400 */
401
402 {
404 text::add_to_substitution_map(sub, text::variable_type::x, text::fp_currency{ state.world.nation_get_private_investment(state.local_player_nation) });
405 auto box = text::open_layout_box(contents, 0);
406 text::localised_format_box(state, contents, box, "investment_pool", sub);
407 text::close_layout_box(contents, box);
408 }
409 {
412 auto box = text::open_layout_box(contents, 3);
413 text::localised_format_box(state, contents, box, "investment_pool_income_1", sub);
414 text::close_layout_box(contents, box);
415 }
416 {
417 for(auto n : state.world.in_nation) {
418 auto rel = state.world.nation_get_overlord_as_subject(n);
419 auto overlord = state.world.overlord_get_ruler(rel);
420
421 if(overlord == state.local_player_nation) {
422 auto craved_constructions = economy::estimate_private_investment_construct(state, n, true);
424 auto constructions = economy::estimate_private_investment_construct(state, n, false);
425 auto province_constr = economy::estimate_private_investment_province(state, n);
426
427 if(economy::estimate_private_construction_spendings(state, n) < 1.0f && upgrades.size() == 0 && constructions.size() == 0 && province_constr.size() == 0) {
428 auto amt = state.world.nation_get_private_investment(n) * state.defines.alice_privateinvestment_subject_transfer / 100.f;
429
433 auto box = text::open_layout_box(contents, 3);
434 text::localised_format_box(state, contents, box, "investment_pool_income_2", sub);
435 text::close_layout_box(contents, box);
436 }
437 }
438 }
439 }
440 {
443 auto box = text::open_layout_box(contents, 3);
444 text::localised_format_box(state, contents, box, "investment_pool_spending_1", sub);
445 text::close_layout_box(contents, box);
446 }
447
448 auto private_constr = economy::estimate_private_construction_spendings(state, state.local_player_nation);
449 {
452 auto box = text::open_layout_box(contents, 3);
453 text::localised_format_box(state, contents, box, "investment_pool_spending_2", sub);
454 text::close_layout_box(contents, box);
455 }
456 {
457 auto craved_constructions = economy::estimate_private_investment_construct(state, state.local_player_nation, true);
458 auto upgrades = economy::estimate_private_investment_upgrade(state, state.local_player_nation);
459 auto constructions = economy::estimate_private_investment_construct(state, state.local_player_nation, false);
460 auto province_constr = economy::estimate_private_investment_province(state, state.local_player_nation);
461
462 if(private_constr < 1.f && upgrades.size() == 0 && constructions.size() == 0 && province_constr.size() == 0) {
463 auto rel = state.world.nation_get_overlord_as_subject(state.local_player_nation);
464 auto overlord = state.world.overlord_get_ruler(rel);
465
466 auto amt = state.world.nation_get_private_investment(state.local_player_nation) * state.defines.alice_privateinvestment_subject_transfer / 100.f;
467
468 if(!overlord) {
471 auto box = text::open_layout_box(contents, 3);
472 text::localised_format_box(state, contents, box, "investment_pool_spending_3", sub);
473 text::close_layout_box(contents, box);
474 }
475 }
476 }
477 }
478
479};
480
482public:
485 }
486 void on_create(sys::state& state) noexcept override {
490 }
491
492 void on_update(sys::state& state) noexcept override {
493 auto nation_id = retrieve<dcon::nation_id>(state, parent);
494 auto available = nations::max_national_focuses(state, nation_id);
495 auto in_use = nations::national_focuses_in_use(state, nation_id);
496
497 if(in_use < available) {
498 set_text(state, "?R" + text::format_ratio(in_use, available));
499 } else {
500 set_text(state, text::format_ratio(in_use, available));
501 }
502 }
503
504 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
505 auto nation_id = retrieve<dcon::nation_id>(state, parent);
506 auto box = text::open_layout_box(contents, 0);
508 float relevant_pop = state.world.nation_get_demographics(nation_id,
509 demographics::to_key(state, state.world.nation_get_primary_culture(nation_id)));
510 for(auto ac : state.world.in_culture) {
511 if(state.world.nation_get_accepted_cultures(nation_id, ac)) {
512 relevant_pop += state.world.nation_get_demographics(nation_id, demographics::to_key(state, ac));
513 }
514 }
516 auto fPoints = relevant_pop / state.defines.national_focus_divider; // NOTE: Occasionally inaccurate by a few 0.01, this
517 // doesnt really matter so im leaving it -breizh
519 text::localised_format_box(state, contents, box, std::string_view("tb_nationalfocus_culture"), sub1);
523 text::localised_format_box(state, contents, box, std::string_view("tb_max_focus"), sub2);
524 if(nations::national_focuses_in_use(state, nation_id) > 0) {
526 auto nation_fat_id = dcon::fatten(state.world, nation_id);
527 nation_fat_id.for_each_state_ownership([&](dcon::state_ownership_id so) {
528 auto fat_state_id = dcon::fatten(state.world, so);
529 if(fat_state_id.is_valid()) {
530 auto staat = fat_state_id.get_state();
531 if(staat.is_valid()) {
532 auto natl_fat_id = staat.get_owner_focus();
533 if(natl_fat_id.is_valid()) {
534 text::add_to_layout_box(state, contents, box, natl_fat_id.get_name());
536 }
537 }
538 }
539 });
540 } else {
542 text::localised_format_box(state, contents, box, std::string_view("tb_nationalfocus_none"), text::substitution_map{});
543 }
544 text::close_layout_box(contents, box);
545 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::max_national_focus, false);
546 }
547};
548
550public:
551 void on_create(sys::state& state) noexcept override {
555 }
556
557 void on_update(sys::state& state) noexcept override {
558 auto nation_id = retrieve<dcon::nation_id>(state, parent);
559 auto militancy = state.world.nation_get_demographics(nation_id, demographics::militancy);
560 auto total_pop = state.world.nation_get_demographics(nation_id, demographics::total);
562 }
563
566 }
567
568 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
569 auto nation_id = retrieve<dcon::nation_id>(state, parent);
570 auto box = text::open_layout_box(contents, 0);
572 auto mil_change = demographics::get_estimated_mil_change(state, nation_id);
573 auto total = state.world.nation_get_demographics(nation_id, demographics::total);
575 text::fp_two_places{total != 0.f ? state.world.nation_get_demographics(nation_id, demographics::militancy) / total : 0.f});
577 text::fp_four_places{mil_change});
578 text::localised_format_box(state, contents, box, std::string_view("topbar_avg_mil"), sub);
580 text::localised_format_box(state, contents, box, std::string_view("topbar_avg_change"), sub);
581 text::close_layout_box(contents, box);
582
583 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::global_pop_militancy_modifier, true);
584 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::core_pop_militancy_modifier, true);
585 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::non_accepted_pop_militancy_modifier, true);
586 }
587};
588
590public:
593 }
594
595 void on_create(sys::state& state) noexcept override {
599 }
600
601 void on_update(sys::state& state) noexcept override {
602 auto nation_id = retrieve<dcon::nation_id>(state, parent);
603 auto militancy = state.world.nation_get_demographics(nation_id, demographics::consciousness);
604 auto total_pop = state.world.nation_get_demographics(nation_id, demographics::total);
606 }
607
608 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
609 auto nation_id = retrieve<dcon::nation_id>(state, parent);
610
611 auto box = text::open_layout_box(contents, 0);
613 auto con_change = demographics::get_estimated_con_change(state, nation_id);
614 auto total = state.world.nation_get_demographics(nation_id, demographics::total);
616 text::fp_two_places{ total != 0.f ? (state.world.nation_get_demographics(nation_id, demographics::consciousness) / total) : 0.f });
618 text::localised_format_box(state, contents, box, std::string_view("topbar_avg_con"), sub);
620 text::localised_format_box(state, contents, box, std::string_view("topbar_avg_change"), sub);
621 text::close_layout_box(contents, box);
622
623 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::global_pop_consciousness_modifier, true);
624 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::core_pop_consciousness_modifier, true);
625 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::non_accepted_pop_consciousness_modifier, true);
626 }
627};
628
630public:
631 void on_create(sys::state& state) noexcept override {
635 }
636
637 void on_update(sys::state& state) noexcept override {
638 auto points = nations::diplomatic_points(state, retrieve<dcon::nation_id>(state, parent));
639 set_text(state, text::format_float(points, 1));
640 }
641
644 }
645
646 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
647 auto nation_id = retrieve<dcon::nation_id>(state, parent);
648
649 auto box = text::open_layout_box(contents, 0);
653
654 // Monthly gain
657
658 text::substitution_map sub_base;
659 // Base gain
661 text::fp_one_place{ state.defines.base_monthly_diplopoints });
662
663 text::localised_format_box(state, contents, box, std::string_view("topbar_diplopoints"), sub);
665 text::localised_format_box(state, contents, box, std::string_view("topbar_diplopoints_gain"), sub);
667 text::localised_format_box(state, contents, box, std::string_view("topbar_diplopoints_basegain"), sub_base);
668 text::close_layout_box(contents, box);
669
670 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::diplomatic_points_modifier, false);
671 }
672};
673
675public:
678 }
679
680 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
681 auto nation_id = retrieve<dcon::nation_id>(state, parent);
682 auto box = text::open_layout_box(contents, 0);
684 text::add_to_substitution_map(sub, text::variable_type::curr, state.world.nation_get_active_regiments(nation_id));
685 text::add_to_substitution_map(sub, text::variable_type::max, state.world.nation_get_recruitable_regiments(nation_id));
686 text::localised_format_box(state, contents, box, std::string_view("topbar_army_tooltip"), sub);
687 text::close_layout_box(contents, box);
688 }
689};
690
692public:
695 }
696
697 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
698 auto n = retrieve<dcon::nation_id>(state, parent);
699 {
700 auto box = text::open_layout_box(contents, 0);
702 int32_t num_ships = 0;
703 for(auto nv : state.world.nation_get_navy_control(n)) {
704 num_ships += int32_t(nv.get_navy().get_navy_membership().end() - nv.get_navy().get_navy_membership().begin());
705 }
709 text::localised_format_box(state, contents, box, std::string_view("alice_navy_allocation_tt"), sub);
710 text::close_layout_box(contents, box);
711 }
712 for(const auto nv : state.world.nation_get_navy_control_as_controller(n)) {
713 int32_t total = 0;
714 for(const auto memb : nv.get_navy().get_navy_membership()) {
715 total += state.military_definitions.unit_base_definitions[memb.get_ship().get_type()].supply_consumption_score;
716 }
717 auto box = text::open_layout_box(contents, 0);
719 text::add_to_substitution_map(sub, text::variable_type::name, state.to_string_view(nv.get_navy().get_name()));
722 text::localised_format_box(state, contents, box, std::string_view("alice_navy_allocation_2"), sub);
723 text::close_layout_box(contents, box);
724 }
725 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::supply_range, true);
726 }
727};
728
730public:
733 }
734
735 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
736 auto n = retrieve<dcon::nation_id>(state, parent);
737
738 auto issue_id = politics::get_issue_by_name(state, std::string_view("war_policy"));
739 int32_t possible_sum = 0;
740 int32_t raised_sum = 0;
741 auto fat_id = dcon::fatten(state.world, n);
742 for(auto prov_own : fat_id.get_province_ownership_as_nation()) {
743 auto prov = prov_own.get_province();
745 }
746 for(auto prov_own : fat_id.get_province_ownership_as_nation()) {
747 auto prov = prov_own.get_province();
749 }
750 auto box = text::open_layout_box(contents, 0);
753 // TODO - we (might) want to give the value the current war policy provides, though its more transparent perhaps to
754 // just give the NV + Mob. Impact Modifier?
755 text::add_to_substitution_map(sub2, text::variable_type::impact, text::fp_percentage{ (state.world.nation_get_modifier_values(n, sys::national_mod_offsets::mobilization_impact))});
756 text::add_to_substitution_map(sub2, text::variable_type::policy, fat_id.get_issues(issue_id).get_name());
758 text::localised_single_sub_box(state, contents, box, std::string_view("topbar_mobilize_tooltip"), text::variable_type::curr, possible_sum);
760 text::localised_format_box(state, contents, box, std::string_view("mobilization_impact_limit_desc"), sub2);
762 text::localised_format_box(state, contents, box, std::string_view("mobilization_impact_limit_desc2"), sub2);
763 text::close_layout_box(contents, box);
764
765 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::mobilization_impact, true);
766 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::mobilization_size, true);
767 }
768};
769
771private:
772 float getResearchPointsFromPop(sys::state& state, dcon::pop_type_id pop, dcon::nation_id n) {
773 /*
774 Now imagine that Rock Hudson is standing at the top of the water slide hurling Nintendo consoles down the water slide.
775 If it weren't for the ladders, which allow the water to pass through but not the Nintendo consoles,
776 the Nintendo consoles could hit someone in the wave pool on the head, in which case the water park could get sued.
777 */
778 // auto sum = (fat_pop.get_research_points() * ((state.world.nation_get_demographics(n, demographics::to_key(state,
779 // fat_pop)) / state.world.nation_get_demographics(n, demographics::total)) / fat_pop.get_research_optimum() ));
780 auto sum = ((state.world.nation_get_demographics(n, demographics::to_key(state, pop)) /
781 state.world.nation_get_demographics(n, demographics::total)) /
782 state.world.pop_type_get_research_optimum(state.culture_definitions.officers));
783 return sum;
784 }
785
786public:
789 }
790
791 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
792 auto n = retrieve<dcon::nation_id>(state, parent);
793
794 auto box = text::open_layout_box(contents, 0);
797 state.world.pop_type_get_name(state.culture_definitions.officers));
799 text::fp_two_places{getResearchPointsFromPop(state, state.culture_definitions.officers, n)});
802 state.world.nation_get_demographics(n, demographics::to_key(state, state.culture_definitions.officers)) /
803 state.world.nation_get_demographics(n, demographics::total) });
805 text::fp_two_places{(state.world.pop_type_get_research_optimum(state.culture_definitions.officers) * 100)});
806 text::localised_format_box(state, contents, box, std::string_view("alice_daily_leadership_tt"), sub);
807 text::close_layout_box(contents, box);
808
809 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::leadership, true);
810 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::leadership_modifier, true);
811 }
812};
813
815public:
816 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
817 base_data.size.x = int16_t(ui_width(state));
818 base_data.size.y = int16_t(ui_height(state));
820 //Put it far away!
821 if(base_data.position.x >= 256 || base_data.position.y >= 256) {
822 base_data.position.x = int16_t(8192 * 2);
823 base_data.position.y = int16_t(8192 * 2);
824 }
825 }
826};
827
829public:
830 void button_action(sys::state& state) noexcept override {
831 auto const override_and_show_tab = [&]() {
833 state.ui_state.root->move_child_to_front(topbar_subwindow);
835 };
836
837 if(state.ui_state.topbar_subwindow->is_visible()) {
838 state.ui_state.topbar_subwindow->set_visible(state, false);
839 if(state.ui_state.topbar_subwindow != topbar_subwindow) {
840 override_and_show_tab();
841 }
842 } else {
843 override_and_show_tab();
844 }
845 }
846
847 bool is_active(sys::state& state) noexcept override {
849 }
850
853 }
854 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
855 text::add_line(state, contents, "alice_topbar_tab_1");
856 }
857
859};
860
862public:
865 }
866};
868public:
870 // for now we reuse the budget tab sound
872 }
873};
875public:
878 }
879};
881public:
884 }
885};
887public:
890 }
891};
893public:
896 }
897};
899public:
902 }
903};
905public:
908 }
909};
910
912public:
915 }
916
917 void button_action(sys::state& state) noexcept override {
918 auto const override_and_show_tab = [&]() {
921
922 Cyto::Any payload = pop_list_filter(state.local_player_nation);
924
925 state.ui_state.root->move_child_to_front(topbar_subwindow);
927 };
928
929 if(state.ui_state.topbar_subwindow->is_visible()) {
930 state.ui_state.topbar_subwindow->set_visible(state, false);
931 if(state.ui_state.topbar_subwindow != topbar_subwindow) {
932 override_and_show_tab();
933 }
934 } else {
935 override_and_show_tab();
936 }
937 }
938
941 }
942 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
943 text::add_line(state, contents, "alice_topbar_tab_2");
944 }
945};
946
948public:
949 void on_update(sys::state& state) noexcept override {
951 }
954 }
955 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
956 if(state.network_mode == sys::network_mode_type::host) {
957 for(auto pl : state.network_state.clients) {
958 if(!pl.is_active()) {
959 continue;
960 }
962
963 auto mppl = dcon::fatten(state.world, network::find_country_player(state, pl.playing_as));
964 auto pln = sys::player_name{ mppl.get_nickname() };
965
969
970 auto box = text::open_layout_box(contents);
971 text::localised_format_box(state, contents, box, "alice_player_date_sync", sub);
972 text::close_layout_box(contents, box);
973 }
974 }
975 }
976};
977
979public:
980 void on_create(sys::state& state) noexcept override {
983 }
984
986 if(state.actual_game_speed <= 0) {
988 }
990 }
991
992 void button_action(sys::state& state) noexcept override {
993 if(state.actual_game_speed <= 0) {
994 state.actual_game_speed = state.ui_state.held_game_speed;
995 } else {
996 state.ui_state.held_game_speed = state.actual_game_speed.load();
997 state.actual_game_speed = 0;
998 if(state.network_mode == sys::network_mode_type::host) {
999 command::notify_pause_game(state, state.local_player_nation);
1000 }
1001 }
1002 }
1003
1004 void on_update(sys::state& state) noexcept override {
1005 if(state.network_mode == sys::network_mode_type::client) {
1006 disabled = true;
1007 } else {
1008 disabled = state.internally_paused || state.ui_pause.load(std::memory_order::acquire);
1010 }
1011 }
1012
1015 }
1016
1017 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1018 if(state.network_mode == sys::network_mode_type::client) {
1019 text::add_line(state, contents, "alice_only_host_speed");
1020 } else {
1021 text::add_line(state, contents, "topbar_pause_speed");
1022 }
1023
1024 auto ymd = state.current_date.to_ymd(state.start_date);
1025 if(sys::is_leap_year(ymd.year)) {
1026 text::add_line(state, contents, "date_is_leap");
1027 } else {
1028 text::add_line(state, contents, "date_is_not_leap");
1029 }
1030
1031 float nh_temp = 15.f;
1032 std::string nh_season;
1033 if(ymd.month == 12 || ymd.month <= 2) {
1034 nh_season = text::produce_simple_string(state, "winter");
1035 } else if(ymd.month >= 3 && ymd.month <= 5) {
1036 nh_season = text::produce_simple_string(state, "spring");
1037 } else if(ymd.month >= 6 && ymd.month <= 8) {
1038 nh_season = text::produce_simple_string(state, "summer");
1039 } else if(ymd.month >= 9 && ymd.month <= 11) {
1040 nh_season = text::produce_simple_string(state, "autumn");
1041 }
1042 text::add_line(state, contents, "topbar_date_season_nh", text::variable_type::x, std::string_view(nh_season));
1043
1044 std::string sh_season;
1045 if(ymd.month >= 6 && ymd.month <= 8) {
1046 sh_season = text::produce_simple_string(state, "winter");
1047 } else if(ymd.month >= 9 && ymd.month <= 11) {
1048 sh_season = text::produce_simple_string(state, "spring");
1049 } else if(ymd.month == 12 || ymd.month <= 2) {
1050 sh_season = text::produce_simple_string(state, "summer");
1051 } else if(ymd.month >= 3 && ymd.month <= 5) {
1052 sh_season = text::produce_simple_string(state, "autumn");
1053 }
1054 text::add_line(state, contents, "topbar_date_season_sh", text::variable_type::x, std::string_view(sh_season));
1055
1056 //auto r = ((float(rng::reduce(state.game_seed, 4096)) / 4096.f) * 8.f) - 4.f;
1057 //float avg_temp = (nh_temp + sh_temp + r) / 2.f;
1058 //text::add_line(state, contents, "topbar_date_temperature", text::variable_type::x, text::fp_two_places{ avg_temp }, text::variable_type::y, text::fp_two_places{ (avg_temp * (9.f / 5.f)) + 32.f });
1059 //topbar_date_temperature;Average temperature: §Y$x$°C§! / §Y$y$°F§!
1060 }
1061};
1062
1064public:
1065 void on_create(sys::state& state) noexcept override {
1069 }
1070
1071 void button_action(sys::state& state) noexcept override {
1072 if(state.actual_game_speed > 0) {
1073 state.actual_game_speed = std::min(5, state.actual_game_speed.load() + 1);
1074 } else {
1075 state.ui_state.held_game_speed = std::min(5, state.ui_state.held_game_speed + 1);
1076 }
1077 }
1078
1081 }
1082 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1083 auto box = text::open_layout_box(contents, 0);
1084 if(state.network_mode == sys::network_mode_type::client) {
1085 text::localised_format_box(state, contents, box, std::string_view("alice_only_host_speed"));
1086 } else {
1087 text::localised_format_box(state, contents, box, std::string_view("topbar_inc_speed"));
1088 }
1089 text::close_layout_box(contents, box);
1090 }
1091};
1092
1094public:
1095 void on_create(sys::state& state) noexcept override {
1099 }
1100
1101 void button_action(sys::state& state) noexcept override {
1102 if(state.actual_game_speed > 0) {
1103 state.actual_game_speed = std::max(1, state.actual_game_speed.load() - 1);
1104 } else {
1105 state.ui_state.held_game_speed = std::max(1, state.ui_state.held_game_speed - 1);
1106 }
1107 }
1108
1111 }
1112 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1113 auto box = text::open_layout_box(contents, 0);
1114 if(state.network_mode == sys::network_mode_type::client) {
1115 text::localised_format_box(state, contents, box, std::string_view("alice_only_host_speed"));
1116 } else {
1117 text::localised_format_box(state, contents, box, std::string_view("topbar_dec_speed"));
1118 }
1119 text::close_layout_box(contents, box);
1120 }
1121};
1122
1124public:
1125 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
1126 if(state.network_mode == sys::network_mode_type::single_player || state.network_mode == sys::network_mode_type::host) {
1127 if(state.internally_paused || state.ui_pause.load(std::memory_order::acquire)) {
1128 frame = 0;
1129 } else {
1130 frame = state.actual_game_speed;
1131 }
1132 } else {
1133 frame = state.actual_game_speed;
1134 }
1136 }
1137};
1138
1140public:
1141 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1142 return int32_t(!(nations::is_great_power(state, nation_id) &&
1143 state.world.nation_get_rank(nation_id) > uint16_t(state.defines.great_nations_count)));
1144 }
1145
1148 }
1149
1150 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1151 if(!nations::is_great_power(state, state.local_player_nation)) {
1152 text::add_line(state, contents, "countryalert_no_gpstatus");
1153 } else if(state.world.nation_get_rank(state.local_player_nation) > uint16_t(state.defines.great_nations_count)) {
1154 text::add_line(state, contents, "alice_lose_gp");
1155 auto box = text::open_layout_box(contents);
1157 text::add_to_substitution_map(sub, text::variable_type::x, int32_t(state.defines.great_nations_count));
1158 for(const auto gp : state.great_nations) {
1159 if(gp.nation == state.local_player_nation) {
1160 text::add_to_substitution_map(sub, text::variable_type::date, gp.last_greatness + int32_t(state.defines.greatness_days));
1161 break;
1162 }
1163 }
1164 text::localised_format_box(state, contents, box, "alice_gp_status_regain_expiration", sub);
1165 text::close_layout_box(contents, box);
1166 } else if(state.world.nation_get_rank(state.local_player_nation) <= uint16_t(state.defines.great_nations_count)) {
1167 text::add_line(state, contents, "countryalert_no_loosinggpstatus");
1168 }
1169 }
1170};
1171
1173public:
1174 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
1175 return text::produce_simple_string(state, "atpeace");
1176 }
1177};
1178
1180public:
1181 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1182 return int32_t(!economy::nation_is_constructing_factories(state, nation_id));
1183 }
1184
1187 }
1188
1189 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1190 if(parent) {
1191 Cyto::Any payload = dcon::nation_id{};
1192 parent->impl_get(state, payload);
1193 auto nation_id = any_cast<dcon::nation_id>(payload);
1194
1195 auto box = text::open_layout_box(contents, 0);
1197 text::localised_format_box(state, contents, box, "countryalert_no_isbuildingfactories", text::substitution_map{});
1198 } else if(economy::nation_is_constructing_factories(state, nation_id)) {
1199 text::localised_format_box(state, contents, box, "countryalert_isbuildingfactories", text::substitution_map{});
1200 auto nation_fat_id = dcon::fatten(state.world, nation_id);
1201 nation_fat_id.for_each_state_building_construction([&](dcon::state_building_construction_id building_slim_id) {
1202 auto building_fat_id = dcon::fatten(state.world, building_slim_id);
1203 auto stateName = building_fat_id.get_state().get_definition().get_name();
1204 auto factoryType = building_fat_id.get_type().get_name();
1205
1207 text::add_to_layout_box(state, contents, box, stateName);
1208 text::add_space_to_layout_box(state, contents, box);
1209 text::add_to_layout_box(state, contents, box, factoryType);
1210 });
1211 }
1212 text::close_layout_box(contents, box);
1213 }
1214 }
1215};
1216
1218public:
1219 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1220 return int32_t(!economy::nation_has_closed_factories(state, nation_id));
1221 }
1222
1225 }
1226
1227 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1228 if(parent) {
1229 Cyto::Any payload = dcon::nation_id{};
1230 parent->impl_get(state, payload);
1231 auto nation_id = any_cast<dcon::nation_id>(payload);
1232
1233 auto box = text::open_layout_box(contents, 0);
1235 text::localised_format_box(state, contents, box, "remove_countryalert_no_hasclosedfactories", text::substitution_map{});
1236 } else if(economy::nation_has_closed_factories(state, nation_id)) {
1237 text::localised_format_box(state, contents, box, "remove_countryalert_hasclosedfactories", text::substitution_map{});
1239 auto nation_fat = dcon::fatten(state.world, nation_id);
1240 for(auto staat_owner : nation_fat.get_state_ownership()) {
1241 auto staat = staat_owner.get_state().get_definition();
1242 bool new_staat = true;
1243 for(auto abstract : staat.get_abstract_state_membership()) {
1244 auto prov = abstract.get_province();
1245 for(auto factloc : prov.get_factory_location()) {
1246 auto scale = factloc.get_factory().get_production_scale();
1247 if(scale < 0.05f) {
1248 if(new_staat) {
1249 text::add_to_layout_box(state, contents, box, staat.get_name(), text::text_color::yellow);
1250 // text::add_divider_to_layout_box(state, contents, box); // TODO - Parity needed!
1252 new_staat = false;
1253 }
1254 text::add_to_layout_box(state, contents, box, std::string_view(" - "));
1255 text::add_to_layout_box(state, contents, box, factloc.get_factory().get_building_type().get_name(),
1258 }
1259 }
1260 }
1261 }
1262 }
1263 text::close_layout_box(contents, box);
1264 }
1265 }
1266};
1267
1269public:
1270 bool visible = false;
1271 void on_update(sys::state& state) noexcept override {
1272 visible = (state.world.nation_get_spending_level(state.local_player_nation) < 1.0f);
1273 }
1274 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
1275 if(visible)
1277 }
1280 }
1281
1282 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1283 if(visible) {
1284 text::add_line(state, contents, "topbar_budget_warning");
1285 }
1286 }
1287};
1288
1290public:
1291 void on_update(sys::state& state) noexcept override {
1292 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1293 bool has_unemployed = false;
1294 // Only care about factory workers for displaying the red alert
1295 std::array<dcon::pop_type_id, 2> factory_workers{
1296 state.culture_definitions.primary_factory_worker,
1297 state.culture_definitions.secondary_factory_worker
1298 };
1299 for(auto pt : factory_workers) {
1300 for(auto si : state.world.nation_get_state_ownership(nation_id)) {
1301 auto state_instance = si.get_state();
1302 auto total = state_instance.get_demographics(demographics::to_key(state, pt));
1303 auto unemployed = total - state_instance.get_demographics(demographics::to_employment_key(state, pt));
1304 if(unemployed >= 1.0f) {
1305 has_unemployed = true;
1306 break;
1307 }
1308 }
1309 if(has_unemployed)
1310 break;
1311 }
1312 frame = has_unemployed ? 0 : 1;
1313 }
1314
1317 }
1318
1319 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1320 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1321 bool header = false;
1322 std::array<dcon::pop_type_id, 2> factory_workers{
1323 state.culture_definitions.primary_factory_worker,
1324 state.culture_definitions.secondary_factory_worker
1325 };
1326 for(auto pt : factory_workers) {
1327 for(auto si : state.world.nation_get_state_ownership(nation_id)) {
1328 auto state_instance = si.get_state();
1329 auto total = state_instance.get_demographics(demographics::to_key(state, pt));
1330 auto unemployed = total - state_instance.get_demographics(demographics::to_employment_key(state, pt));
1331 if(unemployed >= 1.f) {
1332 if(!header) {
1333 text::add_line(state, contents, "remove_countryalert_hasunemployedworkers");
1334 header = true;
1335 }
1338 text::add_to_substitution_map(sub, text::variable_type::type, state.world.pop_type_get_name(pt));
1339 auto state_name = text::get_dynamic_state_name(state, state_instance);
1342 auto box = text::open_layout_box(contents);
1343 text::localised_format_box(state, contents, box, "topbar_unemployed", sub);
1344 text::close_layout_box(contents, box);
1345 }
1346 }
1347 }
1348 std::array<dcon::pop_type_id, 2> rgo_workers{
1349 state.culture_definitions.farmers,
1350 state.culture_definitions.laborers
1351 };
1352 for(auto pt : rgo_workers) {
1353 for(auto si : state.world.nation_get_state_ownership(nation_id)) {
1354 auto state_instance = si.get_state();
1355 auto total = state_instance.get_demographics(demographics::to_key(state, pt));
1356 auto unemployed = total - state_instance.get_demographics(demographics::to_employment_key(state, pt));
1357 if(unemployed >= 1.f) {
1358 if(!header) {
1359 text::add_line(state, contents, "alice_rgo_unemployment_country_alert");
1360 header = true;
1361 }
1364 text::add_to_substitution_map(sub, text::variable_type::type, state.world.pop_type_get_name(pt));
1365 auto state_name = text::get_dynamic_state_name(state, state_instance);
1368 auto box = text::open_layout_box(contents);
1369 text::localised_format_box(state, contents, box, "topbar_unemployed", sub);
1370 text::close_layout_box(contents, box);
1371 }
1372 }
1373 }
1374 if(!header) {
1375 text::add_line(state, contents, "countryalert_no_hasunemployedworkers");
1376 }
1377 }
1378};
1379
1381public:
1382 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1383 return int32_t(!nations::has_reform_available(state, nation_id));
1384 }
1385
1388 }
1389
1390 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1391 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1392 auto box = text::open_layout_box(contents, 0);
1393 if(!nations::has_reform_available(state, nation_id)) {
1394 text::localised_format_box(state, contents, box, std::string_view("countryalert_no_candoreforms"),
1396 } else if(nations::has_reform_available(state, nation_id)) {
1397 text::localised_format_box(state, contents, box, std::string_view("countryalert_candoreforms"), text::substitution_map{});
1398 text::add_divider_to_layout_box(state, contents, box);
1399 // Display Avaliable Reforms
1400 // Mostly a copy of nations::has_reform_avaliable
1401 auto last_date = state.world.nation_get_last_issue_or_reform_change(nation_id);
1402 if(bool(last_date) && (last_date + int32_t(state.defines.min_delay_between_reforms * 30.0f)) > state.current_date) {
1403 text::close_layout_box(contents, box);
1404 return;
1405 }
1406 if(state.world.nation_get_is_civilized(nation_id)) {
1407 for(auto i : state.culture_definitions.political_issues) {
1408 for(auto o : state.world.issue_get_options(i)) {
1409 if(o && politics::can_enact_political_reform(state, nation_id, o)) {
1410 auto fat_id = dcon::fatten(state.world, o);
1411 text::add_to_layout_box(state, contents, box, fat_id.get_parent_issue().get_name());
1412 text::add_to_layout_box(state, contents, box, std::string_view(": "));
1413 text::add_to_layout_box(state, contents, box, fat_id.get_name());
1415 }
1416 }
1417 }
1418
1419 for(auto i : state.culture_definitions.social_issues) {
1420 for(auto o : state.world.issue_get_options(i)) {
1421 if(o && politics::can_enact_social_reform(state, nation_id, o)) {
1422 auto fat_id = dcon::fatten(state.world, o);
1423 text::add_to_layout_box(state, contents, box, fat_id.get_parent_issue().get_name());
1424 text::add_to_layout_box(state, contents, box, std::string_view(": "));
1425 text::add_to_layout_box(state, contents, box, fat_id.get_name());
1427 }
1428 }
1429 }
1430
1431 text::close_layout_box(contents, box);
1432 return;
1433 } else {
1434 for(auto i : state.culture_definitions.military_issues) {
1435 for(auto o : state.world.reform_get_options(i)) {
1436 if(o && politics::can_enact_military_reform(state, nation_id, o)) {
1437 auto fat_id = dcon::fatten(state.world, o);
1438 text::add_to_layout_box(state, contents, box, fat_id.get_parent_reform().get_name());
1439 text::add_to_layout_box(state, contents, box, std::string_view(": "));
1440 text::add_to_layout_box(state, contents, box, fat_id.get_name());
1442 }
1443 }
1444 }
1445
1446 for(auto i : state.culture_definitions.economic_issues) {
1447 for(auto o : state.world.reform_get_options(i)) {
1448 if(o && politics::can_enact_economic_reform(state, nation_id, o)) {
1449 auto fat_id = dcon::fatten(state.world, o);
1450 text::add_to_layout_box(state, contents, box, fat_id.get_parent_reform().get_name());
1451 text::add_to_layout_box(state, contents, box, std::string_view(": "));
1452 text::add_to_layout_box(state, contents, box, fat_id.get_name());
1454 }
1455 }
1456 }
1457 }
1458 }
1459 text::close_layout_box(contents, box);
1460 }
1461
1462 void button_action(sys::state& state) noexcept override {
1463 auto const override_and_show_tab = [&]() {
1464 state.ui_state.politics_subwindow->set_visible(state, true);
1466
1467 Cyto::Any defs = Cyto::make_any<politics_window_tab>(politics_window_tab::reforms);
1468 state.ui_state.politics_subwindow->impl_get(state, defs);
1469
1470 state.ui_state.root->move_child_to_front(state.ui_state.politics_subwindow);
1471 state.ui_state.topbar_subwindow = state.ui_state.politics_subwindow;
1472 };
1473
1474 if(state.ui_state.topbar_subwindow->is_visible()) {
1475 state.ui_state.topbar_subwindow->set_visible(state, false);
1476 if(state.ui_state.topbar_subwindow != state.ui_state.politics_subwindow)
1477 override_and_show_tab();
1478 } else {
1479 override_and_show_tab();
1480 }
1481 }
1482
1483};
1484
1486public:
1487 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1488 return int32_t(!nations::has_decision_available(state, nation_id));
1489 }
1490
1493 }
1494
1495 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1496 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1497 if(!nations::has_decision_available(state, nation_id)) {
1498 text::add_line(state, contents, "countryalert_no_candodecisions");
1499 } else {
1500 text::add_line(state, contents, "countryalert_candodecisions");
1501
1503 produce_decision_substitutions(state, m, state.local_player_nation);
1504
1505 state.world.for_each_decision([&](dcon::decision_id di) {
1506 if(nation_id != state.local_player_nation || !state.world.decision_get_hide_notification(di)) {
1507 auto lim = state.world.decision_get_potential(di);
1508 if(!lim || trigger::evaluate(state, lim, trigger::to_generic(nation_id), trigger::to_generic(nation_id), 0)) {
1509 auto allow = state.world.decision_get_allow(di);
1510 if(!allow || trigger::evaluate(state, allow, trigger::to_generic(nation_id), trigger::to_generic(nation_id), 0)) {
1511 auto fat_id = dcon::fatten(state.world, di);
1512 auto box = text::open_layout_box(contents);
1513 text::add_to_layout_box(state, contents, box, fat_id.get_name(), m);
1514 text::close_layout_box(contents, box);
1515 }
1516 }
1517 }
1518 });
1519 }
1520 }
1521
1522 void button_action(sys::state& state) noexcept override {
1523 auto const override_and_show_tab = [&]() {
1524 state.ui_state.politics_subwindow->set_visible(state, true);
1526
1527 Cyto::Any defs = Cyto::make_any<politics_window_tab>(politics_window_tab::decisions);
1528 state.ui_state.politics_subwindow->impl_get(state, defs);
1529
1530 state.ui_state.root->move_child_to_front(state.ui_state.politics_subwindow);
1531 state.ui_state.topbar_subwindow = state.ui_state.politics_subwindow;
1532 };
1533
1534 if(state.ui_state.topbar_subwindow->is_visible()) {
1535 state.ui_state.topbar_subwindow->set_visible(state, false);
1536 if(state.ui_state.topbar_subwindow != state.ui_state.politics_subwindow)
1537 override_and_show_tab();
1538 } else {
1539 override_and_show_tab();
1540 }
1541 }
1542
1543};
1544
1546public:
1547 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1548 return int32_t(!politics::is_election_ongoing(state, nation_id));
1549 }
1550
1552 return tooltip_behavior::variable_tooltip;
1553 }
1554
1555 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1556 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1557 auto box = text::open_layout_box(contents, 0);
1558 if(politics::has_elections(state, nation_id)) {
1559 if(!politics::is_election_ongoing(state, nation_id)) {
1560 text::localised_format_box(state, contents, box, std::string_view("countryalert_no_isinelection"),
1562 } else if(politics::is_election_ongoing(state, nation_id)) {
1564 text::add_to_substitution_map(sub, text::variable_type::date, dcon::fatten(state.world, nation_id).get_election_ends());
1565 text::localised_format_box(state, contents, box, std::string_view("countryalert_isinelection"), sub);
1566 }
1567 } else {
1568 text::localised_format_box(state, contents, box, std::string_view("term_for_life"));
1569 }
1570 text::close_layout_box(contents, box);
1571 }
1572};
1573
1575public:
1576 void on_update(sys::state& state) noexcept override {
1577 for(auto rf : state.world.nation_get_rebellion_within(state.local_player_nation)) {
1578 auto org = rf.get_rebels().get_organization();
1579 if(org >= 0.01f) {
1580 frame = 0;
1581 return;
1582 }
1583 }
1584 frame = 1;
1585 }
1586
1588 return tooltip_behavior::variable_tooltip;
1589 }
1590
1591 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1592 bool showed_title = false;
1593
1594 for(auto rf : state.world.nation_get_rebellion_within(state.local_player_nation)) {
1595 auto org = rf.get_rebels().get_organization();
1596 if(org >= 0.01f) {
1597 if(!showed_title) {
1598 text::add_line(state, contents, "countryalert_haverebels");
1600 showed_title = true;
1601 }
1602 auto rebelname = rebel::rebel_name(state, rf.get_rebels());
1603 auto rebelsize = rf.get_rebels().get_possible_regiments();
1604
1605 text::add_line(state, contents, "topbar_faction",
1606 text::variable_type::name, std::string_view{ rebelname },
1609 }
1610 }
1611 }
1612
1613 void button_action(sys::state& state) noexcept override {
1614 auto const override_and_show_tab = [&]() {
1615 state.ui_state.politics_subwindow->set_visible(state, true);
1617
1618 Cyto::Any defs = Cyto::make_any<politics_window_tab>(politics_window_tab::movements);
1619 state.ui_state.politics_subwindow->impl_get(state, defs);
1620
1621 state.ui_state.root->move_child_to_front(state.ui_state.politics_subwindow);
1622 state.ui_state.topbar_subwindow = state.ui_state.politics_subwindow;
1623 };
1624
1625 if(state.ui_state.topbar_subwindow->is_visible()) {
1626 state.ui_state.topbar_subwindow->set_visible(state, false);
1627 if(state.ui_state.topbar_subwindow != state.ui_state.politics_subwindow)
1628 override_and_show_tab();
1629 } else {
1630 override_and_show_tab();
1631 }
1632 }
1633
1634};
1635
1637 uint32_t index = 0;
1638
1639 dcon::province_id get_state_def_province(sys::state& state, dcon::state_definition_id sdef) noexcept {
1640 for(auto const p : state.world.state_definition_get_abstract_state_membership(sdef)) {
1641 if(!p.get_province().get_nation_from_province_ownership()) {
1642 return p.get_province();
1643 }
1644 }
1645 return dcon::province_id{};
1646 }
1647public:
1648 void button_action(sys::state& state) noexcept override {
1649 std::vector<dcon::province_id> provinces;
1650 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1651 auto nation_fat_id = dcon::fatten(state.world, nation_id);
1652 for(auto si : state.world.nation_get_state_ownership(nation_id)) {
1653 if(province::can_integrate_colony(state, si.get_state())) {
1654 provinces.push_back(si.get_state().get_capital());
1655 }
1656 }
1657
1658 state.world.for_each_state_definition([&](dcon::state_definition_id sdef) {
1659 if(province::can_start_colony(state, nation_id, sdef)) {
1660 dcon::province_id province;
1661 for(auto p : state.world.state_definition_get_abstract_state_membership(sdef)) {
1662 if(!p.get_province().get_nation_from_province_ownership()) {
1663 province = p.get_province().id;
1664 break;
1665 }
1666 }
1667 if(province) {
1668 provinces.push_back(province);
1669 }
1670 }
1671 });
1672
1673 nation_fat_id.for_each_colonization([&](dcon::colonization_id colony) {
1674 auto sdef = state.world.colonization_get_state(colony);
1675 if(state.world.state_definition_get_colonization_stage(sdef) == 3) { //make protectorate
1676 provinces.push_back(get_state_def_province(state, sdef));
1677 } else if(province::can_invest_in_colony(state, nation_id, sdef)) { //invest
1678 provinces.push_back(get_state_def_province(state, sdef));
1679 } else { //losing rase
1680 auto lvl = state.world.colonization_get_level(colony);
1681 for(auto cols : state.world.state_definition_get_colonization(sdef)) {
1682 if(lvl < cols.get_level()) {
1683 provinces.push_back(get_state_def_province(state, sdef));
1684 break;
1685 }
1686 }
1687 }
1688 });
1689 if(!provinces.empty()) {
1690 index++;
1691 if(index >= uint32_t(provinces.size())) {
1692 index = 0;
1693 }
1694 if(auto prov = provinces[index]; prov && prov.value < state.province_definitions.first_sea_province.value) {
1695 sound::play_interface_sound(state, sound::get_click_sound(state), state.user_settings.interface_volume * state.user_settings.master_volume);
1696 state.map_state.set_selected_province(prov);
1697 static_cast<ui::province_view_window*>(state.ui_state.province_window)->set_active_province(state, prov);
1698 if(state.map_state.get_zoom() < map::zoom_very_close)
1699 state.map_state.zoom = map::zoom_very_close;
1700 state.map_state.center_map_on_province(state, prov);
1701 }
1702 }
1703 }
1704
1705 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1706 bool any_integratable = false;
1707 for(auto si : state.world.nation_get_state_ownership(nation_id)) {
1708 if(province::can_integrate_colony(state, si.get_state())) {
1709 any_integratable = true;
1710 break;
1711 }
1712 }
1713 state.world.for_each_state_definition([&](dcon::state_definition_id sdef) {
1714 if(province::can_start_colony(state, nation_id, sdef)) {
1715 any_integratable = true;
1716 }
1717 });
1718 if(nations::can_expand_colony(state, nation_id) || any_integratable) {
1719 return 0;
1720 } else if(nations::is_losing_colonial_race(state, nation_id)) {
1721 return 1;
1722 } else {
1723 return 2;
1724 }
1725 }
1726 // TODO - when the player clicks on the colony icon and there are colonies to expand then we want to teleport their camera to the
1727 // colony's position & open the prov window
1728
1730 return tooltip_behavior::variable_tooltip;
1731 }
1732
1733 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1734 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1735 auto nation_fat_id = dcon::fatten(state.world, nation_id);
1736
1737 bool is_empty = true;
1738
1739 for(auto si : state.world.nation_get_state_ownership(nation_id)) {
1740 if(province::can_integrate_colony(state, si.get_state())) {
1741 text::add_line(state, contents, "countryalert_colonialgood_state", text::variable_type::region, si.get_state().id);
1742 is_empty = false;
1743 }
1744 }
1745
1746 state.world.for_each_state_definition([&](dcon::state_definition_id sdef) {
1747 if(province::can_start_colony(state, nation_id, sdef)) {
1748 text::add_line(state, contents, "alice_countryalert_colonialgood_start", text::variable_type::region, sdef);
1749 is_empty = false;
1750 }
1751 });
1752
1753 nation_fat_id.for_each_colonization([&](dcon::colonization_id colony) {
1754 auto sdef = state.world.colonization_get_state(colony);
1755 if(state.world.state_definition_get_colonization_stage(sdef) == 3) {
1756 text::add_line(state, contents, "countryalert_colonialgood_colony", text::variable_type::region, sdef);
1757 is_empty = false;
1758 } else if(province::can_invest_in_colony(state, nation_id, sdef)) {
1759 text::add_line(state, contents, "countryalert_colonialgood_invest", text::variable_type::region, sdef);
1760 is_empty = false;
1761 }
1762 auto lvl = state.world.colonization_get_level(colony);
1763 for(auto cols : state.world.state_definition_get_colonization(sdef)) {
1764 if(lvl < cols.get_level()) {
1765 text::add_line(state, contents, "countryalert_colonialbad_influence", text::variable_type::region, sdef);
1766 is_empty = false;
1767 }
1768 }
1769 });
1770
1771 if(is_empty) {
1772 text::add_line(state, contents, "countryalert_no_colonial");
1773 }
1774 }
1775};
1776
1778public:
1779 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1780 if(state.current_crisis_state == sys::crisis_state::inactive) {
1781 return 2;
1782 } else if(state.crisis_temperature > 80.f) {
1783 return 1;
1784 } else {
1785 return 0;
1786 }
1787 }
1788
1790 return tooltip_behavior::variable_tooltip;
1791 }
1792
1793 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1799 text::add_to_substitution_map(sub, text::variable_type::time, int32_t(state.defines.crisis_cooldown_months));
1800 if(state.current_crisis_state == sys::crisis_state::inactive) {
1801 auto box = text::open_layout_box(contents);
1802 text::localised_format_box(state, contents, box, std::string_view("alice_crisis_inactive"), sub);
1803 text::close_layout_box(contents, box);
1804 } else if(state.current_crisis_state == sys::crisis_state::finding_attacker) {
1805 auto box = text::open_layout_box(contents);
1806 text::localised_format_box(state, contents, box, std::string_view("alice_crisis_finding_attacker"), sub);
1807 text::close_layout_box(contents, box);
1808 } else if(state.current_crisis_state == sys::crisis_state::finding_defender) {
1809 auto box = text::open_layout_box(contents);
1810 text::localised_format_box(state, contents, box, std::string_view("alice_crisis_finding_defender"), sub);
1811 text::close_layout_box(contents, box);
1812 } else if(state.current_crisis_state == sys::crisis_state::heating_up) {
1813 auto box = text::open_layout_box(contents);
1814 text::localised_format_box(state, contents, box, std::string_view("alice_crisis_heating_up"), sub);
1815 text::close_layout_box(contents, box);
1816 //atackers
1817 text::add_line(state, contents, std::string_view("alice_crisis_par_1"));
1818 for(const auto par : state.crisis_participants) {
1819 if(!par.merely_interested && par.supports_attacker) {
1820 text::add_line(state, contents, text::get_name(state, par.id));
1821 }
1822 }
1823 //defenders
1824 text::add_line(state, contents, std::string_view("alice_crisis_par_2"));
1825 for(const auto par : state.crisis_participants) {
1826 if(!par.merely_interested && !par.supports_attacker) {
1827 text::add_line(state, contents, text::get_name(state, par.id));
1828 }
1829 }
1830 //merely interested
1831 text::add_line(state, contents, std::string_view("alice_crisis_par_3"));
1832 for(const auto par : state.crisis_participants) {
1833 if(par.merely_interested) {
1834 text::add_line(state, contents, text::get_name(state, par.id));
1835 }
1836 }
1837 }
1838 if(state.last_crisis_end_date) {
1839 auto box = text::open_layout_box(contents);
1840 text::localised_format_box(state, contents, box, std::string_view("alice_last_crisis"), sub);
1841 text::close_layout_box(contents, box);
1842 }
1843 }
1844};
1845
1847public:
1848 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1850 return 0;
1851 } else if(rebel::sphere_member_has_ongoing_revolt(state, nation_id)) {
1852 return 2;
1853 } else {
1854 return 1;
1855 }
1856 }
1857
1859 return tooltip_behavior::variable_tooltip;
1860 }
1861
1862 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1863 auto n = retrieve<dcon::nation_id>(state, parent);
1864
1866 text::add_line(state, contents, std::string_view("countryalert_no_gpstatus"));
1867 } else {
1868 bool added_increase_header = false;
1869
1870 for(auto it : state.world.nation_get_gp_relationship_as_great_power(n)) {
1871 if((it.get_status() & nations::influence::is_banned) == 0) {
1872 if(it.get_influence() >= state.defines.increaseopinion_influence_cost
1875
1876 if(!added_increase_header)
1877 text::add_line(state, contents, std::string_view("countryalert_canincreaseopinion"));
1878 added_increase_header = true;
1879 text::nation_name_and_flag(state, it.get_influence_target(), contents, 15);
1880 } else if(!(it.get_influence_target().get_in_sphere_of()) &&
1881 it.get_influence() >= state.defines.addtosphere_influence_cost) {
1882 if(!added_increase_header)
1883 text::add_line(state, contents, std::string_view("countryalert_canincreaseopinion"));
1884 added_increase_header = true;
1885 text::nation_name_and_flag(state, it.get_influence_target(), contents, 15);
1886 } else if(it.get_influence_target().get_in_sphere_of()
1888 it.get_influence() >= state.defines.removefromsphere_influence_cost) {
1889 if(!added_increase_header)
1890 text::add_line(state, contents, std::string_view("countryalert_canincreaseopinion"));
1891 added_increase_header = true;
1892 text::nation_name_and_flag(state, it.get_influence_target(), contents, 15);
1893 }
1894 }
1895 }
1896 bool added_reb_header = false;
1897 for(auto m : state.world.in_nation) {
1898 if(state.world.nation_get_in_sphere_of(m) == n) {
1899 [&]() {
1900 for(auto fac : state.world.nation_get_rebellion_within(m)) {
1901 if(rebel::get_faction_brigades_active(state, fac.get_rebels()) > 0) {
1902 if(!added_reb_header)
1903 text::add_line(state, contents, std::string_view("a_alert_reb"));
1904 added_reb_header = true;
1905 text::nation_name_and_flag(state, m, contents, 15);
1906 return;
1907 }
1908 }
1909 }();
1910 }
1911 }
1912
1913 if(!added_increase_header && !added_reb_header)
1914 text::add_line(state, contents, std::string_view("alice_ca_cant_influence"));
1915 }
1916 }
1917};
1918
1920public:
1922 return tooltip_behavior::variable_tooltip;
1923 }
1924
1925 void on_create(sys::state& state) noexcept override {
1926 top_left_extension = ui::xy_pair{ 25, 3 };
1927 bottom_right_extension = ui::xy_pair{ 0, 2 };
1928 expanded_hitbox_text::on_create(state);
1929 }
1930
1931 void on_update(sys::state& state) noexcept override {
1932 auto points = nations::daily_research_points(state, retrieve<dcon::nation_id>(state, parent));
1933 set_text(state, text::format_float(points, 2));
1934 }
1935
1936 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1937 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1938 auto fat = dcon::fatten(state.world, nation_id);
1939
1940 auto tech_id = nations::current_research(state, nation_id);
1941
1942 auto total_pop = state.world.nation_get_demographics(nation_id, demographics::total);
1943 for(auto pt : state.world.in_pop_type) {
1944 auto rp = state.world.pop_type_get_research_points(pt);
1945 if(rp > 0 && state.world.nation_get_demographics(nation_id, demographics::to_key(state, pt)) > 0.0f) {
1946 auto amount = rp * std::min(1.0f, state.world.nation_get_demographics(nation_id, demographics::to_key(state, pt)) / (total_pop * state.world.pop_type_get_research_optimum(pt)));
1947
1949 text::add_to_substitution_map(sub1, text::variable_type::poptype, state.world.pop_type_get_name(pt));
1952 text::fp_two_places{ (state.world.nation_get_demographics(nation_id, demographics::to_key(state, pt)) / total_pop) * 100 });
1954 text::fp_two_places{ (state.world.pop_type_get_research_optimum(pt) * 100) });
1955
1956 auto box = text::open_layout_box(contents, 0);
1957 text::localised_format_box(state, contents, box, std::string_view("tech_daily_researchpoints_tooltip"), sub1);
1958 text::close_layout_box(contents, box);
1959 }
1960 }
1961 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::research_points, true);
1963
1964 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::research_points_modifier, true);
1966
1967 if(!bool(tech_id)) {
1968 auto box2 = text::open_layout_box(contents, 0);
1969 text::localised_single_sub_box(state, contents, box2, std::string_view("rp_accumulated"), text::variable_type::val,
1970 text::fp_one_place{fat.get_research_points()});
1971
1972 text::close_layout_box(contents, box2);
1973 }
1974 }
1975};
1976
1978public:
1979 uint8_t slot = 0;
1981
1983 return tooltip_behavior::variable_tooltip;
1984 }
1985
1986 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1987
1988 auto box = text::open_layout_box(contents, 0);
1990 state,
1991 contents,
1992 box,
1993 text::produce_simple_string(state, state.world.commodity_get_name(amount.commodity)),
1995 );
1996 text::add_to_layout_box(state, contents, box, std::string_view(":"), text::text_color::white);
1997 text::add_space_to_layout_box(state, contents, box);
1998 text::add_to_layout_box(state, contents, box, text::format_float(amount.volume, 2), text::text_color::white);
1999
2001
2002 for(auto i = 0; i < 5; i++) {
2003 if(amount.targets[i].nation) {
2005 auto ident = state.world.nation_get_identity_from_identity_holder(amount.targets[i].nation);
2006 add_to_layout_box(state, contents, box, text::embedded_flag{ ident ? ident : state.national_definitions.rebel_id });
2007 add_space_to_layout_box(state, contents, box);
2008 add_to_layout_box(state, contents, box, text::get_name(state, amount.targets[i].nation));
2009 text::add_to_layout_box(state, contents, box, std::string_view(":"), text::text_color::white);
2010 text::add_space_to_layout_box(state, contents, box);
2011 text::add_to_layout_box(state, contents, box, text::format_float(amount.targets[i].value, 2), text::text_color::white);
2012 }
2013 }
2014
2015 text::close_layout_box(contents, box);
2016 }
2017};
2018
2020public:
2021 uint8_t slot = 0;
2022 dcon::commodity_id commodity_id{};
2023 float amount{};
2024
2026 return tooltip_behavior::variable_tooltip;
2027 }
2028
2029 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
2030 auto box = text::open_layout_box(contents, 0);
2031 text::add_to_layout_box(state, contents, box,
2032 text::produce_simple_string(state, state.world.commodity_get_name(commodity_id)), text::text_color::white);
2033 text::add_to_layout_box(state, contents, box, std::string_view(":"), text::text_color::white);
2034 text::add_space_to_layout_box(state, contents, box);
2036 text::close_layout_box(contents, box);
2037 }
2038};
2039
2041private:
2042 dcon::nation_id current_nation{};
2043 std::vector<topbar_commodity_xport_icon*> import_icons;
2044 std::vector<topbar_commodity_xport_icon*> export_icons;
2045 std::vector<topbar_commodity_amount_icon*> produced_icons;
2046 simple_text_element_base* atpeacetext = nullptr;
2047
2048 army_management_window* army_mgmt_win = nullptr;
2049
2050public:
2051 void on_create(sys::state& state) noexcept override {
2052 window_element_base::on_create(state);
2053 base_data.position.y += 1;
2054
2055 auto bg_pic = make_element_by_type<background_image>(state, "bg_main_menus");
2056 background_pic = bg_pic.get();
2057 background_pic->base_data.position.y -= 1;
2058 add_child_to_back(std::move(bg_pic));
2059
2060 auto dpi_win = make_element_by_type<ui::diplomatic_message_topbar_listbox>(state, "alice_diplomessageicons_window");
2061 state.ui_state.request_topbar_listbox = dpi_win.get();
2062 add_child_to_front(std::move(dpi_win));
2063
2064 state.ui_state.topbar_window = this;
2065
2066 auto new_win = make_element_by_type<army_management_window>(state,
2067 state.ui_state.defs_by_name.find(state.lookup_key("army_management_window"))->second.definition);
2068 army_mgmt_win = new_win.get();
2069 army_mgmt_win->set_visible(state, false);
2070 add_child_to_front(std::move(new_win));
2071
2072 on_update(state);
2073 }
2074
2075 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
2076 if(name == "topbar_bg") {
2077 return partially_transparent_image::make_element_by_type_alias(state, id);
2078 } else if(name == "topbar_paper") {
2079 return partially_transparent_image::make_element_by_type_alias(state, id);
2080 } else if(name == "topbarbutton_production") {
2081 auto btn = make_element_by_type<topbar_production_tab_button>(state, id);
2082
2083 auto tab = make_element_by_type<production_window>(state, "country_production");
2084 state.ui_state.production_subwindow = state.ui_state.topbar_subwindow = btn->topbar_subwindow = tab.get();
2085 state.ui_state.root->add_child_to_back(std::move(tab));
2086 return btn;
2087 } else if(name == "topbarbutton_budget") {
2088 auto btn = make_element_by_type<topbar_budget_tab_button>(state, id);
2089
2090 //auto tab = make_element_by_type<budget_window>(state, "country_budget");
2092 tab->set_visible(state, false);
2093 btn->topbar_subwindow = tab.get();
2094 state.ui_state.root->add_child_to_back(std::move(tab));
2095 return btn;
2096 } else if(name == "topbarbutton_tech") {
2097 auto btn = make_element_by_type<topbar_technology_tab_button>(state, id);
2098
2099 auto tab = make_element_by_type<technology_window>(state, "country_technology");
2100 btn->topbar_subwindow = tab.get();
2101
2102 state.ui_state.technology_subwindow = tab.get();
2103 state.ui_state.root->add_child_to_back(std::move(tab));
2104 return btn;
2105 } else if(name == "topbarbutton_politics") {
2106 auto btn = make_element_by_type<topbar_politics_tab_button>(state, id);
2107 auto tab = make_element_by_type<politics_window>(state, "country_politics");
2108 btn->topbar_subwindow = tab.get();
2109
2110 state.ui_state.politics_subwindow = tab.get();
2111 state.ui_state.root->add_child_to_back(std::move(tab));
2112 return btn;
2113 } else if(name == "topbarbutton_pops") {
2114 auto btn = make_element_by_type<topbar_population_view_button>(state, id);
2115 auto tab = make_element_by_type<population_window>(state, "country_pop");
2116 btn->topbar_subwindow = tab.get();
2117
2118 state.ui_state.population_subwindow = tab.get();
2119 state.ui_state.root->add_child_to_back(std::move(tab));
2120 return btn;
2121 } else if(name == "topbarbutton_trade") {
2122 auto btn = make_element_by_type<topbar_trade_tab_button>(state, id);
2123
2124 auto tab = make_element_by_type<trade_window>(state, "alice_country_trade");
2125 btn->topbar_subwindow = tab.get();
2126
2127 state.ui_state.trade_subwindow = tab.get();
2128 state.ui_state.root->add_child_to_back(std::move(tab));
2129 return btn;
2130 } else if(name == "topbarbutton_diplomacy") {
2131 auto btn = make_element_by_type<topbar_diplomacy_tab_button>(state, id);
2132
2133 auto tab = make_element_by_type<diplomacy_window>(state, "country_diplomacy");
2134 btn->topbar_subwindow = tab.get();
2135 state.ui_state.root->add_child_to_back(std::move(tab));
2136 return btn;
2137 } else if(name == "topbarbutton_military") {
2138 auto btn = make_element_by_type<topbar_military_tab_button>(state, id);
2139
2140 auto tab = make_element_by_type<military_window>(state, "country_military");
2141 btn->topbar_subwindow = tab.get();
2142 state.ui_state.root->add_child_to_back(std::move(tab));
2143 return btn;
2144 } else if(name == "button_speedup") {
2145 return make_element_by_type<topbar_speedup_button>(state, id);
2146 } else if(name == "button_speeddown") {
2147 return make_element_by_type<topbar_speeddown_button>(state, id);
2148 } else if(name == "pause_bg") {
2149 return make_element_by_type<topbar_pause_button>(state, id);
2150 } else if(name == "speed_indicator") {
2151 return make_element_by_type<topbar_speed_indicator>(state, id);
2152 } else if(name == "datetext") {
2153 return make_element_by_type<topbar_date_text>(state, id);
2154 } else if(name == "countryname") {
2155 return make_element_by_type<topbar_nation_name>(state, id);
2156 } else if(name == "player_flag") {
2157 return make_element_by_type<flag_button>(state, id);
2158 } else if(name == "country_prestige") {
2159 return make_element_by_type<topbar_nation_prestige_text>(state, id);
2160 } else if(name == "country_economic") {
2161 return make_element_by_type<topbar_nation_industry_score_text>(state, id);
2162 } else if(name == "country_military") {
2163 return make_element_by_type<topbar_nation_military_score_text>(state, id);
2164 } else if(name == "country_total") {
2165 return make_element_by_type<nation_total_score_text>(state, id);
2166 } else if(name == "country_colonial_power") {
2167 return make_element_by_type<topbar_nation_colonial_power_text>(state, id);
2168 } else if(name == "selected_prestige_rank") {
2169 return make_element_by_type<nation_prestige_rank_text>(state, id);
2170 } else if(name == "selected_industry_rank") {
2171 return make_element_by_type<nation_industry_rank_text>(state, id);
2172 } else if(name == "selected_military_rank") {
2173 return make_element_by_type<nation_military_rank_text>(state, id);
2174 } else if(name == "nation_totalrank") {
2175 return make_element_by_type<nation_rank_text>(state, id);
2176 } else if(name == "topbar_flag_overlay") {
2177 return make_element_by_type<nation_flag_frame>(state, id);
2178 } else if(name == "alert_building_factories") {
2179 return make_element_by_type<topbar_building_factories_icon>(state, id);
2180 } else if(name == "alert_closed_factories") {
2181 return make_element_by_type<topbar_closed_factories_icon>(state, id);
2182 } else if(name == "alert_unemployed_workers") {
2183 return make_element_by_type<topbar_unemployment_icon>(state, id);
2184 } else if(name == "budget_linechart") {
2185 return make_element_by_type<topbar_budget_line_graph>(state, id);
2186 } else if(name == "alice_budget_warning") {
2187 return make_element_by_type<topbar_budget_warning>(state, id);
2188 } else if(name == "budget_funds") {
2189 return make_element_by_type<topbar_treasury_text>(state, id);
2190 } else if(name == "topbar_tech_progress") {
2191 return make_element_by_type<nation_technology_research_progress>(state, id);
2192 } else if(name == "tech_current_research") {
2193 return make_element_by_type<nation_current_research_text>(state, id);
2194 } else if(name == "topbar_researchpoints_value") {
2195 return make_element_by_type<topbar_nation_daily_research_points_text>(state, id);
2196 } else if(name == "tech_literacy_value") {
2197 return make_element_by_type<topbar_nation_literacy_text>(state, id);
2198 } else if(name == "politics_party_icon") {
2199 return make_element_by_type<nation_ruling_party_ideology_plupp>(state, id);
2200 } else if(name == "politics_ruling_party") {
2201 return make_element_by_type<nation_ruling_party_text>(state, id);
2202 } else if(name == "politics_supressionpoints_value") {
2203 return make_element_by_type<nation_suppression_points_text>(state, id);
2204 } else if(name == "politics_infamy_value") {
2205 return make_element_by_type<topbar_nation_infamy_text>(state, id);
2206 } else if(name == "alert_can_do_reforms") {
2207 return make_element_by_type<topbar_available_reforms_icon>(state, id);
2208 } else if(name == "alert_can_do_decisions") {
2209 return make_element_by_type<topbar_available_decisions_icon>(state, id);
2210 } else if(name == "alert_is_in_election") {
2211 return make_element_by_type<topbar_ongoing_election_icon>(state, id);
2212 } else if(name == "alert_have_rebels") {
2213 return make_element_by_type<topbar_rebels_icon>(state, id);
2214 } else if(name == "population_total_value") {
2215 return make_element_by_type<topbar_nation_population_text>(state, id);
2216 } else if(name == "topbar_focus_value") {
2217 return make_element_by_type<topbar_nation_focus_allocation_text>(state, id);
2218 } else if(name == "population_avg_mil_value") {
2219 return make_element_by_type<topbar_nation_militancy_text>(state, id);
2220 } else if(name == "population_avg_con_value") {
2221 return make_element_by_type<topbar_nation_consciousness_text>(state, id);
2222 } else if(name == "diplomacy_status") {
2223 auto ptr = make_element_by_type<topbar_at_peace_text>(state, id);
2224 atpeacetext = ptr.get();
2225 return ptr;
2226 } else if(name == "diplomacy_at_war") {
2227 auto ptr = make_element_by_type<overlapping_enemy_flags>(state, id);
2228 ptr->base_data.position.y -= ptr->base_data.position.y / 4;
2229 ptr->base_data.size.x /= 2;
2230 return ptr;
2231 } else if(name == "diplomacy_diplopoints_value") {
2232 return make_element_by_type<topbar_nation_diplomatic_points_text>(state, id);
2233 } else if(name == "alert_colony") {
2234 return make_element_by_type<topbar_colony_icon>(state, id);
2235 } else if(name == "alert_crisis") {
2236 return make_element_by_type<topbar_crisis_icon>(state, id);
2237 } else if(name == "alert_can_increase_opinion") {
2238 return make_element_by_type<topbar_sphere_icon>(state, id);
2239 } else if(name == "alert_loosing_gp") {
2240 return make_element_by_type<topbar_losing_gp_status_icon>(state, id);
2241 } else if(name == "military_army_value") {
2242 return make_element_by_type<topbar_nation_brigade_allocation_text>(state, id);
2243 } else if(name == "military_navy_value") {
2244 return make_element_by_type<topbar_nation_navy_allocation_text>(state, id);
2245 } else if(name == "military_manpower_value") {
2246 return make_element_by_type<topbar_nation_mobilization_size_text>(state, id);
2247 } else if(name == "military_leadership_value") {
2248 return make_element_by_type<topbar_nation_leadership_points_text>(state, id);
2249 } else if(name == "topbar_outlinerbutton" || name == "topbar_outlinerbutton_bg") {
2250 // Fake button isn't used - we create it manually instead...
2251 return make_element_by_type<invisible_element>(state, id);
2252 } else if(name.substr(0, 13) == "topbar_import") {
2253 auto ptr = make_element_by_type<topbar_commodity_xport_icon>(state, id);
2254 std::string var = std::string{name.substr(13)};
2255 var.empty() ? ptr->slot = uint8_t(0) : ptr->slot = uint8_t(std::stoi(var));
2256 import_icons.push_back(ptr.get());
2257 return ptr;
2258 } else if(name.substr(0, 13) == "topbar_export") {
2259 auto ptr = make_element_by_type<topbar_commodity_xport_icon>(state, id);
2260 std::string var = std::string{name.substr(13)};
2261 var.empty() ? ptr->slot = uint8_t(0) : ptr->slot = uint8_t(std::stoi(var));
2262 export_icons.push_back(ptr.get());
2263 return ptr;
2264 } else if(name.substr(0, 15) == "topbar_produced") {
2265 auto ptr = make_element_by_type<topbar_commodity_amount_icon>(state, id);
2266 std::string var = std::string{name.substr(15)};
2267 var.empty() ? ptr->slot = uint8_t(0) : ptr->slot = uint8_t(std::stoi(var));
2268 produced_icons.push_back(ptr.get());
2269 return ptr;
2270 } else if (name == "selected_military_icon") {
2271 return make_element_by_type<military_score_icon>(state, id);
2272 } else {
2273 return nullptr;
2274 }
2275 }
2276
2277 void on_update(sys::state& state) noexcept override {
2278 atpeacetext->set_visible(state, !state.world.nation_get_is_at_war(state.local_player_nation));
2279 if(state.local_player_nation != current_nation) {
2280 current_nation = state.local_player_nation;
2281 Cyto::Any payload = current_nation;
2282 impl_set(state, payload);
2283 }
2284
2285 for(auto& e : export_icons)
2286 e->set_visible(state, false);
2287 for(auto& e : import_icons)
2288 e->set_visible(state, false);
2289 for(auto& e : produced_icons)
2290 e->set_visible(state, false);
2291
2292 {
2293 static std::vector<economy::trade_volume_data_detailed> exported;
2294 static std::vector<economy::trade_volume_data_detailed> imported;
2295
2296 exported.clear();
2297 imported.clear();
2298
2299 for(dcon::commodity_id cid : state.world.in_commodity) {
2300 if(sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::military_goods &&
2301 sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::raw_material_goods &&
2302 sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::industrial_goods &&
2303 sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::consumer_goods &&
2304 sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::industrial_and_consumer_goods)
2305 return;
2306 exported.push_back(economy::export_volume_detailed(state, state.local_player_nation, cid));
2307 imported.push_back(economy::import_volume_detailed(state, state.local_player_nation, cid));
2308 }
2309
2310 sys::merge_sort(exported.begin(), exported.end(), [&](auto& a, auto& b) {
2311 return a.volume > b.volume;
2312 });
2313 sys::merge_sort(imported.begin(), imported.end(), [&](auto& a, auto& b) {
2314 return a.volume > b.volume;
2315 });
2316
2317 uint8_t slot = 0;
2318 for(size_t it = 0; it < exported.size(); it++) {
2319 for(auto const& e : export_icons)
2320 if(e->slot == slot) {
2321 e->frame = state.world.commodity_get_icon(exported[it].commodity);
2322 e->amount = exported[it];
2323 e->set_visible(state, true);
2324 }
2325 ++slot;
2326 }
2327 slot = 0;
2328 for(size_t it = 0; it < imported.size(); it++) {
2329 for(auto const& e : import_icons)
2330 if(e->slot == slot) {
2331 e->frame = state.world.commodity_get_icon(imported[it].commodity);
2332 e->amount = imported[it];
2333 e->set_visible(state, true);
2334 }
2335 ++slot;
2336 }
2337 }
2338
2339 {
2340 std::map<float, int32_t> v;
2341 for(dcon::commodity_id cid : state.world.in_commodity) {
2342 if(sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::military_goods &&
2343 sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::raw_material_goods &&
2344 sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::industrial_goods &&
2345 sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::consumer_goods &&
2346 sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::industrial_and_consumer_goods)
2347 return;
2348 v.insert({economy::supply(state, state.local_player_nation, cid) - economy::import_volume(state, state.local_player_nation, cid), cid.index() });
2349 }
2350
2351 uint8_t slot = 0;
2352 for(auto it = std::rbegin(v); it != std::rend(v); it++) {
2353 for(auto const& e : produced_icons)
2354 if(e->slot == slot) {
2355 dcon::commodity_id cid = dcon::commodity_id(dcon::commodity_id::value_base_t(it->second));
2356 e->frame = state.world.commodity_get_icon(cid);
2357 e->commodity_id = cid;
2358 e->amount = it->first;
2359 e->set_visible(state, true);
2360 }
2361 ++slot;
2362 }
2363 }
2364 }
2365
2366 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
2367 if(state.ui_state.topbar_subwindow->is_visible()) {
2368 background_pic->set_visible(state, true);
2369 } else {
2370 background_pic->set_visible(state, false);
2371 }
2372 window_element_base::render(state, x, y);
2373 }
2374
2375 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
2376 if(payload.holds_type<dcon::nation_id>()) {
2377 payload.emplace<dcon::nation_id>(state.local_player_nation);
2378 return message_result::consumed;
2379 } else {
2380 return message_result::unseen;
2381 }
2382 }
2383
2384private:
2385 element_base* background_pic = nullptr;
2386
2387 friend class topbar_tab_button;
2388};
2389
2390} // namespace ui
void render(sys::state &state, int32_t x, int32_t y) noexcept override
Definition: gui_topbar.hpp:816
void on_create(sys::state &state) noexcept override
virtual message_result impl_set(sys::state &state, Cyto::Any &payload) noexcept
element_base * parent
virtual void render(sys::state &state, int32_t x, int32_t y) noexcept
virtual message_result get(sys::state &state, Cyto::Any &payload) noexcept
virtual void impl_on_update(sys::state &state) noexcept
bool is_visible() const
message_result impl_get(sys::state &state, Cyto::Any &payload) noexcept
element_data base_data
void set_visible(sys::state &state, bool vis)
void on_create(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_create(sys::state &state) noexcept override
void set_data_points(sys::state &state, std::vector< float > const &datapoints) noexcept
void set_text(sys::state &state, std::string const &new_text)
std::string get_text(sys::state &state, dcon::nation_id nation_id) noexcept override
void button_action(sys::state &state) noexcept override
int32_t get_icon_frame(sys::state &state, dcon::nation_id nation_id) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
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
int32_t get_icon_frame(sys::state &state, dcon::nation_id nation_id) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
Definition: gui_topbar.hpp:163
void on_update(sys::state &state) noexcept override
Definition: gui_topbar.hpp:168
sound::audio_instance & get_click_sound(sys::state &state) noexcept override
Definition: gui_topbar.hpp:863
void render(sys::state &state, int32_t x, int32_t y) 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
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
int32_t get_icon_frame(sys::state &state, dcon::nation_id nation_id) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
int32_t get_icon_frame(sys::state &state, dcon::nation_id nation_id) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
int32_t get_icon_frame(sys::state &state, dcon::nation_id nation_id) noexcept override
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 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
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
int32_t get_icon_frame(sys::state &state, dcon::nation_id nation_id) noexcept override
void on_update(sys::state &state) noexcept override
Definition: gui_topbar.hpp:949
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:955
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:952
sound::audio_instance & get_click_sound(sys::state &state) noexcept override
Definition: gui_topbar.hpp:882
tooltip_behavior has_tooltip(sys::state &state) noexcept override
int32_t get_icon_frame(sys::state &state, dcon::nation_id nation_id) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
sound::audio_instance & get_click_sound(sys::state &state) noexcept override
Definition: gui_topbar.hpp:888
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:680
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:676
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:126
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:122
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:591
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:608
void on_update(sys::state &state) noexcept override
Definition: gui_topbar.hpp:601
void on_create(sys::state &state) noexcept override
Definition: gui_topbar.hpp:595
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:646
void on_update(sys::state &state) noexcept override
Definition: gui_topbar.hpp:637
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:642
void on_create(sys::state &state) noexcept override
Definition: gui_topbar.hpp:631
void on_create(sys::state &state) noexcept override
Definition: gui_topbar.hpp:486
void on_update(sys::state &state) noexcept override
Definition: gui_topbar.hpp:492
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:504
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:483
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:90
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:94
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:228
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:224
void on_create(sys::state &state) noexcept override
Definition: gui_topbar.hpp:216
void on_update(sys::state &state) noexcept override
Definition: gui_topbar.hpp:221
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:791
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:787
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:193
void on_create(sys::state &state) noexcept override
Definition: gui_topbar.hpp:180
void on_update(sys::state &state) noexcept override
Definition: gui_topbar.hpp:186
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:197
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:568
void on_create(sys::state &state) noexcept override
Definition: gui_topbar.hpp:551
void on_update(sys::state &state) noexcept override
Definition: gui_topbar.hpp:557
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:564
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:106
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:110
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:731
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:735
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:33
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:29
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:693
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:697
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:272
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:275
void on_update(sys::state &state) noexcept override
Definition: gui_topbar.hpp:247
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:49
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:53
void on_update(sys::state &state) noexcept override
Definition: gui_topbar.hpp:46
tooltip_behavior has_tooltip(sys::state &state) noexcept override
int32_t get_icon_frame(sys::state &state, dcon::nation_id nation_id) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
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
Definition: gui_topbar.hpp:992
void on_create(sys::state &state) noexcept override
Definition: gui_topbar.hpp:980
void on_update(sys::state &state) noexcept override
sound::audio_instance & get_click_sound(sys::state &state) noexcept override
Definition: gui_topbar.hpp:985
sound::audio_instance & get_click_sound(sys::state &state) noexcept override
Definition: gui_topbar.hpp:876
sound::audio_instance & get_click_sound(sys::state &state) noexcept override
Definition: gui_topbar.hpp:894
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:939
sound::audio_instance & get_click_sound(sys::state &state) noexcept override
Definition: gui_topbar.hpp:913
void button_action(sys::state &state) noexcept override
Definition: gui_topbar.hpp:917
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:942
sound::audio_instance & get_click_sound(sys::state &state) noexcept override
Definition: gui_topbar.hpp:900
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 update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void 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
void button_action(sys::state &state) 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
void button_action(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
int32_t get_icon_frame(sys::state &state, dcon::nation_id nation_id) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:854
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:851
void button_action(sys::state &state) noexcept override
Definition: gui_topbar.hpp:830
element_base * topbar_subwindow
Definition: gui_topbar.hpp:858
bool is_active(sys::state &state) noexcept override
Definition: gui_topbar.hpp:847
sound::audio_instance & get_click_sound(sys::state &state) noexcept override
Definition: gui_topbar.hpp:906
sound::audio_instance & get_click_sound(sys::state &state) noexcept override
Definition: gui_topbar.hpp:869
void on_update(sys::state &state) noexcept override
Definition: gui_topbar.hpp:296
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:325
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:322
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_create(sys::state &state) noexcept override
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::unique_ptr< ui::element_base > make_budgetwindow_main(sys::state &state)
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
float get_estimated_literacy_change(sys::state &state, dcon::pop_id ids)
constexpr dcon::demographics_key total(0)
dcon::demographics_key to_key(sys::state const &state, dcon::pop_type_id v)
float get_estimated_mil_change(sys::state &state, dcon::pop_id ids)
constexpr dcon::demographics_key consciousness(3)
float get_estimated_con_change(sys::state &state, dcon::pop_id ids)
dcon::demographics_key to_employment_key(sys::state const &state, dcon::pop_type_id v)
constexpr dcon::demographics_key literacy(5)
constexpr dcon::demographics_key militancy(4)
std::vector< full_construction_state > estimate_private_investment_upgrade(sys::state &state, dcon::nation_id nid)
Definition: economy.cpp:4943
float supply(sys::state &state, dcon::market_id s, dcon::commodity_id c)
Definition: economy.cpp:206
trade_volume_data_detailed import_volume_detailed(sys::state &state, dcon::nation_id s, dcon::commodity_id c)
Definition: economy.cpp:599
trade_volume_data_detailed export_volume_detailed(sys::state &state, dcon::nation_id s, dcon::commodity_id c)
Definition: economy.cpp:492
float estimate_private_construction_spendings(sys::state &state, dcon::nation_id nid)
Definition: economy.cpp:3701
float estimate_investment_pool_daily_loss(sys::state &state, dcon::nation_id n)
Definition: economy.cpp:8970
float import_volume(sys::state &state, dcon::market_id s, dcon::commodity_id c)
Definition: economy.cpp:578
bool nation_is_constructing_factories(sys::state &state, dcon::nation_id n)
Definition: economy.cpp:1186
std::vector< full_construction_state > estimate_private_investment_construct(sys::state &state, dcon::nation_id nid, bool craved)
Definition: economy.cpp:5051
bool nation_has_closed_factories(sys::state &state, dcon::nation_id n)
Definition: economy.cpp:1190
std::vector< full_construction_province > estimate_private_investment_province(sys::state &state, dcon::nation_id nid)
Definition: economy.cpp:5205
constexpr float zoom_very_close
Definition: constants.hpp:606
int32_t naval_supply_points_used(sys::state &state, dcon::nation_id n)
Definition: military.cpp:1252
int32_t mobilized_regiments_created_from_province(sys::state &state, dcon::province_id p)
Definition: military.cpp:833
int32_t mobilized_regiments_possible_from_province(sys::state &state, dcon::province_id p)
Definition: military.cpp:1137
int32_t naval_supply_points(sys::state &state, dcon::nation_id n)
Definition: military.cpp:1249
constexpr uint8_t is_banned
Definition: nations.hpp:183
constexpr uint8_t level_friendly
Definition: nations.hpp:172
constexpr uint8_t level_in_sphere
Definition: nations.hpp:173
constexpr uint8_t level_mask
Definition: nations.hpp:167
float colonial_points_from_naval_bases(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1239
status get_status(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1145
bool is_great_power(sys::state const &state, dcon::nation_id id)
Definition: nations.cpp:1068
int32_t free_colonial_points(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1304
bool is_losing_colonial_race(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1339
float used_colonial_points(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1282
bool can_expand_colony(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1324
float diplomatic_points(sys::state const &state, dcon::nation_id n)
Definition: nations.cpp:1210
float prestige_score(sys::state const &state, dcon::nation_id n)
Definition: nations.cpp:961
float colonial_points_from_technology(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1273
float monthly_diplomatic_points(sys::state const &state, dcon::nation_id n)
Definition: nations.cpp:1214
float daily_research_points(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:741
bool has_decision_available(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1441
int64_t get_monthly_pop_increase_of_nation(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:56
bool sphereing_progress_is_possible(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1350
int32_t national_focuses_in_use(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1199
bool has_reform_available(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1394
dcon::technology_id current_research(sys::state const &state, dcon::nation_id n)
Definition: nations.cpp:1171
int32_t max_national_focuses(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1183
float get_treasury(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1607
float colonial_points_from_ships(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1220
dcon::mp_player_id find_country_player(sys::state &state, dcon::nation_id nation)
Definition: network.cpp:702
bool can_enact_social_reform(sys::state &state, dcon::nation_id n, dcon::issue_option_id o)
Definition: politics.cpp:181
bool can_enact_political_reform(sys::state &state, dcon::nation_id nation, dcon::issue_option_id issue_option)
Definition: politics.cpp:107
dcon::issue_id get_issue_by_name(sys::state &state, std::string_view name)
Definition: politics.cpp:83
bool can_enact_military_reform(sys::state &state, dcon::nation_id n, dcon::reform_option_id o)
Definition: politics.cpp:253
bool has_elections(sys::state &state, dcon::nation_id nation)
Definition: politics.cpp:60
bool is_election_ongoing(sys::state &state, dcon::nation_id nation)
Definition: politics.cpp:55
bool can_enact_economic_reform(sys::state &state, dcon::nation_id n, dcon::reform_option_id o)
Definition: politics.cpp:273
bool can_integrate_colony(sys::state &state, dcon::state_instance_id id)
Definition: province.cpp:643
bool can_start_colony(sys::state &state, dcon::nation_id n, dcon::state_definition_id d)
Definition: province.cpp:1255
bool can_invest_in_colony(sys::state &state, dcon::nation_id n, dcon::state_definition_id d)
Definition: province.cpp:1179
int32_t get_faction_brigades_active(sys::state &state, dcon::rebel_faction_id r)
Definition: rebels.cpp:1018
bool sphere_member_has_ongoing_revolt(sys::state &state, dcon::nation_id n)
Definition: rebels.cpp:1000
std::string rebel_name(sys::state &state, dcon::rebel_faction_id reb)
Definition: rebels.cpp:1276
audio_instance & get_tab_population_sound(sys::state &state)
Definition: sound_nix.cpp:302
audio_instance & get_tab_production_sound(sys::state &state)
Definition: sound_nix.cpp:305
audio_instance & get_tab_budget_sound(sys::state &state)
Definition: sound_nix.cpp:272
audio_instance & get_tab_technology_sound(sys::state &state)
Definition: sound_nix.cpp:308
audio_instance & get_unpause_sound(sys::state &state)
Definition: sound_nix.cpp:393
audio_instance & get_tab_politics_sound(sys::state &state)
Definition: sound_nix.cpp:293
audio_instance & get_pause_sound(sys::state &state)
Definition: sound_nix.cpp:390
void play_interface_sound(sys::state &state, audio_instance &s, float volume)
Definition: sound_nix.cpp:203
audio_instance & get_tab_diplomacy_sound(sys::state &state)
Definition: sound_nix.cpp:296
audio_instance & get_click_sound(sys::state &state)
Definition: sound_nix.cpp:263
audio_instance & get_tab_military_sound(sys::state &state)
Definition: sound_nix.cpp:299
bool is_leap_year(int32_t year)
commodity_group
Definition: constants.hpp:223
void merge_sort(IT first, IT end, CMP const &cmp) noexcept
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:1823
std::string date_to_string(sys::state &state, sys::date date)
Definition: text.cpp:1082
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
endless_layout create_endless_layout(sys::state &state, layout &dest, layout_parameters const &params)
Definition: text.cpp:1100
std::string format_float(float num, size_t digits)
Definition: text.cpp:981
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
Definition: text.cpp:1923
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
std::string get_dynamic_state_name(sys::state &state, dcon::state_instance_id state_id)
Definition: text.cpp:837
ankerl::unordered_dense::map< uint32_t, substitution > substitution_map
Definition: text.hpp:797
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
Definition: text.cpp:617
text_color
Definition: text.hpp:18
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:1812
void nation_name_and_flag(sys::state &state, dcon::nation_id n, layout_base &dest, int32_t indent)
Definition: text.cpp:2128
std::string prettify_currency(float num)
Definition: text.cpp:702
void close_layout_box(columnar_layout &dest, layout_box &box)
Definition: text.cpp:1831
int32_t ui_height(sys::state const &state)
int32_t ui_width(sys::state const &state)
tooltip_behavior
void produce_decision_substitutions(sys::state &state, text::substitution_map &m, dcon::nation_id n)
std::variant< std::monostate, dcon::nation_id, dcon::state_instance_id, dcon::province_id > pop_list_filter
message_result
bool events_pause_test(sys::state &state)
Definition: gui_event.cpp:1163
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
@ ident
Holds important data about the game world, state, and other data regarding windowing,...
sys::virtual_key shortcut
union ui::element_data::internal_data data
element_base * technology_subwindow
element_base * trade_subwindow
element_base * topbar_window
float last_tick_investment_pool_change
element_base * topbar_subwindow
ankerl::unordered_dense::map< dcon::text_key, element_target, hash_text_key > defs_by_name
std::unique_ptr< element_base > root
element_base * request_topbar_listbox
int32_t held_game_speed
element_base * population_subwindow
element_base * politics_subwindow
element_base * production_subwindow