From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Mon, 16 Sep 2024 18:44:59 +0000 (+0200) Subject: strafehud: move minimum hud angle calculation into hud angle function X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7d82fba1a25540fc6c94bed789ee424f7c4108f1;p=xonotic%2Fxonotic-data.pk3dir.git strafehud: move minimum hud angle calculation into hud angle function --- diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc index 854197399..ec4893bce 100644 --- a/qcsrc/client/hud/panel/strafehud.qc +++ b/qcsrc/client/hud/panel/strafehud.qc @@ -164,13 +164,7 @@ void HUD_StrafeHUD() float wishangle = StrafeHUD_DetermineWishAngle(movement, keys, islocal); bool strafekeys = fabs(wishangle) > 45; - // determine minimum required angle to display full strafe range - float range_minangle = fabs(wishangle) % 90; // maximum range is 90 degree - if(range_minangle > 45) range_minangle = 45 - fabs(wishangle) % 45; // minimum angle range is 45 - range_minangle = 90 - range_minangle; // calculate value which is never >90 or <45 - range_minangle *= 2; // multiply to accommodate for both sides of the hud - - float hudangle = StrafeHUD_DetermineHudAngle(range_minangle); + float hudangle = StrafeHUD_DetermineHudAngle(wishangle); // detect air strafe turning static bool turn = false; diff --git a/qcsrc/client/hud/panel/strafehud/util.qc b/qcsrc/client/hud/panel/strafehud/util.qc index 02adbdbc2..74704685e 100644 --- a/qcsrc/client/hud/panel/strafehud/util.qc +++ b/qcsrc/client/hud/panel/strafehud/util.qc @@ -203,7 +203,7 @@ float StrafeHUD_DetermineWishAngle(vector movement, int keys, bool islocal) return wishangle; } -float StrafeHUD_DetermineHudAngle(float range_minangle) +float StrafeHUD_DetermineHudAngle(float wishangle) { float hudangle; if(isnan(autocvar_hud_panel_strafehud_range)) @@ -213,9 +213,19 @@ float StrafeHUD_DetermineHudAngle(float range_minangle) else if(autocvar_hud_panel_strafehud_range == 0) { if(autocvar__hud_configure) + { hudangle = 90; + } else + { + // determine minimum required angle to display full strafe range + float range_minangle = fabs(wishangle) % 90; // maximum range is 90 degree + if(range_minangle > 45) range_minangle = 45 - fabs(wishangle) % 45; // minimum angle range is 45 + range_minangle = 90 - range_minangle; // calculate value which is never >90 or <45 + range_minangle *= 2; // multiply to accommodate for both sides of the hud + hudangle = range_minangle; // use minimum angle required if dynamically setting hud angle + } } else if(autocvar_hud_panel_strafehud_range < 0) {