ui_actions.h

Go to the documentation of this file.
00001 
00005 /*
00006 Copyright (C) 2002-2010 UFO: Alien Invasion.
00007 
00008 This program is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU General Public License
00010 as published by the Free Software Foundation; either version 2
00011 of the License, or (at your option) any later version.
00012 
00013 This program is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016 
00017 See the GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with this program; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00023 */
00024 
00025 #ifndef CLIENT_UI_UI_ACTIONS_H
00026 #define CLIENT_UI_UI_ACTIONS_H
00027 
00028 #include "../../common/common.h"
00029 
00034 typedef enum uiActionType_s {
00035     EA_NULL = 0,
00036 
00037     EA_BINARYOPERATOR,
00038     EA_UNARYOPERATOR,
00039 
00040     /* masks */
00041     EA_HIGHT_MASK = 0xFF00,
00042 
00043     /* actions */
00044     EA_ACTION = 0x0100,
00045     EA_CMD = EA_ACTION + 1,
00046     EA_CALL = EA_ACTION + 2,
00047     EA_ASSIGN = EA_ACTION + 3,
00048     EA_IF = EA_ACTION + 4,
00049     EA_ELSE = EA_ACTION + 5,
00050     EA_ELIF = EA_ACTION + 6,
00051     EA_WHILE = EA_ACTION + 7,
00052     EA_DELETE = EA_ACTION + 8,
00053     EA_LISTENER = EA_ACTION + 9,
00054     EA_PUSHVARS = EA_ACTION + 10,
00055     EA_POPVARS = EA_ACTION + 11,
00056 
00057     /* boolean to boolean operators */
00058     EA_OPERATOR_BOOLEAN2BOOLEAN = 0x0300,
00059     EA_OPERATOR_AND = EA_OPERATOR_BOOLEAN2BOOLEAN + 1,
00060     EA_OPERATOR_OR = EA_OPERATOR_BOOLEAN2BOOLEAN + 2,
00061     EA_OPERATOR_XOR = EA_OPERATOR_BOOLEAN2BOOLEAN + 3,
00062     EA_OPERATOR_NOT = EA_OPERATOR_BOOLEAN2BOOLEAN + 4,
00063 
00064     /* float to boolean operators */
00065     EA_OPERATOR_FLOAT2BOOLEAN = 0x0400,
00066     EA_OPERATOR_EQ = EA_OPERATOR_FLOAT2BOOLEAN + 1, 
00067     EA_OPERATOR_LE = EA_OPERATOR_FLOAT2BOOLEAN + 2, 
00068     EA_OPERATOR_GE = EA_OPERATOR_FLOAT2BOOLEAN + 3, 
00069     EA_OPERATOR_GT = EA_OPERATOR_FLOAT2BOOLEAN + 4, 
00070     EA_OPERATOR_LT = EA_OPERATOR_FLOAT2BOOLEAN + 5, 
00071     EA_OPERATOR_NE = EA_OPERATOR_FLOAT2BOOLEAN + 6, 
00073     /* float to float operators */
00074     EA_OPERATOR_FLOAT2FLOAT = 0x0500,
00075     EA_OPERATOR_ADD = EA_OPERATOR_FLOAT2FLOAT + 1,
00076     EA_OPERATOR_SUB = EA_OPERATOR_FLOAT2FLOAT + 2,
00077     EA_OPERATOR_MUL = EA_OPERATOR_FLOAT2FLOAT + 3,
00078     EA_OPERATOR_DIV = EA_OPERATOR_FLOAT2FLOAT + 4,
00079     EA_OPERATOR_MOD = EA_OPERATOR_FLOAT2FLOAT + 5,
00080 
00081     /* string operators */
00082     EA_OPERATOR_STRING2BOOLEAN = 0x0600,
00083     EA_OPERATOR_STR_EQ = EA_OPERATOR_STRING2BOOLEAN + 1,    
00084     EA_OPERATOR_STR_NE = EA_OPERATOR_STRING2BOOLEAN + 2,    
00086     /* unary operators */
00087     EA_OPERATOR_UNARY = 0x0700,
00088     EA_OPERATOR_EXISTS = EA_OPERATOR_UNARY + 1,             
00089     EA_OPERATOR_PATHFROM = EA_OPERATOR_UNARY + 2,           
00090     EA_OPERATOR_PATHPROPERTYFROM = EA_OPERATOR_UNARY + 3,   
00092     /* terminal values (leafs) */
00093     EA_VALUE = 0x0A00,
00094     EA_VALUE_STRING = EA_VALUE + 1,                     
00095     EA_VALUE_STRING_WITHINJECTION = EA_VALUE + 2,       
00096     EA_VALUE_FLOAT = EA_VALUE + 3,                      
00097     EA_VALUE_RAW = EA_VALUE + 4,                        
00098     EA_VALUE_CVARNAME = EA_VALUE + 5,                   
00099     EA_VALUE_CVARNAME_WITHINJECTION = EA_VALUE + 6,     
00100     EA_VALUE_PATHNODE = EA_VALUE + 7,                   
00101     EA_VALUE_PATHNODE_WITHINJECTION = EA_VALUE + 8,     
00102     EA_VALUE_PATHPROPERTY = EA_VALUE + 9,               
00103     EA_VALUE_PATHPROPERTY_WITHINJECTION = EA_VALUE + 10,
00104     EA_VALUE_NODEPROPERTY = EA_VALUE + 11,              
00105     EA_VALUE_VAR = EA_VALUE + 12,                       
00106     EA_VALUE_CVAR = EA_VALUE + 13,                      
00107     EA_VALUE_NODE = EA_VALUE + 14,                      
00108     EA_VALUE_PARAM = EA_VALUE + 15,                     
00109     EA_VALUE_PARAMCOUNT = EA_VALUE + 16,                
00110     EA_VALUE_THIS = EA_VALUE + 17,                      
00111     EA_VALUE_WINDOW = EA_VALUE + 18,                    
00112     EA_VALUE_PARENT = EA_VALUE + 19                     
00113 } uiActionType_t;
00114 
00115 
00116 
00122 typedef union {
00123     int integer;
00124     float number;
00125     char* string;
00126     const char* constString;
00127     void* data;
00128     const void* constData;
00129 } uiTerminalActionData_t;
00130 
00143 typedef struct uiAction_s {
00148     short type;
00149 
00153     short subType;
00154 
00158     union {
00163         struct {
00164             struct uiAction_s *left;
00165             struct uiAction_s *right;
00166         } nonTerminal;
00167 
00173         struct {
00174             uiTerminalActionData_t d1;
00175             uiTerminalActionData_t d2;
00176         } terminal;
00177     } d;
00178 
00182     struct uiAction_s *next;
00183 } uiAction_t;
00184 
00185 /* prototype */
00186 struct uiNode_s;
00187 struct cvar_s;
00188 
00193 typedef struct uiValue_s {
00194     uiActionType_t type;    
00195     union {
00196         int integer;
00197         float number;
00198         char* string;
00199         struct cvar_s *cvar;
00200         struct uiNode_s *node;
00201     } value;
00202 } uiValue_t;
00203 
00207 typedef struct uiCallContext_s {
00209     struct uiNode_s* source;
00211     qboolean useCmdParam;
00212     linkedList_t *params;
00213     int paramNumber;
00214     int varPosition;
00215     int varNumber;
00216 } uiCallContext_t;
00217 
00218 
00219 void UI_ExecuteEventActions(struct uiNode_s* source, const uiAction_t* firstAction);
00220 void UI_ExecuteConFuncActions(struct uiNode_s* source, const uiAction_t* firstAction);
00221 qboolean UI_IsInjectedString(const char *string);
00222 void UI_FreeStringProperty(void* pointer);
00223 const char* UI_GenInjectedString(const char* input, qboolean addNewLine, const uiCallContext_t *context);
00224 int UI_GetActionTokenType(const char* token, int group);
00225 uiValue_t* UI_GetVariable (const uiCallContext_t *context, int relativeVarId);
00226 
00227 void UI_PoolAllocAction(uiAction_t** action, int type, const void *data);
00228 uiAction_t* UI_AllocStaticCommandAction(char *command);
00229 void UI_InitActions(void);
00230 void UI_AddListener(struct uiNode_s *node, const value_t *property, struct uiNode_s *functionNode);
00231 void UI_RemoveListener(struct uiNode_s *node, const value_t *property, struct uiNode_s *functionNode);
00232 
00233 const char* UI_GetParam(const uiCallContext_t *context, int paramID);
00234 int UI_GetParamNumber(const uiCallContext_t *context);
00235 
00236 #endif

Generated by  doxygen 1.6.2