Project Alice
Loading...
Searching...
No Matches
gui_event.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <variant>
5
6namespace ui {
7
9 int a = 0;
10};
11
12using event_data_wrapper = std::variant< event::pending_human_n_event, event::pending_human_f_n_event, event::pending_human_p_event, event::pending_human_f_p_event>;
13
15public:
18 }
19 void on_update(sys::state& state) noexcept override;
22 }
23 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override;
24 void button_action(sys::state& state) noexcept override;
25};
27public:
30 }
31 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override {
32 text::add_line(state, contents, "event_auto");
33 }
34 void button_action(sys::state& state) noexcept override;
35};
37public:
38 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
39 if(name == "opt_button") {
40 return make_element_by_type<event_option_button>(state, id);
41 } else if(name == "auto_button") {
42 return make_element_by_type<event_auto_button>(state, id);
43 } else {
44 return nullptr;
45 }
46 }
47};
49public:
50 bool get_horizontal_flip(sys::state& state) noexcept override {
51 return false; //never flip
52 }
53 void on_update(sys::state& state) noexcept override;
54};
56public:
57 void on_create(sys::state& state) noexcept override;
58 void on_update(sys::state& state) noexcept override;
59};
61public:
62 void on_create(sys::state& state) noexcept override {
64 black_text = true;
66 }
67 void on_reset_text(sys::state& state) noexcept override {
68 //TODO: Adapt to classic fonts too!
70 auto font_index = text::font_index_from_font_id(state, fh);
71 auto font_size = text::size_from_font_id(fh);
72 auto& font = state.font_collection.get_font(state, font_index);
73 auto text_height = int32_t(std::ceil(font.line_height(font_size)));
74 base_data.size.y = int16_t((text_height - 15) * 2);
75 }
76 void on_update(sys::state& state) noexcept override;
77};
79public:
82 }
83 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override;
84};
86public:
89 }
90 void update_tooltip(sys::state& state, int32_t x, int32_t y, text::columnar_layout& contents) noexcept override;
91};
92
94public:
95 void on_update(sys::state& state) noexcept override;
96};
98public:
99 void on_update(sys::state& state) noexcept override;
100};
102public:
103 void on_update(sys::state& state) noexcept override;
104};
105class election_issue_support_item : public listbox_row_element_base<dcon::issue_option_id> {
106public:
107 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override;
108};
109class elections_issue_option_listbox : public listbox_element_base<election_issue_support_item, dcon::issue_option_id> {
110protected:
111 std::string_view get_row_element_name() override {
112 return "ew_issue_option_window";
113 }
114public:
115 void on_update(sys::state& state) noexcept override;
116};
117
118//
119// National events
120//
126 count
128class base_event_option_listbox : public listbox_element_base<event_option_button_row, int32_t> {
129public:
130 void on_update(sys::state& state) noexcept override;
131};
133protected:
134 std::string_view get_row_element_name() override {
135 return "alice_nation_event_button";
136 }
137};
139protected:
140 std::string_view get_row_element_name() override {
141 return "alice_prov_event_button";
142 }
143};
145protected:
146 std::string_view get_row_element_name() override {
147 return "alice_election_event_button";
148 }
149};
151 elections_issue_option_listbox* issues_listbox = nullptr;
152public:
153 virtual std::string_view get_option_start_element_name() noexcept {
154 return "event_country_option_start";
155 }
156 virtual event_pool_slot get_pool_slot() noexcept {
158 }
159 event_image* image = nullptr;
161 void on_create(sys::state& state) noexcept override;
162 std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override;
163 message_result get(sys::state& state, Cyto::Any& payload) noexcept override;
164 void on_update(sys::state& state) noexcept override;
165};
167public:
168 static constexpr std::string_view window_element_name = "event_election_window";
169 std::string_view get_option_start_element_name() noexcept override {
170 return "eew_event_option_start";
171 }
172 event_pool_slot get_pool_slot() noexcept override {
174 }
175};
177public:
178 static constexpr std::string_view window_element_name = "event_country_window";
179 std::string_view get_option_start_element_name() noexcept override {
180 return "event_country_option_start";
181 }
182 event_pool_slot get_pool_slot() noexcept override {
184 }
185};
187public:
188 static constexpr std::string_view window_element_name = "event_major_window";
189 std::string_view get_option_start_element_name() noexcept override {
190 return "event_major_option_start";
191 }
192 event_pool_slot get_pool_slot() noexcept override {
194 }
195};
197public:
198 static constexpr std::string_view window_element_name = "event_province_window";
199 std::string_view get_option_start_element_name() noexcept override {
200 return "event_province_option_start";
201 }
202 event_pool_slot get_pool_slot() noexcept override {
204 }
205};
206
207void populate_event_submap(sys::state& state, text::substitution_map& sub, std::variant<event::pending_human_n_event, event::pending_human_f_n_event, event::pending_human_p_event, event::pending_human_f_p_event> const& phe) noexcept;
210bool events_pause_test(sys::state& state);
212
213} // namespace ui
void on_update(sys::state &state) noexcept override
Definition: gui_event.cpp:574
event_image * image
Definition: gui_event.hpp:159
void on_update(sys::state &state) noexcept override
Definition: gui_event.cpp:1126
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
Definition: gui_event.cpp:998
event_data_wrapper event_data
Definition: gui_event.hpp:160
virtual event_pool_slot get_pool_slot() noexcept
Definition: gui_event.hpp:156
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
Definition: gui_event.cpp:1059
virtual std::string_view get_option_start_element_name() noexcept
Definition: gui_event.hpp:153
void on_create(sys::state &state) noexcept override
Definition: gui_event.cpp:609
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
Definition: gui_event.cpp:976
void on_update(sys::state &state) noexcept override
Definition: gui_event.cpp:988
std::string_view get_row_element_name() override
Definition: gui_event.hpp:111
element_data base_data
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_event.hpp:31
void button_action(sys::state &state) noexcept override
Definition: gui_event.cpp:250
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_event.hpp:28
void on_create(sys::state &state) noexcept override
Definition: gui_event.cpp:336
void on_update(sys::state &state) noexcept override
Definition: gui_event.cpp:343
void on_update(sys::state &state) noexcept override
Definition: gui_event.cpp:328
bool get_horizontal_flip(sys::state &state) noexcept override
Definition: gui_event.hpp:50
void on_reset_text(sys::state &state) noexcept override
Definition: gui_event.hpp:67
void on_update(sys::state &state) noexcept override
Definition: gui_event.cpp:419
void on_create(sys::state &state) noexcept override
Definition: gui_event.hpp:62
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_event.cpp:503
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_event.hpp:87
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
Definition: gui_event.hpp:38
void on_update(sys::state &state) noexcept override
Definition: gui_event.cpp:223
void button_action(sys::state &state) noexcept override
Definition: gui_event.cpp:309
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_event.hpp:20
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_event.cpp:274
sound::audio_instance & get_click_sound(sys::state &state) noexcept override
Definition: gui_event.hpp:16
void on_update(sys::state &state) noexcept override
Definition: gui_event.cpp:555
tooltip_behavior has_tooltip(sys::state &state) noexcept override
Definition: gui_event.hpp:80
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
Definition: gui_event.cpp:450
void on_update(sys::state &state) noexcept override
Definition: gui_event.cpp:536
void on_update(sys::state &state) noexcept override
Definition: gui_event.cpp:531
void on_create(sys::state &state) noexcept override
std::string_view get_row_element_name() override
Definition: gui_event.hpp:146
static constexpr std::string_view window_element_name
Definition: gui_event.hpp:168
std::string_view get_option_start_element_name() noexcept override
Definition: gui_event.hpp:169
event_pool_slot get_pool_slot() noexcept override
Definition: gui_event.hpp:172
std::string_view get_row_element_name() override
Definition: gui_event.hpp:134
std::string_view get_option_start_element_name() noexcept override
Definition: gui_event.hpp:179
event_pool_slot get_pool_slot() noexcept override
Definition: gui_event.hpp:182
static constexpr std::string_view window_element_name
Definition: gui_event.hpp:178
std::string_view get_option_start_element_name() noexcept override
Definition: gui_event.hpp:189
static constexpr std::string_view window_element_name
Definition: gui_event.hpp:188
event_pool_slot get_pool_slot() noexcept override
Definition: gui_event.hpp:192
std::string_view get_row_element_name() override
Definition: gui_event.hpp:140
event_pool_slot get_pool_slot() noexcept override
Definition: gui_event.hpp:202
std::string_view get_option_start_element_name() noexcept override
Definition: gui_event.hpp:199
static constexpr std::string_view window_element_name
Definition: gui_event.hpp:198
audio_instance & get_event_sound(sys::state &state)
Definition: sound_nix.cpp:384
int32_t size_from_font_id(uint16_t id)
Definition: fonts.cpp:119
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
Definition: text.cpp:1899
ankerl::unordered_dense::map< uint32_t, substitution > substitution_map
Definition: text.hpp:794
font_selection font_index_from_font_id(sys::state &state, uint16_t id)
Definition: fonts.cpp:130
tooltip_behavior
void close_expired_event_windows(sys::state &state)
Definition: gui_event.cpp:1146
void populate_event_submap(sys::state &state, text::substitution_map &sub, std::variant< event::pending_human_n_event, event::pending_human_f_n_event, event::pending_human_p_event, event::pending_human_f_p_event > const &phe) noexcept
Definition: gui_event.cpp:12
event_pool_slot
Definition: gui_event.hpp:121
@ country_major
Definition: gui_event.hpp:124
@ country
Definition: gui_event.hpp:122
@ country_election
Definition: gui_event.hpp:123
@ province
Definition: gui_event.hpp:125
@ count
Definition: gui_event.hpp:126
message_result
void clear_event_windows(sys::state &state)
Definition: gui_event.cpp:1152
bool events_pause_test(sys::state &state)
Definition: gui_event.cpp:1161
std::variant< event::pending_human_n_event, event::pending_human_f_n_event, event::pending_human_p_event, event::pending_human_f_p_event > event_data_wrapper
Definition: gui_event.hpp:12
void new_event_window(sys::state &state, event_data_wrapper dat)
Definition: gui_event.cpp:1189
uchar uint8_t
union ui::element_data::internal_data data