From 265ea90c68596532755ca559f7b9abec12ded795 Mon Sep 17 00:00:00 2001 From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Wed, 24 Mar 2021 12:51:28 +0100 Subject: [PATCH] Add patch from Juhu/strafehud-fixes branch: "strafehud: add size restrictions back but add a cvar to disable them" --- _hud_common.cfg | 1 + qcsrc/client/hud/panel/strafehud.qc | 57 +++++++++++++++++++++++++---- qcsrc/client/hud/panel/strafehud.qh | 1 + 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/_hud_common.cfg b/_hud_common.cfg index e1a9d8af4..cd32a4128 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -139,6 +139,7 @@ seta hud_panel_strafehud_range "0" "the angle range up to 360 degrees displayed seta hud_panel_strafehud_style "2" "\"0\" = no styling, \"1\" = progress bar style for the strafe bar, \"2\" = gradient for the strafe bar" 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_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" diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc index e87a29751..d1ae9c08c 100644 --- a/qcsrc/client/hud/panel/strafehud.qc +++ b/qcsrc/client/hud/panel/strafehud.qc @@ -168,6 +168,9 @@ void HUD_StrafeHUD() float range_minangle; float arrow_size = max(panel_size.y * min(autocvar_hud_panel_strafehud_angle_arrow_size, 10), 0); // there's only one size cvar for the arrows, they will always have a 45° angle to ensure proper rendering without antialiasing + if(!autocvar_hud_panel_strafehud_uncapped) + arrow_size = max(arrow_size, 1); + // determine whether the player is pressing forwards or backwards keys if(islocal) // if entity is local player { @@ -459,8 +462,24 @@ void HUD_StrafeHUD() // how much is hidden by the current hud angle hidden_width = (360 - hudangle) / hudangle * panel_size.x; // current angle - currentangle_size.x = panel_size.x * min(autocvar_hud_panel_strafehud_angle_width, 10); - currentangle_size.y = max(panel_size.y * min(autocvar_hud_panel_strafehud_angle_height, 10), 0); + currentangle_size.x = autocvar_hud_panel_strafehud_angle_width; + currentangle_size.y = autocvar_hud_panel_strafehud_angle_height; + if(!autocvar_hud_panel_strafehud_uncapped) + { + currentangle_size.x = min(currentangle_size.x, 10); + currentangle_size.y = min(currentangle_size.y, 10); + } + currentangle_size.x *= panel_size.x; + currentangle_size.y *= panel_size.y; + if(!autocvar_hud_panel_strafehud_uncapped) + { + currentangle_size.x = max(currentangle_size.x, 1); + currentangle_size.y = max(currentangle_size.y, 1); + } + else + { + currentangle_size.y = max(currentangle_size.y, 0); + } if(mode == 0) { currentangle_offset = angle/hudangle * panel_size.x; @@ -473,6 +492,8 @@ void HUD_StrafeHUD() bestangle_offset = bestangle/hudangle * panel_size.x + panel_size.x/2; switch_bestangle_offset = -bestangle/hudangle * panel_size.x + panel_size.x/2; bestangle_width = panel_size.x * autocvar_hud_panel_strafehud_switch_width; + if(!autocvar_hud_panel_strafehud_uncapped) + bestangle_width = max(bestangle_width, 1); if(((angle > -wishangle && direction < 0) || (angle < -wishangle && direction > 0)) && (direction != 0)) { @@ -481,7 +502,12 @@ void HUD_StrafeHUD() switch_odd_bestangle_offset = (odd_bestangle+bestangle*2)/hudangle * panel_size.x + panel_size.x/2; } // direction indicator - direction_size_vertical.x = panel_size.y * min(autocvar_hud_panel_strafehud_direction_width, .5); + direction_size_vertical.x = autocvar_hud_panel_strafehud_direction_width; + if(!autocvar_hud_panel_strafehud_uncapped) + direction_size_vertical.x = min(direction_size_vertical.x, 1); + direction_size_vertical.x *= panel_size.y; + if(!autocvar_hud_panel_strafehud_uncapped) + direction_size_vertical.x = max(direction_size_vertical.x, 1); direction_size_vertical.y = panel_size.y; direction_size_horizontal.x = max(panel_size.x * min(autocvar_hud_panel_strafehud_direction_length, .5), direction_size_vertical.x); direction_size_horizontal.y = direction_size_vertical.x; @@ -586,12 +612,19 @@ void HUD_StrafeHUD() } // experimental: slick detector - slickdetector_height = panel_size.y * bound(0, autocvar_hud_panel_strafehud_slickdetector_height, 0.5); + slickdetector_height = max(autocvar_hud_panel_strafehud_slickdetector_height, 0); + if(!autocvar_hud_panel_strafehud_uncapped) + slickdetector_height = min(slickdetector_height, 1); + slickdetector_height *= panel_size.y; if(autocvar_hud_panel_strafehud_slickdetector_range > 0 && autocvar_hud_panel_strafehud_slickdetector_alpha > 0 && slickdetector_height > 0 && panel_size.x > 0) // dunno if slick detection works in spectate { - float slicksteps = 90 / pow(2, bound(0, autocvar_hud_panel_strafehud_slickdetector_granularity, 4)); + float slicksteps = max(autocvar_hud_panel_strafehud_slickdetector_granularity, 0); bool slickdetected = false; + if(!autocvar_hud_panel_strafehud_uncapped) + slicksteps = min(slicksteps, 4); + slicksteps = 90 / pow(2, slicksteps); + if(islocal) slickdetected = IS_ONSLICK(strafeplayer); // don't need to traceline if already touching slick // traceline into every direction @@ -750,7 +783,12 @@ void HUD_StrafeHUD() if(startspeed >= 0 && text_alpha > 0 && autocvar_hud_panel_strafehud_startspeed_size > 0) { vector startspeed_size = panel_size; - startspeed_size.y = panel_size.y * min(autocvar_hud_panel_strafehud_startspeed_size, 10); + startspeed_size.y = autocvar_hud_panel_strafehud_startspeed_size; + if(!autocvar_hud_panel_strafehud_uncapped) + startspeed_size.y = min(startspeed_size.y, 10); + startspeed_size.y *= panel_size.y; + if(!autocvar_hud_panel_strafehud_uncapped) + startspeed_size.y = max(startspeed_size.y, 1); drawstring_aspect(panel_pos + eY * (panel_size.y + arrow_size + ((currentangle_size.y - panel_size.y) / 2)), strcat(ftos_decimals(startspeed * speed_conversion_factor, 2), autocvar_hud_panel_strafehud_unit_show ? speed_unit : ""), startspeed_size, autocvar_hud_panel_strafehud_startspeed_color, text_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); } } @@ -802,7 +840,12 @@ void HUD_StrafeHUD() if(jumpheight_persistent > 0 && text_alpha > 0 && autocvar_hud_panel_strafehud_jumpheight_size > 0) { vector jumpheight_size = panel_size; - jumpheight_size.y = panel_size.y * min(autocvar_hud_panel_strafehud_jumpheight_size, 10); + jumpheight_size.y = autocvar_hud_panel_strafehud_jumpheight_size; + if(!autocvar_hud_panel_strafehud_uncapped) + jumpheight_size.y = min(jumpheight_size.y, 10); + jumpheight_size.y *= panel_size.y; + if(!autocvar_hud_panel_strafehud_uncapped) + jumpheight_size.y = max(jumpheight_size.y, 1); drawstring_aspect(panel_pos - eY * (jumpheight_size.y + arrow_size + ((currentangle_size.y - panel_size.y) / 2)), strcat(ftos_decimals(jumpheight_persistent * length_conversion_factor, length_decimals), autocvar_hud_panel_strafehud_unit_show ? length_unit : ""), jumpheight_size, autocvar_hud_panel_strafehud_jumpheight_color, text_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); } } diff --git a/qcsrc/client/hud/panel/strafehud.qh b/qcsrc/client/hud/panel/strafehud.qh index ef0c447ce..3e8ab93f0 100644 --- a/qcsrc/client/hud/panel/strafehud.qh +++ b/qcsrc/client/hud/panel/strafehud.qh @@ -9,6 +9,7 @@ AUTOCVAR_SAVE(hud_panel_strafehud_range, float, 0, "the angle range up to 360 de AUTOCVAR_SAVE(hud_panel_strafehud_style, int, 2, "\"0\" = no styling, \"1\" = progress bar style for the strafe bar, \"2\" = gradient for the strafe bar"); AUTOCVAR_SAVE(hud_panel_strafehud_unit, int, 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)"); AUTOCVAR_SAVE(hud_panel_strafehud_unit_show, bool, true, "show units"); +AUTOCVAR_SAVE(hud_panel_strafehud_uncapped, bool, false, "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)"); AUTOCVAR_SAVE(hud_panel_strafehud_bar_neutral_color, vector, '1 1 1', "color of the strafe meter neutral zone"); AUTOCVAR_SAVE(hud_panel_strafehud_bar_neutral_alpha, float, 0.1, "opacity of the strafe meter neutral zone"); AUTOCVAR_SAVE(hud_panel_strafehud_bar_accel_color, vector, '0 1 0', "color of the strafe meter acceleration zone"); -- 2.39.2