UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ui_windows.h File Reference

Go to the source code of this file.

Functions

void UI_InitWindows (void)
 
int UI_GetLastFullScreenWindow (void)
 Returns the ID of the last fullscreen ID. Before this, window should be hidden. More...
 
uiNode_tUI_PushWindow (const char *name, const char *parentName=nullptr, linkedList_t *params=nullptr)
 Push a window onto the window stack. More...
 
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...
 
void UI_PopWindow (bool all=false)
 Pops a window from the window stack. More...
 
void UI_PopWindowWithEscKey (void)
 
void UI_CloseWindow (const char *name)
 
uiNode_tUI_GetActiveWindow (void)
 Returns the current active window from the window stack or nullptr if there is none. More...
 
int UI_CompleteWithWindow (const char *partial, const char **match)
 Complete function for ui_push. More...
 
bool UI_IsWindowOnStack (const char *name)
 Check if a named window is on the stack if active windows. More...
 
bool UI_IsMouseOnWindow (void)
 Check if a point is over a window from the stack. More...
 
void UI_InvalidateStack (void)
 Invalidate all windows of the current stack. 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_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...
 
const char * UI_GetActiveWindowName (void)
 Returns the name of the current window. More...
 
void UI_SetNewWindowPos (uiNode_t *window, int x, int y)
 Sets new x and y coordinates for a given window. More...
 
uiNode_tUI_GetWindow (const char *name)
 Searches all windows for the specified one. More...
 

Function Documentation

void UI_CloseWindow ( const char *  name)
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().

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().

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().

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().

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().

void UI_PopWindowWithEscKey ( void  )
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().

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().

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

Sets new x and y coordinates for a given window.

Todo:
move it on m_nodes, its a common getter/setter
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().