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
23namespace ui {
24
25class topbar_nation_name : public generic_name_text<dcon::nation_id> {
26public:
29 }
30
31 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
32 if(state.cheat_data.show_province_id_tooltip) {
33 auto box = text::open_layout_box(contents);
34 text::add_to_layout_box(state, contents, box, std::string_view("Nation ID:"));
36 text::add_to_layout_box(state, contents, box, std::to_string(state.local_player_nation.value));
37 text::close_layout_box(contents, box);
38 }
39 }
40};
41
43public:
44 void on_update(sys::state& state) noexcept override {
45 set_text(state, std::to_string(int32_t(nations::prestige_score(state, retrieve<dcon::nation_id>(state, parent)))));
46 }
49 }
50
51 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
52 auto nation_id = retrieve<dcon::nation_id>(state, parent);
53 auto box = text::open_layout_box(contents, 0);
54 text::localised_format_box(state, contents, box, std::string_view("rank_prestige"), text::substitution_map{});
56 switch(nations::get_status(state, nation_id)) {
58 text::localised_format_box(state, contents, box, std::string_view("diplomacy_greatnation_status"), text::substitution_map{});
59 break;
61 text::localised_format_box(state, contents, box, std::string_view("diplomacy_colonialnation_status"), text::substitution_map{});
62 break;
64 text::localised_format_box(state, contents, box, std::string_view("diplomacy_civilizednation_status"), text::substitution_map{});
65 break;
67 text::localised_format_box(state, contents, box, std::string_view("diplomacy_almost_western_nation_status"), text::substitution_map{});
68 break;
70 text::localised_format_box(state, contents, box, std::string_view("diplomacy_uncivilizednation_status"), text::substitution_map{});
71 break;
73 text::localised_format_box(state, contents, box, std::string_view("diplomacy_primitivenation_status"), text::substitution_map{});
74 break;
75 default:
76 break;
77 };
78 text::close_layout_box(contents, box);
80 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::prestige, true);
82 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::permanent_prestige, true);
83 }
84};
85
87public:
90 }
91
92 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
93 auto nation_id = retrieve<dcon::nation_id>(state, parent);
94 auto box = text::open_layout_box(contents, 0);
95 text::localised_format_box(state, contents, box, std::string_view("rank_industry"), text::substitution_map{});
97 text::localised_format_box(state, contents, box, std::string_view("rank_industry_d"), text::substitution_map{});
98 text::close_layout_box(contents, box);
99 }
100};
101
103public:
106 }
107
108 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
109 auto nation_id = retrieve<dcon::nation_id>(state, parent);
110 auto box = text::open_layout_box(contents, 0);
111 text::localised_format_box(state, contents, box, std::string_view("rank_military"), text::substitution_map{});
113 text::localised_format_box(state, contents, box, std::string_view("rank_military_d"), text::substitution_map{});
114 text::close_layout_box(contents, box);
115 }
116};
117
119public:
122 }
123
124 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
125 auto nation_id = retrieve<dcon::nation_id>(state, parent);
126
128 std::string value;
130 text::add_to_substitution_map(sub, text::variable_type::value, std::string_view(value));
131 auto box = text::open_layout_box(contents, 0);
132 text::localised_format_box(state, contents, box, std::string_view("colonial_points"), sub);
134 text::localised_format_box(state, contents, box, std::string_view("explain_colonial_points"), sub);
136 text::localised_format_box(state, contents, box, std::string_view("available_colonial_power"), sub);
138 text::localised_format_box(state, contents, box, std::string_view("colonial_points_from_technology"), sub);
139 text::add_space_to_layout_box(state, contents, box);
142 text::localised_format_box(state, contents, box, std::string_view("colonial_points_from_naval_bases"), sub);
143 text::add_space_to_layout_box(state, contents, box);
146 text::localised_format_box(state, contents, box, std::string_view("colonial_points_from_ships"), sub);
147 text::add_space_to_layout_box(state, contents, box);
150 text::localised_format_box(state, contents, box, std::string_view("used_colonial_maintenance"), sub);
151 text::add_space_to_layout_box(state, contents, box);
153 text::close_layout_box(contents, box);
154 }
155};
156
158public:
160
161 void on_create(sys::state& state) noexcept override {
164 }
165
166 void on_update(sys::state& state) noexcept override {
167 std::vector<float> datapoints(size_t(32));
168 for(size_t i = 0; i < state.player_data_cache.treasury_record.size(); ++i)
169 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];
170 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];
171 datapoints[0] = datapoints[1]; // otherwise you will store the difference between two non-consecutive days here
172 set_data_points(state, datapoints);
173 }
174};
175
177public:
178 void on_create(sys::state& state) noexcept override {
182 }
183
184 void on_update(sys::state& state) noexcept override {
185 auto n = retrieve<dcon::nation_id>(state, parent);
186 auto literacy = state.world.nation_get_demographics(n, demographics::literacy);
187 auto total_pop = std::max(1.0f, state.world.nation_get_demographics(n, demographics::total));
189 }
190
193 }
194
195 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
196 auto nation_id = retrieve<dcon::nation_id>(state, parent);
197
198 auto box = text::open_layout_box(contents, 0);
200 auto literacy_change = demographics::get_estimated_literacy_change(state, nation_id);
202 auto total = state.world.nation_get_demographics(nation_id, demographics::total);
203 auto avg_literacy = text::format_percentage(total != 0.f ? (state.world.nation_get_demographics(nation_id, demographics::literacy) / total) : 0.f, 1);
204 text::add_to_substitution_map(sub, text::variable_type::avg, std::string_view(avg_literacy));
205 text::localised_format_box(state, contents, box, std::string_view("topbar_avg_literacy"), sub);
207 text::localised_format_box(state, contents, box, std::string_view("topbar_avg_change"), sub);
208 text::close_layout_box(contents, box);
209 }
210};
211
213public:
214 void on_create(sys::state& state) noexcept override {
218 }
219 void on_update(sys::state& state) noexcept override {
220 set_text(state, text::format_float(state.world.nation_get_infamy(retrieve<dcon::nation_id>(state, parent)), 2));
221 }
224 }
225
226 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
227 auto nation_id = retrieve<dcon::nation_id>(state, parent);
228 auto box = text::open_layout_box(contents, 0);
229 auto fat_id = dcon::fatten(state.world, nation_id);
230 text::localised_format_box(state, contents, box, "infamy");
231 text::add_to_layout_box(state, contents, box, std::string_view(":"));
232 text::add_space_to_layout_box(state, contents, box);
233 text::add_to_layout_box(state, contents, box, text::fp_two_places{fat_id.get_infamy()});
234 text::add_to_layout_box(state, contents, box, std::string_view("/"));
235 text::add_to_layout_box(state, contents, box, text::fp_two_places{state.defines.badboy_limit});
237 text::localised_format_box(state, contents, box, "badboy_dro_1");
238 text::close_layout_box(contents, box);
239 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::badboy, false);
240 }
241};
242
244public:
245 void on_update(sys::state& state) noexcept override {
246 auto n = retrieve<dcon::nation_id>(state, parent);
247 auto total_pop = state.world.nation_get_demographics(n, demographics::total);
248
249 auto pop_amount = state.player_data_cache.population_record[state.ui_date.value % 32];
250 auto pop_change = state.ui_date.value <= 32
251 ? (state.ui_date.value <= 2 ? 0.0f : pop_amount - state.player_data_cache.population_record[2])
252 : (pop_amount - state.player_data_cache.population_record[(state.ui_date.value - 30) % 32]);
253
255 if(pop_change == 0)
257
260 auto box = text::open_layout_box(layout, 0);
261 text::add_to_layout_box(state, layout, box, text::prettify(int32_t(total_pop)));
262 text::add_to_layout_box(state, layout, box, std::string(" ("));
263 if(pop_change > 0) {
264 text::add_to_layout_box(state, layout, box, std::string("+"), text::text_color::green);
265 }
266 text::add_to_layout_box(state, layout, box, text::pretty_integer{int64_t(pop_change)}, color);
267 text::add_to_layout_box(state, layout, box, std::string(")"));
268 text::close_layout_box(layout, box);
269 }
272 }
273 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
274
275 auto nation_id = retrieve<dcon::nation_id>(state, parent);
276
277 auto pop_amount = state.player_data_cache.population_record[state.ui_date.value % 32];
278 auto pop_change = state.ui_date.value <= 30 ? 0.0f : (pop_amount - state.player_data_cache.population_record[(state.ui_date.value - 30) % 32]);
279
280 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)) });
281 text::add_line(state, contents, "pop_growth_topbar_2", text::variable_type::x, text::pretty_integer{ int64_t(pop_change) });
283 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) });
284
286
287 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::pop_growth, true);
288 }
289
290};
291
293public:
294 void on_update(sys::state& state) noexcept override {
295 auto n = retrieve<dcon::nation_id>(state, parent);
296
299 auto box = text::open_layout_box(layout, 0);
300
301 auto current_day_record = state.player_data_cache.treasury_record[state.ui_date.value % 32];
302 auto previous_day_record = state.player_data_cache.treasury_record[(state.ui_date.value + 31) % 32];
303 auto change = current_day_record - previous_day_record;
304
306 text::add_to_layout_box(state, layout, box, std::string(" ("));
307 if(change > 0) {
308 text::add_to_layout_box(state, layout, box, std::string("+"), text::text_color::green);
310 } else if(change == 0) {
312 } else {
314 }
315 text::add_to_layout_box(state, layout, box, std::string(")"));
316
317 text::close_layout_box(layout, box);
318 }
319
322 }
323 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
324 /*
325 // SCHOMBERT: A good portion of this is wrong because it is showing maximum values for some of these expense categories
326 // rather than my scaling them to what the actual spending settings are
327
328 auto nation_id = retrieve<dcon::nation_id>(state, parent);
329
330 text::substitution_map sub{};
331
332 auto total_income = economy::estimate_tax_income_by_strata(state, nation_id, culture::pop_strata::poor);
333 total_income += economy::estimate_tax_income_by_strata(state, nation_id, culture::pop_strata::middle);
334 total_income += economy::estimate_tax_income_by_strata(state, nation_id, culture::pop_strata::rich);
335 total_income += economy::estimate_gold_income(state, nation_id);
336
337 auto total_expense = economy::estimate_construction_spending(state, nation_id);
338 total_expense += economy::estimate_land_spending(state, nation_id);
339 total_expense += economy::estimate_naval_spending(state, nation_id);
340 total_expense += economy::estimate_social_spending(state, nation_id);
341 total_expense += economy::estimate_pop_payouts_by_income_type(state, nation_id, culture::income_type::education);
342 total_expense += economy::estimate_pop_payouts_by_income_type(state, nation_id, culture::income_type::administration);
343 total_expense += economy::estimate_pop_payouts_by_income_type(state, nation_id, culture::income_type::military);
344 total_expense += economy::interest_payment(state, nation_id);
345 total_expense += economy::estimate_subsidy_spending(state, nation_id);
346
347 text::add_to_substitution_map(sub, text::variable_type::yesterday,
348 text::fp_one_place{ nations::get_yesterday_income(state, nation_id) });
349 text::add_to_substitution_map(sub, text::variable_type::cash, text::fp_one_place{ nations::get_treasury(state, nation_id) });
350
351 {
352 auto box = text::open_layout_box(contents, 0);
353 text::localised_format_box(state, contents, box, std::string_view("topbar_funds"), sub); // $YESTERDAY && $CASH
354 text::close_layout_box(contents, box);
355 }
356 text::add_line_break_to_layout(state, contents);
357
358 text::add_line(state, contents, std::string_view("budget_total_income"), text::variable_type::val, text::fp_three_places{ total_income }); // $VAL
359 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
360 text::add_line(state, contents, std::string_view("taxes_middle"), text::variable_type::val,
361 text::fp_one_place{ economy::estimate_tax_income_by_strata(state, nation_id, culture::pop_strata::middle) }); // $VAL
362 text::add_line(state, contents, std::string_view("taxes_rich"), text::variable_type::val,
363 text::fp_one_place{ economy::estimate_tax_income_by_strata(state, nation_id, culture::pop_strata::rich) }); // $VAL
364 text::add_line(state, contents, std::string_view("tariffs_income"), text::variable_type::val,
365 text::fp_one_place{ economy::estimate_tariff_income(state, nation_id) }); // $VAL
366 text::add_line(state, contents, std::string_view("budget_exports")); // $VAL TODO
367 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
368 text::add_line(state, contents, std::string_view("budget_total_expense"), text::variable_type::val,
369 text::fp_three_places{ -total_expense }); // $VAL TODO
370 text::add_line(state, contents, std::string_view("budget_expense_slider_education"),
371 text::variable_type::val,
372 text::fp_three_places{
373 -economy::estimate_pop_payouts_by_income_type(state, nation_id, culture::income_type::education) }); // $VAL
374 text::add_line(state, contents, std::string_view("budget_slider_administration"),
375 text::variable_type::val,
376 text::fp_three_places{
377 -economy::estimate_pop_payouts_by_income_type(state, nation_id, culture::income_type::administration) }); // $VAL
378 text::add_line(state, contents, std::string_view("budget_slider_social_spending"),
379 text::variable_type::val,
380 text::fp_three_places{
381 -economy::estimate_social_spending(state, nation_id) }); // $VAL - presumably loan payments == interest (?)
382 text::add_line(state, contents, std::string_view("budget_slider_military_spending"),
383 text::variable_type::val,
384 text::fp_two_places{
385 -economy::estimate_pop_payouts_by_income_type(state, nation_id, culture::income_type::military) }); // $VAL
386 text::add_line(state, contents, std::string_view("budget_interest"), text::variable_type::val,
387 text::fp_one_place{
388 -economy::interest_payment(state, nation_id) }); // $VAL - presumably loan payments == interest (?)
389 text::add_line(state, contents, std::string_view("budget_imports"), text::variable_type::val,
390 text::fp_one_place{ -economy::nation_total_imports(state,
391 nation_id) }); // $VAL - presumably nation_total_imports is for national stockpile (?)
392
393 text::add_line_break_to_layout(state, contents);
394
395 text::add_line(state, contents, std::string_view("topbar_projected_income"), text::variable_type::val,
396 text::fp_two_places{ economy::estimate_daily_income(state, nation_id) });
397
398 */
399 }
400
401};
402
404public:
407 }
408 void on_create(sys::state& state) noexcept override {
412 }
413
414 void on_update(sys::state& state) noexcept override {
415 auto nation_id = retrieve<dcon::nation_id>(state, parent);
416 auto available = nations::max_national_focuses(state, nation_id);
417 auto in_use = nations::national_focuses_in_use(state, nation_id);
418
419 if(in_use < available) {
420 set_text(state, "?R" + text::format_ratio(in_use, available));
421 } else {
422 set_text(state, text::format_ratio(in_use, available));
423 }
424 }
425
426 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
427 auto nation_id = retrieve<dcon::nation_id>(state, parent);
428 auto box = text::open_layout_box(contents, 0);
430 float relevant_pop = state.world.nation_get_demographics(nation_id,
431 demographics::to_key(state, state.world.nation_get_primary_culture(nation_id)));
432 for(auto ac : state.world.in_culture) {
433 if(state.world.nation_get_accepted_cultures(nation_id, ac)) {
434 relevant_pop += state.world.nation_get_demographics(nation_id, demographics::to_key(state, ac));
435 }
436 }
438 auto fPoints = relevant_pop / state.defines.national_focus_divider; // NOTE: Occasionally inaccurate by a few 0.01, this
439 // doesnt really matter so im leaving it -breizh
441 text::localised_format_box(state, contents, box, std::string_view("tb_nationalfocus_culture"), sub1);
445 text::localised_format_box(state, contents, box, std::string_view("tb_max_focus"), sub2);
446 if(nations::national_focuses_in_use(state, nation_id) > 0) {
448 auto nation_fat_id = dcon::fatten(state.world, nation_id);
449 nation_fat_id.for_each_state_ownership([&](dcon::state_ownership_id so) {
450 auto fat_state_id = dcon::fatten(state.world, so);
451 if(fat_state_id.is_valid()) {
452 auto staat = fat_state_id.get_state();
453 if(staat.is_valid()) {
454 auto natl_fat_id = staat.get_owner_focus();
455 if(natl_fat_id.is_valid()) {
456 text::add_to_layout_box(state, contents, box, natl_fat_id.get_name());
458 }
459 }
460 }
461 });
462 } else {
464 text::localised_format_box(state, contents, box, std::string_view("tb_nationalfocus_none"), text::substitution_map{});
465 }
466 text::close_layout_box(contents, box);
467 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::max_national_focus, false);
468 }
469};
470
472public:
473 void on_create(sys::state& state) noexcept override {
477 }
478
479 void on_update(sys::state& state) noexcept override {
480 auto nation_id = retrieve<dcon::nation_id>(state, parent);
481 auto militancy = state.world.nation_get_demographics(nation_id, demographics::militancy);
482 auto total_pop = state.world.nation_get_demographics(nation_id, demographics::total);
484 }
485
488 }
489
490 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
491 auto nation_id = retrieve<dcon::nation_id>(state, parent);
492 auto box = text::open_layout_box(contents, 0);
494 auto mil_change = demographics::get_estimated_mil_change(state, nation_id);
495 auto total = state.world.nation_get_demographics(nation_id, demographics::total);
497 text::fp_two_places{total != 0.f ? state.world.nation_get_demographics(nation_id, demographics::militancy) / total : 0.f});
499 text::fp_four_places{mil_change});
500 text::localised_format_box(state, contents, box, std::string_view("topbar_avg_mil"), sub);
502 text::localised_format_box(state, contents, box, std::string_view("topbar_avg_change"), sub);
503 text::close_layout_box(contents, box);
504
505 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::global_pop_militancy_modifier, true);
506 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::core_pop_militancy_modifier, true);
507 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::non_accepted_pop_militancy_modifier, true);
508 }
509};
510
512public:
515 }
516
517 void on_create(sys::state& state) noexcept override {
521 }
522
523 void on_update(sys::state& state) noexcept override {
524 auto nation_id = retrieve<dcon::nation_id>(state, parent);
525 auto militancy = state.world.nation_get_demographics(nation_id, demographics::consciousness);
526 auto total_pop = state.world.nation_get_demographics(nation_id, demographics::total);
528 }
529
530 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
531 auto nation_id = retrieve<dcon::nation_id>(state, parent);
532
533 auto box = text::open_layout_box(contents, 0);
535 auto con_change = demographics::get_estimated_con_change(state, nation_id);
536 auto total = state.world.nation_get_demographics(nation_id, demographics::total);
538 text::fp_two_places{ total != 0.f ? (state.world.nation_get_demographics(nation_id, demographics::consciousness) / total) : 0.f });
540 text::localised_format_box(state, contents, box, std::string_view("topbar_avg_con"), sub);
542 text::localised_format_box(state, contents, box, std::string_view("topbar_avg_change"), sub);
543 text::close_layout_box(contents, box);
544
545 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::global_pop_consciousness_modifier, true);
546 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::core_pop_consciousness_modifier, true);
547 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::non_accepted_pop_consciousness_modifier, true);
548 }
549};
550
552public:
553 void on_create(sys::state& state) noexcept override {
557 }
558
559 void on_update(sys::state& state) noexcept override {
560 auto points = nations::diplomatic_points(state, retrieve<dcon::nation_id>(state, parent));
561 set_text(state, text::format_float(points, 1));
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
571 auto box = text::open_layout_box(contents, 0);
575
576 // Monthly gain
579
580 text::substitution_map sub_base;
581 // Base gain
583 text::fp_one_place{ state.defines.base_monthly_diplopoints });
584
585 text::localised_format_box(state, contents, box, std::string_view("topbar_diplopoints"), sub);
587 text::localised_format_box(state, contents, box, std::string_view("topbar_diplopoints_gain"), sub);
589 text::localised_format_box(state, contents, box, std::string_view("topbar_diplopoints_basegain"), sub_base);
590 text::close_layout_box(contents, box);
591
592 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::diplomatic_points_modifier, false);
593 }
594};
595
597public:
600 }
601
602 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
603 auto nation_id = retrieve<dcon::nation_id>(state, parent);
604 auto box = text::open_layout_box(contents, 0);
606 text::add_to_substitution_map(sub, text::variable_type::curr, state.world.nation_get_active_regiments(nation_id));
607 text::add_to_substitution_map(sub, text::variable_type::max, state.world.nation_get_recruitable_regiments(nation_id));
608 text::localised_format_box(state, contents, box, std::string_view("topbar_army_tooltip"), sub);
609 text::close_layout_box(contents, box);
610 }
611};
612
614public:
617 }
618
619 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
620 auto n = retrieve<dcon::nation_id>(state, parent);
621 {
622 auto box = text::open_layout_box(contents, 0);
624 int32_t num_ships = 0;
625 for(auto nv : state.world.nation_get_navy_control(n)) {
626 num_ships += int32_t(nv.get_navy().get_navy_membership().end() - nv.get_navy().get_navy_membership().begin());
627 }
631 text::localised_format_box(state, contents, box, std::string_view("alice_navy_allocation_tt"), sub);
632 text::close_layout_box(contents, box);
633 }
634 for(const auto nv : state.world.nation_get_navy_control_as_controller(n)) {
635 int32_t total = 0;
636 for(const auto memb : nv.get_navy().get_navy_membership()) {
637 total += state.military_definitions.unit_base_definitions[memb.get_ship().get_type()].supply_consumption_score;
638 }
639 auto box = text::open_layout_box(contents, 0);
641 text::add_to_substitution_map(sub, text::variable_type::name, state.to_string_view(nv.get_navy().get_name()));
644 text::localised_format_box(state, contents, box, std::string_view("alice_navy_allocation_2"), sub);
645 text::close_layout_box(contents, box);
646 }
647 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::supply_range, true);
648 }
649};
650
652public:
655 }
656
657 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
658 auto n = retrieve<dcon::nation_id>(state, parent);
659
660 auto issue_id = politics::get_issue_by_name(state, std::string_view("war_policy"));
661 int32_t possible_sum = 0;
662 int32_t raised_sum = 0;
663 auto fat_id = dcon::fatten(state.world, n);
664 for(auto prov_own : fat_id.get_province_ownership_as_nation()) {
665 auto prov = prov_own.get_province();
667 }
668 for(auto prov_own : fat_id.get_province_ownership_as_nation()) {
669 auto prov = prov_own.get_province();
671 }
672 auto box = text::open_layout_box(contents, 0);
675 // TODO - we (might) want to give the value the current war policy provides, though its more transparent perhaps to
676 // just give the NV + Mob. Impact Modifier?
677 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))});
678 text::add_to_substitution_map(sub2, text::variable_type::policy, fat_id.get_issues(issue_id).get_name());
680 text::localised_single_sub_box(state, contents, box, std::string_view("topbar_mobilize_tooltip"), text::variable_type::curr, possible_sum);
682 text::localised_format_box(state, contents, box, std::string_view("mobilization_impact_limit_desc"), sub2);
684 text::localised_format_box(state, contents, box, std::string_view("mobilization_impact_limit_desc2"), sub2);
685 text::close_layout_box(contents, box);
686
687 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::mobilization_impact, true);
688 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::mobilization_size, true);
689 }
690};
691
693private:
694 float getResearchPointsFromPop(sys::state& state, dcon::pop_type_id pop, dcon::nation_id n) {
695 /*
696 Now imagine that Rock Hudson is standing at the top of the water slide hurling Nintendo consoles down the water slide.
697 If it weren't for the ladders, which allow the water to pass through but not the Nintendo consoles,
698 the Nintendo consoles could hit someone in the wave pool on the head, in which case the water park could get sued.
699 */
700 // auto sum = (fat_pop.get_research_points() * ((state.world.nation_get_demographics(n, demographics::to_key(state,
701 // fat_pop)) / state.world.nation_get_demographics(n, demographics::total)) / fat_pop.get_research_optimum() ));
702 auto sum = ((state.world.nation_get_demographics(n, demographics::to_key(state, pop)) /
703 state.world.nation_get_demographics(n, demographics::total)) /
704 state.world.pop_type_get_research_optimum(state.culture_definitions.officers));
705 return sum;
706 }
707
708public:
711 }
712
713 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
714 auto n = retrieve<dcon::nation_id>(state, parent);
715
716 auto box = text::open_layout_box(contents, 0);
719 state.world.pop_type_get_name(state.culture_definitions.officers));
721 text::fp_two_places{getResearchPointsFromPop(state, state.culture_definitions.officers, n)});
724 state.world.nation_get_demographics(n, demographics::to_key(state, state.culture_definitions.officers)) /
725 state.world.nation_get_demographics(n, demographics::total) });
727 text::fp_two_places{(state.world.pop_type_get_research_optimum(state.culture_definitions.officers) * 100)});
728 text::localised_format_box(state, contents, box, std::string_view("alice_daily_leadership_tt"), sub);
729 text::close_layout_box(contents, box);
730
731 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::leadership, true);
732 active_modifiers_description(state, contents, n, 0, sys::national_mod_offsets::leadership_modifier, true);
733 }
734};
735
737public:
738 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
739 base_data.size.x = int16_t(ui_width(state));
740 base_data.size.y = int16_t(ui_height(state));
742 //Put it far away!
743 if(base_data.position.x >= 256 || base_data.position.y >= 256) {
744 base_data.position.x = int16_t(8192 * 2);
745 base_data.position.y = int16_t(8192 * 2);
746 }
747 }
748};
749
751public:
752 void button_action(sys::state& state) noexcept override {
753 auto const override_and_show_tab = [&]() {
755 state.ui_state.root->move_child_to_front(topbar_subwindow);
757 };
758
759 if(state.ui_state.topbar_subwindow->is_visible()) {
760 state.ui_state.topbar_subwindow->set_visible(state, false);
761 if(state.ui_state.topbar_subwindow != topbar_subwindow) {
762 override_and_show_tab();
763 }
764 } else {
765 override_and_show_tab();
766 }
767 }
768
769 bool is_active(sys::state& state) noexcept override {
771 }
772
775 }
776 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
777 text::add_line(state, contents, "alice_topbar_tab_1");
778 }
779
781};
782
784public:
787 }
788};
790public:
792 // for now we reuse the budget tab sound
794 }
795};
797public:
800 }
801};
803public:
806 }
807};
809public:
812 }
813};
815public:
818 }
819};
821public:
824 }
825};
827public:
830 }
831};
832
834public:
837 }
838
839 void button_action(sys::state& state) noexcept override {
840 auto const override_and_show_tab = [&]() {
843
844 Cyto::Any payload = pop_list_filter(state.local_player_nation);
846
847 state.ui_state.root->move_child_to_front(topbar_subwindow);
849 };
850
851 if(state.ui_state.topbar_subwindow->is_visible()) {
852 state.ui_state.topbar_subwindow->set_visible(state, false);
853 if(state.ui_state.topbar_subwindow != topbar_subwindow) {
854 override_and_show_tab();
855 }
856 } else {
857 override_and_show_tab();
858 }
859 }
860
863 }
864 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
865 text::add_line(state, contents, "alice_topbar_tab_2");
866 }
867};
868
870public:
871 void on_update(sys::state& state) noexcept override {
873 }
874};
875
877public:
878 void on_create(sys::state& state) noexcept override {
881 }
882
884 if(state.actual_game_speed <= 0) {
886 }
888 }
889
890 void button_action(sys::state& state) noexcept override {
891 if(state.actual_game_speed <= 0) {
892 state.actual_game_speed = state.ui_state.held_game_speed;
893 } else {
894 state.ui_state.held_game_speed = state.actual_game_speed.load();
895 state.actual_game_speed = 0;
896 if(state.network_mode == sys::network_mode_type::host) {
897 command::notify_pause_game(state, state.local_player_nation);
898 }
899 }
900 }
901
902 void on_update(sys::state& state) noexcept override {
903 if(state.network_mode == sys::network_mode_type::client) {
904 disabled = true;
905 } else {
906 disabled = state.internally_paused || state.ui_pause.load(std::memory_order::acquire);
908 }
909 }
910
913 }
914
915 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
916 if(state.network_mode == sys::network_mode_type::client) {
917 text::add_line(state, contents, "alice_only_host_speed");
918 } else {
919 text::add_line(state, contents, "topbar_pause_speed");
920 }
921
922 auto ymd = state.current_date.to_ymd(state.start_date);
923 if(sys::is_leap_year(ymd.year)) {
924 text::add_line(state, contents, "date_is_leap");
925 } else {
926 text::add_line(state, contents, "date_is_not_leap");
927 }
928
929 float nh_temp = 15.f;
930 std::string nh_season;
931 if(ymd.month == 12 || ymd.month <= 2) {
932 nh_season = text::produce_simple_string(state, "winter");
933 } else if(ymd.month >= 3 && ymd.month <= 5) {
934 nh_season = text::produce_simple_string(state, "spring");
935 } else if(ymd.month >= 6 && ymd.month <= 8) {
936 nh_season = text::produce_simple_string(state, "summer");
937 } else if(ymd.month >= 9 && ymd.month <= 11) {
938 nh_season = text::produce_simple_string(state, "autumn");
939 }
940 text::add_line(state, contents, "topbar_date_season_nh", text::variable_type::x, std::string_view(nh_season));
941
942 std::string sh_season;
943 if(ymd.month >= 6 && ymd.month <= 8) {
944 sh_season = text::produce_simple_string(state, "winter");
945 } else if(ymd.month >= 9 && ymd.month <= 11) {
946 sh_season = text::produce_simple_string(state, "spring");
947 } else if(ymd.month == 12 || ymd.month <= 2) {
948 sh_season = text::produce_simple_string(state, "summer");
949 } else if(ymd.month >= 3 && ymd.month <= 5) {
950 sh_season = text::produce_simple_string(state, "autumn");
951 }
952 text::add_line(state, contents, "topbar_date_season_sh", text::variable_type::x, std::string_view(sh_season));
953
954 //auto r = ((float(rng::reduce(state.game_seed, 4096)) / 4096.f) * 8.f) - 4.f;
955 //float avg_temp = (nh_temp + sh_temp + r) / 2.f;
956 //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 });
957 //topbar_date_temperature;Average temperature: §Y$x$°C§! / §Y$y$°F§!
958 }
959};
960
962public:
963 void on_create(sys::state& state) noexcept override {
967 }
968
969 void button_action(sys::state& state) noexcept override {
970 if(state.actual_game_speed > 0) {
971 state.actual_game_speed = std::min(5, state.actual_game_speed.load() + 1);
972 } else {
973 state.ui_state.held_game_speed = std::min(5, state.ui_state.held_game_speed + 1);
974 }
975 }
976
979 }
980 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
981 auto box = text::open_layout_box(contents, 0);
982 if(state.network_mode == sys::network_mode_type::client) {
983 text::localised_format_box(state, contents, box, std::string_view("alice_only_host_speed"));
984 } else {
985 text::localised_format_box(state, contents, box, std::string_view("topbar_inc_speed"));
986 }
987 text::close_layout_box(contents, box);
988 }
989};
990
992public:
993 void on_create(sys::state& state) noexcept override {
997 }
998
999 void button_action(sys::state& state) noexcept override {
1000 if(state.actual_game_speed > 0) {
1001 state.actual_game_speed = std::max(1, state.actual_game_speed.load() - 1);
1002 } else {
1003 state.ui_state.held_game_speed = std::max(1, state.ui_state.held_game_speed - 1);
1004 }
1005 }
1006
1009 }
1010 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1011 auto box = text::open_layout_box(contents, 0);
1012 if(state.network_mode == sys::network_mode_type::client) {
1013 text::localised_format_box(state, contents, box, std::string_view("alice_only_host_speed"));
1014 } else {
1015 text::localised_format_box(state, contents, box, std::string_view("topbar_dec_speed"));
1016 }
1017 text::close_layout_box(contents, box);
1018 }
1019};
1020
1022public:
1023 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
1024 if(state.network_mode == sys::network_mode_type::single_player || state.network_mode == sys::network_mode_type::host) {
1025 if(state.internally_paused || state.ui_pause.load(std::memory_order::acquire)) {
1026 frame = 0;
1027 } else {
1028 frame = state.actual_game_speed;
1029 }
1030 } else {
1031 frame = state.actual_game_speed;
1032 }
1034 }
1035};
1036
1038public:
1039 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1040 return int32_t(!(nations::is_great_power(state, nation_id) &&
1041 state.world.nation_get_rank(nation_id) > uint16_t(state.defines.great_nations_count)));
1042 }
1043
1046 }
1047
1048 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1049 if(!nations::is_great_power(state, state.local_player_nation)) {
1050 text::add_line(state, contents, "countryalert_no_gpstatus");
1051 } else if(state.world.nation_get_rank(state.local_player_nation) > uint16_t(state.defines.great_nations_count)) {
1052 text::add_line(state, contents, "alice_lose_gp");
1053 auto box = text::open_layout_box(contents);
1055 text::add_to_substitution_map(sub, text::variable_type::x, int32_t(state.defines.great_nations_count));
1056 for(const auto gp : state.great_nations) {
1057 if(gp.nation == state.local_player_nation) {
1058 text::add_to_substitution_map(sub, text::variable_type::date, gp.last_greatness + int32_t(state.defines.greatness_days));
1059 break;
1060 }
1061 }
1062 text::localised_format_box(state, contents, box, "alice_gp_status_regain_expiration", sub);
1063 text::close_layout_box(contents, box);
1064 } else if(state.world.nation_get_rank(state.local_player_nation) <= uint16_t(state.defines.great_nations_count)) {
1065 text::add_line(state, contents, "countryalert_no_loosinggpstatus");
1066 }
1067 }
1068};
1069
1071public:
1072 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
1073 return text::produce_simple_string(state, "atpeace");
1074 }
1075};
1076
1078public:
1079 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1080 return int32_t(!economy::nation_is_constructing_factories(state, nation_id));
1081 }
1082
1085 }
1086
1087 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1088 if(parent) {
1089 Cyto::Any payload = dcon::nation_id{};
1090 parent->impl_get(state, payload);
1091 auto nation_id = any_cast<dcon::nation_id>(payload);
1092
1093 auto box = text::open_layout_box(contents, 0);
1095 text::localised_format_box(state, contents, box, "countryalert_no_isbuildingfactories", text::substitution_map{});
1096 } else if(economy::nation_is_constructing_factories(state, nation_id)) {
1097 text::localised_format_box(state, contents, box, "countryalert_isbuildingfactories", text::substitution_map{});
1098 auto nation_fat_id = dcon::fatten(state.world, nation_id);
1099 nation_fat_id.for_each_state_building_construction([&](dcon::state_building_construction_id building_slim_id) {
1100 auto building_fat_id = dcon::fatten(state.world, building_slim_id);
1101 auto stateName = building_fat_id.get_state().get_definition().get_name();
1102 auto factoryType = building_fat_id.get_type().get_name();
1103
1105 text::add_to_layout_box(state, contents, box, stateName);
1106 text::add_space_to_layout_box(state, contents, box);
1107 text::add_to_layout_box(state, contents, box, factoryType);
1108 });
1109 }
1110 text::close_layout_box(contents, box);
1111 }
1112 }
1113};
1114
1116public:
1117 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1118 return int32_t(!economy::nation_has_closed_factories(state, nation_id));
1119 }
1120
1123 }
1124
1125 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1126 if(parent) {
1127 Cyto::Any payload = dcon::nation_id{};
1128 parent->impl_get(state, payload);
1129 auto nation_id = any_cast<dcon::nation_id>(payload);
1130
1131 auto box = text::open_layout_box(contents, 0);
1133 text::localised_format_box(state, contents, box, "remove_countryalert_no_hasclosedfactories", text::substitution_map{});
1134 } else if(economy::nation_has_closed_factories(state, nation_id)) {
1135 text::localised_format_box(state, contents, box, "remove_countryalert_hasclosedfactories", text::substitution_map{});
1137 auto nation_fat = dcon::fatten(state.world, nation_id);
1138 for(auto staat_owner : nation_fat.get_state_ownership()) {
1139 auto staat = staat_owner.get_state().get_definition();
1140 bool new_staat = true;
1141 for(auto abstract : staat.get_abstract_state_membership()) {
1142 auto prov = abstract.get_province();
1143 for(auto factloc : prov.get_factory_location()) {
1144 auto scale = factloc.get_factory().get_production_scale();
1145 if(scale < 0.05f) {
1146 if(new_staat) {
1147 text::add_to_layout_box(state, contents, box, staat.get_name(), text::text_color::yellow);
1148 // text::add_divider_to_layout_box(state, contents, box); // TODO - Parity needed!
1150 new_staat = false;
1151 }
1152 text::add_to_layout_box(state, contents, box, std::string_view(" - "));
1153 text::add_to_layout_box(state, contents, box, factloc.get_factory().get_building_type().get_name(),
1156 }
1157 }
1158 }
1159 }
1160 }
1161 text::close_layout_box(contents, box);
1162 }
1163 }
1164};
1165
1167public:
1168 bool visible = false;
1169 void on_update(sys::state& state) noexcept override {
1170 visible = (state.world.nation_get_spending_level(state.local_player_nation) < 1.0f);
1171 }
1172 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
1173 if(visible)
1175 }
1178 }
1179
1180 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1181 if(visible) {
1182 text::add_line(state, contents, "topbar_budget_warning");
1183 }
1184 }
1185};
1186
1188public:
1189 void on_update(sys::state& state) noexcept override {
1190 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1191 bool has_unemployed = false;
1192 // Only care about factory workers for displaying the red alert
1193 std::array<dcon::pop_type_id, 2> factory_workers{
1194 state.culture_definitions.primary_factory_worker,
1195 state.culture_definitions.secondary_factory_worker
1196 };
1197 for(auto pt : factory_workers) {
1198 for(auto si : state.world.nation_get_state_ownership(nation_id)) {
1199 auto state_instance = si.get_state();
1200 auto total = state_instance.get_demographics(demographics::to_key(state, pt));
1201 auto unemployed = total - state_instance.get_demographics(demographics::to_employment_key(state, pt));
1202 if(unemployed >= 1.0f) {
1203 has_unemployed = true;
1204 break;
1205 }
1206 }
1207 if(has_unemployed)
1208 break;
1209 }
1210 frame = has_unemployed ? 0 : 1;
1211 }
1212
1215 }
1216
1217 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1218 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1219 bool header = false;
1220 std::array<dcon::pop_type_id, 2> factory_workers{
1221 state.culture_definitions.primary_factory_worker,
1222 state.culture_definitions.secondary_factory_worker
1223 };
1224 for(auto pt : factory_workers) {
1225 for(auto si : state.world.nation_get_state_ownership(nation_id)) {
1226 auto state_instance = si.get_state();
1227 auto total = state_instance.get_demographics(demographics::to_key(state, pt));
1228 auto unemployed = total - state_instance.get_demographics(demographics::to_employment_key(state, pt));
1229 if(unemployed >= 1.f) {
1230 if(!header) {
1231 text::add_line(state, contents, "remove_countryalert_hasunemployedworkers");
1232 header = true;
1233 }
1236 text::add_to_substitution_map(sub, text::variable_type::type, state.world.pop_type_get_name(pt));
1237 auto state_name = text::get_dynamic_state_name(state, state_instance);
1240 auto box = text::open_layout_box(contents);
1241 text::localised_format_box(state, contents, box, "topbar_unemployed", sub);
1242 text::close_layout_box(contents, box);
1243 }
1244 }
1245 }
1246 std::array<dcon::pop_type_id, 2> rgo_workers{
1247 state.culture_definitions.farmers,
1248 state.culture_definitions.laborers
1249 };
1250 for(auto pt : rgo_workers) {
1251 for(auto si : state.world.nation_get_state_ownership(nation_id)) {
1252 auto state_instance = si.get_state();
1253 auto total = state_instance.get_demographics(demographics::to_key(state, pt));
1254 auto unemployed = total - state_instance.get_demographics(demographics::to_employment_key(state, pt));
1255 if(unemployed >= 1.f) {
1256 if(!header) {
1257 text::add_line(state, contents, "alice_rgo_unemployment_country_alert");
1258 header = true;
1259 }
1262 text::add_to_substitution_map(sub, text::variable_type::type, state.world.pop_type_get_name(pt));
1263 auto state_name = text::get_dynamic_state_name(state, state_instance);
1266 auto box = text::open_layout_box(contents);
1267 text::localised_format_box(state, contents, box, "topbar_unemployed", sub);
1268 text::close_layout_box(contents, box);
1269 }
1270 }
1271 }
1272 if(!header) {
1273 text::add_line(state, contents, "countryalert_no_hasunemployedworkers");
1274 }
1275 }
1276};
1277
1279public:
1280 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1281 return int32_t(!nations::has_reform_available(state, nation_id));
1282 }
1283
1286 }
1287
1288 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1289 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1290 auto box = text::open_layout_box(contents, 0);
1291 if(!nations::has_reform_available(state, nation_id)) {
1292 text::localised_format_box(state, contents, box, std::string_view("countryalert_no_candoreforms"),
1294 } else if(nations::has_reform_available(state, nation_id)) {
1295 text::localised_format_box(state, contents, box, std::string_view("countryalert_candoreforms"), text::substitution_map{});
1296 text::add_divider_to_layout_box(state, contents, box);
1297 // Display Avaliable Reforms
1298 // Mostly a copy of nations::has_reform_avaliable
1299 auto last_date = state.world.nation_get_last_issue_or_reform_change(nation_id);
1300 if(bool(last_date) && (last_date + int32_t(state.defines.min_delay_between_reforms * 30.0f)) > state.current_date) {
1301 text::close_layout_box(contents, box);
1302 return;
1303 }
1304 if(state.world.nation_get_is_civilized(nation_id)) {
1305 for(auto i : state.culture_definitions.political_issues) {
1306 for(auto o : state.world.issue_get_options(i)) {
1307 if(o && politics::can_enact_political_reform(state, nation_id, o)) {
1308 auto fat_id = dcon::fatten(state.world, o);
1309 text::add_to_layout_box(state, contents, box, fat_id.get_parent_issue().get_name());
1310 text::add_to_layout_box(state, contents, box, std::string_view(": "));
1311 text::add_to_layout_box(state, contents, box, fat_id.get_name());
1313 }
1314 }
1315 }
1316
1317 for(auto i : state.culture_definitions.social_issues) {
1318 for(auto o : state.world.issue_get_options(i)) {
1319 if(o && politics::can_enact_social_reform(state, nation_id, o)) {
1320 auto fat_id = dcon::fatten(state.world, o);
1321 text::add_to_layout_box(state, contents, box, fat_id.get_parent_issue().get_name());
1322 text::add_to_layout_box(state, contents, box, std::string_view(": "));
1323 text::add_to_layout_box(state, contents, box, fat_id.get_name());
1325 }
1326 }
1327 }
1328
1329 text::close_layout_box(contents, box);
1330 return;
1331 } else {
1332 for(auto i : state.culture_definitions.military_issues) {
1333 for(auto o : state.world.reform_get_options(i)) {
1334 if(o && politics::can_enact_military_reform(state, nation_id, o)) {
1335 auto fat_id = dcon::fatten(state.world, o);
1336 text::add_to_layout_box(state, contents, box, fat_id.get_parent_reform().get_name());
1337 text::add_to_layout_box(state, contents, box, std::string_view(": "));
1338 text::add_to_layout_box(state, contents, box, fat_id.get_name());
1340 }
1341 }
1342 }
1343
1344 for(auto i : state.culture_definitions.economic_issues) {
1345 for(auto o : state.world.reform_get_options(i)) {
1346 if(o && politics::can_enact_economic_reform(state, nation_id, o)) {
1347 auto fat_id = dcon::fatten(state.world, o);
1348 text::add_to_layout_box(state, contents, box, fat_id.get_parent_reform().get_name());
1349 text::add_to_layout_box(state, contents, box, std::string_view(": "));
1350 text::add_to_layout_box(state, contents, box, fat_id.get_name());
1352 }
1353 }
1354 }
1355 }
1356 }
1357 text::close_layout_box(contents, box);
1358 }
1359
1360 void button_action(sys::state& state) noexcept override {
1361 auto const override_and_show_tab = [&]() {
1362 state.ui_state.politics_subwindow->set_visible(state, true);
1364
1365 Cyto::Any defs = Cyto::make_any<politics_window_tab>(politics_window_tab::reforms);
1366 state.ui_state.politics_subwindow->impl_get(state, defs);
1367
1368 state.ui_state.root->move_child_to_front(state.ui_state.politics_subwindow);
1369 state.ui_state.topbar_subwindow = state.ui_state.politics_subwindow;
1370 };
1371
1372 if(state.ui_state.topbar_subwindow->is_visible()) {
1373 state.ui_state.topbar_subwindow->set_visible(state, false);
1374 if(state.ui_state.topbar_subwindow != state.ui_state.politics_subwindow)
1375 override_and_show_tab();
1376 } else {
1377 override_and_show_tab();
1378 }
1379 }
1380
1381};
1382
1384public:
1385 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1386 return int32_t(!nations::has_decision_available(state, nation_id));
1387 }
1388
1391 }
1392
1393 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1394 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1395 if(!nations::has_decision_available(state, nation_id)) {
1396 text::add_line(state, contents, "countryalert_no_candodecisions");
1397 } else {
1398 text::add_line(state, contents, "countryalert_candodecisions");
1399
1401 produce_decision_substitutions(state, m, state.local_player_nation);
1402
1403 state.world.for_each_decision([&](dcon::decision_id di) {
1404 if(nation_id != state.local_player_nation || !state.world.decision_get_hide_notification(di)) {
1405 auto lim = state.world.decision_get_potential(di);
1406 if(!lim || trigger::evaluate(state, lim, trigger::to_generic(nation_id), trigger::to_generic(nation_id), 0)) {
1407 auto allow = state.world.decision_get_allow(di);
1408 if(!allow || trigger::evaluate(state, allow, trigger::to_generic(nation_id), trigger::to_generic(nation_id), 0)) {
1409 auto fat_id = dcon::fatten(state.world, di);
1410 auto box = text::open_layout_box(contents);
1411 text::add_to_layout_box(state, contents, box, fat_id.get_name(), m);
1412 text::close_layout_box(contents, box);
1413 }
1414 }
1415 }
1416 });
1417 }
1418 }
1419
1420 void button_action(sys::state& state) noexcept override {
1421 auto const override_and_show_tab = [&]() {
1422 state.ui_state.politics_subwindow->set_visible(state, true);
1424
1425 Cyto::Any defs = Cyto::make_any<politics_window_tab>(politics_window_tab::decisions);
1426 state.ui_state.politics_subwindow->impl_get(state, defs);
1427
1428 state.ui_state.root->move_child_to_front(state.ui_state.politics_subwindow);
1429 state.ui_state.topbar_subwindow = state.ui_state.politics_subwindow;
1430 };
1431
1432 if(state.ui_state.topbar_subwindow->is_visible()) {
1433 state.ui_state.topbar_subwindow->set_visible(state, false);
1434 if(state.ui_state.topbar_subwindow != state.ui_state.politics_subwindow)
1435 override_and_show_tab();
1436 } else {
1437 override_and_show_tab();
1438 }
1439 }
1440
1441};
1442
1444public:
1445 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1446 return int32_t(!politics::is_election_ongoing(state, nation_id));
1447 }
1448
1450 return tooltip_behavior::variable_tooltip;
1451 }
1452
1453 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1454 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1455 auto box = text::open_layout_box(contents, 0);
1456 if(politics::has_elections(state, nation_id)) {
1457 if(!politics::is_election_ongoing(state, nation_id)) {
1458 text::localised_format_box(state, contents, box, std::string_view("countryalert_no_isinelection"),
1460 } else if(politics::is_election_ongoing(state, nation_id)) {
1462 text::add_to_substitution_map(sub, text::variable_type::date, dcon::fatten(state.world, nation_id).get_election_ends());
1463 text::localised_format_box(state, contents, box, std::string_view("countryalert_isinelection"), sub);
1464 }
1465 } else {
1466 text::localised_format_box(state, contents, box, std::string_view("term_for_life"));
1467 }
1468 text::close_layout_box(contents, box);
1469 }
1470};
1471
1473public:
1474 void on_update(sys::state& state) noexcept override {
1475 for(auto rf : state.world.nation_get_rebellion_within(state.local_player_nation)) {
1476 auto org = rf.get_rebels().get_organization();
1477 if(org >= 0.01f) {
1478 frame = 0;
1479 return;
1480 }
1481 }
1482 frame = 1;
1483 }
1484
1486 return tooltip_behavior::variable_tooltip;
1487 }
1488
1489 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1490 bool showed_title = false;
1491
1492 for(auto rf : state.world.nation_get_rebellion_within(state.local_player_nation)) {
1493 auto org = rf.get_rebels().get_organization();
1494 if(org >= 0.01f) {
1495 if(!showed_title) {
1496 text::add_line(state, contents, "countryalert_haverebels");
1498 showed_title = true;
1499 }
1500 auto rebelname = rebel::rebel_name(state, rf.get_rebels());
1501 auto rebelsize = rf.get_rebels().get_possible_regiments();
1502
1503 text::add_line(state, contents, "topbar_faction",
1504 text::variable_type::name, std::string_view{ rebelname },
1507 }
1508 }
1509 }
1510
1511 void button_action(sys::state& state) noexcept override {
1512 auto const override_and_show_tab = [&]() {
1513 state.ui_state.politics_subwindow->set_visible(state, true);
1515
1516 Cyto::Any defs = Cyto::make_any<politics_window_tab>(politics_window_tab::movements);
1517 state.ui_state.politics_subwindow->impl_get(state, defs);
1518
1519 state.ui_state.root->move_child_to_front(state.ui_state.politics_subwindow);
1520 state.ui_state.topbar_subwindow = state.ui_state.politics_subwindow;
1521 };
1522
1523 if(state.ui_state.topbar_subwindow->is_visible()) {
1524 state.ui_state.topbar_subwindow->set_visible(state, false);
1525 if(state.ui_state.topbar_subwindow != state.ui_state.politics_subwindow)
1526 override_and_show_tab();
1527 } else {
1528 override_and_show_tab();
1529 }
1530 }
1531
1532};
1533
1535 uint32_t index = 0;
1536
1537 dcon::province_id get_state_def_province(sys::state& state, dcon::state_definition_id sdef) noexcept {
1538 for(auto const p : state.world.state_definition_get_abstract_state_membership(sdef)) {
1539 if(!p.get_province().get_nation_from_province_ownership()) {
1540 return p.get_province();
1541 }
1542 }
1543 return dcon::province_id{};
1544 }
1545public:
1546 void button_action(sys::state& state) noexcept override {
1547 std::vector<dcon::province_id> provinces;
1548 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1549 auto nation_fat_id = dcon::fatten(state.world, nation_id);
1550 for(auto si : state.world.nation_get_state_ownership(nation_id)) {
1551 if(province::can_integrate_colony(state, si.get_state())) {
1552 provinces.push_back(si.get_state().get_capital());
1553 }
1554 }
1555
1556 state.world.for_each_state_definition([&](dcon::state_definition_id sdef) {
1557 if(province::can_start_colony(state, nation_id, sdef)) {
1558 dcon::province_id province;
1559 for(auto p : state.world.state_definition_get_abstract_state_membership(sdef)) {
1560 if(!p.get_province().get_nation_from_province_ownership()) {
1561 province = p.get_province().id;
1562 break;
1563 }
1564 }
1565 if(province) {
1566 provinces.push_back(province);
1567 }
1568 }
1569 });
1570
1571 nation_fat_id.for_each_colonization([&](dcon::colonization_id colony) {
1572 auto sdef = state.world.colonization_get_state(colony);
1573 if(state.world.state_definition_get_colonization_stage(sdef) == 3) { //make protectorate
1574 provinces.push_back(get_state_def_province(state, sdef));
1575 } else if(province::can_invest_in_colony(state, nation_id, sdef)) { //invest
1576 provinces.push_back(get_state_def_province(state, sdef));
1577 } else { //losing rase
1578 auto lvl = state.world.colonization_get_level(colony);
1579 for(auto cols : state.world.state_definition_get_colonization(sdef)) {
1580 if(lvl < cols.get_level()) {
1581 provinces.push_back(get_state_def_province(state, sdef));
1582 break;
1583 }
1584 }
1585 }
1586 });
1587 if(!provinces.empty()) {
1588 index++;
1589 if(index >= uint32_t(provinces.size())) {
1590 index = 0;
1591 }
1592 if(auto prov = provinces[index]; prov && prov.value < state.province_definitions.first_sea_province.value) {
1593 sound::play_interface_sound(state, sound::get_click_sound(state), state.user_settings.interface_volume * state.user_settings.master_volume);
1594 state.map_state.set_selected_province(prov);
1595 static_cast<ui::province_view_window*>(state.ui_state.province_window)->set_active_province(state, prov);
1596 if(state.map_state.get_zoom() < map::zoom_very_close)
1597 state.map_state.zoom = map::zoom_very_close;
1598 state.map_state.center_map_on_province(state, prov);
1599 }
1600 }
1601 }
1602
1603 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1604 bool any_integratable = false;
1605 for(auto si : state.world.nation_get_state_ownership(nation_id)) {
1606 if(province::can_integrate_colony(state, si.get_state())) {
1607 any_integratable = true;
1608 break;
1609 }
1610 }
1611 state.world.for_each_state_definition([&](dcon::state_definition_id sdef) {
1612 if(province::can_start_colony(state, nation_id, sdef)) {
1613 any_integratable = true;
1614 }
1615 });
1616 if(nations::can_expand_colony(state, nation_id) || any_integratable) {
1617 return 0;
1618 } else if(nations::is_losing_colonial_race(state, nation_id)) {
1619 return 1;
1620 } else {
1621 return 2;
1622 }
1623 }
1624 // TODO - when the player clicks on the colony icon and there are colonies to expand then we want to teleport their camera to the
1625 // colony's position & open the prov window
1626
1628 return tooltip_behavior::variable_tooltip;
1629 }
1630
1631 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1632 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1633 auto nation_fat_id = dcon::fatten(state.world, nation_id);
1634
1635 bool is_empty = true;
1636
1637 for(auto si : state.world.nation_get_state_ownership(nation_id)) {
1638 if(province::can_integrate_colony(state, si.get_state())) {
1639 text::add_line(state, contents, "countryalert_colonialgood_state", text::variable_type::region, si.get_state().id);
1640 is_empty = false;
1641 }
1642 }
1643
1644 state.world.for_each_state_definition([&](dcon::state_definition_id sdef) {
1645 if(province::can_start_colony(state, nation_id, sdef)) {
1646 text::add_line(state, contents, "alice_countryalert_colonialgood_start", text::variable_type::region, sdef);
1647 is_empty = false;
1648 }
1649 });
1650
1651 nation_fat_id.for_each_colonization([&](dcon::colonization_id colony) {
1652 auto sdef = state.world.colonization_get_state(colony);
1653 if(state.world.state_definition_get_colonization_stage(sdef) == 3) {
1654 text::add_line(state, contents, "countryalert_colonialgood_colony", text::variable_type::region, sdef);
1655 is_empty = false;
1656 } else if(province::can_invest_in_colony(state, nation_id, sdef)) {
1657 text::add_line(state, contents, "countryalert_colonialgood_invest", text::variable_type::region, sdef);
1658 is_empty = false;
1659 }
1660 auto lvl = state.world.colonization_get_level(colony);
1661 for(auto cols : state.world.state_definition_get_colonization(sdef)) {
1662 if(lvl < cols.get_level()) {
1663 text::add_line(state, contents, "countryalert_colonialbad_influence", text::variable_type::region, sdef);
1664 is_empty = false;
1665 }
1666 }
1667 });
1668
1669 if(is_empty) {
1670 text::add_line(state, contents, "countryalert_no_colonial");
1671 }
1672 }
1673};
1674
1676public:
1677 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1678 if(state.current_crisis == sys::crisis_type::none) {
1679 return 2;
1680 } else if(state.crisis_temperature > 0.8f) {
1681 return 1;
1682 } else {
1683 return 0;
1684 }
1685 }
1686
1688 return tooltip_behavior::variable_tooltip;
1689 }
1690
1691 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1697 text::add_to_substitution_map(sub, text::variable_type::time, int32_t(state.defines.crisis_cooldown_months));
1698 if(state.current_crisis_mode == sys::crisis_mode::inactive) {
1699 auto box = text::open_layout_box(contents);
1700 text::localised_format_box(state, contents, box, std::string_view("alice_crisis_inactive"), sub);
1701 text::close_layout_box(contents, box);
1702 } else if(state.current_crisis_mode == sys::crisis_mode::finding_attacker) {
1703 auto box = text::open_layout_box(contents);
1704 text::localised_format_box(state, contents, box, std::string_view("alice_crisis_finding_attacker"), sub);
1705 text::close_layout_box(contents, box);
1706 } else if(state.current_crisis_mode == sys::crisis_mode::finding_defender) {
1707 auto box = text::open_layout_box(contents);
1708 text::localised_format_box(state, contents, box, std::string_view("alice_crisis_finding_defender"), sub);
1709 text::close_layout_box(contents, box);
1710 } else if(state.current_crisis_mode == sys::crisis_mode::heating_up) {
1711 auto box = text::open_layout_box(contents);
1712 text::localised_format_box(state, contents, box, std::string_view("alice_crisis_heating_up"), sub);
1713 text::close_layout_box(contents, box);
1714 //atackers
1715 text::add_line(state, contents, std::string_view("alice_crisis_par_1"));
1716 for(const auto par : state.crisis_participants) {
1717 if(!par.merely_interested && par.supports_attacker) {
1718 text::add_line(state, contents, text::get_name(state, par.id));
1719 }
1720 }
1721 //defenders
1722 text::add_line(state, contents, std::string_view("alice_crisis_par_2"));
1723 for(const auto par : state.crisis_participants) {
1724 if(!par.merely_interested && !par.supports_attacker) {
1725 text::add_line(state, contents, text::get_name(state, par.id));
1726 }
1727 }
1728 //merely interested
1729 text::add_line(state, contents, std::string_view("alice_crisis_par_3"));
1730 for(const auto par : state.crisis_participants) {
1731 if(par.merely_interested) {
1732 text::add_line(state, contents, text::get_name(state, par.id));
1733 }
1734 }
1735 }
1736 if(state.last_crisis_end_date) {
1737 auto box = text::open_layout_box(contents);
1738 text::localised_format_box(state, contents, box, std::string_view("alice_last_crisis"), sub);
1739 text::close_layout_box(contents, box);
1740 }
1741 }
1742};
1743
1745public:
1746 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1748 return 0;
1749 } else if(rebel::sphere_member_has_ongoing_revolt(state, nation_id)) {
1750 return 2;
1751 } else {
1752 return 1;
1753 }
1754 }
1755
1757 return tooltip_behavior::variable_tooltip;
1758 }
1759
1760 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1761 auto n = retrieve<dcon::nation_id>(state, parent);
1762
1764 text::add_line(state, contents, std::string_view("countryalert_no_gpstatus"));
1765 } else {
1766 bool added_increase_header = false;
1767
1768 for(auto it : state.world.nation_get_gp_relationship_as_great_power(n)) {
1769 if((it.get_status() & nations::influence::is_banned) == 0) {
1770 if(it.get_influence() >= state.defines.increaseopinion_influence_cost
1773
1774 if(!added_increase_header)
1775 text::add_line(state, contents, std::string_view("countryalert_canincreaseopinion"));
1776 added_increase_header = true;
1777 text::nation_name_and_flag(state, it.get_influence_target(), contents, 15);
1778 } else if(!(it.get_influence_target().get_in_sphere_of()) &&
1779 it.get_influence() >= state.defines.addtosphere_influence_cost) {
1780 if(!added_increase_header)
1781 text::add_line(state, contents, std::string_view("countryalert_canincreaseopinion"));
1782 added_increase_header = true;
1783 text::nation_name_and_flag(state, it.get_influence_target(), contents, 15);
1784 } else if(it.get_influence_target().get_in_sphere_of()
1786 it.get_influence() >= state.defines.removefromsphere_influence_cost) {
1787 if(!added_increase_header)
1788 text::add_line(state, contents, std::string_view("countryalert_canincreaseopinion"));
1789 added_increase_header = true;
1790 text::nation_name_and_flag(state, it.get_influence_target(), contents, 15);
1791 }
1792 }
1793 }
1794 bool added_reb_header = false;
1795 for(auto m : state.world.in_nation) {
1796 if(state.world.nation_get_in_sphere_of(m) == n) {
1797 [&]() {
1798 for(auto fac : state.world.nation_get_rebellion_within(m)) {
1799 if(rebel::get_faction_brigades_active(state, fac.get_rebels()) > 0) {
1800 if(!added_reb_header)
1801 text::add_line(state, contents, std::string_view("a_alert_reb"));
1802 added_reb_header = true;
1803 text::nation_name_and_flag(state, m, contents, 15);
1804 return;
1805 }
1806 }
1807 }();
1808 }
1809 }
1810
1811 if(!added_increase_header && !added_reb_header)
1812 text::add_line(state, contents, std::string_view("alice_ca_cant_influence"));
1813 }
1814 }
1815};
1816
1818public:
1820 return tooltip_behavior::variable_tooltip;
1821 }
1822
1823 void on_create(sys::state& state) noexcept override {
1824 top_left_extension = ui::xy_pair{ 25, 3 };
1825 bottom_right_extension = ui::xy_pair{ 0, 2 };
1826 expanded_hitbox_text::on_create(state);
1827 }
1828
1829 void on_update(sys::state& state) noexcept override {
1830 auto points = nations::daily_research_points(state, retrieve<dcon::nation_id>(state, parent));
1831 set_text(state, text::format_float(points, 2));
1832 }
1833
1834 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1835 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1836 auto fat = dcon::fatten(state.world, nation_id);
1837
1838 auto tech_id = nations::current_research(state, nation_id);
1839
1840 auto total_pop = state.world.nation_get_demographics(nation_id, demographics::total);
1841 for(auto pt : state.world.in_pop_type) {
1842 auto rp = state.world.pop_type_get_research_points(pt);
1843 if(rp > 0 && state.world.nation_get_demographics(nation_id, demographics::to_key(state, pt)) > 0.0f) {
1844 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)));
1845
1847 text::add_to_substitution_map(sub1, text::variable_type::poptype, state.world.pop_type_get_name(pt));
1850 text::fp_two_places{ (state.world.nation_get_demographics(nation_id, demographics::to_key(state, pt)) / total_pop) * 100 });
1852 text::fp_two_places{ (state.world.pop_type_get_research_optimum(pt) * 100) });
1853
1854 auto box = text::open_layout_box(contents, 0);
1855 text::localised_format_box(state, contents, box, std::string_view("tech_daily_researchpoints_tooltip"), sub1);
1856 text::close_layout_box(contents, box);
1857 }
1858 }
1859 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::research_points, true);
1861
1862 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::research_points_modifier, true);
1864
1865 if(!bool(tech_id)) {
1866 auto box2 = text::open_layout_box(contents, 0);
1867 text::localised_single_sub_box(state, contents, box2, std::string_view("rp_accumulated"), text::variable_type::val,
1868 text::fp_one_place{fat.get_research_points()});
1869
1870 text::close_layout_box(contents, box2);
1871 }
1872 }
1873};
1874
1876public:
1877 uint8_t slot = 0;
1878 dcon::commodity_id commodity_id{};
1879 float amount = 0.f;
1880
1882 return tooltip_behavior::variable_tooltip;
1883 }
1884
1885 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1886 auto box = text::open_layout_box(contents, 0);
1887 text::add_to_layout_box(state, contents, box,
1888 text::produce_simple_string(state, state.world.commodity_get_name(commodity_id)), text::text_color::white);
1889 text::add_to_layout_box(state, contents, box, std::string_view(":"), text::text_color::white);
1890 text::add_space_to_layout_box(state, contents, box);
1892 text::close_layout_box(contents, box);
1893 }
1894};
1895
1897private:
1898 dcon::nation_id current_nation{};
1899 std::vector<topbar_commodity_xport_icon*> import_icons;
1900 std::vector<topbar_commodity_xport_icon*> export_icons;
1901 std::vector<topbar_commodity_xport_icon*> produced_icons;
1902 simple_text_element_base* atpeacetext = nullptr;
1903
1904public:
1905 void on_create(sys::state& state) noexcept override {
1906 window_element_base::on_create(state);
1907 base_data.position.y += 1;
1908
1909 auto bg_pic = make_element_by_type<background_image>(state, "bg_main_menus");
1910 background_pic = bg_pic.get();
1911 background_pic->base_data.position.y -= 1;
1912 add_child_to_back(std::move(bg_pic));
1913
1914 auto dpi_win = make_element_by_type<ui::diplomatic_message_topbar_listbox>(state, "alice_diplomessageicons_window");
1915 state.ui_state.request_topbar_listbox = dpi_win.get();
1916 add_child_to_front(std::move(dpi_win));
1917
1918 state.ui_state.topbar_window = this;
1919 on_update(state);
1920 }
1921
1922 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1923 if(name == "topbar_bg") {
1924 return partially_transparent_image::make_element_by_type_alias(state, id);
1925 } else if(name == "topbar_paper") {
1926 return partially_transparent_image::make_element_by_type_alias(state, id);
1927 } else if(name == "topbarbutton_production") {
1928 auto btn = make_element_by_type<topbar_production_tab_button>(state, id);
1929
1930 auto tab = make_element_by_type<production_window>(state, "country_production");
1931 state.ui_state.production_subwindow = state.ui_state.topbar_subwindow = btn->topbar_subwindow = tab.get();
1932 state.ui_state.root->add_child_to_back(std::move(tab));
1933 return btn;
1934 } else if(name == "topbarbutton_budget") {
1935 auto btn = make_element_by_type<topbar_budget_tab_button>(state, id);
1936
1937 auto tab = make_element_by_type<budget_window>(state, "country_budget");
1938 btn->topbar_subwindow = tab.get();
1939 state.ui_state.root->add_child_to_back(std::move(tab));
1940 return btn;
1941 } else if(name == "topbarbutton_tech") {
1942 auto btn = make_element_by_type<topbar_technology_tab_button>(state, id);
1943
1944 auto tab = make_element_by_type<technology_window>(state, "country_technology");
1945 btn->topbar_subwindow = tab.get();
1946
1947 state.ui_state.technology_subwindow = tab.get();
1948 state.ui_state.root->add_child_to_back(std::move(tab));
1949 return btn;
1950 } else if(name == "topbarbutton_politics") {
1951 auto btn = make_element_by_type<topbar_politics_tab_button>(state, id);
1952 auto tab = make_element_by_type<politics_window>(state, "country_politics");
1953 btn->topbar_subwindow = tab.get();
1954
1955 state.ui_state.politics_subwindow = tab.get();
1956 state.ui_state.root->add_child_to_back(std::move(tab));
1957 return btn;
1958 } else if(name == "topbarbutton_pops") {
1959 auto btn = make_element_by_type<topbar_population_view_button>(state, id);
1960 auto tab = make_element_by_type<population_window>(state, "country_pop");
1961 btn->topbar_subwindow = tab.get();
1962
1963 state.ui_state.population_subwindow = tab.get();
1964 state.ui_state.root->add_child_to_back(std::move(tab));
1965 return btn;
1966 } else if(name == "topbarbutton_trade") {
1967 auto btn = make_element_by_type<topbar_trade_tab_button>(state, id);
1968
1969 auto tab = make_element_by_type<trade_window>(state, "alice_country_trade");
1970 btn->topbar_subwindow = tab.get();
1971
1972 state.ui_state.trade_subwindow = tab.get();
1973 state.ui_state.root->add_child_to_back(std::move(tab));
1974 return btn;
1975 } else if(name == "topbarbutton_diplomacy") {
1976 auto btn = make_element_by_type<topbar_diplomacy_tab_button>(state, id);
1977
1978 auto tab = make_element_by_type<diplomacy_window>(state, "country_diplomacy");
1979 btn->topbar_subwindow = tab.get();
1980 state.ui_state.root->add_child_to_back(std::move(tab));
1981 return btn;
1982 } else if(name == "topbarbutton_military") {
1983 auto btn = make_element_by_type<topbar_military_tab_button>(state, id);
1984
1985 auto tab = make_element_by_type<military_window>(state, "country_military");
1986 btn->topbar_subwindow = tab.get();
1987 state.ui_state.root->add_child_to_back(std::move(tab));
1988 return btn;
1989 } else if(name == "button_speedup") {
1990 return make_element_by_type<topbar_speedup_button>(state, id);
1991 } else if(name == "button_speeddown") {
1992 return make_element_by_type<topbar_speeddown_button>(state, id);
1993 } else if(name == "pause_bg") {
1994 return make_element_by_type<topbar_pause_button>(state, id);
1995 } else if(name == "speed_indicator") {
1996 return make_element_by_type<topbar_speed_indicator>(state, id);
1997 } else if(name == "datetext") {
1998 return make_element_by_type<topbar_date_text>(state, id);
1999 } else if(name == "countryname") {
2000 return make_element_by_type<topbar_nation_name>(state, id);
2001 } else if(name == "player_flag") {
2002 return make_element_by_type<flag_button>(state, id);
2003 } else if(name == "country_prestige") {
2004 return make_element_by_type<topbar_nation_prestige_text>(state, id);
2005 } else if(name == "country_economic") {
2006 return make_element_by_type<topbar_nation_industry_score_text>(state, id);
2007 } else if(name == "country_military") {
2008 return make_element_by_type<topbar_nation_military_score_text>(state, id);
2009 } else if(name == "country_total") {
2010 return make_element_by_type<nation_total_score_text>(state, id);
2011 } else if(name == "country_colonial_power") {
2012 return make_element_by_type<topbar_nation_colonial_power_text>(state, id);
2013 } else if(name == "selected_prestige_rank") {
2014 return make_element_by_type<nation_prestige_rank_text>(state, id);
2015 } else if(name == "selected_industry_rank") {
2016 return make_element_by_type<nation_industry_rank_text>(state, id);
2017 } else if(name == "selected_military_rank") {
2018 return make_element_by_type<nation_military_rank_text>(state, id);
2019 } else if(name == "nation_totalrank") {
2020 return make_element_by_type<nation_rank_text>(state, id);
2021 } else if(name == "topbar_flag_overlay") {
2022 return make_element_by_type<nation_flag_frame>(state, id);
2023 } else if(name == "alert_building_factories") {
2024 return make_element_by_type<topbar_building_factories_icon>(state, id);
2025 } else if(name == "alert_closed_factories") {
2026 return make_element_by_type<topbar_closed_factories_icon>(state, id);
2027 } else if(name == "alert_unemployed_workers") {
2028 return make_element_by_type<topbar_unemployment_icon>(state, id);
2029 } else if(name == "budget_linechart") {
2030 return make_element_by_type<topbar_budget_line_graph>(state, id);
2031 } else if(name == "alice_budget_warning") {
2032 return make_element_by_type<topbar_budget_warning>(state, id);
2033 } else if(name == "budget_funds") {
2034 return make_element_by_type<topbar_treasury_text>(state, id);
2035 } else if(name == "topbar_tech_progress") {
2036 return make_element_by_type<nation_technology_research_progress>(state, id);
2037 } else if(name == "tech_current_research") {
2038 return make_element_by_type<nation_current_research_text>(state, id);
2039 } else if(name == "topbar_researchpoints_value") {
2040 return make_element_by_type<topbar_nation_daily_research_points_text>(state, id);
2041 } else if(name == "tech_literacy_value") {
2042 return make_element_by_type<topbar_nation_literacy_text>(state, id);
2043 } else if(name == "politics_party_icon") {
2044 return make_element_by_type<nation_ruling_party_ideology_plupp>(state, id);
2045 } else if(name == "politics_ruling_party") {
2046 return make_element_by_type<nation_ruling_party_text>(state, id);
2047 } else if(name == "politics_supressionpoints_value") {
2048 return make_element_by_type<nation_suppression_points_text>(state, id);
2049 } else if(name == "politics_infamy_value") {
2050 return make_element_by_type<topbar_nation_infamy_text>(state, id);
2051 } else if(name == "alert_can_do_reforms") {
2052 return make_element_by_type<topbar_available_reforms_icon>(state, id);
2053 } else if(name == "alert_can_do_decisions") {
2054 return make_element_by_type<topbar_available_decisions_icon>(state, id);
2055 } else if(name == "alert_is_in_election") {
2056 return make_element_by_type<topbar_ongoing_election_icon>(state, id);
2057 } else if(name == "alert_have_rebels") {
2058 return make_element_by_type<topbar_rebels_icon>(state, id);
2059 } else if(name == "population_total_value") {
2060 return make_element_by_type<topbar_nation_population_text>(state, id);
2061 } else if(name == "topbar_focus_value") {
2062 return make_element_by_type<topbar_nation_focus_allocation_text>(state, id);
2063 } else if(name == "population_avg_mil_value") {
2064 return make_element_by_type<topbar_nation_militancy_text>(state, id);
2065 } else if(name == "population_avg_con_value") {
2066 return make_element_by_type<topbar_nation_consciousness_text>(state, id);
2067 } else if(name == "diplomacy_status") {
2068 auto ptr = make_element_by_type<topbar_at_peace_text>(state, id);
2069 atpeacetext = ptr.get();
2070 return ptr;
2071 } else if(name == "diplomacy_at_war") {
2072 auto ptr = make_element_by_type<overlapping_enemy_flags>(state, id);
2073 ptr->base_data.position.y -= ptr->base_data.position.y / 4;
2074 ptr->base_data.size.x /= 2;
2075 return ptr;
2076 } else if(name == "diplomacy_diplopoints_value") {
2077 return make_element_by_type<topbar_nation_diplomatic_points_text>(state, id);
2078 } else if(name == "alert_colony") {
2079 return make_element_by_type<topbar_colony_icon>(state, id);
2080 } else if(name == "alert_crisis") {
2081 return make_element_by_type<topbar_crisis_icon>(state, id);
2082 } else if(name == "alert_can_increase_opinion") {
2083 return make_element_by_type<topbar_sphere_icon>(state, id);
2084 } else if(name == "alert_loosing_gp") {
2085 return make_element_by_type<topbar_losing_gp_status_icon>(state, id);
2086 } else if(name == "military_army_value") {
2087 return make_element_by_type<topbar_nation_brigade_allocation_text>(state, id);
2088 } else if(name == "military_navy_value") {
2089 return make_element_by_type<topbar_nation_navy_allocation_text>(state, id);
2090 } else if(name == "military_manpower_value") {
2091 return make_element_by_type<topbar_nation_mobilization_size_text>(state, id);
2092 } else if(name == "military_leadership_value") {
2093 return make_element_by_type<topbar_nation_leadership_points_text>(state, id);
2094 } else if(name == "topbar_outlinerbutton" || name == "topbar_outlinerbutton_bg") {
2095 // Fake button isn't used - we create it manually instead...
2096 return make_element_by_type<invisible_element>(state, id);
2097 } else if(name.substr(0, 13) == "topbar_import") {
2098 auto ptr = make_element_by_type<topbar_commodity_xport_icon>(state, id);
2099 std::string var = std::string{name.substr(13)};
2100 var.empty() ? ptr->slot = uint8_t(0) : ptr->slot = uint8_t(std::stoi(var));
2101 import_icons.push_back(ptr.get());
2102 return ptr;
2103 } else if(name.substr(0, 13) == "topbar_export") {
2104 auto ptr = make_element_by_type<topbar_commodity_xport_icon>(state, id);
2105 std::string var = std::string{name.substr(13)};
2106 var.empty() ? ptr->slot = uint8_t(0) : ptr->slot = uint8_t(std::stoi(var));
2107 export_icons.push_back(ptr.get());
2108 return ptr;
2109 } else if(name.substr(0, 15) == "topbar_produced") {
2110 auto ptr = make_element_by_type<topbar_commodity_xport_icon>(state, id);
2111 std::string var = std::string{name.substr(15)};
2112 var.empty() ? ptr->slot = uint8_t(0) : ptr->slot = uint8_t(std::stoi(var));
2113 produced_icons.push_back(ptr.get());
2114 return ptr;
2115 } else if (name == "selected_military_icon") {
2116 return make_element_by_type<military_score_icon>(state, id);
2117 } else {
2118 return nullptr;
2119 }
2120 }
2121
2122 void on_update(sys::state& state) noexcept override {
2123 atpeacetext->set_visible(state, !state.world.nation_get_is_at_war(state.local_player_nation));
2124 if(state.local_player_nation != current_nation) {
2125 current_nation = state.local_player_nation;
2126 Cyto::Any payload = current_nation;
2127 impl_set(state, payload);
2128 }
2129
2130 for(auto& e : export_icons)
2131 e->set_visible(state, false);
2132 for(auto& e : import_icons)
2133 e->set_visible(state, false);
2134 for(auto& e : produced_icons)
2135 e->set_visible(state, false);
2136
2137 {
2138 std::map<float, int32_t> v;
2139 for(dcon::commodity_id cid : state.world.in_commodity) {
2140 if(sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::military_goods &&
2141 sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::raw_material_goods &&
2142 sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::industrial_goods &&
2143 sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::consumer_goods &&
2144 sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::industrial_and_consumer_goods)
2145 return;
2146 float produced = state.world.nation_get_domestic_market_pool(state.local_player_nation, cid);
2147 float consumed = state.world.nation_get_real_demand(state.local_player_nation, cid) *
2148 state.world.nation_get_demand_satisfaction(state.local_player_nation, cid);
2149 v.insert({produced - consumed, cid.index()});
2150 }
2151
2152 uint8_t slot = 0;
2153 for(auto it = std::rbegin(v); it != std::rend(v); it++) {
2154 for(auto const& e : export_icons)
2155 if(e->slot == slot) {
2156 dcon::commodity_id cid = dcon::commodity_id(dcon::commodity_id::value_base_t(it->second));
2157 e->frame = state.world.commodity_get_icon(cid);
2158 e->commodity_id = cid;
2159 e->amount = it->first;
2160 e->set_visible(state, true);
2161 }
2162 ++slot;
2163 }
2164 slot = 0;
2165 for(auto it = v.begin(); it != v.end(); it++) {
2166 for(auto const& e : import_icons)
2167 if(e->slot == slot) {
2168 dcon::commodity_id cid = dcon::commodity_id(dcon::commodity_id::value_base_t(it->second));
2169 e->frame = state.world.commodity_get_icon(cid);
2170 e->commodity_id = cid;
2171 e->amount = it->first;
2172 e->set_visible(state, true);
2173 }
2174 ++slot;
2175 }
2176 }
2177
2178 {
2179 std::map<float, int32_t> v;
2180 for(dcon::commodity_id cid : state.world.in_commodity) {
2181 if(sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::military_goods &&
2182 sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::raw_material_goods &&
2183 sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::industrial_goods &&
2184 sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::consumer_goods &&
2185 sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::industrial_and_consumer_goods)
2186 return;
2187 v.insert({state.world.nation_get_domestic_market_pool(state.local_player_nation, cid), cid.index()});
2188 }
2189
2190 uint8_t slot = 0;
2191 for(auto it = std::rbegin(v); it != std::rend(v); it++) {
2192 for(auto const& e : produced_icons)
2193 if(e->slot == slot) {
2194 dcon::commodity_id cid = dcon::commodity_id(dcon::commodity_id::value_base_t(it->second));
2195 e->frame = state.world.commodity_get_icon(cid);
2196 e->commodity_id = cid;
2197 e->amount = it->first;
2198 e->set_visible(state, true);
2199 }
2200 ++slot;
2201 }
2202 }
2203 }
2204
2205 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
2206 if(state.ui_state.topbar_subwindow->is_visible()) {
2207 background_pic->set_visible(state, true);
2208 } else {
2209 background_pic->set_visible(state, false);
2210 }
2211 window_element_base::render(state, x, y);
2212 }
2213
2214 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
2215 if(payload.holds_type<dcon::nation_id>()) {
2216 payload.emplace<dcon::nation_id>(state.local_player_nation);
2217 return message_result::consumed;
2218 } else {
2219 return message_result::unseen;
2220 }
2221 }
2222
2223private:
2224 element_base* background_pic = nullptr;
2225
2226 friend class topbar_tab_button;
2227};
2228
2229} // namespace ui
void render(sys::state &state, int32_t x, int32_t y) noexcept override
Definition: gui_topbar.hpp:738
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:161
void on_update(sys::state &state) noexcept override
Definition: gui_topbar.hpp:166
sound::audio_instance & get_click_sound(sys::state &state) noexcept override
Definition: gui_topbar.hpp:785
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
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:871
sound::audio_instance & get_click_sound(sys::state &state) noexcept override
Definition: gui_topbar.hpp:804
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:810
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:602
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:598
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:124
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:120
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:513
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:530
void on_update(sys::state &state) noexcept override
Definition: gui_topbar.hpp:523
void on_create(sys::state &state) noexcept override
Definition: gui_topbar.hpp:517
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:568
void on_update(sys::state &state) noexcept override
Definition: gui_topbar.hpp:559
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:564
void on_create(sys::state &state) noexcept override
Definition: gui_topbar.hpp:553
void on_create(sys::state &state) noexcept override
Definition: gui_topbar.hpp:408
void on_update(sys::state &state) noexcept override
Definition: gui_topbar.hpp:414
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:426
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:405
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:88
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:92
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:226
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:222
void on_create(sys::state &state) noexcept override
Definition: gui_topbar.hpp:214
void on_update(sys::state &state) noexcept override
Definition: gui_topbar.hpp:219
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:713
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:709
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:191
void on_create(sys::state &state) noexcept override
Definition: gui_topbar.hpp:178
void on_update(sys::state &state) noexcept override
Definition: gui_topbar.hpp:184
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:195
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:490
void on_create(sys::state &state) noexcept override
Definition: gui_topbar.hpp:473
void on_update(sys::state &state) noexcept override
Definition: gui_topbar.hpp:479
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:486
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:104
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:108
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:653
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:657
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:31
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:27
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:615
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:619
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:270
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:273
void on_update(sys::state &state) noexcept override
Definition: gui_topbar.hpp:245
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:47
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:51
void on_update(sys::state &state) noexcept override
Definition: gui_topbar.hpp:44
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
Definition: gui_topbar.hpp:911
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:915
void button_action(sys::state &state) noexcept override
Definition: gui_topbar.hpp:890
void on_create(sys::state &state) noexcept override
Definition: gui_topbar.hpp:878
void on_update(sys::state &state) noexcept override
Definition: gui_topbar.hpp:902
sound::audio_instance & get_click_sound(sys::state &state) noexcept override
Definition: gui_topbar.hpp:883
sound::audio_instance & get_click_sound(sys::state &state) noexcept override
Definition: gui_topbar.hpp:798
sound::audio_instance & get_click_sound(sys::state &state) noexcept override
Definition: gui_topbar.hpp:816
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:861
sound::audio_instance & get_click_sound(sys::state &state) noexcept override
Definition: gui_topbar.hpp:835
void button_action(sys::state &state) noexcept override
Definition: gui_topbar.hpp:839
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:864
sound::audio_instance & get_click_sound(sys::state &state) noexcept override
Definition: gui_topbar.hpp:822
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
Definition: gui_topbar.hpp:993
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:999
tooltip_behavior has_tooltip(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:977
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:980
void button_action(sys::state &state) noexcept override
Definition: gui_topbar.hpp:969
void on_create(sys::state &state) noexcept override
Definition: gui_topbar.hpp:963
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:776
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:773
void button_action(sys::state &state) noexcept override
Definition: gui_topbar.hpp:752
element_base * topbar_subwindow
Definition: gui_topbar.hpp:780
bool is_active(sys::state &state) noexcept override
Definition: gui_topbar.hpp:769
sound::audio_instance & get_click_sound(sys::state &state) noexcept override
Definition: gui_topbar.hpp:828
sound::audio_instance & get_click_sound(sys::state &state) noexcept override
Definition: gui_topbar.hpp:791
void on_update(sys::state &state) noexcept override
Definition: gui_topbar.hpp:294
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_topbar.hpp:323
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_topbar.hpp:320
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
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)
bool nation_is_constructing_factories(sys::state &state, dcon::nation_id n)
Definition: economy.cpp:404
bool nation_has_closed_factories(sys::state &state, dcon::nation_id n)
Definition: economy.cpp:408
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:1074
int32_t mobilized_regiments_created_from_province(sys::state &state, dcon::province_id p)
Definition: military.cpp:657
int32_t mobilized_regiments_possible_from_province(sys::state &state, dcon::province_id p)
Definition: military.cpp:959
int32_t naval_supply_points(sys::state &state, dcon::nation_id n)
Definition: military.cpp:1071
constexpr uint8_t is_banned
Definition: nations.hpp:179
constexpr uint8_t level_friendly
Definition: nations.hpp:168
constexpr uint8_t level_in_sphere
Definition: nations.hpp:169
constexpr uint8_t level_mask
Definition: nations.hpp:163
float colonial_points_from_naval_bases(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:674
status get_status(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:580
bool is_great_power(sys::state const &state, dcon::nation_id id)
Definition: nations.cpp:503
int32_t free_colonial_points(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:739
bool is_losing_colonial_race(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:774
float used_colonial_points(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:717
bool can_expand_colony(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:759
float diplomatic_points(sys::state const &state, dcon::nation_id n)
Definition: nations.cpp:645
float prestige_score(sys::state const &state, dcon::nation_id n)
Definition: nations.cpp:396
float colonial_points_from_technology(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:708
float monthly_diplomatic_points(sys::state const &state, dcon::nation_id n)
Definition: nations.cpp:649
float daily_research_points(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:254
bool has_decision_available(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:876
int64_t get_monthly_pop_increase_of_nation(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:38
bool sphereing_progress_is_possible(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:785
int32_t national_focuses_in_use(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:634
bool has_reform_available(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:829
dcon::technology_id current_research(sys::state const &state, dcon::nation_id n)
Definition: nations.cpp:606
int32_t max_national_focuses(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:618
float get_treasury(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:1042
float colonial_points_from_ships(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:655
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:593
bool can_start_colony(sys::state &state, dcon::nation_id n, dcon::state_definition_id d)
Definition: province.cpp:1097
bool can_invest_in_colony(sys::state &state, dcon::nation_id n, dcon::state_definition_id d)
Definition: province.cpp:1023
int32_t get_faction_brigades_active(sys::state &state, dcon::rebel_faction_id r)
Definition: rebels.cpp:1016
bool sphere_member_has_ongoing_revolt(sys::state &state, dcon::nation_id n)
Definition: rebels.cpp:998
std::string rebel_name(sys::state &state, dcon::rebel_faction_id reb)
Definition: rebels.cpp:1274
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 add_line_break_to_layout_box(sys::state &state, layout_base &dest, layout_box &box)
Definition: text.cpp:1147
void add_to_layout_box(sys::state &state, layout_base &dest, layout_box &box, embedded_flag ico)
Definition: text.cpp:1165
std::string format_ratio(int32_t left, int32_t right)
Definition: text.cpp:1064
layout_box open_layout_box(layout_base &dest, int32_t indent)
Definition: text.cpp:1799
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:1888
void localised_format_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view key, text::substitution_map const &sub)
Definition: text.cpp:1880
std::string prettify(int64_t num)
Definition: text.cpp:762
endless_layout create_endless_layout(sys::state &state, layout &dest, layout_parameters const &params)
Definition: text.cpp:1100
std::string format_float(float num, size_t digits)
Definition: text.cpp:981
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
Definition: text.cpp:1899
void add_line_break_to_layout(sys::state &state, columnar_layout &dest)
Definition: text.cpp:1152
void add_to_substitution_map(substitution_map &mp, variable_type key, substitution value)
Definition: text.cpp:1068
void add_divider_to_layout_box(sys::state &state, layout_base &dest, layout_box &box)
Definition: text.cpp:2098
std::string get_dynamic_state_name(sys::state &state, dcon::state_instance_id state_id)
Definition: text.cpp:837
ankerl::unordered_dense::map< uint32_t, substitution > substitution_map
Definition: text.hpp:794
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
Definition: text.cpp:617
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:1788
void nation_name_and_flag(sys::state &state, dcon::nation_id n, layout_base &dest, int32_t indent)
Definition: text.cpp:2104
std::string prettify_currency(float num)
Definition: text.cpp:702
void close_layout_box(columnar_layout &dest, layout_box &box)
Definition: text.cpp:1807
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:1161
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
sys::virtual_key shortcut
union ui::element_data::internal_data data
element_base * technology_subwindow
element_base * trade_subwindow
element_base * topbar_window
element_base * topbar_subwindow
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