71static int debugTextPositionY = 0;
72static int debugPositionX = 0;
73#define DEBUG_PANEL_WIDTH 300
75static void UI_HighlightNode (
const uiNode_t* node,
const vec4_t color)
79 int lineDefinition[4];
83 static const vec4_t grey = {0.7, 0.7, 0.7, 1.0};
93 UI_DrawString(
"f_small_bold",
ALIGN_UL, debugPositionX + 20, debugTextPositionY, debugPositionX + 20, DEBUG_PANEL_WIDTH, 0, text, 0, 0,
nullptr,
false,
LONGLINES_PRETTYCHOP);
94 debugTextPositionY += 15;
96 if (debugPositionX != 0) {
97 lineDefinition[0] = debugPositionX + 20;
98 lineDefinition[2] = pos[0] + node->
box.
size[0];
100 lineDefinition[0] = debugPositionX + 20 + width;
101 lineDefinition[2] = pos[0];
103 lineDefinition[1] = debugTextPositionY - 5;
104 lineDefinition[3] = pos[1];
110 vec4_t trans = {1, 1, 1, 1};
112 trans[3] = trans[3] / 2;
115 const int x = pos[0] + current->pos[0];
116 const int y = pos[1] + current->pos[1];
117 UI_DrawFill(x, y, current->size[0], current->size[1], trans);
128static void UI_DrawDebugNodeNames (
void)
130 static const vec4_t white = {1, 1.0, 1.0, 1.0};
131 static const vec4_t background = {0.0, 0.0, 0.0, 0.5};
133 debugTextPositionY = 100;
137 debugPositionX =
viddef.virtualWidth - DEBUG_PANEL_WIDTH;
142 UI_DrawString(
"f_small_bold",
ALIGN_UL, debugPositionX, debugTextPositionY, debugPositionX, 200, 0,
va(
"Mouse X: %i Y: %i",
mousePosX,
mousePosY), 0, 0,
nullptr,
false,
LONGLINES_PRETTYCHOP);
143 debugTextPositionY += 15;
145 UI_DrawString(
"f_small_bold",
ALIGN_UL, debugPositionX, debugTextPositionY, debugPositionX, 200, 0,
"main active window:", 0, 0,
nullptr,
false,
LONGLINES_PRETTYCHOP);
146 debugTextPositionY += 15;
147 UI_DrawString(
"f_small_bold",
ALIGN_UL, debugPositionX+20, debugTextPositionY, debugPositionX + 20, 200, 0,
Cvar_GetString(
"ui_sys_active"), 0, 0,
nullptr,
false,
LONGLINES_PRETTYCHOP);
148 debugTextPositionY += 15;
149 UI_DrawString(
"f_small_bold",
ALIGN_UL, debugPositionX, debugTextPositionY, debugPositionX, 200, 0,
"main option window:", 0, 0,
nullptr,
false,
LONGLINES_PRETTYCHOP);
150 debugTextPositionY += 15;
151 UI_DrawString(
"f_small_bold",
ALIGN_UL, debugPositionX+20, debugTextPositionY, debugPositionX + 20, 200, 0,
Cvar_GetString(
"ui_sys_main"), 0, 0,
nullptr,
false,
LONGLINES_PRETTYCHOP);
152 debugTextPositionY += 15;
153 UI_DrawString(
"f_small_bold",
ALIGN_UL, debugPositionX, debugTextPositionY, debugPositionX, 200, 0,
"-----------------------", 0, 0,
nullptr,
false,
LONGLINES_PRETTYCHOP);
154 debugTextPositionY += 15;
161 UI_DrawString(
"f_small_bold",
ALIGN_UL, debugPositionX, debugTextPositionY, debugPositionX, 200, 0,
"window stack:", 0, 0,
nullptr,
false,
LONGLINES_PRETTYCHOP);
162 debugTextPositionY += 15;
163 for (
int stackPosition = 0; stackPosition <
ui_global.windowStackPos; stackPosition++) {
165 UI_DrawString(
"f_small_bold",
ALIGN_UL, debugPositionX+20, debugTextPositionY, debugPositionX + 20, 200, 0, window->
name, 0, 0,
nullptr,
false,
LONGLINES_PRETTYCHOP);
166 debugTextPositionY += 15;
172 static const vec4_t red = {1.0, 0.0, 0.0, 1.0};
173 UI_DrawString(
"f_small_bold",
ALIGN_UL, debugPositionX, debugTextPositionY, debugPositionX, 200, 0,
"-----------------------", 0, 0,
nullptr,
false,
LONGLINES_PRETTYCHOP);
174 debugTextPositionY += 15;
176 UI_DrawString(
"f_small_bold",
ALIGN_UL, debugPositionX, debugTextPositionY, debugPositionX, 200, 0,
"hovered node:", 0, 0,
nullptr,
false,
LONGLINES_PRETTYCHOP);
177 debugTextPositionY += 15;
187 UI_DrawString(
"f_small_bold",
ALIGN_UL, debugPositionX, debugTextPositionY, debugPositionX, 200, 0,
"-----------------------", 0, 0,
nullptr,
false,
LONGLINES_PRETTYCHOP);
188 debugTextPositionY += 15;
191 UI_DrawString(
"f_small_bold",
ALIGN_UL, debugPositionX, debugTextPositionY, debugPositionX, 200, 0,
"drag and drop target node:", 0, 0,
nullptr,
false,
LONGLINES_PRETTYCHOP);
192 debugTextPositionY += 15;
243 static int globalTransX = 0;
244 static int globalTransY = 0;
245 bool hasClient =
false;
257 globalTransX += clientPosition[0];
258 globalTransY += clientPosition[1];
259 trans[0] = clientPosition[0] *
viddef.rx;
260 trans[1] = clientPosition[1] *
viddef.ry;
272 globalTransX -= clientPosition[0];
273 globalTransY -= clientPosition[1];
274 trans[0] = -clientPosition[0] *
viddef.rx;
275 trans[1] = -clientPosition[1] *
viddef.ry;
298 const vec4_t noticeBG = { 1.0f, 0.0f, 0.0f, 0.2f };
299 const vec4_t noticeColor = { 1.0f, 1.0f, 1.0f, 1.0f };
300 int height = 0, width = 0;
301 const int maxWidth = 500;
302 const char* font =
"f_normal";
306 vec_t* noticePosition;
309 if (noticePosition) {
310 x = noticePosition[0];
311 y = noticePosition[1];
326 if (x + width + 3 >
viddef.virtualWidth)
331 UI_DrawFill((x - 2 + dx) - ((width + 2) / 2), (y - 2) - ((height + 2) / 2), width + 4, height + 4, noticeBG);
364 for (; pos <
ui_global.windowStackPos; pos++) {
394 UI_DrawDebugNodeNames();
416 if (windowName ==
nullptr) {
419 Com_Printf(
"UI_DisplayNotice: No active window\n");
423 Com_Printf(
"UI_DisplayNotice: '%s' not found\n", windowName);
int CL_Milliseconds(void)
void R_FontTextSize(const char *fontId, const char *text, int maxWidth, longlines_t method, int *width, int *height, int *lines, bool *isTruncated)
Supply information about the size of the text when it is linewrapped and rendered,...
void R_Color(const vec4_t rgba)
Change the color to given value.
Primary header for client.
void Com_Printf(const char *const fmt,...)
static const vec4_t green
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
const char * Cvar_GetString(const char *varName)
Returns the value of cvar as string.
void R_DrawLine(int *verts, float thickness)
Draws one line with only one start and one end point.
void R_Transform(const vec3_t transform, const vec3_t rotate, const vec3_t scale)
Perform translate, rotate and scale operations on the current matrix.
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
struct uiExcludeRect_s * next
Atomic structure used to define most of the UI.
uiExcludeRect_t * firstExcludeRect
bool UI_DNDIsDragging(void)
Return true if we are dragging something.
static uiNode_t * targetNode
uiNode_t * UI_DNDGetTargetNode(void)
Return target of the DND.
void UI_DrawDragAndDrop(int mousePosX, int mousePosY)
Draw to dragging object and catch mouse move event.
static void UI_DrawNode(uiNode_t *node)
void UI_CaptureDrawOver(uiNode_t *node)
Capture a node we will draw over all nodes (per window).
static char noticeText[256]
static const int TOOLTIP_DELAY
static uiNode_t * drawOverNode
Node we will draw over.
static bool tooltipVisible
static void UI_CheckTooltipDelay(uiNode_t *node, uiTimer_t *timer)
static cvar_t * ui_show_tooltips
static uiTimer_t * tooltipTimer
static uiNode_t * noticeWindow
void UI_DisplayNotice(const char *text, int time, const char *windowName)
Displays a message over all windows.
static void UI_DrawNotice(void)
Generic notice function that renders a message to the screen.
void UI_Draw(void)
Draws the window stack.
Internal data use by the UI package.
int UI_DebugMode(void)
Get the current debug mode (0 mean disabled).
void UI_Validate(uiNode_t *node)
Validate a node tree.
bool UI_Node_IsVirtual(uiNode_t const *node)
void UI_Node_DrawTooltip(const uiNode_t *node, int x, int y)
const char * UI_Node_GetWidgetName(uiNode_t const *node)
void UI_Node_DrawOverWindow(uiNode_t *node)
void UI_Node_GetClientPosition(uiNode_t const *node, vec2_t position)
bool UI_Node_IsDrawItselfChild(uiNode_t const *node)
bool UI_Node_IsDrawable(uiNode_t const *node)
void UI_Node_Draw(uiNode_t *node)
bool UI_Node_IsScrollableContainer(uiNode_t const *node)
void UI_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
C interface to allow to access to cpp node code.
vec_t * UI_WindowNodeGetNoticePosition(uiNode_t *node)
Get the noticePosition from a window node.
bool UI_CheckVisibility(uiNode_t *node)
Check the if conditions for a given node.
void UI_DeleteNode(uiNode_t *node)
int UI_DrawString(const char *fontID, align_t align, int x, int y, int absX, int maxWidth, int lineHeight, const char *c, int boxHeight, int scrollPos, int *curLine, bool increaseLine, longlines_t method)
void UI_DrawRect(int x, int y, int w, int h, const vec4_t color, float lineWidth, int pattern)
void UI_PushClipRect(int x, int y, int width, int height)
void UI_DrawFill(int x, int y, int w, int h, const vec4_t color)
Fills a box of pixels with a single color.
void UI_PopClipRect(void)
void UI_HandleTimers(void)
Internal function to handle timers.
void UI_TimerStop(uiTimer_t *timer)
Stop a timer.
uiTimer_t * UI_AllocTimer(uiNode_t *node, int firstDelay, timerCallback_t callback)
Allocate a new time for a node.
void UI_TimerStart(uiTimer_t *timer)
Restart a timer.
uiNode_t * UI_GetWindow(const char *name)
Searches all windows for the specified one.
int UI_GetLastFullScreenWindow(void)
Returns the ID of the last fullscreen ID. Before this, window should be hidden.
uiNode_t * UI_GetActiveWindow(void)
Returns the current active window from the window stack or nullptr if there is none.
#define Vector2NotEmpty(a)
#define Vector4Copy(src, dest)