2 string draw_mousepointer;
4 void draw_setMousePointer(string pic)
6 draw_mousepointer = pic;
9 void draw_drawMousePointer(vector where)
11 drawpic(boxToGlobal(where, draw_shift, draw_scale), draw_mousepointer, '32 32 0', '1 1 1', draw_alpha, 0);
18 draw_scale = '1 0 0' * cvar("vid_conwidth") + '0 1 0' * cvar("vid_conheight");
22 vector globalToBox(vector v, vector theOrigin, vector theScale)
30 vector globalToBoxSize(vector v, vector theScale)
37 vector boxToGlobal(vector v, vector theOrigin, vector theScale)
45 vector boxToGlobalSize(vector v, vector theScale)
52 void draw_Picture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha)
54 //drawpic(boxToGlobal(theOrigin, draw_shift, draw_scale), pic, boxToGlobalSize(theSize, draw_scale), theColor, theAlpha * draw_alpha, 0);
55 drawsubpic(boxToGlobal(theOrigin, draw_shift, draw_scale), boxToGlobalSize(theSize, draw_scale), pic, '0 0 0', '1 1 1', theColor, theAlpha * draw_alpha, 0);
58 // a button picture is a texture containing three parts:
59 // 1/4 width: left part
60 // 1/2 width: middle part (stretched)
61 // 1/4 width: right part
62 // it is assumed to be 4x as wide as high for aspect ratio purposes, which
63 // means, the parts are a square, two squares and a square.
64 void draw_ButtonPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha)
68 theOrigin = boxToGlobal(theOrigin, draw_shift, draw_scale);
69 theSize = boxToGlobalSize(theSize, draw_scale);
70 theAlpha *= draw_alpha;
71 width = eX * theSize_x;
72 height = eY * theSize_y;
73 if(theSize_x <= theSize_y * 2)
75 // button not wide enough
76 // draw just left and right part then
77 square = eX * theSize_x * 0.5;
78 drawsubpic(theOrigin, square + height, pic, '0 0 0', '0.25 1 0', theColor, theAlpha, 0);
79 drawsubpic(theOrigin + square, square + height, pic, '0.75 0 0', '0.25 1 0', theColor, theAlpha, 0);
83 square = theSize_y * '1 0 0';
84 drawsubpic(theOrigin, height + square, pic, '0 0 0', '0.25 1 0', theColor, theAlpha, 0);
85 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0.25 0 0', '0.5 1 0', theColor, theAlpha, 0);
86 drawsubpic(theOrigin + width - square, height + square, pic, '0.75 0 0', '0.25 1 0', theColor, theAlpha, 0);
90 // a border picture is a texture containing nine parts:
91 // 1/4 width: left part
92 // 1/2 width: middle part (stretched)
93 // 1/4 width: right part
95 // 1/4 height: top part
96 // 1/2 height: middle part (stretched)
97 // 1/4 height: bottom part
98 void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha, vector theBorderSize)
101 vector width, height;
102 theOrigin = boxToGlobal(theOrigin, draw_shift, draw_scale);
103 theSize = boxToGlobalSize(theSize, draw_scale);
104 theBorderSize = boxToGlobalSize(theBorderSize, draw_scale);
105 theAlpha *= draw_alpha;
106 width = eX * theSize_x;
107 height = eY * theSize_y;
108 if(theSize_x <= theBorderSize_x * 2)
110 // not wide enough... draw just left and right then
111 if(theSize_y <= theBorderSize_y * 2)
113 // not high enough... draw just corners
114 drawsubpic(theOrigin, width * 0.5 + height * 0.5, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
115 drawsubpic(theOrigin + width * 0.5, width * 0.5 + height * 0.5, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
116 drawsubpic(theOrigin + height * 0.5, width * 0.5 + height * 0.5, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
117 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);
121 dY = theBorderSize_x * eY;
122 drawsubpic(theOrigin, width * 0.5 + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
123 drawsubpic(theOrigin + width * 0.5, width * 0.5 + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
124 drawsubpic(theOrigin + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
125 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);
126 drawsubpic(theOrigin + height - dY, width * 0.5 + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
127 drawsubpic(theOrigin + width * 0.5 + dY, width * 0.5 + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
132 if(theSize_y <= theBorderSize_y * 2)
134 // not high enough... draw just top and bottom then
135 dX = theBorderSize_x * eX;
136 drawsubpic(theOrigin, dX + height * 0.5, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
137 drawsubpic(theOrigin + dX, width - 2 * dX + height * 0.5, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0);
138 drawsubpic(theOrigin + width - dX, dX + height * 0.5, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
139 drawsubpic(theOrigin + height * 0.5, dX + height * 0.5, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
140 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);
141 drawsubpic(theOrigin + width - dX + height * 0.5, dX + height * 0.5, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
145 dX = theBorderSize_x * eX;
146 dY = theBorderSize_x * eY;
147 drawsubpic(theOrigin, dX + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
148 drawsubpic(theOrigin + dX, width - 2 * dX + dY, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0);
149 drawsubpic(theOrigin + width - dX, dX + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
150 drawsubpic(theOrigin + dY, dX + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
151 drawsubpic(theOrigin + dY + dX, width - 2 * dX + height - 2 * dY, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
152 drawsubpic(theOrigin + dY + width - dX, dX + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
153 drawsubpic(theOrigin + height - dY, dX + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
154 drawsubpic(theOrigin + height - dY + dX, width - 2 * dX + dY, pic, '0.25 0.75 0', '0.5 0.25 0', theColor, theAlpha, 0);
155 drawsubpic(theOrigin + height - dY + width - dX, dX + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
159 void draw_Text(vector theOrigin, string theText, vector theSize, vector theColor, float theAlpha)
161 if(theSize_x <= 0 || theSize_y <= 0)
162 error("Drawing zero size text?\n");
163 drawstring(boxToGlobal(theOrigin, draw_shift, draw_scale), theText, boxToGlobalSize(theSize, draw_scale), theColor, theAlpha * draw_alpha, 0);
166 float draw_TextWidth(string theText)
168 //return strlen(theText);
169 //print("draw_TextWidth \"", theText, "\"\n");
170 return stringwidth(theText, 0);