From: terencehill Date: Tue, 7 Aug 2018 12:08:16 +0000 (+0200) Subject: Merge branch 'master' into Mario/cursor X-Git-Tag: xonotic-v0.8.5~1843^2~5 X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=e7e4e095eaeac5b8dbc60723f239547bdee88ef5;hp=-c Merge branch 'master' into Mario/cursor --- e7e4e095eaeac5b8dbc60723f239547bdee88ef5 diff --combined qcsrc/client/hud/hud.qc index e26b4e2f5b,2becced8e0..9b5b469933 --- a/qcsrc/client/hud/hud.qc +++ b/qcsrc/client/hud/hud.qc @@@ -75,14 -75,14 +75,14 @@@ vector HUD_Get_Num_Color (float hp, flo 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; @@@ -180,7 -180,7 +180,7 @@@ void HUD_Panel_LoadCvars( //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) @@@ -287,7 -287,7 +287,7 @@@ void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float theAlpha, int drawflag) { - TC(int, drawflag); + TC(int, drawflag); if(!theAlpha) return; @@@ -308,7 -308,7 +308,7 @@@ 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; @@@ -388,7 -388,7 +388,7 @@@ 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); } @@@ -561,49 -561,6 +561,49 @@@ void Hud_Dynamic_Frame( 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; @@@ -723,8 -680,6 +723,8 @@@ HUD_Panel_Draw(HUD_PANEL(QUICKMENU)); HUD_Panel_Draw(HUD_PANEL(SCOREBOARD)); + HUD_Cursor(); + if (intermission == 2) HUD_Reset(); diff --combined qcsrc/client/hud/panel/quickmenu.qc index a9029b2516,98b15ee953..02259f8ee0 --- a/qcsrc/client/hud/panel/quickmenu.qc +++ b/qcsrc/client/hud/panel/quickmenu.qc @@@ -43,7 -43,7 +43,7 @@@ float QuickMenu_TimeOut // 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); @@@ -51,7 -51,7 +51,7 @@@ 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; @@@ -167,6 -167,8 +167,6 @@@ bool QuickMenu_Open(string mode, strin 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); @@@ -194,6 -196,10 +194,6 @@@ void QuickMenu_Close( mouseClicked = 0; prevMouseClicked = 0; QuickMenu_Buffer_Close(); - - if(autocvar_hud_cursormode) - if(!mv_active) - setcursormode(0); } // It assumes submenu open tag is already detected @@@ -219,7 -225,7 +219,7 @@@ bool QuickMenu_IsOpened( 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); @@@ -244,7 -250,7 +244,7 @@@ 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) @@@ -355,7 -361,7 +355,7 @@@ bool QuickMenu_ActionForNumber(int num) { - TC(int, num); + TC(int, num); if (!QuickMenu_IsLastPage) { if (num < 0 || num >= QUICKMENU_MAXLINES) @@@ -383,7 -389,7 +383,7 @@@ 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]) @@@ -401,7 -407,7 +401,7 @@@ 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; @@@ -481,6 -487,9 +481,6 @@@ void QuickMenu_Mouse( return; } - if (!autocvar_hud_cursormode) - update_mousepos(); - panel = HUD_PANEL(QUICKMENU); HUD_Panel_LoadCvars(); @@@ -516,6 -525,10 +516,6 @@@ 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) @@@ -735,7 -748,7 +735,7 @@@ void HUD_QuickMenu( 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; diff --combined qcsrc/client/hud/panel/radar.qc index 2f0777bb1f,65073d9fed..9176aa0ff9 --- a/qcsrc/client/hud/panel/radar.qc +++ b/qcsrc/client/hud/panel/radar.qc @@@ -19,7 -19,7 +19,7 @@@ bool HUD_Radar_Clickable( 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; @@@ -27,6 -27,8 +27,6 @@@ { 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 @@@ -41,6 -43,9 +41,6 @@@ { hud_panel_radar_mouse = 0; mouseClicked = 0; - if(autocvar_hud_cursormode) - if(!mv_active) - setcursormode(0); } } void HUD_Radar_Hide_Maximized() @@@ -51,7 -56,7 +51,7 @@@ 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; @@@ -136,6 -141,9 +136,6 @@@ void HUD_Radar_Mouse( return; } - if (!autocvar_hud_cursormode) - update_mousepos(); - panel = HUD_PANEL(RADAR); HUD_Panel_LoadCvars(); @@@ -161,6 -169,9 +161,6 @@@ HUD_Radar_Hide_Maximized(); return; } - - - draw_cursor_normal(mousepos, '1 1 1', 0.8); } void HUD_Radar() diff --combined qcsrc/client/main.qc index 3a6d60742f,863905a3d3..df13ca7f62 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@@ -230,7 -230,7 +230,7 @@@ void Shutdown( .float has_team; float SetTeam(entity o, int Team) { - TC(int, Team); + TC(int, Team); devassert_once(Team); entity tm; if(teamplay) @@@ -363,21 -363,20 +363,21 @@@ void PostInit( // 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; diff --combined qcsrc/client/mapvoting.qc index 8d4d8ba9f6,03e94dc7f3..37cb59e082 --- a/qcsrc/client/mapvoting.qc +++ b/qcsrc/client/mapvoting.qc @@@ -43,7 -43,7 +43,7 @@@ int n_ssdirs 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) @@@ -64,7 -64,7 +64,7 @@@ 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) @@@ -77,7 -77,7 +77,7 @@@ 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)) @@@ -189,7 -189,7 +189,7 @@@ 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; @@@ -264,7 -264,7 +264,7 @@@ 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; @@@ -281,7 -281,7 +281,7 @@@ 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) @@@ -321,7 -321,6 +321,7 @@@ float MapVote_Selection(vector topleft return mv_mouse_selection; } +vector prev_mousepos; void MapVote_Draw() { string map; @@@ -340,11 -339,10 +340,11 @@@ 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; @@@ -487,11 -485,13 +487,11 @@@ 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) @@@ -522,7 -522,7 +522,7 @@@ void MapVote_CheckPK3(string pic, string pk3, int id) { - TC(int, id); + TC(int, id); entity pak; pak = spawn(); pak.netname = pk3; @@@ -544,7 -544,7 +544,7 @@@ 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; @@@ -587,7 -587,7 +587,7 @@@ void MapVote_ReadMask( 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); @@@ -604,7 -604,7 +604,7 @@@ void GameTypeVote_ReadOption(int i) { - TC(int, i); + TC(int, i); string gt = strzone(ReadString()); mv_maps[i] = gt; @@@ -649,7 -649,8 +649,7 @@@ 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; @@@ -710,13 -711,13 +710,13 @@@ 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; @@@ -728,7 -729,7 +728,7 @@@ } int MapVote_MoveRight(int pos) { - TC(int, pos); + TC(int, pos); int imp; if ( pos < 0 ) imp = 0; @@@ -740,7 -741,7 +740,7 @@@ } int MapVote_MoveUp(int pos) { - TC(int, pos); + TC(int, pos); int imp; if ( pos < 0 ) imp = mv_num_maps - 1; @@@ -760,7 -761,7 +760,7 @@@ } int MapVote_MoveDown(int pos) { - TC(int, pos); + TC(int, pos); int imp; if ( pos < 0 ) imp = 0; @@@ -777,7 -778,7 +777,7 @@@ float MapVote_InputEvent(int bInputType, float nPrimary, float nSecondary) { - TC(int, bInputType); + TC(int, bInputType); float imp; if (!mv_active) diff --combined qcsrc/client/view.qc index 3a5f1b5e76,a7fbe13682..27fa344b39 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@@ -491,9 -491,8 +491,8 @@@ vector GetCurrentFov(float fov 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; @@@ -526,7 -525,11 +525,11 @@@ 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); } @@@ -570,10 -573,10 +573,10 @@@ 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) @@@ -1552,52 -1555,6 +1555,52 @@@ void ViewLocation_Mouse( //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; @@@ -1611,7 -1568,7 +1614,7 @@@ int lasthud 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; @@@ -2487,7 -2444,16 +2490,7 @@@ 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();