From 065630b22d72eb851172ab02caec33e950b90d6f Mon Sep 17 00:00:00 2001 From: Des - Date: Tue, 13 May 2025 08:06:11 +0000 Subject: [PATCH] Move checkpoint splits from infomessages to their own HUD panel --- _hud_common.cfg | 2 + _hud_descriptions.cfg | 12 ++ hud_luma.cfg | 14 +- hud_luminos.cfg | 14 +- hud_luminos_minimal.cfg | 14 +- hud_luminos_minimal_xhair.cfg | 14 +- hud_luminos_old.cfg | 14 +- hud_nexuiz.cfg | 14 +- qcsrc/client/hud/hud.qh | 4 +- qcsrc/client/hud/panel/_mod.inc | 1 + qcsrc/client/hud/panel/_mod.qh | 1 + qcsrc/client/hud/panel/checkpoints.qc | 154 ++++++++++++++++++ qcsrc/client/hud/panel/checkpoints.qh | 8 + qcsrc/client/hud/panel/infomessages.qc | 33 ---- qcsrc/client/hud/panel/racetimer.qc | 44 +++-- qcsrc/client/main.qc | 4 + qcsrc/client/main.qh | 2 - qcsrc/menu/xonotic/_mod.inc | 1 + qcsrc/menu/xonotic/_mod.qh | 1 + .../xonotic/dialog_hudpanel_checkpoints.qc | 27 +++ .../xonotic/dialog_hudpanel_checkpoints.qh | 13 ++ qcsrc/menu/xonotic/mainwindow.qc | 5 + xonotic-client.cfg | 1 - 23 files changed, 338 insertions(+), 59 deletions(-) create mode 100644 qcsrc/client/hud/panel/checkpoints.qc create mode 100644 qcsrc/client/hud/panel/checkpoints.qh create mode 100644 qcsrc/menu/xonotic/dialog_hudpanel_checkpoints.qc create mode 100644 qcsrc/menu/xonotic/dialog_hudpanel_checkpoints.qh diff --git a/_hud_common.cfg b/_hud_common.cfg index d574fcb0ce..332994700c 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -32,6 +32,7 @@ seta hud_panel_timer 1 "enable this panel" seta hud_panel_radar 1 "enable this panel, \"2\" = also enable in non-teambased game modes" seta hud_panel_score 1 "enable this panel" seta hud_panel_racetimer 1 "enable this panel" +seta hud_panel_checkpoints 1 "enable this panel" seta hud_panel_vote 1 "enable this panel" seta hud_panel_modicons 1 "enable this panel" seta hud_panel_pressedkeys 1 "enable this panel, \"1\" = show only when spectating other players, \"2\" = show always" @@ -63,6 +64,7 @@ seta hud_panel_timer_dynamichud 1 "apply the dynamic HUD effects to t seta hud_panel_radar_dynamichud 1 "apply the dynamic HUD effects to this panel" seta hud_panel_score_dynamichud 1 "apply the dynamic HUD effects to this panel" seta hud_panel_racetimer_dynamichud 1 "apply the dynamic HUD effects to this panel" +seta hud_panel_checkpoints_dynamichud 1 "apply the dynamic HUD effects to this panel" seta hud_panel_vote_dynamichud 1 "apply the dynamic HUD effects to this panel" seta hud_panel_modicons_dynamichud 1 "apply the dynamic HUD effects to this panel" seta hud_panel_pressedkeys_dynamichud 1 "apply the dynamic HUD effects to this panel" diff --git a/_hud_descriptions.cfg b/_hud_descriptions.cfg index 56c1e9d7ca..ba05a968cf 100644 --- a/_hud_descriptions.cfg +++ b/_hud_descriptions.cfg @@ -177,6 +177,18 @@ seta hud_panel_racetimer_bg_alpha "" "if set to something else than \"\" = overr seta hud_panel_racetimer_bg_border "" "if set to something else than \"\" = override default size of border around the background" seta hud_panel_racetimer_bg_padding "" "if set to something else than \"\" = override default padding of contents from border" +seta hud_panel_checkpoints_pos "" "position of this base of the panel" +seta hud_panel_checkpoints_size "" "size of this panel" +seta hud_panel_checkpoints_bg "" "if set to something else than \"\" = override default background" +seta hud_panel_checkpoints_bg_color "" "if set to something else than \"\" = override default panel background color" +seta hud_panel_checkpoints_bg_color_team "" "override panel color with team color in team based games" +seta hud_panel_checkpoints_bg_alpha "" "if set to something else than \"\" = override default panel background alpha" +seta hud_panel_checkpoints_bg_border "" "if set to something else than \"\" = override default size of border around the background" +seta hud_panel_checkpoints_bg_padding "" "if set to something else than \"\" = override default padding of contents from border" +seta hud_panel_checkpoints_align "" "text alignment; \"0\" = left, \"0.5\" = center, \"1\" = right" +seta hud_panel_checkpoints_flip "" "order the list top to bottom instead of bottom to top" +seta hud_panel_checkpoints_fontscale "" "scale the text font by this amount" + seta hud_panel_vote_pos "" "position of this base of the panel" seta hud_panel_vote_size "" "size of this panel" seta hud_panel_vote_alreadyvoted_alpha "" "alpha of the vote dialog after you have voted" diff --git a/hud_luma.cfg b/hud_luma.cfg index 579a5bd7a8..c947e10f4a 100644 --- a/hud_luma.cfg +++ b/hud_luma.cfg @@ -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 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 25 26 " +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 25 26 27 " seta hud_configure_grid "1" seta hud_configure_grid_xsize "0.005000" @@ -178,6 +178,18 @@ seta hud_panel_racetimer_bg_alpha "" seta hud_panel_racetimer_bg_border "" seta hud_panel_racetimer_bg_padding "" +seta hud_panel_checkpoints_pos "0.700000 0.190000" +seta hud_panel_checkpoints_size "0.250000 0.170000" +seta hud_panel_checkpoints_bg "" +seta hud_panel_checkpoints_bg_color "" +seta hud_panel_checkpoints_bg_color_team "" +seta hud_panel_checkpoints_bg_alpha "" +seta hud_panel_checkpoints_bg_border "" +seta hud_panel_checkpoints_bg_padding "" +seta hud_panel_checkpoints_flip "0" +seta hud_panel_checkpoints_align "1" +seta hud_panel_checkpoints_fontscale "1" + seta hud_panel_vote_pos "0.740000 0.690000" seta hud_panel_vote_size "0.190000 0.090000" seta hud_panel_vote_bg "border_default" diff --git a/hud_luminos.cfg b/hud_luminos.cfg index 362dbf5e52..3e32a83586 100644 --- a/hud_luminos.cfg +++ b/hud_luminos.cfg @@ -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 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 25 26 " +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 25 26 27 " seta hud_configure_grid "1" seta hud_configure_grid_xsize "0.010000" @@ -178,6 +178,18 @@ seta hud_panel_racetimer_bg_alpha "" seta hud_panel_racetimer_bg_border "" seta hud_panel_racetimer_bg_padding "" +seta hud_panel_checkpoints_pos "0.670000 0.200000" +seta hud_panel_checkpoints_size "0.250000 0.170000" +seta hud_panel_checkpoints_bg "" +seta hud_panel_checkpoints_bg_color "" +seta hud_panel_checkpoints_bg_color_team "" +seta hud_panel_checkpoints_bg_alpha "" +seta hud_panel_checkpoints_bg_border "" +seta hud_panel_checkpoints_bg_padding "" +seta hud_panel_checkpoints_flip "0" +seta hud_panel_checkpoints_align "1" +seta hud_panel_checkpoints_fontscale "1" + seta hud_panel_vote_pos "0.720000 0.670000" seta hud_panel_vote_size "0.190000 0.090000" seta hud_panel_vote_bg "border_default" diff --git a/hud_luminos_minimal.cfg b/hud_luminos_minimal.cfg index 8fd1d6892b..49544db643 100644 --- a/hud_luminos_minimal.cfg +++ b/hud_luminos_minimal.cfg @@ -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 25 15 16 18 23 19 20 21 22 24 25 26 " +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 25 26 27 " seta hud_configure_grid "1" seta hud_configure_grid_xsize "0.010000" @@ -178,6 +178,18 @@ seta hud_panel_racetimer_bg_alpha "" seta hud_panel_racetimer_bg_border "" seta hud_panel_racetimer_bg_padding "" +seta hud_panel_checkpoints_pos "0.740000 0.110000" +seta hud_panel_checkpoints_size "0.250000 0.170000" +seta hud_panel_checkpoints_bg "" +seta hud_panel_checkpoints_bg_color "" +seta hud_panel_checkpoints_bg_color_team "" +seta hud_panel_checkpoints_bg_alpha "" +seta hud_panel_checkpoints_bg_border "" +seta hud_panel_checkpoints_bg_padding "" +seta hud_panel_checkpoints_flip "0" +seta hud_panel_checkpoints_align "1" +seta hud_panel_checkpoints_fontscale "1" + seta hud_panel_vote_pos "0.720000 0.890000" seta hud_panel_vote_size "0.170000 0.110000" seta hud_panel_vote_bg "" diff --git a/hud_luminos_minimal_xhair.cfg b/hud_luminos_minimal_xhair.cfg index ff7c94328e..c3ac4684f4 100644 --- a/hud_luminos_minimal_xhair.cfg +++ b/hud_luminos_minimal_xhair.cfg @@ -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 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 25 26 " +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 25 26 27 " seta hud_configure_grid "1" seta hud_configure_grid_xsize "0.010000" @@ -178,6 +178,18 @@ seta hud_panel_racetimer_bg_alpha "" seta hud_panel_racetimer_bg_border "" seta hud_panel_racetimer_bg_padding "" +seta hud_panel_checkpoints_pos "0.740000 0.110000" +seta hud_panel_checkpoints_size "0.250000 0.170000" +seta hud_panel_checkpoints_bg "" +seta hud_panel_checkpoints_bg_color "" +seta hud_panel_checkpoints_bg_color_team "" +seta hud_panel_checkpoints_bg_alpha "" +seta hud_panel_checkpoints_bg_border "" +seta hud_panel_checkpoints_bg_padding "" +seta hud_panel_checkpoints_flip "0" +seta hud_panel_checkpoints_align "1" +seta hud_panel_checkpoints_fontscale "1" + seta hud_panel_vote_pos "0.720000 0.890000" seta hud_panel_vote_size "0.170000 0.110000" seta hud_panel_vote_bg "" diff --git a/hud_luminos_old.cfg b/hud_luminos_old.cfg index ff9661362b..66e0f65dbb 100644 --- a/hud_luminos_old.cfg +++ b/hud_luminos_old.cfg @@ -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 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 25 26 " +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 25 26 27 " seta hud_configure_grid "1" seta hud_configure_grid_xsize "0.010000" @@ -178,6 +178,18 @@ seta hud_panel_racetimer_bg_alpha "" seta hud_panel_racetimer_bg_border "" seta hud_panel_racetimer_bg_padding "" +seta hud_panel_checkpoints_pos "0.660000 0.110000" +seta hud_panel_checkpoints_size "0.250000 0.170000" +seta hud_panel_checkpoints_bg "0" +seta hud_panel_checkpoints_bg_color "" +seta hud_panel_checkpoints_bg_color_team "" +seta hud_panel_checkpoints_bg_alpha "" +seta hud_panel_checkpoints_bg_border "" +seta hud_panel_checkpoints_bg_padding "" +seta hud_panel_checkpoints_flip "0" +seta hud_panel_checkpoints_align "1" +seta hud_panel_checkpoints_fontscale "1" + seta hud_panel_vote_pos "0.020000 0.650000" seta hud_panel_vote_size "0.230000 0.110000" seta hud_panel_vote_bg "" diff --git a/hud_nexuiz.cfg b/hud_nexuiz.cfg index 5c50c9adfc..846e98bba7 100644 --- a/hud_nexuiz.cfg +++ b/hud_nexuiz.cfg @@ -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 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 25 26 " +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 25 26 27 " seta hud_configure_grid "1" seta hud_configure_grid_xsize "0.010000" @@ -178,6 +178,18 @@ seta hud_panel_racetimer_bg_alpha "" seta hud_panel_racetimer_bg_border "" seta hud_panel_racetimer_bg_padding "" +seta hud_panel_checkpoints_pos "0.740000 0.420000" +seta hud_panel_checkpoints_size "0.250000 0.170000" +seta hud_panel_checkpoints_bg "0" +seta hud_panel_checkpoints_bg_color "" +seta hud_panel_checkpoints_bg_color_team "" +seta hud_panel_checkpoints_bg_alpha "" +seta hud_panel_checkpoints_bg_border "" +seta hud_panel_checkpoints_bg_padding "" +seta hud_panel_checkpoints_flip "0" +seta hud_panel_checkpoints_align "1" +seta hud_panel_checkpoints_fontscale "1" + seta hud_panel_vote_pos "0.690000 0.750000" seta hud_panel_vote_size "0.300000 0.100000" seta hud_panel_vote_bg "" diff --git a/qcsrc/client/hud/hud.qh b/qcsrc/client/hud/hud.qh index d1daf41976..edd34e87c4 100644 --- a/qcsrc/client/hud/hud.qh +++ b/qcsrc/client/hud/hud.qh @@ -278,7 +278,9 @@ REGISTER_HUD_PANEL(QUICKMENU, HUD_QuickMenu, PANEL_CONFIG_MAIN 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 REGISTER_HUD_PANEL(PICKUP, HUD_Pickup, PANEL_CONFIG_MAIN | PANEL_CONFIG_CANBEOFF, PANEL_SHOW_MAINGAME ) // PICKUP -// always add new panels to the end of list +REGISTER_HUD_PANEL(CHECKPOINTS, HUD_Checkpoints, PANEL_CONFIG_MAIN | PANEL_CONFIG_CANBEOFF, PANEL_SHOW_MAINGAME ) // CHECKPOINTS +// always add new panels to the end of list and add a comment in the form of +// "// Panel Name (#nr)" with the relative panel nr in your main panelname.qc // Because calling lots of functions in QC apparently cuts fps in half on many machines: // ---------------------- diff --git a/qcsrc/client/hud/panel/_mod.inc b/qcsrc/client/hud/panel/_mod.inc index 73f61c3a71..8a9d6baeb6 100644 --- a/qcsrc/client/hud/panel/_mod.inc +++ b/qcsrc/client/hud/panel/_mod.inc @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include diff --git a/qcsrc/client/hud/panel/_mod.qh b/qcsrc/client/hud/panel/_mod.qh index 4a6ca59c84..097ff4babe 100644 --- a/qcsrc/client/hud/panel/_mod.qh +++ b/qcsrc/client/hud/panel/_mod.qh @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include diff --git a/qcsrc/client/hud/panel/checkpoints.qc b/qcsrc/client/hud/panel/checkpoints.qc new file mode 100644 index 0000000000..f9cba39051 --- /dev/null +++ b/qcsrc/client/hud/panel/checkpoints.qc @@ -0,0 +1,154 @@ +#include "checkpoints.qh" +#include "racetimer.qh" +#include "physics.qh" + +#include +#include +#include + +// Checkpoints (#27) + +void HUD_Checkpoints_Export(int fh) +{ + // allow saving cvars that aesthetically change the panel into hud skin files + HUD_Write_Cvar("hud_panel_checkpoints_align"); + HUD_Write_Cvar("hud_panel_checkpoints_flip"); + HUD_Write_Cvar("hud_panel_checkpoints_fontscale"); +} + +const float CHECKPOINTS_SPACING = 0.25; +const float CHECKPOINTS_BASE_SIZE = 0.75; + +string demolines[10]; + +vector Checkpoints_drawstring(string s, vector pos, vector sz, float a, vector fontsize) +{ + getWrappedLine_remaining = s; + const float align = bound(0, autocvar_hud_panel_checkpoints_align, 1); + float offset = 0; + if (autocvar_hud_panel_checkpoints_flip) + { + const string s_original = s; + do + { + s = getWrappedLine(sz.x - offset, fontsize, stringwidth_colors); + if (autocvar_hud_panel_checkpoints_align) + offset = (sz.x - stringwidth_colors(s, fontsize) - offset) * align; + pos.y -= fontsize.y; + offset = fontsize.x; + } + while (getWrappedLine_remaining); + + getWrappedLine_remaining = s_original; + offset = 0; + } + const float old_pos_y = pos.y; + + do + { + s = getWrappedLine(sz.x - offset, fontsize, stringwidth_colors); + if (autocvar_hud_panel_checkpoints_align) + offset = (sz.x - stringwidth_colors(s, fontsize) - offset) * align; + drawcolorcodedstring(pos + eX * offset, s, fontsize, a, DRAWFLAG_NORMAL); + pos.y += fontsize.y; + offset = fontsize.x; + } + while (getWrappedLine_remaining); + + if (autocvar_hud_panel_checkpoints_flip) + { + pos.y = old_pos_y; + pos.y -= CHECKPOINTS_SPACING * fontsize.y; + } + else + pos.y += CHECKPOINTS_SPACING * fontsize.y; + + return pos; +} + +vector Checkpoints_Draw(int end, vector pos, vector fontsize, vector rs_fontsize) +{ + string s; + for (int j = end; j >= 0; --j) + { + s = autocvar__hud_configure ? demolines[j] : race_checkpoint_splits[j]; + if (s == "") + continue; + pos = Checkpoints_drawstring(s, pos, panel_size, panel_fg_alpha, fontsize); + if (autocvar_hud_panel_checkpoints_flip) // now check if the next line can be shown (fit) + { + if (pos.y < panel_pos.y) + break; + } + else + { + if (pos.y > panel_pos.y + panel_size.y - rs_fontsize.y) + break; + } + } + return pos; +} + +void HUD_Checkpoints() +{ + if (!autocvar__hud_configure) + { + if (!autocvar_hud_panel_checkpoints) return; + } + + HUD_Panel_LoadCvars(); + + if (autocvar_hud_panel_checkpoints_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; + } + + vector pos = panel_pos; + if (autocvar_hud_panel_checkpoints_flip) + pos.y += panel_size.y; + + const vector rs_fontsize = hud_fontsize * CHECKPOINTS_BASE_SIZE; + const vector fontsize = autocvar_hud_panel_checkpoints_fontscale > 0.125 ? rs_fontsize * autocvar_hud_panel_checkpoints_fontscale : rs_fontsize; + + int i; + if (!autocvar__hud_configure) + { + // show up to race_nextcheckpoint (not including) or everything if you are before start (0 or 254) + // (except race_laptime != 0 for race, means next is start+finish so don't show previous lap finish) + if (race_checkpoint != 0 && race_checkpoint != 254) // middle of run/race + i = race_checkpoint; + else if (ISGAMETYPE(RACE) && race_nextcheckpoint == 0) // before start, but on race, so don't keep old finish visible + i = 253; + else // before start, not on race (cts), keep old run cps visible + i = 255; + } + else + { + const string units_text = autocvar_cl_race_cptimes_showspeed_unit ? GetSpeedUnit(autocvar_hud_speed_unit) : ""; + const float speed_conv_f = GetSpeedUnitFactor(autocvar_hud_speed_unit); + for (i = 0; i < 4; ++i) + { + string timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(18.7 + i * 5.33), false); + string time_split = i == 0 ? "+0.39" : i == 1 ? "+0.0" : i == 2 ? "-0.14" : "-0.08"; + string col = i == 0 ? "^1" : i == 1 ? "^3" : "^2"; + float speed_split = speed_conv_f * (1086 + i * 51); + float speed_diff = speed_conv_f * (i == 0 ? -34 : i == 1 ? 86 : i == 2 ? 25 : 0); + string speed_color = rgb_to_hexcolor(i == 0 ? autocvar_hud_progressbar_acceleration_neg_color : autocvar_hud_progressbar_acceleration_color); + if (i == 3) + speed_color = "^3"; + demolines[i] = sprintf(strcat("%s %s", _("Checkpoint %d"), " (%s) ^7%d%s %s"), timestr, col, i+1, time_split, speed_split, units_text, sprintf("%s(%+d%s)", speed_color, speed_diff, units_text)); + } + for (; i < 10; ++i) // iust draw 10 for configuring the HUD + demolines[i] = sprintf(strcat("%s ^7", _("Checkpoint %d"), " ^7%d%s"), TIME_ENCODED_TOSTRING(TIME_ENCODE(i*9.37), false), i+1, (1100 + i*63) * speed_conv_f, units_text); + --i; + } + + pos = Checkpoints_Draw(i, pos, fontsize, rs_fontsize); +} diff --git a/qcsrc/client/hud/panel/checkpoints.qh b/qcsrc/client/hud/panel/checkpoints.qh new file mode 100644 index 0000000000..5151789e46 --- /dev/null +++ b/qcsrc/client/hud/panel/checkpoints.qh @@ -0,0 +1,8 @@ +#pragma once +#include "../panel.qh" + +bool autocvar_hud_panel_checkpoints = true; +bool autocvar_hud_panel_checkpoints_dynamichud = true; +bool autocvar_hud_panel_checkpoints_flip = false; +bool autocvar_hud_panel_checkpoints_align = true; +float autocvar_hud_panel_checkpoints_fontscale = 1; diff --git a/qcsrc/client/hud/panel/infomessages.qc b/qcsrc/client/hud/panel/infomessages.qc index 5866271ef9..2774d64983 100644 --- a/qcsrc/client/hud/panel/infomessages.qc +++ b/qcsrc/client/hud/panel/infomessages.qc @@ -1,6 +1,4 @@ #include "infomessages.qh" -#include "racetimer.qh" // for race_checkpoint_splits -#include // for ISGAMETYPE(RACE) #include #include @@ -230,37 +228,6 @@ void HUD_InfoMessages() InfoMessage(s); } } - if(autocvar_cl_race_checkpoint_splits_hud && !spectatee_status) { - int lines[6]; - int ln = 5; - // show up to race_nextcheckpoint (not including) or everything - // if you are before start (0 or 254) - // (except race_laptime != 0 for race, means next is - // start+finish so don't show previous lap finish) - int i; - if (race_checkpoint != 0 && race_checkpoint != 254) - { // middle of run/race - i = race_checkpoint; - } - else if (ISGAMETYPE(RACE) && race_nextcheckpoint == 0) - { // before start, but on race, so don't keep old finish visible - i = 253; - } - else - { // before start, not on race (cts), keep old run cps visible - i = 255; - } - for (; ln >= 0 && i >= 0; --i) - { - if (race_checkpoint_splits[i]) - { - lines[ln] = i; - --ln; - } - } - for (int j = 0; j < 6; ++j) - InfoMessage(race_checkpoint_splits[lines[j]]); - } } else { diff --git a/qcsrc/client/hud/panel/racetimer.qc b/qcsrc/client/hud/panel/racetimer.qc index 3ce7e55efc..91e4d3fec0 100644 --- a/qcsrc/client/hud/panel/racetimer.qc +++ b/qcsrc/client/hud/panel/racetimer.qc @@ -9,6 +9,7 @@ float racetimer_lastcheckpoint; string racetimer_checkpoint_comparison; string racetimer_checkpoint_time; bool racetimer_have_stored_splits; +float racetimer_have_stored_splits_player; // Race timer (#8) @@ -107,13 +108,15 @@ string MakeRaceString(int cp, float mytime, float theirtime, float othertime, fl return strcat(col, sprintf("%s (%s %s)", cpname, timestr, strcat(theirname, col, lapstr))); } -void ClearRaceSplits() { +void ClearCheckpointSplits(bool quiet) +{ bool once = true; - racetimer_lastcheckpoint = 0; - for (int i = 0; i <= 255; ++i) + bool changed_player = (racetimer_have_stored_splits_player != (current_player + 1)); + for (int i = 0; i < 256; ++i) { if(race_checkpoint_splits[i] - && autocvar_cl_race_checkpoint_splits_console) + && autocvar_cl_race_checkpoint_splits_console + && !quiet) { if(once) { @@ -123,23 +126,27 @@ void ClearRaceSplits() { LOG_HELP(race_checkpoint_splits[i]); } strfree(race_checkpoint_splits[i]); + if(changed_player) race_checkpoint_splits_speed[i] = 0; } racetimer_have_stored_splits = false; + racetimer_lastcheckpoint = 0; + if(changed_player) racetimer_have_stored_splits_player = 0; } -void StoreRaceSplits(float race_checkpoint, string forcetime, string s) { +void StoreCheckpointSplits(float race_checkpoint, string forcetime, string s) +{ // store checkpoint splits string for later printing - if (!entcs_IsSpectating(player_localnum)) - { - // 0 or 255 go to 255 as finish, strcpy does the free if needed - strcpy(race_checkpoint_splits[race_checkpoint ? race_checkpoint : 255], (forcetime != "") ? sprintf("%s %s", forcetime, s) : s); - } + if (racetimer_have_stored_splits && racetimer_have_stored_splits_player != (current_player + 1)) // we changed player + ClearCheckpointSplits(true); + // 0 or 255 go to 255 as finish, strcpy does the free if needed + strcpy(race_checkpoint_splits[race_checkpoint ? race_checkpoint : 255], (forcetime != "") ? sprintf("%s %s", forcetime, s) : s); // cache racetimer_lastcheckpoint = race_checkpoint; strcpy(racetimer_checkpoint_comparison, s); strcpy(racetimer_checkpoint_time, forcetime); racetimer_have_stored_splits = true; + racetimer_have_stored_splits_player = (current_player + 1); } void HUD_RaceTimer () @@ -197,7 +204,9 @@ void HUD_RaceTimer () str_pos = pos + eX * 0.5 * (mySize.x - stringwidth(s, false, '1 1 0' * 0.6 * mySize.y)); drawstring(str_pos, s, '1 1 0' * 0.6 * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); draw_endBoldFont(); - s = strcat("^1", sprintf(_("Checkpoint %d"), 1), " (+15.42)"); + float speed_conversion_factor = GetSpeedUnitFactor(autocvar_hud_speed_unit); + string units_text = autocvar_cl_race_cptimes_showspeed_unit ? GetSpeedUnit(autocvar_hud_speed_unit) : ""; + s = strcat("^1", sprintf(_("Checkpoint %d"), 1), " (+15.42)", autocvar_cl_race_cptimes_showspeed ? sprintf(" ^7%d%s %s(%+d%s)", 345 * speed_conversion_factor, units_text, rgb_to_hexcolor(autocvar_hud_progressbar_acceleration_color), 123 * speed_conversion_factor, units_text) : ""); str_pos = pos + vec2(0.5 * (mySize.x - stringwidth(s, true, '1 1 0' * 0.2 * mySize.y)), 0.6 * mySize.y); drawcolorcodedstring(str_pos, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha, DRAWFLAG_NORMAL); s = sprintf(_("PENALTY: %.1f (%s)"), 2, _("missing a checkpoint")); @@ -214,7 +223,8 @@ void HUD_RaceTimer () { if(race_checkpoint != 254 && race_time != 0) { - if (race_checkpoint == racetimer_lastcheckpoint) + if (race_checkpoint == racetimer_lastcheckpoint // same cp *and* player + && racetimer_have_stored_splits_player == (current_player + 1)) { // use cached strings s = racetimer_checkpoint_comparison; @@ -222,6 +232,9 @@ void HUD_RaceTimer () } else { + if (racetimer_have_stored_splits && racetimer_have_stored_splits_player != (current_player + 1)) // we changed player + ClearCheckpointSplits(true); + // build checkpoint split strings if(race_time && race_previousbesttime) s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, ((race_mypreviousbesttime) ? TIME_DECODE(race_time) - TIME_DECODE(race_mypreviousbesttime) : 0), 0, race_previousbestname); @@ -250,19 +263,18 @@ void HUD_RaceTimer () { race_checkpoint_splits_speed[race_checkpoint] = speed; } - } if(race_time) forcetime = TIME_ENCODED_TOSTRING(race_time, false); - StoreRaceSplits(race_checkpoint, forcetime, s); + StoreCheckpointSplits(race_checkpoint, forcetime, s); } } else { // clean cp splits on start if(racetimer_have_stored_splits && race_time == 0) - ClearRaceSplits(); + ClearCheckpointSplits(false); } } else @@ -320,7 +332,7 @@ void HUD_RaceTimer () else { if(racetimer_have_stored_splits && (race_time == 0 || time < STAT(GAMESTARTTIME))) - ClearRaceSplits(); + ClearCheckpointSplits(false); if(race_mycheckpointtime) { diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index e2a192dfb2..d534b89108 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -109,6 +109,10 @@ void CSQC_Init(float apilevel, string enginename, float engineversion) cvar_settemp("_scoreboard_team_selection_available", "1"); cvar_set("_scoreboard_team_selection", "0"); // in case it has been left set to 1 + // XONRELEASE: default values for <= 0.8.6 can be removed after next release + registercvar("hud_panel_checkpoints_pos", "0.700000 0.190000"); + registercvar("hud_panel_checkpoints_size", "0.250000 0.170000"); + gametype = NULL; postinit = false; diff --git a/qcsrc/client/main.qh b/qcsrc/client/main.qh index 9a80347dc8..111aa87f64 100644 --- a/qcsrc/client/main.qh +++ b/qcsrc/client/main.qh @@ -17,13 +17,11 @@ bool autocvar_developer_csqcentities; // or the release after it to support the old-stable release // this can't be done now as players would lack these from their configs then bool autocvar_cl_race_checkpoint_splits_console; -bool autocvar_cl_race_checkpoint_splits_hud; bool autocvar_cl_race_cptimes_showspeed = false; bool autocvar_cl_race_cptimes_showspeed_unit = true; float autocvar_cl_race_cptimes_namesize = 10; #else AUTOCVAR_SAVE(cl_race_checkpoint_splits_console, bool, 1, "print checkpoint splits to console"); -AUTOCVAR_SAVE(cl_race_checkpoint_splits_hud, bool, 1, "show race checkpoint splits on HUD in infomessages"); AUTOCVAR_SAVE(cl_race_cptimes_showspeed, bool, 0, "show race checkpoint speed (NOTE: ignores vertical speed)"); AUTOCVAR_SAVE(cl_race_cptimes_showspeed_unit, bool, 1, "show race checkpoint speed units"); AUTOCVAR_SAVE(cl_race_cptimes_namesize, float, 10, "maximum player name length in race checkpoint messages"); diff --git a/qcsrc/menu/xonotic/_mod.inc b/qcsrc/menu/xonotic/_mod.inc index 1382a75195..b1de3b47fb 100644 --- a/qcsrc/menu/xonotic/_mod.inc +++ b/qcsrc/menu/xonotic/_mod.inc @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/qcsrc/menu/xonotic/_mod.qh b/qcsrc/menu/xonotic/_mod.qh index ab2dd6c5b2..18ac74a5e0 100644 --- a/qcsrc/menu/xonotic/_mod.qh +++ b/qcsrc/menu/xonotic/_mod.qh @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_checkpoints.qc b/qcsrc/menu/xonotic/dialog_hudpanel_checkpoints.qc new file mode 100644 index 0000000000..be6ac2aa95 --- /dev/null +++ b/qcsrc/menu/xonotic/dialog_hudpanel_checkpoints.qc @@ -0,0 +1,27 @@ +#include "dialog_hudpanel_checkpoints.qh" + +#include "textlabel.qh" +#include "checkbox.qh" +#include "slider.qh" +#include "radiobutton.qh" + +void XonoticHUDCheckpointsDialog_fill(entity me) +{ + entity e; + string panelname = "checkpoints"; + + dialog_hudpanel_main_checkbox(me, panelname); + + dialog_hudpanel_main_settings(me, panelname); + + me.TR(me); + me.TD(me, 1, 1.4, e = makeXonoticTextLabel(0, _("Font scale:"))); + me.TD(me, 1, 2.6, e = makeXonoticSlider(0.8, 2, 0.1, "hud_panel_checkpoints_fontscale")); + me.TR(me); + me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Align:"))); + me.TD(me, 1, 1, e = makeXonoticRadioButton(3, "hud_panel_checkpoints_align", "0", _("Left"))); + me.TD(me, 1, 1, e = makeXonoticRadioButton(3, "hud_panel_checkpoints_align", "0.5", _("Center"))); + me.TD(me, 1, 1, e = makeXonoticRadioButton(3, "hud_panel_checkpoints_align", "1", _("Right"))); + me.TR(me); + me.TD(me, 1, 4, e = makeXonoticCheckBox(0, "hud_panel_checkpoints_flip", _("Flip checkpoint order"))); +} diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_checkpoints.qh b/qcsrc/menu/xonotic/dialog_hudpanel_checkpoints.qh new file mode 100644 index 0000000000..621470e2c3 --- /dev/null +++ b/qcsrc/menu/xonotic/dialog_hudpanel_checkpoints.qh @@ -0,0 +1,13 @@ +#pragma once + +#include "rootdialog.qh" +CLASS(XonoticHUDCheckpointsDialog, XonoticRootDialog) + METHOD(XonoticHUDCheckpointsDialog, fill, void(entity)); + ATTRIB(XonoticHUDCheckpointsDialog, title, string, _("Checkpoints Panel")); + ATTRIB(XonoticHUDCheckpointsDialog, color, vector, SKINCOLOR_DIALOG_TEAMSELECT); + ATTRIB(XonoticHUDCheckpointsDialog, intendedWidth, float, 0.4); + ATTRIB(XonoticHUDCheckpointsDialog, rows, float, 15.5); + ATTRIB(XonoticHUDCheckpointsDialog, columns, float, 4); + ATTRIB(XonoticHUDCheckpointsDialog, name, string, "HUDcheckpoints"); + ATTRIB(XonoticHUDCheckpointsDialog, requiresConnection, float, true); +ENDCLASS(XonoticHUDCheckpointsDialog) diff --git a/qcsrc/menu/xonotic/mainwindow.qc b/qcsrc/menu/xonotic/mainwindow.qc index 039d3452fd..131dfed582 100644 --- a/qcsrc/menu/xonotic/mainwindow.qc +++ b/qcsrc/menu/xonotic/mainwindow.qc @@ -15,6 +15,7 @@ #include "dialog_hudpanel_powerups.qh" #include "dialog_hudpanel_pressedkeys.qh" #include "dialog_hudpanel_racetimer.qh" +#include "dialog_hudpanel_checkpoints.qh" #include "dialog_hudpanel_radar.qh" #include "dialog_hudpanel_score.qh" #include "dialog_hudpanel_timer.qh" @@ -135,6 +136,10 @@ void MainWindow_configureMainWindow(entity me) i.configureDialog(i); me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z); + i = NEW(XonoticHUDCheckpointsDialog); + i.configureDialog(i); + me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z); + i = NEW(XonoticHUDRadarDialog); i.configureDialog(i); me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z); diff --git a/xonotic-client.cfg b/xonotic-client.cfg index 7dd42f8b50..0cb0370f00 100644 --- a/xonotic-client.cfg +++ b/xonotic-client.cfg @@ -733,7 +733,6 @@ seta cl_race_cptimes_showspeed 0 "show race checkpoint speed (NOTE: ignores vert seta cl_race_cptimes_showspeed_unit 1 "show race checkpoint speed units" seta cl_race_cptimes_namesize 10 "maximum length of player names in race checkpoint messages" seta cl_race_checkpoint_splits_console 1 "print race checkpoint splits to console" -seta cl_race_checkpoint_splits_hud 1 "show race checkpoint splits on HUD in infomessages" seta cl_autoswitch_cts -1 "\"-1\" = fallback to the behavior of cl_autoswitch, \"0\" = never autoswitch in CTS, \"1\" = always autoswitch in CTS (regardless of weapon priority)" -- 2.39.5