ATTRIB(XonoticLanguageList, realUpperMargin, float, 0)
ATTRIB(XonoticLanguageList, columnNameOrigin, float, 0)
ATTRIB(XonoticLanguageList, columnNameSize, float, 0)
+ ATTRIB(XonoticLanguageList, columnPercentageOrigin, float, 0)
+ ATTRIB(XonoticLanguageList, columnPercentageSize, float, 0)
METHOD(XonoticLanguageList, clickListBoxItem, void(entity, float, vector)) // double click handling
METHOD(XonoticLanguageList, keyDown, float(entity, float, float, float)) // enter handling
#define LANGPARM_ID 0
#define LANGPARM_NAME 1
#define LANGPARM_NAME_LOCALIZED 2
-#define LANGPARM_COUNT 3
+#define LANGPARM_PERCENTAGE 3
+#define LANGPARM_COUNT 4
entity makeXonoticLanguageList()
{
void XonoticLanguageList_drawListBoxItem(entity me, float i, vector absSize, float isSelected)
{
- string s;
+ string s, p;
if(isSelected)
draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
+
s = me.languageParameter(me, i, LANGPARM_NAME_LOCALIZED);
- draw_Text(me.realUpperMargin * eY + (me.columnNameOrigin + (me.columnNameSize - draw_TextWidth(s, 0, me.realFontSize)) * 0.5) * eX, s, me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
+ s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize);
+ draw_Text(me.realUpperMargin * eY + me.columnNameOrigin * eX, s, me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
+
+ 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, '1 1 1', SKINALPHA_TEXT, 0);
+ }
}
void XonoticLanguageList_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
me.realFontSize_y = me.fontSize / (absSize_y * me.itemHeight);
me.realFontSize_x = me.fontSize / (absSize_x * (1 - me.controlWidth));
me.realUpperMargin = 0.5 * (1 - me.realFontSize_y);
+ me.columnPercentageSize = me.realFontSize_x * 3;
+ me.columnPercentageOrigin = 1 - me.columnPercentageSize;
me.columnNameOrigin = 0;
- me.columnNameSize = 1;
+ me.columnNameSize = me.columnPercentageOrigin;
}
void XonoticLanguageList_setSelected(entity me, float i)
continue;
bufstr_set(buf, i * LANGPARM_COUNT + LANGPARM_ID, argv(0));
bufstr_set(buf, i * LANGPARM_COUNT + LANGPARM_NAME, argv(1));
- bufstr_set(buf, i * LANGPARM_COUNT + LANGPARM_NAME_LOCALIZED, argv(2));
+ float k = strstrofs(argv(2), "(", 0);
+ if(k > 0)
+ if(substring(argv(2), strlen(argv(2)) - 1, 1) == ")")
+ {
+ string percent = substring(argv(2), k + 1, -2);
+ if(percent != "100%")
+ bufstr_set(buf, i * LANGPARM_COUNT + LANGPARM_PERCENTAGE, percent);
+ }
+ bufstr_set(buf, i * LANGPARM_COUNT + LANGPARM_NAME_LOCALIZED, (k < 0) ? argv(2) : substring(argv(2), 0, k - 1));
++i;
}
fclose(fh);