+/*
+=========
+VM_drawcharacter
+
+float drawcharacter(vector position, float character, vector scale, vector rgb, float alpha, float flag)
+=========
+*/
+void VM_drawcharacter(void)
+{
+ float *pos,*scale,*rgb;
+ char character;
+ int flag;
+ VM_SAFEPARMCOUNT(6,VM_drawcharacter);
+
+ character = (char) PRVM_G_FLOAT(OFS_PARM1);
+ if(character == 0)
+ {
+ Con_Printf("VM_drawcharacter: %s passed null character !\n",PRVM_NAME);
+ PRVM_G_FLOAT(OFS_RETURN) = -1;
+ return;
+ }
+
+ pos = PRVM_G_VECTOR(OFS_PARM0);
+ scale = PRVM_G_VECTOR(OFS_PARM2);
+ rgb = PRVM_G_VECTOR(OFS_PARM3);
+ flag = (int)PRVM_G_FLOAT(OFS_PARM5);
+
+ if(flag < DRAWFLAG_NORMAL || flag >=DRAWFLAG_NUMFLAGS)
+ {
+ Con_Printf("VM_drawcharacter: %s: wrong DRAWFLAG %i !\n",PRVM_NAME,flag);
+ PRVM_G_FLOAT(OFS_RETURN) = -2;
+ return;
+ }
+
+ if(pos[2] || scale[2])
+ Con_Printf("VM_drawcharacter: z value%c from %s discarded\n",(pos[2] && scale[2]) ? 's' : 0,((pos[2] && scale[2]) ? "pos and scale" : (pos[2] ? "pos" : "scale")));
+
+ if(!scale[0] || !scale[1])
+ {
+ Con_Printf("VM_drawcharacter: scale %s is null !\n", (scale[0] == 0) ? ((scale[1] == 0) ? "x and y" : "x") : "y");
+ PRVM_G_FLOAT(OFS_RETURN) = -3;
+ return;
+ }
+
+ DrawQ_String (pos[0], pos[1], &character, 1, scale[0], scale[1], rgb[0], rgb[1], rgb[2], PRVM_G_FLOAT(OFS_PARM4), flag);
+ PRVM_G_FLOAT(OFS_RETURN) = 1;
+}
+
+/*
+=========
+VM_drawstring
+
+float drawstring(vector position, string text, vector scale, vector rgb, float alpha, float flag)
+=========
+*/
+void VM_drawstring(void)
+{
+ float *pos,*scale,*rgb;
+ const char *string;
+ int flag;
+ VM_SAFEPARMCOUNT(6,VM_drawstring);
+
+ string = PRVM_G_STRING(OFS_PARM1);
+ if(!string)
+ {
+ Con_Printf("VM_drawstring: %s passed null string !\n",PRVM_NAME);
+ PRVM_G_FLOAT(OFS_RETURN) = -1;
+ return;
+ }
+
+ //VM_CheckEmptyString(string); Why should it be checked - perhaps the menu wants to support the precolored letters, too?
+
+ pos = PRVM_G_VECTOR(OFS_PARM0);
+ scale = PRVM_G_VECTOR(OFS_PARM2);
+ rgb = PRVM_G_VECTOR(OFS_PARM3);
+ flag = (int)PRVM_G_FLOAT(OFS_PARM5);
+
+ if(flag < DRAWFLAG_NORMAL || flag >=DRAWFLAG_NUMFLAGS)
+ {
+ Con_Printf("VM_drawstring: %s: wrong DRAWFLAG %i !\n",PRVM_NAME,flag);
+ PRVM_G_FLOAT(OFS_RETURN) = -2;
+ return;
+ }
+
+ if(!scale[0] || !scale[1])
+ {
+ Con_Printf("VM_drawstring: scale %s is null !\n", (scale[0] == 0) ? ((scale[1] == 0) ? "x and y" : "x") : "y");
+ PRVM_G_FLOAT(OFS_RETURN) = -3;
+ return;
+ }
+
+ if(pos[2] || scale[2])
+ Con_Printf("VM_drawstring: z value%c from %s discarded\n",(pos[2] && scale[2]) ? 's' : 0,((pos[2] && scale[2]) ? "pos and scale" : (pos[2] ? "pos" : "scale")));
+
+ DrawQ_String (pos[0], pos[1], string, 0, scale[0], scale[1], rgb[0], rgb[1], rgb[2], PRVM_G_FLOAT(OFS_PARM4), flag);
+ PRVM_G_FLOAT(OFS_RETURN) = 1;
+}
+/*
+=========
+VM_drawpic
+
+float drawpic(vector position, string pic, vector size, vector rgb, float alpha, float flag)
+=========
+*/
+void VM_drawpic(void)
+{
+ const char *pic;
+ float *size, *pos, *rgb;
+ int flag;
+
+ VM_SAFEPARMCOUNT(6,VM_drawpic);
+
+ pic = PRVM_G_STRING(OFS_PARM1);
+
+ if(!pic)
+ {
+ Con_Printf("VM_drawpic: %s passed null picture name !\n", PRVM_NAME);
+ PRVM_G_FLOAT(OFS_RETURN) = -1;
+ return;
+ }
+
+ VM_CheckEmptyString (pic);
+
+ // is pic cached ? no function yet for that
+ if(!1)
+ {
+ Con_Printf("VM_drawpic: %s: %s not cached !\n", PRVM_NAME, pic);
+ PRVM_G_FLOAT(OFS_RETURN) = -4;
+ return;
+ }
+
+ pos = PRVM_G_VECTOR(OFS_PARM0);
+ size = PRVM_G_VECTOR(OFS_PARM2);
+ rgb = PRVM_G_VECTOR(OFS_PARM3);
+ flag = (int) PRVM_G_FLOAT(OFS_PARM5);
+
+ if(flag < DRAWFLAG_NORMAL || flag >=DRAWFLAG_NUMFLAGS)
+ {
+ Con_Printf("VM_drawstring: %s: wrong DRAWFLAG %i !\n",PRVM_NAME,flag);
+ PRVM_G_FLOAT(OFS_RETURN) = -2;
+ return;
+ }
+
+ if(pos[2] || size[2])
+ Con_Printf("VM_drawstring: z value%c from %s discarded\n",(pos[2] && size[2]) ? 's' : 0,((pos[2] && size[2]) ? "pos and size" : (pos[2] ? "pos" : "size")));
+
+ DrawQ_Pic(pos[0], pos[1], pic, size[0], size[1], rgb[0], rgb[1], rgb[2], PRVM_G_FLOAT(OFS_PARM4), flag);
+ PRVM_G_FLOAT(OFS_RETURN) = 1;
+}
+
+/*
+=========
+VM_drawfill
+
+float drawfill(vector position, vector size, vector rgb, float alpha, float flag)
+=========
+*/
+void VM_drawfill(void)
+{
+ float *size, *pos, *rgb;
+ int flag;
+
+ VM_SAFEPARMCOUNT(5,VM_drawfill);
+
+
+ pos = PRVM_G_VECTOR(OFS_PARM0);
+ size = PRVM_G_VECTOR(OFS_PARM1);
+ rgb = PRVM_G_VECTOR(OFS_PARM2);
+ flag = (int) PRVM_G_FLOAT(OFS_PARM4);
+
+ if(flag < DRAWFLAG_NORMAL || flag >=DRAWFLAG_NUMFLAGS)
+ {
+ Con_Printf("VM_drawstring: %s: wrong DRAWFLAG %i !\n",PRVM_NAME,flag);
+ PRVM_G_FLOAT(OFS_RETURN) = -2;
+ return;
+ }
+
+ if(pos[2] || size[2])
+ Con_Printf("VM_drawstring: z value%c from %s discarded\n",(pos[2] && size[2]) ? 's' : 0,((pos[2] && size[2]) ? "pos and size" : (pos[2] ? "pos" : "size")));
+
+ DrawQ_Pic(pos[0], pos[1], 0, size[0], size[1], rgb[0], rgb[1], rgb[2], PRVM_G_FLOAT(OFS_PARM3), flag);
+ PRVM_G_FLOAT(OFS_RETURN) = 1;
+}
+
+/*
+=========
+VM_drawsetcliparea
+
+drawsetcliparea(float x, float y, float width, float height)
+=========
+*/
+void VM_drawsetcliparea(void)
+{
+ float x,y,w,h;
+ VM_SAFEPARMCOUNT(4,VM_drawsetcliparea);
+
+ x = bound(0, PRVM_G_FLOAT(OFS_PARM0), vid_conwidth.integer);
+ y = bound(0, PRVM_G_FLOAT(OFS_PARM1), vid_conheight.integer);
+ w = bound(0, PRVM_G_FLOAT(OFS_PARM2) + PRVM_G_FLOAT(OFS_PARM0) - x, (vid_conwidth.integer - x));
+ h = bound(0, PRVM_G_FLOAT(OFS_PARM3) + PRVM_G_FLOAT(OFS_PARM1) - y, (vid_conheight.integer - y));
+
+ DrawQ_SetClipArea(x, y, w, h);
+}
+
+/*
+=========
+VM_drawresetcliparea
+
+drawresetcliparea()
+=========
+*/
+void VM_drawresetcliparea(void)
+{
+ VM_SAFEPARMCOUNT(0,VM_drawresetcliparea);
+
+ DrawQ_ResetClipArea();
+}
+
+/*
+=========
+VM_getimagesize
+
+vector getimagesize(string pic)
+=========
+*/
+void VM_getimagesize(void)
+{
+ const char *p;
+ cachepic_t *pic;
+
+ VM_SAFEPARMCOUNT(1,VM_getimagesize);
+
+ p = PRVM_G_STRING(OFS_PARM0);
+
+ if(!p)
+ PRVM_ERROR("VM_getimagepos: %s passed null picture name !\n", PRVM_NAME);