]> icculus.org git repositories - divverent/nexuiz.git/blob - menu/graphic.qc
grappling hook
[divverent/nexuiz.git] / menu / graphic.qc
1 ///////////////////////////////////////////////
2 // Graphic Source File
3 ///////////////////////
4 // This file belongs to dpmod/darkplaces
5 // AK contains all graphic functions
6 ///////////////////////////////////////////////
7
8 void(void) gfx_init =
9 {
10         vid_conwidth = cvar("vid_conwidth");
11         vid_conheight = cvar("vid_conheight");
12 };
13
14 void(void) gfx_frame =
15 {
16         vid_conwidth = cvar("vid_conwidth");
17         vid_conheight = cvar("vid_conheight");
18 };
19
20 void(void) gfx_toggle =
21 {
22 };
23
24 void(float keynr, float ascii) gfx_keydown =
25 {
26 };
27
28 void(void) gfx_draw =
29 {
30 };
31
32 void(void) gfx_shutdown =
33 {
34 };
35
36 string(string pic_name, float complain) gfx_loadpic =
37 {
38         string c;
39         c = precache_pic(pic_name);
40
41         if(c == "" && complain)
42                 error("Couldnt precache ", pic_name, " !\n");
43         if(c == "")
44                 dprint("Couldnt precache ", pic_name, " !\n");
45         return c;
46 };
47
48 void(string pic_name) gfx_unloadpic =
49 {
50         // FIXME: gfx_unloadpic is a bit buggy in dp at the moment - restart the menu a few times
51         // and you get an access violation
52         //gfx_unloadpic(pic_name);
53 };
54
55 void(vector position, float character, vector scale, vector rgb, float alpha, float flag)
56 gfx_drawchar =
57 {
58         float ret;
59
60         position = gfx_converttocon(position);
61         scale = gfx_converttocon(scale);
62
63         if(scale == '0 0 0')
64                 return;
65
66         ret = drawcharacter(position, character, scale, rgb, alpha, flag);
67
68         if(ret == 1)
69                 return;
70         if(ret == ERR_NULLSTRING)
71                 error("Null character !\n");
72         if(ret == ERR_BADDRAWFLAG)
73                 error("Bad draw flag !\n");
74         if(ret == ERR_BADSCALE)
75                 error("Bad scale !\n");
76         error("Unknown error code !\n");
77 };
78
79 void(vector position, string str, vector scale, vector rgb, float alpha, float flag)
80 gfx_drawstring =
81 {
82         float ret;
83
84         position = gfx_converttocon(position);
85         scale = gfx_converttocon(scale);
86
87         if(scale == '0 0 0')
88                 return;
89
90         ret = drawstring(position, str, scale, rgb, alpha, flag);
91
92         if(ret == 1)
93                 return;
94         if(ret == ERR_NULLSTRING)
95                 error("Null string !\n");
96         if(ret == ERR_BADDRAWFLAG)
97                 error("Bad draw flag !\n");
98         if(ret == ERR_BADSCALE)
99                 error("Bad scale !\n");
100         error("Unknown error code !\n");
101 };
102
103 void(vector position, string pic_name, vector size, vector rgb, float alpha, float flag)
104 gfx_drawpic =
105 {
106         float ret;
107
108         if(size == '0 0 0')
109                 size = gfx_getimagesize(pic_name);
110
111         // for FrikQCC
112         position = gfx_converttocon(position);
113         size = gfx_converttocon(size);
114
115         ret = drawpic(position, pic_name, size, rgb, alpha, flag);
116
117         if(ret == 1)
118                 return;
119         if(ret == ERR_NULLSTRING)
120                 error("Null string !\n");
121         if(ret == ERR_BADDRAWFLAG)
122                 error("Bad draw flag !\n");
123         if(ret == ERR_BADSIZE)
124                 error("Bad size !\n");
125         if(ret == ERR_NOTCACHED)
126                 error("Picture ", pic_name, " was not precached !\n");
127         error("Unknown error code !\n");
128 };
129
130 void(vector position, vector size, vector rgb, float alpha, float flag)
131 gfx_fillarea =
132 {
133         float ret;
134
135         position = gfx_converttocon(position);
136         size = gfx_converttocon(size);
137
138         if(size == '0 0 0')
139                 return;
140
141         ret = drawfill(position, size, rgb, alpha, flag);
142
143         if(ret == 1)
144                 return;
145         if(ret == ERR_BADDRAWFLAG)
146                 error("Bad draw flag !\n");
147         error("Unknown error code !\n");
148 };
149
150 void(vector position, vector size) gfx_setcliparea =
151 {
152         position = gfx_converttocon(position);
153         size = gfx_converttocon(size);
154         drawsetcliparea(position_x, position_y, size_x, size_y);
155 };
156
157 void(void) gfx_resetcliparea =
158 {
159         drawresetcliparea();
160 };
161
162 void(vector position, float character, vector scale, vector rgb, float alpha, float flag)
163 menu_drawchar =
164 {
165         position = gfx_conmentogfx(position);
166         gfx_drawchar(position, character, scale, rgb, alpha, flag);
167 };
168
169 void(vector position, string str, vector scale, vector rgb, float alpha, float flag)
170 menu_drawstring =
171 {
172         position = gfx_conmentogfx(position);
173         gfx_drawstring(position, str, scale, rgb, alpha, flag);
174 }
175
176 void(vector position, string pic_name, vector size, vector rgb, float alpha, float flag)
177 menu_drawpic =
178 {
179         position = gfx_conmentogfx(position);
180         gfx_drawpic(position, pic_name, size, rgb, alpha, flag);
181 };
182
183 void(vector position, vector size, vector rgb, float alpha, float flag)
184 menu_fillarea =
185 {
186         position = gfx_conmentogfx(position);
187         gfx_fillarea(position, size, rgb, alpha, flag);
188 };
189
190
191 void(vector position, vector size) menu_setcliparea =
192 {
193         position = gfx_conmentogfx(position);
194         gfx_setcliparea(position, size);
195 };
196
197
198 void(void) menu_resetcliparea =
199 {
200         gfx_resetcliparea();
201 };
202
203 vector(string pic_name) gfx_getimagesize =
204 {
205         return drawgetimagesize(pic_name);
206 }
207
208 vector(vector vec) gfx_converttogfx =
209 {
210         vector v;
211         v_x = vec_x * (GFX_WIDTH / vid_conwidth);
212         v_y = vec_y * (GFX_HEIGHT / vid_conheight);
213         return v;
214 };
215
216 vector(vector vec) gfx_converttocon =
217 {
218         vector v;
219         v_x = vec_x * (vid_conwidth / GFX_WIDTH);
220         v_y = vec_y * (vid_conheight / GFX_HEIGHT);
221         return v;
222 };
223
224 vector(vector vec) gfx_conmentogfx =
225 {
226         return (vec + menu_localorigin);
227 };
228
229 vector(vector vec) gfx_congfxtomen =
230 {
231         return (vec - menu_localorigin);
232 };
233
234 void(vector position, vector size, float width, vector rgb, float alpha, float flag)
235 menu_drawoutline =
236 {
237         local vector p, s;
238         
239         s_x = size_x;
240         s_y = width;    
241         menu_fillarea( position, s, rgb, alpha, flag );
242         
243         p_x = position_x;
244         p_y = position_y + size_y - width;
245         menu_fillarea( p, s, rgb, alpha, flag );
246         
247         s_x = width;
248         s_y = size_y;
249         menu_fillarea( position, s, rgb, alpha, flag );
250         
251         p_x = position_x + size_x - width;
252         p_y = position_y;
253         menu_fillarea( p, s, rgb, alpha, flag );        
254 };