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