From 7c923b36217ab32ab0b3196c93d49dfadb22f328 Mon Sep 17 00:00:00 2001 From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Tue, 5 May 2020 00:53:26 +0200 Subject: [PATCH] removed mode option, won't implement that for a while if ever --- _hud_common.cfg | 1 - qcsrc/client/autocvars.qh | 1 - qcsrc/client/hud/panel/strafehud.qc | 168 +++++++++--------- .../menu/xonotic/dialog_hudpanel_strafehud.qc | 8 - 4 files changed, 80 insertions(+), 98 deletions(-) diff --git a/_hud_common.cfg b/_hud_common.cfg index f9ef96917..a3273761b 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -123,7 +123,6 @@ seta hud_panel_scoreboard_accuracy_showdelay_minpos 0.75 "delay displaying the a seta hud_panel_scoreboard_team_size_position 0 "where to show the team size (0 = do not show, 1 = left of scoreboard, 2 = right of scoreboard), will move team scores to the other side if necessary" seta _hud_panel_strafehud_demo "0" "HUD changes angle during configure" -seta hud_panel_strafehud_mode "0" "strafehud mode: \"0\" = movement centered, \"1\" = angle centered" seta hud_panel_strafehud_bar_alpha ".2" "opacity of the strafe meter" seta hud_panel_strafehud_bar_color "1 1 1" "color of the strafe meter" seta hud_panel_strafehud_indicator_color "0 1 0" "color of the strafe angle indicator" diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index 71136a1d4..706cd3305 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -322,7 +322,6 @@ bool autocvar_hud_panel_score; bool autocvar_hud_panel_score_rankings; bool autocvar_hud_panel_strafehud; bool autocvar__hud_panel_strafehud_demo; -int autocvar_hud_panel_strafehud_mode; float autocvar_hud_panel_strafehud_bar_alpha; vector autocvar_hud_panel_strafehud_bar_color; vector autocvar_hud_panel_strafehud_indicator_color; diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc index aa1fc81b8..c8557052f 100644 --- a/qcsrc/client/hud/panel/strafehud.qc +++ b/qcsrc/client/hud/panel/strafehud.qc @@ -359,116 +359,108 @@ void HUD_StrafeHUD() strafehud_overturn_size.x = floor((panel_size.x * (strafehud_hudangle - strafehud_maxangle) / strafehud_hudangle) / 2 + .5); strafehud_mirror_overturn_size.x = floor(panel_size.x * strafehud_mirrorangle / (strafehud_hudangle * 2) + .5); - switch(autocvar_hud_panel_strafehud_mode) + // mark the ideal strafe angle + if(strafehud_speed >= strafehud_indicator_minspeed) // draw indicators if strafing is required to gain speed { - default: - case 0: // view centered - // mark the ideal strafe angle - if(strafehud_speed >= strafehud_indicator_minspeed) // draw indicators if strafing is required to gain speed + if (fabs(strafehud_bestangle) <= strafehud_hudangle) // don't draw angle indicator and acceleration zones if outside of hud range { - if (fabs(strafehud_bestangle) <= strafehud_hudangle) // don't draw angle indicator and acceleration zones if outside of hud range + if (strafehud_direction != 0) // only draw acceleration zones if strafe direction can be determined { - if (strafehud_direction != 0) // only draw acceleration zones if strafe direction can be determined + // calculate zone in which strafe acceleration happens + if(strafehud_direction < 0) // moving left + { + strafehud_accelzone_offset = 0; + strafehud_accelzone_size.x = strafehud_bestangle_offset; + } + else // moving right + { + strafehud_accelzone_offset = strafehud_bestangle_offset + strafehud_bestangle_size.x; + strafehud_accelzone_size.x = panel_size.x - strafehud_accelzone_offset; + } + + if(strafehud_hudangle > strafehud_maxangle) // draw overturn area and move acceleration zone { - // calculate zone in which strafe acceleration happens if(strafehud_direction < 0) // moving left { - strafehud_accelzone_offset = 0; - strafehud_accelzone_size.x = strafehud_bestangle_offset; + // calculate offset of overturn area + strafehud_overturn_offset = 0; + // move/adjust acceleration zone + strafehud_accelzone_offset += strafehud_overturn_size.x; + strafehud_accelzone_size.x -= strafehud_overturn_size.x; + // calculate the remainder of the overturn zone on the opposite side + strafehud_mirror_overturn_offset = panel_size.x - strafehud_mirror_overturn_size.x; } else // moving right { - strafehud_accelzone_offset = strafehud_bestangle_offset + strafehud_bestangle_size.x; - strafehud_accelzone_size.x = panel_size.x - strafehud_accelzone_offset; + // calculate offset of overturn area + strafehud_overturn_offset = panel_size.x - strafehud_overturn_size.x; + // adjust acceleration zone + strafehud_accelzone_size.x -= strafehud_overturn_size.x; + // calculate the remainder of the overturn zone on the opposite side + strafehud_mirror_overturn_offset = 0; } - - if(strafehud_hudangle > strafehud_maxangle) // draw overturn area and move acceleration zone + // draw overturn area + if(strafehud_overturn_size.x != 0 && strafehud_overturn_size.y != 0) { - if(strafehud_direction < 0) // moving left - { - // calculate offset of overturn area - strafehud_overturn_offset = 0; - // move/adjust acceleration zone - strafehud_accelzone_offset += strafehud_overturn_size.x; - strafehud_accelzone_size.x -= strafehud_overturn_size.x; - // calculate the remainder of the overturn zone on the opposite side - strafehud_mirror_overturn_offset = panel_size.x - strafehud_mirror_overturn_size.x; - } - else // moving right - { - // calculate offset of overturn area - strafehud_overturn_offset = panel_size.x - strafehud_overturn_size.x; - // adjust acceleration zone - strafehud_accelzone_size.x -= strafehud_overturn_size.x; - // calculate the remainder of the overturn zone on the opposite side - strafehud_mirror_overturn_offset = 0; - } - // draw overturn area - if(strafehud_overturn_size.x != 0 && strafehud_overturn_size.y != 0) - { - HUD_Panel_DrawProgressBar(panel_pos + eX * strafehud_overturn_offset, strafehud_overturn_size, "progressbar", 1, 0, 0, strafehud_alert_color, strafehud_bar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); - } - // draw remaining overturn area on the opposite side if there is any (180 degree in total) - if(strafehud_mirrorangle > 0 && strafehud_mirror_overturn_size.x != 0 && strafehud_mirror_overturn_size.y != 0) - { - HUD_Panel_DrawProgressBar(panel_pos + eX * strafehud_mirror_overturn_offset, strafehud_mirror_overturn_size, "progressbar", 1, 0, 0, strafehud_alert_color, strafehud_bar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); - } + HUD_Panel_DrawProgressBar(panel_pos + eX * strafehud_overturn_offset, strafehud_overturn_size, "progressbar", 1, 0, 0, strafehud_alert_color, strafehud_bar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); } - - // draw acceleration zone - if(strafehud_accelzone_size.x != 0 && strafehud_accelzone_size.y != 0) + // draw remaining overturn area on the opposite side if there is any (180 degree in total) + if(strafehud_mirrorangle > 0 && strafehud_mirror_overturn_size.x != 0 && strafehud_mirror_overturn_size.y != 0) { - HUD_Panel_DrawProgressBar(panel_pos + eX * strafehud_accelzone_offset, strafehud_accelzone_size, "progressbar", 1, 0, 0, strafehud_bestangle_color, strafehud_bar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + HUD_Panel_DrawProgressBar(panel_pos + eX * strafehud_mirror_overturn_offset, strafehud_mirror_overturn_size, "progressbar", 1, 0, 0, strafehud_alert_color, strafehud_bar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); } - - // draw the direction indicator caps at the sides of the hud - // vertical line - drawfill(panel_pos + eX * (strafehud_direction < 0 ? -strafehud_direction_size_vertical.x : panel_size.x), strafehud_direction_size_vertical, strafehud_direction_color, panel_fg_alpha, DRAWFLAG_NORMAL); - // top horizontal line - drawfill(panel_pos + eX * (strafehud_direction < 0 ? -strafehud_direction_size_vertical.x : panel_size.x - strafehud_direction_size_horizontal.x + strafehud_direction_size_vertical.x) - eY * strafehud_direction_size_horizontal.y, strafehud_direction_size_horizontal, strafehud_direction_color, panel_fg_alpha, DRAWFLAG_NORMAL); - // bottom horizontal line - drawfill(panel_pos + eX * (strafehud_direction < 0 ? -strafehud_direction_size_vertical.x : panel_size.x - strafehud_direction_size_horizontal.x + strafehud_direction_size_vertical.x) + eY * panel_size.y, strafehud_direction_size_horizontal, strafehud_direction_color, panel_fg_alpha, DRAWFLAG_NORMAL); - - // draw opposite best strafe angle - drawfill(panel_pos + eX * (strafehud_bestangle_opposite_offset - (-strafehud_direction < 0 ? strafehud_bestangle_size.x : 0)), strafehud_bestangle_size, strafehud_bestangle_opposite_color, panel_fg_alpha, DRAWFLAG_NORMAL); - // draw current best strafe angle - drawfill(panel_pos + eX * (strafehud_bestangle_offset - (strafehud_direction < 0 ? strafehud_bestangle_size.x : 0)), strafehud_bestangle_size, strafehud_bestangle_color, panel_fg_alpha, DRAWFLAG_NORMAL); } - else + + // draw acceleration zone + if(strafehud_accelzone_size.x != 0 && strafehud_accelzone_size.y != 0) { - // draw best angles for acceleration - drawfill(panel_pos + eX * (strafehud_bestangle_opposite_offset - strafehud_bestangle_size.x), strafehud_bestangle_size, strafehud_bestangle_opposite_color, panel_fg_alpha, DRAWFLAG_NORMAL); - drawfill(panel_pos + eX * (strafehud_bestangle_offset), strafehud_bestangle_size, strafehud_bestangle_opposite_color, panel_fg_alpha, DRAWFLAG_NORMAL); + HUD_Panel_DrawProgressBar(panel_pos + eX * strafehud_accelzone_offset, strafehud_accelzone_size, "progressbar", 1, 0, 0, strafehud_bestangle_color, strafehud_bar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); } - } - } - else - { - strafehud_bestangle_anywhere = true; // no indicators, moving forward should suffice to gain speed - } - // draw the actual strafe angle - if (!strafehud_bestangle_anywhere) // player gains speed with strafing - { - if ((strafehud_direction > 0 && strafehud_angle >= strafehud_bestangle) || - (strafehud_direction < 0 && strafehud_angle <= strafehud_bestangle)) - strafehud_currentangle_color = strafehud_good_color; + // draw the direction indicator caps at the sides of the hud + // vertical line + drawfill(panel_pos + eX * (strafehud_direction < 0 ? -strafehud_direction_size_vertical.x : panel_size.x), strafehud_direction_size_vertical, strafehud_direction_color, panel_fg_alpha, DRAWFLAG_NORMAL); + // top horizontal line + drawfill(panel_pos + eX * (strafehud_direction < 0 ? -strafehud_direction_size_vertical.x : panel_size.x - strafehud_direction_size_horizontal.x + strafehud_direction_size_vertical.x) - eY * strafehud_direction_size_horizontal.y, strafehud_direction_size_horizontal, strafehud_direction_color, panel_fg_alpha, DRAWFLAG_NORMAL); + // bottom horizontal line + drawfill(panel_pos + eX * (strafehud_direction < 0 ? -strafehud_direction_size_vertical.x : panel_size.x - strafehud_direction_size_horizontal.x + strafehud_direction_size_vertical.x) + eY * panel_size.y, strafehud_direction_size_horizontal, strafehud_direction_color, panel_fg_alpha, DRAWFLAG_NORMAL); + + // draw opposite best strafe angle + drawfill(panel_pos + eX * (strafehud_bestangle_opposite_offset - (-strafehud_direction < 0 ? strafehud_bestangle_size.x : 0)), strafehud_bestangle_size, strafehud_bestangle_opposite_color, panel_fg_alpha, DRAWFLAG_NORMAL); + // draw current best strafe angle + drawfill(panel_pos + eX * (strafehud_bestangle_offset - (strafehud_direction < 0 ? strafehud_bestangle_size.x : 0)), strafehud_bestangle_size, strafehud_bestangle_color, panel_fg_alpha, DRAWFLAG_NORMAL); + } + else + { + // draw best angles for acceleration + drawfill(panel_pos + eX * (strafehud_bestangle_opposite_offset - strafehud_bestangle_size.x), strafehud_bestangle_size, strafehud_bestangle_opposite_color, panel_fg_alpha, DRAWFLAG_NORMAL); + drawfill(panel_pos + eX * (strafehud_bestangle_offset), strafehud_bestangle_size, strafehud_bestangle_opposite_color, panel_fg_alpha, DRAWFLAG_NORMAL); + } } + } + else + { + strafehud_bestangle_anywhere = true; // no indicators, moving forward should suffice to gain speed + } - if (fabs(strafehud_moveangle) > 89.9) // player is overturning - { - strafehud_currentangle_color = strafehud_alert_color; - } + // draw the actual strafe angle + if (!strafehud_bestangle_anywhere) // player gains speed with strafing + { + if ((strafehud_direction > 0 && strafehud_angle >= strafehud_bestangle) || + (strafehud_direction < 0 && strafehud_angle <= strafehud_bestangle)) + strafehud_currentangle_color = strafehud_good_color; + } - if (strafehud_speed <= (strafehud_maxspeed + .1) && strafehud_currentangle_color != strafehud_alert_color) // player gains speed without strafing - { - strafehud_currentangle_color = strafehud_good_color; - } + if (fabs(strafehud_moveangle) > 89.9) // player is overturning + { + strafehud_currentangle_color = strafehud_alert_color; + } - drawfill(panel_pos - '0 1 0'*floor(panel_size.y * .25 + .5) + eX * (strafehud_currentangle_offset - strafehud_currentangle_size.x/2), strafehud_currentangle_size, strafehud_currentangle_color, autocvar_hud_panel_strafehud_angle_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); - break; - case 1: // angle centered - // TODO: implement angle centered strafehud + if (strafehud_speed <= (strafehud_maxspeed + .1) && strafehud_currentangle_color != strafehud_alert_color) // player gains speed without strafing + { + strafehud_currentangle_color = strafehud_good_color; } + + drawfill(panel_pos - '0 1 0'*floor(panel_size.y * .25 + .5) + eX * (strafehud_currentangle_offset - strafehud_currentangle_size.x/2), strafehud_currentangle_size, strafehud_currentangle_color, autocvar_hud_panel_strafehud_angle_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); } } diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_strafehud.qc b/qcsrc/menu/xonotic/dialog_hudpanel_strafehud.qc index 717d8908d..3c8ec9ab4 100644 --- a/qcsrc/menu/xonotic/dialog_hudpanel_strafehud.qc +++ b/qcsrc/menu/xonotic/dialog_hudpanel_strafehud.qc @@ -33,14 +33,6 @@ void XonoticHUDStrafeHUDDialog_fill(entity me) dialog_hudpanel_main_settings(me, panelname); - me.TR(me); - me.TD(me, 1, 1.4, e = makeXonoticTextLabel(0, _("StrafeHUD mode:"))); - - me.TD(me, 1, 2.6, e = makeXonoticTextSlider("hud_panel_strafehud_mode")); - e.addValue(e, _("View centered"), "0"); - e.addValue(e, _("Angle centered"), "1"); - e.configureXonoticTextSliderValues(e); - setDependentStringNotEqual(e, "hud_panel_strafehud_mode", "0"); // until multiple modes are actually supported me.TR(me); me.TD(me, 1, 1.2, e = makeXonoticCheckBoxString("1", "0", "_hud_panel_strafehud_demo", _("Demo mode"))); me.TDempty(me, 0.4); -- 2.39.2