1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * ©1995 Artsoft Development *
6 * 33659 Bielefeld-Senne *
7 * Telefon: (0521) 493245 *
8 * eMail: aeglos@valinor.owl.de *
9 * aeglos@uni-paderborn.de *
10 * q99492@pbhrzx.uni-paderborn.de *
11 *----------------------------------------------------------*
14 * Letzte Aenderung: 15.06.1995 *
15 ***********************************************************/
22 /* sizes in the level editor */
24 #define ED_WIN_MB_LEFT_XPOS 7
25 #define ED_WIN_MB_LEFT_YPOS 6
26 #define ED_WIN_LEVELNR_XPOS 77
27 #define ED_WIN_LEVELNR_YPOS 7
28 #define ED_WIN_MB_MIDDLE_XPOS 7
29 #define ED_WIN_MB_MIDDLE_YPOS 258
30 #define ED_WIN_MB_RIGHT_XPOS 77
31 #define ED_WIN_MB_RIGHT_YPOS 258
33 #define ED_BUTTON_EUP_XPOS 35
34 #define ED_BUTTON_EUP_YPOS 5
35 #define ED_BUTTON_EUP_XSIZE 30
36 #define ED_BUTTON_EUP_YSIZE 25
37 #define ED_BUTTON_EDOWN_XPOS 35
38 #define ED_BUTTON_EDOWN_YPOS 250
39 #define ED_BUTTON_EDOWN_XSIZE 30
40 #define ED_BUTTON_EDOWN_YSIZE 25
41 #define ED_BUTTON_ELEM_XPOS 6
42 #define ED_BUTTON_ELEM_YPOS 30
43 #define ED_BUTTON_ELEM_XSIZE 22
44 #define ED_BUTTON_ELEM_YSIZE 22
49 #define ED_BUTTON_EUP_Y2POS 140
50 #define ED_BUTTON_EDOWN_Y2POS 165
51 #define ED_BUTTON_ELEM_Y2POS 190
53 #define ED_BUTTON_CTRL_XPOS 5
54 #define ED_BUTTON_CTRL_YPOS 5
55 #define ED_BUTTON_CTRL_XSIZE 90
56 #define ED_BUTTON_CTRL_YSIZE 30
57 #define ED_BUTTON_FILL_XPOS 5
58 #define ED_BUTTON_FILL_YPOS 35
59 #define ED_BUTTON_FILL_XSIZE 90
60 #define ED_BUTTON_FILL_YSIZE 20
61 #define ED_BUTTON_LEFT_XPOS 5
62 #define ED_BUTTON_LEFT_YPOS 65
63 #define ED_BUTTON_LEFT_XSIZE 30
64 #define ED_BUTTON_LEFT_YSIZE 20
65 #define ED_BUTTON_UP_XPOS 35
66 #define ED_BUTTON_UP_YPOS 55
67 #define ED_BUTTON_UP_XSIZE 30
68 #define ED_BUTTON_UP_YSIZE 20
69 #define ED_BUTTON_DOWN_XPOS 35
70 #define ED_BUTTON_DOWN_YPOS 75
71 #define ED_BUTTON_DOWN_XSIZE 30
72 #define ED_BUTTON_DOWN_YSIZE 20
73 #define ED_BUTTON_RIGHT_XPOS 65
74 #define ED_BUTTON_RIGHT_YPOS 65
75 #define ED_BUTTON_RIGHT_XSIZE 30
76 #define ED_BUTTON_RIGHT_YSIZE 20
78 #define ED_BUTTON_EDIT_XPOS 5
79 #define ED_BUTTON_EDIT_YPOS 5
80 #define ED_BUTTON_EDIT_XSIZE 90
81 #define ED_BUTTON_EDIT_YSIZE 30
82 #define ED_BUTTON_CLEAR_XPOS 5
83 #define ED_BUTTON_CLEAR_YPOS 35
84 #define ED_BUTTON_CLEAR_XSIZE 90
85 #define ED_BUTTON_CLEAR_YSIZE 20
86 #define ED_BUTTON_UNDO_XPOS 5
87 #define ED_BUTTON_UNDO_YPOS 55
88 #define ED_BUTTON_UNDO_XSIZE 90
89 #define ED_BUTTON_UNDO_YSIZE 20
90 #define ED_BUTTON_EXIT_XPOS 5
91 #define ED_BUTTON_EXIT_YPOS 75
92 #define ED_BUTTON_EXIT_XSIZE 90
93 #define ED_BUTTON_EXIT_YSIZE 20
95 #define ED_BUTTON_MINUS_XPOS 2
96 #define ED_BUTTON_MINUS_YPOS 60
97 #define ED_BUTTON_MINUS_XSIZE 20
98 #define ED_BUTTON_MINUS_YSIZE 20
99 #define ED_WIN_COUNT_XPOS (ED_BUTTON_MINUS_XPOS+ED_BUTTON_MINUS_XSIZE+2)
100 #define ED_WIN_COUNT_YPOS ED_BUTTON_MINUS_YPOS
101 #define ED_WIN_COUNT_XSIZE 52
102 #define ED_WIN_COUNT_YSIZE ED_BUTTON_MINUS_YSIZE
103 #define ED_BUTTON_PLUS_XPOS (ED_WIN_COUNT_XPOS+ED_WIN_COUNT_XSIZE+2)
104 #define ED_BUTTON_PLUS_YPOS ED_BUTTON_MINUS_YPOS
105 #define ED_BUTTON_PLUS_XSIZE ED_BUTTON_MINUS_XSIZE
106 #define ED_BUTTON_PLUS_YSIZE ED_BUTTON_MINUS_YSIZE
108 #define ED_COUNT_GADGET_XPOS 16
109 #define ED_COUNT_GADGET_YPOS (16+3*MINI_TILEY+64)
110 #define ED_COUNT_GADGET_YSIZE (ED_BUTTON_MINUS_YSIZE+4)
111 #define ED_COUNT_TEXT_XPOS (ED_COUNT_GADGET_XPOS+DXSIZE+10)
112 #define ED_COUNT_TEXT_YPOS (ED_COUNT_GADGET_YPOS+3)
113 #define ED_COUNT_TEXT_YSIZE ED_COUNT_GADGET_YSIZE
114 #define ED_COUNT_VALUE_XPOS (ED_COUNT_GADGET_XPOS+ED_BUTTON_MINUS_XSIZE+7)
115 #define ED_COUNT_VALUE_YPOS ED_COUNT_TEXT_YPOS
116 #define ED_SIZE_GADGET_XPOS (SX+21*MINI_TILEX)
117 #define ED_SIZE_GADGET_YPOS (SY+4*MINI_TILEY)
118 #define ED_SIZE_GADGET_YSIZE (ED_BUTTON_MINUS_YSIZE+4)
119 #define ED_SIZE_TEXT_XPOS (ED_SIZE_GADGET_XPOS+DXSIZE+10)
120 #define ED_SIZE_TEXT_YPOS (ED_SIZE_GADGET_YPOS+3)
121 #define ED_SIZE_TEXT_YSIZE ED_COUNT_GADGET_YSIZE
122 #define ED_SIZE_VALUE_XPOS (ED_SIZE_GADGET_XPOS+ED_BUTTON_MINUS_XSIZE+7)
123 #define ED_SIZE_VALUE_YPOS ED_SIZE_TEXT_YPOS
125 #define ON_EDIT_BUTTON(x,y) (((x)>=(VX+ED_BUTTON_CTRL_XPOS) && \
126 (x)< (VX+ED_BUTTON_CTRL_XPOS + \
127 ED_BUTTON_CTRL_XSIZE) && \
128 (y)>=(VY+ED_BUTTON_CTRL_YPOS) && \
129 (y)< (VY+ED_BUTTON_CTRL_YPOS + \
130 ED_BUTTON_CTRL_YSIZE + \
131 ED_BUTTON_FILL_YSIZE)) || \
132 ((x)>=(VX+ED_BUTTON_LEFT_XPOS) && \
133 (x)< (VX+ED_BUTTON_LEFT_XPOS + \
134 ED_BUTTON_LEFT_XSIZE + \
135 ED_BUTTON_UP_XSIZE + \
136 ED_BUTTON_RIGHT_XSIZE) && \
137 (y)>=(VY+ED_BUTTON_LEFT_YPOS) && \
138 (y)< (VY+ED_BUTTON_LEFT_YPOS + \
139 ED_BUTTON_LEFT_YSIZE)) || \
140 ((x)>=(VX+ED_BUTTON_UP_XPOS) && \
141 (x)< (VX+ED_BUTTON_UP_XPOS + \
142 ED_BUTTON_UP_XSIZE) && \
143 (y)>=(VY+ED_BUTTON_UP_YPOS) && \
144 (y)< (VY+ED_BUTTON_UP_YPOS + \
145 ED_BUTTON_UP_YSIZE + \
146 ED_BUTTON_DOWN_YSIZE)))
148 #define ON_CTRL_BUTTON(x,y) ((x)>=(VX+ED_BUTTON_EDIT_XPOS) && \
149 (x)< (VX+ED_BUTTON_EDIT_XPOS + \
150 ED_BUTTON_EDIT_XSIZE) && \
151 (y)>=(VY+ED_BUTTON_EDIT_YPOS) && \
152 (y)< (VY+ED_BUTTON_EDIT_YPOS + \
153 ED_BUTTON_EDIT_YSIZE + \
154 ED_BUTTON_CLEAR_YSIZE + \
155 ED_BUTTON_UNDO_YSIZE + \
156 ED_BUTTON_EXIT_YSIZE))
158 #define ON_ELEM_BUTTON(x,y) (((x)>=(DX+ED_BUTTON_EUP_XPOS) && \
159 (x)< (DX+ED_BUTTON_EUP_XPOS + \
160 ED_BUTTON_EUP_XSIZE) && \
161 (y)>=(DY+ED_BUTTON_EUP_YPOS) && \
162 (y)< (DY+ED_BUTTON_EUP_YPOS + \
163 ED_BUTTON_EUP_YSIZE)) || \
164 ((x)>=(DX+ED_BUTTON_EDOWN_XPOS) && \
165 (x)< (DX+ED_BUTTON_EDOWN_XPOS + \
166 ED_BUTTON_EDOWN_XSIZE) && \
167 (y)>=(DY+ED_BUTTON_EDOWN_YPOS) && \
168 (y)< (DY+ED_BUTTON_EDOWN_YPOS + \
169 ED_BUTTON_EDOWN_YSIZE)) || \
170 ((x)>=(DX+ED_BUTTON_ELEM_XPOS) && \
171 (x)< (DX+ED_BUTTON_ELEM_XPOS + \
172 MAX_ELEM_X*ED_BUTTON_ELEM_XSIZE) && \
173 (y)>=(DY+ED_BUTTON_ELEM_YPOS) && \
174 (y)< (DY+ED_BUTTON_ELEM_YPOS + \
175 MAX_ELEM_Y*ED_BUTTON_ELEM_YSIZE)))
177 #define ON_COUNT_BUTTON(x,y) (((((x)>=ED_COUNT_GADGET_XPOS && \
178 (x)<(ED_COUNT_GADGET_XPOS + \
179 ED_BUTTON_MINUS_XSIZE)) || \
180 ((x)>=(ED_COUNT_GADGET_XPOS + \
181 (ED_BUTTON_PLUS_XPOS - \
182 ED_BUTTON_MINUS_XPOS)) && \
183 (x)<(ED_COUNT_GADGET_XPOS + \
184 (ED_BUTTON_PLUS_XPOS - \
185 ED_BUTTON_MINUS_XPOS) + \
186 ED_BUTTON_PLUS_XSIZE))) && \
187 ((y)>=ED_COUNT_GADGET_YPOS && \
188 (y)<(ED_COUNT_GADGET_YPOS + \
189 16*ED_COUNT_GADGET_YSIZE)) && \
190 (((y)-ED_COUNT_GADGET_YPOS) % \
191 ED_COUNT_GADGET_YSIZE) < \
192 ED_BUTTON_MINUS_YSIZE) || \
193 ((((x)>=ED_SIZE_GADGET_XPOS && \
194 (x)<(ED_SIZE_GADGET_XPOS + \
195 ED_BUTTON_MINUS_XSIZE)) || \
196 ((x)>=(ED_SIZE_GADGET_XPOS + \
197 (ED_BUTTON_PLUS_XPOS - \
198 ED_BUTTON_MINUS_XPOS)) && \
199 (x)<(ED_SIZE_GADGET_XPOS + \
200 (ED_BUTTON_PLUS_XPOS - \
201 ED_BUTTON_MINUS_XPOS) + \
202 ED_BUTTON_PLUS_XSIZE))) && \
203 ((y)>=ED_SIZE_GADGET_YPOS && \
204 (y)<(ED_SIZE_GADGET_YPOS + \
205 2*ED_SIZE_GADGET_YSIZE)) && \
206 (((y)-ED_SIZE_GADGET_YPOS) % \
207 ED_SIZE_GADGET_YSIZE) < \
208 ED_BUTTON_MINUS_YSIZE))
210 #define EDIT_BUTTON(x,y) (((y) < (VY + ED_BUTTON_CTRL_YPOS + \
211 ED_BUTTON_CTRL_YSIZE)) ? 0 : \
212 ((y) < (VY + ED_BUTTON_CTRL_YPOS + \
213 ED_BUTTON_CTRL_YSIZE + \
214 ED_BUTTON_FILL_YSIZE)) ? 1 : \
215 ((x) < (VX + ED_BUTTON_LEFT_XPOS + \
216 ED_BUTTON_LEFT_XSIZE) ? 2 : \
217 (x) > (VX + ED_BUTTON_LEFT_XPOS + \
218 ED_BUTTON_LEFT_XSIZE + \
219 ED_BUTTON_UP_XSIZE) ? 5 : \
220 3+(((y)-(VY + ED_BUTTON_CTRL_YPOS + \
221 ED_BUTTON_CTRL_YSIZE + \
222 ED_BUTTON_FILL_YSIZE)) / \
223 ED_BUTTON_UP_YSIZE)))
225 #define CTRL_BUTTON(x,y) (((y) < (VY + ED_BUTTON_EDIT_YPOS + \
226 ED_BUTTON_EDIT_YSIZE)) ? 0 : \
227 1+(((y)-(VY + ED_BUTTON_EDIT_YPOS + \
228 ED_BUTTON_EDIT_YSIZE)) / \
229 ED_BUTTON_CLEAR_YSIZE))
231 #define ELEM_BUTTON(x,y) (((y) < (DY + ED_BUTTON_EUP_YPOS + \
232 ED_BUTTON_EUP_YSIZE)) ? 0 : \
233 ((y) > (DY + ED_BUTTON_EDOWN_YPOS)) ? 1 : \
234 2+(((y) - (DY + ED_BUTTON_ELEM_YPOS)) / \
235 ED_BUTTON_ELEM_YSIZE)*MAX_ELEM_X + \
236 ((x) - (DX + ED_BUTTON_ELEM_XPOS)) / \
237 ED_BUTTON_ELEM_XSIZE)
239 #define COUNT_BUTTON(x,y) ((x) < ED_SIZE_GADGET_XPOS ? \
240 ((((y) - ED_COUNT_GADGET_YPOS) / \
241 ED_COUNT_GADGET_YSIZE)*2 + \
242 ((x) < (ED_COUNT_GADGET_XPOS + \
243 ED_BUTTON_MINUS_XSIZE) ? 0 : 1)) : \
244 32+((((y) - ED_SIZE_GADGET_YPOS) / \
245 ED_SIZE_GADGET_YSIZE)*2 + \
246 ((x) < (ED_SIZE_GADGET_XPOS + \
247 ED_BUTTON_MINUS_XSIZE) ? 0 : 1)))
249 /* values for asking control */
250 #define ED_BUTTON_CTRL (1L<<0)
251 #define ED_BUTTON_FILL (1L<<1)
252 #define ED_BUTTON_LEFT (1L<<2)
253 #define ED_BUTTON_UP (1L<<3)
254 #define ED_BUTTON_DOWN (1L<<4)
255 #define ED_BUTTON_RIGHT (1L<<5)
256 #define ED_BUTTON_EDIT (1L<<6)
257 #define ED_BUTTON_CLEAR (1L<<7)
258 #define ED_BUTTON_UNDO (1L<<8)
259 #define ED_BUTTON_EXIT (1L<<9)
261 #define ED_BUTTON_PRESSED (1L<<10)
262 #define ED_BUTTON_RELEASED (1L<<11)
264 #define ED_BUTTON_EUP 0
265 #define ED_BUTTON_EDOWN 1
266 #define ED_BUTTON_ELEM 2
270 /* OBSOLETE *********************** */
272 /* sizes in the level editor */
273 #define ED_PFEIL_XSIZE 46
274 #define ED_PFEIL_YSIZE 19
275 #define ED_ZEIT_XSIZE 20
276 #define ED_ZEIT_YSIZE 20
277 #define ED_CLEX_XSIZE 46
278 #define ED_CLEX_YSIZE 18
279 #define ED_BUT_CLEX_Y (DYSIZE-2-ED_CLEX_YSIZE)
280 #define ED_BUT_ZEIT_Y (ED_BUT_CLEX_Y-2-ED_ZEIT_YSIZE)
281 #define ED_BUT_PFEIL_Y (ED_BUT_ZEIT_Y-2-ED_PFEIL_YSIZE)
282 #define ED_BUT_ZEIT2_X (ED_ZEIT_XSIZE+10)
283 #define ED_BUT_ZEIT2_Y (ED_BUT_ZEIT_Y+4)
285 #define ED_BUT_Y ED_BUT_PFEIL_Y
287 /* OBSOLETE *********************** */
292 /* other constants for the editor */
293 #define ED_SCROLL_NO 0
294 #define ED_SCROLL_LEFT 1
295 #define ED_SCROLL_RIGHT 2
296 #define ED_SCROLL_UP 4
297 #define ED_SCROLL_DOWN 8
299 void DrawLevelEd(void);
300 void ScrollMiniLevel(int, int, int);
301 void LevelEd(int, int, int);
302 void LevelNameTyping(KeySym);
303 void DrawEditButton(unsigned long state);
304 void DrawCtrlButton(unsigned long state);
305 void DrawElemButton(int, int);
306 void DrawCountButton(int, int);
307 int CheckEditButtons(int, int, int);
308 int CheckCtrlButtons(int, int, int);
309 int CheckElemButtons(int, int, int);
310 int CheckCountButtons(int, int, int);