Project Alice
Loading...
Searching...
No Matches
macrobuilder2.cpp
Go to the documentation of this file.
1namespace alice_ui {
2struct macrobuilder2_main_close_button_t;
3struct macrobuilder2_main_header_text_t;
4struct macrobuilder2_main_template_list_t;
5struct macrobuilder2_main_unit_grid_t;
6struct macrobuilder2_main_list_page_left_t;
7struct macrobuilder2_main_list_page_right_t;
8struct macrobuilder2_main_grid_page_left_t;
9struct macrobuilder2_main_grid_page_right_t;
10struct macrobuilder2_main_list_page_number_t;
11struct macrobuilder2_main_grid_page_number_t;
12struct macrobuilder2_main_apply_button_t;
13struct macrobuilder2_main_t;
14struct macrobuilder2_list_item_select_button_t;
15struct macrobuilder2_list_item_delete_button_t;
16struct macrobuilder2_list_item_t;
17struct macrobuilder2_grid_item_unit_icon_t;
18struct macrobuilder2_grid_item_decrease_count_t;
19struct macrobuilder2_grid_item_increase_count_t;
20struct macrobuilder2_grid_item_current_count_t;
21struct macrobuilder2_grid_item_t;
23 std::string_view texture_key;
24 dcon::texture_id background_texture;
25 dcon::text_key tooltip_key;
26 void on_create(sys::state& state) noexcept override;
27 void render(sys::state & state, int32_t x, int32_t y) noexcept override;
28 ui::tooltip_behavior has_tooltip(sys::state & state) noexcept override {
30 }
31 ui::message_result test_mouse(sys::state& state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override {
32 if(type == ui::mouse_probe_type::click) {
34 } else if(type == ui::mouse_probe_type::tooltip) {
36 } else if(type == ui::mouse_probe_type::scroll) {
38 } else {
40 }
41 }
42 ui::message_result on_lbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
43 ui::message_result on_rbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
45 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override;
46 void on_update(sys::state& state) noexcept override;
47};
51 float text_scale = 1.500000f;
52 bool text_is_header = true;
54 std::string cached_text;
55 dcon::text_key text_key;
56 void set_text(sys::state & state, std::string const& new_text);
57 void on_reset_text(sys::state & state) noexcept override;
58 void on_create(sys::state& state) noexcept override;
59 void render(sys::state & state, int32_t x, int32_t y) noexcept override;
60 ui::tooltip_behavior has_tooltip(sys::state & state) noexcept override {
62 }
63 ui::message_result test_mouse(sys::state& state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override {
64 if(type == ui::mouse_probe_type::click) {
66 } else if(type == ui::mouse_probe_type::tooltip) {
68 } else if(type == ui::mouse_probe_type::scroll) {
70 } else {
72 }
73 }
74 void on_update(sys::state& state) noexcept override;
75};
77 int32_t page = 0;
78 std::vector<int32_t> values;
79 std::vector<ui::element_base*> visible_items;
80 void on_create(sys::state& state) noexcept override;
81 ui::tooltip_behavior has_tooltip(sys::state & state) noexcept override {
83 }
84 ui::message_result test_mouse(sys::state& state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override {
85 if(type == ui::mouse_probe_type::click) {
87 } else if(type == ui::mouse_probe_type::tooltip) {
89 } else if(type == ui::mouse_probe_type::scroll) {
91 } else {
93 }
94 }
95 ui::message_result on_scroll(sys::state & state, int32_t x, int32_t y, float amount, sys::key_modifiers mods) noexcept override;
96 void change_page(sys::state & state, int32_t new_page);
97 int32_t max_page();
98 void on_update(sys::state& state) noexcept override;
99};
101 int32_t page = 0;
102 std::vector<dcon::unit_type_id> values;
103 std::vector<ui::element_base*> visible_items;
104 void on_create(sys::state& state) noexcept override;
105 ui::tooltip_behavior has_tooltip(sys::state & state) noexcept override {
107 }
108 ui::message_result test_mouse(sys::state& state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override {
109 if(type == ui::mouse_probe_type::click) {
111 } else if(type == ui::mouse_probe_type::tooltip) {
113 } else if(type == ui::mouse_probe_type::scroll) {
115 } else {
117 }
118 }
119 ui::message_result on_scroll(sys::state & state, int32_t x, int32_t y, float amount, sys::key_modifiers mods) noexcept override;
120 void change_page(sys::state & state, int32_t new_page);
121 int32_t max_page();
122 void on_update(sys::state& state) noexcept override;
123};
125 std::string_view texture_key;
126 dcon::texture_id background_texture;
127 bool disabled = false;
128 void on_create(sys::state& state) noexcept override;
129 void render(sys::state & state, int32_t x, int32_t y) noexcept override;
130 ui::tooltip_behavior has_tooltip(sys::state & state) noexcept override {
132 }
133 ui::message_result test_mouse(sys::state& state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override {
134 if(type == ui::mouse_probe_type::click) {
136 } else if(type == ui::mouse_probe_type::tooltip) {
138 } else if(type == ui::mouse_probe_type::scroll) {
140 } else {
142 }
143 }
144 ui::message_result on_lbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
145 ui::message_result on_rbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
146 void on_update(sys::state& state) noexcept override;
147};
149 std::string_view texture_key;
150 dcon::texture_id background_texture;
151 bool disabled = false;
152 void on_create(sys::state& state) noexcept override;
153 void render(sys::state & state, int32_t x, int32_t y) noexcept override;
154 ui::tooltip_behavior has_tooltip(sys::state & state) noexcept override {
156 }
157 ui::message_result test_mouse(sys::state& state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override {
158 if(type == ui::mouse_probe_type::click) {
160 } else if(type == ui::mouse_probe_type::tooltip) {
162 } else if(type == ui::mouse_probe_type::scroll) {
164 } else {
166 }
167 }
168 ui::message_result on_lbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
169 ui::message_result on_rbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
170 void on_update(sys::state& state) noexcept override;
171};
173 std::string_view texture_key;
174 dcon::texture_id background_texture;
175 bool disabled = false;
176 void on_create(sys::state& state) noexcept override;
177 void render(sys::state & state, int32_t x, int32_t y) noexcept override;
178 ui::tooltip_behavior has_tooltip(sys::state & state) noexcept override {
180 }
181 ui::message_result test_mouse(sys::state& state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override {
182 if(type == ui::mouse_probe_type::click) {
184 } else if(type == ui::mouse_probe_type::tooltip) {
186 } else if(type == ui::mouse_probe_type::scroll) {
188 } else {
190 }
191 }
192 ui::message_result on_lbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
193 ui::message_result on_rbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
194 void on_update(sys::state& state) noexcept override;
195};
197 std::string_view texture_key;
198 dcon::texture_id background_texture;
199 bool disabled = false;
200 void on_create(sys::state& state) noexcept override;
201 void render(sys::state & state, int32_t x, int32_t y) noexcept override;
202 ui::tooltip_behavior has_tooltip(sys::state & state) noexcept override {
204 }
205 ui::message_result test_mouse(sys::state& state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override {
206 if(type == ui::mouse_probe_type::click) {
208 } else if(type == ui::mouse_probe_type::tooltip) {
210 } else if(type == ui::mouse_probe_type::scroll) {
212 } else {
214 }
215 }
216 ui::message_result on_lbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
217 ui::message_result on_rbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
218 void on_update(sys::state& state) noexcept override;
219};
223 float text_scale = 1.000000f;
224 bool text_is_header = false;
226 std::string cached_text;
227 void set_text(sys::state & state, std::string const& new_text);
228 void on_reset_text(sys::state & state) noexcept override;
229 void on_create(sys::state& state) noexcept override;
230 void render(sys::state & state, int32_t x, int32_t y) noexcept override;
231 ui::tooltip_behavior has_tooltip(sys::state & state) noexcept override {
233 }
234 ui::message_result test_mouse(sys::state& state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override {
235 if(type == ui::mouse_probe_type::click) {
237 } else if(type == ui::mouse_probe_type::tooltip) {
239 } else if(type == ui::mouse_probe_type::scroll) {
241 } else {
243 }
244 }
245 void on_update(sys::state& state) noexcept override;
246};
250 float text_scale = 1.000000f;
251 bool text_is_header = false;
253 std::string cached_text;
254 void set_text(sys::state & state, std::string const& new_text);
255 void on_reset_text(sys::state & state) noexcept override;
256 void on_create(sys::state& state) noexcept override;
257 void render(sys::state & state, int32_t x, int32_t y) noexcept override;
258 ui::tooltip_behavior has_tooltip(sys::state & state) noexcept override {
260 }
261 ui::message_result test_mouse(sys::state& state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override {
262 if(type == ui::mouse_probe_type::click) {
264 } else if(type == ui::mouse_probe_type::tooltip) {
266 } else if(type == ui::mouse_probe_type::scroll) {
268 } else {
270 }
271 }
272 void on_update(sys::state& state) noexcept override;
273};
275 std::string_view texture_key;
276 dcon::texture_id background_texture;
277 bool disabled = false;
280 float text_scale = 1.000000f;
281 bool text_is_header = false;
283 std::string cached_text;
284 dcon::text_key text_key;
285 void set_text(sys::state & state, std::string const& new_text);
286 void on_reset_text(sys::state & state) noexcept override;
287 void on_create(sys::state& state) noexcept override;
288 void render(sys::state & state, int32_t x, int32_t y) noexcept override;
289 ui::tooltip_behavior has_tooltip(sys::state & state) noexcept override {
291 }
292 ui::message_result test_mouse(sys::state& state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override {
293 if(type == ui::mouse_probe_type::click) {
295 } else if(type == ui::mouse_probe_type::tooltip) {
297 } else if(type == ui::mouse_probe_type::scroll) {
299 } else {
301 }
302 }
303 ui::message_result on_lbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
304 ui::message_result on_rbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
305 void on_update(sys::state& state) noexcept override;
306};
308 std::string_view texture_key;
309 std::string_view alt_texture_key;
310 dcon::texture_id alt_background_texture;
311 bool is_active = false;
312 dcon::texture_id background_texture;
315 float text_scale = 1.000000f;
316 bool text_is_header = false;
318 std::string cached_text;
319 void set_text(sys::state & state, std::string const& new_text);
320 void on_reset_text(sys::state & state) noexcept override;
321 void on_create(sys::state& state) noexcept override;
322 void render(sys::state & state, int32_t x, int32_t y) noexcept override;
323 ui::tooltip_behavior has_tooltip(sys::state & state) noexcept override {
325 }
326 ui::message_result test_mouse(sys::state& state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override {
327 if(type == ui::mouse_probe_type::click) {
329 } else if(type == ui::mouse_probe_type::tooltip) {
331 } else if(type == ui::mouse_probe_type::scroll) {
333 } else {
335 }
336 }
337 ui::message_result on_lbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
338 ui::message_result on_rbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
339 void on_update(sys::state& state) noexcept override;
340};
342 std::string_view texture_key;
343 dcon::texture_id background_texture;
344 dcon::text_key tooltip_key;
345 void on_create(sys::state& state) noexcept override;
346 void render(sys::state & state, int32_t x, int32_t y) noexcept override;
347 ui::tooltip_behavior has_tooltip(sys::state & state) noexcept override {
349 }
350 ui::message_result test_mouse(sys::state& state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override {
351 if(type == ui::mouse_probe_type::click) {
353 } else if(type == ui::mouse_probe_type::tooltip) {
355 } else if(type == ui::mouse_probe_type::scroll) {
357 } else {
359 }
360 }
361 ui::message_result on_lbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
362 ui::message_result on_rbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
363 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override;
364 void on_update(sys::state& state) noexcept override;
365};
367 std::string_view gfx_key;
368 dcon::gfx_object_id background_gid;
369 int32_t frame = 0;
370 void on_create(sys::state& state) noexcept override;
371 void render(sys::state & state, int32_t x, int32_t y) noexcept override;
372 ui::tooltip_behavior has_tooltip(sys::state & state) noexcept override {
374 }
375 ui::message_result test_mouse(sys::state& state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override {
376 if(type == ui::mouse_probe_type::click) {
378 } else if(type == ui::mouse_probe_type::tooltip) {
380 } else if(type == ui::mouse_probe_type::scroll) {
382 } else {
384 }
385 }
386 ui::message_result on_lbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
387 ui::message_result on_rbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
388 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override;
389 void on_update(sys::state& state) noexcept override;
390};
392 std::string_view texture_key;
393 dcon::texture_id background_texture;
394 bool disabled = false;
395 void on_create(sys::state& state) noexcept override;
396 void render(sys::state & state, int32_t x, int32_t y) noexcept override;
397 ui::tooltip_behavior has_tooltip(sys::state & state) noexcept override {
399 }
400 ui::message_result test_mouse(sys::state& state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override {
401 if(type == ui::mouse_probe_type::click) {
403 } else if(type == ui::mouse_probe_type::tooltip) {
405 } else if(type == ui::mouse_probe_type::scroll) {
407 } else {
409 }
410 }
411 ui::message_result on_lbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
412 ui::message_result on_rbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
413 void on_update(sys::state& state) noexcept override;
414};
416 std::string_view texture_key;
417 dcon::texture_id background_texture;
418 bool disabled = false;
419 void on_create(sys::state& state) noexcept override;
420 void render(sys::state & state, int32_t x, int32_t y) noexcept override;
421 ui::tooltip_behavior has_tooltip(sys::state & state) noexcept override {
423 }
424 ui::message_result test_mouse(sys::state& state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override {
425 if(type == ui::mouse_probe_type::click) {
427 } else if(type == ui::mouse_probe_type::tooltip) {
429 } else if(type == ui::mouse_probe_type::scroll) {
431 } else {
433 }
434 }
435 ui::message_result on_lbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
436 ui::message_result on_rbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
437 void on_update(sys::state& state) noexcept override;
438};
442 float text_scale = 1.000000f;
443 bool text_is_header = false;
445 std::string cached_text;
446 void set_text(sys::state & state, std::string const& new_text);
447 void on_reset_text(sys::state & state) noexcept override;
448 void on_create(sys::state& state) noexcept override;
449 void render(sys::state & state, int32_t x, int32_t y) noexcept override;
450 ui::tooltip_behavior has_tooltip(sys::state & state) noexcept override {
452 }
453 ui::message_result test_mouse(sys::state& state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override {
454 if(type == ui::mouse_probe_type::click) {
456 } else if(type == ui::mouse_probe_type::tooltip) {
458 } else if(type == ui::mouse_probe_type::scroll) {
460 } else {
462 }
463 }
464 void on_update(sys::state& state) noexcept override;
465};
478 std::string_view texture_key;
479 dcon::texture_id background_texture;
480 void on_create(sys::state& state) noexcept override;
481 void render(sys::state & state, int32_t x, int32_t y) noexcept override;
482 ui::message_result on_lbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
483 ui::message_result on_rbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
484 ui::message_result test_mouse(sys::state& state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override {
486 }
487 void on_drag(sys::state& state, int32_t oldx, int32_t oldy, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override {
488 auto location_abs = get_absolute_location(state, *this);
489 if(location_abs.x <= oldx && oldx < base_data.size.x + location_abs.x && location_abs.y <= oldy && oldy < base_data.size.y + location_abs.y) {
490 ui::xy_pair new_abs_pos = location_abs;
491 new_abs_pos.x += int16_t(x - oldx);
492 new_abs_pos.y += int16_t(y - oldy);
493 if(ui::ui_width(state) > base_data.size.x)
494 new_abs_pos.x = int16_t(std::clamp(int32_t(new_abs_pos.x), 0, ui::ui_width(state) - base_data.size.x));
495 if(ui::ui_height(state) > base_data.size.y)
496 new_abs_pos.y = int16_t(std::clamp(int32_t(new_abs_pos.y), 0, ui::ui_height(state) - base_data.size.y));
497 if(state.world.locale_get_native_rtl(state.font_collection.get_current_locale())) {
498 base_data.position.x -= int16_t(new_abs_pos.x - location_abs.x);
499 } else {
500 base_data.position.x += int16_t(new_abs_pos.x - location_abs.x);
501 }
502 base_data.position.y += int16_t(new_abs_pos.y - location_abs.y);
503 }
504 }
505 void on_update(sys::state& state) noexcept override;
506};
507std::unique_ptr<ui::element_base> make_macrobuilder2_main(sys::state& state);
509 int32_t value;
512 void on_create(sys::state& state) noexcept override;
513 ui::message_result test_mouse(sys::state& state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override {
515 }
516 void on_update(sys::state& state) noexcept override;
517 void* get_by_name(sys::state& state, std::string_view name) noexcept override {
518 if(name == "value") {
519 return (void*)(&value);
520 }
521 return nullptr;
522 }
523};
524std::unique_ptr<ui::element_base> make_macrobuilder2_list_item(sys::state& state);
526 dcon::unit_type_id value;
531 std::string_view texture_key;
532 dcon::texture_id background_texture;
533 void on_create(sys::state& state) noexcept override;
534 void render(sys::state & state, int32_t x, int32_t y) noexcept override;
535 ui::message_result on_lbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
536 ui::message_result on_rbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override;
537 ui::message_result test_mouse(sys::state& state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override {
539 }
540 void on_update(sys::state& state) noexcept override;
541 void* get_by_name(sys::state& state, std::string_view name) noexcept override {
542 if(name == "value") {
543 return (void*)(&value);
544 }
545 return nullptr;
546 }
547};
548std::unique_ptr<ui::element_base> make_macrobuilder2_grid_item(sys::state& state);
551 sound::play_interface_sound(state, sound::get_click_sound(state), state.user_settings.interface_volume* state.user_settings.master_volume);
552// BEGIN main::close_button::lbutton_action
553 main.set_visible(state, false);
555 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));
556// END
558}
561}
563 if(key == sys::virtual_key::ESCAPE) {
564 on_lbutton_down(state, 0, 0, mods);
566 }
568}
569void macrobuilder2_main_close_button_t::update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept {
570 text::add_line(state, contents, tooltip_key);
571}
572void macrobuilder2_main_close_button_t::render(sys::state & state, int32_t x, int32_t y) noexcept {
573 ogl::render_textured_rect(state, ui::get_color_modification(this == state.ui_state.under_mouse, false, true), float(x), float(y), float(base_data.size.x), float(base_data.size.y), ogl::get_late_load_texture_handle(state, background_texture, texture_key), base_data.get_rotation(), false, state.world.locale_get_native_rtl(state.font_collection.get_current_locale()));
574}
577// BEGIN main::close_button::update
578// END
579}
581// BEGIN main::close_button::create
582// END
583}
584void macrobuilder2_main_header_text_t::set_text(sys::state& state, std::string const& new_text) {
585 if(new_text != cached_text) {
586 cached_text = new_text;
589 text::single_line_layout sl{ internal_layout, text::layout_parameters{ 0, 0, static_cast<int16_t>(base_data.size.x), static_cast<int16_t>(base_data.size.y), text::make_font_id(state, text_is_header, text_scale * 18), 0, text_alignment, text::text_color::black, true, true }, state.world.locale_get_native_rtl(state.font_collection.get_current_locale()) ? text::layout_base::rtl_status::rtl : text::layout_base::rtl_status::ltr };
590 sl.add_text(state, cached_text);
591 }
592}
594 cached_text = text::produce_simple_string(state, text_key);
595 internal_layout.contents.clear();
596 internal_layout.number_of_lines = 0;
597 text::single_line_layout sl{ internal_layout, text::layout_parameters{ 0, 0, static_cast<int16_t>(base_data.size.x), static_cast<int16_t>(base_data.size.y), text::make_font_id(state, text_is_header, text_scale * 18), 0, text_alignment, text::text_color::black, true, true }, state.world.locale_get_native_rtl(state.font_collection.get_current_locale()) ? text::layout_base::rtl_status::rtl : text::layout_base::rtl_status::ltr };
598 sl.add_text(state, cached_text);
599}
600void macrobuilder2_main_header_text_t::render(sys::state & state, int32_t x, int32_t y) noexcept {
601 if(internal_layout.contents.empty()) return;
602 auto fh = text::make_font_id(state, text_is_header, text_scale * 18);
603 auto linesz = state.font_collection.line_height(state, fh);
604 if(linesz == 0.0f) return;
605 auto ycentered = (base_data.size.y - linesz) / 2;
606 auto cmod = ui::get_color_modification(this == state.ui_state.under_mouse, false, false);
607 for(auto& t : internal_layout.contents) {
608 ui::render_text_chunk(state, t, float(x) + t.x, float(y + int32_t(ycentered)), fh, ui::get_text_color(state, text_color), cmod);
609 }
610}
613// BEGIN main::header_text::update
614// END
615}
617 on_reset_text(state);
618// BEGIN main::header_text::create
619// END
620}
622 if(values.size() == 0) return 0;
623 if(visible_items.size() == 0) return 0;
624 return int32_t(values.size() - 1) / int32_t(visible_items.size());
625}
627 bool lflip = new_page < page && page > 0;
628 bool rflip = new_page > page && page < max_page();
629 if(rflip) {
630 auto pos = ui::get_absolute_location(state, *this);
631 state.ui_animation.start_animation(state, pos.x, pos.y, base_data.size.x, base_data.size.y, ogl::animation::type::page_flip_left, 200);
632 } else if(lflip) {
633 auto pos = ui::get_absolute_location(state, *this);
634 state.ui_animation.start_animation(state, pos.x, pos.y, base_data.size.x, base_data.size.y, ogl::animation::type::page_flip_left_rev, 200);
635 }
636 page = std::clamp(new_page, 0, max_page());
637 state.game_state_updated.store(true, std::memory_order::release);
638 if(rflip || lflip) {
639 impl_on_update(state);
640 state.ui_animation.post_update_frame(state);
641 }
642}
643ui::message_result macrobuilder2_main_template_list_t::on_scroll(sys::state& state, int32_t x, int32_t y, float amount, sys::key_modifiers mods) noexcept {
644 change_page(state, page + ((amount < 0) ? 1 : -1));
646}
649// BEGIN main::template_list::update
650// END
651 page = std::clamp(page, 0, max_page());
652 auto fill_count = visible_items.size();
653 auto fill_start = size_t(page) * fill_count;
654 for(size_t fill_position = 0; fill_position < fill_count; ++fill_position) {
655 if(fill_position + fill_start < values.size()) {
656 ((macrobuilder2_list_item_t*)visible_items[fill_position])->value = values[fill_position + fill_start];
657 visible_items[fill_position]->flags &= ~ui::element_base::is_invisible_mask;
658 } else {
659 visible_items[fill_position]->set_visible(state, false);
660 }
661 }
662}
664 auto ptr = make_macrobuilder2_list_item(state);
665 int32_t item_y_size = ptr->base_data.size.y;
666 visible_items.push_back(ptr.get());
667 add_child_to_back(std::move(ptr));
668 auto total_rows = int32_t(base_data.size.y) / item_y_size;
669 for(int32_t i = 1; i < total_rows; ++i) {
670 auto ptrb = make_macrobuilder2_list_item(state);
671 ptrb->base_data.position.y = int16_t(i * item_y_size);
672 visible_items.push_back(ptrb.get());
673 add_child_to_back(std::move(ptrb));
674 }
675// BEGIN main::template_list::create
677 auto f = simple_fs::open_file(sdir, state.loaded_scenario_file);
678 if(f) {
679 auto contents = simple_fs::view_contents(*f);
680
681 uint32_t num_templates = contents.file_size / sizeof(sys::macro_builder_template);
682 //Corruption protection
683 if(num_templates >= 8192 * 4)
684 num_templates = 8192 * 4;
685 state.ui_state.templates.resize(num_templates);
686 std::memcpy(state.ui_state.templates.data(), contents.data, num_templates * sizeof(sys::macro_builder_template));
687
688 for(int32_t i = -1; i < int32_t(num_templates); ++i) {
689 values.push_back(i);
690 }
691 } else {
692 values.push_back(-1);
693 }
694// END
695}
697 if(values.size() == 0) return 0;
698 if(visible_items.size() == 0) return 0;
699 return int32_t(values.size() - 1) / int32_t(visible_items.size());
700}
702 bool lflip = new_page < page && page > 0;
703 bool rflip = new_page > page && page < max_page();
704 if(rflip) {
705 auto pos = ui::get_absolute_location(state, *this);
706 state.ui_animation.start_animation(state, pos.x, pos.y, base_data.size.x, base_data.size.y, ogl::animation::type::page_flip_up, 200);
707 } else if(lflip) {
708 auto pos = ui::get_absolute_location(state, *this);
709 state.ui_animation.start_animation(state, pos.x, pos.y, base_data.size.x, base_data.size.y, ogl::animation::type::page_flip_up_rev, 200);
710 }
711 page = std::clamp(new_page, 0, max_page());
712 state.game_state_updated.store(true, std::memory_order::release);
713 if(rflip || lflip) {
714 impl_on_update(state);
715 state.ui_animation.post_update_frame(state);
716 }
717}
718ui::message_result macrobuilder2_main_unit_grid_t::on_scroll(sys::state& state, int32_t x, int32_t y, float amount, sys::key_modifiers mods) noexcept {
719 change_page(state, page + ((amount < 0) ? 1 : -1));
721}
724// BEGIN main::unit_grid::update
725// END
726 page = std::clamp(page, 0, max_page());
727 auto fill_count = visible_items.size();
728 auto fill_start = size_t(page) * fill_count;
729 for(size_t fill_position = 0; fill_position < fill_count; ++fill_position) {
730 if(fill_position + fill_start < values.size()) {
731 ((macrobuilder2_grid_item_t*)visible_items[fill_position])->value = values[fill_position + fill_start];
732 visible_items[fill_position]->flags &= ~ui::element_base::is_invisible_mask;
733 } else {
734 visible_items[fill_position]->set_visible(state, false);
735 }
736 }
737}
739 auto ptr = make_macrobuilder2_grid_item(state);
740 int32_t item_y_size = ptr->base_data.size.y;
741 int32_t item_x_size = ptr->base_data.size.x;
742 visible_items.push_back(ptr.get());
743 add_child_to_back(std::move(ptr));
744 auto total_rows = int32_t(base_data.size.y) / item_y_size;
745 auto total_columns = int32_t(base_data.size.x) / item_x_size;
746 for(int32_t i = 0; i < total_rows; ++i) {
747 for(int32_t j = (i == 0 ? 1 : 0); j < total_columns; ++j) {
748 auto ptrb = make_macrobuilder2_grid_item(state);
749 ptrb->base_data.position.y = int16_t(i * item_y_size);
750 ptrb->base_data.position.x = int16_t(j * item_x_size);
751 visible_items.push_back(ptrb.get());
752 add_child_to_back(std::move(ptrb));
753 }
754 }
755// BEGIN main::unit_grid::create
756 for(uint32_t i = 2; i < state.military_definitions.unit_base_definitions.size() && i < sys::macro_builder_template::max_types; ++i) {
757 dcon::unit_type_id id{ dcon::unit_type_id::value_base_t(i) };
758 if(state.military_definitions.unit_base_definitions[id].is_land) {
759 values.push_back(id);
760 }
761 }
762 while((values.size() % visible_items.size()) != 0) {
763 values.push_back(dcon::unit_type_id{});
764 }
765 for(uint32_t i = 2; i < state.military_definitions.unit_base_definitions.size() && i < sys::macro_builder_template::max_types; ++i) {
766 dcon::unit_type_id id{ dcon::unit_type_id::value_base_t(i) };
767 if(!state.military_definitions.unit_base_definitions[id].is_land) {
768 values.push_back(id);
769 }
770 }
771// END
772}
774 if(disabled) return ui::message_result::consumed;
776 sound::play_interface_sound(state, sound::get_click_sound(state), state.user_settings.interface_volume* state.user_settings.master_volume);
777// BEGIN main::list_page_left::lbutton_action
778 main.template_list->change_page(state, main.template_list->page - 1);
779// END
781}
784}
785void macrobuilder2_main_list_page_left_t::render(sys::state & state, int32_t x, int32_t y) noexcept {
786 ogl::render_textured_rect(state, ui::get_color_modification(this == state.ui_state.under_mouse, disabled, true), float(x), float(y), float(base_data.size.x), float(base_data.size.y), ogl::get_late_load_texture_handle(state, background_texture, texture_key), base_data.get_rotation(), false, state.world.locale_get_native_rtl(state.font_collection.get_current_locale()));
787}
790// BEGIN main::list_page_left::update
791 if(main.template_list->values.size() > main.template_list->visible_items.size()) {
792 element_base::flags &= ~element_base::is_invisible_mask;
793 } else {
794 element_base::flags |= element_base::is_invisible_mask;
795 }
796// END
797}
799// BEGIN main::list_page_left::create
800// END
801}
803 if(disabled) return ui::message_result::consumed;
805 sound::play_interface_sound(state, sound::get_click_sound(state), state.user_settings.interface_volume* state.user_settings.master_volume);
806// BEGIN main::list_page_right::lbutton_action
807 main.template_list->change_page(state, main.template_list->page + 1);
808// END
810}
813}
814void macrobuilder2_main_list_page_right_t::render(sys::state & state, int32_t x, int32_t y) noexcept {
815 ogl::render_textured_rect(state, ui::get_color_modification(this == state.ui_state.under_mouse, disabled, true), float(x), float(y), float(base_data.size.x), float(base_data.size.y), ogl::get_late_load_texture_handle(state, background_texture, texture_key), base_data.get_rotation(), false, state.world.locale_get_native_rtl(state.font_collection.get_current_locale()));
816}
819// BEGIN main::list_page_right::update
820 if(main.template_list->values.size() > main.template_list->visible_items.size()) {
821 element_base::flags &= ~element_base::is_invisible_mask;
822 } else {
823 element_base::flags |= element_base::is_invisible_mask;
824 }
825// END
826}
828// BEGIN main::list_page_right::create
829// END
830}
832 if(disabled) return ui::message_result::consumed;
834 sound::play_interface_sound(state, sound::get_click_sound(state), state.user_settings.interface_volume* state.user_settings.master_volume);
835// BEGIN main::grid_page_left::lbutton_action
836 main.unit_grid->change_page(state, main.unit_grid->page - 1);
837// END
839}
842}
843void macrobuilder2_main_grid_page_left_t::render(sys::state & state, int32_t x, int32_t y) noexcept {
844 ogl::render_textured_rect(state, ui::get_color_modification(this == state.ui_state.under_mouse, disabled, true), float(x), float(y), float(base_data.size.x), float(base_data.size.y), ogl::get_late_load_texture_handle(state, background_texture, texture_key), base_data.get_rotation(), false, state.world.locale_get_native_rtl(state.font_collection.get_current_locale()));
845}
848// BEGIN main::grid_page_left::update
849 if(main.unit_grid->values.size() > main.unit_grid->visible_items.size()) {
850 element_base::flags &= ~element_base::is_invisible_mask;
851 } else {
852 element_base::flags |= element_base::is_invisible_mask;
853 }
854// END
855}
857// BEGIN main::grid_page_left::create
858// END
859}
861 if(disabled) return ui::message_result::consumed;
863 sound::play_interface_sound(state, sound::get_click_sound(state), state.user_settings.interface_volume* state.user_settings.master_volume);
864// BEGIN main::grid_page_right::lbutton_action
865 main.unit_grid->change_page(state, main.unit_grid->page + 1);
866// END
868}
871}
872void macrobuilder2_main_grid_page_right_t::render(sys::state & state, int32_t x, int32_t y) noexcept {
873 ogl::render_textured_rect(state, ui::get_color_modification(this == state.ui_state.under_mouse, disabled, true), float(x), float(y), float(base_data.size.x), float(base_data.size.y), ogl::get_late_load_texture_handle(state, background_texture, texture_key), base_data.get_rotation(), false, state.world.locale_get_native_rtl(state.font_collection.get_current_locale()));
874}
877// BEGIN main::grid_page_right::update
878 if(main.unit_grid->values.size() > main.unit_grid->visible_items.size()) {
879 element_base::flags &= ~element_base::is_invisible_mask;
880 } else {
881 element_base::flags |= element_base::is_invisible_mask;
882 }
883// END
884}
886// BEGIN main::grid_page_right::create
887// END
888}
889void macrobuilder2_main_list_page_number_t::set_text(sys::state& state, std::string const& new_text) {
890 if(new_text != cached_text) {
891 cached_text = new_text;
894 text::single_line_layout sl{ internal_layout, text::layout_parameters{ 0, 0, static_cast<int16_t>(base_data.size.x), static_cast<int16_t>(base_data.size.y), text::make_font_id(state, text_is_header, text_scale * 18), 0, text_alignment, text::text_color::black, true, true }, state.world.locale_get_native_rtl(state.font_collection.get_current_locale()) ? text::layout_base::rtl_status::rtl : text::layout_base::rtl_status::ltr };
895 sl.add_text(state, cached_text);
896 }
897}
899}
900void macrobuilder2_main_list_page_number_t::render(sys::state & state, int32_t x, int32_t y) noexcept {
901 if(internal_layout.contents.empty()) return;
902 auto fh = text::make_font_id(state, text_is_header, text_scale * 18);
903 auto linesz = state.font_collection.line_height(state, fh);
904 if(linesz == 0.0f) return;
905 auto ycentered = (base_data.size.y - linesz) / 2;
906 auto cmod = ui::get_color_modification(this == state.ui_state.under_mouse, false, false);
907 for(auto& t : internal_layout.contents) {
908 ui::render_text_chunk(state, t, float(x) + t.x, float(y + int32_t(ycentered)), fh, ui::get_text_color(state, text_color), cmod);
909 }
910}
913// BEGIN main::list_page_number::update
914 if(main.template_list->values.size() > main.template_list->visible_items.size()) {
915 set_text(state, std::to_string(main.template_list->page + 1) + "/" + std::to_string(1 + main.template_list->max_page()));
916 } else {
917 set_text(state, "");
918 }
919// END
920}
922// BEGIN main::list_page_number::create
923// END
924}
925void macrobuilder2_main_grid_page_number_t::set_text(sys::state& state, std::string const& new_text) {
926 if(new_text != cached_text) {
927 cached_text = new_text;
930 text::single_line_layout sl{ internal_layout, text::layout_parameters{ 0, 0, static_cast<int16_t>(base_data.size.x), static_cast<int16_t>(base_data.size.y), text::make_font_id(state, text_is_header, text_scale * 18), 0, text_alignment, text::text_color::black, true, true }, state.world.locale_get_native_rtl(state.font_collection.get_current_locale()) ? text::layout_base::rtl_status::rtl : text::layout_base::rtl_status::ltr };
931 sl.add_text(state, cached_text);
932 }
933}
935}
936void macrobuilder2_main_grid_page_number_t::render(sys::state & state, int32_t x, int32_t y) noexcept {
937 if(internal_layout.contents.empty()) return;
938 auto fh = text::make_font_id(state, text_is_header, text_scale * 18);
939 auto linesz = state.font_collection.line_height(state, fh);
940 if(linesz == 0.0f) return;
941 auto ycentered = (base_data.size.y - linesz) / 2;
942 auto cmod = ui::get_color_modification(this == state.ui_state.under_mouse, false, false);
943 for(auto& t : internal_layout.contents) {
944 ui::render_text_chunk(state, t, float(x) + t.x, float(y + int32_t(ycentered)), fh, ui::get_text_color(state, text_color), cmod);
945 }
946}
949// BEGIN main::grid_page_number::update
950 if(main.unit_grid->values.size() > main.unit_grid->visible_items.size()) {
951 set_text(state, std::to_string(main.unit_grid->page + 1) + "/" + std::to_string(1 + main.unit_grid->max_page()));
952 } else {
953 set_text(state, "");
954 }
955// END
956}
958// BEGIN main::grid_page_number::create
959// END
960}
962 if(disabled) return ui::message_result::consumed;
964 sound::play_interface_sound(state, sound::get_click_sound(state), state.user_settings.interface_volume* state.user_settings.master_volume);
965// BEGIN main::apply_button::lbutton_action
966 if(state.ui_state.current_template < 0 || state.ui_state.current_template >= int32_t(state.ui_state.templates.size()))
968
969 auto const& t = state.ui_state.templates[state.ui_state.current_template];
970
971 bool is_land = true;
972 for(uint32_t i = 2; i < state.military_definitions.unit_base_definitions.size() && i < sys::macro_builder_template::max_types; ++i) {
973 dcon::unit_type_id id{ dcon::unit_type_id::value_base_t(i) };
974 if(!state.military_definitions.unit_base_definitions[id].is_land && t.amounts[i] > 0) {
975 is_land = false;
976 }
977 }
978
979 const auto template_province = state.map_state.selected_province;
980
981 std::vector<dcon::province_id> provinces;
982 state.fill_vector_of_connected_provinces(state.map_state.selected_province, is_land, provinces);
983 if(provinces.empty())
985
986 if(is_land) {
987 std::array<uint8_t, sys::macro_builder_template::max_types> current_distribution;
988 current_distribution.fill(0);
989 state.build_up_to_template_land(
990 t,
991 state.map_state.selected_province,
992 provinces,
993 current_distribution
994 );
995 } else {
997 std::memcpy(rem_to_build, t.amounts, sizeof(rem_to_build));
998
999 std::sort(provinces.begin(), provinces.end(), [&state](auto const a, auto const b) {
1000 auto ab = state.world.province_get_province_naval_construction_as_province(a);
1001 auto bb = state.world.province_get_province_naval_construction_as_province(b);
1002 int32_t asz = int32_t(ab.end() - ab.begin());
1003 int32_t bsz = int32_t(bb.end() - bb.begin());
1004 if(asz == bsz)
1005 return a.index() < b.index();
1006 return asz < bsz;
1007 });
1008 for(dcon::unit_type_id::value_base_t i = 0; i < sys::macro_builder_template::max_types; i++) {
1009 dcon::unit_type_id utid = dcon::unit_type_id(i);
1010 if(rem_to_build[i] > 0
1011 && is_land == state.military_definitions.unit_base_definitions[utid].is_land
1012 && (state.military_definitions.unit_base_definitions[utid].active || state.world.nation_get_active_unit(state.local_player_nation, utid))) {
1013 for(const auto prov : provinces) {
1014 auto const port_level = state.world.province_get_building_level(prov, uint8_t(economy::province_building_type::naval_base));
1015 if(port_level >= state.military_definitions.unit_base_definitions[utid].min_port_level
1016 && command::can_start_naval_unit_construction(state, state.local_player_nation, prov, utid, template_province)) {
1017 command::start_naval_unit_construction(state, state.local_player_nation, prov, utid, template_province);
1018 rem_to_build[i]--;
1019 if(rem_to_build[i] == 0)
1020 break;
1021 }
1022 }
1023 // sort provinces again so that the ships can be built on parallel
1024 std::sort(provinces.begin(), provinces.end(), [&state](auto const a, auto const b) {
1025 auto ab = state.world.province_get_province_naval_construction_as_province(a);
1026 auto bb = state.world.province_get_province_naval_construction_as_province(b);
1027 int32_t asz = int32_t(ab.end() - ab.begin());
1028 int32_t bsz = int32_t(bb.end() - bb.begin());
1029 if(asz == bsz)
1030 return a.index() < b.index();
1031 return asz < bsz;
1032 });
1033 }
1034 }
1035 }
1036 state.game_state_updated.store(true, std::memory_order::release);
1037// END
1039}
1042}
1043void macrobuilder2_main_apply_button_t::set_text(sys::state& state, std::string const& new_text) {
1044 if(new_text != cached_text) {
1045 cached_text = new_text;
1046 internal_layout.contents.clear();
1048 text::single_line_layout sl{ internal_layout, text::layout_parameters{ 0, 0, static_cast<int16_t>(base_data.size.x), static_cast<int16_t>(base_data.size.y), text::make_font_id(state, text_is_header, text_scale * 18), 0, text_alignment, text::text_color::black, true, true }, state.world.locale_get_native_rtl(state.font_collection.get_current_locale()) ? text::layout_base::rtl_status::rtl : text::layout_base::rtl_status::ltr };
1049 sl.add_text(state, cached_text);
1050 }
1051}
1053 cached_text = text::produce_simple_string(state, text_key);
1054 internal_layout.contents.clear();
1055 internal_layout.number_of_lines = 0;
1056 text::single_line_layout sl{ internal_layout, text::layout_parameters{ 0, 0, static_cast<int16_t>(base_data.size.x), static_cast<int16_t>(base_data.size.y), text::make_font_id(state, text_is_header, text_scale * 18), 0, text_alignment, text::text_color::black, true, true }, state.world.locale_get_native_rtl(state.font_collection.get_current_locale()) ? text::layout_base::rtl_status::rtl : text::layout_base::rtl_status::ltr };
1057 sl.add_text(state, cached_text);
1058}
1059void macrobuilder2_main_apply_button_t::render(sys::state & state, int32_t x, int32_t y) noexcept {
1060 ogl::render_textured_rect(state, ui::get_color_modification(this == state.ui_state.under_mouse, disabled, true), float(x), float(y), float(base_data.size.x), float(base_data.size.y), ogl::get_late_load_texture_handle(state, background_texture, texture_key), base_data.get_rotation(), false, state.world.locale_get_native_rtl(state.font_collection.get_current_locale()));
1061 if(internal_layout.contents.empty()) return;
1062 auto fh = text::make_font_id(state, text_is_header, text_scale * 18);
1063 auto linesz = state.font_collection.line_height(state, fh);
1064 if(linesz == 0.0f) return;
1065 auto ycentered = (base_data.size.y - linesz) / 2;
1066 auto cmod = ui::get_color_modification(this == state.ui_state.under_mouse, disabled, true);
1067 for(auto& t : internal_layout.contents) {
1068 ui::render_text_chunk(state, t, float(x) + t.x, float(y + int32_t(ycentered)), fh, ui::get_text_color(state, text_color), cmod);
1069 }
1070}
1073// BEGIN main::apply_button::update
1074 disabled = (state.ui_state.current_template == -1 || state.map_state.selected_province == dcon::province_id{} || state.world.province_get_nation_from_province_ownership(state.map_state.selected_province) != state.local_player_nation || state.world.province_get_nation_from_province_control(state.map_state.selected_province) != state.local_player_nation);
1075// END
1076}
1078 on_reset_text(state);
1079// BEGIN main::apply_button::create
1080// END
1081}
1083 state.ui_state.drag_target = this;
1085}
1088}
1089void macrobuilder2_main_t::render(sys::state & state, int32_t x, int32_t y) noexcept {
1090 ogl::render_textured_rect(state, ui::get_color_modification(this == state.ui_state.under_mouse, false, false), float(x), float(y), float(base_data.size.x), float(base_data.size.y), ogl::get_late_load_texture_handle(state, background_texture, texture_key), base_data.get_rotation(), false, state.world.locale_get_native_rtl(state.font_collection.get_current_locale()));
1091}
1093// BEGIN main::update
1094// END
1095}
1097 auto window_bytes = state.ui_state.new_ui_windows.find(std::string("macrobuilder2::main"));
1098 if(window_bytes == state.ui_state.new_ui_windows.end()) std::abort();
1099 std::vector<sys::aui_pending_bytes> pending_children;
1100 auto win_data = read_window_bytes(window_bytes->second.data, window_bytes->second.size, pending_children);
1101 base_data.position.x = win_data.x_pos;
1102 base_data.position.y = win_data.y_pos;
1103 base_data.size.x = win_data.x_size;
1104 base_data.size.y = win_data.y_size;
1105 base_data.flags = uint8_t(win_data.orientation);
1106 texture_key = win_data.texture;
1107 auto name_key = state.lookup_key("macrobuilder2::main");
1108 for(auto ex : state.ui_defs.extensions) {
1109 if(name_key && ex.window == name_key) {
1110 auto ch_res = ui::make_element_immediate(state, ex.child);
1111 if(ch_res) {
1112 this->add_child_to_back(std::move(ch_res));
1113 }
1114 }
1115 }
1116 while(!pending_children.empty()) {
1117 auto child_data = read_child_bytes(pending_children.back().data, pending_children.back().size);
1118 pending_children.pop_back();
1119 if(child_data.name == "close_button") {
1120 auto cptr = std::make_unique<macrobuilder2_main_close_button_t>();
1121 cptr->parent = this;
1122 close_button = cptr.get();
1123 cptr->base_data.position.x = child_data.x_pos;
1124 cptr->base_data.position.y = child_data.y_pos;
1125 cptr->base_data.size.x = child_data.x_size;
1126 cptr->base_data.size.y = child_data.y_size;
1127 cptr->texture_key = child_data.texture;
1128 cptr->tooltip_key = state.lookup_key(child_data.tooltip_text_key);
1129 cptr->on_create(state);
1130 this->add_child_to_back(std::move(cptr));
1131 continue;
1132 }
1133 if(child_data.name == "header_text") {
1134 auto cptr = std::make_unique<macrobuilder2_main_header_text_t>();
1135 cptr->parent = this;
1136 header_text = cptr.get();
1137 cptr->base_data.position.x = child_data.x_pos;
1138 cptr->base_data.position.y = child_data.y_pos;
1139 cptr->base_data.size.x = child_data.x_size;
1140 cptr->base_data.size.y = child_data.y_size;
1141 cptr->text_key = state.lookup_key(child_data.text_key);
1142 cptr->text_scale = child_data.text_scale;
1143 cptr->text_is_header = (child_data.text_type == aui_text_type::header);
1144 cptr->text_alignment = child_data.text_alignment;
1145 cptr->text_color = child_data.text_color;
1146 cptr->on_create(state);
1147 this->add_child_to_back(std::move(cptr));
1148 continue;
1149 }
1150 if(child_data.name == "template_list") {
1151 auto cptr = std::make_unique<macrobuilder2_main_template_list_t>();
1152 cptr->parent = this;
1153 template_list = cptr.get();
1154 cptr->base_data.position.x = child_data.x_pos;
1155 cptr->base_data.position.y = child_data.y_pos;
1156 cptr->base_data.size.x = child_data.x_size;
1157 cptr->base_data.size.y = child_data.y_size;
1158 cptr->on_create(state);
1159 this->add_child_to_back(std::move(cptr));
1160 continue;
1161 }
1162 if(child_data.name == "unit_grid") {
1163 auto cptr = std::make_unique<macrobuilder2_main_unit_grid_t>();
1164 cptr->parent = this;
1165 unit_grid = cptr.get();
1166 cptr->base_data.position.x = child_data.x_pos;
1167 cptr->base_data.position.y = child_data.y_pos;
1168 cptr->base_data.size.x = child_data.x_size;
1169 cptr->base_data.size.y = child_data.y_size;
1170 cptr->on_create(state);
1171 this->add_child_to_back(std::move(cptr));
1172 continue;
1173 }
1174 if(child_data.name == "list_page_left") {
1175 auto cptr = std::make_unique<macrobuilder2_main_list_page_left_t>();
1176 cptr->parent = this;
1177 list_page_left = cptr.get();
1178 cptr->base_data.position.x = child_data.x_pos;
1179 cptr->base_data.position.y = child_data.y_pos;
1180 cptr->base_data.size.x = child_data.x_size;
1181 cptr->base_data.size.y = child_data.y_size;
1183 cptr->texture_key = child_data.texture;
1184 cptr->on_create(state);
1185 this->add_child_to_back(std::move(cptr));
1186 continue;
1187 }
1188 if(child_data.name == "list_page_right") {
1189 auto cptr = std::make_unique<macrobuilder2_main_list_page_right_t>();
1190 cptr->parent = this;
1191 list_page_right = cptr.get();
1192 cptr->base_data.position.x = child_data.x_pos;
1193 cptr->base_data.position.y = child_data.y_pos;
1194 cptr->base_data.size.x = child_data.x_size;
1195 cptr->base_data.size.y = child_data.y_size;
1197 cptr->texture_key = child_data.texture;
1198 cptr->on_create(state);
1199 this->add_child_to_back(std::move(cptr));
1200 continue;
1201 }
1202 if(child_data.name == "grid_page_left") {
1203 auto cptr = std::make_unique<macrobuilder2_main_grid_page_left_t>();
1204 cptr->parent = this;
1205 grid_page_left = cptr.get();
1206 cptr->base_data.position.x = child_data.x_pos;
1207 cptr->base_data.position.y = child_data.y_pos;
1208 cptr->base_data.size.x = child_data.x_size;
1209 cptr->base_data.size.y = child_data.y_size;
1211 cptr->texture_key = child_data.texture;
1212 cptr->on_create(state);
1213 this->add_child_to_back(std::move(cptr));
1214 continue;
1215 }
1216 if(child_data.name == "grid_page_right") {
1217 auto cptr = std::make_unique<macrobuilder2_main_grid_page_right_t>();
1218 cptr->parent = this;
1219 grid_page_right = cptr.get();
1220 cptr->base_data.position.x = child_data.x_pos;
1221 cptr->base_data.position.y = child_data.y_pos;
1222 cptr->base_data.size.x = child_data.x_size;
1223 cptr->base_data.size.y = child_data.y_size;
1225 cptr->texture_key = child_data.texture;
1226 cptr->on_create(state);
1227 this->add_child_to_back(std::move(cptr));
1228 continue;
1229 }
1230 if(child_data.name == "list_page_number") {
1231 auto cptr = std::make_unique<macrobuilder2_main_list_page_number_t>();
1232 cptr->parent = this;
1233 list_page_number = cptr.get();
1234 cptr->base_data.position.x = child_data.x_pos;
1235 cptr->base_data.position.y = child_data.y_pos;
1236 cptr->base_data.size.x = child_data.x_size;
1237 cptr->base_data.size.y = child_data.y_size;
1238 cptr->text_scale = child_data.text_scale;
1239 cptr->text_is_header = (child_data.text_type == aui_text_type::header);
1240 cptr->text_alignment = child_data.text_alignment;
1241 cptr->text_color = child_data.text_color;
1242 cptr->on_create(state);
1243 this->add_child_to_back(std::move(cptr));
1244 continue;
1245 }
1246 if(child_data.name == "grid_page_number") {
1247 auto cptr = std::make_unique<macrobuilder2_main_grid_page_number_t>();
1248 cptr->parent = this;
1249 grid_page_number = cptr.get();
1250 cptr->base_data.position.x = child_data.x_pos;
1251 cptr->base_data.position.y = child_data.y_pos;
1252 cptr->base_data.size.x = child_data.x_size;
1253 cptr->base_data.size.y = child_data.y_size;
1254 cptr->text_scale = child_data.text_scale;
1255 cptr->text_is_header = (child_data.text_type == aui_text_type::header);
1256 cptr->text_alignment = child_data.text_alignment;
1257 cptr->text_color = child_data.text_color;
1258 cptr->on_create(state);
1259 this->add_child_to_back(std::move(cptr));
1260 continue;
1261 }
1262 if(child_data.name == "apply_button") {
1263 auto cptr = std::make_unique<macrobuilder2_main_apply_button_t>();
1264 cptr->parent = this;
1265 apply_button = cptr.get();
1266 cptr->base_data.position.x = child_data.x_pos;
1267 cptr->base_data.position.y = child_data.y_pos;
1268 cptr->base_data.size.x = child_data.x_size;
1269 cptr->base_data.size.y = child_data.y_size;
1270 cptr->texture_key = child_data.texture;
1271 cptr->text_key = state.lookup_key(child_data.text_key);
1272 cptr->text_scale = child_data.text_scale;
1273 cptr->text_is_header = (child_data.text_type == aui_text_type::header);
1274 cptr->text_alignment = child_data.text_alignment;
1275 cptr->text_color = child_data.text_color;
1276 cptr->on_create(state);
1277 this->add_child_to_back(std::move(cptr));
1278 continue;
1279 }
1280 }
1281// BEGIN main::create
1282// END
1283}
1284std::unique_ptr<ui::element_base> make_macrobuilder2_main(sys::state& state) {
1285 auto ptr = std::make_unique<macrobuilder2_main_t>();
1286 ptr->on_create(state);
1287 return ptr;
1288}
1290 macrobuilder2_list_item_t& list_item = *((macrobuilder2_list_item_t*)(parent));
1291 macrobuilder2_main_t& main = *((macrobuilder2_main_t*)(parent->parent->parent));
1292 sound::play_interface_sound(state, sound::get_click_sound(state), state.user_settings.interface_volume* state.user_settings.master_volume);
1293// BEGIN list_item::select_button::lbutton_action
1294 state.ui_state.current_template = list_item.value;
1295 state.game_state_updated.store(true, std::memory_order::release);
1296// END
1298}
1301}
1302void macrobuilder2_list_item_select_button_t::set_text(sys::state& state, std::string const& new_text) {
1303 if(new_text != cached_text) {
1304 cached_text = new_text;
1305 internal_layout.contents.clear();
1307 text::single_line_layout sl{ internal_layout, text::layout_parameters{ 0, 0, static_cast<int16_t>(base_data.size.x), static_cast<int16_t>(base_data.size.y), text::make_font_id(state, text_is_header, text_scale * 18), 0, text_alignment, text::text_color::black, true, true }, state.world.locale_get_native_rtl(state.font_collection.get_current_locale()) ? text::layout_base::rtl_status::rtl : text::layout_base::rtl_status::ltr };
1308 sl.add_text(state, cached_text);
1309 }
1310}
1312}
1313void macrobuilder2_list_item_select_button_t::render(sys::state & state, int32_t x, int32_t y) noexcept {
1314 if(is_active)
1315 ogl::render_textured_rect(state, ui::get_color_modification(this == state.ui_state.under_mouse, false, true), float(x), float(y), float(base_data.size.x), float(base_data.size.y), ogl::get_late_load_texture_handle(state, alt_background_texture, alt_texture_key), base_data.get_rotation(), false, state.world.locale_get_native_rtl(state.font_collection.get_current_locale()));
1316 else
1317 ogl::render_textured_rect(state, ui::get_color_modification(this == state.ui_state.under_mouse, false, true), float(x), float(y), float(base_data.size.x), float(base_data.size.y), ogl::get_late_load_texture_handle(state, background_texture, texture_key), base_data.get_rotation(), false, state.world.locale_get_native_rtl(state.font_collection.get_current_locale()));
1318 if(internal_layout.contents.empty()) return;
1319 auto fh = text::make_font_id(state, text_is_header, text_scale * 18);
1320 auto linesz = state.font_collection.line_height(state, fh);
1321 if(linesz == 0.0f) return;
1322 auto ycentered = (base_data.size.y - linesz) / 2;
1323 auto cmod = ui::get_color_modification(this == state.ui_state.under_mouse, false, true);
1324 for(auto& t : internal_layout.contents) {
1325 ui::render_text_chunk(state, t, float(x) + t.x, float(y + int32_t(ycentered)), fh, ui::get_text_color(state, text_color), cmod);
1326 }
1327}
1329 macrobuilder2_list_item_t& list_item = *((macrobuilder2_list_item_t*)(parent));
1330 macrobuilder2_main_t& main = *((macrobuilder2_main_t*)(parent->parent->parent));
1331// BEGIN list_item::select_button::update
1332 if(list_item.value == state.ui_state.current_template) {
1333 is_active = true;
1335 } else {
1336 is_active = false;
1338 }
1339 if(list_item.value == -1) {
1340 set_text(state, text::produce_simple_string(state, "macro_new_template"));
1341 return;
1342 }
1343 if(list_item.value >= int32_t(state.ui_state.templates.size()))
1344 return;
1345
1346 std::string accumulated;
1347 for(dcon::unit_type_id::value_base_t i = 2; i < state.military_definitions.unit_base_definitions.size() && i < sys::macro_builder_template::max_types; i++) {
1348 auto amount = state.ui_state.templates[list_item.value].amounts[i];
1349 if(amount < 1) {
1350 continue;
1351 }
1352 accumulated += std::to_string(amount);
1353 accumulated += "@*" + std::string(i < 10 ? "0" : "") + std::to_string(i);
1354 }
1355 set_text(state, accumulated);
1356// END
1357}
1359// BEGIN list_item::select_button::create
1360// END
1361}
1363 macrobuilder2_list_item_t& list_item = *((macrobuilder2_list_item_t*)(parent));
1364 macrobuilder2_main_t& main = *((macrobuilder2_main_t*)(parent->parent->parent));
1365 sound::play_interface_sound(state, sound::get_click_sound(state), state.user_settings.interface_volume* state.user_settings.master_volume);
1366// BEGIN list_item::delete_button::lbutton_action
1367 if(list_item.value != -1) {
1368 if(list_item.value == state.ui_state.current_template) {
1369 state.ui_state.current_template = -1;
1370 }
1371 state.ui_state.templates.erase(state.ui_state.templates.begin() + list_item.value);
1372 main.template_list->values.pop_back();
1373 state.game_state_updated.store(true, std::memory_order::release);
1374 }
1375// END
1377}
1380}
1382 text::add_line(state, contents, tooltip_key);
1383}
1384void macrobuilder2_list_item_delete_button_t::render(sys::state & state, int32_t x, int32_t y) noexcept {
1385 ogl::render_textured_rect(state, ui::get_color_modification(this == state.ui_state.under_mouse, false, true), float(x), float(y), float(base_data.size.x), float(base_data.size.y), ogl::get_late_load_texture_handle(state, background_texture, texture_key), base_data.get_rotation(), false, state.world.locale_get_native_rtl(state.font_collection.get_current_locale()));
1386}
1388 macrobuilder2_list_item_t& list_item = *((macrobuilder2_list_item_t*)(parent));
1389 macrobuilder2_main_t& main = *((macrobuilder2_main_t*)(parent->parent->parent));
1390// BEGIN list_item::delete_button::update
1391 if(list_item.value != -1) {
1392 element_base::flags &= ~element_base::is_invisible_mask;
1393 } else {
1394 element_base::flags |= element_base::is_invisible_mask;
1395 }
1396// END
1397}
1399// BEGIN list_item::delete_button::create
1400// END
1401}
1403 macrobuilder2_main_t& main = *((macrobuilder2_main_t*)(parent->parent));
1404// BEGIN list_item::update
1405// END
1406}
1408 auto window_bytes = state.ui_state.new_ui_windows.find(std::string("macrobuilder2::list_item"));
1409 if(window_bytes == state.ui_state.new_ui_windows.end()) std::abort();
1410 std::vector<sys::aui_pending_bytes> pending_children;
1411 auto win_data = read_window_bytes(window_bytes->second.data, window_bytes->second.size, pending_children);
1412 base_data.position.x = win_data.x_pos;
1413 base_data.position.y = win_data.y_pos;
1414 base_data.size.x = win_data.x_size;
1415 base_data.size.y = win_data.y_size;
1416 base_data.flags = uint8_t(win_data.orientation);
1417 auto name_key = state.lookup_key("macrobuilder2::list_item");
1418 for(auto ex : state.ui_defs.extensions) {
1419 if(name_key && ex.window == name_key) {
1420 auto ch_res = ui::make_element_immediate(state, ex.child);
1421 if(ch_res) {
1422 this->add_child_to_back(std::move(ch_res));
1423 }
1424 }
1425 }
1426 while(!pending_children.empty()) {
1427 auto child_data = read_child_bytes(pending_children.back().data, pending_children.back().size);
1428 pending_children.pop_back();
1429 if(child_data.name == "select_button") {
1430 auto cptr = std::make_unique<macrobuilder2_list_item_select_button_t>();
1431 cptr->parent = this;
1432 select_button = cptr.get();
1433 cptr->base_data.position.x = child_data.x_pos;
1434 cptr->base_data.position.y = child_data.y_pos;
1435 cptr->base_data.size.x = child_data.x_size;
1436 cptr->base_data.size.y = child_data.y_size;
1437 cptr->texture_key = child_data.texture;
1438 cptr->alt_texture_key = child_data.alt_texture;
1439 cptr->text_scale = child_data.text_scale;
1440 cptr->text_is_header = (child_data.text_type == aui_text_type::header);
1441 cptr->text_alignment = child_data.text_alignment;
1442 cptr->text_color = child_data.text_color;
1443 cptr->on_create(state);
1444 this->add_child_to_back(std::move(cptr));
1445 continue;
1446 }
1447 if(child_data.name == "delete_button") {
1448 auto cptr = std::make_unique<macrobuilder2_list_item_delete_button_t>();
1449 cptr->parent = this;
1450 delete_button = cptr.get();
1451 cptr->base_data.position.x = child_data.x_pos;
1452 cptr->base_data.position.y = child_data.y_pos;
1453 cptr->base_data.size.x = child_data.x_size;
1454 cptr->base_data.size.y = child_data.y_size;
1456 cptr->texture_key = child_data.texture;
1457 cptr->tooltip_key = state.lookup_key(child_data.tooltip_text_key);
1458 cptr->on_create(state);
1459 this->add_child_to_back(std::move(cptr));
1460 continue;
1461 }
1462 }
1463// BEGIN list_item::create
1464// END
1465}
1466std::unique_ptr<ui::element_base> make_macrobuilder2_list_item(sys::state& state) {
1467 auto ptr = std::make_unique<macrobuilder2_list_item_t>();
1468 ptr->on_create(state);
1469 return ptr;
1470}
1473}
1476}
1477void macrobuilder2_grid_item_unit_icon_t::update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept {
1478 macrobuilder2_grid_item_t& grid_item = *((macrobuilder2_grid_item_t*)(parent));
1479 macrobuilder2_main_t& main = *((macrobuilder2_main_t*)(parent->parent->parent));
1480// BEGIN grid_item::unit_icon::tooltip
1481 text::add_line(state, contents, state.military_definitions.unit_base_definitions[grid_item.value].name);
1482 text::add_line_break_to_layout(state, contents);
1483 auto utid = grid_item.value;
1484 auto is_land = state.military_definitions.unit_base_definitions[utid].is_land;
1485
1486 float reconnaissance_or_fire_range = 0.f;
1487 float siege_or_torpedo_attack = 0.f;
1488 float attack_or_gun_power = 0.f;
1489 float defence_or_hull = 0.f;
1490 float discipline_or_evasion = std::numeric_limits<float>::max();
1491 float support = 0.f;
1492 float supply_consumption = 0.f;
1493 float maximum_speed = std::numeric_limits<float>::max();
1494 float maneuver = std::numeric_limits<float>::max();
1495 int32_t supply_consumption_score = 0;
1496 bool warn_overseas = false;
1497 bool warn_culture = false;
1498 bool warn_active = false;
1499
1500
1501
1502 if(!state.military_definitions.unit_base_definitions[utid].active && !state.world.nation_get_active_unit(state.local_player_nation, utid))
1503 warn_active = true;
1504 if(state.military_definitions.unit_base_definitions[utid].primary_culture)
1505 warn_culture = true;
1506 if(!state.military_definitions.unit_base_definitions[utid].can_build_overseas)
1507 warn_overseas = true;
1508
1509 reconnaissance_or_fire_range += state.world.nation_get_unit_stats(state.local_player_nation, utid).reconnaissance_or_fire_range;
1510 siege_or_torpedo_attack += state.world.nation_get_unit_stats(state.local_player_nation, utid).siege_or_torpedo_attack;
1511 attack_or_gun_power += state.world.nation_get_unit_stats(state.local_player_nation, utid).attack_or_gun_power;
1512 defence_or_hull += state.world.nation_get_unit_stats(state.local_player_nation, utid).defence_or_hull ;
1513 discipline_or_evasion += std::min(discipline_or_evasion, state.world.nation_get_unit_stats(state.local_player_nation, utid).discipline_or_evasion);
1514 supply_consumption += state.world.nation_get_unit_stats(state.local_player_nation, utid).supply_consumption;
1515 maximum_speed = std::min(maximum_speed, state.world.nation_get_unit_stats(state.local_player_nation, utid).maximum_speed);
1516 if(is_land) {
1517 support += state.world.nation_get_unit_stats(state.local_player_nation, utid).support ;
1518 maneuver += std::min(maneuver, state.military_definitions.unit_base_definitions[utid].maneuver);
1519 } else {
1520 supply_consumption_score += state.military_definitions.unit_base_definitions[utid].supply_consumption_score;
1521 }
1522
1523
1524 if(warn_overseas)
1525 text::add_line(state, contents, "macro_warn_overseas");
1526 if(warn_culture)
1527 text::add_line(state, contents, "macro_warn_culture");
1528 if(warn_active)
1529 text::add_line(state, contents, "macro_warn_unlocked");
1530
1531 if(maximum_speed == std::numeric_limits<float>::max()) maximum_speed = 0.f;
1532 if(discipline_or_evasion == std::numeric_limits<float>::max()) discipline_or_evasion = 0.f;
1533 if(maneuver == std::numeric_limits<float>::max()) maneuver = 0.f;
1534 if(is_land) {
1535 if(reconnaissance_or_fire_range > 0.f) {
1536 text::add_line(state, contents, "unit_recon", text::variable_type::x, text::format_float(reconnaissance_or_fire_range, 2));
1537 }
1538 if(siege_or_torpedo_attack > 0.f) {
1539 text::add_line(state, contents, "unit_siege", text::variable_type::x, text::format_float(siege_or_torpedo_attack, 2));
1540 }
1541 text::add_line(state, contents, "unit_attack", text::variable_type::x, text::format_float(attack_or_gun_power, 2));
1542 text::add_line(state, contents, "unit_defence", text::variable_type::x, text::format_float(defence_or_hull, 2));
1543 text::add_line(state, contents, "unit_discipline", text::variable_type::x, text::format_percentage(discipline_or_evasion, 0));
1544 if(support > 0.f) {
1545 text::add_line(state, contents, "unit_support", text::variable_type::x, text::format_float(support, 0));
1546 }
1547 text::add_line(state, contents, "unit_maneuver", text::variable_type::x, text::format_float(maneuver, 0));
1548 text::add_line(state, contents, "unit_max_speed", text::variable_type::x, text::format_float(maximum_speed, 2));
1549 text::add_line(state, contents, "unit_supply_consumption", text::variable_type::x, text::format_percentage(supply_consumption, 0));
1550 } else {
1551 text::add_line(state, contents, "unit_max_speed", text::variable_type::x, text::format_float(maximum_speed, 2));
1552 text::add_line(state, contents, "unit_attack", text::variable_type::x, text::format_float(attack_or_gun_power, 2));
1553 if(siege_or_torpedo_attack > 0.f) {
1554 text::add_line(state, contents, "unit_torpedo_attack", text::variable_type::x, text::format_float(siege_or_torpedo_attack, 2));
1555 }
1556 text::add_line(state, contents, "unit_hull", text::variable_type::x, text::format_float(defence_or_hull, 2));
1557 text::add_line(state, contents, "unit_fire_range", text::variable_type::x, text::format_float(reconnaissance_or_fire_range, 2));
1558 if(discipline_or_evasion > 0.f) {
1559 text::add_line(state, contents, "unit_evasion", text::variable_type::x, text::format_percentage(discipline_or_evasion, 0));
1560 }
1561 text::add_line(state, contents, "unit_supply_consumption", text::variable_type::x, text::format_percentage(supply_consumption, 0));
1562 text::add_line(state, contents, "unit_supply_load", text::variable_type::x, supply_consumption_score);
1563 }
1564// END
1565}
1566void macrobuilder2_grid_item_unit_icon_t::render(sys::state & state, int32_t x, int32_t y) noexcept {
1567 if(background_gid) {
1568 auto& gfx_def = state.ui_defs.gfx[background_gid];
1569 if(gfx_def.primary_texture_handle) {
1570 if(gfx_def.get_object_type() == ui::object_type::bordered_rect) {
1571 ogl::render_bordered_rect(state, ui::get_color_modification(this == state.ui_state.under_mouse, false, false), gfx_def.type_dependent, float(x), float(y), float(base_data.size.x), float(base_data.size.y), ogl::get_texture_handle(state, gfx_def.primary_texture_handle, gfx_def.is_partially_transparent()), base_data.get_rotation(), gfx_def.is_vertically_flipped(), state.world.locale_get_native_rtl(state.font_collection.get_current_locale()));
1572 } else if(gfx_def.number_of_frames > 1) {
1573 ogl::render_subsprite(state, ui::get_color_modification(this == state.ui_state.under_mouse, false, false), frame, gfx_def.number_of_frames, float(x), float(y), float(base_data.size.x), float(base_data.size.y), ogl::get_texture_handle(state, gfx_def.primary_texture_handle, gfx_def.is_partially_transparent()), base_data.get_rotation(), gfx_def.is_vertically_flipped(), state.world.locale_get_native_rtl(state.font_collection.get_current_locale()));
1574 } else {
1575 ogl::render_textured_rect(state, ui::get_color_modification(this == state.ui_state.under_mouse, false, false), float(x), float(y), float(base_data.size.x), float(base_data.size.y), ogl::get_texture_handle(state, gfx_def.primary_texture_handle, gfx_def.is_partially_transparent()), base_data.get_rotation(), gfx_def.is_vertically_flipped(), state.world.locale_get_native_rtl(state.font_collection.get_current_locale()));
1576 }
1577 }
1578 }
1579}
1581 macrobuilder2_grid_item_t& grid_item = *((macrobuilder2_grid_item_t*)(parent));
1582 macrobuilder2_main_t& main = *((macrobuilder2_main_t*)(parent->parent->parent));
1583// BEGIN grid_item::unit_icon::update
1584 if(!grid_item.value)
1585 return;
1586 frame = state.military_definitions.unit_base_definitions[grid_item.value].icon - 1;
1587// END
1588}
1590 if(auto it = state.ui_state.gfx_by_name.find(state.lookup_key(gfx_key)); it != state.ui_state.gfx_by_name.end()) {
1591 background_gid = it->second;
1592 }
1593// BEGIN grid_item::unit_icon::create
1594// END
1595}
1597 if(disabled) return ui::message_result::consumed;
1598 macrobuilder2_grid_item_t& grid_item = *((macrobuilder2_grid_item_t*)(parent));
1599 macrobuilder2_main_t& main = *((macrobuilder2_main_t*)(parent->parent->parent));
1600 sound::play_interface_sound(state, sound::get_click_sound(state), state.user_settings.interface_volume* state.user_settings.master_volume);
1602// BEGIN grid_item::decrease_count::lbutton_shift_action
1603 if(state.ui_state.current_template != -1) {
1604 auto& v = state.ui_state.templates[state.ui_state.current_template].amounts[grid_item.value.index()];
1605 v = uint8_t(std::clamp(v - 10, 0, 255));
1606 }
1607 state.game_state_updated.store(true, std::memory_order::release);
1608// END
1610 }
1611// BEGIN grid_item::decrease_count::lbutton_action
1612 if(state.ui_state.current_template != -1) {
1613 auto& v = state.ui_state.templates[state.ui_state.current_template].amounts[grid_item.value.index()];
1614 v = uint8_t(std::clamp(v - 1, 0, 255));
1615 }
1616 state.game_state_updated.store(true, std::memory_order::release);
1617// END
1619}
1622}
1623void macrobuilder2_grid_item_decrease_count_t::render(sys::state & state, int32_t x, int32_t y) noexcept {
1624 ogl::render_textured_rect(state, ui::get_color_modification(this == state.ui_state.under_mouse, disabled, true), float(x), float(y), float(base_data.size.x), float(base_data.size.y), ogl::get_late_load_texture_handle(state, background_texture, texture_key), base_data.get_rotation(), false, state.world.locale_get_native_rtl(state.font_collection.get_current_locale()));
1625}
1627 macrobuilder2_grid_item_t& grid_item = *((macrobuilder2_grid_item_t*)(parent));
1628 macrobuilder2_main_t& main = *((macrobuilder2_main_t*)(parent->parent->parent));
1629// BEGIN grid_item::decrease_count::update
1630 if(!grid_item.value)
1631 return;
1632
1633 if(state.ui_state.current_template == -1 || state.ui_state.templates[state.ui_state.current_template].amounts[grid_item.value.index()] == 0) {
1634 disabled = true;
1635 } else {
1636 disabled = false;
1637 }
1638// END
1639}
1641// BEGIN grid_item::decrease_count::create
1642// END
1643}
1645 if(disabled) return ui::message_result::consumed;
1646 macrobuilder2_grid_item_t& grid_item = *((macrobuilder2_grid_item_t*)(parent));
1647 macrobuilder2_main_t& main = *((macrobuilder2_main_t*)(parent->parent->parent));
1648 sound::play_interface_sound(state, sound::get_click_sound(state), state.user_settings.interface_volume* state.user_settings.master_volume);
1650// BEGIN grid_item::increase_count::lbutton_shift_action
1651 if(state.ui_state.current_template != -1) {
1652 auto& v = state.ui_state.templates[state.ui_state.current_template].amounts[grid_item.value.index()];
1653 v = uint8_t(std::clamp(v + 10, 0, 255));
1654 } else {
1655 state.ui_state.templates.emplace_back();
1656 state.ui_state.current_template = int32_t(state.ui_state.templates.size() - 1);
1657 main.template_list->values.push_back(int32_t(state.ui_state.templates.size() - 1));
1658 auto& v = state.ui_state.templates[state.ui_state.current_template].amounts[grid_item.value.index()];
1659 v = uint8_t(std::clamp(v + 10, 0, 255));
1660 main.template_list->page = main.template_list->max_page();
1661 }
1662 bool is_land = state.military_definitions.unit_base_definitions[grid_item.value].is_land;
1663 for(uint32_t i = 2; i < state.military_definitions.unit_base_definitions.size() && i < sys::macro_builder_template::max_types; ++i) {
1664 dcon::unit_type_id id{ dcon::unit_type_id::value_base_t(i) };
1665 if(is_land != state.military_definitions.unit_base_definitions[id].is_land) {
1666 state.ui_state.templates[state.ui_state.current_template].amounts[i] = 0;
1667 }
1668 }
1669 state.game_state_updated.store(true, std::memory_order::release);
1670// END
1672 }
1673// BEGIN grid_item::increase_count::lbutton_action
1674 if(state.ui_state.current_template != -1) {
1675 auto& v = state.ui_state.templates[state.ui_state.current_template].amounts[grid_item.value.index()];
1676 v = uint8_t(std::clamp(v + 1, 0, 255));
1677 } else {
1678 state.ui_state.templates.emplace_back();
1679 state.ui_state.current_template = int32_t(state.ui_state.templates.size() - 1);
1680 main.template_list->values.push_back(int32_t(state.ui_state.templates.size() - 1));
1681 auto& v = state.ui_state.templates[state.ui_state.current_template].amounts[grid_item.value.index()];
1682 v = uint8_t(std::clamp(v + 1, 0, 255));
1683 main.template_list->page = main.template_list->max_page();
1684 }
1685 bool is_land = state.military_definitions.unit_base_definitions[grid_item.value].is_land;
1686 for(uint32_t i = 2; i < state.military_definitions.unit_base_definitions.size() && i < sys::macro_builder_template::max_types; ++i) {
1687 dcon::unit_type_id id{ dcon::unit_type_id::value_base_t(i) };
1688 if(is_land != state.military_definitions.unit_base_definitions[id].is_land) {
1689 state.ui_state.templates[state.ui_state.current_template].amounts[i] = 0;
1690 }
1691 }
1692 state.game_state_updated.store(true, std::memory_order::release);
1693// END
1695}
1698}
1699void macrobuilder2_grid_item_increase_count_t::render(sys::state & state, int32_t x, int32_t y) noexcept {
1700 ogl::render_textured_rect(state, ui::get_color_modification(this == state.ui_state.under_mouse, disabled, true), float(x), float(y), float(base_data.size.x), float(base_data.size.y), ogl::get_late_load_texture_handle(state, background_texture, texture_key), base_data.get_rotation(), false, state.world.locale_get_native_rtl(state.font_collection.get_current_locale()));
1701}
1703 macrobuilder2_grid_item_t& grid_item = *((macrobuilder2_grid_item_t*)(parent));
1704 macrobuilder2_main_t& main = *((macrobuilder2_main_t*)(parent->parent->parent));
1705// BEGIN grid_item::increase_count::update
1706// END
1707}
1709// BEGIN grid_item::increase_count::create
1710// END
1711}
1712void macrobuilder2_grid_item_current_count_t::set_text(sys::state& state, std::string const& new_text) {
1713 if(new_text != cached_text) {
1714 cached_text = new_text;
1715 internal_layout.contents.clear();
1717 text::single_line_layout sl{ internal_layout, text::layout_parameters{ 0, 0, static_cast<int16_t>(base_data.size.x), static_cast<int16_t>(base_data.size.y), text::make_font_id(state, text_is_header, text_scale * 18), 0, text_alignment, text::text_color::black, true, true }, state.world.locale_get_native_rtl(state.font_collection.get_current_locale()) ? text::layout_base::rtl_status::rtl : text::layout_base::rtl_status::ltr };
1718 sl.add_text(state, cached_text);
1719 }
1720}
1722}
1723void macrobuilder2_grid_item_current_count_t::render(sys::state & state, int32_t x, int32_t y) noexcept {
1724 if(internal_layout.contents.empty()) return;
1725 auto fh = text::make_font_id(state, text_is_header, text_scale * 18);
1726 auto linesz = state.font_collection.line_height(state, fh);
1727 if(linesz == 0.0f) return;
1728 auto ycentered = (base_data.size.y - linesz) / 2;
1729 auto cmod = ui::get_color_modification(this == state.ui_state.under_mouse, false, false);
1730 for(auto& t : internal_layout.contents) {
1731 ui::render_text_chunk(state, t, float(x) + t.x, float(y + int32_t(ycentered)), fh, ui::get_text_color(state, text_color), cmod);
1732 }
1733}
1735 macrobuilder2_grid_item_t& grid_item = *((macrobuilder2_grid_item_t*)(parent));
1736 macrobuilder2_main_t& main = *((macrobuilder2_main_t*)(parent->parent->parent));
1737// BEGIN grid_item::current_count::update
1738 if(!grid_item.value)
1739 return;
1740 if(state.ui_state.current_template != -1) {
1741 auto& v = state.ui_state.templates[state.ui_state.current_template].amounts[grid_item.value.index()];
1742 set_text(state, std::to_string(v));
1743 } else {
1744 set_text(state, "0");
1745 }
1746// END
1747}
1749// BEGIN grid_item::current_count::create
1750// END
1751}
1754}
1757}
1758void macrobuilder2_grid_item_t::render(sys::state & state, int32_t x, int32_t y) noexcept {
1759 ogl::render_textured_rect(state, ui::get_color_modification(this == state.ui_state.under_mouse, false, false), float(x), float(y), float(base_data.size.x), float(base_data.size.y), ogl::get_late_load_texture_handle(state, background_texture, texture_key), base_data.get_rotation(), false, state.world.locale_get_native_rtl(state.font_collection.get_current_locale()));
1760}
1762 macrobuilder2_main_t& main = *((macrobuilder2_main_t*)(parent->parent));
1763// BEGIN grid_item::update
1764 if(!value) {
1765 flags |= element_base::is_invisible_mask;
1766 }
1767// END
1768}
1770 auto window_bytes = state.ui_state.new_ui_windows.find(std::string("macrobuilder2::grid_item"));
1771 if(window_bytes == state.ui_state.new_ui_windows.end()) std::abort();
1772 std::vector<sys::aui_pending_bytes> pending_children;
1773 auto win_data = read_window_bytes(window_bytes->second.data, window_bytes->second.size, pending_children);
1774 base_data.position.x = win_data.x_pos;
1775 base_data.position.y = win_data.y_pos;
1776 base_data.size.x = win_data.x_size;
1777 base_data.size.y = win_data.y_size;
1778 base_data.flags = uint8_t(win_data.orientation);
1779 texture_key = win_data.texture;
1781 auto name_key = state.lookup_key("macrobuilder2::grid_item");
1782 for(auto ex : state.ui_defs.extensions) {
1783 if(name_key && ex.window == name_key) {
1784 auto ch_res = ui::make_element_immediate(state, ex.child);
1785 if(ch_res) {
1786 this->add_child_to_back(std::move(ch_res));
1787 }
1788 }
1789 }
1790 while(!pending_children.empty()) {
1791 auto child_data = read_child_bytes(pending_children.back().data, pending_children.back().size);
1792 pending_children.pop_back();
1793 if(child_data.name == "unit_icon") {
1794 auto cptr = std::make_unique<macrobuilder2_grid_item_unit_icon_t>();
1795 cptr->parent = this;
1796 unit_icon = cptr.get();
1797 cptr->base_data.position.x = child_data.x_pos;
1798 cptr->base_data.position.y = child_data.y_pos;
1799 cptr->base_data.size.x = child_data.x_size;
1800 cptr->base_data.size.y = child_data.y_size;
1801 cptr->gfx_key = child_data.texture;
1802 cptr->on_create(state);
1803 this->add_child_to_back(std::move(cptr));
1804 continue;
1805 }
1806 if(child_data.name == "decrease_count") {
1807 auto cptr = std::make_unique<macrobuilder2_grid_item_decrease_count_t>();
1808 cptr->parent = this;
1809 decrease_count = cptr.get();
1810 cptr->base_data.position.x = child_data.x_pos;
1811 cptr->base_data.position.y = child_data.y_pos;
1812 cptr->base_data.size.x = child_data.x_size;
1813 cptr->base_data.size.y = child_data.y_size;
1814 cptr->texture_key = child_data.texture;
1815 cptr->on_create(state);
1816 this->add_child_to_back(std::move(cptr));
1817 continue;
1818 }
1819 if(child_data.name == "increase_count") {
1820 auto cptr = std::make_unique<macrobuilder2_grid_item_increase_count_t>();
1821 cptr->parent = this;
1822 increase_count = cptr.get();
1823 cptr->base_data.position.x = child_data.x_pos;
1824 cptr->base_data.position.y = child_data.y_pos;
1825 cptr->base_data.size.x = child_data.x_size;
1826 cptr->base_data.size.y = child_data.y_size;
1827 cptr->texture_key = child_data.texture;
1828 cptr->on_create(state);
1829 this->add_child_to_back(std::move(cptr));
1830 continue;
1831 }
1832 if(child_data.name == "current_count") {
1833 auto cptr = std::make_unique<macrobuilder2_grid_item_current_count_t>();
1834 cptr->parent = this;
1835 current_count = cptr.get();
1836 cptr->base_data.position.x = child_data.x_pos;
1837 cptr->base_data.position.y = child_data.y_pos;
1838 cptr->base_data.size.x = child_data.x_size;
1839 cptr->base_data.size.y = child_data.y_size;
1840 cptr->text_scale = child_data.text_scale;
1841 cptr->text_is_header = (child_data.text_type == aui_text_type::header);
1842 cptr->text_alignment = child_data.text_alignment;
1843 cptr->text_color = child_data.text_color;
1844 cptr->on_create(state);
1845 this->add_child_to_back(std::move(cptr));
1846 continue;
1847 }
1848 }
1849// BEGIN grid_item::create
1850// END
1851}
1852std::unique_ptr<ui::element_base> make_macrobuilder2_grid_item(sys::state& state) {
1853 auto ptr = std::make_unique<macrobuilder2_grid_item_t>();
1854 ptr->on_create(state);
1855 return ptr;
1856}
1857// LOST-CODE
1858}
void impl_on_update(sys::state &state) noexcept override
static constexpr uint8_t wants_update_when_hidden_mask
element_data base_data
int main(int argc, char *argv[])
aui_element_data read_child_bytes(char const *bytes, size_t size)
aui_window_data read_window_bytes(char const *bytes, size_t size, std::vector< sys::aui_pending_bytes > &children_out)
std::unique_ptr< ui::element_base > make_macrobuilder2_list_item(sys::state &state)
std::unique_ptr< ui::element_base > make_macrobuilder2_main(sys::state &state)
std::unique_ptr< ui::element_base > make_macrobuilder2_grid_item(sys::state &state)
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:635
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:646
GLuint get_late_load_texture_handle(sys::state &state, dcon::texture_id &id, std::string_view asset_name)
Definition: texture.cpp:1049
void render_bordered_rect(sys::state const &state, color_modification enabled, float border_size, float x, float y, float width, float height, GLuint texture_handle, ui::rotation r, bool flipped, bool rtl)
void render_subsprite(sys::state const &state, color_modification enabled, int frame, int total_frames, float x, float y, float width, float height, GLuint texture_handle, ui::rotation r, bool flipped, bool rtl)
void render_textured_rect(sys::state const &state, color_modification enabled, float x, float y, float width, float height, GLuint texture_handle, ui::rotation r, bool flipped, bool rtl)
GLuint get_texture_handle(sys::state &state, dcon::texture_id id, bool keep_data)
Definition: texture.cpp:1066
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)
void play_interface_sound(sys::state &state, audio_instance &s, float volume)
Definition: sound_nix.cpp:203
audio_instance & get_click_sound(sys::state &state)
Definition: sound_nix.cpp:263
virtual_key
Definition: constants.hpp:5
key_modifiers
Definition: constants.hpp:156
alignment
Definition: text.hpp:36
std::string format_float(float num, size_t digits)
Definition: text.cpp:981
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
Definition: text.cpp:1923
void add_line_break_to_layout(sys::state &state, columnar_layout &dest)
Definition: text.cpp:1152
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
Definition: text.cpp:617
text_color
Definition: text.hpp:18
uint16_t make_font_id(sys::state &state, bool as_header, float target_line_size)
Definition: fonts.cpp:891
std::string format_percentage(float num, size_t digits)
Definition: text.cpp:977
int32_t ui_height(sys::state const &state)
int32_t ui_width(sys::state const &state)
void render_text_chunk(sys::state &state, text::text_chunk t, float x, float baseline_y, uint16_t font_id, ogl::color3f text_color, ogl::color_modification cmod)
xy_pair get_absolute_location(sys::state &state, element_base const &node)
tooltip_behavior
ogl::color3f get_text_color(sys::state &state, text::text_color text_color)
message_result
ogl::color_modification get_color_modification(bool is_under_mouse, bool is_disabled, bool is_interactable)
std::unique_ptr< element_base > make_element_immediate(sys::state &state, dcon::gui_def_id id)
uint uint32_t
uchar uint8_t
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
ui::tooltip_behavior has_tooltip(sys::state &state) noexcept override
ui::message_result test_mouse(sys::state &state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void set_text(sys::state &state, std::string const &new_text)
void on_reset_text(sys::state &state) noexcept override
ui::message_result on_rbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
void on_update(sys::state &state) noexcept override
ui::tooltip_behavior has_tooltip(sys::state &state) noexcept override
ui::message_result test_mouse(sys::state &state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override
ui::message_result on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_create(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_update(sys::state &state) noexcept override
ui::message_result on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
ui::message_result on_rbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
ui::tooltip_behavior has_tooltip(sys::state &state) noexcept override
ui::message_result test_mouse(sys::state &state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override
void on_create(sys::state &state) noexcept override
macrobuilder2_grid_item_decrease_count_t * decrease_count
void render(sys::state &state, int32_t x, int32_t y) noexcept override
macrobuilder2_grid_item_unit_icon_t * unit_icon
void on_create(sys::state &state) noexcept override
void * get_by_name(sys::state &state, std::string_view name) noexcept override
macrobuilder2_grid_item_increase_count_t * increase_count
ui::message_result test_mouse(sys::state &state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override
ui::message_result on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
ui::message_result on_rbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
macrobuilder2_grid_item_current_count_t * current_count
void on_update(sys::state &state) noexcept override
ui::message_result test_mouse(sys::state &state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override
ui::message_result on_rbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
void on_update(sys::state &state) noexcept override
ui::tooltip_behavior has_tooltip(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void on_create(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
ui::message_result on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
ui::message_result on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
void on_create(sys::state &state) noexcept override
ui::message_result test_mouse(sys::state &state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override
ui::tooltip_behavior has_tooltip(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
ui::message_result on_rbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
ui::message_result on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
void on_create(sys::state &state) noexcept override
ui::message_result test_mouse(sys::state &state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
ui::tooltip_behavior has_tooltip(sys::state &state) noexcept override
ui::message_result on_rbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
void set_text(sys::state &state, std::string const &new_text)
void on_update(sys::state &state) noexcept override
void on_reset_text(sys::state &state) noexcept override
ui::message_result test_mouse(sys::state &state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override
macrobuilder2_list_item_delete_button_t * delete_button
void on_create(sys::state &state) noexcept override
macrobuilder2_list_item_select_button_t * select_button
void on_update(sys::state &state) noexcept override
void * get_by_name(sys::state &state, std::string_view name) noexcept override
ui::message_result test_mouse(sys::state &state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override
void set_text(sys::state &state, std::string const &new_text)
ui::message_result on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
void on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
ui::tooltip_behavior has_tooltip(sys::state &state) noexcept override
ui::message_result on_rbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_reset_text(sys::state &state) noexcept override
ui::message_result on_key_down(sys::state &state, sys::virtual_key key, sys::key_modifiers mods) noexcept override
ui::message_result test_mouse(sys::state &state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
ui::message_result on_rbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
ui::tooltip_behavior has_tooltip(sys::state &state) noexcept override
ui::message_result on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
ui::tooltip_behavior has_tooltip(sys::state &state) noexcept override
ui::message_result on_rbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_create(sys::state &state) noexcept override
ui::message_result test_mouse(sys::state &state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override
void on_update(sys::state &state) noexcept override
ui::message_result on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
ui::tooltip_behavior has_tooltip(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_reset_text(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void set_text(sys::state &state, std::string const &new_text)
ui::message_result test_mouse(sys::state &state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override
void on_create(sys::state &state) noexcept override
ui::message_result on_rbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
ui::message_result test_mouse(sys::state &state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_update(sys::state &state) noexcept override
ui::tooltip_behavior has_tooltip(sys::state &state) noexcept override
ui::message_result on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_create(sys::state &state) noexcept override
ui::message_result test_mouse(sys::state &state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override
ui::tooltip_behavior has_tooltip(sys::state &state) noexcept override
void on_reset_text(sys::state &state) noexcept override
void set_text(sys::state &state, std::string const &new_text)
void on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
ui::tooltip_behavior has_tooltip(sys::state &state) noexcept override
ui::message_result test_mouse(sys::state &state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override
ui::message_result on_rbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
ui::message_result on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void set_text(sys::state &state, std::string const &new_text)
void on_update(sys::state &state) noexcept override
ui::tooltip_behavior has_tooltip(sys::state &state) noexcept override
ui::message_result test_mouse(sys::state &state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_create(sys::state &state) noexcept override
void on_reset_text(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_create(sys::state &state) noexcept override
ui::message_result test_mouse(sys::state &state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override
void on_update(sys::state &state) noexcept override
ui::message_result on_rbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
ui::message_result on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
ui::tooltip_behavior has_tooltip(sys::state &state) noexcept override
macrobuilder2_main_grid_page_left_t * grid_page_left
void on_update(sys::state &state) noexcept override
ui::message_result on_rbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
macrobuilder2_main_template_list_t * template_list
macrobuilder2_main_apply_button_t * apply_button
macrobuilder2_main_grid_page_number_t * grid_page_number
void on_drag(sys::state &state, int32_t oldx, int32_t oldy, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
macrobuilder2_main_unit_grid_t * unit_grid
macrobuilder2_main_close_button_t * close_button
macrobuilder2_main_list_page_number_t * list_page_number
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_create(sys::state &state) noexcept override
macrobuilder2_main_grid_page_right_t * grid_page_right
macrobuilder2_main_header_text_t * header_text
macrobuilder2_main_list_page_right_t * list_page_right
ui::message_result test_mouse(sys::state &state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override
ui::message_result on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mods) noexcept override
macrobuilder2_main_list_page_left_t * list_page_left
void change_page(sys::state &state, int32_t new_page)
ui::tooltip_behavior has_tooltip(sys::state &state) noexcept override
ui::message_result test_mouse(sys::state &state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override
std::vector< ui::element_base * > visible_items
void on_update(sys::state &state) noexcept override
ui::message_result on_scroll(sys::state &state, int32_t x, int32_t y, float amount, sys::key_modifiers mods) noexcept override
void on_create(sys::state &state) noexcept override
ui::message_result on_scroll(sys::state &state, int32_t x, int32_t y, float amount, sys::key_modifiers mods) noexcept override
void change_page(sys::state &state, int32_t new_page)
std::vector< dcon::unit_type_id > values
ui::message_result test_mouse(sys::state &state, int32_t x, int32_t y, ui::mouse_probe_type type) noexcept override
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
std::vector< ui::element_base * > visible_items
ui::tooltip_behavior has_tooltip(sys::state &state) noexcept override
static constexpr uint32_t max_types
Holds important data about the game world, state, and other data regarding windowing,...
std::vector< text_chunk > contents
Definition: text.hpp:821
int32_t number_of_lines
Definition: text.hpp:822