float HUD_GetRowCount(int item_count, vector size, float item_aspect)
{
- TC(int, item_count);
+ TC(int, item_count);
float aspect = size_y / size_x;
return bound(1, floor((sqrt(4 * item_aspect * aspect * item_count + aspect * aspect) + aspect + 0.5) / 2), item_count);
}
vector HUD_GetTableSize_BestItemAR(int item_count, vector psize, float item_aspect)
{
- TC(int, item_count);
+ TC(int, item_count);
float columns, rows;
float ratio, best_ratio = 0;
float best_columns = 1, best_rows = 1;
//basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu
void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, bool vertical, float baralign, vector theColor, float theAlpha, int drawflag)
{
- TC(bool, vertical); TC(int, drawflag);
+ TC(bool, vertical); TC(int, drawflag);
if(!length_ratio || !theAlpha)
return;
if(length_ratio > 1)
void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float theAlpha, int drawflag)
{
- TC(int, drawflag);
+ TC(int, drawflag);
if(!theAlpha)
return;
void DrawNumIcon_expanding(vector myPos, vector mySize, float theTime, string icon, bool vertical, int icon_right_align, vector color, float theAlpha, float fadelerp)
{
- TC(bool, vertical); TC(int, icon_right_align);
+ TC(bool, vertical); TC(int, icon_right_align);
vector newPos = '0 0 0', newSize = '0 0 0';
vector picpos, numpos;
void DrawNumIcon(vector myPos, vector mySize, float theTime, string icon, bool vertical, int icon_right_align, vector color, float theAlpha)
{
- TC(bool, vertical); TC(int, icon_right_align);
+ TC(bool, vertical); TC(int, icon_right_align);
DrawNumIcon_expanding(myPos, mySize, theTime, icon, vertical, icon_right_align, color, theAlpha, 0);
}
HUD_Scale_Disable();
}
+bool cursor_activestate;
+
+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_Cursor()
+{
+ if(HUD_WouldShowCursor())
+ {
+ if(!cursor_activestate)
+ {
+ cursor_activestate = true;
+ if(autocvar_hud_cursormode)
+ setcursormode(1);
+ }
+ }
+ else
+ {
+ if(cursor_activestate)
+ {
+ cursor_activestate = false;
+ if(autocvar_hud_cursormode)
+ setcursormode(0);
+ }
+ }
+}
+
void HUD_Main()
{
int i;
HUD_Panel_Draw(HUD_PANEL(QUICKMENU));
HUD_Panel_Draw(HUD_PANEL(SCOREBOARD));
+ HUD_Cursor();
+
if (intermission == 2)
HUD_Reset();
// if s1 is not empty s will be displayed as command otherwise as submenu
void QuickMenu_Page_LoadEntry(int i, string s, string s1)
{
- TC(int, i);
+ TC(int, i);
//LOG_INFOF("^xc80 entry %d: %s, %s\n", i, s, s1);
strcpy(QuickMenu_Page_Description[i], s);
strcpy(QuickMenu_Page_Command[i], s1);
void QuickMenu_Page_ClearEntry(int i)
{
- TC(int, i);
+ TC(int, i);
strfree(QuickMenu_Page_Description[i]);
strfree(QuickMenu_Page_Command[i]);
QuickMenu_Page_Command_Type[i] = 0;
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);
mouseClicked = 0;
prevMouseClicked = 0;
QuickMenu_Buffer_Close();
-
- if(autocvar_hud_cursormode)
- if(!mv_active)
- setcursormode(0);
}
// It assumes submenu open tag is already detected
bool HUD_Quickmenu_PlayerListEntries_Create(string cmd, int teamplayers, bool without_me)
{
- TC(int, teamplayers); TC(bool, without_me);
+ TC(int, teamplayers); TC(bool, without_me);
int i;
for(i = 0; i < QUICKMENU_MAXLINES; ++i)
QuickMenu_Page_ClearEntry(i);
int QuickMenu_Buffer_Index_Prev;
bool QuickMenu_Page_Load(string target_submenu, bool new_page)
{
- TC(bool, new_page);
+ TC(bool, new_page);
string s = string_null, cmd = string_null, z_submenu;
if (new_page == 0)
bool QuickMenu_ActionForNumber(int num)
{
- TC(int, num);
+ TC(int, num);
if (!QuickMenu_IsLastPage)
{
if (num < 0 || num >= QUICKMENU_MAXLINES)
void QuickMenu_Page_ActiveEntry(int entry_num)
{
- TC(int, entry_num);
+ TC(int, entry_num);
QuickMenu_Page_ActivatedEntry = entry_num;
QuickMenu_Page_ActivatedEntry_Time = time + 0.1;
if(QuickMenu_Page_Command[QuickMenu_Page_ActivatedEntry])
bool QuickMenu_InputEvent(int bInputType, float nPrimary, float nSecondary)
{
- TC(int, bInputType);
+ TC(int, bInputType);
// we only care for keyboard events
if(bInputType == 2)
return false;
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)
void HUD_Quickmenu_PlayerListEntries(string cmd, int teamplayers, bool without_me)
{
- TC(int, teamplayers); TC(bool, without_me);
+ TC(int, teamplayers); TC(bool, without_me);
entity pl;
if(teamplayers && !team_count)
return;
void HUD_Radar_Show_Maximized(bool doshow, bool clickable)
{
- TC(bool, doshow);
+ TC(bool, doshow);
hud_panel_radar_maximized = doshow;
hud_panel_radar_temp_hidden = 0;
{
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()
float HUD_Radar_InputEvent(int bInputType, float nPrimary, float nSecondary)
{
- TC(int, bInputType);
+ TC(int, bInputType);
if(!hud_panel_radar_maximized || !hud_panel_radar_mouse ||
autocvar__hud_configure || mv_active)
return false;
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()
.float has_team;
float SetTeam(entity o, int Team)
{
- TC(int, Team);
+ TC(int, Team);
devassert_once(Team);
entity tm;
if(teamplay)
// 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;
string MapVote_FormatMapItem(int id, string map, float _count, float maxwidth, vector fontsize)
{
- TC(int, id);
+ TC(int, id);
string pre, post;
pre = sprintf("%d. ", id+1);
if(mv_detail)
vector MapVote_RGB(int id)
{
- TC(int, id);
+ TC(int, id);
if(!(mv_flags[id] & GTV_AVAILABLE))
return '1 1 1';
if(id == mv_ownvote)
void GameTypeVote_DrawGameTypeItem(vector pos, float maxh, float tsize, string gtype, string pic, float _count, int id)
{
- TC(int, id);
+ TC(int, id);
// Find the correct alpha
float alpha;
if(!(mv_flags_start[id] & GTV_AVAILABLE))
void MapVote_DrawMapItem(vector pos, float isize, float tsize, string map, string pic, float _count, int id)
{
- TC(int, id);
+ TC(int, id);
vector img_size = '0 0 0';
string label;
float text_size;
void MapVote_DrawAbstain(vector pos, float isize, float tsize, float _count, int id)
{
- TC(int, id);
+ TC(int, id);
vector rgb;
float text_size;
string label;
vector MapVote_GridVec(vector gridspec, int i, int m)
{
- TC(int, i); TC(int, m);
+ TC(int, i); TC(int, m);
int r = i % m;
return
'1 0 0' * (gridspec.x * r)
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)
{
- TC(int, argc);
+ TC(int, argc);
entity pak;
if(argc != 2 || !mv_pk3list)
void MapVote_CheckPK3(string pic, string pk3, int id)
{
- TC(int, id);
+ TC(int, id);
entity pak;
pak = spawn();
pak.netname = pk3;
void MapVote_CheckPic(string pic, string pk3, int id)
{
- TC(int, id);
+ TC(int, id);
// never try to retrieve a pic for the "don't care" 'map'
if(mv_abstain && id == mv_num_maps - 1)
return;
void MapVote_ReadOption(int i)
{
- TC(int, i);
+ TC(int, i);
string map = strzone(ReadString());
string pk3 = strzone(ReadString());
int j = bound(0, ReadByte(), n_ssdirs - 1);
void GameTypeVote_ReadOption(int i)
{
- TC(int, i);
+ TC(int, i);
string gt = strzone(ReadString());
mv_maps[i] = gt;
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;
void MapVote_SendChoice(int index)
{
- TC(int, index);
+ TC(int, index);
localcmd(strcat("\nimpulse ", ftos(index+1), "\n"));
}
int MapVote_MoveLeft(int pos)
{
- TC(int, pos);
+ TC(int, pos);
int imp;
if ( pos < 0 )
imp = mv_num_maps - 1;
}
int MapVote_MoveRight(int pos)
{
- TC(int, pos);
+ TC(int, pos);
int imp;
if ( pos < 0 )
imp = 0;
}
int MapVote_MoveUp(int pos)
{
- TC(int, pos);
+ TC(int, pos);
int imp;
if ( pos < 0 )
imp = mv_num_maps - 1;
}
int MapVote_MoveDown(int pos)
{
- TC(int, pos);
+ TC(int, pos);
int imp;
if ( pos < 0 )
imp = 0;
float MapVote_InputEvent(int bInputType, float nPrimary, float nSecondary)
{
- TC(int, bInputType);
+ TC(int, bInputType);
float imp;
if (!mv_active)
if(zoomfactor < 1 || zoomfactor > 30)
zoomfactor = 2.5;
zoomspeed = autocvar_cl_zoomspeed;
- if(zoomspeed >= 0)
- if(zoomspeed < 0.5 || zoomspeed > 16)
- zoomspeed = 3.5;
+ if (zoomspeed >= 0 && (zoomspeed < 0.5 || zoomspeed > 16))
+ zoomspeed = 3.5;
zoomdir = button_zoom;
if(zoomdir) { zoomin_effect = 0; }
- if(camera_active)
+ if (spectatee_status > 0 && STAT(CAMERA_SPECTATOR) == 2)
+ {
+ current_viewzoom = 1;
+ }
+ else if (camera_active)
{
current_viewzoom = min(1, current_viewzoom + drawframetime);
}
if(autocvar_cl_velocityzoom_enabled && autocvar_cl_velocityzoom_type) // _type = 0 disables velocity zoom too
{
- if(intermission) { curspeed = 0; }
+ if (intermission || (spectatee_status > 0 && STAT(CAMERA_SPECTATOR) == 2))
+ curspeed = 0;
else
{
-
makevectors(view_angles);
v = pmove_vel;
if(csqcplayer)
//draw_cursor(viewloc_mousepos, '0.5 0.5 0', "/cursor_move", '1 1 1', cursor_alpha);
}
+float mouse_over_panel;
+void HUD_Draw_Mouse()
+{
+ 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);
+}
+
+void HUD_Mouse(entity player)
+{
+ if(autocvar__menu_alpha == 1)
+ return;
+
+ if(!HUD_WouldShowCursor())
+ {
+ 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_Draw_Mouse();
+}
+
bool ov_enabled;
float oldr_nearclip;
float oldr_farclip_base;
float vh_notice_time;
void CSQC_UpdateView(entity this, float w, float h)
{
- TC(int, w); TC(int, h);
+ TC(int, w); TC(int, h);
entity e;
float fov;
float f;
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();