From 8fe249812889d3c14a98b80bf64030877e0271e2 Mon Sep 17 00:00:00 2001 From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Thu, 6 Oct 2022 03:04:35 +0200 Subject: [PATCH] strafehud: small clean up and code readability improvements --- qcsrc/client/hud/panel/strafehud.qc | 11 +++++------ qcsrc/client/hud/panel/strafehud.qh | 3 +++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc index 1390a30d2..859c84d18 100644 --- a/qcsrc/client/hud/panel/strafehud.qc +++ b/qcsrc/client/hud/panel/strafehud.qc @@ -125,7 +125,7 @@ void HUD_StrafeHUD() int direction; // HUD - int mode = autocvar_hud_panel_strafehud_mode >= 0 && autocvar_hud_panel_strafehud_mode <= 1 ? autocvar_hud_panel_strafehud_mode : 0; + int mode = autocvar_hud_panel_strafehud_mode >= 0 && autocvar_hud_panel_strafehud_mode <= 1 ? autocvar_hud_panel_strafehud_mode : STRAFEHUD_MODE_VIEW_CENTERED; float speed_conversion_factor = GetSpeedUnitFactor(autocvar_hud_panel_strafehud_unit); float length_conversion_factor = GetLengthUnitFactor(autocvar_hud_panel_strafehud_unit); int length_decimals = autocvar_hud_panel_strafehud_unit >= 3 && autocvar_hud_panel_strafehud_unit <= 5 ? 6 : 2; // use more decimals when displaying km or miles @@ -481,7 +481,6 @@ void HUD_StrafeHUD() angle *= demo_maxangle; fwd = true; - hud_lasttime = time; wishangle = 45; if(angle < 0) wishangle *= -1; } @@ -553,7 +552,7 @@ void HUD_StrafeHUD() { currentangle_size.y = max(currentangle_size.y, 0); } - if(mode == 0) + if(mode == STRAFEHUD_MODE_VIEW_CENTERED) { currentangle_offset = angle/hudangle * panel_size.x; } @@ -621,7 +620,7 @@ void HUD_StrafeHUD() neutral_offset = direction == STRAFEHUD_DIRECTION_LEFT ? preaccelzone_left_offset + preaccelzone_width : -neutral_width; // shift hud if operating in view angle centered mode - if(mode == 0) + if(mode == STRAFEHUD_MODE_VIEW_CENTERED) { shift_offset = -currentangle_offset; bestangle_offset += shift_offset; @@ -654,7 +653,7 @@ void HUD_StrafeHUD() // draw neutral zone HUD_Panel_DrawStrafeHUD(neutral_offset, neutral_width, hidden_width, autocvar_hud_panel_strafehud_bar_neutral_color, autocvar_hud_panel_strafehud_bar_neutral_alpha * panel_fg_alpha, autocvar_hud_panel_strafehud_style, STRAFEHUD_GRADIENT_NONE); - if(speed >= minspeed && bestangle_width > 0) // only draw indicators if minspeed is reached + if(speed >= minspeed && bestangle_width > 0 && autocvar_hud_panel_strafehud_switch_alpha > 0) // only draw indicators if minspeed is reached { // draw the switch indicator(s) float offset = !odd_angles ? bestangle_offset : odd_bestangle_offset; @@ -777,7 +776,7 @@ void HUD_StrafeHUD() currentangle_color = autocvar_hud_panel_strafehud_angle_accel_color; } - if(mode == 0 || straight_overturn) + if(mode == STRAFEHUD_MODE_VIEW_CENTERED || straight_overturn) { currentangle_offset = panel_size.x/2; } diff --git a/qcsrc/client/hud/panel/strafehud.qh b/qcsrc/client/hud/panel/strafehud.qh index e79437d04..c170cf2d4 100644 --- a/qcsrc/client/hud/panel/strafehud.qh +++ b/qcsrc/client/hud/panel/strafehud.qh @@ -63,6 +63,9 @@ float GetLengthUnitFactor(int); string GetLengthUnit(int); void StrafeHUD_drawStrafeArrow(vector, float, vector, float, bool); +const int STRAFEHUD_MODE_VIEW_CENTERED = 0; +const int STRAFEHUD_MODE_VELOCITY_CENTERED = 1; + const int STRAFEHUD_DIRECTION_NONE = 0; const int STRAFEHUD_DIRECTION_LEFT = 1; const int STRAFEHUD_DIRECTION_RIGHT = 2; -- 2.39.2