36typedef struct ui_typedActionToken_s {
100 if (strcmp(a, b) >= 0) {
101 Sys_Error(
"UI_CheckActionTokenTypeSanity: '%s' is before '%s'. actionList must be sorted by alphabet", a, b);
115 unsigned char min = 0;
119 const int mid = (min + max) >> 1;
120 const int diff = strcmp(
actionTokens[mid].token, token);
145 assert(input[0] ==
'<');
149 while (outputSize && *input !=
'\0' && *input !=
' ' && *input !=
'>') {
150 *output++ = *input++;
182 assert(paramID >= 1);
188 Com_Printf(
"UI_GetParam: %i out of range\n", paramID);
192 current = context->
params;
193 while (paramID > 1) {
194 current = current->
next;
198 return (
const char*) current->
data;
211 static char cmd[256];
212 int length =
sizeof(cmd) - (addNewLine ? 2 : 1);
213 static char propertyName[256];
214 const char* cin = input;
217 while (
length && cin[0] !=
'\0') {
223 if (
char const*
const rest =
Q_strstart(propertyName,
"cvar:")) {
225 const int l = snprintf(cout,
length,
"%s", cvar->
string);
230 }
else if (
char const*
const path =
Q_strstart(propertyName,
"node:")) {
237 Com_Printf(
"UI_GenInjectedString: Node '%s' wasn't found; '' returned\n", path);
242 }
else if (!property) {
243 Com_Printf(
"UI_GenInjectedString: Property '%s' wasn't found; '' returned\n", path);
247 if (
string ==
nullptr) {
248 Com_Printf(
"UI_GenInjectedString: String getter for '%s' property do not exists; '' injected\n", path);
253 l = snprintf(cout,
length,
"%s",
string);
259 }
else if (
char const*
const command =
Q_strstart(propertyName,
"path:")) {
264 else if (
Q_streq(command,
"this"))
266 else if (
Q_streq(command,
"parent"))
269 Com_Printf(
"UI_GenCommand: Command '%s' for path injection unknown\n", command);
291 if (value ==
nullptr)
293 l = snprintf(cout,
length,
"%s", value);
304 const int checked = sscanf(propertyName,
"%d", &arg);
321 assert(cin[0] ==
'\0');
329 return va(
"%s", cmd);
379 if (left ==
nullptr) {
380 Com_Printf(
"UI_ExecuteSetAction: Action without left operand skipped.\n");
385 if (right ==
nullptr) {
386 Com_Printf(
"UI_ExecuteSetAction: Action without right operand skipped.\n");
391 const char* cvarName;
431 const value_t* callProperty =
nullptr;
436 memset(&luaMethod, 0,
sizeof(luaMethod));
444 if ((callNode ==
nullptr) && (!luaMethod.
type)) {
445 Com_Printf(
"UI_ExecuteCallAction: Node from path \"%s\" not found (relative to \"%s\").\n", path,
UI_GetPath(context->
source));
453 newContext.
source = callNode;
454 newContext.
params =
nullptr;
466 const char* value = (
char*) p->
data;
489 else if (callProperty ==
nullptr || callProperty->
type ==
V_UI_ACTION) {
502 func(callNode, &newContext);
519 const int varId = context->
varPosition + relativeVarId;
520 assert(relativeVarId >= 0);
521 assert(relativeVarId < context->varNumber);
522 return &(
ui_global.variableStack[varId]);
528 switch (variable->
type) {
552 switch (action->
type) {
571 assert(number <= context->varNumber);
572 for (
int i = 0;
i < number;
i++) {
587 Com_Error(
ERR_FATAL,
"UI_ExecuteAction: Variable stack full. UI_MAX_VARIABLESTACK hit.");
596 const char* cvarname = action->
d.
nonTerminal.
left->d.terminal.d1.constString;
611 Com_Printf(
"UI_ExecuteAction: Infinite loop. Force breaking 'while'\n");
650 Com_Printf(
"UI_ExecuteAction: Infinite loop. Force breaking 'forchildin'\n");
670 action = action->
next;
676 action = action->
next;
703 static int callnumber = 0;
704 if (callnumber++ > 20) {
708 for (
const uiAction_t* action = firstAction; action && !context->
breakLoop; action = action->next) {
753 const char* c = string;
757 const char* d = c + 1;
762 if (*d ==
' ' || *d ==
'\t' || *d ==
'\n' || *d ==
'\r')
819 (*action)->type =
type;
853 value->
next =
nullptr;
858 action->
next =
nullptr;
863 anchor = &(*anchor)->
next;
882 if (node ==
nullptr) {
887 Com_Printf(
"UI_AddListener_f: '%s' property not found, or is not an event.\n",
Cmd_Argv(1));
892 if (function ==
nullptr) {
917 if (lastAction->type ==
EA_LISTENER && lastAction->d.terminal.d2.constData ==
data) {
919 action = lastAction->
next;
921 while (lastAction->next) {
922 if (lastAction->next->type ==
EA_LISTENER && lastAction->next->d.terminal.d2.constData ==
data)
924 lastAction = lastAction->next;
926 if (lastAction->next) {
927 tmp = lastAction->
next;
928 lastAction->next = lastAction->next->next;
957 if (node ==
nullptr) {
962 Com_Printf(
"UI_RemoveListener_f: '%s' property not found, or is not an event.\n",
Cmd_Argv(1));
967 if (function ==
nullptr) {
985 const char* cvarName;
986 const char* confuncName;
1003 const char* cvarName;
1004 const char* confuncName;
1023 if (entry !=
nullptr)
const char * CL_Translate(const char *t)
const char * Cmd_Argv(int arg)
Returns a given argument.
int Cmd_Argc(void)
Return the number of arguments of the current command. "command parameter" will result in a argc of 2...
void Cmd_AddCommand(const char *cmdName, xcommand_t function, const char *desc)
Add a new command to the script interface.
void Cbuf_AddText(const char *format,...)
Adds command text at the end of the buffer.
void Com_Error(int code, const char *fmt,...)
void Com_Printf(const char *const fmt,...)
cvar_t * Cvar_ForceSet(const char *varName, const char *value)
Will set the variable even if NOSET or LATCH.
cvarChangeListener_t * Cvar_RegisterChangeListener(const char *varName, cvarChangeListenerFunc_t listenerFunc)
Registers a listener that is executed each time a cvar changed its value.
void Cvar_UnRegisterChangeListener(const char *varName, cvarChangeListenerFunc_t listenerFunc)
Unregisters a cvar change listener.
bool Cvar_Delete(const char *varName)
Function to remove the cvar and free the space.
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.
void Sys_Error(const char *error,...)
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.
void LIST_Delete(linkedList_t **list)
bool LIST_RemoveEntry(linkedList_t **list, linkedList_t *entry)
Removes one entry from the linked list.
int LIST_Count(const linkedList_t *list)
bool LIST_IsEmpty(const linkedList_t *list)
Checks whether the given list is empty.
const linkedList_t * LIST_ContainsString(const linkedList_t *list, const char *string)
Searches for the first occurrence of a given string.
#define LIST_Foreach(list, type, var)
Iterates over a linked list, it's safe to delete the returned entry from the list while looping over ...
bool _Mem_AllocatedInPool(memPool_t *pool, const void *pointer)
#define Mem_PoolStrDup(in, pool, tagNum)
#define Mem_PoolAllocType(type, pool)
QGL_EXTERN GLsizei const GLvoid * data
QGL_EXTERN GLuint GLsizei GLsizei * length
QGL_EXTERN GLint GLenum type
QGL_EXTERN GLint GLenum GLboolean GLsizei const GLvoid * pointer
T & Com_GetValue(void *const object, value_t const *const value)
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.
cvarChangeListener_t * changeListener
struct cvarChangeListener_s * next
cvarChangeListenerFunc_t exec
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_s * next
Next element in the action list.
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.
uiBehaviour_t * behaviour
struct uiAction_s * onClick
Type for uiAction_t It also contain type about type (for example EA_BINARYOPERATOR).
union uiValue_t::@240370141006122110255260007133317070215100126152 value
static void UI_CheckActionTokenTypeSanity(void)
Check if the action token list is sorted by alphabet, else dichotomic search can't work.
void UI_ExecuteEventActionsEx(uiNode_t *source, const uiAction_t *firstAction, linkedList_t *params)
void UI_ExecuteEventActions(uiNode_t *source, const uiAction_t *firstAction)
const char * UI_GetParam(const uiCallContext_t *context, int paramID)
static void UI_AddListener_f(void)
add a call of a function into a node event
void UI_InitActions(void)
int UI_GetActionTokenType(const char *token, int group)
return an action type from a token, and a group
void UI_PoolAllocAction(uiAction_t **action, int type, const void *data)
Set a new action to a uiAction_t pointer.
void UI_RemoveListener(uiNode_t *node, const value_t *property, uiNode_t *functionNode)
Remove a function callback from a node event. There can be more than on listener.
static void UI_ExecuteSetAction(const uiAction_t *action, const uiCallContext_t *context)
void UI_AddListener(uiNode_t *node, const value_t *property, const uiNode_t *functionNode)
Add a callback of a function into a node event. There can be more than on listener.
static void UI_CvarChangeListener(const char *cvarName, const char *oldValue, const char *newValue, void *data)
static void UI_ExecuteActions(const uiAction_t *firstAction, uiCallContext_t *context)
Execute a tree of actions from a source.
uiAction_t * UI_AllocStaticCommandAction(const char *command)
Allocate and initialize a command action.
static const char * UI_GenCommandReadProperty(const char *input, char *output, int outputSize)
read a property name from an input buffer to an output
bool UI_IsInjectedString(const char *string)
Test if a string use an injection syntax.
static void UI_AddCvarListener_f(void)
static void UI_RemoveCvarListener_f(void)
static void UI_ReleaseVariable(uiValue_t *variable)
static void UI_NodeSetPropertyFromActionValue(uiNode_t *node, const value_t *property, const uiCallContext_t *context, uiAction_t *value)
uiValue_t * UI_GetVariable(const uiCallContext_t *context, int relativeVarId)
Return a variable from the context.
static void UI_ExecuteCallAction(const uiAction_t *action, const uiCallContext_t *context)
void UI_ExecuteConFuncActions(uiNode_t *source, const uiAction_t *firstAction)
allow to inject command param into cmd of confunc command
static void UI_ExecuteAction(const uiAction_t *action, uiCallContext_t *context)
Execute an action from a source.
static const ui_typedActionToken_t actionTokens[]
List of typed token.
int UI_GetParamNumber(const uiCallContext_t *context)
void UI_FreeStringProperty(void *pointer)
Free a string property if it is allocated into ui_dynStringPool.
const char * UI_GenInjectedString(const char *input, bool addNewLine, const uiCallContext_t *context)
Replace injection identifiers (e.g. <eventParam>) by a value.
static void UI_RemoveListener_f(void)
Remove a function callback from a node event.
@ EA_VALUE_PATHPROPERTY_WITHINJECTION
@ EA_VALUE_CVARNAME_WITHINJECTION
@ EA_VALUE_PATHNODE_WITHINJECTION
const value_t * UI_GetPropertyFromBehaviour(const uiBehaviour_t *behaviour, const char *name)
Get a property from a behaviour or his inheritance It use a dichotomic search.
void(* uiNodeMethod_t)(uiNode_t *node, const struct uiCallContext_s *context)
Signature of a function to bind a node method.
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)
uiNode_t * UI_GetNodeFromExpression(uiAction_t *expression, const uiCallContext_t *context, const value_t **property)
Get a node and a property from an expression.
Internal data use by the UI package.
#define UI_MAX_VARIABLESTACK
bool UI_ExecuteLuaMethod(uiNode_t *node, LUA_FUNCTION fcn, linkedList_t *params, int nparams)
Executes a lua based method defined on the behaviour class of a node.
bool UI_ExecuteLuaConFunc(uiNode_t *node, LUA_FUNCTION fcn)
Executes a lua based confunc node.
Basic lua initialization for the ui.
void UI_ExecuteConfunc(const char *fmt,...)
Executes confunc - just to identify those confuncs in the code - in this frame.
const char * UI_GetStringFromNodeProperty(const uiNode_t *node, const value_t *property)
Return a string from a node property.
void UI_NodeSetPropertyFromRAW(uiNode_t *node, const value_t *property, const void *rawValue, int rawType)
bool UI_NodeSetProperty(uiNode_t *node, const value_t *property, const char *value)
Set node property.
C interface to allow to access to cpp node code.
memPool_t * ui_dynStringPool
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...
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).
bool UI_InitRawActionValue(uiAction_t *action, uiNode_t *node, const value_t *property, const char *string)
uiAction_t * UI_AllocStaticAction(void)
Allocate an action.
#define V_UI_NODEMETHOD_LUA