From: drjaska Date: Fri, 8 Dec 2023 04:54:17 +0000 (+0200) Subject: create menu_cmd isdemo X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=47f6f51f9de4e7e306067c92b2b66d06cd52cf82;p=xonotic%2Fxonotic-data.pk3dir.git create menu_cmd isdemo --- diff --git a/commands.cfg b/commands.cfg index f7cc14eee..6e8e6b617 100644 --- a/commands.cfg +++ b/commands.cfg @@ -119,6 +119,7 @@ alias menu_showsandboxtools "menu_cmd directmenu SandboxTools" alias menu_showquitdialog "menu_cmd directmenu Quit" alias menu_showgamemenudialog "menu_cmd directmenu GameMenu" alias menu_showmonstertools "menu_cmd directmenu MonsterTools" +alias menu_isdemo "menu_cmd isdemo ${* ?}" // command executed before loading a map by the menu // makes sure maxplayers is at least minplayers or minplayers_per_team * 4 or bot_number + 1 diff --git a/qcsrc/menu/command/menu_cmd.qc b/qcsrc/menu/command/menu_cmd.qc index 97deef1d4..b6f471fbf 100644 --- a/qcsrc/menu/command/menu_cmd.qc +++ b/qcsrc/menu/command/menu_cmd.qc @@ -54,6 +54,8 @@ void GameCommand(string theCommand) LOG_HELP(" 'closemenu' closes the menu window named (or the menu window containing an item named )"); LOG_HELP(" if is not specified it shows the list of available items in the console"); LOG_HELP(" 'dumptree' dumps the state of the menu as a tree to the console"); + LOG_HELP(" 'isdemo' checks if engine is currently running a demo. If given an then 1 / 0 is placed"); + LOG_HELP(" in a cvar with that name. Otherwise _menu_isdemo cvar is written to."); LOG_HELP("\nGeneric commands shared by all programs:"); GenericCommand_macro_help(); @@ -75,21 +77,21 @@ void GameCommand(string theCommand) return; } - string cmd = argv(0); + string argcmd = argv(0); string filter = string_null; bool close_mode = false; - if (cmd == "closemenu") + if (argcmd == "closemenu") { close_mode = true; - cmd = "directmenu"; + argcmd = "directmenu"; } - else if (cmd == "directpanelhudmenu") + else if (argcmd == "directpanelhudmenu") { filter = "HUD"; - cmd = "directmenu"; + argcmd = "directmenu"; } - if (cmd == "directmenu") + if (argcmd == "directmenu") { if (argc == 1) { @@ -201,6 +203,25 @@ void GameCommand(string theCommand) return; } + if (argv(0) == "isdemo") + { + if (isdemo()) + { + if (argv(1) != "") + cvar_set(argv(1), "1"); + else + localcmd("\nset _menu_isdemo 1\n"); + } + else + { + if (argv(1) != "") + cvar_set(argv(1), "0"); + else + localcmd("\nset _menu_isdemo 0\n"); + } + return; + } + if(MUTATOR_CALLHOOK(Menu_ConsoleCommand, ss, argc, theCommand)) // handled by a mutator return;