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 27ba252..9afd781 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 7ed9c13..cef5830 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 fcf3d8b..7710cf7 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 61393b1..20c4927 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);