UFO: Alien Invasion
Loading...
Searching...
No Matches
ui_lua.cpp
Go to the documentation of this file.
1
5
6/*
7Copyright (C) 2002-2025 UFO: Alien Invasion.
8
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License
11as published by the Free Software Foundation; either version 2
12of the License, or (at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18See the GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24*/
25
26
27#include "ui_lua.h"
28
29#include "../../shared/cxx.h"
31#include "../../shared/shared.h"
32#include "../../common/cvar.h"
36#include "../cl_lua.h"
37
38//#include "../client.h"
39#include "ui_main.h"
40#include "ui_components.h"
41#include "ui_behaviour.h"
42#include "ui_node.h"
43#include "ui_parse.h"
44#include "ui_internal.h"
45
47
48/* internal field for passing script name as a key to lua registration functions */
49char ui_scriptname[256] = "";
50
51
55void UI_InitLua (void) {
56}
57
61void UI_ShutdownLua (void) {
62}
63
72{
73 lua_rawgeti(CL_GetLuaState(), LUA_REGISTRYINDEX, event); /* push event function on lua stack */
74 SWIG_NewPointerObj(CL_GetLuaState(), node, static_cast<swig_type_info*>(node->behaviour->lua_SWIG_typeinfo), 0); /* push sender on lua stack */
75 if (lua_pcall(CL_GetLuaState(), 1, 0, 0) != 0) {
76 Com_Printf("UI_ExecuteLuaEventScript\n");
77 Com_Printf ("lua error(0) [node=%s, behaviour=%s]: %s\n", UI_GetPath(node), node->behaviour->name, lua_tostring(CL_GetLuaState(), -1));
78 return false;
79 }
80 return true;
81}
82
92{
93 lua_rawgeti(CL_GetLuaState(), LUA_REGISTRYINDEX, event); /* push event function on lua stack */
94 SWIG_NewPointerObj(CL_GetLuaState(), node, static_cast<swig_type_info*>(node->behaviour->lua_SWIG_typeinfo), 0); /* push sender on lua stack */
95 int nparams = 0;
96 LIST_Foreach(params, char, parameter) {
97 lua_pushstring(CL_GetLuaState(), parameter);
98 nparams++;
99 }
100 if (lua_pcall(CL_GetLuaState(), nparams + 1, 0, 0) != 0) {
101 Com_Printf("UI_ExecuteLuaEventScript\n");
102 Com_Printf ("lua error(0) [node=%s, behaviour=%s]: %s\n", UI_GetPath(node), node->behaviour->name, lua_tostring(CL_GetLuaState(), -1));
103 return false;
104 }
105 return true;
106}
107
117{
118 lua_rawgeti (CL_GetLuaState (), LUA_REGISTRYINDEX, event); /* push event function on lua stack */
119 SWIG_NewPointerObj (CL_GetLuaState(), node, static_cast<swig_type_info*>(node->behaviour->lua_SWIG_typeinfo), 0); /* push sender on lua stack */
120 if (lua_pcall (CL_GetLuaState(), 1, 1, 0) != 0) {
121 Com_Printf("UI_ExecuteLuaEventScript_ReturnBool\n");
122 Com_Printf ("lua error(0) [node=%s, behaviour=%s]: %s\n", UI_GetPath(node), node->behaviour->name, lua_tostring(CL_GetLuaState(), -1));
123 return false;
124 }
125 if (!lua_isboolean(CL_GetLuaState(), -1)) {
126 Com_Printf("UI_ExecuteLuaEventScript_ReturnBool\n");
127 Com_Printf ("lua error(0) [node=%s, behaviour=%s]: expecting a boolean as return value\n", UI_GetPath(node), node->behaviour->name);
128 return false;
129 }
130 result = lua_toboolean(CL_GetLuaState(), -1);
131 return true;
132}
133
143bool UI_ExecuteLuaEventScript_XY (uiNode_t* node, LUA_EVENT event, int x, int y)
144{
145 lua_rawgeti(CL_GetLuaState(), LUA_REGISTRYINDEX, event); /* push event function on lua stack */
146 SWIG_NewPointerObj(CL_GetLuaState(), node, static_cast<swig_type_info*>(node->behaviour->lua_SWIG_typeinfo), 0); /* push sender on lua stack */
147 lua_pushinteger(CL_GetLuaState(), x); /* push x on lua stack */
148 lua_pushinteger(CL_GetLuaState(), y); /* push y on lua stack */
149 if (lua_pcall(CL_GetLuaState(), 3, 0, 0) != 0) {
150 Com_Printf("UI_ExecuteLuaEventScript_XY\n");
151 Com_Printf("lua error(0) [node=%s, behaviour=%s]: %s\n", UI_GetPath(node), node->behaviour->name, lua_tostring(CL_GetLuaState(), -1));
152 return false;
153 }
154 return true;
155}
156
166bool UI_ExecuteLuaEventScript_DxDy (uiNode_t* node, LUA_EVENT event, int dx, int dy)
167{
168 lua_rawgeti(CL_GetLuaState(), LUA_REGISTRYINDEX, event); /* push event function on lua stack */
169 SWIG_NewPointerObj(CL_GetLuaState(), node, static_cast<swig_type_info*>(node->behaviour->lua_SWIG_typeinfo), 0); /* push sender on lua stack */
170 lua_pushinteger(CL_GetLuaState(), dx); /* push dx on lua stack */
171 lua_pushinteger(CL_GetLuaState(), dy); /* push dy on lua stack */
172 if (lua_pcall(CL_GetLuaState(), 3, 0, 0) != 0) {
173 Com_Printf("UI_ExecuteLuaEventScript_DxDy\n");
174 Com_Printf("lua error(0) [node=%s, behaviour=%s]: %s\n", UI_GetPath(node), node->behaviour->name, lua_tostring(CL_GetLuaState(), -1));
175 return false;
176 }
177 return true;
178}
179
189bool UI_ExecuteLuaEventScript_Key (uiNode_t* node, LUA_EVENT event, unsigned int key, unsigned short unicode)
190{
191 lua_rawgeti(CL_GetLuaState(), LUA_REGISTRYINDEX, event); /* push event function on lua stack */
192 SWIG_NewPointerObj(CL_GetLuaState(), node, static_cast<swig_type_info*>(node->behaviour->lua_SWIG_typeinfo), 0); /* push sender on lua stack */
193 lua_pushinteger(CL_GetLuaState(), key); /* push key on lua stack */
194 lua_pushinteger(CL_GetLuaState(), unicode); /* push unicode on lua stack */
195 if (lua_pcall(CL_GetLuaState(), 3, 0, 0) != 0) {
196 Com_Printf("UI_ExecuteLuaEventScript_Key\n");
197 Com_Printf("lua error(0) [node=%s, behaviour=%s]: %s\n", UI_GetPath(node), node->behaviour->name, lua_tostring(CL_GetLuaState(), -1));
198 return false;
199 }
200 return true;
201}
202
211bool UI_ExecuteLuaEventScript_DragDrop (uiNode_t* node, LUA_EVENT event, bool &result)
212{
213 lua_rawgeti(CL_GetLuaState(), LUA_REGISTRYINDEX, event); /* push event function on lua stack */
214 SWIG_NewPointerObj(CL_GetLuaState(), node, static_cast<swig_type_info*>(node->behaviour->lua_SWIG_typeinfo), 0); /* push sender on lua stack */
215 if (lua_pcall(CL_GetLuaState(), 1, 1, 0) != 0) {
216 Com_Printf("UI_ExecuteLuaEventScript_DragDrop\n");
217 Com_Printf ("lua error(0) [node=%s, behaviour=%s]: %s\n", UI_GetPath(node), node->behaviour->name, lua_tostring(CL_GetLuaState(), -1));
218 return false;
219 }
220 if (!lua_isboolean(CL_GetLuaState(), -1)) {
221 Com_Printf ("lua error(0) [node=%s, behaviour=%s]: expecting a boolean as return value\n", UI_GetPath(node), node->behaviour->name);
222 return false;
223 }
224 result = lua_toboolean(CL_GetLuaState(), -1);
225 return true;
226}
227
238bool UI_ExecuteLuaEventScript_DragDrop_XY (uiNode_t* node, LUA_EVENT event, int x, int y, bool &result)
239{
240 lua_rawgeti(CL_GetLuaState(), LUA_REGISTRYINDEX, event); /* push event function on lua stack */
241 SWIG_NewPointerObj(CL_GetLuaState(), node, static_cast<swig_type_info*>(node->behaviour->lua_SWIG_typeinfo), 0); /* push sender on lua stack */
242 lua_pushinteger(CL_GetLuaState(), x); /* push x to lua stack */
243 lua_pushinteger(CL_GetLuaState(), y); /* push y to lua stack */
244 if (lua_pcall(CL_GetLuaState(), 3, 1, 0) != 0) {
245 Com_Printf("UI_ExecuteLuaEventScript_DragDrop_XY\n");
246 Com_Printf("lua error(0) [node=%s, behaviour=%s]: %s\n", UI_GetPath(node), node->behaviour->name, lua_tostring(CL_GetLuaState(), -1));
247 return false;
248 }
249 if (!lua_isboolean(CL_GetLuaState(), -1)) {
250 Com_Printf("lua error(0) [node=%s, behaviour=%s]: expecting a boolean as return value\n", UI_GetPath(node), node->behaviour->name);
251 return false;
252 }
253 result = lua_toboolean(CL_GetLuaState(), -1);
254 return true;
255}
256
266bool UI_ExecuteLuaEventScript_DragDrop_IsDropped (uiNode_t* node, LUA_EVENT event, bool isDropped, bool &result)
267{
268 lua_rawgeti(CL_GetLuaState(), LUA_REGISTRYINDEX, event); /* push event function on lua stack */
269 SWIG_NewPointerObj(CL_GetLuaState(), node, static_cast<swig_type_info*>(node->behaviour->lua_SWIG_typeinfo), 0); /* push sender on lua stack */
270 lua_pushboolean(CL_GetLuaState(), isDropped); /* push isDropped to lua stack */
271 if (lua_pcall(CL_GetLuaState(), 2, 1, 0) != 0) {
272 Com_Printf("UI_ExecuteLuaEventScript_DragDrop_IsDropped\n");
273 Com_Printf("lua error(0) [node=%s, behaviour=%s]: %s\n", UI_GetPath(node), node->behaviour->name, lua_tostring(CL_GetLuaState(), -1));
274 return false;
275 }
276 if (!lua_isboolean(CL_GetLuaState(), -1)) {
277 Com_Printf("lua error(0) [node=%s, behaviour=%s]: expecting a boolean as return value\n", UI_GetPath(node), node->behaviour->name);
278 return false;
279 }
280 result = lua_toboolean(CL_GetLuaState(), -1);
281 return true;
282}
283
295bool UI_ExecuteLuaMethod (uiNode_t* node, LUA_FUNCTION fcn, linkedList_t* params, int nparams)
296{
297 lua_rawgeti(CL_GetLuaState(), LUA_REGISTRYINDEX, fcn); /* push event function on lua stack */
298 SWIG_NewPointerObj(CL_GetLuaState(), node, static_cast<swig_type_info*>(node->behaviour->lua_SWIG_typeinfo), 0); /* push sender on lua stack */
299 /* push parameters on stack -> note: all the parameters are pushed as strings, since this is the only
300 * parameter type the old-style script can handle */
301 for (int i = 0; i < nparams; i++) {
302 const char* value = const_cast<const char*>((char*)LIST_GetByIdx(params, i));
303 lua_pushstring(CL_GetLuaState(), value);
304 }
305 if (lua_pcall(CL_GetLuaState(), nparams + 1, 0, 0) != 0) {
306 Com_Printf("UI_ExecuteLuaMethod\n");
307 Com_Printf("lua error(0) [node=%s, behaviour=%s]: %s\n", UI_GetPath(node), node->behaviour->name, lua_tostring(CL_GetLuaState(), -1));
308 return false;
309 }
310 return true;
311}
312
324{
325 lua_rawgeti(CL_GetLuaState(), LUA_REGISTRYINDEX, fcn); /* push event function on lua stack */
326 SWIG_NewPointerObj(CL_GetLuaState(), node, static_cast<swig_type_info*>(node->behaviour->lua_SWIG_typeinfo), 0); /* push sender on lua stack */
327 /* read parameters from cmd and push them on the stack; first parameter is skipped, since this is the
328 * function name; all parameters are strings */
329 for (int i = 1; i < Cmd_Argc(); i++)
330 lua_pushstring(CL_GetLuaState(), Cmd_Argv(i));
331
332 /* execute the confunc */
333 if (lua_pcall(CL_GetLuaState(), Cmd_Argc(), 0, 0) != 0) {
334 Com_Printf("UI_ExecuteLuaConFunc\n");
335 Com_Printf ("lua error(0) [node=%s, behaviour=%s]: %s\n", UI_GetPath(node), node->behaviour->name, lua_tostring(CL_GetLuaState(), -1));
336 return false;
337 }
338 return true;
339}
340
350bool UI_ExecuteLuaMethod_ByName (uiNode_t* node, const char* name, linkedList_t* params, int nparams)
351{
352 LUA_FUNCTION fn;
353 if (UI_GetNodeMethod(node, name, fn)) {
354 return UI_ExecuteLuaMethod(node, fn, params, nparams);
355 }
356 Com_Printf("UI_ExecuteNodeMethod_ByName: calling undefined method %s on node %s\n", name, node->name);
357 return false;
358}
359
367
372void UI_CallHandler_OnLoad (lua_State* L, const char* key)
373{
375}
376
386bool UI_ParseAndLoadLuaScript (const char* name, const char** text)
387{
388 /* determine the length of the string buffer */
389 int ntext = strlen(*text);
390 /* signal lua file found */
391 Com_Printf("UI_ParseAndLoadLuaScript: %s\n", name);
392 /* load the contents of the lua file */
393 if (luaL_loadbuffer(CL_GetLuaState(), *text, ntext, name) == 0) {
394 /* set the script name for calls to the registration functions */
396 /* the script is loaded, now execute it; this will trigger any register_XXXX functions to be
397 * called by the lua script */
398 if (lua_pcall(CL_GetLuaState(), 0, LUA_MULTRET, 0) != 0) {
399 Com_Printf("lua error: %s\n", lua_tostring(CL_GetLuaState(), -1));
400 }
401 else {
402 /* at this point the lua file is loaded and callbacks are registered (on the stack),
403 now call the onLoad if it exists */
405 }
406 ui_scriptname[0] = '\0';
407 } else {
408 Com_Error(0, "lua load error: %s\n", lua_tostring(CL_GetLuaState(), -1));
409 }
410 /* reset the content pointer, this will force the cached content to be released
411 FS_NextScriptHeader. */
412 *text = nullptr;
413 /* execute the onLoad function */
414 return true;
415}
416
428uiNode_t* UI_CreateControl (uiNode_t* parent, const char* type, const char* name, const char* super)
429{
430 uiNode_t* node = nullptr;
431 uiNode_t* node_super = nullptr;
432 uiNode_t* inherited_control = nullptr;
433 uiBehaviour_t* behaviour = nullptr;
434
435 /* get the behaviour */
436 behaviour = UI_GetNodeBehaviour(type);
437 if (!behaviour) {
438 /* if behaviour class not found, try to get a component of this name*/
439 inherited_control = UI_GetComponent(type);
440 if (!inherited_control) {
441 Com_Printf("UI_CreateControl: node behaviour/control '%s' doesn't exist (%s)\n", type, UI_GetPath(parent));
442 return nullptr;
443 }
444 behaviour = inherited_control->behaviour;
445 }
446 /* get the super if it exists */
447 if (super) {
448 node_super = UI_GetComponent(super);
449 /* validate the behaviour matches with the type requested */
450 if (node_super) {
451 if (node_super->behaviour != behaviour) {
452 Com_Printf("UI_CreateControl: behaviour [%s] of super does not match requested type [%s]\n", behaviour->name, node_super->behaviour->name);
453 return nullptr;
454 }
455 }
456 }
457
458 /* check the name */
459 if (!UI_TokenIsName(name, false)) {
460 Com_Printf("UI_CreateControl: \"%s\" is not a well formed node name ([a-zA-Z_][a-zA-Z0-9_]*)\n", name);
461 return nullptr;
462 }
464 Com_Printf("UI_CreateControl: \"%s\" is a reserved token, we can't call a node with it\n", name);
465 return nullptr;
466 }
467
468 /* test if node already exists (inside the parent subtree) */
469 /* Already existing node should only come from inherited node, we should not have 2 definitions of the same node into the same window. */
470 if (parent)
471 node = UI_GetNode(parent, name);
472
473 /* reuse a node */
474 if (node) {
475 if (!node->super) {
476 Com_Printf("UI_CreateControl: trying to create duplicate node [%s]\n", UI_GetPath(node));
477 return nullptr;
478 }
479 const uiBehaviour_t* test = (behaviour != nullptr) ? behaviour : (inherited_control != nullptr) ? inherited_control->behaviour : nullptr;
480 if (node->behaviour != test) {
481 Com_Printf("UI_CreateControl: we can't change node type (node \"%s\")\n", UI_GetPath(node));
482 return nullptr;
483 }
484 Com_DPrintf(DEBUG_CLIENT, "... over-riding node %s\n", UI_GetPath(node));
485 } else {
486 /* clone using super */
487 if (node_super) {
488 node = UI_CloneNode(node_super, nullptr, true, name, true);
489 }
490 /* else try creating a clone of the component */
491 else if (inherited_control) {
492 /* initialize from a component */
493 node = UI_CloneNode(inherited_control, nullptr, true, name, true);
494 }
495 /* else initialize a new node */
496 else {
497 node = UI_AllocNode(name, behaviour->name, true);
498 }
499
500 if (parent) {
501 UI_AppendNode(parent, node);
502 if (node_super || inherited_control)
503 UI_UpdateRoot(node, parent->root);
504 }
505 }
506
507 /* call onload (properties are set from lua) */
508 UI_Node_Loaded(node);
509
510 return node;
511}
512
514{
515 int i;
516 char* indent = new char[level + 1];
517 for (i = 0; i < level; i++) {
518 indent[i] = '\t';
519 }
520 indent[i] = '\0';
521
522 Com_Printf("%s[%s]\n", indent, node->name);
523 for (uiNode_t* child = node->firstChild; child; child = child->next) {
524 UI_PrintNodeTree(child, level + 1);
525 }
526 delete[] indent;
527}
528
529const char* UI_Node_TypeOf(uiNode_t* node)
530{
531 if (node) {
532 return node->behaviour->name;
533 }
534 return nullptr;
535}
536
544uiNode_t* UI_CreateComponent (const char* type, const char* name, const char* super)
545{
546 uiNode_t* node_super = nullptr;
547 uiNode_t* component = nullptr;
548 uiNode_t* inherited = nullptr;
549 uiBehaviour_t* behaviour = nullptr;
550
551 /* check the name */
552 if (!UI_TokenIsName(name, false)) {
553 Com_Printf("UI_CreateComponent: \"%s\" is not a well formed node name ([a-zA-Z_][a-zA-Z0-9_]*)\n", name);
554 return nullptr;
555 }
557 Com_Printf("UI_CreateComponent: \"%s\" is a reserved token, we can't call a node with it\n", name);
558 return nullptr;
559 }
560
561 /* get the type of behaviour */
562 behaviour = UI_GetNodeBehaviour(type);
563 if (!behaviour) {
564 /* if no default behaviour found, try to get a custom component */
565 inherited = UI_GetComponent(type);
566 if (!inherited) {
567 Com_Printf("UI_CreateComponent: node behaviour/control '%s' doesn't exist\n", type);
568 return nullptr;
569 }
570 }
571 /* get the super if it exists */
572 if (super) {
573 node_super = UI_GetComponent(super);
574 /* validate the behaviour matches with the type requested */
575 if (node_super) {
576 if (node_super->behaviour != behaviour) {
577 Com_Printf("UI_CreateComponent: behaviour [%s] of super does not match requested type [%s]\n", behaviour->name, node_super->behaviour->name);
578 return nullptr;
579 }
580 }
581 }
582
583 /* clone using super */
584 if (node_super) {
585 component = UI_CloneNode(node_super, nullptr, true, name, true);
586 }
587 /* else initialize a new node */
588 else {
589 /* use inherited if available */
590 if (inherited) {
591 component = UI_CloneNode(inherited, nullptr, true, name, true);
592 }
593 /* else use the behaviour type */
594 else {
595 component = UI_AllocNode(name, behaviour->name, true);
596 }
597 }
598
599 /* call onload (properties are set and controls are created from lua) */
600 UI_Node_Loaded(component);
601
602 /* add to list of instantiated components */
603 UI_InsertComponent(component);
604
605 //Com_Printf("UI_CreateComponent: registered new component, name [%s], type [%s]\n", name, type);
606
607 return component;
608}
609
618uiNode_t* UI_CreateWindow (const char* type, const char* name, const char* super)
619{
620 /* make sure we create windows only here */
621 if (!Q_streq(type, "window")) {
622 Com_Error(ERR_FATAL, "UI_CreateWindow: '%s %s' is not a window node\n", type, name);
623 return nullptr; /* never reached */
624 }
625 /* make sure the name of the window is a correct identifier */
626 /* note: since this is called from lua, name is never quoted */
627 if (!UI_TokenIsName(name, false)) {
628 Com_Printf("UI_CreateWindow: \"%s\" is not a well formed node name ([a-zA-Z_][a-zA-Z0-9_]*)\n", name);
629 return nullptr;
630 }
631 /* make sure the name of the window is not a reserverd word */
633 Com_Printf("UI_CreateWindow: \"%s\" is a reserved token, we can't call a node with it (node \"%s\")\n", name, name);
634 return nullptr;
635 }
636
637 /* search for windows with same name */
638 int i;
639 for (i = 0; i < ui_global.numWindows; i++)
640 if (!strncmp(name, ui_global.windows[i]->name, sizeof(ui_global.windows[i]->name)))
641 break;
642
643 if (i < ui_global.numWindows) {
644 Com_Printf("UI_CreateWindow: %s \"%s\" with same name found, second ignored\n", type, name);
645 }
646
647 if (ui_global.numWindows >= UI_MAX_WINDOWS) {
648 Com_Error(ERR_FATAL, "UI_CreateWindow: max windows exceeded (%i) - ignore '%s'\n", UI_MAX_WINDOWS, name);
649 return nullptr; /* never reached */
650 }
651
652 /* create the window */
653 uiNode_t* window;
654
655 /* does this window inherit data from another window? */
656 if (super != nullptr) {
657 uiNode_t* superWindow;
658 superWindow = UI_GetWindow(super);
659 if (superWindow == nullptr) {
660 Sys_Error("Could not get the super window \"%s\"", super);
661 }
662 window = UI_CloneNode(superWindow, nullptr, true, name, true);
663 } else {
664 window = UI_AllocNode(name, type, true);
665 window->root = window;
666 }
667
668 /* call onload (properties are set and controls are created from lua) */
669 UI_Node_Loaded(window);
670
671 /* add to list of instantiated windows */
672 UI_InsertWindow(window);
673
674 return window;
675}
unsigned int key
Definition cl_input.cpp:64
unsigned short unicode
Definition cl_input.cpp:65
lua_State * CL_GetLuaState(void)
Returns the lua state for the client side.
Definition cl_lua.cpp:166
void CL_RegisterCallback(const char *key, LUA_FUNCTION fnc)
Registers a lua callback function with a key.
Definition cl_lua.cpp:175
void CL_ExecuteCallback(lua_State *L, const char *key)
Calls the registered lua onload callback function.
Definition cl_lua.cpp:194
const char * Cmd_Argv(int arg)
Returns a given argument.
Definition cmd.cpp:516
int Cmd_Argc(void)
Return the number of arguments of the current command. "command parameter" will result in a argc of 2...
Definition cmd.cpp:505
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
Definition common.cpp:440
void Com_Error(int code, const char *fmt,...)
Definition common.cpp:459
void Com_Printf(const char *const fmt,...)
Definition common.cpp:428
#define ERR_FATAL
Definition common.h:210
Cvar (console variable) header file.
Defined CONSTANTS (Macros are elsewhere).
#define DEBUG_CLIENT
Definition defines.h:59
Filesystem header file.
level_locals_t level
Definition g_main.cpp:38
void Sys_Error(const char *error,...)
Definition g_main.cpp:421
Header file for hashtable.
void * LIST_GetByIdx(linkedList_t *list, int index)
Get an entry of a linked list by its index in the list.
Definition list.cpp:362
#define LIST_Foreach(list, type, var)
Iterates over a linked list, it's safe to delete the returned entry from the list while looping over ...
Definition list.h:41
QGL_EXTERN GLint i
Definition r_gl.h:113
QGL_EXTERN GLint GLenum type
Definition r_gl.h:94
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition r_gl.h:110
Header for lua script functions.
int LUA_FUNCTION
callback signatures for functions defined in Lua
Definition scripts_lua.h:45
int LUA_EVENT
holds a reference to a lua event handler
Definition scripts_lua.h:49
#define Q_streq(a, b)
Definition shared.h:136
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
Definition shared.cpp:457
node behaviour, how a node work
const char * name
void * lua_SWIG_typeinfo
Atomic structure used to define most of the UI.
Definition ui_nodes.h:80
uiNode_t const * super
Definition ui_nodes.h:84
uiNode_t * firstChild
Definition ui_nodes.h:89
uiNode_t * next
Definition ui_nodes.h:91
uiBehaviour_t * behaviour
Definition ui_nodes.h:83
char name[MAX_VAR]
Definition ui_nodes.h:82
uiNode_t * root
Definition ui_nodes.h:93
uiNode_t * UI_GetComponent(const char *name)
Searches all components for the specified one.
void UI_InsertComponent(uiNode_t *component)
Add a new component to the list of all components.
Internal data use by the UI package.
uiGlobal_t ui_global
Definition ui_main.cpp:38
#define UI_MAX_WINDOWS
Definition ui_internal.h:29
const char * UI_Node_TypeOf(uiNode_t *node)
Definition ui_lua.cpp:529
void UI_PrintNodeTree(uiNode_t *node, int level)
Definition ui_lua.cpp:513
uiNode_t * UI_CreateControl(uiNode_t *parent, const char *type, const char *name, const char *super)
Create a new control inherited from a given node class or other node.
Definition ui_lua.cpp:428
bool UI_ExecuteLuaEventScript_DragDrop(uiNode_t *node, LUA_EVENT event, bool &result)
Executes a lua event handler for dragdrop interaction.
Definition ui_lua.cpp:211
bool UI_ExecuteLuaEventScript_DragDrop_XY(uiNode_t *node, LUA_EVENT event, int x, int y, bool &result)
Executes a lua event handler for dragdrop interaction.
Definition ui_lua.cpp:238
char ui_scriptname[256]
Definition ui_lua.cpp:49
bool UI_ExecuteLuaEventScript(uiNode_t *node, LUA_EVENT event)
Executes a lua event handler.
Definition ui_lua.cpp:71
bool UI_ExecuteLuaEventScript_XY(uiNode_t *node, LUA_EVENT event, int x, int y)
Executes a lua event handler with (x,y) argument.
Definition ui_lua.cpp:143
uiNode_t * UI_CreateWindow(const char *type, const char *name, const char *super)
Create a window node with specified type and inheritance.
Definition ui_lua.cpp:618
bool UI_ExecuteLuaMethod(uiNode_t *node, LUA_FUNCTION fcn, linkedList_t *params, int nparams)
Executes a lua based method defined on the behaviour class of a node.
Definition ui_lua.cpp:295
bool UI_ExecuteLuaEventScript_DragDrop_IsDropped(uiNode_t *node, LUA_EVENT event, bool isDropped, bool &result)
Executes a lua event handler for dragdrop interaction.
Definition ui_lua.cpp:266
bool UI_ParseAndLoadLuaScript(const char *name, const char **text)
Parses and loads a .ufo file holding a lua script.
Definition ui_lua.cpp:386
bool UI_ExecuteLuaEventScript_Key(uiNode_t *node, LUA_EVENT event, unsigned int key, unsigned short unicode)
Executes a lua event handler with (keycode,unicode) argument.
Definition ui_lua.cpp:189
void UI_ShutdownLua(void)
Performs UI specific lua shutdown. Call this before CL_ShutdownLua.
Definition ui_lua.cpp:61
bool UI_ExecuteLuaMethod_ByName(uiNode_t *node, const char *name, linkedList_t *params, int nparams)
Executes a lua based method defined on the behaviour class of a node.
Definition ui_lua.cpp:350
uiNode_t * UI_CreateComponent(const char *type, const char *name, const char *super)
Create a new component inherited from a given node class or other node.
Definition ui_lua.cpp:544
void UI_InitLua(void)
Performs UI specific initialization. Call this after CL_InitLua.
Definition ui_lua.cpp:55
void UI_CallHandler_OnLoad(lua_State *L, const char *key)
Call the registered callback handler. This stub primarily exists should the signature of the call cha...
Definition ui_lua.cpp:372
bool UI_ExecuteLuaConFunc(uiNode_t *node, LUA_FUNCTION fcn)
Executes a lua based confunc node.
Definition ui_lua.cpp:323
void UI_RegisterHandler_OnLoad(LUA_FUNCTION fcn)
Register global lua callback function called after loading the module.
Definition ui_lua.cpp:363
bool UI_ExecuteLuaEventScript_ParamList(uiNode_t *node, LUA_EVENT event, linkedList_t *params)
Executes a lua event handler with string parameter list.
Definition ui_lua.cpp:91
bool UI_ExecuteLuaEventScript_DxDy(uiNode_t *node, LUA_EVENT event, int dx, int dy)
Executes a lua event handler with (dx,dy) argument.
Definition ui_lua.cpp:166
bool UI_ExecuteLuaEventScript_ReturnBool(uiNode_t *node, LUA_EVENT event, bool &result)
Executes a lua event handler and returns the result as a boolean.
Definition ui_lua.cpp:116
Basic lua initialization for the ui.
#define SWIG_NewPointerObj(L, ptr, type, owner)
void UI_UpdateRoot(uiNode_t *node, uiNode_t *newRoot)
Definition ui_node.cpp:853
void UI_Node_Loaded(uiNode_t *node)
Definition ui_node.cpp:214
bool UI_GetNodeMethod(const uiNode_t *node, const char *name, LUA_METHOD &fcn)
Finds the lua based method on this node or its super.
Definition ui_node.cpp:1116
void UI_AppendNode(uiNode_t *const parent, uiNode_t *newNode)
add a node at the end of the node child
Definition ui_node.cpp:868
uiNode_t * UI_GetNode(const uiNode_t *node, const char *name)
Search a child node by given name.
Definition ui_node.cpp:714
C interface to allow to access to cpp node code.
uiBehaviour_t * UI_GetNodeBehaviour(const char *name)
Return a node behaviour by name.
Definition ui_nodes.cpp:559
uiNode_t * UI_AllocNode(const char *name, const char *type, bool isDynamic)
Allocate a node into the UI memory.
Definition ui_nodes.cpp:381
uiNode_t * UI_CloneNode(const uiNode_t *node, uiNode_t *newWindow, bool recursive, const char *newName, bool isDynamic)
Clone a node.
Definition ui_nodes.cpp:409
const char * UI_GetPath(const uiNode_t *node)
Return a path from a window to a node.
Definition ui_nodes.cpp:174
bool UI_TokenIsName(const char *name, bool isQuoted)
Definition ui_parse.cpp:126
bool UI_TokenIsReserved(const char *name)
Definition ui_parse.cpp:82
void UI_InsertWindow(uiNode_t *window)
Add a new window to the list of all windows.
uiNode_t * UI_GetWindow(const char *name)
Searches all windows for the specified one.