#include <menu/xonotic/statslist.qc>
#include <menu/xonotic/tab.qc>
#include <menu/xonotic/tabcontroller.qc>
+#include <menu/xonotic/textbox.qc>
#include <menu/xonotic/textlabel.qc>
#include <menu/xonotic/textslider.qc>
#include <menu/xonotic/util.qc>
#include <menu/xonotic/statslist.qh>
#include <menu/xonotic/tab.qh>
#include <menu/xonotic/tabcontroller.qh>
+#include <menu/xonotic/textbox.qh>
#include <menu/xonotic/textlabel.qh>
#include <menu/xonotic/textslider.qh>
#include <menu/xonotic/util.qh>
--- /dev/null
+#include "textbox.qh"
+
+entity makeXonoticTextBox()
+{
+ entity me;
+ me = NEW(XonoticTextBox);
+ me.configureXonoticListBox(me);
+ return me;
+}
+
+void XonoticTextBox_setText(entity me, string text)
+{
+ int buf;
+ int line = 0;
+
+ string t;
+
+ buf = buf_create();
+ for (int i = 0, n = tokenizebyseparator(text, "\n"); i < n; ++i)
+ {
+ t = substring(argv(i), 0, -1);
+ getWrappedLine_remaining = t;
+ while (getWrappedLine_remaining)
+ {
+ t = getWrappedLine(1, me.realFontSize, draw_TextWidth_WithColors);
+ bufstr_set(buf, line, t);
+ line++;
+ }
+ }
+
+ me.stringList = buf;
+ me.nItems = line+1;
+}
+
+string XonoticTextBox_getTextBoxContent(entity me, int i)
+{
+ return bufstr_get(me.stringList, i);
+}
+
+// mostly copied from playerlist
+// FIXME: is this really needed
+void XonoticTextBox_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
+{
+ me.itemAbsSize = '0 0 0';
+ SUPER(XonoticTextBox).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
+
+ me.itemAbsSize.y = absSize.y * me.itemHeight;
+ me.itemAbsSize.x = absSize.x * (1 - me.controlWidth);
+ me.realFontSize.y = me.fontSize / me.itemAbsSize.y;
+ me.realFontSize.x = me.fontSize / me.itemAbsSize.x;
+}
+
+void XonoticTextBox_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)
+{
+ string s;
+
+ s = me.getTextBoxContent(me, i);
+ draw_Text(vec2(0, 0), s, me.realFontSize, me.colorL, me.alpha, true);
+}
--- /dev/null
+#pragma once
+
+#include "listbox.qh"
+
+// slightly hacky multiline textbox with scrollbar
+CLASS(XonoticTextBox, XonoticListBox)
+ ATTRIB(XonoticTextBox, rowsPerItem, float, 1);
+ METHOD(XonoticTextBox, resizeNotify, void(entity, vector, vector, vector, vector));
+ METHOD(XonoticTextBox, drawListBoxItem, void(entity, int, vector, bool, bool));
+ ATTRIB(XonoticTextBox, allowFocusSound, float, 0);
+ ATTRIB(XonoticTextBox, alpha, float, SKINALPHA_TEXT);
+ ATTRIB(XonoticTextBox, fontSize, float, SKINFONTSIZE_NORMAL);
+ ATTRIB(XonoticTextBox, realFontSize, vector, '0 0 0');
+ ATTRIB(XonoticTextBox, itemAbsSize, vector, '0 0 0');
+ METHOD(XonoticTextBox, setText, void(entity, string));
+ METHOD(XonoticTextBox, getTextBoxContent, string(entity, int));
+ ATTRIB(XonoticTextBox, stringList, int, -1);
+ ATTRIB(XonoticTextBox, selectionDoesntMatter, bool, true);
+ENDCLASS(XonoticTextBox)
+entity makeXonoticTextBox();
+