Project Alice
Loading...
Searching...
No Matches
gui_pop_sort_buttons_window.hpp
Go to the documentation of this file.
1#pragma once
2
4
5namespace ui {
6
8 void button_action(sys::state& state) noexcept override {
9 if(parent) {
11 parent->impl_get(state, payload);
12 }
13 }
14};
15
17 void button_action(sys::state& state) noexcept override {
18 if(parent) {
20 parent->impl_get(state, payload);
21 }
22 }
23};
24
26 void button_action(sys::state& state) noexcept override {
27 if(parent) {
29 parent->impl_get(state, payload);
30 }
31 }
32};
33
35 xy_pair sort_template_offset{};
36
37public:
38 void on_create(sys::state& state) noexcept override {
40
41 xy_pair base_sort_template_offset =
42 state.ui_defs.gui[state.ui_state.defs_by_name.find(state.lookup_key("sort_by_pop_template_offset"))->second.definition].position;
43 sort_template_offset = base_sort_template_offset;
44
45 auto ptr = make_element_by_type<primary_worker_sort>(state,
46 state.ui_state.defs_by_name.find(state.lookup_key("sort_by_pop_template"))->second.definition);
47 ptr->set_button_text(state,
48 text::produce_simple_string(state, state.world.pop_type_get_name(state.culture_definitions.primary_factory_worker)));
49 sort_template_offset.x = base_sort_template_offset.x * 0;
50 ptr->base_data.position = sort_template_offset;
51 add_child_to_back(std::move(ptr));
52
53 auto ptr2 = make_element_by_type<secondary_worker_sort>(state,
54 state.ui_state.defs_by_name.find(state.lookup_key("sort_by_pop_template"))->second.definition);
55 ptr2->set_button_text(state,
56 text::produce_simple_string(state, state.world.pop_type_get_name(state.culture_definitions.secondary_factory_worker)));
57 sort_template_offset.x = base_sort_template_offset.x * 1;
58 ptr2->base_data.position = sort_template_offset;
59 add_child_to_back(std::move(ptr2));
60
61 auto ptr3 =
62 make_element_by_type<owner_sort>(state,
63 state.ui_state.defs_by_name.find(state.lookup_key("sort_by_pop_template"))->second.definition);
64 ptr3->set_button_text(state,
65 text::produce_simple_string(state, state.world.pop_type_get_name(state.culture_definitions.capitalists)));
66 sort_template_offset.x = base_sort_template_offset.x * 2;
67 ptr3->base_data.position = sort_template_offset;
68 add_child_to_back(std::move(ptr3));
69
70 set_visible(state, false);
71 }
72};
73
74} // namespace ui
void add_child_to_back(std::unique_ptr< element_base > child) noexcept final
element_base * parent
message_result impl_get(sys::state &state, Cyto::Any &payload) noexcept
void set_visible(sys::state &state, bool vis)
void on_create(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
Definition: text.cpp:617
ankerl::unordered_dense::map< dcon::text_key, element_target, hash_text_key > defs_by_name