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 // TODO port these commands to the command system
47 if (argv(0) == "help" || argc == 0)
49 LOG_HELP("Usage:^3 menu_cmd <command> [<item>], where possible commands are:");
50 LOG_HELP(" 'sync' reloads all cvars on the current menu page");
51 LOG_HELP(" 'directmenu' shows the menu window named <item> (or the menu window containing an item named <item>)");
52 LOG_HELP(" if <item> is not specified it shows the list of available items in the console");
53 LOG_HELP(" 'dumptree' dumps the state of the menu as a tree to the console");
55 LOG_HELP("\nGeneric commands shared by all programs:");
56 GenericCommand_macro_help();
61 if (GenericCommand(theCommand)) return;
63 if (argv(0) == "sync")
69 if (argv(0) == "update_conwidths_before_vid_restart")
71 updateConwidths(cvar("vid_width"), cvar("vid_height"), cvar("vid_pixelheight"));
75 if (argv(0) == "directmenu" || argv(0) == "directpanelhudmenu")
77 string filter = string_null;
78 if (argv(0) == "directpanelhudmenu") filter = "HUD";
82 LOG_HELP("Available items:");
84 FOREACH_ENTITY_ORDERED(it.name != "", {
85 if (it.classname == "vtbl") continue;
89 if (!startsWith(s, filter)) continue;
90 s = substring(s, strlen(filter), strlen(s) - strlen(filter));
95 else if (argc == 2 && !isdemo()) // don't allow this command in demos
97 m_play_click_sound(MENU_SOUND_OPEN);
98 m_goto(strcat(filter, argv(1))); // switch to a menu item
103 if (argv(0) == "skinselect")
105 m_goto("skinselector");
109 if (argv(0) == "languageselect")
111 m_goto("languageselector");
115 if (argv(0) == "videosettings")
117 m_goto("videosettings");
121 if (argv(0) == "dumptree")
123 _dumptree_space = "";
124 depthfirst(main, parent, firstChild, nextSibling, _dumptree_open, _dumptree_close, NULL);
128 if(MUTATOR_CALLHOOK(Menu_ConsoleCommand, ss, argc, theCommand)) // handled by a mutator
131 LOG_INFO("Invalid command. For a list of supported commands, try menu_cmd help.");