1 string _dumptree_space;
2 void _dumptree_open(entity pass, entity me)
9 s = strcat(me.classname, ": ", s);
10 print(_dumptree_space, etos(me), " (", s, ")");
14 _dumptree_space = strcat(_dumptree_space, " ");
19 void _dumptree_close(entity pass, entity me)
23 _dumptree_space = substring(_dumptree_space, 0, strlen(_dumptree_space) - 2);
24 print(_dumptree_space, "}\n");
28 float curl_uri_get_pos;
29 float curl_uri_get_exec[URI_GET_CURL_END - URI_GET_CURL + 1];
30 string curl_uri_get_cvar[URI_GET_CURL_END - URI_GET_CURL + 1];
31 void Curl_URI_Get_Callback(float id, float status, string data)
36 i = id - URI_GET_CURL;
37 do_exec = curl_uri_get_exec[i];
38 do_cvar = curl_uri_get_cvar[i];
41 print(sprintf(_("error: status is %d\n"), status));
50 cvar_set(do_cvar, data);
53 if(!do_exec && !do_cvar)
57 void GameCommand(string theCommand)
60 argc = tokenize_console(theCommand);
62 if(argv(0) == "help" || argc == 0)
64 print(_("Usage: menu_cmd command..., where possible commands are:\n"));
65 print(_(" sync - reloads all cvars on the current menu page\n"));
66 print(_(" directmenu ITEM - select a menu item as main item\n"));
67 GenericCommand("help");
71 if(GenericCommand(theCommand))
80 if(argv(0) == "directmenu") if(argc == 2)
82 // switch to a menu item
83 if(!isdemo()) // don't allow this command in demos
88 if(argv(0) == "directpanelhudmenu")
90 // switch to a menu item
91 m_goto(strcat("HUD", argv(1)));
95 if(argv(0) == "skinselect")
97 m_goto_skin_selector();
101 if(argv(0) == "languageselect")
103 m_goto_language_selector();
107 if(argv(0) == "videosettings")
109 m_goto_video_settings();
113 if(argv(0) == "dumptree")
115 _dumptree_space = "";
116 depthfirst(main, parent, firstChild, nextSibling, _dumptree_open, _dumptree_close, NULL);
120 if(argv(0) == "curl")
131 do_cvar = string_null;
134 for(i = 1; i+1 < argc; ++i)
136 if(argv(i) == "--cvar" && i+2 < argc)
139 do_cvar = strzone(argv(i));
142 if(argv(i) == "--exec")
147 if(argv(i) == "--key" && i+2 < argc)
156 // now, argv(i) is the URL
157 // following args may be POST parameters
162 for(; i+1 < argc; i += 2)
163 bufstr_set(buf, ++j, sprintf("%s=%s", uri_escape(argv(i)), uri_escape(argv(i+1))));
165 bufstr_set(buf, ++j, sprintf("submit=%s", uri_escape(argv(i))));
167 if(j == 0) // no args: GET
168 r = crypto_uri_postbuf(url, URI_GET_CURL + curl_uri_get_pos, string_null, string_null, -1, key);
169 else // with args: POST
170 r = crypto_uri_postbuf(url, URI_GET_CURL + curl_uri_get_pos, "application/x-www-form-urlencoded", "&", buf, key);
174 curl_uri_get_exec[curl_uri_get_pos] = do_exec;
175 curl_uri_get_cvar[curl_uri_get_pos] = do_cvar;
176 curl_uri_get_pos = mod(curl_uri_get_pos + 1, URI_GET_CURL_END - URI_GET_CURL + 1);
179 print(_("error creating curl handle\n"));
186 print(_("Invalid command. For a list of supported commands, try menu_cmd help.\n"));