From: terencehill Date: Tue, 11 Dec 2018 17:45:01 +0000 (+0100) Subject: Avoid a glitch when the HUD cursor gets (re)displayed X-Git-Tag: xonotic-v0.8.5~1698 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=83fdfb28c41d23ca925df3708069fde58555a88c;p=xonotic%2Fxonotic-data.pk3dir.git Avoid a glitch when the HUD cursor gets (re)displayed --- diff --git a/qcsrc/client/hud/hud.qc b/qcsrc/client/hud/hud.qc index 0812ea455..87ed2c439 100644 --- a/qcsrc/client/hud/hud.qc +++ b/qcsrc/client/hud/hud.qc @@ -698,10 +698,15 @@ void HUD_Main() HUD_Panel_Draw(HUD_PANEL(QUICKMENU)); HUD_Panel_Draw(HUD_PANEL(SCOREBOARD)); - bool cursor_active_prev = cursor_active; + int cursor_active_prev = cursor_active; cursor_active = HUD_WouldShowCursor(); if (cursor_active_prev != cursor_active && autocvar_hud_cursormode) + { setcursormode(cursor_active); + // cursor inactive this frame, will be set to 1 the next frame + if (cursor_active) + cursor_active = -1; + } if (intermission == 2) HUD_Reset(); diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 5172731ff..e26f90894 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -1592,6 +1592,15 @@ void HUD_Mouse(entity player) return; } + if (cursor_active == -1) // starting to display the cursor + { + // since HUD_Mouse is called by CSQC_UpdateView before CSQC_InputEvent, + // in the first frame mousepos is the mouse position of the last time + // the cursor was displayed, thus we ignore it to avoid a glictch + cursor_active = 1; + return; + } + if(!autocvar_hud_cursormode) update_mousepos(); diff --git a/qcsrc/client/view.qh b/qcsrc/client/view.qh index 5bce2fe32..12fd6eb61 100644 --- a/qcsrc/client/view.qh +++ b/qcsrc/client/view.qh @@ -16,7 +16,7 @@ entity viewmodels[MAX_WEAPONSLOTS]; vector viewloc_mousepos; -bool cursor_active; +int cursor_active; int cursor_type; const int CURSOR_NORMAL = 0; const int CURSOR_MOVE = 1;