Tweak the system sound to use 0.5 as the default volume, instead of 1.0. This allows...
[voretournament/voretournament.git] / data / qcsrc / menu / gamecommand.qc
1 void GameCommand_Init()\r
2 {\r
3         // make gg call menu QC theCommands\r
4         localcmd("alias qc_cmd \"menu_cmd $*\"\n");\r
5 }\r
6 \r
7 string _dumptree_space;\r
8 void _dumptree_open(entity pass, entity me)\r
9 {\r
10         string s;\r
11         s = me.toString(me);\r
12         if(s == "")\r
13                 s = me.classname;\r
14         else\r
15                 s = strcat(me.classname, ": ", s);\r
16         print(_dumptree_space, etos(me), " (", s, ")");\r
17         if(me.firstChild)\r
18         {\r
19                 print(" {\n");\r
20                 _dumptree_space = strcat(_dumptree_space, "  ");\r
21         }\r
22         else\r
23                 print("\n");\r
24 }\r
25 void _dumptree_close(entity pass, entity me)\r
26 {\r
27         if(me.firstChild)\r
28         {\r
29                 _dumptree_space = substring(_dumptree_space, 0, strlen(_dumptree_space) - 2);\r
30                 print(_dumptree_space, "}\n");\r
31         }\r
32 }\r
33 \r
34 void GameCommand(string theCommand)\r
35 {\r
36         float argc;\r
37         argc = tokenize_console(theCommand);\r
38 \r
39         if(argv(0) == "help" || argc == 0)\r
40         {\r
41                 print("Usage: menu_cmd theCommand..., where possible theCommands are:\n");\r
42                 print("  sync - reloads all cvars on the current menu page\n");\r
43                 print("  directmenu ITEM - select a menu item as main item\n");\r
44                 GameCommand_Generic("help");\r
45                 return;\r
46         }\r
47 \r
48         if(GameCommand_Generic(theCommand))\r
49                 return;\r
50 \r
51         if(argv(0) == "sync")\r
52         {\r
53                 loadAllCvars(main);\r
54                 return;\r
55         }\r
56 \r
57         if(argv(0) == "directmenu") if(argc == 2)\r
58         {\r
59                 // switch to a menu item\r
60                 if(!isdemo()) // don't allow this command in demos\r
61                         m_goto(argv(1));\r
62                 return;\r
63         }\r
64 \r
65         if(argv(0) == "skinselect")\r
66         {\r
67                 m_goto_skin_selector();\r
68                 return;\r
69         }\r
70 \r
71         if(argv(0) == "videosettings")\r
72         {\r
73                 m_goto_video_settings();\r
74                 return;\r
75         }\r
76 \r
77         if(argv(0) == "dumptree")\r
78         {\r
79                 _dumptree_space = "";\r
80                 depthfirst(main, parent, firstChild, nextSibling, _dumptree_open, _dumptree_close, NULL);\r
81                 return;\r
82         }\r
83 \r
84         if(argv(0) == "setresolution")\r
85         {\r
86                 updateConwidths();\r
87                 return;\r
88         }\r
89 \r
90 #if 0\r
91         if(argv(0) == "tokentest")\r
92         {\r
93                 string s;\r
94                 float i, n;\r
95 \r
96                 print("SANE tokenizer:\n");\r
97                 s = cvar_string("tokentest");\r
98                 n = tokenize_console_force_builtin(s);\r
99                 for(i = -n; i < n; ++i)\r
100                 {\r
101                         print("token ", ftos(i), ": '", argv(i), "' = ");\r
102                         print(ftos(argv_start_index(i)), " to ", ftos(argv_end_index(i)), "\n");\r
103                 }\r
104                 print(".\n");\r
105 \r
106                 print("INSANE tokenizer:\n");\r
107                 s = cvar_string("tokentest");\r
108                 n = tokenize(s);\r
109                 for(i = -n; i < n; ++i)\r
110                 {\r
111                         print("token ", ftos(i), ": '", argv(i), "' = ");\r
112                         print(ftos(argv_start_index(i)), " to ", ftos(argv_end_index(i)), "\n");\r
113                 }\r
114                 print(".\n");\r
115 \r
116                 print("EMULATED tokenizer:\n");\r
117                 s = cvar_string("tokentest");\r
118                 n = tokenize_console_force_emulation(s);\r
119                 for(i = -n; i < n; ++i)\r
120                 {\r
121                         print("token ", ftos(i), ": '", argv(i), "' = ");\r
122                         print(ftos(argv_start_index(i)), " to ", ftos(argv_end_index(i)), "\n");\r
123                 }\r
124                 print(".\n");\r
125                 return;\r
126         }\r
127 #endif\r
128 \r
129         print("Invalid theCommand. For a list of supported theCommands, try menu_cmd help.\n");\r
130 }\r