From c9a4e7ae7daaa82d6ac0b122dce2a1d73295fb91 Mon Sep 17 00:00:00 2001 From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Wed, 18 Jan 2023 15:00:33 +0100 Subject: [PATCH 1/1] strafehud: update the strafehud hud editor and add a dedicated cvar to disable optional features if it didn't already have one --- _hud_common.cfg | 13 ++++--- qcsrc/client/hud/panel/strafehud.qc | 36 +++++++++++-------- qcsrc/client/hud/panel/strafehud.qh | 9 +++-- .../menu/xonotic/dialog_hudpanel_strafehud.qc | 16 +++++---- 4 files changed, 47 insertions(+), 27 deletions(-) diff --git a/_hud_common.cfg b/_hud_common.cfg index 0089d5063..ed53ab3ec 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -175,23 +175,28 @@ seta hud_panel_strafehud_angle_arrow_size "0.5" "size of the arrow (relative to seta hud_panel_strafehud_bestangle "1" "set to \"1\" to enable a ghost angle indicator showing the best angle to gain maximum acceleration" seta hud_panel_strafehud_bestangle_color "1 1 1" "color of the indicator showing the best angle to gain maximum acceleration" seta hud_panel_strafehud_bestangle_alpha "0.5" "opacity of the indicator showing the best angle to gain maximum acceleration" +seta hud_panel_strafehud_switch "1" "set to \"1\" to enable the switch indicator showing the angle to move to when switching sides" seta hud_panel_strafehud_switch_minspeed "-1" "minimum speed in qu/s at which switch indicator(s) which are used to aid changing strafe direction will be shown (set to -1 for dynamic minspeed)" seta hud_panel_strafehud_switch_color "1 1 0" "color of the switch indicator" seta hud_panel_strafehud_switch_alpha "1" "opacity of the switch indicator" seta hud_panel_strafehud_switch_width "0.003" "width of the strafe angle indicator(s) (relative to the strafe bar width)" +seta hud_panel_strafehud_direction "0" "set to \"1\" to enable the direction caps to see in which direction you are currently strafing" seta hud_panel_strafehud_direction_color "0 0.5 1" "color of the direction caps which indicate the direction the player is currently strafing towards" -seta hud_panel_strafehud_direction_alpha "0" "opacity of the direction caps which indicate the direction the player is currently strafing towards" +seta hud_panel_strafehud_direction_alpha "1" "opacity of the direction caps which indicate the direction the player is currently strafing towards" seta hud_panel_strafehud_direction_width "0.25" "stroke width of the direction caps which indicate the direction the player is currently strafing towards (relative to the panel height)" seta hud_panel_strafehud_direction_length "0.02" "length of the horizontal component of the direction caps which indicate the direction the player is currently strafing towards (relative to the panel width)" -seta hud_panel_strafehud_slickdetector_range "200" "range of the slick detector in qu, \"0\" to disable" +seta hud_panel_strafehud_slickdetector "1" "set to \"1\" to enable the slick detector which notifies you if there is slick near you" +seta hud_panel_strafehud_slickdetector_range "200" "range of the slick detector in qu" seta hud_panel_strafehud_slickdetector_granularity "1" "value from 0 to 4 which defines how exact the search for slick should be, higher values may yield better results but require more computation" seta hud_panel_strafehud_slickdetector_color "0 1 1" "color of the slick detector indicator" seta hud_panel_strafehud_slickdetector_alpha "0.5" "opacity of the slick detector indicator" seta hud_panel_strafehud_slickdetector_height "0.125" "height of the slick detector indicator (relative to the panel height)" -seta hud_panel_strafehud_startspeed_fade "4" "fade time (in seconds) of the start speed text or \"0\" to disable" +seta hud_panel_strafehud_startspeed "1" "set to \"1\" to enable the start speed indicator which shows you the speed you had while passing the start trigger of a race map" +seta hud_panel_strafehud_startspeed_fade "4" "fade time (in seconds) of the start speed text" seta hud_panel_strafehud_startspeed_color "1 0.75 0" "color of the start speed text" seta hud_panel_strafehud_startspeed_size "1.5" "size of the start speed text (relative to the panel height)" -seta hud_panel_strafehud_jumpheight_fade "0" "fade time (in seconds) of the jump height text or \"0\" to disable" +seta hud_panel_strafehud_jumpheight "0" "set to \"1\" to enable the jump height indicator which tells you how high you jumped" +seta hud_panel_strafehud_jumpheight_fade "4" "fade time (in seconds) of the jump height text" seta hud_panel_strafehud_jumpheight_min "50" "minimum jump height to display in the selected unit" seta hud_panel_strafehud_jumpheight_color "0 1 0.75" "color of the jump height text" seta hud_panel_strafehud_jumpheight_size "1.5" "size of the jump height text (relative to the panel height)" diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc index e12e17a18..620a22ff0 100644 --- a/qcsrc/client/hud/panel/strafehud.qc +++ b/qcsrc/client/hud/panel/strafehud.qc @@ -701,7 +701,7 @@ void HUD_StrafeHUD() // draw neutral zone HUD_Panel_DrawStrafeHUD(neutral_offset, neutral_width, hidden_width, autocvar_hud_panel_strafehud_bar_neutral_color, autocvar_hud_panel_strafehud_bar_neutral_alpha * panel_fg_alpha, autocvar_hud_panel_strafehud_style, STRAFEHUD_GRADIENT_NONE); - if(speed >= minspeed && bestangle_width > 0 && autocvar_hud_panel_strafehud_switch_alpha > 0) // only draw indicators if minspeed is reached + if(autocvar_hud_panel_strafehud_switch && speed >= minspeed && bestangle_width > 0 && autocvar_hud_panel_strafehud_switch_alpha > 0) // only draw indicators if minspeed is reached { // draw the switch indicator(s) float offset = !odd_angles ? bestangle_offset : odd_bestangle_offset; @@ -733,7 +733,7 @@ void HUD_StrafeHUD() if(!autocvar_hud_panel_strafehud_uncapped) slickdetector_height = min(slickdetector_height, 1); slickdetector_height *= panel_size.y; - if(autocvar_hud_panel_strafehud_slickdetector_range > 0 && autocvar_hud_panel_strafehud_slickdetector_alpha > 0 && slickdetector_height > 0 && panel_size.x > 0) + if(autocvar_hud_panel_strafehud_slickdetector && autocvar_hud_panel_strafehud_slickdetector_range > 0 && autocvar_hud_panel_strafehud_slickdetector_alpha > 0 && slickdetector_height > 0 && panel_size.x > 0) { float slicksteps = max(autocvar_hud_panel_strafehud_slickdetector_granularity, 0); bool slickdetected = false; @@ -779,7 +779,7 @@ void HUD_StrafeHUD() } } - if(direction != STRAFEHUD_DIRECTION_NONE && direction_size_vertical.x > 0 && autocvar_hud_panel_strafehud_direction_alpha * panel_fg_alpha > 0) + if(autocvar_hud_panel_strafehud_direction && direction != STRAFEHUD_DIRECTION_NONE && direction_size_vertical.x > 0 && autocvar_hud_panel_strafehud_direction_alpha * panel_fg_alpha > 0) { bool indicator_direction = direction == STRAFEHUD_DIRECTION_LEFT; // invert left/right when strafing backwards or when strafing towards the opposite side indicated by the direction variable @@ -915,13 +915,16 @@ void HUD_StrafeHUD() } } - float startspeed_height = autocvar_hud_panel_strafehud_startspeed_size * panel_size.y; - string startspeed_text = ftos_decimals(startspeed * speed_conversion_factor, 2); - if(autocvar_hud_panel_strafehud_unit_show) - startspeed_text = strcat(startspeed_text, GetSpeedUnit(autocvar_hud_panel_strafehud_unit)); + if(autocvar_hud_panel_strafehud_startspeed) + { + float startspeed_height = autocvar_hud_panel_strafehud_startspeed_size * panel_size.y; + string startspeed_text = ftos_decimals(startspeed * speed_conversion_factor, 2); + if(autocvar_hud_panel_strafehud_unit_show) + startspeed_text = strcat(startspeed_text, GetSpeedUnit(autocvar_hud_panel_strafehud_unit)); - if(StrafeHUD_drawTextIndicator(startspeed_text, startspeed_height, autocvar_hud_panel_strafehud_startspeed_color, autocvar_hud_panel_strafehud_startspeed_fade, starttime, text_offset_bottom, STRAFEHUD_TEXT_BOTTOM)) - text_offset_bottom += startspeed_height; + if(StrafeHUD_drawTextIndicator(startspeed_text, startspeed_height, autocvar_hud_panel_strafehud_startspeed_color, autocvar_hud_panel_strafehud_startspeed_fade, starttime, text_offset_bottom, STRAFEHUD_TEXT_BOTTOM)) + text_offset_bottom += startspeed_height; + } } // show height achieved by a single jump @@ -948,13 +951,16 @@ void HUD_StrafeHUD() } } - float jumpheight_height = autocvar_hud_panel_strafehud_jumpheight_size * panel_size.y; - string jumpheight_text = ftos_decimals(jumpheight * length_conversion_factor, length_decimals); - if(autocvar_hud_panel_strafehud_unit_show) - jumpheight_text = strcat(jumpheight_text, GetLengthUnit(autocvar_hud_panel_strafehud_unit)); + if(autocvar_hud_panel_strafehud_jumpheight) + { + float jumpheight_height = autocvar_hud_panel_strafehud_jumpheight_size * panel_size.y; + string jumpheight_text = ftos_decimals(jumpheight * length_conversion_factor, length_decimals); + if(autocvar_hud_panel_strafehud_unit_show) + jumpheight_text = strcat(jumpheight_text, GetLengthUnit(autocvar_hud_panel_strafehud_unit)); - if(StrafeHUD_drawTextIndicator(jumpheight_text, jumpheight_height, autocvar_hud_panel_strafehud_jumpheight_color, autocvar_hud_panel_strafehud_jumpheight_fade, jumptime, text_offset_top, STRAFEHUD_TEXT_TOP)) - text_offset_top += jumpheight_height; + if(StrafeHUD_drawTextIndicator(jumpheight_text, jumpheight_height, autocvar_hud_panel_strafehud_jumpheight_color, autocvar_hud_panel_strafehud_jumpheight_fade, jumptime, text_offset_top, STRAFEHUD_TEXT_TOP)) + text_offset_top += jumpheight_height; + } } draw_endBoldFont(); diff --git a/qcsrc/client/hud/panel/strafehud.qh b/qcsrc/client/hud/panel/strafehud.qh index 4d466ae9a..2287598e6 100644 --- a/qcsrc/client/hud/panel/strafehud.qh +++ b/qcsrc/client/hud/panel/strafehud.qh @@ -30,23 +30,28 @@ float autocvar_hud_panel_strafehud_angle_arrow_size = 0.5; bool autocvar_hud_panel_strafehud_bestangle = true; vector autocvar_hud_panel_strafehud_bestangle_color = '1 1 1'; float autocvar_hud_panel_strafehud_bestangle_alpha = 0.5; +bool autocvar_hud_panel_strafehud_switch = true; float autocvar_hud_panel_strafehud_switch_minspeed = -1; vector autocvar_hud_panel_strafehud_switch_color = '1 1 0'; float autocvar_hud_panel_strafehud_switch_alpha = 1; float autocvar_hud_panel_strafehud_switch_width = 0.003; +bool autocvar_hud_panel_strafehud_direction = false; vector autocvar_hud_panel_strafehud_direction_color = '0 0.5 1'; -float autocvar_hud_panel_strafehud_direction_alpha = 0; +float autocvar_hud_panel_strafehud_direction_alpha = 1; float autocvar_hud_panel_strafehud_direction_width = 0.25; float autocvar_hud_panel_strafehud_direction_length = 0.02; +bool autocvar_hud_panel_strafehud_slickdetector = true; float autocvar_hud_panel_strafehud_slickdetector_range = 200; int autocvar_hud_panel_strafehud_slickdetector_granularity = 1; vector autocvar_hud_panel_strafehud_slickdetector_color = '0 1 1'; float autocvar_hud_panel_strafehud_slickdetector_alpha = 0.5; float autocvar_hud_panel_strafehud_slickdetector_height = 0.125; +bool autocvar_hud_panel_strafehud_startspeed = true; float autocvar_hud_panel_strafehud_startspeed_fade = 4; vector autocvar_hud_panel_strafehud_startspeed_color = '1 0.75 0'; float autocvar_hud_panel_strafehud_startspeed_size = 1.5; -float autocvar_hud_panel_strafehud_jumpheight_fade = 0; +bool autocvar_hud_panel_strafehud_jumpheight = false; +float autocvar_hud_panel_strafehud_jumpheight_fade = 4; float autocvar_hud_panel_strafehud_jumpheight_min = 50; vector autocvar_hud_panel_strafehud_jumpheight_color = '0 1 0.75'; float autocvar_hud_panel_strafehud_jumpheight_size = 1.5; diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_strafehud.qc b/qcsrc/menu/xonotic/dialog_hudpanel_strafehud.qc index cf4c0065f..c94bef763 100644 --- a/qcsrc/menu/xonotic/dialog_hudpanel_strafehud.qc +++ b/qcsrc/menu/xonotic/dialog_hudpanel_strafehud.qc @@ -24,7 +24,7 @@ void StrafeHUD_ColorReset(entity btn, entity me) cvar_set("hud_panel_strafehud_angle_neutral_color", cvar_defstring("hud_panel_strafehud_angle_neutral_color")); cvar_set("hud_panel_strafehud_angle_overturn_color", cvar_defstring("hud_panel_strafehud_angle_overturn_color")); cvar_set("hud_panel_strafehud_switch_color", cvar_defstring("hud_panel_strafehud_switch_color")); - cvar_set("hud_panel_strafehud_direction_color", cvar_defstring("hud_panel_strafehud_direction_color")); + cvar_set("hud_panel_strafehud_bestangle_color", cvar_defstring("hud_panel_strafehud_bestangle_color")); } void XonoticHUDStrafeHUDDialog_fill(entity me) @@ -120,22 +120,26 @@ void XonoticHUDStrafeHUDDialog_fill(entity me) me.TD(me, 1, 1.9, e = makeXonoticSlider(0, 1, 0.1, "hud_panel_strafehud_angle_alpha")); me.TR(me); - me.TD(me, 1, 1.9, e = makeXonoticTextLabel(0, _("Switch indicators:"))); + me.TD(me, 1, 1.9, e = makeXonoticTextLabel(0, _("Switch indicator:"))); me.TDempty(me, 0.2); - me.TD(me, 1, 1.9, e = makeXonoticTextLabel(0, _("Direction caps:"))); + me.TD(me, 1, 1.9, e = makeXonoticTextLabel(0, _("Best angle indicator:"))); me.TR(me); me.TD(me, 2, 1.9, e = makeXonoticColorpickerString("hud_panel_strafehud_switch_color", "hud_panel_strafehud_switch_color")); me.TDempty(me, 0.2); - me.TD(me, 2, 1.9, e = makeXonoticColorpickerString("hud_panel_strafehud_direction_color", "hud_panel_strafehud_direction_color")); + me.TD(me, 2, 1.9, e = makeXonoticColorpickerString("hud_panel_strafehud_bestangle_color", "hud_panel_strafehud_bestangle_color")); me.TR(me); me.TR(me); - me.TD(me, 1, 1.9, e = makeXonoticSlider(0, 1, 0.1, "hud_panel_strafehud_switch_alpha")); + me.TD(me, 1, 0.9, e = makeXonoticSlider(0, 1, 0.1, "hud_panel_strafehud_switch_alpha")); + me.TDempty(me, 0.1); + me.TD(me, 1, 0.9, e = makeXonoticCheckBoxString("1", "0", "hud_panel_strafehud_switch", _("Enable"))); me.TDempty(me, 0.2); - me.TD(me, 1, 1.9, e = makeXonoticSlider(0, 1, 0.1, "hud_panel_strafehud_direction_alpha")); + me.TD(me, 1, 0.9, e = makeXonoticSlider(0, 1, 0.1, "hud_panel_strafehud_bestangle_alpha")); + me.TDempty(me, 0.1); + me.TD(me, 1, 0.9, e = makeXonoticCheckBoxString("1", "0", "hud_panel_strafehud_bestangle", _("Enable"))); } -- 2.39.2