34 #include "../cl_video.h"
35 #include "../input/cl_input.h"
36 #include "../input/cl_keys.h"
38 #define WINDOWEXTRADATA(node) UI_EXTRADATA(node, windowExtraData_t)
39 #define WINDOWEXTRADATACONST(node) UI_EXTRADATACONST(node, windowExtraData_t)
98 for (; i < j - 1; i++) {
150 assert(position > 0);
151 assert(window !=
nullptr);
175 if (window ==
nullptr) {
176 Com_Printf(
"Window \"%s\" not found.\n", name);
185 if (parentPos == -1) {
186 Com_Printf(
"Didn't find parent window \"%s\" for window push of \"%s\"\n", parentName, name);
215 char const*
const name = (*i)->name;
266 Com_Printf(
"Usage: %s <source-anchor> <point-in-source-anchor> <dest-anchor> <point-in-dest-anchor>\n",
Cmd_Argv(0));
272 if (node ==
nullptr) {
295 if (node ==
nullptr) {
310 if (node ==
nullptr) {
315 node->
box.
pos[0] += destination[0] - source[0];
316 node->
box.
pos[1] += destination[1] - source[1];
323 assert(position >= 0);
359 assert(activeWindow !=
nullptr);
360 Cvar_Set(
"ui_sys_active",
"%s", activeWindow);
367 Cvar_Set(
"ui_sys_main",
"%s", mainWindow);
391 Com_Printf(
"Window '%s' is not on the active stack\n", window->
name);
419 if (ui_sys_active->
string[0] !=
'\0')
424 if (ui_sys_main->
string[0] !=
'\0')
438 if (window ==
nullptr) {
529 if (window ==
nullptr)
569 unsigned char min = 0;
573 const int mid = (min + max) >> 1;
626 if (strcmp(window->
name, node->
name) < 0)
646 if (window ==
nullptr)
681 const char* mainWindow =
Cmd_Argv(1);
682 const char* optionWindow =
nullptr;
695 for (
int i = 0;
i < depth;
i++) {
716 if (node ==
nullptr) {
717 Com_Printf(
"No window by name '%s' exists\n", window);
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");
uiNode_t * windowStack[UI_MAX_WINDOWSTACK]
const char * Cmd_Argv(int arg)
Returns a given argument.
void Cmd_AddCommand(const char *cmdName, xcommand_t function, const char *desc)
Add a new command to the script interface.
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.
void UI_Node_WindowOpened(uiNode_t *node, linkedList_t *params)
void UI_InsertWindow(uiNode_t *window)
Add a new window to the list of all windows.
static void UI_CloseAllWindow(void)
static void UI_PopWindow_f(void)
Console function to pop a window from the window stack.
int UI_CompleteWithWindow(const char *partial, const char **match)
Complete function for ui_push.
bool UI_IsMouseOnWindow(void)
Check if a point is over a window from the stack.
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...
void UI_Invalidate(uiNode_t *node)
Invalidate a node and all his parent to request a layout update.
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
bool UI_WindowIsFullScreen(const uiNode_t *const node)
Check if a window is fullscreen or not.
const char * UI_GetActiveWindowName(void)
Returns the name of the current window.
uiNode_t * UI_GetActiveWindow(void)
Returns the current active window from the window stack or nullptr if there is none.
static void UI_PushWindow_f(void)
Console function to push a window onto the window stack.
static void UI_InitStack_f(void)
void Com_Printf(const char *const fmt,...)
bool Cmd_GenericCompleteFunction(char const *candidate, char const *partial, char const **match)
void UI_Node_WindowClosed(uiNode_t *node)
static void UI_DebugListWindows_f(void)
Debug function to list all UI windows.
void LIST_Delete(linkedList_t **list)
static void UI_RemoveWindowAtPositionFromStack(int position)
void UI_SetNewWindowPos(uiNode_t *window, int x, int y)
Sets new x and y coordinates for a given window.
void UI_InitStack(const char *activeWindow, const char *mainWindow)
Init the stack to start with a window, and have an alternative window with ESC.
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.
void Com_Error(int code, const char *fmt,...)
int UI_GetLastFullScreenWindow(void)
Returns the ID of the last fullscreen ID. Before this, window should be hidden.
void Key_SetDest(keydest_t keyDest)
Sets the keyDest in cls.
static int UI_GetWindowPositionFromStackByName(const char *name)
Searches the position in the current window stack for a given window id.
#define REMOVE_ELEM(array, index, n)
#define UI_MAX_WINDOWSTACK
uiNode_t * UI_PushWindow(const char *name, const char *parentName, linkedList_t *params)
Push a window onto the window stack.
static cvar_t * ui_sys_active
Main window of a stack.
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
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...
#define Vector2Set(v, x, y)
#define WINDOWEXTRADATACONST(node)
int Cmd_Argc(void)
Return the number of arguments of the current command. "command parameter" will result in a argc of 2...
static void UI_PushChildWindow_f(void)
Console function to push a child window onto the window stack.
bool UI_IsWindowOnStack(const char *name)
Check if a named window is on the stack if active windows.
void UI_CloseWindow(const char *name)
void UI_ExecuteEventActions(uiNode_t *source, const uiAction_t *firstAction)
void UI_NodeGetPoint(const uiNode_t *node, vec2_t pos, int direction)
return a relative position of a point into a node.
Atomic structure used to define most of the UI.
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.
uiNode_t * windows[UI_MAX_WINDOWS]
uiNode_t * UI_GetWindow(const char *name)
Searches all windows for the specified one.
void UI_Node_WindowActivate(uiNode_t *node)
void UI_PopWindowWithEscKey(void)
static void UI_DebugTree(const uiNode_t *node, int depth)
Display in the conde the tree of nodes.
void UI_FinishInit(void)
Finish initialization after everything was loaded.
#define WINDOWEXTRADATA(node)
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
void UI_RemoveWindow(uiNode_t *window)
Removes a window from the list of all windows.
void UI_PopWindow(bool all)
Pops a window from the window stack.
bool UI_Node_IsBattleScape(uiNode_t const *node)
void UI_InitWindows(void)
void Cmd_AddParamCompleteFunction(const char *cmdName, int(*function)(const char *partial, const char **match))
static void UI_CloseWindow_f(void)
Console function to close a named window.
static cvar_t * ui_sys_main
Window name use as alternative for option.
const char * UI_Node_GetWidgetName(uiNode_t const *node)
void UI_InvalidateStack(void)
Invalidate all windows of the current stack.
cvar_t * Cvar_Set(const char *varName, const char *value,...)
Sets a cvar value.
static void UI_CloseWindowByRef(uiNode_t *window)
static void UI_DebugTree_f(void)
static void UI_InsertWindowIntoStack(uiNode_t *window, int position)
Insert a window at a position of the stack.
void Cvar_SetValue(const char *varName, float value)
Expands value to a string and calls Cvar_Set.
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...
static void UI_Popup_f(void)
void UI_FinishWindowsInit(void)
Finish windows initialization.
void UI_NodeRelativeToAbsolutePoint(const uiNode_t *node, vec2_t pos)
Update a relative point to an absolute one.