ui_windows.c File Reference

#include "ui_main.h"
#include "ui_internal.h"
#include "ui_input.h"
#include "node/ui_node_abstractnode.h"
#include "node/ui_node_window.h"
#include "../client.h"
Include dependency graph for ui_windows.c:

Go to the source code of this file.

Defines

#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.
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.
static void UI_DeleteWindowFromStack (uiNode_t *window)
 Remove the window from the window stack.
static int UI_GetWindowPositionFromStackByName (const char *name)
 Searches the position in the current window stack for a given window id.
static void UI_InsertWindowIntoStack (uiNode_t *window, int position)
 Insert a window at a position of the stack.
static uiNode_tUI_PushWindowDelete (const char *name, const char *parent, qboolean delete)
 Push a window onto the window stack.
int UI_CompleteWithWindow (const char *partial, const char **match)
 Complete function for mn_push.
uiNode_tUI_PushWindow (const char *name, const char *parentName)
 Push a window onto the window stack.
static void UI_PushChildWindow_f (void)
 Console function to push a child window onto the window stack.
static void UI_PushWindow_f (void)
 Console function to push a window onto the window stack.
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.
static void UI_PushNoHud_f (void)
 Console function to hide the HUD in battlescape mode Note: relies on a "nohud" window existing.
static void UI_RemoveWindowAtPositionFromStack (int position)
static void UI_CloseAllWindow (void)
void UI_InitStack (const char *activeWindow, const char *mainWindow, qboolean popAll, qboolean pushActive)
 Init the stack to start with a window, and have an alternative window with ESC.
qboolean UI_IsWindowOnStack (const char *name)
 Check if a named window is on the stack if active windows.
static void UI_CloseWindowByRef (uiNode_t *window)
void UI_CloseWindow (const char *name)
void UI_PopWindow (qboolean all)
 Pops a window from the window stack.
static void UI_CloseWindow_f (void)
 Console function to close a named window.
void UI_PopWindowWithEscKey (void)
static void UI_PopWindow_f (void)
 Console function to pop a window from the window stack.
uiNode_tUI_GetActiveWindow (void)
 Returns the current active window from the window stack or NULL if there is none.
void UI_GetActiveRenderRect (int *x, int *y, int *width, int *height)
 Determine the position and size of render.
const char * UI_GetActiveWindowName (void)
 Returns the name of the current window.
qboolean UI_IsPointOnWindow (void)
 Check if a point is over a window from the stack.
uiNode_tUI_GetWindow (const char *name)
 Searches all windows for the specified one.
void UI_InvalidateStack (void)
 Invalidate all windows of the current stack.
void UI_SetNewWindowPos (uiNode_t *window, int x, int y)
 Sets new x and y coordinates for a given window.
void UI_InsertWindow (uiNode_t *window)
 Add a new window to the list of all windows.
static void UI_SetNewWindowPos_f (void)
 Console command for moving a window.
static void UI_FireInit_f (void)
 This will reinitialize the current visible window.
static void UI_InitStack_f (void)
static void UI_DebugTree (const uiNode_t *node, int depth)
 Display in the conde the tree of nodes.
static void UI_DebugTree_f (void)
void UI_InitWindows (void)

Variables

static cvar_tmn_sys_main
 Window name use as alternative for option.
static cvar_tmn_sys_active
 Main window of a stack.

Detailed Description

Definition in file ui_windows.c.


Define Documentation

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

Definition at line 34 of file ui_windows.c.

Referenced by UI_FireInit_f(), UI_IsPointOnWindow(), and 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 520 of file ui_windows.c.

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

Referenced by UI_InitWindows().

static void UI_CloseWindowByRef ( uiNode_t window  )  [static]
int UI_CompleteWithWindow ( const char *  partial,
const char **  match 
)

Complete function for mn_push.

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

Definition at line 214 of file ui_windows.c.

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

Referenced by UI_InitWindows(), and UI_RegisterEditorNode().

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

Display in the conde the tree of nodes.

Definition at line 788 of file ui_windows.c.

References uiNode_s::behaviour, Com_Printf(), uiNode_s::firstChild, i, uiNode_s::name, uiBehaviour_s::name, and uiNode_s::next.

Referenced by UI_DebugTree_f().

static void UI_DebugTree_f ( void   )  [static]

Definition at line 804 of file ui_windows.c.

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] window The window to remove from the stack
See also:
UI_PushWindowDelete
Todo:
Why dont we call onClose?

Definition at line 106 of file ui_windows.c.

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

Referenced by UI_PushWindowDelete().

static void UI_FireInit_f ( void   )  [static]

This will reinitialize the current visible window.

Note:
also available as script command mn_reinit
Todo:
replace that by a common action "call *ufopedia.init"

Definition at line 740 of file ui_windows.c.

References Cmd_Argc(), Cmd_Argv(), Com_DPrintf(), Com_Printf(), DEBUG_CLIENT, uiNode_s::name, UI_ExecuteEventActions(), UI_GetNodeByPath(), UI_NodeInstanceOf(), and WINDOWEXTRADATACONST.

Referenced by UI_InitWindows().

void UI_GetActiveRenderRect ( int *  x,
int *  y,
int *  width,
int *  height 
)

Determine the position and size of render.

Todo:
the better way is to add a 'battlescape' node

Definition at line 572 of file ui_windows.c.

References mn_hud, pos, viddef_t::rx, viddef_t::ry, uiNode_s::size, cvar_s::string, UI_GetActiveWindow(), UI_GetNodeAbsPos(), UI_GetWindow(), UI_IsWindowOnStack(), UI_Validate(), viddef, and WINDOWEXTRADATA.

Referenced by SCR_UpdateScreen().

uiNode_t* UI_GetActiveWindow ( void   )  [read]

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

Returns:
uiNode_t pointer from window stack
See also:
UI_GetWindow

Definition at line 564 of file ui_windows.c.

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

Referenced by Irc_Client_CmdPrivmsg(), UI_DisplayNotice(), UI_GetActiveRenderRect(), UI_GetActiveWindowName(), and UI_SetNewWindowPos_f().

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 605 of file ui_windows.c.

References uiNode_s::name, and UI_GetActiveWindow().

Referenced by CP_OnGeoscape(), GAME_SetMode_f(), HUD_RefreshButtons(), Irc_AppendToBuffer(), Irc_Client_CmdPrivmsg(), and MAP_CenterOnPoint_f().

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 50 of file ui_windows.c.

References pos, 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  )  [read]

Searches all windows for the specified one.

Parameters:
[in] name Name of the window we search
Returns:
The window found, else NULL
Note:
Use dichotomic search
See also:
UI_GetActiveWindow

Definition at line 648 of file ui_windows.c.

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

Referenced by UI_CloseWindow(), UI_DebugTree_f(), UI_DisplayNotice(), UI_EditorNodeExtract_f(), UI_GetActiveRenderRect(), UI_ParseWindow(), UI_PopupButton(), UI_PopupList(), UI_PushWindowDelete(), and UI_ReadNodePath().

static int UI_GetWindowPositionFromStackByName ( const char *  name  )  [inline, static]

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 129 of file ui_windows.c.

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

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

void UI_InitStack ( const char *  activeWindow,
const char *  mainWindow,
qboolean  popAll,
qboolean  pushActive 
)

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

Parameters:
[in] activeWindow The first active window of the stack, else NULL
[in] mainWindow The alternative window, else NULL if nothing
[in] popAll If true, clean up the stack first
[in] pushActive If true, push the active window into the stack
Todo:

remove Cvar_Set we have direct access to the cvar

check why activeWindow can be NULL. It should never be NULL: a stack must not be empty

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

Update the code: popAll should be every time true

Update the code: pushActive should be every time true

Illustration about when/how we should use UI_InitStack http://ufoai.ninex.info/wiki/index.php/Image:UI_InitStack.jpg

Definition at line 400 of file ui_windows.c.

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

Referenced by CL_Connect_f(), CL_Reset(), CP_CampaignInit(), CP_EndCampaign(), CP_StartMissionMap(), GAME_CP_Drop(), GAME_CP_Results(), GAME_CP_Spawn(), GAME_Drop(), GAME_MP_StartBattlescape(), GAME_MP_StartServer_f(), GAME_SetMode(), GAME_SK_Start_f(), GAME_StartBattlescape(), SAV_GameLoad(), and UI_InitStack_f().

static void UI_InitStack_f ( void   )  [static]

Definition at line 768 of file ui_windows.c.

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

Referenced by UI_InitWindows().

void UI_InitWindows ( void   ) 
void UI_InsertWindow ( uiNode_t window  ) 

Add a new window to the list of all windows.

Note:
Sort windows by alphabet

Definition at line 698 of file ui_windows.c.

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

Referenced by UI_ParseWindow().

static void UI_InsertWindowIntoStack ( uiNode_t window,
int  position 
) [inline, static]

Insert a window at a position of the stack.

Parameters:
[in] window The window to insert
[in] position Where we want to add the window (0 is the deeper element of the stack)

Definition at line 144 of file ui_windows.c.

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

Referenced by UI_PushWindowDelete().

void UI_InvalidateStack ( void   ) 

Invalidate all windows of the current stack.

Definition at line 674 of file ui_windows.c.

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

Referenced by R_SetMode().

qboolean UI_IsPointOnWindow ( void   ) 

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

See also:
IN_Parse

Definition at line 617 of file ui_windows.c.

References qfalse, qtrue, uiNode_s::root, UI_GetHoveredNode(), UI_GetMouseCapture(), ui_global, WINDOWEXTRADATA, WINDOWEXTRADATACONST, uiGlobal_s::windowStack, and uiGlobal_s::windowStackPos.

Referenced by IN_Parse().

qboolean UI_IsWindowOnStack ( const char *  name  ) 

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

Definition at line 420 of file ui_windows.c.

References UI_GetWindowPositionFromStackByName().

Referenced by CL_HudRadarDown_f(), CL_HudRadarUp_f(), GAME_SetMode(), UI_GetActiveRenderRect(), 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:
window Window we want to move

Definition at line 69 of file ui_windows.c.

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

Referenced by UI_MouseDown().

void UI_PopWindow ( qboolean  all  ) 
static void UI_PopWindow_f ( void   )  [static]

Console function to pop a window from the window stack.

See also:
UI_PopWindow

Definition at line 549 of file ui_windows.c.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), qfalse, 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 256 of file ui_windows.c.

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 "mn_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 284 of file ui_windows.c.

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

Referenced by UI_InitWindows().

static void UI_PushNoHud_f ( void   )  [static]

Console function to hide the HUD in battlescape mode Note: relies on a "nohud" window existing.

See also:
UI_PushWindow

Definition at line 349 of file ui_windows.c.

References CL_BattlescapeRunning(), and UI_PushWindow().

Referenced by UI_InitWindows().

uiNode_t* UI_PushWindow ( const char *  name,
const char *  parentName 
) [read]
static void UI_PushWindow_f ( void   )  [static]

Console function to push a window onto the window stack.

See also:
UI_PushWindow

Definition at line 268 of file ui_windows.c.

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

Referenced by UI_InitWindows().

static uiNode_t* UI_PushWindowDelete ( const char *  name,
const char *  parent,
qboolean  delete 
) [static]

Push a window onto the window stack.

Parameters:
[in] name Name of the window to push onto window stack
[in] parent Window name to link as parent-child (else NULL)
[in] delete Delete the window from the window stack before adding it again
Returns:
pointer to uiNode_t

Definition at line 167 of file ui_windows.c.

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

Referenced by UI_PushWindow().

static void UI_RemoveWindowAtPositionFromStack ( int  position  )  [static]

Definition at line 358 of file ui_windows.c.

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 688 of file ui_windows.c.

References uiNode_s::pos, and Vector2Set.

Referenced by UI_ControlsNodeCapturedMouseMove(), and UI_SetNewWindowPos_f().

static void UI_SetNewWindowPos_f ( void   )  [static]

Console command for moving a window.

Definition at line 725 of file ui_windows.c.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), UI_GetActiveWindow(), and UI_SetNewWindowPos().

Referenced by UI_InitWindows().


Variable Documentation

cvar_t* mn_sys_active [static]

Main window of a stack.

Definition at line 44 of file ui_windows.c.

cvar_t* mn_sys_main [static]

Window name use as alternative for option.

Definition at line 39 of file ui_windows.c.


Generated by  doxygen 1.6.2