]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
strafehud: add size restrictions back but add a cvar to disable them
authorJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Wed, 24 Mar 2021 11:44:23 +0000 (12:44 +0100)
committerJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Wed, 24 Mar 2021 11:44:23 +0000 (12:44 +0100)
_hud_common.cfg
qcsrc/client/hud/panel/strafehud.qc
qcsrc/client/hud/panel/strafehud.qh

index e1a9d8af42bd1128b6c637a5337504ef032ebee4..cd32a4128ba0ab85a7860d05422c8e262d973f9b 100644 (file)
@@ -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"
index ce8a1fcebbf4853396f0c2433a2d6dbd477b28ed..a30229f8885bbdca9e0bb60f445afb65fb0111ee 100644 (file)
@@ -158,6 +158,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
         {
@@ -449,8 +452,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;
@@ -463,6 +482,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))
         {
@@ -471,7 +492,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;
@@ -576,12 +602,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
@@ -740,7 +773,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);
             }
         }
@@ -792,7 +830,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);
             }
         }
index d25c7e249ba10e9749df93e9588f9f1699bac42b..2b3da21002fb59b0db85d1e68e6eafde9ca858c3 100644 (file)
@@ -9,6 +9,7 @@ float autocvar_hud_panel_strafehud_range = 0;
 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;
 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';