From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Mon, 27 Mar 2023 07:29:57 +0000 (+0200) Subject: strafehud: connect the arrow to the line when drawing the angle indicator X-Git-Tag: xonotic-v0.8.6~136^2~1 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f5bd24b823c517378c360525c4e7b363ef80af7d;p=xonotic%2Fxonotic-data.pk3dir.git strafehud: connect the arrow to the line when drawing the angle indicator --- diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc index 396dacb11..c82a6c779 100644 --- a/qcsrc/client/hud/panel/strafehud.qc +++ b/qcsrc/client/hud/panel/strafehud.qc @@ -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(); } diff --git a/qcsrc/client/hud/panel/strafehud.qh b/qcsrc/client/hud/panel/strafehud.qh index 2287598e6..e726e9800 100644 --- a/qcsrc/client/hud/panel/strafehud.qh +++ b/qcsrc/client/hud/panel/strafehud.qh @@ -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;