#include "ui_widgets.h" #include "game_state.h" f32 uiGetScale() { return GetScreenHeight() / 720.0f; } Font getFont() { static const Game *game = NULL; if (!game) { game = ecs_singleton_get(ECS, Game); } return game->font; } void uiPushDivParentPercentage(f32 xPercent, f32 yPercent) { bzUIPushDiv(UI, (BzUISize) { .kind = BZ_UI_SIZE_REL_PARENT, .value = xPercent, }, (BzUISize) { .kind = BZ_UI_SIZE_REL_PARENT, .value = yPercent }); } void uiBaseLabel(const char *txt, Font font, f32 scl) { BzUINode *node = bzUINodeMake(UI, bzUIKeyFromString(txt), &(BzUINodeDesc) { .flags = BZ_UI_DRAW_TEXT | BZ_UI_DRAW_TEXT_SHADOW | BZ_UI_ALIGN_CENTER, .semanticSize[BZ_UI_AXIS_X] = { .kind = BZ_UI_SIZE_FIT, }, .semanticSize[BZ_UI_AXIS_Y] = { .kind = BZ_UI_SIZE_FIT }, .padding = {5, 5, 5, 5}, }); bzUISetTextStyle(UI, node, (BzUITextStyle) { .text = txt, .font = font, .fontSpacing = 2 * uiGetScale() * scl, .fontSize = 62 * uiGetScale() * scl, .normal = WHITE, .hover = WHITE, .active = WHITE, }); bzUISetTextShadowStyle(UI, node, (BzUITextShadowStyle) { .offset[BZ_UI_AXIS_X] = 2 * uiGetScale() * scl, .offset[BZ_UI_AXIS_Y] = 2 * uiGetScale() * scl, .normal = BLACK, .hover = BLACK, .active = BLACK, }); } bool uiBaseTextButton(const char *txt, Font font, f32 scl) { BzUINode *node = bzUINodeMake(UI, bzUIKeyFromString(txt), &(BzUINodeDesc) { .flags = BZ_UI_DRAW_TEXT | BZ_UI_DRAW_TEXT_SHADOW | BZ_UI_ALIGN_CENTER, .semanticSize[BZ_UI_AXIS_X] = { .kind = BZ_UI_SIZE_FIT, }, .semanticSize[BZ_UI_AXIS_Y] = { .kind = BZ_UI_SIZE_FIT }, .padding = {0, 0, 0, 0}, .margin = {5, 5, 5, 5}, }); bzUISetTextStyle(UI, node, (BzUITextStyle) { .text = txt, .font = font, .fontSpacing = 2 * uiGetScale() * scl, .fontSize = 62 * uiGetScale() * scl, .normal = WHITE, .hover = GRAY, .active = YELLOW }); bzUISetTextShadowStyle(UI, node, (BzUITextShadowStyle) { .offset[BZ_UI_AXIS_X] = 2 * uiGetScale() * scl, .offset[BZ_UI_AXIS_Y] = 2 * uiGetScale() * scl, .normal = BLACK, .hover = BLACK, .active = BLACK, }); return bzUIGetInteraction(UI, node).clicked; } void uiMainMenuLabel(const char *txt) { uiBaseLabel(txt, getFont(), 1.8f); } bool uiMainMenuButton(const char *txt) { return uiBaseTextButton(txt, getFont(), 0.8f); }