UFO: Alien Invasion
Loading...
Searching...
No Matches
ui_node.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#include <typeinfo>
27#include "ui_main.h"
28#include "ui_behaviour.h"
29#include "ui_nodes.h"
30#include "ui_node.h"
34#include "node/ui_node_panel.h"
35#include "ui_parse.h"
36#include "ui_components.h"
37#include "ui_internal.h"
38
40
41
42bool UI_Node_IsVirtual (uiNode_t const* node)
43{
44 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
45 return b == nullptr;
46}
47
48bool UI_Node_IsDrawable (uiNode_t const* node)
49{
50 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
51 return b != nullptr;
52}
53
55{
57 return b != nullptr;
58}
59
60bool UI_Node_IsWindow (uiNode_t const* node)
61{
62 uiWindowNode* b = dynamic_cast<uiWindowNode*>(node->behaviour->manager.get());
63 return b != nullptr;
64}
65
67{
68 uiBattleScapeNode* b = dynamic_cast<uiBattleScapeNode*>(node->behaviour->manager.get());
69 return b != nullptr;
70}
71
72bool UI_Node_IsAbstract (uiNode_t const* node)
73{
74 return node->behaviour->isAbstract;
75}
76
78{
79 return node->behaviour->drawItselfChild;
80}
81
85bool UI_Node_IsFunction (uiNode_t const* node)
86{
87 return node->behaviour->isFunction;
88}
89
94{
96 return b != nullptr;
97}
98
99const char* UI_Node_GetWidgetName (uiNode_t const* node)
100{
101 return node->behaviour->name;
102}
103
104intptr_t UI_Node_GetMemorySize (uiNode_t const* node)
105{
106 return sizeof(*node) + node->behaviour->extraDataSize;
107}
108
110{
111 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
112 b->draw(node);
113}
114
115void UI_Node_DrawTooltip (const uiNode_t* node, int x, int y)
116{
117 const uiLocatedNode* b = dynamic_cast<const uiLocatedNode*>(node->behaviour->manager.get());
118 b->drawTooltip(node, x, y);
119}
120
122{
123 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
124 b->drawOverWindow(node);
125}
126
127/* mouse events */
128void UI_Node_LeftClick (uiNode_t* node, int x, int y)
129{
130 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
131 b->onLeftClick(node, x, y);
132}
133
134void UI_Node_RightClick (uiNode_t* node, int x, int y)
135{
136 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
137 b->onRightClick(node, x, y);
138}
139
140void UI_Node_MiddleClick (uiNode_t* node, int x, int y)
141{
142 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
143 b->onMiddleClick(node, x, y);
144}
145
146bool UI_Node_Scroll (uiNode_t* node, int deltaX, int deltaY)
147{
148 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
149 return b->onScroll(node, deltaX, deltaY);
150}
151
152void UI_Node_MouseMove (uiNode_t* node, int x, int y)
153{
154 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
155 b->onMouseMove(node, x, y);
156}
157
158void UI_Node_MouseDown (uiNode_t* node, int x, int y, int button)
159{
160 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
161 b->onMouseDown(node, x, y, button);
162}
163
164void UI_Node_MouseUp (uiNode_t* node, int x, int y, int button)
165{
166 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
167 b->onMouseUp(node, x, y, button);
168}
169
171{
172 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
173 b->onMouseEnter(node);
174}
175
177{
178 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
179 b->onMouseLeave(node);
180}
181
182bool UI_Node_MouseLongPress (uiNode_t* node, int x, int y, int button)
183{
184 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
185 return b->onMouseLongPress(node, x, y, button);
186}
187
188bool UI_Node_StartDragging (uiNode_t* node, int startX, int startY, int currentX, int currentY, int button)
189{
190 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
191 return b->onStartDragging(node, startX, startY, currentX, currentY, button);
192}
193
194void UI_Node_CapturedMouseMove (uiNode_t* node, int x, int y)
195{
196 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
197 b->onCapturedMouseMove(node, x, y);
198}
199
201{
202 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
203 b->onCapturedMouseLost(node);
204}
205
206/* system allocation */
207
209{
210 uiNode* b = node->behaviour->manager.get();
211 b->onLoading(node);
212}
213
215{
216 uiNode* b = node->behaviour->manager.get();
217 b->onLoaded(node);
218}
219
220void UI_Node_Clone (uiNode_t const* source, uiNode_t* clone)
221{
222 uiNode* b = source->behaviour->manager.get();
223 b->clone(source, clone);
224}
225
227 uiNode* b = node->behaviour->manager.get();
228 b->initNodeDynamic(node);
229}
230
232{
233 uiNode* b = node->behaviour->manager.get();
234 b->initNode(node);
235}
236
238{
239 uiNode* b = node->behaviour->manager.get();
240 b->deleteNode(node);
241}
242
243/* system callback */
244
246{
247 uiNode* b = node->behaviour->manager.get();
248 b->onWindowOpened(node, params);
249}
250
252{
253 uiNode* b = node->behaviour->manager.get();
254 b->onWindowClosed(node);
255}
256
258{
259 uiNode* b = node->behaviour->manager.get();
260 b->onWindowActivate(node);
261}
262
264{
265 if (UI_Node_IsDrawable(node)) {
266 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
267 b->doLayout(node);
268 }
269}
270
272{
273 uiNode* b = node->behaviour->manager.get();
274 b->onActivate(node);
275}
276
277void UI_Node_PropertyChanged (uiNode_t* node, const value_t* property)
278{
279 uiNode* b = node->behaviour->manager.get();
280 b->onPropertyChanged(node, property);
281}
282
284{
285 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
286 b->onSizeChanged(node);
287}
288
290{
291 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
292 b->onSizeChanged(node);
293}
294
295void UI_Node_GetClientPosition (uiNode_t const* node, vec2_t position)
296{
298 b->getClientPosition(node, position);
299}
300
301/* drag and drop callback */
302
304{
305 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
306 return b->onDndEnter(node);
307}
308
309bool UI_Node_DndMove (uiNode_t* node, int x, int y)
310{
311 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
312 return b->onDndMove(node, x, y);
313}
314
316{
317 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
318 b->onDndLeave(node);
319}
320
321bool UI_Node_DndDrop (uiNode_t* node, int x, int y)
322{
323 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
324 return b->onDndDrop(node, x, y);
325}
326
327bool UI_Node_DndFinished (uiNode_t* node, bool isDroped)
328{
329 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
330 return b->onDndFinished(node, isDroped);
331}
332
333/* focus and keyboard events */
334
336{
337 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
338 b->onFocusGained(node);
339}
340
342{
343 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
344 b->onFocusLost(node);
345}
346
347bool UI_Node_KeyPressed (uiNode_t* node, unsigned int key, unsigned short unicode)
348{
349 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
350 return b->onKeyPressed(node, key, unicode);
351}
352
353bool UI_Node_KeyReleased (uiNode_t* node, unsigned int key, unsigned short unicode)
354{
355 uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
356 return b->onKeyReleased(node, key, unicode);
357}
358
359/* cell size */
360
362{
364 return b->getCellWidth(node);
365}
366
368{
370 return b->getCellHeight(node);
371}
372
373const char* UI_Node_GetText (uiNode_t* node) {
374 #ifdef DEBUG
375 if (node->text == nullptr) {
376 Com_Printf("warning: requesting uninitialized node->text from [%s]\n", UI_GetPath(node));
377 }
378 #endif // DEBUG
379 return (node->text? node->text : "");
380}
381
382void UI_Node_SetText (uiNode_t* node, const char* text) {
384 if (text != nullptr)
385 node->text = Mem_PoolStrDup(text, ui_dynStringPool, 0);
386 else
387 node->text = nullptr;
388}
389
390void UI_Node_SetFont (uiNode_t* node, const char* name) {
392 if (name != nullptr)
394 else
395 node->font = nullptr;
396}
397
398void UI_Node_SetImage (uiNode_t* node, const char* name) {
400 if (name != nullptr)
402 else
403 node->image = nullptr;
404}
405
406const char* UI_Node_GetTooltip (uiNode_t* node) {
407 return node->tooltip;
408}
409
410void UI_Node_SetTooltip (uiNode_t* node, const char* tooltip) {
411 UI_FreeStringProperty((void*)node->tooltip);
412 if (tooltip != nullptr)
413 node->tooltip = Mem_PoolStrDup(tooltip, ui_dynStringPool, 0);
414 else
415 node->tooltip = nullptr;
416}
417
418bool UI_Node_IsDisabled (uiNode_t const* node) {
419 return node->disabled;
420}
421
422bool UI_Node_IsInvisible (uiNode_t const* node) {
423 return node->invis;
424}
425
426bool UI_Node_IsGhost (uiNode_t const* node) {
427 return node->ghost;
428}
429
430bool UI_Node_IsFlashing (uiNode_t const* node) {
431 return node->flash;
432}
433
434void UI_Node_SetDisabled (uiNode_t* node, const bool value) {
435 node->disabled = value;
436}
437
438#ifdef DEBUG
439
440void UI_Node_DebugCountWidget (uiNode_t* node, int count)
441{
442 node->behaviour->count += count;
443}
444
445#endif
446
453bool UI_NodeInstanceOf (const uiNode_t* node, const char* behaviourName)
454{
455 for (const uiBehaviour_t* behaviour = node->behaviour; behaviour; behaviour = behaviour->super) {
456 if (Q_streq(behaviour->name, behaviourName))
457 return true;
458 }
459 return false;
460}
461
468bool UI_NodeInstanceOfPointer (const uiNode_t* node, const uiBehaviour_t* behaviour)
469{
470 for (const uiBehaviour_t* b = node->behaviour; b; b = b->super) {
471 if (b == behaviour)
472 return true;
473 }
474 return false;
475}
476
484void UI_NodeGetPoint (const uiNode_t* node, vec2_t pos, int direction)
485{
486 switch (UI_GET_HORIZONTAL_ALIGN(direction)) {
488 pos[0] = 0;
489 break;
491 pos[0] = (int)(node->box.size[0] / 2);
492 break;
494 pos[0] = node->box.size[0];
495 break;
496 default:
497 Com_Printf("UI_NodeGetPoint: Align '%d' (0x%X) is not a common alignment", direction, direction);
498 pos[0] = 0;
499 pos[1] = 0;
500 return;
501 }
502
503 switch (UI_GET_VERTICAL_ALIGN(direction)) {
505 pos[1] = 0;
506 break;
508 pos[1] = (int)(node->box.size[1] / 2);
509 break;
511 pos[1] = node->box.size[1];
512 break;
513 default:
514 Com_Printf("UI_NodeGetPoint: Align '%d' (0x%X) is not a common alignment", direction, direction);
515 pos[0] = 0;
516 pos[1] = 0;
517 return;
518 }
519}
520
526void UI_GetNodeAbsPos (const uiNode_t* node, vec2_t pos)
527{
528 assert(node);
529 assert(pos);
530
531 /* if we request the position of a non drawable node, there is a problem */
532 if (node->behaviour->isVirtual)
533 Com_Error(ERR_FATAL, "UI_GetNodeAbsPos: Node '%s' doesn't have a position", node->name);
534
535 Vector2Set(pos, 0, 0);
536 while (node) {
537#ifdef DEBUG
538 if (node->box.pos[0] != (int)node->box.pos[0] || node->box.pos[1] != (int)node->box.pos[1])
539 Com_Error(ERR_FATAL, "UI_GetNodeAbsPos: Node '%s' position %f,%f is not integer", UI_GetPath(node), node->box.pos[0], node->box.pos[1]);
540#endif
541 pos[0] += node->box.pos[0];
542 pos[1] += node->box.pos[1];
543 node = node->parent;
544 }
545}
546
554void UI_GetNodeScreenPos (const uiNode_t* node, vec2_t pos)
555{
556 assert(node);
557 assert(pos);
558
559 /* if we request the position of a non drawable node, there is a problem */
560 if (node->behaviour->isVirtual)
561 Com_Error(ERR_FATAL, "UI_GetNodeAbsPos: Node '%s' doesn't have a position", node->name);
562
563 Vector2Set(pos, 0, 0);
564 while (node) {
565#ifdef DEBUG
566 if (node->box.pos[0] != (int)node->box.pos[0] || node->box.pos[1] != (int)node->box.pos[1])
567 Com_Error(ERR_FATAL, "UI_GetNodeAbsPos: Node '%s' position %f,%f is not integer", UI_GetPath(node), node->box.pos[0], node->box.pos[1]);
568#endif
569 pos[0] += node->box.pos[0];
570 pos[1] += node->box.pos[1];
571 node = node->parent;
572
573 if (node && UI_Node_IsScrollableContainer(node)) {
574 vec2_t clientPosition = {0, 0};
575 UI_Node_GetClientPosition(node, clientPosition);
576 pos[0] += clientPosition[0];
577 pos[1] += clientPosition[1];
578 }
579 }
580}
581
588{
589 assert(node);
590 assert(pos);
591 while (node) {
592 pos[0] += node->box.pos[0];
593 pos[1] += node->box.pos[1];
594 node = node->parent;
595 }
596}
597
604void UI_NodeAbsoluteToRelativePos (const uiNode_t* node, int* x, int* y)
605{
606 assert(node != nullptr);
607 /* if we request the position of an undrawable node, there is a problem */
608 assert(node->behaviour->isVirtual == false);
609 assert(x != nullptr);
610 assert(y != nullptr);
611
612 /* if we request the position of an undrawable node, there is a problem */
613 if (node->behaviour->isVirtual)
614 Com_Error(ERR_DROP, "UI_NodeAbsoluteToRelativePos: Node '%s' doesn't have a position", node->name);
615
616 while (node) {
617 *x -= node->box.pos[0];
618 *y -= node->box.pos[1];
619
621 vec2_t clientPosition = {0, 0};
622 UI_Node_GetClientPosition(node, clientPosition);
623 *x -= clientPosition[0];
624 *y -= clientPosition[1];
625 }
626
627 node = node->parent;
628 }
629}
630
636{
637 if (node)
638 node->invis = true;
639 else
640 Com_Printf("UI_HideNode: No node given\n");
641}
642
648{
649 if (node)
650 node->invis = false;
651 else
652 Com_Printf("UI_UnHideNode: No node given\n");
653}
654
658void UI_NodeSetPos(uiNode_t* node, vec2_t pos) {
659 if (Vector2Equal(node->box.pos, pos))
660 return;
661 node->box.pos[0] = pos[0];
662 node->box.pos[1] = pos[1];
663 UI_Node_PosChanged(node);
664}
665
669void UI_NodeSetPos(uiNode_t* node, float x, float y) {
670 vec2_t p;
671 p[0] = x; p[1] = y;
672 UI_NodeSetPos(node, p);
673}
674
679{
680 if (Vector2Equal(node->box.size, size))
681 return;
682 node->box.size[0] = size[0];
683 node->box.size[1] = size[1];
685}
686
689void UI_NodeSetSize (uiNode_t* node, float w, float h) {
690 vec2_t s;
691 s[0] = w; s[1] = h;
692 UI_NodeSetSize(node, s);
693}
694
699void UI_NodeSetBox (uiNode_t* node, float x, float y, float w, float h) {
700 vec2_t p;
701 vec2_t s;
702 if (x != -1) p[0] = x; else p[0] = node->box.pos[0];
703 if (y != -1) p[1] = y; else p[1] = node->box.pos[1];
704 if (w != -1) s[0] = w; else s[0] = node->box.size[0];
705 if (h != -1) s[1] = h; else s[1] = node->box.size[1];
706 UI_NodeSetPos(node, p);
707 UI_NodeSetSize(node, s);
708}
709
714uiNode_t* UI_GetNode(const uiNode_t* node, const char* name) {
715 uiNode_t* current = nullptr;
716
717 if (!node)
718 return nullptr;
719
720 for (current = node->firstChild; current; current = current->next)
721 if (Q_streq(name, current->name))
722 break;
723
724 return current;
725}
726
734 uiNode_t* current = nullptr;
735 for (current = node->parent->firstChild; current; current = current->next) {
736 if (node == current->next) break;
737 }
738 return current;
739}
740
745uiNode_t* UI_FindNode(const uiNode_t* node, const char* name) {
746 /* search current level */
747 uiNode_t* result = UI_GetNode(node, name);
748 if (!result) {
749 /* iterate child nodes and search next level */
750 for(uiNode_t* current = node->firstChild; current; current = current->next) {
751 result = UI_FindNode(current, name);
752 if (result) break;
753 }
754 }
755 return result;
756}
757
764void UI_InsertNode (uiNode_t* const parent, uiNode_t* prevNode, uiNode_t* newNode)
765{
766 /* parent and newNode should be valid, or else insertion doesn't make sense */
767 assert(parent);
768 assert(newNode);
769 /* insert only a single element */
770 assert(!newNode->next);
771
772 uiNode_t** const anchor = prevNode ? &prevNode->next : &parent->firstChild;
773 newNode->next = *anchor;
774 *anchor = newNode;
775 newNode->parent = parent;
776
777 UI_UpdateRoot (newNode, parent->root);
778
779 if (!parent->firstChild) {
780 parent->firstChild = newNode;
781 }
782 if (!parent->lastChild) {
783 parent->lastChild = newNode;
784 }
785
786 if (!newNode->next) {
787 parent->lastChild = newNode;
788 }
789
790 if (newNode->root && newNode->indexed)
791 UI_WindowNodeAddIndexedNode(newNode->root, newNode);
792
793 UI_Invalidate(parent);
794}
795
803{
804 assert(node);
805 assert(child);
806 assert(child->parent == node);
807 assert(node->firstChild);
808
810 for (uiNode_t** anchor = &node->firstChild;; anchor = &(*anchor)->next) {
811 if (!*anchor)
812 return 0;
813
814 if (*anchor == child) {
815 *anchor = child->next;
816 break;
817 }
818 }
819 UI_Invalidate(node);
820
822 if (node->lastChild == child) {
823 node->lastChild = node->firstChild;
824 while (node->lastChild && node->lastChild->next)
825 node->lastChild = node->lastChild->next;
826 }
827 if (child->root && child->indexed)
829
830 child->next = nullptr;
831 return child;
832}
833
840void UI_MoveNode (uiNode_t* const parent, uiNode_t* prevNode, uiNode_t* node)
841{
842 /* parent and newNode should be valid, or else insertion doesn't make sense */
843 assert(parent);
844 assert(node);
845
846 if (!UI_RemoveNode(parent, node))
847 return;
848 UI_InsertNode(parent, prevNode, node);
849
850 UI_Invalidate(parent);
851}
852
853void UI_UpdateRoot (uiNode_t* node, uiNode_t* newRoot)
854{
855 node->root = newRoot;
856 node = node->firstChild;
857 while (node) {
858 UI_UpdateRoot(node, newRoot);
859 node = node->next;
860 }
861}
862
868void UI_AppendNode (uiNode_t* const parent, uiNode_t* newNode)
869{
870 UI_InsertNode(parent, parent->lastChild, newNode);
871}
872
873void UI_NodeSetPropertyFromRAW (uiNode_t* node, const value_t* property, const void* rawValue, int rawType)
874{
875 if (property->type != rawType) {
876 Com_Printf("UI_NodeSetPropertyFromRAW: type %i expected, but @%s type %i found. Property setter to '%s@%s' skipped\n", rawType, property->string, property->type, UI_GetPath(node), property->string);
877 return;
878 }
879
880 if ((property->type & V_UI_MASK) == V_NOT_UI)
881 Com_SetValue(node, rawValue, property->type, property->ofs, property->size);
882 else if ((property->type & V_UI_MASK) == V_UI_CVAR) {
884 switch (property->type & V_BASETYPEMASK) {
885 case V_FLOAT: *Com_GetValue<float* >(node, property) = *static_cast<float const*>(rawValue); break;
886 case V_INT: *Com_GetValue<int* >(node, property) = *static_cast<int const*>(rawValue); break;
887 default: Com_GetValue<byte const*>(node, property) = static_cast<byte const*>(rawValue); break;
888 }
889 } else if (property->type == V_UI_ACTION) {
890 Com_GetValue<uiAction_t const*>(node, property) = static_cast<uiAction_t const*>(rawValue);
891 } else if (property->type == V_UI_SPRITEREF) {
892 Com_GetValue<uiSprite_t const*>(node, property) = static_cast<uiSprite_t const*>(rawValue);
893 } else {
894 Com_Error(ERR_FATAL, "UI_NodeSetPropertyFromRAW: Property type '%d' unsupported", property->type);
895 }
896 UI_Node_PropertyChanged(node, property);
897}
898
902bool UI_NodeSetProperty (uiNode_t* node, const value_t* property, const char* value)
903{
904 const int specialType = property->type & V_UI_MASK;
905 int result;
906 size_t bytes;
907
908 switch (specialType) {
909 case V_NOT_UI: /* common type */
910 result = Com_ParseValue(node, value, property->type, property->ofs, property->size, &bytes);
911 if (result != RESULT_OK) {
912 Com_Printf("UI_NodeSetProperty: Invalid value for property '%s': %s\n", property->string, Com_GetLastParseError());
913 return false;
914 }
915 UI_Node_PropertyChanged(node, property);
916 return true;
917
918 case V_UI_CVAR: /* cvar */
919 switch ((int)property->type) {
920 case V_UI_CVAR:
921 if (Q_strstart(value, "*cvar:")) {
922 char*& b = Com_GetValue<char*>(node, property);
924 b = Mem_PoolStrDup(value, ui_dynStringPool, 0);
925 UI_Node_PropertyChanged(node, property);
926 return true;
927 }
928 break;
929 case V_CVAR_OR_FLOAT:
930 {
931 float f;
932
933 if (Q_strstart(value, "*cvar:")) {
934 char*& b = Com_GetValue<char*>(node, property);
936 b = Mem_PoolStrDup(value, ui_dynStringPool, 0);
937 UI_Node_PropertyChanged(node, property);
938 return true;
939 }
940
941 result = Com_ParseValue(&f, value, V_FLOAT, 0, sizeof(f), &bytes);
942 if (result != RESULT_OK) {
943 Com_Printf("UI_NodeSetProperty: Invalid value for property '%s': %s\n", property->string, Com_GetLastParseError());
944 return false;
945 }
946
947 void* const b = Com_GetValue<void*>(node, property);
948 if (char const* const cvar = Q_strstart((char const*)b, "*cvar:"))
949 Cvar_SetValue(cvar, f);
950 else
951 *(float*) b = f;
952 UI_Node_PropertyChanged(node, property);
953 return true;
954 }
956 case V_CVAR_OR_STRING:
957 {
958 char*& b = Com_GetValue<char*>(node, property);
960 b = Mem_PoolStrDup(value, ui_dynStringPool, 0);
961 UI_Node_PropertyChanged(node, property);
962 return true;
963 }
964 }
965 break;
966
967 case V_UI:
968 switch ((int)property->type) {
969 case V_UI_SPRITEREF:
970 {
971 uiSprite_t* sprite = UI_GetSpriteByName(value);
972 Com_GetValue<uiSprite_t const*>(node, property) = sprite;
973 UI_Node_PropertyChanged(node, property);
974 return true;
975 }
976 }
977 break;
978 }
979
980 Com_Printf("UI_NodeSetProperty: Unimplemented type for property '%s@%s'\n", UI_GetPath(node), property->string);
981 return false;
982}
983
990const char* UI_GetStringFromNodeProperty (const uiNode_t* node, const value_t* property)
991{
992 const int baseType = property->type & V_UI_MASK;
993 assert(node);
994 assert(property);
995
996 switch (baseType) {
997 case V_NOT_UI: /* common type */
998 return Com_ValueToStr(node, property->type, property->ofs);
999 case V_UI_CVAR:
1000 switch ((int)property->type) {
1001 case V_CVAR_OR_FLOAT:
1002 {
1003 const float f = UI_GetReferenceFloat(node, Com_GetValue<void*>(node, property));
1004 const int i = f;
1005 if (f == i)
1006 return va("%i", i);
1007 else
1008 return va("%f", f);
1009 }
1011 case V_CVAR_OR_STRING:
1012 case V_UI_CVAR:
1013 return UI_GetReferenceString(node, Com_GetValue<char*>(node, property));
1014 }
1015 break;
1016 default:
1017 break;
1018 }
1019
1020 Com_Printf("UI_GetStringFromNodeProperty: Unsupported string getter for property type 0x%X (%s@%s)\n", property->type, UI_GetPath(node), property->string);
1021 return nullptr;
1022}
1023
1031float UI_GetFloatFromNodeProperty (const uiNode_t* node, const value_t* property)
1032{
1033 assert(node);
1034
1035 if (property->type == V_FLOAT) {
1036 return Com_GetValue<float>(node, property);
1037 } else if ((property->type & V_UI_MASK) == V_UI_CVAR) {
1038 void* const b = Com_GetValue<void*>(node, property);
1039 if (char const* const cvarName = Q_strstart((char const*)b, "*cvar:")) {
1040 const cvar_t* cvar = Cvar_Get(cvarName, "", 0, "UI script cvar property");
1041 return cvar->value;
1042 } else if (property->type == V_CVAR_OR_FLOAT) {
1043 return *(const float*) b;
1044 } else if (property->type == V_CVAR_OR_STRING) {
1045 return atof((const char*)b);
1046 }
1047 } else if (property->type == V_INT) {
1048 return Com_GetValue<int>(node, property);
1049 } else if (property->type == V_BOOL) {
1050 return Com_GetValue<bool>(node, property);
1051 } else {
1052#ifdef DEBUG
1053 Com_Printf("UI_GetFloatFromNodeProperty: Unimplemented float getter for property '%s@%s'. If it should return a float, request it.\n", UI_GetPath(node), property->string);
1054#else
1055 Com_Printf("UI_GetFloatFromNodeProperty: Property '%s@%s' can't return a float\n", UI_GetPath(node), property->string);
1056#endif
1057 }
1058
1059 return 0;
1060}
1061
1066{
1067 while (node) {
1068 if (node->invalidated)
1069 return;
1070 node->invalidated = true;
1071 node = node->parent;
1072 }
1073}
1074
1079{
1080 if (node->invalidated)
1081 UI_Node_DoLayout(node);
1082}
1083
1094void UI_AddNodeMethod (uiNode_t* node, const char* name, LUA_METHOD fcn) {
1095 //Com_Printf ("UI_AddNodeMethod: registering node method [%s] on node [%s]\n", name, UI_GetPath(node));
1096
1097 /* the first method, so create a method table on this node */
1098 if (!node->nodeMethods) {
1099 node->nodeMethods = HASH_NewTable(true, true, false);
1100 }
1101 /* add the method */
1102 if (!HASH_Insert(node->nodeMethods, name, strlen(name), &fcn, sizeof(fcn))) {
1103 Com_Printf("UI_AddNodeMethod: method [%s] already defined on this behaviour [%s]\n", name, node->name);
1104 }
1105}
1106
1116bool UI_GetNodeMethod (const uiNode_t* node, const char* name, LUA_METHOD &fcn) {
1117 fcn = LUA_NOREF;
1118 // search the instance methods
1119 for(const uiNode_t* ref=node;ref;ref = ref->super) {
1120 if (ref->nodeMethods) {
1121 void* val=HASH_Get(ref->nodeMethods, name, strlen(name));
1122 if (val != nullptr) {
1123 fcn = *((LUA_METHOD *)val);
1124 return true;
1125 }
1126 }
1127 }
1128 // no instance method found, now scan for behaviour method
1129 return UI_GetBehaviourMethod(node->behaviour, name, fcn);
1130}
1131
1139bool UI_HasNodeMethod (uiNode_t* node, const char* name) {
1140 LUA_METHOD fn;
1141 // search the instance methods
1142 if (UI_GetNodeMethod(node, name, fn)) {
1143 return true;
1144 }
1145 // nothing found, now check behaviour methods
1146 return UI_GetBehaviourMethod(node->behaviour, name, fn);
1147}
1148
1149
1150
1159void UI_Node_SetItem (uiNode_t* node, const char* name, LUA_METHOD fcn) {
1160 UI_AddNodeMethod(node, name, fcn);
1161}
1162
1172 LUA_METHOD fcn;
1173 if (UI_GetNodeMethod(node, name, fcn)) {
1174 return fcn;
1175 }
1176 return LUA_NOREF;
1177}
unsigned int key
Definition cl_input.cpp:64
unsigned short unicode
Definition cl_input.cpp:65
PointerType get() const
Definition sharedptr.h:197
virtual bool onKeyReleased(uiNode_t *node, unsigned int key, unsigned short unicode)
virtual void onMouseUp(uiNode_t *node, int x, int y, int button)
virtual int getCellHeight(uiNode_t *node)
virtual void onMouseEnter(uiNode_t *node)
virtual void onMouseDown(uiNode_t *node, int x, int y, int button)
virtual int getCellWidth(uiNode_t *node)
virtual bool onKeyPressed(uiNode_t *node, unsigned int key, unsigned short unicode)
virtual void onFocusGained(uiNode_t *node)
virtual void drawOverWindow(uiNode_t *node)
virtual bool onDndMove(uiNode_t *node, int x, int y)
virtual void onCapturedMouseLost(uiNode_t *node)
virtual bool onDndFinished(uiNode_t *node, bool isDropped)
virtual void onDndLeave(uiNode_t *node)
virtual void draw(uiNode_t *node)
virtual void drawTooltip(const uiNode_t *node, int x, int y) const
virtual bool onStartDragging(uiNode_t *node, int startX, int startY, int currentX, int currentY, int button)
Send mouse event when a pressed mouse button is dragged.
virtual bool onMouseLongPress(uiNode_t *node, int x, int y, int button)
Send mouse event when a pressed mouse button is dragged.
virtual void onMouseMove(uiNode_t *node, int x, int y)
virtual void onSizeChanged(uiNode_t *node)
Callback stub.
virtual void onMiddleClick(uiNode_t *node, int x, int y)
virtual void onLeftClick(uiNode_t *node, int x, int y)
virtual void onFocusLost(uiNode_t *node)
virtual void onRightClick(uiNode_t *node, int x, int y)
virtual void onMouseLeave(uiNode_t *node)
virtual bool onScroll(uiNode_t *node, int deltaX, int deltaY)
virtual void onCapturedMouseMove(uiNode_t *node, int x, int y)
virtual void getClientPosition(uiNode_t const *node, vec2_t position)
virtual bool onDndEnter(uiNode_t *node)
virtual void doLayout(uiNode_t *node)
Call to update the node layout. This common code revalidates the node tree.
virtual bool onDndDrop(uiNode_t *node, int x, int y)
virtual void onWindowClosed(uiNode_t *node)
virtual void initNodeDynamic(uiNode_t *node)
virtual void onWindowOpened(uiNode_t *node, linkedList_t *params)
virtual void onPropertyChanged(uiNode_t *node, const value_t *property)
virtual void onLoading(uiNode_t *node)
virtual void onLoaded(uiNode_t *node)
virtual void deleteNode(uiNode_t *node)
virtual void onWindowActivate(uiNode_t *node)
virtual void clone(uiNode_t const *source, uiNode_t *clone)
virtual void initNode(uiNode_t *node)
virtual void onActivate(uiNode_t *node)
Activate the node. Can be used without the mouse (ie. a button will execute onClick).
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_DROP
Definition common.h:211
#define ERR_FATAL
Definition common.h:210
void Cvar_SetValue(const char *varName, float value)
Expands value to a string and calls Cvar_Set.
Definition cvar.cpp:671
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
Definition cvar.cpp:342
void * HASH_Get(hashTable_s *t, const void *key, int nkey)
Returns the value for a given key.
hashTable_s * HASH_NewTable(bool ownsKeys, bool ownsValues, bool duplicateOverwrite)
Creates a new hash table and sets it initial capacity.
bool HASH_Insert(hashTable_s *t, const void *key, int nkey, const void *value, int nvalue)
Inserts a new value with given key into the hash table.
Header file for hashtable.
voidpf void uLong size
Definition ioapi.h:42
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
#define Mem_PoolStrDup(in, pool, tagNum)
Definition mem.h:50
QGL_EXTERN GLuint count
Definition r_gl.h:99
QGL_EXTERN GLfloat f
Definition r_gl.h:114
QGL_EXTERN GLint i
Definition r_gl.h:113
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition r_gl.h:110
int Com_SetValue(void *base, const void *set, valueTypes_t type, int ofs, size_t size)
Definition scripts.cpp:1009
const char * Com_GetLastParseError(void)
Definition scripts.cpp:428
const char * Com_ValueToStr(const void *base, const valueTypes_t type, const int ofs)
Definition scripts.cpp:1171
resultStatus_t Com_ParseValue(void *base, const char *token, valueTypes_t type, int ofs, size_t size, size_t *writtenBytes)
Parse a value from a string.
Definition scripts.cpp:656
#define V_BASETYPEMASK
Allow to add extra bit into the type.
Definition scripts.h:41
T & Com_GetValue(void *const object, value_t const *const value)
Definition scripts.h:174
@ V_BOOL
Definition scripts.h:50
@ V_FLOAT
Definition scripts.h:54
@ V_INT
Definition scripts.h:52
@ RESULT_OK
Definition scripts.h:187
int LUA_METHOD
holds a reference to a lua event handler
Definition scripts_lua.h:53
#define Q_streq(a, b)
Definition shared.h:136
char const * Q_strstart(char const *str, char const *start)
Matches the start of a string.
Definition shared.cpp:587
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
Definition shared.cpp:410
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
Definition cvar.h:71
float value
Definition cvar.h:80
Atomic element to store UI scripts The parser use this atom to translate script action into many tree...
Definition ui_actions.h:144
node behaviour, how a node work
const char * name
UINodePtr manager
uiBehaviour_t * super
intptr_t extraDataSize
vec2_t size
Definition ui_nodes.h:52
vec2_t pos
Definition ui_nodes.h:51
Atomic structure used to define most of the UI.
Definition ui_nodes.h:80
bool disabled
Definition ui_nodes.h:102
char * tooltip
Definition ui_nodes.h:99
uiNode_t const * super
Definition ui_nodes.h:84
uiNode_t * firstChild
Definition ui_nodes.h:89
bool invis
Definition ui_nodes.h:101
uiNode_t * next
Definition ui_nodes.h:91
bool flash
Definition ui_nodes.h:107
char * text
Definition ui_nodes.h:121
bool indexed
Definition ui_nodes.h:86
uiNode_t * lastChild
Definition ui_nodes.h:90
bool invalidated
Definition ui_nodes.h:104
bool ghost
Definition ui_nodes.h:105
uiBehaviour_t * behaviour
Definition ui_nodes.h:83
char * font
Definition ui_nodes.h:122
uiNode_t * parent
Definition ui_nodes.h:92
hashTable_s * nodeMethods
Definition ui_nodes.h:132
uiBox_t box
Definition ui_nodes.h:96
char name[MAX_VAR]
Definition ui_nodes.h:82
char * image
Definition ui_nodes.h:123
uiNode_t * root
Definition ui_nodes.h:93
size_t ofs
Definition scripts.h:170
const char * string
Definition scripts.h:168
size_t size
Definition scripts.h:171
valueTypes_t type
Definition scripts.h:169
vec_t vec2_t[2]
Definition ufotypes.h:38
void UI_FreeStringProperty(void *pointer)
Free a string property if it is allocated into ui_dynStringPool.
bool UI_GetBehaviourMethod(const uiBehaviour_t *behaviour, const char *name, LUA_METHOD &fcn)
Finds the lua based method on this behaviour or its super.
Internal data use by the UI package.
void UI_HideNode(uiNode_t *node)
Hides a given node.
Definition ui_node.cpp:635
bool UI_HasNodeMethod(uiNode_t *node, const char *name)
Returns true if a node method of given name is available on this node or its super.
Definition ui_node.cpp:1139
void UI_Node_WindowClosed(uiNode_t *node)
Definition ui_node.cpp:251
bool UI_NodeInstanceOf(const uiNode_t *node, const char *behaviourName)
Check the node inheritance.
Definition ui_node.cpp:453
void UI_AddNodeMethod(uiNode_t *node, const char *name, LUA_METHOD fcn)
Adds a lua based method to the list of available node methods for calling.
Definition ui_node.cpp:1094
void UI_NodeRelativeToAbsolutePoint(const uiNode_t *node, vec2_t pos)
Update a relative point to an absolute one.
Definition ui_node.cpp:587
bool UI_Node_IsFunction(uiNode_t const *node)
Definition ui_node.cpp:85
void UI_Validate(uiNode_t *node)
Validate a node tree.
Definition ui_node.cpp:1078
bool UI_Node_IsVirtual(uiNode_t const *node)
Definition ui_node.cpp:42
void UI_MoveNode(uiNode_t *const parent, uiNode_t *prevNode, uiNode_t *node)
Moves a node in the tree.
Definition ui_node.cpp:840
void UI_Node_DrawTooltip(const uiNode_t *node, int x, int y)
Definition ui_node.cpp:115
void UI_Node_Clone(uiNode_t const *source, uiNode_t *clone)
Definition ui_node.cpp:220
const char * UI_Node_GetWidgetName(uiNode_t const *node)
Definition ui_node.cpp:99
void UI_Node_DeleteNode(uiNode_t *node)
Definition ui_node.cpp:237
const char * UI_GetStringFromNodeProperty(const uiNode_t *node, const value_t *property)
Return a string from a node property.
Definition ui_node.cpp:990
void UI_Node_SetImage(uiNode_t *node, const char *name)
Definition ui_node.cpp:398
void UI_Node_PropertyChanged(uiNode_t *node, const value_t *property)
Definition ui_node.cpp:277
uiNode_t * UI_GetPrevNode(const uiNode_t *node)
Returns the previous node based on the order of nodes in the parent.
Definition ui_node.cpp:733
void UI_NodeSetPropertyFromRAW(uiNode_t *node, const value_t *property, const void *rawValue, int rawType)
Definition ui_node.cpp:873
void UI_Node_DrawOverWindow(uiNode_t *node)
Definition ui_node.cpp:121
void UI_Node_InitNodeDynamic(uiNode_t *node)
Definition ui_node.cpp:226
bool UI_Node_KeyReleased(uiNode_t *node, unsigned int key, unsigned short unicode)
Definition ui_node.cpp:353
int UI_Node_GetCellWidth(uiNode_t *node)
Definition ui_node.cpp:361
void UI_Node_SizeChanged(uiNode_t *node)
Definition ui_node.cpp:289
void UI_NodeSetBox(uiNode_t *node, float x, float y, float w, float h)
Update the node size and height and fire callbacks.
Definition ui_node.cpp:699
LUA_METHOD UI_Node_GetItem(uiNode_t *node, const char *name)
This functions queries a lua based method in the internal uiNode behaviour.
Definition ui_node.cpp:1171
void UI_Node_GetClientPosition(uiNode_t const *node, vec2_t position)
Definition ui_node.cpp:295
void UI_Node_FocusLost(uiNode_t *node)
Definition ui_node.cpp:341
void UI_InsertNode(uiNode_t *const parent, uiNode_t *prevNode, uiNode_t *newNode)
Insert a node next another one into a node. If prevNode is nullptr add the node on the head of the wi...
Definition ui_node.cpp:764
void UI_Node_Activate(uiNode_t *node)
Definition ui_node.cpp:271
void UI_NodeSetSize(uiNode_t *node, vec2_t size)
Update the node size and fire the size callback.
Definition ui_node.cpp:678
void UI_Node_FocusGained(uiNode_t *node)
Definition ui_node.cpp:335
const char * UI_Node_GetTooltip(uiNode_t *node)
Definition ui_node.cpp:406
uiNode_t * UI_RemoveNode(uiNode_t *const node, uiNode_t *child)
Remove a node from a parent node.
Definition ui_node.cpp:802
void UI_UpdateRoot(uiNode_t *node, uiNode_t *newRoot)
Definition ui_node.cpp:853
void UI_Node_PosChanged(uiNode_t *node)
Definition ui_node.cpp:283
bool UI_Node_KeyPressed(uiNode_t *node, unsigned int key, unsigned short unicode)
Definition ui_node.cpp:347
void UI_Node_MouseUp(uiNode_t *node, int x, int y, int button)
Definition ui_node.cpp:164
bool UI_Node_DndEnter(uiNode_t *node)
Definition ui_node.cpp:303
void UI_Node_Loading(uiNode_t *node)
Definition ui_node.cpp:208
bool UI_Node_IsDrawItselfChild(uiNode_t const *node)
Definition ui_node.cpp:77
void UI_NodeAbsoluteToRelativePos(const uiNode_t *node, int *x, int *y)
Update an absolute position to a relative one.
Definition ui_node.cpp:604
bool UI_Node_IsGhost(uiNode_t const *node)
Definition ui_node.cpp:426
bool UI_Node_IsAbstract(uiNode_t const *node)
Definition ui_node.cpp:72
void UI_Node_DoLayout(uiNode_t *node)
Definition ui_node.cpp:263
void UI_Node_MouseDown(uiNode_t *node, int x, int y, int button)
Definition ui_node.cpp:158
bool UI_Node_IsDrawable(uiNode_t const *node)
Definition ui_node.cpp:48
void UI_Node_SetTooltip(uiNode_t *node, const char *tooltip)
Definition ui_node.cpp:410
int UI_Node_GetCellHeight(uiNode_t *node)
Definition ui_node.cpp:367
void UI_Invalidate(uiNode_t *node)
Invalidate a node and all his parent to request a layout update.
Definition ui_node.cpp:1065
void UI_Node_Draw(uiNode_t *node)
Definition ui_node.cpp:109
void UI_NodeGetPoint(const uiNode_t *node, vec2_t pos, int direction)
return a relative position of a point into a node.
Definition ui_node.cpp:484
void UI_Node_MouseLeave(uiNode_t *node)
Definition ui_node.cpp:176
uiNode_t * UI_FindNode(const uiNode_t *node, const char *name)
Recursive searches for a child node by name in the entire subtree.
Definition ui_node.cpp:745
void UI_Node_MouseMove(uiNode_t *node, int x, int y)
Definition ui_node.cpp:152
bool UI_Node_Scroll(uiNode_t *node, int deltaX, int deltaY)
Definition ui_node.cpp:146
void UI_Node_MouseEnter(uiNode_t *node)
Definition ui_node.cpp:170
void UI_Node_Loaded(uiNode_t *node)
Definition ui_node.cpp:214
bool UI_Node_MouseLongPress(uiNode_t *node, int x, int y, int button)
Definition ui_node.cpp:182
void UI_Node_SetItem(uiNode_t *node, const char *name, LUA_METHOD fcn)
This functions adds a lua based method to the internal uiNode behaviour.
Definition ui_node.cpp:1159
bool UI_Node_IsScrollableContainer(uiNode_t const *node)
Definition ui_node.cpp:93
void UI_Node_CapturedMouseMove(uiNode_t *node, int x, int y)
Definition ui_node.cpp:194
void UI_Node_CapturedMouseLost(uiNode_t *node)
Definition ui_node.cpp:200
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
bool UI_Node_DndFinished(uiNode_t *node, bool isDroped)
Definition ui_node.cpp:327
void UI_Node_LeftClick(uiNode_t *node, int x, int y)
Definition ui_node.cpp:128
bool UI_Node_IsWindow(uiNode_t const *node)
Definition ui_node.cpp:60
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
void UI_NodeSetPos(uiNode_t *node, vec2_t pos)
Update the node size and fire the pos callback.
Definition ui_node.cpp:658
void UI_Node_WindowActivate(uiNode_t *node)
Definition ui_node.cpp:257
const char * UI_Node_GetText(uiNode_t *node)
Definition ui_node.cpp:373
void UI_UnHideNode(uiNode_t *node)
Unhides a given node.
Definition ui_node.cpp:647
bool UI_Node_DndDrop(uiNode_t *node, int x, int y)
Definition ui_node.cpp:321
uiNode_t * UI_GetNode(const uiNode_t *node, const char *name)
Search a child node by given name.
Definition ui_node.cpp:714
bool UI_Node_StartDragging(uiNode_t *node, int startX, int startY, int currentX, int currentY, int button)
Definition ui_node.cpp:188
bool UI_Node_IsOptionContainer(uiNode_t const *node)
Definition ui_node.cpp:54
bool UI_Node_IsDisabled(uiNode_t const *node)
Definition ui_node.cpp:418
intptr_t UI_Node_GetMemorySize(uiNode_t const *node)
Definition ui_node.cpp:104
void UI_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
Definition ui_node.cpp:526
void UI_Node_SetFont(uiNode_t *node, const char *name)
Definition ui_node.cpp:390
bool UI_NodeSetProperty(uiNode_t *node, const value_t *property, const char *value)
Set node property.
Definition ui_node.cpp:902
void UI_Node_RightClick(uiNode_t *node, int x, int y)
Definition ui_node.cpp:134
bool UI_Node_IsBattleScape(uiNode_t const *node)
Definition ui_node.cpp:66
bool UI_NodeInstanceOfPointer(const uiNode_t *node, const uiBehaviour_t *behaviour)
Check the node inheritance.
Definition ui_node.cpp:468
void UI_Node_DndLeave(uiNode_t *node)
Definition ui_node.cpp:315
bool UI_Node_IsInvisible(uiNode_t const *node)
Definition ui_node.cpp:422
void UI_Node_InitNode(uiNode_t *node)
Definition ui_node.cpp:231
void UI_Node_SetDisabled(uiNode_t *node, const bool value)
Definition ui_node.cpp:434
void UI_GetNodeScreenPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node in the screen. Screen position is not used for the node rende...
Definition ui_node.cpp:554
void UI_Node_MiddleClick(uiNode_t *node, int x, int y)
Definition ui_node.cpp:140
void UI_Node_SetText(uiNode_t *node, const char *text)
Definition ui_node.cpp:382
void UI_Node_WindowOpened(uiNode_t *node, linkedList_t *params)
Definition ui_node.cpp:245
bool UI_Node_DndMove(uiNode_t *node, int x, int y)
Definition ui_node.cpp:309
bool UI_Node_IsFlashing(uiNode_t const *node)
Definition ui_node.cpp:430
float UI_GetFloatFromNodeProperty(const uiNode_t *node, const value_t *property)
Return a float from a node property.
Definition ui_node.cpp:1031
C interface to allow to access to cpp node code.
static int startY
static int startX
@ LAYOUTALIGN_V_BOTTOM
@ LAYOUTALIGN_V_TOP
@ LAYOUTALIGN_V_MIDDLE
@ LAYOUTALIGN_H_RIGHT
@ LAYOUTALIGN_H_LEFT
@ LAYOUTALIGN_H_MIDDLE
#define UI_GET_VERTICAL_ALIGN(align)
#define UI_GET_HORIZONTAL_ALIGN(align)
memPool_t * ui_dynStringPool
Definition ui_main.cpp:40
bool UI_WindowNodeAddIndexedNode(uiNode_t *const node, uiNode_t *const child)
Add a node to the child index.
bool UI_WindowNodeRemoveIndexedNode(uiNode_t *const node, uiNode_t *const child)
Remove a node from the child index.
const char * UI_GetPath(const uiNode_t *node)
Return a path from a window to a node.
Definition ui_nodes.cpp:174
float UI_GetReferenceFloat(const uiNode_t *const node, const void *ref)
Returns the value of the reference variable.
const char * UI_GetReferenceString(const uiNode_t *const node, const char *ref)
#define V_CVAR_OR_FLOAT
Definition ui_parse.h:68
#define V_UI_SPRITEREF
Definition ui_parse.h:56
#define V_CVAR_OR_LONGSTRING
Definition ui_parse.h:70
#define V_UI_ACTION
Definition ui_parse.h:54
#define V_UI_CVAR
Definition ui_parse.h:59
#define V_CVAR_OR_STRING
Definition ui_parse.h:69
#define V_UI
Definition ui_parse.h:52
#define V_NOT_UI
Definition ui_parse.h:53
#define V_UI_MASK
Definition ui_parse.h:51
uiSprite_t * UI_GetSpriteByName(const char *name)
Return an sprite by is name.
#define Vector2Equal(a, b)
Definition vector.h:67
#define Vector2Set(v, x, y)
Definition vector.h:61