Project Alice
Loading...
Searching...
No Matches
gui_error_window.cpp
Go to the documentation of this file.
2
3namespace ui {
4
5void error_body_text::populate_layout(sys::state& state, text::endless_layout& contents) noexcept {
6 auto box = text::open_layout_box(contents);
7 text::add_to_layout_box(state, contents, box, msg);
8 text::close_layout_box(contents, box);
9}
11 base_data.size.y = int16_t(150);
13}
16 switch(base_data.data.text.get_alignment()) {
19 break;
22 break;
23 default:
24 break;
25 }
26 auto border = base_data.data.text.border_size;
27 auto color = delegate->black_text ? text::text_color::black : text::text_color::white;
28 auto container = text::create_endless_layout(state,
29 delegate->internal_layout,
31 border.x,
32 border.y,
33 int16_t(base_data.size.x - border.x * 2),
34 int16_t(base_data.size.y - border.y * 2),
35 base_data.data.text.font_handle,
36 0,
37 align,
38 color,
39 false });
40 populate_layout(state, container);
41}
42
43std::unique_ptr<element_base> error_dialog_window::make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept {
44 if(name == "title") {
45 auto ptr = make_element_by_type<simple_text_element_base>(state, id);
46 title = ptr.get();
47 return ptr;
48 } else if(name == "description") {
49 auto ptr = make_element_by_type<error_body_text>(state, id);
50 body = ptr.get();
51 return ptr;
52 } else if(name == "agreebutton") {
53 return make_element_by_type<generic_close_button>(state, id);
54 } else if(name == "background") {
55 auto ptr = make_element_by_type<draggable_target>(state, id);
56 ptr->base_data.size = base_data.size;
57 return ptr;
58 } else {
59 return nullptr;
60 }
61}
62void popup_error_window(sys::state& state, std::string_view title, std::string_view body) {
63 if(state.ui_state.error_win == nullptr) {
64 auto new_elm = ui::make_element_by_type<ui::error_dialog_window>(state, "defaultinfodialog");
65 state.ui_state.error_win = new_elm.get();
66 state.current_scene.get_root(state)->add_child_to_front(std::move(new_elm));
67 }
68
69 auto win = static_cast<ui::error_dialog_window*>(state.ui_state.error_win);
70 win->title->set_text(state, std::string(title));
71 win->body->msg = std::string(body);
72 win->set_visible(state, true);
73 win->impl_on_update(state);
74}
75}
virtual message_result get(sys::state &state, Cyto::Any &payload) noexcept
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
simple_text_element_base * title
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 add_to_layout_box(sys::state &state, layout_base &dest, layout_box &box, embedded_flag ico)
Definition: text.cpp:1165
layout_box open_layout_box(layout_base &dest, int32_t indent)
Definition: text.cpp:1799
alignment
Definition: text.hpp:36
endless_layout create_endless_layout(sys::state &state, layout &dest, layout_parameters const &params)
Definition: text.cpp:1100
void close_layout_box(columnar_layout &dest, layout_box &box)
Definition: text.cpp:1807
void popup_error_window(sys::state &state, std::string_view title, std::string_view body)
element_base * error_win