HUD_Scale_Disable();
}
+bool HUD_WouldShowCursor()
+{
+ if(autocvar__hud_configure)
+ return true;
+ if(hud_panel_radar_mouse)
+ return true;
+ if(mv_active)
+ return true;
+ //entity local_player = ((csqcplayer) ? csqcplayer : CSQCModel_server2csqc(player_localentnum - 1)); // TODO: doesn't use regular cursor handling
+ //if(local_player.viewloc && (local_player.viewloc.spawnflags & VIEWLOC_FREEAIM))
+ //return true;
+ if(HUD_Radar_Clickable())
+ return true;
+ if(HUD_MinigameMenu_IsOpened() || active_minigame)
+ return true;
+ if(QuickMenu_IsOpened())
+ return true;
+ return false;
+}
+
void HUD_Main()
{
int i;
HUD_Panel_Draw(HUD_PANEL(RADAR));
if(autocvar__con_chat_maximized)
HUD_Panel_Draw(HUD_PANEL(CHAT));
- if(hud_panel_quickmenu)
+ if (QuickMenu_IsOpened())
HUD_Panel_Draw(HUD_PANEL(QUICKMENU));
HUD_Panel_Draw(HUD_PANEL(SCOREBOARD));
+ bool cursor_active_prev = cursor_active;
+ cursor_active = HUD_WouldShowCursor();
+ if (cursor_active_prev != cursor_active && autocvar_hud_cursormode)
+ setcursormode(cursor_active);
+
if (intermission == 2)
HUD_Reset();
bool HUD_Radar_Clickable();
void HUD_Radar_Mouse();
+bool HUD_WouldShowCursor();
+bool QuickMenu_IsOpened();
REGISTRY(hud_panels, BITS(6))
#define hud_panels_from(i) _hud_panels_from(i, NULL)
float vote_alpha;
float vote_change; // "time" when vote_active changed
-float hud_panel_quickmenu;
-
vector mousepos;
vector panel_click_distance; // mouse cursor distance from the top left corner of the panel (saved only upon a click)
vector panel_click_resizeorigin; // coordinates for opposite point when resizing
REGISTER_HUD_PANEL(MINIGAMEMENU, HUD_MinigameMenu, PANEL_CONFIG_NO , PANEL_SHOW_MAINGAME | PANEL_SHOW_MINIGAME | PANEL_SHOW_MAPVOTE | PANEL_SHOW_WITH_SB) // MINIGAMEMENU
REGISTER_HUD_PANEL(MAPVOTE, MapVote_Draw, PANEL_CONFIG_NO , PANEL_SHOW_MAPVOTE ) // MAPVOTE
REGISTER_HUD_PANEL(ITEMSTIME, HUD_ItemsTime, PANEL_CONFIG_MAIN | PANEL_CONFIG_CANBEOFF, PANEL_SHOW_MAINGAME ) // ITEMSTIME
-REGISTER_HUD_PANEL(QUICKMENU, HUD_QuickMenu, PANEL_CONFIG_MAIN , PANEL_SHOW_MAINGAME ) // QUICKMENU
+REGISTER_HUD_PANEL(QUICKMENU, HUD_QuickMenu, PANEL_CONFIG_MAIN , PANEL_SHOW_MAINGAME | PANEL_SHOW_MINIGAME ) // QUICKMENU
REGISTER_HUD_PANEL(SCOREBOARD, Scoreboard_Draw, PANEL_CONFIG_NO , PANEL_SHOW_MAINGAME | PANEL_SHOW_MINIGAME | PANEL_SHOW_MAPVOTE | PANEL_SHOW_WITH_SB) // SCOREBOARD
// always add new panels to the end of list
#include <client/autocvars.qh>
#include <client/defs.qh>
#include <client/miscfunctions.qh>
+#include <client/view.qh>
#define HUD_Write(s) fputs(fh, s)
#define HUD_Write_Cvar(cvar) HUD_Write(strcat("seta ", cvar, " \"", cvar_string(cvar), "\"\n"))
hud_configure_menu_open = 0;
localcmd("togglemenu\n");
}
+ cursor_type = CURSOR_NORMAL;
cvar_set("_hud_configure", "0");
}
if (bInputType == 1)
return true;
if (!hud_configure_menu_open)
- cvar_set("_hud_configure", "0");
+ HUD_Configure_Exit_Force();
}
else if(nPrimary == K_TAB && hudShiftState & S_CTRL) // switch panel
{
return true;
}
-float HUD_Panel_Check_Mouse_Pos(float allow_move)
+int HUD_Panel_Check_Mouse_Pos(bool allow_move)
{
int i, j = 0;
while(j < hud_panels_COUNT)
// move
if(allow_move && mousepos.x > panel_pos.x && mousepos.y > panel_pos.y && mousepos.x < panel_pos.x + panel_size.x && mousepos.y < panel_pos.y + panel_size.y)
{
- return 1;
+ return CURSOR_MOVE;
}
// resize from topleft border
else if(mousepos.x >= panel_pos.x - border && mousepos.y >= panel_pos.y - border && mousepos.x <= panel_pos.x + 0.5 * panel_size.x && mousepos.y <= panel_pos.y + 0.5 * panel_size.y)
{
- return 2;
+ return CURSOR_RESIZE;
}
// resize from topright border
else if(mousepos.x >= panel_pos.x + 0.5 * panel_size.x && mousepos.y >= panel_pos.y - border && mousepos.x <= panel_pos.x + panel_size.x + border && mousepos.y <= panel_pos.y + 0.5 * panel_size.y)
{
- return 3;
+ return CURSOR_RESIZE2;
}
// resize from bottomleft border
else if(mousepos.x >= panel_pos.x - border && mousepos.y >= panel_pos.y + 0.5 * panel_size.y && mousepos.x <= panel_pos.x + 0.5 * panel_size.x && mousepos.y <= panel_pos.y + panel_size.y + border)
{
- return 3;
+ return CURSOR_RESIZE2;
}
// resize from bottomright border
else if(mousepos.x >= panel_pos.x + 0.5 * panel_size.x && mousepos.y >= panel_pos.y + 0.5 * panel_size.y && mousepos.x <= panel_pos.x + panel_size.x + border && mousepos.y <= panel_pos.y + panel_size.y + border)
{
- return 2;
+ return CURSOR_RESIZE;
}
}
- return 0;
+ return CURSOR_NORMAL;
}
// move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
hud_configure_menu_open = 2;
localcmd("menu_showhudoptions ", highlightedPanel.panel_name, "\n");
}
-float mouse_over_panel;
void HUD_Panel_Mouse()
{
if(autocvar__menu_alpha == 1)
return;
- if (!autocvar_hud_cursormode)
- update_mousepos();
-
if(mouseClicked)
{
if(prevMouseClicked == 0)
prevMouseClickedTime = time;
prevMouseClickedPos = mousepos;
}
- mouse_over_panel = HUD_Panel_Check_Mouse_Pos(mouseClicked & S_MOUSE1);
+ cursor_type = HUD_Panel_Check_Mouse_Pos(mouseClicked & S_MOUSE1);
}
}
else
if(prevMouseClicked)
highlightedAction = 0;
if(hud_configure_menu_open == 2)
- mouse_over_panel = 0;
+ cursor_type = CURSOR_NORMAL;
else
- mouse_over_panel = HUD_Panel_Check_Mouse_Pos(true);
- if (mouse_over_panel && !tab_panel)
+ cursor_type = HUD_Panel_Check_Mouse_Pos(true);
+ if (cursor_type != CURSOR_NORMAL && !tab_panel) // mouse over a panel?
drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .1, DRAWFLAG_NORMAL);
}
- // draw cursor after performing move/resize to have the panel pos/size updated before mouse_over_panel
- float cursor_alpha = 1 - autocvar__menu_alpha;
-
- if(!mouse_over_panel)
- draw_cursor_normal(mousepos, '1 1 1', cursor_alpha);
- else if(mouse_over_panel == 1)
- draw_cursor(mousepos, '0.5 0.5 0', "/cursor_move", '1 1 1', cursor_alpha);
- else if(mouse_over_panel == 2)
- draw_cursor(mousepos, '0.5 0.5 0', "/cursor_resize", '1 1 1', cursor_alpha);
- else
- draw_cursor(mousepos, '0.5 0.5 0', "/cursor_resize2", '1 1 1', cursor_alpha);
-
- prevMouseClicked = mouseClicked;
}
void HUD_Configure_DrawGrid()
{
if(!hud_configure_prev)
{
- if(autocvar_hud_cursormode)
- setcursormode(1);
hudShiftState = 0;
for(i = hud_panels_COUNT - 1; i >= 0; --i)
hud_panels_from(panel_order[i]).update_time = time;
{
if(hud_configure_menu_open)
hud_configure_menu_open = 0;
- if(autocvar_hud_cursormode)
- setcursormode(0);
hud_dynamic_shake_factor = -1;
}
}
#include <client/defs.qh>
#include <client/miscfunctions.qh>
#include <common/ent_cs.qh>
+#include <common/minigames/cl_minigames.qh>
#include <client/hud/_mod.qh>
#include <client/mapvoting.qh>
QuickMenu_Page_Command_Type[i] = 0;
}
+bool HUD_QuickMenu_Forbidden()
+{
+ return (mv_active
+ || (hud_configure_prev && hud_configure_prev != -1)
+ || HUD_MinigameMenu_IsOpened()
+ || (QuickMenu_TimeOut && time > QuickMenu_TimeOut));
+}
+
+// returns true if succeded, false otherwise
bool QuickMenu_Open(string mode, string submenu, string file)
{
+ QuickMenu_TimeOut = 0;
+ if (HUD_QuickMenu_Forbidden())
+ return false;
+
int fh = -1;
string s;
else
QuickMenu_Page_Load("", 0);
- hud_panel_quickmenu = 1;
- if(autocvar_hud_cursormode)
- setcursormode(1);
hudShiftState = 0;
QuickMenu_TimeOut = ((autocvar_hud_panel_quickmenu_time > 0) ? time + autocvar_hud_panel_quickmenu_time : 0);
for (i = 0; i < QUICKMENU_MAXLINES; ++i)
QuickMenu_Page_ClearEntry(i);
QuickMenu_Page_Entries = 0;
- hud_panel_quickmenu = 0;
mouseClicked = 0;
prevMouseClicked = 0;
QuickMenu_Buffer_Close();
-
- if(autocvar_hud_cursormode)
- if(!mv_active)
- setcursormode(0);
}
// It assumes submenu open tag is already detected
return;
}
- if (!autocvar_hud_cursormode)
- update_mousepos();
-
panel = HUD_PANEL(QUICKMENU);
HUD_Panel_LoadCvars();
QuickMenu_Page_ActiveEntry((entry_num < QUICKMENU_MAXLINES - 1) ? entry_num + 1 : 0);
}
}
-
- draw_cursor_normal(mousepos, '1 1 1', 0.8);
-
- prevMouseClicked = mouseClicked;
}
void HUD_Quickmenu_DrawEntry(vector pos, string desc, string option, vector fontsize)
{
if(!autocvar__hud_configure)
{
- if (hud_configure_prev && hud_configure_prev != -1)
- QuickMenu_Close();
-
- if(!hud_draw_maximized) return;
- if(mv_active) return;
- //if(!autocvar_hud_panel_quickmenu) return;
- if(!hud_panel_quickmenu) return;
+ if (!hud_draw_maximized || !QuickMenu_IsOpened())
+ return;
- if(QuickMenu_TimeOut)
- if(time > QuickMenu_TimeOut)
+ if (HUD_QuickMenu_Forbidden())
{
QuickMenu_Close();
return;
{
if (clickable)
{
- if(autocvar_hud_cursormode)
- setcursormode(1);
hud_panel_radar_mouse = 1;
// we must unset the player's buttons, as they aren't released elsewhere
{
hud_panel_radar_mouse = 0;
mouseClicked = 0;
- if(autocvar_hud_cursormode)
- if(!mv_active)
- setcursormode(0);
}
}
void HUD_Radar_Hide_Maximized()
return;
}
- if (!autocvar_hud_cursormode)
- update_mousepos();
-
panel = HUD_PANEL(RADAR);
HUD_Panel_LoadCvars();
HUD_Radar_Hide_Maximized();
return;
}
-
-
- draw_cursor_normal(mousepos, '1 1 1', 0.8);
}
void HUD_Radar()
// In the case of mouse input after a setcursormode(1) call, nPrimary is xpos, nSecondary is ypos.
float CSQC_InputEvent(int bInputType, float nPrimary, float nSecondary)
{
- TC(int, bInputType);
- if (HUD_Panel_InputEvent(bInputType, nPrimary, nSecondary))
+ TC(int, bInputType);
+ bool override = false;
+ override |= HUD_Panel_InputEvent(bInputType, nPrimary, nSecondary);
+ if (override)
return true;
- if (QuickMenu_InputEvent(bInputType, nPrimary, nSecondary))
- return true;
+ override |= QuickMenu_InputEvent(bInputType, nPrimary, nSecondary);
- if (HUD_Radar_InputEvent(bInputType, nPrimary, nSecondary))
- return true;
+ override |= HUD_Radar_InputEvent(bInputType, nPrimary, nSecondary);
- if (MapVote_InputEvent(bInputType, nPrimary, nSecondary))
- return true;
+ override |= MapVote_InputEvent(bInputType, nPrimary, nSecondary);
+
+ override |= HUD_Minigame_InputEvent(bInputType, nPrimary, nSecondary);
- if (HUD_Minigame_InputEvent(bInputType, nPrimary, nSecondary))
+ if(override)
return true;
return false;
return mv_mouse_selection;
}
+vector prev_mousepos;
void MapVote_Draw()
{
string map;
if (!autocvar_hud_cursormode)
{
- vector mpos = mousepos;
- update_mousepos();
- if (mpos.x != mousepos.x || mpos.y != mousepos.y)
+ if (mousepos.x != prev_mousepos.x || mousepos.y != prev_mousepos.y)
+ {
mv_selection_keyboard = 0;
+ prev_mousepos = mousepos;
+ }
}
center = (vid_conwidth - 1)/2;
pos.x = (xmax+xmin)*0.5;
MapVote_DrawAbstain(pos, dist.x, xmax - xmin, tmp, i);
}
-
- draw_cursor_normal(mousepos, '1 1 1', panel_fg_alpha);
}
void Cmd_MapVote_MapDownload(int argc)
void MapVote_Init()
{
mv_active = 1;
- if(autocvar_hud_cursormode) setcursormode(1);
- else mousepos = '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight;
+ if(!autocvar_hud_cursormode) mousepos = '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight;
mv_selection = -1;
mv_selection_keyboard = 0;
//draw_cursor(viewloc_mousepos, '0.5 0.5 0', "/cursor_move", '1 1 1', cursor_alpha);
}
+void HUD_Cursor_Show()
+{
+ float cursor_alpha = 1 - autocvar__menu_alpha;
+ if(cursor_type == CURSOR_NORMAL)
+ draw_cursor_normal(mousepos, '1 1 1', cursor_alpha);
+ else if(cursor_type == CURSOR_MOVE)
+ draw_cursor(mousepos, '0.5 0.5 0', "/cursor_move", '1 1 1', cursor_alpha);
+ else if(cursor_type == CURSOR_RESIZE)
+ draw_cursor(mousepos, '0.5 0.5 0', "/cursor_resize", '1 1 1', cursor_alpha);
+ else if(cursor_type == CURSOR_RESIZE2)
+ draw_cursor(mousepos, '0.5 0.5 0', "/cursor_resize2", '1 1 1', cursor_alpha);
+}
+
+void HUD_Mouse(entity player)
+{
+ if(autocvar__menu_alpha == 1)
+ return;
+
+ if(!cursor_active)
+ {
+ if(player.viewloc && (player.viewloc.spawnflags & VIEWLOC_FREEAIM))
+ ViewLocation_Mouse(); // NOTE: doesn't use cursormode
+ return;
+ }
+
+ if(!autocvar_hud_cursormode)
+ update_mousepos();
+
+ if(autocvar__hud_configure)
+ HUD_Panel_Mouse();
+ else
+ {
+ if (HUD_MinigameMenu_IsOpened() || active_minigame)
+ HUD_Minigame_Mouse();
+ if (QuickMenu_IsOpened())
+ QuickMenu_Mouse();
+ if (HUD_Radar_Clickable())
+ HUD_Radar_Mouse();
+ }
+
+ prevMouseClicked = mouseClicked;
+
+ HUD_Cursor_Show();
+}
+
bool ov_enabled;
float oldr_nearclip;
float oldr_farclip_base;
cvar_set("vid_conheight", h0);
}
- if(autocvar__hud_configure)
- HUD_Panel_Mouse();
- else if (HUD_MinigameMenu_IsOpened() || active_minigame)
- HUD_Minigame_Mouse();
- else if(QuickMenu_IsOpened())
- QuickMenu_Mouse();
- else if(local_player.viewloc && (local_player.viewloc.spawnflags & VIEWLOC_FREEAIM))
- ViewLocation_Mouse(); // NOTE: doesn't use cursormode
- else
- HUD_Radar_Mouse();
+ HUD_Mouse(local_player);
cl_notice_run();
unpause_update();
entity viewmodels[MAX_WEAPONSLOTS];
vector viewloc_mousepos;
+
+bool cursor_active;
+int cursor_type;
+const int CURSOR_NORMAL = 0;
+const int CURSOR_MOVE = 1;
+const int CURSOR_RESIZE = 2;
+const int CURSOR_RESIZE2 = 3;
HUD_MinigameMenu_entries = NULL;
HUD_MinigameMenu_last_entry = NULL;
HUD_MinigameMenu_activeitem = NULL;
- if(autocvar_hud_cursormode)
- if ( !autocvar__hud_configure )
- setcursormode(0);
}
}
HUD_MinigameMenu_last_entry );
HUD_MinigameMenu_CurrentButton();
HUD_MinigameMenu_activeitem = NULL;
- if(autocvar_hud_cursormode)
- setcursormode(1);
}
}
if( !HUD_MinigameMenu_IsOpened() || autocvar__hud_configure || mv_active )
return;
- if (!autocvar_hud_cursormode)
- update_mousepos();
-
if ( HUD_MinigameMenu_IsOpened() && HUD_mouse_over(HUD_PANEL(MINIGAMEMENU)) )
HUD_MinigameMenu_MouseInput();
-
- draw_cursor_normal(mousepos, '1 1 1', panel_fg_alpha);
}