From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Tue, 2 Jun 2020 21:10:33 +0000 (+0200) Subject: improve cvar handling and change strafehud mode default value X-Git-Tag: xonotic-v0.8.5~738^2~68 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=721c882025da9603e1e23dab0b93836e0c37a215;p=xonotic%2Fxonotic-data.pk3dir.git improve cvar handling and change strafehud mode default value --- diff --git a/_hud_common.cfg b/_hud_common.cfg index 23102476e..4950d8162 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -122,23 +122,23 @@ seta hud_panel_scoreboard_accuracy_showdelay 2 "how long to delay displaying acc seta hud_panel_scoreboard_accuracy_showdelay_minpos 0.75 "delay displaying the accuracy panel only if its position is lower than this percentage of the screen height from the top" 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_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: \"0\" = movement centered, \"1\" = angle centered" +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" seta hud_panel_strafehud_indicator_color "0 1 0" "color of the strafe angle indicator" seta hud_panel_strafehud_indicator_switch_color "1 1 0" "color of the strafe angle indicator on the opposite side" -seta hud_panel_strafehud_angle "0" "the maximum angle displayed on the HUD, \"0\" = dynamic" +seta hud_panel_strafehud_angle "0" "the maximum angle displayed on the strafehud, \"0\" = dynamic" seta hud_panel_strafehud_good_color "0 1 1" "indicator color of the actual strafe angle if the angle matches the ideal angle" seta hud_panel_strafehud_warning_color "1 1 0" "indicator color of the actual strafe angle if the angle doesn't match the ideal angle" seta hud_panel_strafehud_alert_color "1 0 1" "indicator color of the actual strafe angle if the angle has a critical value" seta hud_panel_strafehud_angle_alpha "0.8" "indicator transparency of the actual strafe angle" seta hud_panel_strafehud_direction_color "0 0.5 1" "direction indicator color" -seta hud_panel_strafehud_timeout_air "0" "time after take off before changing HUD mode (prevents flickering on slick ramps)" -seta hud_panel_strafehud_timeout_ground "0.03333333" "time after landing before changing HUD mode (prevents flickering on regular strafe turns)" +seta hud_panel_strafehud_timeout_air "0" "time after take off before changing strafehud mode (prevents flickering on slick ramps)" +seta hud_panel_strafehud_timeout_ground "0.03333333" "time after landing before changing strafehud mode (prevents flickering on regular strafe turns)" seta hud_panel_strafehud_timeout_strafe "0.1" "time after releasing the strafe keys before changing mode (prevents flickering when switching between left/right strafe turning)" -seta hud_panel_strafehud_indicator_minspeed "-1" "speed at which HUD indicators will be shown, uses maxspeed if negative" +seta hud_panel_strafehud_indicator_minspeed "-1" "speed at which strafehud indicators will be shown, uses maxspeed if negative" // hud panel aliases alias quickmenu "cl_cmd hud quickmenu ${* ?}" diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index 6e19ab5fc..e7fa12531 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -320,24 +320,24 @@ float autocvar_hud_panel_radar_maximized_rotation; int autocvar_hud_panel_radar_maximized_zoommode; bool autocvar_hud_panel_score; bool autocvar_hud_panel_score_rankings; -bool autocvar_hud_panel_strafehud; -bool autocvar__hud_panel_strafehud_demo; -bool autocvar__hud_panel_strafehud_center; -bool 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; -vector autocvar_hud_panel_strafehud_indicator_switch_color; -float autocvar_hud_panel_strafehud_angle; -vector autocvar_hud_panel_strafehud_good_color; -vector autocvar_hud_panel_strafehud_warning_color; -vector autocvar_hud_panel_strafehud_alert_color; -float autocvar_hud_panel_strafehud_angle_alpha; -vector autocvar_hud_panel_strafehud_direction_color; -float autocvar_hud_panel_strafehud_timeout_air; -float autocvar_hud_panel_strafehud_timeout_ground; -float autocvar_hud_panel_strafehud_timeout_strafe; -float autocvar_hud_panel_strafehud_indicator_minspeed; +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'; +vector autocvar_hud_panel_strafehud_indicator_color = '0 1 0'; +vector autocvar_hud_panel_strafehud_indicator_switch_color = '1 1 0'; +float autocvar_hud_panel_strafehud_angle = 0; +vector autocvar_hud_panel_strafehud_good_color = '0 1 1'; +vector autocvar_hud_panel_strafehud_warning_color = '1 1 0'; +vector autocvar_hud_panel_strafehud_alert_color = '1 0 1'; +float autocvar_hud_panel_strafehud_angle_alpha = 0.8; +vector autocvar_hud_panel_strafehud_direction_color = '0 0.5 1'; +float autocvar_hud_panel_strafehud_timeout_air = 0; +float autocvar_hud_panel_strafehud_timeout_ground = 0.03333333; +float autocvar_hud_panel_strafehud_timeout_strafe = 0.1; +float autocvar_hud_panel_strafehud_indicator_minspeed = -1; bool autocvar_hud_panel_timer; bool autocvar_hud_panel_timer_increment; float autocvar_hud_panel_update_interval; diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc index 73f158d69..12f168e1b 100644 --- a/qcsrc/client/hud/panel/strafehud.qc +++ b/qcsrc/client/hud/panel/strafehud.qc @@ -23,6 +23,17 @@ bool strafehud_state_strafekeys = false; bool strafehud_turn = false; float strafehud_turnangle; +// provide basic panel cvars to old clients +// TODO remove them after a future release (0.8.2+) +noref string autocvar_hud_panel_scoreboard_pos = "0.320000 0.570000"; +noref string autocvar_hud_panel_scoreboard_size = "0.360000 0.020000"; +noref string autocvar_hud_panel_scoreboard_bg = "0"; +noref string autocvar_hud_panel_scoreboard_bg_color = ""; +noref string autocvar_hud_panel_scoreboard_bg_color_team = ""; +noref string autocvar_hud_panel_scoreboard_bg_alpha = "0.7"; +noref string autocvar_hud_panel_scoreboard_bg_border = ""; +noref string autocvar_hud_panel_scoreboard_bg_padding = ""; + void HUD_StrafeHUD() { entity strafeplayer; @@ -89,6 +100,7 @@ void HUD_StrafeHUD() float strafehud_moveangle; // HUD + int strafehud_mode = autocvar_hud_panel_strafehud_mode >= 0 && autocvar_hud_panel_strafehud_mode <= 1 ? autocvar_hud_panel_strafehud_mode : 0; float strafehud_hudangle; float strafehud_bar_offset; vector strafehud_bar_size = panel_size; @@ -350,13 +362,13 @@ void HUD_StrafeHUD() // current angle strafehud_currentangle_size.x = panel_size.x * .005; if(strafehud_currentangle_size.x < 1) strafehud_currentangle_size.x = 1; - if(!autocvar_hud_panel_strafehud_mode) + if(strafehud_mode == 0) { - strafehud_currentangle_offset = bound(-strafehud_hudangle, strafehud_angle, strafehud_hudangle)/strafehud_hudangle * panel_size.x/2 + panel_size.x/2; + strafehud_currentangle_offset = strafehud_angle/strafehud_hudangle * panel_size.x/2; } - else + else if(strafehud_mode == 1) { - strafehud_currentangle_offset = strafehud_angle/strafehud_hudangle * panel_size.x/2; + strafehud_currentangle_offset = bound(-strafehud_hudangle, strafehud_angle, strafehud_hudangle)/strafehud_hudangle * panel_size.x/2 + panel_size.x/2; } strafehud_currentangle_size.y = panel_size.y * 1.5; // best strafe acceleration angle @@ -366,13 +378,13 @@ void HUD_StrafeHUD() if(strafehud_bestangle_size.x < 1) strafehud_bestangle_size.x = 1; strafehud_mirror_bestangle_size = strafehud_bestangle_size; // shift offset of best strafe angle in angle centered mode - if(autocvar_hud_panel_strafehud_mode) + if(strafehud_mode == 0) { strafehud_bestangle_offset -= strafehud_currentangle_offset; strafehud_mirror_bestangle_offset -= strafehud_currentangle_offset; } // remove indicator width from offset - if( strafehud_direction < 0) + if(strafehud_direction < 0) { strafehud_bestangle_offset -= strafehud_bestangle_size.x; } @@ -470,7 +482,7 @@ void HUD_StrafeHUD() 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; - if(autocvar_hud_panel_strafehud_mode) + if(strafehud_mode == 0) { // acceleration zone shifts in angle centered strafehud_accelzone_size.x += strafehud_currentangle_offset; // make sure the size is correct even when the offset is shifted @@ -503,7 +515,7 @@ void HUD_StrafeHUD() 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(autocvar_hud_panel_strafehud_mode == 1) + if(strafehud_mode == 0) { // acceleration zone shifts if angle centered strafehud_accelzone_size.x -= strafehud_currentangle_offset; // make sure the size is correct even when the offset is shifted @@ -660,13 +672,13 @@ void HUD_StrafeHUD() strafehud_currentangle_color = strafehud_good_color; } - if(!autocvar_hud_panel_strafehud_mode) + if(strafehud_mode == 0) { - drawfill(panel_pos - eY * ((strafehud_currentangle_size.y - panel_size.y) / 2) + 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); + drawfill(panel_pos - eY * ((strafehud_currentangle_size.y - panel_size.y) / 2) + eX * (panel_size.x/2 - strafehud_currentangle_size.x/2), strafehud_currentangle_size, strafehud_currentangle_color, autocvar_hud_panel_strafehud_angle_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); } - else + else if(strafehud_mode == 1) { - drawfill(panel_pos - eY * ((strafehud_currentangle_size.y - panel_size.y) / 2) + eX * (panel_size.x/2 - strafehud_currentangle_size.x/2), strafehud_currentangle_size, strafehud_currentangle_color, autocvar_hud_panel_strafehud_angle_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + drawfill(panel_pos - eY * ((strafehud_currentangle_size.y - panel_size.y) / 2) + 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 c8c18fbfd..48748dcdb 100644 --- a/qcsrc/menu/xonotic/dialog_hudpanel_strafehud.qc +++ b/qcsrc/menu/xonotic/dialog_hudpanel_strafehud.qc @@ -37,8 +37,8 @@ void XonoticHUDStrafeHUDDialog_fill(entity 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.addValue(e, _("View angle centered"), "0"); + e.addValue(e, _("Velocity direction centered"), "1"); e.configureXonoticTextSliderValues(e); me.TR(me); me.TD(me, 1, 1.2, e = makeXonoticCheckBoxString("1", "0", "_hud_panel_strafehud_demo", _("Demo mode")));