Project Alice
Loading...
Searching...
No Matches
gui_build_unit_large_window.hpp
Go to the documentation of this file.
1#pragma once
2
5#include "triggers.hpp"
6
7namespace ui {
8
10public:
11 dcon::pop_id pop_info;
12 dcon::province_id province_info;
13 // false == army
14 // true == navy
15 bool is_navy;
16 dcon::modifier_id continent;
17 int16_t num_on_continent = 0;
18 int16_t num_possible = 0;
19 dcon::unit_type_id utid{};
20
23 }
25 return !(*this == o);
26 }
27};
28
30public:
31 dcon::province_land_construction_id land_id;
32 dcon::province_naval_construction_id naval_id;
33 // false == army
34 // true == navy
35 bool is_navy;
36
37 bool operator==(queue_unit_entry_info const& o) const {
38 return land_id == o.land_id && naval_id == o.naval_id && is_navy == o.is_navy;
39 }
40 bool operator!=(queue_unit_entry_info const& o) const {
41 return !(*this == o);
42 }
43};
44
46public:
47 void button_action(sys::state& state) noexcept override {
48 state.ui_state.unit_window_army->set_visible(state, true);
49 state.ui_state.unit_window_navy->set_visible(state, true);
50 state.ui_state.build_unit_window->set_visible(state, false);
51 }
52 void on_update(sys::state& state) noexcept override {
53 if(state.world.nation_get_disarmed_until(state.local_player_nation)
54 && state.current_date < state.world.nation_get_disarmed_until(state.local_player_nation)) {
55 state.ui_state.unit_window_army->set_visible(state, true);
56 state.ui_state.unit_window_navy->set_visible(state, true);
57 state.ui_state.build_unit_window->set_visible(state, false);
58 }
59 }
60};
61
63public:
64 bool is_navy = false;
65
66 void on_update(sys::state& state) noexcept override {
67 auto content = retrieve<buildable_unit_entry_info>(state, parent);
68 color = sys::pack_color(255, 255, 255);
69 if(is_navy == false && std::max(state.defines.alice_full_reinforce, state.world.pop_get_size(content.pop_info) / state.defines.pop_size_per_regiment) < 1.f) {
70 color = sys::pack_color(255, 196, 196);
71 if(state.user_settings.color_blind_mode == sys::color_blind_mode::deutan || state.user_settings.color_blind_mode == sys::color_blind_mode::protan) {
72 color = sys::pack_color(255, 100, 255); //remap to blue
73 } else if(state.user_settings.color_blind_mode == sys::color_blind_mode::achroma) {
74 color = sys::pack_color(196, 196, 196);
75 }
76 }
77 }
78
79 void button_action(sys::state& state) noexcept override {
80 dcon::nation_id n = retrieve<dcon::nation_id>(state, parent);
81 buildable_unit_entry_info info = retrieve<buildable_unit_entry_info>(state, parent);
82 dcon::unit_type_id utid = info.utid ? info.utid : retrieve<dcon::unit_type_id>(state, parent);
83 dcon::province_id p = retrieve<dcon::province_id>(state, parent);
84 if(is_navy) {
87 }
88 } else {
89 dcon::culture_id c = retrieve<dcon::culture_id>(state, parent);
92 }
93 }
94 }
95
98 }
99
100 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
101 dcon::unit_type_id utid = retrieve<dcon::unit_type_id>(state, parent);
102 dcon::province_id p = retrieve<dcon::province_id>(state, parent);
103 if(is_navy) {
104 text::add_line(state, contents, "military_build_unit_tooltip", text::variable_type::name, state.military_definitions.unit_base_definitions[utid].name, text::variable_type::loc, state.world.province_get_name(p));
105 //Any key starting with 'alice' has been added in \assets\alice.csv
106 text::add_line(state, contents, "unit_max_speed", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, utid).maximum_speed, 2));
107 text::add_line(state, contents, "unit_attack", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, utid).attack_or_gun_power, 2));
108 if(state.world.nation_get_unit_stats(state.local_player_nation, utid).siege_or_torpedo_attack > 0) {
109 text::add_line(state, contents, "unit_torpedo_attack", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, utid).siege_or_torpedo_attack, 2));
110 }
111 text::add_line(state, contents, "unit_hull", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, utid).defence_or_hull, 2));
112 text::add_line(state, contents, "unit_fire_range", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, utid).reconnaissance_or_fire_range, 2));
113 if(state.military_definitions.unit_base_definitions[utid].discipline_or_evasion > 0) {
114 text::add_line(state, contents, "unit_evasion", text::variable_type::x, text::format_percentage(state.military_definitions.unit_base_definitions[utid].discipline_or_evasion, 0));
115 }
116 text::add_line(state, contents, "unit_supply_consumption", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, utid).supply_consumption * 100, 0));
117 text::add_line(state, contents, "unit_supply_load", text::variable_type::x, state.military_definitions.unit_base_definitions[utid].supply_consumption_score);
118 } else {
119 text::add_line(state, contents, "military_build_unit_tooltip", text::variable_type::name, state.military_definitions.unit_base_definitions[utid].name, text::variable_type::loc, state.world.province_get_name(p));
120
121 buildable_unit_entry_info info = retrieve< buildable_unit_entry_info>(state, parent);
122 if(std::max(state.defines.alice_full_reinforce, state.world.pop_get_size(info.pop_info) / state.defines.pop_size_per_regiment) < 1.f) {
123 text::add_line(state, contents, "understaffed_regiment", text::variable_type::value, text::format_wholenum(int32_t(state.world.pop_get_size(info.pop_info))));
124 }
125
126 if(state.world.nation_get_unit_stats(state.local_player_nation, utid).reconnaissance_or_fire_range > 0) {
127 text::add_line(state, contents, "unit_recon", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, utid).reconnaissance_or_fire_range, 2));
128 }
129 if(state.world.nation_get_unit_stats(state.local_player_nation, utid).siege_or_torpedo_attack > 0) {
130 text::add_line(state, contents, "unit_siege", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, utid).siege_or_torpedo_attack, 2));
131 }
132 text::add_line(state, contents, "unit_attack", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, utid).attack_or_gun_power, 2));
133 text::add_line(state, contents, "unit_defence", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, utid).defence_or_hull, 2));
134 text::add_line(state, contents, "unit_discipline", text::variable_type::x, text::format_percentage(state.military_definitions.unit_base_definitions[utid].discipline_or_evasion, 0));
135 if(state.military_definitions.unit_base_definitions[utid].support > 0) {
136 text::add_line(state, contents, "unit_support", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, utid).support, 0));
137 }
138 text::add_line(state, contents, "unit_maneuver", text::variable_type::x, text::format_float(state.military_definitions.unit_base_definitions[utid].maneuver, 0));
139 text::add_line(state, contents, "unit_max_speed", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, utid).maximum_speed, 2));
140 text::add_line(state, contents, "unit_supply_consumption", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, utid).supply_consumption * 100, 0));
141 }
142 }
143};
144
146public:
147 bool is_navy = false;
148 void button_action(sys::state& state) noexcept override {
149 dcon::unit_type_id utid = retrieve<dcon::unit_type_id>(state, parent);
150 dcon::modifier_id con = retrieve<dcon::modifier_id>(state, parent);
151 for(auto po : state.world.nation_get_province_ownership_as_nation(state.local_player_nation)) {
152 auto p = po.get_province();
153 if(state.world.province_get_continent(p) == con) {
154 if(is_navy) {
155 if(command::can_start_naval_unit_construction(state, state.local_player_nation, p, utid)) {
156 command::start_naval_unit_construction(state, state.local_player_nation, p, utid);
157 }
158 } else {
159 state.world.for_each_culture([&](dcon::culture_id c) {
160 if(command::can_start_land_unit_construction(state, state.local_player_nation, p, c, utid)) {
161 command::start_land_unit_construction(state, state.local_player_nation, p, c, utid);
162 }
163 });
164 }
165 }
166 }
167 }
168
171 }
172
173 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
174
175 }
176};
177
179public:
181 float good_quantity = 0.0f;
184 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
185 if(name == "goods_type") {
186 auto ptr = make_element_by_type<image_element_base>(state, id);
187 goods_type = ptr.get();
188 return ptr;
189 } else if(name == "value") {
190 auto ptr = make_element_by_type<simple_text_element_base>(state, id);
191 value = ptr.get();
192 return ptr;
193 } else {
194 return nullptr;
195 }
196 }
197 void on_update(sys::state& state) noexcept override {
200 }
201};
202
204public:
205 bool is_navy = false;
206 void button_action(sys::state& state) noexcept override {
207 ui::queue_unit_entry_info local_unit_entry = retrieve<ui::queue_unit_entry_info>(state, parent);
208 if(!local_unit_entry.is_navy) {
209 dcon::nation_id n = state.world.province_land_construction_get_nation(local_unit_entry.land_id);
210 dcon::unit_type_id utid = state.world.province_land_construction_get_type(local_unit_entry.land_id);
211 dcon::province_id p = state.world.pop_get_province_from_pop_location(state.world.province_land_construction_get_pop(local_unit_entry.land_id));
212 dcon::culture_id c = state.world.pop_get_culture(state.world.province_land_construction_get_pop(local_unit_entry.land_id));
214 } else {
215 dcon::nation_id n = state.world.province_naval_construction_get_nation(local_unit_entry.naval_id);
216 dcon::unit_type_id utid = state.world.province_naval_construction_get_type(local_unit_entry.naval_id);
217 dcon::province_id p = state.world.province_naval_construction_get_province(local_unit_entry.naval_id);
219 }
220 }
221
224 }
225
226 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
227 /*
228 dcon::unit_type_id utid = retrieve<dcon::unit_type_id>(state, parent);
229 dcon::province_id p = retrieve<dcon::province_id>(state, parent);
230 if(is_navy) {
231 text::add_line(state, contents, "military_build_unit_tooltip", text::variable_type::name, state.military_definitions.unit_base_definitions[utid].name, text::variable_type::loc, state.world.province_get_name(p));
232 //Any key starting with 'alice' has been added in \assets\alice.csv
233 text::add_line(state, contents, "unit_max_speed", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, utid).maximum_speed, 2));
234 text::add_line(state, contents, "unit_attack", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, utid).attack_or_gun_power, 2));
235 text::add_line(state, contents, "unit_hull", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, utid).defence_or_hull, 2));
236 text::add_line(state, contents, "unit_fire_range", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, utid).reconnaissance_or_fire_range, 2));
237 text::add_line(state, contents, "unit_supply_consumption", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, utid).supply_consumption * 100, 0));
238 text::add_line(state, contents, "unit_supply_load", text::variable_type::x, state.military_definitions.unit_base_definitions[utid].supply_consumption_score);
239 } else {
240 text::add_line(state, contents, "military_build_unit_tooltip", text::variable_type::name, state.military_definitions.unit_base_definitions[utid].name, text::variable_type::loc, state.world.province_get_name(p));
241 text::add_line(state, contents, "unit_attack", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, utid).attack_or_gun_power, 2));
242 text::add_line(state, contents, "unit_defence", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, utid).defence_or_hull, 2));
243 text::add_line(state, contents, "unit_discipline", text::variable_type::x, text::format_percentage(state.military_definitions.unit_base_definitions[utid].discipline, 0));
244 text::add_line(state, contents, "unit_maneuver", text::variable_type::x, text::format_float(state.military_definitions.unit_base_definitions[utid].maneuver_or_evasion, 0));
245 text::add_line(state, contents, "unit_max_speed", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, utid).maximum_speed, 2));
246 text::add_line(state, contents, "unit_supply_consumption", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, utid).supply_consumption * 100, 0));
247 }
248 */
249 }
250};
251
253public:
254 bool is_navy = false;
255
256 void button_action(sys::state& state) noexcept override {
257 if(is_navy) {
258 for(auto lc : state.world.nation_get_province_naval_construction(state.local_player_nation)) {
259 command::cancel_naval_unit_construction(state, state.local_player_nation, lc.get_province(), lc.get_type());
260 }
261 } else {
262 for(auto lc : state.world.nation_get_province_land_construction(state.local_player_nation)) {
263 command::cancel_land_unit_construction(state, state.local_player_nation, lc.get_pop().get_province_from_pop_location(), lc.get_pop().get_culture(), lc.get_type());
264 }
265 }
266 }
267
270 }
271
272 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
273 text::add_line(state, contents, "mil_construction_cancel_all");
274 }
275
276 message_result set(sys::state& state, Cyto::Any& payload) noexcept override {
277 if(payload.holds_type<dcon::army_id>()) {
278 is_navy = false;
280 } else if(payload.holds_type<dcon::navy_id>()) {
281 is_navy = true;
283 }
285 }
286
287};
288
290public:
291 dcon::unit_type_id unit_type{};
292
293 void button_action(sys::state& state) noexcept override {
295 }
296
297 void on_update(sys::state& state) noexcept override {
298 dcon::nation_id n = retrieve<dcon::nation_id>(state, parent);
299 disabled = state.world.nation_get_active_unit(n, unit_type) == false &&
300 state.military_definitions.unit_base_definitions[unit_type].active == false;
301 }
302
305 }
306
307 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
308 text::add_line(state, contents, state.military_definitions.unit_base_definitions[unit_type].name);
309 if(state.military_definitions.unit_base_definitions[unit_type].is_land) {
310 if(state.world.nation_get_unit_stats(state.local_player_nation, unit_type).reconnaissance_or_fire_range > 0) {
311 text::add_line(state, contents, "unit_recon", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, unit_type).reconnaissance_or_fire_range, 2));
312 }
313 if(state.world.nation_get_unit_stats(state.local_player_nation, unit_type).siege_or_torpedo_attack > 0) {
314 text::add_line(state, contents, "unit_siege", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, unit_type).siege_or_torpedo_attack, 2));
315 }
316 text::add_line(state, contents, "unit_attack", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, unit_type).attack_or_gun_power, 2));
317 text::add_line(state, contents, "unit_defence", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, unit_type).defence_or_hull, 2));
318 text::add_line(state, contents, "unit_discipline", text::variable_type::x, text::format_percentage(state.military_definitions.unit_base_definitions[unit_type].discipline_or_evasion, 0));
319 if(state.military_definitions.unit_base_definitions[unit_type].support > 0) {
320 text::add_line(state, contents, "unit_support", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, unit_type).support, 0));
321 }
322 text::add_line(state, contents, "unit_maneuver", text::variable_type::x, text::format_float(state.military_definitions.unit_base_definitions[unit_type].maneuver, 0));
323 text::add_line(state, contents, "unit_max_speed", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, unit_type).maximum_speed, 2));
324 text::add_line(state, contents, "unit_supply_consumption", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, unit_type).supply_consumption * 100, 0));
325 } else {
326 text::add_line(state, contents, "unit_max_speed", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, unit_type).maximum_speed, 2));
327 text::add_line(state, contents, "unit_attack", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, unit_type).attack_or_gun_power, 2));
328 if(state.world.nation_get_unit_stats(state.local_player_nation, unit_type).siege_or_torpedo_attack > 0) {
329 text::add_line(state, contents, "unit_torpedo_attack", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, unit_type).siege_or_torpedo_attack, 2));
330 }
331 text::add_line(state, contents, "unit_hull", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, unit_type).defence_or_hull, 2));
332 text::add_line(state, contents, "unit_fire_range", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, unit_type).reconnaissance_or_fire_range, 2));
333 if(state.military_definitions.unit_base_definitions[unit_type].discipline_or_evasion > 0) {
334 text::add_line(state, contents, "unit_evasion", text::variable_type::x, text::format_percentage(state.military_definitions.unit_base_definitions[unit_type].discipline_or_evasion, 0));
335 }
336 text::add_line(state, contents, "unit_supply_consumption", text::variable_type::x, text::format_percentage(state.world.nation_get_unit_stats(state.local_player_nation, unit_type).supply_consumption, 0));
337 text::add_line(state, contents, "unit_supply_load", text::variable_type::x, state.military_definitions.unit_base_definitions[unit_type].supply_consumption_score);
338 }
339 if(!(state.world.nation_get_active_unit(state.local_player_nation, unit_type) && state.military_definitions.unit_base_definitions[unit_type].active)) {
340 for(const auto inv : state.world.in_invention) {
341 if(inv.get_activate_unit(unit_type)) {
342 text::add_line(state, contents, "activated_by_with_a_chance_of", text::variable_type::x, inv.get_name());
343 additive_value_modifier_description(state, contents, inv.get_chance(), trigger::to_generic(state.local_player_nation), trigger::to_generic(state.local_player_nation), 0);
344 }
345 }
346 }
347 }
348
349 message_result set(sys::state& state, Cyto::Any& payload) noexcept override {
350 if(payload.holds_type<element_selection_wrapper<dcon::unit_type_id>>()) {
351 if(unit_type == any_cast<element_selection_wrapper<dcon::unit_type_id>>(payload).data) {
352 frame = 1;
353 } else {
354 frame = 0;
355 }
357 }
359 }
360};
361
362class units_build_item : public listbox_row_element_base<buildable_unit_entry_info> {
363public:
372 std::vector<resource_cost*> resource_cost_elements;
373
374 std::string pop_size_text;
375
376 void on_create(sys::state& state) noexcept override {
377 for(uint32_t i = 0; i < economy::commodity_set::set_size; ++i) {
378 auto ptr = make_element_by_type<resource_cost>(state, state.ui_state.defs_by_name.find(state.lookup_key("build_resource_cost"))->second.definition);
379 resource_cost_elements.push_back(ptr.get());
380 add_child_to_front(std::move(ptr));
381 }
383 }
384
385 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
386 if(name == "build_button") {
387 auto ptr = make_element_by_type<unit_build_button>(state, id);
388 ptr->set_button_text(state, "");
389 build_button = ptr.get();
390 return ptr;
391 } else if(name == "build_button_group") {
392 auto ptr = make_element_by_type<unit_build_button_group>(state, id);
393 ptr->set_button_text(state, "");
394 build_button_group = ptr.get();
395 return ptr;
396 } else if(name == "name") {
397 auto ptr = make_element_by_type<simple_text_element_base>(state, id);
398 unit_name = ptr.get();
399 return ptr;
400 } else if(name == "unit_strip") {
401 auto ptr = make_element_by_type<image_element_base>(state, id);
402 unit_icon = ptr.get();
403 return ptr;
404 } else if(name == "province") {
405 auto ptr = make_element_by_type<simple_text_element_base>(state, id);
406 province = ptr.get();
407 return ptr;
408 } else if(name == "time_to_build") {
409 auto ptr = make_element_by_type<simple_text_element_base>(state, id);
410 build_time = ptr.get();
411 return ptr;
412 } else if(name == "popsize") {
413 auto ptr = make_element_by_type<simple_text_element_base>(state, id);
414 pop_size = ptr.get();
415 auto ptr2 = make_element_by_type<simple_text_element_base>(state, id);
416 ptr2->base_data.position.y += 14;
417 brigades = ptr2.get();
418 add_child_to_back(std::move(ptr2));
419 return ptr;
420 } else {
421 return nullptr;
422 }
423 }
424
425 void on_update(sys::state& state) noexcept override {
426 dcon::unit_type_id utid = content.utid ? content.utid : retrieve<dcon::unit_type_id>(state, parent);
427 if(!utid)
428 return;
429 auto const& udef = state.military_definitions.unit_base_definitions[utid];
430 if(!content.continent) {
435
436 int16_t r = 0;
437 for(auto ele : resource_cost_elements) {
438 ele->set_visible(state, false);
439 }
440 for(auto com : udef.build_cost.commodity_type) {
441 if(udef.build_cost.commodity_amounts[r] > 0.0f) {
442 if(r >= int16_t(resource_cost_elements.size()))
443 break;
444 resource_cost_elements[r]->good_frame = state.world.commodity_get_icon(com);
445 resource_cost_elements[r]->good_quantity = udef.build_cost.commodity_amounts[r] * (2.0f - state.world.nation_get_administrative_efficiency(state.local_player_nation));
446 resource_cost_elements[r]->set_visible(state, true);
447 resource_cost_elements[r]->base_data.position.x = build_button->base_data.size.x - (resource_cost_elements[r]->base_data.size.x * (r + 1));
448 r++;
449 }
450 }
452 //unit_strip
453 if(unit_icon) unit_icon->frame = int32_t(udef.icon - 1);
454 //time_to_build
458 //popsize
459 if(content.is_navy) {
462 } else {
463 pop_size_text = text::format_float(state.world.pop_get_size(content.pop_info) / 1000, 1);
464 int num_of_brigades = 0;
465
466 state.world.pop_get_province_from_pop_location(content.pop_info);
467
468 for(auto pl : state.world.province_get_pop_location_as_province(state.world.pop_get_province_from_pop_location(content.pop_info))) {
469 if(pl.get_pop().get_poptype() == state.culture_definitions.soldiers) {
470 for(auto i : state.world.pop_get_regiment_source(pl.get_pop())) {
471 num_of_brigades += 1;
472 }
473 }
474 }
475
478 if(pop_size) pop_size->set_text(state, text::resolve_string_substitution(state, "unit_build_unit_pop_size", n));
479
483 if(brigades) brigades->set_text(state, text::resolve_string_substitution(state, "unit_build_unit_brigades", p));
484 }
485 //province
486 if(province) province->set_text(state, text::produce_simple_string(state, state.world.province_get_name(content.province_info)));
487 //name
489 if(content.is_navy == false) {
491 auto culture_id = state.world.pop_get_culture(content.pop_info);
492 auto culture_content = text::produce_simple_string(state, culture_id.get_name());
493 auto unit_type_name = text::produce_simple_string(state, udef.name);
494 if(unit_name) {
495 std::string num_txt = content.num_possible > 1
496 ? ("(" + std::to_string(content.num_possible) + ") ")
497 : "";
498 unit_name->set_text(state, num_txt + culture_content + " " + unit_type_name);
499 }
500 } else {
503 }
504 } else {
505 int16_t r = 0;
506 for(auto ele : resource_cost_elements) {
507 ele->set_visible(state, false);
508 }
509 for(auto com : udef.build_cost.commodity_type) {
510 if(udef.build_cost.commodity_amounts[r] > 0.0f) {
511 if(r >= int16_t(resource_cost_elements.size()))
512 break;
513 resource_cost_elements[r]->good_frame = state.world.commodity_get_icon(com);
514 resource_cost_elements[r]->good_quantity = ((udef.build_cost.commodity_amounts[r] * (2.0f - state.world.nation_get_administrative_efficiency(state.local_player_nation))) * float(content.num_on_continent));
515 resource_cost_elements[r]->set_visible(state, true);
516 resource_cost_elements[r]->base_data.position.x = build_button->base_data.size.x - (resource_cost_elements[r]->base_data.size.x * (r + 1));
517 r++;
518 }
519 }
521 if(pop_size) pop_size->set_visible(state, false);
522 if(brigades) brigades->set_visible(state, false);
524
527
528 if(unit_icon) unit_icon->frame = int32_t(udef.icon - 1);
529 if(province) province->set_text(state, text::produce_simple_string(state, state.world.modifier_get_name(content.continent)));
530 if(unit_name) unit_name->set_text(state, std::to_string(content.num_on_continent) + " " + text::produce_simple_string(state, state.military_definitions.unit_base_definitions[utid].name));
531 }
532 }
533
534 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
535 if(payload.holds_type<dcon::culture_id>()) {
536 payload.emplace<dcon::culture_id>(state.world.pop_get_culture(content.pop_info).id);
538 } else if(payload.holds_type<dcon::province_id>()) {
539 payload.emplace<dcon::province_id>(content.province_info);
541 } else if(payload.holds_type<dcon::modifier_id>()) {
542 payload.emplace<dcon::modifier_id>(content.continent);
544 } else if(payload.holds_type< dcon::unit_type_id>()) {
545 payload.emplace<dcon::unit_type_id>(content.utid);
547 }
549 }
550};
551
552class units_build_listbox : public listbox_element_base<units_build_item, buildable_unit_entry_info> {
553protected:
554 std::string_view get_row_element_name() override {
555 return "build_unit_entry_wide";
556 }
557
558public:
559 // false == army
560 // true == navy
561 bool is_navy = true;
562
563 void on_update(sys::state& state) noexcept override {
564 row_contents.clear();
565 dcon::unit_type_id utid = retrieve<dcon::unit_type_id>(state, parent);
566 if(!utid)
567 return;
568
569 buildable_unit_entry_info group_info;
570 group_info.utid = utid;
571 std::vector<dcon::modifier_const_fat_id> continent_list;
572 std::vector<buildable_unit_entry_info> list_of_possible_units;
573 if(is_navy == false) {
574 for(auto po : state.world.nation_get_province_ownership_as_nation(state.local_player_nation)) {
575 auto p = po.get_province();
576 state.world.for_each_culture([&](dcon::culture_id c) {
577 if(command::can_start_land_unit_construction(state, state.local_player_nation, p, c, utid)) {
578 buildable_unit_entry_info info;
579 info.utid = utid;
580 info.is_navy = false;
581 for(auto pl : state.world.province_get_pop_location_as_province(p)) {
582 if(pl.get_pop().get_culture() == c) {
583 if(pl.get_pop().get_poptype() == state.culture_definitions.soldiers && state.world.pop_get_size(pl.get_pop()) >= state.defines.pop_min_size_for_regiment) {
584 info.pop_info = pl.get_pop();
585 auto pop_possible = int16_t(military::regiments_possible_from_pop(state, pl.get_pop()));
586 const auto lc = pl.get_pop().get_province_land_construction_as_pop();
587 pop_possible -= int16_t(lc.end() - lc.begin());
588 const auto ar = pl.get_pop().get_regiment_source();
589 pop_possible -= int16_t(ar.end() - ar.begin());
590 info.num_possible += std::max(pop_possible, int16_t(0));
591 break;
592 }
593 }
594 }
595 info.province_info = p;
596 if(info.num_possible > 0) {
597 if(!std::count(continent_list.begin(), continent_list.end(), state.world.province_get_continent(p))) {
598 continent_list.push_back(state.world.province_get_continent(p));
599 }
600 info.continent = state.world.province_get_continent(p);
601 list_of_possible_units.push_back(info);
602 }
603 }
604 });
605 }
606 group_info.pop_info = dcon::pop_id{};
607 group_info.province_info = dcon::province_id{};
608 group_info.is_navy = false;
609 int16_t num_units_on_con = 0;
610 for(auto con : continent_list) {
611 group_info.continent = con;
612 for(auto bu : list_of_possible_units) {
613 if(bu.continent == con) {
614 num_units_on_con += bu.num_possible;
615 }
616 }
617 group_info.num_on_continent = num_units_on_con;
618 // pass 1 - put fully staffed regiments first
619 row_contents.push_back(group_info);
620 for(auto bu : list_of_possible_units) {
621 if(bu.continent == con && std::max(state.defines.alice_full_reinforce, state.world.pop_get_size(bu.pop_info) / state.defines.pop_size_per_regiment) >= 1.f) {
622 bu.continent = dcon::modifier_id{};
623 row_contents.push_back(bu);
624 }
625 }
626 // pass 2 - put the understaffed regiments AFTER
627 for(auto bu : list_of_possible_units) {
628 if(bu.continent == con && std::max(state.defines.alice_full_reinforce, state.world.pop_get_size(bu.pop_info) / state.defines.pop_size_per_regiment) < 1.f) {
629 bu.continent = dcon::modifier_id{};
630 row_contents.push_back(bu);
631 }
632 }
633 num_units_on_con = 0;
634 }
635 } else {
636 for(auto po : state.world.nation_get_province_ownership_as_nation(state.local_player_nation)) {
637 auto p = po.get_province();
638 if(command::can_start_naval_unit_construction(state, state.local_player_nation, p, utid)) {
639 buildable_unit_entry_info info;
640 info.utid = utid;
641 info.is_navy = true;
642 info.continent = state.world.province_get_continent(p);
643 info.pop_info = dcon::pop_id{};
644 info.province_info = p;
645 if(!std::count(continent_list.begin(), continent_list.end(), state.world.province_get_continent(p))) {
646 continent_list.push_back(state.world.province_get_continent(p));
647 }
648 list_of_possible_units.push_back(info);
649 }
650 }
651 group_info.pop_info = dcon::pop_id{};
652 group_info.province_info = dcon::province_id{};
653 group_info.is_navy = true;
654 int16_t num_units_on_con = 0;
655 for(auto con : continent_list) {
656 group_info.continent = con;
657 for(auto bu : list_of_possible_units) {
658 if(bu.continent == con) {
659 num_units_on_con++;
660 }
661 }
662 group_info.num_on_continent = num_units_on_con;
663 row_contents.push_back(group_info);
664 for(auto bu : list_of_possible_units) {
665 if(bu.continent == con) {
666 bu.continent = dcon::modifier_id{};
667 row_contents.push_back(bu);
668 }
669 }
670 num_units_on_con = 0;
671 }
672 }
673 update(state);
674 }
675};
676
677class units_queue_item : public listbox_row_element_base<queue_unit_entry_info> {
678public:
679 ui::image_element_base* unit_icon = nullptr;
680 ui::simple_text_element_base* unit_name = nullptr;
681 ui::unit_queue_button* queue_button = nullptr;
682
683 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
684 if(name == "button") {
685 return make_element_by_type<invisible_element>(state, id);
686 } else if(name == "button2") {
687 auto ptr = make_element_by_type<ui::unit_queue_button>(state, id);
688 ptr->set_button_text(state, "");
689 queue_button = ptr.get();
690 return ptr;
691 } else if(name == "unit_strip") {
692 auto ptr = make_element_by_type<image_element_base>(state, id);
693 unit_icon = ptr.get();
694 return ptr;
695 } else if(name == "name") {
696 auto ptr = make_element_by_type<simple_text_element_base>(state, id);
697 unit_name = ptr.get();
698 return ptr;
699 } else if(name == "province") {
700 return make_element_by_type<generic_name_text<dcon::province_id>>(state, id);
701 } else if(name == "continent") {
702 return make_element_by_type<generic_name_text<dcon::modifier_id>>(state, id);
703 } else {
704 return nullptr;
705 }
706 }
707
708 void on_update(sys::state& state) noexcept override {
709 if(!content.is_navy) {
710 auto c = content.land_id;
711
712 dcon::unit_type_id utid = state.world.province_land_construction_get_type(c);
713 if(utid) {
714 unit_icon->frame = state.military_definitions.unit_base_definitions[utid].icon - 1;
715
716 auto culture_content = text::produce_simple_string(state,
717 state.world.pop_get_culture(state.world.province_land_construction_get_pop(c)).get_name());
718 auto unit_type_name = text::produce_simple_string(state, state.military_definitions.unit_base_definitions[utid].name);
719 unit_name->set_text(state, culture_content + " " + unit_type_name);
720 queue_button->is_navy = false;
721 }
722 } else if(content.is_navy) {
723 auto c = content.naval_id;
724
725 dcon::unit_type_id utid = state.world.province_naval_construction_get_type(c);
726 if(utid) {
727 unit_icon->frame = state.military_definitions.unit_base_definitions[utid].icon - 1;
728
729 unit_name->set_text(state, text::produce_simple_string(state, state.military_definitions.unit_base_definitions[utid].name));
730 queue_button->is_navy = true;
731 }
732 }
733 }
734
735 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
736 if(payload.holds_type<dcon::province_id>()) {
737 dcon::province_id p{};
738 if(!content.is_navy) {
739 auto c = content.land_id;
740 p = state.world.pop_location_get_province(state.world.pop_get_pop_location_as_pop(state.world.province_land_construction_get_pop(c)));
741 } else if(content.is_navy) {
742 auto c = content.naval_id;
743 p = state.world.province_naval_construction_get_province(c);
744 }
745 payload.emplace<dcon::province_id>(p);
746 return message_result::consumed;
747 } else if(payload.holds_type<dcon::modifier_id>()) {
748 dcon::province_id p{};
749 if(!content.is_navy) {
750 auto c = content.land_id;
751 p = state.world.pop_location_get_province(state.world.pop_get_pop_location_as_pop(state.world.province_land_construction_get_pop(c)));
752 } else if(content.is_navy) {
753 auto c = content.naval_id;
754 p = state.world.province_naval_construction_get_province(c);
755 }
756 payload.emplace<dcon::modifier_id>(state.world.province_get_continent(p));
757 return message_result::consumed;
758 } else if(payload.holds_type<ui::queue_unit_entry_info>()) {
759 payload.emplace<ui::queue_unit_entry_info>(content);
760 return message_result::consumed;
761 }
763 }
764};
765
766class units_queue_listbox : public listbox_element_base<units_queue_item, ui::queue_unit_entry_info> {
767protected:
768 std::string_view get_row_element_name() override {
769 return "queue_unit_entry";
770 }
771
772public:
773 // false == army
774 // true == navy
775 bool is_navy = true;
776
777 void on_update(sys::state& state) noexcept override {
778 row_contents.clear();
779 if(is_navy == false) {
780 state.world.nation_for_each_province_land_construction_as_nation(state.local_player_nation, [&](dcon::province_land_construction_id c) { row_contents.push_back(ui::queue_unit_entry_info{ c, dcon::province_naval_construction_id{0}, false }); });
781 } else {
782 state.world.nation_for_each_province_naval_construction_as_nation(state.local_player_nation, [&](dcon::province_naval_construction_id c) { row_contents.push_back(ui::queue_unit_entry_info{ dcon::province_land_construction_id{0}, c, true }); });
783 }
784 update(state);
785 }
786};
787
789public:
790 void on_update(sys::state& state) noexcept override {
791 auto cstr_range = state.world.nation_get_province_land_construction(state.local_player_nation);
792 set_text(state, std::to_string(cstr_range.end() - cstr_range.begin()));
793 }
794};
795
797public:
798 void on_update(sys::state& state) noexcept override {
799 auto cstr_range = state.world.nation_get_province_naval_construction(state.local_player_nation);
800 set_text(state, std::to_string(cstr_range.end() - cstr_range.begin()));
801 }
802};
803
805 dcon::unit_type_id unit_type{};
806 dcon::unit_type_id first_land_type{};
807 dcon::unit_type_id first_naval_type{};
808
809public:
810 void on_create(sys::state& state) noexcept override {
811 window_element_base::on_create(state);
812 set_visible(state, false);
813 }
814
815 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
816 if(name == "cancel_all_units") {
817 return make_element_by_type<cancel_all_units_button>(state, id);
818 } else if(name == "build_army_label") {
819 auto ptr = make_element_by_type<simple_text_element_base>(state, id);
820 army_elements.push_back(ptr.get());
821 return ptr;
822 } else if(name == "build_navy_label") {
823 auto ptr = make_element_by_type<simple_text_element_base>(state, id);
824 navy_elements.push_back(ptr.get());
825 return ptr;
826 } else if(name == "close") {
827 return make_element_by_type<build_unit_close_button>(state, id);
828 } else if(name == "list") {
829 auto ptr = make_element_by_type<units_build_listbox>(state, id);
830 units_listbox = ptr.get();
831 return ptr;
832 } else if(name == "queue") {
833 auto ptr = make_element_by_type<units_queue_listbox>(state, id);
834 units_queue = ptr.get();
835 return ptr;
836 } else if(name == "external_scroll_slider_list") {
837 return make_element_by_type<invisible_element>(state, id);
838 } else if(name == "units_being_built_number") {
839 {
840 auto ptr = make_element_by_type<land_unit_under_construction_count>(state, id);
841 army_elements.push_back(ptr.get());
842 add_child_to_back(std::move(ptr));
843 }
844 {
845 auto ptr = make_element_by_type<naval_unit_under_construction_count>(state, id);
846 navy_elements.push_back(ptr.get());
847 return ptr;
848 }
849 } else if(name == "external_scroll_slider_queue") {
850 return make_element_by_type<invisible_element>(state, id);
851 } else if(name.substr(0, 12) == "unit_folder_") {
852 auto ptr = make_element_by_type<unit_folder_button>(state, id);
853 int32_t value = std::stoi(std::string(name.substr(12)));
854 for(uint8_t i = 0; i < state.military_definitions.unit_base_definitions.size(); i++) {
855 auto const& def = state.military_definitions.unit_base_definitions[dcon::unit_type_id(i)];
856 if(def.icon == value) {
857 ptr->unit_type = dcon::unit_type_id(i);
858 if(def.is_land) {
859 first_land_type = ptr->unit_type;
860 army_elements.push_back(ptr.get());
861 } else {
862 first_naval_type = ptr->unit_type;
863 navy_elements.push_back(ptr.get());
864 }
865 }
866 }
867 return ptr;
868 } else if(name == "military_recruit_bg") {
869 return make_element_by_type<opaque_element_base>(state, id);
870 } else {
871 return nullptr;
872 }
873 }
874
876 units_queue->is_navy = units_listbox->is_navy = false;
877 for(auto element : army_elements)
878 element->set_visible(state, true);
879 units_listbox->impl_on_update(state);
880 units_queue->impl_on_update(state);
881 }
882
884 for(auto element : army_elements)
885 element->set_visible(state, false);
886 }
887
889 units_queue->is_navy = units_listbox->is_navy = true;
890 for(auto element : navy_elements)
891 element->set_visible(state, true);
892 units_listbox->impl_on_update(state);
893 units_queue->impl_on_update(state);
894 }
895
897 for(auto element : navy_elements)
898 element->set_visible(state, false);
899 }
900
901 message_result set(sys::state& state, Cyto::Any& payload) noexcept override {
902 if(payload.holds_type<dcon::army_id>()) {
903 unit_type = first_land_type;
904 set_navy_invisible(state);
905 set_army_visible(state);
906 Cyto::Any unit_type_payload = element_selection_wrapper<dcon::unit_type_id>{ first_land_type };
907 impl_set(state, unit_type_payload);
908 return message_result::consumed;
909 } else if(payload.holds_type<dcon::navy_id>()) {
910 unit_type = first_naval_type;
911 set_army_invisible(state);
912 set_navy_visible(state);
913 Cyto::Any unit_type_payload = element_selection_wrapper<dcon::unit_type_id>{ first_naval_type };
914 impl_set(state, unit_type_payload);
915 return message_result::consumed;
916 }
917 return message_result::unseen;
918 }
919
920 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
921 if(payload.holds_type<element_selection_wrapper<dcon::unit_type_id>>()) {
922 unit_type = Cyto::any_cast<element_selection_wrapper<dcon::unit_type_id>>(payload).data;
923 units_listbox->impl_on_update(state);
924 units_queue->impl_on_update(state);
925 impl_set(state, payload);
926 return message_result::consumed;
927 } else if(payload.holds_type<dcon::unit_type_id>()) {
928 payload.emplace<dcon::unit_type_id>(unit_type);
929 return message_result::consumed;
930 }
931 return message_result::unseen;
932 }
933
934 std::vector<element_base*> army_elements;
935 std::vector<element_base*> navy_elements;
936 ui::units_build_listbox* units_listbox = nullptr;
937 ui::units_queue_listbox* units_queue = nullptr;
938};
939
940class units_province_build_listbox : public listbox_element_base<units_build_item, buildable_unit_entry_info> {
941protected:
942 std::string_view get_row_element_name() override {
943 return "build_unit_entry";
944 }
945public:
946 bool is_navy = true; // false == army; true == navy
947 void on_update(sys::state& state) noexcept override {
948 row_contents.clear();
949 for(uint8_t i = 2; i < state.military_definitions.unit_base_definitions.size(); i++) {
950 auto utid = dcon::unit_type_id(i);
951
952 auto const& def = state.military_definitions.unit_base_definitions[utid];
953 if(!def.active && !state.world.nation_get_active_unit(state.local_player_nation, utid))
954 continue;
955 if(def.is_land != !is_navy)
956 continue;
957 auto p = retrieve<dcon::province_id>(state, parent);
959 info.is_navy = is_navy;
960 info.utid = utid;
961 info.province_info = p;
962 if(is_navy == false) {
963 state.world.for_each_culture([&](dcon::culture_id c) {
964 if(command::can_start_land_unit_construction(state, state.local_player_nation, p, c, utid)) {
965 for(auto pl : state.world.province_get_pop_location_as_province(p)) {
966 if(pl.get_pop().get_culture() == c) {
967 if(pl.get_pop().get_poptype() == state.culture_definitions.soldiers && state.world.pop_get_size(pl.get_pop()) >= state.defines.pop_min_size_for_regiment) {
968 info.pop_info = pl.get_pop();
969 auto pop_possible = int16_t(military::regiments_possible_from_pop(state, pl.get_pop()));
970 const auto lc = pl.get_pop().get_province_land_construction_as_pop();
971 pop_possible -= int16_t(lc.end() - lc.begin());
972 const auto ar = pl.get_pop().get_regiment_source();
973 pop_possible -= int16_t(ar.end() - ar.begin());
974 info.num_possible += std::max(pop_possible, int16_t(0));
975 break;
976 }
977 }
978 }
979 if(info.num_possible > 0)
980 row_contents.push_back(info);
981 }
982 });
983 } else if(command::can_start_naval_unit_construction(state, state.local_player_nation, p, utid)) {
984 row_contents.push_back(info);
985 }
986 }
987 update(state);
988 }
989};
990
991class units_province_queue_listbox : public listbox_element_base<units_queue_item, ui::queue_unit_entry_info> {
992protected:
993 std::string_view get_row_element_name() override {
994 return "queue_unit_entry";
995 }
996public:
997 bool is_navy = true;
998 void on_update(sys::state& state) noexcept override {
999 auto p = retrieve<dcon::province_id>(state, parent);
1000 row_contents.clear();
1001 if(is_navy == false) {
1002 state.world.nation_for_each_province_land_construction_as_nation(state.local_player_nation, [&](dcon::province_land_construction_id c) {
1003 if(p == state.world.pop_get_province_from_pop_location(state.world.province_land_construction_get_pop(c)))
1004 row_contents.push_back(ui::queue_unit_entry_info{ c, dcon::province_naval_construction_id{0}, is_navy });
1005 });
1006 } else {
1007 state.world.province_for_each_province_naval_construction(p, [&](dcon::province_naval_construction_id c) { row_contents.push_back(ui::queue_unit_entry_info{ dcon::province_land_construction_id{0}, c, is_navy }); });
1008 }
1009 update(state);
1010 }
1011};
1012
1014public:
1015 bool is_navy = false;
1016 void button_action(sys::state& state) noexcept override {
1017 auto p = retrieve<dcon::province_id>(state, parent);
1018 if(is_navy == false) {
1019 state.world.nation_for_each_province_land_construction_as_nation(state.local_player_nation, [&](dcon::province_land_construction_id c) {
1020 auto lc = dcon::fatten(state.world, c);
1021 if(p == state.world.pop_get_province_from_pop_location(state.world.province_land_construction_get_pop(c)))
1022 command::cancel_land_unit_construction(state, state.local_player_nation, lc.get_pop().get_province_from_pop_location(), lc.get_pop().get_culture(), lc.get_type());
1023 });
1024 } else {
1025 state.world.province_for_each_province_naval_construction(p, [&](dcon::province_naval_construction_id c) {
1026 auto lc = dcon::fatten(state.world, c);
1027 command::cancel_naval_unit_construction(state, state.local_player_nation, lc.get_province(), lc.get_type());
1028 });
1029 }
1030 }
1032 return tooltip_behavior::variable_tooltip;
1033 }
1034 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
1035 text::add_line(state, contents, "mil_construction_cancel_all");
1036 }
1037};
1039public:
1040 void button_action(sys::state& state) noexcept override {
1042 }
1043 void on_update(sys::state& state) noexcept override {
1044 if(state.world.nation_get_disarmed_until(state.local_player_nation)
1045 && state.current_date < state.world.nation_get_disarmed_until(state.local_player_nation)) {
1047 }
1048 }
1049};
1051 std::vector<element_base*> army_elements;
1052 std::vector<element_base*> navy_elements;
1053 units_province_build_listbox* units_listbox = nullptr;
1054 units_province_queue_listbox* units_queue = nullptr;
1055 build_unit_province_cancel_all_units_button* cancel_all_btn = nullptr;
1056public:
1057 void on_create(sys::state& state) noexcept override {
1058 window_element_base::on_create(state);
1059 set_visible(state, false);
1060 }
1061
1062 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
1063 if(name == "cancel_all_units") {
1064 auto ptr = make_element_by_type<build_unit_province_cancel_all_units_button>(state, id);
1065 cancel_all_btn = ptr.get();
1066 return ptr;
1067 } else if(name == "close") {
1068 return make_element_by_type<build_unit_province_close_button>(state, id);
1069 } else if(name == "list") {
1070 auto ptr = make_element_by_type<units_province_build_listbox>(state, id);
1071 units_listbox = ptr.get();
1072 return ptr;
1073 } else if(name == "queue") {
1074 auto ptr = make_element_by_type<units_province_queue_listbox>(state, id);
1075 units_queue = ptr.get();
1076 return ptr;
1077 } else if(name == "province_recruit_bg") {
1078 return make_element_by_type<opaque_element_base>(state, id);
1079 } else if(name == "external_scroll_slider_list"
1080 || name == "external_scroll_slider_queue"
1081 || name == "cell_window_list"
1082 || name == "cell_window_queue") {
1083 return make_element_by_type<invisible_element>(state, id);
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::army_id>()) {
1091 units_queue->is_navy = units_listbox->is_navy = cancel_all_btn->is_navy = false;
1092 units_listbox->impl_on_update(state);
1093 units_queue->impl_on_update(state);
1094 return message_result::consumed;
1095 } else if(payload.holds_type<dcon::navy_id>()) {
1096 units_queue->is_navy = units_listbox->is_navy = cancel_all_btn->is_navy = true;
1097 units_listbox->impl_on_update(state);
1098 units_queue->impl_on_update(state);
1099 return message_result::consumed;
1100 }
1101 return message_result::unseen;
1102 }
1103};
1104
1105} // namespace ui
void button_action(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
message_result set(sys::state &state, Cyto::Any &payload) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
std::vector< element_base * > army_elements
std::vector< element_base * > navy_elements
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
dcon::province_id province_info
int16_t num_on_continent
bool operator==(buildable_unit_entry_info const &o) const
dcon::unit_type_id utid
dcon::pop_id pop_info
bool operator!=(buildable_unit_entry_info const &o) const
dcon::modifier_id continent
int16_t num_possible
bool is_navy
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
message_result set(sys::state &state, Cyto::Any &payload) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
void add_child_to_back(std::unique_ptr< element_base > child) noexcept final
void add_child_to_front(std::unique_ptr< element_base > child) noexcept final
void impl_on_update(sys::state &state) noexcept override
element_base * parent
virtual message_result get(sys::state &state, Cyto::Any &payload) noexcept
virtual void on_create(sys::state &state) noexcept
element_data base_data
void set_visible(sys::state &state, bool vis)
void on_update(sys::state &state) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
void on_update(sys::state &state) noexcept override
bool operator!=(queue_unit_entry_info const &o) const
dcon::province_naval_construction_id naval_id
bool operator==(queue_unit_entry_info const &o) const
bool is_navy
dcon::province_land_construction_id land_id
void on_update(sys::state &state) noexcept override
simple_text_element_base * value
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
image_element_base * goods_type
void set_text(sys::state &state, std::string const &new_text)
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void button_action(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
message_result set(sys::state &state, Cyto::Any &payload) noexcept override
void 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 update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void button_action(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
ui::image_element_base * unit_icon
ui::simple_text_element_base * build_time
void on_create(sys::state &state) noexcept override
ui::simple_text_element_base * brigades
ui::simple_text_element_base * unit_name
ui::simple_text_element_base * pop_size
ui::unit_build_button * build_button
std::vector< resource_cost * > resource_cost_elements
ui::unit_build_button_group * build_button_group
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::string_view get_row_element_name() override
std::string_view get_row_element_name() override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
std::string_view get_row_element_name() 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
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
std::string_view get_row_element_name() override
void on_update(sys::state &state) noexcept override
void start_land_unit_construction(sys::state &state, dcon::nation_id source, dcon::province_id location, dcon::culture_id soldier_culture, dcon::unit_type_id type, dcon::province_id template_province)
Definition: commands.cpp:668
void start_naval_unit_construction(sys::state &state, dcon::nation_id source, dcon::province_id location, dcon::unit_type_id type, dcon::province_id template_province)
Definition: commands.cpp:609
bool can_start_land_unit_construction(sys::state &state, dcon::nation_id source, dcon::province_id location, dcon::culture_id soldier_culture, dcon::unit_type_id type, dcon::province_id template_province)
Definition: commands.cpp:679
bool can_start_naval_unit_construction(sys::state &state, dcon::nation_id source, dcon::province_id location, dcon::unit_type_id type, dcon::province_id template_province)
Definition: commands.cpp:620
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
int32_t regiments_max_possible_from_province(sys::state &state, dcon::province_id p)
Definition: military.cpp:709
uint32_t pack_color(float r, float g, float b)
std::string resolve_string_substitution(sys::state &state, dcon::text_key source_text, substitution_map const &mp)
Definition: text.cpp:2113
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_to_substitution_map(substitution_map &mp, variable_type key, substitution value)
Definition: text.cpp:1068
std::string format_wholenum(int32_t num)
Definition: text.cpp:1033
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
std::string format_percentage(float num, size_t digits)
Definition: text.cpp:977
int32_t to_generic(dcon::province_id v)
Definition: triggers.hpp:12
void additive_value_modifier_description(sys::state &state, text::layout_base &layout, dcon::value_modifier_key modifier, int32_t primary, int32_t this_slot, int32_t from_slot)
tooltip_behavior
void send(sys::state &state, element_base *parent, T value)
message_result
uint uint32_t
uchar uint8_t
static constexpr uint32_t set_size
element_base * unit_window_army
element_base * unit_window_navy
ankerl::unordered_dense::map< dcon::text_key, element_target, hash_text_key > defs_by_name
element_base * build_unit_window
element_base * build_province_unit_window