1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-2002 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
16 #include "libgame/libgame.h"
27 #define INFOTEXT_UNKNOWN_ELEMENT "unknown"
31 -----------------------------------------------------------------------------
32 screen and artwork graphic pixel position definitions
33 -----------------------------------------------------------------------------
36 /* positions in the level editor */
37 #define ED_WIN_MB_LEFT_XPOS 6
38 #define ED_WIN_MB_LEFT_YPOS 258
39 #define ED_WIN_MB_MIDDLE_XPOS 42
40 #define ED_WIN_MB_MIDDLE_YPOS ED_WIN_MB_LEFT_YPOS
41 #define ED_WIN_MB_RIGHT_XPOS 78
42 #define ED_WIN_MB_RIGHT_YPOS ED_WIN_MB_LEFT_YPOS
44 /* values for the control window */
45 #define ED_CTRL_NO_BUTTONS_GFX_XPOS 6
46 #define ED_CTRL_NO_BUTTONS_GFX_YPOS 286
47 #define ED_CTRL1_BUTTONS_GFX_YPOS 236
48 #define ED_CTRL2_BUTTONS_GFX_YPOS 236
49 #define ED_CTRL3_BUTTONS_GFX_YPOS 324
50 #define ED_CTRL1_BUTTONS_ALT_GFX_YPOS 142
51 #define ED_CTRL3_BUTTONS_ALT_GFX_YPOS 302
53 #define ED_CTRL1_BUTTON_XSIZE 22
54 #define ED_CTRL1_BUTTON_YSIZE 22
55 #define ED_CTRL1_BUTTONS_XPOS 6
56 #define ED_CTRL1_BUTTONS_YPOS 6
57 #define ED_CTRL2_BUTTON_XSIZE 30
58 #define ED_CTRL2_BUTTON_YSIZE 20
59 #define ED_CTRL2_BUTTONS_XPOS 5
60 #define ED_CTRL2_BUTTONS_YPOS 99
61 #define ED_CTRL3_BUTTON_XSIZE 22
62 #define ED_CTRL3_BUTTON_YSIZE 22
63 #define ED_CTRL3_BUTTONS_XPOS 6
64 #define ED_CTRL3_BUTTONS_YPOS 6
66 #define ED_CTRL1_BUTTONS_HORIZ 4
67 #define ED_CTRL1_BUTTONS_VERT 4
68 #define ED_CTRL2_BUTTONS_HORIZ 3
69 #define ED_CTRL2_BUTTONS_VERT 2
70 #define ED_CTRL3_BUTTONS_HORIZ 3
71 #define ED_CTRL3_BUTTONS_VERT 1
73 #define ED_NUM_CTRL1_BUTTONS (ED_CTRL1_BUTTONS_HORIZ * ED_CTRL1_BUTTONS_VERT)
74 #define ED_NUM_CTRL2_BUTTONS (ED_CTRL2_BUTTONS_HORIZ * ED_CTRL2_BUTTONS_VERT)
75 #define ED_NUM_CTRL3_BUTTONS (ED_CTRL3_BUTTONS_HORIZ * ED_CTRL3_BUTTONS_VERT)
76 #define ED_NUM_CTRL1_2_BUTTONS (ED_NUM_CTRL1_BUTTONS + ED_NUM_CTRL2_BUTTONS)
77 #define ED_NUM_CTRL_BUTTONS (ED_NUM_CTRL1_BUTTONS + \
78 ED_NUM_CTRL2_BUTTONS + \
81 /* values for the element list */
82 #define ED_ELEMENTLIST_XPOS 5
83 #define ED_ELEMENTLIST_YPOS 30
84 #define ED_ELEMENTLIST_XSIZE 20
85 #define ED_ELEMENTLIST_YSIZE 20
86 #define ED_ELEMENTLIST_BUTTONS_HORIZ 4
87 #define ED_ELEMENTLIST_BUTTONS_VERT 11
88 #define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \
89 ED_ELEMENTLIST_BUTTONS_VERT)
91 /* standard distances */
92 #define ED_BORDER_SIZE 3
93 #define ED_BORDER_TEXT_XSIZE 5
94 #define ED_BORDER_AREA_YSIZE 1
96 #define ED_GADGET_DISTANCE 2
97 #define ED_GADGET_TEXT_DISTANCE (2 * ED_GADGET_DISTANCE)
98 #define ED_DRAWINGAREA_TEXT_DISTANCE (ED_GADGET_TEXT_DISTANCE + \
101 /* values for the setting windows */
102 #define ED_SETTINGS_XSTART (3 * MINI_TILEX / 2)
103 #define ED_SETTINGS_YSTART (MINI_TILEY * 10)
105 #define ED_XOFFSET_CHECKBOX (ED_CHECKBUTTON_XSIZE + \
106 2 * ED_GADGET_DISTANCE)
108 #define ED_SETTINGS_XOFFSET ED_XOFFSET_CHECKBOX
109 #define ED_SETTINGS_YOFFSET (3 * MINI_TILEY / 2)
111 #define ED_SETTINGS_XPOS(n) (ED_SETTINGS_XSTART + \
112 n * ED_SETTINGS_XOFFSET)
113 #define ED_SETTINGS_YPOS(n) (ED_SETTINGS_YSTART + \
114 n * ED_SETTINGS_YOFFSET)
116 #define ED_SETTINGS1_YPOS MINI_TILEY
117 #define ED_SETTINGS2_XPOS MINI_TILEX
118 #define ED_SETTINGS2_YPOS (ED_SETTINGS1_YPOS + 12 * TILEY - 2)
120 /* values for counter gadgets */
121 #define ED_COUNTER_YSTART (ED_SETTINGS1_YPOS + 2 * TILEY)
122 #define ED_COUNTER_YDISTANCE (3 * MINI_TILEY)
123 #define ED_COUNTER_YPOS(n) (ED_COUNTER_YSTART + \
124 n * ED_COUNTER_YDISTANCE)
125 #define ED_COUNTER2_YPOS(n) (ED_COUNTER_YSTART + \
126 n * ED_COUNTER_YDISTANCE - 2)
128 /* values for element content drawing areas */
130 #define ED_AREA_ELEM_CONTENT_XPOS ( 2 * MINI_TILEX)
131 #define ED_AREA_ELEM_CONTENT_YPOS (22 * MINI_TILEY)
134 #define ED_AREA_YAMYAM_CONTENT_XPOS(n) (ED_AREA_ELEM_CONTENT_XPOS + \
135 5 * (n % 4) * MINI_TILEX)
136 #define ED_AREA_YAMYAM_CONTENT_YPOS(n) (ED_AREA_ELEM_CONTENT_YPOS + \
137 6 * (n / 4) * MINI_TILEY)
139 /* custom change target */
140 #define ED_AREA_ELEM_CONTENT2_YPOS (ED_SETTINGS_YPOS(2) + \
142 /* optional custom graphic */
143 #define ED_AREA_ELEM_CONTENT3_YPOS (ED_SETTINGS_YPOS(1) + \
145 /* custom element content */
146 #define ED_AREA_ELEM_CONTENT4_XPOS (29 * MINI_TILEX)
147 #define ED_AREA_ELEM_CONTENT4_YPOS (ED_SETTINGS_YPOS(13) + \
148 ED_GADGET_DISTANCE - MINI_TILEY)
149 /* movement enter/leave element */
150 #define ED_AREA_ELEM_CONTENT4a_XPOS (29 * MINI_TILEX)
151 #define ED_AREA_ELEM_CONTENT4a_YPOS (ED_SETTINGS_YPOS(7) + \
153 #define ED_AREA_ELEM_CONTENT4b_XPOS (29 * MINI_TILEX)
154 #define ED_AREA_ELEM_CONTENT4b_YPOS (ED_SETTINGS_YPOS(7) + \
156 /* custom change trigger element */
157 #define ED_AREA_ELEM_CONTENT5_YPOS (ED_SETTINGS_YPOS(6) + \
159 /* extended custom change target */
160 #define ED_AREA_ELEM_CONTENT6_XPOS (29 * MINI_TILEX)
161 #define ED_AREA_ELEM_CONTENT6_YPOS (ED_SETTINGS_YPOS(10) + \
162 ED_GADGET_DISTANCE - MINI_TILEY)
163 /* group element content */
164 #define ED_AREA_GROUP_CONTENT_XPOS ED_SETTINGS_XPOS(0)
165 #define ED_AREA_GROUP_CONTENT_YPOS (22 * MINI_TILEY)
167 /* values for random placement background drawing area */
168 #define ED_AREA_RANDOM_BACKGROUND_YPOS (31 * MINI_TILEY)
170 /* values for scrolling gadgets for drawing area */
171 #define ED_SCROLLBUTTON_XPOS 24
172 #define ED_SCROLLBUTTON_YPOS 0
173 #define ED_SCROLLBAR_XPOS 24
174 #define ED_SCROLLBAR_YPOS 64
176 #define ED_SCROLLBUTTON_XSIZE 16
177 #define ED_SCROLLBUTTON_YSIZE 16
179 #define ED_SCROLL_UP_XPOS (SXSIZE - ED_SCROLLBUTTON_XSIZE)
180 #define ED_SCROLL_UP_YPOS (0)
181 #define ED_SCROLL_DOWN_XPOS ED_SCROLL_UP_XPOS
182 #define ED_SCROLL_DOWN_YPOS (SYSIZE - 3 * ED_SCROLLBUTTON_YSIZE)
183 #define ED_SCROLL_LEFT_XPOS (0)
184 #define ED_SCROLL_LEFT_YPOS (SYSIZE - 2 * ED_SCROLLBUTTON_YSIZE)
185 #define ED_SCROLL_RIGHT_XPOS (SXSIZE - 2 * ED_SCROLLBUTTON_XSIZE)
186 #define ED_SCROLL_RIGHT_YPOS ED_SCROLL_LEFT_YPOS
187 #define ED_SCROLL_HORIZONTAL_XPOS (ED_SCROLL_LEFT_XPOS + ED_SCROLLBUTTON_XSIZE)
188 #define ED_SCROLL_HORIZONTAL_YPOS ED_SCROLL_LEFT_YPOS
189 #define ED_SCROLL_HORIZONTAL_XSIZE (SXSIZE - 3 * ED_SCROLLBUTTON_XSIZE)
190 #define ED_SCROLL_HORIZONTAL_YSIZE ED_SCROLLBUTTON_YSIZE
191 #define ED_SCROLL_VERTICAL_XPOS ED_SCROLL_UP_XPOS
192 #define ED_SCROLL_VERTICAL_YPOS (ED_SCROLL_UP_YPOS + ED_SCROLLBUTTON_YSIZE)
193 #define ED_SCROLL_VERTICAL_XSIZE ED_SCROLLBUTTON_XSIZE
194 #define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - 4 * ED_SCROLLBUTTON_YSIZE)
196 /* values for scrolling gadgets for element list */
197 #define ED_SCROLLBUTTON2_XPOS 50
198 #define ED_SCROLLBUTTON2_YPOS 0
199 #define ED_SCROLLBAR2_XPOS 50
200 #define ED_SCROLLBAR2_YPOS 20
202 #define ED_SCROLLBUTTON2_XSIZE 10
203 #define ED_SCROLLBUTTON2_YSIZE 10
205 #define ED_SCROLL2_UP_XPOS 85
206 #define ED_SCROLL2_UP_YPOS 30
207 #define ED_SCROLL2_DOWN_XPOS ED_SCROLL2_UP_XPOS
208 #define ED_SCROLL2_DOWN_YPOS (ED_SCROLL2_UP_YPOS + \
209 ED_ELEMENTLIST_BUTTONS_VERT * \
210 ED_ELEMENTLIST_YSIZE - \
211 ED_SCROLLBUTTON2_YSIZE)
212 #define ED_SCROLL2_VERTICAL_XPOS ED_SCROLL2_UP_XPOS
213 #define ED_SCROLL2_VERTICAL_YPOS (ED_SCROLL2_UP_YPOS + \
214 ED_SCROLLBUTTON2_YSIZE)
215 #define ED_SCROLL2_VERTICAL_XSIZE ED_SCROLLBUTTON2_XSIZE
216 #define ED_SCROLL2_VERTICAL_YSIZE (ED_ELEMENTLIST_BUTTONS_VERT * \
217 ED_ELEMENTLIST_YSIZE - \
218 2 * ED_SCROLLBUTTON2_YSIZE)
220 /* values for checkbutton gadgets */
221 #define ED_CHECKBUTTON_XSIZE ED_BUTTON_COUNT_XSIZE
222 #define ED_CHECKBUTTON_YSIZE ED_BUTTON_COUNT_YSIZE
223 #define ED_CHECKBUTTON_UNCHECKED_XPOS ED_BUTTON_MINUS_XPOS
224 #define ED_CHECKBUTTON_CHECKED_XPOS ED_BUTTON_PLUS_XPOS
225 #define ED_CHECKBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 22)
226 #define ED_RADIOBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 44)
227 #define ED_STICKYBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 66)
229 /* some positions in the editor control window */
230 #define ED_BUTTON_ELEM_XPOS 6
231 #define ED_BUTTON_ELEM_YPOS 30
232 #define ED_BUTTON_ELEM_XSIZE 22
233 #define ED_BUTTON_ELEM_YSIZE 22
235 /* some values for text input, selectbox and counter gadgets */
236 #define ED_BUTTON_COUNT_YPOS 60
237 #define ED_BUTTON_COUNT_XSIZE 20
238 #define ED_BUTTON_COUNT_YSIZE 20
239 #define ED_WIN_COUNT_XPOS (2 + ED_BUTTON_COUNT_XSIZE + 2)
240 #define ED_WIN_COUNT_YPOS ED_BUTTON_COUNT_YPOS
241 #define ED_WIN_COUNT_XSIZE 52
242 #define ED_WIN_COUNT_YSIZE ED_BUTTON_COUNT_YSIZE
243 #define ED_WIN_COUNT2_XPOS 27
244 #define ED_WIN_COUNT2_YPOS 3
245 #define ED_WIN_COUNT2_XSIZE 46
246 #define ED_WIN_COUNT2_YSIZE ED_BUTTON_COUNT_YSIZE
248 #define ED_BUTTON_MINUS_XPOS 2
249 #define ED_BUTTON_MINUS_YPOS ED_BUTTON_COUNT_YPOS
250 #define ED_BUTTON_MINUS_XSIZE ED_BUTTON_COUNT_XSIZE
251 #define ED_BUTTON_MINUS_YSIZE ED_BUTTON_COUNT_YSIZE
252 #define ED_BUTTON_PLUS_XPOS (ED_WIN_COUNT_XPOS + \
253 ED_WIN_COUNT_XSIZE + 2)
254 #define ED_BUTTON_PLUS_YPOS ED_BUTTON_COUNT_YPOS
255 #define ED_BUTTON_PLUS_XSIZE ED_BUTTON_COUNT_XSIZE
256 #define ED_BUTTON_PLUS_YSIZE ED_BUTTON_COUNT_YSIZE
258 #define ED_SELECTBOX_XPOS ED_WIN_COUNT_XPOS
259 #define ED_SELECTBOX_YPOS (ED_WIN_COUNT_YPOS + \
260 2 + ED_WIN_COUNT_YSIZE)
261 #define ED_SELECTBOX_XSIZE ED_WIN_COUNT_XSIZE
262 #define ED_SELECTBOX_YSIZE ED_WIN_COUNT_YSIZE
264 #define ED_SELECTBOX_BUTTON_XSIZE 14
266 #define ED_TEXTBUTTON_XPOS ED_WIN_COUNT_XPOS
267 #define ED_TEXTBUTTON_YPOS (ED_WIN_COUNT_YPOS + \
268 4 * (2 + ED_WIN_COUNT_YSIZE))
269 #define ED_TEXTBUTTON_INACTIVE_YPOS ED_TEXTBUTTON_YPOS
271 #define ED_TEXTBUTTON_TAB_XPOS ED_WIN_COUNT_XPOS
272 #define ED_TEXTBUTTON_TAB_YPOS (ED_WIN_COUNT_YPOS + \
273 2 * (2 + ED_WIN_COUNT_YSIZE))
274 #define ED_TEXTBUTTON_TAB_INACTIVE_YPOS (ED_WIN_COUNT_YPOS + \
275 3 * (2 + ED_WIN_COUNT_YSIZE))
277 #define ED_TEXTBUTTON_XSIZE ED_WIN_COUNT_XSIZE
278 #define ED_TEXTBUTTON_YSIZE ED_WIN_COUNT_YSIZE
280 /* values for ClearEditorGadgetInfoText() and HandleGadgetInfoText() */
281 #define INFOTEXT_XPOS SX
282 #define INFOTEXT_YPOS (SY + SYSIZE - MINI_TILEX + 2)
283 #define INFOTEXT_XSIZE SXSIZE
284 #define INFOTEXT_YSIZE MINI_TILEX
288 -----------------------------------------------------------------------------
289 editor gadget definitions
290 -----------------------------------------------------------------------------
293 /* drawing toolbox buttons */
294 #define GADGET_ID_NONE -1
295 #define GADGET_ID_TOOLBOX_FIRST 0
297 #define GADGET_ID_SINGLE_ITEMS (GADGET_ID_TOOLBOX_FIRST + 0)
298 #define GADGET_ID_CONNECTED_ITEMS (GADGET_ID_TOOLBOX_FIRST + 1)
299 #define GADGET_ID_LINE (GADGET_ID_TOOLBOX_FIRST + 2)
300 #define GADGET_ID_ARC (GADGET_ID_TOOLBOX_FIRST + 3)
301 #define GADGET_ID_RECTANGLE (GADGET_ID_TOOLBOX_FIRST + 4)
302 #define GADGET_ID_FILLED_BOX (GADGET_ID_TOOLBOX_FIRST + 5)
303 #define GADGET_ID_WRAP_UP (GADGET_ID_TOOLBOX_FIRST + 6)
304 #define GADGET_ID_TEXT (GADGET_ID_TOOLBOX_FIRST + 7)
305 #define GADGET_ID_FLOOD_FILL (GADGET_ID_TOOLBOX_FIRST + 8)
306 #define GADGET_ID_WRAP_LEFT (GADGET_ID_TOOLBOX_FIRST + 9)
307 #define GADGET_ID_PROPERTIES (GADGET_ID_TOOLBOX_FIRST + 10)
308 #define GADGET_ID_WRAP_RIGHT (GADGET_ID_TOOLBOX_FIRST + 11)
309 #define GADGET_ID_RANDOM_PLACEMENT (GADGET_ID_TOOLBOX_FIRST + 12)
310 #define GADGET_ID_GRAB_BRUSH (GADGET_ID_TOOLBOX_FIRST + 13)
311 #define GADGET_ID_WRAP_DOWN (GADGET_ID_TOOLBOX_FIRST + 14)
312 #define GADGET_ID_PICK_ELEMENT (GADGET_ID_TOOLBOX_FIRST + 15)
314 #define GADGET_ID_UNDO (GADGET_ID_TOOLBOX_FIRST + 16)
315 #define GADGET_ID_INFO (GADGET_ID_TOOLBOX_FIRST + 17)
316 #define GADGET_ID_SAVE (GADGET_ID_TOOLBOX_FIRST + 18)
317 #define GADGET_ID_CLEAR (GADGET_ID_TOOLBOX_FIRST + 19)
318 #define GADGET_ID_TEST (GADGET_ID_TOOLBOX_FIRST + 20)
319 #define GADGET_ID_EXIT (GADGET_ID_TOOLBOX_FIRST + 21)
321 #define GADGET_ID_CUSTOM_COPY_FROM (GADGET_ID_TOOLBOX_FIRST + 22)
322 #define GADGET_ID_CUSTOM_COPY_TO (GADGET_ID_TOOLBOX_FIRST + 23)
323 #define GADGET_ID_CUSTOM_EXCHANGE (GADGET_ID_TOOLBOX_FIRST + 24)
325 /* counter button identifiers */
326 #define GADGET_ID_COUNTER_FIRST (GADGET_ID_TOOLBOX_FIRST + 25)
328 #define GADGET_ID_SELECT_LEVEL_DOWN (GADGET_ID_COUNTER_FIRST + 0)
329 #define GADGET_ID_SELECT_LEVEL_TEXT (GADGET_ID_COUNTER_FIRST + 1)
330 #define GADGET_ID_SELECT_LEVEL_UP (GADGET_ID_COUNTER_FIRST + 2)
331 #define GADGET_ID_LEVEL_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 3)
332 #define GADGET_ID_LEVEL_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 4)
333 #define GADGET_ID_LEVEL_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 5)
334 #define GADGET_ID_LEVEL_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 6)
335 #define GADGET_ID_LEVEL_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 7)
336 #define GADGET_ID_LEVEL_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 8)
337 #define GADGET_ID_LEVEL_RANDOM_DOWN (GADGET_ID_COUNTER_FIRST + 9)
338 #define GADGET_ID_LEVEL_RANDOM_TEXT (GADGET_ID_COUNTER_FIRST + 10)
339 #define GADGET_ID_LEVEL_RANDOM_UP (GADGET_ID_COUNTER_FIRST + 11)
340 #define GADGET_ID_LEVEL_GEMSLIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 12)
341 #define GADGET_ID_LEVEL_GEMSLIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 13)
342 #define GADGET_ID_LEVEL_GEMSLIMIT_UP (GADGET_ID_COUNTER_FIRST + 14)
343 #define GADGET_ID_LEVEL_TIMELIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 15)
344 #define GADGET_ID_LEVEL_TIMELIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 16)
345 #define GADGET_ID_LEVEL_TIMELIMIT_UP (GADGET_ID_COUNTER_FIRST + 17)
346 #define GADGET_ID_LEVEL_TIMESCORE_DOWN (GADGET_ID_COUNTER_FIRST + 18)
347 #define GADGET_ID_LEVEL_TIMESCORE_TEXT (GADGET_ID_COUNTER_FIRST + 19)
348 #define GADGET_ID_LEVEL_TIMESCORE_UP (GADGET_ID_COUNTER_FIRST + 20)
349 #define GADGET_ID_ELEMENT_SCORE_DOWN (GADGET_ID_COUNTER_FIRST + 21)
350 #define GADGET_ID_ELEMENT_SCORE_TEXT (GADGET_ID_COUNTER_FIRST + 22)
351 #define GADGET_ID_ELEMENT_SCORE_UP (GADGET_ID_COUNTER_FIRST + 23)
352 #define GADGET_ID_ELEMENT_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 24)
353 #define GADGET_ID_ELEMENT_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 25)
354 #define GADGET_ID_ELEMENT_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 26)
355 #define GADGET_ID_ENVELOPE_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 27)
356 #define GADGET_ID_ENVELOPE_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 28)
357 #define GADGET_ID_ENVELOPE_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 29)
358 #define GADGET_ID_ENVELOPE_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 30)
359 #define GADGET_ID_ENVELOPE_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 31)
360 #define GADGET_ID_ENVELOPE_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 32)
361 #define GADGET_ID_CUSTOM_SCORE_DOWN (GADGET_ID_COUNTER_FIRST + 33)
362 #define GADGET_ID_CUSTOM_SCORE_TEXT (GADGET_ID_COUNTER_FIRST + 34)
363 #define GADGET_ID_CUSTOM_SCORE_UP (GADGET_ID_COUNTER_FIRST + 35)
364 #define GADGET_ID_CUSTOM_GEMCOUNT_DOWN (GADGET_ID_COUNTER_FIRST + 36)
365 #define GADGET_ID_CUSTOM_GEMCOUNT_TEXT (GADGET_ID_COUNTER_FIRST + 37)
366 #define GADGET_ID_CUSTOM_GEMCOUNT_UP (GADGET_ID_COUNTER_FIRST + 38)
367 #define GADGET_ID_PUSH_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 39)
368 #define GADGET_ID_PUSH_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 40)
369 #define GADGET_ID_PUSH_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 41)
370 #define GADGET_ID_PUSH_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 42)
371 #define GADGET_ID_PUSH_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 43)
372 #define GADGET_ID_PUSH_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 44)
373 #define GADGET_ID_MOVE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 45)
374 #define GADGET_ID_MOVE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 46)
375 #define GADGET_ID_MOVE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 47)
376 #define GADGET_ID_MOVE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 48)
377 #define GADGET_ID_MOVE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 49)
378 #define GADGET_ID_MOVE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 50)
379 #define GADGET_ID_CHANGE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 51)
380 #define GADGET_ID_CHANGE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 52)
381 #define GADGET_ID_CHANGE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 53)
382 #define GADGET_ID_CHANGE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 54)
383 #define GADGET_ID_CHANGE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 55)
384 #define GADGET_ID_CHANGE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 56)
385 #define GADGET_ID_CHANGE_CONT_RND_DOWN (GADGET_ID_COUNTER_FIRST + 57)
386 #define GADGET_ID_CHANGE_CONT_RND_TEXT (GADGET_ID_COUNTER_FIRST + 58)
387 #define GADGET_ID_CHANGE_CONT_RND_UP (GADGET_ID_COUNTER_FIRST + 59)
388 #define GADGET_ID_GROUP_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 60)
389 #define GADGET_ID_GROUP_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 61)
390 #define GADGET_ID_GROUP_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 62)
392 /* drawing area identifiers */
393 #define GADGET_ID_DRAWING_AREA_FIRST (GADGET_ID_COUNTER_FIRST + 63)
395 #define GADGET_ID_DRAWING_LEVEL (GADGET_ID_DRAWING_AREA_FIRST + 0)
396 #define GADGET_ID_ELEMENT_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 1)
397 #define GADGET_ID_ELEMENT_CONTENT_1 (GADGET_ID_DRAWING_AREA_FIRST + 2)
398 #define GADGET_ID_ELEMENT_CONTENT_2 (GADGET_ID_DRAWING_AREA_FIRST + 3)
399 #define GADGET_ID_ELEMENT_CONTENT_3 (GADGET_ID_DRAWING_AREA_FIRST + 4)
400 #define GADGET_ID_ELEMENT_CONTENT_4 (GADGET_ID_DRAWING_AREA_FIRST + 5)
401 #define GADGET_ID_ELEMENT_CONTENT_5 (GADGET_ID_DRAWING_AREA_FIRST + 6)
402 #define GADGET_ID_ELEMENT_CONTENT_6 (GADGET_ID_DRAWING_AREA_FIRST + 7)
403 #define GADGET_ID_ELEMENT_CONTENT_7 (GADGET_ID_DRAWING_AREA_FIRST + 8)
404 #define GADGET_ID_AMOEBA_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 9)
405 #define GADGET_ID_CUSTOM_GRAPHIC (GADGET_ID_DRAWING_AREA_FIRST + 10)
406 #define GADGET_ID_CUSTOM_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 11)
407 #define GADGET_ID_CUSTOM_MOVE_ENTER (GADGET_ID_DRAWING_AREA_FIRST + 12)
408 #define GADGET_ID_CUSTOM_MOVE_LEAVE (GADGET_ID_DRAWING_AREA_FIRST + 13)
409 #define GADGET_ID_CUSTOM_CHANGE_TARGET (GADGET_ID_DRAWING_AREA_FIRST + 14)
410 #define GADGET_ID_CUSTOM_CHANGE_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 15)
411 #define GADGET_ID_CUSTOM_CHANGE_TRIGGER (GADGET_ID_DRAWING_AREA_FIRST + 16)
412 #define GADGET_ID_GROUP_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 17)
413 #define GADGET_ID_RANDOM_BACKGROUND (GADGET_ID_DRAWING_AREA_FIRST + 18)
415 /* text input identifiers */
416 #define GADGET_ID_TEXT_INPUT_FIRST (GADGET_ID_DRAWING_AREA_FIRST + 19)
418 #define GADGET_ID_LEVEL_NAME (GADGET_ID_TEXT_INPUT_FIRST + 0)
419 #define GADGET_ID_LEVEL_AUTHOR (GADGET_ID_TEXT_INPUT_FIRST + 1)
420 #define GADGET_ID_ELEMENT_NAME (GADGET_ID_TEXT_INPUT_FIRST + 2)
422 /* text area identifiers */
423 #define GADGET_ID_TEXT_AREA_FIRST (GADGET_ID_TEXT_INPUT_FIRST + 3)
425 #define GADGET_ID_ENVELOPE_INFO (GADGET_ID_TEXT_AREA_FIRST + 0)
427 /* selectbox identifiers */
428 #define GADGET_ID_SELECTBOX_FIRST (GADGET_ID_TEXT_AREA_FIRST + 1)
430 #define GADGET_ID_CUSTOM_WALK_TO_ACTION (GADGET_ID_SELECTBOX_FIRST + 0)
431 #define GADGET_ID_CUSTOM_CONSISTENCY (GADGET_ID_SELECTBOX_FIRST + 1)
432 #define GADGET_ID_CUSTOM_DEADLINESS (GADGET_ID_SELECTBOX_FIRST + 2)
433 #define GADGET_ID_CUSTOM_MOVE_PATTERN (GADGET_ID_SELECTBOX_FIRST + 3)
434 #define GADGET_ID_CUSTOM_MOVE_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 4)
435 #define GADGET_ID_CUSTOM_MOVE_STEPSIZE (GADGET_ID_SELECTBOX_FIRST + 5)
436 #define GADGET_ID_CUSTOM_SMASH_TARGETS (GADGET_ID_SELECTBOX_FIRST + 6)
437 #define GADGET_ID_CUSTOM_SLIPPERY_TYPE (GADGET_ID_SELECTBOX_FIRST + 7)
438 #define GADGET_ID_CUSTOM_ACCESS_TYPE (GADGET_ID_SELECTBOX_FIRST + 8)
439 #define GADGET_ID_CUSTOM_ACCESS_LAYER (GADGET_ID_SELECTBOX_FIRST + 9)
440 #define GADGET_ID_CHANGE_TIME_UNITS (GADGET_ID_SELECTBOX_FIRST + 10)
441 #define GADGET_ID_CHANGE_DIRECT_ACTION (GADGET_ID_SELECTBOX_FIRST + 11)
442 #define GADGET_ID_CHANGE_OTHER_ACTION (GADGET_ID_SELECTBOX_FIRST + 12)
443 #define GADGET_ID_CHANGE_SIDES (GADGET_ID_SELECTBOX_FIRST + 13)
444 #define GADGET_ID_CHANGE_POWER (GADGET_ID_SELECTBOX_FIRST + 14)
445 #define GADGET_ID_SELECT_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 15)
447 /* textbutton identifiers */
448 #define GADGET_ID_TEXTBUTTON_FIRST (GADGET_ID_SELECTBOX_FIRST + 16)
450 #define GADGET_ID_PROPERTIES_INFO (GADGET_ID_TEXTBUTTON_FIRST + 0)
451 #define GADGET_ID_PROPERTIES_CONFIG (GADGET_ID_TEXTBUTTON_FIRST + 1)
452 #define GADGET_ID_PROPERTIES_ADVANCED (GADGET_ID_TEXTBUTTON_FIRST + 2)
453 #define GADGET_ID_SAVE_AS_TEMPLATE (GADGET_ID_TEXTBUTTON_FIRST + 3)
454 #define GADGET_ID_ADD_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 4)
455 #define GADGET_ID_DEL_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 5)
457 /* graphicbutton identifiers */
458 #define GADGET_ID_GRAPHICBUTTON_FIRST (GADGET_ID_TEXTBUTTON_FIRST + 6)
460 #define GADGET_ID_PREV_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 0)
461 #define GADGET_ID_NEXT_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 1)
463 /* gadgets for scrolling of drawing area */
464 #define GADGET_ID_SCROLLING_FIRST (GADGET_ID_GRAPHICBUTTON_FIRST + 2)
466 #define GADGET_ID_SCROLL_UP (GADGET_ID_SCROLLING_FIRST + 0)
467 #define GADGET_ID_SCROLL_DOWN (GADGET_ID_SCROLLING_FIRST + 1)
468 #define GADGET_ID_SCROLL_LEFT (GADGET_ID_SCROLLING_FIRST + 2)
469 #define GADGET_ID_SCROLL_RIGHT (GADGET_ID_SCROLLING_FIRST + 3)
470 #define GADGET_ID_SCROLL_HORIZONTAL (GADGET_ID_SCROLLING_FIRST + 4)
471 #define GADGET_ID_SCROLL_VERTICAL (GADGET_ID_SCROLLING_FIRST + 5)
473 /* gadgets for scrolling element list */
474 #define GADGET_ID_SCROLLING_LIST_FIRST (GADGET_ID_SCROLLING_FIRST + 6)
476 #define GADGET_ID_SCROLL_LIST_UP (GADGET_ID_SCROLLING_LIST_FIRST + 0)
477 #define GADGET_ID_SCROLL_LIST_DOWN (GADGET_ID_SCROLLING_LIST_FIRST + 1)
478 #define GADGET_ID_SCROLL_LIST_VERTICAL (GADGET_ID_SCROLLING_LIST_FIRST + 2)
480 /* checkbuttons for level/element properties */
481 #define GADGET_ID_CHECKBUTTON_FIRST (GADGET_ID_SCROLLING_LIST_FIRST + 3)
483 #define GADGET_ID_RANDOM_PERCENTAGE (GADGET_ID_CHECKBUTTON_FIRST + 0)
484 #define GADGET_ID_RANDOM_QUANTITY (GADGET_ID_CHECKBUTTON_FIRST + 1)
485 #define GADGET_ID_RANDOM_RESTRICTED (GADGET_ID_CHECKBUTTON_FIRST + 2)
486 #define GADGET_ID_DOUBLE_SPEED (GADGET_ID_CHECKBUTTON_FIRST + 3)
487 #define GADGET_ID_GRAVITY (GADGET_ID_CHECKBUTTON_FIRST + 4)
488 #define GADGET_ID_STICK_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 5)
489 #define GADGET_ID_EM_SLIPPERY_GEMS (GADGET_ID_CHECKBUTTON_FIRST + 6)
490 #define GADGET_ID_CUSTOM_EXPLODE_RESULT (GADGET_ID_CHECKBUTTON_FIRST + 7)
491 #define GADGET_ID_CUSTOM_EXPLODE_FIRE (GADGET_ID_CHECKBUTTON_FIRST + 8)
492 #define GADGET_ID_CUSTOM_EXPLODE_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 9)
493 #define GADGET_ID_CUSTOM_EXPLODE_IMPACT (GADGET_ID_CHECKBUTTON_FIRST + 10)
494 #define GADGET_ID_CUSTOM_WALK_TO_OBJECT (GADGET_ID_CHECKBUTTON_FIRST + 11)
495 #define GADGET_ID_CUSTOM_DEADLY (GADGET_ID_CHECKBUTTON_FIRST + 12)
496 #define GADGET_ID_CUSTOM_CAN_MOVE (GADGET_ID_CHECKBUTTON_FIRST + 13)
497 #define GADGET_ID_CUSTOM_CAN_FALL (GADGET_ID_CHECKBUTTON_FIRST + 14)
498 #define GADGET_ID_CUSTOM_CAN_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 15)
499 #define GADGET_ID_CUSTOM_SLIPPERY (GADGET_ID_CHECKBUTTON_FIRST + 16)
500 #define GADGET_ID_CUSTOM_ACCESSIBLE (GADGET_ID_CHECKBUTTON_FIRST + 17)
501 #define GADGET_ID_CUSTOM_USE_GRAPHIC (GADGET_ID_CHECKBUTTON_FIRST + 18)
502 #define GADGET_ID_CUSTOM_USE_TEMPLATE (GADGET_ID_CHECKBUTTON_FIRST + 19)
503 #define GADGET_ID_CUSTOM_CAN_CHANGE (GADGET_ID_CHECKBUTTON_FIRST + 20)
504 #define GADGET_ID_CHANGE_USE_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 21)
505 #define GADGET_ID_CHANGE_USE_EXPLOSION (GADGET_ID_CHECKBUTTON_FIRST + 22)
506 #define GADGET_ID_CHANGE_ONLY_COMPLETE (GADGET_ID_CHECKBUTTON_FIRST + 23)
507 #define GADGET_ID_CHANGE_USE_RANDOM (GADGET_ID_CHECKBUTTON_FIRST + 24)
508 #define GADGET_ID_CHANGE_DELAY (GADGET_ID_CHECKBUTTON_FIRST + 25)
509 #define GADGET_ID_CHANGE_BY_DIRECT_ACT (GADGET_ID_CHECKBUTTON_FIRST + 26)
510 #define GADGET_ID_CHANGE_BY_OTHER_ACT (GADGET_ID_CHECKBUTTON_FIRST + 27)
512 /* gadgets for buttons in element list */
513 #define GADGET_ID_ELEMENTLIST_FIRST (GADGET_ID_CHECKBUTTON_FIRST + 28)
514 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
515 ED_NUM_ELEMENTLIST_BUTTONS - 1)
517 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
519 /* radio button numbers */
520 #define RADIO_NR_NONE 0
521 #define RADIO_NR_DRAWING_TOOLBOX 1
522 #define RADIO_NR_RANDOM_ELEMENTS 2
524 /* values for counter gadgets */
525 #define ED_COUNTER_ID_SELECT_LEVEL 0
526 #define ED_COUNTER_ID_LEVEL_XSIZE 1
527 #define ED_COUNTER_ID_LEVEL_YSIZE 2
528 #define ED_COUNTER_ID_LEVEL_GEMSLIMIT 3
529 #define ED_COUNTER_ID_LEVEL_TIMELIMIT 4
530 #define ED_COUNTER_ID_LEVEL_TIMESCORE 5
531 #define ED_COUNTER_ID_LEVEL_RANDOM 6
532 #define ED_COUNTER_ID_ELEMENT_SCORE 7
533 #define ED_COUNTER_ID_ELEMENT_CONTENT 8
534 #define ED_COUNTER_ID_ENVELOPE_XSIZE 9
535 #define ED_COUNTER_ID_ENVELOPE_YSIZE 10
536 #define ED_COUNTER_ID_CUSTOM_SCORE 11
537 #define ED_COUNTER_ID_CUSTOM_GEMCOUNT 12
538 #define ED_COUNTER_ID_PUSH_DELAY_FIX 13
539 #define ED_COUNTER_ID_PUSH_DELAY_RND 14
540 #define ED_COUNTER_ID_MOVE_DELAY_FIX 15
541 #define ED_COUNTER_ID_MOVE_DELAY_RND 16
542 #define ED_COUNTER_ID_GROUP_CONTENT 17
543 #define ED_COUNTER_ID_CHANGE_DELAY_FIX 18
544 #define ED_COUNTER_ID_CHANGE_DELAY_RND 19
545 #define ED_COUNTER_ID_CHANGE_CONT_RND 20
547 #define ED_NUM_COUNTERBUTTONS 21
549 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
550 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM
552 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM_SCORE
553 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_MOVE_DELAY_RND
555 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
556 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
558 /* values for scrollbutton gadgets */
559 #define ED_SCROLLBUTTON_ID_AREA_UP 0
560 #define ED_SCROLLBUTTON_ID_AREA_DOWN 1
561 #define ED_SCROLLBUTTON_ID_AREA_LEFT 2
562 #define ED_SCROLLBUTTON_ID_AREA_RIGHT 3
563 #define ED_SCROLLBUTTON_ID_LIST_UP 4
564 #define ED_SCROLLBUTTON_ID_LIST_DOWN 5
566 #define ED_NUM_SCROLLBUTTONS 6
568 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
569 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
571 /* values for scrollbar gadgets */
572 #define ED_SCROLLBAR_ID_AREA_HORIZONTAL 0
573 #define ED_SCROLLBAR_ID_AREA_VERTICAL 1
574 #define ED_SCROLLBAR_ID_LIST_VERTICAL 2
576 #define ED_NUM_SCROLLBARS 3
578 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
579 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
581 /* values for text input gadgets */
582 #define ED_TEXTINPUT_ID_LEVEL_NAME 0
583 #define ED_TEXTINPUT_ID_LEVEL_AUTHOR 1
584 #define ED_TEXTINPUT_ID_ELEMENT_NAME 2
586 #define ED_NUM_TEXTINPUT 3
588 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
589 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
591 /* values for text area gadgets */
592 #define ED_TEXTAREA_ID_ENVELOPE_INFO 0
594 #define ED_NUM_TEXTAREAS 1
596 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
597 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
599 /* values for selectbox gadgets */
600 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE 0
601 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER 1
602 #define ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION 2
603 #define ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN 3
604 #define ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION 4
605 #define ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE 5
606 #define ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS 6
607 #define ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE 7
608 #define ED_SELECTBOX_ID_CUSTOM_DEADLINESS 8
609 #define ED_SELECTBOX_ID_CUSTOM_CONSISTENCY 9
610 #define ED_SELECTBOX_ID_CHANGE_TIME_UNITS 10
611 #define ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION 11
612 #define ED_SELECTBOX_ID_CHANGE_OTHER_ACTION 12
613 #define ED_SELECTBOX_ID_CHANGE_SIDES 13
614 #define ED_SELECTBOX_ID_CHANGE_POWER 14
615 #define ED_SELECTBOX_ID_SELECT_CHANGE_PAGE 15
617 #define ED_NUM_SELECTBOX 16
619 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
620 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM_CONSISTENCY
622 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
623 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
625 /* values for textbutton gadgets */
626 #define ED_TEXTBUTTON_ID_PROPERTIES_INFO 0
627 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG 1
628 #define ED_TEXTBUTTON_ID_PROPERTIES_ADVANCED 2
629 #define ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE 3
630 #define ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE 4
631 #define ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE 5
633 #define ED_NUM_TEXTBUTTONS 6
635 #define ED_TEXTBUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
636 #define ED_TEXTBUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_ADVANCED
638 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE
639 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
641 /* values for graphicbutton gadgets */
642 #define ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE 0
643 #define ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE 1
645 #define ED_NUM_GRAPHICBUTTONS 2
647 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
648 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE
650 /* values for checkbutton gadgets */
651 #define ED_CHECKBUTTON_ID_DOUBLE_SPEED 0
652 #define ED_CHECKBUTTON_ID_GRAVITY 1
653 #define ED_CHECKBUTTON_ID_RANDOM_RESTRICTED 2
654 #define ED_CHECKBUTTON_ID_STICK_ELEMENT 3
655 #define ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS 4
656 #define ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE 5
657 #define ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT 6
658 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE 7
659 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL 8
660 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH 9
661 #define ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY 10
662 #define ED_CHECKBUTTON_ID_CUSTOM_DEADLY 11
663 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_RESULT 12
664 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE 13
665 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH 14
666 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT 15
667 #define ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC 16
668 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE 17
669 #define ED_CHECKBUTTON_ID_CHANGE_DELAY 18
670 #define ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT 19
671 #define ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT 20
672 #define ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION 21
673 #define ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT 22
674 #define ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE 23
675 #define ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM 24
676 #define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE 25
678 #define ED_NUM_CHECKBUTTONS 26
680 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_DOUBLE_SPEED
681 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
683 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE
684 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
686 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
687 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE
689 /* values for radiobutton gadgets */
690 #define ED_RADIOBUTTON_ID_PERCENTAGE 0
691 #define ED_RADIOBUTTON_ID_QUANTITY 1
693 #define ED_NUM_RADIOBUTTONS 2
695 #define ED_RADIOBUTTON_ID_LEVEL_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
696 #define ED_RADIOBUTTON_ID_LEVEL_LAST ED_RADIOBUTTON_ID_QUANTITY
698 /* values for drawing area gadgets */
699 #define ED_DRAWING_ID_DRAWING_LEVEL 0
700 #define ED_DRAWING_ID_ELEMENT_CONTENT_0 1
701 #define ED_DRAWING_ID_ELEMENT_CONTENT_1 2
702 #define ED_DRAWING_ID_ELEMENT_CONTENT_2 3
703 #define ED_DRAWING_ID_ELEMENT_CONTENT_3 4
704 #define ED_DRAWING_ID_ELEMENT_CONTENT_4 5
705 #define ED_DRAWING_ID_ELEMENT_CONTENT_5 6
706 #define ED_DRAWING_ID_ELEMENT_CONTENT_6 7
707 #define ED_DRAWING_ID_ELEMENT_CONTENT_7 8
708 #define ED_DRAWING_ID_AMOEBA_CONTENT 9
709 #define ED_DRAWING_ID_CUSTOM_GRAPHIC 10
710 #define ED_DRAWING_ID_CUSTOM_CONTENT 11
711 #define ED_DRAWING_ID_CUSTOM_MOVE_ENTER 12
712 #define ED_DRAWING_ID_CUSTOM_MOVE_LEAVE 13
713 #define ED_DRAWING_ID_CUSTOM_CHANGE_TARGET 14
714 #define ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT 15
715 #define ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER 16
716 #define ED_DRAWING_ID_GROUP_CONTENT 17
717 #define ED_DRAWING_ID_RANDOM_BACKGROUND 18
719 #define ED_NUM_DRAWING_AREAS 19
723 -----------------------------------------------------------------------------
724 some internally used definitions
725 -----------------------------------------------------------------------------
728 /* values for CopyLevelToUndoBuffer() */
729 #define UNDO_IMMEDIATE 0
730 #define UNDO_ACCUMULATE 1
732 /* values for scrollbars */
733 #define ED_SCROLL_NO 0
734 #define ED_SCROLL_LEFT 1
735 #define ED_SCROLL_RIGHT 2
736 #define ED_SCROLL_UP 4
737 #define ED_SCROLL_DOWN 8
739 /* screens in the level editor */
740 #define ED_MODE_DRAWING 0
741 #define ED_MODE_INFO 1
742 #define ED_MODE_PROPERTIES 2
744 /* sub-screens in the element properties section */
745 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
746 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
747 #define ED_MODE_PROPERTIES_ADVANCED ED_TEXTBUTTON_ID_PROPERTIES_ADVANCED
749 /* how many steps can be cancelled */
750 #define NUM_UNDO_STEPS (10 + 1)
752 /* values for elements with score for certain actions */
754 #define MAX_SCORE 255
756 /* values for elements with count for collecting */
757 #define MIN_COLLECT_COUNT 0
758 #define MAX_COLLECT_COUNT 100
760 /* values for random placement */
761 #define RANDOM_USE_PERCENTAGE 0
762 #define RANDOM_USE_QUANTITY 1
764 /* maximal size of level editor drawing area */
765 #define MAX_ED_FIELDX (2 * SCR_FIELDX)
766 #define MAX_ED_FIELDY (2 * SCR_FIELDY - 1)
770 -----------------------------------------------------------------------------
771 some internally used data structure definitions
772 -----------------------------------------------------------------------------
779 } control_info[ED_NUM_CTRL_BUTTONS] =
781 { 's', "draw single items" },
782 { 'd', "draw connected items" },
783 { 'l', "draw lines" },
784 { 'a', "draw arcs" },
785 { 'r', "draw outline rectangles" },
786 { 'R', "draw filled rectangles" },
787 { '\0', "wrap (rotate) level up" },
788 { 't', "enter text elements" },
789 { 'f', "flood fill" },
790 { '\0', "wrap (rotate) level left" },
791 { '?', "properties of drawing element" },
792 { '\0', "wrap (rotate) level right" },
793 { '\0', "random element placement" },
794 { 'b', "grab brush" },
795 { '\0', "wrap (rotate) level down" },
796 { ',', "pick drawing element" },
798 { 'U', "undo last operation" },
799 { 'I', "level properties" },
800 { 'S', "save level" },
801 { 'C', "clear level" },
802 { 'T', "test level" },
803 { 'E', "exit level editor" },
805 { '\0', "copy settings from other element" },
806 { '\0', "copy settings to other element" },
807 { '\0', "exchange settings with other element" },
810 static int random_placement_value = 10;
811 static int random_placement_method = RANDOM_USE_QUANTITY;
812 static int random_placement_background_element = EL_SAND;
813 static boolean random_placement_background_restricted = FALSE;
814 static boolean stick_element_properties_window = FALSE;
815 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
816 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
817 static struct ElementChangeInfo custom_element_change;
818 static struct ElementGroupInfo group_element_info;
819 static struct ElementInfo custom_element;
824 int min_value, max_value;
825 int gadget_id_down, gadget_id_up;
829 char *text_above, *text_left, *text_right;
830 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
832 /* ---------- level and editor settings ---------------------------------- */
835 DX + 5 - SX, DY + 3 - SY,
837 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
838 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
843 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(2),
844 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
845 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
846 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
848 "playfield size:", NULL, "width",
851 -1, ED_COUNTER_YPOS(2),
852 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
853 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
854 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
859 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(3),
861 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
862 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
864 "number of emeralds to collect:", NULL, NULL
867 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(4),
869 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
870 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
872 "time available to solve level:", NULL, "(0 => no time limit)"
875 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(5),
877 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
878 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
879 &level.score[SC_TIME_BONUS],
880 "score for each 10 seconds left:", NULL, NULL
883 ED_SETTINGS_XPOS(0), ED_COUNTER2_YPOS(8),
885 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
886 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
887 &random_placement_value,
888 "random element placement:", NULL, "in"
891 /* ---------- element settings: configure (various elements) ------------- */
894 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(0),
895 MIN_SCORE, MAX_SCORE,
896 GADGET_ID_ELEMENT_SCORE_DOWN, GADGET_ID_ELEMENT_SCORE_UP,
897 GADGET_ID_ELEMENT_SCORE_TEXT, GADGET_ID_NONE,
898 NULL, /* will be set when used */
902 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(6),
903 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
904 GADGET_ID_ELEMENT_CONTENT_DOWN, GADGET_ID_ELEMENT_CONTENT_UP,
905 GADGET_ID_ELEMENT_CONTENT_TEXT, GADGET_ID_NONE,
906 &level.num_yamyam_contents,
907 NULL, NULL, "number of content areas"
910 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(0),
911 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
912 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
913 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
918 -1, ED_SETTINGS_YPOS(0),
919 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
920 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
921 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
926 /* ---------- element settings: configure (custom elements) -------------- */
929 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(3),
930 MIN_SCORE, MAX_SCORE,
931 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
932 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
933 &custom_element.collect_score,
937 -1, ED_SETTINGS_YPOS(3),
938 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
939 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
940 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
941 &custom_element.collect_count,
945 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(4),
947 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
948 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
949 &custom_element.push_delay_fixed,
950 NULL, "push delay", NULL
953 -1, ED_SETTINGS_YPOS(4),
955 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
956 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
957 &custom_element.push_delay_random,
958 NULL, "+random", NULL
961 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(9),
963 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
964 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
965 &custom_element.move_delay_fixed,
966 NULL, "move delay", NULL
969 -1, ED_SETTINGS_YPOS(9),
971 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
972 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
973 &custom_element.move_delay_random,
974 NULL, "+random", NULL
977 /* ---------- element settings: configure (group elements) --------------- */
980 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(6),
981 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
982 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
983 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
984 &group_element_info.num_elements,
985 NULL, NULL, "number of elements in group"
988 /* ---------- element settings: advanced (custom elements) --------------- */
991 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(3),
993 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
994 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
995 &custom_element_change.delay_fixed,
999 -1, ED_SETTINGS_YPOS(3),
1001 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1002 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1003 &custom_element_change.delay_random,
1004 NULL, "+random", NULL
1007 ED_SETTINGS_XPOS(3), ED_SETTINGS_YPOS(12),
1009 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1010 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1011 &custom_element_change.random,
1012 NULL, "use random replace:", "%"
1022 char *text_above, *infotext;
1023 } textinput_info[ED_NUM_TEXTINPUT] =
1026 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(0),
1027 GADGET_ID_LEVEL_NAME,
1033 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(1),
1034 GADGET_ID_LEVEL_AUTHOR,
1035 MAX_LEVEL_AUTHOR_LEN,
1040 5 * MINI_TILEX, 5 * MINI_TILEY - ED_BORDER_SIZE,
1041 GADGET_ID_ELEMENT_NAME,
1042 MAX_ELEMENT_NAME_LEN - 2, /* currently 2 chars less editable */
1043 custom_element.description,
1044 NULL, "Element name"
1054 char *text_above, *infotext;
1055 } textarea_info[ED_NUM_TEXTAREAS] =
1058 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(2),
1059 GADGET_ID_ENVELOPE_INFO,
1060 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1062 "Envelope Info:", "Envelope Info"
1066 static struct ValueTextInfo options_access_type[] =
1068 { EP_WALKABLE, "walk" },
1069 { EP_PASSABLE, "pass" },
1073 static struct ValueTextInfo options_access_layer[] =
1075 { EP_ACCESSIBLE_OVER, "over" },
1076 { EP_ACCESSIBLE_INSIDE, "inside" },
1077 { EP_ACCESSIBLE_UNDER, "under" },
1081 static struct ValueTextInfo options_walk_to_action[] =
1083 { EP_DIGGABLE, "diggable" },
1084 { EP_COLLECTIBLE_ONLY, "collectible" },
1085 { EP_DROPPABLE, "collectible & droppable" },
1086 { EP_PUSHABLE, "pushable" },
1090 static struct ValueTextInfo options_move_pattern[] =
1092 { MV_LEFT, "left" },
1093 { MV_RIGHT, "right" },
1095 { MV_DOWN, "down" },
1096 { MV_HORIZONTAL, "horizontal" },
1097 { MV_VERTICAL, "vertical" },
1098 { MV_ALL_DIRECTIONS, "all directions" },
1099 { MV_TOWARDS_PLAYER, "towards player" },
1100 { MV_AWAY_FROM_PLAYER, "away from player" },
1101 { MV_ALONG_LEFT_SIDE, "along left side" },
1102 { MV_ALONG_RIGHT_SIDE, "along right side" },
1103 { MV_TURNING_LEFT, "turning left" },
1104 { MV_TURNING_RIGHT, "turning right" },
1105 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1106 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1107 { MV_TURNING_RANDOM, "turning random" },
1108 { MV_WHEN_PUSHED, "when pushed" },
1109 { MV_WHEN_DROPPED, "when dropped" },
1111 { MV_MAZE_RUNNER, "maze runner style" },
1112 { MV_MAZE_HUNTER, "maze hunter style" },
1117 static struct ValueTextInfo options_move_direction[] =
1119 { MV_NO_MOVING, "automatic" },
1120 { MV_LEFT, "left" },
1121 { MV_RIGHT, "right" },
1123 { MV_DOWN, "down" },
1127 static struct ValueTextInfo options_move_stepsize[] =
1133 { 16, "very fast" },
1137 static struct ValueTextInfo options_smash_targets[] =
1139 { EP_CAN_SMASH_PLAYER, "player" },
1141 { EP_CAN_SMASH_ENEMIES, "enemies" },
1143 { EP_CAN_SMASH_EVERYTHING, "everything" },
1147 static struct ValueTextInfo options_slippery_type[] =
1149 { SLIPPERY_ANY_RANDOM, "random" },
1150 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
1151 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
1152 { SLIPPERY_ONLY_LEFT, "only left" },
1153 { SLIPPERY_ONLY_RIGHT, "only right" },
1157 static struct ValueTextInfo options_deadliness[] =
1159 { EP_DONT_RUN_INTO, "running into" },
1160 { EP_DONT_COLLIDE_WITH, "colliding with" },
1161 { EP_DONT_TOUCH, "touching" },
1165 static struct ValueTextInfo options_consistency[] =
1167 { EP_CAN_EXPLODE_3X3, "can explode 3x3" },
1168 { EP_CAN_EXPLODE_DYNA, "can explode 3+3" },
1169 { EP_CAN_EXPLODE_1X1, "can explode 1x1" },
1170 { EP_INDESTRUCTIBLE, "indestructible" },
1174 static struct ValueTextInfo options_time_units[] =
1177 { FRAMES_PER_SECOND, "seconds" },
1181 static struct ValueTextInfo options_change_direct_action[] =
1183 { CE_TOUCHED_BY_PLAYER, "touched by player ..." },
1184 { CE_PRESSED_BY_PLAYER, "pressed by player ..." },
1185 { CE_PUSHED_BY_PLAYER, "pushed by player ..." },
1186 { CE_ENTERED_BY_PLAYER, "entered by player ..." },
1187 { CE_LEFT_BY_PLAYER, "left by player ..." },
1188 { CE_DROPPED_BY_PLAYER, "dropped by player" },
1189 { CE_SWITCHED, "switched ..." },
1191 { CE_HITTING_SOMETHING, "hitting something ..." },
1192 { CE_HIT_BY_SOMETHING, "hit by something ..." },
1194 { CE_HITTING_SOMETHING, "collision ..." },
1196 { CE_IMPACT, "impact (on something)" },
1197 { CE_SMASHED, "smashed (from above)" },
1201 static struct ValueTextInfo options_change_other_action[] =
1203 { CE_OTHER_GETS_TOUCHED, "player touches ..." },
1204 { CE_OTHER_GETS_PRESSED, "player presses ..." },
1205 { CE_OTHER_GETS_PUSHED, "player pushes ..." },
1206 { CE_OTHER_GETS_ENTERED, "player enters ..." },
1207 { CE_OTHER_GETS_LEFT, "player leaves ..." },
1208 { CE_OTHER_GETS_DIGGED, "player digs" },
1209 { CE_OTHER_GETS_COLLECTED, "player collects" },
1210 { CE_OTHER_GETS_DROPPED, "player drops" },
1211 { CE_OTHER_IS_TOUCHING, "touching ..." },
1213 { CE_OTHER_IS_HITTING, "hitting ..." },
1214 { CE_OTHER_GETS_HIT, "hit by ..." },
1216 { CE_OTHER_IS_SWITCHING, "switch of ..." },
1217 { CE_OTHER_IS_CHANGING, "change of" },
1218 { CE_OTHER_IS_EXPLODING, "explosion of" },
1222 static struct ValueTextInfo options_change_sides[] =
1224 { CH_SIDE_LEFT, "left side" },
1225 { CH_SIDE_RIGHT, "right side" },
1226 { CH_SIDE_TOP, "top side" },
1227 { CH_SIDE_BOTTOM, "bottom side" },
1228 { CH_SIDE_LEFT_RIGHT, "left/right side" },
1229 { CH_SIDE_TOP_BOTTOM, "top/bottom side" },
1230 { CH_SIDE_ANY, "any side" },
1234 static struct ValueTextInfo options_change_power[] =
1236 { CP_NON_DESTRUCTIVE, "empty" },
1237 { CP_HALF_DESTRUCTIVE, "diggable" },
1238 { CP_FULL_DESTRUCTIVE, "destructible" },
1242 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
1243 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
1252 int gadget_id_align;
1253 int size; /* char size of selectbox or '-1' (dynamically determined) */
1254 struct ValueTextInfo *options;
1256 char *text_left, *text_right, *infotext;
1257 } selectbox_info[ED_NUM_SELECTBOX] =
1259 /* ---------- element settings: configure (custom elements) ------------- */
1262 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(1),
1263 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
1265 options_access_type,
1266 &custom_element.access_type,
1267 "player can", NULL, "type of access to this field"
1270 -1, ED_SETTINGS_YPOS(1),
1271 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
1273 options_access_layer,
1274 &custom_element.access_layer,
1275 NULL, NULL, "layer of access for this field"
1278 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(2),
1279 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
1281 options_walk_to_action,
1282 &custom_element.walk_to_action,
1283 NULL, NULL, "diggable/collectible/pushable"
1286 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(5),
1287 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
1289 options_move_pattern,
1290 &custom_element.move_pattern,
1291 "can move", NULL, "element move direction"
1294 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(6),
1295 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
1297 options_move_direction,
1298 &custom_element.move_direction_initial,
1299 "starts moving", NULL, "initial element move direction"
1302 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(8),
1303 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
1305 options_move_stepsize,
1306 &custom_element.move_stepsize,
1307 "move/fall speed", NULL, "speed of element movement"
1310 -1, ED_SETTINGS_YPOS(10),
1311 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
1313 options_smash_targets,
1314 &custom_element.smash_targets,
1315 "can smash", NULL, "elements that can be smashed"
1318 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(11),
1319 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
1321 options_slippery_type,
1322 &custom_element.slippery_type,
1323 "slippery", NULL, "where other elements fall down"
1326 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(12),
1327 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
1330 &custom_element.deadliness,
1331 "deadly when", NULL, "deadliness of element"
1334 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(13),
1335 GADGET_ID_CUSTOM_CONSISTENCY, GADGET_ID_NONE,
1337 options_consistency,
1338 &custom_element.consistency,
1339 NULL, NULL, "consistency/destructibility"
1342 /* ---------- element settings: advanced (custom elements) --------------- */
1345 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(4),
1346 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
1349 &custom_element_change.delay_frames,
1350 "delay time given in", NULL, "delay time units for change"
1353 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(5),
1354 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
1356 options_change_direct_action,
1357 &custom_element_change.direct_action,
1358 NULL, NULL, "type of direct action"
1361 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(6),
1362 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
1364 options_change_other_action,
1365 &custom_element_change.other_action,
1366 NULL, "element:", "type of other element action"
1369 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(7),
1370 GADGET_ID_CHANGE_SIDES, GADGET_ID_NONE,
1372 options_change_sides,
1373 &custom_element_change.sides,
1374 "... at", NULL, "element side that causes change"
1377 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(10),
1378 GADGET_ID_CHANGE_POWER, GADGET_ID_NONE,
1380 options_change_power,
1381 &custom_element_change.power,
1382 "replace when", NULL, "which elements can be replaced"
1385 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(14),
1386 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
1388 options_change_page,
1389 &custom_element.current_change_page,
1390 NULL, NULL, "element config page"
1398 int gadget_id_align;
1401 char *text_left, *text_right, *infotext;
1402 } textbutton_info[ED_NUM_TEXTBUTTONS] =
1405 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(1),
1406 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
1408 NULL, NULL, "Show information about element"
1411 ED_SETTINGS_XPOS(0) + 166, ED_COUNTER_YPOS(1),
1412 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_NONE,
1414 NULL, NULL, "Configure element properties"
1417 ED_SETTINGS_XPOS(0) + 332, ED_COUNTER_YPOS(1),
1418 GADGET_ID_PROPERTIES_ADVANCED, GADGET_ID_NONE,
1420 NULL, NULL, "Advanced element configuration"
1423 -1, ED_SETTINGS_YPOS(13),
1424 GADGET_ID_SAVE_AS_TEMPLATE, GADGET_ID_CUSTOM_USE_TEMPLATE,
1425 -1, "Save as template",
1426 " ", NULL, "Save current settings as new template"
1429 -1, ED_SETTINGS_YPOS(14),
1430 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
1432 " ", NULL, "Add new config page"
1435 -1, ED_SETTINGS_YPOS(14),
1436 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
1438 NULL, NULL, "Delete current config page"
1448 int gadget_id_align;
1449 char *text_left, *text_right, *infotext;
1450 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
1453 ED_BUTTON_MINUS_XPOS, ED_BUTTON_COUNT_YPOS,
1454 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(14),
1455 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
1456 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
1457 NULL, NULL, "select previous config page"
1460 ED_BUTTON_PLUS_XPOS, ED_BUTTON_COUNT_YPOS,
1461 -1, ED_SETTINGS_YPOS(14),
1462 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
1463 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
1464 NULL, "config page", "select next config page"
1474 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
1477 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 0 * ED_SCROLLBUTTON_YSIZE,
1478 ED_SCROLL_UP_XPOS, ED_SCROLL_UP_YPOS,
1479 GADGET_ID_SCROLL_UP,
1480 "scroll level editing area up"
1483 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 1 * ED_SCROLLBUTTON_YSIZE,
1484 ED_SCROLL_DOWN_XPOS, ED_SCROLL_DOWN_YPOS,
1485 GADGET_ID_SCROLL_DOWN,
1486 "scroll level editing area down"
1489 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 2 * ED_SCROLLBUTTON_YSIZE,
1490 ED_SCROLL_LEFT_XPOS, ED_SCROLL_LEFT_YPOS,
1491 GADGET_ID_SCROLL_LEFT,
1492 "scroll level editing area left"
1495 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 3 * ED_SCROLLBUTTON_YSIZE,
1496 ED_SCROLL_RIGHT_XPOS, ED_SCROLL_RIGHT_YPOS,
1497 GADGET_ID_SCROLL_RIGHT,
1498 "scroll level editing area right"
1501 ED_SCROLLBUTTON2_XPOS, ED_SCROLLBUTTON2_YPOS + 0 * ED_SCROLLBUTTON2_YSIZE,
1502 ED_SCROLL2_UP_XPOS, ED_SCROLL2_UP_YPOS,
1503 GADGET_ID_SCROLL_LIST_UP,
1504 "scroll element list up ('Page Up')"
1507 ED_SCROLLBUTTON2_XPOS, ED_SCROLLBUTTON2_YPOS + 1 * ED_SCROLLBUTTON2_YSIZE,
1508 ED_SCROLL2_DOWN_XPOS, ED_SCROLL2_DOWN_YPOS,
1509 GADGET_ID_SCROLL_LIST_DOWN,
1510 "scroll element list down ('Page Down')"
1522 } scrollbar_info[ED_NUM_SCROLLBARS] =
1525 ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
1526 SX + ED_SCROLL_HORIZONTAL_XPOS, SY + ED_SCROLL_HORIZONTAL_YPOS,
1527 ED_SCROLL_HORIZONTAL_XSIZE, ED_SCROLL_HORIZONTAL_YSIZE,
1528 GD_TYPE_SCROLLBAR_HORIZONTAL,
1529 GADGET_ID_SCROLL_HORIZONTAL,
1530 "scroll level editing area horizontally"
1533 ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
1534 SX + ED_SCROLL_VERTICAL_XPOS, SY + ED_SCROLL_VERTICAL_YPOS,
1535 ED_SCROLL_VERTICAL_XSIZE, ED_SCROLL_VERTICAL_YSIZE,
1536 GD_TYPE_SCROLLBAR_VERTICAL,
1537 GADGET_ID_SCROLL_VERTICAL,
1538 "scroll level editing area vertically"
1541 ED_SCROLLBAR2_XPOS, ED_SCROLLBAR2_YPOS,
1542 DX + ED_SCROLL2_VERTICAL_XPOS, DY + ED_SCROLL2_VERTICAL_YPOS,
1543 ED_SCROLL2_VERTICAL_XSIZE, ED_SCROLL2_VERTICAL_YSIZE,
1544 GD_TYPE_SCROLLBAR_VERTICAL,
1545 GADGET_ID_SCROLL_LIST_VERTICAL,
1546 "scroll element list vertically"
1554 int gadget_id_align;
1555 int radio_button_nr;
1558 char *text_left, *text_right, *infotext;
1559 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
1562 -1, ED_COUNTER2_YPOS(8),
1563 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
1564 RADIO_NR_RANDOM_ELEMENTS,
1565 &random_placement_method, RANDOM_USE_PERCENTAGE,
1566 " ", "percentage", "use percentage for random elements"
1569 -1, ED_COUNTER2_YPOS(8),
1570 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
1571 RADIO_NR_RANDOM_ELEMENTS,
1572 &random_placement_method, RANDOM_USE_QUANTITY,
1573 " ", "quantity", "use quantity for random elements"
1581 int gadget_id_align;
1583 char *text_left, *text_right, *infotext;
1584 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
1586 /* ---------- level and editor settings ---------------------------------- */
1589 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(6) - MINI_TILEY,
1590 GADGET_ID_DOUBLE_SPEED, GADGET_ID_NONE,
1591 &level.double_speed,
1592 NULL, "double speed movement", "set movement speed of player"
1595 -1, ED_COUNTER_YPOS(6) - MINI_TILEY,
1596 GADGET_ID_GRAVITY, GADGET_ID_DOUBLE_SPEED,
1597 &level.initial_gravity,
1598 " ", "gravity", "set level gravity"
1601 ED_SETTINGS_XPOS(0), ED_COUNTER2_YPOS(9) - MINI_TILEY,
1602 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
1603 &random_placement_background_restricted,
1605 "restrict random placement to:", "set random placement restriction"
1608 /* ---------- element settings: configure (various elements) ------------- */
1611 ED_SETTINGS_XPOS(0), 0, /* set at runtime */
1612 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
1613 &stick_element_properties_window,
1615 "stick this screen to edit content","stick this screen to edit content"
1618 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(4),
1619 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
1620 &level.em_slippery_gems,
1622 "slip down from certain flat walls","use EM style slipping behaviour"
1625 /* ---------- element settings: configure (custom elements) ------------- */
1628 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1),
1629 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
1630 &custom_element_properties[EP_ACCESSIBLE],
1631 NULL, NULL, "player can walk to or pass this field"
1634 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(2),
1635 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
1636 &custom_element_properties[EP_WALK_TO_OBJECT],
1637 NULL, NULL, "player can dig/collect/push element"
1640 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(5),
1641 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
1642 &custom_element_properties[EP_CAN_MOVE],
1643 NULL, NULL, "element can move in some direction"
1646 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(10),
1647 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
1648 &custom_element_properties[EP_CAN_FALL],
1649 NULL, "can fall", "element can fall down"
1652 -1, ED_SETTINGS_YPOS(10),
1653 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
1654 &custom_element_properties[EP_CAN_SMASH],
1655 " ", NULL, "element can smash other elements"
1658 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(11),
1659 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
1660 &custom_element_properties[EP_SLIPPERY],
1661 NULL, NULL, "other elements can fall down from it"
1664 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(12),
1665 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
1666 &custom_element_properties[EP_DEADLY],
1667 NULL, NULL, "element can kill the player"
1670 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(13),
1671 GADGET_ID_CUSTOM_EXPLODE_RESULT, GADGET_ID_NONE,
1672 &custom_element_properties[EP_EXPLODE_RESULT],
1673 NULL, NULL, "set consistency/destructibility"
1676 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(14),
1677 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
1678 &custom_element.can_explode_by_fire,
1679 NULL, "by fire", "element can explode by fire/explosion"
1682 -1, ED_SETTINGS_YPOS(14),
1683 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
1684 &custom_element.can_explode_smashed,
1685 " ", "smashed", "element can explode when smashed"
1688 -1, ED_SETTINGS_YPOS(14),
1689 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
1690 &custom_element.can_explode_impact,
1691 " ", "impact", "element can explode on impact"
1694 /* ---------- element settings: advanced (custom elements) --------------- */
1697 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1),
1698 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
1699 &custom_element.use_gfx_element,
1700 NULL, "use graphic of element:", "use graphic for custom element"
1703 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(2),
1704 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
1705 &custom_element_change.can_change,
1706 NULL, "element changes to:", "element can change to other element"
1709 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(3),
1710 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
1711 &custom_element_change_events[CE_DELAY],
1712 NULL, NULL, "element changes after delay"
1715 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(5),
1716 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
1717 &custom_element_change_events[CE_BY_DIRECT_ACTION],
1718 NULL, NULL, "element changes by direct action"
1721 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(6),
1722 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
1723 &custom_element_change_events[CE_BY_OTHER_ACTION],
1724 NULL, NULL, "element changes by other element"
1727 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(8),
1728 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
1729 &custom_element_change.explode,
1730 NULL, "explode instead of change", "element explodes instead of change"
1733 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(9),
1734 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
1735 &custom_element_change.use_content,
1736 NULL, "use extended change target:","element changes to more elements"
1739 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(11),
1740 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
1741 &custom_element_change.only_complete,
1742 NULL, "replace all or nothing", "only replace when all can be changed"
1745 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(12),
1746 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
1747 &custom_element_change.use_random_change,
1748 NULL, NULL, "use percentage for random replace"
1751 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(13),
1752 GADGET_ID_CUSTOM_USE_TEMPLATE, GADGET_ID_NONE,
1753 &level.use_custom_template,
1754 NULL, "use template", "use template for custom properties"
1761 int area_xsize, area_ysize;
1763 int gadget_id_align;
1764 char *text_left, *text_right, *text_below;
1765 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
1767 /* ---------- level playfield content ------------------------------------ */
1771 MAX_ED_FIELDX, MAX_ED_FIELDY,
1772 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
1776 /* ---------- yam yam content -------------------------------------------- */
1779 ED_AREA_YAMYAM_CONTENT_XPOS(0), ED_AREA_YAMYAM_CONTENT_YPOS(0),
1781 GADGET_ID_ELEMENT_CONTENT_0, GADGET_ID_NONE,
1785 ED_AREA_YAMYAM_CONTENT_XPOS(1), ED_AREA_YAMYAM_CONTENT_YPOS(1),
1787 GADGET_ID_ELEMENT_CONTENT_1, GADGET_ID_NONE,
1791 ED_AREA_YAMYAM_CONTENT_XPOS(2), ED_AREA_YAMYAM_CONTENT_YPOS(2),
1793 GADGET_ID_ELEMENT_CONTENT_2, GADGET_ID_NONE,
1797 ED_AREA_YAMYAM_CONTENT_XPOS(3), ED_AREA_YAMYAM_CONTENT_YPOS(3),
1799 GADGET_ID_ELEMENT_CONTENT_3, GADGET_ID_NONE,
1803 ED_AREA_YAMYAM_CONTENT_XPOS(4), ED_AREA_YAMYAM_CONTENT_YPOS(4),
1805 GADGET_ID_ELEMENT_CONTENT_4, GADGET_ID_NONE,
1809 ED_AREA_YAMYAM_CONTENT_XPOS(5), ED_AREA_YAMYAM_CONTENT_YPOS(5),
1811 GADGET_ID_ELEMENT_CONTENT_5, GADGET_ID_NONE,
1815 ED_AREA_YAMYAM_CONTENT_XPOS(6), ED_AREA_YAMYAM_CONTENT_YPOS(6),
1817 GADGET_ID_ELEMENT_CONTENT_6, GADGET_ID_NONE,
1821 ED_AREA_YAMYAM_CONTENT_XPOS(7), ED_AREA_YAMYAM_CONTENT_YPOS(7),
1823 GADGET_ID_ELEMENT_CONTENT_7, GADGET_ID_NONE,
1827 /* ---------- amoeba content --------------------------------------------- */
1830 ED_AREA_ELEM_CONTENT_XPOS, ED_AREA_ELEM_CONTENT_YPOS,
1832 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
1833 NULL, "content of amoeba", NULL
1836 /* ---------- custom graphic --------------------------------------------- */
1839 -1, ED_AREA_ELEM_CONTENT3_YPOS,
1841 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
1845 /* ---------- custom content (when exploding) ---------------------------- */
1848 ED_AREA_ELEM_CONTENT4_XPOS, ED_AREA_ELEM_CONTENT4_YPOS,
1850 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, /* align three rows */
1851 "content:", NULL, NULL
1854 /* ---------- custom enter and leave element (when moving) --------------- */
1857 ED_SETTINGS_XPOS(1), ED_AREA_ELEM_CONTENT4a_YPOS,
1859 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
1860 "can dig:", " ", NULL
1864 -1, ED_AREA_ELEM_CONTENT4b_YPOS,
1866 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_ENTER,
1867 "can leave behind:", NULL, NULL
1870 /* ---------- custom change target --------------------------------------- */
1873 -1, ED_AREA_ELEM_CONTENT2_YPOS,
1875 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
1876 NULL, "after/when:", NULL
1879 /* ---------- custom change content (extended change target) ------------- */
1882 ED_AREA_ELEM_CONTENT6_XPOS, ED_AREA_ELEM_CONTENT6_YPOS,
1884 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, /* align three rows */
1888 /* ---------- custom change trigger (element causing change) ------------- */
1891 -1, ED_AREA_ELEM_CONTENT5_YPOS,
1893 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
1897 /* ---------- group element content -------------------------------------- */
1900 ED_AREA_GROUP_CONTENT_XPOS, ED_AREA_GROUP_CONTENT_YPOS,
1901 MAX_ELEMENTS_IN_GROUP, 1,
1902 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
1903 "content:", NULL, NULL
1906 /* ---------- random background (for random painting) -------------------- */
1909 -1, ED_AREA_RANDOM_BACKGROUND_YPOS,
1911 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
1918 -----------------------------------------------------------------------------
1919 some internally used variables
1920 -----------------------------------------------------------------------------
1923 /* actual size of level editor drawing area */
1924 static int ed_fieldx = MAX_ED_FIELDX - 1, ed_fieldy = MAX_ED_FIELDY - 1;
1926 /* actual position of level editor drawing area in level playfield */
1927 static int level_xpos = -1, level_ypos = -1;
1929 #define IN_ED_FIELD(x,y) ((x)>=0 && (x)<ed_fieldx && (y)>=0 &&(y)<ed_fieldy)
1931 /* drawing elements on the three mouse buttons */
1932 static int new_element1 = EL_WALL;
1933 static int new_element2 = EL_EMPTY;
1934 static int new_element3 = EL_SAND;
1936 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
1937 (button) == 2 ? new_element2 : \
1938 (button) == 3 ? new_element3 : EL_EMPTY)
1939 #define BUTTON_STEPSIZE(button) ((button) == 1 ? 1 : (button) == 2 ? 5 : 10)
1941 /* forward declaration for internal use */
1942 static void ModifyEditorCounter(int, int);
1943 static void ModifyEditorCounterLimits(int, int, int);
1944 static void ModifyEditorSelectbox(int, int);
1945 static void ModifyEditorDrawingArea(int, int, int);
1946 static void ModifyEditorElementList();
1947 static void RedrawDrawingElements();
1948 static void DrawDrawingWindow();
1949 static void DrawLevelInfoWindow();
1950 static void DrawPropertiesWindow();
1951 static void UpdateCustomElementGraphicGadgets();
1952 static boolean checkPropertiesConfig();
1953 static void CopyLevelToUndoBuffer(int);
1954 static void HandleDrawingAreas(struct GadgetInfo *);
1955 static void HandleCounterButtons(struct GadgetInfo *);
1956 static void HandleTextInputGadgets(struct GadgetInfo *);
1957 static void HandleTextAreaGadgets(struct GadgetInfo *);
1958 static void HandleSelectboxGadgets(struct GadgetInfo *);
1959 static void HandleTextbuttonGadgets(struct GadgetInfo *);
1960 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
1961 static void HandleRadiobuttons(struct GadgetInfo *);
1962 static void HandleCheckbuttons(struct GadgetInfo *);
1963 static void HandleControlButtons(struct GadgetInfo *);
1964 static void HandleDrawingAreaInfo(struct GadgetInfo *);
1966 static struct GadgetInfo *level_editor_gadget[NUM_EDITOR_GADGETS];
1967 static int right_gadget_border[NUM_EDITOR_GADGETS];
1969 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
1970 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
1971 static boolean draw_with_brush = FALSE;
1972 static int properties_element = 0;
1974 static short FieldBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
1975 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
1976 static int undo_buffer_position = 0;
1977 static int undo_buffer_steps = 0;
1979 static int edit_mode;
1980 static int edit_mode_properties;
1982 static int element_shift = 0;
1984 static int editor_hl_boulderdash[] =
2002 static int editor_el_boulderdash[] =
2019 EL_BD_BUTTERFLY_LEFT,
2021 EL_BD_BUTTERFLY_RIGHT,
2022 EL_BD_FIREFLY_RIGHT,
2025 EL_BD_BUTTERFLY_DOWN,
2029 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
2030 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
2031 static int num_editor_hl_boulderdash = SIZEOF_ARRAY_INT(editor_hl_boulderdash);
2032 static int num_editor_el_boulderdash = SIZEOF_ARRAY_INT(editor_el_boulderdash);
2034 static int editor_hl_emerald_mine[] =
2052 static int editor_el_emerald_mine[] =
2099 EL_ACID_POOL_TOPLEFT,
2101 EL_ACID_POOL_TOPRIGHT,
2104 EL_ACID_POOL_BOTTOMLEFT,
2105 EL_ACID_POOL_BOTTOM,
2106 EL_ACID_POOL_BOTTOMRIGHT,
2136 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
2137 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
2138 static int num_editor_hl_emerald_mine=SIZEOF_ARRAY_INT(editor_hl_emerald_mine);
2139 static int num_editor_el_emerald_mine=SIZEOF_ARRAY_INT(editor_el_emerald_mine);
2141 static int editor_hl_more[] =
2149 static int editor_el_more[] =
2177 EL_WALL_EMERALD_YELLOW,
2178 EL_WALL_EMERALD_RED,
2179 EL_WALL_EMERALD_PURPLE,
2196 EL_DYNABOMB_INCREASE_NUMBER,
2197 EL_DYNABOMB_INCREASE_SIZE,
2198 EL_DYNABOMB_INCREASE_POWER,
2219 EL_BALLOON_SWITCH_ANY,
2221 EL_BALLOON_SWITCH_LEFT,
2222 EL_BALLOON_SWITCH_RIGHT,
2223 EL_BALLOON_SWITCH_UP,
2224 EL_BALLOON_SWITCH_DOWN,
2227 EL_EXPANDABLE_WALL_HORIZONTAL,
2228 EL_EXPANDABLE_WALL_VERTICAL,
2229 EL_EXPANDABLE_WALL_ANY,
2231 EL_INVISIBLE_STEELWALL,
2246 static int *editor_hl_more_ptr = editor_hl_more;
2247 static int *editor_el_more_ptr = editor_el_more;
2248 static int num_editor_hl_more = SIZEOF_ARRAY_INT(editor_hl_more);
2249 static int num_editor_el_more = SIZEOF_ARRAY_INT(editor_el_more);
2251 static int editor_hl_sokoban[] =
2264 static int editor_el_sokoban[] =
2267 EL_SOKOBAN_FIELD_EMPTY,
2268 EL_SOKOBAN_FIELD_FULL,
2271 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
2272 static int *editor_el_sokoban_ptr = editor_el_sokoban;
2273 static int num_editor_hl_sokoban = SIZEOF_ARRAY_INT(editor_hl_sokoban);
2274 static int num_editor_el_sokoban = SIZEOF_ARRAY_INT(editor_el_sokoban);
2276 static int editor_hl_supaplex[] =
2289 static int editor_el_supaplex[] =
2302 EL_SP_HARDWARE_GRAY,
2311 EL_SP_GRAVITY_PORT_RIGHT,
2312 EL_SP_GRAVITY_PORT_DOWN,
2313 EL_SP_GRAVITY_PORT_LEFT,
2315 EL_SP_GRAVITY_PORT_UP,
2321 EL_SP_PORT_VERTICAL,
2322 EL_SP_PORT_HORIZONTAL,
2330 EL_SP_HARDWARE_BASE_1,
2331 EL_SP_HARDWARE_GREEN,
2332 EL_SP_HARDWARE_BLUE,
2335 EL_SP_HARDWARE_YELLOW,
2336 EL_SP_HARDWARE_BASE_2,
2337 EL_SP_HARDWARE_BASE_3,
2338 EL_SP_HARDWARE_BASE_4,
2340 EL_SP_HARDWARE_BASE_5,
2341 EL_SP_HARDWARE_BASE_6,
2345 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
2346 static int *editor_el_supaplex_ptr = editor_el_supaplex;
2347 static int num_editor_hl_supaplex = SIZEOF_ARRAY_INT(editor_hl_supaplex);
2348 static int num_editor_el_supaplex = SIZEOF_ARRAY_INT(editor_el_supaplex);
2350 static int editor_hl_diamond_caves[] =
2373 static int editor_el_diamond_caves[] =
2380 EL_CONVEYOR_BELT_1_LEFT,
2381 EL_CONVEYOR_BELT_1_MIDDLE,
2382 EL_CONVEYOR_BELT_1_RIGHT,
2383 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
2385 EL_CONVEYOR_BELT_2_LEFT,
2386 EL_CONVEYOR_BELT_2_MIDDLE,
2387 EL_CONVEYOR_BELT_2_RIGHT,
2388 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
2390 EL_CONVEYOR_BELT_3_LEFT,
2391 EL_CONVEYOR_BELT_3_MIDDLE,
2392 EL_CONVEYOR_BELT_3_RIGHT,
2393 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
2395 EL_CONVEYOR_BELT_4_LEFT,
2396 EL_CONVEYOR_BELT_4_MIDDLE,
2397 EL_CONVEYOR_BELT_4_RIGHT,
2398 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
2400 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
2401 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
2402 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
2403 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
2405 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
2406 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
2407 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
2408 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
2411 EL_SWITCHGATE_CLOSED,
2412 EL_SWITCHGATE_SWITCH_UP,
2427 EL_STEELWALL_SLIPPERY,
2430 EL_SIGN_EXCLAMATION,
2433 EL_LIGHT_SWITCH_ACTIVE,
2440 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
2441 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
2442 static int num_editor_hl_diamond_caves = SIZEOF_ARRAY_INT(editor_hl_diamond_caves);
2443 static int num_editor_el_diamond_caves = SIZEOF_ARRAY_INT(editor_el_diamond_caves);
2445 static int editor_hl_dx_boulderdash[] =
2468 static int editor_el_dx_boulderdash[] =
2472 EL_TUBE_HORIZONTAL_DOWN,
2476 EL_TUBE_VERTICAL_RIGHT,
2478 EL_TUBE_VERTICAL_LEFT,
2482 EL_TUBE_HORIZONTAL_UP,
2490 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
2491 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
2492 static int num_editor_hl_dx_boulderdash = SIZEOF_ARRAY_INT(editor_hl_dx_boulderdash);
2493 static int num_editor_el_dx_boulderdash = SIZEOF_ARRAY_INT(editor_el_dx_boulderdash);
2495 static int editor_hl_chars[] =
2503 static int editor_el_chars[] =
2592 EL_CHAR(FONT_ASCII_CURSOR),
2595 static int *editor_hl_chars_ptr = editor_hl_chars;
2596 static int *editor_el_chars_ptr = editor_el_chars;
2597 static int num_editor_hl_chars = SIZEOF_ARRAY_INT(editor_hl_chars);
2598 static int num_editor_el_chars = SIZEOF_ARRAY_INT(editor_el_chars);
2600 static int editor_hl_custom[] =
2623 static int editor_el_custom[] =
2625 EL_CUSTOM_START + 0,
2626 EL_CUSTOM_START + 1,
2627 EL_CUSTOM_START + 2,
2628 EL_CUSTOM_START + 3,
2630 EL_CUSTOM_START + 4,
2631 EL_CUSTOM_START + 5,
2632 EL_CUSTOM_START + 6,
2633 EL_CUSTOM_START + 7,
2635 EL_CUSTOM_START + 8,
2636 EL_CUSTOM_START + 9,
2637 EL_CUSTOM_START + 10,
2638 EL_CUSTOM_START + 11,
2640 EL_CUSTOM_START + 12,
2641 EL_CUSTOM_START + 13,
2642 EL_CUSTOM_START + 14,
2643 EL_CUSTOM_START + 15,
2645 EL_CUSTOM_START + 16,
2646 EL_CUSTOM_START + 17,
2647 EL_CUSTOM_START + 18,
2648 EL_CUSTOM_START + 19,
2650 EL_CUSTOM_START + 20,
2651 EL_CUSTOM_START + 21,
2652 EL_CUSTOM_START + 22,
2653 EL_CUSTOM_START + 23,
2655 EL_CUSTOM_START + 24,
2656 EL_CUSTOM_START + 25,
2657 EL_CUSTOM_START + 26,
2658 EL_CUSTOM_START + 27,
2660 EL_CUSTOM_START + 28,
2661 EL_CUSTOM_START + 29,
2662 EL_CUSTOM_START + 30,
2663 EL_CUSTOM_START + 31,
2665 EL_CUSTOM_START + 32,
2666 EL_CUSTOM_START + 33,
2667 EL_CUSTOM_START + 34,
2668 EL_CUSTOM_START + 35,
2670 EL_CUSTOM_START + 36,
2671 EL_CUSTOM_START + 37,
2672 EL_CUSTOM_START + 38,
2673 EL_CUSTOM_START + 39,
2675 EL_CUSTOM_START + 40,
2676 EL_CUSTOM_START + 41,
2677 EL_CUSTOM_START + 42,
2678 EL_CUSTOM_START + 43,
2680 EL_CUSTOM_START + 44,
2681 EL_CUSTOM_START + 45,
2682 EL_CUSTOM_START + 46,
2683 EL_CUSTOM_START + 47,
2685 EL_CUSTOM_START + 48,
2686 EL_CUSTOM_START + 49,
2687 EL_CUSTOM_START + 50,
2688 EL_CUSTOM_START + 51,
2690 EL_CUSTOM_START + 52,
2691 EL_CUSTOM_START + 53,
2692 EL_CUSTOM_START + 54,
2693 EL_CUSTOM_START + 55,
2695 EL_CUSTOM_START + 56,
2696 EL_CUSTOM_START + 57,
2697 EL_CUSTOM_START + 58,
2698 EL_CUSTOM_START + 59,
2700 EL_CUSTOM_START + 60,
2701 EL_CUSTOM_START + 61,
2702 EL_CUSTOM_START + 62,
2703 EL_CUSTOM_START + 63,
2705 EL_CUSTOM_START + 64,
2706 EL_CUSTOM_START + 65,
2707 EL_CUSTOM_START + 66,
2708 EL_CUSTOM_START + 67,
2710 EL_CUSTOM_START + 68,
2711 EL_CUSTOM_START + 69,
2712 EL_CUSTOM_START + 70,
2713 EL_CUSTOM_START + 71,
2715 EL_CUSTOM_START + 72,
2716 EL_CUSTOM_START + 73,
2717 EL_CUSTOM_START + 74,
2718 EL_CUSTOM_START + 75,
2720 EL_CUSTOM_START + 76,
2721 EL_CUSTOM_START + 77,
2722 EL_CUSTOM_START + 78,
2723 EL_CUSTOM_START + 79,
2725 EL_CUSTOM_START + 80,
2726 EL_CUSTOM_START + 81,
2727 EL_CUSTOM_START + 82,
2728 EL_CUSTOM_START + 83,
2730 EL_CUSTOM_START + 84,
2731 EL_CUSTOM_START + 85,
2732 EL_CUSTOM_START + 86,
2733 EL_CUSTOM_START + 87,
2735 EL_CUSTOM_START + 88,
2736 EL_CUSTOM_START + 89,
2737 EL_CUSTOM_START + 90,
2738 EL_CUSTOM_START + 91,
2740 EL_CUSTOM_START + 92,
2741 EL_CUSTOM_START + 93,
2742 EL_CUSTOM_START + 94,
2743 EL_CUSTOM_START + 95,
2745 EL_CUSTOM_START + 96,
2746 EL_CUSTOM_START + 97,
2747 EL_CUSTOM_START + 98,
2748 EL_CUSTOM_START + 99,
2750 EL_CUSTOM_START + 100,
2751 EL_CUSTOM_START + 101,
2752 EL_CUSTOM_START + 102,
2753 EL_CUSTOM_START + 103,
2755 EL_CUSTOM_START + 104,
2756 EL_CUSTOM_START + 105,
2757 EL_CUSTOM_START + 106,
2758 EL_CUSTOM_START + 107,
2760 EL_CUSTOM_START + 108,
2761 EL_CUSTOM_START + 109,
2762 EL_CUSTOM_START + 110,
2763 EL_CUSTOM_START + 111,
2765 EL_CUSTOM_START + 112,
2766 EL_CUSTOM_START + 113,
2767 EL_CUSTOM_START + 114,
2768 EL_CUSTOM_START + 115,
2770 EL_CUSTOM_START + 116,
2771 EL_CUSTOM_START + 117,
2772 EL_CUSTOM_START + 118,
2773 EL_CUSTOM_START + 119,
2775 EL_CUSTOM_START + 120,
2776 EL_CUSTOM_START + 121,
2777 EL_CUSTOM_START + 122,
2778 EL_CUSTOM_START + 123,
2780 EL_CUSTOM_START + 124,
2781 EL_CUSTOM_START + 125,
2782 EL_CUSTOM_START + 126,
2783 EL_CUSTOM_START + 127
2785 static int *editor_hl_custom_ptr = editor_hl_custom;
2786 static int *editor_el_custom_ptr = editor_el_custom;
2787 static int num_editor_hl_custom = SIZEOF_ARRAY_INT(editor_hl_custom);
2788 static int num_editor_el_custom = SIZEOF_ARRAY_INT(editor_el_custom);
2790 static int editor_hl_custom_more[] =
2794 static int editor_el_custom_more[] =
2796 EL_CUSTOM_START + 128,
2797 EL_CUSTOM_START + 129,
2798 EL_CUSTOM_START + 130,
2799 EL_CUSTOM_START + 131,
2801 EL_CUSTOM_START + 132,
2802 EL_CUSTOM_START + 133,
2803 EL_CUSTOM_START + 134,
2804 EL_CUSTOM_START + 135,
2806 EL_CUSTOM_START + 136,
2807 EL_CUSTOM_START + 137,
2808 EL_CUSTOM_START + 138,
2809 EL_CUSTOM_START + 139,
2811 EL_CUSTOM_START + 140,
2812 EL_CUSTOM_START + 141,
2813 EL_CUSTOM_START + 142,
2814 EL_CUSTOM_START + 143,
2816 EL_CUSTOM_START + 144,
2817 EL_CUSTOM_START + 145,
2818 EL_CUSTOM_START + 146,
2819 EL_CUSTOM_START + 147,
2821 EL_CUSTOM_START + 148,
2822 EL_CUSTOM_START + 149,
2823 EL_CUSTOM_START + 150,
2824 EL_CUSTOM_START + 151,
2826 EL_CUSTOM_START + 152,
2827 EL_CUSTOM_START + 153,
2828 EL_CUSTOM_START + 154,
2829 EL_CUSTOM_START + 155,
2831 EL_CUSTOM_START + 156,
2832 EL_CUSTOM_START + 157,
2833 EL_CUSTOM_START + 158,
2834 EL_CUSTOM_START + 159,
2836 EL_CUSTOM_START + 160,
2837 EL_CUSTOM_START + 161,
2838 EL_CUSTOM_START + 162,
2839 EL_CUSTOM_START + 163,
2841 EL_CUSTOM_START + 164,
2842 EL_CUSTOM_START + 165,
2843 EL_CUSTOM_START + 166,
2844 EL_CUSTOM_START + 167,
2846 EL_CUSTOM_START + 168,
2847 EL_CUSTOM_START + 169,
2848 EL_CUSTOM_START + 170,
2849 EL_CUSTOM_START + 171,
2851 EL_CUSTOM_START + 172,
2852 EL_CUSTOM_START + 173,
2853 EL_CUSTOM_START + 174,
2854 EL_CUSTOM_START + 175,
2856 EL_CUSTOM_START + 176,
2857 EL_CUSTOM_START + 177,
2858 EL_CUSTOM_START + 178,
2859 EL_CUSTOM_START + 179,
2861 EL_CUSTOM_START + 180,
2862 EL_CUSTOM_START + 181,
2863 EL_CUSTOM_START + 182,
2864 EL_CUSTOM_START + 183,
2866 EL_CUSTOM_START + 184,
2867 EL_CUSTOM_START + 185,
2868 EL_CUSTOM_START + 186,
2869 EL_CUSTOM_START + 187,
2871 EL_CUSTOM_START + 188,
2872 EL_CUSTOM_START + 189,
2873 EL_CUSTOM_START + 190,
2874 EL_CUSTOM_START + 191,
2876 EL_CUSTOM_START + 192,
2877 EL_CUSTOM_START + 193,
2878 EL_CUSTOM_START + 194,
2879 EL_CUSTOM_START + 195,
2881 EL_CUSTOM_START + 196,
2882 EL_CUSTOM_START + 197,
2883 EL_CUSTOM_START + 198,
2884 EL_CUSTOM_START + 199,
2886 EL_CUSTOM_START + 200,
2887 EL_CUSTOM_START + 201,
2888 EL_CUSTOM_START + 202,
2889 EL_CUSTOM_START + 203,
2891 EL_CUSTOM_START + 204,
2892 EL_CUSTOM_START + 205,
2893 EL_CUSTOM_START + 206,
2894 EL_CUSTOM_START + 207,
2896 EL_CUSTOM_START + 208,
2897 EL_CUSTOM_START + 209,
2898 EL_CUSTOM_START + 210,
2899 EL_CUSTOM_START + 211,
2901 EL_CUSTOM_START + 212,
2902 EL_CUSTOM_START + 213,
2903 EL_CUSTOM_START + 214,
2904 EL_CUSTOM_START + 215,
2906 EL_CUSTOM_START + 216,
2907 EL_CUSTOM_START + 217,
2908 EL_CUSTOM_START + 218,
2909 EL_CUSTOM_START + 219,
2911 EL_CUSTOM_START + 220,
2912 EL_CUSTOM_START + 221,
2913 EL_CUSTOM_START + 222,
2914 EL_CUSTOM_START + 223,
2916 EL_CUSTOM_START + 224,
2917 EL_CUSTOM_START + 225,
2918 EL_CUSTOM_START + 226,
2919 EL_CUSTOM_START + 227,
2921 EL_CUSTOM_START + 228,
2922 EL_CUSTOM_START + 229,
2923 EL_CUSTOM_START + 230,
2924 EL_CUSTOM_START + 231,
2926 EL_CUSTOM_START + 232,
2927 EL_CUSTOM_START + 233,
2928 EL_CUSTOM_START + 234,
2929 EL_CUSTOM_START + 235,
2931 EL_CUSTOM_START + 236,
2932 EL_CUSTOM_START + 237,
2933 EL_CUSTOM_START + 238,
2934 EL_CUSTOM_START + 239,
2936 EL_CUSTOM_START + 240,
2937 EL_CUSTOM_START + 241,
2938 EL_CUSTOM_START + 242,
2939 EL_CUSTOM_START + 243,
2941 EL_CUSTOM_START + 244,
2942 EL_CUSTOM_START + 245,
2943 EL_CUSTOM_START + 246,
2944 EL_CUSTOM_START + 247,
2946 EL_CUSTOM_START + 248,
2947 EL_CUSTOM_START + 249,
2948 EL_CUSTOM_START + 250,
2949 EL_CUSTOM_START + 251,
2951 EL_CUSTOM_START + 252,
2952 EL_CUSTOM_START + 253,
2953 EL_CUSTOM_START + 254,
2954 EL_CUSTOM_START + 255
2956 static int *editor_hl_custom_more_ptr = editor_hl_custom_more;
2957 static int *editor_el_custom_more_ptr = editor_el_custom_more;
2958 static int num_editor_hl_custom_more = SIZEOF_ARRAY_INT(editor_hl_custom_more);
2959 static int num_editor_el_custom_more = SIZEOF_ARRAY_INT(editor_el_custom_more);
2961 static int editor_hl_group[] =
2984 static int editor_el_group[] =
2998 EL_GROUP_START + 10,
2999 EL_GROUP_START + 11,
3001 EL_GROUP_START + 12,
3002 EL_GROUP_START + 13,
3003 EL_GROUP_START + 14,
3006 static int *editor_hl_group_ptr = editor_hl_group;
3007 static int *editor_el_group_ptr = editor_el_group;
3008 static int num_editor_hl_group = SIZEOF_ARRAY_INT(editor_hl_group);
3009 static int num_editor_el_group = SIZEOF_ARRAY_INT(editor_el_group);
3011 static int editor_hl_group_more[] =
3015 static int editor_el_group_more[] =
3017 EL_GROUP_START + 16,
3018 EL_GROUP_START + 17,
3019 EL_GROUP_START + 18,
3020 EL_GROUP_START + 19,
3022 EL_GROUP_START + 20,
3023 EL_GROUP_START + 21,
3024 EL_GROUP_START + 22,
3025 EL_GROUP_START + 23,
3027 EL_GROUP_START + 24,
3028 EL_GROUP_START + 25,
3029 EL_GROUP_START + 26,
3030 EL_GROUP_START + 27,
3032 EL_GROUP_START + 28,
3033 EL_GROUP_START + 29,
3034 EL_GROUP_START + 30,
3037 static int *editor_hl_group_more_ptr = editor_hl_group_more;
3038 static int *editor_el_group_more_ptr = editor_el_group_more;
3039 static int num_editor_hl_group_more = SIZEOF_ARRAY_INT(editor_hl_group_more);
3040 static int num_editor_el_group_more = SIZEOF_ARRAY_INT(editor_el_group_more);
3042 static int editor_hl_user_defined[] =
3060 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
3061 static int *editor_el_user_defined_ptr = NULL;
3062 static int num_editor_hl_user_defined=SIZEOF_ARRAY_INT(editor_hl_user_defined);
3063 static int num_editor_el_user_defined = 0;
3065 static int editor_hl_empty[] = { };
3066 static int editor_el_empty[ED_NUM_ELEMENTLIST_BUTTONS];
3068 static int *editor_hl_empty_ptr = editor_hl_empty;
3069 static int *editor_el_empty_ptr = editor_el_empty;
3070 static int num_editor_hl_empty = 0;
3071 static int num_editor_el_empty = 0; /* dynamically determined, if needed */
3073 static boolean use_el_empty = FALSE;
3075 static int *editor_elements = NULL; /* dynamically allocated */
3076 static int num_editor_elements = 0; /* dynamically determined */
3080 boolean *setup_value;
3082 int **headline_list;
3083 int *headline_list_size;
3086 int *element_list_size;
3088 boolean last_setup_value;
3090 editor_elements_info[] =
3093 &setup.editor.el_boulderdash,
3094 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
3095 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
3098 &setup.editor.el_emerald_mine,
3099 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
3100 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
3103 &setup.editor.el_more,
3104 &editor_hl_more_ptr, &num_editor_hl_more,
3105 &editor_el_more_ptr, &num_editor_el_more
3108 &setup.editor.el_sokoban,
3109 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
3110 &editor_el_sokoban_ptr, &num_editor_el_sokoban
3113 &setup.editor.el_supaplex,
3114 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
3115 &editor_el_supaplex_ptr, &num_editor_el_supaplex
3118 &setup.editor.el_diamond_caves,
3119 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
3120 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
3123 &setup.editor.el_dx_boulderdash,
3124 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
3125 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
3128 &setup.editor.el_chars,
3129 &editor_hl_chars_ptr, &num_editor_hl_chars,
3130 &editor_el_chars_ptr, &num_editor_el_chars
3133 &setup.editor.el_custom,
3134 &editor_hl_custom_ptr, &num_editor_hl_custom,
3135 &editor_el_custom_ptr, &num_editor_el_custom
3138 &setup.editor.el_custom_more,
3139 &editor_hl_custom_more_ptr, &num_editor_hl_custom_more,
3140 &editor_el_custom_more_ptr, &num_editor_el_custom_more
3143 &setup.editor.el_custom,
3144 &editor_hl_group_ptr, &num_editor_hl_group,
3145 &editor_el_group_ptr, &num_editor_el_group
3148 &setup.editor.el_custom_more,
3149 &editor_hl_group_more_ptr, &num_editor_hl_group_more,
3150 &editor_el_group_more_ptr, &num_editor_el_group_more
3153 &setup.editor.el_user_defined,
3154 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
3155 &editor_el_user_defined_ptr, &num_editor_el_user_defined
3159 &editor_hl_empty_ptr, &num_editor_hl_empty,
3160 &editor_el_empty_ptr, &num_editor_el_empty,
3171 -----------------------------------------------------------------------------
3173 -----------------------------------------------------------------------------
3176 static int getMaxInfoTextLength()
3178 return (SXSIZE / getFontWidth(FONT_TEXT_2));
3181 static int getTextWidthForGadget(char *text)
3186 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
3189 static int getTextWidthForDrawingArea(char *text)
3194 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
3197 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
3199 return (gi->x + gi->width + getTextWidthForGadget(text));
3202 static char *getElementInfoText(int element)
3204 char *info_text = NULL;
3206 if (element < NUM_FILE_ELEMENTS)
3208 if (strlen(element_info[element].description) > 0)
3209 info_text = element_info[element].description;
3210 else if (element_info[element].custom_description != NULL)
3211 info_text = element_info[element].custom_description;
3212 else if (element_info[element].editor_description != NULL)
3213 info_text = element_info[element].editor_description;
3216 if (info_text == NULL)
3217 info_text = INFOTEXT_UNKNOWN_ELEMENT;
3222 static void ReinitializeElementList()
3224 static boolean initialized = FALSE;
3228 checked_free(editor_elements);
3232 /* initialize optional user defined element list */
3233 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
3234 &num_editor_el_user_defined);
3236 /* initialize list of empty elements (used for padding, if needed) */
3237 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
3238 editor_el_empty[i] = EL_EMPTY;
3240 /* do some sanity checks for each element from element list */
3241 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
3243 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
3245 int element = (*editor_elements_info[i].element_list)[j];
3247 if (element >= NUM_FILE_ELEMENTS)
3248 Error(ERR_WARN, "editor element %d is runtime element", element);
3250 if (strcmp(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT) == 0)
3251 Error(ERR_WARN, "no element description for element %d", element);
3258 num_editor_elements = 0;
3259 use_el_empty = FALSE;
3261 /* determine size of element list */
3262 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
3264 if (*editor_elements_info[i].setup_value)
3266 if (setup.editor.el_headlines)
3267 num_editor_elements += *editor_elements_info[i].headline_list_size;
3269 num_editor_elements += *editor_elements_info[i].element_list_size;
3273 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
3275 /* offer at least as many elements as element buttons exist */
3276 use_el_empty = TRUE;
3277 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
3279 num_editor_elements += num_editor_el_empty;
3282 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
3284 /* fill element list */
3285 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
3287 if (*editor_elements_info[i].setup_value)
3289 if (setup.editor.el_headlines)
3290 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
3291 editor_elements[pos++] = (*editor_elements_info[i].headline_list)[j];
3293 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
3294 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
3298 /* correct position of element list scrollbar */
3299 if (element_shift < 0)
3301 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
3302 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
3305 void PrintEditorElementList()
3307 boolean *stop = &setup.editor.el_user_defined;
3310 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
3312 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
3314 int element = (*editor_elements_info[i].headline_list)[j];
3316 printf("# %s\n", element_info[element].token_name);
3322 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
3324 int element = (*editor_elements_info[i].element_list)[j];
3326 printf("# %s\n", element_info[element].token_name);
3334 static void ReinitializeElementListButtons()
3336 static boolean last_setup_value_headlines = FALSE;
3337 static boolean initialization_needed = TRUE;
3340 if (!initialization_needed) /* check if editor element setup has changed */
3342 if (last_setup_value_headlines != setup.editor.el_headlines)
3343 initialization_needed = TRUE;
3345 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
3346 if (editor_elements_info[i].last_setup_value !=
3347 *editor_elements_info[i].setup_value)
3348 initialization_needed = TRUE;
3351 if (!initialization_needed)
3354 FreeLevelEditorGadgets();
3355 CreateLevelEditorGadgets();
3357 /* store current setup values for next invocation of this function */
3358 last_setup_value_headlines = setup.editor.el_headlines;
3359 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
3360 editor_elements_info[i].last_setup_value =
3361 *editor_elements_info[i].setup_value;
3363 initialization_needed = FALSE;
3366 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
3369 int border_graphic =
3370 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
3373 int num_mini_tilex = width / MINI_TILEX + 1;
3374 int num_mini_tiley = height / MINI_TILEY + 1;
3377 getMiniGraphicSource(border_graphic, &src_bitmap, &src_x, &src_y);
3379 for (y = 0; y < num_mini_tiley; y++)
3380 for (x = 0; x < num_mini_tilex; x++)
3381 BlitBitmap(src_bitmap, drawto, src_x, src_y, MINI_TILEX, MINI_TILEY,
3382 dest_x - MINI_TILEX / 2 + x * MINI_TILEX,
3383 dest_y - MINI_TILEY / 2 + y * MINI_TILEY);
3385 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
3388 static void DrawDrawingArea(int id)
3390 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
3393 if (id == ED_DRAWING_ID_RANDOM_BACKGROUND)
3394 DrawMiniGraphicExt(drawto, gi->x, gi->y,
3395 el2edimg(random_placement_background_element));
3396 else if (id == ED_DRAWING_ID_AMOEBA_CONTENT)
3397 DrawMiniGraphicExt(drawto, gi->x, gi->y, el2edimg(level.amoeba_content));
3398 else if (id == ED_DRAWING_ID_CUSTOM_GRAPHIC)
3399 DrawMiniGraphicExt(drawto, gi->x, gi->y,
3400 el2edimg(custom_element.gfx_element));
3401 else if (id == ED_DRAWING_ID_CUSTOM_CONTENT)
3402 for (y = 0; y < 3; y++)
3403 for (x = 0; x < 3; x++)
3404 DrawMiniGraphicExt(drawto,
3405 gi->x + x * MINI_TILEX, gi->y + y * MINI_TILEY,
3406 el2edimg(custom_element.content[x][y]));
3407 else if (id == ED_DRAWING_ID_CUSTOM_MOVE_ENTER)
3408 DrawMiniGraphicExt(drawto, gi->x, gi->y,
3409 el2edimg(custom_element.move_enter_element));
3410 else if (id == ED_DRAWING_ID_CUSTOM_MOVE_LEAVE)
3411 DrawMiniGraphicExt(drawto, gi->x, gi->y,
3412 el2edimg(custom_element.move_leave_element));
3413 else if (id == ED_DRAWING_ID_CUSTOM_CHANGE_TARGET)
3414 DrawMiniGraphicExt(drawto, gi->x, gi->y,
3415 el2edimg(custom_element_change.target_element));
3416 else if (id == ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT)
3417 for (y = 0; y < 3; y++)
3418 for (x = 0; x < 3; x++)
3419 DrawMiniGraphicExt(drawto,
3420 gi->x + x * MINI_TILEX, gi->y + y * MINI_TILEY,
3421 el2edimg(custom_element_change.content[x][y]));
3422 else if (id == ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER)
3423 DrawMiniGraphicExt(drawto, gi->x, gi->y,
3424 el2edimg(custom_element_change.trigger_element));
3425 else if (id == ED_DRAWING_ID_GROUP_CONTENT)
3426 for (x = 0; x < group_element_info.num_elements; x++)
3427 DrawMiniGraphicExt(drawto, gi->x + x * MINI_TILEX, gi->y,
3428 el2edimg(group_element_info.element[x]));
3429 else if (id >= ED_DRAWING_ID_ELEMENT_CONTENT_0 &&
3430 id <= ED_DRAWING_ID_ELEMENT_CONTENT_7)
3432 int nr = id - ED_DRAWING_ID_ELEMENT_CONTENT_0;
3434 for (y = 0; y < 3; y++)
3435 for (x = 0; x < 3; x++)
3436 DrawMiniGraphicExt(drawto,
3437 gi->x + x * MINI_TILEX, gi->y + y * MINI_TILEY,
3438 el2edimg(level.yamyam_content[nr][x][y]));
3442 static void ScrollMiniLevel(int from_x, int from_y, int scroll)
3445 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
3446 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
3448 BlitBitmap(drawto, drawto,
3449 SX + (dx == -1 ? MINI_TILEX : 0),
3450 SY + (dy == -1 ? MINI_TILEY : 0),
3451 (ed_fieldx * MINI_TILEX) - (dx != 0 ? MINI_TILEX : 0),
3452 (ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0),
3453 SX + (dx == +1 ? MINI_TILEX : 0),
3454 SY + (dy == +1 ? MINI_TILEY : 0));
3457 x = (dx == 1 ? 0 : ed_fieldx - 1);
3458 for (y = 0; y < ed_fieldy; y++)
3459 DrawMiniElementOrWall(x, y, from_x, from_y);
3463 y = (dy == 1 ? 0 : ed_fieldy - 1);
3464 for (x = 0; x < ed_fieldx; x++)
3465 DrawMiniElementOrWall(x, y, from_x, from_y);
3468 redraw_mask |= REDRAW_FIELD;
3472 static void CreateControlButtons()
3474 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
3475 struct GadgetInfo *gi;
3476 unsigned long event_mask;
3479 /* create toolbox buttons */
3480 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
3484 int gd_xoffset, gd_yoffset;
3485 int gd_x1, gd_x2, gd_y1, gd_y2;
3487 int radio_button_nr;
3490 if (id == GADGET_ID_SINGLE_ITEMS ||
3491 id == GADGET_ID_CONNECTED_ITEMS ||
3492 id == GADGET_ID_LINE ||
3493 id == GADGET_ID_ARC ||
3494 id == GADGET_ID_TEXT ||
3495 id == GADGET_ID_RECTANGLE ||
3496 id == GADGET_ID_FILLED_BOX ||
3497 id == GADGET_ID_FLOOD_FILL ||
3498 id == GADGET_ID_GRAB_BRUSH ||
3499 id == GADGET_ID_PICK_ELEMENT ||
3500 id == GADGET_ID_CUSTOM_COPY_FROM ||
3501 id == GADGET_ID_CUSTOM_COPY_TO ||
3502 id == GADGET_ID_CUSTOM_EXCHANGE)
3504 button_type = GD_TYPE_RADIO_BUTTON;
3505 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
3506 checked = (id == drawing_function ? TRUE : FALSE);
3507 event_mask = GD_EVENT_PRESSED;
3511 button_type = GD_TYPE_NORMAL_BUTTON;
3512 radio_button_nr = RADIO_NR_NONE;
3515 if (id == GADGET_ID_WRAP_LEFT ||
3516 id == GADGET_ID_WRAP_RIGHT ||
3517 id == GADGET_ID_WRAP_UP ||
3518 id == GADGET_ID_WRAP_DOWN)
3519 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
3521 event_mask = GD_EVENT_RELEASED;
3524 if (id < ED_NUM_CTRL1_BUTTONS)
3526 int x = i % ED_CTRL1_BUTTONS_HORIZ;
3527 int y = i / ED_CTRL1_BUTTONS_HORIZ;
3529 gd_xoffset = ED_CTRL1_BUTTONS_XPOS + x * ED_CTRL1_BUTTON_XSIZE;
3530 gd_yoffset = ED_CTRL1_BUTTONS_YPOS + y * ED_CTRL1_BUTTON_YSIZE;
3531 width = ED_CTRL1_BUTTON_XSIZE;
3532 height = ED_CTRL1_BUTTON_YSIZE;
3534 gd_x1 = DOOR_GFX_PAGEX8 + gd_xoffset;
3535 gd_x2 = DOOR_GFX_PAGEX7 + gd_xoffset;
3536 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL1_BUTTONS_GFX_YPOS + gd_yoffset;
3537 gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL1_BUTTONS_ALT_GFX_YPOS + gd_yoffset;
3539 else if (id < ED_NUM_CTRL1_2_BUTTONS)
3541 int x = (i - ED_NUM_CTRL1_BUTTONS) % ED_CTRL2_BUTTONS_HORIZ;
3542 int y = (i - ED_NUM_CTRL1_BUTTONS) / ED_CTRL2_BUTTONS_HORIZ;
3544 gd_xoffset = ED_CTRL2_BUTTONS_XPOS + x * ED_CTRL2_BUTTON_XSIZE;
3545 gd_yoffset = ED_CTRL2_BUTTONS_YPOS + y * ED_CTRL2_BUTTON_YSIZE;
3546 width = ED_CTRL2_BUTTON_XSIZE;
3547 height = ED_CTRL2_BUTTON_YSIZE;
3549 gd_x1 = DOOR_GFX_PAGEX8 + gd_xoffset;
3550 gd_x2 = DOOR_GFX_PAGEX7 + gd_xoffset;
3551 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL2_BUTTONS_GFX_YPOS + gd_yoffset;
3552 gd_y2 = 0; /* no alternative graphic for these buttons */
3556 int x = (i - ED_NUM_CTRL1_2_BUTTONS) % ED_CTRL3_BUTTONS_HORIZ + 1;
3557 int y = (i - ED_NUM_CTRL1_2_BUTTONS) / ED_CTRL3_BUTTONS_HORIZ;
3559 gd_xoffset = ED_CTRL3_BUTTONS_XPOS + x * ED_CTRL3_BUTTON_XSIZE;
3560 gd_yoffset = ED_CTRL3_BUTTONS_YPOS + y * ED_CTRL3_BUTTON_YSIZE;
3561 width = ED_CTRL3_BUTTON_XSIZE;
3562 height = ED_CTRL3_BUTTON_YSIZE;
3564 gd_x1 = DOOR_GFX_PAGEX6 + gd_xoffset;
3565 gd_x2 = DOOR_GFX_PAGEX5 + gd_xoffset;
3566 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL3_BUTTONS_GFX_YPOS + gd_yoffset;
3567 gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL3_BUTTONS_ALT_GFX_YPOS + gd_yoffset;
3570 gi = CreateGadget(GDI_CUSTOM_ID, id,
3571 GDI_CUSTOM_TYPE_ID, i,
3572 GDI_INFO_TEXT, control_info[i].text,
3573 GDI_X, EX + gd_xoffset,
3574 GDI_Y, EY + gd_yoffset,
3577 GDI_TYPE, button_type,
3578 GDI_STATE, GD_BUTTON_UNPRESSED,
3579 GDI_RADIO_NR, radio_button_nr,
3580 GDI_CHECKED, checked,
3581 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
3582 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y1,
3583 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2,
3584 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
3585 GDI_EVENT_MASK, event_mask,
3586 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
3587 GDI_CALLBACK_ACTION, HandleControlButtons,
3591 Error(ERR_EXIT, "cannot create gadget");
3593 level_editor_gadget[id] = gi;
3596 /* create buttons for scrolling of drawing area and element list */
3597 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
3599 int id = scrollbutton_info[i].gadget_id;
3600 int x, y, width, height;
3601 int gd_x1, gd_x2, gd_y1, gd_y2;
3603 x = scrollbutton_info[i].x;
3604 y = scrollbutton_info[i].y;
3606 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
3608 if (id == GADGET_ID_SCROLL_LIST_UP ||
3609 id == GADGET_ID_SCROLL_LIST_DOWN)
3613 width = ED_SCROLLBUTTON2_XSIZE;
3614 height = ED_SCROLLBUTTON2_YSIZE;
3615 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].gd_x;
3616 gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].gd_y;
3617 gd_x2 = gd_x1 - ED_SCROLLBUTTON2_XSIZE;
3624 width = ED_SCROLLBUTTON_XSIZE;
3625 height = ED_SCROLLBUTTON_YSIZE;
3626 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].gd_x;
3627 gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].gd_y;
3628 gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE;
3632 gi = CreateGadget(GDI_CUSTOM_ID, id,
3633 GDI_CUSTOM_TYPE_ID, i,
3634 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
3639 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
3640 GDI_STATE, GD_BUTTON_UNPRESSED,
3641 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
3642 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
3643 GDI_EVENT_MASK, event_mask,
3644 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
3645 GDI_CALLBACK_ACTION, HandleControlButtons,
3649 Error(ERR_EXIT, "cannot create gadget");
3651 level_editor_gadget[id] = gi;
3654 /* create buttons for element list */
3655 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
3657 Bitmap *deco_bitmap;
3658 int deco_x, deco_y, deco_xpos, deco_ypos;
3659 int gd_xoffset, gd_yoffset;
3660 int gd_x1, gd_x2, gd_y;
3661 int x = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
3662 int y = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
3663 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
3664 int element = editor_elements[i];
3666 event_mask = GD_EVENT_RELEASED;
3668 gd_xoffset = ED_ELEMENTLIST_XPOS + x * ED_ELEMENTLIST_XSIZE;
3669 gd_yoffset = ED_ELEMENTLIST_YPOS + y * ED_ELEMENTLIST_YSIZE;
3671 gd_x1 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS + ED_ELEMENTLIST_XSIZE;
3672 gd_x2 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS;
3673 gd_y = DOOR_GFX_PAGEY1 + ED_ELEMENTLIST_YPOS;
3675 getMiniGraphicSource(el2edimg(element), &deco_bitmap, &deco_x, &deco_y);
3676 deco_xpos = (ED_ELEMENTLIST_XSIZE - MINI_TILEX) / 2;
3677 deco_ypos = (ED_ELEMENTLIST_YSIZE - MINI_TILEY) / 2;
3679 gi = CreateGadget(GDI_CUSTOM_ID, id,
3680 GDI_CUSTOM_TYPE_ID, i,
3681 GDI_INFO_TEXT, getElementInfoText(element),
3682 GDI_X, DX + gd_xoffset,
3683 GDI_Y, DY + gd_yoffset,
3684 GDI_WIDTH, ED_ELEMENTLIST_XSIZE,
3685 GDI_HEIGHT, ED_ELEMENTLIST_YSIZE,
3686 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
3687 GDI_STATE, GD_BUTTON_UNPRESSED,
3688 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
3689 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
3690 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
3691 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
3692 GDI_DECORATION_SIZE, MINI_TILEX, MINI_TILEY,
3693 GDI_DECORATION_SHIFTING, 1, 1,
3694 GDI_EVENT_MASK, event_mask,
3695 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
3696 GDI_CALLBACK_ACTION, HandleControlButtons,
3700 Error(ERR_EXIT, "cannot create gadget");
3702 level_editor_gadget[id] = gi;
3706 static void CreateCounterButtons()
3708 int max_infotext_len = getMaxInfoTextLength();
3711 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
3714 int x = SX + counterbutton_info[i].x; /* down count button */
3715 int y = SY + counterbutton_info[i].y;
3717 /* determine horizontal position to the right of specified gadget */
3718 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
3719 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
3720 ED_GADGET_TEXT_DISTANCE);
3722 /* determine horizontal offset for leading text */
3723 if (counterbutton_info[i].text_left != NULL)
3724 x += getTextWidthForGadget(counterbutton_info[i].text_left);
3726 for (j = 0; j < 2; j++)
3728 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
3729 struct GadgetInfo *gi;
3731 counterbutton_info[i].gadget_id_down :
3732 counterbutton_info[i].gadget_id_up);
3734 int gd_x, gd_x1, gd_x2, gd_y;
3736 unsigned long event_mask;
3737 char infotext[max_infotext_len + 1];
3739 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
3741 if (i == ED_COUNTER_ID_SELECT_LEVEL)
3744 ED_SCROLLBUTTON_ID_AREA_LEFT :
3745 ED_SCROLLBUTTON_ID_AREA_RIGHT);
3747 event_mask |= GD_EVENT_RELEASED;
3750 x += 2 * ED_GADGET_DISTANCE;
3751 y += ED_GADGET_DISTANCE;
3753 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[sid].gd_x;
3754 gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE;
3755 gd_y = DOOR_GFX_PAGEY1 + scrollbutton_info[sid].gd_y;
3756 x_size = ED_SCROLLBUTTON_XSIZE;
3757 y_size = ED_SCROLLBUTTON_YSIZE;
3761 gd_xoffset = (j == 0 ? ED_BUTTON_MINUS_XPOS : ED_BUTTON_PLUS_XPOS);
3762 gd_x1 = DOOR_GFX_PAGEX4 + gd_xoffset;
3763 gd_x2 = DOOR_GFX_PAGEX3 + gd_xoffset;
3764 gd_y = DOOR_GFX_PAGEY1 + ED_BUTTON_COUNT_YPOS;
3765 x_size = ED_BUTTON_COUNT_XSIZE;
3766 y_size = ED_BUTTON_COUNT_YSIZE;
3769 sprintf(infotext, "%s counter value by 1, 5 or 10",
3770 (j == 0 ? "decrease" : "increase"));
3772 gi = CreateGadget(GDI_CUSTOM_ID, id,
3773 GDI_CUSTOM_TYPE_ID, i,
3774 GDI_INFO_TEXT, infotext,
3779 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
3780 GDI_STATE, GD_BUTTON_UNPRESSED,
3781 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
3782 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
3783 GDI_EVENT_MASK, event_mask,
3784 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
3785 GDI_CALLBACK_ACTION, HandleCounterButtons,
3789 Error(ERR_EXIT, "cannot create gadget");
3791 level_editor_gadget[id] = gi;
3792 right_gadget_border[id] =
3793 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
3795 x += gi->width + ED_GADGET_DISTANCE; /* text count button */
3799 int font_type = FONT_INPUT_1;
3800 int font_type_active = FONT_INPUT_1_ACTIVE;
3801 int gd_width = ED_WIN_COUNT_XSIZE;
3803 id = counterbutton_info[i].gadget_id_text;
3804 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
3806 if (i == ED_COUNTER_ID_SELECT_LEVEL)
3808 font_type = FONT_LEVEL_NUMBER;
3809 font_type_active = FONT_LEVEL_NUMBER;
3811 x += 2 * ED_GADGET_DISTANCE;
3812 y -= ED_GADGET_DISTANCE;
3814 gd_x = DOOR_GFX_PAGEX6 + ED_WIN_COUNT2_XPOS;
3815 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT2_YPOS;
3816 gd_width = ED_WIN_COUNT2_XSIZE;
3820 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
3821 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
3824 gi = CreateGadget(GDI_CUSTOM_ID, id,
3825 GDI_CUSTOM_TYPE_ID, i,
3826 GDI_INFO_TEXT, "enter counter value",
3829 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
3830 GDI_NUMBER_VALUE, 0,
3831 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
3832 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
3834 GDI_TEXT_FONT, font_type,
3835 GDI_TEXT_FONT_ACTIVE, font_type_active,
3836 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
3837 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
3838 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
3839 GDI_DESIGN_WIDTH, gd_width,
3840 GDI_EVENT_MASK, event_mask,
3841 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
3842 GDI_CALLBACK_ACTION, HandleCounterButtons,
3846 Error(ERR_EXIT, "cannot create gadget");
3848 level_editor_gadget[id] = gi;
3849 right_gadget_border[id] =
3850 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
3852 x += gi->width + ED_GADGET_DISTANCE; /* up count button */
3858 static void CreateDrawingAreas()
3862 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
3864 struct GadgetInfo *gi;
3865 unsigned long event_mask;
3866 int id = drawingarea_info[i].gadget_id;
3867 int x = SX + drawingarea_info[i].x;
3868 int y = SY + drawingarea_info[i].y;
3869 int area_xsize = drawingarea_info[i].area_xsize;
3870 int area_ysize = drawingarea_info[i].area_ysize;
3873 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
3874 GD_EVENT_OFF_BORDERS;
3876 /* determine horizontal position to the right of specified gadget */
3877 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
3878 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
3879 ED_DRAWINGAREA_TEXT_DISTANCE);
3881 /* determine horizontal offset for leading text */
3882 if (drawingarea_info[i].text_left != NULL)
3883 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
3885 gi = CreateGadget(GDI_CUSTOM_ID, id,
3886 GDI_CUSTOM_TYPE_ID, i,
3889 GDI_TYPE, GD_TYPE_DRAWING_AREA,
3890 GDI_AREA_SIZE, area_xsize, area_ysize,
3891 GDI_ITEM_SIZE, MINI_TILEX, MINI_TILEY,
3892 GDI_EVENT_MASK, event_mask,
3893 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
3894 GDI_CALLBACK_ACTION, HandleDrawingAreas,
3898 Error(ERR_EXIT, "cannot create gadget");
3900 level_editor_gadget[id] = gi;
3901 right_gadget_border[id] =
3902 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
3906 static void CreateTextInputGadgets()
3908 int max_infotext_len = getMaxInfoTextLength();
3911 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
3913 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
3915 struct GadgetInfo *gi;
3916 unsigned long event_mask;
3917 char infotext[MAX_OUTPUT_LINESIZE + 1];
3918 int id = textinput_info[i].gadget_id;
3920 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
3922 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
3923 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
3925 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
3926 infotext[max_infotext_len] = '\0';
3928 gi = CreateGadget(GDI_CUSTOM_ID, id,
3929 GDI_CUSTOM_TYPE_ID, i,
3930 GDI_INFO_TEXT, infotext,
3931 GDI_X, SX + textinput_info[i].x,
3932 GDI_Y, SY + textinput_info[i].y,
3933 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
3934 GDI_TEXT_VALUE, textinput_info[i].value,
3935 GDI_TEXT_SIZE, textinput_info[i].size,
3936 GDI_TEXT_FONT, FONT_INPUT_1,
3937 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
3938 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
3939 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
3940 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
3941 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
3942 GDI_EVENT_MASK, event_mask,
3943 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
3944 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
3948 Error(ERR_EXIT, "cannot create gadget");
3950 level_editor_gadget[id] = gi;
3954 static void CreateTextAreaGadgets()
3956 int max_infotext_len = getMaxInfoTextLength();
3959 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
3961 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
3963 struct GadgetInfo *gi;
3964 unsigned long event_mask;
3965 char infotext[MAX_OUTPUT_LINESIZE + 1];
3966 int id = textarea_info[i].gadget_id;
3967 int area_xsize = textarea_info[i].xsize;
3968 int area_ysize = textarea_info[i].ysize;
3970 event_mask = GD_EVENT_TEXT_LEAVING;
3972 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
3973 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
3975 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
3976 infotext[max_infotext_len] = '\0';
3978 gi = CreateGadget(GDI_CUSTOM_ID, id,
3979 GDI_CUSTOM_TYPE_ID, i,
3980 GDI_INFO_TEXT, infotext,
3981 GDI_X, SX + textarea_info[i].x,
3982 GDI_Y, SY + textarea_info[i].y,
3983 GDI_TYPE, GD_TYPE_TEXT_AREA,
3984 GDI_AREA_SIZE, area_xsize, area_ysize,
3985 GDI_TEXT_FONT, FONT_INPUT_1,
3986 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
3987 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
3988 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
3989 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
3990 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
3991 GDI_EVENT_MASK, event_mask,
3992 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
3993 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
3997 Error(ERR_EXIT, "cannot create gadget");
3999 level_editor_gadget[id] = gi;
4003 static void CreateSelectboxGadgets()
4005 int max_infotext_len = getMaxInfoTextLength();
4008 for (i = 0; i < ED_NUM_SELECTBOX; i++)
4010 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4012 struct GadgetInfo *gi;
4013 unsigned long event_mask;
4014 char infotext[MAX_OUTPUT_LINESIZE + 1];
4015 int id = selectbox_info[i].gadget_id;
4016 int x = SX + selectbox_info[i].x;
4017 int y = SY + selectbox_info[i].y;
4019 if (selectbox_info[i].size == -1) /* dynamically determine size */
4021 /* (we cannot use -1 for uninitialized values if we directly compare
4022 with results from strlen(), because the '<' and '>' operation will
4023 implicitely cast -1 to an unsigned integer value!) */
4024 selectbox_info[i].size = 0;
4026 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
4027 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
4028 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
4030 selectbox_info[i].size++; /* add one character empty space */
4033 event_mask = GD_EVENT_RELEASED |
4034 GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
4036 gd_x = DOOR_GFX_PAGEX4 + ED_SELECTBOX_XPOS;
4037 gd_y = DOOR_GFX_PAGEY1 + ED_SELECTBOX_YPOS;
4039 /* determine horizontal position to the right of specified gadget */
4040 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
4041 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
4042 ED_GADGET_TEXT_DISTANCE);
4044 /* determine horizontal offset for leading text */
4045 if (selectbox_info[i].text_left != NULL)
4046 x += getTextWidthForGadget(selectbox_info[i].text_left);
4048 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
4049 infotext[max_infotext_len] = '\0';
4051 gi = CreateGadget(GDI_CUSTOM_ID, id,
4052 GDI_CUSTOM_TYPE_ID, i,
4053 GDI_INFO_TEXT, infotext,
4056 GDI_TYPE, GD_TYPE_SELECTBOX,
4057 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
4058 GDI_TEXT_SIZE, selectbox_info[i].size,
4059 GDI_TEXT_FONT, FONT_INPUT_1,
4060 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
4061 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
4062 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
4063 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
4064 GDI_BORDER_SIZE_SELECTBUTTON, ED_SELECTBOX_BUTTON_XSIZE,
4065 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
4066 GDI_EVENT_MASK, event_mask,
4067 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4068 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
4072 Error(ERR_EXIT, "cannot create gadget");
4074 level_editor_gadget[id] = gi;
4075 right_gadget_border[id] =
4076 getRightGadgetBorder(gi, selectbox_info[i].text_right);
4080 static void CreateTextbuttonGadgets()
4082 int max_infotext_len = getMaxInfoTextLength();
4085 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
4087 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4088 int gd_x1, gd_x2, gd_y1, gd_y2;
4089 struct GadgetInfo *gi;
4090 unsigned long event_mask;
4091 char infotext[MAX_OUTPUT_LINESIZE + 1];
4092 int id = textbutton_info[i].gadget_id;
4093 int x = SX + textbutton_info[i].x;
4094 int y = SY + textbutton_info[i].y;
4096 if (textbutton_info[i].size == -1) /* dynamically determine size */
4097 textbutton_info[i].size = strlen(textbutton_info[i].text);
4099 event_mask = GD_EVENT_RELEASED;
4101 if (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_ADVANCED)
4103 gd_x1 = DOOR_GFX_PAGEX4 + ED_TEXTBUTTON_TAB_XPOS;
4104 gd_x2 = DOOR_GFX_PAGEX3 + ED_TEXTBUTTON_TAB_XPOS;
4105 gd_y1 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_TAB_YPOS;
4106 gd_y2 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_TAB_INACTIVE_YPOS;
4110 gd_x1 = DOOR_GFX_PAGEX4 + ED_TEXTBUTTON_XPOS;
4111 gd_x2 = DOOR_GFX_PAGEX3 + ED_TEXTBUTTON_XPOS;
4112 gd_y1 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_YPOS;
4113 gd_y2 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_INACTIVE_YPOS;
4116 sprintf(infotext, "%s", textbutton_info[i].infotext);
4117 infotext[max_infotext_len] = '\0';
4119 /* determine horizontal position to the right of specified gadget */
4120 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
4121 x = (right_gadget_border[textbutton_info[i].gadget_id_align] +
4122 ED_GADGET_TEXT_DISTANCE);
4124 /* determine horizontal offset for leading text */
4125 if (textbutton_info[i].text_left != NULL)
4126 x += getTextWidthForGadget(textbutton_info[i].text_left);
4128 gi = CreateGadget(GDI_CUSTOM_ID, id,
4129 GDI_CUSTOM_TYPE_ID, i,
4130 GDI_INFO_TEXT, infotext,
4133 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
4134 GDI_TEXT_VALUE, textbutton_info[i].text,
4135 GDI_TEXT_SIZE, textbutton_info[i].size,
4136 GDI_TEXT_FONT, FONT_INPUT_2_ACTIVE,
4137 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2,
4138 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
4139 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y1,
4140 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2,
4141 GDI_BORDER_SIZE, ED_BORDER_TEXT_XSIZE, ED_BORDER_SIZE,
4142 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
4143 GDI_DECORATION_SHIFTING, 1, 1,
4144 GDI_EVENT_MASK, event_mask,
4145 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4146 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
4150 Error(ERR_EXIT, "cannot create gadget");
4152 level_editor_gadget[id] = gi;
4153 right_gadget_border[id] =
4154 getRightGadgetBorder(gi, textbutton_info[i].text_right);
4158 static void CreateGraphicbuttonGadgets()
4160 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4161 struct GadgetInfo *gi;
4162 unsigned long event_mask;
4165 /* create buttons for scrolling of drawing area and element list */
4166 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
4168 int id = graphicbutton_info[i].gadget_id;
4169 int gd_x1, gd_x2, gd_y1, gd_y2;
4170 int x = SX + graphicbutton_info[i].x;
4171 int y = SY + graphicbutton_info[i].y;
4173 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
4175 gd_x1 = DOOR_GFX_PAGEX4 + graphicbutton_info[i].gd_x;
4176 gd_x2 = DOOR_GFX_PAGEX3 + graphicbutton_info[i].gd_x;
4177 gd_y1 = DOOR_GFX_PAGEY1 + graphicbutton_info[i].gd_y;
4180 /* determine horizontal position to the right of specified gadget */
4181 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
4182 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
4183 ED_GADGET_TEXT_DISTANCE);
4185 /* determine horizontal offset for leading text */
4186 if (graphicbutton_info[i].text_left != NULL)
4187 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
4189 gi = CreateGadget(GDI_CUSTOM_ID, id,
4190 GDI_CUSTOM_TYPE_ID, i,
4191 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
4194 GDI_WIDTH, graphicbutton_info[i].width,
4195 GDI_HEIGHT, graphicbutton_info[i].height,
4196 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
4197 GDI_STATE, GD_BUTTON_UNPRESSED,
4198 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
4199 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
4200 GDI_EVENT_MASK, event_mask,
4201 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4202 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
4206 Error(ERR_EXIT, "cannot create gadget");
4208 level_editor_gadget[id] = gi;
4209 right_gadget_border[id] =
4210 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
4214 static void CreateScrollbarGadgets()
4218 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
4220 int id = scrollbar_info[i].gadget_id;
4221 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4222 int gd_x1, gd_x2, gd_y1, gd_y2;
4223 struct GadgetInfo *gi;
4224 int items_max, items_visible, item_position;
4225 unsigned long event_mask;
4227 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
4229 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
4230 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
4231 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
4233 else /* drawing area scrollbars */
4235 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
4237 items_max = MAX(lev_fieldx + 2, ed_fieldx);
4238 items_visible = ed_fieldx;
4243 items_max = MAX(lev_fieldy + 2, ed_fieldy);
4244 items_visible = ed_fieldy;
4249 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
4251 gd_x1 = DOOR_GFX_PAGEX8 + scrollbar_info[i].gd_x;
4252 gd_x2 = (gd_x1 - (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL ?
4253 scrollbar_info[i].height : scrollbar_info[i].width));
4254 gd_y1 = DOOR_GFX_PAGEY1 + scrollbar_info[i].gd_y;
4255 gd_y2 = DOOR_GFX_PAGEY1 + scrollbar_info[i].gd_y;
4257 gi = CreateGadget(GDI_CUSTOM_ID, id,
4258 GDI_CUSTOM_TYPE_ID, i,
4259 GDI_INFO_TEXT, scrollbar_info[i].infotext,
4260 GDI_X, scrollbar_info[i].x,
4261 GDI_Y, scrollbar_info[i].y,
4262 GDI_WIDTH, scrollbar_info[i].width,
4263 GDI_HEIGHT, scrollbar_info[i].height,
4264 GDI_TYPE, scrollbar_info[i].type,
4265 GDI_SCROLLBAR_ITEMS_MAX, items_max,
4266 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
4267 GDI_SCROLLBAR_ITEM_POSITION, item_position,
4268 GDI_STATE, GD_BUTTON_UNPRESSED,
4269 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
4270 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
4271 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
4272 GDI_EVENT_MASK, event_mask,
4273 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4274 GDI_CALLBACK_ACTION, HandleControlButtons,
4278 Error(ERR_EXIT, "cannot create gadget");
4280 level_editor_gadget[id] = gi;
4284 static void CreateCheckbuttonGadgets()
4286 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4287 struct GadgetInfo *gi;
4288 unsigned long event_mask;
4289 int gd_x1, gd_x2, gd_x3, gd_x4, gd_y;
4292 event_mask = GD_EVENT_PRESSED;
4294 gd_x1 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_UNCHECKED_XPOS;
4295 gd_x2 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_UNCHECKED_XPOS;
4296 gd_x3 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_CHECKED_XPOS;
4297 gd_x4 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_CHECKED_XPOS;
4298 gd_y = DOOR_GFX_PAGEY1 + ED_RADIOBUTTON_YPOS;
4300 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
4302 int id = checkbutton_info[i].gadget_id;
4303 int x = SX + checkbutton_info[i].x;
4304 int y = SY + checkbutton_info[i].y;
4306 if (id == GADGET_ID_STICK_ELEMENT)
4307 gd_y = DOOR_GFX_PAGEY1 + ED_STICKYBUTTON_YPOS;
4309 gd_y = DOOR_GFX_PAGEY1 + ED_CHECKBUTTON_YPOS;
4311 /* determine horizontal position to the right of specified gadget */
4312 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
4313 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
4314 ED_GADGET_TEXT_DISTANCE);
4316 /* determine horizontal offset for leading text */
4317 if (checkbutton_info[i].text_left != NULL)
4318 x += getTextWidthForGadget(checkbutton_info[i].text_left);
4320 gi = CreateGadget(GDI_CUSTOM_ID, id,
4321 GDI_CUSTOM_TYPE_ID, i,
4322 GDI_INFO_TEXT, checkbutton_info[i].infotext,
4325 GDI_WIDTH, ED_CHECKBUTTON_XSIZE,
4326 GDI_HEIGHT, ED_CHECKBUTTON_YSIZE,
4327 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
4328 GDI_CHECKED, *checkbutton_info[i].value,
4329 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
4330 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
4331 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y,
4332 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y,
4333 GDI_EVENT_MASK, event_mask,
4334 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4335 GDI_CALLBACK_ACTION, HandleCheckbuttons,
4339 Error(ERR_EXIT, "cannot create gadget");
4341 level_editor_gadget[id] = gi;
4342 right_gadget_border[id] =
4343 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
4347 static void CreateRadiobuttonGadgets()
4349 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4350 struct GadgetInfo *gi;
4351 unsigned long event_mask;
4352 int gd_x1, gd_x2, gd_x3, gd_x4, gd_y;
4355 event_mask = GD_EVENT_PRESSED;
4357 gd_x1 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_UNCHECKED_XPOS;
4358 gd_x2 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_UNCHECKED_XPOS;
4359 gd_x3 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_CHECKED_XPOS;
4360 gd_x4 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_CHECKED_XPOS;
4361 gd_y = DOOR_GFX_PAGEY1 + ED_RADIOBUTTON_YPOS;
4363 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
4365 int id = radiobutton_info[i].gadget_id;
4366 int x = SX + radiobutton_info[i].x;
4367 int y = SY + radiobutton_info[i].y;
4370 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
4372 /* determine horizontal position to the right of specified gadget */
4373 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
4374 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
4375 ED_GADGET_TEXT_DISTANCE);
4377 /* determine horizontal offset for leading text */
4378 if (radiobutton_info[i].text_left != NULL)
4379 x += getTextWidthForGadget(radiobutton_info[i].text_left);
4381 gi = CreateGadget(GDI_CUSTOM_ID, id,
4382 GDI_CUSTOM_TYPE_ID, i,
4383 GDI_INFO_TEXT, radiobutton_info[i].infotext,
4386 GDI_WIDTH, ED_CHECKBUTTON_XSIZE,
4387 GDI_HEIGHT, ED_CHECKBUTTON_YSIZE,
4388 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
4389 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
4390 GDI_CHECKED, checked,
4391 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
4392 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
4393 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y,
4394 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y,
4395 GDI_EVENT_MASK, event_mask,
4396 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4397 GDI_CALLBACK_ACTION, HandleRadiobuttons,
4401 Error(ERR_EXIT, "cannot create gadget");
4403 level_editor_gadget[id] = gi;
4404 right_gadget_border[id] =
4405 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
4409 void CreateLevelEditorGadgets()
4411 int old_game_status = game_status;
4413 /* setting 'game_status' is needed to get the right fonts for the editor */
4414 game_status = GAME_MODE_EDITOR;
4416 ReinitializeElementList();
4418 CreateControlButtons();
4419 CreateScrollbarGadgets();
4421 /* order of function calls is important because of cross-references */
4422 CreateCheckbuttonGadgets();
4423 CreateCounterButtons();
4424 CreateRadiobuttonGadgets();
4425 CreateTextInputGadgets();
4426 CreateTextAreaGadgets();
4427 CreateSelectboxGadgets();
4428 CreateGraphicbuttonGadgets();
4429 CreateTextbuttonGadgets();
4430 CreateDrawingAreas();
4432 game_status = old_game_status;
4435 void FreeLevelEditorGadgets()
4439 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
4440 FreeGadget(level_editor_gadget[i]);
4443 static void MapCounterButtons(int id)
4445 int gadget_id_down = counterbutton_info[id].gadget_id_down;
4446 int gadget_id_up = counterbutton_info[id].gadget_id_up;
4447 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
4448 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
4450 char infotext[MAX_OUTPUT_LINESIZE + 1];
4451 int max_infotext_len = getMaxInfoTextLength();
4452 int xoffset_left = 0;
4453 int yoffset_left = ED_BORDER_SIZE;
4454 int xoffset_right = getCounterGadgetWidth();
4455 int yoffset_right = ED_BORDER_SIZE;
4457 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
4458 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
4459 int yoffset_above = MINI_TILEX + ED_GADGET_DISTANCE;
4460 int yoffset = ED_BORDER_SIZE;
4461 int x_left = gi_down->x - xoffset_left;
4462 int x_right = gi_up->x + gi_up->width + xoffset_right;
4463 int y_above = gi_down->y - yoffset_above;
4465 int y = gi_up->y + yoffset;
4468 if (counterbutton_info[id].text_above)
4469 DrawText(x, y_above, counterbutton_info[id].text_above, FONT_TEXT_1);
4471 if (counterbutton_info[id].text_left)
4472 DrawText(x_left, y, counterbutton_info[id].text_left, FONT_TEXT_1);
4474 if (counterbutton_info[id].text_right)
4475 DrawText(x_right, y, counterbutton_info[id].text_right, FONT_TEXT_1);
4477 ModifyEditorCounter(id, *counterbutton_info[id].value);
4479 MapGadget(level_editor_gadget[counterbutton_info[id].gadget_id_down]);
4480 MapGadget(level_editor_gadget[counterbutton_info[id].gadget_id_text]);
4481 MapGadget(level_editor_gadget[counterbutton_info[id].gadget_id_up]);
4484 static void MapControlButtons()
4489 /* map toolbox buttons (excluding special CE toolbox buttons) */
4490 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
4491 MapGadget(level_editor_gadget[i]);
4493 /* map buttons to select elements */
4494 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
4495 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
4496 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
4497 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
4498 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
4500 /* map buttons to select level */
4501 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
4502 ModifyEditorCounterLimits(counter_id,
4503 leveldir_current->first_level,
4504 leveldir_current->last_level);
4505 MapCounterButtons(counter_id);
4508 static void MapDrawingArea(int id)
4510 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
4511 int area_xsize = gi->drawing.area_xsize;
4512 int area_ysize = gi->drawing.area_ysize;
4513 int xoffset_left= getTextWidthForDrawingArea(drawingarea_info[id].text_left);
4514 int xoffset_below= getTextWidth(drawingarea_info[id].text_below,FONT_TEXT_1);
4515 int x_left = gi->x - xoffset_left;
4516 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
4517 int x_below = gi->x + (gi->width - xoffset_below) / 2;
4518 int y_side = gi->y + (gi->height - getFontHeight(FONT_TEXT_1)) / 2;
4519 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
4521 if (drawingarea_info[id].text_left)
4522 DrawText(x_left, y_side, drawingarea_info[id].text_left, FONT_TEXT_1);
4524 if (drawingarea_info[id].text_right)
4525 DrawText(x_right, y_side, drawingarea_info[id].text_right, FONT_TEXT_1);
4527 if (drawingarea_info[id].text_below)
4528 DrawText(x_below, y_below, drawingarea_info[id].text_below, FONT_TEXT_1);
4530 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
4532 DrawElementBorder(gi->x, gi->y,
4533 area_xsize * MINI_TILEX, area_ysize * MINI_TILEY, TRUE);
4535 DrawDrawingArea(id);
4541 static void MapTextInputGadget(int id)
4543 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
4544 int xoffset_above = 0;
4545 int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
4546 int x_above = textinput_info[id].x + xoffset_above;
4547 int y_above = textinput_info[id].y + yoffset_above;
4549 if (textinput_info[id].text_above)
4550 DrawTextS(x_above, y_above, FONT_TEXT_1, textinput_info[id].text_above);
4552 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
4557 static void MapTextAreaGadget(int id)
4559 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
4560 int xoffset_above = 0;
4561 int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
4562 int x_above = textarea_info[id].x + xoffset_above;
4563 int y_above = textarea_info[id].y + yoffset_above;
4565 if (textarea_info[id].text_above)
4566 DrawTextS(x_above, y_above, FONT_TEXT_1, textarea_info[id].text_above);
4568 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
4573 static void MapSelectboxGadget(int id)
4575 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
4576 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
4577 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
4578 int yoffset = ED_BORDER_SIZE;
4579 int x_left = gi->x - xoffset_left;
4580 int x_right = gi->x + gi->width + xoffset_right;
4581 int y = gi->y + yoffset;
4583 if (selectbox_info[id].text_left)
4584 DrawText(x_left, y, selectbox_info[id].text_left, FONT_TEXT_1);
4586 if (selectbox_info[id].text_right)
4587 DrawText(x_right, y, selectbox_info[id].text_right, FONT_TEXT_1);
4589 ModifyEditorSelectbox(id, *selectbox_info[id].value);
4594 static void MapTextbuttonGadget(int id)
4596 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
4597 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
4598 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
4599 int yoffset = ED_BORDER_SIZE;
4600 int x_left = gi->x - xoffset_left;
4601 int x_right = gi->x + gi->width + xoffset_right;
4602 int y = gi->y + yoffset;
4604 /* only show button to delete change pages when more than minimum pages */
4605 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
4606 custom_element.num_change_pages == MIN_CHANGE_PAGES)
4609 if (textbutton_info[id].text_left)
4610 DrawText(x_left, y, textbutton_info[id].text_left, FONT_TEXT_1);
4612 if (textbutton_info[id].text_right)
4613 DrawText(x_right, y, textbutton_info[id].text_right, FONT_TEXT_1);
4618 static void MapGraphicbuttonGadget(int id)
4620 struct GadgetInfo *gi= level_editor_gadget[graphicbutton_info[id].gadget_id];
4621 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
4622 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
4623 int yoffset = ED_BORDER_SIZE;
4624 int x_left = gi->x - xoffset_left;
4625 int x_right = gi->x + gi->width + xoffset_right;
4626 int y = gi->y + yoffset;
4628 if (graphicbutton_info[id].text_left)
4629 DrawText(x_left, y, graphicbutton_info[id].text_left, FONT_TEXT_1);
4631 if (graphicbutton_info[id].text_right)
4632 DrawText(x_right, y, graphicbutton_info[id].text_right, FONT_TEXT_1);
4637 static void MapRadiobuttonGadget(int id)
4639 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
4640 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
4641 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
4642 int yoffset = ED_BORDER_SIZE;
4643 int x_left = gi->x - xoffset_left;
4644 int x_right = gi->x + gi->width + xoffset_right;
4645 int y = gi->y + yoffset;
4647 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
4649 if (radiobutton_info[id].text_left)
4650 DrawText(x_left, y, radiobutton_info[id].text_left, FONT_TEXT_1);
4652 if (radiobutton_info[id].text_right)
4653 DrawText(x_right, y, radiobutton_info[id].text_right, FONT_TEXT_1);
4655 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
4660 static void MapCheckbuttonGadget(int id)
4662 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
4663 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
4664 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
4665 int yoffset = ED_BORDER_SIZE;
4666 int x_left = gi->x - xoffset_left;
4667 int x_right = gi->x + gi->width + xoffset_right;
4668 int y = gi->y + yoffset;
4670 /* special case needed for "sticky" gadget */
4671 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value,
4672 GDI_Y, SY + checkbutton_info[id].y, GDI_END);
4673 y = gi->y + yoffset;
4675 if (checkbutton_info[id].text_left)
4676 DrawText(x_left, y, checkbutton_info[id].text_left, FONT_TEXT_1);
4678 if (checkbutton_info[id].text_right)
4679 DrawText(x_right, y, checkbutton_info[id].text_right, FONT_TEXT_1);
4684 static void MapMainDrawingArea()
4686 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
4687 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
4690 for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
4692 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
4693 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
4694 no_horizontal_scrollbar) ||
4695 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
4696 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
4697 no_vertical_scrollbar))
4700 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
4703 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
4705 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
4706 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
4709 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
4712 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
4715 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
4719 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
4721 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
4722 i == GADGET_ID_CUSTOM_COPY_TO ||
4723 i == GADGET_ID_CUSTOM_EXCHANGE)
4726 MapGadget(level_editor_gadget[i]);
4728 UnmapGadget(level_editor_gadget[i]);
4733 static void MapLevelEditorToolboxCustomGadgets()
4735 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
4738 static void UnmapLevelEditorToolboxCustomGadgets()
4740 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
4743 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
4745 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4748 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
4750 if (i != GADGET_ID_SINGLE_ITEMS &&
4751 i != GADGET_ID_PROPERTIES &&
4752 i != GADGET_ID_PICK_ELEMENT)
4754 struct GadgetInfo *gi = level_editor_gadget[i];
4762 BlitBitmap(gd_bitmap, drawto,
4763 DOOR_GFX_PAGEX6 + ED_CTRL_NO_BUTTONS_GFX_XPOS,
4764 DOOR_GFX_PAGEY1 + ED_CTRL_NO_BUTTONS_GFX_YPOS,
4765 gi->width, gi->height, gi->x, gi->y);
4767 redraw_mask |= REDRAW_DOOR_3;
4773 static void MapLevelEditorToolboxDrawingGadgets()
4775 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
4778 static void UnmapLevelEditorToolboxDrawingGadgets()
4780 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
4783 static void UnmapDrawingArea(int id)
4785 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
4788 static void UnmapLevelEditorWindowGadgets()
4792 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
4793 if (level_editor_gadget[i]->x < SX + SXSIZE)
4794 UnmapGadget(level_editor_gadget[i]);
4797 void UnmapLevelEditorGadgets()
4801 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
4802 UnmapGadget(level_editor_gadget[i]);
4805 static void ResetUndoBuffer()
4807 undo_buffer_position = -1;
4808 undo_buffer_steps = -1;
4809 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
4812 static void DrawEditModeWindow()
4814 ModifyEditorElementList();
4815 RedrawDrawingElements();
4817 if (edit_mode == ED_MODE_INFO)
4818 DrawLevelInfoWindow();
4819 else if (edit_mode == ED_MODE_PROPERTIES)
4820 DrawPropertiesWindow();
4821 else /* edit_mode == ED_MODE_DRAWING */
4822 DrawDrawingWindow();
4825 static boolean LevelChanged()
4827 boolean level_changed = FALSE;
4830 for (y = 0; y < lev_fieldy; y++)
4831 for (x = 0; x < lev_fieldx; x++)
4832 if (Feld[x][y] != level.field[x][y])
4833 level_changed = TRUE;
4835 return level_changed;
4838 static boolean LevelContainsPlayer()
4840 boolean player_found = FALSE;
4843 for (y = 0; y < lev_fieldy; y++)
4844 for (x = 0; x < lev_fieldx; x++)
4845 if (Feld[x][y] == EL_PLAYER_1 ||
4846 Feld[x][y] == EL_SP_MURPHY)
4847 player_found = TRUE;
4849 return player_found;
4852 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
4853 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
4857 for (x = 0; x < lev_fieldx; x++)
4858 for (y = 0; y < lev_fieldy; y++)
4859 dst[x][y] = src[x][y];
4862 static int setSelectboxValue(int selectbox_id, int new_value)
4864 int new_index_value = 0;
4867 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
4868 if (selectbox_info[selectbox_id].options[i].value == new_value)
4869 new_index_value = i;
4871 *selectbox_info[selectbox_id].value =
4872 selectbox_info[selectbox_id].options[new_index_value].value;
4874 return new_index_value;
4877 static void copy_custom_element_settings(int element_from, int element_to)
4879 struct ElementInfo *ei_from = &element_info[element_from];
4880 struct ElementInfo *ei_to = &element_info[element_to];
4883 /* ---------- copy element description ---------- */
4884 for (i = 0; i < MAX_ELEMENT_NAME_LEN + 1; i++)
4885 ei_to->description[i] = ei_from->description[i];
4887 /* ---------- copy element properties ---------- */
4888 Properties[element_to][EP_BITFIELD_BASE] =
4889 Properties[element_from][EP_BITFIELD_BASE];
4891 /* ---------- copy custom property values ---------- */
4893 ei_to->use_gfx_element = ei_from->use_gfx_element;
4894 ei_to->gfx_element = ei_from->gfx_element;
4896 ei_to->collect_score = ei_from->collect_score;
4897 ei_to->collect_count = ei_from->collect_count;
4899 ei_to->push_delay_fixed = ei_from->push_delay_fixed;
4900 ei_to->push_delay_random = ei_from->push_delay_random;
4901 ei_to->move_delay_fixed = ei_from->move_delay_fixed;
4902 ei_to->move_delay_random = ei_from->move_delay_random;
4904 ei_to->move_pattern = ei_from->move_pattern;
4905 ei_to->move_direction_initial = ei_from->move_direction_initial;
4906 ei_to->move_stepsize = ei_from->move_stepsize;
4908 ei_to->slippery_type = ei_from->slippery_type;
4910 for (y = 0; y < 3; y++)
4911 for (x = 0; x < 3; x++)
4912 ei_to->content[x][y] = ei_from->content[x][y];
4914 ei_to->num_change_pages = ei_from->num_change_pages;
4915 setElementChangePages(ei_to, ei_to->num_change_pages);
4917 for (i=0; i < ei_to->num_change_pages; i++)
4919 struct ElementChangeInfo *change_to = &ei_to->change_page[i];
4920 struct ElementChangeInfo *change_from = &ei_from->change_page[i];
4922 /* always start with reliable default values */
4923 setElementChangeInfoToDefaults(change_to);
4925 change_to->events = change_from->events;
4927 change_to->target_element = change_from->target_element;
4929 change_to->delay_fixed = change_from->delay_fixed;
4930 change_to->delay_random = change_from->delay_random;
4931 change_to->delay_frames = change_from->delay_frames;
4933 change_to->trigger_element = change_from->trigger_element;
4935 change_to->explode = change_from->explode;
4936 change_to->use_content = change_from->use_content;
4937 change_to->only_complete = change_from->only_complete;
4938 change_to->use_random_change = change_from->use_random_change;
4940 change_to->random = change_from->random;
4941 change_to->power = change_from->power;
4943 for (y = 0; y < 3; y++)
4944 for (x = 0; x < 3; x++)
4945 change_to->content[x][y] = change_from->content[x][y];
4947 change_to->can_change = change_from->can_change;
4949 change_to->sides = change_from->sides;
4952 /* mark this custom element as modified */
4953 ei_to->modified_settings = TRUE;
4956 static void replace_custom_element_in_settings(int element_from,
4961 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
4963 struct ElementInfo *ei = &element_info[i];
4965 for (y = 0; y < 3; y++)
4966 for (x = 0; x < 3; x++)
4967 if (ei->content[x][y] == element_from)
4968 ei->content[x][y] = element_to;
4970 for (j=0; j < ei->num_change_pages; j++)
4972 struct ElementChangeInfo *change = &ei->change_page[j];
4974 if (change->target_element == element_from)
4975 change->target_element = element_to;
4977 if (change->trigger_element == element_from)
4978 change->trigger_element = element_to;
4980 for (y = 0; y < 3; y++)
4981 for (x = 0; x < 3; x++)
4982 if (change->content[x][y] == element_from)
4983 change->content[x][y] = element_to;
4988 static void replace_custom_element_in_playfield(int element_from,
4993 for (x = 0; x < lev_fieldx; x++)
4994 for (y = 0; y < lev_fieldy; y++)
4995 if (Feld[x][y] == element_from)
4996 Feld[x][y] = element_to;
4999 static void CopyCustomElement(int element_old, int element_new, int copy_mode)
5001 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
5003 copy_custom_element_settings(element_new, element_old);
5005 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
5007 copy_custom_element_settings(element_old, element_new);
5009 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
5011 copy_custom_element_settings(element_old, EL_DUMMY);
5012 copy_custom_element_settings(element_new, element_old);
5013 copy_custom_element_settings(EL_DUMMY, element_new);
5015 replace_custom_element_in_settings(element_old, EL_DUMMY);
5016 replace_custom_element_in_settings(element_new, element_old);
5017 replace_custom_element_in_settings(EL_DUMMY, element_new);
5019 replace_custom_element_in_playfield(element_old, EL_DUMMY);
5020 replace_custom_element_in_playfield(element_new, element_old);
5021 replace_custom_element_in_playfield(EL_DUMMY, element_new);
5024 UpdateCustomElementGraphicGadgets();
5025 DrawPropertiesWindow();
5028 static void CopyCustomElementPropertiesToEditor(int element)
5031 int current_change_page = element_info[element].current_change_page;
5033 /* dynamically (re)build selectbox for selecting change page */
5034 for (i = 0; i < element_info[element].num_change_pages; i++)
5036 sprintf(options_change_page_strings[i], "%d", i + 1);
5038 options_change_page[i].value = i;
5039 options_change_page[i].text = options_change_page_strings[i];
5042 options_change_page[i].value = -1;
5043 options_change_page[i].text = NULL;
5045 /* needed here to initialize combined element properties */
5046 InitElementPropertiesEngine(level.game_version);
5048 element_info[element].change =
5049 &element_info[element].change_page[current_change_page];
5051 custom_element = element_info[element];
5052 custom_element_change = *element_info[element].change;
5054 /* needed to initially set selectbox value variables to reliable defaults */
5055 for (i = 0; i < ED_NUM_SELECTBOX; i++)
5056 setSelectboxValue(i, *selectbox_info[i].value);
5058 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
5059 custom_element_properties[i] = HAS_PROPERTY(element, i);
5061 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
5062 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
5064 /* ---------- element settings: configure (custom elements) ------------- */
5066 /* set accessible layer selectbox help value */
5067 custom_element.access_type =
5068 (IS_WALKABLE(element) ? EP_WALKABLE :
5069 IS_PASSABLE(element) ? EP_PASSABLE :
5070 custom_element.access_type);
5071 custom_element.access_layer =
5072 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
5073 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
5074 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
5075 custom_element.access_layer);
5076 custom_element_properties[EP_ACCESSIBLE] =
5077 (IS_ACCESSIBLE_OVER(element) ||
5078 IS_ACCESSIBLE_INSIDE(element) ||
5079 IS_ACCESSIBLE_UNDER(element));
5081 /* set walk-to-object action selectbox help value */
5082 custom_element.walk_to_action =
5083 (IS_DIGGABLE(element) ? EP_DIGGABLE :
5084 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
5085 IS_DROPPABLE(element) ? EP_DROPPABLE :
5086 IS_PUSHABLE(element) ? EP_PUSHABLE :
5087 custom_element.walk_to_action);
5088 custom_element_properties[EP_WALK_TO_OBJECT] =
5089 (IS_DIGGABLE(element) ||
5090 IS_COLLECTIBLE_ONLY(element) ||
5091 IS_DROPPABLE(element) ||
5092 IS_PUSHABLE(element));
5094 /* set smash targets selectbox help value */
5095 custom_element.smash_targets =
5096 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
5097 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
5098 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
5099 custom_element.smash_targets);
5100 custom_element_properties[EP_CAN_SMASH] =
5101 (CAN_SMASH_EVERYTHING(element) ||
5102 CAN_SMASH_ENEMIES(element) ||
5103 CAN_SMASH_PLAYER(element));
5105 /* set deadliness selectbox help value */
5106 custom_element.deadliness =
5107 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
5108 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
5109 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
5110 custom_element.deadliness);
5111 custom_element_properties[EP_DEADLY] =
5112 (DONT_TOUCH(element) ||
5113 DONT_COLLIDE_WITH(element) ||
5114 DONT_RUN_INTO(element));
5116 /* set consistency selectbox help value */
5117 custom_element.consistency =
5118 (IS_INDESTRUCTIBLE(element) ? EP_INDESTRUCTIBLE :
5119 CAN_EXPLODE_1X1(element) ? EP_CAN_EXPLODE_1X1 :
5120 CAN_EXPLODE_3X3(element) ? EP_CAN_EXPLODE_3X3 :
5121 CAN_EXPLODE_DYNA(element) ? EP_CAN_EXPLODE_DYNA :
5122 custom_element.consistency);
5123 custom_element_properties[EP_EXPLODE_RESULT] =
5124 (IS_INDESTRUCTIBLE(element) ||
5125 CAN_EXPLODE_1X1(element) ||
5126 CAN_EXPLODE_3X3(element) ||
5127 CAN_EXPLODE_DYNA(element));
5129 /* special case: sub-settings dependent from main setting */
5130 if (CAN_EXPLODE_BY_FIRE(element))
5131 custom_element.can_explode_by_fire = TRUE;
5132 if (CAN_EXPLODE_SMASHED(element))
5133 custom_element.can_explode_smashed = TRUE;
5134 if (CAN_EXPLODE_IMPACT(element))
5135 custom_element.can_explode_impact = TRUE;
5137 /* ---------- element settings: advanced (custom elements) --------------- */
5139 /* set "change by direct action" selectbox help value */
5140 custom_element_change.direct_action =
5141 (HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
5142 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
5143 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
5144 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
5145 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
5146 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
5147 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
5148 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
5149 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
5150 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
5151 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
5152 custom_element_change.direct_action);
5154 /* set "change by other element action" selectbox help value */
5155 custom_element_change.other_action =
5156 (HAS_CHANGE_EVENT(element, CE_OTHER_GETS_TOUCHED) ? CE_OTHER_GETS_TOUCHED :
5157 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_PRESSED) ? CE_OTHER_GETS_PRESSED :
5158 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_PUSHED) ? CE_OTHER_GETS_PUSHED :
5159 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_ENTERED) ? CE_OTHER_GETS_ENTERED :
5160 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_LEFT) ? CE_OTHER_GETS_LEFT :
5161 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_DIGGED) ? CE_OTHER_GETS_DIGGED :
5162 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_COLLECTED) ? CE_OTHER_GETS_COLLECTED :
5163 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_DROPPED) ? CE_OTHER_GETS_DROPPED :
5164 HAS_CHANGE_EVENT(element, CE_OTHER_IS_TOUCHING) ? CE_OTHER_IS_TOUCHING :
5165 HAS_CHANGE_EVENT(element, CE_OTHER_IS_HITTING) ? CE_OTHER_IS_HITTING :
5166 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_HIT) ? CE_OTHER_GETS_HIT :
5167 HAS_CHANGE_EVENT(element, CE_OTHER_IS_SWITCHING) ? CE_OTHER_IS_SWITCHING :
5168 HAS_CHANGE_EVENT(element, CE_OTHER_IS_CHANGING) ? CE_OTHER_IS_CHANGING :
5169 HAS_CHANGE_EVENT(element, CE_OTHER_IS_EXPLODING) ? CE_OTHER_IS_EXPLODING :
5170 custom_element_change.other_action);
5173 static void CopyGroupElementPropertiesToEditor(int element)
5175 group_element_info = *element_info[element].group;
5176 custom_element = element_info[element]; /* needed for description */
5179 static void CopyElementPropertiesToEditor(int element)
5181 if (IS_CUSTOM_ELEMENT(element))
5182 CopyCustomElementPropertiesToEditor(element);
5183 else if (IS_GROUP_ELEMENT(element))
5184 CopyGroupElementPropertiesToEditor(element);
5187 static void CopyCustomElementPropertiesToGame(int element)
5190 int access_type_and_layer;
5192 /* mark that this custom element has been modified */
5193 custom_element.modified_settings = TRUE;
5195 if (level.use_custom_template)
5197 if (Request("Copy and modify level template ?", REQ_ASK))
5199 level.use_custom_template = FALSE;
5200 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE],
5201 GDI_CHECKED, FALSE, GDI_END);
5205 LoadLevelTemplate(-1); /* this resets all element modifications ... */
5207 DrawEditModeWindow(); /* ... and copies them to 'custom_element' */
5211 element_info[element] = custom_element;
5212 *element_info[element].change = custom_element_change;
5214 /* ---------- element settings: configure (custom elements) ------------- */
5216 /* set accessible property from checkbox and selectbox */
5217 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
5218 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
5219 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
5220 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
5221 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
5222 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
5223 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
5224 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
5225 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
5226 custom_element_properties[access_type_and_layer] =
5227 custom_element_properties[EP_ACCESSIBLE];
5229 /* set walk-to-object property from checkbox and selectbox */
5230 custom_element_properties[EP_DIGGABLE] = FALSE;
5231 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
5232 custom_element_properties[EP_DROPPABLE] = FALSE;
5233 custom_element_properties[EP_PUSHABLE] = FALSE;
5234 custom_element_properties[custom_element.walk_to_action] =
5235 custom_element_properties[EP_WALK_TO_OBJECT];
5237 /* set smash property from checkbox and selectbox */
5238 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
5239 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
5240 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
5241 custom_element_properties[custom_element.smash_targets] =
5242 custom_element_properties[EP_CAN_SMASH];
5244 /* set deadliness property from checkbox and selectbox */
5245 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
5246 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
5247 custom_element_properties[EP_DONT_TOUCH] = FALSE;
5248 custom_element_properties[custom_element.deadliness] =
5249 custom_element_properties[EP_DEADLY];
5251 /* set consistency property from checkbox and selectbox */
5252 custom_element_properties[EP_INDESTRUCTIBLE] = FALSE;
5253 custom_element_properties[EP_CAN_EXPLODE_1X1] = FALSE;
5254 custom_element_properties[EP_CAN_EXPLODE_3X3] = FALSE;
5255 custom_element_properties[EP_CAN_EXPLODE_DYNA] = FALSE;
5256 custom_element_properties[EP_CAN_EXPLODE_BY_FIRE] = FALSE;
5257 custom_element_properties[EP_CAN_EXPLODE_SMASHED] = FALSE;
5258 custom_element_properties[EP_CAN_EXPLODE_IMPACT] = FALSE;
5259 custom_element_properties[custom_element.consistency] =
5260 custom_element_properties[EP_EXPLODE_RESULT];
5262 /* special case: sub-settings dependent from main setting */
5263 if (custom_element_properties[EP_CAN_EXPLODE_1X1] ||
5264 custom_element_properties[EP_CAN_EXPLODE_3X3] ||
5265 custom_element_properties[EP_CAN_EXPLODE_DYNA])
5267 custom_element_properties[EP_CAN_EXPLODE_BY_FIRE] =
5268 custom_element.can_explode_by_fire;
5269 custom_element_properties[EP_CAN_EXPLODE_SMASHED] =
5270 custom_element.can_explode_smashed;
5271 custom_element_properties[EP_CAN_EXPLODE_IMPACT] =
5272 custom_element.can_explode_impact;
5275 /* ---------- element settings: advanced (custom elements) --------------- */
5277 /* set player change event from checkbox and selectbox */
5278 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
5279 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
5280 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
5281 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
5282 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
5283 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
5284 custom_element_change_events[CE_SWITCHED] = FALSE;
5285 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
5286 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
5287 custom_element_change_events[CE_IMPACT] = FALSE;
5288 custom_element_change_events[CE_SMASHED] = FALSE;
5289 custom_element_change_events[custom_element_change.direct_action] =
5290 custom_element_change_events[CE_BY_DIRECT_ACTION];
5292 /* set other element action change event from checkbox and selectbox */
5293 custom_element_change_events[CE_OTHER_GETS_TOUCHED] = FALSE;
5294 custom_element_change_events[CE_OTHER_GETS_PRESSED] = FALSE;
5295 custom_element_change_events[CE_OTHER_GETS_PUSHED] = FALSE;
5296 custom_element_change_events[CE_OTHER_GETS_ENTERED] = FALSE;
5297 custom_element_change_events[CE_OTHER_GETS_LEFT] = FALSE;
5298 custom_element_change_events[CE_OTHER_GETS_DIGGED] = FALSE;
5299 custom_element_change_events[CE_OTHER_GETS_COLLECTED] = FALSE;
5300 custom_element_change_events[CE_OTHER_GETS_DROPPED] = FALSE;
5301 custom_element_change_events[CE_OTHER_IS_TOUCHING] = FALSE;
5302 custom_element_change_events[CE_OTHER_IS_HITTING] = FALSE;
5303 custom_element_change_events[CE_OTHER_GETS_HIT] = FALSE;
5304 custom_element_change_events[CE_OTHER_IS_SWITCHING] = FALSE;
5305 custom_element_change_events[CE_OTHER_IS_CHANGING] = FALSE;
5306 custom_element_change_events[CE_OTHER_IS_EXPLODING] = FALSE;
5307 custom_element_change_events[custom_element_change.other_action] =
5308 custom_element_change_events[CE_BY_OTHER_ACTION];
5310 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
5311 SET_PROPERTY(element, i, custom_element_properties[i]);
5313 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
5314 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
5316 /* copy change events also to special level editor variable */
5317 custom_element = element_info[element];
5318 custom_element_change = *element_info[element].change;
5321 static void CopyGroupElementPropertiesToGame(int element)
5323 element_info[element] = custom_element;
5324 *element_info[element].group = group_element_info;
5326 /* mark that this group element has been modified */
5327 element_info[element].modified_settings = TRUE;
5330 static void CopyElementPropertiesToGame(int element)
5332 if (IS_CUSTOM_ELEMENT(element))
5333 CopyCustomElementPropertiesToGame(element);
5334 else if (IS_GROUP_ELEMENT(element))
5335 CopyGroupElementPropertiesToGame(element);
5340 CloseDoor(DOOR_CLOSE_ALL);
5341 OpenDoor(DOOR_OPEN_2 | DOOR_NO_DELAY);
5343 if (level_editor_test_game)
5345 CopyPlayfield(level.field, Feld);
5346 CopyPlayfield(FieldBackup, level.field);
5348 level_editor_test_game = FALSE;
5352 edit_mode = ED_MODE_DRAWING;
5353 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
5361 /* copy default editor door content to main double buffer */
5362 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
5363 DOOR_GFX_PAGEX6, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
5366 /* draw mouse button brush elements */
5367 RedrawDrawingElements();
5370 /* draw bigger door */
5371 DrawSpecialEditorDoor();
5373 /* draw new control window */
5374 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
5375 DOOR_GFX_PAGEX8, 236, EXSIZE, EYSIZE, EX, EY);
5377 redraw_mask |= REDRAW_ALL;
5379 ReinitializeElementListButtons(); /* only needed after setup changes */
5381 ModifyEditorElementList(); /* may be needed for custom elements */
5385 MapControlButtons();
5387 DrawEditModeWindow();
5389 /* copy actual editor door content to door double buffer for OpenDoor() */
5390 BlitBitmap(drawto, bitmap_db_door,
5391 DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
5393 OpenDoor(DOOR_OPEN_1);
5396 static void AdjustDrawingAreaGadgets()
5398 int ed_xsize = lev_fieldx + 2;
5399 int ed_ysize = lev_fieldy + 2;
5400 int max_ed_fieldx = MAX_ED_FIELDX;
5401 int max_ed_fieldy = MAX_ED_FIELDY;
5402 boolean horizontal_scrollbar_needed;
5403 boolean vertical_scrollbar_needed;
5404 int x, y, width, height;
5405 int xoffset, yoffset;
5407 /* check if we need any scrollbars */
5408 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
5409 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
5411 /* check if we have a smaller editor field because of scrollbars */
5412 if (horizontal_scrollbar_needed)
5413 max_ed_fieldy = MAX_ED_FIELDY - 1;
5414 if (vertical_scrollbar_needed)
5415 max_ed_fieldx = MAX_ED_FIELDX - 1;
5417 /* check again if we now need more scrollbars because of less space */
5418 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
5419 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
5421 /* check if editor field gets even smaller after adding new scrollbars */
5422 if (horizontal_scrollbar_needed)
5423 max_ed_fieldy = MAX_ED_FIELDY - 1;
5424 if (vertical_scrollbar_needed)
5425 max_ed_fieldx = MAX_ED_FIELDX - 1;
5427 ed_fieldx = (ed_xsize < MAX_ED_FIELDX ? ed_xsize : max_ed_fieldx);
5428 ed_fieldy = (ed_ysize < MAX_ED_FIELDY ? ed_ysize : max_ed_fieldy);
5430 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
5431 GDI_WIDTH, ed_fieldx * MINI_TILEX,
5432 GDI_HEIGHT, ed_fieldy * MINI_TILEY,
5433 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
5436 xoffset = (ed_fieldx == MAX_ED_FIELDX ? ED_SCROLLBUTTON_XSIZE : 0);
5437 yoffset = (ed_fieldy == MAX_ED_FIELDY ? ED_SCROLLBUTTON_YSIZE : 0);
5439 x = SX + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_RIGHT].x + xoffset;
5440 y = SX + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_DOWN].y + yoffset;
5442 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT], GDI_X, x, GDI_END);
5443 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN], GDI_Y, y, GDI_END);
5445 width = scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width + xoffset;
5446 height = scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].height + yoffset;
5448 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
5450 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
5452 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
5454 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
5458 static void AdjustLevelScrollPosition()
5460 if (level_xpos < -1)
5462 if (level_xpos > lev_fieldx - ed_fieldx + 1)
5463 level_xpos = lev_fieldx - ed_fieldx + 1;
5464 if (lev_fieldx < ed_fieldx - 2)
5467 if (level_ypos < -1)
5469 if (level_ypos > lev_fieldy - ed_fieldy + 1)
5470 level_ypos = lev_fieldy - ed_fieldy + 1;
5471 if (lev_fieldy < ed_fieldy - 2)
5475 static void AdjustEditorScrollbar(int id)
5477 struct GadgetInfo *gi = level_editor_gadget[id];
5478 int items_max, items_visible, item_position;
5480 if (id == GADGET_ID_SCROLL_HORIZONTAL)
5482 items_max = MAX(lev_fieldx + 2, ed_fieldx);
5483 items_visible = ed_fieldx;
5484 item_position = level_xpos + 1;
5488 items_max = MAX(lev_fieldy + 2, ed_fieldy);
5489 items_visible = ed_fieldy;
5490 item_position = level_ypos + 1;
5493 if (item_position > items_max - items_visible)
5494 item_position = items_max - items_visible;
5496 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
5497 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
5500 static void ModifyEditorCounter(int counter_id, int new_value)
5502 int *counter_value = counterbutton_info[counter_id].value;
5503 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
5504 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
5506 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
5508 if (counter_value != NULL)
5509 *counter_value = gi->textinput.number_value;
5512 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
5514 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
5515 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
5517 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
5520 static void ModifyEditorSelectbox(int selectbox_id, int new_value)
5522 int gadget_id = selectbox_info[selectbox_id].gadget_id;
5523 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
5524 int new_index_value = setSelectboxValue(selectbox_id, new_value);
5526 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
5529 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
5531 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
5532 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
5534 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
5537 static void ModifyEditorElementList()
5541 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
5543 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
5544 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
5545 struct GadgetDesign *gd = &gi->deco.design;
5546 int element = editor_elements[element_shift + i];
5549 getMiniGraphicSource(el2edimg(element), &gd->bitmap, &gd->x, &gd->y);
5550 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
5555 static void PickDrawingElement(int button, int element)
5557 if (button < 1 || button > 3)
5562 new_element1 = element;
5563 DrawMiniGraphicExt(drawto,
5564 DX + ED_WIN_MB_LEFT_XPOS, DY + ED_WIN_MB_LEFT_YPOS,
5565 el2edimg(new_element1));
5567 else if (button == 2)
5569 new_element2 = element;
5570 DrawMiniGraphicExt(drawto,
5571 DX + ED_WIN_MB_MIDDLE_XPOS, DY + ED_WIN_MB_MIDDLE_YPOS,
5572 el2edimg(new_element2));
5576 new_element3 = element;
5577 DrawMiniGraphicExt(drawto,
5578 DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS,
5579 el2edimg(new_element3));
5582 redraw_mask |= REDRAW_DOOR_1;
5585 static void RedrawDrawingElements()
5587 PickDrawingElement(1, new_element1);
5588 PickDrawingElement(2, new_element2);
5589 PickDrawingElement(3, new_element3);
5592 static void DrawDrawingWindow()
5594 stick_element_properties_window = FALSE;
5596 SetMainBackgroundImage(IMG_UNDEFINED);
5599 UnmapLevelEditorWindowGadgets();
5600 UnmapLevelEditorToolboxCustomGadgets();
5602 AdjustDrawingAreaGadgets();
5603 AdjustLevelScrollPosition();
5604 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
5605 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
5607 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
5609 MapMainDrawingArea();
5610 MapLevelEditorToolboxDrawingGadgets();
5613 static void DrawLevelInfoWindow()
5617 stick_element_properties_window = FALSE;
5619 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
5621 UnmapLevelEditorWindowGadgets();
5623 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS1_YPOS,
5624 "Level Settings", FONT_TITLE_1);
5625 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS2_YPOS,
5626 "Editor Settings", FONT_TITLE_1);
5628 /* draw counter gadgets */
5629 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
5630 MapCounterButtons(i);
5632 /* draw checkbutton gadgets */
5633 for (i=ED_CHECKBUTTON_ID_LEVEL_FIRST; i <= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
5634 MapCheckbuttonGadget(i);
5636 /* draw radiobutton gadgets */
5637 for (i=ED_RADIOBUTTON_ID_LEVEL_FIRST; i <= ED_RADIOBUTTON_ID_LEVEL_LAST; i++)
5638 MapRadiobuttonGadget(i);
5640 /* draw text input gadgets */
5641 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
5642 MapTextInputGadget(i);
5644 /* draw drawing area */
5645 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
5648 static void DrawCustomContentArea()
5650 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
5651 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
5652 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
5653 int x2 = right_gadget_border[GADGET_ID_CUSTOM_CONSISTENCY];
5654 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
5655 int xoffset = ED_DRAWINGAREA_TEXT_DISTANCE;
5657 /* add distance for potential left text (without drawing area border) */
5658 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
5660 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
5662 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
5665 static void DrawCustomChangeContentArea()
5667 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
5668 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
5669 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
5670 int x2 = right_gadget_border[GADGET_ID_CHANGE_POWER];
5671 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
5672 int xoffset = ED_DRAWINGAREA_TEXT_DISTANCE;
5674 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
5679 static void DrawElementContentAreas()
5681 int x = SX + ED_AREA_YAMYAM_CONTENT_XPOS(3) + 4 * MINI_TILEX;
5682 int y = SY + ED_AREA_YAMYAM_CONTENT_YPOS(0) + ED_BORDER_AREA_YSIZE;
5685 /* display counter to choose number of element content areas */
5686 MapCounterButtons(ED_COUNTER_ID_ELEMENT_CONTENT);
5688 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
5690 int id = ED_DRAWING_ID_ELEMENT_CONTENT_0 + i;
5691 int font_height = getFontHeight(FONT_TEXT_1);
5693 if (i < level.num_yamyam_contents)
5697 UnmapDrawingArea(id);
5699 /* delete content areas in case of reducing number of them */
5700 DrawBackground(SX + drawingarea_info[id].x - MINI_TILEX / 2,
5701 SY + drawingarea_info[id].y - MINI_TILEY / 2,
5703 4 * MINI_TILEY + ED_GADGET_TEXT_DISTANCE + font_height);
5707 DrawText(x, y + 0 * MINI_TILEY, "content", FONT_TEXT_1);
5708 DrawText(x, y + 1 * MINI_TILEY, "when", FONT_TEXT_1);
5709 DrawText(x, y + 2 * MINI_TILEY, "smashed", FONT_TEXT_1);
5712 static void DrawGroupElementArea(int element)
5714 int num_elements = group_element_info.num_elements;
5715 int id = ED_DRAWING_ID_GROUP_CONTENT;
5716 int sx = SX + drawingarea_info[id].x - MINI_TILEX / 2;
5717 int sy = SY + drawingarea_info[id].y - MINI_TILEY / 2;
5718 int xsize = MAX_ELEMENTS_IN_GROUP;
5721 if (drawingarea_info[id].text_left != NULL)
5722 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
5724 UnmapDrawingArea(id);
5726 ModifyEditorDrawingArea(id, num_elements, 1);
5728 /* delete content areas in case of reducing number of them */
5729 DrawBackground(sx, sy, (xsize + 1) * MINI_TILEX, (ysize + 1) * MINI_TILEY);
5734 static void DrawEnvelopeTextArea(int envelope_nr)
5736 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
5737 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
5740 DrawBackground(gi->x, gi->y, gi->width, gi->height);
5742 if (envelope_nr != -1)
5743 textarea_info[id].value = level.envelope_text[envelope_nr];
5745 ModifyGadget(gi, GDI_AREA_SIZE,
5746 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
5747 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
5750 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
5753 char *getElementDescriptionFilename(int element)
5755 char *docs_dir = options.docs_directory;
5756 char *elements_subdir = "elements";
5757 static char *filename = NULL;
5758 char basename[MAX_FILENAME_LEN];
5760 checked_free(filename);
5762 /* 1st try: look for element description file for exactly this element */
5763 sprintf(basename, "%s.txt", element_info[element].token_name);
5764 filename = getPath3(docs_dir, elements_subdir, basename);
5765 if (fileExists(filename))
5770 /* 2nd try: look for element description file for this element's class */
5771 sprintf(basename, "%s.txt", element_info[element].class_name);
5772 filename = getPath3(docs_dir, elements_subdir, basename);
5773 if (fileExists(filename))
5779 static boolean PrintInfoText(char *text, int font_nr, int start_line)
5781 int font_height = getFontHeight(font_nr);
5782 int pad_x = ED_SETTINGS_XPOS(0);
5783 int pad_y = ED_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
5784 int sx = SX + pad_x;
5785 int sy = SY + pad_y;
5786 int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
5788 if (start_line >= max_lines_per_screen)
5791 DrawText(sx, sy + start_line * font_height, text, font_nr);
5798 static int PrintElementDescriptionFromFile(char *filename, int start_line)
5800 int font_nr = FONT_TEXT_2;
5801 int font_width = getFontWidth(font_nr);
5802 int font_height = getFontHeight(font_nr);
5803 int pad_x = ED_SETTINGS_XPOS(0);
5804 int pad_y = ED_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
5805 int sx = SX + pad_x;
5806 int sy = SY + pad_y + start_line * font_height;
5807 int max_chars_per_line = (SXSIZE - 2 * pad_x) / font_width;
5808 int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
5810 return DrawTextFromFile(sx, sy, filename, font_nr, max_chars_per_line,
5811 max_lines_per_screen);
5816 static int PrintElementDescriptionFromFile(char *filename, int start_line)
5818 int font_nr = FONT_TEXT_2;
5819 int font_width = getFontWidth(font_nr);
5820 int font_height = getFontHeight(font_nr);
5821 int pad_x = ED_SETTINGS_XPOS(0);
5822 int pad_y = ED_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
5823 int sx = SX + pad_x;
5824 int sy = SY + pad_y;
5825 int max_chars_per_line = (SXSIZE - 2 * pad_x) / font_width;
5826 int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
5827 int current_line = start_line;
5828 char line[MAX_LINE_LEN];
5829 char buffer[max_chars_per_line + 1];
5833 if (current_line >= max_lines_per_screen)
5836 if (filename == NULL)
5839 if (!(file = fopen(filename, MODE_READ)))
5845 while (!feof(file) && current_line < max_lines_per_screen)
5848 boolean last_line_was_empty = TRUE;
5850 /* read next line of input file */
5851 if (!fgets(line, MAX_LINE_LEN, file))
5854 /* skip comments (lines directly beginning with '#') */
5858 /* cut trailing newline from input line */
5859 for (line_ptr = line; *line_ptr; line_ptr++)
5861 if (*line_ptr == '\n' || *line_ptr == '\r')
5868 if (strlen(line) == 0) /* special case: force empty line */
5873 while (*line_ptr && current_line < max_lines_per_screen)
5875 boolean buffer_filled = RenderLineToBuffer(&line_ptr,
5876 buffer, &buffer_len,
5877 last_line_was_empty,
5878 max_chars_per_line);
5881 DrawText(sx, sy + current_line * font_height, buffer, font_nr);
5884 last_line_was_empty = (buffer_len == 0);
5894 if (buffer_len > 0 && current_line < max_lines_per_screen)
5896 DrawText(sx, sy + current_line * font_height, buffer, font_nr);
5900 return (current_line - start_line);
5905 static void DrawPropertiesTabulatorGadgets()
5907 struct GadgetInfo *gd_gi = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
5908 struct GadgetDesign *gd = &gd_gi->alt_design[GD_BUTTON_UNPRESSED];
5909 int gd_x = gd->x + gd_gi->border.width / 2;
5910 int gd_y = gd->y + gd_gi->height - 1;
5911 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
5912 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
5913 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
5916 /* draw additional "advanced" tabulator for custom elements */
5917 if (IS_CUSTOM_ELEMENT(properties_element) ||
5918 IS_GROUP_ELEMENT(properties_element))
5919 id_last = ED_TEXTBUTTON_ID_PROPERTIES_ADVANCED;
5921 for (i = id_first; i <= id_last; i++)
5923 int gadget_id = textbutton_info[i].gadget_id;
5924 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
5925 boolean active = (i != edit_mode_properties);
5927 /* draw background line below tabulator button */
5928 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width,1);
5930 /* draw solid line below inactive tabulator buttons */
5931 if (!active && tab_color != BLACK_PIXEL) /* black => transparent */
5932 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,1, tab_color);
5934 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
5935 MapTextbuttonGadget(i);
5938 /* draw little border line below tabulator buttons */
5939 if (tab_color != BLACK_PIXEL) /* black => transparent */
5940 FillRectangle(drawto, gd_gi->x, gd_gi->y + gd_gi->height + 1,
5941 3 * gd_gi->width + 2 * ED_GADGET_DISTANCE,
5942 ED_GADGET_DISTANCE, tab_color);
5945 static void DrawPropertiesInfo()
5954 /* configurable properties */
5956 { EP_WALKABLE_OVER, "- player can walk over it" },
5957 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
5958 { EP_WALKABLE_UNDER, "- player can walk under it" },
5959 { EP_PASSABLE_OVER, "- player can pass over it" },
5960 { EP_PASSABLE_INSIDE, "- player can pass through it" },
5961 { EP_PASSABLE_UNDER, "- player can pass under it" },
5963 { EP_DIGGABLE, "- can be digged away" },
5964 { EP_COLLECTIBLE, "- can be collected" },
5965 { EP_DROPPABLE, "- can be dropped after collecting" },
5966 { EP_PUSHABLE, "- can be pushed" },
5968 { EP_CAN_MOVE, "- can move" },
5969 { EP_CAN_FALL, "- can fall" },
5971 { EP_CAN_SMASH_PLAYER, "- can smash player" },
5973 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
5975 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
5977 { EP_SLIPPERY, "- slippery for falling objects" },
5978 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
5980 { EP_DONT_RUN_INTO, "- deadly when running into" },
5981 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
5982 { EP_DONT_TOUCH, "- deadly when touching" },
5984 { EP_INDESTRUCTIBLE, "- indestructible" },
5986 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
5987 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
5988 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
5990 { EP_CAN_CHANGE, "- can change to other element" },
5992 /* pre-defined properties */
5993 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
5994 { EP_HAS_CONTENT, "- can contain other elements" },
5998 char *filename = getElementDescriptionFilename(properties_element);
5999 char *percentage_text = "In this level:";
6000 char *properties_text = "Standard properties:";
6002 int num_elements_in_level;
6003 int num_standard_properties = 0;
6004 int font1_nr = FONT_TEXT_1;
6005 int font2_nr = FONT_TEXT_2;
6006 int font1_width = getFontWidth(font1_nr);
6007 int font2_height = getFontHeight(font2_nr);
6008 int pad_x = ED_SETTINGS_XPOS(0);
6009 int pad_y = ED_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
6010 int screen_line = 0;
6014 if (IS_CUSTOM_ELEMENT(properties_element))
6016 DrawTextF(pad_x, pad_y + screen_line++ * font2_height, FONT_TEXT_3,
6017 "[Custom Element %d]", properties_element - EL_CUSTOM_START + 1);
6020 else if (IS_GROUP_ELEMENT(properties_element))
6022 DrawTextF(pad_x, pad_y + screen_line++ * font2_height, FONT_TEXT_3,
6023 "[Group Element %d]", properties_element - EL_GROUP_START + 1);
6028 /* ----- print number of elements / percentage of this element in level */
6030 num_elements_in_level = 0;
6031 for (y = 0; y < lev_fieldy; y++)
6032 for (x = 0; x < lev_fieldx; x++)
6033 if (Feld[x][y] == properties_element)
6034 num_elements_in_level++;
6035 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
6037 DrawTextS(pad_x, pad_y + screen_line * font2_height, font1_nr,
6039 DrawTextF(pad_x + strlen(percentage_text) * font1_width,
6040 pad_y + screen_line++ * font2_height, font2_nr,
6041 "%d (%.2f%%)", num_elements_in_level, percentage);
6045 /* ----- print standard properties of this element */
6047 DrawTextS(pad_x, pad_y + screen_line++ * font2_height, font1_nr,
6050 for (i = 0; properties[i].value != -1; i++)
6052 if (!HAS_PROPERTY(properties_element, properties[i].value))
6055 DrawTextS(pad_x, pad_y + screen_line++ * font2_height, font2_nr,
6056 properties[i].text);
6057 num_standard_properties++;
6060 if (num_standard_properties == 0)
6061 DrawTextS(pad_x + strlen(properties_text) * font1_width,
6062 pad_y + (screen_line - 1) * font2_height, font2_nr, "none");
6066 /* ----- print special description of this element */
6068 PrintInfoText("Description:", FONT_TEXT_1, screen_line);
6069 if (PrintElementDescriptionFromFile(filename, screen_line + 1) == 0)
6070 PrintInfoText("No description available.", FONT_TEXT_1, screen_line);
6073 #define TEXT_COLLECTING "Score for collecting"
6074 #define TEXT_SMASHING "Score for smashing"
6075 #define TEXT_CRACKING "Score for cracking"
6076 #define TEXT_SPEED "Speed of amoeba growth"
6077 #define TEXT_DURATION "Duration when activated"
6084 } elements_with_counter[] =
6086 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
6087 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
6088 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
6089 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
6090 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
6091 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
6092 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
6093 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
6094 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
6095 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
6096 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
6097 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
6098 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
6099 { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
6100 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
6101 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
6102 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
6103 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
6104 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6105 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6106 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6107 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6108 { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
6109 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6110 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6111 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6112 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6113 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
6114 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
6115 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
6116 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
6117 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
6118 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
6119 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
6120 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
6121 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
6122 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE],TEXT_COLLECTING },
6123 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
6124 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
6125 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
6126 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
6127 { EL_EXTRA_TIME, &level.score[SC_TIME_BONUS], TEXT_COLLECTING },
6128 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
6129 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
6130 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
6131 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
6133 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
6134 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
6135 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
6136 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
6138 { EL_EM_KEY_1_FILE, &level.score[SC_KEY], TEXT_COLLECTING },
6139 { EL_EM_KEY_2_FILE, &level.score[SC_KEY], TEXT_COLLECTING },
6140 { EL_EM_KEY_3_FILE, &level.score[SC_KEY], TEXT_COLLECTING },
6141 { EL_EM_KEY_4_FILE, &level.score[SC_KEY], TEXT_COLLECTING },
6143 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_SPEED },
6144 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_SPEED },
6145 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_SPEED },
6146 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_SPEED },
6147 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
6148 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
6152 static boolean checkPropertiesConfig()
6156 if (IS_GEM(properties_element) ||
6157 IS_CUSTOM_ELEMENT(properties_element) ||
6158 IS_GROUP_ELEMENT(properties_element) ||
6159 IS_ENVELOPE(properties_element) ||
6160 HAS_CONTENT(properties_element))
6163 for (i = 0; elements_with_counter[i].element != -1; i++)
6164 if (elements_with_counter[i].element == properties_element)
6170 static void DrawPropertiesConfig()
6174 if (!checkPropertiesConfig())
6176 PrintInfoText("No configuration options available.", FONT_TEXT_1, 0);
6181 /* check if there are elements where a score can be chosen for */
6182 for (i = 0; elements_with_counter[i].element != -1; i++)
6184 if (elements_with_counter[i].element == properties_element)
6186 int counter_id = ED_COUNTER_ID_ELEMENT_SCORE;
6188 counterbutton_info[counter_id].value = elements_with_counter[i].value;
6189 counterbutton_info[counter_id].text_right= elements_with_counter[i].text;
6190 MapCounterButtons(counter_id);
6196 if (HAS_CONTENT(properties_element))
6198 /* draw stickybutton gadget */
6199 i = ED_CHECKBUTTON_ID_STICK_ELEMENT;
6200 checkbutton_info[i].y = ED_COUNTER_YPOS(4);
6201 MapCheckbuttonGadget(i);
6203 if (IS_AMOEBOID(properties_element))
6204 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
6206 DrawElementContentAreas();
6209 if (IS_GEM(properties_element))
6210 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
6212 if (IS_ENVELOPE(properties_element))
6214 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
6215 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
6216 int envelope_nr = properties_element - EL_ENVELOPE_1;
6218 counterbutton_info[counter1_id].value = &level.envelope_xsize[envelope_nr];
6219 counterbutton_info[counter2_id].value = &level.envelope_ysize[envelope_nr];
6221 /* display counter to choose size of envelope text area */
6222 MapCounterButtons(ED_COUNTER_ID_ENVELOPE_XSIZE);
6223 MapCounterButtons(ED_COUNTER_ID_ENVELOPE_YSIZE);
6225 DrawEnvelopeTextArea(envelope_nr);
6228 if (IS_CUSTOM_ELEMENT(properties_element))
6230 /* draw stickybutton gadget */
6231 i = ED_CHECKBUTTON_ID_STICK_ELEMENT;
6232 checkbutton_info[i].y = ED_SETTINGS_YPOS(0);
6233 MapCheckbuttonGadget(i);
6235 /* draw checkbutton gadgets */
6236 for (i = ED_CHECKBUTTON_ID_CUSTOM_FIRST;
6237 i <= ED_CHECKBUTTON_ID_CUSTOM_LAST; i++)
6238 MapCheckbuttonGadget(i);
6240 /* draw counter gadgets */
6241 for (i = ED_COUNTER_ID_CUSTOM_FIRST; i <= ED_COUNTER_ID_CUSTOM_LAST; i++)
6242 MapCounterButtons(i);
6244 /* draw selectbox gadgets */
6245 for (i=ED_SELECTBOX_ID_CUSTOM_FIRST; i <= ED_SELECTBOX_ID_CUSTOM_LAST; i++)
6246 MapSelectboxGadget(i);
6248 /* draw drawing area gadgets */
6249 DrawCustomContentArea();
6250 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
6251 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
6253 /* draw text input gadgets */
6254 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
6256 else if (IS_GROUP_ELEMENT(properties_element))
6258 /* draw stickybutton gadget */
6259 i = ED_CHECKBUTTON_ID_STICK_ELEMENT;
6260 checkbutton_info[i].y = ED_SETTINGS_YPOS(0);
6261 MapCheckbuttonGadget(i);
6263 /* draw counter gadgets */
6264 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
6266 /* draw drawing area gadgets */
6267 DrawGroupElementArea(properties_element);
6269 /* draw text input gadgets */
6270 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
6274 static void DrawPropertiesAdvancedDrawingAreas()
6276 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
6278 if (IS_CUSTOM_ELEMENT(properties_element))
6280 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
6281 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
6283 DrawCustomChangeContentArea();
6286 redraw_mask |= REDRAW_FIELD;
6289 static void DrawPropertiesAdvanced()
6293 /* draw stickybutton gadget */
6294 i = ED_CHECKBUTTON_ID_STICK_ELEMENT;
6295 checkbutton_info[i].y = ED_SETTINGS_YPOS(0);
6296 MapCheckbuttonGadget(i);
6298 if (IS_CUSTOM_ELEMENT(properties_element))
6300 /* draw checkbutton gadgets */
6301 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
6302 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
6303 MapCheckbuttonGadget(i);
6305 /* draw counter gadgets */
6306 for (i = ED_COUNTER_ID_CHANGE_FIRST;
6307 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
6308 MapCounterButtons(i);
6310 /* draw selectbox gadgets */
6311 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
6312 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
6313 MapSelectboxGadget(i);
6315 /* draw textbutton gadgets */
6316 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
6317 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
6318 MapTextbuttonGadget(i);
6320 /* draw graphicbutton gadgets */
6321 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
6322 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
6323 MapGraphicbuttonGadget(i);
6325 else if (IS_GROUP_ELEMENT(properties_element))
6327 /* draw checkbutton gadgets */
6328 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
6329 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE);
6331 /* draw textbutton gadgets */
6332 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE);
6335 /* draw drawing area gadgets */
6336 DrawPropertiesAdvancedDrawingAreas();
6339 static void DrawElementName(int x, int y, int element)
6341 char *element_name = getElementInfoText(element);
6342 int font_nr = FONT_TEXT_1;
6343 int font_width = getFontWidth(font_nr);
6344 int font_height = getFontHeight(font_nr);
6345 int max_text_width = SXSIZE - x - ED_SETTINGS_XPOS(0);
6346 int max_chars_per_line = max_text_width / font_width;
6347 char buffer[max_chars_per_line + 1];
6349 if (strlen(element_name) <= max_chars_per_line)
6350 DrawTextS(x, y, font_nr, element_name);
6353 int next_pos = max_chars_per_line;
6355 strncpy(buffer, element_name, max_chars_per_line);
6356 buffer[max_chars_per_line] = '\0';
6358 if (element_name[max_chars_per_line] == ' ')
6364 for (i = max_chars_per_line - 1; i >= 0; i--)
6365 if (buffer[i] == ' ')
6368 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
6375 DrawTextS(x, y - font_height / 2, font_nr, buffer);
6377 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
6378 buffer[max_chars_per_line] = '\0';
6380 DrawTextS(x, y + font_height / 2, font_nr, buffer);
6384 static void DrawPropertiesWindow()
6389 stick_element_properties_window = FALSE;
6391 /* make sure that previous properties edit mode exists for this element */
6392 if (edit_mode_properties == ED_MODE_PROPERTIES_ADVANCED &&
6393 !IS_CUSTOM_ELEMENT(properties_element) &&
6394 !IS_GROUP_ELEMENT(properties_element))
6395 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
6397 CopyElementPropertiesToEditor(properties_element);
6399 UnmapLevelEditorWindowGadgets();
6400 UnmapLevelEditorToolboxDrawingGadgets();
6401 UnmapLevelEditorToolboxCustomGadgets();
6403 if (IS_CUSTOM_ELEMENT(properties_element))
6404 MapLevelEditorToolboxCustomGadgets();
6406 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
6409 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS1_YPOS,
6410 "Element Settings", FONT_TITLE_1);
6412 DrawElementBorder(SX + xstart * MINI_TILEX,
6413 SY + ystart * MINI_TILEY + MINI_TILEY / 2,
6414 TILEX, TILEY, FALSE);
6415 DrawGraphicAnimationExt(drawto,
6416 SX + xstart * MINI_TILEX,
6417 SY + ystart * MINI_TILEY + MINI_TILEY / 2,
6418 el2img(properties_element), -1, NO_MASKING);
6420 FrameCounter = 0; /* restart animation frame counter */
6422 DrawElementName((xstart + 3) * MINI_TILEX, (ystart + 1) * MINI_TILEY,
6423 properties_element);
6425 DrawPropertiesTabulatorGadgets();
6427 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
6428 DrawPropertiesInfo();
6429 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG)
6430 DrawPropertiesConfig();
6431 else /* edit_mode_properties == ED_MODE_PROPERTIES_ADVANCED */
6432 DrawPropertiesAdvanced();
6435 static void UpdateCustomElementGraphicGadgets()
6437 ModifyEditorElementList();
6438 RedrawDrawingElements();
6440 if (edit_mode == ED_MODE_PROPERTIES &&
6441 edit_mode_properties == ED_MODE_PROPERTIES_ADVANCED)
6442 DrawPropertiesAdvancedDrawingAreas();
6445 static void DrawLineElement(int sx, int sy, int element, boolean change_level)
6447 int lx = sx + level_xpos;
6448 int ly = sy + level_ypos;
6450 DrawMiniElement(sx, sy, (element < 0 ? Feld[lx][ly] : element));
6453 Feld[lx][ly] = element;
6456 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
6457 int element, boolean change_level)
6459 if (from_y == to_y) /* horizontal line */
6465 swap_numbers(&from_x, &to_x);
6467 for (x = from_x; x <= to_x; x++)
6468 DrawLineElement(x, y, element, change_level);
6470 else if (from_x == to_x) /* vertical line */
6476 swap_numbers(&from_y, &to_y);
6478 for (y = from_y; y <= to_y; y++)
6479 DrawLineElement(x, y, element, change_level);
6481 else /* diagonal line */
6483 int len_x = ABS(to_x - from_x);
6484 int len_y = ABS(to_y - from_y);
6487 if (len_y < len_x) /* a < 1 */
6489 float a = (float)len_y / (float)len_x;
6492 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
6494 for (x = 0; x <= len_x; x++)
6496 y = (int)(a * x + 0.5) * (to_y < from_y ? -1 : +1);
6497 DrawLineElement(from_x + x, from_y + y, element, change_level);
6502 float a = (float)len_x / (float)len_y;
6505 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
6507 for (y = 0; y <= len_y; y++)
6509 x = (int)(a * y + 0.5) * (to_x < from_x ? -1 : +1);
6510 DrawLineElement(from_x + x, from_y + y, element, change_level);
6516 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
6517 int element, boolean change_level)
6519 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
6520 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
6521 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
6522 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
6525 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
6526 int element, boolean change_level)
6531 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
6533 for (y = from_y; y <= to_y; y++)
6534 DrawLine(from_x, y, to_x, y, element, change_level);
6537 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
6538 int element, boolean change_level)
6540 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
6541 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
6542 int len_x = ABS(to_x - from_x);
6543 int len_y = ABS(to_y - from_y);
6546 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
6548 /* not optimal (some points get drawn twice) but simple,
6549 and fast enough for the few points we are drawing */
6551 for (x = 0; x <= radius; x++)
6555 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
6557 sx = from_x + x * (from_x < to_x2 ? +1 : -1);
6558 sy = from_y + y * (from_y < to_y2 ? +1 : -1);
6559 lx = sx + level_xpos;
6560 ly = sy + level_ypos;
6562 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
6563 DrawLineElement(sx, sy, element, change_level);
6566 for (y = 0; y <= radius; y++)
6570 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
6572 sx = from_x + x * (from_x < to_x2 ? +1 : -1);
6573 sy = from_y + y * (from_y < to_y2 ? +1 : -1);
6574 lx = sx + level_xpos;
6575 ly = sy + level_ypos;
6577 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
6578 DrawLineElement(sx, sy, element, change_level);
6582 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
6583 int element, boolean change_level)
6585 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
6586 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
6588 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
6591 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
6592 #if DRAW_CIRCLES_BUTTON_AVAILABLE
6593 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
6594 int element, boolean change_level)
6596 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
6597 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
6598 int mirror_to_x2 = from_x - (to_x2 - from_x);
6599 int mirror_to_y2 = from_y - (to_y2 - from_y);
6601 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
6602 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
6603 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
6604 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element,change_level);
6608 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
6610 int from_sx, from_sy;
6614 swap_numbers(&from_x, &to_x);
6617 swap_numbers(&from_y, &to_y);
6619 from_sx = SX + from_x * MINI_TILEX;
6620 from_sy = SY + from_y * MINI_TILEY;
6621 to_sx = SX + to_x * MINI_TILEX + MINI_TILEX - 1;
6622 to_sy = SY + to_y * MINI_TILEY + MINI_TILEY - 1;
6624 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
6625 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
6626 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
6627 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
6629 if (from_x == to_x && from_y == to_y)
6630 MarkTileDirty(from_x/2, from_y/2);
6632 redraw_mask |= REDRAW_FIELD;
6635 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
6636 int element, boolean change_level)
6638 if (element == -1 || change_level)
6639 DrawBox(from_x, from_y, to_x, to_y, -1, FALSE);
6641 DrawAreaBorder(from_x, from_y, to_x, to_y);
6644 /* values for CopyBrushExt() */
6645 #define CB_AREA_TO_BRUSH 0
6646 #define CB_BRUSH_TO_CURSOR 1
6647 #define CB_BRUSH_TO_LEVEL 2
6648 #define CB_DELETE_OLD_CURSOR 3
6650 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
6651 int button, int mode)
6653 static short brush_buffer[MAX_ED_FIELDX][MAX_ED_FIELDY];
6654 static int brush_width, brush_height;
6655 static int last_cursor_x = -1, last_cursor_y = -1;
6656 static boolean delete_old_brush;
6657 int new_element = BUTTON_ELEMENT(button);
6660 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
6663 if (mode == CB_AREA_TO_BRUSH)
6665 int from_lx, from_ly;
6668 swap_numbers(&from_x, &to_x);
6671 swap_numbers(&from_y, &to_y);
6673 brush_width = to_x - from_x + 1;
6674 brush_height = to_y - from_y + 1;
6676 from_lx = from_x + level_xpos;
6677 from_ly = from_y + level_ypos;
6679 for (y = 0; y < brush_height; y++)
6681 for (x=0; x < brush_width; x++)
6683 brush_buffer[x][y] = Feld[from_lx + x][from_ly + y];
6686 DrawLineElement(from_x + x, from_y + y, new_element, TRUE);
6691 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
6693 delete_old_brush = FALSE;
6695 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
6696 mode == CB_BRUSH_TO_LEVEL)
6698 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
6699 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
6700 int cursor_from_x = cursor_x - brush_width / 2;
6701 int cursor_from_y = cursor_y - brush_height / 2;
6702 int border_from_x = cursor_x, border_from_y = cursor_y;
6703 int border_to_x = cursor_x, border_to_y = cursor_y;
6705 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
6706 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
6708 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
6709 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
6711 delete_old_brush = FALSE;
6715 for (y = 0; y < brush_height; y++)
6717 for (x = 0; x < brush_width; x++)
6719 int sx = cursor_from_x + x;
6720 int sy = cursor_from_y + y;
6721 int lx = sx + level_xpos;
6722 int ly = sy + level_ypos;
6723 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
6724 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
6725 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
6726 brush_buffer[x][y] : new_element);
6728 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
6730 if (sx < border_from_x)
6732 else if (sx > border_to_x)
6734 if (sy < border_from_y)
6736 else if (sy > border_to_y)
6739 DrawLineElement(sx, sy, element, change_level);
6744 if (mode != CB_DELETE_OLD_CURSOR)
6745 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
6747 last_cursor_x = cursor_x;
6748 last_cursor_y = cursor_y;
6749 delete_old_brush = TRUE;
6753 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
6756 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
6759 static void CopyBrushToLevel(int x, int y, int button)
6761 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
6764 static void CopyBrushToCursor(int x, int y)
6766 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
6769 static void DeleteBrushFromCursor()
6771 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
6774 static void FloodFill(int from_x, int from_y, int fill_element)
6778 static int check[4][2] = { {-1,0}, {0,-1}, {1,0}, {0,1} };
6779 static int safety = 0;
6781 /* check if starting field still has the desired content */
6782 if (Feld[from_x][from_y] == fill_element)
6787 if (safety > lev_fieldx*lev_fieldy)
6788 Error(ERR_EXIT, "Something went wrong in 'FloodFill()'. Please debug.");
6790 old_element = Feld[from_x][from_y];
6791 Feld[from_x][from_y] = fill_element;
6793 for (i = 0; i < 4; i++)
6795 x = from_x + check[i][0];
6796 y = from_y + check[i][1];
6798 if (IN_LEV_FIELD(x,y) && Feld[x][y] == old_element)
6799 FloodFill(x, y, fill_element);
6805 /* values for DrawLevelText() modes */
6807 #define TEXT_SETCURSOR 1
6808 #define TEXT_WRITECHAR 2
6809 #define TEXT_BACKSPACE 3
6810 #define TEXT_NEWLINE 4
6812 #define TEXT_QUERY_TYPING 6
6814 static int DrawLevelText(int sx, int sy, char letter, int mode)
6816 static short delete_buffer[MAX_LEV_FIELDX];
6817 static int start_sx, start_sy;
6818 static int last_sx, last_sy;
6819 static boolean typing = FALSE;
6820 int letter_element = EL_CHAR_ASCII0 + letter;
6823 /* map lower case letters to upper case and convert special characters */
6824 if (letter >= 'a' && letter <= 'z')
6825 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
6826 else if (letter == 'ä' || letter == 'Ä')
6827 letter_element = EL_CHAR_AUMLAUT;
6828 else if (letter == 'ö' || letter == 'Ö')
6829 letter_element = EL_CHAR_OUMLAUT;
6830 else if (letter == 'ü' || letter == 'Ü')
6831 letter_element = EL_CHAR_UUMLAUT;
6832 else if (letter == '^')
6833 letter_element = EL_CHAR_COPYRIGHT;
6835 letter_element = EL_CHAR_ASCII0 + letter;
6837 if (mode != TEXT_INIT)
6842 if (mode != TEXT_SETCURSOR)
6848 lx = last_sx + level_xpos;
6849 ly = last_sy + level_ypos;
6856 DrawLevelText(0, 0, 0, TEXT_END);
6859 start_sx = last_sx = sx;
6860 start_sy = last_sy = sy;
6861 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
6864 case TEXT_SETCURSOR:
6865 DrawMiniElement(last_sx, last_sy, Feld[lx][ly]);
6866 DrawAreaBorder(sx, sy, sx, sy);
6871 case TEXT_WRITECHAR:
6872 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
6874 delete_buffer[sx - start_sx] = Feld[lx][ly];
6875 Feld[lx][ly] = letter_element;
6877 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
6878 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
6879 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
6880 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
6882 DrawLevelText(0, 0, 0, TEXT_END);
6886 case TEXT_BACKSPACE:
6889 Feld[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
6890 DrawMiniElement(sx - 1, sy, Feld[lx - 1][ly]);
6891 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
6896 if (sy + 1 < ed_fieldy - 1 && ly + 1 < lev_fieldy - 1)
6897 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
6899 DrawLevelText(0, 0, 0, TEXT_END);
6903 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
6904 DrawMiniElement(sx, sy, Feld[lx][ly]);
6908 case TEXT_QUERY_TYPING:
6918 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
6919 int element, boolean change_level)
6921 int lx = sx + level_xpos;
6922 int ly = sy + level_ypos;
6925 DrawMiniElement(sx, sy, Feld[lx][ly]);
6927 DrawAreaBorder(sx, sy, sx, sy);
6930 static void CopyLevelToUndoBuffer(int mode)
6932 static boolean accumulated_undo = FALSE;
6933 boolean new_undo_buffer_position = TRUE;
6934 int last_border_element;
6939 case UNDO_IMMEDIATE:
6940 accumulated_undo = FALSE;
6943 case UNDO_ACCUMULATE:
6944 if (accumulated_undo)
6945 new_undo_buffer_position = FALSE;
6946 accumulated_undo = TRUE;
6953 if (new_undo_buffer_position)
6955 /* new position in undo buffer ring */
6956 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
6958 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
6959 undo_buffer_steps++;
6962 for (x = 0; x < lev_fieldx; x++)
6963 for (y = 0; y < lev_fieldy; y++)
6964 UndoBuffer[undo_buffer_position][x][y] = Feld[x][y];
6966 /* check if drawing operation forces change of border style */
6967 last_border_element = BorderElement;
6969 if (BorderElement != last_border_element)
6970 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
6973 static void RandomPlacement(int new_element)
6975 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
6976 int num_free_positions;
6981 /* determine number of free positions for the new elements */
6982 /* (maybe this statement should be formatted a bit more readable...) */
6983 num_free_positions = 0;
6984 for (x = 0; x < lev_fieldx; x++)
6985 for (y = 0; y < lev_fieldy; y++)
6986 if ((free_position[x][y] =
6987 ((random_placement_background_restricted &&
6988 Feld[x][y] == random_placement_background_element) ||
6989 (!random_placement_background_restricted &&
6990 Feld[x][y] != new_element))) == TRUE)
6991 num_free_positions++;
6993 /* determine number of new elements to place there */
6994 num_percentage = num_free_positions * random_placement_value / 100;
6995 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
6996 num_percentage : random_placement_value);
6998 /* if not more free positions than elements to place, fill whole level */
6999 if (num_elements >= num_free_positions)
7001 for (x = 0; x < lev_fieldx; x++)
7002 for (y = 0; y < lev_fieldy; y++)
7003 Feld[x][y] = new_element;
7005 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7006 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7010 while (num_elements > 0)
7012 x = RND(lev_fieldx);
7013 y = RND(lev_fieldy);
7015 /* don't place element at the same position twice */
7016 if (free_position[x][y])
7018 free_position[x][y] = FALSE;
7019 Feld[x][y] = new_element;
7024 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7025 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7028 void WrapLevel(int dx, int dy)
7030 int wrap_dx = lev_fieldx - dx;
7031 int wrap_dy = lev_fieldy - dy;
7034 for (x = 0; x < lev_fieldx; x++)
7035 for (y = 0; y < lev_fieldy; y++)
7036 FieldBackup[x][y] = Feld[x][y];
7038 for (x = 0; x < lev_fieldx; x++)
7039 for (y = 0; y < lev_fieldy; y++)
7041 FieldBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
7043 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7044 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
7047 static void HandleDrawingAreas(struct GadgetInfo *gi)
7049 static boolean started_inside_drawing_area = FALSE;
7050 int id = gi->custom_id;
7051 boolean button_press_event;
7052 boolean button_release_event;
7053 boolean inside_drawing_area = !gi->event.off_borders;
7054 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
7055 int actual_drawing_function;
7056 int button = gi->event.button;
7057 int new_element = BUTTON_ELEMENT(button);
7058 int sx = gi->event.x, sy = gi->event.y;
7059 int min_sx = 0, min_sy = 0;
7060 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
7061 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
7063 int min_lx = 0, min_ly = 0;
7064 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
7067 /* handle info callback for each invocation of action callback */
7068 gi->callback_info(gi);
7070 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
7071 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
7073 /* make sure to stay inside drawing area boundaries */
7074 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
7075 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
7079 /* get positions inside level field */
7080 lx = sx + level_xpos;
7081 ly = sy + level_ypos;
7083 if (!IN_LEV_FIELD(lx, ly))
7084 inside_drawing_area = FALSE;
7086 /* make sure to stay inside level field boundaries */
7087 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
7088 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
7090 /* correct drawing area positions accordingly */
7091 sx = lx - level_xpos;
7092 sy = ly - level_ypos;
7095 if (button_press_event)
7096 started_inside_drawing_area = inside_drawing_area;
7098 if (!started_inside_drawing_area)
7101 if (!button && !button_release_event)
7104 /* automatically switch to 'single item' drawing mode, if needed */
7105 actual_drawing_function =
7106 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
7107 drawing_function : GADGET_ID_SINGLE_ITEMS);
7109 /* clicking into drawing area with pressed Control key picks element */
7110 if (GetKeyModState() & KMOD_Control)
7112 last_drawing_function = drawing_function;
7113 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
7116 switch (actual_drawing_function)
7118 case GADGET_ID_SINGLE_ITEMS:
7121 if (button_release_event)
7123 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7125 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
7126 !inside_drawing_area)
7127 DeleteBrushFromCursor();
7133 if (draw_with_brush)
7135 if (!button_release_event)
7136 CopyBrushToLevel(sx, sy, button);
7138 else if (new_element != Feld[lx][ly])
7140 if (new_element == EL_PLAYER_1)
7142 /* remove player at old position */
7143 for (y = 0; y < lev_fieldy; y++)
7145 for (x = 0; x < lev_fieldx; x++)
7147 if (Feld[x][y] == EL_PLAYER_1)
7149 Feld[x][y] = EL_EMPTY;
7150 if (x - level_xpos >= 0 && x - level_xpos < ed_fieldx &&
7151 y - level_ypos >= 0 && y - level_ypos < ed_fieldy)
7152 DrawMiniElement(x - level_xpos, y - level_ypos,
7159 Feld[lx][ly] = new_element;
7160 DrawMiniElement(sx, sy, new_element);
7165 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
7166 DrawMiniGraphicExt(drawto,
7167 gi->x + sx * MINI_TILEX,
7168 gi->y + sy * MINI_TILEY,
7169 el2edimg(new_element));
7171 DrawGraphicExt(drawto,
7174 el2img(new_element), 0);
7176 if (id == GADGET_ID_AMOEBA_CONTENT)
7177 level.amoeba_content = new_element;
7178 else if (id == GADGET_ID_CUSTOM_GRAPHIC)
7180 new_element = GFX_ELEMENT(new_element);
7181 custom_element.gfx_element = new_element;
7183 CopyElementPropertiesToGame(properties_element);
7185 UpdateCustomElementGraphicGadgets();
7187 FrameCounter = 0; /* restart animation frame counter */
7189 else if (id == GADGET_ID_CUSTOM_CONTENT)
7191 custom_element.content[sx][sy] = new_element;
7193 CopyCustomElementPropertiesToGame(properties_element);
7195 else if (id == GADGET_ID_CUSTOM_MOVE_ENTER)
7197 custom_element.move_enter_element = new_element;
7199 CopyCustomElementPropertiesToGame(properties_element);
7201 else if (id == GADGET_ID_CUSTOM_MOVE_LEAVE)
7203 custom_element.move_leave_element = new_element;
7205 CopyCustomElementPropertiesToGame(properties_element);
7207 else if (id == GADGET_ID_CUSTOM_CHANGE_TARGET)
7209 custom_element_change.target_element = new_element;
7211 CopyCustomElementPropertiesToGame(properties_element);
7213 else if (id == GADGET_ID_CUSTOM_CHANGE_CONTENT)
7215 custom_element_change.content[sx][sy] = new_element;
7217 CopyCustomElementPropertiesToGame(properties_element);
7219 else if (id == GADGET_ID_CUSTOM_CHANGE_TRIGGER)
7221 custom_element_change.trigger_element = new_element;
7223 CopyCustomElementPropertiesToGame(properties_element);
7225 else if (id == GADGET_ID_GROUP_CONTENT)
7227 group_element_info.element[sx] = new_element;
7229 CopyGroupElementPropertiesToGame(properties_element);
7231 else if (id == GADGET_ID_RANDOM_BACKGROUND)
7232 random_placement_background_element = new_element;
7233 else if (id >= GADGET_ID_ELEMENT_CONTENT_0 &&
7234 id <= GADGET_ID_ELEMENT_CONTENT_7)
7235 level.yamyam_content[id - GADGET_ID_ELEMENT_CONTENT_0][sx][sy] =
7240 case GADGET_ID_CONNECTED_ITEMS:
7242 static int last_sx = -1;
7243 static int last_sy = -1;
7245 if (button_release_event)
7246 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7250 if (!button_press_event)
7251 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
7259 case GADGET_ID_LINE:
7261 case GADGET_ID_RECTANGLE:
7262 case GADGET_ID_FILLED_BOX:
7263 case GADGET_ID_GRAB_BRUSH:
7264 case GADGET_ID_TEXT:
7266 static int last_sx = -1;
7267 static int last_sy = -1;
7268 static int start_sx = -1;
7269 static int start_sy = -1;
7270 void (*draw_func)(int, int, int, int, int, boolean);
7272 if (drawing_function == GADGET_ID_LINE)
7273 draw_func = DrawLine;
7274 else if (drawing_function == GADGET_ID_ARC)
7275 draw_func = DrawArc;
7276 else if (drawing_function == GADGET_ID_RECTANGLE)
7277 draw_func = DrawBox;
7278 else if (drawing_function == GADGET_ID_FILLED_BOX)
7279 draw_func = DrawFilledBox;
7280 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
7281 draw_func = SelectArea;
7282 else /* (drawing_function == GADGET_ID_TEXT) */
7283 draw_func = SetTextCursor;
7285 if (button_press_event)
7287 draw_func(sx, sy, sx, sy, new_element, FALSE);
7288 start_sx = last_sx = sx;
7289 start_sy = last_sy = sy;
7291 if (drawing_function == GADGET_ID_TEXT)
7292 DrawLevelText(0, 0, 0, TEXT_END);
7294 else if (button_release_event)
7296 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
7297 if (drawing_function == GADGET_ID_GRAB_BRUSH)
7299 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
7300 CopyBrushToCursor(sx, sy);
7301 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
7303 draw_with_brush = TRUE;
7305 else if (drawing_function == GADGET_ID_TEXT)
7306 DrawLevelText(sx, sy, 0, TEXT_INIT);
7308 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7310 else if (last_sx != sx || last_sy != sy)
7312 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
7313 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
7320 case GADGET_ID_FLOOD_FILL:
7321 if (button_press_event && Feld[lx][ly] != new_element)
7323 FloodFill(lx, ly, new_element);
7324 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7325 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7329 case GADGET_ID_PICK_ELEMENT:
7330 if (button_release_event)
7331 ClickOnGadget(level_editor_gadget[last_drawing_function],
7333 else if (draw_level)
7334 PickDrawingElement(button, Feld[lx][ly]);
7335 else if (id == GADGET_ID_AMOEBA_CONTENT)
7336 PickDrawingElement(button, level.amoeba_content);
7337 else if (id == GADGET_ID_CUSTOM_GRAPHIC)
7338 PickDrawingElement(button, custom_element.gfx_element);
7339 else if (id == GADGET_ID_CUSTOM_CONTENT)
7340 PickDrawingElement(button, custom_element.content[sx][sy]);
7341 else if (id == GADGET_ID_CUSTOM_MOVE_ENTER)
7342 PickDrawingElement(button, custom_element.move_enter_element);
7343 else if (id == GADGET_ID_CUSTOM_MOVE_LEAVE)
7344 PickDrawingElement(button, custom_element.move_leave_element);
7345 else if (id == GADGET_ID_CUSTOM_CHANGE_TARGET)
7346 PickDrawingElement(button, custom_element_change.target_element);
7347 else if (id == GADGET_ID_CUSTOM_CHANGE_CONTENT)
7348 PickDrawingElement(button, custom_element_change.content[sx][sy]);
7349 else if (id == GADGET_ID_CUSTOM_CHANGE_TRIGGER)
7350 PickDrawingElement(button, custom_element_change.trigger_element);
7351 else if (id == GADGET_ID_GROUP_CONTENT)
7352 PickDrawingElement(button, group_element_info.element[sx]);
7353 else if (id == GADGET_ID_RANDOM_BACKGROUND)
7354 PickDrawingElement(button, random_placement_background_element);
7355 else if (id >= GADGET_ID_ELEMENT_CONTENT_0 &&
7356 id <= GADGET_ID_ELEMENT_CONTENT_7)
7358 int i = id - GADGET_ID_ELEMENT_CONTENT_0;
7360 PickDrawingElement(button, level.yamyam_content[i][sx][sy]);
7370 static void HandleCounterButtons(struct GadgetInfo *gi)
7372 int gadget_id = gi->custom_id;
7373 int counter_id = gi->custom_type_id;
7374 int button = gi->event.button;
7375 int *counter_value = counterbutton_info[counter_id].value;
7376 int step = BUTTON_STEPSIZE(button) *
7377 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
7379 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
7381 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
7382 boolean released = (gi->event.type == GD_EVENT_RELEASED);
7383 boolean level_changed = LevelChanged();
7385 if ((level_changed && pressed) || (!level_changed && released))
7388 if (level_changed && !Request("Level has changed! Discard changes ?",
7391 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
7392 ModifyEditorCounter(counter_id, *counter_value);
7397 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
7398 *counter_value = gi->textinput.number_value;
7400 ModifyEditorCounter(counter_id, *counter_value + step);
7404 case ED_COUNTER_ID_ELEMENT_CONTENT:
7405 DrawElementContentAreas();
7408 case ED_COUNTER_ID_GROUP_CONTENT:
7409 DrawGroupElementArea(properties_element);
7410 CopyGroupElementPropertiesToGame(properties_element);
7413 case ED_COUNTER_ID_ENVELOPE_XSIZE:
7414 case ED_COUNTER_ID_ENVELOPE_YSIZE:
7415 DrawEnvelopeTextArea(-1);
7418 case ED_COUNTER_ID_LEVEL_XSIZE:
7419 case ED_COUNTER_ID_LEVEL_YSIZE:
7420 lev_fieldx = level.fieldx;
7421 lev_fieldy = level.fieldy;
7424 case ED_COUNTER_ID_SELECT_LEVEL:
7425 LoadLevel(level_nr);
7428 DrawEditModeWindow();
7435 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
7436 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
7437 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
7438 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
7439 CopyElementPropertiesToGame(properties_element);
7442 static void HandleTextInputGadgets(struct GadgetInfo *gi)
7444 int type_id = gi->custom_type_id;
7446 strcpy(textinput_info[type_id].value, gi->textinput.value);
7448 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
7450 CopyElementPropertiesToGame(properties_element);
7452 ModifyEditorElementList(); /* update changed button info text */
7456 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
7458 int type_id = gi->custom_type_id;
7460 strcpy(textarea_info[type_id].value, gi->textarea.value);
7463 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
7465 int type_id = gi->custom_type_id;
7467 *selectbox_info[type_id].value =
7468 selectbox_info[type_id].options[gi->selectbox.index].value;
7470 if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
7472 element_info[properties_element].current_change_page = gi->selectbox.index;
7474 DrawPropertiesWindow();
7476 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
7477 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
7478 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
7479 type_id <= ED_SELECTBOX_ID_CHANGE_LAST))
7480 CopyElementPropertiesToGame(properties_element);
7483 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
7485 int type_id = gi->custom_type_id;
7488 if (type_id >= ED_TEXTBUTTON_ID_PROPERTIES_FIRST &&
7489 type_id <= ED_TEXTBUTTON_ID_PROPERTIES_LAST)
7491 edit_mode_properties = gi->custom_type_id;
7493 DrawPropertiesWindow();
7495 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE)
7497 char *template_filename = getDefaultLevelFilename(-1);
7498 boolean new_template = !fileExists(template_filename);
7501 Request("Save this template and kill the old ?", REQ_ASK))
7502 SaveLevelTemplate();
7505 Request("Template saved !", REQ_CONFIRM);
7507 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
7508 custom_element.num_change_pages < MAX_CHANGE_PAGES)
7510 struct ElementInfo *ei = &element_info[properties_element];
7512 setElementChangePages(ei, ei->num_change_pages + 1);
7514 /* set new change page to be new current change page */
7515 ei->current_change_page = ei->num_change_pages - 1;
7516 ei->change = &ei->change_page[ei->current_change_page];
7518 setElementChangeInfoToDefaults(ei->change);
7520 DrawPropertiesWindow();
7522 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
7523 custom_element.num_change_pages > MIN_CHANGE_PAGES)
7525 struct ElementInfo *ei = &element_info[properties_element];
7527 /* copy all change pages after change page to be deleted */
7528 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
7529 ei->change_page[i] = ei->change_page[i + 1];
7531 setElementChangePages(ei, ei->num_change_pages - 1);
7533 DrawPropertiesWindow();
7537 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
7539 int type_id = gi->custom_type_id;
7541 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
7542 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
7544 struct ElementInfo *ei = &element_info[properties_element];
7545 int step = BUTTON_STEPSIZE(gi->event.button);
7547 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
7548 ei->current_change_page += step;
7550 if (ei->current_change_page < 0)
7551 ei->current_change_page = 0;
7552 else if (ei->current_change_page >= ei->num_change_pages)
7553 ei->current_change_page = ei->num_change_pages - 1;
7555 DrawPropertiesWindow();
7559 static void HandleRadiobuttons(struct GadgetInfo *gi)
7561 *radiobutton_info[gi->custom_type_id].value =
7562 radiobutton_info[gi->custom_type_id].checked_value;
7565 static void HandleCheckbuttons(struct GadgetInfo *gi)
7567 int type_id = gi->custom_type_id;
7569 *checkbutton_info[type_id].value ^= TRUE;
7571 if ((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
7572 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
7573 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
7574 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST &&
7575 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE))
7577 CopyElementPropertiesToGame(properties_element);
7580 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
7582 UpdateCustomElementGraphicGadgets();
7584 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE)
7586 char *template_filename = getDefaultLevelFilename(-1);
7588 if (level.use_custom_template && !fileExists(template_filename))
7590 Request("No level template found !", REQ_CONFIRM);
7592 level.use_custom_template = FALSE;
7593 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
7598 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
7600 DrawEditModeWindow();
7604 static void HandleControlButtons(struct GadgetInfo *gi)
7606 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
7607 static int last_edit_mode = ED_MODE_DRAWING;
7608 static int last_custom_copy_mode = -1;
7609 int id = gi->custom_id;
7610 int button = gi->event.button;
7611 int step = BUTTON_STEPSIZE(button);
7612 int new_element = BUTTON_ELEMENT(button);
7615 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
7616 DrawLevelText(0, 0, 0, TEXT_END);
7618 if (id < ED_NUM_CTRL1_BUTTONS &&
7619 id != GADGET_ID_SINGLE_ITEMS &&
7620 id != GADGET_ID_PROPERTIES &&
7621 id != GADGET_ID_PICK_ELEMENT &&
7622 edit_mode != ED_MODE_DRAWING &&
7623 drawing_function != GADGET_ID_PICK_ELEMENT &&
7624 !(GetKeyModState() & KMOD_Control))
7626 DrawDrawingWindow();
7627 edit_mode = ED_MODE_DRAWING;
7632 case GADGET_ID_SCROLL_LEFT:
7633 if (level_xpos >= 0)
7635 if (lev_fieldx < ed_fieldx - 2)
7639 if (level_xpos < -1)
7642 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
7644 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7646 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
7647 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
7651 case GADGET_ID_SCROLL_RIGHT:
7652 if (level_xpos <= lev_fieldx - ed_fieldx)
7654 if (lev_fieldx < ed_fieldx - 2)
7658 if (level_xpos > lev_fieldx - ed_fieldx + 1)
7659 level_xpos = lev_fieldx - ed_fieldx + 1;
7661 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
7663 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7665 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
7666 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
7670 case GADGET_ID_SCROLL_UP:
7671 if (level_ypos >= 0)
7673 if (lev_fieldy < ed_fieldy - 2)
7677 if (level_ypos < -1)
7680 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
7682 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7684 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
7685 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
7689 case GADGET_ID_SCROLL_DOWN:
7690 if (level_ypos <= lev_fieldy - ed_fieldy)
7692 if (lev_fieldy < ed_fieldy - 2)
7696 if (level_ypos > lev_fieldy - ed_fieldy + 1)
7697 level_ypos = lev_fieldy - ed_fieldy + 1;
7699 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_UP);
7701 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7703 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
7704 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
7708 case GADGET_ID_SCROLL_HORIZONTAL:
7709 level_xpos = gi->event.item_position - 1;
7710 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7713 case GADGET_ID_SCROLL_VERTICAL:
7714 level_ypos = gi->event.item_position - 1;
7715 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7718 case GADGET_ID_SCROLL_LIST_UP:
7719 case GADGET_ID_SCROLL_LIST_DOWN:
7720 case GADGET_ID_SCROLL_LIST_VERTICAL:
7721 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
7722 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
7725 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
7726 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
7728 if (element_shift < 0)
7730 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
7731 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
7733 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
7734 GDI_SCROLLBAR_ITEM_POSITION,
7735 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
7738 ModifyEditorElementList();
7742 case GADGET_ID_WRAP_LEFT:
7743 WrapLevel(-step, 0);
7746 case GADGET_ID_WRAP_RIGHT:
7750 case GADGET_ID_WRAP_UP:
7751 WrapLevel(0, -step);
7754 case GADGET_ID_WRAP_DOWN:
7758 case GADGET_ID_SINGLE_ITEMS:
7759 case GADGET_ID_CONNECTED_ITEMS:
7760 case GADGET_ID_LINE:
7762 case GADGET_ID_TEXT:
7763 case GADGET_ID_RECTANGLE:
7764 case GADGET_ID_FILLED_BOX:
7765 case GADGET_ID_FLOOD_FILL:
7766 case GADGET_ID_GRAB_BRUSH:
7767 case GADGET_ID_PICK_ELEMENT:
7768 if (drawing_function != GADGET_ID_PICK_ELEMENT)
7769 last_drawing_function = drawing_function;
7770 drawing_function = id;
7771 draw_with_brush = FALSE;
7774 case GADGET_ID_RANDOM_PLACEMENT:
7775 RandomPlacement(new_element);
7778 case GADGET_ID_PROPERTIES:
7779 if (edit_mode != ED_MODE_PROPERTIES)
7781 properties_element = new_element;
7782 DrawPropertiesWindow();
7783 edit_mode = ED_MODE_PROPERTIES;
7785 last_level_drawing_function = drawing_function;
7786 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
7791 DrawDrawingWindow();
7792 edit_mode = ED_MODE_DRAWING;
7794 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
7799 case GADGET_ID_CUSTOM_COPY_FROM:
7800 case GADGET_ID_CUSTOM_COPY_TO:
7801 case GADGET_ID_CUSTOM_EXCHANGE:
7802 last_custom_copy_mode = id;
7803 last_drawing_function = drawing_function;
7806 case GADGET_ID_UNDO:
7807 if (undo_buffer_steps == 0)
7809 Request("Undo buffer empty !", REQ_CONFIRM);
7813 if (edit_mode != ED_MODE_DRAWING)
7815 DrawDrawingWindow();
7816 edit_mode = ED_MODE_DRAWING;
7819 undo_buffer_position =
7820 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
7821 undo_buffer_steps--;
7823 for (x = 0; x < lev_fieldx; x++)
7824 for (y = 0; y < lev_fieldy; y++)
7825 Feld[x][y] = UndoBuffer[undo_buffer_position][x][y];
7826 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos,level_ypos);
7829 case GADGET_ID_INFO:
7830 if (edit_mode != ED_MODE_INFO)
7832 last_edit_mode = edit_mode;
7833 edit_mode = ED_MODE_INFO;
7835 DrawLevelInfoWindow();
7839 edit_mode = last_edit_mode;
7841 DrawEditModeWindow();
7845 case GADGET_ID_CLEAR:
7846 if (edit_mode != ED_MODE_DRAWING)
7848 DrawDrawingWindow();
7849 edit_mode = ED_MODE_DRAWING;
7852 for (x = 0; x < MAX_LEV_FIELDX; x++)
7853 for (y = 0; y < MAX_LEV_FIELDY; y++)
7854 Feld[x][y] = (button == 1 ? EL_EMPTY : new_element);
7855 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
7857 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7860 case GADGET_ID_SAVE:
7861 if (leveldir_current->readonly)
7863 Request("This level is read only !", REQ_CONFIRM);
7867 if (!LevelContainsPlayer)
7868 Request("No Level without Gregor Mc Duffin please !", REQ_CONFIRM);
7871 char *level_filename = getDefaultLevelFilename(level_nr);
7872 boolean new_level = !fileExists(level_filename);
7875 Request("Save this level and kill the old ?", REQ_ASK))
7877 CopyPlayfield(Feld, level.field);
7879 SaveLevel(level_nr);
7883 Request("Level saved !", REQ_CONFIRM);
7887 case GADGET_ID_TEST:
7888 if (!LevelContainsPlayer)
7889 Request("No Level without Gregor Mc Duffin please !", REQ_CONFIRM);
7893 level.game_version = GAME_VERSION_ACTUAL;
7895 CopyPlayfield(level.field, FieldBackup);
7896 CopyPlayfield(Feld, level.field);
7898 UnmapLevelEditorGadgets();
7899 UndrawSpecialEditorDoor();
7901 CloseDoor(DOOR_CLOSE_ALL);
7903 DrawCompleteVideoDisplay();
7905 if (setup.autorecord)
7906 TapeStartRecording();
7908 level_editor_test_game = TRUE;
7909 game_status = GAME_MODE_PLAYING;
7915 case GADGET_ID_EXIT:
7916 RequestExitLevelEditor(TRUE); /* if level has changed, ask user */
7920 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
7921 id <= GADGET_ID_ELEMENTLIST_LAST)
7923 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
7924 int new_element = editor_elements[element_position + element_shift];
7926 if (last_custom_copy_mode != -1)
7928 CopyCustomElement(properties_element, new_element,
7929 last_custom_copy_mode);
7931 ClickOnGadget(level_editor_gadget[last_drawing_function],
7934 last_custom_copy_mode = -1;
7939 PickDrawingElement(button, new_element);
7941 if (!stick_element_properties_window &&
7942 drawing_function != GADGET_ID_PICK_ELEMENT &&
7943 !(GetKeyModState() & KMOD_Control))
7945 properties_element = new_element;
7946 if (edit_mode == ED_MODE_PROPERTIES)
7947 DrawPropertiesWindow();
7950 if (drawing_function == GADGET_ID_PICK_ELEMENT)
7951 ClickOnGadget(level_editor_gadget[last_drawing_function],
7955 else if (gi->event.type == GD_EVENT_PRESSED)
7956 printf("default: HandleControlButtons: GD_EVENT_PRESSED(%d)\n", id);
7957 else if (gi->event.type == GD_EVENT_RELEASED)
7958 printf("default: HandleControlButtons: GD_EVENT_RELEASED(%d)\n", id);
7959 else if (gi->event.type == GD_EVENT_MOVING)
7960 printf("default: HandleControlButtons: GD_EVENT_MOVING(%d)\n", id);
7962 printf("default: HandleControlButtons: ? (id == %d)\n", id);
7968 void HandleLevelEditorKeyInput(Key key)
7970 char letter = getCharFromKey(key);
7971 int button = MB_LEFTBUTTON;
7973 if (drawing_function == GADGET_ID_TEXT &&
7974 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
7977 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
7978 else if (key == KSYM_Delete || key == KSYM_BackSpace)
7979 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
7980 else if (key == KSYM_Return)
7981 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
7982 else if (key == KSYM_Escape)
7983 DrawLevelText(0, 0, 0, TEXT_END);
7985 else if (button_status == MB_RELEASED)
7987 int i, id = GADGET_ID_NONE;
7992 id = GADGET_ID_SCROLL_LEFT;
7995 id = GADGET_ID_SCROLL_RIGHT;
7998 id = GADGET_ID_SCROLL_UP;
8001 id = GADGET_ID_SCROLL_DOWN;
8004 id = GADGET_ID_SCROLL_LIST_UP;
8005 button = MB_RIGHTBUTTON;
8007 case KSYM_Page_Down:
8008 id = GADGET_ID_SCROLL_LIST_DOWN;
8009 button = MB_RIGHTBUTTON;
8013 if (edit_mode == ED_MODE_DRAWING)
8015 RequestExitLevelEditor(setup.ask_on_escape);
8019 DrawDrawingWindow();
8020 edit_mode = ED_MODE_DRAWING;
8028 if (id != GADGET_ID_NONE)
8029 ClickOnGadget(level_editor_gadget[id], button);
8030 else if (letter == '.')
8031 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
8032 else if (key == KSYM_Return || key == setup.shortcut.toggle_pause)
8033 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
8035 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
8036 if (letter && letter == control_info[i].shortcut)
8037 if (!anyTextGadgetActive())
8038 ClickOnGadget(level_editor_gadget[i], button);
8042 void HandleLevelEditorIdle()
8044 static unsigned long action_delay = 0;
8045 unsigned long action_delay_value = GameFrameDelay;
8046 int xpos = 1, ypos = 2;
8048 if (edit_mode != ED_MODE_PROPERTIES)
8051 if (!DelayReached(&action_delay, action_delay_value))
8054 DrawGraphicAnimationExt(drawto,
8056 SY + ypos * TILEY + MINI_TILEY / 2,
8057 el2img(properties_element), -1, NO_MASKING);
8059 MarkTileDirty(xpos, ypos);
8060 MarkTileDirty(xpos, ypos + 1);
8062 FrameCounter++; /* increase animation frame counter */
8065 void ClearEditorGadgetInfoText()
8067 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
8070 void HandleEditorGadgetInfoText(void *ptr)
8072 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
8073 char infotext[MAX_OUTPUT_LINESIZE + 1];
8074 char shortcut[MAX_OUTPUT_LINESIZE + 1];
8075 int max_infotext_len = getMaxInfoTextLength();
8077 if (game_status != GAME_MODE_EDITOR)
8080 ClearEditorGadgetInfoText();
8082 if (gi->event.type == GD_EVENT_INFO_LEAVING)
8085 /* misuse this function to delete brush cursor, if needed */
8086 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
8087 DeleteBrushFromCursor();
8089 if (gi == NULL || gi->info_text == NULL)
8092 strncpy(infotext, gi->info_text, max_infotext_len);
8093 infotext[max_infotext_len] = '\0';
8095 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
8097 int key = control_info[gi->custom_id].shortcut;
8101 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS) /* special case 1 */
8102 sprintf(shortcut, " ('.' or '%c')", key);
8103 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT) /* special case 2 */
8104 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
8105 else if (gi->custom_id == GADGET_ID_TEST) /* special case 3 */
8106 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
8107 else /* normal case */
8108 sprintf(shortcut, " ('%s%c')",
8109 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
8111 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
8112 strcat(infotext, shortcut);
8116 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, FONT_TEXT_2);
8119 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
8121 static int start_lx, start_ly;
8122 int id = gi->custom_id;
8123 int sx = gi->event.x;
8124 int sy = gi->event.y;
8125 int lx = sx + level_xpos;
8126 int ly = sy + level_ypos;
8127 int min_sx = 0, min_sy = 0;
8128 int max_sx = gi->drawing.area_xsize - 1;
8129 int max_sy = gi->drawing.area_ysize - 1;
8130 int actual_drawing_function = drawing_function;
8131 int max_infotext_len = getMaxInfoTextLength();
8132 char infotext[MAX_OUTPUT_LINESIZE + 1];
8135 infotext[0] = '\0'; /* start with empty info text */
8137 /* pressed Control key: simulate picking element */
8138 if (GetKeyModState() & KMOD_Control)
8139 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
8141 ClearEditorGadgetInfoText();
8143 if (gi->event.type == GD_EVENT_INFO_LEAVING)
8146 /* make sure to stay inside drawing area boundaries */
8147 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
8148 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
8150 if (id == GADGET_ID_DRAWING_LEVEL)
8154 int min_lx = 0, min_ly = 0;
8155 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
8157 /* get positions inside level field */
8158 lx = sx + level_xpos;
8159 ly = sy + level_ypos;
8161 /* make sure to stay inside level field boundaries */
8162 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
8163 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
8165 /* correct drawing area positions accordingly */
8166 sx = lx - level_xpos;
8167 sy = ly - level_ypos;
8170 if (IN_ED_FIELD(sx,sy) && IN_LEV_FIELD(lx, ly))
8172 if (button_status) /* if (gi->state == GD_BUTTON_PRESSED) */
8174 if (gi->event.type == GD_EVENT_PRESSED)
8180 switch (actual_drawing_function)
8182 case GADGET_ID_SINGLE_ITEMS:
8183 text = "Drawing single items";
8185 case GADGET_ID_CONNECTED_ITEMS:
8186 text = "Drawing connected items";
8188 case GADGET_ID_LINE:
8189 text = "Drawing line";
8192 text = "Drawing arc";
8194 case GADGET_ID_TEXT:
8195 text = "Setting text cursor";
8197 case GADGET_ID_RECTANGLE:
8198 text = "Drawing rectangle";
8200 case GADGET_ID_FILLED_BOX:
8201 text = "Drawing filled box";
8203 case GADGET_ID_FLOOD_FILL:
8204 text = "Flood fill";
8206 case GADGET_ID_GRAB_BRUSH:
8207 text = "Grabbing brush";
8209 case GADGET_ID_PICK_ELEMENT:
8210 text = "Picking element";
8214 text = "Drawing position";
8219 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
8220 sprintf(infotext, "%s: %d, %d", text, lx, ly);
8222 sprintf(infotext, "%s: %d, %d", text,
8223 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
8225 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
8226 DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
8227 "%s: %d, %d", infotext, lx, ly);
8229 DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
8230 "%s: %d, %d", infotext,
8231 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
8235 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
8236 strncpy(infotext, getElementInfoText(Feld[lx][ly]), max_infotext_len);
8238 sprintf(infotext, "Level position: %d, %d", lx, ly);
8240 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
8241 DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
8242 "%s", getElementInfoText(Feld[lx][ly]));
8244 DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
8245 "Level position: %d, %d", lx, ly);
8249 /* misuse this function to draw brush cursor, if needed */
8250 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
8252 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
8253 CopyBrushToCursor(sx, sy);
8255 DeleteBrushFromCursor();
8258 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
8260 int element = EL_EMPTY;
8262 if (id == GADGET_ID_AMOEBA_CONTENT)
8263 element = level.amoeba_content;
8264 else if (id == GADGET_ID_CUSTOM_GRAPHIC)
8265 element = custom_element.gfx_element;
8266 else if (id == GADGET_ID_CUSTOM_CONTENT)
8267 element = custom_element.content[sx][sy];
8268 else if (id == GADGET_ID_CUSTOM_MOVE_ENTER)
8269 element = custom_element.move_enter_element;
8270 else if (id == GADGET_ID_CUSTOM_MOVE_LEAVE)
8271 element = custom_element.move_leave_element;
8272 else if (id == GADGET_ID_CUSTOM_CHANGE_TARGET)
8273 element = custom_element_change.target_element;
8274 else if (id == GADGET_ID_CUSTOM_CHANGE_CONTENT)
8275 element = custom_element_change.content[sx][sy];
8276 else if (id == GADGET_ID_CUSTOM_CHANGE_TRIGGER)
8277 element = custom_element_change.trigger_element;
8278 else if (id == GADGET_ID_GROUP_CONTENT)
8279 element = group_element_info.element[sx];
8280 else if (id == GADGET_ID_RANDOM_BACKGROUND)
8281 element = random_placement_background_element;
8282 else if (id >= GADGET_ID_ELEMENT_CONTENT_0 &&
8283 id <= GADGET_ID_ELEMENT_CONTENT_7)
8284 element = level.yamyam_content[id - GADGET_ID_ELEMENT_CONTENT_0][sx][sy];
8286 strncpy(infotext, getElementInfoText(element), max_infotext_len);
8290 if (id == GADGET_ID_AMOEBA_CONTENT)
8291 strcpy(infotext, "Amoeba content");
8292 else if (id == GADGET_ID_CUSTOM_GRAPHIC)
8293 strcpy(infotext, "Custom graphic element");
8294 else if (id == GADGET_ID_CUSTOM_CONTENT)
8295 sprintf(infotext, "Custom element content position: %d, %d", sx, sy);
8296 else if (id == GADGET_ID_CUSTOM_MOVE_ENTER)
8297 strcpy(infotext, "Element that can be digged/collected");
8298 else if (id == GADGET_ID_CUSTOM_MOVE_LEAVE)
8299 strcpy(infotext, "Element that will be left behind");
8300 else if (id == GADGET_ID_CUSTOM_CHANGE_TARGET)
8301 strcpy(infotext, "New element after change");
8302 else if (id == GADGET_ID_CUSTOM_CHANGE_CONTENT)
8303 strcpy(infotext, "New extended elements after change");
8304 else if (id == GADGET_ID_CUSTOM_CHANGE_TRIGGER)
8305 strcpy(infotext, "Other element triggering change");
8306 else if (id == GADGET_ID_GROUP_CONTENT)
8307 sprintf(infotext, "Group element position: %d", sx + 1);
8308 else if (id == GADGET_ID_RANDOM_BACKGROUND)
8309 strcpy(infotext, "Random placement background");
8310 else if (id >= GADGET_ID_ELEMENT_CONTENT_0 &&
8311 id <= GADGET_ID_ELEMENT_CONTENT_7)
8312 sprintf(infotext, "Content area %d position: %d, %d",
8313 id - GADGET_ID_ELEMENT_CONTENT_0 + 1, sx, sy);
8316 infotext[max_infotext_len] = '\0';
8318 if (strlen(infotext) > 0)
8319 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, infotext);
8322 void RequestExitLevelEditor(boolean ask_if_level_has_changed)
8324 if (!ask_if_level_has_changed ||
8326 Request("Level has changed! Exit without saving ?",
8327 REQ_ASK | REQ_STAY_OPEN))
8330 CloseDoor(DOOR_CLOSE_1);
8331 SetDoorState(DOOR_CLOSE_2);
8333 CloseDoor(DOOR_CLOSE_ALL);
8335 game_status = GAME_MODE_MAIN;
8340 CloseDoor(DOOR_CLOSE_1);
8341 BlitBitmap(bitmap_db_door, bitmap_db_door,
8342 DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1, DXSIZE,DYSIZE,
8343 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
8344 OpenDoor(DOOR_OPEN_1);