44 if (property !=
nullptr)
49 switch (expression->
type) {
53 switch (variable->
type) {
73 Com_Printf(
"UI_GetNodeFromExpression: Node '%s' wasn't found; nullptr returned\n", path);
76 if (propertyTmp !=
nullptr)
77 Com_Printf(
"UI_GetNodeFromExpression: No property expected, but path '%s' contain a property. Property ignored.\n", path);
93 Com_Printf(
"UI_GetNodeFromExpression: Node '%s' wasn't found; nullptr returned\n", path);
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);
100 *
property = propertyTmp;
123 switch (expression->
type) {
132 Com_Printf(
"UI_GetNodeFromExpression: Path '%s' from node '%s' found no node; nullptr returned\n", path,
UI_GetPath(relativeTo));
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));
139 *
property = propertyTmp;
162 switch (expression->
type) {
166 switch (variable->
type) {
169 Com_Printf(
"UI_GetFloatFromExpression: String variable not initialized. '0' returned");
178 if (cvar ==
nullptr) {
179 Com_Printf(
"UI_GetFloatFromExpression: Cvar variable not initialized. '0' returned");
185 Com_Printf(
"UI_GetFloatFromExpression: Unsupported variable type: %i. '0' returned", variable->
type);
206 cvar =
Cvar_Get(cvarName,
"", 0,
"Cvar from UI script expression");
216 Com_Printf(
"UI_GetFloatFromParam: Node wasn't found; '0'\n");
220 Com_Printf(
"UI_GetFloatFromParam: Property wasn't found; '0' returned\n");
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);
245 switch (expression->
type) {
247 return value1 + value2;
249 return value1 - value2;
251 return value1 * value2;
254 Com_Printf(
"UI_GetFloatFromExpression: Div by 0. '0' returned");
257 return value1 / value2;
260 const int v1 = value1;
261 const int v2 = value2;
270 switch (expression->
type) {
279 Com_Error(
ERR_FATAL,
"UI_GetFloatFromExpression: (EA_OPERATOR_UNARY) Invalid expression type %i", expression->
type);
284 Com_Printf(
"UI_GetFloatFromExpression: Unsupported expression type: %i. '0' returned", expression->
type);
297 switch (expression->
type) {
301 switch (variable->
type) {
304 Com_Printf(
"UI_GetStringFromExpression: String variable not initialized. Empty string returned");
311 const int integer = number;
313 if (number == integer)
314 return va(
"%i", integer);
316 return va(
"%f", number);
321 if (cvar ==
nullptr) {
322 Com_Printf(
"UI_GetStringFromExpression: Cvar variable not initialized. Empty string returned");
328 Com_Printf(
"UI_GetStringFromExpression: Unsupported variable type: %i. Empty string returned", variable->
type);
343 const int integer = number;
345 if (number == integer)
346 return va(
"%i", integer);
348 return va(
"%f", number);
357 cvar =
Cvar_Get(cvarName,
"", 0,
"Cvar from UI script expression");
368 Com_Printf(
"UI_GetStringFromExpression: Node wasn't found; Empty string returned\n");
372 Com_Printf(
"UI_GetStringFromExpression: Property wasn't found; Empty string returned\n");
376 if (
string ==
nullptr) {
391 switch (expression->
type) {
400 Com_Error(
ERR_FATAL,
"UI_GetFloatFromExpression: (EA_OPERATOR_UNARY) Invalid expression type %i", expression->
type);
414 const int integer = number;
416 if (number == integer)
417 return va(
"%i", integer);
419 return va(
"%f", number);
423 Com_Printf(
"UI_GetStringFromExpression: Unsupported expression type: %i", expression->
type);
433 if (expression ==
nullptr)
442#define VALUE1 UI_GetBooleanFromExpression(expression->d.nonTerminal.left, context)
443#define VALUE2 UI_GetBooleanFromExpression(expression->d.nonTerminal.right, context)
445 switch (expression->
type) {
455 Com_Error(
ERR_FATAL,
"UI_GetBooleanFromExpression: (BOOL2BOOL) Invalid expression type");
464 switch (expression->
type) {
466 return value1 == value2;
468 return value1 <= value2;
470 return value1 >= value2;
472 return value1 > value2;
474 return value1 < value2;
476 return value1 != value2;
478 Com_Error(
ERR_FATAL,
"UI_GetBooleanFromExpression: (FLOAT2BOOL) Invalid expression type");
483 switch (expression->
type) {
503 return node !=
nullptr;
512 Com_Error(
ERR_FATAL,
"UI_GetBooleanFromExpression: (EA_OPERATOR_UNARY) Invalid expression type %i", expression->
type);
520 switch (expression->
type) {
522 return Q_streq(value1, value2);
524 return !
Q_streq(value1, value2);
526 Com_Error(
ERR_FATAL,
"UI_GetBooleanFromExpression: (STRING2BOOL) Invalid expression type");
542 const char* text, *base;
545 base =
va(
"( %s )", description);
549 Com_Printf(
"UI_AllocStaticStringCondition: Parse error on expression \"%s\"\n", base);
566 if (*text ==
nullptr) {
567 Com_Printf(
"UI_ParseTerminalExpression: Token expected\n");
586 }
else if (token[5] >=
'1' && token[5] <=
'9') {
588 if (sscanf(token + 5,
"%i", &
i) == 1) {
600 if (
char const*
const cvarName =
Q_strstart(token,
"*cvar:")) {
611 if (
char const* path =
Q_strstart(token,
"*")) {
612 const char* propertyName;
617 char const*
const relativeToNode =
Q_strstart(path,
"node:");
619 path = relativeToNode;
625 if (!relativeToNode) {
626 Com_Printf(
"UI_ParseExpression: Old syntax, please prefix '%s' with \"*node:root.\" \n", token);
627 path =
va(
"root.%s", path);
632 propertyName = strchr(path,
'@');
633 if (propertyName ==
nullptr) {
646 if ((token[0] >=
'0' && token[0] <=
'9')
647 || (token[0] ==
'-' && token[1] >=
'0' && token[1] <=
'9')) {
649 float f = atof(token);
667 Com_Error(
ERR_FATAL,
"UI_ParseValueExpression: Token \"%s\" unknown. String must use quotes, cvar and nodes must use prefix.\n", token);
675 if (*text ==
nullptr)
685 if (*text ==
nullptr)
697 Com_Printf(
"UI_ParseExpression: Invalid 'expression' statement. Unknown '%s' operator\n", token);
705 if (*text ==
nullptr)
708 Com_Printf(
"UI_ParseExpression: Token ')' expected\n");
734 Com_Printf(
"UI_ParseExpression: Cvar or Node path expected, but type %d found\n", e->
type);
void Com_Error(int code, const char *fmt,...)
void Com_Printf(const char *const fmt,...)
cvar_t * Cvar_FindVar(const char *varName)
Searches for a cvar given by parameter.
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
const char * Com_Parse(const char *data_p[], char *target, size_t size, bool replaceWhitespaces)
Parse a token out of a string.
void Com_UnParseLastToken(void)
Put back the last token into the parser The next call of Com_Parse will return the same token again.
Com_TokenType_t Com_GetType(const char **data_p)
Get the current token type.
Shared parsing functions.
QGL_EXTERN int GLboolean GLfloat * v
QGL_EXTERN GLint GLenum type
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
#define Q_strcasecmp(a, b)
#define Q_strncasecmp(s1, s2, n)
char const * Q_strstart(char const *str, char const *start)
Matches the start of a string.
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...
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
Atomic element to store UI scripts The parser use this atom to translate script action into many tree...
short type
Define the type of the element, it can be a command, an operator, or a value.
uiTerminalActionData_t d1
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
struct uiAction_s * right
union uiAction_t::@020173205255351022052355137266041366256354050344 d
Stores data about the action.
Contain the context of the calling of a function.
Atomic structure used to define most of the UI.
Type for uiAction_t It also contain type about type (for example EA_BINARYOPERATOR).
union uiValue_t::@240370141006122110255260007133317070215100126152 value
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_FLOAT2FLOAT
@ EA_VALUE_PATHPROPERTY_WITHINJECTION
@ EA_OPERATOR_BOOLEAN2BOOLEAN
@ EA_OPERATOR_FLOAT2BOOLEAN
@ EA_OPERATOR_PATHPROPERTYFROM
@ EA_OPERATOR_STRING2BOOLEAN
@ EA_VALUE_CVARNAME_WITHINJECTION
@ EA_VALUE_STRING_WITHINJECTION
@ EA_VALUE_PATHNODE_WITHINJECTION
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)
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)
const char * UI_GetStringFromNodeProperty(const uiNode_t *node, const value_t *property)
Return a string from a node property.
float UI_GetFloatFromNodeProperty(const uiNode_t *node, const value_t *property)
Return a float from a node property.
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.
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).
char * UI_AllocStaticString(const char *string, int size)
Allocate a string into the UI static memory.
uiAction_t * UI_AllocStaticAction(void)
Allocate an action.