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