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 void on_update(sys::state& state) noexcept override {
1169 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1170 bool has_unemployed = false;
1171 // Only care about factory workers for displaying the red alert
1172 std::array<dcon::pop_type_id, 2> factory_workers{
1173 state.culture_definitions.primary_factory_worker,
1174 state.culture_definitions.secondary_factory_worker
1175 };
1176 for(auto pt : factory_workers) {
1177 for(auto si : state.world.nation_get_state_ownership(nation_id)) {
1178 auto state_instance = si.get_state();
1179 auto total = state_instance.get_demographics(demographics::to_key(state, pt));
1180 auto unemployed = total - state_instance.get_demographics(demographics::to_employment_key(state, pt));
1181 if(unemployed >= 1.0f) {
1182 has_unemployed = true;
1183 break;
1184 }
1185 }
1186 if(has_unemployed)
1187 break;
1188 }
1189 frame = has_unemployed ? 0 : 1;
1190 }
1191
1194 }
1195
1196 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1197 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1198 bool header = false;
1199 std::array<dcon::pop_type_id, 2> factory_workers{
1200 state.culture_definitions.primary_factory_worker,
1201 state.culture_definitions.secondary_factory_worker
1202 };
1203 for(auto pt : factory_workers) {
1204 for(auto si : state.world.nation_get_state_ownership(nation_id)) {
1205 auto state_instance = si.get_state();
1206 auto total = state_instance.get_demographics(demographics::to_key(state, pt));
1207 auto unemployed = total - state_instance.get_demographics(demographics::to_employment_key(state, pt));
1208 if(unemployed >= 1.f) {
1209 if(!header) {
1210 text::add_line(state, contents, "remove_countryalert_hasunemployedworkers");
1211 header = true;
1212 }
1215 text::add_to_substitution_map(sub, text::variable_type::type, state.world.pop_type_get_name(pt));
1216 auto state_name = text::get_dynamic_state_name(state, state_instance);
1219 auto box = text::open_layout_box(contents);
1220 text::localised_format_box(state, contents, box, "topbar_unemployed", sub);
1221 text::close_layout_box(contents, box);
1222 }
1223 }
1224 }
1225 std::array<dcon::pop_type_id, 2> rgo_workers{
1226 state.culture_definitions.farmers,
1227 state.culture_definitions.laborers
1228 };
1229 for(auto pt : rgo_workers) {
1230 for(auto si : state.world.nation_get_state_ownership(nation_id)) {
1231 auto state_instance = si.get_state();
1232 auto total = state_instance.get_demographics(demographics::to_key(state, pt));
1233 auto unemployed = total - state_instance.get_demographics(demographics::to_employment_key(state, pt));
1234 if(unemployed >= 1.f) {
1235 if(!header) {
1236 text::add_line(state, contents, "alice_rgo_unemployment_country_alert");
1237 header = true;
1238 }
1241 text::add_to_substitution_map(sub, text::variable_type::type, state.world.pop_type_get_name(pt));
1242 auto state_name = text::get_dynamic_state_name(state, state_instance);
1245 auto box = text::open_layout_box(contents);
1246 text::localised_format_box(state, contents, box, "topbar_unemployed", sub);
1247 text::close_layout_box(contents, box);
1248 }
1249 }
1250 }
1251 if(!header) {
1252 text::add_line(state, contents, "countryalert_no_hasunemployedworkers");
1253 }
1254 }
1255};
1256
1258public:
1259 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1260 return int32_t(!nations::has_reform_available(state, nation_id));
1261 }
1262
1265 }
1266
1267 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1268 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1269 auto box = text::open_layout_box(contents, 0);
1270 if(!nations::has_reform_available(state, nation_id)) {
1271 text::localised_format_box(state, contents, box, std::string_view("countryalert_no_candoreforms"),
1273 } else if(nations::has_reform_available(state, nation_id)) {
1274 text::localised_format_box(state, contents, box, std::string_view("countryalert_candoreforms"), text::substitution_map{});
1275 text::add_divider_to_layout_box(state, contents, box);
1276 // Display Avaliable Reforms
1277 // Mostly a copy of nations::has_reform_avaliable
1278 auto last_date = state.world.nation_get_last_issue_or_reform_change(nation_id);
1279 if(bool(last_date) && (last_date + int32_t(state.defines.min_delay_between_reforms * 30.0f)) > state.current_date) {
1280 text::close_layout_box(contents, box);
1281 return;
1282 }
1283 if(state.world.nation_get_is_civilized(nation_id)) {
1284 for(auto i : state.culture_definitions.political_issues) {
1285 for(auto o : state.world.issue_get_options(i)) {
1286 if(o && politics::can_enact_political_reform(state, nation_id, o)) {
1287 auto fat_id = dcon::fatten(state.world, o);
1288 text::add_to_layout_box(state, contents, box, fat_id.get_parent_issue().get_name());
1289 text::add_to_layout_box(state, contents, box, std::string_view(": "));
1290 text::add_to_layout_box(state, contents, box, fat_id.get_name());
1292 }
1293 }
1294 }
1295
1296 for(auto i : state.culture_definitions.social_issues) {
1297 for(auto o : state.world.issue_get_options(i)) {
1298 if(o && politics::can_enact_social_reform(state, nation_id, o)) {
1299 auto fat_id = dcon::fatten(state.world, o);
1300 text::add_to_layout_box(state, contents, box, fat_id.get_parent_issue().get_name());
1301 text::add_to_layout_box(state, contents, box, std::string_view(": "));
1302 text::add_to_layout_box(state, contents, box, fat_id.get_name());
1304 }
1305 }
1306 }
1307
1308 text::close_layout_box(contents, box);
1309 return;
1310 } else {
1311 for(auto i : state.culture_definitions.military_issues) {
1312 for(auto o : state.world.reform_get_options(i)) {
1313 if(o && politics::can_enact_military_reform(state, nation_id, o)) {
1314 auto fat_id = dcon::fatten(state.world, o);
1315 text::add_to_layout_box(state, contents, box, fat_id.get_parent_reform().get_name());
1316 text::add_to_layout_box(state, contents, box, std::string_view(": "));
1317 text::add_to_layout_box(state, contents, box, fat_id.get_name());
1319 }
1320 }
1321 }
1322
1323 for(auto i : state.culture_definitions.economic_issues) {
1324 for(auto o : state.world.reform_get_options(i)) {
1325 if(o && politics::can_enact_economic_reform(state, nation_id, o)) {
1326 auto fat_id = dcon::fatten(state.world, o);
1327 text::add_to_layout_box(state, contents, box, fat_id.get_parent_reform().get_name());
1328 text::add_to_layout_box(state, contents, box, std::string_view(": "));
1329 text::add_to_layout_box(state, contents, box, fat_id.get_name());
1331 }
1332 }
1333 }
1334 }
1335 }
1336 text::close_layout_box(contents, box);
1337 }
1338
1339 void button_action(sys::state& state) noexcept override {
1340 auto const override_and_show_tab = [&]() {
1341 state.ui_state.politics_subwindow->set_visible(state, true);
1343
1344 Cyto::Any defs = Cyto::make_any<politics_window_tab>(politics_window_tab::reforms);
1345 state.ui_state.politics_subwindow->impl_get(state, defs);
1346
1347 state.ui_state.root->move_child_to_front(state.ui_state.politics_subwindow);
1348 state.ui_state.topbar_subwindow = state.ui_state.politics_subwindow;
1349 };
1350
1351 if(state.ui_state.topbar_subwindow->is_visible()) {
1352 state.ui_state.topbar_subwindow->set_visible(state, false);
1353 if(state.ui_state.topbar_subwindow != state.ui_state.politics_subwindow)
1354 override_and_show_tab();
1355 } else {
1356 override_and_show_tab();
1357 }
1358 }
1359
1360};
1361
1363public:
1364 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1365 return int32_t(!nations::has_decision_available(state, nation_id));
1366 }
1367
1370 }
1371
1372 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1373 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1374 if(!nations::has_decision_available(state, nation_id)) {
1375 text::add_line(state, contents, "countryalert_no_candodecisions");
1376 } else {
1377 text::add_line(state, contents, "countryalert_candodecisions");
1378
1380 produce_decision_substitutions(state, m, state.local_player_nation);
1381
1382 state.world.for_each_decision([&](dcon::decision_id di) {
1383 if(nation_id != state.local_player_nation || !state.world.decision_get_hide_notification(di)) {
1384 auto lim = state.world.decision_get_potential(di);
1385 if(!lim || trigger::evaluate(state, lim, trigger::to_generic(nation_id), trigger::to_generic(nation_id), 0)) {
1386 auto allow = state.world.decision_get_allow(di);
1387 if(!allow || trigger::evaluate(state, allow, trigger::to_generic(nation_id), trigger::to_generic(nation_id), 0)) {
1388 auto fat_id = dcon::fatten(state.world, di);
1389 auto box = text::open_layout_box(contents);
1390 text::add_to_layout_box(state, contents, box, fat_id.get_name(), m);
1391 text::close_layout_box(contents, box);
1392 }
1393 }
1394 }
1395 });
1396 }
1397 }
1398
1399 void button_action(sys::state& state) noexcept override {
1400 auto const override_and_show_tab = [&]() {
1401 state.ui_state.politics_subwindow->set_visible(state, true);
1403
1404 Cyto::Any defs = Cyto::make_any<politics_window_tab>(politics_window_tab::decisions);
1405 state.ui_state.politics_subwindow->impl_get(state, defs);
1406
1407 state.ui_state.root->move_child_to_front(state.ui_state.politics_subwindow);
1408 state.ui_state.topbar_subwindow = state.ui_state.politics_subwindow;
1409 };
1410
1411 if(state.ui_state.topbar_subwindow->is_visible()) {
1412 state.ui_state.topbar_subwindow->set_visible(state, false);
1413 if(state.ui_state.topbar_subwindow != state.ui_state.politics_subwindow)
1414 override_and_show_tab();
1415 } else {
1416 override_and_show_tab();
1417 }
1418 }
1419
1420};
1421
1423public:
1424 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1425 return int32_t(!politics::is_election_ongoing(state, nation_id));
1426 }
1427
1429 return tooltip_behavior::variable_tooltip;
1430 }
1431
1432 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1433 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1434 auto box = text::open_layout_box(contents, 0);
1435 if(politics::has_elections(state, nation_id)) {
1436 if(!politics::is_election_ongoing(state, nation_id)) {
1437 text::localised_format_box(state, contents, box, std::string_view("countryalert_no_isinelection"),
1439 } else if(politics::is_election_ongoing(state, nation_id)) {
1441 text::add_to_substitution_map(sub, text::variable_type::date, dcon::fatten(state.world, nation_id).get_election_ends());
1442 text::localised_format_box(state, contents, box, std::string_view("countryalert_isinelection"), sub);
1443 }
1444 } else {
1445 text::localised_format_box(state, contents, box, std::string_view("term_for_life"));
1446 }
1447 text::close_layout_box(contents, box);
1448 }
1449};
1450
1452public:
1453 void on_update(sys::state& state) noexcept override {
1454 for(auto rf : state.world.nation_get_rebellion_within(state.local_player_nation)) {
1455 auto org = rf.get_rebels().get_organization();
1456 if(org >= 0.01f) {
1457 frame = 0;
1458 return;
1459 }
1460 }
1461 frame = 1;
1462 }
1463
1465 return tooltip_behavior::variable_tooltip;
1466 }
1467
1468 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1469 bool showed_title = false;
1470
1471 for(auto rf : state.world.nation_get_rebellion_within(state.local_player_nation)) {
1472 auto org = rf.get_rebels().get_organization();
1473 if(org >= 0.01f) {
1474 if(!showed_title) {
1475 text::add_line(state, contents, "countryalert_haverebels");
1477 showed_title = true;
1478 }
1479 auto rebelname = rebel::rebel_name(state, rf.get_rebels());
1480 auto rebelsize = rf.get_rebels().get_possible_regiments();
1481
1482 text::add_line(state, contents, "topbar_faction",
1483 text::variable_type::name, std::string_view{ rebelname },
1486 }
1487 }
1488 }
1489
1490 void button_action(sys::state& state) noexcept override {
1491 auto const override_and_show_tab = [&]() {
1492 state.ui_state.politics_subwindow->set_visible(state, true);
1494
1495 Cyto::Any defs = Cyto::make_any<politics_window_tab>(politics_window_tab::movements);
1496 state.ui_state.politics_subwindow->impl_get(state, defs);
1497
1498 state.ui_state.root->move_child_to_front(state.ui_state.politics_subwindow);
1499 state.ui_state.topbar_subwindow = state.ui_state.politics_subwindow;
1500 };
1501
1502 if(state.ui_state.topbar_subwindow->is_visible()) {
1503 state.ui_state.topbar_subwindow->set_visible(state, false);
1504 if(state.ui_state.topbar_subwindow != state.ui_state.politics_subwindow)
1505 override_and_show_tab();
1506 } else {
1507 override_and_show_tab();
1508 }
1509 }
1510
1511};
1512
1514 uint32_t index = 0;
1515
1516 dcon::province_id get_state_def_province(sys::state& state, dcon::state_definition_id sdef) noexcept {
1517 for(auto const p : state.world.state_definition_get_abstract_state_membership(sdef)) {
1518 if(!p.get_province().get_nation_from_province_ownership()) {
1519 return p.get_province();
1520 }
1521 }
1522 return dcon::province_id{};
1523 }
1524public:
1525 void button_action(sys::state& state) noexcept override {
1526 std::vector<dcon::province_id> provinces;
1527 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1528 auto nation_fat_id = dcon::fatten(state.world, nation_id);
1529 for(auto si : state.world.nation_get_state_ownership(nation_id)) {
1530 if(province::can_integrate_colony(state, si.get_state())) {
1531 provinces.push_back(si.get_state().get_capital());
1532 }
1533 }
1534
1535 state.world.for_each_state_definition([&](dcon::state_definition_id sdef) {
1536 if(province::can_start_colony(state, nation_id, sdef)) {
1537 dcon::province_id province;
1538 for(auto p : state.world.state_definition_get_abstract_state_membership(sdef)) {
1539 if(!p.get_province().get_nation_from_province_ownership()) {
1540 province = p.get_province().id;
1541 break;
1542 }
1543 }
1544 if(province) {
1545 provinces.push_back(province);
1546 }
1547 }
1548 });
1549
1550 nation_fat_id.for_each_colonization([&](dcon::colonization_id colony) {
1551 auto sdef = state.world.colonization_get_state(colony);
1552 if(state.world.state_definition_get_colonization_stage(sdef) == 3) { //make protectorate
1553 provinces.push_back(get_state_def_province(state, sdef));
1554 } else if(province::can_invest_in_colony(state, nation_id, sdef)) { //invest
1555 provinces.push_back(get_state_def_province(state, sdef));
1556 } else { //losing rase
1557 auto lvl = state.world.colonization_get_level(colony);
1558 for(auto cols : state.world.state_definition_get_colonization(sdef)) {
1559 if(lvl < cols.get_level()) {
1560 provinces.push_back(get_state_def_province(state, sdef));
1561 break;
1562 }
1563 }
1564 }
1565 });
1566 if(!provinces.empty()) {
1567 index++;
1568 if(index >= uint32_t(provinces.size())) {
1569 index = 0;
1570 }
1571 if(auto prov = provinces[index]; prov && prov.value < state.province_definitions.first_sea_province.value) {
1572 sound::play_interface_sound(state, sound::get_click_sound(state), state.user_settings.interface_volume * state.user_settings.master_volume);
1573 state.map_state.set_selected_province(prov);
1574 static_cast<ui::province_view_window*>(state.ui_state.province_window)->set_active_province(state, prov);
1575 if(state.map_state.get_zoom() < map::zoom_very_close)
1576 state.map_state.zoom = map::zoom_very_close;
1577 state.map_state.center_map_on_province(state, prov);
1578 }
1579 }
1580 }
1581
1582 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1583 bool any_integratable = false;
1584 for(auto si : state.world.nation_get_state_ownership(nation_id)) {
1585 if(province::can_integrate_colony(state, si.get_state())) {
1586 any_integratable = true;
1587 break;
1588 }
1589 }
1590 state.world.for_each_state_definition([&](dcon::state_definition_id sdef) {
1591 if(province::can_start_colony(state, nation_id, sdef)) {
1592 any_integratable = true;
1593 }
1594 });
1595 if(nations::can_expand_colony(state, nation_id) || any_integratable) {
1596 return 0;
1597 } else if(nations::is_losing_colonial_race(state, nation_id)) {
1598 return 1;
1599 } else {
1600 return 2;
1601 }
1602 }
1603 // TODO - when the player clicks on the colony icon and there are colonies to expand then we want to teleport their camera to the
1604 // colony's position & open the prov window
1605
1607 return tooltip_behavior::variable_tooltip;
1608 }
1609
1610 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1611 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1612 auto nation_fat_id = dcon::fatten(state.world, nation_id);
1613
1614 bool is_empty = true;
1615
1616 for(auto si : state.world.nation_get_state_ownership(nation_id)) {
1617 if(province::can_integrate_colony(state, si.get_state())) {
1618 text::add_line(state, contents, "countryalert_colonialgood_state", text::variable_type::region, si.get_state().id);
1619 is_empty = false;
1620 }
1621 }
1622
1623 state.world.for_each_state_definition([&](dcon::state_definition_id sdef) {
1624 if(province::can_start_colony(state, nation_id, sdef)) {
1625 text::add_line(state, contents, "alice_countryalert_colonialgood_start", text::variable_type::region, sdef);
1626 is_empty = false;
1627 }
1628 });
1629
1630 nation_fat_id.for_each_colonization([&](dcon::colonization_id colony) {
1631 auto sdef = state.world.colonization_get_state(colony);
1632 if(state.world.state_definition_get_colonization_stage(sdef) == 3) {
1633 text::add_line(state, contents, "countryalert_colonialgood_colony", text::variable_type::region, sdef);
1634 is_empty = false;
1635 } else if(province::can_invest_in_colony(state, nation_id, sdef)) {
1636 text::add_line(state, contents, "countryalert_colonialgood_invest", text::variable_type::region, sdef);
1637 is_empty = false;
1638 }
1639 auto lvl = state.world.colonization_get_level(colony);
1640 for(auto cols : state.world.state_definition_get_colonization(sdef)) {
1641 if(lvl < cols.get_level()) {
1642 text::add_line(state, contents, "countryalert_colonialbad_influence", text::variable_type::region, sdef);
1643 is_empty = false;
1644 }
1645 }
1646 });
1647
1648 if(is_empty) {
1649 text::add_line(state, contents, "countryalert_no_colonial");
1650 }
1651 }
1652};
1653
1655public:
1656 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1657 if(state.current_crisis == sys::crisis_type::none) {
1658 return 2;
1659 } else if(state.crisis_temperature > 0.8f) {
1660 return 1;
1661 } else {
1662 return 0;
1663 }
1664 }
1665
1667 return tooltip_behavior::variable_tooltip;
1668 }
1669
1670 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1676 text::add_to_substitution_map(sub, text::variable_type::time, int32_t(state.defines.crisis_cooldown_months));
1677 if(state.current_crisis_mode == sys::crisis_mode::inactive) {
1678 auto box = text::open_layout_box(contents);
1679 text::localised_format_box(state, contents, box, std::string_view("alice_crisis_inactive"), sub);
1680 text::close_layout_box(contents, box);
1681 } else if(state.current_crisis_mode == sys::crisis_mode::finding_attacker) {
1682 auto box = text::open_layout_box(contents);
1683 text::localised_format_box(state, contents, box, std::string_view("alice_crisis_finding_attacker"), sub);
1684 text::close_layout_box(contents, box);
1685 } else if(state.current_crisis_mode == sys::crisis_mode::finding_defender) {
1686 auto box = text::open_layout_box(contents);
1687 text::localised_format_box(state, contents, box, std::string_view("alice_crisis_finding_defender"), sub);
1688 text::close_layout_box(contents, box);
1689 } else if(state.current_crisis_mode == sys::crisis_mode::heating_up) {
1690 auto box = text::open_layout_box(contents);
1691 text::localised_format_box(state, contents, box, std::string_view("alice_crisis_heating_up"), sub);
1692 text::close_layout_box(contents, box);
1693 //atackers
1694 text::add_line(state, contents, std::string_view("alice_crisis_par_1"));
1695 for(const auto par : state.crisis_participants) {
1696 if(!par.merely_interested && par.supports_attacker) {
1697 text::add_line(state, contents, text::get_name(state, par.id));
1698 }
1699 }
1700 //defenders
1701 text::add_line(state, contents, std::string_view("alice_crisis_par_2"));
1702 for(const auto par : state.crisis_participants) {
1703 if(!par.merely_interested && !par.supports_attacker) {
1704 text::add_line(state, contents, text::get_name(state, par.id));
1705 }
1706 }
1707 //merely interested
1708 text::add_line(state, contents, std::string_view("alice_crisis_par_3"));
1709 for(const auto par : state.crisis_participants) {
1710 if(par.merely_interested) {
1711 text::add_line(state, contents, text::get_name(state, par.id));
1712 }
1713 }
1714 }
1715 if(state.last_crisis_end_date) {
1716 auto box = text::open_layout_box(contents);
1717 text::localised_format_box(state, contents, box, std::string_view("alice_last_crisis"), sub);
1718 text::close_layout_box(contents, box);
1719 }
1720 }
1721};
1722
1724public:
1725 int32_t get_icon_frame(sys::state& state, dcon::nation_id nation_id) noexcept override {
1727 return 0;
1728 } else if(rebel::sphere_member_has_ongoing_revolt(state, nation_id)) {
1729 return 2;
1730 } else {
1731 return 1;
1732 }
1733 }
1734
1736 return tooltip_behavior::variable_tooltip;
1737 }
1738
1739 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1740 auto n = retrieve<dcon::nation_id>(state, parent);
1741
1743 text::add_line(state, contents, std::string_view("countryalert_no_gpstatus"));
1744 } else {
1745 bool added_increase_header = false;
1746
1747 for(auto it : state.world.nation_get_gp_relationship_as_great_power(n)) {
1748 if((it.get_status() & nations::influence::is_banned) == 0) {
1749 if(it.get_influence() >= state.defines.increaseopinion_influence_cost
1752
1753 if(!added_increase_header)
1754 text::add_line(state, contents, std::string_view("countryalert_canincreaseopinion"));
1755 added_increase_header = true;
1756 text::nation_name_and_flag(state, it.get_influence_target(), contents, 15);
1757 } else if(!(it.get_influence_target().get_in_sphere_of()) &&
1758 it.get_influence() >= state.defines.addtosphere_influence_cost) {
1759 if(!added_increase_header)
1760 text::add_line(state, contents, std::string_view("countryalert_canincreaseopinion"));
1761 added_increase_header = true;
1762 text::nation_name_and_flag(state, it.get_influence_target(), contents, 15);
1763 } else if(it.get_influence_target().get_in_sphere_of()
1765 it.get_influence() >= state.defines.removefromsphere_influence_cost) {
1766 if(!added_increase_header)
1767 text::add_line(state, contents, std::string_view("countryalert_canincreaseopinion"));
1768 added_increase_header = true;
1769 text::nation_name_and_flag(state, it.get_influence_target(), contents, 15);
1770 }
1771 }
1772 }
1773 bool added_reb_header = false;
1774 for(auto m : state.world.in_nation) {
1775 if(state.world.nation_get_in_sphere_of(m) == n) {
1776 [&]() {
1777 for(auto fac : state.world.nation_get_rebellion_within(m)) {
1778 if(rebel::get_faction_brigades_active(state, fac.get_rebels()) > 0) {
1779 if(!added_reb_header)
1780 text::add_line(state, contents, std::string_view("a_alert_reb"));
1781 added_reb_header = true;
1782 text::nation_name_and_flag(state, m, contents, 15);
1783 return;
1784 }
1785 }
1786 }();
1787 }
1788 }
1789
1790 if(!added_increase_header && !added_reb_header)
1791 text::add_line(state, contents, std::string_view("alice_ca_cant_influence"));
1792 }
1793 }
1794};
1795
1797public:
1799 return tooltip_behavior::variable_tooltip;
1800 }
1801
1802 void on_create(sys::state& state) noexcept override {
1803 top_left_extension = ui::xy_pair{ 25, 3 };
1804 bottom_right_extension = ui::xy_pair{ 0, 2 };
1805 expanded_hitbox_text::on_create(state);
1806 }
1807
1808 void on_update(sys::state& state) noexcept override {
1809 auto points = nations::daily_research_points(state, retrieve<dcon::nation_id>(state, parent));
1810 set_text(state, text::format_float(points, 2));
1811 }
1812
1813 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1814 auto nation_id = retrieve<dcon::nation_id>(state, parent);
1815 auto fat = dcon::fatten(state.world, nation_id);
1816
1817 auto tech_id = nations::current_research(state, nation_id);
1818
1819 auto total_pop = state.world.nation_get_demographics(nation_id, demographics::total);
1820 for(auto pt : state.world.in_pop_type) {
1821 auto rp = state.world.pop_type_get_research_points(pt);
1822 if(rp > 0 && state.world.nation_get_demographics(nation_id, demographics::to_key(state, pt)) > 0.0f) {
1823 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)));
1824
1826 text::add_to_substitution_map(sub1, text::variable_type::poptype, state.world.pop_type_get_name(pt));
1829 text::fp_two_places{ (state.world.nation_get_demographics(nation_id, demographics::to_key(state, pt)) / total_pop) * 100 });
1831 text::fp_two_places{ (state.world.pop_type_get_research_optimum(pt) * 100) });
1832
1833 auto box = text::open_layout_box(contents, 0);
1834 text::localised_format_box(state, contents, box, std::string_view("tech_daily_researchpoints_tooltip"), sub1);
1835 text::close_layout_box(contents, box);
1836 }
1837 }
1838 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::research_points, true);
1840
1841 active_modifiers_description(state, contents, nation_id, 0, sys::national_mod_offsets::research_points_modifier, true);
1843
1844 if(!bool(tech_id)) {
1845 auto box2 = text::open_layout_box(contents, 0);
1846 text::localised_single_sub_box(state, contents, box2, std::string_view("rp_accumulated"), text::variable_type::val,
1847 text::fp_one_place{fat.get_research_points()});
1848
1849 text::close_layout_box(contents, box2);
1850 }
1851 }
1852};
1853
1855public:
1856 uint8_t slot = 0;
1857 dcon::commodity_id commodity_id{};
1858 float amount = 0.f;
1859
1861 return tooltip_behavior::variable_tooltip;
1862 }
1863
1864 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1865 auto box = text::open_layout_box(contents, 0);
1866 text::add_to_layout_box(state, contents, box,
1867 text::produce_simple_string(state, state.world.commodity_get_name(commodity_id)), text::text_color::white);
1868 text::add_to_layout_box(state, contents, box, std::string_view(":"), text::text_color::white);
1869 text::add_space_to_layout_box(state, contents, box);
1871 text::close_layout_box(contents, box);
1872 }
1873};
1874
1876private:
1877 dcon::nation_id current_nation{};
1878 std::vector<topbar_commodity_xport_icon*> import_icons;
1879 std::vector<topbar_commodity_xport_icon*> export_icons;
1880 std::vector<topbar_commodity_xport_icon*> produced_icons;
1881 simple_text_element_base* atpeacetext = nullptr;
1882
1883public:
1884 void on_create(sys::state& state) noexcept override {
1885 window_element_base::on_create(state);
1886 base_data.position.y += 1;
1887
1888 auto bg_pic = make_element_by_type<background_image>(state, "bg_main_menus");
1889 background_pic = bg_pic.get();
1890 background_pic->base_data.position.y -= 1;
1891 add_child_to_back(std::move(bg_pic));
1892
1893 auto dpi_win = make_element_by_type<ui::diplomatic_message_topbar_listbox>(state, "alice_diplomessageicons_window");
1894 state.ui_state.request_topbar_listbox = dpi_win.get();
1895 add_child_to_front(std::move(dpi_win));
1896
1897 state.ui_state.topbar_window = this;
1898 on_update(state);
1899 }
1900
1901 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1902 if(name == "topbar_bg") {
1903 return partially_transparent_image::make_element_by_type_alias(state, id);
1904 } else if(name == "topbar_paper") {
1905 return partially_transparent_image::make_element_by_type_alias(state, id);
1906 } else if(name == "topbarbutton_production") {
1907 auto btn = make_element_by_type<topbar_production_tab_button>(state, id);
1908
1909 auto tab = make_element_by_type<production_window>(state, "country_production");
1910 state.ui_state.production_subwindow = state.ui_state.topbar_subwindow = btn->topbar_subwindow = tab.get();
1911 state.ui_state.root->add_child_to_back(std::move(tab));
1912 return btn;
1913 } else if(name == "topbarbutton_budget") {
1914 auto btn = make_element_by_type<topbar_budget_tab_button>(state, id);
1915
1916 auto tab = make_element_by_type<budget_window>(state, "country_budget");
1917 btn->topbar_subwindow = tab.get();
1918 state.ui_state.root->add_child_to_back(std::move(tab));
1919 return btn;
1920 } else if(name == "topbarbutton_tech") {
1921 auto btn = make_element_by_type<topbar_technology_tab_button>(state, id);
1922
1923 auto tab = make_element_by_type<technology_window>(state, "country_technology");
1924 btn->topbar_subwindow = tab.get();
1925
1926 state.ui_state.technology_subwindow = tab.get();
1927 state.ui_state.root->add_child_to_back(std::move(tab));
1928 return btn;
1929 } else if(name == "topbarbutton_politics") {
1930 auto btn = make_element_by_type<topbar_politics_tab_button>(state, id);
1931 auto tab = make_element_by_type<politics_window>(state, "country_politics");
1932 btn->topbar_subwindow = tab.get();
1933
1934 state.ui_state.politics_subwindow = tab.get();
1935 state.ui_state.root->add_child_to_back(std::move(tab));
1936 return btn;
1937 } else if(name == "topbarbutton_pops") {
1938 auto btn = make_element_by_type<topbar_population_view_button>(state, id);
1939 auto tab = make_element_by_type<population_window>(state, "country_pop");
1940 btn->topbar_subwindow = tab.get();
1941
1942 state.ui_state.population_subwindow = tab.get();
1943 state.ui_state.root->add_child_to_back(std::move(tab));
1944 return btn;
1945 } else if(name == "topbarbutton_trade") {
1946 auto btn = make_element_by_type<topbar_trade_tab_button>(state, id);
1947
1948 auto tab = make_element_by_type<trade_window>(state, "alice_country_trade");
1949 btn->topbar_subwindow = tab.get();
1950
1951 state.ui_state.trade_subwindow = tab.get();
1952 state.ui_state.root->add_child_to_back(std::move(tab));
1953 return btn;
1954 } else if(name == "topbarbutton_diplomacy") {
1955 auto btn = make_element_by_type<topbar_diplomacy_tab_button>(state, id);
1956
1957 auto tab = make_element_by_type<diplomacy_window>(state, "country_diplomacy");
1958 btn->topbar_subwindow = tab.get();
1959 state.ui_state.root->add_child_to_back(std::move(tab));
1960 return btn;
1961 } else if(name == "topbarbutton_military") {
1962 auto btn = make_element_by_type<topbar_military_tab_button>(state, id);
1963
1964 auto tab = make_element_by_type<military_window>(state, "country_military");
1965 btn->topbar_subwindow = tab.get();
1966 state.ui_state.root->add_child_to_back(std::move(tab));
1967 return btn;
1968 } else if(name == "button_speedup") {
1969 return make_element_by_type<topbar_speedup_button>(state, id);
1970 } else if(name == "button_speeddown") {
1971 return make_element_by_type<topbar_speeddown_button>(state, id);
1972 } else if(name == "pause_bg") {
1973 return make_element_by_type<topbar_pause_button>(state, id);
1974 } else if(name == "speed_indicator") {
1975 return make_element_by_type<topbar_speed_indicator>(state, id);
1976 } else if(name == "datetext") {
1977 return make_element_by_type<topbar_date_text>(state, id);
1978 } else if(name == "countryname") {
1979 return make_element_by_type<topbar_nation_name>(state, id);
1980 } else if(name == "player_flag") {
1981 return make_element_by_type<flag_button>(state, id);
1982 } else if(name == "country_prestige") {
1983 return make_element_by_type<topbar_nation_prestige_text>(state, id);
1984 } else if(name == "country_economic") {
1985 return make_element_by_type<topbar_nation_industry_score_text>(state, id);
1986 } else if(name == "country_military") {
1987 return make_element_by_type<topbar_nation_military_score_text>(state, id);
1988 } else if(name == "country_total") {
1989 return make_element_by_type<nation_total_score_text>(state, id);
1990 } else if(name == "country_colonial_power") {
1991 return make_element_by_type<topbar_nation_colonial_power_text>(state, id);
1992 } else if(name == "selected_prestige_rank") {
1993 return make_element_by_type<nation_prestige_rank_text>(state, id);
1994 } else if(name == "selected_industry_rank") {
1995 return make_element_by_type<nation_industry_rank_text>(state, id);
1996 } else if(name == "selected_military_rank") {
1997 return make_element_by_type<nation_military_rank_text>(state, id);
1998 } else if(name == "nation_totalrank") {
1999 return make_element_by_type<nation_rank_text>(state, id);
2000 } else if(name == "topbar_flag_overlay") {
2001 return make_element_by_type<nation_flag_frame>(state, id);
2002 } else if(name == "alert_building_factories") {
2003 return make_element_by_type<topbar_building_factories_icon>(state, id);
2004 } else if(name == "alert_closed_factories") {
2005 return make_element_by_type<topbar_closed_factories_icon>(state, id);
2006 } else if(name == "alert_unemployed_workers") {
2007 return make_element_by_type<topbar_unemployment_icon>(state, id);
2008 } else if(name == "budget_linechart") {
2009 return make_element_by_type<topbar_budget_line_graph>(state, id);
2010 } else if(name == "budget_funds") {
2011 return make_element_by_type<topbar_treasury_text>(state, id);
2012 } else if(name == "topbar_tech_progress") {
2013 return make_element_by_type<nation_technology_research_progress>(state, id);
2014 } else if(name == "tech_current_research") {
2015 return make_element_by_type<nation_current_research_text>(state, id);
2016 } else if(name == "topbar_researchpoints_value") {
2017 return make_element_by_type<topbar_nation_daily_research_points_text>(state, id);
2018 } else if(name == "tech_literacy_value") {
2019 return make_element_by_type<topbar_nation_literacy_text>(state, id);
2020 } else if(name == "politics_party_icon") {
2021 return make_element_by_type<nation_ruling_party_ideology_plupp>(state, id);
2022 } else if(name == "politics_ruling_party") {
2023 return make_element_by_type<nation_ruling_party_text>(state, id);
2024 } else if(name == "politics_supressionpoints_value") {
2025 return make_element_by_type<nation_suppression_points_text>(state, id);
2026 } else if(name == "politics_infamy_value") {
2027 return make_element_by_type<topbar_nation_infamy_text>(state, id);
2028 } else if(name == "alert_can_do_reforms") {
2029 return make_element_by_type<topbar_available_reforms_icon>(state, id);
2030 } else if(name == "alert_can_do_decisions") {
2031 return make_element_by_type<topbar_available_decisions_icon>(state, id);
2032 } else if(name == "alert_is_in_election") {
2033 return make_element_by_type<topbar_ongoing_election_icon>(state, id);
2034 } else if(name == "alert_have_rebels") {
2035 return make_element_by_type<topbar_rebels_icon>(state, id);
2036 } else if(name == "population_total_value") {
2037 return make_element_by_type<topbar_nation_population_text>(state, id);
2038 } else if(name == "topbar_focus_value") {
2039 return make_element_by_type<topbar_nation_focus_allocation_text>(state, id);
2040 } else if(name == "population_avg_mil_value") {
2041 return make_element_by_type<topbar_nation_militancy_text>(state, id);
2042 } else if(name == "population_avg_con_value") {
2043 return make_element_by_type<topbar_nation_consciousness_text>(state, id);
2044 } else if(name == "diplomacy_status") {
2045 auto ptr = make_element_by_type<topbar_at_peace_text>(state, id);
2046 atpeacetext = ptr.get();
2047 return ptr;
2048 } else if(name == "diplomacy_at_war") {
2049 auto ptr = make_element_by_type<overlapping_enemy_flags>(state, id);
2050 ptr->base_data.position.y -= ptr->base_data.position.y / 4;
2051 ptr->base_data.size.x /= 2;
2052 return ptr;
2053 } else if(name == "diplomacy_diplopoints_value") {
2054 return make_element_by_type<topbar_nation_diplomatic_points_text>(state, id);
2055 } else if(name == "alert_colony") {
2056 return make_element_by_type<topbar_colony_icon>(state, id);
2057 } else if(name == "alert_crisis") {
2058 return make_element_by_type<topbar_crisis_icon>(state, id);
2059 } else if(name == "alert_can_increase_opinion") {
2060 return make_element_by_type<topbar_sphere_icon>(state, id);
2061 } else if(name == "alert_loosing_gp") {
2062 return make_element_by_type<topbar_losing_gp_status_icon>(state, id);
2063 } else if(name == "military_army_value") {
2064 return make_element_by_type<topbar_nation_brigade_allocation_text>(state, id);
2065 } else if(name == "military_navy_value") {
2066 return make_element_by_type<topbar_nation_navy_allocation_text>(state, id);
2067 } else if(name == "military_manpower_value") {
2068 return make_element_by_type<topbar_nation_mobilization_size_text>(state, id);
2069 } else if(name == "military_leadership_value") {
2070 return make_element_by_type<topbar_nation_leadership_points_text>(state, id);
2071 } else if(name == "topbar_outlinerbutton" || name == "topbar_outlinerbutton_bg") {
2072 // Fake button isn't used - we create it manually instead...
2073 return make_element_by_type<invisible_element>(state, id);
2074 } else if(name.substr(0, 13) == "topbar_import") {
2075 auto ptr = make_element_by_type<topbar_commodity_xport_icon>(state, id);
2076 std::string var = std::string{name.substr(13)};
2077 var.empty() ? ptr->slot = uint8_t(0) : ptr->slot = uint8_t(std::stoi(var));
2078 import_icons.push_back(ptr.get());
2079 return ptr;
2080 } else if(name.substr(0, 13) == "topbar_export") {
2081 auto ptr = make_element_by_type<topbar_commodity_xport_icon>(state, id);
2082 std::string var = std::string{name.substr(13)};
2083 var.empty() ? ptr->slot = uint8_t(0) : ptr->slot = uint8_t(std::stoi(var));
2084 export_icons.push_back(ptr.get());
2085 return ptr;
2086 } else if(name.substr(0, 15) == "topbar_produced") {
2087 auto ptr = make_element_by_type<topbar_commodity_xport_icon>(state, id);
2088 std::string var = std::string{name.substr(15)};
2089 var.empty() ? ptr->slot = uint8_t(0) : ptr->slot = uint8_t(std::stoi(var));
2090 produced_icons.push_back(ptr.get());
2091 return ptr;
2092 } else if (name == "selected_military_icon") {
2093 return make_element_by_type<military_score_icon>(state, id);
2094 } else {
2095 return nullptr;
2096 }
2097 }
2098
2099 void on_update(sys::state& state) noexcept override {
2100 atpeacetext->set_visible(state, !state.world.nation_get_is_at_war(state.local_player_nation));
2101 if(state.local_player_nation != current_nation) {
2102 current_nation = state.local_player_nation;
2103 Cyto::Any payload = current_nation;
2104 impl_set(state, payload);
2105 }
2106
2107 for(auto& e : export_icons)
2108 e->set_visible(state, false);
2109 for(auto& e : import_icons)
2110 e->set_visible(state, false);
2111 for(auto& e : produced_icons)
2112 e->set_visible(state, false);
2113
2114 {
2115 std::map<float, int32_t> v;
2116 for(dcon::commodity_id cid : state.world.in_commodity) {
2117 if(sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::military_goods &&
2118 sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::raw_material_goods &&
2119 sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::industrial_goods &&
2120 sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::consumer_goods &&
2121 sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::industrial_and_consumer_goods)
2122 return;
2123 float produced = state.world.nation_get_domestic_market_pool(state.local_player_nation, cid);
2124 float consumed = state.world.nation_get_real_demand(state.local_player_nation, cid) *
2125 state.world.nation_get_demand_satisfaction(state.local_player_nation, cid);
2126 v.insert({produced - consumed, cid.index()});
2127 }
2128
2129 uint8_t slot = 0;
2130 for(auto it = std::rbegin(v); it != std::rend(v); it++) {
2131 for(auto const& e : export_icons)
2132 if(e->slot == slot) {
2133 dcon::commodity_id cid = dcon::commodity_id(dcon::commodity_id::value_base_t(it->second));
2134 e->frame = state.world.commodity_get_icon(cid);
2135 e->commodity_id = cid;
2136 e->amount = it->first;
2137 e->set_visible(state, true);
2138 }
2139 ++slot;
2140 }
2141 slot = 0;
2142 for(auto it = v.begin(); it != v.end(); it++) {
2143 for(auto const& e : import_icons)
2144 if(e->slot == slot) {
2145 dcon::commodity_id cid = dcon::commodity_id(dcon::commodity_id::value_base_t(it->second));
2146 e->frame = state.world.commodity_get_icon(cid);
2147 e->commodity_id = cid;
2148 e->amount = it->first;
2149 e->set_visible(state, true);
2150 }
2151 ++slot;
2152 }
2153 }
2154
2155 {
2156 std::map<float, int32_t> v;
2157 for(dcon::commodity_id cid : state.world.in_commodity) {
2158 if(sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::military_goods &&
2159 sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::raw_material_goods &&
2160 sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::industrial_goods &&
2161 sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::consumer_goods &&
2162 sys::commodity_group(state.world.commodity_get_commodity_group(cid)) != sys::commodity_group::industrial_and_consumer_goods)
2163 return;
2164 v.insert({state.world.nation_get_domestic_market_pool(state.local_player_nation, cid), cid.index()});
2165 }
2166
2167 uint8_t slot = 0;
2168 for(auto it = std::rbegin(v); it != std::rend(v); it++) {
2169 for(auto const& e : produced_icons)
2170 if(e->slot == slot) {
2171 dcon::commodity_id cid = dcon::commodity_id(dcon::commodity_id::value_base_t(it->second));
2172 e->frame = state.world.commodity_get_icon(cid);
2173 e->commodity_id = cid;
2174 e->amount = it->first;
2175 e->set_visible(state, true);
2176 }
2177 ++slot;
2178 }
2179 }
2180 }
2181
2182 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
2183 if(state.ui_state.topbar_subwindow->is_visible()) {
2184 background_pic->set_visible(state, true);
2185 } else {
2186 background_pic->set_visible(state, false);
2187 }
2188 window_element_base::render(state, x, y);
2189 }
2190
2191 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
2192 if(payload.holds_type<dcon::nation_id>()) {
2193 payload.emplace<dcon::nation_id>(state.local_player_nation);
2194 return message_result::consumed;
2195 } else {
2196 return message_result::unseen;
2197 }
2198 }
2199
2200private:
2201 element_base* background_pic = nullptr;
2202
2203 friend class topbar_tab_button;
2204};
2205
2206} // 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 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
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:165
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:223
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:243
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