From: terencehill Date: Fri, 25 Mar 2022 16:55:33 +0000 (+0100) Subject: Allow translating gameplay tips (ported them from server to client) X-Git-Tag: xonotic-v0.8.5~81^2~8 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=805edf1cbc31ceb15c3c4541659a6f60b007b5fa;p=xonotic%2Fxonotic-data.pk3dir.git Allow translating gameplay tips (ported them from server to client) --- diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 1441eedf0..0741acc21 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -1345,18 +1345,23 @@ NET_HANDLE(TE_CSQC_SERVERINFO, bool isNew) string modifications = translate_modifications(ReadString()); string weaponarena_list = translate_weaponarena(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", MapInfo_Type_ToText(gametype), "^8\n"); + modifications = cons_mid(modifications, ", ", weaponarena_list); 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); + string mutator_msg = ""; + MUTATOR_CALLHOOK(BuildGameplayTipsString, mutator_msg); + mutator_msg = M_ARGV(0, string); msg = strcat(msg, mutator_msg); // trust that the mutator will do proper formatting + if (motd != "") msg = strcat(msg, "\n\n^8", _("MOTD:"), " ^7", motd); diff --git a/qcsrc/common/mutators/mutator/hook/_mod.inc b/qcsrc/common/mutators/mutator/hook/_mod.inc index e5e68b610..626c4cffa 100644 --- a/qcsrc/common/mutators/mutator/hook/_mod.inc +++ b/qcsrc/common/mutators/mutator/hook/_mod.inc @@ -1,4 +1,7 @@ // generated file; do not modify +#ifdef CSQC + #include +#endif #ifdef SVQC #include #endif diff --git a/qcsrc/common/mutators/mutator/hook/_mod.qh b/qcsrc/common/mutators/mutator/hook/_mod.qh index 5a5d26e81..1216e36e8 100644 --- a/qcsrc/common/mutators/mutator/hook/_mod.qh +++ b/qcsrc/common/mutators/mutator/hook/_mod.qh @@ -1,4 +1,7 @@ // generated file; do not modify +#ifdef CSQC + #include +#endif #ifdef SVQC #include #endif diff --git a/qcsrc/common/mutators/mutator/hook/cl_hook.qc b/qcsrc/common/mutators/mutator/hook/cl_hook.qc new file mode 100644 index 000000000..b600701a2 --- /dev/null +++ b/qcsrc/common/mutators/mutator/hook/cl_hook.qc @@ -0,0 +1,12 @@ +#include "cl_hook.qh" + +#ifdef CSQC +REGISTER_MUTATOR(cl_hook, true); + +MUTATOR_HOOKFUNCTION(cl_hook, BuildGameplayTipsString) +{ + M_ARGV(0, string) = strcat(M_ARGV(0, string), + "\n\n", _("^3grappling hook^8 is enabled, press 'e' (+hook) to use it"), "\n"); +} + +#endif diff --git a/qcsrc/common/mutators/mutator/hook/cl_hook.qh b/qcsrc/common/mutators/mutator/hook/cl_hook.qh new file mode 100644 index 000000000..6f70f09be --- /dev/null +++ b/qcsrc/common/mutators/mutator/hook/cl_hook.qh @@ -0,0 +1 @@ +#pragma once diff --git a/qcsrc/common/mutators/mutator/hook/sv_hook.qc b/qcsrc/common/mutators/mutator/hook/sv_hook.qc index c6a595363..94379cbb2 100644 --- a/qcsrc/common/mutators/mutator/hook/sv_hook.qc +++ b/qcsrc/common/mutators/mutator/hook/sv_hook.qc @@ -30,11 +30,6 @@ MUTATOR_HOOKFUNCTION(hook, BuildMutatorsPrettyString) M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Hook"); } -MUTATOR_HOOKFUNCTION(hook, BuildGameplayTipsString) -{ - M_ARGV(0, string) = strcat(M_ARGV(0, string), "\n\n^3grappling hook^8 is enabled, press 'e' (+hook) to use it\n"); -} - MUTATOR_HOOKFUNCTION(hook, SetStartItems) { if(autocvar_g_grappling_hook_useammo) diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index 7a00bd686..49e70b600 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -117,6 +117,13 @@ MUTATOR_HOOKFUNCTION(cl_nades, EditProjectile) else proj.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY; } + +MUTATOR_HOOKFUNCTION(cl_nades, BuildGameplayTipsString) +{ + M_ARGV(0, string) = strcat(M_ARGV(0, string), + "\n\n", _("^3nades^8 are enabled, press 'g' (dropweapon) to use them"), "\n"); +} + bool Projectile_isnade(int p) { return Nade_FromProjectile(p) != NADE_TYPE_Null; @@ -1569,9 +1576,4 @@ MUTATOR_HOOKFUNCTION(nades, BuildMutatorsString) M_ARGV(0, string) = strcat(M_ARGV(0, string), ":Nades"); } -MUTATOR_HOOKFUNCTION(nades, BuildGameplayTipsString) -{ - M_ARGV(0, string) = strcat(M_ARGV(0, string), "\n\n^3nades^8 are enabled, press 'g' (dropweapon) to use them\n"); -} - #endif diff --git a/qcsrc/common/mutators/mutator/offhand_blaster/_mod.inc b/qcsrc/common/mutators/mutator/offhand_blaster/_mod.inc index 41bb01e55..0a555570d 100644 --- a/qcsrc/common/mutators/mutator/offhand_blaster/_mod.inc +++ b/qcsrc/common/mutators/mutator/offhand_blaster/_mod.inc @@ -1,4 +1,7 @@ // generated file; do not modify +#ifdef CSQC + #include +#endif #ifdef SVQC #include #endif diff --git a/qcsrc/common/mutators/mutator/offhand_blaster/_mod.qh b/qcsrc/common/mutators/mutator/offhand_blaster/_mod.qh index 5e11096a5..2c4587f41 100644 --- a/qcsrc/common/mutators/mutator/offhand_blaster/_mod.qh +++ b/qcsrc/common/mutators/mutator/offhand_blaster/_mod.qh @@ -1,4 +1,7 @@ // generated file; do not modify +#ifdef CSQC + #include +#endif #ifdef SVQC #include #endif diff --git a/qcsrc/common/mutators/mutator/offhand_blaster/cl_offhand_blaster.qc b/qcsrc/common/mutators/mutator/offhand_blaster/cl_offhand_blaster.qc new file mode 100644 index 000000000..39e6ad8d4 --- /dev/null +++ b/qcsrc/common/mutators/mutator/offhand_blaster/cl_offhand_blaster.qc @@ -0,0 +1,9 @@ +#include "cl_offhand_blaster.qh" + +REGISTER_MUTATOR(cl_offhand_blaster, true); + +MUTATOR_HOOKFUNCTION(cl_offhand_blaster, BuildGameplayTipsString) +{ + M_ARGV(0, string) = strcat(M_ARGV(0, string), + "\n\n", _("^3offhand blaster^8 is enabled, press 'e' (+hook) to use it"), "\n"); +} diff --git a/qcsrc/common/mutators/mutator/offhand_blaster/cl_offhand_blaster.qh b/qcsrc/common/mutators/mutator/offhand_blaster/cl_offhand_blaster.qh new file mode 100644 index 000000000..6f70f09be --- /dev/null +++ b/qcsrc/common/mutators/mutator/offhand_blaster/cl_offhand_blaster.qh @@ -0,0 +1 @@ +#pragma once diff --git a/qcsrc/common/mutators/mutator/offhand_blaster/sv_offhand_blaster.qc b/qcsrc/common/mutators/mutator/offhand_blaster/sv_offhand_blaster.qc index fbffa8a43..931ab1ad9 100644 --- a/qcsrc/common/mutators/mutator/offhand_blaster/sv_offhand_blaster.qc +++ b/qcsrc/common/mutators/mutator/offhand_blaster/sv_offhand_blaster.qc @@ -14,11 +14,6 @@ MUTATOR_HOOKFUNCTION(offhand_blaster, BuildMutatorsPrettyString) M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Offhand blaster"); } -MUTATOR_HOOKFUNCTION(offhand_blaster, BuildGameplayTipsString) -{ - M_ARGV(0, string) = strcat(M_ARGV(0, string), "\n\n^3offhand blaster^8 is enabled, press 'e' (+hook) to use it\n"); -} - MUTATOR_HOOKFUNCTION(offhand_blaster, PlayerSpawn) { entity player = M_ARGV(0, entity); diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 15cac948a..c27ba948c 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -1053,11 +1053,6 @@ void SendWelcomemessage(entity this, bool force_centerprint) WriteString(MSG_ONE, cache_mutatormsg); - string mutator_msg = ""; - MUTATOR_CALLHOOK(BuildGameplayTipsString, mutator_msg); - mutator_msg = M_ARGV(0, string); - - WriteString(MSG_ONE, mutator_msg); // trust that the mutator will do proper formatting WriteString(MSG_ONE, strreplace("\\n", "\n", autocvar_sv_motd)); }