UFO: Alien Invasion
Loading...
Searching...
No Matches
ui_behaviour.h
Go to the documentation of this file.
1
4
5/*
6Copyright (C) 2002-2025 UFO: Alien Invasion.
7
8This program is free software; you can redistribute it and/or
9modify it under the terms of the GNU General Public License
10as published by the Free Software Foundation; either version 2
11of the License, or (at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23*/
24
25#pragma once
26
27#include "ui_nodes.h"
29
30struct value_s;
31struct uiBehaviour_t;
32struct uiNode_t;
33struct hashTable_s;
34
40 /* behaviour attributes */
41 const char* name;
42 const char* extends;
45 bool isVirtual;
51
54 intptr_t extraDataSize;
56
59#ifdef DEBUG
60 int count;
61#endif
62};
63
67typedef void (*uiNodeMethod_t)(uiNode_t* node, const struct uiCallContext_s* context);
68
81const struct value_s* UI_RegisterNodePropertyPosSize_(uiBehaviour_t* behaviour, const char* name, int type, size_t pos, size_t size);
82
91#define UI_RegisterNodeProperty(BEHAVIOUR, NAME, TYPE, OBJECTTYPE, ATTRIBUTE) UI_RegisterNodePropertyPosSize_(BEHAVIOUR, NAME, TYPE, offsetof(OBJECTTYPE, ATTRIBUTE), MEMBER_SIZEOF(OBJECTTYPE, ATTRIBUTE))
92
99#define UI_EXTRADATA_OFFSETOF_(TYPE, MEMBER) ((size_t) &((TYPE *)(UI_EXTRADATA_POINTER(0, TYPE)))->MEMBER)
100
109#define UI_RegisterExtradataNodeProperty(BEHAVIOUR, NAME, TYPE, EXTRADATATYPE, ATTRIBUTE) UI_RegisterNodePropertyPosSize_(BEHAVIOUR, NAME, TYPE, UI_EXTRADATA_OFFSETOF_(EXTRADATATYPE, ATTRIBUTE), MEMBER_SIZEOF(EXTRADATATYPE, ATTRIBUTE))
110
117#define UI_RegisterOveridedNodeProperty(BEHAVIOUR, NAME) ;
118
126const struct value_s* UI_RegisterNodeMethod(uiBehaviour_t* behaviour, const char* name, uiNodeMethod_t function);
127
132const struct value_s* UI_GetPropertyFromBehaviour(const uiBehaviour_t* behaviour, const char* name) __attribute__ ((warn_unused_result));
133
139const value_t* UI_GetPropertyOrLuaMethod(const uiNode_t* node, const char* name, value_t *out);
140
146
147void UI_AddBehaviourMethod (uiBehaviour_t* behaviour, const char* name, LUA_METHOD fcn);
148bool UI_HasBehaviourMethod (uiBehaviour_t* behaviour, const char* name);
149bool UI_GetBehaviourMethod (const uiBehaviour_t* behaviour, const char* name, LUA_METHOD &fcn);
150
151
#define __attribute__(x)
Definition cxx.h:37
voidpf void uLong size
Definition ioapi.h:42
QGL_EXTERN void(APIENTRY *qglActiveTexture)(GLenum texture)
QGL_EXTERN GLuint count
Definition r_gl.h:99
QGL_EXTERN GLint GLenum type
Definition r_gl.h:94
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition r_gl.h:110
int LUA_METHOD
holds a reference to a lua event handler
Definition scripts_lua.h:53
The hash table structure, contains an array of buckets being indexed by the hash function.
Definition hashtable.cpp:96
node behaviour, how a node work
const char * name
void * lua_SWIG_typeinfo
UINodePtr manager
const char * extends
hashTable_s * nodeMethods
uiBehaviour_t * super
intptr_t extraDataSize
const value_t ** localProperties
Atomic structure used to define most of the UI.
Definition ui_nodes.h:80
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_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.
void UI_InitializeNodeBehaviour(uiBehaviour_t *behaviour)
Initialize a node behaviour memory, after registration, and before using it.
bool UI_GetBehaviourMethod(const uiBehaviour_t *behaviour, const char *name, LUA_METHOD &fcn)
Finds the lua based method on this behaviour or its super.
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.
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.
void(* uiNodeMethod_t)(uiNode_t *node, const struct uiCallContext_s *context)
Signature of a function to bind a node method.
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.
const struct value_s * UI_RegisterNodeMethod(uiBehaviour_t *behaviour, const char *name, uiNodeMethod_t function)
Register a node method to a behaviour.
SharedPtr< uiNode > UINodePtr