From e96453b40f42e6b4bd1c9d6edce7bebcb9c42eb9 Mon Sep 17 00:00:00 2001 From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Thu, 18 Mar 2021 15:25:45 +0100 Subject: [PATCH] Add patch from Juhu/strafehud-fixes branch: "strafehud: add angle indicator styles and arrows" --- _hud_common.cfg | 5 +++++ qcsrc/client/hud/panel/strafehud.qc | 35 ++++++++++++++++++++++++++++- qcsrc/client/hud/panel/strafehud.qh | 5 +++++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/_hud_common.cfg b/_hud_common.cfg index a62837f5f..e99fb5234 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -145,12 +145,17 @@ seta hud_panel_strafehud_bar_accel_color "0 1 0" "color of the strafe meter acce seta hud_panel_strafehud_bar_accel_alpha "0.3" "opacity of the strafe meter acceleration zone" seta hud_panel_strafehud_bar_overturn_color "1 0 1" "color of the strafe meter overturn zone" seta hud_panel_strafehud_bar_overturn_alpha "0.3" "opacity of the strafe meter overturn zone" +seta hud_panel_strafehud_angle_style "2" "set the angle indicator style: 0 = solid line, 1 = dashed line, 2 = none" +seta hud_panel_strafehud_angle_dashes "4" "determines the amount of dashes if the angle indicator uses a dashed line" seta hud_panel_strafehud_angle_alpha "0.8" "opacity of the indicator showing the player's current angle" seta hud_panel_strafehud_angle_height "1.5" "height of the indicator showing the player's current angle (relative to the panel height)" seta hud_panel_strafehud_angle_width "0.005" "width of the indicator showing the player's current angle (relative to the panel width)" seta hud_panel_strafehud_angle_neutral_color "1 1 0" "color of the indicator showing the player's current angle if the player's angle is within the neutral zone" seta hud_panel_strafehud_angle_accel_color "0 1 1" "color of the indicator showing the player's current angle if the player's angle is within the acceleration zone" seta hud_panel_strafehud_angle_overturn_color "1 0 1" "color of the indicator showing the player's current angle if the player's angle is within the overturn zone" +seta hud_panel_strafehud_angle_arrow "1" "set the angle indicators arrow style: 0 = none, 1 = top, 2 = bottom, 3 = both" +seta hud_panel_strafehud_angle_arrow_height "0.5" "height of the arrow (relative to the panel height)" +seta hud_panel_strafehud_angle_arrow_width "0.03" "width of the arrow (relative to the panel width)" seta hud_panel_strafehud_switch_minspeed "-1" "minimum speed in qu/s at which switch indicators which are used to aid changing strafe direction will be shown (uses physics maxspeed + antiflicker speed if negative)" seta hud_panel_strafehud_switch_active_color "0 1 0" "color of the switch indicator on the current side" seta hud_panel_strafehud_switch_active_alpha "1" "opacity of the switch indicator on the current side" diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc index 1d86963e6..6cf82e701 100644 --- a/qcsrc/client/hud/panel/strafehud.qc +++ b/qcsrc/client/hud/panel/strafehud.qc @@ -804,7 +804,40 @@ void HUD_StrafeHUD() 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); + switch(autocvar_hud_panel_strafehud_angle_style) + { + case 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); + break; + case 1: + vector line_size = currentangle_size; + line_size.y = currentangle_size.y / (bound(2, autocvar_hud_panel_strafehud_angle_dashes, 100)*2-1); + for(float i = 0; i < currentangle_size.y; i += line_size.y*2) + { + if(i + line_size.y*2 >= currentangle_size.y) line_size.y = currentangle_size.y - i; + drawfill(panel_pos - eY * ((currentangle_size.y - panel_size.y) / 2 - i) + eX * (currentangle_offset - line_size.x/2), line_size, currentangle_color, autocvar_hud_panel_strafehud_angle_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + } + break; + case 2: + default: + } + + if(autocvar_hud_panel_strafehud_angle_arrow > 0) + { + vector arrow_size = currentangle_size; + arrow_size.x = max(panel_size.x * autocvar_hud_panel_strafehud_angle_arrow_width, 1); + arrow_size.y = max(panel_size.y * min(autocvar_hud_panel_strafehud_angle_arrow_height, 1), 1); + vector arrow_fragment = '0 0.25 0'; + + for(float i = arrow_size.y; i > 0; i -= arrow_fragment.y) + { + arrow_fragment.x = arrow_size.x * (i/arrow_size.y); + if(autocvar_hud_panel_strafehud_angle_arrow == 1 || autocvar_hud_panel_strafehud_angle_arrow >= 3) + drawfill(panel_pos - eY * ((currentangle_size.y - panel_size.y) / 2 + i) + eX * (currentangle_offset - arrow_fragment.x/2), arrow_fragment, currentangle_color, autocvar_hud_panel_strafehud_angle_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + if(autocvar_hud_panel_strafehud_angle_arrow >= 2) + drawfill(panel_pos + eY * (-(currentangle_size.y - panel_size.y) / 2 + currentangle_size.y + i - arrow_fragment.y) + eX * (currentangle_offset - arrow_fragment.x/2), arrow_fragment, currentangle_color, autocvar_hud_panel_strafehud_angle_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + } + } } } } diff --git a/qcsrc/client/hud/panel/strafehud.qh b/qcsrc/client/hud/panel/strafehud.qh index ac984ed75..d057d953a 100644 --- a/qcsrc/client/hud/panel/strafehud.qh +++ b/qcsrc/client/hud/panel/strafehud.qh @@ -15,12 +15,17 @@ AUTOCVAR_SAVE(hud_panel_strafehud_bar_accel_color, vector, '0 1 0', "color of th AUTOCVAR_SAVE(hud_panel_strafehud_bar_accel_alpha, float, 0.3, "opacity of the strafe meter acceleration zone"); AUTOCVAR_SAVE(hud_panel_strafehud_bar_overturn_color, vector, '1 0 1', "color of the strafe meter overturn zone"); AUTOCVAR_SAVE(hud_panel_strafehud_bar_overturn_alpha, float, 0.3, "opacity of the strafe meter overturn zone"); +AUTOCVAR_SAVE(hud_panel_strafehud_angle_style, int, 2, "set the angle indicator style: 0 = solid line, 1 = dashed line, 2 = none"); +AUTOCVAR_SAVE(hud_panel_strafehud_angle_dashes, int, 4, "determines the amount of dashes if the angle indicator uses a dashed line"); AUTOCVAR_SAVE(hud_panel_strafehud_angle_alpha, float, 0.8, "opacity of the indicator showing the player's current angle"); AUTOCVAR_SAVE(hud_panel_strafehud_angle_height, float, 1.5, "height of the indicator showing the player's current angle (relative to the panel height)"); AUTOCVAR_SAVE(hud_panel_strafehud_angle_width, float, 0.005, "width of the indicator showing the player's current angle (relative to the panel width)"); AUTOCVAR_SAVE(hud_panel_strafehud_angle_neutral_color, vector, '1 1 0', "color of the indicator showing the player's current angle if the player's angle is within the neutral zone"); AUTOCVAR_SAVE(hud_panel_strafehud_angle_accel_color, vector, '0 1 1', "color of the indicator showing the player's current angle if the player's angle is within the acceleration zone"); AUTOCVAR_SAVE(hud_panel_strafehud_angle_overturn_color, vector, '1 0 1', "color of the indicator showing the player's current angle if the player's angle is within the overturn zone"); +AUTOCVAR_SAVE(hud_panel_strafehud_angle_arrow, int, 1, "set the angle indicators arrow style: 0 = none, 1 = top, 2 = bottom, 3 = both"); +AUTOCVAR_SAVE(hud_panel_strafehud_angle_arrow_height, float, 0.5, "height of the arrow (relative to the panel height)"); +AUTOCVAR_SAVE(hud_panel_strafehud_angle_arrow_width, float, 0.03, "width of the arrow (relative to the panel width)"); AUTOCVAR_SAVE(hud_panel_strafehud_switch_minspeed, float, -1, "minimum speed in qu/s at which switch indicators which are used to aid changing strafe direction will be shown (uses physics maxspeed + antiflicker speed if negative)"); AUTOCVAR_SAVE(hud_panel_strafehud_switch_active_color, vector, '0 1 0', "color of the switch indicator on the current side"); AUTOCVAR_SAVE(hud_panel_strafehud_switch_active_alpha, float, 1, "opacity of the switch indicator on the current side"); -- 2.39.2