From c8c88c99dd248213626dedfafe872248011aa385 Mon Sep 17 00:00:00 2001 From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Mon, 9 Sep 2024 06:31:03 +0200 Subject: [PATCH] strafehud: draw switch indicators using the angle indicator style --- _hud_common.cfg | 3 +- qcsrc/client/hud/panel/strafehud.qc | 29 +++++++++++++++ qcsrc/client/hud/panel/strafehud.qh | 3 +- qcsrc/client/hud/panel/strafehud/core.qc | 46 ------------------------ qcsrc/client/hud/panel/strafehud/util.qc | 5 --- qcsrc/client/hud/panel/strafehud/util.qh | 1 - 6 files changed, 31 insertions(+), 56 deletions(-) diff --git a/_hud_common.cfg b/_hud_common.cfg index 8bd81ef3c..383d9cd85 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -182,8 +182,7 @@ seta hud_panel_strafehud_bestangle_alpha "0.5" "opacity of the indicator showing seta hud_panel_strafehud_switch "1" "set to \"1\" to enable the strafe angle indicator showing the angle to move to when changing side" seta hud_panel_strafehud_switch_minspeed "-1" "minimum speed in qu/s at which angle indicator(s) which are used to aid changing strafe direction will be shown (set to -1 for dynamic minspeed)" seta hud_panel_strafehud_switch_color "1 1 0" "color of the strafe angle indicators for changing strafe direction" -seta hud_panel_strafehud_switch_alpha "1" "opacity of the strafe angle indicators for changing strafe direction" -seta hud_panel_strafehud_switch_width "0.003" "width of the strafe angle indicators for changing strafe direction (relative to the strafe bar width)" +seta hud_panel_strafehud_switch_alpha "0.5" "opacity of the strafe angle indicators for changing strafe direction" seta hud_panel_strafehud_direction "0" "set to \"1\" to enable the direction caps to see in which direction you are currently strafing" seta hud_panel_strafehud_direction_color "0 0.5 1" "color of the direction caps which indicate the direction the player is currently strafing towards" seta hud_panel_strafehud_direction_alpha "1" "opacity of the direction caps which indicate the direction the player is currently strafing towards" diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc index dc6f90608..5f72f4627 100644 --- a/qcsrc/client/hud/panel/strafehud.qc +++ b/qcsrc/client/hud/panel/strafehud.qc @@ -471,6 +471,35 @@ void HUD_StrafeHUD() { bool angle_indicator_visible = false; + // minimum speed for change indicators + float minspeed = autocvar_hud_panel_strafehud_switch_minspeed; + if(minspeed < 0) + minspeed = bestspeed + frictionspeed; + + // only draw change indicators if minspeed is reached + if(autocvar_hud_panel_strafehud_switch && speed >= minspeed) + { + // draw the change indicator(s) + float current_changeangle = opposite_direction ? opposite_changeangle : changeangle; + float opposite_changeangle = opposite_direction ? opposite_bestangle : bestangle; + + StrafeHUD_DrawAngleIndicator( + current_changeangle, currentangle_size, arrow_size, num_dashes, + has_top_arrow, has_bottom_arrow, autocvar_hud_panel_strafehud_switch_color, + autocvar_hud_panel_strafehud_switch_alpha, hudangle); + + if(direction == STRAFEHUD_DIRECTION_NONE) + { + StrafeHUD_DrawAngleIndicator( + opposite_changeangle, currentangle_size, arrow_size, num_dashes, + has_top_arrow, has_bottom_arrow, autocvar_hud_panel_strafehud_switch_color, + autocvar_hud_panel_strafehud_switch_alpha, hudangle); + } + + if(autocvar_hud_panel_strafehud_switch_alpha > 0) + angle_indicator_visible = true; + } + if(autocvar_hud_panel_strafehud_bestangle && direction != STRAFEHUD_DIRECTION_NONE) { float ghostangle = opposite_direction ? opposite_bestangle : bestangle; diff --git a/qcsrc/client/hud/panel/strafehud.qh b/qcsrc/client/hud/panel/strafehud.qh index 6afc88e3c..1c1a3d934 100644 --- a/qcsrc/client/hud/panel/strafehud.qh +++ b/qcsrc/client/hud/panel/strafehud.qh @@ -35,8 +35,7 @@ float autocvar_hud_panel_strafehud_bestangle_alpha = 0.5; bool autocvar_hud_panel_strafehud_switch = true; float autocvar_hud_panel_strafehud_switch_minspeed = -1; vector autocvar_hud_panel_strafehud_switch_color = '1 1 0'; -float autocvar_hud_panel_strafehud_switch_alpha = 1; -float autocvar_hud_panel_strafehud_switch_width = 0.003; +float autocvar_hud_panel_strafehud_switch_alpha = 0.5; bool autocvar_hud_panel_strafehud_direction = false; vector autocvar_hud_panel_strafehud_direction_color = '0 0.5 1'; float autocvar_hud_panel_strafehud_direction_alpha = 1; diff --git a/qcsrc/client/hud/panel/strafehud/core.qc b/qcsrc/client/hud/panel/strafehud/core.qc index 501fe0187..19e526f14 100644 --- a/qcsrc/client/hud/panel/strafehud/core.qc +++ b/qcsrc/client/hud/panel/strafehud/core.qc @@ -135,52 +135,6 @@ void StrafeHUD_DrawStrafeMeter( autocvar_hud_panel_strafehud_bar_neutral_alpha * panel_fg_alpha, autocvar_hud_panel_strafehud_style, STRAFEHUD_GRADIENT_NONE, true, hudangle); - - float minspeed = autocvar_hud_panel_strafehud_switch_minspeed; - if(minspeed < 0) - minspeed = bestspeed + frictionspeed; - - // only draw indicators if minspeed is reached - if(autocvar_hud_panel_strafehud_switch && speed >= minspeed && autocvar_hud_panel_strafehud_switch_alpha > 0) - { - // draw the change indicator(s) - float offsetangle = opposite_direction ? opposite_changeangle : changeangle; - float opposite_offsetangle = opposite_direction ? opposite_bestangle : bestangle; - - float bestangle_width = max(panel_size.x * autocvar_hud_panel_strafehud_switch_width, 1); - bestangle_width = StrafeHUD_widthToAngle(bestangle_width, hudangle); - - // remove change indicator width from offset - if(direction == STRAFEHUD_DIRECTION_LEFT) - { - if(!opposite_direction) - opposite_offsetangle -= bestangle_width; - else - offsetangle -= bestangle_width; - } - else - { - if(!opposite_direction) - offsetangle -= bestangle_width; - else - opposite_offsetangle -= bestangle_width; - } - - StrafeHUD_drawStrafeHUD( - offsetangle, bestangle_width, - autocvar_hud_panel_strafehud_switch_color, - autocvar_hud_panel_strafehud_switch_alpha * panel_fg_alpha, - STRAFEHUD_STYLE_DRAWFILL, STRAFEHUD_GRADIENT_NONE, - false, hudangle); - - if(direction == STRAFEHUD_DIRECTION_NONE) - StrafeHUD_drawStrafeHUD( - opposite_offsetangle, bestangle_width, - autocvar_hud_panel_strafehud_switch_color, - autocvar_hud_panel_strafehud_switch_alpha * panel_fg_alpha, - STRAFEHUD_STYLE_DRAWFILL, STRAFEHUD_GRADIENT_NONE, - false, hudangle); - } } } diff --git a/qcsrc/client/hud/panel/strafehud/util.qc b/qcsrc/client/hud/panel/strafehud/util.qc index 256e314a5..19ac844fe 100644 --- a/qcsrc/client/hud/panel/strafehud/util.qc +++ b/qcsrc/client/hud/panel/strafehud/util.qc @@ -14,11 +14,6 @@ float StrafeHUD_angleToOffset(float angle, float range) return StrafeHUD_angleToWidth(angle, range) + panel_size.x / 2; } -float StrafeHUD_widthToAngle(float offset, float range) -{ - return offset / panel_size.x * range; -} - float StrafeHUD_project(float ratio, float range, bool reverse) { range *= DEG2RAD / 2; diff --git a/qcsrc/client/hud/panel/strafehud/util.qh b/qcsrc/client/hud/panel/strafehud/util.qh index 9053ff610..b00adf9ae 100644 --- a/qcsrc/client/hud/panel/strafehud/util.qh +++ b/qcsrc/client/hud/panel/strafehud/util.qh @@ -9,7 +9,6 @@ float StrafeHUD_projectOffset(float, float, bool); float StrafeHUD_projectWidth(float, float, float); float StrafeHUD_angleToWidth(float, float); float StrafeHUD_angleToOffset(float, float); -float StrafeHUD_widthToAngle(float, float); float DetectWaterLevel(entity); float DetectFrameTime(); float DetectWishAngle(vector, int, bool); -- 2.39.2