9 rectangle.
w -= value * 2.f;
10 rectangle.
h -= value * 2.f;
19 rect result{ 0.f, 0.f, w, h };
25 result.x = rectangle.
x + rectangle.
w / 2.f - w / 2.f;
28 result.x = rectangle.
x + rectangle.
w - w;
38 result.y = rectangle.
y + rectangle.
h / 2.f - h / 2.f;
41 result.y = rectangle.
y + rectangle.
h - h;
53 float red,
float green,
float blue
55 if(state.mouse_x_position / state.user_settings.ui_scale >= r.
x && state.mouse_x_position / state.user_settings.ui_scale <= r.
x + r.
w) {
56 if(state.mouse_y_position / state.user_settings.ui_scale >= r.
y && state.mouse_y_position / state.user_settings.ui_scale <= r.
y + r.
h) {
63 r.
x , r.
y , r.
w , r.
h , red, green, blue,
72 if(state.mouse_x_position / state.user_settings.ui_scale >= r.
x && state.mouse_x_position / state.user_settings.ui_scale <= r.
x + r.
w) {
73 if(state.mouse_y_position / state.user_settings.ui_scale >= r.
y && state.mouse_y_position / state.user_settings.ui_scale <= r.
y + r.
h) {
80 r.
x , r.
y , r.
w , r.
h , 0.f, 0.f, 0.f,
86 r.
x + 1.f, r.
y + 1.f, r.
w - 2.f, r.
h - 2.f,
94 int frame,
int total_frames,
97 if(state.mouse_x_position / state.user_settings.ui_scale >= r.
x && state.mouse_x_position / state.user_settings.ui_scale <= r.
x + r.
w) {
98 if(state.mouse_y_position / state.user_settings.ui_scale >= r.
y && state.mouse_y_position / state.user_settings.ui_scale <= r.
y + r.
h) {
105 r.
x , r.
y , r.
w , r.
h ,
114 GLuint texture_handle
116 if(state.mouse_x_position / state.user_settings.ui_scale >= r.
x && state.mouse_x_position / state.user_settings.ui_scale <= r.
x + r.
w) {
117 if(state.mouse_y_position / state.user_settings.ui_scale >= r.
y && state.mouse_y_position / state.user_settings.ui_scale <= r.
y + r.
h) {
135 bool result = state.iui_state.active_element == identifier;
143 if(!(state.mouse_x_position / state.user_settings.ui_scale > r.
x && state.mouse_x_position / state.user_settings.ui_scale < r.
x + r.
w)) {
146 if(!(state.mouse_y_position / state.user_settings.ui_scale > r.
y && state.mouse_y_position / state.user_settings.ui_scale < r.
y + r.
h)) {
151 state.iui_state.hovered_element = identifier;
153 if(state.iui_state.mouse_pressed) {
154 if(state.iui_state.active_element == identifier) {
156 state.iui_state.mouse_pressed =
false;
159 state.iui_state.active_element = identifier;
170 GLuint texture_handle,
173 bool result = state.iui_state.active_element == identifier;
181 if(!(state.mouse_x_position / state.user_settings.ui_scale > r.
x && state.mouse_x_position / state.user_settings.ui_scale < r.
x + r.
w)) {
184 if(!(state.mouse_y_position / state.user_settings.ui_scale > r.
y && state.mouse_y_position / state.user_settings.ui_scale < r.
y + r.
h)) {
189 state.iui_state.hovered_element = identifier;
191 if(state.iui_state.mouse_pressed) {
192 if(state.iui_state.active_element == identifier) {
194 state.iui_state.mouse_pressed =
false;
197 state.iui_state.active_element = identifier;
206 uint16_t font_handle,
216 .bottom = (int16_t)h,
217 .font_id = font_handle,
227 std::vector<text::text_chunk>& content,
230 auto font_size = state.font_collection.line_height(state,
current_font);
231 auto text_height = 0.f;
233 for(
auto& txt : content) {
234 text_height = std::max(text_height, txt.y + font_size);
237 for(
auto& txt : content) {
242 (r.
y + txt.y + r.
h / 2.f - text_height / 2.f) ,
272 render_text(state, contents.base_layout.contents, r, { 0.f, 0.f, 0.f });
300 render_text(state, contents.base_layout.contents, r, { 0.f, 0.f, 0.f });
328 render_text(state, contents.base_layout.contents, r, { 0.f, 0.f, 0.f });
337 std::string_view key,
352 render_text(state, contents.base_layout.contents, r, color);
361 std::string_view key,
369 auto key = state.lookup_key(name);
370 auto def = state.ui_state.defs_by_name.find(key)->second.definition;
371 auto& desc = state.ui_defs.gui[def];
372 local_desc.
w = desc.size.x;
373 local_desc.
h = desc.size.y;
374 auto& gfx_def = state.ui_defs.gfx[desc.data.button.button_image];
375 auto handle =
ogl::get_texture_handle(state, gfx_def.primary_texture_handle, gfx_def.is_partially_transparent());
void shrink(rect &rectangle, float value)
rect subrect(rect &rectangle, float w, float h, alignment_horizontal align_hor, alignment_vertical align_vert)
void move_to(rect &rectangle, float x, float y)
void render_colored_rect(sys::state const &state, float x, float y, float width, float height, float red, float green, float blue, ui::rotation r, bool flipped, bool rtl)
void render_subsprite(sys::state const &state, color_modification enabled, int frame, int total_frames, float x, float y, float width, float height, GLuint texture_handle, ui::rotation r, bool flipped, bool rtl)
void render_simple_rect(sys::state const &state, float x, float y, float width, float height, ui::rotation r, bool flipped, bool rtl)
GLuint get_texture_handle(sys::state &state, dcon::texture_id id, bool keep_data)
void add_to_layout_box(sys::state &state, layout_base &dest, layout_box &box, embedded_flag ico)
layout_box open_layout_box(layout_base &dest, int32_t indent)
void localised_format_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view key, text::substitution_map const &sub)
endless_layout create_endless_layout(sys::state &state, layout &dest, layout_parameters const ¶ms)
void close_layout_box(columnar_layout &dest, layout_box &box)
void render_text_chunk(sys::state &state, text::text_chunk t, float x, float baseline_y, uint16_t font_id, ogl::color3f text_color, ogl::color_modification cmod)
void load_description(sys::state &state, std::string_view name, element_description &local_desc)
ankerl::unordered_dense::map< int32_t, std::vector< text::text_chunk > > gui_text_chunks_map
void localized_string(sys::state &state, int32_t identifier, rect &r, std::string_view key, ogl::color3f color={ 0.f, 0.f, 0.f })
void render_text(sys::state &state, std::vector< text::text_chunk > &content, rect &r, ogl::color3f color)
void int_whole(sys::state &state, int32_t identifier, rect &r, int32_t value)
text::endless_layout init_layout(sys::state &state, text::layout &layout, uint16_t font_handle, text::alignment align, float w, float h)
ankerl::unordered_dense::map< int32_t, int32_t > gui_int_map
ankerl::unordered_dense::map< int32_t, float > gui_float_map
bool button(sys::state &state, int32_t identifier, rect &r, bool active)
void panel(sys::state &state, rect &r)
void float_2(sys::state &state, int32_t identifier, rect &r, float value)
void localized_string_r(sys::state &state, int32_t identifier, rect r, std::string_view key, ogl::color3f color={ 0.f, 0.f, 0.f })
void panel_textured(sys::state &state, rect &r, GLuint texture_handle)
ankerl::unordered_dense::map< int32_t, std::string > gui_text_map
bool button_textured(sys::state &state, int32_t identifier, rect &r, int total_frames, GLuint texture_handle, bool active)
void panel_colored(sys::state &state, rect &r, float red, float green, float blue)
void price(sys::state &state, int32_t identifier, rect &r, float value)
void panel_subsprite(sys::state &state, rect &r, int frame, int total_frames, GLuint texture_handle)
Holds important data about the game world, state, and other data regarding windowing,...