diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2025-11-17 08:59:04 -0500 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2025-11-17 08:59:04 -0500 |
| commit | 1a083f7bb41480980d1a1e5fd680189892b33afa (patch) | |
| tree | aef322023eba5262fd0085d134819d972018c5fa | |
| parent | 1d595e8c9b027e4aac222138e9c056eefaaaf512 (diff) | |
pke: static-ui ignore uninitialized text
| -rw-r--r-- | src/static-ui.cpp | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/static-ui.cpp b/src/static-ui.cpp index 33910db..d7d2f6a 100644 --- a/src/static-ui.cpp +++ b/src/static-ui.cpp @@ -417,26 +417,32 @@ bool pke_ui_calc_px(pk_arr_t<pke_ui_box_instance_buffer_item> &buffer, pk_arr_t< FontRenderSettings frs; switch (box->type) { case PKE_UI_BOX_TYPE_TEXT: - frs = FontType_GetFontRender(box->type_data->text.font_type_render)->settings; - frs.surface_area_pos = box->internal.px_corner; - frs.surface_area_size = box->internal.px_size; - if (PK_HAS_FLAG(box->flags, PKE_UI_BOX_FLAG_VISIBILITY_INVISIBLE)) { - frs.flags = FONT_RENDER_FLAG(FONT_RENDER_FLAG_T(frs.flags) | FONT_RENDER_FLAG_T(FONT_RENDER_FLAG_VISIBILITY_INVISIBLE)); - } else { - frs.flags = FONT_RENDER_FLAG(FONT_RENDER_FLAG_T(frs.flags) & (~FONT_RENDER_FLAG_T(FONT_RENDER_FLAG_VISIBILITY_INVISIBLE))); + if (box->type_data->text.font_type_render.font_render_handle != FontRenderHandle_MAX) { + frs = FontType_GetFontRender(box->type_data->text.font_type_render)->settings; + frs.surface_area_pos = box->internal.px_corner; + frs.surface_area_size = box->internal.px_size; + /* + if (PK_HAS_FLAG(box->flags, PKE_UI_BOX_FLAG_VISIBILITY_INVISIBLE)) { + frs.flags = FONT_RENDER_FLAG(FONT_RENDER_FLAG_T(frs.flags) | FONT_RENDER_FLAG_T(FONT_RENDER_FLAG_VISIBILITY_INVISIBLE)); + } else { + frs.flags = FONT_RENDER_FLAG(FONT_RENDER_FLAG_T(frs.flags) & (~FONT_RENDER_FLAG_T(FONT_RENDER_FLAG_VISIBILITY_INVISIBLE))); + } + */ + FontType_UpdateStringRender(box->type_data->text.font_type_render, &frs); } - FontType_UpdateStringRender(box->type_data->text.font_type_render, &frs); break; case PKE_UI_BOX_TYPE_BUTTON_TEXT: - frs = FontType_GetFontRender(box->type_data->button_text.font_type_render)->settings; - frs.surface_area_pos = box->internal.px_corner; - frs.surface_area_size = box->internal.px_size; - if (PK_HAS_FLAG(box->flags, PKE_UI_BOX_FLAG_VISIBILITY_INVISIBLE)) { - frs.flags = FONT_RENDER_FLAG(FONT_RENDER_FLAG_T(frs.flags) | FONT_RENDER_FLAG_T(FONT_RENDER_FLAG_VISIBILITY_INVISIBLE)); - } else { - frs.flags = FONT_RENDER_FLAG(FONT_RENDER_FLAG_T(frs.flags) & (~FONT_RENDER_FLAG_T(FONT_RENDER_FLAG_VISIBILITY_INVISIBLE))); + if (box->type_data->button_text.font_type_render.font_render_handle != FontRenderHandle_MAX) { + frs = FontType_GetFontRender(box->type_data->button_text.font_type_render)->settings; + frs.surface_area_pos = box->internal.px_corner; + frs.surface_area_size = box->internal.px_size; + if (PK_HAS_FLAG(box->flags, PKE_UI_BOX_FLAG_VISIBILITY_INVISIBLE)) { + frs.flags = FONT_RENDER_FLAG(FONT_RENDER_FLAG_T(frs.flags) | FONT_RENDER_FLAG_T(FONT_RENDER_FLAG_VISIBILITY_INVISIBLE)); + } else { + frs.flags = FONT_RENDER_FLAG(FONT_RENDER_FLAG_T(frs.flags) & (~FONT_RENDER_FLAG_T(FONT_RENDER_FLAG_VISIBILITY_INVISIBLE))); + } + FontType_UpdateStringRender(box->type_data->button_text.font_type_render, &frs); } - FontType_UpdateStringRender(box->type_data->button_text.font_type_render, &frs); break; case PKE_UI_BOX_TYPE_BUTTON_IMAGE: break; @@ -915,6 +921,7 @@ void pke_ui_internal_new_typed_box(pke_ui_box *box, const PKE_UI_BOX_TYPE type) break; case PKE_UI_BOX_TYPE_TEXT: tp_data = pk_new<pke_ui_box_type_data>(pke_ui_master.bkt); + tp_data->text.font_type_render = FontTypeRender_MAX; box->flags |= PKE_UI_BOX_FLAG_VISIBILITY_INVISIBLE; break; case PKE_UI_BOX_TYPE_INPUT_TEXT: |
