2 #include "../item/label.qh"
4 entity makeXonoticTextBox()
7 me = NEW(XonoticTextBox);
8 me.configureXonoticListBox(me);
12 void XonoticTextBox_destroy(entity me)
14 if (me.stringList >= 0)
16 buf_del(me.stringList);
21 void XonoticTextBox_setText(entity me, string text)
23 if (me.stringList >= 0)
25 buf_del(me.stringList);
35 string separator = (me.escapedNewLines) ? "\\n" : "\n";
36 for (int i = 0, n = tokenizebyseparator(text, separator); i < n; ++i)
38 t = substring(argv(i), 0, -1);
39 getWrappedLine_remaining = t;
40 while (getWrappedLine_remaining)
42 t = getWrappedLine(1, me.realFontSize, (me.allowColors) ? draw_TextWidth_WithColors : draw_TextWidth_WithoutColors);
43 bufstr_set(buf, line, t);
52 string XonoticTextBox_getTextBoxLine(entity me, int i)
54 if (me.stringList >= 0)
56 return bufstr_get(me.stringList, i);
61 // mostly copied from playerlist
62 // FIXME: is this really needed
63 void XonoticTextBox_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
65 me.itemAbsSize = '0 0 0';
66 SUPER(XonoticTextBox).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
68 me.itemAbsSize.y = absSize.y * me.itemHeight;
69 me.itemAbsSize.x = absSize.x * (1 - me.controlWidth);
70 me.realFontSize.y = me.fontSize / me.itemAbsSize.y;
71 me.realFontSize.x = me.fontSize / me.itemAbsSize.x;
72 string temp = string_null;
73 for (int i = 0; i < me.nItems; ++i)
77 temp = me.getTextBoxLine(me, i);
81 temp = strcat(temp, "\n", me.getTextBoxLine(me, i));
87 void XonoticTextBox_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)
89 string s = me.getTextBoxLine(me, i);
90 vector color = (me.allowColors) ? '1 1 1' : me.colorL;
92 draw_CenterText(0.5 * eX, s, me.realFontSize, color, 1, me.allowColors);
94 draw_Text(vec2(0, 0), s, me.realFontSize, color, me.alpha, me.allowColors);