27 #include "../ui_main.h"
28 #include "../ui_internal.h"
29 #include "../ui_font.h"
30 #include "../ui_actions.h"
31 #include "../ui_parse.h"
32 #include "../ui_render.h"
33 #include "../ui_lua.h"
38 #include "../../client.h"
39 #include "../../cl_language.h"
40 #include "../../../shared/parse.h"
42 #include "../../../common/scripts_lua.h"
44 #define EXTRADATA_TYPE text2ExtraData_t
45 #define EXTRADATA(node) UI_EXTRADATA(node, EXTRADATA_TYPE)
46 #define EXTRADATACONST(node) UI_EXTRADATACONST(node, EXTRADATA_TYPE)
51 int bufferSize = 1024;
56 if (node->
text !=
nullptr)
61 switch (shared->
type) {
75 while (data[0] !=
'\0') {
76 const char* next = strchr(data,
'\n');
79 lineSize = strlen(data);
81 lineSize = next -
data;
83 if (lineSize + 1 > bufferSize) {
84 bufferSize = lineSize + 1;
113 if (lineHeight == 0) {
124 line = (
int) (y / lineHeight) +
EXTRADATACONST(node).super.super.scrollY.viewPos;
149 const char* oldFont =
nullptr;
159 int lineHeight =
EXTRADATA(node).super.lineHeight;
160 if (lineHeight == 0) {
164 viewSizeY = node->
box.
size[1] / lineHeight;
166 viewSizeY =
EXTRADATA(node).super.super.scrollY.viewSize;
190 const char* cur = (
const char*)list->
data;
202 switch (toupper(cur[1])) {
204 Com_sprintf(newFont,
sizeof(newFont),
"%s_bold", font);
221 UI_DrawString(font, (
align_t)node->
contentAlign, x1, y, x, width,
EXTRADATA(node).super.lineHeight, cur, viewSizeY,
EXTRADATA(node).super.super.scrollY.viewPos, &fullSizeY,
true, (
longlines_t)
EXTRADATA(node).super.longlines);
271 switch (shared->
type) {
293 if (line < 0 || line >=
EXTRADATA(node).super.super.scrollY.fullSize)
314 if (line < 0 || line >=
EXTRADATA(node).super.super.scrollY.fullSize)
325 EXTRADATA(node).super.textLineSelected = -1;
333 int lineheight =
EXTRADATA(node).super.lineHeight;
336 if (lineheight == 0) {
343 if (
EXTRADATA(node).super.super.scrollY.viewSize == 0) {
344 if (node->
box.
size[1] != 0 && lineheight != 0) {
345 EXTRADATA(node).super.super.scrollY.viewSize = node->
box.
size[1] / lineheight;
347 EXTRADATA(node).super.super.scrollY.viewSize = 1;
354 node->
box.
size[1] =
EXTRADATA(node).super.super.scrollY.viewSize * lineheight;
362 if (
EXTRADATA(node).super.super.scrollY.viewSize != (
int)(node->
box.
size[1] / lineheight)) {
363 Com_Printf(
"UI_TextNodeLoaded: rows value (%i) of node '%s' differs from size (%.0f) and format (%i) values\n",
374 behaviour->
name =
"text2";
#define Mem_AllocTypeN(type, n)
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.
void draw(uiNode_t *node) override
Draw a text node.
bool UI_NodeInstanceOf(const uiNode_t *node, const char *behaviourName)
Check the node inheritance.
void onLoaded(uiNode_t *node) override
uiSharedData_t sharedData[UI_MAX_DATAID]
Holds shared data.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
static void UI_TextNodeGenerateLineSplit(uiNode_t *node)
void onLeftClick(uiNode_t *node, int x, int y) override
Calls the script command for a text node that is clickable.
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
void Com_Printf(const char *const fmt,...)
void LIST_Delete(linkedList_t **list)
struct uiAction_s * onClick
void R_Color(const vec4_t rgba)
Change the color to given value.
void Com_Error(int code, const char *fmt,...)
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
const char * UI_GetText(int textId)
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.
align_t
We need this here for checking the boundaries from script values.
void LIST_AddString(linkedList_t **listDest, const char *data)
Adds an string to a new or to an already existing linked list. The string is copied here...
linkedList_t * linkedListText
Holds a linked list for displaying in the UI.
#define Vector4Set(v, r, g, b, a)
SharedPtr< uiNode > UINodePtr
void updateCache(uiNode_t *node) override
const char * UI_GetPath(const uiNode_t *node)
Return a path from a window to a node.
static int UI_TextNodeGetLine(const uiNode_t *node, int x, int y)
Get the line number under an absolute position.
void UI_ExecuteEventActions(uiNode_t *source, const uiAction_t *firstAction)
bool UI_ExecuteLuaEventScript_XY(uiNode_t *node, LUA_EVENT event, int x, int y)
Executes a lua event handler with (x,y) argument.
void validateCache(uiNode_t *node)
const char * UI_GetReferenceString(const uiNode_t *const node, const char *ref)
Atomic structure used to define most of 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...
void UI_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
struct uiAction_s * onRightClick
void drawText(uiNode_t *node, const linkedList_t *list, bool noDraw)
Handles linked list of text. Each element of the list must be a line of text without line break...
void onMouseMove(uiNode_t *node, int x, int y) override
union uiSharedData_s::@18 data
const char * CL_Translate(const char *t)
const char * UI_GetFontFromNode(const uiNode_t *const node)
Return the font for a specific node or default font.
void UI_NodeAbsoluteToRelativePos(const uiNode_t *node, int *x, int *y)
Update an absolute position to a relative one.
node behaviour, how a node work
void onLoading(uiNode_t *node) override
int UI_FontGetHeight(const char *fontID)
void UI_RegisterText2Node(uiBehaviour_t *behaviour)
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)
GLsizei const GLvoid * data
#define EXTRADATACONST(node)
void UI_TextNodeSelectLine(uiNode_t *node, int num)
Change the selected line.