Project Alice
Loading...
Searching...
No Matches
gui_diplomacy_window.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "dcon_generated.hpp"
5#include "gui_graphics.hpp"
6#include "text.hpp"
7#include "parsers.hpp"
8#include <algorithm>
9#include <functional>
10
13#include "gui_peace_window.hpp"
14#include "gui_crisis_window.hpp"
15
16namespace military {
17std::string get_war_name(sys::state&, dcon::war_id);
18}
19
20namespace ui {
21
22
24public:
25 void on_update(sys::state& state) noexcept override {
26 const dcon::cb_type_id cbt = retrieve<dcon::cb_type_id>(state, parent);
27 frame = state.world.cb_type_get_sprite_index(cbt) - 1;
28 }
29};
30
32public:
33 void on_update(sys::state& state) noexcept override {
34 dcon::cb_type_id content = retrieve<dcon::cb_type_id>(state, parent);
35 dcon::nation_id target = retrieve<dcon::nation_id>(state, parent);
36 auto war = retrieve<dcon::war_id>(state, parent);
37 auto cb_infamy = military::has_truce_with(state, state.local_player_nation, target)
39 : military::cb_infamy(state, content);
40 if(state.world.nation_get_infamy(state.local_player_nation) + cb_infamy >= state.defines.badboy_limit) {
41 color = sys::pack_color(255, 196, 196);
42 } else {
43 color = sys::pack_color(255, 255, 255);
44 }
45
47 if(parent) {
48 auto selected = retrieve<dcon::cb_type_id>(state, parent->parent);
49 disabled = selected == content;
50 }
51 }
52
53 void button_action(sys::state& state) noexcept override {
54 const dcon::cb_type_id content = retrieve<dcon::cb_type_id>(state, parent);
56 }
57
60 }
61
62 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
63 dcon::cb_type_id content = retrieve<dcon::cb_type_id>(state, parent);
64 dcon::nation_id target = retrieve<dcon::nation_id>(state, parent);
65 auto cb_infamy = military::has_truce_with(state, state.local_player_nation, target)
67 : military::cb_infamy(state, content);
68 if(state.world.nation_get_infamy(state.local_player_nation) + cb_infamy >= state.defines.badboy_limit) {
69 text::add_line(state, contents, "alice_tt_wg_infamy_limit");
70 }
71 text::add_line_with_condition(state, contents, "alice_wg_condition_5", military::cb_conditions_satisfied(state, state.local_player_nation, target, content));
72 text::add_line(state, contents, "alice_wg_usage_trigger");
73 ui::trigger_description(state, contents, state.world.cb_type_get_can_use(content), trigger::to_generic(target), trigger::to_generic(state.local_player_nation), trigger::to_generic(target));
74 }
75};
76
77class diplomacy_make_cb_type : public listbox_row_element_base<dcon::cb_type_id> {
78public:
79 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
80 if(name == "wargoal_icon") {
81 return make_element_by_type<cb_wargoal_icon>(state, id);
82 } else if(name == "select_cb") {
83 return make_element_by_type<cb_wargoal_button>(state, id);
84 } else {
85 return nullptr;
86 }
87 }
88};
89
90class diplomacy_make_cb_listbox : public listbox_element_base<diplomacy_make_cb_type, dcon::cb_type_id> {
91protected:
92 std::string_view get_row_element_name() override {
93 return "cb_type_item";
94 }
95
96public:
97 void on_update(sys::state& state) noexcept override {
98 row_contents.clear();
99 dcon::nation_id content = retrieve<dcon::nation_id>(state, parent);
100 state.world.for_each_cb_type([&](dcon::cb_type_id cb) {
101 if(command::can_fabricate_cb(state, state.local_player_nation, content, cb))
102 row_contents.push_back(cb);
103 });
104 update(state);
105 }
106};
107
109public:
110 void button_action(sys::state& state) noexcept override {
111 auto content = retrieve<dcon::cb_type_id>(state, parent);
112 auto target_nation = retrieve<dcon::nation_id>(state, parent);
113 command::fabricate_cb(state, state.local_player_nation, target_nation, content);
114 parent->set_visible(state, false);
115 }
116
117 void on_update(sys::state& state) noexcept override {
118 auto content = retrieve<dcon::cb_type_id>(state, parent);
119 auto target_nation = retrieve<dcon::nation_id>(state, parent);
120 disabled = !command::can_fabricate_cb(state, state.local_player_nation, target_nation, content);
121 }
122};
123
125public:
126 void populate_layout(sys::state& state, text::endless_layout& contents) noexcept override {
127 auto fat_cb = dcon::fatten(state.world, retrieve<dcon::cb_type_id>(state, parent));
128 auto box = text::open_layout_box(contents);
129 auto fab_time = std::ceil(100.0f / (state.defines.cb_generation_base_speed * fat_cb.get_construction_speed() * (state.world.nation_get_modifier_values(state.local_player_nation, sys::national_mod_offsets::cb_generation_speed_modifier) + 1.0f)));
130 auto target_nation = retrieve<dcon::nation_id>(state, parent);
131 if(fat_cb.is_valid()) {
137 text::localised_format_box(state, contents, box, std::string_view("alice_cb_creation_detail"), sub);
138 } else {
141 text::localised_format_box(state, contents, box, std::string_view("alice_cb_creation_detail_none"), sub);
142 }
143 text::close_layout_box(contents, box);
144 }
145};
146
148public:
149 void on_update(sys::state& state) noexcept override {
151 }
152};
153
154class diplomacy_make_cb_window : public window_element_base { // eu3dialogtype
155private:
156 dcon::cb_type_id root_cb{};
157
158public:
159 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
160 if(name == "background") {
161 auto ptr = make_element_by_type<draggable_target>(state, id);
162 ptr->base_data.size = base_data.size; // Nudge size for proper sizing
163 return ptr;
164 } else if(name == "diplo_makecb_bg") {
165 return make_element_by_type<image_element_base>(state, id);
166 } else if(name == "title") {
167 return make_element_by_type<make_cb_title>(state, id);
168 } else if(name == "description") {
169 return make_element_by_type<diplomacy_make_cb_desc>(state, id);
170 } else if(name == "leftshield") {
171 return make_element_by_type<nation_player_flag>(state, id);
172 } else if(name == "rightshield") {
173 return make_element_by_type<flag_button>(state, id);
174 } else if(name == "agreebutton") {
175 return make_element_by_type<diplomacy_make_cb_button>(state, id);
176 } else if(name == "declinebutton") {
177 return make_element_by_type<generic_close_button>(state, id);
178 } else if(name == "cb_list") {
179 return make_element_by_type<diplomacy_make_cb_listbox>(state, id);
180 } else {
181 return nullptr;
182 }
183 }
184
185 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
186 if(payload.holds_type<element_selection_wrapper<dcon::cb_type_id>>()) {
187 root_cb = any_cast<element_selection_wrapper<dcon::cb_type_id>>(payload).data;
190 } else if(payload.holds_type<dcon::cb_type_id>()) {
191 payload.emplace<dcon::cb_type_id>(root_cb);
193 }
195 }
196};
197
198
199enum class diplomacy_window_tab : uint8_t { great_powers = 0x0, wars = 0x1, casus_belli = 0x2, crisis = 0x3 };
200
202public:
205 }
206
207 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
208 auto n = retrieve<dcon::nation_id>(state, parent);
211 int32_t total = 0;
212 int32_t discovered = 0;
213 state.world.for_each_technology([&](dcon::technology_id id) {
214 auto fat_id = dcon::fatten(state.world, id);
215 if(state.culture_definitions.tech_folders[fat_id.get_folder_index()].category != culture::tech_category::navy)
216 return;
217 ++total;
218 if(state.world.nation_get_active_technologies(n, id))
219 ++discovered;
220 });
221 text::add_line(state, contents, "navy_technology_levels", text::variable_type::val, discovered, text::variable_type::max, total);
222 }
223};
224
226public:
229 }
230
231 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
232 auto n = retrieve<dcon::nation_id>(state, parent);
235 int32_t total = 0;
236 int32_t discovered = 0;
237 state.world.for_each_technology([&](dcon::technology_id id) {
238 auto fat_id = dcon::fatten(state.world, id);
239 if(state.culture_definitions.tech_folders[fat_id.get_folder_index()].category != culture::tech_category::army)
240 return;
241 ++total;
242 if(state.world.nation_get_active_technologies(n, id))
243 ++discovered;
244 });
245 text::add_line(state, contents, "army_technology_levels", text::variable_type::val, discovered, text::variable_type::max, total);
246 }
247};
248
250public:
251 std::string get_text(sys::state& state, dcon::nation_id nation_id) noexcept override {
252 auto fat_id = dcon::fatten(state.world, nation_id);
253 return text::format_percentage(fat_id.get_war_exhaustion() / 100.0f, 1);
254 }
255
258 }
259
260 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
261 auto n = retrieve<dcon::nation_id>(state, parent);
262
263 auto box = text::open_layout_box(contents);
264 text::localised_format_box(state, contents, box, "diplomacy_wx_1");
265 auto mod = state.world.nation_get_modifier_values(n, sys::national_mod_offsets::war_exhaustion);
266 if(mod > 0) {
267 text::add_to_layout_box(state, contents, box, std::string_view("+"), text::text_color::red);
269 } else if(mod == 0) {
270 text::add_to_layout_box(state, contents, box, std::string_view("+0"));
271 } else {
273 }
274 text::close_layout_box(contents, box);
275
276 active_modifiers_description(state, contents, n, 15, sys::national_mod_offsets::war_exhaustion, false);
277 }
278};
279
281public:
282 void on_update(sys::state& state) noexcept override {
283 if(!parent)
284 return;
285 auto content = retrieve<dcon::nation_id>(state, parent);
286 auto window_content = retrieve<dcon::nation_id>(state, parent->parent);
287 if(content == window_content)
288 frame = 1;
289 else
290 frame = 0;
291 }
292 void button_action(sys::state& state) noexcept override {
293 auto content = retrieve<dcon::nation_id>(state, parent);
295 }
296};
297
298void explain_influence(sys::state& state, dcon::nation_id target, text::columnar_layout& contents) {
299 int32_t total_influence_shares = 0;
300 auto n = fatten(state.world, state.local_player_nation);
301
302 for(auto rel : state.world.nation_get_gp_relationship_as_great_power(state.local_player_nation)) {
303 if(nations::can_accumulate_influence_with(state, state.local_player_nation, rel.get_influence_target(), rel)) {
304 switch(rel.get_status() & nations::influence::priority_mask) {
306 total_influence_shares += 1;
307 break;
309 total_influence_shares += 2;
310 break;
312 total_influence_shares += 3;
313 break;
314 default:
316 break;
317 }
318 }
319 }
320
321 auto rel = fatten(state.world, state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation));
322
323 if((state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) != 0) {
324 text::add_line(state, contents, "influence_explain_1");
325 return;
326 }
327 if(military::has_truce_with(state, state.local_player_nation, target)) {
328 text::add_line(state, contents, "influence_explain_2");
329 return;
330 }
331 if(military::are_at_war(state, state.local_player_nation, target)) {
332 text::add_line(state, contents, "influence_explain_3");
333 return;
334 }
335
336 if(total_influence_shares > 0) {
337 float total_gain = state.defines.base_greatpower_daily_influence
338 * (1.0f + n.get_modifier_values(sys::national_mod_offsets::influence_modifier))
339 * (1.0f + n.get_modifier_values(sys::national_mod_offsets::influence));
340 float gp_score = n.get_industrial_score() + n.get_military_score() + nations::prestige_score(state, n);
341 float base_shares = nations::get_base_shares(state, rel, total_gain, total_influence_shares);
342
343 float total_fi = nations::get_foreign_investment(state, n);
344 auto gp_invest = state.world.unilateral_relationship_get_foreign_investment(
345 state.world.get_unilateral_relationship_by_unilateral_pair(target, n));
346
347 float discredit_factor = (rel.get_status() & nations::influence::is_discredited) != 0
348 ? state.defines.discredit_influence_gain_factor
349 : 0.0f;
350 float neighbor_factor = bool(state.world.get_nation_adjacency_by_nation_adjacency_pair(n, target))
351 ? state.defines.neighbour_bonus_influence_percent
352 : 0.0f;
353 float sphere_neighbor_factor = nations::has_sphere_neighbour(state, n, target)
354 ? state.defines.sphere_neighbour_bonus_influence_percent
355 : 0.0f;
356 float continent_factor =
357 n.get_capital().get_continent() != state.world.nation_get_capital(target).get_continent()
358 ? state.defines.other_continent_bonus_influence_percent
359 : 0.0f;
360 float puppet_factor =
361 fatten(state.world, state.world.nation_get_overlord_as_subject(target)).get_ruler() == n
362 ? state.defines.puppet_bonus_influence_percent
363 : 0.0f;
364 float relationship_factor =
365 state.world.diplomatic_relation_get_value(state.world.get_diplomatic_relation_by_diplomatic_pair(n, target)) / state.defines.relation_influence_modifier;
366
367 float investment_factor =
368 total_fi > 0.0f
369 ? state.defines.investment_influence_defense * gp_invest / total_fi
370 : 0.0f;
371 float pop_factor =
372 state.world.nation_get_demographics(target, demographics::total) > state.defines.large_population_limit
373 ? state.defines.large_population_influence_penalty * state.world.nation_get_demographics(target, demographics::total) / state.defines.large_population_influence_penalty_chunk
374 : 0.0f;
375 float score_factor =
376 gp_score > 0.0f
377 ? std::max(1.0f - (state.world.nation_get_industrial_score(target) + state.world.nation_get_military_score(target) + nations::prestige_score(state, target)) / gp_score, 0.0f)
378 : 0.0f;
379
380 float total_multiplier = 1.0f + discredit_factor + neighbor_factor + sphere_neighbor_factor + continent_factor + puppet_factor + relationship_factor + investment_factor + pop_factor + score_factor;
381
382 auto gain_amount = std::max(0.0f, base_shares * total_multiplier);
383
384 text::add_line(state, contents, "remove_diplomacy_dailyinflulence_gain", text::variable_type::num, text::fp_two_places{ gain_amount }, text::variable_type::country, target);
386
387 text::add_line(state, contents, "influence_explain_4", text::variable_type::x, text::fp_two_places{ total_gain });
388 text::add_line(state, contents, "influence_explain_5", text::variable_type::x, text::fp_two_places{ state.defines.base_greatpower_daily_influence }, text::variable_type::y, text::fp_percentage{ 1.0f + n.get_modifier_values(sys::national_mod_offsets::influence_modifier) }, text::variable_type::val, text::fp_percentage{ 1.0f + n.get_modifier_values(sys::national_mod_offsets::influence) });
389
390 text::add_line(state, contents, "influence_explain_6", text::variable_type::x, text::fp_percentage{ 1.0f + n.get_modifier_values(sys::national_mod_offsets::influence_modifier) });
391 active_modifiers_description(state, contents, n, 15, sys::national_mod_offsets::influence_modifier, false);
392
393 text::add_line(state, contents, "influence_explain_7", text::variable_type::x, text::fp_percentage{ 1.0f + n.get_modifier_values(sys::national_mod_offsets::influence) });
394 active_modifiers_description(state, contents, n, 15, sys::national_mod_offsets::influence, false);
395
397
398 text::add_line(state, contents, "influence_explain_8", text::variable_type::x, text::fp_two_places{ base_shares });
399
400 if(discredit_factor != 0 || neighbor_factor != 0 || sphere_neighbor_factor != 0 || continent_factor != 0 || puppet_factor != 0 || relationship_factor != 0 || investment_factor != 0 || pop_factor != 0 || score_factor != 0) {
401
402 text::add_line(state, contents, "influence_explain_9");
403
404 if(discredit_factor != 0) {
405 text::add_line(state, contents, "influence_explain_10", text::variable_type::x, text::fp_two_places{ discredit_factor }, 15);
406 }
407 if(neighbor_factor != 0) {
408 text::add_line(state, contents, "influence_explain_11", text::variable_type::x, text::fp_two_places{ neighbor_factor }, 15);
409 }
410 if(sphere_neighbor_factor != 0) {
411 text::add_line(state, contents, "influence_explain_12", text::variable_type::x, text::fp_two_places{ sphere_neighbor_factor }, 15);
412 }
413 if(continent_factor != 0) {
414 text::add_line(state, contents, "influence_explain_13", text::variable_type::x, text::fp_two_places{ continent_factor }, 15);
415 }
416 if(puppet_factor != 0) {
417 text::add_line(state, contents, "influence_explain_14", text::variable_type::x, text::fp_two_places{ puppet_factor }, 15);
418 }
419 if(relationship_factor != 0) {
420 text::add_line(state, contents, "influence_explain_15", text::variable_type::x, text::fp_two_places{ relationship_factor }, 15);
421 }
422 if(investment_factor != 0) {
423 text::add_line(state, contents, "influence_explain_16", text::variable_type::x, text::fp_two_places{ investment_factor }, 15);
424 }
425 if(pop_factor != 0) {
426 text::add_line(state, contents, "influence_explain_17", text::variable_type::x, text::fp_two_places{ pop_factor }, 15);
427 }
428 if(score_factor != 0) {
429 text::add_line(state, contents, "influence_explain_18", text::variable_type::x, text::fp_two_places{ score_factor }, 15);
430 }
431 }
432 }
433}
434
436 static std::string_view get_prio_key(uint8_t f) {
439 return "diplomacy_prio_none";
441 return "diplomacy_prio_low";
443 return "diplomacy_prio_middle";
445 return "diplomacy_prio_high";
446 default:
447 return "diplomacy_prio_none";
448 }
449 }
450
451public:
452 void on_update(sys::state& state) noexcept override {
453 auto nation_id = retrieve<dcon::nation_id>(state, parent);
454
455 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(nation_id, state.local_player_nation);
456 uint8_t rel_flags = bool(rel) ? state.world.gp_relationship_get_status(rel) : 0;
457 switch(rel_flags & nations::influence::priority_mask) {
459 frame = 0;
460 disabled = !command::can_change_influence_priority(state, state.local_player_nation, nation_id, 1);
461 break;
463 frame = 1;
464 disabled = !command::can_change_influence_priority(state, state.local_player_nation, nation_id, 2);
465 break;
467 frame = 2;
468 disabled = !command::can_change_influence_priority(state, state.local_player_nation, nation_id, 3);
469 break;
471 frame = 3;
472 disabled = !command::can_change_influence_priority(state, state.local_player_nation, nation_id, 0);
473 break;
474 default:
475 break;
476 }
477 }
478
479 void button_action(sys::state& state) noexcept override {
480 auto nation_id = retrieve<dcon::nation_id>(state, parent);
481
482 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(nation_id, state.local_player_nation);
483 uint8_t rel_flags = bool(rel) ? state.world.gp_relationship_get_status(rel) : 0;
484 switch(rel_flags & nations::influence::priority_mask) {
486 command::change_influence_priority(state, state.local_player_nation, nation_id, 1);
487 break;
489 command::change_influence_priority(state, state.local_player_nation, nation_id, 2);
490 break;
492 command::change_influence_priority(state, state.local_player_nation, nation_id, 3);
493 break;
495 command::change_influence_priority(state, state.local_player_nation, nation_id, 0);
496 break;
497 }
498 }
499
500 void button_right_action(sys::state& state) noexcept override {
501 auto nation_id = retrieve<dcon::nation_id>(state, parent);
502 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(nation_id, state.local_player_nation);
503 uint8_t rel_flags = bool(rel) ? state.world.gp_relationship_get_status(rel) : 0;
504 switch(rel_flags & nations::influence::priority_mask) {
506 command::change_influence_priority(state, state.local_player_nation, nation_id, 3);
507 break;
509 command::change_influence_priority(state, state.local_player_nation, nation_id, 0);
510 break;
512 command::change_influence_priority(state, state.local_player_nation, nation_id, 1);
513 break;
515 command::change_influence_priority(state, state.local_player_nation, nation_id, 2);
516 break;
517 default:
518 break;
519 }
520 }
521
524 }
525
526 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
527 auto nation_id = retrieve<dcon::nation_id>(state, parent);
528
529 if(!nations::is_great_power(state, state.local_player_nation)) {
530 text::add_line(state, contents, "diplomacy_cannot_set_prio");
531 } else if(nations::is_great_power(state, nation_id)) {
532 text::add_line(state, contents, "diplomacy_cannot_set_prio_gp");
533 } else {
534 explain_influence(state, nation_id, contents);
535 }
536
537 auto box = text::open_layout_box(contents, 0);
539 text::localised_format_box(state, contents, box, std::string_view("diplomacy_set_prio_desc"));
540 text::close_layout_box(contents, box);
541 active_modifiers_description(state, contents, state.local_player_nation, 0, sys::national_mod_offsets::influence, false);
542 }
543};
544
546public:
547 bool is_active(sys::state& state) noexcept override {
548 auto const n = retrieve<dcon::nation_id>(state, parent);
549 auto const rel = state.world.get_unilateral_relationship_by_unilateral_pair(n, state.local_player_nation);
550 return state.world.unilateral_relationship_get_interested_in_alliance(rel);
551 }
552 void on_update(sys::state& state) noexcept override {
553 auto const n = retrieve<dcon::nation_id>(state, parent);
555 frame = is_active(state) ? 1 : 0;
556 }
557 void button_action(sys::state& state) noexcept override {
558 auto const n = retrieve<dcon::nation_id>(state, parent);
559 command::toggle_interested_in_alliance(state, state.local_player_nation, n);
560 }
563 }
564 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
565 text::add_line(state, contents, "alice_interested_in_alliance");
566 }
567};
568
569class diplomacy_country_info : public listbox_row_element_base<dcon::nation_id> {
570public:
571 void on_create(sys::state& state) noexcept override {
573 base_data.position.x -= 14;
574 base_data.position.y -= 524;
575 }
576 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
577 if(name == "country_select") {
578 return make_element_by_type<diplomacy_country_select>(state, id);
579 } else if(name == "country_flag") {
580 auto ptr = make_element_by_type<flag_button>(state, id);
581 ptr->base_data.position.y -= 2; // Nudge
582 return ptr;
583 } else if(name == "country_name") {
584 return make_element_by_type<generic_name_text<dcon::nation_id>>(state, id);
585 } else if(name == "country_prio") {
586 auto ptr = make_element_by_type<diplomacy_priority_button>(state, id);
587 //
588 auto btn = make_element_by_type<diplomacy_country_interested_in_alliance>(state, "alice_interested_in_alliance");
589 btn->base_data.position = ptr->base_data.position;
590 btn->base_data.position.x -= btn->base_data.size.x;
591 add_child_to_front(std::move(btn));
592 //
593 return ptr;
594 } else if(name == "country_boss_flag") {
595 return make_element_by_type<nation_overlord_flag>(state, id);
596 } else if(name == "country_prestige") {
597 return make_element_by_type<nation_prestige_rank_text>(state, id);
598 } else if(name == "country_economic") {
599 return make_element_by_type<nation_industry_rank_text>(state, id);
600 } else if(name == "country_military") {
601 return make_element_by_type<nation_military_rank_text>(state, id);
602 } else if(name == "country_total") {
603 return make_element_by_type<nation_rank_text>(state, id);
604 } else if(name == "country_opinion") {
605 return make_element_by_type<nation_player_opinion_text>(state, id);
606 } else if(name == "country_relation") {
607 return make_element_by_type<nation_player_relations_text>(state, id);
608 } else if(name.substr(0, 10) == "country_gp") {
609 auto ptr = make_element_by_type<nation_gp_opinion_text>(state, id);
610 ptr->rank = uint16_t(std::stoi(std::string{name.substr(10)}));
611 return ptr;
612 } else {
613 return nullptr;
614 }
615 }
616};
617
619 dcon::nation_id data;
620};
621
622class diplomacy_country_listbox : public listbox_element_base<diplomacy_country_info, dcon::nation_id> {
623protected:
624 std::string_view get_row_element_name() override {
625 return "diplomacy_country_info";
626 }
627 void on_update(sys::state& state) noexcept override {
628 auto current_filter = retrieve< country_filter_setting>(state, parent);
629 auto current_sort = retrieve<country_sort_setting>(state, parent);
630
631 row_contents.clear();
632 state.world.for_each_nation([&](dcon::nation_id id) {
633 if(state.world.nation_get_owned_province_count(id) != 0) {
634 bool passes_filter = country_category_filter_check(state, current_filter.general_category, state.local_player_nation, id);
635 bool right_continent = !current_filter.continent || state.world.nation_get_capital(id).get_continent() == current_filter.continent;
636 if(passes_filter && right_continent)
637 row_contents.push_back(id);
638 }
639 });
640 sort_countries(state, row_contents, current_sort.sort, current_sort.sort_ascend);
641 update(state);
642 }
643
644 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
645 if(payload.holds_type<dip_make_nation_visible>()) {
647
648 auto n = any_cast<dip_make_nation_visible>(payload).data;
649 int32_t i = int32_t(row_contents.size());
650 for(; i-- > 0;) {
651 if(row_contents[i] == n) {
652 break;
653 }
654 }
655 if(i != -1) {
656 auto current_vis = list_scrollbar->raw_value();
657 auto vis_count = int32_t(row_windows.size());
658
659 if(i < current_vis || i >= current_vis + vis_count) {
661 update(state);
662 }
663 }
665 } else {
667 }
668 }
669};
670
672public:
673 void on_update(sys::state& state) noexcept override {
674 auto cb = retrieve<military::available_cb>(state, parent);
675 dcon::cb_type_id content = cb.cb_type;
676 frame = state.world.cb_type_get_sprite_index(content) - 1;
677
678 auto conditions = state.world.cb_type_get_can_use(cb.cb_type);
679 if(conditions) {
680 disabled = !trigger::evaluate(state, conditions, trigger::to_generic(retrieve<dcon::nation_id>(state, parent)), trigger::to_generic(state.local_player_nation), trigger::to_generic(retrieve<dcon::nation_id>(state, parent)));
681 } else {
682 disabled = false;
683 }
684 }
685
688 }
689
690 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
691 auto cb = retrieve<military::available_cb>(state, parent);
692 text::add_line(state, contents, state.world.cb_type_get_name(cb.cb_type));
693 if(cb.expiration) {
694 text::add_line(state, contents, "until_date", text::variable_type::x, cb.expiration);
695 }
696 auto conditions = state.world.cb_type_get_can_use(cb.cb_type);
697 if(conditions) {
699 text::add_line(state, contents, "cb_conditions_header");
700 ui::trigger_description(state, contents, conditions, trigger::to_generic(retrieve<dcon::nation_id>(state, parent)), trigger::to_generic(state.local_player_nation), trigger::to_generic(retrieve<dcon::nation_id>(state, parent)));
701 }
702 }
703};
704
705class overlapping_cb_icon : public listbox_row_element_base<military::available_cb> {
706public:
707 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
708 if(name == "wargoal_icon") {
709 return make_element_by_type<cb_icon>(state, id);
710 } else {
711 return nullptr;
712 }
713 }
714};
715
716class overlapping_wargoals : public overlapping_listbox_element_base<overlapping_cb_icon, military::available_cb> {
717protected:
718 std::string_view get_row_element_name() override {
719 return "wargoal";
720 }
721
722public:
723 void on_update(sys::state& state) noexcept override {
724 row_contents.clear();
725
726 auto content = retrieve<dcon::nation_id>(state, parent);
727 if(!content || content == state.local_player_nation)
728 return;
729
730 auto one_cbs = state.world.nation_get_available_cbs(state.local_player_nation);
731 for(auto& cb : one_cbs)
732 if(cb.target == content)
733 row_contents.push_back(cb);
734
735 for(auto cb : state.world.in_cb_type) {
736 if((cb.get_type_bits() & military::cb_flag::always) != 0) {
737 if(military::cb_conditions_satisfied(state, state.local_player_nation, content, cb))
738 row_contents.push_back(military::available_cb{ sys::date{}, content, cb});
739 }
740 }
741 update(state);
742
743 }
744};
745
746class overlapping_active_wargoals : public overlapping_listbox_element_base<overlapping_wg_icon, military::wg_summary> {
747protected:
748 std::string_view get_row_element_name() override {
749 return "wargoal";
750 }
751
752public:
753 void on_update(sys::state& state) noexcept override {
754 row_contents.clear();
755
756 auto content = retrieve<dcon::nation_id>(state, parent);
757
758 auto war = military::find_war_between(state, content, state.local_player_nation);
759
760 if(content && content != state.local_player_nation && war) {
761 for(auto wg : state.world.war_get_wargoals_attached(war)) {
762 if(wg.get_wargoal().get_added_by() == state.local_player_nation && wg.get_wargoal().get_target_nation() == content) {
764 wg.get_wargoal().get_secondary_nation(),
765 wg.get_wargoal().get_associated_tag(),
766 wg.get_wargoal().get_associated_state(),
767 wg.get_wargoal().get_type()
768 });
769 }
770 }
771 }
772
773
774 update(state);
775
776 }
777};
778
780public:
781 void on_update(sys::state& state) noexcept override {
782 auto content = retrieve<dcon::nation_id>(state, parent);
783 if(!content)
784 return;
785
786 disabled = true;
787 if(state.cheat_data.always_allow_wargoals) {
788 disabled = false;
789 return;
790 }
791
792 if(content == state.local_player_nation) {
793 return;
794 }
795
796 if(state.world.nation_get_diplomatic_points(state.local_player_nation) < state.defines.addwargoal_diplomatic_cost) {
797 return;
798 }
799
800 auto w = military::find_war_between(state, state.local_player_nation, content);
801 if(!w) {
802 return;
803 }
804
805 bool is_attacker = military::is_attacker(state, w, state.local_player_nation);
807 return;
808
809 for(auto cb_type : state.world.in_cb_type) {
810 if((state.world.cb_type_get_type_bits(cb_type) & military::cb_flag::always) == 0 && military::cb_conditions_satisfied(state, state.local_player_nation, content, cb_type)) {
811 bool cb_fabbed = false;
812 for(auto& fab_cb : state.world.nation_get_available_cbs(state.local_player_nation)) {
813 if(fab_cb.cb_type == cb_type && fab_cb.target == content) {
814 cb_fabbed = true;
815 break;
816 }
817 }
818 if(!cb_fabbed) {
819 if((state.world.cb_type_get_type_bits(cb_type) & military::cb_flag::is_not_constructing_cb) != 0)
820 continue; // can only add a constructable cb this way
821
822 auto totalpop = state.world.nation_get_demographics(state.local_player_nation, demographics::total);
823 auto jingoism_perc = totalpop > 0 ? state.world.nation_get_demographics(state.local_player_nation, demographics::to_key(state, state.culture_definitions.jingoism)) / totalpop : 0.0f;
824
825 if(state.world.war_get_is_great(w)) {
826 if(jingoism_perc >= state.defines.wargoal_jingoism_requirement * state.defines.gw_wargoal_jingoism_requirement_mod) {
827 disabled = false;
828 return;
829 }
830 } else {
831 if(jingoism_perc >= state.defines.wargoal_jingoism_requirement) {
832 disabled = false;
833 return;
834 }
835 }
836 } else {
837 disabled = false;
838 return;
839 }
840 } else { // this is an always CB
841 // prevent duplicate war goals
842 if(military::cb_conditions_satisfied(state, state.local_player_nation, content, cb_type) && military::can_add_always_cb_to_war(state, state.local_player_nation, content, cb_type, w)) {
843 disabled = false;
844 return;
845 }
846 }
847 }
848 }
849
850 void button_action(sys::state& state) noexcept override {
852 }
853
856 }
857
858 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
859 auto content = retrieve<dcon::nation_id>(state, parent);
860 if(content == state.local_player_nation) {
861 text::add_line_with_condition(state, contents, "add_wg_1", false);
862 return;
863 }
864
865 if(state.defines.addwargoal_diplomatic_cost > 0) {
866 text::add_line_with_condition(state, contents, "add_wg_3", state.world.nation_get_diplomatic_points(state.local_player_nation) >= state.defines.addwargoal_diplomatic_cost, text::variable_type::x, int64_t(state.defines.addwargoal_diplomatic_cost));
867 }
868
869 auto w = military::find_war_between(state, state.local_player_nation, content);
870 text::add_line_with_condition(state, contents, "add_wg_2", bool(w));
871 if(!w) {
872 return;
873 }
874
875 bool is_attacker = military::is_attacker(state, w, state.local_player_nation);
877
878 for(auto cb_type : state.world.in_cb_type) {
879 if(military::cb_conditions_satisfied(state, state.local_player_nation, content, cb_type)) {
880 if((state.world.cb_type_get_type_bits(cb_type) & military::cb_flag::always) == 0) {
881 for(auto& fab_cb : state.world.nation_get_available_cbs(state.local_player_nation)) {
882 if(fab_cb.cb_type == cb_type && fab_cb.target == content) {
883 return;
884 }
885 }
886 } else { // this is an always CB
887 // prevent duplicate war goals
888 if(military::can_add_always_cb_to_war(state, state.local_player_nation, content, cb_type, w)) {
889 return;
890 }
891 }
892 }
893 }
894
895 // if we hit this, it means no existing cb is ready to be applied
896 auto totalpop = state.world.nation_get_demographics(state.local_player_nation, demographics::total);
897 auto jingoism_perc = totalpop > 0 ? state.world.nation_get_demographics(state.local_player_nation, demographics::to_key(state, state.culture_definitions.jingoism)) / totalpop : 0.0f;
898 if(state.world.war_get_is_great(w)) {
899 text::add_line_with_condition(state, contents, "add_wg_4", jingoism_perc >= state.defines.wargoal_jingoism_requirement * state.defines.gw_wargoal_jingoism_requirement_mod, text::variable_type::x, text::fp_percentage_one_place{jingoism_perc}, text::variable_type::y, text::fp_percentage_one_place{state.defines.wargoal_jingoism_requirement * state.defines.gw_wargoal_jingoism_requirement_mod});
900 } else {
901 text::add_line_with_condition(state, contents, "add_wg_4", jingoism_perc >= state.defines.wargoal_jingoism_requirement, text::variable_type::x, text::fp_percentage_one_place{jingoism_perc}, text::variable_type::y, text::fp_percentage_one_place{state.defines.wargoal_jingoism_requirement});
902 }
903 }
904};
905
907public:
908 void on_update(sys::state& state) noexcept override {
909 auto pc = state.world.nation_get_primary_culture(retrieve<dcon::nation_id>(state, parent));
910 auto pr = state.world.nation_get_religion(retrieve<dcon::nation_id>(state, parent));
911 std::string t = text::produce_simple_string(state, pc.get_name());
912 t += ", ";
913 t += text::produce_simple_string(state, pr.get_name());
914 set_text(state, t);
915 }
918 }
919 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
920 auto content = retrieve<dcon::nation_id>(state, parent);
921 text::add_line(state, contents, "is_primary_culture", text::variable_type::name, state.world.culture_get_name(state.world.nation_get_primary_culture(content)));
922 text::add_line(state, contents, "is_primary_religion", text::variable_type::name, state.world.religion_get_name(state.world.nation_get_religion(content)));
923 }
924};
925
927 void on_update(sys::state& state) noexcept override {
928 auto n = retrieve<dcon::nation_id>(state, parent);
929 bool first = true;
930 std::string t;
931 for(const auto ac : state.world.in_culture) {
932 if(state.world.nation_get_accepted_cultures(n, ac)) {
933 if(first) {
934 first = false;
935 } else {
936 t += ", ";
937 }
938 t += text::produce_simple_string(state, state.world.culture_get_name(ac));
939 }
940 }
942 }
943 tooltip_behavior has_tooltip(sys::state& state) noexcept override {
945 }
946 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
947 auto n = retrieve<dcon::nation_id>(state, parent);
948 for(const auto c : state.world.in_culture) {
949 if(state.world.nation_get_accepted_cultures(n, c))
950 text::add_line(state, contents, "is_accepted_culture2", text::variable_type::name, state.world.culture_get_name(c));
951 }
952 }
953};
954
956public:
957 bool show = false;
958
959 void on_update(sys::state& state) noexcept override {
960 show = nations::is_great_power(state, retrieve<dcon::nation_id>(state, parent));
961 }
962 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
963 if(show)
965 }
966};
967
969 int32_t value = 0;
970};
971
973public:
974 bool show = false;
975 void on_update(sys::state& state) noexcept override {
976 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_detail_num>(state, parent).value));
977 auto target = retrieve<dcon::nation_id>(state, parent);
978 show = (state.world.gp_relationship_get_status(state.world.get_gp_relationship_by_gp_influence_pair(target, gp)) & nations::influence::is_banned) != 0;
979 }
982 }
983
984 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
985 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_detail_num>(state, parent).value));
986 auto target = retrieve<dcon::nation_id>(state, parent);
987 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, gp);
988
989 text::add_line(state, contents, "dp_inf_tooltip_ban", text::variable_type::x, state.world.gp_relationship_get_penalty_expires_date(rel));
990 }
991 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
992 if(show)
994 }
995};
996
998public:
999 bool show = false;
1000 void on_update(sys::state& state) noexcept override {
1001 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_detail_num>(state, parent).value));
1002 auto target = retrieve<dcon::nation_id>(state, parent);
1003 show = (state.world.gp_relationship_get_status(state.world.get_gp_relationship_by_gp_influence_pair(target, gp)) & nations::influence::is_discredited) != 0;
1004 }
1007 }
1008
1009 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1010 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_detail_num>(state, parent).value));
1011 auto target = retrieve<dcon::nation_id>(state, parent);
1012 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, gp);
1013
1014 text::add_line(state, contents, "dp_inf_tooltip_discredit", text::variable_type::x, state.world.gp_relationship_get_penalty_expires_date(rel));
1015 }
1016 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
1017 if(show)
1019 }
1020};
1021
1023public:
1024 void on_update(sys::state& state) noexcept override {
1025 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_detail_num>(state, parent).value));
1026 auto target = retrieve<dcon::nation_id>(state, parent);
1027
1028 set_text(state, text::get_influence_level_name(state, state.world.gp_relationship_get_status(state.world.get_gp_relationship_by_gp_influence_pair(target, gp))));
1029 }
1030};
1032public:
1033 void on_update(sys::state& state) noexcept override {
1034 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_detail_num>(state, parent).value));
1035 auto target = retrieve<dcon::nation_id>(state, parent);
1036
1037 set_text(state, text::format_float(state.world.gp_relationship_get_influence(state.world.get_gp_relationship_by_gp_influence_pair(target, gp)), 1));
1038 }
1039};
1041public:
1042 void on_update(sys::state& state) noexcept override {
1043 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_detail_num>(state, parent).value));
1044 auto target = retrieve<dcon::nation_id>(state, parent);
1045
1046 set_text(state, text::format_money(state.world.unilateral_relationship_get_foreign_investment(state.world.get_unilateral_relationship_by_unilateral_pair(target, gp))));
1047 }
1048};
1049
1051public:
1052 virtual dcon::national_identity_id get_current_nation(sys::state& state) noexcept override {
1053 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_detail_num>(state, parent).value));
1054 return state.world.nation_get_identity_from_identity_holder(gp);
1055 }
1056};
1057
1060};
1061
1063public:
1064 int32_t gp_num = 0;
1065
1066 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1067 if(name == "country_flag") {
1068 return make_element_by_type<great_power_detail_flag>(state, id);
1069 } else if(name == "nongp_country_opinion") {
1070 return make_element_by_type<great_power_opinion_detail>(state, id);
1071 } else if(name == "nongp_country_influence") {
1072 return make_element_by_type<great_power_influence_detail>(state, id);
1073 } else if(name == "nongp_country_invest") {
1074 return make_element_by_type<great_power_investment_detail>(state, id);
1075 } else if(name == "country_discredited") {
1076 return make_element_by_type<gp_detail_discredited>(state, id);
1077 } else if(name == "country_banned_embassy") {
1078 return make_element_by_type<gp_detail_banned>(state, id);
1079 }
1080
1081 return nullptr;
1082 }
1083
1084 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
1085 if(payload.holds_type<gp_detail_num>()) {
1086 payload.emplace<gp_detail_num>(gp_detail_num{ gp_num });
1088 }
1089 return window_element_base::get(state, payload);
1090 }
1091};
1092
1093template<class T>
1095public:
1096
1097 void on_update(sys::state& state) noexcept override {
1098 T content = retrieve<T>(state, parent);
1099 dcon::overlord_id overlord = state.world.nation_get_overlord_as_subject(content);
1100 dcon::nation_id overlord_nation = state.world.overlord_get_ruler(overlord);
1101 auto fat_id = dcon::fatten(state.world, overlord_nation);
1102 if(state.world.nation_get_is_substate(content)) {
1104 } else if(overlord_nation) {
1106 } else {
1108 }
1109 }
1110};
1111
1113private:
1114 flag_button* country_flag = nullptr;
1115 nation_player_relations_text* country_relation = nullptr;
1116 image_element_base* country_relation_icon = nullptr;
1117
1118 ui::xy_pair sub_window_top_left = {};
1119
1120 std::array<element_base*, 7> gp_elements;
1121 std::array<element_base*, 9> non_gp_elements;
1122 std::array<element_base*, 21> war_elements;
1123
1124public:
1125 void on_create(sys::state& state) noexcept override {
1127 uint32_t row_count = uint32_t(state.defines.great_nations_count) / 2;
1128 for(uint32_t i = 0; i < uint32_t(state.defines.great_nations_count); i++) {
1129 auto win = make_element_by_type<great_power_inf_detail>(state, state.ui_state.defs_by_name.find(state.lookup_key("diplomacy_non_gp_extra_info"))->second.definition);
1130 win->gp_num = int32_t(i);
1131 win->base_data.position = sub_window_top_left;
1132 win->base_data.position.x += win->base_data.size.x * int16_t(i / row_count);
1133 win->base_data.position.y += win->base_data.size.y * int16_t(i % row_count);
1134 non_gp_elements[1 + i] = win.get();
1135 add_child_to_front(std::move(win));
1136 }
1137 }
1138
1139 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1140 if(name == "gp_extra_info_bg") {
1141 auto ptr = make_element_by_type<image_element_base>(state, id);
1142 gp_elements[0] = ptr.get();
1143 return ptr;
1144 } else if(name == "country_gp_friendly_label") {
1145 auto ptr = make_element_by_type<simple_text_element_base>(state, id);
1146 gp_elements[1] = ptr.get();
1147 return ptr;
1148 } else if(name == "country_gp_cordial_label") {
1149 auto ptr = make_element_by_type<simple_text_element_base>(state, id);
1150 gp_elements[2] = ptr.get();
1151 return ptr;
1152 } else if(name == "country_gp_sphere_label") {
1153 auto ptr = make_element_by_type<simple_text_element_base>(state, id);
1154 gp_elements[3] = ptr.get();
1155 return ptr;
1156 } else if(name == "country_gp_friendly") {
1157 auto ptr = make_element_by_type<overlapping_friendly_flags>(state, id);
1158 ptr->base_data.position.y -= 8 - 1; // Nudge
1159 gp_elements[4] = ptr.get();
1160 return ptr;
1161 } else if(name == "country_gp_cordial") {
1162 auto ptr = make_element_by_type<overlapping_cordial_flags>(state, id);
1163 ptr->base_data.position.y -= 8 - 1; // Nudge
1164 gp_elements[5] = ptr.get();
1165 return ptr;
1166 } else if(name == "country_gp_sphere") {
1167 auto ptr = make_element_by_type<overlapping_sphere_flags>(state, id);
1168 ptr->base_data.position.y -= 8 - 1; // Nudge
1169 gp_elements[6] = ptr.get();
1170 return ptr;
1171 } else if(name == "nongp_extra_info_bg") {
1172 auto ptr = make_element_by_type<image_element_base>(state, id);
1173 non_gp_elements[0] = ptr.get();
1174 auto const& def = state.ui_defs.gui[state.ui_state.defs_by_name.find(state.lookup_key("diplomacy_non_gp_extra_fact_pos"))->second.definition];
1175 sub_window_top_left = def.position;
1176 return ptr;
1177 } else if(name == "country_flag") {
1178 return make_element_by_type<flag_button>(state, id);
1179 } else if(name == "country_flag_overlay") {
1180 return make_element_by_type<nation_flag_frame>(state, id);
1181 } else if(name == "country_name") {
1182 return make_element_by_type<generic_name_text<dcon::nation_id>>(state, id);
1183 } else if(name == "country_status") {
1184 auto ptr = make_element_by_type<nation_status_diplomacy_window<dcon::nation_id>>(state, id);
1185 return ptr;
1186 } else if(name == "selected_nation_totalrank") {
1187 return make_element_by_type<nation_rank_text>(state, id);
1188 } else if(name == "ideology_icon") {
1189 return make_element_by_type<nation_ruling_party_ideology_plupp>(state, id);
1190 } else if(name == "country_party") {
1191 return make_element_by_type<nation_ruling_party_text>(state, id);
1192 } else if(name == "country_gov") {
1193 return make_element_by_type<nation_government_type_text>(state, id);
1194 } else if(name == "country_tech") {
1195 return make_element_by_type<national_tech_school>(state, id);
1196 } else if(name == "our_relation_icon") {
1197 auto ptr = make_element_by_type<image_element_base>(state, id);
1198 country_relation_icon = ptr.get();
1199 return ptr;
1200 } else if(name == "our_relation") {
1201 auto ptr = make_element_by_type<nation_player_relations_text>(state, id);
1202 country_relation = ptr.get();
1203 return ptr;
1204 } else if(name == "country_prestige") {
1205 return make_element_by_type<nation_prestige_text>(state, id);
1206 } else if(name == "selected_prestige_rank") {
1207 return make_element_by_type<nation_prestige_rank_text>(state, id);
1208 } else if(name == "country_economic") {
1209 return make_element_by_type<nation_industry_score_text>(state, id);
1210 } else if(name == "selected_industry_rank") {
1211 return make_element_by_type<nation_industry_rank_text>(state, id);
1212 } else if(name == "country_military") {
1213 return make_element_by_type<nation_military_score_text>(state, id);
1214 } else if(name == "selected_military_rank") {
1215 return make_element_by_type<nation_military_rank_text>(state, id);
1216 } else if(name == "country_total") {
1217 return make_element_by_type<nation_total_score_text>(state, id);
1218 } else if(name == "selected_total_rank") {
1219 return make_element_by_type<nation_rank_text>(state, id);
1220 } else if(name == "country_population") {
1221 return make_element_by_type<nation_population_text>(state, id);
1222 } else if(name == "country_primary_cultures") {
1223 return make_element_by_type<nation_primary_culture>(state, id);
1224 } else if(name == "country_accepted_cultures") {
1225 return make_element_by_type<nation_accepted_cultures>(state, id);
1226 } else if(name == "war_extra_info_bg") {
1227 auto ptr = make_element_by_type<image_element_base>(state, id);
1228 war_elements[0] = ptr.get();
1229 return ptr;
1230 } else if(name == "country_wars") {
1231 auto ptr = make_element_by_type<overlapping_enemy_flags>(state, id);
1232 ptr->base_data.position.y -= 8 - 1; // Nudge
1233 war_elements[1] = ptr.get();
1234 return ptr;
1235 } else if(name == "country_wars_text") {
1236 auto ptr = make_element_by_type<simple_text_element_base>(state, id);
1237 war_elements[2] = ptr.get();
1238 return ptr;
1239 } else if(name == "country_allies_text") {
1240 auto ptr = make_element_by_type<simple_text_element_base>(state, id);
1241 war_elements[3] = ptr.get();
1242 return ptr;
1243 } else if(name == "country_protected_text") {
1244 auto ptr = make_element_by_type<simple_text_element_base>(state, id);
1245 war_elements[4] = ptr.get();
1246 return ptr;
1247 } else if(name == "country_truce_text") {
1248 auto ptr = make_element_by_type<simple_text_element_base>(state, id);
1249 war_elements[5] = ptr.get();
1250 return ptr;
1251 } else if(name == "country_cb_text") {
1252 auto ptr = make_element_by_type<simple_text_element_base>(state, id);
1253 war_elements[6] = ptr.get();
1254 return ptr;
1255 } else if(name == "infamy_icon") {
1256 auto ptr = make_element_by_type<image_element_base>(state, id);
1257 war_elements[7] = ptr.get();
1258 return ptr;
1259 } else if(name == "warexhastion_icon") {
1260 auto ptr = make_element_by_type<image_element_base>(state, id);
1261 war_elements[8] = ptr.get();
1262 return ptr;
1263 } else if(name == "brigade_icon") {
1264 auto ptr = make_element_by_type<image_element_base>(state, id);
1265 war_elements[9] = ptr.get();
1266 return ptr;
1267 } else if(name == "ships_icon") {
1268 auto ptr = make_element_by_type<image_element_base>(state, id);
1269 war_elements[10] = ptr.get();
1270 return ptr;
1271 } else if(name == "country_allies") {
1272 auto ptr = make_element_by_type<overlapping_ally_flags>(state, id);
1273 ptr->base_data.position.y -= 8 - 1; // Nudge
1274 war_elements[11] = ptr.get();
1275 return ptr;
1276 } else if(name == "country_protected") {
1277 auto ptr = make_element_by_type<overlapping_sphere_flags>(state, id);
1278 ptr->base_data.position.y -= 8 - 1; // Nudge
1279 war_elements[12] = ptr.get();
1280 return ptr;
1281 } else if(name == "country_truce") {
1282 auto ptr = make_element_by_type<overlapping_truce_flags>(state, id);
1283 ptr->base_data.position.y -= 8 - 1; // Nudge
1284 war_elements[13] = ptr.get();
1285 return ptr;
1286 } else if(name == "current_wargoals") {
1287 auto ptr = make_element_by_type<overlapping_active_wargoals>(state, id);
1288 war_elements[14] = ptr.get();
1289 return ptr;
1290 } else if(name == "country_cb") {
1291 auto ptr = make_element_by_type<overlapping_wargoals>(state, id);
1292 war_elements[15] = ptr.get();
1293 return ptr;
1294 } else if(name == "infamy_text") {
1295 auto ptr = make_element_by_type<nation_infamy_text>(state, id);
1296 war_elements[16] = ptr.get();
1297 return ptr;
1298 } else if(name == "warexhastion_text") {
1299 auto ptr = make_element_by_type<diplomacy_war_exhaustion>(state, id);
1300 war_elements[17] = ptr.get();
1301 return ptr;
1302 } else if(name == "brigade_text") {
1303 auto ptr = make_element_by_type<diplomacy_nation_armies_text>(state, id);
1304 war_elements[18] = ptr.get();
1305 return ptr;
1306 } else if(name == "ships_text") {
1307 auto ptr = make_element_by_type<diplomacy_nation_navies_text>(state, id);
1308 war_elements[19] = ptr.get();
1309 return ptr;
1310 } else if(name == "add_wargoal") {
1311 auto ptr = make_element_by_type<diplomacy_action_add_wargoal_button>(state, id);
1312 war_elements[20] = ptr.get();
1313 return ptr;
1314 } else if(name == "selected_military_icon") {
1315 return make_element_by_type<military_score_icon>(state, id);
1316 } else {
1317 return nullptr;
1318 }
1319 }
1320
1321 void on_update(sys::state& state) noexcept override {
1322 auto content = retrieve<dcon::nation_id>(state, parent);
1323 country_relation->set_visible(state, content != state.local_player_nation);
1324 country_relation_icon->set_visible(state, content != state.local_player_nation);
1325 auto active_tab = retrieve<dip_tab_request>(state, parent).tab;
1326
1327 if(active_tab != diplomacy_window_tab::great_powers) {
1328 for(auto p : gp_elements) {
1329 if(p)
1330 p->set_visible(state, false);
1331 }
1332 for(auto p : non_gp_elements) {
1333 if(p)
1334 p->set_visible(state, false);
1335 }
1336 for(auto p : war_elements) {
1337 if(p)
1338 p->set_visible(state, true);
1339 }
1340 } else if(nations::is_great_power(state, content)) {
1341 for(auto p : gp_elements) {
1342 if(p)
1343 p->set_visible(state, true);
1344 }
1345 for(auto p : non_gp_elements) {
1346 if(p)
1347 p->set_visible(state, false);
1348 }
1349 for(auto p : war_elements) {
1350 if(p)
1351 p->set_visible(state, false);
1352 }
1353 } else {
1354 for(auto p : gp_elements) {
1355 if(p)
1356 p->set_visible(state, false);
1357 }
1358 for(auto p : non_gp_elements) {
1359 if(p)
1360 p->set_visible(state, true);
1361 }
1362 for(auto p : war_elements) {
1363 if(p)
1364 p->set_visible(state, false);
1365 }
1366 }
1367
1368 }
1369};
1370
1372protected:
1374 row_contents.clear();
1375 dcon::war_id w = retrieve<dcon::war_id>(state, parent);
1376 auto war = dcon::fatten(state.world, w);
1377 row_contents.push_back(war.get_primary_attacker().get_identity_from_identity_holder().id);
1378 for(auto o : war.get_war_participant())
1379 if(o.get_is_attacker() == true && o.get_nation() != war.get_primary_attacker())
1380 row_contents.push_back(o.get_nation().get_identity_from_identity_holder().id);
1381 update(state);
1382 }
1383};
1385protected:
1387 row_contents.clear();
1388 dcon::war_id w = retrieve<dcon::war_id>(state, parent);
1389 auto war = dcon::fatten(state.world, w);
1390 row_contents.push_back(war.get_primary_defender().get_identity_from_identity_holder().id);
1391 for(auto o : war.get_war_participant())
1392 if(o.get_is_attacker() == false && o.get_nation() != war.get_primary_defender())
1393 row_contents.push_back(o.get_nation().get_identity_from_identity_holder().id);
1394 update(state);
1395 }
1396};
1397
1398template<bool IsAttacker>
1400public:
1401 void on_update(sys::state& state) noexcept override {
1402 dcon::war_id content = retrieve<dcon::war_id>(state, parent);
1403
1404 auto fat_id = dcon::fatten(state.world, content);
1405 int32_t strength = 0;
1406 for(auto o : fat_id.get_war_participant())
1407 if(o.get_is_attacker() == IsAttacker)
1408 strength += int32_t(o.get_nation().get_military_score());
1409 set_button_text(state, std::to_string(strength));
1410 }
1411
1414 }
1415
1416 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1417 dcon::war_id content = retrieve<dcon::war_id>(state, parent);
1418 auto fat_id = dcon::fatten(state.world, content);
1419 {
1420 auto box = text::open_layout_box(contents, 0);
1422 text::add_to_substitution_map(sub, text::variable_type::date, fat_id.get_start_date());
1423 text::localised_format_box(state, contents, box, "war_start_date_desc", sub);
1424 text::close_layout_box(contents, box);
1425 }
1426 for(auto o : fat_id.get_war_participant()) {
1427 if(o.get_is_attacker() == IsAttacker) {
1428 auto name = text::get_name(state, o.get_nation().id);
1429 auto box = text::open_layout_box(contents, 0);
1431 text::add_to_layout_box(state, contents, box, std::string{":"}, text::text_color::yellow);
1432 text::add_space_to_layout_box(state, contents, box);
1433 auto strength = int32_t(o.get_nation().get_military_score());
1434 text::add_to_layout_box(state, contents, box, std::to_string(strength), text::text_color::white);
1435 text::close_layout_box(contents, box);
1436 }
1437 }
1438 }
1439};
1440
1441template<bool B>
1443public:
1444 void on_create(sys::state& state) noexcept override {
1447 }
1448
1449 void on_update(sys::state& state) noexcept override {
1450 dcon::war_id war_id = retrieve<dcon::war_id>(state, parent);
1451 disabled = !command::can_intervene_in_war(state, state.local_player_nation, war_id, B);
1452 }
1453
1454 void button_action(sys::state& state) noexcept override {
1455 dcon::war_id war_id = retrieve<dcon::war_id>(state, parent);
1456 command::intervene_in_war(state, state.local_player_nation, war_id, B);
1457 }
1458
1461 }
1462
1463 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1464
1465 dcon::nation_id nation_id = retrieve<dcon::nation_id>(state, parent);
1466 dcon::war_id w = retrieve<dcon::war_id>(state, parent);
1467
1468 if(!state.world.war_get_is_great(w)) {
1469 text::add_line(state, contents, "intervene_1");
1470 } else {
1471 text::add_line(state, contents, "intervene_2");
1472 }
1474
1475 text::add_line_with_condition(state, contents, "intervene_3", nations::is_great_power(state, state.local_player_nation));
1476 text::add_line_with_condition(state, contents, "intervene_4", !nations::is_involved_in_crisis(state, state.local_player_nation));
1477 if(state.defines.min_months_to_intervene > 0) {
1478 text::add_line_with_condition(state, contents, "intervene_5", state.current_date >= state.world.war_get_start_date(w) + int32_t(30.0f * state.defines.min_months_to_intervene), text::variable_type::x, int64_t(state.defines.min_months_to_intervene));
1479 }
1480 text::add_line_with_condition(state, contents, "intervene_6", military::joining_war_does_not_violate_constraints(state, state.local_player_nation, w, B));
1481
1482 if constexpr(!B) {
1483 text::add_line_with_condition(state, contents, "intervene_8", !military::has_truce_with(state, state.local_player_nation, state.world.war_get_primary_attacker(w)));
1484 }
1485
1486 if(!state.world.war_get_is_great(w)) {
1487 auto defender = state.world.war_get_primary_defender(w);
1488 auto rel_w_defender = state.world.get_gp_relationship_by_gp_influence_pair(defender, state.local_player_nation);
1489 auto inf = state.world.gp_relationship_get_status(rel_w_defender) & nations::influence::level_mask;
1490
1492
1493 text::add_line_with_condition(state, contents, "intervene_7", !state.world.war_get_is_crisis_war(w));
1494 text::add_line_with_condition(state, contents, "intervene_9", !B);
1496 text::add_line_with_condition(state, contents, "intervene_11", military::primary_warscore(state, w) >= -state.defines.min_warscore_to_intervene, text::variable_type::x, int64_t(-state.defines.min_warscore_to_intervene));
1497
1498 } else {
1499 if constexpr(B) {
1500 text::add_line_with_condition(state, contents, "intervene_8", !military::joining_as_attacker_would_break_truce(state, state.local_player_nation, w));
1501 }
1502
1503 text::add_line_with_condition(state, contents, "intervene_12", state.world.nation_get_war_exhaustion(state.local_player_nation) < state.defines.gw_intervene_max_exhaustion, text::variable_type::x, int64_t(state.defines.gw_intervene_max_exhaustion));
1504
1505 auto primary_on_side = B ? state.world.war_get_primary_attacker(w) : state.world.war_get_primary_defender(w);
1506 auto rel = state.world.get_diplomatic_relation_by_diplomatic_pair(primary_on_side, state.local_player_nation);
1507
1508 text::add_line_with_condition(state, contents, "intervene_13", state.world.diplomatic_relation_get_value(rel) >= state.defines.gw_intervene_min_relations, text::variable_type::x, int64_t(state.defines.gw_intervene_min_relations));
1509
1510 bool any_in_sphere = false;
1511 bool any_allied = false;
1512 bool any_armies = false;
1513
1514 for(auto p : state.world.war_get_war_participant(w)) {
1515 if(p.get_is_attacker() != B) { // scan nations on other side
1516 if(p.get_nation().get_in_sphere_of() == state.local_player_nation)
1517 any_in_sphere = true;
1518
1519 auto irel = state.world.get_diplomatic_relation_by_diplomatic_pair(p.get_nation(), state.local_player_nation);
1520 if(state.world.diplomatic_relation_get_are_allied(irel))
1521 any_allied = true;
1522
1523 for(auto prov : p.get_nation().get_province_ownership()) {
1524 for(auto arm : prov.get_province().get_army_location()) {
1525 if(arm.get_army().get_controller_from_army_control() == state.local_player_nation)
1526 any_armies = true;
1527 }
1528 }
1529 }
1530 }
1531 text::add_line_with_condition(state, contents, "intervene_14", !any_in_sphere);
1532 text::add_line_with_condition(state, contents, "intervene_15", !any_allied);
1533 text::add_line_with_condition(state, contents, "intervene_16", !any_armies);
1534 }
1535
1536
1537 }
1538};
1539
1541public:
1542 void on_update(sys::state& state) noexcept override {
1543 auto wg = retrieve<dcon::wargoal_id>(state, parent);
1544 frame = state.world.cb_type_get_sprite_index(state.world.wargoal_get_type(wg)) - 1;
1545 }
1546
1549 }
1550
1551 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1552 auto wg = retrieve<dcon::wargoal_id>(state, parent);
1553 auto cb = state.world.wargoal_get_type(wg);
1554 text::add_line(state, contents, state.world.cb_type_get_name(cb));
1555
1557 text::add_line(state, contents, "war_goal_1", text::variable_type::x, state.world.wargoal_get_added_by(wg));
1558 text::add_line(state, contents, "war_goal_2", text::variable_type::x, state.world.wargoal_get_target_nation(wg));
1559 if(state.world.wargoal_get_associated_state(wg)) {
1560 text::add_line(state, contents, "war_goal_3", text::variable_type::x, state.world.wargoal_get_associated_state(wg));
1561 }
1562 if(state.world.wargoal_get_associated_tag(wg)) {
1563 text::add_line(state, contents, "war_goal_10", text::variable_type::x, state.world.wargoal_get_associated_tag(wg));
1564 } else if(state.world.wargoal_get_secondary_nation(wg)) {
1565 text::add_line(state, contents, "war_goal_4", text::variable_type::x, state.world.wargoal_get_secondary_nation(wg));
1566 }
1567 if(state.world.wargoal_get_ticking_war_score(wg) != 0) {
1568 text::add_line(state, contents, "war_goal_5", text::variable_type::x, text::fp_one_place{state.world.wargoal_get_ticking_war_score(wg)});
1569 {
1570 auto box = text::open_layout_box(contents);
1572 text::add_to_substitution_map(sub, text::variable_type::x, text::fp_percentage{ state.defines.tws_fulfilled_idle_space });
1574 text::localised_format_box(state, contents, box, "war_goal_6", sub);
1575 text::close_layout_box(contents, box);
1576 }
1577 {
1578 auto box = text::open_layout_box(contents);
1580 text::add_to_substitution_map(sub, text::variable_type::x, text::pretty_integer{ int32_t(state.defines.tws_grace_period_days) });
1581 text::add_to_substitution_map(sub, text::variable_type::y, text::fp_two_places{ state.defines.tws_not_fulfilled_speed });
1582 text::localised_format_box(state, contents, box, "war_goal_7", sub);
1583 text::close_layout_box(contents, box);
1584 }
1585 auto const start_date = state.world.war_get_start_date(state.world.wargoal_get_war_from_wargoals_attached(wg));
1586 auto const end_date = start_date + int32_t(state.defines.tws_grace_period_days);
1587 auto box = text::open_layout_box(contents);
1591 if(end_date <= state.current_date) {
1592 text::localised_format_box(state, contents, box, "war_goal_9", sub);
1593 } else {
1594 text::localised_format_box(state, contents, box, "war_goal_8", sub);
1595 }
1596 text::close_layout_box(contents, box);
1597 }
1598 }
1599};
1600
1601class overlapping_wargoal_icon : public listbox_row_element_base<dcon::wargoal_id> {
1602public:
1603 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1604 if(name == "wargoal_icon") {
1605 return make_element_by_type<wargoal_icon>(state, id);
1606 } else {
1607 return nullptr;
1608 }
1609 }
1610};
1611
1612template<bool B>
1613class diplomacy_war_overlapping_wargoals : public overlapping_listbox_element_base<overlapping_wargoal_icon, dcon::wargoal_id> {
1614protected:
1615 std::string_view get_row_element_name() override {
1616 return "wargoal";
1617 }
1618
1619public:
1620 void on_update(sys::state& state) noexcept override {
1621 row_contents.clear();
1622
1623 dcon::war_id content = retrieve<dcon::war_id>(state, parent);
1624 for(auto wg : state.world.war_get_wargoals_attached(content)) {
1625 if(military::is_attacker(state, content, wg.get_wargoal().get_added_by()) == B)
1626 row_contents.push_back(wg.get_wargoal().id);
1627 }
1628
1629 update(state);
1630 }
1631};
1632
1634 void on_update(sys::state& state) noexcept override {
1635 auto w = retrieve<dcon::war_id>(state, parent);
1636 auto s = military::get_war_name(state, w);
1637 set_text(state, s);
1638 }
1639};
1640
1642public:
1643 void on_update(sys::state& state) noexcept override {
1644 auto war = retrieve<dcon::war_id>(state, parent);
1645 if(war) {
1646 auto ws = military::primary_warscore(state, war);
1647 progress = ws / 200.0f + 0.5f;
1648 }
1649 }
1650
1653 }
1654
1655 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1656 auto war = retrieve<dcon::war_id>(state, parent);
1661 }
1662};
1663
1666 int16_t width = 0;
1667};
1668
1670public:
1671 void on_update(sys::state& state) noexcept override {
1672 auto bar_pos = retrieve<war_bar_position>(state, parent);
1673 auto war = retrieve<dcon::war_id>(state, parent);
1674
1675 auto attacker_cost = std::min(military::attacker_peace_cost(state, war), 100);
1676 auto x_pos = int16_t((float(attacker_cost) / 200.0f + 0.5f) * float(bar_pos.width));
1677
1678 base_data.position.x = int16_t(x_pos + bar_pos.bottom_left.x - base_data.size.x / 2);
1679 base_data.position.y = bar_pos.bottom_left.y;
1680 }
1681};
1682
1684public:
1685 void on_update(sys::state& state) noexcept override {
1686 auto bar_pos = retrieve<war_bar_position>(state, parent);
1687 auto war = retrieve<dcon::war_id>(state, parent);
1688
1689 auto defender_cost = std::min(military::defender_peace_cost(state, war), 100);
1690 auto x_pos = int16_t((float(-defender_cost) / 200.0f + 0.5f) * float(bar_pos.width));
1691
1692 base_data.position.x = int16_t(x_pos + bar_pos.bottom_left.x - base_data.size.x / 2);
1693 base_data.position.y = bar_pos.bottom_left.y;
1694 }
1695};
1696
1698 void on_update(sys::state& state) noexcept override {
1699 auto war = retrieve<dcon::war_id>(state, parent);
1700 if(state.world.war_get_is_great(war)) {
1701 frame = 2;
1702 } else if(state.world.war_get_is_crisis_war(war)) {
1703 frame = 1;
1704 } else {
1705 frame = 0;
1706 }
1707 }
1708};
1709
1711public:
1712 void on_update(sys::state& state) noexcept override {
1713 auto war = retrieve<dcon::war_id>(state, parent);
1714 if(war) {
1715 auto ws = military::primary_warscore(state, war) / 100.0f;
1717 }
1718 }
1719};
1720
1721class diplomacy_war_info : public listbox_row_element_base<dcon::war_id> {
1722public:
1724
1725 void on_create(sys::state& state) noexcept override {
1728 }
1729
1730 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1731 if(name == "diplo_war_entrybg") {
1732 return make_element_by_type<war_bg>(state, id);
1733 } else if(name == "war_name") {
1734 return make_element_by_type<war_name_text>(state, id);
1735 } else if(name == "attackers_mil_strength") {
1736 auto ptr = make_element_by_type<war_side_strength_text<true>>(state, id);
1737 ptr->base_data.position.y -= 4; // Nudge
1738 return ptr;
1739 } else if(name == "defenders_mil_strength") {
1740 auto ptr = make_element_by_type<war_side_strength_text<false>>(state, id);
1741 ptr->base_data.position.y -= 4; // Nudge
1742 return ptr;
1743 } else if(name == "warscore") {
1744 auto ptr = make_element_by_type<war_score_progress_bar>(state, id);
1745 bar_position.width = ptr->base_data.size.x;
1746 bar_position.bottom_left = ui::xy_pair{ptr->base_data.position.x, int16_t(ptr->base_data.position.y + ptr->base_data.size.y)};
1747 return ptr;
1748 } if(name == "diplo_warscore_marker1") {
1749 return make_element_by_type<attacker_peace_goal>(state, id);
1750 } else if(name == "diplo_warscore_marker2") {
1751 return make_element_by_type<defender_peace_goal>(state, id);
1752 } else if(name == "warscore_text") {
1753 auto ptr = make_element_by_type<war_score_text>(state, id);
1754 ptr->base_data.position.y -= 2;
1755 return ptr;
1756 } else if(name == "attackers") {
1757 auto ptr = make_element_by_type<overlapping_attacker_flags>(state, id);
1758 ptr->base_data.position.y -= 8 - 2;
1759 return ptr;
1760 } else if(name == "defenders") {
1761 auto ptr = make_element_by_type<overlapping_defender_flags>(state, id);
1762 ptr->base_data.position.y -= 8 - 2;
1763 return ptr;
1764 } else if(name == "attackers_wargoals") {
1765 return make_element_by_type<diplomacy_war_overlapping_wargoals<true>>(state, id);
1766 } else if(name == "defenders_wargoals") {
1767 return make_element_by_type<diplomacy_war_overlapping_wargoals<false>>(state, id);
1768 } else if(name == "join_attackers") {
1769 return make_element_by_type<diplomacy_join_war_button<true>>(state, id);
1770 } else if(name == "join_defenders") {
1771 return make_element_by_type<diplomacy_join_war_button<false>>(state, id);
1772 } else {
1773 return nullptr;
1774 }
1775 }
1776
1777 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
1778 if(payload.holds_type<war_bar_position>()) {
1779 payload.emplace<war_bar_position>(bar_position);
1781 }
1783 }
1784};
1785
1787public:
1788 void on_update(sys::state& state) noexcept override {
1789 const dcon::nation_id content = retrieve<dcon::nation_id>(state, parent);
1790 auto fat = dcon::fatten(state.world, content);
1791 frame = fat.get_constructing_cb_type().get_sprite_index() - 1;
1792 }
1793
1796 }
1797
1798 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1799 const dcon::nation_id content = retrieve<dcon::nation_id>(state, parent);
1800 auto fat = dcon::fatten(state.world, content);
1801 auto box = text::open_layout_box(contents);
1802 text::add_to_layout_box(state, contents, box, fat.get_constructing_cb_type().get_name(), text::text_color::yellow);
1803 text::add_to_layout_box(state, contents, box, std::string_view(": "), text::text_color::yellow);
1804 text::add_to_layout_box(state, contents, box, fat.get_constructing_cb_target());
1805 text::close_layout_box(contents, box);
1806 }
1807};
1808
1810public:
1811 void on_update(sys::state& state) noexcept override {
1812 const dcon::nation_id content = retrieve<dcon::nation_id>(state, parent);
1813 auto fat = dcon::fatten(state.world, content);
1814 progress = (fat.get_constructing_cb_progress() / 100.0f);
1815 }
1816
1819 }
1820
1821 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1822 auto fab_by = retrieve<dcon::nation_id>(state, parent);
1823 auto target = state.world.nation_get_constructing_cb_target(fab_by);
1825 text::add_line(state, contents, "fab_is_paused");
1826 } else {
1827 auto rem_progress = 100.0f - state.world.nation_get_constructing_cb_progress(fab_by);
1828 auto daily_progress = state.defines.cb_generation_base_speed * state.world.nation_get_constructing_cb_type(fab_by).get_construction_speed()* (state.world.nation_get_modifier_values(fab_by, sys::national_mod_offsets::cb_generation_speed_modifier) + 1.0f);
1829 auto days = int32_t(std::ceil(rem_progress / daily_progress));
1830 text::add_line(state, contents, "fab_finish_date", text::variable_type::date, state.current_date + days);
1831 }
1833 active_modifiers_description(state, contents, fab_by, 0, sys::national_mod_offsets::cb_generation_speed_modifier, true);
1834 }
1835};
1836
1838protected:
1839 void populate_flags(sys::state& state) noexcept override {
1840 const dcon::nation_id content = retrieve<dcon::nation_id>(state, parent);
1841 auto fat = dcon::fatten(state.world, content);
1842 row_contents.clear();
1843 row_contents.push_back(fat.get_identity_from_identity_holder().id);
1844 update(state);
1845 }
1846};
1847
1849protected:
1850 void populate_flags(sys::state& state) noexcept override {
1851 const dcon::nation_id content = retrieve<dcon::nation_id>(state, parent);
1852 auto fat = dcon::fatten(state.world, content);
1853 row_contents.clear();
1854 row_contents.push_back(fat.get_constructing_cb_target().get_identity_from_identity_holder().id);
1855 update(state);
1856 }
1857};
1858
1860public:
1861 void on_update(sys::state& state) noexcept override {
1862 const dcon::nation_id content = retrieve<dcon::nation_id>(state, parent);
1863 if(content != state.local_player_nation) {
1864 disabled = true;
1865 } else {
1867 }
1868 }
1869
1870 void button_action(sys::state& state) noexcept override {
1871 const dcon::nation_id content = retrieve<dcon::nation_id>(state, parent);
1873 }
1874
1875 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
1876 if(retrieve<dcon::nation_id>(state, parent) == state.local_player_nation)
1878 }
1879};
1880
1882public:
1883 void on_update(sys::state& state) noexcept override {
1884 auto just_progress = state.world.nation_get_constructing_cb_progress(retrieve<dcon::nation_id>(state, parent));
1885 set_text(state, text::format_percentage(just_progress / 100.0f, 0));
1886 }
1887};
1888
1890public:
1891 void on_create(sys::state& state) noexcept override {
1892 base_data.position.y -= int16_t(20); //nudge
1894 }
1895
1896 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1897 if(name == "diplo_cb_entrybg") {
1898 return make_element_by_type<image_element_base>(state, id);
1899 } else if(name == "cb_type_icon") {
1900 return make_element_by_type<justifying_cb_type_icon>(state, id);
1901 } else if(name == "cb_progress") {
1902 return make_element_by_type<justifying_cb_progress>(state, id);
1903 } else if(name == "cb_progress_text") {
1904 return make_element_by_type<cb_progress_text>(state, id);
1905 } else if(name == "attackers") {
1906 auto ptr = make_element_by_type<justifying_attacker_flag>(state, id);
1907 ptr->base_data.position.y -= 7; // Nudge
1908 return ptr;
1909 } else if(name == "defenders") {
1910 auto ptr = make_element_by_type<justifying_defender_flag>(state, id);
1911 ptr->base_data.position.y -= 7; // Nudge
1912 return ptr;
1913 } else if(name == "cancel") {
1914 return make_element_by_type<diplomacy_casus_belli_cancel_button>(state, id);
1915 } else {
1916 return nullptr;
1917 }
1918 }
1919};
1920
1921class diplomacy_casus_belli_listbox : public listbox_element_base<diplomacy_casus_belli_entry, dcon::nation_id> {
1922protected:
1923 std::string_view get_row_element_name() override {
1924 return "diplomacy_cb_info_player";
1925 }
1926
1927public:
1928 void on_create(sys::state& state) noexcept override {
1929 base_data.size.x += int16_t(400);
1931 }
1932 void on_update(sys::state& state) noexcept override {
1933 row_contents.clear();
1934 // Put player wargoals first
1935 for(const auto id : state.world.in_nation) {
1936 if(id == state.local_player_nation && dcon::fatten(state.world, state.local_player_nation).get_constructing_cb_type().is_valid()) {
1937 row_contents.push_back(id);
1938 }
1939 }
1940 // And after - everyone elses
1941 for(const auto id : state.world.in_nation) {
1942 if(id != state.local_player_nation && dcon::fatten(state.world, id).get_constructing_cb_is_discovered()) {
1943 row_contents.push_back(id);
1944 }
1945 }
1946 update(state);
1947 }
1948};
1949
1951public:
1952 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1953 if(name == "cb_listbox") {
1954 auto ptr = make_element_by_type<diplomacy_casus_belli_listbox>(state, id);
1955 ptr->base_data.position.x -= 400; // Nudge
1956 return ptr;
1957 } else {
1958 return nullptr;
1959 }
1960 }
1961};
1962
1963class diplomacy_war_listbox : public listbox_element_base<diplomacy_war_info, dcon::war_id> {
1964protected:
1965 std::string_view get_row_element_name() override {
1966 return "diplomacy_war_info";
1967 }
1968
1969public:
1970 void on_update(sys::state& state) noexcept override {
1971 row_contents.clear();
1972 state.world.for_each_war([&](dcon::war_id id) { row_contents.push_back(id); });
1973 std::sort(row_contents.begin(), row_contents.end(), [&](dcon::war_id a, dcon::war_id b) {
1974 auto in_a = military::get_role(state, a, state.local_player_nation) != military::war_role::none;
1975 auto in_b = military::get_role(state, b, state.local_player_nation) != military::war_role::none;
1976 if(in_a != in_b) {
1977 return in_a;
1978 } else {
1979 return state.world.war_get_start_date(a) < state.world.war_get_start_date(b);
1980 }
1981 });
1982 update(state);
1983 }
1984};
1985
1987public:
1988 uint8_t rank = 0;
1989
1990 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1991 if(name == "country_name") {
1992 return make_element_by_type<generic_name_text<dcon::nation_id>>(state, id);
1993 } else if(name == "country_flag") {
1994 return make_element_by_type<flag_button>(state, id);
1995 } else if(name == "country_puppets") {
1996 auto ptr = make_element_by_type<overlapping_sphere_flags>(state, id);
1997 ptr->base_data.position.y -= 8; // Nudge
1998 return ptr;
1999 } else if(name == "gp_prestige") {
2000 return make_element_by_type<nation_prestige_text>(state, id);
2001 } else if(name == "gp_economic") {
2002 return make_element_by_type<nation_industry_score_text>(state, id);
2003 } else if(name == "gp_military") {
2004 return make_element_by_type<nation_military_score_text>(state, id);
2005 } else if(name == "gp_total") {
2006 return make_element_by_type<nation_total_score_text>(state, id);
2007 } else {
2008 return nullptr;
2009 }
2010 }
2011
2012 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
2013 if(payload.holds_type<dcon::nation_id>()) {
2014 payload.emplace<dcon::nation_id>(nations::get_nth_great_power(state, rank));
2015 return message_result::consumed;
2016 }
2017 return window_element_base::get(state, payload);
2018 }
2019};
2020
2022public:
2023 void button_action(sys::state& state) noexcept override {
2024 send(state, parent, element_selection_wrapper<country_list_sort>{country_list_sort(uint8_t(country_list_sort::gp_influence) | rank)});
2025 }
2026};
2027
2029public:
2030 bool is_active(sys::state& state) noexcept final {
2031 return parent && static_cast<generic_tabbed_window<diplomacy_window_tab>*>(parent)->active_tab == diplomacy_window_tab::crisis;
2032 }
2033
2034 void button_action(sys::state& state) noexcept final {
2035 diplomacy_window_tab target = diplomacy_window_tab::crisis;
2036 send(state, parent, target);
2037 }
2038
2039 void on_update(sys::state& state) noexcept override {
2040 checkbox_button::on_update(state);
2041 disabled = state.current_crisis == sys::crisis_type::none;
2042 }
2043};
2044
2046public:
2047 void on_create(sys::state& state) noexcept override {
2048 simple_text_element_base::on_create(state);
2049 set_text(state, text::produce_simple_string(state, "tut_8c_3"));
2050 }
2051};
2052
2053class diplomacy_window : public generic_tabbed_window<diplomacy_window_tab> {
2054private:
2055 diplomacy_country_listbox* country_listbox = nullptr;
2056 diplomacy_war_listbox* war_listbox = nullptr;
2057 diplomacy_country_facts* country_facts = nullptr;
2058 diplomacy_action_dialog_window* action_dialog_win = nullptr;
2059 diplomacy_gp_action_dialog_window* gp_action_dialog_win = nullptr;
2060 diplomacy_declare_war_dialog* declare_war_win = nullptr;
2061 offer_war_goal_dialog* offer_goal_win = nullptr;
2062 diplomacy_setup_peace_dialog* setup_peace_win = nullptr;
2063 diplomacy_make_cb_window* make_cb_win = nullptr;
2064 crisis_resolution_dialog* crisis_backdown_win = nullptr;
2065 diplomacy_casus_belli_window* casus_belli_window = nullptr;
2066 // element_base* casus_belli_window = nullptr;
2067 diplomacy_crisis_info_window* crisis_window = nullptr;
2068
2069 std::vector<diplomacy_greatpower_info*> gp_infos{};
2070 std::vector<element_base*> action_buttons{};
2071
2072 dcon::nation_id facts_nation_id{};
2073
2076
2077 template<typename T>
2078 void add_action_button(sys::state& state, xy_pair offset) noexcept {
2079 auto ptr = make_element_by_type<T>(state, state.ui_state.defs_by_name.find(state.lookup_key("diplomacy_option"))->second.definition);
2080 ptr->base_data.position = offset;
2081 action_buttons.push_back(ptr.get());
2082 add_child_to_front(std::move(ptr));
2083 }
2084
2085public:
2086 void on_create(sys::state& state) noexcept override {
2087 generic_tabbed_window::on_create(state);
2088 state.ui_state.diplomacy_subwindow = this;
2089
2090 xy_pair base_gp_info_offset =
2091 state.ui_defs.gui[state.ui_state.defs_by_name.find(state.lookup_key("diplomacy_greatpower_pos"))->second.definition].position;
2092 xy_pair gp_info_offset = base_gp_info_offset;
2093 for(uint8_t i = 0; i < uint8_t(state.defines.great_nations_count); i++) {
2094 auto ptr = make_element_by_type<diplomacy_greatpower_info>(state,
2095 state.ui_state.defs_by_name.find(state.lookup_key("diplomacy_greatpower_info"))->second.definition);
2096 ptr->base_data.position = gp_info_offset;
2097 ptr->rank = i;
2098 // Increment gp offset
2099 gp_info_offset.y += ptr->base_data.size.y;
2100 if(i + 1 == uint8_t(state.defines.great_nations_count) / 2) {
2101 gp_info_offset.y = base_gp_info_offset.y;
2102 gp_info_offset.x += (ptr->base_data.size.x / 2) + 62; // Nudge
2103 }
2104 gp_infos.push_back(ptr.get());
2105 add_child_to_front(std::move(ptr));
2106 }
2107
2108 // Fill out all the options for the diplomacy window
2109 xy_pair options_base_offset =
2110 state.ui_defs.gui[state.ui_state.defs_by_name.find(state.lookup_key("diplomacy_actions_pos"))->second.definition].position;
2111 xy_pair options_size = state.ui_defs.gui[state.ui_state.defs_by_name.find(state.lookup_key("diplomacy_option"))->second.definition].size;
2112 xy_pair options_offset = options_base_offset;
2113 add_action_button<diplomacy_action_window<diplomacy_action_ally_button>>(state, options_offset);
2114 options_offset.y += options_size.y;
2115 add_action_button<diplomacy_action_window<diplomacy_action_call_ally_button>>(state, options_offset);
2116 options_offset.y += options_size.y;
2117 add_action_button<diplomacy_action_window<diplomacy_action_military_access_button>>(state, options_offset);
2118 options_offset.y += options_size.y;
2119 add_action_button<diplomacy_action_window<diplomacy_action_give_military_access_button>>(state, options_offset);
2120 options_offset.y += options_size.y;
2121 add_action_button<diplomacy_action_window<diplomacy_action_increase_relations_button>>(state, options_offset);
2122 options_offset.y += options_size.y;
2123 add_action_button<diplomacy_action_window<diplomacy_action_decrease_relations_button>>(state, options_offset);
2124 options_offset.y += options_size.y;
2125 add_action_button<diplomacy_action_window<diplomacy_action_war_subisides_button>>(state, options_offset);
2126 options_offset.y += options_size.y;
2127 add_action_button<diplomacy_action_window<diplomacy_action_declare_war_button>>(state, options_offset);
2128 options_offset.y += options_size.y;
2129 add_action_button<diplomacy_action_window<diplomacy_action_release_subject_button>>(state, options_offset);
2130 // Next row of actions...
2131 options_offset.x += options_size.x;
2132 options_offset.y = options_base_offset.y;
2133 add_action_button<diplomacy_action_window<diplomacy_action_discredit_button>>(state, options_offset);
2134 options_offset.y += options_size.y;
2135 add_action_button<diplomacy_action_window<diplomacy_action_expel_advisors_button>>(state, options_offset);
2136 options_offset.y += options_size.y;
2137 add_action_button<diplomacy_action_window<diplomacy_action_ban_embassy_button>>(state, options_offset);
2138 options_offset.y += options_size.y;
2139 add_action_button<diplomacy_action_window<diplomacy_action_increase_opinion_button>>(state, options_offset);
2140 options_offset.y += options_size.y;
2141 add_action_button<diplomacy_action_window<diplomacy_action_decrease_opinion_button>>(state, options_offset);
2142 options_offset.y += options_size.y;
2143 add_action_button<diplomacy_action_window<diplomacy_action_add_to_sphere_button>>(state, options_offset);
2144 options_offset.y += options_size.y;
2145 add_action_button<diplomacy_action_window<diplomacy_action_remove_from_sphere_button>>(state, options_offset);
2146 options_offset.y += options_size.y;
2147 add_action_button<diplomacy_action_window<diplomacy_action_justify_war_button>>(state, options_offset);
2148 options_offset.y += options_size.y;
2149 add_action_button<diplomacy_action_window<diplomacy_action_state_transfer_button>>(state, options_offset);
2150
2151 auto new_win1 = make_element_by_type<diplomacy_action_dialog_window>(state,
2152 state.ui_state.defs_by_name.find(state.lookup_key("defaultdiplomacydialog"))->second.definition);
2153 new_win1->set_visible(state, false);
2154 action_dialog_win = new_win1.get();
2155 add_child_to_front(std::move(new_win1));
2156
2157 auto new_win2 = make_element_by_type<diplomacy_gp_action_dialog_window>(state,
2158 state.ui_state.defs_by_name.find(state.lookup_key("gpselectdiplomacydialog"))->second.definition);
2159 new_win2->set_visible(state, false);
2160 gp_action_dialog_win = new_win2.get();
2161 add_child_to_front(std::move(new_win2));
2162
2163 auto new_win3 = make_element_by_type<diplomacy_declare_war_dialog>(state,
2164 state.ui_state.defs_by_name.find(state.lookup_key("declarewardialog"))->second.definition);
2165 new_win3->set_visible(state, false);
2166 declare_war_win = new_win3.get();
2167 add_child_to_front(std::move(new_win3));
2168
2169 {
2170 auto new_winc = make_element_by_type<offer_war_goal_dialog>(state,
2171 state.ui_state.defs_by_name.find(state.lookup_key("declarewardialog"))->second.definition);
2172 new_winc->set_visible(state, false);
2173 offer_goal_win = new_winc.get();
2174 add_child_to_front(std::move(new_winc));
2175 }
2176
2177 auto new_win4 = make_element_by_type<diplomacy_setup_peace_dialog>(state,
2178 state.ui_state.defs_by_name.find(state.lookup_key("setuppeacedialog"))->second.definition);
2179 new_win4->set_visible(state, false);
2180 setup_peace_win = new_win4.get();
2181 add_child_to_front(std::move(new_win4));
2182
2183 auto new_win5 = make_element_by_type<diplomacy_make_cb_window>(state,
2184 state.ui_state.defs_by_name.find(state.lookup_key("makecbdialog"))->second.definition);
2185 new_win5->set_visible(state, false);
2186 make_cb_win = new_win5.get();
2187 add_child_to_front(std::move(new_win5));
2188
2189 auto new_win6 = make_element_by_type<crisis_resolution_dialog>(state,
2190 state.ui_state.defs_by_name.find(state.lookup_key("setuppeacedialog"))->second.definition);
2191 new_win6->set_visible(state, false);
2192 crisis_backdown_win = new_win6.get();
2193 add_child_to_front(std::move(new_win6));
2194
2195 if(state.great_nations.size() > 1) {
2196 Cyto::Any payload = element_selection_wrapper<dcon::nation_id>{ state.great_nations[0].nation };
2197 impl_get(state, payload);
2198 }
2199
2200 set_visible(state, false);
2201 }
2202
2203 void on_update(sys::state& state) noexcept override {
2204 if(active_tab == diplomacy_window_tab::crisis && state.current_crisis == sys::crisis_type::none) {
2205 send<diplomacy_window_tab>(state, this, diplomacy_window_tab::great_powers);
2206 }
2207 }
2208
2209 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
2210 if(name == "main_bg") {
2211 return make_element_by_type<image_element_base>(state, id);
2212 } else if(name == "bg_diplomacy") {
2213 return make_element_by_type<opaque_element_base>(state, id);
2214 } else if(name == "close_button") {
2215 return make_element_by_type<generic_close_button>(state, id);
2216 } else if(name == "gp_info") {
2217 auto ptr = make_element_by_type<generic_tab_button<diplomacy_window_tab>>(state, id);
2218 ptr->target = diplomacy_window_tab::great_powers;
2219 return ptr;
2220 } else if(name == "gp_info_text") {
2221 return make_element_by_type<gp_tab_text>(state, id);
2222 } else if(name == "war_info") {
2223 auto ptr = make_element_by_type<generic_tab_button<diplomacy_window_tab>>(state, id);
2224 ptr->target = diplomacy_window_tab::wars;
2225 return ptr;
2226 } else if(name == "cb_info") {
2227 auto ptr = make_element_by_type<generic_tab_button<diplomacy_window_tab>>(state, id);
2228 ptr->target = diplomacy_window_tab::casus_belli;
2229 return ptr;
2230 } else if(name == "crisis_info") {
2231 return make_element_by_type<crisis_tab_button>(state, id);
2232 } else if(name == "filter_all") {
2233 return make_element_by_type<category_filter_button<country_list_filter::all>>(state, id);
2234 } else if(name == "filter_enemies") {
2235 return make_element_by_type<category_filter_button<country_list_filter::enemies>>(state, id);
2236 } else if(name == "filter_allies") {
2237 return make_element_by_type<category_filter_button<country_list_filter::allies>>(state, id);
2238 } else if(name == "filter_neighbours") {
2239 return make_element_by_type<category_filter_button<country_list_filter::neighbors>>(state, id);
2240 } else if(name == "filter_sphere") {
2241 return make_element_by_type<category_filter_button<country_list_filter::sphere>>(state, id);
2242 } else if(name == "cb_info_win") {
2243 auto ptr = make_element_by_type<diplomacy_casus_belli_window>(state, id);
2244 // auto ptr = make_element_immediate(state, id);
2245 casus_belli_window = ptr.get();
2246 ptr->set_visible(state, false);
2247 return ptr;
2248 } else if(name == "crisis_info_win") {
2249 auto ptr = make_element_by_type<diplomacy_crisis_info_window>(state, id);
2250 crisis_window = ptr.get();
2251 ptr->set_visible(state, false);
2252 return ptr;
2253 } else if(name == "country_listbox") {
2254 auto ptr = make_element_by_type<diplomacy_country_listbox>(state, id);
2255 country_listbox = ptr.get();
2256 return ptr;
2257 } else if(name == "war_listbox") {
2258 auto ptr = make_element_by_type<diplomacy_war_listbox>(state, id);
2259 war_listbox = ptr.get();
2260 war_listbox->set_visible(state, false);
2261 return ptr;
2262 } else if(name == "diplomacy_country_facts") {
2263 auto ptr = make_element_by_type<diplomacy_country_facts>(state, id);
2264 country_facts = ptr.get();
2265 return ptr;
2266 } else if(name == "sort_by_country") {
2267 auto ptr = make_element_by_type<country_sort_button<country_list_sort::country>>(state, id);
2268 return ptr;
2269 } else if(name == "sort_by_boss") {
2270 auto ptr = make_element_by_type<country_sort_button<country_list_sort::boss>>(state, id);
2271 ptr->base_data.position.y -= 1; // Nudge
2272 return ptr;
2273 } else if(name == "sort_by_prestige") {
2274 auto ptr = make_element_by_type<country_sort_button<country_list_sort::prestige_rank>>(state, id);
2275 ptr->base_data.position.y -= 1; // Nudge
2276 return ptr;
2277 } else if(name == "sort_by_economic") {
2278 auto ptr = make_element_by_type<country_sort_button<country_list_sort::economic_rank>>(state, id);
2279 ptr->base_data.position.y -= 1; // Nudge
2280 return ptr;
2281 } else if(name == "sort_by_military") {
2282 auto ptr = make_element_by_type<country_sort_button<country_list_sort::military_rank>>(state, id);
2283 ptr->base_data.position.y -= 1; // Nudge
2284 return ptr;
2285 } else if(name == "sort_by_total") {
2286 auto ptr = make_element_by_type<country_sort_button<country_list_sort::total_rank>>(state, id);
2287 ptr->base_data.position.y -= 1; // Nudge
2288 return ptr;
2289 } else if(name == "sort_by_relation") {
2290 auto ptr = make_element_by_type<country_sort_button<country_list_sort::relation>>(state, id);
2291 ptr->base_data.position.y -= 1; // Nudge
2292 return ptr;
2293 } else if(name == "sort_by_opinion") {
2294 return make_element_by_type<country_sort_button<country_list_sort::opinion>>(state, id);
2295 } else if(name == "sort_by_prio") {
2296 return make_element_by_type<country_sort_button<country_list_sort::priority>>(state, id);
2297 } else if(name.substr(0, 14) == "sort_by_gpflag") {
2298 auto ptr = make_element_by_type<diplomacy_sort_nation_gp_flag>(state, id);
2299 ptr->rank = uint16_t(std::stoi(std::string{name.substr(14)}));
2300 ptr->base_data.position.y -= 2; // Nudge
2301 return ptr;
2302 } else if(name.substr(0, 10) == "sort_by_gp") {
2303 auto ptr = make_element_by_type<country_sort_button<country_list_sort::gp_influence>>(state, id);
2304 ptr->offset = uint8_t(std::stoi(std::string{name.substr(10)}));
2305 ptr->base_data.position.y -= 2; // Nudge
2306 return ptr;
2307 } else if(name.length() >= 7 && name.substr(0, 7) == "filter_") {
2308 auto const filter_name = name.substr(7);
2309 auto ptr = make_element_by_type<continent_filter_button>(state, id);
2310 auto k = state.lookup_key(filter_name);
2311 if(k) {
2312 for(auto m : state.world.in_modifier) {
2313 if(m.get_name() == k) {
2314 ptr->continent = m;
2315 break;
2316 }
2317 }
2318 }
2319 return ptr;
2320 } else {
2321 return nullptr;
2322 }
2323 }
2324
2326 war_listbox->set_visible(state, false);
2327 casus_belli_window->set_visible(state, false);
2328 crisis_window->set_visible(state, false);
2329 for(auto e : gp_infos)
2330 e->set_visible(state, false);
2331 }
2332
2333 void on_hide(sys::state& state) noexcept override {
2334 offer_goal_win->set_visible(state, false);
2335 action_dialog_win->set_visible(state, false);
2336 declare_war_win->set_visible(state, false);
2337 setup_peace_win->set_visible(state, false);
2338 make_cb_win->set_visible(state, false);
2339 crisis_backdown_win->set_visible(state, false);
2340 gp_action_dialog_win->set_visible(state, false);
2341 }
2342
2343 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
2344 if(payload.holds_type<diplomacy_window_tab>()) {
2345 auto enum_val = any_cast<diplomacy_window_tab>(payload);
2346 hide_tabs(state);
2347 switch(enum_val) {
2348 case diplomacy_window_tab::great_powers:
2349 for(auto e : gp_infos)
2350 e->set_visible(state, true);
2351 break;
2352 case diplomacy_window_tab::wars:
2353 war_listbox->set_visible(state, true);
2354 break;
2355 case diplomacy_window_tab::casus_belli:
2356 casus_belli_window->set_visible(state, true);
2357 break;
2358 case diplomacy_window_tab::crisis:
2359 crisis_window->set_visible(state, true);
2360 break;
2361 default:
2362 break;
2363 }
2364 active_tab = enum_val;
2365 country_facts->impl_on_update(state);
2366 return message_result::consumed;
2367 } else if(payload.holds_type<dip_tab_request>()) {
2368 payload.emplace<dip_tab_request>(dip_tab_request{ active_tab });
2369 return message_result::consumed;
2370 } else if(payload.holds_type<country_sort_setting>()) {
2371 payload.emplace<country_sort_setting>(sort);
2372 return message_result::consumed;
2373 } else if(payload.holds_type< country_filter_setting>()) {
2374 payload.emplace<country_filter_setting>(filter);
2375 return message_result::consumed;
2376 } else if(payload.holds_type<element_selection_wrapper<country_list_sort>>()) {
2377 auto new_sort = any_cast<element_selection_wrapper<country_list_sort>>(payload).data;
2378 sort.sort_ascend = (new_sort == sort.sort) ? !sort.sort_ascend : true;
2379 sort.sort = new_sort;
2380 country_listbox->impl_on_update(state);
2381 return message_result::consumed;
2382 } else if(payload.holds_type<country_list_filter>()) {
2383 auto temp = any_cast<country_list_filter>(payload);
2384 filter.general_category = filter.general_category != temp ? temp : country_list_filter::all;
2385 country_listbox->impl_on_update(state);
2386 return message_result::consumed;
2387 } else if(payload.holds_type<dcon::modifier_id>()) {
2388 auto temp_c = any_cast<dcon::modifier_id>(payload);
2389 filter.continent = filter.continent == temp_c ? dcon::modifier_id{} : temp_c;
2390 country_listbox->impl_on_update(state);
2391 return message_result::consumed;
2392 } else if(payload.holds_type<dcon::nation_id>()) {
2393 payload.emplace<dcon::nation_id>(facts_nation_id);
2394 return message_result::consumed;
2395 } else if(payload.holds_type<element_selection_wrapper<dcon::nation_id>>()) {
2396 facts_nation_id = any_cast<element_selection_wrapper<dcon::nation_id>>(payload).data;
2397 send(state, country_listbox, dip_make_nation_visible{ facts_nation_id });
2398 impl_on_update(state);
2399 return message_result::consumed;
2400 } else if(payload.holds_type<open_offer_window>()) {
2401 auto offer_to = any_cast<open_offer_window>(payload).to;
2402
2403 offer_goal_win->set_visible(state, false);
2404 offer_goal_win->reset_window(state, offer_to);
2405 offer_goal_win->set_visible(state, true);
2406
2407 } else if(payload.holds_type<trigger_gp_choice>()) {
2408 auto action = any_cast<trigger_gp_choice>(payload).action;
2409
2410 action_dialog_win->set_visible(state, false);
2411 declare_war_win->set_visible(state, false);
2412 setup_peace_win->set_visible(state, false);
2413 make_cb_win->set_visible(state, false);
2414 crisis_backdown_win->set_visible(state, false);
2415
2416 gp_action_dialog_win->set_visible(state, false);
2417 gp_action_dialog_win->action_target = facts_nation_id;
2418 gp_action_dialog_win->current_action = action;
2419 gp_action_dialog_win->set_visible(state, true); // this will also force an update
2420
2421 } else if(payload.holds_type<diplomacy_action>()) {
2422 auto v = any_cast<diplomacy_action>(payload);
2423 gp_action_dialog_win->set_visible(state, false);
2424 action_dialog_win->set_visible(state, false);
2425 declare_war_win->set_visible(state, false);
2426 setup_peace_win->set_visible(state, false);
2427 make_cb_win->set_visible(state, false);
2428 crisis_backdown_win->set_visible(state, false);
2429 Cyto::Any new_payload = facts_nation_id;
2430 auto fat = dcon::fatten(state.world, facts_nation_id);
2431 switch(v) {
2432 case diplomacy_action::add_to_sphere:
2433 command::add_to_sphere(state, state.local_player_nation, facts_nation_id);
2434 break;
2435 case diplomacy_action::military_access:
2436 command::ask_for_military_access(state, state.local_player_nation, facts_nation_id);
2437 break;
2438 case diplomacy_action::cancel_military_access:
2439 command::cancel_military_access(state, state.local_player_nation, facts_nation_id);
2440 break;
2441 case diplomacy_action::give_military_access:
2442 // TODO: Give military access
2443 break;
2444 case diplomacy_action::cancel_give_military_access:
2445 command::cancel_given_military_access(state, state.local_player_nation, facts_nation_id);
2446 break;
2447 case diplomacy_action::increase_relations:
2448 command::increase_relations(state, state.local_player_nation, facts_nation_id);
2449 break;
2450 case diplomacy_action::decrease_relations:
2451 command::decrease_relations(state, state.local_player_nation, facts_nation_id);
2452 break;
2453 case diplomacy_action::war_subsidies:
2454 command::give_war_subsidies(state, state.local_player_nation, facts_nation_id);
2455 break;
2456 case diplomacy_action::cancel_war_subsidies:
2457 command::cancel_war_subsidies(state, state.local_player_nation, facts_nation_id);
2458 break;
2459 case diplomacy_action::ally:
2460 command::ask_for_alliance(state, state.local_player_nation, facts_nation_id);
2461 break;
2462 case diplomacy_action::cancel_ally:
2463 command::cancel_alliance(state, state.local_player_nation, facts_nation_id);
2464 break;
2465 case diplomacy_action::call_ally:
2466 for(auto war_par : fat.get_war_participant()) {
2467 command::call_to_arms(state, state.local_player_nation, facts_nation_id,
2468 dcon::fatten(state.world, war_par).get_war().id);
2469 }
2470 break;
2471 case diplomacy_action::remove_from_sphere:
2472 gp_action_dialog_win->set_visible(state, true);
2473 gp_action_dialog_win->impl_set(state, new_payload);
2474 gp_action_dialog_win->impl_set(state, payload);
2475 gp_action_dialog_win->impl_on_update(state);
2476 break;
2477 case diplomacy_action::declare_war:
2478 case diplomacy_action::add_wargoal:
2479 declare_war_win->set_visible(state, false);
2480 declare_war_win->reset_window(state);
2481 declare_war_win->set_visible(state, true);
2482
2483 break;
2484 case diplomacy_action::make_peace:
2485 setup_peace_win->open_window(state);
2486 setup_peace_win->set_visible(state, true);
2487 setup_peace_win->impl_set(state, new_payload);
2488 setup_peace_win->impl_set(state, payload);
2489 setup_peace_win->impl_on_update(state);
2490 break;
2491 case diplomacy_action::justify_war:
2492 make_cb_win->impl_set(state, new_payload);
2493 make_cb_win->impl_set(state, payload);
2494 make_cb_win->set_visible(state, true);
2495 break;
2496 case diplomacy_action::crisis_backdown:
2497 crisis_backdown_win->open_window(state);
2498 crisis_backdown_win->set_visible(state, true);
2499 crisis_backdown_win->impl_on_update(state);
2500 break;
2501 case diplomacy_action::crisis_support:
2502 break;
2503 default:
2504 action_dialog_win->set_visible(state, true);
2505 action_dialog_win->impl_set(state, new_payload);
2506 action_dialog_win->impl_set(state, payload);
2507 action_dialog_win->impl_on_update(state);
2508 break;
2509 }
2510 return message_result::consumed;
2511 }
2513 }
2514};
2515
2516} // namespace ui
dcon::text_key get_name() noexcept
void on_update(sys::state &state) noexcept override
void set_button_text(sys::state &state, std::string const &new_text)
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void button_action(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
message_result impl_set(sys::state &state, Cyto::Any &payload) noexcept final
void add_child_to_front(std::unique_ptr< element_base > child) noexcept final
void impl_on_update(sys::state &state) noexcept override
void open_window(sys::state &state)
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
void on_update(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept final
bool is_active(sys::state &state) noexcept final
void on_update(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void on_update(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void button_action(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_create(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
std::string_view get_row_element_name() override
void on_update(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_update(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_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
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
bool is_active(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
std::string_view get_row_element_name() override
void on_update(sys::state &state) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
void button_action(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
void button_action(sys::state &state) noexcept override
void on_create(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 button_action(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void populate_layout(sys::state &state, text::endless_layout &contents) noexcept override
std::string_view get_row_element_name() override
void on_update(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id 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
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void button_right_action(sys::state &state) noexcept override
void open_window(sys::state &state)
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
void button_action(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
std::string get_text(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
void on_create(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
std::string_view get_row_element_name() override
void on_update(sys::state &state) noexcept override
std::string_view get_row_element_name() override
void on_update(sys::state &state) 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
void on_hide(sys::state &state) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
void on_update(sys::state &state) noexcept override
void hide_tabs(sys::state &state)
element_base * parent
virtual message_result get(sys::state &state, Cyto::Any &payload) noexcept
virtual void on_create(sys::state &state) noexcept
element_data base_data
void set_visible(sys::state &state, bool vis)
void 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_update(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
virtual dcon::national_identity_id get_current_nation(sys::state &state) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_update(sys::state &state) noexcept override
void on_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 populate_flags(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void on_update(sys::state &state) noexcept override
void 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 populate_flags(sys::state &state) noexcept override
standard_listbox_scrollbar< diplomacy_country_info, dcon::nation_id > * list_scrollbar
void on_create(sys::state &state) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
void on_update(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void on_update(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void reset_window(sys::state &state, dcon::nation_id offer_to)
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
void on_update(sys::state &state) noexcept override
std::string_view get_row_element_name() override
void populate_flags(sys::state &state) override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void populate_flags(sys::state &state) override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
std::string_view get_row_element_name() override
void on_update(sys::state &state) noexcept override
int32_t raw_value() const
void update_raw_value(sys::state &state, int32_t v)
void set_text(sys::state &state, std::string const &new_text)
void on_update(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void on_update(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void on_create(sys::state &state) noexcept override
#define B(name, bit)
Definition: cpu.h:216
bool can_intervene_in_war(sys::state &state, dcon::nation_id source, dcon::war_id w, bool for_attacker)
Definition: commands.cpp:1668
void give_war_subsidies(sys::state &state, dcon::nation_id source, dcon::nation_id target)
Definition: commands.cpp:230
bool can_cancel_cb_fabrication(sys::state &state, dcon::nation_id source)
Definition: commands.cpp:2196
bool can_fabricate_cb(sys::state &state, dcon::nation_id source, dcon::nation_id target, dcon::cb_type_id type)
Definition: commands.cpp:2147
bool can_toggle_interested_in_alliance(sys::state &state, dcon::nation_id asker, dcon::nation_id target)
Definition: commands.cpp:2352
bool can_change_influence_priority(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target, uint8_t priority)
Definition: commands.cpp:1020
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
constexpr dcon::demographics_key total(0)
dcon::demographics_key to_key(sys::state const &state, dcon::pop_type_id v)
constexpr uint32_t is_not_constructing_cb
Definition: military.hpp:12
constexpr uint32_t always
Definition: military.hpp:10
bool cb_conditions_satisfied(sys::state &state, dcon::nation_id actor, dcon::nation_id target, dcon::cb_type_id cb)
Definition: military.cpp:254
float primary_warscore(sys::state &state, dcon::war_id w)
Definition: military.cpp:3629
float truce_break_cb_infamy(sys::state &state, dcon::cb_type_id t)
Definition: military.cpp:1450
int32_t total_regiments(sys::state &state, dcon::nation_id n)
Definition: military.cpp:24
int32_t defender_peace_cost(sys::state &state, dcon::war_id war)
Definition: military.cpp:1693
bool has_truce_with(sys::state &state, dcon::nation_id attacker, dcon::nation_id target)
Definition: military.cpp:2037
int32_t attacker_peace_cost(sys::state &state, dcon::war_id war)
Definition: military.cpp:1682
bool is_attacker(sys::state &state, dcon::war_id w, dcon::nation_id n)
Definition: military.cpp:2234
bool joining_as_attacker_would_break_truce(sys::state &state, dcon::nation_id a, dcon::war_id w)
Definition: military.cpp:607
float primary_warscore_from_blockades(sys::state &state, dcon::war_id w)
Definition: military.cpp:3590
float cb_infamy(sys::state const &state, dcon::cb_type_id t)
Definition: military.cpp:1266
dcon::war_id find_war_between(sys::state const &state, dcon::nation_id a, dcon::nation_id b)
Definition: military.cpp:542
float primary_warscore_from_battles(sys::state &state, dcon::war_id w)
Definition: military.cpp:3668
float primary_warscore_from_occupation(sys::state &state, dcon::war_id w)
Definition: military.cpp:3637
bool are_at_war(sys::state const &state, dcon::nation_id a, dcon::nation_id b)
Definition: military.cpp:475
bool defenders_have_non_status_quo_wargoal(sys::state const &state, dcon::war_id w)
Definition: military.cpp:584
float primary_warscore_from_war_goals(sys::state &state, dcon::war_id w)
Definition: military.cpp:3672
int32_t total_ships(sys::state &state, dcon::nation_id n)
Definition: military.cpp:27
bool joining_war_does_not_violate_constraints(sys::state const &state, dcon::nation_id a, dcon::war_id w, bool as_attacker)
Definition: military.cpp:546
std::string get_war_name(sys::state &, dcon::war_id)
Definition: military.cpp:2316
bool can_add_always_cb_to_war(sys::state &state, dcon::nation_id actor, dcon::nation_id target, dcon::cb_type_id cb, dcon::war_id w)
Definition: military.cpp:110
bool defenders_have_status_quo_wargoal(sys::state const &state, dcon::war_id w)
Definition: military.cpp:592
constexpr uint8_t is_banned
Definition: nations.hpp:179
constexpr uint8_t level_friendly
Definition: nations.hpp:168
constexpr uint8_t is_discredited
Definition: nations.hpp:178
constexpr uint8_t priority_zero
Definition: nations.hpp:172
constexpr uint8_t priority_three
Definition: nations.hpp:175
constexpr uint8_t priority_mask
Definition: nations.hpp:171
constexpr uint8_t priority_one
Definition: nations.hpp:173
constexpr uint8_t level_mask
Definition: nations.hpp:163
constexpr uint8_t priority_two
Definition: nations.hpp:174
bool is_great_power(sys::state const &state, dcon::nation_id id)
Definition: nations.cpp:503
bool is_involved_in_crisis(sys::state const &state, dcon::nation_id n)
Definition: nations.cpp:1066
float get_foreign_investment(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:314
float get_base_shares(sys::state &state, dcon::gp_relationship_id gp, float total_gain, int32_t total_influence_shares)
Definition: nations.cpp:1513
bool has_sphere_neighbour(sys::state &state, dcon::nation_id n, dcon::nation_id target)
Definition: nations.cpp:1529
dcon::nation_id get_nth_great_power(sys::state const &state, uint16_t n)
Definition: nations.cpp:57
float prestige_score(sys::state const &state, dcon::nation_id n)
Definition: nations.cpp:396
bool can_accumulate_influence_with(sys::state &state, dcon::nation_id gp, dcon::nation_id target, dcon::gp_relationship_id rel)
Definition: nations.cpp:1500
uint32_t pack_color(float r, float g, float b)
void add_to_layout_box(sys::state &state, layout_base &dest, layout_box &box, embedded_flag ico)
Definition: text.cpp:1165
std::string format_money(float num)
Definition: text.cpp:1029
std::string get_name_as_string(sys::state &state, T t)
Definition: text.hpp:954
layout_box open_layout_box(layout_base &dest, int32_t indent)
Definition: text.cpp:1799
void localised_format_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view key, text::substitution_map const &sub)
Definition: text.cpp:1880
std::string format_float(float num, size_t digits)
Definition: text.cpp:981
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
Definition: text.cpp:1899
void add_line_with_condition(sys::state &state, layout_base &dest, std::string_view key, bool condition_met, int32_t indent)
Definition: text.cpp:1955
void add_line_break_to_layout(sys::state &state, columnar_layout &dest)
Definition: text.cpp:1152
void add_to_substitution_map(substitution_map &mp, variable_type key, substitution value)
Definition: text.cpp:1068
void add_divider_to_layout_box(sys::state &state, layout_base &dest, layout_box &box)
Definition: text.cpp:2098
ankerl::unordered_dense::map< uint32_t, substitution > substitution_map
Definition: text.hpp:794
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
Definition: text.cpp:617
dcon::text_key get_name(sys::state &state, dcon::nation_id id)
Definition: text.cpp:880
std::string format_percentage(float num, size_t digits)
Definition: text.cpp:977
std::string get_influence_level_name(sys::state const &state, uint8_t v)
Definition: text.cpp:958
void add_space_to_layout_box(sys::state &state, layout_base &dest, layout_box &box)
Definition: text.cpp:1788
void close_layout_box(columnar_layout &dest, layout_box &box)
Definition: text.cpp:1807
int32_t to_generic(dcon::province_id v)
Definition: triggers.hpp:12
bool evaluate(sys::state &state, dcon::trigger_key key, int32_t primary, int32_t this_slot, int32_t from_slot)
Definition: triggers.cpp:5810
void sort_countries(sys::state &state, std::vector< dcon::nation_id > &list, country_list_sort sort, bool sort_ascend)
tooltip_behavior
void send(sys::state &state, element_base *parent, T value)
void trigger_description(sys::state &state, text::layout_base &layout, dcon::trigger_key k, int32_t primary_slot=-1, int32_t this_slot=-1, int32_t from_slot=-1)
message_result
std::string get_status_text(sys::state &state, dcon::nation_id nation_id)
void explain_influence(sys::state &state, dcon::nation_id target, text::columnar_layout &contents)
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
ui::diplomacy_window_tab tab
ankerl::unordered_dense::map< dcon::text_key, element_target, hash_text_key > defs_by_name
element_base * diplomacy_subwindow