]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
strafehud: connect the arrow to the line when drawing the angle indicator
authorJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Mon, 27 Mar 2023 07:29:57 +0000 (09:29 +0200)
committerJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Mon, 27 Mar 2023 07:54:59 +0000 (09:54 +0200)
qcsrc/client/hud/panel/strafehud.qc
qcsrc/client/hud/panel/strafehud.qh

index 396dacb110e4fb2bd80237fc06383ef828eb1fea..c82a6c779ee53065cf289e339c3ca0ec036797f1 100644 (file)
@@ -954,6 +954,7 @@ void HUD_StrafeHUD()
                        default:
                                // don't offset text and arrows if the angle indicator line isn't drawn
                                angleheight_offset = panel_size.y;
+                               currentangle_size = '0 0 0';
                }
 
                float angle_offset_top = 0, angle_offset_bottom = 0;
@@ -976,11 +977,11 @@ void HUD_StrafeHUD()
                                                StrafeHUD_drawStrafeArrow(
                                                        panel_pos + eY * ((panel_size.y - angleheight_offset) / 2) + eX * ghost_offset,
                                                        arrow_size, autocvar_hud_panel_strafehud_bestangle_color,
-                                                       autocvar_hud_panel_strafehud_bestangle_alpha * panel_fg_alpha, true);
+                                                       autocvar_hud_panel_strafehud_bestangle_alpha * panel_fg_alpha, true, currentangle_size.x);
                                        StrafeHUD_drawStrafeArrow(
                                                panel_pos + eY * ((panel_size.y - angleheight_offset) / 2) + eX * currentangle_offset,
                                                arrow_size, currentangle_color,
-                                               autocvar_hud_panel_strafehud_angle_alpha * panel_fg_alpha, true);
+                                               autocvar_hud_panel_strafehud_angle_alpha * panel_fg_alpha, true, currentangle_size.x);
 
                                        angle_offset_top += arrow_size; // further offset the top text offset if the top arrow is drawn
                                }
@@ -990,11 +991,11 @@ void HUD_StrafeHUD()
                                                StrafeHUD_drawStrafeArrow(
                                                        panel_pos + eY * ((panel_size.y - angleheight_offset) / 2 + angleheight_offset) + eX * ghost_offset,
                                                        arrow_size, autocvar_hud_panel_strafehud_bestangle_color,
-                                                       autocvar_hud_panel_strafehud_bestangle_alpha * panel_fg_alpha, false);
+                                                       autocvar_hud_panel_strafehud_bestangle_alpha * panel_fg_alpha, false, currentangle_size.x);
                                        StrafeHUD_drawStrafeArrow(
                                                panel_pos + eY * ((panel_size.y - angleheight_offset) / 2 + angleheight_offset) + eX * currentangle_offset,
                                                arrow_size, currentangle_color,
-                                               autocvar_hud_panel_strafehud_angle_alpha * panel_fg_alpha, false);
+                                               autocvar_hud_panel_strafehud_angle_alpha * panel_fg_alpha, false, currentangle_size.x);
 
                                        angle_offset_bottom += arrow_size; // further offset the bottom text offset if the bottom arrow is drawn
                                }
@@ -1242,15 +1243,24 @@ void StrafeHUD_drawGradient(vector color1, vector color2, vector size, float ori
 }
 
 // draw the strafe arrows (inspired by drawspritearrow() in common/mutators/mutator/waypoints/waypointsprites.qc)
-void StrafeHUD_drawStrafeArrow(vector origin, float size, vector color, float alpha, bool flipped)
+void StrafeHUD_drawStrafeArrow(vector origin, float size, vector color, float alpha, bool flipped, float connection_width)
 {
        origin = HUD_Shift(origin);
-       size = HUD_ScaleX(size);
+       float width = HUD_ScaleX(size * 2 + connection_width);
+       float height = HUD_ScaleY(size);
        if(flipped) origin -= size * eY;
        R_BeginPolygon("", DRAWFLAG_NORMAL, true);
-       R_PolygonVertex(origin + (flipped ? size * eY : '0 0 0')          , '0 0 0', color, alpha);
-       R_PolygonVertex(origin + (flipped ? '0 0 0' : size * eY) - size * eX, '0 0 0', color, alpha);
-       R_PolygonVertex(origin + (flipped ? '0 0 0' : size * eY) + size * eX, '0 0 0', color, alpha);
+       if(connection_width > 0)
+       {
+               R_PolygonVertex(origin + (connection_width / 2 * eX) + (flipped ? height * eY : '0 0 0'), '0 0 0', color, alpha);
+               R_PolygonVertex(origin - (connection_width / 2 * eX) + (flipped ? height * eY : '0 0 0'), '0 0 0', color, alpha);
+       }
+       else
+       {
+               R_PolygonVertex(origin + (flipped ? height * eY : '0 0 0'), '0 0 0', color, alpha);
+       }
+       R_PolygonVertex(origin + (flipped ? '0 0 0' : height * eY) - (width / 2) * eX, '0 0 0', color, alpha);
+       R_PolygonVertex(origin + (flipped ? '0 0 0' : height * eY) + (width / 2) * eX, '0 0 0', color, alpha);
        R_EndPolygon();
 }
 
index 2287598e6220aae724abdaa5889c59d16b0fe06d..e726e98005b540919822d54af2161ff0ed1f6a00 100644 (file)
@@ -65,7 +65,7 @@ vector StrafeHUD_mixColors(vector, vector, float);
 void StrafeHUD_drawGradient(vector, vector, vector, float, float, float, float, int);
 float GetLengthUnitFactor(int);
 string GetLengthUnit(int);
-void StrafeHUD_drawStrafeArrow(vector, float, vector, float, bool);
+void StrafeHUD_drawStrafeArrow(vector, float, vector, float, bool, float);
 bool StrafeHUD_drawTextIndicator(string, float, vector, float, float, float, int);
 
 const int STRAFEHUD_MODE_VIEW_CENTERED = 0;