]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Allow showing the Welcome dialog in demos, initially hidden
authorterencehill <piuntn@gmail.com>
Sun, 3 Jul 2022 22:36:28 +0000 (00:36 +0200)
committerbones_was_here <bones_was_here@xa.org.au>
Thu, 7 Jul 2022 14:02:41 +0000 (00:02 +1000)
qcsrc/client/main.qc
qcsrc/menu/command/menu_cmd.qc
qcsrc/menu/xonotic/dialog_welcome.qc
qcsrc/menu/xonotic/dialog_welcome.qh

index 0a643da4aaabd37eef38d5bf7fc32fbeeb805cf3..cfadaf1b21a691bfe70394cc7c0fb3f7a88e422b 100644 (file)
@@ -1434,17 +1434,16 @@ void Welcome_Message_Show_Try()
        if (!welcome_msg_menu_check_maxtime)
                return;
 
-       bool want_dialog = !isdemo();
        // if want dialog check if menu is initialized but for a short time
-       if (!want_dialog || cvar("_menu_initialized") == 2 || time > welcome_msg_menu_check_maxtime)
+       if (cvar("_menu_initialized") == 2 || time > welcome_msg_menu_check_maxtime)
        {
-               if (want_dialog && cvar("_menu_welcome_dialog_available"))
+               if (cvar("_menu_welcome_dialog_available"))
                {
                        string welcomedialog_args = strcat("HOSTNAME \"", hostname, "\"");
                        string msg = MakeConsoleSafe(strreplace("\n", "\\n", welcome_msg));
                        welcomedialog_args = strcat(welcomedialog_args, " WELCOME \"", msg, "\"");
                        localcmd("\nmenu_cmd directmenu Welcome ", welcomedialog_args, "\n");
-                       if (intermission) // close it after it's been initialized so it can still be opened manually
+                       if (intermission || isdemo()) // close it after it's been initialized so it can still be opened manually
                                localcmd("\ntogglemenu 0\n");
                }
 
index b56e8e9e4afd4ba69e8047d6afbdc04cd64119d7..2f97712b676a1dc67f0eb5bbbf2739507bb5f950 100644 (file)
@@ -93,12 +93,12 @@ void GameCommand(string theCommand)
                                LOG_HELP(" ", s);
                        });
                }
-               else if (argc == 2 && !isdemo())     // don't allow this command in demos
+               else if (argc == 2 && (!isdemo() || argv(1) == "Welcome")) // don't allow this command in demos
                {
                        m_play_click_sound(MENU_SOUND_OPEN);
                        m_goto(strcat(filter, argv(1))); // switch to a menu item
                }
-               else if(argc > 2 && !isdemo())
+               else if(argc > 2 && (!isdemo() || argv(1) == "Welcome"))
                {
                        entity e = NULL;
                        float argsbuf = 0;
index 6448a0fca5333b3f71e0bc5ea736e74cf9435d7e..bf45084d73bc47b305d62ed831e09536e42f14b9 100644 (file)
@@ -82,6 +82,17 @@ void XonoticWelcomeDialog_draw(entity me)
                localcmd("\n+show_info0; defer 2 -show_info0\n");
                me.close(me);
        }
+
+       if (isdemo())
+       {
+               me.joinButton_ent.disabled = true;
+               me.spectateButton_ent.disabled = true;
+       }
+       else
+       {
+               me.joinButton_ent.disabled = false;
+               me.spectateButton_ent.disabled = false;
+       }
 }
 
 void XonoticWelcomeDialog_fill(entity me)
@@ -101,5 +112,5 @@ void XonoticWelcomeDialog_fill(entity me)
        me.gotoRC(me, me.rows - 1, 0);
                me.TD(me, 1, me.columns / 2, me.joinButton_ent = makeXonoticCommandButton(_("Join"), '0 1 0', "cmd join", COMMANDBUTTON_CLOSE));
                        me.joinButton_ent.preferredFocusPriority = 1;
-               me.TD(me, 1, me.columns / 2, makeXonoticCommandButton(_("Spectate"), '0 0 0', "cmd spectate", COMMANDBUTTON_CLOSE));
+               me.TD(me, 1, me.columns / 2, me.spectateButton_ent = makeXonoticCommandButton(_("Spectate"), '0 0 0', "cmd spectate", COMMANDBUTTON_CLOSE));
 }
index bca7e56e6e96d4eda373a949a9a466ec3c238b22..b8a85ff642d6f1e4bee58e6be8462652ad049423 100644 (file)
@@ -20,5 +20,6 @@ CLASS(XonoticWelcomeDialog, XonoticRootDialog)
        ATTRIB(XonoticWelcomeDialog, serverinfo_MOTD, string, string_null);
        ATTRIB(XonoticWelcomeDialog, serverinfo_MOTD_ent, entity, world);
        ATTRIB(XonoticWelcomeDialog, joinButton_ent, entity, world);
+       ATTRIB(XonoticWelcomeDialog, spectateButton_ent, entity, world);
        ATTRIB(XonoticWelcomeDialog, requiresConnection, bool, true);
 ENDCLASS(XonoticWelcomeDialog)