From 4efe4721be72d067e4fd6eefdca01e430975bd63 Mon Sep 17 00:00:00 2001 From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Sun, 15 Jan 2023 00:56:44 +0100 Subject: [PATCH] strafehud: merge the preaccel zone into the accel zone and make it use a gradient if gradient style is active, add hud_panel_strafehud_bar_preaccel to optionally ignore this part of the accel zone --- _hud_common.cfg | 3 +-- qcsrc/client/hud/panel/strafehud.qc | 14 ++++++++++---- qcsrc/client/hud/panel/strafehud.qh | 3 +-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/_hud_common.cfg b/_hud_common.cfg index d982ad6e3..1d8caae4c 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -155,12 +155,11 @@ seta hud_panel_strafehud_style "2" "\"0\" = no styling, \"1\" = progress bar sty seta hud_panel_strafehud_unit "1" "speed unit (1 = qu/s, 2 = m/s, 3 = km/h, 4 = mph, 5 = knots), length unit (1 = qu, 2 = m, 3 = km, 4 = mi, 5 = nmi)" seta hud_panel_strafehud_unit_show "1" "show units" seta hud_panel_strafehud_uncapped "0" "set to \"1\" to remove some safety restrictions, useful to set thinner indicator lines down to 1px or for trying out higher values for some performance degrading operations (warning: elements may turn invisible if too thin, other configurations may crash your game or look horribly ugly)" +seta hud_panel_strafehud_bar_preaccel "1" "set to \"1\" to extend the acceleration zone by the strafe meter zone before full acceleration can be achieved" seta hud_panel_strafehud_bar_neutral_color "1 1 1" "color of the strafe meter neutral zone" seta hud_panel_strafehud_bar_neutral_alpha "0.1" "opacity of the strafe meter neutral zone" seta hud_panel_strafehud_bar_accel_color "0 1 0" "color of the strafe meter acceleration zone" seta hud_panel_strafehud_bar_accel_alpha "0.5" "opacity of the strafe meter acceleration zone" -seta hud_panel_strafehud_bar_preaccel_color "1 0.75 0" "color of the strafe meter zone before full acceleration can be achieved" -seta hud_panel_strafehud_bar_preaccel_alpha "0.5" "opacity of the strafe meter zone before full acceleration can be achieved" seta hud_panel_strafehud_bar_overturn_color "1 0 1" "color of the strafe meter overturn zone" seta hud_panel_strafehud_bar_overturn_alpha "0.5" "opacity of the strafe meter overturn zone" seta hud_panel_strafehud_angle_style "0" "set the angle indicator style: 0 = none, 1 = solid line, 2 = dashed line" diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc index 2347128b1..226ad4f62 100644 --- a/qcsrc/client/hud/panel/strafehud.qc +++ b/qcsrc/client/hud/panel/strafehud.qc @@ -638,7 +638,10 @@ void HUD_StrafeHUD() { // calculate various zones of the strafe-o-meter accelzone_width = (90 - fabs(bestangle + wishangle))/hudangle * panel_size.x; - preaccelzone_width = (fabs(bestangle - prebestangle))/hudangle * panel_size.x; + if(autocvar_hud_panel_strafehud_bar_preaccel) + preaccelzone_width = (fabs(bestangle - prebestangle))/hudangle * panel_size.x; + else + preaccelzone_width = 0; overturn_offset = accelzone_width + preaccelzone_width; accelzone_right_offset = preaccelzone_width; accelzone_left_offset = overturn_offset + overturn_width; @@ -669,11 +672,13 @@ void HUD_StrafeHUD() // draw left acceleration zone HUD_Panel_DrawStrafeHUD(accelzone_left_offset, accelzone_width, hidden_width, autocvar_hud_panel_strafehud_bar_accel_color, autocvar_hud_panel_strafehud_bar_accel_alpha * panel_fg_alpha, autocvar_hud_panel_strafehud_style, STRAFEHUD_GRADIENT_LEFT); - HUD_Panel_DrawStrafeHUD(preaccelzone_left_offset, preaccelzone_width, hidden_width, autocvar_hud_panel_strafehud_bar_preaccel_color, autocvar_hud_panel_strafehud_bar_preaccel_alpha * panel_fg_alpha, autocvar_hud_panel_strafehud_style, STRAFEHUD_GRADIENT_NONE); + if(autocvar_hud_panel_strafehud_bar_preaccel) + HUD_Panel_DrawStrafeHUD(preaccelzone_left_offset, preaccelzone_width, hidden_width, autocvar_hud_panel_strafehud_bar_accel_color, autocvar_hud_panel_strafehud_bar_accel_alpha * panel_fg_alpha, autocvar_hud_panel_strafehud_style, STRAFEHUD_GRADIENT_RIGHT); // draw right acceleration zone HUD_Panel_DrawStrafeHUD(accelzone_right_offset, accelzone_width, hidden_width, autocvar_hud_panel_strafehud_bar_accel_color, autocvar_hud_panel_strafehud_bar_accel_alpha * panel_fg_alpha, autocvar_hud_panel_strafehud_style, STRAFEHUD_GRADIENT_RIGHT); - HUD_Panel_DrawStrafeHUD(preaccelzone_right_offset, preaccelzone_width, hidden_width, autocvar_hud_panel_strafehud_bar_preaccel_color, autocvar_hud_panel_strafehud_bar_preaccel_alpha * panel_fg_alpha, autocvar_hud_panel_strafehud_style, STRAFEHUD_GRADIENT_NONE); + if(autocvar_hud_panel_strafehud_bar_preaccel) + HUD_Panel_DrawStrafeHUD(preaccelzone_right_offset, preaccelzone_width, hidden_width, autocvar_hud_panel_strafehud_bar_accel_color, autocvar_hud_panel_strafehud_bar_accel_alpha * panel_fg_alpha, autocvar_hud_panel_strafehud_style, STRAFEHUD_GRADIENT_LEFT); // draw overturn zone (technically incorrect, acceleration decreases at 90 degrees but speed loss happens a little bit after 90 degrees, however due to sv_airstopaccelerate that's hard to calculate) HUD_Panel_DrawStrafeHUD(overturn_offset, overturn_width, hidden_width, autocvar_hud_panel_strafehud_bar_overturn_color, autocvar_hud_panel_strafehud_bar_overturn_alpha * panel_fg_alpha, autocvar_hud_panel_strafehud_style, STRAFEHUD_GRADIENT_BOTH); @@ -803,7 +808,8 @@ void HUD_StrafeHUD() } else if(moveangle >= real_prebestangle) { - currentangle_color = autocvar_hud_panel_strafehud_angle_accel_color; + if(autocvar_hud_panel_strafehud_bar_preaccel) + currentangle_color = autocvar_hud_panel_strafehud_angle_accel_color; strafe_ratio = (moveangle - real_prebestangle) / (real_bestangle - real_prebestangle); } diff --git a/qcsrc/client/hud/panel/strafehud.qh b/qcsrc/client/hud/panel/strafehud.qh index b351f936a..eac62e7ed 100644 --- a/qcsrc/client/hud/panel/strafehud.qh +++ b/qcsrc/client/hud/panel/strafehud.qh @@ -10,12 +10,11 @@ int autocvar_hud_panel_strafehud_style = 2; int autocvar_hud_panel_strafehud_unit = 1; bool autocvar_hud_panel_strafehud_unit_show = true; bool autocvar_hud_panel_strafehud_uncapped = false; +bool autocvar_hud_panel_strafehud_bar_preaccel = true; vector autocvar_hud_panel_strafehud_bar_neutral_color = '1 1 1'; float autocvar_hud_panel_strafehud_bar_neutral_alpha = 0.1; vector autocvar_hud_panel_strafehud_bar_accel_color = '0 1 0'; float autocvar_hud_panel_strafehud_bar_accel_alpha = 0.5; -vector autocvar_hud_panel_strafehud_bar_preaccel_color = '1 0.75 0'; -float autocvar_hud_panel_strafehud_bar_preaccel_alpha = 0.5; vector autocvar_hud_panel_strafehud_bar_overturn_color = '1 0 1'; float autocvar_hud_panel_strafehud_bar_overturn_alpha = 0.5; int autocvar_hud_panel_strafehud_angle_style = 0; -- 2.39.2