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