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"));
54 LOG_INFO("Generic commands shared by all programs:");
55 GenericCommand_macro_help();
60 if (GenericCommand(theCommand)) return;
62 if (argv(0) == "sync")
68 if (argv(0) == "update_conwidths_before_vid_restart")
70 updateConwidths(cvar("vid_width"), cvar("vid_height"), cvar("vid_pixelheight"));
74 if (argv(0) == "directmenu" || argv(0) == "directpanelhudmenu")
76 string filter = string_null;
77 if (argv(0) == "directpanelhudmenu") filter = "HUD";
81 LOG_INFO(_("Available options:"));
83 FOREACH_ENTITY_ORDERED(it.name != "", {
84 if (it.classname == "vtbl") continue;
88 if (!startsWith(s, filter)) continue;
89 s = substring(s, strlen(filter), strlen(s) - strlen(filter));
94 else if (argc == 2 && !isdemo()) // don't allow this command in demos
96 m_play_click_sound(MENU_SOUND_OPEN);
97 m_goto(strcat(filter, argv(1))); // switch to a menu item
102 if (argv(0) == "skinselect")
104 m_goto("skinselector");
108 if (argv(0) == "languageselect")
110 m_goto("languageselector");
114 if (argv(0) == "videosettings")
116 m_goto("videosettings");
120 if (argv(0) == "dumptree")
122 _dumptree_space = "";
123 depthfirst(main, parent, firstChild, nextSibling, _dumptree_open, _dumptree_close, NULL);
127 if(MUTATOR_CALLHOOK(Menu_ConsoleCommand, ss, argc, theCommand)) // handled by a mutator
130 LOG_INFO(_("Invalid command. For a list of supported commands, try menu_cmd help."));