]> icculus.org git repositories - divverent/darkplaces.git/blob - dpdefs/menudefs.qc
drawcolorcodedstring: support full 6 parms (added starting rgb) and returns color...
[divverent/darkplaces.git] / 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() m_toggle;
20 void() m_shutdown;
21
22 /////////////////////////////////////////////////////////
23 // sys constants
24 ///////////////////////////
25 // key constants
26
27 //
28 // these are the key numbers that should be passed to Key_Event
29 //
30 float K_TAB                     =       9;
31 float K_ENTER           =       13;
32 float K_ESCAPE          =       27;
33 float K_SPACE           =       32;
34
35 // normal keys should be passed as lowercased ascii
36
37 float K_BACKSPACE       =       127;
38 float K_UPARROW         =       128;
39 float K_DOWNARROW       =       129;
40 float K_LEFTARROW       =       130;
41 float K_RIGHTARROW      =       131;
42
43 float K_ALT             =       132;
44 float K_CTRL    =       133;
45 float K_SHIFT   =       134;
46 float K_F1              =       135;
47 float K_F2              =       136;
48 float K_F3              =       137;
49 float K_F4              =       138;
50 float K_F5              =       139;
51 float K_F6              =       140;
52 float K_F7              =       141;
53 float K_F8              =       142;
54 float K_F9              =       143;
55 float K_F10             =       144;
56 float K_F11             =       145;
57 float K_F12             =       146;
58 float K_INS             =       147;
59 float K_DEL             =       148;
60 float K_PGDN    =       149;
61 float K_PGUP    =       150;
62 float K_HOME    =       151;
63 float K_END             =       152;
64
65 float K_PAUSE   =       153;
66
67 float K_NUMLOCK         = 154;
68 float K_CAPSLOCK        = 155;
69 float K_SCROLLLOCK      = 156;
70
71 float K_KP_0    =       157;
72 float K_KP_INS  =       K_KP_0;
73 float K_KP_1    =       158;
74 float K_KP_END  =       K_KP_1;
75 float K_KP_2    =       159;
76 float K_KP_DOWNARROW = K_KP_2;
77 float K_KP_3    =       160;
78 float K_KP_PGDN = K_KP_3;
79 float K_KP_4    =       161
80 float K_KP_LEFTARROW = K_KP_4;
81 float K_KP_5    =       162;
82 float K_KP_6    =       163;
83 float K_KP_RIGHTARROW = K_KP_6;
84 float K_KP_7    =       164;
85 float K_KP_HOME = K_KP_7;
86 float K_KP_8    =       165;
87 float K_KP_UPARROW = K_KP_8;
88 float K_KP_9    = 166;
89 float K_KP_PGUP = K_KP_9;
90 float K_KP_PERIOD = 167;
91 float K_KP_DEL = K_KP_PERIOD;
92 float K_KP_DIVIDE = 168;
93 float K_KP_SLASH = K_KP_DIVIDE;
94 float K_KP_MULTIPLY = 169;
95 float K_KP_MINUS        = 170;
96 float K_KP_PLUS         = 171;
97 float K_KP_ENTER        = 172;
98 float K_KP_EQUALS       = 173;
99
100 // mouse buttons generate virtual keys
101
102 float K_MOUSE1  =       512;
103 float K_MOUSE2  =       513;
104 float K_MOUSE3  =       514;
105 float K_MOUSE4  =       515;
106 float K_MWHEELUP = K_MOUSE4;
107 float K_MOUSE5  =       516;
108 float K_MWHEELDOWN = K_MOUSE5;
109 float K_MOUSE6  =       517;
110 float K_MOUSE7  =       518;
111 float K_MOUSE8  =       519;
112 float K_MOUSE9  =       520;
113 float K_MOUSE10 =       521;
114 float K_MOUSE11 =       522;
115 float K_MOUSE12 =       523;
116 float K_MOUSE13 =       524;
117 float K_MOUSE14 =       525;
118 float K_MOUSE15 =       526;
119 float K_MOUSE16 =       527;
120
121 //
122 // joystick buttons
123 //
124 float K_JOY1 = 768;
125 float K_JOY2 = 769;
126 float K_JOY3 = 770;
127 float K_JOY4 = 771;
128
129 //
130 //
131 // aux keys are for multi-buttoned joysticks to generate so they can use
132 // the normal binding process
133 //
134 float K_AUX1    =       772;
135 float K_AUX2    =       773;
136 float K_AUX3    =       774;
137 float K_AUX4    =       775;
138 float K_AUX5    =       776;
139 float K_AUX6    =       777;
140 float K_AUX7    =       778;
141 float K_AUX8    =       779;
142 float K_AUX9    =       780;
143 float K_AUX10   =       781;
144 float K_AUX11   =       782;
145 float K_AUX12   =       783;
146 float K_AUX13   =       784;
147 float K_AUX14   =       785;
148 float K_AUX15   =       786;
149 float K_AUX16   =       787;
150 float K_AUX17   =       788;
151 float K_AUX18   =       789;
152 float K_AUX19   =       790;
153 float K_AUX20   =       791;
154 float K_AUX21   =       792;
155 float K_AUX22   =       793;
156 float K_AUX23   =       794;
157 float K_AUX24   =       795;
158 float K_AUX25   =       796;
159 float K_AUX26   =       797;
160 float K_AUX27   =       798;
161 float K_AUX28   =       799;
162 float K_AUX29   =       800;
163 float K_AUX30   =       801;
164 float K_AUX31   =       802;
165 float K_AUX32   =       803;
166
167 ///////////////////////////
168 // key dest constants
169
170 float KEY_GAME          =       0;
171 float KEY_MENU          =       2;
172 float KEY_UNKNOWN       =       3;
173
174 ///////////////////////////
175 // file constants
176
177 float FILE_READ = 0;
178 float FILE_APPEND = 1;
179 float FILE_WRITE = 2;
180
181 ///////////////////////////
182 // logical constants (just for completeness)
183
184 float TRUE      = 1;
185 float FALSE = 0;
186
187 ///////////////////////////
188 // boolean constants
189
190 float true = 1;
191 float false = 0;
192
193 ///////////////////////////
194 // msg constants
195
196 float MSG_BROADCAST             = 0;            // unreliable to all
197 float MSG_ONE                   = 1;            // reliable to one (msg_entity)
198 float MSG_ALL                   = 2;            // reliable to all
199 float MSG_INIT                  = 3;            // write to the init string
200
201 /////////////////////////////
202 // mouse target constants
203
204 float MT_MENU = 1;
205 float MT_CLIENT = 2;
206
207 /////////////////////////
208 // client state constants
209
210 float CS_DEDICATED              = 0;
211 float CS_DISCONNECTED   = 1;
212 float CS_CONNECTED              = 2;
213
214 ///////////////////////////
215 // blend flags
216
217 float DRAWFLAG_NORMAL           = 0;
218 float DRAWFLAG_ADDITIVE         = 1;
219 float DRAWFLAG_MODULATE         = 2;
220 float DRAWFLAG_2XMODULATE   = 3;
221
222 ///////////////////////////
223 // null entity (actually it is the same like the world entity)
224
225 entity null_entity;
226
227 ///////////////////////////
228 // error constants
229
230 // file handling
231 float ERR_CANNOTOPEN                    = -1; // fopen
232 float ERR_NOTENOUGHFILEHANDLES  = -2; // fopen
233 float ERR_INVALIDMODE                   = -3; // fopen
234 float ERR_BADFILENAME                   = -4; // fopen
235
236 // drawing functions
237
238 float ERR_NULLSTRING                    = -1;
239 float ERR_BADDRAWFLAG                   = -2;
240 float ERR_BADSCALE                              = -3;
241 float ERR_BADSIZE                               = ERR_BADSCALE;
242 float ERR_NOTCACHED                             = -4;
243
244 /* not supported at the moment
245 ///////////////////////////
246 // os constants
247
248 float OS_WINDOWS        = 0;
249 float OS_LINUX          = 1;
250 float OS_MAC            = 2;
251 */
252
253
254
255
256
257
258
259
260
261
262 //////////////////////////////////////////////////
263 // common cmd
264 //////////////////////////////////////////////////
265 // AK FIXME: Create perhaps a special builtin file for the common cmds
266
267 void    checkextension(string ext)      = #1;
268
269 // error cmds
270 void    error(string err,...)           = #2;
271 void    objerror(string err,...)        = #3;
272
273 // print
274
275 void    print(string text,...)                   = #4;
276 void    bprint(string text,...)                  = #5;
277 void    sprint(float clientnum, string text,...) = #6;
278 void    centerprint(string text,...)             = #7;
279
280 // vector stuff
281
282 vector  normalize(vector v)             = #8;
283 float   vlen(vector v)                  = #9;
284 float   vectoyaw(vector v)              = #10;
285 vector  vectoangles(vector v)           = #11;
286
287 float   random(void)  = #12;
288
289 void    cmd(string command) = #13;
290
291 // cvar cmds
292
293 float   cvar(string name)                       = #14;
294 const string str_cvar(string name)              = #71;
295 void    cvar_set(string name, string value)     = #15;
296
297 void    dprint(string text,...) = #16;
298
299 // conversion functions
300
301 string  ftos(float f)   = #17;
302 float   fabs(float f)   = #18;
303 string  vtos(vector v)  = #19;
304 string  etos(entity e)  = #20;
305
306 float   stof(string val,...)  = #21;
307
308 entity  spawn(void)             = #22;
309 void    remove(entity e)        = #23;
310
311 entity  findstring(entity start, .string field, string match)   = #24;
312 entity  findfloat(entity start, .float field, float match)      = #25;
313 entity  findentity(entity start, .entity field, entity match)   = #25;
314
315 entity  findchainstring(.string field, string match)    = #26;
316 entity  findchainfloat(.float field, float match)       = #27;
317 entity  findchainentity(.entity field, entity match)    = #27;
318
319 string  precache_file(string file)      = #28;
320 string  precache_sound(string sample)   = #29;
321
322 void    crash(void)     = #72;
323 void    coredump(void)  = #30;
324 void    stackdump(void) = #73;
325 void    traceon(void)   = #31;
326 void    traceoff(void)  = #32;
327
328 void    eprint(entity e)        = #33;
329 float   rint(float f)           = #34;
330 float   floor(float f)          = #35;
331 float   ceil(float f)           = #36;
332 entity  nextent(entity e)       = #37;
333 float   sin(float f)            = #38;
334 float   cos(float f)            = #39;
335 float   sqrt(float f)           = #40;
336 vector  randomvec(void)         = #41;
337
338 float   registercvar(string name, string value, float flags)  = #42; // returns 1 if success
339
340 float   min(float f,...)  = #43;
341 float   max(float f,...)  = #44;
342
343 float   bound(float min,float value, float max)  = #45;
344 float   pow(float a, float b)  = #46;
345
346 void    copyentity(entity src, entity dst)  = #47;
347
348 float   fopen(string filename, float mode)  = #48;
349 void    fclose(float fhandle)  = #49;
350 string  fgets(float fhandle)  = #50;
351 void    fputs(float fhandle, string s)  = #51;
352
353 float   strlen(string s)  = #52;
354 string  strcat(string s1,string s2,...)  = #53;
355 string  substring(string s, float start, float length)  = #54;
356
357 vector  stov(string s)  = #55;
358
359 string  strzone(string s)  = #56;
360 void    strunzone(string s) = #57;
361
362 float   tokenize(string s)  = #58
363 string  argv(float n)  = #59;
364
365 float   isserver(void)  = #60;
366 float   clientcount(void)  = #61;
367 float   clientstate(void)  = #62;
368 void    clientcommand(float client, string s)  = #63;
369 void    changelevel(string map)  = #64;
370 void    localsound(string sample)  = #65;
371 vector  getmousepos(void)       = #66;
372 float   gettime(void)           = #67;
373 void    loadfromdata(string data) = #68;
374 void    loadfromfile(string file) = #69;
375
376 float   mod(float val, float m) = #70;
377
378 float   search_begin(string pattern, float caseinsensitive, float quiet) = #74;
379 void    search_end(float handle) = #75;
380 float   search_getsize(float handle) = #76;
381 string  search_getfilename(float handle, float num) = #77;
382
383 string  chr(float ascii) = #78;
384
385 /////////////////////////////////////////////////
386 // Write* Functions
387 /////////////////////////////////////////////////
388 void    WriteByte(float data, float dest, float desto)  = #401;
389 void    WriteChar(float data, float dest, float desto)  = #402;
390 void    WriteShort(float data, float dest, float desto) = #403;
391 void    WriteLong(float data, float dest, float desto)  = #404;
392 void    WriteAngle(float data, float dest, float desto) = #405;
393 void    WriteCoord(float data, float dest, float desto) = #406;
394 void    WriteString(string data, float dest, float desto)= #407;
395 void    WriteEntity(entity data, float dest, float desto) = #408;
396
397 //////////////////////////////////////////////////
398 // Draw funtions
399 //////////////////////////////////////////////////
400
401 float   iscachedpic(string name)        = #451;
402 string  precache_pic(string name)       = #452;
403 void    freepic(string name)            = #453;
404
405 float   drawcharacter(vector position, float character, vector scale, vector rgb, float alpha, float flag) = #454;
406
407 float   drawstring(vector position, string text, vector scale, vector rgb, float alpha, float flag) = #455;
408
409 float   drawcolorcodedstring(vector position, string text, vector scale, float alpha, float flag) = #467;
410
411 vector  drawcolorcodedstring2(vector position, string text, vector scale, vector rgb, float alpha, float flag) = #467;
412  
413 float   drawpic(vector position, string pic, vector size, vector rgb, float alpha, float flag) = #456;
414
415 float   drawfill(vector position, vector size, vector rgb, float alpha, float flag) = #457;
416
417 void    drawsetcliparea(float x, float y, float width, float height) = #458;
418
419 void    drawresetcliparea(void) = #459;
420
421 vector  drawgetimagesize(string pic) = #460;
422
423 ////////////////////////////////////////////////
424 // Menu functions
425 ////////////////////////////////////////////////
426
427 void    setkeydest(float dest)  = #601;
428 float   getkeydest(void)        = #602;
429
430 void    setmousetarget(float trg) = #603;
431 float   getmousetarget(void)      = #604;
432
433 float   isfunction(string function_name) = #607;
434 void    callfunction(...) = #605;
435 void    writetofile(float fhandle, entity ent) = #606;
436 vector  getresolution(float number) = #608;
437 string  keynumtostring(float keynum) = #609;
438
439 float   gethostcachevalue(float type) = #611;
440 string  gethostcachestring(float type, float hostnr) = #612;
441
442 //DP_CSQC_BINDMAPS
443 //idea: daemon, motorsep
444 //darkplaces implementation: divVerent
445 //builtin definitions:
446 string(float key, float bindmap) getkeybind_bindmap = #342;
447 float(float key, string bind, float bindmap) setkeybind_bindmap = #630;
448 vector(void) getbindmaps = #631;
449 float(vector bm) setbindmaps = #632;
450 string(string command, float bindmap) findkeysforcommand = #610;
451 float(string key) stringtokeynum = #341;
452 //<also allowed builtin number to match EXT_CSQC> string(float keynum) keynumtostring = #340;
453 //description: key bind setting/getting including support for switchable
454 //bindmaps.
455
456 //DP_CRYPTO
457 //idea: divVerent
458 //darkplaces implementation: divVerent
459 //field definitions: (MENUQC)
460 string(string serveraddress) crypto_getkeyfp = #633; // retrieves the cached host key's CA fingerprint of a server given by IP address
461 string(string serveraddress) crypto_getidfp = #634; // retrieves the cached host key fingerprint of a server given by IP address
462 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
463 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
464 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
465 float(string url, float id, string content_type, string delim, float buf, float keyid) crypto_uri_postbuf = #513;
466 //description:
467 //use -1 as buffer handle to justs end delim as postdata