]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add horizontal padding to guide descriptions
authorotta8634 <k9wolf@pm.me>
Tue, 31 Dec 2024 16:45:22 +0000 (00:45 +0800)
committerotta8634 <k9wolf@pm.me>
Tue, 31 Dec 2024 16:45:22 +0000 (00:45 +0800)
Looked crammed beforehand.
Used `1 - 2 * this.realFontSize.x`, which seems to be used in several other places in the code.

qcsrc/menu/xonotic/guide/description.qc

index 64ab10840712638e6941d817410a76611c65a967..bf198cc8d28b2b8aedd08b8b93de6e7b15f56dee 100644 (file)
@@ -3,7 +3,7 @@
 void XonoticGuideDescription_drawListBoxItem(entity this, int i, vector absSize, bool isSelected, bool isFocused)
 {
        tokenizebyseparator(this.descriptionWrapped, "\n");
-       draw_Text(this.realUpperMargin * eY, argv(i), this.realFontSize, '1 1 1', 1, true);
+       draw_Text(this.realFontSize.x * eX + this.realUpperMargin * eY, argv(i), this.realFontSize, '1 1 1', 1, true);
 }
 
 void XonoticGuideDescription_setDescription(entity this, string desc)
@@ -16,13 +16,16 @@ void XonoticGuideDescription_setDescription(entity this, string desc)
        string currentWrapped = this.descriptionWrapped;
        if (currentWrapped)
                strunzone(currentWrapped);
+
        string wrapped = "";
+       // horizontal padding is this.realFontSize.x on both sides
+       float maxWidth = 1 - 2 * this.realFontSize.x;
        for (int i = 0, n = tokenizebyseparator(desc, "\n"); i < n; ++i)
        {
                string line = "";
                for (getWrappedLine_remaining = argv(i); getWrappedLine_remaining; )
                {
-                       string s = getWrappedLine(1, this.realFontSize, draw_TextWidth_WithColors);
+                       string s = getWrappedLine(maxWidth, this.realFontSize, draw_TextWidth_WithColors);
                        line = strcat(line, "\n", s);
                }
                wrapped = strcat(wrapped, line);