Project Alice
Loading...
Searching...
No Matches
gui_minimap.hpp
Go to the documentation of this file.
1#pragma once
2
4#include "gui_graphics.hpp"
7#include "gui_main_menu.hpp"
9#include "opengl_wrapper.hpp"
10#include "map.hpp"
11#include "map_modes.hpp"
12#include <glm/glm.hpp>
13
14namespace ui {
15
17public:
18 void button_action(sys::state& state) noexcept override {
20 // Update elements...
21 state.ui_state.root->impl_on_update(state);
22 }
23
24 bool is_active(sys::state& state) noexcept override {
25 return state.map_state.active_map_mode == target;
26 }
27
29
32 }
33
34 void update_tooltip(sys::state& state, int32_t x, int32_t t, text::columnar_layout& contents) noexcept override {
35 auto box = text::open_layout_box(contents, 0);
36 auto s = "mapmode_" + std::to_string(uint32_t(target));
37 text::localised_format_box(state, contents, box, std::string_view(s));
38 text::close_layout_box(contents, box);
39 }
40};
41
43public:
44 void button_action(sys::state& state) noexcept override {
45 if(!state.ui_state.search_window) {
46 auto window = make_element_by_type<province_search_window>(state, "goto_box");
47 state.ui_state.search_window = window.get();
48 state.ui_state.root->add_child_to_front(std::move(window));
49 } else if(state.ui_state.search_window->is_visible()) {
50 state.ui_state.search_window->set_visible(state, false);
51 } else {
52 state.ui_state.search_window->set_visible(state, true);
53 state.ui_state.root->move_child_to_front(state.ui_state.search_window);
54 }
55 }
56
59 }
60
61 void update_tooltip(sys::state& state, int32_t x, int32_t t, text::columnar_layout& contents) noexcept override {
62 auto box = text::open_layout_box(contents, 0);
63 text::localised_format_box(state, contents, box, std::string_view("goto_goto"));
64 text::close_layout_box(contents, box);
65 }
66};
67
69public:
70 void button_action(sys::state& state) noexcept override {
71 if(!state.ui_state.ledger_window) {
72 auto window = make_element_by_type<ledger_window>(state, "ledger");
73 state.ui_state.ledger_window = window.get();
74 state.ui_state.root->add_child_to_front(std::move(window));
75 } else if(state.ui_state.ledger_window->is_visible()) {
76 state.ui_state.ledger_window->set_visible(state, false);
77 } else {
78 state.ui_state.ledger_window->set_visible(state, true);
79 state.ui_state.root->move_child_to_front(state.ui_state.ledger_window);
80 }
81 }
82
85 }
86
87 void update_tooltip(sys::state& state, int32_t x, int32_t t, text::columnar_layout& contents) noexcept override {
88 auto box = text::open_layout_box(contents, 0);
89 text::localised_format_box(state, contents, box, std::string_view("m_ledger_button"));
90 text::close_layout_box(contents, box);
91 }
92};
93
95public:
96 void on_update(sys::state& state) noexcept override {
97 auto index = retrieve<uint32_t>(state, parent);
98 //auto const& name = state.ui_state.templates[index].name;
99 //auto sv = std::string_view(name, name + sizeof(name));
100
101 auto contents = text::create_endless_layout(
102 state,
105 0,
106 0,
107 static_cast<int16_t>(base_data.size.x),
108 static_cast<int16_t>(base_data.size.y),
110 0,
113 true
114 });
115
116 auto box = text::open_layout_box(contents);
117
118 for(dcon::unit_type_id::value_base_t i = 0; i < state.military_definitions.unit_base_definitions.size(); i++) {
119 auto amount = state.ui_state.templates[index].amounts[i];
120
121 if(amount < 1) {
122 continue;
123 }
124
125 auto const utid = dcon::unit_type_id(i);
126
127 std::string padding = i < 10 ? "0" : "";
128
129 text::add_to_layout_box(state, contents, box, text::int_wholenum{ amount });
130
131 std::string description = "@*" + padding + std::to_string(i);
132
133 text::add_unparsed_text_to_layout_box(state, contents, box, description);
134 }
135
136 text::close_layout_box(contents, box);
137 }
138};
140public:
141 void on_update(sys::state& state) noexcept override {
142 auto index = retrieve<uint32_t>(state, parent);
143 auto nid = state.ui_state.templates[index].source;
144 set_current_nation(state, state.world.nation_get_identity_from_identity_holder(nid));
145 }
146};
149public:
150 void button_action(sys::state& state) noexcept override {
151 auto index = retrieve<uint32_t>(state, parent);
152 if(index >= uint32_t(state.ui_state.templates.size()))
153 return;
154 std::memcpy(&state.ui_state.current_template, &state.ui_state.templates[index], sizeof(sys::macro_builder_template));
156 }
157};
159public:
160 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
161 if(name == "name") {
162 return make_element_by_type<macro_builder_template_name>(state, id);
163 } else if(name == "background") {
164 return make_element_by_type<macro_builder_template_select>(state, id);
165 } else {
166 return nullptr;
167 }
168 }
169};
170class macro_builder_template_listbox : public listbox_element_base<macro_builder_template_entry, uint32_t> {
171protected:
172 std::string_view get_row_element_name() override {
173 return "alice_macro_builder_template_entry";
174 }
175public:
176 void on_create(sys::state& state) noexcept override {
179 auto f = simple_fs::open_file(sdir, state.loaded_scenario_file);
180 if(f) {
181 auto contents = simple_fs::view_contents(*f);
182 if(contents.file_size > 0) {
183 uint32_t num_templates = contents.file_size / sizeof(sys::macro_builder_template);
184 //Corruption protection
185 if(num_templates >= 8192 * 4)
186 num_templates = 8192 * 4;
187 state.ui_state.templates.resize(num_templates);
188 std::memcpy(state.ui_state.templates.data(), contents.data, num_templates * sizeof(sys::macro_builder_template));
189 }
190 }
191 }
192 void on_update(sys::state& state) noexcept override {
193 row_contents.resize(state.ui_state.templates.size(), 0);
194 for(uint32_t i = 0; i < uint32_t(state.ui_state.templates.size()); i++)
195 row_contents[i] = i;
196 update(state);
197 }
198};
199
201public:
202 void on_update(sys::state& state) noexcept override {
203 auto content = retrieve<dcon::unit_type_id>(state, parent);
204 auto name = text::produce_simple_string(state, state.military_definitions.unit_base_definitions[content].name);
205 int32_t amount = state.ui_state.current_template.amounts[content.index()];
206 set_text(state, "(" + std::to_string(amount) + ") " + name);
207 }
208};
210public:
211 void button_action(sys::state& state) noexcept override {
212 auto content = retrieve<dcon::unit_type_id>(state, parent);
213 if(state.ui_state.current_template.amounts[content.index()] < 255) {
214 state.ui_state.current_template.amounts[content.index()] += 1;
215 }
217 }
218 void button_right_action(sys::state& state) noexcept override {
219 auto content = retrieve<dcon::unit_type_id>(state, parent);
220 if(state.ui_state.current_template.amounts[content.index()] > 0) {
221 state.ui_state.current_template.amounts[content.index()] -= 1;
222 }
224 }
225};
226class macro_builder_unit_entry : public listbox_row_element_base<dcon::unit_type_id> {
227public:
228 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
229 if(name == "name") {
230 return make_element_by_type<macro_builder_unit_name>(state, id);
231 } else if(name == "background") {
232 return make_element_by_type<macro_builder_unit_button>(state, id);
233 } else {
234 return nullptr;
235 }
236 }
237};
240};
241class macro_builder_unit_listbox : public listbox_element_base<macro_builder_unit_entry, dcon::unit_type_id> {
242protected:
243 std::string_view get_row_element_name() override {
244 return "alice_macro_builder_unit_entry";
245 }
246public:
247 void on_update(sys::state& state) noexcept override {
248 row_contents.clear();
249 bool is_land = retrieve<macro_builder_state>(state, parent).is_land;
250 for(dcon::unit_type_id::value_base_t i = 0; i < state.military_definitions.unit_base_definitions.size(); i++) {
251 auto const utid = dcon::unit_type_id(i);
252 auto const& ut = state.military_definitions.unit_base_definitions[utid];
253 if(ut.is_land == is_land && (ut.active || state.world.nation_get_active_unit(state.local_player_nation, utid))) {
254 row_contents.push_back(utid);
255 }
256 }
257 update(state);
258 }
259};
261public:
262 void button_action(sys::state& state) noexcept override {
264 std::memset(state.ui_state.current_template.name, ' ', sizeof(sys::macro_builder_template::name));
266 }
267};
269public:
270 void button_action(sys::state& state) noexcept override {
272 t.source = state.local_player_nation;
273 // Replace templates with the same name and of the same scenario
274 bool overwrite = false;
275 for(auto& u : state.ui_state.templates) {
276 if(std::memcmp(u.name, t.name, sizeof(sys::macro_builder_template::name)) == 0) {
277 std::memcpy(&u, &t, sizeof(sys::macro_builder_template));
278 overwrite = true;
279 break;
280 }
281 }
282 if(!overwrite) {
283 state.ui_state.templates.push_back(t);
284 }
286 simple_fs::write_file(sdir, state.loaded_scenario_file, reinterpret_cast<const char*>(state.ui_state.templates.data()), uint32_t(state.ui_state.templates.size()) * sizeof(sys::macro_builder_template));
288 }
289};
291public:
292 void button_action(sys::state& state) noexcept override {
294 for(uint32_t i = 0; i < uint32_t(state.ui_state.templates.size()); i++) {
295 auto const& u = state.ui_state.templates[i];
296 if(std::memcmp(u.name, t.name, sizeof(sys::macro_builder_template::name)) == 0) {
297 state.ui_state.templates.erase(state.ui_state.templates.begin() + i);
298 break;
299 }
300 }
302 simple_fs::write_file(sdir, state.loaded_scenario_file, reinterpret_cast<const char*>(state.ui_state.templates.data()), uint32_t(state.ui_state.templates.size()) * sizeof(sys::macro_builder_template));
304 }
305};
307public:
308 void button_action(sys::state& state) noexcept override {
309 std::memcpy(&state.ui_state.main_template, &state.ui_state.current_template, sizeof(sys::macro_builder_template));
310 state.game_state_updated.store(true, std::memory_order::release);
311 }
312};
315public:
316 void on_update(sys::state& state) noexcept override {
317 auto is_land = retrieve<macro_builder_state>(state, parent).is_land;
318 if(is_land) {
319 set_button_text(state, text::produce_simple_string(state, "macro_switch_type_naval"));
320 } else {
321 set_button_text(state, text::produce_simple_string(state, "macro_switch_type_land"));
322 }
323 }
324 void button_action(sys::state& state) noexcept override {
326 }
327};
329public:
330 void edit_box_update(sys::state& state, std::string_view str) noexcept override {
332 std::memset(state.ui_state.current_template.name, ' ', sizeof(sys::macro_builder_template::name));
333 if(!s.empty())
334 std::memcpy(state.ui_state.current_template.name, s.data(), std::min(s.length(), sizeof(sys::macro_builder_template::name)));
335 }
336};
338public:
339 void on_update(sys::state& state) noexcept override {
341 text::layout_parameters{ 0, 0, int16_t(base_data.size.x), int16_t(base_data.size.y),
342 base_data.data.text.font_handle, 0, text::alignment::left,
343 text::is_black_from_font_id(base_data.data.text.font_handle) ? text::text_color::black : text::text_color::white, false });
344 auto is_land = retrieve<macro_builder_state>(state, parent).is_land;
345 auto const& t = state.ui_state.current_template;
346
347 float reconnaissance_or_fire_range = 0.f;
348 float siege_or_torpedo_attack = 0.f;
349 float attack_or_gun_power = 0.f;
350 float defence_or_hull = 0.f;
351 float discipline_or_evasion = std::numeric_limits<float>::max();
352 float support = 0.f;
353 float supply_consumption = 0.f;
354 float maximum_speed = std::numeric_limits<float>::max();
355 float maneuver = std::numeric_limits<float>::max();
356 int32_t supply_consumption_score = 0;
357 bool warn_overseas = false;
358 bool warn_culture = false;
359 bool warn_active = false;
360 for(dcon::unit_type_id::value_base_t i = 0; i < sys::macro_builder_template::max_types; i++) {
361 if(t.amounts[i] == 0) //not needed to show this
362 continue;
363 dcon::unit_type_id utid = dcon::unit_type_id(i);
364 if(is_land != state.military_definitions.unit_base_definitions[utid].is_land)
365 continue;
366
367 if(!state.military_definitions.unit_base_definitions[utid].active && !state.world.nation_get_active_unit(state.local_player_nation, utid))
368 warn_active = true;
369 if(state.military_definitions.unit_base_definitions[utid].primary_culture)
370 warn_culture = true;
371 if(state.military_definitions.unit_base_definitions[utid].can_build_overseas)
372 warn_overseas = true;
373
374 reconnaissance_or_fire_range += state.world.nation_get_unit_stats(state.local_player_nation, utid).reconnaissance_or_fire_range * float(t.amounts[i]);
375 siege_or_torpedo_attack += state.world.nation_get_unit_stats(state.local_player_nation, utid).siege_or_torpedo_attack * float(t.amounts[i]);
376 attack_or_gun_power += state.world.nation_get_unit_stats(state.local_player_nation, utid).attack_or_gun_power * float(t.amounts[i]);
377 defence_or_hull += state.world.nation_get_unit_stats(state.local_player_nation, utid).defence_or_hull * float(t.amounts[i]);
378 discipline_or_evasion += std::min(discipline_or_evasion, state.world.nation_get_unit_stats(state.local_player_nation, utid).discipline_or_evasion);
379 supply_consumption += state.world.nation_get_unit_stats(state.local_player_nation, utid).supply_consumption * float(t.amounts[i]);
380 maximum_speed = std::min(maximum_speed, state.world.nation_get_unit_stats(state.local_player_nation, utid).maximum_speed);
381 if(is_land) {
382 support += state.world.nation_get_unit_stats(state.local_player_nation, utid).support * float(t.amounts[i]);
383 maneuver += std::min(maneuver, state.military_definitions.unit_base_definitions[utid].maneuver);
384 } else {
385 supply_consumption_score += state.military_definitions.unit_base_definitions[utid].supply_consumption_score * int32_t(t.amounts[i]);
386 }
387 }
388
389 if(warn_overseas)
390 text::add_line(state, contents, "macro_warn_overseas");
391 if(warn_culture)
392 text::add_line(state, contents, "macro_warn_culture");
393 if(warn_active)
394 text::add_line(state, contents, "macro_warn_unlocked");
395
396 // Total
397 if(maximum_speed == std::numeric_limits<float>::max()) maximum_speed = 0.f;
398 if(discipline_or_evasion == std::numeric_limits<float>::max()) discipline_or_evasion = 0.f;
399 if(maneuver == std::numeric_limits<float>::max()) maneuver = 0.f;
400 text::add_line(state, contents, text::produce_simple_string(state, "macro_total_desc"));
401 if(is_land) {
402 if(reconnaissance_or_fire_range > 0.f) {
403 text::add_line(state, contents, "unit_recon", text::variable_type::x, text::format_float(reconnaissance_or_fire_range, 2));
404 }
405 if(siege_or_torpedo_attack > 0.f) {
406 text::add_line(state, contents, "unit_siege", text::variable_type::x, text::format_float(siege_or_torpedo_attack, 2));
407 }
408 text::add_line(state, contents, "unit_attack", text::variable_type::x, text::format_float(attack_or_gun_power, 2));
409 text::add_line(state, contents, "unit_defence", text::variable_type::x, text::format_float(defence_or_hull, 2));
410 text::add_line(state, contents, "unit_discipline", text::variable_type::x, text::format_percentage(discipline_or_evasion, 0));
411 if(support > 0.f) {
412 text::add_line(state, contents, "unit_support", text::variable_type::x, text::format_float(support, 0));
413 }
414 text::add_line(state, contents, "unit_maneuver", text::variable_type::x, text::format_float(maneuver, 0));
415 text::add_line(state, contents, "unit_max_speed", text::variable_type::x, text::format_float(maximum_speed, 2));
416 text::add_line(state, contents, "unit_supply_consumption", text::variable_type::x, text::format_percentage(supply_consumption, 0));
417 } else {
418 text::add_line(state, contents, "unit_max_speed", text::variable_type::x, text::format_float(maximum_speed, 2));
419 text::add_line(state, contents, "unit_attack", text::variable_type::x, text::format_float(attack_or_gun_power, 2));
420 if(siege_or_torpedo_attack > 0.f) {
421 text::add_line(state, contents, "unit_torpedo_attack", text::variable_type::x, text::format_float(siege_or_torpedo_attack, 2));
422 }
423 text::add_line(state, contents, "unit_hull", text::variable_type::x, text::format_float(defence_or_hull, 2));
424 text::add_line(state, contents, "unit_fire_range", text::variable_type::x, text::format_float(reconnaissance_or_fire_range, 2));
425 if(discipline_or_evasion > 0.f) {
426 text::add_line(state, contents, "unit_evasion", text::variable_type::x, text::format_percentage(discipline_or_evasion, 0));
427 }
428 text::add_line(state, contents, "unit_supply_consumption", text::variable_type::x, text::format_percentage(supply_consumption, 0));
429 text::add_line(state, contents, "unit_supply_load", text::variable_type::x, supply_consumption_score);
430 }
432
433 // Describe for each
434 for(dcon::unit_type_id::value_base_t i = 0; i < sys::macro_builder_template::max_types; i++) {
435 if(t.amounts[i] == 0) //not needed to show this
436 continue;
437 dcon::unit_type_id utid = dcon::unit_type_id(i);
438 if(is_land != state.military_definitions.unit_base_definitions[utid].is_land)
439 continue;
440 text::add_line(state, contents, state.military_definitions.unit_base_definitions[utid].name);
441 if(is_land) {
442 if(state.world.nation_get_unit_stats(state.local_player_nation, utid).reconnaissance_or_fire_range > 0) {
443 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 * float(t.amounts[i]), 2));
444 }
445 if(state.world.nation_get_unit_stats(state.local_player_nation, utid).siege_or_torpedo_attack > 0) {
446 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 * float(t.amounts[i]), 2));
447 }
448 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 * float(t.amounts[i]), 2));
449 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 * float(t.amounts[i]), 2));
450 text::add_line(state, contents, "unit_discipline", text::variable_type::x, text::format_percentage(state.military_definitions.unit_base_definitions[utid].discipline_or_evasion * float(t.amounts[i]), 0));
451 if(state.military_definitions.unit_base_definitions[utid].support > 0.f) {
452 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 * float(t.amounts[i]), 0));
453 }
454 text::add_line(state, contents, "unit_maneuver", text::variable_type::x, text::format_float(state.military_definitions.unit_base_definitions[utid].maneuver * float(t.amounts[i]), 0));
455 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 * float(t.amounts[i]), 2));
456 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, utid).supply_consumption * float(t.amounts[i]), 0));
457 } else {
458 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 * float(t.amounts[i]), 2));
459 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 * float(t.amounts[i]), 2));
460 if(state.world.nation_get_unit_stats(state.local_player_nation, utid).siege_or_torpedo_attack > 0) {
461 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 * float(t.amounts[i]), 2));
462 }
463 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* float(t.amounts[i]), 2));
464 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* float(t.amounts[i]), 2));
465 if(state.military_definitions.unit_base_definitions[utid].discipline_or_evasion > 0.f) {
466 text::add_line(state, contents, "unit_evasion", text::variable_type::x, text::format_percentage(state.military_definitions.unit_base_definitions[utid].discipline_or_evasion * float(t.amounts[i]), 0));
467 }
468 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, utid).supply_consumption * float(t.amounts[i]), 0));
469 text::add_line(state, contents, "unit_supply_load", text::variable_type::x, state.military_definitions.unit_base_definitions[utid].supply_consumption_score * int32_t(t.amounts[i]));
470 }
472 }
474 }
475};
477 std::vector<dcon::province_id> provinces;
478public:
479 void on_create(sys::state& state) noexcept override {
481 }
482 void on_update(sys::state& state) noexcept override {
483 disabled = true;
484 for(auto const amount : state.ui_state.current_template.amounts) {
485 if(amount != 0) {
486 disabled = false;
487 break;
488 }
489 }
490 disabled = disabled || (state.map_state.selected_province == dcon::province_id{});
491 }
492 void button_action(sys::state& state) noexcept override {
493 auto is_land = retrieve<macro_builder_state>(state, parent).is_land;
494 auto const& t = state.ui_state.current_template;
495 const auto template_province = state.map_state.selected_province;
496
497 state.fill_vector_of_connected_provinces(state.map_state.selected_province, is_land, provinces);
498 if(provinces.empty())
499 return;
500
501 if(is_land) {
502 std::array<uint8_t, sys::macro_builder_template::max_types> current_distribution;
503 current_distribution.fill(0);
504 state.build_up_to_template_land(
505 state.ui_state.current_template,
506 state.map_state.selected_province,
507 provinces,
508 current_distribution
509 );
510 } else {
512 std::memcpy(rem_to_build, t.amounts, sizeof(rem_to_build));
513
514 std::sort(provinces.begin(), provinces.end(), [&state](auto const a, auto const b) {
515 auto ab = state.world.province_get_province_naval_construction_as_province(a);
516 auto bb = state.world.province_get_province_naval_construction_as_province(b);
517 int32_t asz = int32_t(ab.end() - ab.begin());
518 int32_t bsz = int32_t(bb.end() - bb.begin());
519 if(asz == bsz)
520 return a.index() < b.index();
521 return asz < bsz;
522 });
523 for(dcon::unit_type_id::value_base_t i = 0; i < sys::macro_builder_template::max_types; i++) {
524 dcon::unit_type_id utid = dcon::unit_type_id(i);
525 if(rem_to_build[i] > 0
526 && is_land == state.military_definitions.unit_base_definitions[utid].is_land
527 && (state.military_definitions.unit_base_definitions[utid].active || state.world.nation_get_active_unit(state.local_player_nation, utid))) {
528 for(const auto prov : provinces) {
529 auto const port_level = state.world.province_get_building_level(prov, uint8_t(economy::province_building_type::naval_base));
530 if(port_level >= state.military_definitions.unit_base_definitions[utid].min_port_level
531 && command::can_start_naval_unit_construction(state, state.local_player_nation, prov, utid, template_province)) {
532 command::start_naval_unit_construction(state, state.local_player_nation, prov, utid, template_province);
533 rem_to_build[i]--;
534 if(rem_to_build[i] == 0)
535 break;
536 }
537 }
538 // sort provinces again so that the ships can be built on parallel
539 std::sort(provinces.begin(), provinces.end(), [&state](auto const a, auto const b) {
540 auto ab = state.world.province_get_province_naval_construction_as_province(a);
541 auto bb = state.world.province_get_province_naval_construction_as_province(b);
542 int32_t asz = int32_t(ab.end() - ab.begin());
543 int32_t bsz = int32_t(bb.end() - bb.begin());
544 if(asz == bsz)
545 return a.index() < b.index();
546 return asz < bsz;
547 });
548 }
549 }
550 }
551 state.game_state_updated.store(true, std::memory_order::release);
552 }
555 }
556
557 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
558 if(state.map_state.selected_province == dcon::province_id{}) {
559 text::add_line(state, contents, "macro_select_province");
560 return;
561 }
562 auto is_land = retrieve<macro_builder_state>(state, parent).is_land;
563 auto const& t = state.ui_state.current_template;
564 const auto template_province = state.map_state.selected_province;
566 std::memcpy(rem_to_build, t.amounts, sizeof(rem_to_build));
567 state.fill_vector_of_connected_provinces(state.map_state.selected_province, is_land, provinces);
568
569 if(provinces.empty()) {
570 text::add_line(state, contents, "macro_warn_invalid_province");
571 return;
572 }
573
574 if(is_land) {
575 for(const auto prov : provinces) {
576 for(const auto p : state.world.province_get_pop_location_as_province(prov)) {
577 if(p.get_pop().get_poptype() != state.culture_definitions.soldiers)
578 continue;
579 int32_t possible = military::regiments_possible_from_pop(state, p.get_pop());
580 int32_t used = int32_t(p.get_pop().get_regiment_source().end() - p.get_pop().get_regiment_source().begin());
581 used += int32_t(p.get_pop().get_province_land_construction_as_pop().end() - p.get_pop().get_province_land_construction_as_pop().begin());
582 int32_t avail = possible - used;
583 if(possible > 0 && avail > 0) {
584 for(dcon::unit_type_id::value_base_t i = 0; i < sys::macro_builder_template::max_types; i++) {
585 dcon::unit_type_id utid = dcon::unit_type_id(i);
586 if(rem_to_build[i] > 0
587 && is_land == state.military_definitions.unit_base_definitions[utid].is_land
588 && command::can_start_land_unit_construction(state, state.local_player_nation, prov, p.get_pop().get_culture(), utid, template_province)) {
589 for(int32_t j = 0; j < int32_t(rem_to_build[i]) && j < avail; j++) {
590 rem_to_build[i]--;
591 avail--;
592 if(rem_to_build[i] == 0)
593 break;
594 }
595 }
596 }
597 }
598 }
599 }
600 } else {
601 std::sort(provinces.begin(), provinces.end(), [&state](auto const a, auto const b) {
602 auto ab = state.world.province_get_province_naval_construction_as_province(a);
603 auto bb = state.world.province_get_province_naval_construction_as_province(b);
604 int32_t asz = int32_t(ab.end() - ab.begin());
605 int32_t bsz = int32_t(bb.end() - bb.begin());
606 if(asz == bsz)
607 return a.index() < b.index();
608 return asz < bsz;
609 });
610 for(dcon::unit_type_id::value_base_t i = 0; i < sys::macro_builder_template::max_types; i++) {
611 dcon::unit_type_id utid = dcon::unit_type_id(i);
612 if(rem_to_build[i] > 0
613 && is_land == state.military_definitions.unit_base_definitions[utid].is_land
614 && (state.military_definitions.unit_base_definitions[utid].active || state.world.nation_get_active_unit(state.local_player_nation, utid))) {
615 for(const auto prov : provinces) {
616 auto const port_level = state.world.province_get_building_level(prov, uint8_t(economy::province_building_type::naval_base));
617 if(port_level >= state.military_definitions.unit_base_definitions[utid].min_port_level
618 && command::can_start_naval_unit_construction(state, state.local_player_nation, prov, utid, template_province)) {
619 rem_to_build[i]--;
620 if(rem_to_build[i] == 0)
621 break;
622 }
623 }
624 // sort provinces again so that the ships can be built on parallel
625 std::sort(provinces.begin(), provinces.end(), [&state](auto const a, auto const b) {
626 auto ab = state.world.province_get_province_naval_construction_as_province(a);
627 auto bb = state.world.province_get_province_naval_construction_as_province(b);
628 int32_t asz = int32_t(ab.end() - ab.begin());
629 int32_t bsz = int32_t(bb.end() - bb.begin());
630 if(asz == bsz)
631 return a.index() < b.index();
632 return asz < bsz;
633 });
634 }
635 }
636 }
637
638 for(dcon::unit_type_id::value_base_t i = 0; i < sys::macro_builder_template::max_types; i++) {
639 if(rem_to_build[i] > 0) {
640 dcon::unit_type_id utid = dcon::unit_type_id(i);
643 text::add_to_substitution_map(sub, text::variable_type::y, text::int_wholenum{ t.amounts[i] - rem_to_build[i] });
644 text::add_to_substitution_map(sub, text::variable_type::name, state.military_definitions.unit_base_definitions[utid].name);
645 auto box = text::open_layout_box(contents);
646 text::localised_format_box(state, contents, box, "macro_warn_insuff", sub);
647 text::close_layout_box(contents, box);
648 }
649 }
650 }
651};
653 bool is_land = true;
654 macro_builder_name_input* name_input = nullptr;
655public:
656 void on_create(sys::state& state) noexcept override {
659 }
660
661 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
662 if(name == "background") {
663 return make_element_by_type<draggable_target>(state, id);
664 } else if(name == "close") {
665 return make_element_by_type<generic_close_button>(state, id);
666 } else if(name == "input") {
667 auto ptr = make_element_by_type<macro_builder_name_input>(state, id);
668 name_input = ptr.get();
669 return ptr;
670 } else if(name == "template_listbox") {
671 return make_element_by_type<macro_builder_template_listbox>(state, id);
672 } else if(name == "unit_listbox") {
673 return make_element_by_type<macro_builder_unit_listbox>(state, id);
674 } else if(name == "new_template") {
675 return make_element_by_type<macro_builder_new_template_button>(state, id);
676 } else if(name == "save_template") {
677 return make_element_by_type<macro_builder_save_template_button>(state, id);
678 } else if(name == "remove_template") {
679 return make_element_by_type<macro_builder_remove_template_button>(state, id);
680 } else if(name == "set_main") {
681 return make_element_by_type<macro_builder_set_main_template_button>(state, id);
682 } else if(name == "switch_type") {
683 return make_element_by_type<macro_builder_switch_type_button>(state, id);
684 } else if(name == "apply") {
685 return make_element_by_type<macro_builder_apply_button>(state, id);
686 } else if(name == "details") {
687 return make_element_by_type<macro_builder_details>(state, id);
688 } else {
689 return nullptr;
690 }
691 }
692
693 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
694 if(payload.holds_type<macro_builder_state>()) {
695 payload.emplace<macro_builder_state>(macro_builder_state{ is_land });
697 } else if(payload.holds_type< notify_macro_toggle_is_land>()) {
698 is_land = !is_land;
701 } else if(payload.holds_type< notify_template_select>()) {
702 auto const& name = state.ui_state.current_template.name;
703 auto sv = std::string_view(name, name + sizeof(name));
704 auto s = std::string(sv);
705 name_input->edit_index_position(state, 0);
706 name_input->set_text(state, s);
709 } else if(payload.holds_type<notify_setting_update>()) {
712 }
713 return message_result::consumed;// window_element_base::impl_get(state, payload);
714 }
715};
717public:
718 void button_action(sys::state& state) noexcept override {
719 if(!state.ui_state.macro_builder_window) {
720 auto window = make_element_by_type<macro_builder_window>(state, "alice_macro_builder");
721 state.ui_state.macro_builder_window = window.get();
722 state.ui_state.root->add_child_to_front(std::move(window));
723 } else if(state.ui_state.macro_builder_window->is_visible()) {
725 } else {
727 state.ui_state.root->move_child_to_front(state.ui_state.macro_builder_window);
728 }
729 }
730
733 }
734
735 void update_tooltip(sys::state& state, int32_t x, int32_t t, text::columnar_layout& contents) noexcept override {
736 auto box = text::open_layout_box(contents, 0);
737 text::localised_format_box(state, contents, box, std::string_view("macro_builder"));
738 text::close_layout_box(contents, box);
739 }
740};
742public:
743 void button_action(sys::state& state) noexcept override {
745 }
748 }
749 void update_tooltip(sys::state& state, int32_t x, int32_t t, text::columnar_layout& contents) noexcept override {
750 auto box = text::open_layout_box(contents);
751 text::localised_format_box(state, contents, box, "console_button_tooltip");
752 text::close_layout_box(contents, box);
753 }
754};
755
757public:
758 void button_action(sys::state& state) noexcept override {
759 if(!state.ui_state.msg_filters_window) {
760 auto window = make_element_by_type<message_filters_window>(state, "message_filters");
761 state.ui_state.msg_filters_window = window.get();
762 state.ui_state.root->add_child_to_front(std::move(window));
763 } else if(state.ui_state.msg_filters_window->is_visible()) {
764 state.ui_state.msg_filters_window->set_visible(state, false);
765 } else {
766 state.ui_state.msg_filters_window->set_visible(state, true);
767 state.ui_state.root->move_child_to_front(state.ui_state.msg_filters_window);
768 }
769 }
770
773 }
774
775 void update_tooltip(sys::state& state, int32_t x, int32_t t, text::columnar_layout& contents) noexcept override {
776 auto box = text::open_layout_box(contents, 0);
777 text::localised_format_box(state, contents, box, std::string_view("sidemenu_menubar_msg_settings"), text::substitution_map{});
778 text::close_layout_box(contents, box);
779 }
780};
781
783public:
786 }
787
788 void update_tooltip(sys::state& state, int32_t x, int32_t t, text::columnar_layout& contents) noexcept override {
789 auto box = text::open_layout_box(contents, 0);
790 text::localised_format_box(state, contents, box, std::string_view("sidemenu_menubar_msg_combat"), text::substitution_map{});
791 text::close_layout_box(contents, box);
792 }
793};
794
796public:
799 }
800
801 void update_tooltip(sys::state& state, int32_t x, int32_t t, text::columnar_layout& contents) noexcept override {
802 auto box = text::open_layout_box(contents, 0);
803 text::localised_format_box(state, contents, box, std::string_view("sidemenu_menubar_msg_diplo"), text::substitution_map{});
804 text::close_layout_box(contents, box);
805 }
806};
807
809public:
812 }
813
814 void update_tooltip(sys::state& state, int32_t x, int32_t t, text::columnar_layout& contents) noexcept override {
815 auto box = text::open_layout_box(contents, 0);
816 text::localised_format_box(state, contents, box, std::string_view("sidemenu_menubar_msg_unit"), text::substitution_map{});
817 text::close_layout_box(contents, box);
818 }
819};
820
822public:
825 }
826
827 void update_tooltip(sys::state& state, int32_t x, int32_t t, text::columnar_layout& contents) noexcept override {
828 auto box = text::open_layout_box(contents, 0);
829 text::localised_format_box(state, contents, box, std::string_view("sidemenu_menubar_msg_province"), text::substitution_map{});
830 text::close_layout_box(contents, box);
831 }
832};
833
835public:
838 }
839
840 void update_tooltip(sys::state& state, int32_t x, int32_t t, text::columnar_layout& contents) noexcept override {
841 auto box = text::open_layout_box(contents, 0);
842 text::localised_format_box(state, contents, box, std::string_view("sidemenu_menubar_msg_other"), text::substitution_map{});
843 text::close_layout_box(contents, box);
844 }
845};
846
848public:
851 }
852
853 void update_tooltip(sys::state& state, int32_t x, int32_t t, text::columnar_layout& contents) noexcept override {
854 auto box = text::open_layout_box(contents, 0);
855 text::localised_format_box(state, contents, box, std::string_view("sidemenu_menubar_msg_event"), text::substitution_map{});
856 text::close_layout_box(contents, box);
857 }
858};
859
861public:
862 void button_action(sys::state& state) noexcept override {
863 if(!state.ui_state.main_menu) {
864 auto window = make_element_by_type<main_menu_window>(state, "alice_main_menu");
865 state.ui_state.main_menu = window.get();
866 state.ui_state.root->add_child_to_front(std::move(window));
867 } else if(state.ui_state.main_menu->is_visible()) {
868 state.ui_state.main_menu->set_visible(state, false);
869 } else {
870 state.ui_state.main_menu->set_visible(state, true);
871 state.ui_state.root->move_child_to_front(state.ui_state.main_menu);
872 }
873 }
876 }
877
878 void update_tooltip(sys::state& state, int32_t x, int32_t t, text::columnar_layout& contents) noexcept override {
879 auto box = text::open_layout_box(contents, 0);
880 text::localised_format_box(state, contents, box, std::string_view("m_menu_button"));
881 text::close_layout_box(contents, box);
882 }
883};
884
886
888public:
889 void button_action(sys::state& state) noexcept override {
891 set_visible(state, false);
892 }
893};
895public:
896 void button_action(sys::state& state) noexcept override {
897 state.map_state.zoom = std::clamp(state.map_state.zoom * 2.0f,map::min_zoom, map::max_zoom);
898 }
901 }
902 void update_tooltip(sys::state& state, int32_t x, int32_t t, text::columnar_layout& contents) noexcept override {
903 text::add_line(state, contents, "zoom_in");
904 }
905};
907public:
908 void button_action(sys::state& state) noexcept override {
909 state.map_state.zoom = std::clamp(state.map_state.zoom * 0.5f, map::min_zoom, map::max_zoom);
910 }
913 }
914 void update_tooltip(sys::state& state, int32_t x, int32_t t, text::columnar_layout& contents) noexcept override {
915 text::add_line(state, contents, "zoom_out");
916 }
917};
918
920 const std::string_view mapmode_btn_prefix{"mapmode_"};
921 minimap_open_message_log_button* open_btn = nullptr;
922public:
923 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
924 if(name == "messagelog_window") {
925 auto ptr = make_element_by_type<message_log_window>(state, id);
926 ptr->base_data.position.y += 1; //nudge
927 state.ui_state.msg_log_window = ptr.get();
928 ptr->set_visible(state, false);
929 return ptr;
930 } else if(name == "minimap_bg") {
931 return make_element_by_type<opaque_element_base>(state, id);
932 } else if(name == "openbutton") {
933 auto ptr = make_element_by_type<minimap_open_message_log_button>(state, id);
934 ptr->base_data.position.y += 1; //nudge
935 open_btn = ptr.get();
936 return ptr;
937 } else if(name == "menu_button") {
938 return make_element_by_type<minimap_menu_button>(state, id);
939 } else if(name == "button_macro") {
940 return make_element_by_type<minimap_macro_builder_button>(state, id);
941 } else if(name == "button_console") {
942 return make_element_by_type<minimap_console_button>(state, id);
943 } else if(name == "button_goto") {
944 return make_element_by_type<minimap_goto_button>(state, id);
945 } else if(name == "ledger_button") {
946 return make_element_by_type<minimap_ledger_button>(state, id);
947 } else if(name == "map_zoom_in") {
948 return make_element_by_type<minimap_zoom_in_button>(state, id);
949 } else if(name == "map_zoom_out") {
950 return make_element_by_type<minimap_zoom_out_button>(state, id);
951 } else if(name == "menubar_bg") {
953 } else if(name == "chat_window"
954 || name == "menubar_mail_bg"
955 || name == "menubar_msg_settings"
956 || name == "menubar_msg_combat"
957 || name == "menubar_msg_diplo"
958 || name == "menubar_msg_unit"
959 || name == "menubar_msg_province"
960 || name == "menubar_msg_event"
961 || name == "menubar_msg_other"
962 || name == "menubar_plans_toggle"
963 || name == "menubar_plans_open") {
964 return make_element_by_type<invisible_element>(state, id);
965 } else if(name.starts_with(mapmode_btn_prefix)) {
966 auto ptr = make_element_by_type<minimap_mapmode_button>(state, id);
967 size_t num_index = name.rfind("_") + 1;
968 uint8_t num = 0;
969 for(size_t i = num_index; i < name.size(); i++) {
970 num *= 10;
971 num += name[i] - '0';
972 }
973 ptr->target = static_cast<map_mode::mode>(num);
974 return ptr;
975 } else {
976 return nullptr;
977 }
978 }
979
980 void on_update(sys::state& state) noexcept override {
981 if(state.ui_state.msg_log_window) {
982 open_btn->set_visible(state, !state.ui_state.msg_log_window->is_visible());
983 }
984 }
985
986 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
987 base_data.size.x = int16_t(ui_width(state));
988 base_data.size.y = int16_t(ui_height(state));
990 }
991
992 message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
993 if(payload.holds_type<open_msg_log_data>()) {
996 }
998 }
999};
1000
1002public:
1003 bool get_horizontal_flip(sys::state& state) noexcept override {
1004 return false; //never flip
1005 }
1006
1007 void render(sys::state& state, int32_t x, int32_t y) noexcept override {
1009 // TODO draw white box to represent window borders
1010 }
1011
1012 message_result on_lbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override {
1013 auto minimap_size = glm::vec2(base_data.size.x, base_data.size.y);
1014 state.map_state.set_pos(glm::vec2(x, y) / minimap_size);
1016 }
1017
1018 message_result on_scroll(sys::state& state, int32_t x, int32_t y, float amount, sys::key_modifiers mods) noexcept override {
1020 }
1021};
1022
1023} // namespace ui
void set_button_text(sys::state &state, std::string const &new_text)
void on_create(sys::state &state) noexcept override
static void show_toggle(sys::state &state)
void impl_on_update(sys::state &state) noexcept override
virtual void edit_index_position(sys::state &state, int32_t index) noexcept
element_base * parent
virtual void render(sys::state &state, int32_t x, int32_t y) noexcept
virtual message_result get(sys::state &state, Cyto::Any &payload) noexcept
bool is_visible() const
element_data base_data
void set_visible(sys::state &state, bool vis)
virtual void set_current_nation(sys::state &state, dcon::national_identity_id identity) noexcept
void on_create(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void button_action(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void edit_box_update(sys::state &state, std::string_view str) noexcept override
void button_action(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
void button_action(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
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
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
Definition: gui_minimap.hpp:96
void button_action(sys::state &state) noexcept override
void button_right_action(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_update(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
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
void button_action(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t t, text::columnar_layout &contents) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_minimap.hpp:57
void button_action(sys::state &state) noexcept override
Definition: gui_minimap.hpp:44
void update_tooltip(sys::state &state, int32_t x, int32_t t, text::columnar_layout &contents) noexcept override
Definition: gui_minimap.hpp:61
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_minimap.hpp:83
void update_tooltip(sys::state &state, int32_t x, int32_t t, text::columnar_layout &contents) noexcept override
Definition: gui_minimap.hpp:87
void button_action(sys::state &state) noexcept override
Definition: gui_minimap.hpp:70
void update_tooltip(sys::state &state, int32_t x, int32_t t, text::columnar_layout &contents) noexcept override
void button_action(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_minimap.hpp:30
bool is_active(sys::state &state) noexcept override
Definition: gui_minimap.hpp:24
void button_action(sys::state &state) noexcept override
Definition: gui_minimap.hpp:18
void update_tooltip(sys::state &state, int32_t x, int32_t t, text::columnar_layout &contents) noexcept override
Definition: gui_minimap.hpp:34
void update_tooltip(sys::state &state, int32_t x, int32_t t, text::columnar_layout &contents) 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 t, 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 t, 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 t, 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 t, 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 t, 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 t, text::columnar_layout &contents) 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 t, text::columnar_layout &contents) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void button_action(sys::state &state) noexcept override
bool get_horizontal_flip(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
message_result on_scroll(sys::state &state, int32_t x, int32_t y, float amount, sys::key_modifiers mods) noexcept override
message_result on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) 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 t, 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 t, text::columnar_layout &contents) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
static std::unique_ptr< partially_transparent_image > make_element_by_type_alias(sys::state &state, dcon::gui_def_id id)
void calibrate_scrollbar(sys::state &state) noexcept
multiline_text_element_base * delegate
void set_text(sys::state &state, std::string const &new_text)
void on_create(sys::state &state) noexcept override
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
void set_map_mode(sys::state &state, mode mode)
Definition: map_modes.cpp:796
constexpr float max_zoom
Definition: constants.hpp:604
constexpr float min_zoom
Definition: constants.hpp:603
int32_t regiments_possible_from_pop(sys::state &state, dcon::pop_id p)
Definition: military.cpp:675
std::string_view remove_surrounding_whitespace(std::string_view txt)
Definition: parsers.cpp:381
void write_file(directory const &dir, native_string_view file_name, char const *file_data, uint32_t file_size)
directory get_or_create_templates_directory()
std::optional< file > open_file(directory const &dir, native_string_view file_name)
file_contents view_contents(file const &f)
key_modifiers
Definition: constants.hpp:156
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 add_unparsed_text_to_layout_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view sv, substitution_map const &mp)
Definition: text.cpp:1601
void localised_format_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view key, text::substitution_map const &sub)
Definition: text.cpp:1880
endless_layout create_endless_layout(sys::state &state, layout &dest, layout_parameters const &params)
Definition: text.cpp:1100
std::string format_float(float num, size_t digits)
Definition: text.cpp:981
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
Definition: text.cpp:1899
void add_line_break_to_layout(sys::state &state, columnar_layout &dest)
Definition: text.cpp:1152
void add_to_substitution_map(substitution_map &mp, variable_type key, substitution value)
Definition: text.cpp:1068
ankerl::unordered_dense::map< uint32_t, substitution > substitution_map
Definition: text.hpp:794
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
Definition: text.cpp:617
std::string format_percentage(float num, size_t digits)
Definition: text.cpp:977
void close_layout_box(columnar_layout &dest, layout_box &box)
Definition: text.cpp:1807
int32_t ui_height(sys::state const &state)
int32_t ui_width(sys::state const &state)
tooltip_behavior
void send(sys::state &state, element_base *parent, T value)
message_result
uint uint32_t
uchar uint8_t
static constexpr uint32_t max_types
union ui::element_data::internal_data data
element_base * main_menu
sys::macro_builder_template main_template
element_base * msg_log_window
element_base * search_window
std::vector< sys::macro_builder_template > templates
std::unique_ptr< element_base > root
element_base * macro_builder_window
element_base * msg_filters_window
element_base * ledger_window
sys::macro_builder_template current_template