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"
38 #include "../../client.h"
39 #include "../../cl_language.h"
40 #include "../../../shared/parse.h"
42 #include "../../../common/scripts_lua.h"
44 #define EXTRADATA_TYPE textExtraData_t
45 #define EXTRADATA(node) UI_EXTRADATA(node, EXTRADATA_TYPE)
46 #define EXTRADATACONST(node) UI_EXTRADATACONST(node, EXTRADATA_TYPE)
77 if (
EXTRADATA(node).textLineSelected == num)
109 if (
EXTRADATA(node).super.scrollY.fullSize >
EXTRADATA(node).super.scrollY.viewSize) {
111 if (
EXTRADATA(node).super.onViewChange) {
114 else if (
EXTRADATA(node).super.lua_onViewChange != LUA_NOREF) {
133 if (lineHeight == 0) {
161 int lineheight =
EXTRADATA(node).lineHeight;
164 if (lineheight == 0) {
171 if (
EXTRADATA(node).super.scrollY.viewSize == 0) {
172 if (node->
box.
size[1] != 0 && lineheight != 0) {
175 EXTRADATA(node).super.scrollY.viewSize = 1;
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",
200 #define UI_TEXTNODE_BUFFERSIZE 32768
214 const char* oldFont =
nullptr;
216 vec4_t colorSelectedHover;
217 char* cur, *tab, *end;
227 int lineHeight =
EXTRADATA(node).lineHeight;
228 if (lineHeight == 0) {
232 viewSizeY = node->
box.
size[1] / lineHeight;
234 viewSizeY =
EXTRADATA(node).super.scrollY.viewSize;
253 colorHover[3] = node->
color[3];
286 switch (toupper(cur[1])) {
288 Com_sprintf(newFont,
sizeof(newFont),
"%s_bold", font);
297 end = strchr(cur,
'\n');
304 if (fullSizeY ==
EXTRADATA(node).textLineSelected &&
EXTRADATA(node).textLineSelected >= 0) {
314 if (fullSizeY ==
EXTRADATA(node).textLineSelected &&
EXTRADATA(node).textLineSelected >= 0) {
322 haveTab = strchr(cur,
'\t') !=
nullptr;
324 while (cur && *cur) {
327 tab = strchr(cur,
'\t');
332 tabwidth = width / 3;
337 int numtabs = strspn(tab,
"\t");
343 tabwidth = width - (x1 - x);
349 if ((x1 - x) + tabwidth > width)
350 tabwidth = width - (x1 - x);
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);
369 if (cur && (cur[0] || end || list)) {
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);
412 switch (shared->
type) {
444 switch (shared->
type) {
469 if (line < 0 || line >=
EXTRADATA(node).super.scrollY.fullSize)
490 if (line < 0 || line >=
EXTRADATA(node).super.scrollY.fullSize)
504 bool down = deltaY > 0;
507 updated =
scrollY(node, (down ? 1 : -1));
579 int lineHeight =
EXTRADATA(node).lineHeight;
587 behaviour->
name =
"text";
588 behaviour->
extends =
"abstractscrollable";
virtual void updateCache(uiNode_t *node)
struct uiAction_s * onWheelDown
void doLayout(uiNode_t *node) override
Call to update the node layout. This common code revalidates the node tree.
const char * Cmd_Argv(int arg)
Returns a given argument.
void onMouseMove(uiNode_t *node, int x, int y) override
bool UI_NodeInstanceOf(const uiNode_t *node, const char *behaviourName)
Check the node inheritance.
struct uiAction_s * onChange
void onMouseUp(uiNode_t *node, int x, int y, int button) override
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...
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
uiBehaviour_t * behaviour
void onLoading(uiNode_t *node) override
bool UI_ExecuteLuaEventScript(uiNode_t *node, LUA_EVENT event)
Executes a lua event handler.
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.
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
void Com_Printf(const char *const fmt,...)
struct uiAction_s * onClick
#define VectorScale(in, scale, out)
int UI_GetDataVersion(int textId)
#define UI_RegisterExtradataNodeProperty(BEHAVIOUR, NAME, TYPE, EXTRADATATYPE, ATTRIBUTE)
Initialize a property from extradata of node.
void R_Color(const vec4_t rgba)
Change the color to given value.
void Com_Error(int code, const char *fmt,...)
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 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.
align_t
We need this here for checking the boundaries from script values.
linkedList_t * linkedListText
Holds a linked list for displaying in the UI.
#define Vector4Set(v, r, g, b, a)
struct uiAction_s * onWheelUp
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 onLeftClick(uiNode_t *node, int x, int y) override
Calls the script command for a text node that is clickable.
const char * UI_GetTextFromList(int textId, int line)
SharedPtr< uiNode > UINodePtr
void UI_RegisterTextNode(uiBehaviour_t *behaviour)
const char * UI_GetPath(const uiNode_t *node)
Return a path from a window to a node.
const char * UI_TextNodeGetSelectedText(uiNode_t *node, int num)
void onCapturedMouseMove(uiNode_t *node, int x, int y) override
void UI_TextScrollEnd(const char *nodePath)
Scroll to the bottom.
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 Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
const char * UI_GetReferenceString(const uiNode_t *const node, const char *ref)
void validateCache(uiNode_t *node)
void drawText(uiNode_t *node, const char *text, const linkedList_t *list, bool noDraw)
Handles line breaks and drawing for shared data id.
#define EXTRADATACONST(node)
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 Com_RegisterConstInt(const char *name, int value)
Register mappings between script strings and enum values for values of the type V_INT.
void UI_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
struct uiAction_s * onRightClick
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
struct uiAction_s * onWheel
void draw(uiNode_t *node) override
Draw a text node.
int UI_FontGetHeight(const char *fontID)
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 UI_TEXTNODE_BUFFERSIZE
bool onScroll(uiNode_t *node, int deltaX, int deltaY) override
void onLoaded(uiNode_t *node) override
virtual void doLayout(uiNode_t *node)
Call to update the node layout. This common code revalidates the node tree.
QGL_EXTERN int GLboolean GLfloat * v
static int UI_TextNodeGetLine(const uiNode_t *node, int x, int y)
Get the line number under an absolute position.
void UI_TextNodeSelectLine(uiNode_t *node, int num)
Change the selected line.
const char * text
Holds static array of characters to display.