]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/draw.qc
Merge remote-tracking branch 'origin/samual/serverlist'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / draw.qc
index 1bda59583bb2dad9c7566657ea33b98de5040bfb..df93daa6e0bcd3cacaf8fbf57d3ffdbdb0d5ba35 100644 (file)
@@ -2,14 +2,6 @@ string draw_mousepointer;
 vector draw_mousepointer_offset;
 vector draw_mousepointer_size;
 
-string draw_UseSkinFor(string pic)
-{
-       if(substring(pic, 0, 1) == "/")
-               return substring(pic, 1, strlen(pic)-1);
-       else
-               return strcat(draw_currentSkin, "/", pic);
-}
-
 void draw_setMousePointer(string pic, vector theSize, vector theOffset)
 {
        draw_mousepointer = strzone(draw_UseSkinFor(pic));
@@ -24,11 +16,21 @@ void draw_drawMousePointer(vector where)
 
 void draw_reset(float cw, float ch, float ox, float oy)
 {
-       drawfont = FONT_USER+0;
        draw_shift = '1 0 0' * ox + '0 1 0' * oy;
        draw_scale = '1 0 0' * cw + '0 1 0' * ch;
        draw_alpha = 1;
        draw_fontscale = '1 1 0';
+       draw_endBoldFont();
+}
+
+void draw_beginBoldFont()
+{
+       drawfont = FONT_USER+3;
+}
+
+void draw_endBoldFont()
+{
+       drawfont = FONT_USER+0;
 }
 
 vector globalToBox(vector v, vector theOrigin, vector theScale)
@@ -61,14 +63,22 @@ vector boxToGlobalSize(vector v, vector theScale)
        return v;
 }
 
-void draw_PreloadPicture(string pic)
+string draw_PreloadPicture(string pic)
+{
+       pic = draw_UseSkinFor(pic);
+       return precache_pic(pic);
+}
+
+string draw_PreloadPictureWithFlags(string pic, float f)
 {
        pic = draw_UseSkinFor(pic);
-       precache_pic(pic);
+       return precache_pic(pic, f);
 }
 
 void draw_Picture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha)
 {
+       if(theSize_x == 0 || theSize_y <= 0) // no default sizing please
+               return;
        pic = draw_UseSkinFor(pic);
        drawpic(boxToGlobal(theOrigin, draw_shift, draw_scale), pic, boxToGlobalSize(theSize, draw_scale), theColor, theAlpha * draw_alpha, 0);
 }
@@ -167,12 +177,6 @@ void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector the
        vector dX, dY;
        vector width, height;
        vector bW, bH;
-       if (theBorderSize_x <= 0 && theBorderSize_y <= 0) // no border
-       {
-               // draw only the central part
-               drawsubpic(theOrigin, theSize, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
-               return;
-       }
        pic = draw_UseSkinFor(pic);
        theOrigin = boxToGlobal(theOrigin, draw_shift, draw_scale);
        theSize = boxToGlobalSize(theSize, draw_scale);
@@ -180,11 +184,40 @@ void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector the
        theAlpha *= draw_alpha;
        width = eX * theSize_x;
        height = eY * theSize_y;
-       if(theSize_x <= theBorderSize_x * 2)
+       // zero size? bail out, we cannot handle this
+       if(theSize_x <= 0 || theSize_y <= 0)
+               return;
+       if(theBorderSize_x <= 0) // no x border
+       {
+               if(theBorderSize_y <= 0)
+               {
+                       drawsubpic(theOrigin,                            width          + height,          pic, '0.25 0.25 0', '0.5  0.5  0', theColor, theAlpha, 0);
+               }
+               else if(theSize_y <= theBorderSize_y * 2)
+               {
+                       // not high enough... draw just top and bottom then
+                       bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
+                       drawsubpic(theOrigin,                             width          + height * 0.5, pic, '0.25 0 0',           '0.5  0 0' + bH, theColor, theAlpha, 0);
+                       drawsubpic(theOrigin              + height * 0.5, width          + height * 0.5, pic, '0.25 0 0' + eY - bH, '0.5  0 0' + bH, theColor, theAlpha, 0);
+               }
+               else
+               {
+                       dY = theBorderSize_y * eY;
+                       drawsubpic(theOrigin,                            width                   +     dY, pic, '0.25 0    0', '0.5  0.25 0', theColor, theAlpha, 0);
+                       drawsubpic(theOrigin          + dY,              width          + height - 2 * dY, pic, '0.25 0.25 0', '0.5  0.5  0', theColor, theAlpha, 0);
+                       drawsubpic(theOrigin + height - dY,              width                   +     dY, pic, '0.25 0.75 0', '0.5  0.25 0', theColor, theAlpha, 0);
+               }
+       }
+       else if(theSize_x <= theBorderSize_x * 2)
        {
                // not wide enough... draw just left and right then
                bW = eX * (0.25 * theSize_x / (theBorderSize_x * 2));
-               if(theSize_y <= theBorderSize_y * 2)
+               if(theBorderSize_y <= 0)
+               {
+                       drawsubpic(theOrigin,                             width * 0.5 + height,          pic, '0 0.25 0',           '0 0.5  0' + bW, theColor, theAlpha, 0);
+                       drawsubpic(theOrigin + width * 0.5,               width * 0.5 + height,          pic, '0 0.25 0' + eX - bW, '0 0.5  0' + bW, theColor, theAlpha, 0);
+               }
+               else if(theSize_y <= theBorderSize_y * 2)
                {
                        // not high enough... draw just corners
                        bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
@@ -195,7 +228,7 @@ void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector the
                }
                else
                {
-                       dY = theBorderSize_x * eY;
+                       dY = theBorderSize_y * eY;
                        drawsubpic(theOrigin,                             width * 0.5          +     dY, pic, '0 0    0',           '0 0.25 0' + bW, theColor, theAlpha, 0);
                        drawsubpic(theOrigin + width * 0.5,               width * 0.5          +     dY, pic, '0 0    0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
                        drawsubpic(theOrigin                        + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0',           '0 0.5  0' + bW, theColor, theAlpha, 0);
@@ -206,7 +239,14 @@ void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector the
        }
        else
        {
-               if(theSize_y <= theBorderSize_y * 2)
+               if(theBorderSize_y <= 0)
+               {
+                       dX = theBorderSize_x * eX;
+                       drawsubpic(theOrigin,                                        dX + height,          pic, '0    0.25 0', '0.25 0.5  0', theColor, theAlpha, 0);
+                       drawsubpic(theOrigin                       + dX, width - 2 * dX + height,          pic, '0.25 0.25 0', '0.5  0.5  0', theColor, theAlpha, 0);
+                       drawsubpic(theOrigin               + width - dX,             dX + height,          pic, '0.75 0.25 0', '0.25 0.5  0', theColor, theAlpha, 0);
+               }
+               else if(theSize_y <= theBorderSize_y * 2)
                {
                        // not high enough... draw just top and bottom then
                        bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
@@ -221,7 +261,7 @@ void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector the
                else
                {
                        dX = theBorderSize_x * eX;
-                       dY = theBorderSize_x * eY;
+                       dY = theBorderSize_y * eY;
                        drawsubpic(theOrigin,                                        dX          +     dY, pic, '0    0    0', '0.25 0.25 0', theColor, theAlpha, 0);
                        drawsubpic(theOrigin                  + dX,      width - 2 * dX          +     dY, pic, '0.25 0    0', '0.5  0.25 0', theColor, theAlpha, 0);
                        drawsubpic(theOrigin          + width - dX,                  dX          +     dY, pic, '0.75 0    0', '0.25 0.25 0', theColor, theAlpha, 0);
@@ -236,8 +276,10 @@ void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector the
 }
 void draw_Text(vector theOrigin, string theText, vector theSize, vector theColor, float theAlpha, float ICanHasKallerz)
 {
-       if(theSize_x <= 0 || theSize_y <= 0)
-               error("Drawing zero size text?\n");
+       if(theSize_x <= 0 || theSize_y <= 0) {
+               dprint("Drawing zero size text?\n");
+               return;
+       }
 
        //float wi;
        //wi = draw_TextWidth(theText, ICanHasKallerz, theSize);
@@ -250,14 +292,14 @@ void draw_Text(vector theOrigin, string theText, vector theSize, vector theColor
 }
 void draw_CenterText(vector theOrigin, string theText, vector theSize, vector theColor, float theAlpha, float ICanHasKallerz)
 {
-       //print(strcat("orig = ", vtos(theOrigin) ," tx = ", ftos(draw_TextWidth(theText, ICanHasKallerz, theSize)), "\n"));
+       //dprint(strcat("orig = ", vtos(theOrigin) ," tx = ", ftos(draw_TextWidth(theText, ICanHasKallerz, theSize)), "\n"));
        draw_Text(theOrigin - eX * 0.5 * draw_TextWidth(theText, ICanHasKallerz, theSize), theText, theSize, theColor, theAlpha, ICanHasKallerz);
 }
 
 float draw_TextWidth(string theText, float ICanHasKallerz, vector SizeThxBye)
 {
        //return strlen(theText);
-       //print("draw_TextWidth \"", theText, "\"\n");
+       //dprint("draw_TextWidth \"", theText, "\"\n");
        vector v;
        v = '0 0 0';
        //float r;