]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/command/menu_cmd.qc
Merge branch 'master' into terencehill/directmenu_options
[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                 GenericCommand("help");
39                 return;
40         }
41
42         if(GenericCommand(theCommand))
43                 return;
44
45         if(argv(0) == "sync")
46         {
47                 m_sync();
48                 return;
49         }
50
51         if(argv(0) == "directmenu" || argv(0) == "directpanelhudmenu")
52         {
53                 string filter;
54                 if(argv(0) == "directpanelhudmenu")
55                         filter = strzone("HUD");
56
57                 if(argc == 1)
58                 {
59                         print(_("Available options:\n"));
60                         float i;
61                         entity e;
62                         string s;
63
64                         for(i = 0, e = world; (e = nextent(e)); )
65                                 if(e.classname != "vtbl" && e.name != "")
66                                 {
67                                         s = e.name;
68                                         if(filter)
69                                         {
70                                                 if(substring(s, 0, strlen(filter)) != filter)
71                                                         continue;
72                                                 s = substring(s, strlen(filter), strlen(s) - strlen(filter));
73                                         }
74                                         print(strcat(" ", s ,"\n"));
75                                         ++i;
76                                 }
77                 }
78                 else if(argc == 2 && !isdemo()) // don't allow this command in demos
79                         m_goto(strcat(filter, argv(1))); // switch to a menu item
80                 if(filter)
81                         strunzone(filter);
82                 return;
83         }
84
85         if(argv(0) == "skinselect")
86         {
87                 m_goto("skinselector");
88                 return;
89         }
90
91         if(argv(0) == "languageselect")
92         {
93                 m_goto("languageselector");
94                 return;
95         }
96
97         if(argv(0) == "videosettings")
98         {
99                 m_goto("videosettings");
100                 return;
101         }
102
103         if(argv(0) == "dumptree")
104         {
105                 _dumptree_space = "";
106                 depthfirst(main, parent, firstChild, nextSibling, _dumptree_open, _dumptree_close, NULL);
107                 return;
108         }
109
110         if(argv(0) == "curl")
111         {
112         }
113
114         print(_("Invalid command. For a list of supported commands, try menu_cmd help.\n"));
115 }