1 ///////////////////////////////////////////////
3 ///////////////////////
4 // This file belongs to dpmod/darkplaces
5 // AK contains all graphic functions
6 ///////////////////////////////////////////////
10 vid_conwidth = cvar("vid_conwidth");
11 vid_conheight = cvar("vid_conheight");
14 void(void) gfx_frame =
16 vid_conwidth = cvar("vid_conwidth");
17 vid_conheight = cvar("vid_conheight");
20 void(void) gfx_toggle =
24 void(float keynr, float ascii) gfx_keydown =
32 void(void) gfx_shutdown =
36 string(string pic_name, float complain) gfx_loadpic =
39 c = precache_pic(pic_name);
41 if(c == "" && complain)
42 error("Couldnt precache ", pic_name, " !\n");
44 dprint("Couldnt precache ", pic_name, " !\n");
48 void(string pic_name) gfx_unloadpic =
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);
55 void(vector position, float character, vector scale, vector rgb, float alpha, float flag)
60 position = gfx_converttocon(position);
61 scale = gfx_converttocon(scale);
66 ret = drawcharacter(position, character, scale, rgb, alpha, flag);
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");
79 void(vector position, string str, vector scale, vector rgb, float alpha, float flag)
84 position = gfx_converttocon(position);
85 scale = gfx_converttocon(scale);
90 ret = drawstring(position, str, scale, rgb, alpha, flag);
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");
103 void(vector position, string pic_name, vector size, vector rgb, float alpha, float flag)
109 size = gfx_getimagesize(pic_name);
112 position = gfx_converttocon(position);
113 size = gfx_converttocon(size);
115 ret = drawpic(position, pic_name, size, rgb, alpha, flag);
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");
130 void(vector position, vector size, vector rgb, float alpha, float flag)
135 position = gfx_converttocon(position);
136 size = gfx_converttocon(size);
141 ret = drawfill(position, size, rgb, alpha, flag);
145 if(ret == ERR_BADDRAWFLAG)
146 error("Bad draw flag !\n");
147 error("Unknown error code !\n");
150 void(vector position, vector size) gfx_setcliparea =
152 position = gfx_converttocon(position);
153 size = gfx_converttocon(size);
154 drawsetcliparea(position_x, position_y, size_x, size_y);
157 void(void) gfx_resetcliparea =
162 void(vector position, float character, vector scale, vector rgb, float alpha, float flag)
165 position = gfx_conmentogfx(position);
166 gfx_drawchar(position, character, scale, rgb, alpha, flag);
169 void(vector position, string str, vector scale, vector rgb, float alpha, float flag)
172 position = gfx_conmentogfx(position);
173 gfx_drawstring(position, str, scale, rgb, alpha, flag);
176 void(vector position, string pic_name, vector size, vector rgb, float alpha, float flag)
179 position = gfx_conmentogfx(position);
180 gfx_drawpic(position, pic_name, size, rgb, alpha, flag);
183 void(vector position, vector size, vector rgb, float alpha, float flag)
186 position = gfx_conmentogfx(position);
187 gfx_fillarea(position, size, rgb, alpha, flag);
191 void(vector position, vector size) menu_setcliparea =
193 position = gfx_conmentogfx(position);
194 gfx_setcliparea(position, size);
198 void(void) menu_resetcliparea =
203 vector(string pic_name) gfx_getimagesize =
205 return drawgetimagesize(pic_name);
208 vector(vector vec) gfx_converttogfx =
211 v_x = vec_x * (GFX_WIDTH / vid_conwidth);
212 v_y = vec_y * (GFX_HEIGHT / vid_conheight);
216 vector(vector vec) gfx_converttocon =
219 v_x = vec_x * (vid_conwidth / GFX_WIDTH);
220 v_y = vec_y * (vid_conheight / GFX_HEIGHT);
224 vector(vector vec) gfx_conmentogfx =
226 return (vec + menu_localorigin);
229 vector(vector vec) gfx_congfxtomen =
231 return (vec - menu_localorigin);
234 void(vector position, vector size, float width, vector rgb, float alpha, float flag)
241 menu_fillarea( position, s, rgb, alpha, flag );
244 p_y = position_y + size_y - width;
245 menu_fillarea( p, s, rgb, alpha, flag );
249 menu_fillarea( position, s, rgb, alpha, flag );
251 p_x = position_x + size_x - width;
253 menu_fillarea( p, s, rgb, alpha, flag );