6 #include <menu/mutators/_mod.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 print(_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 print(_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:"));
49 LOG_INFO(_(" sync - reloads all cvars on the current menu page"));
50 LOG_INFO(_(" directmenu ITEM - select a menu item as main item"));
51 LOG_INFO(_(" dumptree - dump the state of the menu as a tree to the console"));
53 LOG_INFO("Generic commands shared by all programs:");
54 GenericCommand_macro_help();
59 if (GenericCommand(theCommand)) return;
61 if (argv(0) == "sync")
67 if (argv(0) == "update_conwidths_before_vid_restart")
69 updateConwidths(cvar("vid_width"), cvar("vid_height"), cvar("vid_pixelheight"));
73 if (argv(0) == "directmenu" || argv(0) == "directpanelhudmenu")
75 string filter = string_null;
76 if (argv(0) == "directpanelhudmenu") filter = "HUD";
80 LOG_INFO(_("Available options:"));
82 FOREACH_ENTITY_ORDERED(it.name != "", {
83 if (it.classname == "vtbl") continue;
87 if (!startsWith(s, filter)) continue;
88 s = substring(s, strlen(filter), strlen(s) - strlen(filter));
93 else if (argc == 2 && !isdemo()) // don't allow this command in demos
95 m_play_click_sound(MENU_SOUND_OPEN);
96 m_goto(strcat(filter, argv(1))); // switch to a menu item
101 if (argv(0) == "skinselect")
103 m_goto("skinselector");
107 if (argv(0) == "languageselect")
109 m_goto("languageselector");
113 if (argv(0) == "videosettings")
115 m_goto("videosettings");
119 if (argv(0) == "dumptree")
121 _dumptree_space = "";
122 depthfirst(main, parent, firstChild, nextSibling, _dumptree_open, _dumptree_close, NULL);
126 if(MUTATOR_CALLHOOK(Menu_ConsoleCommand, ss, argc, theCommand)) // handled by a mutator
129 LOG_INFO(_("Invalid command. For a list of supported commands, try menu_cmd help."));