38 #include "../client.h"
39 #include "../renderer/r_draw.h"
40 #include "../renderer/r_misc.h"
71 static int debugTextPositionY = 0;
72 static int debugPositionX = 0;
73 #define DEBUG_PANEL_WIDTH 300
75 static 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};
84 UI_HighlightNode(node->
parent, grey);
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);
128 static 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;
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;
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;
178 UI_HighlightNode(hoveredNode, red);
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;
193 UI_HighlightNode(targetNode, green);
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];
318 x += noticeWindow->
box.
pos[0];
319 y += noticeWindow->
box.
pos[1];
331 UI_DrawFill((x - 2 + dx) - ((width + 2) / 2), (y - 2) - ((height + 2) / 2), width + 4, height + 4, noticeBG);
368 drawOverNode =
nullptr;
384 noticeWindow =
nullptr;
394 UI_DrawDebugNodeNames();
416 if (windowName ==
nullptr) {
418 if (noticeWindow ==
nullptr)
419 Com_Printf(
"UI_DisplayNotice: No active window\n");
422 if (noticeWindow ==
nullptr)
423 Com_Printf(
"UI_DisplayNotice: '%s' not found\n", windowName);
#define Vector2NotEmpty(a)
uiNode_t * windowStack[UI_MAX_WINDOWSTACK]
uiNode_t * UI_DNDGetTargetNode(void)
Return target of the DND.
void UI_PopClipRect(void)
void UI_Validate(uiNode_t *node)
Validate a node tree.
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.
static void UI_DrawNotice(void)
Generic notice function that renders a message to the screen.
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...
bool UI_CheckVisibility(uiNode_t *node)
Check the if conditions for a given node.
void UI_CaptureDrawOver(uiNode_t *node)
Capture a node we will draw over all nodes (per window)
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
bool UI_Node_IsVirtual(uiNode_t const *node)
uiNode_t * UI_GetActiveWindow(void)
Returns the current active window from the window stack or nullptr if there is none.
uiExcludeRect_t * firstExcludeRect
static uiNode_t * targetNode
uiTimer_t * UI_AllocTimer(uiNode_t *node, int firstDelay, timerCallback_t callback)
Allocate a new time for a node.
void Com_Printf(const char *const fmt,...)
bool UI_Node_IsScrollableContainer(uiNode_t const *node)
void UI_Node_DrawOverWindow(uiNode_t *node)
static const int TOOLTIP_DELAY
void UI_DeleteNode(uiNode_t *node)
void R_Color(const vec4_t rgba)
Change the color to given value.
Internal data use by the UI package.
C interface to allow to access to cpp node code.
int UI_GetLastFullScreenWindow(void)
Returns the ID of the last fullscreen ID. Before this, window should be hidden.
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
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, without actually rendering it. Any of the output parameters may be nullptr.
bool UI_Node_IsDrawable(uiNode_t const *node)
void UI_Draw(void)
Draws the window stack.
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
void UI_HandleTimers(void)
Internal function to handle timers.
void UI_Node_GetClientPosition(uiNode_t const *node, vec2_t position)
static char noticeText[256]
static void UI_CheckTooltipDelay(uiNode_t *node, uiTimer_t *timer)
static uiNode_t * drawOverNode
Node we will draw over.
void UI_TimerStop(uiTimer_t *timer)
Stop a timer.
Atomic structure used to define most of the UI.
vec_t * UI_WindowNodeGetNoticePosition(uiNode_t *node)
Get the noticePosition from a window node.
void UI_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
bool UI_Node_IsDrawItselfChild(uiNode_t const *node)
static const vec4_t green
void R_DrawLine(int *verts, float thickness)
Draws one line with only one start and one end point.
uiNode_t * UI_GetWindow(const char *name)
Searches all windows for the specified one.
static uiNode_t * noticeWindow
void UI_Node_Draw(uiNode_t *node)
void UI_Node_DrawTooltip(const uiNode_t *node, int x, int y)
static uiTimer_t * tooltipTimer
void UI_DrawDragAndDrop(int mousePosX, int mousePosY)
Draw to dragging object and catch mouse move event.
static cvar_t * ui_show_tooltips
int UI_DebugMode(void)
Get the current debug mode (0 mean disabled)
void UI_PushClipRect(int x, int y, int width, int height)
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)
const char * UI_Node_GetWidgetName(uiNode_t const *node)
const char * Cvar_GetString(const char *varName)
Returns the value of cvar as string.
void UI_DrawFill(int x, int y, int w, int h, const vec4_t color)
Fills a box of pixels with a single color.
bool UI_DNDIsDragging(void)
Return true if we are dragging something.
struct uiExcludeRect_s * next
static void UI_DrawNode(uiNode_t *node)
void UI_TimerStart(uiTimer_t *timer)
Restart a timer.
#define Vector4Copy(src, dest)
static bool tooltipVisible
int CL_Milliseconds(void)
void UI_DisplayNotice(const char *text, int time, const char *windowName)
Displays a message over all windows.