From: terencehill Date: Fri, 6 May 2022 15:55:34 +0000 (+0200) Subject: Add possibility to load a customized quickmenu file provided by the server in a serve... X-Git-Tag: xonotic-v0.8.6~360^2~2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2c20ffd020303beb3201c5e5bd6fabf11768ffc7;p=xonotic%2Fxonotic-data.pk3dir.git Add possibility to load a customized quickmenu file provided by the server in a serverpackage from within the default quickmenu --- diff --git a/_hud_common.cfg b/_hud_common.cfg index 5fdba6721..74f48a6aa 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -110,6 +110,7 @@ seta hud_panel_itemstime_progressbar_maxtime "30" "when left time is at least th seta hud_panel_itemstime_hidespawned "1" "if 1 hide an item from the panel when all the occurrences of it are available again; if 2 hide it when at least one occurrence is available again" seta hud_panel_itemstime_hidebig "0" "if 1 hide big armor and health from the panel" +set _hud_panel_quickmenu_file_from_server "" "reserved cvar set by the server with a custom server quickmenu file that appears in the default quickmenu" seta hud_panel_quickmenu_file "" "load the quick menu from this file (empty or 0 to disable)" seta hud_panel_quickmenu_translatecommands 0 "when the game is translated, translate strings inside commands too (useful for chat commands)" seta hud_panel_quickmenu_time 5 "quickmenu expires after this number of seconds in the same page" diff --git a/qcsrc/client/command/cl_cmd.qc b/qcsrc/client/command/cl_cmd.qc index 49683b50d..0f8a69e72 100644 --- a/qcsrc/client/command/cl_cmd.qc +++ b/qcsrc/client/command/cl_cmd.qc @@ -267,7 +267,7 @@ void LocalCommand_hud(int request, int argc) { if (argv(2) == "help") { - LOG_HELP(" quickmenu [[default | file | \"\"] submenu file]"); + LOG_HELP(" quickmenu [[default | file | \"\"] ]"); LOG_HELP("Called without options (or with \"\") loads either the default quickmenu or a quickmenu file if hud_panel_quickmenu_file is set to a valid filename."); LOG_HELP("A submenu name can be given to open the quickmenu directly in a submenu; it requires to specify 'default', 'file' or '\"\"' option."); LOG_HELP("A file name can also be given to open a different quickmenu"); diff --git a/qcsrc/client/hud/panel/quickmenu.qc b/qcsrc/client/hud/panel/quickmenu.qc index 01fae6e02..695a58fb0 100644 --- a/qcsrc/client/hud/panel/quickmenu.qc +++ b/qcsrc/client/hud/panel/quickmenu.qc @@ -872,6 +872,12 @@ void QuickMenu_Default(string target_submenu) QUICKMENU_ENTRY(CTX(_("QMCMD^Shuffle teams")), "vcall shuffleteams") QUICKMENU_SMENU(CTX(_("QMCMD^Call a vote")), "Call a vote") + if (autocvar__hud_panel_quickmenu_file_from_server != "") + { + // TODO make it translatable + QUICKMENU_ENTRY("Server's custom quickmenu", "quickmenu; wait; quickmenu \"\" \"\" $_hud_panel_quickmenu_file_from_server") + } + if(spectatee_status != 0) { QUICKMENU_SMENU_PL(CTX(_("QMCMD^Spectate a player")), "Spectate a player", "spectate \"%s^7\"", 0, 1) diff --git a/qcsrc/client/hud/panel/quickmenu.qh b/qcsrc/client/hud/panel/quickmenu.qh index 3b6a1fe72..249b5121f 100644 --- a/qcsrc/client/hud/panel/quickmenu.qh +++ b/qcsrc/client/hud/panel/quickmenu.qh @@ -6,6 +6,7 @@ float autocvar_hud_panel_quickmenu_align; float autocvar_hud_panel_quickmenu_translatecommands; string autocvar_hud_panel_quickmenu_file; float autocvar_hud_panel_quickmenu_time; +string autocvar__hud_panel_quickmenu_file_from_server; bool QuickMenu_InputEvent(float bInputType, float nPrimary, float nSecondary); bool QuickMenu_IsOpened(); diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index cab642e67..88691ae39 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -1145,6 +1145,10 @@ void ClientConnect(entity this) { if (g_weaponarena_weapons == WEPSET(TUBA)) stuffcmd(this, "cl_cmd settemp chase_active 1\n"); + // quickmenu file must be put in a subfolder with an unique name + // to reduce chances of overriding custom client quickmenus + if (autocvar_sv_quickmenu_file != "" && strstrofs(autocvar_sv_quickmenu_file, "/", 0) && fexists(autocvar_sv_quickmenu_file)) + stuffcmd(this, sprintf("cl_cmd settemp _hud_panel_quickmenu_file_from_server %s\n", autocvar_sv_quickmenu_file)); } if (!autocvar_sv_foginterval && world.fog != "") diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index 5fc5422c6..69bf720db 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -50,11 +50,12 @@ string autocvar_hostname; int autocvar_spawn_debug; string autocvar_sv_motd; int autocvar_sv_name_maxlength = 64; +string autocvar_sv_quickmenu_file; bool autocvar_sv_servermodelsonly; +bool autocvar_sv_showspectators; int autocvar_sv_spectate; bool autocvar_sv_teamnagger; float autocvar_sv_player_scale; -bool autocvar_sv_showspectators; // WEAPONTODO .string weaponorder_byimpulse; diff --git a/xonotic-server.cfg b/xonotic-server.cfg index 859314980..334f749a2 100644 --- a/xonotic-server.cfg +++ b/xonotic-server.cfg @@ -595,3 +595,5 @@ set sv_warpzone_allow_selftarget 0 "do not touch" // don't notify cvar changes in the chat sv_disablenotify 1 + +set sv_quickmenu_file "" "filename of the quickmenu that appears in client's default quickmenu, file must be located in a subfolder with an unique name"