UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ui_windows.cpp File Reference
#include "ui_main.h"
#include "ui_internal.h"
#include "ui_input.h"
#include "ui_node.h"
#include "ui_popup.h"
#include "node/ui_node_abstractnode.h"
#include "node/ui_node_window.h"
#include "node/ui_node_battlescape.h"
#include "../cl_video.h"
#include "../input/cl_input.h"
#include "../input/cl_keys.h"

Go to the source code of this file.

Macros

#define WINDOWEXTRADATA(node)   UI_EXTRADATA(node, windowExtraData_t)
 
#define WINDOWEXTRADATACONST(node)   UI_EXTRADATACONST(node, windowExtraData_t)
 

Functions

int UI_GetLastFullScreenWindow (void)
 Returns the ID of the last fullscreen ID. Before this, window should be hidden. More...
 
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. More...
 
static void UI_DeleteWindowFromStack (uiNode_t *window)
 Remove the window from the window stack. More...
 
static int UI_GetWindowPositionFromStackByName (const char *name)
 Searches the position in the current window stack for a given window id. More...
 
static void UI_InsertWindowIntoStack (uiNode_t *window, int position)
 Insert a window at a position of the stack. More...
 
uiNode_tUI_PushWindow (const char *name, const char *parentName, linkedList_t *params)
 Push a window onto the window stack. More...
 
int UI_CompleteWithWindow (const char *partial, const char **match)
 Complete function for ui_push. More...
 
static void UI_PushChildWindow_f (void)
 Console function to push a child window onto the window stack. More...
 
static void UI_PushWindow_f (void)
 Console function to push a window onto the window stack. More...
 
static void UI_PushDropDownWindow_f (void)
 Console function to push a dropdown window at a position. It work like UI_PushWindow but move the window at the right position. More...
 
static void UI_RemoveWindowAtPositionFromStack (int position)
 
static void UI_CloseAllWindow (void)
 
void UI_InitStack (const char *activeWindow, const char *mainWindow)
 Init the stack to start with a window, and have an alternative window with ESC. More...
 
bool UI_IsWindowOnStack (const char *name)
 Check if a named window is on the stack if active windows. More...
 
static void UI_CloseWindowByRef (uiNode_t *window)
 
void UI_CloseWindow (const char *name)
 
void UI_PopWindow (bool all)
 Pops a window from the window stack. More...
 
static void UI_CloseWindow_f (void)
 Console function to close a named window. More...
 
void UI_PopWindowWithEscKey (void)
 
static void UI_PopWindow_f (void)
 Console function to pop a window from the window stack. More...
 
uiNode_tUI_GetActiveWindow (void)
 Returns the current active window from the window stack or nullptr if there is none. More...
 
const char * UI_GetActiveWindowName (void)
 Returns the name of the current window. More...
 
bool UI_IsMouseOnWindow (void)
 Check if a point is over a window from the stack. More...
 
uiNode_tUI_GetWindow (const char *name)
 Searches all windows for the specified one. More...
 
void UI_InvalidateStack (void)
 Invalidate all windows of the current stack. More...
 
void UI_SetNewWindowPos (uiNode_t *window, int x, int y)
 Sets new x and y coordinates for a given window. More...
 
void UI_InsertWindow (uiNode_t *window)
 Add a new window to the list of all windows. More...
 
void UI_RemoveWindow (uiNode_t *window)
 Removes a window from the list of all windows. More...
 
void UI_FinishWindowsInit (void)
 Finish windows initialization. More...
 
static void UI_InitStack_f (void)
 
static void UI_DebugTree (const uiNode_t *node, int depth)
 Display in the conde the tree of nodes. More...
 
static void UI_DebugTree_f (void)
 
static void UI_Popup_f (void)
 
static void UI_DebugListWindows_f (void)
 Debug function to list all UI windows. More...
 
void UI_InitWindows (void)
 

Variables

static cvar_tui_sys_main
 Window name use as alternative for option. More...
 
static cvar_tui_sys_active
 Main window of a stack. More...
 

Macro Definition Documentation

#define WINDOWEXTRADATACONST (   node)    UI_EXTRADATACONST(node, windowExtraData_t)

Definition at line 39 of file ui_windows.cpp.

Referenced by UI_PopWindowWithEscKey().

Function Documentation

static void UI_CloseAllWindow ( void  )
static
void UI_CloseWindow ( const char *  name)
static void UI_CloseWindow_f ( void  )
static

Console function to close a named window.

See also
UI_PushWindow

Definition at line 473 of file ui_windows.cpp.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), and UI_CloseWindow().

Referenced by UI_InitWindows().

int UI_CompleteWithWindow ( const char *  partial,
const char **  match 
)

Complete function for ui_push.

See also
Cmd_AddParamCompleteFunction
UI_PushWindow
Note
Does not really complete the input - but shows at least all parsed windows

Definition at line 211 of file ui_windows.cpp.

References Cmd_GenericCompleteFunction(), Com_Printf(), i, name, uiGlobal_s::numWindows, ui_global, and uiGlobal_s::windows.

Referenced by UI_InitWindows(), and UI_RegisterEditorNode().

static void UI_DebugListWindows_f ( void  )
static

Debug function to list all UI windows.

Definition at line 739 of file ui_windows.cpp.

References Com_Printf(), i, uiNode_t::name, uiGlobal_s::numWindows, ui_global, and uiGlobal_s::windows.

Referenced by UI_InitWindows().

static void UI_DebugTree ( const uiNode_t node,
int  depth 
)
static

Display in the conde the tree of nodes.

Definition at line 693 of file ui_windows.cpp.

References Com_Printf(), uiNode_t::firstChild, i, uiNode_t::name, uiNode_t::next, and UI_Node_GetWidgetName().

Referenced by UI_DebugTree_f().

static void UI_DebugTree_f ( void  )
static

Definition at line 707 of file ui_windows.cpp.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), UI_DebugTree(), and UI_GetWindow().

Referenced by UI_InitWindows().

static void UI_DeleteWindowFromStack ( uiNode_t window)
static

Remove the window from the window stack.

Parameters
[in]windowThe window to remove from the stack
Todo:
Why dont we call onClose?

Definition at line 110 of file ui_windows.cpp.

References i, ui_global, UI_InvalidateMouse(), uiGlobal_s::windowStack, and uiGlobal_s::windowStackPos.

Referenced by UI_PushWindow().

void UI_FinishWindowsInit ( void  )

Finish windows initialization.

Note
private function

Definition at line 665 of file ui_windows.cpp.

References i, uiGlobal_s::numWindows, UI_ExecuteEventActions(), ui_global, WINDOWEXTRADATA, and uiGlobal_s::windows.

Referenced by UI_FinishInit().

uiNode_t* UI_GetActiveWindow ( void  )

Returns the current active window from the window stack or nullptr if there is none.

Returns
uiNode_t pointer from window stack
See also
UI_GetWindow

Definition at line 516 of file ui_windows.cpp.

References ui_global, uiGlobal_s::windowStack, and uiGlobal_s::windowStackPos.

Referenced by Irc_Client_CmdPrivmsg(), UI_CloseWindowByRef(), UI_DisplayNotice(), and UI_GetActiveWindowName().

const char* UI_GetActiveWindowName ( void  )

Returns the name of the current window.

Returns
Active window name, else empty string
See also
UI_GetActiveWIndow

Definition at line 526 of file ui_windows.cpp.

References uiNode_t::name, and UI_GetActiveWindow().

Referenced by GAME_GetImportData(), GAME_SetMode_f(), HUD_UpdateButtons(), Irc_AppendToBuffer(), and Irc_Client_CmdPrivmsg().

int UI_GetLastFullScreenWindow ( void  )

Returns the ID of the last fullscreen ID. Before this, window should be hidden.

Returns
The last full screen window on the screen, else 0. If the stack is empty, return -1

Definition at line 55 of file ui_windows.cpp.

References ui_global, UI_WindowIsFullScreen(), uiGlobal_s::windowStack, and uiGlobal_s::windowStackPos.

Referenced by UI_Draw(), UI_FocusNextActionNode(), and UI_KeyPressed().

uiNode_t* UI_GetWindow ( const char *  name)

Searches all windows for the specified one.

Parameters
[in]nameName of the window we search
Returns
The window found, else nullptr
Note
Use dichotomic search
See also
UI_GetActiveWindow

Definition at line 567 of file ui_windows.cpp.

References uiNode_t::name, uiGlobal_s::numWindows, ui_global, and uiGlobal_s::windows.

Referenced by _wrap_get_window(), HUD_CheckCLHud(), UFO_AnalyseTestWindow(), UI_CloseWindow(), UI_CreateWindow(), UI_DebugTree_f(), UI_DisplayNotice(), UI_EditorNodeExtract_f(), UI_ParseWindow(), UI_PopupButton(), UI_PopupList(), UI_PushWindow(), and UI_ReadNodePath().

static int UI_GetWindowPositionFromStackByName ( const char *  name)
inlinestatic

Searches the position in the current window stack for a given window id.

Returns
-1 if the window is not on the stack

Definition at line 133 of file ui_windows.cpp.

References i, uiNode_t::name, Q_streq, ui_global, uiGlobal_s::windowStack, and uiGlobal_s::windowStackPos.

Referenced by UI_CloseWindowByRef(), UI_IsWindowOnStack(), and UI_PushWindow().

void UI_InitStack ( const char *  activeWindow,
const char *  mainWindow 
)

Init the stack to start with a window, and have an alternative window with ESC.

Note
Illustration about when/how we should use this http://ufoai.org/wiki/index.php/Image:UI_InitStack.jpg
Parameters
[in]activeWindowThe first active window of the stack, else nullptr
[in]mainWindowThe alternative window, else nullptr if nothing
Todo:

remove Cvar_Set we have direct access to the cvar

We should only call it a very few time. When we switch from/to this different par of the game: main-option-interface / geoscape-and-base / battlescape

Definition at line 354 of file ui_windows.cpp.

References Cvar_Set(), uiGlobal_s::numWindows, UI_FinishInit(), ui_global, UI_PopWindow(), and UI_PushWindow().

Referenced by GAME_Drop(), GAME_GetImportData(), GAME_SetMode(), HUD_InitUI(), and UI_InitStack_f().

static void UI_InitStack_f ( void  )
static

Definition at line 674 of file ui_windows.cpp.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), and UI_InitStack().

Referenced by UI_InitWindows().

void UI_InsertWindow ( uiNode_t window)

Add a new window to the list of all windows.

Note
Sort windows by alphabet

Definition at line 616 of file ui_windows.cpp.

References Com_Error(), ERR_FATAL, i, uiNode_t::name, uiGlobal_s::numWindows, ui_global, UI_MAX_WINDOWS, and uiGlobal_s::windows.

Referenced by UI_CreateWindow(), and UI_ParseWindow().

static void UI_InsertWindowIntoStack ( uiNode_t window,
int  position 
)
inlinestatic

Insert a window at a position of the stack.

Parameters
[in]windowThe window to insert
[in]positionWhere we want to add the window (0 is the deeper element of the stack)

Definition at line 147 of file ui_windows.cpp.

References i, ui_global, uiGlobal_s::windowStack, and uiGlobal_s::windowStackPos.

Referenced by UI_PushWindow().

void UI_InvalidateStack ( void  )

Invalidate all windows of the current stack.

Definition at line 593 of file ui_windows.cpp.

References Cvar_SetValue(), ui_global, UI_Invalidate(), viddef, viddef_t::virtualHeight, viddef_t::virtualWidth, uiGlobal_s::windowStack, and uiGlobal_s::windowStackPos.

Referenced by R_SetMode().

bool UI_IsMouseOnWindow ( void  )

Check if a point is over a window from the stack.

See also
IN_Parse

Definition at line 538 of file ui_windows.cpp.

References UI_GetHoveredNode(), UI_GetMouseCapture(), ui_global, UI_Node_IsBattleScape(), WINDOWEXTRADATA, uiGlobal_s::windowStack, and uiGlobal_s::windowStackPos.

Referenced by IN_Parse().

bool UI_IsWindowOnStack ( const char *  name)

Check if a named window is on the stack if active windows.

Definition at line 373 of file ui_windows.cpp.

References UI_GetWindowPositionFromStackByName().

Referenced by GAME_SetMode(), UI_Popup(), UI_PopupButton(), and UI_PopupList().

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.

Parameters
windowWindow we want to move

Definition at line 74 of file ui_windows.cpp.

References i, ui_global, UI_WindowIsFullScreen(), WINDOWEXTRADATA, uiGlobal_s::windowStack, and uiGlobal_s::windowStackPos.

Referenced by UI_MouseDown().

static void UI_Popup_f ( void  )
static

Definition at line 724 of file ui_windows.cpp.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), and UI_Popup().

Referenced by UI_InitWindows().

static void UI_PopWindow_f ( void  )
static

Console function to pop a window from the window stack.

See also
UI_PopWindow

Definition at line 501 of file ui_windows.cpp.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), and UI_PopWindow().

Referenced by UI_InitWindows().

void UI_PopWindowWithEscKey ( void  )
static void UI_PushChildWindow_f ( void  )
static

Console function to push a child window onto the window stack.

See also
UI_PushWindow

Definition at line 228 of file ui_windows.cpp.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), and UI_PushWindow().

Referenced by UI_InitWindows().

static void UI_PushDropDownWindow_f ( void  )
static

Console function to push a dropdown window at a position. It work like UI_PushWindow but move the window at the right position.

See also
UI_PushWindow
Note
The usage is "ui_push_dropdown sourcenode pointposition destinationnode pointposition" sourcenode must be a node into the window we want to push, we will move the window to have sourcenode over destinationnode pointposition select for each node a position (like a corner).

Definition at line 263 of file ui_windows.cpp.

References uiNode_t::box, Cmd_Argc(), Cmd_Argv(), Com_ParseValue(), Com_Printf(), mousePosX, mousePosY, uiNode_t::name, uiBox_t::pos, Q_streq, RESULT_OK, uiNode_t::root, UI_GetNodeByPath(), UI_NodeGetPoint(), UI_NodeRelativeToAbsolutePoint(), UI_PushWindow(), and V_INT.

Referenced by UI_InitWindows().

uiNode_t* UI_PushWindow ( const char *  name,
const char *  parentName,
linkedList_t params 
)

Push a window onto the window stack.

Parameters
[in]nameName of the window to push onto window stack
[in]parentNameWindow name to link as parent-child (else nullptr)
[in]paramsList of string parameters to send to the onWindowOpened method. It can be nullptr when there is no parameters, else this object must be freed by the caller.
Returns
A pointer to uiNode_t

Definition at line 170 of file ui_windows.cpp.

References Com_Printf(), key_game, Key_SetDest(), UI_DeleteWindowFromStack(), UI_GetWindow(), UI_GetWindowPositionFromStackByName(), ui_global, UI_InsertWindowIntoStack(), UI_InvalidateMouse(), UI_MAX_WINDOWSTACK, UI_Node_WindowOpened(), UI_ReleaseInput(), WINDOWEXTRADATA, uiGlobal_s::windowStack, and uiGlobal_s::windowStackPos.

Referenced by _wrap_push_window(), CL_BattlescapeRadarOpen_f(), CL_ConnectionlessPacket(), CL_HudRadarDown_f(), GAME_InitMissionBriefing(), Irc_Client_CmdPrivmsg(), Irc_Client_Invite_f(), Irc_Input_Activate_f(), Irc_Proto_ProcessServerMsg(), UI_CloseWindowByRef(), UI_InitStack(), UI_Popup(), UI_PopupButton(), UI_PopupList(), UI_PushChildWindow_f(), UI_PushDropDownWindow_f(), UI_PushWindow_(), UI_PushWindow_f(), UI_Restart_f(), uiWindowNode_t_open(), and WEB_CheckAuth().

static void UI_PushWindow_f ( void  )
static

Console function to push a window onto the window stack.

See also
UI_PushWindow

Definition at line 240 of file ui_windows.cpp.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), i, LIST_AddString(), LIST_Delete(), and UI_PushWindow().

Referenced by UI_InitWindows().

void UI_RemoveWindow ( uiNode_t window)

Removes a window from the list of all windows.

Parameters
[in]windowPointer to the window node to remove
Note
Leaves no gap, keeps sorting

Definition at line 644 of file ui_windows.cpp.

References uiGlobal_s::numWindows, REMOVE_ELEM, ui_global, and uiGlobal_s::windows.

Referenced by uiWindowNode::deleteNode().

static void UI_RemoveWindowAtPositionFromStack ( int  position)
static

Definition at line 320 of file ui_windows.cpp.

References i, ui_global, uiGlobal_s::windowStack, and uiGlobal_s::windowStackPos.

Referenced by UI_CloseWindowByRef().

void UI_SetNewWindowPos ( uiNode_t window,
int  x,
int  y 
)

Sets new x and y coordinates for a given window.

Todo:
remove that

Definition at line 606 of file ui_windows.cpp.

References uiNode_t::box, uiBox_t::pos, and Vector2Set.

Referenced by uiControlNode::onCapturedMouseMove().

Variable Documentation

cvar_t* ui_sys_active
static

Main window of a stack.

Definition at line 49 of file ui_windows.cpp.

cvar_t* ui_sys_main
static

Window name use as alternative for option.

Definition at line 44 of file ui_windows.cpp.