From e1710cf5fd8589b1526ace555a4efb7de04877da Mon Sep 17 00:00:00 2001 From: Des Date: Fri, 6 Dec 2024 08:54:56 -0300 Subject: [PATCH] Add center-align option, for weirdos. --- _hud_descriptions.cfg | 2 +- qcsrc/client/hud/panel/racesplits.qc | 3 ++- qcsrc/menu/xonotic/dialog_hudpanel_racesplits.qc | 5 ++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/_hud_descriptions.cfg b/_hud_descriptions.cfg index 8db185cdd..da521e4a8 100644 --- a/_hud_descriptions.cfg +++ b/_hud_descriptions.cfg @@ -187,7 +187,7 @@ seta hud_panel_racesplits_bg_border "" "if set to something else than \"\" = ove 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 "" "order the list top to bottom instead of bottom to top" -seta hud_panel_racesplits_align "" "text alignment: 0 left, 1 right" +seta hud_panel_racesplits_align "" "text alignment: 0 left, 0.5 center, 1 right" seta hud_panel_vote_pos "" "position of this base of the panel" seta hud_panel_vote_size "" "size of this panel" diff --git a/qcsrc/client/hud/panel/racesplits.qc b/qcsrc/client/hud/panel/racesplits.qc index 3cc3e51db..a1b487ead 100644 --- a/qcsrc/client/hud/panel/racesplits.qc +++ b/qcsrc/client/hud/panel/racesplits.qc @@ -22,11 +22,12 @@ vector RaceSplits_drawstring(string s, vector pos, vector sz, float a, vector fo { getWrappedLine_remaining = s; float offset = 0; + float align = bound(0, autocvar_hud_panel_racesplits_align, 1); while(getWrappedLine_remaining) { s = getWrappedLine(sz.x - offset, fontsize, stringwidth_colors); if(autocvar_hud_panel_racesplits_align) - offset = sz.x - stringwidth_colors(s, fontsize) - offset; + 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; diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_racesplits.qc b/qcsrc/menu/xonotic/dialog_hudpanel_racesplits.qc index 3a9836e8c..42b0716d2 100644 --- a/qcsrc/menu/xonotic/dialog_hudpanel_racesplits.qc +++ b/qcsrc/menu/xonotic/dialog_hudpanel_racesplits.qc @@ -17,7 +17,10 @@ void XonoticHUDRaceSplitsDialog_fill(entity 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_align", _("Align right"))); + me.TD(me, 1, 3.8/4, e = makeXonoticTextLabel(0, _("Align:"))); + me.TD(me, 1, 3.8/4, e = makeXonoticRadioButton(3, "hud_panel_racesplits_align", "0", _("Left"))); + me.TD(me, 1, 3.8/4, e = makeXonoticRadioButton(3, "hud_panel_racesplits_align", "0.5", _("Center"))); + me.TD(me, 1, 3.8/4, e = makeXonoticRadioButton(3, "hud_panel_racesplits_align", "1", _("Right"))); me.TR(me); me.TDempty(me, 0.2); me.TD(me, 1, 3.8, e = makeXonoticCheckBox(0, "hud_panel_racesplits_flip", _("Flip splits order"))); -- 2.39.2