From: divverent Date: Sat, 27 Oct 2007 10:59:44 +0000 (+0000) Subject: new menu QC builtin "stringwidth(string text, float handleColors)", does not do anyth... X-Git-Tag: xonotic-v0.1.0preview~2827 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5b833f17e13e0eeb0a30351315739abbb822c6eb;p=xonotic%2Fdarkplaces.git new menu QC builtin "stringwidth(string text, float handleColors)", does not do anything useful yet, but added for future expansion (variable width fonts); also add this to CSQC (see TODO in clvm_cmds.c) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7654 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/clvm_cmds.c b/clvm_cmds.c index f4cab9c5..68b8ecc2 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -3076,7 +3076,7 @@ VM_drawfill, // #323 float(vector position, vector size, vector rgb, float a VM_drawsetcliparea, // #324 void(float x, float y, float width, float height) drawsetcliparea VM_drawresetcliparea, // #325 void(void) drawresetcliparea VM_drawcolorcodedstring, // #326 float drawcolorcodedstring(vector position, string text, vector scale, vector rgb, float alpha, float flag) (EXT_CSQC) -NULL, // #327 +NULL, // #327 // FIXME add stringwidth() here? NULL, // #328 NULL, // #329 VM_CL_getstatf, // #330 float(float stnum) getstatf (EXT_CSQC) diff --git a/mvm_cmds.c b/mvm_cmds.c index 69391109..dddf5a18 100644 --- a/mvm_cmds.c +++ b/mvm_cmds.c @@ -1228,7 +1228,7 @@ VM_cin_getstate, // #464 VM_cin_restart, // #465 VM_drawline, // #466 VM_drawcolorcodedstring, // #467 -NULL, // #468 +VM_stringwidth, // #468 NULL, // #469 NULL, // #470 VM_asin, // #471 float(float s) VM_asin (DP_QC_ASINACOSATANATAN2TAN) diff --git a/prvm_cmds.c b/prvm_cmds.c index 36cb5dbd..1c7f4233 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -2729,6 +2729,24 @@ void VM_drawcolorcodedstring(void) } /* ========= +VM_stringwidth + +float stringwidth(string text, float allowColorCodes) +========= +*/ +void VM_stringwidth(void) +{ + const char *string; + int colors; + VM_SAFEPARMCOUNT(2,VM_drawstring); + + string = PRVM_G_STRING(OFS_PARM0); + colors = (int)PRVM_G_FLOAT(OFS_PARM1); + + PRVM_G_FLOAT(OFS_RETURN) = DrawQ_String(0, 0, string, 0, 1, 1, 0, 0, 0, 0, 0, NULL, !colors); // 1x1 characters, don't actually draw +} +/* +========= VM_drawpic float drawpic(vector position, string pic, vector size, vector rgb, float alpha, float flag) diff --git a/prvm_cmds.h b/prvm_cmds.h index 1efbd261..fb483737 100644 --- a/prvm_cmds.h +++ b/prvm_cmds.h @@ -134,6 +134,8 @@ string precache_pic(string pic) freepic(string s) float drawcharacter(vector position, float character, vector scale, vector rgb, float alpha, float flag) float drawstring(vector position, string text, vector scale, vector rgb, float alpha, float flag) +float drawcolorcodedstring(vector position, string text, vector scale, float alpha, float flag) +float stringwidth(string text, float handleColors) float drawpic(vector position, string pic, vector size, vector rgb, float alpha, float flag) float drawfill(vector position, vector size, vector rgb, float alpha, float flag) drawsetcliparea(float x, float y, float width, float height) @@ -324,6 +326,7 @@ void VM_freepic(void); void VM_drawcharacter(void); void VM_drawstring(void); void VM_drawcolorcodedstring(void); +void VM_stringwidth(void); void VM_drawpic(void); void VM_drawfill(void); void VM_drawsetcliparea(void);