From 1a083f7bb41480980d1a1e5fd680189892b33afa Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Mon, 17 Nov 2025 08:59:04 -0500 Subject: pke: static-ui ignore uninitialized text --- src/static-ui.cpp | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'src') 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 &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_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: -- cgit v1.2.3