UFO: Alien Invasion
Loading...
Searching...
No Matches
ui_node_text.cpp
Go to the documentation of this file.
1
5
6/*
7Copyright (C) 2002-2025 UFO: Alien Invasion.
8
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License
11as published by the Free Software Foundation; either version 2
12of the License, or (at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18See the GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24*/
25
26#include "../ui_main.h"
27#include "../ui_internal.h"
28#include "../ui_font.h"
29#include "../ui_actions.h"
30#include "../ui_parse.h"
31#include "../ui_behaviour.h"
32#include "../ui_render.h"
33#include "../ui_lua.h"
34
35#include "ui_node_text.h"
37
38#include "../../client.h"
39#include "../../cl_language.h"
41
43
44#define EXTRADATA_TYPE textExtraData_t
45#define EXTRADATA(node) UI_EXTRADATA(node, EXTRADATA_TYPE)
46#define EXTRADATACONST(node) UI_EXTRADATACONST(node, EXTRADATA_TYPE)
47
48/* Used for drag&drop-like scrolling */
49static int mouseScrollX;
50static int mouseScrollY;
51
53{
54 int v;
55 if (EXTRADATA(node).dataID == TEXT_NULL || node->text != nullptr)
56 return;
57
58 v = UI_GetDataVersion(EXTRADATA(node).dataID);
59 if (v != EXTRADATA(node).versionId) {
60 updateCache(node);
61 }
62}
63
64const char* UI_TextNodeGetSelectedText (uiNode_t* node, int num)
65{
66 const char* text = UI_GetTextFromList(EXTRADATA(node).dataID, num);
67 if (text == nullptr)
68 return "";
69 return text;
70}
71
75void UI_TextNodeSelectLine (uiNode_t* node, int num)
76{
77 if (EXTRADATA(node).textLineSelected == num)
78 return;
79 EXTRADATA(node).textLineSelected = num;
80 EXTRADATA(node).textSelected = UI_TextNodeGetSelectedText(node, num);
81 if (node->onChange) {
83 }
84 if (node->lua_onChange != LUA_NOREF) {
86 }
87}
88
93void UI_TextScrollEnd (const char* nodePath)
94{
95 uiNode_t* node = UI_GetNodeByPath(nodePath);
96 if (!node) {
97 Com_DPrintf(DEBUG_CLIENT, "UI_TextScrollEnd: Node '%s' could not be found\n", nodePath);
98 return;
99 }
100
101 if (!UI_NodeInstanceOf(node, "text")) {
102 Com_Printf("UI_TextScrollEnd: '%s' node is no instance of 'text'.\n", Cmd_Argv(1));
103 return;
104 }
105
106 uiTextNode* b = dynamic_cast<uiTextNode*>(node->behaviour->manager.get());
107 b->validateCache(node);
108
109 if (EXTRADATA(node).super.scrollY.fullSize > EXTRADATA(node).super.scrollY.viewSize) {
110 EXTRADATA(node).super.scrollY.viewPos = EXTRADATA(node).super.scrollY.fullSize - EXTRADATA(node).super.scrollY.viewSize;
111 if (EXTRADATA(node).super.onViewChange) {
112 UI_ExecuteEventActions(node, EXTRADATA(node).super.onViewChange);
113 }
114 else if (EXTRADATA(node).super.lua_onViewChange != LUA_NOREF) {
115 UI_ExecuteLuaEventScript (node, EXTRADATA(node).super.lua_onViewChange);
116 }
117 }
118}
119
126static int UI_TextNodeGetLine (const uiNode_t* node, int x, int y)
127{
128 int lineHeight;
129 int line;
130 assert(UI_NodeInstanceOf(node, "text"));
131
132 lineHeight = EXTRADATACONST(node).lineHeight;
133 if (lineHeight == 0) {
134 const char* font = UI_GetFontFromNode(node);
135 lineHeight = UI_FontGetHeight(font);
136 }
137
138 UI_NodeAbsoluteToRelativePos(node, &x, &y);
139 y -= node->padding;
140
141 /* skip position over the first line */
142 if (y < 0)
143 return -1;
144 line = (int) (y / lineHeight) + EXTRADATACONST(node).super.scrollY.viewPos;
145
146 /* skip position under the last line */
147 if (line >= EXTRADATACONST(node).super.scrollY.fullSize)
148 return -1;
149
150 return line;
151}
152
153void uiTextNode::onMouseMove (uiNode_t* node, int x, int y)
154{
155 EXTRADATA(node).lineUnderMouse = UI_TextNodeGetLine(node, x, y);
156}
157
160
161 int lineheight = EXTRADATA(node).lineHeight;
162 /* auto compute lineheight */
163 /* we don't overwrite EXTRADATA(node).lineHeight, because "0" is dynamically replaced by font height on draw function */
164 if (lineheight == 0) {
165 /* the font is used */
166 const char* font = UI_GetFontFromNode(node);
167 lineheight = UI_FontGetHeight(font);
168 }
169
170 /* auto compute rows (super.viewSizeY) */
171 if (EXTRADATA(node).super.scrollY.viewSize == 0) {
172 if (node->box.size[1] != 0 && lineheight != 0) {
173 EXTRADATA(node).super.scrollY.viewSize = node->box.size[1] / lineheight;
174 } else {
175 EXTRADATA(node).super.scrollY.viewSize = 1;
176 Com_Printf("UI_TextNodeLoaded: node '%s' has no rows value\n", UI_GetPath(node));
177 }
178 }
179
180 /* auto compute height */
181 if (node->box.size[1] == 0) {
182 node->box.size[1] = EXTRADATA(node).super.scrollY.viewSize * lineheight;
183 }
184
185 /* is text slot exists */
186 if (EXTRADATA(node).dataID >= UI_MAX_DATAID)
187 Com_Error(ERR_DROP, "Error in node %s - max shared data id num exceeded (num: %i, max: %i)", UI_GetPath(node), EXTRADATA(node).dataID, UI_MAX_DATAID);
188
189#ifdef DEBUG
190 if (EXTRADATA(node).super.scrollY.viewSize != (int)(node->box.size[1] / lineheight)) {
191 Com_Printf("UI_TextNodeLoaded: rows value (%i) of node '%s' differs from size (%.0f) and format (%i) values\n",
192 EXTRADATA(node).super.scrollY.viewSize, UI_GetPath(node), node->box.size[1], lineheight);
193 }
194#endif
195
196 if (node->text == nullptr && EXTRADATA(node).dataID == TEXT_NULL)
197 Com_Printf("UI_TextNodeLoaded: 'textid' property of node '%s' is not set\n", UI_GetPath(node));
198}
199
200#define UI_TEXTNODE_BUFFERSIZE 32768
201
210void uiTextNode::drawText (uiNode_t* node, const char* text, const linkedList_t* list, bool noDraw)
211{
212 static char textCopy[UI_TEXTNODE_BUFFERSIZE];
213 char newFont[MAX_VAR];
214 const char* oldFont = nullptr;
215 vec4_t colorHover;
216 vec4_t colorSelectedHover;
217 char* cur, *tab, *end;
218 int fullSizeY;
219 const char* font = UI_GetFontFromNode(node);
220 vec2_t pos;
221 int x, y, width;
222 int viewSizeY;
223
224 UI_GetNodeAbsPos(node, pos);
225
226 if (isSizeChange(node)) {
227 int lineHeight = EXTRADATA(node).lineHeight;
228 if (lineHeight == 0) {
229 const char* font = UI_GetFontFromNode(node);
230 lineHeight = UI_FontGetHeight(font);
231 }
232 viewSizeY = node->box.size[1] / lineHeight;
233 } else {
234 viewSizeY = EXTRADATA(node).super.scrollY.viewSize;
235 }
236
237 /* text box */
238 x = pos[0] + node->padding;
239 y = pos[1] + node->padding;
240 width = node->box.size[0] - node->padding - node->padding;
241
242 if (text) {
243 Q_strncpyz(textCopy, text, sizeof(textCopy));
244 } else if (list) {
245 Q_strncpyz(textCopy, CL_Translate((const char*)list->data), sizeof(textCopy));
246 } else
247 return;
248
249 cur = textCopy;
250
251 /* Hover darkening effect for normal text lines. */
252 VectorScale(node->color, 0.8, colorHover);
253 colorHover[3] = node->color[3];
254
255 /* Hover darkening effect for selected text lines. */
256 VectorScale(node->selectedColor, 0.8, colorSelectedHover);
257 colorSelectedHover[3] = node->selectedColor[3];
258
259 /* fix position of the start of the draw according to the align */
260 switch (node->contentAlign % 3) {
261 case 0: /* left */
262 break;
263 case 1: /* middle */
264 x += width / 2;
265 break;
266 case 2: /* right */
267 x += width;
268 break;
269 }
270
271 R_Color(node->color);
272
273 fullSizeY = 0;
274 do {
275 bool haveTab;
276 int x1; /* variable x position */
277 /* new line starts from node x position */
278 x1 = x;
279 if (oldFont) {
280 font = oldFont;
281 oldFont = nullptr;
282 }
283
284 /* text styles and inline images */
285 if (cur[0] == '^') {
286 switch (toupper(cur[1])) {
287 case 'B':
288 Com_sprintf(newFont, sizeof(newFont), "%s_bold", font);
289 oldFont = font;
290 font = newFont;
291 cur += 2; /* don't print the format string */
292 break;
293 }
294 }
295
296 /* get the position of the next newline - otherwise end will be null */
297 end = strchr(cur, '\n');
298 if (end)
299 /* set the \n to \0 to draw only this part (before the \n) with our font renderer */
300 /* let end point to the next char after the \n (or \0 now) */
301 *end++ = '\0';
302
303 /* highlighting */
304 if (fullSizeY == EXTRADATA(node).textLineSelected && EXTRADATA(node).textLineSelected >= 0) {
305 /* Draw current line in "selected" color (if the linenumber is stored). */
306 R_Color(node->selectedColor);
307 } else {
308 R_Color(node->color);
309 }
310
311 if (node->state && EXTRADATA(node).mousefx && fullSizeY == EXTRADATA(node).lineUnderMouse) {
312 /* Highlight line if mousefx is true. */
314 if (fullSizeY == EXTRADATA(node).textLineSelected && EXTRADATA(node).textLineSelected >= 0) {
315 R_Color(colorSelectedHover);
316 } else {
317 R_Color(colorHover);
318 }
319 }
320
321 /* tabulation, we assume all the tabs fit on a single line */
322 haveTab = strchr(cur, '\t') != nullptr;
323 if (haveTab) {
324 while (cur && *cur) {
325 int tabwidth;
326
327 tab = strchr(cur, '\t');
328
329 /* use tab stop as given via property definition
330 * or use 1/3 of the node size (width) */
331 if (!EXTRADATA(node).tabWidth)
332 tabwidth = width / 3;
333 else
334 tabwidth = EXTRADATA(node).tabWidth;
335
336 if (tab) {
337 int numtabs = strspn(tab, "\t");
338 tabwidth *= numtabs;
339 while (*tab == '\t')
340 *tab++ = '\0';
341 } else {
342 /* maximize width for the last element */
343 tabwidth = width - (x1 - x);
344 if (tabwidth < 0)
345 tabwidth = 0;
346 }
347
348 /* minimize width for element outside node */
349 if ((x1 - x) + tabwidth > width)
350 tabwidth = width - (x1 - x);
351
352 /* make sure it is positive */
353 if (tabwidth < 0)
354 tabwidth = 0;
355
356 if (tabwidth != 0)
357 UI_DrawString(font, (align_t)node->contentAlign, x1, y, x1, tabwidth - 1, EXTRADATA(node).lineHeight, cur, viewSizeY, EXTRADATA(node).super.scrollY.viewPos, &fullSizeY, false, LONGLINES_PRETTYCHOP);
358
359 /* next */
360 x1 += tabwidth;
361 cur = tab;
362 }
363 fullSizeY++;
364 }
365
366 /*Com_Printf("until newline - lines: %i\n", lines);*/
367 /* the conditional expression at the end is a hack to draw "/n/n" as a blank line */
368 /* prevent line from being drawn if there is nothing that should be drawn after it */
369 if (cur && (cur[0] || end || list)) {
370 /* is it a white line? */
371 if (!cur) {
372 fullSizeY++;
373 } else {
374 if (noDraw) {
375 int lines = 0;
376 R_FontTextSize(font, cur, width, (longlines_t)EXTRADATA(node).longlines, nullptr, nullptr, &lines, nullptr);
377 fullSizeY += lines;
378 } else
379 UI_DrawString(font, (align_t)node->contentAlign, x1, y, x, width, EXTRADATA(node).lineHeight, cur, viewSizeY, EXTRADATA(node).super.scrollY.viewPos, &fullSizeY, true, (longlines_t)EXTRADATA(node).longlines);
380 }
381 }
382
383 if (EXTRADATA(node).mousefx)
384 R_Color(node->color); /* restore original color */
385
386 /* now set cur to the next char after the \n (see above) */
387 cur = end;
388 if (!cur && list) {
389 list = list->next;
390 if (list) {
391 Q_strncpyz(textCopy, CL_Translate((const char*)list->data), sizeof(textCopy));
392 cur = textCopy;
393 }
394 }
395 } while (cur);
396
397 /* update scroll status */
398 setScrollY(node, -1, viewSizeY, fullSizeY);
399
400 R_Color(nullptr);
401}
402
404{
405 const uiSharedData_t* shared;
406
407 if (EXTRADATA(node).dataID == TEXT_NULL && node->text != nullptr)
408 return;
409
410 shared = &ui_global.sharedData[EXTRADATA(node).dataID];
411
412 switch (shared->type) {
413 case UI_SHARED_TEXT:
414 {
415 const char* t = CL_Translate(shared->data.text);
416 drawText(node, t, nullptr, true);
417 }
418 break;
420 drawText(node, nullptr, shared->data.linkedListText, true);
421 break;
422 default:
423 break;
424 }
425
426 EXTRADATA(node).versionId = shared->versionId;
427}
428
433{
434 const uiSharedData_t* shared;
435
436 if (EXTRADATA(node).dataID == TEXT_NULL && node->text != nullptr) {
437 const char* t = CL_Translate(UI_GetReferenceString(node, node->text));
438 drawText(node, t, nullptr, false);
439 return;
440 }
441
442 shared = &ui_global.sharedData[EXTRADATA(node).dataID];
443
444 switch (shared->type) {
445 case UI_SHARED_TEXT:
446 {
447 const char* t = CL_Translate(shared->data.text);
448 drawText(node, t, nullptr, false);
449 break;
450 }
452 drawText(node, nullptr, shared->data.linkedListText, false);
453 break;
454 default:
455 break;
456 }
457
458 EXTRADATA(node).versionId = shared->versionId;
459}
460
465void uiTextNode::onLeftClick (uiNode_t* node, int x, int y)
466{
467 int line = UI_TextNodeGetLine(node, x, y);
468
469 if (line < 0 || line >= EXTRADATA(node).super.scrollY.fullSize)
470 return;
471
472 UI_TextNodeSelectLine(node, line);
473
474 if (node->onClick) {
475 UI_ExecuteEventActions(node, node->onClick);
476 }
477 if (node->lua_onClick != LUA_NOREF) {
478 UI_ExecuteLuaEventScript_XY(node, node->lua_onClick, x, y);
479 }
480}
481
486void uiTextNode::onRightClick (uiNode_t* node, int x, int y)
487{
488 int line = UI_TextNodeGetLine(node, x, y);
489
490 if (line < 0 || line >= EXTRADATA(node).super.scrollY.fullSize)
491 return;
492
493 UI_TextNodeSelectLine(node, line);
494
495 if (node->onRightClick)
497}
498
501bool uiTextNode::onScroll (uiNode_t* node, int deltaX, int deltaY)
502{
503 bool updated;
504 bool down = deltaY > 0;
505 if (deltaY == 0)
506 return false;
507 updated = scrollY(node, (down ? 1 : -1));
508
509 /* @todo use super behaviour */
510 if (node->onWheelUp && !down) {
512 updated = true;
513 }
514 if (node->onWheelDown && down) {
516 updated = true;
517 }
518 if (node->onWheel) {
519 UI_ExecuteEventActions(node, node->onWheel);
520 updated = true;
521 }
522 return updated;
523}
524
526{
527 EXTRADATA(node).textLineSelected = -1;
528 EXTRADATA(node).textSelected = "";
529 Vector4Set(node->selectedColor, 1.0, 1.0, 1.0, 1.0);
530 Vector4Set(node->color, 1.0, 1.0, 1.0, 1.0);
531}
532
534{
535 /* code moved to doLayout since it was used to precompute layout */
536}
537
542void uiTextNode::onMouseDown (uiNode_t* node, int x, int y, int button)
543{
544 if (button == K_MOUSE1 && !UI_GetMouseCapture() &&
545 EXTRADATA(node).super.scrollY.fullSize > EXTRADATA(node).super.scrollY.viewSize) {
546 UI_SetMouseCapture(node);
547 mouseScrollX = x;
548 mouseScrollY = y;
549 }
550}
551
552void uiTextNode::onMouseUp (uiNode_t* node, int x, int y, int button)
553{
554 if (UI_GetMouseCapture() == node) /* More checks can never hurt */
556}
557
559{
560 const int lineHeight = getCellHeight(node);
561 const int deltaY = (mouseScrollY - y) / lineHeight;
562 /* We're doing only vertical scroll, that's enough for the most instances */
563 if (abs(mouseScrollY - y) >= lineHeight) {
564 scrollY(node, deltaY);
565 /* @todo not accurate */
566 mouseScrollX = x;
567 mouseScrollY = y;
568 }
569 onMouseMove(node, x, y);
570}
571
578{
579 int lineHeight = EXTRADATA(node).lineHeight;
580 if (lineHeight == 0)
581 lineHeight = UI_FontGetHeight(UI_GetFontFromNode(node));
582 return lineHeight;
583}
584
586{
587 behaviour->name = "text";
588 behaviour->extends = "abstractscrollable";
589 behaviour->manager = UINodePtr(new uiTextNode());
590 behaviour->extraDataSize = sizeof(EXTRADATA_TYPE);
591 behaviour->lua_SWIG_typeinfo = UI_SWIG_TypeQuery("uiTextNode_t *");
592
593 /* Current selected line */
594 UI_RegisterExtradataNodeProperty(behaviour, "lineselected", V_INT, textExtraData_t, textLineSelected);
595
596 /* Text of the current selected line */
597 UI_RegisterExtradataNodeProperty(behaviour, "textselected", V_CVAR_OR_STRING, textExtraData_t, textSelected);
598
599 /* One of the list TEXT_* @sa ui_data.h for an up-to-date list.
600 * Display a shared content registered by the client code.
601 */
602 UI_RegisterExtradataNodeProperty(behaviour, "dataid", V_UI_DATAID, textExtraData_t, dataID);
603 /* Size between two lines. Default value is 0, in this case it use a line height according to the font size. */
604 UI_RegisterExtradataNodeProperty(behaviour, "lineheight", V_INT, textExtraData_t, lineHeight);
605 /* Bigger size of the width replacing a tab character. */
606 UI_RegisterExtradataNodeProperty(behaviour, "tabwidth", V_INT, textExtraData_t, tabWidth);
607 /* What to do with text lines longer than node width. Default is to wordwrap them to make multiple lines.
608 * It can be LONGLINES_WRAP, LONGLINES_CHOP, LONGLINES_PRETTYCHOP
609 */
610 UI_RegisterExtradataNodeProperty(behaviour, "longlines", V_INT, textExtraData_t, longlines);
611
612 /* Number of visible line we can display into the node height.
613 * Currently, it translate the scrollable property <code>viewSize</code>
614 * @todo For a smooth scroll we should split that
615 */
616 UI_RegisterExtradataNodeProperty(behaviour, "rows", V_INT, textExtraData_t, super.scrollY.viewSize);
617 /* Number of lines contained into the node.
618 * Currently, it translate the scrollable property <code>fullSize</code>
619 * @todo For a smooth scroll we should split that
620 */
621 UI_RegisterExtradataNodeProperty(behaviour, "lines", V_INT, textExtraData_t, super.scrollY.fullSize);
622
626 UI_RegisterExtradataNodeProperty(behaviour, "mousefx", V_BOOL, textExtraData_t, mousefx);
627
628 Com_RegisterConstInt("LONGLINES_WRAP", LONGLINES_WRAP);
629 Com_RegisterConstInt("LONGLINES_CHOP", LONGLINES_CHOP);
630 Com_RegisterConstInt("LONGLINES_PRETTYCHOP", LONGLINES_PRETTYCHOP);
631}
int down
Definition cl_input.cpp:66
@ K_MOUSE1
Definition cl_keys.h:46
const char * CL_Translate(const char *t)
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,...
Definition r_font.cpp:522
longlines_t
@ LONGLINES_WRAP
@ LONGLINES_CHOP
@ LONGLINES_PRETTYCHOP
void R_Color(const vec4_t rgba)
Change the color to given value.
Definition r_state.cpp:1011
PointerType get() const
Definition sharedptr.h:197
bool scrollY(uiNode_t *node, int offset)
Scroll the Y scroll with a relative position, and call event if need.
bool setScrollY(uiNode_t *node, int viewPos, int viewSize, int fullSize)
Set the Y scroll to a position, and call event if need.
bool isSizeChange(uiNode_t *node)
return true if the node size change and update the cache
virtual void doLayout(uiNode_t *node)
Call to update the node layout. This common code revalidates the node tree.
void onMouseMove(uiNode_t *node, int x, int y) override
void onCapturedMouseMove(uiNode_t *node, int x, int y) override
void doLayout(uiNode_t *node) override
Call to update the node layout. This common code revalidates the node tree.
void validateCache(uiNode_t *node)
bool onScroll(uiNode_t *node, int deltaX, int deltaY) override
void drawText(uiNode_t *node, const char *text, const linkedList_t *list, bool noDraw)
Handles line breaks and drawing for shared data id.
void onRightClick(uiNode_t *node, int x, int y) override
Calls the script command for a text node that is clickable via right mouse button.
int getCellHeight(uiNode_t *node) override
Return size of the cell, which is the size (in virtual "pixel") which represent 1 in the scroll value...
void draw(uiNode_t *node) override
Draw a text node.
void onLoading(uiNode_t *node) override
void onLeftClick(uiNode_t *node, int x, int y) override
Calls the script command for a text node that is clickable.
virtual void updateCache(uiNode_t *node)
void onMouseDown(uiNode_t *node, int x, int y, int button) override
Track mouse down/up events to implement drag&drop-like scrolling, for touchscreen devices.
void onMouseUp(uiNode_t *node, int x, int y, int button) override
void onLoaded(uiNode_t *node) override
Primary header for client.
const char * Cmd_Argv(int arg)
Returns a given argument.
Definition cmd.cpp:516
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
Definition common.cpp:440
void Com_Error(int code, const char *fmt,...)
Definition common.cpp:459
void Com_Printf(const char *const fmt,...)
Definition common.cpp:428
#define ERR_DROP
Definition common.h:211
#define DEBUG_CLIENT
Definition defines.h:59
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
Shared parsing functions.
QGL_EXTERN int GLboolean GLfloat * v
Definition r_gl.h:120
void Com_RegisterConstInt(const char *name, int value)
Register mappings between script strings and enum values for values of the type V_INT.
Definition scripts.cpp:198
align_t
We need this here for checking the boundaries from script values.
Definition scripts.h:89
@ V_BOOL
Definition scripts.h:50
@ V_INT
Definition scripts.h:52
Header for lua script functions.
#define MAX_VAR
Definition shared.h:36
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
Definition shared.cpp:457
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
Definition shared.cpp:494
void * data
Definition list.h:31
linkedList_t * next
Definition list.h:32
node behaviour, how a node work
const char * name
void * lua_SWIG_typeinfo
UINodePtr manager
const char * extends
intptr_t extraDataSize
vec2_t size
Definition ui_nodes.h:52
Atomic structure used to define most of the UI.
Definition ui_nodes.h:80
struct uiAction_s * onWheelDown
Definition ui_nodes.h:142
char * text
Definition ui_nodes.h:121
int contentAlign
Definition ui_nodes.h:120
vec4_t color
Definition ui_nodes.h:127
uiBehaviour_t * behaviour
Definition ui_nodes.h:83
struct uiAction_s * onWheel
Definition ui_nodes.h:138
LUA_EVENT lua_onChange
Definition ui_nodes.h:162
struct uiAction_s * onChange
Definition ui_nodes.h:143
vec4_t selectedColor
Definition ui_nodes.h:128
LUA_EVENT lua_onClick
Definition ui_nodes.h:148
uiBox_t box
Definition ui_nodes.h:96
int padding
Definition ui_nodes.h:109
struct uiAction_s * onClick
Definition ui_nodes.h:135
struct uiAction_s * onRightClick
Definition ui_nodes.h:136
struct uiAction_s * onWheelUp
Definition ui_nodes.h:141
bool state
Definition ui_nodes.h:106
union uiSharedData_t::@061052176262211162172023345235067125273303251247 data
uiSharedType_t type
Definition ui_data.h:45
linkedList_t * linkedListText
Holds a linked list for displaying in the UI.
Definition ui_data.h:50
const char * text
Holds static array of characters to display.
Definition ui_data.h:48
vec_t vec4_t[4]
Definition ufotypes.h:40
vec_t vec2_t[2]
Definition ufotypes.h:38
void UI_ExecuteEventActions(uiNode_t *source, const uiAction_t *firstAction)
#define UI_RegisterExtradataNodeProperty(BEHAVIOUR, NAME, TYPE, EXTRADATATYPE, ATTRIBUTE)
Initialize a property from extradata of node.
const char * UI_GetTextFromList(int textId, int line)
Definition ui_data.cpp:151
int UI_GetDataVersion(int textId)
Definition ui_data.cpp:159
@ UI_SHARED_TEXT
Definition ui_data.h:39
@ UI_SHARED_LINKEDLISTTEXT
Definition ui_data.h:40
@ UI_MAX_DATAID
Definition ui_dataids.h:87
@ TEXT_NULL
Definition ui_dataids.h:29
int UI_FontGetHeight(const char *fontID)
Definition ui_font.cpp:166
const char * UI_GetFontFromNode(const uiNode_t *const node)
Return the font for a specific node or default font.
Definition ui_font.cpp:145
void UI_SetMouseCapture(uiNode_t *node)
Captured the mouse into a node.
Definition ui_input.cpp:516
uiNode_t * UI_GetMouseCapture(void)
Return the captured node.
Definition ui_input.cpp:508
void UI_MouseRelease(void)
Release the captured node.
Definition ui_input.cpp:526
Internal data use by the UI package.
uiGlobal_t ui_global
Definition ui_main.cpp:38
bool UI_ExecuteLuaEventScript(uiNode_t *node, LUA_EVENT event)
Executes a lua event handler.
Definition ui_lua.cpp:71
bool UI_ExecuteLuaEventScript_XY(uiNode_t *node, LUA_EVENT event, int x, int y)
Executes a lua event handler with (x,y) argument.
Definition ui_lua.cpp:143
Basic lua initialization for the ui.
void * UI_SWIG_TypeQuery(const char *name)
This function queries the SWIG type table for a type information structure. It is used in combination...
bool UI_NodeInstanceOf(const uiNode_t *node, const char *behaviourName)
Check the node inheritance.
Definition ui_node.cpp:453
void UI_NodeAbsoluteToRelativePos(const uiNode_t *node, int *x, int *y)
Update an absolute position to a relative one.
Definition ui_node.cpp:604
void UI_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
Definition ui_node.cpp:526
SharedPtr< uiNode > UINodePtr
#define EXTRADATA_TYPE
#define EXTRADATA(node)
static int mouseScrollY
static int mouseScrollX
void UI_TextScrollEnd(const char *nodePath)
Scroll to the bottom.
#define EXTRADATA(node)
void UI_TextNodeSelectLine(uiNode_t *node, int num)
Change the selected line.
static int UI_TextNodeGetLine(const uiNode_t *node, int x, int y)
Get the line number under an absolute position.
const char * UI_TextNodeGetSelectedText(uiNode_t *node, int num)
void UI_RegisterTextNode(uiBehaviour_t *behaviour)
#define EXTRADATACONST(node)
#define UI_TEXTNODE_BUFFERSIZE
void UI_TextNodeSelectLine(uiNode_t *node, int num)
Change the selected line.
uiNode_t * UI_GetNodeByPath(const char *path)
Return a node by a path name (names with dot separation) It is a simplification facade over UI_ReadNo...
Definition ui_nodes.cpp:313
const char * UI_GetPath(const uiNode_t *node)
Return a path from a window to a node.
Definition ui_nodes.cpp:174
const char * UI_GetReferenceString(const uiNode_t *const node, const char *ref)
#define V_UI_DATAID
Definition ui_parse.h:58
#define V_CVAR_OR_STRING
Definition ui_parse.h:69
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)
#define Vector4Set(v, r, g, b, a)
Definition vector.h:62
#define VectorScale(in, scale, out)
Definition vector.h:79