]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Show the Welcome dialog in the campaign too
authorterencehill <piuntn@gmail.com>
Sat, 26 Mar 2022 10:48:01 +0000 (11:48 +0100)
committerterencehill <piuntn@gmail.com>
Sat, 26 Mar 2022 10:48:01 +0000 (11:48 +0100)
notifications.cfg
qcsrc/client/main.qc
qcsrc/common/notifications/all.inc
qcsrc/common/notifications/all.qh
qcsrc/menu/command/menu_cmd.qc
qcsrc/menu/xonotic/campaign.qc
qcsrc/server/campaign.qc
qcsrc/server/campaign.qh
qcsrc/server/client.qc

index 9bfcb335ed2d52d40204aec58df3d04a42d3384b..83fbcaf849fb23be8a46febd075b598fcf3d28a5 100644 (file)
@@ -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
index 13b68aa837147099956f180ac41274ff483915d4..67b259c180bb9c4c1b9e6468a96e28170c7e66aa 100644 (file)
@@ -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();
index 51902a5702b1c85e35382a98e4ee682c165482bb..31d9bb1d1eef32365b0dce07f500d092c848aba1 100644 (file)
@@ -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"), "")
index 8d882bf3ccede40ac09e28b75b614640c1a02acc..45259741b355aa7d703c0e4db40a276abb53be5e 100644 (file)
@@ -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)
index c8ddf726a64b46d2926a2ce6506c0c2d83b4062d..b933a9194f4747bf8f5e5c7e61505e5abdb1392f 100644 (file)
@@ -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
                }
index b9e9f54dbd73b94360e951a2e092bc9ea98a3db7..900e085d8c6b1c655d5d9fa35b57752d12ab7e98 100644 (file)
@@ -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)
index debc0566907dc8fdf2ce0102bf108bb53aae3e5d..6bd853d1b4af51d053ff9048f5712d184ca60986 100644 (file)
@@ -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));
 
index 1aca24492069678a7d4f59a0030227a349d96be3..10e06a240f836f6328cf7834c6a66989529e6a1a 100644 (file)
@@ -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();
 
index e4041786b847b9e3ba8b6257051b6e156436e96d..bafcb5266baa42c6b61bd63d73c888f9f3db1c55 100644 (file)
@@ -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))
                {