Xonotic
menudefs.qc
Go to the documentation of this file.
1 // sys globals
3 
4 entity self;
5 
9 // sys fields
10 
14 // sys functions
15 
16 void() m_init;
17 void(float keynr, float ascii) m_keydown;
18 void(float width, float height) m_draw;
19 void(float mode) m_toggle;
20 void() m_shutdown;
21 // optional: float(float) m_gethostcachecategory;
22 
24 // sys constants
26 // key dest constants
27 
28 float KEY_UNKNOWN = -1;
29 float KEY_GAME = 0;
30 float KEY_MENU = 2;
31 float KEY_MENU_GRABBED = 3;
32 
34 // file constants
35 
36 float FILE_READ = 0;
37 float FILE_APPEND = 1;
38 float FILE_WRITE = 2;
39 
41 // logical constants (just for completeness)
42 
43 float TRUE = 1;
44 float FALSE = 0;
45 
47 // boolean constants
48 
49 float true = 1;
50 float false = 0;
51 
53 // msg constants
54 
55 float MSG_BROADCAST = 0; // unreliable to all
56 float MSG_ONE = 1; // reliable to one (msg_entity)
57 float MSG_ALL = 2; // reliable to all
58 float MSG_INIT = 3; // write to the init string
59 
61 // mouse target constants
62 
63 float MT_MENU = 1;
64 float MT_CLIENT = 2;
65 
67 // client state constants
68 
69 float CS_DEDICATED = 0;
70 float CS_DISCONNECTED = 1;
71 float CS_CONNECTED = 2;
72 
74 // blend flags
75 
76 float DRAWFLAG_NORMAL = 0;
80 
82 // null entity (actually it is the same like the world entity)
83 
85 
87 // error constants
88 
89 // file handling
90 float ERR_CANNOTOPEN = -1; // fopen
91 float ERR_NOTENOUGHFILEHANDLES = -2; // fopen
92 float ERR_INVALIDMODE = -3; // fopen
93 float ERR_BADFILENAME = -4; // fopen
94 
95 // drawing functions
96 
97 float ERR_NULLSTRING = -1;
98 float ERR_BADDRAWFLAG = -2;
99 float ERR_BADSCALE = -3;
100 float ERR_BADSIZE = -3; // same as ERR_BADSCALE
101 float ERR_NOTCACHED = -4;
102 
103 // server list stuff
110 float SLIST_SORTFIELD = 6;
112 float SLIST_LEGACY_LINE1 = 1024;
113 float SLIST_LEGACY_LINE2 = 1025;
117 float SLIST_TEST_LESS = 3;
124 float SLIST_MASK_AND = 0;
125 float SLIST_MASK_OR = 512;
126 
127 // font stuff
128 float FONT_DEFAULT = 0;
129 float FONT_CONSOLE = 1;
130 float FONT_SBAR = 2;
131 float FONT_NOTIFY = 3;
132 float FONT_CHAT = 4;
134 float FONT_INFOBAR = 6;
135 float FONT_MENU = 7;
136 float FONT_USER = 8; // add to this the index, like FONT_USER+3 = user3. At least 8 of them are supported.
137 float drawfont;
138 
139 /* not supported at the moment
141 // os constants
142 
143 float OS_WINDOWS = 0;
144 float OS_LINUX = 1;
145 float OS_MAC = 2;
146 */
147 
148 
149 
150 
151 
152 
153 
154 
155 
156 
158 // common cmd
160 // AK FIXME: Create perhaps a special builtin file for the common cmds
161 
162 float checkextension(string ext) = #1;
163 
164 // error cmds
165 void error(string err,...) = #2;
166 void objerror(string err,...) = #3;
167 
168 // print
169 
170 void print(string text,...) = #4;
171 void bprint(string text,...) = #5;
172 void sprint(float clientnum, string text,...) = #6;
173 void centerprint(string text,...) = #7;
174 
175 // vector stuff
176 
177 vector normalize(vector v) = #8;
178 float vlen(vector v) = #9;
179 float vectoyaw(vector v) = #10;
180 vector vectoangles(vector v) = #11;
181 
182 float random(void) = #12;
183 
184 void cmd(string command, ...) = #13;
185 
186 // cvar cmds
187 
188 float cvar(string name) = #14;
189 const string str_cvar(string name) = #71;
190 void cvar_set(string name, string value) = #15;
191 
192 void dprint(string text,...) = #16;
193 
194 // conversion functions
195 
196 string ftos(float f) = #17;
197 float fabs(float f) = #18;
198 string vtos(vector v) = #19;
199 string etos(entity e) = #20;
200 
201 float stof(string val,...) = #21;
202 
203 entity spawn(void) = #22;
204 void remove(entity e) = #23;
205 
206 entity find(entity start, .string field, string match) = #24;
207 entity findfloat(entity start, .float field, float match) = #25;
208 entity findentity(entity start, .entity field, entity match) = #25;
209 
210 entity findchainstring(.string field, string match) = #26;
211 entity findchainfloat(.float field, float match) = #27;
212 entity findchainentity(.entity field, entity match) = #27;
213 
214 string precache_file(string file) = #28;
215 string precache_sound(string sample) = #29;
216 
217 void crash(void) = #72;
218 void coredump(void) = #30;
219 void stackdump(void) = #73;
220 void traceon(void) = #31;
221 void traceoff(void) = #32;
222 
223 void eprint(entity e) = #33;
224 float rint(float f) = #34;
225 float floor(float f) = #35;
226 float ceil(float f) = #36;
227 entity nextent(entity e) = #37;
228 float sin(float f) = #38;
229 float cos(float f) = #39;
230 float sqrt(float f) = #40;
231 vector randomvec(void) = #41;
232 
233 float registercvar(string name, string value, float flags) = #42; // returns 1 if success
234 
235 float min(float f,...) = #43;
236 float max(float f,...) = #44;
237 
238 float bound(float min,float value, float max) = #45;
239 float pow(float a, float b) = #46;
240 
241 void copyentity(entity src, entity dst) = #47;
242 
243 float fopen(string filename, float mode) = #48;
244 void fclose(float fhandle) = #49;
245 string fgets(float fhandle) = #50;
246 void fputs(float fhandle, string s) = #51;
247 
248 float strlen(string s) = #52;
249 string strcat(string s1,string s2,...) = #53;
250 string substring(string s, float start, float length) = #54;
251 
252 vector stov(string s) = #55;
253 
254 string strzone(string s) = #56;
255 void strunzone(string s) = #57;
256 
257 float tokenize(string s) = #58;
258 string argv(float n) = #59;
259 
260 float isserver(void) = #60;
261 float clientcount(void) = #61;
262 float clientstate(void) = #62;
263 void clientcommand(float client, string s) = #63;
264 void changelevel(string map) = #64;
265 void localsound(string sample) = #65;
266 vector getmousepos(void) = #66;
267 float gettime(void) = #67;
268 void loadfromdata(string data) = #68;
269 void loadfromfile(string file) = #69;
270 
271 float mod(float val, float m) = #70;
272 
273 float search_begin(string pattern, float caseinsensitive, float quiet) = #74;
274 void search_end(float handle) = #75;
275 float search_getsize(float handle) = #76;
276 string search_getfilename(float handle, float num) = #77;
277 
278 string chr(float ascii) = #78;
279 
281 // Write* Functions
283 void WriteByte(float data, float dest, float desto) = #401;
284 void WriteChar(float data, float dest, float desto) = #402;
285 void WriteShort(float data, float dest, float desto) = #403;
286 void WriteLong(float data, float dest, float desto) = #404;
287 void WriteAngle(float data, float dest, float desto) = #405;
288 void WriteCoord(float data, float dest, float desto) = #406;
289 void WriteString(string data, float dest, float desto)= #407;
290 void WriteEntity(entity data, float dest, float desto) = #408;
291 
293 // Draw funtions
295 
296 float iscachedpic(string name) = #451;
297 string precache_pic(string name, ...) = #452;
298 void freepic(string name) = #453;
299 
300 float drawcharacter(vector position, float character, vector scale, vector rgb, float alpha, float flag) = #454;
301 
302 float drawstring(vector position, string text, vector scale, vector rgb, float alpha, float flag) = #455;
303 
304 float drawcolorcodedstring(vector position, string text, vector scale, float alpha, float flag) = #467;
305 
306 vector drawcolorcodedstring2(vector position, string text, vector scale, vector rgb, float alpha, float flag) = #467;
307 
308 float drawpic(vector position, string pic, vector size, vector rgb, float alpha, float flag) = #456;
309 
310 float drawfill(vector position, vector size, vector rgb, float alpha, float flag) = #457;
311 
312 void drawsetcliparea(float x, float y, float width, float height) = #458;
313 
314 void drawresetcliparea(void) = #459;
315 
316 vector drawgetimagesize(string pic) = #460;
317 
319 // Menu functions
321 
322 void setkeydest(float dest) = #601;
323 float getkeydest(void) = #602;
324 
325 void setmousetarget(float trg) = #603;
326 float getmousetarget(void) = #604;
327 
328 float isfunction(string function_name) = #607;
329 void callfunction(...) = #605;
330 void writetofile(float fhandle, entity ent) = #606;
331 vector getresolution(float number) = #608;
332 string keynumtostring(float keynum) = #609;
333 
334 float gethostcachevalue(float type) = #611;
335 string gethostcachestring(float type, float hostnr) = #612;
336 
337 //DP_CSQC_BINDMAPS
338 //idea: daemon, motorsep
339 //darkplaces implementation: divVerent
340 //builtin definitions:
341 string(float key, float bindmap) getkeybind_bindmap = #342;
342 float(float key, string bind, float bindmap) setkeybind_bindmap = #630;
343 vector(void) getbindmaps = #631;
344 float(vector bm) setbindmaps = #632;
345 string(string command, float bindmap) findkeysforcommand = #610;
346 float(string key) stringtokeynum = #341;
347 //<also allowed builtin number to match EXT_CSQC> string(float keynum) keynumtostring = #340;
348 //description: key bind setting/getting including support for switchable
349 //bindmaps.
350 
351 //DP_CRYPTO
352 //idea: divVerent
353 //darkplaces implementation: divVerent
354 //field definitions: (MENUQC)
355 string(string serveraddress) crypto_getkeyfp = #633; // retrieves the cached host key's CA fingerprint of a server given by IP address
356 string(string serveraddress) crypto_getidfp = #634; // retrieves the cached host key fingerprint of a server given by IP address
357 float(string serveraddress) crypto_getidstatus = #643; // retrieves the cached host key's key status. See below for CRYPTO_IDSTATUS_ defines.
358 string(string serveraddress) crypto_getencryptlevel = #635; // 0 if never encrypting, 1 supported, 2 requested, 3 required, appended by list of allowed methods in order of preference ("AES128"), preceded by a space each
359 string(float i) crypto_getmykeyfp = #636; // retrieves the CA key fingerprint of a given CA slot, or "" if slot is unused but more to come, or string_null if end of list
360 string(float i) crypto_getmyidfp = #637; // retrieves the ID fingerprint of a given CA slot, or "" if slot is unused but more to come, or string_null if end of list
365 float(float i) crypto_getmyidstatus = #641; // retrieves the ID's status of a given CA slot, or 0 if slot is unused but more to come, or -1 if end of list
366 float(string url, float id, string content_type, string delim, float buf, float keyid) crypto_uri_postbuf = #513;
367 //description:
368 //use -1 as buffer handle to justs end delim as postdata
369 
370 //DP_GECKO_SUPPORT
371 //idea: Res2k, BlackHC
372 //darkplaces implementation: Res2k, BlackHC
373 //constant definitions:
375 float GECKO_BUTTON_UP = 1;
376 // either use down and up or just press but not all of them!
378 // use this for mouse events if needed?
380 //builtin definitions:
381 float gecko_create( string name ) = #487;
382 void gecko_destroy( string name ) = #488;
383 void gecko_navigate( string name, string URI ) = #489;
384 float gecko_keyevent( string name, float key, float eventtype ) = #490;
385 void gecko_mousemove( string name, float x, float y ) = #491;
386 void gecko_resize( string name, float w, float h ) = #492;
387 vector gecko_get_texture_extent( string name ) = #493;
388 //engine-called QC prototypes:
389 //string(string name, string query) Qecko_Query;
390 //description:
391 //provides an interface to the offscreengecko library and allows for internet browsing in games
392 
393 //FTE_STRINGS
394 //idea: many
395 //darkplaces implementation: KrimZon
396 //description:
397 //various string manipulation functions
398 float(string str, string sub, float startpos) strstrofs = #221;
399 float(string str, float ofs) str2chr = #222;
400 string(float c, ...) chr2str = #223;
401 string(float ccase, float calpha, float cnum, string s, ...) strconv = #224;
402 string(float chars, string s, ...) strpad = #225;
403 string(string info, string key, string value, ...) infoadd = #226;
404 string(string info, string key) infoget = #227;
405 float(string s1, string s2) strcmp = #228;
406 float(string s1, string s2, float len) strncmp = #228;
407 float(string s1, string s2) strcasecmp = #229;
408 float(string s1, string s2, float len) strncasecmp = #230;
409 
410 //DP_PRECACHE_PIC_FLAGS
411 //idea: divVerent
412 //darkplaces implementation: divVerent
413 //constant definitions:
414 float PRECACHE_PIC_FROMWAD = 1; // this one actually is part of EXT_CSQC
415 float PRECACHE_PIC_NOTPERSISTENT = 2; // picture may get deallocated when unused
416 float PRECACHE_PIC_MIPMAP = 8; // mipmap the texture for possibly better downscaling at memory expense
417 //notes: these constants are given as optional second argument to precache_pic()
418 
419 //DP_QC_CRC16
420 //idea: div0
421 //darkplaces implementation: div0
422 //Some hash function to build hash tables with. This has to be be the CRC-16-CCITT that is also required for the QuakeWorld download protocol.
423 //When caseinsensitive is set, the CRC is calculated of the lower cased string.
424 float(float caseinsensitive, string s, ...) crc16 = #494;
425 
426 //DP_QC_CVAR_TYPE
427 float(string name) cvar_type = #495;
434 
435 //DP_QC_STRINGBUFFERS
436 //idea: ??
437 //darkplaces implementation: LadyHavoc
438 //functions to manage string buffer objects - that is, arbitrary length string arrays that are handled by the engine
439 float() buf_create = #440;
440 void(float bufhandle) buf_del = #441;
441 float(float bufhandle) buf_getsize = #442;
442 void(float bufhandle_from, float bufhandle_to) buf_copy = #443;
443 void(float bufhandle, float sortpower, float backward) buf_sort = #444;
444 string(float bufhandle, string glue) buf_implode = #445;
445 string(float bufhandle, float string_index) bufstr_get = #446;
446 void(float bufhandle, float string_index, string str) bufstr_set = #447;
447 float(float bufhandle, string str, float order) bufstr_add = #448;
448 void(float bufhandle, float string_index) bufstr_free = #449;
449 void(float bufhandle, string pattern, string antipattern) buf_cvarlist = #517;
450 
451 //DP_QC_STRING_CASE_FUNCTIONS
452 //idea: Dresk
453 //darkplaces implementation: LadyHavoc / Dresk
454 //builtin definitions:
455 string(string s) strtolower = #480; // returns the passed in string in pure lowercase form
456 string(string s) strtoupper = #481; // returns the passed in string in pure uppercase form
457 //description:
458 //provides simple string uppercase and lowercase functions
459 
460 //DP_QC_CVAR_DESCRIPTION
461 //idea: divVerent
462 //DarkPlaces implementation: divVerent
463 //builtin definitions:
464 string(string name) cvar_description = #518;
465 //description:
466 //returns the description of a cvar
467 
468 //DP_QC_DIGEST
469 //idea: motorsep, Spike
470 //DarkPlaces implementation: divVerent
471 //builtin definitions:
472 string(string digest, string data, ...) digest_hex = #639;
473 //description:
474 //returns a given hex digest of given data
475 //the returned digest is always encoded in hexadecimal
476 //only the "MD4" digest is always supported!
477 //if the given digest is not supported, string_null is returned
478 //the digest string is matched case sensitively, use "MD4", not "md4"!
479 
480 //DP_QC_URI_ESCAPE
481 //idea: div0
482 //darkplaces implementation: div0
483 //URI::Escape's functionality
484 string(string in) uri_escape = #510;
485 string(string in) uri_unescape = #511;
486 
487 //DP_QC_URI_GET
488 //idea: divVerent
489 //darkplaces implementation: divVerent
490 //loads text from an URL into a string
491 //returns 1 on success of initiation, 0 if there are too many concurrent
492 //connections already or if the URL is invalid
493 //the following callback will receive the data and MUST exist!
494 // void(float id, float status, string data) URI_Get_Callback;
495 //status is either
496 // negative for an internal error,
497 // 0 for success, or
498 // the HTTP response code on server error (e.g. 404)
499 //if 1 is returned by uri_get, the callback will be called in the future
500 float(string url, float id) uri_get = #513;
501 //DP_QC_URI_POST
502 //idea: divVerent
503 //darkplaces implementation: divVerent
504 //loads text from an URL into a string after POSTing via HTTP
505 //works like uri_get, but uri_post sends data with Content-Type: content_type to the server
506 //and uri_post sends the string buffer buf, joined using the delimiter delim
507 float(string url, float id, string content_type, string data) uri_post = #513;
508 float(string url, float id, string content_type, string delim, float buf) uri_postbuf = #513;
509 
510 //DP_QC_ENTITYDATA
511 //idea: KrimZon
512 //darkplaces implementation: KrimZon
513 //builtin definitions:
514 float() numentityfields = #496;
515 string(float fieldnum) entityfieldname = #497;
516 float(float fieldnum) entityfieldtype = #498;
517 string(float fieldnum, entity ent) getentityfieldstring = #499;
518 float(float fieldnum, entity ent, string s) putentityfieldstring = #500;
519 //constants:
520 //Returned by entityfieldtype
521 float FIELD_STRING = 1;
522 float FIELD_FLOAT = 2;
523 float FIELD_VECTOR = 3;
524 float FIELD_ENTITY = 4;
525 float FIELD_FUNCTION = 6;
526 //description:
527 //Versatile functions intended for storing data from specific entities between level changes, but can be customized for some kind of partial savegame.
528 //WARNING: .entity fields cannot be saved and restored between map loads as they will leave dangling pointers.
529 //numentityfields returns the number of entity fields. NOT offsets. Vectors comprise 4 fields: v, v_x, v_y and v_z.
530 //entityfieldname returns the name as a string, eg. "origin" or "classname" or whatever.
531 //entityfieldtype returns a value that the constants represent, but the field may be of another type in more exotic progs.dat formats or compilers.
532 //getentityfieldstring returns data as would be written to a savegame, eg... "0.05" (float), "0 0 1" (vector), or "Hello World!" (string). Function names can also be returned.
533 //putentityfieldstring puts the data returned by getentityfieldstring back into the entity.
534 
535 //DP_COVERAGE
536 //idea: divVerent
537 //darkplaces implementation: divVerent
538 //function definitions:
539 void coverage() = #642; // Reports a coverage event. The engine counts for each of the calls to this builtin whether it has been called.
540 
541 //DP_QC_FS_SEARCH_PACKFILE
542 //idea: Mario
543 //darkplaces implementation: Mario
544 //builtin definitions:
545 float(string pattern, float caseinsensitive, float quiet, string packfile) search_packfile_begin = #74;
546 //description:
547 //extension to search_begin (DP_QC_FS_SEARCH), performs a filename search with the specified pattern (for example "maps/*.bsp") and stores the results in a search slot (minimum of 128 supported by any engine with this extension), the other functions take this returned search slot number, be sure to search_free when done (they are also freed on progs reload).
548 //only searches for files within the specified packfile, which is expected to match the results of whichpack().
549 
550 // assorted undocumented extensions
551 string(string, float) netaddress_resolve = #625;
552 string(string search, string replace, string subject) strreplace = #484;
553 string(string search, string replace, string subject) strireplace = #485;
554 string(float uselocaltime, string format, ...) strftime = #478;
555 float(string s) tokenize_console = #514;
556 float(float i) argv_start_index = #515;
557 float(float i) argv_end_index = #516;
558 string(float, float) getgamedirinfo = #626;
559 #define GETGAMEDIRINFO_NAME 0
560 #define GETGAMEDIRINFO_DESCRIPTION 1
561 float log(float f) = #532;
562 string(string format, ...) sprintf = #627;
563 string(string s) strdecolorize = #477;
564 entity findflags(entity start, .float field, float match) = #87;
565 entity findchainflags(.float field, float match) = #88;
566 float(string s, string separator1, ...) tokenizebyseparator = #479;
567 float etof(entity ent) = #79;
568 entity ftoe(float num) = #80;
569 float validstring(string str) = #81;
570 float altstr_count(string str) = #82;
571 string altstr_prepare(string str) = #83;
572 string altstr_get(string str, float num) = #84;
573 string altstr_set(string str, float num, string set) = #85;
574 string altstr_ins(string str, float num, string set) = #86;
575 float isdemo() = #349;
576 float drawsubpic(vector position, vector size, string pic, vector srcPosition, vector srcSize, vector rgb, float alpha, float flag) = #469;
577 //vector getresolution(float number, ...) = #608; // optional argument "isfullscreen"
578 void parseentitydata(entity ent, string data) = #613;
579 void resethostcachemasks(void) = #615;
580 void sethostcachemaskstring(float mask, float fld, string str, float op) = #616;
581 void sethostcachemasknumber(float mask, float fld, float num, float op) = #617;
582 void resorthostcache(void) = #618;
583 float SLSF_DESCENDING = 1;
584 float SLSF_FAVORITES = 2;
585 float SLSF_CATEGORIES = 4;
586 void sethostcachesort(float fld, float slsf) = #619;
587 void refreshhostcache(...) = #620; // optional boolean argument "clear_list"
588 float gethostcachenumber(float fld, float hostnr) = #621;
589 float gethostcacheindexforkey(string key) = #622;
590 void addwantedhostcachekey(string key) = #623;
591 string getextresponse(void) = #624;
592 const string cvar_string(string name) = #71;
593 const string cvar_defstring(string name) = #89;
594 float stringwidth(string text, float handleColors, vector size) = #468;
float alpha
Definition: items.qc:14
vector dest
Definition: jumppads.qh:41
spree_inf s1 s2 s3loc s2 s1
Definition: all.inc:265
spree_inf s1 s2 s3loc s2 spree_inf s1 s2 s3loc s2 spree_inf s1 s2 s3loc s2 s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2 f1 f1points s1 s2
Definition: all.inc:438
int int number
Definition: impulse.qc:89
#define str2chr
Definition: dpextensions.qh:45
entity() spawn
#define strncmp
Definition: dpextensions.qh:54
entity err
Definition: promise.qc:44
vector size
Definition: csprogsdefs.qc:114
#define argv_end_index
Definition: dpextensions.qh:30
#define buf_create
Definition: dpextensions.qh:63
#define strcmp
Definition: dpextensions.qh:51
#define argv_start_index
Definition: dpextensions.qh:27
float height
Definition: jumppads.qh:12
#define strstrofs
Definition: dpextensions.qh:42
float scale
Definition: projectile.qc:14
#define tokenize_console
Definition: dpextensions.qh:24
vector v
Definition: ent_cs.qc:116
float flags
Definition: csprogsdefs.qc:129
#define strncasecmp
Definition: dpextensions.qh:60
#define tokenizebyseparator
Definition: dpextensions.qh:21
#define strcasecmp
Definition: dpextensions.qh:57
#define chr2str
Definition: dpextensions.qh:48