Project Alice
Loading...
Searching...
No Matches
gui_diplomacy_actions_window.hpp
Go to the documentation of this file.
1#pragma once
2
4#include "military.hpp"
5#include "ai.hpp"
6
7namespace ui {
8
10 ally,
33};
34
40};
41
44};
45
46
48public:
49 void on_create(sys::state& state) noexcept override {
50 base_data.data.button.txt = state.lookup_key("discredit_button");
52 }
53
54 void on_update(sys::state& state) noexcept override {
55 auto target = retrieve<dcon::nation_id>(state, parent);
56
57 disabled = false;
58
59 if(!state.world.nation_get_is_great_power(state.local_player_nation) || state.world.nation_get_is_great_power(target))
60 disabled = true;
61
62 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
63 if(state.world.gp_relationship_get_influence(rel) < state.defines.discredit_influence_cost)
64 disabled = true;
65
66 if((state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) != 0)
67 disabled = true;
68
69 if(military::are_at_war(state, state.local_player_nation, target))
70 disabled = true;
71
72 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
74 disabled = true;
75 }
76
77 void button_action(sys::state& state) noexcept override {
79 }
80
83 }
84
85 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
86
87 auto target = retrieve<dcon::nation_id>(state, parent);
88
89 text::add_line(state, contents, "discredit_desc", text::variable_type::days, int64_t(state.defines.discredit_days));
91
92 text::add_line_with_condition(state, contents, "iaction_explain_5", state.world.nation_get_is_great_power(state.local_player_nation));
93
94 text::add_line_with_condition(state, contents, "iaction_explain_6", !state.world.nation_get_is_great_power(target));
95
96 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
97 text::add_line_with_condition(state, contents, "iaction_explain_1", state.world.gp_relationship_get_influence(rel) >= state.defines.discredit_influence_cost, text::variable_type::x, int64_t(state.defines.discredit_influence_cost));
98
99 text::add_line_with_condition(state, contents, "iaction_explain_2", (state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) == 0);
100 text::add_line_with_condition(state, contents, "iaction_explain_3", !military::are_at_war(state, state.local_player_nation, target));
101
102 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
103 text::add_line_with_condition(state, contents, "discredit_explain_2", clevel != nations::influence::level_hostile);
104
105
106
107 }
108};
109
111public:
112 void on_create(sys::state& state) noexcept override {
113 base_data.data.button.txt = state.lookup_key("expeladvisors_button");
115 }
116
117 void on_update(sys::state& state) noexcept override {
118 auto target = retrieve<dcon::nation_id>(state, parent);
119
120 disabled = false;
121
122 if(!state.world.nation_get_is_great_power(state.local_player_nation) || state.world.nation_get_is_great_power(target))
123 disabled = true;
124
125 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
126 if(state.world.gp_relationship_get_influence(rel) < state.defines.expeladvisors_influence_cost)
127 disabled = true;
128
129 if((state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) != 0)
130 disabled = true;
131
132 if(military::are_at_war(state, state.local_player_nation, target))
133 disabled = true;
134
135 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
137 disabled = true;
138 }
139
140 void button_action(sys::state& state) noexcept override {
142 }
143
146 }
147
148 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
149
150 auto target = retrieve<dcon::nation_id>(state, parent);
151
152 text::add_line(state, contents, "expeladvisors_desc");
154
155 text::add_line_with_condition(state, contents, "iaction_explain_5", state.world.nation_get_is_great_power(state.local_player_nation));
156
157 text::add_line_with_condition(state, contents, "iaction_explain_6", !state.world.nation_get_is_great_power(target));
158
159 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
160 text::add_line_with_condition(state, contents, "iaction_explain_1", state.world.gp_relationship_get_influence(rel) >= state.defines.expeladvisors_influence_cost, text::variable_type::x, int64_t(state.defines.expeladvisors_influence_cost));
161
162 text::add_line_with_condition(state, contents, "iaction_explain_2", (state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) == 0);
163 text::add_line_with_condition(state, contents, "iaction_explain_3", !military::are_at_war(state, state.local_player_nation, target));
164
165 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
167
168
169 }
170};
171
173public:
174 void on_create(sys::state& state) noexcept override {
175 base_data.data.button.txt = state.lookup_key("banembassy_button");
177 }
178
179 void on_update(sys::state& state) noexcept override {
180 auto target = retrieve<dcon::nation_id>(state, parent);
181
182 disabled = false;
183
184 if(!state.world.nation_get_is_great_power(state.local_player_nation) || state.world.nation_get_is_great_power(target))
185 disabled = true;
186
187 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
188 if(state.world.gp_relationship_get_influence(rel) < state.defines.banembassy_influence_cost)
189 disabled = true;
190
191 if((state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) != 0)
192 disabled = true;
193
194 if(military::are_at_war(state, state.local_player_nation, target))
195 disabled = true;
196
197 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
199 disabled = true;
200 }
201
202 void button_action(sys::state& state) noexcept override {
204 }
205
208 }
209
210 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
211
212 auto target = retrieve<dcon::nation_id>(state, parent);
213
214 text::add_line(state, contents, "banembassy_desc", text::variable_type::days, int64_t(state.defines.banembassy_days));
216
217 text::add_line_with_condition(state, contents, "iaction_explain_5", state.world.nation_get_is_great_power(state.local_player_nation));
218
219 text::add_line_with_condition(state, contents, "iaction_explain_6", !state.world.nation_get_is_great_power(target));
220
221 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
222 text::add_line_with_condition(state, contents, "iaction_explain_1", state.world.gp_relationship_get_influence(rel) >= state.defines.banembassy_influence_cost, text::variable_type::x, int64_t(state.defines.banembassy_influence_cost));
223
224 text::add_line_with_condition(state, contents, "iaction_explain_2", (state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) == 0);
225 text::add_line_with_condition(state, contents, "iaction_explain_3", !military::are_at_war(state, state.local_player_nation, target));
226
227 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
229
230
231 }
232};
233
234
236public:
237 void on_create(sys::state& state) noexcept override {
238 base_data.data.button.txt = state.lookup_key("decreaseopinion_button");
240 }
241
242 void on_update(sys::state& state) noexcept override {
243 auto target = retrieve<dcon::nation_id>(state, parent);
244
245 disabled = false;
246
247 if(!state.world.nation_get_is_great_power(state.local_player_nation) || state.world.nation_get_is_great_power(target))
248 disabled = true;
249
250 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
251 if(state.world.gp_relationship_get_influence(rel) < state.defines.decreaseopinion_influence_cost)
252 disabled = true;
253
254 if((state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) != 0)
255 disabled = true;
256
257 if(military::are_at_war(state, state.local_player_nation, target))
258 disabled = true;
259
260 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
262 disabled = true;
263 }
264
265 void button_action(sys::state& state) noexcept override {
267 }
268
271 }
272
273 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
274
275 auto target = retrieve<dcon::nation_id>(state, parent);
276
277 text::add_line(state, contents, "decreaseopinion_desc");
279
280 text::add_line_with_condition(state, contents, "iaction_explain_5", state.world.nation_get_is_great_power(state.local_player_nation));
281
282 text::add_line_with_condition(state, contents, "iaction_explain_6", !state.world.nation_get_is_great_power(target));
283
284 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
285 text::add_line_with_condition(state, contents, "iaction_explain_1", state.world.gp_relationship_get_influence(rel) >= state.defines.decreaseopinion_influence_cost, text::variable_type::x, int64_t(state.defines.decreaseopinion_influence_cost));
286
287 text::add_line_with_condition(state, contents, "iaction_explain_2", (state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) == 0);
288 text::add_line_with_condition(state, contents, "iaction_explain_3", !military::are_at_war(state, state.local_player_nation, target));
289
290 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
291 text::add_line_with_condition(state, contents, "dec_op_explain_3", clevel != nations::influence::level_hostile);
292
293
294 }
295};
296
297
299public:
300 void on_update(sys::state& state) noexcept override {
301 auto content = retrieve<dcon::nation_id>(state, parent);
302
303 if(nations::are_allied(state, content, state.local_player_nation)) {
304 set_button_text(state, text::produce_simple_string(state, "cancelalliance_button"));
305 disabled = !command::can_cancel_alliance(state, state.local_player_nation, content);
306 } else {
308
311 m.from = state.local_player_nation;
312 m.to = content;
313 disabled = !command::can_ask_for_alliance(state, state.local_player_nation, content) || (!state.world.nation_get_is_player_controlled(content) && !diplomatic_message::ai_will_accept(state, m));
314 }
315 }
316
317 void button_action(sys::state& state) noexcept override {
318 auto content = retrieve<dcon::nation_id>(state, parent);
319 if(nations::are_allied(state, content, state.local_player_nation)) {
320 command::cancel_alliance(state, state.local_player_nation, content);
321 } else {
322 command::ask_for_alliance(state, state.local_player_nation, content);
323 }
324 }
325
328 }
329
330 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
331
332 auto content = retrieve<dcon::nation_id>(state, parent);
333 if(nations::are_allied(state, content, state.local_player_nation)) {
334 text::add_line(state, contents, "cancelalliance_desc");
336
337 if(state.local_player_nation == content) {
338 text::add_line_with_condition(state, contents, "cancel_ally_explain_1", false);
339 }
340 if(state.defines.cancelalliance_diplomatic_cost > 0) {
341 text::add_line_with_condition(state, contents, "cancel_ally_explain_2", state.world.nation_get_diplomatic_points(state.local_player_nation) >= state.defines.cancelalliance_diplomatic_cost, text::variable_type::x, int64_t(state.defines.cancelalliance_diplomatic_cost));
342 }
343
344 auto rel = state.world.get_diplomatic_relation_by_diplomatic_pair(content, state.local_player_nation);
345 text::add_line_with_condition(state, contents, "cancel_ally_explain_3", state.world.diplomatic_relation_get_are_allied(rel));
346 //text::add_line_with_condition(state, contents, "cancel_ally_explain_4", !military::are_allied_in_war(state, state.local_player_nation, content));
347
348 auto ol = state.world.nation_get_overlord_as_subject(state.local_player_nation);
349 text::add_line_with_condition(state, contents, "cancel_ally_explain_5", state.world.overlord_get_ruler(ol) != content);
350 } else {
351 auto asker = state.local_player_nation;
352 auto target = content;
353
354 text::add_line(state, contents, "alliance_desc");
356
357 if(asker == target)
358 text::add_line_with_condition(state, contents, "ally_explain_1", false);
359
360 if(state.defines.alliance_diplomatic_cost > 0) {
361 text::add_line_with_condition(state, contents, "ally_explain_2", state.world.nation_get_diplomatic_points(state.local_player_nation) >= state.defines.alliance_diplomatic_cost, text::variable_type::x, int64_t(state.defines.alliance_diplomatic_cost));
362 }
363 auto rel = state.world.get_diplomatic_relation_by_diplomatic_pair(content, state.local_player_nation);
364 text::add_line_with_condition(state, contents, "ally_explain_3", state.world.diplomatic_relation_get_are_allied(rel) == false);
365 text::add_line_with_condition(state, contents, "ally_explain_4", !state.world.nation_get_is_great_power(asker) || !state.world.nation_get_is_great_power(target) || state.current_crisis == sys::crisis_type::none);
366
367 auto ol = state.world.nation_get_overlord_as_subject(asker);
368 text::add_line_with_condition(state, contents, "ally_explain_5", !state.world.overlord_get_ruler(ol));
369 auto ol2 = state.world.nation_get_overlord_as_subject(target);
370 text::add_line_with_condition(state, contents, "ally_explain_8", !state.world.overlord_get_ruler(ol2));
371
372 text::add_line_with_condition(state, contents, "ally_explain_6", !military::are_at_war(state, asker, target));
373
374 if(!state.world.nation_get_is_player_controlled(content)) {
377 m.from = state.local_player_nation;
378 m.to = content;
379
381 ai::explain_ai_alliance_reasons(state, content, contents, 15);
382 }
383 }
384
385 }
386};
387
389public:
390 void on_create(sys::state& state) noexcept override {
391 base_data.data.button.txt = state.lookup_key("callally_button");
393 }
394
395 void on_update(sys::state& state) noexcept override {
396 auto content = retrieve<dcon::nation_id>(state, parent);
397
398 disabled = true;
399 for(auto war_par : state.world.nation_get_war_participant(state.local_player_nation)) {
400 if(command::can_call_to_arms(state, state.local_player_nation, content, war_par.get_war())) {
401
402 if(!state.world.nation_get_is_player_controlled(content)) {
405 m.from = state.local_player_nation;
406 m.to = content;
407 m.data.war = war_par.get_war();
409 disabled = false;
410 break;
411 }
412 } else {
413 disabled = false;
414 break;
415 }
416 }
417 }
418 }
419
420 void button_action(sys::state& state) noexcept override {
421
422 auto asker = state.local_player_nation;
423 auto target = retrieve<dcon::nation_id>(state, parent);
424
425 for(auto war_par : state.world.nation_get_war_participant(asker)) {
426 if(command::can_call_to_arms(state, state.local_player_nation, target, war_par.get_war())) {
427
428 if(!state.world.nation_get_is_player_controlled(target)) {
431 m.from = state.local_player_nation;
432 m.to = target;
433 m.data.war = war_par.get_war();
435 command::call_to_arms(state, asker, target, war_par.get_war());
436 }
437 } else {
438 command::call_to_arms(state, asker, target, war_par.get_war());
439 }
440 }
441 }
442
443 }
444
447 }
448
449 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
450
451 auto asker = state.local_player_nation;
452 auto target = retrieve<dcon::nation_id>(state, parent);
453
454 text::add_line(state, contents, "remove_callally_desc");
456
457 if(state.defines.callally_diplomatic_cost > 0) {
458 text::add_line_with_condition(state, contents, "call_ally_explain_2", state.world.nation_get_diplomatic_points(asker) >= state.defines.callally_diplomatic_cost, text::variable_type::x, int64_t(state.defines.callally_diplomatic_cost));
459 }
460 text::add_line_with_condition(state, contents, "call_ally_explain_1", nations::are_allied(state, asker, target));
461 text::add_line_with_condition(state, contents, "call_ally_explain_3", state.world.nation_get_is_at_war(asker));
462
463 bool possible_war = false;
464 bool that_ai_will_accept = false;
465
466 for(auto war_par : state.world.nation_get_war_participant(asker)) {
467 if(!military::is_civil_war(state, war_par.get_war())
468 && military::standard_war_joining_is_possible(state, war_par.get_war(), target, military::is_attacker(state, war_par.get_war(), asker))
469 && (!war_par.get_war().get_is_crisis_war() || state.military_definitions.great_wars_enabled)) {
470
471 possible_war = true;
472 if(!state.world.nation_get_is_player_controlled(target)) {
475 m.from = state.local_player_nation;
476 m.to = target;
477 m.data.war = war_par.get_war();
479 that_ai_will_accept = true;
480 }
481 }
482 }
483 }
484 text::add_line_with_condition(state, contents, "call_ally_explain_4", possible_war);
485 if(!state.world.nation_get_is_player_controlled(target)) {
486 text::add_line_with_condition(state, contents, "call_ally_explain_5", that_ai_will_accept);
487 }
488
489 }
490};
491
493public:
494 void on_update(sys::state& state) noexcept override {
495 auto target = retrieve<dcon::nation_id>(state, parent);
496 auto urid = state.world.get_unilateral_relationship_by_unilateral_pair(target, state.local_player_nation);
497
498 if(state.world.unilateral_relationship_get_military_access(urid)) {
499 disabled = !command::can_cancel_military_access(state, state.local_player_nation, target);
500 set_button_text(state, text::produce_simple_string(state, "cancelaskmilitaryaccess_button"));
501 } else {
502 if(command::can_ask_for_access(state, state.local_player_nation, target)) {
503 if(!state.world.nation_get_is_player_controlled(target)) {
506 m.from = state.local_player_nation;
507 m.to = target;
509 disabled = false;
510 } else {
511 disabled = true;
512 }
513 } else {
514 disabled = false;
515 }
516 } else {
517 disabled = true;
518 }
519 set_button_text(state, text::produce_simple_string(state, "askmilitaryaccess_button"));
520 }
521 }
522
523 void button_action(sys::state& state) noexcept override {
524 auto target = retrieve<dcon::nation_id>(state, parent);
525 auto urid = state.world.get_unilateral_relationship_by_unilateral_pair(target, state.local_player_nation);
526
527 if(state.world.unilateral_relationship_get_military_access(urid)) {
528 command::cancel_military_access(state, state.local_player_nation, target);
529 } else {
530 command::ask_for_military_access(state, state.local_player_nation, target);
531 }
532
533 }
534
537 }
538
539 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
540 auto target = retrieve<dcon::nation_id>(state, parent);
541 auto urid = state.world.get_unilateral_relationship_by_unilateral_pair(target, state.local_player_nation);
542
543
544 if(state.world.unilateral_relationship_get_military_access(urid)) {
545 text::add_line(state, contents, "cancelaskmilitaryaccess_desc");
547
548 if(state.defines.cancelaskmilaccess_diplomatic_cost > 0) {
549 text::add_line_with_condition(state, contents, "cancel_access_explain_1", state.world.nation_get_diplomatic_points(state.local_player_nation) >= state.defines.cancelaskmilaccess_diplomatic_cost, text::variable_type::x, int64_t(state.defines.cancelaskmilaccess_diplomatic_cost));
550 }
551 } else {
552 text::add_line(state, contents, "askmilitaryaccess_desc");
554
555 if(target == state.local_player_nation) {
556 text::add_line_with_condition(state, contents, "ask_access_explain_1", false);
557 }
558 if(state.defines.askmilaccess_diplomatic_cost > 0) {
559 text::add_line_with_condition(state, contents, "ask_access_explain_2", state.world.nation_get_diplomatic_points(state.local_player_nation) >= state.defines.askmilaccess_diplomatic_cost, text::variable_type::x, int64_t(state.defines.askmilaccess_diplomatic_cost));
560 }
561 if(!state.world.nation_get_is_player_controlled(target)) {
564 m.from = state.local_player_nation;
565 m.to = target;
566 text::add_line_with_condition(state, contents, "ask_access_explain_3", diplomatic_message::ai_will_accept(state, m));
567
568 ai::explain_ai_access_reasons(state, target, contents, 15);
569 }
570 text::add_line_with_condition(state, contents, "ask_access_explain_4", !military::are_at_war(state, state.local_player_nation, target));
571 }
572
573 }
574};
575
577public:
578 void on_update(sys::state& state) noexcept override {
579 auto target = retrieve<dcon::nation_id>(state, parent);
580 auto urid = state.world.get_unilateral_relationship_by_unilateral_pair(state.local_player_nation, target);
581
582 if(state.world.unilateral_relationship_get_military_access(urid)) {
583 set_button_text(state, text::produce_simple_string(state, "cancelgivemilitaryaccess_button"));
584 disabled = !command::can_cancel_given_military_access(state, state.local_player_nation, target);
585 } else {
586 set_button_text(state, text::produce_simple_string(state, "givemilitaryaccess_button"));
587 disabled = !command::can_give_military_access(state, state.local_player_nation, target);
588 }
589 }
590
591 void button_action(sys::state& state) noexcept override {
592 auto target = retrieve<dcon::nation_id>(state, parent);
593 auto urid = state.world.get_unilateral_relationship_by_unilateral_pair(state.local_player_nation, target);
594
595 if(state.world.unilateral_relationship_get_military_access(urid)) {
596 command::cancel_given_military_access(state, state.local_player_nation, target);
597 } else {
598 command::give_military_access(state, state.local_player_nation, target);
599 }
600
601 }
602
605 }
606
607 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
608 auto target = retrieve<dcon::nation_id>(state, parent);
609 auto urid = state.world.get_unilateral_relationship_by_unilateral_pair(state.local_player_nation, target);
610
611 if(state.world.unilateral_relationship_get_military_access(urid)) {
612 text::add_line(state, contents, "cancelgivemilitaryaccess_desc");
614
615 if(state.defines.cancelgivemilaccess_diplomatic_cost > 0) {
616 text::add_line_with_condition(state, contents, "cancel_given_access_explain_1", state.world.nation_get_diplomatic_points(state.local_player_nation) >= state.defines.cancelgivemilaccess_diplomatic_cost, text::variable_type::x, int64_t(state.defines.cancelgivemilaccess_diplomatic_cost));
617 }
618 } else {
619 text::add_line(state, contents, "givemilitaryaccess_desc");
621
622 if(target == state.local_player_nation) {
623 text::add_line_with_condition(state, contents, "give_access_explain_1", false);
624 }
625 if(state.defines.givemilaccess_diplomatic_cost > 0) {
626 text::add_line_with_condition(state, contents, "give_access_explain_2", state.world.nation_get_diplomatic_points(state.local_player_nation) >= state.defines.givemilaccess_diplomatic_cost, text::variable_type::x, int64_t(state.defines.givemilaccess_diplomatic_cost));
627 }
628 text::add_line_with_condition(state, contents, "give_access_explain_3", !military::are_at_war(state, state.local_player_nation, target));
629 }
630
631 }
632};
633
635public:
636 void on_create(sys::state& state) noexcept override {
637 base_data.data.button.txt = state.lookup_key("increaserelation_button");
639 }
640
641 void on_update(sys::state& state) noexcept override {
642 auto content = retrieve<dcon::nation_id>(state, parent);
643 disabled = !command::can_increase_relations(state, state.local_player_nation, content);
644 }
645
646 void button_action(sys::state& state) noexcept override {
647
648 command::increase_relations(state, state.local_player_nation, retrieve<dcon::nation_id>(state, parent));
649
650 }
651
654 }
655
656 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
657
658 auto target = retrieve<dcon::nation_id>(state, parent);
659
660 text::add_line(state, contents, "increase_rel_explain_1", text::variable_type::x, int64_t(state.defines.increaserelation_relation_on_accept));
662
663 if(target == state.local_player_nation) {
664 text::add_line_with_condition(state, contents, "increase_rel_explain_2", false);
665 }
666
667 text::add_line_with_condition(state, contents, "increase_rel_explain_3", state.world.nation_get_diplomatic_points(state.local_player_nation) >= state.defines.increaserelation_diplomatic_cost, text::variable_type::x, int64_t(state.defines.increaserelation_diplomatic_cost));
668
669 auto rel = state.world.get_diplomatic_relation_by_diplomatic_pair(state.local_player_nation, target);
670 text::add_line_with_condition(state, contents, "increase_rel_explain_4", state.world.diplomatic_relation_get_value(rel) < 200.0f);
671
672 text::add_line_with_condition(state, contents, "increase_rel_explain_5", !military::are_at_war(state, state.local_player_nation, target));
673
674 }
675};
676
678public:
679 void on_create(sys::state& state) noexcept override {
680 base_data.data.button.txt = state.lookup_key("decreaserelation_button");
682 }
683
684 void on_update(sys::state& state) noexcept override {
685 auto content = retrieve<dcon::nation_id>(state, parent);
686 disabled = !command::can_decrease_relations(state, state.local_player_nation, content);
687 }
688
689 void button_action(sys::state& state) noexcept override {
690 command::decrease_relations(state, state.local_player_nation, retrieve<dcon::nation_id>(state, parent));
691 }
692
695 }
696
697 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
698
699 auto target = retrieve<dcon::nation_id>(state, parent);
700
701 text::add_line(state, contents, "decrease_rel_explain_1", text::variable_type::x, int64_t(state.defines.decreaserelation_relation_on_accept));
703
704 if(target == state.local_player_nation) {
705 text::add_line_with_condition(state, contents, "decrease_rel_explain_2", false);
706 }
707
708 text::add_line_with_condition(state, contents, "decrease_rel_explain_3", state.world.nation_get_diplomatic_points(state.local_player_nation) >= state.defines.decreaserelation_diplomatic_cost, text::variable_type::x, int64_t(state.defines.decreaserelation_diplomatic_cost));
709
710 auto rel = state.world.get_diplomatic_relation_by_diplomatic_pair(state.local_player_nation, target);
711 text::add_line_with_condition(state, contents, "decrease_rel_explain_4", state.world.diplomatic_relation_get_value(rel) > -200.0f);
712
713 text::add_line_with_condition(state, contents, "decrease_rel_explain_5", !military::are_at_war(state, state.local_player_nation, target));
714
715 }
716};
717
719public:
720 void on_update(sys::state& state) noexcept override {
721 auto target = retrieve<dcon::nation_id>(state, parent);
722 auto rel = state.world.get_unilateral_relationship_by_unilateral_pair(target, state.local_player_nation);
723 bool subsidies = state.world.unilateral_relationship_get_war_subsidies(rel);
724 set_button_text(state, text::produce_simple_string(state, subsidies ? "cancel_warsubsidies_button" : "warsubsidies_button"));
726 ? !command::can_cancel_war_subsidies(state, state.local_player_nation, target)
727 : !command::can_give_war_subsidies(state, state.local_player_nation, target);
728 }
729
730 void button_action(sys::state& state) noexcept override {
731 auto target = retrieve<dcon::nation_id>(state, parent);
732 auto rel = state.world.get_unilateral_relationship_by_unilateral_pair(target, state.local_player_nation);
733 bool subsidies = state.world.unilateral_relationship_get_war_subsidies(rel);
734 if(subsidies) {
735 command::cancel_war_subsidies(state, state.local_player_nation, target);
736 } else {
737 command::give_war_subsidies(state, state.local_player_nation, target);
738 }
739 }
740
743 }
744
745 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
746 auto target = retrieve<dcon::nation_id>(state, parent);
747 auto rel = state.world.get_unilateral_relationship_by_unilateral_pair(target, state.local_player_nation);
748 bool subsidies = state.world.unilateral_relationship_get_war_subsidies(rel);
749
750 if(subsidies) {
752 if(state.defines.cancelwarsubsidy_diplomatic_cost > 0) {
754 text::add_line_with_condition(state, contents, "cancel_w_sub_explain_2", state.world.nation_get_diplomatic_points(state.local_player_nation) >= state.defines.cancelwarsubsidy_diplomatic_cost, text::variable_type::x, int16_t(state.defines.cancelwarsubsidy_diplomatic_cost));
755 }
756 } else {
759
760 if(state.local_player_nation == target) {
761 text::add_line_with_condition(state, contents, "w_sub_explain_1", false);
762 }
763 if(state.defines.warsubsidy_diplomatic_cost > 0) {
764 text::add_line_with_condition(state, contents, "w_sub_explain_2", state.world.nation_get_diplomatic_points(state.local_player_nation) >= state.defines.warsubsidy_diplomatic_cost, text::variable_type::x, int16_t(state.defines.warsubsidy_diplomatic_cost));
765 }
766 text::add_line_with_condition(state, contents, "w_sub_explain_3", !military::are_at_war(state, state.local_player_nation, target));
767 text::add_line_with_condition(state, contents, "w_sub_explain_4", state.world.nation_get_is_at_war(target));
768 }
769 }
770};
771
773public:
774 void on_update(sys::state& state) noexcept override {
775 dcon::nation_id content = retrieve<dcon::nation_id>(state, parent);
776
777 if(military::are_at_war(state, state.local_player_nation, content)) {
778 disabled = !command::can_start_peace_offer(state, state.local_player_nation, content,
779 military::find_war_between(state, state.local_player_nation, content), true);
781 } else {
782 disabled = state.local_player_nation == content || !military::can_use_cb_against(state, state.local_player_nation, content) || state.world.nation_get_diplomatic_points(state.local_player_nation) < state.defines.declarewar_diplomatic_cost || military::are_in_common_war(state, state.local_player_nation, content);
784 }
785 }
786
787 void button_action(sys::state& state) noexcept override {
788 if(parent) {
789 dcon::nation_id content = retrieve<dcon::nation_id>(state, parent);
791 parent->impl_get(state, ac_payload);
792 }
793 }
794
797 }
798
799 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
800
801 auto target = retrieve<dcon::nation_id>(state, parent);
802 auto source = state.local_player_nation;
803
804 if(military::are_at_war(state, state.local_player_nation, target)) {
805 text::add_line(state, contents, "peace_description");
807 {
808 auto ol = state.world.nation_get_overlord_as_subject(source);
809 text::add_line_with_condition(state, contents, "peace_explain_1", !state.world.overlord_get_ruler(ol));
810 }
811
812 {
813 auto ol = state.world.nation_get_overlord_as_subject(target);
814 text::add_line_with_condition(state, contents, "peace_explain_2", !state.world.overlord_get_ruler(ol));
815 }
816
817 auto war = military::find_war_between(state, source, target);
818
819 if(state.world.war_get_is_crisis_war(war)) {
820 bool both_wl = (state.world.war_get_primary_attacker(war) == source && state.world.war_get_primary_defender(war) == target) || (state.world.war_get_primary_attacker(war) == target || state.world.war_get_primary_defender(war) == source);
821 text::add_line_with_condition(state, contents, "peace_explain_4", both_wl);
822 } else {
823 bool one_is_wl = [&]() {
824 if(state.world.war_get_primary_attacker(war) == source) {
826 return true;
827 } else if(state.world.war_get_primary_defender(war) == source) {
829 return true;
830 } else if(state.world.war_get_primary_attacker(war) == target) {
832 return true;
833 } else if(state.world.war_get_primary_defender(war) == target) {
835 return true;
836 }
837 return false;
838 }();
839 text::add_line_with_condition(state, contents, "peace_explain_3", one_is_wl);
840 }
841 text::add_line_with_condition(state, contents, "peace_explain_5", !(state.world.nation_get_peace_offer_from_pending_peace_offer(source)));
842
843 } else {
844 text::add_line(state, contents, "act_wardesc");
846
847 if(source == target) {
848 text::add_line_with_condition(state, contents, "war_explain_1", false);
849 }
850 if(state.defines.declarewar_diplomatic_cost > 0) {
851 text::add_line_with_condition(state, contents, "war_explain_3", state.world.nation_get_diplomatic_points(state.local_player_nation) >= state.defines.declarewar_diplomatic_cost, text::variable_type::x, int64_t(state.defines.declarewar_diplomatic_cost));
852 }
853 text::add_line_with_condition(state, contents, "war_explain_2", military::can_use_cb_against(state, state.local_player_nation, target));
854 text::add_line_with_condition(state, contents, "war_explain_4", !military::are_in_common_war(state, state.local_player_nation, target));
855 }
856
857 }
858};
859
861public:
862 void on_create(sys::state& state) noexcept override {
863 base_data.data.button.txt = state.lookup_key("alice_diplo_release_subject");
865 }
866
867 void on_update(sys::state& state) noexcept override {
868 auto n = retrieve<dcon::nation_id>(state, parent);
869 disabled = !command::can_release_subject(state, state.local_player_nation, n);
870 }
871
872 void button_action(sys::state& state) noexcept override {
873 auto n = retrieve<dcon::nation_id>(state, parent);
874 command::release_subject(state, state.local_player_nation, n);
875 }
876
879 }
880
881 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
882 auto n = retrieve<dcon::nation_id>(state, parent);
883 text::add_line(state, contents, "alice_diplo_release_subject_desc");
884 text::add_line_with_condition(state, contents, "alice_diplo_release_subject_0", state.world.overlord_get_ruler(state.world.nation_get_overlord_as_subject(n)) == state.local_player_nation);
885 }
886};
887
889public:
890 void on_create(sys::state& state) noexcept override {
891 base_data.data.button.txt = state.lookup_key("increaseopinion_button");
893 }
894
895 void on_update(sys::state& state) noexcept override {
896 auto content = retrieve<dcon::nation_id>(state, parent);
897 disabled = !command::can_increase_opinion(state, state.local_player_nation, content);
898 }
899
900 void button_action(sys::state& state) noexcept override {
901 auto content = retrieve<dcon::nation_id>(state, parent);
902 command::increase_opinion(state, state.local_player_nation, content);
903 }
904
907 }
908
909 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
910
911 auto target = retrieve<dcon::nation_id>(state, parent);
912 auto source = state.local_player_nation;
913
914 text::add_line(state, contents, "increaseopinion_desc");
916
917 text::add_line_with_condition(state, contents, "iaction_explain_5", state.world.nation_get_is_great_power(source));
918
919 text::add_line_with_condition(state, contents, "iaction_explain_6", !state.world.nation_get_is_great_power(target));
920
921 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, source);
922 text::add_line_with_condition(state, contents, "iaction_explain_1", state.world.gp_relationship_get_influence(rel) >= state.defines.increaseopinion_influence_cost, text::variable_type::x, int64_t(state.defines.increaseopinion_influence_cost));
923
924 text::add_line_with_condition(state, contents, "iaction_explain_2", (state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) == 0);
925 text::add_line_with_condition(state, contents, "iaction_explain_3", !military::are_at_war(state, source, target));
926
927 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
929
930 }
931};
932
934public:
935 void on_create(sys::state& state) noexcept override {
936 base_data.data.button.txt = state.lookup_key("addtosphere_button");
938 }
939
940 void on_update(sys::state& state) noexcept override {
941 auto content = retrieve<dcon::nation_id>(state, parent);
942 disabled = !command::can_add_to_sphere(state, state.local_player_nation, content);
943 }
944
945 void button_action(sys::state& state) noexcept override {
946 auto content = retrieve<dcon::nation_id>(state, parent);
947 command::add_to_sphere(state, state.local_player_nation, content);
948 }
949
952 }
953
954 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
955 auto target = retrieve<dcon::nation_id>(state, parent);
956 auto source = state.local_player_nation;
957
958 text::add_line(state, contents, "addtosphere_desc");
960
961 text::add_line_with_condition(state, contents, "iaction_explain_5", state.world.nation_get_is_great_power(source));
962
963 text::add_line_with_condition(state, contents, "iaction_explain_6", !state.world.nation_get_is_great_power(target));
964
965 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, source);
966 text::add_line_with_condition(state, contents, "iaction_explain_1", state.world.gp_relationship_get_influence(rel) >= state.defines.addtosphere_influence_cost, text::variable_type::x, int64_t(state.defines.addtosphere_influence_cost));
967
968 text::add_line_with_condition(state, contents, "iaction_explain_2", (state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) == 0);
969 text::add_line_with_condition(state, contents, "iaction_explain_3", !military::are_at_war(state, source, target));
970
971 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
972 text::add_line_with_condition(state, contents, "add_sphere_explain_1", clevel == nations::influence::level_friendly);
973
974 text::add_line_with_condition(state, contents, "add_sphere_explain_2", !state.world.nation_get_in_sphere_of(target));
975
976 }
977};
978
980public:
981 void on_create(sys::state& state) noexcept override {
982 base_data.data.button.txt = state.lookup_key("removefromsphere_button");
984 }
985
986 void on_update(sys::state& state) noexcept override {
987 auto content = retrieve<dcon::nation_id>(state, parent);
988 disabled = !command::can_remove_from_sphere(state, state.local_player_nation, content, state.world.nation_get_in_sphere_of(content));
989 }
990
991 void button_action(sys::state& state) noexcept override {
992 auto content = retrieve<dcon::nation_id>(state, parent);
993 command::remove_from_sphere(state, state.local_player_nation, content, state.world.nation_get_in_sphere_of(content));
994 }
995
998 }
999
1000 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1001
1002 auto target = retrieve<dcon::nation_id>(state, parent);
1003 auto source = state.local_player_nation;
1004 bool in_players_sphere = state.world.nation_get_in_sphere_of(target) == source;
1005
1006 text::add_line(state, contents, "removefromsphere_desc");
1007 if(in_players_sphere) {
1008 if(state.defines.removefromsphere_infamy_cost != 0) {
1009 text::add_line(state, contents, "rem_sphere_explain_4", text::variable_type::x, text::fp_one_place{ state.defines.removefromsphere_infamy_cost });
1010 }
1011 if(state.defines.removefromsphere_prestige_cost != 0) {
1012 text::add_line(state, contents, "rem_sphere_explain_5", text::variable_type::x, text::fp_one_place{ state.defines.removefromsphere_prestige_cost });
1013 }
1014 }
1016
1017 text::add_line_with_condition(state, contents, "iaction_explain_5", state.world.nation_get_is_great_power(state.local_player_nation));
1018
1019 text::add_line_with_condition(state, contents, "iaction_explain_6", !state.world.nation_get_is_great_power(target));
1020
1021 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
1022 text::add_line_with_condition(state, contents, "iaction_explain_1", state.world.gp_relationship_get_influence(rel) >= state.defines.removefromsphere_influence_cost, text::variable_type::x, int64_t(state.defines.removefromsphere_influence_cost));
1023
1024 text::add_line_with_condition(state, contents, "iaction_explain_2", (state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) == 0);
1025 text::add_line_with_condition(state, contents, "iaction_explain_3", !military::are_at_war(state, state.local_player_nation, target));
1026
1027 text::add_line_with_condition(state, contents, "rem_sphere_explain_1", bool(state.world.nation_get_in_sphere_of(target)));
1028
1029 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
1030 if(!in_players_sphere) {
1031 text::add_line_with_condition(state, contents, "rem_sphere_explain_2", clevel == nations::influence::level_friendly);
1032 } else {
1033 text::add_line_with_condition(state, contents, "rem_sphere_explain_3", true);
1034 }
1035
1036 }
1037};
1038
1040 bool has_any_justifiable_cb(sys::state& state, dcon::nation_id source, dcon::nation_id target) noexcept {
1041 auto res = false;
1042 state.world.for_each_cb_type([&](dcon::cb_type_id cb) {
1043 if(command::can_fabricate_cb(state, source, target, cb))
1044 res = true;
1045 });
1046
1047 return res;
1048 }
1049public:
1050 void on_create(sys::state& state) noexcept override {
1051 base_data.data.button.txt = state.lookup_key("make_cb_button");
1053 }
1054
1055 void on_update(sys::state& state) noexcept override {
1056 auto source = state.local_player_nation;
1057 auto target = retrieve<dcon::nation_id>(state, parent);
1058
1059 auto can_subjects_declare = state.defines.alice_allow_subjects_declare_wars;
1060
1061 disabled = false;
1062 if(source == target)
1063 disabled = true;
1064 if(state.world.nation_get_constructing_cb_type(source))
1065 disabled = true;
1066 auto ol = state.world.nation_get_overlord_as_subject(source);
1067 if(state.defines.alice_allow_subjects_declare_wars < 1 && state.world.overlord_get_ruler(ol) && state.world.overlord_get_ruler(ol) != target)
1068 disabled = true;
1069 if(state.world.nation_get_in_sphere_of(target) == source)
1070 disabled = true;
1071 if(state.world.nation_get_diplomatic_points(source) < state.defines.make_cb_diplomatic_cost)
1072 disabled = true;
1073 if(military::are_at_war(state, target, source))
1074 disabled = true;
1075 if(!has_any_justifiable_cb(state, source, target))
1076 disabled = true;
1077 }
1078
1079 void button_action(sys::state& state) noexcept override {
1080 if(parent) {
1082 parent->impl_get(state, payload);
1083 }
1084 }
1085
1088 }
1089
1090 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1091 auto source = state.local_player_nation;
1092 auto target = retrieve<dcon::nation_id>(state, parent);
1093 text::add_line(state, contents, "make_cb_desc");
1095 if(source == target) {
1096 text::add_line_with_condition(state, contents, "fab_explain_1", false);
1097 }
1098 if(state.defines.make_cb_diplomatic_cost > 0) {
1099 text::add_line_with_condition(state, contents, "fab_explain_2", state.world.nation_get_diplomatic_points(source) >= state.defines.make_cb_diplomatic_cost, text::variable_type::x, int16_t(state.defines.make_cb_diplomatic_cost));
1100 }
1101 text::add_line_with_condition(state, contents, "fab_explain_3", !state.world.nation_get_constructing_cb_type(source));
1102 if(state.defines.alice_allow_subjects_declare_wars < 1) {
1103 auto ol = state.world.nation_get_overlord_as_subject(source);
1104 text::add_line_with_condition(state, contents, "fab_explain_4", !state.world.overlord_get_ruler(ol) || state.world.overlord_get_ruler(ol) == target);
1105 }
1106 text::add_line_with_condition(state, contents, "fab_explain_5", state.world.nation_get_in_sphere_of(target) != source);
1107 text::add_line_with_condition(state, contents, "fab_explain_6", !military::are_at_war(state, target, source));
1108 text::add_line_with_condition(state, contents, "fab_explain_7", has_any_justifiable_cb(state, source, target));
1109 text::add_line_with_condition(state, contents, "fab_explain_8", !military::has_truce_with(state, target, source));
1110 }
1111};
1112
1113class diplomacy_action_dialog_title_text : public generic_settable_element<simple_text_element_base, diplomacy_action> {
1114 static std::string_view get_title_key(diplomacy_action v) noexcept {
1115 switch(v) {
1117 return "alliancetitle";
1119 return "cancelalliancetitle";
1121 return "callallytitle";
1123 return "wartitle";
1125 return "askmilitaryaccesstitle";
1127 return "cancelaskmilitaryaccesstitle";
1129 return "givemilitaryaccesstitle";
1131 return "cancelgivemilitaryaccesstitle";
1133 return "increaserelationtitle";
1135 return "decreaserelationtitle";
1137 return "warsubsidiestitle";
1139 return "cancel_warsubsidiestitle";
1141 return "increaseopiniontitle";
1143 return "addtospheretitle";
1145 return "removefromspheretitle";
1147 return "make_cbtitle";
1149 return "give_unit_commandtitle";
1151 return "cancel_unit_commandtitle";
1153 return "make_peacetitle";
1154 default:
1155 return "";
1156 }
1157 }
1158
1159public:
1160 void on_update(sys::state& state) noexcept override {
1162 }
1163};
1164class diplomacy_action_dialog_description_text : public generic_settable_element<multiline_text_element_base, diplomacy_action> {
1165 static std::string_view get_title_key(diplomacy_action v) noexcept {
1166 switch(v) {
1168 return "alliancenewdesc";
1170 return "breakalliancenewdesc";
1172 return "callally_desc";
1174 return "war_desc";
1176 return "askmilitaryaccess_desc";
1178 return "cancelaskmilitaryaccess_desc";
1180 return "givemilitaryaccess_desc";
1182 return "cancelgivemilitaryaccess_desc";
1184 return "increaserelation_desc";
1186 return "decreaserelation_desc";
1188 return "warsubsidies_desc";
1190 return "cancel_warsubsidies_desc";
1192 return "increaseopinion_desc";
1194 return "addtosphere_desc";
1196 return "removefromsphere_desc";
1198 return "make_cb_desc";
1200 return "give_unit_command_desc";
1202 return "cancel_unit_command_desc";
1204 return "make_peace_desc";
1205 default:
1206 return "";
1207 }
1208 }
1209
1210public:
1211 void on_update(sys::state& state) noexcept override {
1213 text::layout_parameters{ 0, 0, static_cast<int16_t>(base_data.size.x), static_cast<int16_t>(base_data.size.y),
1215 auto box = text::open_layout_box(contents);
1216 text::localised_format_box(state, contents, box, get_title_key(content));
1217 text::close_layout_box(contents, box);
1218 }
1219};
1220
1221class diplomacy_action_dialog_agree_button : public generic_settable_element<button_element_base, diplomacy_action> {
1222 bool get_can_perform(sys::state& state) noexcept {
1223 auto target = retrieve<dcon::nation_id>(state, parent);
1224 switch(content) {
1226 return command::can_ask_for_alliance(state, state.local_player_nation, target);
1228 return command::can_cancel_alliance(state, state.local_player_nation, target);
1230 {
1231 for(auto wp : dcon::fatten(state.world, state.local_player_nation).get_war_participant())
1232 if(command::can_call_to_arms(state, state.local_player_nation, target, dcon::fatten(state.world, wp).get_war().id))
1233 return true;
1234 return false;
1235 }
1237 return false;
1239 return command::can_ask_for_access(state, state.local_player_nation, target);
1241 return command::can_cancel_military_access(state, state.local_player_nation, target);
1243 return false;
1245 return command::can_cancel_given_military_access(state, state.local_player_nation, target);
1247 return command::can_increase_relations(state, state.local_player_nation, target);
1249 return command::can_decrease_relations(state, state.local_player_nation, target);
1251 return command::can_give_war_subsidies(state, state.local_player_nation, target);
1253 return command::can_cancel_war_subsidies(state, state.local_player_nation, target);
1255 return command::can_increase_opinion(state, state.local_player_nation, target);
1257 return command::can_add_to_sphere(state, state.local_player_nation, target);
1259 return command::can_remove_from_sphere(state, state.local_player_nation, target, state.world.nation_get_in_sphere_of(target));
1261 return false;
1263 return false;
1265 return false;
1267 return false;
1269 return false;
1271 return false;
1273 return false;
1275 return false;
1276 }
1277 return false;
1278 }
1279
1280public:
1281 void on_create(sys::state& state) noexcept override {
1282 base_data.data.button.txt = state.lookup_key("agree");
1284 }
1285
1286 void on_update(sys::state& state) noexcept override {
1287 disabled = !get_can_perform(state);
1288 }
1289
1290 void button_action(sys::state& state) noexcept override {
1291 auto target = retrieve<dcon::nation_id>(state, parent);
1292 switch(content) {
1294 command::ask_for_alliance(state, state.local_player_nation, target);
1295 break;
1297 command::cancel_alliance(state, state.local_player_nation, target);
1298 break;
1300 for(auto wp : dcon::fatten(state.world, state.local_player_nation).get_war_participant())
1301 command::call_to_arms(state, state.local_player_nation, target, dcon::fatten(state.world, wp).get_war().id);
1302 break;
1304 break;
1306 command::ask_for_military_access(state, state.local_player_nation, target);
1307 break;
1309 command::cancel_military_access(state, state.local_player_nation, target);
1310 break;
1312 break;
1314 command::cancel_given_military_access(state, state.local_player_nation, target);
1315 break;
1317 command::increase_relations(state, state.local_player_nation, target);
1318 break;
1320 command::decrease_relations(state, state.local_player_nation, target);
1321 break;
1323 command::give_war_subsidies(state, state.local_player_nation, target);
1324 break;
1326 command::cancel_war_subsidies(state, state.local_player_nation, target);
1327 break;
1329 command::increase_opinion(state, state.local_player_nation, target);
1330 break;
1332 command::add_to_sphere(state, state.local_player_nation, target);
1333 break;
1335 command::remove_from_sphere(state, state.local_player_nation, target, state.world.nation_get_in_sphere_of(target));
1336 break;
1338 break;
1340 break;
1342 break;
1344 break;
1346 break;
1348 break;
1350 break;
1352 break;
1353 }
1354 if(parent) {
1355 parent->set_visible(state, false);
1356 }
1357 }
1358};
1360public:
1361 void on_create(sys::state& state) noexcept override {
1362 base_data.data.button.txt = state.lookup_key("decline");
1364 }
1365};
1366
1368public:
1369 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1370 if(name == "title") {
1371 return make_element_by_type<diplomacy_action_dialog_title_text>(state, id);
1372 } else if(name == "description") {
1373 return make_element_by_type<diplomacy_action_dialog_description_text>(state, id);
1374 } else if(name == "chance_string") {
1375 return make_element_by_type<simple_text_element_base>(state, id);
1376 } else if(name == "agreebutton") {
1377 return make_element_by_type<diplomacy_action_dialog_agree_button>(state, id);
1378 } else if(name == "declinebutton") {
1379 return make_element_by_type<diplomacy_action_dialog_decline_button>(state, id);
1380 } else if(name == "leftshield") {
1381 return make_element_by_type<nation_player_flag>(state, id);
1382 } else if(name == "rightshield") {
1383 return make_element_by_type<flag_button>(state, id);
1384 } else if(name == "background") {
1385 auto ptr = make_element_by_type<draggable_target>(state, id);
1386 ptr->base_data.size = base_data.size;
1387 return ptr;
1388 } else {
1389 return nullptr;
1390 }
1391 }
1392};
1393
1394
1396 int32_t value = 0;
1397};
1398
1400 int32_t value = 0;
1401};
1402
1404 int32_t value = 0;
1405};
1406
1408public:
1409 dcon::national_identity_id get_current_nation(sys::state& state) noexcept override {
1410 auto n = nations::get_nth_great_power(state, uint16_t(retrieve<gp_choice_num>(state, parent).value));
1411 return state.world.nation_get_identity_from_identity_holder(n);
1412 }
1413 void button_action(sys::state& state) noexcept override {
1414 auto this_selection = retrieve<gp_choice_num>(state, parent);
1415 send(state, parent, gp_choice_select{ this_selection.value });
1416 }
1417};
1418
1420public:
1421 void on_update(sys::state& state) noexcept override {
1422 auto n = nations::get_nth_great_power(state, uint16_t(retrieve<gp_choice_num>(state, parent).value));
1424 }
1425};
1426
1428public:
1429 bool show = false;
1430 void on_update(sys::state& state) noexcept override {
1431 show = retrieve<gp_choice_num>(state, parent).value == retrieve<gp_choice_get_selection>(state, parent).value;
1432 }
1433 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
1434 if(show) {
1436 }
1437 }
1438};
1439
1441public:
1442 bool show = false;
1443 void on_update(sys::state& state) noexcept override {
1444 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_choice_num>(state, parent).value));
1445 auto target = retrieve<dcon::nation_id>(state, parent);
1446 show = (state.world.gp_relationship_get_status(state.world.get_gp_relationship_by_gp_influence_pair(target, gp)) & nations::influence::is_banned) != 0;
1447 }
1450 }
1451
1452 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1453 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_choice_num>(state, parent).value));
1454 auto target = retrieve<dcon::nation_id>(state, parent);
1455 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, gp);
1456
1457 text::add_line(state, contents, "dp_inf_tooltip_ban", text::variable_type::x, state.world.gp_relationship_get_penalty_expires_date(rel));
1458 }
1459 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
1460 if(show)
1462 }
1463};
1464
1466public:
1467 bool show = false;
1468 void on_update(sys::state& state) noexcept override {
1469 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_choice_num>(state, parent).value));
1470 auto target = retrieve<dcon::nation_id>(state, parent);
1471 show = (state.world.gp_relationship_get_status(state.world.get_gp_relationship_by_gp_influence_pair(target, gp)) & nations::influence::is_discredited) != 0;
1472 }
1475 }
1476
1477 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1478 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_choice_num>(state, parent).value));
1479 auto target = retrieve<dcon::nation_id>(state, parent);
1480 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, gp);
1481
1482 text::add_line(state, contents, "dp_inf_tooltip_discredit", text::variable_type::x, state.world.gp_relationship_get_penalty_expires_date(rel));
1483 }
1484 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
1485 if(show)
1487 }
1488};
1489
1491public:
1492 void on_update(sys::state& state) noexcept override {
1493 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_choice_num>(state, parent).value));
1494 auto target = retrieve<dcon::nation_id>(state, parent);
1495
1496 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))));
1497 }
1498};
1500public:
1501 void on_update(sys::state& state) noexcept override {
1502 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_choice_num>(state, parent).value));
1503 auto target = retrieve<dcon::nation_id>(state, parent);
1504
1505 set_text(state, text::format_float(state.world.gp_relationship_get_influence(state.world.get_gp_relationship_by_gp_influence_pair(target, gp)), 1));
1506 }
1507};
1508
1510public:
1512
1513 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1514 if(name == "country_name") {
1515 return make_element_by_type<select_gp_name>(state, id);
1516 } else if(name == "country_flag") {
1517 return make_element_by_type<select_gp_choice_button>(state, id);
1518 } else if(name == "country_selected") {
1519 return make_element_by_type<select_gp_selection_icon>(state, id);
1520 } else if(name == "country_discredited") {
1521 return make_element_by_type<select_gp_discredited>(state, id);
1522 } else if(name == "country_banned_embassy") {
1523 return make_element_by_type<select_gp_banned>(state, id);
1524 } else if(name == "country_opinion") {
1525 return make_element_by_type<select_gp_opinion_detail>(state, id);
1526 } else if(name == "country_influence") {
1527 return make_element_by_type<select_gp_influence_detail>(state, id);
1528 } else {
1529 return nullptr;
1530 }
1531 }
1532
1533 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
1534 if(payload.holds_type<gp_choice_num>()) {
1535 payload.emplace<gp_choice_num>(gp_choice_num{ rank });
1537 }
1538 return window_element_base::get(state, payload);
1539 }
1540};
1541
1542
1543class gp_action_choice_title : public generic_settable_element<simple_text_element_base, diplomacy_action> {
1544public:
1545 void on_update(sys::state& state) noexcept override {
1546 switch(retrieve<gp_choice_actions>(state, parent)) {
1548 set_text(state, text::produce_simple_string(state, "discredittitle"));
1549 break;
1551 set_text(state, text::produce_simple_string(state, "expeladvisorstitle"));
1552 break;
1554 set_text(state, text::produce_simple_string(state, "banembassytitle"));
1555 break;
1557 set_text(state, text::produce_simple_string(state, "decreaseopiniontitle"));
1558 break;
1559 default:
1560 break;
1561 }
1562
1563 }
1564};
1565
1566class gp_action_choice_desc : public generic_settable_element<simple_text_element_base, diplomacy_action> {
1567public:
1568 void on_update(sys::state& state) noexcept override {
1570 switch(retrieve<gp_choice_actions>(state, parent)) {
1572 text::add_to_substitution_map(m, text::variable_type::days, int64_t(state.defines.discredit_days));
1573 set_text(state, text::resolve_string_substitution(state, "discredit_desc", m));
1574 break;
1576 set_text(state, text::produce_simple_string(state, "expeladvisors_desc"));
1577 break;
1579 text::add_to_substitution_map(m, text::variable_type::days, int64_t(state.defines.banembassy_days));
1580 set_text(state, text::resolve_string_substitution(state, "banembassy_desc", m));
1581 break;
1583 set_text(state, text::produce_simple_string(state, "decreaseopinion_desc"));
1584 break;
1585 default:
1586 break;
1587 }
1588
1589 }
1590};
1591
1593public:
1594 void on_create(sys::state& state) noexcept override {
1595 base_data.data.button.txt = state.lookup_key("cancel");
1597 }
1598};
1599
1601public:
1602 void on_create(sys::state& state) noexcept override {
1603 base_data.data.button.txt = state.lookup_key("ok");
1605 }
1606
1607 void on_update(sys::state& state) noexcept override {
1608 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_choice_get_selection>(state, parent).value));
1609 auto target = retrieve<dcon::nation_id>(state, parent);
1610
1611 switch(retrieve<gp_choice_actions>(state, parent)) {
1613 disabled = !command::can_discredit_advisors(state, state.local_player_nation, target, gp);
1614 break;
1616 disabled = !command::can_expel_advisors(state, state.local_player_nation, target, gp);
1617 break;
1619 disabled = !command::can_ban_embassy(state, state.local_player_nation, target, gp);
1620 break;
1622 disabled = !command::can_decrease_opinion(state, state.local_player_nation, target, gp);
1623 break;
1624 }
1625 }
1626 void button_action(sys::state& state) noexcept override {
1627 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_choice_get_selection>(state, parent).value));
1628 auto target = retrieve<dcon::nation_id>(state, parent);
1629
1630 switch(retrieve<gp_choice_actions>(state, parent)) {
1632 command::discredit_advisors(state, state.local_player_nation, target, gp);
1633 break;
1635 command::expel_advisors(state, state.local_player_nation, target, gp);
1636 break;
1638 command::ban_embassy(state, state.local_player_nation, target, gp);
1639 break;
1641 command::decrease_opinion(state, state.local_player_nation, target, gp);
1642 break;
1643 }
1644 parent->set_visible(state, false);
1645 }
1648 }
1649 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1650 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_choice_get_selection>(state, parent).value));
1651 auto target = retrieve<dcon::nation_id>(state, parent);
1652
1653 switch(retrieve<gp_choice_actions>(state, parent)) {
1655 {
1656 if(state.local_player_nation == gp) {
1657 text::add_line_with_condition(state, contents, "discredit_explain_1", false);
1658 }
1659
1660 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
1661
1662 text::add_line_with_condition(state, contents, "iaction_explain_1", rel && state.world.gp_relationship_get_influence(rel) >= state.defines.discredit_influence_cost, text::variable_type::x, int64_t(state.defines.discredit_influence_cost));
1663
1664 text::add_line_with_condition(state, contents, "iaction_explain_2", (state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) == 0);
1665 text::add_line_with_condition(state, contents, "iaction_explain_3", !military::are_at_war(state, state.local_player_nation, target));
1666
1667 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
1668 text::add_line_with_condition(state, contents, "discredit_explain_2", clevel != nations::influence::level_hostile);
1669
1670
1671 auto orel = state.world.get_gp_relationship_by_gp_influence_pair(target, gp);
1672 text::add_line_with_condition(state, contents, "discredit_explain_3", (state.world.gp_relationship_get_status(orel) & nations::influence::is_banned) == 0);
1673
1675 }
1676 break;
1678 {
1679 if(state.local_player_nation == gp) {
1680 text::add_line_with_condition(state, contents, "expel_explain_1", false);
1681 }
1682
1683 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
1684
1685 text::add_line_with_condition(state, contents, "iaction_explain_1", rel && state.world.gp_relationship_get_influence(rel) >= state.defines.expeladvisors_influence_cost, text::variable_type::x, int64_t(state.defines.expeladvisors_influence_cost));
1686
1687 text::add_line_with_condition(state, contents, "iaction_explain_2", (state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) == 0);
1688
1689 text::add_line_with_condition(state, contents, "iaction_explain_3", !military::are_at_war(state, state.local_player_nation, target));
1690
1691 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
1692
1694
1696 }
1697 break;
1699 {
1700 if(state.local_player_nation == gp) {
1701 text::add_line_with_condition(state, contents, "ban_explain_1", false);
1702 }
1703
1704 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
1705
1706 text::add_line_with_condition(state, contents, "iaction_explain_1", rel && state.world.gp_relationship_get_influence(rel) >= state.defines.banembassy_influence_cost, text::variable_type::x, int64_t(state.defines.banembassy_influence_cost));
1707
1708 text::add_line_with_condition(state, contents, "iaction_explain_2", (state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) == 0);
1709
1710 text::add_line_with_condition(state, contents, "iaction_explain_3", !military::are_at_war(state, state.local_player_nation, target));
1711
1712 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
1714
1716 }
1717 break;
1719 {
1720 if(state.local_player_nation == gp) {
1721 text::add_line_with_condition(state, contents, "dec_op_explain_1", false);
1722 }
1723
1724 if(state.world.nation_get_in_sphere_of(target) == gp) {
1725 text::add_line_with_condition(state, contents, "dec_op_explain_2", false);
1726 }
1727
1728 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
1729
1730 text::add_line_with_condition(state, contents, "iaction_explain_1", rel && state.world.gp_relationship_get_influence(rel) >= state.defines.decreaseopinion_influence_cost, text::variable_type::x, int64_t(state.defines.decreaseopinion_influence_cost));
1731
1732 text::add_line_with_condition(state, contents, "iaction_explain_2", (state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) == 0);
1733
1734 text::add_line_with_condition(state, contents, "iaction_explain_3", !military::are_at_war(state, state.local_player_nation, target));
1735
1736 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
1737 text::add_line_with_condition(state, contents, "dec_op_explain_3", clevel != nations::influence::level_hostile);
1738
1739
1741 state.world.gp_relationship_get_status(state.world.get_gp_relationship_by_gp_influence_pair(target,
1743 text::add_line_with_condition(state, contents, "dec_op_explain_4", false);
1744 }
1745
1747
1748 }
1749 break;
1750 default:
1751 break;
1752 }
1753 }
1754};
1755
1757public:
1758 int32_t selected_gp = 0;
1759 dcon::nation_id action_target{ 0 };
1761
1762 void on_create(sys::state& state) noexcept override {
1764
1765 xy_pair gp_base_select_offset =
1766 state.ui_defs.gui[state.ui_state.defs_by_name.find(state.lookup_key("gpselectoptionpos"))->second.definition].position;
1767 xy_pair gp_select_offset = gp_base_select_offset;
1768 for(uint8_t i = 0; i < uint8_t(state.defines.great_nations_count); i++) {
1769 auto ptr = make_element_by_type<diplomacy_action_gp_dialog_select_window>(state,
1770 state.ui_state.defs_by_name.find(state.lookup_key("gpselectoption"))->second.definition);
1771 ptr->base_data.position = gp_select_offset;
1772 ptr->rank = i;
1773 // Arrange in columns of 2 elements each...
1774 gp_select_offset.y += ptr->base_data.size.y;
1775 if(i != 0 && i % 2 == 1) {
1776 gp_select_offset.x += ptr->base_data.size.x;
1777 gp_select_offset.y = gp_base_select_offset.y;
1778 }
1779 add_child_to_front(std::move(ptr));
1780 }
1781 }
1782
1783 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1784 if(name == "title") {
1785 return make_element_by_type<gp_action_choice_title>(state, id);
1786 } else if(name == "description") {
1787 return make_element_by_type<gp_action_choice_desc>(state, id);
1788 } else if(name == "agreebutton") {
1789 return make_element_by_type<gp_action_choice_accept_button>(state, id);
1790 } else if(name == "declinebutton") {
1791 return make_element_by_type<gp_action_choice_cancel_button>(state, id);
1792 } else if(name == "leftshield") {
1793 return make_element_by_type<nation_player_flag>(state, id);
1794 } else if(name == "rightshield") {
1795 return make_element_by_type<flag_button>(state, id);
1796 } else if(name == "background") {
1797 auto ptr = make_element_by_type<draggable_target>(state, id);
1798 ptr->base_data.size = base_data.size;
1799 return ptr;
1800 } else {
1801 return nullptr;
1802 }
1803 }
1804
1805 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
1806 if(payload.holds_type<gp_choice_select>()) {
1807 selected_gp = any_cast<gp_choice_select>(payload).value;
1810 } else if(payload.holds_type<dcon::nation_id>()) {
1811 payload.emplace<dcon::nation_id>(action_target);
1813 } else if(payload.holds_type<gp_choice_get_selection>()) {
1816 } else if(payload.holds_type<gp_choice_actions>()) {
1817 payload.emplace<gp_choice_actions>(current_action);
1819 }
1820 return window_element_base::get(state, payload);
1821 }
1822};
1823
1825public:
1826 void on_create(sys::state& state) noexcept override {
1827 base_data.data.button.txt = state.lookup_key("state_transfer_button");
1829 }
1830
1831 void on_update(sys::state& state) noexcept override {
1832 auto content = retrieve<dcon::nation_id>(state, parent);
1833 disabled = true;
1834 for(const auto s : state.world.nation_get_state_ownership(content)) {
1835 if(command::can_state_transfer(state, state.local_player_nation, content, s.get_state().get_definition())) {
1836 disabled = false;
1837 break;
1838 }
1839 }
1840 }
1841
1842 void button_action(sys::state& state) noexcept override {
1843 auto content = retrieve<dcon::nation_id>(state, parent);
1844
1846 seldata.single_state_select = true;
1847 for(const auto s : state.world.nation_get_state_ownership(state.local_player_nation)) {
1848 if(command::can_state_transfer(state, state.local_player_nation, content, s.get_state().get_definition())) {
1849 seldata.selectable_states.push_back(s.get_state().get_definition());
1850 }
1851 }
1852 seldata.on_select = [this, content](sys::state& state, dcon::state_definition_id sdef) {
1853 command::state_transfer(state, state.local_player_nation, content, sdef);
1855 };
1856 seldata.on_cancel = [this](sys::state& state) {
1858 };
1859 state.start_state_selection(seldata);
1860 }
1861
1864 }
1865
1866 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1867 auto target = retrieve<dcon::nation_id>(state, parent);
1868 auto source = state.local_player_nation;
1869
1870 text::add_line(state, contents, "state_transfer_desc");
1872 text::add_line_with_condition(state, contents, "state_transfer_explain_1", state.world.nation_get_is_player_controlled(target));
1873 text::add_line_with_condition(state, contents, "state_transfer_explain_2", state.current_crisis == sys::crisis_type::none);
1874 text::add_line_with_condition(state, contents, "state_transfer_explain_3", !state.world.overlord_get_ruler(state.world.nation_get_overlord_as_subject(source)));
1875 text::add_line_with_condition(state, contents, "state_transfer_explain_4", !state.world.overlord_get_ruler(state.world.nation_get_overlord_as_subject(target)));
1876 text::add_line_with_condition(state, contents, "state_transfer_explain_5", !(state.world.nation_get_is_at_war(source) || state.world.nation_get_is_at_war(target)));
1877 text::add_line_with_condition(state, contents, "state_transfer_explain_6", state.world.nation_get_owned_state_count(source) > 1);
1878 }
1879};
1880
1881template<typename T>
1883public:
1884 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1885 if(name == "action_option") {
1886 return make_element_by_type<T>(state, id);
1887 } else {
1888 return nullptr;
1889 }
1890 }
1891};
1892
1893} // namespace ui
void set_button_text(sys::state &state, std::string const &new_text)
void on_create(sys::state &state) noexcept override
void add_child_to_front(std::unique_ptr< element_base > child) noexcept final
void impl_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_create(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void 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
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 on_create(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void 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
void button_action(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
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 button_action(sys::state &state) 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 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_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_create(sys::state &state) 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
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
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void button_action(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void on_update(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void button_action(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
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 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 button_action(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
void on_update(sys::state &state) noexcept override
void on_create(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
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
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 button_action(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
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
tooltip_behavior has_tooltip(sys::state &state) noexcept override
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 on_create(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void button_action(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void on_update(sys::state &state) noexcept override
tooltip_behavior has_tooltip(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
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
element_base * parent
virtual message_result get(sys::state &state, Cyto::Any &payload) noexcept
virtual void impl_on_update(sys::state &state) noexcept
message_result impl_get(sys::state &state, Cyto::Any &payload) noexcept
element_data base_data
void set_visible(sys::state &state, bool vis)
void button_action(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_create(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
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) 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 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 on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void set_text(sys::state &state, std::string const &new_text)
void on_create(sys::state &state) noexcept override
void explain_ai_access_reasons(sys::state &state, dcon::nation_id target, text::layout_base &contents, int32_t indent)
Definition: ai.cpp:363
void explain_ai_alliance_reasons(sys::state &state, dcon::nation_id target, text::layout_base &contents, int32_t indent)
Definition: ai.cpp:324
bool can_state_transfer(sys::state &state, dcon::nation_id asker, dcon::nation_id target, dcon::state_definition_id sid)
Definition: commands.cpp:2375
bool can_increase_opinion(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target)
Definition: commands.cpp:1273
bool can_cancel_military_access(sys::state &state, dcon::nation_id source, dcon::nation_id target, bool ignore_cost)
Definition: commands.cpp:2500
bool can_release_subject(sys::state &state, dcon::nation_id source, dcon::nation_id target)
Definition: commands.cpp:3807
bool can_expel_advisors(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target, dcon::nation_id affected_gp)
Definition: commands.cpp:1132
bool can_add_to_sphere(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target)
Definition: commands.cpp:1410
bool can_give_war_subsidies(sys::state &state, dcon::nation_id source, dcon::nation_id target)
Definition: commands.cpp:238
bool can_give_military_access(sys::state &state, dcon::nation_id asker, dcon::nation_id target, bool ignore_cost)
Definition: commands.cpp:2262
bool can_cancel_war_subsidies(sys::state &state, dcon::nation_id source, dcon::nation_id target)
Definition: commands.cpp:283
void give_war_subsidies(sys::state &state, dcon::nation_id source, dcon::nation_id target)
Definition: commands.cpp:230
bool can_call_to_arms(sys::state &state, dcon::nation_id asker, dcon::nation_id target, dcon::war_id w, bool ignore_cost)
Definition: commands.cpp:2430
bool can_ask_for_access(sys::state &state, dcon::nation_id asker, dcon::nation_id target, bool ignore_cost)
Definition: commands.cpp:2222
bool can_increase_relations(sys::state &state, dcon::nation_id source, dcon::nation_id target)
Definition: commands.cpp:325
bool can_ban_embassy(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target, dcon::nation_id affected_gp)
Definition: commands.cpp:1202
bool can_decrease_relations(sys::state &state, dcon::nation_id source, dcon::nation_id target)
Definition: commands.cpp:365
bool can_start_peace_offer(sys::state &state, dcon::nation_id source, dcon::nation_id target, dcon::war_id war, bool is_concession)
Definition: commands.cpp:2809
bool can_discredit_advisors(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target, dcon::nation_id affected_gp)
Definition: commands.cpp:1057
bool can_remove_from_sphere(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target, dcon::nation_id affected_gp)
Definition: commands.cpp:1470
bool can_decrease_opinion(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target, dcon::nation_id affected_gp)
Definition: commands.cpp:1331
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_cancel_alliance(sys::state &state, dcon::nation_id source, dcon::nation_id target, bool ignore_cost)
Definition: commands.cpp:2578
bool can_cancel_given_military_access(sys::state &state, dcon::nation_id source, dcon::nation_id target, bool ignore_cost)
Definition: commands.cpp:2539
bool can_ask_for_alliance(sys::state &state, dcon::nation_id asker, dcon::nation_id target, bool ignore_cost)
Definition: commands.cpp:2297
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
bool ai_will_accept(sys::state &state, message const &m)
float estimate_war_subsidies(sys::state &state, dcon::nation_id n)
Definition: economy.cpp:4827
bool can_use_cb_against(sys::state &state, dcon::nation_id from, dcon::nation_id target)
Definition: military.cpp:95
bool has_truce_with(sys::state &state, dcon::nation_id attacker, dcon::nation_id target)
Definition: military.cpp:2037
bool standard_war_joining_is_possible(sys::state &state, dcon::war_id wfor, dcon::nation_id n, bool as_attacker)
Definition: military.cpp:2344
war_role get_role(sys::state const &state, dcon::war_id w, dcon::nation_id n)
Definition: military.cpp:2242
bool is_attacker(sys::state &state, dcon::war_id w, dcon::nation_id n)
Definition: military.cpp:2234
bool are_in_common_war(sys::state const &state, dcon::nation_id a, dcon::nation_id b)
Definition: military.cpp:497
dcon::war_id find_war_between(sys::state const &state, dcon::nation_id a, dcon::nation_id b)
Definition: military.cpp:542
bool are_at_war(sys::state const &state, dcon::nation_id a, dcon::nation_id b)
Definition: military.cpp:475
bool is_civil_war(sys::state const &state, dcon::war_id w)
Definition: military.cpp:567
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 level_opposed
Definition: nations.hpp:165
constexpr uint8_t level_hostile
Definition: nations.hpp:166
constexpr uint8_t level_in_sphere
Definition: nations.hpp:169
constexpr uint8_t level_mask
Definition: nations.hpp:163
int32_t get_level(sys::state &state, dcon::nation_id gp, dcon::nation_id target)
Definition: nations.cpp:23
bool is_influence_level_greater_or_equal(int32_t l, int32_t r)
Definition: nations.hpp:249
bool are_allied(sys::state &state, dcon::nation_id a, dcon::nation_id b)
Definition: nations.cpp:198
dcon::nation_id get_nth_great_power(sys::state const &state, uint16_t n)
Definition: nations.cpp:57
std::string resolve_string_substitution(sys::state &state, dcon::text_key source_text, substitution_map const &mp)
Definition: text.cpp:2113
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
endless_layout create_endless_layout(sys::state &state, layout &dest, layout_parameters const &params)
Definition: text.cpp:1100
std::string format_float(float num, size_t digits)
Definition: text.cpp:981
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
Definition: text.cpp:1899
void add_line_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
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 get_influence_level_name(sys::state const &state, uint8_t v)
Definition: text.cpp:958
void close_layout_box(columnar_layout &dest, layout_box &box)
Definition: text.cpp:1807
tooltip_behavior
void send(sys::state &state, element_base *parent, T value)
message_result
uchar uint8_t
std::vector< dcon::state_definition_id > selectable_states
std::function< void(sys::state &, dcon::state_definition_id)> on_select
std::function< void(sys::state &)> on_cancel
union ui::element_data::internal_data data
dcon::national_identity_id get_current_nation(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_update(sys::state &state) noexcept override
ankerl::unordered_dense::map< dcon::text_key, element_target, hash_text_key > defs_by_name
dcon::text_key txt