From: terencehill Date: Wed, 12 Jun 2024 23:36:47 +0000 (+0200) Subject: Menu: allow customizing line spacing in wrapped TextLabel text. Improve appearance... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=afad41ba80e3f90d0b1c4b2011a94e3882d06698;p=xonotic%2Fxonotic-data.pk3dir.git Menu: allow customizing line spacing in wrapped TextLabel text. Improve appearance of a couple long messages. The language change warning message is now an unique string, removing a possible source of confusion for translators since the first part of the message ended with a coma --- diff --git a/qcsrc/menu/item/label.qc b/qcsrc/menu/item/label.qc index f7a782dab..8d297e7a4 100644 --- a/qcsrc/menu/item/label.qc +++ b/qcsrc/menu/item/label.qc @@ -75,7 +75,10 @@ draw_fontscale = dfs; - me.realOrigin_y = 0.5 * (1 - lines * me.realFontSize.y); + float text_height = lines * me.realFontSize.y; + if (lines > 1) + text_height += (lines - 1) * me.realFontSize.y * me.allowWrap_spacing; + me.realOrigin_y = 0.5 * (1 - text_height); } if (me.isBold) draw_endBoldFont(); @@ -150,7 +153,7 @@ if (me.allowColors) t = getWrappedLine((1 - me.keepspaceLeft - me.keepspaceRight), fs, draw_TextWidth_WithColors); else t = getWrappedLine((1 - me.keepspaceLeft - me.keepspaceRight), fs, draw_TextWidth_WithoutColors); draw_Text(o, t, fs, me.colorL, me.alpha, me.allowColors); - o.y += me.realFontSize.y; + o.y += me.realFontSize.y * (1 + me.allowWrap_spacing); } } else diff --git a/qcsrc/menu/item/label.qh b/qcsrc/menu/item/label.qh index 2439d1d5b..8a81ec351 100644 --- a/qcsrc/menu/item/label.qh +++ b/qcsrc/menu/item/label.qh @@ -26,7 +26,11 @@ CLASS(Label, MenuItem) ATTRIB(Label, disabled, float, 0); ATTRIB(Label, disabledAlpha, float, 0.3); ATTRIB(Label, textEntity, entity); + // if allowWrap is enabled text is wrapped on multiple lines and can't be condensed; + // lines are centered vertically and are allowed to extend outside the item box + // so there should be some free space above and below the item ATTRIB(Label, allowWrap, float, 0); + ATTRIB(Label, allowWrap_spacing, float, 0); ATTRIB(Label, recalcPos, float, 0); ATTRIB(Label, condenseFactor, float, 1); ATTRIB(Label, overrideRealOrigin, vector, '0 0 0'); diff --git a/qcsrc/menu/xonotic/dialog_firstrun.qc b/qcsrc/menu/xonotic/dialog_firstrun.qc index c45256c52..f17699b37 100644 --- a/qcsrc/menu/xonotic/dialog_firstrun.qc +++ b/qcsrc/menu/xonotic/dialog_firstrun.qc @@ -43,6 +43,7 @@ void XonoticFirstRunDialog_fill(entity me) me.TDempty(me, 1); me.TD(me, 2, 4, e = makeXonoticTextLabel(0, _("Welcome to Xonotic, please select your language preference and enter your player name to get started. You can change these options later through the menu system."))); e.allowWrap = 1; + e.allowWrap_spacing = 0.5; me.TR(me); me.TR(me); diff --git a/qcsrc/menu/xonotic/dialog_settings_user_languagewarning.qc b/qcsrc/menu/xonotic/dialog_settings_user_languagewarning.qc index 3cbd15bb4..be41cc20d 100644 --- a/qcsrc/menu/xonotic/dialog_settings_user_languagewarning.qc +++ b/qcsrc/menu/xonotic/dialog_settings_user_languagewarning.qc @@ -7,9 +7,11 @@ void XonoticLanguageWarningDialog_fill(entity me) { entity e; me.TR(me); - me.TD(me, 1, 4, e = makeXonoticTextLabel(0, _("While connected language changes will be applied only to the menu,"))); + me.TD(me, 2, 4, e = makeXonoticTextLabel(0, + _("While connected language changes will be applied only to the menu, full language changes will take effect starting from the next game"))); + e.allowWrap = 1; + e.allowWrap_spacing = 0.5; me.TR(me); - me.TD(me, 1, 4, e = makeXonoticTextLabel(0, _("full language changes will take effect starting from the next game"))); me.TR(me); me.TR(me); // reconnect command doesn't work properly, otherwise it would replace disconnect diff --git a/qcsrc/menu/xonotic/dialog_settings_user_languagewarning.qh b/qcsrc/menu/xonotic/dialog_settings_user_languagewarning.qh index ba5c8a5d1..7bfbdadce 100644 --- a/qcsrc/menu/xonotic/dialog_settings_user_languagewarning.qh +++ b/qcsrc/menu/xonotic/dialog_settings_user_languagewarning.qh @@ -6,6 +6,6 @@ CLASS(XonoticLanguageWarningDialog, XonoticDialog) ATTRIB(XonoticLanguageWarningDialog, title, string, _("Warning")); ATTRIB(XonoticLanguageWarningDialog, color, vector, SKINCOLOR_DIALOG_HUDCONFIRM); ATTRIB(XonoticLanguageWarningDialog, intendedWidth, float, 0.6); - ATTRIB(XonoticLanguageWarningDialog, rows, float, 5); + ATTRIB(XonoticLanguageWarningDialog, rows, float, 4); ATTRIB(XonoticLanguageWarningDialog, columns, float, 4); ENDCLASS(XonoticLanguageWarningDialog)