From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Thu, 2 Jul 2020 06:30:16 +0000 (+0200) Subject: strafehud: make the angle indicator use a gradient too if the hud is set to gradient... X-Git-Tag: xonotic-v0.8.5~738^2~19 X-Git-Url: https://git.xonotic.org/?a=commitdiff_plain;h=ef073fef4fd1826e5be07181cc46be70b9b178a8;p=xonotic%2Fxonotic-data.pk3dir.git strafehud: make the angle indicator use a gradient too if the hud is set to gradient style --- diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc index 6edac53a7..89e64fbed 100644 --- a/qcsrc/client/hud/panel/strafehud.qc +++ b/qcsrc/client/hud/panel/strafehud.qc @@ -116,6 +116,7 @@ void HUD_StrafeHUD() float minspeed; float shift_offset = 0; bool straight_overturn = false; + bool immobile = speed <= (swimming ? antiflicker_speed : 0); float hudangle; float neutral_offset; float neutral_width; @@ -455,7 +456,7 @@ void HUD_StrafeHUD() overturn_width = 180/hudangle * panel_size.x; // the neutral zone fills the whole strafe bar - if(speed <= (swimming ? antiflicker_speed : 0)) + if(immobile) { // draw neutral zone if(panel_size.x > 0 && panel_size.y > 0 && autocvar_hud_panel_strafehud_bar_neutral_alpha * panel_fg_alpha > 0) @@ -555,13 +556,13 @@ void HUD_StrafeHUD() } } - if(speed < (maxspeed + antiflicker_speed) && speed > 0) + if(speed < (maxspeed + antiflicker_speed) && !immobile) { bestangle_anywhere = true; // moving forward should suffice to gain speed } // draw the actual strafe angle - if(!bestangle_anywhere) // player gains speed with strafing + if(!bestangle_anywhere && !immobile) // player gains speed with strafing { if((direction > 0 && (angle >= bestangle || angle <= -(bestangle + wishangle*2))) || (direction < 0 && (angle <= bestangle || angle >= -(bestangle + wishangle*2)))) @@ -581,6 +582,38 @@ void HUD_StrafeHUD() { currentangle_offset = panel_size.x/2; } + + if(autocvar_hud_panel_strafehud_style == 2 && !immobile) + { + float moveangle = angle + wishangle; + float strafeangle = (bestangle + wishangle) * (direction < 0 ? -1 : 1); + float strafe_ratio = 0; + if(fabs(moveangle) > 90) + { + strafe_ratio = -((fabs(moveangle) - 90) / 90); + if(strafe_ratio < -1) strafe_ratio = -1 - strafe_ratio%1; + } + else + { + if(moveangle >= strafeangle) + { + strafe_ratio = 1 - (moveangle - strafeangle) / (90 - strafeangle); + } + else if(moveangle <= -strafeangle) + { + strafe_ratio = 1 - (moveangle + strafeangle) / (-90 + strafeangle); + } + } + if(strafe_ratio < 0) + { + currentangle_color = StrafeHUD_mixColors(autocvar_hud_panel_strafehud_angle_neutral_color, autocvar_hud_panel_strafehud_angle_overturn_color, -strafe_ratio); + } + else + { + currentangle_color = StrafeHUD_mixColors(autocvar_hud_panel_strafehud_angle_neutral_color, autocvar_hud_panel_strafehud_angle_accel_color, strafe_ratio); + } + } + if(currentangle_size.x > 0 && currentangle_size.y > 0 && autocvar_hud_panel_strafehud_angle_alpha * panel_fg_alpha > 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);