]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
WIP: ToS versioning done
authorz411 <z411@omaera.org>
Wed, 24 Nov 2021 05:23:13 +0000 (02:23 -0300)
committerz411 <z411@omaera.org>
Wed, 24 Nov 2021 05:23:13 +0000 (02:23 -0300)
qcsrc/menu/xonotic/.util.qc.kate-swp [deleted file]
qcsrc/menu/xonotic/dialog_termsofservice.qc
qcsrc/menu/xonotic/dialog_termsofservice.qh
qcsrc/menu/xonotic/mainwindow.qc
qcsrc/menu/xonotic/mainwindow.qh
qcsrc/menu/xonotic/util.qc
qcsrc/menu/xonotic/util.qh

diff --git a/qcsrc/menu/xonotic/.util.qc.kate-swp b/qcsrc/menu/xonotic/.util.qc.kate-swp
deleted file mode 100644 (file)
index 4f3893a..0000000
Binary files a/qcsrc/menu/xonotic/.util.qc.kate-swp and /dev/null differ
index c0c26c9fd62d523714cf4e6a0bdc4ab9a13c647e..568fdedfc044f352cf3993ec57fd095867c2e3ec 100644 (file)
 
 void Close_Clicked(entity btn, entity me)
 {
-    cvar_set("_termsofservice_accepted", "1");
+       LOG_INFO("Setting _termsofservice_accepted to ", _Nex_ExtResponseSystem_NewToS);
+    cvar_set("_termsofservice_accepted", _Nex_ExtResponseSystem_NewToS);
     localcmd("saveconfig");
     if (main.firstRunDialog.shouldShow())
     {
-        main.dialogToShow = main.firstRunDialog;
+               main.firstDraw = true;
     }
     Dialog_Close(btn, me);
 }
@@ -26,24 +27,6 @@ void DontAccept_Clicked(entity btn, entity 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;
-            }
-        }
-        fclose(fh);
-    }
-    LOG_INFO("Test: ", _Nex_ExtResponseSystem_TOS, ": ", ftos(XonoticToSDialog_shouldShow()));
-    me.textBox.setText(me.textBox, ToSText);*/
        string downloadurl = "http://maria.omaera.org/tos.txt";
        url_single_fopen(downloadurl, FILE_READ, XonoticToS_OnGet, me);
 }
@@ -90,9 +73,8 @@ void XonoticToS_OnGet(entity fh, entity me, int status)
 
 bool XonoticToSDialog_shouldShow()
 {
-    //return (_Nex_ExtResponseSystem_TOS && !autocvar__termsofservice_accepted);
        LOG_INFO("newtos value: ", _Nex_ExtResponseSystem_NewToS);
-       return (_Nex_ExtResponseSystem_NewToS != "");
+       return (_Nex_ExtResponseSystem_NewToS != autocvar__termsofservice_accepted);
 }
 
 void XonoticToSDialog_fill(entity me)
index d901d032727eeb6a2c567f2c42c5e3b12aa456f5..50e22cf91e3d6a522e81c6533a7d9dd9e8ad2b94 100644 (file)
@@ -1,5 +1,7 @@
 #pragma once
 
+string autocvar__termsofservice_accepted;
+
 #include "rootdialog.qh"
 CLASS(XonoticToSDialog, XonoticRootDialog)
        METHOD(XonoticToSDialog, shouldShow, bool());
index 2347dbef3ac35ddfd6833235f1f3654d7c392077..dba0a661de5b9779979aca4098006d8684a3baab 100644 (file)
@@ -59,10 +59,13 @@ void MainWindow_draw(entity me)
 {
        SUPER(MainWindow).draw(me);
 
-       if(me.dialogToShow)
-       {
-               DialogOpenButton_Click_withCoords(NULL, me.dialogToShow, '0 0 0', eX * conwidth + eY * conheight);
-               me.dialogToShow = NULL;
+       if (me.firstDraw) {
+               if (me.ToSDialog.shouldShow())
+                       DialogOpenButton_Click_withCoords(NULL, me.ToSDialog, '0 0 0', eX * conwidth + eY * conheight);
+               else if(me.firstRunDialog.shouldShow())
+                       DialogOpenButton_Click_withCoords(NULL, me.firstRunDialog, '0 0 0', eX * conwidth + eY * conheight);
+               
+               me.firstDraw = false;
        }
 
        //-------------------------------------
@@ -338,13 +341,4 @@ void MainWindow_configureMainWindow(entity me)
 
        me.initializeDialog(me, n);
        me.disconnectDialogVisibility = 1;
-
-    if (me.ToSDialog.shouldShow())
-    {
-        me.dialogToShow = me.ToSDialog;
-    }
-       else if(me.firstRunDialog.shouldShow())
-    {
-               me.dialogToShow = me.firstRunDialog;
-    }
 }
index 28658949b55339533e9728ee0774aeb143b59978..82e126a9f0f41025c7cf7c7ae725d0d51020abe4 100644 (file)
@@ -21,7 +21,7 @@ CLASS(MainWindow, ModalController)
        ATTRIB(MainWindow, languageWarningDialog, entity);
        ATTRIB(MainWindow, mainNexposee, entity);
        ATTRIB(MainWindow, fadedAlpha, float, SKINALPHA_BEHIND);
-       ATTRIB(MainWindow, dialogToShow, entity);
+       ATTRIB(MainWindow, firstDraw, bool, true);
        ATTRIB(MainWindow, demostartconfirmDialog, entity);
        ATTRIB(MainWindow, demotimeconfirmDialog, entity);
        ATTRIB(MainWindow, resetDialog, entity);
index fc0364c9eb9e63ee9c36848c598b3b5b70dc9cf0..b6d35044707db120b7e498e2732d9da06701e68e 100644 (file)
@@ -307,10 +307,6 @@ void URI_Get_Callback(float id, float status, string data)
        {
                UpdateNotification_URI_Get_Callback(id, status, data);
        }
-       else if (id == URI_GET_TOS)
-       {
-               TOS_URI_Get_Callback(id, status, data);
-       }
        else
        {
                LOG_INFOF("Received HTTP request data for an invalid id %d.", id);
@@ -444,10 +440,8 @@ void UpdateNotification_URI_Get_Callback(float id, float status, string data)
        
        if(un_tosversion != "")
        {
-               if(autocvar__termsofservice_accepted != un_tosversion) {
-                       _Nex_ExtResponseSystem_NewToS = strzone(un_tosversion);
-                       LOG_INFO("Setting netwos value to ", un_tosversion);
-               }
+               _Nex_ExtResponseSystem_NewToS = strzone(un_tosversion);
+               LOG_INFO("Setting netwos value to ", un_tosversion);
        }
 
        if(un_bannedservers != "")
@@ -475,24 +469,6 @@ void UpdateNotification_URI_Get_Callback(float id, float status, string data)
        }
 }
 
-void TOS_URI_Get_Callback(float id, float status, string data)
-{
-       if(_Nex_ExtResponseSystem_TOS)
-       {
-               LOG_TRACE("error: TOS_URI_Get_Callback has been called before");
-               return;
-       }
-       if(status != 0)
-       {
-               LOG_TRACEF("error receiving tos: status is %d", status);
-               return;
-       }
-
-       _Nex_ExtResponseSystem_TOS = strzone(data);
-       LOG_INFO("Data: ", _Nex_ExtResponseSystem_TOS);
-       LOG_INFO("New TOS version: ", _Nex_ExtResponseSystem_NewToS);
-}
-
 // END OF URI SYSTEM ////////////////////////////////////////////////////////
 
 void updateCheck()
index 5aeb2c7e7d15fc553777950b98b8c139900fbc78..bbe29a07214495c216ce4d50e42c2fd610e2719e 100644 (file)
@@ -27,8 +27,6 @@ float updateCompression();
 
 void UpdateNotification_URI_Get_Callback(float id, float status, string data);
 
-void TOS_URI_Get_Callback(float id, float status, string data);
-
 // game type list box stuff (does not NEED to contain all game types, other
 // types stay available via console)
 entity GameType_GetID(int cnt);
@@ -49,9 +47,6 @@ string _Nex_ExtResponseSystem_PromotedServers;
 float _Nex_ExtResponseSystem_PromotedServersNeedsRefresh;
 string _Nex_ExtResponseSystem_RecommendedServers;
 float _Nex_ExtResponseSystem_RecommendedServersNeedsRefresh;
-string _Nex_ExtResponseSystem_TOS;
 string _Nex_ExtResponseSystem_NewToS;
 
 void CheckSendCvars(entity me, string cvarnamestring);
-
-string autocvar__termsofservice_accepted = "0";