ui: fix flash not working

This commit is contained in:
Marcin Kurczewski 2025-04-19 20:45:42 +02:00
parent 411c3443df
commit 9ee04f9c41

View file

@ -3,22 +3,12 @@
#include "game/ui/elements/hide.h" #include "game/ui/elements/hide.h"
#include "game/ui/helpers.h" #include "game/ui/helpers.h"
static void M_Draw(const UI_NODE *node);
static const UI_WIDGET_OPS m_Ops = { static const UI_WIDGET_OPS m_Ops = {
.measure = UI_MeasureWrapper, .measure = UI_MeasureWrapper,
.layout = UI_LayoutWrapper, .layout = UI_LayoutWrapper,
.draw = M_Draw, .draw = UI_DrawWrapper,
}; };
static void M_Draw(const UI_NODE *const node)
{
UI_FLASH_STATE *const s = *(UI_FLASH_STATE **)node->data;
UI_BeginHide(s->count >= 0);
UI_DrawWrapper(node);
UI_EndHide();
}
void UI_Flash_Init(UI_FLASH_STATE *const s, const int32_t rate) void UI_Flash_Init(UI_FLASH_STATE *const s, const int32_t rate)
{ {
s->count = 0; s->count = 0;
@ -43,9 +33,11 @@ void UI_BeginFlash(UI_FLASH_STATE *const s)
*(UI_FLASH_STATE **)node->data = s; *(UI_FLASH_STATE **)node->data = s;
UI_AddChild(node); UI_AddChild(node);
UI_PushCurrent(node); UI_PushCurrent(node);
UI_BeginHide(s->count >= 0);
} }
void UI_EndFlash(void) void UI_EndFlash(void)
{ {
UI_EndHide();
UI_PopCurrent(); UI_PopCurrent();
} }