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()
{
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);
}
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)
{
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;
}
}
}
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);
}
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)