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