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,
34};
35
41};
42
45};
46
48public:
49 virtual dcon::text_key get_name(sys::state& state, dcon::nation_id target) {
50 return state.lookup_key("null");
51 }
52
53 virtual bool is_available(sys::state& state, dcon::nation_id target) {
54 return false;
55 }
56
57 virtual void button_action(sys::state& state, dcon::nation_id target, ui::element_base* parent) {
58
59 }
60
61 virtual void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents, dcon::nation_id target) {
62
63 }
64};
65
66
68public:
69 dcon::text_key get_name(sys::state& state, dcon::nation_id target) noexcept override {
70 return state.lookup_key("discredit_button");
71 }
72
73 bool is_available(sys::state& state, dcon::nation_id target) noexcept override {
74 if(!state.world.nation_get_is_great_power(state.local_player_nation) || state.world.nation_get_is_great_power(target))
75 return false;
76 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
77 if(state.world.gp_relationship_get_influence(rel) < state.defines.discredit_influence_cost)
78 return false;
79
80 if((state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) != 0)
81 return false;
82 if(military::are_at_war(state, state.local_player_nation, target))
83 return false;
84 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
86 return false;
87
88 return true;
89 }
90
91 void button_action(sys::state& state, dcon::nation_id target, ui::element_base* parent) noexcept override {
93 }
94
95 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents, dcon::nation_id target) noexcept override {
96 text::add_line(state, contents, "discredit_desc", text::variable_type::days, int64_t(state.defines.discredit_days));
98
99 text::add_line_with_condition(state, contents, "iaction_explain_5", state.world.nation_get_is_great_power(state.local_player_nation));
100
101 text::add_line_with_condition(state, contents, "iaction_explain_6", !state.world.nation_get_is_great_power(target));
102
103 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
104 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));
105
106 text::add_line_with_condition(state, contents, "iaction_explain_2", (state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) == 0);
107 text::add_line_with_condition(state, contents, "iaction_explain_3", !military::are_at_war(state, state.local_player_nation, target));
108
109 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
110 text::add_line_with_condition(state, contents, "discredit_explain_2", clevel != nations::influence::level_hostile);
111 }
112};
113
115public:
116 dcon::text_key get_name(sys::state& state, dcon::nation_id target) noexcept override {
117 return state.lookup_key("expeladvisors_button");
118 }
119
120 bool is_available(sys::state& state, dcon::nation_id target) noexcept override {
121 if(!state.world.nation_get_is_great_power(state.local_player_nation) || state.world.nation_get_is_great_power(target))
122 return false;
123
124 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
125 if(state.world.gp_relationship_get_influence(rel) < state.defines.expeladvisors_influence_cost)
126 return false;
127
128 if((state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) != 0)
129 return false;
130
131 if(military::are_at_war(state, state.local_player_nation, target))
132 return false;
133
134 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
136 return false;
137
138 return true;
139 }
140
141
142 void button_action(sys::state& state, dcon::nation_id target, ui::element_base* parent) noexcept override {
144 }
145
146 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents, dcon::nation_id target) noexcept override {
147 text::add_line(state, contents, "expeladvisors_desc");
149
150 text::add_line_with_condition(state, contents, "iaction_explain_5", state.world.nation_get_is_great_power(state.local_player_nation));
151
152 text::add_line_with_condition(state, contents, "iaction_explain_6", !state.world.nation_get_is_great_power(target));
153
154 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
155 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));
156
157 text::add_line_with_condition(state, contents, "iaction_explain_2", (state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) == 0);
158 text::add_line_with_condition(state, contents, "iaction_explain_3", !military::are_at_war(state, state.local_player_nation, target));
159
160 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
162 }
163};
164
166public:
167 dcon::text_key get_name(sys::state& state, dcon::nation_id target) noexcept override {
168 return state.lookup_key("banembassy_button");
169 }
170
171 bool is_available(sys::state& state, dcon::nation_id target) noexcept override {
172 if(!state.world.nation_get_is_great_power(state.local_player_nation) || state.world.nation_get_is_great_power(target))
173 return false;
174
175 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
176 if(state.world.gp_relationship_get_influence(rel) < state.defines.banembassy_influence_cost)
177 return false;
178
179 if((state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) != 0)
180 return false;
181
182 if(military::are_at_war(state, state.local_player_nation, target))
183 return false;
184
185 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
187 return false;
188
189 return true;
190 }
191
192
193 void button_action(sys::state& state, dcon::nation_id target, ui::element_base* parent) noexcept override {
195 }
196
197 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents, dcon::nation_id target) noexcept override {
198 text::add_line(state, contents, "banembassy_desc", text::variable_type::days, int64_t(state.defines.banembassy_days));
200
201 text::add_line_with_condition(state, contents, "iaction_explain_5", state.world.nation_get_is_great_power(state.local_player_nation));
202
203 text::add_line_with_condition(state, contents, "iaction_explain_6", !state.world.nation_get_is_great_power(target));
204
205 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
206 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));
207
208 text::add_line_with_condition(state, contents, "iaction_explain_2", (state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) == 0);
209 text::add_line_with_condition(state, contents, "iaction_explain_3", !military::are_at_war(state, state.local_player_nation, target));
210
211 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
213
214
215 }
216};
217
218
220public:
221 dcon::text_key get_name(sys::state& state, dcon::nation_id target) noexcept override {
222 return state.lookup_key("decreaseopinion_button");
223 }
224
225 bool is_available(sys::state& state, dcon::nation_id target) noexcept override {
226 if(!state.world.nation_get_is_great_power(state.local_player_nation) || state.world.nation_get_is_great_power(target))
227 return false;
228
229 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
230 if(state.world.gp_relationship_get_influence(rel) < state.defines.decreaseopinion_influence_cost)
231 return false;
232
233 if((state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) != 0)
234 return false;
235
236 if(military::are_at_war(state, state.local_player_nation, target))
237 return false;
238
239 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
241 return false;
242
243 return true;
244 }
245
246
247 void button_action(sys::state& state, dcon::nation_id target, ui::element_base* parent) noexcept override {
249 }
250
251 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents, dcon::nation_id target) noexcept override {
252 text::add_line(state, contents, "decreaseopinion_desc");
254
255 text::add_line_with_condition(state, contents, "iaction_explain_5", state.world.nation_get_is_great_power(state.local_player_nation));
256
257 text::add_line_with_condition(state, contents, "iaction_explain_6", !state.world.nation_get_is_great_power(target));
258
259 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
260 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));
261
262 text::add_line_with_condition(state, contents, "iaction_explain_2", (state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) == 0);
263 text::add_line_with_condition(state, contents, "iaction_explain_3", !military::are_at_war(state, state.local_player_nation, target));
264
265 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
266 text::add_line_with_condition(state, contents, "dec_op_explain_3", clevel != nations::influence::level_hostile);
267 }
268};
269
270
272public:
273 dcon::text_key get_name(sys::state& state, dcon::nation_id target) noexcept override {
274 if(nations::are_allied(state, target, state.local_player_nation)) {
275 return state.lookup_key("cancelalliance_button");
276 } else {
277 return state.lookup_key("alliance_button");
278 }
279 }
280
281 bool is_available(sys::state& state, dcon::nation_id target) noexcept override {
282 if(nations::are_allied(state, target, state.local_player_nation)) {
283 return command::can_cancel_alliance(state, state.local_player_nation, target);
284 } else {
287 m.from = state.local_player_nation;
288 m.to = target;
289 return command::can_ask_for_alliance(state, state.local_player_nation, target) && (state.world.nation_get_is_player_controlled(target) || diplomatic_message::ai_will_accept(state, m));
290 }
291 }
292
293
294 void button_action(sys::state& state, dcon::nation_id target, ui::element_base* parent) noexcept override {
295 if(nations::are_allied(state, target, state.local_player_nation)) {
296 command::cancel_alliance(state, state.local_player_nation, target);
297 } else {
298 command::ask_for_alliance(state, state.local_player_nation, target);
299 }
300 }
301
302 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents, dcon::nation_id target) noexcept override {
303 if(nations::are_allied(state, target, state.local_player_nation)) {
304 text::add_line(state, contents, "cancelalliance_desc");
306
307 if(state.local_player_nation == target) {
308 text::add_line_with_condition(state, contents, "cancel_ally_explain_1", false);
309 }
310 if(state.defines.cancelalliance_diplomatic_cost > 0) {
311 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));
312 }
313
314 auto rel = state.world.get_diplomatic_relation_by_diplomatic_pair(target, state.local_player_nation);
315 text::add_line_with_condition(state, contents, "cancel_ally_explain_3", state.world.diplomatic_relation_get_are_allied(rel));
316 //text::add_line_with_condition(state, contents, "cancel_ally_explain_4", !military::are_allied_in_war(state, state.local_player_nation, content));
317
318 auto ol = state.world.nation_get_overlord_as_subject(state.local_player_nation);
319 text::add_line_with_condition(state, contents, "cancel_ally_explain_5", state.world.overlord_get_ruler(ol) != target);
320 } else {
321 auto asker = state.local_player_nation;
322
323 text::add_line(state, contents, "alliance_desc");
325
326 if(asker == target)
327 text::add_line_with_condition(state, contents, "ally_explain_1", false);
328
329 if(state.defines.alliance_diplomatic_cost > 0) {
330 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));
331 }
332 auto rel = state.world.get_diplomatic_relation_by_diplomatic_pair(target, state.local_player_nation);
333 text::add_line_with_condition(state, contents, "ally_explain_3", state.world.diplomatic_relation_get_are_allied(rel) == false);
334 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_state == sys::crisis_state::inactive);
335
336 if(state.defines.alice_allow_subjects_declare_wars == 0) {
337 auto ol = state.world.nation_get_overlord_as_subject(asker);
338 text::add_line_with_condition(state, contents, "ally_explain_5", !state.world.overlord_get_ruler(ol));
339 auto ol2 = state.world.nation_get_overlord_as_subject(target);
340 text::add_line_with_condition(state, contents, "ally_explain_8", !state.world.overlord_get_ruler(ol2));
341 }
342
343 text::add_line_with_condition(state, contents, "ally_explain_6", !military::are_at_war(state, asker, target));
344
345 if(!state.world.nation_get_is_player_controlled(target)) {
348 m.from = state.local_player_nation;
349 m.to = target;
350
352 ai::explain_ai_alliance_reasons(state, target, contents, 15);
353 }
354 }
355 }
356};
357
359 dcon::text_key get_name(sys::state& state, dcon::nation_id target) noexcept override {
360 return state.lookup_key("callally_button");
361 }
362
363 bool is_available(sys::state& state, dcon::nation_id target) noexcept override {
364 for(auto war_par : state.world.nation_get_war_participant(state.local_player_nation)) {
365 if(command::can_call_to_arms(state, state.local_player_nation, target, war_par.get_war())) {
366 if(!state.world.nation_get_is_player_controlled(target)) {
369 m.from = state.local_player_nation;
370 m.to = target;
371 m.data.war = war_par.get_war();
373 return true;
374 break;
375 }
376 } else {
377 return true;
378 break;
379 }
380 }
381 }
382
383 return false;
384 }
385
386
387 void button_action(sys::state& state, dcon::nation_id target, ui::element_base* parent) noexcept override {
388 auto asker = state.local_player_nation;
389
390 for(auto war_par : state.world.nation_get_war_participant(asker)) {
391 if(command::can_call_to_arms(state, state.local_player_nation, target, war_par.get_war())) {
392
393 if(!state.world.nation_get_is_player_controlled(target)) {
396 m.from = state.local_player_nation;
397 m.to = target;
398 m.data.war = war_par.get_war();
400 command::call_to_arms(state, asker, target, war_par.get_war());
401 }
402 } else {
403 command::call_to_arms(state, asker, target, war_par.get_war());
404 }
405 }
406 }
407 }
408
409 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents, dcon::nation_id target) noexcept override {
410 auto asker = state.local_player_nation;
411
412 text::add_line(state, contents, "remove_callally_desc");
414
415 if(state.defines.callally_diplomatic_cost > 0) {
416 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));
417 }
418 text::add_line_with_condition(state, contents, "call_ally_explain_1", nations::are_allied(state, asker, target));
419 text::add_line_with_condition(state, contents, "call_ally_explain_3", state.world.nation_get_is_at_war(asker));
420
421 bool possible_war = false;
422 bool that_ai_will_accept = false;
423
424 for(auto war_par : state.world.nation_get_war_participant(asker)) {
425 if(!military::is_civil_war(state, war_par.get_war())
426 && military::standard_war_joining_is_possible(state, war_par.get_war(), target, military::is_attacker(state, war_par.get_war(), asker))
427 && (!war_par.get_war().get_is_crisis_war() || state.military_definitions.great_wars_enabled)) {
428
429 possible_war = true;
430 if(!state.world.nation_get_is_player_controlled(target)) {
433 m.from = state.local_player_nation;
434 m.to = target;
435 m.data.war = war_par.get_war();
437 that_ai_will_accept = true;
438 }
439 }
440 }
441 }
442 text::add_line_with_condition(state, contents, "call_ally_explain_4", possible_war);
443 if(!state.world.nation_get_is_player_controlled(target)) {
444 text::add_line_with_condition(state, contents, "call_ally_explain_5", that_ai_will_accept);
445 }
446
447 }
448};
449
451public:
452 dcon::text_key get_name(sys::state& state, dcon::nation_id target) noexcept override {
453 auto urid = state.world.get_unilateral_relationship_by_unilateral_pair(target, state.local_player_nation);
454
455 if(state.world.unilateral_relationship_get_military_access(urid)) {
456 return state.lookup_key("cancelaskmilitaryaccess_button");
457 } else {
458 return state.lookup_key("askmilitaryaccess_button");
459 }
460 }
461
462 bool is_available(sys::state& state, dcon::nation_id target) noexcept override {
463 auto urid = state.world.get_unilateral_relationship_by_unilateral_pair(target, state.local_player_nation);
464
465 if(state.world.unilateral_relationship_get_military_access(urid)) {
466 return command::can_cancel_military_access(state, state.local_player_nation, target);
467 } else {
468 if(command::can_ask_for_access(state, state.local_player_nation, target)) {
469 if(!state.world.nation_get_is_player_controlled(target)) {
472 m.from = state.local_player_nation;
473 m.to = target;
475 return true;
476 } else {
477 return false;
478 }
479 } else {
480 return true;
481 }
482 } else {
483 return false;
484 }
485 }
486 }
487
488 void button_action(sys::state& state, dcon::nation_id target, ui::element_base* parent) noexcept override {
489 auto urid = state.world.get_unilateral_relationship_by_unilateral_pair(target, state.local_player_nation);
490
491 if(state.world.unilateral_relationship_get_military_access(urid)) {
492 command::cancel_military_access(state, state.local_player_nation, target);
493 } else {
494 command::ask_for_military_access(state, state.local_player_nation, target);
495 }
496 }
497
498 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents, dcon::nation_id target) noexcept override {
499 auto urid = state.world.get_unilateral_relationship_by_unilateral_pair(target, state.local_player_nation);
500
501 if(state.world.unilateral_relationship_get_military_access(urid)) {
502 text::add_line(state, contents, "cancelaskmilitaryaccess_desc");
504
505 if(state.defines.cancelaskmilaccess_diplomatic_cost > 0) {
506 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));
507 }
508 } else {
509 text::add_line(state, contents, "askmilitaryaccess_desc");
511
512 if(target == state.local_player_nation) {
513 text::add_line_with_condition(state, contents, "ask_access_explain_1", false);
514 }
515 if(state.defines.askmilaccess_diplomatic_cost > 0) {
516 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));
517 }
518 if(!state.world.nation_get_is_player_controlled(target)) {
521 m.from = state.local_player_nation;
522 m.to = target;
523 text::add_line_with_condition(state, contents, "ask_access_explain_3", diplomatic_message::ai_will_accept(state, m));
524
525 ai::explain_ai_access_reasons(state, target, contents, 15);
526 }
527 text::add_line_with_condition(state, contents, "ask_access_explain_4", !military::are_at_war(state, state.local_player_nation, target));
528 }
529
530 }
531};
532
534public:
535 dcon::text_key get_name(sys::state& state, dcon::nation_id target) noexcept override {
536 auto urid = state.world.get_unilateral_relationship_by_unilateral_pair(state.local_player_nation, target);
537
538 if(state.world.unilateral_relationship_get_military_access(urid)) {
539 return state.lookup_key("cancelgivemilitaryaccess_button");
540 } else {
541 return state.lookup_key("givemilitaryaccess_button");
542 }
543 }
544
545 bool is_available(sys::state& state, dcon::nation_id target) noexcept override {
546 auto urid = state.world.get_unilateral_relationship_by_unilateral_pair(state.local_player_nation, target);
547
548 if(state.world.unilateral_relationship_get_military_access(urid)) {
549 return command::can_cancel_given_military_access(state, state.local_player_nation, target);
550 } else {
551 return command::can_give_military_access(state, state.local_player_nation, target);
552 }
553 }
554
555 void button_action(sys::state& state, dcon::nation_id target, ui::element_base* parent) noexcept override {
556 auto urid = state.world.get_unilateral_relationship_by_unilateral_pair(state.local_player_nation, target);
557
558 if(state.world.unilateral_relationship_get_military_access(urid)) {
559 command::cancel_given_military_access(state, state.local_player_nation, target);
560 } else {
561 command::give_military_access(state, state.local_player_nation, target);
562 }
563 }
564
565 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents, dcon::nation_id target) noexcept override {
566 auto urid = state.world.get_unilateral_relationship_by_unilateral_pair(state.local_player_nation, target);
567
568 if(state.world.unilateral_relationship_get_military_access(urid)) {
569 text::add_line(state, contents, "cancelgivemilitaryaccess_desc");
571
572 if(state.defines.cancelgivemilaccess_diplomatic_cost > 0) {
573 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));
574 }
575 } else {
576 text::add_line(state, contents, "givemilitaryaccess_desc");
578
579 if(target == state.local_player_nation) {
580 text::add_line_with_condition(state, contents, "give_access_explain_1", false);
581 }
582 if(state.defines.givemilaccess_diplomatic_cost > 0) {
583 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));
584 }
585 text::add_line_with_condition(state, contents, "give_access_explain_3", !military::are_at_war(state, state.local_player_nation, target));
586 }
587 }
588};
589
591public:
592 dcon::text_key get_name(sys::state& state, dcon::nation_id target) noexcept override {
593 return state.lookup_key("increaserelation_button");
594 }
595
596 bool is_available(sys::state& state, dcon::nation_id target) noexcept override {
597 return command::can_increase_relations(state, state.local_player_nation, target);
598 }
599
600 void button_action(sys::state& state, dcon::nation_id target, ui::element_base* parent) noexcept override {
601 command::increase_relations(state, state.local_player_nation, target);
602 }
603
604 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents, dcon::nation_id target) noexcept override {
605 text::add_line(state, contents, "increase_rel_explain_1", text::variable_type::x, int64_t(state.defines.increaserelation_relation_on_accept));
607
608 if(target == state.local_player_nation) {
609 text::add_line_with_condition(state, contents, "increase_rel_explain_2", false);
610 }
611
612 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));
613
614 auto rel = state.world.get_diplomatic_relation_by_diplomatic_pair(state.local_player_nation, target);
615 text::add_line_with_condition(state, contents, "increase_rel_explain_4", state.world.diplomatic_relation_get_value(rel) < 200.0f);
616
617 text::add_line_with_condition(state, contents, "increase_rel_explain_5", !military::are_at_war(state, state.local_player_nation, target));
618 }
619};
620
622public:
623 dcon::text_key get_name(sys::state& state, dcon::nation_id target) noexcept override {
624 return state.lookup_key("decreaserelation_button");
625 }
626
627 bool is_available(sys::state& state, dcon::nation_id target) noexcept override {
628 return command::can_increase_relations(state, state.local_player_nation, target);
629 }
630
631 void button_action(sys::state& state, dcon::nation_id target, ui::element_base* parent) noexcept override {
632 command::decrease_relations(state, state.local_player_nation, target);
633 }
634
635 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents, dcon::nation_id target) noexcept override {
636 text::add_line(state, contents, "decrease_rel_explain_1", text::variable_type::x, int64_t(state.defines.decreaserelation_relation_on_accept));
638
639 if(target == state.local_player_nation) {
640 text::add_line_with_condition(state, contents, "decrease_rel_explain_2", false);
641 }
642
643 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));
644
645 auto rel = state.world.get_diplomatic_relation_by_diplomatic_pair(state.local_player_nation, target);
646 text::add_line_with_condition(state, contents, "decrease_rel_explain_4", state.world.diplomatic_relation_get_value(rel) > -200.0f);
647
648 text::add_line_with_condition(state, contents, "decrease_rel_explain_5", !military::are_at_war(state, state.local_player_nation, target));
649
650 }
651};
652
654public:
655 dcon::text_key get_name(sys::state& state, dcon::nation_id target) noexcept override {
656 auto rel = state.world.get_unilateral_relationship_by_unilateral_pair(target, state.local_player_nation);
657 bool subsidies = state.world.unilateral_relationship_get_war_subsidies(rel);
658
659 if(subsidies) {
660 return state.lookup_key("cancel_warsubsidies_button");
661 } else {
662 return state.lookup_key("warsubsidies_button");
663 }
664 }
665
666 bool is_available(sys::state& state, dcon::nation_id target) noexcept override {
667 auto rel = state.world.get_unilateral_relationship_by_unilateral_pair(target, state.local_player_nation);
668 bool subsidies = state.world.unilateral_relationship_get_war_subsidies(rel);
669
670 if(subsidies) {
671 return command::can_cancel_war_subsidies(state, state.local_player_nation, target);
672 } else {
673 return command::can_give_war_subsidies(state, state.local_player_nation, target);
674 }
675 }
676
677 void button_action(sys::state& state, dcon::nation_id target, ui::element_base* parent) noexcept override {
678 auto rel = state.world.get_unilateral_relationship_by_unilateral_pair(target, state.local_player_nation);
679 bool subsidies = state.world.unilateral_relationship_get_war_subsidies(rel);
680 if(subsidies) {
681 command::cancel_war_subsidies(state, state.local_player_nation, target);
682 } else {
683 command::give_war_subsidies(state, state.local_player_nation, target);
684 }
685 }
686
687 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents, dcon::nation_id target) noexcept override {
688 auto rel = state.world.get_unilateral_relationship_by_unilateral_pair(target, state.local_player_nation);
689 bool subsidies = state.world.unilateral_relationship_get_war_subsidies(rel);
690
691 auto lpn_fat = dcon::fatten(state.world, state.local_player_nation);
692 auto target_fat = dcon::fatten(state.world, target);
693 auto subsize = economy::estimate_war_subsidies(state, target_fat, lpn_fat);
694
695 if(subsidies) {
696 text::add_line(state, contents, "cancel_w_sub_explain_1", text::variable_type::x, text::fp_currency{ subsize });
697 if(state.defines.cancelwarsubsidy_diplomatic_cost > 0) {
699 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));
700 }
701 } else {
702 text::add_line(state, contents, "warsubsidies_desc", text::variable_type::money, text::fp_one_place{ subsize });
704
705 if(state.local_player_nation == target) {
706 text::add_line_with_condition(state, contents, "w_sub_explain_1", false);
707 }
708 if(state.defines.warsubsidy_diplomatic_cost > 0) {
709 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));
710 }
711 text::add_line_with_condition(state, contents, "w_sub_explain_3", !military::are_at_war(state, state.local_player_nation, target));
712 // text::add_line_with_condition(state, contents, "w_sub_explain_4", state.world.nation_get_is_at_war(target));
713 }
714 }
715};
716
718public:
719 dcon::text_key get_name(sys::state& state, dcon::nation_id target) noexcept override {
720 if(military::are_at_war(state, state.local_player_nation, target)) {
721 return state.lookup_key("peace_button");
722 } else {
723 return state.lookup_key("war_button");
724 }
725 }
726
727 bool is_available(sys::state& state, dcon::nation_id target) noexcept override {
728 if(military::are_at_war(state, state.local_player_nation, target)) {
729 return command::can_start_peace_offer(state, state.local_player_nation, target,
730 military::find_war_between(state, state.local_player_nation, target), true);
731 } else {
732 return !(state.local_player_nation == target || !military::can_use_cb_against(state, state.local_player_nation, target) || 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, target));
733 }
734 }
735
736 void button_action(sys::state& state, dcon::nation_id target, ui::element_base* parent) noexcept override {
737 if(parent) {
738 dcon::nation_id content = retrieve<dcon::nation_id>(state, parent);
740 parent->impl_get(state, ac_payload);
741 }
742 }
743
744 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents, dcon::nation_id target) noexcept override {
745 auto source = state.local_player_nation;
746
747 if(military::are_at_war(state, state.local_player_nation, target)) {
748 text::add_line(state, contents, "peace_description");
750 {
751 auto ol = state.world.nation_get_overlord_as_subject(source);
752 text::add_line_with_condition(state, contents, "peace_explain_1", !state.world.overlord_get_ruler(ol));
753 }
754
755 {
756 auto ol = state.world.nation_get_overlord_as_subject(target);
757 text::add_line_with_condition(state, contents, "peace_explain_2", !state.world.overlord_get_ruler(ol));
758 }
759
760 auto war = military::find_war_between(state, source, target);
761
762 if(state.world.war_get_is_crisis_war(war)) {
763 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);
764 text::add_line_with_condition(state, contents, "peace_explain_4", both_wl);
765 } else {
766 bool one_is_wl = [&]() {
767 if(state.world.war_get_primary_attacker(war) == source) {
769 return true;
770 } else if(state.world.war_get_primary_defender(war) == source) {
772 return true;
773 } else if(state.world.war_get_primary_attacker(war) == target) {
775 return true;
776 } else if(state.world.war_get_primary_defender(war) == target) {
778 return true;
779 }
780 return false;
781 }();
782 text::add_line_with_condition(state, contents, "peace_explain_3", one_is_wl);
783 }
784 text::add_line_with_condition(state, contents, "peace_explain_5", !(state.world.nation_get_peace_offer_from_pending_peace_offer(source)));
785
786 } else {
787 text::add_line(state, contents, "act_wardesc");
789
790 if(source == target) {
791 text::add_line_with_condition(state, contents, "war_explain_1", false);
792 }
793 if(state.defines.declarewar_diplomatic_cost > 0) {
794 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));
795 }
796 text::add_line_with_condition(state, contents, "war_explain_2", military::can_use_cb_against(state, state.local_player_nation, target));
797 text::add_line_with_condition(state, contents, "war_explain_4", !military::are_in_common_war(state, state.local_player_nation, target));
798 }
799
800 }
801};
802
804public:
805 dcon::text_key get_name(sys::state& state, dcon::nation_id target) noexcept override {
806 return state.lookup_key("alice_diplo_release_subject");
807 }
808
809 bool is_available(sys::state& state, dcon::nation_id target) noexcept override {
810 return command::can_release_subject(state, state.local_player_nation, target);
811 }
812
813 void button_action(sys::state& state, dcon::nation_id target, ui::element_base* parent) noexcept override {
814 command::release_subject(state, state.local_player_nation, target);
815 }
816
817 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents, dcon::nation_id target) noexcept override {
818 text::add_line(state, contents, "alice_diplo_release_subject_desc");
819 text::add_line_with_condition(state, contents, "alice_diplo_release_subject_0", state.world.overlord_get_ruler(state.world.nation_get_overlord_as_subject(target)) == state.local_player_nation);
820 }
821};
822
824public:
825 dcon::text_key get_name(sys::state& state, dcon::nation_id target) noexcept override {
826 return state.lookup_key("increaseopinion_button");
827 }
828
829 bool is_available(sys::state& state, dcon::nation_id target) noexcept override {
830 return command::can_increase_opinion(state, state.local_player_nation, target);
831 }
832
833 void button_action(sys::state& state, dcon::nation_id target, ui::element_base* parent) noexcept override {
834 command::increase_opinion(state, state.local_player_nation, target);
835 }
836
837 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents, dcon::nation_id target) noexcept override {
838 auto source = state.local_player_nation;
839
840 text::add_line(state, contents, "increaseopinion_desc");
842
843 text::add_line_with_condition(state, contents, "iaction_explain_5", state.world.nation_get_is_great_power(source));
844
845 text::add_line_with_condition(state, contents, "iaction_explain_6", !state.world.nation_get_is_great_power(target));
846
847 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, source);
848 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));
849
850 text::add_line_with_condition(state, contents, "iaction_explain_2", (state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) == 0);
851 text::add_line_with_condition(state, contents, "iaction_explain_3", !military::are_at_war(state, source, target));
852
853 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
855
856 }
857};
858
860public:
861 dcon::text_key get_name(sys::state& state, dcon::nation_id target) noexcept override {
862 return state.lookup_key("addtosphere_button");
863 }
864
865 bool is_available(sys::state& state, dcon::nation_id target) noexcept override {
866 return command::can_add_to_sphere(state, state.local_player_nation, target);
867 }
868
869 void button_action(sys::state& state, dcon::nation_id target, ui::element_base* parent) noexcept override {
870 command::add_to_sphere(state, state.local_player_nation, target);
871 }
872
873 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents, dcon::nation_id target) noexcept override {
874 auto source = state.local_player_nation;
875
876 text::add_line(state, contents, "addtosphere_desc");
878
879 text::add_line_with_condition(state, contents, "iaction_explain_5", state.world.nation_get_is_great_power(source));
880
881 text::add_line_with_condition(state, contents, "iaction_explain_6", !state.world.nation_get_is_great_power(target));
882
883 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, source);
884 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));
885
886 text::add_line_with_condition(state, contents, "iaction_explain_2", (state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) == 0);
887 text::add_line_with_condition(state, contents, "iaction_explain_3", !military::are_at_war(state, source, target));
888
889 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
890 text::add_line_with_condition(state, contents, "add_sphere_explain_1", clevel == nations::influence::level_friendly);
891
892 text::add_line_with_condition(state, contents, "add_sphere_explain_2", !state.world.nation_get_in_sphere_of(target));
893
894 }
895};
896
898public:
899 dcon::text_key get_name(sys::state& state, dcon::nation_id target) noexcept override {
900 return state.lookup_key("removefromsphere_button");
901 }
902
903 bool is_available(sys::state& state, dcon::nation_id target) noexcept override {
904 return command::can_remove_from_sphere(state, state.local_player_nation, target, state.world.nation_get_in_sphere_of(target));
905 }
906
907 void button_action(sys::state& state, dcon::nation_id target, ui::element_base* parent) noexcept override {
908 command::remove_from_sphere(state, state.local_player_nation, target, state.world.nation_get_in_sphere_of(target));
909 }
910
911 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents, dcon::nation_id target) noexcept override {
912 auto source = state.local_player_nation;
913 bool in_players_sphere = state.world.nation_get_in_sphere_of(target) == source;
914
915 text::add_line(state, contents, "removefromsphere_desc");
916 if(in_players_sphere) {
917 if(state.defines.removefromsphere_infamy_cost != 0) {
918 text::add_line(state, contents, "rem_sphere_explain_4", text::variable_type::x, text::fp_one_place{ state.defines.removefromsphere_infamy_cost });
919 }
920 if(state.defines.removefromsphere_prestige_cost != 0) {
921 text::add_line(state, contents, "rem_sphere_explain_5", text::variable_type::x, text::fp_one_place{ state.defines.removefromsphere_prestige_cost });
922 }
923 }
925
926 text::add_line_with_condition(state, contents, "iaction_explain_5", state.world.nation_get_is_great_power(state.local_player_nation));
927
928 text::add_line_with_condition(state, contents, "iaction_explain_6", !state.world.nation_get_is_great_power(target));
929
930 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
931 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));
932
933 text::add_line_with_condition(state, contents, "iaction_explain_2", (state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) == 0);
934 text::add_line_with_condition(state, contents, "iaction_explain_3", !military::are_at_war(state, state.local_player_nation, target));
935
936 text::add_line_with_condition(state, contents, "rem_sphere_explain_1", bool(state.world.nation_get_in_sphere_of(target)));
937
938 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
939 if(!in_players_sphere) {
940 text::add_line_with_condition(state, contents, "rem_sphere_explain_2", clevel == nations::influence::level_friendly);
941 } else {
942 text::add_line_with_condition(state, contents, "rem_sphere_explain_3", true);
943 }
944
945 }
946};
947
949 bool has_any_justifiable_cb(sys::state& state, dcon::nation_id source, dcon::nation_id target) noexcept {
950 auto res = false;
951 state.world.for_each_cb_type([&](dcon::cb_type_id cb) {
952 if(command::can_fabricate_cb(state, source, target, cb))
953 res = true;
954 });
955
956 return res;
957 }
958public:
959 dcon::text_key get_name(sys::state& state, dcon::nation_id target) noexcept override {
960 return state.lookup_key("make_cb_button");
961 }
962
963 bool is_available(sys::state& state, dcon::nation_id target) noexcept override {
964 auto source = state.local_player_nation;
965
966 auto can_subjects_declare = state.defines.alice_allow_subjects_declare_wars;
967
968 if(source == target)
969 return false;
970 if(state.world.nation_get_constructing_cb_type(source))
971 return false;
972 auto ol = state.world.nation_get_overlord_as_subject(source);
973 if(state.defines.alice_allow_subjects_declare_wars < 1 && state.world.overlord_get_ruler(ol) && state.world.overlord_get_ruler(ol) != target)
974 return false;
975 if(state.world.nation_get_in_sphere_of(target) == source)
976 return false;
977 if(state.world.nation_get_diplomatic_points(source) < state.defines.make_cb_diplomatic_cost)
978 return false;
979 if(military::are_at_war(state, target, source))
980 return false;
981 if(!has_any_justifiable_cb(state, source, target))
982 return false;
983
984 return true;
985 }
986
987 void button_action(sys::state& state, dcon::nation_id target, ui::element_base* parent) noexcept override {
988 if(parent) {
990 parent->impl_get(state, payload);
991 }
992 }
993
994 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents, dcon::nation_id target) noexcept override {
995 auto source = state.local_player_nation;
996 text::add_line(state, contents, "make_cb_desc");
998 if(source == target) {
999 text::add_line_with_condition(state, contents, "fab_explain_1", false);
1000 }
1001 if(state.defines.make_cb_diplomatic_cost > 0) {
1002 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));
1003 }
1004 text::add_line_with_condition(state, contents, "fab_explain_3", !state.world.nation_get_constructing_cb_type(source));
1005 if(state.defines.alice_allow_subjects_declare_wars < 1) {
1006 auto ol = state.world.nation_get_overlord_as_subject(source);
1007 text::add_line_with_condition(state, contents, "fab_explain_4", !state.world.overlord_get_ruler(ol) || state.world.overlord_get_ruler(ol) == target);
1008 }
1009 text::add_line_with_condition(state, contents, "fab_explain_5", state.world.nation_get_in_sphere_of(target) != source);
1010 text::add_line_with_condition(state, contents, "fab_explain_6", !military::are_at_war(state, target, source));
1011 text::add_line_with_condition(state, contents, "fab_explain_7", has_any_justifiable_cb(state, source, target));
1012 text::add_line_with_condition(state, contents, "fab_explain_8", !military::has_truce_with(state, target, source));
1013 }
1014};
1015
1016class diplomacy_action_dialog_title_text : public generic_settable_element<simple_text_element_base, diplomacy_action> {
1017 static std::string_view get_title_key(diplomacy_action v) noexcept {
1018 switch(v) {
1020 return "alliancetitle";
1022 return "cancelalliancetitle";
1024 return "callallytitle";
1026 return "wartitle";
1028 return "askmilitaryaccesstitle";
1030 return "cancelaskmilitaryaccesstitle";
1032 return "givemilitaryaccesstitle";
1034 return "cancelgivemilitaryaccesstitle";
1036 return "increaserelationtitle";
1038 return "decreaserelationtitle";
1040 return "warsubsidiestitle";
1042 return "cancel_warsubsidiestitle";
1044 return "increaseopiniontitle";
1046 return "addtospheretitle";
1048 return "removefromspheretitle";
1050 return "make_cbtitle";
1052 return "give_unit_commandtitle";
1054 return "cancel_unit_commandtitle";
1056 return "make_peacetitle";
1057 default:
1058 return "";
1059 }
1060 }
1061
1062public:
1063 void on_update(sys::state& state) noexcept override {
1065 }
1066};
1067class diplomacy_action_dialog_description_text : public generic_settable_element<multiline_text_element_base, diplomacy_action> {
1068 static std::string_view get_title_key(diplomacy_action v) noexcept {
1069 switch(v) {
1071 return "alliancenewdesc";
1073 return "breakalliancenewdesc";
1075 return "callally_desc";
1077 return "war_desc";
1079 return "askmilitaryaccess_desc";
1081 return "cancelaskmilitaryaccess_desc";
1083 return "givemilitaryaccess_desc";
1085 return "cancelgivemilitaryaccess_desc";
1087 return "increaserelation_desc";
1089 return "decreaserelation_desc";
1091 return "warsubsidies_desc";
1093 return "cancel_warsubsidies_desc";
1095 return "increaseopinion_desc";
1097 return "addtosphere_desc";
1099 return "removefromsphere_desc";
1101 return "make_cb_desc";
1103 return "give_unit_command_desc";
1105 return "cancel_unit_command_desc";
1107 return "make_peace_desc";
1108 default:
1109 return "";
1110 }
1111 }
1112
1113public:
1114 void on_update(sys::state& state) noexcept override {
1116 text::layout_parameters{ 0, 0, static_cast<int16_t>(base_data.size.x), static_cast<int16_t>(base_data.size.y),
1118 auto box = text::open_layout_box(contents);
1119 text::localised_format_box(state, contents, box, get_title_key(content));
1120 text::close_layout_box(contents, box);
1121 }
1122};
1123
1124class diplomacy_action_dialog_agree_button : public generic_settable_element<button_element_base, diplomacy_action> {
1125 bool get_can_perform(sys::state& state) noexcept {
1126 auto target = retrieve<dcon::nation_id>(state, parent);
1127 switch(content) {
1129 return true;
1131 return command::can_ask_for_alliance(state, state.local_player_nation, target);
1133 return command::can_cancel_alliance(state, state.local_player_nation, target);
1135 {
1136 for(auto wp : dcon::fatten(state.world, state.local_player_nation).get_war_participant())
1137 if(command::can_call_to_arms(state, state.local_player_nation, target, dcon::fatten(state.world, wp).get_war().id))
1138 return true;
1139 return false;
1140 }
1142 return false;
1144 return command::can_ask_for_access(state, state.local_player_nation, target);
1146 return command::can_cancel_military_access(state, state.local_player_nation, target);
1148 return false;
1150 return command::can_cancel_given_military_access(state, state.local_player_nation, target);
1152 return command::can_increase_relations(state, state.local_player_nation, target);
1154 return command::can_decrease_relations(state, state.local_player_nation, target);
1156 return command::can_give_war_subsidies(state, state.local_player_nation, target);
1158 return command::can_cancel_war_subsidies(state, state.local_player_nation, target);
1160 return command::can_increase_opinion(state, state.local_player_nation, target);
1162 return command::can_add_to_sphere(state, state.local_player_nation, target);
1164 return command::can_remove_from_sphere(state, state.local_player_nation, target, state.world.nation_get_in_sphere_of(target));
1166 return false;
1168 return false;
1170 return false;
1172 return false;
1174 return false;
1176 return false;
1178 return false;
1180 return false;
1181 }
1182 return false;
1183 }
1184
1185public:
1186 void on_create(sys::state& state) noexcept override {
1187 base_data.data.button.txt = state.lookup_key("agree");
1189 }
1190
1191 void on_update(sys::state& state) noexcept override {
1192 disabled = !get_can_perform(state);
1193 }
1194
1195 void button_action(sys::state& state) noexcept override {
1196 auto target = retrieve<dcon::nation_id>(state, parent);
1197 switch(content) {
1199 break;
1201 command::ask_for_alliance(state, state.local_player_nation, target);
1202 break;
1204 command::cancel_alliance(state, state.local_player_nation, target);
1205 break;
1207 for(auto wp : dcon::fatten(state.world, state.local_player_nation).get_war_participant())
1208 command::call_to_arms(state, state.local_player_nation, target, dcon::fatten(state.world, wp).get_war().id);
1209 break;
1211 break;
1213 command::ask_for_military_access(state, state.local_player_nation, target);
1214 break;
1216 command::cancel_military_access(state, state.local_player_nation, target);
1217 break;
1219 break;
1221 command::cancel_given_military_access(state, state.local_player_nation, target);
1222 break;
1224 command::increase_relations(state, state.local_player_nation, target);
1225 break;
1227 command::decrease_relations(state, state.local_player_nation, target);
1228 break;
1230 command::give_war_subsidies(state, state.local_player_nation, target);
1231 break;
1233 command::cancel_war_subsidies(state, state.local_player_nation, target);
1234 break;
1236 command::increase_opinion(state, state.local_player_nation, target);
1237 break;
1239 command::add_to_sphere(state, state.local_player_nation, target);
1240 break;
1242 command::remove_from_sphere(state, state.local_player_nation, target, state.world.nation_get_in_sphere_of(target));
1243 break;
1245 break;
1247 break;
1249 break;
1251 break;
1253 break;
1255 break;
1257 break;
1259 break;
1260 }
1261 if(parent) {
1262 parent->set_visible(state, false);
1263 }
1264 }
1265};
1267public:
1268 void on_create(sys::state& state) noexcept override {
1269 base_data.data.button.txt = state.lookup_key("decline");
1271 }
1272};
1273
1275public:
1276 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1277 if(name == "title") {
1278 return make_element_by_type<diplomacy_action_dialog_title_text>(state, id);
1279 } else if(name == "description") {
1280 return make_element_by_type<diplomacy_action_dialog_description_text>(state, id);
1281 } else if(name == "chance_string") {
1282 return make_element_by_type<simple_text_element_base>(state, id);
1283 } else if(name == "agreebutton") {
1284 return make_element_by_type<diplomacy_action_dialog_agree_button>(state, id);
1285 } else if(name == "declinebutton") {
1286 return make_element_by_type<diplomacy_action_dialog_decline_button>(state, id);
1287 } else if(name == "leftshield") {
1288 return make_element_by_type<nation_player_flag>(state, id);
1289 } else if(name == "rightshield") {
1290 return make_element_by_type<flag_button>(state, id);
1291 } else if(name == "background") {
1292 auto ptr = make_element_by_type<draggable_target>(state, id);
1293 ptr->base_data.size = base_data.size;
1294 return ptr;
1295 } else {
1296 return nullptr;
1297 }
1298 }
1299};
1300
1301
1303 int32_t value = 0;
1304};
1305
1307 int32_t value = 0;
1308};
1309
1311 int32_t value = 0;
1312};
1313
1315public:
1316 dcon::national_identity_id get_current_nation(sys::state& state) noexcept override {
1317 auto n = nations::get_nth_great_power(state, uint16_t(retrieve<gp_choice_num>(state, parent).value));
1318 return state.world.nation_get_identity_from_identity_holder(n);
1319 }
1320 void button_action(sys::state& state) noexcept override {
1321 auto this_selection = retrieve<gp_choice_num>(state, parent);
1322 send(state, parent, gp_choice_select{ this_selection.value });
1323 }
1324};
1325
1327public:
1328 void on_update(sys::state& state) noexcept override {
1329 auto n = nations::get_nth_great_power(state, uint16_t(retrieve<gp_choice_num>(state, parent).value));
1331 }
1332};
1333
1335public:
1336 bool show = false;
1337 void on_update(sys::state& state) noexcept override {
1338 show = retrieve<gp_choice_num>(state, parent).value == retrieve<gp_choice_get_selection>(state, parent).value;
1339 }
1340 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
1341 if(show) {
1343 }
1344 }
1345};
1346
1348public:
1349 bool show = false;
1350 void on_update(sys::state& state) noexcept override {
1351 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_choice_num>(state, parent).value));
1352 auto target = retrieve<dcon::nation_id>(state, parent);
1353 show = (state.world.gp_relationship_get_status(state.world.get_gp_relationship_by_gp_influence_pair(target, gp)) & nations::influence::is_banned) != 0;
1354 }
1357 }
1358
1359 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1360 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_choice_num>(state, parent).value));
1361 auto target = retrieve<dcon::nation_id>(state, parent);
1362 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, gp);
1363
1364 text::add_line(state, contents, "dp_inf_tooltip_ban", text::variable_type::x, state.world.gp_relationship_get_penalty_expires_date(rel));
1365 }
1366 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
1367 if(show)
1369 }
1370};
1371
1373public:
1374 bool show = false;
1375 void on_update(sys::state& state) noexcept override {
1376 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_choice_num>(state, parent).value));
1377 auto target = retrieve<dcon::nation_id>(state, parent);
1378 show = (state.world.gp_relationship_get_status(state.world.get_gp_relationship_by_gp_influence_pair(target, gp)) & nations::influence::is_discredited) != 0;
1379 }
1382 }
1383
1384 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1385 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_choice_num>(state, parent).value));
1386 auto target = retrieve<dcon::nation_id>(state, parent);
1387 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, gp);
1388
1389 text::add_line(state, contents, "dp_inf_tooltip_discredit", text::variable_type::x, state.world.gp_relationship_get_penalty_expires_date(rel));
1390 }
1391 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
1392 if(show)
1394 }
1395};
1396
1398public:
1399 void on_update(sys::state& state) noexcept override {
1400 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_choice_num>(state, parent).value));
1401 auto target = retrieve<dcon::nation_id>(state, parent);
1402
1403 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))));
1404 }
1405};
1407public:
1408 void on_update(sys::state& state) noexcept override {
1409 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_choice_num>(state, parent).value));
1410 auto target = retrieve<dcon::nation_id>(state, parent);
1411
1412 set_text(state, text::format_float(state.world.gp_relationship_get_influence(state.world.get_gp_relationship_by_gp_influence_pair(target, gp)), 1));
1413 }
1414};
1415
1417public:
1419
1420 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1421 if(name == "country_name") {
1422 return make_element_by_type<select_gp_name>(state, id);
1423 } else if(name == "country_flag") {
1424 return make_element_by_type<select_gp_choice_button>(state, id);
1425 } else if(name == "country_selected") {
1426 return make_element_by_type<select_gp_selection_icon>(state, id);
1427 } else if(name == "country_discredited") {
1428 return make_element_by_type<select_gp_discredited>(state, id);
1429 } else if(name == "country_banned_embassy") {
1430 return make_element_by_type<select_gp_banned>(state, id);
1431 } else if(name == "country_opinion") {
1432 return make_element_by_type<select_gp_opinion_detail>(state, id);
1433 } else if(name == "country_influence") {
1434 return make_element_by_type<select_gp_influence_detail>(state, id);
1435 } else {
1436 return nullptr;
1437 }
1438 }
1439
1440 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
1441 if(payload.holds_type<gp_choice_num>()) {
1442 payload.emplace<gp_choice_num>(gp_choice_num{ rank });
1444 }
1445 return window_element_base::get(state, payload);
1446 }
1447};
1448
1449
1450class gp_action_choice_title : public generic_settable_element<simple_text_element_base, diplomacy_action> {
1451public:
1452 void on_update(sys::state& state) noexcept override {
1453 switch(retrieve<gp_choice_actions>(state, parent)) {
1455 set_text(state, text::produce_simple_string(state, "discredittitle"));
1456 break;
1458 set_text(state, text::produce_simple_string(state, "expeladvisorstitle"));
1459 break;
1461 set_text(state, text::produce_simple_string(state, "banembassytitle"));
1462 break;
1464 set_text(state, text::produce_simple_string(state, "decreaseopiniontitle"));
1465 break;
1466 default:
1467 break;
1468 }
1469
1470 }
1471};
1472
1473class gp_action_choice_desc : public generic_settable_element<simple_text_element_base, diplomacy_action> {
1474public:
1475 void on_update(sys::state& state) noexcept override {
1477 switch(retrieve<gp_choice_actions>(state, parent)) {
1479 text::add_to_substitution_map(m, text::variable_type::days, int64_t(state.defines.discredit_days));
1480 set_text(state, text::resolve_string_substitution(state, "discredit_desc", m));
1481 break;
1483 set_text(state, text::produce_simple_string(state, "expeladvisors_desc"));
1484 break;
1486 text::add_to_substitution_map(m, text::variable_type::days, int64_t(state.defines.banembassy_days));
1487 set_text(state, text::resolve_string_substitution(state, "banembassy_desc", m));
1488 break;
1490 set_text(state, text::produce_simple_string(state, "decreaseopinion_desc"));
1491 break;
1492 default:
1493 break;
1494 }
1495
1496 }
1497};
1498
1500public:
1501 void on_create(sys::state& state) noexcept override {
1502 base_data.data.button.txt = state.lookup_key("cancel");
1504 }
1505};
1506
1508public:
1509 void on_create(sys::state& state) noexcept override {
1510 base_data.data.button.txt = state.lookup_key("ok");
1512 }
1513
1514 void on_update(sys::state& state) noexcept override {
1515 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_choice_get_selection>(state, parent).value));
1516 auto target = retrieve<dcon::nation_id>(state, parent);
1517
1518 switch(retrieve<gp_choice_actions>(state, parent)) {
1520 disabled = !command::can_discredit_advisors(state, state.local_player_nation, target, gp);
1521 break;
1523 disabled = !command::can_expel_advisors(state, state.local_player_nation, target, gp);
1524 break;
1526 disabled = !command::can_ban_embassy(state, state.local_player_nation, target, gp);
1527 break;
1529 disabled = !command::can_decrease_opinion(state, state.local_player_nation, target, gp);
1530 break;
1531 }
1532 }
1533 void button_action(sys::state& state) noexcept override {
1534 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_choice_get_selection>(state, parent).value));
1535 auto target = retrieve<dcon::nation_id>(state, parent);
1536
1537 switch(retrieve<gp_choice_actions>(state, parent)) {
1539 command::discredit_advisors(state, state.local_player_nation, target, gp);
1540 break;
1542 command::expel_advisors(state, state.local_player_nation, target, gp);
1543 break;
1545 command::ban_embassy(state, state.local_player_nation, target, gp);
1546 break;
1548 command::decrease_opinion(state, state.local_player_nation, target, gp);
1549 break;
1550 }
1551 parent->set_visible(state, false);
1552 }
1555 }
1556 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1557 auto gp = nations::get_nth_great_power(state, uint16_t(retrieve<gp_choice_get_selection>(state, parent).value));
1558 auto target = retrieve<dcon::nation_id>(state, parent);
1559
1560 switch(retrieve<gp_choice_actions>(state, parent)) {
1562 {
1563 if(state.local_player_nation == gp) {
1564 text::add_line_with_condition(state, contents, "discredit_explain_1", false);
1565 }
1566
1567 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
1568
1569 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));
1570
1571 text::add_line_with_condition(state, contents, "iaction_explain_2", (state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) == 0);
1572 text::add_line_with_condition(state, contents, "iaction_explain_3", !military::are_at_war(state, state.local_player_nation, target));
1573
1574 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
1575 text::add_line_with_condition(state, contents, "discredit_explain_2", clevel != nations::influence::level_hostile);
1576
1577
1578 auto orel = state.world.get_gp_relationship_by_gp_influence_pair(target, gp);
1579 text::add_line_with_condition(state, contents, "discredit_explain_3", (state.world.gp_relationship_get_status(orel) & nations::influence::is_banned) == 0);
1580
1582 }
1583 break;
1585 {
1586 if(state.local_player_nation == gp) {
1587 text::add_line_with_condition(state, contents, "expel_explain_1", false);
1588 }
1589
1590 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
1591
1592 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));
1593
1594 text::add_line_with_condition(state, contents, "iaction_explain_2", (state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) == 0);
1595
1596 text::add_line_with_condition(state, contents, "iaction_explain_3", !military::are_at_war(state, state.local_player_nation, target));
1597
1598 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
1599
1601
1603 }
1604 break;
1606 {
1607 if(state.local_player_nation == gp) {
1608 text::add_line_with_condition(state, contents, "ban_explain_1", false);
1609 }
1610
1611 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
1612
1613 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));
1614
1615 text::add_line_with_condition(state, contents, "iaction_explain_2", (state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) == 0);
1616
1617 text::add_line_with_condition(state, contents, "iaction_explain_3", !military::are_at_war(state, state.local_player_nation, target));
1618
1619 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
1621
1623 }
1624 break;
1626 {
1627 if(state.local_player_nation == gp) {
1628 text::add_line_with_condition(state, contents, "dec_op_explain_1", false);
1629 }
1630
1631 if(state.world.nation_get_in_sphere_of(target) == gp) {
1632 text::add_line_with_condition(state, contents, "dec_op_explain_2", false);
1633 }
1634
1635 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(target, state.local_player_nation);
1636
1637 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));
1638
1639 text::add_line_with_condition(state, contents, "iaction_explain_2", (state.world.gp_relationship_get_status(rel) & nations::influence::is_banned) == 0);
1640
1641 text::add_line_with_condition(state, contents, "iaction_explain_3", !military::are_at_war(state, state.local_player_nation, target));
1642
1643 auto clevel = (nations::influence::level_mask & state.world.gp_relationship_get_status(rel));
1644 text::add_line_with_condition(state, contents, "dec_op_explain_3", clevel != nations::influence::level_hostile);
1645
1646
1648 state.world.gp_relationship_get_status(state.world.get_gp_relationship_by_gp_influence_pair(target,
1650 text::add_line_with_condition(state, contents, "dec_op_explain_4", false);
1651 }
1652
1654
1655 }
1656 break;
1657 default:
1658 break;
1659 }
1660 }
1661};
1662
1664public:
1665 int32_t selected_gp = 0;
1666 dcon::nation_id action_target{ 0 };
1668
1669 void on_create(sys::state& state) noexcept override {
1671
1672 xy_pair gp_base_select_offset =
1673 state.ui_defs.gui[state.ui_state.defs_by_name.find(state.lookup_key("gpselectoptionpos"))->second.definition].position;
1674 xy_pair gp_select_offset = gp_base_select_offset;
1675 for(uint8_t i = 0; i < uint8_t(state.defines.great_nations_count); i++) {
1676 auto ptr = make_element_by_type<diplomacy_action_gp_dialog_select_window>(state,
1677 state.ui_state.defs_by_name.find(state.lookup_key("gpselectoption"))->second.definition);
1678 ptr->base_data.position = gp_select_offset;
1679 ptr->rank = i;
1680 // Arrange in columns of 2 elements each...
1681 gp_select_offset.y += ptr->base_data.size.y;
1682 if(i != 0 && i % 2 == 1) {
1683 gp_select_offset.x += ptr->base_data.size.x;
1684 gp_select_offset.y = gp_base_select_offset.y;
1685 }
1686 add_child_to_front(std::move(ptr));
1687 }
1688 }
1689
1690 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1691 if(name == "title") {
1692 return make_element_by_type<gp_action_choice_title>(state, id);
1693 } else if(name == "description") {
1694 return make_element_by_type<gp_action_choice_desc>(state, id);
1695 } else if(name == "agreebutton") {
1696 return make_element_by_type<gp_action_choice_accept_button>(state, id);
1697 } else if(name == "declinebutton") {
1698 return make_element_by_type<gp_action_choice_cancel_button>(state, id);
1699 } else if(name == "leftshield") {
1700 return make_element_by_type<nation_player_flag>(state, id);
1701 } else if(name == "rightshield") {
1702 return make_element_by_type<flag_button>(state, id);
1703 } else if(name == "background") {
1704 auto ptr = make_element_by_type<draggable_target>(state, id);
1705 ptr->base_data.size = base_data.size;
1706 return ptr;
1707 } else {
1708 return nullptr;
1709 }
1710 }
1711
1712 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
1713 if(payload.holds_type<gp_choice_select>()) {
1714 selected_gp = any_cast<gp_choice_select>(payload).value;
1717 } else if(payload.holds_type<dcon::nation_id>()) {
1718 payload.emplace<dcon::nation_id>(action_target);
1720 } else if(payload.holds_type<gp_choice_get_selection>()) {
1723 } else if(payload.holds_type<gp_choice_actions>()) {
1724 payload.emplace<gp_choice_actions>(current_action);
1726 }
1727 return window_element_base::get(state, payload);
1728 }
1729};
1730
1732public:
1733 dcon::text_key get_name(sys::state& state, dcon::nation_id target) noexcept override {
1734 return state.lookup_key("state_transfer_button");
1735 }
1736
1737 bool is_available(sys::state& state, dcon::nation_id target) noexcept override {
1738 for(const auto s : state.world.nation_get_state_ownership(target)) {
1739 if(command::can_state_transfer(state, state.local_player_nation, target, s.get_state().get_definition())) {
1740 return true;
1741 }
1742 }
1743
1744 return false;
1745 }
1746
1747 void button_action(sys::state& state, dcon::nation_id target, ui::element_base* parent) noexcept override {
1748
1750 seldata.single_state_select = true;
1751 for(const auto s : state.world.nation_get_state_ownership(state.local_player_nation)) {
1752 if(command::can_state_transfer(state, state.local_player_nation, target, s.get_state().get_definition())) {
1753 seldata.selectable_states.push_back(s.get_state().get_definition());
1754 }
1755 }
1756 seldata.on_select = [parent, target](sys::state& state, dcon::state_definition_id sdef) {
1757 command::state_transfer(state, state.local_player_nation, target, sdef);
1758 parent->impl_on_update(state);
1759 };
1760 seldata.on_cancel = [parent](sys::state& state) {
1761 parent->impl_on_update(state);
1762 };
1763 state.start_state_selection(seldata);
1764 }
1765
1766 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents, dcon::nation_id target) noexcept override {
1767 auto source = state.local_player_nation;
1768
1769 text::add_line(state, contents, "state_transfer_desc");
1771
1772 text::add_line_with_condition(state, contents, "state_transfer_explain_2", state.current_crisis_state == sys::crisis_state::inactive);
1773 text::add_line_with_condition(state, contents, "state_transfer_explain_3", !state.world.overlord_get_ruler(state.world.nation_get_overlord_as_subject(source)));
1774 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)));
1775 text::add_line_with_condition(state, contents, "state_transfer_explain_6", state.world.nation_get_owned_state_count(source) > 1);
1776 }
1777};
1778
1779template<typename T>
1781public:
1782 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1783 if(name == "action_option") {
1784 return make_element_by_type<T>(state, id);
1785 } else {
1786 return nullptr;
1787 }
1788 }
1789};
1790
1791} // namespace ui
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 update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents, dcon::nation_id target) noexcept override
dcon::text_key get_name(sys::state &state, dcon::nation_id target) noexcept override
void button_action(sys::state &state, dcon::nation_id target, ui::element_base *parent) noexcept override
bool is_available(sys::state &state, dcon::nation_id target) noexcept override
void button_action(sys::state &state, dcon::nation_id target, ui::element_base *parent) noexcept override
dcon::text_key get_name(sys::state &state, dcon::nation_id target) noexcept override
bool is_available(sys::state &state, dcon::nation_id target) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents, dcon::nation_id target) noexcept override
bool is_available(sys::state &state, dcon::nation_id target) noexcept override
dcon::text_key get_name(sys::state &state, dcon::nation_id target) noexcept override
void button_action(sys::state &state, dcon::nation_id target, ui::element_base *parent) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents, dcon::nation_id target) noexcept override
virtual dcon::text_key get_name(sys::state &state, dcon::nation_id target)
virtual void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents, dcon::nation_id target)
virtual bool is_available(sys::state &state, dcon::nation_id target)
virtual void button_action(sys::state &state, dcon::nation_id target, ui::element_base *parent)
void button_action(sys::state &state, dcon::nation_id target, ui::element_base *parent) noexcept override
dcon::text_key get_name(sys::state &state, dcon::nation_id target) noexcept override
bool is_available(sys::state &state, dcon::nation_id target) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents, dcon::nation_id target) noexcept override
dcon::text_key get_name(sys::state &state, dcon::nation_id target) noexcept override
bool is_available(sys::state &state, dcon::nation_id target) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents, dcon::nation_id target) noexcept override
void button_action(sys::state &state, dcon::nation_id target, ui::element_base *parent) noexcept override
dcon::text_key get_name(sys::state &state, dcon::nation_id target) noexcept override
void button_action(sys::state &state, dcon::nation_id target, ui::element_base *parent) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents, dcon::nation_id target) noexcept override
bool is_available(sys::state &state, dcon::nation_id target) 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
void button_action(sys::state &state, dcon::nation_id target, ui::element_base *parent) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents, dcon::nation_id target) noexcept override
bool is_available(sys::state &state, dcon::nation_id target) noexcept override
dcon::text_key get_name(sys::state &state, dcon::nation_id target) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents, dcon::nation_id target) noexcept override
dcon::text_key get_name(sys::state &state, dcon::nation_id target) noexcept override
bool is_available(sys::state &state, dcon::nation_id target) noexcept override
void button_action(sys::state &state, dcon::nation_id target, ui::element_base *parent) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents, dcon::nation_id target) noexcept override
bool is_available(sys::state &state, dcon::nation_id target) noexcept override
void button_action(sys::state &state, dcon::nation_id target, ui::element_base *parent) noexcept override
dcon::text_key get_name(sys::state &state, dcon::nation_id target) 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
dcon::text_key get_name(sys::state &state, dcon::nation_id target) noexcept override
void button_action(sys::state &state, dcon::nation_id target, ui::element_base *parent) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents, dcon::nation_id target) noexcept override
bool is_available(sys::state &state, dcon::nation_id target) noexcept override
void button_action(sys::state &state, dcon::nation_id target, ui::element_base *parent) noexcept override
bool is_available(sys::state &state, dcon::nation_id target) noexcept override
dcon::text_key get_name(sys::state &state, dcon::nation_id target) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents, dcon::nation_id target) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents, dcon::nation_id target) noexcept override
bool is_available(sys::state &state, dcon::nation_id target) noexcept override
void button_action(sys::state &state, dcon::nation_id target, ui::element_base *parent) noexcept override
dcon::text_key get_name(sys::state &state, dcon::nation_id target) noexcept override
bool is_available(sys::state &state, dcon::nation_id target) noexcept override
void button_action(sys::state &state, dcon::nation_id target, ui::element_base *parent) noexcept override
dcon::text_key get_name(sys::state &state, dcon::nation_id target) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents, dcon::nation_id target) noexcept override
dcon::text_key get_name(sys::state &state, dcon::nation_id target) noexcept override
void button_action(sys::state &state, dcon::nation_id target, ui::element_base *parent) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents, dcon::nation_id target) noexcept override
bool is_available(sys::state &state, dcon::nation_id target) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents, dcon::nation_id target) noexcept override
dcon::text_key get_name(sys::state &state, dcon::nation_id target) noexcept override
bool is_available(sys::state &state, dcon::nation_id target) noexcept override
void button_action(sys::state &state, dcon::nation_id target, ui::element_base *parent) noexcept override
dcon::text_key get_name(sys::state &state, dcon::nation_id target) noexcept override
void button_action(sys::state &state, dcon::nation_id target, ui::element_base *parent) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents, dcon::nation_id target) noexcept override
bool is_available(sys::state &state, dcon::nation_id target) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents, dcon::nation_id target) noexcept override
void button_action(sys::state &state, dcon::nation_id target, ui::element_base *parent) noexcept override
dcon::text_key get_name(sys::state &state, dcon::nation_id target) noexcept override
bool is_available(sys::state &state, dcon::nation_id target) 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
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:371
void explain_ai_alliance_reasons(sys::state &state, dcon::nation_id target, text::layout_base &contents, int32_t indent)
Definition: ai.cpp:332
bool can_state_transfer(sys::state &state, dcon::nation_id asker, dcon::nation_id target, dcon::state_definition_id sid)
Definition: commands.cpp:2462
bool can_increase_opinion(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target)
Definition: commands.cpp:1302
bool can_cancel_military_access(sys::state &state, dcon::nation_id source, dcon::nation_id target, bool ignore_cost)
Definition: commands.cpp:2587
bool can_release_subject(sys::state &state, dcon::nation_id source, dcon::nation_id target)
Definition: commands.cpp:4042
bool can_expel_advisors(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target, dcon::nation_id affected_gp)
Definition: commands.cpp:1161
bool can_add_to_sphere(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target)
Definition: commands.cpp:1439
bool can_give_war_subsidies(sys::state &state, dcon::nation_id source, dcon::nation_id target)
Definition: commands.cpp:259
bool can_give_military_access(sys::state &state, dcon::nation_id asker, dcon::nation_id target, bool ignore_cost)
Definition: commands.cpp:2349
bool can_cancel_war_subsidies(sys::state &state, dcon::nation_id source, dcon::nation_id target)
Definition: commands.cpp:304
void give_war_subsidies(sys::state &state, dcon::nation_id source, dcon::nation_id target)
Definition: commands.cpp:251
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:2517
bool can_fabricate_cb(sys::state &state, dcon::nation_id source, dcon::nation_id target, dcon::cb_type_id type, dcon::state_definition_id target_state)
Definition: commands.cpp:2224
bool can_ask_for_access(sys::state &state, dcon::nation_id asker, dcon::nation_id target, bool ignore_cost)
Definition: commands.cpp:2309
bool can_increase_relations(sys::state &state, dcon::nation_id source, dcon::nation_id target)
Definition: commands.cpp:346
bool can_ban_embassy(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target, dcon::nation_id affected_gp)
Definition: commands.cpp:1231
bool can_decrease_relations(sys::state &state, dcon::nation_id source, dcon::nation_id target)
Definition: commands.cpp:386
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:2932
bool can_discredit_advisors(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target, dcon::nation_id affected_gp)
Definition: commands.cpp:1086
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:1499
bool can_decrease_opinion(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target, dcon::nation_id affected_gp)
Definition: commands.cpp:1360
bool can_cancel_alliance(sys::state &state, dcon::nation_id source, dcon::nation_id target, bool ignore_cost)
Definition: commands.cpp:2665
bool can_cancel_given_military_access(sys::state &state, dcon::nation_id source, dcon::nation_id target, bool ignore_cost)
Definition: commands.cpp:2626
bool can_ask_for_alliance(sys::state &state, dcon::nation_id asker, dcon::nation_id target, bool ignore_cost)
Definition: commands.cpp:2384
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)
Returns the appropriate acceptance evaluation for a given diplomatic message. It is required to defin...
float estimate_war_subsidies(sys::state &state, dcon::nation_fat_id target, dcon::nation_fat_id source)
Definition: economy.cpp:8210
bool can_use_cb_against(sys::state &state, dcon::nation_id from, dcon::nation_id target)
Definition: military.cpp:245
bool has_truce_with(sys::state &state, dcon::nation_id attacker, dcon::nation_id target)
Definition: military.cpp:2296
bool standard_war_joining_is_possible(sys::state &state, dcon::war_id wfor, dcon::nation_id n, bool as_attacker)
Definition: military.cpp:2603
war_role get_role(sys::state const &state, dcon::war_id w, dcon::nation_id n)
Definition: military.cpp:2501
bool is_attacker(sys::state &state, dcon::war_id w, dcon::nation_id n)
Definition: military.cpp:2493
bool are_in_common_war(sys::state const &state, dcon::nation_id a, dcon::nation_id b)
Definition: military.cpp:673
dcon::war_id find_war_between(sys::state const &state, dcon::nation_id a, dcon::nation_id b)
Definition: military.cpp:718
bool are_at_war(sys::state const &state, dcon::nation_id a, dcon::nation_id b)
Definition: military.cpp:649
bool is_civil_war(sys::state const &state, dcon::war_id w)
Definition: military.cpp:743
constexpr uint8_t is_banned
Definition: nations.hpp:183
constexpr uint8_t level_friendly
Definition: nations.hpp:172
constexpr uint8_t is_discredited
Definition: nations.hpp:182
constexpr uint8_t level_opposed
Definition: nations.hpp:169
constexpr uint8_t level_hostile
Definition: nations.hpp:170
constexpr uint8_t level_in_sphere
Definition: nations.hpp:173
constexpr uint8_t level_mask
Definition: nations.hpp:167
int32_t get_level(sys::state &state, dcon::nation_id gp, dcon::nation_id target)
Definition: nations.cpp:25
bool is_influence_level_greater_or_equal(int32_t l, int32_t r)
Definition: nations.hpp:253
bool are_allied(sys::state &state, dcon::nation_id a, dcon::nation_id b)
Definition: nations.cpp:685
dcon::nation_id get_nth_great_power(sys::state const &state, uint16_t n)
Definition: nations.cpp:75
std::string resolve_string_substitution(sys::state &state, dcon::text_key source_text, substitution_map const &mp)
Definition: text.cpp:2137
layout_box open_layout_box(layout_base &dest, int32_t indent)
Definition: text.cpp:1823
void localised_format_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view key, text::substitution_map const &sub)
Definition: text.cpp:1904
endless_layout create_endless_layout(sys::state &state, layout &dest, layout_parameters const &params)
Definition: text.cpp:1100
std::string format_float(float num, size_t digits)
Definition: text.cpp:981
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
Definition: text.cpp:1923
void add_line_with_condition(sys::state &state, layout_base &dest, std::string_view key, bool condition_met, int32_t indent)
Definition: text.cpp:1979
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:797
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:1831
tooltip_behavior
void send(sys::state &state, element_base *parent, T value)
message_result
uchar uint8_t
Holds data regarding a diplomatic message between two specified nations at a certain date,...
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
Holds important data about the game world, state, and other data regarding windowing,...
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