UFO: Alien Invasion
Loading...
Searching...
No Matches
ui_expression.cpp
Go to the documentation of this file.
1
4
5/*
6Copyright (C) 2002-2025 UFO: Alien Invasion.
7
8This program is free software; you can redistribute it and/or
9modify it under the terms of the GNU General Public License
10as published by the Free Software Foundation; either version 2
11of the License, or (at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23*/
24
25#include "ui_expression.h"
26#include "ui_main.h"
27#include "ui_node.h"
28#include "ui_internal.h"
29#include "ui_parse.h"
30#include "ui_actions.h"
32#include "../../shared/parse.h"
33#include "../../shared/shared.h"
34
42uiNode_t* UI_GetNodeFromExpression (uiAction_t* expression, const uiCallContext_t* context, const value_t** property)
43{
44 if (property != nullptr)
45 *property = nullptr;
46
47 switch (expression->type & EA_HIGHT_MASK) {
48 case EA_VALUE:
49 switch (expression->type) {
50 case EA_VALUE_VAR:
51 {
52 uiValue_t* variable = UI_GetVariable(context, expression->d.terminal.d1.integer);
53 switch (variable->type) {
54 case EA_VALUE_NODE:
55 return variable->value.node;
56 default:
57 break;
58 }
59 }
60 break;
61
64 {
65 uiNode_t* node;
66 const value_t* propertyTmp;
67 const char* path = expression->d.terminal.d1.constString;
68 if (expression->type == EA_VALUE_PATHNODE_WITHINJECTION)
69 path = UI_GenInjectedString(path, false, context);
70
71 UI_ReadNodePath(path, context->source, context->tagNode, &node, &propertyTmp);
72 if (!node) {
73 Com_Printf("UI_GetNodeFromExpression: Node '%s' wasn't found; nullptr returned\n", path);
74 return nullptr;
75 }
76 if (propertyTmp != nullptr)
77 Com_Printf("UI_GetNodeFromExpression: No property expected, but path '%s' contain a property. Property ignored.\n", path);
78
79 return node;
80 }
81
84 {
85 uiNode_t* node;
86 const value_t* propertyTmp;
87 const char* path = expression->d.terminal.d1.constString;
89 path = UI_GenInjectedString(path, false, context);
90
91 UI_ReadNodePath(path, context->source, context->tagNode, &node, &propertyTmp);
92 if (!node) {
93 Com_Printf("UI_GetNodeFromExpression: Node '%s' wasn't found; nullptr returned\n", path);
94 return nullptr;
95 }
96 if (property == nullptr) {
97 if (propertyTmp != nullptr)
98 Com_Printf("UI_GetNodeFromExpression: No property expected, but path '%s' contain a property. Property ignored.\n", path);
99 } else {
100 *property = propertyTmp;
101 }
102
103 return node;
104 }
105
106 case EA_VALUE_THIS:
107 return context->source;
108
109 case EA_VALUE_PARENT:
110 return context->source->parent;
111
112 case EA_VALUE_WINDOW:
113 return context->source->root;
114
115 case EA_VALUE_CHILD:
116 return context->tagNode;
117
118 default:
119 break;
120 }
121 break;
123 switch (expression->type) {
125 {
126 uiNode_t* relativeTo = UI_GetNodeFromExpression(expression->d.nonTerminal.left, context, nullptr);
127 uiNode_t* node;
128 const value_t* propertyTmp;
129 const char* path = expression->d.terminal.d2.constString;
130 UI_ReadNodePath(path, relativeTo, context->tagNode, &node, &propertyTmp);
131 if (!node) {
132 Com_Printf("UI_GetNodeFromExpression: Path '%s' from node '%s' found no node; nullptr returned\n", path, UI_GetPath(relativeTo));
133 return nullptr;
134 }
135 if (property == nullptr) {
136 if (propertyTmp != nullptr)
137 Com_Printf("UI_GetNodeFromExpression: No property expected, but path '%s' from node '%s' found no node; nullptr returned\n", path, UI_GetPath(relativeTo));
138 } else {
139 *property = propertyTmp;
140 }
141 return node;
142 }
143 default:
144 break;
145 }
146 break;
147 default:
148 break;
149 }
150
151 return nullptr;
152}
153
154
158float UI_GetFloatFromExpression (uiAction_t* expression, const uiCallContext_t* context)
159{
160 switch (expression->type & EA_HIGHT_MASK) {
161 case EA_VALUE:
162 switch (expression->type) {
163 case EA_VALUE_VAR:
164 {
165 uiValue_t* variable = UI_GetVariable(context, expression->d.terminal.d1.integer);
166 switch (variable->type) {
167 case EA_VALUE_STRING:
168 if (variable->value.string == nullptr) {
169 Com_Printf("UI_GetFloatFromExpression: String variable not initialized. '0' returned");
170 return 0;
171 }
172 return atof(variable->value.string);
173 case EA_VALUE_FLOAT:
174 return variable->value.number;
175 case EA_VALUE_CVAR:
176 {
177 cvar_t* cvar = variable->value.cvar;
178 if (cvar == nullptr) {
179 Com_Printf("UI_GetFloatFromExpression: Cvar variable not initialized. '0' returned");
180 return 0;
181 }
182 return cvar->value;
183 }
184 default:
185 Com_Printf("UI_GetFloatFromExpression: Unsupported variable type: %i. '0' returned", variable->type);
186 return 0;
187 }
188 }
189 case EA_VALUE_STRING:
191 {
192 const char* string = expression->d.terminal.d1.constString;
193 if (expression->type == EA_VALUE_STRING_WITHINJECTION)
194 string = UI_GenInjectedString(string, false, context);
195 return atof(string);
196 }
197 case EA_VALUE_FLOAT:
198 return expression->d.terminal.d1.number;
201 {
202 cvar_t* cvar = nullptr;
203 const char* cvarName = expression->d.terminal.d1.constString;
204 if (expression->type == EA_VALUE_CVARNAME_WITHINJECTION)
205 cvarName = UI_GenInjectedString(cvarName, false, context);
206 cvar = Cvar_Get(cvarName, "", 0, "Cvar from UI script expression");
207 return cvar->value;
208 }
211 {
212 uiNode_t* node;
213 const value_t* property;
214 node = UI_GetNodeFromExpression(expression, context, &property);
215 if (!node) {
216 Com_Printf("UI_GetFloatFromParam: Node wasn't found; '0'\n");
217 return 0;
218 }
219 if (!property) {
220 Com_Printf("UI_GetFloatFromParam: Property wasn't found; '0' returned\n");
221 return 0;
222 }
223 return UI_GetFloatFromNodeProperty(node, property);
224 }
225 case EA_VALUE_PARAM:
226 {
227 const int paramId = expression->d.terminal.d1.integer;
228 const char* string = UI_GetParam(context, paramId);
229 if (string[0] == '\0') {
230 Com_Printf("UI_GetFloatFromParam: Param '%i' is out of range, or empty; '0' returned\n", paramId);
231 return 0;
232 }
233 return atof(string);
234 }
236 return UI_GetParamNumber(context);
237 }
238 break;
239
241 {
242 const float value1 = UI_GetFloatFromExpression(expression->d.nonTerminal.left, context);
243 const float value2 = UI_GetFloatFromExpression(expression->d.nonTerminal.right, context);
244
245 switch (expression->type) {
246 case EA_OPERATOR_ADD:
247 return value1 + value2;
248 case EA_OPERATOR_SUB:
249 return value1 - value2;
250 case EA_OPERATOR_MUL:
251 return value1 * value2;
252 case EA_OPERATOR_DIV:
253 if (value2 == 0) {
254 Com_Printf("UI_GetFloatFromExpression: Div by 0. '0' returned");
255 return 0;
256 } else
257 return value1 / value2;
258 case EA_OPERATOR_MOD:
259 {
260 const int v1 = value1;
261 const int v2 = value2;
263 return v1 % v2;
264 }
265 }
266 }
267 break;
268
270 switch (expression->type) {
272 {
273 uiNode_t* node;
274 const value_t* property;
275 node = UI_GetNodeFromExpression(expression, context, &property);
276 return UI_GetFloatFromNodeProperty(node, property);
277 }
278 default:
279 Com_Error(ERR_FATAL, "UI_GetFloatFromExpression: (EA_OPERATOR_UNARY) Invalid expression type %i", expression->type);
280 }
281
282 }
283
284 Com_Printf("UI_GetFloatFromExpression: Unsupported expression type: %i. '0' returned", expression->type);
285 return 0;
286}
287
293const char* UI_GetStringFromExpression (uiAction_t* expression, const uiCallContext_t* context)
294{
295 switch (expression->type & EA_HIGHT_MASK) {
296 case EA_VALUE:
297 switch (expression->type) {
298 case EA_VALUE_VAR:
299 {
300 uiValue_t* variable = UI_GetVariable(context, expression->d.terminal.d1.integer);
301 switch (variable->type) {
302 case EA_VALUE_STRING:
303 if (variable->value.string == nullptr) {
304 Com_Printf("UI_GetStringFromExpression: String variable not initialized. Empty string returned");
305 return "";
306 }
307 return variable->value.string;
308 case EA_VALUE_FLOAT:
309 {
310 const float number = variable->value.number;
311 const int integer = number;
313 if (number == integer)
314 return va("%i", integer);
315 else
316 return va("%f", number);
317 }
318 case EA_VALUE_CVAR:
319 {
320 cvar_t* cvar = variable->value.cvar;
321 if (cvar == nullptr) {
322 Com_Printf("UI_GetStringFromExpression: Cvar variable not initialized. Empty string returned");
323 return "";
324 }
325 return cvar->string;
326 }
327 default:
328 Com_Printf("UI_GetStringFromExpression: Unsupported variable type: %i. Empty string returned", variable->type);
329 return "";
330 }
331 }
332 case EA_VALUE_STRING:
334 {
335 const char* string = expression->d.terminal.d1.constString;
336 if (expression->type == EA_VALUE_STRING_WITHINJECTION)
337 string = UI_GenInjectedString(string, false, context);
338 return string;
339 }
340 case EA_VALUE_FLOAT:
341 {
342 const float number = expression->d.terminal.d1.number;
343 const int integer = number;
345 if (number == integer)
346 return va("%i", integer);
347 else
348 return va("%f", number);
349 }
352 {
353 cvar_t* cvar = nullptr;
354 const char* cvarName = expression->d.terminal.d1.constString;
355 if (expression->type == EA_VALUE_CVARNAME_WITHINJECTION)
356 cvarName = UI_GenInjectedString(cvarName, false, context);
357 cvar = Cvar_Get(cvarName, "", 0, "Cvar from UI script expression");
358 return cvar->string;
359 }
362 {
363 uiNode_t* node;
364 const value_t* property;
365 const char* string;
366 node = UI_GetNodeFromExpression(expression, context, &property);
367 if (!node) {
368 Com_Printf("UI_GetStringFromExpression: Node wasn't found; Empty string returned\n");
369 return "";
370 }
371 if (!property) {
372 Com_Printf("UI_GetStringFromExpression: Property wasn't found; Empty string returned\n");
373 return "";
374 }
375 string = UI_GetStringFromNodeProperty(node, property);
376 if (string == nullptr) {
377 Com_Printf("UI_GetStringFromExpression: String getter for '%s@%s' property do not exists; '' returned\n", UI_Node_GetWidgetName(node), property->string);
378 return "";
379 }
380 return string;
381 }
382 break;
383 case EA_VALUE_PARAM:
384 return UI_GetParam(context, expression->d.terminal.d1.integer);
386 return va("%i", UI_GetParamNumber(context));
387 }
388 break;
389
391 switch (expression->type) {
393 {
394 uiNode_t* node;
395 const value_t* property;
396 node = UI_GetNodeFromExpression(expression, context, &property);
397 return UI_GetStringFromNodeProperty(node, property);
398 }
399 default:
400 Com_Error(ERR_FATAL, "UI_GetFloatFromExpression: (EA_OPERATOR_UNARY) Invalid expression type %i", expression->type);
401 }
402
406 {
407 const bool v = UI_GetBooleanFromExpression(expression, context);
408 return (v)?"1":"0";
409 }
410
412 {
413 const float number = UI_GetFloatFromExpression(expression, context);
414 const int integer = number;
416 if (number == integer)
417 return va("%i", integer);
418 else
419 return va("%f", number);
420 }
421 }
422
423 Com_Printf("UI_GetStringFromExpression: Unsupported expression type: %i", expression->type);
424 return "";
425}
426
432{
433 if (expression == nullptr)
434 return false;
435
436 switch (expression->type & EA_HIGHT_MASK) {
437 case EA_VALUE:
438 return UI_GetFloatFromExpression(expression, context) != 0;
439
441 {
442#define VALUE1 UI_GetBooleanFromExpression(expression->d.nonTerminal.left, context)
443#define VALUE2 UI_GetBooleanFromExpression(expression->d.nonTerminal.right, context)
444
445 switch (expression->type) {
446 case EA_OPERATOR_AND:
447 return VALUE1 && VALUE2;
448 case EA_OPERATOR_OR:
449 return VALUE1 || VALUE2;
450 case EA_OPERATOR_XOR:
451 return VALUE1 ^ VALUE2;
452 case EA_OPERATOR_NOT:
453 return !VALUE1;
454 default:
455 Com_Error(ERR_FATAL, "UI_GetBooleanFromExpression: (BOOL2BOOL) Invalid expression type");
456 }
457 }
458
460 {
461 const float value1 = UI_GetFloatFromExpression(expression->d.nonTerminal.left, context);
462 const float value2 = UI_GetFloatFromExpression(expression->d.nonTerminal.right, context);
463
464 switch (expression->type) {
465 case EA_OPERATOR_EQ:
466 return value1 == value2;
467 case EA_OPERATOR_LE:
468 return value1 <= value2;
469 case EA_OPERATOR_GE:
470 return value1 >= value2;
471 case EA_OPERATOR_GT:
472 return value1 > value2;
473 case EA_OPERATOR_LT:
474 return value1 < value2;
475 case EA_OPERATOR_NE:
476 return value1 != value2;
477 default:
478 Com_Error(ERR_FATAL, "UI_GetBooleanFromExpression: (FLOAT2BOOL) Invalid expression type");
479 }
480 }
481
483 switch (expression->type) {
485 {
486 const uiAction_t* e = expression->d.nonTerminal.left;
487 const char* name;
488 assert(e);
490 switch (e->type) {
492 name = UI_GenInjectedString(name, false, context);
493 /* resolved the cvar name, continue processing, fall through */
495 return Cvar_FindVar(name) != nullptr;
497 name = UI_GenInjectedString(name, false, context);
498 /* resolved the path node name, continue processing, fall through */
499 case EA_VALUE_PATHNODE: {
500 uiNode_t* node = nullptr;
501 const value_t* property;
502 UI_ReadNodePath(name, context->source, context->tagNode, &node, &property);
503 return node != nullptr;
504 }
505 default:
506 return false;
507 }
508 }
510 return UI_GetFloatFromExpression(expression, context) != 0;
511 default:
512 Com_Error(ERR_FATAL, "UI_GetBooleanFromExpression: (EA_OPERATOR_UNARY) Invalid expression type %i", expression->type);
513 }
514
516 {
517 const char* value1 = UI_GetStringFromExpression(expression->d.nonTerminal.left, context);
518 const char* value2 = UI_GetStringFromExpression(expression->d.nonTerminal.right, context);
519
520 switch (expression->type) {
522 return Q_streq(value1, value2);
524 return !Q_streq(value1, value2);
525 default:
526 Com_Error(ERR_FATAL, "UI_GetBooleanFromExpression: (STRING2BOOL) Invalid expression type");
527 }
528 }
529
530 default:
531 Com_Error(ERR_FATAL, "UI_GetBooleanFromExpression: Unsupported expression type: %i", expression->type);
532 }
533}
534
541{
542 const char* text, *base;
543 uiAction_t* expression;
544
545 base = va("( %s )", description);
546 text = base;
547 expression = UI_ParseExpression(&text);
548 if (!expression) {
549 Com_Printf("UI_AllocStaticStringCondition: Parse error on expression \"%s\"\n", base);
550 return nullptr;
551 }
552
553 return expression;
554}
555
560static uiAction_t* UI_ParseValueExpression (const char** text)
561{
562 const char* token;
563 uiAction_t* expression = UI_AllocStaticAction();
564
565 token = Com_Parse(text);
566 if (*text == nullptr) {
567 Com_Printf("UI_ParseTerminalExpression: Token expected\n");
568 return nullptr;
569 }
570
571 /* it is a const string (or an injection tag for compatibility) */
572 if (Com_GetType(text) == TT_QUOTED_WORD || token[0] == '<') {
573 expression->d.terminal.d1.constString = UI_AllocStaticString(token, 0);
574 if (UI_IsInjectedString(token))
576 else
577 expression->type = EA_VALUE_STRING;
578 return expression;
579 }
580
581 /* it is a param */
582 if (!Q_strncasecmp(token, "param", 5)) {
583 if (!Q_strcasecmp(token, "paramcount")) {
584 expression->type = EA_VALUE_PARAMCOUNT;
585 return expression;
586 } else if (token[5] >= '1' && token[5] <= '9') {
587 int i;
588 if (sscanf(token + 5, "%i", &i) == 1) {
589 /* token range 1-9 already avoid 0 */
590 assert(i != 0);
592 expression->type = EA_VALUE_PARAM;
593 expression->d.terminal.d1.integer = i;
594 return expression;
595 }
596 }
597 }
598
599 /* it is a cvarname */
600 if (char const* const cvarName = Q_strstart(token, "*cvar:")) {
601 expression->d.terminal.d1.constString = UI_AllocStaticString(cvarName, 0);
602 if (UI_IsInjectedString(cvarName))
604 else
605 expression->type = EA_VALUE_CVARNAME;
606 return expression;
607 }
608
609 /* it is a node property or it is a OLD syntax node property */
611 if (char const* path = Q_strstart(token, "*")) {
612 const char* propertyName;
613#if 0 /* it looks useless, an unused cache */
614 const value_t* property;
615#endif
616
617 char const* const relativeToNode = Q_strstart(path, "node:");
618 if (relativeToNode)
619 path = relativeToNode;
620
621 if (UI_IsInjectedString(path))
623 else
624 expression->type = EA_VALUE_PATHPROPERTY;
625 if (!relativeToNode) {
626 Com_Printf("UI_ParseExpression: Old syntax, please prefix '%s' with \"*node:root.\" \n", token);
627 path = va("root.%s", path);
628 }
629 expression->d.terminal.d1.constString = UI_AllocStaticString(path, 0);
630
631 /* get property name */
632 propertyName = strchr(path, '@');
633 if (propertyName == nullptr) {
634 if (expression->type == EA_VALUE_PATHPROPERTY_WITHINJECTION)
636 else
637 expression->type = EA_VALUE_PATHNODE;
638 return expression;
639 }
640 propertyName++;
641
642 return expression;
643 }
644
645 /* unsigned and signed number */
646 if ((token[0] >= '0' && token[0] <= '9')
647 || (token[0] == '-' && token[1] >= '0' && token[1] <= '9')) {
649 float f = atof(token);
650 expression->d.terminal.d1.number = f;
651 expression->type = EA_VALUE_FLOAT;
652 return expression;
653 }
654
655 /* boolean */
656 if (Q_streq(token, "true")) {
657 expression->d.terminal.d1.number = 1.0;
658 expression->type = EA_VALUE_FLOAT;
659 return expression;
660 }
661 if (Q_streq(token, "false")) {
662 expression->d.terminal.d1.number = 0.0;
663 expression->type = EA_VALUE_FLOAT;
664 return expression;
665 }
666
667 Com_Error(ERR_FATAL, "UI_ParseValueExpression: Token \"%s\" unknown. String must use quotes, cvar and nodes must use prefix.\n", token);
668}
669
670uiAction_t* UI_ParseExpression (const char** text)
671{
672 const char* token;
673
674 token = Com_Parse(text);
675 if (*text == nullptr)
676 return nullptr;
677
678 if (Q_streq(token, "(")) {
679 uiAction_t* expression;
680 uiAction_t* e;
681
682 e = UI_ParseExpression(text);
683
684 token = Com_Parse(text);
685 if (*text == nullptr)
686 return nullptr;
687
688 /* unary operator or unneed "( ... )" */
689 if (Q_streq(token, ")"))
690 return e;
691
692 /* then its an operator */
693 expression = UI_AllocStaticAction();
694 expression->d.nonTerminal.left = e;
695 expression->type = UI_GetActionTokenType(token, EA_BINARYOPERATOR);
696 if (expression->type == EA_NULL) {
697 Com_Printf("UI_ParseExpression: Invalid 'expression' statement. Unknown '%s' operator\n", token);
698 return nullptr;
699 }
700
701 e = UI_ParseExpression(text);
702 expression->d.nonTerminal.right = e;
703
704 token = Com_Parse(text);
705 if (*text == nullptr)
706 return nullptr;
707 if (!Q_streq(token, ")")) {
708 Com_Printf("UI_ParseExpression: Token ')' expected\n");
709 return nullptr;
710 }
711
712 return expression;
713 } else {
714 const int type = UI_GetActionTokenType(token, EA_UNARYOPERATOR);
715 if (type == EA_NULL) {
717 return UI_ParseValueExpression(text);
718 } else {
719 uiAction_t* expression = UI_AllocStaticAction();
720 uiAction_t* e;
721
722 e = UI_ParseExpression(text);
723 expression->type = type;
724 expression->d.nonTerminal.left = e;
725
726 if (expression->type == EA_OPERATOR_EXISTS) {
727 switch (e->type) {
732 break;
733 default:
734 Com_Printf("UI_ParseExpression: Cvar or Node path expected, but type %d found\n", e->type);
735 return nullptr;
736 }
737 }
738 return expression;
739 }
740 }
741}
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_FATAL
Definition common.h:210
cvar_t * Cvar_FindVar(const char *varName)
Searches for a cvar given by parameter.
Definition cvar.cpp:106
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
Definition cvar.cpp:342
const char * Com_Parse(const char *data_p[], char *target, size_t size, bool replaceWhitespaces)
Parse a token out of a string.
Definition parse.cpp:107
void Com_UnParseLastToken(void)
Put back the last token into the parser The next call of Com_Parse will return the same token again.
Definition parse.cpp:42
Com_TokenType_t Com_GetType(const char **data_p)
Get the current token type.
Definition parse.cpp:60
Shared parsing functions.
@ TT_QUOTED_WORD
Definition parse.h:43
QGL_EXTERN int GLboolean GLfloat * v
Definition r_gl.h:120
QGL_EXTERN GLfloat f
Definition r_gl.h:114
QGL_EXTERN GLint i
Definition r_gl.h:113
QGL_EXTERN GLint GLenum type
Definition r_gl.h:94
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition r_gl.h:110
#define Q_strcasecmp(a, b)
Definition shared.h:131
#define Q_streq(a, b)
Definition shared.h:136
#define Q_strncasecmp(s1, s2, n)
Definition shared.h:132
char const * Q_strstart(char const *str, char const *start)
Matches the start of a string.
Definition shared.cpp:587
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...
Definition shared.cpp:410
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
Definition cvar.h:71
float value
Definition cvar.h:80
char * string
Definition cvar.h:73
Atomic element to store UI scripts The parser use this atom to translate script action into many tree...
Definition ui_actions.h:144
short type
Define the type of the element, it can be a command, an operator, or a value.
Definition ui_actions.h:149
uiTerminalActionData_t d1
Definition ui_actions.h:175
struct uiAction_t::@020173205255351022052355137266041366256354050344::@226100300324067003344030331332225043077332072062 terminal
Stores a terminal action (a value, which must be a leaf in the tree).
struct uiAction_t::@020173205255351022052355137266041366256354050344::@051207210304220322206103241251135377014006203150 nonTerminal
Stores a none terminal action (a command or an operator).
uiTerminalActionData_t d2
Definition ui_actions.h:176
struct uiAction_s * right
Definition ui_actions.h:166
union uiAction_t::@020173205255351022052355137266041366256354050344 d
Stores data about the action.
struct uiAction_s * left
Definition ui_actions.h:165
Contain the context of the calling of a function.
Definition ui_actions.h:208
uiNode_t * source
Definition ui_actions.h:210
uiNode_t * tagNode
Definition ui_actions.h:212
Atomic structure used to define most of the UI.
Definition ui_nodes.h:80
uiNode_t * parent
Definition ui_nodes.h:92
uiNode_t * root
Definition ui_nodes.h:93
Type for uiAction_t It also contain type about type (for example EA_BINARYOPERATOR).
Definition ui_actions.h:194
float number
Definition ui_actions.h:198
char * string
Definition ui_actions.h:199
struct cvar_s * cvar
Definition ui_actions.h:200
uiActionType_t type
Definition ui_actions.h:195
union uiValue_t::@240370141006122110255260007133317070215100126152 value
uiNode_t * node
Definition ui_actions.h:201
const char * string
Definition scripts.h:168
const char * UI_GetParam(const uiCallContext_t *context, int paramID)
int UI_GetActionTokenType(const char *token, int group)
return an action type from a token, and a group
bool UI_IsInjectedString(const char *string)
Test if a string use an injection syntax.
uiValue_t * UI_GetVariable(const uiCallContext_t *context, int relativeVarId)
Return a variable from the context.
int UI_GetParamNumber(const uiCallContext_t *context)
const char * UI_GenInjectedString(const char *input, bool addNewLine, const uiCallContext_t *context)
Replace injection identifiers (e.g. <eventParam>) by a value.
@ EA_OPERATOR_LT
Definition ui_actions.h:71
@ EA_OPERATOR_FLOAT2FLOAT
Definition ui_actions.h:75
@ EA_OPERATOR_STR_NE
Definition ui_actions.h:85
@ EA_VALUE_PATHPROPERTY_WITHINJECTION
Definition ui_actions.h:104
@ EA_OPERATOR_XOR
Definition ui_actions.h:62
@ EA_VALUE_THIS
Definition ui_actions.h:111
@ EA_OPERATOR_BOOLEAN2BOOLEAN
Definition ui_actions.h:59
@ EA_VALUE_STRING
Definition ui_actions.h:95
@ EA_OPERATOR_DIV
Definition ui_actions.h:79
@ EA_OPERATOR_ADD
Definition ui_actions.h:76
@ EA_VALUE_PATHNODE
Definition ui_actions.h:101
@ EA_VALUE_FLOAT
Definition ui_actions.h:97
@ EA_OPERATOR_GT
Definition ui_actions.h:70
@ EA_OPERATOR_GE
Definition ui_actions.h:69
@ EA_OPERATOR_FLOAT2BOOLEAN
Definition ui_actions.h:66
@ EA_OPERATOR_OR
Definition ui_actions.h:61
@ EA_BINARYOPERATOR
Definition ui_actions.h:36
@ EA_OPERATOR_PATHPROPERTYFROM
Definition ui_actions.h:91
@ EA_OPERATOR_NOT
Definition ui_actions.h:63
@ EA_OPERATOR_SUB
Definition ui_actions.h:77
@ EA_OPERATOR_AND
Definition ui_actions.h:60
@ EA_VALUE_CVARNAME
Definition ui_actions.h:99
@ EA_VALUE_PARENT
Definition ui_actions.h:113
@ EA_HIGHT_MASK
Definition ui_actions.h:40
@ EA_OPERATOR_MOD
Definition ui_actions.h:80
@ EA_VALUE_PARAM
Definition ui_actions.h:109
@ EA_OPERATOR_LE
Definition ui_actions.h:68
@ EA_OPERATOR_STRING2BOOLEAN
Definition ui_actions.h:83
@ EA_VALUE_PATHPROPERTY
Definition ui_actions.h:103
@ EA_OPERATOR_STR_EQ
Definition ui_actions.h:84
@ EA_OPERATOR_EXISTS
Definition ui_actions.h:89
@ EA_VALUE_CVARNAME_WITHINJECTION
Definition ui_actions.h:100
@ EA_VALUE_WINDOW
Definition ui_actions.h:112
@ EA_OPERATOR_UNARY
Definition ui_actions.h:88
@ EA_NULL
Definition ui_actions.h:34
@ EA_OPERATOR_MUL
Definition ui_actions.h:78
@ EA_VALUE_STRING_WITHINJECTION
Definition ui_actions.h:96
@ EA_VALUE_VAR
Definition ui_actions.h:106
@ EA_VALUE_PARAMCOUNT
Definition ui_actions.h:110
@ EA_VALUE_CHILD
Definition ui_actions.h:114
@ EA_OPERATOR_NE
Definition ui_actions.h:72
@ EA_VALUE_NODE
Definition ui_actions.h:108
@ EA_VALUE
Definition ui_actions.h:94
@ EA_VALUE_CVAR
Definition ui_actions.h:107
@ EA_OPERATOR_EQ
Definition ui_actions.h:67
@ EA_UNARYOPERATOR
Definition ui_actions.h:37
@ EA_VALUE_PATHNODE_WITHINJECTION
Definition ui_actions.h:102
uiAction_t * UI_AllocStaticStringCondition(const char *description)
Allocate and initialize an expression according to a string.
uiAction_t * UI_ParseExpression(const char **text)
bool UI_GetBooleanFromExpression(uiAction_t *expression, const uiCallContext_t *context)
Check if an expression is true.
const char * UI_GetStringFromExpression(uiAction_t *expression, const uiCallContext_t *context)
float UI_GetFloatFromExpression(uiAction_t *expression, const uiCallContext_t *context)
#define VALUE1
#define VALUE2
uiNode_t * UI_GetNodeFromExpression(uiAction_t *expression, const uiCallContext_t *context, const value_t **property)
Get a node and a property from an expression.
static uiAction_t * UI_ParseValueExpression(const char **text)
Read a value from the stream and init an action with it.
Internal data use by the UI package.
const char * UI_Node_GetWidgetName(uiNode_t const *node)
Definition ui_node.cpp:99
const char * UI_GetStringFromNodeProperty(const uiNode_t *node, const value_t *property)
Return a string from a node property.
Definition ui_node.cpp:990
float UI_GetFloatFromNodeProperty(const uiNode_t *node, const value_t *property)
Return a float from a node property.
Definition ui_node.cpp:1031
C interface to allow to access to cpp node code.
const char * UI_GetPath(const uiNode_t *node)
Return a path from a window to a node.
Definition ui_nodes.cpp:174
void UI_ReadNodePath(const char *path, const uiNode_t *relativeNode, const uiNode_t *iterationNode, uiNode_t **resultNode, const value_t **resultProperty, value_t *luaMethod)
Read a path and return every we can use (node and property).
Definition ui_nodes.cpp:219
char * UI_AllocStaticString(const char *string, int size)
Allocate a string into the UI static memory.
Definition ui_parse.cpp:204
uiAction_t * UI_AllocStaticAction(void)
Allocate an action.
Definition ui_parse.cpp:221
const char * constString
Definition ui_actions.h:127