UFO: Alien Invasion
Loading...
Searching...
No Matches
ui_behaviour.h File Reference
Include dependency graph for ui_behaviour.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  uiBehaviour_t
 node behaviour, how a node work More...

Macros

#define UI_RegisterNodeProperty(BEHAVIOUR, NAME, TYPE, OBJECTTYPE, ATTRIBUTE)
 Initialize a property.
#define UI_EXTRADATA_OFFSETOF_(TYPE, MEMBER)
 Return the offset of an extradata node attribute.
#define UI_RegisterExtradataNodeProperty(BEHAVIOUR, NAME, TYPE, EXTRADATATYPE, ATTRIBUTE)
 Initialize a property from extradata of node.
#define UI_RegisterOveridedNodeProperty(BEHAVIOUR, NAME)
 Initialize a property which override an inherited property. It is yet only used for the documentation.

Typedefs

typedef void(* uiNodeMethod_t) (uiNode_t *node, const struct uiCallContext_s *context)
 Signature of a function to bind a node method.

Functions

const struct value_s * UI_RegisterNodePropertyPosSize_ (uiBehaviour_t *behaviour, const char *name, int type, size_t pos, size_t size)
 Register a property to a behaviour. It should not be used in the code.
const struct value_s * UI_RegisterNodeMethod (uiBehaviour_t *behaviour, const char *name, uiNodeMethod_t function)
 Register a node method to a behaviour.
const struct value_s * UI_GetPropertyFromBehaviour (const uiBehaviour_t *behaviour, const char *name) __attribute__((warn_unused_result))
 Return a property from a node behaviour.
const value_tUI_GetPropertyOrLuaMethod (const uiNode_t *node, const char *name, value_t *out)
 Return a property or lua based method from a node, node behaviour or inherited behaviour.
void UI_InitializeNodeBehaviour (uiBehaviour_t *behaviour)
 Initialize a node behaviour memory, after registration, and before using it.
void UI_AddBehaviourMethod (uiBehaviour_t *behaviour, const char *name, LUA_METHOD fcn)
 Adds a lua based method to the list of available behaviour methods for calling.
bool UI_HasBehaviourMethod (uiBehaviour_t *behaviour, const char *name)
 Returns true if a node method of given name is available on this behaviour or its super.
bool UI_GetBehaviourMethod (const uiBehaviour_t *behaviour, const char *name, LUA_METHOD &fcn)
 Finds the lua based method on this behaviour or its super.

Macro Definition Documentation

◆ UI_EXTRADATA_OFFSETOF_

#define UI_EXTRADATA_OFFSETOF_ ( TYPE,
MEMBER )
Value:
((size_t) &((TYPE *)(UI_EXTRADATA_POINTER(0, TYPE)))->MEMBER)
#define UI_EXTRADATA_POINTER(NODE, TYPE)
Return extradata structure from a node.
Definition ui_nodes.h:184

Return the offset of an extradata node attribute.

Parameters
TYPEExtradata type
MEMBERAttribute name
See also
offsetof

Definition at line 99 of file ui_behaviour.h.

◆ UI_RegisterExtradataNodeProperty

#define UI_RegisterExtradataNodeProperty ( BEHAVIOUR,
NAME,
TYPE,
EXTRADATATYPE,
ATTRIBUTE )
Value:
UI_RegisterNodePropertyPosSize_(BEHAVIOUR, NAME, TYPE, UI_EXTRADATA_OFFSETOF_(EXTRADATATYPE, ATTRIBUTE), MEMBER_SIZEOF(EXTRADATATYPE, ATTRIBUTE))
#define MEMBER_SIZEOF(TYPE, MEMBER)
Definition scripts.h:34
const struct value_s * UI_RegisterNodePropertyPosSize_(uiBehaviour_t *behaviour, const char *name, int type, size_t pos, size_t size)
Register a property to a behaviour. It should not be used in the code.
#define UI_EXTRADATA_OFFSETOF_(TYPE, MEMBER)
Return the offset of an extradata node attribute.

Initialize a property from extradata of node.

Parameters
BEHAVIOURbehaviour Target behaviour
NAMEName of the property
TYPEType of the property
EXTRADATATYPEObject type containing the property
ATTRIBUTEName of the attribute of the object containing data of the property

Definition at line 109 of file ui_behaviour.h.

Referenced by UI_RegisterAbstractOptionNode(), UI_RegisterAbstractScrollableNode(), UI_RegisterAbstractScrollbarNode(), UI_RegisterAbstractValueNode(), UI_RegisterBarNode(), UI_RegisterBaseInventoryNode(), UI_RegisterBaseLayoutNode(), UI_RegisterButtonNode(), UI_RegisterCheckBoxNode(), UI_RegisterContainerNode(), UI_RegisterDataNode(), UI_RegisterGeoscapeNode(), UI_RegisterImageNode(), UI_RegisterItemNode(), UI_RegisterLineChartNode(), UI_RegisterModelNode(), UI_RegisterOptionListNode(), UI_RegisterOptionNode(), UI_RegisterOptionTreeNode(), UI_RegisterPanelNode(), UI_RegisterRadioButtonNode(), UI_RegisterRowsNode(), UI_RegisterSequenceNode(), UI_RegisterSpinnerNode(), UI_RegisterStringNode(), UI_RegisterTBarNode(), UI_RegisterTextEntryNode(), UI_RegisterTextNode(), UI_RegisterTimerNode(), UI_RegisterVideoNode(), UI_RegisterWindowNode(), and UI_RegisterZoneNode().

◆ UI_RegisterNodeProperty

#define UI_RegisterNodeProperty ( BEHAVIOUR,
NAME,
TYPE,
OBJECTTYPE,
ATTRIBUTE )
Value:
UI_RegisterNodePropertyPosSize_(BEHAVIOUR, NAME, TYPE, offsetof(OBJECTTYPE, ATTRIBUTE), MEMBER_SIZEOF(OBJECTTYPE, ATTRIBUTE))

Initialize a property.

Parameters
BEHAVIOURbehaviour Target behaviour
NAMEName of the property
TYPEType of the property
OBJECTTYPEObject type containing the property
ATTRIBUTEName of the attribute of the object containing data of the property

Definition at line 91 of file ui_behaviour.h.

Referenced by UI_RegisterAbstractNode(), UI_RegisterImageNode(), UI_RegisterRowsNode(), UI_RegisterTextureNode(), and UI_RegisterVScrollbarNode().

◆ UI_RegisterOveridedNodeProperty

#define UI_RegisterOveridedNodeProperty ( BEHAVIOUR,
NAME )
Value:
;

Initialize a property which override an inherited property. It is yet only used for the documentation.

Parameters
BEHAVIOURbehaviour Target behaviour
NAMEName of the property

Definition at line 117 of file ui_behaviour.h.

Referenced by UI_RegisterDataNode(), and UI_RegisterTextEntryNode().

Typedef Documentation

◆ uiNodeMethod_t

typedef void(* uiNodeMethod_t) (uiNode_t *node, const struct uiCallContext_s *context)

Signature of a function to bind a node method.

Definition at line 67 of file ui_behaviour.h.

Function Documentation

◆ UI_AddBehaviourMethod()

void UI_AddBehaviourMethod ( uiBehaviour_t * behaviour,
const char * name,
LUA_METHOD fcn )

Adds a lua based method to the list of available behaviour methods for calling.

Parameters
[in]behaviourThe behaviour to extend.
[in]nameThe name of the new method to add
[in]fcnThe lua based function reference.
Note
If the method name is already defined, the new method is not added and a warning will be issued in the log.

Definition at line 251 of file ui_behaviour.cpp.

References Com_Printf(), HASH_Insert(), HASH_NewTable(), name, uiBehaviour_t::name, and uiBehaviour_t::nodeMethods.

Referenced by uiNode_t_add_classmethod().

◆ UI_GetBehaviourMethod()

bool UI_GetBehaviourMethod ( const uiBehaviour_t * behaviour,
const char * name,
LUA_METHOD & fcn )

Finds the lua based method on this behaviour or its super.

Parameters
[in]behaviourThe node behaviour to examine.
[in]nameThe name of the method to find
[out]fcnA reference to a LUA_METHOD value to the corresponding lua based function or to LUA_NOREF if the method is not found
Returns
True if the method is found, false otherwise.

Definition at line 272 of file ui_behaviour.cpp.

References HASH_Get(), name, uiBehaviour_t::nodeMethods, and uiBehaviour_t::super.

Referenced by UI_GetNodeMethod(), UI_HasBehaviourMethod(), and UI_HasNodeMethod().

◆ UI_GetPropertyFromBehaviour()

const struct value_s * UI_GetPropertyFromBehaviour ( const uiBehaviour_t * behaviour,
const char * name )

Return a property from a node behaviour.

Returns
A property, else nullptr if not found.

Return a property from a node behaviour.

Parameters
[in]behaviourContext behaviour
[in]nameProperty name we search
Returns
A value_t with the requested name, else nullptr

Definition at line 100 of file ui_behaviour.cpp.

References uiBehaviour_t::localProperties, name, uiBehaviour_t::propertyCount, Q_strcasecmp, value_t::string, and uiBehaviour_t::super.

Referenced by uiFuncNode::onLoaded(), uiPanelNode::onPropertyChanged(), uiConFuncNode::onWindowClosed(), uiConFuncNode::onWindowOpened(), UI_GenInjectedString(), UI_GetPropertyOrLuaMethod(), UI_InitializeNodeBehaviour(), UI_ParseNodeBody(), UI_ParseNodeProperties(), and UI_Window_SetCloseButton().

◆ UI_GetPropertyOrLuaMethod()

const value_t * UI_GetPropertyOrLuaMethod ( const uiNode_t * node,
const char * name,
value_t * out )

Return a property or lua based method from a node, node behaviour or inherited behaviour.

Returns
A local property or lua method, else nullptr if not found.
Note
Important: in case of a lua method, free the allocated .string value holding the method name!!!

Return a property or lua based method from a node, node behaviour or inherited behaviour.

Parameters
[in]nodeThe node holding the method
[in]nameProperty name we search
[out]outA reference to a value_t structure wich is filled if a lua based method is available. Set to nullptr to onlys scan for properties and not for lua based methods.
Returns
A value_t with the requested name, else nullptr
Note
This function first searches the local properties of the behaviour before looking into lua based functions.
If a lua function is found, .type is set to V_UI_NODEMETHOD_LUA, .string is set to the method name and .ofs is set to the lua callback id of the function.
After use, be sure to free the allocated .string value!!!

Definition at line 136 of file ui_behaviour.cpp.

References uiNode_t::behaviour, Mem_StrDup, name, value_t::ofs, value_t::size, value_t::string, value_t::type, UI_GetNodeMethod(), UI_GetPropertyFromBehaviour(), and V_UI_NODEMETHOD_LUA.

Referenced by UI_ReadNodePath().

◆ UI_HasBehaviourMethod()

bool UI_HasBehaviourMethod ( uiBehaviour_t * behaviour,
const char * name )

Returns true if a node method of given name is available on this behaviour or its super.

Parameters
[in]behaviourThe node behaviour to examine.
[in]nameThe name of the method to find
Returns
True if the method is found, false otherwise.

Definition at line 292 of file ui_behaviour.cpp.

References name, and UI_GetBehaviourMethod().

◆ UI_InitializeNodeBehaviour()

void UI_InitializeNodeBehaviour ( uiBehaviour_t * behaviour)

Initialize a node behaviour memory, after registration, and before using it.

Parameters
behaviourBehaviour to initialize
behaviourBehaviour to initialize
Note
This method sets the SWIG type for this behaviour for the runtime conversion of uiNode_t* values to the correct subclass.
Todo
Find a way to remove that, if possible

<

Todo
not possible at the moment, not sure its the right way

<

Todo
not possible at the moment, not sure its the right way

Definition at line 160 of file ui_behaviour.cpp.

References Com_Error(), ERR_FATAL, uiBehaviour_t::extends, uiBehaviour_t::extraDataSize, i, uiBehaviour_t::isInitialized, uiBehaviour_t::localProperties, uiBehaviour_t::manager, Mem_Free, uiBehaviour_t::name, uiBehaviour_t::propertyCount, Q_strcasecmp, Q_streq, Q_strvalid, value_t::string, STRUCT_MEMORY_ALIGN, uiBehaviour_t::super, UI_AllocHunkMemory(), UI_GetNodeBehaviour(), UI_GetPropertyFromBehaviour(), UI_InitializeNodeBehaviour(), and V_UI_NODEMETHOD.

Referenced by UI_InitializeNodeBehaviour(), and UI_InitNodes().

◆ UI_RegisterNodeMethod()

const struct value_s * UI_RegisterNodeMethod ( uiBehaviour_t * behaviour,
const char * name,
uiNodeMethod_t function )

Register a node method to a behaviour.

Parameters
behaviourTarget behaviour
nameName of the property
functionfunction to execute the node method
Returns
A link to the node property

Definition at line 88 of file ui_behaviour.cpp.

References name, UI_RegisterNodePropertyPosSize_(), and V_UI_NODEMETHOD.

Referenced by UI_RegisterAbstractNode(), UI_RegisterAbstractScrollableNode(), UI_RegisterCheckBoxNode(), UI_RegisterCvarFuncNode(), UI_RegisterEditorNode(), UI_RegisterGeoscapeNode(), UI_RegisterOptionTreeNode(), and UI_RegisterTextEntryNode().

◆ UI_RegisterNodePropertyPosSize_()

const struct value_s * UI_RegisterNodePropertyPosSize_ ( uiBehaviour_t * behaviour,
const char * name,
int type,
size_t pos,
size_t size )

Register a property to a behaviour. It should not be used in the code.

Parameters
behaviourTarget behaviour
nameName of the property
typeType of the property
posposition of the attribute (which store property memory) into the node structure
sizesize of the attribute (which store property memory) into the node structure
See also
UI_RegisterNodeProperty
UI_RegisterExtradataNodeProperty
Returns
A link to the node property

Definition at line 53 of file ui_behaviour.cpp.

References Com_Error(), ERR_FATAL, LOCAL_PROPERTY_SIZE, uiBehaviour_t::localProperties, Mem_PoolAllocTypeN, name, uiBehaviour_t::name, uiBehaviour_t::propertyCount, STRUCT_MEMORY_ALIGN, type, UI_AllocHunkMemory(), ui_sysPool, V_CVAR_OR_LONGSTRING, V_CVAR_OR_STRING, V_LONGSTRING, and V_STRING.

Referenced by UI_RegisterNodeMethod().