]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
strafehud: add strafe efficiency indicator
authorJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Thu, 6 Jul 2023 19:01:20 +0000 (21:01 +0200)
committerJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Thu, 6 Jul 2023 19:01:20 +0000 (21:01 +0200)
_hud_common.cfg
qcsrc/client/hud/panel/strafehud.qc
qcsrc/client/hud/panel/strafehud.qh

index a3b4a5c2026f78843a99b0aa63874abb83243d58..953984a772445cd6c50ce4bfd64fef468075ed8c 100644 (file)
@@ -224,6 +224,8 @@ seta hud_panel_strafehud_sonar_pitch_exponent "1" "exponent of the dynamic playb
 seta hud_panel_strafehud_vangle "0" "set to \"1\" to enable the vertical angle indicator"
 seta hud_panel_strafehud_vangle_color "0.75 0.75 0.75" "color of the vertical angle text"
 seta hud_panel_strafehud_vangle_size "1" "size of the vertical angle text (relative to the panel height)"
+seta hud_panel_strafehud_strafeefficiency "0" "set to \"1\" to enable the strafe efficiency indicator"
+seta hud_panel_strafehud_strafeefficiency_size "1" "size of the strafe efficiency text (relative to the panel height)"
 seta hud_panel_strafehud_projection "0" "strafehud projection mode, \"0\" = linear, \"1\" = perspective, \"2\" = panoramic"
 
 // hud panel aliases
index 88a80976f86c38f82756cde136d38ffac7b8c4c2..3bfcdd3dc4a726bfaf65c818f701844c8031f28b 100644 (file)
@@ -921,10 +921,10 @@ void HUD_StrafeHUD()
                }
 
                // draw the actual strafe angle
+               float strafe_ratio = 0;
                if(!immobile)
                {
                        float moveangle = fabs(angle + wishangle);
-                       float strafe_ratio = 0;
 
                        // player is overturning
                        if(moveangle >= 90)
@@ -1136,6 +1136,24 @@ void HUD_StrafeHUD()
                        }
                }
 
+               // strafe efficiency
+               {
+                       if(autocvar_hud_panel_strafehud_strafeefficiency)
+                       {
+                               float strafeeff_height = autocvar_hud_panel_strafehud_strafeefficiency_size * panel_size.y;
+                               string strafeeff_text = strcat(ftos_decimals(strafe_ratio * 100, 2), "%");
+                           vector strafeeff_color = '1 1 1' - (strafe_ratio > 0 ? '1 0 1' : '0 1 1') * fabs(strafe_ratio);
+
+                               bool was_drawn = StrafeHUD_drawTextIndicator(
+                                       strafeeff_text, strafeeff_height,
+                                       strafeeff_color, 1,
+                                       time, text_offset_top, STRAFEHUD_TEXT_TOP);
+
+                               if(was_drawn)
+                                       text_offset_top += strafeeff_height;
+                       }
+               }
+
                // show height achieved by a single jump
                // FIXME: checking z position differences is unreliable (warpzones, teleporter, kill, etc) but using velocity to calculate jump height would be
                //        inaccurate in hud code (possibly different tick rate than physics, doesn't run when hud isn't drawn, rounding errors)
index 782831acd466426e8924d1651ca5706fe928210a..861a566b79fdd09c0b8cfd0fcd6b763c3c6a6d7a 100644 (file)
@@ -73,6 +73,8 @@ float autocvar_hud_panel_strafehud_sonar_pitch_exponent = 1;
 bool autocvar_hud_panel_strafehud_vangle = false;
 vector autocvar_hud_panel_strafehud_vangle_color = '0.75 0.75 0.75';
 float autocvar_hud_panel_strafehud_vangle_size = 1;
+bool autocvar_hud_panel_strafehud_strafeefficiency = false;
+float autocvar_hud_panel_strafehud_strafeefficiency_size = 1;
 int autocvar_hud_panel_strafehud_projection = 0;
 
 void HUD_Panel_DrawStrafeHUD(float, float, float, vector, float, int, int, bool, float);