UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ui_windows.cpp
Go to the documentation of this file.
1 
5 /*
6 Copyright (C) 2002-2020 UFO: Alien Invasion.
7 
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 
17 See the GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 
23 */
24 
25 #include "ui_main.h"
26 #include "ui_internal.h"
27 #include "ui_input.h"
28 #include "ui_node.h"
29 #include "ui_popup.h"
31 #include "node/ui_node_window.h"
33 
34 #include "../cl_video.h"
35 #include "../input/cl_input.h"
36 #include "../input/cl_keys.h"
37 
38 #define WINDOWEXTRADATA(node) UI_EXTRADATA(node, windowExtraData_t)
39 #define WINDOWEXTRADATACONST(node) UI_EXTRADATACONST(node, windowExtraData_t)
40 
45 
50 
56 {
57  /* stack pos */
58  int pos = ui_global.windowStackPos - 1;
59  while (pos > 0) {
61  break;
62  pos--;
63  }
64  /* if we find nothing we return 0 */
65  return pos;
66 }
67 
75 {
76  int i, j;
77 
78  if (UI_WindowIsFullScreen(window))
79  return;
80 
81  /* get window index */
82  for (i = 0; i < ui_global.windowStackPos; i++) {
83  if (ui_global.windowStack[i] == window)
84  break;
85  }
86 
87  /* search the last compatible window */
88  for (j = i; j < ui_global.windowStackPos; j++) {
90  break;
91  if (WINDOWEXTRADATA(window).parent != WINDOWEXTRADATA(ui_global.windowStack[j]).parent)
92  break;
93  }
94  if (i + 1 == j)
95  return;
96 
97  /* translate windows */
98  for (; i < j - 1; i++) {
100  }
101  /* add the current window on top */
102  ui_global.windowStack[i] = window;
103 }
104 
110 static void UI_DeleteWindowFromStack (uiNode_t* window)
111 {
112  int i;
113 
114  /* get window index */
115  for (i = 0; i < ui_global.windowStackPos; i++) {
116  if (ui_global.windowStack[i] == window)
117  break;
118  }
119 
120  /* update stack */
121  if (i < ui_global.windowStackPos) {
123  for (; i < ui_global.windowStackPos; i++)
126  }
127 }
128 
133 static inline int UI_GetWindowPositionFromStackByName (const char* name)
134 {
135  for (int i = 0; i < ui_global.windowStackPos; i++)
136  if (Q_streq(ui_global.windowStack[i]->name, name))
137  return i;
138 
139  return -1;
140 }
141 
147 static inline void UI_InsertWindowIntoStack (uiNode_t* window, int position)
148 {
149  assert(position <= ui_global.windowStackPos);
150  assert(position > 0);
151  assert(window != nullptr);
152 
153  /* create space for the new window */
154  for (int i = ui_global.windowStackPos; i > position; i--) {
156  }
157  /* insert */
158  ui_global.windowStack[position] = window;
160 }
161 
170 uiNode_t* UI_PushWindow (const char* name, const char* parentName, linkedList_t* params)
171 {
172  UI_ReleaseInput();
173 
174  uiNode_t* window = UI_GetWindow(name);
175  if (window == nullptr) {
176  Com_Printf("Window \"%s\" not found.\n", name);
177  return nullptr;
178  }
179 
180  UI_DeleteWindowFromStack(window);
181 
183  if (parentName) {
184  const int parentPos = UI_GetWindowPositionFromStackByName(parentName);
185  if (parentPos == -1) {
186  Com_Printf("Didn't find parent window \"%s\" for window push of \"%s\"\n", parentName, name);
187  return nullptr;
188  }
189  UI_InsertWindowIntoStack(window, parentPos + 1);
190  WINDOWEXTRADATA(window).parent = ui_global.windowStack[parentPos];
191  } else
193  else
194  Com_Printf("Window stack overflow\n");
195 
196  UI_Node_WindowOpened(window, params);
197 
198  /* change from e.g. console mode to game input mode (fetch input) */
200 
202  return window;
203 }
204 
211 int UI_CompleteWithWindow (const char* partial, const char** match)
212 {
213  int n = 0;
214  for (uiNode_t** i = ui_global.windows, ** const end = i + ui_global.numWindows; i != end; ++i) {
215  char const* const name = (*i)->name;
216  if (Cmd_GenericCompleteFunction(name, partial, match)) {
217  Com_Printf("%s\n", name);
218  ++n;
219  }
220  }
221  return n;
222 }
223 
228 static void UI_PushChildWindow_f (void)
229 {
230  if (Cmd_Argc() > 1)
232  else
233  Com_Printf("Usage: %s <name> <parentname>\n", Cmd_Argv(0));
234 }
235 
240 static void UI_PushWindow_f (void)
241 {
242  if (Cmd_Argc() == 0) {
243  Com_Printf("Usage: %s <name> <params>\n", Cmd_Argv(0));
244  return;
245  }
246 
247  linkedList_t* params = nullptr;
248  for (int i = 2; i < Cmd_Argc(); i++) {
249  LIST_AddString(&params, Cmd_Argv(i));
250  }
251  UI_PushWindow(Cmd_Argv(1), nullptr, params);
252  LIST_Delete(&params);
253 }
254 
263 static void UI_PushDropDownWindow_f (void)
264 {
265  if (Cmd_Argc() != 4 && Cmd_Argc() != 5) {
266  Com_Printf("Usage: %s <source-anchor> <point-in-source-anchor> <dest-anchor> <point-in-dest-anchor>\n", Cmd_Argv(0));
267  return;
268  }
269 
270  /* get the source anchor */
271  uiNode_t* node = UI_GetNodeByPath(Cmd_Argv(1));
272  if (node == nullptr) {
273  Com_Printf("UI_PushDropDownWindow_f: Node '%s' doesn't exist\n", Cmd_Argv(1));
274  return;
275  }
276  size_t writtenBytes;
277  int direction;
278  int result = Com_ParseValue(&direction, Cmd_Argv(2), V_INT, 0, sizeof(direction), &writtenBytes);
279  if (result != RESULT_OK) {
280  Com_Printf("UI_PushDropDownWindow_f: '%s' in not a V_INT\n", Cmd_Argv(2));
281  return;
282  }
283  vec2_t source;
284  vec2_t destination;
285  UI_NodeGetPoint(node, source, direction);
286  UI_NodeRelativeToAbsolutePoint(node, source);
287 
288  /* get the destination anchor */
289  if (Q_streq(Cmd_Argv(4), "mouse")) {
290  destination[0] = mousePosX;
291  destination[1] = mousePosY;
292  } else {
293  /* get the source anchor */
294  node = UI_GetNodeByPath(Cmd_Argv(3));
295  if (node == nullptr) {
296  Com_Printf("UI_PushDropDownWindow_f: Node '%s' doesn't exist\n", Cmd_Argv(3));
297  return;
298  }
299  result = Com_ParseValue(&direction, Cmd_Argv(4), V_INT, 0, sizeof(direction), &writtenBytes);
300  if (result != RESULT_OK) {
301  Com_Printf("UI_PushDropDownWindow_f: '%s' in not a V_INT\n", Cmd_Argv(4));
302  return;
303  }
304  UI_NodeGetPoint(node, destination, direction);
305  UI_NodeRelativeToAbsolutePoint(node, destination);
306  }
307 
308  /* update the window and push it */
309  node = UI_GetNodeByPath(Cmd_Argv(1));
310  if (node == nullptr) {
311  Com_Printf("UI_PushDropDownWindow_f: Node '%s' doesn't exist\n", Cmd_Argv(1));
312  return;
313  }
314  node = node->root;
315  node->box.pos[0] += destination[0] - source[0];
316  node->box.pos[1] += destination[1] - source[1];
317  UI_PushWindow(node->name);
318 }
319 
320 static void UI_RemoveWindowAtPositionFromStack (int position)
321 {
322  assert(position < ui_global.windowStackPos);
323  assert(position >= 0);
324 
325  /* create space for the new window */
326  for (int i = position; i < ui_global.windowStackPos; i++) {
328  }
330 }
331 
332 static void UI_CloseAllWindow (void)
333 {
334  for (int i = ui_global.windowStackPos - 1; i >= 0; i--) {
335  uiNode_t* window = ui_global.windowStack[i];
336 
337  UI_Node_WindowClosed(window);
338 
339  /* safe: unlink window */
340  WINDOWEXTRADATA(window).parent = nullptr;
343  }
344 }
345 
354 void UI_InitStack (const char* activeWindow, const char* mainWindow)
355 {
356  UI_FinishInit();
357  UI_PopWindow(true);
358 
359  assert(activeWindow != nullptr);
360  Cvar_Set("ui_sys_active", "%s", activeWindow);
361  /* prevent calls before UI script initialization */
362  if (ui_global.numWindows != 0) {
363  UI_PushWindow(activeWindow);
364  }
365 
366  if (mainWindow)
367  Cvar_Set("ui_sys_main", "%s", mainWindow);
368 }
369 
373 bool UI_IsWindowOnStack (const char* name)
374 {
375  return UI_GetWindowPositionFromStackByName(name) != -1;
376 }
377 
381 static void UI_CloseWindowByRef (uiNode_t* window)
382 {
383  uiNode_t* oldfirst = ui_global.windowStack[0];
384 
386  UI_ReleaseInput();
387 
388  assert(ui_global.windowStackPos);
390  if (i == -1) {
391  Com_Printf("Window '%s' is not on the active stack\n", window->name);
392  return;
393  }
394 
395  /* close child */
396  while (i + 1 < ui_global.windowStackPos) {
397  uiNode_t* m = ui_global.windowStack[i + 1];
398  if (WINDOWEXTRADATA(m).parent != window) {
399  break;
400  }
401 
402  UI_Node_WindowClosed(window);
403  WINDOWEXTRADATA(m).parent = nullptr;
405  }
406 
407  /* close the window */
408  UI_Node_WindowClosed(window);
409  WINDOWEXTRADATA(window).parent = nullptr;
411 
413 
414  if (ui_global.windowStackPos == 0) {
415  /* ui_sys_main contains the window that is the very first window and should be
416  * pushed back onto the stack (otherwise there would be no window at all
417  * right now) */
418  if (Q_streq(oldfirst->name, ui_sys_main->string)) {
419  if (ui_sys_active->string[0] != '\0')
420  UI_PushWindow(ui_sys_active->string);
422  UI_PushWindow(ui_sys_main->string);
423  } else {
424  if (ui_sys_main->string[0] != '\0')
425  UI_PushWindow(ui_sys_main->string);
427  UI_PushWindow(ui_sys_active->string);
428  }
429  }
430 
431  uiNode_t* activeWindow = UI_GetActiveWindow();
432  UI_Node_WindowActivate(activeWindow);
433 }
434 
435 void UI_CloseWindow (const char* name)
436 {
437  uiNode_t* window = UI_GetWindow(name);
438  if (window == nullptr) {
439  Com_Printf("Window '%s' not found\n", name);
440  return;
441  }
442 
443  /* found the correct add it to stack or bring it on top */
444  UI_CloseWindowByRef(window);
445 }
446 
452 void UI_PopWindow (bool all)
453 {
454  if (all) {
456  } else {
459  return;
460  if (WINDOWEXTRADATA(mainWindow).parent)
461  mainWindow = WINDOWEXTRADATA(mainWindow).parent;
462  UI_CloseWindowByRef(mainWindow);
463  }
464 
465  /* change from e.g. console mode to game input mode (fetch input) */
467 }
468 
473 static void UI_CloseWindow_f (void)
474 {
475  if (Cmd_Argc() != 2) {
476  Com_Printf("Usage: %s <name>\n", Cmd_Argv(0));
477  return;
478  }
479 
481 }
482 
484 {
485  /* nothing if stack is empty */
486  if (ui_global.windowStackPos == 0)
487  return;
488 
489  /* some window can prevent escape */
491  if (WINDOWEXTRADATACONST(window).preventTypingEscape)
492  return;
493 
494  UI_PopWindow();
495 }
496 
501 static void UI_PopWindow_f (void)
502 {
503  if (Cmd_Argc() > 1) {
504  Com_Printf("Usage: %s\n", Cmd_Argv(0));
505  return;
506  }
507 
508  UI_PopWindow();
509 }
510 
517 {
519 }
520 
526 const char* UI_GetActiveWindowName (void)
527 {
528  const uiNode_t* window = UI_GetActiveWindow();
529  if (window == nullptr)
530  return "";
531  return window->name;
532 }
533 
539 {
540  if (UI_GetMouseCapture() != nullptr)
541  return true;
542 
543  if (ui_global.windowStackPos != 0) {
545  return true;
546  }
547 
548  const uiNode_t* hovered = UI_GetHoveredNode();
549  if (hovered) {
550  /* else if it is a render node */
551  if (UI_Node_IsBattleScape(hovered)) {
552  return false;
553  }
554  return true;
555  }
556 
557  return true;
558 }
559 
567 uiNode_t* UI_GetWindow (const char* name)
568 {
569  unsigned char min = 0;
570  unsigned char max = ui_global.numWindows;
571 
572  while (min != max) {
573  const int mid = (min + max) >> 1;
574  const int diff = strcmp(ui_global.windows[mid]->name, name);
575  assert(mid < max);
576  assert(mid >= min);
577 
578  if (diff == 0)
579  return ui_global.windows[mid];
580 
581  if (diff > 0)
582  max = mid;
583  else
584  min = mid + 1;
585  }
586 
587  return nullptr;
588 }
589 
594 {
595  for (int pos = 0; pos < ui_global.windowStackPos; pos++) {
597  }
598  Cvar_SetValue("ui_sys_screenwidth", viddef.virtualWidth);
599  Cvar_SetValue("ui_sys_screenheight", viddef.virtualHeight);
600 }
601 
606 void UI_SetNewWindowPos (uiNode_t* window, int x, int y)
607 {
608  if (window)
609  Vector2Set(window->box.pos, x, y);
610 }
611 
616 void UI_InsertWindow (uiNode_t* window)
617 {
618 
620  Com_Error(ERR_FATAL, "UI_InsertWindow: hit UI_MAX_WINDOWS");
621 
622  /* search the insertion position */
623  int pos;
624  for (pos = 0; pos < ui_global.numWindows; pos++) {
625  const uiNode_t* node = ui_global.windows[pos];
626  if (strcmp(window->name, node->name) < 0)
627  break;
628  }
629 
630  /* create the space */
631  for (int i = ui_global.numWindows - 1; i >= pos; i--)
633 
634  /* insert */
635  ui_global.windows[pos] = window;
637 }
638 
644 void UI_RemoveWindow (uiNode_t* window)
645 {
646  if (window == nullptr)
647  return;
648 
649  int pos;
650  for (pos = 0; pos < ui_global.numWindows; pos++) {
651  const uiNode_t* node = ui_global.windows[pos];
652  if (window == node)
653  break;
654  }
655  if (pos == ui_global.numWindows)
656  return;
657 
659 }
660 
666 {
667  for (int i = 0; i < ui_global.numWindows; i++) {
668  uiNode_t* window = ui_global.windows[i];
669  if (WINDOWEXTRADATA(window).onScriptLoaded)
670  UI_ExecuteEventActions(window, WINDOWEXTRADATA(window).onScriptLoaded);
671  }
672 }
673 
674 static void UI_InitStack_f (void)
675 {
676  if (Cmd_Argc() < 2) {
677  Com_Printf("Usage: %s <mainwindow> [<optionwindow>]\n", Cmd_Argv(0));
678  return;
679  }
680 
681  const char* mainWindow = Cmd_Argv(1);
682  const char* optionWindow = nullptr;
683  if (Cmd_Argc() == 3) {
684  optionWindow = Cmd_Argv(2);
685  }
686 
687  UI_InitStack(mainWindow, optionWindow);
688 }
689 
693 static void UI_DebugTree (const uiNode_t* node, int depth)
694 {
695  for (int i = 0; i < depth; i++) {
696  Com_Printf(" ");
697  }
698  Com_Printf("+ %s %s\n", UI_Node_GetWidgetName(node), node->name);
699 
700  const uiNode_t* child = node->firstChild;
701  while (child) {
702  UI_DebugTree(child, depth + 1);
703  child = child->next;
704  }
705 }
706 
707 static void UI_DebugTree_f (void)
708 {
709  if (Cmd_Argc() != 2) {
710  Com_Printf("Usage: %s <mainwindow>\n", Cmd_Argv(0));
711  return;
712  }
713 
714  const char* window = Cmd_Argv(1);
715  const uiNode_t* node = UI_GetWindow(window);
716  if (node == nullptr) {
717  Com_Printf("No window by name '%s' exists\n", window);
718  return;
719  }
720 
721  UI_DebugTree(node, 0);
722 }
723 
724 static void UI_Popup_f (void)
725 {
726  if (Cmd_Argc() != 3) {
727  Com_Printf("Usage: %s <header> <body>\n", Cmd_Argv(0));
728  return;
729  }
730 
731  const char* header = Cmd_Argv(1);
732  const char* body = Cmd_Argv(2);
733  UI_Popup(header, body);
734 }
735 
739 static void UI_DebugListWindows_f (void)
740 {
741  for (int i = 0; i < ui_global.numWindows; i++) {
742  const uiNode_t* const window = ui_global.windows[i];
743  Com_Printf("%3d. %s\n", i, window->name);
744  }
745 }
746 
747 void UI_InitWindows (void)
748 {
749  ui_sys_main = Cvar_Get("ui_sys_main", "", 0, "This is the main window id that is at the very first window stack - also see ui_sys_active");
750  ui_sys_active = Cvar_Get("ui_sys_active", "", 0, "The active window we will return to when hitting esc once - also see ui_sys_main");
751 
752  /* add command */
753  Cmd_AddCommand("ui_push", UI_PushWindow_f, "Push a window to the window stack");
755  Cmd_AddCommand("ui_push_dropdown", UI_PushDropDownWindow_f, "Push a dropdown window at a position");
756  Cmd_AddCommand("ui_push_child", UI_PushChildWindow_f, "Push a window to the windowstack with a big dependency to a parent window");
757  Cmd_AddCommand("ui_pop", UI_PopWindow_f, "Pops the current window from the stack");
758  Cmd_AddCommand("ui_close", UI_CloseWindow_f, "Close a window");
759  Cmd_AddCommand("ui_initstack", UI_InitStack_f, "Initialize the window stack with a main and an option window.");
760  Cmd_AddCommand("ui_tree", UI_DebugTree_f, "Display a tree of nodes from a window into the console.");
761  Cmd_AddCommand("ui_listwindows", UI_DebugListWindows_f, "List all UI windows exist into the console.");
762  Cmd_AddCommand("ui_popup", UI_Popup_f, "Shows a popup window");
764 }
uiNode_t * windowStack[UI_MAX_WINDOWSTACK]
Definition: ui_internal.h:77
const char * Cmd_Argv(int arg)
Returns a given argument.
Definition: cmd.cpp:516
void Cmd_AddCommand(const char *cmdName, xcommand_t function, const char *desc)
Add a new command to the script interface.
Definition: cmd.cpp:744
void UI_MoveWindowOnTop(uiNode_t *window)
Move the window on top of compatible windows. "Compatible" mean non full screen windows, and windows with the same window parent.
Definition: ui_windows.cpp:74
void UI_Node_WindowOpened(uiNode_t *node, linkedList_t *params)
Definition: ui_node.cpp:245
void UI_InsertWindow(uiNode_t *window)
Add a new window to the list of all windows.
Definition: ui_windows.cpp:616
uiNode_t * next
Definition: ui_nodes.h:91
static void UI_CloseAllWindow(void)
Definition: ui_windows.cpp:332
static void UI_PopWindow_f(void)
Console function to pop a window from the window stack.
Definition: ui_windows.cpp:501
uiGlobal_t ui_global
Definition: ui_main.cpp:38
int UI_CompleteWithWindow(const char *partial, const char **match)
Complete function for ui_push.
Definition: ui_windows.cpp:211
bool UI_IsMouseOnWindow(void)
Check if a point is over a window from the stack.
Definition: ui_windows.cpp:538
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...
Definition: ui_nodes.cpp:313
void UI_Invalidate(uiNode_t *node)
Invalidate a node and all his parent to request a layout update.
Definition: ui_node.cpp:1053
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
Definition: cvar.h:71
bool UI_WindowIsFullScreen(const uiNode_t *const node)
Check if a window is fullscreen or not.
int windowStackPos
Definition: ui_internal.h:78
const char * UI_GetActiveWindowName(void)
Returns the name of the current window.
Definition: ui_windows.cpp:526
uiNode_t * UI_GetActiveWindow(void)
Returns the current active window from the window stack or nullptr if there is none.
Definition: ui_windows.cpp:516
char name[MAX_VAR]
Definition: ui_nodes.h:82
static void UI_PushWindow_f(void)
Console function to push a window onto the window stack.
Definition: ui_windows.cpp:240
static void UI_InitStack_f(void)
Definition: ui_windows.cpp:674
viddef_t viddef
Definition: cl_video.cpp:34
void UI_InvalidateMouse(void)
Force to invalidate the mouse position and then to update hover nodes...
Definition: ui_input.cpp:560
void Com_Printf(const char *const fmt,...)
Definition: common.cpp:386
bool Cmd_GenericCompleteFunction(char const *candidate, char const *partial, char const **match)
Definition: cmd.cpp:648
void UI_Node_WindowClosed(uiNode_t *node)
Definition: ui_node.cpp:251
static void UI_DebugListWindows_f(void)
Debug function to list all UI windows.
Definition: ui_windows.cpp:739
int virtualHeight
Definition: cl_video.h:74
void LIST_Delete(linkedList_t **list)
Definition: list.cpp:195
static void UI_RemoveWindowAtPositionFromStack(int position)
Definition: ui_windows.cpp:320
void UI_SetNewWindowPos(uiNode_t *window, int x, int y)
Sets new x and y coordinates for a given window.
Definition: ui_windows.cpp:606
void UI_InitStack(const char *activeWindow, const char *mainWindow)
Init the stack to start with a window, and have an alternative window with ESC.
Definition: ui_windows.cpp:354
#define ERR_FATAL
Definition: common.h:210
Internal data use by the UI package.
C interface to allow to access to cpp node code.
static void UI_DeleteWindowFromStack(uiNode_t *window)
Remove the window from the window stack.
Definition: ui_windows.cpp:110
void Com_Error(int code, const char *fmt,...)
Definition: common.cpp:417
int UI_GetLastFullScreenWindow(void)
Returns the ID of the last fullscreen ID. Before this, window should be hidden.
Definition: ui_windows.cpp:55
void Key_SetDest(keydest_t keyDest)
Sets the keyDest in cls.
Definition: cl_keys.cpp:815
static int UI_GetWindowPositionFromStackByName(const char *name)
Searches the position in the current window stack for a given window id.
Definition: ui_windows.cpp:133
#define REMOVE_ELEM(array, index, n)
Definition: common.h:408
#define UI_MAX_WINDOWSTACK
Definition: ui_internal.h:31
uiNode_t * root
Definition: ui_nodes.h:93
uiNode_t * UI_PushWindow(const char *name, const char *parentName, linkedList_t *params)
Push a window onto the window stack.
Definition: ui_windows.cpp:170
static cvar_t * ui_sys_active
Main window of a stack.
Definition: ui_windows.cpp:49
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 LIST_AddString(linkedList_t **listDest, const char *data)
Adds an string to a new or to an already existing linked list. The string is copied here...
Definition: list.cpp:139
int mousePosY
Definition: cl_input.cpp:80
#define Vector2Set(v, x, y)
Definition: vector.h:61
#define WINDOWEXTRADATACONST(node)
Definition: ui_windows.cpp:39
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
static void UI_PushChildWindow_f(void)
Console function to push a child window onto the window stack.
Definition: ui_windows.cpp:228
bool UI_IsWindowOnStack(const char *name)
Check if a named window is on the stack if active windows.
Definition: ui_windows.cpp:373
void UI_CloseWindow(const char *name)
Definition: ui_windows.cpp:435
void UI_ExecuteEventActions(uiNode_t *source, const uiAction_t *firstAction)
Definition: ui_actions.cpp:726
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:472
uiNode_t * UI_GetMouseCapture(void)
Return the captured node.
Definition: ui_input.cpp:508
Atomic structure used to define most of the UI.
Definition: ui_nodes.h:80
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:659
uiNode_t * windows[UI_MAX_WINDOWS]
Definition: ui_internal.h:68
uiNode_t * UI_GetWindow(const char *name)
Searches all windows for the specified one.
Definition: ui_windows.cpp:567
void UI_Node_WindowActivate(uiNode_t *node)
Definition: ui_node.cpp:257
void UI_PopWindowWithEscKey(void)
Definition: ui_windows.cpp:483
static void UI_DebugTree(const uiNode_t *node, int depth)
Display in the conde the tree of nodes.
Definition: ui_windows.cpp:693
int numWindows
Definition: ui_internal.h:69
void UI_FinishInit(void)
Finish initialization after everything was loaded.
Definition: ui_main.cpp:268
#define WINDOWEXTRADATA(node)
Definition: ui_windows.cpp:38
QGL_EXTERN GLint i
Definition: r_gl.h:113
char * string
Definition: cvar.h:73
#define UI_MAX_WINDOWS
Definition: ui_internal.h:29
void UI_ReleaseInput(void)
Release all captured input (keyboard or mouse)
Definition: ui_input.cpp:496
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition: r_gl.h:110
void UI_RemoveWindow(uiNode_t *window)
Removes a window from the list of all windows.
Definition: ui_windows.cpp:644
void UI_PopWindow(bool all)
Pops a window from the window stack.
Definition: ui_windows.cpp:452
bool UI_Node_IsBattleScape(uiNode_t const *node)
Definition: ui_node.cpp:66
vec_t vec2_t[2]
Definition: ufotypes.h:38
void UI_InitWindows(void)
Definition: ui_windows.cpp:747
Definition: scripts.h:52
void Cmd_AddParamCompleteFunction(const char *cmdName, int(*function)(const char *partial, const char **match))
Definition: cmd.cpp:679
static void UI_CloseWindow_f(void)
Console function to close a named window.
Definition: ui_windows.cpp:473
static cvar_t * ui_sys_main
Window name use as alternative for option.
Definition: ui_windows.cpp:44
const char * UI_Node_GetWidgetName(uiNode_t const *node)
Definition: ui_node.cpp:99
void UI_InvalidateStack(void)
Invalidate all windows of the current stack.
Definition: ui_windows.cpp:593
int virtualWidth
Definition: cl_video.h:74
uiNode_t * firstChild
Definition: ui_nodes.h:89
cvar_t * Cvar_Set(const char *varName, const char *value,...)
Sets a cvar value.
Definition: cvar.cpp:615
#define Q_streq(a, b)
Definition: shared.h:136
uiBox_t box
Definition: ui_nodes.h:96
static void UI_CloseWindowByRef(uiNode_t *window)
Definition: ui_windows.cpp:381
int mousePosX
Definition: cl_input.cpp:80
static void UI_DebugTree_f(void)
Definition: ui_windows.cpp:707
uiNode_t * UI_GetHoveredNode(void)
Get the current hovered node.
Definition: ui_input.cpp:552
void UI_Popup(const char *title, const char *text)
Popup on geoscape.
Definition: ui_popup.cpp:47
static void UI_InsertWindowIntoStack(uiNode_t *window, int position)
Insert a window at a position of the stack.
Definition: ui_windows.cpp:147
void Cvar_SetValue(const char *varName, float value)
Expands value to a string and calls Cvar_Set.
Definition: cvar.cpp:671
static void UI_PushDropDownWindow_f(void)
Console function to push a dropdown window at a position. It work like UI_PushWindow but move the win...
Definition: ui_windows.cpp:263
static void UI_Popup_f(void)
Definition: ui_windows.cpp:724
static struct mdfour * m
Definition: md4.cpp:35
void UI_FinishWindowsInit(void)
Finish windows initialization.
Definition: ui_windows.cpp:665
void UI_NodeRelativeToAbsolutePoint(const uiNode_t *node, vec2_t pos)
Update a relative point to an absolute one.
Definition: ui_node.cpp:575
vec2_t pos
Definition: ui_nodes.h:51