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 (7 * 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)
124 #define ED_SETTINGS_TAB_XOFFSET 124
126 #define ED_LEVEL_SETTINGS_XPOS(n) (ED_LEVEL_SETTINGS_XSTART + \
127 (n) * ED_SETTINGS_XOFFSET)
128 #define ED_LEVEL_SETTINGS_YPOS(n) (ED_LEVEL_SETTINGS_YSTART + \
129 (n) * ED_SETTINGS_YOFFSET)
131 #define ED_ELEMENT_SETTINGS_XPOS(n) (ED_ELEMENT_SETTINGS_XSTART + \
132 (n) * ED_SETTINGS_XOFFSET)
133 #define ED_ELEMENT_SETTINGS_YPOS(n) (ED_ELEMENT_SETTINGS_YSTART + \
134 (n) * ED_SETTINGS_YOFFSET)
136 #define ED_LEVEL_SETTINGS_TABS_XPOS(n) (ED_LEVEL_SETTINGS_XPOS(0) + \
137 (n) * ED_SETTINGS_TAB_XOFFSET)
138 #define ED_LEVEL_SETTINGS_TABS_YPOS(n) (ED_LEVEL_SETTINGS_YSTART - \
141 #define ED_ELEMENT_SETTINGS_TABS_XPOS(n) (ED_ELEMENT_SETTINGS_XPOS(0) + \
142 (n) * ED_SETTINGS_TAB_XOFFSET)
143 #define ED_ELEMENT_SETTINGS_TABS_YPOS(n) (ED_ELEMENT_SETTINGS_YSTART - \
146 #define ED_SETTINGS1_YPOS MINI_TILEY
147 #define ED_SETTINGS2_XPOS MINI_TILEX
148 #define ED_SETTINGS2_YPOS (ED_SETTINGS1_YPOS + 12 * TILEY - 2)
150 /* values for counter gadgets */
151 #define ED_COUNTER_YSTART (ED_SETTINGS1_YPOS + 2 * TILEY)
152 #define ED_COUNTER_YDISTANCE (3 * MINI_TILEY)
153 #define ED_COUNTER_YPOS(n) (ED_COUNTER_YSTART + \
154 (n) * ED_COUNTER_YDISTANCE)
155 #define ED_COUNTER2_YPOS(n) (ED_COUNTER_YSTART + \
156 (n) * ED_COUNTER_YDISTANCE - 2)
158 /* values for element content drawing areas */
159 #define ED_AREA_1X1_SETTINGS_XPOS(n) (ED_ELEMENT_SETTINGS_XPOS(n))
160 #define ED_AREA_1X1_SETTINGS_YPOS(n) (ED_ELEMENT_SETTINGS_YPOS(n) + \
163 #define ED_AREA_3X3_SETTINGS_XPOS(n) (ED_ELEMENT_SETTINGS_XPOS(n))
164 #define ED_AREA_3X3_SETTINGS_YPOS(n) (ED_ELEMENT_SETTINGS_YPOS(n) + \
165 ED_GADGET_DISTANCE - MINI_TILEY)
168 #define ED_AREA_YAMYAM_CONTENT_XPOS(n) (2 * MINI_TILEX + \
169 5 * ((n) % 4) * MINI_TILEX)
170 #define ED_AREA_YAMYAM_CONTENT_YPOS(n) (11 * ED_SETTINGS_YOFFSET + \
171 6 * ((n) / 4) * MINI_TILEY)
173 /* magic ball content */
174 #define ED_AREA_MAGIC_BALL_CONTENT_XPOS(n) (2 * MINI_TILEX + \
175 5 * ((n) % 4) * MINI_TILEX)
176 #define ED_AREA_MAGIC_BALL_CONTENT_YPOS(n) (12 * ED_SETTINGS_YOFFSET + \
177 6 * ((n) / 4) * MINI_TILEY)
179 /* values for scrolling gadgets for drawing area */
180 #define ED_SCROLLBUTTON_XPOS 24
181 #define ED_SCROLLBUTTON_YPOS 0
182 #define ED_SCROLLBAR_XPOS 24
183 #define ED_SCROLLBAR_YPOS 64
185 #define ED_SCROLLBUTTON_XSIZE 16
186 #define ED_SCROLLBUTTON_YSIZE 16
188 #define ED_SCROLL_UP_XPOS (SXSIZE - ED_SCROLLBUTTON_XSIZE)
189 #define ED_SCROLL_UP_YPOS (0)
190 #define ED_SCROLL_DOWN_XPOS ED_SCROLL_UP_XPOS
191 #define ED_SCROLL_DOWN_YPOS (SYSIZE - 3 * ED_SCROLLBUTTON_YSIZE)
192 #define ED_SCROLL_LEFT_XPOS (0)
193 #define ED_SCROLL_LEFT_YPOS (SYSIZE - 2 * ED_SCROLLBUTTON_YSIZE)
194 #define ED_SCROLL_RIGHT_XPOS (SXSIZE - 2 * ED_SCROLLBUTTON_XSIZE)
195 #define ED_SCROLL_RIGHT_YPOS ED_SCROLL_LEFT_YPOS
196 #define ED_SCROLL_HORIZONTAL_XPOS (ED_SCROLL_LEFT_XPOS + \
197 ED_SCROLLBUTTON_XSIZE)
198 #define ED_SCROLL_HORIZONTAL_YPOS ED_SCROLL_LEFT_YPOS
199 #define ED_SCROLL_HORIZONTAL_XSIZE (SXSIZE - 3 * ED_SCROLLBUTTON_XSIZE)
200 #define ED_SCROLL_HORIZONTAL_YSIZE ED_SCROLLBUTTON_YSIZE
201 #define ED_SCROLL_VERTICAL_XPOS ED_SCROLL_UP_XPOS
202 #define ED_SCROLL_VERTICAL_YPOS (ED_SCROLL_UP_YPOS + \
203 ED_SCROLLBUTTON_YSIZE)
204 #define ED_SCROLL_VERTICAL_XSIZE ED_SCROLLBUTTON_XSIZE
205 #define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - 4 * ED_SCROLLBUTTON_YSIZE)
207 /* values for scrolling gadgets for element list */
208 #define ED_SCROLLBUTTON2_XPOS 50
209 #define ED_SCROLLBUTTON2_YPOS 0
210 #define ED_SCROLLBAR2_XPOS 50
211 #define ED_SCROLLBAR2_YPOS 20
213 #define ED_SCROLLBUTTON2_XSIZE 10
214 #define ED_SCROLLBUTTON2_YSIZE 10
216 #define ED_SCROLL2_UP_XPOS 85
217 #define ED_SCROLL2_UP_YPOS 30
218 #define ED_SCROLL2_DOWN_XPOS ED_SCROLL2_UP_XPOS
219 #define ED_SCROLL2_DOWN_YPOS (ED_SCROLL2_UP_YPOS + \
220 ED_ELEMENTLIST_BUTTONS_VERT * \
221 ED_ELEMENTLIST_YSIZE - \
222 ED_SCROLLBUTTON2_YSIZE)
223 #define ED_SCROLL2_VERTICAL_XPOS ED_SCROLL2_UP_XPOS
224 #define ED_SCROLL2_VERTICAL_YPOS (ED_SCROLL2_UP_YPOS + \
225 ED_SCROLLBUTTON2_YSIZE)
226 #define ED_SCROLL2_VERTICAL_XSIZE ED_SCROLLBUTTON2_XSIZE
227 #define ED_SCROLL2_VERTICAL_YSIZE (ED_ELEMENTLIST_BUTTONS_VERT * \
228 ED_ELEMENTLIST_YSIZE - \
229 2 * ED_SCROLLBUTTON2_YSIZE)
231 /* values for checkbutton gadgets */
232 #define ED_CHECKBUTTON_XSIZE ED_BUTTON_COUNT_XSIZE
233 #define ED_CHECKBUTTON_YSIZE ED_BUTTON_COUNT_YSIZE
234 #define ED_CHECKBUTTON_UNCHECKED_XPOS ED_BUTTON_MINUS_XPOS
235 #define ED_CHECKBUTTON_CHECKED_XPOS ED_BUTTON_PLUS_XPOS
236 #define ED_CHECKBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 22)
237 #define ED_RADIOBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 44)
238 #define ED_STICKYBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 66)
240 /* values for some special graphic buttons */
241 #define ED_COPY_CHANGE_PAGE_XPOS 25
242 #define ED_COPY_CHANGE_PAGE_YPOS 50
243 #define ED_PASTE_CHANGE_PAGE_XPOS 25
244 #define ED_PASTE_CHANGE_PAGE_YPOS 70
246 /* some values for text input, selectbox and counter gadgets */
247 #define ED_BUTTON_COUNT_YPOS 60
248 #define ED_BUTTON_COUNT_XSIZE 20
249 #define ED_BUTTON_COUNT_YSIZE 20
250 #define ED_WIN_COUNT_XPOS (2 + ED_BUTTON_COUNT_XSIZE + 2)
251 #define ED_WIN_COUNT_YPOS ED_BUTTON_COUNT_YPOS
252 #define ED_WIN_COUNT_XSIZE 52
253 #define ED_WIN_COUNT_YSIZE ED_BUTTON_COUNT_YSIZE
254 #define ED_WIN_COUNT2_XPOS 27
255 #define ED_WIN_COUNT2_YPOS 3
256 #define ED_WIN_COUNT2_XSIZE 46
257 #define ED_WIN_COUNT2_YSIZE ED_BUTTON_COUNT_YSIZE
259 #define ED_BUTTON_MINUS_XPOS 2
260 #define ED_BUTTON_MINUS_YPOS ED_BUTTON_COUNT_YPOS
261 #define ED_BUTTON_MINUS_XSIZE ED_BUTTON_COUNT_XSIZE
262 #define ED_BUTTON_MINUS_YSIZE ED_BUTTON_COUNT_YSIZE
263 #define ED_BUTTON_PLUS_XPOS (ED_WIN_COUNT_XPOS + \
264 ED_WIN_COUNT_XSIZE + 2)
265 #define ED_BUTTON_PLUS_YPOS ED_BUTTON_COUNT_YPOS
266 #define ED_BUTTON_PLUS_XSIZE ED_BUTTON_COUNT_XSIZE
267 #define ED_BUTTON_PLUS_YSIZE ED_BUTTON_COUNT_YSIZE
269 #define ED_SELECTBOX_XPOS ED_WIN_COUNT_XPOS
270 #define ED_SELECTBOX_YPOS (ED_WIN_COUNT_YPOS + \
271 2 + ED_WIN_COUNT_YSIZE)
272 #define ED_SELECTBOX_XSIZE ED_WIN_COUNT_XSIZE
273 #define ED_SELECTBOX_YSIZE ED_WIN_COUNT_YSIZE
275 #define ED_SELECTBOX_BUTTON_XSIZE 14
277 #define ED_TEXTBUTTON_XPOS ED_WIN_COUNT_XPOS
278 #define ED_TEXTBUTTON_YPOS (ED_WIN_COUNT_YPOS + \
279 4 * (2 + ED_WIN_COUNT_YSIZE))
280 #define ED_TEXTBUTTON_INACTIVE_YPOS ED_TEXTBUTTON_YPOS
282 #define ED_TEXTBUTTON_TAB_XPOS ED_WIN_COUNT_XPOS
283 #define ED_TEXTBUTTON_TAB_YPOS (ED_WIN_COUNT_YPOS + \
284 2 * (2 + ED_WIN_COUNT_YSIZE))
285 #define ED_TEXTBUTTON_TAB_INACTIVE_YPOS (ED_WIN_COUNT_YPOS + \
286 3 * (2 + ED_WIN_COUNT_YSIZE))
288 #define ED_TEXTBUTTON_XSIZE ED_WIN_COUNT_XSIZE
289 #define ED_TEXTBUTTON_YSIZE ED_WIN_COUNT_YSIZE
291 /* values for ClearEditorGadgetInfoText() and HandleEditorGadgetInfoText() */
292 #define INFOTEXT_XPOS SX
293 #define INFOTEXT_YPOS (SY + SYSIZE - MINI_TILEX + 2)
294 #define INFOTEXT_XSIZE SXSIZE
295 #define INFOTEXT_YSIZE MINI_TILEX
299 -----------------------------------------------------------------------------
300 editor gadget definitions
301 -----------------------------------------------------------------------------
304 /* drawing toolbox buttons */
305 #define GADGET_ID_NONE -1
306 #define GADGET_ID_TOOLBOX_FIRST 0
308 #define GADGET_ID_SINGLE_ITEMS (GADGET_ID_TOOLBOX_FIRST + 0)
309 #define GADGET_ID_CONNECTED_ITEMS (GADGET_ID_TOOLBOX_FIRST + 1)
310 #define GADGET_ID_LINE (GADGET_ID_TOOLBOX_FIRST + 2)
311 #define GADGET_ID_ARC (GADGET_ID_TOOLBOX_FIRST + 3)
312 #define GADGET_ID_RECTANGLE (GADGET_ID_TOOLBOX_FIRST + 4)
313 #define GADGET_ID_FILLED_BOX (GADGET_ID_TOOLBOX_FIRST + 5)
314 #define GADGET_ID_WRAP_UP (GADGET_ID_TOOLBOX_FIRST + 6)
315 #define GADGET_ID_TEXT (GADGET_ID_TOOLBOX_FIRST + 7)
316 #define GADGET_ID_FLOOD_FILL (GADGET_ID_TOOLBOX_FIRST + 8)
317 #define GADGET_ID_WRAP_LEFT (GADGET_ID_TOOLBOX_FIRST + 9)
318 #define GADGET_ID_PROPERTIES (GADGET_ID_TOOLBOX_FIRST + 10)
319 #define GADGET_ID_WRAP_RIGHT (GADGET_ID_TOOLBOX_FIRST + 11)
320 #define GADGET_ID_RANDOM_PLACEMENT (GADGET_ID_TOOLBOX_FIRST + 12)
321 #define GADGET_ID_GRAB_BRUSH (GADGET_ID_TOOLBOX_FIRST + 13)
322 #define GADGET_ID_WRAP_DOWN (GADGET_ID_TOOLBOX_FIRST + 14)
323 #define GADGET_ID_PICK_ELEMENT (GADGET_ID_TOOLBOX_FIRST + 15)
325 #define GADGET_ID_UNDO (GADGET_ID_TOOLBOX_FIRST + 16)
326 #define GADGET_ID_INFO (GADGET_ID_TOOLBOX_FIRST + 17)
327 #define GADGET_ID_SAVE (GADGET_ID_TOOLBOX_FIRST + 18)
328 #define GADGET_ID_CLEAR (GADGET_ID_TOOLBOX_FIRST + 19)
329 #define GADGET_ID_TEST (GADGET_ID_TOOLBOX_FIRST + 20)
330 #define GADGET_ID_EXIT (GADGET_ID_TOOLBOX_FIRST + 21)
332 #define GADGET_ID_CUSTOM_COPY_FROM (GADGET_ID_TOOLBOX_FIRST + 22)
333 #define GADGET_ID_CUSTOM_COPY_TO (GADGET_ID_TOOLBOX_FIRST + 23)
334 #define GADGET_ID_CUSTOM_EXCHANGE (GADGET_ID_TOOLBOX_FIRST + 24)
335 #define GADGET_ID_CUSTOM_COPY (GADGET_ID_TOOLBOX_FIRST + 25)
336 #define GADGET_ID_CUSTOM_PASTE (GADGET_ID_TOOLBOX_FIRST + 26)
338 /* counter gadget identifiers */
339 #define GADGET_ID_COUNTER_FIRST (GADGET_ID_TOOLBOX_FIRST + 27)
341 #define GADGET_ID_SELECT_LEVEL_DOWN (GADGET_ID_COUNTER_FIRST + 0)
342 #define GADGET_ID_SELECT_LEVEL_TEXT (GADGET_ID_COUNTER_FIRST + 1)
343 #define GADGET_ID_SELECT_LEVEL_UP (GADGET_ID_COUNTER_FIRST + 2)
344 #define GADGET_ID_LEVEL_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 3)
345 #define GADGET_ID_LEVEL_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 4)
346 #define GADGET_ID_LEVEL_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 5)
347 #define GADGET_ID_LEVEL_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 6)
348 #define GADGET_ID_LEVEL_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 7)
349 #define GADGET_ID_LEVEL_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 8)
350 #define GADGET_ID_LEVEL_RANDOM_DOWN (GADGET_ID_COUNTER_FIRST + 9)
351 #define GADGET_ID_LEVEL_RANDOM_TEXT (GADGET_ID_COUNTER_FIRST + 10)
352 #define GADGET_ID_LEVEL_RANDOM_UP (GADGET_ID_COUNTER_FIRST + 11)
353 #define GADGET_ID_LEVEL_GEMSLIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 12)
354 #define GADGET_ID_LEVEL_GEMSLIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 13)
355 #define GADGET_ID_LEVEL_GEMSLIMIT_UP (GADGET_ID_COUNTER_FIRST + 14)
356 #define GADGET_ID_LEVEL_TIMELIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 15)
357 #define GADGET_ID_LEVEL_TIMELIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 16)
358 #define GADGET_ID_LEVEL_TIMELIMIT_UP (GADGET_ID_COUNTER_FIRST + 17)
359 #define GADGET_ID_LEVEL_TIMESCORE_DOWN (GADGET_ID_COUNTER_FIRST + 18)
360 #define GADGET_ID_LEVEL_TIMESCORE_TEXT (GADGET_ID_COUNTER_FIRST + 19)
361 #define GADGET_ID_LEVEL_TIMESCORE_UP (GADGET_ID_COUNTER_FIRST + 20)
362 #define GADGET_ID_LEVEL_RANDOM_SEED_DOWN (GADGET_ID_COUNTER_FIRST + 21)
363 #define GADGET_ID_LEVEL_RANDOM_SEED_TEXT (GADGET_ID_COUNTER_FIRST + 22)
364 #define GADGET_ID_LEVEL_RANDOM_SEED_UP (GADGET_ID_COUNTER_FIRST + 23)
365 #define GADGET_ID_ELEMENT_VALUE1_DOWN (GADGET_ID_COUNTER_FIRST + 24)
366 #define GADGET_ID_ELEMENT_VALUE1_TEXT (GADGET_ID_COUNTER_FIRST + 25)
367 #define GADGET_ID_ELEMENT_VALUE1_UP (GADGET_ID_COUNTER_FIRST + 26)
368 #define GADGET_ID_ELEMENT_VALUE2_DOWN (GADGET_ID_COUNTER_FIRST + 27)
369 #define GADGET_ID_ELEMENT_VALUE2_TEXT (GADGET_ID_COUNTER_FIRST + 28)
370 #define GADGET_ID_ELEMENT_VALUE2_UP (GADGET_ID_COUNTER_FIRST + 29)
371 #define GADGET_ID_ELEMENT_VALUE3_DOWN (GADGET_ID_COUNTER_FIRST + 30)
372 #define GADGET_ID_ELEMENT_VALUE3_TEXT (GADGET_ID_COUNTER_FIRST + 31)
373 #define GADGET_ID_ELEMENT_VALUE3_UP (GADGET_ID_COUNTER_FIRST + 32)
374 #define GADGET_ID_ELEMENT_VALUE4_DOWN (GADGET_ID_COUNTER_FIRST + 33)
375 #define GADGET_ID_ELEMENT_VALUE4_TEXT (GADGET_ID_COUNTER_FIRST + 34)
376 #define GADGET_ID_ELEMENT_VALUE4_UP (GADGET_ID_COUNTER_FIRST + 35)
377 #define GADGET_ID_YAMYAM_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 36)
378 #define GADGET_ID_YAMYAM_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 37)
379 #define GADGET_ID_YAMYAM_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 38)
380 #define GADGET_ID_BALL_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 39)
381 #define GADGET_ID_BALL_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 40)
382 #define GADGET_ID_BALL_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 41)
383 #define GADGET_ID_ANDROID_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 42)
384 #define GADGET_ID_ANDROID_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 43)
385 #define GADGET_ID_ANDROID_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 44)
386 #define GADGET_ID_ENVELOPE_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 45)
387 #define GADGET_ID_ENVELOPE_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 46)
388 #define GADGET_ID_ENVELOPE_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 47)
389 #define GADGET_ID_ENVELOPE_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 48)
390 #define GADGET_ID_ENVELOPE_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 49)
391 #define GADGET_ID_ENVELOPE_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 50)
392 #define GADGET_ID_INVENTORY_SIZE_DOWN (GADGET_ID_COUNTER_FIRST + 51)
393 #define GADGET_ID_INVENTORY_SIZE_TEXT (GADGET_ID_COUNTER_FIRST + 52)
394 #define GADGET_ID_INVENTORY_SIZE_UP (GADGET_ID_COUNTER_FIRST + 53)
395 #define GADGET_ID_CUSTOM_SCORE_DOWN (GADGET_ID_COUNTER_FIRST + 54)
396 #define GADGET_ID_CUSTOM_SCORE_TEXT (GADGET_ID_COUNTER_FIRST + 55)
397 #define GADGET_ID_CUSTOM_SCORE_UP (GADGET_ID_COUNTER_FIRST + 56)
398 #define GADGET_ID_CUSTOM_GEMCOUNT_DOWN (GADGET_ID_COUNTER_FIRST + 57)
399 #define GADGET_ID_CUSTOM_GEMCOUNT_TEXT (GADGET_ID_COUNTER_FIRST + 58)
400 #define GADGET_ID_CUSTOM_GEMCOUNT_UP (GADGET_ID_COUNTER_FIRST + 59)
401 #define GADGET_ID_CUSTOM_VALUE_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 60)
402 #define GADGET_ID_CUSTOM_VALUE_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 61)
403 #define GADGET_ID_CUSTOM_VALUE_FIX_UP (GADGET_ID_COUNTER_FIRST + 62)
404 #define GADGET_ID_CUSTOM_VALUE_RND_DOWN (GADGET_ID_COUNTER_FIRST + 63)
405 #define GADGET_ID_CUSTOM_VALUE_RND_TEXT (GADGET_ID_COUNTER_FIRST + 64)
406 #define GADGET_ID_CUSTOM_VALUE_RND_UP (GADGET_ID_COUNTER_FIRST + 65)
407 #define GADGET_ID_PUSH_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 66)
408 #define GADGET_ID_PUSH_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 67)
409 #define GADGET_ID_PUSH_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 68)
410 #define GADGET_ID_PUSH_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 69)
411 #define GADGET_ID_PUSH_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 70)
412 #define GADGET_ID_PUSH_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 71)
413 #define GADGET_ID_DROP_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 72)
414 #define GADGET_ID_DROP_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 73)
415 #define GADGET_ID_DROP_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 74)
416 #define GADGET_ID_DROP_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 75)
417 #define GADGET_ID_DROP_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 76)
418 #define GADGET_ID_DROP_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 77)
419 #define GADGET_ID_MOVE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 78)
420 #define GADGET_ID_MOVE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 79)
421 #define GADGET_ID_MOVE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 80)
422 #define GADGET_ID_MOVE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 81)
423 #define GADGET_ID_MOVE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 82)
424 #define GADGET_ID_MOVE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 83)
425 #define GADGET_ID_EXPLOSION_DELAY_DOWN (GADGET_ID_COUNTER_FIRST + 84)
426 #define GADGET_ID_EXPLOSION_DELAY_TEXT (GADGET_ID_COUNTER_FIRST + 85)
427 #define GADGET_ID_EXPLOSION_DELAY_UP (GADGET_ID_COUNTER_FIRST + 86)
428 #define GADGET_ID_IGNITION_DELAY_DOWN (GADGET_ID_COUNTER_FIRST + 87)
429 #define GADGET_ID_IGNITION_DELAY_TEXT (GADGET_ID_COUNTER_FIRST + 88)
430 #define GADGET_ID_IGNITION_DELAY_UP (GADGET_ID_COUNTER_FIRST + 89)
431 #define GADGET_ID_CHANGE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 90)
432 #define GADGET_ID_CHANGE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 91)
433 #define GADGET_ID_CHANGE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 92)
434 #define GADGET_ID_CHANGE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 93)
435 #define GADGET_ID_CHANGE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 94)
436 #define GADGET_ID_CHANGE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 95)
437 #define GADGET_ID_CHANGE_CONT_RND_DOWN (GADGET_ID_COUNTER_FIRST + 96)
438 #define GADGET_ID_CHANGE_CONT_RND_TEXT (GADGET_ID_COUNTER_FIRST + 97)
439 #define GADGET_ID_CHANGE_CONT_RND_UP (GADGET_ID_COUNTER_FIRST + 98)
440 #define GADGET_ID_GROUP_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 99)
441 #define GADGET_ID_GROUP_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 100)
442 #define GADGET_ID_GROUP_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 101)
444 /* drawing area identifiers */
445 #define GADGET_ID_DRAWING_AREA_FIRST (GADGET_ID_COUNTER_FIRST + 102)
447 #define GADGET_ID_DRAWING_LEVEL (GADGET_ID_DRAWING_AREA_FIRST + 0)
448 #define GADGET_ID_YAMYAM_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 1)
449 #define GADGET_ID_YAMYAM_CONTENT_1 (GADGET_ID_DRAWING_AREA_FIRST + 2)
450 #define GADGET_ID_YAMYAM_CONTENT_2 (GADGET_ID_DRAWING_AREA_FIRST + 3)
451 #define GADGET_ID_YAMYAM_CONTENT_3 (GADGET_ID_DRAWING_AREA_FIRST + 4)
452 #define GADGET_ID_YAMYAM_CONTENT_4 (GADGET_ID_DRAWING_AREA_FIRST + 5)
453 #define GADGET_ID_YAMYAM_CONTENT_5 (GADGET_ID_DRAWING_AREA_FIRST + 6)
454 #define GADGET_ID_YAMYAM_CONTENT_6 (GADGET_ID_DRAWING_AREA_FIRST + 7)
455 #define GADGET_ID_YAMYAM_CONTENT_7 (GADGET_ID_DRAWING_AREA_FIRST + 8)
456 #define GADGET_ID_MAGIC_BALL_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 9)
457 #define GADGET_ID_MAGIC_BALL_CONTENT_1 (GADGET_ID_DRAWING_AREA_FIRST + 10)
458 #define GADGET_ID_MAGIC_BALL_CONTENT_2 (GADGET_ID_DRAWING_AREA_FIRST + 11)
459 #define GADGET_ID_MAGIC_BALL_CONTENT_3 (GADGET_ID_DRAWING_AREA_FIRST + 12)
460 #define GADGET_ID_MAGIC_BALL_CONTENT_4 (GADGET_ID_DRAWING_AREA_FIRST + 13)
461 #define GADGET_ID_MAGIC_BALL_CONTENT_5 (GADGET_ID_DRAWING_AREA_FIRST + 14)
462 #define GADGET_ID_MAGIC_BALL_CONTENT_6 (GADGET_ID_DRAWING_AREA_FIRST + 15)
463 #define GADGET_ID_MAGIC_BALL_CONTENT_7 (GADGET_ID_DRAWING_AREA_FIRST + 16)
464 #define GADGET_ID_ANDROID_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 17)
465 #define GADGET_ID_AMOEBA_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 18)
466 #define GADGET_ID_START_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 19)
467 #define GADGET_ID_ARTWORK_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 20)
468 #define GADGET_ID_EXPLOSION_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 21)
469 #define GADGET_ID_INVENTORY_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 22)
470 #define GADGET_ID_CUSTOM_GRAPHIC (GADGET_ID_DRAWING_AREA_FIRST + 23)
471 #define GADGET_ID_CUSTOM_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 24)
472 #define GADGET_ID_CUSTOM_MOVE_ENTER (GADGET_ID_DRAWING_AREA_FIRST + 25)
473 #define GADGET_ID_CUSTOM_MOVE_LEAVE (GADGET_ID_DRAWING_AREA_FIRST + 26)
474 #define GADGET_ID_CUSTOM_CHANGE_TARGET (GADGET_ID_DRAWING_AREA_FIRST + 27)
475 #define GADGET_ID_CUSTOM_CHANGE_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 28)
476 #define GADGET_ID_CUSTOM_CHANGE_TRIGGER (GADGET_ID_DRAWING_AREA_FIRST + 29)
477 #define GADGET_ID_CUSTOM_CHANGE_ACTION (GADGET_ID_DRAWING_AREA_FIRST + 30)
478 #define GADGET_ID_GROUP_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 31)
479 #define GADGET_ID_RANDOM_BACKGROUND (GADGET_ID_DRAWING_AREA_FIRST + 32)
481 /* text input identifiers */
482 #define GADGET_ID_TEXT_INPUT_FIRST (GADGET_ID_DRAWING_AREA_FIRST + 33)
484 #define GADGET_ID_LEVEL_NAME (GADGET_ID_TEXT_INPUT_FIRST + 0)
485 #define GADGET_ID_LEVEL_AUTHOR (GADGET_ID_TEXT_INPUT_FIRST + 1)
486 #define GADGET_ID_ELEMENT_NAME (GADGET_ID_TEXT_INPUT_FIRST + 2)
488 /* text area identifiers */
489 #define GADGET_ID_TEXT_AREA_FIRST (GADGET_ID_TEXT_INPUT_FIRST + 3)
491 #define GADGET_ID_ENVELOPE_INFO (GADGET_ID_TEXT_AREA_FIRST + 0)
493 /* selectbox identifiers */
494 #define GADGET_ID_SELECTBOX_FIRST (GADGET_ID_TEXT_AREA_FIRST + 1)
496 #define GADGET_ID_TIME_OR_STEPS (GADGET_ID_SELECTBOX_FIRST + 0)
497 #define GADGET_ID_GAME_ENGINE_TYPE (GADGET_ID_SELECTBOX_FIRST + 1)
498 #define GADGET_ID_WIND_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 2)
499 #define GADGET_ID_PLAYER_SPEED (GADGET_ID_SELECTBOX_FIRST + 3)
500 #define GADGET_ID_CUSTOM_WALK_TO_ACTION (GADGET_ID_SELECTBOX_FIRST + 4)
501 #define GADGET_ID_CUSTOM_EXPLOSION_TYPE (GADGET_ID_SELECTBOX_FIRST + 5)
502 #define GADGET_ID_CUSTOM_DEADLINESS (GADGET_ID_SELECTBOX_FIRST + 6)
503 #define GADGET_ID_CUSTOM_MOVE_PATTERN (GADGET_ID_SELECTBOX_FIRST + 7)
504 #define GADGET_ID_CUSTOM_MOVE_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 8)
505 #define GADGET_ID_CUSTOM_MOVE_STEPSIZE (GADGET_ID_SELECTBOX_FIRST + 9)
506 #define GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE (GADGET_ID_SELECTBOX_FIRST + 10)
507 #define GADGET_ID_CUSTOM_SMASH_TARGETS (GADGET_ID_SELECTBOX_FIRST + 11)
508 #define GADGET_ID_CUSTOM_SLIPPERY_TYPE (GADGET_ID_SELECTBOX_FIRST + 12)
509 #define GADGET_ID_CUSTOM_ACCESS_TYPE (GADGET_ID_SELECTBOX_FIRST + 13)
510 #define GADGET_ID_CUSTOM_ACCESS_LAYER (GADGET_ID_SELECTBOX_FIRST + 14)
511 #define GADGET_ID_CUSTOM_ACCESS_PROTECTED (GADGET_ID_SELECTBOX_FIRST + 15)
512 #define GADGET_ID_CUSTOM_ACCESS_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 16)
513 #define GADGET_ID_CHANGE_TIME_UNITS (GADGET_ID_SELECTBOX_FIRST + 17)
514 #define GADGET_ID_CHANGE_DIRECT_ACTION (GADGET_ID_SELECTBOX_FIRST + 18)
515 #define GADGET_ID_CHANGE_OTHER_ACTION (GADGET_ID_SELECTBOX_FIRST + 19)
516 #define GADGET_ID_CHANGE_SIDE (GADGET_ID_SELECTBOX_FIRST + 20)
517 #define GADGET_ID_CHANGE_PLAYER (GADGET_ID_SELECTBOX_FIRST + 21)
518 #define GADGET_ID_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 22)
519 #define GADGET_ID_CHANGE_REPLACE_WHEN (GADGET_ID_SELECTBOX_FIRST + 23)
520 #define GADGET_ID_ACTION_TYPE (GADGET_ID_SELECTBOX_FIRST + 24)
521 #define GADGET_ID_ACTION_MODE (GADGET_ID_SELECTBOX_FIRST + 25)
522 #define GADGET_ID_ACTION_ARG (GADGET_ID_SELECTBOX_FIRST + 26)
523 #define GADGET_ID_SELECT_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 27)
524 #define GADGET_ID_GROUP_CHOICE_MODE (GADGET_ID_SELECTBOX_FIRST + 28)
526 /* textbutton identifiers */
527 #define GADGET_ID_TEXTBUTTON_FIRST (GADGET_ID_SELECTBOX_FIRST + 29)
529 #define GADGET_ID_LEVELINFO_LEVEL (GADGET_ID_TEXTBUTTON_FIRST + 0)
530 #define GADGET_ID_LEVELINFO_EDITOR (GADGET_ID_TEXTBUTTON_FIRST + 1)
531 #define GADGET_ID_PROPERTIES_INFO (GADGET_ID_TEXTBUTTON_FIRST + 2)
532 #define GADGET_ID_PROPERTIES_CONFIG (GADGET_ID_TEXTBUTTON_FIRST + 3)
533 #define GADGET_ID_PROPERTIES_CONFIG_1 (GADGET_ID_TEXTBUTTON_FIRST + 4)
534 #define GADGET_ID_PROPERTIES_CONFIG_2 (GADGET_ID_TEXTBUTTON_FIRST + 5)
535 #define GADGET_ID_PROPERTIES_CHANGE (GADGET_ID_TEXTBUTTON_FIRST + 6)
536 #define GADGET_ID_SAVE_AS_TEMPLATE (GADGET_ID_TEXTBUTTON_FIRST + 7)
537 #define GADGET_ID_ADD_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 8)
538 #define GADGET_ID_DEL_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 9)
540 /* graphicbutton identifiers */
541 #define GADGET_ID_GRAPHICBUTTON_FIRST (GADGET_ID_TEXTBUTTON_FIRST + 10)
543 #define GADGET_ID_PREV_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 0)
544 #define GADGET_ID_NEXT_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 1)
545 #define GADGET_ID_COPY_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 2)
546 #define GADGET_ID_PASTE_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 3)
548 /* gadgets for scrolling of drawing area */
549 #define GADGET_ID_SCROLLING_FIRST (GADGET_ID_GRAPHICBUTTON_FIRST + 4)
551 #define GADGET_ID_SCROLL_UP (GADGET_ID_SCROLLING_FIRST + 0)
552 #define GADGET_ID_SCROLL_DOWN (GADGET_ID_SCROLLING_FIRST + 1)
553 #define GADGET_ID_SCROLL_LEFT (GADGET_ID_SCROLLING_FIRST + 2)
554 #define GADGET_ID_SCROLL_RIGHT (GADGET_ID_SCROLLING_FIRST + 3)
555 #define GADGET_ID_SCROLL_HORIZONTAL (GADGET_ID_SCROLLING_FIRST + 4)
556 #define GADGET_ID_SCROLL_VERTICAL (GADGET_ID_SCROLLING_FIRST + 5)
558 /* gadgets for scrolling element list */
559 #define GADGET_ID_SCROLLING_LIST_FIRST (GADGET_ID_SCROLLING_FIRST + 6)
561 #define GADGET_ID_SCROLL_LIST_UP (GADGET_ID_SCROLLING_LIST_FIRST + 0)
562 #define GADGET_ID_SCROLL_LIST_DOWN (GADGET_ID_SCROLLING_LIST_FIRST + 1)
563 #define GADGET_ID_SCROLL_LIST_VERTICAL (GADGET_ID_SCROLLING_LIST_FIRST + 2)
565 /* checkbuttons/radiobuttons for level/element properties */
566 #define GADGET_ID_CHECKBUTTON_FIRST (GADGET_ID_SCROLLING_LIST_FIRST + 3)
568 #define GADGET_ID_RANDOM_PERCENTAGE (GADGET_ID_CHECKBUTTON_FIRST + 0)
569 #define GADGET_ID_RANDOM_QUANTITY (GADGET_ID_CHECKBUTTON_FIRST + 1)
570 #define GADGET_ID_RANDOM_RESTRICTED (GADGET_ID_CHECKBUTTON_FIRST + 2)
571 #define GADGET_ID_STICK_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 3)
572 #define GADGET_ID_EM_SLIPPERY_GEMS (GADGET_ID_CHECKBUTTON_FIRST + 4)
573 #define GADGET_ID_EM_EXPLODES_BY_FIRE (GADGET_ID_CHECKBUTTON_FIRST + 5)
574 #define GADGET_ID_USE_SPRING_BUG (GADGET_ID_CHECKBUTTON_FIRST + 6)
575 #define GADGET_ID_USE_TIME_ORB_BUG (GADGET_ID_CHECKBUTTON_FIRST + 7)
576 #define GADGET_ID_RANDOM_BALL_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 8)
577 #define GADGET_ID_INITIAL_BALL_STATE (GADGET_ID_CHECKBUTTON_FIRST + 9)
578 #define GADGET_ID_GROW_INTO_DIGGABLE (GADGET_ID_CHECKBUTTON_FIRST + 10)
579 #define GADGET_ID_AUTO_EXIT_SOKOBAN (GADGET_ID_CHECKBUTTON_FIRST + 11)
580 #define GADGET_ID_CONTINUOUS_SNAPPING (GADGET_ID_CHECKBUTTON_FIRST + 12)
581 #define GADGET_ID_BLOCK_SNAP_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 13)
582 #define GADGET_ID_BLOCK_LAST_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 14)
583 #define GADGET_ID_SP_BLOCK_LAST_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 15)
584 #define GADGET_ID_INSTANT_RELOCATION (GADGET_ID_CHECKBUTTON_FIRST + 16)
585 #define GADGET_ID_SHIFTED_RELOCATION (GADGET_ID_CHECKBUTTON_FIRST + 17)
586 #define GADGET_ID_USE_START_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 18)
587 #define GADGET_ID_USE_ARTWORK_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 19)
588 #define GADGET_ID_USE_EXPLOSION_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 20)
589 #define GADGET_ID_INITIAL_GRAVITY (GADGET_ID_CHECKBUTTON_FIRST + 21)
590 #define GADGET_ID_USE_INITIAL_INVENTORY (GADGET_ID_CHECKBUTTON_FIRST + 22)
591 #define GADGET_ID_CAN_PASS_TO_WALKABLE (GADGET_ID_CHECKBUTTON_FIRST + 23)
592 #define GADGET_ID_CAN_FALL_INTO_ACID (GADGET_ID_CHECKBUTTON_FIRST + 24)
593 #define GADGET_ID_CAN_MOVE_INTO_ACID (GADGET_ID_CHECKBUTTON_FIRST + 25)
594 #define GADGET_ID_DONT_COLLIDE_WITH (GADGET_ID_CHECKBUTTON_FIRST + 26)
595 #define GADGET_ID_ENVELOPE_AUTOWRAP (GADGET_ID_CHECKBUTTON_FIRST + 27)
596 #define GADGET_ID_ENVELOPE_CENTERED (GADGET_ID_CHECKBUTTON_FIRST + 28)
597 #define GADGET_ID_CUSTOM_INDESTRUCTIBLE (GADGET_ID_CHECKBUTTON_FIRST + 29)
598 #define GADGET_ID_CUSTOM_CAN_EXPLODE (GADGET_ID_CHECKBUTTON_FIRST + 30)
599 #define GADGET_ID_CUSTOM_EXPLODE_FIRE (GADGET_ID_CHECKBUTTON_FIRST + 31)
600 #define GADGET_ID_CUSTOM_EXPLODE_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 32)
601 #define GADGET_ID_CUSTOM_EXPLODE_IMPACT (GADGET_ID_CHECKBUTTON_FIRST + 33)
602 #define GADGET_ID_CUSTOM_WALK_TO_OBJECT (GADGET_ID_CHECKBUTTON_FIRST + 34)
603 #define GADGET_ID_CUSTOM_DEADLY (GADGET_ID_CHECKBUTTON_FIRST + 35)
604 #define GADGET_ID_CUSTOM_CAN_MOVE (GADGET_ID_CHECKBUTTON_FIRST + 36)
605 #define GADGET_ID_CUSTOM_CAN_FALL (GADGET_ID_CHECKBUTTON_FIRST + 37)
606 #define GADGET_ID_CUSTOM_CAN_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 38)
607 #define GADGET_ID_CUSTOM_SLIPPERY (GADGET_ID_CHECKBUTTON_FIRST + 39)
608 #define GADGET_ID_CUSTOM_ACCESSIBLE (GADGET_ID_CHECKBUTTON_FIRST + 40)
609 #define GADGET_ID_CUSTOM_GRAV_REACHABLE (GADGET_ID_CHECKBUTTON_FIRST + 41)
610 #define GADGET_ID_CUSTOM_USE_LAST_VALUE (GADGET_ID_CHECKBUTTON_FIRST + 42)
611 #define GADGET_ID_CUSTOM_USE_GRAPHIC (GADGET_ID_CHECKBUTTON_FIRST + 43)
612 #define GADGET_ID_CUSTOM_USE_TEMPLATE (GADGET_ID_CHECKBUTTON_FIRST + 44)
613 #define GADGET_ID_CUSTOM_CAN_CHANGE (GADGET_ID_CHECKBUTTON_FIRST + 45)
614 #define GADGET_ID_CHANGE_USE_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 46)
615 #define GADGET_ID_CHANGE_USE_EXPLOSION (GADGET_ID_CHECKBUTTON_FIRST + 47)
616 #define GADGET_ID_CHANGE_ONLY_COMPLETE (GADGET_ID_CHECKBUTTON_FIRST + 48)
617 #define GADGET_ID_CHANGE_USE_RANDOM (GADGET_ID_CHECKBUTTON_FIRST + 49)
618 #define GADGET_ID_CHANGE_HAS_ACTION (GADGET_ID_CHECKBUTTON_FIRST + 50)
619 #define GADGET_ID_CHANGE_DELAY (GADGET_ID_CHECKBUTTON_FIRST + 51)
620 #define GADGET_ID_CHANGE_BY_DIRECT_ACT (GADGET_ID_CHECKBUTTON_FIRST + 52)
621 #define GADGET_ID_CHANGE_BY_OTHER_ACT (GADGET_ID_CHECKBUTTON_FIRST + 53)
623 /* gadgets for buttons in element list */
624 #define GADGET_ID_ELEMENTLIST_FIRST (GADGET_ID_CHECKBUTTON_FIRST + 54)
625 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
626 ED_NUM_ELEMENTLIST_BUTTONS - 1)
628 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
630 /* radio button numbers */
631 #define RADIO_NR_NONE 0
632 #define RADIO_NR_DRAWING_TOOLBOX 1
633 #define RADIO_NR_RANDOM_ELEMENTS 2
635 /* values for counter gadgets */
636 #define ED_COUNTER_ID_SELECT_LEVEL 0
637 #define ED_COUNTER_ID_LEVEL_XSIZE 1
638 #define ED_COUNTER_ID_LEVEL_YSIZE 2
639 #define ED_COUNTER_ID_LEVEL_GEMSLIMIT 3
640 #define ED_COUNTER_ID_LEVEL_TIMELIMIT 4
641 #define ED_COUNTER_ID_LEVEL_TIMESCORE 5
642 #define ED_COUNTER_ID_LEVEL_RANDOM_SEED 6
643 #define ED_COUNTER_ID_LEVEL_RANDOM 7
644 #define ED_COUNTER_ID_ELEMENT_VALUE1 8
645 #define ED_COUNTER_ID_ELEMENT_VALUE2 9
646 #define ED_COUNTER_ID_ELEMENT_VALUE3 10
647 #define ED_COUNTER_ID_ELEMENT_VALUE4 11
648 #define ED_COUNTER_ID_YAMYAM_CONTENT 12
649 #define ED_COUNTER_ID_BALL_CONTENT 13
650 #define ED_COUNTER_ID_ANDROID_CONTENT 14
651 #define ED_COUNTER_ID_ENVELOPE_XSIZE 15
652 #define ED_COUNTER_ID_ENVELOPE_YSIZE 16
653 #define ED_COUNTER_ID_INVENTORY_SIZE 17
654 #define ED_COUNTER_ID_CUSTOM_SCORE 18
655 #define ED_COUNTER_ID_CUSTOM_GEMCOUNT 19
656 #define ED_COUNTER_ID_CUSTOM_VALUE_FIX 20
657 #define ED_COUNTER_ID_CUSTOM_VALUE_RND 21
658 #define ED_COUNTER_ID_PUSH_DELAY_FIX 22
659 #define ED_COUNTER_ID_PUSH_DELAY_RND 23
660 #define ED_COUNTER_ID_DROP_DELAY_FIX 24
661 #define ED_COUNTER_ID_DROP_DELAY_RND 25
662 #define ED_COUNTER_ID_MOVE_DELAY_FIX 26
663 #define ED_COUNTER_ID_MOVE_DELAY_RND 27
664 #define ED_COUNTER_ID_EXPLOSION_DELAY 28
665 #define ED_COUNTER_ID_IGNITION_DELAY 29
666 #define ED_COUNTER_ID_GROUP_CONTENT 30
667 #define ED_COUNTER_ID_CHANGE_DELAY_FIX 31
668 #define ED_COUNTER_ID_CHANGE_DELAY_RND 32
669 #define ED_COUNTER_ID_CHANGE_CONT_RND 33
671 #define ED_NUM_COUNTERBUTTONS 34
673 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
674 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
675 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
676 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
678 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
679 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
680 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
681 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
682 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
683 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
685 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
686 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
688 /* values for scrollbutton gadgets */
689 #define ED_SCROLLBUTTON_ID_AREA_UP 0
690 #define ED_SCROLLBUTTON_ID_AREA_DOWN 1
691 #define ED_SCROLLBUTTON_ID_AREA_LEFT 2
692 #define ED_SCROLLBUTTON_ID_AREA_RIGHT 3
693 #define ED_SCROLLBUTTON_ID_LIST_UP 4
694 #define ED_SCROLLBUTTON_ID_LIST_DOWN 5
696 #define ED_NUM_SCROLLBUTTONS 6
698 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
699 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
701 /* values for scrollbar gadgets */
702 #define ED_SCROLLBAR_ID_AREA_HORIZONTAL 0
703 #define ED_SCROLLBAR_ID_AREA_VERTICAL 1
704 #define ED_SCROLLBAR_ID_LIST_VERTICAL 2
706 #define ED_NUM_SCROLLBARS 3
708 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
709 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
711 /* values for text input gadgets */
712 #define ED_TEXTINPUT_ID_LEVEL_NAME 0
713 #define ED_TEXTINPUT_ID_LEVEL_AUTHOR 1
714 #define ED_TEXTINPUT_ID_ELEMENT_NAME 2
716 #define ED_NUM_TEXTINPUT 3
718 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
719 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
721 /* values for text area gadgets */
722 #define ED_TEXTAREA_ID_ENVELOPE_INFO 0
724 #define ED_NUM_TEXTAREAS 1
726 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
727 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
729 /* values for selectbox gadgets */
730 #define ED_SELECTBOX_ID_TIME_OR_STEPS 0
731 #define ED_SELECTBOX_ID_GAME_ENGINE_TYPE 1
732 #define ED_SELECTBOX_ID_WIND_DIRECTION 2
733 #define ED_SELECTBOX_ID_PLAYER_SPEED 3
734 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE 4
735 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER 5
736 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED 6
737 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION 7
738 #define ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION 8
739 #define ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN 9
740 #define ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION 10
741 #define ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE 11
742 #define ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE 12
743 #define ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS 13
744 #define ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE 14
745 #define ED_SELECTBOX_ID_CUSTOM_DEADLINESS 15
746 #define ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE 16
747 #define ED_SELECTBOX_ID_CHANGE_TIME_UNITS 17
748 #define ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION 18
749 #define ED_SELECTBOX_ID_CHANGE_OTHER_ACTION 19
750 #define ED_SELECTBOX_ID_CHANGE_SIDE 20
751 #define ED_SELECTBOX_ID_CHANGE_PLAYER 21
752 #define ED_SELECTBOX_ID_CHANGE_PAGE 22
753 #define ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN 23
754 #define ED_SELECTBOX_ID_ACTION_TYPE 24
755 #define ED_SELECTBOX_ID_ACTION_MODE 25
756 #define ED_SELECTBOX_ID_ACTION_ARG 26
757 #define ED_SELECTBOX_ID_SELECT_CHANGE_PAGE 27
758 #define ED_SELECTBOX_ID_GROUP_CHOICE_MODE 28
760 #define ED_NUM_SELECTBOX 29
762 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
763 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_WIND_DIRECTION
765 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
766 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
767 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
768 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
769 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
770 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
772 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
773 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
775 /* values for textbutton gadgets */
776 #define ED_TEXTBUTTON_ID_LEVELINFO_LEVEL 0
777 #define ED_TEXTBUTTON_ID_LEVELINFO_EDITOR 1
778 #define ED_TEXTBUTTON_ID_PROPERTIES_INFO 2
779 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG 3
780 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1 4
781 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2 5
782 #define ED_TEXTBUTTON_ID_PROPERTIES_CHANGE 6
783 #define ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE 7
784 #define ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE 8
785 #define ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE 9
787 #define ED_NUM_TEXTBUTTONS 10
789 #define ED_TEXTBUTTON_ID_LEVELINFO_FIRST ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
790 #define ED_TEXTBUTTON_ID_LEVELINFO_LAST ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
792 #define ED_TEXTBUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
793 #define ED_TEXTBUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
795 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
796 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
798 /* values for graphicbutton gadgets */
799 #define ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE 0
800 #define ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE 1
801 #define ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE 2
802 #define ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE 3
804 #define ED_NUM_GRAPHICBUTTONS 4
806 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
807 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
809 /* values for checkbutton gadgets */
810 #define ED_CHECKBUTTON_ID_RANDOM_RESTRICTED 0
811 #define ED_CHECKBUTTON_ID_STICK_ELEMENT 1
812 #define ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS 2
813 #define ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE 3
814 #define ED_CHECKBUTTON_ID_USE_SPRING_BUG 4
815 #define ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG 5
816 #define ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT 6
817 #define ED_CHECKBUTTON_ID_INITIAL_BALL_STATE 7
818 #define ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE 8
819 #define ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN 9
820 #define ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING 10
821 #define ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD 11
822 #define ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD 12
823 #define ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD 13
824 #define ED_CHECKBUTTON_ID_INSTANT_RELOCATION 14
825 #define ED_CHECKBUTTON_ID_SHIFTED_RELOCATION 15
826 #define ED_CHECKBUTTON_ID_USE_START_ELEMENT 16
827 #define ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT 17
828 #define ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT 18
829 #define ED_CHECKBUTTON_ID_INITIAL_GRAVITY 19
830 #define ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY 20
831 #define ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE 21
832 #define ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID 22
833 #define ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID 23
834 #define ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH 24
835 #define ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP 25
836 #define ED_CHECKBUTTON_ID_ENVELOPE_CENTERED 26
837 #define ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC 27
838 #define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE 28
839 #define ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE 29
840 #define ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE 30
841 #define ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE 31
842 #define ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT 32
843 #define ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE 33
844 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE 34
845 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL 35
846 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH 36
847 #define ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY 37
848 #define ED_CHECKBUTTON_ID_CUSTOM_DEADLY 38
849 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE 39
850 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE 40
851 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH 41
852 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT 42
853 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE 43
854 #define ED_CHECKBUTTON_ID_CHANGE_DELAY 44
855 #define ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT 45
856 #define ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT 46
857 #define ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION 47
858 #define ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT 48
859 #define ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE 49
860 #define ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM 50
861 #define ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION 51
863 #define ED_NUM_CHECKBUTTONS 52
865 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
866 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
868 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
869 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
870 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
871 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
872 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
873 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
875 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
876 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
878 /* values for radiobutton gadgets */
879 #define ED_RADIOBUTTON_ID_PERCENTAGE 0
880 #define ED_RADIOBUTTON_ID_QUANTITY 1
882 #define ED_NUM_RADIOBUTTONS 2
884 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
885 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
887 /* values for drawing area gadgets */
888 #define ED_DRAWING_ID_DRAWING_LEVEL 0
889 #define ED_DRAWING_ID_YAMYAM_CONTENT_0 1
890 #define ED_DRAWING_ID_YAMYAM_CONTENT_1 2
891 #define ED_DRAWING_ID_YAMYAM_CONTENT_2 3
892 #define ED_DRAWING_ID_YAMYAM_CONTENT_3 4
893 #define ED_DRAWING_ID_YAMYAM_CONTENT_4 5
894 #define ED_DRAWING_ID_YAMYAM_CONTENT_5 6
895 #define ED_DRAWING_ID_YAMYAM_CONTENT_6 7
896 #define ED_DRAWING_ID_YAMYAM_CONTENT_7 8
897 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 9
898 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_1 10
899 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_2 11
900 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_3 12
901 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_4 13
902 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_5 14
903 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_6 15
904 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_7 16
905 #define ED_DRAWING_ID_ANDROID_CONTENT 17
906 #define ED_DRAWING_ID_AMOEBA_CONTENT 18
907 #define ED_DRAWING_ID_START_ELEMENT 19
908 #define ED_DRAWING_ID_ARTWORK_ELEMENT 20
909 #define ED_DRAWING_ID_EXPLOSION_ELEMENT 21
910 #define ED_DRAWING_ID_INVENTORY_CONTENT 22
911 #define ED_DRAWING_ID_CUSTOM_GRAPHIC 23
912 #define ED_DRAWING_ID_CUSTOM_CONTENT 24
913 #define ED_DRAWING_ID_CUSTOM_MOVE_ENTER 25
914 #define ED_DRAWING_ID_CUSTOM_MOVE_LEAVE 26
915 #define ED_DRAWING_ID_CUSTOM_CHANGE_TARGET 27
916 #define ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT 28
917 #define ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER 29
918 #define ED_DRAWING_ID_CUSTOM_CHANGE_ACTION 30
919 #define ED_DRAWING_ID_GROUP_CONTENT 31
920 #define ED_DRAWING_ID_RANDOM_BACKGROUND 32
922 #define ED_NUM_DRAWING_AREAS 33
926 -----------------------------------------------------------------------------
927 some internally used definitions
928 -----------------------------------------------------------------------------
931 /* values for CopyLevelToUndoBuffer() */
932 #define UNDO_IMMEDIATE 0
933 #define UNDO_ACCUMULATE 1
935 /* values for scrollbars */
936 #define ED_SCROLL_NO 0
937 #define ED_SCROLL_LEFT 1
938 #define ED_SCROLL_RIGHT 2
939 #define ED_SCROLL_UP 4
940 #define ED_SCROLL_DOWN 8
942 /* screens in the level editor */
943 #define ED_MODE_DRAWING 0
944 #define ED_MODE_INFO 1
945 #define ED_MODE_PROPERTIES 2
947 /* sub-screens in the global settings section */
948 #define ED_MODE_LEVELINFO_LEVEL ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
949 #define ED_MODE_LEVELINFO_EDITOR ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
951 /* sub-screens in the element properties section */
952 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
953 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
954 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
955 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
956 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
958 /* how many steps can be cancelled */
959 #define NUM_UNDO_STEPS (10 + 1)
961 /* values for elements with score for certain actions */
963 #define MAX_SCORE 999
965 /* values for elements with count for collecting */
966 #define MIN_COLLECT_COUNT 0
967 #define MAX_COLLECT_COUNT 999
969 /* values for random placement */
970 #define RANDOM_USE_PERCENTAGE 0
971 #define RANDOM_USE_QUANTITY 1
973 /* maximal size of level editor drawing area */
974 #define MAX_ED_FIELDX (2 * SCR_FIELDX)
975 #define MAX_ED_FIELDY (2 * SCR_FIELDY - 1)
979 -----------------------------------------------------------------------------
980 some internally used data structure definitions
981 -----------------------------------------------------------------------------
988 } control_info[ED_NUM_CTRL_BUTTONS] =
990 /* note: some additional characters are already reserved for "cheat mode"
991 shortcuts (":XYZ" style) -- for details, see "events.c" */
993 { 's', "draw single items" },
994 { 'd', "draw connected items" },
995 { 'l', "draw lines" },
996 { 'a', "draw arcs" },
997 { 'r', "draw outline rectangles" },
998 { 'R', "draw filled rectangles" },
999 { '\0', "wrap (rotate) level up" },
1000 { 't', "enter text elements" },
1001 { 'f', "flood fill" },
1002 { '\0', "wrap (rotate) level left" },
1003 { '?', "properties of drawing element" },
1004 { '\0', "wrap (rotate) level right" },
1005 { '\0', "random element placement" },
1006 { 'b', "grab brush" },
1007 { '\0', "wrap (rotate) level down" },
1008 { ',', "pick drawing element" },
1010 { 'U', "undo last operation" },
1011 { 'I', "properties of level" },
1012 { 'S', "save level" },
1013 { 'C', "clear level" },
1014 { 'T', "test level" },
1015 { 'E', "exit level editor" },
1017 { '\0', "copy settings from other element" },
1018 { '\0', "copy settings to other element" },
1019 { '\0', "exchange element with other element" },
1021 { '\0', "copy settings from this element" },
1022 { '\0', "paste settings to this element" },
1025 static int random_placement_value = 10;
1026 static int random_placement_method = RANDOM_USE_QUANTITY;
1027 static int random_placement_background_element = EL_SAND;
1028 static boolean random_placement_background_restricted = FALSE;
1029 static boolean stick_element_properties_window = FALSE;
1030 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1031 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1032 static struct ElementChangeInfo custom_element_change;
1033 static struct ElementGroupInfo group_element_info;
1034 static struct ElementInfo custom_element;
1039 int min_value, max_value;
1040 int gadget_id_down, gadget_id_up;
1042 int gadget_id_align;
1044 char *text_above, *text_left, *text_right;
1045 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1047 /* ---------- current level number --------------------------------------- */
1050 DX + 5 - SX, DY + 3 - SY,
1052 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1053 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1058 /* ---------- level and editor settings ---------------------------------- */
1061 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1062 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1063 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1064 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1066 "playfield size:", NULL, "width",
1069 -1, ED_LEVEL_SETTINGS_YPOS(4),
1070 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1071 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1072 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1074 NULL, " ", "height",
1077 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1079 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1080 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1082 NULL, "number of gems to collect:", NULL
1085 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
1087 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1088 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1090 "time or step limit to solve level:", NULL, NULL
1093 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(9),
1095 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1096 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1097 &level.score[SC_TIME_BONUS],
1098 "score for each second/step left:", NULL, NULL
1101 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
1103 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1104 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1106 NULL, "random seed:", "(0 => random)"
1109 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1111 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1112 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1113 &random_placement_value,
1114 "random element placement:", NULL, "in"
1117 /* ---------- element settings: configure (various elements) ------------- */
1120 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1121 MIN_SCORE, MAX_SCORE,
1122 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1123 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1124 NULL, /* will be set when used */
1128 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1129 MIN_SCORE, MAX_SCORE,
1130 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1131 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1132 NULL, /* will be set when used */
1136 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1137 MIN_SCORE, MAX_SCORE,
1138 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1139 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1140 NULL, /* will be set when used */
1144 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1145 MIN_SCORE, MAX_SCORE,
1146 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1147 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1148 NULL, /* will be set when used */
1152 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1153 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1154 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1155 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1156 &level.num_yamyam_contents,
1157 NULL, NULL, "number of content areas"
1160 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1161 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1162 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1163 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1164 &level.num_ball_contents,
1165 NULL, NULL, "number of content areas"
1168 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1169 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1170 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1171 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1172 &level.num_android_clone_elements,
1173 NULL, NULL, "number of clonable elements"
1176 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1177 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1178 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1179 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1180 NULL, /* will be set when used */
1181 NULL, NULL, "width",
1184 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1185 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1186 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1187 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1188 NULL, /* will be set when used */
1189 NULL, " ", "height",
1192 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1193 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1194 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1195 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1196 &level.initial_inventory_size[0],
1197 NULL, NULL, "number of inventory elements"
1200 /* ---------- element settings: configure 1 (custom elements) ------------ */
1203 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1204 MIN_SCORE, MAX_SCORE,
1205 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1206 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1207 &custom_element.collect_score_initial,
1208 NULL, "CE score", " "
1211 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1212 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1213 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1214 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1215 &custom_element.collect_count_initial,
1216 NULL, "CE count", NULL
1219 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
1221 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1222 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1223 &custom_element.ce_value_fixed_initial,
1224 NULL, "CE value", NULL
1227 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
1229 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1230 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1231 &custom_element.ce_value_random_initial,
1232 NULL, "+random", NULL
1235 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1237 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1238 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1239 &custom_element.push_delay_fixed,
1240 NULL, "push delay", NULL
1243 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1245 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1246 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1247 &custom_element.push_delay_random,
1248 NULL, "+random", NULL
1251 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
1253 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1254 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1255 &custom_element.drop_delay_fixed,
1256 NULL, "drop delay", NULL
1259 -1, ED_ELEMENT_SETTINGS_YPOS(8),
1261 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1262 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1263 &custom_element.drop_delay_random,
1264 NULL, "+random", NULL
1267 /* ---------- element settings: configure 2 (custom elements) ------------ */
1270 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1272 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1273 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1274 &custom_element.move_delay_fixed,
1275 NULL, "move delay", NULL
1278 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1280 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1281 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1282 &custom_element.move_delay_random,
1283 NULL, "+random", NULL
1286 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
1288 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1289 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1290 &custom_element.explosion_delay,
1291 NULL, "explosion delay", NULL
1294 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1296 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1297 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1298 &custom_element.ignition_delay,
1299 NULL, "ignition delay", "(by fire)"
1302 /* ---------- element settings: configure (group elements) --------------- */
1305 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
1306 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1307 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1308 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1309 &group_element_info.num_elements,
1310 NULL, NULL, "number of elements in group"
1313 /* ---------- element settings: advanced (custom elements) --------------- */
1316 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1318 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1319 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1320 &custom_element_change.delay_fixed,
1321 NULL, "CE delay", NULL,
1324 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1326 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1327 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1328 &custom_element_change.delay_random,
1329 NULL, "+random", NULL
1332 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1334 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1335 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1336 &custom_element_change.random_percentage,
1337 NULL, "use random replace:", "%"
1347 char *text_above, *infotext;
1348 } textinput_info[ED_NUM_TEXTINPUT] =
1351 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1352 GADGET_ID_LEVEL_NAME,
1358 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1359 GADGET_ID_LEVEL_AUTHOR,
1360 MAX_LEVEL_AUTHOR_LEN,
1365 5 * MINI_TILEX - 2, 5 * MINI_TILEY - ED_BORDER_SIZE + 1,
1366 GADGET_ID_ELEMENT_NAME,
1367 MAX_ELEMENT_NAME_LEN - 2, /* currently 2 chars less editable */
1368 custom_element.description,
1369 NULL, "Element name"
1379 char *text_above, *infotext;
1380 } textarea_info[ED_NUM_TEXTAREAS] =
1383 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1384 GADGET_ID_ENVELOPE_INFO,
1385 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1387 "Envelope Content:", "Envelope Content"
1391 static struct ValueTextInfo options_time_or_steps[] =
1399 static struct ValueTextInfo options_game_engine_type[] =
1401 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1402 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1403 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1408 static struct ValueTextInfo options_wind_direction[] =
1410 { MV_START_NONE, "none" },
1411 { MV_START_LEFT, "left" },
1412 { MV_START_RIGHT, "right" },
1413 { MV_START_UP, "up" },
1414 { MV_START_DOWN, "down" },
1419 static struct ValueTextInfo options_player_speed[] =
1426 { 16, "very fast" },
1427 { 32, "ultrafast" },
1432 static struct ValueTextInfo options_access_type[] =
1434 { EP_WALKABLE, "walkable" },
1435 { EP_PASSABLE, "passable" },
1440 static struct ValueTextInfo options_access_layer[] =
1442 { EP_ACCESSIBLE_OVER, "over" },
1443 { EP_ACCESSIBLE_INSIDE, "inside" },
1444 { EP_ACCESSIBLE_UNDER, "under" },
1449 static struct ValueTextInfo options_access_protected[] =
1451 { 0, "unprotected" },
1457 static struct ValueTextInfo options_access_direction[] =
1459 { MV_NO_DIRECTION, "no direction" },
1460 { MV_LEFT, "left" },
1461 { MV_RIGHT, "right" },
1463 { MV_DOWN, "down" },
1464 { MV_LEFT | MV_UP, "left + up" },
1465 { MV_LEFT | MV_DOWN, "left + down" },
1466 { MV_RIGHT | MV_UP, "right + up" },
1467 { MV_RIGHT | MV_DOWN, "right + down" },
1468 { MV_HORIZONTAL, "horizontal" },
1469 { MV_VERTICAL, "vertical" },
1470 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1471 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1472 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1473 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1474 { MV_ALL_DIRECTIONS, "all directions" },
1479 static struct ValueTextInfo options_walk_to_action[] =
1481 { EP_DIGGABLE, "diggable" },
1482 { EP_COLLECTIBLE_ONLY, "collectible" },
1483 { EP_DROPPABLE, "collectible & droppable" },
1484 { EP_THROWABLE, "collectible & throwable" },
1485 { EP_PUSHABLE, "pushable" },
1490 static struct ValueTextInfo options_move_pattern[] =
1492 { MV_LEFT, "left" },
1493 { MV_RIGHT, "right" },
1495 { MV_DOWN, "down" },
1496 { MV_HORIZONTAL, "horizontal" },
1497 { MV_VERTICAL, "vertical" },
1498 { MV_ALL_DIRECTIONS, "all directions" },
1499 { MV_WIND_DIRECTION, "wind direction" },
1500 { MV_TOWARDS_PLAYER, "towards player" },
1501 { MV_AWAY_FROM_PLAYER, "away from player" },
1502 { MV_ALONG_LEFT_SIDE, "along left side" },
1503 { MV_ALONG_RIGHT_SIDE, "along right side" },
1504 { MV_TURNING_LEFT, "turning left" },
1505 { MV_TURNING_RIGHT, "turning right" },
1506 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1507 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1508 { MV_TURNING_RANDOM, "turning random" },
1509 { MV_MAZE_RUNNER, "maze runner style" },
1510 { MV_MAZE_HUNTER, "maze hunter style" },
1511 { MV_WHEN_PUSHED, "when pushed" },
1512 { MV_WHEN_DROPPED, "when dropped/thrown" },
1517 static struct ValueTextInfo options_move_direction[] =
1519 { MV_START_AUTOMATIC, "automatic" },
1520 { MV_START_LEFT, "left" },
1521 { MV_START_RIGHT, "right" },
1522 { MV_START_UP, "up" },
1523 { MV_START_DOWN, "down" },
1524 { MV_START_RANDOM, "random" },
1525 { MV_START_PREVIOUS, "previous" },
1530 static struct ValueTextInfo options_move_stepsize[] =
1532 { 0, "not moving" },
1537 { 16, "very fast" },
1538 { 32, "even faster" },
1543 static struct ValueTextInfo options_move_leave_type[] =
1545 { LEAVE_TYPE_UNLIMITED, "leave behind" },
1546 { LEAVE_TYPE_LIMITED, "change it to" },
1551 static struct ValueTextInfo options_smash_targets[] =
1553 { EP_CAN_SMASH_PLAYER, "player" },
1555 { EP_CAN_SMASH_ENEMIES, "enemies" },
1557 { EP_CAN_SMASH_EVERYTHING, "everything" },
1562 static struct ValueTextInfo options_slippery_type[] =
1564 { SLIPPERY_ANY_RANDOM, "random" },
1565 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
1566 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
1567 { SLIPPERY_ONLY_LEFT, "only left" },
1568 { SLIPPERY_ONLY_RIGHT, "only right" },
1573 static struct ValueTextInfo options_deadliness[] =
1575 { EP_DONT_RUN_INTO, "running into" },
1576 { EP_DONT_COLLIDE_WITH, "colliding with" },
1577 { EP_DONT_GET_HIT_BY, "getting hit by" },
1578 { EP_DONT_TOUCH, "touching" },
1583 static struct ValueTextInfo options_explosion_type[] =
1585 { EXPLODES_3X3, "3x3" },
1586 { EXPLODES_CROSS, "3+3" },
1587 { EXPLODES_1X1, "1x1" },
1592 static struct ValueTextInfo options_time_units[] =
1595 { FRAMES_PER_SECOND, "seconds" },
1600 static struct ValueTextInfo options_change_direct_action[] =
1602 { CE_TOUCHED_BY_PLAYER, "touched by player" },
1603 { CE_PRESSED_BY_PLAYER, "pressed by player" },
1604 { CE_SWITCHED_BY_PLAYER, "switched by player" },
1605 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
1606 { CE_PUSHED_BY_PLAYER, "pushed by player" },
1607 { CE_ENTERED_BY_PLAYER, "entered by player" },
1608 { CE_LEFT_BY_PLAYER, "left by player" },
1609 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
1610 { CE_SWITCHED, "switched" },
1611 { CE_HITTING_SOMETHING, "hitting something" },
1612 { CE_HIT_BY_SOMETHING, "hit by something" },
1614 { CE_BLOCKED, "blocked" },
1616 { CE_IMPACT, "impact (on something)" },
1617 { CE_SMASHED, "smashed (from above)" },
1619 { CE_VALUE_CHANGES, "CE value changes" },
1620 { CE_SCORE_CHANGES, "CE score changes" },
1622 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
1623 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
1628 static struct ValueTextInfo options_change_other_action[] =
1630 { CE_PLAYER_TOUCHES_X, "player touches" },
1631 { CE_PLAYER_PRESSES_X, "player presses" },
1632 { CE_PLAYER_SWITCHES_X, "player switches" },
1633 { CE_PLAYER_SNAPS_X, "player snaps" },
1634 { CE_PLAYER_PUSHES_X, "player pushes" },
1635 { CE_PLAYER_ENTERS_X, "player enters" },
1636 { CE_PLAYER_LEAVES_X, "player leaves" },
1637 { CE_PLAYER_DIGS_X, "player digs" },
1638 { CE_PLAYER_COLLECTS_X, "player collects" },
1639 { CE_PLAYER_DROPS_X, "player drops/throws" },
1640 { CE_TOUCHING_X, "touching" },
1641 { CE_HITTING_X, "hitting" },
1642 { CE_DIGGING_X, "digging" },
1643 { CE_HIT_BY_X, "hit by" },
1644 { CE_SWITCH_OF_X, "switch of" },
1645 { CE_CHANGE_OF_X, "change by page of" },
1646 { CE_EXPLOSION_OF_X, "explosion of" },
1647 { CE_MOVE_OF_X, "move of" },
1648 { CE_CREATION_OF_X, "creation of" },
1649 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
1650 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
1651 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
1652 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
1657 static struct ValueTextInfo options_change_trigger_side[] =
1659 { CH_SIDE_LEFT, "left" },
1660 { CH_SIDE_RIGHT, "right" },
1661 { CH_SIDE_TOP, "top" },
1662 { CH_SIDE_BOTTOM, "bottom" },
1663 { CH_SIDE_LEFT_RIGHT, "left/right" },
1664 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
1665 { CH_SIDE_ANY, "any" },
1670 static struct ValueTextInfo options_change_trigger_player[] =
1672 { CH_PLAYER_1, "1" },
1673 { CH_PLAYER_2, "2" },
1674 { CH_PLAYER_3, "3" },
1675 { CH_PLAYER_4, "4" },
1676 { CH_PLAYER_ANY, "any" },
1681 static struct ValueTextInfo options_change_trigger_page[] =
1693 { (1 << 10), "11" },
1694 { (1 << 11), "12" },
1695 { (1 << 12), "13" },
1696 { (1 << 13), "14" },
1697 { (1 << 14), "15" },
1698 { (1 << 15), "16" },
1699 { (1 << 16), "17" },
1700 { (1 << 17), "18" },
1701 { (1 << 18), "19" },
1702 { (1 << 19), "20" },
1703 { (1 << 20), "21" },
1704 { (1 << 21), "22" },
1705 { (1 << 22), "23" },
1706 { (1 << 23), "24" },
1707 { (1 << 24), "25" },
1708 { (1 << 25), "26" },
1709 { (1 << 26), "27" },
1710 { (1 << 27), "28" },
1711 { (1 << 28), "29" },
1712 { (1 << 29), "30" },
1713 { (1 << 30), "31" },
1714 { (1 << 31), "32" },
1715 { CH_PAGE_ANY, "any" },
1720 static struct ValueTextInfo options_change_replace_when[] =
1722 { CP_WHEN_EMPTY, "empty" },
1723 { CP_WHEN_WALKABLE, "walkable" },
1724 { CP_WHEN_DIGGABLE, "diggable" },
1725 { CP_WHEN_COLLECTIBLE, "collectible" },
1726 { CP_WHEN_REMOVABLE, "removable" },
1727 { CP_WHEN_DESTRUCTIBLE, "destructible" },
1732 static struct ValueTextInfo options_action_type[] =
1734 { CA_NO_ACTION, "no action" },
1735 { CA_UNDEFINED, " " },
1736 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
1737 { CA_RESTART_LEVEL, "restart level" },
1738 { CA_SHOW_ENVELOPE, "show envelope" },
1739 { CA_SET_LEVEL_TIME, "set time" },
1740 { CA_SET_LEVEL_SCORE, "set score" },
1741 { CA_SET_LEVEL_GEMS, "set gems" },
1742 { CA_SET_LEVEL_WIND, "set wind dir." },
1743 { CA_SET_LEVEL_RANDOM_SEED, "set rand. seed" },
1744 { CA_UNDEFINED, " " },
1745 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
1746 { CA_MOVE_PLAYER, "move player" },
1747 { CA_EXIT_PLAYER, "exit player" },
1748 { CA_KILL_PLAYER, "kill player" },
1749 { CA_SET_PLAYER_KEYS, "set keys" },
1750 { CA_SET_PLAYER_SPEED, "set speed" },
1751 { CA_SET_PLAYER_SHIELD, "set shield" },
1752 { CA_SET_PLAYER_GRAVITY, "set gravity" },
1753 { CA_SET_PLAYER_ARTWORK, "set artwork" },
1754 { CA_SET_PLAYER_INVENTORY, "set inventory" },
1755 { CA_UNDEFINED, " " },
1756 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
1757 { CA_SET_CE_VALUE, "set CE value" },
1758 { CA_SET_CE_SCORE, "set CE score" },
1759 { CA_SET_CE_ARTWORK, "set CE artwork" },
1760 { CA_UNDEFINED, " " },
1761 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
1762 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
1767 static struct ValueTextInfo options_action_mode_none[] =
1769 { CA_MODE_UNDEFINED, " " },
1774 static struct ValueTextInfo options_action_mode_assign[] =
1776 { CA_MODE_SET, "=" },
1781 static struct ValueTextInfo options_action_mode_add_remove[] =
1783 { CA_MODE_ADD, "+" },
1784 { CA_MODE_SUBTRACT, "-" },
1789 static struct ValueTextInfo options_action_mode_calculate[] =
1791 { CA_MODE_SET, "=" },
1792 { CA_MODE_ADD, "+" },
1793 { CA_MODE_SUBTRACT, "-" },
1794 { CA_MODE_MULTIPLY, "*" },
1795 { CA_MODE_DIVIDE, "/" },
1796 { CA_MODE_MODULO, "%" },
1801 static struct ValueTextInfo options_action_arg_none[] =
1803 { CA_ARG_UNDEFINED, " " },
1808 static struct ValueTextInfo options_action_arg_player[] =
1810 { CA_ARG_PLAYER_HEADLINE, "[player]" },
1811 { CA_ARG_PLAYER_1, "1" },
1812 { CA_ARG_PLAYER_2, "2" },
1813 { CA_ARG_PLAYER_3, "3" },
1814 { CA_ARG_PLAYER_4, "4" },
1815 { CA_ARG_PLAYER_ANY, "any" },
1816 { CA_ARG_PLAYER_TRIGGER, "trigger" },
1817 { CA_ARG_PLAYER_ACTION, "action ->" },
1822 static struct ValueTextInfo options_action_arg_number[] =
1824 { CA_ARG_NUMBER_HEADLINE, "[number]" },
1831 { CA_ARG_10, "10" },
1832 { CA_ARG_100, "100" },
1833 { CA_ARG_1000, "1000" },
1834 { CA_ARG_UNDEFINED, " " },
1835 { CA_ARG_NUMBER_MIN, "min" },
1836 { CA_ARG_NUMBER_MAX, "max" },
1837 { CA_ARG_UNDEFINED, " " },
1838 { CA_ARG_NUMBER_RESET, "reset" },
1839 { CA_ARG_UNDEFINED, " " },
1840 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
1841 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
1842 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
1843 { CA_ARG_UNDEFINED, " " },
1844 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
1845 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
1846 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
1847 { CA_ARG_UNDEFINED, " " },
1848 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
1849 { CA_ARG_ELEMENT_CV_TARGET, "target" },
1850 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
1851 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
1852 { CA_ARG_UNDEFINED, " " },
1853 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
1854 { CA_ARG_ELEMENT_CS_TARGET, "target" },
1855 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
1856 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
1861 static struct ValueTextInfo options_action_arg_value[] =
1863 { CA_ARG_NUMBER_HEADLINE, "[number]" },
1870 { CA_ARG_10, "10" },
1871 { CA_ARG_100, "100" },
1872 { CA_ARG_1000, "1000" },
1873 { CA_ARG_UNDEFINED, " " },
1874 { CA_ARG_NUMBER_MIN, "min" },
1875 { CA_ARG_NUMBER_MAX, "max" },
1876 { CA_ARG_UNDEFINED, " " },
1877 { CA_ARG_NUMBER_RESET, "reset" },
1878 { CA_ARG_UNDEFINED, " " },
1879 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
1880 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
1881 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
1882 { CA_ARG_UNDEFINED, " " },
1883 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
1884 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
1885 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
1886 { CA_ARG_UNDEFINED, " " },
1887 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
1888 { CA_ARG_ELEMENT_CV_TARGET, "target" },
1889 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
1890 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
1891 { CA_ARG_UNDEFINED, " " },
1892 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
1893 { CA_ARG_ELEMENT_CS_TARGET, "target" },
1894 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
1895 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
1896 { CA_ARG_UNDEFINED, " " },
1897 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
1898 { CA_ARG_ELEMENT_NR_TARGET, "target" },
1899 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
1900 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
1905 static struct ValueTextInfo options_action_arg_envelope[] =
1907 { CA_ARG_NUMBER_HEADLINE, "[number]" },
1912 { CA_ARG_UNDEFINED, " " },
1913 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
1914 { CA_ARG_ELEMENT_TARGET, "target" },
1915 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
1916 { CA_ARG_ELEMENT_ACTION, "action ->" },
1921 static struct ValueTextInfo options_action_arg_key[] =
1923 { CA_ARG_NUMBER_HEADLINE, "[number]" },
1932 { CA_ARG_UNDEFINED, " " },
1933 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
1934 { CA_ARG_ELEMENT_TARGET, "target" },
1935 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
1936 { CA_ARG_ELEMENT_ACTION, "action ->" },
1941 static struct ValueTextInfo options_action_arg_speed[] =
1943 { CA_ARG_SPEED_HEADLINE, "[speed]" },
1944 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
1945 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
1946 { CA_ARG_SPEED_SLOW, "slow" },
1947 { CA_ARG_SPEED_NORMAL, "normal" },
1948 { CA_ARG_SPEED_FAST, "fast" },
1949 { CA_ARG_SPEED_VERY_FAST, "very fast" },
1950 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
1951 { CA_ARG_UNDEFINED, " " },
1952 { CA_ARG_SPEED_SLOWER, "slower" },
1953 { CA_ARG_SPEED_FASTER, "faster" },
1954 { CA_ARG_UNDEFINED, " " },
1955 { CA_ARG_SPEED_RESET, "reset" },
1960 static struct ValueTextInfo options_action_arg_shield[] =
1962 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
1963 { CA_ARG_SHIELD_OFF, "off" },
1964 { CA_ARG_SHIELD_NORMAL, "normal" },
1965 { CA_ARG_SHIELD_DEADLY, "deadly" },
1970 static struct ValueTextInfo options_action_arg_artwork[] =
1972 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
1973 { CA_ARG_ELEMENT_TARGET, "target" },
1974 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
1975 { CA_ARG_ELEMENT_ACTION, "action ->" },
1976 { CA_ARG_UNDEFINED, " " },
1977 { CA_ARG_ELEMENT_RESET, "reset" },
1982 static struct ValueTextInfo options_action_arg_gravity[] =
1984 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
1985 { CA_ARG_GRAVITY_ON, "on" },
1986 { CA_ARG_GRAVITY_OFF, "off" },
1987 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
1992 static struct ValueTextInfo options_action_arg_direction[] =
1994 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
1995 { CA_ARG_DIRECTION_NONE, "none" },
1996 { CA_ARG_DIRECTION_LEFT, "left" },
1997 { CA_ARG_DIRECTION_RIGHT, "right" },
1998 { CA_ARG_DIRECTION_UP, "up" },
1999 { CA_ARG_DIRECTION_DOWN, "down" },
2000 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2001 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2006 static struct ValueTextInfo options_action_arg_scan_mode[] =
2008 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2009 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2010 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2015 static struct ValueTextInfo options_action_arg_inventory[] =
2017 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2018 { CA_ARG_ELEMENT_TARGET, "+ target" },
2019 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2020 { CA_ARG_ELEMENT_ACTION, "+ action" },
2021 { CA_ARG_UNDEFINED, " " },
2022 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2023 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2024 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2025 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2026 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2027 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2028 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2029 { CA_ARG_UNDEFINED, " " },
2030 { CA_ARG_INVENTORY_RESET, "reset" },
2035 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2036 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2041 static struct ValueTextInfo options_group_choice_mode[] =
2043 { ANIM_RANDOM, "random" },
2044 { ANIM_LOOP, "loop" },
2045 { ANIM_LINEAR, "linear" },
2046 { ANIM_PINGPONG, "pingpong" },
2047 { ANIM_PINGPONG2, "pingpong 2" },
2052 static struct ValueTextInfo *action_arg_modes[] =
2054 options_action_mode_none,
2055 options_action_mode_assign,
2056 options_action_mode_add_remove,
2057 options_action_mode_calculate,
2064 struct ValueTextInfo *options;
2066 action_arg_options[] =
2068 { CA_NO_ACTION, 0, options_action_arg_none, },
2069 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2070 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2071 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2072 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2073 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2074 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2075 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2076 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2077 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2078 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2079 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2080 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2081 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2082 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2083 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2084 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2085 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2086 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2087 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2088 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2097 int gadget_id_align;
2098 int size; /* char size of selectbox or '-1' (dynamically determined) */
2099 struct ValueTextInfo *options;
2101 char *text_left, *text_right, *infotext;
2102 } selectbox_info[ED_NUM_SELECTBOX] =
2104 /* ---------- level and editor settings ---------------------------------- */
2107 -1, ED_LEVEL_SETTINGS_YPOS(7),
2108 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2110 options_time_or_steps,
2111 &level.use_step_counter,
2112 NULL, "(0 => no limit)", "time or step limit"
2115 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
2116 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2118 options_game_engine_type,
2119 &level.game_engine_type,
2120 "game engine:", NULL, "game engine"
2123 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2124 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2126 options_wind_direction,
2127 &level.wind_direction_initial,
2128 "initial wind direction:", NULL, "initial wind direction"
2131 /* ---------- element settings: configure (several elements) ------------- */
2134 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
2135 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2137 options_player_speed,
2138 &level.initial_player_stepsize[0],
2139 "initial player speed:", NULL, "initial player speed"
2142 /* ---------- element settings: configure 1 (custom elements) ------------ */
2145 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2146 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2148 options_access_type,
2149 &custom_element.access_type,
2150 NULL, NULL, "type of access to this field"
2153 -1, ED_ELEMENT_SETTINGS_YPOS(3),
2154 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2156 options_access_layer,
2157 &custom_element.access_layer,
2158 NULL, NULL, "layer of access for this field"
2161 -1, ED_ELEMENT_SETTINGS_YPOS(3),
2162 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2164 options_access_protected,
2165 &custom_element.access_protected,
2166 NULL, NULL, "protected access for this field"
2169 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2170 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2172 options_access_direction,
2173 &custom_element.access_direction,
2174 "from", NULL, "access direction for this field"
2177 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
2178 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2180 options_walk_to_action,
2181 &custom_element.walk_to_action,
2182 NULL, NULL, "diggable/collectible/pushable"
2185 /* ---------- element settings: configure 2 (custom elements) ------------ */
2188 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2189 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2191 options_move_pattern,
2192 &custom_element.move_pattern,
2193 "can move", NULL, "element move pattern"
2196 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2197 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2199 options_move_direction,
2200 &custom_element.move_direction_initial,
2201 "starts moving", NULL, "initial element move direction"
2204 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2205 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2207 options_move_stepsize,
2208 &custom_element.move_stepsize,
2209 "move/fall speed", NULL, "speed of element movement"
2212 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2213 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2215 options_move_leave_type,
2216 &custom_element.move_leave_type,
2217 "can dig: can", ":", "leave behind or change element"
2220 -1, ED_ELEMENT_SETTINGS_YPOS(7),
2221 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2223 options_smash_targets,
2224 &custom_element.smash_targets,
2225 "can smash", NULL, "elements that can be smashed"
2228 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
2229 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2231 options_slippery_type,
2232 &custom_element.slippery_type,
2233 "slippery", NULL, "where other elements fall down"
2236 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2237 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2240 &custom_element.deadliness,
2241 "deadly when", NULL, "deadliness of element"
2244 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2245 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2247 options_explosion_type,
2248 &custom_element.explosion_type,
2249 "can explode", NULL, "explosion type"
2252 /* ---------- element settings: advanced (custom elements) --------------- */
2255 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2256 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2259 &custom_element_change.delay_frames,
2260 "delay time given in", NULL, "delay time units for change"
2263 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2264 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2266 options_change_direct_action,
2267 &custom_element_change.direct_action,
2268 NULL, NULL, "type of direct action"
2271 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2272 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2274 options_change_other_action,
2275 &custom_element_change.other_action,
2276 NULL, "element:", "type of other element action"
2279 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2280 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2282 options_change_trigger_side,
2283 &custom_element_change.trigger_side,
2284 "at", "side", "element side triggering change"
2287 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2288 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2290 options_change_trigger_player,
2291 &custom_element_change.trigger_player,
2292 "player:", " ", "player that causes change"
2295 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2296 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2298 options_change_trigger_page,
2299 &custom_element_change.trigger_page,
2300 "page:", NULL, "change page that causes change"
2303 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2304 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2306 options_change_replace_when,
2307 &custom_element_change.replace_when,
2308 "replace when", NULL, "which elements can be replaced"
2311 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2312 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2314 options_action_type,
2315 &custom_element_change.action_type,
2316 NULL, NULL, "action on specified condition"
2319 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2320 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2322 options_action_mode_none,
2323 &custom_element_change.action_mode,
2324 NULL, NULL, "action operator"
2327 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2328 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2330 options_action_arg_none,
2331 &custom_element_change.action_arg,
2332 NULL, NULL, "action parameter"
2335 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2336 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2338 options_change_page,
2339 &custom_element.current_change_page,
2340 NULL, NULL, "element change page"
2343 /* ---------- element settings: configure (group elements) --------------- */
2346 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
2347 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2349 options_group_choice_mode,
2350 &group_element_info.choice_mode,
2351 "choice type:", NULL, "type of group element choice"
2359 int gadget_id_align;
2362 char *text_left, *text_right, *infotext;
2363 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2366 ED_LEVEL_SETTINGS_TABS_XPOS(0), ED_LEVEL_SETTINGS_TABS_YPOS(0),
2367 GADGET_ID_LEVELINFO_LEVEL, GADGET_ID_NONE,
2369 NULL, NULL, "Configure level properties"
2372 ED_LEVEL_SETTINGS_TABS_XPOS(1), ED_LEVEL_SETTINGS_TABS_YPOS(0),
2373 GADGET_ID_LEVELINFO_EDITOR, GADGET_ID_NONE,
2375 NULL, NULL, "Configure editor properties"
2378 ED_ELEMENT_SETTINGS_TABS_XPOS(0), ED_ELEMENT_SETTINGS_TABS_YPOS(0),
2379 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
2381 NULL, NULL, "Show information about element"
2384 ED_ELEMENT_SETTINGS_TABS_XPOS(1), ED_ELEMENT_SETTINGS_TABS_YPOS(0),
2385 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_NONE,
2387 NULL, NULL, "Configure element properties"
2390 ED_ELEMENT_SETTINGS_TABS_XPOS(1), ED_ELEMENT_SETTINGS_TABS_YPOS(0),
2391 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_NONE,
2393 NULL, NULL, "Configure element properties, part 1"
2396 ED_ELEMENT_SETTINGS_TABS_XPOS(2), ED_ELEMENT_SETTINGS_TABS_YPOS(0),
2397 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_NONE,
2399 NULL, NULL, "Configure element properties, part 2"
2402 ED_ELEMENT_SETTINGS_TABS_XPOS(3), ED_ELEMENT_SETTINGS_TABS_YPOS(0),
2403 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_NONE,
2405 NULL, NULL, "Configure custom element change pages"
2408 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2409 GADGET_ID_SAVE_AS_TEMPLATE, GADGET_ID_CUSTOM_USE_TEMPLATE,
2411 " ", "As Template", "Save current settings as new template"
2414 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2415 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
2417 NULL, NULL, "Add new change page"
2420 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2421 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
2423 NULL, NULL, "Delete current change page"
2433 int gadget_id_align;
2434 char *text_left, *text_right, *infotext;
2435 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
2438 ED_BUTTON_MINUS_XPOS, ED_BUTTON_COUNT_YPOS,
2439 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
2440 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
2441 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
2442 NULL, NULL, "select previous change page"
2445 ED_BUTTON_PLUS_XPOS, ED_BUTTON_COUNT_YPOS,
2446 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2447 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
2448 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
2449 NULL, "change page", "select next change page"
2452 ED_COPY_CHANGE_PAGE_XPOS, ED_COPY_CHANGE_PAGE_YPOS,
2453 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2454 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
2455 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
2456 " ", NULL, "copy settings from this change page"
2459 ED_PASTE_CHANGE_PAGE_XPOS, ED_PASTE_CHANGE_PAGE_YPOS,
2460 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2461 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
2462 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
2463 NULL, NULL, "paste settings to this change page"
2473 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
2476 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 0 * ED_SCROLLBUTTON_YSIZE,
2477 ED_SCROLL_UP_XPOS, ED_SCROLL_UP_YPOS,
2478 GADGET_ID_SCROLL_UP,
2479 "scroll level editing area up"
2482 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 1 * ED_SCROLLBUTTON_YSIZE,
2483 ED_SCROLL_DOWN_XPOS, ED_SCROLL_DOWN_YPOS,
2484 GADGET_ID_SCROLL_DOWN,
2485 "scroll level editing area down"
2488 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 2 * ED_SCROLLBUTTON_YSIZE,
2489 ED_SCROLL_LEFT_XPOS, ED_SCROLL_LEFT_YPOS,
2490 GADGET_ID_SCROLL_LEFT,
2491 "scroll level editing area left"
2494 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 3 * ED_SCROLLBUTTON_YSIZE,
2495 ED_SCROLL_RIGHT_XPOS, ED_SCROLL_RIGHT_YPOS,
2496 GADGET_ID_SCROLL_RIGHT,
2497 "scroll level editing area right"
2500 ED_SCROLLBUTTON2_XPOS, ED_SCROLLBUTTON2_YPOS + 0 * ED_SCROLLBUTTON2_YSIZE,
2501 ED_SCROLL2_UP_XPOS, ED_SCROLL2_UP_YPOS,
2502 GADGET_ID_SCROLL_LIST_UP,
2503 "scroll element list up ('Page Up')"
2506 ED_SCROLLBUTTON2_XPOS, ED_SCROLLBUTTON2_YPOS + 1 * ED_SCROLLBUTTON2_YSIZE,
2507 ED_SCROLL2_DOWN_XPOS, ED_SCROLL2_DOWN_YPOS,
2508 GADGET_ID_SCROLL_LIST_DOWN,
2509 "scroll element list down ('Page Down')"
2518 int wheel_x, wheel_y;
2519 int wheel_width, wheel_height;
2523 } scrollbar_info[ED_NUM_SCROLLBARS] =
2526 ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
2527 SX + ED_SCROLL_HORIZONTAL_XPOS, SY + ED_SCROLL_HORIZONTAL_YPOS,
2528 ED_SCROLL_HORIZONTAL_XSIZE, ED_SCROLL_HORIZONTAL_YSIZE,
2534 SX + SXSIZE + SX, WIN_YSIZE,
2536 GD_TYPE_SCROLLBAR_HORIZONTAL,
2537 GADGET_ID_SCROLL_HORIZONTAL,
2538 "scroll level editing area horizontally"
2541 ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
2542 SX + ED_SCROLL_VERTICAL_XPOS, SY + ED_SCROLL_VERTICAL_YPOS,
2543 ED_SCROLL_VERTICAL_XSIZE, ED_SCROLL_VERTICAL_YSIZE,
2549 SX + SXSIZE + SX, WIN_YSIZE,
2551 GD_TYPE_SCROLLBAR_VERTICAL,
2552 GADGET_ID_SCROLL_VERTICAL,
2553 "scroll level editing area vertically"
2556 ED_SCROLLBAR2_XPOS, ED_SCROLLBAR2_YPOS,
2557 DX + ED_SCROLL2_VERTICAL_XPOS, DY + ED_SCROLL2_VERTICAL_YPOS,
2558 ED_SCROLL2_VERTICAL_XSIZE, ED_SCROLL2_VERTICAL_YSIZE,
2563 SX + SXSIZE + SX, 0,
2564 WIN_XSIZE - (SX + SXSIZE + SX), WIN_YSIZE,
2566 GD_TYPE_SCROLLBAR_VERTICAL,
2567 GADGET_ID_SCROLL_LIST_VERTICAL,
2568 "scroll element list vertically"
2576 int gadget_id_align;
2577 int radio_button_nr;
2580 char *text_left, *text_right, *infotext;
2581 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
2584 -1, ED_LEVEL_SETTINGS_YPOS(0),
2585 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
2586 RADIO_NR_RANDOM_ELEMENTS,
2587 &random_placement_method, RANDOM_USE_PERCENTAGE,
2588 " ", "percentage", "use percentage for random elements"
2591 -1, ED_LEVEL_SETTINGS_YPOS(0),
2592 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
2593 RADIO_NR_RANDOM_ELEMENTS,
2594 &random_placement_method, RANDOM_USE_QUANTITY,
2595 " ", "quantity", "use quantity for random elements"
2603 int gadget_id_align;
2605 char *text_left, *text_right, *infotext;
2606 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
2608 /* ---------- level and editor settings ---------------------------------- */
2611 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
2612 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
2613 &random_placement_background_restricted,
2615 "restrict random placement to:", "set random placement restriction"
2618 /* ---------- element settings: configure (various elements) ------------- */
2621 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2622 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
2623 &stick_element_properties_window,
2625 "stick this screen to edit content","stick this screen to edit content"
2628 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2629 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
2630 &level.em_slippery_gems,
2632 "slip down from certain flat walls","use EM/DC style slipping behaviour"
2635 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2636 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
2637 &level.em_explodes_by_fire,
2639 "explodes with chain reaction", "use R'n'D style explosion behaviour"
2642 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2643 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
2644 &level.use_spring_bug,
2646 "use spring pushing bug", "use odd spring pushing behaviour"
2649 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2650 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
2651 &level.use_time_orb_bug,
2653 "use time orb bug", "use odd time orb behaviour"
2656 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2657 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
2660 "create single random element", "only create one element from content"
2663 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2664 GADGET_ID_INITIAL_BALL_STATE, GADGET_ID_NONE,
2665 &level.ball_state_initial,
2667 "magic ball initially activated", "activate magic ball after level start"
2670 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2671 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
2672 &level.grow_into_diggable,
2674 "can grow into anything diggable", "grow into more than just sand"
2677 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2678 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
2679 &level.auto_exit_sokoban,
2681 "exit level if all fields solved", "automatically finish Sokoban levels"
2684 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
2685 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
2686 &level.continuous_snapping,
2688 "continuos snapping", "use snapping without releasing key"
2691 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2692 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
2693 &level.block_snap_field,
2695 "block snapped field when snapping", "use snapping delay to show animation"
2698 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2699 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
2700 &level.block_last_field,
2702 "block last field when moving", "player blocks last field when moving"
2705 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2706 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
2707 &level.sp_block_last_field,
2709 "block last field when moving", "player blocks last field when moving"
2712 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
2713 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
2714 &level.instant_relocation,
2716 "no scrolling when relocating", "player gets relocated without delay"
2719 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2720 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
2721 &level.shifted_relocation,
2723 "no centering when relocating", "level not centered after relocation"
2726 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
2727 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
2728 &level.use_start_element[0],
2730 "use level start element:", "start level at this element's position"
2733 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
2734 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
2735 &level.use_artwork_element[0],
2737 "use artwork from element:", "use player artwork from other element"
2740 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
2741 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
2742 &level.use_explosion_element[0],
2744 "use explosion from element:", "use explosion properties from element"
2747 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
2748 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
2749 &level.initial_player_gravity[0],
2751 "use initial gravity", "set initial player gravity"
2754 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2755 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
2756 &level.use_initial_inventory[0],
2758 "use initial inventory:", "use collected elements on level start"
2761 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
2762 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
2763 &level.can_pass_to_walkable,
2765 "can pass to walkable element", "player can pass to empty or walkable"
2768 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2769 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
2770 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
2772 "can fall into acid (with gravity)","player can fall into acid pool"
2775 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2776 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
2777 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
2779 "can move into acid", "element can move into acid pool"
2782 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2783 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
2784 &custom_element_properties[EP_DONT_COLLIDE_WITH],
2786 "deadly when colliding with", "element is deadly when hitting player"
2789 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2790 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
2791 &level.envelope[0].autowrap,
2793 "auto-wrap", "automatically wrap envelope text"
2796 -1, ED_ELEMENT_SETTINGS_YPOS(1),
2797 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
2798 &level.envelope[0].centered,
2800 "centered", "automatically center envelope text"
2803 /* ---------- element settings: configure 1 (custom elements) ----------- */
2806 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2807 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
2808 &custom_element.use_gfx_element,
2810 /* !!! add separate "use existing element sound" !!! */
2813 "use graphic/sound of element:", "use existing graphic and sound"
2816 "use graphic of element:", "use existing element graphic"
2820 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2821 GADGET_ID_CUSTOM_USE_TEMPLATE, GADGET_ID_NONE,
2822 &level.use_custom_template,
2824 "use template", "use template for custom properties"
2827 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
2828 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
2829 &custom_element_properties[EP_ACCESSIBLE],
2831 NULL, "player can walk to or pass this field"
2834 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
2835 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
2836 &custom_element_properties[EP_GRAVITY_REACHABLE],
2838 "reachable despite gravity", "player can walk/dig despite gravity"
2841 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
2842 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
2843 &custom_element.use_last_ce_value,
2845 "use last CE value after change", "use last CE value after change"
2848 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
2849 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
2850 &custom_element_properties[EP_WALK_TO_OBJECT],
2852 NULL, "player can dig/collect/push element"
2855 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
2856 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
2857 &custom_element_properties[EP_INDESTRUCTIBLE],
2859 "indestructible", "element is indestructible"
2862 /* ---------- element settings: configure 2 (custom elements) ----------- */
2865 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2866 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
2867 &custom_element_properties[EP_CAN_MOVE],
2869 NULL, "element can move with some pattern"
2872 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2873 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
2874 &custom_element_properties[EP_CAN_FALL],
2876 "can fall", "element can fall down"
2879 -1, ED_ELEMENT_SETTINGS_YPOS(7),
2880 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
2881 &custom_element_properties[EP_CAN_SMASH],
2883 NULL, "element can smash other elements"
2886 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
2887 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
2888 &custom_element_properties[EP_SLIPPERY],
2890 NULL, "other elements can fall down from it"
2893 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
2894 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
2895 &custom_element_properties[EP_DEADLY],
2897 NULL, "element can kill the player"
2900 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
2901 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
2902 &custom_element_properties[EP_CAN_EXPLODE],
2904 NULL, "element can explode"
2907 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
2908 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
2909 &custom_element_properties[EP_EXPLODES_BY_FIRE],
2911 "by fire", "element can explode by fire/explosion"
2914 -1, ED_ELEMENT_SETTINGS_YPOS(11),
2915 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
2916 &custom_element_properties[EP_EXPLODES_SMASHED],
2918 "smashed", "element can explode when smashed"
2921 -1, ED_ELEMENT_SETTINGS_YPOS(11),
2922 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
2923 &custom_element_properties[EP_EXPLODES_IMPACT],
2925 "impact", "element can explode on impact"
2928 /* ---------- element settings: advanced (custom elements) --------------- */
2931 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2932 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
2933 &custom_element_change.can_change,
2935 "element changes to:", "change element on specified condition"
2938 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2939 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
2940 &custom_element_change_events[CE_DELAY],
2942 NULL, "element changes after delay"
2945 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2946 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
2947 &custom_element_change_events[CE_BY_DIRECT_ACTION],
2949 NULL, "element changes by direct action"
2952 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
2953 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
2954 &custom_element_change_events[CE_BY_OTHER_ACTION],
2956 NULL, "element changes by other element"
2959 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
2960 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
2961 &custom_element_change.explode,
2963 "explode instead of change", "element explodes instead of change"
2966 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2967 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
2968 &custom_element_change.use_target_content,
2970 "use extended change target:", "element changes to more elements"
2973 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
2974 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
2975 &custom_element_change.only_if_complete,
2977 "replace all or nothing", "only replace when all can be changed"
2980 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
2981 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
2982 &custom_element_change.use_random_replace,
2984 NULL, "use percentage for random replace"
2987 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
2988 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
2989 &custom_element_change.has_action,
2991 NULL, "execute action on specified condition"
2999 int gadget_id_align;
3001 int area_xsize, area_ysize;
3002 char *text_left, *text_right, *text_below, *infotext;
3003 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3005 /* ---------- level playfield content ------------------------------------ */
3009 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
3010 NULL, MAX_ED_FIELDX, MAX_ED_FIELDY,
3011 NULL, NULL, NULL, NULL
3014 /* ---------- yam yam content -------------------------------------------- */
3017 ED_AREA_YAMYAM_CONTENT_XPOS(0), ED_AREA_YAMYAM_CONTENT_YPOS(0),
3018 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
3019 &level.yamyam_content[0].e[0][0], 3, 3,
3020 NULL, NULL, "1", NULL
3023 ED_AREA_YAMYAM_CONTENT_XPOS(1), ED_AREA_YAMYAM_CONTENT_YPOS(1),
3024 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
3025 &level.yamyam_content[1].e[0][0], 3, 3,
3026 NULL, NULL, "2", NULL
3029 ED_AREA_YAMYAM_CONTENT_XPOS(2), ED_AREA_YAMYAM_CONTENT_YPOS(2),
3030 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
3031 &level.yamyam_content[2].e[0][0], 3, 3,
3032 NULL, NULL, "3", NULL
3035 ED_AREA_YAMYAM_CONTENT_XPOS(3), ED_AREA_YAMYAM_CONTENT_YPOS(3),
3036 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
3037 &level.yamyam_content[3].e[0][0], 3, 3,
3038 NULL, NULL, "4", NULL
3041 ED_AREA_YAMYAM_CONTENT_XPOS(4), ED_AREA_YAMYAM_CONTENT_YPOS(4),
3042 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
3043 &level.yamyam_content[4].e[0][0], 3, 3,
3044 NULL, NULL, "5", NULL
3047 ED_AREA_YAMYAM_CONTENT_XPOS(5), ED_AREA_YAMYAM_CONTENT_YPOS(5),
3048 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
3049 &level.yamyam_content[5].e[0][0], 3, 3,
3050 NULL, NULL, "6", NULL
3053 ED_AREA_YAMYAM_CONTENT_XPOS(6), ED_AREA_YAMYAM_CONTENT_YPOS(6),
3054 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
3055 &level.yamyam_content[6].e[0][0], 3, 3,
3056 NULL, NULL, "7", NULL
3059 ED_AREA_YAMYAM_CONTENT_XPOS(7), ED_AREA_YAMYAM_CONTENT_YPOS(7),
3060 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
3061 &level.yamyam_content[7].e[0][0], 3, 3,
3062 NULL, NULL, "8", NULL
3065 /* ---------- magic ball content ----------------------------------------- */
3068 ED_AREA_MAGIC_BALL_CONTENT_XPOS(0), ED_AREA_MAGIC_BALL_CONTENT_YPOS(0),
3069 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
3070 &level.ball_content[0].e[0][0], 3, 3,
3071 NULL, NULL, "1", NULL
3074 ED_AREA_MAGIC_BALL_CONTENT_XPOS(1), ED_AREA_MAGIC_BALL_CONTENT_YPOS(1),
3075 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
3076 &level.ball_content[1].e[0][0], 3, 3,
3077 NULL, NULL, "2", NULL
3080 ED_AREA_MAGIC_BALL_CONTENT_XPOS(2), ED_AREA_MAGIC_BALL_CONTENT_YPOS(2),
3081 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
3082 &level.ball_content[2].e[0][0], 3, 3,
3083 NULL, NULL, "3", NULL
3086 ED_AREA_MAGIC_BALL_CONTENT_XPOS(3), ED_AREA_MAGIC_BALL_CONTENT_YPOS(3),
3087 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
3088 &level.ball_content[3].e[0][0], 3, 3,
3089 NULL, NULL, "4", NULL
3092 ED_AREA_MAGIC_BALL_CONTENT_XPOS(4), ED_AREA_MAGIC_BALL_CONTENT_YPOS(4),
3093 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
3094 &level.ball_content[4].e[0][0], 3, 3,
3095 NULL, NULL, "5", NULL
3098 ED_AREA_MAGIC_BALL_CONTENT_XPOS(5), ED_AREA_MAGIC_BALL_CONTENT_YPOS(5),
3099 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
3100 &level.ball_content[5].e[0][0], 3, 3,
3101 NULL, NULL, "6", NULL
3104 ED_AREA_MAGIC_BALL_CONTENT_XPOS(6), ED_AREA_MAGIC_BALL_CONTENT_YPOS(6),
3105 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
3106 &level.ball_content[6].e[0][0], 3, 3,
3107 NULL, NULL, "7", NULL
3110 ED_AREA_MAGIC_BALL_CONTENT_XPOS(7), ED_AREA_MAGIC_BALL_CONTENT_YPOS(7),
3111 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
3112 &level.ball_content[7].e[0][0], 3, 3,
3113 NULL, NULL, "8", NULL
3116 /* ---------- android content -------------------------------------------- */
3119 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(5),
3120 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
3121 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
3122 "elements:", NULL, NULL, "elements android can clone"
3125 /* ---------- amoeba content --------------------------------------------- */
3128 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
3129 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
3130 &level.amoeba_content, 1, 1,
3131 "content:", NULL, NULL, "amoeba content"
3134 /* ---------- level start element ---------------------------------------- */
3137 -1, ED_AREA_1X1_SETTINGS_YPOS(9),
3138 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
3139 &level.start_element[0], 1, 1,
3140 NULL, NULL, NULL, "level start element"
3143 /* ---------- player artwork element ------------------------------------- */
3146 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
3147 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
3148 &level.artwork_element[0], 1, 1,
3149 NULL, NULL, NULL, "element for player artwork"
3152 /* ---------- player explosion element ----------------------------------- */
3155 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
3156 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
3157 &level.explosion_element[0], 1, 1,
3158 NULL, NULL, NULL, "element for player explosion"
3161 /* ---------- player initial inventory ----------------------------------- */
3164 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3165 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
3166 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
3167 NULL, NULL, NULL, "content for initial inventory"
3170 /* ---------- element settings: configure 1 (custom elements) ----------- */
3172 /* ---------- custom graphic --------------------------------------------- */
3175 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3176 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
3177 &custom_element.gfx_element_initial,1, 1,
3178 NULL, NULL, NULL, "custom graphic element"
3181 /* ---------- element settings: configure 2 (custom elements) ----------- */
3183 /* ---------- custom content (when exploding) ---------------------------- */
3186 -1, ED_AREA_3X3_SETTINGS_YPOS(10),
3187 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, /* align three rows */
3188 &custom_element.content.e[0][0], 3, 3,
3189 "content:", NULL, NULL, NULL
3192 /* ---------- custom enter and leave element (when moving) --------------- */
3195 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
3196 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
3197 &custom_element.move_enter_element, 1, 1,
3198 "can dig:", " ", NULL, "element that can be digged/collected"
3201 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
3202 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
3203 &custom_element.move_leave_element, 1, 1,
3204 NULL, NULL, NULL, "element that will be left behind"
3207 /* ---------- element settings: advanced (custom elements) --------------- */
3209 /* ---------- custom change target --------------------------------------- */
3212 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3213 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
3214 &custom_element_change.target_element, 1, 1,
3215 NULL, "after/when:", NULL, "new target element after change"
3218 /* ---------- custom change content (extended change target) ------------- */
3221 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
3222 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, /* align three rows */
3223 &custom_element_change.target_content.e[0][0], 3, 3,
3224 NULL, NULL, NULL, "new extended elements after change"
3227 /* ---------- custom change trigger (element causing change) ------------- */
3230 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
3231 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
3232 &custom_element_change.initial_trigger_element, 1, 1,
3233 NULL, NULL, NULL, "other element triggering change"
3236 /* ---------- custom change action (element used for action) ------------- */
3239 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
3240 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
3241 &custom_element_change.action_element, 1, 1,
3242 NULL, NULL, NULL, "element used as action parameter"
3245 /* ---------- group element content -------------------------------------- */
3248 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(4),
3249 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
3250 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
3251 "content:", NULL, NULL, NULL
3254 /* ---------- random background (for random painting) -------------------- */
3257 -1, ED_AREA_1X1_SETTINGS_YPOS(-1),
3258 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
3259 &random_placement_background_element, 1, 1,
3260 NULL, NULL, NULL, "random placement background"
3266 -----------------------------------------------------------------------------
3267 some internally used variables
3268 -----------------------------------------------------------------------------
3271 /* actual size of level editor drawing area */
3272 static int ed_fieldx = MAX_ED_FIELDX - 1, ed_fieldy = MAX_ED_FIELDY - 1;
3274 /* actual position of level editor drawing area in level playfield */
3275 static int level_xpos = -1, level_ypos = -1;
3278 #define IN_ED_FIELD(x,y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
3280 #define IN_ED_FIELD(x,y) ((x)>=0 && (x)<ed_fieldx && (y)>=0 &&(y)<ed_fieldy)
3283 /* drawing elements on the three mouse buttons */
3284 static int new_element1 = EL_WALL;
3285 static int new_element2 = EL_EMPTY;
3286 static int new_element3 = EL_SAND;
3288 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
3289 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
3290 (button) == 2 ? new_element2 : \
3291 (button) == 3 ? new_element3 : EL_EMPTY)
3292 #define BUTTON_STEPSIZE(button) ((button) == 1 ? 1 : (button) == 2 ? 5 : 10)
3294 /* forward declaration for internal use */
3295 static void ModifyEditorCounterValue(int, int);
3296 static void ModifyEditorCounterLimits(int, int, int);
3297 static void ModifyEditorSelectboxValue(int, int);
3298 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
3299 static void ModifyEditorDrawingArea(int, int, int);
3300 static void ModifyEditorElementList();
3301 static void AdjustElementListScrollbar();
3302 static void RedrawDrawingElements();
3303 static void DrawDrawingWindow();
3304 static void DrawLevelInfoWindow();
3305 static void DrawPropertiesWindow();
3306 static void UpdateCustomElementGraphicGadgets();
3307 static boolean checkPropertiesConfig(int);
3308 static void CopyLevelToUndoBuffer(int);
3309 static void HandleDrawingAreas(struct GadgetInfo *);
3310 static void HandleCounterButtons(struct GadgetInfo *);
3311 static void HandleTextInputGadgets(struct GadgetInfo *);
3312 static void HandleTextAreaGadgets(struct GadgetInfo *);
3313 static void HandleSelectboxGadgets(struct GadgetInfo *);
3314 static void HandleTextbuttonGadgets(struct GadgetInfo *);
3315 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
3316 static void HandleRadiobuttons(struct GadgetInfo *);
3317 static void HandleCheckbuttons(struct GadgetInfo *);
3318 static void HandleControlButtons(struct GadgetInfo *);
3319 static void HandleDrawingAreaInfo(struct GadgetInfo *);
3320 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
3322 static struct GadgetInfo *level_editor_gadget[NUM_EDITOR_GADGETS];
3323 static int right_gadget_border[NUM_EDITOR_GADGETS];
3325 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
3326 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
3327 static boolean draw_with_brush = FALSE;
3328 static int properties_element = 0;
3330 static short FieldBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3331 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3332 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3333 static int undo_buffer_position = 0;
3334 static int undo_buffer_steps = 0;
3336 static int edit_mode;
3337 static int edit_mode_levelinfo;
3338 static int edit_mode_properties;
3340 static int element_shift = 0;
3342 static int editor_el_players[] =
3349 static int *editor_el_players_ptr = editor_el_players;
3350 static int num_editor_el_players = SIZEOF_ARRAY_INT(editor_el_players);
3352 static int editor_hl_boulderdash[] =
3354 EL_INTERNAL_CASCADE_BD_ACTIVE,
3360 static int editor_el_boulderdash[] =
3369 EL_BD_EXPANDABLE_WALL,
3377 EL_BD_BUTTERFLY_LEFT,
3379 EL_BD_BUTTERFLY_RIGHT,
3380 EL_BD_FIREFLY_RIGHT,
3383 EL_BD_BUTTERFLY_DOWN,
3387 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
3388 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
3389 static int num_editor_hl_boulderdash = SIZEOF_ARRAY_INT(editor_hl_boulderdash);
3390 static int num_editor_el_boulderdash = SIZEOF_ARRAY_INT(editor_el_boulderdash);
3392 static int editor_hl_emerald_mine[] =
3394 EL_INTERNAL_CASCADE_EM_ACTIVE,
3400 static int editor_el_emerald_mine[] =
3437 EL_ACID_POOL_TOPLEFT,
3439 EL_ACID_POOL_TOPRIGHT,
3442 EL_ACID_POOL_BOTTOMLEFT,
3443 EL_ACID_POOL_BOTTOM,
3444 EL_ACID_POOL_BOTTOMRIGHT,
3464 EL_EM_STEEL_EXIT_CLOSED,
3465 EL_EM_STEEL_EXIT_OPEN,
3467 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
3468 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
3469 static int num_editor_hl_emerald_mine=SIZEOF_ARRAY_INT(editor_hl_emerald_mine);
3470 static int num_editor_el_emerald_mine=SIZEOF_ARRAY_INT(editor_el_emerald_mine);
3472 static int editor_hl_emerald_mine_club[] =
3474 EL_INTERNAL_CASCADE_EMC_ACTIVE,
3480 static int editor_el_emerald_mine_club[] =
3507 EL_EMC_WALL_SLIPPERY_1,
3508 EL_EMC_WALL_SLIPPERY_2,
3509 EL_EMC_WALL_SLIPPERY_3,
3510 EL_EMC_WALL_SLIPPERY_4,
3533 EL_EMC_MAGIC_BALL_SWITCH,
3535 EL_EMC_SPRING_BUMPER,
3540 EL_EM_DYNAMITE_ACTIVE,
3544 EL_BALLOON_SWITCH_UP,
3545 EL_BALLOON_SWITCH_ANY,
3548 EL_BALLOON_SWITCH_LEFT,
3550 EL_BALLOON_SWITCH_RIGHT,
3554 EL_BALLOON_SWITCH_DOWN,
3555 EL_BALLOON_SWITCH_NONE,
3557 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
3558 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
3559 static int num_editor_hl_emerald_mine_club=SIZEOF_ARRAY_INT(editor_hl_emerald_mine_club);
3560 static int num_editor_el_emerald_mine_club=SIZEOF_ARRAY_INT(editor_el_emerald_mine_club);
3562 static int editor_hl_rnd[] =
3564 EL_INTERNAL_CASCADE_RND_ACTIVE,
3570 static int editor_el_rnd[] =
3602 EL_WALL_EMERALD_YELLOW,
3603 EL_WALL_EMERALD_RED,
3604 EL_WALL_EMERALD_PURPLE,
3622 EL_DYNABOMB_INCREASE_NUMBER,
3623 EL_DYNABOMB_INCREASE_SIZE,
3624 EL_DYNABOMB_INCREASE_POWER,
3644 EL_INVISIBLE_STEELWALL,
3648 EL_EXPANDABLE_WALL_HORIZONTAL,
3649 EL_EXPANDABLE_WALL_VERTICAL,
3650 EL_EXPANDABLE_WALL_ANY,
3652 static int *editor_hl_rnd_ptr = editor_hl_rnd;
3653 static int *editor_el_rnd_ptr = editor_el_rnd;
3654 static int num_editor_hl_rnd = SIZEOF_ARRAY_INT(editor_hl_rnd);
3655 static int num_editor_el_rnd = SIZEOF_ARRAY_INT(editor_el_rnd);
3657 static int editor_hl_sokoban[] =
3659 EL_INTERNAL_CASCADE_SB_ACTIVE,
3665 static int editor_el_sokoban[] =
3668 EL_SOKOBAN_FIELD_EMPTY,
3669 EL_SOKOBAN_FIELD_FULL,
3670 EL_SOKOBAN_FIELD_PLAYER,
3672 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
3673 static int *editor_el_sokoban_ptr = editor_el_sokoban;
3674 static int num_editor_hl_sokoban = SIZEOF_ARRAY_INT(editor_hl_sokoban);
3675 static int num_editor_el_sokoban = SIZEOF_ARRAY_INT(editor_el_sokoban);
3677 static int editor_hl_supaplex[] =
3679 EL_INTERNAL_CASCADE_SP_ACTIVE,
3685 static int editor_el_supaplex[] =
3703 EL_SP_PORT_HORIZONTAL,
3704 EL_SP_PORT_VERTICAL,
3712 EL_SP_GRAVITY_PORT_LEFT,
3713 EL_SP_GRAVITY_PORT_RIGHT,
3714 EL_SP_GRAVITY_PORT_UP,
3715 EL_SP_GRAVITY_PORT_DOWN,
3717 EL_SP_GRAVITY_ON_PORT_LEFT,
3718 EL_SP_GRAVITY_ON_PORT_RIGHT,
3719 EL_SP_GRAVITY_ON_PORT_UP,
3720 EL_SP_GRAVITY_ON_PORT_DOWN,
3722 EL_SP_GRAVITY_OFF_PORT_LEFT,
3723 EL_SP_GRAVITY_OFF_PORT_RIGHT,
3724 EL_SP_GRAVITY_OFF_PORT_UP,
3725 EL_SP_GRAVITY_OFF_PORT_DOWN,
3727 EL_SP_HARDWARE_GRAY,
3728 EL_SP_HARDWARE_GREEN,
3729 EL_SP_HARDWARE_BLUE,
3732 EL_SP_HARDWARE_BASE_1,
3733 EL_SP_HARDWARE_BASE_2,
3734 EL_SP_HARDWARE_BASE_3,
3735 EL_SP_HARDWARE_BASE_4,
3737 EL_SP_HARDWARE_BASE_5,
3738 EL_SP_HARDWARE_BASE_6,
3739 EL_SP_HARDWARE_YELLOW,
3747 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
3748 static int *editor_el_supaplex_ptr = editor_el_supaplex;
3749 static int num_editor_hl_supaplex = SIZEOF_ARRAY_INT(editor_hl_supaplex);
3750 static int num_editor_el_supaplex = SIZEOF_ARRAY_INT(editor_el_supaplex);
3752 static int editor_hl_diamond_caves[] =
3754 EL_INTERNAL_CASCADE_DC_ACTIVE,
3760 static int editor_el_diamond_caves[] =
3767 EL_CONVEYOR_BELT_1_LEFT,
3768 EL_CONVEYOR_BELT_1_MIDDLE,
3769 EL_CONVEYOR_BELT_1_RIGHT,
3770 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
3772 EL_CONVEYOR_BELT_2_LEFT,
3773 EL_CONVEYOR_BELT_2_MIDDLE,
3774 EL_CONVEYOR_BELT_2_RIGHT,
3775 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
3777 EL_CONVEYOR_BELT_3_LEFT,
3778 EL_CONVEYOR_BELT_3_MIDDLE,
3779 EL_CONVEYOR_BELT_3_RIGHT,
3780 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
3782 EL_CONVEYOR_BELT_4_LEFT,
3783 EL_CONVEYOR_BELT_4_MIDDLE,
3784 EL_CONVEYOR_BELT_4_RIGHT,
3785 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
3787 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
3788 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
3789 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
3790 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
3792 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
3793 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
3794 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
3795 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
3800 EL_DC_TIMEGATE_SWITCH,
3802 EL_SWITCHGATE_CLOSED,
3804 EL_SWITCHGATE_SWITCH_UP,
3805 EL_SWITCHGATE_SWITCH_DOWN,
3808 EL_LIGHT_SWITCH_ACTIVE,
3809 EL_DC_SWITCHGATE_SWITCH_UP,
3810 EL_DC_SWITCHGATE_SWITCH_DOWN,
3812 EL_STEEL_EXIT_CLOSED,
3814 EL_STEELWALL_SLIPPERY,
3817 EL_QUICKSAND_FAST_EMPTY,
3818 EL_QUICKSAND_FAST_FULL,
3832 EL_SIGN_RADIOACTIVITY,
3838 EL_SIGN_ENTRY_FORBIDDEN,
3839 EL_SIGN_EMERGENCY_EXIT,
3864 EL_DC_STEELWALL_2_SINGLE,
3865 EL_DC_STEELWALL_2_TOP,
3866 EL_SIGN_EXCLAMATION,
3869 EL_DC_STEELWALL_2_LEFT,
3870 EL_DC_STEELWALL_2_MIDDLE,
3871 EL_DC_STEELWALL_2_HORIZONTAL,
3872 EL_DC_STEELWALL_2_RIGHT,
3874 EL_DC_STEELWALL_1_TOPLEFT,
3875 EL_DC_STEELWALL_2_VERTICAL,
3876 EL_DC_STEELWALL_1_TOPRIGHT,
3879 EL_DC_STEELWALL_1_VERTICAL,
3880 EL_DC_STEELWALL_2_BOTTOM,
3882 EL_DC_GATE_WHITE_GRAY,
3884 EL_DC_STEELWALL_1_BOTTOMLEFT,
3885 EL_DC_STEELWALL_1_HORIZONTAL,
3886 EL_DC_STEELWALL_1_BOTTOMRIGHT,
3887 EL_DC_GATE_FAKE_GRAY,
3889 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
3890 EL_DC_STEELWALL_1_BOTTOM,
3891 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
3892 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
3894 EL_DC_STEELWALL_1_RIGHT,
3896 EL_DC_STEELWALL_1_LEFT,
3897 EL_EXPANDABLE_STEELWALL_VERTICAL,
3899 EL_DC_STEELWALL_1_TOPRIGHT_2,
3900 EL_DC_STEELWALL_1_TOP,
3901 EL_DC_STEELWALL_1_TOPLEFT_2,
3902 EL_EXPANDABLE_STEELWALL_ANY,
3904 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
3905 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
3906 static int num_editor_hl_diamond_caves = SIZEOF_ARRAY_INT(editor_hl_diamond_caves);
3907 static int num_editor_el_diamond_caves = SIZEOF_ARRAY_INT(editor_el_diamond_caves);
3909 static int editor_hl_dx_boulderdash[] =
3911 EL_INTERNAL_CASCADE_DX_ACTIVE,
3917 static int editor_el_dx_boulderdash[] =
3921 EL_TUBE_HORIZONTAL_DOWN,
3925 EL_TUBE_VERTICAL_RIGHT,
3927 EL_TUBE_VERTICAL_LEFT,
3931 EL_TUBE_HORIZONTAL_UP,
3939 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
3940 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
3941 static int num_editor_hl_dx_boulderdash = SIZEOF_ARRAY_INT(editor_hl_dx_boulderdash);
3942 static int num_editor_el_dx_boulderdash = SIZEOF_ARRAY_INT(editor_el_dx_boulderdash);
3944 static int editor_hl_chars[] =
3946 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
3952 static int editor_el_chars[] =
4041 EL_CHAR(FONT_ASCII_CURSOR),
4042 EL_CHAR(FONT_ASCII_BUTTON),
4044 EL_CHAR(FONT_ASCII_UP),
4045 EL_CHAR(FONT_ASCII_DOWN),
4049 static int *editor_hl_chars_ptr = editor_hl_chars;
4050 static int *editor_el_chars_ptr = editor_el_chars;
4051 static int num_editor_hl_chars = SIZEOF_ARRAY_INT(editor_hl_chars);
4052 static int num_editor_el_chars = SIZEOF_ARRAY_INT(editor_el_chars);
4054 static int editor_hl_steel_chars[] =
4056 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
4062 static int editor_el_steel_chars[] =
4072 EL_STEEL_CHAR('\''),
4139 EL_STEEL_CHAR('\\'),
4144 EL_STEEL_CHAR('©'),
4145 EL_STEEL_CHAR('Ä'),
4146 EL_STEEL_CHAR('Ö'),
4147 EL_STEEL_CHAR('Ü'),
4149 EL_STEEL_CHAR('°'),
4150 EL_STEEL_CHAR('®'),
4151 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
4152 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
4154 EL_STEEL_CHAR(FONT_ASCII_UP),
4155 EL_STEEL_CHAR(FONT_ASCII_DOWN),
4159 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
4160 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
4161 static int num_editor_hl_steel_chars = SIZEOF_ARRAY_INT(editor_hl_steel_chars);
4162 static int num_editor_el_steel_chars = SIZEOF_ARRAY_INT(editor_el_steel_chars);
4164 static int editor_hl_custom[] =
4166 EL_INTERNAL_CASCADE_CE_ACTIVE,
4172 static int editor_el_custom[] =
4174 EL_CUSTOM_START + 0,
4175 EL_CUSTOM_START + 1,
4176 EL_CUSTOM_START + 2,
4177 EL_CUSTOM_START + 3,
4179 EL_CUSTOM_START + 4,
4180 EL_CUSTOM_START + 5,
4181 EL_CUSTOM_START + 6,
4182 EL_CUSTOM_START + 7,
4184 EL_CUSTOM_START + 8,
4185 EL_CUSTOM_START + 9,
4186 EL_CUSTOM_START + 10,
4187 EL_CUSTOM_START + 11,
4189 EL_CUSTOM_START + 12,
4190 EL_CUSTOM_START + 13,
4191 EL_CUSTOM_START + 14,
4192 EL_CUSTOM_START + 15,
4194 EL_CUSTOM_START + 16,
4195 EL_CUSTOM_START + 17,
4196 EL_CUSTOM_START + 18,
4197 EL_CUSTOM_START + 19,
4199 EL_CUSTOM_START + 20,
4200 EL_CUSTOM_START + 21,
4201 EL_CUSTOM_START + 22,
4202 EL_CUSTOM_START + 23,
4204 EL_CUSTOM_START + 24,
4205 EL_CUSTOM_START + 25,
4206 EL_CUSTOM_START + 26,
4207 EL_CUSTOM_START + 27,
4209 EL_CUSTOM_START + 28,
4210 EL_CUSTOM_START + 29,
4211 EL_CUSTOM_START + 30,
4212 EL_CUSTOM_START + 31,
4214 EL_CUSTOM_START + 32,
4215 EL_CUSTOM_START + 33,
4216 EL_CUSTOM_START + 34,
4217 EL_CUSTOM_START + 35,
4219 EL_CUSTOM_START + 36,
4220 EL_CUSTOM_START + 37,
4221 EL_CUSTOM_START + 38,
4222 EL_CUSTOM_START + 39,
4224 EL_CUSTOM_START + 40,
4225 EL_CUSTOM_START + 41,
4226 EL_CUSTOM_START + 42,
4227 EL_CUSTOM_START + 43,
4229 EL_CUSTOM_START + 44,
4230 EL_CUSTOM_START + 45,
4231 EL_CUSTOM_START + 46,
4232 EL_CUSTOM_START + 47,
4234 EL_CUSTOM_START + 48,
4235 EL_CUSTOM_START + 49,
4236 EL_CUSTOM_START + 50,
4237 EL_CUSTOM_START + 51,
4239 EL_CUSTOM_START + 52,
4240 EL_CUSTOM_START + 53,
4241 EL_CUSTOM_START + 54,
4242 EL_CUSTOM_START + 55,
4244 EL_CUSTOM_START + 56,
4245 EL_CUSTOM_START + 57,
4246 EL_CUSTOM_START + 58,
4247 EL_CUSTOM_START + 59,
4249 EL_CUSTOM_START + 60,
4250 EL_CUSTOM_START + 61,
4251 EL_CUSTOM_START + 62,
4252 EL_CUSTOM_START + 63,
4254 EL_CUSTOM_START + 64,
4255 EL_CUSTOM_START + 65,
4256 EL_CUSTOM_START + 66,
4257 EL_CUSTOM_START + 67,
4259 EL_CUSTOM_START + 68,
4260 EL_CUSTOM_START + 69,
4261 EL_CUSTOM_START + 70,
4262 EL_CUSTOM_START + 71,
4264 EL_CUSTOM_START + 72,
4265 EL_CUSTOM_START + 73,
4266 EL_CUSTOM_START + 74,
4267 EL_CUSTOM_START + 75,
4269 EL_CUSTOM_START + 76,
4270 EL_CUSTOM_START + 77,
4271 EL_CUSTOM_START + 78,
4272 EL_CUSTOM_START + 79,
4274 EL_CUSTOM_START + 80,
4275 EL_CUSTOM_START + 81,
4276 EL_CUSTOM_START + 82,
4277 EL_CUSTOM_START + 83,
4279 EL_CUSTOM_START + 84,
4280 EL_CUSTOM_START + 85,
4281 EL_CUSTOM_START + 86,
4282 EL_CUSTOM_START + 87,
4284 EL_CUSTOM_START + 88,
4285 EL_CUSTOM_START + 89,
4286 EL_CUSTOM_START + 90,
4287 EL_CUSTOM_START + 91,
4289 EL_CUSTOM_START + 92,
4290 EL_CUSTOM_START + 93,
4291 EL_CUSTOM_START + 94,
4292 EL_CUSTOM_START + 95,
4294 EL_CUSTOM_START + 96,
4295 EL_CUSTOM_START + 97,
4296 EL_CUSTOM_START + 98,
4297 EL_CUSTOM_START + 99,
4299 EL_CUSTOM_START + 100,
4300 EL_CUSTOM_START + 101,
4301 EL_CUSTOM_START + 102,
4302 EL_CUSTOM_START + 103,
4304 EL_CUSTOM_START + 104,
4305 EL_CUSTOM_START + 105,
4306 EL_CUSTOM_START + 106,
4307 EL_CUSTOM_START + 107,
4309 EL_CUSTOM_START + 108,
4310 EL_CUSTOM_START + 109,
4311 EL_CUSTOM_START + 110,
4312 EL_CUSTOM_START + 111,
4314 EL_CUSTOM_START + 112,
4315 EL_CUSTOM_START + 113,
4316 EL_CUSTOM_START + 114,
4317 EL_CUSTOM_START + 115,
4319 EL_CUSTOM_START + 116,
4320 EL_CUSTOM_START + 117,
4321 EL_CUSTOM_START + 118,
4322 EL_CUSTOM_START + 119,
4324 EL_CUSTOM_START + 120,
4325 EL_CUSTOM_START + 121,
4326 EL_CUSTOM_START + 122,
4327 EL_CUSTOM_START + 123,
4329 EL_CUSTOM_START + 124,
4330 EL_CUSTOM_START + 125,
4331 EL_CUSTOM_START + 126,
4332 EL_CUSTOM_START + 127,
4334 EL_CUSTOM_START + 128,
4335 EL_CUSTOM_START + 129,
4336 EL_CUSTOM_START + 130,
4337 EL_CUSTOM_START + 131,
4339 EL_CUSTOM_START + 132,
4340 EL_CUSTOM_START + 133,
4341 EL_CUSTOM_START + 134,
4342 EL_CUSTOM_START + 135,
4344 EL_CUSTOM_START + 136,
4345 EL_CUSTOM_START + 137,
4346 EL_CUSTOM_START + 138,
4347 EL_CUSTOM_START + 139,
4349 EL_CUSTOM_START + 140,
4350 EL_CUSTOM_START + 141,
4351 EL_CUSTOM_START + 142,
4352 EL_CUSTOM_START + 143,
4354 EL_CUSTOM_START + 144,
4355 EL_CUSTOM_START + 145,
4356 EL_CUSTOM_START + 146,
4357 EL_CUSTOM_START + 147,
4359 EL_CUSTOM_START + 148,
4360 EL_CUSTOM_START + 149,
4361 EL_CUSTOM_START + 150,
4362 EL_CUSTOM_START + 151,
4364 EL_CUSTOM_START + 152,
4365 EL_CUSTOM_START + 153,
4366 EL_CUSTOM_START + 154,
4367 EL_CUSTOM_START + 155,
4369 EL_CUSTOM_START + 156,
4370 EL_CUSTOM_START + 157,
4371 EL_CUSTOM_START + 158,
4372 EL_CUSTOM_START + 159,
4374 EL_CUSTOM_START + 160,
4375 EL_CUSTOM_START + 161,
4376 EL_CUSTOM_START + 162,
4377 EL_CUSTOM_START + 163,
4379 EL_CUSTOM_START + 164,
4380 EL_CUSTOM_START + 165,
4381 EL_CUSTOM_START + 166,
4382 EL_CUSTOM_START + 167,
4384 EL_CUSTOM_START + 168,
4385 EL_CUSTOM_START + 169,
4386 EL_CUSTOM_START + 170,
4387 EL_CUSTOM_START + 171,
4389 EL_CUSTOM_START + 172,
4390 EL_CUSTOM_START + 173,
4391 EL_CUSTOM_START + 174,
4392 EL_CUSTOM_START + 175,
4394 EL_CUSTOM_START + 176,
4395 EL_CUSTOM_START + 177,
4396 EL_CUSTOM_START + 178,
4397 EL_CUSTOM_START + 179,
4399 EL_CUSTOM_START + 180,
4400 EL_CUSTOM_START + 181,
4401 EL_CUSTOM_START + 182,
4402 EL_CUSTOM_START + 183,
4404 EL_CUSTOM_START + 184,
4405 EL_CUSTOM_START + 185,
4406 EL_CUSTOM_START + 186,
4407 EL_CUSTOM_START + 187,
4409 EL_CUSTOM_START + 188,
4410 EL_CUSTOM_START + 189,
4411 EL_CUSTOM_START + 190,
4412 EL_CUSTOM_START + 191,
4414 EL_CUSTOM_START + 192,
4415 EL_CUSTOM_START + 193,
4416 EL_CUSTOM_START + 194,
4417 EL_CUSTOM_START + 195,
4419 EL_CUSTOM_START + 196,
4420 EL_CUSTOM_START + 197,
4421 EL_CUSTOM_START + 198,
4422 EL_CUSTOM_START + 199,
4424 EL_CUSTOM_START + 200,
4425 EL_CUSTOM_START + 201,
4426 EL_CUSTOM_START + 202,
4427 EL_CUSTOM_START + 203,
4429 EL_CUSTOM_START + 204,
4430 EL_CUSTOM_START + 205,
4431 EL_CUSTOM_START + 206,
4432 EL_CUSTOM_START + 207,
4434 EL_CUSTOM_START + 208,
4435 EL_CUSTOM_START + 209,
4436 EL_CUSTOM_START + 210,
4437 EL_CUSTOM_START + 211,
4439 EL_CUSTOM_START + 212,
4440 EL_CUSTOM_START + 213,
4441 EL_CUSTOM_START + 214,
4442 EL_CUSTOM_START + 215,
4444 EL_CUSTOM_START + 216,
4445 EL_CUSTOM_START + 217,
4446 EL_CUSTOM_START + 218,
4447 EL_CUSTOM_START + 219,
4449 EL_CUSTOM_START + 220,
4450 EL_CUSTOM_START + 221,
4451 EL_CUSTOM_START + 222,
4452 EL_CUSTOM_START + 223,
4454 EL_CUSTOM_START + 224,
4455 EL_CUSTOM_START + 225,
4456 EL_CUSTOM_START + 226,
4457 EL_CUSTOM_START + 227,
4459 EL_CUSTOM_START + 228,
4460 EL_CUSTOM_START + 229,
4461 EL_CUSTOM_START + 230,
4462 EL_CUSTOM_START + 231,
4464 EL_CUSTOM_START + 232,
4465 EL_CUSTOM_START + 233,
4466 EL_CUSTOM_START + 234,
4467 EL_CUSTOM_START + 235,
4469 EL_CUSTOM_START + 236,
4470 EL_CUSTOM_START + 237,
4471 EL_CUSTOM_START + 238,
4472 EL_CUSTOM_START + 239,
4474 EL_CUSTOM_START + 240,
4475 EL_CUSTOM_START + 241,
4476 EL_CUSTOM_START + 242,
4477 EL_CUSTOM_START + 243,
4479 EL_CUSTOM_START + 244,
4480 EL_CUSTOM_START + 245,
4481 EL_CUSTOM_START + 246,
4482 EL_CUSTOM_START + 247,
4484 EL_CUSTOM_START + 248,
4485 EL_CUSTOM_START + 249,
4486 EL_CUSTOM_START + 250,
4487 EL_CUSTOM_START + 251,
4489 EL_CUSTOM_START + 252,
4490 EL_CUSTOM_START + 253,
4491 EL_CUSTOM_START + 254,
4492 EL_CUSTOM_START + 255
4494 static int *editor_hl_custom_ptr = editor_hl_custom;
4495 static int *editor_el_custom_ptr = editor_el_custom;
4496 static int num_editor_hl_custom = SIZEOF_ARRAY_INT(editor_hl_custom);
4497 static int num_editor_el_custom = SIZEOF_ARRAY_INT(editor_el_custom);
4499 static int editor_hl_group[] =
4501 EL_INTERNAL_CASCADE_GE_ACTIVE,
4507 static int editor_el_group[] =
4521 EL_GROUP_START + 10,
4522 EL_GROUP_START + 11,
4524 EL_GROUP_START + 12,
4525 EL_GROUP_START + 13,
4526 EL_GROUP_START + 14,
4527 EL_GROUP_START + 15,
4529 EL_GROUP_START + 16,
4530 EL_GROUP_START + 17,
4531 EL_GROUP_START + 18,
4532 EL_GROUP_START + 19,
4534 EL_GROUP_START + 20,
4535 EL_GROUP_START + 21,
4536 EL_GROUP_START + 22,
4537 EL_GROUP_START + 23,
4539 EL_GROUP_START + 24,
4540 EL_GROUP_START + 25,
4541 EL_GROUP_START + 26,
4542 EL_GROUP_START + 27,
4544 EL_GROUP_START + 28,
4545 EL_GROUP_START + 29,
4546 EL_GROUP_START + 30,
4549 static int *editor_hl_group_ptr = editor_hl_group;
4550 static int *editor_el_group_ptr = editor_el_group;
4551 static int num_editor_hl_group = SIZEOF_ARRAY_INT(editor_hl_group);
4552 static int num_editor_el_group = SIZEOF_ARRAY_INT(editor_el_group);
4554 static int editor_hl_reference[] =
4556 EL_INTERNAL_CASCADE_REF_ACTIVE,
4562 static int editor_el_reference[] =
4566 EL_TRIGGER_CE_VALUE,
4567 EL_TRIGGER_CE_SCORE,
4571 EL_CURRENT_CE_VALUE,
4572 EL_CURRENT_CE_SCORE,
4594 static int *editor_hl_reference_ptr = editor_hl_reference;
4595 static int *editor_el_reference_ptr = editor_el_reference;
4596 static int num_editor_hl_reference = SIZEOF_ARRAY_INT(editor_hl_reference);
4597 static int num_editor_el_reference = SIZEOF_ARRAY_INT(editor_el_reference);
4599 static int editor_hl_user_defined[] =
4601 EL_INTERNAL_CASCADE_USER_ACTIVE,
4607 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
4608 static int *editor_el_user_defined_ptr = NULL;
4609 static int num_editor_hl_user_defined=SIZEOF_ARRAY_INT(editor_hl_user_defined);
4610 static int num_editor_el_user_defined = 0;
4612 static int editor_hl_dynamic[] =
4614 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
4620 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
4621 static int *editor_el_dynamic_ptr = NULL;
4622 static int num_editor_hl_dynamic = SIZEOF_ARRAY_INT(editor_hl_dynamic);
4623 static int num_editor_el_dynamic = 0;
4625 static int editor_hl_empty[] = { };
4626 static int editor_el_empty[ED_NUM_ELEMENTLIST_BUTTONS];
4628 static int *editor_hl_empty_ptr = editor_hl_empty;
4629 static int *editor_el_empty_ptr = editor_el_empty;
4630 static int num_editor_hl_empty = 0;
4631 static int num_editor_el_empty = 0; /* dynamically determined, if needed */
4633 static boolean use_el_empty = FALSE;
4635 static int *editor_elements = NULL; /* dynamically allocated */
4636 static int num_editor_elements = 0; /* dynamically determined */
4638 static boolean setup_editor_show_always = TRUE;
4639 static boolean setup_editor_cascade_never = FALSE;
4641 static int editor_hl_unused[] = { EL_EMPTY };
4642 static int *editor_hl_unused_ptr = editor_hl_unused;
4643 static int num_editor_hl_unused = 0;
4647 boolean *setup_value;
4648 boolean *setup_cascade_value;
4650 int **headline_list;
4651 int *headline_list_size;
4654 int *element_list_size;
4656 boolean last_setup_value;
4658 editor_elements_info[] =
4661 &setup_editor_show_always,
4662 &setup_editor_cascade_never,
4663 &editor_hl_unused_ptr, &num_editor_hl_unused,
4664 &editor_el_players_ptr, &num_editor_el_players
4667 &setup.editor.el_boulderdash,
4668 &setup.editor_cascade.el_bd,
4669 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
4670 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
4673 &setup.editor.el_emerald_mine,
4674 &setup.editor_cascade.el_em,
4675 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
4676 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
4679 &setup.editor.el_emerald_mine_club,
4680 &setup.editor_cascade.el_emc,
4681 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
4682 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
4685 &setup.editor.el_more,
4686 &setup.editor_cascade.el_rnd,
4687 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
4688 &editor_el_rnd_ptr, &num_editor_el_rnd
4691 &setup.editor.el_sokoban,
4692 &setup.editor_cascade.el_sb,
4693 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
4694 &editor_el_sokoban_ptr, &num_editor_el_sokoban
4697 &setup.editor.el_supaplex,
4698 &setup.editor_cascade.el_sp,
4699 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
4700 &editor_el_supaplex_ptr, &num_editor_el_supaplex
4703 &setup.editor.el_diamond_caves,
4704 &setup.editor_cascade.el_dc,
4705 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
4706 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
4709 &setup.editor.el_dx_boulderdash,
4710 &setup.editor_cascade.el_dx,
4711 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
4712 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
4715 &setup.editor.el_chars,
4716 &setup.editor_cascade.el_chars,
4717 &editor_hl_chars_ptr, &num_editor_hl_chars,
4718 &editor_el_chars_ptr, &num_editor_el_chars
4721 &setup.editor.el_steel_chars,
4722 &setup.editor_cascade.el_steel_chars,
4723 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
4724 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
4727 &setup.editor.el_custom,
4728 &setup.editor_cascade.el_ce,
4729 &editor_hl_custom_ptr, &num_editor_hl_custom,
4730 &editor_el_custom_ptr, &num_editor_el_custom
4733 &setup.editor.el_custom,
4734 &setup.editor_cascade.el_ge,
4735 &editor_hl_group_ptr, &num_editor_hl_group,
4736 &editor_el_group_ptr, &num_editor_el_group
4739 &setup.editor.el_custom,
4740 &setup.editor_cascade.el_ref,
4741 &editor_hl_reference_ptr, &num_editor_hl_reference,
4742 &editor_el_reference_ptr, &num_editor_el_reference
4745 &setup.editor.el_user_defined,
4746 &setup.editor_cascade.el_user,
4747 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
4748 &editor_el_user_defined_ptr, &num_editor_el_user_defined
4751 &setup.editor.el_dynamic,
4752 &setup.editor_cascade.el_dynamic,
4753 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
4754 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
4759 &editor_hl_empty_ptr, &num_editor_hl_empty,
4760 &editor_el_empty_ptr, &num_editor_el_empty,
4772 -----------------------------------------------------------------------------
4774 -----------------------------------------------------------------------------
4777 static int getMaxInfoTextLength()
4779 return (SXSIZE / getFontWidth(FONT_TEXT_2));
4782 static int getTextWidthForGadget(char *text)
4787 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
4790 static int getTextWidthForDrawingArea(char *text)
4795 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
4798 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
4800 return (gi->x + gi->width + getTextWidthForGadget(text));
4803 static char *getElementInfoText(int element)
4805 char *info_text = NULL;
4807 if (element < MAX_NUM_ELEMENTS)
4809 if (strlen(element_info[element].description) > 0)
4810 info_text = element_info[element].description;
4811 else if (element_info[element].custom_description != NULL)
4812 info_text = element_info[element].custom_description;
4813 else if (element_info[element].editor_description != NULL)
4814 info_text = element_info[element].editor_description;
4817 if (info_text == NULL)
4818 info_text = INFOTEXT_UNKNOWN_ELEMENT;
4823 char *getElementDescriptionFilename(int element)
4825 char *docs_dir = options.docs_directory;
4826 char *elements_subdir = "elements";
4827 static char *filename = NULL;
4828 char basename[MAX_FILENAME_LEN];
4830 checked_free(filename);
4832 /* 1st try: look for element description file for exactly this element */
4833 sprintf(basename, "%s.txt", element_info[element].token_name);
4834 filename = getPath3(docs_dir, elements_subdir, basename);
4835 if (fileExists(filename))
4840 /* 2nd try: look for element description file for this element's class */
4841 sprintf(basename, "%s.txt", element_info[element].class_name);
4842 filename = getPath3(docs_dir, elements_subdir, basename);
4843 if (fileExists(filename))
4849 static void InitDynamicEditorElementList(int **elements, int *num_elements)
4851 boolean element_found[NUM_FILE_ELEMENTS];
4854 /* initialize list of used elements to "not used" */
4855 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
4856 element_found[i] = FALSE;
4858 /* find all elements used in current level */
4859 for (y = 0; y < lev_fieldy; y++)
4860 for (x = 0; x < lev_fieldx; x++)
4861 if (Feld[x][y] < NUM_FILE_ELEMENTS) /* should always be true */
4862 element_found[Feld[x][y]] = TRUE;
4866 /* count number of elements used in current level */
4867 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
4868 if (element_found[i])
4871 /* add space for up to 3 more elements for padding that may be needed */
4874 /* free memory for old list of elements, if needed */
4875 checked_free(*elements);
4877 /* allocate memory for new list of elements */
4878 *elements = checked_malloc(*num_elements * sizeof(int));
4882 /* add all elements used in current level (non-custom/group elements) */
4883 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
4884 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
4885 (*elements)[(*num_elements)++] = i;
4887 /* add all elements used in current level (custom/group elements) */
4888 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
4889 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
4890 (*elements)[(*num_elements)++] = i;
4892 while (*num_elements % 4) /* pad with empty elements, if needed */
4893 (*elements)[(*num_elements)++] = EL_EMPTY;
4896 static void ReinitializeElementList()
4898 static boolean initialization_needed = TRUE;
4902 if (initialization_needed)
4904 LoadSetup_EditorCascade(); /* load last editor cascade state */
4906 /* initialize editor cascade element from saved cascade state */
4907 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4909 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
4910 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
4912 if (IS_EDITOR_CASCADE(*cascade_element))
4914 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
4915 EL_CASCADE_INACTIVE(*cascade_element));
4918 initialization_needed = FALSE;
4921 checked_free(editor_elements);
4923 /* reload optional user defined element list for each invocation of editor */
4924 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
4925 &num_editor_el_user_defined);
4927 /* initialize dynamic level element list for each invocation of editor */
4928 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
4929 &num_editor_el_dynamic);
4931 /* initialize list of empty elements (used for padding, if needed) */
4932 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
4933 editor_el_empty[i] = EL_EMPTY;
4935 /* do some sanity checks for each element from element list */
4936 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4938 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
4940 int element = (*editor_elements_info[i].element_list)[j];
4942 if (element >= NUM_FILE_ELEMENTS)
4943 Error(ERR_WARN, "editor element %d is runtime element", element);
4945 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
4946 Error(ERR_WARN, "no element description for element %d", element);
4950 num_editor_elements = 0;
4951 use_el_empty = FALSE;
4953 /* determine size of element list */
4954 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4956 boolean found_inactive_cascade = FALSE;
4958 if (*editor_elements_info[i].setup_value)
4960 if (setup.editor.el_headlines)
4962 num_editor_elements += *editor_elements_info[i].headline_list_size;
4964 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
4966 int element = (*editor_elements_info[i].headline_list)[j];
4968 if (IS_EDITOR_CASCADE_INACTIVE(element))
4969 found_inactive_cascade = TRUE;
4973 if (found_inactive_cascade)
4976 num_editor_elements += *editor_elements_info[i].element_list_size;
4980 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
4982 /* offer at least as many elements as element buttons exist */
4983 use_el_empty = TRUE;
4984 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
4986 num_editor_elements += num_editor_el_empty;
4989 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
4991 /* fill element list */
4992 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4994 boolean found_inactive_cascade = FALSE;
4996 if (*editor_elements_info[i].setup_value)
4998 if (setup.editor.el_headlines)
5000 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
5002 int element = (*editor_elements_info[i].headline_list)[j];
5004 editor_elements[pos++] = element;
5006 if (IS_EDITOR_CASCADE_INACTIVE(element))
5007 found_inactive_cascade = TRUE;
5011 if (found_inactive_cascade)
5014 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
5015 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
5019 /* (this function is also called before editor gadgets are initialized!) */
5020 AdjustElementListScrollbar();
5023 void PrintEditorElementList()
5025 boolean *stop = &setup.editor.el_user_defined;
5028 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
5030 int cascade_element = (*editor_elements_info[i].headline_list)[0];
5032 if (IS_EDITOR_CASCADE(cascade_element))
5034 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
5035 char *headline = element_info[cascade_element_show].editor_description;
5037 printf_line_with_prefix("# ", "-", 77);
5038 printf("# %s\n", headline);
5039 printf_line_with_prefix("# ", "-", 77);
5042 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
5044 int element = (*editor_elements_info[i].headline_list)[j];
5046 if (IS_EDITOR_CASCADE(element))
5047 element = EL_CHAR_MINUS;
5049 printf("# %s\n", element_info[element].token_name);
5055 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
5057 int element = (*editor_elements_info[i].element_list)[j];
5059 printf("# %s\n", element_info[element].token_name);
5067 static void ReinitializeElementListButtons()
5069 static boolean last_setup_value_headlines = FALSE;
5070 static boolean initialization_needed = TRUE;
5073 if (!initialization_needed) /* check if editor element setup has changed */
5075 if (last_setup_value_headlines != setup.editor.el_headlines)
5076 initialization_needed = TRUE;
5078 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5079 if (editor_elements_info[i].last_setup_value !=
5080 *editor_elements_info[i].setup_value)
5081 initialization_needed = TRUE;
5084 if (!initialization_needed)
5087 FreeLevelEditorGadgets();
5088 CreateLevelEditorGadgets();
5090 /* store current setup values for next invocation of this function */
5091 last_setup_value_headlines = setup.editor.el_headlines;
5092 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5093 editor_elements_info[i].last_setup_value =
5094 *editor_elements_info[i].setup_value;
5096 initialization_needed = FALSE;
5099 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
5102 int border_graphic =
5103 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
5106 int bx = (input ? 4 : 8);
5107 int by = (input ? 4 : 8);
5108 int bx2 = TILEX - bx;
5109 int by2 = TILEY - by;
5112 getGraphicSource(border_graphic, 0, &src_bitmap, &src_x, &src_y);
5114 BlitBitmap(src_bitmap, drawto, src_x, src_y,
5115 bx, by, dest_x - bx, dest_y - by);
5116 BlitBitmap(src_bitmap, drawto, src_x + bx2, src_y,
5117 bx, by, dest_x + width, dest_y - by);
5118 BlitBitmap(src_bitmap, drawto, src_x, src_y + by2,
5119 bx, by, dest_x - bx, dest_y + height);
5120 BlitBitmap(src_bitmap, drawto, src_x + bx2, src_y + by2,
5121 bx, by, dest_x + width, dest_y + height);
5123 for (i = 0; i < width / MINI_TILEX; i++)
5125 BlitBitmap(src_bitmap, drawto, src_x + bx, src_y, MINI_TILEX, by,
5126 dest_x + i * MINI_TILEX, dest_y - by);
5127 BlitBitmap(src_bitmap, drawto, src_x + bx, src_y + by2, MINI_TILEX, by,
5128 dest_x + i * MINI_TILEX, dest_y + height);
5131 for (i = 0; i < height / MINI_TILEY; i++)
5133 BlitBitmap(src_bitmap, drawto, src_x, src_y + by, bx, MINI_TILEY,
5134 dest_x - bx, dest_y + i * MINI_TILEY);
5135 BlitBitmap(src_bitmap, drawto, src_x + bx2, src_y + by, bx, MINI_TILEY,
5136 dest_x + width, dest_y + i * MINI_TILEY);
5139 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
5142 static void DrawDrawingArea(int id)
5144 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
5147 int *value = drawingarea_info[id].value;
5148 int area_xsize = drawingarea_info[id].area_xsize;
5149 int area_ysize = drawingarea_info[id].area_ysize;
5151 for (x = 0; x < area_xsize; x++)
5152 for (y = 0; y < area_ysize; y++)
5153 DrawMiniGraphicExt(drawto,
5154 gi->x + x * MINI_TILEX,
5155 gi->y + y * MINI_TILEY,
5156 el2edimg(value[x * area_ysize + y]));
5159 static void ScrollMiniLevel(int from_x, int from_y, int scroll)
5162 /* (directly solved in BlitBitmap() now) */
5163 static Bitmap *tmp_backbuffer = NULL;
5166 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
5167 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
5170 /* (directly solved in BlitBitmap() now) */
5171 if (tmp_backbuffer == NULL)
5172 tmp_backbuffer = CreateBitmap(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH);
5174 /* needed when blitting directly to same bitmap -- should not be needed with
5175 recent SDL libraries, but apparently does not work in 1.2.11 directly */
5176 BlitBitmap(drawto, tmp_backbuffer,
5177 SX + (dx == -1 ? MINI_TILEX : 0),
5178 SY + (dy == -1 ? MINI_TILEY : 0),
5179 (ed_fieldx * MINI_TILEX) - (dx != 0 ? MINI_TILEX : 0),
5180 (ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0),
5181 SX + (dx == +1 ? MINI_TILEX : 0),
5182 SY + (dy == +1 ? MINI_TILEY : 0));
5183 BlitBitmap(tmp_backbuffer, drawto,
5184 SX + (dx == +1 ? MINI_TILEX : 0),
5185 SY + (dy == +1 ? MINI_TILEY : 0),
5186 (ed_fieldx * MINI_TILEX) - (dx != 0 ? MINI_TILEX : 0),
5187 (ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0),
5188 SX + (dx == +1 ? MINI_TILEX : 0),
5189 SY + (dy == +1 ? MINI_TILEY : 0));
5193 BlitBitmap(drawto, drawto,
5194 SX + (dx == -1 ? MINI_TILEX : 0),
5195 SY + (dy == -1 ? MINI_TILEY : 0),
5196 (ed_fieldx * MINI_TILEX) - (dx != 0 ? MINI_TILEX : 0),
5197 (ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0),
5198 SX + (dx == +1 ? MINI_TILEX : 0),
5199 SY + (dy == +1 ? MINI_TILEY : 0));
5204 x = (dx == 1 ? 0 : ed_fieldx - 1);
5205 for (y = 0; y < ed_fieldy; y++)
5206 DrawMiniElementOrWall(x, y, from_x, from_y);
5210 y = (dy == 1 ? 0 : ed_fieldy - 1);
5211 for (x = 0; x < ed_fieldx; x++)
5212 DrawMiniElementOrWall(x, y, from_x, from_y);
5215 redraw_mask |= REDRAW_FIELD;
5219 static void CreateControlButtons()
5221 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5222 struct GadgetInfo *gi;
5223 unsigned long event_mask;
5226 /* create toolbox buttons */
5227 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
5231 int gd_xoffset, gd_yoffset;
5232 int gd_x1, gd_x2, gd_y1, gd_y2;
5234 int radio_button_nr;
5237 if (id == GADGET_ID_SINGLE_ITEMS ||
5238 id == GADGET_ID_CONNECTED_ITEMS ||
5239 id == GADGET_ID_LINE ||
5240 id == GADGET_ID_ARC ||
5241 id == GADGET_ID_TEXT ||
5242 id == GADGET_ID_RECTANGLE ||
5243 id == GADGET_ID_FILLED_BOX ||
5244 id == GADGET_ID_FLOOD_FILL ||
5245 id == GADGET_ID_GRAB_BRUSH ||
5246 id == GADGET_ID_PICK_ELEMENT ||
5247 id == GADGET_ID_CUSTOM_COPY_FROM ||
5248 id == GADGET_ID_CUSTOM_COPY_TO ||
5249 id == GADGET_ID_CUSTOM_EXCHANGE)
5251 button_type = GD_TYPE_RADIO_BUTTON;
5252 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
5253 checked = (id == drawing_function ? TRUE : FALSE);
5254 event_mask = GD_EVENT_PRESSED;
5258 button_type = GD_TYPE_NORMAL_BUTTON;
5259 radio_button_nr = RADIO_NR_NONE;
5262 if (id == GADGET_ID_WRAP_LEFT ||
5263 id == GADGET_ID_WRAP_RIGHT ||
5264 id == GADGET_ID_WRAP_UP ||
5265 id == GADGET_ID_WRAP_DOWN)
5266 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5268 event_mask = GD_EVENT_RELEASED;
5271 if (id < ED_NUM_CTRL1_BUTTONS)
5273 int x = i % ED_CTRL1_BUTTONS_HORIZ;
5274 int y = i / ED_CTRL1_BUTTONS_HORIZ;
5276 gd_xoffset = ED_CTRL1_BUTTONS_XPOS + x * ED_CTRL1_BUTTON_XSIZE;
5277 gd_yoffset = ED_CTRL1_BUTTONS_YPOS + y * ED_CTRL1_BUTTON_YSIZE;
5278 width = ED_CTRL1_BUTTON_XSIZE;
5279 height = ED_CTRL1_BUTTON_YSIZE;
5281 gd_x1 = DOOR_GFX_PAGEX8 + gd_xoffset;
5282 gd_x2 = DOOR_GFX_PAGEX7 + gd_xoffset;
5283 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL1_BUTTONS_GFX_YPOS + gd_yoffset;
5284 gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL1_BUTTONS_ALT_GFX_YPOS + gd_yoffset;
5286 else if (id < ED_NUM_CTRL1_2_BUTTONS)
5288 int x = (i - ED_NUM_CTRL1_BUTTONS) % ED_CTRL2_BUTTONS_HORIZ;
5289 int y = (i - ED_NUM_CTRL1_BUTTONS) / ED_CTRL2_BUTTONS_HORIZ;
5291 gd_xoffset = ED_CTRL2_BUTTONS_XPOS + x * ED_CTRL2_BUTTON_XSIZE;
5292 gd_yoffset = ED_CTRL2_BUTTONS_YPOS + y * ED_CTRL2_BUTTON_YSIZE;
5293 width = ED_CTRL2_BUTTON_XSIZE;
5294 height = ED_CTRL2_BUTTON_YSIZE;
5296 gd_x1 = DOOR_GFX_PAGEX8 + gd_xoffset;
5297 gd_x2 = DOOR_GFX_PAGEX7 + gd_xoffset;
5298 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL2_BUTTONS_GFX_YPOS + gd_yoffset;
5299 gd_y2 = 0; /* no alternative graphic for these buttons */
5301 else if (id < ED_NUM_CTRL1_3_BUTTONS)
5303 int x = (i - ED_NUM_CTRL1_2_BUTTONS) % ED_CTRL3_BUTTONS_HORIZ + 1;
5304 int y = (i - ED_NUM_CTRL1_2_BUTTONS) / ED_CTRL3_BUTTONS_HORIZ;
5306 gd_xoffset = ED_CTRL3_BUTTONS_XPOS + x * ED_CTRL3_BUTTON_XSIZE;
5307 gd_yoffset = ED_CTRL3_BUTTONS_YPOS + y * ED_CTRL3_BUTTON_YSIZE;
5308 width = ED_CTRL3_BUTTON_XSIZE;
5309 height = ED_CTRL3_BUTTON_YSIZE;
5311 gd_x1 = DOOR_GFX_PAGEX6 + gd_xoffset;
5312 gd_x2 = DOOR_GFX_PAGEX5 + gd_xoffset;
5313 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL3_BUTTONS_GFX_YPOS + gd_yoffset;
5314 gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL3_BUTTONS_ALT_GFX_YPOS + gd_yoffset;
5318 int x = (i - ED_NUM_CTRL1_3_BUTTONS) % ED_CTRL4_BUTTONS_HORIZ;
5319 int y = (i - ED_NUM_CTRL1_3_BUTTONS) / ED_CTRL4_BUTTONS_HORIZ + 3;
5321 gd_xoffset = ED_CTRL4_BUTTONS_XPOS + x * ED_CTRL4_BUTTON_XSIZE;
5322 gd_yoffset = ED_CTRL4_BUTTONS_YPOS + y * ED_CTRL4_BUTTON_YSIZE;
5323 width = ED_CTRL4_BUTTON_XSIZE;
5324 height = ED_CTRL4_BUTTON_YSIZE;
5326 gd_x1 = DOOR_GFX_PAGEX6 + ED_CTRL4_BUTTONS_GFX_XPOS + gd_xoffset;
5327 gd_x2 = DOOR_GFX_PAGEX5 + ED_CTRL4_BUTTONS_GFX_XPOS + gd_xoffset;
5328 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL4_BUTTONS_GFX_YPOS + gd_yoffset;
5329 gd_y2 = 0; /* no alternative graphic for these buttons */
5332 gi = CreateGadget(GDI_CUSTOM_ID, id,
5333 GDI_CUSTOM_TYPE_ID, i,
5334 GDI_INFO_TEXT, control_info[i].text,
5335 GDI_X, EX + gd_xoffset,
5336 GDI_Y, EY + gd_yoffset,
5339 GDI_TYPE, button_type,
5340 GDI_STATE, GD_BUTTON_UNPRESSED,
5341 GDI_RADIO_NR, radio_button_nr,
5342 GDI_CHECKED, checked,
5343 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5344 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y1,
5345 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2,
5346 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
5347 GDI_EVENT_MASK, event_mask,
5348 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5349 GDI_CALLBACK_ACTION, HandleControlButtons,
5353 Error(ERR_EXIT, "cannot create gadget");
5355 level_editor_gadget[id] = gi;
5358 /* create buttons for scrolling of drawing area and element list */
5359 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
5361 int id = scrollbutton_info[i].gadget_id;
5362 int x, y, width, height;
5363 int gd_x1, gd_x2, gd_y1, gd_y2;
5365 x = scrollbutton_info[i].x;
5366 y = scrollbutton_info[i].y;
5368 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5370 if (id == GADGET_ID_SCROLL_LIST_UP ||
5371 id == GADGET_ID_SCROLL_LIST_DOWN)
5375 width = ED_SCROLLBUTTON2_XSIZE;
5376 height = ED_SCROLLBUTTON2_YSIZE;
5377 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].gd_x;
5378 gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].gd_y;
5379 gd_x2 = gd_x1 - ED_SCROLLBUTTON2_XSIZE;
5386 width = ED_SCROLLBUTTON_XSIZE;
5387 height = ED_SCROLLBUTTON_YSIZE;
5388 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].gd_x;
5389 gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].gd_y;
5390 gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE;
5394 gi = CreateGadget(GDI_CUSTOM_ID, id,
5395 GDI_CUSTOM_TYPE_ID, i,
5396 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
5401 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
5402 GDI_STATE, GD_BUTTON_UNPRESSED,
5403 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5404 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
5405 GDI_EVENT_MASK, event_mask,
5406 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5407 GDI_CALLBACK_ACTION, HandleControlButtons,
5411 Error(ERR_EXIT, "cannot create gadget");
5413 level_editor_gadget[id] = gi;
5416 /* create buttons for element list */
5417 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
5419 Bitmap *deco_bitmap;
5420 int deco_x, deco_y, deco_xpos, deco_ypos;
5421 int gd_xoffset, gd_yoffset;
5422 int gd_x1, gd_x2, gd_y;
5423 int x = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
5424 int y = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
5425 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
5426 int element = editor_elements[i];
5428 event_mask = GD_EVENT_RELEASED;
5430 gd_xoffset = ED_ELEMENTLIST_XPOS + x * ED_ELEMENTLIST_XSIZE;
5431 gd_yoffset = ED_ELEMENTLIST_YPOS + y * ED_ELEMENTLIST_YSIZE;
5433 gd_x1 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS + ED_ELEMENTLIST_XSIZE;
5434 gd_x2 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS;
5435 gd_y = DOOR_GFX_PAGEY1 + ED_ELEMENTLIST_YPOS;
5437 getMiniGraphicSource(el2edimg(element), &deco_bitmap, &deco_x, &deco_y);
5438 deco_xpos = (ED_ELEMENTLIST_XSIZE - MINI_TILEX) / 2;
5439 deco_ypos = (ED_ELEMENTLIST_YSIZE - MINI_TILEY) / 2;
5441 gi = CreateGadget(GDI_CUSTOM_ID, id,
5442 GDI_CUSTOM_TYPE_ID, i,
5443 GDI_INFO_TEXT, getElementInfoText(element),
5444 GDI_X, DX + gd_xoffset,
5445 GDI_Y, DY + gd_yoffset,
5446 GDI_WIDTH, ED_ELEMENTLIST_XSIZE,
5447 GDI_HEIGHT, ED_ELEMENTLIST_YSIZE,
5448 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
5449 GDI_STATE, GD_BUTTON_UNPRESSED,
5450 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
5451 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
5452 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
5453 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
5454 GDI_DECORATION_SIZE, MINI_TILEX, MINI_TILEY,
5455 GDI_DECORATION_SHIFTING, 1, 1,
5456 GDI_EVENT_MASK, event_mask,
5457 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5458 GDI_CALLBACK_ACTION, HandleControlButtons,
5462 Error(ERR_EXIT, "cannot create gadget");
5464 level_editor_gadget[id] = gi;
5468 static void CreateCounterButtons()
5470 int max_infotext_len = getMaxInfoTextLength();
5473 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
5476 int x = SX + counterbutton_info[i].x; /* down count button */
5477 int y = SY + counterbutton_info[i].y;
5479 /* determine horizontal position to the right of specified gadget */
5480 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
5481 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
5482 ED_GADGET_TEXT_DISTANCE);
5484 /* determine horizontal offset for leading text */
5485 if (counterbutton_info[i].text_left != NULL)
5486 x += getTextWidthForGadget(counterbutton_info[i].text_left);
5488 for (j = 0; j < 2; j++)
5490 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5491 struct GadgetInfo *gi;
5493 counterbutton_info[i].gadget_id_down :
5494 counterbutton_info[i].gadget_id_up);
5496 int gd_x, gd_x1, gd_x2, gd_y;
5498 unsigned long event_mask;
5499 char infotext[max_infotext_len + 1];
5501 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5503 if (i == ED_COUNTER_ID_SELECT_LEVEL)
5506 ED_SCROLLBUTTON_ID_AREA_LEFT :
5507 ED_SCROLLBUTTON_ID_AREA_RIGHT);
5509 event_mask |= GD_EVENT_RELEASED;
5512 x += 2 * ED_GADGET_DISTANCE;
5513 y += ED_GADGET_DISTANCE;
5515 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[sid].gd_x;
5516 gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE;
5517 gd_y = DOOR_GFX_PAGEY1 + scrollbutton_info[sid].gd_y;
5518 x_size = ED_SCROLLBUTTON_XSIZE;
5519 y_size = ED_SCROLLBUTTON_YSIZE;
5523 gd_xoffset = (j == 0 ? ED_BUTTON_MINUS_XPOS : ED_BUTTON_PLUS_XPOS);
5524 gd_x1 = DOOR_GFX_PAGEX4 + gd_xoffset;
5525 gd_x2 = DOOR_GFX_PAGEX3 + gd_xoffset;
5526 gd_y = DOOR_GFX_PAGEY1 + ED_BUTTON_COUNT_YPOS;
5527 x_size = ED_BUTTON_COUNT_XSIZE;
5528 y_size = ED_BUTTON_COUNT_YSIZE;
5531 sprintf(infotext, "%s counter value by 1, 5 or 10",
5532 (j == 0 ? "decrease" : "increase"));
5534 gi = CreateGadget(GDI_CUSTOM_ID, id,
5535 GDI_CUSTOM_TYPE_ID, i,
5536 GDI_INFO_TEXT, infotext,
5541 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
5542 GDI_STATE, GD_BUTTON_UNPRESSED,
5543 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
5544 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
5545 GDI_EVENT_MASK, event_mask,
5546 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5547 GDI_CALLBACK_ACTION, HandleCounterButtons,
5551 Error(ERR_EXIT, "cannot create gadget");
5553 level_editor_gadget[id] = gi;
5554 right_gadget_border[id] =
5555 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
5557 x += gi->width + ED_GADGET_DISTANCE; /* text count button */
5561 int font_type = FONT_INPUT_1;
5562 int font_type_active = FONT_INPUT_1_ACTIVE;
5563 int gd_width = ED_WIN_COUNT_XSIZE;
5565 id = counterbutton_info[i].gadget_id_text;
5566 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
5568 if (i == ED_COUNTER_ID_SELECT_LEVEL)
5570 font_type = FONT_LEVEL_NUMBER;
5572 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
5574 font_type_active = FONT_LEVEL_NUMBER;
5576 x += 2 * ED_GADGET_DISTANCE;
5577 y -= ED_GADGET_DISTANCE;
5579 gd_x = DOOR_GFX_PAGEX6 + ED_WIN_COUNT2_XPOS;
5580 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT2_YPOS;
5581 gd_width = ED_WIN_COUNT2_XSIZE;
5585 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
5586 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
5589 gi = CreateGadget(GDI_CUSTOM_ID, id,
5590 GDI_CUSTOM_TYPE_ID, i,
5591 GDI_INFO_TEXT, "enter counter value",
5594 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
5595 GDI_NUMBER_VALUE, 0,
5596 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
5597 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
5598 GDI_TEXT_SIZE, 3, /* minimal counter text size */
5599 GDI_TEXT_FONT, font_type,
5600 GDI_TEXT_FONT_ACTIVE, font_type_active,
5601 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
5602 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
5603 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5604 GDI_DESIGN_WIDTH, gd_width,
5605 GDI_EVENT_MASK, event_mask,
5606 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5607 GDI_CALLBACK_ACTION, HandleCounterButtons,
5611 Error(ERR_EXIT, "cannot create gadget");
5613 level_editor_gadget[id] = gi;
5614 right_gadget_border[id] =
5615 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
5617 x += gi->width + ED_GADGET_DISTANCE; /* up count button */
5623 static void CreateDrawingAreas()
5627 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
5629 struct GadgetInfo *gi;
5630 unsigned long event_mask;
5631 int id = drawingarea_info[i].gadget_id;
5632 int x = SX + drawingarea_info[i].x;
5633 int y = SY + drawingarea_info[i].y;
5634 int area_xsize = drawingarea_info[i].area_xsize;
5635 int area_ysize = drawingarea_info[i].area_ysize;
5638 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
5639 GD_EVENT_OFF_BORDERS;
5641 /* determine horizontal position to the right of specified gadget */
5642 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
5643 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
5644 ED_DRAWINGAREA_TEXT_DISTANCE);
5646 /* determine horizontal offset for leading text */
5647 if (drawingarea_info[i].text_left != NULL)
5648 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
5650 gi = CreateGadget(GDI_CUSTOM_ID, id,
5651 GDI_CUSTOM_TYPE_ID, i,
5654 GDI_TYPE, GD_TYPE_DRAWING_AREA,
5655 GDI_AREA_SIZE, area_xsize, area_ysize,
5656 GDI_ITEM_SIZE, MINI_TILEX, MINI_TILEY,
5657 GDI_EVENT_MASK, event_mask,
5658 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
5659 GDI_CALLBACK_ACTION, HandleDrawingAreas,
5663 Error(ERR_EXIT, "cannot create gadget");
5665 level_editor_gadget[id] = gi;
5666 right_gadget_border[id] =
5667 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
5671 static void CreateTextInputGadgets()
5673 int max_infotext_len = getMaxInfoTextLength();
5676 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
5678 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5680 struct GadgetInfo *gi;
5681 unsigned long event_mask;
5682 char infotext[MAX_OUTPUT_LINESIZE + 1];
5683 int id = textinput_info[i].gadget_id;
5685 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
5687 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
5688 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
5690 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
5691 infotext[max_infotext_len] = '\0';
5693 gi = CreateGadget(GDI_CUSTOM_ID, id,
5694 GDI_CUSTOM_TYPE_ID, i,
5695 GDI_INFO_TEXT, infotext,
5696 GDI_X, SX + textinput_info[i].x,
5697 GDI_Y, SY + textinput_info[i].y,
5698 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
5699 GDI_TEXT_VALUE, textinput_info[i].value,
5700 GDI_TEXT_SIZE, textinput_info[i].size,
5701 GDI_TEXT_FONT, FONT_INPUT_1,
5702 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
5703 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
5704 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
5705 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5706 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
5707 GDI_EVENT_MASK, event_mask,
5708 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5709 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
5713 Error(ERR_EXIT, "cannot create gadget");
5715 level_editor_gadget[id] = gi;
5719 static void CreateTextAreaGadgets()
5721 int max_infotext_len = getMaxInfoTextLength();
5724 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
5726 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5728 struct GadgetInfo *gi;
5729 unsigned long event_mask;
5730 char infotext[MAX_OUTPUT_LINESIZE + 1];
5731 int id = textarea_info[i].gadget_id;
5732 int area_xsize = textarea_info[i].xsize;
5733 int area_ysize = textarea_info[i].ysize;
5735 event_mask = GD_EVENT_TEXT_LEAVING;
5737 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
5738 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
5740 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
5741 infotext[max_infotext_len] = '\0';
5743 gi = CreateGadget(GDI_CUSTOM_ID, id,
5744 GDI_CUSTOM_TYPE_ID, i,
5745 GDI_INFO_TEXT, infotext,
5746 GDI_X, SX + textarea_info[i].x,
5747 GDI_Y, SY + textarea_info[i].y,
5748 GDI_TYPE, GD_TYPE_TEXT_AREA,
5749 GDI_AREA_SIZE, area_xsize, area_ysize,
5750 GDI_TEXT_FONT, FONT_INPUT_1,
5751 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
5752 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
5753 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
5754 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5755 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
5756 GDI_EVENT_MASK, event_mask,
5757 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5758 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
5762 Error(ERR_EXIT, "cannot create gadget");
5764 level_editor_gadget[id] = gi;
5768 static void CreateSelectboxGadgets()
5770 int max_infotext_len = getMaxInfoTextLength();
5773 for (i = 0; i < ED_NUM_SELECTBOX; i++)
5775 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5777 struct GadgetInfo *gi;
5778 unsigned long event_mask;
5779 char infotext[MAX_OUTPUT_LINESIZE + 1];
5780 int id = selectbox_info[i].gadget_id;
5781 int x = SX + selectbox_info[i].x;
5782 int y = SY + selectbox_info[i].y;
5784 if (selectbox_info[i].size == -1) /* dynamically determine size */
5786 /* (we cannot use -1 for uninitialized values if we directly compare
5787 with results from strlen(), because the '<' and '>' operation will
5788 implicitely cast -1 to an unsigned integer value!) */
5789 selectbox_info[i].size = 0;
5791 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
5792 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
5793 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
5795 selectbox_info[i].size++; /* add one character empty space */
5798 event_mask = GD_EVENT_RELEASED |
5799 GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
5801 gd_x = DOOR_GFX_PAGEX4 + ED_SELECTBOX_XPOS;
5802 gd_y = DOOR_GFX_PAGEY1 + ED_SELECTBOX_YPOS;
5804 /* determine horizontal position to the right of specified gadget */
5805 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
5806 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
5807 ED_GADGET_TEXT_DISTANCE);
5809 /* determine horizontal offset for leading text */
5810 if (selectbox_info[i].text_left != NULL)
5811 x += getTextWidthForGadget(selectbox_info[i].text_left);
5813 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
5814 infotext[max_infotext_len] = '\0';
5816 gi = CreateGadget(GDI_CUSTOM_ID, id,
5817 GDI_CUSTOM_TYPE_ID, i,
5818 GDI_INFO_TEXT, infotext,
5821 GDI_TYPE, GD_TYPE_SELECTBOX,
5822 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
5823 GDI_TEXT_SIZE, selectbox_info[i].size,
5824 GDI_TEXT_FONT, FONT_INPUT_1,
5825 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
5826 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
5827 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
5828 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5829 GDI_BORDER_SIZE_SELECTBUTTON, ED_SELECTBOX_BUTTON_XSIZE,
5830 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
5831 GDI_EVENT_MASK, event_mask,
5832 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5833 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
5837 Error(ERR_EXIT, "cannot create gadget");
5839 level_editor_gadget[id] = gi;
5840 right_gadget_border[id] =
5841 getRightGadgetBorder(gi, selectbox_info[i].text_right);
5845 static void CreateTextbuttonGadgets()
5847 int max_infotext_len = getMaxInfoTextLength();
5850 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
5852 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5853 int gd_x1, gd_x2, gd_y1, gd_y2;
5854 struct GadgetInfo *gi;
5855 unsigned long event_mask;
5856 char infotext[MAX_OUTPUT_LINESIZE + 1];
5857 int id = textbutton_info[i].gadget_id;
5858 int x = SX + textbutton_info[i].x;
5859 int y = SY + textbutton_info[i].y;
5861 if (textbutton_info[i].size == -1) /* dynamically determine size */
5862 textbutton_info[i].size = strlen(textbutton_info[i].text);
5864 event_mask = GD_EVENT_RELEASED;
5866 if ((id >= GADGET_ID_LEVELINFO_LEVEL && id <= GADGET_ID_LEVELINFO_EDITOR) ||
5867 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE))
5869 gd_x1 = DOOR_GFX_PAGEX4 + ED_TEXTBUTTON_TAB_XPOS;
5870 gd_x2 = DOOR_GFX_PAGEX3 + ED_TEXTBUTTON_TAB_XPOS;
5871 gd_y1 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_TAB_YPOS;
5872 gd_y2 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_TAB_INACTIVE_YPOS;
5876 gd_x1 = DOOR_GFX_PAGEX4 + ED_TEXTBUTTON_XPOS;
5877 gd_x2 = DOOR_GFX_PAGEX3 + ED_TEXTBUTTON_XPOS;
5878 gd_y1 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_YPOS;
5879 gd_y2 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_INACTIVE_YPOS;
5882 sprintf(infotext, "%s", textbutton_info[i].infotext);
5883 infotext[max_infotext_len] = '\0';
5885 /* determine horizontal position to the right of specified gadget */
5886 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
5887 x = (right_gadget_border[textbutton_info[i].gadget_id_align] +
5888 ED_GADGET_TEXT_DISTANCE);
5890 /* determine horizontal offset for leading text */
5891 if (textbutton_info[i].text_left != NULL)
5892 x += getTextWidthForGadget(textbutton_info[i].text_left);
5894 gi = CreateGadget(GDI_CUSTOM_ID, id,
5895 GDI_CUSTOM_TYPE_ID, i,
5896 GDI_INFO_TEXT, infotext,
5899 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
5900 GDI_TEXT_VALUE, textbutton_info[i].text,
5901 GDI_TEXT_SIZE, textbutton_info[i].size,
5902 GDI_TEXT_FONT, FONT_INPUT_2_ACTIVE,
5903 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2,
5904 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5905 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y1,
5906 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2,
5907 GDI_BORDER_SIZE, ED_BORDER_TEXT_XSIZE, ED_BORDER_SIZE,
5908 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
5909 GDI_DECORATION_SHIFTING, 1, 1,
5910 GDI_EVENT_MASK, event_mask,
5911 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5912 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
5916 Error(ERR_EXIT, "cannot create gadget");
5918 level_editor_gadget[id] = gi;
5919 right_gadget_border[id] =
5920 getRightGadgetBorder(gi, textbutton_info[i].text_right);
5924 static void CreateGraphicbuttonGadgets()
5926 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5927 struct GadgetInfo *gi;
5928 unsigned long event_mask;
5931 /* create buttons for scrolling of drawing area and element list */
5932 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
5934 int id = graphicbutton_info[i].gadget_id;
5935 int gd_x1, gd_x2, gd_y1, gd_y2;
5936 int x = SX + graphicbutton_info[i].x;
5937 int y = SY + graphicbutton_info[i].y;
5939 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5941 if (i <= ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
5943 gd_x1 = DOOR_GFX_PAGEX4 + graphicbutton_info[i].gd_x;
5944 gd_y1 = DOOR_GFX_PAGEY1 + graphicbutton_info[i].gd_y;
5945 gd_x2 = DOOR_GFX_PAGEX3 + graphicbutton_info[i].gd_x;
5948 else /* (i <= ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE) */
5950 gd_x1 = DOOR_GFX_PAGEX6 + graphicbutton_info[i].gd_x;
5951 gd_y1 = DOOR_GFX_PAGEY1 + graphicbutton_info[i].gd_y;
5952 gd_x2 = gd_x1 - ED_BUTTON_COUNT_XSIZE;
5956 /* determine horizontal position to the right of specified gadget */
5957 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
5958 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
5959 ED_GADGET_TEXT_DISTANCE);
5961 /* determine horizontal offset for leading text */
5962 if (graphicbutton_info[i].text_left != NULL)
5963 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
5965 gi = CreateGadget(GDI_CUSTOM_ID, id,
5966 GDI_CUSTOM_TYPE_ID, i,
5967 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
5970 GDI_WIDTH, graphicbutton_info[i].width,
5971 GDI_HEIGHT, graphicbutton_info[i].height,
5972 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
5973 GDI_STATE, GD_BUTTON_UNPRESSED,
5974 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5975 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
5976 GDI_EVENT_MASK, event_mask,
5977 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5978 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
5982 Error(ERR_EXIT, "cannot create gadget");
5984 level_editor_gadget[id] = gi;
5985 right_gadget_border[id] =
5986 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
5990 static void CreateScrollbarGadgets()
5994 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
5996 int id = scrollbar_info[i].gadget_id;
5997 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5998 int gd_x1, gd_x2, gd_y1, gd_y2;
5999 struct GadgetInfo *gi;
6000 int items_max, items_visible, item_position;
6001 unsigned long event_mask;
6003 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
6005 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
6006 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
6007 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
6009 else /* drawing area scrollbars */
6011 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
6013 items_max = MAX(lev_fieldx + 2, ed_fieldx);
6014 items_visible = ed_fieldx;
6019 items_max = MAX(lev_fieldy + 2, ed_fieldy);
6020 items_visible = ed_fieldy;
6025 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
6027 gd_x1 = DOOR_GFX_PAGEX8 + scrollbar_info[i].gd_x;
6028 gd_x2 = (gd_x1 - (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL ?
6029 scrollbar_info[i].height : scrollbar_info[i].width));
6030 gd_y1 = DOOR_GFX_PAGEY1 + scrollbar_info[i].gd_y;
6031 gd_y2 = DOOR_GFX_PAGEY1 + scrollbar_info[i].gd_y;
6033 gi = CreateGadget(GDI_CUSTOM_ID, id,
6034 GDI_CUSTOM_TYPE_ID, i,
6035 GDI_INFO_TEXT, scrollbar_info[i].infotext,
6036 GDI_X, scrollbar_info[i].x,
6037 GDI_Y, scrollbar_info[i].y,
6038 GDI_WIDTH, scrollbar_info[i].width,
6039 GDI_HEIGHT, scrollbar_info[i].height,
6040 GDI_TYPE, scrollbar_info[i].type,
6041 GDI_SCROLLBAR_ITEMS_MAX, items_max,
6042 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
6043 GDI_SCROLLBAR_ITEM_POSITION, item_position,
6044 GDI_WHEEL_AREA_X, scrollbar_info[i].wheel_x,
6045 GDI_WHEEL_AREA_Y, scrollbar_info[i].wheel_y,
6046 GDI_WHEEL_AREA_WIDTH, scrollbar_info[i].wheel_width,
6047 GDI_WHEEL_AREA_HEIGHT, scrollbar_info[i].wheel_height,
6048 GDI_STATE, GD_BUTTON_UNPRESSED,
6049 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6050 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6051 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
6052 GDI_EVENT_MASK, event_mask,
6053 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6054 GDI_CALLBACK_ACTION, HandleControlButtons,
6058 Error(ERR_EXIT, "cannot create gadget");
6060 level_editor_gadget[id] = gi;
6064 static void CreateCheckbuttonGadgets()
6066 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
6067 struct GadgetInfo *gi;
6068 unsigned long event_mask;
6069 int gd_x1, gd_x2, gd_x3, gd_x4, gd_y;
6072 event_mask = GD_EVENT_PRESSED;
6074 gd_x1 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_UNCHECKED_XPOS;
6075 gd_x2 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_UNCHECKED_XPOS;
6076 gd_x3 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_CHECKED_XPOS;
6077 gd_x4 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_CHECKED_XPOS;
6078 gd_y = DOOR_GFX_PAGEY1 + ED_RADIOBUTTON_YPOS;
6080 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
6082 int id = checkbutton_info[i].gadget_id;
6083 int x = SX + checkbutton_info[i].x;
6084 int y = SY + checkbutton_info[i].y;
6086 if (id == GADGET_ID_STICK_ELEMENT)
6087 gd_y = DOOR_GFX_PAGEY1 + ED_STICKYBUTTON_YPOS;
6089 gd_y = DOOR_GFX_PAGEY1 + ED_CHECKBUTTON_YPOS;
6091 /* determine horizontal position to the right of specified gadget */
6092 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6093 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
6094 ED_GADGET_TEXT_DISTANCE);
6096 /* determine horizontal offset for leading text */
6097 if (checkbutton_info[i].text_left != NULL)
6098 x += getTextWidthForGadget(checkbutton_info[i].text_left);
6100 gi = CreateGadget(GDI_CUSTOM_ID, id,
6101 GDI_CUSTOM_TYPE_ID, i,
6102 GDI_INFO_TEXT, checkbutton_info[i].infotext,
6105 GDI_WIDTH, ED_CHECKBUTTON_XSIZE,
6106 GDI_HEIGHT, ED_CHECKBUTTON_YSIZE,
6107 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
6108 GDI_CHECKED, *checkbutton_info[i].value,
6109 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
6110 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
6111 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y,
6112 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y,
6113 GDI_EVENT_MASK, event_mask,
6114 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6115 GDI_CALLBACK_ACTION, HandleCheckbuttons,
6119 Error(ERR_EXIT, "cannot create gadget");
6121 level_editor_gadget[id] = gi;
6122 right_gadget_border[id] =
6123 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
6127 static void CreateRadiobuttonGadgets()
6129 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
6130 struct GadgetInfo *gi;
6131 unsigned long event_mask;
6132 int gd_x1, gd_x2, gd_x3, gd_x4, gd_y;
6135 event_mask = GD_EVENT_PRESSED;
6137 gd_x1 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_UNCHECKED_XPOS;
6138 gd_x2 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_UNCHECKED_XPOS;
6139 gd_x3 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_CHECKED_XPOS;
6140 gd_x4 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_CHECKED_XPOS;
6141 gd_y = DOOR_GFX_PAGEY1 + ED_RADIOBUTTON_YPOS;
6143 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
6145 int id = radiobutton_info[i].gadget_id;
6146 int x = SX + radiobutton_info[i].x;
6147 int y = SY + radiobutton_info[i].y;
6150 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
6152 /* determine horizontal position to the right of specified gadget */
6153 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
6154 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
6155 ED_GADGET_TEXT_DISTANCE);
6157 /* determine horizontal offset for leading text */
6158 if (radiobutton_info[i].text_left != NULL)
6159 x += getTextWidthForGadget(radiobutton_info[i].text_left);
6161 gi = CreateGadget(GDI_CUSTOM_ID, id,
6162 GDI_CUSTOM_TYPE_ID, i,
6163 GDI_INFO_TEXT, radiobutton_info[i].infotext,
6166 GDI_WIDTH, ED_CHECKBUTTON_XSIZE,
6167 GDI_HEIGHT, ED_CHECKBUTTON_YSIZE,
6168 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
6169 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
6170 GDI_CHECKED, checked,
6171 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
6172 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
6173 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y,
6174 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y,
6175 GDI_EVENT_MASK, event_mask,
6176 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6177 GDI_CALLBACK_ACTION, HandleRadiobuttons,
6181 Error(ERR_EXIT, "cannot create gadget");
6183 level_editor_gadget[id] = gi;
6184 right_gadget_border[id] =
6185 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
6189 void CreateLevelEditorGadgets()
6191 int old_game_status = game_status;
6193 /* setting 'game_status' is needed to get the right fonts for the editor */
6194 game_status = GAME_MODE_EDITOR;
6196 ReinitializeElementList();
6198 CreateControlButtons();
6199 CreateScrollbarGadgets();
6201 /* order of function calls is important because of cross-references */
6202 CreateCheckbuttonGadgets();
6203 CreateCounterButtons();
6204 CreateRadiobuttonGadgets();
6205 CreateTextInputGadgets();
6206 CreateTextAreaGadgets();
6207 CreateSelectboxGadgets();
6208 CreateGraphicbuttonGadgets();
6209 CreateTextbuttonGadgets();
6210 CreateDrawingAreas();
6212 game_status = old_game_status;
6215 void FreeLevelEditorGadgets()
6219 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
6221 FreeGadget(level_editor_gadget[i]);
6223 level_editor_gadget[i] = NULL;
6227 static void MapCounterButtons(int id)
6229 int gadget_id_down = counterbutton_info[id].gadget_id_down;
6230 int gadget_id_text = counterbutton_info[id].gadget_id_text;
6231 int gadget_id_up = counterbutton_info[id].gadget_id_up;
6232 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
6233 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
6234 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
6235 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
6236 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6237 int yoffset_above = MINI_TILEX + ED_GADGET_DISTANCE;
6238 int yoffset = ED_BORDER_SIZE;
6239 int x_left = gi_down->x - xoffset_left;
6240 int x_right; /* set after gadget position was modified */
6241 int y_above = gi_down->y - yoffset_above;
6243 int y; /* set after gadget position was modified */
6245 /* counter limits must be changed first to prevent value truncation */
6246 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
6247 counterbutton_info[id].max_value);
6249 /* right text position might have changed after setting position above */
6250 x_right = gi_up->x + gi_up->width + xoffset_right;
6252 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
6254 /* set position for "value[1,2,3,4]" counter gadgets (score in most cases) */
6255 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
6256 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
6258 ModifyGadget(gi_down, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
6259 ModifyGadget(gi_text, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
6260 ModifyGadget(gi_up, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
6263 /* vertical position might have changed after setting position above */
6264 y = gi_up->y + yoffset;
6266 if (counterbutton_info[id].text_above)
6267 DrawText(x, y_above, counterbutton_info[id].text_above, FONT_TEXT_1);
6269 if (counterbutton_info[id].text_left)
6270 DrawText(x_left, y, counterbutton_info[id].text_left, FONT_TEXT_1);
6272 if (counterbutton_info[id].text_right)
6273 DrawText(x_right, y, counterbutton_info[id].text_right, FONT_TEXT_1);
6280 static void MapControlButtons()
6285 /* map toolbox buttons (excluding special CE toolbox buttons) */
6286 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
6287 MapGadget(level_editor_gadget[i]);
6289 /* map buttons to select elements */
6290 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6291 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
6292 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
6293 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
6294 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
6296 /* map buttons to select level */
6297 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
6298 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
6299 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
6300 MapCounterButtons(counter_id);
6303 static void MapDrawingArea(int id)
6305 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6306 int area_xsize = gi->drawing.area_xsize;
6307 int area_ysize = gi->drawing.area_ysize;
6308 int xoffset_left= getTextWidthForDrawingArea(drawingarea_info[id].text_left);
6309 int xoffset_below= getTextWidth(drawingarea_info[id].text_below,FONT_TEXT_1);
6310 int x_left = gi->x - xoffset_left;
6311 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
6312 int x_below = gi->x + (gi->width - xoffset_below) / 2;
6313 int y_side = gi->y + (gi->height - getFontHeight(FONT_TEXT_1)) / 2;
6314 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
6316 if (drawingarea_info[id].text_left)
6317 DrawText(x_left, y_side, drawingarea_info[id].text_left, FONT_TEXT_1);
6319 if (drawingarea_info[id].text_right)
6320 DrawText(x_right, y_side, drawingarea_info[id].text_right, FONT_TEXT_1);
6322 if (drawingarea_info[id].text_below)
6323 DrawText(x_below, y_below, drawingarea_info[id].text_below, FONT_TEXT_1);
6325 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
6327 DrawElementBorder(gi->x, gi->y,
6328 area_xsize * MINI_TILEX, area_ysize * MINI_TILEY, TRUE);
6330 DrawDrawingArea(id);
6336 static void MapTextInputGadget(int id)
6338 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
6339 int xoffset_above = 0;
6340 int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
6341 int x_above = textinput_info[id].x + xoffset_above;
6342 int y_above = textinput_info[id].y + yoffset_above;
6344 if (textinput_info[id].text_above)
6345 DrawTextS(x_above, y_above, FONT_TEXT_1, textinput_info[id].text_above);
6347 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
6352 static void MapTextAreaGadget(int id)
6354 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
6355 int xoffset_above = 0;
6356 int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
6357 int x_above = textarea_info[id].x + xoffset_above;
6358 int y_above = textarea_info[id].y + yoffset_above;
6360 if (textarea_info[id].text_above)
6361 DrawTextS(x_above, y_above, FONT_TEXT_1, textarea_info[id].text_above);
6363 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
6368 static void MapSelectboxGadget(int id)
6370 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
6371 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
6372 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6373 int yoffset = ED_BORDER_SIZE;
6374 int x_left = gi->x - xoffset_left;
6375 int x_right = gi->x + gi->width + xoffset_right;
6376 int y = gi->y + yoffset;
6378 if (selectbox_info[id].text_left)
6379 DrawText(x_left, y, selectbox_info[id].text_left, FONT_TEXT_1);
6381 if (selectbox_info[id].text_right)
6382 DrawText(x_right, y, selectbox_info[id].text_right, FONT_TEXT_1);
6384 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
6389 static void MapTextbuttonGadget(int id)
6391 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
6392 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
6393 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6394 int yoffset = ED_BORDER_SIZE;
6395 int x_left = gi->x - xoffset_left;
6396 int x_right = gi->x + gi->width + xoffset_right;
6397 int y = gi->y + yoffset;
6399 /* only show button to delete change pages when more than minimum pages */
6400 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
6401 custom_element.num_change_pages == MIN_CHANGE_PAGES)
6404 if (textbutton_info[id].text_left)
6405 DrawText(x_left, y, textbutton_info[id].text_left, FONT_TEXT_1);
6407 if (textbutton_info[id].text_right)
6408 DrawText(x_right, y, textbutton_info[id].text_right, FONT_TEXT_1);
6413 static void MapGraphicbuttonGadget(int id)
6415 struct GadgetInfo *gi= level_editor_gadget[graphicbutton_info[id].gadget_id];
6416 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
6417 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6418 int yoffset = ED_BORDER_SIZE;
6419 int x_left = gi->x - xoffset_left;
6420 int x_right = gi->x + gi->width + xoffset_right;
6421 int y = gi->y + yoffset;
6423 if (graphicbutton_info[id].text_left)
6424 DrawText(x_left, y, graphicbutton_info[id].text_left, FONT_TEXT_1);
6426 if (graphicbutton_info[id].text_right)
6427 DrawText(x_right, y, graphicbutton_info[id].text_right, FONT_TEXT_1);
6432 static void MapRadiobuttonGadget(int id)
6434 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
6435 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
6436 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6437 int yoffset = ED_BORDER_SIZE;
6438 int x_left = gi->x - xoffset_left;
6439 int x_right = gi->x + gi->width + xoffset_right;
6440 int y = gi->y + yoffset;
6442 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
6444 if (radiobutton_info[id].text_left)
6445 DrawText(x_left, y, radiobutton_info[id].text_left, FONT_TEXT_1);
6447 if (radiobutton_info[id].text_right)
6448 DrawText(x_right, y, radiobutton_info[id].text_right, FONT_TEXT_1);
6450 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
6455 static void MapCheckbuttonGadget(int id)
6457 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
6458 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
6459 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6460 int yoffset = ED_BORDER_SIZE;
6461 int x_left, x_right, y; /* set after gadget position was modified */
6463 /* set position for gadgets with dynamically determined position */
6464 if (checkbutton_info[id].x != -1) /* do not change dynamic positions */
6465 ModifyGadget(gi, GDI_X, SX + checkbutton_info[id].x, GDI_END);
6466 ModifyGadget(gi, GDI_Y, SY + checkbutton_info[id].y, GDI_END);
6468 x_left = gi->x - xoffset_left;
6469 x_right = gi->x + gi->width + xoffset_right;
6470 y = gi->y + yoffset;
6472 if (checkbutton_info[id].text_left)
6473 DrawText(x_left, y, checkbutton_info[id].text_left, FONT_TEXT_1);
6475 if (checkbutton_info[id].text_right)
6476 DrawText(x_right, y, checkbutton_info[id].text_right, FONT_TEXT_1);
6478 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
6483 static void MapMainDrawingArea()
6485 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
6486 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
6489 for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
6491 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
6492 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
6493 no_horizontal_scrollbar) ||
6494 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
6495 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
6496 no_vertical_scrollbar))
6499 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
6502 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
6504 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
6505 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
6508 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
6511 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
6514 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
6518 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6520 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
6521 i == GADGET_ID_CUSTOM_COPY_TO ||
6522 i == GADGET_ID_CUSTOM_EXCHANGE ||
6523 i == GADGET_ID_CUSTOM_COPY ||
6524 i == GADGET_ID_CUSTOM_PASTE)
6527 MapGadget(level_editor_gadget[i]);
6529 UnmapGadget(level_editor_gadget[i]);
6534 static void MapLevelEditorToolboxCustomGadgets()
6536 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
6539 static void UnmapLevelEditorToolboxCustomGadgets()
6541 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
6544 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
6546 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
6549 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
6551 if (i != GADGET_ID_SINGLE_ITEMS &&
6552 i != GADGET_ID_PROPERTIES &&
6553 i != GADGET_ID_PICK_ELEMENT)
6555 struct GadgetInfo *gi = level_editor_gadget[i];
6563 BlitBitmap(gd_bitmap, drawto,
6564 DOOR_GFX_PAGEX6 + ED_CTRL_NO_BUTTONS_GFX_XPOS,
6565 DOOR_GFX_PAGEY1 + ED_CTRL_NO_BUTTONS_GFX_YPOS,
6566 gi->width, gi->height, gi->x, gi->y);
6568 redraw_mask |= REDRAW_DOOR_3;
6574 static void MapLevelEditorToolboxDrawingGadgets()
6576 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
6579 static void UnmapLevelEditorToolboxDrawingGadgets()
6581 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
6584 static void UnmapDrawingArea(int id)
6586 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
6589 static void UnmapLevelEditorWindowGadgets()
6593 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
6594 if (level_editor_gadget[i]->x < SX + SXSIZE)
6595 UnmapGadget(level_editor_gadget[i]);
6598 void UnmapLevelEditorGadgets()
6602 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
6603 UnmapGadget(level_editor_gadget[i]);
6606 static void ResetUndoBuffer()
6608 undo_buffer_position = -1;
6609 undo_buffer_steps = -1;
6610 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
6612 level.changed = FALSE;
6615 static void DrawEditModeWindow()
6617 ModifyEditorElementList();
6618 RedrawDrawingElements();
6620 if (edit_mode == ED_MODE_INFO)
6621 DrawLevelInfoWindow();
6622 else if (edit_mode == ED_MODE_PROPERTIES)
6623 DrawPropertiesWindow();
6624 else /* edit_mode == ED_MODE_DRAWING */
6625 DrawDrawingWindow();
6628 static boolean LevelChanged()
6630 boolean field_changed = FALSE;
6633 if (leveldir_current->readonly)
6636 for (y = 0; y < lev_fieldy; y++)
6637 for (x = 0; x < lev_fieldx; x++)
6638 if (Feld[x][y] != level.field[x][y])
6639 field_changed = TRUE;
6641 return (level.changed || field_changed);
6644 static boolean LevelContainsPlayer()
6646 boolean player_found = FALSE;
6649 return TRUE; /* !!! CURRENTLY DEACTIVATED !!! */
6651 for (y = 0; y < lev_fieldy; y++) for (x = 0; x < lev_fieldx; x++)
6653 if (Feld[x][y] == EL_PLAYER_1 ||
6654 Feld[x][y] == EL_SP_MURPHY)
6655 player_found = TRUE;
6658 return player_found;
6661 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
6662 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
6666 for (x = 0; x < lev_fieldx; x++)
6667 for (y = 0; y < lev_fieldy; y++)
6668 dst[x][y] = src[x][y];
6671 static int setSelectboxValue(int selectbox_id, int new_value)
6673 int new_index_value = 0;
6676 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
6677 if (selectbox_info[selectbox_id].options[i].value == new_value)
6678 new_index_value = i;
6680 *selectbox_info[selectbox_id].value =
6681 selectbox_info[selectbox_id].options[new_index_value].value;
6683 return new_index_value;
6686 static void setSelectboxSpecialActionVariablesIfNeeded()
6690 /* change action mode and arg variables according to action type variable */
6691 for (i = 0; action_arg_options[i].value != -1; i++)
6693 if (action_arg_options[i].value == custom_element_change.action_type)
6695 int mode = action_arg_options[i].mode;
6697 /* only change if corresponding selectbox has changed */
6698 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
6699 action_arg_modes[mode])
6700 custom_element_change.action_mode = -1;
6702 /* only change if corresponding selectbox has changed */
6703 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
6704 action_arg_options[i].options)
6705 custom_element_change.action_arg = -1;
6712 static void setSelectboxSpecialActionOptions()
6716 /* change action mode and arg selectbox according to action type selectbox */
6717 for (i = 0; action_arg_options[i].value != -1; i++)
6719 if (action_arg_options[i].value == custom_element_change.action_type)
6721 int mode = action_arg_options[i].mode;
6723 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
6724 action_arg_modes[mode]);
6725 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
6726 custom_element_change.action_mode);
6728 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
6729 action_arg_options[i].options);
6730 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
6731 custom_element_change.action_arg);
6737 static void copy_custom_element_settings(int element_from, int element_to)
6739 struct ElementInfo *ei_from = &element_info[element_from];
6740 struct ElementInfo *ei_to = &element_info[element_to];
6742 copyElementInfo(ei_from, ei_to);
6745 static void replace_custom_element_in_settings(int element_from,
6750 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6752 struct ElementInfo *ei = &element_info[i];
6754 for (y = 0; y < 3; y++)
6755 for (x = 0; x < 3; x++)
6756 if (ei->content.e[x][y] == element_from)
6757 ei->content.e[x][y] = element_to;
6759 for (j = 0; j < ei->num_change_pages; j++)
6761 struct ElementChangeInfo *change = &ei->change_page[j];
6763 if (change->target_element == element_from)
6764 change->target_element = element_to;
6766 if (change->initial_trigger_element == element_from)
6767 change->initial_trigger_element = element_to;
6769 if (change->action_element == element_from)
6770 change->action_element = element_to;
6772 for (y = 0; y < 3; y++)
6773 for (x = 0; x < 3; x++)
6774 if (change->target_content.e[x][y] == element_from)
6775 change->target_content.e[x][y] = element_to;
6778 if (ei->group != NULL) /* group or internal */
6779 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
6780 if (ei->group->element[j] == element_from)
6781 ei->group->element[j] = element_to;
6785 static void replace_custom_element_in_playfield(int element_from,
6790 for (x = 0; x < lev_fieldx; x++)
6791 for (y = 0; y < lev_fieldy; y++)
6792 if (Feld[x][y] == element_from)
6793 Feld[x][y] = element_to;
6796 static boolean CopyCustomElement(int element_old, int element_new,
6799 if (copy_mode == GADGET_ID_CUSTOM_COPY)
6801 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
6802 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
6803 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
6805 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
6807 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
6808 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
6809 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
6811 level.changed = TRUE;
6813 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
6815 Request("Please choose custom element !", REQ_CONFIRM);
6819 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
6821 Request("Please choose group element !", REQ_CONFIRM);
6827 level.changed = TRUE;
6830 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
6832 copy_custom_element_settings(element_new, element_old);
6834 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
6836 copy_custom_element_settings(element_old, element_new);
6838 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
6840 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
6841 copy_custom_element_settings(element_new, element_old);
6842 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
6844 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
6845 replace_custom_element_in_settings(element_new, element_old);
6846 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
6848 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
6849 replace_custom_element_in_playfield(element_new, element_old);
6850 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
6853 UpdateCustomElementGraphicGadgets();
6854 DrawPropertiesWindow();
6859 static void CopyCustomElementPropertiesToEditor(int element)
6862 int current_change_page = element_info[element].current_change_page;
6864 /* dynamically (re)build selectbox for selecting change page */
6865 for (i = 0; i < element_info[element].num_change_pages; i++)
6867 sprintf(options_change_page_strings[i], "%d", i + 1);
6869 options_change_page[i].value = i;
6870 options_change_page[i].text = options_change_page_strings[i];
6873 options_change_page[i].value = -1;
6874 options_change_page[i].text = NULL;
6876 /* needed here to initialize combined element properties */
6877 InitElementPropertiesEngine(level.game_version);
6879 element_info[element].change =
6880 &element_info[element].change_page[current_change_page];
6882 custom_element = element_info[element];
6883 custom_element_change = *element_info[element].change;
6885 /* needed to initially set selectbox options for special action options */
6886 setSelectboxSpecialActionOptions();
6888 /* needed to initially set selectbox value variables to reliable defaults */
6889 for (i = 0; i < ED_NUM_SELECTBOX; i++)
6890 setSelectboxValue(i, *selectbox_info[i].value);
6892 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
6893 custom_element_properties[i] = HAS_PROPERTY(element, i);
6895 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
6896 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
6898 /* ---------- element settings: configure (custom elements) ------------- */
6900 /* set accessible layer selectbox help value */
6901 custom_element.access_type =
6902 (IS_WALKABLE(element) ? EP_WALKABLE :
6903 IS_PASSABLE(element) ? EP_PASSABLE :
6904 custom_element.access_type);
6905 custom_element.access_layer =
6906 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
6907 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
6908 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
6909 custom_element.access_layer);
6910 custom_element.access_protected =
6911 (IS_PROTECTED(element) ? 1 : 0);
6912 custom_element_properties[EP_ACCESSIBLE] =
6913 (IS_ACCESSIBLE_OVER(element) ||
6914 IS_ACCESSIBLE_INSIDE(element) ||
6915 IS_ACCESSIBLE_UNDER(element));
6917 /* set walk-to-object action selectbox help value */
6918 custom_element.walk_to_action =
6919 (IS_DIGGABLE(element) ? EP_DIGGABLE :
6920 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
6921 IS_DROPPABLE(element) ? EP_DROPPABLE :
6922 IS_THROWABLE(element) ? EP_THROWABLE :
6923 IS_PUSHABLE(element) ? EP_PUSHABLE :
6924 custom_element.walk_to_action);
6925 custom_element_properties[EP_WALK_TO_OBJECT] =
6926 (IS_DIGGABLE(element) ||
6927 IS_COLLECTIBLE_ONLY(element) ||
6928 IS_DROPPABLE(element) ||
6929 IS_THROWABLE(element) ||
6930 IS_PUSHABLE(element));
6932 /* set smash targets selectbox help value */
6933 custom_element.smash_targets =
6934 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
6935 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
6936 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
6937 custom_element.smash_targets);
6938 custom_element_properties[EP_CAN_SMASH] =
6939 (CAN_SMASH_EVERYTHING(element) ||
6940 CAN_SMASH_ENEMIES(element) ||
6941 CAN_SMASH_PLAYER(element));
6943 /* set deadliness selectbox help value */
6944 custom_element.deadliness =
6945 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
6946 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
6947 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
6948 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
6949 custom_element.deadliness);
6950 custom_element_properties[EP_DEADLY] =
6951 (DONT_TOUCH(element) ||
6952 DONT_GET_HIT_BY(element) ||
6953 DONT_COLLIDE_WITH(element) ||
6954 DONT_RUN_INTO(element));
6956 /* ---------- element settings: advanced (custom elements) --------------- */
6958 /* set "change by direct action" selectbox help value */
6959 custom_element_change.direct_action =
6960 (HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
6961 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
6962 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
6963 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
6964 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
6965 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
6966 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
6967 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
6968 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
6969 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
6970 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
6971 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
6972 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
6973 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
6974 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
6975 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
6976 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
6977 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
6978 custom_element_change.direct_action);
6980 /* set "change by other element action" selectbox help value */
6981 custom_element_change.other_action =
6982 (HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
6983 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
6984 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
6985 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
6986 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
6987 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
6988 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
6989 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
6990 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
6991 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
6992 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
6993 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
6994 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
6995 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
6996 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
6997 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
6998 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
6999 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
7000 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
7001 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
7002 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
7003 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
7004 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
7005 custom_element_change.other_action);
7008 static void CopyGroupElementPropertiesToEditor(int element)
7010 group_element_info = *element_info[element].group;
7011 custom_element = element_info[element]; /* needed for description */
7014 static void CopyClassicElementPropertiesToEditor(int element)
7016 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
7017 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
7018 getMoveIntoAcidProperty(&level, element);
7020 if (MAYBE_DONT_COLLIDE_WITH(element))
7021 custom_element_properties[EP_DONT_COLLIDE_WITH] =
7022 getDontCollideWithProperty(&level, element);
7025 static void CopyElementPropertiesToEditor(int element)
7027 if (IS_CUSTOM_ELEMENT(element))
7028 CopyCustomElementPropertiesToEditor(element);
7029 else if (IS_GROUP_ELEMENT(element))
7030 CopyGroupElementPropertiesToEditor(element);
7032 CopyClassicElementPropertiesToEditor(element);
7035 static void CopyCustomElementPropertiesToGame(int element)
7038 int access_type_and_layer;
7040 /* mark that this custom element has been modified */
7041 custom_element.modified_settings = TRUE;
7042 level.changed = TRUE;
7044 if (level.use_custom_template)
7046 if (Request("Copy and modify level template ?", REQ_ASK))
7048 level.use_custom_template = FALSE;
7049 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE],
7050 GDI_CHECKED, FALSE, GDI_END);
7054 LoadLevelTemplate(-1); /* this resets all element modifications ... */
7056 DrawEditModeWindow(); /* ... and copies them to 'custom_element' */
7060 element_info[element] = custom_element;
7061 *element_info[element].change = custom_element_change;
7063 /* ---------- element settings: configure (custom elements) ------------- */
7065 /* set accessible property from checkbox and selectbox */
7066 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
7067 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
7068 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
7069 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
7070 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
7071 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
7072 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
7073 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
7074 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
7075 custom_element_properties[access_type_and_layer] =
7076 custom_element_properties[EP_ACCESSIBLE];
7077 custom_element_properties[EP_PROTECTED] =
7078 (custom_element.access_protected != 0 &&
7079 custom_element_properties[EP_ACCESSIBLE]);
7081 /* set walk-to-object property from checkbox and selectbox */
7082 custom_element_properties[EP_DIGGABLE] = FALSE;
7083 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
7084 custom_element_properties[EP_DROPPABLE] = FALSE;
7085 custom_element_properties[EP_THROWABLE] = FALSE;
7086 custom_element_properties[EP_PUSHABLE] = FALSE;
7087 custom_element_properties[custom_element.walk_to_action] =
7088 custom_element_properties[EP_WALK_TO_OBJECT];
7090 /* set smash property from checkbox and selectbox */
7091 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
7092 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
7093 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
7094 custom_element_properties[custom_element.smash_targets] =
7095 custom_element_properties[EP_CAN_SMASH];
7097 /* set deadliness property from checkbox and selectbox */
7098 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
7099 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
7100 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
7101 custom_element_properties[EP_DONT_TOUCH] = FALSE;
7102 custom_element_properties[custom_element.deadliness] =
7103 custom_element_properties[EP_DEADLY];
7105 /* ---------- element settings: advanced (custom elements) --------------- */
7107 /* set player change event from checkbox and selectbox */
7108 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
7109 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
7110 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
7111 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
7112 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
7113 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
7114 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
7115 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
7116 custom_element_change_events[CE_SWITCHED] = FALSE;
7117 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
7118 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
7119 custom_element_change_events[CE_BLOCKED] = FALSE;
7120 custom_element_change_events[CE_IMPACT] = FALSE;
7121 custom_element_change_events[CE_SMASHED] = FALSE;
7122 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
7123 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
7124 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
7125 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
7126 custom_element_change_events[custom_element_change.direct_action] =
7127 custom_element_change_events[CE_BY_DIRECT_ACTION];
7129 /* set other element action change event from checkbox and selectbox */
7130 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
7131 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
7132 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
7133 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
7134 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
7135 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
7136 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
7137 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
7138 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
7139 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
7140 custom_element_change_events[CE_TOUCHING_X] = FALSE;
7141 custom_element_change_events[CE_HITTING_X] = FALSE;
7142 custom_element_change_events[CE_DIGGING_X] = FALSE;
7143 custom_element_change_events[CE_HIT_BY_X] = FALSE;
7144 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
7145 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
7146 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
7147 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
7148 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
7149 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
7150 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
7151 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
7152 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
7153 custom_element_change_events[custom_element_change.other_action] =
7154 custom_element_change_events[CE_BY_OTHER_ACTION];
7156 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
7157 SET_PROPERTY(element, i, custom_element_properties[i]);
7159 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
7160 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
7162 /* copy change events also to special level editor variable */
7163 custom_element = element_info[element];
7164 custom_element_change = *element_info[element].change;
7167 static void CopyGroupElementPropertiesToGame(int element)
7169 element_info[element] = custom_element;
7170 *element_info[element].group = group_element_info;
7172 /* mark that this group element has been modified */
7173 element_info[element].modified_settings = TRUE;
7174 level.changed = TRUE;
7177 static void CopyClassicElementPropertiesToGame(int element)
7179 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
7180 setMoveIntoAcidProperty(&level, element,
7181 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
7183 if (MAYBE_DONT_COLLIDE_WITH(element))
7184 setDontCollideWithProperty(&level, element,
7185 custom_element_properties[EP_DONT_COLLIDE_WITH]);
7188 static void CopyElementPropertiesToGame(int element)
7190 if (IS_CUSTOM_ELEMENT(element))
7191 CopyCustomElementPropertiesToGame(element);
7192 else if (IS_GROUP_ELEMENT(element))
7193 CopyGroupElementPropertiesToGame(element);
7195 CopyClassicElementPropertiesToGame(element);
7198 void CheckElementDescriptions()
7202 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
7203 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
7204 Error(ERR_WARN, "no element description for element '%s'", EL_NAME(i));
7211 CloseDoor(DOOR_CLOSE_ALL);
7214 FadeOut(REDRAW_FIELD);
7217 OpenDoor(DOOR_OPEN_2 | DOOR_NO_DELAY);
7220 CheckElementDescriptions();
7223 if (level_editor_test_game)
7225 CopyPlayfield(level.field, Feld);
7226 CopyPlayfield(FieldBackup, level.field);
7228 level_editor_test_game = FALSE;
7232 edit_mode = ED_MODE_DRAWING;
7233 edit_mode_levelinfo = ED_MODE_LEVELINFO_LEVEL;
7234 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
7242 /* copy default editor door content to main double buffer */
7243 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
7244 DOOR_GFX_PAGEX6, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
7246 /* draw bigger door */
7247 DrawSpecialEditorDoor();
7249 /* draw new control window */
7250 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
7251 DOOR_GFX_PAGEX8, 236, EXSIZE, EYSIZE, EX, EY);
7253 redraw_mask |= REDRAW_ALL;
7255 ReinitializeElementList(); /* update dynamic level element list */
7256 ReinitializeElementListButtons(); /* custom element may look different */
7258 InitElementPropertiesGfxElement();
7265 MapControlButtons();
7268 FadeOut(REDRAW_FIELD);
7271 DrawEditModeWindow();
7274 FadeIn(REDRAW_FIELD);
7277 /* copy actual editor door content to door double buffer for OpenDoor() */
7278 BlitBitmap(drawto, bitmap_db_door,
7279 DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
7282 /* draw new control window (with border) to window */
7283 redraw_mask |= REDRAW_ALL;
7287 OpenDoor(DOOR_OPEN_1);
7290 static void AdjustDrawingAreaGadgets()
7292 int ed_xsize = lev_fieldx + 2;
7293 int ed_ysize = lev_fieldy + 2;
7294 int max_ed_fieldx = MAX_ED_FIELDX;
7295 int max_ed_fieldy = MAX_ED_FIELDY;
7296 boolean horizontal_scrollbar_needed;
7297 boolean vertical_scrollbar_needed;
7298 int x, y, width, height;
7299 int xoffset, yoffset;
7301 /* check if we need any scrollbars */
7302 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
7303 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
7305 /* check if we have a smaller editor field because of scrollbars */
7306 if (horizontal_scrollbar_needed)
7307 max_ed_fieldy = MAX_ED_FIELDY - 1;
7308 if (vertical_scrollbar_needed)
7309 max_ed_fieldx = MAX_ED_FIELDX - 1;
7311 /* check again if we now need more scrollbars because of less space */
7312 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
7313 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
7315 /* check if editor field gets even smaller after adding new scrollbars */
7316 if (horizontal_scrollbar_needed)
7317 max_ed_fieldy = MAX_ED_FIELDY - 1;
7318 if (vertical_scrollbar_needed)
7319 max_ed_fieldx = MAX_ED_FIELDX - 1;
7321 ed_fieldx = (ed_xsize < MAX_ED_FIELDX ? ed_xsize : max_ed_fieldx);
7322 ed_fieldy = (ed_ysize < MAX_ED_FIELDY ? ed_ysize : max_ed_fieldy);
7324 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
7325 GDI_WIDTH, ed_fieldx * MINI_TILEX,
7326 GDI_HEIGHT, ed_fieldy * MINI_TILEY,
7327 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
7330 xoffset = (ed_fieldx == MAX_ED_FIELDX ? ED_SCROLLBUTTON_XSIZE : 0);
7331 yoffset = (ed_fieldy == MAX_ED_FIELDY ? ED_SCROLLBUTTON_YSIZE : 0);
7333 x = SX + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_RIGHT].x + xoffset;
7334 y = SX + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_DOWN].y + yoffset;
7336 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT], GDI_X, x, GDI_END);
7337 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN], GDI_Y, y, GDI_END);
7339 width = scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width + xoffset;
7340 height = scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].height + yoffset;
7342 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
7344 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
7346 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
7348 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
7352 static void AdjustLevelScrollPosition()
7354 if (level_xpos < -1)
7356 if (level_xpos > lev_fieldx - ed_fieldx + 1)
7357 level_xpos = lev_fieldx - ed_fieldx + 1;
7358 if (lev_fieldx < ed_fieldx - 2)
7361 if (level_ypos < -1)
7363 if (level_ypos > lev_fieldy - ed_fieldy + 1)
7364 level_ypos = lev_fieldy - ed_fieldy + 1;
7365 if (lev_fieldy < ed_fieldy - 2)
7369 static void AdjustEditorScrollbar(int id)
7371 struct GadgetInfo *gi = level_editor_gadget[id];
7372 int items_max, items_visible, item_position;
7374 if (id == GADGET_ID_SCROLL_HORIZONTAL)
7376 items_max = MAX(lev_fieldx + 2, ed_fieldx);
7377 items_visible = ed_fieldx;
7378 item_position = level_xpos + 1;
7382 items_max = MAX(lev_fieldy + 2, ed_fieldy);
7383 items_visible = ed_fieldy;
7384 item_position = level_ypos + 1;
7387 if (item_position > items_max - items_visible)
7388 item_position = items_max - items_visible;
7390 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
7391 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
7394 static void AdjustElementListScrollbar()
7396 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
7397 int items_max, items_visible, item_position;
7399 /* correct position of element list scrollbar */
7400 if (element_shift < 0)
7402 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
7403 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
7405 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
7406 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
7407 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
7409 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
7410 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7411 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
7414 static void ModifyEditorCounterValue(int counter_id, int new_value)
7416 int *counter_value = counterbutton_info[counter_id].value;
7417 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
7418 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7420 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
7422 if (counter_value != NULL)
7423 *counter_value = gi->textinput.number_value;
7426 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
7428 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
7429 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7431 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
7433 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
7434 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
7436 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
7437 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
7439 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
7440 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_DISTANCE,GDI_END);
7444 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
7446 int gadget_id = selectbox_info[selectbox_id].gadget_id;
7447 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7448 int new_index_value = setSelectboxValue(selectbox_id, new_value);
7450 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
7453 static void ModifyEditorSelectboxOptions(int selectbox_id,
7454 struct ValueTextInfo *options)
7456 int gadget_id = selectbox_info[selectbox_id].gadget_id;
7457 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7459 selectbox_info[selectbox_id].options = options;
7461 /* set index to zero -- list may be shorter now (correct later, if needed) */
7462 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
7463 GDI_SELECTBOX_OPTIONS, options, GDI_END);
7466 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
7468 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
7469 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7471 drawingarea_info[drawingarea_id].area_xsize = xsize;
7472 drawingarea_info[drawingarea_id].area_ysize = ysize;
7474 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
7477 static void ModifyEditorElementList()
7481 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7483 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
7484 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7485 struct GadgetDesign *gd = &gi->deco.design;
7486 int element = editor_elements[element_shift + i];
7490 getMiniGraphicSource(el2edimg(element), &gd->bitmap, &gd->x, &gd->y);
7491 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
7497 static void PickDrawingElement(int button, int element)
7499 if (button < 1 || button > 3)
7504 new_element1 = element;
7505 DrawMiniGraphicExt(drawto,
7506 DX + ED_WIN_MB_LEFT_XPOS, DY + ED_WIN_MB_LEFT_YPOS,
7507 el2edimg(new_element1));
7509 else if (button == 2)
7511 new_element2 = element;
7512 DrawMiniGraphicExt(drawto,
7513 DX + ED_WIN_MB_MIDDLE_XPOS, DY + ED_WIN_MB_MIDDLE_YPOS,
7514 el2edimg(new_element2));
7518 new_element3 = element;
7519 DrawMiniGraphicExt(drawto,
7520 DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS,
7521 el2edimg(new_element3));
7524 redraw_mask |= REDRAW_DOOR_1;
7527 static void RedrawDrawingElements()
7529 PickDrawingElement(1, new_element1);
7530 PickDrawingElement(2, new_element2);
7531 PickDrawingElement(3, new_element3);
7534 static void DrawDrawingWindow()
7536 stick_element_properties_window = FALSE;
7538 SetMainBackgroundImage(IMG_UNDEFINED);
7541 UnmapLevelEditorWindowGadgets();
7542 UnmapLevelEditorToolboxCustomGadgets();
7544 AdjustDrawingAreaGadgets();
7545 AdjustLevelScrollPosition();
7546 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
7547 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
7549 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7551 MapMainDrawingArea();
7552 MapLevelEditorToolboxDrawingGadgets();
7555 static int getTabulatorBarWidth()
7557 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
7558 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
7560 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
7563 static void DrawLevelInfoTabulatorGadgets()
7565 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELINFO_LEVEL];
7566 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
7567 int gd_x = gd->x + gd_gi1->border.width / 2;
7568 int gd_y = gd->y + gd_gi1->height - 1;
7569 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
7570 int id_first = ED_TEXTBUTTON_ID_LEVELINFO_LEVEL;
7571 int id_last = ED_TEXTBUTTON_ID_LEVELINFO_EDITOR;
7578 for (i = id_first; i <= id_last; i++)
7580 int gadget_id = textbutton_info[i].gadget_id;
7581 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7582 boolean active = (i != edit_mode_levelinfo);
7584 /* draw background line below tabulator button */
7585 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
7587 /* draw solid line below inactive tabulator buttons */
7588 if (!active && tab_color != BLACK_PIXEL) /* black => transparent */
7589 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width, 1, tab_color);
7591 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
7592 MapTextbuttonGadget(i);
7596 /* draw little border line below tabulator buttons */
7597 if (tab_color != BLACK_PIXEL) /* black => transparent */
7598 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height + 1,
7599 getTabulatorBarWidth(), ED_GADGET_DISTANCE,
7602 /* draw little border line below tabulator buttons */
7603 if (tab_color != BLACK_PIXEL) /* black => transparent */
7604 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height + 1,
7605 max_tabs * gd_gi1->width + (max_tabs -1) * ED_GADGET_DISTANCE,
7606 ED_GADGET_DISTANCE, tab_color);
7610 static void DrawPropertiesTabulatorGadgets()
7612 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
7613 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
7614 int gd_x = gd->x + gd_gi1->border.width / 2;
7615 int gd_y = gd->y + gd_gi1->height - 1;
7616 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
7617 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
7618 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
7625 /* draw two config tabulators for player elements */
7626 if (ELEM_IS_PLAYER(properties_element))
7627 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
7629 /* draw two config and one "change" tabulator for custom elements */
7630 if (IS_CUSTOM_ELEMENT(properties_element))
7631 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
7633 for (i = id_first; i <= id_last; i++)
7635 int gadget_id = textbutton_info[i].gadget_id;
7636 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7637 boolean active = (i != edit_mode_properties);
7639 /* use "config 1" and "config 2" instead of "config" for players and CEs */
7640 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
7641 (ELEM_IS_PLAYER(properties_element) ||
7642 IS_CUSTOM_ELEMENT(properties_element)))
7645 /* draw background line below tabulator button */
7646 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
7648 /* draw solid line below inactive tabulator buttons */
7649 if (!active && tab_color != BLACK_PIXEL) /* black => transparent */
7650 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width, 1, tab_color);
7652 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
7653 MapTextbuttonGadget(i);
7657 /* draw little border line below tabulator buttons */
7658 if (tab_color != BLACK_PIXEL) /* black => transparent */
7659 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height + 1,
7660 getTabulatorBarWidth(), ED_GADGET_DISTANCE,
7663 /* draw little border line below tabulator buttons */
7664 if (tab_color != BLACK_PIXEL) /* black => transparent */
7665 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height + 1,
7666 max_tabs * gd_gi1->width + (max_tabs -1) * ED_GADGET_DISTANCE,
7667 ED_GADGET_DISTANCE, tab_color);
7671 static void DrawLevelInfoLevel()
7675 /* draw counter gadgets */
7676 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
7677 MapCounterButtons(i);
7679 /* draw selectbox gadgets */
7680 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
7681 MapSelectboxGadget(i);
7683 /* draw text input gadgets */
7684 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
7685 MapTextInputGadget(i);
7688 static void DrawLevelInfoEditor()
7692 /* draw counter gadgets */
7693 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
7694 MapCounterButtons(i);
7696 /* draw checkbutton gadgets */
7697 for (i=ED_CHECKBUTTON_ID_EDITOR_FIRST; i<= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
7698 MapCheckbuttonGadget(i);
7700 /* draw radiobutton gadgets */
7701 for (i=ED_RADIOBUTTON_ID_EDITOR_FIRST; i<= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
7702 MapRadiobuttonGadget(i);
7704 /* draw drawing area */
7705 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
7708 static void DrawLevelInfoWindow()
7710 stick_element_properties_window = FALSE;
7712 UnmapLevelEditorWindowGadgets();
7714 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
7719 DrawTextSCentered(ED_SETTINGS1_YPOS, FONT_TITLE_1, "Global Settings");
7721 DrawTextSCentered(ED_SETTINGS1_YPOS, FONT_TITLE_1, "Level Settings");
7722 DrawTextSCentered(ED_SETTINGS2_YPOS, FONT_TITLE_1, "Editor Settings");
7725 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS1_YPOS,
7726 "Level Settings", FONT_TITLE_1);
7727 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS2_YPOS,
7728 "Editor Settings", FONT_TITLE_1);
7731 DrawLevelInfoTabulatorGadgets();
7733 if (edit_mode_levelinfo == ED_MODE_LEVELINFO_LEVEL)
7734 DrawLevelInfoLevel();
7735 else /* (edit_mode_levelinfo == ED_MODE_LEVELINFO_EDITOR) */
7736 DrawLevelInfoEditor();
7739 static void DrawCustomContentArea()
7741 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
7742 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
7743 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
7744 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
7745 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
7746 int xoffset = ED_DRAWINGAREA_TEXT_DISTANCE;
7748 /* add distance for potential left text (without drawing area border) */
7749 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
7751 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
7753 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
7756 static void DrawCustomChangeContentArea()
7758 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
7759 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
7760 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
7761 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
7762 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
7763 int xoffset = ED_DRAWINGAREA_TEXT_DISTANCE;
7765 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
7770 static void DrawYamYamContentAreas()
7772 int x = SX + ED_AREA_YAMYAM_CONTENT_XPOS(3) + 4 * MINI_TILEX;
7773 int y = SY + ED_AREA_YAMYAM_CONTENT_YPOS(0) + ED_BORDER_AREA_YSIZE;
7776 /* display counter to choose number of element content areas */
7777 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
7779 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
7781 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
7783 if (i < level.num_yamyam_contents)
7789 int font_height = getFontHeight(FONT_TEXT_1);
7791 UnmapDrawingArea(id);
7793 /* delete content areas in case of reducing number of them */
7794 DrawBackground(SX + drawingarea_info[id].x - MINI_TILEX / 2,
7795 SY + drawingarea_info[id].y - MINI_TILEY / 2,
7797 4 * MINI_TILEY + ED_GADGET_TEXT_DISTANCE + font_height);
7801 DrawText(x, y + 0 * MINI_TILEY, "content", FONT_TEXT_1);
7802 DrawText(x, y + 1 * MINI_TILEY, "when", FONT_TEXT_1);
7803 DrawText(x, y + 2 * MINI_TILEY, "smashed", FONT_TEXT_1);
7806 static void DrawMagicBallContentAreas()
7808 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_XPOS(3) + 4 * MINI_TILEX;
7809 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_YPOS(0) + ED_BORDER_AREA_YSIZE;
7812 /* display counter to choose number of element content areas */
7813 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
7815 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
7817 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
7819 if (i < level.num_ball_contents)
7825 int font_height = getFontHeight(FONT_TEXT_1);
7827 UnmapDrawingArea(id);
7829 /* delete content areas in case of reducing number of them */
7830 DrawBackground(SX + drawingarea_info[id].x - MINI_TILEX / 2,
7831 SY + drawingarea_info[id].y - MINI_TILEY / 2,
7833 4 * MINI_TILEY + ED_GADGET_TEXT_DISTANCE + font_height);
7837 DrawText(x, y + 0 * MINI_TILEY, "generated", FONT_TEXT_1);
7838 DrawText(x, y + 1 * MINI_TILEY, "when", FONT_TEXT_1);
7839 DrawText(x, y + 2 * MINI_TILEY, "active", FONT_TEXT_1);
7842 static void DrawAndroidElementArea(int element)
7844 int num_elements = level.num_android_clone_elements;
7845 int id = ED_DRAWING_ID_ANDROID_CONTENT;
7846 int sx = SX + drawingarea_info[id].x - MINI_TILEX / 2;
7847 int sy = SY + drawingarea_info[id].y - MINI_TILEY / 2;
7848 int xsize = MAX_ANDROID_ELEMENTS;
7851 /* display counter to choose number of element areas */
7852 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
7854 if (drawingarea_info[id].text_left != NULL)
7855 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
7857 UnmapDrawingArea(id);
7859 ModifyEditorDrawingArea(id, num_elements, 1);
7861 /* delete content areas in case of reducing number of them */
7862 DrawBackground(sx, sy, (xsize + 1) * MINI_TILEX, (ysize + 1) * MINI_TILEY);
7867 static void DrawGroupElementArea(int element)
7869 int num_elements = group_element_info.num_elements;
7870 int id = ED_DRAWING_ID_GROUP_CONTENT;
7871 int sx = SX + drawingarea_info[id].x - MINI_TILEX / 2;
7872 int sy = SY + drawingarea_info[id].y - MINI_TILEY / 2;
7873 int xsize = MAX_ELEMENTS_IN_GROUP;
7876 if (drawingarea_info[id].text_left != NULL)
7877 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
7879 UnmapDrawingArea(id);
7881 ModifyEditorDrawingArea(id, num_elements, 1);
7883 /* delete content areas in case of reducing number of them */
7884 DrawBackground(sx, sy, (xsize + 1) * MINI_TILEX, (ysize + 1) * MINI_TILEY);
7889 static void DrawPlayerInitialInventoryArea(int element)
7891 int player_nr = GET_PLAYER_NR(element);
7892 int num_elements = level.initial_inventory_size[player_nr];
7893 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
7894 int sx = SX + drawingarea_info[id].x - MINI_TILEX / 2;
7895 int sy = SY + drawingarea_info[id].y - MINI_TILEY / 2;
7896 int xsize = MAX_INITIAL_INVENTORY_SIZE;
7899 /* determine horizontal position to the right of specified gadget */
7900 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
7901 sx += (right_gadget_border[drawingarea_info[id].gadget_id_align] +
7902 ED_DRAWINGAREA_TEXT_DISTANCE);
7904 /* determine horizontal offset for leading text */
7905 if (drawingarea_info[id].text_left != NULL)
7906 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
7908 UnmapDrawingArea(id);
7910 ModifyEditorDrawingArea(id, num_elements, 1);
7912 /* delete content areas in case of reducing number of them */
7913 DrawBackground(sx, sy, (xsize + 1) * MINI_TILEX, (ysize + 1) * MINI_TILEY);
7918 static void DrawEnvelopeTextArea(int envelope_nr)
7920 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
7921 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
7924 DrawBackground(gi->x, gi->y, gi->width, gi->height);
7926 if (envelope_nr != -1)
7927 textarea_info[id].value = level.envelope[envelope_nr].text;
7929 ModifyGadget(gi, GDI_AREA_SIZE,
7930 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
7931 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
7934 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
7937 static boolean PrintInfoText(char *text, int font_nr, int start_line)
7939 int font_height = getFontHeight(font_nr);
7940 int pad_x = ED_ELEMENT_SETTINGS_XPOS(0);
7941 int pad_y = ED_ELEMENT_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
7942 int sx = SX + pad_x;
7943 int sy = SY + pad_y;
7944 int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
7946 if (start_line >= max_lines_per_screen)
7949 DrawText(sx, sy + start_line * font_height, text, font_nr);
7954 static int PrintElementDescriptionFromFile(char *filename, int start_line)
7956 int font_nr = FONT_TEXT_2;
7957 int font_width = getFontWidth(font_nr);
7958 int font_height = getFontHeight(font_nr);
7959 int pad_x = ED_ELEMENT_SETTINGS_XPOS(0);
7960 int pad_y = ED_ELEMENT_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
7961 int sx = SX + pad_x;
7962 int sy = SY + pad_y + start_line * font_height;
7963 int max_chars_per_line = (SXSIZE - 2 * pad_x) / font_width;
7964 int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
7966 return DrawTextFile(sx, sy, filename, font_nr, max_chars_per_line, -1,
7967 max_lines_per_screen, -1, TRUE, FALSE, FALSE);
7970 static void DrawPropertiesInfo()
7979 /* configurable properties */
7981 { EP_WALKABLE_OVER, "- player can walk over it" },
7982 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
7983 { EP_WALKABLE_UNDER, "- player can walk under it" },
7984 { EP_PASSABLE_OVER, "- player can pass over it" },
7985 { EP_PASSABLE_INSIDE, "- player can pass through it" },
7986 { EP_PASSABLE_UNDER, "- player can pass under it" },
7987 { EP_PROTECTED, "- player is protected by it" },
7989 { EP_DIGGABLE, "- can be digged away" },
7990 { EP_COLLECTIBLE, "- can be collected" },
7991 { EP_DROPPABLE, "- can be dropped after collecting" },
7992 { EP_THROWABLE, "- can be thrown after collecting" },
7993 { EP_PUSHABLE, "- can be pushed" },
7995 { EP_CAN_FALL, "- can fall" },
7996 { EP_CAN_MOVE, "- can move" },
7998 { EP_CAN_SMASH_PLAYER, "- can smash player" },
8000 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
8002 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
8004 { EP_SLIPPERY, "- slippery for falling elements" },
8005 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
8007 { EP_DONT_RUN_INTO, "- deadly when running into" },
8008 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
8009 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
8010 { EP_DONT_TOUCH, "- deadly when touching" },
8012 { EP_INDESTRUCTIBLE, "- indestructible" },
8014 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
8015 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
8016 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
8018 { EP_CAN_CHANGE, "- can change to other element" },
8020 /* pre-defined properties */
8021 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
8022 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
8023 { EP_SWITCHABLE, "- can be switched" },
8025 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
8030 char *filename = getElementDescriptionFilename(properties_element);
8031 char *percentage_text = "In this level:";
8032 char *properties_text = "Standard properties:";
8034 int num_elements_in_level;
8035 int num_standard_properties = 0;
8036 int font1_nr = FONT_TEXT_1;
8037 int font2_nr = FONT_TEXT_2;
8038 int font1_width = getFontWidth(font1_nr);
8039 int font2_height = getFontHeight(font2_nr);
8040 int pad_x = ED_ELEMENT_SETTINGS_XPOS(0);
8041 int pad_y = ED_ELEMENT_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
8042 int screen_line = 0;
8045 if (setup.editor.show_element_token)
8047 DrawTextF(pad_x, pad_y + screen_line++ * font2_height, FONT_TEXT_3,
8048 "[%s]", element_info[properties_element].token_name);
8052 /* ----- print number of elements / percentage of this element in level */
8054 num_elements_in_level = 0;
8055 for (y = 0; y < lev_fieldy; y++)
8056 for (x = 0; x < lev_fieldx; x++)
8057 if (Feld[x][y] == properties_element)
8058 num_elements_in_level++;
8059 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
8061 DrawTextS(pad_x, pad_y + screen_line * font2_height, font1_nr,
8063 DrawTextF(pad_x + strlen(percentage_text) * font1_width,
8064 pad_y + screen_line++ * font2_height, font2_nr,
8065 "%d (%.2f%%)", num_elements_in_level, percentage);
8069 /* ----- print standard properties of this element */
8071 DrawTextS(pad_x, pad_y + screen_line++ * font2_height, font1_nr,
8074 for (i = 0; properties[i].value != -1; i++)
8076 if (!HAS_PROPERTY(properties_element, properties[i].value))
8079 DrawTextS(pad_x, pad_y + screen_line++ * font2_height, font2_nr,
8080 properties[i].text);
8081 num_standard_properties++;
8084 if (num_standard_properties == 0)
8085 DrawTextS(pad_x + strlen(properties_text) * font1_width,
8086 pad_y + (screen_line - 1) * font2_height, font2_nr, "none");
8090 /* ----- print special description of this element */
8092 PrintInfoText("Description:", FONT_TEXT_1, screen_line);
8093 if (PrintElementDescriptionFromFile(filename, screen_line + 1) == 0)
8094 PrintInfoText("No description available.", FONT_TEXT_1, screen_line);
8097 #define TEXT_COLLECTING "Score for collecting"
8098 #define TEXT_SMASHING "Score for smashing"
8099 #define TEXT_SLURPING "Score for slurping robot"
8100 #define TEXT_CRACKING "Score for cracking"
8101 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
8102 #define TEXT_DURATION "Duration when activated"
8103 #define TEXT_BALL_DELAY "Element generation delay"
8104 #define TEXT_MOVE_SPEED "Speed of android moving"
8105 #define TEXT_CLONE_SPEED "Speed of android cloning"
8106 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
8107 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
8108 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
8109 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
8110 #define TEXT_TIME_BONUS "Extra time to solve level"
8117 } elements_with_counter[] =
8119 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
8120 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
8121 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
8122 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
8123 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
8124 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
8125 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
8126 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
8127 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
8128 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
8129 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
8130 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
8131 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
8132 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
8133 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
8134 { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
8135 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
8136 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
8137 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
8138 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
8139 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8140 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8141 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8142 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8143 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8144 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8145 { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
8146 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8147 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8148 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8149 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8150 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
8151 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
8152 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
8153 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
8154 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
8155 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
8156 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
8157 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
8158 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
8159 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
8160 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
8161 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
8162 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
8163 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
8164 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
8165 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE],TEXT_COLLECTING },
8166 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
8167 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
8168 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
8169 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
8170 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
8171 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
8172 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
8173 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
8174 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
8175 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
8176 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
8177 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
8178 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
8179 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
8180 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
8181 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
8182 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
8183 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
8184 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
8185 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
8186 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
8187 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
8188 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
8189 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
8190 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
8191 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
8192 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
8194 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
8195 { EL_DC_TIMEGATE_SWITCH,&level.time_timegate, TEXT_DURATION },
8196 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
8197 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
8198 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
8199 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
8200 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
8201 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
8202 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
8203 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
8204 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
8205 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
8206 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
8207 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
8208 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
8209 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
8211 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
8212 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
8213 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
8214 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
8215 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
8216 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
8217 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
8218 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
8223 static boolean checkPropertiesConfig(int element)
8227 if (IS_GEM(element) ||
8228 IS_CUSTOM_ELEMENT(element) ||
8229 IS_GROUP_ELEMENT(element) ||
8230 IS_ENVELOPE(element) ||
8231 ELEM_IS_PLAYER(element) ||
8232 HAS_EDITOR_CONTENT(element) ||
8233 CAN_GROW(element) ||
8234 COULD_MOVE_INTO_ACID(element) ||
8235 MAYBE_DONT_COLLIDE_WITH(element) ||
8236 element == EL_SOKOBAN_OBJECT ||
8237 element == EL_SOKOBAN_FIELD_EMPTY ||
8238 element == EL_SOKOBAN_FIELD_FULL)
8241 for (i = 0; elements_with_counter[i].element != -1; i++)
8242 if (elements_with_counter[i].element == element)
8248 static void DrawPropertiesConfig()
8250 int max_num_element_counters = 4;
8251 int num_element_counters = 0;
8254 if (!checkPropertiesConfig(properties_element))
8256 PrintInfoText("No configuration options available.", FONT_TEXT_1, 0);
8261 /* check if there are elements where a value can be chosen for */
8262 for (i = 0; elements_with_counter[i].element != -1; i++)
8264 if (elements_with_counter[i].element == properties_element)
8266 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
8268 counterbutton_info[counter_id].y =
8269 ED_ELEMENT_SETTINGS_YPOS(
8270 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
8271 (CAN_GROW(properties_element) ? 1 : 0) +
8272 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
8273 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
8274 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
8275 num_element_counters);
8277 counterbutton_info[counter_id].value = elements_with_counter[i].value;
8278 counterbutton_info[counter_id].text_right= elements_with_counter[i].text;
8280 if (properties_element == EL_GAME_OF_LIFE ||
8281 properties_element == EL_BIOMAZE)
8283 counterbutton_info[counter_id].min_value = 0; /* min neighbours */
8284 counterbutton_info[counter_id].max_value = 8; /* max neighbours */
8288 /* !!! CHANGE THIS FOR CERTAIN ELEMENTS !!! */
8289 counterbutton_info[counter_id].min_value = MIN_SCORE;
8290 counterbutton_info[counter_id].max_value = MAX_SCORE;
8293 MapCounterButtons(counter_id);
8295 num_element_counters++;
8296 if (num_element_counters >= max_num_element_counters)
8301 if (HAS_EDITOR_CONTENT(properties_element))
8303 /* draw stickybutton gadget */
8304 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
8306 if (IS_AMOEBOID(properties_element))
8307 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
8308 else if (properties_element == EL_YAMYAM ||
8309 properties_element == EL_YAMYAM_LEFT ||
8310 properties_element == EL_YAMYAM_RIGHT ||
8311 properties_element == EL_YAMYAM_UP ||
8312 properties_element == EL_YAMYAM_DOWN)
8313 DrawYamYamContentAreas();
8314 else if (properties_element == EL_EMC_MAGIC_BALL)
8316 DrawMagicBallContentAreas();
8318 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
8319 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_STATE);
8321 else if (properties_element == EL_EMC_ANDROID)
8322 DrawAndroidElementArea(properties_element);
8325 if (ELEM_IS_PLAYER(properties_element))
8327 int player_nr = GET_PLAYER_NR(properties_element);
8329 /* these properties can be set for every player individually */
8331 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
8333 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
8334 &level.start_element[player_nr];
8335 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
8336 &level.artwork_element[player_nr];
8337 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
8338 &level.explosion_element[player_nr];
8340 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
8341 &level.use_start_element[player_nr];
8342 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
8343 &level.use_artwork_element[player_nr];
8344 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
8345 &level.use_explosion_element[player_nr];
8346 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
8347 &level.initial_player_gravity[player_nr];
8349 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
8350 &level.initial_player_stepsize[player_nr];
8352 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
8353 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
8354 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
8355 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
8356 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
8357 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
8358 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
8359 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
8360 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
8361 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
8362 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
8363 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
8364 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
8366 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
8367 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
8368 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
8370 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
8372 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
8374 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
8375 &level.initial_inventory_content[player_nr][0];
8377 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
8378 &level.initial_inventory_size[player_nr];
8380 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
8381 &level.use_initial_inventory[player_nr];
8383 /* draw checkbutton gadgets */
8384 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
8386 /* draw counter gadgets */
8387 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
8389 /* draw drawing area gadgets */
8390 DrawPlayerInitialInventoryArea(properties_element);
8394 if (IS_GEM(properties_element))
8395 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
8397 if (properties_element == EL_EM_DYNAMITE)
8398 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
8400 if (COULD_MOVE_INTO_ACID(properties_element) &&
8401 !ELEM_IS_PLAYER(properties_element) &&
8402 (!IS_CUSTOM_ELEMENT(properties_element) ||
8403 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
8405 /* set position for checkbutton for "can move into acid" */
8406 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
8407 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
8408 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
8409 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 6 :
8410 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
8412 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
8415 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
8416 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
8418 if (properties_element == EL_SPRING)
8419 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
8421 if (properties_element == EL_TIME_ORB_FULL)
8422 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
8424 if (CAN_GROW(properties_element))
8426 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
8427 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
8429 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
8432 if (properties_element == EL_SOKOBAN_OBJECT ||
8433 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
8434 properties_element == EL_SOKOBAN_FIELD_FULL)
8435 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
8437 if (IS_ENVELOPE(properties_element))
8439 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
8440 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
8441 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
8442 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
8443 int envelope_nr = properties_element - EL_ENVELOPE_1;
8445 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
8446 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
8448 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
8449 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
8451 /* display counter to choose size of envelope text area */
8452 MapCounterButtons(counter1_id);
8453 MapCounterButtons(counter2_id);
8455 /* display checkbuttons to choose auto-wrap and alignment properties */
8456 MapCheckbuttonGadget(button1_id);
8457 MapCheckbuttonGadget(button2_id);
8459 DrawEnvelopeTextArea(envelope_nr);
8462 if (IS_CUSTOM_ELEMENT(properties_element))
8464 /* draw stickybutton gadget */
8465 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
8467 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
8469 /* draw checkbutton gadgets */
8470 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
8471 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
8472 MapCheckbuttonGadget(i);
8474 /* draw counter gadgets */
8475 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
8476 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
8477 MapCounterButtons(i);
8479 /* draw selectbox gadgets */
8480 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
8481 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
8482 MapSelectboxGadget(i);
8484 /* draw textbutton gadgets */
8485 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE);
8487 /* draw text input gadgets */
8488 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
8490 /* draw drawing area gadgets */
8491 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
8493 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
8495 /* draw checkbutton gadgets */
8496 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
8497 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
8498 MapCheckbuttonGadget(i);
8500 /* draw counter gadgets */
8501 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
8502 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
8503 MapCounterButtons(i);
8505 /* draw selectbox gadgets */
8506 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
8507 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
8508 MapSelectboxGadget(i);
8510 /* draw drawing area gadgets */
8511 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
8512 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
8513 DrawCustomContentArea();
8516 else if (IS_GROUP_ELEMENT(properties_element))
8518 /* draw stickybutton gadget */
8519 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
8521 /* draw checkbutton gadgets */
8522 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
8523 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE);
8525 /* draw counter gadgets */
8526 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
8528 /* draw selectbox gadgets */
8529 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
8531 /* draw textbutton gadgets */
8532 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE);
8534 /* draw drawing area gadgets */
8535 DrawGroupElementArea(properties_element);
8537 /* draw text input gadgets */
8538 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
8540 /* draw drawing area gadgets */
8541 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
8545 static void DrawPropertiesChangeDrawingAreas()
8547 if (IS_CUSTOM_ELEMENT(properties_element))
8549 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
8550 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
8551 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
8553 DrawCustomChangeContentArea();
8556 redraw_mask |= REDRAW_FIELD;
8559 static void DrawPropertiesChange()
8563 /* needed to initially set selectbox options for special action options */
8564 setSelectboxSpecialActionOptions();
8566 /* draw stickybutton gadget */
8567 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
8569 /* draw checkbutton gadgets */
8570 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
8571 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
8572 MapCheckbuttonGadget(i);
8574 /* draw counter gadgets */
8575 for (i = ED_COUNTER_ID_CHANGE_FIRST;
8576 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
8577 MapCounterButtons(i);
8579 /* draw selectbox gadgets */
8580 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
8581 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
8582 MapSelectboxGadget(i);
8584 /* draw textbutton gadgets */
8585 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
8586 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
8587 MapTextbuttonGadget(i);
8589 /* draw graphicbutton gadgets */
8590 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
8591 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
8592 MapGraphicbuttonGadget(i);
8594 /* draw drawing area gadgets */
8595 DrawPropertiesChangeDrawingAreas();
8598 static void DrawEditorElementAnimation(int x, int y)
8600 int graphic = el2img(properties_element);
8601 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
8602 custom_element.ce_value_fixed_initial :
8603 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
8604 custom_element.collect_score_initial : FrameCounter);
8606 DrawGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
8609 static void DrawEditorElementName(int x, int y, int element)
8611 char *element_name = getElementInfoText(element);
8612 int font_nr = FONT_TEXT_1;
8613 int font_width = getFontWidth(font_nr);
8614 int font_height = getFontHeight(font_nr);
8615 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_XPOS(0);
8616 int max_chars_per_line = max_text_width / font_width;
8617 char buffer[max_chars_per_line + 1];
8619 if (strlen(element_name) <= max_chars_per_line)
8620 DrawTextS(x, y, font_nr, element_name);
8623 int next_pos = max_chars_per_line;
8625 strncpy(buffer, element_name, max_chars_per_line);
8626 buffer[max_chars_per_line] = '\0';
8628 if (element_name[max_chars_per_line] == ' ')
8634 for (i = max_chars_per_line - 1; i >= 0; i--)
8635 if (buffer[i] == ' ')
8638 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
8645 DrawTextS(x, y - font_height / 2, font_nr, buffer);
8647 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
8648 buffer[max_chars_per_line] = '\0';
8650 DrawTextS(x, y + font_height / 2, font_nr, buffer);
8654 static void DrawPropertiesWindow()
8659 stick_element_properties_window = FALSE;
8661 /* make sure that previous properties edit mode exists for this element */
8662 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
8663 !IS_CUSTOM_ELEMENT(properties_element))
8664 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
8666 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
8667 !ELEM_IS_PLAYER(properties_element) &&
8668 !IS_CUSTOM_ELEMENT(properties_element))
8669 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
8671 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
8672 (ELEM_IS_PLAYER(properties_element) ||
8673 IS_CUSTOM_ELEMENT(properties_element)))
8674 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
8676 CopyElementPropertiesToEditor(properties_element);
8678 UnmapLevelEditorWindowGadgets();
8679 UnmapLevelEditorToolboxDrawingGadgets();
8680 UnmapLevelEditorToolboxCustomGadgets();
8682 if (IS_CUSTOM_ELEMENT(properties_element) ||
8683 IS_GROUP_ELEMENT(properties_element))
8684 MapLevelEditorToolboxCustomGadgets();
8686 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
8690 DrawTextSCentered(ED_SETTINGS1_YPOS, FONT_TITLE_1, "Element Settings");
8692 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS1_YPOS,
8693 "Element Settings", FONT_TITLE_1);
8696 FrameCounter = 0; /* restart animation frame counter */
8698 DrawElementBorder(SX + xstart * MINI_TILEX,
8699 SY + ystart * MINI_TILEY + MINI_TILEY / 2,
8700 TILEX, TILEY, FALSE);
8702 DrawEditorElementAnimation(SX + xstart * MINI_TILEX,
8703 SY + ystart * MINI_TILEY + MINI_TILEY / 2);
8705 DrawEditorElementName((xstart + 3) * MINI_TILEX + 1,
8706 (ystart + 1) * MINI_TILEY + 1,
8707 properties_element);
8709 DrawPropertiesTabulatorGadgets();
8711 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
8712 DrawPropertiesInfo();
8713 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
8714 DrawPropertiesChange();
8715 else /* (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2]) */
8716 DrawPropertiesConfig();
8719 static void UpdateCustomElementGraphicGadgets()
8721 struct ElementInfo *ei = &element_info[properties_element];
8724 ei->gfx_element = (ei->use_gfx_element ? ei->gfx_element_initial :
8725 properties_element);
8727 ModifyEditorElementList();
8728 RedrawDrawingElements();
8730 /* force redraw of all mapped drawing area gadgets */
8731 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
8733 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
8740 static int getOpenDirectionFromTube(int element)
8744 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
8745 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
8746 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
8747 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
8748 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
8749 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
8750 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
8751 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
8752 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
8753 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
8754 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
8760 static int getTubeFromOpenDirection(int direction)
8764 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
8765 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
8766 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
8767 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
8768 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
8769 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
8770 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
8771 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
8772 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
8773 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
8774 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
8776 /* if only one direction, fall back to simple tube with that direction */
8777 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
8778 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
8779 case (MV_UP): return EL_TUBE_VERTICAL;
8780 case (MV_DOWN): return EL_TUBE_VERTICAL;
8786 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
8788 int element_new = getTubeFromOpenDirection(direction);
8790 return (element_new != EL_EMPTY ? element_new : element_old);
8793 static int getOpenDirectionFromBelt(int element)
8795 int belt_dir = getBeltDirFromBeltElement(element);
8797 return (belt_dir == MV_LEFT ? MV_RIGHT :
8798 belt_dir == MV_RIGHT ? MV_LEFT :
8799 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
8802 static int getBeltFromNrAndOpenDirection(int nr, int direction)
8804 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
8805 direction == MV_RIGHT ? MV_LEFT :
8806 direction == MV_HORIZONTAL ? MV_NONE : direction);
8808 if (direction == MV_NONE)
8811 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
8814 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
8817 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
8819 return (element_new != EL_EMPTY ? element_new : element_old);
8822 static int getOpenDirectionFromPool(int element)
8826 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
8827 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
8828 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
8829 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
8830 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
8831 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
8837 static int getPoolFromOpenDirection(int direction)
8841 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
8842 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
8843 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
8844 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
8845 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
8846 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
8852 static int getPoolFromOpenDirectionExt(int direction, int help_element)
8854 int element = getPoolFromOpenDirection(direction);
8855 int help_direction = getOpenDirectionFromPool(help_element);
8857 if (element == EL_EMPTY)
8859 int help_direction_vertical = help_direction & MV_VERTICAL;
8861 element = getPoolFromOpenDirection(direction | help_direction_vertical);
8864 if (element == EL_EMPTY)
8866 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
8868 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
8874 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
8876 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
8878 return (element_new != EL_EMPTY ? element_new : element_old);
8881 static int getOpenDirectionFromPillar(int element)
8885 case EL_EMC_WALL_1: return (MV_DOWN);
8886 case EL_EMC_WALL_2: return (MV_VERTICAL);
8887 case EL_EMC_WALL_3: return (MV_UP);
8893 static int getPillarFromOpenDirection(int direction)
8897 case (MV_DOWN): return EL_EMC_WALL_1;
8898 case (MV_VERTICAL): return EL_EMC_WALL_2;
8899 case (MV_UP): return EL_EMC_WALL_3;
8905 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
8907 int element_new = getPillarFromOpenDirection(direction);
8909 return (element_new != EL_EMPTY ? element_new : element_old);
8912 static int getOpenDirectionFromSteel2(int element)
8916 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
8917 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
8918 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
8919 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
8920 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
8921 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
8922 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
8923 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
8929 static int getSteel2FromOpenDirection(int direction)
8933 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
8934 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
8935 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
8936 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
8937 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
8938 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
8939 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
8940 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
8946 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
8948 int element_new = getSteel2FromOpenDirection(direction);
8950 return (element_new != EL_EMPTY ? element_new : element_old);
8953 static int getOpenDirectionFromChip(int element)
8957 case EL_SP_CHIP_SINGLE: return (MV_NONE);
8958 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
8959 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
8960 case EL_SP_CHIP_TOP: return (MV_DOWN);
8961 case EL_SP_CHIP_BOTTOM: return (MV_UP);
8967 static int getChipFromOpenDirection(int direction)
8971 case (MV_NONE): return EL_SP_CHIP_SINGLE;
8972 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
8973 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
8974 case (MV_UP): return EL_SP_CHIP_BOTTOM;
8975 case (MV_DOWN): return EL_SP_CHIP_TOP;
8981 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
8983 int element_new = getChipFromOpenDirection(direction);
8985 return (element_new != EL_EMPTY ? element_new : element_old);
8988 static int getClosedTube(int x, int y)
8990 static int xy[4][2] =
8997 int element_old = IntelliDrawBuffer[x][y];
8998 int direction_old = getOpenDirectionFromTube(element_old);
8999 int direction_new = MV_NONE;
9002 for (i = 0; i < NUM_DIRECTIONS; i++)
9004 int xx = x + xy[i][0];
9005 int yy = y + xy[i][1];
9006 int dir = MV_DIR_FROM_BIT(i);
9007 int dir_opposite = MV_DIR_OPPOSITE(dir);
9009 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
9010 (direction_old & dir) &&
9011 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
9012 direction_new |= dir;
9015 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
9018 static int getClosedBelt(int x, int y)
9020 static int xy[4][2] =
9027 int element_old = IntelliDrawBuffer[x][y];
9028 int nr = getBeltNrFromBeltElement(element_old);
9029 int direction_old = getOpenDirectionFromBelt(element_old);
9030 int direction_new = MV_NONE;
9033 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
9035 int xx = x + xy[i][0];
9036 int yy = y + xy[i][1];
9037 int dir = MV_DIR_FROM_BIT(i);
9038 int dir_opposite = MV_DIR_OPPOSITE(dir);
9040 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
9041 (direction_old & dir) &&
9042 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
9043 direction_new |= dir;
9046 return getBeltFromNrAndOpenDirection(nr, direction_new);
9049 static int getClosedPool(int x, int y)
9051 static int xy[4][2] =
9058 int element_old = IntelliDrawBuffer[x][y];
9059 int direction_old = getOpenDirectionFromPool(element_old);
9060 int direction_new = MV_NONE;
9063 for (i = 0; i < NUM_DIRECTIONS; i++)
9065 int xx = x + xy[i][0];
9066 int yy = y + xy[i][1];
9067 int dir = MV_DIR_FROM_BIT(i);
9068 int dir_opposite = MV_DIR_OPPOSITE(dir);
9070 if (IN_LEV_FIELD(xx, yy) &&
9071 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
9072 (direction_old & dir) &&
9073 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
9074 direction_new |= dir;
9077 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
9080 static int getClosedPillar(int x, int y)
9082 static int xy[4][2] =
9089 int element_old = IntelliDrawBuffer[x][y];
9090 int direction_old = getOpenDirectionFromPillar(element_old);
9091 int direction_new = MV_NONE;
9094 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
9096 int xx = x + xy[i][0];
9097 int yy = y + xy[i][1];
9098 int dir = MV_DIR_FROM_BIT(i);
9099 int dir_opposite = MV_DIR_OPPOSITE(dir);
9101 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
9102 (direction_old & dir) &&
9103 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
9104 direction_new |= dir;
9107 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
9110 static int getClosedSteel2(int x, int y)
9112 static int xy[4][2] =
9119 int element_old = IntelliDrawBuffer[x][y];
9120 int direction_old = getOpenDirectionFromSteel2(element_old);
9121 int direction_new = MV_NONE;
9124 for (i = 0; i < NUM_DIRECTIONS; i++)
9126 int xx = x + xy[i][0];
9127 int yy = y + xy[i][1];
9128 int dir = MV_DIR_FROM_BIT(i);
9129 int dir_opposite = MV_DIR_OPPOSITE(dir);
9131 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
9132 (direction_old & dir) &&
9133 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
9134 direction_new |= dir;
9137 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
9140 static int getClosedChip(int x, int y)
9142 static int xy[4][2] =
9149 int element_old = IntelliDrawBuffer[x][y];
9150 int direction_old = getOpenDirectionFromChip(element_old);
9151 int direction_new = MV_NONE;
9154 for (i = 0; i < NUM_DIRECTIONS; i++)
9156 int xx = x + xy[i][0];
9157 int yy = y + xy[i][1];
9158 int dir = MV_DIR_FROM_BIT(i);
9159 int dir_opposite = MV_DIR_OPPOSITE(dir);
9161 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
9162 (direction_old & dir) &&
9163 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
9164 direction_new |= dir;
9167 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
9170 static void SetElementSimple(int x, int y, int element, boolean change_level)
9172 int sx = x - level_xpos;
9173 int sy = y - level_ypos;
9175 IntelliDrawBuffer[x][y] = element;
9178 Feld[x][y] = element;
9180 if (IN_ED_FIELD(sx, sy))
9181 DrawMiniElement(sx, sy, element);
9184 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
9185 int x2, int y2, int *element2,
9186 int (*close_function)(int, int),
9187 boolean change_level)
9189 /* set neighbour elements to newly determined connections */
9190 SetElementSimple(x1, y1, *element1, change_level);
9191 SetElementSimple(x2, y2, *element2, change_level);
9193 /* remove all open connections of neighbour elements */
9194 *element1 = close_function(x1, y1);
9195 *element2 = close_function(x2, y2);
9197 /* set neighbour elements to new, minimized connections */
9198 SetElementSimple(x1, y1, *element1, change_level);
9199 SetElementSimple(x2, y2, *element2, change_level);
9202 static void SetElementIntelliDraw(int x, int y, int new_element,
9203 boolean change_level, int button)
9205 static int xy[4][2] =
9212 static int last_x = -1;
9213 static int last_y = -1;
9214 int old_element = IntelliDrawBuffer[x][y];
9216 if (new_element == EL_UNDEFINED)
9224 if (IS_TUBE(new_element))
9226 int last_element_new = EL_UNDEFINED;
9227 int direction = MV_NONE;
9230 /* if old element is of same kind, keep all existing directions */
9231 if (IS_TUBE(old_element))
9232 direction |= getOpenDirectionFromTube(old_element);
9234 for (i = 0; i < NUM_DIRECTIONS; i++)
9236 int xx = x + xy[i][0];
9237 int yy = y + xy[i][1];
9239 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9240 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
9242 int dir = MV_DIR_FROM_BIT(i);
9243 int dir_opposite = MV_DIR_OPPOSITE(dir);
9244 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9245 int last_direction_old = getOpenDirectionFromTube(last_element_old);
9246 int last_direction_new = last_direction_old | dir_opposite;
9248 last_element_new = getTubeFromOpenDirection(last_direction_new);
9254 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
9256 if (last_element_new != EL_UNDEFINED)
9257 MergeAndCloseNeighbourElements(x, y, &new_element,
9258 last_x, last_y, &last_element_new,
9259 getClosedTube, change_level);
9261 else if (IS_BELT(new_element))
9263 int belt_nr = getBeltNrFromBeltElement(new_element);
9264 int last_element_new = EL_UNDEFINED;
9265 int direction = MV_NONE;
9268 /* if old element is of same kind, keep all existing directions */
9269 if (IS_BELT(old_element))
9270 direction |= getOpenDirectionFromBelt(old_element);
9272 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
9274 int xx = x + xy[i][0];
9275 int yy = y + xy[i][1];
9277 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9278 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
9280 int dir = MV_DIR_FROM_BIT(i);
9281 int dir_opposite = MV_DIR_OPPOSITE(dir);
9282 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9283 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
9284 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
9285 int last_direction_new = last_direction_old | dir_opposite;
9287 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
9288 last_direction_new);
9293 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
9295 if (last_element_new != EL_UNDEFINED)
9296 MergeAndCloseNeighbourElements(x, y, &new_element,
9297 last_x, last_y, &last_element_new,
9298 getClosedBelt, change_level);
9300 else if (IS_ACID_POOL_OR_ACID(new_element))
9302 int last_element_new = EL_UNDEFINED;
9303 int direction = MV_NONE;
9306 /* if old element is of same kind, keep all existing directions */
9307 if (IS_ACID_POOL_OR_ACID(old_element))
9308 direction |= getOpenDirectionFromPool(old_element);
9310 for (i = 0; i < NUM_DIRECTIONS; i++)
9312 int xx = x + xy[i][0];
9313 int yy = y + xy[i][1];
9315 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9316 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
9318 int dir = MV_DIR_FROM_BIT(i);
9319 int dir_opposite = MV_DIR_OPPOSITE(dir);
9320 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9321 int last_direction_old = getOpenDirectionFromPool(last_element_old);
9322 int last_direction_new = last_direction_old | dir_opposite;
9324 last_element_new = getPoolFromOpenDirection(last_direction_new);
9330 /* special corrections needed for intuitively correct acid pool drawing */
9331 if (last_element_new == EL_EMPTY)
9332 last_element_new = new_element;
9333 else if (last_element_new != EL_UNDEFINED)
9334 new_element = last_element_new;
9336 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
9338 if (last_element_new != EL_UNDEFINED)
9339 MergeAndCloseNeighbourElements(x, y, &new_element,
9340 last_x, last_y, &last_element_new,
9341 getClosedPool, change_level);
9343 else if (IS_EMC_PILLAR(new_element))
9345 int last_element_new = EL_UNDEFINED;
9346 int direction = MV_NONE;
9349 /* if old element is of same kind, keep all existing directions */
9350 if (IS_EMC_PILLAR(old_element))
9351 direction |= getOpenDirectionFromPillar(old_element);
9353 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
9355 int xx = x + xy[i][0];
9356 int yy = y + xy[i][1];
9358 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9359 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
9361 int dir = MV_DIR_FROM_BIT(i);
9362 int dir_opposite = MV_DIR_OPPOSITE(dir);
9363 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9364 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
9365 int last_direction_new = last_direction_old | dir_opposite;
9367 last_element_new = getPillarFromOpenDirection(last_direction_new);
9373 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
9375 if (last_element_new != EL_UNDEFINED)
9376 MergeAndCloseNeighbourElements(x, y, &new_element,
9377 last_x, last_y, &last_element_new,
9378 getClosedPillar, change_level);
9380 else if (IS_DC_STEELWALL_2(new_element))
9382 int last_element_new = EL_UNDEFINED;
9383 int direction = MV_NONE;
9386 /* if old element is of same kind, keep all existing directions */
9387 if (IS_DC_STEELWALL_2(old_element))
9388 direction |= getOpenDirectionFromSteel2(old_element);
9390 for (i = 0; i < NUM_DIRECTIONS; i++)
9392 int xx = x + xy[i][0];
9393 int yy = y + xy[i][1];
9395 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9396 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
9398 int dir = MV_DIR_FROM_BIT(i);
9399 int dir_opposite = MV_DIR_OPPOSITE(dir);
9400 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9401 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
9402 int last_direction_new = last_direction_old | dir_opposite;
9404 last_element_new = getSteel2FromOpenDirection(last_direction_new);
9410 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
9412 if (last_element_new != EL_UNDEFINED)
9413 MergeAndCloseNeighbourElements(x, y, &new_element,
9414 last_x, last_y, &last_element_new,
9415 getClosedSteel2, change_level);
9417 else if (IS_SP_CHIP(new_element))
9419 int last_element_new = EL_UNDEFINED;
9420 int direction = MV_NONE;
9423 /* (do not keep existing directions, regardless of kind of old element) */
9425 for (i = 0; i < NUM_DIRECTIONS; i++)
9427 int xx = x + xy[i][0];
9428 int yy = y + xy[i][1];
9430 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9431 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
9433 int dir = MV_DIR_FROM_BIT(i);
9434 int dir_opposite = MV_DIR_OPPOSITE(dir);
9435 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9436 int last_direction_old = getOpenDirectionFromChip(last_element_old);
9437 int last_direction_new = last_direction_old | dir_opposite;
9439 if (last_direction_old == MV_NONE)
9441 last_element_new = getChipFromOpenDirection(last_direction_new);
9444 else if (last_direction_old & (dir | dir_opposite))
9446 direction |= MV_DIR_OPPOSITE(last_direction_old);
9450 direction |= MV_DIR_OPPOSITE(dir);
9455 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
9457 if (last_element_new != EL_UNDEFINED)
9458 MergeAndCloseNeighbourElements(x, y, &new_element,
9459 last_x, last_y, &last_element_new,
9460 getClosedChip, change_level);
9462 else if (IS_SP_HARDWARE_BASE(new_element))
9464 int nr = GetSimpleRandom(6);
9466 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
9467 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
9468 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
9469 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
9470 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
9472 else if (new_element == EL_SP_HARDWARE_GREEN ||
9473 new_element == EL_SP_HARDWARE_BLUE ||
9474 new_element == EL_SP_HARDWARE_RED)
9476 int nr = GetSimpleRandom(3);
9478 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
9479 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
9481 else if (IS_GROUP_ELEMENT(new_element))
9483 boolean connected_drawing = FALSE;
9486 for (i = 0; i < NUM_DIRECTIONS; i++)
9488 int xx = x + xy[i][0];
9489 int yy = y + xy[i][1];
9491 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9492 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
9493 connected_drawing = TRUE;
9496 if (!connected_drawing)
9497 ResolveGroupElement(new_element);
9499 new_element = GetElementFromGroupElement(new_element);
9501 else if (IS_BELT_SWITCH(old_element))
9503 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
9504 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
9506 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
9507 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
9509 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
9513 static int swappable_elements[][2] =
9515 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
9516 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
9517 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
9518 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
9519 { EL_EMERALD, EL_WALL_EMERALD },
9520 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
9521 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
9522 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
9523 { EL_DIAMOND, EL_WALL_DIAMOND },
9524 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
9525 { EL_GATE_1, EL_GATE_1_GRAY },
9526 { EL_GATE_2, EL_GATE_2_GRAY },
9527 { EL_GATE_3, EL_GATE_3_GRAY },
9528 { EL_GATE_4, EL_GATE_4_GRAY },
9529 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
9530 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
9531 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
9532 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
9533 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
9534 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
9535 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
9536 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
9537 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
9538 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
9539 { EL_LAMP, EL_LAMP_ACTIVE },
9540 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
9541 { EL_SP_BASE, EL_SP_BUGGY_BASE },
9542 { EL_PEARL, EL_WALL_PEARL },
9543 { EL_CRYSTAL, EL_WALL_CRYSTAL },
9544 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
9545 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
9546 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
9547 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
9548 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
9549 { EL_LANDMINE, EL_DC_LANDMINE },
9550 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
9551 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
9552 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
9553 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
9554 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
9558 static int rotatable_elements[][4] =
9576 EL_BD_BUTTERFLY_RIGHT,
9577 EL_BD_BUTTERFLY_DOWN,
9578 EL_BD_BUTTERFLY_LEFT
9583 EL_BD_FIREFLY_RIGHT,
9617 EL_SP_GRAVITY_PORT_UP,
9618 EL_SP_GRAVITY_PORT_RIGHT,
9619 EL_SP_GRAVITY_PORT_DOWN,
9620 EL_SP_GRAVITY_PORT_LEFT
9624 EL_SP_GRAVITY_ON_PORT_UP,
9625 EL_SP_GRAVITY_ON_PORT_RIGHT,
9626 EL_SP_GRAVITY_ON_PORT_DOWN,
9627 EL_SP_GRAVITY_ON_PORT_LEFT
9631 EL_SP_GRAVITY_OFF_PORT_UP,
9632 EL_SP_GRAVITY_OFF_PORT_RIGHT,
9633 EL_SP_GRAVITY_OFF_PORT_DOWN,
9634 EL_SP_GRAVITY_OFF_PORT_LEFT
9645 EL_BALLOON_SWITCH_UP,
9646 EL_BALLOON_SWITCH_RIGHT,
9647 EL_BALLOON_SWITCH_DOWN,
9648 EL_BALLOON_SWITCH_LEFT
9660 for (i = 0; swappable_elements[i][0] != -1; i++)
9662 int element1 = swappable_elements[i][0];
9663 int element2 = swappable_elements[i][1];
9665 if (old_element == element1 || old_element == element2)
9666 new_element = (old_element == element1 ? element2 : element1);
9669 for (i = 0; rotatable_elements[i][0] != -1; i++)
9671 for (j = 0; j < 4; j++)
9673 int element = rotatable_elements[i][j];
9675 if (old_element == element)
9676 new_element = (button == 1 ? rotatable_elements[i][(j + 3) % 4] :
9677 button == 2 ? rotatable_elements[i][0] :
9678 button == 3 ? rotatable_elements[i][(j + 1) % 4] :
9684 SetElementSimple(x, y, new_element, change_level);
9690 static void ResetIntelliDraw()
9694 for (x = 0; x < lev_fieldx; x++)
9695 for (y = 0; y < lev_fieldy; y++)
9696 IntelliDrawBuffer[x][y] = Feld[x][y];
9698 SetElementIntelliDraw(-1, -1, EL_UNDEFINED, FALSE, -1);
9701 static void SetElementExt(int x, int y, int element, boolean change_level,
9705 SetElementSimple(x, y, Feld[x][y], change_level);
9706 else if (GetKeyModState() & KMOD_Shift)
9707 SetElementIntelliDraw(x, y, element, change_level, button);
9709 SetElementSimple(x, y, element, change_level);
9712 static void SetElement(int x, int y, int element)
9714 SetElementExt(x, y, element, TRUE, -1);
9717 static void SetElementButton(int x, int y, int element, int button)
9719 SetElementExt(x, y, element, TRUE, button);
9722 static void DrawLineElement(int sx, int sy, int element, boolean change_level)
9724 int lx = sx + level_xpos;
9725 int ly = sy + level_ypos;
9727 SetElementExt(lx, ly, element, change_level, -1);
9730 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
9731 int element, boolean change_level)
9733 int xsize = ABS(to_x - from_x);
9734 int ysize = ABS(to_y - from_y);
9735 int dx = (to_x < from_x ? -1 : +1);
9736 int dy = (to_y < from_y ? -1 : +1);
9739 if (from_y == to_y) /* horizontal line */
9741 for (i = 0; i <= xsize; i++)
9742 DrawLineElement(from_x + i * dx, from_y, element, change_level);
9744 else if (from_x == to_x) /* vertical line */
9746 for (i = 0; i <= ysize; i++)
9747 DrawLineElement(from_x, from_y + i * dy, element, change_level);
9749 else /* diagonal line */
9751 if (ysize < xsize) /* a < 1 */
9753 float a = (float)ysize / (float)xsize;
9755 for (i = 0; i <= xsize; i++)
9758 int y = dy * (int)(a * i + 0.5);
9760 DrawLineElement(from_x + x, from_y + y, element, change_level);
9765 float a = (float)xsize / (float)ysize;
9767 for (i = 0; i <= ysize; i++)
9769 int x = dx * (int)(a * i + 0.5);
9772 DrawLineElement(from_x + x, from_y + y, element, change_level);
9778 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
9779 int element, boolean change_level)
9781 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
9782 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
9783 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
9784 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
9787 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
9788 int element, boolean change_level)
9793 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
9795 for (y = from_y; y <= to_y; y++)
9796 DrawLine(from_x, y, to_x, y, element, change_level);
9799 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
9800 int element, boolean change_level)
9802 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
9803 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
9804 int len_x = ABS(to_x - from_x);
9805 int len_y = ABS(to_y - from_y);
9808 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
9810 /* not optimal (some points get drawn twice) but simple,
9811 and fast enough for the few points we are drawing */
9813 for (x = 0; x <= radius; x++)
9817 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
9819 sx = from_x + x * (from_x < to_x2 ? +1 : -1);
9820 sy = from_y + y * (from_y < to_y2 ? +1 : -1);
9821 lx = sx + level_xpos;
9822 ly = sy + level_ypos;
9824 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
9825 DrawLineElement(sx, sy, element, change_level);
9828 for (y = 0; y <= radius; y++)
9832 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
9834 sx = from_x + x * (from_x < to_x2 ? +1 : -1);
9835 sy = from_y + y * (from_y < to_y2 ? +1 : -1);
9836 lx = sx + level_xpos;
9837 ly = sy + level_ypos;
9839 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
9840 DrawLineElement(sx, sy, element, change_level);
9844 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
9845 int element, boolean change_level)
9847 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
9848 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
9850 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
9853 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
9855 #if DRAW_CIRCLES_BUTTON_AVAILABLE
9856 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
9857 int element, boolean change_level)
9859 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
9860 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
9861 int mirror_to_x2 = from_x - (to_x2 - from_x);
9862 int mirror_to_y2 = from_y - (to_y2 - from_y);
9864 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
9865 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
9866 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
9867 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element,change_level);
9871 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
9873 int from_sx, from_sy;
9877 swap_numbers(&from_x, &to_x);
9880 swap_numbers(&from_y, &to_y);
9882 from_sx = SX + from_x * MINI_TILEX;
9883 from_sy = SY + from_y * MINI_TILEY;
9884 to_sx = SX + to_x * MINI_TILEX + MINI_TILEX - 1;
9885 to_sy = SY + to_y * MINI_TILEY + MINI_TILEY - 1;
9887 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
9888 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
9889 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
9890 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
9892 if (from_x == to_x && from_y == to_y)
9893 MarkTileDirty(from_x/2, from_y/2);
9895 redraw_mask |= REDRAW_FIELD;
9898 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
9899 int element, boolean change_level)
9901 if (element == -1 || change_level)
9902 DrawBox(from_x, from_y, to_x, to_y, -1, FALSE);
9904 DrawAreaBorder(from_x, from_y, to_x, to_y);
9907 /* values for CopyBrushExt() */
9908 #define CB_AREA_TO_BRUSH 0
9909 #define CB_BRUSH_TO_CURSOR 1
9910 #define CB_BRUSH_TO_LEVEL 2
9911 #define CB_DELETE_OLD_CURSOR 3
9912 #define CB_DUMP_BRUSH 4
9913 #define CB_DUMP_BRUSH_SMALL 5
9915 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
9916 int button, int mode)
9918 static short brush_buffer[MAX_ED_FIELDX][MAX_ED_FIELDY];
9919 static int brush_width, brush_height;
9920 static int last_cursor_x = -1, last_cursor_y = -1;
9921 static boolean delete_old_brush;
9922 int new_element = BUTTON_ELEMENT(button);
9925 if (mode == CB_DUMP_BRUSH ||
9926 mode == CB_DUMP_BRUSH_SMALL)
9928 if (!draw_with_brush)
9930 Error(ERR_WARN, "no brush selected");
9935 for (y = 0; y < brush_height; y++)
9937 for (x = 0; x < brush_width; x++)
9939 int element = brush_buffer[x][y];
9940 int element_mapped = element;
9942 if (IS_CUSTOM_ELEMENT(element))
9943 element_mapped = EL_CUSTOM_START;
9944 else if (IS_GROUP_ELEMENT(element))
9945 element_mapped = EL_GROUP_START;
9946 else if (element >= NUM_FILE_ELEMENTS)
9947 element_mapped = EL_UNKNOWN;
9949 printf("%c%03d", (mode == CB_DUMP_BRUSH ? '`' : '¸'), element_mapped);
9958 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
9961 if (mode == CB_AREA_TO_BRUSH)
9963 int from_lx, from_ly;
9966 swap_numbers(&from_x, &to_x);
9969 swap_numbers(&from_y, &to_y);
9971 brush_width = to_x - from_x + 1;
9972 brush_height = to_y - from_y + 1;
9974 from_lx = from_x + level_xpos;
9975 from_ly = from_y + level_ypos;
9977 for (y = 0; y < brush_height; y++)
9979 for (x = 0; x < brush_width; x++)
9981 brush_buffer[x][y] = Feld[from_lx + x][from_ly + y];
9984 DrawLineElement(from_x + x, from_y + y, new_element, TRUE);
9989 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
9991 delete_old_brush = FALSE;
9993 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
9994 mode == CB_BRUSH_TO_LEVEL)
9996 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
9997 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
9998 int cursor_from_x = cursor_x - brush_width / 2;
9999 int cursor_from_y = cursor_y - brush_height / 2;
10000 int border_from_x = cursor_x, border_from_y = cursor_y;
10001 int border_to_x = cursor_x, border_to_y = cursor_y;
10003 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
10004 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
10006 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
10007 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
10009 delete_old_brush = FALSE;
10013 for (y = 0; y < brush_height; y++)
10015 for (x = 0; x < brush_width; x++)
10017 int sx = cursor_from_x + x;
10018 int sy = cursor_from_y + y;
10019 int lx = sx + level_xpos;
10020 int ly = sy + level_ypos;
10021 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
10022 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
10023 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
10024 brush_buffer[x][y] : new_element);
10026 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
10028 if (sx < border_from_x)
10029 border_from_x = sx;
10030 else if (sx > border_to_x)
10032 if (sy < border_from_y)
10033 border_from_y = sy;
10034 else if (sy > border_to_y)
10037 DrawLineElement(sx, sy, element, change_level);
10042 if (mode != CB_DELETE_OLD_CURSOR)
10043 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
10045 last_cursor_x = cursor_x;
10046 last_cursor_y = cursor_y;
10047 delete_old_brush = TRUE;
10051 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
10054 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
10057 static void CopyBrushToLevel(int x, int y, int button)
10059 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
10062 static void CopyBrushToCursor(int x, int y)
10064 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
10067 static void DeleteBrushFromCursor()
10069 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
10074 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
10077 void DumpBrush_Small()
10079 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
10082 static void FloodFill(int from_x, int from_y, int fill_element)
10084 FloodFillLevel(from_x, from_y, fill_element, Feld, lev_fieldx, lev_fieldy);
10087 /* values for DrawLevelText() modes */
10088 #define TEXT_INIT 0
10089 #define TEXT_SETCURSOR 1
10090 #define TEXT_WRITECHAR 2
10091 #define TEXT_BACKSPACE 3
10092 #define TEXT_NEWLINE 4
10094 #define TEXT_QUERY_TYPING 6
10096 static int DrawLevelText(int sx, int sy, char letter, int mode)
10098 static short delete_buffer[MAX_LEV_FIELDX];
10099 static int start_sx, start_sy;
10100 static int last_sx, last_sy;
10101 static boolean typing = FALSE;
10102 int letter_element = EL_CHAR_ASCII0 + letter;
10103 int lx = 0, ly = 0;
10105 /* map lower case letters to upper case and convert special characters */
10106 if (letter >= 'a' && letter <= 'z')
10107 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
10108 else if (letter == 'ä' || letter == 'Ä')
10109 letter_element = EL_CHAR_AUMLAUT;
10110 else if (letter == 'ö' || letter == 'Ö')
10111 letter_element = EL_CHAR_OUMLAUT;
10112 else if (letter == 'ü' || letter == 'Ü')
10113 letter_element = EL_CHAR_UUMLAUT;
10114 else if (letter == '^')
10115 letter_element = EL_CHAR_COPYRIGHT;
10117 letter_element = EL_CHAR_ASCII0 + letter;
10119 if (mode != TEXT_INIT)
10124 if (mode != TEXT_SETCURSOR)
10130 lx = last_sx + level_xpos;
10131 ly = last_sy + level_ypos;
10138 DrawLevelText(0, 0, 0, TEXT_END);
10141 start_sx = last_sx = sx;
10142 start_sy = last_sy = sy;
10143 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
10146 case TEXT_SETCURSOR:
10147 DrawMiniElement(last_sx, last_sy, Feld[lx][ly]);
10148 DrawAreaBorder(sx, sy, sx, sy);
10153 case TEXT_WRITECHAR:
10154 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
10156 delete_buffer[sx - start_sx] = Feld[lx][ly];
10157 Feld[lx][ly] = letter_element;
10159 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
10160 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
10161 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
10162 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
10164 DrawLevelText(0, 0, 0, TEXT_END);
10166 level.changed = TRUE;
10170 case TEXT_BACKSPACE:
10173 Feld[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
10174 DrawMiniElement(sx - 1, sy, Feld[lx - 1][ly]);
10175 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
10180 if (sy + 1 < ed_fieldy - 1 && ly + 1 < lev_fieldy - 1)
10181 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
10183 DrawLevelText(0, 0, 0, TEXT_END);
10187 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10188 DrawMiniElement(sx, sy, Feld[lx][ly]);
10192 case TEXT_QUERY_TYPING:
10202 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
10203 int element, boolean change_level)
10205 int lx = sx + level_xpos;
10206 int ly = sy + level_ypos;
10209 DrawMiniElement(sx, sy, Feld[lx][ly]);
10211 DrawAreaBorder(sx, sy, sx, sy);
10214 static void CheckLevelBorderElement(boolean redraw_playfield)
10216 int last_border_element = BorderElement;
10218 SetBorderElement();
10220 if (redraw_playfield && BorderElement != last_border_element)
10221 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10224 static void CopyLevelToUndoBuffer(int mode)
10226 static boolean accumulated_undo = FALSE;
10227 boolean new_undo_buffer_position = TRUE;
10232 case UNDO_IMMEDIATE:
10233 accumulated_undo = FALSE;
10236 case UNDO_ACCUMULATE:
10237 if (accumulated_undo)
10238 new_undo_buffer_position = FALSE;
10239 accumulated_undo = TRUE;
10246 if (new_undo_buffer_position)
10248 /* new position in undo buffer ring */
10249 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
10251 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
10252 undo_buffer_steps++;
10255 for (x = 0; x < lev_fieldx; x++)
10256 for (y = 0; y < lev_fieldy; y++)
10257 UndoBuffer[undo_buffer_position][x][y] = Feld[x][y];
10259 /* check if drawing operation forces change of border style */
10260 CheckLevelBorderElement(TRUE);
10262 level.changed = TRUE;
10265 static void RandomPlacement(int new_element)
10267 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
10268 int num_free_positions = 0;
10269 int num_percentage, num_elements;
10273 ResetIntelliDraw();
10276 /* determine number of free positions for randomly placing the new element */
10277 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
10279 free_position[x][y] =
10280 (random_placement_background_restricted ?
10281 Feld[x][y] == random_placement_background_element :
10282 Feld[x][y] != new_element);
10284 if (free_position[x][y])
10285 num_free_positions++;
10288 /* determine number of new elements to place there */
10289 num_percentage = num_free_positions * random_placement_value / 100;
10290 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
10291 num_percentage : random_placement_value);
10293 /* if less free positions than elements to place, fill all these positions */
10294 if (num_free_positions < num_elements)
10296 for (x = 0; x < lev_fieldx; x++)
10297 for (y = 0; y < lev_fieldy; y++)
10298 if (free_position[x][y])
10300 SetElement(x, y, new_element);
10302 Feld[x][y] = new_element;
10307 while (num_elements > 0)
10309 x = GetSimpleRandom(lev_fieldx);
10310 y = GetSimpleRandom(lev_fieldy);
10312 /* don't place element at the same position twice */
10313 if (free_position[x][y])
10315 free_position[x][y] = FALSE;
10317 SetElement(x, y, new_element);
10319 Feld[x][y] = new_element;
10326 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10327 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10330 void WrapLevel(int dx, int dy)
10332 int wrap_dx = lev_fieldx - dx;
10333 int wrap_dy = lev_fieldy - dy;
10336 for (x = 0; x < lev_fieldx; x++)
10337 for (y = 0; y < lev_fieldy; y++)
10338 FieldBackup[x][y] = Feld[x][y];
10340 for (x = 0; x < lev_fieldx; x++)
10341 for (y = 0; y < lev_fieldy; y++)
10343 FieldBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
10345 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10346 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
10349 static void HandleDrawingAreas(struct GadgetInfo *gi)
10351 static boolean started_inside_drawing_area = FALSE;
10352 int id = gi->custom_id;
10353 boolean button_press_event;
10354 boolean button_release_event;
10355 boolean inside_drawing_area = !gi->event.off_borders;
10356 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
10357 int actual_drawing_function;
10358 int button = gi->event.button;
10359 int new_element = BUTTON_ELEMENT(button);
10360 int sx = gi->event.x, sy = gi->event.y;
10361 int min_sx = 0, min_sy = 0;
10362 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
10363 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
10364 int lx = 0, ly = 0;
10365 int min_lx = 0, min_ly = 0;
10366 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
10369 /* handle info callback for each invocation of action callback */
10370 gi->callback_info(gi);
10372 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
10373 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
10375 /* make sure to stay inside drawing area boundaries */
10376 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
10377 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
10381 /* get positions inside level field */
10382 lx = sx + level_xpos;
10383 ly = sy + level_ypos;
10385 if (!IN_LEV_FIELD(lx, ly))
10386 inside_drawing_area = FALSE;
10388 /* make sure to stay inside level field boundaries */
10389 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
10390 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
10392 /* correct drawing area positions accordingly */
10393 sx = lx - level_xpos;
10394 sy = ly - level_ypos;
10397 if (button_press_event)
10398 started_inside_drawing_area = inside_drawing_area;
10400 if (!started_inside_drawing_area)
10403 if (!IS_VALID_BUTTON(button))
10406 if (!button && !button_release_event)
10409 /* automatically switch to 'single item' drawing mode, if needed */
10410 actual_drawing_function =
10411 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
10412 drawing_function : GADGET_ID_SINGLE_ITEMS);
10414 /* clicking into drawing area with pressed Control key picks element */
10415 if (GetKeyModState() & KMOD_Control)
10417 last_drawing_function = drawing_function;
10418 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
10421 if (GetKeyModState() & KMOD_Shift)
10423 if (button_press_event || button_release_event)
10424 ResetIntelliDraw();
10427 switch (actual_drawing_function)
10429 case GADGET_ID_SINGLE_ITEMS:
10432 if (button_release_event)
10434 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10436 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
10437 !inside_drawing_area)
10438 DeleteBrushFromCursor();
10441 ResetIntelliDraw();
10445 if (!button || button_release_event)
10448 if (draw_with_brush)
10451 if (!button_release_event)
10453 CopyBrushToLevel(sx, sy, button);
10458 else if (new_element != Feld[lx][ly])
10461 if (new_element == EL_PLAYER_1)
10463 /* remove player at old position */
10464 for (y = 0; y < lev_fieldy; y++)
10466 for (x = 0; x < lev_fieldx; x++)
10468 if (Feld[x][y] == EL_PLAYER_1)
10471 SetElement(x, y, EL_EMPTY);
10473 Feld[x][y] = EL_EMPTY;
10475 if (IN_ED_FIELD(x - level_xpos, y - level_ypos))
10476 DrawMiniElement(x - level_xpos, y - level_ypos, EL_EMPTY);
10478 if (x - level_xpos >= 0 && x - level_xpos < ed_fieldx &&
10479 y - level_ypos >= 0 && y - level_ypos < ed_fieldy)
10480 DrawMiniElement(x - level_xpos, y - level_ypos, EL_EMPTY);
10489 SetElementButton(lx, ly, new_element, button);
10491 Feld[lx][ly] = new_element;
10492 DrawMiniElement(sx, sy, new_element);
10498 int type_id = gi->custom_type_id;
10499 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
10501 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
10502 DrawMiniGraphicExt(drawto,
10503 gi->x + sx * MINI_TILEX,
10504 gi->y + sy * MINI_TILEY,
10505 el2edimg(new_element));
10507 DrawGraphicExt(drawto,
10508 gi->x + sx * TILEX,
10509 gi->y + sy * TILEY,
10510 el2img(new_element), 0);
10512 if (id == GADGET_ID_CUSTOM_GRAPHIC)
10513 new_element = GFX_ELEMENT(new_element);
10515 drawingarea_info[type_id].value[pos] = new_element;
10517 CopyElementPropertiesToGame(properties_element);
10519 if (id == GADGET_ID_CUSTOM_GRAPHIC)
10521 UpdateCustomElementGraphicGadgets();
10523 FrameCounter = 0; /* restart animation frame counter */
10528 case GADGET_ID_CONNECTED_ITEMS:
10530 static int last_sx = -1;
10531 static int last_sy = -1;
10533 if (button_release_event)
10534 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10538 if (!button_press_event)
10539 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
10547 case GADGET_ID_LINE:
10548 case GADGET_ID_ARC:
10549 case GADGET_ID_RECTANGLE:
10550 case GADGET_ID_FILLED_BOX:
10551 case GADGET_ID_GRAB_BRUSH:
10552 case GADGET_ID_TEXT:
10554 static int last_sx = -1;
10555 static int last_sy = -1;
10556 static int start_sx = -1;
10557 static int start_sy = -1;
10558 void (*draw_func)(int, int, int, int, int, boolean);
10560 if (drawing_function == GADGET_ID_LINE)
10561 draw_func = DrawLine;
10562 else if (drawing_function == GADGET_ID_ARC)
10563 draw_func = DrawArc;
10564 else if (drawing_function == GADGET_ID_RECTANGLE)
10565 draw_func = DrawBox;
10566 else if (drawing_function == GADGET_ID_FILLED_BOX)
10567 draw_func = DrawFilledBox;
10568 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
10569 draw_func = SelectArea;
10570 else /* (drawing_function == GADGET_ID_TEXT) */
10571 draw_func = SetTextCursor;
10573 if (button_press_event)
10575 draw_func(sx, sy, sx, sy, new_element, FALSE);
10576 start_sx = last_sx = sx;
10577 start_sy = last_sy = sy;
10579 if (drawing_function == GADGET_ID_TEXT)
10580 DrawLevelText(0, 0, 0, TEXT_END);
10582 else if (button_release_event)
10584 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
10585 if (drawing_function == GADGET_ID_GRAB_BRUSH)
10587 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
10588 CopyBrushToCursor(sx, sy);
10589 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
10591 draw_with_brush = TRUE;
10593 else if (drawing_function == GADGET_ID_TEXT)
10594 DrawLevelText(sx, sy, 0, TEXT_INIT);
10596 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10598 else if (last_sx != sx || last_sy != sy)
10600 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
10601 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
10608 case GADGET_ID_FLOOD_FILL:
10609 if (button_press_event && Feld[lx][ly] != new_element)
10611 FloodFill(lx, ly, new_element);
10612 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10613 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10617 case GADGET_ID_PICK_ELEMENT:
10618 if (button_release_event)
10619 ClickOnGadget(level_editor_gadget[last_drawing_function],
10621 else if (draw_level)
10622 PickDrawingElement(button, Feld[lx][ly]);
10625 int type_id = gi->custom_type_id;
10626 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
10628 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
10638 static void HandleCounterButtons(struct GadgetInfo *gi)
10640 int gadget_id = gi->custom_id;
10641 int counter_id = gi->custom_type_id;
10642 int button = gi->event.button;
10643 int *counter_value = counterbutton_info[counter_id].value;
10644 int step = BUTTON_STEPSIZE(button) *
10645 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
10647 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
10649 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
10650 boolean released = (gi->event.type == GD_EVENT_RELEASED);
10651 boolean level_changed = LevelChanged();
10653 if ((level_changed && pressed) || (!level_changed && released))
10656 if (level_changed && !Request("Level has changed ! Discard changes ?",
10659 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
10660 ModifyEditorCounterValue(counter_id, *counter_value);
10666 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
10667 *counter_value = gi->textinput.number_value;
10669 ModifyEditorCounterValue(counter_id, *counter_value + step);
10671 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
10673 LoadLevel(level_nr);
10674 LoadScore(level_nr);
10679 DrawEditModeWindow();
10684 switch (counter_id)
10686 case ED_COUNTER_ID_YAMYAM_CONTENT:
10687 DrawYamYamContentAreas();
10690 case ED_COUNTER_ID_BALL_CONTENT:
10691 DrawMagicBallContentAreas();
10694 case ED_COUNTER_ID_ANDROID_CONTENT:
10695 DrawAndroidElementArea(properties_element);
10698 case ED_COUNTER_ID_GROUP_CONTENT:
10699 DrawGroupElementArea(properties_element);
10700 CopyGroupElementPropertiesToGame(properties_element);
10703 case ED_COUNTER_ID_INVENTORY_SIZE:
10704 DrawPlayerInitialInventoryArea(properties_element);
10707 case ED_COUNTER_ID_ENVELOPE_XSIZE:
10708 case ED_COUNTER_ID_ENVELOPE_YSIZE:
10709 DrawEnvelopeTextArea(-1);
10712 case ED_COUNTER_ID_LEVEL_XSIZE:
10713 case ED_COUNTER_ID_LEVEL_YSIZE:
10714 lev_fieldx = level.fieldx;
10715 lev_fieldy = level.fieldy;
10722 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
10723 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
10724 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
10725 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
10726 CopyElementPropertiesToGame(properties_element);
10728 level.changed = TRUE;
10731 static void HandleTextInputGadgets(struct GadgetInfo *gi)
10733 int type_id = gi->custom_type_id;
10735 strcpy(textinput_info[type_id].value, gi->textinput.value);
10737 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
10739 CopyElementPropertiesToGame(properties_element);
10741 ModifyEditorElementList(); /* update changed button info text */
10744 level.changed = TRUE;
10747 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
10749 int type_id = gi->custom_type_id;
10752 strncpy(textarea_info[type_id].value, gi->textarea.value,
10753 MAX_ENVELOPE_TEXT_LEN);
10754 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
10756 /* !!! BUGGY !!! MAX_ENVELOPE_TEXT_LEN != MAX_GADGET_TEXTSIZE !!! */
10757 strcpy(textarea_info[type_id].value, gi->textarea.value);
10760 level.changed = TRUE;
10763 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
10765 int type_id = gi->custom_type_id;
10766 int value_old = *selectbox_info[type_id].value;
10767 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
10769 *selectbox_info[type_id].value = value_new;
10771 if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
10773 element_info[properties_element].current_change_page = gi->selectbox.index;
10775 DrawPropertiesWindow();
10777 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
10778 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
10779 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
10780 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
10781 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
10783 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
10785 /* when changing action type, also check action mode and action arg */
10786 if (value_old != value_new)
10787 setSelectboxSpecialActionVariablesIfNeeded();
10789 DrawPropertiesChange();
10792 CopyElementPropertiesToGame(properties_element);
10794 level.changed = TRUE;
10798 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
10800 int type_id = gi->custom_type_id;
10803 if (type_id >= ED_TEXTBUTTON_ID_LEVELINFO_FIRST &&
10804 type_id <= ED_TEXTBUTTON_ID_LEVELINFO_LAST)
10806 edit_mode_levelinfo = gi->custom_type_id;
10808 DrawLevelInfoWindow();
10810 else if (type_id >= ED_TEXTBUTTON_ID_PROPERTIES_FIRST &&
10811 type_id <= ED_TEXTBUTTON_ID_PROPERTIES_LAST)
10813 edit_mode_properties = gi->custom_type_id;
10815 DrawPropertiesWindow();
10817 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE)
10819 char *template_filename = getDefaultLevelFilename(-1);
10820 boolean new_template = !fileExists(template_filename);
10822 /* backup original "level.field" (needed to track playfield changes) */
10823 CopyPlayfield(level.field, FieldBackup);
10825 /* "SaveLevelTemplate()" uses "level.field", so copy editor playfield */
10826 CopyPlayfield(Feld, level.field);
10828 if (new_template ||
10829 Request("Save this template and kill the old ?", REQ_ASK))
10830 SaveLevelTemplate();
10833 Request("Template saved !", REQ_CONFIRM);
10835 /* restore original "level.field" (needed to track playfield changes) */
10836 CopyPlayfield(FieldBackup, level.field);
10838 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
10839 custom_element.num_change_pages < MAX_CHANGE_PAGES)
10841 struct ElementInfo *ei = &element_info[properties_element];
10843 setElementChangePages(ei, ei->num_change_pages + 1);
10845 /* set new change page to be new current change page */
10846 ei->current_change_page = ei->num_change_pages - 1;
10847 ei->change = &ei->change_page[ei->current_change_page];
10849 setElementChangeInfoToDefaults(ei->change);
10851 DrawPropertiesWindow();
10853 level.changed = TRUE;
10855 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
10856 custom_element.num_change_pages > MIN_CHANGE_PAGES)
10858 struct ElementInfo *ei = &element_info[properties_element];
10860 /* copy all change pages after change page to be deleted */
10861 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
10862 ei->change_page[i] = ei->change_page[i + 1];
10864 setElementChangePages(ei, ei->num_change_pages - 1);
10866 DrawPropertiesWindow();
10868 level.changed = TRUE;
10872 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
10874 int type_id = gi->custom_type_id;
10876 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
10877 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
10879 struct ElementInfo *ei = &element_info[properties_element];
10880 int step = BUTTON_STEPSIZE(gi->event.button);
10882 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
10883 ei->current_change_page += step;
10885 if (ei->current_change_page < 0)
10886 ei->current_change_page = 0;
10887 else if (ei->current_change_page >= ei->num_change_pages)
10888 ei->current_change_page = ei->num_change_pages - 1;
10890 DrawPropertiesWindow();
10892 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
10893 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
10895 struct ElementInfo *ei = &element_info[properties_element];
10896 int current_change_page = ei->current_change_page;
10898 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
10899 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
10900 ei->change_page[current_change_page];
10901 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
10903 ei->change_page[current_change_page] =
10904 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
10906 level.changed = TRUE;
10909 DrawPropertiesWindow();
10913 static void HandleRadiobuttons(struct GadgetInfo *gi)
10915 *radiobutton_info[gi->custom_type_id].value =
10916 radiobutton_info[gi->custom_type_id].checked_value;
10918 level.changed = TRUE;
10921 static void HandleCheckbuttons(struct GadgetInfo *gi)
10923 int type_id = gi->custom_type_id;
10925 *checkbutton_info[type_id].value ^= TRUE;
10927 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
10928 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
10929 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
10930 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
10931 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
10932 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
10933 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
10934 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE))
10936 CopyElementPropertiesToGame(properties_element);
10939 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
10941 UpdateCustomElementGraphicGadgets();
10943 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE)
10945 char *template_filename = getDefaultLevelFilename(-1);
10947 if (level.use_custom_template && !fileExists(template_filename))
10949 Request("No level template found !", REQ_CONFIRM);
10951 level.use_custom_template = FALSE;
10952 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
10957 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
10959 DrawEditModeWindow();
10962 level.changed = TRUE;
10965 static void HandleControlButtons(struct GadgetInfo *gi)
10967 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
10968 static int last_edit_mode = ED_MODE_DRAWING;
10969 static int last_custom_copy_mode = -1;
10970 int id = gi->custom_id;
10971 int button = gi->event.button;
10972 int step = BUTTON_STEPSIZE(button);
10973 int new_element = BUTTON_ELEMENT(button);
10976 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
10977 DrawLevelText(0, 0, 0, TEXT_END);
10979 if (id < ED_NUM_CTRL1_BUTTONS &&
10980 id != GADGET_ID_SINGLE_ITEMS &&
10981 id != GADGET_ID_PROPERTIES &&
10982 id != GADGET_ID_PICK_ELEMENT &&
10983 edit_mode != ED_MODE_DRAWING &&
10984 drawing_function != GADGET_ID_PICK_ELEMENT &&
10985 !(GetKeyModState() & KMOD_Control))
10987 DrawDrawingWindow();
10988 edit_mode = ED_MODE_DRAWING;
10991 /* element copy mode active, but no element button pressed => deactivate */
10992 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
10993 last_custom_copy_mode = -1;
10997 case GADGET_ID_SCROLL_LEFT:
10998 if (level_xpos >= 0)
11000 if (lev_fieldx < ed_fieldx - 2)
11003 level_xpos -= step;
11004 if (level_xpos < -1)
11007 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
11009 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11011 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
11012 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
11016 case GADGET_ID_SCROLL_RIGHT:
11017 if (level_xpos <= lev_fieldx - ed_fieldx)
11019 if (lev_fieldx < ed_fieldx - 2)
11022 level_xpos += step;
11023 if (level_xpos > lev_fieldx - ed_fieldx + 1)
11024 level_xpos = lev_fieldx - ed_fieldx + 1;
11026 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
11028 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11030 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
11031 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
11035 case GADGET_ID_SCROLL_UP:
11036 if (level_ypos >= 0)
11038 if (lev_fieldy < ed_fieldy - 2)
11041 level_ypos -= step;
11042 if (level_ypos < -1)
11045 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
11047 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11049 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
11050 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
11054 case GADGET_ID_SCROLL_DOWN:
11055 if (level_ypos <= lev_fieldy - ed_fieldy)
11057 if (lev_fieldy < ed_fieldy - 2)
11060 level_ypos += step;
11061 if (level_ypos > lev_fieldy - ed_fieldy + 1)
11062 level_ypos = lev_fieldy - ed_fieldy + 1;
11064 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_UP);
11066 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11068 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
11069 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
11073 case GADGET_ID_SCROLL_HORIZONTAL:
11074 level_xpos = gi->event.item_position - 1;
11075 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11078 case GADGET_ID_SCROLL_VERTICAL:
11079 level_ypos = gi->event.item_position - 1;
11080 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11083 case GADGET_ID_SCROLL_LIST_UP:
11084 case GADGET_ID_SCROLL_LIST_DOWN:
11085 case GADGET_ID_SCROLL_LIST_VERTICAL:
11086 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
11087 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
11090 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
11091 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
11093 if (element_shift < 0)
11095 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
11096 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
11098 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
11099 GDI_SCROLLBAR_ITEM_POSITION,
11100 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
11103 ModifyEditorElementList();
11107 case GADGET_ID_WRAP_LEFT:
11108 WrapLevel(-step, 0);
11111 case GADGET_ID_WRAP_RIGHT:
11112 WrapLevel(step, 0);
11115 case GADGET_ID_WRAP_UP:
11116 WrapLevel(0, -step);
11119 case GADGET_ID_WRAP_DOWN:
11120 WrapLevel(0, step);
11123 case GADGET_ID_SINGLE_ITEMS:
11124 case GADGET_ID_CONNECTED_ITEMS:
11125 case GADGET_ID_LINE:
11126 case GADGET_ID_ARC:
11127 case GADGET_ID_TEXT:
11128 case GADGET_ID_RECTANGLE:
11129 case GADGET_ID_FILLED_BOX:
11130 case GADGET_ID_FLOOD_FILL:
11131 case GADGET_ID_GRAB_BRUSH:
11132 case GADGET_ID_PICK_ELEMENT:
11133 if (drawing_function != GADGET_ID_PICK_ELEMENT)
11134 last_drawing_function = drawing_function;
11135 drawing_function = id;
11136 draw_with_brush = FALSE;
11139 case GADGET_ID_RANDOM_PLACEMENT:
11140 RandomPlacement(new_element);
11143 case GADGET_ID_PROPERTIES:
11144 if (edit_mode != ED_MODE_PROPERTIES)
11146 properties_element = new_element;
11147 DrawPropertiesWindow();
11148 edit_mode = ED_MODE_PROPERTIES;
11150 last_level_drawing_function = drawing_function;
11151 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
11156 DrawDrawingWindow();
11157 edit_mode = ED_MODE_DRAWING;
11159 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
11164 case GADGET_ID_CUSTOM_COPY_FROM:
11165 case GADGET_ID_CUSTOM_COPY_TO:
11166 case GADGET_ID_CUSTOM_EXCHANGE:
11167 last_custom_copy_mode = id;
11168 last_drawing_function = drawing_function;
11171 case GADGET_ID_CUSTOM_COPY:
11172 CopyCustomElement(properties_element, -1, id);
11175 case GADGET_ID_CUSTOM_PASTE:
11176 CopyCustomElement(-1, properties_element, id);
11179 case GADGET_ID_UNDO:
11180 if (undo_buffer_steps == 0)
11182 Request("Undo buffer empty !", REQ_CONFIRM);
11186 if (edit_mode != ED_MODE_DRAWING)
11188 DrawDrawingWindow();
11189 edit_mode = ED_MODE_DRAWING;
11192 undo_buffer_position =
11193 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
11194 undo_buffer_steps--;
11196 for (x = 0; x < lev_fieldx; x++)
11197 for (y = 0; y < lev_fieldy; y++)
11198 Feld[x][y] = UndoBuffer[undo_buffer_position][x][y];
11200 /* check if undo operation forces change of border style */
11201 CheckLevelBorderElement(FALSE);
11203 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11207 case GADGET_ID_INFO:
11208 if (edit_mode != ED_MODE_INFO)
11210 last_edit_mode = edit_mode;
11211 edit_mode = ED_MODE_INFO;
11213 DrawLevelInfoWindow();
11217 edit_mode = last_edit_mode;
11219 DrawEditModeWindow();
11223 case GADGET_ID_CLEAR:
11224 if (edit_mode != ED_MODE_DRAWING)
11226 DrawDrawingWindow();
11227 edit_mode = ED_MODE_DRAWING;
11230 for (x = 0; x < MAX_LEV_FIELDX; x++)
11231 for (y = 0; y < MAX_LEV_FIELDY; y++)
11232 Feld[x][y] = (button == 1 ? EL_EMPTY : new_element);
11234 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
11236 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11239 case GADGET_ID_SAVE:
11240 if (leveldir_current->readonly)
11242 Request("This level is read only !", REQ_CONFIRM);
11246 if (!LevelContainsPlayer())
11247 Request("No Level without Gregor Mc Duffin please !", REQ_CONFIRM);
11250 char *level_filename = getDefaultLevelFilename(level_nr);
11251 boolean new_level = !fileExists(level_filename);
11254 Request("Save this level and kill the old ?", REQ_ASK))
11256 CopyPlayfield(Feld, level.field);
11258 SaveLevel(level_nr);
11262 Request("Level saved !", REQ_CONFIRM);
11264 level.changed = FALSE;
11268 case GADGET_ID_TEST:
11269 if (!LevelContainsPlayer())
11270 Request("No Level without Gregor Mc Duffin please !", REQ_CONFIRM);
11273 if (LevelChanged())
11274 level.game_version = GAME_VERSION_ACTUAL;
11276 CopyPlayfield(level.field, FieldBackup);
11277 CopyPlayfield(Feld, level.field);
11279 CopyNativeLevel_RND_to_Native(&level);
11281 UnmapLevelEditorGadgets();
11282 UndrawSpecialEditorDoor();
11284 CloseDoor(DOOR_CLOSE_ALL);
11286 BackToFront(); /* force redraw of undrawn special door */
11288 DrawCompleteVideoDisplay();
11290 level_editor_test_game = TRUE;
11292 StartGameActions(FALSE, setup.autorecord, level.random_seed);
11296 case GADGET_ID_EXIT:
11297 RequestExitLevelEditor(TRUE, FALSE); /* if level has changed, ask user */
11301 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
11302 id <= GADGET_ID_ELEMENTLIST_LAST)
11304 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
11305 int new_element = editor_elements[element_position + element_shift];
11307 if (IS_EDITOR_CASCADE(new_element))
11311 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
11313 int *cascade_element= &(*editor_elements_info[i].headline_list)[0];
11314 boolean *cascade_value=editor_elements_info[i].setup_cascade_value;
11316 if (*cascade_element == new_element)
11318 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
11319 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
11321 /* update element selection list */
11322 ReinitializeElementList();
11323 ModifyEditorElementList();
11325 /* update cascading gadget info text */
11326 PrintEditorGadgetInfoText(level_editor_gadget[id]);
11328 /* save current editor cascading state */
11329 SaveSetup_EditorCascade();
11338 if (last_custom_copy_mode != -1)
11340 if (CopyCustomElement(properties_element, new_element,
11341 last_custom_copy_mode))
11343 ClickOnGadget(level_editor_gadget[last_drawing_function],
11346 last_custom_copy_mode = -1;
11352 PickDrawingElement(button, new_element);
11354 if (!stick_element_properties_window &&
11355 drawing_function != GADGET_ID_PICK_ELEMENT &&
11356 !(GetKeyModState() & KMOD_Control))
11358 properties_element = new_element;
11359 if (edit_mode == ED_MODE_PROPERTIES)
11360 DrawPropertiesWindow();
11363 if (drawing_function == GADGET_ID_PICK_ELEMENT)
11364 ClickOnGadget(level_editor_gadget[last_drawing_function],
11368 else if (gi->event.type == GD_EVENT_PRESSED)
11369 printf("default: HandleControlButtons: GD_EVENT_PRESSED(%d)\n", id);
11370 else if (gi->event.type == GD_EVENT_RELEASED)
11371 printf("default: HandleControlButtons: GD_EVENT_RELEASED(%d)\n", id);
11372 else if (gi->event.type == GD_EVENT_MOVING)
11373 printf("default: HandleControlButtons: GD_EVENT_MOVING(%d)\n", id);
11375 printf("default: HandleControlButtons: ? (id == %d)\n", id);
11381 void HandleLevelEditorKeyInput(Key key)
11383 char letter = getCharFromKey(key);
11384 int button = MB_LEFTBUTTON;
11386 if (drawing_function == GADGET_ID_TEXT &&
11387 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
11390 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
11391 else if (key == KSYM_Delete || key == KSYM_BackSpace)
11392 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
11393 else if (key == KSYM_Return)
11394 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
11395 else if (key == KSYM_Escape)
11396 DrawLevelText(0, 0, 0, TEXT_END);
11398 else if (button_status == MB_RELEASED)
11400 int id = GADGET_ID_NONE;
11401 int new_element_shift = element_shift;
11407 id = GADGET_ID_SCROLL_LEFT;
11410 id = GADGET_ID_SCROLL_RIGHT;
11413 id = GADGET_ID_SCROLL_UP;
11416 id = GADGET_ID_SCROLL_DOWN;
11419 id = GADGET_ID_SCROLL_LIST_UP;
11420 button = MB_RIGHTBUTTON;
11422 case KSYM_Page_Down:
11423 id = GADGET_ID_SCROLL_LIST_DOWN;
11424 button = MB_RIGHTBUTTON;
11429 element_shift = (key == KSYM_Home ? 0 :
11430 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
11432 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
11433 GDI_SCROLLBAR_ITEM_POSITION,
11434 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
11436 ModifyEditorElementList();
11443 /* this is needed to prevent interference with running "True X-Mouse" */
11444 if (GetKeyModStateFromEvents() & KMOD_Control)
11447 /* check for last or next editor cascade block in element list */
11448 for (i = 0; i < num_editor_elements; i++)
11450 if ((key == KSYM_Insert && i == element_shift) ||
11451 (key == KSYM_Delete && new_element_shift > element_shift))
11454 /* jump to next cascade block (or to start of element list) */
11455 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
11456 new_element_shift = i;
11459 if (i < num_editor_elements)
11460 element_shift = new_element_shift;
11462 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
11463 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
11465 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
11466 GDI_SCROLLBAR_ITEM_POSITION,
11467 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
11469 ModifyEditorElementList();
11474 if (edit_mode == ED_MODE_DRAWING)
11476 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
11478 else if (edit_mode == ED_MODE_INFO)
11480 HandleControlButtons(level_editor_gadget[GADGET_ID_INFO]);
11482 else if (edit_mode == ED_MODE_PROPERTIES)
11484 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
11486 else /* should never happen */
11488 DrawDrawingWindow();
11489 edit_mode = ED_MODE_DRAWING;
11498 if (id != GADGET_ID_NONE)
11499 ClickOnGadget(level_editor_gadget[id], button);
11500 else if (letter == '.')
11501 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
11502 else if (key == KSYM_Return || key == setup.shortcut.toggle_pause)
11503 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
11505 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
11506 if (letter && letter == control_info[i].shortcut)
11507 if (!anyTextGadgetActive())
11508 ClickOnGadget(level_editor_gadget[i], button);
11512 void HandleLevelEditorIdle()
11514 static unsigned long action_delay = 0;
11515 unsigned long action_delay_value = GameFrameDelay;
11516 int xpos = 1, ypos = 2;
11519 if (edit_mode != ED_MODE_PROPERTIES)
11522 if (!DelayReached(&action_delay, action_delay_value))
11525 for (i = 0; i < ED_NUM_SELECTBOX; i++)
11527 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
11529 if (gi->mapped && gi->active && gi->selectbox.open)
11533 DrawEditorElementAnimation(SX + xpos * TILEX,
11534 SY + ypos * TILEY + MINI_TILEY / 2);
11536 MarkTileDirty(xpos, ypos);
11537 MarkTileDirty(xpos, ypos + 1);
11539 FrameCounter++; /* increase animation frame counter */
11542 void ClearEditorGadgetInfoText()
11544 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
11547 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
11549 char infotext[MAX_OUTPUT_LINESIZE + 1];
11550 char shortcut[MAX_OUTPUT_LINESIZE + 1];
11551 int max_infotext_len = getMaxInfoTextLength();
11553 if (gi == NULL || gi->info_text == NULL)
11556 strncpy(infotext, gi->info_text, max_infotext_len);
11557 infotext[max_infotext_len] = '\0';
11559 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
11561 int key = control_info[gi->custom_id].shortcut;
11565 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS) /* special case 1 */
11566 sprintf(shortcut, " ('.' or '%c')", key);
11567 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT) /* special case 2 */
11568 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
11569 else if (gi->custom_id == GADGET_ID_TEST) /* special case 3 */
11570 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
11571 else /* normal case */
11572 sprintf(shortcut, " ('%s%c')",
11573 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
11575 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
11576 strcat(infotext, shortcut);
11580 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, FONT_TEXT_2);
11583 void HandleEditorGadgetInfoText(void *ptr)
11585 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
11587 if (game_status != GAME_MODE_EDITOR)
11590 ClearEditorGadgetInfoText();
11592 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
11595 /* misuse this function to delete brush cursor, if needed */
11596 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
11597 DeleteBrushFromCursor();
11599 PrintEditorGadgetInfoText(gi);
11602 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
11604 static int start_lx, start_ly;
11605 int id = gi->custom_id;
11606 int type_id = gi->custom_type_id;
11607 int sx = gi->event.x;
11608 int sy = gi->event.y;
11609 int lx = sx + level_xpos;
11610 int ly = sy + level_ypos;
11611 int min_sx = 0, min_sy = 0;
11612 int max_sx = gi->drawing.area_xsize - 1;
11613 int max_sy = gi->drawing.area_ysize - 1;
11614 int actual_drawing_function = drawing_function;
11615 int max_infotext_len = getMaxInfoTextLength();
11616 char infotext[MAX_OUTPUT_LINESIZE + 1];
11619 infotext[0] = '\0'; /* start with empty info text */
11621 /* pressed Control key: simulate picking element */
11622 if (GetKeyModState() & KMOD_Control)
11623 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
11625 ClearEditorGadgetInfoText();
11627 if (gi->event.type == GD_EVENT_INFO_LEAVING)
11630 /* make sure to stay inside drawing area boundaries */
11631 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
11632 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
11634 if (id == GADGET_ID_DRAWING_LEVEL)
11638 int min_lx = 0, min_ly = 0;
11639 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
11641 /* get positions inside level field */
11642 lx = sx + level_xpos;
11643 ly = sy + level_ypos;
11645 /* make sure to stay inside level field boundaries */
11646 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
11647 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
11649 /* correct drawing area positions accordingly */
11650 sx = lx - level_xpos;
11651 sy = ly - level_ypos;
11654 if (IN_ED_FIELD(sx,sy) && IN_LEV_FIELD(lx, ly))
11656 if (button_status) /* if (gi->state == GD_BUTTON_PRESSED) */
11658 if (gi->event.type == GD_EVENT_PRESSED)
11664 switch (actual_drawing_function)
11666 case GADGET_ID_SINGLE_ITEMS:
11667 text = "Drawing single items";
11669 case GADGET_ID_CONNECTED_ITEMS:
11670 text = "Drawing connected items";
11672 case GADGET_ID_LINE:
11673 text = "Drawing line";
11675 case GADGET_ID_ARC:
11676 text = "Drawing arc";
11678 case GADGET_ID_TEXT:
11679 text = "Setting text cursor";
11681 case GADGET_ID_RECTANGLE:
11682 text = "Drawing rectangle";
11684 case GADGET_ID_FILLED_BOX:
11685 text = "Drawing filled box";
11687 case GADGET_ID_FLOOD_FILL:
11688 text = "Flood fill";
11690 case GADGET_ID_GRAB_BRUSH:
11691 text = "Grabbing brush";
11693 case GADGET_ID_PICK_ELEMENT:
11694 text = "Picking element";
11698 text = "Drawing position";
11702 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
11703 sprintf(infotext, "%s: %d, %d", text, lx, ly);
11705 sprintf(infotext, "%s: %d, %d", text,
11706 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
11708 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
11709 strncpy(infotext, getElementInfoText(Feld[lx][ly]), max_infotext_len);
11711 sprintf(infotext, "Level position: %d, %d", lx, ly);
11714 /* misuse this function to draw brush cursor, if needed */
11715 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
11717 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
11718 CopyBrushToCursor(sx, sy);
11720 DeleteBrushFromCursor();
11723 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
11725 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
11726 int element = drawingarea_info[type_id].value[pos];
11728 strncpy(infotext, getElementInfoText(element), max_infotext_len);
11732 if (id == GADGET_ID_CUSTOM_CONTENT)
11733 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
11734 else if (id == GADGET_ID_GROUP_CONTENT)
11735 sprintf(infotext, "group element position: %d", sx + 1);
11736 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
11737 id <= GADGET_ID_YAMYAM_CONTENT_7)
11738 sprintf(infotext, "content area %d position: %d, %d",
11739 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
11740 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
11741 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
11742 sprintf(infotext, "content area %d position: %d, %d",
11743 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
11744 else if (id == GADGET_ID_ANDROID_CONTENT)
11745 sprintf(infotext, "android element position: %d", sx + 1);
11746 else if (drawingarea_info[type_id].infotext != NULL)
11747 strcpy(infotext, drawingarea_info[type_id].infotext);
11750 infotext[max_infotext_len] = '\0';
11752 if (strlen(infotext) > 0)
11753 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, infotext);
11756 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
11757 boolean quick_quit)
11759 if (!ask_if_level_has_changed ||
11761 Request("Level has changed ! Exit without saving ?",
11762 REQ_ASK | REQ_STAY_OPEN))
11764 CloseDoor(DOOR_CLOSE_1);
11765 SetDoorState(DOOR_CLOSE_2);
11769 FadeSkipNextFadeIn();
11772 fading = fading_none;
11775 game_status = GAME_MODE_MAIN;
11777 DrawAndFadeInMainMenu(REDRAW_FIELD);
11784 CloseDoor(DOOR_CLOSE_1);
11785 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);