Project Alice
Loading...
Searching...
No Matches
gui_pop_sort_buttons_window.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
gui_element_types.hpp
"
4
5
namespace
ui
{
6
7
class
primary_worker_sort
:
public
button_element_base
{
8
void
button_action(
sys::state
&
state
)
noexcept
override
{
9
if
(
parent
) {
10
Cyto::Any
payload =
production_sort_order::primary_workers
;
11
parent
->
impl_get
(
state
, payload);
12
}
13
}
14
};
15
16
class
secondary_worker_sort
:
public
button_element_base
{
17
void
button_action(
sys::state
&
state
)
noexcept
override
{
18
if
(
parent
) {
19
Cyto::Any
payload =
production_sort_order::secondary_workers
;
20
parent
->
impl_get
(
state
, payload);
21
}
22
}
23
};
24
25
class
owner_sort
:
public
button_element_base
{
26
void
button_action(
sys::state
&
state
)
noexcept
override
{
27
if
(
parent
) {
28
Cyto::Any
payload =
production_sort_order::owners
;
29
parent
->
impl_get
(
state
, payload);
30
}
31
}
32
};
33
34
class
pop_sort_buttons_window
:
public
window_element_base
{
35
xy_pair
sort_template_offset{};
36
37
public
:
38
void
on_create
(
sys::state
&
state
)
noexcept
override
{
39
window_element_base::on_create
(
state
);
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
Cyto::Any
Definition:
cyto_any.hpp:313
ui::button_element_base
Definition:
gui_element_types.hpp:202
ui::container_base::add_child_to_back
void add_child_to_back(std::unique_ptr< element_base > child) noexcept final
Definition:
gui_element_types.cpp:122
ui::element_base::parent
element_base * parent
Definition:
gui_element_base.hpp:20
ui::element_base::impl_get
message_result impl_get(sys::state &state, Cyto::Any &payload) noexcept
Definition:
gui_graphics.cpp:237
ui::element_base::set_visible
void set_visible(sys::state &state, bool vis)
Definition:
gui_element_base.hpp:26
ui::owner_sort
Definition:
gui_pop_sort_buttons_window.hpp:25
ui::pop_sort_buttons_window
Definition:
gui_pop_sort_buttons_window.hpp:34
ui::pop_sort_buttons_window::on_create
void on_create(sys::state &state) noexcept override
Definition:
gui_pop_sort_buttons_window.hpp:38
ui::primary_worker_sort
Definition:
gui_pop_sort_buttons_window.hpp:7
ui::secondary_worker_sort
Definition:
gui_pop_sort_buttons_window.hpp:16
ui::window_element_base
Definition:
gui_element_types.hpp:443
ui::window_element_base::on_create
void on_create(sys::state &state) noexcept override
Definition:
gui_element_types.cpp:1223
gui_element_types.hpp
text::produce_simple_string
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
Definition:
text.cpp:617
ui
Definition:
constants.hpp:582
ui::production_sort_order::secondary_workers
@ secondary_workers
ui::production_sort_order::primary_workers
@ primary_workers
ui::production_sort_order::owners
@ owners
sys::state
Definition:
system_state.hpp:472
ui::state
Definition:
gui_graphics.hpp:403
ui::state::defs_by_name
ankerl::unordered_dense::map< dcon::text_key, element_target, hash_text_key > defs_by_name
Definition:
gui_graphics.hpp:438
ui::xy_pair
Definition:
gui_graphics.hpp:31
ui::xy_pair::x
int16_t x
Definition:
gui_graphics.hpp:32
src
gui
topbar_subwindows
production_subwindows
gui_pop_sort_buttons_window.hpp
Generated by
1.9.5