From: Rudolf Polzer Date: Sat, 26 Nov 2011 10:28:02 +0000 (+0100) Subject: many menuqc improvements regarding dpdefs X-Git-Tag: xonotic-v0.6.0~35^2~33^2~11 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=30c0ffb0a1663cf25575ab4e203778a6bb8d8d57;p=xonotic%2Fxonotic-data.pk3dir.git many menuqc improvements regarding dpdefs --- diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index 0f2289307..62975e53a 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -212,7 +212,7 @@ const float K_KP_PLUS = 171; const float K_KP_ENTER = 172; const float K_KP_EQUALS = 173; -const float K_PAUSE = 255; +const float K_PAUSE = 153; // // joystick buttons diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index 5ffef8f09..10e4e345b 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -1074,8 +1074,8 @@ vector rgb_to_hsv(vector rgb) float mi, ma; vector hsv; - mi = min3(rgb_x, rgb_y, rgb_z); - ma = max3(rgb_x, rgb_y, rgb_z); + mi = min(rgb_x, rgb_y, rgb_z); + ma = max(rgb_x, rgb_y, rgb_z); hsv_x = rgb_mi_ma_to_hue(rgb, mi, ma); hsv_z = ma; @@ -1098,8 +1098,8 @@ vector rgb_to_hsl(vector rgb) float mi, ma; vector hsl; - mi = min3(rgb_x, rgb_y, rgb_z); - ma = max3(rgb_x, rgb_y, rgb_z); + mi = min(rgb_x, rgb_y, rgb_z); + ma = max(rgb_x, rgb_y, rgb_z); hsl_x = rgb_mi_ma_to_hue(rgb, mi, ma); diff --git a/qcsrc/dpdefs/keycodes.qc b/qcsrc/dpdefs/keycodes.qc new file mode 100644 index 000000000..76945736f --- /dev/null +++ b/qcsrc/dpdefs/keycodes.qc @@ -0,0 +1,147 @@ +/////////////////////////// +// key constants + +// +// these are the key numbers that should be passed to Key_Event +// +float K_TAB = 9; +float K_ENTER = 13; +float K_ESCAPE = 27; +float K_SPACE = 32; + +// normal keys should be passed as lowercased ascii + +float K_BACKSPACE = 127; +float K_UPARROW = 128; +float K_DOWNARROW = 129; +float K_LEFTARROW = 130; +float K_RIGHTARROW = 131; + +float K_ALT = 132; +float K_CTRL = 133; +float K_SHIFT = 134; + +float K_F1 = 135; +float K_F2 = 136; +float K_F3 = 137; +float K_F4 = 138; +float K_F5 = 139; +float K_F6 = 140; +float K_F7 = 141; +float K_F8 = 142; +float K_F9 = 143; +float K_F10 = 144; +float K_F11 = 145; +float K_F12 = 146; + +float K_INS = 147; +float K_DEL = 148; +float K_PGDN = 149; +float K_PGUP = 150; +float K_HOME = 151; +float K_END = 152; + +float K_NUMLOCK = 154; +float K_CAPSLOCK = 155; +float K_SCROLLLOCK = 156; + +float K_KP_0 = 157; +float K_KP_INS = K_KP_0; +float K_KP_1 = 158; +float K_KP_END = K_KP_1; +float K_KP_2 = 159; +float K_KP_DOWNARROW = K_KP_2; +float K_KP_3 = 160; +float K_KP_PGDN = K_KP_3; +float K_KP_4 = 161; +float K_KP_LEFTARROW = K_KP_4; +float K_KP_5 = 162; +float K_KP_6 = 163; +float K_KP_RIGHTARROW = K_KP_6; +float K_KP_7 = 164; +float K_KP_HOME = K_KP_7; +float K_KP_8 = 165; +float K_KP_UPARROW = K_KP_8; +float K_KP_9 = 166; +float K_KP_PGUP = K_KP_9; +float K_KP_PERIOD = 167; +float K_KP_DEL = K_KP_PERIOD; +float K_KP_DIVIDE = 168; +float K_KP_SLASH = K_KP_DIVIDE; +float K_KP_MULTIPLY = 169; +float K_KP_MINUS = 170; +float K_KP_PLUS = 171; +float K_KP_ENTER = 172; +float K_KP_EQUALS = 173; + +// mouse buttons generate virtual keys +float K_PAUSE = 153; + +// +// joystick buttons +// +float K_JOY1 = 768; +float K_JOY2 = 769; +float K_JOY3 = 770; +float K_JOY4 = 771; + +// +// +// aux keys are for multi-buttoned joysticks to generate so they can use +// the normal binding process +// +float K_AUX1 = 772; +float K_AUX2 = 773; +float K_AUX3 = 774; +float K_AUX4 = 775; +float K_AUX5 = 776; +float K_AUX6 = 777; +float K_AUX7 = 778; +float K_AUX8 = 779; +float K_AUX9 = 780; +float K_AUX10 = 781; +float K_AUX11 = 782; +float K_AUX12 = 783; +float K_AUX13 = 784; +float K_AUX14 = 785; +float K_AUX15 = 786; +float K_AUX16 = 787; +float K_AUX17 = 788; +float K_AUX18 = 789; +float K_AUX19 = 790; +float K_AUX20 = 791; +float K_AUX21 = 792; +float K_AUX22 = 793; +float K_AUX23 = 794; +float K_AUX24 = 795; +float K_AUX25 = 796; +float K_AUX26 = 797; +float K_AUX27 = 798; +float K_AUX28 = 799; +float K_AUX29 = 800; +float K_AUX30 = 801; +float K_AUX31 = 802; +float K_AUX32 = 803; + +// +// mouse buttons generate virtual keys +// +float K_MOUSE1 = 512; +float K_MOUSE2 = 513; +float K_MOUSE3 = 514; +float K_MWHEELUP = 515; +float K_MWHEELDOWN = 516; +float K_MOUSE4 = 517; +float K_MOUSE5 = 518; +float K_MOUSE6 = 519; +float K_MOUSE7 = 520; +float K_MOUSE8 = 521; +float K_MOUSE9 = 522; +float K_MOUSE10 = 523; +float K_MOUSE11 = 524; +float K_MOUSE12 = 525; +float K_MOUSE13 = 526; +float K_MOUSE14 = 527; +float K_MOUSE15 = 528; +float K_MOUSE16 = 529; + diff --git a/qcsrc/dpdefs/menudefs.qc b/qcsrc/dpdefs/menudefs.qc new file mode 100644 index 000000000..0a7bd6ae4 --- /dev/null +++ b/qcsrc/dpdefs/menudefs.qc @@ -0,0 +1,524 @@ +////////////////////////////////////////////////////////// +// sys globals + +entity self; + +///////////////////////////////////////////////////////// +void end_sys_globals; +///////////////////////////////////////////////////////// +// sys fields + +///////////////////////////////////////////////////////// +void end_sys_fields; +///////////////////////////////////////////////////////// +// sys functions + +void() m_init; +void(float keynr, float ascii) m_keydown; +void() m_draw; +void() m_toggle; +void() m_shutdown; + +///////////////////////////////////////////////////////// +// sys constants +/////////////////////////// +// key dest constants + +float KEY_UNKNOWN = -1; +float KEY_GAME = 0; +float KEY_MENU = 2; +float KEY_MENU_GRABBED = 3; + +/////////////////////////// +// file constants + +float FILE_READ = 0; +float FILE_APPEND = 1; +float FILE_WRITE = 2; + +/////////////////////////// +// logical constants (just for completeness) + +float TRUE = 1; +float FALSE = 0; + +/////////////////////////// +// boolean constants + +float true = 1; +float false = 0; + +/////////////////////////// +// msg constants + +float MSG_BROADCAST = 0; // unreliable to all +float MSG_ONE = 1; // reliable to one (msg_entity) +float MSG_ALL = 2; // reliable to all +float MSG_INIT = 3; // write to the init string + +///////////////////////////// +// mouse target constants + +float MT_MENU = 1; +float MT_CLIENT = 2; + +///////////////////////// +// client state constants + +float CS_DEDICATED = 0; +float CS_DISCONNECTED = 1; +float CS_CONNECTED = 2; + +/////////////////////////// +// blend flags + +float DRAWFLAG_NORMAL = 0; +float DRAWFLAG_ADDITIVE = 1; +float DRAWFLAG_MODULATE = 2; +float DRAWFLAG_2XMODULATE = 3; + +/////////////////////////// +// null entity (actually it is the same like the world entity) + +entity null_entity; + +/////////////////////////// +// error constants + +// file handling +float ERR_CANNOTOPEN = -1; // fopen +float ERR_NOTENOUGHFILEHANDLES = -2; // fopen +float ERR_INVALIDMODE = -3; // fopen +float ERR_BADFILENAME = -4; // fopen + +// drawing functions + +float ERR_NULLSTRING = -1; +float ERR_BADDRAWFLAG = -2; +float ERR_BADSCALE = -3; +float ERR_BADSIZE = ERR_BADSCALE; +float ERR_NOTCACHED = -4; + +// server list stuff +float SLIST_HOSTCACHEVIEWCOUNT = 0; +float SLIST_HOSTCACHETOTALCOUNT = 1; +float SLIST_MASTERQUERYCOUNT = 2; +float SLIST_MASTERREPLYCOUNT = 3; +float SLIST_SERVERQUERYCOUNT = 4; +float SLIST_SERVERREPLYCOUNT = 5; +float SLIST_SORTFIELD = 6; +float SLIST_SORTDESCENDING = 7; +float SLIST_LEGACY_LINE1 = 1024; +float SLIST_LEGACY_LINE2 = 1025; +float SLIST_TEST_CONTAINS = 0; +float SLIST_TEST_NOTCONTAIN = 1; +float SLIST_TEST_LESSEQUAL = 2; +float SLIST_TEST_LESS = 3; +float SLIST_TEST_EQUAL = 4; +float SLIST_TEST_GREATER = 5; +float SLIST_TEST_GREATEREQUAL = 6; +float SLIST_TEST_NOTEQUAL = 7; +float SLIST_TEST_STARTSWITH = 8; +float SLIST_TEST_NOTSTARTSWITH = 9; +float SLIST_MASK_AND = 0; +float SLIST_MASK_OR = 512; + +// font stuff +float FONT_DEFAULT = 0; +float FONT_CONSOLE = 1; +float FONT_SBAR = 2; +float FONT_NOTIFY = 3; +float FONT_CHAT = 4; +float FONT_CENTERPRINT = 5; +float FONT_INFOBAR = 6; +float FONT_MENU = 7; +float FONT_USER = 8; // add to this the index, like FONT_USER+3 = user3. At least 8 of them are supported. +float drawfont; + +/* not supported at the moment +/////////////////////////// +// os constants + +float OS_WINDOWS = 0; +float OS_LINUX = 1; +float OS_MAC = 2; +*/ + + + + + + + + + + +////////////////////////////////////////////////// +// common cmd +////////////////////////////////////////////////// +// AK FIXME: Create perhaps a special builtin file for the common cmds + +void checkextension(string ext) = #1; + +// error cmds +void error(string err,...) = #2; +void objerror(string err,...) = #3; + +// print + +void print(string text,...) = #4; +void bprint(string text,...) = #5; +void sprint(float clientnum, string text,...) = #6; +void centerprint(string text,...) = #7; + +// vector stuff + +vector normalize(vector v) = #8; +float vlen(vector v) = #9; +float vectoyaw(vector v) = #10; +vector vectoangles(vector v) = #11; + +float random(void) = #12; + +void cmd(string command, ...) = #13; + +// cvar cmds + +float cvar(string name) = #14; +const string str_cvar(string name) = #71; +void cvar_set(string name, string value) = #15; + +void dprint(string text,...) = #16; + +// conversion functions + +string ftos(float f) = #17; +float fabs(float f) = #18; +string vtos(vector v) = #19; +string etos(entity e) = #20; + +float stof(string val,...) = #21; + +entity spawn(void) = #22; +void remove(entity e) = #23; + +entity findstring(entity start, .string field, string match) = #24; +entity findfloat(entity start, .float field, float match) = #25; +entity findentity(entity start, .entity field, entity match) = #25; + +entity findchainstring(.string field, string match) = #26; +entity findchainfloat(.float field, float match) = #27; +entity findchainentity(.entity field, entity match) = #27; + +string precache_file(string file) = #28; +string precache_sound(string sample) = #29; + +void crash(void) = #72; +void coredump(void) = #30; +void stackdump(void) = #73; +void traceon(void) = #31; +void traceoff(void) = #32; + +void eprint(entity e) = #33; +float rint(float f) = #34; +float floor(float f) = #35; +float ceil(float f) = #36; +entity nextent(entity e) = #37; +float sin(float f) = #38; +float cos(float f) = #39; +float sqrt(float f) = #40; +vector randomvec(void) = #41; + +float registercvar(string name, string value, float flags) = #42; // returns 1 if success + +float min(float f,...) = #43; +float max(float f,...) = #44; + +float bound(float min,float value, float max) = #45; +float pow(float a, float b) = #46; + +void copyentity(entity src, entity dst) = #47; + +float fopen(string filename, float mode) = #48; +void fclose(float fhandle) = #49; +string fgets(float fhandle) = #50; +void fputs(float fhandle, string s) = #51; + +float strlen(string s) = #52; +string strcat(string s1,string s2,...) = #53; +string substring(string s, float start, float length) = #54; + +vector stov(string s) = #55; + +string strzone(string s) = #56; +void strunzone(string s) = #57; + +float tokenize(string s) = #58 +string argv(float n) = #59; + +float isserver(void) = #60; +float clientcount(void) = #61; +float clientstate(void) = #62; +void clientcommand(float client, string s) = #63; +void changelevel(string map) = #64; +void localsound(string sample) = #65; +vector getmousepos(void) = #66; +float gettime(void) = #67; +void loadfromdata(string data) = #68; +void loadfromfile(string file) = #69; + +float mod(float val, float m) = #70; + +float search_begin(string pattern, float caseinsensitive, float quiet) = #74; +void search_end(float handle) = #75; +float search_getsize(float handle) = #76; +string search_getfilename(float handle, float num) = #77; + +string chr(float ascii) = #78; + +///////////////////////////////////////////////// +// Write* Functions +///////////////////////////////////////////////// +void WriteByte(float data, float dest, float desto) = #401; +void WriteChar(float data, float dest, float desto) = #402; +void WriteShort(float data, float dest, float desto) = #403; +void WriteLong(float data, float dest, float desto) = #404; +void WriteAngle(float data, float dest, float desto) = #405; +void WriteCoord(float data, float dest, float desto) = #406; +void WriteString(string data, float dest, float desto)= #407; +void WriteEntity(entity data, float dest, float desto) = #408; + +////////////////////////////////////////////////// +// Draw funtions +////////////////////////////////////////////////// + +float iscachedpic(string name) = #451; +string precache_pic(string name) = #452; +void freepic(string name) = #453; + +float drawcharacter(vector position, float character, vector scale, vector rgb, float alpha, float flag) = #454; + +float drawstring(vector position, string text, vector scale, vector rgb, float alpha, float flag) = #455; + +float drawcolorcodedstring(vector position, string text, vector scale, float alpha, float flag) = #467; + +vector drawcolorcodedstring2(vector position, string text, vector scale, vector rgb, float alpha, float flag) = #467; + +float drawpic(vector position, string pic, vector size, vector rgb, float alpha, float flag) = #456; + +float drawfill(vector position, vector size, vector rgb, float alpha, float flag) = #457; + +void drawsetcliparea(float x, float y, float width, float height) = #458; + +void drawresetcliparea(void) = #459; + +vector drawgetimagesize(string pic) = #460; + +//////////////////////////////////////////////// +// Menu functions +//////////////////////////////////////////////// + +void setkeydest(float dest) = #601; +float getkeydest(void) = #602; + +void setmousetarget(float trg) = #603; +float getmousetarget(void) = #604; + +float isfunction(string function_name) = #607; +void callfunction(...) = #605; +void writetofile(float fhandle, entity ent) = #606; +vector getresolution(float number) = #608; +string keynumtostring(float keynum) = #609; + +float gethostcachevalue(float type) = #611; +string gethostcachestring(float type, float hostnr) = #612; + +//DP_CSQC_BINDMAPS +//idea: daemon, motorsep +//darkplaces implementation: divVerent +//builtin definitions: +string(float key, float bindmap) getkeybind_bindmap = #342; +float(float key, string bind, float bindmap) setkeybind_bindmap = #630; +vector(void) getbindmaps = #631; +float(vector bm) setbindmaps = #632; +string(string command, float bindmap) findkeysforcommand = #610; +float(string key) stringtokeynum = #341; +// string(float keynum) keynumtostring = #340; +//description: key bind setting/getting including support for switchable +//bindmaps. + +//DP_CRYPTO +//idea: divVerent +//darkplaces implementation: divVerent +//field definitions: (MENUQC) +string(string serveraddress) crypto_getkeyfp = #633; // retrieves the cached host key's CA fingerprint of a server given by IP address +string(string serveraddress) crypto_getidfp = #634; // retrieves the cached host key fingerprint of a server given by IP address +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 +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 +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 +float(string url, float id, string content_type, string delim, float buf, float keyid) crypto_uri_postbuf = #513; +//description: +//use -1 as buffer handle to justs end delim as postdata + +//DP_GECKO_SUPPORT +//idea: Res2k, BlackHC +//darkplaces implementation: Res2k, BlackHC +//constant definitions: +float GECKO_BUTTON_DOWN = 0; +float GECKO_BUTTON_UP = 1; +// either use down and up or just press but not all of them! +float GECKO_BUTTON_PRESS = 2; +// use this for mouse events if needed? +float GECKO_BUTTON_DOUBLECLICK = 3; +//builtin definitions: +float gecko_create( string name ) = #487; +void gecko_destroy( string name ) = #488; +void gecko_navigate( string name, string URI ) = #489; +float gecko_keyevent( string name, float key, float eventtype ) = #490; +void gecko_mousemove( string name, float x, float y ) = #491; +void gecko_resize( string name, float w, float h ) = #492; +vector gecko_get_texture_extent( string name ) = #493; +//engine-called QC prototypes: +//string(string name, string query) Qecko_Query; +//description: +//provides an interface to the offscreengecko library and allows for internet browsing in games + +//FTE_STRINGS +//idea: many +//darkplaces implementation: KrimZon +//description: +//various string manipulation functions +float(string str, string sub, float startpos) strstrofs = #221; +float(string str, float ofs) str2chr = #222; +string(float c, ...) chr2str = #223; +string(float ccase, float calpha, float cnum, string s, ...) strconv = #224; +string(float chars, string s, ...) strpad = #225; +string(string info, string key, string value, ...) infoadd = #226; +string(string info, string key) infoget = #227; +float(string s1, string s2, float len) strncmp = #228; +float(string s1, string s2) strcasecmp = #229; +float(string s1, string s2, float len) strncasecmp = #230; + +//DP_QC_CRC16 +//idea: div0 +//darkplaces implementation: div0 +//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. +//When caseinsensitive is set, the CRC is calculated of the lower cased string. +float(float caseinsensitive, string s, ...) crc16 = #494; + +//DP_QC_CVAR_TYPE +float(string name) cvar_type = #495; +float CVAR_TYPEFLAG_EXISTS = 1; +float CVAR_TYPEFLAG_SAVED = 2; +float CVAR_TYPEFLAG_PRIVATE = 4; +float CVAR_TYPEFLAG_ENGINE = 8; +float CVAR_TYPEFLAG_HASDESCRIPTION = 16; +float CVAR_TYPEFLAG_READONLY = 32; + +//DP_QC_STRINGBUFFERS +//idea: ?? +//darkplaces implementation: LordHavoc +//functions to manage string buffer objects - that is, arbitrary length string arrays that are handled by the engine +float() buf_create = #440; +void(float bufhandle) buf_del = #441; +float(float bufhandle) buf_getsize = #442; +void(float bufhandle_from, float bufhandle_to) buf_copy = #443; +void(float bufhandle, float sortpower, float backward) buf_sort = #444; +string(float bufhandle, string glue) buf_implode = #445; +string(float bufhandle, float string_index) bufstr_get = #446; +void(float bufhandle, float string_index, string str) bufstr_set = #447; +float(float bufhandle, string str, float order) bufstr_add = #448; +void(float bufhandle, float string_index) bufstr_free = #449; +void(float bufhandle, string pattern, string antipattern) buf_cvarlist = #517; + +//DP_QC_CVAR_DESCRIPTION +//idea: divVerent +//DarkPlaces implementation: divVerent +//builtin definitions: +string(string name) cvar_description = #518; +//description: +//returns the description of a cvar + +//DP_QC_DIGEST +//idea: motorsep, Spike +//DarkPlaces implementation: divVerent +//builtin definitions: +string(string digest, string data, ...) digest_hex = #639; +//description: +//returns a given hex digest of given data +//the returned digest is always encoded in hexadecimal +//only the "MD4" digest is always supported! +//if the given digest is not supported, string_null is returned +//the digest string is matched case sensitively, use "MD4", not "md4"! + +//DP_QC_URI_ESCAPE +//idea: div0 +//darkplaces implementation: div0 +//URI::Escape's functionality +string(string in) uri_escape = #510; +string(string in) uri_unescape = #511; + +//DP_QC_URI_GET +//idea: divVerent +//darkplaces implementation: divVerent +//loads text from an URL into a string +//returns 1 on success of initiation, 0 if there are too many concurrent +//connections already or if the URL is invalid +//the following callback will receive the data and MUST exist! +// void(float id, float status, string data) URI_Get_Callback; +//status is either +// negative for an internal error, +// 0 for success, or +// the HTTP response code on server error (e.g. 404) +//if 1 is returned by uri_get, the callback will be called in the future +float(string url, float id) uri_get = #513; +//DP_QC_URI_POST +//idea: divVerent +//darkplaces implementation: divVerent +//loads text from an URL into a string after POSTing via HTTP +//works like uri_get, but uri_post sends data with Content-Type: content_type to the server +//and uri_post sends the string buffer buf, joined using the delimiter delim +float(string url, float id, string content_type, string data) uri_post = #513; +float(string url, float id, string content_type, string delim, float buf) uri_postbuf = #513; + +// assorted undocumented extensions +string(string, float) netaddress_resolve = #625; +string(string search, string replace, string subject) strreplace = #484; +string(float uselocaltime, string format, ...) strftime = #478; +float(string s) tokenize_console = #514; +float(float i) argv_start_index = #515; +float(float i) argv_end_index = #516; +string(float, float) getgamedirinfo = #626; +#define GETGAMEDIRINFO_NAME 0 +#define GETGAMEDIRINFO_DESCRIPTION 1 +float log(float f) = #532; +string(string format, ...) sprintf = #627; +string(string s) strdecolorize = #477; +entity findflags(entity start, .float field, float match) = #87; +entity findchainflags(.float field, float match) = #88; +float(string s, string separator1, ...) tokenizebyseparator = #479; +float etof(entity ent) = #79; +entity ftoe(float num) = #80; +float validstring(string str) = #81; +float altstr_count(string str) = #82; +string altstr_prepare(string str) = #83; +string altstr_get(string str, float num) = #84; +string altstr_set(string str, float num, string set) = #85; +string altstr_ins(string str, float num, string set) = #86; +float isdemo() = #349; +float drawsubpic(vector position, vector size, string pic, vector srcPosition, vector srcSize, vector rgb, float alpha, float flag) = #469; +//vector getresolution(float number, ...) = #608; // optional argument "isfullscreen" +void parseentitydata(entity ent, string data) = #613; +void resethostcachemasks(void) = #615; +void sethostcachemaskstring(float mask, float fld, string str, float op) = #616; +void sethostcachemasknumber(float mask, float fld, float num, float op) = #617; +void resorthostcache(void) = #618; +void sethostcachesort(float fld, float descending) = #619; +void refreshhostcache(void) = #620; +float gethostcachenumber(float fld, float hostnr) = #621; +float gethostcacheindexforkey(string key) = #622; +void addwantedhostcachekey(string key) = #623; +string getextresponse(void) = #624; +const string cvar_string(string name) = #71; +const string cvar_defstring(string name) = #89; +float stringwidth(string text, float handleColors, vector size) = #468; diff --git a/qcsrc/menu/mbuiltin.qh b/qcsrc/menu/mbuiltin.qh deleted file mode 100644 index ffdc1bb91..000000000 --- a/qcsrc/menu/mbuiltin.qh +++ /dev/null @@ -1,355 +0,0 @@ -////////////////////////////////////////////////// -// common cmd -////////////////////////////////////////////////// -// AK FIXME: Create perhaps a special builtin file for the common cmds - -float checkextension(string ext) = #1; - -// error cmds -void error(string err,...) = #2; -void objerror(string err,...) = #3; - -// print - -void print(string text,...) = #4; -void bprint(string text,...) = #5; -void sprint(float clientnum, string text,...) = #6; -void centerprint(string text,...) = #7; - -// vector stuff - -vector normalize(vector v) = #8; -float vlen(vector v) = #9; -float vectoyaw(vector v) = #10; -vector vectoangles(vector v) = #11; - -float random(void) = #12; - -void cmd(string command, ...) = #13; - -// cvar cmds - -float cvar(string name) = #14; -const string cvar_string(string name) = #71; -const string cvar_defstring(string name) = #89; -void cvar_set(string name, string value) = #15; - -void dprint(string text,...) = #16; - -// conversion functions - -string ftos(float f) = #17; -float fabs(float f) = #18; -string vtos(vector v) = #19; -string etos(entity e) = #20; - -float stof(string val,...) = #21; - -entity spawn(void) = #22; -void remove(entity e) = #23; - -entity findstring(entity start, .string _field, string match) = #24; -entity findfloat(entity start, .float _field, float match) = #25; -entity findentity(entity start, .entity _field, entity match) = #25; - -entity findchainstring(.string _field, string match) = #26; -entity findchainfloat(.float _field, float match) = #27; -entity findchainentity(.entity _field, entity match) = #27; - -entity findflags(entity start, .float field, float match) = #87; -entity findchainflags(.float field, float match) = #88; - -string precache_file(string file) = #28; -string precache_sound(string sample) = #29; - -void crash(void) = #72; -void coredump(void) = #30; -void stackdump(void) = #73; -void traceon(void) = #31; -void traceoff(void) = #32; - -void eprint(entity e) = #33; -float rint(float f) = #34; -float floor(float f) = #35; -float ceil(float f) = #36; -entity nextent(entity e) = #37; -float sin(float f) = #38; -float cos(float f) = #39; -float sqrt(float f) = #40; -vector randomvec(void) = #41; - -float registercvar(string name, string value, float flags) = #42; // returns 1 if success -float min(float f,...) = #43; -float (float a, float b, float c) min3 = #43; -float (float a, float b, float c, float d) min4 = #43; -float (float a, float b, float c, float d, float e) min5 = #43; -float (float a, float b, float c, float d, float e, float f) min6 = #43; -float (float a, float b, float c, float d, float e, float f, float g) min7 = #43; -float (float a, float b, float c, float d, float e, float f, float g, float h) min8 = #43; -float max(float f,...) = #44; -float (float a, float b, float c) max3 = #44; -float (float a, float b, float c, float d) max4 = #44; -float (float a, float b, float c, float d, float e) max5 = #44; -float (float a, float b, float c, float d, float e, float f) max6 = #44; -float (float a, float b, float c, float d, float e, float f, float g) max7 = #44; -float (float a, float b, float c, float d, float e, float f, float g, float h) max8 = #44; -float bound(float min,float value, float max) = #45; -float pow(float a, float b) = #46; -void copyentity(entity src, entity dst) = #47; - -float fopen(string filename, float mode) = #48; -void fclose(float fhandle) = #49; -string fgets(float fhandle) = #50; -void fputs(float fhandle, string s) = #51; - -float strlen(string s) = #52; -//string strcat(string s1,string s2,...) = #53; -string strcat(string s1, ...) = #53; -string substring(string s, float start, float length) = #54; - -vector stov(string s) = #55; - -string strzone(string s) = #56; -void strunzone(string s) = #57; - -float tokenize(string s) = #58; -float(string s, string separator1, ...) tokenizebyseparator = #479; -string argv(float n) = #59; - -float isserver(void) = #60; -float clientcount(void) = #61; -float clientstate(void) = #62; -void clientcommand(float client, string s) = #63; -void changelevel(string map) = #64; -void localsound(string sample) = #65; -vector getmousepos(void) = #66; -float gettime(void) = #67; -void loadfromdata(string data) = #68; -void loadfromfile(string file) = #69; - -float mod(float val, float m) = #70; - -float search_begin(string pattern, float caseinsensitive, float quiet) = #74; -void search_end(float handle) = #75; -float search_getsize(float handle) = #76; -string search_getfilename(float handle, float num) = #77; - -string chr(float ascii) = #78; - -float etof(entity ent) = #79; -entity ftoe(float num) = #80; - -float validstring(string str) = #81; - -float altstr_count(string str) = #82; -string altstr_prepare(string str) = #83; -string altstr_get(string str, float num) = #84; -string altstr_set(string str, float num, string set) = #85; -string altstr_ins(string str, float num, string set) = #86; - -float isdemo() = #349; - -///////////////////////////////////////////////// -// Write* Functions -///////////////////////////////////////////////// -void WriteByte(float data, float dest, float desto) = #401; -void WriteChar(float data, float dest, float desto) = #402; -void WriteShort(float data, float dest, float desto) = #403; -void WriteLong(float data, float dest, float desto) = #404; -void WriteAngle(float data, float dest, float desto) = #405; -void WriteCoord(float data, float dest, float desto) = #406; -void WriteString(string data, float dest, float desto)= #407; -void WriteEntity(entity data, float dest, float desto) = #408; - -////////////////////////////////////////////////// -// Draw funtions -////////////////////////////////////////////////// - -float iscachedpic(string name) = #451; -string precache_pic(string name) = #452; -void freepic(string name) = #453; - -float drawcharacter(vector position, float character, vector scale, vector rgb, float alpha, float flag) = #454; - -float drawstring(vector position, string text, vector scale, vector rgb, float alpha, float flag) = #455; -float drawcolorcodedstring(vector position, string text, vector scale, float alpha, float flag) = #467; -float stringwidth(string text, float handleColors, vector size) = #468; - -float drawpic(vector position, string pic, vector size, vector rgb, float alpha, float flag) = #456; -float drawsubpic(vector position, vector size, string pic, vector srcPosition, vector srcSize, vector rgb, float alpha, float flag) = #469; - -float drawfill(vector position, vector size, vector rgb, float alpha, float flag) = #457; - -void drawsetcliparea(float x, float y, float width, float height) = #458; - -void drawresetcliparea(void) = #459; - -vector drawgetimagesize(string pic) = #460; - -float cin_open(string file, string name) = #461; -void cin_close(string name) = #462; -void cin_setstate(string name, float type) = #463; -float cin_getstate(string name) = #464; - -//////////////////////////////////////////////// -// Menu functions -//////////////////////////////////////////////// - -void setkeydest(float dest) = #601; -float getkeydest(void) = #602; - -void setmousetarget(float trg) = #603; -float getmousetarget(void) = #604; - -float isfunction(string function_name) = #607; -void callfunction(...) = #605; -void writetofile(float fhandle, entity ent) = #606; -vector getresolution(float number, ...) = #608; // optional argument "isfullscreen" -string keynumtostring(float keynum) = #609; -string findkeysforcommand(string command) = #610; - -float gethostcachevalue(float type) = #611; -string gethostcachestring(float type, float hostnr) = #612; - -void parseentitydata(entity ent, string data) = #613; - -float stringtokeynum(string key) = #614; - -void resethostcachemasks(void) = #615; -void sethostcachemaskstring(float mask, float fld, string str, float op) = #616; -void sethostcachemasknumber(float mask, float fld, float num, float op) = #617; -void resorthostcache(void) = #618; -void sethostcachesort(float fld, float descending) = #619; -void refreshhostcache(void) = #620; -float gethostcachenumber(float fld, float hostnr) = #621; -float gethostcacheindexforkey(string key) = #622; -void addwantedhostcachekey(string key) = #623; -string getextresponse(void) = #624; - -// AK the builtin numbers may change - the code might be removed again -float gecko_create( string name ) = #487; -void gecko_destroy( string name ) = #488; -void gecko_navigate( string name, string URI ) = #489; -float gecko_keyevent( string name, float key, float eventtype ) = #490; -void gecko_mousemove( string name, float x, float y ) = #491; -void gecko_resize( string name, float w, float h ) = #492; -vector gecko_get_texture_extent( string name ) = #493; - -//FTE_STRINGS -//idea: many -//darkplaces implementation: KrimZon -//description: -//various string manipulation functions -float(string str, string sub, float startpos) strstrofs = #221; -float(string str, float ofs) str2chr = #222; -string(float c, ...) chr2str = #223; -string(float ccase, float calpha, float cnum, string s, ...) strconv = #224; -string(float chars, string s, ...) strpad = #225; -string(string info, string key, string value, ...) infoadd = #226; -string(string info, string key) infoget = #227; -float(string s1, string s2, float len) strncmp = #228; -float(string s1, string s2) strcasecmp = #229; -float(string s1, string s2, float len) strncasecmp = #230; - -string(string s) strdecolorize = #477; - -//DP_QC_STRINGBUFFERS -//idea: ?? -//darkplaces implementation: LordHavoc -//functions to manage string buffer objects - that is, arbitrary length string arrays that are handled by the engine -float() buf_create = #440; -void(float bufhandle) buf_del = #441; -float(float bufhandle) buf_getsize = #442; -void(float bufhandle_from, float bufhandle_to) buf_copy = #443; -void(float bufhandle, float sortpower, float backward) buf_sort = #444; -string(float bufhandle, string glue) buf_implode = #445; -string(float bufhandle, float string_index) bufstr_get = #446; -void(float bufhandle, float string_index, string str) bufstr_set = #447; -float(float bufhandle, string str, float order) bufstr_add = #448; -void(float bufhandle, float string_index) bufstr_free = #449; -void(float bufhandle, string pattern, string antipattern) buf_cvarlist = #517; -string(string name) cvar_description = #518; - -//DP_QC_CRC16 -//idea: div0 -//darkplaces implementation: div0 -//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. -//When caseinsensitive is set, the CRC is calculated of the lower cased string. -float(float caseinsensitive, string s, ...) crc16 = #494; - -//DP_QC_CVAR_TYPE -float(string name) cvar_type = #495; -float CVAR_TYPEFLAG_EXISTS = 1; -float CVAR_TYPEFLAG_SAVED = 2; -float CVAR_TYPEFLAG_PRIVATE = 4; -float CVAR_TYPEFLAG_ENGINE = 8; -float CVAR_TYPEFLAG_HASDESCRIPTION = 16; -float CVAR_TYPEFLAG_READONLY = 32; - -//DP_QC_URI_ESCAPE -//idea: div0 -//darkplaces implementation: div0 -//URI::Escape's functionality -string(string in) uri_escape = #510; -string(string in) uri_unescape = #511; - -//DP_QC_URI_GET -//idea: divVerent -//darkplaces implementation: divVerent -//loads text from an URL into a string -//returns 1 on success of initiation, 0 if there are too many concurrent -//connections already or if the URL is invalid -//the following callback will receive the data and MUST exist! -// void(float id, float status, string data) URI_Get_Callback; -//status is either -// negative for an internal error, -// 0 for success, or -// the HTTP response code on server error (e.g. 404) -//if 1 is returned by uri_get, the callback will be called in the future -float(string url, float id) uri_get = #513; -//DP_QC_URI_POST -//idea: divVerent -//darkplaces implementation: divVerent -//loads text from an URL into a string after POSTing via HTTP -//works like uri_get, but uri_post sends data with Content-Type: content_type to the server -//and uri_post sends the string buffer buf, joined using the delimiter delim -float(string url, float id, string content_type, string data) uri_post = #513; -float(string url, float id, string content_type, string delim, float buf) uri_postbuf = #513; - -string(string, float) netaddress_resolve = #625; -string(string search, string replace, string subject) strreplace = #484; - -string(float uselocaltime, string format, ...) strftime = #478; - -float(string s) tokenize_console = #514; -float(float i) argv_start_index = #515; -float(float i) argv_end_index = #516; - -string(float, float) getgamedirinfo = #626; -#define GETGAMEDIRINFO_NAME 0 -#define GETGAMEDIRINFO_DESCRIPTION 1 -float log(float f) = #532; - -string(string format, ...) sprintf = #627; - -//DP_CRYPTO -//idea: divVerent -//darkplaces implementation: divVerent -//field definitions: (MENUQC) -string crypto_getkeyfp(string serveraddress) = #633; // retrieves the cached host key's CA fingerprint of a server given by IP address -string crypto_getidfp(string serveraddress) = #634; // retrieves the cached host key fingerprint of a server given by IP address -string crypto_getencryptlevel(string serveraddress) = #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 -float(string url, float id, string content_type, string delim, float buf, float keyid) crypto_uri_postbuf = #513; -//description: - -//DP_QC_DIGEST -//idea: motorsep, Spike -//DarkPlaces implementation: divVerent -//builtin definitions: -string(string digest, string data, ...) digest_hex = #639; -//description: -//returns a given hex digest of given data -//the returned digest is always encoded in hexadecimal -//only the "MD4" digest is always supported! -//if the given digest is not supported, string_null is returned -//the digest string is matched case sensitively, use "MD4", not "md4"! diff --git a/qcsrc/menu/msys.qh b/qcsrc/menu/msys.qh deleted file mode 100644 index f2fa30e74..000000000 --- a/qcsrc/menu/msys.qh +++ /dev/null @@ -1,173 +0,0 @@ -#pragma flag off fastarrays // make dp behave with new fteqcc versions. remove when dp bug with fteqcc fastarrays is fixed - -////////////////////////////////////////////////////////// -// sys globals - -entity self; - -///////////////////////////////////////////////////////// -void end_sys_globals; -///////////////////////////////////////////////////////// -// sys fields - -///////////////////////////////////////////////////////// -void end_sys_fields; -///////////////////////////////////////////////////////// -// sys functions - -void() m_init; -void(float keynr, float ascii) m_keydown; -void() m_draw; -void() m_display; // old NG Menu -void() m_toggle; -void() m_hide; // old NG Menu -void() m_shutdown; - -///////////////////////////////////////////////////////// -// sys constants - -/////////////////////////// -// key dest constants - -float KEY_UNKNOWN = -1; -float KEY_GAME = 0; -float KEY_MENU = 2; -float KEY_MENU_GRABBED = 3; - -/////////////////////////// -// file constants - -float FILE_READ = 0; -float FILE_APPEND = 1; -float FILE_WRITE = 2; - -/////////////////////////// -// logical constants (just for completeness) - -float TRUE = 1; -float FALSE = 0; - -/////////////////////////// -// boolean constants - -float true = 1; -float false = 0; - -/////////////////////////// -// msg constants - -float MSG_BROADCAST = 0; // unreliable to all -float MSG_ONE = 1; // reliable to one (msg_entity) -float MSG_ALL = 2; // reliable to all -float MSG_INIT = 3; // write to the init string - -///////////////////////////// -// mouse target constants - -float MT_MENU = 1; -float MT_CLIENT = 2; - -///////////////////////// -// client state constants - -float CS_DEDICATED = 0; -float CS_DISCONNECTED = 1; -float CS_CONNECTED = 2; - -/////////////////////////// -// blend flags - -float DRAWFLAG_NORMAL = 0; -float DRAWFLAG_ADDITIVE = 1; -float DRAWFLAG_MODULATE = 2; -float DRAWFLAG_2XMODULATE = 3; - - -/////////////////////////// -// server list constants - -float SLIST_HOSTCACHEVIEWCOUNT = 0; -float SLIST_HOSTCACHETOTALCOUNT = 1; -float SLIST_MASTERQUERYCOUNT = 2; -float SLIST_MASTERREPLYCOUNT = 3; -float SLIST_SERVERQUERYCOUNT = 4; -float SLIST_SERVERREPLYCOUNT = 5; -float SLIST_SORTFIELD = 6; -float SLIST_SORTDESCENDING = 7; - -float SLIST_LEGACY_LINE1 = 1024; -float SLIST_LEGACY_LINE2 = 1025; - -float SLIST_TEST_CONTAINS = 0; -float SLIST_TEST_NOTCONTAIN = 1; -float SLIST_TEST_LESSEQUAL = 2; -float SLIST_TEST_LESS = 3; -float SLIST_TEST_EQUAL = 4; -float SLIST_TEST_GREATER = 5; -float SLIST_TEST_GREATEREQUAL = 6; -float SLIST_TEST_NOTEQUAL = 7; -float SLIST_TEST_STARTSWITH = 8; -float SLIST_TEST_NOTSTARTSWITH = 9; - -float SLIST_MASK_AND = 0; -float SLIST_MASK_OR = 512; - -float NET_CURRENTPROTOCOL = 3; - -//////////////////////////////// -// cinematic action constants - -float CINE_PLAY = 1; -float CINE_LOOP = 2; -float CINE_PAUSE = 3; -float CINE_FIRSTFRAME = 4; -float CINE_RESETONWAKEUP= 5; - -/////////////////////////// -// null entity (actually it is the same like the world entity) - -entity null_entity; - -/////////////////////////// -// error constants - -// file handling -float ERR_CANNOTOPEN = -1; // fopen -float ERR_NOTENOUGHFILEHANDLES = -2; // fopen -float ERR_INVALIDMODE = -3; // fopen -float ERR_BADFILENAME = -4; // fopen - -// drawing functions - -float ERR_NULLSTRING = -1; -float ERR_BADDRAWFLAG = -2; -float ERR_BADSCALE = -3; -//float ERR_BADSIZE = ERR_BADSCALE; -float ERR_NOTCACHED = -4; - -float GECKO_BUTTON_DOWN = 0; -float GECKO_BUTTON_UP = 1; -// either use down and up or just press but not all of them! -float GECKO_BUTTON_PRESS = 2; -// use this for mouse events if needed? -float GECKO_BUTTON_DOUBLECLICK = 3; - -/* not supported at the moment -/////////////////////////// -// os constants - -float OS_WINDOWS = 0; -float OS_LINUX = 1; -float OS_MAC = 2; -*/ - -float drawfont; // set this to one of the following for draw text routines to work with another font -float FONT_DEFAULT = 0; -float FONT_CONSOLE = 1; -float FONT_SBAR = 2; -float FONT_NOTIFY = 3; -float FONT_CHAT = 4; -float FONT_CENTERPRINT = 5; -float FONT_INFOBAR = 6; -float FONT_MENU = 7; -float FONT_USER = 8; // add to this the index, like FONT_USER+3 = user3. At least 8 of them are supported. diff --git a/qcsrc/menu/progs.src b/qcsrc/menu/progs.src index 1184c32d1..979ae519f 100644 --- a/qcsrc/menu/progs.src +++ b/qcsrc/menu/progs.src @@ -1,9 +1,11 @@ ../../menu.dat +../dpdefs/menudefs.qc +../dpdefs/keycodes.qc + config.qh ../common/util-pre.qh -msys.qh -mbuiltin.qh + ../warpzonelib/mathlib.qh ../common/util.qh diff --git a/qcsrc/menu/xonotic/dialog_hudsetup_exit.c b/qcsrc/menu/xonotic/dialog_hudsetup_exit.c index 540e85e4f..0fde6e0bd 100644 --- a/qcsrc/menu/xonotic/dialog_hudsetup_exit.c +++ b/qcsrc/menu/xonotic/dialog_hudsetup_exit.c @@ -21,7 +21,7 @@ void XonoticHUDExitDialog_fill(entity me) me.TD(me, 1, 4, makeXonoticTextLabel(0, _("Panel background defaults:"))); me.TR(me); me.TD(me, 1, 1.4, e = makeXonoticTextLabel(0, _("Background:"))); - me.TD(me, 1, 2.6, e = makeXonoticTextSlider(strzone(strcat("hud_panel_bg")))); + me.TD(me, 1, 2.6, e = makeXonoticTextSlider("hud_panel_bg")); e.addValue(e, _("Disable"), "0"); e.addValue(e, "border_default", "border_default"); // this is a file name! e.configureXonoticTextSliderValues(e); diff --git a/qcsrc/menu/xonotic/keybinder.c b/qcsrc/menu/xonotic/keybinder.c index 754135bb2..1107e60ab 100644 --- a/qcsrc/menu/xonotic/keybinder.c +++ b/qcsrc/menu/xonotic/keybinder.c @@ -73,7 +73,7 @@ entity makeXonoticKeyBinder() void replace_bind(string from, string to) { float n, j, k; - n = tokenize(findkeysforcommand(from)); // uses '...' strings + n = tokenize(findkeysforcommand(from, 0)); // uses '...' strings for(j = 0; j < n; ++j) { k = stof(argv(j)); @@ -141,7 +141,7 @@ void XonoticKeyBinder_keyGrabbed(entity me, float key, float ascii) if(func == "") return; - n = tokenize(findkeysforcommand(func)); // uses '...' strings + n = tokenize(findkeysforcommand(func, 0)); // uses '...' strings nvalid = 0; for(j = 0; j < n; ++j) { @@ -213,7 +213,7 @@ void KeyBinder_Bind_Clear(entity btn, entity me) if(func == "") return; - n = tokenize(findkeysforcommand(func)); // uses '...' strings + n = tokenize(findkeysforcommand(func, 0)); // uses '...' strings for(j = 0; j < n; ++j) { k = stof(argv(j)); @@ -331,7 +331,7 @@ void XonoticKeyBinder_drawListBoxItem(entity me, float i, vector absSize, float draw_Text(me.realUpperMargin * eY + extraMargin * eX, s, me.realFontSize, theColor, theAlpha, 0); if(func != "") { - n = tokenize(findkeysforcommand(func)); // uses '...' strings + n = tokenize(findkeysforcommand(func, 0)); // uses '...' strings s = ""; for(j = 0; j < n; ++j) { diff --git a/qcsrc/menu/xonotic/slider_resolution.c b/qcsrc/menu/xonotic/slider_resolution.c index d5d013048..2e3ea4ce4 100644 --- a/qcsrc/menu/xonotic/slider_resolution.c +++ b/qcsrc/menu/xonotic/slider_resolution.c @@ -34,8 +34,8 @@ void updateConwidths() if(f < 1) c = c * f; // ensures that c_x <= r_x and c_y <= r_y - minfactor = min(1, 640 / c_x); // can be > 1 only if c_x is <640 - maxfactor = max3(1, r_x / c_x, r_y / c_y); // can be < 1 only if r_x < c_x and r_y < c_y + minfactor = min(1, 640 / c_x); // can be > 1 only if c_x is <640 + maxfactor = max(1, r_x / c_x, r_y / c_y); // can be < 1 only if r_x < c_x and r_y < c_y dprint("min factor: ", ftos(minfactor), "\n"); dprint("max factor: ", ftos(maxfactor), "\n");