6 #include "../mutators/events.qh"
8 #include <common/command/_mod.qh>
10 .entity firstChild, nextSibling;
12 string _dumptree_space;
13 void _dumptree_open(entity pass, entity me)
17 if (s == "") s = me.classname;
18 else s = strcat(me.classname, ": ", s);
19 LOG_INFO(_dumptree_space, etos(me), " (", s, ")");
23 _dumptree_space = strcat(_dumptree_space, " ");
30 void _dumptree_close(entity pass, entity me)
34 _dumptree_space = substring(_dumptree_space, 0, strlen(_dumptree_space) - 2);
35 LOG_INFO(_dumptree_space, "}\n");
39 float updateConwidths(float width, float height, float pixelheight);
41 void GameCommand(string theCommand)
43 int argc = tokenize_console(theCommand);
44 string ss = strtolower(argv(0));
46 if (argv(0) == "help" || argc == 0)
48 LOG_INFO(_("Usage: menu_cmd command..., where possible commands are:\n"));
49 LOG_INFO(_(" sync - reloads all cvars on the current menu page\n"));
50 LOG_INFO(_(" directmenu ITEM - select a menu item as main item\n"));
52 LOG_INFO("\nGeneric commands shared by all programs:\n");
53 GenericCommand_macro_help();
58 if (GenericCommand(theCommand)) return;
60 if (argv(0) == "sync")
66 if (argv(0) == "update_conwidths_before_vid_restart")
68 updateConwidths(cvar("vid_width"), cvar("vid_height"), cvar("vid_pixelheight"));
72 if (argv(0) == "directmenu" || argv(0) == "directpanelhudmenu")
74 string filter = string_null;
75 if (argv(0) == "directpanelhudmenu") filter = "HUD";
79 LOG_INFO(_("Available options:\n"));
81 FOREACH_ENTITY_ORDERED(it.name != "", {
82 if (it.classname == "vtbl") continue;
86 if (!startsWith(s, filter)) continue;
87 s = substring(s, strlen(filter), strlen(s) - strlen(filter));
89 LOG_INFOF(" %s\n", s);
92 else if (argc == 2 && !isdemo()) // don't allow this command in demos
94 m_play_click_sound(MENU_SOUND_OPEN);
95 m_goto(strcat(filter, argv(1))); // switch to a menu item
100 if (argv(0) == "skinselect")
102 m_goto("skinselector");
106 if (argv(0) == "languageselect")
108 m_goto("languageselector");
112 if (argv(0) == "videosettings")
114 m_goto("videosettings");
118 if (argv(0) == "dumptree")
120 _dumptree_space = "";
121 depthfirst(main, parent, firstChild, nextSibling, _dumptree_open, _dumptree_close, NULL);
125 if(MUTATOR_CALLHOOK(Menu_ConsoleCommand, ss, argc, theCommand)) // handled by a mutator
128 LOG_INFO(_("Invalid command. For a list of supported commands, try menu_cmd help.\n"));