1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-2006 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
16 #include "libgame/libgame.h"
27 #define INFOTEXT_UNKNOWN_ELEMENT "unknown"
31 -----------------------------------------------------------------------------
32 screen and artwork graphic pixel position definitions
33 -----------------------------------------------------------------------------
36 /* positions in the level editor */
37 #define ED_WIN_MB_LEFT_XPOS 6
38 #define ED_WIN_MB_LEFT_YPOS 258
39 #define ED_WIN_MB_MIDDLE_XPOS 42
40 #define ED_WIN_MB_MIDDLE_YPOS ED_WIN_MB_LEFT_YPOS
41 #define ED_WIN_MB_RIGHT_XPOS 78
42 #define ED_WIN_MB_RIGHT_YPOS ED_WIN_MB_LEFT_YPOS
44 /* values for the control window */
45 #define ED_CTRL_NO_BUTTONS_GFX_XPOS 6
46 #define ED_CTRL_NO_BUTTONS_GFX_YPOS 286
47 #define ED_CTRL1_BUTTONS_GFX_YPOS 236
48 #define ED_CTRL2_BUTTONS_GFX_YPOS 236
49 #define ED_CTRL3_BUTTONS_GFX_YPOS 324
50 #define ED_CTRL4_BUTTONS_GFX_XPOS 44
51 #define ED_CTRL4_BUTTONS_GFX_YPOS 214
52 #define ED_CTRL1_BUTTONS_ALT_GFX_YPOS 142
53 #define ED_CTRL3_BUTTONS_ALT_GFX_YPOS 302
55 #define ED_CTRL1_BUTTON_XSIZE 22
56 #define ED_CTRL1_BUTTON_YSIZE 22
57 #define ED_CTRL1_BUTTONS_XPOS 6
58 #define ED_CTRL1_BUTTONS_YPOS 6
59 #define ED_CTRL2_BUTTON_XSIZE 30
60 #define ED_CTRL2_BUTTON_YSIZE 20
61 #define ED_CTRL2_BUTTONS_XPOS 5
62 #define ED_CTRL2_BUTTONS_YPOS 99
63 #define ED_CTRL3_BUTTON_XSIZE 22
64 #define ED_CTRL3_BUTTON_YSIZE 22
65 #define ED_CTRL3_BUTTONS_XPOS 6
66 #define ED_CTRL3_BUTTONS_YPOS 6
67 #define ED_CTRL4_BUTTON_XSIZE 22
68 #define ED_CTRL4_BUTTON_YSIZE 22
69 #define ED_CTRL4_BUTTONS_XPOS 6
70 #define ED_CTRL4_BUTTONS_YPOS 6
72 #define ED_CTRL1_BUTTONS_HORIZ 4
73 #define ED_CTRL1_BUTTONS_VERT 4
74 #define ED_CTRL2_BUTTONS_HORIZ 3
75 #define ED_CTRL2_BUTTONS_VERT 2
76 #define ED_CTRL3_BUTTONS_HORIZ 3
77 #define ED_CTRL3_BUTTONS_VERT 1
78 #define ED_CTRL4_BUTTONS_HORIZ 2
79 #define ED_CTRL4_BUTTONS_VERT 1
81 #define ED_NUM_CTRL1_BUTTONS (ED_CTRL1_BUTTONS_HORIZ * ED_CTRL1_BUTTONS_VERT)
82 #define ED_NUM_CTRL2_BUTTONS (ED_CTRL2_BUTTONS_HORIZ * ED_CTRL2_BUTTONS_VERT)
83 #define ED_NUM_CTRL3_BUTTONS (ED_CTRL3_BUTTONS_HORIZ * ED_CTRL3_BUTTONS_VERT)
84 #define ED_NUM_CTRL4_BUTTONS (ED_CTRL4_BUTTONS_HORIZ * ED_CTRL4_BUTTONS_VERT)
85 #define ED_NUM_CTRL1_2_BUTTONS (ED_NUM_CTRL1_BUTTONS + ED_NUM_CTRL2_BUTTONS)
86 #define ED_NUM_CTRL1_3_BUTTONS (ED_NUM_CTRL1_2_BUTTONS + ED_NUM_CTRL3_BUTTONS)
87 #define ED_NUM_CTRL_BUTTONS (ED_NUM_CTRL1_BUTTONS + \
88 ED_NUM_CTRL2_BUTTONS + \
89 ED_NUM_CTRL3_BUTTONS + \
92 /* values for the element list */
93 #define ED_ELEMENTLIST_XPOS 5
94 #define ED_ELEMENTLIST_YPOS 30
95 #define ED_ELEMENTLIST_XSIZE 20
96 #define ED_ELEMENTLIST_YSIZE 20
97 #define ED_ELEMENTLIST_BUTTONS_HORIZ 4
98 #define ED_ELEMENTLIST_BUTTONS_VERT 11
99 #define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \
100 ED_ELEMENTLIST_BUTTONS_VERT)
102 /* standard distances */
103 #define ED_BORDER_SIZE 3
104 #define ED_BORDER_TEXT_XSIZE 5
105 #define ED_BORDER_AREA_YSIZE 1
107 #define ED_GADGET_DISTANCE 2
108 #define ED_GADGET_TEXT_DISTANCE (2 * ED_GADGET_DISTANCE)
109 #define ED_DRAWINGAREA_TEXT_DISTANCE (ED_GADGET_TEXT_DISTANCE + \
112 /* values for the settings windows */
113 #define ED_LEVEL_SETTINGS_XSTART (3 * MINI_TILEX / 2)
114 #define ED_LEVEL_SETTINGS_YSTART (5 * MINI_TILEY)
116 #define ED_ELEMENT_SETTINGS_XSTART (3 * MINI_TILEX / 2)
117 #define ED_ELEMENT_SETTINGS_YSTART (10 * MINI_TILEY)
119 #define ED_XOFFSET_CHECKBOX (ED_CHECKBUTTON_XSIZE + \
120 2 * ED_GADGET_DISTANCE)
122 #define ED_SETTINGS_XOFFSET ED_XOFFSET_CHECKBOX
123 #define ED_SETTINGS_YOFFSET (3 * MINI_TILEY / 2)
125 #define ED_LEVEL_SETTINGS_XPOS(n) (ED_LEVEL_SETTINGS_XSTART + \
126 (n) * ED_SETTINGS_XOFFSET)
127 #define ED_LEVEL_SETTINGS_YPOS(n) (ED_LEVEL_SETTINGS_YSTART + \
128 (n) * ED_SETTINGS_YOFFSET)
130 #define ED_ELEMENT_SETTINGS_XPOS(n) (ED_ELEMENT_SETTINGS_XSTART + \
131 (n) * ED_SETTINGS_XOFFSET)
132 #define ED_ELEMENT_SETTINGS_YPOS(n) (ED_ELEMENT_SETTINGS_YSTART + \
133 (n) * ED_SETTINGS_YOFFSET)
135 #define ED_SETTINGS1_YPOS MINI_TILEY
136 #define ED_SETTINGS2_XPOS MINI_TILEX
137 #define ED_SETTINGS2_YPOS (ED_SETTINGS1_YPOS + 12 * TILEY - 2)
139 /* values for counter gadgets */
140 #define ED_COUNTER_YSTART (ED_SETTINGS1_YPOS + 2 * TILEY)
141 #define ED_COUNTER_YDISTANCE (3 * MINI_TILEY)
142 #define ED_COUNTER_YPOS(n) (ED_COUNTER_YSTART + \
143 (n) * ED_COUNTER_YDISTANCE)
144 #define ED_COUNTER2_YPOS(n) (ED_COUNTER_YSTART + \
145 (n) * ED_COUNTER_YDISTANCE - 2)
147 /* values for element content drawing areas */
148 #define ED_AREA_1X1_SETTINGS_XPOS(n) (ED_ELEMENT_SETTINGS_XPOS(n))
149 #define ED_AREA_1X1_SETTINGS_YPOS(n) (ED_ELEMENT_SETTINGS_YPOS(n) + \
152 #define ED_AREA_3X3_SETTINGS_XPOS(n) (ED_ELEMENT_SETTINGS_XPOS(n))
153 #define ED_AREA_3X3_SETTINGS_YPOS(n) (ED_ELEMENT_SETTINGS_YPOS(n) + \
154 ED_GADGET_DISTANCE - MINI_TILEY)
157 #define ED_AREA_YAMYAM_CONTENT_XPOS(n) (2 * MINI_TILEX + \
158 5 * ((n) % 4) * MINI_TILEX)
159 #define ED_AREA_YAMYAM_CONTENT_YPOS(n) (11 * ED_SETTINGS_YOFFSET + \
160 6 * ((n) / 4) * MINI_TILEY)
162 /* magic ball content */
163 #define ED_AREA_MAGIC_BALL_CONTENT_XPOS(n) (2 * MINI_TILEX + \
164 5 * ((n) % 4) * MINI_TILEX)
165 #define ED_AREA_MAGIC_BALL_CONTENT_YPOS(n) (12 * ED_SETTINGS_YOFFSET + \
166 6 * ((n) / 4) * MINI_TILEY)
168 /* values for scrolling gadgets for drawing area */
169 #define ED_SCROLLBUTTON_XPOS 24
170 #define ED_SCROLLBUTTON_YPOS 0
171 #define ED_SCROLLBAR_XPOS 24
172 #define ED_SCROLLBAR_YPOS 64
174 #define ED_SCROLLBUTTON_XSIZE 16
175 #define ED_SCROLLBUTTON_YSIZE 16
177 #define ED_SCROLL_UP_XPOS (SXSIZE - ED_SCROLLBUTTON_XSIZE)
178 #define ED_SCROLL_UP_YPOS (0)
179 #define ED_SCROLL_DOWN_XPOS ED_SCROLL_UP_XPOS
180 #define ED_SCROLL_DOWN_YPOS (SYSIZE - 3 * ED_SCROLLBUTTON_YSIZE)
181 #define ED_SCROLL_LEFT_XPOS (0)
182 #define ED_SCROLL_LEFT_YPOS (SYSIZE - 2 * ED_SCROLLBUTTON_YSIZE)
183 #define ED_SCROLL_RIGHT_XPOS (SXSIZE - 2 * ED_SCROLLBUTTON_XSIZE)
184 #define ED_SCROLL_RIGHT_YPOS ED_SCROLL_LEFT_YPOS
185 #define ED_SCROLL_HORIZONTAL_XPOS (ED_SCROLL_LEFT_XPOS + \
186 ED_SCROLLBUTTON_XSIZE)
187 #define ED_SCROLL_HORIZONTAL_YPOS ED_SCROLL_LEFT_YPOS
188 #define ED_SCROLL_HORIZONTAL_XSIZE (SXSIZE - 3 * ED_SCROLLBUTTON_XSIZE)
189 #define ED_SCROLL_HORIZONTAL_YSIZE ED_SCROLLBUTTON_YSIZE
190 #define ED_SCROLL_VERTICAL_XPOS ED_SCROLL_UP_XPOS
191 #define ED_SCROLL_VERTICAL_YPOS (ED_SCROLL_UP_YPOS + \
192 ED_SCROLLBUTTON_YSIZE)
193 #define ED_SCROLL_VERTICAL_XSIZE ED_SCROLLBUTTON_XSIZE
194 #define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - 4 * ED_SCROLLBUTTON_YSIZE)
196 /* values for scrolling gadgets for element list */
197 #define ED_SCROLLBUTTON2_XPOS 50
198 #define ED_SCROLLBUTTON2_YPOS 0
199 #define ED_SCROLLBAR2_XPOS 50
200 #define ED_SCROLLBAR2_YPOS 20
202 #define ED_SCROLLBUTTON2_XSIZE 10
203 #define ED_SCROLLBUTTON2_YSIZE 10
205 #define ED_SCROLL2_UP_XPOS 85
206 #define ED_SCROLL2_UP_YPOS 30
207 #define ED_SCROLL2_DOWN_XPOS ED_SCROLL2_UP_XPOS
208 #define ED_SCROLL2_DOWN_YPOS (ED_SCROLL2_UP_YPOS + \
209 ED_ELEMENTLIST_BUTTONS_VERT * \
210 ED_ELEMENTLIST_YSIZE - \
211 ED_SCROLLBUTTON2_YSIZE)
212 #define ED_SCROLL2_VERTICAL_XPOS ED_SCROLL2_UP_XPOS
213 #define ED_SCROLL2_VERTICAL_YPOS (ED_SCROLL2_UP_YPOS + \
214 ED_SCROLLBUTTON2_YSIZE)
215 #define ED_SCROLL2_VERTICAL_XSIZE ED_SCROLLBUTTON2_XSIZE
216 #define ED_SCROLL2_VERTICAL_YSIZE (ED_ELEMENTLIST_BUTTONS_VERT * \
217 ED_ELEMENTLIST_YSIZE - \
218 2 * ED_SCROLLBUTTON2_YSIZE)
220 /* values for checkbutton gadgets */
221 #define ED_CHECKBUTTON_XSIZE ED_BUTTON_COUNT_XSIZE
222 #define ED_CHECKBUTTON_YSIZE ED_BUTTON_COUNT_YSIZE
223 #define ED_CHECKBUTTON_UNCHECKED_XPOS ED_BUTTON_MINUS_XPOS
224 #define ED_CHECKBUTTON_CHECKED_XPOS ED_BUTTON_PLUS_XPOS
225 #define ED_CHECKBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 22)
226 #define ED_RADIOBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 44)
227 #define ED_STICKYBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 66)
229 /* values for some special graphic buttons */
230 #define ED_COPY_CHANGE_PAGE_XPOS 25
231 #define ED_COPY_CHANGE_PAGE_YPOS 50
232 #define ED_PASTE_CHANGE_PAGE_XPOS 25
233 #define ED_PASTE_CHANGE_PAGE_YPOS 70
235 /* some values for text input, selectbox and counter gadgets */
236 #define ED_BUTTON_COUNT_YPOS 60
237 #define ED_BUTTON_COUNT_XSIZE 20
238 #define ED_BUTTON_COUNT_YSIZE 20
239 #define ED_WIN_COUNT_XPOS (2 + ED_BUTTON_COUNT_XSIZE + 2)
240 #define ED_WIN_COUNT_YPOS ED_BUTTON_COUNT_YPOS
241 #define ED_WIN_COUNT_XSIZE 52
242 #define ED_WIN_COUNT_YSIZE ED_BUTTON_COUNT_YSIZE
243 #define ED_WIN_COUNT2_XPOS 27
244 #define ED_WIN_COUNT2_YPOS 3
245 #define ED_WIN_COUNT2_XSIZE 46
246 #define ED_WIN_COUNT2_YSIZE ED_BUTTON_COUNT_YSIZE
248 #define ED_BUTTON_MINUS_XPOS 2
249 #define ED_BUTTON_MINUS_YPOS ED_BUTTON_COUNT_YPOS
250 #define ED_BUTTON_MINUS_XSIZE ED_BUTTON_COUNT_XSIZE
251 #define ED_BUTTON_MINUS_YSIZE ED_BUTTON_COUNT_YSIZE
252 #define ED_BUTTON_PLUS_XPOS (ED_WIN_COUNT_XPOS + \
253 ED_WIN_COUNT_XSIZE + 2)
254 #define ED_BUTTON_PLUS_YPOS ED_BUTTON_COUNT_YPOS
255 #define ED_BUTTON_PLUS_XSIZE ED_BUTTON_COUNT_XSIZE
256 #define ED_BUTTON_PLUS_YSIZE ED_BUTTON_COUNT_YSIZE
258 #define ED_SELECTBOX_XPOS ED_WIN_COUNT_XPOS
259 #define ED_SELECTBOX_YPOS (ED_WIN_COUNT_YPOS + \
260 2 + ED_WIN_COUNT_YSIZE)
261 #define ED_SELECTBOX_XSIZE ED_WIN_COUNT_XSIZE
262 #define ED_SELECTBOX_YSIZE ED_WIN_COUNT_YSIZE
264 #define ED_SELECTBOX_BUTTON_XSIZE 14
266 #define ED_TEXTBUTTON_XPOS ED_WIN_COUNT_XPOS
267 #define ED_TEXTBUTTON_YPOS (ED_WIN_COUNT_YPOS + \
268 4 * (2 + ED_WIN_COUNT_YSIZE))
269 #define ED_TEXTBUTTON_INACTIVE_YPOS ED_TEXTBUTTON_YPOS
271 #define ED_TEXTBUTTON_TAB_XPOS ED_WIN_COUNT_XPOS
272 #define ED_TEXTBUTTON_TAB_YPOS (ED_WIN_COUNT_YPOS + \
273 2 * (2 + ED_WIN_COUNT_YSIZE))
274 #define ED_TEXTBUTTON_TAB_INACTIVE_YPOS (ED_WIN_COUNT_YPOS + \
275 3 * (2 + ED_WIN_COUNT_YSIZE))
277 #define ED_TEXTBUTTON_XSIZE ED_WIN_COUNT_XSIZE
278 #define ED_TEXTBUTTON_YSIZE ED_WIN_COUNT_YSIZE
280 /* values for ClearEditorGadgetInfoText() and HandleEditorGadgetInfoText() */
281 #define INFOTEXT_XPOS SX
282 #define INFOTEXT_YPOS (SY + SYSIZE - MINI_TILEX + 2)
283 #define INFOTEXT_XSIZE SXSIZE
284 #define INFOTEXT_YSIZE MINI_TILEX
288 -----------------------------------------------------------------------------
289 editor gadget definitions
290 -----------------------------------------------------------------------------
293 /* drawing toolbox buttons */
294 #define GADGET_ID_NONE -1
295 #define GADGET_ID_TOOLBOX_FIRST 0
297 #define GADGET_ID_SINGLE_ITEMS (GADGET_ID_TOOLBOX_FIRST + 0)
298 #define GADGET_ID_CONNECTED_ITEMS (GADGET_ID_TOOLBOX_FIRST + 1)
299 #define GADGET_ID_LINE (GADGET_ID_TOOLBOX_FIRST + 2)
300 #define GADGET_ID_ARC (GADGET_ID_TOOLBOX_FIRST + 3)
301 #define GADGET_ID_RECTANGLE (GADGET_ID_TOOLBOX_FIRST + 4)
302 #define GADGET_ID_FILLED_BOX (GADGET_ID_TOOLBOX_FIRST + 5)
303 #define GADGET_ID_WRAP_UP (GADGET_ID_TOOLBOX_FIRST + 6)
304 #define GADGET_ID_TEXT (GADGET_ID_TOOLBOX_FIRST + 7)
305 #define GADGET_ID_FLOOD_FILL (GADGET_ID_TOOLBOX_FIRST + 8)
306 #define GADGET_ID_WRAP_LEFT (GADGET_ID_TOOLBOX_FIRST + 9)
307 #define GADGET_ID_PROPERTIES (GADGET_ID_TOOLBOX_FIRST + 10)
308 #define GADGET_ID_WRAP_RIGHT (GADGET_ID_TOOLBOX_FIRST + 11)
309 #define GADGET_ID_RANDOM_PLACEMENT (GADGET_ID_TOOLBOX_FIRST + 12)
310 #define GADGET_ID_GRAB_BRUSH (GADGET_ID_TOOLBOX_FIRST + 13)
311 #define GADGET_ID_WRAP_DOWN (GADGET_ID_TOOLBOX_FIRST + 14)
312 #define GADGET_ID_PICK_ELEMENT (GADGET_ID_TOOLBOX_FIRST + 15)
314 #define GADGET_ID_UNDO (GADGET_ID_TOOLBOX_FIRST + 16)
315 #define GADGET_ID_INFO (GADGET_ID_TOOLBOX_FIRST + 17)
316 #define GADGET_ID_SAVE (GADGET_ID_TOOLBOX_FIRST + 18)
317 #define GADGET_ID_CLEAR (GADGET_ID_TOOLBOX_FIRST + 19)
318 #define GADGET_ID_TEST (GADGET_ID_TOOLBOX_FIRST + 20)
319 #define GADGET_ID_EXIT (GADGET_ID_TOOLBOX_FIRST + 21)
321 #define GADGET_ID_CUSTOM_COPY_FROM (GADGET_ID_TOOLBOX_FIRST + 22)
322 #define GADGET_ID_CUSTOM_COPY_TO (GADGET_ID_TOOLBOX_FIRST + 23)
323 #define GADGET_ID_CUSTOM_EXCHANGE (GADGET_ID_TOOLBOX_FIRST + 24)
324 #define GADGET_ID_CUSTOM_COPY (GADGET_ID_TOOLBOX_FIRST + 25)
325 #define GADGET_ID_CUSTOM_PASTE (GADGET_ID_TOOLBOX_FIRST + 26)
327 /* counter gadget identifiers */
328 #define GADGET_ID_COUNTER_FIRST (GADGET_ID_TOOLBOX_FIRST + 27)
330 #define GADGET_ID_SELECT_LEVEL_DOWN (GADGET_ID_COUNTER_FIRST + 0)
331 #define GADGET_ID_SELECT_LEVEL_TEXT (GADGET_ID_COUNTER_FIRST + 1)
332 #define GADGET_ID_SELECT_LEVEL_UP (GADGET_ID_COUNTER_FIRST + 2)
333 #define GADGET_ID_LEVEL_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 3)
334 #define GADGET_ID_LEVEL_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 4)
335 #define GADGET_ID_LEVEL_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 5)
336 #define GADGET_ID_LEVEL_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 6)
337 #define GADGET_ID_LEVEL_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 7)
338 #define GADGET_ID_LEVEL_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 8)
339 #define GADGET_ID_LEVEL_RANDOM_DOWN (GADGET_ID_COUNTER_FIRST + 9)
340 #define GADGET_ID_LEVEL_RANDOM_TEXT (GADGET_ID_COUNTER_FIRST + 10)
341 #define GADGET_ID_LEVEL_RANDOM_UP (GADGET_ID_COUNTER_FIRST + 11)
342 #define GADGET_ID_LEVEL_GEMSLIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 12)
343 #define GADGET_ID_LEVEL_GEMSLIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 13)
344 #define GADGET_ID_LEVEL_GEMSLIMIT_UP (GADGET_ID_COUNTER_FIRST + 14)
345 #define GADGET_ID_LEVEL_TIMELIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 15)
346 #define GADGET_ID_LEVEL_TIMELIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 16)
347 #define GADGET_ID_LEVEL_TIMELIMIT_UP (GADGET_ID_COUNTER_FIRST + 17)
348 #define GADGET_ID_LEVEL_TIMESCORE_DOWN (GADGET_ID_COUNTER_FIRST + 18)
349 #define GADGET_ID_LEVEL_TIMESCORE_TEXT (GADGET_ID_COUNTER_FIRST + 19)
350 #define GADGET_ID_LEVEL_TIMESCORE_UP (GADGET_ID_COUNTER_FIRST + 20)
351 #define GADGET_ID_ELEMENT_VALUE1_DOWN (GADGET_ID_COUNTER_FIRST + 21)
352 #define GADGET_ID_ELEMENT_VALUE1_TEXT (GADGET_ID_COUNTER_FIRST + 22)
353 #define GADGET_ID_ELEMENT_VALUE1_UP (GADGET_ID_COUNTER_FIRST + 23)
354 #define GADGET_ID_ELEMENT_VALUE2_DOWN (GADGET_ID_COUNTER_FIRST + 24)
355 #define GADGET_ID_ELEMENT_VALUE2_TEXT (GADGET_ID_COUNTER_FIRST + 25)
356 #define GADGET_ID_ELEMENT_VALUE2_UP (GADGET_ID_COUNTER_FIRST + 26)
357 #define GADGET_ID_ELEMENT_VALUE3_DOWN (GADGET_ID_COUNTER_FIRST + 27)
358 #define GADGET_ID_ELEMENT_VALUE3_TEXT (GADGET_ID_COUNTER_FIRST + 28)
359 #define GADGET_ID_ELEMENT_VALUE3_UP (GADGET_ID_COUNTER_FIRST + 29)
360 #define GADGET_ID_ELEMENT_VALUE4_DOWN (GADGET_ID_COUNTER_FIRST + 30)
361 #define GADGET_ID_ELEMENT_VALUE4_TEXT (GADGET_ID_COUNTER_FIRST + 31)
362 #define GADGET_ID_ELEMENT_VALUE4_UP (GADGET_ID_COUNTER_FIRST + 32)
363 #define GADGET_ID_YAMYAM_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 33)
364 #define GADGET_ID_YAMYAM_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 34)
365 #define GADGET_ID_YAMYAM_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 35)
366 #define GADGET_ID_BALL_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 36)
367 #define GADGET_ID_BALL_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 37)
368 #define GADGET_ID_BALL_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 38)
369 #define GADGET_ID_ANDROID_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 39)
370 #define GADGET_ID_ANDROID_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 40)
371 #define GADGET_ID_ANDROID_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 41)
372 #define GADGET_ID_ENVELOPE_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 42)
373 #define GADGET_ID_ENVELOPE_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 43)
374 #define GADGET_ID_ENVELOPE_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 44)
375 #define GADGET_ID_ENVELOPE_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 45)
376 #define GADGET_ID_ENVELOPE_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 46)
377 #define GADGET_ID_ENVELOPE_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 47)
378 #define GADGET_ID_INVENTORY_SIZE_DOWN (GADGET_ID_COUNTER_FIRST + 48)
379 #define GADGET_ID_INVENTORY_SIZE_TEXT (GADGET_ID_COUNTER_FIRST + 49)
380 #define GADGET_ID_INVENTORY_SIZE_UP (GADGET_ID_COUNTER_FIRST + 50)
381 #define GADGET_ID_CUSTOM_SCORE_DOWN (GADGET_ID_COUNTER_FIRST + 51)
382 #define GADGET_ID_CUSTOM_SCORE_TEXT (GADGET_ID_COUNTER_FIRST + 52)
383 #define GADGET_ID_CUSTOM_SCORE_UP (GADGET_ID_COUNTER_FIRST + 53)
384 #define GADGET_ID_CUSTOM_GEMCOUNT_DOWN (GADGET_ID_COUNTER_FIRST + 54)
385 #define GADGET_ID_CUSTOM_GEMCOUNT_TEXT (GADGET_ID_COUNTER_FIRST + 55)
386 #define GADGET_ID_CUSTOM_GEMCOUNT_UP (GADGET_ID_COUNTER_FIRST + 56)
387 #define GADGET_ID_CUSTOM_VALUE_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 57)
388 #define GADGET_ID_CUSTOM_VALUE_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 58)
389 #define GADGET_ID_CUSTOM_VALUE_FIX_UP (GADGET_ID_COUNTER_FIRST + 59)
390 #define GADGET_ID_CUSTOM_VALUE_RND_DOWN (GADGET_ID_COUNTER_FIRST + 60)
391 #define GADGET_ID_CUSTOM_VALUE_RND_TEXT (GADGET_ID_COUNTER_FIRST + 61)
392 #define GADGET_ID_CUSTOM_VALUE_RND_UP (GADGET_ID_COUNTER_FIRST + 62)
393 #define GADGET_ID_PUSH_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 63)
394 #define GADGET_ID_PUSH_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 64)
395 #define GADGET_ID_PUSH_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 65)
396 #define GADGET_ID_PUSH_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 66)
397 #define GADGET_ID_PUSH_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 67)
398 #define GADGET_ID_PUSH_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 68)
399 #define GADGET_ID_DROP_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 69)
400 #define GADGET_ID_DROP_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 70)
401 #define GADGET_ID_DROP_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 71)
402 #define GADGET_ID_DROP_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 72)
403 #define GADGET_ID_DROP_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 73)
404 #define GADGET_ID_DROP_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 74)
405 #define GADGET_ID_MOVE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 75)
406 #define GADGET_ID_MOVE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 76)
407 #define GADGET_ID_MOVE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 77)
408 #define GADGET_ID_MOVE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 78)
409 #define GADGET_ID_MOVE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 79)
410 #define GADGET_ID_MOVE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 80)
411 #define GADGET_ID_EXPLOSION_DELAY_DOWN (GADGET_ID_COUNTER_FIRST + 81)
412 #define GADGET_ID_EXPLOSION_DELAY_TEXT (GADGET_ID_COUNTER_FIRST + 82)
413 #define GADGET_ID_EXPLOSION_DELAY_UP (GADGET_ID_COUNTER_FIRST + 83)
414 #define GADGET_ID_IGNITION_DELAY_DOWN (GADGET_ID_COUNTER_FIRST + 84)
415 #define GADGET_ID_IGNITION_DELAY_TEXT (GADGET_ID_COUNTER_FIRST + 85)
416 #define GADGET_ID_IGNITION_DELAY_UP (GADGET_ID_COUNTER_FIRST + 86)
417 #define GADGET_ID_CHANGE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 87)
418 #define GADGET_ID_CHANGE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 88)
419 #define GADGET_ID_CHANGE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 89)
420 #define GADGET_ID_CHANGE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 90)
421 #define GADGET_ID_CHANGE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 91)
422 #define GADGET_ID_CHANGE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 92)
423 #define GADGET_ID_CHANGE_CONT_RND_DOWN (GADGET_ID_COUNTER_FIRST + 93)
424 #define GADGET_ID_CHANGE_CONT_RND_TEXT (GADGET_ID_COUNTER_FIRST + 94)
425 #define GADGET_ID_CHANGE_CONT_RND_UP (GADGET_ID_COUNTER_FIRST + 95)
426 #define GADGET_ID_GROUP_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 96)
427 #define GADGET_ID_GROUP_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 97)
428 #define GADGET_ID_GROUP_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 98)
430 /* drawing area identifiers */
431 #define GADGET_ID_DRAWING_AREA_FIRST (GADGET_ID_COUNTER_FIRST + 99)
433 #define GADGET_ID_DRAWING_LEVEL (GADGET_ID_DRAWING_AREA_FIRST + 0)
434 #define GADGET_ID_YAMYAM_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 1)
435 #define GADGET_ID_YAMYAM_CONTENT_1 (GADGET_ID_DRAWING_AREA_FIRST + 2)
436 #define GADGET_ID_YAMYAM_CONTENT_2 (GADGET_ID_DRAWING_AREA_FIRST + 3)
437 #define GADGET_ID_YAMYAM_CONTENT_3 (GADGET_ID_DRAWING_AREA_FIRST + 4)
438 #define GADGET_ID_YAMYAM_CONTENT_4 (GADGET_ID_DRAWING_AREA_FIRST + 5)
439 #define GADGET_ID_YAMYAM_CONTENT_5 (GADGET_ID_DRAWING_AREA_FIRST + 6)
440 #define GADGET_ID_YAMYAM_CONTENT_6 (GADGET_ID_DRAWING_AREA_FIRST + 7)
441 #define GADGET_ID_YAMYAM_CONTENT_7 (GADGET_ID_DRAWING_AREA_FIRST + 8)
442 #define GADGET_ID_MAGIC_BALL_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 9)
443 #define GADGET_ID_MAGIC_BALL_CONTENT_1 (GADGET_ID_DRAWING_AREA_FIRST + 10)
444 #define GADGET_ID_MAGIC_BALL_CONTENT_2 (GADGET_ID_DRAWING_AREA_FIRST + 11)
445 #define GADGET_ID_MAGIC_BALL_CONTENT_3 (GADGET_ID_DRAWING_AREA_FIRST + 12)
446 #define GADGET_ID_MAGIC_BALL_CONTENT_4 (GADGET_ID_DRAWING_AREA_FIRST + 13)
447 #define GADGET_ID_MAGIC_BALL_CONTENT_5 (GADGET_ID_DRAWING_AREA_FIRST + 14)
448 #define GADGET_ID_MAGIC_BALL_CONTENT_6 (GADGET_ID_DRAWING_AREA_FIRST + 15)
449 #define GADGET_ID_MAGIC_BALL_CONTENT_7 (GADGET_ID_DRAWING_AREA_FIRST + 16)
450 #define GADGET_ID_ANDROID_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 17)
451 #define GADGET_ID_AMOEBA_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 18)
452 #define GADGET_ID_START_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 19)
453 #define GADGET_ID_ARTWORK_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 20)
454 #define GADGET_ID_EXPLOSION_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 21)
455 #define GADGET_ID_INVENTORY_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 22)
456 #define GADGET_ID_CUSTOM_GRAPHIC (GADGET_ID_DRAWING_AREA_FIRST + 23)
457 #define GADGET_ID_CUSTOM_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 24)
458 #define GADGET_ID_CUSTOM_MOVE_ENTER (GADGET_ID_DRAWING_AREA_FIRST + 25)
459 #define GADGET_ID_CUSTOM_MOVE_LEAVE (GADGET_ID_DRAWING_AREA_FIRST + 26)
460 #define GADGET_ID_CUSTOM_CHANGE_TARGET (GADGET_ID_DRAWING_AREA_FIRST + 27)
461 #define GADGET_ID_CUSTOM_CHANGE_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 28)
462 #define GADGET_ID_CUSTOM_CHANGE_TRIGGER (GADGET_ID_DRAWING_AREA_FIRST + 29)
463 #define GADGET_ID_CUSTOM_CHANGE_ACTION (GADGET_ID_DRAWING_AREA_FIRST + 30)
464 #define GADGET_ID_GROUP_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 31)
465 #define GADGET_ID_RANDOM_BACKGROUND (GADGET_ID_DRAWING_AREA_FIRST + 32)
467 /* text input identifiers */
468 #define GADGET_ID_TEXT_INPUT_FIRST (GADGET_ID_DRAWING_AREA_FIRST + 33)
470 #define GADGET_ID_LEVEL_NAME (GADGET_ID_TEXT_INPUT_FIRST + 0)
471 #define GADGET_ID_LEVEL_AUTHOR (GADGET_ID_TEXT_INPUT_FIRST + 1)
472 #define GADGET_ID_ELEMENT_NAME (GADGET_ID_TEXT_INPUT_FIRST + 2)
474 /* text area identifiers */
475 #define GADGET_ID_TEXT_AREA_FIRST (GADGET_ID_TEXT_INPUT_FIRST + 3)
477 #define GADGET_ID_ENVELOPE_INFO (GADGET_ID_TEXT_AREA_FIRST + 0)
479 /* selectbox identifiers */
480 #define GADGET_ID_SELECTBOX_FIRST (GADGET_ID_TEXT_AREA_FIRST + 1)
482 #define GADGET_ID_TIME_OR_STEPS (GADGET_ID_SELECTBOX_FIRST + 0)
483 #define GADGET_ID_GAME_ENGINE_TYPE (GADGET_ID_SELECTBOX_FIRST + 1)
484 #define GADGET_ID_WIND_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 2)
485 #define GADGET_ID_PLAYER_SPEED (GADGET_ID_SELECTBOX_FIRST + 3)
486 #define GADGET_ID_CUSTOM_WALK_TO_ACTION (GADGET_ID_SELECTBOX_FIRST + 4)
487 #define GADGET_ID_CUSTOM_EXPLOSION_TYPE (GADGET_ID_SELECTBOX_FIRST + 5)
488 #define GADGET_ID_CUSTOM_DEADLINESS (GADGET_ID_SELECTBOX_FIRST + 6)
489 #define GADGET_ID_CUSTOM_MOVE_PATTERN (GADGET_ID_SELECTBOX_FIRST + 7)
490 #define GADGET_ID_CUSTOM_MOVE_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 8)
491 #define GADGET_ID_CUSTOM_MOVE_STEPSIZE (GADGET_ID_SELECTBOX_FIRST + 9)
492 #define GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE (GADGET_ID_SELECTBOX_FIRST + 10)
493 #define GADGET_ID_CUSTOM_SMASH_TARGETS (GADGET_ID_SELECTBOX_FIRST + 11)
494 #define GADGET_ID_CUSTOM_SLIPPERY_TYPE (GADGET_ID_SELECTBOX_FIRST + 12)
495 #define GADGET_ID_CUSTOM_ACCESS_TYPE (GADGET_ID_SELECTBOX_FIRST + 13)
496 #define GADGET_ID_CUSTOM_ACCESS_LAYER (GADGET_ID_SELECTBOX_FIRST + 14)
497 #define GADGET_ID_CUSTOM_ACCESS_PROTECTED (GADGET_ID_SELECTBOX_FIRST + 15)
498 #define GADGET_ID_CUSTOM_ACCESS_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 16)
499 #define GADGET_ID_CHANGE_TIME_UNITS (GADGET_ID_SELECTBOX_FIRST + 17)
500 #define GADGET_ID_CHANGE_DIRECT_ACTION (GADGET_ID_SELECTBOX_FIRST + 18)
501 #define GADGET_ID_CHANGE_OTHER_ACTION (GADGET_ID_SELECTBOX_FIRST + 19)
502 #define GADGET_ID_CHANGE_SIDE (GADGET_ID_SELECTBOX_FIRST + 20)
503 #define GADGET_ID_CHANGE_PLAYER (GADGET_ID_SELECTBOX_FIRST + 21)
504 #define GADGET_ID_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 22)
505 #define GADGET_ID_CHANGE_REPLACE_WHEN (GADGET_ID_SELECTBOX_FIRST + 23)
506 #define GADGET_ID_ACTION_TYPE (GADGET_ID_SELECTBOX_FIRST + 24)
507 #define GADGET_ID_ACTION_MODE (GADGET_ID_SELECTBOX_FIRST + 25)
508 #define GADGET_ID_ACTION_ARG (GADGET_ID_SELECTBOX_FIRST + 26)
509 #define GADGET_ID_SELECT_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 27)
510 #define GADGET_ID_GROUP_CHOICE_MODE (GADGET_ID_SELECTBOX_FIRST + 28)
512 /* textbutton identifiers */
513 #define GADGET_ID_TEXTBUTTON_FIRST (GADGET_ID_SELECTBOX_FIRST + 29)
515 #define GADGET_ID_PROPERTIES_INFO (GADGET_ID_TEXTBUTTON_FIRST + 0)
516 #define GADGET_ID_PROPERTIES_CONFIG (GADGET_ID_TEXTBUTTON_FIRST + 1)
517 #define GADGET_ID_PROPERTIES_CONFIG_1 (GADGET_ID_TEXTBUTTON_FIRST + 2)
518 #define GADGET_ID_PROPERTIES_CONFIG_2 (GADGET_ID_TEXTBUTTON_FIRST + 3)
519 #define GADGET_ID_PROPERTIES_CHANGE (GADGET_ID_TEXTBUTTON_FIRST + 4)
520 #define GADGET_ID_SAVE_AS_TEMPLATE (GADGET_ID_TEXTBUTTON_FIRST + 5)
521 #define GADGET_ID_ADD_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 6)
522 #define GADGET_ID_DEL_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 7)
524 /* graphicbutton identifiers */
525 #define GADGET_ID_GRAPHICBUTTON_FIRST (GADGET_ID_TEXTBUTTON_FIRST + 8)
527 #define GADGET_ID_PREV_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 0)
528 #define GADGET_ID_NEXT_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 1)
529 #define GADGET_ID_COPY_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 2)
530 #define GADGET_ID_PASTE_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 3)
532 /* gadgets for scrolling of drawing area */
533 #define GADGET_ID_SCROLLING_FIRST (GADGET_ID_GRAPHICBUTTON_FIRST + 4)
535 #define GADGET_ID_SCROLL_UP (GADGET_ID_SCROLLING_FIRST + 0)
536 #define GADGET_ID_SCROLL_DOWN (GADGET_ID_SCROLLING_FIRST + 1)
537 #define GADGET_ID_SCROLL_LEFT (GADGET_ID_SCROLLING_FIRST + 2)
538 #define GADGET_ID_SCROLL_RIGHT (GADGET_ID_SCROLLING_FIRST + 3)
539 #define GADGET_ID_SCROLL_HORIZONTAL (GADGET_ID_SCROLLING_FIRST + 4)
540 #define GADGET_ID_SCROLL_VERTICAL (GADGET_ID_SCROLLING_FIRST + 5)
542 /* gadgets for scrolling element list */
543 #define GADGET_ID_SCROLLING_LIST_FIRST (GADGET_ID_SCROLLING_FIRST + 6)
545 #define GADGET_ID_SCROLL_LIST_UP (GADGET_ID_SCROLLING_LIST_FIRST + 0)
546 #define GADGET_ID_SCROLL_LIST_DOWN (GADGET_ID_SCROLLING_LIST_FIRST + 1)
547 #define GADGET_ID_SCROLL_LIST_VERTICAL (GADGET_ID_SCROLLING_LIST_FIRST + 2)
549 /* checkbuttons/radiobuttons for level/element properties */
550 #define GADGET_ID_CHECKBUTTON_FIRST (GADGET_ID_SCROLLING_LIST_FIRST + 3)
552 #define GADGET_ID_RANDOM_PERCENTAGE (GADGET_ID_CHECKBUTTON_FIRST + 0)
553 #define GADGET_ID_RANDOM_QUANTITY (GADGET_ID_CHECKBUTTON_FIRST + 1)
554 #define GADGET_ID_RANDOM_RESTRICTED (GADGET_ID_CHECKBUTTON_FIRST + 2)
555 #define GADGET_ID_STICK_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 3)
556 #define GADGET_ID_EM_SLIPPERY_GEMS (GADGET_ID_CHECKBUTTON_FIRST + 4)
557 #define GADGET_ID_USE_SPRING_BUG (GADGET_ID_CHECKBUTTON_FIRST + 5)
558 #define GADGET_ID_USE_TIME_ORB_BUG (GADGET_ID_CHECKBUTTON_FIRST + 6)
559 #define GADGET_ID_RANDOM_BALL_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 7)
560 #define GADGET_ID_INITIAL_BALL_STATE (GADGET_ID_CHECKBUTTON_FIRST + 8)
561 #define GADGET_ID_GROW_INTO_DIGGABLE (GADGET_ID_CHECKBUTTON_FIRST + 9)
562 #define GADGET_ID_CONTINUOUS_SNAPPING (GADGET_ID_CHECKBUTTON_FIRST + 10)
563 #define GADGET_ID_BLOCK_SNAP_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 11)
564 #define GADGET_ID_BLOCK_LAST_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 12)
565 #define GADGET_ID_SP_BLOCK_LAST_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 13)
566 #define GADGET_ID_INSTANT_RELOCATION (GADGET_ID_CHECKBUTTON_FIRST + 14)
567 #define GADGET_ID_SHIFTED_RELOCATION (GADGET_ID_CHECKBUTTON_FIRST + 15)
568 #define GADGET_ID_USE_START_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 16)
569 #define GADGET_ID_USE_ARTWORK_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 17)
570 #define GADGET_ID_USE_EXPLOSION_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 18)
571 #define GADGET_ID_INITIAL_GRAVITY (GADGET_ID_CHECKBUTTON_FIRST + 19)
572 #define GADGET_ID_USE_INITIAL_INVENTORY (GADGET_ID_CHECKBUTTON_FIRST + 20)
573 #define GADGET_ID_CAN_PASS_TO_WALKABLE (GADGET_ID_CHECKBUTTON_FIRST + 21)
574 #define GADGET_ID_CAN_FALL_INTO_ACID (GADGET_ID_CHECKBUTTON_FIRST + 22)
575 #define GADGET_ID_CAN_MOVE_INTO_ACID (GADGET_ID_CHECKBUTTON_FIRST + 23)
576 #define GADGET_ID_DONT_COLLIDE_WITH (GADGET_ID_CHECKBUTTON_FIRST + 24)
577 #define GADGET_ID_ENVELOPE_AUTOWRAP (GADGET_ID_CHECKBUTTON_FIRST + 25)
578 #define GADGET_ID_ENVELOPE_CENTERED (GADGET_ID_CHECKBUTTON_FIRST + 26)
579 #define GADGET_ID_CUSTOM_INDESTRUCTIBLE (GADGET_ID_CHECKBUTTON_FIRST + 27)
580 #define GADGET_ID_CUSTOM_CAN_EXPLODE (GADGET_ID_CHECKBUTTON_FIRST + 28)
581 #define GADGET_ID_CUSTOM_EXPLODE_FIRE (GADGET_ID_CHECKBUTTON_FIRST + 29)
582 #define GADGET_ID_CUSTOM_EXPLODE_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 30)
583 #define GADGET_ID_CUSTOM_EXPLODE_IMPACT (GADGET_ID_CHECKBUTTON_FIRST + 31)
584 #define GADGET_ID_CUSTOM_WALK_TO_OBJECT (GADGET_ID_CHECKBUTTON_FIRST + 32)
585 #define GADGET_ID_CUSTOM_DEADLY (GADGET_ID_CHECKBUTTON_FIRST + 33)
586 #define GADGET_ID_CUSTOM_CAN_MOVE (GADGET_ID_CHECKBUTTON_FIRST + 34)
587 #define GADGET_ID_CUSTOM_CAN_FALL (GADGET_ID_CHECKBUTTON_FIRST + 35)
588 #define GADGET_ID_CUSTOM_CAN_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 36)
589 #define GADGET_ID_CUSTOM_SLIPPERY (GADGET_ID_CHECKBUTTON_FIRST + 37)
590 #define GADGET_ID_CUSTOM_ACCESSIBLE (GADGET_ID_CHECKBUTTON_FIRST + 38)
591 #define GADGET_ID_CUSTOM_GRAV_REACHABLE (GADGET_ID_CHECKBUTTON_FIRST + 39)
592 #define GADGET_ID_CUSTOM_USE_LAST_VALUE (GADGET_ID_CHECKBUTTON_FIRST + 40)
593 #define GADGET_ID_CUSTOM_USE_GRAPHIC (GADGET_ID_CHECKBUTTON_FIRST + 41)
594 #define GADGET_ID_CUSTOM_USE_TEMPLATE (GADGET_ID_CHECKBUTTON_FIRST + 42)
595 #define GADGET_ID_CUSTOM_CAN_CHANGE (GADGET_ID_CHECKBUTTON_FIRST + 43)
596 #define GADGET_ID_CHANGE_USE_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 44)
597 #define GADGET_ID_CHANGE_USE_EXPLOSION (GADGET_ID_CHECKBUTTON_FIRST + 45)
598 #define GADGET_ID_CHANGE_ONLY_COMPLETE (GADGET_ID_CHECKBUTTON_FIRST + 46)
599 #define GADGET_ID_CHANGE_USE_RANDOM (GADGET_ID_CHECKBUTTON_FIRST + 47)
600 #define GADGET_ID_CHANGE_HAS_ACTION (GADGET_ID_CHECKBUTTON_FIRST + 48)
601 #define GADGET_ID_CHANGE_DELAY (GADGET_ID_CHECKBUTTON_FIRST + 49)
602 #define GADGET_ID_CHANGE_BY_DIRECT_ACT (GADGET_ID_CHECKBUTTON_FIRST + 50)
603 #define GADGET_ID_CHANGE_BY_OTHER_ACT (GADGET_ID_CHECKBUTTON_FIRST + 51)
605 /* gadgets for buttons in element list */
606 #define GADGET_ID_ELEMENTLIST_FIRST (GADGET_ID_CHECKBUTTON_FIRST + 52)
607 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
608 ED_NUM_ELEMENTLIST_BUTTONS - 1)
610 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
612 /* radio button numbers */
613 #define RADIO_NR_NONE 0
614 #define RADIO_NR_DRAWING_TOOLBOX 1
615 #define RADIO_NR_RANDOM_ELEMENTS 2
617 /* values for counter gadgets */
618 #define ED_COUNTER_ID_SELECT_LEVEL 0
619 #define ED_COUNTER_ID_LEVEL_XSIZE 1
620 #define ED_COUNTER_ID_LEVEL_YSIZE 2
621 #define ED_COUNTER_ID_LEVEL_GEMSLIMIT 3
622 #define ED_COUNTER_ID_LEVEL_TIMELIMIT 4
623 #define ED_COUNTER_ID_LEVEL_TIMESCORE 5
624 #define ED_COUNTER_ID_LEVEL_RANDOM 6
625 #define ED_COUNTER_ID_ELEMENT_VALUE1 7
626 #define ED_COUNTER_ID_ELEMENT_VALUE2 8
627 #define ED_COUNTER_ID_ELEMENT_VALUE3 9
628 #define ED_COUNTER_ID_ELEMENT_VALUE4 10
629 #define ED_COUNTER_ID_YAMYAM_CONTENT 11
630 #define ED_COUNTER_ID_BALL_CONTENT 12
631 #define ED_COUNTER_ID_ANDROID_CONTENT 13
632 #define ED_COUNTER_ID_ENVELOPE_XSIZE 14
633 #define ED_COUNTER_ID_ENVELOPE_YSIZE 15
634 #define ED_COUNTER_ID_INVENTORY_SIZE 16
635 #define ED_COUNTER_ID_CUSTOM_SCORE 17
636 #define ED_COUNTER_ID_CUSTOM_GEMCOUNT 18
637 #define ED_COUNTER_ID_CUSTOM_VALUE_FIX 19
638 #define ED_COUNTER_ID_CUSTOM_VALUE_RND 20
639 #define ED_COUNTER_ID_PUSH_DELAY_FIX 21
640 #define ED_COUNTER_ID_PUSH_DELAY_RND 22
641 #define ED_COUNTER_ID_DROP_DELAY_FIX 23
642 #define ED_COUNTER_ID_DROP_DELAY_RND 24
643 #define ED_COUNTER_ID_MOVE_DELAY_FIX 25
644 #define ED_COUNTER_ID_MOVE_DELAY_RND 26
645 #define ED_COUNTER_ID_EXPLOSION_DELAY 27
646 #define ED_COUNTER_ID_IGNITION_DELAY 28
647 #define ED_COUNTER_ID_GROUP_CONTENT 29
648 #define ED_COUNTER_ID_CHANGE_DELAY_FIX 30
649 #define ED_COUNTER_ID_CHANGE_DELAY_RND 31
650 #define ED_COUNTER_ID_CHANGE_CONT_RND 32
652 #define ED_NUM_COUNTERBUTTONS 33
654 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
655 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM
657 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
658 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
659 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
660 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
661 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
662 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
664 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
665 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
667 /* values for scrollbutton gadgets */
668 #define ED_SCROLLBUTTON_ID_AREA_UP 0
669 #define ED_SCROLLBUTTON_ID_AREA_DOWN 1
670 #define ED_SCROLLBUTTON_ID_AREA_LEFT 2
671 #define ED_SCROLLBUTTON_ID_AREA_RIGHT 3
672 #define ED_SCROLLBUTTON_ID_LIST_UP 4
673 #define ED_SCROLLBUTTON_ID_LIST_DOWN 5
675 #define ED_NUM_SCROLLBUTTONS 6
677 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
678 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
680 /* values for scrollbar gadgets */
681 #define ED_SCROLLBAR_ID_AREA_HORIZONTAL 0
682 #define ED_SCROLLBAR_ID_AREA_VERTICAL 1
683 #define ED_SCROLLBAR_ID_LIST_VERTICAL 2
685 #define ED_NUM_SCROLLBARS 3
687 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
688 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
690 /* values for text input gadgets */
691 #define ED_TEXTINPUT_ID_LEVEL_NAME 0
692 #define ED_TEXTINPUT_ID_LEVEL_AUTHOR 1
693 #define ED_TEXTINPUT_ID_ELEMENT_NAME 2
695 #define ED_NUM_TEXTINPUT 3
697 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
698 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
700 /* values for text area gadgets */
701 #define ED_TEXTAREA_ID_ENVELOPE_INFO 0
703 #define ED_NUM_TEXTAREAS 1
705 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
706 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
708 /* values for selectbox gadgets */
709 #define ED_SELECTBOX_ID_TIME_OR_STEPS 0
710 #define ED_SELECTBOX_ID_GAME_ENGINE_TYPE 1
711 #define ED_SELECTBOX_ID_WIND_DIRECTION 2
712 #define ED_SELECTBOX_ID_PLAYER_SPEED 3
713 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE 4
714 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER 5
715 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED 6
716 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION 7
717 #define ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION 8
718 #define ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN 9
719 #define ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION 10
720 #define ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE 11
721 #define ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE 12
722 #define ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS 13
723 #define ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE 14
724 #define ED_SELECTBOX_ID_CUSTOM_DEADLINESS 15
725 #define ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE 16
726 #define ED_SELECTBOX_ID_CHANGE_TIME_UNITS 17
727 #define ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION 18
728 #define ED_SELECTBOX_ID_CHANGE_OTHER_ACTION 19
729 #define ED_SELECTBOX_ID_CHANGE_SIDE 20
730 #define ED_SELECTBOX_ID_CHANGE_PLAYER 21
731 #define ED_SELECTBOX_ID_CHANGE_PAGE 22
732 #define ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN 23
733 #define ED_SELECTBOX_ID_ACTION_TYPE 24
734 #define ED_SELECTBOX_ID_ACTION_MODE 25
735 #define ED_SELECTBOX_ID_ACTION_ARG 26
736 #define ED_SELECTBOX_ID_SELECT_CHANGE_PAGE 27
737 #define ED_SELECTBOX_ID_GROUP_CHOICE_MODE 28
739 #define ED_NUM_SELECTBOX 29
741 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
742 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_WIND_DIRECTION
744 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
745 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
746 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
747 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
748 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
749 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
751 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
752 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
754 /* values for textbutton gadgets */
755 #define ED_TEXTBUTTON_ID_PROPERTIES_INFO 0
756 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG 1
757 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1 2
758 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2 3
759 #define ED_TEXTBUTTON_ID_PROPERTIES_CHANGE 4
760 #define ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE 5
761 #define ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE 6
762 #define ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE 7
764 #define ED_NUM_TEXTBUTTONS 8
766 #define ED_TEXTBUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
767 #define ED_TEXTBUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
769 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
770 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
772 /* values for graphicbutton gadgets */
773 #define ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE 0
774 #define ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE 1
775 #define ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE 2
776 #define ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE 3
778 #define ED_NUM_GRAPHICBUTTONS 4
780 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
781 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
783 /* values for checkbutton gadgets */
784 #define ED_CHECKBUTTON_ID_RANDOM_RESTRICTED 0
785 #define ED_CHECKBUTTON_ID_STICK_ELEMENT 1
786 #define ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS 2
787 #define ED_CHECKBUTTON_ID_USE_SPRING_BUG 3
788 #define ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG 4
789 #define ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT 5
790 #define ED_CHECKBUTTON_ID_INITIAL_BALL_STATE 6
791 #define ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE 7
792 #define ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING 8
793 #define ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD 9
794 #define ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD 10
795 #define ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD 11
796 #define ED_CHECKBUTTON_ID_INSTANT_RELOCATION 12
797 #define ED_CHECKBUTTON_ID_SHIFTED_RELOCATION 13
798 #define ED_CHECKBUTTON_ID_USE_START_ELEMENT 14
799 #define ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT 15
800 #define ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT 16
801 #define ED_CHECKBUTTON_ID_INITIAL_GRAVITY 17
802 #define ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY 18
803 #define ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE 19
804 #define ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID 20
805 #define ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID 21
806 #define ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH 22
807 #define ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP 23
808 #define ED_CHECKBUTTON_ID_ENVELOPE_CENTERED 24
809 #define ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC 25
810 #define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE 26
811 #define ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE 27
812 #define ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE 28
813 #define ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE 29
814 #define ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT 30
815 #define ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE 31
816 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE 32
817 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL 33
818 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH 34
819 #define ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY 35
820 #define ED_CHECKBUTTON_ID_CUSTOM_DEADLY 36
821 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE 37
822 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE 38
823 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH 39
824 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT 40
825 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE 41
826 #define ED_CHECKBUTTON_ID_CHANGE_DELAY 42
827 #define ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT 43
828 #define ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT 44
829 #define ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION 45
830 #define ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT 46
831 #define ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE 47
832 #define ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM 48
833 #define ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION 49
835 #define ED_NUM_CHECKBUTTONS 50
837 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
838 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
840 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
841 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
842 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
843 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
844 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
845 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
847 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
848 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
850 /* values for radiobutton gadgets */
851 #define ED_RADIOBUTTON_ID_PERCENTAGE 0
852 #define ED_RADIOBUTTON_ID_QUANTITY 1
854 #define ED_NUM_RADIOBUTTONS 2
856 #define ED_RADIOBUTTON_ID_LEVEL_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
857 #define ED_RADIOBUTTON_ID_LEVEL_LAST ED_RADIOBUTTON_ID_QUANTITY
859 /* values for drawing area gadgets */
860 #define ED_DRAWING_ID_DRAWING_LEVEL 0
861 #define ED_DRAWING_ID_YAMYAM_CONTENT_0 1
862 #define ED_DRAWING_ID_YAMYAM_CONTENT_1 2
863 #define ED_DRAWING_ID_YAMYAM_CONTENT_2 3
864 #define ED_DRAWING_ID_YAMYAM_CONTENT_3 4
865 #define ED_DRAWING_ID_YAMYAM_CONTENT_4 5
866 #define ED_DRAWING_ID_YAMYAM_CONTENT_5 6
867 #define ED_DRAWING_ID_YAMYAM_CONTENT_6 7
868 #define ED_DRAWING_ID_YAMYAM_CONTENT_7 8
869 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 9
870 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_1 10
871 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_2 11
872 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_3 12
873 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_4 13
874 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_5 14
875 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_6 15
876 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_7 16
877 #define ED_DRAWING_ID_ANDROID_CONTENT 17
878 #define ED_DRAWING_ID_AMOEBA_CONTENT 18
879 #define ED_DRAWING_ID_START_ELEMENT 19
880 #define ED_DRAWING_ID_ARTWORK_ELEMENT 20
881 #define ED_DRAWING_ID_EXPLOSION_ELEMENT 21
882 #define ED_DRAWING_ID_INVENTORY_CONTENT 22
883 #define ED_DRAWING_ID_CUSTOM_GRAPHIC 23
884 #define ED_DRAWING_ID_CUSTOM_CONTENT 24
885 #define ED_DRAWING_ID_CUSTOM_MOVE_ENTER 25
886 #define ED_DRAWING_ID_CUSTOM_MOVE_LEAVE 26
887 #define ED_DRAWING_ID_CUSTOM_CHANGE_TARGET 27
888 #define ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT 28
889 #define ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER 29
890 #define ED_DRAWING_ID_CUSTOM_CHANGE_ACTION 30
891 #define ED_DRAWING_ID_GROUP_CONTENT 31
892 #define ED_DRAWING_ID_RANDOM_BACKGROUND 32
894 #define ED_NUM_DRAWING_AREAS 33
898 -----------------------------------------------------------------------------
899 some internally used definitions
900 -----------------------------------------------------------------------------
903 /* values for CopyLevelToUndoBuffer() */
904 #define UNDO_IMMEDIATE 0
905 #define UNDO_ACCUMULATE 1
907 /* values for scrollbars */
908 #define ED_SCROLL_NO 0
909 #define ED_SCROLL_LEFT 1
910 #define ED_SCROLL_RIGHT 2
911 #define ED_SCROLL_UP 4
912 #define ED_SCROLL_DOWN 8
914 /* screens in the level editor */
915 #define ED_MODE_DRAWING 0
916 #define ED_MODE_INFO 1
917 #define ED_MODE_PROPERTIES 2
919 /* sub-screens in the element properties section */
920 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
921 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
922 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
923 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
924 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
926 /* how many steps can be cancelled */
927 #define NUM_UNDO_STEPS (10 + 1)
929 /* values for elements with score for certain actions */
931 #define MAX_SCORE 999
933 /* values for elements with count for collecting */
934 #define MIN_COLLECT_COUNT 0
935 #define MAX_COLLECT_COUNT 999
937 /* values for random placement */
938 #define RANDOM_USE_PERCENTAGE 0
939 #define RANDOM_USE_QUANTITY 1
941 /* maximal size of level editor drawing area */
942 #define MAX_ED_FIELDX (2 * SCR_FIELDX)
943 #define MAX_ED_FIELDY (2 * SCR_FIELDY - 1)
947 -----------------------------------------------------------------------------
948 some internally used data structure definitions
949 -----------------------------------------------------------------------------
956 } control_info[ED_NUM_CTRL_BUTTONS] =
958 /* note: some additional characters are already reserved for "cheat mode"
959 shortcuts (":XYZ" style) -- for details, see "events.c" */
961 { 's', "draw single items" },
962 { 'd', "draw connected items" },
963 { 'l', "draw lines" },
964 { 'a', "draw arcs" },
965 { 'r', "draw outline rectangles" },
966 { 'R', "draw filled rectangles" },
967 { '\0', "wrap (rotate) level up" },
968 { 't', "enter text elements" },
969 { 'f', "flood fill" },
970 { '\0', "wrap (rotate) level left" },
971 { '?', "properties of drawing element" },
972 { '\0', "wrap (rotate) level right" },
973 { '\0', "random element placement" },
974 { 'b', "grab brush" },
975 { '\0', "wrap (rotate) level down" },
976 { ',', "pick drawing element" },
978 { 'U', "undo last operation" },
979 { 'I', "level properties" },
980 { 'S', "save level" },
981 { 'C', "clear level" },
982 { 'T', "test level" },
983 { 'E', "exit level editor" },
985 { '\0', "copy settings from other element" },
986 { '\0', "copy settings to other element" },
987 { '\0', "exchange element with other element" },
989 { '\0', "copy settings from this element" },
990 { '\0', "paste settings to this element" },
993 static int random_placement_value = 10;
994 static int random_placement_method = RANDOM_USE_QUANTITY;
995 static int random_placement_background_element = EL_SAND;
996 static boolean random_placement_background_restricted = FALSE;
997 static boolean stick_element_properties_window = FALSE;
998 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
999 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1000 static struct ElementChangeInfo custom_element_change;
1001 static struct ElementGroupInfo group_element_info;
1002 static struct ElementInfo custom_element;
1007 int min_value, max_value;
1008 int gadget_id_down, gadget_id_up;
1010 int gadget_id_align;
1012 char *text_above, *text_left, *text_right;
1013 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1015 /* ---------- current level number --------------------------------------- */
1018 DX + 5 - SX, DY + 3 - SY,
1020 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1021 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1026 /* ---------- level and editor settings ---------------------------------- */
1029 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1030 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1031 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1032 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1034 "playfield size:", NULL, "width",
1037 -1, ED_LEVEL_SETTINGS_YPOS(4),
1038 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1039 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1040 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1042 NULL, " ", "height",
1045 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1047 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1048 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1050 NULL, "number of gems to collect:", NULL
1053 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
1055 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1056 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1058 "time or step limit to solve level:", NULL, NULL
1061 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(9),
1063 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1064 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1065 &level.score[SC_TIME_BONUS],
1066 "score for each second/step left:", NULL, NULL
1069 ED_LEVEL_SETTINGS_XPOS(0), ED_COUNTER2_YPOS(8),
1071 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1072 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1073 &random_placement_value,
1074 "random element placement:", NULL, "in"
1077 /* ---------- element settings: configure (various elements) ------------- */
1080 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1081 MIN_SCORE, MAX_SCORE,
1082 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1083 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1084 NULL, /* will be set when used */
1088 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1089 MIN_SCORE, MAX_SCORE,
1090 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1091 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1092 NULL, /* will be set when used */
1096 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1097 MIN_SCORE, MAX_SCORE,
1098 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1099 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1100 NULL, /* will be set when used */
1104 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1105 MIN_SCORE, MAX_SCORE,
1106 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1107 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1108 NULL, /* will be set when used */
1112 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1113 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1114 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1115 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1116 &level.num_yamyam_contents,
1117 NULL, NULL, "number of content areas"
1120 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1121 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1122 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1123 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1124 &level.num_ball_contents,
1125 NULL, NULL, "number of content areas"
1128 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1129 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1130 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1131 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1132 &level.num_android_clone_elements,
1133 NULL, NULL, "number of clonable elements"
1136 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1137 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1138 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1139 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1140 NULL, /* will be set when used */
1141 NULL, NULL, "width",
1144 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1145 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1146 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1147 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1148 NULL, /* will be set when used */
1149 NULL, " ", "height",
1152 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1153 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1154 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1155 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1156 &level.initial_inventory_size[0],
1157 NULL, NULL, "number of inventory elements"
1160 /* ---------- element settings: configure 1 (custom elements) ------------ */
1163 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1164 MIN_SCORE, MAX_SCORE,
1165 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1166 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1167 &custom_element.collect_score_initial,
1168 NULL, "CE score", " "
1171 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1172 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1173 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1174 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1175 &custom_element.collect_count_initial,
1176 NULL, "CE count", NULL
1179 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
1181 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1182 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1183 &custom_element.ce_value_fixed_initial,
1184 NULL, "CE value", NULL
1187 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
1189 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1190 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1191 &custom_element.ce_value_random_initial,
1192 NULL, "+random", NULL
1195 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1197 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1198 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1199 &custom_element.push_delay_fixed,
1200 NULL, "push delay", NULL
1203 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1205 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1206 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1207 &custom_element.push_delay_random,
1208 NULL, "+random", NULL
1211 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
1213 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1214 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1215 &custom_element.drop_delay_fixed,
1216 NULL, "drop delay", NULL
1219 -1, ED_ELEMENT_SETTINGS_YPOS(8),
1221 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1222 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1223 &custom_element.drop_delay_random,
1224 NULL, "+random", NULL
1227 /* ---------- element settings: configure 2 (custom elements) ------------ */
1230 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1232 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1233 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1234 &custom_element.move_delay_fixed,
1235 NULL, "move delay", NULL
1238 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1240 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1241 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1242 &custom_element.move_delay_random,
1243 NULL, "+random", NULL
1246 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
1248 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1249 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1250 &custom_element.explosion_delay,
1251 NULL, "explosion delay", NULL
1254 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1256 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1257 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1258 &custom_element.ignition_delay,
1259 NULL, "ignition delay", "(by fire)"
1262 /* ---------- element settings: configure (group elements) --------------- */
1265 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
1266 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1267 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1268 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1269 &group_element_info.num_elements,
1270 NULL, NULL, "number of elements in group"
1273 /* ---------- element settings: advanced (custom elements) --------------- */
1276 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1278 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1279 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1280 &custom_element_change.delay_fixed,
1281 NULL, "CE delay", NULL,
1284 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1286 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1287 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1288 &custom_element_change.delay_random,
1289 NULL, "+random", NULL
1292 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1294 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1295 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1296 &custom_element_change.random_percentage,
1297 NULL, "use random replace:", "%"
1307 char *text_above, *infotext;
1308 } textinput_info[ED_NUM_TEXTINPUT] =
1311 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1312 GADGET_ID_LEVEL_NAME,
1318 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1319 GADGET_ID_LEVEL_AUTHOR,
1320 MAX_LEVEL_AUTHOR_LEN,
1325 5 * MINI_TILEX - 2, 5 * MINI_TILEY - ED_BORDER_SIZE + 1,
1326 GADGET_ID_ELEMENT_NAME,
1327 MAX_ELEMENT_NAME_LEN - 2, /* currently 2 chars less editable */
1328 custom_element.description,
1329 NULL, "Element name"
1339 char *text_above, *infotext;
1340 } textarea_info[ED_NUM_TEXTAREAS] =
1343 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1344 GADGET_ID_ENVELOPE_INFO,
1345 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1347 "Envelope Content:", "Envelope Content"
1351 static struct ValueTextInfo options_time_or_steps[] =
1359 static struct ValueTextInfo options_game_engine_type[] =
1361 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1362 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1367 static struct ValueTextInfo options_wind_direction[] =
1369 { MV_START_NONE, "none" },
1370 { MV_START_LEFT, "left" },
1371 { MV_START_RIGHT, "right" },
1372 { MV_START_UP, "up" },
1373 { MV_START_DOWN, "down" },
1378 static struct ValueTextInfo options_player_speed[] =
1385 { 16, "very fast" },
1386 { 32, "ultrafast" },
1391 static struct ValueTextInfo options_access_type[] =
1393 { EP_WALKABLE, "walkable" },
1394 { EP_PASSABLE, "passable" },
1399 static struct ValueTextInfo options_access_layer[] =
1401 { EP_ACCESSIBLE_OVER, "over" },
1402 { EP_ACCESSIBLE_INSIDE, "inside" },
1403 { EP_ACCESSIBLE_UNDER, "under" },
1408 static struct ValueTextInfo options_access_protected[] =
1410 { 0, "unprotected" },
1416 static struct ValueTextInfo options_access_direction[] =
1418 { MV_NO_DIRECTION, "no direction" },
1419 { MV_LEFT, "left" },
1420 { MV_RIGHT, "right" },
1422 { MV_DOWN, "down" },
1423 { MV_LEFT | MV_UP, "left + up" },
1424 { MV_LEFT | MV_DOWN, "left + down" },
1425 { MV_RIGHT | MV_UP, "right + up" },
1426 { MV_RIGHT | MV_DOWN, "right + down" },
1427 { MV_HORIZONTAL, "horizontal" },
1428 { MV_VERTICAL, "vertical" },
1429 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1430 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1431 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1432 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1433 { MV_ALL_DIRECTIONS, "all directions" },
1438 static struct ValueTextInfo options_walk_to_action[] =
1440 { EP_DIGGABLE, "diggable" },
1441 { EP_COLLECTIBLE_ONLY, "collectible" },
1442 { EP_DROPPABLE, "collectible & droppable" },
1443 { EP_THROWABLE, "collectible & throwable" },
1444 { EP_PUSHABLE, "pushable" },
1449 static struct ValueTextInfo options_move_pattern[] =
1451 { MV_LEFT, "left" },
1452 { MV_RIGHT, "right" },
1454 { MV_DOWN, "down" },
1455 { MV_HORIZONTAL, "horizontal" },
1456 { MV_VERTICAL, "vertical" },
1457 { MV_ALL_DIRECTIONS, "all directions" },
1458 { MV_WIND_DIRECTION, "wind direction" },
1459 { MV_TOWARDS_PLAYER, "towards player" },
1460 { MV_AWAY_FROM_PLAYER, "away from player" },
1461 { MV_ALONG_LEFT_SIDE, "along left side" },
1462 { MV_ALONG_RIGHT_SIDE, "along right side" },
1463 { MV_TURNING_LEFT, "turning left" },
1464 { MV_TURNING_RIGHT, "turning right" },
1465 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1466 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1467 { MV_TURNING_RANDOM, "turning random" },
1468 { MV_MAZE_RUNNER, "maze runner style" },
1469 { MV_MAZE_HUNTER, "maze hunter style" },
1470 { MV_WHEN_PUSHED, "when pushed" },
1471 { MV_WHEN_DROPPED, "when dropped/thrown" },
1476 static struct ValueTextInfo options_move_direction[] =
1478 { MV_START_AUTOMATIC, "automatic" },
1479 { MV_START_LEFT, "left" },
1480 { MV_START_RIGHT, "right" },
1481 { MV_START_UP, "up" },
1482 { MV_START_DOWN, "down" },
1483 { MV_START_RANDOM, "random" },
1484 { MV_START_PREVIOUS, "previous" },
1489 static struct ValueTextInfo options_move_stepsize[] =
1491 { 0, "not moving" },
1496 { 16, "very fast" },
1497 { 32, "even faster" },
1502 static struct ValueTextInfo options_move_leave_type[] =
1504 { LEAVE_TYPE_UNLIMITED, "leave behind" },
1505 { LEAVE_TYPE_LIMITED, "change it to" },
1510 static struct ValueTextInfo options_smash_targets[] =
1512 { EP_CAN_SMASH_PLAYER, "player" },
1514 { EP_CAN_SMASH_ENEMIES, "enemies" },
1516 { EP_CAN_SMASH_EVERYTHING, "everything" },
1521 static struct ValueTextInfo options_slippery_type[] =
1523 { SLIPPERY_ANY_RANDOM, "random" },
1524 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
1525 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
1526 { SLIPPERY_ONLY_LEFT, "only left" },
1527 { SLIPPERY_ONLY_RIGHT, "only right" },
1532 static struct ValueTextInfo options_deadliness[] =
1534 { EP_DONT_RUN_INTO, "running into" },
1535 { EP_DONT_COLLIDE_WITH, "colliding with" },
1536 { EP_DONT_GET_HIT_BY, "getting hit by" },
1537 { EP_DONT_TOUCH, "touching" },
1542 static struct ValueTextInfo options_explosion_type[] =
1544 { EXPLODES_3X3, "3x3" },
1545 { EXPLODES_CROSS, "3+3" },
1546 { EXPLODES_1X1, "1x1" },
1551 static struct ValueTextInfo options_time_units[] =
1554 { FRAMES_PER_SECOND, "seconds" },
1559 static struct ValueTextInfo options_change_direct_action[] =
1561 { CE_TOUCHED_BY_PLAYER, "touched by player" },
1562 { CE_PRESSED_BY_PLAYER, "pressed by player" },
1563 { CE_SWITCHED_BY_PLAYER, "switched by player" },
1564 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
1565 { CE_PUSHED_BY_PLAYER, "pushed by player" },
1566 { CE_ENTERED_BY_PLAYER, "entered by player" },
1567 { CE_LEFT_BY_PLAYER, "left by player" },
1568 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
1569 { CE_SWITCHED, "switched" },
1570 { CE_HITTING_SOMETHING, "hitting something" },
1571 { CE_HIT_BY_SOMETHING, "hit by something" },
1573 { CE_BLOCKED, "blocked" },
1575 { CE_IMPACT, "impact (on something)" },
1576 { CE_SMASHED, "smashed (from above)" },
1578 { CE_VALUE_CHANGES, "CE value changes" },
1579 { CE_SCORE_CHANGES, "CE score changes" },
1581 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
1582 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
1587 static struct ValueTextInfo options_change_other_action[] =
1589 { CE_PLAYER_TOUCHES_X, "player touches" },
1590 { CE_PLAYER_PRESSES_X, "player presses" },
1591 { CE_PLAYER_SWITCHES_X, "player switches" },
1592 { CE_PLAYER_SNAPS_X, "player snaps" },
1593 { CE_PLAYER_PUSHES_X, "player pushes" },
1594 { CE_PLAYER_ENTERS_X, "player enters" },
1595 { CE_PLAYER_LEAVES_X, "player leaves" },
1596 { CE_PLAYER_DIGS_X, "player digs" },
1597 { CE_PLAYER_COLLECTS_X, "player collects" },
1598 { CE_PLAYER_DROPS_X, "player drops/throws" },
1599 { CE_TOUCHING_X, "touching" },
1600 { CE_HITTING_X, "hitting" },
1601 { CE_DIGGING_X, "digging" },
1602 { CE_HIT_BY_X, "hit by" },
1603 { CE_SWITCH_OF_X, "switch of" },
1604 { CE_CHANGE_OF_X, "change by page of" },
1605 { CE_EXPLOSION_OF_X, "explosion of" },
1606 { CE_MOVE_OF_X, "move of" },
1607 { CE_CREATION_OF_X, "creation of" },
1608 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
1609 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
1610 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
1611 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
1616 static struct ValueTextInfo options_change_trigger_side[] =
1618 { CH_SIDE_LEFT, "left" },
1619 { CH_SIDE_RIGHT, "right" },
1620 { CH_SIDE_TOP, "top" },
1621 { CH_SIDE_BOTTOM, "bottom" },
1622 { CH_SIDE_LEFT_RIGHT, "left/right" },
1623 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
1624 { CH_SIDE_ANY, "any" },
1629 static struct ValueTextInfo options_change_trigger_player[] =
1631 { CH_PLAYER_1, "1" },
1632 { CH_PLAYER_2, "2" },
1633 { CH_PLAYER_3, "3" },
1634 { CH_PLAYER_4, "4" },
1635 { CH_PLAYER_ANY, "any" },
1640 static struct ValueTextInfo options_change_trigger_page[] =
1652 { (1 << 10), "11" },
1653 { (1 << 11), "12" },
1654 { (1 << 12), "13" },
1655 { (1 << 13), "14" },
1656 { (1 << 14), "15" },
1657 { (1 << 15), "16" },
1658 { (1 << 16), "17" },
1659 { (1 << 17), "18" },
1660 { (1 << 18), "19" },
1661 { (1 << 19), "20" },
1662 { (1 << 20), "21" },
1663 { (1 << 21), "22" },
1664 { (1 << 22), "23" },
1665 { (1 << 23), "24" },
1666 { (1 << 24), "25" },
1667 { (1 << 25), "26" },
1668 { (1 << 26), "27" },
1669 { (1 << 27), "28" },
1670 { (1 << 28), "29" },
1671 { (1 << 29), "30" },
1672 { (1 << 30), "31" },
1673 { (1 << 31), "32" },
1674 { CH_PAGE_ANY, "any" },
1679 static struct ValueTextInfo options_change_replace_when[] =
1681 { CP_WHEN_EMPTY, "empty" },
1682 { CP_WHEN_WALKABLE, "walkable" },
1683 { CP_WHEN_DIGGABLE, "diggable" },
1684 { CP_WHEN_COLLECTIBLE, "collectible" },
1685 { CP_WHEN_REMOVABLE, "removable" },
1686 { CP_WHEN_DESTRUCTIBLE, "destructible" },
1691 static struct ValueTextInfo options_action_type[] =
1693 { CA_NO_ACTION, "no action" },
1694 { CA_UNDEFINED, " " },
1695 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
1696 { CA_RESTART_LEVEL, "restart level" },
1697 { CA_SHOW_ENVELOPE, "show envelope" },
1698 { CA_SET_LEVEL_TIME, "set time" },
1699 { CA_SET_LEVEL_SCORE, "set score" },
1700 { CA_SET_LEVEL_GEMS, "set gems" },
1701 { CA_SET_LEVEL_WIND, "set wind dir." },
1702 { CA_UNDEFINED, " " },
1703 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
1704 { CA_MOVE_PLAYER, "move player" },
1705 { CA_EXIT_PLAYER, "exit player" },
1706 { CA_KILL_PLAYER, "kill player" },
1707 { CA_SET_PLAYER_KEYS, "set keys" },
1708 { CA_SET_PLAYER_SPEED, "set speed" },
1709 { CA_SET_PLAYER_SHIELD, "set shield" },
1710 { CA_SET_PLAYER_GRAVITY, "set gravity" },
1711 { CA_SET_PLAYER_ARTWORK, "set artwork" },
1712 { CA_SET_PLAYER_INVENTORY, "set inventory" },
1713 { CA_UNDEFINED, " " },
1714 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
1715 { CA_SET_CE_VALUE, "set CE value" },
1716 { CA_SET_CE_SCORE, "set CE score" },
1717 { CA_UNDEFINED, " " },
1718 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
1719 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
1724 static struct ValueTextInfo options_action_mode_none[] =
1726 { CA_MODE_UNDEFINED, " " },
1731 static struct ValueTextInfo options_action_mode_assign[] =
1733 { CA_MODE_SET, "=" },
1738 static struct ValueTextInfo options_action_mode_add_remove[] =
1740 { CA_MODE_ADD, "+" },
1741 { CA_MODE_SUBTRACT, "-" },
1746 static struct ValueTextInfo options_action_mode_calculate[] =
1748 { CA_MODE_SET, "=" },
1749 { CA_MODE_ADD, "+" },
1750 { CA_MODE_SUBTRACT, "-" },
1751 { CA_MODE_MULTIPLY, "*" },
1752 { CA_MODE_DIVIDE, "/" },
1753 { CA_MODE_MODULO, "%" },
1758 static struct ValueTextInfo options_action_arg_none[] =
1760 { CA_ARG_UNDEFINED, " " },
1765 static struct ValueTextInfo options_action_arg_player[] =
1767 { CA_ARG_PLAYER_HEADLINE, "[player]" },
1768 { CA_ARG_PLAYER_1, "1" },
1769 { CA_ARG_PLAYER_2, "2" },
1770 { CA_ARG_PLAYER_3, "3" },
1771 { CA_ARG_PLAYER_4, "4" },
1772 { CA_ARG_PLAYER_ANY, "any" },
1773 { CA_ARG_PLAYER_TRIGGER, "trigger" },
1774 { CA_ARG_PLAYER_ACTION, "action ->" },
1779 static struct ValueTextInfo options_action_arg_number[] =
1781 { CA_ARG_NUMBER_HEADLINE, "[number]" },
1788 { CA_ARG_10, "10" },
1789 { CA_ARG_100, "100" },
1790 { CA_ARG_1000, "1000" },
1791 { CA_ARG_UNDEFINED, " " },
1792 { CA_ARG_NUMBER_MIN, "min" },
1793 { CA_ARG_NUMBER_MAX, "max" },
1794 { CA_ARG_UNDEFINED, " " },
1795 { CA_ARG_NUMBER_RESET, "reset" },
1796 { CA_ARG_UNDEFINED, " " },
1797 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
1798 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
1799 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
1800 { CA_ARG_UNDEFINED, " " },
1801 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
1802 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
1803 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
1804 { CA_ARG_UNDEFINED, " " },
1805 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
1806 { CA_ARG_ELEMENT_CV_TARGET, "target" },
1807 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
1808 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
1809 { CA_ARG_UNDEFINED, " " },
1810 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
1811 { CA_ARG_ELEMENT_CS_TARGET, "target" },
1812 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
1813 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
1818 static struct ValueTextInfo options_action_arg_value[] =
1820 { CA_ARG_NUMBER_HEADLINE, "[number]" },
1827 { CA_ARG_10, "10" },
1828 { CA_ARG_100, "100" },
1829 { CA_ARG_1000, "1000" },
1830 { CA_ARG_UNDEFINED, " " },
1831 { CA_ARG_NUMBER_MIN, "min" },
1832 { CA_ARG_NUMBER_MAX, "max" },
1833 { CA_ARG_UNDEFINED, " " },
1834 { CA_ARG_NUMBER_RESET, "reset" },
1835 { CA_ARG_UNDEFINED, " " },
1836 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
1837 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
1838 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
1839 { CA_ARG_UNDEFINED, " " },
1840 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
1841 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
1842 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
1843 { CA_ARG_UNDEFINED, " " },
1844 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
1845 { CA_ARG_ELEMENT_CV_TARGET, "target" },
1846 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
1847 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
1848 { CA_ARG_UNDEFINED, " " },
1849 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
1850 { CA_ARG_ELEMENT_CS_TARGET, "target" },
1851 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
1852 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
1853 { CA_ARG_UNDEFINED, " " },
1854 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
1855 { CA_ARG_ELEMENT_NR_TARGET, "target" },
1856 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
1857 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
1862 static struct ValueTextInfo options_action_arg_envelope[] =
1864 { CA_ARG_NUMBER_HEADLINE, "[number]" },
1869 { CA_ARG_UNDEFINED, " " },
1870 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
1871 { CA_ARG_ELEMENT_TARGET, "target" },
1872 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
1873 { CA_ARG_ELEMENT_ACTION, "action ->" },
1878 static struct ValueTextInfo options_action_arg_key[] =
1880 { CA_ARG_NUMBER_HEADLINE, "[number]" },
1889 { CA_ARG_UNDEFINED, " " },
1890 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
1891 { CA_ARG_ELEMENT_TARGET, "target" },
1892 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
1893 { CA_ARG_ELEMENT_ACTION, "action ->" },
1898 static struct ValueTextInfo options_action_arg_speed[] =
1900 { CA_ARG_SPEED_HEADLINE, "[speed]" },
1901 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
1902 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
1903 { CA_ARG_SPEED_SLOW, "slow" },
1904 { CA_ARG_SPEED_NORMAL, "normal" },
1905 { CA_ARG_SPEED_FAST, "fast" },
1906 { CA_ARG_SPEED_VERY_FAST, "very fast" },
1907 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
1908 { CA_ARG_UNDEFINED, " " },
1909 { CA_ARG_SPEED_SLOWER, "slower" },
1910 { CA_ARG_SPEED_FASTER, "faster" },
1911 { CA_ARG_UNDEFINED, " " },
1912 { CA_ARG_SPEED_RESET, "reset" },
1917 static struct ValueTextInfo options_action_arg_shield[] =
1919 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
1920 { CA_ARG_SHIELD_OFF, "off" },
1921 { CA_ARG_SHIELD_NORMAL, "normal" },
1922 { CA_ARG_SHIELD_DEADLY, "deadly" },
1927 static struct ValueTextInfo options_action_arg_artwork[] =
1929 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
1930 { CA_ARG_ELEMENT_TARGET, "target" },
1931 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
1932 { CA_ARG_ELEMENT_ACTION, "action ->" },
1933 { CA_ARG_UNDEFINED, " " },
1934 { CA_ARG_ELEMENT_RESET, "reset" },
1939 static struct ValueTextInfo options_action_arg_gravity[] =
1941 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
1942 { CA_ARG_GRAVITY_ON, "on" },
1943 { CA_ARG_GRAVITY_OFF, "off" },
1944 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
1949 static struct ValueTextInfo options_action_arg_direction[] =
1951 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
1952 { CA_ARG_DIRECTION_NONE, "none" },
1953 { CA_ARG_DIRECTION_LEFT, "left" },
1954 { CA_ARG_DIRECTION_RIGHT, "right" },
1955 { CA_ARG_DIRECTION_UP, "up" },
1956 { CA_ARG_DIRECTION_DOWN, "down" },
1957 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
1958 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
1963 static struct ValueTextInfo options_action_arg_scan_mode[] =
1965 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
1966 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
1967 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
1972 static struct ValueTextInfo options_action_arg_inventory[] =
1974 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
1975 { CA_ARG_ELEMENT_TARGET, "target" },
1976 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
1977 { CA_ARG_ELEMENT_ACTION, "action ->" },
1978 { CA_ARG_UNDEFINED, " " },
1979 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
1980 { CA_ARG_INVENTORY_RM_FIRST, "first" },
1981 { CA_ARG_INVENTORY_RM_LAST, "last" },
1982 { CA_ARG_INVENTORY_RM_ALL, "all" },
1983 { CA_ARG_UNDEFINED, " " },
1984 { CA_ARG_INVENTORY_RESET, "reset" },
1989 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
1990 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
1995 static struct ValueTextInfo options_group_choice_mode[] =
1997 { ANIM_RANDOM, "random" },
1998 { ANIM_LOOP, "loop" },
1999 { ANIM_LINEAR, "linear" },
2000 { ANIM_PINGPONG, "pingpong" },
2001 { ANIM_PINGPONG2, "pingpong 2" },
2006 static struct ValueTextInfo *action_arg_modes[] =
2008 options_action_mode_none,
2009 options_action_mode_assign,
2010 options_action_mode_add_remove,
2011 options_action_mode_calculate,
2018 struct ValueTextInfo *options;
2020 action_arg_options[] =
2022 { CA_NO_ACTION, 0, options_action_arg_none, },
2023 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2024 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2025 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2026 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2027 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2028 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2029 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2030 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2031 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2032 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2033 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2034 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2035 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2036 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2037 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2038 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2039 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2040 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2049 int gadget_id_align;
2050 int size; /* char size of selectbox or '-1' (dynamically determined) */
2051 struct ValueTextInfo *options;
2053 char *text_left, *text_right, *infotext;
2054 } selectbox_info[ED_NUM_SELECTBOX] =
2056 /* ---------- level and editor settings ---------------------------------- */
2059 -1, ED_LEVEL_SETTINGS_YPOS(7),
2060 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2062 options_time_or_steps,
2063 &level.use_step_counter,
2064 NULL, "(0 => no limit)", "time or step limit"
2067 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
2068 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2070 options_game_engine_type,
2071 &level.game_engine_type,
2072 "game engine:", NULL, "game engine"
2075 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2076 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2078 options_wind_direction,
2079 &level.wind_direction_initial,
2080 "initial wind direction:", NULL, "initial wind direction"
2083 /* ---------- element settings: configure (several elements) ------------- */
2086 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
2087 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2089 options_player_speed,
2090 &level.initial_player_stepsize[0],
2091 "initial player speed:", NULL, "initial player speed"
2094 /* ---------- element settings: configure 1 (custom elements) ------------ */
2097 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2098 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2100 options_access_type,
2101 &custom_element.access_type,
2102 NULL, NULL, "type of access to this field"
2105 -1, ED_ELEMENT_SETTINGS_YPOS(3),
2106 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2108 options_access_layer,
2109 &custom_element.access_layer,
2110 NULL, NULL, "layer of access for this field"
2113 -1, ED_ELEMENT_SETTINGS_YPOS(3),
2114 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2116 options_access_protected,
2117 &custom_element.access_protected,
2118 NULL, NULL, "protected access for this field"
2121 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2122 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2124 options_access_direction,
2125 &custom_element.access_direction,
2126 "from", NULL, "access direction for this field"
2129 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
2130 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2132 options_walk_to_action,
2133 &custom_element.walk_to_action,
2134 NULL, NULL, "diggable/collectible/pushable"
2137 /* ---------- element settings: configure 2 (custom elements) ------------ */
2140 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2141 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2143 options_move_pattern,
2144 &custom_element.move_pattern,
2145 "can move", NULL, "element move pattern"
2148 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2149 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2151 options_move_direction,
2152 &custom_element.move_direction_initial,
2153 "starts moving", NULL, "initial element move direction"
2156 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2157 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2159 options_move_stepsize,
2160 &custom_element.move_stepsize,
2161 "move/fall speed", NULL, "speed of element movement"
2164 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2165 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2167 options_move_leave_type,
2168 &custom_element.move_leave_type,
2169 "can dig: can", ":", "leave behind or change element"
2172 -1, ED_ELEMENT_SETTINGS_YPOS(7),
2173 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2175 options_smash_targets,
2176 &custom_element.smash_targets,
2177 "can smash", NULL, "elements that can be smashed"
2180 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
2181 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2183 options_slippery_type,
2184 &custom_element.slippery_type,
2185 "slippery", NULL, "where other elements fall down"
2188 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2189 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2192 &custom_element.deadliness,
2193 "deadly when", NULL, "deadliness of element"
2196 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2197 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2199 options_explosion_type,
2200 &custom_element.explosion_type,
2201 "can explode", NULL, "explosion type"
2204 /* ---------- element settings: advanced (custom elements) --------------- */
2207 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2208 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2211 &custom_element_change.delay_frames,
2212 "delay time given in", NULL, "delay time units for change"
2215 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2216 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2218 options_change_direct_action,
2219 &custom_element_change.direct_action,
2220 NULL, NULL, "type of direct action"
2223 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2224 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2226 options_change_other_action,
2227 &custom_element_change.other_action,
2228 NULL, "element:", "type of other element action"
2231 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2232 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2234 options_change_trigger_side,
2235 &custom_element_change.trigger_side,
2236 "at", "side", "element side triggering change"
2239 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2240 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2242 options_change_trigger_player,
2243 &custom_element_change.trigger_player,
2244 "player:", " ", "player that causes change"
2247 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2248 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2250 options_change_trigger_page,
2251 &custom_element_change.trigger_page,
2252 "page:", NULL, "change page that causes change"
2255 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2256 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2258 options_change_replace_when,
2259 &custom_element_change.replace_when,
2260 "replace when", NULL, "which elements can be replaced"
2263 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2264 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2266 options_action_type,
2267 &custom_element_change.action_type,
2268 NULL, NULL, "action on specified condition"
2271 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2272 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2274 options_action_mode_none,
2275 &custom_element_change.action_mode,
2276 NULL, NULL, "action operator"
2279 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2280 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2282 options_action_arg_none,
2283 &custom_element_change.action_arg,
2284 NULL, NULL, "action parameter"
2287 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2288 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2290 options_change_page,
2291 &custom_element.current_change_page,
2292 NULL, NULL, "element change page"
2295 /* ---------- element settings: configure (group elements) --------------- */
2298 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
2299 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2301 options_group_choice_mode,
2302 &group_element_info.choice_mode,
2303 "choice type:", NULL, "type of group element choice"
2311 int gadget_id_align;
2314 char *text_left, *text_right, *infotext;
2315 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2318 ED_ELEMENT_SETTINGS_XPOS(0), ED_COUNTER_YPOS(1),
2319 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
2321 NULL, NULL, "Show information about element"
2324 ED_ELEMENT_SETTINGS_XPOS(0) + 124, ED_COUNTER_YPOS(1),
2325 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_NONE,
2327 NULL, NULL, "Configure element properties"
2330 ED_ELEMENT_SETTINGS_XPOS(0) + 124, ED_COUNTER_YPOS(1),
2331 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_NONE,
2333 NULL, NULL, "Configure element properties, part 1"
2336 ED_ELEMENT_SETTINGS_XPOS(0) + 248, ED_COUNTER_YPOS(1),
2337 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_NONE,
2339 NULL, NULL, "Configure element properties, part 2"
2342 ED_ELEMENT_SETTINGS_XPOS(0) + 372, ED_COUNTER_YPOS(1),
2343 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_NONE,
2345 NULL, NULL, "Configure custom element change pages"
2348 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2349 GADGET_ID_SAVE_AS_TEMPLATE, GADGET_ID_CUSTOM_USE_TEMPLATE,
2351 " ", "As Template", "Save current settings as new template"
2354 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2355 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
2357 NULL, NULL, "Add new change page"
2360 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2361 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
2363 NULL, NULL, "Delete current change page"
2373 int gadget_id_align;
2374 char *text_left, *text_right, *infotext;
2375 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
2378 ED_BUTTON_MINUS_XPOS, ED_BUTTON_COUNT_YPOS,
2379 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
2380 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
2381 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
2382 NULL, NULL, "select previous change page"
2385 ED_BUTTON_PLUS_XPOS, ED_BUTTON_COUNT_YPOS,
2386 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2387 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
2388 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
2389 NULL, "change page", "select next change page"
2392 ED_COPY_CHANGE_PAGE_XPOS, ED_COPY_CHANGE_PAGE_YPOS,
2393 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2394 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
2395 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
2396 " ", NULL, "copy settings from this change page"
2399 ED_PASTE_CHANGE_PAGE_XPOS, ED_PASTE_CHANGE_PAGE_YPOS,
2400 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2401 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
2402 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
2403 NULL, NULL, "paste settings to this change page"
2413 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
2416 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 0 * ED_SCROLLBUTTON_YSIZE,
2417 ED_SCROLL_UP_XPOS, ED_SCROLL_UP_YPOS,
2418 GADGET_ID_SCROLL_UP,
2419 "scroll level editing area up"
2422 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 1 * ED_SCROLLBUTTON_YSIZE,
2423 ED_SCROLL_DOWN_XPOS, ED_SCROLL_DOWN_YPOS,
2424 GADGET_ID_SCROLL_DOWN,
2425 "scroll level editing area down"
2428 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 2 * ED_SCROLLBUTTON_YSIZE,
2429 ED_SCROLL_LEFT_XPOS, ED_SCROLL_LEFT_YPOS,
2430 GADGET_ID_SCROLL_LEFT,
2431 "scroll level editing area left"
2434 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 3 * ED_SCROLLBUTTON_YSIZE,
2435 ED_SCROLL_RIGHT_XPOS, ED_SCROLL_RIGHT_YPOS,
2436 GADGET_ID_SCROLL_RIGHT,
2437 "scroll level editing area right"
2440 ED_SCROLLBUTTON2_XPOS, ED_SCROLLBUTTON2_YPOS + 0 * ED_SCROLLBUTTON2_YSIZE,
2441 ED_SCROLL2_UP_XPOS, ED_SCROLL2_UP_YPOS,
2442 GADGET_ID_SCROLL_LIST_UP,
2443 "scroll element list up ('Page Up')"
2446 ED_SCROLLBUTTON2_XPOS, ED_SCROLLBUTTON2_YPOS + 1 * ED_SCROLLBUTTON2_YSIZE,
2447 ED_SCROLL2_DOWN_XPOS, ED_SCROLL2_DOWN_YPOS,
2448 GADGET_ID_SCROLL_LIST_DOWN,
2449 "scroll element list down ('Page Down')"
2458 int wheel_x, wheel_y;
2459 int wheel_width, wheel_height;
2463 } scrollbar_info[ED_NUM_SCROLLBARS] =
2466 ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
2467 SX + ED_SCROLL_HORIZONTAL_XPOS, SY + ED_SCROLL_HORIZONTAL_YPOS,
2468 ED_SCROLL_HORIZONTAL_XSIZE, ED_SCROLL_HORIZONTAL_YSIZE,
2474 SX + SXSIZE + SX, WIN_YSIZE,
2476 GD_TYPE_SCROLLBAR_HORIZONTAL,
2477 GADGET_ID_SCROLL_HORIZONTAL,
2478 "scroll level editing area horizontally"
2481 ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
2482 SX + ED_SCROLL_VERTICAL_XPOS, SY + ED_SCROLL_VERTICAL_YPOS,
2483 ED_SCROLL_VERTICAL_XSIZE, ED_SCROLL_VERTICAL_YSIZE,
2489 SX + SXSIZE + SX, WIN_YSIZE,
2491 GD_TYPE_SCROLLBAR_VERTICAL,
2492 GADGET_ID_SCROLL_VERTICAL,
2493 "scroll level editing area vertically"
2496 ED_SCROLLBAR2_XPOS, ED_SCROLLBAR2_YPOS,
2497 DX + ED_SCROLL2_VERTICAL_XPOS, DY + ED_SCROLL2_VERTICAL_YPOS,
2498 ED_SCROLL2_VERTICAL_XSIZE, ED_SCROLL2_VERTICAL_YSIZE,
2503 SX + SXSIZE + SX, 0,
2504 WIN_XSIZE - (SX + SXSIZE + SX), WIN_YSIZE,
2506 GD_TYPE_SCROLLBAR_VERTICAL,
2507 GADGET_ID_SCROLL_LIST_VERTICAL,
2508 "scroll element list vertically"
2516 int gadget_id_align;
2517 int radio_button_nr;
2520 char *text_left, *text_right, *infotext;
2521 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
2524 -1, ED_COUNTER2_YPOS(8),
2525 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
2526 RADIO_NR_RANDOM_ELEMENTS,
2527 &random_placement_method, RANDOM_USE_PERCENTAGE,
2528 " ", "percentage", "use percentage for random elements"
2531 -1, ED_COUNTER2_YPOS(8),
2532 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
2533 RADIO_NR_RANDOM_ELEMENTS,
2534 &random_placement_method, RANDOM_USE_QUANTITY,
2535 " ", "quantity", "use quantity for random elements"
2543 int gadget_id_align;
2545 char *text_left, *text_right, *infotext;
2546 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
2548 /* ---------- level and editor settings ---------------------------------- */
2551 ED_LEVEL_SETTINGS_XPOS(0), ED_COUNTER2_YPOS(9) - MINI_TILEY,
2552 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
2553 &random_placement_background_restricted,
2555 "restrict random placement to:", "set random placement restriction"
2558 /* ---------- element settings: configure (various elements) ------------- */
2561 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2562 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
2563 &stick_element_properties_window,
2565 "stick this screen to edit content","stick this screen to edit content"
2568 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2569 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
2570 &level.em_slippery_gems,
2572 "slip down from certain flat walls","use EM/DC style slipping behaviour"
2575 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2576 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
2577 &level.use_spring_bug,
2579 "use spring pushing bug", "use odd spring pushing behaviour"
2582 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2583 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
2584 &level.use_time_orb_bug,
2586 "use time orb bug", "use odd time orb behaviour"
2589 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2590 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
2593 "create single random element", "only create one element from content"
2596 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2597 GADGET_ID_INITIAL_BALL_STATE, GADGET_ID_NONE,
2598 &level.ball_state_initial,
2600 "magic ball initially activated", "activate magic ball after level start"
2603 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2604 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
2605 &level.grow_into_diggable,
2607 "can grow into anything diggable", "grow into more than just sand"
2610 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
2611 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
2612 &level.continuous_snapping,
2614 "continuos snapping", "use snapping without releasing key"
2617 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2618 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
2619 &level.block_snap_field,
2621 "block snapped field when snapping", "use snapping delay to show animation"
2624 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2625 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
2626 &level.block_last_field,
2628 "block last field when moving", "player blocks last field when moving"
2631 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2632 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
2633 &level.sp_block_last_field,
2635 "block last field when moving", "player blocks last field when moving"
2638 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
2639 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
2640 &level.instant_relocation,
2642 "no scrolling when relocating", "player gets relocated without delay"
2645 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2646 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
2647 &level.shifted_relocation,
2649 "no centering when relocating", "level not centered after relocation"
2652 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
2653 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
2654 &level.use_start_element[0],
2656 "use level start element:", "start level at this element's position"
2659 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
2660 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
2661 &level.use_artwork_element[0],
2663 "use artwork from element:", "use player artwork from other element"
2666 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
2667 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
2668 &level.use_explosion_element[0],
2670 "use explosion from element:", "use explosion properties from element"
2673 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
2674 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
2675 &level.initial_player_gravity[0],
2677 "use initial gravity", "set initial player gravity"
2680 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2681 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
2682 &level.use_initial_inventory[0],
2684 "use initial inventory:", "use collected elements on level start"
2687 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
2688 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
2689 &level.can_pass_to_walkable,
2691 "can pass to walkable element", "player can pass to empty or walkable"
2694 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2695 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
2696 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
2698 "can fall into acid (with gravity)","player can fall into acid pool"
2701 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2702 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
2703 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
2705 "can move into acid", "element can move into acid pool"
2708 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2709 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
2710 &custom_element_properties[EP_DONT_COLLIDE_WITH],
2712 "deadly when colliding with", "element is deadly when hitting player"
2715 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2716 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
2717 &level.envelope[0].autowrap,
2719 "auto-wrap", "automatically wrap envelope text"
2722 -1, ED_ELEMENT_SETTINGS_YPOS(1),
2723 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
2724 &level.envelope[0].centered,
2726 "centered", "automatically center envelope text"
2729 /* ---------- element settings: configure 1 (custom elements) ----------- */
2732 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2733 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
2734 &custom_element.use_gfx_element,
2736 /* !!! add separate "use existing element sound" !!! */
2739 "use graphic/sound of element:", "use existing graphic and sound"
2742 "use graphic of element:", "use existing element graphic"
2746 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2747 GADGET_ID_CUSTOM_USE_TEMPLATE, GADGET_ID_NONE,
2748 &level.use_custom_template,
2750 "use template", "use template for custom properties"
2753 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
2754 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
2755 &custom_element_properties[EP_ACCESSIBLE],
2757 NULL, "player can walk to or pass this field"
2760 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
2761 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
2762 &custom_element_properties[EP_GRAVITY_REACHABLE],
2764 "reachable despite gravity", "player can walk/dig despite gravity"
2767 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
2768 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
2769 &custom_element.use_last_ce_value,
2771 "use last CE value after change", "use last CE value after change"
2774 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
2775 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
2776 &custom_element_properties[EP_WALK_TO_OBJECT],
2778 NULL, "player can dig/collect/push element"
2781 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
2782 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
2783 &custom_element_properties[EP_INDESTRUCTIBLE],
2785 "indestructible", "element is indestructible"
2788 /* ---------- element settings: configure 2 (custom elements) ----------- */
2791 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2792 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
2793 &custom_element_properties[EP_CAN_MOVE],
2795 NULL, "element can move with some pattern"
2798 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2799 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
2800 &custom_element_properties[EP_CAN_FALL],
2802 "can fall", "element can fall down"
2805 -1, ED_ELEMENT_SETTINGS_YPOS(7),
2806 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
2807 &custom_element_properties[EP_CAN_SMASH],
2809 NULL, "element can smash other elements"
2812 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
2813 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
2814 &custom_element_properties[EP_SLIPPERY],
2816 NULL, "other elements can fall down from it"
2819 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
2820 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
2821 &custom_element_properties[EP_DEADLY],
2823 NULL, "element can kill the player"
2826 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
2827 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
2828 &custom_element_properties[EP_CAN_EXPLODE],
2830 NULL, "element can explode"
2833 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
2834 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
2835 &custom_element_properties[EP_EXPLODES_BY_FIRE],
2837 "by fire", "element can explode by fire/explosion"
2840 -1, ED_ELEMENT_SETTINGS_YPOS(11),
2841 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
2842 &custom_element_properties[EP_EXPLODES_SMASHED],
2844 "smashed", "element can explode when smashed"
2847 -1, ED_ELEMENT_SETTINGS_YPOS(11),
2848 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
2849 &custom_element_properties[EP_EXPLODES_IMPACT],
2851 "impact", "element can explode on impact"
2854 /* ---------- element settings: advanced (custom elements) --------------- */
2857 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2858 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
2859 &custom_element_change.can_change,
2861 "element changes to:", "change element on specified condition"
2864 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2865 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
2866 &custom_element_change_events[CE_DELAY],
2868 NULL, "element changes after delay"
2871 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2872 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
2873 &custom_element_change_events[CE_BY_DIRECT_ACTION],
2875 NULL, "element changes by direct action"
2878 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
2879 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
2880 &custom_element_change_events[CE_BY_OTHER_ACTION],
2882 NULL, "element changes by other element"
2885 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
2886 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
2887 &custom_element_change.explode,
2889 "explode instead of change", "element explodes instead of change"
2892 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2893 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
2894 &custom_element_change.use_target_content,
2896 "use extended change target:", "element changes to more elements"
2899 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
2900 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
2901 &custom_element_change.only_if_complete,
2903 "replace all or nothing", "only replace when all can be changed"
2906 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
2907 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
2908 &custom_element_change.use_random_replace,
2910 NULL, "use percentage for random replace"
2913 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
2914 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
2915 &custom_element_change.has_action,
2917 NULL, "execute action on specified condition"
2925 int gadget_id_align;
2927 int area_xsize, area_ysize;
2928 char *text_left, *text_right, *text_below, *infotext;
2929 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
2931 /* ---------- level playfield content ------------------------------------ */
2935 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
2936 NULL, MAX_ED_FIELDX, MAX_ED_FIELDY,
2937 NULL, NULL, NULL, NULL
2940 /* ---------- yam yam content -------------------------------------------- */
2943 ED_AREA_YAMYAM_CONTENT_XPOS(0), ED_AREA_YAMYAM_CONTENT_YPOS(0),
2944 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
2945 &level.yamyam_content[0].e[0][0], 3, 3,
2946 NULL, NULL, "1", NULL
2949 ED_AREA_YAMYAM_CONTENT_XPOS(1), ED_AREA_YAMYAM_CONTENT_YPOS(1),
2950 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
2951 &level.yamyam_content[1].e[0][0], 3, 3,
2952 NULL, NULL, "2", NULL
2955 ED_AREA_YAMYAM_CONTENT_XPOS(2), ED_AREA_YAMYAM_CONTENT_YPOS(2),
2956 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
2957 &level.yamyam_content[2].e[0][0], 3, 3,
2958 NULL, NULL, "3", NULL
2961 ED_AREA_YAMYAM_CONTENT_XPOS(3), ED_AREA_YAMYAM_CONTENT_YPOS(3),
2962 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
2963 &level.yamyam_content[3].e[0][0], 3, 3,
2964 NULL, NULL, "4", NULL
2967 ED_AREA_YAMYAM_CONTENT_XPOS(4), ED_AREA_YAMYAM_CONTENT_YPOS(4),
2968 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
2969 &level.yamyam_content[4].e[0][0], 3, 3,
2970 NULL, NULL, "5", NULL
2973 ED_AREA_YAMYAM_CONTENT_XPOS(5), ED_AREA_YAMYAM_CONTENT_YPOS(5),
2974 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
2975 &level.yamyam_content[5].e[0][0], 3, 3,
2976 NULL, NULL, "6", NULL
2979 ED_AREA_YAMYAM_CONTENT_XPOS(6), ED_AREA_YAMYAM_CONTENT_YPOS(6),
2980 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
2981 &level.yamyam_content[6].e[0][0], 3, 3,
2982 NULL, NULL, "7", NULL
2985 ED_AREA_YAMYAM_CONTENT_XPOS(7), ED_AREA_YAMYAM_CONTENT_YPOS(7),
2986 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
2987 &level.yamyam_content[7].e[0][0], 3, 3,
2988 NULL, NULL, "8", NULL
2991 /* ---------- magic ball content ----------------------------------------- */
2994 ED_AREA_MAGIC_BALL_CONTENT_XPOS(0), ED_AREA_MAGIC_BALL_CONTENT_YPOS(0),
2995 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
2996 &level.ball_content[0].e[0][0], 3, 3,
2997 NULL, NULL, "1", NULL
3000 ED_AREA_MAGIC_BALL_CONTENT_XPOS(1), ED_AREA_MAGIC_BALL_CONTENT_YPOS(1),
3001 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
3002 &level.ball_content[1].e[0][0], 3, 3,
3003 NULL, NULL, "2", NULL
3006 ED_AREA_MAGIC_BALL_CONTENT_XPOS(2), ED_AREA_MAGIC_BALL_CONTENT_YPOS(2),
3007 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
3008 &level.ball_content[2].e[0][0], 3, 3,
3009 NULL, NULL, "3", NULL
3012 ED_AREA_MAGIC_BALL_CONTENT_XPOS(3), ED_AREA_MAGIC_BALL_CONTENT_YPOS(3),
3013 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
3014 &level.ball_content[3].e[0][0], 3, 3,
3015 NULL, NULL, "4", NULL
3018 ED_AREA_MAGIC_BALL_CONTENT_XPOS(4), ED_AREA_MAGIC_BALL_CONTENT_YPOS(4),
3019 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
3020 &level.ball_content[4].e[0][0], 3, 3,
3021 NULL, NULL, "5", NULL
3024 ED_AREA_MAGIC_BALL_CONTENT_XPOS(5), ED_AREA_MAGIC_BALL_CONTENT_YPOS(5),
3025 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
3026 &level.ball_content[5].e[0][0], 3, 3,
3027 NULL, NULL, "6", NULL
3030 ED_AREA_MAGIC_BALL_CONTENT_XPOS(6), ED_AREA_MAGIC_BALL_CONTENT_YPOS(6),
3031 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
3032 &level.ball_content[6].e[0][0], 3, 3,
3033 NULL, NULL, "7", NULL
3036 ED_AREA_MAGIC_BALL_CONTENT_XPOS(7), ED_AREA_MAGIC_BALL_CONTENT_YPOS(7),
3037 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
3038 &level.ball_content[7].e[0][0], 3, 3,
3039 NULL, NULL, "8", NULL
3042 /* ---------- android content -------------------------------------------- */
3045 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(5),
3046 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
3047 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
3048 "elements:", NULL, NULL, "elements android can clone"
3051 /* ---------- amoeba content --------------------------------------------- */
3054 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
3055 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
3056 &level.amoeba_content, 1, 1,
3057 "content:", NULL, NULL, "amoeba content"
3060 /* ---------- level start element ---------------------------------------- */
3063 -1, ED_AREA_1X1_SETTINGS_YPOS(9),
3064 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
3065 &level.start_element[0], 1, 1,
3066 NULL, NULL, NULL, "level start element"
3069 /* ---------- player artwork element ------------------------------------- */
3072 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
3073 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
3074 &level.artwork_element[0], 1, 1,
3075 NULL, NULL, NULL, "element for player artwork"
3078 /* ---------- player explosion element ----------------------------------- */
3081 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
3082 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
3083 &level.explosion_element[0], 1, 1,
3084 NULL, NULL, NULL, "element for player explosion"
3087 /* ---------- player initial inventory ----------------------------------- */
3090 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3091 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
3092 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
3093 NULL, NULL, NULL, "content for initial inventory"
3096 /* ---------- element settings: configure 1 (custom elements) ----------- */
3098 /* ---------- custom graphic --------------------------------------------- */
3101 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3102 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
3103 &custom_element.gfx_element, 1, 1,
3104 NULL, NULL, NULL, "custom graphic element"
3107 /* ---------- element settings: configure 2 (custom elements) ----------- */
3109 /* ---------- custom content (when exploding) ---------------------------- */
3112 -1, ED_AREA_3X3_SETTINGS_YPOS(10),
3113 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, /* align three rows */
3114 &custom_element.content.e[0][0], 3, 3,
3115 "content:", NULL, NULL, NULL
3118 /* ---------- custom enter and leave element (when moving) --------------- */
3121 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
3122 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
3123 &custom_element.move_enter_element, 1, 1,
3124 "can dig:", " ", NULL, "element that can be digged/collected"
3127 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
3128 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
3129 &custom_element.move_leave_element, 1, 1,
3130 NULL, NULL, NULL, "element that will be left behind"
3133 /* ---------- element settings: advanced (custom elements) --------------- */
3135 /* ---------- custom change target --------------------------------------- */
3138 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3139 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
3140 &custom_element_change.target_element, 1, 1,
3141 NULL, "after/when:", NULL, "new target element after change"
3144 /* ---------- custom change content (extended change target) ------------- */
3147 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
3148 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, /* align three rows */
3149 &custom_element_change.target_content.e[0][0], 3, 3,
3150 NULL, NULL, NULL, "new extended elements after change"
3153 /* ---------- custom change trigger (element causing change) ------------- */
3156 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
3157 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
3158 &custom_element_change.initial_trigger_element, 1, 1,
3159 NULL, NULL, NULL, "other element triggering change"
3162 /* ---------- custom change action (element used for action) ------------- */
3165 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
3166 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
3167 &custom_element_change.action_element, 1, 1,
3168 NULL, NULL, NULL, "element used as action parameter"
3171 /* ---------- group element content -------------------------------------- */
3174 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(4),
3175 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
3176 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
3177 "content:", NULL, NULL, NULL
3180 /* ---------- random background (for random painting) -------------------- */
3183 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3184 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
3185 &random_placement_background_element, 1, 1,
3186 NULL, NULL, NULL, "random placement background"
3192 -----------------------------------------------------------------------------
3193 some internally used variables
3194 -----------------------------------------------------------------------------
3197 /* actual size of level editor drawing area */
3198 static int ed_fieldx = MAX_ED_FIELDX - 1, ed_fieldy = MAX_ED_FIELDY - 1;
3200 /* actual position of level editor drawing area in level playfield */
3201 static int level_xpos = -1, level_ypos = -1;
3204 #define IN_ED_FIELD(x,y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
3206 #define IN_ED_FIELD(x,y) ((x)>=0 && (x)<ed_fieldx && (y)>=0 &&(y)<ed_fieldy)
3209 /* drawing elements on the three mouse buttons */
3210 static int new_element1 = EL_WALL;
3211 static int new_element2 = EL_EMPTY;
3212 static int new_element3 = EL_SAND;
3214 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
3215 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
3216 (button) == 2 ? new_element2 : \
3217 (button) == 3 ? new_element3 : EL_EMPTY)
3218 #define BUTTON_STEPSIZE(button) ((button) == 1 ? 1 : (button) == 2 ? 5 : 10)
3220 /* forward declaration for internal use */
3221 static void ModifyEditorCounterValue(int, int);
3222 static void ModifyEditorCounterLimits(int, int, int);
3223 static void ModifyEditorSelectboxValue(int, int);
3224 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
3225 static void ModifyEditorDrawingArea(int, int, int);
3226 static void ModifyEditorElementList();
3227 static void AdjustElementListScrollbar();
3228 static void RedrawDrawingElements();
3229 static void DrawDrawingWindow();
3230 static void DrawLevelInfoWindow();
3231 static void DrawPropertiesWindow();
3232 static void UpdateCustomElementGraphicGadgets();
3233 static boolean checkPropertiesConfig(int);
3234 static void CopyLevelToUndoBuffer(int);
3235 static void HandleDrawingAreas(struct GadgetInfo *);
3236 static void HandleCounterButtons(struct GadgetInfo *);
3237 static void HandleTextInputGadgets(struct GadgetInfo *);
3238 static void HandleTextAreaGadgets(struct GadgetInfo *);
3239 static void HandleSelectboxGadgets(struct GadgetInfo *);
3240 static void HandleTextbuttonGadgets(struct GadgetInfo *);
3241 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
3242 static void HandleRadiobuttons(struct GadgetInfo *);
3243 static void HandleCheckbuttons(struct GadgetInfo *);
3244 static void HandleControlButtons(struct GadgetInfo *);
3245 static void HandleDrawingAreaInfo(struct GadgetInfo *);
3246 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
3248 static struct GadgetInfo *level_editor_gadget[NUM_EDITOR_GADGETS];
3249 static int right_gadget_border[NUM_EDITOR_GADGETS];
3251 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
3252 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
3253 static boolean draw_with_brush = FALSE;
3254 static int properties_element = 0;
3256 static short FieldBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3257 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3258 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3259 static int undo_buffer_position = 0;
3260 static int undo_buffer_steps = 0;
3262 static int edit_mode;
3263 static int edit_mode_properties;
3265 static int element_shift = 0;
3267 static int editor_el_players[] =
3274 static int *editor_el_players_ptr = editor_el_players;
3275 static int num_editor_el_players = SIZEOF_ARRAY_INT(editor_el_players);
3277 static int editor_hl_boulderdash[] =
3279 EL_INTERNAL_CASCADE_BD_ACTIVE,
3285 static int editor_el_boulderdash[] =
3294 EL_BD_EXPANDABLE_WALL,
3302 EL_BD_BUTTERFLY_LEFT,
3304 EL_BD_BUTTERFLY_RIGHT,
3305 EL_BD_FIREFLY_RIGHT,
3308 EL_BD_BUTTERFLY_DOWN,
3312 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
3313 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
3314 static int num_editor_hl_boulderdash = SIZEOF_ARRAY_INT(editor_hl_boulderdash);
3315 static int num_editor_el_boulderdash = SIZEOF_ARRAY_INT(editor_el_boulderdash);
3317 static int editor_hl_emerald_mine[] =
3319 EL_INTERNAL_CASCADE_EM_ACTIVE,
3325 static int editor_el_emerald_mine[] =
3362 EL_ACID_POOL_TOPLEFT,
3364 EL_ACID_POOL_TOPRIGHT,
3367 EL_ACID_POOL_BOTTOMLEFT,
3368 EL_ACID_POOL_BOTTOM,
3369 EL_ACID_POOL_BOTTOMRIGHT,
3389 EL_EM_STEEL_EXIT_CLOSED,
3390 EL_EM_STEEL_EXIT_OPEN,
3392 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
3393 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
3394 static int num_editor_hl_emerald_mine=SIZEOF_ARRAY_INT(editor_hl_emerald_mine);
3395 static int num_editor_el_emerald_mine=SIZEOF_ARRAY_INT(editor_el_emerald_mine);
3397 static int editor_hl_emerald_mine_club[] =
3399 EL_INTERNAL_CASCADE_EMC_ACTIVE,
3405 static int editor_el_emerald_mine_club[] =
3432 EL_EMC_WALL_SLIPPERY_1,
3433 EL_EMC_WALL_SLIPPERY_2,
3434 EL_EMC_WALL_SLIPPERY_3,
3435 EL_EMC_WALL_SLIPPERY_4,
3458 EL_EMC_MAGIC_BALL_SWITCH,
3460 EL_EMC_SPRING_BUMPER,
3465 EL_EM_DYNAMITE_ACTIVE,
3469 EL_BALLOON_SWITCH_UP,
3470 EL_BALLOON_SWITCH_ANY,
3473 EL_BALLOON_SWITCH_LEFT,
3475 EL_BALLOON_SWITCH_RIGHT,
3479 EL_BALLOON_SWITCH_DOWN,
3480 EL_BALLOON_SWITCH_NONE,
3482 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
3483 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
3484 static int num_editor_hl_emerald_mine_club=SIZEOF_ARRAY_INT(editor_hl_emerald_mine_club);
3485 static int num_editor_el_emerald_mine_club=SIZEOF_ARRAY_INT(editor_el_emerald_mine_club);
3487 static int editor_hl_rnd[] =
3489 EL_INTERNAL_CASCADE_RND_ACTIVE,
3495 static int editor_el_rnd[] =
3527 EL_WALL_EMERALD_YELLOW,
3528 EL_WALL_EMERALD_RED,
3529 EL_WALL_EMERALD_PURPLE,
3547 EL_DYNABOMB_INCREASE_NUMBER,
3548 EL_DYNABOMB_INCREASE_SIZE,
3549 EL_DYNABOMB_INCREASE_POWER,
3569 EL_INVISIBLE_STEELWALL,
3573 EL_EXPANDABLE_WALL_HORIZONTAL,
3574 EL_EXPANDABLE_WALL_VERTICAL,
3575 EL_EXPANDABLE_WALL_ANY,
3577 static int *editor_hl_rnd_ptr = editor_hl_rnd;
3578 static int *editor_el_rnd_ptr = editor_el_rnd;
3579 static int num_editor_hl_rnd = SIZEOF_ARRAY_INT(editor_hl_rnd);
3580 static int num_editor_el_rnd = SIZEOF_ARRAY_INT(editor_el_rnd);
3582 static int editor_hl_sokoban[] =
3584 EL_INTERNAL_CASCADE_SB_ACTIVE,
3590 static int editor_el_sokoban[] =
3593 EL_SOKOBAN_FIELD_EMPTY,
3594 EL_SOKOBAN_FIELD_FULL,
3595 EL_SOKOBAN_FIELD_PLAYER,
3597 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
3598 static int *editor_el_sokoban_ptr = editor_el_sokoban;
3599 static int num_editor_hl_sokoban = SIZEOF_ARRAY_INT(editor_hl_sokoban);
3600 static int num_editor_el_sokoban = SIZEOF_ARRAY_INT(editor_el_sokoban);
3602 static int editor_hl_supaplex[] =
3604 EL_INTERNAL_CASCADE_SP_ACTIVE,
3610 static int editor_el_supaplex[] =
3628 EL_SP_PORT_HORIZONTAL,
3629 EL_SP_PORT_VERTICAL,
3637 EL_SP_GRAVITY_PORT_LEFT,
3638 EL_SP_GRAVITY_PORT_RIGHT,
3639 EL_SP_GRAVITY_PORT_UP,
3640 EL_SP_GRAVITY_PORT_DOWN,
3642 EL_SP_HARDWARE_GRAY,
3643 EL_SP_HARDWARE_GREEN,
3644 EL_SP_HARDWARE_BLUE,
3647 EL_SP_HARDWARE_BASE_1,
3648 EL_SP_HARDWARE_BASE_2,
3649 EL_SP_HARDWARE_BASE_3,
3650 EL_SP_HARDWARE_BASE_4,
3652 EL_SP_HARDWARE_BASE_5,
3653 EL_SP_HARDWARE_BASE_6,
3654 EL_SP_HARDWARE_YELLOW,
3662 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
3663 static int *editor_el_supaplex_ptr = editor_el_supaplex;
3664 static int num_editor_hl_supaplex = SIZEOF_ARRAY_INT(editor_hl_supaplex);
3665 static int num_editor_el_supaplex = SIZEOF_ARRAY_INT(editor_el_supaplex);
3667 static int editor_hl_diamond_caves[] =
3669 EL_INTERNAL_CASCADE_DC_ACTIVE,
3675 static int editor_el_diamond_caves[] =
3682 EL_CONVEYOR_BELT_1_LEFT,
3683 EL_CONVEYOR_BELT_1_MIDDLE,
3684 EL_CONVEYOR_BELT_1_RIGHT,
3685 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
3687 EL_CONVEYOR_BELT_2_LEFT,
3688 EL_CONVEYOR_BELT_2_MIDDLE,
3689 EL_CONVEYOR_BELT_2_RIGHT,
3690 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
3692 EL_CONVEYOR_BELT_3_LEFT,
3693 EL_CONVEYOR_BELT_3_MIDDLE,
3694 EL_CONVEYOR_BELT_3_RIGHT,
3695 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
3697 EL_CONVEYOR_BELT_4_LEFT,
3698 EL_CONVEYOR_BELT_4_MIDDLE,
3699 EL_CONVEYOR_BELT_4_RIGHT,
3700 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
3702 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
3703 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
3704 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
3705 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
3707 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
3708 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
3709 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
3710 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
3715 EL_DC_TIMEGATE_SWITCH,
3717 EL_SWITCHGATE_CLOSED,
3719 EL_SWITCHGATE_SWITCH_UP,
3720 EL_SWITCHGATE_SWITCH_DOWN,
3723 EL_LIGHT_SWITCH_ACTIVE,
3724 EL_DC_SWITCHGATE_SWITCH_UP,
3725 EL_DC_SWITCHGATE_SWITCH_DOWN,
3727 EL_STEEL_EXIT_CLOSED,
3729 EL_STEELWALL_SLIPPERY,
3732 EL_QUICKSAND_FAST_EMPTY,
3733 EL_QUICKSAND_FAST_FULL,
3747 EL_SIGN_RADIOACTIVITY,
3753 EL_SIGN_ENTRY_FORBIDDEN,
3754 EL_SIGN_EMERGENCY_EXIT,
3779 EL_DC_STEELWALL_2_SINGLE,
3780 EL_DC_STEELWALL_2_TOP,
3781 EL_SIGN_EXCLAMATION,
3784 EL_DC_STEELWALL_2_LEFT,
3785 EL_DC_STEELWALL_2_MIDDLE,
3786 EL_DC_STEELWALL_2_HORIZONTAL,
3787 EL_DC_STEELWALL_2_RIGHT,
3789 EL_DC_STEELWALL_1_TOPLEFT,
3790 EL_DC_STEELWALL_2_VERTICAL,
3791 EL_DC_STEELWALL_1_TOPRIGHT,
3794 EL_DC_STEELWALL_1_VERTICAL,
3795 EL_DC_STEELWALL_2_BOTTOM,
3797 EL_DC_GATE_WHITE_GRAY,
3799 EL_DC_STEELWALL_1_BOTTOMLEFT,
3800 EL_DC_STEELWALL_1_HORIZONTAL,
3801 EL_DC_STEELWALL_1_BOTTOMRIGHT,
3802 EL_DC_GATE_FAKE_GRAY,
3804 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
3805 EL_DC_STEELWALL_1_BOTTOM,
3806 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
3807 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
3809 EL_DC_STEELWALL_1_RIGHT,
3811 EL_DC_STEELWALL_1_LEFT,
3812 EL_EXPANDABLE_STEELWALL_VERTICAL,
3814 EL_DC_STEELWALL_1_TOPRIGHT_2,
3815 EL_DC_STEELWALL_1_TOP,
3816 EL_DC_STEELWALL_1_TOPLEFT_2,
3817 EL_EXPANDABLE_STEELWALL_ANY,
3819 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
3820 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
3821 static int num_editor_hl_diamond_caves = SIZEOF_ARRAY_INT(editor_hl_diamond_caves);
3822 static int num_editor_el_diamond_caves = SIZEOF_ARRAY_INT(editor_el_diamond_caves);
3824 static int editor_hl_dx_boulderdash[] =
3826 EL_INTERNAL_CASCADE_DX_ACTIVE,
3832 static int editor_el_dx_boulderdash[] =
3836 EL_TUBE_HORIZONTAL_DOWN,
3840 EL_TUBE_VERTICAL_RIGHT,
3842 EL_TUBE_VERTICAL_LEFT,
3846 EL_TUBE_HORIZONTAL_UP,
3854 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
3855 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
3856 static int num_editor_hl_dx_boulderdash = SIZEOF_ARRAY_INT(editor_hl_dx_boulderdash);
3857 static int num_editor_el_dx_boulderdash = SIZEOF_ARRAY_INT(editor_el_dx_boulderdash);
3859 static int editor_hl_chars[] =
3861 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
3867 static int editor_el_chars[] =
3956 EL_CHAR(FONT_ASCII_CURSOR),
3957 EL_CHAR(FONT_ASCII_BUTTON),
3959 EL_CHAR(FONT_ASCII_UP),
3960 EL_CHAR(FONT_ASCII_DOWN),
3964 static int *editor_hl_chars_ptr = editor_hl_chars;
3965 static int *editor_el_chars_ptr = editor_el_chars;
3966 static int num_editor_hl_chars = SIZEOF_ARRAY_INT(editor_hl_chars);
3967 static int num_editor_el_chars = SIZEOF_ARRAY_INT(editor_el_chars);
3969 static int editor_hl_steel_chars[] =
3971 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
3977 static int editor_el_steel_chars[] =
3987 EL_STEEL_CHAR('\''),
4054 EL_STEEL_CHAR('\\'),
4059 EL_STEEL_CHAR('©'),
4060 EL_STEEL_CHAR('Ä'),
4061 EL_STEEL_CHAR('Ö'),
4062 EL_STEEL_CHAR('Ü'),
4064 EL_STEEL_CHAR('°'),
4065 EL_STEEL_CHAR('®'),
4066 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
4067 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
4069 EL_STEEL_CHAR(FONT_ASCII_UP),
4070 EL_STEEL_CHAR(FONT_ASCII_DOWN),
4074 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
4075 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
4076 static int num_editor_hl_steel_chars = SIZEOF_ARRAY_INT(editor_hl_steel_chars);
4077 static int num_editor_el_steel_chars = SIZEOF_ARRAY_INT(editor_el_steel_chars);
4079 static int editor_hl_custom[] =
4081 EL_INTERNAL_CASCADE_CE_ACTIVE,
4087 static int editor_el_custom[] =
4089 EL_CUSTOM_START + 0,
4090 EL_CUSTOM_START + 1,
4091 EL_CUSTOM_START + 2,
4092 EL_CUSTOM_START + 3,
4094 EL_CUSTOM_START + 4,
4095 EL_CUSTOM_START + 5,
4096 EL_CUSTOM_START + 6,
4097 EL_CUSTOM_START + 7,
4099 EL_CUSTOM_START + 8,
4100 EL_CUSTOM_START + 9,
4101 EL_CUSTOM_START + 10,
4102 EL_CUSTOM_START + 11,
4104 EL_CUSTOM_START + 12,
4105 EL_CUSTOM_START + 13,
4106 EL_CUSTOM_START + 14,
4107 EL_CUSTOM_START + 15,
4109 EL_CUSTOM_START + 16,
4110 EL_CUSTOM_START + 17,
4111 EL_CUSTOM_START + 18,
4112 EL_CUSTOM_START + 19,
4114 EL_CUSTOM_START + 20,
4115 EL_CUSTOM_START + 21,
4116 EL_CUSTOM_START + 22,
4117 EL_CUSTOM_START + 23,
4119 EL_CUSTOM_START + 24,
4120 EL_CUSTOM_START + 25,
4121 EL_CUSTOM_START + 26,
4122 EL_CUSTOM_START + 27,
4124 EL_CUSTOM_START + 28,
4125 EL_CUSTOM_START + 29,
4126 EL_CUSTOM_START + 30,
4127 EL_CUSTOM_START + 31,
4129 EL_CUSTOM_START + 32,
4130 EL_CUSTOM_START + 33,
4131 EL_CUSTOM_START + 34,
4132 EL_CUSTOM_START + 35,
4134 EL_CUSTOM_START + 36,
4135 EL_CUSTOM_START + 37,
4136 EL_CUSTOM_START + 38,
4137 EL_CUSTOM_START + 39,
4139 EL_CUSTOM_START + 40,
4140 EL_CUSTOM_START + 41,
4141 EL_CUSTOM_START + 42,
4142 EL_CUSTOM_START + 43,
4144 EL_CUSTOM_START + 44,
4145 EL_CUSTOM_START + 45,
4146 EL_CUSTOM_START + 46,
4147 EL_CUSTOM_START + 47,
4149 EL_CUSTOM_START + 48,
4150 EL_CUSTOM_START + 49,
4151 EL_CUSTOM_START + 50,
4152 EL_CUSTOM_START + 51,
4154 EL_CUSTOM_START + 52,
4155 EL_CUSTOM_START + 53,
4156 EL_CUSTOM_START + 54,
4157 EL_CUSTOM_START + 55,
4159 EL_CUSTOM_START + 56,
4160 EL_CUSTOM_START + 57,
4161 EL_CUSTOM_START + 58,
4162 EL_CUSTOM_START + 59,
4164 EL_CUSTOM_START + 60,
4165 EL_CUSTOM_START + 61,
4166 EL_CUSTOM_START + 62,
4167 EL_CUSTOM_START + 63,
4169 EL_CUSTOM_START + 64,
4170 EL_CUSTOM_START + 65,
4171 EL_CUSTOM_START + 66,
4172 EL_CUSTOM_START + 67,
4174 EL_CUSTOM_START + 68,
4175 EL_CUSTOM_START + 69,
4176 EL_CUSTOM_START + 70,
4177 EL_CUSTOM_START + 71,
4179 EL_CUSTOM_START + 72,
4180 EL_CUSTOM_START + 73,
4181 EL_CUSTOM_START + 74,
4182 EL_CUSTOM_START + 75,
4184 EL_CUSTOM_START + 76,
4185 EL_CUSTOM_START + 77,
4186 EL_CUSTOM_START + 78,
4187 EL_CUSTOM_START + 79,
4189 EL_CUSTOM_START + 80,
4190 EL_CUSTOM_START + 81,
4191 EL_CUSTOM_START + 82,
4192 EL_CUSTOM_START + 83,
4194 EL_CUSTOM_START + 84,
4195 EL_CUSTOM_START + 85,
4196 EL_CUSTOM_START + 86,
4197 EL_CUSTOM_START + 87,
4199 EL_CUSTOM_START + 88,
4200 EL_CUSTOM_START + 89,
4201 EL_CUSTOM_START + 90,
4202 EL_CUSTOM_START + 91,
4204 EL_CUSTOM_START + 92,
4205 EL_CUSTOM_START + 93,
4206 EL_CUSTOM_START + 94,
4207 EL_CUSTOM_START + 95,
4209 EL_CUSTOM_START + 96,
4210 EL_CUSTOM_START + 97,
4211 EL_CUSTOM_START + 98,
4212 EL_CUSTOM_START + 99,
4214 EL_CUSTOM_START + 100,
4215 EL_CUSTOM_START + 101,
4216 EL_CUSTOM_START + 102,
4217 EL_CUSTOM_START + 103,
4219 EL_CUSTOM_START + 104,
4220 EL_CUSTOM_START + 105,
4221 EL_CUSTOM_START + 106,
4222 EL_CUSTOM_START + 107,
4224 EL_CUSTOM_START + 108,
4225 EL_CUSTOM_START + 109,
4226 EL_CUSTOM_START + 110,
4227 EL_CUSTOM_START + 111,
4229 EL_CUSTOM_START + 112,
4230 EL_CUSTOM_START + 113,
4231 EL_CUSTOM_START + 114,
4232 EL_CUSTOM_START + 115,
4234 EL_CUSTOM_START + 116,
4235 EL_CUSTOM_START + 117,
4236 EL_CUSTOM_START + 118,
4237 EL_CUSTOM_START + 119,
4239 EL_CUSTOM_START + 120,
4240 EL_CUSTOM_START + 121,
4241 EL_CUSTOM_START + 122,
4242 EL_CUSTOM_START + 123,
4244 EL_CUSTOM_START + 124,
4245 EL_CUSTOM_START + 125,
4246 EL_CUSTOM_START + 126,
4247 EL_CUSTOM_START + 127,
4249 EL_CUSTOM_START + 128,
4250 EL_CUSTOM_START + 129,
4251 EL_CUSTOM_START + 130,
4252 EL_CUSTOM_START + 131,
4254 EL_CUSTOM_START + 132,
4255 EL_CUSTOM_START + 133,
4256 EL_CUSTOM_START + 134,
4257 EL_CUSTOM_START + 135,
4259 EL_CUSTOM_START + 136,
4260 EL_CUSTOM_START + 137,
4261 EL_CUSTOM_START + 138,
4262 EL_CUSTOM_START + 139,
4264 EL_CUSTOM_START + 140,
4265 EL_CUSTOM_START + 141,
4266 EL_CUSTOM_START + 142,
4267 EL_CUSTOM_START + 143,
4269 EL_CUSTOM_START + 144,
4270 EL_CUSTOM_START + 145,
4271 EL_CUSTOM_START + 146,
4272 EL_CUSTOM_START + 147,
4274 EL_CUSTOM_START + 148,
4275 EL_CUSTOM_START + 149,
4276 EL_CUSTOM_START + 150,
4277 EL_CUSTOM_START + 151,
4279 EL_CUSTOM_START + 152,
4280 EL_CUSTOM_START + 153,
4281 EL_CUSTOM_START + 154,
4282 EL_CUSTOM_START + 155,
4284 EL_CUSTOM_START + 156,
4285 EL_CUSTOM_START + 157,
4286 EL_CUSTOM_START + 158,
4287 EL_CUSTOM_START + 159,
4289 EL_CUSTOM_START + 160,
4290 EL_CUSTOM_START + 161,
4291 EL_CUSTOM_START + 162,
4292 EL_CUSTOM_START + 163,
4294 EL_CUSTOM_START + 164,
4295 EL_CUSTOM_START + 165,
4296 EL_CUSTOM_START + 166,
4297 EL_CUSTOM_START + 167,
4299 EL_CUSTOM_START + 168,
4300 EL_CUSTOM_START + 169,
4301 EL_CUSTOM_START + 170,
4302 EL_CUSTOM_START + 171,
4304 EL_CUSTOM_START + 172,
4305 EL_CUSTOM_START + 173,
4306 EL_CUSTOM_START + 174,
4307 EL_CUSTOM_START + 175,
4309 EL_CUSTOM_START + 176,
4310 EL_CUSTOM_START + 177,
4311 EL_CUSTOM_START + 178,
4312 EL_CUSTOM_START + 179,
4314 EL_CUSTOM_START + 180,
4315 EL_CUSTOM_START + 181,
4316 EL_CUSTOM_START + 182,
4317 EL_CUSTOM_START + 183,
4319 EL_CUSTOM_START + 184,
4320 EL_CUSTOM_START + 185,
4321 EL_CUSTOM_START + 186,
4322 EL_CUSTOM_START + 187,
4324 EL_CUSTOM_START + 188,
4325 EL_CUSTOM_START + 189,
4326 EL_CUSTOM_START + 190,
4327 EL_CUSTOM_START + 191,
4329 EL_CUSTOM_START + 192,
4330 EL_CUSTOM_START + 193,
4331 EL_CUSTOM_START + 194,
4332 EL_CUSTOM_START + 195,
4334 EL_CUSTOM_START + 196,
4335 EL_CUSTOM_START + 197,
4336 EL_CUSTOM_START + 198,
4337 EL_CUSTOM_START + 199,
4339 EL_CUSTOM_START + 200,
4340 EL_CUSTOM_START + 201,
4341 EL_CUSTOM_START + 202,
4342 EL_CUSTOM_START + 203,
4344 EL_CUSTOM_START + 204,
4345 EL_CUSTOM_START + 205,
4346 EL_CUSTOM_START + 206,
4347 EL_CUSTOM_START + 207,
4349 EL_CUSTOM_START + 208,
4350 EL_CUSTOM_START + 209,
4351 EL_CUSTOM_START + 210,
4352 EL_CUSTOM_START + 211,
4354 EL_CUSTOM_START + 212,
4355 EL_CUSTOM_START + 213,
4356 EL_CUSTOM_START + 214,
4357 EL_CUSTOM_START + 215,
4359 EL_CUSTOM_START + 216,
4360 EL_CUSTOM_START + 217,
4361 EL_CUSTOM_START + 218,
4362 EL_CUSTOM_START + 219,
4364 EL_CUSTOM_START + 220,
4365 EL_CUSTOM_START + 221,
4366 EL_CUSTOM_START + 222,
4367 EL_CUSTOM_START + 223,
4369 EL_CUSTOM_START + 224,
4370 EL_CUSTOM_START + 225,
4371 EL_CUSTOM_START + 226,
4372 EL_CUSTOM_START + 227,
4374 EL_CUSTOM_START + 228,
4375 EL_CUSTOM_START + 229,
4376 EL_CUSTOM_START + 230,
4377 EL_CUSTOM_START + 231,
4379 EL_CUSTOM_START + 232,
4380 EL_CUSTOM_START + 233,
4381 EL_CUSTOM_START + 234,
4382 EL_CUSTOM_START + 235,
4384 EL_CUSTOM_START + 236,
4385 EL_CUSTOM_START + 237,
4386 EL_CUSTOM_START + 238,
4387 EL_CUSTOM_START + 239,
4389 EL_CUSTOM_START + 240,
4390 EL_CUSTOM_START + 241,
4391 EL_CUSTOM_START + 242,
4392 EL_CUSTOM_START + 243,
4394 EL_CUSTOM_START + 244,
4395 EL_CUSTOM_START + 245,
4396 EL_CUSTOM_START + 246,
4397 EL_CUSTOM_START + 247,
4399 EL_CUSTOM_START + 248,
4400 EL_CUSTOM_START + 249,
4401 EL_CUSTOM_START + 250,
4402 EL_CUSTOM_START + 251,
4404 EL_CUSTOM_START + 252,
4405 EL_CUSTOM_START + 253,
4406 EL_CUSTOM_START + 254,
4407 EL_CUSTOM_START + 255
4409 static int *editor_hl_custom_ptr = editor_hl_custom;
4410 static int *editor_el_custom_ptr = editor_el_custom;
4411 static int num_editor_hl_custom = SIZEOF_ARRAY_INT(editor_hl_custom);
4412 static int num_editor_el_custom = SIZEOF_ARRAY_INT(editor_el_custom);
4414 static int editor_hl_group[] =
4416 EL_INTERNAL_CASCADE_GE_ACTIVE,
4422 static int editor_el_group[] =
4436 EL_GROUP_START + 10,
4437 EL_GROUP_START + 11,
4439 EL_GROUP_START + 12,
4440 EL_GROUP_START + 13,
4441 EL_GROUP_START + 14,
4442 EL_GROUP_START + 15,
4444 EL_GROUP_START + 16,
4445 EL_GROUP_START + 17,
4446 EL_GROUP_START + 18,
4447 EL_GROUP_START + 19,
4449 EL_GROUP_START + 20,
4450 EL_GROUP_START + 21,
4451 EL_GROUP_START + 22,
4452 EL_GROUP_START + 23,
4454 EL_GROUP_START + 24,
4455 EL_GROUP_START + 25,
4456 EL_GROUP_START + 26,
4457 EL_GROUP_START + 27,
4459 EL_GROUP_START + 28,
4460 EL_GROUP_START + 29,
4461 EL_GROUP_START + 30,
4464 static int *editor_hl_group_ptr = editor_hl_group;
4465 static int *editor_el_group_ptr = editor_el_group;
4466 static int num_editor_hl_group = SIZEOF_ARRAY_INT(editor_hl_group);
4467 static int num_editor_el_group = SIZEOF_ARRAY_INT(editor_el_group);
4469 static int editor_hl_reference[] =
4471 EL_INTERNAL_CASCADE_REF_ACTIVE,
4477 static int editor_el_reference[] =
4481 EL_TRIGGER_CE_VALUE,
4482 EL_TRIGGER_CE_SCORE,
4486 EL_CURRENT_CE_VALUE,
4487 EL_CURRENT_CE_SCORE,
4509 static int *editor_hl_reference_ptr = editor_hl_reference;
4510 static int *editor_el_reference_ptr = editor_el_reference;
4511 static int num_editor_hl_reference = SIZEOF_ARRAY_INT(editor_hl_reference);
4512 static int num_editor_el_reference = SIZEOF_ARRAY_INT(editor_el_reference);
4514 static int editor_hl_user_defined[] =
4516 EL_INTERNAL_CASCADE_USER_ACTIVE,
4522 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
4523 static int *editor_el_user_defined_ptr = NULL;
4524 static int num_editor_hl_user_defined=SIZEOF_ARRAY_INT(editor_hl_user_defined);
4525 static int num_editor_el_user_defined = 0;
4527 static int editor_hl_dynamic[] =
4529 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
4535 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
4536 static int *editor_el_dynamic_ptr = NULL;
4537 static int num_editor_hl_dynamic = SIZEOF_ARRAY_INT(editor_hl_dynamic);
4538 static int num_editor_el_dynamic = 0;
4540 static int editor_hl_empty[] = { };
4541 static int editor_el_empty[ED_NUM_ELEMENTLIST_BUTTONS];
4543 static int *editor_hl_empty_ptr = editor_hl_empty;
4544 static int *editor_el_empty_ptr = editor_el_empty;
4545 static int num_editor_hl_empty = 0;
4546 static int num_editor_el_empty = 0; /* dynamically determined, if needed */
4548 static boolean use_el_empty = FALSE;
4550 static int *editor_elements = NULL; /* dynamically allocated */
4551 static int num_editor_elements = 0; /* dynamically determined */
4553 static boolean setup_editor_show_always = TRUE;
4554 static boolean setup_editor_cascade_never = FALSE;
4556 static int editor_hl_unused[] = { EL_EMPTY };
4557 static int *editor_hl_unused_ptr = editor_hl_unused;
4558 static int num_editor_hl_unused = 0;
4562 boolean *setup_value;
4563 boolean *setup_cascade_value;
4565 int **headline_list;
4566 int *headline_list_size;
4569 int *element_list_size;
4571 boolean last_setup_value;
4573 editor_elements_info[] =
4576 &setup_editor_show_always,
4577 &setup_editor_cascade_never,
4578 &editor_hl_unused_ptr, &num_editor_hl_unused,
4579 &editor_el_players_ptr, &num_editor_el_players
4582 &setup.editor.el_boulderdash,
4583 &setup.editor_cascade.el_bd,
4584 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
4585 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
4588 &setup.editor.el_emerald_mine,
4589 &setup.editor_cascade.el_em,
4590 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
4591 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
4594 &setup.editor.el_emerald_mine_club,
4595 &setup.editor_cascade.el_emc,
4596 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
4597 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
4600 &setup.editor.el_more,
4601 &setup.editor_cascade.el_rnd,
4602 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
4603 &editor_el_rnd_ptr, &num_editor_el_rnd
4606 &setup.editor.el_sokoban,
4607 &setup.editor_cascade.el_sb,
4608 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
4609 &editor_el_sokoban_ptr, &num_editor_el_sokoban
4612 &setup.editor.el_supaplex,
4613 &setup.editor_cascade.el_sp,
4614 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
4615 &editor_el_supaplex_ptr, &num_editor_el_supaplex
4618 &setup.editor.el_diamond_caves,
4619 &setup.editor_cascade.el_dc,
4620 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
4621 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
4624 &setup.editor.el_dx_boulderdash,
4625 &setup.editor_cascade.el_dx,
4626 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
4627 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
4630 &setup.editor.el_chars,
4631 &setup.editor_cascade.el_chars,
4632 &editor_hl_chars_ptr, &num_editor_hl_chars,
4633 &editor_el_chars_ptr, &num_editor_el_chars
4636 &setup.editor.el_steel_chars,
4637 &setup.editor_cascade.el_steel_chars,
4638 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
4639 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
4642 &setup.editor.el_custom,
4643 &setup.editor_cascade.el_ce,
4644 &editor_hl_custom_ptr, &num_editor_hl_custom,
4645 &editor_el_custom_ptr, &num_editor_el_custom
4648 &setup.editor.el_custom,
4649 &setup.editor_cascade.el_ge,
4650 &editor_hl_group_ptr, &num_editor_hl_group,
4651 &editor_el_group_ptr, &num_editor_el_group
4654 &setup.editor.el_custom,
4655 &setup.editor_cascade.el_ref,
4656 &editor_hl_reference_ptr, &num_editor_hl_reference,
4657 &editor_el_reference_ptr, &num_editor_el_reference
4660 &setup.editor.el_user_defined,
4661 &setup.editor_cascade.el_user,
4662 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
4663 &editor_el_user_defined_ptr, &num_editor_el_user_defined
4666 &setup.editor.el_dynamic,
4667 &setup.editor_cascade.el_dynamic,
4668 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
4669 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
4674 &editor_hl_empty_ptr, &num_editor_hl_empty,
4675 &editor_el_empty_ptr, &num_editor_el_empty,
4687 -----------------------------------------------------------------------------
4689 -----------------------------------------------------------------------------
4692 static int getMaxInfoTextLength()
4694 return (SXSIZE / getFontWidth(FONT_TEXT_2));
4697 static int getTextWidthForGadget(char *text)
4702 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
4705 static int getTextWidthForDrawingArea(char *text)
4710 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
4713 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
4715 return (gi->x + gi->width + getTextWidthForGadget(text));
4718 static char *getElementInfoText(int element)
4720 char *info_text = NULL;
4722 if (element < MAX_NUM_ELEMENTS)
4724 if (strlen(element_info[element].description) > 0)
4725 info_text = element_info[element].description;
4726 else if (element_info[element].custom_description != NULL)
4727 info_text = element_info[element].custom_description;
4728 else if (element_info[element].editor_description != NULL)
4729 info_text = element_info[element].editor_description;
4732 if (info_text == NULL)
4733 info_text = INFOTEXT_UNKNOWN_ELEMENT;
4738 char *getElementDescriptionFilename(int element)
4740 char *docs_dir = options.docs_directory;
4741 char *elements_subdir = "elements";
4742 static char *filename = NULL;
4743 char basename[MAX_FILENAME_LEN];
4745 checked_free(filename);
4747 /* 1st try: look for element description file for exactly this element */
4748 sprintf(basename, "%s.txt", element_info[element].token_name);
4749 filename = getPath3(docs_dir, elements_subdir, basename);
4750 if (fileExists(filename))
4755 /* 2nd try: look for element description file for this element's class */
4756 sprintf(basename, "%s.txt", element_info[element].class_name);
4757 filename = getPath3(docs_dir, elements_subdir, basename);
4758 if (fileExists(filename))
4764 static void InitDynamicEditorElementList(int **elements, int *num_elements)
4766 boolean element_found[NUM_FILE_ELEMENTS];
4769 /* initialize list of used elements to "not used" */
4770 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
4771 element_found[i] = FALSE;
4773 /* find all elements used in current level */
4774 for (y = 0; y < lev_fieldy; y++)
4775 for (x = 0; x < lev_fieldx; x++)
4776 if (Feld[x][y] < NUM_FILE_ELEMENTS) /* should always be true */
4777 element_found[Feld[x][y]] = TRUE;
4781 /* count number of elements used in current level */
4782 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
4783 if (element_found[i])
4786 /* add space for up to 3 more elements for padding that may be needed */
4789 /* free memory for old list of elements, if needed */
4790 checked_free(*elements);
4792 /* allocate memory for new list of elements */
4793 *elements = checked_malloc(*num_elements * sizeof(int));
4797 /* add all elements used in current level (non-custom/group elements) */
4798 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
4799 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
4800 (*elements)[(*num_elements)++] = i;
4802 /* add all elements used in current level (custom/group elements) */
4803 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
4804 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
4805 (*elements)[(*num_elements)++] = i;
4807 while (*num_elements % 4) /* pad with empty elements, if needed */
4808 (*elements)[(*num_elements)++] = EL_EMPTY;
4811 static void ReinitializeElementList()
4813 static boolean initialization_needed = TRUE;
4817 if (initialization_needed)
4819 LoadSetup_EditorCascade(); /* load last editor cascade state */
4821 /* initialize editor cascade element from saved cascade state */
4822 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4824 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
4825 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
4827 if (IS_EDITOR_CASCADE(*cascade_element))
4829 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
4830 EL_CASCADE_INACTIVE(*cascade_element));
4833 initialization_needed = FALSE;
4836 checked_free(editor_elements);
4838 /* reload optional user defined element list for each invocation of editor */
4839 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
4840 &num_editor_el_user_defined);
4842 /* initialize dynamic level element list for each invocation of editor */
4843 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
4844 &num_editor_el_dynamic);
4846 /* initialize list of empty elements (used for padding, if needed) */
4847 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
4848 editor_el_empty[i] = EL_EMPTY;
4850 /* do some sanity checks for each element from element list */
4851 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4853 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
4855 int element = (*editor_elements_info[i].element_list)[j];
4857 if (element >= NUM_FILE_ELEMENTS)
4858 Error(ERR_WARN, "editor element %d is runtime element", element);
4860 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
4861 Error(ERR_WARN, "no element description for element %d", element);
4865 num_editor_elements = 0;
4866 use_el_empty = FALSE;
4868 /* determine size of element list */
4869 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4871 boolean found_inactive_cascade = FALSE;
4873 if (*editor_elements_info[i].setup_value)
4875 if (setup.editor.el_headlines)
4877 num_editor_elements += *editor_elements_info[i].headline_list_size;
4879 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
4881 int element = (*editor_elements_info[i].headline_list)[j];
4883 if (IS_EDITOR_CASCADE_INACTIVE(element))
4884 found_inactive_cascade = TRUE;
4888 if (found_inactive_cascade)
4891 num_editor_elements += *editor_elements_info[i].element_list_size;
4895 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
4897 /* offer at least as many elements as element buttons exist */
4898 use_el_empty = TRUE;
4899 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
4901 num_editor_elements += num_editor_el_empty;
4904 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
4906 /* fill element list */
4907 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4909 boolean found_inactive_cascade = FALSE;
4911 if (*editor_elements_info[i].setup_value)
4913 if (setup.editor.el_headlines)
4915 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
4917 int element = (*editor_elements_info[i].headline_list)[j];
4919 editor_elements[pos++] = element;
4921 if (IS_EDITOR_CASCADE_INACTIVE(element))
4922 found_inactive_cascade = TRUE;
4926 if (found_inactive_cascade)
4929 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
4930 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
4934 /* (this function is also called before editor gadgets are initialized!) */
4935 AdjustElementListScrollbar();
4938 void PrintEditorElementList()
4940 boolean *stop = &setup.editor.el_user_defined;
4943 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
4945 int cascade_element = (*editor_elements_info[i].headline_list)[0];
4947 if (IS_EDITOR_CASCADE(cascade_element))
4949 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
4950 char *headline = element_info[cascade_element_show].editor_description;
4952 printf_line_with_prefix("# ", "-", 77);
4953 printf("# %s\n", headline);
4954 printf_line_with_prefix("# ", "-", 77);
4957 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
4959 int element = (*editor_elements_info[i].headline_list)[j];
4961 if (IS_EDITOR_CASCADE(element))
4962 element = EL_CHAR_MINUS;
4964 printf("# %s\n", element_info[element].token_name);
4970 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
4972 int element = (*editor_elements_info[i].element_list)[j];
4974 printf("# %s\n", element_info[element].token_name);
4982 static void ReinitializeElementListButtons()
4984 static boolean last_setup_value_headlines = FALSE;
4985 static boolean initialization_needed = TRUE;
4988 if (!initialization_needed) /* check if editor element setup has changed */
4990 if (last_setup_value_headlines != setup.editor.el_headlines)
4991 initialization_needed = TRUE;
4993 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4994 if (editor_elements_info[i].last_setup_value !=
4995 *editor_elements_info[i].setup_value)
4996 initialization_needed = TRUE;
4999 if (!initialization_needed)
5002 FreeLevelEditorGadgets();
5003 CreateLevelEditorGadgets();
5005 /* store current setup values for next invocation of this function */
5006 last_setup_value_headlines = setup.editor.el_headlines;
5007 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5008 editor_elements_info[i].last_setup_value =
5009 *editor_elements_info[i].setup_value;
5011 initialization_needed = FALSE;
5014 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
5017 int border_graphic =
5018 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
5021 int bx = (input ? 4 : 8);
5022 int by = (input ? 4 : 8);
5023 int bx2 = TILEX - bx;
5024 int by2 = TILEY - by;
5027 getGraphicSource(border_graphic, 0, &src_bitmap, &src_x, &src_y);
5029 BlitBitmap(src_bitmap, drawto, src_x, src_y,
5030 bx, by, dest_x - bx, dest_y - by);
5031 BlitBitmap(src_bitmap, drawto, src_x + bx2, src_y,
5032 bx, by, dest_x + width, dest_y - by);
5033 BlitBitmap(src_bitmap, drawto, src_x, src_y + by2,
5034 bx, by, dest_x - bx, dest_y + height);
5035 BlitBitmap(src_bitmap, drawto, src_x + bx2, src_y + by2,
5036 bx, by, dest_x + width, dest_y + height);
5038 for (i = 0; i < width / MINI_TILEX; i++)
5040 BlitBitmap(src_bitmap, drawto, src_x + bx, src_y, MINI_TILEX, by,
5041 dest_x + i * MINI_TILEX, dest_y - by);
5042 BlitBitmap(src_bitmap, drawto, src_x + bx, src_y + by2, MINI_TILEX, by,
5043 dest_x + i * MINI_TILEX, dest_y + height);
5046 for (i = 0; i < height / MINI_TILEY; i++)
5048 BlitBitmap(src_bitmap, drawto, src_x, src_y + by, bx, MINI_TILEY,
5049 dest_x - bx, dest_y + i * MINI_TILEY);
5050 BlitBitmap(src_bitmap, drawto, src_x + bx2, src_y + by, bx, MINI_TILEY,
5051 dest_x + width, dest_y + i * MINI_TILEY);
5054 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
5057 static void DrawDrawingArea(int id)
5059 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
5062 int *value = drawingarea_info[id].value;
5063 int area_xsize = drawingarea_info[id].area_xsize;
5064 int area_ysize = drawingarea_info[id].area_ysize;
5066 for (x = 0; x < area_xsize; x++)
5067 for (y = 0; y < area_ysize; y++)
5068 DrawMiniGraphicExt(drawto,
5069 gi->x + x * MINI_TILEX,
5070 gi->y + y * MINI_TILEY,
5071 el2edimg(value[x * area_ysize + y]));
5074 static void ScrollMiniLevel(int from_x, int from_y, int scroll)
5077 /* (directly solved in BlitBitmap() now) */
5078 static Bitmap *tmp_backbuffer = NULL;
5081 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
5082 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
5085 /* (directly solved in BlitBitmap() now) */
5086 if (tmp_backbuffer == NULL)
5087 tmp_backbuffer = CreateBitmap(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH);
5089 /* needed when blitting directly to same bitmap -- should not be needed with
5090 recent SDL libraries, but apparently does not work in 1.2.11 directly */
5091 BlitBitmap(drawto, tmp_backbuffer,
5092 SX + (dx == -1 ? MINI_TILEX : 0),
5093 SY + (dy == -1 ? MINI_TILEY : 0),
5094 (ed_fieldx * MINI_TILEX) - (dx != 0 ? MINI_TILEX : 0),
5095 (ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0),
5096 SX + (dx == +1 ? MINI_TILEX : 0),
5097 SY + (dy == +1 ? MINI_TILEY : 0));
5098 BlitBitmap(tmp_backbuffer, drawto,
5099 SX + (dx == +1 ? MINI_TILEX : 0),
5100 SY + (dy == +1 ? MINI_TILEY : 0),
5101 (ed_fieldx * MINI_TILEX) - (dx != 0 ? MINI_TILEX : 0),
5102 (ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0),
5103 SX + (dx == +1 ? MINI_TILEX : 0),
5104 SY + (dy == +1 ? MINI_TILEY : 0));
5108 BlitBitmap(drawto, drawto,
5109 SX + (dx == -1 ? MINI_TILEX : 0),
5110 SY + (dy == -1 ? MINI_TILEY : 0),
5111 (ed_fieldx * MINI_TILEX) - (dx != 0 ? MINI_TILEX : 0),
5112 (ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0),
5113 SX + (dx == +1 ? MINI_TILEX : 0),
5114 SY + (dy == +1 ? MINI_TILEY : 0));
5119 x = (dx == 1 ? 0 : ed_fieldx - 1);
5120 for (y = 0; y < ed_fieldy; y++)
5121 DrawMiniElementOrWall(x, y, from_x, from_y);
5125 y = (dy == 1 ? 0 : ed_fieldy - 1);
5126 for (x = 0; x < ed_fieldx; x++)
5127 DrawMiniElementOrWall(x, y, from_x, from_y);
5130 redraw_mask |= REDRAW_FIELD;
5134 static void CreateControlButtons()
5136 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5137 struct GadgetInfo *gi;
5138 unsigned long event_mask;
5141 /* create toolbox buttons */
5142 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
5146 int gd_xoffset, gd_yoffset;
5147 int gd_x1, gd_x2, gd_y1, gd_y2;
5149 int radio_button_nr;
5152 if (id == GADGET_ID_SINGLE_ITEMS ||
5153 id == GADGET_ID_CONNECTED_ITEMS ||
5154 id == GADGET_ID_LINE ||
5155 id == GADGET_ID_ARC ||
5156 id == GADGET_ID_TEXT ||
5157 id == GADGET_ID_RECTANGLE ||
5158 id == GADGET_ID_FILLED_BOX ||
5159 id == GADGET_ID_FLOOD_FILL ||
5160 id == GADGET_ID_GRAB_BRUSH ||
5161 id == GADGET_ID_PICK_ELEMENT ||
5162 id == GADGET_ID_CUSTOM_COPY_FROM ||
5163 id == GADGET_ID_CUSTOM_COPY_TO ||
5164 id == GADGET_ID_CUSTOM_EXCHANGE)
5166 button_type = GD_TYPE_RADIO_BUTTON;
5167 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
5168 checked = (id == drawing_function ? TRUE : FALSE);
5169 event_mask = GD_EVENT_PRESSED;
5173 button_type = GD_TYPE_NORMAL_BUTTON;
5174 radio_button_nr = RADIO_NR_NONE;
5177 if (id == GADGET_ID_WRAP_LEFT ||
5178 id == GADGET_ID_WRAP_RIGHT ||
5179 id == GADGET_ID_WRAP_UP ||
5180 id == GADGET_ID_WRAP_DOWN)
5181 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5183 event_mask = GD_EVENT_RELEASED;
5186 if (id < ED_NUM_CTRL1_BUTTONS)
5188 int x = i % ED_CTRL1_BUTTONS_HORIZ;
5189 int y = i / ED_CTRL1_BUTTONS_HORIZ;
5191 gd_xoffset = ED_CTRL1_BUTTONS_XPOS + x * ED_CTRL1_BUTTON_XSIZE;
5192 gd_yoffset = ED_CTRL1_BUTTONS_YPOS + y * ED_CTRL1_BUTTON_YSIZE;
5193 width = ED_CTRL1_BUTTON_XSIZE;
5194 height = ED_CTRL1_BUTTON_YSIZE;
5196 gd_x1 = DOOR_GFX_PAGEX8 + gd_xoffset;
5197 gd_x2 = DOOR_GFX_PAGEX7 + gd_xoffset;
5198 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL1_BUTTONS_GFX_YPOS + gd_yoffset;
5199 gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL1_BUTTONS_ALT_GFX_YPOS + gd_yoffset;
5201 else if (id < ED_NUM_CTRL1_2_BUTTONS)
5203 int x = (i - ED_NUM_CTRL1_BUTTONS) % ED_CTRL2_BUTTONS_HORIZ;
5204 int y = (i - ED_NUM_CTRL1_BUTTONS) / ED_CTRL2_BUTTONS_HORIZ;
5206 gd_xoffset = ED_CTRL2_BUTTONS_XPOS + x * ED_CTRL2_BUTTON_XSIZE;
5207 gd_yoffset = ED_CTRL2_BUTTONS_YPOS + y * ED_CTRL2_BUTTON_YSIZE;
5208 width = ED_CTRL2_BUTTON_XSIZE;
5209 height = ED_CTRL2_BUTTON_YSIZE;
5211 gd_x1 = DOOR_GFX_PAGEX8 + gd_xoffset;
5212 gd_x2 = DOOR_GFX_PAGEX7 + gd_xoffset;
5213 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL2_BUTTONS_GFX_YPOS + gd_yoffset;
5214 gd_y2 = 0; /* no alternative graphic for these buttons */
5216 else if (id < ED_NUM_CTRL1_3_BUTTONS)
5218 int x = (i - ED_NUM_CTRL1_2_BUTTONS) % ED_CTRL3_BUTTONS_HORIZ + 1;
5219 int y = (i - ED_NUM_CTRL1_2_BUTTONS) / ED_CTRL3_BUTTONS_HORIZ;
5221 gd_xoffset = ED_CTRL3_BUTTONS_XPOS + x * ED_CTRL3_BUTTON_XSIZE;
5222 gd_yoffset = ED_CTRL3_BUTTONS_YPOS + y * ED_CTRL3_BUTTON_YSIZE;
5223 width = ED_CTRL3_BUTTON_XSIZE;
5224 height = ED_CTRL3_BUTTON_YSIZE;
5226 gd_x1 = DOOR_GFX_PAGEX6 + gd_xoffset;
5227 gd_x2 = DOOR_GFX_PAGEX5 + gd_xoffset;
5228 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL3_BUTTONS_GFX_YPOS + gd_yoffset;
5229 gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL3_BUTTONS_ALT_GFX_YPOS + gd_yoffset;
5233 int x = (i - ED_NUM_CTRL1_3_BUTTONS) % ED_CTRL4_BUTTONS_HORIZ;
5234 int y = (i - ED_NUM_CTRL1_3_BUTTONS) / ED_CTRL4_BUTTONS_HORIZ + 3;
5236 gd_xoffset = ED_CTRL4_BUTTONS_XPOS + x * ED_CTRL4_BUTTON_XSIZE;
5237 gd_yoffset = ED_CTRL4_BUTTONS_YPOS + y * ED_CTRL4_BUTTON_YSIZE;
5238 width = ED_CTRL4_BUTTON_XSIZE;
5239 height = ED_CTRL4_BUTTON_YSIZE;
5241 gd_x1 = DOOR_GFX_PAGEX6 + ED_CTRL4_BUTTONS_GFX_XPOS + gd_xoffset;
5242 gd_x2 = DOOR_GFX_PAGEX5 + ED_CTRL4_BUTTONS_GFX_XPOS + gd_xoffset;
5243 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL4_BUTTONS_GFX_YPOS + gd_yoffset;
5244 gd_y2 = 0; /* no alternative graphic for these buttons */
5247 gi = CreateGadget(GDI_CUSTOM_ID, id,
5248 GDI_CUSTOM_TYPE_ID, i,
5249 GDI_INFO_TEXT, control_info[i].text,
5250 GDI_X, EX + gd_xoffset,
5251 GDI_Y, EY + gd_yoffset,
5254 GDI_TYPE, button_type,
5255 GDI_STATE, GD_BUTTON_UNPRESSED,
5256 GDI_RADIO_NR, radio_button_nr,
5257 GDI_CHECKED, checked,
5258 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5259 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y1,
5260 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2,
5261 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
5262 GDI_EVENT_MASK, event_mask,
5263 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5264 GDI_CALLBACK_ACTION, HandleControlButtons,
5268 Error(ERR_EXIT, "cannot create gadget");
5270 level_editor_gadget[id] = gi;
5273 /* create buttons for scrolling of drawing area and element list */
5274 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
5276 int id = scrollbutton_info[i].gadget_id;
5277 int x, y, width, height;
5278 int gd_x1, gd_x2, gd_y1, gd_y2;
5280 x = scrollbutton_info[i].x;
5281 y = scrollbutton_info[i].y;
5283 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5285 if (id == GADGET_ID_SCROLL_LIST_UP ||
5286 id == GADGET_ID_SCROLL_LIST_DOWN)
5290 width = ED_SCROLLBUTTON2_XSIZE;
5291 height = ED_SCROLLBUTTON2_YSIZE;
5292 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].gd_x;
5293 gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].gd_y;
5294 gd_x2 = gd_x1 - ED_SCROLLBUTTON2_XSIZE;
5301 width = ED_SCROLLBUTTON_XSIZE;
5302 height = ED_SCROLLBUTTON_YSIZE;
5303 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].gd_x;
5304 gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].gd_y;
5305 gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE;
5309 gi = CreateGadget(GDI_CUSTOM_ID, id,
5310 GDI_CUSTOM_TYPE_ID, i,
5311 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
5316 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
5317 GDI_STATE, GD_BUTTON_UNPRESSED,
5318 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5319 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
5320 GDI_EVENT_MASK, event_mask,
5321 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5322 GDI_CALLBACK_ACTION, HandleControlButtons,
5326 Error(ERR_EXIT, "cannot create gadget");
5328 level_editor_gadget[id] = gi;
5331 /* create buttons for element list */
5332 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
5334 Bitmap *deco_bitmap;
5335 int deco_x, deco_y, deco_xpos, deco_ypos;
5336 int gd_xoffset, gd_yoffset;
5337 int gd_x1, gd_x2, gd_y;
5338 int x = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
5339 int y = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
5340 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
5341 int element = editor_elements[i];
5343 event_mask = GD_EVENT_RELEASED;
5345 gd_xoffset = ED_ELEMENTLIST_XPOS + x * ED_ELEMENTLIST_XSIZE;
5346 gd_yoffset = ED_ELEMENTLIST_YPOS + y * ED_ELEMENTLIST_YSIZE;
5348 gd_x1 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS + ED_ELEMENTLIST_XSIZE;
5349 gd_x2 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS;
5350 gd_y = DOOR_GFX_PAGEY1 + ED_ELEMENTLIST_YPOS;
5352 getMiniGraphicSource(el2edimg(element), &deco_bitmap, &deco_x, &deco_y);
5353 deco_xpos = (ED_ELEMENTLIST_XSIZE - MINI_TILEX) / 2;
5354 deco_ypos = (ED_ELEMENTLIST_YSIZE - MINI_TILEY) / 2;
5356 gi = CreateGadget(GDI_CUSTOM_ID, id,
5357 GDI_CUSTOM_TYPE_ID, i,
5358 GDI_INFO_TEXT, getElementInfoText(element),
5359 GDI_X, DX + gd_xoffset,
5360 GDI_Y, DY + gd_yoffset,
5361 GDI_WIDTH, ED_ELEMENTLIST_XSIZE,
5362 GDI_HEIGHT, ED_ELEMENTLIST_YSIZE,
5363 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
5364 GDI_STATE, GD_BUTTON_UNPRESSED,
5365 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
5366 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
5367 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
5368 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
5369 GDI_DECORATION_SIZE, MINI_TILEX, MINI_TILEY,
5370 GDI_DECORATION_SHIFTING, 1, 1,
5371 GDI_EVENT_MASK, event_mask,
5372 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5373 GDI_CALLBACK_ACTION, HandleControlButtons,
5377 Error(ERR_EXIT, "cannot create gadget");
5379 level_editor_gadget[id] = gi;
5383 static void CreateCounterButtons()
5385 int max_infotext_len = getMaxInfoTextLength();
5388 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
5391 int x = SX + counterbutton_info[i].x; /* down count button */
5392 int y = SY + counterbutton_info[i].y;
5394 /* determine horizontal position to the right of specified gadget */
5395 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
5396 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
5397 ED_GADGET_TEXT_DISTANCE);
5399 /* determine horizontal offset for leading text */
5400 if (counterbutton_info[i].text_left != NULL)
5401 x += getTextWidthForGadget(counterbutton_info[i].text_left);
5403 for (j = 0; j < 2; j++)
5405 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5406 struct GadgetInfo *gi;
5408 counterbutton_info[i].gadget_id_down :
5409 counterbutton_info[i].gadget_id_up);
5411 int gd_x, gd_x1, gd_x2, gd_y;
5413 unsigned long event_mask;
5414 char infotext[max_infotext_len + 1];
5416 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5418 if (i == ED_COUNTER_ID_SELECT_LEVEL)
5421 ED_SCROLLBUTTON_ID_AREA_LEFT :
5422 ED_SCROLLBUTTON_ID_AREA_RIGHT);
5424 event_mask |= GD_EVENT_RELEASED;
5427 x += 2 * ED_GADGET_DISTANCE;
5428 y += ED_GADGET_DISTANCE;
5430 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[sid].gd_x;
5431 gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE;
5432 gd_y = DOOR_GFX_PAGEY1 + scrollbutton_info[sid].gd_y;
5433 x_size = ED_SCROLLBUTTON_XSIZE;
5434 y_size = ED_SCROLLBUTTON_YSIZE;
5438 gd_xoffset = (j == 0 ? ED_BUTTON_MINUS_XPOS : ED_BUTTON_PLUS_XPOS);
5439 gd_x1 = DOOR_GFX_PAGEX4 + gd_xoffset;
5440 gd_x2 = DOOR_GFX_PAGEX3 + gd_xoffset;
5441 gd_y = DOOR_GFX_PAGEY1 + ED_BUTTON_COUNT_YPOS;
5442 x_size = ED_BUTTON_COUNT_XSIZE;
5443 y_size = ED_BUTTON_COUNT_YSIZE;
5446 sprintf(infotext, "%s counter value by 1, 5 or 10",
5447 (j == 0 ? "decrease" : "increase"));
5449 gi = CreateGadget(GDI_CUSTOM_ID, id,
5450 GDI_CUSTOM_TYPE_ID, i,
5451 GDI_INFO_TEXT, infotext,
5456 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
5457 GDI_STATE, GD_BUTTON_UNPRESSED,
5458 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
5459 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
5460 GDI_EVENT_MASK, event_mask,
5461 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5462 GDI_CALLBACK_ACTION, HandleCounterButtons,
5466 Error(ERR_EXIT, "cannot create gadget");
5468 level_editor_gadget[id] = gi;
5469 right_gadget_border[id] =
5470 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
5472 x += gi->width + ED_GADGET_DISTANCE; /* text count button */
5476 int font_type = FONT_INPUT_1;
5477 int font_type_active = FONT_INPUT_1_ACTIVE;
5478 int gd_width = ED_WIN_COUNT_XSIZE;
5480 id = counterbutton_info[i].gadget_id_text;
5481 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
5483 if (i == ED_COUNTER_ID_SELECT_LEVEL)
5485 font_type = FONT_LEVEL_NUMBER;
5487 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
5489 font_type_active = FONT_LEVEL_NUMBER;
5491 x += 2 * ED_GADGET_DISTANCE;
5492 y -= ED_GADGET_DISTANCE;
5494 gd_x = DOOR_GFX_PAGEX6 + ED_WIN_COUNT2_XPOS;
5495 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT2_YPOS;
5496 gd_width = ED_WIN_COUNT2_XSIZE;
5500 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
5501 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
5504 gi = CreateGadget(GDI_CUSTOM_ID, id,
5505 GDI_CUSTOM_TYPE_ID, i,
5506 GDI_INFO_TEXT, "enter counter value",
5509 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
5510 GDI_NUMBER_VALUE, 0,
5511 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
5512 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
5513 GDI_TEXT_SIZE, 3, /* minimal counter text size */
5514 GDI_TEXT_FONT, font_type,
5515 GDI_TEXT_FONT_ACTIVE, font_type_active,
5516 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
5517 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
5518 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5519 GDI_DESIGN_WIDTH, gd_width,
5520 GDI_EVENT_MASK, event_mask,
5521 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5522 GDI_CALLBACK_ACTION, HandleCounterButtons,
5526 Error(ERR_EXIT, "cannot create gadget");
5528 level_editor_gadget[id] = gi;
5529 right_gadget_border[id] =
5530 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
5532 x += gi->width + ED_GADGET_DISTANCE; /* up count button */
5538 static void CreateDrawingAreas()
5542 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
5544 struct GadgetInfo *gi;
5545 unsigned long event_mask;
5546 int id = drawingarea_info[i].gadget_id;
5547 int x = SX + drawingarea_info[i].x;
5548 int y = SY + drawingarea_info[i].y;
5549 int area_xsize = drawingarea_info[i].area_xsize;
5550 int area_ysize = drawingarea_info[i].area_ysize;
5553 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
5554 GD_EVENT_OFF_BORDERS;
5556 /* determine horizontal position to the right of specified gadget */
5557 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
5558 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
5559 ED_DRAWINGAREA_TEXT_DISTANCE);
5561 /* determine horizontal offset for leading text */
5562 if (drawingarea_info[i].text_left != NULL)
5563 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
5565 gi = CreateGadget(GDI_CUSTOM_ID, id,
5566 GDI_CUSTOM_TYPE_ID, i,
5569 GDI_TYPE, GD_TYPE_DRAWING_AREA,
5570 GDI_AREA_SIZE, area_xsize, area_ysize,
5571 GDI_ITEM_SIZE, MINI_TILEX, MINI_TILEY,
5572 GDI_EVENT_MASK, event_mask,
5573 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
5574 GDI_CALLBACK_ACTION, HandleDrawingAreas,
5578 Error(ERR_EXIT, "cannot create gadget");
5580 level_editor_gadget[id] = gi;
5581 right_gadget_border[id] =
5582 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
5586 static void CreateTextInputGadgets()
5588 int max_infotext_len = getMaxInfoTextLength();
5591 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
5593 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5595 struct GadgetInfo *gi;
5596 unsigned long event_mask;
5597 char infotext[MAX_OUTPUT_LINESIZE + 1];
5598 int id = textinput_info[i].gadget_id;
5600 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
5602 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
5603 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
5605 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
5606 infotext[max_infotext_len] = '\0';
5608 gi = CreateGadget(GDI_CUSTOM_ID, id,
5609 GDI_CUSTOM_TYPE_ID, i,
5610 GDI_INFO_TEXT, infotext,
5611 GDI_X, SX + textinput_info[i].x,
5612 GDI_Y, SY + textinput_info[i].y,
5613 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
5614 GDI_TEXT_VALUE, textinput_info[i].value,
5615 GDI_TEXT_SIZE, textinput_info[i].size,
5616 GDI_TEXT_FONT, FONT_INPUT_1,
5617 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
5618 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
5619 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
5620 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5621 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
5622 GDI_EVENT_MASK, event_mask,
5623 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5624 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
5628 Error(ERR_EXIT, "cannot create gadget");
5630 level_editor_gadget[id] = gi;
5634 static void CreateTextAreaGadgets()
5636 int max_infotext_len = getMaxInfoTextLength();
5639 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
5641 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5643 struct GadgetInfo *gi;
5644 unsigned long event_mask;
5645 char infotext[MAX_OUTPUT_LINESIZE + 1];
5646 int id = textarea_info[i].gadget_id;
5647 int area_xsize = textarea_info[i].xsize;
5648 int area_ysize = textarea_info[i].ysize;
5650 event_mask = GD_EVENT_TEXT_LEAVING;
5652 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
5653 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
5655 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
5656 infotext[max_infotext_len] = '\0';
5658 gi = CreateGadget(GDI_CUSTOM_ID, id,
5659 GDI_CUSTOM_TYPE_ID, i,
5660 GDI_INFO_TEXT, infotext,
5661 GDI_X, SX + textarea_info[i].x,
5662 GDI_Y, SY + textarea_info[i].y,
5663 GDI_TYPE, GD_TYPE_TEXT_AREA,
5664 GDI_AREA_SIZE, area_xsize, area_ysize,
5665 GDI_TEXT_FONT, FONT_INPUT_1,
5666 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
5667 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
5668 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
5669 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5670 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
5671 GDI_EVENT_MASK, event_mask,
5672 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5673 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
5677 Error(ERR_EXIT, "cannot create gadget");
5679 level_editor_gadget[id] = gi;
5683 static void CreateSelectboxGadgets()
5685 int max_infotext_len = getMaxInfoTextLength();
5688 for (i = 0; i < ED_NUM_SELECTBOX; i++)
5690 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5692 struct GadgetInfo *gi;
5693 unsigned long event_mask;
5694 char infotext[MAX_OUTPUT_LINESIZE + 1];
5695 int id = selectbox_info[i].gadget_id;
5696 int x = SX + selectbox_info[i].x;
5697 int y = SY + selectbox_info[i].y;
5699 if (selectbox_info[i].size == -1) /* dynamically determine size */
5701 /* (we cannot use -1 for uninitialized values if we directly compare
5702 with results from strlen(), because the '<' and '>' operation will
5703 implicitely cast -1 to an unsigned integer value!) */
5704 selectbox_info[i].size = 0;
5706 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
5707 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
5708 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
5710 selectbox_info[i].size++; /* add one character empty space */
5713 event_mask = GD_EVENT_RELEASED |
5714 GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
5716 gd_x = DOOR_GFX_PAGEX4 + ED_SELECTBOX_XPOS;
5717 gd_y = DOOR_GFX_PAGEY1 + ED_SELECTBOX_YPOS;
5719 /* determine horizontal position to the right of specified gadget */
5720 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
5721 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
5722 ED_GADGET_TEXT_DISTANCE);
5724 /* determine horizontal offset for leading text */
5725 if (selectbox_info[i].text_left != NULL)
5726 x += getTextWidthForGadget(selectbox_info[i].text_left);
5728 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
5729 infotext[max_infotext_len] = '\0';
5731 gi = CreateGadget(GDI_CUSTOM_ID, id,
5732 GDI_CUSTOM_TYPE_ID, i,
5733 GDI_INFO_TEXT, infotext,
5736 GDI_TYPE, GD_TYPE_SELECTBOX,
5737 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
5738 GDI_TEXT_SIZE, selectbox_info[i].size,
5739 GDI_TEXT_FONT, FONT_INPUT_1,
5740 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
5741 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
5742 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
5743 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5744 GDI_BORDER_SIZE_SELECTBUTTON, ED_SELECTBOX_BUTTON_XSIZE,
5745 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
5746 GDI_EVENT_MASK, event_mask,
5747 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5748 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
5752 Error(ERR_EXIT, "cannot create gadget");
5754 level_editor_gadget[id] = gi;
5755 right_gadget_border[id] =
5756 getRightGadgetBorder(gi, selectbox_info[i].text_right);
5760 static void CreateTextbuttonGadgets()
5762 int max_infotext_len = getMaxInfoTextLength();
5765 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
5767 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5768 int gd_x1, gd_x2, gd_y1, gd_y2;
5769 struct GadgetInfo *gi;
5770 unsigned long event_mask;
5771 char infotext[MAX_OUTPUT_LINESIZE + 1];
5772 int id = textbutton_info[i].gadget_id;
5773 int x = SX + textbutton_info[i].x;
5774 int y = SY + textbutton_info[i].y;
5776 if (textbutton_info[i].size == -1) /* dynamically determine size */
5777 textbutton_info[i].size = strlen(textbutton_info[i].text);
5779 event_mask = GD_EVENT_RELEASED;
5781 if (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE)
5783 gd_x1 = DOOR_GFX_PAGEX4 + ED_TEXTBUTTON_TAB_XPOS;
5784 gd_x2 = DOOR_GFX_PAGEX3 + ED_TEXTBUTTON_TAB_XPOS;
5785 gd_y1 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_TAB_YPOS;
5786 gd_y2 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_TAB_INACTIVE_YPOS;
5790 gd_x1 = DOOR_GFX_PAGEX4 + ED_TEXTBUTTON_XPOS;
5791 gd_x2 = DOOR_GFX_PAGEX3 + ED_TEXTBUTTON_XPOS;
5792 gd_y1 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_YPOS;
5793 gd_y2 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_INACTIVE_YPOS;
5796 sprintf(infotext, "%s", textbutton_info[i].infotext);
5797 infotext[max_infotext_len] = '\0';
5799 /* determine horizontal position to the right of specified gadget */
5800 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
5801 x = (right_gadget_border[textbutton_info[i].gadget_id_align] +
5802 ED_GADGET_TEXT_DISTANCE);
5804 /* determine horizontal offset for leading text */
5805 if (textbutton_info[i].text_left != NULL)
5806 x += getTextWidthForGadget(textbutton_info[i].text_left);
5808 gi = CreateGadget(GDI_CUSTOM_ID, id,
5809 GDI_CUSTOM_TYPE_ID, i,
5810 GDI_INFO_TEXT, infotext,
5813 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
5814 GDI_TEXT_VALUE, textbutton_info[i].text,
5815 GDI_TEXT_SIZE, textbutton_info[i].size,
5816 GDI_TEXT_FONT, FONT_INPUT_2_ACTIVE,
5817 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2,
5818 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5819 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y1,
5820 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2,
5821 GDI_BORDER_SIZE, ED_BORDER_TEXT_XSIZE, ED_BORDER_SIZE,
5822 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
5823 GDI_DECORATION_SHIFTING, 1, 1,
5824 GDI_EVENT_MASK, event_mask,
5825 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5826 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
5830 Error(ERR_EXIT, "cannot create gadget");
5832 level_editor_gadget[id] = gi;
5833 right_gadget_border[id] =
5834 getRightGadgetBorder(gi, textbutton_info[i].text_right);
5838 static void CreateGraphicbuttonGadgets()
5840 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5841 struct GadgetInfo *gi;
5842 unsigned long event_mask;
5845 /* create buttons for scrolling of drawing area and element list */
5846 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
5848 int id = graphicbutton_info[i].gadget_id;
5849 int gd_x1, gd_x2, gd_y1, gd_y2;
5850 int x = SX + graphicbutton_info[i].x;
5851 int y = SY + graphicbutton_info[i].y;
5853 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5855 if (i <= ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
5857 gd_x1 = DOOR_GFX_PAGEX4 + graphicbutton_info[i].gd_x;
5858 gd_y1 = DOOR_GFX_PAGEY1 + graphicbutton_info[i].gd_y;
5859 gd_x2 = DOOR_GFX_PAGEX3 + graphicbutton_info[i].gd_x;
5862 else /* (i <= ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE) */
5864 gd_x1 = DOOR_GFX_PAGEX6 + graphicbutton_info[i].gd_x;
5865 gd_y1 = DOOR_GFX_PAGEY1 + graphicbutton_info[i].gd_y;
5866 gd_x2 = gd_x1 - ED_BUTTON_COUNT_XSIZE;
5870 /* determine horizontal position to the right of specified gadget */
5871 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
5872 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
5873 ED_GADGET_TEXT_DISTANCE);
5875 /* determine horizontal offset for leading text */
5876 if (graphicbutton_info[i].text_left != NULL)
5877 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
5879 gi = CreateGadget(GDI_CUSTOM_ID, id,
5880 GDI_CUSTOM_TYPE_ID, i,
5881 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
5884 GDI_WIDTH, graphicbutton_info[i].width,
5885 GDI_HEIGHT, graphicbutton_info[i].height,
5886 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
5887 GDI_STATE, GD_BUTTON_UNPRESSED,
5888 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5889 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
5890 GDI_EVENT_MASK, event_mask,
5891 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5892 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
5896 Error(ERR_EXIT, "cannot create gadget");
5898 level_editor_gadget[id] = gi;
5899 right_gadget_border[id] =
5900 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
5904 static void CreateScrollbarGadgets()
5908 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
5910 int id = scrollbar_info[i].gadget_id;
5911 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5912 int gd_x1, gd_x2, gd_y1, gd_y2;
5913 struct GadgetInfo *gi;
5914 int items_max, items_visible, item_position;
5915 unsigned long event_mask;
5917 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
5919 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
5920 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
5921 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
5923 else /* drawing area scrollbars */
5925 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
5927 items_max = MAX(lev_fieldx + 2, ed_fieldx);
5928 items_visible = ed_fieldx;
5933 items_max = MAX(lev_fieldy + 2, ed_fieldy);
5934 items_visible = ed_fieldy;
5939 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
5941 gd_x1 = DOOR_GFX_PAGEX8 + scrollbar_info[i].gd_x;
5942 gd_x2 = (gd_x1 - (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL ?
5943 scrollbar_info[i].height : scrollbar_info[i].width));
5944 gd_y1 = DOOR_GFX_PAGEY1 + scrollbar_info[i].gd_y;
5945 gd_y2 = DOOR_GFX_PAGEY1 + scrollbar_info[i].gd_y;
5947 gi = CreateGadget(GDI_CUSTOM_ID, id,
5948 GDI_CUSTOM_TYPE_ID, i,
5949 GDI_INFO_TEXT, scrollbar_info[i].infotext,
5950 GDI_X, scrollbar_info[i].x,
5951 GDI_Y, scrollbar_info[i].y,
5952 GDI_WIDTH, scrollbar_info[i].width,
5953 GDI_HEIGHT, scrollbar_info[i].height,
5954 GDI_TYPE, scrollbar_info[i].type,
5955 GDI_SCROLLBAR_ITEMS_MAX, items_max,
5956 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
5957 GDI_SCROLLBAR_ITEM_POSITION, item_position,
5958 GDI_WHEEL_AREA_X, scrollbar_info[i].wheel_x,
5959 GDI_WHEEL_AREA_Y, scrollbar_info[i].wheel_y,
5960 GDI_WHEEL_AREA_WIDTH, scrollbar_info[i].wheel_width,
5961 GDI_WHEEL_AREA_HEIGHT, scrollbar_info[i].wheel_height,
5962 GDI_STATE, GD_BUTTON_UNPRESSED,
5963 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5964 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
5965 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5966 GDI_EVENT_MASK, event_mask,
5967 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5968 GDI_CALLBACK_ACTION, HandleControlButtons,
5972 Error(ERR_EXIT, "cannot create gadget");
5974 level_editor_gadget[id] = gi;
5978 static void CreateCheckbuttonGadgets()
5980 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5981 struct GadgetInfo *gi;
5982 unsigned long event_mask;
5983 int gd_x1, gd_x2, gd_x3, gd_x4, gd_y;
5986 event_mask = GD_EVENT_PRESSED;
5988 gd_x1 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_UNCHECKED_XPOS;
5989 gd_x2 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_UNCHECKED_XPOS;
5990 gd_x3 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_CHECKED_XPOS;
5991 gd_x4 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_CHECKED_XPOS;
5992 gd_y = DOOR_GFX_PAGEY1 + ED_RADIOBUTTON_YPOS;
5994 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
5996 int id = checkbutton_info[i].gadget_id;
5997 int x = SX + checkbutton_info[i].x;
5998 int y = SY + checkbutton_info[i].y;
6000 if (id == GADGET_ID_STICK_ELEMENT)
6001 gd_y = DOOR_GFX_PAGEY1 + ED_STICKYBUTTON_YPOS;
6003 gd_y = DOOR_GFX_PAGEY1 + ED_CHECKBUTTON_YPOS;
6005 /* determine horizontal position to the right of specified gadget */
6006 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6007 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
6008 ED_GADGET_TEXT_DISTANCE);
6010 /* determine horizontal offset for leading text */
6011 if (checkbutton_info[i].text_left != NULL)
6012 x += getTextWidthForGadget(checkbutton_info[i].text_left);
6014 gi = CreateGadget(GDI_CUSTOM_ID, id,
6015 GDI_CUSTOM_TYPE_ID, i,
6016 GDI_INFO_TEXT, checkbutton_info[i].infotext,
6019 GDI_WIDTH, ED_CHECKBUTTON_XSIZE,
6020 GDI_HEIGHT, ED_CHECKBUTTON_YSIZE,
6021 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
6022 GDI_CHECKED, *checkbutton_info[i].value,
6023 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
6024 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
6025 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y,
6026 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y,
6027 GDI_EVENT_MASK, event_mask,
6028 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6029 GDI_CALLBACK_ACTION, HandleCheckbuttons,
6033 Error(ERR_EXIT, "cannot create gadget");
6035 level_editor_gadget[id] = gi;
6036 right_gadget_border[id] =
6037 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
6041 static void CreateRadiobuttonGadgets()
6043 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
6044 struct GadgetInfo *gi;
6045 unsigned long event_mask;
6046 int gd_x1, gd_x2, gd_x3, gd_x4, gd_y;
6049 event_mask = GD_EVENT_PRESSED;
6051 gd_x1 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_UNCHECKED_XPOS;
6052 gd_x2 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_UNCHECKED_XPOS;
6053 gd_x3 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_CHECKED_XPOS;
6054 gd_x4 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_CHECKED_XPOS;
6055 gd_y = DOOR_GFX_PAGEY1 + ED_RADIOBUTTON_YPOS;
6057 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
6059 int id = radiobutton_info[i].gadget_id;
6060 int x = SX + radiobutton_info[i].x;
6061 int y = SY + radiobutton_info[i].y;
6064 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
6066 /* determine horizontal position to the right of specified gadget */
6067 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
6068 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
6069 ED_GADGET_TEXT_DISTANCE);
6071 /* determine horizontal offset for leading text */
6072 if (radiobutton_info[i].text_left != NULL)
6073 x += getTextWidthForGadget(radiobutton_info[i].text_left);
6075 gi = CreateGadget(GDI_CUSTOM_ID, id,
6076 GDI_CUSTOM_TYPE_ID, i,
6077 GDI_INFO_TEXT, radiobutton_info[i].infotext,
6080 GDI_WIDTH, ED_CHECKBUTTON_XSIZE,
6081 GDI_HEIGHT, ED_CHECKBUTTON_YSIZE,
6082 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
6083 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
6084 GDI_CHECKED, checked,
6085 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
6086 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
6087 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y,
6088 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y,
6089 GDI_EVENT_MASK, event_mask,
6090 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6091 GDI_CALLBACK_ACTION, HandleRadiobuttons,
6095 Error(ERR_EXIT, "cannot create gadget");
6097 level_editor_gadget[id] = gi;
6098 right_gadget_border[id] =
6099 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
6103 void CreateLevelEditorGadgets()
6105 int old_game_status = game_status;
6107 /* setting 'game_status' is needed to get the right fonts for the editor */
6108 game_status = GAME_MODE_EDITOR;
6110 ReinitializeElementList();
6112 CreateControlButtons();
6113 CreateScrollbarGadgets();
6115 /* order of function calls is important because of cross-references */
6116 CreateCheckbuttonGadgets();
6117 CreateCounterButtons();
6118 CreateRadiobuttonGadgets();
6119 CreateTextInputGadgets();
6120 CreateTextAreaGadgets();
6121 CreateSelectboxGadgets();
6122 CreateGraphicbuttonGadgets();
6123 CreateTextbuttonGadgets();
6124 CreateDrawingAreas();
6126 game_status = old_game_status;
6129 void FreeLevelEditorGadgets()
6133 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
6135 FreeGadget(level_editor_gadget[i]);
6137 level_editor_gadget[i] = NULL;
6141 static void MapCounterButtons(int id)
6143 int gadget_id_down = counterbutton_info[id].gadget_id_down;
6144 int gadget_id_text = counterbutton_info[id].gadget_id_text;
6145 int gadget_id_up = counterbutton_info[id].gadget_id_up;
6146 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
6147 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
6148 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
6149 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
6150 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6151 int yoffset_above = MINI_TILEX + ED_GADGET_DISTANCE;
6152 int yoffset = ED_BORDER_SIZE;
6153 int x_left = gi_down->x - xoffset_left;
6154 int x_right; /* set after gadget position was modified */
6155 int y_above = gi_down->y - yoffset_above;
6157 int y; /* set after gadget position was modified */
6159 /* counter limits must be changed first to prevent value truncation */
6160 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
6161 counterbutton_info[id].max_value);
6163 /* right text position might have changed after setting position above */
6164 x_right = gi_up->x + gi_up->width + xoffset_right;
6166 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
6168 /* set position for "value[1,2,3,4]" counter gadgets (score in most cases) */
6169 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
6170 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
6172 ModifyGadget(gi_down, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
6173 ModifyGadget(gi_text, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
6174 ModifyGadget(gi_up, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
6177 /* vertical position might have changed after setting position above */
6178 y = gi_up->y + yoffset;
6180 if (counterbutton_info[id].text_above)
6181 DrawText(x, y_above, counterbutton_info[id].text_above, FONT_TEXT_1);
6183 if (counterbutton_info[id].text_left)
6184 DrawText(x_left, y, counterbutton_info[id].text_left, FONT_TEXT_1);
6186 if (counterbutton_info[id].text_right)
6187 DrawText(x_right, y, counterbutton_info[id].text_right, FONT_TEXT_1);
6194 static void MapControlButtons()
6199 /* map toolbox buttons (excluding special CE toolbox buttons) */
6200 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
6201 MapGadget(level_editor_gadget[i]);
6203 /* map buttons to select elements */
6204 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6205 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
6206 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
6207 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
6208 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
6210 /* map buttons to select level */
6211 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
6212 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
6213 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
6214 MapCounterButtons(counter_id);
6217 static void MapDrawingArea(int id)
6219 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6220 int area_xsize = gi->drawing.area_xsize;
6221 int area_ysize = gi->drawing.area_ysize;
6222 int xoffset_left= getTextWidthForDrawingArea(drawingarea_info[id].text_left);
6223 int xoffset_below= getTextWidth(drawingarea_info[id].text_below,FONT_TEXT_1);
6224 int x_left = gi->x - xoffset_left;
6225 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
6226 int x_below = gi->x + (gi->width - xoffset_below) / 2;
6227 int y_side = gi->y + (gi->height - getFontHeight(FONT_TEXT_1)) / 2;
6228 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
6230 if (drawingarea_info[id].text_left)
6231 DrawText(x_left, y_side, drawingarea_info[id].text_left, FONT_TEXT_1);
6233 if (drawingarea_info[id].text_right)
6234 DrawText(x_right, y_side, drawingarea_info[id].text_right, FONT_TEXT_1);
6236 if (drawingarea_info[id].text_below)
6237 DrawText(x_below, y_below, drawingarea_info[id].text_below, FONT_TEXT_1);
6239 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
6241 DrawElementBorder(gi->x, gi->y,
6242 area_xsize * MINI_TILEX, area_ysize * MINI_TILEY, TRUE);
6244 DrawDrawingArea(id);
6250 static void MapTextInputGadget(int id)
6252 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
6253 int xoffset_above = 0;
6254 int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
6255 int x_above = textinput_info[id].x + xoffset_above;
6256 int y_above = textinput_info[id].y + yoffset_above;
6258 if (textinput_info[id].text_above)
6259 DrawTextS(x_above, y_above, FONT_TEXT_1, textinput_info[id].text_above);
6261 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
6266 static void MapTextAreaGadget(int id)
6268 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
6269 int xoffset_above = 0;
6270 int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
6271 int x_above = textarea_info[id].x + xoffset_above;
6272 int y_above = textarea_info[id].y + yoffset_above;
6274 if (textarea_info[id].text_above)
6275 DrawTextS(x_above, y_above, FONT_TEXT_1, textarea_info[id].text_above);
6277 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
6282 static void MapSelectboxGadget(int id)
6284 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
6285 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
6286 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6287 int yoffset = ED_BORDER_SIZE;
6288 int x_left = gi->x - xoffset_left;
6289 int x_right = gi->x + gi->width + xoffset_right;
6290 int y = gi->y + yoffset;
6292 if (selectbox_info[id].text_left)
6293 DrawText(x_left, y, selectbox_info[id].text_left, FONT_TEXT_1);
6295 if (selectbox_info[id].text_right)
6296 DrawText(x_right, y, selectbox_info[id].text_right, FONT_TEXT_1);
6298 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
6303 static void MapTextbuttonGadget(int id)
6305 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
6306 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
6307 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6308 int yoffset = ED_BORDER_SIZE;
6309 int x_left = gi->x - xoffset_left;
6310 int x_right = gi->x + gi->width + xoffset_right;
6311 int y = gi->y + yoffset;
6313 /* only show button to delete change pages when more than minimum pages */
6314 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
6315 custom_element.num_change_pages == MIN_CHANGE_PAGES)
6318 if (textbutton_info[id].text_left)
6319 DrawText(x_left, y, textbutton_info[id].text_left, FONT_TEXT_1);
6321 if (textbutton_info[id].text_right)
6322 DrawText(x_right, y, textbutton_info[id].text_right, FONT_TEXT_1);
6327 static void MapGraphicbuttonGadget(int id)
6329 struct GadgetInfo *gi= level_editor_gadget[graphicbutton_info[id].gadget_id];
6330 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
6331 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6332 int yoffset = ED_BORDER_SIZE;
6333 int x_left = gi->x - xoffset_left;
6334 int x_right = gi->x + gi->width + xoffset_right;
6335 int y = gi->y + yoffset;
6337 if (graphicbutton_info[id].text_left)
6338 DrawText(x_left, y, graphicbutton_info[id].text_left, FONT_TEXT_1);
6340 if (graphicbutton_info[id].text_right)
6341 DrawText(x_right, y, graphicbutton_info[id].text_right, FONT_TEXT_1);
6346 static void MapRadiobuttonGadget(int id)
6348 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
6349 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
6350 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6351 int yoffset = ED_BORDER_SIZE;
6352 int x_left = gi->x - xoffset_left;
6353 int x_right = gi->x + gi->width + xoffset_right;
6354 int y = gi->y + yoffset;
6356 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
6358 if (radiobutton_info[id].text_left)
6359 DrawText(x_left, y, radiobutton_info[id].text_left, FONT_TEXT_1);
6361 if (radiobutton_info[id].text_right)
6362 DrawText(x_right, y, radiobutton_info[id].text_right, FONT_TEXT_1);
6364 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
6369 static void MapCheckbuttonGadget(int id)
6371 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
6372 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
6373 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6374 int yoffset = ED_BORDER_SIZE;
6375 int x_left, x_right, y; /* set after gadget position was modified */
6377 /* set position for gadgets with dynamically determined position */
6378 if (checkbutton_info[id].x != -1) /* do not change dynamic positions */
6379 ModifyGadget(gi, GDI_X, SX + checkbutton_info[id].x, GDI_END);
6380 ModifyGadget(gi, GDI_Y, SY + checkbutton_info[id].y, GDI_END);
6382 x_left = gi->x - xoffset_left;
6383 x_right = gi->x + gi->width + xoffset_right;
6384 y = gi->y + yoffset;
6386 if (checkbutton_info[id].text_left)
6387 DrawText(x_left, y, checkbutton_info[id].text_left, FONT_TEXT_1);
6389 if (checkbutton_info[id].text_right)
6390 DrawText(x_right, y, checkbutton_info[id].text_right, FONT_TEXT_1);
6392 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
6397 static void MapMainDrawingArea()
6399 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
6400 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
6403 for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
6405 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
6406 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
6407 no_horizontal_scrollbar) ||
6408 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
6409 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
6410 no_vertical_scrollbar))
6413 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
6416 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
6418 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
6419 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
6422 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
6425 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
6428 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
6432 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6434 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
6435 i == GADGET_ID_CUSTOM_COPY_TO ||
6436 i == GADGET_ID_CUSTOM_EXCHANGE ||
6437 i == GADGET_ID_CUSTOM_COPY ||
6438 i == GADGET_ID_CUSTOM_PASTE)
6441 MapGadget(level_editor_gadget[i]);
6443 UnmapGadget(level_editor_gadget[i]);
6448 static void MapLevelEditorToolboxCustomGadgets()
6450 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
6453 static void UnmapLevelEditorToolboxCustomGadgets()
6455 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
6458 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
6460 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
6463 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
6465 if (i != GADGET_ID_SINGLE_ITEMS &&
6466 i != GADGET_ID_PROPERTIES &&
6467 i != GADGET_ID_PICK_ELEMENT)
6469 struct GadgetInfo *gi = level_editor_gadget[i];
6477 BlitBitmap(gd_bitmap, drawto,
6478 DOOR_GFX_PAGEX6 + ED_CTRL_NO_BUTTONS_GFX_XPOS,
6479 DOOR_GFX_PAGEY1 + ED_CTRL_NO_BUTTONS_GFX_YPOS,
6480 gi->width, gi->height, gi->x, gi->y);
6482 redraw_mask |= REDRAW_DOOR_3;
6488 static void MapLevelEditorToolboxDrawingGadgets()
6490 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
6493 static void UnmapLevelEditorToolboxDrawingGadgets()
6495 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
6498 static void UnmapDrawingArea(int id)
6500 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
6503 static void UnmapLevelEditorWindowGadgets()
6507 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
6508 if (level_editor_gadget[i]->x < SX + SXSIZE)
6509 UnmapGadget(level_editor_gadget[i]);
6512 void UnmapLevelEditorGadgets()
6516 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
6517 UnmapGadget(level_editor_gadget[i]);
6520 static void ResetUndoBuffer()
6522 undo_buffer_position = -1;
6523 undo_buffer_steps = -1;
6524 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
6526 level.changed = FALSE;
6529 static void DrawEditModeWindow()
6531 ModifyEditorElementList();
6532 RedrawDrawingElements();
6534 if (edit_mode == ED_MODE_INFO)
6535 DrawLevelInfoWindow();
6536 else if (edit_mode == ED_MODE_PROPERTIES)
6537 DrawPropertiesWindow();
6538 else /* edit_mode == ED_MODE_DRAWING */
6539 DrawDrawingWindow();
6542 static boolean LevelChanged()
6544 boolean field_changed = FALSE;
6547 if (leveldir_current->readonly)
6550 for (y = 0; y < lev_fieldy; y++)
6551 for (x = 0; x < lev_fieldx; x++)
6552 if (Feld[x][y] != level.field[x][y])
6553 field_changed = TRUE;
6555 return (level.changed || field_changed);
6558 static boolean LevelContainsPlayer()
6560 boolean player_found = FALSE;
6563 return TRUE; /* !!! CURRENTLY DEACTIVATED !!! */
6565 for (y = 0; y < lev_fieldy; y++) for (x = 0; x < lev_fieldx; x++)
6567 if (Feld[x][y] == EL_PLAYER_1 ||
6568 Feld[x][y] == EL_SP_MURPHY)
6569 player_found = TRUE;
6572 return player_found;
6575 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
6576 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
6580 for (x = 0; x < lev_fieldx; x++)
6581 for (y = 0; y < lev_fieldy; y++)
6582 dst[x][y] = src[x][y];
6585 static int setSelectboxValue(int selectbox_id, int new_value)
6587 int new_index_value = 0;
6590 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
6591 if (selectbox_info[selectbox_id].options[i].value == new_value)
6592 new_index_value = i;
6594 *selectbox_info[selectbox_id].value =
6595 selectbox_info[selectbox_id].options[new_index_value].value;
6597 return new_index_value;
6600 static void setSelectboxSpecialActionVariablesIfNeeded()
6604 /* change action mode and arg variables according to action type variable */
6605 for (i = 0; action_arg_options[i].value != -1; i++)
6607 if (action_arg_options[i].value == custom_element_change.action_type)
6609 int mode = action_arg_options[i].mode;
6611 /* only change if corresponding selectbox has changed */
6612 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
6613 action_arg_modes[mode])
6614 custom_element_change.action_mode = -1;
6616 /* only change if corresponding selectbox has changed */
6617 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
6618 action_arg_options[i].options)
6619 custom_element_change.action_arg = -1;
6626 static void setSelectboxSpecialActionOptions()
6630 /* change action mode and arg selectbox according to action type selectbox */
6631 for (i = 0; action_arg_options[i].value != -1; i++)
6633 if (action_arg_options[i].value == custom_element_change.action_type)
6635 int mode = action_arg_options[i].mode;
6637 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
6638 action_arg_modes[mode]);
6639 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
6640 custom_element_change.action_mode);
6642 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
6643 action_arg_options[i].options);
6644 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
6645 custom_element_change.action_arg);
6651 static void copy_custom_element_settings(int element_from, int element_to)
6653 struct ElementInfo *ei_from = &element_info[element_from];
6654 struct ElementInfo *ei_to = &element_info[element_to];
6656 copyElementInfo(ei_from, ei_to);
6659 static void replace_custom_element_in_settings(int element_from,
6664 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6666 struct ElementInfo *ei = &element_info[i];
6668 for (y = 0; y < 3; y++)
6669 for (x = 0; x < 3; x++)
6670 if (ei->content.e[x][y] == element_from)
6671 ei->content.e[x][y] = element_to;
6673 for (j = 0; j < ei->num_change_pages; j++)
6675 struct ElementChangeInfo *change = &ei->change_page[j];
6677 if (change->target_element == element_from)
6678 change->target_element = element_to;
6680 if (change->initial_trigger_element == element_from)
6681 change->initial_trigger_element = element_to;
6683 if (change->action_element == element_from)
6684 change->action_element = element_to;
6686 for (y = 0; y < 3; y++)
6687 for (x = 0; x < 3; x++)
6688 if (change->target_content.e[x][y] == element_from)
6689 change->target_content.e[x][y] = element_to;
6692 if (ei->group != NULL) /* group or internal */
6693 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
6694 if (ei->group->element[j] == element_from)
6695 ei->group->element[j] = element_to;
6699 static void replace_custom_element_in_playfield(int element_from,
6704 for (x = 0; x < lev_fieldx; x++)
6705 for (y = 0; y < lev_fieldy; y++)
6706 if (Feld[x][y] == element_from)
6707 Feld[x][y] = element_to;
6710 static boolean CopyCustomElement(int element_old, int element_new,
6713 if (copy_mode == GADGET_ID_CUSTOM_COPY)
6715 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
6716 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
6717 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
6719 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
6721 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
6722 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
6723 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
6725 level.changed = TRUE;
6727 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
6729 Request("Please choose custom element !", REQ_CONFIRM);
6733 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
6735 Request("Please choose group element !", REQ_CONFIRM);
6741 level.changed = TRUE;
6744 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
6746 copy_custom_element_settings(element_new, element_old);
6748 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
6750 copy_custom_element_settings(element_old, element_new);
6752 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
6754 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
6755 copy_custom_element_settings(element_new, element_old);
6756 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
6758 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
6759 replace_custom_element_in_settings(element_new, element_old);
6760 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
6762 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
6763 replace_custom_element_in_playfield(element_new, element_old);
6764 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
6767 UpdateCustomElementGraphicGadgets();
6768 DrawPropertiesWindow();
6773 static void CopyCustomElementPropertiesToEditor(int element)
6776 int current_change_page = element_info[element].current_change_page;
6778 /* dynamically (re)build selectbox for selecting change page */
6779 for (i = 0; i < element_info[element].num_change_pages; i++)
6781 sprintf(options_change_page_strings[i], "%d", i + 1);
6783 options_change_page[i].value = i;
6784 options_change_page[i].text = options_change_page_strings[i];
6787 options_change_page[i].value = -1;
6788 options_change_page[i].text = NULL;
6790 /* needed here to initialize combined element properties */
6791 InitElementPropertiesEngine(level.game_version);
6793 element_info[element].change =
6794 &element_info[element].change_page[current_change_page];
6796 custom_element = element_info[element];
6797 custom_element_change = *element_info[element].change;
6799 /* needed to initially set selectbox options for special action options */
6800 setSelectboxSpecialActionOptions();
6802 /* needed to initially set selectbox value variables to reliable defaults */
6803 for (i = 0; i < ED_NUM_SELECTBOX; i++)
6804 setSelectboxValue(i, *selectbox_info[i].value);
6806 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
6807 custom_element_properties[i] = HAS_PROPERTY(element, i);
6809 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
6810 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
6812 /* ---------- element settings: configure (custom elements) ------------- */
6814 /* set accessible layer selectbox help value */
6815 custom_element.access_type =
6816 (IS_WALKABLE(element) ? EP_WALKABLE :
6817 IS_PASSABLE(element) ? EP_PASSABLE :
6818 custom_element.access_type);
6819 custom_element.access_layer =
6820 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
6821 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
6822 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
6823 custom_element.access_layer);
6824 custom_element.access_protected =
6825 (IS_PROTECTED(element) ? 1 : 0);
6826 custom_element_properties[EP_ACCESSIBLE] =
6827 (IS_ACCESSIBLE_OVER(element) ||
6828 IS_ACCESSIBLE_INSIDE(element) ||
6829 IS_ACCESSIBLE_UNDER(element));
6831 /* set walk-to-object action selectbox help value */
6832 custom_element.walk_to_action =
6833 (IS_DIGGABLE(element) ? EP_DIGGABLE :
6834 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
6835 IS_DROPPABLE(element) ? EP_DROPPABLE :
6836 IS_THROWABLE(element) ? EP_THROWABLE :
6837 IS_PUSHABLE(element) ? EP_PUSHABLE :
6838 custom_element.walk_to_action);
6839 custom_element_properties[EP_WALK_TO_OBJECT] =
6840 (IS_DIGGABLE(element) ||
6841 IS_COLLECTIBLE_ONLY(element) ||
6842 IS_DROPPABLE(element) ||
6843 IS_THROWABLE(element) ||
6844 IS_PUSHABLE(element));
6846 /* set smash targets selectbox help value */
6847 custom_element.smash_targets =
6848 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
6849 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
6850 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
6851 custom_element.smash_targets);
6852 custom_element_properties[EP_CAN_SMASH] =
6853 (CAN_SMASH_EVERYTHING(element) ||
6854 CAN_SMASH_ENEMIES(element) ||
6855 CAN_SMASH_PLAYER(element));
6857 /* set deadliness selectbox help value */
6858 custom_element.deadliness =
6859 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
6860 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
6861 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
6862 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
6863 custom_element.deadliness);
6864 custom_element_properties[EP_DEADLY] =
6865 (DONT_TOUCH(element) ||
6866 DONT_GET_HIT_BY(element) ||
6867 DONT_COLLIDE_WITH(element) ||
6868 DONT_RUN_INTO(element));
6870 /* ---------- element settings: advanced (custom elements) --------------- */
6872 /* set "change by direct action" selectbox help value */
6873 custom_element_change.direct_action =
6874 (HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
6875 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
6876 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
6877 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
6878 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
6879 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
6880 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
6881 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
6882 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
6883 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
6884 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
6885 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
6886 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
6887 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
6888 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
6889 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
6890 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
6891 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
6892 custom_element_change.direct_action);
6894 /* set "change by other element action" selectbox help value */
6895 custom_element_change.other_action =
6896 (HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
6897 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
6898 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
6899 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
6900 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
6901 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
6902 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
6903 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
6904 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
6905 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
6906 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
6907 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
6908 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
6909 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
6910 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
6911 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
6912 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
6913 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
6914 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
6915 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
6916 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
6917 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
6918 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
6919 custom_element_change.other_action);
6922 static void CopyGroupElementPropertiesToEditor(int element)
6924 group_element_info = *element_info[element].group;
6925 custom_element = element_info[element]; /* needed for description */
6928 static void CopyClassicElementPropertiesToEditor(int element)
6930 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
6931 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
6932 getMoveIntoAcidProperty(&level, element);
6934 if (MAYBE_DONT_COLLIDE_WITH(element))
6935 custom_element_properties[EP_DONT_COLLIDE_WITH] =
6936 getDontCollideWithProperty(&level, element);
6939 static void CopyElementPropertiesToEditor(int element)
6941 if (IS_CUSTOM_ELEMENT(element))
6942 CopyCustomElementPropertiesToEditor(element);
6943 else if (IS_GROUP_ELEMENT(element))
6944 CopyGroupElementPropertiesToEditor(element);
6946 CopyClassicElementPropertiesToEditor(element);
6949 static void CopyCustomElementPropertiesToGame(int element)
6952 int access_type_and_layer;
6954 /* mark that this custom element has been modified */
6955 custom_element.modified_settings = TRUE;
6956 level.changed = TRUE;
6958 if (level.use_custom_template)
6960 if (Request("Copy and modify level template ?", REQ_ASK))
6962 level.use_custom_template = FALSE;
6963 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE],
6964 GDI_CHECKED, FALSE, GDI_END);
6968 LoadLevelTemplate(-1); /* this resets all element modifications ... */
6970 DrawEditModeWindow(); /* ... and copies them to 'custom_element' */
6974 element_info[element] = custom_element;
6975 *element_info[element].change = custom_element_change;
6977 /* ---------- element settings: configure (custom elements) ------------- */
6979 /* set accessible property from checkbox and selectbox */
6980 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
6981 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
6982 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
6983 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
6984 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
6985 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
6986 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
6987 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
6988 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
6989 custom_element_properties[access_type_and_layer] =
6990 custom_element_properties[EP_ACCESSIBLE];
6991 custom_element_properties[EP_PROTECTED] =
6992 (custom_element.access_protected != 0 &&
6993 custom_element_properties[EP_ACCESSIBLE]);
6995 /* set walk-to-object property from checkbox and selectbox */
6996 custom_element_properties[EP_DIGGABLE] = FALSE;
6997 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
6998 custom_element_properties[EP_DROPPABLE] = FALSE;
6999 custom_element_properties[EP_THROWABLE] = FALSE;
7000 custom_element_properties[EP_PUSHABLE] = FALSE;
7001 custom_element_properties[custom_element.walk_to_action] =
7002 custom_element_properties[EP_WALK_TO_OBJECT];
7004 /* set smash property from checkbox and selectbox */
7005 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
7006 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
7007 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
7008 custom_element_properties[custom_element.smash_targets] =
7009 custom_element_properties[EP_CAN_SMASH];
7011 /* set deadliness property from checkbox and selectbox */
7012 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
7013 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
7014 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
7015 custom_element_properties[EP_DONT_TOUCH] = FALSE;
7016 custom_element_properties[custom_element.deadliness] =
7017 custom_element_properties[EP_DEADLY];
7019 /* ---------- element settings: advanced (custom elements) --------------- */
7021 /* set player change event from checkbox and selectbox */
7022 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
7023 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
7024 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
7025 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
7026 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
7027 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
7028 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
7029 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
7030 custom_element_change_events[CE_SWITCHED] = FALSE;
7031 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
7032 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
7033 custom_element_change_events[CE_BLOCKED] = FALSE;
7034 custom_element_change_events[CE_IMPACT] = FALSE;
7035 custom_element_change_events[CE_SMASHED] = FALSE;
7036 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
7037 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
7038 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
7039 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
7040 custom_element_change_events[custom_element_change.direct_action] =
7041 custom_element_change_events[CE_BY_DIRECT_ACTION];
7043 /* set other element action change event from checkbox and selectbox */
7044 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
7045 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
7046 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
7047 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
7048 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
7049 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
7050 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
7051 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
7052 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
7053 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
7054 custom_element_change_events[CE_TOUCHING_X] = FALSE;
7055 custom_element_change_events[CE_HITTING_X] = FALSE;
7056 custom_element_change_events[CE_DIGGING_X] = FALSE;
7057 custom_element_change_events[CE_HIT_BY_X] = FALSE;
7058 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
7059 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
7060 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
7061 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
7062 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
7063 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
7064 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
7065 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
7066 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
7067 custom_element_change_events[custom_element_change.other_action] =
7068 custom_element_change_events[CE_BY_OTHER_ACTION];
7070 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
7071 SET_PROPERTY(element, i, custom_element_properties[i]);
7073 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
7074 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
7076 /* copy change events also to special level editor variable */
7077 custom_element = element_info[element];
7078 custom_element_change = *element_info[element].change;
7081 static void CopyGroupElementPropertiesToGame(int element)
7083 element_info[element] = custom_element;
7084 *element_info[element].group = group_element_info;
7086 /* mark that this group element has been modified */
7087 element_info[element].modified_settings = TRUE;
7088 level.changed = TRUE;
7091 static void CopyClassicElementPropertiesToGame(int element)
7093 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
7094 setMoveIntoAcidProperty(&level, element,
7095 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
7097 if (MAYBE_DONT_COLLIDE_WITH(element))
7098 setDontCollideWithProperty(&level, element,
7099 custom_element_properties[EP_DONT_COLLIDE_WITH]);
7102 static void CopyElementPropertiesToGame(int element)
7104 if (IS_CUSTOM_ELEMENT(element))
7105 CopyCustomElementPropertiesToGame(element);
7106 else if (IS_GROUP_ELEMENT(element))
7107 CopyGroupElementPropertiesToGame(element);
7109 CopyClassicElementPropertiesToGame(element);
7112 void CheckElementDescriptions()
7116 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
7117 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
7118 Error(ERR_WARN, "no element description for element '%s'", EL_NAME(i));
7123 CloseDoor(DOOR_CLOSE_ALL);
7126 FadeOut(REDRAW_FIELD);
7129 OpenDoor(DOOR_OPEN_2 | DOOR_NO_DELAY);
7132 CheckElementDescriptions();
7135 if (level_editor_test_game)
7137 CopyPlayfield(level.field, Feld);
7138 CopyPlayfield(FieldBackup, level.field);
7140 level_editor_test_game = FALSE;
7144 edit_mode = ED_MODE_DRAWING;
7145 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
7153 /* copy default editor door content to main double buffer */
7154 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
7155 DOOR_GFX_PAGEX6, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
7157 /* draw bigger door */
7158 DrawSpecialEditorDoor();
7160 /* draw new control window */
7161 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
7162 DOOR_GFX_PAGEX8, 236, EXSIZE, EYSIZE, EX, EY);
7164 redraw_mask |= REDRAW_ALL;
7166 ReinitializeElementList(); /* update dynamic level element list */
7167 ReinitializeElementListButtons(); /* custom element may look different */
7174 MapControlButtons();
7177 FadeOut(REDRAW_FIELD);
7180 DrawEditModeWindow();
7183 FadeIn(REDRAW_FIELD);
7186 /* copy actual editor door content to door double buffer for OpenDoor() */
7187 BlitBitmap(drawto, bitmap_db_door,
7188 DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
7191 /* draw new control window (with border) to window */
7192 redraw_mask |= REDRAW_ALL;
7196 OpenDoor(DOOR_OPEN_1);
7199 static void AdjustDrawingAreaGadgets()
7201 int ed_xsize = lev_fieldx + 2;
7202 int ed_ysize = lev_fieldy + 2;
7203 int max_ed_fieldx = MAX_ED_FIELDX;
7204 int max_ed_fieldy = MAX_ED_FIELDY;
7205 boolean horizontal_scrollbar_needed;
7206 boolean vertical_scrollbar_needed;
7207 int x, y, width, height;
7208 int xoffset, yoffset;
7210 /* check if we need any scrollbars */
7211 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
7212 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
7214 /* check if we have a smaller editor field because of scrollbars */
7215 if (horizontal_scrollbar_needed)
7216 max_ed_fieldy = MAX_ED_FIELDY - 1;
7217 if (vertical_scrollbar_needed)
7218 max_ed_fieldx = MAX_ED_FIELDX - 1;
7220 /* check again if we now need more scrollbars because of less space */
7221 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
7222 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
7224 /* check if editor field gets even smaller after adding new scrollbars */
7225 if (horizontal_scrollbar_needed)
7226 max_ed_fieldy = MAX_ED_FIELDY - 1;
7227 if (vertical_scrollbar_needed)
7228 max_ed_fieldx = MAX_ED_FIELDX - 1;
7230 ed_fieldx = (ed_xsize < MAX_ED_FIELDX ? ed_xsize : max_ed_fieldx);
7231 ed_fieldy = (ed_ysize < MAX_ED_FIELDY ? ed_ysize : max_ed_fieldy);
7233 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
7234 GDI_WIDTH, ed_fieldx * MINI_TILEX,
7235 GDI_HEIGHT, ed_fieldy * MINI_TILEY,
7236 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
7239 xoffset = (ed_fieldx == MAX_ED_FIELDX ? ED_SCROLLBUTTON_XSIZE : 0);
7240 yoffset = (ed_fieldy == MAX_ED_FIELDY ? ED_SCROLLBUTTON_YSIZE : 0);
7242 x = SX + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_RIGHT].x + xoffset;
7243 y = SX + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_DOWN].y + yoffset;
7245 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT], GDI_X, x, GDI_END);
7246 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN], GDI_Y, y, GDI_END);
7248 width = scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width + xoffset;
7249 height = scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].height + yoffset;
7251 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
7253 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
7255 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
7257 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
7261 static void AdjustLevelScrollPosition()
7263 if (level_xpos < -1)
7265 if (level_xpos > lev_fieldx - ed_fieldx + 1)
7266 level_xpos = lev_fieldx - ed_fieldx + 1;
7267 if (lev_fieldx < ed_fieldx - 2)
7270 if (level_ypos < -1)
7272 if (level_ypos > lev_fieldy - ed_fieldy + 1)
7273 level_ypos = lev_fieldy - ed_fieldy + 1;
7274 if (lev_fieldy < ed_fieldy - 2)
7278 static void AdjustEditorScrollbar(int id)
7280 struct GadgetInfo *gi = level_editor_gadget[id];
7281 int items_max, items_visible, item_position;
7283 if (id == GADGET_ID_SCROLL_HORIZONTAL)
7285 items_max = MAX(lev_fieldx + 2, ed_fieldx);
7286 items_visible = ed_fieldx;
7287 item_position = level_xpos + 1;
7291 items_max = MAX(lev_fieldy + 2, ed_fieldy);
7292 items_visible = ed_fieldy;
7293 item_position = level_ypos + 1;
7296 if (item_position > items_max - items_visible)
7297 item_position = items_max - items_visible;
7299 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
7300 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
7303 static void AdjustElementListScrollbar()
7305 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
7306 int items_max, items_visible, item_position;
7308 /* correct position of element list scrollbar */
7309 if (element_shift < 0)
7311 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
7312 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
7314 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
7315 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
7316 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
7318 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
7319 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7320 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
7323 static void ModifyEditorCounterValue(int counter_id, int new_value)
7325 int *counter_value = counterbutton_info[counter_id].value;
7326 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
7327 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7329 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
7331 if (counter_value != NULL)
7332 *counter_value = gi->textinput.number_value;
7335 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
7337 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
7338 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7340 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
7342 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
7343 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
7345 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
7346 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
7348 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
7349 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_DISTANCE,GDI_END);
7353 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
7355 int gadget_id = selectbox_info[selectbox_id].gadget_id;
7356 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7357 int new_index_value = setSelectboxValue(selectbox_id, new_value);
7359 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
7362 static void ModifyEditorSelectboxOptions(int selectbox_id,
7363 struct ValueTextInfo *options)
7365 int gadget_id = selectbox_info[selectbox_id].gadget_id;
7366 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7368 selectbox_info[selectbox_id].options = options;
7370 /* set index to zero -- list may be shorter now (correct later, if needed) */
7371 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
7372 GDI_SELECTBOX_OPTIONS, options, GDI_END);
7375 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
7377 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
7378 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7380 drawingarea_info[drawingarea_id].area_xsize = xsize;
7381 drawingarea_info[drawingarea_id].area_ysize = ysize;
7383 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
7386 static void ModifyEditorElementList()
7390 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7392 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
7393 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7394 struct GadgetDesign *gd = &gi->deco.design;
7395 int element = editor_elements[element_shift + i];
7399 getMiniGraphicSource(el2edimg(element), &gd->bitmap, &gd->x, &gd->y);
7400 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
7406 static void PickDrawingElement(int button, int element)
7408 if (button < 1 || button > 3)
7413 new_element1 = element;
7414 DrawMiniGraphicExt(drawto,
7415 DX + ED_WIN_MB_LEFT_XPOS, DY + ED_WIN_MB_LEFT_YPOS,
7416 el2edimg(new_element1));
7418 else if (button == 2)
7420 new_element2 = element;
7421 DrawMiniGraphicExt(drawto,
7422 DX + ED_WIN_MB_MIDDLE_XPOS, DY + ED_WIN_MB_MIDDLE_YPOS,
7423 el2edimg(new_element2));
7427 new_element3 = element;
7428 DrawMiniGraphicExt(drawto,
7429 DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS,
7430 el2edimg(new_element3));
7433 redraw_mask |= REDRAW_DOOR_1;
7436 static void RedrawDrawingElements()
7438 PickDrawingElement(1, new_element1);
7439 PickDrawingElement(2, new_element2);
7440 PickDrawingElement(3, new_element3);
7443 static void DrawDrawingWindow()
7445 stick_element_properties_window = FALSE;
7447 SetMainBackgroundImage(IMG_UNDEFINED);
7450 UnmapLevelEditorWindowGadgets();
7451 UnmapLevelEditorToolboxCustomGadgets();
7453 AdjustDrawingAreaGadgets();
7454 AdjustLevelScrollPosition();
7455 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
7456 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
7458 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7460 MapMainDrawingArea();
7461 MapLevelEditorToolboxDrawingGadgets();
7464 static void DrawLevelInfoWindow()
7468 stick_element_properties_window = FALSE;
7470 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
7472 UnmapLevelEditorWindowGadgets();
7475 DrawTextSCentered(ED_SETTINGS1_YPOS, FONT_TITLE_1, "Level Settings");
7476 DrawTextSCentered(ED_SETTINGS2_YPOS, FONT_TITLE_1, "Editor Settings");
7478 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS1_YPOS,
7479 "Level Settings", FONT_TITLE_1);
7480 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS2_YPOS,
7481 "Editor Settings", FONT_TITLE_1);
7484 /* draw counter gadgets */
7485 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
7486 MapCounterButtons(i);
7488 /* draw selectbox gadgets */
7489 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
7490 MapSelectboxGadget(i);
7492 /* draw checkbutton gadgets */
7493 for (i=ED_CHECKBUTTON_ID_LEVEL_FIRST; i <= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
7494 MapCheckbuttonGadget(i);
7496 /* draw radiobutton gadgets */
7497 for (i=ED_RADIOBUTTON_ID_LEVEL_FIRST; i <= ED_RADIOBUTTON_ID_LEVEL_LAST; i++)
7498 MapRadiobuttonGadget(i);
7500 /* draw text input gadgets */
7501 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
7502 MapTextInputGadget(i);
7504 /* draw drawing area */
7505 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
7508 static void DrawCustomContentArea()
7510 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
7511 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
7512 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
7513 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
7514 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
7515 int xoffset = ED_DRAWINGAREA_TEXT_DISTANCE;
7517 /* add distance for potential left text (without drawing area border) */
7518 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
7520 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
7522 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
7525 static void DrawCustomChangeContentArea()
7527 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
7528 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
7529 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
7530 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
7531 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
7532 int xoffset = ED_DRAWINGAREA_TEXT_DISTANCE;
7534 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
7539 static void DrawYamYamContentAreas()
7541 int x = SX + ED_AREA_YAMYAM_CONTENT_XPOS(3) + 4 * MINI_TILEX;
7542 int y = SY + ED_AREA_YAMYAM_CONTENT_YPOS(0) + ED_BORDER_AREA_YSIZE;
7545 /* display counter to choose number of element content areas */
7546 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
7548 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
7550 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
7552 if (i < level.num_yamyam_contents)
7558 int font_height = getFontHeight(FONT_TEXT_1);
7560 UnmapDrawingArea(id);
7562 /* delete content areas in case of reducing number of them */
7563 DrawBackground(SX + drawingarea_info[id].x - MINI_TILEX / 2,
7564 SY + drawingarea_info[id].y - MINI_TILEY / 2,
7566 4 * MINI_TILEY + ED_GADGET_TEXT_DISTANCE + font_height);
7570 DrawText(x, y + 0 * MINI_TILEY, "content", FONT_TEXT_1);
7571 DrawText(x, y + 1 * MINI_TILEY, "when", FONT_TEXT_1);
7572 DrawText(x, y + 2 * MINI_TILEY, "smashed", FONT_TEXT_1);
7575 static void DrawMagicBallContentAreas()
7577 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_XPOS(3) + 4 * MINI_TILEX;
7578 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_YPOS(0) + ED_BORDER_AREA_YSIZE;
7581 /* display counter to choose number of element content areas */
7582 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
7584 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
7586 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
7588 if (i < level.num_ball_contents)
7594 int font_height = getFontHeight(FONT_TEXT_1);
7596 UnmapDrawingArea(id);
7598 /* delete content areas in case of reducing number of them */
7599 DrawBackground(SX + drawingarea_info[id].x - MINI_TILEX / 2,
7600 SY + drawingarea_info[id].y - MINI_TILEY / 2,
7602 4 * MINI_TILEY + ED_GADGET_TEXT_DISTANCE + font_height);
7606 DrawText(x, y + 0 * MINI_TILEY, "generated", FONT_TEXT_1);
7607 DrawText(x, y + 1 * MINI_TILEY, "when", FONT_TEXT_1);
7608 DrawText(x, y + 2 * MINI_TILEY, "active", FONT_TEXT_1);
7611 static void DrawAndroidElementArea(int element)
7613 int num_elements = level.num_android_clone_elements;
7614 int id = ED_DRAWING_ID_ANDROID_CONTENT;
7615 int sx = SX + drawingarea_info[id].x - MINI_TILEX / 2;
7616 int sy = SY + drawingarea_info[id].y - MINI_TILEY / 2;
7617 int xsize = MAX_ANDROID_ELEMENTS;
7620 /* display counter to choose number of element areas */
7621 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
7623 if (drawingarea_info[id].text_left != NULL)
7624 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
7626 UnmapDrawingArea(id);
7628 ModifyEditorDrawingArea(id, num_elements, 1);
7630 /* delete content areas in case of reducing number of them */
7631 DrawBackground(sx, sy, (xsize + 1) * MINI_TILEX, (ysize + 1) * MINI_TILEY);
7636 static void DrawGroupElementArea(int element)
7638 int num_elements = group_element_info.num_elements;
7639 int id = ED_DRAWING_ID_GROUP_CONTENT;
7640 int sx = SX + drawingarea_info[id].x - MINI_TILEX / 2;
7641 int sy = SY + drawingarea_info[id].y - MINI_TILEY / 2;
7642 int xsize = MAX_ELEMENTS_IN_GROUP;
7645 if (drawingarea_info[id].text_left != NULL)
7646 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
7648 UnmapDrawingArea(id);
7650 ModifyEditorDrawingArea(id, num_elements, 1);
7652 /* delete content areas in case of reducing number of them */
7653 DrawBackground(sx, sy, (xsize + 1) * MINI_TILEX, (ysize + 1) * MINI_TILEY);
7658 static void DrawPlayerInitialInventoryArea(int element)
7660 int player_nr = GET_PLAYER_NR(element);
7661 int num_elements = level.initial_inventory_size[player_nr];
7662 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
7663 int sx = SX + drawingarea_info[id].x - MINI_TILEX / 2;
7664 int sy = SY + drawingarea_info[id].y - MINI_TILEY / 2;
7665 int xsize = MAX_INITIAL_INVENTORY_SIZE;
7668 /* determine horizontal position to the right of specified gadget */
7669 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
7670 sx += (right_gadget_border[drawingarea_info[id].gadget_id_align] +
7671 ED_DRAWINGAREA_TEXT_DISTANCE);
7673 /* determine horizontal offset for leading text */
7674 if (drawingarea_info[id].text_left != NULL)
7675 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
7677 UnmapDrawingArea(id);
7679 ModifyEditorDrawingArea(id, num_elements, 1);
7681 /* delete content areas in case of reducing number of them */
7682 DrawBackground(sx, sy, (xsize + 1) * MINI_TILEX, (ysize + 1) * MINI_TILEY);
7687 static void DrawEnvelopeTextArea(int envelope_nr)
7689 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
7690 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
7693 DrawBackground(gi->x, gi->y, gi->width, gi->height);
7695 if (envelope_nr != -1)
7696 textarea_info[id].value = level.envelope[envelope_nr].text;
7698 ModifyGadget(gi, GDI_AREA_SIZE,
7699 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
7700 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
7703 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
7706 static boolean PrintInfoText(char *text, int font_nr, int start_line)
7708 int font_height = getFontHeight(font_nr);
7709 int pad_x = ED_ELEMENT_SETTINGS_XPOS(0);
7710 int pad_y = ED_ELEMENT_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
7711 int sx = SX + pad_x;
7712 int sy = SY + pad_y;
7713 int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
7715 if (start_line >= max_lines_per_screen)
7718 DrawText(sx, sy + start_line * font_height, text, font_nr);
7723 static int PrintElementDescriptionFromFile(char *filename, int start_line)
7725 int font_nr = FONT_TEXT_2;
7726 int font_width = getFontWidth(font_nr);
7727 int font_height = getFontHeight(font_nr);
7728 int pad_x = ED_ELEMENT_SETTINGS_XPOS(0);
7729 int pad_y = ED_ELEMENT_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
7730 int sx = SX + pad_x;
7731 int sy = SY + pad_y + start_line * font_height;
7732 int max_chars_per_line = (SXSIZE - 2 * pad_x) / font_width;
7733 int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
7735 return DrawTextFile(sx, sy, filename, font_nr, max_chars_per_line, -1,
7736 max_lines_per_screen, -1, TRUE, FALSE, FALSE);
7739 static void DrawPropertiesTabulatorGadgets()
7741 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
7742 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
7743 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
7744 int gd_x = gd->x + gd_gi1->border.width / 2;
7745 int gd_y = gd->y + gd_gi1->height - 1;
7746 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
7747 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
7748 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
7755 /* draw two config tabulators for player elements */
7756 if (ELEM_IS_PLAYER(properties_element))
7757 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
7759 /* draw two config and one "change" tabulator for custom elements */
7760 if (IS_CUSTOM_ELEMENT(properties_element))
7761 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
7763 for (i = id_first; i <= id_last; i++)
7765 int gadget_id = textbutton_info[i].gadget_id;
7766 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7767 boolean active = (i != edit_mode_properties);
7769 /* use "config 1" and "config 2" instead of "config" for players and CEs */
7770 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
7771 (ELEM_IS_PLAYER(properties_element) ||
7772 IS_CUSTOM_ELEMENT(properties_element)))
7775 /* draw background line below tabulator button */
7776 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
7778 /* draw solid line below inactive tabulator buttons */
7779 if (!active && tab_color != BLACK_PIXEL) /* black => transparent */
7780 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width, 1, tab_color);
7782 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
7783 MapTextbuttonGadget(i);
7787 /* draw little border line below tabulator buttons */
7788 if (tab_color != BLACK_PIXEL) /* black => transparent */
7789 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height + 1,
7790 gd_gi4->x - gd_gi1->x + gd_gi4->width, ED_GADGET_DISTANCE,
7793 /* draw little border line below tabulator buttons */
7794 if (tab_color != BLACK_PIXEL) /* black => transparent */
7795 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height + 1,
7796 max_tabs * gd_gi1->width + (max_tabs -1) * ED_GADGET_DISTANCE,
7797 ED_GADGET_DISTANCE, tab_color);
7801 static void DrawPropertiesInfo()
7810 /* configurable properties */
7812 { EP_WALKABLE_OVER, "- player can walk over it" },
7813 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
7814 { EP_WALKABLE_UNDER, "- player can walk under it" },
7815 { EP_PASSABLE_OVER, "- player can pass over it" },
7816 { EP_PASSABLE_INSIDE, "- player can pass through it" },
7817 { EP_PASSABLE_UNDER, "- player can pass under it" },
7818 { EP_PROTECTED, "- player is protected by it" },
7820 { EP_DIGGABLE, "- can be digged away" },
7821 { EP_COLLECTIBLE, "- can be collected" },
7822 { EP_DROPPABLE, "- can be dropped after collecting" },
7823 { EP_THROWABLE, "- can be thrown after collecting" },
7824 { EP_PUSHABLE, "- can be pushed" },
7826 { EP_CAN_FALL, "- can fall" },
7827 { EP_CAN_MOVE, "- can move" },
7829 { EP_CAN_SMASH_PLAYER, "- can smash player" },
7831 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
7833 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
7835 { EP_SLIPPERY, "- slippery for falling elements" },
7836 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
7838 { EP_DONT_RUN_INTO, "- deadly when running into" },
7839 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
7840 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
7841 { EP_DONT_TOUCH, "- deadly when touching" },
7843 { EP_INDESTRUCTIBLE, "- indestructible" },
7845 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
7846 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
7847 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
7849 { EP_CAN_CHANGE, "- can change to other element" },
7851 /* pre-defined properties */
7852 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
7853 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
7854 { EP_SWITCHABLE, "- can be switched" },
7856 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
7861 char *filename = getElementDescriptionFilename(properties_element);
7862 char *percentage_text = "In this level:";
7863 char *properties_text = "Standard properties:";
7865 int num_elements_in_level;
7866 int num_standard_properties = 0;
7867 int font1_nr = FONT_TEXT_1;
7868 int font2_nr = FONT_TEXT_2;
7869 int font1_width = getFontWidth(font1_nr);
7870 int font2_height = getFontHeight(font2_nr);
7871 int pad_x = ED_ELEMENT_SETTINGS_XPOS(0);
7872 int pad_y = ED_ELEMENT_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
7873 int screen_line = 0;
7876 if (setup.editor.show_element_token)
7878 DrawTextF(pad_x, pad_y + screen_line++ * font2_height, FONT_TEXT_3,
7879 "[%s]", element_info[properties_element].token_name);
7883 /* ----- print number of elements / percentage of this element in level */
7885 num_elements_in_level = 0;
7886 for (y = 0; y < lev_fieldy; y++)
7887 for (x = 0; x < lev_fieldx; x++)
7888 if (Feld[x][y] == properties_element)
7889 num_elements_in_level++;
7890 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
7892 DrawTextS(pad_x, pad_y + screen_line * font2_height, font1_nr,
7894 DrawTextF(pad_x + strlen(percentage_text) * font1_width,
7895 pad_y + screen_line++ * font2_height, font2_nr,
7896 "%d (%.2f%%)", num_elements_in_level, percentage);
7900 /* ----- print standard properties of this element */
7902 DrawTextS(pad_x, pad_y + screen_line++ * font2_height, font1_nr,
7905 for (i = 0; properties[i].value != -1; i++)
7907 if (!HAS_PROPERTY(properties_element, properties[i].value))
7910 DrawTextS(pad_x, pad_y + screen_line++ * font2_height, font2_nr,
7911 properties[i].text);
7912 num_standard_properties++;
7915 if (num_standard_properties == 0)
7916 DrawTextS(pad_x + strlen(properties_text) * font1_width,
7917 pad_y + (screen_line - 1) * font2_height, font2_nr, "none");
7921 /* ----- print special description of this element */
7923 PrintInfoText("Description:", FONT_TEXT_1, screen_line);
7924 if (PrintElementDescriptionFromFile(filename, screen_line + 1) == 0)
7925 PrintInfoText("No description available.", FONT_TEXT_1, screen_line);
7928 #define TEXT_COLLECTING "Score for collecting"
7929 #define TEXT_SMASHING "Score for smashing"
7930 #define TEXT_SLURPING "Score for slurping robot"
7931 #define TEXT_CRACKING "Score for cracking"
7932 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
7933 #define TEXT_DURATION "Duration when activated"
7934 #define TEXT_BALL_DELAY "Element generation delay"
7935 #define TEXT_MOVE_SPEED "Speed of android moving"
7936 #define TEXT_CLONE_SPEED "Speed of android cloning"
7937 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
7938 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
7939 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
7940 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
7941 #define TEXT_TIME_BONUS "Extra time to solve level"
7948 } elements_with_counter[] =
7950 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
7951 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
7952 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
7953 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
7954 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
7955 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
7956 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
7957 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
7958 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
7959 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
7960 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
7961 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
7962 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
7963 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
7964 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
7965 { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
7966 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
7967 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
7968 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
7969 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
7970 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7971 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7972 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7973 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7974 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7975 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7976 { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
7977 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7978 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7979 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7980 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7981 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
7982 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
7983 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
7984 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
7985 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
7986 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
7987 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
7988 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
7989 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
7990 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
7991 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
7992 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
7993 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
7994 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
7995 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
7996 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE],TEXT_COLLECTING },
7997 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
7998 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
7999 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
8000 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
8001 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
8002 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
8003 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
8004 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
8005 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
8006 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
8007 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
8008 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
8009 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
8010 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
8011 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
8012 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
8013 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
8014 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
8015 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
8016 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
8017 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
8018 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
8019 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
8020 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
8021 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
8022 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
8023 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
8025 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
8026 { EL_DC_TIMEGATE_SWITCH,&level.time_timegate, TEXT_DURATION },
8027 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
8028 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
8029 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
8030 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
8031 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
8032 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
8033 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
8034 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
8035 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
8036 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
8037 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
8038 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
8039 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
8040 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
8042 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
8043 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
8044 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
8045 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
8046 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
8047 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
8048 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
8049 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
8054 static boolean checkPropertiesConfig(int element)
8058 if (IS_GEM(element) ||
8059 IS_CUSTOM_ELEMENT(element) ||
8060 IS_GROUP_ELEMENT(element) ||
8061 IS_ENVELOPE(element) ||
8062 ELEM_IS_PLAYER(element) ||
8063 HAS_EDITOR_CONTENT(element) ||
8064 CAN_GROW(element) ||
8065 COULD_MOVE_INTO_ACID(element) ||
8066 MAYBE_DONT_COLLIDE_WITH(element))
8069 for (i = 0; elements_with_counter[i].element != -1; i++)
8070 if (elements_with_counter[i].element == element)
8076 static void DrawPropertiesConfig()
8078 int max_num_element_counters = 4;
8079 int num_element_counters = 0;
8082 if (!checkPropertiesConfig(properties_element))
8084 PrintInfoText("No configuration options available.", FONT_TEXT_1, 0);
8089 /* check if there are elements where a value can be chosen for */
8090 for (i = 0; elements_with_counter[i].element != -1; i++)
8092 if (elements_with_counter[i].element == properties_element)
8094 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
8096 counterbutton_info[counter_id].y =
8097 ED_ELEMENT_SETTINGS_YPOS(
8098 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
8099 (CAN_GROW(properties_element) ? 1 : 0) +
8100 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
8101 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
8102 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
8103 num_element_counters);
8105 counterbutton_info[counter_id].value = elements_with_counter[i].value;
8106 counterbutton_info[counter_id].text_right= elements_with_counter[i].text;
8108 if (properties_element == EL_GAME_OF_LIFE ||
8109 properties_element == EL_BIOMAZE)
8111 counterbutton_info[counter_id].min_value = 0; /* min neighbours */
8112 counterbutton_info[counter_id].max_value = 8; /* max neighbours */
8116 /* !!! CHANGE THIS FOR CERTAIN ELEMENTS !!! */
8117 counterbutton_info[counter_id].min_value = MIN_SCORE;
8118 counterbutton_info[counter_id].max_value = MAX_SCORE;
8121 MapCounterButtons(counter_id);
8123 num_element_counters++;
8124 if (num_element_counters >= max_num_element_counters)
8129 if (HAS_EDITOR_CONTENT(properties_element))
8131 /* draw stickybutton gadget */
8132 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
8134 if (IS_AMOEBOID(properties_element))
8135 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
8136 else if (properties_element == EL_YAMYAM ||
8137 properties_element == EL_YAMYAM_LEFT ||
8138 properties_element == EL_YAMYAM_RIGHT ||
8139 properties_element == EL_YAMYAM_UP ||
8140 properties_element == EL_YAMYAM_DOWN)
8141 DrawYamYamContentAreas();
8142 else if (properties_element == EL_EMC_MAGIC_BALL)
8144 DrawMagicBallContentAreas();
8146 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
8147 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_STATE);
8149 else if (properties_element == EL_EMC_ANDROID)
8150 DrawAndroidElementArea(properties_element);
8153 if (ELEM_IS_PLAYER(properties_element))
8155 int player_nr = GET_PLAYER_NR(properties_element);
8157 /* these properties can be set for every player individually */
8159 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
8161 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
8162 &level.start_element[player_nr];
8163 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
8164 &level.artwork_element[player_nr];
8165 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
8166 &level.explosion_element[player_nr];
8168 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
8169 &level.use_start_element[player_nr];
8170 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
8171 &level.use_artwork_element[player_nr];
8172 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
8173 &level.use_explosion_element[player_nr];
8174 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
8175 &level.initial_player_gravity[player_nr];
8177 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
8178 &level.initial_player_stepsize[player_nr];
8180 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
8181 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
8182 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
8183 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
8184 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
8185 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
8186 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
8187 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
8188 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
8189 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
8190 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
8191 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
8192 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
8194 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
8195 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
8196 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
8198 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
8200 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
8202 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
8203 &level.initial_inventory_content[player_nr][0];
8205 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
8206 &level.initial_inventory_size[player_nr];
8208 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
8209 &level.use_initial_inventory[player_nr];
8211 /* draw checkbutton gadgets */
8212 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
8214 /* draw counter gadgets */
8215 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
8217 /* draw drawing area gadgets */
8218 DrawPlayerInitialInventoryArea(properties_element);
8222 if (IS_GEM(properties_element))
8223 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
8225 if (COULD_MOVE_INTO_ACID(properties_element) &&
8226 !ELEM_IS_PLAYER(properties_element) &&
8227 (!IS_CUSTOM_ELEMENT(properties_element) ||
8228 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
8230 /* set position for checkbutton for "can move into acid" */
8231 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
8232 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
8233 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
8234 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 6 :
8235 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
8237 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
8240 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
8241 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
8243 if (properties_element == EL_SPRING)
8244 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
8246 if (properties_element == EL_TIME_ORB_FULL)
8247 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
8249 if (CAN_GROW(properties_element))
8251 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
8252 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
8254 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
8257 if (IS_ENVELOPE(properties_element))
8259 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
8260 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
8261 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
8262 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
8263 int envelope_nr = properties_element - EL_ENVELOPE_1;
8265 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
8266 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
8268 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
8269 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
8271 /* display counter to choose size of envelope text area */
8272 MapCounterButtons(counter1_id);
8273 MapCounterButtons(counter2_id);
8275 /* display checkbuttons to choose auto-wrap and alignment properties */
8276 MapCheckbuttonGadget(button1_id);
8277 MapCheckbuttonGadget(button2_id);
8279 DrawEnvelopeTextArea(envelope_nr);
8282 if (IS_CUSTOM_ELEMENT(properties_element))
8284 /* draw stickybutton gadget */
8285 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
8287 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
8289 /* draw checkbutton gadgets */
8290 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
8291 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
8292 MapCheckbuttonGadget(i);
8294 /* draw counter gadgets */
8295 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
8296 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
8297 MapCounterButtons(i);
8299 /* draw selectbox gadgets */
8300 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
8301 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
8302 MapSelectboxGadget(i);
8304 /* draw textbutton gadgets */
8305 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE);
8307 /* draw text input gadgets */
8308 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
8310 /* draw drawing area gadgets */
8311 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
8313 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
8315 /* draw checkbutton gadgets */
8316 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
8317 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
8318 MapCheckbuttonGadget(i);
8320 /* draw counter gadgets */
8321 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
8322 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
8323 MapCounterButtons(i);
8325 /* draw selectbox gadgets */
8326 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
8327 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
8328 MapSelectboxGadget(i);
8330 /* draw drawing area gadgets */
8331 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
8332 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
8333 DrawCustomContentArea();
8336 else if (IS_GROUP_ELEMENT(properties_element))
8338 /* draw stickybutton gadget */
8339 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
8341 /* draw checkbutton gadgets */
8342 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
8343 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE);
8345 /* draw counter gadgets */
8346 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
8348 /* draw selectbox gadgets */
8349 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
8351 /* draw textbutton gadgets */
8352 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE);
8354 /* draw drawing area gadgets */
8355 DrawGroupElementArea(properties_element);
8357 /* draw text input gadgets */
8358 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
8360 /* draw drawing area gadgets */
8361 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
8365 static void DrawPropertiesChangeDrawingAreas()
8367 if (IS_CUSTOM_ELEMENT(properties_element))
8369 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
8370 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
8371 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
8373 DrawCustomChangeContentArea();
8376 redraw_mask |= REDRAW_FIELD;
8379 static void DrawPropertiesChange()
8383 /* needed to initially set selectbox options for special action options */
8384 setSelectboxSpecialActionOptions();
8386 /* draw stickybutton gadget */
8387 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
8389 /* draw checkbutton gadgets */
8390 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
8391 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
8392 MapCheckbuttonGadget(i);
8394 /* draw counter gadgets */
8395 for (i = ED_COUNTER_ID_CHANGE_FIRST;
8396 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
8397 MapCounterButtons(i);
8399 /* draw selectbox gadgets */
8400 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
8401 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
8402 MapSelectboxGadget(i);
8404 /* draw textbutton gadgets */
8405 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
8406 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
8407 MapTextbuttonGadget(i);
8409 /* draw graphicbutton gadgets */
8410 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
8411 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
8412 MapGraphicbuttonGadget(i);
8414 /* draw drawing area gadgets */
8415 DrawPropertiesChangeDrawingAreas();
8418 static void DrawEditorElementAnimation(int x, int y)
8420 int graphic = el2img(properties_element);
8421 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
8422 custom_element.ce_value_fixed_initial :
8423 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
8424 custom_element.collect_score_initial : FrameCounter);
8426 DrawGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
8429 static void DrawEditorElementName(int x, int y, int element)
8431 char *element_name = getElementInfoText(element);
8432 int font_nr = FONT_TEXT_1;
8433 int font_width = getFontWidth(font_nr);
8434 int font_height = getFontHeight(font_nr);
8435 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_XPOS(0);
8436 int max_chars_per_line = max_text_width / font_width;
8437 char buffer[max_chars_per_line + 1];
8439 if (strlen(element_name) <= max_chars_per_line)
8440 DrawTextS(x, y, font_nr, element_name);
8443 int next_pos = max_chars_per_line;
8445 strncpy(buffer, element_name, max_chars_per_line);
8446 buffer[max_chars_per_line] = '\0';
8448 if (element_name[max_chars_per_line] == ' ')
8454 for (i = max_chars_per_line - 1; i >= 0; i--)
8455 if (buffer[i] == ' ')
8458 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
8465 DrawTextS(x, y - font_height / 2, font_nr, buffer);
8467 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
8468 buffer[max_chars_per_line] = '\0';
8470 DrawTextS(x, y + font_height / 2, font_nr, buffer);
8474 static void DrawPropertiesWindow()
8479 stick_element_properties_window = FALSE;
8481 /* make sure that previous properties edit mode exists for this element */
8482 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
8483 !IS_CUSTOM_ELEMENT(properties_element))
8484 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
8486 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
8487 !ELEM_IS_PLAYER(properties_element) &&
8488 !IS_CUSTOM_ELEMENT(properties_element))
8489 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
8491 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
8492 (ELEM_IS_PLAYER(properties_element) ||
8493 IS_CUSTOM_ELEMENT(properties_element)))
8494 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
8496 CopyElementPropertiesToEditor(properties_element);
8498 UnmapLevelEditorWindowGadgets();
8499 UnmapLevelEditorToolboxDrawingGadgets();
8500 UnmapLevelEditorToolboxCustomGadgets();
8502 if (IS_CUSTOM_ELEMENT(properties_element) ||
8503 IS_GROUP_ELEMENT(properties_element))
8504 MapLevelEditorToolboxCustomGadgets();
8506 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
8510 DrawTextSCentered(ED_SETTINGS1_YPOS, FONT_TITLE_1, "Element Settings");
8512 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS1_YPOS,
8513 "Element Settings", FONT_TITLE_1);
8516 FrameCounter = 0; /* restart animation frame counter */
8518 DrawElementBorder(SX + xstart * MINI_TILEX,
8519 SY + ystart * MINI_TILEY + MINI_TILEY / 2,
8520 TILEX, TILEY, FALSE);
8522 DrawEditorElementAnimation(SX + xstart * MINI_TILEX,
8523 SY + ystart * MINI_TILEY + MINI_TILEY / 2);
8525 DrawEditorElementName((xstart + 3) * MINI_TILEX + 1,
8526 (ystart + 1) * MINI_TILEY + 1,
8527 properties_element);
8529 DrawPropertiesTabulatorGadgets();
8531 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
8532 DrawPropertiesInfo();
8533 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
8534 DrawPropertiesChange();
8535 else /* (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2]) */
8536 DrawPropertiesConfig();
8539 static void UpdateCustomElementGraphicGadgets()
8543 ModifyEditorElementList();
8544 RedrawDrawingElements();
8546 /* force redraw of all mapped drawing area gadgets */
8547 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
8549 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
8556 static int getOpenDirectionFromTube(int element)
8560 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
8561 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
8562 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
8563 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
8564 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
8565 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
8566 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
8567 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
8568 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
8569 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
8570 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
8576 static int getTubeFromOpenDirection(int direction)
8580 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
8581 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
8582 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
8583 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
8584 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
8585 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
8586 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
8587 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
8588 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
8589 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
8590 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
8592 /* if only one direction, fall back to simple tube with that direction */
8593 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
8594 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
8595 case (MV_UP): return EL_TUBE_VERTICAL;
8596 case (MV_DOWN): return EL_TUBE_VERTICAL;
8602 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
8604 int element_new = getTubeFromOpenDirection(direction);
8606 return (element_new != EL_EMPTY ? element_new : element_old);
8609 static int getOpenDirectionFromBelt(int element)
8611 int belt_dir = getBeltDirFromBeltElement(element);
8613 return (belt_dir == MV_LEFT ? MV_RIGHT :
8614 belt_dir == MV_RIGHT ? MV_LEFT :
8615 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
8618 static int getBeltFromNrAndOpenDirection(int nr, int direction)
8620 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
8621 direction == MV_RIGHT ? MV_LEFT :
8622 direction == MV_HORIZONTAL ? MV_NONE : direction);
8624 if (direction == MV_NONE)
8627 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
8630 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
8633 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
8635 return (element_new != EL_EMPTY ? element_new : element_old);
8638 static int getOpenDirectionFromPool(int element)
8642 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
8643 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
8644 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
8645 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
8646 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
8647 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
8653 static int getPoolFromOpenDirection(int direction)
8657 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
8658 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
8659 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
8660 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
8661 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
8662 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
8668 static int getPoolFromOpenDirectionExt(int direction, int help_element)
8670 int element = getPoolFromOpenDirection(direction);
8671 int help_direction = getOpenDirectionFromPool(help_element);
8673 if (element == EL_EMPTY)
8675 int help_direction_vertical = help_direction & MV_VERTICAL;
8677 element = getPoolFromOpenDirection(direction | help_direction_vertical);
8680 if (element == EL_EMPTY)
8682 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
8684 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
8690 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
8692 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
8694 return (element_new != EL_EMPTY ? element_new : element_old);
8697 static int getOpenDirectionFromPillar(int element)
8701 case EL_EMC_WALL_1: return (MV_DOWN);
8702 case EL_EMC_WALL_2: return (MV_VERTICAL);
8703 case EL_EMC_WALL_3: return (MV_UP);
8709 static int getPillarFromOpenDirection(int direction)
8713 case (MV_DOWN): return EL_EMC_WALL_1;
8714 case (MV_VERTICAL): return EL_EMC_WALL_2;
8715 case (MV_UP): return EL_EMC_WALL_3;
8721 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
8723 int element_new = getPillarFromOpenDirection(direction);
8725 return (element_new != EL_EMPTY ? element_new : element_old);
8728 static int getOpenDirectionFromSteel2(int element)
8732 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
8733 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
8734 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
8735 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
8736 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
8737 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
8738 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
8739 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
8745 static int getSteel2FromOpenDirection(int direction)
8749 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
8750 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
8751 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
8752 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
8753 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
8754 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
8755 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
8756 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
8762 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
8764 int element_new = getSteel2FromOpenDirection(direction);
8766 return (element_new != EL_EMPTY ? element_new : element_old);
8769 static int getOpenDirectionFromChip(int element)
8773 case EL_SP_CHIP_SINGLE: return (MV_NONE);
8774 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
8775 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
8776 case EL_SP_CHIP_TOP: return (MV_DOWN);
8777 case EL_SP_CHIP_BOTTOM: return (MV_UP);
8783 static int getChipFromOpenDirection(int direction)
8787 case (MV_NONE): return EL_SP_CHIP_SINGLE;
8788 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
8789 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
8790 case (MV_UP): return EL_SP_CHIP_BOTTOM;
8791 case (MV_DOWN): return EL_SP_CHIP_TOP;
8797 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
8799 int element_new = getChipFromOpenDirection(direction);
8801 return (element_new != EL_EMPTY ? element_new : element_old);
8804 static int getClosedTube(int x, int y)
8806 static int xy[4][2] =
8813 int element_old = IntelliDrawBuffer[x][y];
8814 int direction_old = getOpenDirectionFromTube(element_old);
8815 int direction_new = MV_NONE;
8818 for (i = 0; i < NUM_DIRECTIONS; i++)
8820 int xx = x + xy[i][0];
8821 int yy = y + xy[i][1];
8822 int dir = MV_DIR_FROM_BIT(i);
8823 int dir_opposite = MV_DIR_OPPOSITE(dir);
8825 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
8826 (direction_old & dir) &&
8827 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
8828 direction_new |= dir;
8831 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
8834 static int getClosedBelt(int x, int y)
8836 static int xy[4][2] =
8843 int element_old = IntelliDrawBuffer[x][y];
8844 int nr = getBeltNrFromBeltElement(element_old);
8845 int direction_old = getOpenDirectionFromBelt(element_old);
8846 int direction_new = MV_NONE;
8849 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
8851 int xx = x + xy[i][0];
8852 int yy = y + xy[i][1];
8853 int dir = MV_DIR_FROM_BIT(i);
8854 int dir_opposite = MV_DIR_OPPOSITE(dir);
8856 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
8857 (direction_old & dir) &&
8858 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
8859 direction_new |= dir;
8862 return getBeltFromNrAndOpenDirection(nr, direction_new);
8865 static int getClosedPool(int x, int y)
8867 static int xy[4][2] =
8874 int element_old = IntelliDrawBuffer[x][y];
8875 int direction_old = getOpenDirectionFromPool(element_old);
8876 int direction_new = MV_NONE;
8879 for (i = 0; i < NUM_DIRECTIONS; i++)
8881 int xx = x + xy[i][0];
8882 int yy = y + xy[i][1];
8883 int dir = MV_DIR_FROM_BIT(i);
8884 int dir_opposite = MV_DIR_OPPOSITE(dir);
8886 if (IN_LEV_FIELD(xx, yy) &&
8887 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
8888 (direction_old & dir) &&
8889 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
8890 direction_new |= dir;
8893 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
8896 static int getClosedPillar(int x, int y)
8898 static int xy[4][2] =
8905 int element_old = IntelliDrawBuffer[x][y];
8906 int direction_old = getOpenDirectionFromPillar(element_old);
8907 int direction_new = MV_NONE;
8910 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
8912 int xx = x + xy[i][0];
8913 int yy = y + xy[i][1];
8914 int dir = MV_DIR_FROM_BIT(i);
8915 int dir_opposite = MV_DIR_OPPOSITE(dir);
8917 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
8918 (direction_old & dir) &&
8919 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
8920 direction_new |= dir;
8923 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
8926 static int getClosedSteel2(int x, int y)
8928 static int xy[4][2] =
8935 int element_old = IntelliDrawBuffer[x][y];
8936 int direction_old = getOpenDirectionFromSteel2(element_old);
8937 int direction_new = MV_NONE;
8940 for (i = 0; i < NUM_DIRECTIONS; i++)
8942 int xx = x + xy[i][0];
8943 int yy = y + xy[i][1];
8944 int dir = MV_DIR_FROM_BIT(i);
8945 int dir_opposite = MV_DIR_OPPOSITE(dir);
8947 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
8948 (direction_old & dir) &&
8949 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
8950 direction_new |= dir;
8953 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
8956 static int getClosedChip(int x, int y)
8958 static int xy[4][2] =
8965 int element_old = IntelliDrawBuffer[x][y];
8966 int direction_old = getOpenDirectionFromChip(element_old);
8967 int direction_new = MV_NONE;
8970 for (i = 0; i < NUM_DIRECTIONS; i++)
8972 int xx = x + xy[i][0];
8973 int yy = y + xy[i][1];
8974 int dir = MV_DIR_FROM_BIT(i);
8975 int dir_opposite = MV_DIR_OPPOSITE(dir);
8977 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
8978 (direction_old & dir) &&
8979 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
8980 direction_new |= dir;
8983 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
8986 static void SetElementSimple(int x, int y, int element, boolean change_level)
8988 int sx = x - level_xpos;
8989 int sy = y - level_ypos;
8991 IntelliDrawBuffer[x][y] = element;
8994 Feld[x][y] = element;
8996 if (IN_ED_FIELD(sx, sy))
8997 DrawMiniElement(sx, sy, element);
9000 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
9001 int x2, int y2, int *element2,
9002 int (*close_function)(int, int),
9003 boolean change_level)
9005 /* set neighbour elements to newly determined connections */
9006 SetElementSimple(x1, y1, *element1, change_level);
9007 SetElementSimple(x2, y2, *element2, change_level);
9009 /* remove all open connections of neighbour elements */
9010 *element1 = close_function(x1, y1);
9011 *element2 = close_function(x2, y2);
9013 /* set neighbour elements to new, minimized connections */
9014 SetElementSimple(x1, y1, *element1, change_level);
9015 SetElementSimple(x2, y2, *element2, change_level);
9018 static void SetElementIntelliDraw(int x, int y, int new_element,
9019 boolean change_level, int button)
9021 static int xy[4][2] =
9028 static int last_x = -1;
9029 static int last_y = -1;
9030 int old_element = IntelliDrawBuffer[x][y];
9032 if (new_element == EL_UNDEFINED)
9040 if (IS_TUBE(new_element))
9042 int last_element_new = EL_UNDEFINED;
9043 int direction = MV_NONE;
9046 /* if old element is of same kind, keep all existing directions */
9047 if (IS_TUBE(old_element))
9048 direction |= getOpenDirectionFromTube(old_element);
9050 for (i = 0; i < NUM_DIRECTIONS; i++)
9052 int xx = x + xy[i][0];
9053 int yy = y + xy[i][1];
9055 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9056 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
9058 int dir = MV_DIR_FROM_BIT(i);
9059 int dir_opposite = MV_DIR_OPPOSITE(dir);
9060 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9061 int last_direction_old = getOpenDirectionFromTube(last_element_old);
9062 int last_direction_new = last_direction_old | dir_opposite;
9064 last_element_new = getTubeFromOpenDirection(last_direction_new);
9070 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
9072 if (last_element_new != EL_UNDEFINED)
9073 MergeAndCloseNeighbourElements(x, y, &new_element,
9074 last_x, last_y, &last_element_new,
9075 getClosedTube, change_level);
9077 else if (IS_BELT(new_element))
9079 int belt_nr = getBeltNrFromBeltElement(new_element);
9080 int last_element_new = EL_UNDEFINED;
9081 int direction = MV_NONE;
9084 /* if old element is of same kind, keep all existing directions */
9085 if (IS_BELT(old_element))
9086 direction |= getOpenDirectionFromBelt(old_element);
9088 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
9090 int xx = x + xy[i][0];
9091 int yy = y + xy[i][1];
9093 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9094 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
9096 int dir = MV_DIR_FROM_BIT(i);
9097 int dir_opposite = MV_DIR_OPPOSITE(dir);
9098 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9099 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
9100 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
9101 int last_direction_new = last_direction_old | dir_opposite;
9103 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
9104 last_direction_new);
9109 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
9111 if (last_element_new != EL_UNDEFINED)
9112 MergeAndCloseNeighbourElements(x, y, &new_element,
9113 last_x, last_y, &last_element_new,
9114 getClosedBelt, change_level);
9116 else if (IS_ACID_POOL_OR_ACID(new_element))
9118 int last_element_new = EL_UNDEFINED;
9119 int direction = MV_NONE;
9122 /* if old element is of same kind, keep all existing directions */
9123 if (IS_ACID_POOL_OR_ACID(old_element))
9124 direction |= getOpenDirectionFromPool(old_element);
9126 for (i = 0; i < NUM_DIRECTIONS; i++)
9128 int xx = x + xy[i][0];
9129 int yy = y + xy[i][1];
9131 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9132 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
9134 int dir = MV_DIR_FROM_BIT(i);
9135 int dir_opposite = MV_DIR_OPPOSITE(dir);
9136 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9137 int last_direction_old = getOpenDirectionFromPool(last_element_old);
9138 int last_direction_new = last_direction_old | dir_opposite;
9140 last_element_new = getPoolFromOpenDirection(last_direction_new);
9146 /* special corrections needed for intuitively correct acid pool drawing */
9147 if (last_element_new == EL_EMPTY)
9148 last_element_new = new_element;
9149 else if (last_element_new != EL_UNDEFINED)
9150 new_element = last_element_new;
9152 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
9154 if (last_element_new != EL_UNDEFINED)
9155 MergeAndCloseNeighbourElements(x, y, &new_element,
9156 last_x, last_y, &last_element_new,
9157 getClosedPool, change_level);
9159 else if (IS_EMC_PILLAR(new_element))
9161 int last_element_new = EL_UNDEFINED;
9162 int direction = MV_NONE;
9165 /* if old element is of same kind, keep all existing directions */
9166 if (IS_EMC_PILLAR(old_element))
9167 direction |= getOpenDirectionFromPillar(old_element);
9169 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
9171 int xx = x + xy[i][0];
9172 int yy = y + xy[i][1];
9174 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9175 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
9177 int dir = MV_DIR_FROM_BIT(i);
9178 int dir_opposite = MV_DIR_OPPOSITE(dir);
9179 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9180 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
9181 int last_direction_new = last_direction_old | dir_opposite;
9183 last_element_new = getPillarFromOpenDirection(last_direction_new);
9189 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
9191 if (last_element_new != EL_UNDEFINED)
9192 MergeAndCloseNeighbourElements(x, y, &new_element,
9193 last_x, last_y, &last_element_new,
9194 getClosedPillar, change_level);
9196 else if (IS_DC_STEELWALL_2(new_element))
9198 int last_element_new = EL_UNDEFINED;
9199 int direction = MV_NONE;
9202 /* if old element is of same kind, keep all existing directions */
9203 if (IS_DC_STEELWALL_2(old_element))
9204 direction |= getOpenDirectionFromSteel2(old_element);
9206 for (i = 0; i < NUM_DIRECTIONS; i++)
9208 int xx = x + xy[i][0];
9209 int yy = y + xy[i][1];
9211 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9212 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
9214 int dir = MV_DIR_FROM_BIT(i);
9215 int dir_opposite = MV_DIR_OPPOSITE(dir);
9216 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9217 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
9218 int last_direction_new = last_direction_old | dir_opposite;
9220 last_element_new = getSteel2FromOpenDirection(last_direction_new);
9226 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
9228 if (last_element_new != EL_UNDEFINED)
9229 MergeAndCloseNeighbourElements(x, y, &new_element,
9230 last_x, last_y, &last_element_new,
9231 getClosedSteel2, change_level);
9233 else if (IS_SP_CHIP(new_element))
9235 int last_element_new = EL_UNDEFINED;
9236 int direction = MV_NONE;
9239 /* (do not keep existing directions, regardless of kind of old element) */
9241 for (i = 0; i < NUM_DIRECTIONS; i++)
9243 int xx = x + xy[i][0];
9244 int yy = y + xy[i][1];
9246 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9247 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
9249 int dir = MV_DIR_FROM_BIT(i);
9250 int dir_opposite = MV_DIR_OPPOSITE(dir);
9251 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9252 int last_direction_old = getOpenDirectionFromChip(last_element_old);
9253 int last_direction_new = last_direction_old | dir_opposite;
9255 if (last_direction_old == MV_NONE)
9257 last_element_new = getChipFromOpenDirection(last_direction_new);
9260 else if (last_direction_old & (dir | dir_opposite))
9262 direction |= MV_DIR_OPPOSITE(last_direction_old);
9266 direction |= MV_DIR_OPPOSITE(dir);
9271 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
9273 if (last_element_new != EL_UNDEFINED)
9274 MergeAndCloseNeighbourElements(x, y, &new_element,
9275 last_x, last_y, &last_element_new,
9276 getClosedChip, change_level);
9278 else if (IS_SP_HARDWARE_BASE(new_element))
9280 int nr = GetSimpleRandom(6);
9282 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
9283 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
9284 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
9285 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
9286 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
9288 else if (new_element == EL_SP_HARDWARE_GREEN ||
9289 new_element == EL_SP_HARDWARE_BLUE ||
9290 new_element == EL_SP_HARDWARE_RED)
9292 int nr = GetSimpleRandom(3);
9294 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
9295 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
9297 else if (IS_GROUP_ELEMENT(new_element))
9299 boolean connected_drawing = FALSE;
9302 for (i = 0; i < NUM_DIRECTIONS; i++)
9304 int xx = x + xy[i][0];
9305 int yy = y + xy[i][1];
9307 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9308 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
9309 connected_drawing = TRUE;
9312 if (!connected_drawing)
9313 ResolveGroupElement(new_element);
9315 new_element = GetElementFromGroupElement(new_element);
9317 else if (IS_BELT_SWITCH(old_element))
9319 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
9320 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
9322 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
9323 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
9325 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
9329 static int swappable_elements[][2] =
9331 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
9332 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
9333 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
9334 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
9335 { EL_EMERALD, EL_WALL_EMERALD },
9336 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
9337 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
9338 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
9339 { EL_DIAMOND, EL_WALL_DIAMOND },
9340 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
9341 { EL_GATE_1, EL_GATE_1_GRAY },
9342 { EL_GATE_2, EL_GATE_2_GRAY },
9343 { EL_GATE_3, EL_GATE_3_GRAY },
9344 { EL_GATE_4, EL_GATE_4_GRAY },
9345 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
9346 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
9347 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
9348 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
9349 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
9350 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
9351 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
9352 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
9353 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
9354 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
9355 { EL_LAMP, EL_LAMP_ACTIVE },
9356 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
9357 { EL_SP_BASE, EL_SP_BUGGY_BASE },
9358 { EL_PEARL, EL_WALL_PEARL },
9359 { EL_CRYSTAL, EL_WALL_CRYSTAL },
9360 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
9361 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
9362 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
9363 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
9364 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
9365 { EL_LANDMINE, EL_DC_LANDMINE },
9366 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
9367 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
9368 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
9369 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
9370 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
9374 static int rotatable_elements[][4] =
9392 EL_BD_BUTTERFLY_RIGHT,
9393 EL_BD_BUTTERFLY_DOWN,
9394 EL_BD_BUTTERFLY_LEFT
9399 EL_BD_FIREFLY_RIGHT,
9433 EL_SP_GRAVITY_PORT_UP,
9434 EL_SP_GRAVITY_PORT_RIGHT,
9435 EL_SP_GRAVITY_PORT_DOWN,
9436 EL_SP_GRAVITY_PORT_LEFT
9447 EL_BALLOON_SWITCH_UP,
9448 EL_BALLOON_SWITCH_RIGHT,
9449 EL_BALLOON_SWITCH_DOWN,
9450 EL_BALLOON_SWITCH_LEFT
9454 EL_SP_GRAVITY_ON_PORT_UP,
9455 EL_SP_GRAVITY_ON_PORT_RIGHT,
9456 EL_SP_GRAVITY_ON_PORT_DOWN,
9457 EL_SP_GRAVITY_ON_PORT_LEFT
9461 EL_SP_GRAVITY_OFF_PORT_UP,
9462 EL_SP_GRAVITY_OFF_PORT_RIGHT,
9463 EL_SP_GRAVITY_OFF_PORT_DOWN,
9464 EL_SP_GRAVITY_OFF_PORT_LEFT
9476 for (i = 0; swappable_elements[i][0] != -1; i++)
9478 int element1 = swappable_elements[i][0];
9479 int element2 = swappable_elements[i][1];
9481 if (old_element == element1 || old_element == element2)
9482 new_element = (old_element == element1 ? element2 : element1);
9485 for (i = 0; rotatable_elements[i][0] != -1; i++)
9487 for (j = 0; j < 4; j++)
9489 int element = rotatable_elements[i][j];
9491 if (old_element == element)
9492 new_element = (button == 1 ? rotatable_elements[i][(j + 3) % 4] :
9493 button == 2 ? rotatable_elements[i][0] :
9494 button == 3 ? rotatable_elements[i][(j + 1) % 4] :
9500 SetElementSimple(x, y, new_element, change_level);
9506 static void ResetIntelliDraw()
9510 for (x = 0; x < lev_fieldx; x++)
9511 for (y = 0; y < lev_fieldy; y++)
9512 IntelliDrawBuffer[x][y] = Feld[x][y];
9514 SetElementIntelliDraw(-1, -1, EL_UNDEFINED, FALSE, -1);
9517 static void SetElementExt(int x, int y, int element, boolean change_level,
9521 SetElementSimple(x, y, Feld[x][y], change_level);
9522 else if (GetKeyModState() & KMOD_Shift)
9523 SetElementIntelliDraw(x, y, element, change_level, button);
9525 SetElementSimple(x, y, element, change_level);
9528 static void SetElement(int x, int y, int element)
9530 SetElementExt(x, y, element, TRUE, -1);
9533 static void SetElementButton(int x, int y, int element, int button)
9535 SetElementExt(x, y, element, TRUE, button);
9538 static void DrawLineElement(int sx, int sy, int element, boolean change_level)
9540 int lx = sx + level_xpos;
9541 int ly = sy + level_ypos;
9543 SetElementExt(lx, ly, element, change_level, -1);
9546 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
9547 int element, boolean change_level)
9549 int xsize = ABS(to_x - from_x);
9550 int ysize = ABS(to_y - from_y);
9551 int dx = (to_x < from_x ? -1 : +1);
9552 int dy = (to_y < from_y ? -1 : +1);
9555 if (from_y == to_y) /* horizontal line */
9557 for (i = 0; i <= xsize; i++)
9558 DrawLineElement(from_x + i * dx, from_y, element, change_level);
9560 else if (from_x == to_x) /* vertical line */
9562 for (i = 0; i <= ysize; i++)
9563 DrawLineElement(from_x, from_y + i * dy, element, change_level);
9565 else /* diagonal line */
9567 if (ysize < xsize) /* a < 1 */
9569 float a = (float)ysize / (float)xsize;
9571 for (i = 0; i <= xsize; i++)
9574 int y = dy * (int)(a * i + 0.5);
9576 DrawLineElement(from_x + x, from_y + y, element, change_level);
9581 float a = (float)xsize / (float)ysize;
9583 for (i = 0; i <= ysize; i++)
9585 int x = dx * (int)(a * i + 0.5);
9588 DrawLineElement(from_x + x, from_y + y, element, change_level);
9594 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
9595 int element, boolean change_level)
9597 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
9598 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
9599 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
9600 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
9603 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
9604 int element, boolean change_level)
9609 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
9611 for (y = from_y; y <= to_y; y++)
9612 DrawLine(from_x, y, to_x, y, element, change_level);
9615 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
9616 int element, boolean change_level)
9618 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
9619 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
9620 int len_x = ABS(to_x - from_x);
9621 int len_y = ABS(to_y - from_y);
9624 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
9626 /* not optimal (some points get drawn twice) but simple,
9627 and fast enough for the few points we are drawing */
9629 for (x = 0; x <= radius; x++)
9633 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
9635 sx = from_x + x * (from_x < to_x2 ? +1 : -1);
9636 sy = from_y + y * (from_y < to_y2 ? +1 : -1);
9637 lx = sx + level_xpos;
9638 ly = sy + level_ypos;
9640 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
9641 DrawLineElement(sx, sy, element, change_level);
9644 for (y = 0; y <= radius; y++)
9648 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
9650 sx = from_x + x * (from_x < to_x2 ? +1 : -1);
9651 sy = from_y + y * (from_y < to_y2 ? +1 : -1);
9652 lx = sx + level_xpos;
9653 ly = sy + level_ypos;
9655 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
9656 DrawLineElement(sx, sy, element, change_level);
9660 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
9661 int element, boolean change_level)
9663 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
9664 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
9666 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
9669 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
9671 #if DRAW_CIRCLES_BUTTON_AVAILABLE
9672 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
9673 int element, boolean change_level)
9675 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
9676 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
9677 int mirror_to_x2 = from_x - (to_x2 - from_x);
9678 int mirror_to_y2 = from_y - (to_y2 - from_y);
9680 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
9681 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
9682 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
9683 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element,change_level);
9687 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
9689 int from_sx, from_sy;
9693 swap_numbers(&from_x, &to_x);
9696 swap_numbers(&from_y, &to_y);
9698 from_sx = SX + from_x * MINI_TILEX;
9699 from_sy = SY + from_y * MINI_TILEY;
9700 to_sx = SX + to_x * MINI_TILEX + MINI_TILEX - 1;
9701 to_sy = SY + to_y * MINI_TILEY + MINI_TILEY - 1;
9703 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
9704 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
9705 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
9706 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
9708 if (from_x == to_x && from_y == to_y)
9709 MarkTileDirty(from_x/2, from_y/2);
9711 redraw_mask |= REDRAW_FIELD;
9714 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
9715 int element, boolean change_level)
9717 if (element == -1 || change_level)
9718 DrawBox(from_x, from_y, to_x, to_y, -1, FALSE);
9720 DrawAreaBorder(from_x, from_y, to_x, to_y);
9723 /* values for CopyBrushExt() */
9724 #define CB_AREA_TO_BRUSH 0
9725 #define CB_BRUSH_TO_CURSOR 1
9726 #define CB_BRUSH_TO_LEVEL 2
9727 #define CB_DELETE_OLD_CURSOR 3
9728 #define CB_DUMP_BRUSH 4
9729 #define CB_DUMP_BRUSH_SMALL 5
9731 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
9732 int button, int mode)
9734 static short brush_buffer[MAX_ED_FIELDX][MAX_ED_FIELDY];
9735 static int brush_width, brush_height;
9736 static int last_cursor_x = -1, last_cursor_y = -1;
9737 static boolean delete_old_brush;
9738 int new_element = BUTTON_ELEMENT(button);
9741 if (mode == CB_DUMP_BRUSH ||
9742 mode == CB_DUMP_BRUSH_SMALL)
9744 if (!draw_with_brush)
9746 Error(ERR_WARN, "no brush selected");
9751 for (y = 0; y < brush_height; y++)
9753 for (x = 0; x < brush_width; x++)
9755 int element = brush_buffer[x][y];
9756 int element_mapped = element;
9758 if (IS_CUSTOM_ELEMENT(element))
9759 element_mapped = EL_CUSTOM_START;
9760 else if (IS_GROUP_ELEMENT(element))
9761 element_mapped = EL_GROUP_START;
9762 else if (element >= NUM_FILE_ELEMENTS)
9763 element_mapped = EL_UNKNOWN;
9765 printf("%c%03d", (mode == CB_DUMP_BRUSH ? '`' : '¸'), element_mapped);
9774 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
9777 if (mode == CB_AREA_TO_BRUSH)
9779 int from_lx, from_ly;
9782 swap_numbers(&from_x, &to_x);
9785 swap_numbers(&from_y, &to_y);
9787 brush_width = to_x - from_x + 1;
9788 brush_height = to_y - from_y + 1;
9790 from_lx = from_x + level_xpos;
9791 from_ly = from_y + level_ypos;
9793 for (y = 0; y < brush_height; y++)
9795 for (x = 0; x < brush_width; x++)
9797 brush_buffer[x][y] = Feld[from_lx + x][from_ly + y];
9800 DrawLineElement(from_x + x, from_y + y, new_element, TRUE);
9805 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
9807 delete_old_brush = FALSE;
9809 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
9810 mode == CB_BRUSH_TO_LEVEL)
9812 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
9813 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
9814 int cursor_from_x = cursor_x - brush_width / 2;
9815 int cursor_from_y = cursor_y - brush_height / 2;
9816 int border_from_x = cursor_x, border_from_y = cursor_y;
9817 int border_to_x = cursor_x, border_to_y = cursor_y;
9819 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
9820 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
9822 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
9823 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
9825 delete_old_brush = FALSE;
9829 for (y = 0; y < brush_height; y++)
9831 for (x = 0; x < brush_width; x++)
9833 int sx = cursor_from_x + x;
9834 int sy = cursor_from_y + y;
9835 int lx = sx + level_xpos;
9836 int ly = sy + level_ypos;
9837 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
9838 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
9839 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
9840 brush_buffer[x][y] : new_element);
9842 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
9844 if (sx < border_from_x)
9846 else if (sx > border_to_x)
9848 if (sy < border_from_y)
9850 else if (sy > border_to_y)
9853 DrawLineElement(sx, sy, element, change_level);
9858 if (mode != CB_DELETE_OLD_CURSOR)
9859 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
9861 last_cursor_x = cursor_x;
9862 last_cursor_y = cursor_y;
9863 delete_old_brush = TRUE;
9867 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
9870 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
9873 static void CopyBrushToLevel(int x, int y, int button)
9875 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
9878 static void CopyBrushToCursor(int x, int y)
9880 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
9883 static void DeleteBrushFromCursor()
9885 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
9890 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
9893 void DumpBrush_Small()
9895 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
9898 static void FloodFill(int from_x, int from_y, int fill_element)
9900 FloodFillLevel(from_x, from_y, fill_element, Feld, lev_fieldx, lev_fieldy);
9903 /* values for DrawLevelText() modes */
9905 #define TEXT_SETCURSOR 1
9906 #define TEXT_WRITECHAR 2
9907 #define TEXT_BACKSPACE 3
9908 #define TEXT_NEWLINE 4
9910 #define TEXT_QUERY_TYPING 6
9912 static int DrawLevelText(int sx, int sy, char letter, int mode)
9914 static short delete_buffer[MAX_LEV_FIELDX];
9915 static int start_sx, start_sy;
9916 static int last_sx, last_sy;
9917 static boolean typing = FALSE;
9918 int letter_element = EL_CHAR_ASCII0 + letter;
9921 /* map lower case letters to upper case and convert special characters */
9922 if (letter >= 'a' && letter <= 'z')
9923 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
9924 else if (letter == 'ä' || letter == 'Ä')
9925 letter_element = EL_CHAR_AUMLAUT;
9926 else if (letter == 'ö' || letter == 'Ö')
9927 letter_element = EL_CHAR_OUMLAUT;
9928 else if (letter == 'ü' || letter == 'Ü')
9929 letter_element = EL_CHAR_UUMLAUT;
9930 else if (letter == '^')
9931 letter_element = EL_CHAR_COPYRIGHT;
9933 letter_element = EL_CHAR_ASCII0 + letter;
9935 if (mode != TEXT_INIT)
9940 if (mode != TEXT_SETCURSOR)
9946 lx = last_sx + level_xpos;
9947 ly = last_sy + level_ypos;
9954 DrawLevelText(0, 0, 0, TEXT_END);
9957 start_sx = last_sx = sx;
9958 start_sy = last_sy = sy;
9959 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
9962 case TEXT_SETCURSOR:
9963 DrawMiniElement(last_sx, last_sy, Feld[lx][ly]);
9964 DrawAreaBorder(sx, sy, sx, sy);
9969 case TEXT_WRITECHAR:
9970 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
9972 delete_buffer[sx - start_sx] = Feld[lx][ly];
9973 Feld[lx][ly] = letter_element;
9975 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
9976 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
9977 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
9978 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
9980 DrawLevelText(0, 0, 0, TEXT_END);
9982 level.changed = TRUE;
9986 case TEXT_BACKSPACE:
9989 Feld[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
9990 DrawMiniElement(sx - 1, sy, Feld[lx - 1][ly]);
9991 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
9996 if (sy + 1 < ed_fieldy - 1 && ly + 1 < lev_fieldy - 1)
9997 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
9999 DrawLevelText(0, 0, 0, TEXT_END);
10003 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10004 DrawMiniElement(sx, sy, Feld[lx][ly]);
10008 case TEXT_QUERY_TYPING:
10018 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
10019 int element, boolean change_level)
10021 int lx = sx + level_xpos;
10022 int ly = sy + level_ypos;
10025 DrawMiniElement(sx, sy, Feld[lx][ly]);
10027 DrawAreaBorder(sx, sy, sx, sy);
10030 static void CheckLevelBorderElement(boolean redraw_playfield)
10032 int last_border_element = BorderElement;
10034 SetBorderElement();
10036 if (redraw_playfield && BorderElement != last_border_element)
10037 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10040 static void CopyLevelToUndoBuffer(int mode)
10042 static boolean accumulated_undo = FALSE;
10043 boolean new_undo_buffer_position = TRUE;
10048 case UNDO_IMMEDIATE:
10049 accumulated_undo = FALSE;
10052 case UNDO_ACCUMULATE:
10053 if (accumulated_undo)
10054 new_undo_buffer_position = FALSE;
10055 accumulated_undo = TRUE;
10062 if (new_undo_buffer_position)
10064 /* new position in undo buffer ring */
10065 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
10067 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
10068 undo_buffer_steps++;
10071 for (x = 0; x < lev_fieldx; x++)
10072 for (y = 0; y < lev_fieldy; y++)
10073 UndoBuffer[undo_buffer_position][x][y] = Feld[x][y];
10075 /* check if drawing operation forces change of border style */
10076 CheckLevelBorderElement(TRUE);
10078 level.changed = TRUE;
10081 static void RandomPlacement(int new_element)
10083 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
10084 int num_free_positions = 0;
10085 int num_percentage, num_elements;
10089 ResetIntelliDraw();
10092 /* determine number of free positions for randomly placing the new element */
10093 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
10095 free_position[x][y] =
10096 (random_placement_background_restricted ?
10097 Feld[x][y] == random_placement_background_element :
10098 Feld[x][y] != new_element);
10100 if (free_position[x][y])
10101 num_free_positions++;
10104 /* determine number of new elements to place there */
10105 num_percentage = num_free_positions * random_placement_value / 100;
10106 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
10107 num_percentage : random_placement_value);
10109 /* if less free positions than elements to place, fill all these positions */
10110 if (num_free_positions < num_elements)
10112 for (x = 0; x < lev_fieldx; x++)
10113 for (y = 0; y < lev_fieldy; y++)
10114 if (free_position[x][y])
10116 SetElement(x, y, new_element);
10118 Feld[x][y] = new_element;
10123 while (num_elements > 0)
10125 x = GetSimpleRandom(lev_fieldx);
10126 y = GetSimpleRandom(lev_fieldy);
10128 /* don't place element at the same position twice */
10129 if (free_position[x][y])
10131 free_position[x][y] = FALSE;
10133 SetElement(x, y, new_element);
10135 Feld[x][y] = new_element;
10142 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10143 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10146 void WrapLevel(int dx, int dy)
10148 int wrap_dx = lev_fieldx - dx;
10149 int wrap_dy = lev_fieldy - dy;
10152 for (x = 0; x < lev_fieldx; x++)
10153 for (y = 0; y < lev_fieldy; y++)
10154 FieldBackup[x][y] = Feld[x][y];
10156 for (x = 0; x < lev_fieldx; x++)
10157 for (y = 0; y < lev_fieldy; y++)
10159 FieldBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
10161 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10162 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
10165 static void HandleDrawingAreas(struct GadgetInfo *gi)
10167 static boolean started_inside_drawing_area = FALSE;
10168 int id = gi->custom_id;
10169 boolean button_press_event;
10170 boolean button_release_event;
10171 boolean inside_drawing_area = !gi->event.off_borders;
10172 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
10173 int actual_drawing_function;
10174 int button = gi->event.button;
10175 int new_element = BUTTON_ELEMENT(button);
10176 int sx = gi->event.x, sy = gi->event.y;
10177 int min_sx = 0, min_sy = 0;
10178 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
10179 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
10180 int lx = 0, ly = 0;
10181 int min_lx = 0, min_ly = 0;
10182 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
10185 /* handle info callback for each invocation of action callback */
10186 gi->callback_info(gi);
10188 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
10189 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
10191 /* make sure to stay inside drawing area boundaries */
10192 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
10193 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
10197 /* get positions inside level field */
10198 lx = sx + level_xpos;
10199 ly = sy + level_ypos;
10201 if (!IN_LEV_FIELD(lx, ly))
10202 inside_drawing_area = FALSE;
10204 /* make sure to stay inside level field boundaries */
10205 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
10206 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
10208 /* correct drawing area positions accordingly */
10209 sx = lx - level_xpos;
10210 sy = ly - level_ypos;
10213 if (button_press_event)
10214 started_inside_drawing_area = inside_drawing_area;
10216 if (!started_inside_drawing_area)
10219 if (!IS_VALID_BUTTON(button))
10222 if (!button && !button_release_event)
10225 /* automatically switch to 'single item' drawing mode, if needed */
10226 actual_drawing_function =
10227 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
10228 drawing_function : GADGET_ID_SINGLE_ITEMS);
10230 /* clicking into drawing area with pressed Control key picks element */
10231 if (GetKeyModState() & KMOD_Control)
10233 last_drawing_function = drawing_function;
10234 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
10237 if (GetKeyModState() & KMOD_Shift)
10239 if (button_press_event || button_release_event)
10240 ResetIntelliDraw();
10243 switch (actual_drawing_function)
10245 case GADGET_ID_SINGLE_ITEMS:
10248 if (button_release_event)
10250 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10252 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
10253 !inside_drawing_area)
10254 DeleteBrushFromCursor();
10257 ResetIntelliDraw();
10261 if (!button || button_release_event)
10264 if (draw_with_brush)
10267 if (!button_release_event)
10269 CopyBrushToLevel(sx, sy, button);
10274 else if (new_element != Feld[lx][ly])
10277 if (new_element == EL_PLAYER_1)
10279 /* remove player at old position */
10280 for (y = 0; y < lev_fieldy; y++)
10282 for (x = 0; x < lev_fieldx; x++)
10284 if (Feld[x][y] == EL_PLAYER_1)
10287 SetElement(x, y, EL_EMPTY);
10289 Feld[x][y] = EL_EMPTY;
10291 if (IN_ED_FIELD(x - level_xpos, y - level_ypos))
10292 DrawMiniElement(x - level_xpos, y - level_ypos, EL_EMPTY);
10294 if (x - level_xpos >= 0 && x - level_xpos < ed_fieldx &&
10295 y - level_ypos >= 0 && y - level_ypos < ed_fieldy)
10296 DrawMiniElement(x - level_xpos, y - level_ypos, EL_EMPTY);
10305 SetElementButton(lx, ly, new_element, button);
10307 Feld[lx][ly] = new_element;
10308 DrawMiniElement(sx, sy, new_element);
10314 int type_id = gi->custom_type_id;
10315 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
10317 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
10318 DrawMiniGraphicExt(drawto,
10319 gi->x + sx * MINI_TILEX,
10320 gi->y + sy * MINI_TILEY,
10321 el2edimg(new_element));
10323 DrawGraphicExt(drawto,
10324 gi->x + sx * TILEX,
10325 gi->y + sy * TILEY,
10326 el2img(new_element), 0);
10328 if (id == GADGET_ID_CUSTOM_GRAPHIC)
10329 new_element = GFX_ELEMENT(new_element);
10331 drawingarea_info[type_id].value[pos] = new_element;
10333 CopyElementPropertiesToGame(properties_element);
10335 if (id == GADGET_ID_CUSTOM_GRAPHIC)
10337 UpdateCustomElementGraphicGadgets();
10339 FrameCounter = 0; /* restart animation frame counter */
10344 case GADGET_ID_CONNECTED_ITEMS:
10346 static int last_sx = -1;
10347 static int last_sy = -1;
10349 if (button_release_event)
10350 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10354 if (!button_press_event)
10355 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
10363 case GADGET_ID_LINE:
10364 case GADGET_ID_ARC:
10365 case GADGET_ID_RECTANGLE:
10366 case GADGET_ID_FILLED_BOX:
10367 case GADGET_ID_GRAB_BRUSH:
10368 case GADGET_ID_TEXT:
10370 static int last_sx = -1;
10371 static int last_sy = -1;
10372 static int start_sx = -1;
10373 static int start_sy = -1;
10374 void (*draw_func)(int, int, int, int, int, boolean);
10376 if (drawing_function == GADGET_ID_LINE)
10377 draw_func = DrawLine;
10378 else if (drawing_function == GADGET_ID_ARC)
10379 draw_func = DrawArc;
10380 else if (drawing_function == GADGET_ID_RECTANGLE)
10381 draw_func = DrawBox;
10382 else if (drawing_function == GADGET_ID_FILLED_BOX)
10383 draw_func = DrawFilledBox;
10384 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
10385 draw_func = SelectArea;
10386 else /* (drawing_function == GADGET_ID_TEXT) */
10387 draw_func = SetTextCursor;
10389 if (button_press_event)
10391 draw_func(sx, sy, sx, sy, new_element, FALSE);
10392 start_sx = last_sx = sx;
10393 start_sy = last_sy = sy;
10395 if (drawing_function == GADGET_ID_TEXT)
10396 DrawLevelText(0, 0, 0, TEXT_END);
10398 else if (button_release_event)
10400 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
10401 if (drawing_function == GADGET_ID_GRAB_BRUSH)
10403 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
10404 CopyBrushToCursor(sx, sy);
10405 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
10407 draw_with_brush = TRUE;
10409 else if (drawing_function == GADGET_ID_TEXT)
10410 DrawLevelText(sx, sy, 0, TEXT_INIT);
10412 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10414 else if (last_sx != sx || last_sy != sy)
10416 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
10417 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
10424 case GADGET_ID_FLOOD_FILL:
10425 if (button_press_event && Feld[lx][ly] != new_element)
10427 FloodFill(lx, ly, new_element);
10428 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10429 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10433 case GADGET_ID_PICK_ELEMENT:
10434 if (button_release_event)
10435 ClickOnGadget(level_editor_gadget[last_drawing_function],
10437 else if (draw_level)
10438 PickDrawingElement(button, Feld[lx][ly]);
10441 int type_id = gi->custom_type_id;
10442 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
10444 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
10454 static void HandleCounterButtons(struct GadgetInfo *gi)
10456 int gadget_id = gi->custom_id;
10457 int counter_id = gi->custom_type_id;
10458 int button = gi->event.button;
10459 int *counter_value = counterbutton_info[counter_id].value;
10460 int step = BUTTON_STEPSIZE(button) *
10461 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
10463 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
10465 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
10466 boolean released = (gi->event.type == GD_EVENT_RELEASED);
10467 boolean level_changed = LevelChanged();
10469 if ((level_changed && pressed) || (!level_changed && released))
10472 if (level_changed && !Request("Level has changed ! Discard changes ?",
10475 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
10476 ModifyEditorCounterValue(counter_id, *counter_value);
10482 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
10483 *counter_value = gi->textinput.number_value;
10485 ModifyEditorCounterValue(counter_id, *counter_value + step);
10487 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
10489 LoadLevel(level_nr);
10490 LoadScore(level_nr);
10495 DrawEditModeWindow();
10500 switch (counter_id)
10502 case ED_COUNTER_ID_YAMYAM_CONTENT:
10503 DrawYamYamContentAreas();
10506 case ED_COUNTER_ID_BALL_CONTENT:
10507 DrawMagicBallContentAreas();
10510 case ED_COUNTER_ID_ANDROID_CONTENT:
10511 DrawAndroidElementArea(properties_element);
10514 case ED_COUNTER_ID_GROUP_CONTENT:
10515 DrawGroupElementArea(properties_element);
10516 CopyGroupElementPropertiesToGame(properties_element);
10519 case ED_COUNTER_ID_INVENTORY_SIZE:
10520 DrawPlayerInitialInventoryArea(properties_element);
10523 case ED_COUNTER_ID_ENVELOPE_XSIZE:
10524 case ED_COUNTER_ID_ENVELOPE_YSIZE:
10525 DrawEnvelopeTextArea(-1);
10528 case ED_COUNTER_ID_LEVEL_XSIZE:
10529 case ED_COUNTER_ID_LEVEL_YSIZE:
10530 lev_fieldx = level.fieldx;
10531 lev_fieldy = level.fieldy;
10538 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
10539 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
10540 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
10541 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
10542 CopyElementPropertiesToGame(properties_element);
10544 level.changed = TRUE;
10547 static void HandleTextInputGadgets(struct GadgetInfo *gi)
10549 int type_id = gi->custom_type_id;
10551 strcpy(textinput_info[type_id].value, gi->textinput.value);
10553 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
10555 CopyElementPropertiesToGame(properties_element);
10557 ModifyEditorElementList(); /* update changed button info text */
10560 level.changed = TRUE;
10563 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
10565 int type_id = gi->custom_type_id;
10568 strncpy(textarea_info[type_id].value, gi->textarea.value,
10569 MAX_ENVELOPE_TEXT_LEN);
10570 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
10572 /* !!! BUGGY !!! MAX_ENVELOPE_TEXT_LEN != MAX_GADGET_TEXTSIZE !!! */
10573 strcpy(textarea_info[type_id].value, gi->textarea.value);
10576 level.changed = TRUE;
10579 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
10581 int type_id = gi->custom_type_id;
10582 int value_old = *selectbox_info[type_id].value;
10583 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
10585 *selectbox_info[type_id].value = value_new;
10587 if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
10589 element_info[properties_element].current_change_page = gi->selectbox.index;
10591 DrawPropertiesWindow();
10593 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
10594 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
10595 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
10596 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
10597 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
10599 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
10601 /* when changing action type, also check action mode and action arg */
10602 if (value_old != value_new)
10603 setSelectboxSpecialActionVariablesIfNeeded();
10605 DrawPropertiesChange();
10608 CopyElementPropertiesToGame(properties_element);
10610 level.changed = TRUE;
10614 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
10616 int type_id = gi->custom_type_id;
10619 if (type_id >= ED_TEXTBUTTON_ID_PROPERTIES_FIRST &&
10620 type_id <= ED_TEXTBUTTON_ID_PROPERTIES_LAST)
10622 edit_mode_properties = gi->custom_type_id;
10624 DrawPropertiesWindow();
10626 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE)
10628 char *template_filename = getDefaultLevelFilename(-1);
10629 boolean new_template = !fileExists(template_filename);
10631 if (new_template ||
10632 Request("Save this template and kill the old ?", REQ_ASK))
10633 SaveLevelTemplate();
10636 Request("Template saved !", REQ_CONFIRM);
10638 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
10639 custom_element.num_change_pages < MAX_CHANGE_PAGES)
10641 struct ElementInfo *ei = &element_info[properties_element];
10643 setElementChangePages(ei, ei->num_change_pages + 1);
10645 /* set new change page to be new current change page */
10646 ei->current_change_page = ei->num_change_pages - 1;
10647 ei->change = &ei->change_page[ei->current_change_page];
10649 setElementChangeInfoToDefaults(ei->change);
10651 DrawPropertiesWindow();
10653 level.changed = TRUE;
10655 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
10656 custom_element.num_change_pages > MIN_CHANGE_PAGES)
10658 struct ElementInfo *ei = &element_info[properties_element];
10660 /* copy all change pages after change page to be deleted */
10661 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
10662 ei->change_page[i] = ei->change_page[i + 1];
10664 setElementChangePages(ei, ei->num_change_pages - 1);
10666 DrawPropertiesWindow();
10668 level.changed = TRUE;
10672 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
10674 int type_id = gi->custom_type_id;
10676 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
10677 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
10679 struct ElementInfo *ei = &element_info[properties_element];
10680 int step = BUTTON_STEPSIZE(gi->event.button);
10682 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
10683 ei->current_change_page += step;
10685 if (ei->current_change_page < 0)
10686 ei->current_change_page = 0;
10687 else if (ei->current_change_page >= ei->num_change_pages)
10688 ei->current_change_page = ei->num_change_pages - 1;
10690 DrawPropertiesWindow();
10692 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
10693 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
10695 struct ElementInfo *ei = &element_info[properties_element];
10696 int current_change_page = ei->current_change_page;
10698 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
10699 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
10700 ei->change_page[current_change_page];
10701 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
10703 ei->change_page[current_change_page] =
10704 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
10706 level.changed = TRUE;
10709 DrawPropertiesWindow();
10713 static void HandleRadiobuttons(struct GadgetInfo *gi)
10715 *radiobutton_info[gi->custom_type_id].value =
10716 radiobutton_info[gi->custom_type_id].checked_value;
10718 level.changed = TRUE;
10721 static void HandleCheckbuttons(struct GadgetInfo *gi)
10723 int type_id = gi->custom_type_id;
10725 *checkbutton_info[type_id].value ^= TRUE;
10727 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
10728 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
10729 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
10730 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
10731 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
10732 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
10733 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
10734 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE))
10736 CopyElementPropertiesToGame(properties_element);
10739 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
10741 UpdateCustomElementGraphicGadgets();
10743 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE)
10745 char *template_filename = getDefaultLevelFilename(-1);
10747 if (level.use_custom_template && !fileExists(template_filename))
10749 Request("No level template found !", REQ_CONFIRM);
10751 level.use_custom_template = FALSE;
10752 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
10757 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
10759 DrawEditModeWindow();
10762 level.changed = TRUE;
10765 static void HandleControlButtons(struct GadgetInfo *gi)
10767 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
10768 static int last_edit_mode = ED_MODE_DRAWING;
10769 static int last_custom_copy_mode = -1;
10770 int id = gi->custom_id;
10771 int button = gi->event.button;
10772 int step = BUTTON_STEPSIZE(button);
10773 int new_element = BUTTON_ELEMENT(button);
10776 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
10777 DrawLevelText(0, 0, 0, TEXT_END);
10779 if (id < ED_NUM_CTRL1_BUTTONS &&
10780 id != GADGET_ID_SINGLE_ITEMS &&
10781 id != GADGET_ID_PROPERTIES &&
10782 id != GADGET_ID_PICK_ELEMENT &&
10783 edit_mode != ED_MODE_DRAWING &&
10784 drawing_function != GADGET_ID_PICK_ELEMENT &&
10785 !(GetKeyModState() & KMOD_Control))
10787 DrawDrawingWindow();
10788 edit_mode = ED_MODE_DRAWING;
10791 /* element copy mode active, but no element button pressed => deactivate */
10792 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
10793 last_custom_copy_mode = -1;
10797 case GADGET_ID_SCROLL_LEFT:
10798 if (level_xpos >= 0)
10800 if (lev_fieldx < ed_fieldx - 2)
10803 level_xpos -= step;
10804 if (level_xpos < -1)
10807 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
10809 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10811 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
10812 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
10816 case GADGET_ID_SCROLL_RIGHT:
10817 if (level_xpos <= lev_fieldx - ed_fieldx)
10819 if (lev_fieldx < ed_fieldx - 2)
10822 level_xpos += step;
10823 if (level_xpos > lev_fieldx - ed_fieldx + 1)
10824 level_xpos = lev_fieldx - ed_fieldx + 1;
10826 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
10828 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10830 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
10831 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
10835 case GADGET_ID_SCROLL_UP:
10836 if (level_ypos >= 0)
10838 if (lev_fieldy < ed_fieldy - 2)
10841 level_ypos -= step;
10842 if (level_ypos < -1)
10845 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
10847 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10849 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
10850 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
10854 case GADGET_ID_SCROLL_DOWN:
10855 if (level_ypos <= lev_fieldy - ed_fieldy)
10857 if (lev_fieldy < ed_fieldy - 2)
10860 level_ypos += step;
10861 if (level_ypos > lev_fieldy - ed_fieldy + 1)
10862 level_ypos = lev_fieldy - ed_fieldy + 1;
10864 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_UP);
10866 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10868 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
10869 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
10873 case GADGET_ID_SCROLL_HORIZONTAL:
10874 level_xpos = gi->event.item_position - 1;
10875 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10878 case GADGET_ID_SCROLL_VERTICAL:
10879 level_ypos = gi->event.item_position - 1;
10880 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10883 case GADGET_ID_SCROLL_LIST_UP:
10884 case GADGET_ID_SCROLL_LIST_DOWN:
10885 case GADGET_ID_SCROLL_LIST_VERTICAL:
10886 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
10887 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
10890 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
10891 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
10893 if (element_shift < 0)
10895 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
10896 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
10898 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
10899 GDI_SCROLLBAR_ITEM_POSITION,
10900 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
10903 ModifyEditorElementList();
10907 case GADGET_ID_WRAP_LEFT:
10908 WrapLevel(-step, 0);
10911 case GADGET_ID_WRAP_RIGHT:
10912 WrapLevel(step, 0);
10915 case GADGET_ID_WRAP_UP:
10916 WrapLevel(0, -step);
10919 case GADGET_ID_WRAP_DOWN:
10920 WrapLevel(0, step);
10923 case GADGET_ID_SINGLE_ITEMS:
10924 case GADGET_ID_CONNECTED_ITEMS:
10925 case GADGET_ID_LINE:
10926 case GADGET_ID_ARC:
10927 case GADGET_ID_TEXT:
10928 case GADGET_ID_RECTANGLE:
10929 case GADGET_ID_FILLED_BOX:
10930 case GADGET_ID_FLOOD_FILL:
10931 case GADGET_ID_GRAB_BRUSH:
10932 case GADGET_ID_PICK_ELEMENT:
10933 if (drawing_function != GADGET_ID_PICK_ELEMENT)
10934 last_drawing_function = drawing_function;
10935 drawing_function = id;
10936 draw_with_brush = FALSE;
10939 case GADGET_ID_RANDOM_PLACEMENT:
10940 RandomPlacement(new_element);
10943 case GADGET_ID_PROPERTIES:
10944 if (edit_mode != ED_MODE_PROPERTIES)
10946 properties_element = new_element;
10947 DrawPropertiesWindow();
10948 edit_mode = ED_MODE_PROPERTIES;
10950 last_level_drawing_function = drawing_function;
10951 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
10956 DrawDrawingWindow();
10957 edit_mode = ED_MODE_DRAWING;
10959 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
10964 case GADGET_ID_CUSTOM_COPY_FROM:
10965 case GADGET_ID_CUSTOM_COPY_TO:
10966 case GADGET_ID_CUSTOM_EXCHANGE:
10967 last_custom_copy_mode = id;
10968 last_drawing_function = drawing_function;
10971 case GADGET_ID_CUSTOM_COPY:
10972 CopyCustomElement(properties_element, -1, id);
10975 case GADGET_ID_CUSTOM_PASTE:
10976 CopyCustomElement(-1, properties_element, id);
10979 case GADGET_ID_UNDO:
10980 if (undo_buffer_steps == 0)
10982 Request("Undo buffer empty !", REQ_CONFIRM);
10986 if (edit_mode != ED_MODE_DRAWING)
10988 DrawDrawingWindow();
10989 edit_mode = ED_MODE_DRAWING;
10992 undo_buffer_position =
10993 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
10994 undo_buffer_steps--;
10996 for (x = 0; x < lev_fieldx; x++)
10997 for (y = 0; y < lev_fieldy; y++)
10998 Feld[x][y] = UndoBuffer[undo_buffer_position][x][y];
11000 /* check if undo operation forces change of border style */
11001 CheckLevelBorderElement(FALSE);
11003 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11007 case GADGET_ID_INFO:
11008 if (edit_mode != ED_MODE_INFO)
11010 last_edit_mode = edit_mode;
11011 edit_mode = ED_MODE_INFO;
11013 DrawLevelInfoWindow();
11017 edit_mode = last_edit_mode;
11019 DrawEditModeWindow();
11023 case GADGET_ID_CLEAR:
11024 if (edit_mode != ED_MODE_DRAWING)
11026 DrawDrawingWindow();
11027 edit_mode = ED_MODE_DRAWING;
11030 for (x = 0; x < MAX_LEV_FIELDX; x++)
11031 for (y = 0; y < MAX_LEV_FIELDY; y++)
11032 Feld[x][y] = (button == 1 ? EL_EMPTY : new_element);
11034 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
11036 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11039 case GADGET_ID_SAVE:
11040 if (leveldir_current->readonly)
11042 Request("This level is read only !", REQ_CONFIRM);
11046 if (!LevelContainsPlayer())
11047 Request("No Level without Gregor Mc Duffin please !", REQ_CONFIRM);
11050 char *level_filename = getDefaultLevelFilename(level_nr);
11051 boolean new_level = !fileExists(level_filename);
11054 Request("Save this level and kill the old ?", REQ_ASK))
11056 CopyPlayfield(Feld, level.field);
11058 SaveLevel(level_nr);
11062 Request("Level saved !", REQ_CONFIRM);
11064 level.changed = FALSE;
11068 case GADGET_ID_TEST:
11069 if (!LevelContainsPlayer())
11070 Request("No Level without Gregor Mc Duffin please !", REQ_CONFIRM);
11073 if (LevelChanged())
11074 level.game_version = GAME_VERSION_ACTUAL;
11076 CopyPlayfield(level.field, FieldBackup);
11077 CopyPlayfield(Feld, level.field);
11079 CopyNativeLevel_RND_to_Native(&level);
11081 UnmapLevelEditorGadgets();
11082 UndrawSpecialEditorDoor();
11084 CloseDoor(DOOR_CLOSE_ALL);
11086 DrawCompleteVideoDisplay();
11088 level_editor_test_game = TRUE;
11090 StartGameActions(FALSE, setup.autorecord, NEW_RANDOMIZE);
11094 case GADGET_ID_EXIT:
11095 RequestExitLevelEditor(TRUE, FALSE); /* if level has changed, ask user */
11099 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
11100 id <= GADGET_ID_ELEMENTLIST_LAST)
11102 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
11103 int new_element = editor_elements[element_position + element_shift];
11105 if (IS_EDITOR_CASCADE(new_element))
11109 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
11111 int *cascade_element= &(*editor_elements_info[i].headline_list)[0];
11112 boolean *cascade_value=editor_elements_info[i].setup_cascade_value;
11114 if (*cascade_element == new_element)
11116 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
11117 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
11119 /* update element selection list */
11120 ReinitializeElementList();
11121 ModifyEditorElementList();
11123 /* update cascading gadget info text */
11124 PrintEditorGadgetInfoText(level_editor_gadget[id]);
11126 /* save current editor cascading state */
11127 SaveSetup_EditorCascade();
11136 if (last_custom_copy_mode != -1)
11138 if (CopyCustomElement(properties_element, new_element,
11139 last_custom_copy_mode))
11141 ClickOnGadget(level_editor_gadget[last_drawing_function],
11144 last_custom_copy_mode = -1;
11150 PickDrawingElement(button, new_element);
11152 if (!stick_element_properties_window &&
11153 drawing_function != GADGET_ID_PICK_ELEMENT &&
11154 !(GetKeyModState() & KMOD_Control))
11156 properties_element = new_element;
11157 if (edit_mode == ED_MODE_PROPERTIES)
11158 DrawPropertiesWindow();
11161 if (drawing_function == GADGET_ID_PICK_ELEMENT)
11162 ClickOnGadget(level_editor_gadget[last_drawing_function],
11166 else if (gi->event.type == GD_EVENT_PRESSED)
11167 printf("default: HandleControlButtons: GD_EVENT_PRESSED(%d)\n", id);
11168 else if (gi->event.type == GD_EVENT_RELEASED)
11169 printf("default: HandleControlButtons: GD_EVENT_RELEASED(%d)\n", id);
11170 else if (gi->event.type == GD_EVENT_MOVING)
11171 printf("default: HandleControlButtons: GD_EVENT_MOVING(%d)\n", id);
11173 printf("default: HandleControlButtons: ? (id == %d)\n", id);
11179 void HandleLevelEditorKeyInput(Key key)
11181 char letter = getCharFromKey(key);
11182 int button = MB_LEFTBUTTON;
11184 if (drawing_function == GADGET_ID_TEXT &&
11185 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
11188 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
11189 else if (key == KSYM_Delete || key == KSYM_BackSpace)
11190 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
11191 else if (key == KSYM_Return)
11192 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
11193 else if (key == KSYM_Escape)
11194 DrawLevelText(0, 0, 0, TEXT_END);
11196 else if (button_status == MB_RELEASED)
11198 int id = GADGET_ID_NONE;
11199 int new_element_shift = element_shift;
11205 id = GADGET_ID_SCROLL_LEFT;
11208 id = GADGET_ID_SCROLL_RIGHT;
11211 id = GADGET_ID_SCROLL_UP;
11214 id = GADGET_ID_SCROLL_DOWN;
11217 id = GADGET_ID_SCROLL_LIST_UP;
11218 button = MB_RIGHTBUTTON;
11220 case KSYM_Page_Down:
11221 id = GADGET_ID_SCROLL_LIST_DOWN;
11222 button = MB_RIGHTBUTTON;
11227 element_shift = (key == KSYM_Home ? 0 :
11228 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
11230 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
11231 GDI_SCROLLBAR_ITEM_POSITION,
11232 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
11234 ModifyEditorElementList();
11241 /* this is needed to prevent interference with running "True X-Mouse" */
11242 if (GetKeyModStateFromEvents() & KMOD_Control)
11245 /* check for last or next editor cascade block in element list */
11246 for (i = 0; i < num_editor_elements; i++)
11248 if ((key == KSYM_Insert && i == element_shift) ||
11249 (key == KSYM_Delete && new_element_shift > element_shift))
11252 /* jump to next cascade block (or to start of element list) */
11253 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
11254 new_element_shift = i;
11257 if (i < num_editor_elements)
11258 element_shift = new_element_shift;
11260 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
11261 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
11263 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
11264 GDI_SCROLLBAR_ITEM_POSITION,
11265 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
11267 ModifyEditorElementList();
11272 if (edit_mode == ED_MODE_DRAWING)
11274 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
11276 else if (edit_mode == ED_MODE_INFO)
11278 HandleControlButtons(level_editor_gadget[GADGET_ID_INFO]);
11280 else if (edit_mode == ED_MODE_PROPERTIES)
11282 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
11284 else /* should never happen */
11286 DrawDrawingWindow();
11287 edit_mode = ED_MODE_DRAWING;
11296 if (id != GADGET_ID_NONE)
11297 ClickOnGadget(level_editor_gadget[id], button);
11298 else if (letter == '.')
11299 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
11300 else if (key == KSYM_Return || key == setup.shortcut.toggle_pause)
11301 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
11303 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
11304 if (letter && letter == control_info[i].shortcut)
11305 if (!anyTextGadgetActive())
11306 ClickOnGadget(level_editor_gadget[i], button);
11310 void HandleLevelEditorIdle()
11312 static unsigned long action_delay = 0;
11313 unsigned long action_delay_value = GameFrameDelay;
11314 int xpos = 1, ypos = 2;
11317 if (edit_mode != ED_MODE_PROPERTIES)
11320 if (!DelayReached(&action_delay, action_delay_value))
11323 for (i = 0; i < ED_NUM_SELECTBOX; i++)
11325 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
11327 if (gi->mapped && gi->active && gi->selectbox.open)
11331 DrawEditorElementAnimation(SX + xpos * TILEX,
11332 SY + ypos * TILEY + MINI_TILEY / 2);
11334 MarkTileDirty(xpos, ypos);
11335 MarkTileDirty(xpos, ypos + 1);
11337 FrameCounter++; /* increase animation frame counter */
11340 void ClearEditorGadgetInfoText()
11342 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
11345 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
11347 char infotext[MAX_OUTPUT_LINESIZE + 1];
11348 char shortcut[MAX_OUTPUT_LINESIZE + 1];
11349 int max_infotext_len = getMaxInfoTextLength();
11351 if (gi == NULL || gi->info_text == NULL)
11354 strncpy(infotext, gi->info_text, max_infotext_len);
11355 infotext[max_infotext_len] = '\0';
11357 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
11359 int key = control_info[gi->custom_id].shortcut;
11363 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS) /* special case 1 */
11364 sprintf(shortcut, " ('.' or '%c')", key);
11365 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT) /* special case 2 */
11366 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
11367 else if (gi->custom_id == GADGET_ID_TEST) /* special case 3 */
11368 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
11369 else /* normal case */
11370 sprintf(shortcut, " ('%s%c')",
11371 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
11373 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
11374 strcat(infotext, shortcut);
11378 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, FONT_TEXT_2);
11381 void HandleEditorGadgetInfoText(void *ptr)
11383 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
11385 if (game_status != GAME_MODE_EDITOR)
11388 ClearEditorGadgetInfoText();
11390 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
11393 /* misuse this function to delete brush cursor, if needed */
11394 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
11395 DeleteBrushFromCursor();
11397 PrintEditorGadgetInfoText(gi);
11400 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
11402 static int start_lx, start_ly;
11403 int id = gi->custom_id;
11404 int type_id = gi->custom_type_id;
11405 int sx = gi->event.x;
11406 int sy = gi->event.y;
11407 int lx = sx + level_xpos;
11408 int ly = sy + level_ypos;
11409 int min_sx = 0, min_sy = 0;
11410 int max_sx = gi->drawing.area_xsize - 1;
11411 int max_sy = gi->drawing.area_ysize - 1;
11412 int actual_drawing_function = drawing_function;
11413 int max_infotext_len = getMaxInfoTextLength();
11414 char infotext[MAX_OUTPUT_LINESIZE + 1];
11417 infotext[0] = '\0'; /* start with empty info text */
11419 /* pressed Control key: simulate picking element */
11420 if (GetKeyModState() & KMOD_Control)
11421 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
11423 ClearEditorGadgetInfoText();
11425 if (gi->event.type == GD_EVENT_INFO_LEAVING)
11428 /* make sure to stay inside drawing area boundaries */
11429 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
11430 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
11432 if (id == GADGET_ID_DRAWING_LEVEL)
11436 int min_lx = 0, min_ly = 0;
11437 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
11439 /* get positions inside level field */
11440 lx = sx + level_xpos;
11441 ly = sy + level_ypos;
11443 /* make sure to stay inside level field boundaries */
11444 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
11445 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
11447 /* correct drawing area positions accordingly */
11448 sx = lx - level_xpos;
11449 sy = ly - level_ypos;
11452 if (IN_ED_FIELD(sx,sy) && IN_LEV_FIELD(lx, ly))
11454 if (button_status) /* if (gi->state == GD_BUTTON_PRESSED) */
11456 if (gi->event.type == GD_EVENT_PRESSED)
11462 switch (actual_drawing_function)
11464 case GADGET_ID_SINGLE_ITEMS:
11465 text = "Drawing single items";
11467 case GADGET_ID_CONNECTED_ITEMS:
11468 text = "Drawing connected items";
11470 case GADGET_ID_LINE:
11471 text = "Drawing line";
11473 case GADGET_ID_ARC:
11474 text = "Drawing arc";
11476 case GADGET_ID_TEXT:
11477 text = "Setting text cursor";
11479 case GADGET_ID_RECTANGLE:
11480 text = "Drawing rectangle";
11482 case GADGET_ID_FILLED_BOX:
11483 text = "Drawing filled box";
11485 case GADGET_ID_FLOOD_FILL:
11486 text = "Flood fill";
11488 case GADGET_ID_GRAB_BRUSH:
11489 text = "Grabbing brush";
11491 case GADGET_ID_PICK_ELEMENT:
11492 text = "Picking element";
11496 text = "Drawing position";
11500 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
11501 sprintf(infotext, "%s: %d, %d", text, lx, ly);
11503 sprintf(infotext, "%s: %d, %d", text,
11504 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
11506 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
11507 strncpy(infotext, getElementInfoText(Feld[lx][ly]), max_infotext_len);
11509 sprintf(infotext, "Level position: %d, %d", lx, ly);
11512 /* misuse this function to draw brush cursor, if needed */
11513 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
11515 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
11516 CopyBrushToCursor(sx, sy);
11518 DeleteBrushFromCursor();
11521 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
11523 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
11524 int element = drawingarea_info[type_id].value[pos];
11526 strncpy(infotext, getElementInfoText(element), max_infotext_len);
11530 if (id == GADGET_ID_CUSTOM_CONTENT)
11531 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
11532 else if (id == GADGET_ID_GROUP_CONTENT)
11533 sprintf(infotext, "group element position: %d", sx + 1);
11534 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
11535 id <= GADGET_ID_YAMYAM_CONTENT_7)
11536 sprintf(infotext, "content area %d position: %d, %d",
11537 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
11538 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
11539 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
11540 sprintf(infotext, "content area %d position: %d, %d",
11541 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
11542 else if (id == GADGET_ID_ANDROID_CONTENT)
11543 sprintf(infotext, "android element position: %d", sx + 1);
11544 else if (drawingarea_info[type_id].infotext != NULL)
11545 strcpy(infotext, drawingarea_info[type_id].infotext);
11548 infotext[max_infotext_len] = '\0';
11550 if (strlen(infotext) > 0)
11551 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, infotext);
11554 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
11555 boolean quick_quit)
11557 if (!ask_if_level_has_changed ||
11559 Request("Level has changed ! Exit without saving ?",
11560 REQ_ASK | REQ_STAY_OPEN))
11562 CloseDoor(DOOR_CLOSE_1);
11563 SetDoorState(DOOR_CLOSE_2);
11567 FadeSkipNextFadeIn();
11570 fading = fading_none;
11573 game_status = GAME_MODE_MAIN;
11575 DrawAndFadeInMainMenu(REDRAW_FIELD);
11582 CloseDoor(DOOR_CLOSE_1);
11583 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);