#include "textbox.qh"
#include "textlabel.qh"
#include "button.qh"
+#include "util.qh"
void Close_Clicked(entity btn, entity me)
{
- cvar_set("_termsofservice_accepted", "1");
+ LOG_INFOF("Accepted ToS version %d", _Nex_ExtResponseSystem_NewToS);
+ cvar_set("_termsofservice_accepted", ftos(_Nex_ExtResponseSystem_NewToS));
localcmd("saveconfig");
if (main.firstRunDialog.shouldShow())
- {
- main.dialogToShow = main.firstRunDialog;
- }
+ main.firstDraw = true;
Dialog_Close(btn, me);
}
void XonoticToSDialog_loadXonoticToS(entity me)
{
- string ToSText = "";
- int fh = fopen("tos.txt", FILE_READ);
- if (fh >= 0)
- {
- for (string line; (line = fgets(fh)); ) {
- if (ToSText != "")
- {
- ToSText = strcat(ToSText, "\n", line);
- }
- else
- {
- ToSText = line;
- }
+ string downloadurl = "http://maria.omaera.org/tos.txt";
+ url_single_fopen(downloadurl, FILE_READ, XonoticToS_OnGet, me);
+}
+
+void XonoticToS_OnGet(entity fh, entity me, int status)
+{
+ switch (status) {
+ case URL_READY_CLOSED:
+ {
+ break;
+ }
+ case URL_READY_ERROR:
+ {
+ me.text = strzone("Error reading ToS");
+ me.textBox.setText(me.textBox, me.text);
+ break;
}
- fclose(fh);
- }
- me.textBox.setText(me.textBox, ToSText);
+ case URL_READY_CANREAD:
+ {
+ strfree(me.text);
+ string temp = "";
+ for (string s; (s = url_fgets(fh)); )
+ {
+ if (temp != "")
+ {
+ temp = strcat(temp, "\n", s);
+ }
+ else
+ {
+ temp = s;
+ }
+ }
+ url_fclose(fh);
+ me.text = strzone(temp);
+ me.textBox.setText(me.textBox, me.text);
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
}
bool XonoticToSDialog_shouldShow()
{
- return (fexists("tos.txt") && !autocvar__termsofservice_accepted);
+ return (_Nex_ExtResponseSystem_NewToS && _Nex_ExtResponseSystem_NewToS > autocvar__termsofservice_accepted);
}
void XonoticToSDialog_fill(entity me)
{
entity e;
+ string subtitle;
+
+ if (autocvar__termsofservice_accepted > 0)
+ subtitle = _("Terms of Service have been updated. Please read them before continuing:");
+ else
+ subtitle = _("Welcome to Xonotic! Please read the following Terms of Service:");
me.TR(me);
- me.TD(me, 1, 4, e = makeXonoticTextLabel(0, _("Welcome to Xonotic! Please read the following Terms of Service")));
+ me.TD(me, 1, 5, e = makeXonoticTextLabel(0, subtitle));
e.allowWrap = 1;
me.TR(me);