From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Sun, 15 Jan 2023 18:30:49 +0000 (+0100) Subject: strafehud: refactor some drawing code + make the angle arrows obey hud shift/scaling X-Git-Tag: xonotic-v0.8.6~136^2~10 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=cd122db718a7bb17b01b975628390ca6ae290fda;p=xonotic%2Fxonotic-data.pk3dir.git strafehud: refactor some drawing code + make the angle arrows obey hud shift/scaling --- diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc index d1f5c1c61..e21e37c75 100644 --- a/qcsrc/client/hud/panel/strafehud.qc +++ b/qcsrc/client/hud/panel/strafehud.qc @@ -613,8 +613,6 @@ void HUD_StrafeHUD() direction_size_horizontal.x = panel_size.x * min(autocvar_hud_panel_strafehud_direction_length, .5); direction_size_horizontal.y = direction_size_vertical.x; direction_size_horizontal.z = 0; - // overturn - overturn_width = 180/hudangle * panel_size.x; // the neutral zone fills the whole strafe bar if(immobile) @@ -637,18 +635,33 @@ void HUD_StrafeHUD() else { // calculate various zones of the strafe-o-meter - accelzone_width = (90 - fabs(bestangle + wishangle))/hudangle * panel_size.x; if(autocvar_hud_panel_strafehud_bar_preaccel) preaccelzone_width = (fabs(bestangle - prebestangle))/hudangle * panel_size.x; else preaccelzone_width = 0; - overturn_offset = accelzone_width + preaccelzone_width; - accelzone_right_offset = preaccelzone_width; - accelzone_left_offset = overturn_offset + overturn_width; - preaccelzone_right_offset = 0; - preaccelzone_left_offset = accelzone_left_offset + accelzone_width; + accelzone_width = (90 - fabs(bestangle + wishangle))/hudangle * panel_size.x; + overturn_width = 180/hudangle * panel_size.x; neutral_width = 360/hudangle * panel_size.x - accelzone_width*2 - preaccelzone_width*2 - overturn_width; - neutral_offset = direction == STRAFEHUD_DIRECTION_LEFT ? preaccelzone_left_offset + preaccelzone_width : -neutral_width; + + { + float current_offset = 0; + preaccelzone_right_offset = current_offset; + current_offset += preaccelzone_width; + + accelzone_right_offset = current_offset; + current_offset += accelzone_width; + + overturn_offset = current_offset; + current_offset += overturn_width; + + accelzone_left_offset = current_offset; + current_offset += accelzone_width; + + preaccelzone_left_offset = current_offset; + current_offset += preaccelzone_width; + + neutral_offset = direction == STRAFEHUD_DIRECTION_LEFT ? current_offset : -neutral_width; // the wrapping code may struggle if we always append it on the right side + } // shift hud if operating in view angle centered mode if(mode == STRAFEHUD_MODE_VIEW_CENTERED) @@ -1108,6 +1121,8 @@ 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) { + origin = HUD_Shift(origin); + size = HUD_ScaleX(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);