UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ui_actions.h
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 #pragma once
26 
27 #include "../../common/common.h"
28 
33 typedef enum uiActionType_s {
34  EA_NULL = 0,
35 
38 
39  /* masks */
40  EA_HIGHT_MASK = 0xFF00,
41 
42  /* actions */
43  EA_ACTION = 0x0100,
57 
58  /* boolean to boolean operators */
64 
65  /* float to boolean operators */
74  /* float to float operators */
81 
82  /* string operators */
87  /* unary operators */
93  /* terminal values (leafs) */
94  EA_VALUE = 0x0A00,
116 
117 
118 
124 typedef union uiTerminalActionData_s {
125  int integer;
126  float number;
127  const char* constString;
128  void* data;
129  const void* constData;
131 
144 typedef struct uiAction_s {
149  short type;
150 
154  short subType;
155 
159  union {
164  struct {
165  struct uiAction_s* left;
166  struct uiAction_s* right;
167  } nonTerminal;
168 
174  struct {
177  } terminal;
178  } d;
179 
183  struct uiAction_s* next;
184 } uiAction_t;
185 
186 /* prototype */
187 struct uiNode_t;
188 struct cvar_s;
189 
194 typedef struct uiValue_s {
196  union {
197  int integer;
198  float number;
199  char* string;
200  struct cvar_s* cvar;
202  } value;
203 } uiValue_t;
204 
208 typedef struct uiCallContext_s {
220  bool breakLoop;
222 
223 void UI_ExecuteEventActions(uiNode_t* source, const uiAction_t* firstAction);
224 void UI_ExecuteConFuncActions(uiNode_t* source, const uiAction_t* firstAction);
225 void UI_ExecuteEventActionsEx (uiNode_t* source, const uiAction_t* firstAction, linkedList_t* params);
226 bool UI_IsInjectedString(const char* string);
227 void UI_FreeStringProperty(void* pointer);
228 const char* UI_GenInjectedString(const char* input, bool addNewLine, const uiCallContext_t* context);
229 int UI_GetActionTokenType(const char* token, int group);
230 uiValue_t* UI_GetVariable (const uiCallContext_t* context, int relativeVarId);
231 
232 void UI_PoolAllocAction(uiAction_t** action, int type, const void* data);
233 uiAction_t* UI_AllocStaticCommandAction(const char* command);
234 void UI_InitActions(void);
235 void UI_AddListener(uiNode_t* node, const value_t* property, uiNode_t const* functionNode);
236 void UI_RemoveListener(uiNode_t* node, const value_t* property, uiNode_t* functionNode);
237 
238 const char* UI_GetParam(const uiCallContext_t* context, int paramID);
239 int UI_GetParamNumber(const uiCallContext_t* context);
struct uiAction_s uiAction_t
Atomic element to store UI scripts The parser use this atom to translate script action into many tree...
struct uiAction_s::@14::@16 terminal
Stores a terminal action (a value, which must be a leaf in the tree)
QGL_EXTERN GLint GLenum type
Definition: r_gl.h:94
uiActionType_t type
Definition: ui_actions.h:195
union uiTerminalActionData_s uiTerminalActionData_t
Defines the data of a uiAction_t leaf. It allows different kind of data without cast.
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
Definition: cvar.h:71
void UI_ExecuteConFuncActions(uiNode_t *source, const uiAction_t *firstAction)
allow to inject command param into cmd of confunc command
Definition: ui_actions.cpp:717
QGL_EXTERN GLint GLenum GLboolean GLsizei const GLvoid * pointer
Definition: r_gl.h:94
void UI_InitActions(void)
struct uiAction_s * right
Definition: ui_actions.h:166
void UI_FreeStringProperty(void *pointer)
Free a string property if it is allocated into ui_dynStringPool.
Definition: ui_actions.cpp:778
union uiAction_s::@14 d
Stores data about the action.
uiAction_t * UI_AllocStaticCommandAction(const char *command)
Allocate and initialize a command action.
Definition: ui_actions.cpp:796
struct cvar_s * cvar
Definition: ui_actions.h:200
int UI_GetParamNumber(const uiCallContext_t *context)
Definition: ui_actions.cpp:166
uiTerminalActionData_t d2
Definition: ui_actions.h:176
char * string
Definition: ui_actions.h:199
struct uiAction_s::@14::@15 nonTerminal
Stores a none terminal action (a command or an operator)
uiActionType_s
Type for uiAction_t It also contain type about type (for example EA_BINARYOPERATOR) ...
Definition: ui_actions.h:33
void UI_ExecuteEventActionsEx(uiNode_t *source, const uiAction_t *firstAction, linkedList_t *params)
Definition: ui_actions.cpp:735
void UI_PoolAllocAction(uiAction_t **action, int type, const void *data)
Set a new action to a uiAction_t pointer.
Definition: ui_actions.cpp:814
void UI_AddListener(uiNode_t *node, const value_t *property, uiNode_t const *functionNode)
Add a callback of a function into a node event. There can be more than on listener.
Definition: ui_actions.cpp:835
int UI_GetActionTokenType(const char *token, int group)
return an action type from a token, and a group
Definition: ui_actions.cpp:113
uiNode_t * source
Definition: ui_actions.h:210
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. ...
Definition: ui_actions.cpp:906
linkedList_t * params
Definition: ui_actions.h:215
Atomic structure used to define most of the UI.
Definition: ui_nodes.h:80
uiValue_t * UI_GetVariable(const uiCallContext_t *context, int relativeVarId)
Return a variable from the context.
Definition: ui_actions.cpp:517
struct uiValue_s uiValue_t
Type for uiAction_t It also contain type about type (for example EA_BINARYOPERATOR) ...
uiNode_t * tagNode
Definition: ui_actions.h:212
Contain the context of the calling of a function.
Definition: ui_actions.h:208
float number
Definition: ui_actions.h:198
const void * constData
Definition: ui_actions.h:129
short subType
Some operators/commands/values can use it to store info about the content.
Definition: ui_actions.h:154
uiTerminalActionData_t d1
Definition: ui_actions.h:175
const char * UI_GetParam(const uiCallContext_t *context, int paramID)
Definition: ui_actions.cpp:179
enum uiActionType_s uiActionType_t
Type for uiAction_t It also contain type about type (for example EA_BINARYOPERATOR) ...
union uiValue_s::@17 value
bool UI_IsInjectedString(const char *string)
Test if a string use an injection syntax.
Definition: ui_actions.cpp:751
struct uiAction_s * left
Definition: ui_actions.h:165
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
struct uiAction_s * next
Next element in the action list.
Definition: ui_actions.h:183
Type for uiAction_t It also contain type about type (for example EA_BINARYOPERATOR) ...
Definition: ui_actions.h:194
int integer
Definition: ui_actions.h:197
const char * constString
Definition: ui_actions.h:127
Defines the data of a uiAction_t leaf. It allows different kind of data without cast.
Definition: ui_actions.h:124
uiNode_t * node
Definition: ui_actions.h:201
GLsizei const GLvoid * data
Definition: r_gl.h:152
struct uiCallContext_s uiCallContext_t
Contain the context of the calling of a function.
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
void UI_ExecuteEventActions(uiNode_t *source, const uiAction_t *firstAction)
Definition: ui_actions.cpp:726