From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Tue, 23 Jun 2020 01:56:02 +0000 (+0200) Subject: strafehud: reworked panel center feature X-Git-Tag: xonotic-v0.8.5~738^2~43 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=baa2752e50dc133d2a54bd6ba01c66f210acbdb0;p=xonotic%2Fxonotic-data.pk3dir.git strafehud: reworked panel center feature --- diff --git a/_hud_common.cfg b/_hud_common.cfg index 201f19b5d..91d2d3030 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -125,7 +125,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" "strafehud changes angle during configure" -seta _hud_panel_strafehud_center "0" "puts the angle indicator in the center during HUD configure" seta hud_panel_strafehud_mode "0" "strafehud mode which controls whether the strafehud is centered at: \"0\" = view angle, \"1\" = velocity direction" seta hud_panel_strafehud_bar_alpha "0.3" "opacity of the strafe meter" seta hud_panel_strafehud_bar_color "1 1 1" "color of the strafe meter" diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index 4ed427baa..a8d46ff54 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -323,7 +323,6 @@ bool autocvar_hud_panel_score; bool autocvar_hud_panel_score_rankings; int autocvar_hud_panel_strafehud = 3; bool autocvar__hud_panel_strafehud_demo = false; -bool autocvar__hud_panel_strafehud_center = false; int autocvar_hud_panel_strafehud_mode = 0; float autocvar_hud_panel_strafehud_bar_alpha = 0.3; vector autocvar_hud_panel_strafehud_bar_color = '1 1 1'; diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc index 7cdae87b8..e00c18473 100644 --- a/qcsrc/client/hud/panel/strafehud.qc +++ b/qcsrc/client/hud/panel/strafehud.qc @@ -375,26 +375,17 @@ void HUD_StrafeHUD() } else // simulate turning for HUD setup { - if(autocvar__hud_panel_strafehud_center) + if(autocvar__hud_panel_strafehud_demo && ((time - demo_time) >= .025)) { - angle = demo_angle = 0; - demo_time = 0; - wishangle = 0; - } - else - { - if(autocvar__hud_panel_strafehud_demo && ((time - demo_time) >= .025)) + demo_time = time; + demo_angle += demo_direction; + if(fabs(demo_angle) >= 55) { - demo_time = time; - demo_angle += demo_direction; - if(fabs(demo_angle) >= 55) - { - demo_direction = -demo_direction; - } + demo_direction = -demo_direction; } - angle = demo_angle; - wishangle = 45 * (demo_angle > 0 ? 1 : -1); } + angle = demo_angle; + wishangle = 45 * (demo_angle > 0 ? 1 : -1); } // invert the wish angle when strafing backwards diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_strafehud.qc b/qcsrc/menu/xonotic/dialog_hudpanel_strafehud.qc index 48748dcdb..ad3b4cbe4 100644 --- a/qcsrc/menu/xonotic/dialog_hudpanel_strafehud.qc +++ b/qcsrc/menu/xonotic/dialog_hudpanel_strafehud.qc @@ -7,6 +7,14 @@ #include "textlabel.qh" #include "textslider.qh" +void StrafeHUD_CenterPanel(entity btn, entity me) +{ + vector size = stov(str_cvar("hud_panel_strafehud_size")); + vector pos = stov(str_cvar("hud_panel_strafehud_pos")); + pos.x = 0.5 - size.x / 2; + cvar_set("hud_panel_strafehud_pos", strcat(ftos(pos.x), " ", ftos(pos.y))); +} + void StrafeHUD_ColorReset(entity btn, entity me) { cvar_set("hud_panel_strafehud_bar_color", cvar_defstring("hud_panel_strafehud_bar_color")); @@ -42,16 +50,17 @@ void XonoticHUDStrafeHUDDialog_fill(entity me) e.configureXonoticTextSliderValues(e); me.TR(me); me.TD(me, 1, 1.2, e = makeXonoticCheckBoxString("1", "0", "_hud_panel_strafehud_demo", _("Demo mode"))); - setDependentStringNotEqual(e, "_hud_panel_strafehud_center", "1"); me.TDempty(me, 0.4); me.TD(me, 1, 0.6, e = makeXonoticTextLabel(0, _("Range:"))); me.TD(me, 1, 1.8, e = makeXonoticSlider(0, 360, 5, "hud_panel_strafehud_angle")); me.TR(me); - me.TD(me, 1, 1.2, e = makeXonoticCheckBoxString("1", "0", "_hud_panel_strafehud_center", _("Center angle"))); + me.TD(me, 1, 1.9, e = makeXonoticButton(_("Center StrafeHUD"), '0 0 0')); + e.onClick = StrafeHUD_CenterPanel; + e.onClickEntity = me; - me.TDempty(me, 0.4); - me.TD(me, 1, 2.4, e = makeXonoticButton(_("Reset colors"), '0 0 0')); + me.TDempty(me, 0.2); + me.TD(me, 1, 1.9, e = makeXonoticButton(_("Reset colors"), '0 0 0')); e.onClick = StrafeHUD_ColorReset; e.onClickEntity = me; me.TR(me);