]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/command/menu_cmd.qc
Merge branch 'master' of ssh://gitlab.com/xonotic/xonotic-data.pk3dir into kickban...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / command / menu_cmd.qc
1 string _dumptree_space;
2 void _dumptree_open(entity pass, entity me)
3 {
4         string s;
5         s = me.toString(me);
6         if(s == "")
7                 s = me.classname;
8         else
9                 s = strcat(me.classname, ": ", s);
10         print(_dumptree_space, etos(me), " (", s, ")");
11         if(me.firstChild)
12         {
13                 print(" {\n");
14                 _dumptree_space = strcat(_dumptree_space, "  ");
15         }
16         else
17                 print("\n");
18 }
19 void _dumptree_close(entity pass, entity me)
20 {
21         if(me.firstChild)
22         {
23                 _dumptree_space = substring(_dumptree_space, 0, strlen(_dumptree_space) - 2);
24                 print(_dumptree_space, "}\n");
25         }
26 }
27
28 void GameCommand(string theCommand)
29 {
30         float argc;
31         argc = tokenize_console(theCommand);
32
33         if(argv(0) == "help" || argc == 0)
34         {
35                 print(_("Usage: menu_cmd command..., where possible commands are:\n"));
36                 print(_("  sync - reloads all cvars on the current menu page\n"));
37                 print(_("  directmenu ITEM - select a menu item as main item\n"));
38
39                 print("\nGeneric commands shared by all programs:\n");
40                 GenericCommand_macro_help();
41
42                 return;
43         }
44
45         if(GenericCommand(theCommand))
46                 return;
47
48         if(argv(0) == "sync")
49         {
50                 m_sync();
51                 return;
52         }
53
54         if(argv(0) == "update_conwidths_before_vid_restart")
55         {
56                 updateConwidths(cvar("vid_width"), cvar("vid_height"), cvar("vid_pixelheight"));
57                 return;
58         }
59
60         if(argv(0) == "directmenu" || argv(0) == "directpanelhudmenu")
61         {
62                 string filter = string_null;
63                 if(argv(0) == "directpanelhudmenu")
64                         filter = strzone("HUD");
65
66                 if(argc == 1)
67                 {
68                         print(_("Available options:\n"));
69                         float i;
70                         entity e;
71                         string s;
72
73                         for(i = 0, e = world; (e = nextent(e)); )
74                                 if(e.classname != "vtbl" && e.name != "")
75                                 {
76                                         s = e.name;
77                                         if(filter)
78                                         {
79                                                 if(substring(s, 0, strlen(filter)) != filter)
80                                                         continue;
81                                                 s = substring(s, strlen(filter), strlen(s) - strlen(filter));
82                                         }
83                                         print(strcat(" ", s ,"\n"));
84                                         ++i;
85                                 }
86                 }
87                 else if(argc == 2 && !isdemo()) // don't allow this command in demos
88                 {
89                         m_play_click_sound(MENU_SOUND_OPEN);
90                         m_goto(strcat(filter, argv(1))); // switch to a menu item
91                 }
92                 if(filter)
93                         strunzone(filter);
94                 return;
95         }
96
97         if(argv(0) == "skinselect")
98         {
99                 m_goto("skinselector");
100                 return;
101         }
102
103         if(argv(0) == "languageselect")
104         {
105                 m_goto("languageselector");
106                 return;
107         }
108
109         if(argv(0) == "videosettings")
110         {
111                 m_goto("videosettings");
112                 return;
113         }
114
115         if(argv(0) == "dumptree")
116         {
117                 _dumptree_space = "";
118                 depthfirst(main, parent, firstChild, nextSibling, _dumptree_open, _dumptree_close, NULL);
119                 return;
120         }
121
122         print(_("Invalid command. For a list of supported commands, try menu_cmd help.\n"));
123 }