]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Added QC function drawcolorcodedstring (#326 CSQC, #467 MQC) which is similar to...
authordresk <dresk@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 5 Sep 2007 22:15:04 +0000 (22:15 +0000)
committerdresk <dresk@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 5 Sep 2007 22:15:04 +0000 (22:15 +0000)
Useful for drawing colorized player names, centerprints, etc.

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7561 d7cf8633-e32d-0410-b094-e92efae38249

clvm_cmds.c
mvm_cmds.c
prvm_cmds.c
prvm_cmds.h

index 27ba252100ae22ccfd74c8716423891311bfb4eb..9afd7812cdf3c20dcf81592b0ce499ecb3502dc6 100644 (file)
@@ -3075,7 +3075,7 @@ VM_drawpic,                                               // #322 float(vector position, string pic, vector size, vector
 VM_drawfill,                                   // #323 float(vector position, vector size, vector rgb, float alpha, float flag) drawfill (EXT_CSQC)
 VM_drawsetcliparea,                            // #324 void(float x, float y, float width, float height) drawsetcliparea
 VM_drawresetcliparea,                  // #325 void(void) drawresetcliparea
-NULL,                                                  // #326
+VM_drawcolorcodedstring,               // #326 float drawcolorcodedstring(vector position, string text, vector scale, vector rgb, float alpha, float flag) (EXT_CSQC)
 NULL,                                                  // #327
 NULL,                                                  // #328
 NULL,                                                  // #329
index 7ed9c135d92ae2db97ccdd3e8510a680c3913e0e..cef5830c09b207828a12b211d30cc10ca07763c8 100644 (file)
@@ -1226,7 +1226,7 @@ VM_cin_setstate,                  // #463
 VM_cin_getstate,                       // #464
 VM_cin_restart,                        // #465
 VM_drawline,                           // #466
-NULL,                                          // #467
+VM_drawcolorcodedstring,       // #467
 NULL,                                          // #468
 NULL,                                          // #469
 NULL,                                          // #470
index fcf3d8ba40967301ca9134116435bc9ca4b52d12..7710cf786f340a7809a3055d7b289854276079c0 100644 (file)
@@ -2586,6 +2586,47 @@ void VM_drawstring(void)
        DrawQ_String (pos[0], pos[1], string, 0, scale[0], scale[1], rgb[0], rgb[1], rgb[2], PRVM_G_FLOAT(OFS_PARM4), flag, NULL, true);
        PRVM_G_FLOAT(OFS_RETURN) = 1;
 }
+
+/*
+=========
+VM_drawcolorcodedstring
+
+float  drawcolorcodedstring(vector position, string text, vector scale, float alpha, float flag)
+=========
+*/
+void VM_drawcolorcodedstring(void)
+{
+       float *pos,*scale;
+       const char  *string;
+       int flag,color;
+       VM_SAFEPARMCOUNT(5,VM_drawstring);
+
+       string = PRVM_G_STRING(OFS_PARM1);
+       pos = PRVM_G_VECTOR(OFS_PARM0);
+       scale = PRVM_G_VECTOR(OFS_PARM2);
+       flag = (int)PRVM_G_FLOAT(OFS_PARM5);
+
+       if(flag < DRAWFLAG_NORMAL || flag >=DRAWFLAG_NUMFLAGS)
+       {
+               PRVM_G_FLOAT(OFS_RETURN) = -2;
+               VM_Warning("VM_drawcolorcodedstring: %s: wrong DRAWFLAG %i !\n",PRVM_NAME,flag);
+               return;
+       }
+
+       if(!scale[0] || !scale[1])
+       {
+               PRVM_G_FLOAT(OFS_RETURN) = -3;
+               VM_Warning("VM_drawcolorcodedstring: scale %s is null !\n", (scale[0] == 0) ? ((scale[1] == 0) ? "x and y" : "x") : "y");
+               return;
+       }
+
+       if(pos[2] || scale[2])
+               Con_Printf("VM_drawcolorcodedstring: z value%s from %s discarded\n",(pos[2] && scale[2]) ? "s" : " ",((pos[2] && scale[2]) ? "pos and scale" : (pos[2] ? "pos" : "scale")));
+
+       color = -1;
+       DrawQ_String (pos[0], pos[1], string, 0, scale[0], scale[1], 1, 1, 1, PRVM_G_FLOAT(OFS_PARM3), flag, NULL, false);
+       PRVM_G_FLOAT(OFS_RETURN) = 1;
+}
 /*
 =========
 VM_drawpic
index 61393b16a2e8e923bdead48264ff892c03006d2c..20c4927beda304814542b66ea7bf2d59037811d4 100644 (file)
@@ -323,6 +323,7 @@ void VM_precache_pic(void);
 void VM_freepic(void);
 void VM_drawcharacter(void);
 void VM_drawstring(void);
+void VM_drawcolorcodedstring(void);
 void VM_drawpic(void);
 void VM_drawfill(void);
 void VM_drawsetcliparea(void);