]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
strafehud: draw switch indicators using the angle indicator style
authorJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Mon, 9 Sep 2024 04:31:03 +0000 (06:31 +0200)
committerJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Mon, 9 Sep 2024 04:31:03 +0000 (06:31 +0200)
_hud_common.cfg
qcsrc/client/hud/panel/strafehud.qc
qcsrc/client/hud/panel/strafehud.qh
qcsrc/client/hud/panel/strafehud/core.qc
qcsrc/client/hud/panel/strafehud/util.qc
qcsrc/client/hud/panel/strafehud/util.qh

index 8bd81ef3c2a318f392078d5b135d706c50bc2c34..383d9cd8558d8e805c3ba1f4c6044f02c62451a7 100644 (file)
@@ -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"
index dc6f90608dab69419d5131dba82ab21aa286c805..5f72f4627483298724105b2d2134de855dee53bf 100644 (file)
@@ -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;
index 6afc88e3c51ec2a76f2f18493ed2360952b62281..1c1a3d9342cd520d0673275d40efed322375d41a 100644 (file)
@@ -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;
index 501fe018792a7dc1cafafb02ab1863df850e18dc..19e526f1403bcc51b54e587380ea8538e91bd855 100644 (file)
@@ -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);
-               }
        }
 }
 
index 256e314a58d42a8dfa197d4b7ee227b8c5c0f5f8..19ac844fe13246369fb6a845aee07b0f054485a2 100644 (file)
@@ -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;
index 9053ff61045ed0431192b8cdd36de23484d9aa30..b00adf9ae1c85986ac0ecc72db9d740fbfca9819 100644 (file)
@@ -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);