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_AMOEBA_CONTENT_XPOS ED_SETTINGS_XPOS(0)
131 #define ED_AREA_AMOEBA_CONTENT_YPOS (ED_SETTINGS_YPOS(2) + \
135 #define ED_AREA_YAMYAM_CONTENT_XPOS(n) (2 * MINI_TILEX + \
136 5 * (n % 4) * MINI_TILEX)
137 #define ED_AREA_YAMYAM_CONTENT_YPOS(n) (22 * MINI_TILEY + \
138 6 * (n / 4) * MINI_TILEY)
140 /* custom change target */
141 #define ED_AREA_ELEM_CONTENT2_YPOS (ED_SETTINGS_YPOS(1) + \
143 /* optional custom graphic */
144 #define ED_AREA_ELEM_CONTENT3_YPOS (ED_SETTINGS_YPOS(1) + \
146 /* custom element content */
147 #define ED_AREA_ELEM_CONTENT4_XPOS (29 * MINI_TILEX)
148 #define ED_AREA_ELEM_CONTENT4_YPOS (ED_SETTINGS_YPOS(2) + \
149 ED_GADGET_DISTANCE - MINI_TILEY)
150 /* movement enter/leave element */
151 #define ED_AREA_ELEM_CONTENT4a_XPOS (29 * MINI_TILEX)
152 #define ED_AREA_ELEM_CONTENT4a_YPOS (ED_SETTINGS_YPOS(10) + \
154 #define ED_AREA_ELEM_CONTENT4b_XPOS (29 * MINI_TILEX)
155 #define ED_AREA_ELEM_CONTENT4b_YPOS (ED_SETTINGS_YPOS(10) + \
157 /* custom change trigger element */
158 #define ED_AREA_ELEM_CONTENT5_YPOS (ED_SETTINGS_YPOS(5) + \
160 /* extended custom change target */
161 #define ED_AREA_ELEM_CONTENT6_XPOS (29 * MINI_TILEX)
162 #define ED_AREA_ELEM_CONTENT6_YPOS (ED_SETTINGS_YPOS(9) + \
163 ED_GADGET_DISTANCE - MINI_TILEY)
164 /* group element content */
165 #define ED_AREA_GROUP_CONTENT_XPOS ED_SETTINGS_XPOS(0)
167 #define ED_AREA_GROUP_CONTENT_YPOS (ED_SETTINGS_YPOS(4) + \
170 #define ED_AREA_GROUP_CONTENT_YPOS (22 * MINI_TILEY)
173 /* values for random placement background drawing area */
174 #define ED_AREA_RANDOM_BACKGROUND_YPOS (31 * MINI_TILEY)
176 /* values for scrolling gadgets for drawing area */
177 #define ED_SCROLLBUTTON_XPOS 24
178 #define ED_SCROLLBUTTON_YPOS 0
179 #define ED_SCROLLBAR_XPOS 24
180 #define ED_SCROLLBAR_YPOS 64
182 #define ED_SCROLLBUTTON_XSIZE 16
183 #define ED_SCROLLBUTTON_YSIZE 16
185 #define ED_SCROLL_UP_XPOS (SXSIZE - ED_SCROLLBUTTON_XSIZE)
186 #define ED_SCROLL_UP_YPOS (0)
187 #define ED_SCROLL_DOWN_XPOS ED_SCROLL_UP_XPOS
188 #define ED_SCROLL_DOWN_YPOS (SYSIZE - 3 * ED_SCROLLBUTTON_YSIZE)
189 #define ED_SCROLL_LEFT_XPOS (0)
190 #define ED_SCROLL_LEFT_YPOS (SYSIZE - 2 * ED_SCROLLBUTTON_YSIZE)
191 #define ED_SCROLL_RIGHT_XPOS (SXSIZE - 2 * ED_SCROLLBUTTON_XSIZE)
192 #define ED_SCROLL_RIGHT_YPOS ED_SCROLL_LEFT_YPOS
193 #define ED_SCROLL_HORIZONTAL_XPOS (ED_SCROLL_LEFT_XPOS + ED_SCROLLBUTTON_XSIZE)
194 #define ED_SCROLL_HORIZONTAL_YPOS ED_SCROLL_LEFT_YPOS
195 #define ED_SCROLL_HORIZONTAL_XSIZE (SXSIZE - 3 * ED_SCROLLBUTTON_XSIZE)
196 #define ED_SCROLL_HORIZONTAL_YSIZE ED_SCROLLBUTTON_YSIZE
197 #define ED_SCROLL_VERTICAL_XPOS ED_SCROLL_UP_XPOS
198 #define ED_SCROLL_VERTICAL_YPOS (ED_SCROLL_UP_YPOS + ED_SCROLLBUTTON_YSIZE)
199 #define ED_SCROLL_VERTICAL_XSIZE ED_SCROLLBUTTON_XSIZE
200 #define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - 4 * ED_SCROLLBUTTON_YSIZE)
202 /* values for scrolling gadgets for element list */
203 #define ED_SCROLLBUTTON2_XPOS 50
204 #define ED_SCROLLBUTTON2_YPOS 0
205 #define ED_SCROLLBAR2_XPOS 50
206 #define ED_SCROLLBAR2_YPOS 20
208 #define ED_SCROLLBUTTON2_XSIZE 10
209 #define ED_SCROLLBUTTON2_YSIZE 10
211 #define ED_SCROLL2_UP_XPOS 85
212 #define ED_SCROLL2_UP_YPOS 30
213 #define ED_SCROLL2_DOWN_XPOS ED_SCROLL2_UP_XPOS
214 #define ED_SCROLL2_DOWN_YPOS (ED_SCROLL2_UP_YPOS + \
215 ED_ELEMENTLIST_BUTTONS_VERT * \
216 ED_ELEMENTLIST_YSIZE - \
217 ED_SCROLLBUTTON2_YSIZE)
218 #define ED_SCROLL2_VERTICAL_XPOS ED_SCROLL2_UP_XPOS
219 #define ED_SCROLL2_VERTICAL_YPOS (ED_SCROLL2_UP_YPOS + \
220 ED_SCROLLBUTTON2_YSIZE)
221 #define ED_SCROLL2_VERTICAL_XSIZE ED_SCROLLBUTTON2_XSIZE
222 #define ED_SCROLL2_VERTICAL_YSIZE (ED_ELEMENTLIST_BUTTONS_VERT * \
223 ED_ELEMENTLIST_YSIZE - \
224 2 * ED_SCROLLBUTTON2_YSIZE)
226 /* values for checkbutton gadgets */
227 #define ED_CHECKBUTTON_XSIZE ED_BUTTON_COUNT_XSIZE
228 #define ED_CHECKBUTTON_YSIZE ED_BUTTON_COUNT_YSIZE
229 #define ED_CHECKBUTTON_UNCHECKED_XPOS ED_BUTTON_MINUS_XPOS
230 #define ED_CHECKBUTTON_CHECKED_XPOS ED_BUTTON_PLUS_XPOS
231 #define ED_CHECKBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 22)
232 #define ED_RADIOBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 44)
233 #define ED_STICKYBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 66)
235 /* some positions in the editor control window */
236 #define ED_BUTTON_ELEM_XPOS 6
237 #define ED_BUTTON_ELEM_YPOS 30
238 #define ED_BUTTON_ELEM_XSIZE 22
239 #define ED_BUTTON_ELEM_YSIZE 22
241 /* some values for text input, selectbox and counter gadgets */
242 #define ED_BUTTON_COUNT_YPOS 60
243 #define ED_BUTTON_COUNT_XSIZE 20
244 #define ED_BUTTON_COUNT_YSIZE 20
245 #define ED_WIN_COUNT_XPOS (2 + ED_BUTTON_COUNT_XSIZE + 2)
246 #define ED_WIN_COUNT_YPOS ED_BUTTON_COUNT_YPOS
247 #define ED_WIN_COUNT_XSIZE 52
248 #define ED_WIN_COUNT_YSIZE ED_BUTTON_COUNT_YSIZE
249 #define ED_WIN_COUNT2_XPOS 27
250 #define ED_WIN_COUNT2_YPOS 3
251 #define ED_WIN_COUNT2_XSIZE 46
252 #define ED_WIN_COUNT2_YSIZE ED_BUTTON_COUNT_YSIZE
254 #define ED_BUTTON_MINUS_XPOS 2
255 #define ED_BUTTON_MINUS_YPOS ED_BUTTON_COUNT_YPOS
256 #define ED_BUTTON_MINUS_XSIZE ED_BUTTON_COUNT_XSIZE
257 #define ED_BUTTON_MINUS_YSIZE ED_BUTTON_COUNT_YSIZE
258 #define ED_BUTTON_PLUS_XPOS (ED_WIN_COUNT_XPOS + \
259 ED_WIN_COUNT_XSIZE + 2)
260 #define ED_BUTTON_PLUS_YPOS ED_BUTTON_COUNT_YPOS
261 #define ED_BUTTON_PLUS_XSIZE ED_BUTTON_COUNT_XSIZE
262 #define ED_BUTTON_PLUS_YSIZE ED_BUTTON_COUNT_YSIZE
264 #define ED_SELECTBOX_XPOS ED_WIN_COUNT_XPOS
265 #define ED_SELECTBOX_YPOS (ED_WIN_COUNT_YPOS + \
266 2 + ED_WIN_COUNT_YSIZE)
267 #define ED_SELECTBOX_XSIZE ED_WIN_COUNT_XSIZE
268 #define ED_SELECTBOX_YSIZE ED_WIN_COUNT_YSIZE
270 #define ED_SELECTBOX_BUTTON_XSIZE 14
272 #define ED_TEXTBUTTON_XPOS ED_WIN_COUNT_XPOS
273 #define ED_TEXTBUTTON_YPOS (ED_WIN_COUNT_YPOS + \
274 4 * (2 + ED_WIN_COUNT_YSIZE))
275 #define ED_TEXTBUTTON_INACTIVE_YPOS ED_TEXTBUTTON_YPOS
277 #define ED_TEXTBUTTON_TAB_XPOS ED_WIN_COUNT_XPOS
278 #define ED_TEXTBUTTON_TAB_YPOS (ED_WIN_COUNT_YPOS + \
279 2 * (2 + ED_WIN_COUNT_YSIZE))
280 #define ED_TEXTBUTTON_TAB_INACTIVE_YPOS (ED_WIN_COUNT_YPOS + \
281 3 * (2 + ED_WIN_COUNT_YSIZE))
283 #define ED_TEXTBUTTON_XSIZE ED_WIN_COUNT_XSIZE
284 #define ED_TEXTBUTTON_YSIZE ED_WIN_COUNT_YSIZE
286 /* values for ClearEditorGadgetInfoText() and HandleGadgetInfoText() */
287 #define INFOTEXT_XPOS SX
288 #define INFOTEXT_YPOS (SY + SYSIZE - MINI_TILEX + 2)
289 #define INFOTEXT_XSIZE SXSIZE
290 #define INFOTEXT_YSIZE MINI_TILEX
294 -----------------------------------------------------------------------------
295 editor gadget definitions
296 -----------------------------------------------------------------------------
299 /* drawing toolbox buttons */
300 #define GADGET_ID_NONE -1
301 #define GADGET_ID_TOOLBOX_FIRST 0
303 #define GADGET_ID_SINGLE_ITEMS (GADGET_ID_TOOLBOX_FIRST + 0)
304 #define GADGET_ID_CONNECTED_ITEMS (GADGET_ID_TOOLBOX_FIRST + 1)
305 #define GADGET_ID_LINE (GADGET_ID_TOOLBOX_FIRST + 2)
306 #define GADGET_ID_ARC (GADGET_ID_TOOLBOX_FIRST + 3)
307 #define GADGET_ID_RECTANGLE (GADGET_ID_TOOLBOX_FIRST + 4)
308 #define GADGET_ID_FILLED_BOX (GADGET_ID_TOOLBOX_FIRST + 5)
309 #define GADGET_ID_WRAP_UP (GADGET_ID_TOOLBOX_FIRST + 6)
310 #define GADGET_ID_TEXT (GADGET_ID_TOOLBOX_FIRST + 7)
311 #define GADGET_ID_FLOOD_FILL (GADGET_ID_TOOLBOX_FIRST + 8)
312 #define GADGET_ID_WRAP_LEFT (GADGET_ID_TOOLBOX_FIRST + 9)
313 #define GADGET_ID_PROPERTIES (GADGET_ID_TOOLBOX_FIRST + 10)
314 #define GADGET_ID_WRAP_RIGHT (GADGET_ID_TOOLBOX_FIRST + 11)
315 #define GADGET_ID_RANDOM_PLACEMENT (GADGET_ID_TOOLBOX_FIRST + 12)
316 #define GADGET_ID_GRAB_BRUSH (GADGET_ID_TOOLBOX_FIRST + 13)
317 #define GADGET_ID_WRAP_DOWN (GADGET_ID_TOOLBOX_FIRST + 14)
318 #define GADGET_ID_PICK_ELEMENT (GADGET_ID_TOOLBOX_FIRST + 15)
320 #define GADGET_ID_UNDO (GADGET_ID_TOOLBOX_FIRST + 16)
321 #define GADGET_ID_INFO (GADGET_ID_TOOLBOX_FIRST + 17)
322 #define GADGET_ID_SAVE (GADGET_ID_TOOLBOX_FIRST + 18)
323 #define GADGET_ID_CLEAR (GADGET_ID_TOOLBOX_FIRST + 19)
324 #define GADGET_ID_TEST (GADGET_ID_TOOLBOX_FIRST + 20)
325 #define GADGET_ID_EXIT (GADGET_ID_TOOLBOX_FIRST + 21)
327 #define GADGET_ID_CUSTOM_COPY_FROM (GADGET_ID_TOOLBOX_FIRST + 22)
328 #define GADGET_ID_CUSTOM_COPY_TO (GADGET_ID_TOOLBOX_FIRST + 23)
329 #define GADGET_ID_CUSTOM_EXCHANGE (GADGET_ID_TOOLBOX_FIRST + 24)
331 /* counter button identifiers */
332 #define GADGET_ID_COUNTER_FIRST (GADGET_ID_TOOLBOX_FIRST + 25)
334 #define GADGET_ID_SELECT_LEVEL_DOWN (GADGET_ID_COUNTER_FIRST + 0)
335 #define GADGET_ID_SELECT_LEVEL_TEXT (GADGET_ID_COUNTER_FIRST + 1)
336 #define GADGET_ID_SELECT_LEVEL_UP (GADGET_ID_COUNTER_FIRST + 2)
337 #define GADGET_ID_LEVEL_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 3)
338 #define GADGET_ID_LEVEL_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 4)
339 #define GADGET_ID_LEVEL_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 5)
340 #define GADGET_ID_LEVEL_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 6)
341 #define GADGET_ID_LEVEL_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 7)
342 #define GADGET_ID_LEVEL_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 8)
343 #define GADGET_ID_LEVEL_RANDOM_DOWN (GADGET_ID_COUNTER_FIRST + 9)
344 #define GADGET_ID_LEVEL_RANDOM_TEXT (GADGET_ID_COUNTER_FIRST + 10)
345 #define GADGET_ID_LEVEL_RANDOM_UP (GADGET_ID_COUNTER_FIRST + 11)
346 #define GADGET_ID_LEVEL_GEMSLIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 12)
347 #define GADGET_ID_LEVEL_GEMSLIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 13)
348 #define GADGET_ID_LEVEL_GEMSLIMIT_UP (GADGET_ID_COUNTER_FIRST + 14)
349 #define GADGET_ID_LEVEL_TIMELIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 15)
350 #define GADGET_ID_LEVEL_TIMELIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 16)
351 #define GADGET_ID_LEVEL_TIMELIMIT_UP (GADGET_ID_COUNTER_FIRST + 17)
352 #define GADGET_ID_LEVEL_TIMESCORE_DOWN (GADGET_ID_COUNTER_FIRST + 18)
353 #define GADGET_ID_LEVEL_TIMESCORE_TEXT (GADGET_ID_COUNTER_FIRST + 19)
354 #define GADGET_ID_LEVEL_TIMESCORE_UP (GADGET_ID_COUNTER_FIRST + 20)
355 #define GADGET_ID_ELEMENT_SCORE_DOWN (GADGET_ID_COUNTER_FIRST + 21)
356 #define GADGET_ID_ELEMENT_SCORE_TEXT (GADGET_ID_COUNTER_FIRST + 22)
357 #define GADGET_ID_ELEMENT_SCORE_UP (GADGET_ID_COUNTER_FIRST + 23)
358 #define GADGET_ID_ELEMENT_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 24)
359 #define GADGET_ID_ELEMENT_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 25)
360 #define GADGET_ID_ELEMENT_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 26)
361 #define GADGET_ID_ENVELOPE_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 27)
362 #define GADGET_ID_ENVELOPE_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 28)
363 #define GADGET_ID_ENVELOPE_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 29)
364 #define GADGET_ID_ENVELOPE_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 30)
365 #define GADGET_ID_ENVELOPE_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 31)
366 #define GADGET_ID_ENVELOPE_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 32)
367 #define GADGET_ID_CUSTOM_SCORE_DOWN (GADGET_ID_COUNTER_FIRST + 33)
368 #define GADGET_ID_CUSTOM_SCORE_TEXT (GADGET_ID_COUNTER_FIRST + 34)
369 #define GADGET_ID_CUSTOM_SCORE_UP (GADGET_ID_COUNTER_FIRST + 35)
370 #define GADGET_ID_CUSTOM_GEMCOUNT_DOWN (GADGET_ID_COUNTER_FIRST + 36)
371 #define GADGET_ID_CUSTOM_GEMCOUNT_TEXT (GADGET_ID_COUNTER_FIRST + 37)
372 #define GADGET_ID_CUSTOM_GEMCOUNT_UP (GADGET_ID_COUNTER_FIRST + 38)
373 #define GADGET_ID_PUSH_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 39)
374 #define GADGET_ID_PUSH_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 40)
375 #define GADGET_ID_PUSH_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 41)
376 #define GADGET_ID_PUSH_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 42)
377 #define GADGET_ID_PUSH_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 43)
378 #define GADGET_ID_PUSH_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 44)
379 #define GADGET_ID_MOVE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 45)
380 #define GADGET_ID_MOVE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 46)
381 #define GADGET_ID_MOVE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 47)
382 #define GADGET_ID_MOVE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 48)
383 #define GADGET_ID_MOVE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 49)
384 #define GADGET_ID_MOVE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 50)
385 #define GADGET_ID_EXPLOSION_DELAY_DOWN (GADGET_ID_COUNTER_FIRST + 51)
386 #define GADGET_ID_EXPLOSION_DELAY_TEXT (GADGET_ID_COUNTER_FIRST + 52)
387 #define GADGET_ID_EXPLOSION_DELAY_UP (GADGET_ID_COUNTER_FIRST + 53)
388 #define GADGET_ID_IGNITION_DELAY_DOWN (GADGET_ID_COUNTER_FIRST + 54)
389 #define GADGET_ID_IGNITION_DELAY_TEXT (GADGET_ID_COUNTER_FIRST + 55)
390 #define GADGET_ID_IGNITION_DELAY_UP (GADGET_ID_COUNTER_FIRST + 56)
391 #define GADGET_ID_CHANGE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 57)
392 #define GADGET_ID_CHANGE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 58)
393 #define GADGET_ID_CHANGE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 59)
394 #define GADGET_ID_CHANGE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 60)
395 #define GADGET_ID_CHANGE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 61)
396 #define GADGET_ID_CHANGE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 62)
397 #define GADGET_ID_CHANGE_CONT_RND_DOWN (GADGET_ID_COUNTER_FIRST + 63)
398 #define GADGET_ID_CHANGE_CONT_RND_TEXT (GADGET_ID_COUNTER_FIRST + 64)
399 #define GADGET_ID_CHANGE_CONT_RND_UP (GADGET_ID_COUNTER_FIRST + 65)
400 #define GADGET_ID_GROUP_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 66)
401 #define GADGET_ID_GROUP_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 67)
402 #define GADGET_ID_GROUP_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 68)
404 /* drawing area identifiers */
405 #define GADGET_ID_DRAWING_AREA_FIRST (GADGET_ID_COUNTER_FIRST + 69)
407 #define GADGET_ID_DRAWING_LEVEL (GADGET_ID_DRAWING_AREA_FIRST + 0)
408 #define GADGET_ID_ELEMENT_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 1)
409 #define GADGET_ID_ELEMENT_CONTENT_1 (GADGET_ID_DRAWING_AREA_FIRST + 2)
410 #define GADGET_ID_ELEMENT_CONTENT_2 (GADGET_ID_DRAWING_AREA_FIRST + 3)
411 #define GADGET_ID_ELEMENT_CONTENT_3 (GADGET_ID_DRAWING_AREA_FIRST + 4)
412 #define GADGET_ID_ELEMENT_CONTENT_4 (GADGET_ID_DRAWING_AREA_FIRST + 5)
413 #define GADGET_ID_ELEMENT_CONTENT_5 (GADGET_ID_DRAWING_AREA_FIRST + 6)
414 #define GADGET_ID_ELEMENT_CONTENT_6 (GADGET_ID_DRAWING_AREA_FIRST + 7)
415 #define GADGET_ID_ELEMENT_CONTENT_7 (GADGET_ID_DRAWING_AREA_FIRST + 8)
416 #define GADGET_ID_AMOEBA_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 9)
417 #define GADGET_ID_CUSTOM_GRAPHIC (GADGET_ID_DRAWING_AREA_FIRST + 10)
418 #define GADGET_ID_CUSTOM_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 11)
419 #define GADGET_ID_CUSTOM_MOVE_ENTER (GADGET_ID_DRAWING_AREA_FIRST + 12)
420 #define GADGET_ID_CUSTOM_MOVE_LEAVE (GADGET_ID_DRAWING_AREA_FIRST + 13)
421 #define GADGET_ID_CUSTOM_CHANGE_TARGET (GADGET_ID_DRAWING_AREA_FIRST + 14)
422 #define GADGET_ID_CUSTOM_CHANGE_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 15)
423 #define GADGET_ID_CUSTOM_CHANGE_TRIGGER (GADGET_ID_DRAWING_AREA_FIRST + 16)
424 #define GADGET_ID_GROUP_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 17)
425 #define GADGET_ID_RANDOM_BACKGROUND (GADGET_ID_DRAWING_AREA_FIRST + 18)
427 /* text input identifiers */
428 #define GADGET_ID_TEXT_INPUT_FIRST (GADGET_ID_DRAWING_AREA_FIRST + 19)
430 #define GADGET_ID_LEVEL_NAME (GADGET_ID_TEXT_INPUT_FIRST + 0)
431 #define GADGET_ID_LEVEL_AUTHOR (GADGET_ID_TEXT_INPUT_FIRST + 1)
432 #define GADGET_ID_ELEMENT_NAME (GADGET_ID_TEXT_INPUT_FIRST + 2)
434 /* text area identifiers */
435 #define GADGET_ID_TEXT_AREA_FIRST (GADGET_ID_TEXT_INPUT_FIRST + 3)
437 #define GADGET_ID_ENVELOPE_INFO (GADGET_ID_TEXT_AREA_FIRST + 0)
439 /* selectbox identifiers */
440 #define GADGET_ID_SELECTBOX_FIRST (GADGET_ID_TEXT_AREA_FIRST + 1)
442 #define GADGET_ID_CUSTOM_WALK_TO_ACTION (GADGET_ID_SELECTBOX_FIRST + 0)
443 #define GADGET_ID_CUSTOM_CONSISTENCY (GADGET_ID_SELECTBOX_FIRST + 1)
444 #define GADGET_ID_CUSTOM_DEADLINESS (GADGET_ID_SELECTBOX_FIRST + 2)
445 #define GADGET_ID_CUSTOM_MOVE_PATTERN (GADGET_ID_SELECTBOX_FIRST + 3)
446 #define GADGET_ID_CUSTOM_MOVE_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 4)
447 #define GADGET_ID_CUSTOM_MOVE_STEPSIZE (GADGET_ID_SELECTBOX_FIRST + 5)
448 #define GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE (GADGET_ID_SELECTBOX_FIRST + 6)
449 #define GADGET_ID_CUSTOM_SMASH_TARGETS (GADGET_ID_SELECTBOX_FIRST + 7)
450 #define GADGET_ID_CUSTOM_SLIPPERY_TYPE (GADGET_ID_SELECTBOX_FIRST + 8)
451 #define GADGET_ID_CUSTOM_ACCESS_TYPE (GADGET_ID_SELECTBOX_FIRST + 9)
452 #define GADGET_ID_CUSTOM_ACCESS_LAYER (GADGET_ID_SELECTBOX_FIRST + 10)
453 #define GADGET_ID_CUSTOM_ACCESS_PROTECTED (GADGET_ID_SELECTBOX_FIRST + 11)
454 #define GADGET_ID_CUSTOM_ACCESS_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 12)
455 #define GADGET_ID_CHANGE_TIME_UNITS (GADGET_ID_SELECTBOX_FIRST + 13)
456 #define GADGET_ID_CHANGE_DIRECT_ACTION (GADGET_ID_SELECTBOX_FIRST + 14)
457 #define GADGET_ID_CHANGE_OTHER_ACTION (GADGET_ID_SELECTBOX_FIRST + 15)
458 #define GADGET_ID_CHANGE_SIDES (GADGET_ID_SELECTBOX_FIRST + 16)
459 #define GADGET_ID_CHANGE_POWER (GADGET_ID_SELECTBOX_FIRST + 17)
460 #define GADGET_ID_SELECT_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 18)
461 #define GADGET_ID_GROUP_CHOICE_MODE (GADGET_ID_SELECTBOX_FIRST + 19)
463 /* textbutton identifiers */
464 #define GADGET_ID_TEXTBUTTON_FIRST (GADGET_ID_SELECTBOX_FIRST + 20)
466 #define GADGET_ID_PROPERTIES_INFO (GADGET_ID_TEXTBUTTON_FIRST + 0)
467 #define GADGET_ID_PROPERTIES_CONFIG (GADGET_ID_TEXTBUTTON_FIRST + 1)
468 #define GADGET_ID_PROPERTIES_CONFIG_1 (GADGET_ID_TEXTBUTTON_FIRST + 2)
469 #define GADGET_ID_PROPERTIES_CONFIG_2 (GADGET_ID_TEXTBUTTON_FIRST + 3)
470 #define GADGET_ID_PROPERTIES_CHANGE (GADGET_ID_TEXTBUTTON_FIRST + 4)
471 #define GADGET_ID_SAVE_AS_TEMPLATE (GADGET_ID_TEXTBUTTON_FIRST + 5)
472 #define GADGET_ID_ADD_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 6)
473 #define GADGET_ID_DEL_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 7)
475 /* graphicbutton identifiers */
476 #define GADGET_ID_GRAPHICBUTTON_FIRST (GADGET_ID_TEXTBUTTON_FIRST + 8)
478 #define GADGET_ID_PREV_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 0)
479 #define GADGET_ID_NEXT_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 1)
481 /* gadgets for scrolling of drawing area */
482 #define GADGET_ID_SCROLLING_FIRST (GADGET_ID_GRAPHICBUTTON_FIRST + 2)
484 #define GADGET_ID_SCROLL_UP (GADGET_ID_SCROLLING_FIRST + 0)
485 #define GADGET_ID_SCROLL_DOWN (GADGET_ID_SCROLLING_FIRST + 1)
486 #define GADGET_ID_SCROLL_LEFT (GADGET_ID_SCROLLING_FIRST + 2)
487 #define GADGET_ID_SCROLL_RIGHT (GADGET_ID_SCROLLING_FIRST + 3)
488 #define GADGET_ID_SCROLL_HORIZONTAL (GADGET_ID_SCROLLING_FIRST + 4)
489 #define GADGET_ID_SCROLL_VERTICAL (GADGET_ID_SCROLLING_FIRST + 5)
491 /* gadgets for scrolling element list */
492 #define GADGET_ID_SCROLLING_LIST_FIRST (GADGET_ID_SCROLLING_FIRST + 6)
494 #define GADGET_ID_SCROLL_LIST_UP (GADGET_ID_SCROLLING_LIST_FIRST + 0)
495 #define GADGET_ID_SCROLL_LIST_DOWN (GADGET_ID_SCROLLING_LIST_FIRST + 1)
496 #define GADGET_ID_SCROLL_LIST_VERTICAL (GADGET_ID_SCROLLING_LIST_FIRST + 2)
498 /* checkbuttons/radiobuttons for level/element properties */
499 #define GADGET_ID_CHECKBUTTON_FIRST (GADGET_ID_SCROLLING_LIST_FIRST + 3)
501 #define GADGET_ID_RANDOM_PERCENTAGE (GADGET_ID_CHECKBUTTON_FIRST + 0)
502 #define GADGET_ID_RANDOM_QUANTITY (GADGET_ID_CHECKBUTTON_FIRST + 1)
503 #define GADGET_ID_RANDOM_RESTRICTED (GADGET_ID_CHECKBUTTON_FIRST + 2)
504 #define GADGET_ID_DOUBLE_SPEED (GADGET_ID_CHECKBUTTON_FIRST + 3)
505 #define GADGET_ID_GRAVITY (GADGET_ID_CHECKBUTTON_FIRST + 4)
506 #define GADGET_ID_STICK_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 5)
507 #define GADGET_ID_EM_SLIPPERY_GEMS (GADGET_ID_CHECKBUTTON_FIRST + 6)
508 #define GADGET_ID_BLOCK_LAST_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 7)
509 #define GADGET_ID_SP_BLOCK_LAST_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 8)
510 #define GADGET_ID_CUSTOM_EXPLODE_RESULT (GADGET_ID_CHECKBUTTON_FIRST + 9)
511 #define GADGET_ID_CUSTOM_EXPLODE_FIRE (GADGET_ID_CHECKBUTTON_FIRST + 10)
512 #define GADGET_ID_CUSTOM_EXPLODE_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 11)
513 #define GADGET_ID_CUSTOM_EXPLODE_IMPACT (GADGET_ID_CHECKBUTTON_FIRST + 12)
514 #define GADGET_ID_CUSTOM_WALK_TO_OBJECT (GADGET_ID_CHECKBUTTON_FIRST + 13)
515 #define GADGET_ID_CUSTOM_DEADLY (GADGET_ID_CHECKBUTTON_FIRST + 14)
516 #define GADGET_ID_CUSTOM_CAN_MOVE (GADGET_ID_CHECKBUTTON_FIRST + 15)
517 #define GADGET_ID_CUSTOM_CAN_FALL (GADGET_ID_CHECKBUTTON_FIRST + 16)
518 #define GADGET_ID_CUSTOM_CAN_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 17)
519 #define GADGET_ID_CUSTOM_SLIPPERY (GADGET_ID_CHECKBUTTON_FIRST + 18)
520 #define GADGET_ID_CUSTOM_ACCESSIBLE (GADGET_ID_CHECKBUTTON_FIRST + 19)
521 #define GADGET_ID_CUSTOM_USE_GRAPHIC (GADGET_ID_CHECKBUTTON_FIRST + 20)
522 #define GADGET_ID_CUSTOM_USE_TEMPLATE (GADGET_ID_CHECKBUTTON_FIRST + 21)
523 #define GADGET_ID_CUSTOM_CAN_CHANGE (GADGET_ID_CHECKBUTTON_FIRST + 22)
524 #define GADGET_ID_CHANGE_USE_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 23)
525 #define GADGET_ID_CHANGE_USE_EXPLOSION (GADGET_ID_CHECKBUTTON_FIRST + 24)
526 #define GADGET_ID_CHANGE_ONLY_COMPLETE (GADGET_ID_CHECKBUTTON_FIRST + 25)
527 #define GADGET_ID_CHANGE_USE_RANDOM (GADGET_ID_CHECKBUTTON_FIRST + 26)
528 #define GADGET_ID_CHANGE_DELAY (GADGET_ID_CHECKBUTTON_FIRST + 27)
529 #define GADGET_ID_CHANGE_BY_DIRECT_ACT (GADGET_ID_CHECKBUTTON_FIRST + 28)
530 #define GADGET_ID_CHANGE_BY_OTHER_ACT (GADGET_ID_CHECKBUTTON_FIRST + 29)
532 /* gadgets for buttons in element list */
533 #define GADGET_ID_ELEMENTLIST_FIRST (GADGET_ID_CHECKBUTTON_FIRST + 30)
534 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
535 ED_NUM_ELEMENTLIST_BUTTONS - 1)
537 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
539 /* radio button numbers */
540 #define RADIO_NR_NONE 0
541 #define RADIO_NR_DRAWING_TOOLBOX 1
542 #define RADIO_NR_RANDOM_ELEMENTS 2
544 /* values for counter gadgets */
545 #define ED_COUNTER_ID_SELECT_LEVEL 0
546 #define ED_COUNTER_ID_LEVEL_XSIZE 1
547 #define ED_COUNTER_ID_LEVEL_YSIZE 2
548 #define ED_COUNTER_ID_LEVEL_GEMSLIMIT 3
549 #define ED_COUNTER_ID_LEVEL_TIMELIMIT 4
550 #define ED_COUNTER_ID_LEVEL_TIMESCORE 5
551 #define ED_COUNTER_ID_LEVEL_RANDOM 6
552 #define ED_COUNTER_ID_ELEMENT_SCORE 7
553 #define ED_COUNTER_ID_ELEMENT_CONTENT 8
554 #define ED_COUNTER_ID_ENVELOPE_XSIZE 9
555 #define ED_COUNTER_ID_ENVELOPE_YSIZE 10
556 #define ED_COUNTER_ID_CUSTOM_SCORE 11
557 #define ED_COUNTER_ID_CUSTOM_GEMCOUNT 12
558 #define ED_COUNTER_ID_PUSH_DELAY_FIX 13
559 #define ED_COUNTER_ID_PUSH_DELAY_RND 14
560 #define ED_COUNTER_ID_MOVE_DELAY_FIX 15
561 #define ED_COUNTER_ID_MOVE_DELAY_RND 16
562 #define ED_COUNTER_ID_EXPLOSION_DELAY 17
563 #define ED_COUNTER_ID_IGNITION_DELAY 18
564 #define ED_COUNTER_ID_GROUP_CONTENT 19
565 #define ED_COUNTER_ID_CHANGE_DELAY_FIX 20
566 #define ED_COUNTER_ID_CHANGE_DELAY_RND 21
567 #define ED_COUNTER_ID_CHANGE_CONT_RND 22
569 #define ED_NUM_COUNTERBUTTONS 23
571 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
572 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM
574 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
575 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_MOVE_DELAY_RND
576 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_EXPLOSION_DELAY
577 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
578 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
579 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
581 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
582 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
584 /* values for scrollbutton gadgets */
585 #define ED_SCROLLBUTTON_ID_AREA_UP 0
586 #define ED_SCROLLBUTTON_ID_AREA_DOWN 1
587 #define ED_SCROLLBUTTON_ID_AREA_LEFT 2
588 #define ED_SCROLLBUTTON_ID_AREA_RIGHT 3
589 #define ED_SCROLLBUTTON_ID_LIST_UP 4
590 #define ED_SCROLLBUTTON_ID_LIST_DOWN 5
592 #define ED_NUM_SCROLLBUTTONS 6
594 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
595 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
597 /* values for scrollbar gadgets */
598 #define ED_SCROLLBAR_ID_AREA_HORIZONTAL 0
599 #define ED_SCROLLBAR_ID_AREA_VERTICAL 1
600 #define ED_SCROLLBAR_ID_LIST_VERTICAL 2
602 #define ED_NUM_SCROLLBARS 3
604 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
605 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
607 /* values for text input gadgets */
608 #define ED_TEXTINPUT_ID_LEVEL_NAME 0
609 #define ED_TEXTINPUT_ID_LEVEL_AUTHOR 1
610 #define ED_TEXTINPUT_ID_ELEMENT_NAME 2
612 #define ED_NUM_TEXTINPUT 3
614 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
615 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
617 /* values for text area gadgets */
618 #define ED_TEXTAREA_ID_ENVELOPE_INFO 0
620 #define ED_NUM_TEXTAREAS 1
622 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
623 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
625 /* values for selectbox gadgets */
626 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE 0
627 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER 1
628 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED 2
629 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION 3
630 #define ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION 4
631 #define ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN 5
632 #define ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION 6
633 #define ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE 7
634 #define ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE 8
635 #define ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS 9
636 #define ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE 10
637 #define ED_SELECTBOX_ID_CUSTOM_DEADLINESS 11
638 #define ED_SELECTBOX_ID_CUSTOM_CONSISTENCY 12
639 #define ED_SELECTBOX_ID_CHANGE_TIME_UNITS 13
640 #define ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION 14
641 #define ED_SELECTBOX_ID_CHANGE_OTHER_ACTION 15
642 #define ED_SELECTBOX_ID_CHANGE_SIDES 16
643 #define ED_SELECTBOX_ID_CHANGE_POWER 17
644 #define ED_SELECTBOX_ID_SELECT_CHANGE_PAGE 18
645 #define ED_SELECTBOX_ID_GROUP_CHOICE_MODE 19
647 #define ED_NUM_SELECTBOX 20
649 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
650 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE
651 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_DEADLINESS
652 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_CONSISTENCY
653 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
654 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
656 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
657 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
659 /* values for textbutton gadgets */
660 #define ED_TEXTBUTTON_ID_PROPERTIES_INFO 0
661 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG 1
662 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1 2
663 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2 3
664 #define ED_TEXTBUTTON_ID_PROPERTIES_CHANGE 4
665 #define ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE 5
666 #define ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE 6
667 #define ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE 7
669 #define ED_NUM_TEXTBUTTONS 8
671 #define ED_TEXTBUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
672 #define ED_TEXTBUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
674 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
675 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
677 /* values for graphicbutton gadgets */
678 #define ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE 0
679 #define ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE 1
681 #define ED_NUM_GRAPHICBUTTONS 2
683 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
684 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE
686 /* values for checkbutton gadgets */
687 #define ED_CHECKBUTTON_ID_DOUBLE_SPEED 0
688 #define ED_CHECKBUTTON_ID_GRAVITY 1
689 #define ED_CHECKBUTTON_ID_RANDOM_RESTRICTED 2
690 #define ED_CHECKBUTTON_ID_STICK_ELEMENT 3
691 #define ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS 4
692 #define ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD 5
693 #define ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD 6
694 #define ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC 7
695 #define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE 8
696 #define ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE 9
697 #define ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT 10
698 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE 11
699 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL 12
700 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH 13
701 #define ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY 14
702 #define ED_CHECKBUTTON_ID_CUSTOM_DEADLY 15
703 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_RESULT 16
704 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE 17
705 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH 18
706 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT 19
707 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE 20
708 #define ED_CHECKBUTTON_ID_CHANGE_DELAY 21
709 #define ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT 22
710 #define ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT 23
711 #define ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION 24
712 #define ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT 25
713 #define ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE 26
714 #define ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM 27
716 #define ED_NUM_CHECKBUTTONS 28
718 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_DOUBLE_SPEED
719 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
721 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
722 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY
723 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_DEADLY
724 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
725 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
726 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
728 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
729 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM
731 /* values for radiobutton gadgets */
732 #define ED_RADIOBUTTON_ID_PERCENTAGE 0
733 #define ED_RADIOBUTTON_ID_QUANTITY 1
735 #define ED_NUM_RADIOBUTTONS 2
737 #define ED_RADIOBUTTON_ID_LEVEL_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
738 #define ED_RADIOBUTTON_ID_LEVEL_LAST ED_RADIOBUTTON_ID_QUANTITY
740 /* values for drawing area gadgets */
741 #define ED_DRAWING_ID_DRAWING_LEVEL 0
742 #define ED_DRAWING_ID_ELEMENT_CONTENT_0 1
743 #define ED_DRAWING_ID_ELEMENT_CONTENT_1 2
744 #define ED_DRAWING_ID_ELEMENT_CONTENT_2 3
745 #define ED_DRAWING_ID_ELEMENT_CONTENT_3 4
746 #define ED_DRAWING_ID_ELEMENT_CONTENT_4 5
747 #define ED_DRAWING_ID_ELEMENT_CONTENT_5 6
748 #define ED_DRAWING_ID_ELEMENT_CONTENT_6 7
749 #define ED_DRAWING_ID_ELEMENT_CONTENT_7 8
750 #define ED_DRAWING_ID_AMOEBA_CONTENT 9
751 #define ED_DRAWING_ID_CUSTOM_GRAPHIC 10
752 #define ED_DRAWING_ID_CUSTOM_CONTENT 11
753 #define ED_DRAWING_ID_CUSTOM_MOVE_ENTER 12
754 #define ED_DRAWING_ID_CUSTOM_MOVE_LEAVE 13
755 #define ED_DRAWING_ID_CUSTOM_CHANGE_TARGET 14
756 #define ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT 15
757 #define ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER 16
758 #define ED_DRAWING_ID_GROUP_CONTENT 17
759 #define ED_DRAWING_ID_RANDOM_BACKGROUND 18
761 #define ED_NUM_DRAWING_AREAS 19
765 -----------------------------------------------------------------------------
766 some internally used definitions
767 -----------------------------------------------------------------------------
770 /* values for CopyLevelToUndoBuffer() */
771 #define UNDO_IMMEDIATE 0
772 #define UNDO_ACCUMULATE 1
774 /* values for scrollbars */
775 #define ED_SCROLL_NO 0
776 #define ED_SCROLL_LEFT 1
777 #define ED_SCROLL_RIGHT 2
778 #define ED_SCROLL_UP 4
779 #define ED_SCROLL_DOWN 8
781 /* screens in the level editor */
782 #define ED_MODE_DRAWING 0
783 #define ED_MODE_INFO 1
784 #define ED_MODE_PROPERTIES 2
786 /* sub-screens in the element properties section */
787 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
788 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
789 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
790 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
791 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
793 /* how many steps can be cancelled */
794 #define NUM_UNDO_STEPS (10 + 1)
796 /* values for elements with score for certain actions */
798 #define MAX_SCORE 255
800 /* values for elements with count for collecting */
801 #define MIN_COLLECT_COUNT 0
802 #define MAX_COLLECT_COUNT 100
804 /* values for random placement */
805 #define RANDOM_USE_PERCENTAGE 0
806 #define RANDOM_USE_QUANTITY 1
808 /* maximal size of level editor drawing area */
809 #define MAX_ED_FIELDX (2 * SCR_FIELDX)
810 #define MAX_ED_FIELDY (2 * SCR_FIELDY - 1)
814 -----------------------------------------------------------------------------
815 some internally used data structure definitions
816 -----------------------------------------------------------------------------
823 } control_info[ED_NUM_CTRL_BUTTONS] =
825 { 's', "draw single items" },
826 { 'd', "draw connected items" },
827 { 'l', "draw lines" },
828 { 'a', "draw arcs" },
829 { 'r', "draw outline rectangles" },
830 { 'R', "draw filled rectangles" },
831 { '\0', "wrap (rotate) level up" },
832 { 't', "enter text elements" },
833 { 'f', "flood fill" },
834 { '\0', "wrap (rotate) level left" },
835 { '?', "properties of drawing element" },
836 { '\0', "wrap (rotate) level right" },
837 { '\0', "random element placement" },
838 { 'b', "grab brush" },
839 { '\0', "wrap (rotate) level down" },
840 { ',', "pick drawing element" },
842 { 'U', "undo last operation" },
843 { 'I', "level properties" },
844 { 'S', "save level" },
845 { 'C', "clear level" },
846 { 'T', "test level" },
847 { 'E', "exit level editor" },
849 { '\0', "copy settings from other element" },
850 { '\0', "copy settings to other element" },
851 { '\0', "exchange settings with other element" },
854 static int random_placement_value = 10;
855 static int random_placement_method = RANDOM_USE_QUANTITY;
856 static int random_placement_background_element = EL_SAND;
857 static boolean random_placement_background_restricted = FALSE;
858 static boolean stick_element_properties_window = FALSE;
859 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
860 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
861 static struct ElementChangeInfo custom_element_change;
862 static struct ElementGroupInfo group_element_info;
863 static struct ElementInfo custom_element;
868 int min_value, max_value;
869 int gadget_id_down, gadget_id_up;
873 char *text_above, *text_left, *text_right;
874 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
876 /* ---------- level and editor settings ---------------------------------- */
879 DX + 5 - SX, DY + 3 - SY,
881 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
882 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
887 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(2),
888 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
889 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
890 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
892 "playfield size:", NULL, "width",
895 -1, ED_COUNTER_YPOS(2),
896 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
897 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
898 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
903 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(3),
905 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
906 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
908 "number of emeralds to collect:", NULL, NULL
911 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(4),
913 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
914 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
916 "time available to solve level:", NULL, "(0 => no time limit)"
919 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(5),
921 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
922 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
923 &level.score[SC_TIME_BONUS],
924 "score for each 10 seconds left:", NULL, NULL
927 ED_SETTINGS_XPOS(0), ED_COUNTER2_YPOS(8),
929 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
930 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
931 &random_placement_value,
932 "random element placement:", NULL, "in"
935 /* ---------- element settings: configure (various elements) ------------- */
938 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(0),
939 MIN_SCORE, MAX_SCORE,
940 GADGET_ID_ELEMENT_SCORE_DOWN, GADGET_ID_ELEMENT_SCORE_UP,
941 GADGET_ID_ELEMENT_SCORE_TEXT, GADGET_ID_NONE,
942 NULL, /* will be set when used */
946 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(6),
947 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
948 GADGET_ID_ELEMENT_CONTENT_DOWN, GADGET_ID_ELEMENT_CONTENT_UP,
949 GADGET_ID_ELEMENT_CONTENT_TEXT, GADGET_ID_NONE,
950 &level.num_yamyam_contents,
951 NULL, NULL, "number of content areas"
954 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(0),
955 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
956 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
957 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
962 -1, ED_SETTINGS_YPOS(0),
963 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
964 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
965 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
970 /* ---------- element settings: configure 1 (custom elements) ------------ */
973 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(6),
974 MIN_SCORE, MAX_SCORE,
975 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
976 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
977 &custom_element.collect_score,
981 -1, ED_SETTINGS_YPOS(6),
982 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
983 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
984 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
985 &custom_element.collect_count,
989 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(7),
991 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
992 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
993 &custom_element.push_delay_fixed,
994 NULL, "push delay", NULL
997 -1, ED_SETTINGS_YPOS(7),
999 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1000 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1001 &custom_element.push_delay_random,
1002 NULL, "+random", NULL
1005 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(12),
1007 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1008 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1009 &custom_element.move_delay_fixed,
1010 NULL, "move delay", NULL
1013 -1, ED_SETTINGS_YPOS(12),
1015 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1016 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1017 &custom_element.move_delay_random,
1018 NULL, "+random", NULL
1021 /* ---------- element settings: configure 2 (custom elements) ------------ */
1024 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(4),
1026 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1027 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1028 &custom_element.explosion_delay,
1029 NULL, "explosion delay", NULL
1032 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(5),
1034 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1035 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1036 &custom_element.ignition_delay,
1037 NULL, "ignition delay", "(by fire)"
1040 /* ---------- element settings: configure (group elements) --------------- */
1043 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(5),
1044 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1045 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1046 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1047 &group_element_info.num_elements,
1048 NULL, NULL, "number of elements in group"
1051 /* ---------- element settings: advanced (custom elements) --------------- */
1054 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(2),
1056 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1057 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1058 &custom_element_change.delay_fixed,
1059 NULL, "delay", NULL,
1062 -1, ED_SETTINGS_YPOS(2),
1064 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1065 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1066 &custom_element_change.delay_random,
1067 NULL, "+random", NULL
1070 ED_SETTINGS_XPOS(3), ED_SETTINGS_YPOS(11),
1072 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1073 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1074 &custom_element_change.random,
1075 NULL, "use random replace:", "%"
1085 char *text_above, *infotext;
1086 } textinput_info[ED_NUM_TEXTINPUT] =
1089 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(0),
1090 GADGET_ID_LEVEL_NAME,
1096 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(1),
1097 GADGET_ID_LEVEL_AUTHOR,
1098 MAX_LEVEL_AUTHOR_LEN,
1103 5 * MINI_TILEX - 2, 5 * MINI_TILEY - ED_BORDER_SIZE + 1,
1104 GADGET_ID_ELEMENT_NAME,
1105 MAX_ELEMENT_NAME_LEN - 2, /* currently 2 chars less editable */
1106 custom_element.description,
1107 NULL, "Element name"
1117 char *text_above, *infotext;
1118 } textarea_info[ED_NUM_TEXTAREAS] =
1121 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(2),
1122 GADGET_ID_ENVELOPE_INFO,
1123 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1125 "Envelope Info:", "Envelope Info"
1129 static struct ValueTextInfo options_access_type[] =
1131 { EP_WALKABLE, "walkable" },
1132 { EP_PASSABLE, "passable" },
1136 static struct ValueTextInfo options_access_layer[] =
1138 { EP_ACCESSIBLE_OVER, "over" },
1139 { EP_ACCESSIBLE_INSIDE, "inside" },
1140 { EP_ACCESSIBLE_UNDER, "under" },
1144 static struct ValueTextInfo options_access_protected[] =
1146 { 0, "unprotected" },
1151 static struct ValueTextInfo options_access_direction[] =
1153 { MV_LEFT, "left" },
1154 { MV_RIGHT, "right" },
1156 { MV_DOWN, "down" },
1157 { MV_LEFT | MV_UP, "left + up" },
1158 { MV_LEFT | MV_DOWN, "left + down" },
1159 { MV_RIGHT | MV_UP, "right + up" },
1160 { MV_RIGHT | MV_DOWN, "right + down" },
1161 { MV_HORIZONTAL, "horizontal" },
1162 { MV_VERTICAL, "vertical" },
1163 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1164 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1165 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1166 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1167 { MV_ALL_DIRECTIONS, "all directions" },
1171 static struct ValueTextInfo options_walk_to_action[] =
1173 { EP_DIGGABLE, "diggable" },
1174 { EP_COLLECTIBLE_ONLY, "collectible" },
1175 { EP_DROPPABLE, "collectible & droppable" },
1176 { EP_PUSHABLE, "pushable" },
1180 static struct ValueTextInfo options_move_pattern[] =
1182 { MV_LEFT, "left" },
1183 { MV_RIGHT, "right" },
1185 { MV_DOWN, "down" },
1186 { MV_HORIZONTAL, "horizontal" },
1187 { MV_VERTICAL, "vertical" },
1188 { MV_ALL_DIRECTIONS, "all directions" },
1189 { MV_TOWARDS_PLAYER, "towards player" },
1190 { MV_AWAY_FROM_PLAYER, "away from player" },
1191 { MV_ALONG_LEFT_SIDE, "along left side" },
1192 { MV_ALONG_RIGHT_SIDE, "along right side" },
1193 { MV_TURNING_LEFT, "turning left" },
1194 { MV_TURNING_RIGHT, "turning right" },
1195 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1196 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1197 { MV_TURNING_RANDOM, "turning random" },
1198 { MV_WHEN_PUSHED, "when pushed" },
1199 { MV_WHEN_DROPPED, "when dropped" },
1200 { MV_MAZE_RUNNER, "maze runner style" },
1201 { MV_MAZE_HUNTER, "maze hunter style" },
1205 static struct ValueTextInfo options_move_direction[] =
1207 { MV_START_AUTOMATIC, "automatic" },
1208 { MV_START_LEFT, "left" },
1209 { MV_START_RIGHT, "right" },
1210 { MV_START_UP, "up" },
1211 { MV_START_DOWN, "down" },
1212 { MV_START_RANDOM, "random" },
1213 { MV_START_PREVIOUS, "previous" },
1217 static struct ValueTextInfo options_move_stepsize[] =
1223 { 16, "very fast" },
1227 static struct ValueTextInfo options_move_leave_type[] =
1229 { LEAVE_TYPE_UNLIMITED, "leave behind" },
1230 { LEAVE_TYPE_LIMITED, "change it to" },
1234 static struct ValueTextInfo options_smash_targets[] =
1236 { EP_CAN_SMASH_PLAYER, "player" },
1238 { EP_CAN_SMASH_ENEMIES, "enemies" },
1240 { EP_CAN_SMASH_EVERYTHING, "everything" },
1244 static struct ValueTextInfo options_slippery_type[] =
1246 { SLIPPERY_ANY_RANDOM, "random" },
1247 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
1248 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
1249 { SLIPPERY_ONLY_LEFT, "only left" },
1250 { SLIPPERY_ONLY_RIGHT, "only right" },
1254 static struct ValueTextInfo options_deadliness[] =
1256 { EP_DONT_RUN_INTO, "running into" },
1257 { EP_DONT_COLLIDE_WITH, "colliding with" },
1258 { EP_DONT_TOUCH, "touching" },
1262 static struct ValueTextInfo options_consistency[] =
1264 { EP_CAN_EXPLODE_3X3, "can explode 3x3" },
1265 { EP_CAN_EXPLODE_DYNA, "can explode 3+3" },
1266 { EP_CAN_EXPLODE_1X1, "can explode 1x1" },
1267 { EP_INDESTRUCTIBLE, "indestructible" },
1271 static struct ValueTextInfo options_time_units[] =
1274 { FRAMES_PER_SECOND, "seconds" },
1278 static struct ValueTextInfo options_change_direct_action[] =
1280 { CE_TOUCHED_BY_PLAYER, "touched by player ..." },
1281 { CE_PRESSED_BY_PLAYER, "pressed by player ..." },
1282 { CE_PUSHED_BY_PLAYER, "pushed by player ..." },
1283 { CE_ENTERED_BY_PLAYER, "entered by player ..." },
1284 { CE_LEFT_BY_PLAYER, "left by player ..." },
1285 { CE_DROPPED_BY_PLAYER, "dropped by player" },
1286 { CE_SWITCHED, "switched ..." },
1288 { CE_HITTING_SOMETHING, "hitting something ..." },
1289 { CE_HIT_BY_SOMETHING, "hit by something ..." },
1291 { CE_HITTING_SOMETHING, "collision ..." },
1293 { CE_IMPACT, "impact (on something)" },
1294 { CE_SMASHED, "smashed (from above)" },
1298 static struct ValueTextInfo options_change_other_action[] =
1300 { CE_OTHER_GETS_TOUCHED, "player touches ..." },
1301 { CE_OTHER_GETS_PRESSED, "player presses ..." },
1302 { CE_OTHER_GETS_PUSHED, "player pushes ..." },
1303 { CE_OTHER_GETS_ENTERED, "player enters ..." },
1304 { CE_OTHER_GETS_LEFT, "player leaves ..." },
1305 { CE_OTHER_GETS_DIGGED, "player digs" },
1306 { CE_OTHER_GETS_COLLECTED, "player collects" },
1307 { CE_OTHER_GETS_DROPPED, "player drops" },
1308 { CE_OTHER_IS_TOUCHING, "touching ..." },
1310 { CE_OTHER_IS_HITTING, "hitting ..." },
1311 { CE_OTHER_GETS_HIT, "hit by ..." },
1313 { CE_OTHER_IS_SWITCHING, "switch of ..." },
1314 { CE_OTHER_IS_CHANGING, "change of" },
1315 { CE_OTHER_IS_EXPLODING, "explosion of" },
1319 static struct ValueTextInfo options_change_sides[] =
1321 { CH_SIDE_LEFT, "left side" },
1322 { CH_SIDE_RIGHT, "right side" },
1323 { CH_SIDE_TOP, "top side" },
1324 { CH_SIDE_BOTTOM, "bottom side" },
1325 { CH_SIDE_LEFT_RIGHT, "left/right side" },
1326 { CH_SIDE_TOP_BOTTOM, "top/bottom side" },
1327 { CH_SIDE_ANY, "any side" },
1331 static struct ValueTextInfo options_change_power[] =
1333 { CP_NON_DESTRUCTIVE, "empty" },
1334 { CP_HALF_DESTRUCTIVE, "diggable" },
1335 { CP_FULL_DESTRUCTIVE, "destructible" },
1339 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
1340 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
1345 static struct ValueTextInfo options_group_choice_mode[] =
1347 { ANIM_RANDOM, "random" },
1348 { ANIM_LOOP, "loop" },
1349 { ANIM_LINEAR, "linear" },
1350 { ANIM_PINGPONG, "pingpong" },
1351 { ANIM_PINGPONG2, "pingpong 2" },
1359 int gadget_id_align;
1360 int size; /* char size of selectbox or '-1' (dynamically determined) */
1361 struct ValueTextInfo *options;
1363 char *text_left, *text_right, *infotext;
1364 } selectbox_info[ED_NUM_SELECTBOX] =
1366 /* ---------- element settings: configure 1 (custom elements) ----------- */
1369 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(3),
1370 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
1372 options_access_type,
1373 &custom_element.access_type,
1374 NULL, NULL, "type of access to this field"
1377 -1, ED_SETTINGS_YPOS(3),
1378 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
1380 options_access_layer,
1381 &custom_element.access_layer,
1382 NULL, NULL, "layer of access for this field"
1385 -1, ED_SETTINGS_YPOS(3),
1386 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
1388 options_access_protected,
1389 &custom_element.access_protected,
1390 NULL, NULL, "protected access for this field"
1393 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(4),
1394 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
1396 options_access_direction,
1397 &custom_element.access_direction,
1398 "from", NULL, "access direction for this field"
1401 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(5),
1402 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
1404 options_walk_to_action,
1405 &custom_element.walk_to_action,
1406 NULL, NULL, "diggable/collectible/pushable"
1409 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(8),
1410 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
1412 options_move_pattern,
1413 &custom_element.move_pattern,
1414 "can move", NULL, "element move direction"
1417 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(9),
1418 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
1420 options_move_direction,
1421 &custom_element.move_direction_initial,
1422 "starts moving", NULL, "initial element move direction"
1425 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(11),
1426 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
1428 options_move_stepsize,
1429 &custom_element.move_stepsize,
1430 "move/fall speed", NULL, "speed of element movement"
1433 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(10),
1434 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
1436 options_move_leave_type,
1437 &custom_element.move_leave_type,
1438 "can dig: can", ":", "leave behind or change element"
1441 -1, ED_SETTINGS_YPOS(13),
1442 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
1444 options_smash_targets,
1445 &custom_element.smash_targets,
1446 "can smash", NULL, "elements that can be smashed"
1449 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(14),
1450 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
1452 options_slippery_type,
1453 &custom_element.slippery_type,
1454 "slippery", NULL, "where other elements fall down"
1457 /* ---------- element settings: configure 2 (custom elements) ----------- */
1460 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(1),
1461 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
1464 &custom_element.deadliness,
1465 "deadly when", NULL, "deadliness of element"
1468 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(2),
1469 GADGET_ID_CUSTOM_CONSISTENCY, GADGET_ID_NONE,
1471 options_consistency,
1472 &custom_element.consistency,
1473 NULL, NULL, "consistency/destructibility"
1476 /* ---------- element settings: advanced (custom elements) --------------- */
1479 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(3),
1480 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
1483 &custom_element_change.delay_frames,
1484 "delay time given in", NULL, "delay time units for change"
1487 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(4),
1488 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
1490 options_change_direct_action,
1491 &custom_element_change.direct_action,
1492 NULL, NULL, "type of direct action"
1495 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(5),
1496 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
1498 options_change_other_action,
1499 &custom_element_change.other_action,
1500 NULL, "element:", "type of other element action"
1503 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(6),
1504 GADGET_ID_CHANGE_SIDES, GADGET_ID_NONE,
1506 options_change_sides,
1507 &custom_element_change.sides,
1508 "... at", NULL, "element side that causes change"
1511 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(9),
1512 GADGET_ID_CHANGE_POWER, GADGET_ID_NONE,
1514 options_change_power,
1515 &custom_element_change.power,
1516 "replace when", NULL, "which elements can be replaced"
1519 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(13),
1520 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
1522 options_change_page,
1523 &custom_element.current_change_page,
1524 NULL, NULL, "element change page"
1527 /* ---------- element settings: configure (group elements) --------------- */
1530 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(6),
1531 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
1533 options_group_choice_mode,
1534 &group_element_info.choice_mode,
1535 "choice type:", NULL, "type of group element choice"
1543 int gadget_id_align;
1546 char *text_left, *text_right, *infotext;
1547 } textbutton_info[ED_NUM_TEXTBUTTONS] =
1551 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(1),
1552 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
1554 NULL, NULL, "Show information about element"
1557 ED_SETTINGS_XPOS(0) + 124, ED_COUNTER_YPOS(1),
1558 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_NONE,
1560 NULL, NULL, "Configure element properties"
1563 ED_SETTINGS_XPOS(0) + 124, ED_COUNTER_YPOS(1),
1564 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_NONE,
1566 NULL, NULL, "Configure custom element properties"
1569 ED_SETTINGS_XPOS(0) + 248, ED_COUNTER_YPOS(1),
1570 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_NONE,
1572 NULL, NULL, "Configure custom element properties"
1575 ED_SETTINGS_XPOS(0) + 372, ED_COUNTER_YPOS(1),
1576 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_NONE,
1578 NULL, NULL, "Custom element change configuration"
1582 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(1),
1583 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
1585 NULL, NULL, "Show information about element"
1588 ED_SETTINGS_XPOS(0) + 166, ED_COUNTER_YPOS(1),
1589 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_NONE,
1591 NULL, NULL, "Configure element properties"
1594 ED_SETTINGS_XPOS(0) + 332, ED_COUNTER_YPOS(1),
1595 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_NONE,
1597 NULL, NULL, "Advanced element configuration"
1601 -1, ED_SETTINGS_YPOS(2),
1602 GADGET_ID_SAVE_AS_TEMPLATE, GADGET_ID_CUSTOM_USE_TEMPLATE,
1604 " ", "As Template", "Save current settings as new template"
1607 -1, ED_SETTINGS_YPOS(13),
1608 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
1610 " ", NULL, "Add new change page"
1613 -1, ED_SETTINGS_YPOS(13),
1614 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
1616 NULL, NULL, "Delete current change page"
1626 int gadget_id_align;
1627 char *text_left, *text_right, *infotext;
1628 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
1631 ED_BUTTON_MINUS_XPOS, ED_BUTTON_COUNT_YPOS,
1632 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(13),
1633 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
1634 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
1635 NULL, NULL, "select previous change page"
1638 ED_BUTTON_PLUS_XPOS, ED_BUTTON_COUNT_YPOS,
1639 -1, ED_SETTINGS_YPOS(13),
1640 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
1641 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
1642 NULL, "change page", "select next change page"
1652 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
1655 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 0 * ED_SCROLLBUTTON_YSIZE,
1656 ED_SCROLL_UP_XPOS, ED_SCROLL_UP_YPOS,
1657 GADGET_ID_SCROLL_UP,
1658 "scroll level editing area up"
1661 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 1 * ED_SCROLLBUTTON_YSIZE,
1662 ED_SCROLL_DOWN_XPOS, ED_SCROLL_DOWN_YPOS,
1663 GADGET_ID_SCROLL_DOWN,
1664 "scroll level editing area down"
1667 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 2 * ED_SCROLLBUTTON_YSIZE,
1668 ED_SCROLL_LEFT_XPOS, ED_SCROLL_LEFT_YPOS,
1669 GADGET_ID_SCROLL_LEFT,
1670 "scroll level editing area left"
1673 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 3 * ED_SCROLLBUTTON_YSIZE,
1674 ED_SCROLL_RIGHT_XPOS, ED_SCROLL_RIGHT_YPOS,
1675 GADGET_ID_SCROLL_RIGHT,
1676 "scroll level editing area right"
1679 ED_SCROLLBUTTON2_XPOS, ED_SCROLLBUTTON2_YPOS + 0 * ED_SCROLLBUTTON2_YSIZE,
1680 ED_SCROLL2_UP_XPOS, ED_SCROLL2_UP_YPOS,
1681 GADGET_ID_SCROLL_LIST_UP,
1682 "scroll element list up ('Page Up')"
1685 ED_SCROLLBUTTON2_XPOS, ED_SCROLLBUTTON2_YPOS + 1 * ED_SCROLLBUTTON2_YSIZE,
1686 ED_SCROLL2_DOWN_XPOS, ED_SCROLL2_DOWN_YPOS,
1687 GADGET_ID_SCROLL_LIST_DOWN,
1688 "scroll element list down ('Page Down')"
1700 } scrollbar_info[ED_NUM_SCROLLBARS] =
1703 ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
1704 SX + ED_SCROLL_HORIZONTAL_XPOS, SY + ED_SCROLL_HORIZONTAL_YPOS,
1705 ED_SCROLL_HORIZONTAL_XSIZE, ED_SCROLL_HORIZONTAL_YSIZE,
1706 GD_TYPE_SCROLLBAR_HORIZONTAL,
1707 GADGET_ID_SCROLL_HORIZONTAL,
1708 "scroll level editing area horizontally"
1711 ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
1712 SX + ED_SCROLL_VERTICAL_XPOS, SY + ED_SCROLL_VERTICAL_YPOS,
1713 ED_SCROLL_VERTICAL_XSIZE, ED_SCROLL_VERTICAL_YSIZE,
1714 GD_TYPE_SCROLLBAR_VERTICAL,
1715 GADGET_ID_SCROLL_VERTICAL,
1716 "scroll level editing area vertically"
1719 ED_SCROLLBAR2_XPOS, ED_SCROLLBAR2_YPOS,
1720 DX + ED_SCROLL2_VERTICAL_XPOS, DY + ED_SCROLL2_VERTICAL_YPOS,
1721 ED_SCROLL2_VERTICAL_XSIZE, ED_SCROLL2_VERTICAL_YSIZE,
1722 GD_TYPE_SCROLLBAR_VERTICAL,
1723 GADGET_ID_SCROLL_LIST_VERTICAL,
1724 "scroll element list vertically"
1732 int gadget_id_align;
1733 int radio_button_nr;
1736 char *text_left, *text_right, *infotext;
1737 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
1740 -1, ED_COUNTER2_YPOS(8),
1741 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
1742 RADIO_NR_RANDOM_ELEMENTS,
1743 &random_placement_method, RANDOM_USE_PERCENTAGE,
1744 " ", "percentage", "use percentage for random elements"
1747 -1, ED_COUNTER2_YPOS(8),
1748 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
1749 RADIO_NR_RANDOM_ELEMENTS,
1750 &random_placement_method, RANDOM_USE_QUANTITY,
1751 " ", "quantity", "use quantity for random elements"
1759 int gadget_id_align;
1761 char *text_left, *text_right, *infotext;
1762 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
1764 /* ---------- level and editor settings ---------------------------------- */
1767 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(6) - MINI_TILEY,
1768 GADGET_ID_DOUBLE_SPEED, GADGET_ID_NONE,
1769 &level.double_speed,
1770 NULL, "double speed movement", "set movement speed of player"
1773 -1, ED_COUNTER_YPOS(6) - MINI_TILEY,
1774 GADGET_ID_GRAVITY, GADGET_ID_DOUBLE_SPEED,
1775 &level.initial_gravity,
1776 " ", "gravity", "set level gravity"
1779 ED_SETTINGS_XPOS(0), ED_COUNTER2_YPOS(9) - MINI_TILEY,
1780 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
1781 &random_placement_background_restricted,
1783 "restrict random placement to:", "set random placement restriction"
1786 /* ---------- element settings: configure (various elements) ------------- */
1789 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(0),
1790 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
1791 &stick_element_properties_window,
1793 "stick this screen to edit content","stick this screen to edit content"
1796 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1),
1797 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
1798 &level.em_slippery_gems,
1800 "slip down from certain flat walls","use EM style slipping behaviour"
1803 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(0),
1804 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
1805 &level.block_last_field,
1807 "block last field when moving", "player blocks last field when moving"
1810 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(4),
1811 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
1812 &level.sp_block_last_field,
1814 "block last field when moving", "player blocks last field when moving"
1817 /* ---------- element settings: configure 1 (custom elements) ----------- */
1820 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1),
1821 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
1822 &custom_element.use_gfx_element,
1823 NULL, "use graphic of element:", "use graphic for custom element"
1826 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(2),
1827 GADGET_ID_CUSTOM_USE_TEMPLATE, GADGET_ID_NONE,
1828 &level.use_custom_template,
1829 NULL, "use template", "use template for custom properties"
1832 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(3),
1833 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
1834 &custom_element_properties[EP_ACCESSIBLE],
1835 NULL, NULL, "player can walk to or pass this field"
1838 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(5),
1839 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
1840 &custom_element_properties[EP_WALK_TO_OBJECT],
1841 NULL, NULL, "player can dig/collect/push element"
1844 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(8),
1845 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
1846 &custom_element_properties[EP_CAN_MOVE],
1847 NULL, NULL, "element can move in some direction"
1850 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(13),
1851 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
1852 &custom_element_properties[EP_CAN_FALL],
1853 NULL, "can fall", "element can fall down"
1856 -1, ED_SETTINGS_YPOS(13),
1857 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
1858 &custom_element_properties[EP_CAN_SMASH],
1859 " ", NULL, "element can smash other elements"
1862 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(14),
1863 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
1864 &custom_element_properties[EP_SLIPPERY],
1865 NULL, NULL, "other elements can fall down from it"
1868 /* ---------- element settings: configure 2 (custom elements) ----------- */
1871 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1),
1872 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
1873 &custom_element_properties[EP_DEADLY],
1874 NULL, NULL, "element can kill the player"
1877 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(2),
1878 GADGET_ID_CUSTOM_EXPLODE_RESULT, GADGET_ID_NONE,
1879 &custom_element_properties[EP_EXPLODE_RESULT],
1880 NULL, NULL, "set consistency/destructibility"
1883 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(3),
1884 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
1885 &custom_element.can_explode_by_fire,
1886 NULL, "by fire", "element can explode by fire/explosion"
1889 -1, ED_SETTINGS_YPOS(3),
1890 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
1891 &custom_element.can_explode_smashed,
1892 " ", "smashed", "element can explode when smashed"
1895 -1, ED_SETTINGS_YPOS(3),
1896 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
1897 &custom_element.can_explode_impact,
1898 " ", "impact", "element can explode on impact"
1901 /* ---------- element settings: advanced (custom elements) --------------- */
1904 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1),
1905 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
1906 &custom_element_change.can_change,
1907 NULL, "element changes to:", "element can change to other element"
1910 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(2),
1911 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
1912 &custom_element_change_events[CE_DELAY],
1913 NULL, NULL, "element changes after delay"
1916 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(4),
1917 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
1918 &custom_element_change_events[CE_BY_DIRECT_ACTION],
1919 NULL, NULL, "element changes by direct action"
1922 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(5),
1923 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
1924 &custom_element_change_events[CE_BY_OTHER_ACTION],
1925 NULL, NULL, "element changes by other element"
1928 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(7),
1929 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
1930 &custom_element_change.explode,
1931 NULL, "explode instead of change", "element explodes instead of change"
1934 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(8),
1935 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
1936 &custom_element_change.use_content,
1937 NULL, "use extended change target:","element changes to more elements"
1940 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(10),
1941 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
1942 &custom_element_change.only_complete,
1943 NULL, "replace all or nothing", "only replace when all can be changed"
1946 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(11),
1947 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
1948 &custom_element_change.use_random_change,
1949 NULL, NULL, "use percentage for random replace"
1956 int area_xsize, area_ysize;
1958 int gadget_id_align;
1959 char *text_left, *text_right, *text_below;
1960 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
1962 /* ---------- level playfield content ------------------------------------ */
1966 MAX_ED_FIELDX, MAX_ED_FIELDY,
1967 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
1971 /* ---------- yam yam content -------------------------------------------- */
1974 ED_AREA_YAMYAM_CONTENT_XPOS(0), ED_AREA_YAMYAM_CONTENT_YPOS(0),
1976 GADGET_ID_ELEMENT_CONTENT_0, GADGET_ID_NONE,
1980 ED_AREA_YAMYAM_CONTENT_XPOS(1), ED_AREA_YAMYAM_CONTENT_YPOS(1),
1982 GADGET_ID_ELEMENT_CONTENT_1, GADGET_ID_NONE,
1986 ED_AREA_YAMYAM_CONTENT_XPOS(2), ED_AREA_YAMYAM_CONTENT_YPOS(2),
1988 GADGET_ID_ELEMENT_CONTENT_2, GADGET_ID_NONE,
1992 ED_AREA_YAMYAM_CONTENT_XPOS(3), ED_AREA_YAMYAM_CONTENT_YPOS(3),
1994 GADGET_ID_ELEMENT_CONTENT_3, GADGET_ID_NONE,
1998 ED_AREA_YAMYAM_CONTENT_XPOS(4), ED_AREA_YAMYAM_CONTENT_YPOS(4),
2000 GADGET_ID_ELEMENT_CONTENT_4, GADGET_ID_NONE,
2004 ED_AREA_YAMYAM_CONTENT_XPOS(5), ED_AREA_YAMYAM_CONTENT_YPOS(5),
2006 GADGET_ID_ELEMENT_CONTENT_5, GADGET_ID_NONE,
2010 ED_AREA_YAMYAM_CONTENT_XPOS(6), ED_AREA_YAMYAM_CONTENT_YPOS(6),
2012 GADGET_ID_ELEMENT_CONTENT_6, GADGET_ID_NONE,
2016 ED_AREA_YAMYAM_CONTENT_XPOS(7), ED_AREA_YAMYAM_CONTENT_YPOS(7),
2018 GADGET_ID_ELEMENT_CONTENT_7, GADGET_ID_NONE,
2022 /* ---------- amoeba content --------------------------------------------- */
2025 ED_AREA_AMOEBA_CONTENT_XPOS, ED_AREA_AMOEBA_CONTENT_YPOS,
2027 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
2028 "content:", NULL, NULL
2031 /* ---------- custom graphic --------------------------------------------- */
2034 -1, ED_AREA_ELEM_CONTENT3_YPOS,
2036 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
2040 /* ---------- custom content (when exploding) ---------------------------- */
2043 ED_AREA_ELEM_CONTENT4_XPOS, ED_AREA_ELEM_CONTENT4_YPOS,
2045 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, /* align three rows */
2046 "content:", NULL, NULL
2049 /* ---------- custom enter and leave element (when moving) --------------- */
2052 ED_SETTINGS_XPOS(1), ED_AREA_ELEM_CONTENT4a_YPOS,
2054 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
2055 "can dig:", " ", NULL
2058 -1, ED_AREA_ELEM_CONTENT4b_YPOS,
2060 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
2064 /* ---------- custom change target --------------------------------------- */
2067 -1, ED_AREA_ELEM_CONTENT2_YPOS,
2069 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
2070 NULL, "after/when:", NULL
2073 /* ---------- custom change content (extended change target) ------------- */
2076 ED_AREA_ELEM_CONTENT6_XPOS, ED_AREA_ELEM_CONTENT6_YPOS,
2078 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, /* align three rows */
2082 /* ---------- custom change trigger (element causing change) ------------- */
2085 -1, ED_AREA_ELEM_CONTENT5_YPOS,
2087 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
2091 /* ---------- group element content -------------------------------------- */
2094 ED_AREA_GROUP_CONTENT_XPOS, ED_AREA_GROUP_CONTENT_YPOS,
2095 MAX_ELEMENTS_IN_GROUP, 1,
2096 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
2097 "content:", NULL, NULL
2100 /* ---------- random background (for random painting) -------------------- */
2103 -1, ED_AREA_RANDOM_BACKGROUND_YPOS,
2105 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
2112 -----------------------------------------------------------------------------
2113 some internally used variables
2114 -----------------------------------------------------------------------------
2117 /* actual size of level editor drawing area */
2118 static int ed_fieldx = MAX_ED_FIELDX - 1, ed_fieldy = MAX_ED_FIELDY - 1;
2120 /* actual position of level editor drawing area in level playfield */
2121 static int level_xpos = -1, level_ypos = -1;
2123 #define IN_ED_FIELD(x,y) ((x)>=0 && (x)<ed_fieldx && (y)>=0 &&(y)<ed_fieldy)
2125 /* drawing elements on the three mouse buttons */
2126 static int new_element1 = EL_WALL;
2127 static int new_element2 = EL_EMPTY;
2128 static int new_element3 = EL_SAND;
2130 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
2131 (button) == 2 ? new_element2 : \
2132 (button) == 3 ? new_element3 : EL_EMPTY)
2133 #define BUTTON_STEPSIZE(button) ((button) == 1 ? 1 : (button) == 2 ? 5 : 10)
2135 /* forward declaration for internal use */
2136 static void ModifyEditorCounter(int, int);
2137 static void ModifyEditorCounterLimits(int, int, int);
2138 static void ModifyEditorSelectbox(int, int);
2139 static void ModifyEditorDrawingArea(int, int, int);
2140 static void ModifyEditorElementList();
2141 static void RedrawDrawingElements();
2142 static void DrawDrawingWindow();
2143 static void DrawLevelInfoWindow();
2144 static void DrawPropertiesWindow();
2145 static void UpdateCustomElementGraphicGadgets();
2146 static boolean checkPropertiesConfig();
2147 static void CopyLevelToUndoBuffer(int);
2148 static void HandleDrawingAreas(struct GadgetInfo *);
2149 static void HandleCounterButtons(struct GadgetInfo *);
2150 static void HandleTextInputGadgets(struct GadgetInfo *);
2151 static void HandleTextAreaGadgets(struct GadgetInfo *);
2152 static void HandleSelectboxGadgets(struct GadgetInfo *);
2153 static void HandleTextbuttonGadgets(struct GadgetInfo *);
2154 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
2155 static void HandleRadiobuttons(struct GadgetInfo *);
2156 static void HandleCheckbuttons(struct GadgetInfo *);
2157 static void HandleControlButtons(struct GadgetInfo *);
2158 static void HandleDrawingAreaInfo(struct GadgetInfo *);
2160 static struct GadgetInfo *level_editor_gadget[NUM_EDITOR_GADGETS];
2161 static int right_gadget_border[NUM_EDITOR_GADGETS];
2163 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
2164 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
2165 static boolean draw_with_brush = FALSE;
2166 static int properties_element = 0;
2168 static short FieldBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2169 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2170 static int undo_buffer_position = 0;
2171 static int undo_buffer_steps = 0;
2173 static int edit_mode;
2174 static int edit_mode_properties;
2176 static int element_shift = 0;
2178 static int editor_hl_boulderdash[] =
2196 static int editor_el_boulderdash[] =
2213 EL_BD_BUTTERFLY_LEFT,
2215 EL_BD_BUTTERFLY_RIGHT,
2216 EL_BD_FIREFLY_RIGHT,
2219 EL_BD_BUTTERFLY_DOWN,
2223 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
2224 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
2225 static int num_editor_hl_boulderdash = SIZEOF_ARRAY_INT(editor_hl_boulderdash);
2226 static int num_editor_el_boulderdash = SIZEOF_ARRAY_INT(editor_el_boulderdash);
2228 static int editor_hl_emerald_mine[] =
2246 static int editor_el_emerald_mine[] =
2293 EL_ACID_POOL_TOPLEFT,
2295 EL_ACID_POOL_TOPRIGHT,
2298 EL_ACID_POOL_BOTTOMLEFT,
2299 EL_ACID_POOL_BOTTOM,
2300 EL_ACID_POOL_BOTTOMRIGHT,
2330 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
2331 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
2332 static int num_editor_hl_emerald_mine=SIZEOF_ARRAY_INT(editor_hl_emerald_mine);
2333 static int num_editor_el_emerald_mine=SIZEOF_ARRAY_INT(editor_el_emerald_mine);
2335 static int editor_hl_more[] =
2343 static int editor_el_more[] =
2371 EL_WALL_EMERALD_YELLOW,
2372 EL_WALL_EMERALD_RED,
2373 EL_WALL_EMERALD_PURPLE,
2390 EL_DYNABOMB_INCREASE_NUMBER,
2391 EL_DYNABOMB_INCREASE_SIZE,
2392 EL_DYNABOMB_INCREASE_POWER,
2413 EL_BALLOON_SWITCH_ANY,
2415 EL_BALLOON_SWITCH_LEFT,
2416 EL_BALLOON_SWITCH_RIGHT,
2417 EL_BALLOON_SWITCH_UP,
2418 EL_BALLOON_SWITCH_DOWN,
2421 EL_EXPANDABLE_WALL_HORIZONTAL,
2422 EL_EXPANDABLE_WALL_VERTICAL,
2423 EL_EXPANDABLE_WALL_ANY,
2425 EL_INVISIBLE_STEELWALL,
2440 static int *editor_hl_more_ptr = editor_hl_more;
2441 static int *editor_el_more_ptr = editor_el_more;
2442 static int num_editor_hl_more = SIZEOF_ARRAY_INT(editor_hl_more);
2443 static int num_editor_el_more = SIZEOF_ARRAY_INT(editor_el_more);
2445 static int editor_hl_sokoban[] =
2458 static int editor_el_sokoban[] =
2461 EL_SOKOBAN_FIELD_EMPTY,
2462 EL_SOKOBAN_FIELD_FULL,
2463 EL_SOKOBAN_FIELD_PLAYER,
2465 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
2466 static int *editor_el_sokoban_ptr = editor_el_sokoban;
2467 static int num_editor_hl_sokoban = SIZEOF_ARRAY_INT(editor_hl_sokoban);
2468 static int num_editor_el_sokoban = SIZEOF_ARRAY_INT(editor_el_sokoban);
2470 static int editor_hl_supaplex[] =
2483 static int editor_el_supaplex[] =
2496 EL_SP_HARDWARE_GRAY,
2505 EL_SP_GRAVITY_PORT_RIGHT,
2506 EL_SP_GRAVITY_PORT_DOWN,
2507 EL_SP_GRAVITY_PORT_LEFT,
2509 EL_SP_GRAVITY_PORT_UP,
2515 EL_SP_PORT_VERTICAL,
2516 EL_SP_PORT_HORIZONTAL,
2524 EL_SP_HARDWARE_BASE_1,
2525 EL_SP_HARDWARE_GREEN,
2526 EL_SP_HARDWARE_BLUE,
2529 EL_SP_HARDWARE_YELLOW,
2530 EL_SP_HARDWARE_BASE_2,
2531 EL_SP_HARDWARE_BASE_3,
2532 EL_SP_HARDWARE_BASE_4,
2534 EL_SP_HARDWARE_BASE_5,
2535 EL_SP_HARDWARE_BASE_6,
2539 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
2540 static int *editor_el_supaplex_ptr = editor_el_supaplex;
2541 static int num_editor_hl_supaplex = SIZEOF_ARRAY_INT(editor_hl_supaplex);
2542 static int num_editor_el_supaplex = SIZEOF_ARRAY_INT(editor_el_supaplex);
2544 static int editor_hl_diamond_caves[] =
2567 static int editor_el_diamond_caves[] =
2574 EL_CONVEYOR_BELT_1_LEFT,
2575 EL_CONVEYOR_BELT_1_MIDDLE,
2576 EL_CONVEYOR_BELT_1_RIGHT,
2577 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
2579 EL_CONVEYOR_BELT_2_LEFT,
2580 EL_CONVEYOR_BELT_2_MIDDLE,
2581 EL_CONVEYOR_BELT_2_RIGHT,
2582 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
2584 EL_CONVEYOR_BELT_3_LEFT,
2585 EL_CONVEYOR_BELT_3_MIDDLE,
2586 EL_CONVEYOR_BELT_3_RIGHT,
2587 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
2589 EL_CONVEYOR_BELT_4_LEFT,
2590 EL_CONVEYOR_BELT_4_MIDDLE,
2591 EL_CONVEYOR_BELT_4_RIGHT,
2592 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
2594 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
2595 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
2596 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
2597 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
2599 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
2600 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
2601 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
2602 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
2605 EL_SWITCHGATE_CLOSED,
2606 EL_SWITCHGATE_SWITCH_UP,
2621 EL_STEELWALL_SLIPPERY,
2624 EL_SIGN_EXCLAMATION,
2627 EL_LIGHT_SWITCH_ACTIVE,
2634 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
2635 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
2636 static int num_editor_hl_diamond_caves = SIZEOF_ARRAY_INT(editor_hl_diamond_caves);
2637 static int num_editor_el_diamond_caves = SIZEOF_ARRAY_INT(editor_el_diamond_caves);
2639 static int editor_hl_dx_boulderdash[] =
2662 static int editor_el_dx_boulderdash[] =
2666 EL_TUBE_HORIZONTAL_DOWN,
2670 EL_TUBE_VERTICAL_RIGHT,
2672 EL_TUBE_VERTICAL_LEFT,
2676 EL_TUBE_HORIZONTAL_UP,
2684 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
2685 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
2686 static int num_editor_hl_dx_boulderdash = SIZEOF_ARRAY_INT(editor_hl_dx_boulderdash);
2687 static int num_editor_el_dx_boulderdash = SIZEOF_ARRAY_INT(editor_el_dx_boulderdash);
2689 static int editor_hl_chars[] =
2697 static int editor_el_chars[] =
2786 EL_CHAR(FONT_ASCII_CURSOR),
2789 static int *editor_hl_chars_ptr = editor_hl_chars;
2790 static int *editor_el_chars_ptr = editor_el_chars;
2791 static int num_editor_hl_chars = SIZEOF_ARRAY_INT(editor_hl_chars);
2792 static int num_editor_el_chars = SIZEOF_ARRAY_INT(editor_el_chars);
2794 static int editor_hl_custom[] =
2817 static int editor_el_custom[] =
2819 EL_CUSTOM_START + 0,
2820 EL_CUSTOM_START + 1,
2821 EL_CUSTOM_START + 2,
2822 EL_CUSTOM_START + 3,
2824 EL_CUSTOM_START + 4,
2825 EL_CUSTOM_START + 5,
2826 EL_CUSTOM_START + 6,
2827 EL_CUSTOM_START + 7,
2829 EL_CUSTOM_START + 8,
2830 EL_CUSTOM_START + 9,
2831 EL_CUSTOM_START + 10,
2832 EL_CUSTOM_START + 11,
2834 EL_CUSTOM_START + 12,
2835 EL_CUSTOM_START + 13,
2836 EL_CUSTOM_START + 14,
2837 EL_CUSTOM_START + 15,
2839 EL_CUSTOM_START + 16,
2840 EL_CUSTOM_START + 17,
2841 EL_CUSTOM_START + 18,
2842 EL_CUSTOM_START + 19,
2844 EL_CUSTOM_START + 20,
2845 EL_CUSTOM_START + 21,
2846 EL_CUSTOM_START + 22,
2847 EL_CUSTOM_START + 23,
2849 EL_CUSTOM_START + 24,
2850 EL_CUSTOM_START + 25,
2851 EL_CUSTOM_START + 26,
2852 EL_CUSTOM_START + 27,
2854 EL_CUSTOM_START + 28,
2855 EL_CUSTOM_START + 29,
2856 EL_CUSTOM_START + 30,
2857 EL_CUSTOM_START + 31,
2859 EL_CUSTOM_START + 32,
2860 EL_CUSTOM_START + 33,
2861 EL_CUSTOM_START + 34,
2862 EL_CUSTOM_START + 35,
2864 EL_CUSTOM_START + 36,
2865 EL_CUSTOM_START + 37,
2866 EL_CUSTOM_START + 38,
2867 EL_CUSTOM_START + 39,
2869 EL_CUSTOM_START + 40,
2870 EL_CUSTOM_START + 41,
2871 EL_CUSTOM_START + 42,
2872 EL_CUSTOM_START + 43,
2874 EL_CUSTOM_START + 44,
2875 EL_CUSTOM_START + 45,
2876 EL_CUSTOM_START + 46,
2877 EL_CUSTOM_START + 47,
2879 EL_CUSTOM_START + 48,
2880 EL_CUSTOM_START + 49,
2881 EL_CUSTOM_START + 50,
2882 EL_CUSTOM_START + 51,
2884 EL_CUSTOM_START + 52,
2885 EL_CUSTOM_START + 53,
2886 EL_CUSTOM_START + 54,
2887 EL_CUSTOM_START + 55,
2889 EL_CUSTOM_START + 56,
2890 EL_CUSTOM_START + 57,
2891 EL_CUSTOM_START + 58,
2892 EL_CUSTOM_START + 59,
2894 EL_CUSTOM_START + 60,
2895 EL_CUSTOM_START + 61,
2896 EL_CUSTOM_START + 62,
2897 EL_CUSTOM_START + 63,
2899 EL_CUSTOM_START + 64,
2900 EL_CUSTOM_START + 65,
2901 EL_CUSTOM_START + 66,
2902 EL_CUSTOM_START + 67,
2904 EL_CUSTOM_START + 68,
2905 EL_CUSTOM_START + 69,
2906 EL_CUSTOM_START + 70,
2907 EL_CUSTOM_START + 71,
2909 EL_CUSTOM_START + 72,
2910 EL_CUSTOM_START + 73,
2911 EL_CUSTOM_START + 74,
2912 EL_CUSTOM_START + 75,
2914 EL_CUSTOM_START + 76,
2915 EL_CUSTOM_START + 77,
2916 EL_CUSTOM_START + 78,
2917 EL_CUSTOM_START + 79,
2919 EL_CUSTOM_START + 80,
2920 EL_CUSTOM_START + 81,
2921 EL_CUSTOM_START + 82,
2922 EL_CUSTOM_START + 83,
2924 EL_CUSTOM_START + 84,
2925 EL_CUSTOM_START + 85,
2926 EL_CUSTOM_START + 86,
2927 EL_CUSTOM_START + 87,
2929 EL_CUSTOM_START + 88,
2930 EL_CUSTOM_START + 89,
2931 EL_CUSTOM_START + 90,
2932 EL_CUSTOM_START + 91,
2934 EL_CUSTOM_START + 92,
2935 EL_CUSTOM_START + 93,
2936 EL_CUSTOM_START + 94,
2937 EL_CUSTOM_START + 95,
2939 EL_CUSTOM_START + 96,
2940 EL_CUSTOM_START + 97,
2941 EL_CUSTOM_START + 98,
2942 EL_CUSTOM_START + 99,
2944 EL_CUSTOM_START + 100,
2945 EL_CUSTOM_START + 101,
2946 EL_CUSTOM_START + 102,
2947 EL_CUSTOM_START + 103,
2949 EL_CUSTOM_START + 104,
2950 EL_CUSTOM_START + 105,
2951 EL_CUSTOM_START + 106,
2952 EL_CUSTOM_START + 107,
2954 EL_CUSTOM_START + 108,
2955 EL_CUSTOM_START + 109,
2956 EL_CUSTOM_START + 110,
2957 EL_CUSTOM_START + 111,
2959 EL_CUSTOM_START + 112,
2960 EL_CUSTOM_START + 113,
2961 EL_CUSTOM_START + 114,
2962 EL_CUSTOM_START + 115,
2964 EL_CUSTOM_START + 116,
2965 EL_CUSTOM_START + 117,
2966 EL_CUSTOM_START + 118,
2967 EL_CUSTOM_START + 119,
2969 EL_CUSTOM_START + 120,
2970 EL_CUSTOM_START + 121,
2971 EL_CUSTOM_START + 122,
2972 EL_CUSTOM_START + 123,
2974 EL_CUSTOM_START + 124,
2975 EL_CUSTOM_START + 125,
2976 EL_CUSTOM_START + 126,
2977 EL_CUSTOM_START + 127
2979 static int *editor_hl_custom_ptr = editor_hl_custom;
2980 static int *editor_el_custom_ptr = editor_el_custom;
2981 static int num_editor_hl_custom = SIZEOF_ARRAY_INT(editor_hl_custom);
2982 static int num_editor_el_custom = SIZEOF_ARRAY_INT(editor_el_custom);
2984 static int editor_hl_custom_more[] =
2988 static int editor_el_custom_more[] =
2990 EL_CUSTOM_START + 128,
2991 EL_CUSTOM_START + 129,
2992 EL_CUSTOM_START + 130,
2993 EL_CUSTOM_START + 131,
2995 EL_CUSTOM_START + 132,
2996 EL_CUSTOM_START + 133,
2997 EL_CUSTOM_START + 134,
2998 EL_CUSTOM_START + 135,
3000 EL_CUSTOM_START + 136,
3001 EL_CUSTOM_START + 137,
3002 EL_CUSTOM_START + 138,
3003 EL_CUSTOM_START + 139,
3005 EL_CUSTOM_START + 140,
3006 EL_CUSTOM_START + 141,
3007 EL_CUSTOM_START + 142,
3008 EL_CUSTOM_START + 143,
3010 EL_CUSTOM_START + 144,
3011 EL_CUSTOM_START + 145,
3012 EL_CUSTOM_START + 146,
3013 EL_CUSTOM_START + 147,
3015 EL_CUSTOM_START + 148,
3016 EL_CUSTOM_START + 149,
3017 EL_CUSTOM_START + 150,
3018 EL_CUSTOM_START + 151,
3020 EL_CUSTOM_START + 152,
3021 EL_CUSTOM_START + 153,
3022 EL_CUSTOM_START + 154,
3023 EL_CUSTOM_START + 155,
3025 EL_CUSTOM_START + 156,
3026 EL_CUSTOM_START + 157,
3027 EL_CUSTOM_START + 158,
3028 EL_CUSTOM_START + 159,
3030 EL_CUSTOM_START + 160,
3031 EL_CUSTOM_START + 161,
3032 EL_CUSTOM_START + 162,
3033 EL_CUSTOM_START + 163,
3035 EL_CUSTOM_START + 164,
3036 EL_CUSTOM_START + 165,
3037 EL_CUSTOM_START + 166,
3038 EL_CUSTOM_START + 167,
3040 EL_CUSTOM_START + 168,
3041 EL_CUSTOM_START + 169,
3042 EL_CUSTOM_START + 170,
3043 EL_CUSTOM_START + 171,
3045 EL_CUSTOM_START + 172,
3046 EL_CUSTOM_START + 173,
3047 EL_CUSTOM_START + 174,
3048 EL_CUSTOM_START + 175,
3050 EL_CUSTOM_START + 176,
3051 EL_CUSTOM_START + 177,
3052 EL_CUSTOM_START + 178,
3053 EL_CUSTOM_START + 179,
3055 EL_CUSTOM_START + 180,
3056 EL_CUSTOM_START + 181,
3057 EL_CUSTOM_START + 182,
3058 EL_CUSTOM_START + 183,
3060 EL_CUSTOM_START + 184,
3061 EL_CUSTOM_START + 185,
3062 EL_CUSTOM_START + 186,
3063 EL_CUSTOM_START + 187,
3065 EL_CUSTOM_START + 188,
3066 EL_CUSTOM_START + 189,
3067 EL_CUSTOM_START + 190,
3068 EL_CUSTOM_START + 191,
3070 EL_CUSTOM_START + 192,
3071 EL_CUSTOM_START + 193,
3072 EL_CUSTOM_START + 194,
3073 EL_CUSTOM_START + 195,
3075 EL_CUSTOM_START + 196,
3076 EL_CUSTOM_START + 197,
3077 EL_CUSTOM_START + 198,
3078 EL_CUSTOM_START + 199,
3080 EL_CUSTOM_START + 200,
3081 EL_CUSTOM_START + 201,
3082 EL_CUSTOM_START + 202,
3083 EL_CUSTOM_START + 203,
3085 EL_CUSTOM_START + 204,
3086 EL_CUSTOM_START + 205,
3087 EL_CUSTOM_START + 206,
3088 EL_CUSTOM_START + 207,
3090 EL_CUSTOM_START + 208,
3091 EL_CUSTOM_START + 209,
3092 EL_CUSTOM_START + 210,
3093 EL_CUSTOM_START + 211,
3095 EL_CUSTOM_START + 212,
3096 EL_CUSTOM_START + 213,
3097 EL_CUSTOM_START + 214,
3098 EL_CUSTOM_START + 215,
3100 EL_CUSTOM_START + 216,
3101 EL_CUSTOM_START + 217,
3102 EL_CUSTOM_START + 218,
3103 EL_CUSTOM_START + 219,
3105 EL_CUSTOM_START + 220,
3106 EL_CUSTOM_START + 221,
3107 EL_CUSTOM_START + 222,
3108 EL_CUSTOM_START + 223,
3110 EL_CUSTOM_START + 224,
3111 EL_CUSTOM_START + 225,
3112 EL_CUSTOM_START + 226,
3113 EL_CUSTOM_START + 227,
3115 EL_CUSTOM_START + 228,
3116 EL_CUSTOM_START + 229,
3117 EL_CUSTOM_START + 230,
3118 EL_CUSTOM_START + 231,
3120 EL_CUSTOM_START + 232,
3121 EL_CUSTOM_START + 233,
3122 EL_CUSTOM_START + 234,
3123 EL_CUSTOM_START + 235,
3125 EL_CUSTOM_START + 236,
3126 EL_CUSTOM_START + 237,
3127 EL_CUSTOM_START + 238,
3128 EL_CUSTOM_START + 239,
3130 EL_CUSTOM_START + 240,
3131 EL_CUSTOM_START + 241,
3132 EL_CUSTOM_START + 242,
3133 EL_CUSTOM_START + 243,
3135 EL_CUSTOM_START + 244,
3136 EL_CUSTOM_START + 245,
3137 EL_CUSTOM_START + 246,
3138 EL_CUSTOM_START + 247,
3140 EL_CUSTOM_START + 248,
3141 EL_CUSTOM_START + 249,
3142 EL_CUSTOM_START + 250,
3143 EL_CUSTOM_START + 251,
3145 EL_CUSTOM_START + 252,
3146 EL_CUSTOM_START + 253,
3147 EL_CUSTOM_START + 254,
3148 EL_CUSTOM_START + 255
3150 static int *editor_hl_custom_more_ptr = editor_hl_custom_more;
3151 static int *editor_el_custom_more_ptr = editor_el_custom_more;
3152 static int num_editor_hl_custom_more = SIZEOF_ARRAY_INT(editor_hl_custom_more);
3153 static int num_editor_el_custom_more = SIZEOF_ARRAY_INT(editor_el_custom_more);
3155 static int editor_hl_group[] =
3178 static int editor_el_group[] =
3192 EL_GROUP_START + 10,
3193 EL_GROUP_START + 11,
3195 EL_GROUP_START + 12,
3196 EL_GROUP_START + 13,
3197 EL_GROUP_START + 14,
3200 static int *editor_hl_group_ptr = editor_hl_group;
3201 static int *editor_el_group_ptr = editor_el_group;
3202 static int num_editor_hl_group = SIZEOF_ARRAY_INT(editor_hl_group);
3203 static int num_editor_el_group = SIZEOF_ARRAY_INT(editor_el_group);
3205 static int editor_hl_group_more[] =
3209 static int editor_el_group_more[] =
3211 EL_GROUP_START + 16,
3212 EL_GROUP_START + 17,
3213 EL_GROUP_START + 18,
3214 EL_GROUP_START + 19,
3216 EL_GROUP_START + 20,
3217 EL_GROUP_START + 21,
3218 EL_GROUP_START + 22,
3219 EL_GROUP_START + 23,
3221 EL_GROUP_START + 24,
3222 EL_GROUP_START + 25,
3223 EL_GROUP_START + 26,
3224 EL_GROUP_START + 27,
3226 EL_GROUP_START + 28,
3227 EL_GROUP_START + 29,
3228 EL_GROUP_START + 30,
3231 static int *editor_hl_group_more_ptr = editor_hl_group_more;
3232 static int *editor_el_group_more_ptr = editor_el_group_more;
3233 static int num_editor_hl_group_more = SIZEOF_ARRAY_INT(editor_hl_group_more);
3234 static int num_editor_el_group_more = SIZEOF_ARRAY_INT(editor_el_group_more);
3236 static int editor_hl_user_defined[] =
3254 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
3255 static int *editor_el_user_defined_ptr = NULL;
3256 static int num_editor_hl_user_defined=SIZEOF_ARRAY_INT(editor_hl_user_defined);
3257 static int num_editor_el_user_defined = 0;
3259 static int editor_hl_empty[] = { };
3260 static int editor_el_empty[ED_NUM_ELEMENTLIST_BUTTONS];
3262 static int *editor_hl_empty_ptr = editor_hl_empty;
3263 static int *editor_el_empty_ptr = editor_el_empty;
3264 static int num_editor_hl_empty = 0;
3265 static int num_editor_el_empty = 0; /* dynamically determined, if needed */
3267 static boolean use_el_empty = FALSE;
3269 static int *editor_elements = NULL; /* dynamically allocated */
3270 static int num_editor_elements = 0; /* dynamically determined */
3274 boolean *setup_value;
3276 int **headline_list;
3277 int *headline_list_size;
3280 int *element_list_size;
3282 boolean last_setup_value;
3284 editor_elements_info[] =
3287 &setup.editor.el_boulderdash,
3288 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
3289 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
3292 &setup.editor.el_emerald_mine,
3293 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
3294 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
3297 &setup.editor.el_more,
3298 &editor_hl_more_ptr, &num_editor_hl_more,
3299 &editor_el_more_ptr, &num_editor_el_more
3302 &setup.editor.el_sokoban,
3303 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
3304 &editor_el_sokoban_ptr, &num_editor_el_sokoban
3307 &setup.editor.el_supaplex,
3308 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
3309 &editor_el_supaplex_ptr, &num_editor_el_supaplex
3312 &setup.editor.el_diamond_caves,
3313 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
3314 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
3317 &setup.editor.el_dx_boulderdash,
3318 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
3319 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
3322 &setup.editor.el_chars,
3323 &editor_hl_chars_ptr, &num_editor_hl_chars,
3324 &editor_el_chars_ptr, &num_editor_el_chars
3327 &setup.editor.el_custom,
3328 &editor_hl_custom_ptr, &num_editor_hl_custom,
3329 &editor_el_custom_ptr, &num_editor_el_custom
3332 &setup.editor.el_custom_more,
3333 &editor_hl_custom_more_ptr, &num_editor_hl_custom_more,
3334 &editor_el_custom_more_ptr, &num_editor_el_custom_more
3337 &setup.editor.el_custom,
3338 &editor_hl_group_ptr, &num_editor_hl_group,
3339 &editor_el_group_ptr, &num_editor_el_group
3342 &setup.editor.el_custom_more,
3343 &editor_hl_group_more_ptr, &num_editor_hl_group_more,
3344 &editor_el_group_more_ptr, &num_editor_el_group_more
3347 &setup.editor.el_user_defined,
3348 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
3349 &editor_el_user_defined_ptr, &num_editor_el_user_defined
3353 &editor_hl_empty_ptr, &num_editor_hl_empty,
3354 &editor_el_empty_ptr, &num_editor_el_empty,
3366 short element_mapped;
3368 forum_sketch_element_mapping[] =
3370 { EL_WALL_SLIPPERY, EL_WALL },
3371 { EL_EXPANDABLE_WALL, EL_WALL },
3372 { EL_EXPANDABLE_WALL_HORIZONTAL, EL_WALL },
3373 { EL_EXPANDABLE_WALL_VERTICAL, EL_WALL },
3374 { EL_EXPANDABLE_WALL_ANY, EL_WALL },
3375 { EL_WALL_EMERALD, EL_WALL },
3376 { EL_WALL_DIAMOND, EL_WALL },
3377 { EL_WALL_BD_DIAMOND, EL_WALL },
3378 { EL_WALL_EMERALD_YELLOW, EL_WALL },
3379 { EL_WALL_EMERALD_RED, EL_WALL },
3380 { EL_WALL_EMERALD_PURPLE, EL_WALL },
3381 { EL_ACID_POOL_TOPLEFT, EL_WALL },
3382 { EL_ACID_POOL_TOPRIGHT, EL_WALL },
3383 { EL_ACID_POOL_BOTTOMLEFT, EL_WALL },
3384 { EL_ACID_POOL_BOTTOM, EL_WALL },
3385 { EL_ACID_POOL_BOTTOMRIGHT, EL_WALL },
3386 { EL_BD_WALL, EL_WALL },
3388 { EL_BD_ROCK, EL_ROCK },
3390 { EL_SP_ZONK, EL_ROCK },
3391 { EL_SP_BASE, EL_SAND },
3392 { EL_SP_MURPHY, EL_PLAYER_1 },
3393 { EL_SP_INFOTRON, EL_EMERALD },
3394 { EL_SP_HARDWARE_GRAY, EL_STEELWALL },
3395 { EL_SP_EXIT_CLOSED, EL_EXIT_OPEN },
3396 { EL_SP_DISK_ORANGE, EL_BOMB },
3397 { EL_SP_DISK_RED, EL_BOMB },
3398 { EL_SP_DISK_YELLOW, EL_BOMB },
3399 { EL_SP_PORT_RIGHT, EL_GATE_1_GRAY },
3400 { EL_SP_PORT_DOWN, EL_GATE_1_GRAY },
3401 { EL_SP_PORT_LEFT, EL_GATE_1_GRAY },
3402 { EL_SP_PORT_UP, EL_GATE_1_GRAY },
3403 { EL_SP_GRAVITY_PORT_RIGHT, EL_GATE_1_GRAY },
3404 { EL_SP_GRAVITY_PORT_DOWN, EL_GATE_1_GRAY },
3405 { EL_SP_GRAVITY_PORT_LEFT, EL_GATE_1_GRAY },
3406 { EL_SP_GRAVITY_PORT_UP, EL_GATE_1_GRAY },
3407 { EL_SP_PORT_VERTICAL, EL_GATE_1_GRAY },
3408 { EL_SP_PORT_HORIZONTAL, EL_GATE_1_GRAY },
3409 { EL_SP_PORT_ANY, EL_GATE_1_GRAY },
3410 { EL_SP_SNIKSNAK, EL_BUG },
3411 { EL_SP_ELECTRON, EL_SPACESHIP },
3412 { EL_SP_CHIP_SINGLE, EL_WALL },
3413 { EL_SP_CHIP_LEFT, EL_WALL },
3414 { EL_SP_CHIP_RIGHT, EL_WALL },
3415 { EL_SP_CHIP_TOP, EL_WALL },
3416 { EL_SP_CHIP_BOTTOM, EL_WALL },
3417 { EL_SP_HARDWARE_BASE_1, EL_STEELWALL },
3418 { EL_SP_HARDWARE_GREEN, EL_STEELWALL },
3419 { EL_SP_HARDWARE_BLUE, EL_STEELWALL },
3420 { EL_SP_HARDWARE_RED, EL_STEELWALL },
3421 { EL_SP_HARDWARE_YELLOW, EL_STEELWALL },
3422 { EL_SP_HARDWARE_BASE_2, EL_STEELWALL },
3423 { EL_SP_HARDWARE_BASE_3, EL_STEELWALL },
3424 { EL_SP_HARDWARE_BASE_3, EL_STEELWALL },
3425 { EL_SP_HARDWARE_BASE_4, EL_STEELWALL },
3426 { EL_SP_HARDWARE_BASE_5, EL_STEELWALL },
3427 { EL_SP_HARDWARE_BASE_6, EL_STEELWALL },
3429 { EL_STEELWALL_SLIPPERY, EL_STEELWALL },
3431 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
3433 { EL_DIAMOND, EL_EMERALD },
3434 { EL_BD_DIAMOND, EL_EMERALD },
3435 { EL_EMERALD_YELLOW, EL_EMERALD },
3436 { EL_EMERALD_RED, EL_EMERALD },
3437 { EL_EMERALD_PURPLE, EL_EMERALD },
3439 { EL_AMOEBA_DEAD, EL_AMOEBA },
3440 { EL_AMOEBA_DROP, EL_AMOEBA },
3441 { EL_AMOEBA_WET, EL_AMOEBA },
3442 { EL_AMOEBA_DRY, EL_AMOEBA },
3443 { EL_AMOEBA_FULL, EL_AMOEBA },
3444 { EL_BD_AMOEBA, EL_AMOEBA },
3445 { EL_AMOEBA_TO_DIAMOND, EL_AMOEBA },
3447 { EL_DYNAMITE_ACTIVE, EL_DYNAMITE },
3449 { EL_GATE_2_GRAY, EL_GATE_1_GRAY },
3450 { EL_GATE_3_GRAY, EL_GATE_1_GRAY },
3451 { EL_GATE_4_GRAY, EL_GATE_1_GRAY },
3453 { EL_EM_KEY_1, EL_KEY_1 },
3454 { EL_EM_KEY_2, EL_KEY_2 },
3455 { EL_EM_KEY_3, EL_KEY_3 },
3456 { EL_EM_KEY_4, EL_KEY_4 },
3458 { EL_EM_GATE_1, EL_GATE_1 },
3459 { EL_EM_GATE_2, EL_GATE_2 },
3460 { EL_EM_GATE_3, EL_GATE_3 },
3461 { EL_EM_GATE_4, EL_GATE_4 },
3463 { EL_EM_GATE_1_GRAY, EL_GATE_1_GRAY },
3464 { EL_EM_GATE_2_GRAY, EL_GATE_1_GRAY },
3465 { EL_EM_GATE_3_GRAY, EL_GATE_1_GRAY },
3466 { EL_EM_GATE_4_GRAY, EL_GATE_1_GRAY },
3468 { EL_INVISIBLE_SAND, EL_EMPTY },
3469 { EL_INVISIBLE_WALL, EL_EMPTY },
3470 { EL_INVISIBLE_STEELWALL, EL_EMPTY },
3472 { EL_PACMAN, EL_YAMYAM },
3473 { EL_DARK_YAMYAM, EL_YAMYAM },
3475 { EL_BD_MAGIC_WALL, EL_MAGIC_WALL },
3477 { EL_DYNABOMB_INCREASE_NUMBER, EL_BOMB },
3478 { EL_DYNABOMB_INCREASE_SIZE, EL_BOMB },
3479 { EL_DYNABOMB_INCREASE_POWER, EL_BOMB },
3480 { EL_BLACK_ORB, EL_BOMB },
3481 { EL_DX_SUPABOMB, EL_BOMB },
3483 { EL_SOKOBAN_OBJECT, EL_KEY_1 },
3484 { EL_SOKOBAN_FIELD_EMPTY, EL_GATE_1_GRAY },
3485 { EL_SOKOBAN_FIELD_FULL, EL_GATE_1 },
3486 { EL_SOKOBAN_FIELD_PLAYER, EL_PLAYER_1 },
3488 { EL_BD_BUTTERFLY_RIGHT, EL_BD_BUTTERFLY },
3489 { EL_BD_BUTTERFLY_UP, EL_BD_BUTTERFLY },
3490 { EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY },
3491 { EL_BD_BUTTERFLY_DOWN, EL_BD_BUTTERFLY },
3493 { EL_BD_FIREFLY_RIGHT, EL_BD_FIREFLY },
3494 { EL_BD_FIREFLY_UP, EL_BD_FIREFLY },
3495 { EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY },
3496 { EL_BD_FIREFLY_DOWN, EL_BD_FIREFLY },
3498 { EL_PLAYER_2, EL_PLAYER_1 },
3499 { EL_PLAYER_3, EL_PLAYER_1 },
3500 { EL_PLAYER_4, EL_PLAYER_1 },
3502 { EL_BUG_RIGHT, EL_BUG },
3503 { EL_BUG_UP, EL_BUG },
3504 { EL_BUG_LEFT, EL_BUG },
3505 { EL_BUG_DOWN, EL_BUG },
3507 { EL_SPACESHIP_RIGHT, EL_SPACESHIP },
3508 { EL_SPACESHIP_UP, EL_SPACESHIP },
3509 { EL_SPACESHIP_LEFT, EL_SPACESHIP },
3510 { EL_SPACESHIP_DOWN, EL_SPACESHIP },
3512 { EL_PACMAN_RIGHT, EL_YAMYAM },
3513 { EL_PACMAN_UP, EL_YAMYAM },
3514 { EL_PACMAN_LEFT, EL_YAMYAM },
3515 { EL_PACMAN_DOWN, EL_YAMYAM },
3523 char *element_string;
3525 forum_sketch_element_strings[] =
3527 { EL_PLAYER_1, "p" },
3531 { EL_EMERALD, "e" },
3533 { EL_SPACESHIP, "h" },
3534 { EL_BD_FIREFLY, "f" },
3535 { EL_BD_BUTTERFLY, "b" },
3539 { EL_STEELWALL, "t" },
3540 { EL_MAGIC_WALL, "m" },
3541 { EL_EXIT_OPEN, "x" },
3542 { EL_DYNAMITE, "d" },
3551 { EL_GATE_1_GRAY, "9" },
3554 { EL_ROBOT_WHEEL, "0" },
3556 { EL_CUSTOM_1, "c" },
3557 { EL_CHAR_QUESTION, "?" },
3564 -----------------------------------------------------------------------------
3566 -----------------------------------------------------------------------------
3569 static int getMaxInfoTextLength()
3571 return (SXSIZE / getFontWidth(FONT_TEXT_2));
3574 static int getTextWidthForGadget(char *text)
3579 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
3582 static int getTextWidthForDrawingArea(char *text)
3587 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
3590 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
3592 return (gi->x + gi->width + getTextWidthForGadget(text));
3595 static char *getElementInfoText(int element)
3597 char *info_text = NULL;
3599 if (element < NUM_FILE_ELEMENTS)
3601 if (strlen(element_info[element].description) > 0)
3602 info_text = element_info[element].description;
3603 else if (element_info[element].custom_description != NULL)
3604 info_text = element_info[element].custom_description;
3605 else if (element_info[element].editor_description != NULL)
3606 info_text = element_info[element].editor_description;
3609 if (info_text == NULL)
3610 info_text = INFOTEXT_UNKNOWN_ELEMENT;
3615 static void ReinitializeElementList()
3617 static boolean initialized = FALSE;
3621 checked_free(editor_elements);
3625 /* initialize optional user defined element list */
3626 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
3627 &num_editor_el_user_defined);
3629 /* initialize list of empty elements (used for padding, if needed) */
3630 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
3631 editor_el_empty[i] = EL_EMPTY;
3633 /* do some sanity checks for each element from element list */
3634 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
3636 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
3638 int element = (*editor_elements_info[i].element_list)[j];
3640 if (element >= NUM_FILE_ELEMENTS)
3641 Error(ERR_WARN, "editor element %d is runtime element", element);
3643 if (strcmp(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT) == 0)
3644 Error(ERR_WARN, "no element description for element %d", element);
3651 num_editor_elements = 0;
3652 use_el_empty = FALSE;
3654 /* determine size of element list */
3655 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
3657 if (*editor_elements_info[i].setup_value)
3659 if (setup.editor.el_headlines)
3660 num_editor_elements += *editor_elements_info[i].headline_list_size;
3662 num_editor_elements += *editor_elements_info[i].element_list_size;
3666 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
3668 /* offer at least as many elements as element buttons exist */
3669 use_el_empty = TRUE;
3670 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
3672 num_editor_elements += num_editor_el_empty;
3675 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
3677 /* fill element list */
3678 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
3680 if (*editor_elements_info[i].setup_value)
3682 if (setup.editor.el_headlines)
3683 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
3684 editor_elements[pos++] = (*editor_elements_info[i].headline_list)[j];
3686 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
3687 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
3691 /* correct position of element list scrollbar */
3692 if (element_shift < 0)
3694 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
3695 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
3698 void PrintEditorElementList()
3700 boolean *stop = &setup.editor.el_user_defined;
3703 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
3705 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
3707 int element = (*editor_elements_info[i].headline_list)[j];
3709 printf("# %s\n", element_info[element].token_name);
3715 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
3717 int element = (*editor_elements_info[i].element_list)[j];
3719 printf("# %s\n", element_info[element].token_name);
3727 static void ReinitializeElementListButtons()
3729 static boolean last_setup_value_headlines = FALSE;
3730 static boolean initialization_needed = TRUE;
3733 if (!initialization_needed) /* check if editor element setup has changed */
3735 if (last_setup_value_headlines != setup.editor.el_headlines)
3736 initialization_needed = TRUE;
3738 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
3739 if (editor_elements_info[i].last_setup_value !=
3740 *editor_elements_info[i].setup_value)
3741 initialization_needed = TRUE;
3744 if (!initialization_needed)
3747 FreeLevelEditorGadgets();
3748 CreateLevelEditorGadgets();
3750 /* store current setup values for next invocation of this function */
3751 last_setup_value_headlines = setup.editor.el_headlines;
3752 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
3753 editor_elements_info[i].last_setup_value =
3754 *editor_elements_info[i].setup_value;
3756 initialization_needed = FALSE;
3759 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
3762 int border_graphic =
3763 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
3766 int num_mini_tilex = width / MINI_TILEX + 1;
3767 int num_mini_tiley = height / MINI_TILEY + 1;
3770 getMiniGraphicSource(border_graphic, &src_bitmap, &src_x, &src_y);
3772 for (y = 0; y < num_mini_tiley; y++)
3773 for (x = 0; x < num_mini_tilex; x++)
3774 BlitBitmap(src_bitmap, drawto, src_x, src_y, MINI_TILEX, MINI_TILEY,
3775 dest_x - MINI_TILEX / 2 + x * MINI_TILEX,
3776 dest_y - MINI_TILEY / 2 + y * MINI_TILEY);
3778 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
3781 static void DrawDrawingArea(int id)
3783 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
3786 if (id == ED_DRAWING_ID_RANDOM_BACKGROUND)
3787 DrawMiniGraphicExt(drawto, gi->x, gi->y,
3788 el2edimg(random_placement_background_element));
3789 else if (id == ED_DRAWING_ID_AMOEBA_CONTENT)
3790 DrawMiniGraphicExt(drawto, gi->x, gi->y, el2edimg(level.amoeba_content));
3791 else if (id == ED_DRAWING_ID_CUSTOM_GRAPHIC)
3792 DrawMiniGraphicExt(drawto, gi->x, gi->y,
3793 el2edimg(custom_element.gfx_element));
3794 else if (id == ED_DRAWING_ID_CUSTOM_CONTENT)
3795 for (y = 0; y < 3; y++)
3796 for (x = 0; x < 3; x++)
3797 DrawMiniGraphicExt(drawto,
3798 gi->x + x * MINI_TILEX, gi->y + y * MINI_TILEY,
3799 el2edimg(custom_element.content[x][y]));
3800 else if (id == ED_DRAWING_ID_CUSTOM_MOVE_ENTER)
3801 DrawMiniGraphicExt(drawto, gi->x, gi->y,
3802 el2edimg(custom_element.move_enter_element));
3803 else if (id == ED_DRAWING_ID_CUSTOM_MOVE_LEAVE)
3804 DrawMiniGraphicExt(drawto, gi->x, gi->y,
3805 el2edimg(custom_element.move_leave_element));
3806 else if (id == ED_DRAWING_ID_CUSTOM_CHANGE_TARGET)
3807 DrawMiniGraphicExt(drawto, gi->x, gi->y,
3808 el2edimg(custom_element_change.target_element));
3809 else if (id == ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT)
3810 for (y = 0; y < 3; y++)
3811 for (x = 0; x < 3; x++)
3812 DrawMiniGraphicExt(drawto,
3813 gi->x + x * MINI_TILEX, gi->y + y * MINI_TILEY,
3814 el2edimg(custom_element_change.content[x][y]));
3815 else if (id == ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER)
3816 DrawMiniGraphicExt(drawto, gi->x, gi->y,
3817 el2edimg(custom_element_change.trigger_element));
3818 else if (id == ED_DRAWING_ID_GROUP_CONTENT)
3819 for (x = 0; x < group_element_info.num_elements; x++)
3820 DrawMiniGraphicExt(drawto, gi->x + x * MINI_TILEX, gi->y,
3821 el2edimg(group_element_info.element[x]));
3822 else if (id >= ED_DRAWING_ID_ELEMENT_CONTENT_0 &&
3823 id <= ED_DRAWING_ID_ELEMENT_CONTENT_7)
3825 int nr = id - ED_DRAWING_ID_ELEMENT_CONTENT_0;
3827 for (y = 0; y < 3; y++)
3828 for (x = 0; x < 3; x++)
3829 DrawMiniGraphicExt(drawto,
3830 gi->x + x * MINI_TILEX, gi->y + y * MINI_TILEY,
3831 el2edimg(level.yamyam_content[nr][x][y]));
3835 static void ScrollMiniLevel(int from_x, int from_y, int scroll)
3838 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
3839 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
3841 BlitBitmap(drawto, drawto,
3842 SX + (dx == -1 ? MINI_TILEX : 0),
3843 SY + (dy == -1 ? MINI_TILEY : 0),
3844 (ed_fieldx * MINI_TILEX) - (dx != 0 ? MINI_TILEX : 0),
3845 (ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0),
3846 SX + (dx == +1 ? MINI_TILEX : 0),
3847 SY + (dy == +1 ? MINI_TILEY : 0));
3850 x = (dx == 1 ? 0 : ed_fieldx - 1);
3851 for (y = 0; y < ed_fieldy; y++)
3852 DrawMiniElementOrWall(x, y, from_x, from_y);
3856 y = (dy == 1 ? 0 : ed_fieldy - 1);
3857 for (x = 0; x < ed_fieldx; x++)
3858 DrawMiniElementOrWall(x, y, from_x, from_y);
3861 redraw_mask |= REDRAW_FIELD;
3865 static void CreateControlButtons()
3867 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
3868 struct GadgetInfo *gi;
3869 unsigned long event_mask;
3872 /* create toolbox buttons */
3873 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
3877 int gd_xoffset, gd_yoffset;
3878 int gd_x1, gd_x2, gd_y1, gd_y2;
3880 int radio_button_nr;
3883 if (id == GADGET_ID_SINGLE_ITEMS ||
3884 id == GADGET_ID_CONNECTED_ITEMS ||
3885 id == GADGET_ID_LINE ||
3886 id == GADGET_ID_ARC ||
3887 id == GADGET_ID_TEXT ||
3888 id == GADGET_ID_RECTANGLE ||
3889 id == GADGET_ID_FILLED_BOX ||
3890 id == GADGET_ID_FLOOD_FILL ||
3891 id == GADGET_ID_GRAB_BRUSH ||
3892 id == GADGET_ID_PICK_ELEMENT ||
3893 id == GADGET_ID_CUSTOM_COPY_FROM ||
3894 id == GADGET_ID_CUSTOM_COPY_TO ||
3895 id == GADGET_ID_CUSTOM_EXCHANGE)
3897 button_type = GD_TYPE_RADIO_BUTTON;
3898 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
3899 checked = (id == drawing_function ? TRUE : FALSE);
3900 event_mask = GD_EVENT_PRESSED;
3904 button_type = GD_TYPE_NORMAL_BUTTON;
3905 radio_button_nr = RADIO_NR_NONE;
3908 if (id == GADGET_ID_WRAP_LEFT ||
3909 id == GADGET_ID_WRAP_RIGHT ||
3910 id == GADGET_ID_WRAP_UP ||
3911 id == GADGET_ID_WRAP_DOWN)
3912 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
3914 event_mask = GD_EVENT_RELEASED;
3917 if (id < ED_NUM_CTRL1_BUTTONS)
3919 int x = i % ED_CTRL1_BUTTONS_HORIZ;
3920 int y = i / ED_CTRL1_BUTTONS_HORIZ;
3922 gd_xoffset = ED_CTRL1_BUTTONS_XPOS + x * ED_CTRL1_BUTTON_XSIZE;
3923 gd_yoffset = ED_CTRL1_BUTTONS_YPOS + y * ED_CTRL1_BUTTON_YSIZE;
3924 width = ED_CTRL1_BUTTON_XSIZE;
3925 height = ED_CTRL1_BUTTON_YSIZE;
3927 gd_x1 = DOOR_GFX_PAGEX8 + gd_xoffset;
3928 gd_x2 = DOOR_GFX_PAGEX7 + gd_xoffset;
3929 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL1_BUTTONS_GFX_YPOS + gd_yoffset;
3930 gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL1_BUTTONS_ALT_GFX_YPOS + gd_yoffset;
3932 else if (id < ED_NUM_CTRL1_2_BUTTONS)
3934 int x = (i - ED_NUM_CTRL1_BUTTONS) % ED_CTRL2_BUTTONS_HORIZ;
3935 int y = (i - ED_NUM_CTRL1_BUTTONS) / ED_CTRL2_BUTTONS_HORIZ;
3937 gd_xoffset = ED_CTRL2_BUTTONS_XPOS + x * ED_CTRL2_BUTTON_XSIZE;
3938 gd_yoffset = ED_CTRL2_BUTTONS_YPOS + y * ED_CTRL2_BUTTON_YSIZE;
3939 width = ED_CTRL2_BUTTON_XSIZE;
3940 height = ED_CTRL2_BUTTON_YSIZE;
3942 gd_x1 = DOOR_GFX_PAGEX8 + gd_xoffset;
3943 gd_x2 = DOOR_GFX_PAGEX7 + gd_xoffset;
3944 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL2_BUTTONS_GFX_YPOS + gd_yoffset;
3945 gd_y2 = 0; /* no alternative graphic for these buttons */
3949 int x = (i - ED_NUM_CTRL1_2_BUTTONS) % ED_CTRL3_BUTTONS_HORIZ + 1;
3950 int y = (i - ED_NUM_CTRL1_2_BUTTONS) / ED_CTRL3_BUTTONS_HORIZ;
3952 gd_xoffset = ED_CTRL3_BUTTONS_XPOS + x * ED_CTRL3_BUTTON_XSIZE;
3953 gd_yoffset = ED_CTRL3_BUTTONS_YPOS + y * ED_CTRL3_BUTTON_YSIZE;
3954 width = ED_CTRL3_BUTTON_XSIZE;
3955 height = ED_CTRL3_BUTTON_YSIZE;
3957 gd_x1 = DOOR_GFX_PAGEX6 + gd_xoffset;
3958 gd_x2 = DOOR_GFX_PAGEX5 + gd_xoffset;
3959 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL3_BUTTONS_GFX_YPOS + gd_yoffset;
3960 gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL3_BUTTONS_ALT_GFX_YPOS + gd_yoffset;
3963 gi = CreateGadget(GDI_CUSTOM_ID, id,
3964 GDI_CUSTOM_TYPE_ID, i,
3965 GDI_INFO_TEXT, control_info[i].text,
3966 GDI_X, EX + gd_xoffset,
3967 GDI_Y, EY + gd_yoffset,
3970 GDI_TYPE, button_type,
3971 GDI_STATE, GD_BUTTON_UNPRESSED,
3972 GDI_RADIO_NR, radio_button_nr,
3973 GDI_CHECKED, checked,
3974 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
3975 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y1,
3976 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2,
3977 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
3978 GDI_EVENT_MASK, event_mask,
3979 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
3980 GDI_CALLBACK_ACTION, HandleControlButtons,
3984 Error(ERR_EXIT, "cannot create gadget");
3986 level_editor_gadget[id] = gi;
3989 /* create buttons for scrolling of drawing area and element list */
3990 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
3992 int id = scrollbutton_info[i].gadget_id;
3993 int x, y, width, height;
3994 int gd_x1, gd_x2, gd_y1, gd_y2;
3996 x = scrollbutton_info[i].x;
3997 y = scrollbutton_info[i].y;
3999 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
4001 if (id == GADGET_ID_SCROLL_LIST_UP ||
4002 id == GADGET_ID_SCROLL_LIST_DOWN)
4006 width = ED_SCROLLBUTTON2_XSIZE;
4007 height = ED_SCROLLBUTTON2_YSIZE;
4008 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].gd_x;
4009 gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].gd_y;
4010 gd_x2 = gd_x1 - ED_SCROLLBUTTON2_XSIZE;
4017 width = ED_SCROLLBUTTON_XSIZE;
4018 height = ED_SCROLLBUTTON_YSIZE;
4019 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].gd_x;
4020 gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].gd_y;
4021 gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE;
4025 gi = CreateGadget(GDI_CUSTOM_ID, id,
4026 GDI_CUSTOM_TYPE_ID, i,
4027 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
4032 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
4033 GDI_STATE, GD_BUTTON_UNPRESSED,
4034 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
4035 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
4036 GDI_EVENT_MASK, event_mask,
4037 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4038 GDI_CALLBACK_ACTION, HandleControlButtons,
4042 Error(ERR_EXIT, "cannot create gadget");
4044 level_editor_gadget[id] = gi;
4047 /* create buttons for element list */
4048 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
4050 Bitmap *deco_bitmap;
4051 int deco_x, deco_y, deco_xpos, deco_ypos;
4052 int gd_xoffset, gd_yoffset;
4053 int gd_x1, gd_x2, gd_y;
4054 int x = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
4055 int y = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
4056 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
4057 int element = editor_elements[i];
4059 event_mask = GD_EVENT_RELEASED;
4061 gd_xoffset = ED_ELEMENTLIST_XPOS + x * ED_ELEMENTLIST_XSIZE;
4062 gd_yoffset = ED_ELEMENTLIST_YPOS + y * ED_ELEMENTLIST_YSIZE;
4064 gd_x1 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS + ED_ELEMENTLIST_XSIZE;
4065 gd_x2 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS;
4066 gd_y = DOOR_GFX_PAGEY1 + ED_ELEMENTLIST_YPOS;
4068 getMiniGraphicSource(el2edimg(element), &deco_bitmap, &deco_x, &deco_y);
4069 deco_xpos = (ED_ELEMENTLIST_XSIZE - MINI_TILEX) / 2;
4070 deco_ypos = (ED_ELEMENTLIST_YSIZE - MINI_TILEY) / 2;
4072 gi = CreateGadget(GDI_CUSTOM_ID, id,
4073 GDI_CUSTOM_TYPE_ID, i,
4074 GDI_INFO_TEXT, getElementInfoText(element),
4075 GDI_X, DX + gd_xoffset,
4076 GDI_Y, DY + gd_yoffset,
4077 GDI_WIDTH, ED_ELEMENTLIST_XSIZE,
4078 GDI_HEIGHT, ED_ELEMENTLIST_YSIZE,
4079 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
4080 GDI_STATE, GD_BUTTON_UNPRESSED,
4081 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
4082 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
4083 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
4084 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
4085 GDI_DECORATION_SIZE, MINI_TILEX, MINI_TILEY,
4086 GDI_DECORATION_SHIFTING, 1, 1,
4087 GDI_EVENT_MASK, event_mask,
4088 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4089 GDI_CALLBACK_ACTION, HandleControlButtons,
4093 Error(ERR_EXIT, "cannot create gadget");
4095 level_editor_gadget[id] = gi;
4099 static void CreateCounterButtons()
4101 int max_infotext_len = getMaxInfoTextLength();
4104 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
4107 int x = SX + counterbutton_info[i].x; /* down count button */
4108 int y = SY + counterbutton_info[i].y;
4110 /* determine horizontal position to the right of specified gadget */
4111 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
4112 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
4113 ED_GADGET_TEXT_DISTANCE);
4115 /* determine horizontal offset for leading text */
4116 if (counterbutton_info[i].text_left != NULL)
4117 x += getTextWidthForGadget(counterbutton_info[i].text_left);
4119 for (j = 0; j < 2; j++)
4121 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4122 struct GadgetInfo *gi;
4124 counterbutton_info[i].gadget_id_down :
4125 counterbutton_info[i].gadget_id_up);
4127 int gd_x, gd_x1, gd_x2, gd_y;
4129 unsigned long event_mask;
4130 char infotext[max_infotext_len + 1];
4132 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
4134 if (i == ED_COUNTER_ID_SELECT_LEVEL)
4137 ED_SCROLLBUTTON_ID_AREA_LEFT :
4138 ED_SCROLLBUTTON_ID_AREA_RIGHT);
4140 event_mask |= GD_EVENT_RELEASED;
4143 x += 2 * ED_GADGET_DISTANCE;
4144 y += ED_GADGET_DISTANCE;
4146 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[sid].gd_x;
4147 gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE;
4148 gd_y = DOOR_GFX_PAGEY1 + scrollbutton_info[sid].gd_y;
4149 x_size = ED_SCROLLBUTTON_XSIZE;
4150 y_size = ED_SCROLLBUTTON_YSIZE;
4154 gd_xoffset = (j == 0 ? ED_BUTTON_MINUS_XPOS : ED_BUTTON_PLUS_XPOS);
4155 gd_x1 = DOOR_GFX_PAGEX4 + gd_xoffset;
4156 gd_x2 = DOOR_GFX_PAGEX3 + gd_xoffset;
4157 gd_y = DOOR_GFX_PAGEY1 + ED_BUTTON_COUNT_YPOS;
4158 x_size = ED_BUTTON_COUNT_XSIZE;
4159 y_size = ED_BUTTON_COUNT_YSIZE;
4162 sprintf(infotext, "%s counter value by 1, 5 or 10",
4163 (j == 0 ? "decrease" : "increase"));
4165 gi = CreateGadget(GDI_CUSTOM_ID, id,
4166 GDI_CUSTOM_TYPE_ID, i,
4167 GDI_INFO_TEXT, infotext,
4172 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
4173 GDI_STATE, GD_BUTTON_UNPRESSED,
4174 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
4175 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
4176 GDI_EVENT_MASK, event_mask,
4177 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4178 GDI_CALLBACK_ACTION, HandleCounterButtons,
4182 Error(ERR_EXIT, "cannot create gadget");
4184 level_editor_gadget[id] = gi;
4185 right_gadget_border[id] =
4186 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
4188 x += gi->width + ED_GADGET_DISTANCE; /* text count button */
4192 int font_type = FONT_INPUT_1;
4193 int font_type_active = FONT_INPUT_1_ACTIVE;
4194 int gd_width = ED_WIN_COUNT_XSIZE;
4196 id = counterbutton_info[i].gadget_id_text;
4197 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
4199 if (i == ED_COUNTER_ID_SELECT_LEVEL)
4201 font_type = FONT_LEVEL_NUMBER;
4202 font_type_active = FONT_LEVEL_NUMBER;
4204 x += 2 * ED_GADGET_DISTANCE;
4205 y -= ED_GADGET_DISTANCE;
4207 gd_x = DOOR_GFX_PAGEX6 + ED_WIN_COUNT2_XPOS;
4208 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT2_YPOS;
4209 gd_width = ED_WIN_COUNT2_XSIZE;
4213 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
4214 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
4217 gi = CreateGadget(GDI_CUSTOM_ID, id,
4218 GDI_CUSTOM_TYPE_ID, i,
4219 GDI_INFO_TEXT, "enter counter value",
4222 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
4223 GDI_NUMBER_VALUE, 0,
4224 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
4225 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
4227 GDI_TEXT_FONT, font_type,
4228 GDI_TEXT_FONT_ACTIVE, font_type_active,
4229 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
4230 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
4231 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
4232 GDI_DESIGN_WIDTH, gd_width,
4233 GDI_EVENT_MASK, event_mask,
4234 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4235 GDI_CALLBACK_ACTION, HandleCounterButtons,
4239 Error(ERR_EXIT, "cannot create gadget");
4241 level_editor_gadget[id] = gi;
4242 right_gadget_border[id] =
4243 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
4245 x += gi->width + ED_GADGET_DISTANCE; /* up count button */
4251 static void CreateDrawingAreas()
4255 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
4257 struct GadgetInfo *gi;
4258 unsigned long event_mask;
4259 int id = drawingarea_info[i].gadget_id;
4260 int x = SX + drawingarea_info[i].x;
4261 int y = SY + drawingarea_info[i].y;
4262 int area_xsize = drawingarea_info[i].area_xsize;
4263 int area_ysize = drawingarea_info[i].area_ysize;
4266 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
4267 GD_EVENT_OFF_BORDERS;
4269 /* determine horizontal position to the right of specified gadget */
4270 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
4271 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
4272 ED_DRAWINGAREA_TEXT_DISTANCE);
4274 /* determine horizontal offset for leading text */
4275 if (drawingarea_info[i].text_left != NULL)
4276 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
4278 gi = CreateGadget(GDI_CUSTOM_ID, id,
4279 GDI_CUSTOM_TYPE_ID, i,
4282 GDI_TYPE, GD_TYPE_DRAWING_AREA,
4283 GDI_AREA_SIZE, area_xsize, area_ysize,
4284 GDI_ITEM_SIZE, MINI_TILEX, MINI_TILEY,
4285 GDI_EVENT_MASK, event_mask,
4286 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
4287 GDI_CALLBACK_ACTION, HandleDrawingAreas,
4291 Error(ERR_EXIT, "cannot create gadget");
4293 level_editor_gadget[id] = gi;
4294 right_gadget_border[id] =
4295 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
4299 static void CreateTextInputGadgets()
4301 int max_infotext_len = getMaxInfoTextLength();
4304 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
4306 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4308 struct GadgetInfo *gi;
4309 unsigned long event_mask;
4310 char infotext[MAX_OUTPUT_LINESIZE + 1];
4311 int id = textinput_info[i].gadget_id;
4313 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
4315 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
4316 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
4318 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
4319 infotext[max_infotext_len] = '\0';
4321 gi = CreateGadget(GDI_CUSTOM_ID, id,
4322 GDI_CUSTOM_TYPE_ID, i,
4323 GDI_INFO_TEXT, infotext,
4324 GDI_X, SX + textinput_info[i].x,
4325 GDI_Y, SY + textinput_info[i].y,
4326 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
4327 GDI_TEXT_VALUE, textinput_info[i].value,
4328 GDI_TEXT_SIZE, textinput_info[i].size,
4329 GDI_TEXT_FONT, FONT_INPUT_1,
4330 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
4331 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
4332 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
4333 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
4334 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
4335 GDI_EVENT_MASK, event_mask,
4336 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4337 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
4341 Error(ERR_EXIT, "cannot create gadget");
4343 level_editor_gadget[id] = gi;
4347 static void CreateTextAreaGadgets()
4349 int max_infotext_len = getMaxInfoTextLength();
4352 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
4354 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4356 struct GadgetInfo *gi;
4357 unsigned long event_mask;
4358 char infotext[MAX_OUTPUT_LINESIZE + 1];
4359 int id = textarea_info[i].gadget_id;
4360 int area_xsize = textarea_info[i].xsize;
4361 int area_ysize = textarea_info[i].ysize;
4363 event_mask = GD_EVENT_TEXT_LEAVING;
4365 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
4366 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
4368 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
4369 infotext[max_infotext_len] = '\0';
4371 gi = CreateGadget(GDI_CUSTOM_ID, id,
4372 GDI_CUSTOM_TYPE_ID, i,
4373 GDI_INFO_TEXT, infotext,
4374 GDI_X, SX + textarea_info[i].x,
4375 GDI_Y, SY + textarea_info[i].y,
4376 GDI_TYPE, GD_TYPE_TEXT_AREA,
4377 GDI_AREA_SIZE, area_xsize, area_ysize,
4378 GDI_TEXT_FONT, FONT_INPUT_1,
4379 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
4380 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
4381 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
4382 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
4383 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
4384 GDI_EVENT_MASK, event_mask,
4385 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4386 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
4390 Error(ERR_EXIT, "cannot create gadget");
4392 level_editor_gadget[id] = gi;
4396 static void CreateSelectboxGadgets()
4398 int max_infotext_len = getMaxInfoTextLength();
4401 for (i = 0; i < ED_NUM_SELECTBOX; i++)
4403 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4405 struct GadgetInfo *gi;
4406 unsigned long event_mask;
4407 char infotext[MAX_OUTPUT_LINESIZE + 1];
4408 int id = selectbox_info[i].gadget_id;
4409 int x = SX + selectbox_info[i].x;
4410 int y = SY + selectbox_info[i].y;
4412 if (selectbox_info[i].size == -1) /* dynamically determine size */
4414 /* (we cannot use -1 for uninitialized values if we directly compare
4415 with results from strlen(), because the '<' and '>' operation will
4416 implicitely cast -1 to an unsigned integer value!) */
4417 selectbox_info[i].size = 0;
4419 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
4420 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
4421 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
4423 selectbox_info[i].size++; /* add one character empty space */
4426 event_mask = GD_EVENT_RELEASED |
4427 GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
4429 gd_x = DOOR_GFX_PAGEX4 + ED_SELECTBOX_XPOS;
4430 gd_y = DOOR_GFX_PAGEY1 + ED_SELECTBOX_YPOS;
4432 /* determine horizontal position to the right of specified gadget */
4433 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
4434 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
4435 ED_GADGET_TEXT_DISTANCE);
4437 /* determine horizontal offset for leading text */
4438 if (selectbox_info[i].text_left != NULL)
4439 x += getTextWidthForGadget(selectbox_info[i].text_left);
4441 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
4442 infotext[max_infotext_len] = '\0';
4444 gi = CreateGadget(GDI_CUSTOM_ID, id,
4445 GDI_CUSTOM_TYPE_ID, i,
4446 GDI_INFO_TEXT, infotext,
4449 GDI_TYPE, GD_TYPE_SELECTBOX,
4450 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
4451 GDI_TEXT_SIZE, selectbox_info[i].size,
4452 GDI_TEXT_FONT, FONT_INPUT_1,
4453 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
4454 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
4455 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
4456 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
4457 GDI_BORDER_SIZE_SELECTBUTTON, ED_SELECTBOX_BUTTON_XSIZE,
4458 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
4459 GDI_EVENT_MASK, event_mask,
4460 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4461 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
4465 Error(ERR_EXIT, "cannot create gadget");
4467 level_editor_gadget[id] = gi;
4468 right_gadget_border[id] =
4469 getRightGadgetBorder(gi, selectbox_info[i].text_right);
4473 static void CreateTextbuttonGadgets()
4475 int max_infotext_len = getMaxInfoTextLength();
4478 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
4480 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4481 int gd_x1, gd_x2, gd_y1, gd_y2;
4482 struct GadgetInfo *gi;
4483 unsigned long event_mask;
4484 char infotext[MAX_OUTPUT_LINESIZE + 1];
4485 int id = textbutton_info[i].gadget_id;
4486 int x = SX + textbutton_info[i].x;
4487 int y = SY + textbutton_info[i].y;
4489 if (textbutton_info[i].size == -1) /* dynamically determine size */
4490 textbutton_info[i].size = strlen(textbutton_info[i].text);
4492 event_mask = GD_EVENT_RELEASED;
4494 if (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE)
4496 gd_x1 = DOOR_GFX_PAGEX4 + ED_TEXTBUTTON_TAB_XPOS;
4497 gd_x2 = DOOR_GFX_PAGEX3 + ED_TEXTBUTTON_TAB_XPOS;
4498 gd_y1 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_TAB_YPOS;
4499 gd_y2 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_TAB_INACTIVE_YPOS;
4503 gd_x1 = DOOR_GFX_PAGEX4 + ED_TEXTBUTTON_XPOS;
4504 gd_x2 = DOOR_GFX_PAGEX3 + ED_TEXTBUTTON_XPOS;
4505 gd_y1 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_YPOS;
4506 gd_y2 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_INACTIVE_YPOS;
4509 sprintf(infotext, "%s", textbutton_info[i].infotext);
4510 infotext[max_infotext_len] = '\0';
4512 /* determine horizontal position to the right of specified gadget */
4513 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
4514 x = (right_gadget_border[textbutton_info[i].gadget_id_align] +
4515 ED_GADGET_TEXT_DISTANCE);
4517 /* determine horizontal offset for leading text */
4518 if (textbutton_info[i].text_left != NULL)
4519 x += getTextWidthForGadget(textbutton_info[i].text_left);
4521 gi = CreateGadget(GDI_CUSTOM_ID, id,
4522 GDI_CUSTOM_TYPE_ID, i,
4523 GDI_INFO_TEXT, infotext,
4526 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
4527 GDI_TEXT_VALUE, textbutton_info[i].text,
4528 GDI_TEXT_SIZE, textbutton_info[i].size,
4529 GDI_TEXT_FONT, FONT_INPUT_2_ACTIVE,
4530 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2,
4531 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
4532 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y1,
4533 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2,
4534 GDI_BORDER_SIZE, ED_BORDER_TEXT_XSIZE, ED_BORDER_SIZE,
4535 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
4536 GDI_DECORATION_SHIFTING, 1, 1,
4537 GDI_EVENT_MASK, event_mask,
4538 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4539 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
4543 Error(ERR_EXIT, "cannot create gadget");
4545 level_editor_gadget[id] = gi;
4546 right_gadget_border[id] =
4547 getRightGadgetBorder(gi, textbutton_info[i].text_right);
4551 static void CreateGraphicbuttonGadgets()
4553 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4554 struct GadgetInfo *gi;
4555 unsigned long event_mask;
4558 /* create buttons for scrolling of drawing area and element list */
4559 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
4561 int id = graphicbutton_info[i].gadget_id;
4562 int gd_x1, gd_x2, gd_y1, gd_y2;
4563 int x = SX + graphicbutton_info[i].x;
4564 int y = SY + graphicbutton_info[i].y;
4566 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
4568 gd_x1 = DOOR_GFX_PAGEX4 + graphicbutton_info[i].gd_x;
4569 gd_x2 = DOOR_GFX_PAGEX3 + graphicbutton_info[i].gd_x;
4570 gd_y1 = DOOR_GFX_PAGEY1 + graphicbutton_info[i].gd_y;
4573 /* determine horizontal position to the right of specified gadget */
4574 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
4575 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
4576 ED_GADGET_TEXT_DISTANCE);
4578 /* determine horizontal offset for leading text */
4579 if (graphicbutton_info[i].text_left != NULL)
4580 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
4582 gi = CreateGadget(GDI_CUSTOM_ID, id,
4583 GDI_CUSTOM_TYPE_ID, i,
4584 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
4587 GDI_WIDTH, graphicbutton_info[i].width,
4588 GDI_HEIGHT, graphicbutton_info[i].height,
4589 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
4590 GDI_STATE, GD_BUTTON_UNPRESSED,
4591 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
4592 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
4593 GDI_EVENT_MASK, event_mask,
4594 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4595 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
4599 Error(ERR_EXIT, "cannot create gadget");
4601 level_editor_gadget[id] = gi;
4602 right_gadget_border[id] =
4603 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
4607 static void CreateScrollbarGadgets()
4611 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
4613 int id = scrollbar_info[i].gadget_id;
4614 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4615 int gd_x1, gd_x2, gd_y1, gd_y2;
4616 struct GadgetInfo *gi;
4617 int items_max, items_visible, item_position;
4618 unsigned long event_mask;
4620 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
4622 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
4623 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
4624 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
4626 else /* drawing area scrollbars */
4628 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
4630 items_max = MAX(lev_fieldx + 2, ed_fieldx);
4631 items_visible = ed_fieldx;
4636 items_max = MAX(lev_fieldy + 2, ed_fieldy);
4637 items_visible = ed_fieldy;
4642 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
4644 gd_x1 = DOOR_GFX_PAGEX8 + scrollbar_info[i].gd_x;
4645 gd_x2 = (gd_x1 - (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL ?
4646 scrollbar_info[i].height : scrollbar_info[i].width));
4647 gd_y1 = DOOR_GFX_PAGEY1 + scrollbar_info[i].gd_y;
4648 gd_y2 = DOOR_GFX_PAGEY1 + scrollbar_info[i].gd_y;
4650 gi = CreateGadget(GDI_CUSTOM_ID, id,
4651 GDI_CUSTOM_TYPE_ID, i,
4652 GDI_INFO_TEXT, scrollbar_info[i].infotext,
4653 GDI_X, scrollbar_info[i].x,
4654 GDI_Y, scrollbar_info[i].y,
4655 GDI_WIDTH, scrollbar_info[i].width,
4656 GDI_HEIGHT, scrollbar_info[i].height,
4657 GDI_TYPE, scrollbar_info[i].type,
4658 GDI_SCROLLBAR_ITEMS_MAX, items_max,
4659 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
4660 GDI_SCROLLBAR_ITEM_POSITION, item_position,
4661 GDI_STATE, GD_BUTTON_UNPRESSED,
4662 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
4663 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
4664 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
4665 GDI_EVENT_MASK, event_mask,
4666 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4667 GDI_CALLBACK_ACTION, HandleControlButtons,
4671 Error(ERR_EXIT, "cannot create gadget");
4673 level_editor_gadget[id] = gi;
4677 static void CreateCheckbuttonGadgets()
4679 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4680 struct GadgetInfo *gi;
4681 unsigned long event_mask;
4682 int gd_x1, gd_x2, gd_x3, gd_x4, gd_y;
4685 event_mask = GD_EVENT_PRESSED;
4687 gd_x1 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_UNCHECKED_XPOS;
4688 gd_x2 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_UNCHECKED_XPOS;
4689 gd_x3 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_CHECKED_XPOS;
4690 gd_x4 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_CHECKED_XPOS;
4691 gd_y = DOOR_GFX_PAGEY1 + ED_RADIOBUTTON_YPOS;
4693 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
4695 int id = checkbutton_info[i].gadget_id;
4696 int x = SX + checkbutton_info[i].x;
4697 int y = SY + checkbutton_info[i].y;
4699 if (id == GADGET_ID_STICK_ELEMENT)
4700 gd_y = DOOR_GFX_PAGEY1 + ED_STICKYBUTTON_YPOS;
4702 gd_y = DOOR_GFX_PAGEY1 + ED_CHECKBUTTON_YPOS;
4704 /* determine horizontal position to the right of specified gadget */
4705 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
4706 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
4707 ED_GADGET_TEXT_DISTANCE);
4709 /* determine horizontal offset for leading text */
4710 if (checkbutton_info[i].text_left != NULL)
4711 x += getTextWidthForGadget(checkbutton_info[i].text_left);
4713 gi = CreateGadget(GDI_CUSTOM_ID, id,
4714 GDI_CUSTOM_TYPE_ID, i,
4715 GDI_INFO_TEXT, checkbutton_info[i].infotext,
4718 GDI_WIDTH, ED_CHECKBUTTON_XSIZE,
4719 GDI_HEIGHT, ED_CHECKBUTTON_YSIZE,
4720 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
4721 GDI_CHECKED, *checkbutton_info[i].value,
4722 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
4723 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
4724 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y,
4725 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y,
4726 GDI_EVENT_MASK, event_mask,
4727 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4728 GDI_CALLBACK_ACTION, HandleCheckbuttons,
4732 Error(ERR_EXIT, "cannot create gadget");
4734 level_editor_gadget[id] = gi;
4735 right_gadget_border[id] =
4736 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
4740 static void CreateRadiobuttonGadgets()
4742 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4743 struct GadgetInfo *gi;
4744 unsigned long event_mask;
4745 int gd_x1, gd_x2, gd_x3, gd_x4, gd_y;
4748 event_mask = GD_EVENT_PRESSED;
4750 gd_x1 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_UNCHECKED_XPOS;
4751 gd_x2 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_UNCHECKED_XPOS;
4752 gd_x3 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_CHECKED_XPOS;
4753 gd_x4 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_CHECKED_XPOS;
4754 gd_y = DOOR_GFX_PAGEY1 + ED_RADIOBUTTON_YPOS;
4756 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
4758 int id = radiobutton_info[i].gadget_id;
4759 int x = SX + radiobutton_info[i].x;
4760 int y = SY + radiobutton_info[i].y;
4763 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
4765 /* determine horizontal position to the right of specified gadget */
4766 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
4767 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
4768 ED_GADGET_TEXT_DISTANCE);
4770 /* determine horizontal offset for leading text */
4771 if (radiobutton_info[i].text_left != NULL)
4772 x += getTextWidthForGadget(radiobutton_info[i].text_left);
4774 gi = CreateGadget(GDI_CUSTOM_ID, id,
4775 GDI_CUSTOM_TYPE_ID, i,
4776 GDI_INFO_TEXT, radiobutton_info[i].infotext,
4779 GDI_WIDTH, ED_CHECKBUTTON_XSIZE,
4780 GDI_HEIGHT, ED_CHECKBUTTON_YSIZE,
4781 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
4782 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
4783 GDI_CHECKED, checked,
4784 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
4785 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
4786 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y,
4787 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y,
4788 GDI_EVENT_MASK, event_mask,
4789 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4790 GDI_CALLBACK_ACTION, HandleRadiobuttons,
4794 Error(ERR_EXIT, "cannot create gadget");
4796 level_editor_gadget[id] = gi;
4797 right_gadget_border[id] =
4798 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
4802 void CreateLevelEditorGadgets()
4804 int old_game_status = game_status;
4806 /* setting 'game_status' is needed to get the right fonts for the editor */
4807 game_status = GAME_MODE_EDITOR;
4809 ReinitializeElementList();
4811 CreateControlButtons();
4812 CreateScrollbarGadgets();
4814 /* order of function calls is important because of cross-references */
4815 CreateCheckbuttonGadgets();
4816 CreateCounterButtons();
4817 CreateRadiobuttonGadgets();
4818 CreateTextInputGadgets();
4819 CreateTextAreaGadgets();
4820 CreateSelectboxGadgets();
4821 CreateGraphicbuttonGadgets();
4822 CreateTextbuttonGadgets();
4823 CreateDrawingAreas();
4825 game_status = old_game_status;
4828 void FreeLevelEditorGadgets()
4832 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
4833 FreeGadget(level_editor_gadget[i]);
4836 static void MapCounterButtons(int id)
4838 int gadget_id_down = counterbutton_info[id].gadget_id_down;
4839 int gadget_id_text = counterbutton_info[id].gadget_id_text;
4840 int gadget_id_up = counterbutton_info[id].gadget_id_up;
4841 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
4842 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
4843 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
4845 char infotext[MAX_OUTPUT_LINESIZE + 1];
4846 int max_infotext_len = getMaxInfoTextLength();
4847 int xoffset_left = 0;
4848 int yoffset_left = ED_BORDER_SIZE;
4849 int xoffset_right = getCounterGadgetWidth();
4850 int yoffset_right = ED_BORDER_SIZE;
4852 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
4853 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
4854 int yoffset_above = MINI_TILEX + ED_GADGET_DISTANCE;
4855 int yoffset = ED_BORDER_SIZE;
4856 int x_left = gi_down->x - xoffset_left;
4857 int x_right = gi_up->x + gi_up->width + xoffset_right;
4858 int y_above = gi_down->y - yoffset_above;
4860 int y = gi_up->y + yoffset;
4864 /* special case needed for "score" counter gadget */
4865 if (id == ED_COUNTER_ID_ELEMENT_SCORE)
4867 ModifyGadget(gi_down, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
4868 ModifyGadget(gi_text, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
4869 ModifyGadget(gi_up, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
4870 y = gi_up->y + yoffset;
4874 if (counterbutton_info[id].text_above)
4875 DrawText(x, y_above, counterbutton_info[id].text_above, FONT_TEXT_1);
4877 if (counterbutton_info[id].text_left)
4878 DrawText(x_left, y, counterbutton_info[id].text_left, FONT_TEXT_1);
4880 if (counterbutton_info[id].text_right)
4881 DrawText(x_right, y, counterbutton_info[id].text_right, FONT_TEXT_1);
4883 ModifyEditorCounter(id, *counterbutton_info[id].value);
4890 static void MapControlButtons()
4895 /* map toolbox buttons (excluding special CE toolbox buttons) */
4896 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
4897 MapGadget(level_editor_gadget[i]);
4899 /* map buttons to select elements */
4900 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
4901 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
4902 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
4903 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
4904 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
4906 /* map buttons to select level */
4907 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
4908 ModifyEditorCounterLimits(counter_id,
4909 leveldir_current->first_level,
4910 leveldir_current->last_level);
4911 MapCounterButtons(counter_id);
4914 static void MapDrawingArea(int id)
4916 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
4917 int area_xsize = gi->drawing.area_xsize;
4918 int area_ysize = gi->drawing.area_ysize;
4919 int xoffset_left= getTextWidthForDrawingArea(drawingarea_info[id].text_left);
4920 int xoffset_below= getTextWidth(drawingarea_info[id].text_below,FONT_TEXT_1);
4921 int x_left = gi->x - xoffset_left;
4922 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
4923 int x_below = gi->x + (gi->width - xoffset_below) / 2;
4924 int y_side = gi->y + (gi->height - getFontHeight(FONT_TEXT_1)) / 2;
4925 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
4927 if (drawingarea_info[id].text_left)
4928 DrawText(x_left, y_side, drawingarea_info[id].text_left, FONT_TEXT_1);
4930 if (drawingarea_info[id].text_right)
4931 DrawText(x_right, y_side, drawingarea_info[id].text_right, FONT_TEXT_1);
4933 if (drawingarea_info[id].text_below)
4934 DrawText(x_below, y_below, drawingarea_info[id].text_below, FONT_TEXT_1);
4936 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
4938 DrawElementBorder(gi->x, gi->y,
4939 area_xsize * MINI_TILEX, area_ysize * MINI_TILEY, TRUE);
4941 DrawDrawingArea(id);
4947 static void MapTextInputGadget(int id)
4949 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
4950 int xoffset_above = 0;
4951 int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
4952 int x_above = textinput_info[id].x + xoffset_above;
4953 int y_above = textinput_info[id].y + yoffset_above;
4955 if (textinput_info[id].text_above)
4956 DrawTextS(x_above, y_above, FONT_TEXT_1, textinput_info[id].text_above);
4958 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
4963 static void MapTextAreaGadget(int id)
4965 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
4966 int xoffset_above = 0;
4967 int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
4968 int x_above = textarea_info[id].x + xoffset_above;
4969 int y_above = textarea_info[id].y + yoffset_above;
4971 if (textarea_info[id].text_above)
4972 DrawTextS(x_above, y_above, FONT_TEXT_1, textarea_info[id].text_above);
4974 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
4979 static void MapSelectboxGadget(int id)
4981 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
4982 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
4983 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
4984 int yoffset = ED_BORDER_SIZE;
4985 int x_left = gi->x - xoffset_left;
4986 int x_right = gi->x + gi->width + xoffset_right;
4987 int y = gi->y + yoffset;
4989 if (selectbox_info[id].text_left)
4990 DrawText(x_left, y, selectbox_info[id].text_left, FONT_TEXT_1);
4992 if (selectbox_info[id].text_right)
4993 DrawText(x_right, y, selectbox_info[id].text_right, FONT_TEXT_1);
4995 ModifyEditorSelectbox(id, *selectbox_info[id].value);
5000 static void MapTextbuttonGadget(int id)
5002 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
5003 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
5004 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
5005 int yoffset = ED_BORDER_SIZE;
5006 int x_left = gi->x - xoffset_left;
5007 int x_right = gi->x + gi->width + xoffset_right;
5008 int y = gi->y + yoffset;
5010 /* only show button to delete change pages when more than minimum pages */
5011 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
5012 custom_element.num_change_pages == MIN_CHANGE_PAGES)
5015 if (textbutton_info[id].text_left)
5016 DrawText(x_left, y, textbutton_info[id].text_left, FONT_TEXT_1);
5018 if (textbutton_info[id].text_right)
5019 DrawText(x_right, y, textbutton_info[id].text_right, FONT_TEXT_1);
5024 static void MapGraphicbuttonGadget(int id)
5026 struct GadgetInfo *gi= level_editor_gadget[graphicbutton_info[id].gadget_id];
5027 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
5028 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
5029 int yoffset = ED_BORDER_SIZE;
5030 int x_left = gi->x - xoffset_left;
5031 int x_right = gi->x + gi->width + xoffset_right;
5032 int y = gi->y + yoffset;
5034 if (graphicbutton_info[id].text_left)
5035 DrawText(x_left, y, graphicbutton_info[id].text_left, FONT_TEXT_1);
5037 if (graphicbutton_info[id].text_right)
5038 DrawText(x_right, y, graphicbutton_info[id].text_right, FONT_TEXT_1);
5043 static void MapRadiobuttonGadget(int id)
5045 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
5046 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
5047 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
5048 int yoffset = ED_BORDER_SIZE;
5049 int x_left = gi->x - xoffset_left;
5050 int x_right = gi->x + gi->width + xoffset_right;
5051 int y = gi->y + yoffset;
5053 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
5055 if (radiobutton_info[id].text_left)
5056 DrawText(x_left, y, radiobutton_info[id].text_left, FONT_TEXT_1);
5058 if (radiobutton_info[id].text_right)
5059 DrawText(x_right, y, radiobutton_info[id].text_right, FONT_TEXT_1);
5061 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
5066 static void MapCheckbuttonGadget(int id)
5068 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
5069 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
5070 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
5071 int yoffset = ED_BORDER_SIZE;
5072 int x_left = gi->x - xoffset_left;
5073 int x_right = gi->x + gi->width + xoffset_right;
5074 int y = gi->y + yoffset;
5076 /* special case needed for "sticky" gadget */
5077 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value,
5078 GDI_Y, SY + checkbutton_info[id].y, GDI_END);
5079 y = gi->y + yoffset;
5081 if (checkbutton_info[id].text_left)
5082 DrawText(x_left, y, checkbutton_info[id].text_left, FONT_TEXT_1);
5084 if (checkbutton_info[id].text_right)
5085 DrawText(x_right, y, checkbutton_info[id].text_right, FONT_TEXT_1);
5090 static void MapMainDrawingArea()
5092 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
5093 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
5096 for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
5098 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
5099 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
5100 no_horizontal_scrollbar) ||
5101 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
5102 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
5103 no_vertical_scrollbar))
5106 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
5109 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
5111 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
5112 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
5115 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
5118 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
5121 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
5125 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
5127 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
5128 i == GADGET_ID_CUSTOM_COPY_TO ||
5129 i == GADGET_ID_CUSTOM_EXCHANGE)
5132 MapGadget(level_editor_gadget[i]);
5134 UnmapGadget(level_editor_gadget[i]);
5139 static void MapLevelEditorToolboxCustomGadgets()
5141 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
5144 static void UnmapLevelEditorToolboxCustomGadgets()
5146 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
5149 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
5151 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5154 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
5156 if (i != GADGET_ID_SINGLE_ITEMS &&
5157 i != GADGET_ID_PROPERTIES &&
5158 i != GADGET_ID_PICK_ELEMENT)
5160 struct GadgetInfo *gi = level_editor_gadget[i];
5168 BlitBitmap(gd_bitmap, drawto,
5169 DOOR_GFX_PAGEX6 + ED_CTRL_NO_BUTTONS_GFX_XPOS,
5170 DOOR_GFX_PAGEY1 + ED_CTRL_NO_BUTTONS_GFX_YPOS,
5171 gi->width, gi->height, gi->x, gi->y);
5173 redraw_mask |= REDRAW_DOOR_3;
5179 static void MapLevelEditorToolboxDrawingGadgets()
5181 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
5184 static void UnmapLevelEditorToolboxDrawingGadgets()
5186 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
5189 static void UnmapDrawingArea(int id)
5191 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
5194 static void UnmapLevelEditorWindowGadgets()
5198 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
5199 if (level_editor_gadget[i]->x < SX + SXSIZE)
5200 UnmapGadget(level_editor_gadget[i]);
5203 void UnmapLevelEditorGadgets()
5207 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
5208 UnmapGadget(level_editor_gadget[i]);
5211 static void ResetUndoBuffer()
5213 undo_buffer_position = -1;
5214 undo_buffer_steps = -1;
5215 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
5218 static void DrawEditModeWindow()
5220 ModifyEditorElementList();
5221 RedrawDrawingElements();
5223 if (edit_mode == ED_MODE_INFO)
5224 DrawLevelInfoWindow();
5225 else if (edit_mode == ED_MODE_PROPERTIES)
5226 DrawPropertiesWindow();
5227 else /* edit_mode == ED_MODE_DRAWING */
5228 DrawDrawingWindow();
5231 static boolean LevelChanged()
5233 boolean level_changed = FALSE;
5236 for (y = 0; y < lev_fieldy; y++)
5237 for (x = 0; x < lev_fieldx; x++)
5238 if (Feld[x][y] != level.field[x][y])
5239 level_changed = TRUE;
5241 return level_changed;
5244 static boolean LevelContainsPlayer()
5246 boolean player_found = FALSE;
5249 for (y = 0; y < lev_fieldy; y++)
5250 for (x = 0; x < lev_fieldx; x++)
5251 if (Feld[x][y] == EL_PLAYER_1 ||
5252 Feld[x][y] == EL_SP_MURPHY)
5253 player_found = TRUE;
5255 return player_found;
5258 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
5259 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
5263 for (x = 0; x < lev_fieldx; x++)
5264 for (y = 0; y < lev_fieldy; y++)
5265 dst[x][y] = src[x][y];
5268 static int setSelectboxValue(int selectbox_id, int new_value)
5270 int new_index_value = 0;
5273 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
5274 if (selectbox_info[selectbox_id].options[i].value == new_value)
5275 new_index_value = i;
5277 *selectbox_info[selectbox_id].value =
5278 selectbox_info[selectbox_id].options[new_index_value].value;
5280 return new_index_value;
5283 static void copy_custom_element_settings(int element_from, int element_to)
5286 struct ElementInfo ei_to_old = element_info[element_to];
5287 struct ElementInfo *ei_from = &element_info[element_from];
5288 struct ElementInfo *ei_to = &element_info[element_to];
5291 /* ---------- copy whole element structure ---------- */
5294 /* ---------- restore structure pointers which cannot be copied ---------- */
5295 ei_to->token_name = ei_to_old.token_name;
5296 ei_to->class_name = ei_to_old.class_name;
5297 ei_to->editor_description = ei_to_old.editor_description;
5298 ei_to->custom_description = ei_to_old.custom_description;
5299 ei_to->change_page = ei_to_old.change_page;
5300 ei_to->change = ei_to_old.change;
5301 ei_to->group = ei_to_old.group;
5303 /* ---------- copy element base properties ---------- */
5304 Properties[element_to][EP_BITFIELD_BASE] =
5305 Properties[element_from][EP_BITFIELD_BASE];
5307 /* ---------- reinitialize and copy change pages ---------- */
5308 setElementChangePages(ei_to, ei_to->num_change_pages);
5310 for (i=0; i < ei_to->num_change_pages; i++)
5311 ei_to->change_page[i] = ei_from->change_page[i];
5313 /* ---------- copy group element info ---------- */
5314 if (ei_from->group != NULL && ei_to->group != NULL) /* group or internal */
5315 *ei_to->group = *ei_from->group;
5319 struct ElementInfo *ei_from = &element_info[element_from];
5320 struct ElementInfo *ei_to = &element_info[element_to];
5323 /* ---------- copy element description ---------- */
5324 for (i = 0; i < MAX_ELEMENT_NAME_LEN + 1; i++)
5325 ei_to->description[i] = ei_from->description[i];
5327 /* ---------- copy element properties ---------- */
5328 Properties[element_to][EP_BITFIELD_BASE] =
5329 Properties[element_from][EP_BITFIELD_BASE];
5331 /* ---------- copy custom property values ---------- */
5333 ei_to->use_gfx_element = ei_from->use_gfx_element;
5334 ei_to->gfx_element = ei_from->gfx_element;
5336 ei_to->collect_score = ei_from->collect_score;
5337 ei_to->collect_count = ei_from->collect_count;
5339 ei_to->push_delay_fixed = ei_from->push_delay_fixed;
5340 ei_to->push_delay_random = ei_from->push_delay_random;
5341 ei_to->move_delay_fixed = ei_from->move_delay_fixed;
5342 ei_to->move_delay_random = ei_from->move_delay_random;
5344 ei_to->move_pattern = ei_from->move_pattern;
5345 ei_to->move_direction_initial = ei_from->move_direction_initial;
5346 ei_to->move_stepsize = ei_from->move_stepsize;
5348 ei_to->slippery_type = ei_from->slippery_type;
5350 for (y = 0; y < 3; y++)
5351 for (x = 0; x < 3; x++)
5352 ei_to->content[x][y] = ei_from->content[x][y];
5354 ei_to->num_change_pages = ei_from->num_change_pages;
5355 setElementChangePages(ei_to, ei_to->num_change_pages);
5357 for (i=0; i < ei_to->num_change_pages; i++)
5359 struct ElementChangeInfo *change_to = &ei_to->change_page[i];
5360 struct ElementChangeInfo *change_from = &ei_from->change_page[i];
5362 /* always start with reliable default values */
5363 setElementChangeInfoToDefaults(change_to);
5365 change_to->events = change_from->events;
5367 change_to->target_element = change_from->target_element;
5369 change_to->delay_fixed = change_from->delay_fixed;
5370 change_to->delay_random = change_from->delay_random;
5371 change_to->delay_frames = change_from->delay_frames;
5373 change_to->trigger_element = change_from->trigger_element;
5375 change_to->explode = change_from->explode;
5376 change_to->use_content = change_from->use_content;
5377 change_to->only_complete = change_from->only_complete;
5378 change_to->use_random_change = change_from->use_random_change;
5380 change_to->random = change_from->random;
5381 change_to->power = change_from->power;
5383 for (y = 0; y < 3; y++)
5384 for (x = 0; x < 3; x++)
5385 change_to->content[x][y] = change_from->content[x][y];
5387 change_to->can_change = change_from->can_change;
5389 change_to->sides = change_from->sides;
5393 /* mark this custom element as modified */
5394 ei_to->modified_settings = TRUE;
5397 static void replace_custom_element_in_settings(int element_from,
5402 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5404 struct ElementInfo *ei = &element_info[i];
5406 for (y = 0; y < 3; y++)
5407 for (x = 0; x < 3; x++)
5408 if (ei->content[x][y] == element_from)
5409 ei->content[x][y] = element_to;
5411 for (j = 0; j < ei->num_change_pages; j++)
5413 struct ElementChangeInfo *change = &ei->change_page[j];
5415 if (change->target_element == element_from)
5416 change->target_element = element_to;
5418 if (change->trigger_element == element_from)
5419 change->trigger_element = element_to;
5421 for (y = 0; y < 3; y++)
5422 for (x = 0; x < 3; x++)
5423 if (change->content[x][y] == element_from)
5424 change->content[x][y] = element_to;
5427 if (ei->group != NULL) /* group or internal */
5428 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
5429 if (ei->group->element[j] == element_from)
5430 ei->group->element[j] = element_to;
5434 static void replace_custom_element_in_playfield(int element_from,
5439 for (x = 0; x < lev_fieldx; x++)
5440 for (y = 0; y < lev_fieldy; y++)
5441 if (Feld[x][y] == element_from)
5442 Feld[x][y] = element_to;
5445 static boolean CopyCustomElement(int element_old, int element_new,
5448 if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
5450 Request("Please choose custom element !", REQ_CONFIRM);
5454 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
5456 Request("Please choose group element !", REQ_CONFIRM);
5461 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
5463 copy_custom_element_settings(element_new, element_old);
5465 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
5467 copy_custom_element_settings(element_old, element_new);
5469 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
5471 copy_custom_element_settings(element_old, EL_INTERNAL_EDITOR);
5472 copy_custom_element_settings(element_new, element_old);
5473 copy_custom_element_settings(EL_INTERNAL_EDITOR, element_new);
5475 replace_custom_element_in_settings(element_old, EL_INTERNAL_EDITOR);
5476 replace_custom_element_in_settings(element_new, element_old);
5477 replace_custom_element_in_settings(EL_INTERNAL_EDITOR, element_new);
5479 replace_custom_element_in_playfield(element_old, EL_INTERNAL_EDITOR);
5480 replace_custom_element_in_playfield(element_new, element_old);
5481 replace_custom_element_in_playfield(EL_INTERNAL_EDITOR, element_new);
5484 UpdateCustomElementGraphicGadgets();
5485 DrawPropertiesWindow();
5490 static void CopyCustomElementPropertiesToEditor(int element)
5493 int current_change_page = element_info[element].current_change_page;
5495 /* dynamically (re)build selectbox for selecting change page */
5496 for (i = 0; i < element_info[element].num_change_pages; i++)
5498 sprintf(options_change_page_strings[i], "%d", i + 1);
5500 options_change_page[i].value = i;
5501 options_change_page[i].text = options_change_page_strings[i];
5504 options_change_page[i].value = -1;
5505 options_change_page[i].text = NULL;
5507 /* needed here to initialize combined element properties */
5508 InitElementPropertiesEngine(level.game_version);
5510 element_info[element].change =
5511 &element_info[element].change_page[current_change_page];
5513 custom_element = element_info[element];
5514 custom_element_change = *element_info[element].change;
5516 /* needed to initially set selectbox value variables to reliable defaults */
5517 for (i = 0; i < ED_NUM_SELECTBOX; i++)
5518 setSelectboxValue(i, *selectbox_info[i].value);
5520 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
5521 custom_element_properties[i] = HAS_PROPERTY(element, i);
5523 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
5524 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
5526 /* ---------- element settings: configure (custom elements) ------------- */
5528 /* set accessible layer selectbox help value */
5529 custom_element.access_type =
5530 (IS_WALKABLE(element) ? EP_WALKABLE :
5531 IS_PASSABLE(element) ? EP_PASSABLE :
5532 custom_element.access_type);
5533 custom_element.access_layer =
5534 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
5535 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
5536 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
5537 custom_element.access_layer);
5538 custom_element.access_protected =
5539 (IS_PROTECTED(element) ? 1 : 0);
5540 custom_element_properties[EP_ACCESSIBLE] =
5541 (IS_ACCESSIBLE_OVER(element) ||
5542 IS_ACCESSIBLE_INSIDE(element) ||
5543 IS_ACCESSIBLE_UNDER(element));
5545 /* set walk-to-object action selectbox help value */
5546 custom_element.walk_to_action =
5547 (IS_DIGGABLE(element) ? EP_DIGGABLE :
5548 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
5549 IS_DROPPABLE(element) ? EP_DROPPABLE :
5550 IS_PUSHABLE(element) ? EP_PUSHABLE :
5551 custom_element.walk_to_action);
5552 custom_element_properties[EP_WALK_TO_OBJECT] =
5553 (IS_DIGGABLE(element) ||
5554 IS_COLLECTIBLE_ONLY(element) ||
5555 IS_DROPPABLE(element) ||
5556 IS_PUSHABLE(element));
5558 /* set smash targets selectbox help value */
5559 custom_element.smash_targets =
5560 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
5561 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
5562 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
5563 custom_element.smash_targets);
5564 custom_element_properties[EP_CAN_SMASH] =
5565 (CAN_SMASH_EVERYTHING(element) ||
5566 CAN_SMASH_ENEMIES(element) ||
5567 CAN_SMASH_PLAYER(element));
5569 /* set deadliness selectbox help value */
5570 custom_element.deadliness =
5571 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
5572 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
5573 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
5574 custom_element.deadliness);
5575 custom_element_properties[EP_DEADLY] =
5576 (DONT_TOUCH(element) ||
5577 DONT_COLLIDE_WITH(element) ||
5578 DONT_RUN_INTO(element));
5580 /* set consistency selectbox help value */
5581 custom_element.consistency =
5582 (IS_INDESTRUCTIBLE(element) ? EP_INDESTRUCTIBLE :
5583 CAN_EXPLODE_1X1(element) ? EP_CAN_EXPLODE_1X1 :
5584 CAN_EXPLODE_3X3(element) ? EP_CAN_EXPLODE_3X3 :
5585 CAN_EXPLODE_DYNA(element) ? EP_CAN_EXPLODE_DYNA :
5586 custom_element.consistency);
5587 custom_element_properties[EP_EXPLODE_RESULT] =
5588 (IS_INDESTRUCTIBLE(element) ||
5589 CAN_EXPLODE_1X1(element) ||
5590 CAN_EXPLODE_3X3(element) ||
5591 CAN_EXPLODE_DYNA(element));
5593 /* special case: sub-settings dependent from main setting */
5594 if (CAN_EXPLODE_BY_FIRE(element))
5595 custom_element.can_explode_by_fire = TRUE;
5596 if (CAN_EXPLODE_SMASHED(element))
5597 custom_element.can_explode_smashed = TRUE;
5598 if (CAN_EXPLODE_IMPACT(element))
5599 custom_element.can_explode_impact = TRUE;
5601 /* ---------- element settings: advanced (custom elements) --------------- */
5603 /* set "change by direct action" selectbox help value */
5604 custom_element_change.direct_action =
5605 (HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
5606 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
5607 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
5608 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
5609 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
5610 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
5611 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
5612 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
5613 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
5614 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
5615 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
5616 custom_element_change.direct_action);
5618 /* set "change by other element action" selectbox help value */
5619 custom_element_change.other_action =
5620 (HAS_CHANGE_EVENT(element, CE_OTHER_GETS_TOUCHED) ? CE_OTHER_GETS_TOUCHED :
5621 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_PRESSED) ? CE_OTHER_GETS_PRESSED :
5622 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_PUSHED) ? CE_OTHER_GETS_PUSHED :
5623 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_ENTERED) ? CE_OTHER_GETS_ENTERED :
5624 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_LEFT) ? CE_OTHER_GETS_LEFT :
5625 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_DIGGED) ? CE_OTHER_GETS_DIGGED :
5626 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_COLLECTED) ? CE_OTHER_GETS_COLLECTED :
5627 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_DROPPED) ? CE_OTHER_GETS_DROPPED :
5628 HAS_CHANGE_EVENT(element, CE_OTHER_IS_TOUCHING) ? CE_OTHER_IS_TOUCHING :
5629 HAS_CHANGE_EVENT(element, CE_OTHER_IS_HITTING) ? CE_OTHER_IS_HITTING :
5630 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_HIT) ? CE_OTHER_GETS_HIT :
5631 HAS_CHANGE_EVENT(element, CE_OTHER_IS_SWITCHING) ? CE_OTHER_IS_SWITCHING :
5632 HAS_CHANGE_EVENT(element, CE_OTHER_IS_CHANGING) ? CE_OTHER_IS_CHANGING :
5633 HAS_CHANGE_EVENT(element, CE_OTHER_IS_EXPLODING) ? CE_OTHER_IS_EXPLODING :
5634 custom_element_change.other_action);
5637 static void CopyGroupElementPropertiesToEditor(int element)
5639 group_element_info = *element_info[element].group;
5640 custom_element = element_info[element]; /* needed for description */
5643 static void CopyElementPropertiesToEditor(int element)
5645 if (IS_CUSTOM_ELEMENT(element))
5646 CopyCustomElementPropertiesToEditor(element);
5647 else if (IS_GROUP_ELEMENT(element))
5648 CopyGroupElementPropertiesToEditor(element);
5651 static void CopyCustomElementPropertiesToGame(int element)
5654 int access_type_and_layer;
5656 /* mark that this custom element has been modified */
5657 custom_element.modified_settings = TRUE;
5659 if (level.use_custom_template)
5661 if (Request("Copy and modify level template ?", REQ_ASK))
5663 level.use_custom_template = FALSE;
5664 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE],
5665 GDI_CHECKED, FALSE, GDI_END);
5669 LoadLevelTemplate(-1); /* this resets all element modifications ... */
5671 DrawEditModeWindow(); /* ... and copies them to 'custom_element' */
5675 element_info[element] = custom_element;
5676 *element_info[element].change = custom_element_change;
5678 /* ---------- element settings: configure (custom elements) ------------- */
5680 /* set accessible property from checkbox and selectbox */
5681 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
5682 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
5683 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
5684 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
5685 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
5686 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
5687 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
5688 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
5689 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
5690 custom_element_properties[access_type_and_layer] =
5691 custom_element_properties[EP_ACCESSIBLE];
5692 custom_element_properties[EP_PROTECTED] =
5693 (custom_element.access_protected != 0 &&
5694 custom_element_properties[EP_ACCESSIBLE]);
5696 /* set walk-to-object property from checkbox and selectbox */
5697 custom_element_properties[EP_DIGGABLE] = FALSE;
5698 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
5699 custom_element_properties[EP_DROPPABLE] = FALSE;
5700 custom_element_properties[EP_PUSHABLE] = FALSE;
5701 custom_element_properties[custom_element.walk_to_action] =
5702 custom_element_properties[EP_WALK_TO_OBJECT];
5704 /* set smash property from checkbox and selectbox */
5705 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
5706 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
5707 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
5708 custom_element_properties[custom_element.smash_targets] =
5709 custom_element_properties[EP_CAN_SMASH];
5711 /* set deadliness property from checkbox and selectbox */
5712 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
5713 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
5714 custom_element_properties[EP_DONT_TOUCH] = FALSE;
5715 custom_element_properties[custom_element.deadliness] =
5716 custom_element_properties[EP_DEADLY];
5718 /* set consistency property from checkbox and selectbox */
5719 custom_element_properties[EP_INDESTRUCTIBLE] = FALSE;
5720 custom_element_properties[EP_CAN_EXPLODE_1X1] = FALSE;
5721 custom_element_properties[EP_CAN_EXPLODE_3X3] = FALSE;
5722 custom_element_properties[EP_CAN_EXPLODE_DYNA] = FALSE;
5723 custom_element_properties[EP_CAN_EXPLODE_BY_FIRE] = FALSE;
5724 custom_element_properties[EP_CAN_EXPLODE_SMASHED] = FALSE;
5725 custom_element_properties[EP_CAN_EXPLODE_IMPACT] = FALSE;
5726 custom_element_properties[custom_element.consistency] =
5727 custom_element_properties[EP_EXPLODE_RESULT];
5729 /* special case: sub-settings dependent from main setting */
5730 if (custom_element_properties[EP_CAN_EXPLODE_1X1] ||
5731 custom_element_properties[EP_CAN_EXPLODE_3X3] ||
5732 custom_element_properties[EP_CAN_EXPLODE_DYNA])
5734 custom_element_properties[EP_CAN_EXPLODE_BY_FIRE] =
5735 custom_element.can_explode_by_fire;
5736 custom_element_properties[EP_CAN_EXPLODE_SMASHED] =
5737 custom_element.can_explode_smashed;
5738 custom_element_properties[EP_CAN_EXPLODE_IMPACT] =
5739 custom_element.can_explode_impact;
5742 /* ---------- element settings: advanced (custom elements) --------------- */
5744 /* set player change event from checkbox and selectbox */
5745 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
5746 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
5747 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
5748 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
5749 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
5750 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
5751 custom_element_change_events[CE_SWITCHED] = FALSE;
5752 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
5753 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
5754 custom_element_change_events[CE_IMPACT] = FALSE;
5755 custom_element_change_events[CE_SMASHED] = FALSE;
5756 custom_element_change_events[custom_element_change.direct_action] =
5757 custom_element_change_events[CE_BY_DIRECT_ACTION];
5759 /* set other element action change event from checkbox and selectbox */
5760 custom_element_change_events[CE_OTHER_GETS_TOUCHED] = FALSE;
5761 custom_element_change_events[CE_OTHER_GETS_PRESSED] = FALSE;
5762 custom_element_change_events[CE_OTHER_GETS_PUSHED] = FALSE;
5763 custom_element_change_events[CE_OTHER_GETS_ENTERED] = FALSE;
5764 custom_element_change_events[CE_OTHER_GETS_LEFT] = FALSE;
5765 custom_element_change_events[CE_OTHER_GETS_DIGGED] = FALSE;
5766 custom_element_change_events[CE_OTHER_GETS_COLLECTED] = FALSE;
5767 custom_element_change_events[CE_OTHER_GETS_DROPPED] = FALSE;
5768 custom_element_change_events[CE_OTHER_IS_TOUCHING] = FALSE;
5769 custom_element_change_events[CE_OTHER_IS_HITTING] = FALSE;
5770 custom_element_change_events[CE_OTHER_GETS_HIT] = FALSE;
5771 custom_element_change_events[CE_OTHER_IS_SWITCHING] = FALSE;
5772 custom_element_change_events[CE_OTHER_IS_CHANGING] = FALSE;
5773 custom_element_change_events[CE_OTHER_IS_EXPLODING] = FALSE;
5774 custom_element_change_events[custom_element_change.other_action] =
5775 custom_element_change_events[CE_BY_OTHER_ACTION];
5777 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
5778 SET_PROPERTY(element, i, custom_element_properties[i]);
5780 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
5781 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
5783 /* copy change events also to special level editor variable */
5784 custom_element = element_info[element];
5785 custom_element_change = *element_info[element].change;
5788 static void CopyGroupElementPropertiesToGame(int element)
5790 element_info[element] = custom_element;
5791 *element_info[element].group = group_element_info;
5793 /* mark that this group element has been modified */
5794 element_info[element].modified_settings = TRUE;
5797 static void CopyElementPropertiesToGame(int element)
5799 if (IS_CUSTOM_ELEMENT(element))
5800 CopyCustomElementPropertiesToGame(element);
5801 else if (IS_GROUP_ELEMENT(element))
5802 CopyGroupElementPropertiesToGame(element);
5807 CloseDoor(DOOR_CLOSE_ALL);
5808 OpenDoor(DOOR_OPEN_2 | DOOR_NO_DELAY);
5810 if (level_editor_test_game)
5812 CopyPlayfield(level.field, Feld);
5813 CopyPlayfield(FieldBackup, level.field);
5815 level_editor_test_game = FALSE;
5819 edit_mode = ED_MODE_DRAWING;
5820 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
5828 /* copy default editor door content to main double buffer */
5829 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
5830 DOOR_GFX_PAGEX6, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
5833 /* draw mouse button brush elements */
5834 RedrawDrawingElements();
5837 /* draw bigger door */
5838 DrawSpecialEditorDoor();
5840 /* draw new control window */
5841 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
5842 DOOR_GFX_PAGEX8, 236, EXSIZE, EYSIZE, EX, EY);
5844 redraw_mask |= REDRAW_ALL;
5846 ReinitializeElementListButtons(); /* only needed after setup changes */
5848 ModifyEditorElementList(); /* may be needed for custom elements */
5852 MapControlButtons();
5854 DrawEditModeWindow();
5856 /* copy actual editor door content to door double buffer for OpenDoor() */
5857 BlitBitmap(drawto, bitmap_db_door,
5858 DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
5860 OpenDoor(DOOR_OPEN_1);
5863 static void AdjustDrawingAreaGadgets()
5865 int ed_xsize = lev_fieldx + 2;
5866 int ed_ysize = lev_fieldy + 2;
5867 int max_ed_fieldx = MAX_ED_FIELDX;
5868 int max_ed_fieldy = MAX_ED_FIELDY;
5869 boolean horizontal_scrollbar_needed;
5870 boolean vertical_scrollbar_needed;
5871 int x, y, width, height;
5872 int xoffset, yoffset;
5874 /* check if we need any scrollbars */
5875 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
5876 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
5878 /* check if we have a smaller editor field because of scrollbars */
5879 if (horizontal_scrollbar_needed)
5880 max_ed_fieldy = MAX_ED_FIELDY - 1;
5881 if (vertical_scrollbar_needed)
5882 max_ed_fieldx = MAX_ED_FIELDX - 1;
5884 /* check again if we now need more scrollbars because of less space */
5885 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
5886 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
5888 /* check if editor field gets even smaller after adding new scrollbars */
5889 if (horizontal_scrollbar_needed)
5890 max_ed_fieldy = MAX_ED_FIELDY - 1;
5891 if (vertical_scrollbar_needed)
5892 max_ed_fieldx = MAX_ED_FIELDX - 1;
5894 ed_fieldx = (ed_xsize < MAX_ED_FIELDX ? ed_xsize : max_ed_fieldx);
5895 ed_fieldy = (ed_ysize < MAX_ED_FIELDY ? ed_ysize : max_ed_fieldy);
5897 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
5898 GDI_WIDTH, ed_fieldx * MINI_TILEX,
5899 GDI_HEIGHT, ed_fieldy * MINI_TILEY,
5900 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
5903 xoffset = (ed_fieldx == MAX_ED_FIELDX ? ED_SCROLLBUTTON_XSIZE : 0);
5904 yoffset = (ed_fieldy == MAX_ED_FIELDY ? ED_SCROLLBUTTON_YSIZE : 0);
5906 x = SX + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_RIGHT].x + xoffset;
5907 y = SX + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_DOWN].y + yoffset;
5909 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT], GDI_X, x, GDI_END);
5910 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN], GDI_Y, y, GDI_END);
5912 width = scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width + xoffset;
5913 height = scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].height + yoffset;
5915 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
5917 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
5919 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
5921 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
5925 static void AdjustLevelScrollPosition()
5927 if (level_xpos < -1)
5929 if (level_xpos > lev_fieldx - ed_fieldx + 1)
5930 level_xpos = lev_fieldx - ed_fieldx + 1;
5931 if (lev_fieldx < ed_fieldx - 2)
5934 if (level_ypos < -1)
5936 if (level_ypos > lev_fieldy - ed_fieldy + 1)
5937 level_ypos = lev_fieldy - ed_fieldy + 1;
5938 if (lev_fieldy < ed_fieldy - 2)
5942 static void AdjustEditorScrollbar(int id)
5944 struct GadgetInfo *gi = level_editor_gadget[id];
5945 int items_max, items_visible, item_position;
5947 if (id == GADGET_ID_SCROLL_HORIZONTAL)
5949 items_max = MAX(lev_fieldx + 2, ed_fieldx);
5950 items_visible = ed_fieldx;
5951 item_position = level_xpos + 1;
5955 items_max = MAX(lev_fieldy + 2, ed_fieldy);
5956 items_visible = ed_fieldy;
5957 item_position = level_ypos + 1;
5960 if (item_position > items_max - items_visible)
5961 item_position = items_max - items_visible;
5963 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
5964 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
5967 static void ModifyEditorCounter(int counter_id, int new_value)
5969 int *counter_value = counterbutton_info[counter_id].value;
5970 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
5971 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
5973 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
5975 if (counter_value != NULL)
5976 *counter_value = gi->textinput.number_value;
5979 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
5981 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
5982 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
5984 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
5987 static void ModifyEditorSelectbox(int selectbox_id, int new_value)
5989 int gadget_id = selectbox_info[selectbox_id].gadget_id;
5990 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
5991 int new_index_value = setSelectboxValue(selectbox_id, new_value);
5993 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
5996 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
5998 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
5999 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
6001 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
6004 static void ModifyEditorElementList()
6008 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6010 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
6011 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
6012 struct GadgetDesign *gd = &gi->deco.design;
6013 int element = editor_elements[element_shift + i];
6016 getMiniGraphicSource(el2edimg(element), &gd->bitmap, &gd->x, &gd->y);
6017 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
6022 static void PickDrawingElement(int button, int element)
6024 if (button < 1 || button > 3)
6029 new_element1 = element;
6030 DrawMiniGraphicExt(drawto,
6031 DX + ED_WIN_MB_LEFT_XPOS, DY + ED_WIN_MB_LEFT_YPOS,
6032 el2edimg(new_element1));
6034 else if (button == 2)
6036 new_element2 = element;
6037 DrawMiniGraphicExt(drawto,
6038 DX + ED_WIN_MB_MIDDLE_XPOS, DY + ED_WIN_MB_MIDDLE_YPOS,
6039 el2edimg(new_element2));
6043 new_element3 = element;
6044 DrawMiniGraphicExt(drawto,
6045 DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS,
6046 el2edimg(new_element3));
6049 redraw_mask |= REDRAW_DOOR_1;
6052 static void RedrawDrawingElements()
6054 PickDrawingElement(1, new_element1);
6055 PickDrawingElement(2, new_element2);
6056 PickDrawingElement(3, new_element3);
6059 static void DrawDrawingWindow()
6061 stick_element_properties_window = FALSE;
6063 SetMainBackgroundImage(IMG_UNDEFINED);
6066 UnmapLevelEditorWindowGadgets();
6067 UnmapLevelEditorToolboxCustomGadgets();
6069 AdjustDrawingAreaGadgets();
6070 AdjustLevelScrollPosition();
6071 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
6072 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
6074 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
6076 MapMainDrawingArea();
6077 MapLevelEditorToolboxDrawingGadgets();
6080 static void DrawLevelInfoWindow()
6084 stick_element_properties_window = FALSE;
6086 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
6088 UnmapLevelEditorWindowGadgets();
6090 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS1_YPOS,
6091 "Level Settings", FONT_TITLE_1);
6092 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS2_YPOS,
6093 "Editor Settings", FONT_TITLE_1);
6095 /* draw counter gadgets */
6096 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
6097 MapCounterButtons(i);
6099 /* draw checkbutton gadgets */
6100 for (i=ED_CHECKBUTTON_ID_LEVEL_FIRST; i <= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
6101 MapCheckbuttonGadget(i);
6103 /* draw radiobutton gadgets */
6104 for (i=ED_RADIOBUTTON_ID_LEVEL_FIRST; i <= ED_RADIOBUTTON_ID_LEVEL_LAST; i++)
6105 MapRadiobuttonGadget(i);
6107 /* draw text input gadgets */
6108 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
6109 MapTextInputGadget(i);
6111 /* draw drawing area */
6112 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
6115 static void DrawCustomContentArea()
6117 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
6118 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6119 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
6120 int x2 = right_gadget_border[GADGET_ID_CUSTOM_CONSISTENCY];
6121 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
6122 int xoffset = ED_DRAWINGAREA_TEXT_DISTANCE;
6124 /* add distance for potential left text (without drawing area border) */
6125 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
6127 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
6129 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
6132 static void DrawCustomChangeContentArea()
6134 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
6135 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6136 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
6137 int x2 = right_gadget_border[GADGET_ID_CHANGE_POWER];
6138 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
6139 int xoffset = ED_DRAWINGAREA_TEXT_DISTANCE;
6141 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
6146 static void DrawElementContentAreas()
6148 int x = SX + ED_AREA_YAMYAM_CONTENT_XPOS(3) + 4 * MINI_TILEX;
6149 int y = SY + ED_AREA_YAMYAM_CONTENT_YPOS(0) + ED_BORDER_AREA_YSIZE;
6152 /* display counter to choose number of element content areas */
6153 MapCounterButtons(ED_COUNTER_ID_ELEMENT_CONTENT);
6155 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
6157 int id = ED_DRAWING_ID_ELEMENT_CONTENT_0 + i;
6158 int font_height = getFontHeight(FONT_TEXT_1);
6160 if (i < level.num_yamyam_contents)
6164 UnmapDrawingArea(id);
6166 /* delete content areas in case of reducing number of them */
6167 DrawBackground(SX + drawingarea_info[id].x - MINI_TILEX / 2,
6168 SY + drawingarea_info[id].y - MINI_TILEY / 2,
6170 4 * MINI_TILEY + ED_GADGET_TEXT_DISTANCE + font_height);
6174 DrawText(x, y + 0 * MINI_TILEY, "content", FONT_TEXT_1);
6175 DrawText(x, y + 1 * MINI_TILEY, "when", FONT_TEXT_1);
6176 DrawText(x, y + 2 * MINI_TILEY, "smashed", FONT_TEXT_1);
6179 static void DrawGroupElementArea(int element)
6181 int num_elements = group_element_info.num_elements;
6182 int id = ED_DRAWING_ID_GROUP_CONTENT;
6183 int sx = SX + drawingarea_info[id].x - MINI_TILEX / 2;
6184 int sy = SY + drawingarea_info[id].y - MINI_TILEY / 2;
6185 int xsize = MAX_ELEMENTS_IN_GROUP;
6188 if (drawingarea_info[id].text_left != NULL)
6189 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
6191 UnmapDrawingArea(id);
6193 ModifyEditorDrawingArea(id, num_elements, 1);
6195 /* delete content areas in case of reducing number of them */
6196 DrawBackground(sx, sy, (xsize + 1) * MINI_TILEX, (ysize + 1) * MINI_TILEY);
6201 static void DrawEnvelopeTextArea(int envelope_nr)
6203 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
6204 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
6207 DrawBackground(gi->x, gi->y, gi->width, gi->height);
6209 if (envelope_nr != -1)
6210 textarea_info[id].value = level.envelope_text[envelope_nr];
6212 ModifyGadget(gi, GDI_AREA_SIZE,
6213 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
6214 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
6217 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
6220 char *getElementDescriptionFilename(int element)
6222 char *docs_dir = options.docs_directory;
6223 char *elements_subdir = "elements";
6224 static char *filename = NULL;
6225 char basename[MAX_FILENAME_LEN];
6227 checked_free(filename);
6229 /* 1st try: look for element description file for exactly this element */
6230 sprintf(basename, "%s.txt", element_info[element].token_name);
6231 filename = getPath3(docs_dir, elements_subdir, basename);
6232 if (fileExists(filename))
6237 /* 2nd try: look for element description file for this element's class */
6238 sprintf(basename, "%s.txt", element_info[element].class_name);
6239 filename = getPath3(docs_dir, elements_subdir, basename);
6240 if (fileExists(filename))
6246 static boolean PrintInfoText(char *text, int font_nr, int start_line)
6248 int font_height = getFontHeight(font_nr);
6249 int pad_x = ED_SETTINGS_XPOS(0);
6250 int pad_y = ED_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
6251 int sx = SX + pad_x;
6252 int sy = SY + pad_y;
6253 int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
6255 if (start_line >= max_lines_per_screen)
6258 DrawText(sx, sy + start_line * font_height, text, font_nr);
6265 static int PrintElementDescriptionFromFile(char *filename, int start_line)
6267 int font_nr = FONT_TEXT_2;
6268 int font_width = getFontWidth(font_nr);
6269 int font_height = getFontHeight(font_nr);
6270 int pad_x = ED_SETTINGS_XPOS(0);
6271 int pad_y = ED_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
6272 int sx = SX + pad_x;
6273 int sy = SY + pad_y + start_line * font_height;
6274 int max_chars_per_line = (SXSIZE - 2 * pad_x) / font_width;
6275 int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
6277 return DrawTextFromFile(sx, sy, filename, font_nr, max_chars_per_line,
6278 max_lines_per_screen);
6283 static int PrintElementDescriptionFromFile(char *filename, int start_line)
6285 int font_nr = FONT_TEXT_2;
6286 int font_width = getFontWidth(font_nr);
6287 int font_height = getFontHeight(font_nr);
6288 int pad_x = ED_SETTINGS_XPOS(0);
6289 int pad_y = ED_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
6290 int sx = SX + pad_x;
6291 int sy = SY + pad_y;
6292 int max_chars_per_line = (SXSIZE - 2 * pad_x) / font_width;
6293 int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
6294 int current_line = start_line;
6295 char line[MAX_LINE_LEN];
6296 char buffer[max_chars_per_line + 1];
6300 if (current_line >= max_lines_per_screen)
6303 if (filename == NULL)
6306 if (!(file = fopen(filename, MODE_READ)))
6312 while (!feof(file) && current_line < max_lines_per_screen)
6315 boolean last_line_was_empty = TRUE;
6317 /* read next line of input file */
6318 if (!fgets(line, MAX_LINE_LEN, file))
6321 /* skip comments (lines directly beginning with '#') */
6325 /* cut trailing newline from input line */
6326 for (line_ptr = line; *line_ptr; line_ptr++)
6328 if (*line_ptr == '\n' || *line_ptr == '\r')
6335 if (strlen(line) == 0) /* special case: force empty line */
6340 while (*line_ptr && current_line < max_lines_per_screen)
6342 boolean buffer_filled = RenderLineToBuffer(&line_ptr,
6343 buffer, &buffer_len,
6344 last_line_was_empty,
6345 max_chars_per_line);
6348 DrawText(sx, sy + current_line * font_height, buffer, font_nr);
6351 last_line_was_empty = (buffer_len == 0);
6361 if (buffer_len > 0 && current_line < max_lines_per_screen)
6363 DrawText(sx, sy + current_line * font_height, buffer, font_nr);
6367 return (current_line - start_line);
6372 static void DrawPropertiesTabulatorGadgets()
6374 struct GadgetInfo *gd_gi = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
6375 struct GadgetDesign *gd = &gd_gi->alt_design[GD_BUTTON_UNPRESSED];
6376 int gd_x = gd->x + gd_gi->border.width / 2;
6377 int gd_y = gd->y + gd_gi->height - 1;
6378 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
6379 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
6380 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
6384 /* draw additional "advanced" tabulator for custom elements */
6385 if (IS_CUSTOM_ELEMENT(properties_element))
6386 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
6388 for (i = id_first; i <= id_last; i++)
6390 int gadget_id = textbutton_info[i].gadget_id;
6391 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
6392 boolean active = (i != edit_mode_properties);
6394 /* use "config 1" and "config 2" instead of "config" */
6395 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
6396 IS_CUSTOM_ELEMENT(properties_element))
6399 /* draw background line below tabulator button */
6400 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width,1);
6402 /* draw solid line below inactive tabulator buttons */
6403 if (!active && tab_color != BLACK_PIXEL) /* black => transparent */
6404 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,1, tab_color);
6406 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
6407 MapTextbuttonGadget(i);
6410 /* draw little border line below tabulator buttons */
6411 if (tab_color != BLACK_PIXEL) /* black => transparent */
6412 FillRectangle(drawto, gd_gi->x, gd_gi->y + gd_gi->height + 1,
6413 max_tabs * gd_gi->width + (max_tabs -1) * ED_GADGET_DISTANCE,
6414 ED_GADGET_DISTANCE, tab_color);
6417 static void DrawPropertiesInfo()
6426 /* configurable properties */
6428 { EP_WALKABLE_OVER, "- player can walk over it" },
6429 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
6430 { EP_WALKABLE_UNDER, "- player can walk under it" },
6431 { EP_PASSABLE_OVER, "- player can pass over it" },
6432 { EP_PASSABLE_INSIDE, "- player can pass through it" },
6433 { EP_PASSABLE_UNDER, "- player can pass under it" },
6435 { EP_DIGGABLE, "- can be digged away" },
6436 { EP_COLLECTIBLE, "- can be collected" },
6437 { EP_DROPPABLE, "- can be dropped after collecting" },
6438 { EP_PUSHABLE, "- can be pushed" },
6440 { EP_CAN_MOVE, "- can move" },
6441 { EP_CAN_FALL, "- can fall" },
6443 { EP_CAN_SMASH_PLAYER, "- can smash player" },
6445 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
6447 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
6449 { EP_SLIPPERY, "- slippery for falling objects" },
6450 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
6452 { EP_DONT_RUN_INTO, "- deadly when running into" },
6453 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
6454 { EP_DONT_TOUCH, "- deadly when touching" },
6456 { EP_INDESTRUCTIBLE, "- indestructible" },
6458 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
6459 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
6460 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
6462 { EP_CAN_CHANGE, "- can change to other element" },
6464 /* pre-defined properties */
6465 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
6466 { EP_HAS_CONTENT, "- can contain other elements" },
6470 char *filename = getElementDescriptionFilename(properties_element);
6471 char *percentage_text = "In this level:";
6472 char *properties_text = "Standard properties:";
6474 int num_elements_in_level;
6475 int num_standard_properties = 0;
6476 int font1_nr = FONT_TEXT_1;
6477 int font2_nr = FONT_TEXT_2;
6478 int font1_width = getFontWidth(font1_nr);
6479 int font2_height = getFontHeight(font2_nr);
6480 int pad_x = ED_SETTINGS_XPOS(0);
6481 int pad_y = ED_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
6482 int screen_line = 0;
6486 if (IS_CUSTOM_ELEMENT(properties_element))
6488 DrawTextF(pad_x, pad_y + screen_line++ * font2_height, FONT_TEXT_3,
6489 "[Custom Element %d]", properties_element - EL_CUSTOM_START + 1);
6492 else if (IS_GROUP_ELEMENT(properties_element))
6494 DrawTextF(pad_x, pad_y + screen_line++ * font2_height, FONT_TEXT_3,
6495 "[Group Element %d]", properties_element - EL_GROUP_START + 1);
6500 /* ----- print number of elements / percentage of this element in level */
6502 num_elements_in_level = 0;
6503 for (y = 0; y < lev_fieldy; y++)
6504 for (x = 0; x < lev_fieldx; x++)
6505 if (Feld[x][y] == properties_element)
6506 num_elements_in_level++;
6507 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
6509 DrawTextS(pad_x, pad_y + screen_line * font2_height, font1_nr,
6511 DrawTextF(pad_x + strlen(percentage_text) * font1_width,
6512 pad_y + screen_line++ * font2_height, font2_nr,
6513 "%d (%.2f%%)", num_elements_in_level, percentage);
6517 /* ----- print standard properties of this element */
6519 DrawTextS(pad_x, pad_y + screen_line++ * font2_height, font1_nr,
6522 for (i = 0; properties[i].value != -1; i++)
6524 if (!HAS_PROPERTY(properties_element, properties[i].value))
6527 DrawTextS(pad_x, pad_y + screen_line++ * font2_height, font2_nr,
6528 properties[i].text);
6529 num_standard_properties++;
6532 if (num_standard_properties == 0)
6533 DrawTextS(pad_x + strlen(properties_text) * font1_width,
6534 pad_y + (screen_line - 1) * font2_height, font2_nr, "none");
6538 /* ----- print special description of this element */
6540 PrintInfoText("Description:", FONT_TEXT_1, screen_line);
6541 if (PrintElementDescriptionFromFile(filename, screen_line + 1) == 0)
6542 PrintInfoText("No description available.", FONT_TEXT_1, screen_line);
6545 #define TEXT_COLLECTING "Score for collecting"
6546 #define TEXT_SMASHING "Score for smashing"
6547 #define TEXT_CRACKING "Score for cracking"
6548 #define TEXT_SPEED "Speed of amoeba growth"
6549 #define TEXT_DURATION "Duration when activated"
6556 } elements_with_counter[] =
6558 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
6559 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
6560 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
6561 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
6562 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
6563 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
6564 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
6565 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
6566 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
6567 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
6568 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
6569 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
6570 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
6571 { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
6572 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
6573 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
6574 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
6575 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
6576 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6577 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6578 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6579 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6580 { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
6581 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6582 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6583 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6584 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6585 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
6586 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
6587 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
6588 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
6589 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
6590 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
6591 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
6592 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
6593 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
6594 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE],TEXT_COLLECTING },
6595 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
6596 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
6597 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
6598 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
6599 { EL_EXTRA_TIME, &level.score[SC_TIME_BONUS], TEXT_COLLECTING },
6600 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
6601 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
6602 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
6603 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
6605 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
6606 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
6607 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
6608 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
6610 { EL_EM_KEY_1_FILE, &level.score[SC_KEY], TEXT_COLLECTING },
6611 { EL_EM_KEY_2_FILE, &level.score[SC_KEY], TEXT_COLLECTING },
6612 { EL_EM_KEY_3_FILE, &level.score[SC_KEY], TEXT_COLLECTING },
6613 { EL_EM_KEY_4_FILE, &level.score[SC_KEY], TEXT_COLLECTING },
6615 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_SPEED },
6616 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_SPEED },
6617 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_SPEED },
6618 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_SPEED },
6619 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
6620 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
6624 static boolean checkPropertiesConfig()
6628 if (IS_GEM(properties_element) ||
6629 IS_CUSTOM_ELEMENT(properties_element) ||
6630 IS_GROUP_ELEMENT(properties_element) ||
6631 IS_ENVELOPE(properties_element) ||
6632 ELEM_IS_PLAYER(properties_element) ||
6633 HAS_CONTENT(properties_element))
6636 for (i = 0; elements_with_counter[i].element != -1; i++)
6637 if (elements_with_counter[i].element == properties_element)
6643 static void DrawPropertiesConfig()
6647 if (!checkPropertiesConfig())
6649 PrintInfoText("No configuration options available.", FONT_TEXT_1, 0);
6654 /* check if there are elements where a score can be chosen for */
6655 for (i = 0; elements_with_counter[i].element != -1; i++)
6657 if (elements_with_counter[i].element == properties_element)
6659 int counter_id = ED_COUNTER_ID_ELEMENT_SCORE;
6661 if (HAS_CONTENT(properties_element)) /* needs stickybutton */
6662 counterbutton_info[counter_id].y = ED_SETTINGS_YPOS(1);
6664 counterbutton_info[counter_id].y = ED_SETTINGS_YPOS(0);
6666 counterbutton_info[counter_id].value = elements_with_counter[i].value;
6667 counterbutton_info[counter_id].text_right= elements_with_counter[i].text;
6669 MapCounterButtons(counter_id);
6675 if (HAS_CONTENT(properties_element))
6677 /* draw stickybutton gadget */
6678 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
6680 if (IS_AMOEBOID(properties_element))
6681 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
6683 DrawElementContentAreas();
6686 if (IS_GEM(properties_element))
6687 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
6689 if (ELEM_IS_PLAYER(properties_element))
6690 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
6691 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
6692 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
6694 if (IS_ENVELOPE(properties_element))
6696 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
6697 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
6698 int envelope_nr = properties_element - EL_ENVELOPE_1;
6700 counterbutton_info[counter1_id].value = &level.envelope_xsize[envelope_nr];
6701 counterbutton_info[counter2_id].value = &level.envelope_ysize[envelope_nr];
6703 /* display counter to choose size of envelope text area */
6704 MapCounterButtons(ED_COUNTER_ID_ENVELOPE_XSIZE);
6705 MapCounterButtons(ED_COUNTER_ID_ENVELOPE_YSIZE);
6707 DrawEnvelopeTextArea(envelope_nr);
6710 if (IS_CUSTOM_ELEMENT(properties_element))
6712 /* draw stickybutton gadget */
6713 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
6715 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
6717 /* draw checkbutton gadgets */
6718 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
6719 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
6720 MapCheckbuttonGadget(i);
6722 /* draw counter gadgets */
6723 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
6724 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
6725 MapCounterButtons(i);
6727 /* draw selectbox gadgets */
6728 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
6729 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
6730 MapSelectboxGadget(i);
6732 /* draw textbutton gadgets */
6733 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE);
6735 /* draw text input gadgets */
6736 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
6738 /* draw drawing area gadgets */
6739 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
6740 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
6741 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
6743 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
6745 /* draw checkbutton gadgets */
6746 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
6747 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
6748 MapCheckbuttonGadget(i);
6750 /* draw counter gadgets */
6751 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
6752 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
6753 MapCounterButtons(i);
6755 /* draw selectbox gadgets */
6756 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
6757 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
6758 MapSelectboxGadget(i);
6760 /* draw drawing area gadgets */
6761 DrawCustomContentArea();
6764 else if (IS_GROUP_ELEMENT(properties_element))
6766 /* draw stickybutton gadget */
6767 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
6769 /* draw checkbutton gadgets */
6770 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
6771 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE);
6773 /* draw counter gadgets */
6774 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
6776 /* draw selectbox gadgets */
6777 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
6779 /* draw textbutton gadgets */
6780 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE);
6782 /* draw drawing area gadgets */
6783 DrawGroupElementArea(properties_element);
6785 /* draw text input gadgets */
6786 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
6788 /* draw drawing area gadgets */
6789 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
6793 static void DrawPropertiesChangeDrawingAreas()
6795 if (IS_CUSTOM_ELEMENT(properties_element))
6797 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
6798 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
6800 DrawCustomChangeContentArea();
6803 redraw_mask |= REDRAW_FIELD;
6806 static void DrawPropertiesChange()
6810 /* draw stickybutton gadget */
6811 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
6813 /* draw checkbutton gadgets */
6814 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
6815 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
6816 MapCheckbuttonGadget(i);
6818 /* draw counter gadgets */
6819 for (i = ED_COUNTER_ID_CHANGE_FIRST;
6820 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
6821 MapCounterButtons(i);
6823 /* draw selectbox gadgets */
6824 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
6825 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
6826 MapSelectboxGadget(i);
6828 /* draw textbutton gadgets */
6829 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
6830 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
6831 MapTextbuttonGadget(i);
6833 /* draw graphicbutton gadgets */
6834 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
6835 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
6836 MapGraphicbuttonGadget(i);
6838 /* draw drawing area gadgets */
6839 DrawPropertiesChangeDrawingAreas();
6842 static void DrawElementName(int x, int y, int element)
6844 char *element_name = getElementInfoText(element);
6845 int font_nr = FONT_TEXT_1;
6846 int font_width = getFontWidth(font_nr);
6847 int font_height = getFontHeight(font_nr);
6848 int max_text_width = SXSIZE - x - ED_SETTINGS_XPOS(0);
6849 int max_chars_per_line = max_text_width / font_width;
6850 char buffer[max_chars_per_line + 1];
6852 if (strlen(element_name) <= max_chars_per_line)
6853 DrawTextS(x, y, font_nr, element_name);
6856 int next_pos = max_chars_per_line;
6858 strncpy(buffer, element_name, max_chars_per_line);
6859 buffer[max_chars_per_line] = '\0';
6861 if (element_name[max_chars_per_line] == ' ')
6867 for (i = max_chars_per_line - 1; i >= 0; i--)
6868 if (buffer[i] == ' ')
6871 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
6878 DrawTextS(x, y - font_height / 2, font_nr, buffer);
6880 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
6881 buffer[max_chars_per_line] = '\0';
6883 DrawTextS(x, y + font_height / 2, font_nr, buffer);
6887 static void DrawPropertiesWindow()
6892 stick_element_properties_window = FALSE;
6894 /* make sure that previous properties edit mode exists for this element */
6895 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
6896 !IS_CUSTOM_ELEMENT(properties_element))
6897 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
6899 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
6900 IS_CUSTOM_ELEMENT(properties_element))
6901 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
6903 CopyElementPropertiesToEditor(properties_element);
6905 UnmapLevelEditorWindowGadgets();
6906 UnmapLevelEditorToolboxDrawingGadgets();
6907 UnmapLevelEditorToolboxCustomGadgets();
6909 if (IS_CUSTOM_ELEMENT(properties_element) ||
6910 IS_GROUP_ELEMENT(properties_element))
6911 MapLevelEditorToolboxCustomGadgets();
6913 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
6916 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS1_YPOS,
6917 "Element Settings", FONT_TITLE_1);
6919 DrawElementBorder(SX + xstart * MINI_TILEX,
6920 SY + ystart * MINI_TILEY + MINI_TILEY / 2,
6921 TILEX, TILEY, FALSE);
6922 DrawGraphicAnimationExt(drawto,
6923 SX + xstart * MINI_TILEX,
6924 SY + ystart * MINI_TILEY + MINI_TILEY / 2,
6925 el2img(properties_element), -1, NO_MASKING);
6927 FrameCounter = 0; /* restart animation frame counter */
6929 DrawElementName((xstart + 3) * MINI_TILEX + 1, (ystart + 1) * MINI_TILEY + 1,
6930 properties_element);
6932 DrawPropertiesTabulatorGadgets();
6934 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
6935 DrawPropertiesInfo();
6936 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
6937 DrawPropertiesChange();
6938 else /* (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2]) */
6939 DrawPropertiesConfig();
6942 static void UpdateCustomElementGraphicGadgets()
6946 ModifyEditorElementList();
6947 RedrawDrawingElements();
6949 /* force redraw of all mapped drawing area gadgets */
6950 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
6952 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
6959 static void DrawLineElement(int sx, int sy, int element, boolean change_level)
6961 int lx = sx + level_xpos;
6962 int ly = sy + level_ypos;
6964 DrawMiniElement(sx, sy, (element < 0 ? Feld[lx][ly] : element));
6967 Feld[lx][ly] = element;
6970 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
6971 int element, boolean change_level)
6973 if (from_y == to_y) /* horizontal line */
6979 swap_numbers(&from_x, &to_x);
6981 for (x = from_x; x <= to_x; x++)
6982 DrawLineElement(x, y, element, change_level);
6984 else if (from_x == to_x) /* vertical line */
6990 swap_numbers(&from_y, &to_y);
6992 for (y = from_y; y <= to_y; y++)
6993 DrawLineElement(x, y, element, change_level);
6995 else /* diagonal line */
6997 int len_x = ABS(to_x - from_x);
6998 int len_y = ABS(to_y - from_y);
7001 if (len_y < len_x) /* a < 1 */
7003 float a = (float)len_y / (float)len_x;
7006 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
7008 for (x = 0; x <= len_x; x++)
7010 y = (int)(a * x + 0.5) * (to_y < from_y ? -1 : +1);
7011 DrawLineElement(from_x + x, from_y + y, element, change_level);
7016 float a = (float)len_x / (float)len_y;
7019 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
7021 for (y = 0; y <= len_y; y++)
7023 x = (int)(a * y + 0.5) * (to_x < from_x ? -1 : +1);
7024 DrawLineElement(from_x + x, from_y + y, element, change_level);
7030 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
7031 int element, boolean change_level)
7033 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
7034 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
7035 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
7036 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
7039 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
7040 int element, boolean change_level)
7045 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
7047 for (y = from_y; y <= to_y; y++)
7048 DrawLine(from_x, y, to_x, y, element, change_level);
7051 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
7052 int element, boolean change_level)
7054 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
7055 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
7056 int len_x = ABS(to_x - from_x);
7057 int len_y = ABS(to_y - from_y);
7060 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
7062 /* not optimal (some points get drawn twice) but simple,
7063 and fast enough for the few points we are drawing */
7065 for (x = 0; x <= radius; x++)
7069 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
7071 sx = from_x + x * (from_x < to_x2 ? +1 : -1);
7072 sy = from_y + y * (from_y < to_y2 ? +1 : -1);
7073 lx = sx + level_xpos;
7074 ly = sy + level_ypos;
7076 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
7077 DrawLineElement(sx, sy, element, change_level);
7080 for (y = 0; y <= radius; y++)
7084 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
7086 sx = from_x + x * (from_x < to_x2 ? +1 : -1);
7087 sy = from_y + y * (from_y < to_y2 ? +1 : -1);
7088 lx = sx + level_xpos;
7089 ly = sy + level_ypos;
7091 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
7092 DrawLineElement(sx, sy, element, change_level);
7096 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
7097 int element, boolean change_level)
7099 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
7100 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
7102 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
7105 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
7106 #if DRAW_CIRCLES_BUTTON_AVAILABLE
7107 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
7108 int element, boolean change_level)
7110 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
7111 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
7112 int mirror_to_x2 = from_x - (to_x2 - from_x);
7113 int mirror_to_y2 = from_y - (to_y2 - from_y);
7115 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
7116 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
7117 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
7118 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element,change_level);
7122 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
7124 int from_sx, from_sy;
7128 swap_numbers(&from_x, &to_x);
7131 swap_numbers(&from_y, &to_y);
7133 from_sx = SX + from_x * MINI_TILEX;
7134 from_sy = SY + from_y * MINI_TILEY;
7135 to_sx = SX + to_x * MINI_TILEX + MINI_TILEX - 1;
7136 to_sy = SY + to_y * MINI_TILEY + MINI_TILEY - 1;
7138 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
7139 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
7140 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
7141 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
7143 if (from_x == to_x && from_y == to_y)
7144 MarkTileDirty(from_x/2, from_y/2);
7146 redraw_mask |= REDRAW_FIELD;
7149 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
7150 int element, boolean change_level)
7152 if (element == -1 || change_level)
7153 DrawBox(from_x, from_y, to_x, to_y, -1, FALSE);
7155 DrawAreaBorder(from_x, from_y, to_x, to_y);
7158 /* values for CopyBrushExt() */
7159 #define CB_AREA_TO_BRUSH 0
7160 #define CB_BRUSH_TO_CURSOR 1
7161 #define CB_BRUSH_TO_LEVEL 2
7162 #define CB_DELETE_OLD_CURSOR 3
7163 #define CB_DUMP_BRUSH 4
7165 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
7166 int button, int mode)
7168 static short brush_buffer[MAX_ED_FIELDX][MAX_ED_FIELDY];
7169 static int brush_width, brush_height;
7170 static int last_cursor_x = -1, last_cursor_y = -1;
7171 static boolean delete_old_brush;
7172 int new_element = BUTTON_ELEMENT(button);
7175 if (mode == CB_DUMP_BRUSH)
7177 if (!draw_with_brush)
7179 Error(ERR_WARN, "no brush selected");
7184 for (y = 0; y < brush_height; y++)
7186 for (x = 0; x < brush_width; x++)
7188 int element = brush_buffer[x][y];
7189 int element_mapped = element;
7190 char *element_string = "?";
7193 for (k = 0; forum_sketch_element_mapping[k].element != -1; k++)
7195 if (forum_sketch_element_mapping[k].element == element)
7197 element_mapped = forum_sketch_element_mapping[k].element_mapped;
7202 if (IS_CUSTOM_ELEMENT(element))
7203 element_mapped = EL_CUSTOM_1;
7205 for (k = 0; forum_sketch_element_strings[k].element != -1; k++)
7207 if (forum_sketch_element_strings[k].element == element_mapped)
7209 element_string = forum_sketch_element_strings[k].element_string;
7214 printf("`%s", element_string);
7223 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
7226 if (mode == CB_AREA_TO_BRUSH)
7228 int from_lx, from_ly;
7231 swap_numbers(&from_x, &to_x);
7234 swap_numbers(&from_y, &to_y);
7236 brush_width = to_x - from_x + 1;
7237 brush_height = to_y - from_y + 1;
7239 from_lx = from_x + level_xpos;
7240 from_ly = from_y + level_ypos;
7242 for (y = 0; y < brush_height; y++)
7244 for (x=0; x < brush_width; x++)
7246 brush_buffer[x][y] = Feld[from_lx + x][from_ly + y];
7249 DrawLineElement(from_x + x, from_y + y, new_element, TRUE);
7254 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7256 delete_old_brush = FALSE;
7258 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
7259 mode == CB_BRUSH_TO_LEVEL)
7261 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
7262 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
7263 int cursor_from_x = cursor_x - brush_width / 2;
7264 int cursor_from_y = cursor_y - brush_height / 2;
7265 int border_from_x = cursor_x, border_from_y = cursor_y;
7266 int border_to_x = cursor_x, border_to_y = cursor_y;
7268 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
7269 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
7271 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
7272 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
7274 delete_old_brush = FALSE;
7278 for (y = 0; y < brush_height; y++)
7280 for (x = 0; x < brush_width; x++)
7282 int sx = cursor_from_x + x;
7283 int sy = cursor_from_y + y;
7284 int lx = sx + level_xpos;
7285 int ly = sy + level_ypos;
7286 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
7287 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
7288 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
7289 brush_buffer[x][y] : new_element);
7291 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
7293 if (sx < border_from_x)
7295 else if (sx > border_to_x)
7297 if (sy < border_from_y)
7299 else if (sy > border_to_y)
7302 DrawLineElement(sx, sy, element, change_level);
7307 if (mode != CB_DELETE_OLD_CURSOR)
7308 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
7310 last_cursor_x = cursor_x;
7311 last_cursor_y = cursor_y;
7312 delete_old_brush = TRUE;
7316 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
7319 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
7322 static void CopyBrushToLevel(int x, int y, int button)
7324 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
7327 static void CopyBrushToCursor(int x, int y)
7329 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
7332 static void DeleteBrushFromCursor()
7334 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
7339 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
7342 static void FloodFill(int from_x, int from_y, int fill_element)
7346 static int check[4][2] = { {-1,0}, {0,-1}, {1,0}, {0,1} };
7347 static int safety = 0;
7349 /* check if starting field still has the desired content */
7350 if (Feld[from_x][from_y] == fill_element)
7355 if (safety > lev_fieldx*lev_fieldy)
7356 Error(ERR_EXIT, "Something went wrong in 'FloodFill()'. Please debug.");
7358 old_element = Feld[from_x][from_y];
7359 Feld[from_x][from_y] = fill_element;
7361 for (i = 0; i < 4; i++)
7363 x = from_x + check[i][0];
7364 y = from_y + check[i][1];
7366 if (IN_LEV_FIELD(x,y) && Feld[x][y] == old_element)
7367 FloodFill(x, y, fill_element);
7373 /* values for DrawLevelText() modes */
7375 #define TEXT_SETCURSOR 1
7376 #define TEXT_WRITECHAR 2
7377 #define TEXT_BACKSPACE 3
7378 #define TEXT_NEWLINE 4
7380 #define TEXT_QUERY_TYPING 6
7382 static int DrawLevelText(int sx, int sy, char letter, int mode)
7384 static short delete_buffer[MAX_LEV_FIELDX];
7385 static int start_sx, start_sy;
7386 static int last_sx, last_sy;
7387 static boolean typing = FALSE;
7388 int letter_element = EL_CHAR_ASCII0 + letter;
7391 /* map lower case letters to upper case and convert special characters */
7392 if (letter >= 'a' && letter <= 'z')
7393 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
7394 else if (letter == 'ä' || letter == 'Ä')
7395 letter_element = EL_CHAR_AUMLAUT;
7396 else if (letter == 'ö' || letter == 'Ö')
7397 letter_element = EL_CHAR_OUMLAUT;
7398 else if (letter == 'ü' || letter == 'Ü')
7399 letter_element = EL_CHAR_UUMLAUT;
7400 else if (letter == '^')
7401 letter_element = EL_CHAR_COPYRIGHT;
7403 letter_element = EL_CHAR_ASCII0 + letter;
7405 if (mode != TEXT_INIT)
7410 if (mode != TEXT_SETCURSOR)
7416 lx = last_sx + level_xpos;
7417 ly = last_sy + level_ypos;
7424 DrawLevelText(0, 0, 0, TEXT_END);
7427 start_sx = last_sx = sx;
7428 start_sy = last_sy = sy;
7429 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
7432 case TEXT_SETCURSOR:
7433 DrawMiniElement(last_sx, last_sy, Feld[lx][ly]);
7434 DrawAreaBorder(sx, sy, sx, sy);
7439 case TEXT_WRITECHAR:
7440 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
7442 delete_buffer[sx - start_sx] = Feld[lx][ly];
7443 Feld[lx][ly] = letter_element;
7445 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
7446 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
7447 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
7448 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
7450 DrawLevelText(0, 0, 0, TEXT_END);
7454 case TEXT_BACKSPACE:
7457 Feld[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
7458 DrawMiniElement(sx - 1, sy, Feld[lx - 1][ly]);
7459 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
7464 if (sy + 1 < ed_fieldy - 1 && ly + 1 < lev_fieldy - 1)
7465 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
7467 DrawLevelText(0, 0, 0, TEXT_END);
7471 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7472 DrawMiniElement(sx, sy, Feld[lx][ly]);
7476 case TEXT_QUERY_TYPING:
7486 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
7487 int element, boolean change_level)
7489 int lx = sx + level_xpos;
7490 int ly = sy + level_ypos;
7493 DrawMiniElement(sx, sy, Feld[lx][ly]);
7495 DrawAreaBorder(sx, sy, sx, sy);
7498 static void CopyLevelToUndoBuffer(int mode)
7500 static boolean accumulated_undo = FALSE;
7501 boolean new_undo_buffer_position = TRUE;
7502 int last_border_element;
7507 case UNDO_IMMEDIATE:
7508 accumulated_undo = FALSE;
7511 case UNDO_ACCUMULATE:
7512 if (accumulated_undo)
7513 new_undo_buffer_position = FALSE;
7514 accumulated_undo = TRUE;
7521 if (new_undo_buffer_position)
7523 /* new position in undo buffer ring */
7524 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
7526 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
7527 undo_buffer_steps++;
7530 for (x = 0; x < lev_fieldx; x++)
7531 for (y = 0; y < lev_fieldy; y++)
7532 UndoBuffer[undo_buffer_position][x][y] = Feld[x][y];
7534 /* check if drawing operation forces change of border style */
7535 last_border_element = BorderElement;
7537 if (BorderElement != last_border_element)
7538 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7541 static void RandomPlacement(int new_element)
7543 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
7544 int num_free_positions;
7549 /* determine number of free positions for the new elements */
7550 /* (maybe this statement should be formatted a bit more readable...) */
7551 num_free_positions = 0;
7552 for (x = 0; x < lev_fieldx; x++)
7553 for (y = 0; y < lev_fieldy; y++)
7554 if ((free_position[x][y] =
7555 ((random_placement_background_restricted &&
7556 Feld[x][y] == random_placement_background_element) ||
7557 (!random_placement_background_restricted &&
7558 Feld[x][y] != new_element))) == TRUE)
7559 num_free_positions++;
7561 /* determine number of new elements to place there */
7562 num_percentage = num_free_positions * random_placement_value / 100;
7563 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
7564 num_percentage : random_placement_value);
7566 /* if not more free positions than elements to place, fill whole level */
7567 if (num_elements >= num_free_positions)
7569 for (x = 0; x < lev_fieldx; x++)
7570 for (y = 0; y < lev_fieldy; y++)
7571 Feld[x][y] = new_element;
7573 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7574 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7578 while (num_elements > 0)
7580 x = RND(lev_fieldx);
7581 y = RND(lev_fieldy);
7583 /* don't place element at the same position twice */
7584 if (free_position[x][y])
7586 free_position[x][y] = FALSE;
7587 Feld[x][y] = new_element;
7592 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7593 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7596 void WrapLevel(int dx, int dy)
7598 int wrap_dx = lev_fieldx - dx;
7599 int wrap_dy = lev_fieldy - dy;
7602 for (x = 0; x < lev_fieldx; x++)
7603 for (y = 0; y < lev_fieldy; y++)
7604 FieldBackup[x][y] = Feld[x][y];
7606 for (x = 0; x < lev_fieldx; x++)
7607 for (y = 0; y < lev_fieldy; y++)
7609 FieldBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
7611 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7612 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
7615 static void HandleDrawingAreas(struct GadgetInfo *gi)
7617 static boolean started_inside_drawing_area = FALSE;
7618 int id = gi->custom_id;
7619 boolean button_press_event;
7620 boolean button_release_event;
7621 boolean inside_drawing_area = !gi->event.off_borders;
7622 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
7623 int actual_drawing_function;
7624 int button = gi->event.button;
7625 int new_element = BUTTON_ELEMENT(button);
7626 int sx = gi->event.x, sy = gi->event.y;
7627 int min_sx = 0, min_sy = 0;
7628 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
7629 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
7631 int min_lx = 0, min_ly = 0;
7632 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
7635 /* handle info callback for each invocation of action callback */
7636 gi->callback_info(gi);
7638 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
7639 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
7641 /* make sure to stay inside drawing area boundaries */
7642 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
7643 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
7647 /* get positions inside level field */
7648 lx = sx + level_xpos;
7649 ly = sy + level_ypos;
7651 if (!IN_LEV_FIELD(lx, ly))
7652 inside_drawing_area = FALSE;
7654 /* make sure to stay inside level field boundaries */
7655 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
7656 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
7658 /* correct drawing area positions accordingly */
7659 sx = lx - level_xpos;
7660 sy = ly - level_ypos;
7663 if (button_press_event)
7664 started_inside_drawing_area = inside_drawing_area;
7666 if (!started_inside_drawing_area)
7669 if (!button && !button_release_event)
7672 /* automatically switch to 'single item' drawing mode, if needed */
7673 actual_drawing_function =
7674 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
7675 drawing_function : GADGET_ID_SINGLE_ITEMS);
7677 /* clicking into drawing area with pressed Control key picks element */
7678 if (GetKeyModState() & KMOD_Control)
7680 last_drawing_function = drawing_function;
7681 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
7684 switch (actual_drawing_function)
7686 case GADGET_ID_SINGLE_ITEMS:
7689 if (button_release_event)
7691 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7693 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
7694 !inside_drawing_area)
7695 DeleteBrushFromCursor();
7701 if (draw_with_brush)
7703 if (!button_release_event)
7704 CopyBrushToLevel(sx, sy, button);
7706 else if (new_element != Feld[lx][ly])
7708 if (new_element == EL_PLAYER_1)
7710 /* remove player at old position */
7711 for (y = 0; y < lev_fieldy; y++)
7713 for (x = 0; x < lev_fieldx; x++)
7715 if (Feld[x][y] == EL_PLAYER_1)
7717 Feld[x][y] = EL_EMPTY;
7718 if (x - level_xpos >= 0 && x - level_xpos < ed_fieldx &&
7719 y - level_ypos >= 0 && y - level_ypos < ed_fieldy)
7720 DrawMiniElement(x - level_xpos, y - level_ypos,
7727 Feld[lx][ly] = new_element;
7728 DrawMiniElement(sx, sy, new_element);
7733 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
7734 DrawMiniGraphicExt(drawto,
7735 gi->x + sx * MINI_TILEX,
7736 gi->y + sy * MINI_TILEY,
7737 el2edimg(new_element));
7739 DrawGraphicExt(drawto,
7742 el2img(new_element), 0);
7744 if (id == GADGET_ID_AMOEBA_CONTENT)
7745 level.amoeba_content = new_element;
7746 else if (id == GADGET_ID_CUSTOM_GRAPHIC)
7748 new_element = GFX_ELEMENT(new_element);
7749 custom_element.gfx_element = new_element;
7751 CopyElementPropertiesToGame(properties_element);
7753 UpdateCustomElementGraphicGadgets();
7755 FrameCounter = 0; /* restart animation frame counter */
7757 else if (id == GADGET_ID_CUSTOM_CONTENT)
7759 custom_element.content[sx][sy] = new_element;
7761 CopyCustomElementPropertiesToGame(properties_element);
7763 else if (id == GADGET_ID_CUSTOM_MOVE_ENTER)
7765 custom_element.move_enter_element = new_element;
7767 CopyCustomElementPropertiesToGame(properties_element);
7769 else if (id == GADGET_ID_CUSTOM_MOVE_LEAVE)
7771 custom_element.move_leave_element = new_element;
7773 CopyCustomElementPropertiesToGame(properties_element);
7775 else if (id == GADGET_ID_CUSTOM_CHANGE_TARGET)
7777 custom_element_change.target_element = new_element;
7779 CopyCustomElementPropertiesToGame(properties_element);
7781 else if (id == GADGET_ID_CUSTOM_CHANGE_CONTENT)
7783 custom_element_change.content[sx][sy] = new_element;
7785 CopyCustomElementPropertiesToGame(properties_element);
7787 else if (id == GADGET_ID_CUSTOM_CHANGE_TRIGGER)
7789 custom_element_change.trigger_element = new_element;
7791 CopyCustomElementPropertiesToGame(properties_element);
7793 else if (id == GADGET_ID_GROUP_CONTENT)
7795 group_element_info.element[sx] = new_element;
7797 CopyGroupElementPropertiesToGame(properties_element);
7799 else if (id == GADGET_ID_RANDOM_BACKGROUND)
7800 random_placement_background_element = new_element;
7801 else if (id >= GADGET_ID_ELEMENT_CONTENT_0 &&
7802 id <= GADGET_ID_ELEMENT_CONTENT_7)
7803 level.yamyam_content[id - GADGET_ID_ELEMENT_CONTENT_0][sx][sy] =
7808 case GADGET_ID_CONNECTED_ITEMS:
7810 static int last_sx = -1;
7811 static int last_sy = -1;
7813 if (button_release_event)
7814 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7818 if (!button_press_event)
7819 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
7827 case GADGET_ID_LINE:
7829 case GADGET_ID_RECTANGLE:
7830 case GADGET_ID_FILLED_BOX:
7831 case GADGET_ID_GRAB_BRUSH:
7832 case GADGET_ID_TEXT:
7834 static int last_sx = -1;
7835 static int last_sy = -1;
7836 static int start_sx = -1;
7837 static int start_sy = -1;
7838 void (*draw_func)(int, int, int, int, int, boolean);
7840 if (drawing_function == GADGET_ID_LINE)
7841 draw_func = DrawLine;
7842 else if (drawing_function == GADGET_ID_ARC)
7843 draw_func = DrawArc;
7844 else if (drawing_function == GADGET_ID_RECTANGLE)
7845 draw_func = DrawBox;
7846 else if (drawing_function == GADGET_ID_FILLED_BOX)
7847 draw_func = DrawFilledBox;
7848 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
7849 draw_func = SelectArea;
7850 else /* (drawing_function == GADGET_ID_TEXT) */
7851 draw_func = SetTextCursor;
7853 if (button_press_event)
7855 draw_func(sx, sy, sx, sy, new_element, FALSE);
7856 start_sx = last_sx = sx;
7857 start_sy = last_sy = sy;
7859 if (drawing_function == GADGET_ID_TEXT)
7860 DrawLevelText(0, 0, 0, TEXT_END);
7862 else if (button_release_event)
7864 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
7865 if (drawing_function == GADGET_ID_GRAB_BRUSH)
7867 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
7868 CopyBrushToCursor(sx, sy);
7869 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
7871 draw_with_brush = TRUE;
7873 else if (drawing_function == GADGET_ID_TEXT)
7874 DrawLevelText(sx, sy, 0, TEXT_INIT);
7876 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7878 else if (last_sx != sx || last_sy != sy)
7880 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
7881 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
7888 case GADGET_ID_FLOOD_FILL:
7889 if (button_press_event && Feld[lx][ly] != new_element)
7891 FloodFill(lx, ly, new_element);
7892 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7893 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7897 case GADGET_ID_PICK_ELEMENT:
7898 if (button_release_event)
7899 ClickOnGadget(level_editor_gadget[last_drawing_function],
7901 else if (draw_level)
7902 PickDrawingElement(button, Feld[lx][ly]);
7903 else if (id == GADGET_ID_AMOEBA_CONTENT)
7904 PickDrawingElement(button, level.amoeba_content);
7905 else if (id == GADGET_ID_CUSTOM_GRAPHIC)
7906 PickDrawingElement(button, custom_element.gfx_element);
7907 else if (id == GADGET_ID_CUSTOM_CONTENT)
7908 PickDrawingElement(button, custom_element.content[sx][sy]);
7909 else if (id == GADGET_ID_CUSTOM_MOVE_ENTER)
7910 PickDrawingElement(button, custom_element.move_enter_element);
7911 else if (id == GADGET_ID_CUSTOM_MOVE_LEAVE)
7912 PickDrawingElement(button, custom_element.move_leave_element);
7913 else if (id == GADGET_ID_CUSTOM_CHANGE_TARGET)
7914 PickDrawingElement(button, custom_element_change.target_element);
7915 else if (id == GADGET_ID_CUSTOM_CHANGE_CONTENT)
7916 PickDrawingElement(button, custom_element_change.content[sx][sy]);
7917 else if (id == GADGET_ID_CUSTOM_CHANGE_TRIGGER)
7918 PickDrawingElement(button, custom_element_change.trigger_element);
7919 else if (id == GADGET_ID_GROUP_CONTENT)
7920 PickDrawingElement(button, group_element_info.element[sx]);
7921 else if (id == GADGET_ID_RANDOM_BACKGROUND)
7922 PickDrawingElement(button, random_placement_background_element);
7923 else if (id >= GADGET_ID_ELEMENT_CONTENT_0 &&
7924 id <= GADGET_ID_ELEMENT_CONTENT_7)
7926 int i = id - GADGET_ID_ELEMENT_CONTENT_0;
7928 PickDrawingElement(button, level.yamyam_content[i][sx][sy]);
7938 static void HandleCounterButtons(struct GadgetInfo *gi)
7940 int gadget_id = gi->custom_id;
7941 int counter_id = gi->custom_type_id;
7942 int button = gi->event.button;
7943 int *counter_value = counterbutton_info[counter_id].value;
7944 int step = BUTTON_STEPSIZE(button) *
7945 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
7947 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
7949 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
7950 boolean released = (gi->event.type == GD_EVENT_RELEASED);
7951 boolean level_changed = LevelChanged();
7953 if ((level_changed && pressed) || (!level_changed && released))
7956 if (level_changed && !Request("Level has changed! Discard changes ?",
7959 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
7960 ModifyEditorCounter(counter_id, *counter_value);
7965 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
7966 *counter_value = gi->textinput.number_value;
7968 ModifyEditorCounter(counter_id, *counter_value + step);
7972 case ED_COUNTER_ID_ELEMENT_CONTENT:
7973 DrawElementContentAreas();
7976 case ED_COUNTER_ID_GROUP_CONTENT:
7977 DrawGroupElementArea(properties_element);
7978 CopyGroupElementPropertiesToGame(properties_element);
7981 case ED_COUNTER_ID_ENVELOPE_XSIZE:
7982 case ED_COUNTER_ID_ENVELOPE_YSIZE:
7983 DrawEnvelopeTextArea(-1);
7986 case ED_COUNTER_ID_LEVEL_XSIZE:
7987 case ED_COUNTER_ID_LEVEL_YSIZE:
7988 lev_fieldx = level.fieldx;
7989 lev_fieldy = level.fieldy;
7992 case ED_COUNTER_ID_SELECT_LEVEL:
7993 LoadLevel(level_nr);
7996 DrawEditModeWindow();
8003 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
8004 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
8005 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
8006 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
8007 CopyElementPropertiesToGame(properties_element);
8010 static void HandleTextInputGadgets(struct GadgetInfo *gi)
8012 int type_id = gi->custom_type_id;
8014 strcpy(textinput_info[type_id].value, gi->textinput.value);
8016 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
8018 CopyElementPropertiesToGame(properties_element);
8020 ModifyEditorElementList(); /* update changed button info text */
8024 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
8026 int type_id = gi->custom_type_id;
8028 strcpy(textarea_info[type_id].value, gi->textarea.value);
8031 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
8033 int type_id = gi->custom_type_id;
8035 *selectbox_info[type_id].value =
8036 selectbox_info[type_id].options[gi->selectbox.index].value;
8038 if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
8040 element_info[properties_element].current_change_page = gi->selectbox.index;
8042 DrawPropertiesWindow();
8044 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
8045 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
8046 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
8047 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
8048 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
8049 CopyElementPropertiesToGame(properties_element);
8052 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
8054 int type_id = gi->custom_type_id;
8057 if (type_id >= ED_TEXTBUTTON_ID_PROPERTIES_FIRST &&
8058 type_id <= ED_TEXTBUTTON_ID_PROPERTIES_LAST)
8060 edit_mode_properties = gi->custom_type_id;
8062 DrawPropertiesWindow();
8064 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE)
8066 char *template_filename = getDefaultLevelFilename(-1);
8067 boolean new_template = !fileExists(template_filename);
8070 Request("Save this template and kill the old ?", REQ_ASK))
8071 SaveLevelTemplate();
8074 Request("Template saved !", REQ_CONFIRM);
8076 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
8077 custom_element.num_change_pages < MAX_CHANGE_PAGES)
8079 struct ElementInfo *ei = &element_info[properties_element];
8081 setElementChangePages(ei, ei->num_change_pages + 1);
8083 /* set new change page to be new current change page */
8084 ei->current_change_page = ei->num_change_pages - 1;
8085 ei->change = &ei->change_page[ei->current_change_page];
8087 setElementChangeInfoToDefaults(ei->change);
8089 DrawPropertiesWindow();
8091 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
8092 custom_element.num_change_pages > MIN_CHANGE_PAGES)
8094 struct ElementInfo *ei = &element_info[properties_element];
8096 /* copy all change pages after change page to be deleted */
8097 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
8098 ei->change_page[i] = ei->change_page[i + 1];
8100 setElementChangePages(ei, ei->num_change_pages - 1);
8102 DrawPropertiesWindow();
8106 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
8108 int type_id = gi->custom_type_id;
8110 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
8111 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
8113 struct ElementInfo *ei = &element_info[properties_element];
8114 int step = BUTTON_STEPSIZE(gi->event.button);
8116 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
8117 ei->current_change_page += step;
8119 if (ei->current_change_page < 0)
8120 ei->current_change_page = 0;
8121 else if (ei->current_change_page >= ei->num_change_pages)
8122 ei->current_change_page = ei->num_change_pages - 1;
8124 DrawPropertiesWindow();
8128 static void HandleRadiobuttons(struct GadgetInfo *gi)
8130 *radiobutton_info[gi->custom_type_id].value =
8131 radiobutton_info[gi->custom_type_id].checked_value;
8134 static void HandleCheckbuttons(struct GadgetInfo *gi)
8136 int type_id = gi->custom_type_id;
8138 *checkbutton_info[type_id].value ^= TRUE;
8140 if (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
8141 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
8142 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
8143 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
8144 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE)
8146 CopyElementPropertiesToGame(properties_element);
8149 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
8151 UpdateCustomElementGraphicGadgets();
8153 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE)
8155 char *template_filename = getDefaultLevelFilename(-1);
8157 if (level.use_custom_template && !fileExists(template_filename))
8159 Request("No level template found !", REQ_CONFIRM);
8161 level.use_custom_template = FALSE;
8162 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
8167 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
8169 DrawEditModeWindow();
8173 static void HandleControlButtons(struct GadgetInfo *gi)
8175 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
8176 static int last_edit_mode = ED_MODE_DRAWING;
8177 static int last_custom_copy_mode = -1;
8178 int id = gi->custom_id;
8179 int button = gi->event.button;
8180 int step = BUTTON_STEPSIZE(button);
8181 int new_element = BUTTON_ELEMENT(button);
8184 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
8185 DrawLevelText(0, 0, 0, TEXT_END);
8187 if (id < ED_NUM_CTRL1_BUTTONS &&
8188 id != GADGET_ID_SINGLE_ITEMS &&
8189 id != GADGET_ID_PROPERTIES &&
8190 id != GADGET_ID_PICK_ELEMENT &&
8191 edit_mode != ED_MODE_DRAWING &&
8192 drawing_function != GADGET_ID_PICK_ELEMENT &&
8193 !(GetKeyModState() & KMOD_Control))
8195 DrawDrawingWindow();
8196 edit_mode = ED_MODE_DRAWING;
8199 /* element copy mode active, but no element button pressed => deactivate */
8200 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
8201 last_custom_copy_mode = -1;
8205 case GADGET_ID_SCROLL_LEFT:
8206 if (level_xpos >= 0)
8208 if (lev_fieldx < ed_fieldx - 2)
8212 if (level_xpos < -1)
8215 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
8217 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8219 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
8220 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
8224 case GADGET_ID_SCROLL_RIGHT:
8225 if (level_xpos <= lev_fieldx - ed_fieldx)
8227 if (lev_fieldx < ed_fieldx - 2)
8231 if (level_xpos > lev_fieldx - ed_fieldx + 1)
8232 level_xpos = lev_fieldx - ed_fieldx + 1;
8234 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
8236 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8238 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
8239 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
8243 case GADGET_ID_SCROLL_UP:
8244 if (level_ypos >= 0)
8246 if (lev_fieldy < ed_fieldy - 2)
8250 if (level_ypos < -1)
8253 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
8255 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8257 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
8258 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
8262 case GADGET_ID_SCROLL_DOWN:
8263 if (level_ypos <= lev_fieldy - ed_fieldy)
8265 if (lev_fieldy < ed_fieldy - 2)
8269 if (level_ypos > lev_fieldy - ed_fieldy + 1)
8270 level_ypos = lev_fieldy - ed_fieldy + 1;
8272 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_UP);
8274 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8276 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
8277 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
8281 case GADGET_ID_SCROLL_HORIZONTAL:
8282 level_xpos = gi->event.item_position - 1;
8283 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8286 case GADGET_ID_SCROLL_VERTICAL:
8287 level_ypos = gi->event.item_position - 1;
8288 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8291 case GADGET_ID_SCROLL_LIST_UP:
8292 case GADGET_ID_SCROLL_LIST_DOWN:
8293 case GADGET_ID_SCROLL_LIST_VERTICAL:
8294 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
8295 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
8298 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
8299 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
8301 if (element_shift < 0)
8303 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
8304 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
8306 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
8307 GDI_SCROLLBAR_ITEM_POSITION,
8308 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
8311 ModifyEditorElementList();
8315 case GADGET_ID_WRAP_LEFT:
8316 WrapLevel(-step, 0);
8319 case GADGET_ID_WRAP_RIGHT:
8323 case GADGET_ID_WRAP_UP:
8324 WrapLevel(0, -step);
8327 case GADGET_ID_WRAP_DOWN:
8331 case GADGET_ID_SINGLE_ITEMS:
8332 case GADGET_ID_CONNECTED_ITEMS:
8333 case GADGET_ID_LINE:
8335 case GADGET_ID_TEXT:
8336 case GADGET_ID_RECTANGLE:
8337 case GADGET_ID_FILLED_BOX:
8338 case GADGET_ID_FLOOD_FILL:
8339 case GADGET_ID_GRAB_BRUSH:
8340 case GADGET_ID_PICK_ELEMENT:
8341 if (drawing_function != GADGET_ID_PICK_ELEMENT)
8342 last_drawing_function = drawing_function;
8343 drawing_function = id;
8344 draw_with_brush = FALSE;
8347 case GADGET_ID_RANDOM_PLACEMENT:
8348 RandomPlacement(new_element);
8351 case GADGET_ID_PROPERTIES:
8352 if (edit_mode != ED_MODE_PROPERTIES)
8354 properties_element = new_element;
8355 DrawPropertiesWindow();
8356 edit_mode = ED_MODE_PROPERTIES;
8358 last_level_drawing_function = drawing_function;
8359 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
8364 DrawDrawingWindow();
8365 edit_mode = ED_MODE_DRAWING;
8367 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
8372 case GADGET_ID_CUSTOM_COPY_FROM:
8373 case GADGET_ID_CUSTOM_COPY_TO:
8374 case GADGET_ID_CUSTOM_EXCHANGE:
8375 last_custom_copy_mode = id;
8376 last_drawing_function = drawing_function;
8379 case GADGET_ID_UNDO:
8380 if (undo_buffer_steps == 0)
8382 Request("Undo buffer empty !", REQ_CONFIRM);
8386 if (edit_mode != ED_MODE_DRAWING)
8388 DrawDrawingWindow();
8389 edit_mode = ED_MODE_DRAWING;
8392 undo_buffer_position =
8393 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
8394 undo_buffer_steps--;
8396 for (x = 0; x < lev_fieldx; x++)
8397 for (y = 0; y < lev_fieldy; y++)
8398 Feld[x][y] = UndoBuffer[undo_buffer_position][x][y];
8399 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos,level_ypos);
8402 case GADGET_ID_INFO:
8403 if (edit_mode != ED_MODE_INFO)
8405 last_edit_mode = edit_mode;
8406 edit_mode = ED_MODE_INFO;
8408 DrawLevelInfoWindow();
8412 edit_mode = last_edit_mode;
8414 DrawEditModeWindow();
8418 case GADGET_ID_CLEAR:
8419 if (edit_mode != ED_MODE_DRAWING)
8421 DrawDrawingWindow();
8422 edit_mode = ED_MODE_DRAWING;
8425 for (x = 0; x < MAX_LEV_FIELDX; x++)
8426 for (y = 0; y < MAX_LEV_FIELDY; y++)
8427 Feld[x][y] = (button == 1 ? EL_EMPTY : new_element);
8428 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
8430 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8433 case GADGET_ID_SAVE:
8434 if (leveldir_current->readonly)
8436 Request("This level is read only !", REQ_CONFIRM);
8440 if (!LevelContainsPlayer)
8441 Request("No Level without Gregor Mc Duffin please !", REQ_CONFIRM);
8444 char *level_filename = getDefaultLevelFilename(level_nr);
8445 boolean new_level = !fileExists(level_filename);
8448 Request("Save this level and kill the old ?", REQ_ASK))
8450 CopyPlayfield(Feld, level.field);
8452 SaveLevel(level_nr);
8456 Request("Level saved !", REQ_CONFIRM);
8460 case GADGET_ID_TEST:
8461 if (!LevelContainsPlayer)
8462 Request("No Level without Gregor Mc Duffin please !", REQ_CONFIRM);
8466 level.game_version = GAME_VERSION_ACTUAL;
8468 CopyPlayfield(level.field, FieldBackup);
8469 CopyPlayfield(Feld, level.field);
8471 UnmapLevelEditorGadgets();
8472 UndrawSpecialEditorDoor();
8474 CloseDoor(DOOR_CLOSE_ALL);
8476 DrawCompleteVideoDisplay();
8478 if (setup.autorecord)
8479 TapeStartRecording();
8481 level_editor_test_game = TRUE;
8482 game_status = GAME_MODE_PLAYING;
8488 case GADGET_ID_EXIT:
8489 RequestExitLevelEditor(TRUE); /* if level has changed, ask user */
8493 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
8494 id <= GADGET_ID_ELEMENTLIST_LAST)
8496 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
8497 int new_element = editor_elements[element_position + element_shift];
8499 if (last_custom_copy_mode != -1)
8501 if (CopyCustomElement(properties_element, new_element,
8502 last_custom_copy_mode))
8504 ClickOnGadget(level_editor_gadget[last_drawing_function],
8507 last_custom_copy_mode = -1;
8513 PickDrawingElement(button, new_element);
8515 if (!stick_element_properties_window &&
8516 drawing_function != GADGET_ID_PICK_ELEMENT &&
8517 !(GetKeyModState() & KMOD_Control))
8519 properties_element = new_element;
8520 if (edit_mode == ED_MODE_PROPERTIES)
8521 DrawPropertiesWindow();
8524 if (drawing_function == GADGET_ID_PICK_ELEMENT)
8525 ClickOnGadget(level_editor_gadget[last_drawing_function],
8529 else if (gi->event.type == GD_EVENT_PRESSED)
8530 printf("default: HandleControlButtons: GD_EVENT_PRESSED(%d)\n", id);
8531 else if (gi->event.type == GD_EVENT_RELEASED)
8532 printf("default: HandleControlButtons: GD_EVENT_RELEASED(%d)\n", id);
8533 else if (gi->event.type == GD_EVENT_MOVING)
8534 printf("default: HandleControlButtons: GD_EVENT_MOVING(%d)\n", id);
8536 printf("default: HandleControlButtons: ? (id == %d)\n", id);
8542 void HandleLevelEditorKeyInput(Key key)
8544 char letter = getCharFromKey(key);
8545 int button = MB_LEFTBUTTON;
8547 if (drawing_function == GADGET_ID_TEXT &&
8548 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
8551 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
8552 else if (key == KSYM_Delete || key == KSYM_BackSpace)
8553 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
8554 else if (key == KSYM_Return)
8555 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
8556 else if (key == KSYM_Escape)
8557 DrawLevelText(0, 0, 0, TEXT_END);
8559 else if (button_status == MB_RELEASED)
8561 int i, id = GADGET_ID_NONE;
8566 id = GADGET_ID_SCROLL_LEFT;
8569 id = GADGET_ID_SCROLL_RIGHT;
8572 id = GADGET_ID_SCROLL_UP;
8575 id = GADGET_ID_SCROLL_DOWN;
8578 id = GADGET_ID_SCROLL_LIST_UP;
8579 button = MB_RIGHTBUTTON;
8581 case KSYM_Page_Down:
8582 id = GADGET_ID_SCROLL_LIST_DOWN;
8583 button = MB_RIGHTBUTTON;
8587 if (edit_mode == ED_MODE_DRAWING)
8589 RequestExitLevelEditor(setup.ask_on_escape);
8593 DrawDrawingWindow();
8594 edit_mode = ED_MODE_DRAWING;
8602 if (id != GADGET_ID_NONE)
8603 ClickOnGadget(level_editor_gadget[id], button);
8604 else if (letter == '.')
8605 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
8606 else if (key == KSYM_Return || key == setup.shortcut.toggle_pause)
8607 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
8609 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
8610 if (letter && letter == control_info[i].shortcut)
8611 if (!anyTextGadgetActive())
8612 ClickOnGadget(level_editor_gadget[i], button);
8616 void HandleLevelEditorIdle()
8618 static unsigned long action_delay = 0;
8619 unsigned long action_delay_value = GameFrameDelay;
8620 int xpos = 1, ypos = 2;
8622 if (edit_mode != ED_MODE_PROPERTIES)
8625 if (!DelayReached(&action_delay, action_delay_value))
8628 DrawGraphicAnimationExt(drawto,
8630 SY + ypos * TILEY + MINI_TILEY / 2,
8631 el2img(properties_element), -1, NO_MASKING);
8633 MarkTileDirty(xpos, ypos);
8634 MarkTileDirty(xpos, ypos + 1);
8636 FrameCounter++; /* increase animation frame counter */
8639 void ClearEditorGadgetInfoText()
8641 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
8644 void HandleEditorGadgetInfoText(void *ptr)
8646 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
8647 char infotext[MAX_OUTPUT_LINESIZE + 1];
8648 char shortcut[MAX_OUTPUT_LINESIZE + 1];
8649 int max_infotext_len = getMaxInfoTextLength();
8651 if (game_status != GAME_MODE_EDITOR)
8654 ClearEditorGadgetInfoText();
8656 if (gi->event.type == GD_EVENT_INFO_LEAVING)
8659 /* misuse this function to delete brush cursor, if needed */
8660 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
8661 DeleteBrushFromCursor();
8663 if (gi == NULL || gi->info_text == NULL)
8666 strncpy(infotext, gi->info_text, max_infotext_len);
8667 infotext[max_infotext_len] = '\0';
8669 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
8671 int key = control_info[gi->custom_id].shortcut;
8675 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS) /* special case 1 */
8676 sprintf(shortcut, " ('.' or '%c')", key);
8677 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT) /* special case 2 */
8678 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
8679 else if (gi->custom_id == GADGET_ID_TEST) /* special case 3 */
8680 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
8681 else /* normal case */
8682 sprintf(shortcut, " ('%s%c')",
8683 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
8685 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
8686 strcat(infotext, shortcut);
8690 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, FONT_TEXT_2);
8693 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
8695 static int start_lx, start_ly;
8696 int id = gi->custom_id;
8697 int sx = gi->event.x;
8698 int sy = gi->event.y;
8699 int lx = sx + level_xpos;
8700 int ly = sy + level_ypos;
8701 int min_sx = 0, min_sy = 0;
8702 int max_sx = gi->drawing.area_xsize - 1;
8703 int max_sy = gi->drawing.area_ysize - 1;
8704 int actual_drawing_function = drawing_function;
8705 int max_infotext_len = getMaxInfoTextLength();
8706 char infotext[MAX_OUTPUT_LINESIZE + 1];
8709 infotext[0] = '\0'; /* start with empty info text */
8711 /* pressed Control key: simulate picking element */
8712 if (GetKeyModState() & KMOD_Control)
8713 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
8715 ClearEditorGadgetInfoText();
8717 if (gi->event.type == GD_EVENT_INFO_LEAVING)
8720 /* make sure to stay inside drawing area boundaries */
8721 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
8722 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
8724 if (id == GADGET_ID_DRAWING_LEVEL)
8728 int min_lx = 0, min_ly = 0;
8729 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
8731 /* get positions inside level field */
8732 lx = sx + level_xpos;
8733 ly = sy + level_ypos;
8735 /* make sure to stay inside level field boundaries */
8736 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
8737 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
8739 /* correct drawing area positions accordingly */
8740 sx = lx - level_xpos;
8741 sy = ly - level_ypos;
8744 if (IN_ED_FIELD(sx,sy) && IN_LEV_FIELD(lx, ly))
8746 if (button_status) /* if (gi->state == GD_BUTTON_PRESSED) */
8748 if (gi->event.type == GD_EVENT_PRESSED)
8754 switch (actual_drawing_function)
8756 case GADGET_ID_SINGLE_ITEMS:
8757 text = "Drawing single items";
8759 case GADGET_ID_CONNECTED_ITEMS:
8760 text = "Drawing connected items";
8762 case GADGET_ID_LINE:
8763 text = "Drawing line";
8766 text = "Drawing arc";
8768 case GADGET_ID_TEXT:
8769 text = "Setting text cursor";
8771 case GADGET_ID_RECTANGLE:
8772 text = "Drawing rectangle";
8774 case GADGET_ID_FILLED_BOX:
8775 text = "Drawing filled box";
8777 case GADGET_ID_FLOOD_FILL:
8778 text = "Flood fill";
8780 case GADGET_ID_GRAB_BRUSH:
8781 text = "Grabbing brush";
8783 case GADGET_ID_PICK_ELEMENT:
8784 text = "Picking element";
8788 text = "Drawing position";
8793 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
8794 sprintf(infotext, "%s: %d, %d", text, lx, ly);
8796 sprintf(infotext, "%s: %d, %d", text,
8797 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
8799 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
8800 DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
8801 "%s: %d, %d", infotext, lx, ly);
8803 DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
8804 "%s: %d, %d", infotext,
8805 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
8809 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
8810 strncpy(infotext, getElementInfoText(Feld[lx][ly]), max_infotext_len);
8812 sprintf(infotext, "Level position: %d, %d", lx, ly);
8814 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
8815 DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
8816 "%s", getElementInfoText(Feld[lx][ly]));
8818 DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
8819 "Level position: %d, %d", lx, ly);
8823 /* misuse this function to draw brush cursor, if needed */
8824 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
8826 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
8827 CopyBrushToCursor(sx, sy);
8829 DeleteBrushFromCursor();
8832 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
8834 int element = EL_EMPTY;
8836 if (id == GADGET_ID_AMOEBA_CONTENT)
8837 element = level.amoeba_content;
8838 else if (id == GADGET_ID_CUSTOM_GRAPHIC)
8839 element = custom_element.gfx_element;
8840 else if (id == GADGET_ID_CUSTOM_CONTENT)
8841 element = custom_element.content[sx][sy];
8842 else if (id == GADGET_ID_CUSTOM_MOVE_ENTER)
8843 element = custom_element.move_enter_element;
8844 else if (id == GADGET_ID_CUSTOM_MOVE_LEAVE)
8845 element = custom_element.move_leave_element;
8846 else if (id == GADGET_ID_CUSTOM_CHANGE_TARGET)
8847 element = custom_element_change.target_element;
8848 else if (id == GADGET_ID_CUSTOM_CHANGE_CONTENT)
8849 element = custom_element_change.content[sx][sy];
8850 else if (id == GADGET_ID_CUSTOM_CHANGE_TRIGGER)
8851 element = custom_element_change.trigger_element;
8852 else if (id == GADGET_ID_GROUP_CONTENT)
8853 element = group_element_info.element[sx];
8854 else if (id == GADGET_ID_RANDOM_BACKGROUND)
8855 element = random_placement_background_element;
8856 else if (id >= GADGET_ID_ELEMENT_CONTENT_0 &&
8857 id <= GADGET_ID_ELEMENT_CONTENT_7)
8858 element = level.yamyam_content[id - GADGET_ID_ELEMENT_CONTENT_0][sx][sy];
8860 strncpy(infotext, getElementInfoText(element), max_infotext_len);
8864 if (id == GADGET_ID_AMOEBA_CONTENT)
8865 strcpy(infotext, "Amoeba content");
8866 else if (id == GADGET_ID_CUSTOM_GRAPHIC)
8867 strcpy(infotext, "Custom graphic element");
8868 else if (id == GADGET_ID_CUSTOM_CONTENT)
8869 sprintf(infotext, "Custom element content position: %d, %d", sx, sy);
8870 else if (id == GADGET_ID_CUSTOM_MOVE_ENTER)
8871 strcpy(infotext, "Element that can be digged/collected");
8872 else if (id == GADGET_ID_CUSTOM_MOVE_LEAVE)
8873 strcpy(infotext, "Element that will be left behind");
8874 else if (id == GADGET_ID_CUSTOM_CHANGE_TARGET)
8875 strcpy(infotext, "New element after change");
8876 else if (id == GADGET_ID_CUSTOM_CHANGE_CONTENT)
8877 strcpy(infotext, "New extended elements after change");
8878 else if (id == GADGET_ID_CUSTOM_CHANGE_TRIGGER)
8879 strcpy(infotext, "Other element triggering change");
8880 else if (id == GADGET_ID_GROUP_CONTENT)
8881 sprintf(infotext, "Group element position: %d", sx + 1);
8882 else if (id == GADGET_ID_RANDOM_BACKGROUND)
8883 strcpy(infotext, "Random placement background");
8884 else if (id >= GADGET_ID_ELEMENT_CONTENT_0 &&
8885 id <= GADGET_ID_ELEMENT_CONTENT_7)
8886 sprintf(infotext, "Content area %d position: %d, %d",
8887 id - GADGET_ID_ELEMENT_CONTENT_0 + 1, sx, sy);
8890 infotext[max_infotext_len] = '\0';
8892 if (strlen(infotext) > 0)
8893 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, infotext);
8896 void RequestExitLevelEditor(boolean ask_if_level_has_changed)
8898 if (!ask_if_level_has_changed ||
8900 Request("Level has changed! Exit without saving ?",
8901 REQ_ASK | REQ_STAY_OPEN))
8904 CloseDoor(DOOR_CLOSE_1);
8905 SetDoorState(DOOR_CLOSE_2);
8907 CloseDoor(DOOR_CLOSE_ALL);
8909 game_status = GAME_MODE_MAIN;
8914 CloseDoor(DOOR_CLOSE_1);
8915 BlitBitmap(bitmap_db_door, bitmap_db_door,
8916 DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1, DXSIZE,DYSIZE,
8917 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
8918 OpenDoor(DOOR_OPEN_1);