From e5448270eedbb55ef2ba895425862fb30a24faf5 Mon Sep 17 00:00:00 2001 From: terencehill Date: Mon, 4 Jul 2022 00:36:28 +0200 Subject: [PATCH] Allow showing the Welcome dialog in demos, initially hidden --- qcsrc/client/main.qc | 7 +++---- qcsrc/menu/command/menu_cmd.qc | 4 ++-- qcsrc/menu/xonotic/dialog_welcome.qc | 13 ++++++++++++- qcsrc/menu/xonotic/dialog_welcome.qh | 1 + 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 0a643da4a..cfadaf1b2 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -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"); } diff --git a/qcsrc/menu/command/menu_cmd.qc b/qcsrc/menu/command/menu_cmd.qc index b56e8e9e4..2f97712b6 100644 --- a/qcsrc/menu/command/menu_cmd.qc +++ b/qcsrc/menu/command/menu_cmd.qc @@ -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; diff --git a/qcsrc/menu/xonotic/dialog_welcome.qc b/qcsrc/menu/xonotic/dialog_welcome.qc index 6448a0fca..bf45084d7 100644 --- a/qcsrc/menu/xonotic/dialog_welcome.qc +++ b/qcsrc/menu/xonotic/dialog_welcome.qc @@ -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)); } diff --git a/qcsrc/menu/xonotic/dialog_welcome.qh b/qcsrc/menu/xonotic/dialog_welcome.qh index bca7e56e6..b8a85ff64 100644 --- a/qcsrc/menu/xonotic/dialog_welcome.qh +++ b/qcsrc/menu/xonotic/dialog_welcome.qh @@ -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) -- 2.39.2