]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/dialog_termsofservice.qc
Restore white tos text
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / dialog_termsofservice.qc
1 #include "dialog_termsofservice.qh"
2
3 #include "../menu.qh"
4 #include "mainwindow.qh"
5 #include "dialog_firstrun.qh"
6 #include "textbox.qh"
7 #include "textlabel.qh"
8 #include "button.qh"
9 #include "util.qh"
10
11 void Close_Clicked(entity btn, entity me)
12 {
13         LOG_INFOF("Accepted ToS version %d", _Nex_ExtResponseSystem_NewToS);
14         cvar_set("_termsofservice_accepted", ftos(_Nex_ExtResponseSystem_NewToS));
15         localcmd("saveconfig\n");
16         if (main.firstRunDialog.shouldShow())
17                 main.firstDraw = true;
18         Dialog_Close(btn, me);
19 }
20
21 void DontAccept_Clicked(entity btn, entity me)
22 {
23         localcmd("quit\n");
24 }
25
26 void XonoticToSDialog_loadXonoticToS(entity me)
27 {
28         url_single_fopen(termsofservice_url, FILE_READ, XonoticToS_OnGet, me);
29 }
30
31 void XonoticToS_OnGet(entity fh, entity me, int status)
32 {
33         switch (status) {
34                 case URL_READY_CLOSED:
35                 {
36                         break;
37                 }
38                 case URL_READY_ERROR:
39                 {
40                         me.text = strzone("Error reading ToS");
41                         me.textBox.setText(me.textBox, me.text);
42                         break;
43                 }
44                 case URL_READY_CANREAD:
45                 {
46                         strfree(me.text);
47                         string temp = "";
48                         for (string s; (s = url_fgets(fh)); )
49                         {
50                                 if (temp != "")
51                                         temp = strcat(temp, "\n", s);
52                                 else
53                                         temp = s;
54                         }
55                         url_fclose(fh);
56                         me.text = strzone(temp);
57                         me.textBox.setText(me.textBox, me.text);
58                         break;
59                 }
60                 default:
61                 {
62                         break;
63                 }
64         }
65 }
66
67 bool XonoticToSDialog_shouldShow()
68 {
69         return (_Nex_ExtResponseSystem_NewToS && _Nex_ExtResponseSystem_NewToS > autocvar__termsofservice_accepted);
70 }
71
72 void XonoticToSDialog_fill(entity me)
73 {
74         entity e;
75         string subtitle;
76
77         if (autocvar__termsofservice_accepted > 0)
78                 subtitle = _("Terms of Service have been updated. Please read them before continuing:");
79         else
80                 subtitle = _("Welcome to Xonotic! Please read the following Terms of Service:");
81
82         me.TR(me);
83                 me.TD(me, 1, 5, e = makeXonoticTextLabel(0, subtitle));
84                 e.allowWrap = 1;
85
86         me.TR(me);
87         me.TR(me);
88                 me.TD(me, me.rows - 4, me.columns, me.textBox = makeXonoticTextBox());
89                         me.textBox.allowColors = true;
90
91         me.TR(me);
92         me.gotoRC(me, me.rows - 1, 0);
93
94                 me.TD(me, 1, me.columns/2, e = makeXonoticButton(_("Accept"), '0 1 0'));
95                 e.onClick = Close_Clicked;
96                 e.onClickEntity = me;
97
98                 me.TD(me, 1, me.columns/2, e = makeXonoticButton(_("Don't accept (quit the game)"), '1 0 0'));
99                 e.onClick = DontAccept_Clicked;
100                 e.onClickEntity = me;
101 }
102