]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Avoid a glitch when the HUD cursor gets (re)displayed
authorterencehill <piuntn@gmail.com>
Tue, 11 Dec 2018 17:45:01 +0000 (18:45 +0100)
committerterencehill <piuntn@gmail.com>
Tue, 11 Dec 2018 17:45:01 +0000 (18:45 +0100)
qcsrc/client/hud/hud.qc
qcsrc/client/view.qc
qcsrc/client/view.qh

index 0812ea4554647ca8cef700426e71974144447eaf..87ed2c4394be3d7721e10923b6ccd026e7c9d1f8 100644 (file)
@@ -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();
index 5172731ffb32017af4246591362dc5ec10b9a517..e26f90894d7ce24f9df890eeeeca4223d3aa290c 100644 (file)
@@ -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();
 
index 5bce2fe3246818293474b6383dd05a2a1d68ce39..12fd6eb614c5e8040e0a24995d35ad7f520107c6 100644 (file)
@@ -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;