140#define NUMBER_OF_BEHAVIOURS lengthof(registerFunctions)
176 static char result[512];
193 Q_strcat(result,
sizeof(result),
".");
223 const char* nextName;
224 char nextCommand =
'^';
226 *resultNode =
nullptr;
228 *resultProperty =
nullptr;
231 while (nextName && nextName[0] !=
'\0') {
232 const char* begin = nextName;
233 char command = nextCommand;
234 nextName = strpbrk(begin,
".@#");
239 assert(nextName - begin + 1 <=
sizeof(
name));
241 nextCommand = *nextName;
248 if (relativeNode ==
nullptr)
250 node =
const_cast<uiNode_t *
>(relativeNode);
252 if (relativeNode ==
nullptr)
254 node = relativeNode->
parent;
256 if (relativeNode ==
nullptr)
258 node = relativeNode->
root;
260 if (iterationNode ==
nullptr)
262 node =
const_cast<uiNode_t *
>(iterationNode);
270 childnode = node->
root;
274 if (luaMethod && !childnode) {
276 if (luaMethod->
type) {
289 assert(nextCommand ==
'\0');
316 const value_t*
property =
nullptr;
319 Com_Printf(
"WARNING: Search for node using path [%s] returns property [%s]\n", path, property->string);
339 if (behaviour ==
nullptr)
346 if (memory ==
nullptr)
347 Com_Error(
ERR_FATAL,
"UI_AllocNodeWithoutNew: No more memory to allocate a new node - increase the cvar ui_hunksize");
348 node =
static_cast<uiNode_t*
>(memory);
357 UI_Node_DebugCountWidget(node, 1);
360 Com_Error(
ERR_FATAL,
"UI_AllocNodeWithoutNew: Node behavior '%s' is abstract. We can't instantiate it.",
type);
362 if (
name !=
nullptr) {
364 if (strlen(node->
name) != strlen(
name))
365 Com_Printf(
"UI_AllocNodeWithoutNew: Node name \"%s\" truncated. New name is \"%s\"\n",
name, node->
name);
418 if (newName !=
nullptr) {
420 if (strlen(newNode->
name) != strlen(newName))
421 Com_Printf(
"UI_CloneNode: Node name \"%s\" truncated. New name is \"%s\"\n", newName, newNode->
name);
425 if (node->
root == node && newWindow ==
nullptr)
428 newNode->
root = newWindow;
429 newNode->
parent =
nullptr;
432 newNode->
next =
nullptr;
433 newNode->
super = node;
477 if (rx < 0 || ry < 0 || rx >= node->
box.
size[0] || ry >= node->
box.
size[1])
483 vec2_t clientPosition = {0, 0};
488 rx -= clientPosition[0];
489 ry -= clientPosition[1];
498 rx += clientPosition[0];
499 ry += clientPosition[1];
512 if (rx >= excludeRect->pos[0]
513 && rx < excludeRect->pos[0] + excludeRect->size[0]
514 && ry >= excludeRect->pos[1]
515 && ry < excludeRect->pos[1] + excludeRect->size[1])
530 for (
int pos =
ui_global.windowStackPos - 1; pos >= 0; pos--) {
561 unsigned char min = 0;
565 const int mid = (min + max) >> 1;
629 Com_Printf(
"UI_DeleteNode: Node '%s' contain static nodes. We can't delete it.\n",
UI_GetPath(node));
638 const value_t**
property = behaviour->localProperties;
639 if (property ==
nullptr)
680 if (strcmp(a->
name, b->
name) >= 0) {
682 Com_Error(
ERR_FATAL,
"UI_InitNodes: '%s' is before '%s'. Please order node behaviour registrations by name", a->
name, b->
name);
700 switch (direction % 3) {
702 inner.
pos[0] = this->
pos[0];
705 inner.
pos[0] = this->
pos[0] + (this->
size[0] * 0.5) - (inner.
size[0] * 0.5);
711 switch (direction / 3) {
713 inner.
pos[1] = this->
pos[1];
716 inner.
pos[1] = this->
pos[1] + (this->
size[1] * 0.5) - (inner.
size[1] * 0.5);
722 inner.
pos[1] = this->
pos[1];
void Com_Error(int code, const char *fmt,...)
void Com_Printf(const char *const fmt,...)
hashTable_s * HASH_CloneTable(hashTable_s *source)
Header file for hashtable.
#define Mem_PoolAlloc(size, pool, tagNum)
QGL_EXTERN void(APIENTRY *qglActiveTexture)(GLenum texture)
QGL_EXTERN GLint GLenum type
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
align_t
We need this here for checking the boundaries from script values.
T & Com_GetValue(void *const object, value_t const *const value)
Header for lua script functions.
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
void Q_strcat(char *dest, size_t destsize, const char *format,...)
Safely (without overflowing the destination buffer) concatenates two strings.
node behaviour, how a node work
void alignBox(uiBox_t &inner, align_t direction)
Contain the context of the calling of a function.
struct uiExcludeRect_s * next
Atomic structure used to define most of the UI.
struct uiAction_s * visibilityCondition
LUA_EVENT lua_onVisibleWhen
uiBehaviour_t * behaviour
uiExcludeRect_t * firstExcludeRect
hashTable_s * nodeMethods
void UI_FreeStringProperty(void *pointer)
Free a string property if it is allocated into ui_dynStringPool.
const value_t * UI_GetPropertyOrLuaMethod(const uiNode_t *node, const char *name, value_t *out)
Get a property or lua based method from a node, node behaviour or inherted behaviour.
void UI_InitializeNodeBehaviour(uiBehaviour_t *behaviour)
Initialize a node behaviour memory, after registration, and before using it.
bool UI_GetBooleanFromExpression(uiAction_t *expression, const uiCallContext_t *context)
Check if an expression is true.
Internal data use by the UI package.
void * UI_AllocHunkMemory(size_t size, int align, bool reset)
#define STRUCT_MEMORY_ALIGN
bool UI_ExecuteLuaEventScript_ReturnBool(uiNode_t *node, LUA_EVENT event, bool &result)
Executes a lua event handler and returns the result as a boolean.
Basic lua initialization for the ui.
int UI_DebugMode(void)
Get the current debug mode (0 mean disabled).
void UI_Validate(uiNode_t *node)
Validate a node tree.
bool UI_Node_IsVirtual(uiNode_t const *node)
void UI_Node_Clone(uiNode_t const *source, uiNode_t *clone)
const char * UI_Node_GetWidgetName(uiNode_t const *node)
void UI_Node_DeleteNode(uiNode_t *node)
void UI_Node_InitNodeDynamic(uiNode_t *node)
void UI_Node_GetClientPosition(uiNode_t const *node, vec2_t position)
uiNode_t * UI_RemoveNode(uiNode_t *const node, uiNode_t *child)
Remove a node from a parent node.
void UI_Node_Loading(uiNode_t *node)
bool UI_Node_IsAbstract(uiNode_t const *node)
bool UI_Node_IsScrollableContainer(uiNode_t const *node)
bool UI_Node_IsWindow(uiNode_t const *node)
void UI_AppendNode(uiNode_t *const parent, uiNode_t *newNode)
add a node at the end of the node child
uiNode_t * UI_GetNode(const uiNode_t *node, const char *name)
Search a child node by given name.
intptr_t UI_Node_GetMemorySize(uiNode_t const *node)
void UI_Node_InitNode(uiNode_t *node)
C interface to allow to access to cpp node code.
void UI_RegisterAbstractNode(uiBehaviour_t *behaviour)
void UI_RegisterAbstractOptionNode(uiBehaviour_t *behaviour)
void UI_RegisterAbstractValueNode(uiBehaviour_t *behaviour)
Define common thing for GUI controls which allow to edit a value (scroolbar, spinner,...
void UI_RegisterBarNode(uiBehaviour_t *behaviour)
void UI_RegisterBaseLayoutNode(uiBehaviour_t *behaviour)
void UI_RegisterBaseInventoryNode(uiBehaviour_t *behaviour)
void UI_RegisterBattlescapeNode(uiBehaviour_t *behaviour)
void UI_RegisterCheckBoxNode(uiBehaviour_t *behaviour)
void UI_RegisterContainerNode(uiBehaviour_t *behaviour)
void UI_RegisterControlsNode(uiBehaviour_t *behaviour)
void UI_RegisterDataNode(uiBehaviour_t *behaviour)
void UI_RegisterEditorNode(uiBehaviour_t *behaviour)
void UI_RegisterGeoscapeNode(uiBehaviour_t *behaviour)
void UI_RegisterImageNode(uiBehaviour_t *behaviour)
void UI_RegisterItemNode(uiBehaviour_t *behaviour)
void UI_RegisterLineChartNode(uiBehaviour_t *behaviour)
Registers lineChart node.
void UI_RegisterMaterialEditorNode(uiBehaviour_t *behaviour)
Material editor related header.
void UI_RegisterMessageListNode(uiBehaviour_t *behaviour)
void UI_RegisterModelNode(uiBehaviour_t *behaviour)
void UI_RegisterOptionNode(uiBehaviour_t *behaviour)
void UI_RegisterOptionListNode(uiBehaviour_t *behaviour)
void UI_RegisterOptionTreeNode(uiBehaviour_t *behaviour)
void UI_RegisterPanelNode(uiBehaviour_t *behaviour)
void UI_RegisterRadarNode(uiBehaviour_t *behaviour)
void UI_RegisterRowsNode(uiBehaviour_t *behaviour)
void UI_RegisterSelectBoxNode(uiBehaviour_t *behaviour)
void UI_RegisterSequenceNode(uiBehaviour_t *behaviour)
void UI_RegisterNullNode(uiBehaviour_t *behaviour)
void UI_RegisterCvarFuncNode(uiBehaviour_t *behaviour)
void UI_RegisterFuncNode(uiBehaviour_t *behaviour)
void UI_RegisterConFuncNode(uiBehaviour_t *behaviour)
void UI_RegisterSpinnerNode(uiBehaviour_t *behaviour)
void UI_RegisterStringNode(uiBehaviour_t *behaviour)
void UI_RegisterTabNode(uiBehaviour_t *behaviour)
void UI_RegisterTBarNode(uiBehaviour_t *behaviour)
void UI_RegisterText2Node(uiBehaviour_t *behaviour)
void UI_RegisterTextNode(uiBehaviour_t *behaviour)
void UI_RegisterTextEntryNode(uiBehaviour_t *behaviour)
void UI_RegisterTextListNode(uiBehaviour_t *behaviour)
void UI_RegisterTextureNode(uiBehaviour_t *behaviour)
void UI_RegisterTimerNode(uiBehaviour_t *behaviour)
void UI_RegisterVideoNode(uiBehaviour_t *behaviour)
void UI_RegisterWindowNode(uiBehaviour_t *behaviour)
bool UI_WindowIsModal(uiNode_t const *const node)
True if the window is a modal.
bool UI_WindowIsFullScreen(const uiNode_t *const node)
Check if a window is fullscreen or not.
bool UI_WindowIsDropDown(uiNode_t const *const node)
True if the window is a drop down.
uiNode_t * UI_WindowNodeGetIndexedChild(uiNode_t *const node, const char *childName)
Get a node from child index.
void UI_RegisterZoneNode(uiBehaviour_t *behaviour)
int UI_GetNodeBehaviourCount(void)
bool UI_CheckVisibility(uiNode_t *node)
Check the if conditions for a given node.
uiNode_t * UI_GetNodeByPath(const char *path)
Return a node by a path name (names with dot separation) It is a simplification facade over UI_ReadNo...
static void UI_BeforeDeletingNode(const uiNode_t *node)
uiBehaviour_t * UI_GetNodeBehaviour(const char *name)
Return a node behaviour by name.
uiNode_t * UI_AllocNode(const char *name, const char *type, bool isDynamic)
Allocate a node into the UI memory.
void UI_DeleteAllChild(uiNode_t *node)
Remove all child from a node (only remove dynamic memory allocation nodes).
static uiBehaviour_t nodeBehaviourList[NUMBER_OF_BEHAVIOURS]
List of all node behaviours, indexes by nodetype num.
static uiNode_t * UI_AllocNodeWithoutNew(const char *name, const char *type, bool isDynamic)
Allocate a node into the UI memory (do not call behaviour->new).
static const registerFunction_t registerFunctions[]
List of functions to register nodes.
void(* registerFunction_t)(uiBehaviour_t *node)
uiNode_t * UI_CloneNode(const uiNode_t *node, uiNode_t *newWindow, bool recursive, const char *newName, bool isDynamic)
Clone a node.
const char * UI_GetPath(const uiNode_t *node)
Return a path from a window to a node.
static uiNode_t * UI_GetNodeInTreeAtPosition(uiNode_t *node, int rx, int ry)
Return the first visible node at a position.
uiBehaviour_t * UI_GetNodeBehaviourByIndex(int index)
void UI_ReadNodePath(const char *path, const uiNode_t *relativeNode, const uiNode_t *iterationNode, uiNode_t **resultNode, const value_t **resultProperty, value_t *luaMethod)
Read a path and return every we can use (node and property).
void UI_DeleteNode(uiNode_t *node)
uiNode_t * UI_GetNodeAtPosition(int x, int y)
Return the first visible node at a position.
#define NUMBER_OF_BEHAVIOURS
uiNode_t * UI_GetWindow(const char *name)
Searches all windows for the specified one.