From: terencehill Date: Tue, 22 Mar 2022 23:11:57 +0000 (+0100) Subject: Partially build the Welcome message in client code, allowing translating some parts... X-Git-Tag: xonotic-v0.8.5~81^2~14 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=583fd7285ee671a2fb8ffa815a069c75280da8d5;p=xonotic%2Fxonotic-data.pk3dir.git Partially build the Welcome message in client code, allowing translating some parts of it --- diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 8d35ecc7d..5e04e7160 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -1288,9 +1288,27 @@ NET_HANDLE(TE_CSQC_WEAPONCOMPLAIN, bool isNew) NET_HANDLE(TE_CSQC_SERVERINFO, bool isNew) { + bool force_centerprint = ReadByte(); string hostname = ReadString(); - string msg = ReadString(); - if (!isdemo() && cvar("_menu_welcome_dialog_available") && autocvar_cl_welcome_in_menu_dialog) + string ver = ReadString(); + string gamemode_name = ReadString(); + string modifications = ReadString(); + string cache_mutatormsg = ReadString(); + string mutator_msg = ReadString(); + string motd = ReadString(); + + string msg = ""; + msg = strcat(msg, ver); + msg = strcat(msg, "^8\n\n", _("match type is "), " ^1", gamemode_name, "^8\n"); + if(modifications != "") + msg = strcat(msg, "^8\n", _("active modifications:"), " ^3", modifications, "^8\n"); + if (cache_mutatormsg != "") + msg = strcat(msg, "\n\n^8", _("special gameplay tips:"), " ^7", cache_mutatormsg); + msg = strcat(msg, mutator_msg); // trust that the mutator will do proper formatting + if (motd != "") + msg = strcat(msg, "\n\n^8", _("MOTD:"), " ^7", motd); + + if (!force_centerprint && !isdemo() && cvar("_menu_welcome_dialog_available") && autocvar_cl_welcome_in_menu_dialog) { string welcomedialog_args; welcomedialog_args = strcat("HOSTNAME \"", hostname, "\""); diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 75c98a868..cadb523cf 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -1033,8 +1033,15 @@ string GetClientVersionMessage(entity this) } } -string getwelcomemessage(entity this) +void SendWelcomemessage(entity this, bool force_centerprint) { + msg_entity = this; + WriteHeader(MSG_ONE, TE_CSQC_SERVERINFO); + WriteByte(MSG_ONE, force_centerprint); + WriteString(MSG_ONE, autocvar_hostname); + WriteString(MSG_ONE, GetClientVersionMessage(this)); + WriteString(MSG_ONE, gamemode_name); + MUTATOR_CALLHOOK(BuildMutatorsPrettyString, ""); string modifications = M_ARGV(0, string); @@ -1055,12 +1062,7 @@ string getwelcomemessage(entity this) modifications = strcat(modifications, ", Jet pack"); modifications = substring(modifications, 2, strlen(modifications) - 2); - string s = GetClientVersionMessage(this); - - s = strcat(s, "^8\n\nmatch type is ^1", gamemode_name, "^8\n"); - - if(modifications != "") - s = strcat(s, "^8\nactive modifications: ^3", modifications, "^8\n"); + WriteString(MSG_ONE, modifications); if(cache_lastmutatormsg != autocvar_g_mutatormsg) { @@ -1068,29 +1070,14 @@ string getwelcomemessage(entity this) strcpy(cache_mutatormsg, cache_lastmutatormsg); } - if (cache_mutatormsg != "") { - s = strcat(s, "\n\n^8special gameplay tips: ^7", cache_mutatormsg); - } + WriteString(MSG_ONE, cache_mutatormsg); string mutator_msg = ""; MUTATOR_CALLHOOK(BuildGameplayTipsString, mutator_msg); mutator_msg = M_ARGV(0, string); - s = strcat(s, mutator_msg); // trust that the mutator will do proper formatting - - string motd = autocvar_sv_motd; - if (motd != "") { - s = strcat(s, "\n\n^8MOTD: ^7", strreplace("\\n", "\n", motd)); - } - return s; -} - -void serverinfo_welcomemessage_send(entity this) -{ - msg_entity = this; - WriteHeader(MSG_ONE, TE_CSQC_SERVERINFO); - WriteString(MSG_ONE, autocvar_hostname); - WriteString(MSG_ONE, getwelcomemessage(this)); + WriteString(MSG_ONE, mutator_msg); // trust that the mutator will do proper formatting + WriteString(MSG_ONE, strreplace("\\n", "\n", autocvar_sv_motd)); } /** @@ -1182,7 +1169,7 @@ void ClientConnect(entity this) if (IS_REAL_CLIENT(this)) { if (!autocvar_g_campaign) - serverinfo_welcomemessage_send(this); + SendWelcomemessage(this, false); sv_notice_join(this); } @@ -2063,7 +2050,7 @@ void PrintWelcomeMessage(entity this) } else { if (PHYS_INPUT_BUTTON_INFO(this)) { CS(this).motd_actived_time = time; - Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_MOTD, getwelcomemessage(this)); + SendWelcomemessage(this, true); } } } diff --git a/qcsrc/server/command/cmd.qh b/qcsrc/server/command/cmd.qh index 344cba0eb..802afc8bd 100644 --- a/qcsrc/server/command/cmd.qh +++ b/qcsrc/server/command/cmd.qh @@ -8,7 +8,5 @@ int autocvar_sv_clientcommand_antispam_count; string MapVote_Suggest(entity this, string m); -void serverinfo_welcomemessage_send(entity this); - // used by common/command/generic.qc:GenericCommand_dumpcommands to list all commands into a .txt file void ClientCommand_macro_write_aliases(float fh);