1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-2006 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_CTRL4_BUTTONS_GFX_XPOS 44
51 #define ED_CTRL4_BUTTONS_GFX_YPOS 214
52 #define ED_CTRL1_BUTTONS_ALT_GFX_YPOS 142
53 #define ED_CTRL3_BUTTONS_ALT_GFX_YPOS 302
55 #define ED_CTRL1_BUTTON_XSIZE 22
56 #define ED_CTRL1_BUTTON_YSIZE 22
57 #define ED_CTRL1_BUTTONS_XPOS 6
58 #define ED_CTRL1_BUTTONS_YPOS 6
59 #define ED_CTRL2_BUTTON_XSIZE 30
60 #define ED_CTRL2_BUTTON_YSIZE 20
61 #define ED_CTRL2_BUTTONS_XPOS 5
62 #define ED_CTRL2_BUTTONS_YPOS 99
63 #define ED_CTRL3_BUTTON_XSIZE 22
64 #define ED_CTRL3_BUTTON_YSIZE 22
65 #define ED_CTRL3_BUTTONS_XPOS 6
66 #define ED_CTRL3_BUTTONS_YPOS 6
67 #define ED_CTRL4_BUTTON_XSIZE 22
68 #define ED_CTRL4_BUTTON_YSIZE 22
69 #define ED_CTRL4_BUTTONS_XPOS 6
70 #define ED_CTRL4_BUTTONS_YPOS 6
72 #define ED_CTRL1_BUTTONS_HORIZ 4
73 #define ED_CTRL1_BUTTONS_VERT 4
74 #define ED_CTRL2_BUTTONS_HORIZ 3
75 #define ED_CTRL2_BUTTONS_VERT 2
76 #define ED_CTRL3_BUTTONS_HORIZ 3
77 #define ED_CTRL3_BUTTONS_VERT 1
78 #define ED_CTRL4_BUTTONS_HORIZ 2
79 #define ED_CTRL4_BUTTONS_VERT 1
81 #define ED_NUM_CTRL1_BUTTONS (ED_CTRL1_BUTTONS_HORIZ * ED_CTRL1_BUTTONS_VERT)
82 #define ED_NUM_CTRL2_BUTTONS (ED_CTRL2_BUTTONS_HORIZ * ED_CTRL2_BUTTONS_VERT)
83 #define ED_NUM_CTRL3_BUTTONS (ED_CTRL3_BUTTONS_HORIZ * ED_CTRL3_BUTTONS_VERT)
84 #define ED_NUM_CTRL4_BUTTONS (ED_CTRL4_BUTTONS_HORIZ * ED_CTRL4_BUTTONS_VERT)
85 #define ED_NUM_CTRL1_2_BUTTONS (ED_NUM_CTRL1_BUTTONS + ED_NUM_CTRL2_BUTTONS)
86 #define ED_NUM_CTRL1_3_BUTTONS (ED_NUM_CTRL1_2_BUTTONS + ED_NUM_CTRL3_BUTTONS)
87 #define ED_NUM_CTRL_BUTTONS (ED_NUM_CTRL1_BUTTONS + \
88 ED_NUM_CTRL2_BUTTONS + \
89 ED_NUM_CTRL3_BUTTONS + \
92 /* values for the element list */
93 #define ED_ELEMENTLIST_XPOS 5
94 #define ED_ELEMENTLIST_YPOS 30
95 #define ED_ELEMENTLIST_XSIZE 20
96 #define ED_ELEMENTLIST_YSIZE 20
97 #define ED_ELEMENTLIST_BUTTONS_HORIZ 4
98 #define ED_ELEMENTLIST_BUTTONS_VERT 11
99 #define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \
100 ED_ELEMENTLIST_BUTTONS_VERT)
102 /* standard distances */
103 #define ED_BORDER_SIZE 3
104 #define ED_BORDER_TEXT_XSIZE 5
105 #define ED_BORDER_AREA_YSIZE 1
107 #define ED_GADGET_DISTANCE 2
108 #define ED_GADGET_TEXT_DISTANCE (2 * ED_GADGET_DISTANCE)
109 #define ED_DRAWINGAREA_TEXT_DISTANCE (ED_GADGET_TEXT_DISTANCE + \
112 /* values for the settings windows */
113 #define ED_LEVEL_SETTINGS_XSTART (3 * MINI_TILEX / 2)
114 #define ED_LEVEL_SETTINGS_YSTART (5 * MINI_TILEY)
116 #define ED_ELEMENT_SETTINGS_XSTART (3 * MINI_TILEX / 2)
117 #define ED_ELEMENT_SETTINGS_YSTART (10 * MINI_TILEY)
119 #define ED_XOFFSET_CHECKBOX (ED_CHECKBUTTON_XSIZE + \
120 2 * ED_GADGET_DISTANCE)
122 #define ED_SETTINGS_XOFFSET ED_XOFFSET_CHECKBOX
123 #define ED_SETTINGS_YOFFSET (3 * MINI_TILEY / 2)
125 #define ED_LEVEL_SETTINGS_XPOS(n) (ED_LEVEL_SETTINGS_XSTART + \
126 (n) * ED_SETTINGS_XOFFSET)
127 #define ED_LEVEL_SETTINGS_YPOS(n) (ED_LEVEL_SETTINGS_YSTART + \
128 (n) * ED_SETTINGS_YOFFSET)
130 #define ED_ELEMENT_SETTINGS_XPOS(n) (ED_ELEMENT_SETTINGS_XSTART + \
131 (n) * ED_SETTINGS_XOFFSET)
132 #define ED_ELEMENT_SETTINGS_YPOS(n) (ED_ELEMENT_SETTINGS_YSTART + \
133 (n) * ED_SETTINGS_YOFFSET)
135 #define ED_SETTINGS1_YPOS MINI_TILEY
136 #define ED_SETTINGS2_XPOS MINI_TILEX
137 #define ED_SETTINGS2_YPOS (ED_SETTINGS1_YPOS + 12 * TILEY - 2)
139 /* values for counter gadgets */
140 #define ED_COUNTER_YSTART (ED_SETTINGS1_YPOS + 2 * TILEY)
141 #define ED_COUNTER_YDISTANCE (3 * MINI_TILEY)
142 #define ED_COUNTER_YPOS(n) (ED_COUNTER_YSTART + \
143 (n) * ED_COUNTER_YDISTANCE)
144 #define ED_COUNTER2_YPOS(n) (ED_COUNTER_YSTART + \
145 (n) * ED_COUNTER_YDISTANCE - 2)
147 /* values for element content drawing areas */
148 #define ED_AREA_1X1_SETTINGS_XPOS(n) (ED_ELEMENT_SETTINGS_XPOS(n))
149 #define ED_AREA_1X1_SETTINGS_YPOS(n) (ED_ELEMENT_SETTINGS_YPOS(n) + \
152 #define ED_AREA_3X3_SETTINGS_XPOS(n) (ED_ELEMENT_SETTINGS_XPOS(n))
153 #define ED_AREA_3X3_SETTINGS_YPOS(n) (ED_ELEMENT_SETTINGS_YPOS(n) + \
154 ED_GADGET_DISTANCE - MINI_TILEY)
157 #define ED_AREA_YAMYAM_CONTENT_XPOS(n) (2 * MINI_TILEX + \
158 5 * ((n) % 4) * MINI_TILEX)
159 #define ED_AREA_YAMYAM_CONTENT_YPOS(n) (11 * ED_SETTINGS_YOFFSET + \
160 6 * ((n) / 4) * MINI_TILEY)
162 /* magic ball content */
163 #define ED_AREA_MAGIC_BALL_CONTENT_XPOS(n) (2 * MINI_TILEX + \
164 5 * ((n) % 4) * MINI_TILEX)
165 #define ED_AREA_MAGIC_BALL_CONTENT_YPOS(n) (12 * ED_SETTINGS_YOFFSET + \
166 6 * ((n) / 4) * MINI_TILEY)
168 /* values for scrolling gadgets for drawing area */
169 #define ED_SCROLLBUTTON_XPOS 24
170 #define ED_SCROLLBUTTON_YPOS 0
171 #define ED_SCROLLBAR_XPOS 24
172 #define ED_SCROLLBAR_YPOS 64
174 #define ED_SCROLLBUTTON_XSIZE 16
175 #define ED_SCROLLBUTTON_YSIZE 16
177 #define ED_SCROLL_UP_XPOS (SXSIZE - ED_SCROLLBUTTON_XSIZE)
178 #define ED_SCROLL_UP_YPOS (0)
179 #define ED_SCROLL_DOWN_XPOS ED_SCROLL_UP_XPOS
180 #define ED_SCROLL_DOWN_YPOS (SYSIZE - 3 * ED_SCROLLBUTTON_YSIZE)
181 #define ED_SCROLL_LEFT_XPOS (0)
182 #define ED_SCROLL_LEFT_YPOS (SYSIZE - 2 * ED_SCROLLBUTTON_YSIZE)
183 #define ED_SCROLL_RIGHT_XPOS (SXSIZE - 2 * ED_SCROLLBUTTON_XSIZE)
184 #define ED_SCROLL_RIGHT_YPOS ED_SCROLL_LEFT_YPOS
185 #define ED_SCROLL_HORIZONTAL_XPOS (ED_SCROLL_LEFT_XPOS + \
186 ED_SCROLLBUTTON_XSIZE)
187 #define ED_SCROLL_HORIZONTAL_YPOS ED_SCROLL_LEFT_YPOS
188 #define ED_SCROLL_HORIZONTAL_XSIZE (SXSIZE - 3 * ED_SCROLLBUTTON_XSIZE)
189 #define ED_SCROLL_HORIZONTAL_YSIZE ED_SCROLLBUTTON_YSIZE
190 #define ED_SCROLL_VERTICAL_XPOS ED_SCROLL_UP_XPOS
191 #define ED_SCROLL_VERTICAL_YPOS (ED_SCROLL_UP_YPOS + \
192 ED_SCROLLBUTTON_YSIZE)
193 #define ED_SCROLL_VERTICAL_XSIZE ED_SCROLLBUTTON_XSIZE
194 #define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - 4 * ED_SCROLLBUTTON_YSIZE)
196 /* values for scrolling gadgets for element list */
197 #define ED_SCROLLBUTTON2_XPOS 50
198 #define ED_SCROLLBUTTON2_YPOS 0
199 #define ED_SCROLLBAR2_XPOS 50
200 #define ED_SCROLLBAR2_YPOS 20
202 #define ED_SCROLLBUTTON2_XSIZE 10
203 #define ED_SCROLLBUTTON2_YSIZE 10
205 #define ED_SCROLL2_UP_XPOS 85
206 #define ED_SCROLL2_UP_YPOS 30
207 #define ED_SCROLL2_DOWN_XPOS ED_SCROLL2_UP_XPOS
208 #define ED_SCROLL2_DOWN_YPOS (ED_SCROLL2_UP_YPOS + \
209 ED_ELEMENTLIST_BUTTONS_VERT * \
210 ED_ELEMENTLIST_YSIZE - \
211 ED_SCROLLBUTTON2_YSIZE)
212 #define ED_SCROLL2_VERTICAL_XPOS ED_SCROLL2_UP_XPOS
213 #define ED_SCROLL2_VERTICAL_YPOS (ED_SCROLL2_UP_YPOS + \
214 ED_SCROLLBUTTON2_YSIZE)
215 #define ED_SCROLL2_VERTICAL_XSIZE ED_SCROLLBUTTON2_XSIZE
216 #define ED_SCROLL2_VERTICAL_YSIZE (ED_ELEMENTLIST_BUTTONS_VERT * \
217 ED_ELEMENTLIST_YSIZE - \
218 2 * ED_SCROLLBUTTON2_YSIZE)
220 /* values for checkbutton gadgets */
221 #define ED_CHECKBUTTON_XSIZE ED_BUTTON_COUNT_XSIZE
222 #define ED_CHECKBUTTON_YSIZE ED_BUTTON_COUNT_YSIZE
223 #define ED_CHECKBUTTON_UNCHECKED_XPOS ED_BUTTON_MINUS_XPOS
224 #define ED_CHECKBUTTON_CHECKED_XPOS ED_BUTTON_PLUS_XPOS
225 #define ED_CHECKBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 22)
226 #define ED_RADIOBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 44)
227 #define ED_STICKYBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 66)
229 /* values for some special graphic buttons */
230 #define ED_COPY_CHANGE_PAGE_XPOS 25
231 #define ED_COPY_CHANGE_PAGE_YPOS 50
232 #define ED_PASTE_CHANGE_PAGE_XPOS 25
233 #define ED_PASTE_CHANGE_PAGE_YPOS 70
235 /* some values for text input, selectbox and counter gadgets */
236 #define ED_BUTTON_COUNT_YPOS 60
237 #define ED_BUTTON_COUNT_XSIZE 20
238 #define ED_BUTTON_COUNT_YSIZE 20
239 #define ED_WIN_COUNT_XPOS (2 + ED_BUTTON_COUNT_XSIZE + 2)
240 #define ED_WIN_COUNT_YPOS ED_BUTTON_COUNT_YPOS
241 #define ED_WIN_COUNT_XSIZE 52
242 #define ED_WIN_COUNT_YSIZE ED_BUTTON_COUNT_YSIZE
243 #define ED_WIN_COUNT2_XPOS 27
244 #define ED_WIN_COUNT2_YPOS 3
245 #define ED_WIN_COUNT2_XSIZE 46
246 #define ED_WIN_COUNT2_YSIZE ED_BUTTON_COUNT_YSIZE
248 #define ED_BUTTON_MINUS_XPOS 2
249 #define ED_BUTTON_MINUS_YPOS ED_BUTTON_COUNT_YPOS
250 #define ED_BUTTON_MINUS_XSIZE ED_BUTTON_COUNT_XSIZE
251 #define ED_BUTTON_MINUS_YSIZE ED_BUTTON_COUNT_YSIZE
252 #define ED_BUTTON_PLUS_XPOS (ED_WIN_COUNT_XPOS + \
253 ED_WIN_COUNT_XSIZE + 2)
254 #define ED_BUTTON_PLUS_YPOS ED_BUTTON_COUNT_YPOS
255 #define ED_BUTTON_PLUS_XSIZE ED_BUTTON_COUNT_XSIZE
256 #define ED_BUTTON_PLUS_YSIZE ED_BUTTON_COUNT_YSIZE
258 #define ED_SELECTBOX_XPOS ED_WIN_COUNT_XPOS
259 #define ED_SELECTBOX_YPOS (ED_WIN_COUNT_YPOS + \
260 2 + ED_WIN_COUNT_YSIZE)
261 #define ED_SELECTBOX_XSIZE ED_WIN_COUNT_XSIZE
262 #define ED_SELECTBOX_YSIZE ED_WIN_COUNT_YSIZE
264 #define ED_SELECTBOX_BUTTON_XSIZE 14
266 #define ED_TEXTBUTTON_XPOS ED_WIN_COUNT_XPOS
267 #define ED_TEXTBUTTON_YPOS (ED_WIN_COUNT_YPOS + \
268 4 * (2 + ED_WIN_COUNT_YSIZE))
269 #define ED_TEXTBUTTON_INACTIVE_YPOS ED_TEXTBUTTON_YPOS
271 #define ED_TEXTBUTTON_TAB_XPOS ED_WIN_COUNT_XPOS
272 #define ED_TEXTBUTTON_TAB_YPOS (ED_WIN_COUNT_YPOS + \
273 2 * (2 + ED_WIN_COUNT_YSIZE))
274 #define ED_TEXTBUTTON_TAB_INACTIVE_YPOS (ED_WIN_COUNT_YPOS + \
275 3 * (2 + ED_WIN_COUNT_YSIZE))
277 #define ED_TEXTBUTTON_XSIZE ED_WIN_COUNT_XSIZE
278 #define ED_TEXTBUTTON_YSIZE ED_WIN_COUNT_YSIZE
280 /* values for ClearEditorGadgetInfoText() and HandleEditorGadgetInfoText() */
281 #define INFOTEXT_XPOS SX
282 #define INFOTEXT_YPOS (SY + SYSIZE - MINI_TILEX + 2)
283 #define INFOTEXT_XSIZE SXSIZE
284 #define INFOTEXT_YSIZE MINI_TILEX
288 -----------------------------------------------------------------------------
289 editor gadget definitions
290 -----------------------------------------------------------------------------
293 /* drawing toolbox buttons */
294 #define GADGET_ID_NONE -1
295 #define GADGET_ID_TOOLBOX_FIRST 0
297 #define GADGET_ID_SINGLE_ITEMS (GADGET_ID_TOOLBOX_FIRST + 0)
298 #define GADGET_ID_CONNECTED_ITEMS (GADGET_ID_TOOLBOX_FIRST + 1)
299 #define GADGET_ID_LINE (GADGET_ID_TOOLBOX_FIRST + 2)
300 #define GADGET_ID_ARC (GADGET_ID_TOOLBOX_FIRST + 3)
301 #define GADGET_ID_RECTANGLE (GADGET_ID_TOOLBOX_FIRST + 4)
302 #define GADGET_ID_FILLED_BOX (GADGET_ID_TOOLBOX_FIRST + 5)
303 #define GADGET_ID_WRAP_UP (GADGET_ID_TOOLBOX_FIRST + 6)
304 #define GADGET_ID_TEXT (GADGET_ID_TOOLBOX_FIRST + 7)
305 #define GADGET_ID_FLOOD_FILL (GADGET_ID_TOOLBOX_FIRST + 8)
306 #define GADGET_ID_WRAP_LEFT (GADGET_ID_TOOLBOX_FIRST + 9)
307 #define GADGET_ID_PROPERTIES (GADGET_ID_TOOLBOX_FIRST + 10)
308 #define GADGET_ID_WRAP_RIGHT (GADGET_ID_TOOLBOX_FIRST + 11)
309 #define GADGET_ID_RANDOM_PLACEMENT (GADGET_ID_TOOLBOX_FIRST + 12)
310 #define GADGET_ID_GRAB_BRUSH (GADGET_ID_TOOLBOX_FIRST + 13)
311 #define GADGET_ID_WRAP_DOWN (GADGET_ID_TOOLBOX_FIRST + 14)
312 #define GADGET_ID_PICK_ELEMENT (GADGET_ID_TOOLBOX_FIRST + 15)
314 #define GADGET_ID_UNDO (GADGET_ID_TOOLBOX_FIRST + 16)
315 #define GADGET_ID_INFO (GADGET_ID_TOOLBOX_FIRST + 17)
316 #define GADGET_ID_SAVE (GADGET_ID_TOOLBOX_FIRST + 18)
317 #define GADGET_ID_CLEAR (GADGET_ID_TOOLBOX_FIRST + 19)
318 #define GADGET_ID_TEST (GADGET_ID_TOOLBOX_FIRST + 20)
319 #define GADGET_ID_EXIT (GADGET_ID_TOOLBOX_FIRST + 21)
321 #define GADGET_ID_CUSTOM_COPY_FROM (GADGET_ID_TOOLBOX_FIRST + 22)
322 #define GADGET_ID_CUSTOM_COPY_TO (GADGET_ID_TOOLBOX_FIRST + 23)
323 #define GADGET_ID_CUSTOM_EXCHANGE (GADGET_ID_TOOLBOX_FIRST + 24)
324 #define GADGET_ID_CUSTOM_COPY (GADGET_ID_TOOLBOX_FIRST + 25)
325 #define GADGET_ID_CUSTOM_PASTE (GADGET_ID_TOOLBOX_FIRST + 26)
327 /* counter gadget identifiers */
328 #define GADGET_ID_COUNTER_FIRST (GADGET_ID_TOOLBOX_FIRST + 27)
330 #define GADGET_ID_SELECT_LEVEL_DOWN (GADGET_ID_COUNTER_FIRST + 0)
331 #define GADGET_ID_SELECT_LEVEL_TEXT (GADGET_ID_COUNTER_FIRST + 1)
332 #define GADGET_ID_SELECT_LEVEL_UP (GADGET_ID_COUNTER_FIRST + 2)
333 #define GADGET_ID_LEVEL_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 3)
334 #define GADGET_ID_LEVEL_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 4)
335 #define GADGET_ID_LEVEL_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 5)
336 #define GADGET_ID_LEVEL_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 6)
337 #define GADGET_ID_LEVEL_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 7)
338 #define GADGET_ID_LEVEL_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 8)
339 #define GADGET_ID_LEVEL_RANDOM_DOWN (GADGET_ID_COUNTER_FIRST + 9)
340 #define GADGET_ID_LEVEL_RANDOM_TEXT (GADGET_ID_COUNTER_FIRST + 10)
341 #define GADGET_ID_LEVEL_RANDOM_UP (GADGET_ID_COUNTER_FIRST + 11)
342 #define GADGET_ID_LEVEL_GEMSLIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 12)
343 #define GADGET_ID_LEVEL_GEMSLIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 13)
344 #define GADGET_ID_LEVEL_GEMSLIMIT_UP (GADGET_ID_COUNTER_FIRST + 14)
345 #define GADGET_ID_LEVEL_TIMELIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 15)
346 #define GADGET_ID_LEVEL_TIMELIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 16)
347 #define GADGET_ID_LEVEL_TIMELIMIT_UP (GADGET_ID_COUNTER_FIRST + 17)
348 #define GADGET_ID_LEVEL_TIMESCORE_DOWN (GADGET_ID_COUNTER_FIRST + 18)
349 #define GADGET_ID_LEVEL_TIMESCORE_TEXT (GADGET_ID_COUNTER_FIRST + 19)
350 #define GADGET_ID_LEVEL_TIMESCORE_UP (GADGET_ID_COUNTER_FIRST + 20)
351 #define GADGET_ID_ELEMENT_VALUE1_DOWN (GADGET_ID_COUNTER_FIRST + 21)
352 #define GADGET_ID_ELEMENT_VALUE1_TEXT (GADGET_ID_COUNTER_FIRST + 22)
353 #define GADGET_ID_ELEMENT_VALUE1_UP (GADGET_ID_COUNTER_FIRST + 23)
354 #define GADGET_ID_ELEMENT_VALUE2_DOWN (GADGET_ID_COUNTER_FIRST + 24)
355 #define GADGET_ID_ELEMENT_VALUE2_TEXT (GADGET_ID_COUNTER_FIRST + 25)
356 #define GADGET_ID_ELEMENT_VALUE2_UP (GADGET_ID_COUNTER_FIRST + 26)
357 #define GADGET_ID_ELEMENT_VALUE3_DOWN (GADGET_ID_COUNTER_FIRST + 27)
358 #define GADGET_ID_ELEMENT_VALUE3_TEXT (GADGET_ID_COUNTER_FIRST + 28)
359 #define GADGET_ID_ELEMENT_VALUE3_UP (GADGET_ID_COUNTER_FIRST + 29)
360 #define GADGET_ID_ELEMENT_VALUE4_DOWN (GADGET_ID_COUNTER_FIRST + 30)
361 #define GADGET_ID_ELEMENT_VALUE4_TEXT (GADGET_ID_COUNTER_FIRST + 31)
362 #define GADGET_ID_ELEMENT_VALUE4_UP (GADGET_ID_COUNTER_FIRST + 32)
363 #define GADGET_ID_YAMYAM_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 33)
364 #define GADGET_ID_YAMYAM_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 34)
365 #define GADGET_ID_YAMYAM_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 35)
366 #define GADGET_ID_BALL_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 36)
367 #define GADGET_ID_BALL_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 37)
368 #define GADGET_ID_BALL_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 38)
369 #define GADGET_ID_ANDROID_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 39)
370 #define GADGET_ID_ANDROID_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 40)
371 #define GADGET_ID_ANDROID_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 41)
372 #define GADGET_ID_ENVELOPE_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 42)
373 #define GADGET_ID_ENVELOPE_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 43)
374 #define GADGET_ID_ENVELOPE_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 44)
375 #define GADGET_ID_ENVELOPE_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 45)
376 #define GADGET_ID_ENVELOPE_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 46)
377 #define GADGET_ID_ENVELOPE_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 47)
378 #define GADGET_ID_CUSTOM_SCORE_DOWN (GADGET_ID_COUNTER_FIRST + 48)
379 #define GADGET_ID_CUSTOM_SCORE_TEXT (GADGET_ID_COUNTER_FIRST + 49)
380 #define GADGET_ID_CUSTOM_SCORE_UP (GADGET_ID_COUNTER_FIRST + 50)
381 #define GADGET_ID_CUSTOM_GEMCOUNT_DOWN (GADGET_ID_COUNTER_FIRST + 51)
382 #define GADGET_ID_CUSTOM_GEMCOUNT_TEXT (GADGET_ID_COUNTER_FIRST + 52)
383 #define GADGET_ID_CUSTOM_GEMCOUNT_UP (GADGET_ID_COUNTER_FIRST + 53)
384 #define GADGET_ID_CUSTOM_VALUE_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 54)
385 #define GADGET_ID_CUSTOM_VALUE_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 55)
386 #define GADGET_ID_CUSTOM_VALUE_FIX_UP (GADGET_ID_COUNTER_FIRST + 56)
387 #define GADGET_ID_CUSTOM_VALUE_RND_DOWN (GADGET_ID_COUNTER_FIRST + 57)
388 #define GADGET_ID_CUSTOM_VALUE_RND_TEXT (GADGET_ID_COUNTER_FIRST + 58)
389 #define GADGET_ID_CUSTOM_VALUE_RND_UP (GADGET_ID_COUNTER_FIRST + 59)
390 #define GADGET_ID_PUSH_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 60)
391 #define GADGET_ID_PUSH_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 61)
392 #define GADGET_ID_PUSH_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 62)
393 #define GADGET_ID_PUSH_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 63)
394 #define GADGET_ID_PUSH_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 64)
395 #define GADGET_ID_PUSH_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 65)
396 #define GADGET_ID_DROP_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 66)
397 #define GADGET_ID_DROP_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 67)
398 #define GADGET_ID_DROP_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 68)
399 #define GADGET_ID_DROP_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 69)
400 #define GADGET_ID_DROP_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 70)
401 #define GADGET_ID_DROP_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 71)
402 #define GADGET_ID_MOVE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 72)
403 #define GADGET_ID_MOVE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 73)
404 #define GADGET_ID_MOVE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 74)
405 #define GADGET_ID_MOVE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 75)
406 #define GADGET_ID_MOVE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 76)
407 #define GADGET_ID_MOVE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 77)
408 #define GADGET_ID_EXPLOSION_DELAY_DOWN (GADGET_ID_COUNTER_FIRST + 78)
409 #define GADGET_ID_EXPLOSION_DELAY_TEXT (GADGET_ID_COUNTER_FIRST + 79)
410 #define GADGET_ID_EXPLOSION_DELAY_UP (GADGET_ID_COUNTER_FIRST + 80)
411 #define GADGET_ID_IGNITION_DELAY_DOWN (GADGET_ID_COUNTER_FIRST + 81)
412 #define GADGET_ID_IGNITION_DELAY_TEXT (GADGET_ID_COUNTER_FIRST + 82)
413 #define GADGET_ID_IGNITION_DELAY_UP (GADGET_ID_COUNTER_FIRST + 83)
414 #define GADGET_ID_CHANGE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 84)
415 #define GADGET_ID_CHANGE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 85)
416 #define GADGET_ID_CHANGE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 86)
417 #define GADGET_ID_CHANGE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 87)
418 #define GADGET_ID_CHANGE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 88)
419 #define GADGET_ID_CHANGE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 89)
420 #define GADGET_ID_CHANGE_CONT_RND_DOWN (GADGET_ID_COUNTER_FIRST + 90)
421 #define GADGET_ID_CHANGE_CONT_RND_TEXT (GADGET_ID_COUNTER_FIRST + 91)
422 #define GADGET_ID_CHANGE_CONT_RND_UP (GADGET_ID_COUNTER_FIRST + 92)
423 #define GADGET_ID_GROUP_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 93)
424 #define GADGET_ID_GROUP_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 94)
425 #define GADGET_ID_GROUP_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 95)
427 /* drawing area identifiers */
428 #define GADGET_ID_DRAWING_AREA_FIRST (GADGET_ID_COUNTER_FIRST + 96)
430 #define GADGET_ID_DRAWING_LEVEL (GADGET_ID_DRAWING_AREA_FIRST + 0)
431 #define GADGET_ID_YAMYAM_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 1)
432 #define GADGET_ID_YAMYAM_CONTENT_1 (GADGET_ID_DRAWING_AREA_FIRST + 2)
433 #define GADGET_ID_YAMYAM_CONTENT_2 (GADGET_ID_DRAWING_AREA_FIRST + 3)
434 #define GADGET_ID_YAMYAM_CONTENT_3 (GADGET_ID_DRAWING_AREA_FIRST + 4)
435 #define GADGET_ID_YAMYAM_CONTENT_4 (GADGET_ID_DRAWING_AREA_FIRST + 5)
436 #define GADGET_ID_YAMYAM_CONTENT_5 (GADGET_ID_DRAWING_AREA_FIRST + 6)
437 #define GADGET_ID_YAMYAM_CONTENT_6 (GADGET_ID_DRAWING_AREA_FIRST + 7)
438 #define GADGET_ID_YAMYAM_CONTENT_7 (GADGET_ID_DRAWING_AREA_FIRST + 8)
439 #define GADGET_ID_MAGIC_BALL_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 9)
440 #define GADGET_ID_MAGIC_BALL_CONTENT_1 (GADGET_ID_DRAWING_AREA_FIRST + 10)
441 #define GADGET_ID_MAGIC_BALL_CONTENT_2 (GADGET_ID_DRAWING_AREA_FIRST + 11)
442 #define GADGET_ID_MAGIC_BALL_CONTENT_3 (GADGET_ID_DRAWING_AREA_FIRST + 12)
443 #define GADGET_ID_MAGIC_BALL_CONTENT_4 (GADGET_ID_DRAWING_AREA_FIRST + 13)
444 #define GADGET_ID_MAGIC_BALL_CONTENT_5 (GADGET_ID_DRAWING_AREA_FIRST + 14)
445 #define GADGET_ID_MAGIC_BALL_CONTENT_6 (GADGET_ID_DRAWING_AREA_FIRST + 15)
446 #define GADGET_ID_MAGIC_BALL_CONTENT_7 (GADGET_ID_DRAWING_AREA_FIRST + 16)
447 #define GADGET_ID_ANDROID_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 17)
448 #define GADGET_ID_AMOEBA_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 18)
449 #define GADGET_ID_START_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 19)
450 #define GADGET_ID_ARTWORK_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 20)
451 #define GADGET_ID_EXPLOSION_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 21)
452 #define GADGET_ID_CUSTOM_GRAPHIC (GADGET_ID_DRAWING_AREA_FIRST + 22)
453 #define GADGET_ID_CUSTOM_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 23)
454 #define GADGET_ID_CUSTOM_MOVE_ENTER (GADGET_ID_DRAWING_AREA_FIRST + 24)
455 #define GADGET_ID_CUSTOM_MOVE_LEAVE (GADGET_ID_DRAWING_AREA_FIRST + 25)
456 #define GADGET_ID_CUSTOM_CHANGE_TARGET (GADGET_ID_DRAWING_AREA_FIRST + 26)
457 #define GADGET_ID_CUSTOM_CHANGE_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 27)
458 #define GADGET_ID_CUSTOM_CHANGE_TRIGGER (GADGET_ID_DRAWING_AREA_FIRST + 28)
459 #define GADGET_ID_GROUP_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 29)
460 #define GADGET_ID_RANDOM_BACKGROUND (GADGET_ID_DRAWING_AREA_FIRST + 30)
462 /* text input identifiers */
463 #define GADGET_ID_TEXT_INPUT_FIRST (GADGET_ID_DRAWING_AREA_FIRST + 31)
465 #define GADGET_ID_LEVEL_NAME (GADGET_ID_TEXT_INPUT_FIRST + 0)
466 #define GADGET_ID_LEVEL_AUTHOR (GADGET_ID_TEXT_INPUT_FIRST + 1)
467 #define GADGET_ID_ELEMENT_NAME (GADGET_ID_TEXT_INPUT_FIRST + 2)
469 /* text area identifiers */
470 #define GADGET_ID_TEXT_AREA_FIRST (GADGET_ID_TEXT_INPUT_FIRST + 3)
472 #define GADGET_ID_ENVELOPE_INFO (GADGET_ID_TEXT_AREA_FIRST + 0)
474 /* selectbox identifiers */
475 #define GADGET_ID_SELECTBOX_FIRST (GADGET_ID_TEXT_AREA_FIRST + 1)
477 #define GADGET_ID_TIME_OR_STEPS (GADGET_ID_SELECTBOX_FIRST + 0)
478 #define GADGET_ID_GAME_ENGINE_TYPE (GADGET_ID_SELECTBOX_FIRST + 1)
479 #define GADGET_ID_WIND_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 2)
480 #define GADGET_ID_PLAYER_SPEED (GADGET_ID_SELECTBOX_FIRST + 3)
481 #define GADGET_ID_CUSTOM_WALK_TO_ACTION (GADGET_ID_SELECTBOX_FIRST + 4)
482 #define GADGET_ID_CUSTOM_EXPLOSION_TYPE (GADGET_ID_SELECTBOX_FIRST + 5)
483 #define GADGET_ID_CUSTOM_DEADLINESS (GADGET_ID_SELECTBOX_FIRST + 6)
484 #define GADGET_ID_CUSTOM_MOVE_PATTERN (GADGET_ID_SELECTBOX_FIRST + 7)
485 #define GADGET_ID_CUSTOM_MOVE_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 8)
486 #define GADGET_ID_CUSTOM_MOVE_STEPSIZE (GADGET_ID_SELECTBOX_FIRST + 9)
487 #define GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE (GADGET_ID_SELECTBOX_FIRST + 10)
488 #define GADGET_ID_CUSTOM_SMASH_TARGETS (GADGET_ID_SELECTBOX_FIRST + 11)
489 #define GADGET_ID_CUSTOM_SLIPPERY_TYPE (GADGET_ID_SELECTBOX_FIRST + 12)
490 #define GADGET_ID_CUSTOM_ACCESS_TYPE (GADGET_ID_SELECTBOX_FIRST + 13)
491 #define GADGET_ID_CUSTOM_ACCESS_LAYER (GADGET_ID_SELECTBOX_FIRST + 14)
492 #define GADGET_ID_CUSTOM_ACCESS_PROTECTED (GADGET_ID_SELECTBOX_FIRST + 15)
493 #define GADGET_ID_CUSTOM_ACCESS_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 16)
494 #define GADGET_ID_CHANGE_TIME_UNITS (GADGET_ID_SELECTBOX_FIRST + 17)
495 #define GADGET_ID_CHANGE_DIRECT_ACTION (GADGET_ID_SELECTBOX_FIRST + 18)
496 #define GADGET_ID_CHANGE_OTHER_ACTION (GADGET_ID_SELECTBOX_FIRST + 19)
497 #define GADGET_ID_CHANGE_SIDE (GADGET_ID_SELECTBOX_FIRST + 20)
498 #define GADGET_ID_CHANGE_PLAYER (GADGET_ID_SELECTBOX_FIRST + 21)
499 #define GADGET_ID_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 22)
500 #define GADGET_ID_CHANGE_REPLACE_WHEN (GADGET_ID_SELECTBOX_FIRST + 23)
501 #define GADGET_ID_ACTION_TYPE (GADGET_ID_SELECTBOX_FIRST + 24)
502 #define GADGET_ID_ACTION_MODE (GADGET_ID_SELECTBOX_FIRST + 25)
503 #define GADGET_ID_ACTION_ARG (GADGET_ID_SELECTBOX_FIRST + 26)
504 #define GADGET_ID_SELECT_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 27)
505 #define GADGET_ID_GROUP_CHOICE_MODE (GADGET_ID_SELECTBOX_FIRST + 28)
507 /* textbutton identifiers */
508 #define GADGET_ID_TEXTBUTTON_FIRST (GADGET_ID_SELECTBOX_FIRST + 29)
510 #define GADGET_ID_PROPERTIES_INFO (GADGET_ID_TEXTBUTTON_FIRST + 0)
511 #define GADGET_ID_PROPERTIES_CONFIG (GADGET_ID_TEXTBUTTON_FIRST + 1)
512 #define GADGET_ID_PROPERTIES_CONFIG_1 (GADGET_ID_TEXTBUTTON_FIRST + 2)
513 #define GADGET_ID_PROPERTIES_CONFIG_2 (GADGET_ID_TEXTBUTTON_FIRST + 3)
514 #define GADGET_ID_PROPERTIES_CHANGE (GADGET_ID_TEXTBUTTON_FIRST + 4)
515 #define GADGET_ID_SAVE_AS_TEMPLATE (GADGET_ID_TEXTBUTTON_FIRST + 5)
516 #define GADGET_ID_ADD_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 6)
517 #define GADGET_ID_DEL_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 7)
519 /* graphicbutton identifiers */
520 #define GADGET_ID_GRAPHICBUTTON_FIRST (GADGET_ID_TEXTBUTTON_FIRST + 8)
522 #define GADGET_ID_PREV_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 0)
523 #define GADGET_ID_NEXT_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 1)
524 #define GADGET_ID_COPY_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 2)
525 #define GADGET_ID_PASTE_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 3)
527 /* gadgets for scrolling of drawing area */
528 #define GADGET_ID_SCROLLING_FIRST (GADGET_ID_GRAPHICBUTTON_FIRST + 4)
530 #define GADGET_ID_SCROLL_UP (GADGET_ID_SCROLLING_FIRST + 0)
531 #define GADGET_ID_SCROLL_DOWN (GADGET_ID_SCROLLING_FIRST + 1)
532 #define GADGET_ID_SCROLL_LEFT (GADGET_ID_SCROLLING_FIRST + 2)
533 #define GADGET_ID_SCROLL_RIGHT (GADGET_ID_SCROLLING_FIRST + 3)
534 #define GADGET_ID_SCROLL_HORIZONTAL (GADGET_ID_SCROLLING_FIRST + 4)
535 #define GADGET_ID_SCROLL_VERTICAL (GADGET_ID_SCROLLING_FIRST + 5)
537 /* gadgets for scrolling element list */
538 #define GADGET_ID_SCROLLING_LIST_FIRST (GADGET_ID_SCROLLING_FIRST + 6)
540 #define GADGET_ID_SCROLL_LIST_UP (GADGET_ID_SCROLLING_LIST_FIRST + 0)
541 #define GADGET_ID_SCROLL_LIST_DOWN (GADGET_ID_SCROLLING_LIST_FIRST + 1)
542 #define GADGET_ID_SCROLL_LIST_VERTICAL (GADGET_ID_SCROLLING_LIST_FIRST + 2)
544 /* checkbuttons/radiobuttons for level/element properties */
545 #define GADGET_ID_CHECKBUTTON_FIRST (GADGET_ID_SCROLLING_LIST_FIRST + 3)
547 #define GADGET_ID_RANDOM_PERCENTAGE (GADGET_ID_CHECKBUTTON_FIRST + 0)
548 #define GADGET_ID_RANDOM_QUANTITY (GADGET_ID_CHECKBUTTON_FIRST + 1)
549 #define GADGET_ID_RANDOM_RESTRICTED (GADGET_ID_CHECKBUTTON_FIRST + 2)
550 #define GADGET_ID_STICK_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 3)
551 #define GADGET_ID_EM_SLIPPERY_GEMS (GADGET_ID_CHECKBUTTON_FIRST + 4)
552 #define GADGET_ID_USE_SPRING_BUG (GADGET_ID_CHECKBUTTON_FIRST + 5)
553 #define GADGET_ID_USE_TIME_ORB_BUG (GADGET_ID_CHECKBUTTON_FIRST + 6)
554 #define GADGET_ID_RANDOM_BALL_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 7)
555 #define GADGET_ID_INITIAL_BALL_STATE (GADGET_ID_CHECKBUTTON_FIRST + 8)
556 #define GADGET_ID_GROW_INTO_DIGGABLE (GADGET_ID_CHECKBUTTON_FIRST + 9)
557 #define GADGET_ID_CONTINUOUS_SNAPPING (GADGET_ID_CHECKBUTTON_FIRST + 10)
558 #define GADGET_ID_BLOCK_SNAP_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 11)
559 #define GADGET_ID_BLOCK_LAST_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 12)
560 #define GADGET_ID_SP_BLOCK_LAST_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 13)
561 #define GADGET_ID_INSTANT_RELOCATION (GADGET_ID_CHECKBUTTON_FIRST + 14)
562 #define GADGET_ID_SHIFTED_RELOCATION (GADGET_ID_CHECKBUTTON_FIRST + 15)
563 #define GADGET_ID_USE_START_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 16)
564 #define GADGET_ID_USE_ARTWORK_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 17)
565 #define GADGET_ID_USE_EXPLOSION_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 18)
566 #define GADGET_ID_INITIAL_GRAVITY (GADGET_ID_CHECKBUTTON_FIRST + 19)
567 #define GADGET_ID_CAN_PASS_TO_WALKABLE (GADGET_ID_CHECKBUTTON_FIRST + 20)
568 #define GADGET_ID_CAN_FALL_INTO_ACID (GADGET_ID_CHECKBUTTON_FIRST + 21)
569 #define GADGET_ID_CAN_MOVE_INTO_ACID (GADGET_ID_CHECKBUTTON_FIRST + 22)
570 #define GADGET_ID_DONT_COLLIDE_WITH (GADGET_ID_CHECKBUTTON_FIRST + 23)
571 #define GADGET_ID_ENVELOPE_AUTOWRAP (GADGET_ID_CHECKBUTTON_FIRST + 24)
572 #define GADGET_ID_ENVELOPE_CENTERED (GADGET_ID_CHECKBUTTON_FIRST + 25)
573 #define GADGET_ID_CUSTOM_INDESTRUCTIBLE (GADGET_ID_CHECKBUTTON_FIRST + 26)
574 #define GADGET_ID_CUSTOM_CAN_EXPLODE (GADGET_ID_CHECKBUTTON_FIRST + 27)
575 #define GADGET_ID_CUSTOM_EXPLODE_FIRE (GADGET_ID_CHECKBUTTON_FIRST + 28)
576 #define GADGET_ID_CUSTOM_EXPLODE_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 29)
577 #define GADGET_ID_CUSTOM_EXPLODE_IMPACT (GADGET_ID_CHECKBUTTON_FIRST + 30)
578 #define GADGET_ID_CUSTOM_WALK_TO_OBJECT (GADGET_ID_CHECKBUTTON_FIRST + 31)
579 #define GADGET_ID_CUSTOM_DEADLY (GADGET_ID_CHECKBUTTON_FIRST + 32)
580 #define GADGET_ID_CUSTOM_CAN_MOVE (GADGET_ID_CHECKBUTTON_FIRST + 33)
581 #define GADGET_ID_CUSTOM_CAN_FALL (GADGET_ID_CHECKBUTTON_FIRST + 34)
582 #define GADGET_ID_CUSTOM_CAN_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 35)
583 #define GADGET_ID_CUSTOM_SLIPPERY (GADGET_ID_CHECKBUTTON_FIRST + 36)
584 #define GADGET_ID_CUSTOM_ACCESSIBLE (GADGET_ID_CHECKBUTTON_FIRST + 37)
585 #define GADGET_ID_CUSTOM_GRAV_REACHABLE (GADGET_ID_CHECKBUTTON_FIRST + 38)
586 #define GADGET_ID_CUSTOM_USE_LAST_VALUE (GADGET_ID_CHECKBUTTON_FIRST + 39)
587 #define GADGET_ID_CUSTOM_USE_GRAPHIC (GADGET_ID_CHECKBUTTON_FIRST + 40)
588 #define GADGET_ID_CUSTOM_USE_TEMPLATE (GADGET_ID_CHECKBUTTON_FIRST + 41)
589 #define GADGET_ID_CUSTOM_CAN_CHANGE (GADGET_ID_CHECKBUTTON_FIRST + 42)
590 #define GADGET_ID_CHANGE_USE_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 43)
591 #define GADGET_ID_CHANGE_USE_EXPLOSION (GADGET_ID_CHECKBUTTON_FIRST + 44)
592 #define GADGET_ID_CHANGE_ONLY_COMPLETE (GADGET_ID_CHECKBUTTON_FIRST + 45)
593 #define GADGET_ID_CHANGE_USE_RANDOM (GADGET_ID_CHECKBUTTON_FIRST + 46)
594 #define GADGET_ID_CHANGE_HAS_ACTION (GADGET_ID_CHECKBUTTON_FIRST + 47)
595 #define GADGET_ID_CHANGE_DELAY (GADGET_ID_CHECKBUTTON_FIRST + 48)
596 #define GADGET_ID_CHANGE_BY_DIRECT_ACT (GADGET_ID_CHECKBUTTON_FIRST + 49)
597 #define GADGET_ID_CHANGE_BY_OTHER_ACT (GADGET_ID_CHECKBUTTON_FIRST + 50)
599 /* gadgets for buttons in element list */
600 #define GADGET_ID_ELEMENTLIST_FIRST (GADGET_ID_CHECKBUTTON_FIRST + 51)
601 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
602 ED_NUM_ELEMENTLIST_BUTTONS - 1)
604 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
606 /* radio button numbers */
607 #define RADIO_NR_NONE 0
608 #define RADIO_NR_DRAWING_TOOLBOX 1
609 #define RADIO_NR_RANDOM_ELEMENTS 2
611 /* values for counter gadgets */
612 #define ED_COUNTER_ID_SELECT_LEVEL 0
613 #define ED_COUNTER_ID_LEVEL_XSIZE 1
614 #define ED_COUNTER_ID_LEVEL_YSIZE 2
615 #define ED_COUNTER_ID_LEVEL_GEMSLIMIT 3
616 #define ED_COUNTER_ID_LEVEL_TIMELIMIT 4
617 #define ED_COUNTER_ID_LEVEL_TIMESCORE 5
618 #define ED_COUNTER_ID_LEVEL_RANDOM 6
619 #define ED_COUNTER_ID_ELEMENT_VALUE1 7
620 #define ED_COUNTER_ID_ELEMENT_VALUE2 8
621 #define ED_COUNTER_ID_ELEMENT_VALUE3 9
622 #define ED_COUNTER_ID_ELEMENT_VALUE4 10
623 #define ED_COUNTER_ID_YAMYAM_CONTENT 11
624 #define ED_COUNTER_ID_BALL_CONTENT 12
625 #define ED_COUNTER_ID_ANDROID_CONTENT 13
626 #define ED_COUNTER_ID_ENVELOPE_XSIZE 14
627 #define ED_COUNTER_ID_ENVELOPE_YSIZE 15
628 #define ED_COUNTER_ID_CUSTOM_SCORE 16
629 #define ED_COUNTER_ID_CUSTOM_GEMCOUNT 17
630 #define ED_COUNTER_ID_CUSTOM_VALUE_FIX 18
631 #define ED_COUNTER_ID_CUSTOM_VALUE_RND 19
632 #define ED_COUNTER_ID_PUSH_DELAY_FIX 20
633 #define ED_COUNTER_ID_PUSH_DELAY_RND 21
634 #define ED_COUNTER_ID_DROP_DELAY_FIX 22
635 #define ED_COUNTER_ID_DROP_DELAY_RND 23
636 #define ED_COUNTER_ID_MOVE_DELAY_FIX 24
637 #define ED_COUNTER_ID_MOVE_DELAY_RND 25
638 #define ED_COUNTER_ID_EXPLOSION_DELAY 26
639 #define ED_COUNTER_ID_IGNITION_DELAY 27
640 #define ED_COUNTER_ID_GROUP_CONTENT 28
641 #define ED_COUNTER_ID_CHANGE_DELAY_FIX 29
642 #define ED_COUNTER_ID_CHANGE_DELAY_RND 30
643 #define ED_COUNTER_ID_CHANGE_CONT_RND 31
645 #define ED_NUM_COUNTERBUTTONS 32
647 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
648 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM
650 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
651 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
652 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
653 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
654 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
655 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
657 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
658 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
660 /* values for scrollbutton gadgets */
661 #define ED_SCROLLBUTTON_ID_AREA_UP 0
662 #define ED_SCROLLBUTTON_ID_AREA_DOWN 1
663 #define ED_SCROLLBUTTON_ID_AREA_LEFT 2
664 #define ED_SCROLLBUTTON_ID_AREA_RIGHT 3
665 #define ED_SCROLLBUTTON_ID_LIST_UP 4
666 #define ED_SCROLLBUTTON_ID_LIST_DOWN 5
668 #define ED_NUM_SCROLLBUTTONS 6
670 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
671 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
673 /* values for scrollbar gadgets */
674 #define ED_SCROLLBAR_ID_AREA_HORIZONTAL 0
675 #define ED_SCROLLBAR_ID_AREA_VERTICAL 1
676 #define ED_SCROLLBAR_ID_LIST_VERTICAL 2
678 #define ED_NUM_SCROLLBARS 3
680 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
681 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
683 /* values for text input gadgets */
684 #define ED_TEXTINPUT_ID_LEVEL_NAME 0
685 #define ED_TEXTINPUT_ID_LEVEL_AUTHOR 1
686 #define ED_TEXTINPUT_ID_ELEMENT_NAME 2
688 #define ED_NUM_TEXTINPUT 3
690 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
691 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
693 /* values for text area gadgets */
694 #define ED_TEXTAREA_ID_ENVELOPE_INFO 0
696 #define ED_NUM_TEXTAREAS 1
698 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
699 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
701 /* values for selectbox gadgets */
702 #define ED_SELECTBOX_ID_TIME_OR_STEPS 0
703 #define ED_SELECTBOX_ID_GAME_ENGINE_TYPE 1
704 #define ED_SELECTBOX_ID_WIND_DIRECTION 2
705 #define ED_SELECTBOX_ID_PLAYER_SPEED 3
706 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE 4
707 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER 5
708 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED 6
709 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION 7
710 #define ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION 8
711 #define ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN 9
712 #define ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION 10
713 #define ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE 11
714 #define ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE 12
715 #define ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS 13
716 #define ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE 14
717 #define ED_SELECTBOX_ID_CUSTOM_DEADLINESS 15
718 #define ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE 16
719 #define ED_SELECTBOX_ID_CHANGE_TIME_UNITS 17
720 #define ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION 18
721 #define ED_SELECTBOX_ID_CHANGE_OTHER_ACTION 19
722 #define ED_SELECTBOX_ID_CHANGE_SIDE 20
723 #define ED_SELECTBOX_ID_CHANGE_PLAYER 21
724 #define ED_SELECTBOX_ID_CHANGE_PAGE 22
725 #define ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN 23
726 #define ED_SELECTBOX_ID_ACTION_TYPE 24
727 #define ED_SELECTBOX_ID_ACTION_MODE 25
728 #define ED_SELECTBOX_ID_ACTION_ARG 26
729 #define ED_SELECTBOX_ID_SELECT_CHANGE_PAGE 27
730 #define ED_SELECTBOX_ID_GROUP_CHOICE_MODE 28
732 #define ED_NUM_SELECTBOX 29
734 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
735 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_WIND_DIRECTION
737 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
738 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
739 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
740 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
741 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
742 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
744 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
745 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
747 /* values for textbutton gadgets */
748 #define ED_TEXTBUTTON_ID_PROPERTIES_INFO 0
749 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG 1
750 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1 2
751 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2 3
752 #define ED_TEXTBUTTON_ID_PROPERTIES_CHANGE 4
753 #define ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE 5
754 #define ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE 6
755 #define ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE 7
757 #define ED_NUM_TEXTBUTTONS 8
759 #define ED_TEXTBUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
760 #define ED_TEXTBUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
762 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
763 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
765 /* values for graphicbutton gadgets */
766 #define ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE 0
767 #define ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE 1
768 #define ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE 2
769 #define ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE 3
771 #define ED_NUM_GRAPHICBUTTONS 4
773 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
774 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
776 /* values for checkbutton gadgets */
777 #define ED_CHECKBUTTON_ID_RANDOM_RESTRICTED 0
778 #define ED_CHECKBUTTON_ID_STICK_ELEMENT 1
779 #define ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS 2
780 #define ED_CHECKBUTTON_ID_USE_SPRING_BUG 3
781 #define ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG 4
782 #define ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT 5
783 #define ED_CHECKBUTTON_ID_INITIAL_BALL_STATE 6
784 #define ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE 7
785 #define ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING 8
786 #define ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD 9
787 #define ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD 10
788 #define ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD 11
789 #define ED_CHECKBUTTON_ID_INSTANT_RELOCATION 12
790 #define ED_CHECKBUTTON_ID_SHIFTED_RELOCATION 13
791 #define ED_CHECKBUTTON_ID_USE_START_ELEMENT 14
792 #define ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT 15
793 #define ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT 16
794 #define ED_CHECKBUTTON_ID_INITIAL_GRAVITY 17
795 #define ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE 18
796 #define ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID 19
797 #define ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID 20
798 #define ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH 21
799 #define ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP 22
800 #define ED_CHECKBUTTON_ID_ENVELOPE_CENTERED 23
801 #define ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC 24
802 #define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE 25
803 #define ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE 26
804 #define ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE 27
805 #define ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE 28
806 #define ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT 29
807 #define ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE 30
808 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE 31
809 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL 32
810 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH 33
811 #define ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY 34
812 #define ED_CHECKBUTTON_ID_CUSTOM_DEADLY 35
813 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE 36
814 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE 37
815 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH 38
816 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT 39
817 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE 40
818 #define ED_CHECKBUTTON_ID_CHANGE_DELAY 41
819 #define ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT 42
820 #define ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT 43
821 #define ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION 44
822 #define ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT 45
823 #define ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE 46
824 #define ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM 47
825 #define ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION 48
827 #define ED_NUM_CHECKBUTTONS 49
829 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
830 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
832 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
833 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
834 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
835 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
836 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
837 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
839 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
840 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
842 /* values for radiobutton gadgets */
843 #define ED_RADIOBUTTON_ID_PERCENTAGE 0
844 #define ED_RADIOBUTTON_ID_QUANTITY 1
846 #define ED_NUM_RADIOBUTTONS 2
848 #define ED_RADIOBUTTON_ID_LEVEL_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
849 #define ED_RADIOBUTTON_ID_LEVEL_LAST ED_RADIOBUTTON_ID_QUANTITY
851 /* values for drawing area gadgets */
852 #define ED_DRAWING_ID_DRAWING_LEVEL 0
853 #define ED_DRAWING_ID_YAMYAM_CONTENT_0 1
854 #define ED_DRAWING_ID_YAMYAM_CONTENT_1 2
855 #define ED_DRAWING_ID_YAMYAM_CONTENT_2 3
856 #define ED_DRAWING_ID_YAMYAM_CONTENT_3 4
857 #define ED_DRAWING_ID_YAMYAM_CONTENT_4 5
858 #define ED_DRAWING_ID_YAMYAM_CONTENT_5 6
859 #define ED_DRAWING_ID_YAMYAM_CONTENT_6 7
860 #define ED_DRAWING_ID_YAMYAM_CONTENT_7 8
861 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 9
862 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_1 10
863 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_2 11
864 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_3 12
865 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_4 13
866 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_5 14
867 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_6 15
868 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_7 16
869 #define ED_DRAWING_ID_ANDROID_CONTENT 17
870 #define ED_DRAWING_ID_AMOEBA_CONTENT 18
871 #define ED_DRAWING_ID_START_ELEMENT 19
872 #define ED_DRAWING_ID_ARTWORK_ELEMENT 20
873 #define ED_DRAWING_ID_EXPLOSION_ELEMENT 21
874 #define ED_DRAWING_ID_CUSTOM_GRAPHIC 22
875 #define ED_DRAWING_ID_CUSTOM_CONTENT 23
876 #define ED_DRAWING_ID_CUSTOM_MOVE_ENTER 24
877 #define ED_DRAWING_ID_CUSTOM_MOVE_LEAVE 25
878 #define ED_DRAWING_ID_CUSTOM_CHANGE_TARGET 26
879 #define ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT 27
880 #define ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER 28
881 #define ED_DRAWING_ID_GROUP_CONTENT 29
882 #define ED_DRAWING_ID_RANDOM_BACKGROUND 30
884 #define ED_NUM_DRAWING_AREAS 31
888 -----------------------------------------------------------------------------
889 some internally used definitions
890 -----------------------------------------------------------------------------
893 /* values for CopyLevelToUndoBuffer() */
894 #define UNDO_IMMEDIATE 0
895 #define UNDO_ACCUMULATE 1
897 /* values for scrollbars */
898 #define ED_SCROLL_NO 0
899 #define ED_SCROLL_LEFT 1
900 #define ED_SCROLL_RIGHT 2
901 #define ED_SCROLL_UP 4
902 #define ED_SCROLL_DOWN 8
904 /* screens in the level editor */
905 #define ED_MODE_DRAWING 0
906 #define ED_MODE_INFO 1
907 #define ED_MODE_PROPERTIES 2
909 /* sub-screens in the element properties section */
910 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
911 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
912 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
913 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
914 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
916 /* how many steps can be cancelled */
917 #define NUM_UNDO_STEPS (10 + 1)
919 /* values for elements with score for certain actions */
921 #define MAX_SCORE 999
923 /* values for elements with count for collecting */
924 #define MIN_COLLECT_COUNT 0
925 #define MAX_COLLECT_COUNT 999
927 /* values for random placement */
928 #define RANDOM_USE_PERCENTAGE 0
929 #define RANDOM_USE_QUANTITY 1
931 /* maximal size of level editor drawing area */
932 #define MAX_ED_FIELDX (2 * SCR_FIELDX)
933 #define MAX_ED_FIELDY (2 * SCR_FIELDY - 1)
937 -----------------------------------------------------------------------------
938 some internally used data structure definitions
939 -----------------------------------------------------------------------------
946 } control_info[ED_NUM_CTRL_BUTTONS] =
948 /* note: some additional characters are already reserved for "cheat mode"
949 shortcuts (":XYZ" style) -- for details, see "events.c" */
951 { 's', "draw single items" },
952 { 'd', "draw connected items" },
953 { 'l', "draw lines" },
954 { 'a', "draw arcs" },
955 { 'r', "draw outline rectangles" },
956 { 'R', "draw filled rectangles" },
957 { '\0', "wrap (rotate) level up" },
958 { 't', "enter text elements" },
959 { 'f', "flood fill" },
960 { '\0', "wrap (rotate) level left" },
961 { '?', "properties of drawing element" },
962 { '\0', "wrap (rotate) level right" },
963 { '\0', "random element placement" },
964 { 'b', "grab brush" },
965 { '\0', "wrap (rotate) level down" },
966 { ',', "pick drawing element" },
968 { 'U', "undo last operation" },
969 { 'I', "level properties" },
970 { 'S', "save level" },
971 { 'C', "clear level" },
972 { 'T', "test level" },
973 { 'E', "exit level editor" },
975 { '\0', "copy settings from other element" },
976 { '\0', "copy settings to other element" },
977 { '\0', "exchange element with other element" },
979 { '\0', "copy settings from this element" },
980 { '\0', "paste settings to this element" },
983 static int random_placement_value = 10;
984 static int random_placement_method = RANDOM_USE_QUANTITY;
985 static int random_placement_background_element = EL_SAND;
986 static boolean random_placement_background_restricted = FALSE;
987 static boolean stick_element_properties_window = FALSE;
988 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
989 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
990 static struct ElementChangeInfo custom_element_change;
991 static struct ElementGroupInfo group_element_info;
992 static struct ElementInfo custom_element;
997 int min_value, max_value;
998 int gadget_id_down, gadget_id_up;
1000 int gadget_id_align;
1002 char *text_above, *text_left, *text_right;
1003 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1005 /* ---------- current level number --------------------------------------- */
1008 DX + 5 - SX, DY + 3 - SY,
1010 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1011 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1016 /* ---------- level and editor settings ---------------------------------- */
1019 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1020 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1021 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1022 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1024 "playfield size:", NULL, "width",
1027 -1, ED_LEVEL_SETTINGS_YPOS(4),
1028 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1029 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1030 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1032 NULL, " ", "height",
1035 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1037 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1038 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1040 NULL, "number of gems to collect:", NULL
1043 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
1045 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1046 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1048 "time or step limit to solve level:", NULL, NULL
1051 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(9),
1053 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1054 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1055 &level.score[SC_TIME_BONUS],
1056 "score for each second/step left:", NULL, NULL
1059 ED_LEVEL_SETTINGS_XPOS(0), ED_COUNTER2_YPOS(8),
1061 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1062 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1063 &random_placement_value,
1064 "random element placement:", NULL, "in"
1067 /* ---------- element settings: configure (various elements) ------------- */
1070 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1071 MIN_SCORE, MAX_SCORE,
1072 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1073 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1074 NULL, /* will be set when used */
1078 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1079 MIN_SCORE, MAX_SCORE,
1080 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1081 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1082 NULL, /* will be set when used */
1086 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1087 MIN_SCORE, MAX_SCORE,
1088 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1089 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1090 NULL, /* will be set when used */
1094 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1095 MIN_SCORE, MAX_SCORE,
1096 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1097 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1098 NULL, /* will be set when used */
1102 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1103 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1104 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1105 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1106 &level.num_yamyam_contents,
1107 NULL, NULL, "number of content areas"
1110 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1111 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1112 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1113 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1114 &level.num_ball_contents,
1115 NULL, NULL, "number of content areas"
1118 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1119 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1120 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1121 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1122 &level.num_android_clone_elements,
1123 NULL, NULL, "number of clonable elements"
1126 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1127 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1128 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1129 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1130 NULL, /* will be set when used */
1131 NULL, NULL, "width",
1134 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1135 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1136 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1137 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1138 NULL, /* will be set when used */
1139 NULL, " ", "height",
1142 /* ---------- element settings: configure 1 (custom elements) ------------ */
1145 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1146 MIN_SCORE, MAX_SCORE,
1147 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1148 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1149 &custom_element.collect_score_initial,
1150 NULL, "CE score", " "
1153 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1154 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1155 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1156 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1157 &custom_element.collect_count_initial,
1158 NULL, "CE count", NULL
1161 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
1163 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1164 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1165 &custom_element.ce_value_fixed_initial,
1166 NULL, "CE value", NULL
1169 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
1171 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1172 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1173 &custom_element.ce_value_random_initial,
1174 NULL, "+random", NULL
1177 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1179 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1180 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1181 &custom_element.push_delay_fixed,
1182 NULL, "push delay", NULL
1185 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1187 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1188 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1189 &custom_element.push_delay_random,
1190 NULL, "+random", NULL
1193 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
1195 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1196 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1197 &custom_element.drop_delay_fixed,
1198 NULL, "drop delay", NULL
1201 -1, ED_ELEMENT_SETTINGS_YPOS(8),
1203 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1204 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1205 &custom_element.drop_delay_random,
1206 NULL, "+random", NULL
1209 /* ---------- element settings: configure 2 (custom elements) ------------ */
1212 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1214 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1215 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1216 &custom_element.move_delay_fixed,
1217 NULL, "move delay", NULL
1220 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1222 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1223 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1224 &custom_element.move_delay_random,
1225 NULL, "+random", NULL
1228 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
1230 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1231 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1232 &custom_element.explosion_delay,
1233 NULL, "explosion delay", NULL
1236 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1238 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1239 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1240 &custom_element.ignition_delay,
1241 NULL, "ignition delay", "(by fire)"
1244 /* ---------- element settings: configure (group elements) --------------- */
1247 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
1248 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1249 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1250 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1251 &group_element_info.num_elements,
1252 NULL, NULL, "number of elements in group"
1255 /* ---------- element settings: advanced (custom elements) --------------- */
1258 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1260 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1261 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1262 &custom_element_change.delay_fixed,
1263 NULL, "CE delay", NULL,
1266 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1268 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1269 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1270 &custom_element_change.delay_random,
1271 NULL, "+random", NULL
1274 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1276 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1277 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1278 &custom_element_change.random_percentage,
1279 NULL, "use random replace:", "%"
1289 char *text_above, *infotext;
1290 } textinput_info[ED_NUM_TEXTINPUT] =
1293 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1294 GADGET_ID_LEVEL_NAME,
1300 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1301 GADGET_ID_LEVEL_AUTHOR,
1302 MAX_LEVEL_AUTHOR_LEN,
1307 5 * MINI_TILEX - 2, 5 * MINI_TILEY - ED_BORDER_SIZE + 1,
1308 GADGET_ID_ELEMENT_NAME,
1309 MAX_ELEMENT_NAME_LEN - 2, /* currently 2 chars less editable */
1310 custom_element.description,
1311 NULL, "Element name"
1321 char *text_above, *infotext;
1322 } textarea_info[ED_NUM_TEXTAREAS] =
1325 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1326 GADGET_ID_ENVELOPE_INFO,
1327 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1329 "Envelope Content:", "Envelope Content"
1333 static struct ValueTextInfo options_time_or_steps[] =
1341 static struct ValueTextInfo options_game_engine_type[] =
1343 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1344 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1349 static struct ValueTextInfo options_wind_direction[] =
1351 { MV_START_NONE, "none" },
1352 { MV_START_LEFT, "left" },
1353 { MV_START_RIGHT, "right" },
1354 { MV_START_UP, "up" },
1355 { MV_START_DOWN, "down" },
1360 static struct ValueTextInfo options_player_speed[] =
1367 { 16, "very fast" },
1368 { 32, "ultrafast" },
1373 static struct ValueTextInfo options_access_type[] =
1375 { EP_WALKABLE, "walkable" },
1376 { EP_PASSABLE, "passable" },
1381 static struct ValueTextInfo options_access_layer[] =
1383 { EP_ACCESSIBLE_OVER, "over" },
1384 { EP_ACCESSIBLE_INSIDE, "inside" },
1385 { EP_ACCESSIBLE_UNDER, "under" },
1390 static struct ValueTextInfo options_access_protected[] =
1392 { 0, "unprotected" },
1398 static struct ValueTextInfo options_access_direction[] =
1400 { MV_NO_DIRECTION, "no direction" },
1401 { MV_LEFT, "left" },
1402 { MV_RIGHT, "right" },
1404 { MV_DOWN, "down" },
1405 { MV_LEFT | MV_UP, "left + up" },
1406 { MV_LEFT | MV_DOWN, "left + down" },
1407 { MV_RIGHT | MV_UP, "right + up" },
1408 { MV_RIGHT | MV_DOWN, "right + down" },
1409 { MV_HORIZONTAL, "horizontal" },
1410 { MV_VERTICAL, "vertical" },
1411 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1412 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1413 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1414 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1415 { MV_ALL_DIRECTIONS, "all directions" },
1420 static struct ValueTextInfo options_walk_to_action[] =
1422 { EP_DIGGABLE, "diggable" },
1423 { EP_COLLECTIBLE_ONLY, "collectible" },
1424 { EP_DROPPABLE, "collectible & droppable" },
1425 { EP_THROWABLE, "collectible & throwable" },
1426 { EP_PUSHABLE, "pushable" },
1431 static struct ValueTextInfo options_move_pattern[] =
1433 { MV_LEFT, "left" },
1434 { MV_RIGHT, "right" },
1436 { MV_DOWN, "down" },
1437 { MV_HORIZONTAL, "horizontal" },
1438 { MV_VERTICAL, "vertical" },
1439 { MV_ALL_DIRECTIONS, "all directions" },
1440 { MV_WIND_DIRECTION, "wind direction" },
1441 { MV_TOWARDS_PLAYER, "towards player" },
1442 { MV_AWAY_FROM_PLAYER, "away from player" },
1443 { MV_ALONG_LEFT_SIDE, "along left side" },
1444 { MV_ALONG_RIGHT_SIDE, "along right side" },
1445 { MV_TURNING_LEFT, "turning left" },
1446 { MV_TURNING_RIGHT, "turning right" },
1447 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1448 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1449 { MV_TURNING_RANDOM, "turning random" },
1450 { MV_MAZE_RUNNER, "maze runner style" },
1451 { MV_MAZE_HUNTER, "maze hunter style" },
1452 { MV_WHEN_PUSHED, "when pushed" },
1453 { MV_WHEN_DROPPED, "when dropped/thrown" },
1458 static struct ValueTextInfo options_move_direction[] =
1460 { MV_START_AUTOMATIC, "automatic" },
1461 { MV_START_LEFT, "left" },
1462 { MV_START_RIGHT, "right" },
1463 { MV_START_UP, "up" },
1464 { MV_START_DOWN, "down" },
1465 { MV_START_RANDOM, "random" },
1466 { MV_START_PREVIOUS, "previous" },
1471 static struct ValueTextInfo options_move_stepsize[] =
1473 { 0, "not moving" },
1478 { 16, "very fast" },
1479 { 32, "even faster" },
1484 static struct ValueTextInfo options_move_leave_type[] =
1486 { LEAVE_TYPE_UNLIMITED, "leave behind" },
1487 { LEAVE_TYPE_LIMITED, "change it to" },
1492 static struct ValueTextInfo options_smash_targets[] =
1494 { EP_CAN_SMASH_PLAYER, "player" },
1496 { EP_CAN_SMASH_ENEMIES, "enemies" },
1498 { EP_CAN_SMASH_EVERYTHING, "everything" },
1503 static struct ValueTextInfo options_slippery_type[] =
1505 { SLIPPERY_ANY_RANDOM, "random" },
1506 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
1507 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
1508 { SLIPPERY_ONLY_LEFT, "only left" },
1509 { SLIPPERY_ONLY_RIGHT, "only right" },
1514 static struct ValueTextInfo options_deadliness[] =
1516 { EP_DONT_RUN_INTO, "running into" },
1517 { EP_DONT_COLLIDE_WITH, "colliding with" },
1518 { EP_DONT_TOUCH, "touching" },
1523 static struct ValueTextInfo options_explosion_type[] =
1525 { EXPLODES_3X3, "3x3" },
1526 { EXPLODES_CROSS, "3+3" },
1527 { EXPLODES_1X1, "1x1" },
1532 static struct ValueTextInfo options_time_units[] =
1535 { FRAMES_PER_SECOND, "seconds" },
1540 static struct ValueTextInfo options_change_direct_action[] =
1542 { CE_TOUCHED_BY_PLAYER, "touched by player" },
1543 { CE_PRESSED_BY_PLAYER, "pressed by player" },
1544 { CE_SWITCHED_BY_PLAYER, "switched by player" },
1545 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
1546 { CE_PUSHED_BY_PLAYER, "pushed by player" },
1547 { CE_ENTERED_BY_PLAYER, "entered by player" },
1548 { CE_LEFT_BY_PLAYER, "left by player" },
1549 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
1550 { CE_SWITCHED, "switched" },
1551 { CE_HITTING_SOMETHING, "hitting something" },
1552 { CE_HIT_BY_SOMETHING, "hit by something" },
1554 { CE_BLOCKED, "blocked" },
1556 { CE_IMPACT, "impact (on something)" },
1557 { CE_SMASHED, "smashed (from above)" },
1559 { CE_VALUE_CHANGES, "CE value changes" },
1560 { CE_SCORE_CHANGES, "CE score changes" },
1562 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
1563 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
1568 static struct ValueTextInfo options_change_other_action[] =
1570 { CE_PLAYER_TOUCHES_X, "player touches" },
1571 { CE_PLAYER_PRESSES_X, "player presses" },
1572 { CE_PLAYER_SWITCHES_X, "player switches" },
1573 { CE_PLAYER_SNAPS_X, "player snaps" },
1574 { CE_PLAYER_PUSHES_X, "player pushes" },
1575 { CE_PLAYER_ENTERS_X, "player enters" },
1576 { CE_PLAYER_LEAVES_X, "player leaves" },
1577 { CE_PLAYER_DIGS_X, "player digs" },
1578 { CE_PLAYER_COLLECTS_X, "player collects" },
1579 { CE_PLAYER_DROPS_X, "player drops/throws" },
1580 { CE_TOUCHING_X, "touching" },
1581 { CE_HITTING_X, "hitting" },
1582 { CE_DIGGING_X, "digging" },
1583 { CE_HIT_BY_X, "hit by" },
1584 { CE_SWITCH_OF_X, "switch of" },
1585 { CE_CHANGE_OF_X, "change by page of" },
1586 { CE_EXPLOSION_OF_X, "explosion of" },
1587 { CE_MOVE_OF_X, "move of" },
1588 { CE_CREATION_OF_X, "creation of" },
1589 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
1590 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
1591 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
1592 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
1597 static struct ValueTextInfo options_change_trigger_side[] =
1599 { CH_SIDE_LEFT, "left" },
1600 { CH_SIDE_RIGHT, "right" },
1601 { CH_SIDE_TOP, "top" },
1602 { CH_SIDE_BOTTOM, "bottom" },
1603 { CH_SIDE_LEFT_RIGHT, "left/right" },
1604 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
1605 { CH_SIDE_ANY, "any" },
1610 static struct ValueTextInfo options_change_trigger_player[] =
1612 { CH_PLAYER_1, "1" },
1613 { CH_PLAYER_2, "2" },
1614 { CH_PLAYER_3, "3" },
1615 { CH_PLAYER_4, "4" },
1616 { CH_PLAYER_ANY, "any" },
1621 static struct ValueTextInfo options_change_trigger_page[] =
1633 { (1 << 10), "11" },
1634 { (1 << 11), "12" },
1635 { (1 << 12), "13" },
1636 { (1 << 13), "14" },
1637 { (1 << 14), "15" },
1638 { (1 << 15), "16" },
1639 { (1 << 16), "17" },
1640 { (1 << 17), "18" },
1641 { (1 << 18), "19" },
1642 { (1 << 19), "20" },
1643 { (1 << 20), "21" },
1644 { (1 << 21), "22" },
1645 { (1 << 22), "23" },
1646 { (1 << 23), "24" },
1647 { (1 << 24), "25" },
1648 { (1 << 25), "26" },
1649 { (1 << 26), "27" },
1650 { (1 << 27), "28" },
1651 { (1 << 28), "29" },
1652 { (1 << 29), "30" },
1653 { (1 << 30), "31" },
1654 { (1 << 31), "32" },
1655 { CH_PAGE_ANY, "any" },
1660 static struct ValueTextInfo options_change_replace_when[] =
1662 { CP_WHEN_EMPTY, "empty" },
1663 { CP_WHEN_WALKABLE, "walkable" },
1664 { CP_WHEN_DIGGABLE, "diggable" },
1665 { CP_WHEN_COLLECTIBLE, "collectible" },
1666 { CP_WHEN_REMOVABLE, "removable" },
1667 { CP_WHEN_DESTRUCTIBLE, "destructible" },
1672 static struct ValueTextInfo options_action_type[] =
1674 { CA_NO_ACTION, "no action" },
1675 { CA_UNDEFINED, " " },
1676 { CA_HEADLINE_LEVEL_ACTIONS, "[level actions]" },
1677 { CA_RESTART_LEVEL, "restart level" },
1678 { CA_SHOW_ENVELOPE, "show envelope" },
1679 { CA_SET_LEVEL_TIME, "set time" },
1680 { CA_SET_LEVEL_SCORE, "set score" },
1681 { CA_SET_LEVEL_GEMS, "set needed gems" },
1682 { CA_SET_LEVEL_WIND, "set wind dir." },
1683 { CA_UNDEFINED, " " },
1684 { CA_HEADLINE_PLAYER_ACTIONS, "[player actions]" },
1685 { CA_MOVE_PLAYER, "move player" },
1686 { CA_EXIT_PLAYER, "exit player" },
1687 { CA_KILL_PLAYER, "kill player" },
1688 { CA_SET_PLAYER_KEYS, "set keys" },
1689 { CA_SET_PLAYER_SPEED, "set speed" },
1690 { CA_SET_PLAYER_SHIELD, "set shield" },
1691 { CA_SET_PLAYER_GRAVITY, "set gravity" },
1692 { CA_SET_PLAYER_ARTWORK, "set artwork" },
1693 { CA_UNDEFINED, " " },
1694 { CA_HEADLINE_CE_ACTIONS, "[CE actions]" },
1695 { CA_SET_CE_VALUE, "set CE value" },
1696 { CA_SET_CE_SCORE, "set CE score" },
1697 { CA_UNDEFINED, " " },
1698 { CA_HEADLINE_ENGINE_ACTIONS, "[engine actions]" },
1699 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
1704 static struct ValueTextInfo options_action_mode_none[] =
1706 { CA_MODE_UNDEFINED, " " },
1711 static struct ValueTextInfo options_action_mode_assign[] =
1713 { CA_MODE_SET, "=" },
1718 static struct ValueTextInfo options_action_mode_add_remove[] =
1720 { CA_MODE_ADD, "+" },
1721 { CA_MODE_SUBTRACT, "-" },
1726 static struct ValueTextInfo options_action_mode_calculate[] =
1728 { CA_MODE_SET, "=" },
1729 { CA_MODE_ADD, "+" },
1730 { CA_MODE_SUBTRACT, "-" },
1731 { CA_MODE_MULTIPLY, "*" },
1732 { CA_MODE_DIVIDE, "/" },
1733 { CA_MODE_MODULO, "%" },
1738 static struct ValueTextInfo options_action_arg_none[] =
1740 { CA_ARG_UNDEFINED, " " },
1745 static struct ValueTextInfo options_action_arg_player[] =
1747 { CA_ARG_PLAYER_HEADLINE, "[player]" },
1748 { CA_ARG_PLAYER_1, "1" },
1749 { CA_ARG_PLAYER_2, "2" },
1750 { CA_ARG_PLAYER_3, "3" },
1751 { CA_ARG_PLAYER_4, "4" },
1752 { CA_ARG_PLAYER_ANY, "any" },
1753 { CA_ARG_PLAYER_TRIGGER, "trigger" },
1758 static struct ValueTextInfo options_action_arg_number[] =
1760 { CA_ARG_NUMBER_HEADLINE, "[number]" },
1767 { CA_ARG_10, "10" },
1768 { CA_ARG_100, "100" },
1769 { CA_ARG_1000, "1000" },
1770 { CA_ARG_UNDEFINED, " " },
1771 { CA_ARG_NUMBER_MIN, "min" },
1772 { CA_ARG_NUMBER_MAX, "max" },
1773 { CA_ARG_UNDEFINED, " " },
1774 { CA_ARG_NUMBER_RESET, "reset" },
1775 { CA_ARG_UNDEFINED, " " },
1776 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
1777 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
1778 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
1779 { CA_ARG_UNDEFINED, " " },
1780 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
1781 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
1782 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
1783 { CA_ARG_UNDEFINED, " " },
1784 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
1785 { CA_ARG_ELEMENT_CV_TARGET, "target" },
1786 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
1787 { CA_ARG_UNDEFINED, " " },
1788 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
1789 { CA_ARG_ELEMENT_CS_TARGET, "target" },
1790 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
1795 static struct ValueTextInfo options_action_arg_value[] =
1797 { CA_ARG_NUMBER_HEADLINE, "[number]" },
1804 { CA_ARG_10, "10" },
1805 { CA_ARG_100, "100" },
1806 { CA_ARG_1000, "1000" },
1807 { CA_ARG_UNDEFINED, " " },
1808 { CA_ARG_NUMBER_MIN, "min" },
1809 { CA_ARG_NUMBER_MAX, "max" },
1810 { CA_ARG_UNDEFINED, " " },
1811 { CA_ARG_NUMBER_RESET, "reset" },
1812 { CA_ARG_UNDEFINED, " " },
1813 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
1814 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
1815 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
1816 { CA_ARG_UNDEFINED, " " },
1817 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
1818 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
1819 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
1820 { CA_ARG_UNDEFINED, " " },
1821 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
1822 { CA_ARG_ELEMENT_CV_TARGET, "target" },
1823 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
1824 { CA_ARG_UNDEFINED, " " },
1825 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
1826 { CA_ARG_ELEMENT_CS_TARGET, "target" },
1827 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
1828 { CA_ARG_UNDEFINED, " " },
1829 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
1830 { CA_ARG_ELEMENT_NR_TARGET, "target" },
1831 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
1836 static struct ValueTextInfo options_action_arg_envelope[] =
1838 { CA_ARG_NUMBER_HEADLINE, "[number]" },
1843 { CA_ARG_UNDEFINED, " " },
1844 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
1845 { CA_ARG_ELEMENT_TARGET, "target" },
1846 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
1851 static struct ValueTextInfo options_action_arg_key[] =
1853 { CA_ARG_NUMBER_HEADLINE, "[number]" },
1862 { CA_ARG_UNDEFINED, " " },
1863 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
1864 { CA_ARG_ELEMENT_TARGET, "target" },
1865 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
1870 static struct ValueTextInfo options_action_arg_speed[] =
1872 { CA_ARG_SPEED_HEADLINE, "[speed]" },
1873 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
1874 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
1875 { CA_ARG_SPEED_SLOW, "slow" },
1876 { CA_ARG_SPEED_NORMAL, "normal" },
1877 { CA_ARG_SPEED_FAST, "fast" },
1878 { CA_ARG_SPEED_VERY_FAST, "very fast" },
1879 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
1880 { CA_ARG_UNDEFINED, " " },
1881 { CA_ARG_SPEED_SLOWER, "slower" },
1882 { CA_ARG_SPEED_FASTER, "faster" },
1883 { CA_ARG_UNDEFINED, " " },
1884 { CA_ARG_SPEED_RESET, "reset" },
1889 static struct ValueTextInfo options_action_arg_shield[] =
1891 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
1892 { CA_ARG_SHIELD_OFF, "off" },
1893 { CA_ARG_SHIELD_NORMAL, "normal" },
1894 { CA_ARG_SHIELD_DEADLY, "deadly" },
1899 static struct ValueTextInfo options_action_arg_artwork[] =
1901 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
1902 { CA_ARG_ELEMENT_TARGET, "target" },
1903 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
1904 { CA_ARG_UNDEFINED, " " },
1905 { CA_ARG_ELEMENT_RESET, "reset" },
1910 static struct ValueTextInfo options_action_arg_gravity[] =
1912 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
1913 { CA_ARG_GRAVITY_ON, "on" },
1914 { CA_ARG_GRAVITY_OFF, "off" },
1915 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
1920 static struct ValueTextInfo options_action_arg_direction[] =
1922 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
1923 { CA_ARG_DIRECTION_NONE, "none" },
1924 { CA_ARG_DIRECTION_LEFT, "left" },
1925 { CA_ARG_DIRECTION_RIGHT, "right" },
1926 { CA_ARG_DIRECTION_UP, "up" },
1927 { CA_ARG_DIRECTION_DOWN, "down" },
1928 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
1929 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
1934 static struct ValueTextInfo options_action_arg_scan_mode[] =
1936 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
1937 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
1938 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
1943 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
1944 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
1949 static struct ValueTextInfo options_group_choice_mode[] =
1951 { ANIM_RANDOM, "random" },
1952 { ANIM_LOOP, "loop" },
1953 { ANIM_LINEAR, "linear" },
1954 { ANIM_PINGPONG, "pingpong" },
1955 { ANIM_PINGPONG2, "pingpong 2" },
1960 static struct ValueTextInfo *action_arg_modes[] =
1962 options_action_mode_none,
1963 options_action_mode_assign,
1964 options_action_mode_add_remove,
1965 options_action_mode_calculate,
1972 struct ValueTextInfo *options;
1974 action_arg_options[] =
1976 { CA_NO_ACTION, 0, options_action_arg_none, },
1977 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
1978 { CA_KILL_PLAYER, 0, options_action_arg_player, },
1979 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
1980 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
1981 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
1982 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
1983 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
1984 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
1985 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
1986 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
1987 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
1988 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
1989 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
1990 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
1991 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
1992 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
1993 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2002 int gadget_id_align;
2003 int size; /* char size of selectbox or '-1' (dynamically determined) */
2004 struct ValueTextInfo *options;
2006 char *text_left, *text_right, *infotext;
2007 } selectbox_info[ED_NUM_SELECTBOX] =
2009 /* ---------- level and editor settings ---------------------------------- */
2012 -1, ED_LEVEL_SETTINGS_YPOS(7),
2013 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2015 options_time_or_steps,
2016 &level.use_step_counter,
2017 NULL, "(0 => no limit)", "time or step limit"
2020 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
2021 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2023 options_game_engine_type,
2024 &level.game_engine_type,
2025 "game engine:", NULL, "game engine"
2028 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2029 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2031 options_wind_direction,
2032 &level.wind_direction_initial,
2033 "initial wind direction:", NULL, "initial wind direction"
2036 /* ---------- element settings: configure (several elements) ------------- */
2039 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
2040 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2042 options_player_speed,
2043 &level.initial_player_stepsize[0],
2044 "initial player speed:", NULL, "initial player speed"
2047 /* ---------- element settings: configure 1 (custom elements) ------------ */
2050 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2051 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2053 options_access_type,
2054 &custom_element.access_type,
2055 NULL, NULL, "type of access to this field"
2058 -1, ED_ELEMENT_SETTINGS_YPOS(3),
2059 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2061 options_access_layer,
2062 &custom_element.access_layer,
2063 NULL, NULL, "layer of access for this field"
2066 -1, ED_ELEMENT_SETTINGS_YPOS(3),
2067 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2069 options_access_protected,
2070 &custom_element.access_protected,
2071 NULL, NULL, "protected access for this field"
2074 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2075 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2077 options_access_direction,
2078 &custom_element.access_direction,
2079 "from", NULL, "access direction for this field"
2082 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
2083 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2085 options_walk_to_action,
2086 &custom_element.walk_to_action,
2087 NULL, NULL, "diggable/collectible/pushable"
2090 /* ---------- element settings: configure 2 (custom elements) ------------ */
2093 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2094 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2096 options_move_pattern,
2097 &custom_element.move_pattern,
2098 "can move", NULL, "element move pattern"
2101 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2102 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2104 options_move_direction,
2105 &custom_element.move_direction_initial,
2106 "starts moving", NULL, "initial element move direction"
2109 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2110 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2112 options_move_stepsize,
2113 &custom_element.move_stepsize,
2114 "move/fall speed", NULL, "speed of element movement"
2117 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2118 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2120 options_move_leave_type,
2121 &custom_element.move_leave_type,
2122 "can dig: can", ":", "leave behind or change element"
2125 -1, ED_ELEMENT_SETTINGS_YPOS(7),
2126 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2128 options_smash_targets,
2129 &custom_element.smash_targets,
2130 "can smash", NULL, "elements that can be smashed"
2133 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
2134 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2136 options_slippery_type,
2137 &custom_element.slippery_type,
2138 "slippery", NULL, "where other elements fall down"
2141 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2142 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2145 &custom_element.deadliness,
2146 "deadly when", NULL, "deadliness of element"
2149 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2150 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2152 options_explosion_type,
2153 &custom_element.explosion_type,
2154 "can explode", NULL, "explosion type"
2157 /* ---------- element settings: advanced (custom elements) --------------- */
2160 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2161 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2164 &custom_element_change.delay_frames,
2165 "delay time given in", NULL, "delay time units for change"
2168 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2169 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2171 options_change_direct_action,
2172 &custom_element_change.direct_action,
2173 NULL, NULL, "type of direct action"
2176 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2177 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2179 options_change_other_action,
2180 &custom_element_change.other_action,
2181 NULL, "element:", "type of other element action"
2184 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2185 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2187 options_change_trigger_side,
2188 &custom_element_change.trigger_side,
2189 "at", "side", "element side triggering change"
2192 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2193 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2195 options_change_trigger_player,
2196 &custom_element_change.trigger_player,
2197 "player:", " ", "player that causes change"
2200 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2201 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2203 options_change_trigger_page,
2204 &custom_element_change.trigger_page,
2205 "page:", NULL, "change page that causes change"
2208 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2209 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2211 options_change_replace_when,
2212 &custom_element_change.replace_when,
2213 "replace when", NULL, "which elements can be replaced"
2216 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2217 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2219 options_action_type,
2220 &custom_element_change.action_type,
2221 NULL, NULL, "action on specified condition"
2224 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2225 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2227 options_action_mode_none,
2228 &custom_element_change.action_mode,
2229 NULL, NULL, "action operator"
2232 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2233 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2235 options_action_arg_none,
2236 &custom_element_change.action_arg,
2237 NULL, NULL, "action parameter"
2240 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2241 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2243 options_change_page,
2244 &custom_element.current_change_page,
2245 NULL, NULL, "element change page"
2248 /* ---------- element settings: configure (group elements) --------------- */
2251 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
2252 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2254 options_group_choice_mode,
2255 &group_element_info.choice_mode,
2256 "choice type:", NULL, "type of group element choice"
2264 int gadget_id_align;
2267 char *text_left, *text_right, *infotext;
2268 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2271 ED_ELEMENT_SETTINGS_XPOS(0), ED_COUNTER_YPOS(1),
2272 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
2274 NULL, NULL, "Show information about element"
2277 ED_ELEMENT_SETTINGS_XPOS(0) + 124, ED_COUNTER_YPOS(1),
2278 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_NONE,
2280 NULL, NULL, "Configure element properties"
2283 ED_ELEMENT_SETTINGS_XPOS(0) + 124, ED_COUNTER_YPOS(1),
2284 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_NONE,
2286 NULL, NULL, "Configure custom element properties"
2289 ED_ELEMENT_SETTINGS_XPOS(0) + 248, ED_COUNTER_YPOS(1),
2290 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_NONE,
2292 NULL, NULL, "Configure custom element properties"
2295 ED_ELEMENT_SETTINGS_XPOS(0) + 372, ED_COUNTER_YPOS(1),
2296 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_NONE,
2298 NULL, NULL, "Custom element change configuration"
2301 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2302 GADGET_ID_SAVE_AS_TEMPLATE, GADGET_ID_CUSTOM_USE_TEMPLATE,
2304 " ", "As Template", "Save current settings as new template"
2307 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2308 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
2310 NULL, NULL, "Add new change page"
2313 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2314 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
2316 NULL, NULL, "Delete current change page"
2326 int gadget_id_align;
2327 char *text_left, *text_right, *infotext;
2328 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
2331 ED_BUTTON_MINUS_XPOS, ED_BUTTON_COUNT_YPOS,
2332 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
2333 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
2334 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
2335 NULL, NULL, "select previous change page"
2338 ED_BUTTON_PLUS_XPOS, ED_BUTTON_COUNT_YPOS,
2339 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2340 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
2341 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
2342 NULL, "change page", "select next change page"
2345 ED_COPY_CHANGE_PAGE_XPOS, ED_COPY_CHANGE_PAGE_YPOS,
2346 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2347 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
2348 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
2349 " ", NULL, "copy settings from this change page"
2352 ED_PASTE_CHANGE_PAGE_XPOS, ED_PASTE_CHANGE_PAGE_YPOS,
2353 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2354 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
2355 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
2356 NULL, NULL, "paste settings to this change page"
2366 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
2369 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 0 * ED_SCROLLBUTTON_YSIZE,
2370 ED_SCROLL_UP_XPOS, ED_SCROLL_UP_YPOS,
2371 GADGET_ID_SCROLL_UP,
2372 "scroll level editing area up"
2375 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 1 * ED_SCROLLBUTTON_YSIZE,
2376 ED_SCROLL_DOWN_XPOS, ED_SCROLL_DOWN_YPOS,
2377 GADGET_ID_SCROLL_DOWN,
2378 "scroll level editing area down"
2381 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 2 * ED_SCROLLBUTTON_YSIZE,
2382 ED_SCROLL_LEFT_XPOS, ED_SCROLL_LEFT_YPOS,
2383 GADGET_ID_SCROLL_LEFT,
2384 "scroll level editing area left"
2387 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 3 * ED_SCROLLBUTTON_YSIZE,
2388 ED_SCROLL_RIGHT_XPOS, ED_SCROLL_RIGHT_YPOS,
2389 GADGET_ID_SCROLL_RIGHT,
2390 "scroll level editing area right"
2393 ED_SCROLLBUTTON2_XPOS, ED_SCROLLBUTTON2_YPOS + 0 * ED_SCROLLBUTTON2_YSIZE,
2394 ED_SCROLL2_UP_XPOS, ED_SCROLL2_UP_YPOS,
2395 GADGET_ID_SCROLL_LIST_UP,
2396 "scroll element list up ('Page Up')"
2399 ED_SCROLLBUTTON2_XPOS, ED_SCROLLBUTTON2_YPOS + 1 * ED_SCROLLBUTTON2_YSIZE,
2400 ED_SCROLL2_DOWN_XPOS, ED_SCROLL2_DOWN_YPOS,
2401 GADGET_ID_SCROLL_LIST_DOWN,
2402 "scroll element list down ('Page Down')"
2411 int wheel_x, wheel_y;
2412 int wheel_width, wheel_height;
2416 } scrollbar_info[ED_NUM_SCROLLBARS] =
2419 ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
2420 SX + ED_SCROLL_HORIZONTAL_XPOS, SY + ED_SCROLL_HORIZONTAL_YPOS,
2421 ED_SCROLL_HORIZONTAL_XSIZE, ED_SCROLL_HORIZONTAL_YSIZE,
2427 SX + SXSIZE + SX, WIN_YSIZE,
2429 GD_TYPE_SCROLLBAR_HORIZONTAL,
2430 GADGET_ID_SCROLL_HORIZONTAL,
2431 "scroll level editing area horizontally"
2434 ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
2435 SX + ED_SCROLL_VERTICAL_XPOS, SY + ED_SCROLL_VERTICAL_YPOS,
2436 ED_SCROLL_VERTICAL_XSIZE, ED_SCROLL_VERTICAL_YSIZE,
2442 SX + SXSIZE + SX, WIN_YSIZE,
2444 GD_TYPE_SCROLLBAR_VERTICAL,
2445 GADGET_ID_SCROLL_VERTICAL,
2446 "scroll level editing area vertically"
2449 ED_SCROLLBAR2_XPOS, ED_SCROLLBAR2_YPOS,
2450 DX + ED_SCROLL2_VERTICAL_XPOS, DY + ED_SCROLL2_VERTICAL_YPOS,
2451 ED_SCROLL2_VERTICAL_XSIZE, ED_SCROLL2_VERTICAL_YSIZE,
2456 SX + SXSIZE + SX, 0,
2457 WIN_XSIZE - (SX + SXSIZE + SX), WIN_YSIZE,
2459 GD_TYPE_SCROLLBAR_VERTICAL,
2460 GADGET_ID_SCROLL_LIST_VERTICAL,
2461 "scroll element list vertically"
2469 int gadget_id_align;
2470 int radio_button_nr;
2473 char *text_left, *text_right, *infotext;
2474 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
2477 -1, ED_COUNTER2_YPOS(8),
2478 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
2479 RADIO_NR_RANDOM_ELEMENTS,
2480 &random_placement_method, RANDOM_USE_PERCENTAGE,
2481 " ", "percentage", "use percentage for random elements"
2484 -1, ED_COUNTER2_YPOS(8),
2485 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
2486 RADIO_NR_RANDOM_ELEMENTS,
2487 &random_placement_method, RANDOM_USE_QUANTITY,
2488 " ", "quantity", "use quantity for random elements"
2496 int gadget_id_align;
2498 char *text_left, *text_right, *infotext;
2499 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
2501 /* ---------- level and editor settings ---------------------------------- */
2504 ED_LEVEL_SETTINGS_XPOS(0), ED_COUNTER2_YPOS(9) - MINI_TILEY,
2505 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
2506 &random_placement_background_restricted,
2508 "restrict random placement to:", "set random placement restriction"
2511 /* ---------- element settings: configure (various elements) ------------- */
2514 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2515 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
2516 &stick_element_properties_window,
2518 "stick this screen to edit content","stick this screen to edit content"
2521 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2522 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
2523 &level.em_slippery_gems,
2525 "slip down from certain flat walls","use EM/DC style slipping behaviour"
2528 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2529 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
2530 &level.use_spring_bug,
2532 "use spring pushing bug", "use odd spring pushing behaviour"
2535 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2536 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
2537 &level.use_time_orb_bug,
2539 "use time orb bug", "use odd time orb behaviour"
2542 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2543 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
2546 "create single random element", "only create one element from content"
2549 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2550 GADGET_ID_INITIAL_BALL_STATE, GADGET_ID_NONE,
2551 &level.ball_state_initial,
2553 "magic ball initially activated", "activate magic ball after level start"
2556 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2557 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
2558 &level.grow_into_diggable,
2560 "can grow into anything diggable", "grow into more than just sand"
2563 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
2564 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
2565 &level.continuous_snapping,
2567 "continuos snapping", "use snapping without releasing key"
2570 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2571 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
2572 &level.block_snap_field,
2574 "block snapped field when snapping", "use snapping delay to show animation"
2577 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2578 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
2579 &level.block_last_field,
2581 "block last field when moving", "player blocks last field when moving"
2584 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2585 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
2586 &level.sp_block_last_field,
2588 "block last field when moving", "player blocks last field when moving"
2591 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
2592 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
2593 &level.instant_relocation,
2595 "no scrolling when relocating", "player gets relocated without delay"
2598 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2599 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
2600 &level.shifted_relocation,
2602 "no centering when relocating", "level not centered after relocation"
2605 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
2606 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
2607 &level.use_start_element[0],
2609 "use level start element:", "start level at this element's position"
2612 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
2613 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
2614 &level.use_artwork_element[0],
2616 "use artwork from element:", "use player artwork from other element"
2619 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
2620 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
2621 &level.use_explosion_element[0],
2623 "use explosion from element:", "use explosion properties from element"
2626 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
2627 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
2628 &level.initial_player_gravity[0],
2630 "use initial gravity", "set initial player gravity"
2633 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
2634 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
2635 &level.can_pass_to_walkable,
2637 "can pass to walkable element", "player can pass to empty or walkable"
2640 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2641 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
2642 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
2644 "can fall into acid (with gravity)","player can fall into acid pool"
2647 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2648 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
2649 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
2651 "can move into acid", "element can move into acid pool"
2654 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2655 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
2656 &custom_element_properties[EP_DONT_COLLIDE_WITH],
2658 "deadly when colliding with", "element is deadly when hitting player"
2661 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2662 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
2663 &level.envelope[0].autowrap,
2665 "auto-wrap", "automatically wrap envelope text"
2668 -1, ED_ELEMENT_SETTINGS_YPOS(1),
2669 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
2670 &level.envelope[0].centered,
2672 "centered", "automatically center envelope text"
2675 /* ---------- element settings: configure 1 (custom elements) ----------- */
2678 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2679 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
2680 &custom_element.use_gfx_element,
2682 /* !!! add separate "use existing element sound" !!! */
2685 "use graphic/sound of element:", "use existing graphic and sound"
2688 "use graphic of element:", "use existing element graphic"
2692 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2693 GADGET_ID_CUSTOM_USE_TEMPLATE, GADGET_ID_NONE,
2694 &level.use_custom_template,
2696 "use template", "use template for custom properties"
2699 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
2700 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
2701 &custom_element_properties[EP_ACCESSIBLE],
2703 NULL, "player can walk to or pass this field"
2706 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
2707 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
2708 &custom_element_properties[EP_GRAVITY_REACHABLE],
2710 "reachable despite gravity", "player can walk/dig despite gravity"
2713 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
2714 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
2715 &custom_element.use_last_ce_value,
2717 "use last CE value after change", "use last CE value after change"
2720 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
2721 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
2722 &custom_element_properties[EP_WALK_TO_OBJECT],
2724 NULL, "player can dig/collect/push element"
2727 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
2728 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
2729 &custom_element_properties[EP_INDESTRUCTIBLE],
2731 "indestructible", "element is indestructible"
2734 /* ---------- element settings: configure 2 (custom elements) ----------- */
2737 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2738 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
2739 &custom_element_properties[EP_CAN_MOVE],
2741 NULL, "element can move with some pattern"
2744 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2745 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
2746 &custom_element_properties[EP_CAN_FALL],
2748 "can fall", "element can fall down"
2751 -1, ED_ELEMENT_SETTINGS_YPOS(7),
2752 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
2753 &custom_element_properties[EP_CAN_SMASH],
2755 NULL, "element can smash other elements"
2758 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
2759 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
2760 &custom_element_properties[EP_SLIPPERY],
2762 NULL, "other elements can fall down from it"
2765 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
2766 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
2767 &custom_element_properties[EP_DEADLY],
2769 NULL, "element can kill the player"
2772 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
2773 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
2774 &custom_element_properties[EP_CAN_EXPLODE],
2776 NULL, "element can explode"
2779 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
2780 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
2781 &custom_element_properties[EP_EXPLODES_BY_FIRE],
2783 "by fire", "element can explode by fire/explosion"
2786 -1, ED_ELEMENT_SETTINGS_YPOS(11),
2787 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
2788 &custom_element_properties[EP_EXPLODES_SMASHED],
2790 "smashed", "element can explode when smashed"
2793 -1, ED_ELEMENT_SETTINGS_YPOS(11),
2794 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
2795 &custom_element_properties[EP_EXPLODES_IMPACT],
2797 "impact", "element can explode on impact"
2800 /* ---------- element settings: advanced (custom elements) --------------- */
2803 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2804 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
2805 &custom_element_change.can_change,
2807 "element changes to:", "change element on specified condition"
2810 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2811 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
2812 &custom_element_change_events[CE_DELAY],
2814 NULL, "element changes after delay"
2817 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2818 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
2819 &custom_element_change_events[CE_BY_DIRECT_ACTION],
2821 NULL, "element changes by direct action"
2824 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
2825 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
2826 &custom_element_change_events[CE_BY_OTHER_ACTION],
2828 NULL, "element changes by other element"
2831 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
2832 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
2833 &custom_element_change.explode,
2835 "explode instead of change", "element explodes instead of change"
2838 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2839 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
2840 &custom_element_change.use_target_content,
2842 "use extended change target:", "element changes to more elements"
2845 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
2846 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
2847 &custom_element_change.only_if_complete,
2849 "replace all or nothing", "only replace when all can be changed"
2852 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
2853 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
2854 &custom_element_change.use_random_replace,
2856 NULL, "use percentage for random replace"
2859 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
2860 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
2861 &custom_element_change.has_action,
2863 NULL, "execute action on specified condition"
2871 int gadget_id_align;
2873 int area_xsize, area_ysize;
2874 char *text_left, *text_right, *text_below, *infotext;
2875 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
2877 /* ---------- level playfield content ------------------------------------ */
2881 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
2882 NULL, MAX_ED_FIELDX, MAX_ED_FIELDY,
2883 NULL, NULL, NULL, NULL
2886 /* ---------- yam yam content -------------------------------------------- */
2889 ED_AREA_YAMYAM_CONTENT_XPOS(0), ED_AREA_YAMYAM_CONTENT_YPOS(0),
2890 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
2891 &level.yamyam_content[0].e[0][0], 3, 3,
2892 NULL, NULL, "1", NULL
2895 ED_AREA_YAMYAM_CONTENT_XPOS(1), ED_AREA_YAMYAM_CONTENT_YPOS(1),
2896 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
2897 &level.yamyam_content[1].e[0][0], 3, 3,
2898 NULL, NULL, "2", NULL
2901 ED_AREA_YAMYAM_CONTENT_XPOS(2), ED_AREA_YAMYAM_CONTENT_YPOS(2),
2902 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
2903 &level.yamyam_content[2].e[0][0], 3, 3,
2904 NULL, NULL, "3", NULL
2907 ED_AREA_YAMYAM_CONTENT_XPOS(3), ED_AREA_YAMYAM_CONTENT_YPOS(3),
2908 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
2909 &level.yamyam_content[3].e[0][0], 3, 3,
2910 NULL, NULL, "4", NULL
2913 ED_AREA_YAMYAM_CONTENT_XPOS(4), ED_AREA_YAMYAM_CONTENT_YPOS(4),
2914 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
2915 &level.yamyam_content[4].e[0][0], 3, 3,
2916 NULL, NULL, "5", NULL
2919 ED_AREA_YAMYAM_CONTENT_XPOS(5), ED_AREA_YAMYAM_CONTENT_YPOS(5),
2920 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
2921 &level.yamyam_content[5].e[0][0], 3, 3,
2922 NULL, NULL, "6", NULL
2925 ED_AREA_YAMYAM_CONTENT_XPOS(6), ED_AREA_YAMYAM_CONTENT_YPOS(6),
2926 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
2927 &level.yamyam_content[6].e[0][0], 3, 3,
2928 NULL, NULL, "7", NULL
2931 ED_AREA_YAMYAM_CONTENT_XPOS(7), ED_AREA_YAMYAM_CONTENT_YPOS(7),
2932 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
2933 &level.yamyam_content[7].e[0][0], 3, 3,
2934 NULL, NULL, "8", NULL
2937 /* ---------- magic ball content ----------------------------------------- */
2940 ED_AREA_MAGIC_BALL_CONTENT_XPOS(0), ED_AREA_MAGIC_BALL_CONTENT_YPOS(0),
2941 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
2942 &level.ball_content[0].e[0][0], 3, 3,
2943 NULL, NULL, "1", NULL
2946 ED_AREA_MAGIC_BALL_CONTENT_XPOS(1), ED_AREA_MAGIC_BALL_CONTENT_YPOS(1),
2947 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
2948 &level.ball_content[1].e[0][0], 3, 3,
2949 NULL, NULL, "2", NULL
2952 ED_AREA_MAGIC_BALL_CONTENT_XPOS(2), ED_AREA_MAGIC_BALL_CONTENT_YPOS(2),
2953 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
2954 &level.ball_content[2].e[0][0], 3, 3,
2955 NULL, NULL, "3", NULL
2958 ED_AREA_MAGIC_BALL_CONTENT_XPOS(3), ED_AREA_MAGIC_BALL_CONTENT_YPOS(3),
2959 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
2960 &level.ball_content[3].e[0][0], 3, 3,
2961 NULL, NULL, "4", NULL
2964 ED_AREA_MAGIC_BALL_CONTENT_XPOS(4), ED_AREA_MAGIC_BALL_CONTENT_YPOS(4),
2965 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
2966 &level.ball_content[4].e[0][0], 3, 3,
2967 NULL, NULL, "5", NULL
2970 ED_AREA_MAGIC_BALL_CONTENT_XPOS(5), ED_AREA_MAGIC_BALL_CONTENT_YPOS(5),
2971 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
2972 &level.ball_content[5].e[0][0], 3, 3,
2973 NULL, NULL, "6", NULL
2976 ED_AREA_MAGIC_BALL_CONTENT_XPOS(6), ED_AREA_MAGIC_BALL_CONTENT_YPOS(6),
2977 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
2978 &level.ball_content[6].e[0][0], 3, 3,
2979 NULL, NULL, "7", NULL
2982 ED_AREA_MAGIC_BALL_CONTENT_XPOS(7), ED_AREA_MAGIC_BALL_CONTENT_YPOS(7),
2983 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
2984 &level.ball_content[7].e[0][0], 3, 3,
2985 NULL, NULL, "8", NULL
2988 /* ---------- android content -------------------------------------------- */
2991 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(5),
2992 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
2993 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
2994 "elements:", NULL, NULL, "elements android can clone"
2997 /* ---------- amoeba content --------------------------------------------- */
3000 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
3001 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
3002 &level.amoeba_content, 1, 1,
3003 "content:", NULL, NULL, "amoeba content"
3006 /* ---------- level start element ---------------------------------------- */
3009 -1, ED_AREA_1X1_SETTINGS_YPOS(9),
3010 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
3011 &level.start_element[0], 1, 1,
3012 NULL, NULL, NULL, "level start element"
3015 /* ---------- player artwork element ------------------------------------- */
3018 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
3019 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
3020 &level.artwork_element[0], 1, 1,
3021 NULL, NULL, NULL, "element for player artwork"
3024 /* ---------- player explosion element ----------------------------------- */
3027 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
3028 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
3029 &level.explosion_element[0], 1, 1,
3030 NULL, NULL, NULL, "element for player explosion"
3033 /* ---------- element settings: configure 1 (custom elements) ----------- */
3035 /* ---------- custom graphic --------------------------------------------- */
3038 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3039 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
3040 &custom_element.gfx_element, 1, 1,
3041 NULL, NULL, NULL, "custom graphic element"
3044 /* ---------- element settings: configure 2 (custom elements) ----------- */
3046 /* ---------- custom content (when exploding) ---------------------------- */
3049 -1, ED_AREA_3X3_SETTINGS_YPOS(10),
3050 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, /* align three rows */
3051 &custom_element.content.e[0][0], 3, 3,
3052 "content:", NULL, NULL, NULL
3055 /* ---------- custom enter and leave element (when moving) --------------- */
3058 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
3059 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
3060 &custom_element.move_enter_element, 1, 1,
3061 "can dig:", " ", NULL, "element that can be digged/collected"
3064 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
3065 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
3066 &custom_element.move_leave_element, 1, 1,
3067 NULL, NULL, NULL, "element that will be left behind"
3070 /* ---------- element settings: advanced (custom elements) --------------- */
3072 /* ---------- custom change target --------------------------------------- */
3075 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3076 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
3077 &custom_element_change.target_element, 1, 1,
3078 NULL, "after/when:", NULL, "new target element after change"
3081 /* ---------- custom change content (extended change target) ------------- */
3084 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
3085 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, /* align three rows */
3086 &custom_element_change.target_content.e[0][0], 3, 3,
3087 NULL, NULL, NULL, "new extended elements after change"
3090 /* ---------- custom change trigger (element causing change) ------------- */
3093 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
3094 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
3095 &custom_element_change.trigger_element, 1, 1,
3096 NULL, NULL, NULL, "other element triggering change"
3099 /* ---------- group element content -------------------------------------- */
3102 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(4),
3103 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
3104 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
3105 "content:", NULL, NULL, NULL
3108 /* ---------- random background (for random painting) -------------------- */
3111 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3112 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
3113 &random_placement_background_element, 1, 1,
3114 NULL, NULL, NULL, "random placement background"
3120 -----------------------------------------------------------------------------
3121 some internally used variables
3122 -----------------------------------------------------------------------------
3125 /* actual size of level editor drawing area */
3126 static int ed_fieldx = MAX_ED_FIELDX - 1, ed_fieldy = MAX_ED_FIELDY - 1;
3128 /* actual position of level editor drawing area in level playfield */
3129 static int level_xpos = -1, level_ypos = -1;
3132 #define IN_ED_FIELD(x,y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
3134 #define IN_ED_FIELD(x,y) ((x)>=0 && (x)<ed_fieldx && (y)>=0 &&(y)<ed_fieldy)
3137 /* drawing elements on the three mouse buttons */
3138 static int new_element1 = EL_WALL;
3139 static int new_element2 = EL_EMPTY;
3140 static int new_element3 = EL_SAND;
3142 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
3143 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
3144 (button) == 2 ? new_element2 : \
3145 (button) == 3 ? new_element3 : EL_EMPTY)
3146 #define BUTTON_STEPSIZE(button) ((button) == 1 ? 1 : (button) == 2 ? 5 : 10)
3148 /* forward declaration for internal use */
3149 static void ModifyEditorCounterValue(int, int);
3150 static void ModifyEditorCounterLimits(int, int, int);
3151 static void ModifyEditorSelectboxValue(int, int);
3152 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
3153 static void ModifyEditorDrawingArea(int, int, int);
3154 static void ModifyEditorElementList();
3155 static void AdjustElementListScrollbar();
3156 static void RedrawDrawingElements();
3157 static void DrawDrawingWindow();
3158 static void DrawLevelInfoWindow();
3159 static void DrawPropertiesWindow();
3160 static void UpdateCustomElementGraphicGadgets();
3161 static boolean checkPropertiesConfig(int);
3162 static void CopyLevelToUndoBuffer(int);
3163 static void HandleDrawingAreas(struct GadgetInfo *);
3164 static void HandleCounterButtons(struct GadgetInfo *);
3165 static void HandleTextInputGadgets(struct GadgetInfo *);
3166 static void HandleTextAreaGadgets(struct GadgetInfo *);
3167 static void HandleSelectboxGadgets(struct GadgetInfo *);
3168 static void HandleTextbuttonGadgets(struct GadgetInfo *);
3169 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
3170 static void HandleRadiobuttons(struct GadgetInfo *);
3171 static void HandleCheckbuttons(struct GadgetInfo *);
3172 static void HandleControlButtons(struct GadgetInfo *);
3173 static void HandleDrawingAreaInfo(struct GadgetInfo *);
3174 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
3176 static struct GadgetInfo *level_editor_gadget[NUM_EDITOR_GADGETS];
3177 static int right_gadget_border[NUM_EDITOR_GADGETS];
3179 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
3180 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
3181 static boolean draw_with_brush = FALSE;
3182 static int properties_element = 0;
3184 static short FieldBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3185 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3186 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3187 static int undo_buffer_position = 0;
3188 static int undo_buffer_steps = 0;
3190 static int edit_mode;
3191 static int edit_mode_properties;
3193 static int element_shift = 0;
3195 static int editor_el_players[] =
3202 static int *editor_el_players_ptr = editor_el_players;
3203 static int num_editor_el_players = SIZEOF_ARRAY_INT(editor_el_players);
3205 static int editor_hl_boulderdash[] =
3207 EL_INTERNAL_CASCADE_BD_ACTIVE,
3213 static int editor_el_boulderdash[] =
3222 EL_BD_EXPANDABLE_WALL,
3230 EL_BD_BUTTERFLY_LEFT,
3232 EL_BD_BUTTERFLY_RIGHT,
3233 EL_BD_FIREFLY_RIGHT,
3236 EL_BD_BUTTERFLY_DOWN,
3240 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
3241 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
3242 static int num_editor_hl_boulderdash = SIZEOF_ARRAY_INT(editor_hl_boulderdash);
3243 static int num_editor_el_boulderdash = SIZEOF_ARRAY_INT(editor_el_boulderdash);
3245 static int editor_hl_emerald_mine[] =
3247 EL_INTERNAL_CASCADE_EM_ACTIVE,
3253 static int editor_el_emerald_mine[] =
3290 EL_ACID_POOL_TOPLEFT,
3292 EL_ACID_POOL_TOPRIGHT,
3295 EL_ACID_POOL_BOTTOMLEFT,
3296 EL_ACID_POOL_BOTTOM,
3297 EL_ACID_POOL_BOTTOMRIGHT,
3317 EL_EM_STEEL_EXIT_CLOSED,
3318 EL_EM_STEEL_EXIT_OPEN,
3320 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
3321 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
3322 static int num_editor_hl_emerald_mine=SIZEOF_ARRAY_INT(editor_hl_emerald_mine);
3323 static int num_editor_el_emerald_mine=SIZEOF_ARRAY_INT(editor_el_emerald_mine);
3325 static int editor_hl_emerald_mine_club[] =
3327 EL_INTERNAL_CASCADE_EMC_ACTIVE,
3333 static int editor_el_emerald_mine_club[] =
3360 EL_EMC_WALL_SLIPPERY_1,
3361 EL_EMC_WALL_SLIPPERY_2,
3362 EL_EMC_WALL_SLIPPERY_3,
3363 EL_EMC_WALL_SLIPPERY_4,
3386 EL_EMC_MAGIC_BALL_SWITCH,
3388 EL_EMC_SPRING_BUMPER,
3393 EL_EM_DYNAMITE_ACTIVE,
3397 EL_BALLOON_SWITCH_UP,
3398 EL_BALLOON_SWITCH_ANY,
3401 EL_BALLOON_SWITCH_LEFT,
3403 EL_BALLOON_SWITCH_RIGHT,
3407 EL_BALLOON_SWITCH_DOWN,
3408 EL_BALLOON_SWITCH_NONE,
3410 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
3411 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
3412 static int num_editor_hl_emerald_mine_club=SIZEOF_ARRAY_INT(editor_hl_emerald_mine_club);
3413 static int num_editor_el_emerald_mine_club=SIZEOF_ARRAY_INT(editor_el_emerald_mine_club);
3415 static int editor_hl_rnd[] =
3417 EL_INTERNAL_CASCADE_RND_ACTIVE,
3423 static int editor_el_rnd[] =
3455 EL_WALL_EMERALD_YELLOW,
3456 EL_WALL_EMERALD_RED,
3457 EL_WALL_EMERALD_PURPLE,
3475 EL_DYNABOMB_INCREASE_NUMBER,
3476 EL_DYNABOMB_INCREASE_SIZE,
3477 EL_DYNABOMB_INCREASE_POWER,
3497 EL_INVISIBLE_STEELWALL,
3501 EL_EXPANDABLE_WALL_HORIZONTAL,
3502 EL_EXPANDABLE_WALL_VERTICAL,
3503 EL_EXPANDABLE_WALL_ANY,
3505 static int *editor_hl_rnd_ptr = editor_hl_rnd;
3506 static int *editor_el_rnd_ptr = editor_el_rnd;
3507 static int num_editor_hl_rnd = SIZEOF_ARRAY_INT(editor_hl_rnd);
3508 static int num_editor_el_rnd = SIZEOF_ARRAY_INT(editor_el_rnd);
3510 static int editor_hl_sokoban[] =
3512 EL_INTERNAL_CASCADE_SB_ACTIVE,
3518 static int editor_el_sokoban[] =
3521 EL_SOKOBAN_FIELD_EMPTY,
3522 EL_SOKOBAN_FIELD_FULL,
3523 EL_SOKOBAN_FIELD_PLAYER,
3525 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
3526 static int *editor_el_sokoban_ptr = editor_el_sokoban;
3527 static int num_editor_hl_sokoban = SIZEOF_ARRAY_INT(editor_hl_sokoban);
3528 static int num_editor_el_sokoban = SIZEOF_ARRAY_INT(editor_el_sokoban);
3530 static int editor_hl_supaplex[] =
3532 EL_INTERNAL_CASCADE_SP_ACTIVE,
3538 static int editor_el_supaplex[] =
3556 EL_SP_PORT_HORIZONTAL,
3557 EL_SP_PORT_VERTICAL,
3565 EL_SP_GRAVITY_PORT_LEFT,
3566 EL_SP_GRAVITY_PORT_RIGHT,
3567 EL_SP_GRAVITY_PORT_UP,
3568 EL_SP_GRAVITY_PORT_DOWN,
3570 EL_SP_HARDWARE_GRAY,
3571 EL_SP_HARDWARE_GREEN,
3572 EL_SP_HARDWARE_BLUE,
3575 EL_SP_HARDWARE_BASE_1,
3576 EL_SP_HARDWARE_BASE_2,
3577 EL_SP_HARDWARE_BASE_3,
3578 EL_SP_HARDWARE_BASE_4,
3580 EL_SP_HARDWARE_BASE_5,
3581 EL_SP_HARDWARE_BASE_6,
3582 EL_SP_HARDWARE_YELLOW,
3590 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
3591 static int *editor_el_supaplex_ptr = editor_el_supaplex;
3592 static int num_editor_hl_supaplex = SIZEOF_ARRAY_INT(editor_hl_supaplex);
3593 static int num_editor_el_supaplex = SIZEOF_ARRAY_INT(editor_el_supaplex);
3595 static int editor_hl_diamond_caves[] =
3597 EL_INTERNAL_CASCADE_DC_ACTIVE,
3603 static int editor_el_diamond_caves[] =
3610 EL_CONVEYOR_BELT_1_LEFT,
3611 EL_CONVEYOR_BELT_1_MIDDLE,
3612 EL_CONVEYOR_BELT_1_RIGHT,
3613 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
3615 EL_CONVEYOR_BELT_2_LEFT,
3616 EL_CONVEYOR_BELT_2_MIDDLE,
3617 EL_CONVEYOR_BELT_2_RIGHT,
3618 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
3620 EL_CONVEYOR_BELT_3_LEFT,
3621 EL_CONVEYOR_BELT_3_MIDDLE,
3622 EL_CONVEYOR_BELT_3_RIGHT,
3623 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
3625 EL_CONVEYOR_BELT_4_LEFT,
3626 EL_CONVEYOR_BELT_4_MIDDLE,
3627 EL_CONVEYOR_BELT_4_RIGHT,
3628 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
3630 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
3631 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
3632 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
3633 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
3635 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
3636 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
3637 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
3638 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
3643 EL_DC_TIMEGATE_SWITCH,
3645 EL_SWITCHGATE_CLOSED,
3647 EL_SWITCHGATE_SWITCH_UP,
3648 EL_SWITCHGATE_SWITCH_DOWN,
3651 EL_LIGHT_SWITCH_ACTIVE,
3652 EL_DC_SWITCHGATE_SWITCH_UP,
3653 EL_DC_SWITCHGATE_SWITCH_DOWN,
3655 EL_STEEL_EXIT_CLOSED,
3657 EL_STEELWALL_SLIPPERY,
3660 EL_QUICKSAND_FAST_EMPTY,
3661 EL_QUICKSAND_FAST_FULL,
3675 EL_SIGN_RADIOACTIVITY,
3681 EL_SIGN_ENTRY_FORBIDDEN,
3682 EL_SIGN_EMERGENCY_EXIT,
3707 EL_DC_STEELWALL_2_SINGLE,
3708 EL_DC_STEELWALL_2_TOP,
3709 EL_SIGN_EXCLAMATION,
3712 EL_DC_STEELWALL_2_LEFT,
3713 EL_DC_STEELWALL_2_MIDDLE,
3714 EL_DC_STEELWALL_2_HORIZONTAL,
3715 EL_DC_STEELWALL_2_RIGHT,
3717 EL_DC_STEELWALL_1_TOPLEFT,
3718 EL_DC_STEELWALL_2_VERTICAL,
3719 EL_DC_STEELWALL_1_TOPRIGHT,
3722 EL_DC_STEELWALL_1_VERTICAL,
3723 EL_DC_STEELWALL_2_BOTTOM,
3725 EL_DC_GATE_WHITE_GRAY,
3727 EL_DC_STEELWALL_1_BOTTOMLEFT,
3728 EL_DC_STEELWALL_1_HORIZONTAL,
3729 EL_DC_STEELWALL_1_BOTTOMRIGHT,
3730 EL_DC_GATE_FAKE_GRAY,
3732 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
3733 EL_DC_STEELWALL_1_BOTTOM,
3734 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
3735 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
3737 EL_DC_STEELWALL_1_RIGHT,
3739 EL_DC_STEELWALL_1_LEFT,
3740 EL_EXPANDABLE_STEELWALL_VERTICAL,
3742 EL_DC_STEELWALL_1_TOPRIGHT_2,
3743 EL_DC_STEELWALL_1_TOP,
3744 EL_DC_STEELWALL_1_TOPLEFT_2,
3745 EL_EXPANDABLE_STEELWALL_ANY,
3747 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
3748 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
3749 static int num_editor_hl_diamond_caves = SIZEOF_ARRAY_INT(editor_hl_diamond_caves);
3750 static int num_editor_el_diamond_caves = SIZEOF_ARRAY_INT(editor_el_diamond_caves);
3752 static int editor_hl_dx_boulderdash[] =
3754 EL_INTERNAL_CASCADE_DX_ACTIVE,
3760 static int editor_el_dx_boulderdash[] =
3764 EL_TUBE_HORIZONTAL_DOWN,
3768 EL_TUBE_VERTICAL_RIGHT,
3770 EL_TUBE_VERTICAL_LEFT,
3774 EL_TUBE_HORIZONTAL_UP,
3782 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
3783 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
3784 static int num_editor_hl_dx_boulderdash = SIZEOF_ARRAY_INT(editor_hl_dx_boulderdash);
3785 static int num_editor_el_dx_boulderdash = SIZEOF_ARRAY_INT(editor_el_dx_boulderdash);
3787 static int editor_hl_chars[] =
3789 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
3795 static int editor_el_chars[] =
3884 EL_CHAR(FONT_ASCII_CURSOR),
3885 EL_CHAR(FONT_ASCII_BUTTON),
3887 EL_CHAR(FONT_ASCII_UP),
3888 EL_CHAR(FONT_ASCII_DOWN),
3892 static int *editor_hl_chars_ptr = editor_hl_chars;
3893 static int *editor_el_chars_ptr = editor_el_chars;
3894 static int num_editor_hl_chars = SIZEOF_ARRAY_INT(editor_hl_chars);
3895 static int num_editor_el_chars = SIZEOF_ARRAY_INT(editor_el_chars);
3897 static int editor_hl_steel_chars[] =
3899 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
3905 static int editor_el_steel_chars[] =
3915 EL_STEEL_CHAR('\''),
3982 EL_STEEL_CHAR('\\'),
3987 EL_STEEL_CHAR('©'),
3988 EL_STEEL_CHAR('Ä'),
3989 EL_STEEL_CHAR('Ö'),
3990 EL_STEEL_CHAR('Ü'),
3992 EL_STEEL_CHAR('°'),
3993 EL_STEEL_CHAR('®'),
3994 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
3995 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
3997 EL_STEEL_CHAR(FONT_ASCII_UP),
3998 EL_STEEL_CHAR(FONT_ASCII_DOWN),
4002 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
4003 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
4004 static int num_editor_hl_steel_chars = SIZEOF_ARRAY_INT(editor_hl_steel_chars);
4005 static int num_editor_el_steel_chars = SIZEOF_ARRAY_INT(editor_el_steel_chars);
4007 static int editor_hl_custom[] =
4009 EL_INTERNAL_CASCADE_CE_ACTIVE,
4015 static int editor_el_custom[] =
4017 EL_CUSTOM_START + 0,
4018 EL_CUSTOM_START + 1,
4019 EL_CUSTOM_START + 2,
4020 EL_CUSTOM_START + 3,
4022 EL_CUSTOM_START + 4,
4023 EL_CUSTOM_START + 5,
4024 EL_CUSTOM_START + 6,
4025 EL_CUSTOM_START + 7,
4027 EL_CUSTOM_START + 8,
4028 EL_CUSTOM_START + 9,
4029 EL_CUSTOM_START + 10,
4030 EL_CUSTOM_START + 11,
4032 EL_CUSTOM_START + 12,
4033 EL_CUSTOM_START + 13,
4034 EL_CUSTOM_START + 14,
4035 EL_CUSTOM_START + 15,
4037 EL_CUSTOM_START + 16,
4038 EL_CUSTOM_START + 17,
4039 EL_CUSTOM_START + 18,
4040 EL_CUSTOM_START + 19,
4042 EL_CUSTOM_START + 20,
4043 EL_CUSTOM_START + 21,
4044 EL_CUSTOM_START + 22,
4045 EL_CUSTOM_START + 23,
4047 EL_CUSTOM_START + 24,
4048 EL_CUSTOM_START + 25,
4049 EL_CUSTOM_START + 26,
4050 EL_CUSTOM_START + 27,
4052 EL_CUSTOM_START + 28,
4053 EL_CUSTOM_START + 29,
4054 EL_CUSTOM_START + 30,
4055 EL_CUSTOM_START + 31,
4057 EL_CUSTOM_START + 32,
4058 EL_CUSTOM_START + 33,
4059 EL_CUSTOM_START + 34,
4060 EL_CUSTOM_START + 35,
4062 EL_CUSTOM_START + 36,
4063 EL_CUSTOM_START + 37,
4064 EL_CUSTOM_START + 38,
4065 EL_CUSTOM_START + 39,
4067 EL_CUSTOM_START + 40,
4068 EL_CUSTOM_START + 41,
4069 EL_CUSTOM_START + 42,
4070 EL_CUSTOM_START + 43,
4072 EL_CUSTOM_START + 44,
4073 EL_CUSTOM_START + 45,
4074 EL_CUSTOM_START + 46,
4075 EL_CUSTOM_START + 47,
4077 EL_CUSTOM_START + 48,
4078 EL_CUSTOM_START + 49,
4079 EL_CUSTOM_START + 50,
4080 EL_CUSTOM_START + 51,
4082 EL_CUSTOM_START + 52,
4083 EL_CUSTOM_START + 53,
4084 EL_CUSTOM_START + 54,
4085 EL_CUSTOM_START + 55,
4087 EL_CUSTOM_START + 56,
4088 EL_CUSTOM_START + 57,
4089 EL_CUSTOM_START + 58,
4090 EL_CUSTOM_START + 59,
4092 EL_CUSTOM_START + 60,
4093 EL_CUSTOM_START + 61,
4094 EL_CUSTOM_START + 62,
4095 EL_CUSTOM_START + 63,
4097 EL_CUSTOM_START + 64,
4098 EL_CUSTOM_START + 65,
4099 EL_CUSTOM_START + 66,
4100 EL_CUSTOM_START + 67,
4102 EL_CUSTOM_START + 68,
4103 EL_CUSTOM_START + 69,
4104 EL_CUSTOM_START + 70,
4105 EL_CUSTOM_START + 71,
4107 EL_CUSTOM_START + 72,
4108 EL_CUSTOM_START + 73,
4109 EL_CUSTOM_START + 74,
4110 EL_CUSTOM_START + 75,
4112 EL_CUSTOM_START + 76,
4113 EL_CUSTOM_START + 77,
4114 EL_CUSTOM_START + 78,
4115 EL_CUSTOM_START + 79,
4117 EL_CUSTOM_START + 80,
4118 EL_CUSTOM_START + 81,
4119 EL_CUSTOM_START + 82,
4120 EL_CUSTOM_START + 83,
4122 EL_CUSTOM_START + 84,
4123 EL_CUSTOM_START + 85,
4124 EL_CUSTOM_START + 86,
4125 EL_CUSTOM_START + 87,
4127 EL_CUSTOM_START + 88,
4128 EL_CUSTOM_START + 89,
4129 EL_CUSTOM_START + 90,
4130 EL_CUSTOM_START + 91,
4132 EL_CUSTOM_START + 92,
4133 EL_CUSTOM_START + 93,
4134 EL_CUSTOM_START + 94,
4135 EL_CUSTOM_START + 95,
4137 EL_CUSTOM_START + 96,
4138 EL_CUSTOM_START + 97,
4139 EL_CUSTOM_START + 98,
4140 EL_CUSTOM_START + 99,
4142 EL_CUSTOM_START + 100,
4143 EL_CUSTOM_START + 101,
4144 EL_CUSTOM_START + 102,
4145 EL_CUSTOM_START + 103,
4147 EL_CUSTOM_START + 104,
4148 EL_CUSTOM_START + 105,
4149 EL_CUSTOM_START + 106,
4150 EL_CUSTOM_START + 107,
4152 EL_CUSTOM_START + 108,
4153 EL_CUSTOM_START + 109,
4154 EL_CUSTOM_START + 110,
4155 EL_CUSTOM_START + 111,
4157 EL_CUSTOM_START + 112,
4158 EL_CUSTOM_START + 113,
4159 EL_CUSTOM_START + 114,
4160 EL_CUSTOM_START + 115,
4162 EL_CUSTOM_START + 116,
4163 EL_CUSTOM_START + 117,
4164 EL_CUSTOM_START + 118,
4165 EL_CUSTOM_START + 119,
4167 EL_CUSTOM_START + 120,
4168 EL_CUSTOM_START + 121,
4169 EL_CUSTOM_START + 122,
4170 EL_CUSTOM_START + 123,
4172 EL_CUSTOM_START + 124,
4173 EL_CUSTOM_START + 125,
4174 EL_CUSTOM_START + 126,
4175 EL_CUSTOM_START + 127,
4177 EL_CUSTOM_START + 128,
4178 EL_CUSTOM_START + 129,
4179 EL_CUSTOM_START + 130,
4180 EL_CUSTOM_START + 131,
4182 EL_CUSTOM_START + 132,
4183 EL_CUSTOM_START + 133,
4184 EL_CUSTOM_START + 134,
4185 EL_CUSTOM_START + 135,
4187 EL_CUSTOM_START + 136,
4188 EL_CUSTOM_START + 137,
4189 EL_CUSTOM_START + 138,
4190 EL_CUSTOM_START + 139,
4192 EL_CUSTOM_START + 140,
4193 EL_CUSTOM_START + 141,
4194 EL_CUSTOM_START + 142,
4195 EL_CUSTOM_START + 143,
4197 EL_CUSTOM_START + 144,
4198 EL_CUSTOM_START + 145,
4199 EL_CUSTOM_START + 146,
4200 EL_CUSTOM_START + 147,
4202 EL_CUSTOM_START + 148,
4203 EL_CUSTOM_START + 149,
4204 EL_CUSTOM_START + 150,
4205 EL_CUSTOM_START + 151,
4207 EL_CUSTOM_START + 152,
4208 EL_CUSTOM_START + 153,
4209 EL_CUSTOM_START + 154,
4210 EL_CUSTOM_START + 155,
4212 EL_CUSTOM_START + 156,
4213 EL_CUSTOM_START + 157,
4214 EL_CUSTOM_START + 158,
4215 EL_CUSTOM_START + 159,
4217 EL_CUSTOM_START + 160,
4218 EL_CUSTOM_START + 161,
4219 EL_CUSTOM_START + 162,
4220 EL_CUSTOM_START + 163,
4222 EL_CUSTOM_START + 164,
4223 EL_CUSTOM_START + 165,
4224 EL_CUSTOM_START + 166,
4225 EL_CUSTOM_START + 167,
4227 EL_CUSTOM_START + 168,
4228 EL_CUSTOM_START + 169,
4229 EL_CUSTOM_START + 170,
4230 EL_CUSTOM_START + 171,
4232 EL_CUSTOM_START + 172,
4233 EL_CUSTOM_START + 173,
4234 EL_CUSTOM_START + 174,
4235 EL_CUSTOM_START + 175,
4237 EL_CUSTOM_START + 176,
4238 EL_CUSTOM_START + 177,
4239 EL_CUSTOM_START + 178,
4240 EL_CUSTOM_START + 179,
4242 EL_CUSTOM_START + 180,
4243 EL_CUSTOM_START + 181,
4244 EL_CUSTOM_START + 182,
4245 EL_CUSTOM_START + 183,
4247 EL_CUSTOM_START + 184,
4248 EL_CUSTOM_START + 185,
4249 EL_CUSTOM_START + 186,
4250 EL_CUSTOM_START + 187,
4252 EL_CUSTOM_START + 188,
4253 EL_CUSTOM_START + 189,
4254 EL_CUSTOM_START + 190,
4255 EL_CUSTOM_START + 191,
4257 EL_CUSTOM_START + 192,
4258 EL_CUSTOM_START + 193,
4259 EL_CUSTOM_START + 194,
4260 EL_CUSTOM_START + 195,
4262 EL_CUSTOM_START + 196,
4263 EL_CUSTOM_START + 197,
4264 EL_CUSTOM_START + 198,
4265 EL_CUSTOM_START + 199,
4267 EL_CUSTOM_START + 200,
4268 EL_CUSTOM_START + 201,
4269 EL_CUSTOM_START + 202,
4270 EL_CUSTOM_START + 203,
4272 EL_CUSTOM_START + 204,
4273 EL_CUSTOM_START + 205,
4274 EL_CUSTOM_START + 206,
4275 EL_CUSTOM_START + 207,
4277 EL_CUSTOM_START + 208,
4278 EL_CUSTOM_START + 209,
4279 EL_CUSTOM_START + 210,
4280 EL_CUSTOM_START + 211,
4282 EL_CUSTOM_START + 212,
4283 EL_CUSTOM_START + 213,
4284 EL_CUSTOM_START + 214,
4285 EL_CUSTOM_START + 215,
4287 EL_CUSTOM_START + 216,
4288 EL_CUSTOM_START + 217,
4289 EL_CUSTOM_START + 218,
4290 EL_CUSTOM_START + 219,
4292 EL_CUSTOM_START + 220,
4293 EL_CUSTOM_START + 221,
4294 EL_CUSTOM_START + 222,
4295 EL_CUSTOM_START + 223,
4297 EL_CUSTOM_START + 224,
4298 EL_CUSTOM_START + 225,
4299 EL_CUSTOM_START + 226,
4300 EL_CUSTOM_START + 227,
4302 EL_CUSTOM_START + 228,
4303 EL_CUSTOM_START + 229,
4304 EL_CUSTOM_START + 230,
4305 EL_CUSTOM_START + 231,
4307 EL_CUSTOM_START + 232,
4308 EL_CUSTOM_START + 233,
4309 EL_CUSTOM_START + 234,
4310 EL_CUSTOM_START + 235,
4312 EL_CUSTOM_START + 236,
4313 EL_CUSTOM_START + 237,
4314 EL_CUSTOM_START + 238,
4315 EL_CUSTOM_START + 239,
4317 EL_CUSTOM_START + 240,
4318 EL_CUSTOM_START + 241,
4319 EL_CUSTOM_START + 242,
4320 EL_CUSTOM_START + 243,
4322 EL_CUSTOM_START + 244,
4323 EL_CUSTOM_START + 245,
4324 EL_CUSTOM_START + 246,
4325 EL_CUSTOM_START + 247,
4327 EL_CUSTOM_START + 248,
4328 EL_CUSTOM_START + 249,
4329 EL_CUSTOM_START + 250,
4330 EL_CUSTOM_START + 251,
4332 EL_CUSTOM_START + 252,
4333 EL_CUSTOM_START + 253,
4334 EL_CUSTOM_START + 254,
4335 EL_CUSTOM_START + 255
4337 static int *editor_hl_custom_ptr = editor_hl_custom;
4338 static int *editor_el_custom_ptr = editor_el_custom;
4339 static int num_editor_hl_custom = SIZEOF_ARRAY_INT(editor_hl_custom);
4340 static int num_editor_el_custom = SIZEOF_ARRAY_INT(editor_el_custom);
4342 static int editor_hl_group[] =
4344 EL_INTERNAL_CASCADE_GE_ACTIVE,
4350 static int editor_el_group[] =
4364 EL_GROUP_START + 10,
4365 EL_GROUP_START + 11,
4367 EL_GROUP_START + 12,
4368 EL_GROUP_START + 13,
4369 EL_GROUP_START + 14,
4370 EL_GROUP_START + 15,
4372 EL_GROUP_START + 16,
4373 EL_GROUP_START + 17,
4374 EL_GROUP_START + 18,
4375 EL_GROUP_START + 19,
4377 EL_GROUP_START + 20,
4378 EL_GROUP_START + 21,
4379 EL_GROUP_START + 22,
4380 EL_GROUP_START + 23,
4382 EL_GROUP_START + 24,
4383 EL_GROUP_START + 25,
4384 EL_GROUP_START + 26,
4385 EL_GROUP_START + 27,
4387 EL_GROUP_START + 28,
4388 EL_GROUP_START + 29,
4389 EL_GROUP_START + 30,
4392 static int *editor_hl_group_ptr = editor_hl_group;
4393 static int *editor_el_group_ptr = editor_el_group;
4394 static int num_editor_hl_group = SIZEOF_ARRAY_INT(editor_hl_group);
4395 static int num_editor_el_group = SIZEOF_ARRAY_INT(editor_el_group);
4397 static int editor_hl_reference[] =
4399 EL_INTERNAL_CASCADE_REF_ACTIVE,
4405 static int editor_el_reference[] =
4409 EL_TRIGGER_CE_VALUE,
4410 EL_TRIGGER_CE_SCORE,
4414 EL_CURRENT_CE_VALUE,
4415 EL_CURRENT_CE_SCORE,
4437 static int *editor_hl_reference_ptr = editor_hl_reference;
4438 static int *editor_el_reference_ptr = editor_el_reference;
4439 static int num_editor_hl_reference = SIZEOF_ARRAY_INT(editor_hl_reference);
4440 static int num_editor_el_reference = SIZEOF_ARRAY_INT(editor_el_reference);
4442 static int editor_hl_user_defined[] =
4444 EL_INTERNAL_CASCADE_USER_ACTIVE,
4450 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
4451 static int *editor_el_user_defined_ptr = NULL;
4452 static int num_editor_hl_user_defined=SIZEOF_ARRAY_INT(editor_hl_user_defined);
4453 static int num_editor_el_user_defined = 0;
4455 static int editor_hl_dynamic[] =
4457 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
4463 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
4464 static int *editor_el_dynamic_ptr = NULL;
4465 static int num_editor_hl_dynamic = SIZEOF_ARRAY_INT(editor_hl_dynamic);
4466 static int num_editor_el_dynamic = 0;
4468 static int editor_hl_empty[] = { };
4469 static int editor_el_empty[ED_NUM_ELEMENTLIST_BUTTONS];
4471 static int *editor_hl_empty_ptr = editor_hl_empty;
4472 static int *editor_el_empty_ptr = editor_el_empty;
4473 static int num_editor_hl_empty = 0;
4474 static int num_editor_el_empty = 0; /* dynamically determined, if needed */
4476 static boolean use_el_empty = FALSE;
4478 static int *editor_elements = NULL; /* dynamically allocated */
4479 static int num_editor_elements = 0; /* dynamically determined */
4481 static boolean setup_editor_show_always = TRUE;
4482 static boolean setup_editor_cascade_never = FALSE;
4484 static int editor_hl_unused[] = { EL_EMPTY };
4485 static int *editor_hl_unused_ptr = editor_hl_unused;
4486 static int num_editor_hl_unused = 0;
4490 boolean *setup_value;
4491 boolean *setup_cascade_value;
4493 int **headline_list;
4494 int *headline_list_size;
4497 int *element_list_size;
4499 boolean last_setup_value;
4501 editor_elements_info[] =
4504 &setup_editor_show_always,
4505 &setup_editor_cascade_never,
4506 &editor_hl_unused_ptr, &num_editor_hl_unused,
4507 &editor_el_players_ptr, &num_editor_el_players
4510 &setup.editor.el_boulderdash,
4511 &setup.editor_cascade.el_bd,
4512 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
4513 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
4516 &setup.editor.el_emerald_mine,
4517 &setup.editor_cascade.el_em,
4518 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
4519 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
4522 &setup.editor.el_emerald_mine_club,
4523 &setup.editor_cascade.el_emc,
4524 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
4525 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
4528 &setup.editor.el_more,
4529 &setup.editor_cascade.el_rnd,
4530 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
4531 &editor_el_rnd_ptr, &num_editor_el_rnd
4534 &setup.editor.el_sokoban,
4535 &setup.editor_cascade.el_sb,
4536 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
4537 &editor_el_sokoban_ptr, &num_editor_el_sokoban
4540 &setup.editor.el_supaplex,
4541 &setup.editor_cascade.el_sp,
4542 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
4543 &editor_el_supaplex_ptr, &num_editor_el_supaplex
4546 &setup.editor.el_diamond_caves,
4547 &setup.editor_cascade.el_dc,
4548 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
4549 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
4552 &setup.editor.el_dx_boulderdash,
4553 &setup.editor_cascade.el_dx,
4554 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
4555 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
4558 &setup.editor.el_chars,
4559 &setup.editor_cascade.el_chars,
4560 &editor_hl_chars_ptr, &num_editor_hl_chars,
4561 &editor_el_chars_ptr, &num_editor_el_chars
4564 &setup.editor.el_steel_chars,
4565 &setup.editor_cascade.el_steel_chars,
4566 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
4567 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
4570 &setup.editor.el_custom,
4571 &setup.editor_cascade.el_ce,
4572 &editor_hl_custom_ptr, &num_editor_hl_custom,
4573 &editor_el_custom_ptr, &num_editor_el_custom
4576 &setup.editor.el_custom,
4577 &setup.editor_cascade.el_ge,
4578 &editor_hl_group_ptr, &num_editor_hl_group,
4579 &editor_el_group_ptr, &num_editor_el_group
4582 &setup.editor.el_custom,
4583 &setup.editor_cascade.el_ref,
4584 &editor_hl_reference_ptr, &num_editor_hl_reference,
4585 &editor_el_reference_ptr, &num_editor_el_reference
4588 &setup.editor.el_user_defined,
4589 &setup.editor_cascade.el_user,
4590 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
4591 &editor_el_user_defined_ptr, &num_editor_el_user_defined
4594 &setup.editor.el_dynamic,
4595 &setup.editor_cascade.el_dynamic,
4596 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
4597 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
4602 &editor_hl_empty_ptr, &num_editor_hl_empty,
4603 &editor_el_empty_ptr, &num_editor_el_empty,
4615 -----------------------------------------------------------------------------
4617 -----------------------------------------------------------------------------
4620 static int getMaxInfoTextLength()
4622 return (SXSIZE / getFontWidth(FONT_TEXT_2));
4625 static int getTextWidthForGadget(char *text)
4630 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
4633 static int getTextWidthForDrawingArea(char *text)
4638 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
4641 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
4643 return (gi->x + gi->width + getTextWidthForGadget(text));
4646 static char *getElementInfoText(int element)
4648 char *info_text = NULL;
4650 if (element < MAX_NUM_ELEMENTS)
4652 if (strlen(element_info[element].description) > 0)
4653 info_text = element_info[element].description;
4654 else if (element_info[element].custom_description != NULL)
4655 info_text = element_info[element].custom_description;
4656 else if (element_info[element].editor_description != NULL)
4657 info_text = element_info[element].editor_description;
4660 if (info_text == NULL)
4661 info_text = INFOTEXT_UNKNOWN_ELEMENT;
4666 char *getElementDescriptionFilename(int element)
4668 char *docs_dir = options.docs_directory;
4669 char *elements_subdir = "elements";
4670 static char *filename = NULL;
4671 char basename[MAX_FILENAME_LEN];
4673 checked_free(filename);
4675 /* 1st try: look for element description file for exactly this element */
4676 sprintf(basename, "%s.txt", element_info[element].token_name);
4677 filename = getPath3(docs_dir, elements_subdir, basename);
4678 if (fileExists(filename))
4683 /* 2nd try: look for element description file for this element's class */
4684 sprintf(basename, "%s.txt", element_info[element].class_name);
4685 filename = getPath3(docs_dir, elements_subdir, basename);
4686 if (fileExists(filename))
4692 static void InitDynamicEditorElementList(int **elements, int *num_elements)
4694 boolean element_found[NUM_FILE_ELEMENTS];
4697 /* initialize list of used elements to "not used" */
4698 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
4699 element_found[i] = FALSE;
4701 /* find all elements used in current level */
4702 for (y = 0; y < lev_fieldy; y++)
4703 for (x = 0; x < lev_fieldx; x++)
4704 if (Feld[x][y] < NUM_FILE_ELEMENTS) /* should always be true */
4705 element_found[Feld[x][y]] = TRUE;
4709 /* count number of elements used in current level */
4710 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
4711 if (element_found[i])
4714 /* add space for up to 3 more elements for padding that may be needed */
4717 /* free memory for old list of elements, if needed */
4718 checked_free(*elements);
4720 /* allocate memory for new list of elements */
4721 *elements = checked_malloc(*num_elements * sizeof(int));
4725 /* add all elements used in current level (non-custom/group elements) */
4726 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
4727 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
4728 (*elements)[(*num_elements)++] = i;
4730 /* add all elements used in current level (custom/group elements) */
4731 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
4732 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
4733 (*elements)[(*num_elements)++] = i;
4735 while (*num_elements % 4) /* pad with empty elements, if needed */
4736 (*elements)[(*num_elements)++] = EL_EMPTY;
4739 static void ReinitializeElementList()
4741 static boolean initialization_needed = TRUE;
4745 if (initialization_needed)
4747 LoadSetup_EditorCascade(); /* load last editor cascade state */
4749 /* initialize editor cascade element from saved cascade state */
4750 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4752 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
4753 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
4755 if (IS_EDITOR_CASCADE(*cascade_element))
4757 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
4758 EL_CASCADE_INACTIVE(*cascade_element));
4761 initialization_needed = FALSE;
4764 checked_free(editor_elements);
4766 /* reload optional user defined element list for each invocation of editor */
4767 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
4768 &num_editor_el_user_defined);
4770 /* initialize dynamic level element list for each invocation of editor */
4771 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
4772 &num_editor_el_dynamic);
4774 /* initialize list of empty elements (used for padding, if needed) */
4775 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
4776 editor_el_empty[i] = EL_EMPTY;
4778 /* do some sanity checks for each element from element list */
4779 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4781 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
4783 int element = (*editor_elements_info[i].element_list)[j];
4785 if (element >= NUM_FILE_ELEMENTS)
4786 Error(ERR_WARN, "editor element %d is runtime element", element);
4788 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
4789 Error(ERR_WARN, "no element description for element %d", element);
4793 num_editor_elements = 0;
4794 use_el_empty = FALSE;
4796 /* determine size of element list */
4797 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4799 boolean found_inactive_cascade = FALSE;
4801 if (*editor_elements_info[i].setup_value)
4803 if (setup.editor.el_headlines)
4805 num_editor_elements += *editor_elements_info[i].headline_list_size;
4807 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
4809 int element = (*editor_elements_info[i].headline_list)[j];
4811 if (IS_EDITOR_CASCADE_INACTIVE(element))
4812 found_inactive_cascade = TRUE;
4816 if (found_inactive_cascade)
4819 num_editor_elements += *editor_elements_info[i].element_list_size;
4823 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
4825 /* offer at least as many elements as element buttons exist */
4826 use_el_empty = TRUE;
4827 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
4829 num_editor_elements += num_editor_el_empty;
4832 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
4834 /* fill element list */
4835 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4837 boolean found_inactive_cascade = FALSE;
4839 if (*editor_elements_info[i].setup_value)
4841 if (setup.editor.el_headlines)
4843 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
4845 int element = (*editor_elements_info[i].headline_list)[j];
4847 editor_elements[pos++] = element;
4849 if (IS_EDITOR_CASCADE_INACTIVE(element))
4850 found_inactive_cascade = TRUE;
4854 if (found_inactive_cascade)
4857 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
4858 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
4862 /* (this function is also called before editor gadgets are initialized!) */
4863 AdjustElementListScrollbar();
4866 void PrintEditorElementList()
4868 boolean *stop = &setup.editor.el_user_defined;
4871 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
4873 int cascade_element = (*editor_elements_info[i].headline_list)[0];
4875 if (IS_EDITOR_CASCADE(cascade_element))
4877 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
4878 char *headline = element_info[cascade_element_show].editor_description;
4880 printf_line_with_prefix("# ", "-", 77);
4881 printf("# %s\n", headline);
4882 printf_line_with_prefix("# ", "-", 77);
4885 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
4887 int element = (*editor_elements_info[i].headline_list)[j];
4889 if (IS_EDITOR_CASCADE(element))
4890 element = EL_CHAR_MINUS;
4892 printf("# %s\n", element_info[element].token_name);
4898 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
4900 int element = (*editor_elements_info[i].element_list)[j];
4902 printf("# %s\n", element_info[element].token_name);
4910 static void ReinitializeElementListButtons()
4912 static boolean last_setup_value_headlines = FALSE;
4913 static boolean initialization_needed = TRUE;
4916 if (!initialization_needed) /* check if editor element setup has changed */
4918 if (last_setup_value_headlines != setup.editor.el_headlines)
4919 initialization_needed = TRUE;
4921 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4922 if (editor_elements_info[i].last_setup_value !=
4923 *editor_elements_info[i].setup_value)
4924 initialization_needed = TRUE;
4927 if (!initialization_needed)
4930 FreeLevelEditorGadgets();
4931 CreateLevelEditorGadgets();
4933 /* store current setup values for next invocation of this function */
4934 last_setup_value_headlines = setup.editor.el_headlines;
4935 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4936 editor_elements_info[i].last_setup_value =
4937 *editor_elements_info[i].setup_value;
4939 initialization_needed = FALSE;
4942 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
4945 int border_graphic =
4946 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
4949 int num_mini_tilex = width / MINI_TILEX + 1;
4950 int num_mini_tiley = height / MINI_TILEY + 1;
4951 int from_x = dest_x - MINI_TILEX / 2;
4952 int from_y = dest_y - MINI_TILEY / 2;
4953 int to_x = from_x + num_mini_tilex * MINI_TILEX - 1;
4954 int to_y = from_y + num_mini_tiley * MINI_TILEY - 1;
4957 getMiniGraphicSource(border_graphic, &src_bitmap, &src_x, &src_y);
4959 for (y = 0; y < num_mini_tiley; y++)
4960 for (x = 0; x < num_mini_tilex; x++)
4961 BlitBitmap(src_bitmap, drawto, src_x, src_y, MINI_TILEX, MINI_TILEY,
4962 from_x + x * MINI_TILEX, from_y + y * MINI_TILEY);
4964 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
4966 DrawSimpleBlackLine(drawto, from_x, from_y, to_x, from_y);
4967 DrawSimpleBlackLine(drawto, to_x, from_y, to_x, to_y);
4968 DrawSimpleBlackLine(drawto, to_x, to_y, from_x, to_y);
4969 DrawSimpleBlackLine(drawto, from_x, to_y, from_x, from_y);
4972 static void DrawDrawingArea(int id)
4974 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
4977 int *value = drawingarea_info[id].value;
4978 int area_xsize = drawingarea_info[id].area_xsize;
4979 int area_ysize = drawingarea_info[id].area_ysize;
4981 for (x = 0; x < area_xsize; x++)
4982 for (y = 0; y < area_ysize; y++)
4983 DrawMiniGraphicExt(drawto,
4984 gi->x + x * MINI_TILEX,
4985 gi->y + y * MINI_TILEY,
4986 el2edimg(value[x * area_ysize + y]));
4989 static void ScrollMiniLevel(int from_x, int from_y, int scroll)
4992 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
4993 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
4995 BlitBitmap(drawto, drawto,
4996 SX + (dx == -1 ? MINI_TILEX : 0),
4997 SY + (dy == -1 ? MINI_TILEY : 0),
4998 (ed_fieldx * MINI_TILEX) - (dx != 0 ? MINI_TILEX : 0),
4999 (ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0),
5000 SX + (dx == +1 ? MINI_TILEX : 0),
5001 SY + (dy == +1 ? MINI_TILEY : 0));
5004 x = (dx == 1 ? 0 : ed_fieldx - 1);
5005 for (y = 0; y < ed_fieldy; y++)
5006 DrawMiniElementOrWall(x, y, from_x, from_y);
5010 y = (dy == 1 ? 0 : ed_fieldy - 1);
5011 for (x = 0; x < ed_fieldx; x++)
5012 DrawMiniElementOrWall(x, y, from_x, from_y);
5015 redraw_mask |= REDRAW_FIELD;
5019 static void CreateControlButtons()
5021 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5022 struct GadgetInfo *gi;
5023 unsigned long event_mask;
5026 /* create toolbox buttons */
5027 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
5031 int gd_xoffset, gd_yoffset;
5032 int gd_x1, gd_x2, gd_y1, gd_y2;
5034 int radio_button_nr;
5037 if (id == GADGET_ID_SINGLE_ITEMS ||
5038 id == GADGET_ID_CONNECTED_ITEMS ||
5039 id == GADGET_ID_LINE ||
5040 id == GADGET_ID_ARC ||
5041 id == GADGET_ID_TEXT ||
5042 id == GADGET_ID_RECTANGLE ||
5043 id == GADGET_ID_FILLED_BOX ||
5044 id == GADGET_ID_FLOOD_FILL ||
5045 id == GADGET_ID_GRAB_BRUSH ||
5046 id == GADGET_ID_PICK_ELEMENT ||
5047 id == GADGET_ID_CUSTOM_COPY_FROM ||
5048 id == GADGET_ID_CUSTOM_COPY_TO ||
5049 id == GADGET_ID_CUSTOM_EXCHANGE)
5051 button_type = GD_TYPE_RADIO_BUTTON;
5052 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
5053 checked = (id == drawing_function ? TRUE : FALSE);
5054 event_mask = GD_EVENT_PRESSED;
5058 button_type = GD_TYPE_NORMAL_BUTTON;
5059 radio_button_nr = RADIO_NR_NONE;
5062 if (id == GADGET_ID_WRAP_LEFT ||
5063 id == GADGET_ID_WRAP_RIGHT ||
5064 id == GADGET_ID_WRAP_UP ||
5065 id == GADGET_ID_WRAP_DOWN)
5066 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5068 event_mask = GD_EVENT_RELEASED;
5071 if (id < ED_NUM_CTRL1_BUTTONS)
5073 int x = i % ED_CTRL1_BUTTONS_HORIZ;
5074 int y = i / ED_CTRL1_BUTTONS_HORIZ;
5076 gd_xoffset = ED_CTRL1_BUTTONS_XPOS + x * ED_CTRL1_BUTTON_XSIZE;
5077 gd_yoffset = ED_CTRL1_BUTTONS_YPOS + y * ED_CTRL1_BUTTON_YSIZE;
5078 width = ED_CTRL1_BUTTON_XSIZE;
5079 height = ED_CTRL1_BUTTON_YSIZE;
5081 gd_x1 = DOOR_GFX_PAGEX8 + gd_xoffset;
5082 gd_x2 = DOOR_GFX_PAGEX7 + gd_xoffset;
5083 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL1_BUTTONS_GFX_YPOS + gd_yoffset;
5084 gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL1_BUTTONS_ALT_GFX_YPOS + gd_yoffset;
5086 else if (id < ED_NUM_CTRL1_2_BUTTONS)
5088 int x = (i - ED_NUM_CTRL1_BUTTONS) % ED_CTRL2_BUTTONS_HORIZ;
5089 int y = (i - ED_NUM_CTRL1_BUTTONS) / ED_CTRL2_BUTTONS_HORIZ;
5091 gd_xoffset = ED_CTRL2_BUTTONS_XPOS + x * ED_CTRL2_BUTTON_XSIZE;
5092 gd_yoffset = ED_CTRL2_BUTTONS_YPOS + y * ED_CTRL2_BUTTON_YSIZE;
5093 width = ED_CTRL2_BUTTON_XSIZE;
5094 height = ED_CTRL2_BUTTON_YSIZE;
5096 gd_x1 = DOOR_GFX_PAGEX8 + gd_xoffset;
5097 gd_x2 = DOOR_GFX_PAGEX7 + gd_xoffset;
5098 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL2_BUTTONS_GFX_YPOS + gd_yoffset;
5099 gd_y2 = 0; /* no alternative graphic for these buttons */
5101 else if (id < ED_NUM_CTRL1_3_BUTTONS)
5103 int x = (i - ED_NUM_CTRL1_2_BUTTONS) % ED_CTRL3_BUTTONS_HORIZ + 1;
5104 int y = (i - ED_NUM_CTRL1_2_BUTTONS) / ED_CTRL3_BUTTONS_HORIZ;
5106 gd_xoffset = ED_CTRL3_BUTTONS_XPOS + x * ED_CTRL3_BUTTON_XSIZE;
5107 gd_yoffset = ED_CTRL3_BUTTONS_YPOS + y * ED_CTRL3_BUTTON_YSIZE;
5108 width = ED_CTRL3_BUTTON_XSIZE;
5109 height = ED_CTRL3_BUTTON_YSIZE;
5111 gd_x1 = DOOR_GFX_PAGEX6 + gd_xoffset;
5112 gd_x2 = DOOR_GFX_PAGEX5 + gd_xoffset;
5113 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL3_BUTTONS_GFX_YPOS + gd_yoffset;
5114 gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL3_BUTTONS_ALT_GFX_YPOS + gd_yoffset;
5118 int x = (i - ED_NUM_CTRL1_3_BUTTONS) % ED_CTRL4_BUTTONS_HORIZ;
5119 int y = (i - ED_NUM_CTRL1_3_BUTTONS) / ED_CTRL4_BUTTONS_HORIZ + 3;
5121 gd_xoffset = ED_CTRL4_BUTTONS_XPOS + x * ED_CTRL4_BUTTON_XSIZE;
5122 gd_yoffset = ED_CTRL4_BUTTONS_YPOS + y * ED_CTRL4_BUTTON_YSIZE;
5123 width = ED_CTRL4_BUTTON_XSIZE;
5124 height = ED_CTRL4_BUTTON_YSIZE;
5126 gd_x1 = DOOR_GFX_PAGEX6 + ED_CTRL4_BUTTONS_GFX_XPOS + gd_xoffset;
5127 gd_x2 = DOOR_GFX_PAGEX5 + ED_CTRL4_BUTTONS_GFX_XPOS + gd_xoffset;
5128 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL4_BUTTONS_GFX_YPOS + gd_yoffset;
5129 gd_y2 = 0; /* no alternative graphic for these buttons */
5132 gi = CreateGadget(GDI_CUSTOM_ID, id,
5133 GDI_CUSTOM_TYPE_ID, i,
5134 GDI_INFO_TEXT, control_info[i].text,
5135 GDI_X, EX + gd_xoffset,
5136 GDI_Y, EY + gd_yoffset,
5139 GDI_TYPE, button_type,
5140 GDI_STATE, GD_BUTTON_UNPRESSED,
5141 GDI_RADIO_NR, radio_button_nr,
5142 GDI_CHECKED, checked,
5143 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5144 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y1,
5145 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2,
5146 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
5147 GDI_EVENT_MASK, event_mask,
5148 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5149 GDI_CALLBACK_ACTION, HandleControlButtons,
5153 Error(ERR_EXIT, "cannot create gadget");
5155 level_editor_gadget[id] = gi;
5158 /* create buttons for scrolling of drawing area and element list */
5159 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
5161 int id = scrollbutton_info[i].gadget_id;
5162 int x, y, width, height;
5163 int gd_x1, gd_x2, gd_y1, gd_y2;
5165 x = scrollbutton_info[i].x;
5166 y = scrollbutton_info[i].y;
5168 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5170 if (id == GADGET_ID_SCROLL_LIST_UP ||
5171 id == GADGET_ID_SCROLL_LIST_DOWN)
5175 width = ED_SCROLLBUTTON2_XSIZE;
5176 height = ED_SCROLLBUTTON2_YSIZE;
5177 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].gd_x;
5178 gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].gd_y;
5179 gd_x2 = gd_x1 - ED_SCROLLBUTTON2_XSIZE;
5186 width = ED_SCROLLBUTTON_XSIZE;
5187 height = ED_SCROLLBUTTON_YSIZE;
5188 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].gd_x;
5189 gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].gd_y;
5190 gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE;
5194 gi = CreateGadget(GDI_CUSTOM_ID, id,
5195 GDI_CUSTOM_TYPE_ID, i,
5196 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
5201 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
5202 GDI_STATE, GD_BUTTON_UNPRESSED,
5203 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5204 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
5205 GDI_EVENT_MASK, event_mask,
5206 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5207 GDI_CALLBACK_ACTION, HandleControlButtons,
5211 Error(ERR_EXIT, "cannot create gadget");
5213 level_editor_gadget[id] = gi;
5216 /* create buttons for element list */
5217 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
5219 Bitmap *deco_bitmap;
5220 int deco_x, deco_y, deco_xpos, deco_ypos;
5221 int gd_xoffset, gd_yoffset;
5222 int gd_x1, gd_x2, gd_y;
5223 int x = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
5224 int y = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
5225 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
5226 int element = editor_elements[i];
5228 event_mask = GD_EVENT_RELEASED;
5230 gd_xoffset = ED_ELEMENTLIST_XPOS + x * ED_ELEMENTLIST_XSIZE;
5231 gd_yoffset = ED_ELEMENTLIST_YPOS + y * ED_ELEMENTLIST_YSIZE;
5233 gd_x1 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS + ED_ELEMENTLIST_XSIZE;
5234 gd_x2 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS;
5235 gd_y = DOOR_GFX_PAGEY1 + ED_ELEMENTLIST_YPOS;
5237 getMiniGraphicSource(el2edimg(element), &deco_bitmap, &deco_x, &deco_y);
5238 deco_xpos = (ED_ELEMENTLIST_XSIZE - MINI_TILEX) / 2;
5239 deco_ypos = (ED_ELEMENTLIST_YSIZE - MINI_TILEY) / 2;
5241 gi = CreateGadget(GDI_CUSTOM_ID, id,
5242 GDI_CUSTOM_TYPE_ID, i,
5243 GDI_INFO_TEXT, getElementInfoText(element),
5244 GDI_X, DX + gd_xoffset,
5245 GDI_Y, DY + gd_yoffset,
5246 GDI_WIDTH, ED_ELEMENTLIST_XSIZE,
5247 GDI_HEIGHT, ED_ELEMENTLIST_YSIZE,
5248 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
5249 GDI_STATE, GD_BUTTON_UNPRESSED,
5250 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
5251 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
5252 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
5253 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
5254 GDI_DECORATION_SIZE, MINI_TILEX, MINI_TILEY,
5255 GDI_DECORATION_SHIFTING, 1, 1,
5256 GDI_EVENT_MASK, event_mask,
5257 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5258 GDI_CALLBACK_ACTION, HandleControlButtons,
5262 Error(ERR_EXIT, "cannot create gadget");
5264 level_editor_gadget[id] = gi;
5268 static void CreateCounterButtons()
5270 int max_infotext_len = getMaxInfoTextLength();
5273 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
5276 int x = SX + counterbutton_info[i].x; /* down count button */
5277 int y = SY + counterbutton_info[i].y;
5279 /* determine horizontal position to the right of specified gadget */
5280 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
5281 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
5282 ED_GADGET_TEXT_DISTANCE);
5284 /* determine horizontal offset for leading text */
5285 if (counterbutton_info[i].text_left != NULL)
5286 x += getTextWidthForGadget(counterbutton_info[i].text_left);
5288 for (j = 0; j < 2; j++)
5290 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5291 struct GadgetInfo *gi;
5293 counterbutton_info[i].gadget_id_down :
5294 counterbutton_info[i].gadget_id_up);
5296 int gd_x, gd_x1, gd_x2, gd_y;
5298 unsigned long event_mask;
5299 char infotext[max_infotext_len + 1];
5301 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5303 if (i == ED_COUNTER_ID_SELECT_LEVEL)
5306 ED_SCROLLBUTTON_ID_AREA_LEFT :
5307 ED_SCROLLBUTTON_ID_AREA_RIGHT);
5309 event_mask |= GD_EVENT_RELEASED;
5312 x += 2 * ED_GADGET_DISTANCE;
5313 y += ED_GADGET_DISTANCE;
5315 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[sid].gd_x;
5316 gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE;
5317 gd_y = DOOR_GFX_PAGEY1 + scrollbutton_info[sid].gd_y;
5318 x_size = ED_SCROLLBUTTON_XSIZE;
5319 y_size = ED_SCROLLBUTTON_YSIZE;
5323 gd_xoffset = (j == 0 ? ED_BUTTON_MINUS_XPOS : ED_BUTTON_PLUS_XPOS);
5324 gd_x1 = DOOR_GFX_PAGEX4 + gd_xoffset;
5325 gd_x2 = DOOR_GFX_PAGEX3 + gd_xoffset;
5326 gd_y = DOOR_GFX_PAGEY1 + ED_BUTTON_COUNT_YPOS;
5327 x_size = ED_BUTTON_COUNT_XSIZE;
5328 y_size = ED_BUTTON_COUNT_YSIZE;
5331 sprintf(infotext, "%s counter value by 1, 5 or 10",
5332 (j == 0 ? "decrease" : "increase"));
5334 gi = CreateGadget(GDI_CUSTOM_ID, id,
5335 GDI_CUSTOM_TYPE_ID, i,
5336 GDI_INFO_TEXT, infotext,
5341 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
5342 GDI_STATE, GD_BUTTON_UNPRESSED,
5343 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
5344 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
5345 GDI_EVENT_MASK, event_mask,
5346 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5347 GDI_CALLBACK_ACTION, HandleCounterButtons,
5351 Error(ERR_EXIT, "cannot create gadget");
5353 level_editor_gadget[id] = gi;
5354 right_gadget_border[id] =
5355 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
5357 x += gi->width + ED_GADGET_DISTANCE; /* text count button */
5361 int font_type = FONT_INPUT_1;
5362 int font_type_active = FONT_INPUT_1_ACTIVE;
5363 int gd_width = ED_WIN_COUNT_XSIZE;
5365 id = counterbutton_info[i].gadget_id_text;
5366 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
5368 if (i == ED_COUNTER_ID_SELECT_LEVEL)
5370 font_type = FONT_LEVEL_NUMBER;
5372 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
5374 font_type_active = FONT_LEVEL_NUMBER;
5376 x += 2 * ED_GADGET_DISTANCE;
5377 y -= ED_GADGET_DISTANCE;
5379 gd_x = DOOR_GFX_PAGEX6 + ED_WIN_COUNT2_XPOS;
5380 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT2_YPOS;
5381 gd_width = ED_WIN_COUNT2_XSIZE;
5385 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
5386 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
5389 gi = CreateGadget(GDI_CUSTOM_ID, id,
5390 GDI_CUSTOM_TYPE_ID, i,
5391 GDI_INFO_TEXT, "enter counter value",
5394 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
5395 GDI_NUMBER_VALUE, 0,
5396 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
5397 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
5398 GDI_TEXT_SIZE, 3, /* minimal counter text size */
5399 GDI_TEXT_FONT, font_type,
5400 GDI_TEXT_FONT_ACTIVE, font_type_active,
5401 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
5402 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
5403 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5404 GDI_DESIGN_WIDTH, gd_width,
5405 GDI_EVENT_MASK, event_mask,
5406 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5407 GDI_CALLBACK_ACTION, HandleCounterButtons,
5411 Error(ERR_EXIT, "cannot create gadget");
5413 level_editor_gadget[id] = gi;
5414 right_gadget_border[id] =
5415 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
5417 x += gi->width + ED_GADGET_DISTANCE; /* up count button */
5423 static void CreateDrawingAreas()
5427 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
5429 struct GadgetInfo *gi;
5430 unsigned long event_mask;
5431 int id = drawingarea_info[i].gadget_id;
5432 int x = SX + drawingarea_info[i].x;
5433 int y = SY + drawingarea_info[i].y;
5434 int area_xsize = drawingarea_info[i].area_xsize;
5435 int area_ysize = drawingarea_info[i].area_ysize;
5438 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
5439 GD_EVENT_OFF_BORDERS;
5441 /* determine horizontal position to the right of specified gadget */
5442 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
5443 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
5444 ED_DRAWINGAREA_TEXT_DISTANCE);
5446 /* determine horizontal offset for leading text */
5447 if (drawingarea_info[i].text_left != NULL)
5448 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
5450 gi = CreateGadget(GDI_CUSTOM_ID, id,
5451 GDI_CUSTOM_TYPE_ID, i,
5454 GDI_TYPE, GD_TYPE_DRAWING_AREA,
5455 GDI_AREA_SIZE, area_xsize, area_ysize,
5456 GDI_ITEM_SIZE, MINI_TILEX, MINI_TILEY,
5457 GDI_EVENT_MASK, event_mask,
5458 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
5459 GDI_CALLBACK_ACTION, HandleDrawingAreas,
5463 Error(ERR_EXIT, "cannot create gadget");
5465 level_editor_gadget[id] = gi;
5466 right_gadget_border[id] =
5467 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
5471 static void CreateTextInputGadgets()
5473 int max_infotext_len = getMaxInfoTextLength();
5476 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
5478 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5480 struct GadgetInfo *gi;
5481 unsigned long event_mask;
5482 char infotext[MAX_OUTPUT_LINESIZE + 1];
5483 int id = textinput_info[i].gadget_id;
5485 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
5487 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
5488 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
5490 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
5491 infotext[max_infotext_len] = '\0';
5493 gi = CreateGadget(GDI_CUSTOM_ID, id,
5494 GDI_CUSTOM_TYPE_ID, i,
5495 GDI_INFO_TEXT, infotext,
5496 GDI_X, SX + textinput_info[i].x,
5497 GDI_Y, SY + textinput_info[i].y,
5498 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
5499 GDI_TEXT_VALUE, textinput_info[i].value,
5500 GDI_TEXT_SIZE, textinput_info[i].size,
5501 GDI_TEXT_FONT, FONT_INPUT_1,
5502 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
5503 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
5504 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
5505 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5506 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
5507 GDI_EVENT_MASK, event_mask,
5508 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5509 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
5513 Error(ERR_EXIT, "cannot create gadget");
5515 level_editor_gadget[id] = gi;
5519 static void CreateTextAreaGadgets()
5521 int max_infotext_len = getMaxInfoTextLength();
5524 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
5526 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5528 struct GadgetInfo *gi;
5529 unsigned long event_mask;
5530 char infotext[MAX_OUTPUT_LINESIZE + 1];
5531 int id = textarea_info[i].gadget_id;
5532 int area_xsize = textarea_info[i].xsize;
5533 int area_ysize = textarea_info[i].ysize;
5535 event_mask = GD_EVENT_TEXT_LEAVING;
5537 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
5538 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
5540 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
5541 infotext[max_infotext_len] = '\0';
5543 gi = CreateGadget(GDI_CUSTOM_ID, id,
5544 GDI_CUSTOM_TYPE_ID, i,
5545 GDI_INFO_TEXT, infotext,
5546 GDI_X, SX + textarea_info[i].x,
5547 GDI_Y, SY + textarea_info[i].y,
5548 GDI_TYPE, GD_TYPE_TEXT_AREA,
5549 GDI_AREA_SIZE, area_xsize, area_ysize,
5550 GDI_TEXT_FONT, FONT_INPUT_1,
5551 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
5552 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
5553 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
5554 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5555 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
5556 GDI_EVENT_MASK, event_mask,
5557 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5558 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
5562 Error(ERR_EXIT, "cannot create gadget");
5564 level_editor_gadget[id] = gi;
5568 static void CreateSelectboxGadgets()
5570 int max_infotext_len = getMaxInfoTextLength();
5573 for (i = 0; i < ED_NUM_SELECTBOX; i++)
5575 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5577 struct GadgetInfo *gi;
5578 unsigned long event_mask;
5579 char infotext[MAX_OUTPUT_LINESIZE + 1];
5580 int id = selectbox_info[i].gadget_id;
5581 int x = SX + selectbox_info[i].x;
5582 int y = SY + selectbox_info[i].y;
5584 if (selectbox_info[i].size == -1) /* dynamically determine size */
5586 /* (we cannot use -1 for uninitialized values if we directly compare
5587 with results from strlen(), because the '<' and '>' operation will
5588 implicitely cast -1 to an unsigned integer value!) */
5589 selectbox_info[i].size = 0;
5591 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
5592 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
5593 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
5595 selectbox_info[i].size++; /* add one character empty space */
5598 event_mask = GD_EVENT_RELEASED |
5599 GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
5601 gd_x = DOOR_GFX_PAGEX4 + ED_SELECTBOX_XPOS;
5602 gd_y = DOOR_GFX_PAGEY1 + ED_SELECTBOX_YPOS;
5604 /* determine horizontal position to the right of specified gadget */
5605 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
5606 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
5607 ED_GADGET_TEXT_DISTANCE);
5609 /* determine horizontal offset for leading text */
5610 if (selectbox_info[i].text_left != NULL)
5611 x += getTextWidthForGadget(selectbox_info[i].text_left);
5613 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
5614 infotext[max_infotext_len] = '\0';
5616 gi = CreateGadget(GDI_CUSTOM_ID, id,
5617 GDI_CUSTOM_TYPE_ID, i,
5618 GDI_INFO_TEXT, infotext,
5621 GDI_TYPE, GD_TYPE_SELECTBOX,
5622 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
5623 GDI_TEXT_SIZE, selectbox_info[i].size,
5624 GDI_TEXT_FONT, FONT_INPUT_1,
5625 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
5626 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
5627 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
5628 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5629 GDI_BORDER_SIZE_SELECTBUTTON, ED_SELECTBOX_BUTTON_XSIZE,
5630 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
5631 GDI_EVENT_MASK, event_mask,
5632 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5633 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
5637 Error(ERR_EXIT, "cannot create gadget");
5639 level_editor_gadget[id] = gi;
5640 right_gadget_border[id] =
5641 getRightGadgetBorder(gi, selectbox_info[i].text_right);
5645 static void CreateTextbuttonGadgets()
5647 int max_infotext_len = getMaxInfoTextLength();
5650 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
5652 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5653 int gd_x1, gd_x2, gd_y1, gd_y2;
5654 struct GadgetInfo *gi;
5655 unsigned long event_mask;
5656 char infotext[MAX_OUTPUT_LINESIZE + 1];
5657 int id = textbutton_info[i].gadget_id;
5658 int x = SX + textbutton_info[i].x;
5659 int y = SY + textbutton_info[i].y;
5661 if (textbutton_info[i].size == -1) /* dynamically determine size */
5662 textbutton_info[i].size = strlen(textbutton_info[i].text);
5664 event_mask = GD_EVENT_RELEASED;
5666 if (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE)
5668 gd_x1 = DOOR_GFX_PAGEX4 + ED_TEXTBUTTON_TAB_XPOS;
5669 gd_x2 = DOOR_GFX_PAGEX3 + ED_TEXTBUTTON_TAB_XPOS;
5670 gd_y1 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_TAB_YPOS;
5671 gd_y2 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_TAB_INACTIVE_YPOS;
5675 gd_x1 = DOOR_GFX_PAGEX4 + ED_TEXTBUTTON_XPOS;
5676 gd_x2 = DOOR_GFX_PAGEX3 + ED_TEXTBUTTON_XPOS;
5677 gd_y1 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_YPOS;
5678 gd_y2 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_INACTIVE_YPOS;
5681 sprintf(infotext, "%s", textbutton_info[i].infotext);
5682 infotext[max_infotext_len] = '\0';
5684 /* determine horizontal position to the right of specified gadget */
5685 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
5686 x = (right_gadget_border[textbutton_info[i].gadget_id_align] +
5687 ED_GADGET_TEXT_DISTANCE);
5689 /* determine horizontal offset for leading text */
5690 if (textbutton_info[i].text_left != NULL)
5691 x += getTextWidthForGadget(textbutton_info[i].text_left);
5693 gi = CreateGadget(GDI_CUSTOM_ID, id,
5694 GDI_CUSTOM_TYPE_ID, i,
5695 GDI_INFO_TEXT, infotext,
5698 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
5699 GDI_TEXT_VALUE, textbutton_info[i].text,
5700 GDI_TEXT_SIZE, textbutton_info[i].size,
5701 GDI_TEXT_FONT, FONT_INPUT_2_ACTIVE,
5702 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2,
5703 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5704 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y1,
5705 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2,
5706 GDI_BORDER_SIZE, ED_BORDER_TEXT_XSIZE, ED_BORDER_SIZE,
5707 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
5708 GDI_DECORATION_SHIFTING, 1, 1,
5709 GDI_EVENT_MASK, event_mask,
5710 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5711 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
5715 Error(ERR_EXIT, "cannot create gadget");
5717 level_editor_gadget[id] = gi;
5718 right_gadget_border[id] =
5719 getRightGadgetBorder(gi, textbutton_info[i].text_right);
5723 static void CreateGraphicbuttonGadgets()
5725 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5726 struct GadgetInfo *gi;
5727 unsigned long event_mask;
5730 /* create buttons for scrolling of drawing area and element list */
5731 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
5733 int id = graphicbutton_info[i].gadget_id;
5734 int gd_x1, gd_x2, gd_y1, gd_y2;
5735 int x = SX + graphicbutton_info[i].x;
5736 int y = SY + graphicbutton_info[i].y;
5738 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5740 if (i <= ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
5742 gd_x1 = DOOR_GFX_PAGEX4 + graphicbutton_info[i].gd_x;
5743 gd_y1 = DOOR_GFX_PAGEY1 + graphicbutton_info[i].gd_y;
5744 gd_x2 = DOOR_GFX_PAGEX3 + graphicbutton_info[i].gd_x;
5747 else /* (i <= ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE) */
5749 gd_x1 = DOOR_GFX_PAGEX6 + graphicbutton_info[i].gd_x;
5750 gd_y1 = DOOR_GFX_PAGEY1 + graphicbutton_info[i].gd_y;
5751 gd_x2 = gd_x1 - ED_BUTTON_COUNT_XSIZE;
5755 /* determine horizontal position to the right of specified gadget */
5756 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
5757 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
5758 ED_GADGET_TEXT_DISTANCE);
5760 /* determine horizontal offset for leading text */
5761 if (graphicbutton_info[i].text_left != NULL)
5762 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
5764 gi = CreateGadget(GDI_CUSTOM_ID, id,
5765 GDI_CUSTOM_TYPE_ID, i,
5766 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
5769 GDI_WIDTH, graphicbutton_info[i].width,
5770 GDI_HEIGHT, graphicbutton_info[i].height,
5771 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
5772 GDI_STATE, GD_BUTTON_UNPRESSED,
5773 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5774 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
5775 GDI_EVENT_MASK, event_mask,
5776 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5777 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
5781 Error(ERR_EXIT, "cannot create gadget");
5783 level_editor_gadget[id] = gi;
5784 right_gadget_border[id] =
5785 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
5789 static void CreateScrollbarGadgets()
5793 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
5795 int id = scrollbar_info[i].gadget_id;
5796 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5797 int gd_x1, gd_x2, gd_y1, gd_y2;
5798 struct GadgetInfo *gi;
5799 int items_max, items_visible, item_position;
5800 unsigned long event_mask;
5802 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
5804 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
5805 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
5806 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
5808 else /* drawing area scrollbars */
5810 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
5812 items_max = MAX(lev_fieldx + 2, ed_fieldx);
5813 items_visible = ed_fieldx;
5818 items_max = MAX(lev_fieldy + 2, ed_fieldy);
5819 items_visible = ed_fieldy;
5824 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
5826 gd_x1 = DOOR_GFX_PAGEX8 + scrollbar_info[i].gd_x;
5827 gd_x2 = (gd_x1 - (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL ?
5828 scrollbar_info[i].height : scrollbar_info[i].width));
5829 gd_y1 = DOOR_GFX_PAGEY1 + scrollbar_info[i].gd_y;
5830 gd_y2 = DOOR_GFX_PAGEY1 + scrollbar_info[i].gd_y;
5832 gi = CreateGadget(GDI_CUSTOM_ID, id,
5833 GDI_CUSTOM_TYPE_ID, i,
5834 GDI_INFO_TEXT, scrollbar_info[i].infotext,
5835 GDI_X, scrollbar_info[i].x,
5836 GDI_Y, scrollbar_info[i].y,
5837 GDI_WIDTH, scrollbar_info[i].width,
5838 GDI_HEIGHT, scrollbar_info[i].height,
5839 GDI_TYPE, scrollbar_info[i].type,
5840 GDI_SCROLLBAR_ITEMS_MAX, items_max,
5841 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
5842 GDI_SCROLLBAR_ITEM_POSITION, item_position,
5843 GDI_WHEEL_AREA_X, scrollbar_info[i].wheel_x,
5844 GDI_WHEEL_AREA_Y, scrollbar_info[i].wheel_y,
5845 GDI_WHEEL_AREA_WIDTH, scrollbar_info[i].wheel_width,
5846 GDI_WHEEL_AREA_HEIGHT, scrollbar_info[i].wheel_height,
5847 GDI_STATE, GD_BUTTON_UNPRESSED,
5848 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5849 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
5850 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5851 GDI_EVENT_MASK, event_mask,
5852 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5853 GDI_CALLBACK_ACTION, HandleControlButtons,
5857 Error(ERR_EXIT, "cannot create gadget");
5859 level_editor_gadget[id] = gi;
5863 static void CreateCheckbuttonGadgets()
5865 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5866 struct GadgetInfo *gi;
5867 unsigned long event_mask;
5868 int gd_x1, gd_x2, gd_x3, gd_x4, gd_y;
5871 event_mask = GD_EVENT_PRESSED;
5873 gd_x1 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_UNCHECKED_XPOS;
5874 gd_x2 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_UNCHECKED_XPOS;
5875 gd_x3 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_CHECKED_XPOS;
5876 gd_x4 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_CHECKED_XPOS;
5877 gd_y = DOOR_GFX_PAGEY1 + ED_RADIOBUTTON_YPOS;
5879 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
5881 int id = checkbutton_info[i].gadget_id;
5882 int x = SX + checkbutton_info[i].x;
5883 int y = SY + checkbutton_info[i].y;
5885 if (id == GADGET_ID_STICK_ELEMENT)
5886 gd_y = DOOR_GFX_PAGEY1 + ED_STICKYBUTTON_YPOS;
5888 gd_y = DOOR_GFX_PAGEY1 + ED_CHECKBUTTON_YPOS;
5890 /* determine horizontal position to the right of specified gadget */
5891 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
5892 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
5893 ED_GADGET_TEXT_DISTANCE);
5895 /* determine horizontal offset for leading text */
5896 if (checkbutton_info[i].text_left != NULL)
5897 x += getTextWidthForGadget(checkbutton_info[i].text_left);
5899 gi = CreateGadget(GDI_CUSTOM_ID, id,
5900 GDI_CUSTOM_TYPE_ID, i,
5901 GDI_INFO_TEXT, checkbutton_info[i].infotext,
5904 GDI_WIDTH, ED_CHECKBUTTON_XSIZE,
5905 GDI_HEIGHT, ED_CHECKBUTTON_YSIZE,
5906 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
5907 GDI_CHECKED, *checkbutton_info[i].value,
5908 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
5909 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
5910 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y,
5911 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y,
5912 GDI_EVENT_MASK, event_mask,
5913 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5914 GDI_CALLBACK_ACTION, HandleCheckbuttons,
5918 Error(ERR_EXIT, "cannot create gadget");
5920 level_editor_gadget[id] = gi;
5921 right_gadget_border[id] =
5922 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
5926 static void CreateRadiobuttonGadgets()
5928 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5929 struct GadgetInfo *gi;
5930 unsigned long event_mask;
5931 int gd_x1, gd_x2, gd_x3, gd_x4, gd_y;
5934 event_mask = GD_EVENT_PRESSED;
5936 gd_x1 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_UNCHECKED_XPOS;
5937 gd_x2 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_UNCHECKED_XPOS;
5938 gd_x3 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_CHECKED_XPOS;
5939 gd_x4 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_CHECKED_XPOS;
5940 gd_y = DOOR_GFX_PAGEY1 + ED_RADIOBUTTON_YPOS;
5942 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
5944 int id = radiobutton_info[i].gadget_id;
5945 int x = SX + radiobutton_info[i].x;
5946 int y = SY + radiobutton_info[i].y;
5949 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
5951 /* determine horizontal position to the right of specified gadget */
5952 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
5953 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
5954 ED_GADGET_TEXT_DISTANCE);
5956 /* determine horizontal offset for leading text */
5957 if (radiobutton_info[i].text_left != NULL)
5958 x += getTextWidthForGadget(radiobutton_info[i].text_left);
5960 gi = CreateGadget(GDI_CUSTOM_ID, id,
5961 GDI_CUSTOM_TYPE_ID, i,
5962 GDI_INFO_TEXT, radiobutton_info[i].infotext,
5965 GDI_WIDTH, ED_CHECKBUTTON_XSIZE,
5966 GDI_HEIGHT, ED_CHECKBUTTON_YSIZE,
5967 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
5968 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
5969 GDI_CHECKED, checked,
5970 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
5971 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
5972 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y,
5973 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y,
5974 GDI_EVENT_MASK, event_mask,
5975 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5976 GDI_CALLBACK_ACTION, HandleRadiobuttons,
5980 Error(ERR_EXIT, "cannot create gadget");
5982 level_editor_gadget[id] = gi;
5983 right_gadget_border[id] =
5984 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
5988 void CreateLevelEditorGadgets()
5990 int old_game_status = game_status;
5992 /* setting 'game_status' is needed to get the right fonts for the editor */
5993 game_status = GAME_MODE_EDITOR;
5995 ReinitializeElementList();
5997 CreateControlButtons();
5998 CreateScrollbarGadgets();
6000 /* order of function calls is important because of cross-references */
6001 CreateCheckbuttonGadgets();
6002 CreateCounterButtons();
6003 CreateRadiobuttonGadgets();
6004 CreateTextInputGadgets();
6005 CreateTextAreaGadgets();
6006 CreateSelectboxGadgets();
6007 CreateGraphicbuttonGadgets();
6008 CreateTextbuttonGadgets();
6009 CreateDrawingAreas();
6011 game_status = old_game_status;
6014 void FreeLevelEditorGadgets()
6018 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
6020 FreeGadget(level_editor_gadget[i]);
6022 level_editor_gadget[i] = NULL;
6026 static void MapCounterButtons(int id)
6028 int gadget_id_down = counterbutton_info[id].gadget_id_down;
6029 int gadget_id_text = counterbutton_info[id].gadget_id_text;
6030 int gadget_id_up = counterbutton_info[id].gadget_id_up;
6031 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
6032 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
6033 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
6034 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
6035 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6036 int yoffset_above = MINI_TILEX + ED_GADGET_DISTANCE;
6037 int yoffset = ED_BORDER_SIZE;
6038 int x_left = gi_down->x - xoffset_left;
6039 int x_right; /* set after gadget position was modified */
6040 int y_above = gi_down->y - yoffset_above;
6042 int y; /* set after gadget position was modified */
6044 /* counter limits must be changed first to prevent value truncation */
6045 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
6046 counterbutton_info[id].max_value);
6048 /* right text position might have changed after setting position above */
6049 x_right = gi_up->x + gi_up->width + xoffset_right;
6051 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
6053 /* set position for "value[1,2,3,4]" counter gadgets (score in most cases) */
6054 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
6055 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
6057 ModifyGadget(gi_down, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
6058 ModifyGadget(gi_text, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
6059 ModifyGadget(gi_up, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
6062 /* vertical position might have changed after setting position above */
6063 y = gi_up->y + yoffset;
6065 if (counterbutton_info[id].text_above)
6066 DrawText(x, y_above, counterbutton_info[id].text_above, FONT_TEXT_1);
6068 if (counterbutton_info[id].text_left)
6069 DrawText(x_left, y, counterbutton_info[id].text_left, FONT_TEXT_1);
6071 if (counterbutton_info[id].text_right)
6072 DrawText(x_right, y, counterbutton_info[id].text_right, FONT_TEXT_1);
6079 static void MapControlButtons()
6084 /* map toolbox buttons (excluding special CE toolbox buttons) */
6085 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
6086 MapGadget(level_editor_gadget[i]);
6088 /* map buttons to select elements */
6089 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6090 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
6091 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
6092 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
6093 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
6095 /* map buttons to select level */
6096 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
6097 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
6098 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
6099 MapCounterButtons(counter_id);
6102 static void MapDrawingArea(int id)
6104 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6105 int area_xsize = gi->drawing.area_xsize;
6106 int area_ysize = gi->drawing.area_ysize;
6107 int xoffset_left= getTextWidthForDrawingArea(drawingarea_info[id].text_left);
6108 int xoffset_below= getTextWidth(drawingarea_info[id].text_below,FONT_TEXT_1);
6109 int x_left = gi->x - xoffset_left;
6110 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
6111 int x_below = gi->x + (gi->width - xoffset_below) / 2;
6112 int y_side = gi->y + (gi->height - getFontHeight(FONT_TEXT_1)) / 2;
6113 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
6115 if (drawingarea_info[id].text_left)
6116 DrawText(x_left, y_side, drawingarea_info[id].text_left, FONT_TEXT_1);
6118 if (drawingarea_info[id].text_right)
6119 DrawText(x_right, y_side, drawingarea_info[id].text_right, FONT_TEXT_1);
6121 if (drawingarea_info[id].text_below)
6122 DrawText(x_below, y_below, drawingarea_info[id].text_below, FONT_TEXT_1);
6124 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
6126 DrawElementBorder(gi->x, gi->y,
6127 area_xsize * MINI_TILEX, area_ysize * MINI_TILEY, TRUE);
6129 DrawDrawingArea(id);
6135 static void MapTextInputGadget(int id)
6137 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
6138 int xoffset_above = 0;
6139 int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
6140 int x_above = textinput_info[id].x + xoffset_above;
6141 int y_above = textinput_info[id].y + yoffset_above;
6143 if (textinput_info[id].text_above)
6144 DrawTextS(x_above, y_above, FONT_TEXT_1, textinput_info[id].text_above);
6146 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
6151 static void MapTextAreaGadget(int id)
6153 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
6154 int xoffset_above = 0;
6155 int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
6156 int x_above = textarea_info[id].x + xoffset_above;
6157 int y_above = textarea_info[id].y + yoffset_above;
6159 if (textarea_info[id].text_above)
6160 DrawTextS(x_above, y_above, FONT_TEXT_1, textarea_info[id].text_above);
6162 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
6167 static void MapSelectboxGadget(int id)
6169 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
6170 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
6171 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6172 int yoffset = ED_BORDER_SIZE;
6173 int x_left = gi->x - xoffset_left;
6174 int x_right = gi->x + gi->width + xoffset_right;
6175 int y = gi->y + yoffset;
6177 if (selectbox_info[id].text_left)
6178 DrawText(x_left, y, selectbox_info[id].text_left, FONT_TEXT_1);
6180 if (selectbox_info[id].text_right)
6181 DrawText(x_right, y, selectbox_info[id].text_right, FONT_TEXT_1);
6183 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
6188 static void MapTextbuttonGadget(int id)
6190 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
6191 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
6192 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6193 int yoffset = ED_BORDER_SIZE;
6194 int x_left = gi->x - xoffset_left;
6195 int x_right = gi->x + gi->width + xoffset_right;
6196 int y = gi->y + yoffset;
6198 /* only show button to delete change pages when more than minimum pages */
6199 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
6200 custom_element.num_change_pages == MIN_CHANGE_PAGES)
6203 if (textbutton_info[id].text_left)
6204 DrawText(x_left, y, textbutton_info[id].text_left, FONT_TEXT_1);
6206 if (textbutton_info[id].text_right)
6207 DrawText(x_right, y, textbutton_info[id].text_right, FONT_TEXT_1);
6212 static void MapGraphicbuttonGadget(int id)
6214 struct GadgetInfo *gi= level_editor_gadget[graphicbutton_info[id].gadget_id];
6215 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
6216 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6217 int yoffset = ED_BORDER_SIZE;
6218 int x_left = gi->x - xoffset_left;
6219 int x_right = gi->x + gi->width + xoffset_right;
6220 int y = gi->y + yoffset;
6222 if (graphicbutton_info[id].text_left)
6223 DrawText(x_left, y, graphicbutton_info[id].text_left, FONT_TEXT_1);
6225 if (graphicbutton_info[id].text_right)
6226 DrawText(x_right, y, graphicbutton_info[id].text_right, FONT_TEXT_1);
6231 static void MapRadiobuttonGadget(int id)
6233 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
6234 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
6235 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6236 int yoffset = ED_BORDER_SIZE;
6237 int x_left = gi->x - xoffset_left;
6238 int x_right = gi->x + gi->width + xoffset_right;
6239 int y = gi->y + yoffset;
6241 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
6243 if (radiobutton_info[id].text_left)
6244 DrawText(x_left, y, radiobutton_info[id].text_left, FONT_TEXT_1);
6246 if (radiobutton_info[id].text_right)
6247 DrawText(x_right, y, radiobutton_info[id].text_right, FONT_TEXT_1);
6249 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
6254 static void MapCheckbuttonGadget(int id)
6256 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
6257 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
6258 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6259 int yoffset = ED_BORDER_SIZE;
6260 int x_left, x_right, y; /* set after gadget position was modified */
6262 /* set position for gadgets with dynamically determined position */
6263 if (checkbutton_info[id].x != -1) /* do not change dynamic positions */
6264 ModifyGadget(gi, GDI_X, SX + checkbutton_info[id].x, GDI_END);
6265 ModifyGadget(gi, GDI_Y, SY + checkbutton_info[id].y, GDI_END);
6267 x_left = gi->x - xoffset_left;
6268 x_right = gi->x + gi->width + xoffset_right;
6269 y = gi->y + yoffset;
6271 if (checkbutton_info[id].text_left)
6272 DrawText(x_left, y, checkbutton_info[id].text_left, FONT_TEXT_1);
6274 if (checkbutton_info[id].text_right)
6275 DrawText(x_right, y, checkbutton_info[id].text_right, FONT_TEXT_1);
6277 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
6282 static void MapMainDrawingArea()
6284 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
6285 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
6288 for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
6290 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
6291 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
6292 no_horizontal_scrollbar) ||
6293 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
6294 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
6295 no_vertical_scrollbar))
6298 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
6301 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
6303 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
6304 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
6307 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
6310 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
6313 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
6317 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6319 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
6320 i == GADGET_ID_CUSTOM_COPY_TO ||
6321 i == GADGET_ID_CUSTOM_EXCHANGE ||
6322 i == GADGET_ID_CUSTOM_COPY ||
6323 i == GADGET_ID_CUSTOM_PASTE)
6326 MapGadget(level_editor_gadget[i]);
6328 UnmapGadget(level_editor_gadget[i]);
6333 static void MapLevelEditorToolboxCustomGadgets()
6335 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
6338 static void UnmapLevelEditorToolboxCustomGadgets()
6340 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
6343 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
6345 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
6348 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
6350 if (i != GADGET_ID_SINGLE_ITEMS &&
6351 i != GADGET_ID_PROPERTIES &&
6352 i != GADGET_ID_PICK_ELEMENT)
6354 struct GadgetInfo *gi = level_editor_gadget[i];
6362 BlitBitmap(gd_bitmap, drawto,
6363 DOOR_GFX_PAGEX6 + ED_CTRL_NO_BUTTONS_GFX_XPOS,
6364 DOOR_GFX_PAGEY1 + ED_CTRL_NO_BUTTONS_GFX_YPOS,
6365 gi->width, gi->height, gi->x, gi->y);
6367 redraw_mask |= REDRAW_DOOR_3;
6373 static void MapLevelEditorToolboxDrawingGadgets()
6375 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
6378 static void UnmapLevelEditorToolboxDrawingGadgets()
6380 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
6383 static void UnmapDrawingArea(int id)
6385 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
6388 static void UnmapLevelEditorWindowGadgets()
6392 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
6393 if (level_editor_gadget[i]->x < SX + SXSIZE)
6394 UnmapGadget(level_editor_gadget[i]);
6397 void UnmapLevelEditorGadgets()
6401 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
6402 UnmapGadget(level_editor_gadget[i]);
6405 static void ResetUndoBuffer()
6407 undo_buffer_position = -1;
6408 undo_buffer_steps = -1;
6409 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
6411 level.changed = FALSE;
6414 static void DrawEditModeWindow()
6416 ModifyEditorElementList();
6417 RedrawDrawingElements();
6419 if (edit_mode == ED_MODE_INFO)
6420 DrawLevelInfoWindow();
6421 else if (edit_mode == ED_MODE_PROPERTIES)
6422 DrawPropertiesWindow();
6423 else /* edit_mode == ED_MODE_DRAWING */
6424 DrawDrawingWindow();
6427 static boolean LevelChanged()
6429 boolean field_changed = FALSE;
6432 if (leveldir_current->readonly)
6435 for (y = 0; y < lev_fieldy; y++)
6436 for (x = 0; x < lev_fieldx; x++)
6437 if (Feld[x][y] != level.field[x][y])
6438 field_changed = TRUE;
6440 return (level.changed || field_changed);
6443 static boolean LevelContainsPlayer()
6445 boolean player_found = FALSE;
6448 return TRUE; /* !!! CURRENTLY DEACTIVATED !!! */
6450 for (y = 0; y < lev_fieldy; y++) for (x = 0; x < lev_fieldx; x++)
6452 if (Feld[x][y] == EL_PLAYER_1 ||
6453 Feld[x][y] == EL_SP_MURPHY)
6454 player_found = TRUE;
6457 return player_found;
6460 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
6461 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
6465 for (x = 0; x < lev_fieldx; x++)
6466 for (y = 0; y < lev_fieldy; y++)
6467 dst[x][y] = src[x][y];
6470 static int setSelectboxValue(int selectbox_id, int new_value)
6472 int new_index_value = 0;
6475 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
6476 if (selectbox_info[selectbox_id].options[i].value == new_value)
6477 new_index_value = i;
6479 *selectbox_info[selectbox_id].value =
6480 selectbox_info[selectbox_id].options[new_index_value].value;
6482 return new_index_value;
6485 static void setSelectboxSpecialActionVariablesIfNeeded()
6489 /* change action mode and arg variables according to action type variable */
6490 for (i = 0; action_arg_options[i].value != -1; i++)
6492 if (action_arg_options[i].value == custom_element_change.action_type)
6494 int mode = action_arg_options[i].mode;
6496 /* only change if corresponding selectbox has changed */
6497 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
6498 action_arg_modes[mode])
6499 custom_element_change.action_mode = -1;
6501 /* only change if corresponding selectbox has changed */
6502 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
6503 action_arg_options[i].options)
6504 custom_element_change.action_arg = -1;
6511 static void setSelectboxSpecialActionOptions()
6515 /* change action mode and arg selectbox according to action type selectbox */
6516 for (i = 0; action_arg_options[i].value != -1; i++)
6518 if (action_arg_options[i].value == custom_element_change.action_type)
6520 int mode = action_arg_options[i].mode;
6522 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
6523 action_arg_modes[mode]);
6524 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
6525 custom_element_change.action_mode);
6527 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
6528 action_arg_options[i].options);
6529 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
6530 custom_element_change.action_arg);
6536 static void copy_custom_element_settings(int element_from, int element_to)
6538 struct ElementInfo *ei_from = &element_info[element_from];
6539 struct ElementInfo *ei_to = &element_info[element_to];
6541 copyElementInfo(ei_from, ei_to);
6544 static void replace_custom_element_in_settings(int element_from,
6549 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6551 struct ElementInfo *ei = &element_info[i];
6553 for (y = 0; y < 3; y++)
6554 for (x = 0; x < 3; x++)
6555 if (ei->content.e[x][y] == element_from)
6556 ei->content.e[x][y] = element_to;
6558 for (j = 0; j < ei->num_change_pages; j++)
6560 struct ElementChangeInfo *change = &ei->change_page[j];
6562 if (change->target_element == element_from)
6563 change->target_element = element_to;
6565 if (change->trigger_element == element_from)
6566 change->trigger_element = element_to;
6568 for (y = 0; y < 3; y++)
6569 for (x = 0; x < 3; x++)
6570 if (change->target_content.e[x][y] == element_from)
6571 change->target_content.e[x][y] = element_to;
6574 if (ei->group != NULL) /* group or internal */
6575 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
6576 if (ei->group->element[j] == element_from)
6577 ei->group->element[j] = element_to;
6581 static void replace_custom_element_in_playfield(int element_from,
6586 for (x = 0; x < lev_fieldx; x++)
6587 for (y = 0; y < lev_fieldy; y++)
6588 if (Feld[x][y] == element_from)
6589 Feld[x][y] = element_to;
6592 static boolean CopyCustomElement(int element_old, int element_new,
6595 if (copy_mode == GADGET_ID_CUSTOM_COPY)
6597 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
6598 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
6599 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
6601 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
6603 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
6604 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
6605 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
6607 level.changed = TRUE;
6609 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
6611 Request("Please choose custom element !", REQ_CONFIRM);
6615 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
6617 Request("Please choose group element !", REQ_CONFIRM);
6623 level.changed = TRUE;
6626 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
6628 copy_custom_element_settings(element_new, element_old);
6630 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
6632 copy_custom_element_settings(element_old, element_new);
6634 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
6636 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
6637 copy_custom_element_settings(element_new, element_old);
6638 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
6640 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
6641 replace_custom_element_in_settings(element_new, element_old);
6642 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
6644 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
6645 replace_custom_element_in_playfield(element_new, element_old);
6646 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
6649 UpdateCustomElementGraphicGadgets();
6650 DrawPropertiesWindow();
6655 static void CopyCustomElementPropertiesToEditor(int element)
6658 int current_change_page = element_info[element].current_change_page;
6660 /* dynamically (re)build selectbox for selecting change page */
6661 for (i = 0; i < element_info[element].num_change_pages; i++)
6663 sprintf(options_change_page_strings[i], "%d", i + 1);
6665 options_change_page[i].value = i;
6666 options_change_page[i].text = options_change_page_strings[i];
6669 options_change_page[i].value = -1;
6670 options_change_page[i].text = NULL;
6672 /* needed here to initialize combined element properties */
6673 InitElementPropertiesEngine(level.game_version);
6675 element_info[element].change =
6676 &element_info[element].change_page[current_change_page];
6678 custom_element = element_info[element];
6679 custom_element_change = *element_info[element].change;
6681 /* needed to initially set selectbox options for special action options */
6682 setSelectboxSpecialActionOptions();
6684 /* needed to initially set selectbox value variables to reliable defaults */
6685 for (i = 0; i < ED_NUM_SELECTBOX; i++)
6686 setSelectboxValue(i, *selectbox_info[i].value);
6688 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
6689 custom_element_properties[i] = HAS_PROPERTY(element, i);
6691 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
6692 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
6694 /* ---------- element settings: configure (custom elements) ------------- */
6696 /* set accessible layer selectbox help value */
6697 custom_element.access_type =
6698 (IS_WALKABLE(element) ? EP_WALKABLE :
6699 IS_PASSABLE(element) ? EP_PASSABLE :
6700 custom_element.access_type);
6701 custom_element.access_layer =
6702 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
6703 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
6704 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
6705 custom_element.access_layer);
6706 custom_element.access_protected =
6707 (IS_PROTECTED(element) ? 1 : 0);
6708 custom_element_properties[EP_ACCESSIBLE] =
6709 (IS_ACCESSIBLE_OVER(element) ||
6710 IS_ACCESSIBLE_INSIDE(element) ||
6711 IS_ACCESSIBLE_UNDER(element));
6713 /* set walk-to-object action selectbox help value */
6714 custom_element.walk_to_action =
6715 (IS_DIGGABLE(element) ? EP_DIGGABLE :
6716 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
6717 IS_DROPPABLE(element) ? EP_DROPPABLE :
6718 IS_THROWABLE(element) ? EP_THROWABLE :
6719 IS_PUSHABLE(element) ? EP_PUSHABLE :
6720 custom_element.walk_to_action);
6721 custom_element_properties[EP_WALK_TO_OBJECT] =
6722 (IS_DIGGABLE(element) ||
6723 IS_COLLECTIBLE_ONLY(element) ||
6724 IS_DROPPABLE(element) ||
6725 IS_THROWABLE(element) ||
6726 IS_PUSHABLE(element));
6728 /* set smash targets selectbox help value */
6729 custom_element.smash_targets =
6730 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
6731 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
6732 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
6733 custom_element.smash_targets);
6734 custom_element_properties[EP_CAN_SMASH] =
6735 (CAN_SMASH_EVERYTHING(element) ||
6736 CAN_SMASH_ENEMIES(element) ||
6737 CAN_SMASH_PLAYER(element));
6739 /* set deadliness selectbox help value */
6740 custom_element.deadliness =
6741 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
6742 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
6743 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
6744 custom_element.deadliness);
6745 custom_element_properties[EP_DEADLY] =
6746 (DONT_TOUCH(element) ||
6747 DONT_COLLIDE_WITH(element) ||
6748 DONT_RUN_INTO(element));
6750 /* ---------- element settings: advanced (custom elements) --------------- */
6752 /* set "change by direct action" selectbox help value */
6753 custom_element_change.direct_action =
6754 (HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
6755 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
6756 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
6757 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
6758 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
6759 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
6760 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
6761 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
6762 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
6763 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
6764 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
6765 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
6766 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
6767 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
6768 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
6769 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
6770 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
6771 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
6772 custom_element_change.direct_action);
6774 /* set "change by other element action" selectbox help value */
6775 custom_element_change.other_action =
6776 (HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
6777 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
6778 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
6779 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
6780 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
6781 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
6782 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
6783 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
6784 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
6785 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
6786 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
6787 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
6788 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
6789 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
6790 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
6791 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
6792 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
6793 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
6794 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
6795 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
6796 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
6797 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
6798 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
6799 custom_element_change.other_action);
6802 static void CopyGroupElementPropertiesToEditor(int element)
6804 group_element_info = *element_info[element].group;
6805 custom_element = element_info[element]; /* needed for description */
6808 static void CopyClassicElementPropertiesToEditor(int element)
6810 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
6811 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
6812 getMoveIntoAcidProperty(&level, element);
6814 if (MAYBE_DONT_COLLIDE_WITH(element))
6815 custom_element_properties[EP_DONT_COLLIDE_WITH] =
6816 getDontCollideWithProperty(&level, element);
6819 static void CopyElementPropertiesToEditor(int element)
6821 if (IS_CUSTOM_ELEMENT(element))
6822 CopyCustomElementPropertiesToEditor(element);
6823 else if (IS_GROUP_ELEMENT(element))
6824 CopyGroupElementPropertiesToEditor(element);
6826 CopyClassicElementPropertiesToEditor(element);
6829 static void CopyCustomElementPropertiesToGame(int element)
6832 int access_type_and_layer;
6834 /* mark that this custom element has been modified */
6835 custom_element.modified_settings = TRUE;
6836 level.changed = TRUE;
6838 if (level.use_custom_template)
6840 if (Request("Copy and modify level template ?", REQ_ASK))
6842 level.use_custom_template = FALSE;
6843 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE],
6844 GDI_CHECKED, FALSE, GDI_END);
6848 LoadLevelTemplate(-1); /* this resets all element modifications ... */
6850 DrawEditModeWindow(); /* ... and copies them to 'custom_element' */
6854 element_info[element] = custom_element;
6855 *element_info[element].change = custom_element_change;
6857 /* ---------- element settings: configure (custom elements) ------------- */
6859 /* set accessible property from checkbox and selectbox */
6860 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
6861 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
6862 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
6863 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
6864 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
6865 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
6866 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
6867 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
6868 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
6869 custom_element_properties[access_type_and_layer] =
6870 custom_element_properties[EP_ACCESSIBLE];
6871 custom_element_properties[EP_PROTECTED] =
6872 (custom_element.access_protected != 0 &&
6873 custom_element_properties[EP_ACCESSIBLE]);
6875 /* set walk-to-object property from checkbox and selectbox */
6876 custom_element_properties[EP_DIGGABLE] = FALSE;
6877 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
6878 custom_element_properties[EP_DROPPABLE] = FALSE;
6879 custom_element_properties[EP_THROWABLE] = FALSE;
6880 custom_element_properties[EP_PUSHABLE] = FALSE;
6881 custom_element_properties[custom_element.walk_to_action] =
6882 custom_element_properties[EP_WALK_TO_OBJECT];
6884 /* set smash property from checkbox and selectbox */
6885 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
6886 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
6887 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
6888 custom_element_properties[custom_element.smash_targets] =
6889 custom_element_properties[EP_CAN_SMASH];
6891 /* set deadliness property from checkbox and selectbox */
6892 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
6893 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
6894 custom_element_properties[EP_DONT_TOUCH] = FALSE;
6895 custom_element_properties[custom_element.deadliness] =
6896 custom_element_properties[EP_DEADLY];
6898 /* ---------- element settings: advanced (custom elements) --------------- */
6900 /* set player change event from checkbox and selectbox */
6901 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
6902 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
6903 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
6904 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
6905 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
6906 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
6907 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
6908 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
6909 custom_element_change_events[CE_SWITCHED] = FALSE;
6910 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
6911 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
6912 custom_element_change_events[CE_BLOCKED] = FALSE;
6913 custom_element_change_events[CE_IMPACT] = FALSE;
6914 custom_element_change_events[CE_SMASHED] = FALSE;
6915 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
6916 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
6917 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
6918 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
6919 custom_element_change_events[custom_element_change.direct_action] =
6920 custom_element_change_events[CE_BY_DIRECT_ACTION];
6922 /* set other element action change event from checkbox and selectbox */
6923 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
6924 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
6925 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
6926 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
6927 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
6928 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
6929 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
6930 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
6931 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
6932 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
6933 custom_element_change_events[CE_TOUCHING_X] = FALSE;
6934 custom_element_change_events[CE_HITTING_X] = FALSE;
6935 custom_element_change_events[CE_DIGGING_X] = FALSE;
6936 custom_element_change_events[CE_HIT_BY_X] = FALSE;
6937 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
6938 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
6939 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
6940 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
6941 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
6942 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
6943 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
6944 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
6945 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
6946 custom_element_change_events[custom_element_change.other_action] =
6947 custom_element_change_events[CE_BY_OTHER_ACTION];
6949 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
6950 SET_PROPERTY(element, i, custom_element_properties[i]);
6952 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
6953 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
6955 /* copy change events also to special level editor variable */
6956 custom_element = element_info[element];
6957 custom_element_change = *element_info[element].change;
6960 static void CopyGroupElementPropertiesToGame(int element)
6962 element_info[element] = custom_element;
6963 *element_info[element].group = group_element_info;
6965 /* mark that this group element has been modified */
6966 element_info[element].modified_settings = TRUE;
6967 level.changed = TRUE;
6970 static void CopyClassicElementPropertiesToGame(int element)
6972 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
6973 setMoveIntoAcidProperty(&level, element,
6974 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
6976 if (MAYBE_DONT_COLLIDE_WITH(element))
6977 setDontCollideWithProperty(&level, element,
6978 custom_element_properties[EP_DONT_COLLIDE_WITH]);
6981 static void CopyElementPropertiesToGame(int element)
6983 if (IS_CUSTOM_ELEMENT(element))
6984 CopyCustomElementPropertiesToGame(element);
6985 else if (IS_GROUP_ELEMENT(element))
6986 CopyGroupElementPropertiesToGame(element);
6988 CopyClassicElementPropertiesToGame(element);
6991 void CheckElementDescriptions()
6995 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6996 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
6997 Error(ERR_WARN, "no element description for element '%s'", EL_NAME(i));
7002 CloseDoor(DOOR_CLOSE_ALL);
7005 FadeOut(REDRAW_FIELD);
7008 OpenDoor(DOOR_OPEN_2 | DOOR_NO_DELAY);
7011 CheckElementDescriptions();
7014 if (level_editor_test_game)
7016 CopyPlayfield(level.field, Feld);
7017 CopyPlayfield(FieldBackup, level.field);
7019 level_editor_test_game = FALSE;
7023 edit_mode = ED_MODE_DRAWING;
7024 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
7032 /* copy default editor door content to main double buffer */
7033 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
7034 DOOR_GFX_PAGEX6, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
7036 /* draw bigger door */
7037 DrawSpecialEditorDoor();
7039 /* draw new control window */
7040 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
7041 DOOR_GFX_PAGEX8, 236, EXSIZE, EYSIZE, EX, EY);
7043 redraw_mask |= REDRAW_ALL;
7045 ReinitializeElementList(); /* update dynamic level element list */
7046 ReinitializeElementListButtons(); /* custom element may look different */
7053 MapControlButtons();
7056 FadeOut(REDRAW_FIELD);
7059 DrawEditModeWindow();
7062 FadeIn(REDRAW_FIELD);
7065 /* copy actual editor door content to door double buffer for OpenDoor() */
7066 BlitBitmap(drawto, bitmap_db_door,
7067 DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
7070 /* draw new control window (with border) to window */
7071 redraw_mask |= REDRAW_ALL;
7075 OpenDoor(DOOR_OPEN_1);
7078 static void AdjustDrawingAreaGadgets()
7080 int ed_xsize = lev_fieldx + 2;
7081 int ed_ysize = lev_fieldy + 2;
7082 int max_ed_fieldx = MAX_ED_FIELDX;
7083 int max_ed_fieldy = MAX_ED_FIELDY;
7084 boolean horizontal_scrollbar_needed;
7085 boolean vertical_scrollbar_needed;
7086 int x, y, width, height;
7087 int xoffset, yoffset;
7089 /* check if we need any scrollbars */
7090 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
7091 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
7093 /* check if we have a smaller editor field because of scrollbars */
7094 if (horizontal_scrollbar_needed)
7095 max_ed_fieldy = MAX_ED_FIELDY - 1;
7096 if (vertical_scrollbar_needed)
7097 max_ed_fieldx = MAX_ED_FIELDX - 1;
7099 /* check again if we now need more scrollbars because of less space */
7100 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
7101 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
7103 /* check if editor field gets even smaller after adding new scrollbars */
7104 if (horizontal_scrollbar_needed)
7105 max_ed_fieldy = MAX_ED_FIELDY - 1;
7106 if (vertical_scrollbar_needed)
7107 max_ed_fieldx = MAX_ED_FIELDX - 1;
7109 ed_fieldx = (ed_xsize < MAX_ED_FIELDX ? ed_xsize : max_ed_fieldx);
7110 ed_fieldy = (ed_ysize < MAX_ED_FIELDY ? ed_ysize : max_ed_fieldy);
7112 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
7113 GDI_WIDTH, ed_fieldx * MINI_TILEX,
7114 GDI_HEIGHT, ed_fieldy * MINI_TILEY,
7115 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
7118 xoffset = (ed_fieldx == MAX_ED_FIELDX ? ED_SCROLLBUTTON_XSIZE : 0);
7119 yoffset = (ed_fieldy == MAX_ED_FIELDY ? ED_SCROLLBUTTON_YSIZE : 0);
7121 x = SX + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_RIGHT].x + xoffset;
7122 y = SX + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_DOWN].y + yoffset;
7124 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT], GDI_X, x, GDI_END);
7125 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN], GDI_Y, y, GDI_END);
7127 width = scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width + xoffset;
7128 height = scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].height + yoffset;
7130 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
7132 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
7134 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
7136 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
7140 static void AdjustLevelScrollPosition()
7142 if (level_xpos < -1)
7144 if (level_xpos > lev_fieldx - ed_fieldx + 1)
7145 level_xpos = lev_fieldx - ed_fieldx + 1;
7146 if (lev_fieldx < ed_fieldx - 2)
7149 if (level_ypos < -1)
7151 if (level_ypos > lev_fieldy - ed_fieldy + 1)
7152 level_ypos = lev_fieldy - ed_fieldy + 1;
7153 if (lev_fieldy < ed_fieldy - 2)
7157 static void AdjustEditorScrollbar(int id)
7159 struct GadgetInfo *gi = level_editor_gadget[id];
7160 int items_max, items_visible, item_position;
7162 if (id == GADGET_ID_SCROLL_HORIZONTAL)
7164 items_max = MAX(lev_fieldx + 2, ed_fieldx);
7165 items_visible = ed_fieldx;
7166 item_position = level_xpos + 1;
7170 items_max = MAX(lev_fieldy + 2, ed_fieldy);
7171 items_visible = ed_fieldy;
7172 item_position = level_ypos + 1;
7175 if (item_position > items_max - items_visible)
7176 item_position = items_max - items_visible;
7178 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
7179 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
7182 static void AdjustElementListScrollbar()
7184 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
7185 int items_max, items_visible, item_position;
7187 /* correct position of element list scrollbar */
7188 if (element_shift < 0)
7190 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
7191 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
7193 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
7194 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
7195 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
7197 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
7198 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7199 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
7202 static void ModifyEditorCounterValue(int counter_id, int new_value)
7204 int *counter_value = counterbutton_info[counter_id].value;
7205 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
7206 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7208 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
7210 if (counter_value != NULL)
7211 *counter_value = gi->textinput.number_value;
7214 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
7216 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
7217 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7219 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
7221 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
7222 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
7224 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
7225 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
7227 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
7228 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_DISTANCE,GDI_END);
7232 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
7234 int gadget_id = selectbox_info[selectbox_id].gadget_id;
7235 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7236 int new_index_value = setSelectboxValue(selectbox_id, new_value);
7238 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
7241 static void ModifyEditorSelectboxOptions(int selectbox_id,
7242 struct ValueTextInfo *options)
7244 int gadget_id = selectbox_info[selectbox_id].gadget_id;
7245 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7247 selectbox_info[selectbox_id].options = options;
7249 /* set index to zero -- list may be shorter now (correct later, if needed) */
7250 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
7251 GDI_SELECTBOX_OPTIONS, options, GDI_END);
7254 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
7256 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
7257 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7259 drawingarea_info[drawingarea_id].area_xsize = xsize;
7260 drawingarea_info[drawingarea_id].area_ysize = ysize;
7262 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
7265 static void ModifyEditorElementList()
7269 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7271 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
7272 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7273 struct GadgetDesign *gd = &gi->deco.design;
7274 int element = editor_elements[element_shift + i];
7278 getMiniGraphicSource(el2edimg(element), &gd->bitmap, &gd->x, &gd->y);
7279 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
7285 static void PickDrawingElement(int button, int element)
7287 if (button < 1 || button > 3)
7292 new_element1 = element;
7293 DrawMiniGraphicExt(drawto,
7294 DX + ED_WIN_MB_LEFT_XPOS, DY + ED_WIN_MB_LEFT_YPOS,
7295 el2edimg(new_element1));
7297 else if (button == 2)
7299 new_element2 = element;
7300 DrawMiniGraphicExt(drawto,
7301 DX + ED_WIN_MB_MIDDLE_XPOS, DY + ED_WIN_MB_MIDDLE_YPOS,
7302 el2edimg(new_element2));
7306 new_element3 = element;
7307 DrawMiniGraphicExt(drawto,
7308 DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS,
7309 el2edimg(new_element3));
7312 redraw_mask |= REDRAW_DOOR_1;
7315 static void RedrawDrawingElements()
7317 PickDrawingElement(1, new_element1);
7318 PickDrawingElement(2, new_element2);
7319 PickDrawingElement(3, new_element3);
7322 static void DrawDrawingWindow()
7324 stick_element_properties_window = FALSE;
7326 SetMainBackgroundImage(IMG_UNDEFINED);
7329 UnmapLevelEditorWindowGadgets();
7330 UnmapLevelEditorToolboxCustomGadgets();
7332 AdjustDrawingAreaGadgets();
7333 AdjustLevelScrollPosition();
7334 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
7335 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
7337 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7339 MapMainDrawingArea();
7340 MapLevelEditorToolboxDrawingGadgets();
7343 static void DrawLevelInfoWindow()
7347 stick_element_properties_window = FALSE;
7349 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
7351 UnmapLevelEditorWindowGadgets();
7354 DrawTextSCentered(ED_SETTINGS1_YPOS, FONT_TITLE_1, "Level Settings");
7355 DrawTextSCentered(ED_SETTINGS2_YPOS, FONT_TITLE_1, "Editor Settings");
7357 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS1_YPOS,
7358 "Level Settings", FONT_TITLE_1);
7359 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS2_YPOS,
7360 "Editor Settings", FONT_TITLE_1);
7363 /* draw counter gadgets */
7364 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
7365 MapCounterButtons(i);
7367 /* draw selectbox gadgets */
7368 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
7369 MapSelectboxGadget(i);
7371 /* draw checkbutton gadgets */
7372 for (i=ED_CHECKBUTTON_ID_LEVEL_FIRST; i <= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
7373 MapCheckbuttonGadget(i);
7375 /* draw radiobutton gadgets */
7376 for (i=ED_RADIOBUTTON_ID_LEVEL_FIRST; i <= ED_RADIOBUTTON_ID_LEVEL_LAST; i++)
7377 MapRadiobuttonGadget(i);
7379 /* draw text input gadgets */
7380 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
7381 MapTextInputGadget(i);
7383 /* draw drawing area */
7384 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
7387 static void DrawCustomContentArea()
7389 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
7390 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
7391 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
7392 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
7393 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
7394 int xoffset = ED_DRAWINGAREA_TEXT_DISTANCE;
7396 /* add distance for potential left text (without drawing area border) */
7397 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
7399 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
7401 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
7404 static void DrawCustomChangeContentArea()
7406 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
7407 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
7408 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
7409 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
7410 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
7411 int xoffset = ED_DRAWINGAREA_TEXT_DISTANCE;
7413 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
7418 static void DrawYamYamContentAreas()
7420 int x = SX + ED_AREA_YAMYAM_CONTENT_XPOS(3) + 4 * MINI_TILEX;
7421 int y = SY + ED_AREA_YAMYAM_CONTENT_YPOS(0) + ED_BORDER_AREA_YSIZE;
7424 /* display counter to choose number of element content areas */
7425 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
7427 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
7429 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
7431 if (i < level.num_yamyam_contents)
7437 int font_height = getFontHeight(FONT_TEXT_1);
7439 UnmapDrawingArea(id);
7441 /* delete content areas in case of reducing number of them */
7442 DrawBackground(SX + drawingarea_info[id].x - MINI_TILEX / 2,
7443 SY + drawingarea_info[id].y - MINI_TILEY / 2,
7445 4 * MINI_TILEY + ED_GADGET_TEXT_DISTANCE + font_height);
7449 DrawText(x, y + 0 * MINI_TILEY, "content", FONT_TEXT_1);
7450 DrawText(x, y + 1 * MINI_TILEY, "when", FONT_TEXT_1);
7451 DrawText(x, y + 2 * MINI_TILEY, "smashed", FONT_TEXT_1);
7454 static void DrawMagicBallContentAreas()
7456 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_XPOS(3) + 4 * MINI_TILEX;
7457 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_YPOS(0) + ED_BORDER_AREA_YSIZE;
7460 /* display counter to choose number of element content areas */
7461 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
7463 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
7465 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
7467 if (i < level.num_ball_contents)
7473 int font_height = getFontHeight(FONT_TEXT_1);
7475 UnmapDrawingArea(id);
7477 /* delete content areas in case of reducing number of them */
7478 DrawBackground(SX + drawingarea_info[id].x - MINI_TILEX / 2,
7479 SY + drawingarea_info[id].y - MINI_TILEY / 2,
7481 4 * MINI_TILEY + ED_GADGET_TEXT_DISTANCE + font_height);
7485 DrawText(x, y + 0 * MINI_TILEY, "generated", FONT_TEXT_1);
7486 DrawText(x, y + 1 * MINI_TILEY, "when", FONT_TEXT_1);
7487 DrawText(x, y + 2 * MINI_TILEY, "active", FONT_TEXT_1);
7490 static void DrawAndroidElementArea(int element)
7492 int num_elements = level.num_android_clone_elements;
7493 int id = ED_DRAWING_ID_ANDROID_CONTENT;
7494 int sx = SX + drawingarea_info[id].x - MINI_TILEX / 2;
7495 int sy = SY + drawingarea_info[id].y - MINI_TILEY / 2;
7496 int xsize = MAX_ANDROID_ELEMENTS;
7499 /* display counter to choose number of element areas */
7500 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
7502 if (drawingarea_info[id].text_left != NULL)
7503 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
7505 UnmapDrawingArea(id);
7507 ModifyEditorDrawingArea(id, num_elements, 1);
7509 /* delete content areas in case of reducing number of them */
7510 DrawBackground(sx, sy, (xsize + 1) * MINI_TILEX, (ysize + 1) * MINI_TILEY);
7515 static void DrawGroupElementArea(int element)
7517 int num_elements = group_element_info.num_elements;
7518 int id = ED_DRAWING_ID_GROUP_CONTENT;
7519 int sx = SX + drawingarea_info[id].x - MINI_TILEX / 2;
7520 int sy = SY + drawingarea_info[id].y - MINI_TILEY / 2;
7521 int xsize = MAX_ELEMENTS_IN_GROUP;
7524 if (drawingarea_info[id].text_left != NULL)
7525 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
7527 UnmapDrawingArea(id);
7529 ModifyEditorDrawingArea(id, num_elements, 1);
7531 /* delete content areas in case of reducing number of them */
7532 DrawBackground(sx, sy, (xsize + 1) * MINI_TILEX, (ysize + 1) * MINI_TILEY);
7537 static void DrawEnvelopeTextArea(int envelope_nr)
7539 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
7540 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
7543 DrawBackground(gi->x, gi->y, gi->width, gi->height);
7545 if (envelope_nr != -1)
7546 textarea_info[id].value = level.envelope[envelope_nr].text;
7548 ModifyGadget(gi, GDI_AREA_SIZE,
7549 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
7550 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
7553 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
7556 static boolean PrintInfoText(char *text, int font_nr, int start_line)
7558 int font_height = getFontHeight(font_nr);
7559 int pad_x = ED_ELEMENT_SETTINGS_XPOS(0);
7560 int pad_y = ED_ELEMENT_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
7561 int sx = SX + pad_x;
7562 int sy = SY + pad_y;
7563 int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
7565 if (start_line >= max_lines_per_screen)
7568 DrawText(sx, sy + start_line * font_height, text, font_nr);
7573 static int PrintElementDescriptionFromFile(char *filename, int start_line)
7575 int font_nr = FONT_TEXT_2;
7576 int font_width = getFontWidth(font_nr);
7577 int font_height = getFontHeight(font_nr);
7578 int pad_x = ED_ELEMENT_SETTINGS_XPOS(0);
7579 int pad_y = ED_ELEMENT_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
7580 int sx = SX + pad_x;
7581 int sy = SY + pad_y + start_line * font_height;
7582 int max_chars_per_line = (SXSIZE - 2 * pad_x) / font_width;
7583 int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
7585 return DrawTextFile(sx, sy, filename, font_nr, max_chars_per_line, -1,
7586 max_lines_per_screen, -1, TRUE, FALSE, FALSE);
7589 static void DrawPropertiesTabulatorGadgets()
7591 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
7592 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
7593 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
7594 int gd_x = gd->x + gd_gi1->border.width / 2;
7595 int gd_y = gd->y + gd_gi1->height - 1;
7596 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
7597 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
7598 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
7605 /* draw additional "change" tabulator for custom elements */
7606 if (IS_CUSTOM_ELEMENT(properties_element))
7607 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
7609 for (i = id_first; i <= id_last; i++)
7611 int gadget_id = textbutton_info[i].gadget_id;
7612 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7613 boolean active = (i != edit_mode_properties);
7615 /* use "config 1" and "config 2" instead of "config" */
7616 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
7617 IS_CUSTOM_ELEMENT(properties_element))
7620 /* draw background line below tabulator button */
7621 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
7623 /* draw solid line below inactive tabulator buttons */
7624 if (!active && tab_color != BLACK_PIXEL) /* black => transparent */
7625 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width, 1, tab_color);
7627 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
7628 MapTextbuttonGadget(i);
7632 /* draw little border line below tabulator buttons */
7633 if (tab_color != BLACK_PIXEL) /* black => transparent */
7634 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height + 1,
7635 gd_gi4->x - gd_gi1->x + gd_gi4->width, ED_GADGET_DISTANCE,
7638 /* draw little border line below tabulator buttons */
7639 if (tab_color != BLACK_PIXEL) /* black => transparent */
7640 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height + 1,
7641 max_tabs * gd_gi1->width + (max_tabs -1) * ED_GADGET_DISTANCE,
7642 ED_GADGET_DISTANCE, tab_color);
7646 static void DrawPropertiesInfo()
7655 /* configurable properties */
7657 { EP_WALKABLE_OVER, "- player can walk over it" },
7658 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
7659 { EP_WALKABLE_UNDER, "- player can walk under it" },
7660 { EP_PASSABLE_OVER, "- player can pass over it" },
7661 { EP_PASSABLE_INSIDE, "- player can pass through it" },
7662 { EP_PASSABLE_UNDER, "- player can pass under it" },
7663 { EP_PROTECTED, "- player is protected by it" },
7665 { EP_DIGGABLE, "- can be digged away" },
7666 { EP_COLLECTIBLE, "- can be collected" },
7667 { EP_DROPPABLE, "- can be dropped after collecting" },
7668 { EP_THROWABLE, "- can be thrown after collecting" },
7669 { EP_PUSHABLE, "- can be pushed" },
7671 { EP_CAN_FALL, "- can fall" },
7672 { EP_CAN_MOVE, "- can move" },
7674 { EP_CAN_SMASH_PLAYER, "- can smash player" },
7676 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
7678 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
7680 { EP_SLIPPERY, "- slippery for falling elements" },
7681 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
7683 { EP_DONT_RUN_INTO, "- deadly when running into" },
7684 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
7685 { EP_DONT_TOUCH, "- deadly when touching" },
7687 { EP_INDESTRUCTIBLE, "- indestructible" },
7689 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
7690 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
7691 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
7693 { EP_CAN_CHANGE, "- can change to other element" },
7695 /* pre-defined properties */
7696 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
7697 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
7698 { EP_SWITCHABLE, "- can be switched" },
7700 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
7705 char *filename = getElementDescriptionFilename(properties_element);
7706 char *percentage_text = "In this level:";
7707 char *properties_text = "Standard properties:";
7709 int num_elements_in_level;
7710 int num_standard_properties = 0;
7711 int font1_nr = FONT_TEXT_1;
7712 int font2_nr = FONT_TEXT_2;
7713 int font1_width = getFontWidth(font1_nr);
7714 int font2_height = getFontHeight(font2_nr);
7715 int pad_x = ED_ELEMENT_SETTINGS_XPOS(0);
7716 int pad_y = ED_ELEMENT_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
7717 int screen_line = 0;
7720 if (setup.editor.show_element_token)
7722 DrawTextF(pad_x, pad_y + screen_line++ * font2_height, FONT_TEXT_3,
7723 "[%s]", element_info[properties_element].token_name);
7727 /* ----- print number of elements / percentage of this element in level */
7729 num_elements_in_level = 0;
7730 for (y = 0; y < lev_fieldy; y++)
7731 for (x = 0; x < lev_fieldx; x++)
7732 if (Feld[x][y] == properties_element)
7733 num_elements_in_level++;
7734 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
7736 DrawTextS(pad_x, pad_y + screen_line * font2_height, font1_nr,
7738 DrawTextF(pad_x + strlen(percentage_text) * font1_width,
7739 pad_y + screen_line++ * font2_height, font2_nr,
7740 "%d (%.2f%%)", num_elements_in_level, percentage);
7744 /* ----- print standard properties of this element */
7746 DrawTextS(pad_x, pad_y + screen_line++ * font2_height, font1_nr,
7749 for (i = 0; properties[i].value != -1; i++)
7751 if (!HAS_PROPERTY(properties_element, properties[i].value))
7754 DrawTextS(pad_x, pad_y + screen_line++ * font2_height, font2_nr,
7755 properties[i].text);
7756 num_standard_properties++;
7759 if (num_standard_properties == 0)
7760 DrawTextS(pad_x + strlen(properties_text) * font1_width,
7761 pad_y + (screen_line - 1) * font2_height, font2_nr, "none");
7765 /* ----- print special description of this element */
7767 PrintInfoText("Description:", FONT_TEXT_1, screen_line);
7768 if (PrintElementDescriptionFromFile(filename, screen_line + 1) == 0)
7769 PrintInfoText("No description available.", FONT_TEXT_1, screen_line);
7772 #define TEXT_COLLECTING "Score for collecting"
7773 #define TEXT_SMASHING "Score for smashing"
7774 #define TEXT_SLURPING "Score for slurping robot"
7775 #define TEXT_CRACKING "Score for cracking"
7776 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
7777 #define TEXT_DURATION "Duration when activated"
7778 #define TEXT_BALL_DELAY "Element generation delay"
7779 #define TEXT_MOVE_SPEED "Speed of android moving"
7780 #define TEXT_CLONE_SPEED "Speed of android cloning"
7781 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
7782 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
7783 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
7784 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
7785 #define TEXT_TIME_BONUS "Extra time to solve level"
7792 } elements_with_counter[] =
7794 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
7795 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
7796 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
7797 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
7798 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
7799 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
7800 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
7801 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
7802 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
7803 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
7804 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
7805 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
7806 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
7807 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
7808 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
7809 { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
7810 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
7811 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
7812 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
7813 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
7814 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7815 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7816 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7817 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7818 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7819 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7820 { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
7821 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7822 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7823 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7824 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7825 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
7826 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
7827 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
7828 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
7829 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
7830 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
7831 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
7832 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
7833 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
7834 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
7835 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
7836 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
7837 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
7838 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
7839 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
7840 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE],TEXT_COLLECTING },
7841 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
7842 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
7843 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
7844 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
7845 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
7846 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
7847 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
7848 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
7849 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
7850 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
7851 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
7852 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
7853 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
7854 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
7855 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
7856 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
7857 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
7858 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
7859 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
7860 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
7861 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
7862 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
7863 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
7864 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
7865 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
7866 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
7868 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
7869 { EL_DC_TIMEGATE_SWITCH,&level.time_timegate, TEXT_DURATION },
7870 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
7871 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
7872 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
7873 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
7874 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
7875 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
7876 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
7877 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
7878 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
7879 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
7880 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
7881 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
7882 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
7883 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
7885 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
7886 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
7887 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
7888 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
7889 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
7890 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
7891 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
7892 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
7897 static boolean checkPropertiesConfig(int element)
7901 if (IS_GEM(element) ||
7902 IS_CUSTOM_ELEMENT(element) ||
7903 IS_GROUP_ELEMENT(element) ||
7904 IS_ENVELOPE(element) ||
7905 ELEM_IS_PLAYER(element) ||
7906 HAS_EDITOR_CONTENT(element) ||
7907 CAN_GROW(element) ||
7908 COULD_MOVE_INTO_ACID(element) ||
7909 MAYBE_DONT_COLLIDE_WITH(element))
7912 for (i = 0; elements_with_counter[i].element != -1; i++)
7913 if (elements_with_counter[i].element == element)
7919 static void DrawPropertiesConfig()
7921 int max_num_element_counters = 4;
7922 int num_element_counters = 0;
7925 if (!checkPropertiesConfig(properties_element))
7927 PrintInfoText("No configuration options available.", FONT_TEXT_1, 0);
7932 /* check if there are elements where a value can be chosen for */
7933 for (i = 0; elements_with_counter[i].element != -1; i++)
7935 if (elements_with_counter[i].element == properties_element)
7937 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
7939 counterbutton_info[counter_id].y =
7940 ED_ELEMENT_SETTINGS_YPOS(
7941 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
7942 (CAN_GROW(properties_element) ? 1 : 0) +
7943 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
7944 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
7945 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
7946 num_element_counters);
7948 counterbutton_info[counter_id].value = elements_with_counter[i].value;
7949 counterbutton_info[counter_id].text_right= elements_with_counter[i].text;
7951 if (properties_element == EL_GAME_OF_LIFE ||
7952 properties_element == EL_BIOMAZE)
7954 counterbutton_info[counter_id].min_value = 0; /* min neighbours */
7955 counterbutton_info[counter_id].max_value = 8; /* max neighbours */
7959 /* !!! CHANGE THIS FOR CERTAIN ELEMENTS !!! */
7960 counterbutton_info[counter_id].min_value = MIN_SCORE;
7961 counterbutton_info[counter_id].max_value = MAX_SCORE;
7964 MapCounterButtons(counter_id);
7966 num_element_counters++;
7967 if (num_element_counters >= max_num_element_counters)
7972 if (HAS_EDITOR_CONTENT(properties_element))
7974 /* draw stickybutton gadget */
7975 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
7977 if (IS_AMOEBOID(properties_element))
7978 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
7979 else if (properties_element == EL_YAMYAM ||
7980 properties_element == EL_YAMYAM_LEFT ||
7981 properties_element == EL_YAMYAM_RIGHT ||
7982 properties_element == EL_YAMYAM_UP ||
7983 properties_element == EL_YAMYAM_DOWN)
7984 DrawYamYamContentAreas();
7985 else if (properties_element == EL_EMC_MAGIC_BALL)
7987 DrawMagicBallContentAreas();
7989 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
7990 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_STATE);
7992 else if (properties_element == EL_EMC_ANDROID)
7993 DrawAndroidElementArea(properties_element);
7996 if (ELEM_IS_PLAYER(properties_element))
7998 int player_nr = GET_PLAYER_NR(properties_element);
8000 /* these properties can be set for every player individually */
8002 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
8003 &level.start_element[player_nr];
8004 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
8005 &level.artwork_element[player_nr];
8006 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
8007 &level.explosion_element[player_nr];
8009 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
8010 &level.use_start_element[player_nr];
8011 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
8012 &level.use_artwork_element[player_nr];
8013 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
8014 &level.use_explosion_element[player_nr];
8015 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
8016 &level.initial_player_gravity[player_nr];
8018 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
8019 &level.initial_player_stepsize[player_nr];
8021 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
8022 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
8023 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
8024 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
8025 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
8026 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
8027 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
8028 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
8029 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
8030 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
8031 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
8032 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
8033 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
8035 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
8036 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
8037 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
8039 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
8042 if (IS_GEM(properties_element))
8043 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
8045 if (COULD_MOVE_INTO_ACID(properties_element) &&
8046 !ELEM_IS_PLAYER(properties_element) &&
8047 (!IS_CUSTOM_ELEMENT(properties_element) ||
8048 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
8050 /* set position for checkbutton for "can move into acid" */
8051 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
8052 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
8053 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
8054 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 6 :
8055 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
8057 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
8060 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
8061 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
8063 if (properties_element == EL_SPRING)
8064 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
8066 if (properties_element == EL_TIME_ORB_FULL)
8067 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
8069 if (CAN_GROW(properties_element))
8071 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
8072 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
8074 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
8077 if (IS_ENVELOPE(properties_element))
8079 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
8080 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
8081 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
8082 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
8083 int envelope_nr = properties_element - EL_ENVELOPE_1;
8085 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
8086 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
8088 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
8089 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
8091 /* display counter to choose size of envelope text area */
8092 MapCounterButtons(counter1_id);
8093 MapCounterButtons(counter2_id);
8095 /* display checkbuttons to choose auto-wrap and alignment properties */
8096 MapCheckbuttonGadget(button1_id);
8097 MapCheckbuttonGadget(button2_id);
8099 DrawEnvelopeTextArea(envelope_nr);
8102 if (IS_CUSTOM_ELEMENT(properties_element))
8104 /* draw stickybutton gadget */
8105 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
8107 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
8109 /* draw checkbutton gadgets */
8110 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
8111 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
8112 MapCheckbuttonGadget(i);
8114 /* draw counter gadgets */
8115 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
8116 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
8117 MapCounterButtons(i);
8119 /* draw selectbox gadgets */
8120 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
8121 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
8122 MapSelectboxGadget(i);
8124 /* draw textbutton gadgets */
8125 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE);
8127 /* draw text input gadgets */
8128 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
8130 /* draw drawing area gadgets */
8131 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
8133 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
8135 /* draw checkbutton gadgets */
8136 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
8137 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
8138 MapCheckbuttonGadget(i);
8140 /* draw counter gadgets */
8141 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
8142 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
8143 MapCounterButtons(i);
8145 /* draw selectbox gadgets */
8146 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
8147 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
8148 MapSelectboxGadget(i);
8150 /* draw drawing area gadgets */
8151 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
8152 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
8153 DrawCustomContentArea();
8156 else if (IS_GROUP_ELEMENT(properties_element))
8158 /* draw stickybutton gadget */
8159 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
8161 /* draw checkbutton gadgets */
8162 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
8163 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE);
8165 /* draw counter gadgets */
8166 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
8168 /* draw selectbox gadgets */
8169 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
8171 /* draw textbutton gadgets */
8172 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE);
8174 /* draw drawing area gadgets */
8175 DrawGroupElementArea(properties_element);
8177 /* draw text input gadgets */
8178 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
8180 /* draw drawing area gadgets */
8181 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
8185 static void DrawPropertiesChangeDrawingAreas()
8187 if (IS_CUSTOM_ELEMENT(properties_element))
8189 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
8190 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
8192 DrawCustomChangeContentArea();
8195 redraw_mask |= REDRAW_FIELD;
8198 static void DrawPropertiesChange()
8202 /* needed to initially set selectbox options for special action options */
8203 setSelectboxSpecialActionOptions();
8205 /* draw stickybutton gadget */
8206 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
8208 /* draw checkbutton gadgets */
8209 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
8210 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
8211 MapCheckbuttonGadget(i);
8213 /* draw counter gadgets */
8214 for (i = ED_COUNTER_ID_CHANGE_FIRST;
8215 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
8216 MapCounterButtons(i);
8218 /* draw selectbox gadgets */
8219 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
8220 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
8221 MapSelectboxGadget(i);
8223 /* draw textbutton gadgets */
8224 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
8225 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
8226 MapTextbuttonGadget(i);
8228 /* draw graphicbutton gadgets */
8229 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
8230 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
8231 MapGraphicbuttonGadget(i);
8233 /* draw drawing area gadgets */
8234 DrawPropertiesChangeDrawingAreas();
8237 static void DrawEditorElementAnimation(int x, int y)
8239 int graphic = el2img(properties_element);
8240 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
8241 custom_element.ce_value_fixed_initial :
8242 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
8243 custom_element.collect_score_initial : FrameCounter);
8245 DrawGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
8248 static void DrawEditorElementName(int x, int y, int element)
8250 char *element_name = getElementInfoText(element);
8251 int font_nr = FONT_TEXT_1;
8252 int font_width = getFontWidth(font_nr);
8253 int font_height = getFontHeight(font_nr);
8254 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_XPOS(0);
8255 int max_chars_per_line = max_text_width / font_width;
8256 char buffer[max_chars_per_line + 1];
8258 if (strlen(element_name) <= max_chars_per_line)
8259 DrawTextS(x, y, font_nr, element_name);
8262 int next_pos = max_chars_per_line;
8264 strncpy(buffer, element_name, max_chars_per_line);
8265 buffer[max_chars_per_line] = '\0';
8267 if (element_name[max_chars_per_line] == ' ')
8273 for (i = max_chars_per_line - 1; i >= 0; i--)
8274 if (buffer[i] == ' ')
8277 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
8284 DrawTextS(x, y - font_height / 2, font_nr, buffer);
8286 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
8287 buffer[max_chars_per_line] = '\0';
8289 DrawTextS(x, y + font_height / 2, font_nr, buffer);
8293 static void DrawPropertiesWindow()
8298 stick_element_properties_window = FALSE;
8300 /* make sure that previous properties edit mode exists for this element */
8301 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
8302 !IS_CUSTOM_ELEMENT(properties_element))
8303 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
8305 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
8306 IS_CUSTOM_ELEMENT(properties_element))
8307 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
8309 CopyElementPropertiesToEditor(properties_element);
8311 UnmapLevelEditorWindowGadgets();
8312 UnmapLevelEditorToolboxDrawingGadgets();
8313 UnmapLevelEditorToolboxCustomGadgets();
8315 if (IS_CUSTOM_ELEMENT(properties_element) ||
8316 IS_GROUP_ELEMENT(properties_element))
8317 MapLevelEditorToolboxCustomGadgets();
8319 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
8323 DrawTextSCentered(ED_SETTINGS1_YPOS, FONT_TITLE_1, "Element Settings");
8325 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS1_YPOS,
8326 "Element Settings", FONT_TITLE_1);
8329 FrameCounter = 0; /* restart animation frame counter */
8331 DrawElementBorder(SX + xstart * MINI_TILEX,
8332 SY + ystart * MINI_TILEY + MINI_TILEY / 2,
8333 TILEX, TILEY, FALSE);
8335 DrawEditorElementAnimation(SX + xstart * MINI_TILEX,
8336 SY + ystart * MINI_TILEY + MINI_TILEY / 2);
8338 DrawEditorElementName((xstart + 3) * MINI_TILEX + 1,
8339 (ystart + 1) * MINI_TILEY + 1,
8340 properties_element);
8342 DrawPropertiesTabulatorGadgets();
8344 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
8345 DrawPropertiesInfo();
8346 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
8347 DrawPropertiesChange();
8348 else /* (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2]) */
8349 DrawPropertiesConfig();
8352 static void UpdateCustomElementGraphicGadgets()
8356 ModifyEditorElementList();
8357 RedrawDrawingElements();
8359 /* force redraw of all mapped drawing area gadgets */
8360 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
8362 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
8369 static int getOpenDirectionFromTube(int element)
8373 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
8374 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
8375 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
8376 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
8377 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
8378 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
8379 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
8380 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
8381 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
8382 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
8383 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
8389 static int getTubeFromOpenDirection(int direction)
8393 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
8394 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
8395 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
8396 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
8397 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
8398 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
8399 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
8400 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
8401 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
8402 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
8403 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
8405 /* if only one direction, fall back to simple tube with that direction */
8406 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
8407 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
8408 case (MV_UP): return EL_TUBE_VERTICAL;
8409 case (MV_DOWN): return EL_TUBE_VERTICAL;
8415 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
8417 int element_new = getTubeFromOpenDirection(direction);
8419 return (element_new != EL_EMPTY ? element_new : element_old);
8422 static int getOpenDirectionFromBelt(int element)
8424 int belt_dir = getBeltDirFromBeltElement(element);
8426 return (belt_dir == MV_LEFT ? MV_RIGHT :
8427 belt_dir == MV_RIGHT ? MV_LEFT :
8428 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
8431 static int getBeltFromNrAndOpenDirection(int nr, int direction)
8433 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
8434 direction == MV_RIGHT ? MV_LEFT :
8435 direction == MV_HORIZONTAL ? MV_NONE : direction);
8437 if (direction == MV_NONE)
8440 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
8443 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
8446 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
8448 return (element_new != EL_EMPTY ? element_new : element_old);
8451 static int getOpenDirectionFromPool(int element)
8455 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
8456 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
8457 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
8458 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
8459 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
8460 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
8466 static int getPoolFromOpenDirection(int direction)
8470 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
8471 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
8472 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
8473 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
8474 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
8475 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
8481 static int getPoolFromOpenDirectionExt(int direction, int help_element)
8483 int element = getPoolFromOpenDirection(direction);
8484 int help_direction = getOpenDirectionFromPool(help_element);
8486 if (element == EL_EMPTY)
8488 int help_direction_vertical = help_direction & MV_VERTICAL;
8490 element = getPoolFromOpenDirection(direction | help_direction_vertical);
8493 if (element == EL_EMPTY)
8495 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
8497 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
8503 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
8505 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
8507 return (element_new != EL_EMPTY ? element_new : element_old);
8510 static int getOpenDirectionFromPillar(int element)
8514 case EL_EMC_WALL_1: return (MV_DOWN);
8515 case EL_EMC_WALL_2: return (MV_VERTICAL);
8516 case EL_EMC_WALL_3: return (MV_UP);
8522 static int getPillarFromOpenDirection(int direction)
8526 case (MV_DOWN): return EL_EMC_WALL_1;
8527 case (MV_VERTICAL): return EL_EMC_WALL_2;
8528 case (MV_UP): return EL_EMC_WALL_3;
8534 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
8536 int element_new = getPillarFromOpenDirection(direction);
8538 return (element_new != EL_EMPTY ? element_new : element_old);
8541 static int getOpenDirectionFromSteel2(int element)
8545 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
8546 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
8547 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
8548 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
8549 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
8550 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
8551 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
8552 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
8558 static int getSteel2FromOpenDirection(int direction)
8562 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
8563 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
8564 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
8565 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
8566 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
8567 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
8568 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
8569 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
8575 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
8577 int element_new = getSteel2FromOpenDirection(direction);
8579 return (element_new != EL_EMPTY ? element_new : element_old);
8582 static int getOpenDirectionFromChip(int element)
8586 case EL_SP_CHIP_SINGLE: return (MV_NONE);
8587 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
8588 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
8589 case EL_SP_CHIP_TOP: return (MV_DOWN);
8590 case EL_SP_CHIP_BOTTOM: return (MV_UP);
8596 static int getChipFromOpenDirection(int direction)
8600 case (MV_NONE): return EL_SP_CHIP_SINGLE;
8601 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
8602 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
8603 case (MV_UP): return EL_SP_CHIP_BOTTOM;
8604 case (MV_DOWN): return EL_SP_CHIP_TOP;
8610 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
8612 int element_new = getChipFromOpenDirection(direction);
8614 return (element_new != EL_EMPTY ? element_new : element_old);
8617 static int getClosedTube(int x, int y)
8619 static int xy[4][2] =
8626 int element_old = IntelliDrawBuffer[x][y];
8627 int direction_old = getOpenDirectionFromTube(element_old);
8628 int direction_new = MV_NONE;
8631 for (i = 0; i < NUM_DIRECTIONS; i++)
8633 int xx = x + xy[i][0];
8634 int yy = y + xy[i][1];
8635 int dir = MV_DIR_FROM_BIT(i);
8636 int dir_opposite = MV_DIR_OPPOSITE(dir);
8638 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
8639 (direction_old & dir) &&
8640 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
8641 direction_new |= dir;
8644 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
8647 static int getClosedBelt(int x, int y)
8649 static int xy[4][2] =
8656 int element_old = IntelliDrawBuffer[x][y];
8657 int nr = getBeltNrFromBeltElement(element_old);
8658 int direction_old = getOpenDirectionFromBelt(element_old);
8659 int direction_new = MV_NONE;
8662 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
8664 int xx = x + xy[i][0];
8665 int yy = y + xy[i][1];
8666 int dir = MV_DIR_FROM_BIT(i);
8667 int dir_opposite = MV_DIR_OPPOSITE(dir);
8669 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
8670 (direction_old & dir) &&
8671 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
8672 direction_new |= dir;
8675 return getBeltFromNrAndOpenDirection(nr, direction_new);
8678 static int getClosedPool(int x, int y)
8680 static int xy[4][2] =
8687 int element_old = IntelliDrawBuffer[x][y];
8688 int direction_old = getOpenDirectionFromPool(element_old);
8689 int direction_new = MV_NONE;
8692 for (i = 0; i < NUM_DIRECTIONS; i++)
8694 int xx = x + xy[i][0];
8695 int yy = y + xy[i][1];
8696 int dir = MV_DIR_FROM_BIT(i);
8697 int dir_opposite = MV_DIR_OPPOSITE(dir);
8699 if (IN_LEV_FIELD(xx, yy) &&
8700 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
8701 (direction_old & dir) &&
8702 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
8703 direction_new |= dir;
8706 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
8709 static int getClosedPillar(int x, int y)
8711 static int xy[4][2] =
8718 int element_old = IntelliDrawBuffer[x][y];
8719 int direction_old = getOpenDirectionFromPillar(element_old);
8720 int direction_new = MV_NONE;
8723 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
8725 int xx = x + xy[i][0];
8726 int yy = y + xy[i][1];
8727 int dir = MV_DIR_FROM_BIT(i);
8728 int dir_opposite = MV_DIR_OPPOSITE(dir);
8730 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
8731 (direction_old & dir) &&
8732 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
8733 direction_new |= dir;
8736 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
8739 static int getClosedSteel2(int x, int y)
8741 static int xy[4][2] =
8748 int element_old = IntelliDrawBuffer[x][y];
8749 int direction_old = getOpenDirectionFromSteel2(element_old);
8750 int direction_new = MV_NONE;
8753 for (i = 0; i < NUM_DIRECTIONS; i++)
8755 int xx = x + xy[i][0];
8756 int yy = y + xy[i][1];
8757 int dir = MV_DIR_FROM_BIT(i);
8758 int dir_opposite = MV_DIR_OPPOSITE(dir);
8760 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
8761 (direction_old & dir) &&
8762 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
8763 direction_new |= dir;
8766 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
8769 static int getClosedChip(int x, int y)
8771 static int xy[4][2] =
8778 int element_old = IntelliDrawBuffer[x][y];
8779 int direction_old = getOpenDirectionFromChip(element_old);
8780 int direction_new = MV_NONE;
8783 for (i = 0; i < NUM_DIRECTIONS; i++)
8785 int xx = x + xy[i][0];
8786 int yy = y + xy[i][1];
8787 int dir = MV_DIR_FROM_BIT(i);
8788 int dir_opposite = MV_DIR_OPPOSITE(dir);
8790 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
8791 (direction_old & dir) &&
8792 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
8793 direction_new |= dir;
8796 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
8799 static void SetElementSimple(int x, int y, int element, boolean change_level)
8801 int sx = x - level_xpos;
8802 int sy = y - level_ypos;
8804 IntelliDrawBuffer[x][y] = element;
8807 Feld[x][y] = element;
8809 if (IN_ED_FIELD(sx, sy))
8810 DrawMiniElement(sx, sy, element);
8813 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
8814 int x2, int y2, int *element2,
8815 int (*close_function)(int, int),
8816 boolean change_level)
8818 /* set neighbour elements to newly determined connections */
8819 SetElementSimple(x1, y1, *element1, change_level);
8820 SetElementSimple(x2, y2, *element2, change_level);
8822 /* remove all open connections of neighbour elements */
8823 *element1 = close_function(x1, y1);
8824 *element2 = close_function(x2, y2);
8826 /* set neighbour elements to new, minimized connections */
8827 SetElementSimple(x1, y1, *element1, change_level);
8828 SetElementSimple(x2, y2, *element2, change_level);
8831 static void SetElementIntelliDraw(int x, int y, int new_element,
8832 boolean change_level, int button)
8834 static int xy[4][2] =
8841 static int last_x = -1;
8842 static int last_y = -1;
8843 int old_element = IntelliDrawBuffer[x][y];
8845 if (new_element == EL_UNDEFINED)
8853 if (IS_TUBE(new_element))
8855 int last_element_new = EL_UNDEFINED;
8856 int direction = MV_NONE;
8859 /* if old element is of same kind, keep all existing directions */
8860 if (IS_TUBE(old_element))
8861 direction |= getOpenDirectionFromTube(old_element);
8863 for (i = 0; i < NUM_DIRECTIONS; i++)
8865 int xx = x + xy[i][0];
8866 int yy = y + xy[i][1];
8868 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
8869 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
8871 int dir = MV_DIR_FROM_BIT(i);
8872 int dir_opposite = MV_DIR_OPPOSITE(dir);
8873 int last_element_old = IntelliDrawBuffer[last_x][last_y];
8874 int last_direction_old = getOpenDirectionFromTube(last_element_old);
8875 int last_direction_new = last_direction_old | dir_opposite;
8877 last_element_new = getTubeFromOpenDirection(last_direction_new);
8883 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
8885 if (last_element_new != EL_UNDEFINED)
8886 MergeAndCloseNeighbourElements(x, y, &new_element,
8887 last_x, last_y, &last_element_new,
8888 getClosedTube, change_level);
8890 else if (IS_BELT(new_element))
8892 int belt_nr = getBeltNrFromBeltElement(new_element);
8893 int last_element_new = EL_UNDEFINED;
8894 int direction = MV_NONE;
8897 /* if old element is of same kind, keep all existing directions */
8898 if (IS_BELT(old_element))
8899 direction |= getOpenDirectionFromBelt(old_element);
8901 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
8903 int xx = x + xy[i][0];
8904 int yy = y + xy[i][1];
8906 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
8907 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
8909 int dir = MV_DIR_FROM_BIT(i);
8910 int dir_opposite = MV_DIR_OPPOSITE(dir);
8911 int last_element_old = IntelliDrawBuffer[last_x][last_y];
8912 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
8913 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
8914 int last_direction_new = last_direction_old | dir_opposite;
8916 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
8917 last_direction_new);
8922 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
8924 if (last_element_new != EL_UNDEFINED)
8925 MergeAndCloseNeighbourElements(x, y, &new_element,
8926 last_x, last_y, &last_element_new,
8927 getClosedBelt, change_level);
8929 else if (IS_ACID_POOL_OR_ACID(new_element))
8931 int last_element_new = EL_UNDEFINED;
8932 int direction = MV_NONE;
8935 /* if old element is of same kind, keep all existing directions */
8936 if (IS_ACID_POOL_OR_ACID(old_element))
8937 direction |= getOpenDirectionFromPool(old_element);
8939 for (i = 0; i < NUM_DIRECTIONS; i++)
8941 int xx = x + xy[i][0];
8942 int yy = y + xy[i][1];
8944 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
8945 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
8947 int dir = MV_DIR_FROM_BIT(i);
8948 int dir_opposite = MV_DIR_OPPOSITE(dir);
8949 int last_element_old = IntelliDrawBuffer[last_x][last_y];
8950 int last_direction_old = getOpenDirectionFromPool(last_element_old);
8951 int last_direction_new = last_direction_old | dir_opposite;
8953 last_element_new = getPoolFromOpenDirection(last_direction_new);
8959 /* special corrections needed for intuitively correct acid pool drawing */
8960 if (last_element_new == EL_EMPTY)
8961 last_element_new = new_element;
8962 else if (last_element_new != EL_UNDEFINED)
8963 new_element = last_element_new;
8965 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
8967 if (last_element_new != EL_UNDEFINED)
8968 MergeAndCloseNeighbourElements(x, y, &new_element,
8969 last_x, last_y, &last_element_new,
8970 getClosedPool, change_level);
8972 else if (IS_EMC_PILLAR(new_element))
8974 int last_element_new = EL_UNDEFINED;
8975 int direction = MV_NONE;
8978 /* if old element is of same kind, keep all existing directions */
8979 if (IS_EMC_PILLAR(old_element))
8980 direction |= getOpenDirectionFromPillar(old_element);
8982 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
8984 int xx = x + xy[i][0];
8985 int yy = y + xy[i][1];
8987 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
8988 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
8990 int dir = MV_DIR_FROM_BIT(i);
8991 int dir_opposite = MV_DIR_OPPOSITE(dir);
8992 int last_element_old = IntelliDrawBuffer[last_x][last_y];
8993 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
8994 int last_direction_new = last_direction_old | dir_opposite;
8996 last_element_new = getPillarFromOpenDirection(last_direction_new);
9002 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
9004 if (last_element_new != EL_UNDEFINED)
9005 MergeAndCloseNeighbourElements(x, y, &new_element,
9006 last_x, last_y, &last_element_new,
9007 getClosedPillar, change_level);
9009 else if (IS_DC_STEELWALL_2(new_element))
9011 int last_element_new = EL_UNDEFINED;
9012 int direction = MV_NONE;
9015 /* if old element is of same kind, keep all existing directions */
9016 if (IS_DC_STEELWALL_2(old_element))
9017 direction |= getOpenDirectionFromSteel2(old_element);
9019 for (i = 0; i < NUM_DIRECTIONS; i++)
9021 int xx = x + xy[i][0];
9022 int yy = y + xy[i][1];
9024 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9025 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
9027 int dir = MV_DIR_FROM_BIT(i);
9028 int dir_opposite = MV_DIR_OPPOSITE(dir);
9029 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9030 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
9031 int last_direction_new = last_direction_old | dir_opposite;
9033 last_element_new = getSteel2FromOpenDirection(last_direction_new);
9039 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
9041 if (last_element_new != EL_UNDEFINED)
9042 MergeAndCloseNeighbourElements(x, y, &new_element,
9043 last_x, last_y, &last_element_new,
9044 getClosedSteel2, change_level);
9046 else if (IS_SP_CHIP(new_element))
9048 int last_element_new = EL_UNDEFINED;
9049 int direction = MV_NONE;
9052 /* (do not keep existing directions, regardless of kind of old element) */
9054 for (i = 0; i < NUM_DIRECTIONS; i++)
9056 int xx = x + xy[i][0];
9057 int yy = y + xy[i][1];
9059 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9060 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
9062 int dir = MV_DIR_FROM_BIT(i);
9063 int dir_opposite = MV_DIR_OPPOSITE(dir);
9064 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9065 int last_direction_old = getOpenDirectionFromChip(last_element_old);
9066 int last_direction_new = last_direction_old | dir_opposite;
9068 if (last_direction_old == MV_NONE)
9070 last_element_new = getChipFromOpenDirection(last_direction_new);
9073 else if (last_direction_old & (dir | dir_opposite))
9075 direction |= MV_DIR_OPPOSITE(last_direction_old);
9079 direction |= MV_DIR_OPPOSITE(dir);
9084 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
9086 if (last_element_new != EL_UNDEFINED)
9087 MergeAndCloseNeighbourElements(x, y, &new_element,
9088 last_x, last_y, &last_element_new,
9089 getClosedChip, change_level);
9091 else if (IS_SP_HARDWARE_BASE(new_element))
9093 int nr = GetSimpleRandom(6);
9095 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
9096 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
9097 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
9098 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
9099 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
9101 else if (new_element == EL_SP_HARDWARE_GREEN ||
9102 new_element == EL_SP_HARDWARE_BLUE ||
9103 new_element == EL_SP_HARDWARE_RED)
9105 int nr = GetSimpleRandom(3);
9107 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
9108 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
9110 else if (IS_GROUP_ELEMENT(new_element))
9112 boolean connected_drawing = FALSE;
9115 for (i = 0; i < NUM_DIRECTIONS; i++)
9117 int xx = x + xy[i][0];
9118 int yy = y + xy[i][1];
9120 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9121 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
9122 connected_drawing = TRUE;
9125 if (!connected_drawing)
9126 ResolveGroupElement(new_element);
9128 new_element = GetElementFromGroupElement(new_element);
9130 else if (IS_BELT_SWITCH(old_element))
9132 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
9133 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
9135 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
9136 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
9138 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
9142 static int swappable_elements[][2] =
9144 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
9145 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
9146 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
9147 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
9148 { EL_EMERALD, EL_WALL_EMERALD },
9149 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
9150 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
9151 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
9152 { EL_DIAMOND, EL_WALL_DIAMOND },
9153 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
9154 { EL_GATE_1, EL_GATE_1_GRAY },
9155 { EL_GATE_2, EL_GATE_2_GRAY },
9156 { EL_GATE_3, EL_GATE_3_GRAY },
9157 { EL_GATE_4, EL_GATE_4_GRAY },
9158 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
9159 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
9160 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
9161 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
9162 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
9163 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
9164 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
9165 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
9166 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
9167 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
9168 { EL_LAMP, EL_LAMP_ACTIVE },
9169 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
9170 { EL_SP_BASE, EL_SP_BUGGY_BASE },
9171 { EL_PEARL, EL_WALL_PEARL },
9172 { EL_CRYSTAL, EL_WALL_CRYSTAL },
9173 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
9174 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
9175 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
9176 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
9177 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
9178 { EL_LANDMINE, EL_DC_LANDMINE },
9179 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
9180 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
9181 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
9182 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
9183 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
9187 static int rotatable_elements[][4] =
9205 EL_BD_BUTTERFLY_RIGHT,
9206 EL_BD_BUTTERFLY_DOWN,
9207 EL_BD_BUTTERFLY_LEFT
9212 EL_BD_FIREFLY_RIGHT,
9246 EL_SP_GRAVITY_PORT_UP,
9247 EL_SP_GRAVITY_PORT_RIGHT,
9248 EL_SP_GRAVITY_PORT_DOWN,
9249 EL_SP_GRAVITY_PORT_LEFT
9260 EL_BALLOON_SWITCH_UP,
9261 EL_BALLOON_SWITCH_RIGHT,
9262 EL_BALLOON_SWITCH_DOWN,
9263 EL_BALLOON_SWITCH_LEFT
9267 EL_SP_GRAVITY_ON_PORT_UP,
9268 EL_SP_GRAVITY_ON_PORT_RIGHT,
9269 EL_SP_GRAVITY_ON_PORT_DOWN,
9270 EL_SP_GRAVITY_ON_PORT_LEFT
9274 EL_SP_GRAVITY_OFF_PORT_UP,
9275 EL_SP_GRAVITY_OFF_PORT_RIGHT,
9276 EL_SP_GRAVITY_OFF_PORT_DOWN,
9277 EL_SP_GRAVITY_OFF_PORT_LEFT
9289 for (i = 0; swappable_elements[i][0] != -1; i++)
9291 int element1 = swappable_elements[i][0];
9292 int element2 = swappable_elements[i][1];
9294 if (old_element == element1 || old_element == element2)
9295 new_element = (old_element == element1 ? element2 : element1);
9298 for (i = 0; rotatable_elements[i][0] != -1; i++)
9300 for (j = 0; j < 4; j++)
9302 int element = rotatable_elements[i][j];
9304 if (old_element == element)
9305 new_element = (button == 1 ? rotatable_elements[i][(j + 3) % 4] :
9306 button == 2 ? rotatable_elements[i][0] :
9307 button == 3 ? rotatable_elements[i][(j + 1) % 4] :
9313 SetElementSimple(x, y, new_element, change_level);
9319 static void ResetIntelliDraw()
9323 for (x = 0; x < lev_fieldx; x++)
9324 for (y = 0; y < lev_fieldy; y++)
9325 IntelliDrawBuffer[x][y] = Feld[x][y];
9327 SetElementIntelliDraw(-1, -1, EL_UNDEFINED, FALSE, -1);
9330 static void SetElementExt(int x, int y, int element, boolean change_level,
9334 SetElementSimple(x, y, Feld[x][y], change_level);
9335 else if (GetKeyModState() & KMOD_Shift)
9336 SetElementIntelliDraw(x, y, element, change_level, button);
9338 SetElementSimple(x, y, element, change_level);
9341 static void SetElement(int x, int y, int element)
9343 SetElementExt(x, y, element, TRUE, -1);
9346 static void SetElementButton(int x, int y, int element, int button)
9348 SetElementExt(x, y, element, TRUE, button);
9351 static void DrawLineElement(int sx, int sy, int element, boolean change_level)
9353 int lx = sx + level_xpos;
9354 int ly = sy + level_ypos;
9356 SetElementExt(lx, ly, element, change_level, -1);
9359 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
9360 int element, boolean change_level)
9362 int xsize = ABS(to_x - from_x);
9363 int ysize = ABS(to_y - from_y);
9364 int dx = (to_x < from_x ? -1 : +1);
9365 int dy = (to_y < from_y ? -1 : +1);
9368 if (from_y == to_y) /* horizontal line */
9370 for (i = 0; i <= xsize; i++)
9371 DrawLineElement(from_x + i * dx, from_y, element, change_level);
9373 else if (from_x == to_x) /* vertical line */
9375 for (i = 0; i <= ysize; i++)
9376 DrawLineElement(from_x, from_y + i * dy, element, change_level);
9378 else /* diagonal line */
9380 if (ysize < xsize) /* a < 1 */
9382 float a = (float)ysize / (float)xsize;
9384 for (i = 0; i <= xsize; i++)
9387 int y = dy * (int)(a * i + 0.5);
9389 DrawLineElement(from_x + x, from_y + y, element, change_level);
9394 float a = (float)xsize / (float)ysize;
9396 for (i = 0; i <= ysize; i++)
9398 int x = dx * (int)(a * i + 0.5);
9401 DrawLineElement(from_x + x, from_y + y, element, change_level);
9407 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
9408 int element, boolean change_level)
9410 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
9411 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
9412 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
9413 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
9416 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
9417 int element, boolean change_level)
9422 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
9424 for (y = from_y; y <= to_y; y++)
9425 DrawLine(from_x, y, to_x, y, element, change_level);
9428 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
9429 int element, boolean change_level)
9431 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
9432 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
9433 int len_x = ABS(to_x - from_x);
9434 int len_y = ABS(to_y - from_y);
9437 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
9439 /* not optimal (some points get drawn twice) but simple,
9440 and fast enough for the few points we are drawing */
9442 for (x = 0; x <= radius; x++)
9446 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
9448 sx = from_x + x * (from_x < to_x2 ? +1 : -1);
9449 sy = from_y + y * (from_y < to_y2 ? +1 : -1);
9450 lx = sx + level_xpos;
9451 ly = sy + level_ypos;
9453 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
9454 DrawLineElement(sx, sy, element, change_level);
9457 for (y = 0; y <= radius; y++)
9461 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
9463 sx = from_x + x * (from_x < to_x2 ? +1 : -1);
9464 sy = from_y + y * (from_y < to_y2 ? +1 : -1);
9465 lx = sx + level_xpos;
9466 ly = sy + level_ypos;
9468 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
9469 DrawLineElement(sx, sy, element, change_level);
9473 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
9474 int element, boolean change_level)
9476 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
9477 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
9479 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
9482 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
9484 #if DRAW_CIRCLES_BUTTON_AVAILABLE
9485 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
9486 int element, boolean change_level)
9488 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
9489 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
9490 int mirror_to_x2 = from_x - (to_x2 - from_x);
9491 int mirror_to_y2 = from_y - (to_y2 - from_y);
9493 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
9494 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
9495 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
9496 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element,change_level);
9500 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
9502 int from_sx, from_sy;
9506 swap_numbers(&from_x, &to_x);
9509 swap_numbers(&from_y, &to_y);
9511 from_sx = SX + from_x * MINI_TILEX;
9512 from_sy = SY + from_y * MINI_TILEY;
9513 to_sx = SX + to_x * MINI_TILEX + MINI_TILEX - 1;
9514 to_sy = SY + to_y * MINI_TILEY + MINI_TILEY - 1;
9516 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
9517 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
9518 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
9519 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
9521 if (from_x == to_x && from_y == to_y)
9522 MarkTileDirty(from_x/2, from_y/2);
9524 redraw_mask |= REDRAW_FIELD;
9527 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
9528 int element, boolean change_level)
9530 if (element == -1 || change_level)
9531 DrawBox(from_x, from_y, to_x, to_y, -1, FALSE);
9533 DrawAreaBorder(from_x, from_y, to_x, to_y);
9536 /* values for CopyBrushExt() */
9537 #define CB_AREA_TO_BRUSH 0
9538 #define CB_BRUSH_TO_CURSOR 1
9539 #define CB_BRUSH_TO_LEVEL 2
9540 #define CB_DELETE_OLD_CURSOR 3
9541 #define CB_DUMP_BRUSH 4
9542 #define CB_DUMP_BRUSH_SMALL 5
9544 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
9545 int button, int mode)
9547 static short brush_buffer[MAX_ED_FIELDX][MAX_ED_FIELDY];
9548 static int brush_width, brush_height;
9549 static int last_cursor_x = -1, last_cursor_y = -1;
9550 static boolean delete_old_brush;
9551 int new_element = BUTTON_ELEMENT(button);
9554 if (mode == CB_DUMP_BRUSH ||
9555 mode == CB_DUMP_BRUSH_SMALL)
9557 if (!draw_with_brush)
9559 Error(ERR_WARN, "no brush selected");
9564 for (y = 0; y < brush_height; y++)
9566 for (x = 0; x < brush_width; x++)
9568 int element = brush_buffer[x][y];
9569 int element_mapped = element;
9571 if (IS_CUSTOM_ELEMENT(element))
9572 element_mapped = EL_CUSTOM_START;
9573 else if (IS_GROUP_ELEMENT(element))
9574 element_mapped = EL_GROUP_START;
9575 else if (element >= NUM_FILE_ELEMENTS)
9576 element_mapped = EL_UNKNOWN;
9578 printf("%c%03d", (mode == CB_DUMP_BRUSH ? '`' : '¸'), element_mapped);
9587 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
9590 if (mode == CB_AREA_TO_BRUSH)
9592 int from_lx, from_ly;
9595 swap_numbers(&from_x, &to_x);
9598 swap_numbers(&from_y, &to_y);
9600 brush_width = to_x - from_x + 1;
9601 brush_height = to_y - from_y + 1;
9603 from_lx = from_x + level_xpos;
9604 from_ly = from_y + level_ypos;
9606 for (y = 0; y < brush_height; y++)
9608 for (x = 0; x < brush_width; x++)
9610 brush_buffer[x][y] = Feld[from_lx + x][from_ly + y];
9613 DrawLineElement(from_x + x, from_y + y, new_element, TRUE);
9618 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
9620 delete_old_brush = FALSE;
9622 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
9623 mode == CB_BRUSH_TO_LEVEL)
9625 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
9626 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
9627 int cursor_from_x = cursor_x - brush_width / 2;
9628 int cursor_from_y = cursor_y - brush_height / 2;
9629 int border_from_x = cursor_x, border_from_y = cursor_y;
9630 int border_to_x = cursor_x, border_to_y = cursor_y;
9632 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
9633 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
9635 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
9636 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
9638 delete_old_brush = FALSE;
9642 for (y = 0; y < brush_height; y++)
9644 for (x = 0; x < brush_width; x++)
9646 int sx = cursor_from_x + x;
9647 int sy = cursor_from_y + y;
9648 int lx = sx + level_xpos;
9649 int ly = sy + level_ypos;
9650 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
9651 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
9652 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
9653 brush_buffer[x][y] : new_element);
9655 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
9657 if (sx < border_from_x)
9659 else if (sx > border_to_x)
9661 if (sy < border_from_y)
9663 else if (sy > border_to_y)
9666 DrawLineElement(sx, sy, element, change_level);
9671 if (mode != CB_DELETE_OLD_CURSOR)
9672 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
9674 last_cursor_x = cursor_x;
9675 last_cursor_y = cursor_y;
9676 delete_old_brush = TRUE;
9680 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
9683 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
9686 static void CopyBrushToLevel(int x, int y, int button)
9688 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
9691 static void CopyBrushToCursor(int x, int y)
9693 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
9696 static void DeleteBrushFromCursor()
9698 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
9703 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
9706 void DumpBrush_Small()
9708 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
9711 static void FloodFill(int from_x, int from_y, int fill_element)
9713 FloodFillLevel(from_x, from_y, fill_element, Feld, lev_fieldx, lev_fieldy);
9716 /* values for DrawLevelText() modes */
9718 #define TEXT_SETCURSOR 1
9719 #define TEXT_WRITECHAR 2
9720 #define TEXT_BACKSPACE 3
9721 #define TEXT_NEWLINE 4
9723 #define TEXT_QUERY_TYPING 6
9725 static int DrawLevelText(int sx, int sy, char letter, int mode)
9727 static short delete_buffer[MAX_LEV_FIELDX];
9728 static int start_sx, start_sy;
9729 static int last_sx, last_sy;
9730 static boolean typing = FALSE;
9731 int letter_element = EL_CHAR_ASCII0 + letter;
9734 /* map lower case letters to upper case and convert special characters */
9735 if (letter >= 'a' && letter <= 'z')
9736 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
9737 else if (letter == 'ä' || letter == 'Ä')
9738 letter_element = EL_CHAR_AUMLAUT;
9739 else if (letter == 'ö' || letter == 'Ö')
9740 letter_element = EL_CHAR_OUMLAUT;
9741 else if (letter == 'ü' || letter == 'Ü')
9742 letter_element = EL_CHAR_UUMLAUT;
9743 else if (letter == '^')
9744 letter_element = EL_CHAR_COPYRIGHT;
9746 letter_element = EL_CHAR_ASCII0 + letter;
9748 if (mode != TEXT_INIT)
9753 if (mode != TEXT_SETCURSOR)
9759 lx = last_sx + level_xpos;
9760 ly = last_sy + level_ypos;
9767 DrawLevelText(0, 0, 0, TEXT_END);
9770 start_sx = last_sx = sx;
9771 start_sy = last_sy = sy;
9772 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
9775 case TEXT_SETCURSOR:
9776 DrawMiniElement(last_sx, last_sy, Feld[lx][ly]);
9777 DrawAreaBorder(sx, sy, sx, sy);
9782 case TEXT_WRITECHAR:
9783 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
9785 delete_buffer[sx - start_sx] = Feld[lx][ly];
9786 Feld[lx][ly] = letter_element;
9788 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
9789 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
9790 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
9791 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
9793 DrawLevelText(0, 0, 0, TEXT_END);
9795 level.changed = TRUE;
9799 case TEXT_BACKSPACE:
9802 Feld[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
9803 DrawMiniElement(sx - 1, sy, Feld[lx - 1][ly]);
9804 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
9809 if (sy + 1 < ed_fieldy - 1 && ly + 1 < lev_fieldy - 1)
9810 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
9812 DrawLevelText(0, 0, 0, TEXT_END);
9816 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
9817 DrawMiniElement(sx, sy, Feld[lx][ly]);
9821 case TEXT_QUERY_TYPING:
9831 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
9832 int element, boolean change_level)
9834 int lx = sx + level_xpos;
9835 int ly = sy + level_ypos;
9838 DrawMiniElement(sx, sy, Feld[lx][ly]);
9840 DrawAreaBorder(sx, sy, sx, sy);
9843 static void CheckLevelBorderElement(boolean redraw_playfield)
9845 int last_border_element = BorderElement;
9849 if (redraw_playfield && BorderElement != last_border_element)
9850 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9853 static void CopyLevelToUndoBuffer(int mode)
9855 static boolean accumulated_undo = FALSE;
9856 boolean new_undo_buffer_position = TRUE;
9861 case UNDO_IMMEDIATE:
9862 accumulated_undo = FALSE;
9865 case UNDO_ACCUMULATE:
9866 if (accumulated_undo)
9867 new_undo_buffer_position = FALSE;
9868 accumulated_undo = TRUE;
9875 if (new_undo_buffer_position)
9877 /* new position in undo buffer ring */
9878 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
9880 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
9881 undo_buffer_steps++;
9884 for (x = 0; x < lev_fieldx; x++)
9885 for (y = 0; y < lev_fieldy; y++)
9886 UndoBuffer[undo_buffer_position][x][y] = Feld[x][y];
9888 /* check if drawing operation forces change of border style */
9889 CheckLevelBorderElement(TRUE);
9891 level.changed = TRUE;
9894 static void RandomPlacement(int new_element)
9896 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
9897 int num_free_positions = 0;
9898 int num_percentage, num_elements;
9905 /* determine number of free positions for randomly placing the new element */
9906 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
9908 free_position[x][y] =
9909 (random_placement_background_restricted ?
9910 Feld[x][y] == random_placement_background_element :
9911 Feld[x][y] != new_element);
9913 if (free_position[x][y])
9914 num_free_positions++;
9917 /* determine number of new elements to place there */
9918 num_percentage = num_free_positions * random_placement_value / 100;
9919 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
9920 num_percentage : random_placement_value);
9922 /* if less free positions than elements to place, fill all these positions */
9923 if (num_free_positions < num_elements)
9925 for (x = 0; x < lev_fieldx; x++)
9926 for (y = 0; y < lev_fieldy; y++)
9927 if (free_position[x][y])
9929 SetElement(x, y, new_element);
9931 Feld[x][y] = new_element;
9936 while (num_elements > 0)
9938 x = GetSimpleRandom(lev_fieldx);
9939 y = GetSimpleRandom(lev_fieldy);
9941 /* don't place element at the same position twice */
9942 if (free_position[x][y])
9944 free_position[x][y] = FALSE;
9946 SetElement(x, y, new_element);
9948 Feld[x][y] = new_element;
9955 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9956 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
9959 void WrapLevel(int dx, int dy)
9961 int wrap_dx = lev_fieldx - dx;
9962 int wrap_dy = lev_fieldy - dy;
9965 for (x = 0; x < lev_fieldx; x++)
9966 for (y = 0; y < lev_fieldy; y++)
9967 FieldBackup[x][y] = Feld[x][y];
9969 for (x = 0; x < lev_fieldx; x++)
9970 for (y = 0; y < lev_fieldy; y++)
9972 FieldBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
9974 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9975 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
9978 static void HandleDrawingAreas(struct GadgetInfo *gi)
9980 static boolean started_inside_drawing_area = FALSE;
9981 int id = gi->custom_id;
9982 boolean button_press_event;
9983 boolean button_release_event;
9984 boolean inside_drawing_area = !gi->event.off_borders;
9985 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
9986 int actual_drawing_function;
9987 int button = gi->event.button;
9988 int new_element = BUTTON_ELEMENT(button);
9989 int sx = gi->event.x, sy = gi->event.y;
9990 int min_sx = 0, min_sy = 0;
9991 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
9992 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
9994 int min_lx = 0, min_ly = 0;
9995 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
9998 /* handle info callback for each invocation of action callback */
9999 gi->callback_info(gi);
10001 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
10002 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
10004 /* make sure to stay inside drawing area boundaries */
10005 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
10006 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
10010 /* get positions inside level field */
10011 lx = sx + level_xpos;
10012 ly = sy + level_ypos;
10014 if (!IN_LEV_FIELD(lx, ly))
10015 inside_drawing_area = FALSE;
10017 /* make sure to stay inside level field boundaries */
10018 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
10019 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
10021 /* correct drawing area positions accordingly */
10022 sx = lx - level_xpos;
10023 sy = ly - level_ypos;
10026 if (button_press_event)
10027 started_inside_drawing_area = inside_drawing_area;
10029 if (!started_inside_drawing_area)
10032 if (!IS_VALID_BUTTON(button))
10035 if (!button && !button_release_event)
10038 /* automatically switch to 'single item' drawing mode, if needed */
10039 actual_drawing_function =
10040 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
10041 drawing_function : GADGET_ID_SINGLE_ITEMS);
10043 /* clicking into drawing area with pressed Control key picks element */
10044 if (GetKeyModState() & KMOD_Control)
10046 last_drawing_function = drawing_function;
10047 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
10050 if (GetKeyModState() & KMOD_Shift)
10052 if (button_press_event || button_release_event)
10053 ResetIntelliDraw();
10056 switch (actual_drawing_function)
10058 case GADGET_ID_SINGLE_ITEMS:
10061 if (button_release_event)
10063 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10065 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
10066 !inside_drawing_area)
10067 DeleteBrushFromCursor();
10070 ResetIntelliDraw();
10074 if (!button || button_release_event)
10077 if (draw_with_brush)
10080 if (!button_release_event)
10082 CopyBrushToLevel(sx, sy, button);
10087 else if (new_element != Feld[lx][ly])
10090 if (new_element == EL_PLAYER_1)
10092 /* remove player at old position */
10093 for (y = 0; y < lev_fieldy; y++)
10095 for (x = 0; x < lev_fieldx; x++)
10097 if (Feld[x][y] == EL_PLAYER_1)
10100 SetElement(x, y, EL_EMPTY);
10102 Feld[x][y] = EL_EMPTY;
10104 if (IN_ED_FIELD(x - level_xpos, y - level_ypos))
10105 DrawMiniElement(x - level_xpos, y - level_ypos, EL_EMPTY);
10107 if (x - level_xpos >= 0 && x - level_xpos < ed_fieldx &&
10108 y - level_ypos >= 0 && y - level_ypos < ed_fieldy)
10109 DrawMiniElement(x - level_xpos, y - level_ypos, EL_EMPTY);
10118 SetElementButton(lx, ly, new_element, button);
10120 Feld[lx][ly] = new_element;
10121 DrawMiniElement(sx, sy, new_element);
10127 int type_id = gi->custom_type_id;
10128 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
10130 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
10131 DrawMiniGraphicExt(drawto,
10132 gi->x + sx * MINI_TILEX,
10133 gi->y + sy * MINI_TILEY,
10134 el2edimg(new_element));
10136 DrawGraphicExt(drawto,
10137 gi->x + sx * TILEX,
10138 gi->y + sy * TILEY,
10139 el2img(new_element), 0);
10141 if (id == GADGET_ID_CUSTOM_GRAPHIC)
10142 new_element = GFX_ELEMENT(new_element);
10144 drawingarea_info[type_id].value[pos] = new_element;
10146 CopyElementPropertiesToGame(properties_element);
10148 if (id == GADGET_ID_CUSTOM_GRAPHIC)
10150 UpdateCustomElementGraphicGadgets();
10152 FrameCounter = 0; /* restart animation frame counter */
10157 case GADGET_ID_CONNECTED_ITEMS:
10159 static int last_sx = -1;
10160 static int last_sy = -1;
10162 if (button_release_event)
10163 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10167 if (!button_press_event)
10168 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
10176 case GADGET_ID_LINE:
10177 case GADGET_ID_ARC:
10178 case GADGET_ID_RECTANGLE:
10179 case GADGET_ID_FILLED_BOX:
10180 case GADGET_ID_GRAB_BRUSH:
10181 case GADGET_ID_TEXT:
10183 static int last_sx = -1;
10184 static int last_sy = -1;
10185 static int start_sx = -1;
10186 static int start_sy = -1;
10187 void (*draw_func)(int, int, int, int, int, boolean);
10189 if (drawing_function == GADGET_ID_LINE)
10190 draw_func = DrawLine;
10191 else if (drawing_function == GADGET_ID_ARC)
10192 draw_func = DrawArc;
10193 else if (drawing_function == GADGET_ID_RECTANGLE)
10194 draw_func = DrawBox;
10195 else if (drawing_function == GADGET_ID_FILLED_BOX)
10196 draw_func = DrawFilledBox;
10197 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
10198 draw_func = SelectArea;
10199 else /* (drawing_function == GADGET_ID_TEXT) */
10200 draw_func = SetTextCursor;
10202 if (button_press_event)
10204 draw_func(sx, sy, sx, sy, new_element, FALSE);
10205 start_sx = last_sx = sx;
10206 start_sy = last_sy = sy;
10208 if (drawing_function == GADGET_ID_TEXT)
10209 DrawLevelText(0, 0, 0, TEXT_END);
10211 else if (button_release_event)
10213 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
10214 if (drawing_function == GADGET_ID_GRAB_BRUSH)
10216 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
10217 CopyBrushToCursor(sx, sy);
10218 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
10220 draw_with_brush = TRUE;
10222 else if (drawing_function == GADGET_ID_TEXT)
10223 DrawLevelText(sx, sy, 0, TEXT_INIT);
10225 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10227 else if (last_sx != sx || last_sy != sy)
10229 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
10230 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
10237 case GADGET_ID_FLOOD_FILL:
10238 if (button_press_event && Feld[lx][ly] != new_element)
10240 FloodFill(lx, ly, new_element);
10241 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10242 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10246 case GADGET_ID_PICK_ELEMENT:
10247 if (button_release_event)
10248 ClickOnGadget(level_editor_gadget[last_drawing_function],
10250 else if (draw_level)
10251 PickDrawingElement(button, Feld[lx][ly]);
10254 int type_id = gi->custom_type_id;
10255 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
10257 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
10267 static void HandleCounterButtons(struct GadgetInfo *gi)
10269 int gadget_id = gi->custom_id;
10270 int counter_id = gi->custom_type_id;
10271 int button = gi->event.button;
10272 int *counter_value = counterbutton_info[counter_id].value;
10273 int step = BUTTON_STEPSIZE(button) *
10274 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
10276 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
10278 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
10279 boolean released = (gi->event.type == GD_EVENT_RELEASED);
10280 boolean level_changed = LevelChanged();
10282 if ((level_changed && pressed) || (!level_changed && released))
10285 if (level_changed && !Request("Level has changed ! Discard changes ?",
10288 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
10289 ModifyEditorCounterValue(counter_id, *counter_value);
10295 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
10296 *counter_value = gi->textinput.number_value;
10298 ModifyEditorCounterValue(counter_id, *counter_value + step);
10300 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
10302 LoadLevel(level_nr);
10305 DrawEditModeWindow();
10310 switch (counter_id)
10312 case ED_COUNTER_ID_YAMYAM_CONTENT:
10313 DrawYamYamContentAreas();
10316 case ED_COUNTER_ID_BALL_CONTENT:
10317 DrawMagicBallContentAreas();
10320 case ED_COUNTER_ID_ANDROID_CONTENT:
10321 DrawAndroidElementArea(properties_element);
10324 case ED_COUNTER_ID_GROUP_CONTENT:
10325 DrawGroupElementArea(properties_element);
10326 CopyGroupElementPropertiesToGame(properties_element);
10329 case ED_COUNTER_ID_ENVELOPE_XSIZE:
10330 case ED_COUNTER_ID_ENVELOPE_YSIZE:
10331 DrawEnvelopeTextArea(-1);
10334 case ED_COUNTER_ID_LEVEL_XSIZE:
10335 case ED_COUNTER_ID_LEVEL_YSIZE:
10336 lev_fieldx = level.fieldx;
10337 lev_fieldy = level.fieldy;
10344 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
10345 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
10346 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
10347 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
10348 CopyElementPropertiesToGame(properties_element);
10350 level.changed = TRUE;
10353 static void HandleTextInputGadgets(struct GadgetInfo *gi)
10355 int type_id = gi->custom_type_id;
10357 strcpy(textinput_info[type_id].value, gi->textinput.value);
10359 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
10361 CopyElementPropertiesToGame(properties_element);
10363 ModifyEditorElementList(); /* update changed button info text */
10366 level.changed = TRUE;
10369 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
10371 int type_id = gi->custom_type_id;
10374 strncpy(textarea_info[type_id].value, gi->textarea.value,
10375 MAX_ENVELOPE_TEXT_LEN);
10376 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
10378 /* !!! BUGGY !!! MAX_ENVELOPE_TEXT_LEN != MAX_GADGET_TEXTSIZE !!! */
10379 strcpy(textarea_info[type_id].value, gi->textarea.value);
10382 level.changed = TRUE;
10385 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
10387 int type_id = gi->custom_type_id;
10388 int value_old = *selectbox_info[type_id].value;
10389 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
10391 *selectbox_info[type_id].value = value_new;
10393 if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
10395 element_info[properties_element].current_change_page = gi->selectbox.index;
10397 DrawPropertiesWindow();
10399 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
10400 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
10401 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
10402 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
10403 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
10405 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
10407 /* when changing action type, also check action mode and action arg */
10408 if (value_old != value_new)
10409 setSelectboxSpecialActionVariablesIfNeeded();
10411 DrawPropertiesChange();
10414 CopyElementPropertiesToGame(properties_element);
10416 level.changed = TRUE;
10420 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
10422 int type_id = gi->custom_type_id;
10425 if (type_id >= ED_TEXTBUTTON_ID_PROPERTIES_FIRST &&
10426 type_id <= ED_TEXTBUTTON_ID_PROPERTIES_LAST)
10428 edit_mode_properties = gi->custom_type_id;
10430 DrawPropertiesWindow();
10432 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE)
10434 char *template_filename = getDefaultLevelFilename(-1);
10435 boolean new_template = !fileExists(template_filename);
10437 if (new_template ||
10438 Request("Save this template and kill the old ?", REQ_ASK))
10439 SaveLevelTemplate();
10442 Request("Template saved !", REQ_CONFIRM);
10444 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
10445 custom_element.num_change_pages < MAX_CHANGE_PAGES)
10447 struct ElementInfo *ei = &element_info[properties_element];
10449 setElementChangePages(ei, ei->num_change_pages + 1);
10451 /* set new change page to be new current change page */
10452 ei->current_change_page = ei->num_change_pages - 1;
10453 ei->change = &ei->change_page[ei->current_change_page];
10455 setElementChangeInfoToDefaults(ei->change);
10457 DrawPropertiesWindow();
10459 level.changed = TRUE;
10461 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
10462 custom_element.num_change_pages > MIN_CHANGE_PAGES)
10464 struct ElementInfo *ei = &element_info[properties_element];
10466 /* copy all change pages after change page to be deleted */
10467 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
10468 ei->change_page[i] = ei->change_page[i + 1];
10470 setElementChangePages(ei, ei->num_change_pages - 1);
10472 DrawPropertiesWindow();
10474 level.changed = TRUE;
10478 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
10480 int type_id = gi->custom_type_id;
10482 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
10483 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
10485 struct ElementInfo *ei = &element_info[properties_element];
10486 int step = BUTTON_STEPSIZE(gi->event.button);
10488 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
10489 ei->current_change_page += step;
10491 if (ei->current_change_page < 0)
10492 ei->current_change_page = 0;
10493 else if (ei->current_change_page >= ei->num_change_pages)
10494 ei->current_change_page = ei->num_change_pages - 1;
10496 DrawPropertiesWindow();
10498 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
10499 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
10501 struct ElementInfo *ei = &element_info[properties_element];
10502 int current_change_page = ei->current_change_page;
10504 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
10505 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
10506 ei->change_page[current_change_page];
10507 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
10509 ei->change_page[current_change_page] =
10510 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
10512 level.changed = TRUE;
10515 DrawPropertiesWindow();
10519 static void HandleRadiobuttons(struct GadgetInfo *gi)
10521 *radiobutton_info[gi->custom_type_id].value =
10522 radiobutton_info[gi->custom_type_id].checked_value;
10524 level.changed = TRUE;
10527 static void HandleCheckbuttons(struct GadgetInfo *gi)
10529 int type_id = gi->custom_type_id;
10531 *checkbutton_info[type_id].value ^= TRUE;
10533 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
10534 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
10535 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
10536 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
10537 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
10538 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
10539 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
10540 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE))
10542 CopyElementPropertiesToGame(properties_element);
10545 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
10547 UpdateCustomElementGraphicGadgets();
10549 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE)
10551 char *template_filename = getDefaultLevelFilename(-1);
10553 if (level.use_custom_template && !fileExists(template_filename))
10555 Request("No level template found !", REQ_CONFIRM);
10557 level.use_custom_template = FALSE;
10558 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
10563 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
10565 DrawEditModeWindow();
10568 level.changed = TRUE;
10571 static void HandleControlButtons(struct GadgetInfo *gi)
10573 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
10574 static int last_edit_mode = ED_MODE_DRAWING;
10575 static int last_custom_copy_mode = -1;
10576 int id = gi->custom_id;
10577 int button = gi->event.button;
10578 int step = BUTTON_STEPSIZE(button);
10579 int new_element = BUTTON_ELEMENT(button);
10582 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
10583 DrawLevelText(0, 0, 0, TEXT_END);
10585 if (id < ED_NUM_CTRL1_BUTTONS &&
10586 id != GADGET_ID_SINGLE_ITEMS &&
10587 id != GADGET_ID_PROPERTIES &&
10588 id != GADGET_ID_PICK_ELEMENT &&
10589 edit_mode != ED_MODE_DRAWING &&
10590 drawing_function != GADGET_ID_PICK_ELEMENT &&
10591 !(GetKeyModState() & KMOD_Control))
10593 DrawDrawingWindow();
10594 edit_mode = ED_MODE_DRAWING;
10597 /* element copy mode active, but no element button pressed => deactivate */
10598 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
10599 last_custom_copy_mode = -1;
10603 case GADGET_ID_SCROLL_LEFT:
10604 if (level_xpos >= 0)
10606 if (lev_fieldx < ed_fieldx - 2)
10609 level_xpos -= step;
10610 if (level_xpos < -1)
10613 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
10615 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10617 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
10618 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
10622 case GADGET_ID_SCROLL_RIGHT:
10623 if (level_xpos <= lev_fieldx - ed_fieldx)
10625 if (lev_fieldx < ed_fieldx - 2)
10628 level_xpos += step;
10629 if (level_xpos > lev_fieldx - ed_fieldx + 1)
10630 level_xpos = lev_fieldx - ed_fieldx + 1;
10632 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
10634 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10636 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
10637 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
10641 case GADGET_ID_SCROLL_UP:
10642 if (level_ypos >= 0)
10644 if (lev_fieldy < ed_fieldy - 2)
10647 level_ypos -= step;
10648 if (level_ypos < -1)
10651 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
10653 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10655 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
10656 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
10660 case GADGET_ID_SCROLL_DOWN:
10661 if (level_ypos <= lev_fieldy - ed_fieldy)
10663 if (lev_fieldy < ed_fieldy - 2)
10666 level_ypos += step;
10667 if (level_ypos > lev_fieldy - ed_fieldy + 1)
10668 level_ypos = lev_fieldy - ed_fieldy + 1;
10670 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_UP);
10672 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10674 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
10675 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
10679 case GADGET_ID_SCROLL_HORIZONTAL:
10680 level_xpos = gi->event.item_position - 1;
10681 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10684 case GADGET_ID_SCROLL_VERTICAL:
10685 level_ypos = gi->event.item_position - 1;
10686 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10689 case GADGET_ID_SCROLL_LIST_UP:
10690 case GADGET_ID_SCROLL_LIST_DOWN:
10691 case GADGET_ID_SCROLL_LIST_VERTICAL:
10692 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
10693 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
10696 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
10697 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
10699 if (element_shift < 0)
10701 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
10702 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
10704 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
10705 GDI_SCROLLBAR_ITEM_POSITION,
10706 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
10709 ModifyEditorElementList();
10713 case GADGET_ID_WRAP_LEFT:
10714 WrapLevel(-step, 0);
10717 case GADGET_ID_WRAP_RIGHT:
10718 WrapLevel(step, 0);
10721 case GADGET_ID_WRAP_UP:
10722 WrapLevel(0, -step);
10725 case GADGET_ID_WRAP_DOWN:
10726 WrapLevel(0, step);
10729 case GADGET_ID_SINGLE_ITEMS:
10730 case GADGET_ID_CONNECTED_ITEMS:
10731 case GADGET_ID_LINE:
10732 case GADGET_ID_ARC:
10733 case GADGET_ID_TEXT:
10734 case GADGET_ID_RECTANGLE:
10735 case GADGET_ID_FILLED_BOX:
10736 case GADGET_ID_FLOOD_FILL:
10737 case GADGET_ID_GRAB_BRUSH:
10738 case GADGET_ID_PICK_ELEMENT:
10739 if (drawing_function != GADGET_ID_PICK_ELEMENT)
10740 last_drawing_function = drawing_function;
10741 drawing_function = id;
10742 draw_with_brush = FALSE;
10745 case GADGET_ID_RANDOM_PLACEMENT:
10746 RandomPlacement(new_element);
10749 case GADGET_ID_PROPERTIES:
10750 if (edit_mode != ED_MODE_PROPERTIES)
10752 properties_element = new_element;
10753 DrawPropertiesWindow();
10754 edit_mode = ED_MODE_PROPERTIES;
10756 last_level_drawing_function = drawing_function;
10757 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
10762 DrawDrawingWindow();
10763 edit_mode = ED_MODE_DRAWING;
10765 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
10770 case GADGET_ID_CUSTOM_COPY_FROM:
10771 case GADGET_ID_CUSTOM_COPY_TO:
10772 case GADGET_ID_CUSTOM_EXCHANGE:
10773 last_custom_copy_mode = id;
10774 last_drawing_function = drawing_function;
10777 case GADGET_ID_CUSTOM_COPY:
10778 CopyCustomElement(properties_element, -1, id);
10781 case GADGET_ID_CUSTOM_PASTE:
10782 CopyCustomElement(-1, properties_element, id);
10785 case GADGET_ID_UNDO:
10786 if (undo_buffer_steps == 0)
10788 Request("Undo buffer empty !", REQ_CONFIRM);
10792 if (edit_mode != ED_MODE_DRAWING)
10794 DrawDrawingWindow();
10795 edit_mode = ED_MODE_DRAWING;
10798 undo_buffer_position =
10799 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
10800 undo_buffer_steps--;
10802 for (x = 0; x < lev_fieldx; x++)
10803 for (y = 0; y < lev_fieldy; y++)
10804 Feld[x][y] = UndoBuffer[undo_buffer_position][x][y];
10806 /* check if undo operation forces change of border style */
10807 CheckLevelBorderElement(FALSE);
10809 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10813 case GADGET_ID_INFO:
10814 if (edit_mode != ED_MODE_INFO)
10816 last_edit_mode = edit_mode;
10817 edit_mode = ED_MODE_INFO;
10819 DrawLevelInfoWindow();
10823 edit_mode = last_edit_mode;
10825 DrawEditModeWindow();
10829 case GADGET_ID_CLEAR:
10830 if (edit_mode != ED_MODE_DRAWING)
10832 DrawDrawingWindow();
10833 edit_mode = ED_MODE_DRAWING;
10836 for (x = 0; x < MAX_LEV_FIELDX; x++)
10837 for (y = 0; y < MAX_LEV_FIELDY; y++)
10838 Feld[x][y] = (button == 1 ? EL_EMPTY : new_element);
10840 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
10842 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10845 case GADGET_ID_SAVE:
10846 if (leveldir_current->readonly)
10848 Request("This level is read only !", REQ_CONFIRM);
10852 if (!LevelContainsPlayer())
10853 Request("No Level without Gregor Mc Duffin please !", REQ_CONFIRM);
10856 char *level_filename = getDefaultLevelFilename(level_nr);
10857 boolean new_level = !fileExists(level_filename);
10860 Request("Save this level and kill the old ?", REQ_ASK))
10862 CopyPlayfield(Feld, level.field);
10864 SaveLevel(level_nr);
10868 Request("Level saved !", REQ_CONFIRM);
10870 level.changed = FALSE;
10874 case GADGET_ID_TEST:
10875 if (!LevelContainsPlayer())
10876 Request("No Level without Gregor Mc Duffin please !", REQ_CONFIRM);
10879 if (LevelChanged())
10880 level.game_version = GAME_VERSION_ACTUAL;
10882 CopyPlayfield(level.field, FieldBackup);
10883 CopyPlayfield(Feld, level.field);
10885 CopyNativeLevel_RND_to_Native(&level);
10887 UnmapLevelEditorGadgets();
10888 UndrawSpecialEditorDoor();
10890 CloseDoor(DOOR_CLOSE_ALL);
10892 DrawCompleteVideoDisplay();
10894 level_editor_test_game = TRUE;
10896 StartGameActions(FALSE, setup.autorecord, NEW_RANDOMIZE);
10900 case GADGET_ID_EXIT:
10901 RequestExitLevelEditor(TRUE, FALSE); /* if level has changed, ask user */
10905 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
10906 id <= GADGET_ID_ELEMENTLIST_LAST)
10908 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
10909 int new_element = editor_elements[element_position + element_shift];
10911 if (IS_EDITOR_CASCADE(new_element))
10915 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
10917 int *cascade_element= &(*editor_elements_info[i].headline_list)[0];
10918 boolean *cascade_value=editor_elements_info[i].setup_cascade_value;
10920 if (*cascade_element == new_element)
10922 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
10923 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
10925 /* update element selection list */
10926 ReinitializeElementList();
10927 ModifyEditorElementList();
10929 /* update cascading gadget info text */
10930 PrintEditorGadgetInfoText(level_editor_gadget[id]);
10932 /* save current editor cascading state */
10933 SaveSetup_EditorCascade();
10942 if (last_custom_copy_mode != -1)
10944 if (CopyCustomElement(properties_element, new_element,
10945 last_custom_copy_mode))
10947 ClickOnGadget(level_editor_gadget[last_drawing_function],
10950 last_custom_copy_mode = -1;
10956 PickDrawingElement(button, new_element);
10958 if (!stick_element_properties_window &&
10959 drawing_function != GADGET_ID_PICK_ELEMENT &&
10960 !(GetKeyModState() & KMOD_Control))
10962 properties_element = new_element;
10963 if (edit_mode == ED_MODE_PROPERTIES)
10964 DrawPropertiesWindow();
10967 if (drawing_function == GADGET_ID_PICK_ELEMENT)
10968 ClickOnGadget(level_editor_gadget[last_drawing_function],
10972 else if (gi->event.type == GD_EVENT_PRESSED)
10973 printf("default: HandleControlButtons: GD_EVENT_PRESSED(%d)\n", id);
10974 else if (gi->event.type == GD_EVENT_RELEASED)
10975 printf("default: HandleControlButtons: GD_EVENT_RELEASED(%d)\n", id);
10976 else if (gi->event.type == GD_EVENT_MOVING)
10977 printf("default: HandleControlButtons: GD_EVENT_MOVING(%d)\n", id);
10979 printf("default: HandleControlButtons: ? (id == %d)\n", id);
10985 void HandleLevelEditorKeyInput(Key key)
10987 char letter = getCharFromKey(key);
10988 int button = MB_LEFTBUTTON;
10990 if (drawing_function == GADGET_ID_TEXT &&
10991 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
10994 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
10995 else if (key == KSYM_Delete || key == KSYM_BackSpace)
10996 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
10997 else if (key == KSYM_Return)
10998 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
10999 else if (key == KSYM_Escape)
11000 DrawLevelText(0, 0, 0, TEXT_END);
11002 else if (button_status == MB_RELEASED)
11004 int id = GADGET_ID_NONE;
11005 int new_element_shift = element_shift;
11011 id = GADGET_ID_SCROLL_LEFT;
11014 id = GADGET_ID_SCROLL_RIGHT;
11017 id = GADGET_ID_SCROLL_UP;
11020 id = GADGET_ID_SCROLL_DOWN;
11023 id = GADGET_ID_SCROLL_LIST_UP;
11024 button = MB_RIGHTBUTTON;
11026 case KSYM_Page_Down:
11027 id = GADGET_ID_SCROLL_LIST_DOWN;
11028 button = MB_RIGHTBUTTON;
11033 element_shift = (key == KSYM_Home ? 0 :
11034 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
11036 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
11037 GDI_SCROLLBAR_ITEM_POSITION,
11038 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
11040 ModifyEditorElementList();
11047 /* this is needed to prevent interference with running "True X-Mouse" */
11048 if (GetKeyModStateFromEvents() & KMOD_Control)
11051 /* check for last or next editor cascade block in element list */
11052 for (i = 0; i < num_editor_elements; i++)
11054 if ((key == KSYM_Insert && i == element_shift) ||
11055 (key == KSYM_Delete && new_element_shift > element_shift))
11058 /* jump to next cascade block (or to start of element list) */
11059 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
11060 new_element_shift = i;
11063 if (i < num_editor_elements)
11064 element_shift = new_element_shift;
11066 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
11067 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
11069 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
11070 GDI_SCROLLBAR_ITEM_POSITION,
11071 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
11073 ModifyEditorElementList();
11078 if (edit_mode == ED_MODE_DRAWING)
11080 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
11082 else if (edit_mode == ED_MODE_INFO)
11084 HandleControlButtons(level_editor_gadget[GADGET_ID_INFO]);
11086 else if (edit_mode == ED_MODE_PROPERTIES)
11088 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
11090 else /* should never happen */
11092 DrawDrawingWindow();
11093 edit_mode = ED_MODE_DRAWING;
11102 if (id != GADGET_ID_NONE)
11103 ClickOnGadget(level_editor_gadget[id], button);
11104 else if (letter == '.')
11105 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
11106 else if (key == KSYM_Return || key == setup.shortcut.toggle_pause)
11107 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
11109 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
11110 if (letter && letter == control_info[i].shortcut)
11111 if (!anyTextGadgetActive())
11112 ClickOnGadget(level_editor_gadget[i], button);
11116 void HandleLevelEditorIdle()
11118 static unsigned long action_delay = 0;
11119 unsigned long action_delay_value = GameFrameDelay;
11120 int xpos = 1, ypos = 2;
11122 if (edit_mode != ED_MODE_PROPERTIES)
11125 if (!DelayReached(&action_delay, action_delay_value))
11128 DrawEditorElementAnimation(SX + xpos * TILEX,
11129 SY + ypos * TILEY + MINI_TILEY / 2);
11131 MarkTileDirty(xpos, ypos);
11132 MarkTileDirty(xpos, ypos + 1);
11134 FrameCounter++; /* increase animation frame counter */
11137 void ClearEditorGadgetInfoText()
11139 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
11142 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
11144 char infotext[MAX_OUTPUT_LINESIZE + 1];
11145 char shortcut[MAX_OUTPUT_LINESIZE + 1];
11146 int max_infotext_len = getMaxInfoTextLength();
11148 if (gi == NULL || gi->info_text == NULL)
11151 strncpy(infotext, gi->info_text, max_infotext_len);
11152 infotext[max_infotext_len] = '\0';
11154 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
11156 int key = control_info[gi->custom_id].shortcut;
11160 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS) /* special case 1 */
11161 sprintf(shortcut, " ('.' or '%c')", key);
11162 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT) /* special case 2 */
11163 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
11164 else if (gi->custom_id == GADGET_ID_TEST) /* special case 3 */
11165 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
11166 else /* normal case */
11167 sprintf(shortcut, " ('%s%c')",
11168 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
11170 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
11171 strcat(infotext, shortcut);
11175 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, FONT_TEXT_2);
11178 void HandleEditorGadgetInfoText(void *ptr)
11180 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
11182 if (game_status != GAME_MODE_EDITOR)
11185 ClearEditorGadgetInfoText();
11187 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
11190 /* misuse this function to delete brush cursor, if needed */
11191 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
11192 DeleteBrushFromCursor();
11194 PrintEditorGadgetInfoText(gi);
11197 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
11199 static int start_lx, start_ly;
11200 int id = gi->custom_id;
11201 int type_id = gi->custom_type_id;
11202 int sx = gi->event.x;
11203 int sy = gi->event.y;
11204 int lx = sx + level_xpos;
11205 int ly = sy + level_ypos;
11206 int min_sx = 0, min_sy = 0;
11207 int max_sx = gi->drawing.area_xsize - 1;
11208 int max_sy = gi->drawing.area_ysize - 1;
11209 int actual_drawing_function = drawing_function;
11210 int max_infotext_len = getMaxInfoTextLength();
11211 char infotext[MAX_OUTPUT_LINESIZE + 1];
11214 infotext[0] = '\0'; /* start with empty info text */
11216 /* pressed Control key: simulate picking element */
11217 if (GetKeyModState() & KMOD_Control)
11218 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
11220 ClearEditorGadgetInfoText();
11222 if (gi->event.type == GD_EVENT_INFO_LEAVING)
11225 /* make sure to stay inside drawing area boundaries */
11226 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
11227 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
11229 if (id == GADGET_ID_DRAWING_LEVEL)
11233 int min_lx = 0, min_ly = 0;
11234 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
11236 /* get positions inside level field */
11237 lx = sx + level_xpos;
11238 ly = sy + level_ypos;
11240 /* make sure to stay inside level field boundaries */
11241 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
11242 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
11244 /* correct drawing area positions accordingly */
11245 sx = lx - level_xpos;
11246 sy = ly - level_ypos;
11249 if (IN_ED_FIELD(sx,sy) && IN_LEV_FIELD(lx, ly))
11251 if (button_status) /* if (gi->state == GD_BUTTON_PRESSED) */
11253 if (gi->event.type == GD_EVENT_PRESSED)
11259 switch (actual_drawing_function)
11261 case GADGET_ID_SINGLE_ITEMS:
11262 text = "Drawing single items";
11264 case GADGET_ID_CONNECTED_ITEMS:
11265 text = "Drawing connected items";
11267 case GADGET_ID_LINE:
11268 text = "Drawing line";
11270 case GADGET_ID_ARC:
11271 text = "Drawing arc";
11273 case GADGET_ID_TEXT:
11274 text = "Setting text cursor";
11276 case GADGET_ID_RECTANGLE:
11277 text = "Drawing rectangle";
11279 case GADGET_ID_FILLED_BOX:
11280 text = "Drawing filled box";
11282 case GADGET_ID_FLOOD_FILL:
11283 text = "Flood fill";
11285 case GADGET_ID_GRAB_BRUSH:
11286 text = "Grabbing brush";
11288 case GADGET_ID_PICK_ELEMENT:
11289 text = "Picking element";
11293 text = "Drawing position";
11297 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
11298 sprintf(infotext, "%s: %d, %d", text, lx, ly);
11300 sprintf(infotext, "%s: %d, %d", text,
11301 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
11303 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
11304 strncpy(infotext, getElementInfoText(Feld[lx][ly]), max_infotext_len);
11306 sprintf(infotext, "Level position: %d, %d", lx, ly);
11309 /* misuse this function to draw brush cursor, if needed */
11310 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
11312 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
11313 CopyBrushToCursor(sx, sy);
11315 DeleteBrushFromCursor();
11318 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
11320 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
11321 int element = drawingarea_info[type_id].value[pos];
11323 strncpy(infotext, getElementInfoText(element), max_infotext_len);
11327 if (id == GADGET_ID_CUSTOM_CONTENT)
11328 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
11329 else if (id == GADGET_ID_GROUP_CONTENT)
11330 sprintf(infotext, "group element position: %d", sx + 1);
11331 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
11332 id <= GADGET_ID_YAMYAM_CONTENT_7)
11333 sprintf(infotext, "content area %d position: %d, %d",
11334 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
11335 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
11336 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
11337 sprintf(infotext, "content area %d position: %d, %d",
11338 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
11339 else if (id == GADGET_ID_ANDROID_CONTENT)
11340 sprintf(infotext, "android element position: %d", sx + 1);
11341 else if (drawingarea_info[type_id].infotext != NULL)
11342 strcpy(infotext, drawingarea_info[type_id].infotext);
11345 infotext[max_infotext_len] = '\0';
11347 if (strlen(infotext) > 0)
11348 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, infotext);
11351 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
11352 boolean quick_quit)
11354 if (!ask_if_level_has_changed ||
11356 Request("Level has changed ! Exit without saving ?",
11357 REQ_ASK | REQ_STAY_OPEN))
11359 CloseDoor(DOOR_CLOSE_1);
11360 SetDoorState(DOOR_CLOSE_2);
11364 FadeSkipNextFadeIn();
11367 fading = fading_none;
11370 game_status = GAME_MODE_MAIN;
11372 DrawAndFadeInMainMenu(REDRAW_FIELD);
11379 CloseDoor(DOOR_CLOSE_1);
11380 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);