From e32fa2cfa19f04fedb470fd43bc6ddf0fede9af3 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sat, 26 Mar 2022 11:48:01 +0100 Subject: [PATCH] Show the Welcome dialog in the campaign too --- notifications.cfg | 5 ++--- qcsrc/client/main.qc | 19 +++++++++++++++++++ qcsrc/common/notifications/all.inc | 1 - qcsrc/common/notifications/all.qh | 1 - qcsrc/menu/command/menu_cmd.qc | 2 -- qcsrc/menu/xonotic/campaign.qc | 6 +++--- qcsrc/server/campaign.qc | 6 +++++- qcsrc/server/campaign.qh | 1 + qcsrc/server/client.qc | 17 +++++++++++------ 9 files changed, 41 insertions(+), 17 deletions(-) diff --git a/notifications.cfg b/notifications.cfg index 9bfcb335e..83fbcaf84 100644 --- a/notifications.cfg +++ b/notifications.cfg @@ -342,12 +342,11 @@ seta notification_INFO_WEAPON_TUBA_SUICIDE "1" "0 = off, 1 = print to console, 2 seta notification_INFO_WEAPON_VAPORIZER_MURDER "1" "0 = off, 1 = print to console, 2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)" seta notification_INFO_WEAPON_VORTEX_MURDER "1" "0 = off, 1 = print to console, 2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)" -// MSG_CENTER notifications (count = 242): +// MSG_CENTER notifications (count = 241): seta notification_CENTER_ALONE "1" "0 = off, 1 = centerprint" seta notification_CENTER_ASSAULT_ATTACKING "1" "0 = off, 1 = centerprint" seta notification_CENTER_ASSAULT_DEFENDING "1" "0 = off, 1 = centerprint" seta notification_CENTER_ASSAULT_OBJ_DESTROYED "1" "0 = off, 1 = centerprint" -seta notification_CENTER_CAMPAIGN_MESSAGE "1" "0 = off, 1 = centerprint" seta notification_CENTER_CAMPCHECK "1" "0 = off, 1 = centerprint" seta notification_CENTER_COINTOSS "1" "0 = off, 1 = centerprint" seta notification_CENTER_COUNTDOWN_BEGIN "1" "0 = off, 1 = centerprint" @@ -747,4 +746,4 @@ seta notification_show_sprees_info "3" "Show spree information in MSG_INFO messa seta notification_show_sprees_info_newline "1" "Show attacker spree information for MSG_INFO messages on a separate line than the death notification itself" seta notification_show_sprees_info_specialonly "1" "Don't show attacker spree information in MSG_INFO messages if it isn't an achievement" -// Notification counts (total = 840): MSG_ANNCE = 80, MSG_INFO = 334, MSG_CENTER = 242, MSG_MULTI = 156, MSG_CHOICE = 28 +// Notification counts (total = 839): MSG_ANNCE = 80, MSG_INFO = 334, MSG_CENTER = 241, MSG_MULTI = 156, MSG_CHOICE = 28 diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 13b68aa83..67b259c18 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -1288,6 +1288,25 @@ NET_HANDLE(TE_CSQC_WEAPONCOMPLAIN, bool isNew) NET_HANDLE(TE_CSQC_SERVERINFO, bool isNew) { + bool campaign = ReadByte(); + if (campaign) + { + string campaign_title = ReadString(); + int campaign_level = ReadByte(); + string campaign_msg = ReadString(); + string welcomedialog_args; + welcomedialog_args = strcat("HOSTNAME \"", campaign_title, "\""); + string key = getcommandkey(_("jump"), "+jump"); + string msg = strcat( + CCR("^F1"), sprintf(_("Level %d:"), campaign_level), + sprintf(CCR(" ^BG%s\n^3\n"), campaign_msg), + sprintf(CCR(_("^BGPress ^F2%s^BG to enter the game")), key)); + msg = MakeConsoleSafe(strreplace("\n", "\\n", msg)); + welcomedialog_args = strcat(welcomedialog_args, " WELCOME \"", msg, "\""); + localcmd("\nmenu_cmd directmenu Welcome ", welcomedialog_args, "\n"); + return true; + } + bool force_centerprint = ReadByte(); string hostname = ReadString(); string ver = ReadString(); diff --git a/qcsrc/common/notifications/all.inc b/qcsrc/common/notifications/all.inc index 51902a570..31d9bb1d1 100644 --- a/qcsrc/common/notifications/all.inc +++ b/qcsrc/common/notifications/all.inc @@ -713,7 +713,6 @@ string multiteam_info_sprintf(string input, string teamname) { return ((input != MSG_CENTER_NOTIF(INSTAGIB_FINDAMMO_FIRST, N_ENABLE, 0, 0, "", CPID_INSTAGIB_FINDAMMO, "1 10", _("^BGGet some ammo or you'll be dead in ^F4^COUNT^BG!"), _("^BGGet some ammo! ^F4^COUNT^BG left!")) MSG_CENTER_NOTIF(INSTAGIB_LIVES_REMAINING, N_ENABLE, 0, 1, "f1", CPID_Null, "0 0", _("^F2Extra lives remaining: ^K1%s"), "") - MSG_CENTER_NOTIF(CAMPAIGN_MESSAGE, N_ENABLE, 1, 1, "f1 s1 join_key", CPID_CAMPAIGN_MESSAGE, "-1 0", strcat(_("Level %s: "), "^BG%s\n^3\n", _("^BGPress ^F2%s^BG to enter the game")), "") MSG_CENTER_NOTIF(MOTD, N_ENABLE, 1, 0, "s1", CPID_MOTD, "-1 0", "^BG%s", "") MSG_CENTER_NOTIF(NIX_COUNTDOWN, N_ENABLE, 0, 2, "item_wepname", CPID_NIX, "1 f2", _("^F2^COUNT^BG until weapon change...\nNext weapon: ^F1%s"), "") diff --git a/qcsrc/common/notifications/all.qh b/qcsrc/common/notifications/all.qh index 8d882bf3c..45259741b 100644 --- a/qcsrc/common/notifications/all.qh +++ b/qcsrc/common/notifications/all.qh @@ -62,7 +62,6 @@ ENUMCLASS(CPID) CASE(CPID, MISSING_TEAMS) CASE(CPID, MISSING_PLAYERS) CASE(CPID, INSTAGIB_FINDAMMO) - CASE(CPID, CAMPAIGN_MESSAGE) CASE(CPID, MOTD) CASE(CPID, NIX) CASE(CPID, ONSLAUGHT) diff --git a/qcsrc/menu/command/menu_cmd.qc b/qcsrc/menu/command/menu_cmd.qc index c8ddf726a..b933a9194 100644 --- a/qcsrc/menu/command/menu_cmd.qc +++ b/qcsrc/menu/command/menu_cmd.qc @@ -95,8 +95,6 @@ void GameCommand(string theCommand) } else if (argc == 2 && !isdemo()) // don't allow this command in demos { - if (argv(1) == "Welcome" && cvar("g_campaign")) - return; m_play_click_sound(MENU_SOUND_OPEN); m_goto(strcat(filter, argv(1))); // switch to a menu item } diff --git a/qcsrc/menu/xonotic/campaign.qc b/qcsrc/menu/xonotic/campaign.qc index b9e9f54db..900e085d8 100644 --- a/qcsrc/menu/xonotic/campaign.qc +++ b/qcsrc/menu/xonotic/campaign.qc @@ -239,9 +239,9 @@ void XonoticCampaignList_drawListBoxItem(entity me, int i, vector absSize, bool s = campaign_shortdesc[i]; // fteqcc sucks else s = "???"; - // NOTE the following string is equal to the one used in the campaign level notification - // (CAMPAIGN_MESSAGE) to avoid adding another duplicate string to translate - s = draw_TextShortenToWidth(strcat(sprintf(_("Level %s: "), itos(i+1)), s), me.columnNameSize, 0, me.realFontSize); + // NOTE the following string should be equal to the one used in the Welcome dialog + // to avoid adding a slightly different string to translate + s = draw_TextShortenToWidth(strcat(sprintf(_("Level %d:"), i+1), " ", s), me.columnNameSize, 0, me.realFontSize); draw_Text(me.realUpperMargin1 * eY + (me.columnNameOrigin + 0.00 * (me.columnNameSize - draw_TextWidth(s, 0, me.realFontSize))) * eX, s, me.realFontSize, theColor, theAlpha, 0); if(i <= me.campaignIndex) diff --git a/qcsrc/server/campaign.qc b/qcsrc/server/campaign.qc index debc05669..6bd853d1b 100644 --- a/qcsrc/server/campaign.qc +++ b/qcsrc/server/campaign.qc @@ -41,6 +41,11 @@ float Campaign_Invalid() return 0; } +string Campaign_GetTitle() +{ + return campaign_title; +} + int Campaign_GetLevelNum() { return campaign_level + 1; @@ -95,7 +100,6 @@ void CampaignPreInit() cvar_settemp("g_dm", "0"); cvar_settemp("skill", ftos(baseskill)); cvar_settemp("bot_number", ftos(campaign_bots[0])); - cvar_settemp("cl_welcome_in_menu_dialog", "0"); MapInfo_SwitchGameType(MapInfo_Type_FromString(campaign_gametype[0], false)); diff --git a/qcsrc/server/campaign.qh b/qcsrc/server/campaign.qh index 1aca24492..10e06a240 100644 --- a/qcsrc/server/campaign.qh +++ b/qcsrc/server/campaign.qh @@ -10,6 +10,7 @@ int autocvar_g_campaign_skill; // this must be included BEFORE campaign_common.h to make this a memory saving #define CAMPAIGN_MAX_ENTRIES 2 +string Campaign_GetTitle(); int Campaign_GetLevelNum(); string Campaign_GetMessage(); diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index e4041786b..bafcb5266 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -1037,6 +1037,14 @@ void SendWelcomemessage(entity this, bool force_centerprint) { msg_entity = this; WriteHeader(MSG_ONE, TE_CSQC_SERVERINFO); + WriteByte(MSG_ONE, boolean(autocvar_g_campaign)); + if (boolean(autocvar_g_campaign)) + { + WriteString(MSG_ONE, Campaign_GetTitle()); + WriteByte(MSG_ONE, Campaign_GetLevelNum()); + WriteString(MSG_ONE, Campaign_GetMessage()); + return; + } WriteByte(MSG_ONE, force_centerprint); WriteString(MSG_ONE, autocvar_hostname); WriteString(MSG_ONE, GetClientVersionMessage(this)); @@ -2057,7 +2065,7 @@ void PrintWelcomeMessage(entity this) if (autocvar_g_campaign) { if ((IS_PLAYER(this) && PHYS_INPUT_BUTTON_INFO(this)) || (!IS_PLAYER(this))) { CS(this).motd_actived_time = time; - Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_CAMPAIGN_MESSAGE, Campaign_GetMessage(), Campaign_GetLevelNum()); + SendWelcomemessage(this, false); } } else { if (PHYS_INPUT_BUTTON_INFO(this)) { @@ -2073,7 +2081,7 @@ void PrintWelcomeMessage(entity this) CS(this).motd_actived_time = time; else if ((time - CS(this).motd_actived_time > 2) && IS_PLAYER(this)) { // hide it some seconds after BUTTON_INFO has been released CS(this).motd_actived_time = 0; - Kill_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CPID_CAMPAIGN_MESSAGE); + Kill_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CPID_MOTD); } } else { if (PHYS_INPUT_BUTTON_INFO(this)) @@ -2092,10 +2100,7 @@ void PrintWelcomeMessage(entity this) { // instantly hide MOTD CS(this).motd_actived_time = 0; - if (autocvar_g_campaign) - Kill_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CPID_CAMPAIGN_MESSAGE); - else - Kill_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CPID_MOTD); + Kill_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CPID_MOTD); } else if (IS_PLAYER(this) || IS_SPEC(this)) { -- 2.39.2