From: Des Date: Wed, 11 Sep 2024 15:56:35 +0000 (-0300) Subject: Move race splits from infomessage to their own hud panel X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d78bba8e52edd76c526b164e4fed000982014c8c;p=xonotic%2Fxonotic-data.pk3dir.git Move race splits from infomessage to their own hud panel --- diff --git a/_hud_common.cfg b/_hud_common.cfg index 954ffbd80..a270e56a8 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 gamemodes" seta hud_panel_score 1 "enable this panel" seta hud_panel_racetimer 1 "enable this panel" +seta hud_panel_racesplits 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_racesplits_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 b18312646..b306d2116 100644 --- a/_hud_descriptions.cfg +++ b/_hud_descriptions.cfg @@ -177,6 +177,17 @@ 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_racesplits_pos "" "position of this base of the panel" +seta hud_panel_racesplits_size "" "size of this panel" +seta hud_panel_racesplits_bg "" "if set to something else than \"\" = override default background" +seta hud_panel_racesplits_bg_color "" "if set to something else than \"\" = override default panel background color" +seta hud_panel_racesplits_bg_color_team "" "override panel color with team color in team based games" +seta hud_panel_racesplits_bg_alpha "" "if set to something else than \"\" = override default panel background alpha" +seta hud_panel_racesplits_bg_border "" "if set to something else than \"\" = override default size of border around the background" +seta hud_panel_racesplits_bg_padding "" "if set to something else than \"\" = override default padding of contents from border" +seta hud_panel_racesplits_lines "" "amount of lines to show, max 50, font size will adapt accordingly" +seta hud_panel_racesplits_flip "" "1 = align the items to the right" + 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 9aaaac6f7..ee85f0467 100644 --- a/hud_luma.cfg +++ b/hud_luma.cfg @@ -178,6 +178,17 @@ seta hud_panel_racetimer_bg_alpha "" seta hud_panel_racetimer_bg_border "" seta hud_panel_racetimer_bg_padding "" +seta hud_panel_racesplits_pos "0.700000 0.190000" +seta hud_panel_racesplits_size "0.250000 0.170000" +seta hud_panel_racesplits_bg "" +seta hud_panel_racesplits_bg_color "" +seta hud_panel_racesplits_bg_color_team "" +seta hud_panel_racesplits_bg_alpha "" +seta hud_panel_racesplits_bg_border "" +seta hud_panel_racesplits_bg_padding "" +seta hud_panel_racesplits_lines "8" +seta hud_panel_racesplits_flip "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 6bc988364..af5c75191 100644 --- a/hud_luminos.cfg +++ b/hud_luminos.cfg @@ -178,6 +178,17 @@ seta hud_panel_racetimer_bg_alpha "" seta hud_panel_racetimer_bg_border "" seta hud_panel_racetimer_bg_padding "" +seta hud_panel_racesplits_pos "0.700000 0.190000" +seta hud_panel_racesplits_size "0.250000 0.170000" +seta hud_panel_racesplits_bg "" +seta hud_panel_racesplits_bg_color "" +seta hud_panel_racesplits_bg_color_team "" +seta hud_panel_racesplits_bg_alpha "" +seta hud_panel_racesplits_bg_border "" +seta hud_panel_racesplits_bg_padding "" +seta hud_panel_racesplits_lines "8" +seta hud_panel_racesplits_flip "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 c798b7564..44f643707 100644 --- a/hud_luminos_minimal.cfg +++ b/hud_luminos_minimal.cfg @@ -178,6 +178,17 @@ seta hud_panel_racetimer_bg_alpha "" seta hud_panel_racetimer_bg_border "" seta hud_panel_racetimer_bg_padding "" +seta hud_panel_racesplits_pos "0.700000 0.190000" +seta hud_panel_racesplits_size "0.250000 0.170000" +seta hud_panel_racesplits_bg "" +seta hud_panel_racesplits_bg_color "" +seta hud_panel_racesplits_bg_color_team "" +seta hud_panel_racesplits_bg_alpha "" +seta hud_panel_racesplits_bg_border "" +seta hud_panel_racesplits_bg_padding "" +seta hud_panel_racesplits_lines "8" +seta hud_panel_racesplits_flip "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 7532b807f..e5bc48492 100644 --- a/hud_luminos_minimal_xhair.cfg +++ b/hud_luminos_minimal_xhair.cfg @@ -178,6 +178,17 @@ seta hud_panel_racetimer_bg_alpha "" seta hud_panel_racetimer_bg_border "" seta hud_panel_racetimer_bg_padding "" +seta hud_panel_racesplits_pos "0.700000 0.190000" +seta hud_panel_racesplits_size "0.250000 0.170000" +seta hud_panel_racesplits_bg "" +seta hud_panel_racesplits_bg_color "" +seta hud_panel_racesplits_bg_color_team "" +seta hud_panel_racesplits_bg_alpha "" +seta hud_panel_racesplits_bg_border "" +seta hud_panel_racesplits_bg_padding "" +seta hud_panel_racesplits_lines "8" +seta hud_panel_racesplits_flip "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 80ab470df..2ec1d347a 100644 --- a/hud_luminos_old.cfg +++ b/hud_luminos_old.cfg @@ -178,6 +178,17 @@ seta hud_panel_racetimer_bg_alpha "" seta hud_panel_racetimer_bg_border "" seta hud_panel_racetimer_bg_padding "" +seta hud_panel_racesplits_pos "0.700000 0.190000" +seta hud_panel_racesplits_size "0.250000 0.170000" +seta hud_panel_racesplits_bg "" +seta hud_panel_racesplits_bg_color "" +seta hud_panel_racesplits_bg_color_team "" +seta hud_panel_racesplits_bg_alpha "" +seta hud_panel_racesplits_bg_border "" +seta hud_panel_racesplits_bg_padding "" +seta hud_panel_racesplits_lines "6" +seta hud_panel_racesplits_flip "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 2b8fe1465..a40409302 100644 --- a/hud_nexuiz.cfg +++ b/hud_nexuiz.cfg @@ -178,6 +178,17 @@ seta hud_panel_racetimer_bg_alpha "" seta hud_panel_racetimer_bg_border "" seta hud_panel_racetimer_bg_padding "" +seta hud_panel_racesplits_pos "0.700000 0.190000" +seta hud_panel_racesplits_size "0.250000 0.170000" +seta hud_panel_racesplits_bg "" +seta hud_panel_racesplits_bg_color "" +seta hud_panel_racesplits_bg_color_team "" +seta hud_panel_racesplits_bg_alpha "" +seta hud_panel_racesplits_bg_border "" +seta hud_panel_racesplits_bg_padding "" +seta hud_panel_racesplits_lines "6" +seta hud_panel_racesplits_flip "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 d1daf4197..c22064ea0 100644 --- a/qcsrc/client/hud/hud.qh +++ b/qcsrc/client/hud/hud.qh @@ -260,6 +260,7 @@ REGISTER_HUD_PANEL(TIMER, HUD_Timer, PANEL_CONFIG_MAIN | PANE REGISTER_HUD_PANEL(RADAR, HUD_Radar, PANEL_CONFIG_MAIN | PANEL_CONFIG_CANBEOFF, PANEL_SHOW_MAINGAME ) // RADAR REGISTER_HUD_PANEL(SCORE, HUD_Score, PANEL_CONFIG_MAIN | PANEL_CONFIG_CANBEOFF, PANEL_SHOW_MAINGAME | PANEL_SHOW_MINIGAME ) // SCORE REGISTER_HUD_PANEL(RACETIMER, HUD_RaceTimer, PANEL_CONFIG_MAIN | PANEL_CONFIG_CANBEOFF, PANEL_SHOW_MAINGAME ) // RACETIMER +REGISTER_HUD_PANEL(RACESPLITS, HUD_RaceSplits, PANEL_CONFIG_MAIN | PANEL_CONFIG_CANBEOFF, PANEL_SHOW_MAINGAME ) // RACESPLITS REGISTER_HUD_PANEL(VOTE, HUD_Vote, PANEL_CONFIG_MAIN | PANEL_CONFIG_CANBEOFF, PANEL_SHOW_MAINGAME | PANEL_SHOW_MINIGAME | PANEL_SHOW_MAPVOTE | PANEL_SHOW_WITH_SB) // VOTE REGISTER_HUD_PANEL(MODICONS, HUD_ModIcons, PANEL_CONFIG_MAIN | PANEL_CONFIG_CANBEOFF, PANEL_SHOW_MAINGAME | PANEL_SHOW_WITH_SB) // MODICONS REGISTER_HUD_PANEL(PRESSEDKEYS, HUD_PressedKeys, PANEL_CONFIG_MAIN | PANEL_CONFIG_CANBEOFF, PANEL_SHOW_MAINGAME ) // PRESSEDKEYS diff --git a/qcsrc/client/hud/panel/_mod.inc b/qcsrc/client/hud/panel/_mod.inc index 9f6c7fb5c..07919b6e7 100644 --- a/qcsrc/client/hud/panel/_mod.inc +++ b/qcsrc/client/hud/panel/_mod.inc @@ -13,6 +13,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 4f901379e..6b9b563ad 100644 --- a/qcsrc/client/hud/panel/_mod.qh +++ b/qcsrc/client/hud/panel/_mod.qh @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/qcsrc/client/hud/panel/infomessages.qc b/qcsrc/client/hud/panel/infomessages.qc index 5866271ef..2774d6498 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/racesplits.qc b/qcsrc/client/hud/panel/racesplits.qc new file mode 100644 index 000000000..7a62ae5f0 --- /dev/null +++ b/qcsrc/client/hud/panel/racesplits.qc @@ -0,0 +1,110 @@ +#include "racesplits.qh" +#include "racetimer.qh" // for race_checkpoint_splits +#include // for ISGAMETYPE(RACE) + +#include +#include + + +void HUD_RaceSplits_Export(int fh) +{ + // allow saving cvars that aesthetically change the panel into hud skin files + HUD_Write_Cvar("hud_panel_racesplits_flip"); +} + +vector RaceSplits_drawstring(string s, vector pos, vector sz, float a, vector fontsize) +{ + getWrappedLine_remaining = s; + float offset = 0; + while(getWrappedLine_remaining) + { + s = getWrappedLine(sz.x - offset, fontsize, stringwidth_colors); + if(autocvar_hud_panel_racesplits_flip) + offset = sz.x - stringwidth_colors(s, fontsize) - offset; + drawcolorcodedstring(pos + eX * offset, s, fontsize, a, DRAWFLAG_NORMAL); + pos.y += fontsize.y; + offset = fontsize.x; + } + pos.y += fontsize.y * 0.25; + return pos; +} + +#define RaceSplit(s) MACRO_BEGIN \ + pos = RaceSplits_drawstring(s, pos, mySize, panel_fg_alpha, fontsize); \ +MACRO_END + +void HUD_RaceSplits() +{ + if(!autocvar__hud_configure) + { + if(!autocvar_hud_panel_racesplits) return; + } + + HUD_Panel_LoadCvars(); + vector pos, mySize; + pos = panel_pos; + mySize = panel_size; + + if (autocvar_hud_panel_racesplits_dynamichud) + HUD_Scale_Enable(); + else + HUD_Scale_Disable(); + HUD_Panel_DrawBg(); + if(panel_bg_padding) + { + pos += '1 1 0' * panel_bg_padding; + mySize -= '2 2 0' * panel_bg_padding; + } + + #define HUD_RACESPLITS_MAX_NRLINES 50 // feels like twice more than enough + int nrlines = autocvar_hud_panel_racesplits_lines <= HUD_RACESPLITS_MAX_NRLINES ? autocvar_hud_panel_racesplits_lines : HUD_RACESPLITS_MAX_NRLINES; + vector fontsize = '0.8 1 0' * (mySize.y / (nrlines+2)); + string s; + if(!autocvar__hud_configure) + { + if(spectatee_status) + { + // RaceSplit(_("Splits not supported while spectating")); + } + + if(autocvar_cl_race_checkpoint_splits_hud && !spectatee_status) + { + int mlines[HUD_RACESPLITS_MAX_NRLINES]; + int ln = nrlines -1; + // 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]) + { + mlines[ln] = i; + --ln; + } + } + for (int j = 0; j < nrlines; ++j) + RaceSplit(race_checkpoint_splits[mlines[j]]); + } + } + else + { + string col[4]; col[0] = "^7"; col[1] = "^1"; col[2] = "^3"; col[3] = "^2"; + for (int j = 0; j < nrlines; ++j) + // strcat to use same string as racetimer does, ugly but it's just for hud_configure + RaceSplit(sprintf(strcat("%s",_("Intermediate %d"),"..."), col[j%4], j+1)); + } +} diff --git a/qcsrc/client/hud/panel/racesplits.qh b/qcsrc/client/hud/panel/racesplits.qh new file mode 100644 index 000000000..6f4f5b87f --- /dev/null +++ b/qcsrc/client/hud/panel/racesplits.qh @@ -0,0 +1,8 @@ +#pragma once +#include "../panel.qh" + +bool autocvar_hud_panel_racesplits; +bool autocvar_hud_panel_racesplits_dynamichud = false; +bool autocvar_hud_panel_racesplits_flip; +int autocvar_hud_panel_racesplits_lines; + diff --git a/qcsrc/common/_mod.inc b/qcsrc/common/_mod.inc index 4a45c1edb..c63e54d75 100644 --- a/qcsrc/common/_mod.inc +++ b/qcsrc/common/_mod.inc @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include diff --git a/qcsrc/common/_mod.qh b/qcsrc/common/_mod.qh index f8461f41e..b0303432e 100644 --- a/qcsrc/common/_mod.qh +++ b/qcsrc/common/_mod.qh @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include diff --git a/qcsrc/menu/xonotic/_mod.inc b/qcsrc/menu/xonotic/_mod.inc index 96287299d..e9b17130e 100644 --- a/qcsrc/menu/xonotic/_mod.inc +++ b/qcsrc/menu/xonotic/_mod.inc @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/qcsrc/menu/xonotic/_mod.qh b/qcsrc/menu/xonotic/_mod.qh index c8941bbd6..5d05cc219 100644 --- a/qcsrc/menu/xonotic/_mod.qh +++ b/qcsrc/menu/xonotic/_mod.qh @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_racesplits.qc b/qcsrc/menu/xonotic/dialog_hudpanel_racesplits.qc new file mode 100644 index 000000000..bbaa1924d --- /dev/null +++ b/qcsrc/menu/xonotic/dialog_hudpanel_racesplits.qc @@ -0,0 +1,25 @@ +#include "dialog_hudpanel_racesplits.qh" + +#include "textlabel.qh" +#include "checkbox.qh" +#include "slider.qh" + +void XonoticHUDRaceSplitsDialog_fill(entity me) +{ + entity e; + string panelname = "racesplits"; + + dialog_hudpanel_main_checkbox(me, panelname); + + dialog_hudpanel_main_settings(me, panelname); + + me.TR(me); + me.TD(me, 1, 4, e = makeXonoticTextLabel(0, _("Race Splits:"))); + me.TR(me); + me.TDempty(me, 0.2); + me.TD(me, 1, 3.8, e = makeXonoticCheckBox(0, "hud_panel_racesplits_flip", _("Flip align"))); + me.TR(me); + me.TDempty(me, 0.2); + me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Splits to keep on screen:"))); + me.TD(me, 1, 2.6, e = makeXonoticSlider(1, 50, 1, "hud_panel_racesplits_lines")); +} diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_racesplits.qh b/qcsrc/menu/xonotic/dialog_hudpanel_racesplits.qh new file mode 100644 index 000000000..99d837815 --- /dev/null +++ b/qcsrc/menu/xonotic/dialog_hudpanel_racesplits.qh @@ -0,0 +1,13 @@ +#pragma once + +#include "rootdialog.qh" +CLASS(XonoticHUDRaceSplitsDialog, XonoticRootDialog) + METHOD(XonoticHUDRaceSplitsDialog, fill, void(entity)); + ATTRIB(XonoticHUDRaceSplitsDialog, title, string, _("Race Splits Panel")); + ATTRIB(XonoticHUDRaceSplitsDialog, color, vector, SKINCOLOR_DIALOG_TEAMSELECT); + ATTRIB(XonoticHUDRaceSplitsDialog, intendedWidth, float, 0.4); + ATTRIB(XonoticHUDRaceSplitsDialog, rows, float, 15.5); + ATTRIB(XonoticHUDRaceSplitsDialog, columns, float, 4); + ATTRIB(XonoticHUDRaceSplitsDialog, name, string, "HUDracesplits"); + ATTRIB(XonoticHUDRaceSplitsDialog, requiresConnection, float, true); +ENDCLASS(XonoticHUDRaceSplitsDialog) diff --git a/qcsrc/menu/xonotic/mainwindow.qc b/qcsrc/menu/xonotic/mainwindow.qc index 039d3452f..f9ce60415 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_racesplits.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(XonoticHUDRaceSplitsDialog); + 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);