]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
strafehud: add a ghost angle indicator showing the best angle to gain maximum acceler...
authorJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Sat, 27 Mar 2021 07:58:26 +0000 (08:58 +0100)
committerJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Sat, 27 Mar 2021 07:58:26 +0000 (08:58 +0100)
_hud_common.cfg
qcsrc/client/hud/panel/strafehud.qc
qcsrc/client/hud/panel/strafehud.qh

index 0297d71e4cebea522072e5b7cfab8f8375426b02..ca6e7fb025a8d87c11966d0298a1a9e27a4bfcd9 100644 (file)
@@ -158,6 +158,9 @@ seta hud_panel_strafehud_angle_accel_color "0 1 1" "color of the indicator showi
 seta hud_panel_strafehud_angle_overturn_color "1 0 1" "color of the indicator showing the player's current angle if it is within the overturn zone"
 seta hud_panel_strafehud_angle_arrow "1" "set the angle indicator's arrow style: 0 = none, 1 = top, 2 = bottom, 3 = both"
 seta hud_panel_strafehud_angle_arrow_size "0.5" "size of the arrow (relative to the panel height)"
+seta hud_panel_strafehud_bestangle "0" "set to \"1\" to enable a ghost angle indicator showing the best angle to gain maximum acceleration"
+seta hud_panel_strafehud_bestangle_color "1 1 1" "color of the indicator showing the best angle to gain maximum acceleration"
+seta hud_panel_strafehud_bestangle_alpha "0.5" "opacity of the indicator showing the best angle to gain maximum acceleration"
 seta hud_panel_strafehud_switch_minspeed "-1" "minimum speed in qu/s at which switch 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 switch indicator"
 seta hud_panel_strafehud_switch_alpha "1" "opacity of the switch indicator"
index f88f54a48d28e2bdf68364a838b9b834f4dcdaa7..64ff1c7a538f95a6d15779d7b166d3c2ec3498ab 100644 (file)
@@ -570,18 +570,6 @@ void HUD_StrafeHUD()
             neutral_width = 360/hudangle * panel_size.x - accelzone_width*2 - preaccelzone_width*2 - overturn_width;
             neutral_offset = direction < 0 ? preaccelzone_left_offset + preaccelzone_width : -neutral_width;
 
-            // remove switch indicator width from offset
-            if(direction < 0)
-            {
-                bestangle_offset -= bestangle_width;
-                switch_odd_bestangle_offset -= bestangle_width;
-            }
-            else
-            {
-                switch_bestangle_offset -= bestangle_width;
-                odd_bestangle_offset -= bestangle_width;
-            }
-
             // shift hud if operating in view angle centered mode
             if(mode == 0)
             {
@@ -639,6 +627,23 @@ void HUD_StrafeHUD()
                 // draw the switch indicator(s)
                 float offset = !odd_angles ? bestangle_offset : odd_bestangle_offset;
                 float switch_offset = !odd_angles ? switch_bestangle_offset : switch_odd_bestangle_offset;
+
+                // remove switch indicator width from offset
+                if(direction < 0)
+                {
+                    if(!odd_angles)
+                        offset -= bestangle_width;
+                    else
+                        switch_offset -= bestangle_width;
+                }
+                else
+                {
+                    if(!odd_angles)
+                        switch_offset -= bestangle_width;
+                    else
+                        offset -= bestangle_width;
+                }
+
                 HUD_Panel_DrawStrafeHUD(switch_offset, bestangle_width, autocvar_hud_panel_strafehud_switch_color, autocvar_hud_panel_strafehud_switch_alpha * panel_fg_alpha, 0, 0);
                 if(direction == 0) HUD_Panel_DrawStrafeHUD(offset, bestangle_width, autocvar_hud_panel_strafehud_switch_color, autocvar_hud_panel_strafehud_switch_alpha * panel_fg_alpha, 0, 0);
             }
@@ -762,7 +767,11 @@ void HUD_StrafeHUD()
             switch(autocvar_hud_panel_strafehud_angle_style)
             {
                 case 1:
-                    if(currentangle_size.x > 0 && currentangle_size.y > 0) drawfill(panel_pos - eY * ((currentangle_size.y - panel_size.y) / 2) + eX * (currentangle_offset - currentangle_size.x/2), currentangle_size, currentangle_color, autocvar_hud_panel_strafehud_angle_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                    if(currentangle_size.x > 0 && currentangle_size.y > 0)
+                    {
+                        if(autocvar_hud_panel_strafehud_bestangle && direction != 0) drawfill(panel_pos - eY * ((currentangle_size.y - panel_size.y) / 2) + eX * ((!odd_angles ? bestangle_offset : odd_bestangle_offset) - currentangle_size.x/2), currentangle_size, autocvar_hud_panel_strafehud_bestangle_color, autocvar_hud_panel_strafehud_bestangle_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                        drawfill(panel_pos - eY * ((currentangle_size.y - panel_size.y) / 2) + eX * (currentangle_offset - currentangle_size.x/2), currentangle_size, currentangle_color, autocvar_hud_panel_strafehud_angle_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                    }
                     break;
                 case 2:
                     if(currentangle_size.x > 0 && currentangle_size.y > 0)
@@ -772,6 +781,7 @@ void HUD_StrafeHUD()
                         for(float i = 0; i < currentangle_size.y; i += line_size.y*2)
                         {
                             if(i + line_size.y*2 >= currentangle_size.y) line_size.y = currentangle_size.y - i;
+                            if(autocvar_hud_panel_strafehud_bestangle && direction != 0) drawfill(panel_pos - eY * ((currentangle_size.y - panel_size.y) / 2 - i) + eX * ((!odd_angles ? bestangle_offset : odd_bestangle_offset) - line_size.x/2), line_size, autocvar_hud_panel_strafehud_bestangle_color, autocvar_hud_panel_strafehud_bestangle_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                             drawfill(panel_pos - eY * ((currentangle_size.y - panel_size.y) / 2 - i) + eX * (currentangle_offset - line_size.x/2), line_size, currentangle_color, autocvar_hud_panel_strafehud_angle_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                         }
                     }
@@ -785,9 +795,15 @@ void HUD_StrafeHUD()
                 if(arrow_size > 0)
                 {
                     if(autocvar_hud_panel_strafehud_angle_arrow == 1 || autocvar_hud_panel_strafehud_angle_arrow >= 3)
+                    {
+                        if(autocvar_hud_panel_strafehud_bestangle && direction != 0) StrafeHUD_drawStrafeArrow(panel_pos + eY * ((panel_size.y - currentangle_size.y) / 2) + eX * (!odd_angles ? bestangle_offset : odd_bestangle_offset), arrow_size, autocvar_hud_panel_strafehud_bestangle_color, autocvar_hud_panel_strafehud_bestangle_alpha * panel_fg_alpha, true);
                         StrafeHUD_drawStrafeArrow(panel_pos + eY * ((panel_size.y - currentangle_size.y) / 2) + eX * currentangle_offset, arrow_size, currentangle_color, autocvar_hud_panel_strafehud_angle_alpha * panel_fg_alpha, true);
+                    }
                     if(autocvar_hud_panel_strafehud_angle_arrow >= 2)
+                    {
+                        if(autocvar_hud_panel_strafehud_bestangle && direction != 0) StrafeHUD_drawStrafeArrow(panel_pos + eY * ((panel_size.y - currentangle_size.y) / 2 + currentangle_size.y) + eX * (!odd_angles ? bestangle_offset : odd_bestangle_offset), arrow_size, autocvar_hud_panel_strafehud_bestangle_color, autocvar_hud_panel_strafehud_bestangle_alpha * panel_fg_alpha, false);
                         StrafeHUD_drawStrafeArrow(panel_pos + eY * ((panel_size.y - currentangle_size.y) / 2 + currentangle_size.y) + eX * currentangle_offset, arrow_size, currentangle_color, autocvar_hud_panel_strafehud_angle_alpha * panel_fg_alpha, false);
+                    }
                 }
             }
         }
index 33330e834265ba5bb6b606de1bb0b756cb69b2f4..fb438ec4170e55df05b5c58c37458fb5884b6333 100644 (file)
@@ -28,6 +28,9 @@ vector autocvar_hud_panel_strafehud_angle_accel_color = '0 1 1';
 vector autocvar_hud_panel_strafehud_angle_overturn_color = '1 0 1';
 int autocvar_hud_panel_strafehud_angle_arrow = 1;
 float autocvar_hud_panel_strafehud_angle_arrow_size = 0.5;
+bool autocvar_hud_panel_strafehud_bestangle = false;
+vector autocvar_hud_panel_strafehud_bestangle_color = '1 1 1';
+float autocvar_hud_panel_strafehud_bestangle_alpha = 0.5;
 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;