}
case URL_READY_ERROR:
{
- me.text = strzone("Error reading ToS");
- me.textBox.setText(me.textBox, me.text);
+ me.textBox.setText(me.textBox, "Error reading ToS");
break;
}
case URL_READY_CANREAD:
{
- strfree(me.text);
string temp = "";
for (string s; (s = url_fgets(fh)); )
{
temp = s;
}
url_fclose(fh);
- me.text = strzone(temp);
- me.textBox.setText(me.textBox, me.text);
+ me.textBox.setText(me.textBox, temp);
break;
}
default:
ATTRIB(XonoticServerToSTab, rows, float, 17);
ATTRIB(XonoticServerToSTab, columns, float, 6.2);
- ATTRIB(XonoticServerToSTab, text, string);
ATTRIB(XonoticServerToSTab, textBox, entity);
ENDCLASS(XonoticServerToSTab)
entity makeXonoticServerToSTab();
}
case URL_READY_ERROR:
{
- me.text = strzone("Error reading ToS");
- me.textBox.setText(me.textBox, me.text);
+ me.textBox.setText(me.textBox, "Error reading ToS");
break;
}
case URL_READY_CANREAD:
{
- strfree(me.text);
string temp = "";
for (string s; (s = url_fgets(fh)); )
{
temp = s;
}
url_fclose(fh);
- me.text = strzone(temp);
- me.textBox.setText(me.textBox, me.text);
+ me.textBox.setText(me.textBox, temp);
break;
}
default:
ATTRIB(XonoticToSDialog, columns, float, 6.2);
ATTRIB(XonoticToSDialog, name, string, "TermsOfService");
- ATTRIB(XonoticToSDialog, text, string);
ATTRIB(XonoticToSDialog, textBox, entity);
ATTRIB(XonoticToSDialog, closable, float, 0);
buf_del(me.stringList);
me.stringList = -1;
}
+ strfree(me.text);
}
-void XonoticTextBox_setText(entity me, string text)
+void XonoticTextBox_setText(entity me, string txt)
{
if (me.stringList >= 0)
{
me.stringList = -1;
}
+ strcpy(me.text, txt);
+
int buf;
int line = 0;
buf = buf_create();
string separator = (me.escapedNewLines) ? "\\n" : "\n";
- for (int i = 0, n = tokenizebyseparator(text, separator); i < n; ++i)
+ for (int i = 0, n = tokenizebyseparator(txt, separator); i < n; ++i)
{
t = substring(argv(i), 0, -1);
getWrappedLine_remaining = t;
return string_null;
}
-// 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';
me.itemAbsSize.x = absSize.x * (1 - me.controlWidth);
me.realFontSize.y = me.fontSize / me.itemAbsSize.y;
me.realFontSize.x = me.fontSize / me.itemAbsSize.x;
- string temp = string_null;
- for (int i = 0; i < me.nItems; ++i)
- {
- if (!temp)
- {
- temp = me.getTextBoxLine(me, i);
- }
- else
- {
- temp = strcat(temp, "\n", me.getTextBoxLine(me, i));
- }
- }
- me.setText(me, temp);
+ me.setText(me, strcat(me.text)); // rewrap
}
void XonoticTextBox_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)