From: terencehill Date: Tue, 7 Aug 2018 21:53:36 +0000 (+0200) Subject: Clean up / simplify some hud cursor code X-Git-Tag: xonotic-v0.8.5~1843^2~3 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=25a407b7b13088fb19505397e4b9357640ebbac8;p=xonotic%2Fxonotic-data.pk3dir.git Clean up / simplify some hud cursor code --- diff --git a/qcsrc/client/hud/hud.qc b/qcsrc/client/hud/hud.qc index 9b5b46993..3493cde26 100644 --- a/qcsrc/client/hud/hud.qc +++ b/qcsrc/client/hud/hud.qc @@ -561,8 +561,6 @@ void Hud_Dynamic_Frame() HUD_Scale_Disable(); } -bool cursor_activestate; - bool HUD_WouldShowCursor() { if(autocvar__hud_configure) @@ -582,27 +580,6 @@ bool HUD_WouldShowCursor() 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() { @@ -723,7 +700,10 @@ void HUD_Main() HUD_Panel_Draw(HUD_PANEL(QUICKMENU)); HUD_Panel_Draw(HUD_PANEL(SCOREBOARD)); - HUD_Cursor(); + 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(); diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 8c0eee412..9555f3114 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -1555,7 +1555,7 @@ void ViewLocation_Mouse() //draw_cursor(viewloc_mousepos, '0.5 0.5 0', "/cursor_move", '1 1 1', cursor_alpha); } -void HUD_Draw_Mouse() +void HUD_Cursor_Show() { float cursor_alpha = 1 - autocvar__menu_alpha; if(cursor_type == CURSOR_NORMAL) @@ -1573,7 +1573,7 @@ void HUD_Mouse(entity player) if(autocvar__menu_alpha == 1) return; - if(!HUD_WouldShowCursor()) + if(!cursor_active) { if(player.viewloc && (player.viewloc.spawnflags & VIEWLOC_FREEAIM)) ViewLocation_Mouse(); // NOTE: doesn't use cursormode @@ -1597,7 +1597,7 @@ void HUD_Mouse(entity player) prevMouseClicked = mouseClicked; - HUD_Draw_Mouse(); + HUD_Cursor_Show(); } bool ov_enabled; diff --git a/qcsrc/client/view.qh b/qcsrc/client/view.qh index 6b3fe4430..5bce2fe32 100644 --- a/qcsrc/client/view.qh +++ b/qcsrc/client/view.qh @@ -16,6 +16,7 @@ entity viewmodels[MAX_WEAPONSLOTS]; vector viewloc_mousepos; +bool cursor_active; int cursor_type; const int CURSOR_NORMAL = 0; const int CURSOR_MOVE = 1;