r2863 - trunk/data/qcsrc/menu-div0test

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Mon Oct 29 06:03:15 EDT 2007


Author: div0
Date: 2007-10-29 06:03:15 -0400 (Mon, 29 Oct 2007)
New Revision: 2863

Modified:
   trunk/data/qcsrc/menu-div0test/draw.qc
   trunk/data/qcsrc/menu-div0test/draw.qh
Log:
new primitive: VertButtonPicture


Modified: trunk/data/qcsrc/menu-div0test/draw.qc
===================================================================
--- trunk/data/qcsrc/menu-div0test/draw.qc	2007-10-28 10:50:38 UTC (rev 2862)
+++ trunk/data/qcsrc/menu-div0test/draw.qc	2007-10-29 10:03:15 UTC (rev 2863)
@@ -65,6 +65,7 @@
 {
 	vector square;
 	vector width, height;
+	vector bW;
 	theOrigin = boxToGlobal(theOrigin, draw_shift, draw_scale);
 	theSize = boxToGlobalSize(theSize, draw_scale);
 	theAlpha *= draw_alpha;
@@ -75,18 +76,53 @@
 		// button not wide enough
 		// draw just left and right part then
 		square = eX * theSize_x * 0.5;
-		drawsubpic(theOrigin,          square + height, pic, '0   0 0', '0.25 1 0', theColor, theAlpha, 0);
-		drawsubpic(theOrigin + square, square + height, pic, '0.75 0 0', '0.25 1 0', theColor, theAlpha, 0);
+		bW = eX * (0.25 * theSize_x / (theSize_y * 2));
+		drawsubpic(theOrigin,          square + height, pic, '0 0 0', eY + bW, theColor, theAlpha, 0);
+		drawsubpic(theOrigin + square, square + height, pic, eX - bW, eY + bW, theColor, theAlpha, 0);
 	}
 	else
 	{
-		square = theSize_y * '1 0 0';
+		square = eX * theSize_y;
 		drawsubpic(theOrigin,                  height  +     square, pic, '0    0 0', '0.25 1 0', theColor, theAlpha, 0);
 		drawsubpic(theOrigin +         square, theSize - 2 * square, pic, '0.25 0 0', '0.5  1 0', theColor, theAlpha, 0);
 		drawsubpic(theOrigin + width - square, height  +     square, pic, '0.75 0 0', '0.25 1 0', theColor, theAlpha, 0);
 	}
 }
 
+// a vertical button picture is a texture containing three parts:
+//   1/4 height: left part
+//   1/2 height: middle part (stretched)
+//   1/4 height: right part
+// it is assumed to be 4x as high as wide for aspect ratio purposes, which
+// means, the parts are a square, two squares and a square.
+void draw_VertButtonPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha)
+{
+	vector square;
+	vector width, height;
+	vector bH;
+	theOrigin = boxToGlobal(theOrigin, draw_shift, draw_scale);
+	theSize = boxToGlobalSize(theSize, draw_scale);
+	theAlpha *= draw_alpha;
+	width = eX * theSize_x;
+	height = eY * theSize_y;
+	if(theSize_y <= theSize_x * 2)
+	{
+		// button not high enough
+		// draw just upper and lower part then
+		square = eY * theSize_y * 0.5;
+		bH = eY * (0.25 * theSize_y / (theSize_x * 2));
+		drawsubpic(theOrigin,          square + width, pic, '0 0 0', eX + bH, theColor, theAlpha, 0);
+		drawsubpic(theOrigin + square, square + width, pic, eY - bH, eX + bH, theColor, theAlpha, 0);
+	}
+	else
+	{
+		square = eY * theSize_x;
+		drawsubpic(theOrigin,                   width   +     square, pic, '0 0    0', '1 0.25 0', theColor, theAlpha, 0);
+		drawsubpic(theOrigin +          square, theSize - 2 * square, pic, '0 0.25 0', '1 0.5  0', theColor, theAlpha, 0);
+		drawsubpic(theOrigin + height - square, width   +     square, pic, '0 0.75 0', '1 0.25 0', theColor, theAlpha, 0);
+	}
+}
+
 // a border picture is a texture containing nine parts:
 //   1/4 width: left part
 //   1/2 width: middle part (stretched)
@@ -99,6 +135,7 @@
 {
 	vector dX, dY;
 	vector width, height;
+	vector bW, bH;
 	theOrigin = boxToGlobal(theOrigin, draw_shift, draw_scale);
 	theSize = boxToGlobalSize(theSize, draw_scale);
 	theBorderSize = boxToGlobalSize(theBorderSize, draw_scale);
@@ -108,23 +145,25 @@
 	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)
 		{
 			// not high enough... draw just corners
-			drawsubpic(theOrigin,                 width * 0.5 + height * 0.5, pic, '0    0    0', '0.25 0.25 0', theColor, theAlpha, 0);
-			drawsubpic(theOrigin + width   * 0.5, width * 0.5 + height * 0.5, pic, '0.75 0    0', '0.25 0.25 0', theColor, theAlpha, 0);
-			drawsubpic(theOrigin + height  * 0.5, width * 0.5 + height * 0.5, pic, '0    0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
-			drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
+			bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
+			drawsubpic(theOrigin,                 width * 0.5 + height * 0.5, pic, '0 0 0',           bW + bH, theColor, theAlpha, 0);
+			drawsubpic(theOrigin + width   * 0.5, width * 0.5 + height * 0.5, pic, eX - bW,           bW + bH, theColor, theAlpha, 0);
+			drawsubpic(theOrigin + height  * 0.5, width * 0.5 + height * 0.5, pic, eY - bH,           bW + bH, theColor, theAlpha, 0);
+			drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, eX + eY - bW - bH, bW + bH, theColor, theAlpha, 0);
 		}
 		else
 		{
 			dY = theBorderSize_x * eY;
-			drawsubpic(theOrigin,                      width * 0.5          +     dY, pic, '0    0    0', '0.25 0.25 0', theColor, theAlpha, 0);
-			drawsubpic(theOrigin + width   * 0.5,      width * 0.5          +     dY, pic, '0.75 0    0', '0.25 0.25 0', theColor, theAlpha, 0);
-			drawsubpic(theOrigin                 + dY, width * 0.5 + height - 2 * dY, pic, '0    0.25 0', '0.25 0.5  0', theColor, theAlpha, 0);
-			drawsubpic(theOrigin + width   * 0.5 + dY, width * 0.5 + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5  0', theColor, theAlpha, 0);
-			drawsubpic(theOrigin + height        - dY, width * 0.5          +     dY, pic, '0    0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
-			drawsubpic(theOrigin + width   * 0.5 + dY, width * 0.5          +     dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
+			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);
+			drawsubpic(theOrigin + width * 0.5          + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0' + eX - bW, '0 0.5  0' + bW, theColor, theAlpha, 0);
+			drawsubpic(theOrigin               + height - dY, width * 0.5          +     dY, pic, '0 0.75 0',           '0 0.25 0' + bW, theColor, theAlpha, 0);
+			drawsubpic(theOrigin + width * 0.5 + height - dY, width * 0.5          +     dY, pic, '0 0.75 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
 		}
 	}
 	else
@@ -132,13 +171,14 @@
 		if(theSize_y <= theBorderSize_y * 2)
 		{
 			// not high enough... draw just top and bottom then
+			bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
 			dX = theBorderSize_x * eX;
-			drawsubpic(theOrigin,                                         dX + height * 0.5, pic, '0    0    0', '0.25 0.25 0', theColor, theAlpha, 0);
-			drawsubpic(theOrigin + dX,                        width - 2 * dX + height * 0.5, pic, '0.25 0    0', '0.5  0.25 0', theColor, theAlpha, 0);
-			drawsubpic(theOrigin + width - dX,                            dX + height * 0.5, pic, '0.75 0    0', '0.25 0.25 0', theColor, theAlpha, 0);
-			drawsubpic(theOrigin              + height * 0.5,             dX + height * 0.5, pic, '0    0    0', '0.25 0.25 0', theColor, theAlpha, 0);
-			drawsubpic(theOrigin + dX         + height * 0.5, width - 2 * dX + height * 0.5, pic, '0.25 0    0', '0.5  0.25 0', theColor, theAlpha, 0);
-			drawsubpic(theOrigin + width - dX + height * 0.5,             dX + height * 0.5, pic, '0.75 0    0', '0.25 0.25 0', theColor, theAlpha, 0);
+			drawsubpic(theOrigin,                                         dX + height * 0.5, pic, '0    0 0',           '0.25 0 0' + bH, theColor, theAlpha, 0);
+			drawsubpic(theOrigin + dX,                        width - 2 * dX + height * 0.5, pic, '0.25 0 0',           '0.5  0 0' + bH, theColor, theAlpha, 0);
+			drawsubpic(theOrigin + width - dX,                            dX + height * 0.5, pic, '0.75 0 0',           '0.25 0 0' + bH, theColor, theAlpha, 0);
+			drawsubpic(theOrigin              + height * 0.5,             dX + height * 0.5, pic, '0    0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
+			drawsubpic(theOrigin + dX         + height * 0.5, width - 2 * dX + height * 0.5, pic, '0.25 0 0' + eY - bH, '0.5  0 0' + bH, theColor, theAlpha, 0);
+			drawsubpic(theOrigin + width - dX + height * 0.5,             dX + height * 0.5, pic, '0.75 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
 		}
 		else
 		{

Modified: trunk/data/qcsrc/menu-div0test/draw.qh
===================================================================
--- trunk/data/qcsrc/menu-div0test/draw.qh	2007-10-28 10:50:38 UTC (rev 2862)
+++ trunk/data/qcsrc/menu-div0test/draw.qh	2007-10-29 10:03:15 UTC (rev 2863)
@@ -7,6 +7,7 @@
 void draw_drawMousePointer(vector where);
 
 void draw_ButtonPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha);
+void draw_VertButtonPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha);
 void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha, vector theBorderSize);
 void draw_Picture(vector origin, string pic, vector size, vector color, float alpha);
 void draw_Text(vector origin, string text, vector size, vector color, float alpha);




More information about the nexuiz-commits mailing list