]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Condense fonts in listboxes too, where they are influenced by translation strings.
authorRudolf Polzer <divverent@xonotic.org>
Tue, 6 Jan 2015 16:21:04 +0000 (17:21 +0100)
committerRudolf Polzer <divverent@xonotic.org>
Tue, 6 Jan 2015 16:22:02 +0000 (17:22 +0100)
qcsrc/menu/draw.qc
qcsrc/menu/draw.qh
qcsrc/menu/xonotic/gametypelist.c
qcsrc/menu/xonotic/languagelist.c
qcsrc/menu/xonotic/playerlist.c
qcsrc/menu/xonotic/weaponslist.c

index df93daa6e0bcd3cacaf8fbf57d3ffdbdb0d5ba35..afa4d49e031ea0af517e8ef80ffe812078731d2f 100644 (file)
@@ -308,6 +308,16 @@ float draw_TextWidth(string theText, float ICanHasKallerz, vector SizeThxBye)
        return v_x;
 }
 
+float draw_CondensedFontFactor(string theText, float ICanHasKallerz, vector SizeThxBye, float maxWidth)
+{
+       float w = draw_TextWidth(theText, ICanHasKallerz, SizeThxBye);
+       if (w > maxWidth) {
+               //dprintf("NOTE: label text %s too wide for label, condensed by factor %f\n", theText, maxWidth / w);
+               return maxWidth / w;
+       }
+       return 0.8;
+}
+
 float draw_clipSet;
 void draw_SetClip()
 {
index bd75795bbc0cf633cdc0f4ef2c6ee66ccf7b0ad6..9632c8fea6d27dab04b889d70be33c53747dd57b 100644 (file)
@@ -26,6 +26,7 @@ void draw_Fill(vector theOrigin, vector theSize, vector theColor, float theAlpha
 void draw_Text(vector origin, string text, vector size, vector color, float alpha, float allowColorCodes);
 void draw_CenterText(vector origin, string text, vector size, vector color, float alpha, float allowColorCodes);
 float draw_TextWidth(string text, float allowColorCodes, vector size);
+float draw_CondensedFontFactor(string theText, float ICanHasKallerz, vector SizeThxBye, float maxWidth);
 string draw_TextShortenToWidth(string text, float maxWidth, float allowColorCodes, vector size);
 float draw_TextLengthUpToWidth(string text, float maxWidth, float allowColorCodes, vector size);
 
index c7f385761d804cac0f94177a4fc8625a37748e37..e3df84467708fc9ab1c47a04410e66fa15aa21b2 100644 (file)
@@ -76,23 +76,27 @@ void XonoticGametypeList_saveCvars(entity me)
 }
 void XonoticGametypeList_drawListBoxItem(entity me, float i, vector absSize, float isSelected)
 {
-       string s;
+       string s1, s2;
 
        if(isSelected)
                draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
 
        draw_Picture(me.columnIconOrigin * eX, GameType_GetIcon(i), me.columnIconSize * eX + eY, '1 1 1', SKINALPHA_LISTBOX_SELECTED);
-       s = GameType_GetName(i);
-       draw_Text(me.realUpperMargin * eY + me.columnNameOrigin * eX, s, me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
+       s1 = GameType_GetName(i);
        
        if(_MapInfo_GetTeamPlayBool(GameType_GetID(i)))
-               s = _("teamplay");
+               s2 = _("teamplay");
        else
-               s = _("free for all");
+               s2 = _("free for all");
 
-       draw_Text(me.realUpperMargin1 * eY + (me.columnNameOrigin + 1.0 * (me.columnNameSize - draw_TextWidth(s, 0, me.realFontSize))) * eX, s, me.realFontSize, SKINCOLOR_TEXT, SKINALPHA_TEXT, 0);
-       //s = GameType_GetTeams(i);
-       //draw_Text(me.realUpperMargin1 * eY + (me.columnNameOrigin + 1.00 * (me.columnNameSize - draw_TextWidth(s, 0, me.realFontSize))) * eX, s, me.realFontSize, SKINCOLOR_TEXT, SKINALPHA_TEXT, 0);
+       vector save_fontscale = draw_fontscale;
+       float f = draw_CondensedFontFactor(strcat(s1, " ", s2), FALSE, me.realFontSize, 1);
+       draw_fontscale_x *= f;
+       vector fs = me.realFontSize;
+       fs_x *= f;
+       draw_Text(me.realUpperMargin * eY + me.columnNameOrigin * eX, s1, fs, '1 1 1', SKINALPHA_TEXT, 0);
+       draw_Text(me.realUpperMargin * eY + (me.columnNameOrigin + 1.0 * (me.columnNameSize - draw_TextWidth(s2, 0, fs))) * eX, s2, fs, SKINCOLOR_TEXT, SKINALPHA_TEXT, 0);
+       draw_fontscale = save_fontscale;
 }
 void XonoticGametypeList_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
 {
index 56d074115a4c6a788ba49d83e558739c86244cb3..24445786aea98b696c0c1c84b926d6ac29cafc2c 100644 (file)
@@ -64,14 +64,25 @@ void XonoticLanguageList_drawListBoxItem(entity me, float i, vector absSize, flo
                draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
 
        s = me.languageParameter(me, i, LANGPARM_NAME_LOCALIZED);
-       s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize);
-       draw_Text(me.realUpperMargin * eY + me.columnNameOrigin * eX, s, me.realFontSize, SKINCOLOR_TEXT, SKINALPHA_TEXT, 0);
+
+       vector save_fontscale = draw_fontscale;
+       float f = draw_CondensedFontFactor(s, FALSE, me.realFontSize, 1);
+       draw_fontscale_x *= f;
+       vector fs = me.realFontSize;
+       fs_x *= f;
+       draw_Text(me.realUpperMargin * eY + me.columnNameOrigin * eX, s, fs, SKINCOLOR_TEXT, SKINALPHA_TEXT, 0);
+       draw_fontscale = save_fontscale;
 
        p = me.languageParameter(me, i, LANGPARM_PERCENTAGE);
        if(p != "")
        {
-               p = draw_TextShortenToWidth(p, me.columnPercentageSize, 0, me.realFontSize);
-               draw_Text(me.realUpperMargin * eY + (me.columnPercentageOrigin + (me.columnPercentageSize - draw_TextWidth(p, 0, me.realFontSize))) * eX, p, me.realFontSize, SKINCOLOR_TEXT, SKINALPHA_TEXT, 0);
+               vector save_fontscale = draw_fontscale;
+               float f = draw_CondensedFontFactor(p, FALSE, me.realFontSize, 1);
+               draw_fontscale_x *= f;
+               vector fs = me.realFontSize;
+               fs_x *= f;
+               draw_Text(me.realUpperMargin * eY + (me.columnPercentageOrigin + (me.columnPercentageSize - draw_TextWidth(p, 0, fs))) * eX, p, fs, SKINCOLOR_TEXT, SKINALPHA_TEXT, 0);
+               draw_fontscale = save_fontscale;
        }
 }
 
index 315a68caa731b4c15657ca4e0d20c13b60814c60..b3ee38670a04ad41117b82f3db7c0b2ee780b974 100644 (file)
@@ -129,9 +129,9 @@ void XonoticPlayerList_drawListBoxItem(entity me, float i, vector absSize, float
        }
 
        s = draw_TextShortenToWidth(s, me.columnNameSize, 1, me.realFontSize);
-       score = draw_TextShortenToWidth(score, me.columnScoreSize, 0, me.realFontSize);
-
        draw_Text(me.realUpperMargin2 * eY + (me.columnNameOrigin + 0.00 * (me.columnNameSize - draw_TextWidth(s, 1, me.realFontSize))) * eX, s, me.realFontSize, '1 1 1', 1, 1);
+
+       score = draw_TextShortenToWidth(score, me.columnScoreSize, 0, me.realFontSize);
        draw_Text(me.realUpperMargin2 * eY + (me.columnScoreOrigin + 1.00 * (me.columnScoreSize - draw_TextWidth(score, 1, me.realFontSize))) * eX, score, me.realFontSize, rgb, 1, 0);
 }
 
index b6c536a90441cf7bf1cedc471bcc12280f786b84..8e573b8c3fecbbcbc8121ff79da1d7edc883c0d8 100644 (file)
@@ -100,7 +100,14 @@ void XonoticWeaponsList_drawListBoxItem(entity me, float i, vector absSize, floa
        string msg = e.message;
        if(e.spawnflags & WEP_FLAG_MUTATORBLOCKED)
                msg = sprintf(_("%s (mutator weapon)"), msg);
-       draw_Text(me.realUpperMargin * eY, msg, me.realFontSize, SKINCOLOR_TEXT, SKINALPHA_TEXT, 0);
+
+       vector save_fontscale = draw_fontscale;
+       float f = draw_CondensedFontFactor(msg, FALSE, me.realFontSize, 1);
+       draw_fontscale_x *= f;
+       vector fs = me.realFontSize;
+       fs_x *= f;
+       draw_Text(me.realUpperMargin * eY, msg, fs, SKINCOLOR_TEXT, SKINALPHA_TEXT, 0);
+       draw_fontscale = save_fontscale;
 }
 
 float XonoticWeaponsList_keyDown(entity me, float scan, float ascii, float shift)