ui_parse.c File Reference

#include "../client.h"
#include "ui_parse.h"
#include "ui_main.h"
#include "ui_data.h"
#include "ui_internal.h"
#include "ui_actions.h"
#include "ui_icon.h"
#include "ui_components.h"
#include "node/ui_node_window.h"
#include "node/ui_node_selectbox.h"
#include "node/ui_node_abstractnode.h"
#include "node/ui_node_abstractoption.h"
#include "../../shared/parse.h"
Include dependency graph for ui_parse.c:

Go to the source code of this file.

Functions

static qboolean UI_ParseProperty (void *object, const value_t *property, const char *objectName, const char **text, const char **token)
 Parse a property value.
static uiAction_tUI_ParseActionList (uiNode_t *node, const char **text, const const char **token)
 Parse actions and return action list.
static uiNode_tUI_ParseNode (uiNode_t *parent, const char **text, const char **token, const char *errhead)
 parse a node
static qboolean UI_TokenIsReserved (const char *name)
static qboolean UI_TokenIsValue (const char *name, qboolean isQuoted)
static qboolean UI_TokenIsName (const char *name, qboolean isQuoted)
const value_tUI_FindPropertyByName (const value_t *propertyList, const char *name)
 Find a value_t by name into a array of value_t.
float * UI_AllocStaticFloat (int count)
 Allocate a float into the UI static memory.
vec4_tUI_AllocStaticColor (int count)
 Allocate a color into the UI static memory.
char * UI_AllocStaticString (const char *string, int size)
 Allocate a string into the UI static memory.
uiAction_tUI_AllocStaticAction (void)
 Allocate an action.
qboolean UI_InitRawActionValue (uiAction_t *action, uiNode_t *node, const value_t *property, const char *string)
static qboolean UI_ParseSetAction (uiNode_t *node, uiAction_t *action, const char **text, const char **token, const char *errhead)
 Parser for setter command.
static qboolean UI_ParseCallAction (uiNode_t *node, uiAction_t *action, const char **text, const char **token, const char *errhead)
 Parser for c command.
static qboolean UI_ParseExcludeRect (uiNode_t *node, const char **text, const char **token, const char *errhead)
static qboolean UI_ParseEventProperty (uiNode_t *node, const value_t *event, const char **text, const char **token, const char *errhead)
static qboolean UI_ParseFunction (uiNode_t *node, const char **text, const char **token)
static qboolean UI_ParseNodeProperties (uiNode_t *node, const char **text, const char **token)
 parse all sequencial properties into a block
static qboolean UI_ParseNodeBody (uiNode_t *node, const char **text, const char **token, const char *errhead)
 Read a node body.
void UI_ParseUIModel (const char *name, const char **text)
 parses the models.ufo and all files where UI models (menu_model) are defined
void UI_ParseIcon (const char *name, const char **text)
void UI_ParseComponent (const char *type, const char **text)
 Parse a component.
void UI_ParseWindow (const char *type, const char *name, const char **text)
 Parse a window.
const char * UI_GetReferenceString (const uiNode_t *const node, const char *ref)
float UI_GetReferenceFloat (const uiNode_t *const node, const void *ref)

Variables

static const value_t uiModelProperties []
 valid properties for a UI model definition
static const char * reserved_tokens []
 reserved token preventing calling a node with it

Detailed Description

Todo:

remove all "token" param from function and use Com_UnParseLastToken

reduce use of uiGlobal (create global functions to add/get/... entities)

Definition in file ui_parse.c.


Function Documentation

uiAction_t* UI_AllocStaticAction ( void   )  [read]
vec4_t* UI_AllocStaticColor ( int  count  ) 

Allocate a color into the UI static memory.

Note:
Its not a dynamic memory allocation. Please only use it at the loading time
Parameters:
[in] count number of element need to allocate
Todo:
Assert out when we are not in parsing/loading stage

Definition at line 185 of file ui_parse.c.

References uiGlobal_s::adata, uiGlobal_s::adataize, Com_Error(), uiGlobal_s::curadata, ERR_FATAL, and ui_global.

float* UI_AllocStaticFloat ( int  count  ) 

Allocate a float into the UI static memory.

Note:
Its not a dynamic memory allocation. Please only use it at the loading time
Parameters:
[in] count number of element need to allocate
Todo:
Assert out when we are not in parsing/loading stage

Definition at line 167 of file ui_parse.c.

References uiGlobal_s::adata, uiGlobal_s::adataize, Com_Error(), uiGlobal_s::curadata, ERR_FATAL, and ui_global.

Referenced by UI_CloneCvarOrFloat(), and UI_InitCvarOrFloat().

char* UI_AllocStaticString ( const char *  string,
int  size 
)

Allocate a string into the UI static memory.

Note:
Its not a dynamic memory allocation. Please only use it at the loading time
Parameters:
[in] string Use to initialize the string
[in] size request a fixed memory size, if 0 the string size is used
Todo:
Assert out when we are not in parsing/loading stage

Definition at line 204 of file ui_parse.c.

References uiGlobal_s::adata, uiGlobal_s::adataize, Com_Error(), uiGlobal_s::curadata, ERR_FATAL, and ui_global.

Referenced by UI_AutoGenerateIcon(), UI_InitRawActionValue(), UI_ModelNodeClone(), UI_ModelNodeLoaded(), UI_ParseActionList(), UI_ParseSetAction(), and UI_ParseValueExpression().

const value_t* UI_FindPropertyByName ( const value_t propertyList,
const char *  name 
)

Find a value_t by name into a array of value_t.

Parameters:
[in] propertyList Array of value_t, with null termination
[in] name Property name we search
Returns:
A value_t with the requested name, else NULL

Definition at line 150 of file ui_parse.c.

References Q_strcasecmp, and value_s::string.

Referenced by UI_GetPropertyFromBehaviour(), UI_MaterialEditorChangeValue_f(), UI_ParseIcon(), and UI_ParseUIModel().

float UI_GetReferenceFloat ( const uiNode_t *const   node,
const void *  ref 
)
const char* UI_GetReferenceString ( const uiNode_t *const   node,
const char *  ref 
)
qboolean UI_InitRawActionValue ( uiAction_t action,
uiNode_t node,
const value_t property,
const char *  string 
)

Parse a string according to a property type, and allocate a raw value to the static memory

Parameters:
action Action to initialize
node Current node we are parsing, only used for error message
property Type of the value to parse, if NULL the string is not stored as string
string String value to parse
Returns:
True if the action is initialized
Todo:
remove node param and catch error where we call that function

Todo:
we should hide use of ui_global.curadata

Definition at line 242 of file ui_parse.c.

References Com_AlignPtr(), Com_EParseValue(), Com_Printf(), uiGlobal_s::curadata, uiAction_s::d, EA_VALUE_RAW, EA_VALUE_STRING, qfalse, qtrue, value_s::size, value_s::string, uiAction_s::terminal, value_s::type, uiAction_s::type, UI_AllocStaticString(), UI_GetIconByName(), UI_GetPath(), ui_global, V_BASETYPEMASK, V_UI_CVAR, V_UI_ICONREF, and V_UI_MASK.

Referenced by UI_NodeSetPropertyFromActionValue(), and UI_ParseSetAction().

static uiAction_t * UI_ParseActionList ( uiNode_t node,
const char **  text,
const const char **  token 
) [static]

Parse actions and return action list.

Returns:
The first element from a list of action
See also:
ea_t
Todo:
need cleanup, compute action out of the final memory; reduce number of var

Todo:
better to append the action after initialization

Definition at line 431 of file ui_parse.c.

References Com_EParse(), Com_Printf(), uiAction_s::d, EA_ACTION, EA_ASSIGN, EA_CALL, EA_CMD, EA_DELETE, EA_ELIF, EA_ELSE, EA_IF, EA_NULL, EA_VALUE_CVARNAME, EA_WHILE, uiAction_s::next, uiAction_s::nonTerminal, qfalse, qtrue, uiAction_s::terminal, uiAction_s::type, type, UI_AllocStaticAction(), UI_AllocStaticString(), UI_GetActionTokenType(), UI_GetPath(), UI_ParseCallAction(), UI_ParseExpression(), and UI_ParseSetAction().

Referenced by UI_ParseEventProperty(), UI_ParseFunction(), and UI_ParseSetAction().

static qboolean UI_ParseCallAction ( uiNode_t node,
uiAction_t action,
const char **  text,
const char **  token,
const char *  errhead 
) [static]
void UI_ParseComponent ( const char *  type,
const char **  text 
)

Parse a component.

See also:
CL_ParseClientData
 component panel componentName {
 }

Definition at line 1256 of file ui_parse.c.

References Com_Error(), Com_Parse(), Com_UnParseLastToken(), ERR_FATAL, UI_InsertComponent(), and UI_ParseNode().

Referenced by CL_ParseClientData().

static qboolean UI_ParseEventProperty ( uiNode_t node,
const value_t event,
const char **  text,
const char **  token,
const char *  errhead 
) [static]
static qboolean UI_ParseExcludeRect ( uiNode_t node,
const char **  text,
const char **  token,
const char *  errhead 
) [static]
static qboolean UI_ParseFunction ( uiNode_t node,
const char **  text,
const char **  token 
) [static]
void UI_ParseIcon ( const char *  name,
const char **  text 
)
static uiNode_t * UI_ParseNode ( uiNode_t parent,
const char **  text,
const char **  token,
const char *  errhead 
) [static]

parse a node

See also:
UI_ParseNodeProperties
Todo:
we can think about merging UI_ParseNodeProperties here
Note:
first token already read
dont read more than the need token (last right token is '}' of end of node)

Todo:
move it into caller

Definition at line 1045 of file ui_parse.c.

References uiNode_s::behaviour, Com_DPrintf(), Com_EParse(), Com_ParsedTokenIsQuoted(), Com_Printf(), DEBUG_CLIENT, uiBehaviour_s::loaded, uiBehaviour_s::name, uiNode_s::parent, Q_strcasecmp, qfalse, qtrue, uiNode_s::root, UI_AllocNode(), UI_AppendNode(), UI_CloneNode(), UI_GetComponent(), UI_GetNode(), UI_GetNodeBehaviour(), UI_GetPath(), UI_ParseNodeBody(), UI_TokenIsName(), UI_TokenIsReserved(), and UI_UpdateRoot().

Referenced by UI_ParseComponent(), and UI_ParseNodeBody().

static qboolean UI_ParseNodeBody ( uiNode_t node,
const char **  text,
const char **  token,
const char *  errhead 
) [static]

Read a node body.

Note:
Node header already read, we are over the node name, or '{'
 Allowed syntax
 { properties }
 OR
 { nodes }
 OR
 { { properties } nodes }

Definition at line 964 of file ui_parse.c.

References uiNode_s::behaviour, Com_EParse(), Com_Printf(), uiBehaviour_s::isFunction, uiNode_s::name, uiGlobal_s::numNodes, qfalse, qtrue, UI_GetPath(), UI_GetPropertyFromBehaviour(), ui_global, UI_ParseFunction(), UI_ParseNode(), and UI_ParseNodeProperties().

Referenced by UI_ParseNode(), and UI_ParseWindow().

static qboolean UI_ParseNodeProperties ( uiNode_t node,
const char **  text,
const char **  token 
) [static]

parse all sequencial properties into a block

See also:
UI_ParseNodeProperties
Note:
allow to use an extra block
 foobehaviour foonode {
   { properties }
   // the function stop reading here
   nodes
 }
 foobehaviour foonode {
   properties
   // the function stop reading here
   nodes
 }

Definition at line 905 of file ui_parse.c.

References uiNode_s::behaviour, Com_EParse(), Com_Printf(), uiNode_s::name, qfalse, qtrue, value_s::string, UI_GetPath(), UI_GetPropertyFromBehaviour(), and UI_ParseProperty().

Referenced by UI_ParseNodeBody().

static qboolean UI_ParseProperty ( void *  object,
const value_t property,
const char *  objectName,
const char **  text,
const char **  token 
) [static]
static qboolean UI_ParseSetAction ( uiNode_t node,
uiAction_t action,
const char **  text,
const char **  token,
const char *  errhead 
) [static]
void UI_ParseUIModel ( const char *  name,
const char **  text 
)
void UI_ParseWindow ( const char *  type,
const char *  name,
const char **  text 
)
static qboolean UI_TokenIsName ( const char *  name,
qboolean  isQuoted 
) [static]

Definition at line 122 of file ui_parse.c.

References qfalse, and qtrue.

Referenced by UI_ParseNode(), and UI_ParseWindow().

static qboolean UI_TokenIsReserved ( const char *  name  )  [static]

Definition at line 78 of file ui_parse.c.

References qfalse, and qtrue.

Referenced by UI_ParseNode(), and UI_ParseWindow().

static qboolean UI_TokenIsValue ( const char *  name,
qboolean  isQuoted 
) [static]

Definition at line 89 of file ui_parse.c.

References qfalse, and qtrue.

Referenced by UI_ParseProperty().


Variable Documentation

const char* reserved_tokens[] [static]
Initial value:
 {
    "this",
    "parent",
    "root",
    "null",
    "super",
    "node",
    "cvar",
    "int",
    "float",
    "string",
    "var",
    NULL
}

reserved token preventing calling a node with it

Todo:
Use dichotomic search

Definition at line 63 of file ui_parse.c.

const value_t uiModelProperties[] [static]
Initial value:
 {
    {"model", V_CLIENT_HUNK_STRING, offsetof(uiModel_t, model), 0},
    {"need", V_NULL, 0, 0},
    {"anim", V_CLIENT_HUNK_STRING, offsetof(uiModel_t, anim), 0},
    {"skin", V_INT, offsetof(uiModel_t, skin), sizeof(int)},
    {"color", V_COLOR, offsetof(uiModel_t, color), sizeof(vec4_t)},
    {"tag", V_CLIENT_HUNK_STRING, offsetof(uiModel_t, tag), 0},
    {"parent", V_CLIENT_HUNK_STRING, offsetof(uiModel_t, parent), 0},

    {NULL, V_NULL, 0, 0},
}

valid properties for a UI model definition

Definition at line 48 of file ui_parse.c.


Generated by  doxygen 1.6.2