mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-28 12:47:58 +03:00
ui2: try to fix aredfan's issue
Some checks are pending
Run code linters / Run code linters (push) Waiting to run
Some checks are pending
Run code linters / Run code linters (push) Waiting to run
This commit is contained in:
parent
748e621287
commit
c0d630e76e
8 changed files with 31 additions and 31 deletions
|
@ -74,18 +74,8 @@ static void M_DrawNode(const UI2_NODE *const node)
|
|||
return;
|
||||
}
|
||||
|
||||
// Draw self
|
||||
const bool draw_children = node->ops->draw(node);
|
||||
if (!draw_children) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Draw children
|
||||
const UI2_NODE *child = node->first_child;
|
||||
while (child != nullptr) {
|
||||
M_DrawNode(child);
|
||||
child = child->next_sibling;
|
||||
}
|
||||
node->ops->draw(node);
|
||||
// Recursing to children is a responsibility of the draw function.
|
||||
}
|
||||
|
||||
// Allocate a new node
|
||||
|
|
|
@ -31,12 +31,20 @@ void UI2_LayoutWrapper(
|
|||
UI2_LayoutBasic(node, x, y, w, h);
|
||||
UI2_NODE *child = node->first_child;
|
||||
while (child != nullptr) {
|
||||
child->ops->layout(child, x, y, w, h);
|
||||
if (child->ops->layout != nullptr) {
|
||||
child->ops->layout(child, x, y, w, h);
|
||||
}
|
||||
child = child->next_sibling;
|
||||
}
|
||||
}
|
||||
|
||||
bool UI2_DrawWrapper(const UI2_NODE *const node)
|
||||
void UI2_DrawWrapper(const UI2_NODE *const node)
|
||||
{
|
||||
return node->measure_w > 0.0f && node->measure_h > 0.0f;
|
||||
UI2_NODE *child = node->first_child;
|
||||
while (child != nullptr) {
|
||||
if (child->ops->draw != nullptr) {
|
||||
child->ops->draw(child);
|
||||
}
|
||||
child = child->next_sibling;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,4 +6,4 @@
|
|||
void UI2_MeasureWrapper(UI2_NODE *node);
|
||||
void UI2_LayoutBasic(UI2_NODE *node, float x, float y, float w, float h);
|
||||
void UI2_LayoutWrapper(UI2_NODE *node, float x, float y, float w, float h);
|
||||
bool UI2_DrawWrapper(const UI2_NODE *node);
|
||||
void UI2_DrawWrapper(const UI2_NODE *node);
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "game/ui2/widgets/stack.h"
|
||||
#include "utils.h"
|
||||
|
||||
static bool M_Draw(const UI2_NODE *node);
|
||||
static void M_Draw(const UI2_NODE *node);
|
||||
|
||||
static const UI2_WIDGET_OPS m_Ops = {
|
||||
.measure = UI2_MeasureWrapper,
|
||||
|
@ -92,13 +92,13 @@ static void M_HandleConfirm(const EVENT *event, void *user_data)
|
|||
state->history_idx = Console_History_GetLength();
|
||||
}
|
||||
|
||||
static bool M_Draw(const UI2_NODE *node)
|
||||
static void M_Draw(const UI2_NODE *node)
|
||||
{
|
||||
UI2_CONSOLE_STATE *const state = *(UI2_CONSOLE_STATE **)node->data;
|
||||
if (Console_IsOpened() || state->logs.vis_lines > 0) {
|
||||
Console_DrawBackdrop();
|
||||
}
|
||||
return true;
|
||||
UI2_DrawWrapper(node);
|
||||
}
|
||||
|
||||
void UI2_Console_Init(UI2_CONSOLE_STATE *const state)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "game/clock.h"
|
||||
#include "game/ui2/helpers.h"
|
||||
|
||||
static bool M_Draw(const UI2_NODE *node);
|
||||
static void M_Draw(const UI2_NODE *node);
|
||||
|
||||
static const UI2_WIDGET_OPS m_Ops = {
|
||||
.measure = UI2_MeasureWrapper,
|
||||
|
@ -11,7 +11,7 @@ static const UI2_WIDGET_OPS m_Ops = {
|
|||
.draw = M_Draw,
|
||||
};
|
||||
|
||||
static bool M_Draw(const UI2_NODE *const node)
|
||||
static void M_Draw(const UI2_NODE *const node)
|
||||
{
|
||||
UI2_FLASH_STATE *const state = *(UI2_FLASH_STATE **)node->data;
|
||||
const bool draw_children = state->count < 0;
|
||||
|
@ -19,7 +19,9 @@ static bool M_Draw(const UI2_NODE *const node)
|
|||
if (state->count < -state->rate) {
|
||||
state->count = state->rate;
|
||||
}
|
||||
return draw_children;
|
||||
if (draw_children) {
|
||||
UI2_DrawWrapper(node);
|
||||
}
|
||||
}
|
||||
|
||||
void UI2_BeginFlash(UI2_FLASH_STATE *const state)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "game/text.h"
|
||||
#include "game/ui2/helpers.h"
|
||||
|
||||
static bool M_Draw(const UI2_NODE *node);
|
||||
static void M_Draw(const UI2_NODE *node);
|
||||
|
||||
static const UI2_WIDGET_OPS m_Ops = {
|
||||
.measure = UI2_MeasureWrapper,
|
||||
|
@ -12,7 +12,7 @@ static const UI2_WIDGET_OPS m_Ops = {
|
|||
.draw = M_Draw,
|
||||
};
|
||||
|
||||
static bool M_Draw(const UI2_NODE *node)
|
||||
static void M_Draw(const UI2_NODE *node)
|
||||
{
|
||||
const UI2_FRAME_SETTINGS *settings = node->data;
|
||||
UI_STYLE menu_style = UI_STYLE_PC;
|
||||
|
@ -20,17 +20,17 @@ static bool M_Draw(const UI2_NODE *node)
|
|||
menu_style = g_Config.ui.menu_style;
|
||||
#endif
|
||||
|
||||
UI2_DrawWrapper(node);
|
||||
if (settings->draw_background) {
|
||||
Output_DrawTextBackground(
|
||||
menu_style, UI2_ScaleX(node->x), UI2_ScaleY(node->y),
|
||||
UI2_ScaleX(node->w), UI2_ScaleY(node->h), 30, TS_REQUESTED);
|
||||
UI2_ScaleX(node->w), UI2_ScaleY(node->h), 80, TS_REQUESTED);
|
||||
}
|
||||
if (settings->draw_outline) {
|
||||
Output_DrawTextOutline(
|
||||
menu_style, UI2_ScaleX(node->x), UI2_ScaleY(node->y),
|
||||
UI2_ScaleX(node->w), UI2_ScaleY(node->h), 20, TS_REQUESTED);
|
||||
UI2_ScaleX(node->w), UI2_ScaleY(node->h), 0, TS_REQUESTED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void UI2_BeginFrame(void)
|
||||
|
|
|
@ -12,7 +12,7 @@ typedef struct {
|
|||
} M_DATA;
|
||||
|
||||
static void M_Measure(UI2_NODE *node);
|
||||
static bool M_Draw(const UI2_NODE *node);
|
||||
static void M_Draw(const UI2_NODE *node);
|
||||
|
||||
static UI2_LABEL_SETTINGS m_DefaultSettings = { .scale = 1.0f };
|
||||
static const UI2_WIDGET_OPS m_Ops = {
|
||||
|
@ -47,7 +47,7 @@ static void M_Measure(UI2_NODE *const node)
|
|||
data->text, &node->measure_w, &node->measure_h, data->settings);
|
||||
}
|
||||
|
||||
static bool M_Draw(const UI2_NODE *const node)
|
||||
static void M_Draw(const UI2_NODE *const node)
|
||||
{
|
||||
M_DATA *const data = node->data;
|
||||
TEXTSTRING *const textstring =
|
||||
|
@ -57,7 +57,7 @@ static bool M_Draw(const UI2_NODE *const node)
|
|||
}
|
||||
Text_DrawText(textstring);
|
||||
Text_Remove(textstring);
|
||||
return true;
|
||||
UI2_DrawWrapper(node);
|
||||
}
|
||||
|
||||
void UI2_Label(const char *const text)
|
||||
|
|
|
@ -11,7 +11,7 @@ struct UI2_NODE;
|
|||
typedef struct {
|
||||
void (*measure)(struct UI2_NODE *node);
|
||||
void (*layout)(struct UI2_NODE *node, float x, float y, float w, float h);
|
||||
bool (*draw)(const struct UI2_NODE *node);
|
||||
void (*draw)(const struct UI2_NODE *node);
|
||||
} UI2_WIDGET_OPS;
|
||||
|
||||
// Node structure that forms the UI tree
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue