]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'Juhu/strafehud' into 'master'
authorMario <mario.mario@y7mail.com>
Wed, 14 Oct 2020 17:58:56 +0000 (17:58 +0000)
committerMario <mario.mario@y7mail.com>
Wed, 14 Oct 2020 17:58:56 +0000 (17:58 +0000)
StrafeHUD for Xonotic

See merge request xonotic/xonotic-data.pk3dir!802

22 files changed:
_hud_common.cfg
_hud_descriptions.cfg
hud_luma.cfg
hud_luminos.cfg
hud_luminos_minimal.cfg
hud_luminos_minimal_xhair.cfg
hud_luminos_old.cfg
hud_nexuiz.cfg
qcsrc/client/autocvars.qh
qcsrc/client/hud/hud.qh
qcsrc/client/hud/panel/_mod.inc
qcsrc/client/hud/panel/_mod.qh
qcsrc/client/hud/panel/strafehud.qc [new file with mode: 0644]
qcsrc/client/hud/panel/strafehud.qh [new file with mode: 0644]
qcsrc/client/mutators/events.qh
qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc
qcsrc/common/gamemodes/gamemode/race/cl_race.qc
qcsrc/menu/xonotic/_mod.inc
qcsrc/menu/xonotic/_mod.qh
qcsrc/menu/xonotic/dialog_hudpanel_strafehud.qc [new file with mode: 0644]
qcsrc/menu/xonotic/dialog_hudpanel_strafehud.qh [new file with mode: 0644]
qcsrc/menu/xonotic/mainwindow.qc

index 73ab1739b004be2b052820e49ad6a96e4226a980..f2be854d5b1d9603ad9ae1ca5e66ca4d2d66662b 100644 (file)
@@ -47,6 +47,7 @@ seta hud_panel_itemstime        2 "enable this panel, 1 = show when spectating,
 //seta hud_panel_scoreboard       1 "enable this panel"
 seta hud_panel_scoreboard_accuracy 1 "show weapon accuracy stats panel on scoreboard; colors can be configured with accuracy_color* cvars"
 seta hud_panel_scoreboard_ctf_leaderboard 1 "show a capture time rankings leaderboard in the scoreboard if allowed by the server"
+seta hud_panel_strafehud        3 "enable this panel, 1 = show if not observing, 2 = show always, 3 = show only in race/cts if not observing"
 
 seta hud_panel_weapons_dynamichud          1 "apply the dynamic hud effects to this panel"
 seta hud_panel_ammo_dynamichud             1 "apply the dynamic hud effects to this panel"
@@ -66,6 +67,7 @@ seta hud_panel_physics_dynamichud          1 "apply the dynamic hud effects to t
 seta hud_panel_centerprint_dynamichud      1 "apply the dynamic hud effects to this panel"
 seta hud_panel_itemstime_dynamichud        1 "apply the dynamic hud effects to this panel"
 seta hud_panel_scoreboard_dynamichud       0 "apply the dynamic hud effects to this panel"
+seta hud_panel_strafehud_dynamichud        1 "apply the dynamic hud effects to this panel"
 
 seta hud_panel_weapons_ammo_full_shells 60 "show 100% of the status bar at this ammo count"
 seta hud_panel_weapons_ammo_full_nails 320 "show 100% of the status bar at this ammo count"
@@ -122,6 +124,53 @@ 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" "strafehud changes angle during configure"
+seta hud_panel_strafehud_mode "0" "strafehud mode which controls whether the strafehud is centered at \"0\" = view angle, \"1\" = velocity angle"
+seta hud_panel_strafehud_range "0" "the angle range up to 360 degrees displayed on the strafehud, \"0\" = dynamic (chooses the minimum range required to still see the whole area needed for accelerating at once)"
+seta hud_panel_strafehud_style "1" "\"0\" = no styling, \"1\" = progress bar style for the strafe bar, \"2\" = gradient for the strafe bar"
+seta hud_panel_strafehud_unit "1" "speed unit (1 = qu/s, 2 = m/s, 3 = km/h, 4 = mph, 5 = knots), length unit (1 = qu, 2 = m, 3 = km, 4 = mi, 5 = nmi)"
+seta hud_panel_strafehud_unit_show "1" "show units"
+seta hud_panel_strafehud_bar_neutral_color "1 1 1" "color of the strafe meter neutral zone"
+seta hud_panel_strafehud_bar_neutral_alpha "0.3" "opacity of the strafe meter neutral zone"
+seta hud_panel_strafehud_bar_accel_color "0 1 0" "color of the strafe meter acceleration zone"
+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_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_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"
+seta hud_panel_strafehud_switch_inactive_color "1 1 0" "color of the switch indicator on the opposite side"
+seta hud_panel_strafehud_switch_inactive_alpha "1" "opacity of the switch indicator on the opposite side"
+seta hud_panel_strafehud_switch_width "0.0075" "width of the strafe angle indicators (relative to the strafe bar width)"
+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 "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 "0" "range of the slick detector in qu, \"0\" to disable"
+seta hud_panel_strafehud_slickdetector_granularity "2" "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 "0" "fade time (in seconds) of the start speed text or \"0\" to disable"
+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_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)"
+seta hud_panel_strafehud_timeout_air "0.1" "time (in seconds) after take off before changing to air strafe physics when not jumping (visually more consistent hud while on slick downwards ramps)"
+seta hud_panel_strafehud_timeout_ground "0.03333333" "time (in seconds) after landing before changing to non-air strafe physics (visually more consistent hud while strafe turning when touching the floor after every hop)"
+seta hud_panel_strafehud_timeout_turn "0.1" "time (in seconds) after releasing the strafe keys before changing mode (visually more consistent hud while switching between left/right strafe turning)"
+seta hud_panel_strafehud_timeout_direction "0.5" "time (in seconds) it takes until direction changes (forward or backward movement) are applied (set to zero if you intend to sideways strafe)"
+seta hud_panel_strafehud_antiflicker_angle "0.01" "how many degrees from 0° to 180° the hud ignores if it could cause visual disturbances otherwise (and to counter rounding errors)"
+seta hud_panel_strafehud_antiflicker_speed "0.0001" "how many qu/s the hud ignores if it could cause visual disturbances otherwise (and to counter rounding errors)"
+
 // hud panel aliases
 alias quickmenu "cl_cmd hud quickmenu ${* ?}"
 
index a2a23ddea19a1d8d10dacd4ae870967b10503a30..6880f96e045c863e25a083b7e446b0db8b2891a1 100644 (file)
@@ -378,3 +378,12 @@ seta hud_panel_scoreboard_table_highlight_alpha_self "" "self highlight alpha of
 seta hud_panel_scoreboard_bg_teams_color_team "" "override panel team color in team tables"
 seta hud_panel_scoreboard_accuracy_doublerows "" "use two rows instead of one"
 seta hud_panel_scoreboard_accuracy_nocolors "" "don't use colors displaying accuracy stats"
+
+seta hud_panel_strafehud_pos "" "position of this base of the panel"
+seta hud_panel_strafehud_size "" "size of this panel"
+seta hud_panel_strafehud_bg "" "if set to something else than \"\" = override default background"
+seta hud_panel_strafehud_bg_color "" "if set to something else than \"\" = override default panel background color"
+seta hud_panel_strafehud_bg_color_team "" "override panel color with team color in team based games"
+seta hud_panel_strafehud_bg_alpha "" "if set to something else than \"\" = override default panel background alpha"
+seta hud_panel_strafehud_bg_border "" "if set to something else than \"\" = override default size of border around the background"
+seta hud_panel_strafehud_bg_padding "" "if set to something else than \"\" = override default padding of contents from border"
index 5e3ca40562f3ea13fd54bab5e7ef7b92080f8534..747736b26998c49741663256473f75f1b5289f57 100644 (file)
@@ -30,7 +30,7 @@ seta hud_progressbar_acceleration_neg_color "0.86 0.35 0"
 seta hud_progressbar_vehicles_ammo1_color "0.77 0.67 0"
 seta hud_progressbar_vehicles_ammo2_color "0.86 0.35 0"
 
-seta _hud_panelorder "17 15 12 9 5 10 6 14 0 7 4 11 2 1 3 8 13 16 18 23 19 20 21 22 24 "
+seta _hud_panelorder "17 25 15 12 9 5 10 6 14 0 7 4 11 2 1 3 8 13 16 18 23 19 20 21 22 24 "
 
 seta hud_configure_grid "1"
 seta hud_configure_grid_xsize "0.005000"
@@ -380,4 +380,13 @@ seta hud_panel_scoreboard_bg_teams_color_team "0"
 seta hud_panel_scoreboard_accuracy_doublerows "0"
 seta hud_panel_scoreboard_accuracy_nocolors "0"
 
+seta hud_panel_strafehud_pos "0.320000 0.570000"
+seta hud_panel_strafehud_size "0.360000 0.020000"
+seta hud_panel_strafehud_bg "0"
+seta hud_panel_strafehud_bg_color ""
+seta hud_panel_strafehud_bg_color_team ""
+seta hud_panel_strafehud_bg_alpha "0.7"
+seta hud_panel_strafehud_bg_border ""
+seta hud_panel_strafehud_bg_padding ""
+
 menu_sync
index 5b0f9e05612f9a778a756aab555dc1816214ad7f..3a02780b6b24a754777d03d7ce91173d9765ea72 100644 (file)
@@ -30,7 +30,7 @@ seta hud_progressbar_acceleration_neg_color "0.125 0.25 0.5"
 seta hud_progressbar_vehicles_ammo1_color "0.8 0.7 0"
 seta hud_progressbar_vehicles_ammo2_color "0.7 0.4 0"
 
-seta _hud_panelorder "17 15 12 9 10 5 6 14 0 7 4 11 2 1 3 8 13 16 18 23 19 20 21 22 24 "
+seta _hud_panelorder "17 25 15 12 9 10 5 6 14 0 7 4 11 2 1 3 8 13 16 18 23 19 20 21 22 24 "
 
 seta hud_configure_grid "1"
 seta hud_configure_grid_xsize "0.010000"
@@ -380,4 +380,13 @@ seta hud_panel_scoreboard_bg_teams_color_team "0"
 seta hud_panel_scoreboard_accuracy_doublerows "1"
 seta hud_panel_scoreboard_accuracy_nocolors "0"
 
+seta hud_panel_strafehud_pos "0.330000 0.570000"
+seta hud_panel_strafehud_size "0.340000 0.020000"
+seta hud_panel_strafehud_bg ""
+seta hud_panel_strafehud_bg_color ""
+seta hud_panel_strafehud_bg_color_team ""
+seta hud_panel_strafehud_bg_alpha ""
+seta hud_panel_strafehud_bg_border ""
+seta hud_panel_strafehud_bg_padding ""
+
 menu_sync
index 1e1845ed73d555359698c1dda420270dfc196205..80642d6fe535d7a0d09e2d77dbcfbae36cfc7492 100644 (file)
@@ -30,7 +30,7 @@ seta hud_progressbar_acceleration_neg_color "0.125 0.25 0.5"
 seta hud_progressbar_vehicles_ammo1_color "0.8 0.7 0"
 seta hud_progressbar_vehicles_ammo2_color "0.7 0.4 0"
 
-seta _hud_panelorder "17 10 3 0 14 6 9 13 4 1 2 11 12 7 5 8 15 16 18 23 19 20 21 22 24 "
+seta _hud_panelorder "17 10 3 0 14 6 9 13 4 1 2 11 12 7 5 8 25 15 16 18 23 19 20 21 22 24 "
 
 seta hud_configure_grid "1"
 seta hud_configure_grid_xsize "0.010000"
@@ -380,4 +380,13 @@ seta hud_panel_scoreboard_bg_teams_color_team "0.7"
 seta hud_panel_scoreboard_accuracy_doublerows "1"
 seta hud_panel_scoreboard_accuracy_nocolors "0"
 
+seta hud_panel_strafehud_pos "0.380000 0.550000"
+seta hud_panel_strafehud_size "0.240000 0.025000"
+seta hud_panel_strafehud_bg ""
+seta hud_panel_strafehud_bg_color ""
+seta hud_panel_strafehud_bg_color_team ""
+seta hud_panel_strafehud_bg_alpha ""
+seta hud_panel_strafehud_bg_border ""
+seta hud_panel_strafehud_bg_padding ""
+
 menu_sync
index 7995bc1638d26e94fbd34b83bda2020c04bfc3b4..31abc94cfcc1fae657bf053c0677a8593fbf5f9f 100644 (file)
@@ -30,7 +30,7 @@ seta hud_progressbar_acceleration_neg_color "0.125 0.25 0.5"
 seta hud_progressbar_vehicles_ammo1_color "0.8 0.7 0"
 seta hud_progressbar_vehicles_ammo2_color "0.7 0.4 0"
 
-seta _hud_panelorder "17 15 3 1 2 11 10 0 14 6 9 13 4 12 7 5 8 16 18 23 19 20 21 22 24 "
+seta _hud_panelorder "17 25 15 3 1 2 11 10 0 14 6 9 13 4 12 7 5 8 16 18 23 19 20 21 22 24 "
 
 seta hud_configure_grid "1"
 seta hud_configure_grid_xsize "0.010000"
@@ -380,4 +380,13 @@ seta hud_panel_scoreboard_bg_teams_color_team "0.7"
 seta hud_panel_scoreboard_accuracy_doublerows "1"
 seta hud_panel_scoreboard_accuracy_nocolors "0"
 
+seta hud_panel_strafehud_pos "0.330000 0.700000"
+seta hud_panel_strafehud_size "0.340000 0.015000"
+seta hud_panel_strafehud_bg ""
+seta hud_panel_strafehud_bg_color ""
+seta hud_panel_strafehud_bg_color_team ""
+seta hud_panel_strafehud_bg_alpha ""
+seta hud_panel_strafehud_bg_border ""
+seta hud_panel_strafehud_bg_padding ""
+
 menu_sync
index c303f227969aac102571b6295a752a3cdd00ddf6..d53902eac34183ffdbfef1d60b2a702098cbec55 100644 (file)
@@ -30,7 +30,7 @@ seta hud_progressbar_acceleration_neg_color "0.125 0.25 0.5"
 seta hud_progressbar_vehicles_ammo1_color "0.8 0.7 0"
 seta hud_progressbar_vehicles_ammo2_color "0.7 0.4 0"
 
-seta _hud_panelorder "17 15 10 9 6 8 14 5 0 4 13 2 7 1 3 11 12 16 18 23 19 20 21 22 24 "
+seta _hud_panelorder "17 25 15 10 9 6 8 14 5 0 4 13 2 7 1 3 11 12 16 18 23 19 20 21 22 24 "
 
 seta hud_configure_grid "1"
 seta hud_configure_grid_xsize "0.010000"
@@ -380,4 +380,13 @@ seta hud_panel_scoreboard_bg_teams_color_team "0.7"
 seta hud_panel_scoreboard_accuracy_doublerows "1"
 seta hud_panel_scoreboard_accuracy_nocolors "0"
 
+seta hud_panel_strafehud_pos "0.320000 0.540000"
+seta hud_panel_strafehud_size "0.360000 0.025000"
+seta hud_panel_strafehud_bg ""
+seta hud_panel_strafehud_bg_color ""
+seta hud_panel_strafehud_bg_color_team ""
+seta hud_panel_strafehud_bg_alpha ""
+seta hud_panel_strafehud_bg_border ""
+seta hud_panel_strafehud_bg_padding ""
+
 menu_sync
index 62e843301fef13ec7fb8b2ad56e066d2890a52bf..b820ef52499dd172255ff69aef9a45dbf759fc0a 100644 (file)
@@ -30,7 +30,7 @@ seta hud_progressbar_acceleration_neg_color "0.125 0.25 0.5"
 seta hud_progressbar_vehicles_ammo1_color "0.8 0.7 0"
 seta hud_progressbar_vehicles_ammo2_color "0.7 0.4 0"
 
-seta _hud_panelorder "17 15 0 11 8 5 6 14 9 13 7 2 3 1 10 12 4 16 18 23 19 20 21 22 24 "
+seta _hud_panelorder "17 25 15 0 11 8 5 6 14 9 13 7 2 3 1 10 12 4 16 18 23 19 20 21 22 24 "
 
 seta hud_configure_grid "1"
 seta hud_configure_grid_xsize "0.010000"
@@ -380,4 +380,13 @@ seta hud_panel_scoreboard_bg_teams_color_team "0.7"
 seta hud_panel_scoreboard_accuracy_doublerows "1"
 seta hud_panel_scoreboard_accuracy_nocolors "0"
 
+seta hud_panel_strafehud_pos "0.360000 0.570000"
+seta hud_panel_strafehud_size "0.280000 0.025000"
+seta hud_panel_strafehud_bg "0"
+seta hud_panel_strafehud_bg_color ""
+seta hud_panel_strafehud_bg_color_team ""
+seta hud_panel_strafehud_bg_alpha ""
+seta hud_panel_strafehud_bg_border ""
+seta hud_panel_strafehud_bg_padding ""
+
 menu_sync
index 347da5de121ce77739b3acb704ed67f60c5c5bcd..967f8e443475fdaa3e48eb88f30f6e72f21d141b 100644 (file)
@@ -211,6 +211,7 @@ bool autocvar_hud_panel_infomessages_dynamichud = false;
 bool autocvar_hud_panel_physics_dynamichud      = true;
 bool autocvar_hud_panel_centerprint_dynamichud  = true;
 //bool autocvar_hud_panel_itemstime_dynamichud    = true;
+bool autocvar_hud_panel_strafehud_dynamichud    = true;
 bool autocvar_hud_panel_healtharmor_hide_ondeath  = false;
 bool autocvar_hud_panel_ammo_hide_ondeath         = false;
 bool autocvar_hud_panel_powerups_hide_ondeath     = false;
@@ -320,6 +321,53 @@ 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;
+int autocvar_hud_panel_strafehud = 3;
+bool autocvar__hud_panel_strafehud_demo = false;
+int autocvar_hud_panel_strafehud_mode = 0;
+float autocvar_hud_panel_strafehud_range = 0;
+int autocvar_hud_panel_strafehud_style = 1;
+int autocvar_hud_panel_strafehud_unit = 1;
+bool autocvar_hud_panel_strafehud_unit_show = true;
+vector autocvar_hud_panel_strafehud_bar_neutral_color = '1 1 1';
+float autocvar_hud_panel_strafehud_bar_neutral_alpha = 0.3;
+vector autocvar_hud_panel_strafehud_bar_accel_color = '0 1 0';
+float autocvar_hud_panel_strafehud_bar_accel_alpha = 0.3;
+vector autocvar_hud_panel_strafehud_bar_overturn_color = '1 0 1';
+float autocvar_hud_panel_strafehud_bar_overturn_alpha = 0.3;
+float autocvar_hud_panel_strafehud_angle_alpha = 0.8;
+float autocvar_hud_panel_strafehud_angle_height = 1.5;
+float autocvar_hud_panel_strafehud_angle_width = 0.005;
+vector autocvar_hud_panel_strafehud_angle_neutral_color = '1 1 0';
+vector autocvar_hud_panel_strafehud_angle_accel_color = '0 1 1';
+vector autocvar_hud_panel_strafehud_angle_overturn_color = '1 0 1';
+float autocvar_hud_panel_strafehud_switch_minspeed = -1;
+vector autocvar_hud_panel_strafehud_switch_active_color = '0 1 0';
+float autocvar_hud_panel_strafehud_switch_active_alpha = 1;
+vector autocvar_hud_panel_strafehud_switch_inactive_color = '1 1 0';
+float autocvar_hud_panel_strafehud_switch_inactive_alpha = 1;
+float autocvar_hud_panel_strafehud_switch_width = 0.0075;
+vector autocvar_hud_panel_strafehud_direction_color = '0 0.5 1';
+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;
+float autocvar_hud_panel_strafehud_slickdetector_range = 0;
+int autocvar_hud_panel_strafehud_slickdetector_granularity = 2;
+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;
+float autocvar_hud_panel_strafehud_startspeed_fade = 0;
+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;
+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;
+float autocvar_hud_panel_strafehud_timeout_air = 0.1;
+float autocvar_hud_panel_strafehud_timeout_ground = 0.03333333;
+float autocvar_hud_panel_strafehud_timeout_turn = 0.1;
+float autocvar_hud_panel_strafehud_timeout_direction = 0.5;
+float autocvar_hud_panel_strafehud_antiflicker_angle = 0.01;
+float autocvar_hud_panel_strafehud_antiflicker_speed = 0.0001;
 bool autocvar_hud_panel_timer;
 bool autocvar_hud_panel_timer_increment;
 float autocvar_hud_panel_update_interval;
index dae8a72d9b5fced452fa5c4f469b8f7343734cea..b8740560f98e70178402abe55e0df265e58b53c2 100644 (file)
@@ -253,6 +253,7 @@ REGISTER_HUD_PANEL(MAPVOTE,         MapVote_Draw,       PANEL_CONFIG_NO
 REGISTER_HUD_PANEL(ITEMSTIME,       HUD_ItemsTime,      PANEL_CONFIG_MAIN | PANEL_CONFIG_CANBEOFF, PANEL_SHOW_MAINGAME                                                                ) // ITEMSTIME
 REGISTER_HUD_PANEL(QUICKMENU,       HUD_QuickMenu,      PANEL_CONFIG_MAIN                        , PANEL_SHOW_MAINGAME | PANEL_SHOW_MINIGAME                                          ) // QUICKMENU
 REGISTER_HUD_PANEL(SCOREBOARD,      Scoreboard_Draw,    PANEL_CONFIG_NO                          , PANEL_SHOW_MAINGAME | PANEL_SHOW_MINIGAME | PANEL_SHOW_MAPVOTE | PANEL_SHOW_WITH_SB) // SCOREBOARD
+REGISTER_HUD_PANEL(STRAFEHUD,       HUD_StrafeHUD,      PANEL_CONFIG_MAIN | PANEL_CONFIG_CANBEOFF, PANEL_SHOW_MAINGAME                                                                ) // STRAFEHUD
 // always add new panels to the end of list
 
 // Because calling lots of functions in QC apparently cuts fps in half on many machines:
index 7a95752132c43f3764da1a067db10667ba87c4bd..68e368ed13cb0c9dad0227073710fe0f885c7c57 100644 (file)
@@ -16,6 +16,7 @@
 #include <client/hud/panel/radar.qc>
 #include <client/hud/panel/score.qc>
 #include <client/hud/panel/scoreboard.qc>
+#include <client/hud/panel/strafehud.qc>
 #include <client/hud/panel/timer.qc>
 #include <client/hud/panel/vote.qc>
 #include <client/hud/panel/weapons.qc>
index c24b5c0002876d29d4beca731325ca828004c4e3..1b45f0cd042a5be7fa4b42483c1e08039c04f636 100644 (file)
@@ -16,6 +16,7 @@
 #include <client/hud/panel/radar.qh>
 #include <client/hud/panel/score.qh>
 #include <client/hud/panel/scoreboard.qh>
+#include <client/hud/panel/strafehud.qh>
 #include <client/hud/panel/timer.qh>
 #include <client/hud/panel/vote.qh>
 #include <client/hud/panel/weapons.qh>
diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc
new file mode 100644 (file)
index 0000000..36e6f60
--- /dev/null
@@ -0,0 +1,915 @@
+// Author: Juhu
+
+#include "strafehud.qh"
+
+#include <client/autocvars.qh>
+#include <client/draw.qh>
+#include <client/hud/panel/racetimer.qh>
+#include <client/main.qh>
+#include <client/resources.qh>
+#include <common/animdecide.qh>
+#include <common/ent_cs.qh>
+#include <common/mapinfo.qh>
+#include <common/physics/movetypes/movetypes.qh>
+#include <common/physics/player.qh>
+#include <lib/csqcmodel/cl_player.qh>
+
+// StrafeHUD (#25)
+
+void HUD_StrafeHUD_Export(int fh)
+{
+    // allow saving cvars that aesthetically change the panel into hud skin files
+}
+
+float hidden_width;
+int direction;
+float demo_angle = -37;
+float demo_direction = 1;
+float demo_time = 0;
+bool state_onground = false;
+float state_onground_time = 0;
+bool state_strafekeys = false;
+float state_strafekeys_time = 0;
+bool turn = false;
+float turnangle;
+bool fwd = true;
+bool state_fwd = true;
+bool state_fwd_prev = true;
+float state_fwd_time = 0;
+float starttime = 0;
+float startspeed = -1;
+float jumptime = 0;
+float jumpheight = -1;
+float jumpheight_persistent = -1;
+float jumpheight_prev = 0;
+float jumpspeed_prev = 0;
+bool  jumprestart = true;
+
+// provide basic panel cvars to old clients
+// TODO remove them after a future release (0.8.2+)
+noref string autocvar_hud_panel_strafehud_pos = "0.320000 0.570000";
+noref string autocvar_hud_panel_strafehud_size = "0.360000 0.020000";
+noref string autocvar_hud_panel_strafehud_bg = "0";
+noref string autocvar_hud_panel_strafehud_bg_color = "";
+noref string autocvar_hud_panel_strafehud_bg_color_team = "";
+noref string autocvar_hud_panel_strafehud_bg_alpha = "0.7";
+noref string autocvar_hud_panel_strafehud_bg_border = "";
+noref string autocvar_hud_panel_strafehud_bg_padding = "";
+
+void HUD_StrafeHUD()
+{
+    entity strafeplayer;
+    bool islocal;
+
+    // generic hud routines
+    if(!autocvar__hud_configure)
+    {
+        if(!autocvar_hud_panel_strafehud ||
+           (spectatee_status == -1 && (autocvar_hud_panel_strafehud == 1 || autocvar_hud_panel_strafehud == 3)) ||
+           (autocvar_hud_panel_strafehud == 3 && !MUTATOR_CALLHOOK(HUD_StrafeHUD_showoptional))) return;
+    }
+
+    HUD_Panel_LoadCvars();
+
+    if(autocvar_hud_panel_strafehud_dynamichud)
+    {
+        HUD_Scale_Enable();
+    }
+    else
+    {
+        HUD_Scale_Disable();
+    }
+
+    HUD_Panel_DrawBg();
+
+    if(panel_bg_padding)
+    {
+        panel_pos  += '1 1 0' * panel_bg_padding;
+        panel_size -= '2 2 0' * panel_bg_padding;
+    }
+
+    // find out whether the local csqcmodel entity is valid
+    if(spectatee_status > 0 || isdemo())
+    {
+        islocal = false;
+        strafeplayer = CSQCModel_server2csqc(player_localentnum - 1);
+    }
+    else
+    {
+        islocal = true;
+        strafeplayer = csqcplayer;
+    }
+
+    // draw strafehud
+    if(csqcplayer && strafeplayer)
+    {
+        // physics
+        bool   onground                      = islocal ? IS_ONGROUND(strafeplayer) : !(strafeplayer.anim_implicit_state & ANIMIMPLICITSTATE_INAIR);
+        bool   strafekeys;
+        bool   swimming                      = strafeplayer.waterlevel >= WATERLEVEL_SWIMMING;
+        bool   spectating                    = entcs_GetSpecState(strafeplayer.sv_entnum) == ENTCS_SPEC_PURE;
+        float  speed                         = !autocvar__hud_configure ? vlen(vec2(csqcplayer.velocity)) : 1337; // use local csqcmodel entity for this even when spectating, flickers too much otherwise
+        float  maxspeed_crouch_mod           = IS_DUCKED(strafeplayer) && !swimming ? .5 : 1;
+        float  maxspeed_water_mod            = swimming ? .7 : 1; // very simplified water physics, the hud will not work well (and is not supposed to) while swimming
+        float  maxspeed_phys                 = onground ? PHYS_MAXSPEED(strafeplayer) : PHYS_MAXAIRSPEED(strafeplayer);
+        float  maxspeed                      = !autocvar__hud_configure ? maxspeed_phys * maxspeed_crouch_mod * maxspeed_water_mod : 320;
+        float  vel_angle                     = vectoangles(strafeplayer.velocity).y;
+        float  view_angle                    = PHYS_INPUT_ANGLES(strafeplayer).y + 180;
+        float  angle;
+        vector movement                      = PHYS_INPUT_MOVEVALUES(strafeplayer);
+        int    keys                          = STAT(PRESSED_KEYS);
+        int    keys_fwd;
+        float  wishangle                     = 0;
+
+        // HUD
+        int    mode                          = autocvar_hud_panel_strafehud_mode >= 0 && autocvar_hud_panel_strafehud_mode <= 1 ? autocvar_hud_panel_strafehud_mode : 0;
+        float  speed_conversion_factor       = GetSpeedUnitFactor(autocvar_hud_panel_strafehud_unit);
+        float  length_conversion_factor      = GetLengthUnitFactor(autocvar_hud_panel_strafehud_unit);
+        string speed_unit                    = GetSpeedUnit(autocvar_hud_panel_strafehud_unit);
+        string length_unit                   = GetLengthUnit(autocvar_hud_panel_strafehud_unit);
+        int    length_decimals               = autocvar_hud_panel_strafehud_unit >= 3 && autocvar_hud_panel_strafehud_unit <= 5 ? 6 : 2; // use more decimals when displaying km or miles
+        float  antiflicker_angle             = bound(0, autocvar_hud_panel_strafehud_antiflicker_angle, 180);
+        float  antiflicker_speed             = max(0, autocvar_hud_panel_strafehud_antiflicker_speed);
+        float  minspeed;
+        float  shift_offset                  = 0;
+        bool   straight_overturn             = false;
+        bool   immobile                      = speed <= (swimming ? antiflicker_speed : 0);
+        float  hudangle;
+        float  neutral_offset;
+        float  neutral_width;
+        vector currentangle_color            = autocvar_hud_panel_strafehud_angle_neutral_color;
+        float  currentangle_offset;
+        vector currentangle_size             = '0 0 0';
+        float  bestangle;
+        float  odd_bestangle;
+        bool   bestangle_anywhere            = false;
+        float  bestangle_offset;
+        float  switch_bestangle_offset;
+        bool   odd_angles                    = false;
+        float  odd_bestangle_offset          = 0;
+        float  switch_odd_bestangle_offset   = 0;
+        float  bestangle_width;
+        float  accelzone_left_offset;
+        float  accelzone_right_offset;
+        float  accelzone_width;
+        float  overturn_offset;
+        float  overturn_width;
+        float  slickdetector_height;
+        vector direction_size_vertical       = '0 0 0';
+        vector direction_size_horizontal     = '0 0 0';
+        float  range_minangle;
+
+        // determine whether the player is pressing forwards or backwards keys
+        if(islocal) // if entity is local player
+        {
+            if(movement.x > 0)
+            {
+                keys_fwd = 1;
+            }
+            else if(movement.x < 0)
+            {
+                keys_fwd = -1;
+            }
+            else
+            {
+                keys_fwd = 0;
+            }
+        }
+        else // alternatively determine direction by querying pressed keys
+        {
+            if((keys & KEY_FORWARD) && !(keys & KEY_BACKWARD))
+            {
+                keys_fwd = 1;
+            }
+            else if(!(keys & KEY_FORWARD) && (keys & KEY_BACKWARD))
+            {
+                keys_fwd = -1;
+            }
+            else
+            {
+                keys_fwd = 0;
+            }
+        }
+
+        // determine player wishdir
+        if(islocal) // if entity is local player
+        {
+            if(movement.x == 0)
+            {
+                if(movement.y < 0)
+                {
+                    wishangle = -90;
+                }
+                else if(movement.y > 0)
+                {
+                    wishangle = 90;
+                }
+                else
+                {
+                    wishangle = 0;
+                }
+            }
+            else
+            {
+                if(movement.y == 0)
+                {
+                    wishangle = 0;
+                }
+                else
+                {
+                    wishangle = RAD2DEG * atan2(movement.y, movement.x);
+                    // wrap the wish angle if it exceeds ±90°
+                    if(fabs(wishangle) > 90)
+                    {
+                        if(wishangle < 0) wishangle += 180;
+                        else wishangle -= 180;
+                        wishangle = -wishangle;
+                    }
+                }
+            }
+        }
+        else // alternatively calculate wishdir by querying pressed keys
+        {
+            if(keys & KEY_FORWARD || keys & KEY_BACKWARD)
+            {
+                wishangle = 45;
+            }
+            else
+            {
+                wishangle = 90;
+            }
+            if(keys & KEY_LEFT)
+            {
+                wishangle *= -1;
+            }
+            else if(!(keys & KEY_RIGHT))
+            {
+                wishangle = 0; // wraps at 180°
+            }
+        }
+
+        strafekeys = fabs(wishangle) == 90;
+
+        // determine minimum required angle to display full strafe range
+        range_minangle = fabs(wishangle) % 90; // maximum range is 90 degree
+        if(range_minangle > 45) // minimum angle range is 45
+        {
+            range_minangle = 45 - fabs(wishangle) % 45;
+        }
+        range_minangle = 90 - range_minangle; // calculate value which is never >90 or <45
+        range_minangle *= 2; // multiply to accommodate for both sides of the hud
+
+        if(autocvar_hud_panel_strafehud_range == 0)
+        {
+            if(autocvar__hud_configure)
+            {
+                hudangle = 90;
+            }
+            else
+            {
+                hudangle = range_minangle; // use minimum angle required if dynamically setting hud angle
+            }
+        }
+        else
+        {
+            hudangle = bound(0, fabs(autocvar_hud_panel_strafehud_range), 360); // limit HUD range to 360 degrees, higher values don't make sense
+        }
+
+        // detect air strafe turning
+        if(onground != state_onground)
+        {
+            state_onground_time = time;
+        }
+        state_onground = onground;
+
+        if(strafekeys != state_strafekeys)
+        {
+            state_strafekeys_time = time;
+        }
+        state_strafekeys = strafekeys;
+
+        if((keys & KEY_FORWARD) || (keys & KEY_BACKWARD) || swimming || autocvar__hud_configure)
+        {
+            turn = false;
+        }
+        else if(onground)
+        {
+            if((time - state_onground_time) >= autocvar_hud_panel_strafehud_timeout_ground) // timeout for strafe jumping in general
+            {
+                turn = false;
+            }
+        }
+        else // air strafe only
+        {
+            if(strafekeys)
+            {
+                if(((time - state_onground_time) >= autocvar_hud_panel_strafehud_timeout_air) || (keys & KEY_JUMP)) // timeout for slick ramps
+                {
+                    turn = true; // CPMA turning
+                    turnangle = wishangle;
+                }
+            }
+            else if((time - state_strafekeys_time) >= autocvar_hud_panel_strafehud_timeout_turn) // timeout for jumping with strafe keys only
+            {
+                turn = false;
+            }
+        }
+        if(turn)
+        {
+            maxspeed = PHYS_MAXAIRSTRAFESPEED(strafeplayer); // no modifiers here because they don't affect air strafing
+            wishangle = turnangle;
+        }
+
+        minspeed = autocvar_hud_panel_strafehud_switch_minspeed < 0 ? maxspeed + antiflicker_speed : autocvar_hud_panel_strafehud_switch_minspeed;
+
+        // get current strafing angle ranging from -180° to +180°
+        if(!autocvar__hud_configure)
+        {
+            if(speed > 0)
+            {
+                // calculate view angle relative to the players current velocity direction
+                angle = vel_angle - view_angle;
+
+                // if the angle goes above 180° or below -180° wrap it to the opposite side
+                if (angle > 180) angle -= 360;
+                else if(angle < -180) angle += 360;
+
+                // shift the strafe angle by 180° for hud calculations
+                if(angle < 0) angle += 180;
+                else angle -= 180;
+
+                // determine whether the player is strafing forwards or backwards
+                // if the player isn't strafe turning use forwards/backwards keys to determine direction
+                if(!strafekeys)
+                {
+                    if(keys_fwd > 0)
+                    {
+                        state_fwd = true;
+                    }
+                    else if(keys_fwd < 0)
+                    {
+                        state_fwd = false;
+                    }
+                    else
+                    {
+                        state_fwd = fabs(angle) <= 90;
+                    }
+                }
+                // otherwise determine by examining the strafe angle
+                else
+                {
+                    if(wishangle < 0) // detect direction using wishangle since the direction is not yet set
+                    {
+                        state_fwd = angle <= -wishangle;
+                    }
+                    else
+                    {
+                        state_fwd = angle >= -wishangle;
+                    }
+                }
+
+                if(state_fwd_prev != state_fwd)
+                {
+                    state_fwd_time = time;
+                }
+                state_fwd_prev = state_fwd;
+
+                if((time - state_fwd_time) >= autocvar_hud_panel_strafehud_timeout_direction || speed < maxspeed || (strafekeys && mode == 0)) // timeout when changing between forwards and backwards movement
+                {
+                    fwd = state_fwd;
+                }
+
+                // shift the strafe angle by 180° when strafing backwards
+                if(!fwd)
+                {
+                    if(angle < 0) angle += 180;
+                    else angle -= 180;
+                }
+
+                // don't make the angle indicator switch side too much at ±180° if anti flicker is turned on
+                if(angle > (180 - antiflicker_angle) || angle < (-180 + antiflicker_angle))
+                {
+                    straight_overturn = true;
+                }
+            }
+            else
+            {
+                angle = 0;
+            }
+        }
+        else // simulate turning for HUD setup
+        {
+            fwd = true;
+            if(autocvar__hud_panel_strafehud_demo && ((time - demo_time) >= .025))
+            {
+                demo_time = time;
+                demo_angle += demo_direction;
+                if(fabs(demo_angle) >= 55)
+                {
+                    demo_direction = -demo_direction;
+                }
+            }
+            angle = demo_angle;
+            wishangle = 45 * (demo_angle > 0 ? 1 : -1);
+        }
+
+        // invert the wish angle when strafing backwards
+        if(!fwd)
+        {
+            wishangle = -wishangle;
+        }
+
+        // flip angles if v_flipped is enabled
+        if(autocvar_v_flipped)
+        {
+            angle = -angle;
+            wishangle = -wishangle;
+        }
+
+        // determine whether the player is strafing left or right
+        if(wishangle != 0)
+        {
+            direction = wishangle > 0 ? 1 : -1;
+        }
+        else
+        {
+            direction = (angle > antiflicker_angle && angle < (180 - antiflicker_angle)) ? 1 : (angle < -antiflicker_angle && angle > (-180 + antiflicker_angle)) ? -1 : 0;
+        }
+
+        // best angle to strafe at
+        bestangle = (speed > maxspeed ? acos(maxspeed / speed) : 0) * RAD2DEG * (direction < 0 ? -1 : 1);
+        odd_bestangle = -bestangle - wishangle;
+        bestangle -= wishangle;
+
+        // various offsets and size calculations of hud indicator elements
+        // how much is hidden by the current hud angle
+        hidden_width = (360 - hudangle) / hudangle * panel_size.x;
+        // current angle
+        currentangle_size.x = max(panel_size.x * autocvar_hud_panel_strafehud_angle_width, 1);
+        if(mode == 0)
+        {
+            currentangle_offset = angle/hudangle * panel_size.x;
+        }
+        else
+        {
+            currentangle_offset = bound(-hudangle/2, angle, hudangle/2)/hudangle * panel_size.x + panel_size.x/2;
+        }
+        currentangle_size.y = max(panel_size.y * min(autocvar_hud_panel_strafehud_angle_height, 2), 1);
+        // best strafe acceleration angle
+        bestangle_offset        =  bestangle/hudangle * panel_size.x + panel_size.x/2;
+        switch_bestangle_offset = -bestangle/hudangle * panel_size.x + panel_size.x/2;
+        bestangle_width = max(panel_size.x * autocvar_hud_panel_strafehud_switch_width, 1);
+
+        if(((angle > -wishangle && direction < 0) || (angle < -wishangle && direction > 0)) && (direction != 0))
+        {
+            odd_angles = true;
+            odd_bestangle_offset = odd_bestangle/hudangle * panel_size.x + panel_size.x/2;
+            switch_odd_bestangle_offset = (odd_bestangle+bestangle*2)/hudangle * panel_size.x + panel_size.x/2;
+        }
+        // direction indicator
+        direction_size_vertical.x = max(panel_size.y * min(autocvar_hud_panel_strafehud_direction_width, .5), 1);
+        direction_size_vertical.y = panel_size.y;
+        direction_size_horizontal.x = max(panel_size.x * min(autocvar_hud_panel_strafehud_direction_length, .5), direction_size_vertical.x);
+        direction_size_horizontal.y = direction_size_vertical.x;
+        // overturn
+        overturn_width = 180/hudangle * panel_size.x;
+
+        // the neutral zone fills the whole strafe bar
+        if(immobile)
+        {
+            // draw neutral zone
+            if(panel_size.x > 0 && panel_size.y > 0 && autocvar_hud_panel_strafehud_bar_neutral_alpha * panel_fg_alpha > 0)
+            {
+                switch(autocvar_hud_panel_strafehud_style)
+                {
+                    default:
+                    case 0:
+                        drawfill(panel_pos, panel_size, autocvar_hud_panel_strafehud_bar_neutral_color, autocvar_hud_panel_strafehud_bar_neutral_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                        break;
+
+                    case 1:
+                        HUD_Panel_DrawProgressBar(panel_pos, panel_size, "progressbar", 1, 0, 0, autocvar_hud_panel_strafehud_bar_neutral_color, autocvar_hud_panel_strafehud_bar_neutral_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                }
+            }
+        }
+        else
+        {
+            // calculate various zones of the strafe-o-meter
+            accelzone_width = overturn_offset = (90 - fabs(bestangle + wishangle))/hudangle * panel_size.x;
+            accelzone_right_offset = 0;
+            accelzone_left_offset = overturn_offset + overturn_width;
+            neutral_width = 360/hudangle * panel_size.x - accelzone_width*2 - overturn_width;
+            neutral_offset = direction < 0 ? accelzone_left_offset + accelzone_width : -neutral_width;
+
+            // remove switch indicator width from offset
+            if(direction < 0)
+            {
+                bestangle_offset -= bestangle_width;
+                switch_odd_bestangle_offset -= bestangle_width;
+            }
+            else
+            {
+                switch_bestangle_offset -= bestangle_width;
+                odd_bestangle_offset -= bestangle_width;
+            }
+
+            // shift hud if operating in view angle centered mode
+            if(mode == 0)
+            {
+                shift_offset = -currentangle_offset;
+                bestangle_offset += shift_offset;
+                switch_bestangle_offset += shift_offset;
+                odd_bestangle_offset += shift_offset;
+                switch_odd_bestangle_offset += shift_offset;
+            }
+            if(direction < 0) shift_offset += -360/hudangle * panel_size.x;
+            // calculate how far off-center the strafe zones currently are
+            shift_offset += (panel_size.x + neutral_width)/2 - wishangle/hudangle * panel_size.x;
+            // shift strafe zones into correct place
+            neutral_offset += shift_offset;
+            accelzone_left_offset += shift_offset;
+            accelzone_right_offset += shift_offset;
+            overturn_offset += shift_offset;
+
+            // draw left acceleration zone
+            HUD_Panel_DrawStrafeHUD(accelzone_left_offset, accelzone_width, autocvar_hud_panel_strafehud_bar_accel_color, autocvar_hud_panel_strafehud_bar_accel_alpha * panel_fg_alpha, autocvar_hud_panel_strafehud_style, 1);
+
+            // draw right acceleration zone
+            HUD_Panel_DrawStrafeHUD(accelzone_right_offset, accelzone_width, autocvar_hud_panel_strafehud_bar_accel_color, autocvar_hud_panel_strafehud_bar_accel_alpha * panel_fg_alpha, autocvar_hud_panel_strafehud_style, 2);
+
+            // draw overturn zone
+            HUD_Panel_DrawStrafeHUD(overturn_offset, overturn_width, autocvar_hud_panel_strafehud_bar_overturn_color, autocvar_hud_panel_strafehud_bar_overturn_alpha * panel_fg_alpha, autocvar_hud_panel_strafehud_style, 3);
+
+            // draw neutral zone
+            HUD_Panel_DrawStrafeHUD(neutral_offset, neutral_width, autocvar_hud_panel_strafehud_bar_neutral_color, autocvar_hud_panel_strafehud_bar_neutral_alpha * panel_fg_alpha, autocvar_hud_panel_strafehud_style, 0);
+
+            if(direction != 0 && direction_size_vertical.x > 0 && autocvar_hud_panel_strafehud_direction_alpha * panel_fg_alpha > 0)
+            {
+                bool indicator_direction = direction < 0;
+                // invert left/right when strafing backwards or when strafing towards the opposite side indicated by the direction variable
+                // if both conditions are true then it's inverted twice hence not inverted at all
+                if(!fwd != odd_angles)
+                {
+                    indicator_direction = !indicator_direction;
+                }
+                // draw the direction indicator caps at the sides of the hud
+                // vertical line
+                if(direction_size_vertical.y > 0) drawfill(panel_pos + eX * (indicator_direction ? -direction_size_vertical.x : panel_size.x), direction_size_vertical, autocvar_hud_panel_strafehud_direction_color, autocvar_hud_panel_strafehud_direction_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                // top horizontal line
+                drawfill(panel_pos + eX * (indicator_direction ? -direction_size_vertical.x : panel_size.x - direction_size_horizontal.x + direction_size_vertical.x) - eY * direction_size_horizontal.y, direction_size_horizontal, autocvar_hud_panel_strafehud_direction_color, autocvar_hud_panel_strafehud_direction_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                // bottom horizontal line
+                drawfill(panel_pos + eX * (indicator_direction ? -direction_size_vertical.x : panel_size.x - direction_size_horizontal.x + direction_size_vertical.x) + eY * panel_size.y, direction_size_horizontal, autocvar_hud_panel_strafehud_direction_color, autocvar_hud_panel_strafehud_direction_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+            }
+
+            if(speed >= minspeed) // only draw indicators if minspeed is reached
+            {
+                // draw best angles for acceleration
+                float offset = !odd_angles ? bestangle_offset : odd_bestangle_offset;
+                float switch_offset = !odd_angles ? switch_bestangle_offset : switch_odd_bestangle_offset;
+                // both indicators are inactive if no direction can be determined
+                vector switch_color = direction != 0 ? autocvar_hud_panel_strafehud_switch_active_color : autocvar_hud_panel_strafehud_switch_inactive_color;
+                float switch_alpha = direction != 0 ? autocvar_hud_panel_strafehud_switch_active_alpha : autocvar_hud_panel_strafehud_switch_inactive_alpha;
+                // draw the switch indicators
+                HUD_Panel_DrawStrafeHUD(switch_offset, bestangle_width, autocvar_hud_panel_strafehud_switch_inactive_color, autocvar_hud_panel_strafehud_switch_inactive_alpha * panel_fg_alpha, 0, 0);
+                HUD_Panel_DrawStrafeHUD(offset, bestangle_width, switch_color, switch_alpha * panel_fg_alpha, 0, 0);
+            }
+        }
+
+        // experimental: slick detector
+        slickdetector_height = panel_size.y * bound(0, autocvar_hud_panel_strafehud_slickdetector_height, 0.5);
+        if(autocvar_hud_panel_strafehud_slickdetector_range > 0 && autocvar_hud_panel_strafehud_slickdetector_alpha > 0 && slickdetector_height > 0 && panel_size.x > 0) // dunno if slick detection works in spectate
+        {
+            float slicksteps = 90 / pow(2, bound(0, autocvar_hud_panel_strafehud_slickdetector_granularity, 4));
+            bool slickdetected = false;
+
+            slickdetected = IS_ONSLICK(strafeplayer); // don't need to traceline if already touching slick
+
+            // traceline into every direction
+            trace_dphitq3surfaceflags = 0;
+            for(float i = 0; i < 360 && !slickdetected; i += slicksteps)
+            {
+                vector slickoffset;
+                float slickrotate;
+                slickoffset.z = -cos(i * DEG2RAD) * autocvar_hud_panel_strafehud_slickdetector_range;
+                slickrotate = sin(i * DEG2RAD) * autocvar_hud_panel_strafehud_slickdetector_range;
+                if(i != 0 && i != 180)
+                {
+                    for(float j = 0; j < 180 && !slickdetected; j += slicksteps)
+                    {
+                        slickoffset.x = sin(j * DEG2RAD) * slickrotate;
+                        slickoffset.y = cos(j * DEG2RAD) * slickrotate;
+
+                        traceline(strafeplayer.origin, strafeplayer.origin + slickoffset, MOVE_WORLDONLY, NULL);
+                        if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK) slickdetected = true;
+                    }
+                }
+                else
+                {
+                    slickoffset.x = slickoffset.y = 0;
+                    traceline(strafeplayer.origin, strafeplayer.origin + slickoffset, MOVE_WORLDONLY, NULL);
+                    if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK) slickdetected = true;
+                }
+            }
+
+            // if a traceline hit a slick surface
+            if(slickdetected)
+            {
+                vector slickdetector_size = panel_size;
+                slickdetector_size.y = slickdetector_height;
+                // top horizontal line
+                drawfill(panel_pos - eY * slickdetector_size.y, slickdetector_size, autocvar_hud_panel_strafehud_slickdetector_color, autocvar_hud_panel_strafehud_slickdetector_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                // bottom horizontal line
+                drawfill(panel_pos + eY * panel_size.y, slickdetector_size, autocvar_hud_panel_strafehud_slickdetector_color, autocvar_hud_panel_strafehud_slickdetector_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+            }
+        }
+
+        draw_beginBoldFont();
+        // show speed when crossing the start trigger
+        if(autocvar_hud_panel_strafehud_startspeed_fade > 0)
+        {
+            float text_alpha = 0;
+            if(race_checkpoint == 254) // checkpoint 254 is the start trigger
+            {
+                if(starttime != race_checkpointtime)
+                {
+                    starttime = race_checkpointtime;
+                    startspeed = speed;
+                }
+            }
+            if(startspeed >= 0)
+            {
+                text_alpha = cos(((time - starttime) / autocvar_hud_panel_strafehud_startspeed_fade) * 90 * DEG2RAD); // fade non-linear like the physics panel does
+                if((time - starttime) > autocvar_hud_panel_strafehud_startspeed_fade)
+                {
+                    startspeed = -1;
+                }
+            }
+            if(startspeed >= 0 && text_alpha > 0 && autocvar_hud_panel_strafehud_startspeed_size > 0)
+            {
+                vector startspeed_size = panel_size;
+                startspeed_size.y = panel_size.y * min(autocvar_hud_panel_strafehud_startspeed_size, 5);
+                drawstring_aspect(panel_pos + eY * panel_size.y, strcat(ftos_decimals(startspeed * speed_conversion_factor, 2), autocvar_hud_panel_strafehud_unit_show ? speed_unit : ""), startspeed_size, autocvar_hud_panel_strafehud_startspeed_color, text_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+            }
+        }
+        else
+        {
+            starttime = 0;
+            startspeed = -1;
+        }
+
+        // experimental: show height achieved by a single jump (doesn't work in low gravity and may not be 100% accurate)
+        if(autocvar_hud_panel_strafehud_jumpheight_fade > 0)
+        {
+            float text_alpha = 0;
+            float jumpheight_min = max(autocvar_hud_panel_strafehud_jumpheight_min, 0);
+            float jumpheight_current = strafeplayer.origin.z;
+            float jumpspeed_current = strafeplayer.velocity.z;
+            if(jumpspeed_prev <= jumpspeed_current || jumpheight_prev > jumpheight_current || IS_ONGROUND(strafeplayer) || swimming || IS_DEAD(strafeplayer) || spectating)
+            {
+                // tries to catch kill and spectate but those are not reliable, should just hook to kill/spectate/teleport and reset jump height there
+                jumprestart = true;
+            }
+            else
+            {
+                if(jumpheight < 0 || jumprestart)
+                {
+                    jumprestart = false;
+                    jumpheight = 0;
+                }
+                else
+                {
+                    jumpheight += jumpheight_current - jumpheight_prev;
+                }
+                if((jumpheight * length_conversion_factor) > jumpheight_min && jumpheight > jumpheight_persistent)
+                {
+                    jumptime = time;
+                    jumpheight_persistent = jumpheight;
+                }
+            }
+            jumpheight_prev = jumpheight_current;
+            jumpspeed_prev = jumpspeed_current;
+            if(jumpheight_persistent > 0)
+            {
+                text_alpha = cos(((time - jumptime) / autocvar_hud_panel_strafehud_jumpheight_fade) * 90 * DEG2RAD); // fade non-linear like the physics panel does
+                if((time - jumptime) > autocvar_hud_panel_strafehud_jumpheight_fade)
+                {
+                    jumpheight_persistent = -1;
+                }
+            }
+            if(jumpheight_persistent > 0 && text_alpha > 0 && autocvar_hud_panel_strafehud_jumpheight_size > 0)
+            {
+                vector jumpheight_size = panel_size;
+                jumpheight_size.y = panel_size.y * min(autocvar_hud_panel_strafehud_jumpheight_size, 5);
+                drawstring_aspect(panel_pos - eY * jumpheight_size.y, strcat(ftos_decimals(jumpheight_persistent * length_conversion_factor, length_decimals), autocvar_hud_panel_strafehud_unit_show ? length_unit : ""), jumpheight_size, autocvar_hud_panel_strafehud_jumpheight_color, text_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+            }
+        }
+        else
+        {
+            jumpheight_prev = jumpspeed_prev = 0;
+            jumpheight = jumpheight_persistent = -1;
+        }
+        draw_endBoldFont();
+
+        if(speed < (maxspeed + antiflicker_speed) && !immobile)
+        {
+            bestangle_anywhere = true; // moving forward should suffice to gain speed
+        }
+
+        // draw the actual strafe angle
+        if(!bestangle_anywhere && !immobile) // player gains speed with strafing
+        {
+            if((direction > 0 && (angle >= bestangle || angle <= -(bestangle + wishangle*2))) ||
+               (direction < 0 && (angle <= bestangle || angle >= -(bestangle + wishangle*2))))
+            currentangle_color = autocvar_hud_panel_strafehud_angle_accel_color;
+        }
+
+        if(fabs(angle + wishangle) > 90) // player is overturning
+        {
+            currentangle_color = autocvar_hud_panel_strafehud_angle_overturn_color;
+        }
+        else if(bestangle_anywhere) // player gains speed without strafing
+        {
+            currentangle_color = autocvar_hud_panel_strafehud_angle_accel_color;
+        }
+
+        if(mode == 0 || straight_overturn)
+        {
+            currentangle_offset = panel_size.x/2;
+        }
+
+        if(autocvar_hud_panel_strafehud_style == 2 && !immobile)
+        {
+            float moveangle = angle + wishangle;
+            float strafeangle = (bestangle + wishangle) * (direction < 0 ? -1 : 1);
+            float strafe_ratio = 0;
+            if(fabs(moveangle) > 90)
+            {
+                strafe_ratio = -((fabs(moveangle) - 90) / 90);
+                if(strafe_ratio < -1) strafe_ratio = -2 - strafe_ratio;
+            }
+            else
+            {
+                if(moveangle >= strafeangle)
+                {
+                    strafe_ratio = 1 - (moveangle - strafeangle) / (90 - strafeangle);
+                }
+                else if(moveangle <= -strafeangle)
+                {
+                    strafe_ratio = 1 - (moveangle + strafeangle) / (-90 + strafeangle);
+                }
+            }
+            if(strafe_ratio < 0)
+            {
+                currentangle_color = StrafeHUD_mixColors(autocvar_hud_panel_strafehud_angle_neutral_color, autocvar_hud_panel_strafehud_angle_overturn_color, -strafe_ratio);
+            }
+            else
+            {
+                currentangle_color = StrafeHUD_mixColors(autocvar_hud_panel_strafehud_angle_neutral_color, autocvar_hud_panel_strafehud_angle_accel_color, strafe_ratio);
+            }
+        }
+
+        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);
+        }
+    }
+}
+
+// functions to make hud elements align perfectly in the hud area
+void HUD_Panel_DrawStrafeHUD(float offset, float width, vector color, float alpha, int type, int gradientType)
+{
+    float mirror_offset, mirror_width;
+    vector size = panel_size;
+    vector mirror_size = panel_size;
+
+    float original_width = width;
+    float hiddencolor_width;
+
+    if(alpha <= 0 && type != 2 || width <= 0) return;
+
+    if(type == 2 && gradientType == 0) type = 0;
+
+    if(offset < 0)
+    {
+        mirror_width = min(fabs(offset), width);
+        mirror_offset = panel_size.x + hidden_width - fabs(offset);
+        width += offset;
+        offset = 0;
+    }
+    else
+    {
+        mirror_width = min(offset + width - panel_size.x - hidden_width, width);
+        mirror_offset = max(offset - panel_size.x - hidden_width, 0);
+    }
+    if((offset + width) > panel_size.x)
+    {
+        width = panel_size.x - offset;
+    }
+    if(mirror_offset < 0)
+    {
+        mirror_width += mirror_offset;
+        mirror_offset = 0;
+    }
+    if((mirror_offset + mirror_width) > panel_size.x)
+    {
+        mirror_width = panel_size.x - mirror_offset;
+    }
+
+    if(width < 0) width = 0;
+    if(mirror_width < 0) mirror_width = 0;
+    hiddencolor_width = original_width - width - mirror_width;
+
+    if(direction < 0) // swap mirror and non-mirror values if direction points left
+    {
+        offset += mirror_offset;
+        mirror_offset = offset - mirror_offset;
+        offset -= mirror_offset;
+
+        width += mirror_width;
+        mirror_width = width - mirror_width;
+        width -= mirror_width;
+    }
+
+    size.x = width;
+    mirror_size.x = mirror_width;
+
+    switch(type)
+    {
+        default:
+        case 0: // no styling (drawfill)
+            if(mirror_size.x > 0 && mirror_size.y > 0) drawfill(panel_pos + eX * mirror_offset, mirror_size, color, alpha, DRAWFLAG_NORMAL);
+            if(size.x > 0 && size.y > 0) drawfill(panel_pos + eX * offset, size, color, alpha, DRAWFLAG_NORMAL);
+            break;
+
+        case 1: // progress bar style
+            if(mirror_size.x > 0 && mirror_size.y > 0) HUD_Panel_DrawProgressBar(panel_pos + eX * mirror_offset, mirror_size, "progressbar", 1, 0, 0, color, alpha, DRAWFLAG_NORMAL);
+            if(size.x > 0 && size.y > 0) HUD_Panel_DrawProgressBar(panel_pos + eX * offset, size, "progressbar", 1, 0, 0, color, alpha, DRAWFLAG_NORMAL);
+            break;
+
+        case 2: // gradient style (types: 1 = left, 2 = right, 3 = both)
+            StrafeHUD_drawGradient(color, autocvar_hud_panel_strafehud_bar_neutral_color, mirror_size, original_width, mirror_offset, alpha, width + (mirror_offset == 0 ? hiddencolor_width : 0), gradientType);
+            StrafeHUD_drawGradient(color, autocvar_hud_panel_strafehud_bar_neutral_color, size, original_width, offset, alpha, (offset == 0 ? hiddencolor_width : 0), gradientType);
+    }
+}
+
+vector StrafeHUD_mixColors(vector color1, vector color2, float ratio)
+{
+    vector mixedColor;
+    if(ratio <= 0) return color1;
+    if(ratio >= 1) return color2;
+    mixedColor.x = color1.x + (color2.x - color1.x) * ratio;
+    mixedColor.y = color1.y + (color2.y - color1.y) * ratio;
+    mixedColor.z = color1.z + (color2.z - color1.z) * ratio;
+    return mixedColor;
+}
+
+void StrafeHUD_drawGradient(vector color1, vector color2, vector size, float original_width, float offset, float alpha, float gradientOffset, int gradientType)
+{
+    float color_ratio, alpha1, alpha2;
+    vector gradient_size = size;
+    alpha1 = bound(0, alpha, 1);
+    alpha2 = bound(0, autocvar_hud_panel_strafehud_bar_neutral_alpha, 1);
+    if((alpha1+alpha2) == 0) return;
+    color_ratio = alpha1/(alpha1+alpha2);
+    for(int i = 0; i < size.x; ++i)
+    {
+        float ratio, alpha_ratio, combine_ratio1, combine_ratio2;
+        gradient_size.x = size.x - i < 1 ? size.x - i : 1;
+        ratio = (i + gradientOffset) / original_width * (gradientType == 3 ? 2 : 1);
+        if(ratio > 1) ratio = 2 - ratio;
+        if(gradientType != 2) ratio = 1 - ratio;
+        alpha_ratio = alpha1 - (alpha1 - alpha2) * ratio;
+        combine_ratio1 = ratio*(1-color_ratio);
+        combine_ratio2 = (1-ratio)*color_ratio;
+        ratio = (combine_ratio1 + combine_ratio2) == 0 ? 1 : combine_ratio1/(combine_ratio1 + combine_ratio2);
+        if(alpha_ratio > 0) drawfill(panel_pos + eX * (offset + i), gradient_size, StrafeHUD_mixColors(color1, color2, ratio), alpha_ratio, DRAWFLAG_NORMAL);
+    }
+}
+
+// length unit conversion (km and miles are only included to match the GetSpeedUnit* functions)
+float GetLengthUnitFactor(int length_unit)
+{
+       switch(length_unit)
+       {
+               default:
+               case 1: return 1.0;
+               case 2: return 0.0254;
+               case 3: return 0.0254 * 0.001;
+               case 4: return 0.0254 * 0.001 * 0.6213711922;
+               case 5: return 0.0254 * 0.001 * 0.5399568035;
+       }
+}
+
+string GetLengthUnit(int length_unit)
+{
+       switch(length_unit)
+       {
+               // translator-friendly strings without the initial space
+               default:
+               case 1: return strcat(" ", _("qu"));
+               case 2: return strcat(" ", _("m"));
+               case 3: return strcat(" ", _("km"));
+               case 4: return strcat(" ", _("mi"));
+               case 5: return strcat(" ", _("nmi"));
+       }
+}
diff --git a/qcsrc/client/hud/panel/strafehud.qh b/qcsrc/client/hud/panel/strafehud.qh
new file mode 100644 (file)
index 0000000..acc43bd
--- /dev/null
@@ -0,0 +1,8 @@
+#pragma once
+#include "../panel.qh"
+
+void HUD_Panel_DrawStrafeHUD(float, float, vector, float, int, int);
+vector StrafeHUD_mixColors(vector, vector, float);
+void StrafeHUD_drawGradient(vector, vector, vector, float, float, float, float, int);
+float GetLengthUnitFactor(int);
+string GetLengthUnit(int);
index 23bbe00d89e767d5dc5c81d3d045fb75e80c1e34..c606906ab2eb45da744e7ace1b93ff6e1527876b 100644 (file)
@@ -121,6 +121,9 @@ MUTATOR_HOOKABLE(HUD_Powerups_add, EV_NO_ARGS);
 /** return true to show the physics HUD panel when optional mode is enabled */
 MUTATOR_HOOKABLE(HUD_Physics_showoptional, EV_NO_ARGS);
 
+/** return true to show the strafehud when optional mode is enabled */
+MUTATOR_HOOKABLE(HUD_StrafeHUD_showoptional, EV_NO_ARGS);
+
 /** return true to hide the score HUD panel */
 MUTATOR_HOOKABLE(HUD_Score_show, EV_NO_ARGS);
 
index 950ebcf155637cc121b775a48a56a0aff3afab6b..ee62df152f06143c8e6cb68fd60c1fad24d399a2 100644 (file)
@@ -9,6 +9,11 @@ MUTATOR_HOOKFUNCTION(cl_cts, HUD_Physics_showoptional)
        return ISGAMETYPE(CTS); // show the optional physics panel
 }
 
+MUTATOR_HOOKFUNCTION(cl_cts, HUD_StrafeHUD_showoptional)
+{
+       return ISGAMETYPE(CTS); // show the optional strafehud
+}
+
 MUTATOR_HOOKFUNCTION(cl_cts, HUD_Score_show)
 {
        return spectatee_status == -1 && ISGAMETYPE(CTS); // hide the score panel while observing
index 45d79bf0dbae75b5bf40f44293bf286643e36f97..a47ce272e49d7fd12ec5105be2bc84037146caaa 100644 (file)
@@ -156,6 +156,11 @@ MUTATOR_HOOKFUNCTION(cl_race, HUD_Physics_showoptional)
        return ISGAMETYPE(RACE); // show the optional physics panel
 }
 
+MUTATOR_HOOKFUNCTION(cl_race, HUD_StrafeHUD_showoptional)
+{
+       return ISGAMETYPE(RACE); // show the optional strafehud
+}
+
 MUTATOR_HOOKFUNCTION(cl_race, HUD_Score_show)
 {
        return spectatee_status == -1 && ISGAMETYPE(RACE); // hide the score panel while observing
index e77af222bcbad51502f4e6f521e2cd19cbca9d6b..0f9a960c92f657e0dc00ba00ff1ea3a26bdb10bd 100644 (file)
@@ -37,6 +37,7 @@
 #include <menu/xonotic/dialog_hudpanel_racetimer.qc>
 #include <menu/xonotic/dialog_hudpanel_radar.qc>
 #include <menu/xonotic/dialog_hudpanel_score.qc>
+#include <menu/xonotic/dialog_hudpanel_strafehud.qc>
 #include <menu/xonotic/dialog_hudpanel_timer.qc>
 #include <menu/xonotic/dialog_hudpanel_vote.qc>
 #include <menu/xonotic/dialog_hudpanel_weapons.qc>
index 97c1ce9c595ec920785729eff08750a2cfd471b5..2bb4ccead24a71d6df581c6db654e49acd47cb7e 100644 (file)
@@ -37,6 +37,7 @@
 #include <menu/xonotic/dialog_hudpanel_racetimer.qh>
 #include <menu/xonotic/dialog_hudpanel_radar.qh>
 #include <menu/xonotic/dialog_hudpanel_score.qh>
+#include <menu/xonotic/dialog_hudpanel_strafehud.qh>
 #include <menu/xonotic/dialog_hudpanel_timer.qh>
 #include <menu/xonotic/dialog_hudpanel_vote.qh>
 #include <menu/xonotic/dialog_hudpanel_weapons.qh>
diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_strafehud.qc b/qcsrc/menu/xonotic/dialog_hudpanel_strafehud.qc
new file mode 100644 (file)
index 0000000..0344f3f
--- /dev/null
@@ -0,0 +1,152 @@
+#include "dialog_hudpanel_strafehud.qh"
+
+#include "checkbox_string.qh"
+#include "colorpicker_string.qh"
+#include "button.qh"
+#include "slider.qh"
+#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_accel_color", cvar_defstring("hud_panel_strafehud_bar_accel_color"));
+    cvar_set("hud_panel_strafehud_bar_neutral_color", cvar_defstring("hud_panel_strafehud_bar_neutral_color"));
+    cvar_set("hud_panel_strafehud_bar_overturn_color", cvar_defstring("hud_panel_strafehud_bar_overturn_color"));
+    cvar_set("hud_panel_strafehud_angle_accel_color", cvar_defstring("hud_panel_strafehud_angle_accel_color"));
+    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_active_color", cvar_defstring("hud_panel_strafehud_switch_active_color"));
+    cvar_set("hud_panel_strafehud_switch_inactive_color", cvar_defstring("hud_panel_strafehud_switch_inactive_color"));
+    cvar_set("hud_panel_strafehud_direction_color", cvar_defstring("hud_panel_strafehud_direction_color"));
+}
+
+void XonoticHUDStrafeHUDDialog_fill(entity me)
+{
+    entity e;
+    string panelname = "strafehud";
+
+    me.TR(me);
+        me.TD(me, 1, 4, e = makeXonoticTextSlider("hud_panel_strafehud"));
+            e.addValue(e, _("Disable"), "0");
+            e.addValue(e, _("Enable"), "1");
+            e.addValue(e, _("Enable even observing"), "2");
+            e.addValue(e, _("Enable only in Race/CTS"), "3");
+            e.configureXonoticTextSliderValues(e);
+
+    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 angle centered"), "0");
+            e.addValue(e, _("Velocity angle centered"), "1");
+            e.configureXonoticTextSliderValues(e);
+    me.TR(me);
+        me.TD(me, 1, 1.4, e = makeXonoticTextLabel(0, _("StrafeHUD style:")));
+
+        me.TD(me, 1, 2.6, e = makeXonoticTextSlider("hud_panel_strafehud_style"));
+            e.addValue(e, _("no styling"), "0");
+            e.addValue(e, _("progress bar"), "1");
+            e.addValue(e, _("gradient"), "2");
+            e.configureXonoticTextSliderValues(e);
+    me.TR(me);
+        me.TD(me, 1, 1.2, e = makeXonoticCheckBoxString("1", "0", "_hud_panel_strafehud_demo", _("Demo mode")));
+
+        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_range"));
+    me.TR(me);
+        me.TD(me, 1, 1.9, e = makeXonoticButton(_("Center panel"), '0 0 0'));
+            e.onClick = StrafeHUD_CenterPanel;
+            e.onClickEntity = me;
+
+        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);
+        me.TD(me, 1, 1.9, e = makeXonoticTextLabel(0, _("Strafe bar:")));
+
+        me.TDempty(me, 0.2);
+
+        me.TD(me, 1, 1.9, e = makeXonoticTextLabel(0, _("Angle indicator:")));
+    me.TR(me);
+        me.TD(me, 1, 0.56666666, e = makeXonoticTextLabel(0, _("Neutral:")));
+        me.TDempty(me, 0.1);
+        me.TD(me, 1, 0.56666666, e = makeXonoticTextLabel(0, _("Good:")));
+        me.TDempty(me, 0.1);
+        me.TD(me, 1, 0.56666666, e = makeXonoticTextLabel(0, _("Overturn:")));
+
+        me.TDempty(me, 0.2);
+
+        me.TD(me, 1, 0.56666666, e = makeXonoticTextLabel(0, _("Neutral:")));
+        me.TDempty(me, 0.1);
+        me.TD(me, 1, 0.56666666, e = makeXonoticTextLabel(0, _("Good:")));
+        me.TDempty(me, 0.1);
+        me.TD(me, 1, 0.56666666, e = makeXonoticTextLabel(0, _("Overturn:")));
+    me.TR(me);
+        me.TD(me, 2, 0.56666666, e = makeXonoticColorpickerString("hud_panel_strafehud_bar_neutral_color", "hud_panel_strafehud_bar_neutral_color"));
+        me.TDempty(me, 0.1);
+        me.TD(me, 2, 0.56666666, e = makeXonoticColorpickerString("hud_panel_strafehud_bar_accel_color", "hud_panel_strafehud_bar_accel_color"));
+        me.TDempty(me, 0.1);
+        me.TD(me, 2, 0.56666666, e = makeXonoticColorpickerString("hud_panel_strafehud_bar_overturn_color", "hud_panel_strafehud_bar_overturn_color"));
+
+        me.TDempty(me, 0.2);
+
+        me.TD(me, 2, 0.56666666, e = makeXonoticColorpickerString("hud_panel_strafehud_angle_neutral_color", "hud_panel_strafehud_angle_neutral_color"));
+        me.TDempty(me, 0.1);
+        me.TD(me, 2, 0.56666666, e = makeXonoticColorpickerString("hud_panel_strafehud_angle_accel_color", "hud_panel_strafehud_angle_accel_color"));
+        me.TDempty(me, 0.1);
+        me.TD(me, 2, 0.56666666, e = makeXonoticColorpickerString("hud_panel_strafehud_angle_overturn_color", "hud_panel_strafehud_angle_overturn_color"));
+    me.TR(me);
+    me.TR(me);
+        me.TD(me, 1, 0.56666666, e = makeXonoticSlider(0, 1, 0.1, "hud_panel_strafehud_bar_neutral_alpha"));
+        me.TDempty(me, 0.1);
+        me.TD(me, 1, 0.56666666, e = makeXonoticSlider(0, 1, 0.1, "hud_panel_strafehud_bar_accel_alpha"));
+        me.TDempty(me, 0.1);
+        me.TD(me, 1, 0.56666666, e = makeXonoticSlider(0, 1, 0.1, "hud_panel_strafehud_bar_overturn_alpha"));
+
+        me.TDempty(me, 0.2);
+
+        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.TDempty(me, 0.2);
+
+        me.TD(me, 1, 1.9, e = makeXonoticTextLabel(0, _("Direction caps:")));
+    me.TR(me);
+        me.TD(me, 1, 0.9, e = makeXonoticTextLabel(0, _("Active:")));
+
+        me.TDempty(me, 0.2);
+
+        me.TD(me, 1, 0.9, e = makeXonoticTextLabel(0, _("Inactive:")));
+    me.TR(me);
+        me.TD(me, 2, 0.85, e = makeXonoticColorpickerString("hud_panel_strafehud_switch_active_color", "hud_panel_strafehud_switch_active_color"));
+        me.TDempty(me, 0.2);
+        me.TD(me, 2, 0.85, e = makeXonoticColorpickerString("hud_panel_strafehud_switch_inactive_color", "hud_panel_strafehud_switch_inactive_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.TR(me);
+    me.TR(me);
+        me.TD(me, 1, 0.9, e = makeXonoticSlider(0, 1, 0.1, "hud_panel_strafehud_switch_active_alpha"));
+        me.TDempty(me, 0.1);
+        me.TD(me, 1, 0.9, e = makeXonoticSlider(0, 1, 0.1, "hud_panel_strafehud_switch_inactive_alpha"));
+
+        me.TDempty(me, 0.2);
+
+        me.TD(me, 1, 1.9, e = makeXonoticSlider(0, 1, 0.1, "hud_panel_strafehud_direction_alpha"));
+}
diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_strafehud.qh b/qcsrc/menu/xonotic/dialog_hudpanel_strafehud.qh
new file mode 100644 (file)
index 0000000..f209b51
--- /dev/null
@@ -0,0 +1,13 @@
+#pragma once
+
+#include "rootdialog.qh"
+CLASS(XonoticHUDStrafeHUDDialog, XonoticRootDialog)
+    METHOD(XonoticHUDStrafeHUDDialog, fill, void(entity));
+    ATTRIB(XonoticHUDStrafeHUDDialog, title, string, _("StrafeHUD Panel"));
+    ATTRIB(XonoticHUDStrafeHUDDialog, color, vector, SKINCOLOR_DIALOG_TEAMSELECT);
+    ATTRIB(XonoticHUDStrafeHUDDialog, intendedWidth, float, 0.4);
+    ATTRIB(XonoticHUDStrafeHUDDialog, rows, float, 23.5);
+    ATTRIB(XonoticHUDStrafeHUDDialog, columns, float, 4);
+    ATTRIB(XonoticHUDStrafeHUDDialog, name, string, "HUDstrafehud");
+    ATTRIB(XonoticHUDStrafeHUDDialog, requiresConnection, float, true);
+ENDCLASS(XonoticHUDStrafeHUDDialog)
index 55f922929fde71fc0b3670ebde078e19ae7d0efc..89a61fb0d89d2fff669177c4245b5c738d0aad4c 100644 (file)
@@ -25,6 +25,7 @@
 #include "dialog_hudpanel_centerprint.qh"
 #include "dialog_hudpanel_itemstime.qh"
 #include "dialog_hudpanel_quickmenu.qh"
+#include "dialog_hudpanel_strafehud.qh"
 
 #include "dialog_settings_input_userbind.qh"
 #include "dialog_settings_bindings_reset.qh"
@@ -190,6 +191,10 @@ void MainWindow_configureMainWindow(entity me)
        i.configureDialog(i);
        me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
 
+       i = NEW(XonoticHUDStrafeHUDDialog);
+       i.configureDialog(i);
+       me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
+
        // dialogs used by settings
        me.userbindEditDialog = i = NEW(XonoticUserbindEditDialog);
        i.configureDialog(i);