From: terencehill Date: Mon, 13 Jan 2020 17:42:06 +0000 (+0100) Subject: Allow translating "Level %s: " in campaign level descriptions X-Git-Tag: xonotic-v0.8.5~1145^2~1^2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8d6302c73451c7f8aa7ca5d5eb54d926b73342f6;p=xonotic%2Fxonotic-data.pk3dir.git Allow translating "Level %s: " in campaign level descriptions --- diff --git a/notifications.cfg b/notifications.cfg index 80b26a9d8..41f0706ea 100644 --- a/notifications.cfg +++ b/notifications.cfg @@ -351,11 +351,12 @@ 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 = 239): +// MSG_CENTER notifications (count = 240): 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" @@ -753,4 +754,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 = 846): MSG_ANNCE = 89, MSG_INFO = 334, MSG_CENTER = 239, MSG_MULTI = 156, MSG_CHOICE = 28 +// Notification counts (total = 847): MSG_ANNCE = 89, MSG_INFO = 334, MSG_CENTER = 240, MSG_MULTI = 156, MSG_CHOICE = 28 diff --git a/qcsrc/common/notifications/all.inc b/qcsrc/common/notifications/all.inc index 69de56573..0b0ea6bd9 100644 --- a/qcsrc/common/notifications/all.inc +++ b/qcsrc/common/notifications/all.inc @@ -713,6 +713,7 @@ 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 join_key", CPID_MOTD, "-1 0", strcat("^BG%s\n^3\n", _("^BGPress ^F2%s^BG to enter the game")), "") 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 846f85937..192c22432 100644 --- a/qcsrc/common/notifications/all.qh +++ b/qcsrc/common/notifications/all.qh @@ -62,6 +62,7 @@ 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/xonotic/campaign.qc b/qcsrc/menu/xonotic/campaign.qc index 0f64aefdb..6f1d5111b 100644 --- a/qcsrc/menu/xonotic/campaign.qc +++ b/qcsrc/menu/xonotic/campaign.qc @@ -239,7 +239,9 @@ void XonoticCampaignList_drawListBoxItem(entity me, int i, vector absSize, bool s = campaign_shortdesc[i]; // fteqcc sucks else s = "???"; - s = draw_TextShortenToWidth(sprintf(_("Level %d: %s"), i+1, s), me.columnNameSize, 0, me.realFontSize); + // 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); 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 cbe7fec8d..336d825a7 100644 --- a/qcsrc/server/campaign.qc +++ b/qcsrc/server/campaign.qc @@ -75,10 +75,19 @@ float Campaign_Invalid() return 0; } +int Campaign_GetLevelNum() +{ + return campaign_level + 1; +} + +string Campaign_GetMessage() +{ + return strcat(campaign_shortdesc[0], "\n^3\n", campaign_longdesc[0]); +} + void CampaignPreInit() { float baseskill; - string title; campaign_level = autocvar__campaign_index; campaign_name = strzone(autocvar__campaign_name); campaign_index_var = strzone(strcat("g_campaign", campaign_name, "_index")); @@ -142,11 +151,6 @@ void CampaignPreInit() if(Campaign_Invalid()) return; - - title = campaign_shortdesc[0]; - title = strzone(strcat("Level ", ftos(campaign_level + 1), ": ", title)); - campaign_message = strzone(strcat(title, "\n^3\n", campaign_longdesc[0])); - strunzone(title); } void CampaignPostInit() @@ -309,7 +313,6 @@ void CampaignPostIntermission() CampaignSetup(campaign_won); CampaignFile_Unload(); - strunzone(campaign_message); strunzone(campaign_index_var); strunzone(campaign_name); campaign_name = ""; diff --git a/qcsrc/server/campaign.qh b/qcsrc/server/campaign.qh index df25c6c6a..0662a3704 100644 --- a/qcsrc/server/campaign.qh +++ b/qcsrc/server/campaign.qh @@ -3,7 +3,8 @@ // this must be included BEFORE campaign_common.h to make this a memory saving #define CAMPAIGN_MAX_ENTRIES 2 -string campaign_message; +int Campaign_GetLevelNum(); +string Campaign_GetMessage(); void CampaignPreInit(); void CampaignPostInit(); diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 1d5e240b3..e0c5762e9 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -2021,7 +2021,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_MOTD, campaign_message); + Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_CAMPAIGN_MESSAGE, Campaign_GetMessage(), Campaign_GetLevelNum()); } } else { if (PHYS_INPUT_BUTTON_INFO(this)) { @@ -2037,7 +2037,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_MOTD); + Kill_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CPID_CAMPAIGN_MESSAGE); } } else { if (PHYS_INPUT_BUTTON_INFO(this)) @@ -2056,7 +2056,10 @@ void PrintWelcomeMessage(entity this) { // instantly hide MOTD CS(this).motd_actived_time = 0; - Kill_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CPID_MOTD); + 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); } else if (IS_PLAYER(this) || IS_SPEC(this)) {