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