Project Alice
Loading...
Searching...
No Matches
gui_pick_wargoal_window.hpp
Go to the documentation of this file.
1#pragma once
2
3namespace ui {
4
5
7public:
8 void button_action(sys::state& state) noexcept override {
10 }
11};
12
13
15public:
16 void on_update(sys::state& state) noexcept override {
17 auto content = retrieve<dcon::cb_type_id>(state, parent);
18 frame = (dcon::fatten(state.world, content).get_sprite_index() - 1);
19 }
20};
21
23public:
24 void button_action(sys::state& state) noexcept override {
25 dcon::cb_type_id content = retrieve<dcon::cb_type_id>(state, parent);
26 dcon::cb_type_id selected = parent ? retrieve<dcon::cb_type_id>(state, parent->parent) : dcon::cb_type_id{};
27 if(content == selected)
29 else
31 }
32
33 void on_update(sys::state& state) noexcept override {
34 dcon::cb_type_id content = retrieve<dcon::cb_type_id>(state, parent);
35 dcon::nation_id target = retrieve<dcon::nation_id>(state, parent);
36 auto war = retrieve<dcon::war_id>(state, parent);
37 auto cb_infamy = !war
38 ? (military::has_truce_with(state, state.local_player_nation, target)
40 : military::cb_infamy(state, content))
41 : military::cb_addition_infamy_cost(state, war, content, state.local_player_nation, target);
42 if(state.world.nation_get_infamy(state.local_player_nation) + cb_infamy >= state.defines.badboy_limit) {
43 color = sys::pack_color(255, 196, 196);
44 } else {
45 color = sys::pack_color(255, 255, 255);
46 }
47
48 auto fat_id = dcon::fatten(state.world, content);
50 }
51
54 }
55 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
56 dcon::cb_type_id content = retrieve<dcon::cb_type_id>(state, parent);
57 dcon::nation_id target = retrieve<dcon::nation_id>(state, parent);
58 auto war = retrieve<dcon::war_id>(state, parent);
59 auto cb_infamy = !war
60 ? (military::has_truce_with(state, state.local_player_nation, target)
62 : 0.f)
63 : military::cb_addition_infamy_cost(state, war, content, state.local_player_nation, target);
64 if(state.world.nation_get_infamy(state.local_player_nation) + cb_infamy >= state.defines.badboy_limit) {
65 text::add_line(state, contents, "alice_tt_wg_infamy_limit");
66 }
67
68 auto fat_id = dcon::fatten(state.world, content);
69 if(fat_id.get_can_use()) {
70 text::add_line(state, contents, "tt_can_use_nation");
71 trigger_description(state, contents, fat_id.get_can_use(), trigger::to_generic(target), trigger::to_generic(state.local_player_nation), trigger::to_generic(target));
72 }
73 if(auto allowed_substates = fat_id.get_allowed_substate_regions(); allowed_substates) {
74 text::add_line_with_condition(state, contents, "is_substate", state.world.nation_get_is_substate(target));
75 if(state.world.nation_get_is_substate(target)) {
76 auto ruler = state.world.overlord_get_ruler(state.world.nation_get_overlord_as_subject(target));
77 trigger_description(state, contents, allowed_substates, trigger::to_generic(ruler), trigger::to_generic(state.local_player_nation), trigger::to_generic(state.local_player_nation));
78 }
79 }
80 text::add_line(state, contents, "et_on_add");
81 effect_description(state, contents, fat_id.get_on_add(), trigger::to_generic(state.local_player_nation), trigger::to_generic(state.local_player_nation), trigger::to_generic(target),
82 uint32_t(state.current_date.value), uint32_t((state.local_player_nation.index() << 7) ^ target.index() ^ (fat_id.id.index() << 3)));
83 text::add_line(state, contents, "et_on_po_accepted");
84 auto windx = 0;//wargoal.index()
85 effect_description(state, contents, fat_id.get_on_po_accepted(), trigger::to_generic(target), trigger::to_generic(state.local_player_nation), trigger::to_generic(state.local_player_nation),
86 uint32_t((state.current_date.value << 8) ^ target.index()), uint32_t(state.local_player_nation.index() ^ (windx << 3)));
87
88 if(auto allowed_states = fat_id.get_allowed_states(); allowed_states) {
89 bool described = false;
90 for(auto si : state.world.nation_get_state_ownership(target)) {
91 if(trigger::evaluate(state, allowed_states, trigger::to_generic(si.get_state().id), trigger::to_generic(state.local_player_nation), trigger::to_generic(state.local_player_nation))) {
92 ui::trigger_description(state, contents, allowed_states, trigger::to_generic(si.get_state().id), trigger::to_generic(state.local_player_nation), trigger::to_generic(state.local_player_nation));
93 described = true;
94 break;
95 }
96 }
97 if(!described) {
98 ui::trigger_description(state, contents, allowed_states, -1, trigger::to_generic(state.local_player_nation), trigger::to_generic(state.local_player_nation));
99 }
100 }
101 }
102};
103
104class wargoal_type_item : public listbox_row_element_base<dcon::cb_type_id> {
105public:
106 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
107 if(name == "wargoal_icon") {
108 auto ptr = make_element_by_type<wargoal_type_item_icon>(state, id);
109 //ptr->base_data.position.x += 16; // Nudge
110 return ptr;
111 } else if(name == "select_goal_invalid") {
112 return make_element_by_type<invisible_element>(state, id);
113 } else if(name == "select_goal") {
114 auto ptr = make_element_by_type<wargoal_type_item_button>(state, id);
115 //ptr->base_data.position.x += 16; // Nudge
116 return ptr;
117 } else {
118 return nullptr;
119 }
120 }
121};
122
123class wargoal_type_listbox : public listbox_element_base<wargoal_type_item, dcon::cb_type_id> {
124protected:
125 std::string_view get_row_element_name() override {
126 return "wargoal_item";
127 }
128
129public:
130 void on_update(sys::state& state) noexcept override {
131 row_contents.clear();
132
133 auto selected_cb = retrieve<dcon::cb_type_id>(state, parent);
134 if(selected_cb) {
135 row_contents.push_back(selected_cb);
136 update(state);
137 return;
138 }
139
140 dcon::nation_id content = retrieve<dcon::nation_id>(state, parent);
141 auto w = military::find_war_between(state, state.local_player_nation, content);
142
143 if(w) { // war is ongoing
144 for(auto cb_type : state.world.in_cb_type) {
145 // prevent duplicate war goals
147 if(military::war_goal_would_be_duplicate(state, state.local_player_nation, w, content, cb_type, dcon::state_definition_id{}, dcon::national_identity_id{}, dcon::nation_id{}))
148 continue;
149 }
150
151 if((state.world.cb_type_get_type_bits(cb_type) & military::cb_flag::always) == 0 && military::cb_conditions_satisfied(state, state.local_player_nation, content, cb_type)) {
152 bool cb_fabbed = false;
153 for(auto& fab_cb : state.world.nation_get_available_cbs(state.local_player_nation)) {
154 if(fab_cb.cb_type == cb_type && fab_cb.target == content) {
155 cb_fabbed = true;
156 break;
157 }
158 }
159 if(!cb_fabbed) {
160 if((state.world.cb_type_get_type_bits(cb_type) & military::cb_flag::is_not_constructing_cb) != 0)
161 continue; // can only add a constructable cb this way
162
163 auto totalpop = state.world.nation_get_demographics(state.local_player_nation, demographics::total);
164 auto jingoism_perc = totalpop > 0 ? state.world.nation_get_demographics(state.local_player_nation, demographics::to_key(state, state.culture_definitions.jingoism)) / totalpop : 0.0f;
165 if(state.world.war_get_is_great(w)) {
166 if(jingoism_perc >= state.defines.wargoal_jingoism_requirement * state.defines.gw_wargoal_jingoism_requirement_mod) {
167 row_contents.push_back(cb_type);
168 continue;
169 }
170 } else {
171 if(jingoism_perc >= state.defines.wargoal_jingoism_requirement) {
172 row_contents.push_back(cb_type);
173 continue;
174 }
175 }
176 } else {
177 row_contents.push_back(cb_type);
178 continue;
179 }
180 } else { // this is an always CB
181 if(military::cb_conditions_satisfied(state, state.local_player_nation, content, cb_type) && military::can_add_always_cb_to_war(state, state.local_player_nation, content, cb_type, w)) {
182 row_contents.push_back(cb_type);
183 continue;
184 }
185 }
186 }
187 } else { // this is a declare war action
188 auto other_cbs = state.world.nation_get_available_cbs(state.local_player_nation);
189 for(auto cb : state.world.in_cb_type) {
190 bool can_use = military::cb_conditions_satisfied(state, state.local_player_nation, content, cb) && [&]() {
191 if((cb.get_type_bits() & military::cb_flag::always) != 0) {
192 return true;
193 }
194 for(auto& fabbed : other_cbs) {
195 if(fabbed.cb_type == cb && fabbed.target == content)
196 return true;
197 }
198 return false;
199 }();
200
201 if(can_use) {
202 row_contents.push_back(cb);
203 }
204 }
205 }
206
207 update(state);
208 }
209};
210
212public:
213 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
214 if(name == "wargoal_list") {
215 return make_element_by_type<wargoal_type_listbox>(state, id);
216 } else if(name == "cancel_select") {
217 return make_element_by_type<wargoal_cancel_button>(state, id);
218 } else {
219 return nullptr;
220 }
221 }
222};
223
225public:
226 void button_action(sys::state& state) noexcept override {
227 dcon::national_identity_id content = retrieve<dcon::national_identity_id>(state, parent);
229 }
230
231 void on_update(sys::state& state) noexcept override {
232 dcon::national_identity_id content = retrieve<dcon::national_identity_id>(state, parent);
234 }
235
238 }
239 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
240 dcon::cb_type_id cb = retrieve<dcon::cb_type_id>(state, parent);
241 if(auto allowed_countries = state.world.cb_type_get_allowed_countries(cb); allowed_countries) {
242 dcon::nation_id target = retrieve<dcon::nation_id>(state, parent);
243 auto holder = state.world.national_identity_get_nation_from_identity_holder(retrieve<dcon::national_identity_id>(state, parent));
244 trigger_description(state, contents, allowed_countries, trigger::to_generic(target), trigger::to_generic(state.local_player_nation), trigger::to_generic(holder));
245 }
246 }
247};
248
249class wargoal_country_item : public listbox_row_element_base<dcon::national_identity_id> {
250public:
251 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
252 if(name == "select_country") {
253 return make_element_by_type<wargoal_country_item_button>(state, id);
254 } else {
255 return nullptr;
256 }
257 }
258};
259
260class wargoal_country_listbox : public listbox_element_base<wargoal_country_item, dcon::national_identity_id> {
261protected:
262 std::string_view get_row_element_name() override {
263 return "wargoal_country_item";
264 }
265
266public:
267 void on_update(sys::state& state) noexcept override {
268 row_contents.clear();
269
270 dcon::nation_id target = retrieve<dcon::nation_id>(state, parent);
271 auto actor = state.local_player_nation;
272 dcon::cb_type_id cb = retrieve<dcon::cb_type_id>(state, parent);
273 auto war = military::find_war_between(state, actor, target);
274
275 dcon::trigger_key allowed_countries = state.world.cb_type_get_allowed_countries(cb);
276 if(!allowed_countries) {
277 update(state);
278 return;
279 }
280
281 for(auto n : state.world.in_nation) {
282 if(n != actor && trigger::evaluate(state, allowed_countries, trigger::to_generic(target), trigger::to_generic(actor), trigger::to_generic(n.id))) {
283 auto id = state.world.nation_get_identity_from_identity_holder(n);
284 if(!war) {
285 row_contents.push_back(id);
287 row_contents.push_back(id);
288 } else {
290 if(!military::war_goal_would_be_duplicate(state, state.local_player_nation, war, target, cb, dcon::state_definition_id{}, id, dcon::nation_id{})) {
291 row_contents.push_back(id);
292 }
293 } else {
294 if(!military::war_goal_would_be_duplicate(state, state.local_player_nation, war, target, cb, dcon::state_definition_id{}, dcon::national_identity_id{}, n)) {
295 row_contents.push_back(id);
296 }
297 }
298 }
299 }
300 }
301
302 update(state);
303 }
304};
305
307public:
308 void button_action(sys::state& state) noexcept override {
310 }
311};
312
314public:
315 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
316 if(name == "country_list") {
317 return make_element_by_type<wargoal_country_listbox>(state, id);
318 } else if(name == "cancel_select") {
319 return make_element_by_type<wargoal_cancel_country_select>(state, id);
320 } else {
321 return nullptr;
322 }
323 }
324};
325
326
328public:
329 void on_update(sys::state& state) noexcept override {
330 auto cb = retrieve<dcon::cb_type_id>(state, parent);
331 auto target = retrieve<dcon::nation_id>(state, parent);
332 auto source = state.local_player_nation;
333
334 dcon::nation_id real_target = target;
335
336 auto target_ol_rel = state.world.nation_get_overlord_as_subject(target);
337 if(state.world.overlord_get_ruler(target_ol_rel))
338 real_target = state.world.overlord_get_ruler(target_ol_rel);
339
340 if(cb) {
341 if(auto w = military::find_war_between(state, source, target); w) {
343 set_text(state, "0.0");
344 } else if(military::has_truce_with(state, source, real_target)) {
345 auto cb_prestige_loss = military::truce_break_cb_prestige_cost(state, cb);
346
348 set_text(state, text::format_float(cb_prestige_loss, 1));
349 } else {
351 set_text(state, "0.0");
352 }
353 } else {
355 set_text(state, "0.0");
356 }
357 }
358};
360public:
361 void on_update(sys::state& state) noexcept override {
362 auto cb = retrieve<dcon::cb_type_id>(state, parent);
363 auto target = retrieve<dcon::nation_id>(state, parent);
364 auto source = state.local_player_nation;
365
366 dcon::nation_id real_target = target;
367
368 auto target_ol_rel = state.world.nation_get_overlord_as_subject(target);
369 if(state.world.overlord_get_ruler(target_ol_rel))
370 real_target = state.world.overlord_get_ruler(target_ol_rel);
371
372 if(cb) {
373 if(auto w = military::find_war_between(state, source, target); w) {
374 auto cb_infamy = military::cb_addition_infamy_cost(state, w, cb, source, target);
375
377 set_text(state, text::format_float(cb_infamy, 1));
378 } else if(military::has_truce_with(state, source, real_target)) {
379 auto cb_infamy = military::truce_break_cb_infamy(state, cb);
380
382 set_text(state, text::format_float(cb_infamy, 1));
383 } else {
385 set_text(state, "0.0");
386 }
387 } else {
389 set_text(state, "0.0");
390 }
391 }
392};
394public:
395 void on_update(sys::state& state) noexcept override {
396 auto cb = retrieve<dcon::cb_type_id>(state, parent);
397 auto target = retrieve<dcon::nation_id>(state, parent);
398 auto source = state.local_player_nation;
399
400 dcon::nation_id real_target = target;
401
402 auto target_ol_rel = state.world.nation_get_overlord_as_subject(target);
403 if(state.world.overlord_get_ruler(target_ol_rel))
404 real_target = state.world.overlord_get_ruler(target_ol_rel);
405
406 if(cb) {
407 if(auto w = military::find_war_between(state, source, target); w) {
409 set_text(state, "0.0");
410 } else if(military::has_truce_with(state, source, real_target)) {
411 auto cb_militancy = military::truce_break_cb_militancy(state, cb);
412
414 set_text(state, text::format_float(cb_militancy, 1));
415 } else {
417 set_text(state, "0.0");
418 }
419 } else {
421 set_text(state, "0.0");
422 }
423 }
424};
425
427public:
428 void on_create(sys::state& state) noexcept override {
431 }
432};
433
435public:
436 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
437 if(name == "wargoal_gain_effect_text") {
438 return make_element_by_type<wargoal_add_header>(state, id);
439 } else if(name == "prestige_icon") {
440 return make_element_by_type<image_element_base>(state, id);
441 } else if(name == "prestige") {
442 return make_element_by_type<wargoal_add_prestige>(state, id);
443 } else if(name == "infamy_icon") {
444 return make_element_by_type<image_element_base>(state, id);
445 } else if(name == "infamy") {
446 return make_element_by_type<wargoal_add_infamy>(state, id);
447 } else if(name == "militancy_icon") {
448 return make_element_by_type<image_element_base>(state, id);
449 } else if(name == "militancy") {
450 return make_element_by_type<wargoal_add_militancy>(state, id);
451 } else {
452 return nullptr;
453 }
454 }
455};
456
458public:
459 void on_create(sys::state& state) noexcept override {
461 set_text(state, "0.0");
462 }
463};
464
465
467public:
468 void on_update(sys::state& state) noexcept override {
469 auto cb = retrieve<dcon::cb_type_id>(state, parent);
470 auto source = state.local_player_nation;
471
472 if(cb) {
473 float prestige_gain = military::successful_cb_prestige(state, cb, source);
474 if(prestige_gain > 0) {
476 set_text(state, text::format_float(prestige_gain, 1));
477 } else {
479 set_text(state, "0.0");
480 }
481 } else {
483 set_text(state, "0.0");
484 }
485 }
486};
487
489public:
490 void on_create(sys::state& state) noexcept override {
493 }
494};
495
497public:
498 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
499 if(name == "wargoal_gain_effect_text") {
500 return make_element_by_type<wargoal_success_header>(state, id);
501 } else if(name == "prestige_icon") {
502 return make_element_by_type<image_element_base>(state, id);
503 } else if(name == "prestige") {
504 return make_element_by_type<wargoal_success_prestige>(state, id);
505 } else if(name == "infamy_icon") {
506 return make_element_by_type<image_element_base>(state, id);
507 } else if(name == "infamy") {
508 return make_element_by_type<fixed_zero>(state, id);
509 } else if(name == "militancy_icon") {
510 return make_element_by_type<image_element_base>(state, id);
511 } else if(name == "militancy") {
512 return make_element_by_type<fixed_zero>(state, id);
513 } else {
514 return nullptr;
515 }
516 }
517};
518
520public:
521 void on_update(sys::state& state) noexcept override {
522 auto cb = retrieve<dcon::cb_type_id>(state, parent);
523 auto source = state.local_player_nation;
524 if(cb) {
525 float prestige_loss = std::min(state.defines.war_failed_goal_prestige_base, state.defines.war_failed_goal_prestige * nations::prestige_score(state, source)) * state.world.cb_type_get_penalty_factor(cb);
526
527 if(prestige_loss < 0) {
529 set_text(state, text::format_float(prestige_loss, 1));
530 } else {
532 set_text(state, "0.0");
533 }
534 } else {
536 set_text(state, "0.0");
537 }
538 }
539};
540
542public:
543 void on_update(sys::state& state) noexcept override {
544 auto cb = retrieve<dcon::cb_type_id>(state, parent);
545 if(cb) {
546 auto pop_militancy = state.defines.war_failed_goal_militancy * state.world.cb_type_get_penalty_factor(cb);
547
548 if(pop_militancy > 0) {
550 set_text(state, text::format_float(pop_militancy, 1));
551 } else {
553 set_text(state, "0.0");
554 }
555 } else {
557 set_text(state, "0.0");
558 }
559 }
560};
561
563public:
564 void on_create(sys::state& state) noexcept override {
567 }
568};
569
571public:
572 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
573 if(name == "wargoal_gain_effect_text") {
574 return make_element_by_type<wargoal_failure_header>(state, id);
575 } else if(name == "prestige_icon") {
576 return make_element_by_type<image_element_base>(state, id);
577 } else if(name == "prestige") {
578 return make_element_by_type<wargoal_failure_prestige>(state, id);
579 } else if(name == "infamy_icon") {
580 return make_element_by_type<image_element_base>(state, id);
581 } else if(name == "infamy") {
582 return make_element_by_type<fixed_zero>(state, id);
583 } else if(name == "militancy_icon") {
584 return make_element_by_type<image_element_base>(state, id);
585 } else if(name == "militancy") {
586 return make_element_by_type<wargoal_failure_militancy>(state, id);
587 } else {
588 return nullptr;
589 }
590 }
591};
592
594public:
595 void on_update(sys::state& state) noexcept override {
596 auto war = retrieve<dcon::war_id>(state, parent);
597 if(!war) {
599 } else {
601 }
602 }
603};
604
606 bool done = false;
607};
608
610public:
611 void on_update(sys::state& state) noexcept override {
612 auto wg_ready = retrieve<check_wg_completion>(state, parent).done;
613 if(!wg_ready) {
614 disabled = true;
615 return;
616 }
617
618 dcon::nation_id n = retrieve<dcon::nation_id>(state, parent);
619 dcon::state_definition_id s = retrieve<dcon::state_definition_id>(state, parent);
620 dcon::national_identity_id ni = retrieve<dcon::national_identity_id>(state, parent);
621 dcon::cb_type_id c = retrieve<dcon::cb_type_id>(state, parent);
622
623 if(military::are_at_war(state, state.local_player_nation, n)) {
624 dcon::war_id w = military::find_war_between(state, state.local_player_nation, n);
625 disabled = !command::can_add_war_goal(state, state.local_player_nation, w, n, c, s, ni,
626 state.world.national_identity_get_nation_from_identity_holder(ni));
627 } else {
628 disabled = !command::can_declare_war(state, state.local_player_nation, n, c, s, ni,
629 state.world.national_identity_get_nation_from_identity_holder(ni));
630 }
631 }
632
633 void button_action(sys::state& state) noexcept override {
634 dcon::nation_id n = retrieve<dcon::nation_id>(state, parent);
635 dcon::state_definition_id s = retrieve<dcon::state_definition_id>(state, parent);
636 dcon::national_identity_id ni = retrieve<dcon::national_identity_id>(state, parent);
637 dcon::cb_type_id c = retrieve<dcon::cb_type_id>(state, parent);
638 if(military::are_at_war(state, state.local_player_nation, n)) {
639 dcon::war_id w = military::find_war_between(state, state.local_player_nation, n);
640 command::add_war_goal(state, state.local_player_nation, w, n, c, s, ni,
641 state.world.national_identity_get_nation_from_identity_holder(ni));
642 } else {
643 command::declare_war(state, state.local_player_nation, n, c, s, ni,
644 state.world.national_identity_get_nation_from_identity_holder(ni), retrieve<bool>(state, parent));
645 }
646 parent->set_visible(state, false);
647 }
648
651 }
652
653 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
654 auto wg_ready = retrieve<check_wg_completion>(state, parent).done;
655 if(!wg_ready) {
656 text::add_line_with_condition(state, contents, "wg_not_ready", false);
657 return;
658 }
659
660 dcon::nation_id n = retrieve<dcon::nation_id>(state, parent);
661 dcon::state_definition_id s = retrieve<dcon::state_definition_id>(state, parent);
662 dcon::national_identity_id ni = retrieve<dcon::national_identity_id>(state, parent);
663 dcon::cb_type_id c = retrieve<dcon::cb_type_id>(state, parent);
664
665 if(command::can_declare_war(state, state.local_player_nation, n, c, s, ni,
666 state.world.national_identity_get_nation_from_identity_holder(ni))) {
667 auto box = text::open_layout_box(contents, 0);
668 text::localised_format_box(state, contents, box, std::string_view("valid_wartarget"));
669 text::close_layout_box(contents, box);
670 text::add_line_with_condition(state, contents, "alice_condition_diplo_points", !(state.world.nation_get_is_player_controlled(state.local_player_nation) && 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));
671 } else {
672 dcon::war_id w = military::find_war_between(state, state.local_player_nation, n);
673 auto box = text::open_layout_box(contents, 0);
674 if(military::are_allied_in_war(state, state.local_player_nation, n)) {
675 text::localised_format_box(state, contents, box, std::string_view("invalid_wartarget_shared_war"));
676 }
677 auto rel = state.world.get_diplomatic_relation_by_diplomatic_pair(state.local_player_nation, n);
678 if(state.world.diplomatic_relation_get_are_allied(rel)) {
679 text::localised_format_box(state, contents, box, std::string_view("no_war_allied"));
680 }
681 text::close_layout_box(contents, box);
682 text::add_line_with_condition(state, contents, "alice_condition_diplo_points", !(state.world.nation_get_is_player_controlled(state.local_player_nation) && state.world.nation_get_diplomatic_points(state.local_player_nation) < state.defines.addwargoal_diplomatic_cost), text::variable_type::x, int64_t(state.defines.addwargoal_diplomatic_cost));
683
684 bool is_attacker = military::is_attacker(state, w, state.local_player_nation);
685 bool target_in_war = false;
686 for(auto par : state.world.war_get_war_participant(w)) {
687 if(par.get_nation() == n) {
688 text::add_line_with_condition(state, contents, "alice_wg_condition_4", !(par.get_is_attacker() == is_attacker));
689 target_in_war = true;
690 break;
691 }
692 }
693 text::add_line_with_condition(state, contents, "alice_wg_condition_1", !(!is_attacker && military::defenders_have_status_quo_wargoal(state, w)));
694 text::add_line_with_condition(state, contents, "alice_wg_condition_2", bool(target_in_war));
695 text::add_line_with_condition(state, contents, "alice_wg_condition_3", !(military::war_goal_would_be_duplicate(state, state.local_player_nation, w, n, c, s, ni, state.world.national_identity_get_nation_from_identity_holder(ni))));
696
697 if((state.world.cb_type_get_type_bits(c) & military::cb_flag::always) == 0) {
698 bool cb_fabbed = false;
699 for(auto& fab_cb : state.world.nation_get_available_cbs(state.local_player_nation)) {
700 if(fab_cb.cb_type == c && fab_cb.target == n) {
701 cb_fabbed = true;
702 break;
703 }
704 }
705 if(!cb_fabbed) {
706 text::add_line_with_condition(state, contents, "alice_wg_condition_7", !((state.world.cb_type_get_type_bits(c) & military::cb_flag::is_not_constructing_cb) != 0));
707 auto totalpop = state.world.nation_get_demographics(state.local_player_nation, demographics::total);
708 auto jingoism_perc = totalpop > 0 ? state.world.nation_get_demographics(state.local_player_nation, demographics::to_key(state, state.culture_definitions.jingoism)) / totalpop : 0.0f;
709 if(state.world.war_get_is_great(w)) {
710 text::add_line_with_condition(state, contents, "alice_wg_condition_6", jingoism_perc >= state.defines.gw_wargoal_jingoism_requirement_mod,
711 text::variable_type::need, text::fp_two_places{ state.defines.gw_wargoal_jingoism_requirement_mod },
713 } else {
714 text::add_line_with_condition(state, contents, "alice_wg_condition_6", jingoism_perc >= state.defines.wargoal_jingoism_requirement,
715 text::variable_type::need, text::fp_two_places{ state.defines.wargoal_jingoism_requirement },
717 }
718 }
719 }
720 }
721 text::add_line_with_condition(state, contents, "alice_wg_condition_5", military::cb_instance_conditions_satisfied(state, state.local_player_nation, n, c, s, ni, state.world.national_identity_get_nation_from_identity_holder(ni)));
722
723 if(auto can_use = state.world.cb_type_get_can_use(c); can_use) {
724 text::add_line(state, contents, "alice_wg_usage_trigger");
725 ui::trigger_description(state, contents, can_use, trigger::to_generic(n), trigger::to_generic(state.local_player_nation), trigger::to_generic(n));
726 }
727 }
728};
729
730
731int32_t calculate_partial_score(sys::state& state, dcon::nation_id target, dcon::cb_type_id id, dcon::state_definition_id state_def, dcon::national_identity_id second_nation) {
732 int32_t cost = -1;
733
734 auto war = military::find_war_between(state, state.local_player_nation, target);
736
737 cost = military::peace_cost(state, military::find_war_between(state, state.local_player_nation, target), id, state.local_player_nation, target, dcon::nation_id{}, dcon::state_definition_id{}, dcon::national_identity_id{});
739
740 if(state_def) {
742 if(!second_nation) {
743 return -1;
744 }
746 if(!second_nation) {
747 return -1;
748 }
749 }
750
751 cost = 0;
752
753 // for each state ...
754 if(war) {
755 auto is_attacker = military::is_attacker(state, war, state.local_player_nation);
756 for(auto si : state.world.in_state_instance) {
757 if(si.get_definition() == state_def) {
758 auto wr = military::get_role(state, war, si.get_nation_from_state_ownership());
759 if((is_attacker && wr == military::war_role::defender) || (!is_attacker && wr == military::war_role::attacker)) {
761 cost += military::peace_cost(state, war, id, state.local_player_nation, si.get_nation_from_state_ownership(), dcon::nation_id{}, state_def, second_nation);
763 cost += military::peace_cost(state, war, id, state.local_player_nation, si.get_nation_from_state_ownership(), state.world.national_identity_get_nation_from_identity_holder(second_nation), state_def, dcon::national_identity_id{});
764 } else {
765 cost += military::peace_cost(state, war, id, state.local_player_nation, si.get_nation_from_state_ownership(), dcon::nation_id{}, state_def, dcon::national_identity_id{});
766 }
767 }
768 }
769 }
770 } else {
771 for(auto si : state.world.in_state_instance) {
772 if(si.get_definition() == state_def) {
773 auto n = si.get_nation_from_state_ownership();
774 auto no = n.get_overlord_as_subject().get_ruler();
775 if(n == target || no == target) {
777 cost += military::peace_cost(state, dcon::war_id{}, id, state.local_player_nation, si.get_nation_from_state_ownership(), dcon::nation_id{}, state_def, second_nation);
779 cost += military::peace_cost(state, dcon::war_id{}, id, state.local_player_nation, si.get_nation_from_state_ownership(), state.world.national_identity_get_nation_from_identity_holder(second_nation), state_def, dcon::national_identity_id{});
780 } else {
781 cost += military::peace_cost(state, dcon::war_id{}, id, state.local_player_nation, si.get_nation_from_state_ownership(), dcon::nation_id{}, state_def, dcon::national_identity_id{});
782 }
783 }
784 }
785 }
786 }
787 }
789 if(second_nation) {
790 cost = military::peace_cost(state, military::find_war_between(state, state.local_player_nation, target), id, state.local_player_nation, target, dcon::nation_id{}, dcon::state_definition_id{}, second_nation);
791 }
793 if(second_nation) {
794 cost = military::peace_cost(state, military::find_war_between(state, state.local_player_nation, target), id, state.local_player_nation, target, state.world.national_identity_get_nation_from_identity_holder(second_nation), dcon::state_definition_id{}, dcon::national_identity_id{});
795 }
796 }
797 return cost;
798}
799
801public:
802 void populate_layout(sys::state& state, text::endless_layout& contents) noexcept override {
803 auto id = retrieve<dcon::cb_type_id>(state, parent);
804 auto fat_cb = dcon::fatten(state.world, id);
805 auto box = text::open_layout_box(contents);
806 auto target = retrieve<dcon::nation_id>(state, parent);
807
809
810 if(id) {
812 text::localised_format_box(state, contents, box, std::string_view("add_wargoal_wargoal"), sub);
813 } else {
814 auto str = text::produce_simple_string(state, "nocasusbelli");
815 text::add_to_substitution_map(sub, text::variable_type::goal, std::string_view(str));
816 text::localised_format_box(state, contents, box, std::string_view("add_wargoal_wargoal"), sub);
817 }
818 text::close_layout_box(contents, box);
819
820 if(id) {
821 auto state_def = retrieve<dcon::state_definition_id>(state, parent);
822 auto second_nation = retrieve<dcon::national_identity_id>(state, parent);
823 auto cost = calculate_partial_score(state, target, id, state_def, second_nation);
824 if(cost != -1) {
825 text::add_line(state, contents, "add_wargoal_peace_cost", text::variable_type::cost, int64_t(cost));
826 }
827 }
828
829 }
830};
831
833public:
834 void populate_layout(sys::state& state, text::endless_layout& contents) noexcept override {
835 auto id = retrieve<dcon::cb_type_id>(state, parent);
836
837 auto content = retrieve<dcon::nation_id>(state, parent);
838 auto sdef = retrieve<dcon::state_definition_id>(state, parent);
839 auto nid = retrieve<dcon::national_identity_id>(state, parent);
840 auto fat_cb = dcon::fatten(state.world, id);
841 auto box = text::open_layout_box(contents);
842
843 if(id) {
846 text::add_to_substitution_map(sub, text::variable_type::third, nid); // Third Party Country
850 text::add_to_layout_box(state, contents, box, fat_cb.get_long_desc(), sub);
851 }
852 text::close_layout_box(contents, box);
853 }
854};
855
857public:
858 bool show = true;
859
860 void button_action(sys::state& state) noexcept override {
861 if(parent) {
862 bool content = retrieve<bool>(state, parent);
863 Cyto::Any b_payload = element_selection_wrapper<bool>{ !content };
864 parent->impl_get(state, b_payload);
865 }
866 }
867
868 void on_update(sys::state& state) noexcept override {
869 bool content = retrieve<bool>(state, parent);
870 frame = content ? 1 : 0;
871 auto war = retrieve<dcon::war_id>(state, parent);
872 show = !bool(war);
873 }
874
875 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
876 if(show)
878 }
881 }
882 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
883 if(!show)
884 return;
885
886 auto target = retrieve<dcon::nation_id>(state, parent);
887
888 bool has_allies = false;
889 for(auto dr : state.world.nation_get_diplomatic_relation(state.local_player_nation)) {
890 if(dr.get_are_allied()) {
891 auto other = dr.get_related_nations(0) == state.local_player_nation ? dr.get_related_nations(1) : dr.get_related_nations(0);
892 if(other.get_is_player_controlled()) {
893 text::add_line(state, contents, "att_call_is_human", text::variable_type::x, other.id);
894 } else {
895 if(target == other || military::are_in_common_war(state, target, other) || military::are_at_war(state, target, other) || nations::are_allied(state, target, other)) {
896 text::add_line(state, contents, "att_call_will_decline", text::variable_type::x, other.id);
897 } else {
898 bool will_join = false;
899
900 if(military::can_use_cb_against(state, other, target))
901 will_join = true;
902 if(state.world.nation_get_ai_rival(other) == target)
903 will_join = true;
904
905 // TODO: check subjects, other nations that can be expected to defensively answer the CTA
906
907 if(will_join) {
908 text::add_line(state, contents, "att_call_will_accept", text::variable_type::x, other.id);
909 } else {
910 text::add_line(state, contents, "att_call_will_decline", text::variable_type::x, other.id);
911 }
912 }
913 }
914 has_allies = true;
915 }
916 }
917 if(!has_allies) {
918 text::add_line(state, contents, "att_call_no_allies");
919 }
920 }
921};
922
924public:
925 bool show = true;
926
927 void on_update(sys::state& state) noexcept override {
928 auto war = retrieve<dcon::war_id>(state, parent);
929 show = !bool(war);
930 }
931
932 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
933 if(show)
935 }
936};
937
939public:
940 void button_action(sys::state& state) noexcept override {
941 if(parent) {
942 parent->set_visible(state, false);
943 }
945 }
946};
947
948class diplomacy_declare_war_dialog : public window_element_base { // eu3dialogtype
949private:
950 wargoal_setup_window* wargoal_setup_win = nullptr;
951 wargoal_country_select_window* wargoal_country_win = nullptr;
952
953 dcon::cb_type_id cb_to_use;
954 dcon::state_definition_id target_state;
955 dcon::national_identity_id target_country;
956 bool will_call_allies = false;
957 bool wargoal_decided_upon = false;
958
959 void select_mode(sys::state& state) {
961 seldata.single_state_select = true;
962 dcon::nation_id target = retrieve<dcon::nation_id>(state, parent);
963 auto actor = state.local_player_nation;
964 dcon::cb_type_id cb = cb_to_use;
965 auto war = military::find_war_between(state, actor, target);
966 auto secondary_tag = target_country;
967 auto allowed_substate_regions = state.world.cb_type_get_allowed_substate_regions(cb);
968 if(allowed_substate_regions) {
969 for(auto v : state.world.nation_get_overlord_as_ruler(target)) {
970 if(v.get_subject().get_is_substate()) {
971 for(auto si : state.world.nation_get_state_ownership(target)) {
972 if(trigger::evaluate(state, allowed_substate_regions, trigger::to_generic(si.get_state().id), trigger::to_generic(actor), trigger::to_generic(actor))) {
973 auto def = si.get_state().get_definition().id;
974 if(std::find(seldata.selectable_states.begin(), seldata.selectable_states.end(), def) == seldata.selectable_states.end()) {
975 if(!military::war_goal_would_be_duplicate(state, state.local_player_nation, war, v.get_subject(), cb, def, dcon::national_identity_id{}, dcon::nation_id{})) {
976 seldata.selectable_states.push_back(def);
977 }
978 }
979 }
980 }
981 }
982 }
983 } else {
984 auto allowed_states = state.world.cb_type_get_allowed_states(cb);
985 if(auto ac = state.world.cb_type_get_allowed_countries(cb); ac) {
986 auto in_nation = state.world.national_identity_get_nation_from_identity_holder(secondary_tag);
987 for(auto si : state.world.nation_get_state_ownership(target)) {
988 if(trigger::evaluate(state, allowed_states, trigger::to_generic(si.get_state().id), trigger::to_generic(actor), trigger::to_generic(in_nation))) {
989 auto def = si.get_state().get_definition().id;
990 if(!military::war_goal_would_be_duplicate(state, state.local_player_nation, war, target, cb, def, secondary_tag, dcon::nation_id{})) {
991 seldata.selectable_states.push_back(def);
992 }
993 }
994 }
995 } else {
996 for(auto si : state.world.nation_get_state_ownership(target)) {
997 if(trigger::evaluate(state, allowed_states, trigger::to_generic(si.get_state().id), trigger::to_generic(actor), trigger::to_generic(actor))) {
998 auto def = si.get_state().get_definition().id;
999 if(!military::war_goal_would_be_duplicate(state, state.local_player_nation, war, target, cb, def, dcon::national_identity_id{}, dcon::nation_id{})) {
1000 seldata.selectable_states.push_back(def);
1001 }
1002 }
1003 }
1004 }
1005 }
1006 seldata.on_select = [&](sys::state& state, dcon::state_definition_id sdef) {
1007 target_state = sdef;
1008 wargoal_decided_upon = true;
1009 wargoal_setup_win->set_visible(state, true);
1010 wargoal_country_win->set_visible(state, false);
1012 };
1013 seldata.on_cancel = [&](sys::state& state) {
1014 target_state = dcon::state_definition_id{};
1016 wargoal_setup_win->set_visible(state, false);
1017 wargoal_country_win->set_visible(state, true);
1018 } else {
1019 cb_to_use = dcon::cb_type_id{};
1020 wargoal_decided_upon = false;
1021 wargoal_setup_win->set_visible(state, true);
1022 wargoal_country_win->set_visible(state, false);
1023 }
1025 };
1026 state.start_state_selection(seldata);
1027 }
1028public:
1030 cb_to_use = dcon::cb_type_id{};
1031 target_state = dcon::state_definition_id{};
1032 target_country = dcon::national_identity_id{};
1033 will_call_allies = false;
1034 wargoal_decided_upon = false;
1035 wargoal_setup_win->set_visible(state, true);
1036 wargoal_country_win->set_visible(state, false);
1037 }
1038
1039 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1040 if(name == "background") {
1041 auto ptr = make_element_by_type<draggable_target>(state, id);
1042 ptr->base_data.size = base_data.size; // Nudge size for proper sizing
1043 return ptr;
1044 } else if(name == "diplo_declarewar_bg") {
1045 return make_element_by_type<image_element_base>(state, id);
1046 } else if(name == "leftshield") {
1047 return make_element_by_type<nation_player_flag>(state, id);
1048 } else if(name == "rightshield") {
1049 return make_element_by_type<flag_button>(state, id);
1050 } else if(name == "title") {
1051 return make_element_by_type<diplomacy_declare_war_title>(state, id);
1052 } else if(name == "description") {
1053 return make_element_by_type<diplomacy_declare_war_description1>(state, id);
1054 } else if(name == "wargoal_add_effect") {
1055 return make_element_by_type<diplomacy_wargoal_add_window>(state, id);
1056 } else if(name == "wargoal_success_effect") {
1057 return make_element_by_type<diplomacy_wargoal_success_window>(state, id);
1058 } else if(name == "wargoal_failure_effect") {
1059 return make_element_by_type<diplomacy_wargoal_failure_window>(state, id);
1060 } else if(name == "description2") {
1061 return make_element_by_type<diplomacy_declare_war_description2>(state, id);
1062 } else if(name == "acceptance") {
1063 return make_element_by_type<simple_text_element_base>(state, id);
1064 } else if(name == "call_allies_checkbox") {
1065 return make_element_by_type<diplomacy_declare_war_call_allies_checkbox>(state, id);
1066 } else if(name == "call_allies_text") {
1067 return make_element_by_type<diplomacy_declare_war_call_allies_text>(state, id);
1068 } else if(name == "agreebutton") {
1069 return make_element_by_type<diplomacy_declare_war_agree_button>(state, id);
1070 } else if(name == "declinebutton") {
1071 return make_element_by_type<cancel_pick_wg_button>(state, id);
1072 } else if(name == "wargoal_setup") {
1073 auto ptr = make_element_by_type<wargoal_setup_window>(state, id);
1074 wargoal_setup_win = ptr.get();
1075 ptr->set_visible(state, true);
1076 return ptr;
1077 } else if(name == "wargoal_state_select") {
1078 return make_element_by_type<invisible_element>(state, id);
1079 } else if(name == "wargoal_country_select") {
1080 auto ptr = make_element_by_type<wargoal_country_select_window>(state, id);
1081 wargoal_country_win = ptr.get();
1082 ptr->set_visible(state, false);
1083 return ptr;
1084 } else {
1085 return nullptr;
1086 }
1087 }
1088
1089 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
1090 if(payload.holds_type<dcon::war_id>()) {
1091 const dcon::nation_id n = retrieve<dcon::nation_id>(state, parent);
1092 const dcon::war_id w = military::find_war_between(state, state.local_player_nation, n);
1093 payload.emplace<dcon::war_id>(w);
1095 } else if(payload.holds_type< check_wg_completion>()) {
1096 payload.emplace<check_wg_completion>(check_wg_completion{ wargoal_decided_upon });
1098 } else if(payload.holds_type<element_selection_wrapper<dcon::cb_type_id>>()) {
1099 cb_to_use = any_cast<element_selection_wrapper<dcon::cb_type_id>>(payload).data;
1100 if(!cb_to_use) {
1101 wargoal_decided_upon = false;
1103 wargoal_setup_win->set_visible(state, false);
1104 wargoal_country_win->set_visible(state, true);
1105 } else if(military::cb_requires_selection_of_a_state(state, cb_to_use)) {
1106 wargoal_setup_win->set_visible(state, true);
1107 wargoal_country_win->set_visible(state, false);
1108 select_mode(state);
1109 } else {
1110 wargoal_decided_upon = true;
1111 wargoal_setup_win->set_visible(state, true);
1112 wargoal_country_win->set_visible(state, false);
1113 }
1116 } else if(payload.holds_type<element_selection_wrapper<dcon::national_identity_id>>()) {
1117 target_country = any_cast<element_selection_wrapper<dcon::national_identity_id>>(payload).data;
1118 if(target_country) { // goto next step
1120 wargoal_setup_win->set_visible(state, true);
1121 wargoal_country_win->set_visible(state, false);
1122 select_mode(state);
1123 } else {
1124 wargoal_decided_upon = true;
1125 wargoal_setup_win->set_visible(state, true);
1126 wargoal_country_win->set_visible(state, false);
1127 }
1128 } else {
1129 wargoal_decided_upon = false;
1130 cb_to_use = dcon::cb_type_id{};
1131 wargoal_setup_win->set_visible(state, true);
1132 wargoal_country_win->set_visible(state, false);
1133 }
1136 } else if(payload.holds_type<element_selection_wrapper<bool>>()) {
1137 will_call_allies = any_cast<element_selection_wrapper<bool>>(payload).data;
1140 } else if(payload.holds_type<dcon::cb_type_id>()) {
1141 payload.emplace<dcon::cb_type_id>(cb_to_use);
1143 } else if(payload.holds_type<dcon::state_definition_id>()) {
1144 payload.emplace<dcon::state_definition_id>(target_state);
1146 } else if(payload.holds_type<dcon::national_identity_id>()) {
1147 payload.emplace<dcon::national_identity_id>(target_country);
1149 } else if(payload.holds_type<bool>()) {
1150 payload.emplace<bool>(will_call_allies);
1152 }
1154 }
1155};
1156
1158 dcon::nation_id n;
1159};
1161 dcon::nation_id n;
1162};
1164 dcon::nation_id n;
1165};
1166
1168public:
1169 void populate_layout(sys::state& state, text::endless_layout& contents) noexcept override {
1170 auto id = retrieve<dcon::cb_type_id>(state, parent);
1171 auto fat_cb = dcon::fatten(state.world, id);
1172 auto box = text::open_layout_box(contents);
1173 auto target = retrieve<get_target>(state, parent).n;
1174
1176
1177 if(id) {
1179 text::localised_format_box(state, contents, box, std::string_view("add_wargoal_wargoal"), sub);
1180 } else {
1181 auto str = text::produce_simple_string(state, "nocasusbelli");
1182 text::add_to_substitution_map(sub, text::variable_type::goal, std::string_view(str));
1183 text::localised_format_box(state, contents, box, std::string_view("add_wargoal_wargoal"), sub);
1184 }
1185 text::close_layout_box(contents, box);
1186
1187 if(id) {
1188 auto state_def = retrieve<dcon::state_definition_id>(state, parent);
1189 auto second_nation = retrieve<dcon::national_identity_id>(state, parent);
1190 auto cost = calculate_partial_score(state, target, id, state_def, second_nation);
1191 if(cost != -1) {
1192 text::add_line(state, contents, "add_wargoal_peace_cost", text::variable_type::cost, int64_t(cost));
1193 }
1194 }
1195
1196 }
1197};
1198
1200public:
1201 void populate_layout(sys::state& state, text::endless_layout& contents) noexcept override {
1202 auto id = retrieve<dcon::cb_type_id>(state, parent);
1203
1204 auto content = retrieve<get_target>(state, parent).n;
1205 auto dest = retrieve<get_offer_to>(state, parent).n;
1206 auto staat = retrieve<dcon::state_definition_id>(state, parent);
1207 auto nacion = retrieve<dcon::national_identity_id>(state, parent);
1208
1209 auto fat_cb = dcon::fatten(state.world, id);
1210
1211 auto box = text::open_layout_box(contents);
1212
1213 if(id) {
1215 text::add_to_substitution_map(sub, text::variable_type::recipient, content); // Target Nation
1216 text::add_to_substitution_map(sub, text::variable_type::third, nacion); // Third Party Country
1220
1221 text::add_to_layout_box(state, contents, box, fat_cb.get_long_desc(), sub);
1222 }
1223
1224 text::close_layout_box(contents, box);
1225 }
1226};
1227
1228
1230public:
1231 void on_update(sys::state& state) noexcept override {
1232 auto wg_ready = retrieve<check_wg_completion>(state, parent).done;
1233 if(!wg_ready) {
1234 disabled = true;
1235 return;
1236 }
1237 auto ni = retrieve<dcon::national_identity_id>(state, parent);
1238 disabled = !command::can_invite_to_crisis(state, state.local_player_nation, retrieve<get_offer_to>(state, parent).n, retrieve<get_target>(state, parent).n, retrieve<dcon::cb_type_id>(state, parent), retrieve<dcon::state_definition_id>(state, parent), ni, state.world.national_identity_get_nation_from_identity_holder(ni));
1239 }
1240
1241 void button_action(sys::state& state) noexcept override {
1242 auto ni = retrieve<dcon::national_identity_id>(state, parent);
1243 command::invite_to_crisis(state, state.local_player_nation, retrieve<get_offer_to>(state, parent).n, retrieve<get_target>(state, parent).n, retrieve<dcon::cb_type_id>(state, parent), retrieve<dcon::state_definition_id>(state, parent), ni, state.world.national_identity_get_nation_from_identity_holder(ni));
1244 parent->set_visible(state, false);
1245 }
1246
1249 }
1250
1251 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1252 auto wg_ready = retrieve<check_wg_completion>(state, parent).done;
1253 if(!wg_ready) {
1254 text::add_line_with_condition(state, contents, "wg_not_ready", false);
1255 return;
1256 }
1257 }
1258};
1259
1261public:
1262 void on_create(sys::state& state) noexcept override {
1264 set_text(state, text::produce_simple_string(state, "crisis_offertitle"));
1265 }
1266};
1267
1268
1270public:
1271 void on_update(sys::state& state) noexcept override {
1272 auto cb = retrieve<dcon::cb_type_id>(state, parent);
1273 auto target = retrieve<get_target>(state, parent).n;
1274 auto offered = retrieve<get_offer_to>(state, parent).n;
1275
1276 auto infamy = military::crisis_cb_addition_infamy_cost(state, cb, offered, target) *
1277 state.defines.crisis_wargoal_infamy_mult;
1278
1279 if(infamy > 0) {
1281 set_text(state, text::format_float(infamy, 1));
1282 } else {
1284 set_text(state, "0.0");
1285 }
1286 }
1287};
1288
1289
1291public:
1292 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1293 if(name == "wargoal_gain_effect_text") {
1294 return make_element_by_type<wargoal_add_header>(state, id);
1295 } else if(name == "prestige_icon") {
1296 return make_element_by_type<image_element_base>(state, id);
1297 } else if(name == "prestige") {
1298 return make_element_by_type<fixed_zero>(state, id);
1299 } else if(name == "infamy_icon") {
1300 return make_element_by_type<image_element_base>(state, id);
1301 } else if(name == "infamy") {
1302 return make_element_by_type<wargoal_offer_add_infamy>(state, id);
1303 } else if(name == "militancy_icon") {
1304 return make_element_by_type<image_element_base>(state, id);
1305 } else if(name == "militancy") {
1306 return make_element_by_type<fixed_zero>(state, id);
1307 } else {
1308 return nullptr;
1309 }
1310 }
1311};
1312
1313class wargoal_offer_type_listbox : public listbox_element_base<wargoal_type_item, dcon::cb_type_id> {
1314protected:
1315 std::string_view get_row_element_name() override {
1316 return "wargoal_item";
1317 }
1318
1319public:
1320 void on_update(sys::state& state) noexcept override {
1321 row_contents.clear();
1322
1323 auto selected_cb = retrieve<dcon::cb_type_id>(state, parent);
1324 if(selected_cb) {
1325 row_contents.push_back(selected_cb);
1326 update(state);
1327 return;
1328 }
1329
1330 dcon::nation_id actor = retrieve<get_offer_to>(state, parent).n;
1331 dcon::nation_id content = retrieve<get_target>(state, parent).n;
1332
1333 for(auto cb_type : state.world.in_cb_type) {
1334
1335 if(military::cb_conditions_satisfied(state, actor, content, cb_type)) {
1336 if((cb_type.get_type_bits() & military::cb_flag::always) != 0)
1337 row_contents.push_back(cb_type);
1338 else if((cb_type.get_type_bits() & military::cb_flag::is_not_constructing_cb) == 0)
1339 row_contents.push_back(cb_type);
1340 }
1341 }
1342
1343 update(state);
1344 }
1345};
1346
1348public:
1349 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1350 if(name == "country_list") {
1351 return make_element_by_type<wargoal_offer_type_listbox>(state, id);
1352 } else if(name == "cancel_select") {
1353 return make_element_by_type<wargoal_cancel_button>(state, id);
1354 } else {
1355 return nullptr;
1356 }
1357 }
1358};
1359
1360
1362public:
1363 void button_action(sys::state& state) noexcept override {
1364 auto n = retrieve<dcon::nation_id>(state, parent);
1365 send(state, parent, set_target{ n });
1366 }
1367
1368 void on_update(sys::state& state) noexcept override {
1369 auto n = retrieve<dcon::nation_id>(state, parent);
1371 }
1374 }
1375 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1376 dcon::cb_type_id cb = retrieve<dcon::cb_type_id>(state, parent);
1377 if(auto allowed_countries = state.world.cb_type_get_allowed_countries(cb); allowed_countries) {
1378 dcon::nation_id target = retrieve<dcon::nation_id>(state, parent);
1379 auto holder = state.world.national_identity_get_nation_from_identity_holder(retrieve<dcon::national_identity_id>(state, parent));
1380 trigger_description(state, contents, allowed_countries, trigger::to_generic(target), trigger::to_generic(state.local_player_nation), trigger::to_generic(holder));
1381 }
1382 }
1383};
1384
1386public:
1387 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1388 if(name == "select_country") {
1389 return make_element_by_type<wargoal_target_country_item_button>(state, id);
1390 } else {
1391 return nullptr;
1392 }
1393 }
1394};
1395
1396class wargoal_target_country_listbox : public listbox_element_base<wargoal_target_country_item, dcon::nation_id> {
1397protected:
1398 std::string_view get_row_element_name() override {
1399 return "wargoal_country_item";
1400 }
1401
1402public:
1403 void on_update(sys::state& state) noexcept override {
1404 row_contents.clear();
1405 for(auto& par : state.crisis_participants) {
1406 if(!par.id) {
1407 break; // not in crisis
1408 }
1409 if(!par.merely_interested) {
1410 if(state.local_player_nation == state.primary_crisis_attacker && !par.supports_attacker)
1411 row_contents.push_back(par.id);
1412 else if(state.local_player_nation == state.primary_crisis_defender && par.supports_attacker)
1413 row_contents.push_back(par.id);
1414 }
1415 }
1416
1417 update(state);
1418 }
1419};
1420
1422public:
1423 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1424 if(name == "wargoal_list") {
1425 return make_element_by_type<wargoal_target_country_listbox>(state, id);
1426 } else {
1427 return nullptr;
1428 }
1429 }
1430};
1431
1432class wargoal_offer_country_listbox : public listbox_element_base<wargoal_country_item, dcon::national_identity_id> {
1433protected:
1434 std::string_view get_row_element_name() override {
1435 return "wargoal_country_item";
1436 }
1437
1438public:
1439 void on_update(sys::state& state) noexcept override {
1440 row_contents.clear();
1441
1442 dcon::nation_id target = retrieve<get_target>(state, parent).n;
1443 auto actor = retrieve<get_offer_to>(state, parent).n;
1444 dcon::cb_type_id cb = retrieve<dcon::cb_type_id>(state, parent);
1445
1446 dcon::trigger_key allowed_countries = state.world.cb_type_get_allowed_countries(cb);
1447 if(!allowed_countries) {
1448 update(state);
1449 return;
1450 }
1451
1452 for(auto n : state.world.in_nation) {
1453 if(n != actor && trigger::evaluate(state, allowed_countries, trigger::to_generic(target), trigger::to_generic(actor), trigger::to_generic(n.id))) {
1454 row_contents.push_back(state.world.nation_get_identity_from_identity_holder(n));
1455 }
1456 }
1457 update(state);
1458 }
1459};
1460
1462public:
1463 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1464 if(name == "country_list") {
1465 return make_element_by_type<wargoal_offer_country_listbox>(state, id);
1466 } else if(name == "cancel_select") {
1467 return make_element_by_type<wargoal_cancel_country_select>(state, id);
1468 } else {
1469 return nullptr;
1470 }
1471 }
1472};
1473
1475private:
1476 wargoal_offer_setup_window* wargoal_setup_win = nullptr;
1477 wargoal_offer_country_select_window* wargoal_country_win = nullptr;
1478 wargoal_target_country_select_window* wargoal_target_win = nullptr;
1479
1480 dcon::nation_id offer_made_to;
1481 dcon::nation_id wargoal_against;
1482 dcon::cb_type_id cb_to_use;
1483 dcon::state_definition_id target_state;
1484 dcon::national_identity_id target_country;
1485 bool will_call_allies = false;
1486 bool wargoal_decided_upon = false;
1487
1488 void select_mode(sys::state& state) {
1490 seldata.single_state_select = true;
1491 // Populate selectable states...
1492 dcon::nation_id target = wargoal_against;
1493 auto actor = state.local_player_nation;
1494 dcon::cb_type_id cb = cb_to_use;
1495 auto secondary_tag = target_country;
1496 auto allowed_substate_regions = state.world.cb_type_get_allowed_substate_regions(cb);
1497 if(allowed_substate_regions) {
1498 for(auto v : state.world.nation_get_overlord_as_ruler(target)) {
1499 if(v.get_subject().get_is_substate()) {
1500 for(auto si : state.world.nation_get_state_ownership(target)) {
1501 if(trigger::evaluate(state, allowed_substate_regions, trigger::to_generic(si.get_state().id), trigger::to_generic(actor), trigger::to_generic(actor))) {
1502 seldata.selectable_states.push_back(si.get_state().get_definition().id);
1503 }
1504 }
1505 }
1506 }
1507 } else {
1508 auto allowed_states = state.world.cb_type_get_allowed_states(cb);
1509 if(auto allowed_countries = state.world.cb_type_get_allowed_countries(cb); allowed_countries) {
1510 auto in_nation = state.world.national_identity_get_nation_from_identity_holder(secondary_tag);
1511 for(auto si : state.world.nation_get_state_ownership(target)) {
1512 if(trigger::evaluate(state, allowed_states, trigger::to_generic(si.get_state().id), trigger::to_generic(actor), trigger::to_generic(in_nation))) {
1513 seldata.selectable_states.push_back(si.get_state().get_definition().id);
1514 }
1515 }
1516 } else {
1517 for(auto si : state.world.nation_get_state_ownership(target)) {
1518 if(trigger::evaluate(state, allowed_states, trigger::to_generic(si.get_state().id), trigger::to_generic(actor), trigger::to_generic(actor))) {
1519 seldata.selectable_states.push_back(si.get_state().get_definition().id);
1520 }
1521 }
1522 }
1523 }
1524 seldata.on_select = [&](sys::state& state, dcon::state_definition_id sdef) {
1525 target_state = sdef;
1526 wargoal_decided_upon = true;
1527 wargoal_setup_win->set_visible(state, true);
1528 wargoal_country_win->set_visible(state, false);
1530 };
1531 seldata.on_cancel = [&](sys::state& state) {
1532 target_state = dcon::state_definition_id{};
1534 wargoal_setup_win->set_visible(state, false);
1535 //wargoal_state_win->set_visible(state, false);
1536 wargoal_country_win->set_visible(state, true);
1537 } else {
1538 cb_to_use = dcon::cb_type_id{};
1539 wargoal_decided_upon = false;
1540 wargoal_setup_win->set_visible(state, true);
1541 //wargoal_state_win->set_visible(state, false);
1542 wargoal_country_win->set_visible(state, false);
1543 }
1545 };
1546 state.start_state_selection(seldata);
1547 }
1548public:
1549 void reset_window(sys::state& state, dcon::nation_id offer_to) {
1550 wargoal_against = dcon::nation_id{};
1551 offer_made_to = offer_to;
1552 cb_to_use = dcon::cb_type_id{};
1553 target_state = dcon::state_definition_id{};
1554 target_country = dcon::national_identity_id{};
1555 will_call_allies = false;
1556 wargoal_decided_upon = false;
1557
1558 wargoal_setup_win->set_visible(state, false);
1559 //wargoal_state_win->set_visible(state, false);
1560 wargoal_country_win->set_visible(state, false);
1561 wargoal_target_win->set_visible(state, true);
1562 }
1563
1564 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1565 if(name == "background") {
1566 auto ptr = make_element_by_type<draggable_target>(state, id);
1567 ptr->base_data.size = base_data.size; // Nudge size for proper sizing
1568 return ptr;
1569 } else if(name == "leftshield") {
1570 return make_element_by_type<nation_player_flag>(state, id);
1571 } else if(name == "rightshield") {
1572 return make_element_by_type<flag_button>(state, id);
1573 } else if(name == "title") {
1574 return make_element_by_type<wargoal_offer_title>(state, id);
1575 } else if(name == "description") {
1576 return make_element_by_type<wargoal_offer_description1>(state, id);
1577 } else if(name == "wargoal_add_effect") {
1578 return make_element_by_type<wargoal_offer_add_window>(state, id);
1579 } else if(name == "wargoal_success_effect" || name == "wargoal_failure_effect") {
1580 return make_element_by_type<invisible_element>(state, id);
1581 } else if(name == "description2") {
1582 return make_element_by_type<wargoal_offer_description2>(state, id);
1583 } else if(name == "acceptance") {
1584 return make_element_by_type<simple_text_element_base>(state, id);
1585 } else if(name == "call_allies_checkbox") {
1586 return make_element_by_type<invisible_element>(state, id);
1587 } else if(name == "call_allies_text") {
1588 return make_element_by_type<invisible_element>(state, id);
1589 } else if(name == "agreebutton") {
1590 return make_element_by_type<wargoal_offer_agree_button>(state, id);
1591 } else if(name == "declinebutton") {
1592 return make_element_by_type<cancel_pick_wg_button>(state, id);
1593 } else if(name == "wargoal_setup") {
1594 auto ptr = make_element_by_type<wargoal_target_country_select_window>(state, id);
1595 wargoal_target_win = ptr.get();
1596 ptr->set_visible(state, true);
1597 return ptr;
1598 } else if(name == "wargoal_state_select") {
1599 return make_element_by_type<invisible_element>(state, id);
1600 } else if(name == "wargoal_country_select") {
1601 {
1602 auto ptr = make_element_by_type<wargoal_offer_setup_window>(state, id);
1603 wargoal_setup_win = ptr.get();
1604 ptr->set_visible(state, false);
1605 add_child_to_front(std::move(ptr));
1606 }
1607 {
1608 auto ptr = make_element_by_type<wargoal_offer_country_select_window>(state, id);
1609 wargoal_country_win = ptr.get();
1610 ptr->set_visible(state, false);
1611 return ptr;
1612 }
1613 } else {
1614 return nullptr;
1615 }
1616 }
1617
1618 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
1619 if(payload.holds_type<dcon::nation_id>()) {
1620 payload.emplace<dcon::nation_id>(offer_made_to);
1621 } else if(payload.holds_type<get_target>()) {
1622 payload.emplace<get_target>(get_target{ wargoal_against });
1623 } else if(payload.holds_type<get_offer_to>()) {
1624 payload.emplace<get_offer_to>(get_offer_to{ offer_made_to });
1625 } else if(payload.holds_type< check_wg_completion>()) {
1626 payload.emplace<check_wg_completion>(check_wg_completion{ wargoal_decided_upon });
1628 } else if(payload.holds_type<element_selection_wrapper<dcon::cb_type_id>>()) {
1629 cb_to_use = any_cast<element_selection_wrapper<dcon::cb_type_id>>(payload).data;
1630 if(!cb_to_use) {
1631 wargoal_against = dcon::nation_id{};
1632 cb_to_use = dcon::cb_type_id{};
1633 target_state = dcon::state_definition_id{};
1634 target_country = dcon::national_identity_id{};
1635 wargoal_decided_upon = false;
1636
1637 wargoal_setup_win->set_visible(state, false);
1638 //wargoal_state_win->set_visible(state, false);
1639 wargoal_country_win->set_visible(state, false);
1640 wargoal_target_win->set_visible(state, true);
1642 wargoal_setup_win->set_visible(state, false);
1643 //wargoal_state_win->set_visible(state, false);
1644 wargoal_country_win->set_visible(state, true);
1645 wargoal_target_win->set_visible(state, false);
1646 } else if(military::cb_requires_selection_of_a_state(state, cb_to_use)) {
1647 wargoal_setup_win->set_visible(state, false);
1648 //wargoal_state_win->set_visible(state, true);
1649 wargoal_country_win->set_visible(state, false);
1650 wargoal_target_win->set_visible(state, false);
1651 select_mode(state);
1652 } else {
1653 wargoal_decided_upon = true;
1654 wargoal_setup_win->set_visible(state, true);
1655 //wargoal_state_win->set_visible(state, false);
1656 wargoal_country_win->set_visible(state, false);
1657 wargoal_target_win->set_visible(state, false);
1658 }
1661 } else if(payload.holds_type<element_selection_wrapper<dcon::national_identity_id>>()) {
1662 target_country = any_cast<element_selection_wrapper<dcon::national_identity_id>>(payload).data;
1663
1664 if(target_country) { // goto next step
1666 wargoal_setup_win->set_visible(state, true);
1667 //wargoal_state_win->set_visible(state, true);
1668 wargoal_country_win->set_visible(state, false);
1669 wargoal_target_win->set_visible(state, true);
1670 select_mode(state);
1671 } else {
1672 wargoal_setup_win->set_visible(state, true);
1673 //wargoal_state_win->set_visible(state, false);
1674 wargoal_country_win->set_visible(state, false);
1675 wargoal_target_win->set_visible(state, false);
1676 wargoal_decided_upon = true;
1677 }
1678 } else {
1679 wargoal_decided_upon = false;
1680 cb_to_use = dcon::cb_type_id{};
1681 wargoal_setup_win->set_visible(state, true);
1682 //wargoal_state_win->set_visible(state, false);
1683 wargoal_country_win->set_visible(state, false);
1684 wargoal_target_win->set_visible(state, false);
1685 }
1686
1689 } else if(payload.holds_type<set_target>()) {
1690 wargoal_against = any_cast<set_target>(payload).n;
1691 if(wargoal_against) {
1692 wargoal_decided_upon = false;
1693 cb_to_use = dcon::cb_type_id{};
1694 wargoal_setup_win->set_visible(state, true);
1695 //wargoal_state_win->set_visible(state, false);
1696 wargoal_country_win->set_visible(state, false);
1697 wargoal_target_win->set_visible(state, false);
1698 }
1700 } else if(payload.holds_type<dcon::cb_type_id>()) {
1701 payload.emplace<dcon::cb_type_id>(cb_to_use);
1703 } else if(payload.holds_type<dcon::state_definition_id>()) {
1704 payload.emplace<dcon::state_definition_id>(target_state);
1706 } else if(payload.holds_type<dcon::national_identity_id>()) {
1707 payload.emplace<dcon::national_identity_id>(target_country);
1709 } else if(payload.holds_type<bool>()) {
1710 payload.emplace<bool>(will_call_allies);
1712 }
1714 }
1715};
1716
1717}
dcon::text_key get_name() noexcept
void set_button_text(sys::state &state, std::string const &new_text)
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void button_action(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
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 render(sys::state &state, int32_t x, int32_t y) 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_update(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
void populate_layout(sys::state &state, text::endless_layout &contents) noexcept override
void populate_layout(sys::state &state, text::endless_layout &contents) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_update(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) 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
message_result impl_get(sys::state &state, Cyto::Any &payload) noexcept
element_data base_data
void set_visible(sys::state &state, bool vis)
void on_create(sys::state &state) noexcept override
void reset_window(sys::state &state, dcon::nation_id offer_to)
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 on_create(sys::state &state) noexcept override
void set_text(sys::state &state, std::string const &new_text)
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_create(sys::state &state) noexcept override
void set_text(sys::state &state, std::string const &new_text)
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 on_update(sys::state &state) noexcept override
void button_action(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 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
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
std::string_view get_row_element_name() override
void on_update(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void 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) 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::string_view get_row_element_name() override
void on_update(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void populate_layout(sys::state &state, text::endless_layout &contents) noexcept override
void populate_layout(sys::state &state, text::endless_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
void on_create(sys::state &state) noexcept override
std::string_view get_row_element_name() override
void on_update(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void 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
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
std::string_view get_row_element_name() override
void on_update(sys::state &state) noexcept override
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 button_action(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void 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
std::string_view get_row_element_name() override
void on_update(sys::state &state) noexcept override
bool can_invite_to_crisis(sys::state &state, dcon::nation_id source, dcon::nation_id invitation_to, dcon::nation_id target, dcon::cb_type_id primary_cb, dcon::state_definition_id cb_state, dcon::national_identity_id cb_tag, dcon::nation_id cb_secondary_nation)
Definition: commands.cpp:4271
bool can_add_war_goal(sys::state &state, dcon::nation_id source, dcon::war_id w, dcon::nation_id target, dcon::cb_type_id cb_type, dcon::state_definition_id cb_state, dcon::national_identity_id cb_tag, dcon::nation_id cb_secondary_nation)
Definition: commands.cpp:2715
bool can_declare_war(sys::state &state, dcon::nation_id source, dcon::nation_id target, dcon::cb_type_id primary_cb, dcon::state_definition_id cb_state, dcon::national_identity_id cb_tag, dcon::nation_id cb_secondary_nation)
Definition: commands.cpp:2621
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
constexpr dcon::demographics_key total(0)
dcon::demographics_key to_key(sys::state const &state, dcon::pop_type_id v)
void switch_scene(sys::state &state, scene_id ui_scene)
Definition: game_scene.cpp:13
constexpr uint32_t is_not_constructing_cb
Definition: military.hpp:12
constexpr uint32_t always
Definition: military.hpp:10
bool are_allied_in_war(sys::state const &state, dcon::nation_id a, dcon::nation_id b)
Definition: military.cpp:486
float truce_break_cb_prestige_cost(sys::state &state, dcon::cb_type_id t)
Definition: military.cpp:1328
bool cb_conditions_satisfied(sys::state &state, dcon::nation_id actor, dcon::nation_id target, dcon::cb_type_id cb)
Definition: military.cpp:254
float truce_break_cb_infamy(sys::state &state, dcon::cb_type_id t)
Definition: military.cpp:1450
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
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
float cb_infamy(sys::state const &state, dcon::cb_type_id t)
Definition: military.cpp:1266
bool cb_requires_selection_of_a_valid_nation(sys::state const &state, dcon::cb_type_id t)
Definition: military.cpp:1798
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
float crisis_cb_addition_infamy_cost(sys::state &state, dcon::cb_type_id type, dcon::nation_id from, dcon::nation_id target)
Definition: military.cpp:1771
bool cb_instance_conditions_satisfied(sys::state &state, dcon::nation_id actor, dcon::nation_id target, dcon::cb_type_id cb, dcon::state_definition_id st, dcon::national_identity_id tag, dcon::nation_id secondary)
Definition: military.cpp:321
float truce_break_cb_militancy(sys::state &state, dcon::cb_type_id t)
Definition: military.cpp:1389
bool are_at_war(sys::state const &state, dcon::nation_id a, dcon::nation_id b)
Definition: military.cpp:475
bool cb_requires_selection_of_a_liberatable_tag(sys::state const &state, dcon::cb_type_id t)
Definition: military.cpp:1802
int32_t peace_cost(sys::state &state, dcon::war_id war, dcon::cb_type_id wargoal, dcon::nation_id from, dcon::nation_id target, dcon::nation_id secondary_nation, dcon::state_definition_id wargoal_state, dcon::national_identity_id wargoal_tag)
Definition: military.cpp:1540
bool can_add_always_cb_to_war(sys::state &state, dcon::nation_id actor, dcon::nation_id target, dcon::cb_type_id cb, dcon::war_id w)
Definition: military.cpp:110
bool defenders_have_status_quo_wargoal(sys::state const &state, dcon::war_id w)
Definition: military.cpp:592
bool war_goal_would_be_duplicate(sys::state &state, dcon::nation_id source, dcon::war_id w, dcon::nation_id target, dcon::cb_type_id cb_type, dcon::state_definition_id cb_state, dcon::national_identity_id cb_tag, dcon::nation_id cb_secondary_nation)
Definition: military.cpp:7251
float successful_cb_prestige(sys::state &state, dcon::cb_type_id t, dcon::nation_id actor)
Definition: military.cpp:1705
bool cb_requires_selection_of_a_state(sys::state const &state, dcon::cb_type_id t)
Definition: military.cpp:1806
float cb_addition_infamy_cost(sys::state &state, dcon::war_id war, dcon::cb_type_id type, dcon::nation_id from, dcon::nation_id target)
Definition: military.cpp:1779
bool are_allied(sys::state &state, dcon::nation_id a, dcon::nation_id b)
Definition: nations.cpp:198
float prestige_score(sys::state const &state, dcon::nation_id n)
Definition: nations.cpp:396
uint32_t pack_color(float r, float g, float b)
void add_to_layout_box(sys::state &state, layout_base &dest, layout_box &box, embedded_flag ico)
Definition: text.cpp:1165
layout_box open_layout_box(layout_base &dest, int32_t indent)
Definition: text.cpp:1799
void localised_format_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view key, text::substitution_map const &sub)
Definition: text.cpp:1880
std::string format_float(float num, size_t digits)
Definition: text.cpp:981
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
Definition: text.cpp:1899
void add_line_with_condition(sys::state &state, layout_base &dest, std::string_view key, bool condition_met, int32_t indent)
Definition: text.cpp:1955
void add_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
void close_layout_box(columnar_layout &dest, layout_box &box)
Definition: text.cpp:1807
int32_t to_generic(dcon::province_id v)
Definition: triggers.hpp:12
bool evaluate(sys::state &state, dcon::trigger_key key, int32_t primary, int32_t this_slot, int32_t from_slot)
Definition: triggers.cpp:5865
int32_t calculate_partial_score(sys::state &state, dcon::nation_id target, dcon::cb_type_id id, dcon::state_definition_id state_def, dcon::national_identity_id second_nation)
void effect_description(sys::state &state, text::layout_base &layout, dcon::effect_key k, int32_t primary_slot, int32_t this_slot, int32_t from_slot, uint32_t r_lo, uint32_t r_hi)
tooltip_behavior
void send(sys::state &state, element_base *parent, T value)
void trigger_description(sys::state &state, text::layout_base &layout, dcon::trigger_key k, int32_t primary_slot=-1, int32_t this_slot=-1, int32_t from_slot=-1)
message_result
uint uint32_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