UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ui_expression.cpp
Go to the documentation of this file.
1 
5 /*
6 Copyright (C) 2002-2020 UFO: Alien Invasion.
7 
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 
17 See the GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, 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 
42 uiNode_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 
62  case EA_VALUE_PATHNODE:
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;
88  if (expression->type == EA_VALUE_PATHPROPERTY_WITHINJECTION)
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;
122  case EA_OPERATOR_UNARY:
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 
158 float 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;
199  case EA_VALUE_CVARNAME:
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  }
235  case EA_VALUE_PARAMCOUNT:
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 
269  case EA_OPERATOR_UNARY:
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 
293 const 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  }
350  case EA_VALUE_CVARNAME:
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);
385  case EA_VALUE_PARAMCOUNT:
386  return va("%i", UI_GetParamNumber(context));
387  }
388  break;
389 
390  case EA_OPERATOR_UNARY:
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 
431 bool UI_GetBooleanFromExpression (uiAction_t* expression, const uiCallContext_t* context)
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 
482  case EA_OPERATOR_UNARY:
483  switch (expression->type) {
484  case EA_OPERATOR_EXISTS:
485  {
486  const uiAction_t* e = expression->d.nonTerminal.left;
487  const char* name;
488  assert(e);
489  name = e->d.terminal.d1.constString;
490  switch (e->type) {
492  name = UI_GenInjectedString(name, false, context);
493  /* resolved the cvar name, continue processing, fall through */
494  case EA_VALUE_CVARNAME:
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) {
521  case EA_OPERATOR_STR_EQ:
522  return Q_streq(value1, value2);
523  case EA_OPERATOR_STR_NE:
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 
540 uiAction_t* UI_AllocStaticStringCondition (const char* description)
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 
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))
575  expression->type = EA_VALUE_STRING_WITHINJECTION;
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 
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) {
728  case EA_VALUE_CVARNAME:
730  case EA_VALUE_PATHNODE:
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 }
float UI_GetFloatFromNodeProperty(const uiNode_t *node, const value_t *property)
Return a float from a node property.
Definition: ui_node.cpp:1019
bool UI_IsInjectedString(const char *string)
Test if a string use an injection syntax.
Definition: ui_actions.cpp:751
uiAction_t * UI_AllocStaticAction(void)
Allocate an action.
Definition: ui_parse.cpp:221
struct uiAction_s::@14::@16 terminal
Stores a terminal action (a value, which must be a leaf in the tree)
uiNode_t * parent
Definition: ui_nodes.h:92
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
bool UI_GetBooleanFromExpression(uiAction_t *expression, const uiCallContext_t *context)
Check if an expression is true.
QGL_EXTERN GLint GLenum type
Definition: r_gl.h:94
uiAction_t * UI_AllocStaticStringCondition(const char *description)
Allocate and initialize an expression according to a string.
uiActionType_t type
Definition: ui_actions.h:195
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
uiValue_t * UI_GetVariable(const uiCallContext_t *context, int relativeVarId)
Return a variable from the context.
Definition: ui_actions.cpp:517
float value
Definition: cvar.h:80
void Com_Printf(const char *const fmt,...)
Definition: common.cpp:386
uiAction_t * UI_ParseExpression(const char **text)
union uiAction_s::@14 d
Stores data about the action.
struct cvar_s * cvar
Definition: ui_actions.h:200
#define ERR_FATAL
Definition: common.h:210
Internal data use by the UI package.
C interface to allow to access to cpp node code.
void Com_Error(int code, const char *fmt,...)
Definition: common.cpp:417
char * string
Definition: ui_actions.h:199
uiNode_t * root
Definition: ui_nodes.h:93
struct uiAction_s::@14::@15 nonTerminal
Stores a none terminal action (a command or an operator)
int UI_GetActionTokenType(const char *token, int group)
return an action type from a token, and a group
Definition: ui_actions.cpp:113
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 * UI_GetStringFromExpression(uiAction_t *expression, const uiCallContext_t *context)
#define Q_strncasecmp(s1, s2, n)
Definition: shared.h:132
uiNode_t * UI_GetNodeFromExpression(uiAction_t *expression, const uiCallContext_t *context, const value_t **property)
Get a node and a property from an expression.
const char * UI_GetPath(const uiNode_t *node)
Return a path from a window to a node.
Definition: ui_nodes.cpp:174
char const * Q_strstart(char const *str, char const *start)
Matches the start of a string.
Definition: shared.cpp:587
uiNode_t * source
Definition: ui_actions.h:210
#define Q_strcasecmp(a, b)
Definition: shared.h:131
Atomic structure used to define most of the UI.
Definition: ui_nodes.h:80
const char * string
Definition: scripts.h:169
uiNode_t * tagNode
Definition: ui_actions.h:212
Contain the context of the calling of a function.
Definition: ui_actions.h:208
#define VALUE2
float number
Definition: ui_actions.h:198
QGL_EXTERN GLfloat f
Definition: r_gl.h:114
int UI_GetParamNumber(const uiCallContext_t *context)
Definition: ui_actions.cpp:166
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
const char * UI_GetParam(const uiCallContext_t *context, int paramID)
Definition: ui_actions.cpp:179
const char * UI_GenInjectedString(const char *input, bool addNewLine, const uiCallContext_t *context)
Replace injection identifiers (e.g. ) by a value.
Definition: ui_actions.cpp:209
float UI_GetFloatFromExpression(uiAction_t *expression, const uiCallContext_t *context)
QGL_EXTERN GLint i
Definition: r_gl.h:113
union uiValue_s::@17 value
char * string
Definition: cvar.h:73
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition: r_gl.h:110
Com_TokenType_t Com_GetType(const char **data_p)
Get the current token type.
Definition: parse.cpp:60
Type for uiAction_t It also contain type about type (for example EA_BINARYOPERATOR) ...
Definition: ui_actions.h:194
#define VALUE1
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
const char * UI_Node_GetWidgetName(uiNode_t const *node)
Definition: ui_node.cpp:99
uiNode_t * node
Definition: ui_actions.h:201
#define Q_streq(a, b)
Definition: shared.h:136
const char * UI_GetStringFromNodeProperty(const uiNode_t *node, const value_t *property)
Return a string from a node property.
Definition: ui_node.cpp:978
QGL_EXTERN int GLboolean GLfloat * v
Definition: r_gl.h:120
char * UI_AllocStaticString(const char *string, int size)
Allocate a string into the UI static memory.
Definition: ui_parse.cpp:204
cvar_t * Cvar_FindVar(const char *varName)
Searches for a cvar given by parameter.
Definition: cvar.cpp:106
short type
Define the type of the element, it can be a command, an operator, or a value.
Definition: ui_actions.h:149
Atomic element to store UI scripts The parser use this atom to translate script action into many tree...
Definition: ui_actions.h:144
static uiAction_t * UI_ParseValueExpression(const char **text)
Read a value from the stream and init an action with it.
char * text
Definition: ui_nodes.h:121