44 auto msg = retrieve< notification::message*>(
state,
parent);
46 msg->body(
state, contents);
67 base_data.size.x = 500 - (base_data.position.x * 2) - 8;
68 base_data.size.y = 18 * 6;
70 auto res = std::make_unique<message_body_text_internal>();
74 res->base_data.position.x = 0;
75 res->base_data.position.y = 0;
76 res->on_create(
state);
78 add_child_to_front(std::move(res));
80 auto ptr = make_element_by_type<multiline_text_scrollbar>(
state,
"standardlistbox_slider");
82 add_child_to_front(std::move(ptr));
83 text_scrollbar->scale_to_parent();
87 if(delegate->internal_layout.number_of_lines > delegate->visible_lines) {
88 text_scrollbar->set_visible(
state,
true);
89 text_scrollbar->change_settings(
state,
92 text_scrollbar->set_visible(
state,
false);
93 delegate->current_line = 0;
98 if(delegate->internal_layout.number_of_lines > delegate->visible_lines) {
99 text_scrollbar->update_scaled_value(
state, text_scrollbar->scaled_value() + std::clamp(-amount, -1.f, 1.f));
100 delegate->current_line = int32_t(text_scrollbar->scaled_value());
109 auto event = any_cast<multiline_text_scroll_event>(payload);
110 delegate->current_line =
event.new_value;
128 dcon::gfx_object_id gid;
135 auto& gfx_def =
state.ui_defs.gfx[gid];
137 auto& mask_tex =
state.open_gl.asset_textures[dcon::texture_id(gfx_def.type_dependent - 1)];
140 gfx_def.is_vertically_flipped(),
150 int32_t prev_size = 0;
162 auto ptr = make_element_by_type<message_lr_button<false>>(
state,
165 cur_pos.y = ptr->base_data.size.y * 1;
166 ptr->base_data.position = cur_pos;
170 auto ptr = make_element_by_type<message_count_text>(
state,
172 cur_pos.x -= ptr->base_data.size.x;
173 ptr->base_data.position = cur_pos;
174 count_text = ptr.
get();
178 auto ptr = make_element_by_type<message_lr_button<true>>(
state,
180 cur_pos.x -= ptr->base_data.size.x;
181 ptr->base_data.position = cur_pos;
188 if(
name ==
"header") {
189 return make_element_by_type<invisible_element>(
state,
id);
190 }
else if(
name ==
"line1") {
191 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
192 ptr->base_data.size.x =
base_data.
size.
x - (ptr->base_data.position.x * 2);
193 ptr->base_data.size.y = 22;
194 title_text = ptr.
get();
196 }
else if(
name ==
"line3") {
197 auto ptr = make_element_by_type<message_body_text>(
state,
id);
198 desc_text = ptr.
get();
200 }
else if(
name.substr(0, 4) ==
"line") {
201 return make_element_by_type<invisible_element>(
state,
id);
202 }
else if(
name ==
"agreebutton") {
203 return make_element_by_type<invisible_element>(
state,
id);
204 }
else if(
name ==
"declinebutton") {
205 return make_element_by_type<invisible_element>(
state,
id);
206 }
else if(
name ==
"centerok") {
207 return make_element_by_type<message_dismiss_button>(
state,
id);
208 }
else if(
name ==
"leftshield") {
209 return make_element_by_type<message_flag_button>(
state,
id);
210 }
else if(
name ==
"rightshield") {
211 return make_element_by_type<message_flag_button>(
state,
id);
212 }
else if(
name ==
"background") {
213 auto ptr = make_element_by_type<draggable_target>(
state,
id);
223 state.ui_pause.store(
false, std::memory_order_release);
226 if(int32_t(
messages.size()) > prev_size) {
227 index = int32_t(
messages.size()) - 1;
229 if(index >= int32_t(
messages.size()))
232 index = int32_t(
messages.size()) - 1;
234 prev_size = int32_t(
messages.size());
236 count_text->
set_text(
state, std::to_string(int32_t(index) + 1) +
"/" + std::to_string(int32_t(
messages.size())));
244 if(index >= int32_t(
messages.size()))
247 index = int32_t(
messages.size()) - 1;
249 if(payload.holds_type<dcon::nation_id>()) {
251 payload.emplace<dcon::nation_id>(dcon::nation_id{});
253 payload.emplace<dcon::nation_id>(
messages[index].source);
256 }
else if(payload.holds_type<dcon::national_identity_id>()) {
258 payload.emplace<dcon::national_identity_id>(dcon::national_identity_id{});
260 payload.emplace<dcon::national_identity_id>(
state.world.nation_get_identity_from_identity_holder(
messages[index].source));
264 bool b = any_cast<element_selection_wrapper<bool>>(payload).data;
265 index += b ? -1 : +1;
void add_child_to_front(std::unique_ptr< element_base > child) noexcept final
void impl_on_update(sys::state &state) noexcept override
virtual message_result get(sys::state &state, Cyto::Any &payload) noexcept
void set_visible(sys::state &state, bool vis)
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
message_body_text_internal * delegate
multiline_text_scrollbar * text_scrollbar
message_result on_scroll(sys::state &state, int32_t x, int32_t y, float amount, sys::key_modifiers mods) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
message_result test_mouse(sys::state &state, int32_t x, int32_t y, mouse_probe_type type) noexcept override
void on_create(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
std::vector< notification::message > messages
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_create(sys::state &state) noexcept override
void set_text(sys::state &state, std::string const &new_text)
void on_create(sys::state &state) noexcept override
void render_masked_rect(sys::state const &state, color_modification enabled, float x, float y, float width, float height, GLuint texture_handle, GLuint mask_texture_handle, ui::rotation r, bool flipped, bool rtl)
GLuint get_texture_handle(sys::state &state, dcon::texture_id id, bool keep_data)
uint16_t name_into_font_id(sys::state &state, std::string_view txt)
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
void make_size_from_graphics(sys::state &state, ui::element_data &dat)
void send(sys::state &state, element_base *parent, T value)
ogl::color_modification get_color_modification(bool is_under_mouse, bool is_disabled, bool is_interactable)
element_type get_element_type() const
rotation get_rotation() const
union ui::element_data::internal_data data
dcon::gfx_object_id gfx_object
ankerl::unordered_dense::map< dcon::text_key, element_target, hash_text_key > defs_by_name
element_base * under_mouse