]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix #2682 "Bad welcome dialog's backwards compatibility"; behaviour of the welcome...
authorterencehill <piuntn@gmail.com>
Fri, 8 Apr 2022 14:45:55 +0000 (16:45 +0200)
committerterencehill <piuntn@gmail.com>
Fri, 8 Apr 2022 14:49:04 +0000 (16:49 +0200)
qcsrc/menu/menu.qc
qcsrc/menu/xonotic/dialog_welcome.qc
qcsrc/menu/xonotic/dialog_welcome.qh
xonotic-client.cfg

index d26066d190663d28a521a461c270a5d84c0213ae..f2a71d9679f879f1c0564a9ed107456eb43ee29a 100644 (file)
@@ -672,6 +672,7 @@ void m_tooltip(vector pos)
        }
 }
 
+const int MIN_DISCONNECTION_TIME = 1;
 float autocvar_menu_force_on_disconnection;
 bool autocvar_g_campaign;
 void m_draw(float width, float height)
@@ -681,7 +682,7 @@ void m_draw(float width, float height)
        {
                if (autocvar_g_campaign)
                {
-                       if (connected_time && time - connected_time > 1)
+                       if (connected_time && time - connected_time > MIN_DISCONNECTION_TIME)
                        {
                                // in the case player uses the disconnect command (in the console or with a key)
                                // reset g_campaign and update menu items to reflect cvar values that may have been restored after quiting the campaign
@@ -692,12 +693,16 @@ void m_draw(float width, float height)
                }
                if (autocvar_menu_force_on_disconnection > 0)
                {
-                       if (connected_time && time - connected_time > autocvar_menu_force_on_disconnection)
+                       if (connected_time && time - connected_time > MIN_DISCONNECTION_TIME)
                        {
                                m_toggle(true);
-                               connected_time = 0;
                        }
                }
+               if (connected_time && time - connected_time > MIN_DISCONNECTION_TIME)
+               {
+                       localcmd("\nmenu_cmd directmenu Welcome RESET\n");
+                       connected_time = 0;
+               }
        }
        else
                connected_time = time;
index 7873931589cafd5406a252590e8ae4a30c957936..a7646047ec62b3b572a7aa6bf7c511baad9e6c22 100644 (file)
@@ -9,8 +9,8 @@
 
 void welcomeDialog_resetStrings(entity me)
 {
-       strcpy(me.serverinfo_name, "<NO HOSTNAME>");
-       strcpy(me.serverinfo_MOTD, "<NO WELCOME MESSAGE>");
+       strcpy(me.serverinfo_name, _("Welcome"));
+       strcpy(me.serverinfo_MOTD, "");
 }
 
 float XonoticWelcomeDialog_keyDown(entity me, float key, float ascii, float shift)
@@ -56,6 +56,11 @@ void XonoticWelcomeDialog_readInputArgs(entity me, int argsbuf)
                        strcpy(me.serverinfo_name, bufstr_get(argsbuf, ++i));
                else if(s == "WELCOME")
                        strcpy(me.serverinfo_MOTD, bufstr_get(argsbuf, ++i));
+               else if(s == "RESET")
+               {
+                       welcomeDialog_resetStrings(me);
+                       break;
+               }
                ++i;
        }
        //me.serverinfo_name_ent.setText(me.serverinfo_name_ent, me.serverinfo_name);
@@ -63,6 +68,18 @@ void XonoticWelcomeDialog_readInputArgs(entity me, int argsbuf)
        me.frame.setText(me.frame, me.serverinfo_name);
 }
 
+void XonoticWelcomeDialog_draw(entity me)
+{
+       SUPER(XonoticWelcomeDialog).draw(me);
+       if(me.serverinfo_MOTD == "" && gamestatus & (GAME_CONNECTED | GAME_ISSERVER))
+       {
+               // if serverinfo_MOTD is empty while connected it means we are connected to an old server
+               // in this case show the csqc welcome message and instantly close the dialog
+               localcmd("\n+show_info0; defer 2 -show_info0\n");
+               me.close(me);
+       }
+}
+
 void XonoticWelcomeDialog_fill(entity me)
 {
        registercvar("_menu_welcome_dialog_available", "0", 0);
index 4a63942859aff16ae224efbab468e3ff90e16f95..d02cd6e73ca1c8ed99d75169f0d79ef88010235e 100644 (file)
@@ -10,6 +10,7 @@ CLASS(XonoticWelcomeDialog, XonoticRootDialog)
        ATTRIB(XonoticWelcomeDialog, columns, float, 4);
        ATTRIB(XonoticWelcomeDialog, name, string, "Welcome");
 
+       METHOD(XonoticWelcomeDialog, draw, void(entity));
        METHOD(XonoticWelcomeDialog, mouseRelease, bool(entity, vector));
        METHOD(XonoticWelcomeDialog, keyDown, float(entity, float, float, float));
        METHOD(XonoticWelcomeDialog, destroy, void(entity));
@@ -18,4 +19,5 @@ CLASS(XonoticWelcomeDialog, XonoticRootDialog)
        //ATTRIB(XonoticWelcomeDialog, serverinfo_name_ent, entity, world);
        ATTRIB(XonoticWelcomeDialog, serverinfo_MOTD, string, string_null);
        ATTRIB(XonoticWelcomeDialog, serverinfo_MOTD_ent, entity, world);
+       ATTRIB(XonoticWelcomeDialog, requiresConnection, bool, true);
 ENDCLASS(XonoticWelcomeDialog)
index 2a4c2c5c7a801c0da4c60e244f1ff24ad5e2a2d4..940ff2e2654bf8948c4e7ff799b34d38d6e95ca3 100644 (file)
@@ -493,7 +493,7 @@ seta menu_tooltips 1 "menu tooltips: 0 disabled, 1 enabled, 2 also shows cvar or
 set menu_picmip_bypass 0 "bypass texture quality enforcement based on system resources, not recommended and may cause crashes!"
 set menu_showboxes 0 "show item bounding boxes (debug)"
 set menu_cvarlist_onlymodified 0 "show only modified cvars in the cvar list"
-set menu_force_on_disconnection 1 "force to show the menu this number of seconds after you get disconnected (0 to disable)"
+set menu_force_on_disconnection 1 "force to show the menu after you get disconnected"
 
 set _menu_credits_export 0 "set to 1 and restart the menu to export credits to credits.txt (menu will automatically reset to 0)"
 alias menu_credits_export "_menu_credits_export 1; menu_restart"