From 4c84ea02a41ddd4a14bdbb56b976f343380c332b Mon Sep 17 00:00:00 2001 From: z411 Date: Wed, 24 Nov 2021 02:23:13 -0300 Subject: [PATCH] WIP: ToS versioning done --- qcsrc/menu/xonotic/.util.qc.kate-swp | Bin 703 -> 0 bytes qcsrc/menu/xonotic/dialog_termsofservice.qc | 26 +++--------------- qcsrc/menu/xonotic/dialog_termsofservice.qh | 2 ++ qcsrc/menu/xonotic/mainwindow.qc | 20 +++++--------- qcsrc/menu/xonotic/mainwindow.qh | 2 +- qcsrc/menu/xonotic/util.qc | 28 ++------------------ qcsrc/menu/xonotic/util.qh | 5 ---- 7 files changed, 16 insertions(+), 67 deletions(-) delete mode 100644 qcsrc/menu/xonotic/.util.qc.kate-swp diff --git a/qcsrc/menu/xonotic/.util.qc.kate-swp b/qcsrc/menu/xonotic/.util.qc.kate-swp deleted file mode 100644 index 4f3893a545fe2577df669191e4411cde038af81c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 703 zcmbV}%}T>S5XU#EU-jD>?|Z7AZ1Lcwc#qi9^8Lpm=G`GLSTRMo7vgyFvcopGSS={%aET8e9aH`>x?nytJHgae^DRP!^!jI zQ{yUpn|^v1jM?|b+D-F4m<^Uyc4q=?K}=@hRAg*H)?Cl^vWWdFQbL4N#vHg!JP*Dm zUI1(2MQ}vCRPbf+F8O6}OuPcl^SyeaZ`vgZRh?Q>6bT1|1P6LBnkzbn-Z)mKeQts4YBm%}7bBN+*i=;$^M`mv5i z1EqyjN{5N=@gv@seykhR4b`1=vKVL;jUUYh3nR}Mll@;8oQCT9AG=t4>Fu&Q+x-S8 C26o~A diff --git a/qcsrc/menu/xonotic/dialog_termsofservice.qc b/qcsrc/menu/xonotic/dialog_termsofservice.qc index c0c26c9fd..568fdedfc 100644 --- a/qcsrc/menu/xonotic/dialog_termsofservice.qc +++ b/qcsrc/menu/xonotic/dialog_termsofservice.qc @@ -10,11 +10,12 @@ 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) diff --git a/qcsrc/menu/xonotic/dialog_termsofservice.qh b/qcsrc/menu/xonotic/dialog_termsofservice.qh index d901d0327..50e22cf91 100644 --- a/qcsrc/menu/xonotic/dialog_termsofservice.qh +++ b/qcsrc/menu/xonotic/dialog_termsofservice.qh @@ -1,5 +1,7 @@ #pragma once +string autocvar__termsofservice_accepted; + #include "rootdialog.qh" CLASS(XonoticToSDialog, XonoticRootDialog) METHOD(XonoticToSDialog, shouldShow, bool()); diff --git a/qcsrc/menu/xonotic/mainwindow.qc b/qcsrc/menu/xonotic/mainwindow.qc index 2347dbef3..dba0a661d 100644 --- a/qcsrc/menu/xonotic/mainwindow.qc +++ b/qcsrc/menu/xonotic/mainwindow.qc @@ -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; - } } diff --git a/qcsrc/menu/xonotic/mainwindow.qh b/qcsrc/menu/xonotic/mainwindow.qh index 28658949b..82e126a9f 100644 --- a/qcsrc/menu/xonotic/mainwindow.qh +++ b/qcsrc/menu/xonotic/mainwindow.qh @@ -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); diff --git a/qcsrc/menu/xonotic/util.qc b/qcsrc/menu/xonotic/util.qc index fc0364c9e..b6d350447 100644 --- a/qcsrc/menu/xonotic/util.qc +++ b/qcsrc/menu/xonotic/util.qc @@ -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() diff --git a/qcsrc/menu/xonotic/util.qh b/qcsrc/menu/xonotic/util.qh index 5aeb2c7e7..bbe29a072 100644 --- a/qcsrc/menu/xonotic/util.qh +++ b/qcsrc/menu/xonotic/util.qh @@ -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"; -- 2.39.2