From 606cd54963445b5e07344253d1f6cddb72bc5ad8 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 13 Jul 2020 17:33:15 +1000 Subject: [PATCH] Move LMS info message to its own file --- qcsrc/client/hud/panel/infomessages.qc | 20 ++++--------- qcsrc/client/mutators/events.qh | 5 +++- qcsrc/common/gamemodes/gamemode/lms/_mod.inc | 3 ++ qcsrc/common/gamemodes/gamemode/lms/_mod.qh | 3 ++ qcsrc/common/gamemodes/gamemode/lms/cl_lms.qc | 30 +++++++++++++++++++ qcsrc/common/gamemodes/gamemode/lms/cl_lms.qh | 1 + 6 files changed, 47 insertions(+), 15 deletions(-) create mode 100644 qcsrc/common/gamemodes/gamemode/lms/cl_lms.qc create mode 100644 qcsrc/common/gamemodes/gamemode/lms/cl_lms.qh diff --git a/qcsrc/client/hud/panel/infomessages.qc b/qcsrc/client/hud/panel/infomessages.qc index 627fd67ef..83897dfd3 100644 --- a/qcsrc/client/hud/panel/infomessages.qc +++ b/qcsrc/client/hud/panel/infomessages.qc @@ -4,7 +4,6 @@ #include #include -#include // Info messages (#14) @@ -122,22 +121,15 @@ void HUD_InfoMessages() InfoMessage(s); } - MUTATOR_CALLHOOK(DrawInfoMessages, pos, mySize); + bool mutator_returnvalue = MUTATOR_CALLHOOK(DrawInfoMessages, pos, mySize, img_curr_group); + pos = M_ARGV(0, vector); + img_curr_group = M_ARGV(2, int); - if(!warmup_stage && ISGAMETYPE(LMS)) + if(!mutator_returnvalue) { - entity sk; - sk = playerslots[player_localnum]; - if(sk.(scores(ps_primary)) >= 666) - s = _("^1Match has already begun"); - else if(sk.(scores(ps_primary)) > 0) - s = _("^1You have no more lives left"); - else - s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey(_("jump"), "+jump")); - } - else s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey(_("jump"), "+jump")); - InfoMessage(s); + InfoMessage(s); + } } if (time < STAT(GAMESTARTTIME)) diff --git a/qcsrc/client/mutators/events.qh b/qcsrc/client/mutators/events.qh index 0629c2a9f..d08b020e3 100644 --- a/qcsrc/client/mutators/events.qh +++ b/qcsrc/client/mutators/events.qh @@ -163,10 +163,13 @@ MUTATOR_HOOKABLE(DrawCrosshair, EV_NO_ARGS); /** Return true to not draw scoreboard */ MUTATOR_HOOKABLE(DrawScoreboard, EV_NO_ARGS); -/** Called when drawing info messages, allows adding new info messages */ +/** Called when drawing info messages, allows adding new info messages. Return true to hide the standard join message */ #define EV_DrawInfoMessages(i, o) \ /** pos */ i(vector, MUTATOR_ARGV_0_vector) \ + /***/ o(vector, MUTATOR_ARGV_0_vector) \ /** mySize */ i(vector, MUTATOR_ARGV_1_vector) \ + /** img_curr_group */ i(int, MUTATOR_ARGV_2_int) \ + /***/ o(int, MUTATOR_ARGV_2_int) \ /**/ MUTATOR_HOOKABLE(DrawInfoMessages, EV_DrawInfoMessages); diff --git a/qcsrc/common/gamemodes/gamemode/lms/_mod.inc b/qcsrc/common/gamemodes/gamemode/lms/_mod.inc index 69be66feb..11f744664 100644 --- a/qcsrc/common/gamemodes/gamemode/lms/_mod.inc +++ b/qcsrc/common/gamemodes/gamemode/lms/_mod.inc @@ -1,5 +1,8 @@ // generated file; do not modify #include +#ifdef CSQC + #include +#endif #ifdef SVQC #include #endif diff --git a/qcsrc/common/gamemodes/gamemode/lms/_mod.qh b/qcsrc/common/gamemodes/gamemode/lms/_mod.qh index cbb42ad8d..1b1143f4b 100644 --- a/qcsrc/common/gamemodes/gamemode/lms/_mod.qh +++ b/qcsrc/common/gamemodes/gamemode/lms/_mod.qh @@ -1,5 +1,8 @@ // generated file; do not modify #include +#ifdef CSQC + #include +#endif #ifdef SVQC #include #endif diff --git a/qcsrc/common/gamemodes/gamemode/lms/cl_lms.qc b/qcsrc/common/gamemodes/gamemode/lms/cl_lms.qc new file mode 100644 index 000000000..649f964f5 --- /dev/null +++ b/qcsrc/common/gamemodes/gamemode/lms/cl_lms.qc @@ -0,0 +1,30 @@ +#include "cl_lms.qh" + +REGISTER_MUTATOR(cl_lms, true); + +MUTATOR_HOOKFUNCTION(cl_lms, DrawInfoMessages) +{ + if(!warmup_stage && ISGAMETYPE(LMS)) + { + entity sk = playerslots[player_localnum]; + vector pos = M_ARGV(0, vector); + vector mySize = M_ARGV(1, vector); + vector fontsize = '0.2 0.2 0' * mySize.y; + int img_curr_group = M_ARGV(2, int); + if(sk.(scores(ps_primary)) >= 666) + { + InfoMessage(_("^1Match has already begun")); + M_ARGV(0, vector) = pos; + M_ARGV(2, int) = img_curr_group; + return true; + } + else if(sk.(scores(ps_primary)) > 0) + { + InfoMessage(_("^1You have no more lives left")); + M_ARGV(0, vector) = pos; + M_ARGV(2, int) = img_curr_group; + return true; + } + } + return false; +} diff --git a/qcsrc/common/gamemodes/gamemode/lms/cl_lms.qh b/qcsrc/common/gamemodes/gamemode/lms/cl_lms.qh new file mode 100644 index 000000000..6f70f09be --- /dev/null +++ b/qcsrc/common/gamemodes/gamemode/lms/cl_lms.qh @@ -0,0 +1 @@ +#pragma once -- 2.39.2