1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-2006 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
16 #include "libgame/libgame.h"
27 #define INFOTEXT_UNKNOWN_ELEMENT "unknown"
31 -----------------------------------------------------------------------------
32 screen and artwork graphic pixel position definitions
33 -----------------------------------------------------------------------------
36 /* positions in the level editor */
37 #define ED_WIN_MB_LEFT_XPOS 6
38 #define ED_WIN_MB_LEFT_YPOS 258
39 #define ED_WIN_MB_MIDDLE_XPOS 42
40 #define ED_WIN_MB_MIDDLE_YPOS ED_WIN_MB_LEFT_YPOS
41 #define ED_WIN_MB_RIGHT_XPOS 78
42 #define ED_WIN_MB_RIGHT_YPOS ED_WIN_MB_LEFT_YPOS
44 /* values for the control window */
45 #define ED_CTRL_NO_BUTTONS_GFX_XPOS 6
46 #define ED_CTRL_NO_BUTTONS_GFX_YPOS 286
47 #define ED_CTRL1_BUTTONS_GFX_YPOS 236
48 #define ED_CTRL2_BUTTONS_GFX_YPOS 236
49 #define ED_CTRL3_BUTTONS_GFX_YPOS 324
50 #define ED_CTRL4_BUTTONS_GFX_XPOS 44
51 #define ED_CTRL4_BUTTONS_GFX_YPOS 214
52 #define ED_CTRL1_BUTTONS_ALT_GFX_YPOS 142
53 #define ED_CTRL3_BUTTONS_ALT_GFX_YPOS 302
55 #define ED_CTRL1_BUTTON_XSIZE 22
56 #define ED_CTRL1_BUTTON_YSIZE 22
57 #define ED_CTRL1_BUTTONS_XPOS 6
58 #define ED_CTRL1_BUTTONS_YPOS 6
59 #define ED_CTRL2_BUTTON_XSIZE 30
60 #define ED_CTRL2_BUTTON_YSIZE 20
61 #define ED_CTRL2_BUTTONS_XPOS 5
62 #define ED_CTRL2_BUTTONS_YPOS 99
63 #define ED_CTRL3_BUTTON_XSIZE 22
64 #define ED_CTRL3_BUTTON_YSIZE 22
65 #define ED_CTRL3_BUTTONS_XPOS 6
66 #define ED_CTRL3_BUTTONS_YPOS 6
67 #define ED_CTRL4_BUTTON_XSIZE 22
68 #define ED_CTRL4_BUTTON_YSIZE 22
69 #define ED_CTRL4_BUTTONS_XPOS 6
70 #define ED_CTRL4_BUTTONS_YPOS 6
72 #define ED_CTRL1_BUTTONS_HORIZ 4
73 #define ED_CTRL1_BUTTONS_VERT 4
74 #define ED_CTRL2_BUTTONS_HORIZ 3
75 #define ED_CTRL2_BUTTONS_VERT 2
76 #define ED_CTRL3_BUTTONS_HORIZ 3
77 #define ED_CTRL3_BUTTONS_VERT 1
78 #define ED_CTRL4_BUTTONS_HORIZ 2
79 #define ED_CTRL4_BUTTONS_VERT 1
81 #define ED_NUM_CTRL1_BUTTONS (ED_CTRL1_BUTTONS_HORIZ * ED_CTRL1_BUTTONS_VERT)
82 #define ED_NUM_CTRL2_BUTTONS (ED_CTRL2_BUTTONS_HORIZ * ED_CTRL2_BUTTONS_VERT)
83 #define ED_NUM_CTRL3_BUTTONS (ED_CTRL3_BUTTONS_HORIZ * ED_CTRL3_BUTTONS_VERT)
84 #define ED_NUM_CTRL4_BUTTONS (ED_CTRL4_BUTTONS_HORIZ * ED_CTRL4_BUTTONS_VERT)
85 #define ED_NUM_CTRL1_2_BUTTONS (ED_NUM_CTRL1_BUTTONS + ED_NUM_CTRL2_BUTTONS)
86 #define ED_NUM_CTRL1_3_BUTTONS (ED_NUM_CTRL1_2_BUTTONS + ED_NUM_CTRL3_BUTTONS)
87 #define ED_NUM_CTRL_BUTTONS (ED_NUM_CTRL1_BUTTONS + \
88 ED_NUM_CTRL2_BUTTONS + \
89 ED_NUM_CTRL3_BUTTONS + \
92 /* values for the element list */
93 #define ED_ELEMENTLIST_XPOS 5
94 #define ED_ELEMENTLIST_YPOS 30
95 #define ED_ELEMENTLIST_XSIZE 20
96 #define ED_ELEMENTLIST_YSIZE 20
97 #define ED_ELEMENTLIST_BUTTONS_HORIZ 4
98 #define ED_ELEMENTLIST_BUTTONS_VERT 11
99 #define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \
100 ED_ELEMENTLIST_BUTTONS_VERT)
102 /* standard distances */
103 #define ED_BORDER_SIZE 3
104 #define ED_BORDER_TEXT_XSIZE 5
105 #define ED_BORDER_AREA_YSIZE 1
107 #define ED_GADGET_DISTANCE 2
108 #define ED_GADGET_TEXT_DISTANCE (2 * ED_GADGET_DISTANCE)
109 #define ED_DRAWINGAREA_TEXT_DISTANCE (ED_GADGET_TEXT_DISTANCE + \
112 /* values for the settings windows */
113 #define ED_LEVEL_SETTINGS_XSTART (3 * MINI_TILEX / 2)
114 #define ED_LEVEL_SETTINGS_YSTART (7 * MINI_TILEY)
116 #define ED_ELEMENT_SETTINGS_XSTART (3 * MINI_TILEX / 2)
117 #define ED_ELEMENT_SETTINGS_YSTART (10 * MINI_TILEY)
119 #define ED_XOFFSET_CHECKBOX (ED_CHECKBUTTON_XSIZE + \
120 2 * ED_GADGET_DISTANCE)
122 #define ED_SETTINGS_XOFFSET ED_XOFFSET_CHECKBOX
123 #define ED_SETTINGS_YOFFSET (3 * MINI_TILEY / 2)
124 #define ED_SETTINGS_TAB_XOFFSET 124
126 #define ED_LEVEL_SETTINGS_XPOS(n) (ED_LEVEL_SETTINGS_XSTART + \
127 (n) * ED_SETTINGS_XOFFSET)
128 #define ED_LEVEL_SETTINGS_YPOS(n) (ED_LEVEL_SETTINGS_YSTART + \
129 (n) * ED_SETTINGS_YOFFSET)
131 #define ED_ELEMENT_SETTINGS_XPOS(n) (ED_ELEMENT_SETTINGS_XSTART + \
132 (n) * ED_SETTINGS_XOFFSET)
133 #define ED_ELEMENT_SETTINGS_YPOS(n) (ED_ELEMENT_SETTINGS_YSTART + \
134 (n) * ED_SETTINGS_YOFFSET)
136 #define ED_LEVEL_SETTINGS_TABS_XPOS(n) (ED_LEVEL_SETTINGS_XPOS(0) + \
137 (n) * ED_SETTINGS_TAB_XOFFSET)
138 #define ED_LEVEL_SETTINGS_TABS_YPOS(n) (ED_LEVEL_SETTINGS_YSTART - \
141 #define ED_ELEMENT_SETTINGS_TABS_XPOS(n) (ED_ELEMENT_SETTINGS_XPOS(0) + \
142 (n) * ED_SETTINGS_TAB_XOFFSET)
143 #define ED_ELEMENT_SETTINGS_TABS_YPOS(n) (ED_ELEMENT_SETTINGS_YSTART - \
146 #define ED_SETTINGS1_YPOS MINI_TILEY
147 #define ED_SETTINGS2_XPOS MINI_TILEX
148 #define ED_SETTINGS2_YPOS (ED_SETTINGS1_YPOS + 12 * TILEY - 2)
150 /* values for counter gadgets */
151 #define ED_COUNTER_YSTART (ED_SETTINGS1_YPOS + 2 * TILEY)
152 #define ED_COUNTER_YDISTANCE (3 * MINI_TILEY)
153 #define ED_COUNTER_YPOS(n) (ED_COUNTER_YSTART + \
154 (n) * ED_COUNTER_YDISTANCE)
155 #define ED_COUNTER2_YPOS(n) (ED_COUNTER_YSTART + \
156 (n) * ED_COUNTER_YDISTANCE - 2)
158 /* values for element content drawing areas */
159 #define ED_AREA_1X1_SETTINGS_XPOS(n) (ED_ELEMENT_SETTINGS_XPOS(n))
160 #define ED_AREA_1X1_SETTINGS_YPOS(n) (ED_ELEMENT_SETTINGS_YPOS(n) + \
163 #define ED_AREA_3X3_SETTINGS_XPOS(n) (ED_ELEMENT_SETTINGS_XPOS(n))
164 #define ED_AREA_3X3_SETTINGS_YPOS(n) (ED_ELEMENT_SETTINGS_YPOS(n) + \
165 ED_GADGET_DISTANCE - MINI_TILEY)
168 #define ED_AREA_YAMYAM_CONTENT_XPOS(n) (2 * MINI_TILEX + \
169 5 * ((n) % 4) * MINI_TILEX)
170 #define ED_AREA_YAMYAM_CONTENT_YPOS(n) (11 * ED_SETTINGS_YOFFSET + \
171 6 * ((n) / 4) * MINI_TILEY)
173 /* magic ball content */
174 #define ED_AREA_MAGIC_BALL_CONTENT_XPOS(n) (2 * MINI_TILEX + \
175 5 * ((n) % 4) * MINI_TILEX)
176 #define ED_AREA_MAGIC_BALL_CONTENT_YPOS(n) (12 * ED_SETTINGS_YOFFSET + \
177 6 * ((n) / 4) * MINI_TILEY)
179 /* values for scrolling gadgets for drawing area */
180 #define ED_SCROLLBUTTON_XPOS 24
181 #define ED_SCROLLBUTTON_YPOS 0
182 #define ED_SCROLLBAR_XPOS 24
183 #define ED_SCROLLBAR_YPOS 64
185 #define ED_SCROLLBUTTON_XSIZE 16
186 #define ED_SCROLLBUTTON_YSIZE 16
188 #define ED_SCROLL_UP_XPOS (SXSIZE - ED_SCROLLBUTTON_XSIZE)
189 #define ED_SCROLL_UP_YPOS (0)
190 #define ED_SCROLL_DOWN_XPOS ED_SCROLL_UP_XPOS
191 #define ED_SCROLL_DOWN_YPOS (SYSIZE - 3 * ED_SCROLLBUTTON_YSIZE)
192 #define ED_SCROLL_LEFT_XPOS (0)
193 #define ED_SCROLL_LEFT_YPOS (SYSIZE - 2 * ED_SCROLLBUTTON_YSIZE)
194 #define ED_SCROLL_RIGHT_XPOS (SXSIZE - 2 * ED_SCROLLBUTTON_XSIZE)
195 #define ED_SCROLL_RIGHT_YPOS ED_SCROLL_LEFT_YPOS
196 #define ED_SCROLL_HORIZONTAL_XPOS (ED_SCROLL_LEFT_XPOS + \
197 ED_SCROLLBUTTON_XSIZE)
198 #define ED_SCROLL_HORIZONTAL_YPOS ED_SCROLL_LEFT_YPOS
199 #define ED_SCROLL_HORIZONTAL_XSIZE (SXSIZE - 3 * ED_SCROLLBUTTON_XSIZE)
200 #define ED_SCROLL_HORIZONTAL_YSIZE ED_SCROLLBUTTON_YSIZE
201 #define ED_SCROLL_VERTICAL_XPOS ED_SCROLL_UP_XPOS
202 #define ED_SCROLL_VERTICAL_YPOS (ED_SCROLL_UP_YPOS + \
203 ED_SCROLLBUTTON_YSIZE)
204 #define ED_SCROLL_VERTICAL_XSIZE ED_SCROLLBUTTON_XSIZE
205 #define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - 4 * ED_SCROLLBUTTON_YSIZE)
207 /* values for scrolling gadgets for element list */
208 #define ED_SCROLLBUTTON2_XPOS 50
209 #define ED_SCROLLBUTTON2_YPOS 0
210 #define ED_SCROLLBAR2_XPOS 50
211 #define ED_SCROLLBAR2_YPOS 20
213 #define ED_SCROLLBUTTON2_XSIZE 10
214 #define ED_SCROLLBUTTON2_YSIZE 10
216 #define ED_SCROLL2_UP_XPOS 85
217 #define ED_SCROLL2_UP_YPOS 30
218 #define ED_SCROLL2_DOWN_XPOS ED_SCROLL2_UP_XPOS
219 #define ED_SCROLL2_DOWN_YPOS (ED_SCROLL2_UP_YPOS + \
220 ED_ELEMENTLIST_BUTTONS_VERT * \
221 ED_ELEMENTLIST_YSIZE - \
222 ED_SCROLLBUTTON2_YSIZE)
223 #define ED_SCROLL2_VERTICAL_XPOS ED_SCROLL2_UP_XPOS
224 #define ED_SCROLL2_VERTICAL_YPOS (ED_SCROLL2_UP_YPOS + \
225 ED_SCROLLBUTTON2_YSIZE)
226 #define ED_SCROLL2_VERTICAL_XSIZE ED_SCROLLBUTTON2_XSIZE
227 #define ED_SCROLL2_VERTICAL_YSIZE (ED_ELEMENTLIST_BUTTONS_VERT * \
228 ED_ELEMENTLIST_YSIZE - \
229 2 * ED_SCROLLBUTTON2_YSIZE)
231 /* values for checkbutton gadgets */
232 #define ED_CHECKBUTTON_XSIZE ED_BUTTON_COUNT_XSIZE
233 #define ED_CHECKBUTTON_YSIZE ED_BUTTON_COUNT_YSIZE
234 #define ED_CHECKBUTTON_UNCHECKED_XPOS ED_BUTTON_MINUS_XPOS
235 #define ED_CHECKBUTTON_CHECKED_XPOS ED_BUTTON_PLUS_XPOS
236 #define ED_CHECKBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 22)
237 #define ED_RADIOBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 44)
238 #define ED_STICKYBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 66)
240 /* values for some special graphic buttons */
241 #define ED_COPY_CHANGE_PAGE_XPOS 25
242 #define ED_COPY_CHANGE_PAGE_YPOS 50
243 #define ED_PASTE_CHANGE_PAGE_XPOS 25
244 #define ED_PASTE_CHANGE_PAGE_YPOS 70
246 /* some values for text input, selectbox and counter gadgets */
247 #define ED_BUTTON_COUNT_YPOS 60
248 #define ED_BUTTON_COUNT_XSIZE 20
249 #define ED_BUTTON_COUNT_YSIZE 20
250 #define ED_WIN_COUNT_XPOS (2 + ED_BUTTON_COUNT_XSIZE + 2)
251 #define ED_WIN_COUNT_YPOS ED_BUTTON_COUNT_YPOS
252 #define ED_WIN_COUNT_XSIZE 52
253 #define ED_WIN_COUNT_YSIZE ED_BUTTON_COUNT_YSIZE
254 #define ED_WIN_COUNT2_XPOS 27
255 #define ED_WIN_COUNT2_YPOS 3
256 #define ED_WIN_COUNT2_XSIZE 46
257 #define ED_WIN_COUNT2_YSIZE ED_BUTTON_COUNT_YSIZE
259 #define ED_BUTTON_MINUS_XPOS 2
260 #define ED_BUTTON_MINUS_YPOS ED_BUTTON_COUNT_YPOS
261 #define ED_BUTTON_MINUS_XSIZE ED_BUTTON_COUNT_XSIZE
262 #define ED_BUTTON_MINUS_YSIZE ED_BUTTON_COUNT_YSIZE
263 #define ED_BUTTON_PLUS_XPOS (ED_WIN_COUNT_XPOS + \
264 ED_WIN_COUNT_XSIZE + 2)
265 #define ED_BUTTON_PLUS_YPOS ED_BUTTON_COUNT_YPOS
266 #define ED_BUTTON_PLUS_XSIZE ED_BUTTON_COUNT_XSIZE
267 #define ED_BUTTON_PLUS_YSIZE ED_BUTTON_COUNT_YSIZE
269 #define ED_SELECTBOX_XPOS ED_WIN_COUNT_XPOS
270 #define ED_SELECTBOX_YPOS (ED_WIN_COUNT_YPOS + \
271 2 + ED_WIN_COUNT_YSIZE)
272 #define ED_SELECTBOX_XSIZE ED_WIN_COUNT_XSIZE
273 #define ED_SELECTBOX_YSIZE ED_WIN_COUNT_YSIZE
275 #define ED_SELECTBOX_BUTTON_XSIZE 14
277 #define ED_TEXTBUTTON_XPOS ED_WIN_COUNT_XPOS
278 #define ED_TEXTBUTTON_YPOS (ED_WIN_COUNT_YPOS + \
279 4 * (2 + ED_WIN_COUNT_YSIZE))
280 #define ED_TEXTBUTTON_INACTIVE_YPOS ED_TEXTBUTTON_YPOS
282 #define ED_TEXTBUTTON_TAB_XPOS ED_WIN_COUNT_XPOS
283 #define ED_TEXTBUTTON_TAB_YPOS (ED_WIN_COUNT_YPOS + \
284 2 * (2 + ED_WIN_COUNT_YSIZE))
285 #define ED_TEXTBUTTON_TAB_INACTIVE_YPOS (ED_WIN_COUNT_YPOS + \
286 3 * (2 + ED_WIN_COUNT_YSIZE))
288 #define ED_TEXTBUTTON_XSIZE ED_WIN_COUNT_XSIZE
289 #define ED_TEXTBUTTON_YSIZE ED_WIN_COUNT_YSIZE
291 /* values for ClearEditorGadgetInfoText() and HandleEditorGadgetInfoText() */
292 #define INFOTEXT_XPOS SX
293 #define INFOTEXT_YPOS (SY + SYSIZE - MINI_TILEX + 2)
294 #define INFOTEXT_XSIZE SXSIZE
295 #define INFOTEXT_YSIZE MINI_TILEX
299 -----------------------------------------------------------------------------
300 editor gadget definitions
301 -----------------------------------------------------------------------------
304 /* drawing toolbox buttons */
305 #define GADGET_ID_NONE -1
306 #define GADGET_ID_TOOLBOX_FIRST 0
308 #define GADGET_ID_SINGLE_ITEMS (GADGET_ID_TOOLBOX_FIRST + 0)
309 #define GADGET_ID_CONNECTED_ITEMS (GADGET_ID_TOOLBOX_FIRST + 1)
310 #define GADGET_ID_LINE (GADGET_ID_TOOLBOX_FIRST + 2)
311 #define GADGET_ID_ARC (GADGET_ID_TOOLBOX_FIRST + 3)
312 #define GADGET_ID_RECTANGLE (GADGET_ID_TOOLBOX_FIRST + 4)
313 #define GADGET_ID_FILLED_BOX (GADGET_ID_TOOLBOX_FIRST + 5)
314 #define GADGET_ID_WRAP_UP (GADGET_ID_TOOLBOX_FIRST + 6)
315 #define GADGET_ID_TEXT (GADGET_ID_TOOLBOX_FIRST + 7)
316 #define GADGET_ID_FLOOD_FILL (GADGET_ID_TOOLBOX_FIRST + 8)
317 #define GADGET_ID_WRAP_LEFT (GADGET_ID_TOOLBOX_FIRST + 9)
318 #define GADGET_ID_PROPERTIES (GADGET_ID_TOOLBOX_FIRST + 10)
319 #define GADGET_ID_WRAP_RIGHT (GADGET_ID_TOOLBOX_FIRST + 11)
320 #define GADGET_ID_RANDOM_PLACEMENT (GADGET_ID_TOOLBOX_FIRST + 12)
321 #define GADGET_ID_GRAB_BRUSH (GADGET_ID_TOOLBOX_FIRST + 13)
322 #define GADGET_ID_WRAP_DOWN (GADGET_ID_TOOLBOX_FIRST + 14)
323 #define GADGET_ID_PICK_ELEMENT (GADGET_ID_TOOLBOX_FIRST + 15)
325 #define GADGET_ID_UNDO (GADGET_ID_TOOLBOX_FIRST + 16)
326 #define GADGET_ID_INFO (GADGET_ID_TOOLBOX_FIRST + 17)
327 #define GADGET_ID_SAVE (GADGET_ID_TOOLBOX_FIRST + 18)
328 #define GADGET_ID_CLEAR (GADGET_ID_TOOLBOX_FIRST + 19)
329 #define GADGET_ID_TEST (GADGET_ID_TOOLBOX_FIRST + 20)
330 #define GADGET_ID_EXIT (GADGET_ID_TOOLBOX_FIRST + 21)
332 #define GADGET_ID_CUSTOM_COPY_FROM (GADGET_ID_TOOLBOX_FIRST + 22)
333 #define GADGET_ID_CUSTOM_COPY_TO (GADGET_ID_TOOLBOX_FIRST + 23)
334 #define GADGET_ID_CUSTOM_EXCHANGE (GADGET_ID_TOOLBOX_FIRST + 24)
335 #define GADGET_ID_CUSTOM_COPY (GADGET_ID_TOOLBOX_FIRST + 25)
336 #define GADGET_ID_CUSTOM_PASTE (GADGET_ID_TOOLBOX_FIRST + 26)
338 /* counter gadget identifiers */
339 #define GADGET_ID_COUNTER_FIRST (GADGET_ID_TOOLBOX_FIRST + 27)
341 #define GADGET_ID_SELECT_LEVEL_DOWN (GADGET_ID_COUNTER_FIRST + 0)
342 #define GADGET_ID_SELECT_LEVEL_TEXT (GADGET_ID_COUNTER_FIRST + 1)
343 #define GADGET_ID_SELECT_LEVEL_UP (GADGET_ID_COUNTER_FIRST + 2)
344 #define GADGET_ID_LEVEL_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 3)
345 #define GADGET_ID_LEVEL_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 4)
346 #define GADGET_ID_LEVEL_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 5)
347 #define GADGET_ID_LEVEL_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 6)
348 #define GADGET_ID_LEVEL_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 7)
349 #define GADGET_ID_LEVEL_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 8)
350 #define GADGET_ID_LEVEL_RANDOM_DOWN (GADGET_ID_COUNTER_FIRST + 9)
351 #define GADGET_ID_LEVEL_RANDOM_TEXT (GADGET_ID_COUNTER_FIRST + 10)
352 #define GADGET_ID_LEVEL_RANDOM_UP (GADGET_ID_COUNTER_FIRST + 11)
353 #define GADGET_ID_LEVEL_GEMSLIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 12)
354 #define GADGET_ID_LEVEL_GEMSLIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 13)
355 #define GADGET_ID_LEVEL_GEMSLIMIT_UP (GADGET_ID_COUNTER_FIRST + 14)
356 #define GADGET_ID_LEVEL_TIMELIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 15)
357 #define GADGET_ID_LEVEL_TIMELIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 16)
358 #define GADGET_ID_LEVEL_TIMELIMIT_UP (GADGET_ID_COUNTER_FIRST + 17)
359 #define GADGET_ID_LEVEL_TIMESCORE_DOWN (GADGET_ID_COUNTER_FIRST + 18)
360 #define GADGET_ID_LEVEL_TIMESCORE_TEXT (GADGET_ID_COUNTER_FIRST + 19)
361 #define GADGET_ID_LEVEL_TIMESCORE_UP (GADGET_ID_COUNTER_FIRST + 20)
362 #define GADGET_ID_LEVEL_RANDOM_SEED_DOWN (GADGET_ID_COUNTER_FIRST + 21)
363 #define GADGET_ID_LEVEL_RANDOM_SEED_TEXT (GADGET_ID_COUNTER_FIRST + 22)
364 #define GADGET_ID_LEVEL_RANDOM_SEED_UP (GADGET_ID_COUNTER_FIRST + 23)
365 #define GADGET_ID_ELEMENT_VALUE1_DOWN (GADGET_ID_COUNTER_FIRST + 24)
366 #define GADGET_ID_ELEMENT_VALUE1_TEXT (GADGET_ID_COUNTER_FIRST + 25)
367 #define GADGET_ID_ELEMENT_VALUE1_UP (GADGET_ID_COUNTER_FIRST + 26)
368 #define GADGET_ID_ELEMENT_VALUE2_DOWN (GADGET_ID_COUNTER_FIRST + 27)
369 #define GADGET_ID_ELEMENT_VALUE2_TEXT (GADGET_ID_COUNTER_FIRST + 28)
370 #define GADGET_ID_ELEMENT_VALUE2_UP (GADGET_ID_COUNTER_FIRST + 29)
371 #define GADGET_ID_ELEMENT_VALUE3_DOWN (GADGET_ID_COUNTER_FIRST + 30)
372 #define GADGET_ID_ELEMENT_VALUE3_TEXT (GADGET_ID_COUNTER_FIRST + 31)
373 #define GADGET_ID_ELEMENT_VALUE3_UP (GADGET_ID_COUNTER_FIRST + 32)
374 #define GADGET_ID_ELEMENT_VALUE4_DOWN (GADGET_ID_COUNTER_FIRST + 33)
375 #define GADGET_ID_ELEMENT_VALUE4_TEXT (GADGET_ID_COUNTER_FIRST + 34)
376 #define GADGET_ID_ELEMENT_VALUE4_UP (GADGET_ID_COUNTER_FIRST + 35)
377 #define GADGET_ID_YAMYAM_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 36)
378 #define GADGET_ID_YAMYAM_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 37)
379 #define GADGET_ID_YAMYAM_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 38)
380 #define GADGET_ID_BALL_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 39)
381 #define GADGET_ID_BALL_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 40)
382 #define GADGET_ID_BALL_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 41)
383 #define GADGET_ID_ANDROID_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 42)
384 #define GADGET_ID_ANDROID_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 43)
385 #define GADGET_ID_ANDROID_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 44)
386 #define GADGET_ID_ENVELOPE_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 45)
387 #define GADGET_ID_ENVELOPE_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 46)
388 #define GADGET_ID_ENVELOPE_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 47)
389 #define GADGET_ID_ENVELOPE_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 48)
390 #define GADGET_ID_ENVELOPE_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 49)
391 #define GADGET_ID_ENVELOPE_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 50)
392 #define GADGET_ID_INVENTORY_SIZE_DOWN (GADGET_ID_COUNTER_FIRST + 51)
393 #define GADGET_ID_INVENTORY_SIZE_TEXT (GADGET_ID_COUNTER_FIRST + 52)
394 #define GADGET_ID_INVENTORY_SIZE_UP (GADGET_ID_COUNTER_FIRST + 53)
395 #define GADGET_ID_CUSTOM_SCORE_DOWN (GADGET_ID_COUNTER_FIRST + 54)
396 #define GADGET_ID_CUSTOM_SCORE_TEXT (GADGET_ID_COUNTER_FIRST + 55)
397 #define GADGET_ID_CUSTOM_SCORE_UP (GADGET_ID_COUNTER_FIRST + 56)
398 #define GADGET_ID_CUSTOM_GEMCOUNT_DOWN (GADGET_ID_COUNTER_FIRST + 57)
399 #define GADGET_ID_CUSTOM_GEMCOUNT_TEXT (GADGET_ID_COUNTER_FIRST + 58)
400 #define GADGET_ID_CUSTOM_GEMCOUNT_UP (GADGET_ID_COUNTER_FIRST + 59)
401 #define GADGET_ID_CUSTOM_VALUE_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 60)
402 #define GADGET_ID_CUSTOM_VALUE_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 61)
403 #define GADGET_ID_CUSTOM_VALUE_FIX_UP (GADGET_ID_COUNTER_FIRST + 62)
404 #define GADGET_ID_CUSTOM_VALUE_RND_DOWN (GADGET_ID_COUNTER_FIRST + 63)
405 #define GADGET_ID_CUSTOM_VALUE_RND_TEXT (GADGET_ID_COUNTER_FIRST + 64)
406 #define GADGET_ID_CUSTOM_VALUE_RND_UP (GADGET_ID_COUNTER_FIRST + 65)
407 #define GADGET_ID_PUSH_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 66)
408 #define GADGET_ID_PUSH_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 67)
409 #define GADGET_ID_PUSH_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 68)
410 #define GADGET_ID_PUSH_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 69)
411 #define GADGET_ID_PUSH_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 70)
412 #define GADGET_ID_PUSH_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 71)
413 #define GADGET_ID_DROP_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 72)
414 #define GADGET_ID_DROP_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 73)
415 #define GADGET_ID_DROP_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 74)
416 #define GADGET_ID_DROP_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 75)
417 #define GADGET_ID_DROP_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 76)
418 #define GADGET_ID_DROP_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 77)
419 #define GADGET_ID_MOVE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 78)
420 #define GADGET_ID_MOVE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 79)
421 #define GADGET_ID_MOVE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 80)
422 #define GADGET_ID_MOVE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 81)
423 #define GADGET_ID_MOVE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 82)
424 #define GADGET_ID_MOVE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 83)
425 #define GADGET_ID_EXPLOSION_DELAY_DOWN (GADGET_ID_COUNTER_FIRST + 84)
426 #define GADGET_ID_EXPLOSION_DELAY_TEXT (GADGET_ID_COUNTER_FIRST + 85)
427 #define GADGET_ID_EXPLOSION_DELAY_UP (GADGET_ID_COUNTER_FIRST + 86)
428 #define GADGET_ID_IGNITION_DELAY_DOWN (GADGET_ID_COUNTER_FIRST + 87)
429 #define GADGET_ID_IGNITION_DELAY_TEXT (GADGET_ID_COUNTER_FIRST + 88)
430 #define GADGET_ID_IGNITION_DELAY_UP (GADGET_ID_COUNTER_FIRST + 89)
431 #define GADGET_ID_CHANGE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 90)
432 #define GADGET_ID_CHANGE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 91)
433 #define GADGET_ID_CHANGE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 92)
434 #define GADGET_ID_CHANGE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 93)
435 #define GADGET_ID_CHANGE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 94)
436 #define GADGET_ID_CHANGE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 95)
437 #define GADGET_ID_CHANGE_CONT_RND_DOWN (GADGET_ID_COUNTER_FIRST + 96)
438 #define GADGET_ID_CHANGE_CONT_RND_TEXT (GADGET_ID_COUNTER_FIRST + 97)
439 #define GADGET_ID_CHANGE_CONT_RND_UP (GADGET_ID_COUNTER_FIRST + 98)
440 #define GADGET_ID_GROUP_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 99)
441 #define GADGET_ID_GROUP_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 100)
442 #define GADGET_ID_GROUP_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 101)
444 /* drawing area identifiers */
445 #define GADGET_ID_DRAWING_AREA_FIRST (GADGET_ID_COUNTER_FIRST + 102)
447 #define GADGET_ID_DRAWING_LEVEL (GADGET_ID_DRAWING_AREA_FIRST + 0)
448 #define GADGET_ID_YAMYAM_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 1)
449 #define GADGET_ID_YAMYAM_CONTENT_1 (GADGET_ID_DRAWING_AREA_FIRST + 2)
450 #define GADGET_ID_YAMYAM_CONTENT_2 (GADGET_ID_DRAWING_AREA_FIRST + 3)
451 #define GADGET_ID_YAMYAM_CONTENT_3 (GADGET_ID_DRAWING_AREA_FIRST + 4)
452 #define GADGET_ID_YAMYAM_CONTENT_4 (GADGET_ID_DRAWING_AREA_FIRST + 5)
453 #define GADGET_ID_YAMYAM_CONTENT_5 (GADGET_ID_DRAWING_AREA_FIRST + 6)
454 #define GADGET_ID_YAMYAM_CONTENT_6 (GADGET_ID_DRAWING_AREA_FIRST + 7)
455 #define GADGET_ID_YAMYAM_CONTENT_7 (GADGET_ID_DRAWING_AREA_FIRST + 8)
456 #define GADGET_ID_MAGIC_BALL_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 9)
457 #define GADGET_ID_MAGIC_BALL_CONTENT_1 (GADGET_ID_DRAWING_AREA_FIRST + 10)
458 #define GADGET_ID_MAGIC_BALL_CONTENT_2 (GADGET_ID_DRAWING_AREA_FIRST + 11)
459 #define GADGET_ID_MAGIC_BALL_CONTENT_3 (GADGET_ID_DRAWING_AREA_FIRST + 12)
460 #define GADGET_ID_MAGIC_BALL_CONTENT_4 (GADGET_ID_DRAWING_AREA_FIRST + 13)
461 #define GADGET_ID_MAGIC_BALL_CONTENT_5 (GADGET_ID_DRAWING_AREA_FIRST + 14)
462 #define GADGET_ID_MAGIC_BALL_CONTENT_6 (GADGET_ID_DRAWING_AREA_FIRST + 15)
463 #define GADGET_ID_MAGIC_BALL_CONTENT_7 (GADGET_ID_DRAWING_AREA_FIRST + 16)
464 #define GADGET_ID_ANDROID_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 17)
465 #define GADGET_ID_AMOEBA_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 18)
466 #define GADGET_ID_START_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 19)
467 #define GADGET_ID_ARTWORK_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 20)
468 #define GADGET_ID_EXPLOSION_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 21)
469 #define GADGET_ID_INVENTORY_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 22)
470 #define GADGET_ID_CUSTOM_GRAPHIC (GADGET_ID_DRAWING_AREA_FIRST + 23)
471 #define GADGET_ID_CUSTOM_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 24)
472 #define GADGET_ID_CUSTOM_MOVE_ENTER (GADGET_ID_DRAWING_AREA_FIRST + 25)
473 #define GADGET_ID_CUSTOM_MOVE_LEAVE (GADGET_ID_DRAWING_AREA_FIRST + 26)
474 #define GADGET_ID_CUSTOM_CHANGE_TARGET (GADGET_ID_DRAWING_AREA_FIRST + 27)
475 #define GADGET_ID_CUSTOM_CHANGE_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 28)
476 #define GADGET_ID_CUSTOM_CHANGE_TRIGGER (GADGET_ID_DRAWING_AREA_FIRST + 29)
477 #define GADGET_ID_CUSTOM_CHANGE_ACTION (GADGET_ID_DRAWING_AREA_FIRST + 30)
478 #define GADGET_ID_GROUP_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 31)
479 #define GADGET_ID_RANDOM_BACKGROUND (GADGET_ID_DRAWING_AREA_FIRST + 32)
481 /* text input identifiers */
482 #define GADGET_ID_TEXT_INPUT_FIRST (GADGET_ID_DRAWING_AREA_FIRST + 33)
484 #define GADGET_ID_LEVEL_NAME (GADGET_ID_TEXT_INPUT_FIRST + 0)
485 #define GADGET_ID_LEVEL_AUTHOR (GADGET_ID_TEXT_INPUT_FIRST + 1)
486 #define GADGET_ID_ELEMENT_NAME (GADGET_ID_TEXT_INPUT_FIRST + 2)
488 /* text area identifiers */
489 #define GADGET_ID_TEXT_AREA_FIRST (GADGET_ID_TEXT_INPUT_FIRST + 3)
491 #define GADGET_ID_ENVELOPE_INFO (GADGET_ID_TEXT_AREA_FIRST + 0)
493 /* selectbox identifiers */
494 #define GADGET_ID_SELECTBOX_FIRST (GADGET_ID_TEXT_AREA_FIRST + 1)
496 #define GADGET_ID_TIME_OR_STEPS (GADGET_ID_SELECTBOX_FIRST + 0)
497 #define GADGET_ID_GAME_ENGINE_TYPE (GADGET_ID_SELECTBOX_FIRST + 1)
498 #define GADGET_ID_WIND_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 2)
499 #define GADGET_ID_PLAYER_SPEED (GADGET_ID_SELECTBOX_FIRST + 3)
500 #define GADGET_ID_CUSTOM_WALK_TO_ACTION (GADGET_ID_SELECTBOX_FIRST + 4)
501 #define GADGET_ID_CUSTOM_EXPLOSION_TYPE (GADGET_ID_SELECTBOX_FIRST + 5)
502 #define GADGET_ID_CUSTOM_DEADLINESS (GADGET_ID_SELECTBOX_FIRST + 6)
503 #define GADGET_ID_CUSTOM_MOVE_PATTERN (GADGET_ID_SELECTBOX_FIRST + 7)
504 #define GADGET_ID_CUSTOM_MOVE_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 8)
505 #define GADGET_ID_CUSTOM_MOVE_STEPSIZE (GADGET_ID_SELECTBOX_FIRST + 9)
506 #define GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE (GADGET_ID_SELECTBOX_FIRST + 10)
507 #define GADGET_ID_CUSTOM_SMASH_TARGETS (GADGET_ID_SELECTBOX_FIRST + 11)
508 #define GADGET_ID_CUSTOM_SLIPPERY_TYPE (GADGET_ID_SELECTBOX_FIRST + 12)
509 #define GADGET_ID_CUSTOM_ACCESS_TYPE (GADGET_ID_SELECTBOX_FIRST + 13)
510 #define GADGET_ID_CUSTOM_ACCESS_LAYER (GADGET_ID_SELECTBOX_FIRST + 14)
511 #define GADGET_ID_CUSTOM_ACCESS_PROTECTED (GADGET_ID_SELECTBOX_FIRST + 15)
512 #define GADGET_ID_CUSTOM_ACCESS_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 16)
513 #define GADGET_ID_CHANGE_TIME_UNITS (GADGET_ID_SELECTBOX_FIRST + 17)
514 #define GADGET_ID_CHANGE_DIRECT_ACTION (GADGET_ID_SELECTBOX_FIRST + 18)
515 #define GADGET_ID_CHANGE_OTHER_ACTION (GADGET_ID_SELECTBOX_FIRST + 19)
516 #define GADGET_ID_CHANGE_SIDE (GADGET_ID_SELECTBOX_FIRST + 20)
517 #define GADGET_ID_CHANGE_PLAYER (GADGET_ID_SELECTBOX_FIRST + 21)
518 #define GADGET_ID_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 22)
519 #define GADGET_ID_CHANGE_REPLACE_WHEN (GADGET_ID_SELECTBOX_FIRST + 23)
520 #define GADGET_ID_ACTION_TYPE (GADGET_ID_SELECTBOX_FIRST + 24)
521 #define GADGET_ID_ACTION_MODE (GADGET_ID_SELECTBOX_FIRST + 25)
522 #define GADGET_ID_ACTION_ARG (GADGET_ID_SELECTBOX_FIRST + 26)
523 #define GADGET_ID_SELECT_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 27)
524 #define GADGET_ID_GROUP_CHOICE_MODE (GADGET_ID_SELECTBOX_FIRST + 28)
526 /* textbutton identifiers */
527 #define GADGET_ID_TEXTBUTTON_FIRST (GADGET_ID_SELECTBOX_FIRST + 29)
529 #define GADGET_ID_LEVELINFO_LEVEL (GADGET_ID_TEXTBUTTON_FIRST + 0)
530 #define GADGET_ID_LEVELINFO_EDITOR (GADGET_ID_TEXTBUTTON_FIRST + 1)
531 #define GADGET_ID_PROPERTIES_INFO (GADGET_ID_TEXTBUTTON_FIRST + 2)
532 #define GADGET_ID_PROPERTIES_CONFIG (GADGET_ID_TEXTBUTTON_FIRST + 3)
533 #define GADGET_ID_PROPERTIES_CONFIG_1 (GADGET_ID_TEXTBUTTON_FIRST + 4)
534 #define GADGET_ID_PROPERTIES_CONFIG_2 (GADGET_ID_TEXTBUTTON_FIRST + 5)
535 #define GADGET_ID_PROPERTIES_CHANGE (GADGET_ID_TEXTBUTTON_FIRST + 6)
536 #define GADGET_ID_SAVE_AS_TEMPLATE (GADGET_ID_TEXTBUTTON_FIRST + 7)
537 #define GADGET_ID_ADD_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 8)
538 #define GADGET_ID_DEL_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 9)
540 /* graphicbutton identifiers */
541 #define GADGET_ID_GRAPHICBUTTON_FIRST (GADGET_ID_TEXTBUTTON_FIRST + 10)
543 #define GADGET_ID_PREV_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 0)
544 #define GADGET_ID_NEXT_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 1)
545 #define GADGET_ID_COPY_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 2)
546 #define GADGET_ID_PASTE_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 3)
548 /* gadgets for scrolling of drawing area */
549 #define GADGET_ID_SCROLLING_FIRST (GADGET_ID_GRAPHICBUTTON_FIRST + 4)
551 #define GADGET_ID_SCROLL_UP (GADGET_ID_SCROLLING_FIRST + 0)
552 #define GADGET_ID_SCROLL_DOWN (GADGET_ID_SCROLLING_FIRST + 1)
553 #define GADGET_ID_SCROLL_LEFT (GADGET_ID_SCROLLING_FIRST + 2)
554 #define GADGET_ID_SCROLL_RIGHT (GADGET_ID_SCROLLING_FIRST + 3)
555 #define GADGET_ID_SCROLL_HORIZONTAL (GADGET_ID_SCROLLING_FIRST + 4)
556 #define GADGET_ID_SCROLL_VERTICAL (GADGET_ID_SCROLLING_FIRST + 5)
558 /* gadgets for scrolling element list */
559 #define GADGET_ID_SCROLLING_LIST_FIRST (GADGET_ID_SCROLLING_FIRST + 6)
561 #define GADGET_ID_SCROLL_LIST_UP (GADGET_ID_SCROLLING_LIST_FIRST + 0)
562 #define GADGET_ID_SCROLL_LIST_DOWN (GADGET_ID_SCROLLING_LIST_FIRST + 1)
563 #define GADGET_ID_SCROLL_LIST_VERTICAL (GADGET_ID_SCROLLING_LIST_FIRST + 2)
565 /* checkbuttons/radiobuttons for level/element properties */
566 #define GADGET_ID_CHECKBUTTON_FIRST (GADGET_ID_SCROLLING_LIST_FIRST + 3)
568 #define GADGET_ID_RANDOM_PERCENTAGE (GADGET_ID_CHECKBUTTON_FIRST + 0)
569 #define GADGET_ID_RANDOM_QUANTITY (GADGET_ID_CHECKBUTTON_FIRST + 1)
570 #define GADGET_ID_RANDOM_RESTRICTED (GADGET_ID_CHECKBUTTON_FIRST + 2)
571 #define GADGET_ID_STICK_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 3)
572 #define GADGET_ID_EM_SLIPPERY_GEMS (GADGET_ID_CHECKBUTTON_FIRST + 4)
573 #define GADGET_ID_EM_EXPLODES_BY_FIRE (GADGET_ID_CHECKBUTTON_FIRST + 5)
574 #define GADGET_ID_USE_SPRING_BUG (GADGET_ID_CHECKBUTTON_FIRST + 6)
575 #define GADGET_ID_USE_TIME_ORB_BUG (GADGET_ID_CHECKBUTTON_FIRST + 7)
576 #define GADGET_ID_RANDOM_BALL_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 8)
577 #define GADGET_ID_INITIAL_BALL_STATE (GADGET_ID_CHECKBUTTON_FIRST + 9)
578 #define GADGET_ID_GROW_INTO_DIGGABLE (GADGET_ID_CHECKBUTTON_FIRST + 10)
579 #define GADGET_ID_AUTO_EXIT_SOKOBAN (GADGET_ID_CHECKBUTTON_FIRST + 11)
580 #define GADGET_ID_CONTINUOUS_SNAPPING (GADGET_ID_CHECKBUTTON_FIRST + 12)
581 #define GADGET_ID_BLOCK_SNAP_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 13)
582 #define GADGET_ID_BLOCK_LAST_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 14)
583 #define GADGET_ID_SP_BLOCK_LAST_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 15)
584 #define GADGET_ID_INSTANT_RELOCATION (GADGET_ID_CHECKBUTTON_FIRST + 16)
585 #define GADGET_ID_SHIFTED_RELOCATION (GADGET_ID_CHECKBUTTON_FIRST + 17)
586 #define GADGET_ID_USE_START_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 18)
587 #define GADGET_ID_USE_ARTWORK_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 19)
588 #define GADGET_ID_USE_EXPLOSION_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 20)
589 #define GADGET_ID_INITIAL_GRAVITY (GADGET_ID_CHECKBUTTON_FIRST + 21)
590 #define GADGET_ID_USE_INITIAL_INVENTORY (GADGET_ID_CHECKBUTTON_FIRST + 22)
591 #define GADGET_ID_CAN_PASS_TO_WALKABLE (GADGET_ID_CHECKBUTTON_FIRST + 23)
592 #define GADGET_ID_CAN_FALL_INTO_ACID (GADGET_ID_CHECKBUTTON_FIRST + 24)
593 #define GADGET_ID_CAN_MOVE_INTO_ACID (GADGET_ID_CHECKBUTTON_FIRST + 25)
594 #define GADGET_ID_DONT_COLLIDE_WITH (GADGET_ID_CHECKBUTTON_FIRST + 26)
595 #define GADGET_ID_ENVELOPE_AUTOWRAP (GADGET_ID_CHECKBUTTON_FIRST + 27)
596 #define GADGET_ID_ENVELOPE_CENTERED (GADGET_ID_CHECKBUTTON_FIRST + 28)
597 #define GADGET_ID_CUSTOM_INDESTRUCTIBLE (GADGET_ID_CHECKBUTTON_FIRST + 29)
598 #define GADGET_ID_CUSTOM_CAN_EXPLODE (GADGET_ID_CHECKBUTTON_FIRST + 30)
599 #define GADGET_ID_CUSTOM_EXPLODE_FIRE (GADGET_ID_CHECKBUTTON_FIRST + 31)
600 #define GADGET_ID_CUSTOM_EXPLODE_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 32)
601 #define GADGET_ID_CUSTOM_EXPLODE_IMPACT (GADGET_ID_CHECKBUTTON_FIRST + 33)
602 #define GADGET_ID_CUSTOM_WALK_TO_OBJECT (GADGET_ID_CHECKBUTTON_FIRST + 34)
603 #define GADGET_ID_CUSTOM_DEADLY (GADGET_ID_CHECKBUTTON_FIRST + 35)
604 #define GADGET_ID_CUSTOM_CAN_MOVE (GADGET_ID_CHECKBUTTON_FIRST + 36)
605 #define GADGET_ID_CUSTOM_CAN_FALL (GADGET_ID_CHECKBUTTON_FIRST + 37)
606 #define GADGET_ID_CUSTOM_CAN_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 38)
607 #define GADGET_ID_CUSTOM_SLIPPERY (GADGET_ID_CHECKBUTTON_FIRST + 39)
608 #define GADGET_ID_CUSTOM_ACCESSIBLE (GADGET_ID_CHECKBUTTON_FIRST + 40)
609 #define GADGET_ID_CUSTOM_GRAV_REACHABLE (GADGET_ID_CHECKBUTTON_FIRST + 41)
610 #define GADGET_ID_CUSTOM_USE_LAST_VALUE (GADGET_ID_CHECKBUTTON_FIRST + 42)
611 #define GADGET_ID_CUSTOM_USE_GRAPHIC (GADGET_ID_CHECKBUTTON_FIRST + 43)
612 #define GADGET_ID_CUSTOM_USE_TEMPLATE (GADGET_ID_CHECKBUTTON_FIRST + 44)
613 #define GADGET_ID_CUSTOM_CAN_CHANGE (GADGET_ID_CHECKBUTTON_FIRST + 45)
614 #define GADGET_ID_CHANGE_USE_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 46)
615 #define GADGET_ID_CHANGE_USE_EXPLOSION (GADGET_ID_CHECKBUTTON_FIRST + 47)
616 #define GADGET_ID_CHANGE_ONLY_COMPLETE (GADGET_ID_CHECKBUTTON_FIRST + 48)
617 #define GADGET_ID_CHANGE_USE_RANDOM (GADGET_ID_CHECKBUTTON_FIRST + 49)
618 #define GADGET_ID_CHANGE_HAS_ACTION (GADGET_ID_CHECKBUTTON_FIRST + 50)
619 #define GADGET_ID_CHANGE_DELAY (GADGET_ID_CHECKBUTTON_FIRST + 51)
620 #define GADGET_ID_CHANGE_BY_DIRECT_ACT (GADGET_ID_CHECKBUTTON_FIRST + 52)
621 #define GADGET_ID_CHANGE_BY_OTHER_ACT (GADGET_ID_CHECKBUTTON_FIRST + 53)
623 /* gadgets for buttons in element list */
624 #define GADGET_ID_ELEMENTLIST_FIRST (GADGET_ID_CHECKBUTTON_FIRST + 54)
625 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
626 ED_NUM_ELEMENTLIST_BUTTONS - 1)
628 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
630 /* radio button numbers */
631 #define RADIO_NR_NONE 0
632 #define RADIO_NR_DRAWING_TOOLBOX 1
633 #define RADIO_NR_RANDOM_ELEMENTS 2
635 /* values for counter gadgets */
636 #define ED_COUNTER_ID_SELECT_LEVEL 0
637 #define ED_COUNTER_ID_LEVEL_XSIZE 1
638 #define ED_COUNTER_ID_LEVEL_YSIZE 2
639 #define ED_COUNTER_ID_LEVEL_GEMSLIMIT 3
640 #define ED_COUNTER_ID_LEVEL_TIMELIMIT 4
641 #define ED_COUNTER_ID_LEVEL_TIMESCORE 5
642 #define ED_COUNTER_ID_LEVEL_RANDOM_SEED 6
643 #define ED_COUNTER_ID_LEVEL_RANDOM 7
644 #define ED_COUNTER_ID_ELEMENT_VALUE1 8
645 #define ED_COUNTER_ID_ELEMENT_VALUE2 9
646 #define ED_COUNTER_ID_ELEMENT_VALUE3 10
647 #define ED_COUNTER_ID_ELEMENT_VALUE4 11
648 #define ED_COUNTER_ID_YAMYAM_CONTENT 12
649 #define ED_COUNTER_ID_BALL_CONTENT 13
650 #define ED_COUNTER_ID_ANDROID_CONTENT 14
651 #define ED_COUNTER_ID_ENVELOPE_XSIZE 15
652 #define ED_COUNTER_ID_ENVELOPE_YSIZE 16
653 #define ED_COUNTER_ID_INVENTORY_SIZE 17
654 #define ED_COUNTER_ID_CUSTOM_SCORE 18
655 #define ED_COUNTER_ID_CUSTOM_GEMCOUNT 19
656 #define ED_COUNTER_ID_CUSTOM_VALUE_FIX 20
657 #define ED_COUNTER_ID_CUSTOM_VALUE_RND 21
658 #define ED_COUNTER_ID_PUSH_DELAY_FIX 22
659 #define ED_COUNTER_ID_PUSH_DELAY_RND 23
660 #define ED_COUNTER_ID_DROP_DELAY_FIX 24
661 #define ED_COUNTER_ID_DROP_DELAY_RND 25
662 #define ED_COUNTER_ID_MOVE_DELAY_FIX 26
663 #define ED_COUNTER_ID_MOVE_DELAY_RND 27
664 #define ED_COUNTER_ID_EXPLOSION_DELAY 28
665 #define ED_COUNTER_ID_IGNITION_DELAY 29
666 #define ED_COUNTER_ID_GROUP_CONTENT 30
667 #define ED_COUNTER_ID_CHANGE_DELAY_FIX 31
668 #define ED_COUNTER_ID_CHANGE_DELAY_RND 32
669 #define ED_COUNTER_ID_CHANGE_CONT_RND 33
671 #define ED_NUM_COUNTERBUTTONS 34
673 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
674 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
675 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
676 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
678 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
679 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
680 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
681 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
682 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
683 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
685 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
686 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
688 /* values for scrollbutton gadgets */
689 #define ED_SCROLLBUTTON_ID_AREA_UP 0
690 #define ED_SCROLLBUTTON_ID_AREA_DOWN 1
691 #define ED_SCROLLBUTTON_ID_AREA_LEFT 2
692 #define ED_SCROLLBUTTON_ID_AREA_RIGHT 3
693 #define ED_SCROLLBUTTON_ID_LIST_UP 4
694 #define ED_SCROLLBUTTON_ID_LIST_DOWN 5
696 #define ED_NUM_SCROLLBUTTONS 6
698 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
699 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
701 /* values for scrollbar gadgets */
702 #define ED_SCROLLBAR_ID_AREA_HORIZONTAL 0
703 #define ED_SCROLLBAR_ID_AREA_VERTICAL 1
704 #define ED_SCROLLBAR_ID_LIST_VERTICAL 2
706 #define ED_NUM_SCROLLBARS 3
708 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
709 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
711 /* values for text input gadgets */
712 #define ED_TEXTINPUT_ID_LEVEL_NAME 0
713 #define ED_TEXTINPUT_ID_LEVEL_AUTHOR 1
714 #define ED_TEXTINPUT_ID_ELEMENT_NAME 2
716 #define ED_NUM_TEXTINPUT 3
718 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
719 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
721 /* values for text area gadgets */
722 #define ED_TEXTAREA_ID_ENVELOPE_INFO 0
724 #define ED_NUM_TEXTAREAS 1
726 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
727 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
729 /* values for selectbox gadgets */
730 #define ED_SELECTBOX_ID_TIME_OR_STEPS 0
731 #define ED_SELECTBOX_ID_GAME_ENGINE_TYPE 1
732 #define ED_SELECTBOX_ID_WIND_DIRECTION 2
733 #define ED_SELECTBOX_ID_PLAYER_SPEED 3
734 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE 4
735 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER 5
736 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED 6
737 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION 7
738 #define ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION 8
739 #define ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN 9
740 #define ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION 10
741 #define ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE 11
742 #define ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE 12
743 #define ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS 13
744 #define ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE 14
745 #define ED_SELECTBOX_ID_CUSTOM_DEADLINESS 15
746 #define ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE 16
747 #define ED_SELECTBOX_ID_CHANGE_TIME_UNITS 17
748 #define ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION 18
749 #define ED_SELECTBOX_ID_CHANGE_OTHER_ACTION 19
750 #define ED_SELECTBOX_ID_CHANGE_SIDE 20
751 #define ED_SELECTBOX_ID_CHANGE_PLAYER 21
752 #define ED_SELECTBOX_ID_CHANGE_PAGE 22
753 #define ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN 23
754 #define ED_SELECTBOX_ID_ACTION_TYPE 24
755 #define ED_SELECTBOX_ID_ACTION_MODE 25
756 #define ED_SELECTBOX_ID_ACTION_ARG 26
757 #define ED_SELECTBOX_ID_SELECT_CHANGE_PAGE 27
758 #define ED_SELECTBOX_ID_GROUP_CHOICE_MODE 28
760 #define ED_NUM_SELECTBOX 29
762 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
763 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_WIND_DIRECTION
765 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
766 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
767 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
768 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
769 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
770 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
772 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
773 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
775 /* values for textbutton gadgets */
776 #define ED_TEXTBUTTON_ID_LEVELINFO_LEVEL 0
777 #define ED_TEXTBUTTON_ID_LEVELINFO_EDITOR 1
778 #define ED_TEXTBUTTON_ID_PROPERTIES_INFO 2
779 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG 3
780 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1 4
781 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2 5
782 #define ED_TEXTBUTTON_ID_PROPERTIES_CHANGE 6
783 #define ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE 7
784 #define ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE 8
785 #define ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE 9
787 #define ED_NUM_TEXTBUTTONS 10
789 #define ED_TEXTBUTTON_ID_LEVELINFO_FIRST ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
790 #define ED_TEXTBUTTON_ID_LEVELINFO_LAST ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
792 #define ED_TEXTBUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
793 #define ED_TEXTBUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
795 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
796 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
798 /* values for graphicbutton gadgets */
799 #define ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE 0
800 #define ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE 1
801 #define ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE 2
802 #define ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE 3
804 #define ED_NUM_GRAPHICBUTTONS 4
806 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
807 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
809 /* values for checkbutton gadgets */
810 #define ED_CHECKBUTTON_ID_RANDOM_RESTRICTED 0
811 #define ED_CHECKBUTTON_ID_STICK_ELEMENT 1
812 #define ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS 2
813 #define ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE 3
814 #define ED_CHECKBUTTON_ID_USE_SPRING_BUG 4
815 #define ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG 5
816 #define ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT 6
817 #define ED_CHECKBUTTON_ID_INITIAL_BALL_STATE 7
818 #define ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE 8
819 #define ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN 9
820 #define ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING 10
821 #define ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD 11
822 #define ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD 12
823 #define ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD 13
824 #define ED_CHECKBUTTON_ID_INSTANT_RELOCATION 14
825 #define ED_CHECKBUTTON_ID_SHIFTED_RELOCATION 15
826 #define ED_CHECKBUTTON_ID_USE_START_ELEMENT 16
827 #define ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT 17
828 #define ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT 18
829 #define ED_CHECKBUTTON_ID_INITIAL_GRAVITY 19
830 #define ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY 20
831 #define ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE 21
832 #define ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID 22
833 #define ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID 23
834 #define ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH 24
835 #define ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP 25
836 #define ED_CHECKBUTTON_ID_ENVELOPE_CENTERED 26
837 #define ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC 27
838 #define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE 28
839 #define ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE 29
840 #define ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE 30
841 #define ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE 31
842 #define ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT 32
843 #define ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE 33
844 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE 34
845 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL 35
846 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH 36
847 #define ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY 37
848 #define ED_CHECKBUTTON_ID_CUSTOM_DEADLY 38
849 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE 39
850 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE 40
851 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH 41
852 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT 42
853 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE 43
854 #define ED_CHECKBUTTON_ID_CHANGE_DELAY 44
855 #define ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT 45
856 #define ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT 46
857 #define ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION 47
858 #define ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT 48
859 #define ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE 49
860 #define ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM 50
861 #define ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION 51
863 #define ED_NUM_CHECKBUTTONS 52
865 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
866 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
868 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
869 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
870 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
871 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
872 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
873 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
875 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
876 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
878 /* values for radiobutton gadgets */
879 #define ED_RADIOBUTTON_ID_PERCENTAGE 0
880 #define ED_RADIOBUTTON_ID_QUANTITY 1
882 #define ED_NUM_RADIOBUTTONS 2
884 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
885 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
887 /* values for drawing area gadgets */
888 #define ED_DRAWING_ID_DRAWING_LEVEL 0
889 #define ED_DRAWING_ID_YAMYAM_CONTENT_0 1
890 #define ED_DRAWING_ID_YAMYAM_CONTENT_1 2
891 #define ED_DRAWING_ID_YAMYAM_CONTENT_2 3
892 #define ED_DRAWING_ID_YAMYAM_CONTENT_3 4
893 #define ED_DRAWING_ID_YAMYAM_CONTENT_4 5
894 #define ED_DRAWING_ID_YAMYAM_CONTENT_5 6
895 #define ED_DRAWING_ID_YAMYAM_CONTENT_6 7
896 #define ED_DRAWING_ID_YAMYAM_CONTENT_7 8
897 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 9
898 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_1 10
899 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_2 11
900 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_3 12
901 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_4 13
902 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_5 14
903 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_6 15
904 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_7 16
905 #define ED_DRAWING_ID_ANDROID_CONTENT 17
906 #define ED_DRAWING_ID_AMOEBA_CONTENT 18
907 #define ED_DRAWING_ID_START_ELEMENT 19
908 #define ED_DRAWING_ID_ARTWORK_ELEMENT 20
909 #define ED_DRAWING_ID_EXPLOSION_ELEMENT 21
910 #define ED_DRAWING_ID_INVENTORY_CONTENT 22
911 #define ED_DRAWING_ID_CUSTOM_GRAPHIC 23
912 #define ED_DRAWING_ID_CUSTOM_CONTENT 24
913 #define ED_DRAWING_ID_CUSTOM_MOVE_ENTER 25
914 #define ED_DRAWING_ID_CUSTOM_MOVE_LEAVE 26
915 #define ED_DRAWING_ID_CUSTOM_CHANGE_TARGET 27
916 #define ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT 28
917 #define ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER 29
918 #define ED_DRAWING_ID_CUSTOM_CHANGE_ACTION 30
919 #define ED_DRAWING_ID_GROUP_CONTENT 31
920 #define ED_DRAWING_ID_RANDOM_BACKGROUND 32
922 #define ED_NUM_DRAWING_AREAS 33
926 -----------------------------------------------------------------------------
927 some internally used definitions
928 -----------------------------------------------------------------------------
931 /* values for CopyLevelToUndoBuffer() */
932 #define UNDO_IMMEDIATE 0
933 #define UNDO_ACCUMULATE 1
935 /* values for scrollbars */
936 #define ED_SCROLL_NO 0
937 #define ED_SCROLL_LEFT 1
938 #define ED_SCROLL_RIGHT 2
939 #define ED_SCROLL_UP 4
940 #define ED_SCROLL_DOWN 8
942 /* screens in the level editor */
943 #define ED_MODE_DRAWING 0
944 #define ED_MODE_INFO 1
945 #define ED_MODE_PROPERTIES 2
947 /* sub-screens in the global settings section */
948 #define ED_MODE_LEVELINFO_LEVEL ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
949 #define ED_MODE_LEVELINFO_EDITOR ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
951 /* sub-screens in the element properties section */
952 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
953 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
954 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
955 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
956 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
958 /* how many steps can be cancelled */
959 #define NUM_UNDO_STEPS (10 + 1)
961 /* values for elements with score for certain actions */
963 #define MAX_SCORE 999
965 /* values for elements with count for collecting */
966 #define MIN_COLLECT_COUNT 0
967 #define MAX_COLLECT_COUNT 999
969 /* values for random placement */
970 #define RANDOM_USE_PERCENTAGE 0
971 #define RANDOM_USE_QUANTITY 1
973 /* maximal size of level editor drawing area */
975 #define MAX_ED_FIELDX (SCR_FIELDX)
976 #define MAX_ED_FIELDY (SCR_FIELDY - 1)
978 #define MAX_ED_FIELDX (2 * SCR_FIELDX)
979 #define MAX_ED_FIELDY (2 * SCR_FIELDY - 1)
984 -----------------------------------------------------------------------------
985 some internally used data structure definitions
986 -----------------------------------------------------------------------------
993 } control_info[ED_NUM_CTRL_BUTTONS] =
995 /* note: some additional characters are already reserved for "cheat mode"
996 shortcuts (":XYZ" style) -- for details, see "events.c" */
998 { 's', "draw single items" },
999 { 'd', "draw connected items" },
1000 { 'l', "draw lines" },
1001 { 'a', "draw arcs" },
1002 { 'r', "draw outline rectangles" },
1003 { 'R', "draw filled rectangles" },
1004 { '\0', "wrap (rotate) level up" },
1005 { 't', "enter text elements" },
1006 { 'f', "flood fill" },
1007 { '\0', "wrap (rotate) level left" },
1008 { '?', "properties of drawing element" },
1009 { '\0', "wrap (rotate) level right" },
1010 { '\0', "random element placement" },
1011 { 'b', "grab brush" },
1012 { '\0', "wrap (rotate) level down" },
1013 { ',', "pick drawing element" },
1015 { 'U', "undo last operation" },
1016 { 'I', "properties of level" },
1017 { 'S', "save level" },
1018 { 'C', "clear level" },
1019 { 'T', "test level" },
1020 { 'E', "exit level editor" },
1022 { '\0', "copy settings from other element" },
1023 { '\0', "copy settings to other element" },
1024 { '\0', "exchange element with other element" },
1026 { '\0', "copy settings from this element" },
1027 { '\0', "paste settings to this element" },
1030 static int random_placement_value = 10;
1031 static int random_placement_method = RANDOM_USE_QUANTITY;
1032 static int random_placement_background_element = EL_SAND;
1033 static boolean random_placement_background_restricted = FALSE;
1034 static boolean stick_element_properties_window = FALSE;
1035 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1036 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1037 static struct ElementChangeInfo custom_element_change;
1038 static struct ElementGroupInfo group_element_info;
1039 static struct ElementInfo custom_element;
1044 int min_value, max_value;
1045 int gadget_id_down, gadget_id_up;
1047 int gadget_id_align;
1049 char *text_above, *text_left, *text_right;
1050 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1052 /* ---------- current level number --------------------------------------- */
1056 -1, -1, /* these values are not constant, but can change at runtime */
1058 DX + 5 - SX, DY + 3 - SY,
1061 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1062 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1067 /* ---------- level and editor settings ---------------------------------- */
1070 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1071 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1072 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1073 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1075 "playfield size:", NULL, "width",
1078 -1, ED_LEVEL_SETTINGS_YPOS(4),
1079 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1080 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1081 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1083 NULL, " ", "height",
1086 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1088 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1089 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1091 NULL, "number of gems to collect:", NULL
1094 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
1096 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1097 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1099 "time or step limit to solve level:", NULL, NULL
1102 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(9),
1104 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1105 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1106 &level.score[SC_TIME_BONUS],
1107 "score for each second/step left:", NULL, NULL
1110 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
1112 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1113 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1115 NULL, "random seed:", "(0 => random)"
1118 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1120 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1121 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1122 &random_placement_value,
1123 "random element placement:", NULL, "in"
1126 /* ---------- element settings: configure (various elements) ------------- */
1129 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1130 MIN_SCORE, MAX_SCORE,
1131 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1132 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1133 NULL, /* will be set when used */
1137 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1138 MIN_SCORE, MAX_SCORE,
1139 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1140 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1141 NULL, /* will be set when used */
1145 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1146 MIN_SCORE, MAX_SCORE,
1147 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1148 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1149 NULL, /* will be set when used */
1153 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1154 MIN_SCORE, MAX_SCORE,
1155 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1156 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1157 NULL, /* will be set when used */
1161 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1162 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1163 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1164 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1165 &level.num_yamyam_contents,
1166 NULL, NULL, "number of content areas"
1169 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1170 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1171 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1172 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1173 &level.num_ball_contents,
1174 NULL, NULL, "number of content areas"
1177 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1178 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1179 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1180 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1181 &level.num_android_clone_elements,
1182 NULL, NULL, "number of clonable elements"
1185 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1186 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1187 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1188 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1189 NULL, /* will be set when used */
1190 NULL, NULL, "width",
1193 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1194 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1195 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1196 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1197 NULL, /* will be set when used */
1198 NULL, " ", "height",
1201 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1202 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1203 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1204 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1205 &level.initial_inventory_size[0],
1206 NULL, NULL, "number of inventory elements"
1209 /* ---------- element settings: configure 1 (custom elements) ------------ */
1212 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1213 MIN_SCORE, MAX_SCORE,
1214 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1215 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1216 &custom_element.collect_score_initial,
1217 NULL, "CE score", " "
1220 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1221 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1222 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1223 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1224 &custom_element.collect_count_initial,
1225 NULL, "CE count", NULL
1228 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
1230 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1231 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1232 &custom_element.ce_value_fixed_initial,
1233 NULL, "CE value", NULL
1236 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
1238 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1239 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1240 &custom_element.ce_value_random_initial,
1241 NULL, "+random", NULL
1244 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1246 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1247 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1248 &custom_element.push_delay_fixed,
1249 NULL, "push delay", NULL
1252 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1254 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1255 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1256 &custom_element.push_delay_random,
1257 NULL, "+random", NULL
1260 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
1262 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1263 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1264 &custom_element.drop_delay_fixed,
1265 NULL, "drop delay", NULL
1268 -1, ED_ELEMENT_SETTINGS_YPOS(8),
1270 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1271 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1272 &custom_element.drop_delay_random,
1273 NULL, "+random", NULL
1276 /* ---------- element settings: configure 2 (custom elements) ------------ */
1279 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1281 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1282 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1283 &custom_element.move_delay_fixed,
1284 NULL, "move delay", NULL
1287 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1289 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1290 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1291 &custom_element.move_delay_random,
1292 NULL, "+random", NULL
1295 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
1297 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1298 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1299 &custom_element.explosion_delay,
1300 NULL, "explosion delay", NULL
1303 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1305 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1306 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1307 &custom_element.ignition_delay,
1308 NULL, "ignition delay", "(by fire)"
1311 /* ---------- element settings: configure (group elements) --------------- */
1314 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
1315 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1316 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1317 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1318 &group_element_info.num_elements,
1319 NULL, NULL, "number of elements in group"
1322 /* ---------- element settings: advanced (custom elements) --------------- */
1325 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1327 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1328 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1329 &custom_element_change.delay_fixed,
1330 NULL, "CE delay", NULL,
1333 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1335 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1336 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1337 &custom_element_change.delay_random,
1338 NULL, "+random", NULL
1341 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1343 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1344 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1345 &custom_element_change.random_percentage,
1346 NULL, "use random replace:", "%"
1356 char *text_above, *infotext;
1357 } textinput_info[ED_NUM_TEXTINPUT] =
1360 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1361 GADGET_ID_LEVEL_NAME,
1367 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1368 GADGET_ID_LEVEL_AUTHOR,
1369 MAX_LEVEL_AUTHOR_LEN,
1374 5 * MINI_TILEX - 2, 5 * MINI_TILEY - ED_BORDER_SIZE + 1,
1375 GADGET_ID_ELEMENT_NAME,
1376 MAX_ELEMENT_NAME_LEN - 2, /* currently 2 chars less editable */
1377 custom_element.description,
1378 NULL, "Element name"
1388 char *text_above, *infotext;
1389 } textarea_info[ED_NUM_TEXTAREAS] =
1392 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1393 GADGET_ID_ENVELOPE_INFO,
1394 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1396 "Envelope Content:", "Envelope Content"
1400 static struct ValueTextInfo options_time_or_steps[] =
1408 static struct ValueTextInfo options_game_engine_type[] =
1410 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1411 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1412 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1417 static struct ValueTextInfo options_wind_direction[] =
1419 { MV_START_NONE, "none" },
1420 { MV_START_LEFT, "left" },
1421 { MV_START_RIGHT, "right" },
1422 { MV_START_UP, "up" },
1423 { MV_START_DOWN, "down" },
1428 static struct ValueTextInfo options_player_speed[] =
1435 { 16, "very fast" },
1436 { 32, "ultrafast" },
1441 static struct ValueTextInfo options_access_type[] =
1443 { EP_WALKABLE, "walkable" },
1444 { EP_PASSABLE, "passable" },
1449 static struct ValueTextInfo options_access_layer[] =
1451 { EP_ACCESSIBLE_OVER, "over" },
1452 { EP_ACCESSIBLE_INSIDE, "inside" },
1453 { EP_ACCESSIBLE_UNDER, "under" },
1458 static struct ValueTextInfo options_access_protected[] =
1460 { 0, "unprotected" },
1466 static struct ValueTextInfo options_access_direction[] =
1468 { MV_NO_DIRECTION, "no direction" },
1469 { MV_LEFT, "left" },
1470 { MV_RIGHT, "right" },
1472 { MV_DOWN, "down" },
1473 { MV_LEFT | MV_UP, "left + up" },
1474 { MV_LEFT | MV_DOWN, "left + down" },
1475 { MV_RIGHT | MV_UP, "right + up" },
1476 { MV_RIGHT | MV_DOWN, "right + down" },
1477 { MV_HORIZONTAL, "horizontal" },
1478 { MV_VERTICAL, "vertical" },
1479 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1480 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1481 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1482 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1483 { MV_ALL_DIRECTIONS, "all directions" },
1488 static struct ValueTextInfo options_walk_to_action[] =
1490 { EP_DIGGABLE, "diggable" },
1491 { EP_COLLECTIBLE_ONLY, "collectible" },
1492 { EP_DROPPABLE, "collectible & droppable" },
1493 { EP_THROWABLE, "collectible & throwable" },
1494 { EP_PUSHABLE, "pushable" },
1499 static struct ValueTextInfo options_move_pattern[] =
1501 { MV_LEFT, "left" },
1502 { MV_RIGHT, "right" },
1504 { MV_DOWN, "down" },
1505 { MV_HORIZONTAL, "horizontal" },
1506 { MV_VERTICAL, "vertical" },
1507 { MV_ALL_DIRECTIONS, "all directions" },
1508 { MV_WIND_DIRECTION, "wind direction" },
1509 { MV_TOWARDS_PLAYER, "towards player" },
1510 { MV_AWAY_FROM_PLAYER, "away from player" },
1511 { MV_ALONG_LEFT_SIDE, "along left side" },
1512 { MV_ALONG_RIGHT_SIDE, "along right side" },
1513 { MV_TURNING_LEFT, "turning left" },
1514 { MV_TURNING_RIGHT, "turning right" },
1515 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1516 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1517 { MV_TURNING_RANDOM, "turning random" },
1518 { MV_MAZE_RUNNER, "maze runner style" },
1519 { MV_MAZE_HUNTER, "maze hunter style" },
1520 { MV_WHEN_PUSHED, "when pushed" },
1521 { MV_WHEN_DROPPED, "when dropped/thrown" },
1526 static struct ValueTextInfo options_move_direction[] =
1528 { MV_START_AUTOMATIC, "automatic" },
1529 { MV_START_LEFT, "left" },
1530 { MV_START_RIGHT, "right" },
1531 { MV_START_UP, "up" },
1532 { MV_START_DOWN, "down" },
1533 { MV_START_RANDOM, "random" },
1534 { MV_START_PREVIOUS, "previous" },
1539 static struct ValueTextInfo options_move_stepsize[] =
1541 { 0, "not moving" },
1546 { 16, "very fast" },
1547 { 32, "even faster" },
1552 static struct ValueTextInfo options_move_leave_type[] =
1554 { LEAVE_TYPE_UNLIMITED, "leave behind" },
1555 { LEAVE_TYPE_LIMITED, "change it to" },
1560 static struct ValueTextInfo options_smash_targets[] =
1562 { EP_CAN_SMASH_PLAYER, "player" },
1564 { EP_CAN_SMASH_ENEMIES, "enemies" },
1566 { EP_CAN_SMASH_EVERYTHING, "everything" },
1571 static struct ValueTextInfo options_slippery_type[] =
1573 { SLIPPERY_ANY_RANDOM, "random" },
1574 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
1575 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
1576 { SLIPPERY_ONLY_LEFT, "only left" },
1577 { SLIPPERY_ONLY_RIGHT, "only right" },
1582 static struct ValueTextInfo options_deadliness[] =
1584 { EP_DONT_RUN_INTO, "running into" },
1585 { EP_DONT_COLLIDE_WITH, "colliding with" },
1586 { EP_DONT_GET_HIT_BY, "getting hit by" },
1587 { EP_DONT_TOUCH, "touching" },
1592 static struct ValueTextInfo options_explosion_type[] =
1594 { EXPLODES_3X3, "3x3" },
1595 { EXPLODES_CROSS, "3+3" },
1596 { EXPLODES_1X1, "1x1" },
1601 static struct ValueTextInfo options_time_units[] =
1604 { FRAMES_PER_SECOND, "seconds" },
1609 static struct ValueTextInfo options_change_direct_action[] =
1611 { CE_TOUCHED_BY_PLAYER, "touched by player" },
1612 { CE_PRESSED_BY_PLAYER, "pressed by player" },
1613 { CE_SWITCHED_BY_PLAYER, "switched by player" },
1614 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
1615 { CE_PUSHED_BY_PLAYER, "pushed by player" },
1616 { CE_ENTERED_BY_PLAYER, "entered by player" },
1617 { CE_LEFT_BY_PLAYER, "left by player" },
1618 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
1619 { CE_SWITCHED, "switched" },
1620 { CE_HITTING_SOMETHING, "hitting something" },
1621 { CE_HIT_BY_SOMETHING, "hit by something" },
1623 { CE_BLOCKED, "blocked" },
1625 { CE_IMPACT, "impact (on something)" },
1626 { CE_SMASHED, "smashed (from above)" },
1628 { CE_VALUE_CHANGES, "CE value changes" },
1629 { CE_SCORE_CHANGES, "CE score changes" },
1631 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
1632 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
1637 static struct ValueTextInfo options_change_other_action[] =
1639 { CE_PLAYER_TOUCHES_X, "player touches" },
1640 { CE_PLAYER_PRESSES_X, "player presses" },
1641 { CE_PLAYER_SWITCHES_X, "player switches" },
1642 { CE_PLAYER_SNAPS_X, "player snaps" },
1643 { CE_PLAYER_PUSHES_X, "player pushes" },
1644 { CE_PLAYER_ENTERS_X, "player enters" },
1645 { CE_PLAYER_LEAVES_X, "player leaves" },
1646 { CE_PLAYER_DIGS_X, "player digs" },
1647 { CE_PLAYER_COLLECTS_X, "player collects" },
1648 { CE_PLAYER_DROPS_X, "player drops/throws" },
1649 { CE_TOUCHING_X, "touching" },
1650 { CE_HITTING_X, "hitting" },
1651 { CE_DIGGING_X, "digging" },
1652 { CE_HIT_BY_X, "hit by" },
1653 { CE_SWITCH_OF_X, "switch of" },
1654 { CE_CHANGE_OF_X, "change by page of" },
1655 { CE_EXPLOSION_OF_X, "explosion of" },
1656 { CE_MOVE_OF_X, "move of" },
1657 { CE_CREATION_OF_X, "creation of" },
1658 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
1659 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
1660 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
1661 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
1666 static struct ValueTextInfo options_change_trigger_side[] =
1668 { CH_SIDE_LEFT, "left" },
1669 { CH_SIDE_RIGHT, "right" },
1670 { CH_SIDE_TOP, "top" },
1671 { CH_SIDE_BOTTOM, "bottom" },
1672 { CH_SIDE_LEFT_RIGHT, "left/right" },
1673 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
1674 { CH_SIDE_ANY, "any" },
1679 static struct ValueTextInfo options_change_trigger_player[] =
1681 { CH_PLAYER_1, "1" },
1682 { CH_PLAYER_2, "2" },
1683 { CH_PLAYER_3, "3" },
1684 { CH_PLAYER_4, "4" },
1685 { CH_PLAYER_ANY, "any" },
1690 static struct ValueTextInfo options_change_trigger_page[] =
1702 { (1 << 10), "11" },
1703 { (1 << 11), "12" },
1704 { (1 << 12), "13" },
1705 { (1 << 13), "14" },
1706 { (1 << 14), "15" },
1707 { (1 << 15), "16" },
1708 { (1 << 16), "17" },
1709 { (1 << 17), "18" },
1710 { (1 << 18), "19" },
1711 { (1 << 19), "20" },
1712 { (1 << 20), "21" },
1713 { (1 << 21), "22" },
1714 { (1 << 22), "23" },
1715 { (1 << 23), "24" },
1716 { (1 << 24), "25" },
1717 { (1 << 25), "26" },
1718 { (1 << 26), "27" },
1719 { (1 << 27), "28" },
1720 { (1 << 28), "29" },
1721 { (1 << 29), "30" },
1722 { (1 << 30), "31" },
1723 { (1 << 31), "32" },
1724 { CH_PAGE_ANY, "any" },
1729 static struct ValueTextInfo options_change_replace_when[] =
1731 { CP_WHEN_EMPTY, "empty" },
1732 { CP_WHEN_WALKABLE, "walkable" },
1733 { CP_WHEN_DIGGABLE, "diggable" },
1734 { CP_WHEN_COLLECTIBLE, "collectible" },
1735 { CP_WHEN_REMOVABLE, "removable" },
1736 { CP_WHEN_DESTRUCTIBLE, "destructible" },
1741 static struct ValueTextInfo options_action_type[] =
1743 { CA_NO_ACTION, "no action" },
1744 { CA_UNDEFINED, " " },
1745 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
1746 { CA_RESTART_LEVEL, "restart level" },
1747 { CA_SHOW_ENVELOPE, "show envelope" },
1748 { CA_SET_LEVEL_TIME, "set time" },
1749 { CA_SET_LEVEL_SCORE, "set score" },
1750 { CA_SET_LEVEL_GEMS, "set gems" },
1751 { CA_SET_LEVEL_WIND, "set wind dir." },
1752 { CA_SET_LEVEL_RANDOM_SEED, "set rand. seed" },
1753 { CA_UNDEFINED, " " },
1754 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
1755 { CA_MOVE_PLAYER, "move player" },
1756 { CA_EXIT_PLAYER, "exit player" },
1757 { CA_KILL_PLAYER, "kill player" },
1758 { CA_SET_PLAYER_KEYS, "set keys" },
1759 { CA_SET_PLAYER_SPEED, "set speed" },
1760 { CA_SET_PLAYER_SHIELD, "set shield" },
1761 { CA_SET_PLAYER_GRAVITY, "set gravity" },
1762 { CA_SET_PLAYER_ARTWORK, "set artwork" },
1763 { CA_SET_PLAYER_INVENTORY, "set inventory" },
1764 { CA_UNDEFINED, " " },
1765 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
1766 { CA_SET_CE_VALUE, "set CE value" },
1767 { CA_SET_CE_SCORE, "set CE score" },
1768 { CA_SET_CE_ARTWORK, "set CE artwork" },
1769 { CA_UNDEFINED, " " },
1770 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
1771 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
1776 static struct ValueTextInfo options_action_mode_none[] =
1778 { CA_MODE_UNDEFINED, " " },
1783 static struct ValueTextInfo options_action_mode_assign[] =
1785 { CA_MODE_SET, "=" },
1790 static struct ValueTextInfo options_action_mode_add_remove[] =
1792 { CA_MODE_ADD, "+" },
1793 { CA_MODE_SUBTRACT, "-" },
1798 static struct ValueTextInfo options_action_mode_calculate[] =
1800 { CA_MODE_SET, "=" },
1801 { CA_MODE_ADD, "+" },
1802 { CA_MODE_SUBTRACT, "-" },
1803 { CA_MODE_MULTIPLY, "*" },
1804 { CA_MODE_DIVIDE, "/" },
1805 { CA_MODE_MODULO, "%" },
1810 static struct ValueTextInfo options_action_arg_none[] =
1812 { CA_ARG_UNDEFINED, " " },
1817 static struct ValueTextInfo options_action_arg_player[] =
1819 { CA_ARG_PLAYER_HEADLINE, "[player]" },
1820 { CA_ARG_PLAYER_1, "1" },
1821 { CA_ARG_PLAYER_2, "2" },
1822 { CA_ARG_PLAYER_3, "3" },
1823 { CA_ARG_PLAYER_4, "4" },
1824 { CA_ARG_PLAYER_ANY, "any" },
1825 { CA_ARG_PLAYER_TRIGGER, "trigger" },
1826 { CA_ARG_PLAYER_ACTION, "action ->" },
1831 static struct ValueTextInfo options_action_arg_number[] =
1833 { CA_ARG_NUMBER_HEADLINE, "[number]" },
1840 { CA_ARG_10, "10" },
1841 { CA_ARG_100, "100" },
1842 { CA_ARG_1000, "1000" },
1843 { CA_ARG_UNDEFINED, " " },
1844 { CA_ARG_NUMBER_MIN, "min" },
1845 { CA_ARG_NUMBER_MAX, "max" },
1846 { CA_ARG_UNDEFINED, " " },
1847 { CA_ARG_NUMBER_RESET, "reset" },
1848 { CA_ARG_UNDEFINED, " " },
1849 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
1850 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
1851 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
1852 { CA_ARG_UNDEFINED, " " },
1853 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
1854 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
1855 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
1856 { CA_ARG_UNDEFINED, " " },
1857 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
1858 { CA_ARG_ELEMENT_CV_TARGET, "target" },
1859 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
1860 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
1861 { CA_ARG_UNDEFINED, " " },
1862 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
1863 { CA_ARG_ELEMENT_CS_TARGET, "target" },
1864 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
1865 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
1870 static struct ValueTextInfo options_action_arg_value[] =
1872 { CA_ARG_NUMBER_HEADLINE, "[number]" },
1879 { CA_ARG_10, "10" },
1880 { CA_ARG_100, "100" },
1881 { CA_ARG_1000, "1000" },
1882 { CA_ARG_UNDEFINED, " " },
1883 { CA_ARG_NUMBER_MIN, "min" },
1884 { CA_ARG_NUMBER_MAX, "max" },
1885 { CA_ARG_UNDEFINED, " " },
1886 { CA_ARG_NUMBER_RESET, "reset" },
1887 { CA_ARG_UNDEFINED, " " },
1888 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
1889 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
1890 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
1891 { CA_ARG_UNDEFINED, " " },
1892 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
1893 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
1894 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
1895 { CA_ARG_UNDEFINED, " " },
1896 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
1897 { CA_ARG_ELEMENT_CV_TARGET, "target" },
1898 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
1899 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
1900 { CA_ARG_UNDEFINED, " " },
1901 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
1902 { CA_ARG_ELEMENT_CS_TARGET, "target" },
1903 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
1904 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
1905 { CA_ARG_UNDEFINED, " " },
1906 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
1907 { CA_ARG_ELEMENT_NR_TARGET, "target" },
1908 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
1909 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
1914 static struct ValueTextInfo options_action_arg_envelope[] =
1916 { CA_ARG_NUMBER_HEADLINE, "[number]" },
1921 { CA_ARG_UNDEFINED, " " },
1922 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
1923 { CA_ARG_ELEMENT_TARGET, "target" },
1924 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
1925 { CA_ARG_ELEMENT_ACTION, "action ->" },
1930 static struct ValueTextInfo options_action_arg_key[] =
1932 { CA_ARG_NUMBER_HEADLINE, "[number]" },
1941 { CA_ARG_UNDEFINED, " " },
1942 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
1943 { CA_ARG_ELEMENT_TARGET, "target" },
1944 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
1945 { CA_ARG_ELEMENT_ACTION, "action ->" },
1950 static struct ValueTextInfo options_action_arg_speed[] =
1952 { CA_ARG_SPEED_HEADLINE, "[speed]" },
1953 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
1954 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
1955 { CA_ARG_SPEED_SLOW, "slow" },
1956 { CA_ARG_SPEED_NORMAL, "normal" },
1957 { CA_ARG_SPEED_FAST, "fast" },
1958 { CA_ARG_SPEED_VERY_FAST, "very fast" },
1959 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
1960 { CA_ARG_UNDEFINED, " " },
1961 { CA_ARG_SPEED_SLOWER, "slower" },
1962 { CA_ARG_SPEED_FASTER, "faster" },
1963 { CA_ARG_UNDEFINED, " " },
1964 { CA_ARG_SPEED_RESET, "reset" },
1969 static struct ValueTextInfo options_action_arg_shield[] =
1971 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
1972 { CA_ARG_SHIELD_OFF, "off" },
1973 { CA_ARG_SHIELD_NORMAL, "normal" },
1974 { CA_ARG_SHIELD_DEADLY, "deadly" },
1979 static struct ValueTextInfo options_action_arg_artwork[] =
1981 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
1982 { CA_ARG_ELEMENT_TARGET, "target" },
1983 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
1984 { CA_ARG_ELEMENT_ACTION, "action ->" },
1985 { CA_ARG_UNDEFINED, " " },
1986 { CA_ARG_ELEMENT_RESET, "reset" },
1991 static struct ValueTextInfo options_action_arg_gravity[] =
1993 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
1994 { CA_ARG_GRAVITY_ON, "on" },
1995 { CA_ARG_GRAVITY_OFF, "off" },
1996 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2001 static struct ValueTextInfo options_action_arg_direction[] =
2003 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2004 { CA_ARG_DIRECTION_NONE, "none" },
2005 { CA_ARG_DIRECTION_LEFT, "left" },
2006 { CA_ARG_DIRECTION_RIGHT, "right" },
2007 { CA_ARG_DIRECTION_UP, "up" },
2008 { CA_ARG_DIRECTION_DOWN, "down" },
2009 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2010 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2015 static struct ValueTextInfo options_action_arg_scan_mode[] =
2017 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2018 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2019 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2024 static struct ValueTextInfo options_action_arg_inventory[] =
2026 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2027 { CA_ARG_ELEMENT_TARGET, "+ target" },
2028 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2029 { CA_ARG_ELEMENT_ACTION, "+ action" },
2030 { CA_ARG_UNDEFINED, " " },
2031 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2032 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2033 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2034 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2035 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2036 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2037 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2038 { CA_ARG_UNDEFINED, " " },
2039 { CA_ARG_INVENTORY_RESET, "reset" },
2044 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2045 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2050 static struct ValueTextInfo options_group_choice_mode[] =
2052 { ANIM_RANDOM, "random" },
2053 { ANIM_LOOP, "loop" },
2054 { ANIM_LINEAR, "linear" },
2055 { ANIM_PINGPONG, "pingpong" },
2056 { ANIM_PINGPONG2, "pingpong 2" },
2061 static struct ValueTextInfo *action_arg_modes[] =
2063 options_action_mode_none,
2064 options_action_mode_assign,
2065 options_action_mode_add_remove,
2066 options_action_mode_calculate,
2073 struct ValueTextInfo *options;
2075 action_arg_options[] =
2077 { CA_NO_ACTION, 0, options_action_arg_none, },
2078 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2079 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2080 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2081 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2082 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2083 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2084 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2085 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2086 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2087 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2088 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2089 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2090 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2091 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2092 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2093 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2094 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2095 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2096 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2097 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2106 int gadget_id_align;
2107 int size; /* char size of selectbox or '-1' (dynamically determined) */
2108 struct ValueTextInfo *options;
2110 char *text_left, *text_right, *infotext;
2111 } selectbox_info[ED_NUM_SELECTBOX] =
2113 /* ---------- level and editor settings ---------------------------------- */
2116 -1, ED_LEVEL_SETTINGS_YPOS(7),
2117 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2119 options_time_or_steps,
2120 &level.use_step_counter,
2121 NULL, "(0 => no limit)", "time or step limit"
2124 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
2125 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2127 options_game_engine_type,
2128 &level.game_engine_type,
2129 "game engine:", NULL, "game engine"
2132 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2133 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2135 options_wind_direction,
2136 &level.wind_direction_initial,
2137 "initial wind direction:", NULL, "initial wind direction"
2140 /* ---------- element settings: configure (several elements) ------------- */
2143 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
2144 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2146 options_player_speed,
2147 &level.initial_player_stepsize[0],
2148 "initial player speed:", NULL, "initial player speed"
2151 /* ---------- element settings: configure 1 (custom elements) ------------ */
2154 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2155 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2157 options_access_type,
2158 &custom_element.access_type,
2159 NULL, NULL, "type of access to this field"
2162 -1, ED_ELEMENT_SETTINGS_YPOS(3),
2163 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2165 options_access_layer,
2166 &custom_element.access_layer,
2167 NULL, NULL, "layer of access for this field"
2170 -1, ED_ELEMENT_SETTINGS_YPOS(3),
2171 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2173 options_access_protected,
2174 &custom_element.access_protected,
2175 NULL, NULL, "protected access for this field"
2178 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2179 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2181 options_access_direction,
2182 &custom_element.access_direction,
2183 "from", NULL, "access direction for this field"
2186 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
2187 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2189 options_walk_to_action,
2190 &custom_element.walk_to_action,
2191 NULL, NULL, "diggable/collectible/pushable"
2194 /* ---------- element settings: configure 2 (custom elements) ------------ */
2197 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2198 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2200 options_move_pattern,
2201 &custom_element.move_pattern,
2202 "can move", NULL, "element move pattern"
2205 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2206 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2208 options_move_direction,
2209 &custom_element.move_direction_initial,
2210 "starts moving", NULL, "initial element move direction"
2213 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2214 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2216 options_move_stepsize,
2217 &custom_element.move_stepsize,
2218 "move/fall speed", NULL, "speed of element movement"
2221 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2222 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2224 options_move_leave_type,
2225 &custom_element.move_leave_type,
2226 "can dig: can", ":", "leave behind or change element"
2229 -1, ED_ELEMENT_SETTINGS_YPOS(7),
2230 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2232 options_smash_targets,
2233 &custom_element.smash_targets,
2234 "can smash", NULL, "elements that can be smashed"
2237 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
2238 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2240 options_slippery_type,
2241 &custom_element.slippery_type,
2242 "slippery", NULL, "where other elements fall down"
2245 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2246 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2249 &custom_element.deadliness,
2250 "deadly when", NULL, "deadliness of element"
2253 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2254 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2256 options_explosion_type,
2257 &custom_element.explosion_type,
2258 "can explode", NULL, "explosion type"
2261 /* ---------- element settings: advanced (custom elements) --------------- */
2264 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2265 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2268 &custom_element_change.delay_frames,
2269 "delay time given in", NULL, "delay time units for change"
2272 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2273 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2275 options_change_direct_action,
2276 &custom_element_change.direct_action,
2277 NULL, NULL, "type of direct action"
2280 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2281 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2283 options_change_other_action,
2284 &custom_element_change.other_action,
2285 NULL, "element:", "type of other element action"
2288 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2289 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2291 options_change_trigger_side,
2292 &custom_element_change.trigger_side,
2293 "at", "side", "element side triggering change"
2296 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2297 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2299 options_change_trigger_player,
2300 &custom_element_change.trigger_player,
2301 "player:", " ", "player that causes change"
2304 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2305 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2307 options_change_trigger_page,
2308 &custom_element_change.trigger_page,
2309 "page:", NULL, "change page that causes change"
2312 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2313 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2315 options_change_replace_when,
2316 &custom_element_change.replace_when,
2317 "replace when", NULL, "which elements can be replaced"
2320 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2321 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2323 options_action_type,
2324 &custom_element_change.action_type,
2325 NULL, NULL, "action on specified condition"
2328 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2329 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2331 options_action_mode_none,
2332 &custom_element_change.action_mode,
2333 NULL, NULL, "action operator"
2336 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2337 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2339 options_action_arg_none,
2340 &custom_element_change.action_arg,
2341 NULL, NULL, "action parameter"
2344 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2345 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2347 options_change_page,
2348 &custom_element.current_change_page,
2349 NULL, NULL, "element change page"
2352 /* ---------- element settings: configure (group elements) --------------- */
2355 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
2356 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2358 options_group_choice_mode,
2359 &group_element_info.choice_mode,
2360 "choice type:", NULL, "type of group element choice"
2368 int gadget_id_align;
2371 char *text_left, *text_right, *infotext;
2372 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2375 ED_LEVEL_SETTINGS_TABS_XPOS(0), ED_LEVEL_SETTINGS_TABS_YPOS(0),
2376 GADGET_ID_LEVELINFO_LEVEL, GADGET_ID_NONE,
2378 NULL, NULL, "Configure level properties"
2381 ED_LEVEL_SETTINGS_TABS_XPOS(1), ED_LEVEL_SETTINGS_TABS_YPOS(0),
2382 GADGET_ID_LEVELINFO_EDITOR, GADGET_ID_NONE,
2384 NULL, NULL, "Configure editor properties"
2387 ED_ELEMENT_SETTINGS_TABS_XPOS(0), ED_ELEMENT_SETTINGS_TABS_YPOS(0),
2388 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
2390 NULL, NULL, "Show information about element"
2393 ED_ELEMENT_SETTINGS_TABS_XPOS(1), ED_ELEMENT_SETTINGS_TABS_YPOS(0),
2394 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_NONE,
2396 NULL, NULL, "Configure element properties"
2399 ED_ELEMENT_SETTINGS_TABS_XPOS(1), ED_ELEMENT_SETTINGS_TABS_YPOS(0),
2400 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_NONE,
2402 NULL, NULL, "Configure element properties, part 1"
2405 ED_ELEMENT_SETTINGS_TABS_XPOS(2), ED_ELEMENT_SETTINGS_TABS_YPOS(0),
2406 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_NONE,
2408 NULL, NULL, "Configure element properties, part 2"
2411 ED_ELEMENT_SETTINGS_TABS_XPOS(3), ED_ELEMENT_SETTINGS_TABS_YPOS(0),
2412 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_NONE,
2414 NULL, NULL, "Configure custom element change pages"
2417 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2418 GADGET_ID_SAVE_AS_TEMPLATE, GADGET_ID_CUSTOM_USE_TEMPLATE,
2420 " ", "As Template", "Save current settings as new template"
2423 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2424 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
2426 NULL, NULL, "Add new change page"
2429 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2430 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
2432 NULL, NULL, "Delete current change page"
2442 int gadget_id_align;
2443 char *text_left, *text_right, *infotext;
2444 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
2447 ED_BUTTON_MINUS_XPOS, ED_BUTTON_COUNT_YPOS,
2448 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
2449 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
2450 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
2451 NULL, NULL, "select previous change page"
2454 ED_BUTTON_PLUS_XPOS, ED_BUTTON_COUNT_YPOS,
2455 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2456 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
2457 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
2458 NULL, "change page", "select next change page"
2461 ED_COPY_CHANGE_PAGE_XPOS, ED_COPY_CHANGE_PAGE_YPOS,
2462 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2463 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
2464 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
2465 " ", NULL, "copy settings from this change page"
2468 ED_PASTE_CHANGE_PAGE_XPOS, ED_PASTE_CHANGE_PAGE_YPOS,
2469 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2470 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
2471 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
2472 NULL, NULL, "paste settings to this change page"
2482 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
2485 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 0 * ED_SCROLLBUTTON_YSIZE,
2487 -1, -1, /* these values are not constant, but can change at runtime */
2489 ED_SCROLL_UP_XPOS, ED_SCROLL_UP_YPOS,
2491 GADGET_ID_SCROLL_UP,
2492 "scroll level editing area up"
2495 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 1 * ED_SCROLLBUTTON_YSIZE,
2497 -1, -1, /* these values are not constant, but can change at runtime */
2499 ED_SCROLL_DOWN_XPOS, ED_SCROLL_DOWN_YPOS,
2501 GADGET_ID_SCROLL_DOWN,
2502 "scroll level editing area down"
2505 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 2 * ED_SCROLLBUTTON_YSIZE,
2507 -1, -1, /* these values are not constant, but can change at runtime */
2509 ED_SCROLL_LEFT_XPOS, ED_SCROLL_LEFT_YPOS,
2511 GADGET_ID_SCROLL_LEFT,
2512 "scroll level editing area left"
2515 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 3 * ED_SCROLLBUTTON_YSIZE,
2517 -1, -1, /* these values are not constant, but can change at runtime */
2519 ED_SCROLL_RIGHT_XPOS, ED_SCROLL_RIGHT_YPOS,
2521 GADGET_ID_SCROLL_RIGHT,
2522 "scroll level editing area right"
2525 ED_SCROLLBUTTON2_XPOS, ED_SCROLLBUTTON2_YPOS + 0 * ED_SCROLLBUTTON2_YSIZE,
2526 ED_SCROLL2_UP_XPOS, ED_SCROLL2_UP_YPOS,
2527 GADGET_ID_SCROLL_LIST_UP,
2528 "scroll element list up ('Page Up')"
2531 ED_SCROLLBUTTON2_XPOS, ED_SCROLLBUTTON2_YPOS + 1 * ED_SCROLLBUTTON2_YSIZE,
2532 ED_SCROLL2_DOWN_XPOS, ED_SCROLL2_DOWN_YPOS,
2533 GADGET_ID_SCROLL_LIST_DOWN,
2534 "scroll element list down ('Page Down')"
2543 int wheel_x, wheel_y;
2544 int wheel_width, wheel_height;
2548 } scrollbar_info[ED_NUM_SCROLLBARS] =
2551 ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
2553 -1, -1, /* these values are not constant, but can change at runtime */
2554 -1, -1, /* these values are not constant, but can change at runtime */
2555 -1, -1, /* these values are not constant, but can change at runtime */
2556 -1, -1, /* these values are not constant, but can change at runtime */
2558 SX + ED_SCROLL_HORIZONTAL_XPOS, SY + ED_SCROLL_HORIZONTAL_YPOS,
2559 ED_SCROLL_HORIZONTAL_XSIZE, ED_SCROLL_HORIZONTAL_YSIZE,
2563 GD_TYPE_SCROLLBAR_HORIZONTAL,
2564 GADGET_ID_SCROLL_HORIZONTAL,
2565 "scroll level editing area horizontally"
2568 ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
2570 -1, -1, /* these values are not constant, but can change at runtime */
2571 -1, -1, /* these values are not constant, but can change at runtime */
2572 -1, -1, /* these values are not constant, but can change at runtime */
2573 -1, -1, /* these values are not constant, but can change at runtime */
2575 SX + ED_SCROLL_VERTICAL_XPOS, SY + ED_SCROLL_VERTICAL_YPOS,
2576 ED_SCROLL_VERTICAL_XSIZE, ED_SCROLL_VERTICAL_YSIZE,
2580 GD_TYPE_SCROLLBAR_VERTICAL,
2581 GADGET_ID_SCROLL_VERTICAL,
2582 "scroll level editing area vertically"
2585 ED_SCROLLBAR2_XPOS, ED_SCROLLBAR2_YPOS,
2587 -1, -1, /* these values are not constant, but can change at runtime */
2588 ED_SCROLL2_VERTICAL_XSIZE, ED_SCROLL2_VERTICAL_YSIZE,
2589 -1, -1, /* these values are not constant, but can change at runtime */
2591 DX + ED_SCROLL2_VERTICAL_XPOS, DY + ED_SCROLL2_VERTICAL_YPOS,
2592 ED_SCROLL2_VERTICAL_XSIZE, ED_SCROLL2_VERTICAL_YSIZE,
2596 GD_TYPE_SCROLLBAR_VERTICAL,
2597 GADGET_ID_SCROLL_LIST_VERTICAL,
2598 "scroll element list vertically"
2606 int gadget_id_align;
2607 int radio_button_nr;
2610 char *text_left, *text_right, *infotext;
2611 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
2614 -1, ED_LEVEL_SETTINGS_YPOS(0),
2615 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
2616 RADIO_NR_RANDOM_ELEMENTS,
2617 &random_placement_method, RANDOM_USE_PERCENTAGE,
2618 " ", "percentage", "use percentage for random elements"
2621 -1, ED_LEVEL_SETTINGS_YPOS(0),
2622 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
2623 RADIO_NR_RANDOM_ELEMENTS,
2624 &random_placement_method, RANDOM_USE_QUANTITY,
2625 " ", "quantity", "use quantity for random elements"
2633 int gadget_id_align;
2635 char *text_left, *text_right, *infotext;
2636 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
2638 /* ---------- level and editor settings ---------------------------------- */
2641 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
2642 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
2643 &random_placement_background_restricted,
2645 "restrict random placement to:", "set random placement restriction"
2648 /* ---------- element settings: configure (various elements) ------------- */
2651 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2652 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
2653 &stick_element_properties_window,
2655 "stick this screen to edit content","stick this screen to edit content"
2658 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2659 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
2660 &level.em_slippery_gems,
2662 "slip down from certain flat walls","use EM/DC style slipping behaviour"
2665 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2666 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
2667 &level.em_explodes_by_fire,
2669 "explodes with chain reaction", "use R'n'D style explosion behaviour"
2672 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2673 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
2674 &level.use_spring_bug,
2676 "use spring pushing bug", "use odd spring pushing behaviour"
2679 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2680 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
2681 &level.use_time_orb_bug,
2683 "use time orb bug", "use odd time orb behaviour"
2686 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2687 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
2690 "create single random element", "only create one element from content"
2693 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2694 GADGET_ID_INITIAL_BALL_STATE, GADGET_ID_NONE,
2695 &level.ball_state_initial,
2697 "magic ball initially activated", "activate magic ball after level start"
2700 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2701 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
2702 &level.grow_into_diggable,
2704 "can grow into anything diggable", "grow into more than just sand"
2707 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2708 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
2709 &level.auto_exit_sokoban,
2711 "exit level if all fields solved", "automatically finish Sokoban levels"
2714 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
2715 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
2716 &level.continuous_snapping,
2718 "continuos snapping", "use snapping without releasing key"
2721 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2722 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
2723 &level.block_snap_field,
2725 "block snapped field when snapping", "use snapping delay to show animation"
2728 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2729 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
2730 &level.block_last_field,
2732 "block last field when moving", "player blocks last field when moving"
2735 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2736 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
2737 &level.sp_block_last_field,
2739 "block last field when moving", "player blocks last field when moving"
2742 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
2743 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
2744 &level.instant_relocation,
2746 "no scrolling when relocating", "player gets relocated without delay"
2749 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2750 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
2751 &level.shifted_relocation,
2753 "no centering when relocating", "level not centered after relocation"
2756 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
2757 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
2758 &level.use_start_element[0],
2760 "use level start element:", "start level at this element's position"
2763 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
2764 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
2765 &level.use_artwork_element[0],
2767 "use artwork from element:", "use player artwork from other element"
2770 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
2771 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
2772 &level.use_explosion_element[0],
2774 "use explosion from element:", "use explosion properties from element"
2777 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
2778 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
2779 &level.initial_player_gravity[0],
2781 "use initial gravity", "set initial player gravity"
2784 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2785 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
2786 &level.use_initial_inventory[0],
2788 "use initial inventory:", "use collected elements on level start"
2791 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
2792 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
2793 &level.can_pass_to_walkable,
2795 "can pass to walkable element", "player can pass to empty or walkable"
2798 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2799 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
2800 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
2802 "can fall into acid (with gravity)","player can fall into acid pool"
2805 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2806 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
2807 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
2809 "can move into acid", "element can move into acid pool"
2812 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2813 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
2814 &custom_element_properties[EP_DONT_COLLIDE_WITH],
2816 "deadly when colliding with", "element is deadly when hitting player"
2819 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2820 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
2821 &level.envelope[0].autowrap,
2823 "auto-wrap", "automatically wrap envelope text"
2826 -1, ED_ELEMENT_SETTINGS_YPOS(1),
2827 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
2828 &level.envelope[0].centered,
2830 "centered", "automatically center envelope text"
2833 /* ---------- element settings: configure 1 (custom elements) ----------- */
2836 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2837 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
2838 &custom_element.use_gfx_element,
2840 /* !!! add separate "use existing element sound" !!! */
2843 "use graphic/sound of element:", "use existing graphic and sound"
2846 "use graphic of element:", "use existing element graphic"
2850 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2851 GADGET_ID_CUSTOM_USE_TEMPLATE, GADGET_ID_NONE,
2852 &level.use_custom_template,
2854 "use template", "use template for custom properties"
2857 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
2858 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
2859 &custom_element_properties[EP_ACCESSIBLE],
2861 NULL, "player can walk to or pass this field"
2864 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
2865 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
2866 &custom_element_properties[EP_GRAVITY_REACHABLE],
2868 "reachable despite gravity", "player can walk/dig despite gravity"
2871 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
2872 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
2873 &custom_element.use_last_ce_value,
2875 "use last CE value after change", "use last CE value after change"
2878 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
2879 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
2880 &custom_element_properties[EP_WALK_TO_OBJECT],
2882 NULL, "player can dig/collect/push element"
2885 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
2886 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
2887 &custom_element_properties[EP_INDESTRUCTIBLE],
2889 "indestructible", "element is indestructible"
2892 /* ---------- element settings: configure 2 (custom elements) ----------- */
2895 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2896 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
2897 &custom_element_properties[EP_CAN_MOVE],
2899 NULL, "element can move with some pattern"
2902 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2903 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
2904 &custom_element_properties[EP_CAN_FALL],
2906 "can fall", "element can fall down"
2909 -1, ED_ELEMENT_SETTINGS_YPOS(7),
2910 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
2911 &custom_element_properties[EP_CAN_SMASH],
2913 NULL, "element can smash other elements"
2916 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
2917 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
2918 &custom_element_properties[EP_SLIPPERY],
2920 NULL, "other elements can fall down from it"
2923 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
2924 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
2925 &custom_element_properties[EP_DEADLY],
2927 NULL, "element can kill the player"
2930 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
2931 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
2932 &custom_element_properties[EP_CAN_EXPLODE],
2934 NULL, "element can explode"
2937 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
2938 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
2939 &custom_element_properties[EP_EXPLODES_BY_FIRE],
2941 "by fire", "element can explode by fire/explosion"
2944 -1, ED_ELEMENT_SETTINGS_YPOS(11),
2945 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
2946 &custom_element_properties[EP_EXPLODES_SMASHED],
2948 "smashed", "element can explode when smashed"
2951 -1, ED_ELEMENT_SETTINGS_YPOS(11),
2952 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
2953 &custom_element_properties[EP_EXPLODES_IMPACT],
2955 "impact", "element can explode on impact"
2958 /* ---------- element settings: advanced (custom elements) --------------- */
2961 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2962 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
2963 &custom_element_change.can_change,
2965 "element changes to:", "change element on specified condition"
2968 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2969 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
2970 &custom_element_change_events[CE_DELAY],
2972 NULL, "element changes after delay"
2975 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2976 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
2977 &custom_element_change_events[CE_BY_DIRECT_ACTION],
2979 NULL, "element changes by direct action"
2982 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
2983 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
2984 &custom_element_change_events[CE_BY_OTHER_ACTION],
2986 NULL, "element changes by other element"
2989 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
2990 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
2991 &custom_element_change.explode,
2993 "explode instead of change", "element explodes instead of change"
2996 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2997 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
2998 &custom_element_change.use_target_content,
3000 "use extended change target:", "element changes to more elements"
3003 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3004 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3005 &custom_element_change.only_if_complete,
3007 "replace all or nothing", "only replace when all can be changed"
3010 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3011 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3012 &custom_element_change.use_random_replace,
3014 NULL, "use percentage for random replace"
3017 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3018 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3019 &custom_element_change.has_action,
3021 NULL, "execute action on specified condition"
3029 int gadget_id_align;
3031 int area_xsize, area_ysize;
3032 char *text_left, *text_right, *text_below, *infotext;
3033 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3035 /* ---------- level playfield content ------------------------------------ */
3039 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
3042 -1, -1, /* these values are not constant, but can change at runtime */
3044 MAX_ED_FIELDX, MAX_ED_FIELDY,
3046 NULL, NULL, NULL, NULL
3049 /* ---------- yam yam content -------------------------------------------- */
3052 ED_AREA_YAMYAM_CONTENT_XPOS(0), ED_AREA_YAMYAM_CONTENT_YPOS(0),
3053 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
3054 &level.yamyam_content[0].e[0][0], 3, 3,
3055 NULL, NULL, "1", NULL
3058 ED_AREA_YAMYAM_CONTENT_XPOS(1), ED_AREA_YAMYAM_CONTENT_YPOS(1),
3059 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
3060 &level.yamyam_content[1].e[0][0], 3, 3,
3061 NULL, NULL, "2", NULL
3064 ED_AREA_YAMYAM_CONTENT_XPOS(2), ED_AREA_YAMYAM_CONTENT_YPOS(2),
3065 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
3066 &level.yamyam_content[2].e[0][0], 3, 3,
3067 NULL, NULL, "3", NULL
3070 ED_AREA_YAMYAM_CONTENT_XPOS(3), ED_AREA_YAMYAM_CONTENT_YPOS(3),
3071 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
3072 &level.yamyam_content[3].e[0][0], 3, 3,
3073 NULL, NULL, "4", NULL
3076 ED_AREA_YAMYAM_CONTENT_XPOS(4), ED_AREA_YAMYAM_CONTENT_YPOS(4),
3077 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
3078 &level.yamyam_content[4].e[0][0], 3, 3,
3079 NULL, NULL, "5", NULL
3082 ED_AREA_YAMYAM_CONTENT_XPOS(5), ED_AREA_YAMYAM_CONTENT_YPOS(5),
3083 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
3084 &level.yamyam_content[5].e[0][0], 3, 3,
3085 NULL, NULL, "6", NULL
3088 ED_AREA_YAMYAM_CONTENT_XPOS(6), ED_AREA_YAMYAM_CONTENT_YPOS(6),
3089 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
3090 &level.yamyam_content[6].e[0][0], 3, 3,
3091 NULL, NULL, "7", NULL
3094 ED_AREA_YAMYAM_CONTENT_XPOS(7), ED_AREA_YAMYAM_CONTENT_YPOS(7),
3095 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
3096 &level.yamyam_content[7].e[0][0], 3, 3,
3097 NULL, NULL, "8", NULL
3100 /* ---------- magic ball content ----------------------------------------- */
3103 ED_AREA_MAGIC_BALL_CONTENT_XPOS(0), ED_AREA_MAGIC_BALL_CONTENT_YPOS(0),
3104 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
3105 &level.ball_content[0].e[0][0], 3, 3,
3106 NULL, NULL, "1", NULL
3109 ED_AREA_MAGIC_BALL_CONTENT_XPOS(1), ED_AREA_MAGIC_BALL_CONTENT_YPOS(1),
3110 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
3111 &level.ball_content[1].e[0][0], 3, 3,
3112 NULL, NULL, "2", NULL
3115 ED_AREA_MAGIC_BALL_CONTENT_XPOS(2), ED_AREA_MAGIC_BALL_CONTENT_YPOS(2),
3116 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
3117 &level.ball_content[2].e[0][0], 3, 3,
3118 NULL, NULL, "3", NULL
3121 ED_AREA_MAGIC_BALL_CONTENT_XPOS(3), ED_AREA_MAGIC_BALL_CONTENT_YPOS(3),
3122 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
3123 &level.ball_content[3].e[0][0], 3, 3,
3124 NULL, NULL, "4", NULL
3127 ED_AREA_MAGIC_BALL_CONTENT_XPOS(4), ED_AREA_MAGIC_BALL_CONTENT_YPOS(4),
3128 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
3129 &level.ball_content[4].e[0][0], 3, 3,
3130 NULL, NULL, "5", NULL
3133 ED_AREA_MAGIC_BALL_CONTENT_XPOS(5), ED_AREA_MAGIC_BALL_CONTENT_YPOS(5),
3134 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
3135 &level.ball_content[5].e[0][0], 3, 3,
3136 NULL, NULL, "6", NULL
3139 ED_AREA_MAGIC_BALL_CONTENT_XPOS(6), ED_AREA_MAGIC_BALL_CONTENT_YPOS(6),
3140 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
3141 &level.ball_content[6].e[0][0], 3, 3,
3142 NULL, NULL, "7", NULL
3145 ED_AREA_MAGIC_BALL_CONTENT_XPOS(7), ED_AREA_MAGIC_BALL_CONTENT_YPOS(7),
3146 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
3147 &level.ball_content[7].e[0][0], 3, 3,
3148 NULL, NULL, "8", NULL
3151 /* ---------- android content -------------------------------------------- */
3154 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(5),
3155 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
3156 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
3157 "elements:", NULL, NULL, "elements android can clone"
3160 /* ---------- amoeba content --------------------------------------------- */
3163 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
3164 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
3165 &level.amoeba_content, 1, 1,
3166 "content:", NULL, NULL, "amoeba content"
3169 /* ---------- level start element ---------------------------------------- */
3172 -1, ED_AREA_1X1_SETTINGS_YPOS(9),
3173 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
3174 &level.start_element[0], 1, 1,
3175 NULL, NULL, NULL, "level start element"
3178 /* ---------- player artwork element ------------------------------------- */
3181 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
3182 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
3183 &level.artwork_element[0], 1, 1,
3184 NULL, NULL, NULL, "element for player artwork"
3187 /* ---------- player explosion element ----------------------------------- */
3190 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
3191 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
3192 &level.explosion_element[0], 1, 1,
3193 NULL, NULL, NULL, "element for player explosion"
3196 /* ---------- player initial inventory ----------------------------------- */
3199 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3200 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
3201 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
3202 NULL, NULL, NULL, "content for initial inventory"
3205 /* ---------- element settings: configure 1 (custom elements) ----------- */
3207 /* ---------- custom graphic --------------------------------------------- */
3210 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3211 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
3212 &custom_element.gfx_element_initial,1, 1,
3213 NULL, NULL, NULL, "custom graphic element"
3216 /* ---------- element settings: configure 2 (custom elements) ----------- */
3218 /* ---------- custom content (when exploding) ---------------------------- */
3221 -1, ED_AREA_3X3_SETTINGS_YPOS(10),
3222 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, /* align three rows */
3223 &custom_element.content.e[0][0], 3, 3,
3224 "content:", NULL, NULL, NULL
3227 /* ---------- custom enter and leave element (when moving) --------------- */
3230 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
3231 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
3232 &custom_element.move_enter_element, 1, 1,
3233 "can dig:", " ", NULL, "element that can be digged/collected"
3236 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
3237 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
3238 &custom_element.move_leave_element, 1, 1,
3239 NULL, NULL, NULL, "element that will be left behind"
3242 /* ---------- element settings: advanced (custom elements) --------------- */
3244 /* ---------- custom change target --------------------------------------- */
3247 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3248 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
3249 &custom_element_change.target_element, 1, 1,
3250 NULL, "after/when:", NULL, "new target element after change"
3253 /* ---------- custom change content (extended change target) ------------- */
3256 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
3257 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, /* align three rows */
3258 &custom_element_change.target_content.e[0][0], 3, 3,
3259 NULL, NULL, NULL, "new extended elements after change"
3262 /* ---------- custom change trigger (element causing change) ------------- */
3265 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
3266 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
3267 &custom_element_change.initial_trigger_element, 1, 1,
3268 NULL, NULL, NULL, "other element triggering change"
3271 /* ---------- custom change action (element used for action) ------------- */
3274 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
3275 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
3276 &custom_element_change.action_element, 1, 1,
3277 NULL, NULL, NULL, "element used as action parameter"
3280 /* ---------- group element content -------------------------------------- */
3283 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(4),
3284 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
3285 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
3286 "content:", NULL, NULL, NULL
3289 /* ---------- random background (for random painting) -------------------- */
3292 -1, ED_AREA_1X1_SETTINGS_YPOS(-1),
3293 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
3294 &random_placement_background_element, 1, 1,
3295 NULL, NULL, NULL, "random placement background"
3301 -----------------------------------------------------------------------------
3302 some internally used variables
3303 -----------------------------------------------------------------------------
3306 /* actual size of level editor drawing area */
3308 static int ed_fieldx, ed_fieldy;
3310 static int ed_fieldx = MAX_ED_FIELDX - 1, ed_fieldy = MAX_ED_FIELDY - 1;
3313 /* actual position of level editor drawing area in level playfield */
3314 static int level_xpos = -1, level_ypos = -1;
3317 #define IN_ED_FIELD(x,y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
3319 #define IN_ED_FIELD(x,y) ((x)>=0 && (x)<ed_fieldx && (y)>=0 &&(y)<ed_fieldy)
3322 /* drawing elements on the three mouse buttons */
3323 static int new_element1 = EL_WALL;
3324 static int new_element2 = EL_EMPTY;
3325 static int new_element3 = EL_SAND;
3327 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
3328 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
3329 (button) == 2 ? new_element2 : \
3330 (button) == 3 ? new_element3 : EL_EMPTY)
3331 #define BUTTON_STEPSIZE(button) ((button) == 1 ? 1 : (button) == 2 ? 5 : 10)
3333 /* forward declaration for internal use */
3334 static void ModifyEditorCounterValue(int, int);
3335 static void ModifyEditorCounterLimits(int, int, int);
3336 static void ModifyEditorSelectboxValue(int, int);
3337 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
3338 static void ModifyEditorDrawingArea(int, int, int);
3339 static void ModifyEditorElementList();
3340 static void AdjustElementListScrollbar();
3341 static void RedrawDrawingElements();
3342 static void DrawDrawingWindow();
3343 static void DrawLevelInfoWindow();
3344 static void DrawPropertiesWindow();
3345 static void UpdateCustomElementGraphicGadgets();
3346 static boolean checkPropertiesConfig(int);
3347 static void CopyLevelToUndoBuffer(int);
3348 static void HandleDrawingAreas(struct GadgetInfo *);
3349 static void HandleCounterButtons(struct GadgetInfo *);
3350 static void HandleTextInputGadgets(struct GadgetInfo *);
3351 static void HandleTextAreaGadgets(struct GadgetInfo *);
3352 static void HandleSelectboxGadgets(struct GadgetInfo *);
3353 static void HandleTextbuttonGadgets(struct GadgetInfo *);
3354 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
3355 static void HandleRadiobuttons(struct GadgetInfo *);
3356 static void HandleCheckbuttons(struct GadgetInfo *);
3357 static void HandleControlButtons(struct GadgetInfo *);
3358 static void HandleDrawingAreaInfo(struct GadgetInfo *);
3359 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
3361 static struct GadgetInfo *level_editor_gadget[NUM_EDITOR_GADGETS];
3362 static int right_gadget_border[NUM_EDITOR_GADGETS];
3364 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
3365 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
3366 static boolean draw_with_brush = FALSE;
3367 static int properties_element = 0;
3369 static short FieldBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3370 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3371 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3372 static int undo_buffer_position = 0;
3373 static int undo_buffer_steps = 0;
3375 static int edit_mode;
3376 static int edit_mode_levelinfo;
3377 static int edit_mode_properties;
3379 static int element_shift = 0;
3381 static int editor_el_players[] =
3388 static int *editor_el_players_ptr = editor_el_players;
3389 static int num_editor_el_players = SIZEOF_ARRAY_INT(editor_el_players);
3391 static int editor_hl_boulderdash[] =
3393 EL_INTERNAL_CASCADE_BD_ACTIVE,
3399 static int editor_el_boulderdash[] =
3408 EL_BD_EXPANDABLE_WALL,
3416 EL_BD_BUTTERFLY_LEFT,
3418 EL_BD_BUTTERFLY_RIGHT,
3419 EL_BD_FIREFLY_RIGHT,
3422 EL_BD_BUTTERFLY_DOWN,
3426 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
3427 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
3428 static int num_editor_hl_boulderdash = SIZEOF_ARRAY_INT(editor_hl_boulderdash);
3429 static int num_editor_el_boulderdash = SIZEOF_ARRAY_INT(editor_el_boulderdash);
3431 static int editor_hl_emerald_mine[] =
3433 EL_INTERNAL_CASCADE_EM_ACTIVE,
3439 static int editor_el_emerald_mine[] =
3476 EL_ACID_POOL_TOPLEFT,
3478 EL_ACID_POOL_TOPRIGHT,
3481 EL_ACID_POOL_BOTTOMLEFT,
3482 EL_ACID_POOL_BOTTOM,
3483 EL_ACID_POOL_BOTTOMRIGHT,
3503 EL_EM_STEEL_EXIT_CLOSED,
3504 EL_EM_STEEL_EXIT_OPEN,
3506 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
3507 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
3508 static int num_editor_hl_emerald_mine=SIZEOF_ARRAY_INT(editor_hl_emerald_mine);
3509 static int num_editor_el_emerald_mine=SIZEOF_ARRAY_INT(editor_el_emerald_mine);
3511 static int editor_hl_emerald_mine_club[] =
3513 EL_INTERNAL_CASCADE_EMC_ACTIVE,
3519 static int editor_el_emerald_mine_club[] =
3546 EL_EMC_WALL_SLIPPERY_1,
3547 EL_EMC_WALL_SLIPPERY_2,
3548 EL_EMC_WALL_SLIPPERY_3,
3549 EL_EMC_WALL_SLIPPERY_4,
3572 EL_EMC_MAGIC_BALL_SWITCH,
3574 EL_EMC_SPRING_BUMPER,
3579 EL_EM_DYNAMITE_ACTIVE,
3583 EL_BALLOON_SWITCH_UP,
3584 EL_BALLOON_SWITCH_ANY,
3587 EL_BALLOON_SWITCH_LEFT,
3589 EL_BALLOON_SWITCH_RIGHT,
3593 EL_BALLOON_SWITCH_DOWN,
3594 EL_BALLOON_SWITCH_NONE,
3596 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
3597 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
3598 static int num_editor_hl_emerald_mine_club=SIZEOF_ARRAY_INT(editor_hl_emerald_mine_club);
3599 static int num_editor_el_emerald_mine_club=SIZEOF_ARRAY_INT(editor_el_emerald_mine_club);
3601 static int editor_hl_rnd[] =
3603 EL_INTERNAL_CASCADE_RND_ACTIVE,
3609 static int editor_el_rnd[] =
3641 EL_WALL_EMERALD_YELLOW,
3642 EL_WALL_EMERALD_RED,
3643 EL_WALL_EMERALD_PURPLE,
3661 EL_DYNABOMB_INCREASE_NUMBER,
3662 EL_DYNABOMB_INCREASE_SIZE,
3663 EL_DYNABOMB_INCREASE_POWER,
3683 EL_INVISIBLE_STEELWALL,
3687 EL_EXPANDABLE_WALL_HORIZONTAL,
3688 EL_EXPANDABLE_WALL_VERTICAL,
3689 EL_EXPANDABLE_WALL_ANY,
3691 static int *editor_hl_rnd_ptr = editor_hl_rnd;
3692 static int *editor_el_rnd_ptr = editor_el_rnd;
3693 static int num_editor_hl_rnd = SIZEOF_ARRAY_INT(editor_hl_rnd);
3694 static int num_editor_el_rnd = SIZEOF_ARRAY_INT(editor_el_rnd);
3696 static int editor_hl_sokoban[] =
3698 EL_INTERNAL_CASCADE_SB_ACTIVE,
3704 static int editor_el_sokoban[] =
3707 EL_SOKOBAN_FIELD_EMPTY,
3708 EL_SOKOBAN_FIELD_FULL,
3709 EL_SOKOBAN_FIELD_PLAYER,
3711 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
3712 static int *editor_el_sokoban_ptr = editor_el_sokoban;
3713 static int num_editor_hl_sokoban = SIZEOF_ARRAY_INT(editor_hl_sokoban);
3714 static int num_editor_el_sokoban = SIZEOF_ARRAY_INT(editor_el_sokoban);
3716 static int editor_hl_supaplex[] =
3718 EL_INTERNAL_CASCADE_SP_ACTIVE,
3724 static int editor_el_supaplex[] =
3742 EL_SP_PORT_HORIZONTAL,
3743 EL_SP_PORT_VERTICAL,
3751 EL_SP_GRAVITY_PORT_LEFT,
3752 EL_SP_GRAVITY_PORT_RIGHT,
3753 EL_SP_GRAVITY_PORT_UP,
3754 EL_SP_GRAVITY_PORT_DOWN,
3756 EL_SP_GRAVITY_ON_PORT_LEFT,
3757 EL_SP_GRAVITY_ON_PORT_RIGHT,
3758 EL_SP_GRAVITY_ON_PORT_UP,
3759 EL_SP_GRAVITY_ON_PORT_DOWN,
3761 EL_SP_GRAVITY_OFF_PORT_LEFT,
3762 EL_SP_GRAVITY_OFF_PORT_RIGHT,
3763 EL_SP_GRAVITY_OFF_PORT_UP,
3764 EL_SP_GRAVITY_OFF_PORT_DOWN,
3766 EL_SP_HARDWARE_GRAY,
3767 EL_SP_HARDWARE_GREEN,
3768 EL_SP_HARDWARE_BLUE,
3771 EL_SP_HARDWARE_BASE_1,
3772 EL_SP_HARDWARE_BASE_2,
3773 EL_SP_HARDWARE_BASE_3,
3774 EL_SP_HARDWARE_BASE_4,
3776 EL_SP_HARDWARE_BASE_5,
3777 EL_SP_HARDWARE_BASE_6,
3778 EL_SP_HARDWARE_YELLOW,
3786 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
3787 static int *editor_el_supaplex_ptr = editor_el_supaplex;
3788 static int num_editor_hl_supaplex = SIZEOF_ARRAY_INT(editor_hl_supaplex);
3789 static int num_editor_el_supaplex = SIZEOF_ARRAY_INT(editor_el_supaplex);
3791 static int editor_hl_diamond_caves[] =
3793 EL_INTERNAL_CASCADE_DC_ACTIVE,
3799 static int editor_el_diamond_caves[] =
3806 EL_CONVEYOR_BELT_1_LEFT,
3807 EL_CONVEYOR_BELT_1_MIDDLE,
3808 EL_CONVEYOR_BELT_1_RIGHT,
3809 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
3811 EL_CONVEYOR_BELT_2_LEFT,
3812 EL_CONVEYOR_BELT_2_MIDDLE,
3813 EL_CONVEYOR_BELT_2_RIGHT,
3814 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
3816 EL_CONVEYOR_BELT_3_LEFT,
3817 EL_CONVEYOR_BELT_3_MIDDLE,
3818 EL_CONVEYOR_BELT_3_RIGHT,
3819 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
3821 EL_CONVEYOR_BELT_4_LEFT,
3822 EL_CONVEYOR_BELT_4_MIDDLE,
3823 EL_CONVEYOR_BELT_4_RIGHT,
3824 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
3826 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
3827 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
3828 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
3829 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
3831 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
3832 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
3833 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
3834 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
3839 EL_DC_TIMEGATE_SWITCH,
3841 EL_SWITCHGATE_CLOSED,
3843 EL_SWITCHGATE_SWITCH_UP,
3844 EL_SWITCHGATE_SWITCH_DOWN,
3847 EL_LIGHT_SWITCH_ACTIVE,
3848 EL_DC_SWITCHGATE_SWITCH_UP,
3849 EL_DC_SWITCHGATE_SWITCH_DOWN,
3851 EL_STEEL_EXIT_CLOSED,
3853 EL_STEELWALL_SLIPPERY,
3856 EL_QUICKSAND_FAST_EMPTY,
3857 EL_QUICKSAND_FAST_FULL,
3871 EL_SIGN_RADIOACTIVITY,
3877 EL_SIGN_ENTRY_FORBIDDEN,
3878 EL_SIGN_EMERGENCY_EXIT,
3903 EL_DC_STEELWALL_2_SINGLE,
3904 EL_DC_STEELWALL_2_TOP,
3905 EL_SIGN_EXCLAMATION,
3908 EL_DC_STEELWALL_2_LEFT,
3909 EL_DC_STEELWALL_2_MIDDLE,
3910 EL_DC_STEELWALL_2_HORIZONTAL,
3911 EL_DC_STEELWALL_2_RIGHT,
3913 EL_DC_STEELWALL_1_TOPLEFT,
3914 EL_DC_STEELWALL_2_VERTICAL,
3915 EL_DC_STEELWALL_1_TOPRIGHT,
3918 EL_DC_STEELWALL_1_VERTICAL,
3919 EL_DC_STEELWALL_2_BOTTOM,
3921 EL_DC_GATE_WHITE_GRAY,
3923 EL_DC_STEELWALL_1_BOTTOMLEFT,
3924 EL_DC_STEELWALL_1_HORIZONTAL,
3925 EL_DC_STEELWALL_1_BOTTOMRIGHT,
3926 EL_DC_GATE_FAKE_GRAY,
3928 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
3929 EL_DC_STEELWALL_1_BOTTOM,
3930 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
3931 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
3933 EL_DC_STEELWALL_1_RIGHT,
3935 EL_DC_STEELWALL_1_LEFT,
3936 EL_EXPANDABLE_STEELWALL_VERTICAL,
3938 EL_DC_STEELWALL_1_TOPRIGHT_2,
3939 EL_DC_STEELWALL_1_TOP,
3940 EL_DC_STEELWALL_1_TOPLEFT_2,
3941 EL_EXPANDABLE_STEELWALL_ANY,
3943 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
3944 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
3945 static int num_editor_hl_diamond_caves = SIZEOF_ARRAY_INT(editor_hl_diamond_caves);
3946 static int num_editor_el_diamond_caves = SIZEOF_ARRAY_INT(editor_el_diamond_caves);
3948 static int editor_hl_dx_boulderdash[] =
3950 EL_INTERNAL_CASCADE_DX_ACTIVE,
3956 static int editor_el_dx_boulderdash[] =
3960 EL_TUBE_HORIZONTAL_DOWN,
3964 EL_TUBE_VERTICAL_RIGHT,
3966 EL_TUBE_VERTICAL_LEFT,
3970 EL_TUBE_HORIZONTAL_UP,
3978 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
3979 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
3980 static int num_editor_hl_dx_boulderdash = SIZEOF_ARRAY_INT(editor_hl_dx_boulderdash);
3981 static int num_editor_el_dx_boulderdash = SIZEOF_ARRAY_INT(editor_el_dx_boulderdash);
3983 static int editor_hl_chars[] =
3985 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
3991 static int editor_el_chars[] =
4080 EL_CHAR(FONT_ASCII_CURSOR),
4081 EL_CHAR(FONT_ASCII_BUTTON),
4083 EL_CHAR(FONT_ASCII_UP),
4084 EL_CHAR(FONT_ASCII_DOWN),
4088 static int *editor_hl_chars_ptr = editor_hl_chars;
4089 static int *editor_el_chars_ptr = editor_el_chars;
4090 static int num_editor_hl_chars = SIZEOF_ARRAY_INT(editor_hl_chars);
4091 static int num_editor_el_chars = SIZEOF_ARRAY_INT(editor_el_chars);
4093 static int editor_hl_steel_chars[] =
4095 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
4101 static int editor_el_steel_chars[] =
4111 EL_STEEL_CHAR('\''),
4178 EL_STEEL_CHAR('\\'),
4183 EL_STEEL_CHAR('©'),
4184 EL_STEEL_CHAR('Ä'),
4185 EL_STEEL_CHAR('Ö'),
4186 EL_STEEL_CHAR('Ü'),
4188 EL_STEEL_CHAR('°'),
4189 EL_STEEL_CHAR('®'),
4190 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
4191 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
4193 EL_STEEL_CHAR(FONT_ASCII_UP),
4194 EL_STEEL_CHAR(FONT_ASCII_DOWN),
4198 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
4199 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
4200 static int num_editor_hl_steel_chars = SIZEOF_ARRAY_INT(editor_hl_steel_chars);
4201 static int num_editor_el_steel_chars = SIZEOF_ARRAY_INT(editor_el_steel_chars);
4203 static int editor_hl_custom[] =
4205 EL_INTERNAL_CASCADE_CE_ACTIVE,
4211 static int editor_el_custom[] =
4213 EL_CUSTOM_START + 0,
4214 EL_CUSTOM_START + 1,
4215 EL_CUSTOM_START + 2,
4216 EL_CUSTOM_START + 3,
4218 EL_CUSTOM_START + 4,
4219 EL_CUSTOM_START + 5,
4220 EL_CUSTOM_START + 6,
4221 EL_CUSTOM_START + 7,
4223 EL_CUSTOM_START + 8,
4224 EL_CUSTOM_START + 9,
4225 EL_CUSTOM_START + 10,
4226 EL_CUSTOM_START + 11,
4228 EL_CUSTOM_START + 12,
4229 EL_CUSTOM_START + 13,
4230 EL_CUSTOM_START + 14,
4231 EL_CUSTOM_START + 15,
4233 EL_CUSTOM_START + 16,
4234 EL_CUSTOM_START + 17,
4235 EL_CUSTOM_START + 18,
4236 EL_CUSTOM_START + 19,
4238 EL_CUSTOM_START + 20,
4239 EL_CUSTOM_START + 21,
4240 EL_CUSTOM_START + 22,
4241 EL_CUSTOM_START + 23,
4243 EL_CUSTOM_START + 24,
4244 EL_CUSTOM_START + 25,
4245 EL_CUSTOM_START + 26,
4246 EL_CUSTOM_START + 27,
4248 EL_CUSTOM_START + 28,
4249 EL_CUSTOM_START + 29,
4250 EL_CUSTOM_START + 30,
4251 EL_CUSTOM_START + 31,
4253 EL_CUSTOM_START + 32,
4254 EL_CUSTOM_START + 33,
4255 EL_CUSTOM_START + 34,
4256 EL_CUSTOM_START + 35,
4258 EL_CUSTOM_START + 36,
4259 EL_CUSTOM_START + 37,
4260 EL_CUSTOM_START + 38,
4261 EL_CUSTOM_START + 39,
4263 EL_CUSTOM_START + 40,
4264 EL_CUSTOM_START + 41,
4265 EL_CUSTOM_START + 42,
4266 EL_CUSTOM_START + 43,
4268 EL_CUSTOM_START + 44,
4269 EL_CUSTOM_START + 45,
4270 EL_CUSTOM_START + 46,
4271 EL_CUSTOM_START + 47,
4273 EL_CUSTOM_START + 48,
4274 EL_CUSTOM_START + 49,
4275 EL_CUSTOM_START + 50,
4276 EL_CUSTOM_START + 51,
4278 EL_CUSTOM_START + 52,
4279 EL_CUSTOM_START + 53,
4280 EL_CUSTOM_START + 54,
4281 EL_CUSTOM_START + 55,
4283 EL_CUSTOM_START + 56,
4284 EL_CUSTOM_START + 57,
4285 EL_CUSTOM_START + 58,
4286 EL_CUSTOM_START + 59,
4288 EL_CUSTOM_START + 60,
4289 EL_CUSTOM_START + 61,
4290 EL_CUSTOM_START + 62,
4291 EL_CUSTOM_START + 63,
4293 EL_CUSTOM_START + 64,
4294 EL_CUSTOM_START + 65,
4295 EL_CUSTOM_START + 66,
4296 EL_CUSTOM_START + 67,
4298 EL_CUSTOM_START + 68,
4299 EL_CUSTOM_START + 69,
4300 EL_CUSTOM_START + 70,
4301 EL_CUSTOM_START + 71,
4303 EL_CUSTOM_START + 72,
4304 EL_CUSTOM_START + 73,
4305 EL_CUSTOM_START + 74,
4306 EL_CUSTOM_START + 75,
4308 EL_CUSTOM_START + 76,
4309 EL_CUSTOM_START + 77,
4310 EL_CUSTOM_START + 78,
4311 EL_CUSTOM_START + 79,
4313 EL_CUSTOM_START + 80,
4314 EL_CUSTOM_START + 81,
4315 EL_CUSTOM_START + 82,
4316 EL_CUSTOM_START + 83,
4318 EL_CUSTOM_START + 84,
4319 EL_CUSTOM_START + 85,
4320 EL_CUSTOM_START + 86,
4321 EL_CUSTOM_START + 87,
4323 EL_CUSTOM_START + 88,
4324 EL_CUSTOM_START + 89,
4325 EL_CUSTOM_START + 90,
4326 EL_CUSTOM_START + 91,
4328 EL_CUSTOM_START + 92,
4329 EL_CUSTOM_START + 93,
4330 EL_CUSTOM_START + 94,
4331 EL_CUSTOM_START + 95,
4333 EL_CUSTOM_START + 96,
4334 EL_CUSTOM_START + 97,
4335 EL_CUSTOM_START + 98,
4336 EL_CUSTOM_START + 99,
4338 EL_CUSTOM_START + 100,
4339 EL_CUSTOM_START + 101,
4340 EL_CUSTOM_START + 102,
4341 EL_CUSTOM_START + 103,
4343 EL_CUSTOM_START + 104,
4344 EL_CUSTOM_START + 105,
4345 EL_CUSTOM_START + 106,
4346 EL_CUSTOM_START + 107,
4348 EL_CUSTOM_START + 108,
4349 EL_CUSTOM_START + 109,
4350 EL_CUSTOM_START + 110,
4351 EL_CUSTOM_START + 111,
4353 EL_CUSTOM_START + 112,
4354 EL_CUSTOM_START + 113,
4355 EL_CUSTOM_START + 114,
4356 EL_CUSTOM_START + 115,
4358 EL_CUSTOM_START + 116,
4359 EL_CUSTOM_START + 117,
4360 EL_CUSTOM_START + 118,
4361 EL_CUSTOM_START + 119,
4363 EL_CUSTOM_START + 120,
4364 EL_CUSTOM_START + 121,
4365 EL_CUSTOM_START + 122,
4366 EL_CUSTOM_START + 123,
4368 EL_CUSTOM_START + 124,
4369 EL_CUSTOM_START + 125,
4370 EL_CUSTOM_START + 126,
4371 EL_CUSTOM_START + 127,
4373 EL_CUSTOM_START + 128,
4374 EL_CUSTOM_START + 129,
4375 EL_CUSTOM_START + 130,
4376 EL_CUSTOM_START + 131,
4378 EL_CUSTOM_START + 132,
4379 EL_CUSTOM_START + 133,
4380 EL_CUSTOM_START + 134,
4381 EL_CUSTOM_START + 135,
4383 EL_CUSTOM_START + 136,
4384 EL_CUSTOM_START + 137,
4385 EL_CUSTOM_START + 138,
4386 EL_CUSTOM_START + 139,
4388 EL_CUSTOM_START + 140,
4389 EL_CUSTOM_START + 141,
4390 EL_CUSTOM_START + 142,
4391 EL_CUSTOM_START + 143,
4393 EL_CUSTOM_START + 144,
4394 EL_CUSTOM_START + 145,
4395 EL_CUSTOM_START + 146,
4396 EL_CUSTOM_START + 147,
4398 EL_CUSTOM_START + 148,
4399 EL_CUSTOM_START + 149,
4400 EL_CUSTOM_START + 150,
4401 EL_CUSTOM_START + 151,
4403 EL_CUSTOM_START + 152,
4404 EL_CUSTOM_START + 153,
4405 EL_CUSTOM_START + 154,
4406 EL_CUSTOM_START + 155,
4408 EL_CUSTOM_START + 156,
4409 EL_CUSTOM_START + 157,
4410 EL_CUSTOM_START + 158,
4411 EL_CUSTOM_START + 159,
4413 EL_CUSTOM_START + 160,
4414 EL_CUSTOM_START + 161,
4415 EL_CUSTOM_START + 162,
4416 EL_CUSTOM_START + 163,
4418 EL_CUSTOM_START + 164,
4419 EL_CUSTOM_START + 165,
4420 EL_CUSTOM_START + 166,
4421 EL_CUSTOM_START + 167,
4423 EL_CUSTOM_START + 168,
4424 EL_CUSTOM_START + 169,
4425 EL_CUSTOM_START + 170,
4426 EL_CUSTOM_START + 171,
4428 EL_CUSTOM_START + 172,
4429 EL_CUSTOM_START + 173,
4430 EL_CUSTOM_START + 174,
4431 EL_CUSTOM_START + 175,
4433 EL_CUSTOM_START + 176,
4434 EL_CUSTOM_START + 177,
4435 EL_CUSTOM_START + 178,
4436 EL_CUSTOM_START + 179,
4438 EL_CUSTOM_START + 180,
4439 EL_CUSTOM_START + 181,
4440 EL_CUSTOM_START + 182,
4441 EL_CUSTOM_START + 183,
4443 EL_CUSTOM_START + 184,
4444 EL_CUSTOM_START + 185,
4445 EL_CUSTOM_START + 186,
4446 EL_CUSTOM_START + 187,
4448 EL_CUSTOM_START + 188,
4449 EL_CUSTOM_START + 189,
4450 EL_CUSTOM_START + 190,
4451 EL_CUSTOM_START + 191,
4453 EL_CUSTOM_START + 192,
4454 EL_CUSTOM_START + 193,
4455 EL_CUSTOM_START + 194,
4456 EL_CUSTOM_START + 195,
4458 EL_CUSTOM_START + 196,
4459 EL_CUSTOM_START + 197,
4460 EL_CUSTOM_START + 198,
4461 EL_CUSTOM_START + 199,
4463 EL_CUSTOM_START + 200,
4464 EL_CUSTOM_START + 201,
4465 EL_CUSTOM_START + 202,
4466 EL_CUSTOM_START + 203,
4468 EL_CUSTOM_START + 204,
4469 EL_CUSTOM_START + 205,
4470 EL_CUSTOM_START + 206,
4471 EL_CUSTOM_START + 207,
4473 EL_CUSTOM_START + 208,
4474 EL_CUSTOM_START + 209,
4475 EL_CUSTOM_START + 210,
4476 EL_CUSTOM_START + 211,
4478 EL_CUSTOM_START + 212,
4479 EL_CUSTOM_START + 213,
4480 EL_CUSTOM_START + 214,
4481 EL_CUSTOM_START + 215,
4483 EL_CUSTOM_START + 216,
4484 EL_CUSTOM_START + 217,
4485 EL_CUSTOM_START + 218,
4486 EL_CUSTOM_START + 219,
4488 EL_CUSTOM_START + 220,
4489 EL_CUSTOM_START + 221,
4490 EL_CUSTOM_START + 222,
4491 EL_CUSTOM_START + 223,
4493 EL_CUSTOM_START + 224,
4494 EL_CUSTOM_START + 225,
4495 EL_CUSTOM_START + 226,
4496 EL_CUSTOM_START + 227,
4498 EL_CUSTOM_START + 228,
4499 EL_CUSTOM_START + 229,
4500 EL_CUSTOM_START + 230,
4501 EL_CUSTOM_START + 231,
4503 EL_CUSTOM_START + 232,
4504 EL_CUSTOM_START + 233,
4505 EL_CUSTOM_START + 234,
4506 EL_CUSTOM_START + 235,
4508 EL_CUSTOM_START + 236,
4509 EL_CUSTOM_START + 237,
4510 EL_CUSTOM_START + 238,
4511 EL_CUSTOM_START + 239,
4513 EL_CUSTOM_START + 240,
4514 EL_CUSTOM_START + 241,
4515 EL_CUSTOM_START + 242,
4516 EL_CUSTOM_START + 243,
4518 EL_CUSTOM_START + 244,
4519 EL_CUSTOM_START + 245,
4520 EL_CUSTOM_START + 246,
4521 EL_CUSTOM_START + 247,
4523 EL_CUSTOM_START + 248,
4524 EL_CUSTOM_START + 249,
4525 EL_CUSTOM_START + 250,
4526 EL_CUSTOM_START + 251,
4528 EL_CUSTOM_START + 252,
4529 EL_CUSTOM_START + 253,
4530 EL_CUSTOM_START + 254,
4531 EL_CUSTOM_START + 255
4533 static int *editor_hl_custom_ptr = editor_hl_custom;
4534 static int *editor_el_custom_ptr = editor_el_custom;
4535 static int num_editor_hl_custom = SIZEOF_ARRAY_INT(editor_hl_custom);
4536 static int num_editor_el_custom = SIZEOF_ARRAY_INT(editor_el_custom);
4538 static int editor_hl_group[] =
4540 EL_INTERNAL_CASCADE_GE_ACTIVE,
4546 static int editor_el_group[] =
4560 EL_GROUP_START + 10,
4561 EL_GROUP_START + 11,
4563 EL_GROUP_START + 12,
4564 EL_GROUP_START + 13,
4565 EL_GROUP_START + 14,
4566 EL_GROUP_START + 15,
4568 EL_GROUP_START + 16,
4569 EL_GROUP_START + 17,
4570 EL_GROUP_START + 18,
4571 EL_GROUP_START + 19,
4573 EL_GROUP_START + 20,
4574 EL_GROUP_START + 21,
4575 EL_GROUP_START + 22,
4576 EL_GROUP_START + 23,
4578 EL_GROUP_START + 24,
4579 EL_GROUP_START + 25,
4580 EL_GROUP_START + 26,
4581 EL_GROUP_START + 27,
4583 EL_GROUP_START + 28,
4584 EL_GROUP_START + 29,
4585 EL_GROUP_START + 30,
4588 static int *editor_hl_group_ptr = editor_hl_group;
4589 static int *editor_el_group_ptr = editor_el_group;
4590 static int num_editor_hl_group = SIZEOF_ARRAY_INT(editor_hl_group);
4591 static int num_editor_el_group = SIZEOF_ARRAY_INT(editor_el_group);
4593 static int editor_hl_reference[] =
4595 EL_INTERNAL_CASCADE_REF_ACTIVE,
4601 static int editor_el_reference[] =
4605 EL_TRIGGER_CE_VALUE,
4606 EL_TRIGGER_CE_SCORE,
4610 EL_CURRENT_CE_VALUE,
4611 EL_CURRENT_CE_SCORE,
4633 static int *editor_hl_reference_ptr = editor_hl_reference;
4634 static int *editor_el_reference_ptr = editor_el_reference;
4635 static int num_editor_hl_reference = SIZEOF_ARRAY_INT(editor_hl_reference);
4636 static int num_editor_el_reference = SIZEOF_ARRAY_INT(editor_el_reference);
4638 static int editor_hl_user_defined[] =
4640 EL_INTERNAL_CASCADE_USER_ACTIVE,
4646 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
4647 static int *editor_el_user_defined_ptr = NULL;
4648 static int num_editor_hl_user_defined=SIZEOF_ARRAY_INT(editor_hl_user_defined);
4649 static int num_editor_el_user_defined = 0;
4651 static int editor_hl_dynamic[] =
4653 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
4659 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
4660 static int *editor_el_dynamic_ptr = NULL;
4661 static int num_editor_hl_dynamic = SIZEOF_ARRAY_INT(editor_hl_dynamic);
4662 static int num_editor_el_dynamic = 0;
4664 static int editor_hl_empty[] = { };
4665 static int editor_el_empty[ED_NUM_ELEMENTLIST_BUTTONS];
4667 static int *editor_hl_empty_ptr = editor_hl_empty;
4668 static int *editor_el_empty_ptr = editor_el_empty;
4669 static int num_editor_hl_empty = 0;
4670 static int num_editor_el_empty = 0; /* dynamically determined, if needed */
4672 static boolean use_el_empty = FALSE;
4674 static int *editor_elements = NULL; /* dynamically allocated */
4675 static int num_editor_elements = 0; /* dynamically determined */
4677 static boolean setup_editor_show_always = TRUE;
4678 static boolean setup_editor_cascade_never = FALSE;
4680 static int editor_hl_unused[] = { EL_EMPTY };
4681 static int *editor_hl_unused_ptr = editor_hl_unused;
4682 static int num_editor_hl_unused = 0;
4686 boolean *setup_value;
4687 boolean *setup_cascade_value;
4689 int **headline_list;
4690 int *headline_list_size;
4693 int *element_list_size;
4695 boolean last_setup_value;
4697 editor_elements_info[] =
4700 &setup_editor_show_always,
4701 &setup_editor_cascade_never,
4702 &editor_hl_unused_ptr, &num_editor_hl_unused,
4703 &editor_el_players_ptr, &num_editor_el_players
4706 &setup.editor.el_boulderdash,
4707 &setup.editor_cascade.el_bd,
4708 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
4709 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
4712 &setup.editor.el_emerald_mine,
4713 &setup.editor_cascade.el_em,
4714 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
4715 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
4718 &setup.editor.el_emerald_mine_club,
4719 &setup.editor_cascade.el_emc,
4720 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
4721 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
4724 &setup.editor.el_more,
4725 &setup.editor_cascade.el_rnd,
4726 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
4727 &editor_el_rnd_ptr, &num_editor_el_rnd
4730 &setup.editor.el_sokoban,
4731 &setup.editor_cascade.el_sb,
4732 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
4733 &editor_el_sokoban_ptr, &num_editor_el_sokoban
4736 &setup.editor.el_supaplex,
4737 &setup.editor_cascade.el_sp,
4738 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
4739 &editor_el_supaplex_ptr, &num_editor_el_supaplex
4742 &setup.editor.el_diamond_caves,
4743 &setup.editor_cascade.el_dc,
4744 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
4745 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
4748 &setup.editor.el_dx_boulderdash,
4749 &setup.editor_cascade.el_dx,
4750 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
4751 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
4754 &setup.editor.el_chars,
4755 &setup.editor_cascade.el_chars,
4756 &editor_hl_chars_ptr, &num_editor_hl_chars,
4757 &editor_el_chars_ptr, &num_editor_el_chars
4760 &setup.editor.el_steel_chars,
4761 &setup.editor_cascade.el_steel_chars,
4762 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
4763 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
4766 &setup.editor.el_custom,
4767 &setup.editor_cascade.el_ce,
4768 &editor_hl_custom_ptr, &num_editor_hl_custom,
4769 &editor_el_custom_ptr, &num_editor_el_custom
4772 &setup.editor.el_custom,
4773 &setup.editor_cascade.el_ge,
4774 &editor_hl_group_ptr, &num_editor_hl_group,
4775 &editor_el_group_ptr, &num_editor_el_group
4778 &setup.editor.el_custom,
4779 &setup.editor_cascade.el_ref,
4780 &editor_hl_reference_ptr, &num_editor_hl_reference,
4781 &editor_el_reference_ptr, &num_editor_el_reference
4784 &setup.editor.el_user_defined,
4785 &setup.editor_cascade.el_user,
4786 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
4787 &editor_el_user_defined_ptr, &num_editor_el_user_defined
4790 &setup.editor.el_dynamic,
4791 &setup.editor_cascade.el_dynamic,
4792 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
4793 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
4798 &editor_hl_empty_ptr, &num_editor_hl_empty,
4799 &editor_el_empty_ptr, &num_editor_el_empty,
4811 -----------------------------------------------------------------------------
4813 -----------------------------------------------------------------------------
4816 static int getMaxInfoTextLength()
4818 return (SXSIZE / getFontWidth(FONT_TEXT_2));
4821 static int getTextWidthForGadget(char *text)
4826 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
4829 static int getTextWidthForDrawingArea(char *text)
4834 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
4837 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
4839 return (gi->x + gi->width + getTextWidthForGadget(text));
4842 static char *getElementInfoText(int element)
4844 char *info_text = NULL;
4846 if (element < MAX_NUM_ELEMENTS)
4848 if (strlen(element_info[element].description) > 0)
4849 info_text = element_info[element].description;
4850 else if (element_info[element].custom_description != NULL)
4851 info_text = element_info[element].custom_description;
4852 else if (element_info[element].editor_description != NULL)
4853 info_text = element_info[element].editor_description;
4856 if (info_text == NULL)
4857 info_text = INFOTEXT_UNKNOWN_ELEMENT;
4862 char *getElementDescriptionFilename(int element)
4864 char *docs_dir = options.docs_directory;
4865 char *elements_subdir = "elements";
4866 static char *filename = NULL;
4867 char basename[MAX_FILENAME_LEN];
4869 checked_free(filename);
4871 /* 1st try: look for element description file for exactly this element */
4872 sprintf(basename, "%s.txt", element_info[element].token_name);
4873 filename = getPath3(docs_dir, elements_subdir, basename);
4874 if (fileExists(filename))
4879 /* 2nd try: look for element description file for this element's class */
4880 sprintf(basename, "%s.txt", element_info[element].class_name);
4881 filename = getPath3(docs_dir, elements_subdir, basename);
4882 if (fileExists(filename))
4888 static void InitDynamicEditorElementList(int **elements, int *num_elements)
4890 boolean element_found[NUM_FILE_ELEMENTS];
4893 /* initialize list of used elements to "not used" */
4894 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
4895 element_found[i] = FALSE;
4897 /* find all elements used in current level */
4898 for (y = 0; y < lev_fieldy; y++)
4899 for (x = 0; x < lev_fieldx; x++)
4900 if (Feld[x][y] < NUM_FILE_ELEMENTS) /* should always be true */
4901 element_found[Feld[x][y]] = TRUE;
4905 /* count number of elements used in current level */
4906 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
4907 if (element_found[i])
4910 /* add space for up to 3 more elements for padding that may be needed */
4913 /* free memory for old list of elements, if needed */
4914 checked_free(*elements);
4916 /* allocate memory for new list of elements */
4917 *elements = checked_malloc(*num_elements * sizeof(int));
4921 /* add all elements used in current level (non-custom/group elements) */
4922 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
4923 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
4924 (*elements)[(*num_elements)++] = i;
4926 /* add all elements used in current level (custom/group elements) */
4927 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
4928 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
4929 (*elements)[(*num_elements)++] = i;
4931 while (*num_elements % 4) /* pad with empty elements, if needed */
4932 (*elements)[(*num_elements)++] = EL_EMPTY;
4935 static void ReinitializeElementList()
4937 static boolean initialization_needed = TRUE;
4941 if (initialization_needed)
4943 LoadSetup_EditorCascade(); /* load last editor cascade state */
4945 /* initialize editor cascade element from saved cascade state */
4946 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4948 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
4949 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
4951 if (IS_EDITOR_CASCADE(*cascade_element))
4953 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
4954 EL_CASCADE_INACTIVE(*cascade_element));
4957 initialization_needed = FALSE;
4960 checked_free(editor_elements);
4962 /* reload optional user defined element list for each invocation of editor */
4963 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
4964 &num_editor_el_user_defined);
4966 /* initialize dynamic level element list for each invocation of editor */
4967 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
4968 &num_editor_el_dynamic);
4970 /* initialize list of empty elements (used for padding, if needed) */
4971 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
4972 editor_el_empty[i] = EL_EMPTY;
4974 /* do some sanity checks for each element from element list */
4975 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4977 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
4979 int element = (*editor_elements_info[i].element_list)[j];
4981 if (element >= NUM_FILE_ELEMENTS)
4982 Error(ERR_WARN, "editor element %d is runtime element", element);
4984 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
4985 Error(ERR_WARN, "no element description for element %d", element);
4989 num_editor_elements = 0;
4990 use_el_empty = FALSE;
4992 /* determine size of element list */
4993 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4995 boolean found_inactive_cascade = FALSE;
4997 if (*editor_elements_info[i].setup_value)
4999 if (setup.editor.el_headlines)
5001 num_editor_elements += *editor_elements_info[i].headline_list_size;
5003 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
5005 int element = (*editor_elements_info[i].headline_list)[j];
5007 if (IS_EDITOR_CASCADE_INACTIVE(element))
5008 found_inactive_cascade = TRUE;
5012 if (found_inactive_cascade)
5015 num_editor_elements += *editor_elements_info[i].element_list_size;
5019 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
5021 /* offer at least as many elements as element buttons exist */
5022 use_el_empty = TRUE;
5023 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
5025 num_editor_elements += num_editor_el_empty;
5028 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
5030 /* fill element list */
5031 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5033 boolean found_inactive_cascade = FALSE;
5035 if (*editor_elements_info[i].setup_value)
5037 if (setup.editor.el_headlines)
5039 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
5041 int element = (*editor_elements_info[i].headline_list)[j];
5043 editor_elements[pos++] = element;
5045 if (IS_EDITOR_CASCADE_INACTIVE(element))
5046 found_inactive_cascade = TRUE;
5050 if (found_inactive_cascade)
5053 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
5054 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
5058 /* (this function is also called before editor gadgets are initialized!) */
5059 AdjustElementListScrollbar();
5062 void PrintEditorElementList()
5064 boolean *stop = &setup.editor.el_user_defined;
5067 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
5069 int cascade_element = (*editor_elements_info[i].headline_list)[0];
5071 if (IS_EDITOR_CASCADE(cascade_element))
5073 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
5074 char *headline = element_info[cascade_element_show].editor_description;
5076 printf_line_with_prefix("# ", "-", 77);
5077 printf("# %s\n", headline);
5078 printf_line_with_prefix("# ", "-", 77);
5081 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
5083 int element = (*editor_elements_info[i].headline_list)[j];
5085 if (IS_EDITOR_CASCADE(element))
5086 element = EL_CHAR_MINUS;
5088 printf("# %s\n", element_info[element].token_name);
5094 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
5096 int element = (*editor_elements_info[i].element_list)[j];
5098 printf("# %s\n", element_info[element].token_name);
5106 static void ReinitializeElementListButtons()
5108 static boolean last_setup_value_headlines = FALSE;
5109 static boolean initialization_needed = TRUE;
5112 if (!initialization_needed) /* check if editor element setup has changed */
5114 if (last_setup_value_headlines != setup.editor.el_headlines)
5115 initialization_needed = TRUE;
5117 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5118 if (editor_elements_info[i].last_setup_value !=
5119 *editor_elements_info[i].setup_value)
5120 initialization_needed = TRUE;
5123 if (!initialization_needed)
5126 FreeLevelEditorGadgets();
5127 CreateLevelEditorGadgets();
5129 /* store current setup values for next invocation of this function */
5130 last_setup_value_headlines = setup.editor.el_headlines;
5131 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5132 editor_elements_info[i].last_setup_value =
5133 *editor_elements_info[i].setup_value;
5135 initialization_needed = FALSE;
5138 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
5141 int border_graphic =
5142 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
5145 int bx = (input ? 4 : 8);
5146 int by = (input ? 4 : 8);
5147 int bx2 = TILEX - bx;
5148 int by2 = TILEY - by;
5151 getFixedGraphicSource(border_graphic, 0, &src_bitmap, &src_x, &src_y);
5153 BlitBitmap(src_bitmap, drawto, src_x, src_y,
5154 bx, by, dest_x - bx, dest_y - by);
5155 BlitBitmap(src_bitmap, drawto, src_x + bx2, src_y,
5156 bx, by, dest_x + width, dest_y - by);
5157 BlitBitmap(src_bitmap, drawto, src_x, src_y + by2,
5158 bx, by, dest_x - bx, dest_y + height);
5159 BlitBitmap(src_bitmap, drawto, src_x + bx2, src_y + by2,
5160 bx, by, dest_x + width, dest_y + height);
5162 for (i = 0; i < width / MINI_TILEX; i++)
5164 BlitBitmap(src_bitmap, drawto, src_x + bx, src_y, MINI_TILEX, by,
5165 dest_x + i * MINI_TILEX, dest_y - by);
5166 BlitBitmap(src_bitmap, drawto, src_x + bx, src_y + by2, MINI_TILEX, by,
5167 dest_x + i * MINI_TILEX, dest_y + height);
5170 for (i = 0; i < height / MINI_TILEY; i++)
5172 BlitBitmap(src_bitmap, drawto, src_x, src_y + by, bx, MINI_TILEY,
5173 dest_x - bx, dest_y + i * MINI_TILEY);
5174 BlitBitmap(src_bitmap, drawto, src_x + bx2, src_y + by, bx, MINI_TILEY,
5175 dest_x + width, dest_y + i * MINI_TILEY);
5178 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
5181 static void DrawDrawingArea(int id)
5183 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
5186 int *value = drawingarea_info[id].value;
5187 int area_xsize = drawingarea_info[id].area_xsize;
5188 int area_ysize = drawingarea_info[id].area_ysize;
5190 for (x = 0; x < area_xsize; x++)
5191 for (y = 0; y < area_ysize; y++)
5192 DrawMiniGraphicExt(drawto,
5193 gi->x + x * MINI_TILEX,
5194 gi->y + y * MINI_TILEY,
5195 el2edimg(value[x * area_ysize + y]));
5198 static void ScrollMiniLevel(int from_x, int from_y, int scroll)
5201 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
5202 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
5204 BlitBitmap(drawto, drawto,
5205 SX + (dx == -1 ? MINI_TILEX : 0),
5206 SY + (dy == -1 ? MINI_TILEY : 0),
5207 (ed_fieldx * MINI_TILEX) - (dx != 0 ? MINI_TILEX : 0),
5208 (ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0),
5209 SX + (dx == +1 ? MINI_TILEX : 0),
5210 SY + (dy == +1 ? MINI_TILEY : 0));
5214 x = (dx == 1 ? 0 : ed_fieldx - 1);
5215 for (y = 0; y < ed_fieldy; y++)
5216 DrawMiniElementOrWall(x, y, from_x, from_y);
5220 y = (dy == 1 ? 0 : ed_fieldy - 1);
5221 for (x = 0; x < ed_fieldx; x++)
5222 DrawMiniElementOrWall(x, y, from_x, from_y);
5225 redraw_mask |= REDRAW_FIELD;
5229 static void CreateControlButtons()
5231 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5232 struct GadgetInfo *gi;
5233 unsigned long event_mask;
5236 /* create toolbox buttons */
5237 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
5241 int gd_xoffset, gd_yoffset;
5242 int gd_x1, gd_x2, gd_y1, gd_y2;
5244 int radio_button_nr;
5247 if (id == GADGET_ID_SINGLE_ITEMS ||
5248 id == GADGET_ID_CONNECTED_ITEMS ||
5249 id == GADGET_ID_LINE ||
5250 id == GADGET_ID_ARC ||
5251 id == GADGET_ID_TEXT ||
5252 id == GADGET_ID_RECTANGLE ||
5253 id == GADGET_ID_FILLED_BOX ||
5254 id == GADGET_ID_FLOOD_FILL ||
5255 id == GADGET_ID_GRAB_BRUSH ||
5256 id == GADGET_ID_PICK_ELEMENT ||
5257 id == GADGET_ID_CUSTOM_COPY_FROM ||
5258 id == GADGET_ID_CUSTOM_COPY_TO ||
5259 id == GADGET_ID_CUSTOM_EXCHANGE)
5261 button_type = GD_TYPE_RADIO_BUTTON;
5262 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
5263 checked = (id == drawing_function ? TRUE : FALSE);
5264 event_mask = GD_EVENT_PRESSED;
5268 button_type = GD_TYPE_NORMAL_BUTTON;
5269 radio_button_nr = RADIO_NR_NONE;
5272 if (id == GADGET_ID_WRAP_LEFT ||
5273 id == GADGET_ID_WRAP_RIGHT ||
5274 id == GADGET_ID_WRAP_UP ||
5275 id == GADGET_ID_WRAP_DOWN)
5276 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5278 event_mask = GD_EVENT_RELEASED;
5281 if (id < ED_NUM_CTRL1_BUTTONS)
5283 int x = i % ED_CTRL1_BUTTONS_HORIZ;
5284 int y = i / ED_CTRL1_BUTTONS_HORIZ;
5286 gd_xoffset = ED_CTRL1_BUTTONS_XPOS + x * ED_CTRL1_BUTTON_XSIZE;
5287 gd_yoffset = ED_CTRL1_BUTTONS_YPOS + y * ED_CTRL1_BUTTON_YSIZE;
5288 width = ED_CTRL1_BUTTON_XSIZE;
5289 height = ED_CTRL1_BUTTON_YSIZE;
5291 gd_x1 = DOOR_GFX_PAGEX8 + gd_xoffset;
5292 gd_x2 = DOOR_GFX_PAGEX7 + gd_xoffset;
5293 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL1_BUTTONS_GFX_YPOS + gd_yoffset;
5294 gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL1_BUTTONS_ALT_GFX_YPOS + gd_yoffset;
5296 else if (id < ED_NUM_CTRL1_2_BUTTONS)
5298 int x = (i - ED_NUM_CTRL1_BUTTONS) % ED_CTRL2_BUTTONS_HORIZ;
5299 int y = (i - ED_NUM_CTRL1_BUTTONS) / ED_CTRL2_BUTTONS_HORIZ;
5301 gd_xoffset = ED_CTRL2_BUTTONS_XPOS + x * ED_CTRL2_BUTTON_XSIZE;
5302 gd_yoffset = ED_CTRL2_BUTTONS_YPOS + y * ED_CTRL2_BUTTON_YSIZE;
5303 width = ED_CTRL2_BUTTON_XSIZE;
5304 height = ED_CTRL2_BUTTON_YSIZE;
5306 gd_x1 = DOOR_GFX_PAGEX8 + gd_xoffset;
5307 gd_x2 = DOOR_GFX_PAGEX7 + gd_xoffset;
5308 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL2_BUTTONS_GFX_YPOS + gd_yoffset;
5309 gd_y2 = 0; /* no alternative graphic for these buttons */
5311 else if (id < ED_NUM_CTRL1_3_BUTTONS)
5313 int x = (i - ED_NUM_CTRL1_2_BUTTONS) % ED_CTRL3_BUTTONS_HORIZ + 1;
5314 int y = (i - ED_NUM_CTRL1_2_BUTTONS) / ED_CTRL3_BUTTONS_HORIZ;
5316 gd_xoffset = ED_CTRL3_BUTTONS_XPOS + x * ED_CTRL3_BUTTON_XSIZE;
5317 gd_yoffset = ED_CTRL3_BUTTONS_YPOS + y * ED_CTRL3_BUTTON_YSIZE;
5318 width = ED_CTRL3_BUTTON_XSIZE;
5319 height = ED_CTRL3_BUTTON_YSIZE;
5321 gd_x1 = DOOR_GFX_PAGEX6 + gd_xoffset;
5322 gd_x2 = DOOR_GFX_PAGEX5 + gd_xoffset;
5323 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL3_BUTTONS_GFX_YPOS + gd_yoffset;
5324 gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL3_BUTTONS_ALT_GFX_YPOS + gd_yoffset;
5328 int x = (i - ED_NUM_CTRL1_3_BUTTONS) % ED_CTRL4_BUTTONS_HORIZ;
5329 int y = (i - ED_NUM_CTRL1_3_BUTTONS) / ED_CTRL4_BUTTONS_HORIZ + 3;
5331 gd_xoffset = ED_CTRL4_BUTTONS_XPOS + x * ED_CTRL4_BUTTON_XSIZE;
5332 gd_yoffset = ED_CTRL4_BUTTONS_YPOS + y * ED_CTRL4_BUTTON_YSIZE;
5333 width = ED_CTRL4_BUTTON_XSIZE;
5334 height = ED_CTRL4_BUTTON_YSIZE;
5336 gd_x1 = DOOR_GFX_PAGEX6 + ED_CTRL4_BUTTONS_GFX_XPOS + gd_xoffset;
5337 gd_x2 = DOOR_GFX_PAGEX5 + ED_CTRL4_BUTTONS_GFX_XPOS + gd_xoffset;
5338 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL4_BUTTONS_GFX_YPOS + gd_yoffset;
5339 gd_y2 = 0; /* no alternative graphic for these buttons */
5342 gi = CreateGadget(GDI_CUSTOM_ID, id,
5343 GDI_CUSTOM_TYPE_ID, i,
5344 GDI_INFO_TEXT, control_info[i].text,
5345 GDI_X, EX + gd_xoffset,
5346 GDI_Y, EY + gd_yoffset,
5349 GDI_TYPE, button_type,
5350 GDI_STATE, GD_BUTTON_UNPRESSED,
5351 GDI_RADIO_NR, radio_button_nr,
5352 GDI_CHECKED, checked,
5353 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5354 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y1,
5355 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2,
5356 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
5357 GDI_EVENT_MASK, event_mask,
5358 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5359 GDI_CALLBACK_ACTION, HandleControlButtons,
5363 Error(ERR_EXIT, "cannot create gadget");
5365 level_editor_gadget[id] = gi;
5368 /* these values are not constant, but can change at runtime */
5369 scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
5370 scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
5371 scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
5372 scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
5373 scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
5374 scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
5375 scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
5376 scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
5378 /* create buttons for scrolling of drawing area and element list */
5379 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
5381 int id = scrollbutton_info[i].gadget_id;
5382 int x, y, width, height;
5383 int gd_x1, gd_x2, gd_y1, gd_y2;
5385 x = scrollbutton_info[i].x;
5386 y = scrollbutton_info[i].y;
5388 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5390 if (id == GADGET_ID_SCROLL_LIST_UP ||
5391 id == GADGET_ID_SCROLL_LIST_DOWN)
5395 width = ED_SCROLLBUTTON2_XSIZE;
5396 height = ED_SCROLLBUTTON2_YSIZE;
5397 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].gd_x;
5398 gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].gd_y;
5399 gd_x2 = gd_x1 - ED_SCROLLBUTTON2_XSIZE;
5406 width = ED_SCROLLBUTTON_XSIZE;
5407 height = ED_SCROLLBUTTON_YSIZE;
5408 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].gd_x;
5409 gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].gd_y;
5410 gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE;
5414 gi = CreateGadget(GDI_CUSTOM_ID, id,
5415 GDI_CUSTOM_TYPE_ID, i,
5416 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
5421 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
5422 GDI_STATE, GD_BUTTON_UNPRESSED,
5423 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5424 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
5425 GDI_EVENT_MASK, event_mask,
5426 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5427 GDI_CALLBACK_ACTION, HandleControlButtons,
5431 Error(ERR_EXIT, "cannot create gadget");
5433 level_editor_gadget[id] = gi;
5436 /* create buttons for element list */
5437 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
5439 Bitmap *deco_bitmap;
5440 int deco_x, deco_y, deco_xpos, deco_ypos;
5441 int gd_xoffset, gd_yoffset;
5442 int gd_x1, gd_x2, gd_y;
5443 int x = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
5444 int y = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
5445 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
5446 int element = editor_elements[i];
5448 event_mask = GD_EVENT_RELEASED;
5450 gd_xoffset = ED_ELEMENTLIST_XPOS + x * ED_ELEMENTLIST_XSIZE;
5451 gd_yoffset = ED_ELEMENTLIST_YPOS + y * ED_ELEMENTLIST_YSIZE;
5453 gd_x1 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS + ED_ELEMENTLIST_XSIZE;
5454 gd_x2 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS;
5455 gd_y = DOOR_GFX_PAGEY1 + ED_ELEMENTLIST_YPOS;
5457 getMiniGraphicSource(el2edimg(element), &deco_bitmap, &deco_x, &deco_y);
5458 deco_xpos = (ED_ELEMENTLIST_XSIZE - MINI_TILEX) / 2;
5459 deco_ypos = (ED_ELEMENTLIST_YSIZE - MINI_TILEY) / 2;
5461 gi = CreateGadget(GDI_CUSTOM_ID, id,
5462 GDI_CUSTOM_TYPE_ID, i,
5463 GDI_INFO_TEXT, getElementInfoText(element),
5464 GDI_X, DX + gd_xoffset,
5465 GDI_Y, DY + gd_yoffset,
5466 GDI_WIDTH, ED_ELEMENTLIST_XSIZE,
5467 GDI_HEIGHT, ED_ELEMENTLIST_YSIZE,
5468 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
5469 GDI_STATE, GD_BUTTON_UNPRESSED,
5470 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
5471 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
5472 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
5473 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
5474 GDI_DECORATION_SIZE, MINI_TILEX, MINI_TILEY,
5475 GDI_DECORATION_SHIFTING, 1, 1,
5476 GDI_EVENT_MASK, event_mask,
5477 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5478 GDI_CALLBACK_ACTION, HandleControlButtons,
5482 Error(ERR_EXIT, "cannot create gadget");
5484 level_editor_gadget[id] = gi;
5488 static void CreateCounterButtons()
5490 int max_infotext_len = getMaxInfoTextLength();
5493 /* these values are not constant, but can change at runtime */
5494 counterbutton_info[ED_COUNTER_ID_SELECT_LEVEL].x = DX + 5 - SX;
5495 counterbutton_info[ED_COUNTER_ID_SELECT_LEVEL].y = DY + 3 - SY;
5497 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
5500 int x = SX + counterbutton_info[i].x; /* down count button */
5501 int y = SY + counterbutton_info[i].y;
5503 /* determine horizontal position to the right of specified gadget */
5504 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
5505 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
5506 ED_GADGET_TEXT_DISTANCE);
5508 /* determine horizontal offset for leading text */
5509 if (counterbutton_info[i].text_left != NULL)
5510 x += getTextWidthForGadget(counterbutton_info[i].text_left);
5512 for (j = 0; j < 2; j++)
5514 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5515 struct GadgetInfo *gi;
5517 counterbutton_info[i].gadget_id_down :
5518 counterbutton_info[i].gadget_id_up);
5520 int gd_x, gd_x1, gd_x2, gd_y;
5522 unsigned long event_mask;
5523 char infotext[max_infotext_len + 1];
5525 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5527 if (i == ED_COUNTER_ID_SELECT_LEVEL)
5530 ED_SCROLLBUTTON_ID_AREA_LEFT :
5531 ED_SCROLLBUTTON_ID_AREA_RIGHT);
5533 event_mask |= GD_EVENT_RELEASED;
5536 x += 2 * ED_GADGET_DISTANCE;
5537 y += ED_GADGET_DISTANCE;
5539 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[sid].gd_x;
5540 gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE;
5541 gd_y = DOOR_GFX_PAGEY1 + scrollbutton_info[sid].gd_y;
5542 x_size = ED_SCROLLBUTTON_XSIZE;
5543 y_size = ED_SCROLLBUTTON_YSIZE;
5547 gd_xoffset = (j == 0 ? ED_BUTTON_MINUS_XPOS : ED_BUTTON_PLUS_XPOS);
5548 gd_x1 = DOOR_GFX_PAGEX4 + gd_xoffset;
5549 gd_x2 = DOOR_GFX_PAGEX3 + gd_xoffset;
5550 gd_y = DOOR_GFX_PAGEY1 + ED_BUTTON_COUNT_YPOS;
5551 x_size = ED_BUTTON_COUNT_XSIZE;
5552 y_size = ED_BUTTON_COUNT_YSIZE;
5555 sprintf(infotext, "%s counter value by 1, 5 or 10",
5556 (j == 0 ? "decrease" : "increase"));
5558 gi = CreateGadget(GDI_CUSTOM_ID, id,
5559 GDI_CUSTOM_TYPE_ID, i,
5560 GDI_INFO_TEXT, infotext,
5565 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
5566 GDI_STATE, GD_BUTTON_UNPRESSED,
5567 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
5568 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
5569 GDI_EVENT_MASK, event_mask,
5570 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5571 GDI_CALLBACK_ACTION, HandleCounterButtons,
5575 Error(ERR_EXIT, "cannot create gadget");
5577 level_editor_gadget[id] = gi;
5578 right_gadget_border[id] =
5579 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
5581 x += gi->width + ED_GADGET_DISTANCE; /* text count button */
5585 int font_type = FONT_INPUT_1;
5586 int font_type_active = FONT_INPUT_1_ACTIVE;
5587 int gd_width = ED_WIN_COUNT_XSIZE;
5589 id = counterbutton_info[i].gadget_id_text;
5590 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
5592 if (i == ED_COUNTER_ID_SELECT_LEVEL)
5594 font_type = FONT_LEVEL_NUMBER;
5596 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
5598 font_type_active = FONT_LEVEL_NUMBER;
5600 x += 2 * ED_GADGET_DISTANCE;
5601 y -= ED_GADGET_DISTANCE;
5603 gd_x = DOOR_GFX_PAGEX6 + ED_WIN_COUNT2_XPOS;
5604 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT2_YPOS;
5605 gd_width = ED_WIN_COUNT2_XSIZE;
5609 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
5610 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
5613 gi = CreateGadget(GDI_CUSTOM_ID, id,
5614 GDI_CUSTOM_TYPE_ID, i,
5615 GDI_INFO_TEXT, "enter counter value",
5618 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
5619 GDI_NUMBER_VALUE, 0,
5620 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
5621 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
5622 GDI_TEXT_SIZE, 3, /* minimal counter text size */
5623 GDI_TEXT_FONT, font_type,
5624 GDI_TEXT_FONT_ACTIVE, font_type_active,
5625 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
5626 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
5627 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5628 GDI_DESIGN_WIDTH, gd_width,
5629 GDI_EVENT_MASK, event_mask,
5630 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5631 GDI_CALLBACK_ACTION, HandleCounterButtons,
5635 Error(ERR_EXIT, "cannot create gadget");
5637 level_editor_gadget[id] = gi;
5638 right_gadget_border[id] =
5639 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
5641 x += gi->width + ED_GADGET_DISTANCE; /* up count button */
5647 static void CreateDrawingAreas()
5651 /* these values are not constant, but can change at runtime */
5652 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
5653 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
5655 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
5657 struct GadgetInfo *gi;
5658 unsigned long event_mask;
5659 int id = drawingarea_info[i].gadget_id;
5660 int x = SX + drawingarea_info[i].x;
5661 int y = SY + drawingarea_info[i].y;
5662 int area_xsize = drawingarea_info[i].area_xsize;
5663 int area_ysize = drawingarea_info[i].area_ysize;
5666 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
5667 GD_EVENT_OFF_BORDERS;
5669 /* determine horizontal position to the right of specified gadget */
5670 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
5671 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
5672 ED_DRAWINGAREA_TEXT_DISTANCE);
5674 /* determine horizontal offset for leading text */
5675 if (drawingarea_info[i].text_left != NULL)
5676 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
5678 gi = CreateGadget(GDI_CUSTOM_ID, id,
5679 GDI_CUSTOM_TYPE_ID, i,
5682 GDI_TYPE, GD_TYPE_DRAWING_AREA,
5683 GDI_AREA_SIZE, area_xsize, area_ysize,
5684 GDI_ITEM_SIZE, MINI_TILEX, MINI_TILEY,
5685 GDI_EVENT_MASK, event_mask,
5686 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
5687 GDI_CALLBACK_ACTION, HandleDrawingAreas,
5691 Error(ERR_EXIT, "cannot create gadget");
5693 level_editor_gadget[id] = gi;
5694 right_gadget_border[id] =
5695 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
5699 static void CreateTextInputGadgets()
5701 int max_infotext_len = getMaxInfoTextLength();
5704 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
5706 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5708 struct GadgetInfo *gi;
5709 unsigned long event_mask;
5710 char infotext[MAX_OUTPUT_LINESIZE + 1];
5711 int id = textinput_info[i].gadget_id;
5713 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
5715 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
5716 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
5718 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
5719 infotext[max_infotext_len] = '\0';
5721 gi = CreateGadget(GDI_CUSTOM_ID, id,
5722 GDI_CUSTOM_TYPE_ID, i,
5723 GDI_INFO_TEXT, infotext,
5724 GDI_X, SX + textinput_info[i].x,
5725 GDI_Y, SY + textinput_info[i].y,
5726 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
5727 GDI_TEXT_VALUE, textinput_info[i].value,
5728 GDI_TEXT_SIZE, textinput_info[i].size,
5729 GDI_TEXT_FONT, FONT_INPUT_1,
5730 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
5731 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
5732 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
5733 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5734 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
5735 GDI_EVENT_MASK, event_mask,
5736 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5737 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
5741 Error(ERR_EXIT, "cannot create gadget");
5743 level_editor_gadget[id] = gi;
5747 static void CreateTextAreaGadgets()
5749 int max_infotext_len = getMaxInfoTextLength();
5752 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
5754 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5756 struct GadgetInfo *gi;
5757 unsigned long event_mask;
5758 char infotext[MAX_OUTPUT_LINESIZE + 1];
5759 int id = textarea_info[i].gadget_id;
5760 int area_xsize = textarea_info[i].xsize;
5761 int area_ysize = textarea_info[i].ysize;
5763 event_mask = GD_EVENT_TEXT_LEAVING;
5765 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
5766 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
5768 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
5769 infotext[max_infotext_len] = '\0';
5771 gi = CreateGadget(GDI_CUSTOM_ID, id,
5772 GDI_CUSTOM_TYPE_ID, i,
5773 GDI_INFO_TEXT, infotext,
5774 GDI_X, SX + textarea_info[i].x,
5775 GDI_Y, SY + textarea_info[i].y,
5776 GDI_TYPE, GD_TYPE_TEXT_AREA,
5777 GDI_AREA_SIZE, area_xsize, area_ysize,
5778 GDI_TEXT_FONT, FONT_INPUT_1,
5779 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
5780 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
5781 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
5782 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5783 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
5784 GDI_EVENT_MASK, event_mask,
5785 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5786 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
5790 Error(ERR_EXIT, "cannot create gadget");
5792 level_editor_gadget[id] = gi;
5796 static void CreateSelectboxGadgets()
5798 int max_infotext_len = getMaxInfoTextLength();
5801 for (i = 0; i < ED_NUM_SELECTBOX; i++)
5803 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5805 struct GadgetInfo *gi;
5806 unsigned long event_mask;
5807 char infotext[MAX_OUTPUT_LINESIZE + 1];
5808 int id = selectbox_info[i].gadget_id;
5809 int x = SX + selectbox_info[i].x;
5810 int y = SY + selectbox_info[i].y;
5812 if (selectbox_info[i].size == -1) /* dynamically determine size */
5814 /* (we cannot use -1 for uninitialized values if we directly compare
5815 with results from strlen(), because the '<' and '>' operation will
5816 implicitely cast -1 to an unsigned integer value!) */
5817 selectbox_info[i].size = 0;
5819 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
5820 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
5821 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
5823 selectbox_info[i].size++; /* add one character empty space */
5826 event_mask = GD_EVENT_RELEASED |
5827 GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
5829 gd_x = DOOR_GFX_PAGEX4 + ED_SELECTBOX_XPOS;
5830 gd_y = DOOR_GFX_PAGEY1 + ED_SELECTBOX_YPOS;
5832 /* determine horizontal position to the right of specified gadget */
5833 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
5834 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
5835 ED_GADGET_TEXT_DISTANCE);
5837 /* determine horizontal offset for leading text */
5838 if (selectbox_info[i].text_left != NULL)
5839 x += getTextWidthForGadget(selectbox_info[i].text_left);
5841 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
5842 infotext[max_infotext_len] = '\0';
5844 gi = CreateGadget(GDI_CUSTOM_ID, id,
5845 GDI_CUSTOM_TYPE_ID, i,
5846 GDI_INFO_TEXT, infotext,
5849 GDI_TYPE, GD_TYPE_SELECTBOX,
5850 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
5851 GDI_TEXT_SIZE, selectbox_info[i].size,
5852 GDI_TEXT_FONT, FONT_INPUT_1,
5853 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
5854 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
5855 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
5856 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5857 GDI_BORDER_SIZE_SELECTBUTTON, ED_SELECTBOX_BUTTON_XSIZE,
5858 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
5859 GDI_EVENT_MASK, event_mask,
5860 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5861 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
5865 Error(ERR_EXIT, "cannot create gadget");
5867 level_editor_gadget[id] = gi;
5868 right_gadget_border[id] =
5869 getRightGadgetBorder(gi, selectbox_info[i].text_right);
5873 static void CreateTextbuttonGadgets()
5875 int max_infotext_len = getMaxInfoTextLength();
5878 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
5880 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5881 int gd_x1, gd_x2, gd_y1, gd_y2;
5882 struct GadgetInfo *gi;
5883 unsigned long event_mask;
5884 char infotext[MAX_OUTPUT_LINESIZE + 1];
5885 int id = textbutton_info[i].gadget_id;
5886 int x = SX + textbutton_info[i].x;
5887 int y = SY + textbutton_info[i].y;
5889 if (textbutton_info[i].size == -1) /* dynamically determine size */
5890 textbutton_info[i].size = strlen(textbutton_info[i].text);
5892 event_mask = GD_EVENT_RELEASED;
5894 if ((id >= GADGET_ID_LEVELINFO_LEVEL && id <= GADGET_ID_LEVELINFO_EDITOR) ||
5895 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE))
5897 gd_x1 = DOOR_GFX_PAGEX4 + ED_TEXTBUTTON_TAB_XPOS;
5898 gd_x2 = DOOR_GFX_PAGEX3 + ED_TEXTBUTTON_TAB_XPOS;
5899 gd_y1 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_TAB_YPOS;
5900 gd_y2 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_TAB_INACTIVE_YPOS;
5904 gd_x1 = DOOR_GFX_PAGEX4 + ED_TEXTBUTTON_XPOS;
5905 gd_x2 = DOOR_GFX_PAGEX3 + ED_TEXTBUTTON_XPOS;
5906 gd_y1 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_YPOS;
5907 gd_y2 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_INACTIVE_YPOS;
5910 sprintf(infotext, "%s", textbutton_info[i].infotext);
5911 infotext[max_infotext_len] = '\0';
5913 /* determine horizontal position to the right of specified gadget */
5914 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
5915 x = (right_gadget_border[textbutton_info[i].gadget_id_align] +
5916 ED_GADGET_TEXT_DISTANCE);
5918 /* determine horizontal offset for leading text */
5919 if (textbutton_info[i].text_left != NULL)
5920 x += getTextWidthForGadget(textbutton_info[i].text_left);
5922 gi = CreateGadget(GDI_CUSTOM_ID, id,
5923 GDI_CUSTOM_TYPE_ID, i,
5924 GDI_INFO_TEXT, infotext,
5927 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
5928 GDI_TEXT_VALUE, textbutton_info[i].text,
5929 GDI_TEXT_SIZE, textbutton_info[i].size,
5930 GDI_TEXT_FONT, FONT_INPUT_2_ACTIVE,
5931 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2,
5932 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5933 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y1,
5934 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2,
5935 GDI_BORDER_SIZE, ED_BORDER_TEXT_XSIZE, ED_BORDER_SIZE,
5936 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
5937 GDI_DECORATION_SHIFTING, 1, 1,
5938 GDI_EVENT_MASK, event_mask,
5939 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5940 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
5944 Error(ERR_EXIT, "cannot create gadget");
5946 level_editor_gadget[id] = gi;
5947 right_gadget_border[id] =
5948 getRightGadgetBorder(gi, textbutton_info[i].text_right);
5952 static void CreateGraphicbuttonGadgets()
5954 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5955 struct GadgetInfo *gi;
5956 unsigned long event_mask;
5959 /* create buttons for scrolling of drawing area and element list */
5960 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
5962 int id = graphicbutton_info[i].gadget_id;
5963 int gd_x1, gd_x2, gd_y1, gd_y2;
5964 int x = SX + graphicbutton_info[i].x;
5965 int y = SY + graphicbutton_info[i].y;
5967 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5969 if (i <= ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
5971 gd_x1 = DOOR_GFX_PAGEX4 + graphicbutton_info[i].gd_x;
5972 gd_y1 = DOOR_GFX_PAGEY1 + graphicbutton_info[i].gd_y;
5973 gd_x2 = DOOR_GFX_PAGEX3 + graphicbutton_info[i].gd_x;
5976 else /* (i <= ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE) */
5978 gd_x1 = DOOR_GFX_PAGEX6 + graphicbutton_info[i].gd_x;
5979 gd_y1 = DOOR_GFX_PAGEY1 + graphicbutton_info[i].gd_y;
5980 gd_x2 = gd_x1 - ED_BUTTON_COUNT_XSIZE;
5984 /* determine horizontal position to the right of specified gadget */
5985 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
5986 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
5987 ED_GADGET_TEXT_DISTANCE);
5989 /* determine horizontal offset for leading text */
5990 if (graphicbutton_info[i].text_left != NULL)
5991 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
5993 gi = CreateGadget(GDI_CUSTOM_ID, id,
5994 GDI_CUSTOM_TYPE_ID, i,
5995 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
5998 GDI_WIDTH, graphicbutton_info[i].width,
5999 GDI_HEIGHT, graphicbutton_info[i].height,
6000 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6001 GDI_STATE, GD_BUTTON_UNPRESSED,
6002 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6003 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6004 GDI_EVENT_MASK, event_mask,
6005 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6006 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
6010 Error(ERR_EXIT, "cannot create gadget");
6012 level_editor_gadget[id] = gi;
6013 right_gadget_border[id] =
6014 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
6018 static void CreateScrollbarGadgets()
6022 /* these values are not constant, but can change at runtime */
6023 scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
6024 SX + ED_SCROLL_HORIZONTAL_XPOS;
6025 scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
6026 SY + ED_SCROLL_HORIZONTAL_YPOS;
6027 scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
6028 ED_SCROLL_HORIZONTAL_XSIZE;
6029 scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
6030 ED_SCROLL_HORIZONTAL_YSIZE;
6031 scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
6032 scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
6033 scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
6034 scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
6036 scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
6037 SX + ED_SCROLL_VERTICAL_XPOS;
6038 scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
6039 SY + ED_SCROLL_VERTICAL_YPOS;
6040 scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
6041 ED_SCROLL_VERTICAL_XSIZE;
6042 scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
6043 ED_SCROLL_VERTICAL_YSIZE;
6044 scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
6045 scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
6046 scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
6047 scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
6049 scrollbar_info[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
6050 DX + ED_SCROLL2_VERTICAL_XPOS;
6051 scrollbar_info[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
6052 DY + ED_SCROLL2_VERTICAL_YPOS;
6053 scrollbar_info[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = DX;
6054 scrollbar_info[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = DY;
6056 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
6058 int id = scrollbar_info[i].gadget_id;
6059 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
6060 int gd_x1, gd_x2, gd_y1, gd_y2;
6061 struct GadgetInfo *gi;
6062 int items_max, items_visible, item_position;
6063 unsigned long event_mask;
6065 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
6067 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
6068 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
6069 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
6071 else /* drawing area scrollbars */
6073 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
6075 items_max = MAX(lev_fieldx + 2, ed_fieldx);
6076 items_visible = ed_fieldx;
6081 items_max = MAX(lev_fieldy + 2, ed_fieldy);
6082 items_visible = ed_fieldy;
6087 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
6089 gd_x1 = DOOR_GFX_PAGEX8 + scrollbar_info[i].gd_x;
6090 gd_x2 = (gd_x1 - (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL ?
6091 scrollbar_info[i].height : scrollbar_info[i].width));
6092 gd_y1 = DOOR_GFX_PAGEY1 + scrollbar_info[i].gd_y;
6093 gd_y2 = DOOR_GFX_PAGEY1 + scrollbar_info[i].gd_y;
6095 gi = CreateGadget(GDI_CUSTOM_ID, id,
6096 GDI_CUSTOM_TYPE_ID, i,
6097 GDI_INFO_TEXT, scrollbar_info[i].infotext,
6098 GDI_X, scrollbar_info[i].x,
6099 GDI_Y, scrollbar_info[i].y,
6100 GDI_WIDTH, scrollbar_info[i].width,
6101 GDI_HEIGHT, scrollbar_info[i].height,
6102 GDI_TYPE, scrollbar_info[i].type,
6103 GDI_SCROLLBAR_ITEMS_MAX, items_max,
6104 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
6105 GDI_SCROLLBAR_ITEM_POSITION, item_position,
6106 GDI_WHEEL_AREA_X, scrollbar_info[i].wheel_x,
6107 GDI_WHEEL_AREA_Y, scrollbar_info[i].wheel_y,
6108 GDI_WHEEL_AREA_WIDTH, scrollbar_info[i].wheel_width,
6109 GDI_WHEEL_AREA_HEIGHT, scrollbar_info[i].wheel_height,
6110 GDI_STATE, GD_BUTTON_UNPRESSED,
6111 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6112 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6113 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
6114 GDI_EVENT_MASK, event_mask,
6115 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6116 GDI_CALLBACK_ACTION, HandleControlButtons,
6120 Error(ERR_EXIT, "cannot create gadget");
6122 level_editor_gadget[id] = gi;
6126 static void CreateCheckbuttonGadgets()
6128 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
6129 struct GadgetInfo *gi;
6130 unsigned long event_mask;
6131 int gd_x1, gd_x2, gd_x3, gd_x4, gd_y;
6134 event_mask = GD_EVENT_PRESSED;
6136 gd_x1 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_UNCHECKED_XPOS;
6137 gd_x2 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_UNCHECKED_XPOS;
6138 gd_x3 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_CHECKED_XPOS;
6139 gd_x4 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_CHECKED_XPOS;
6140 gd_y = DOOR_GFX_PAGEY1 + ED_RADIOBUTTON_YPOS;
6142 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
6144 int id = checkbutton_info[i].gadget_id;
6145 int x = SX + checkbutton_info[i].x;
6146 int y = SY + checkbutton_info[i].y;
6148 if (id == GADGET_ID_STICK_ELEMENT)
6149 gd_y = DOOR_GFX_PAGEY1 + ED_STICKYBUTTON_YPOS;
6151 gd_y = DOOR_GFX_PAGEY1 + ED_CHECKBUTTON_YPOS;
6153 /* determine horizontal position to the right of specified gadget */
6154 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6155 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
6156 ED_GADGET_TEXT_DISTANCE);
6158 /* determine horizontal offset for leading text */
6159 if (checkbutton_info[i].text_left != NULL)
6160 x += getTextWidthForGadget(checkbutton_info[i].text_left);
6162 gi = CreateGadget(GDI_CUSTOM_ID, id,
6163 GDI_CUSTOM_TYPE_ID, i,
6164 GDI_INFO_TEXT, checkbutton_info[i].infotext,
6167 GDI_WIDTH, ED_CHECKBUTTON_XSIZE,
6168 GDI_HEIGHT, ED_CHECKBUTTON_YSIZE,
6169 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
6170 GDI_CHECKED, *checkbutton_info[i].value,
6171 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
6172 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
6173 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y,
6174 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y,
6175 GDI_EVENT_MASK, event_mask,
6176 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6177 GDI_CALLBACK_ACTION, HandleCheckbuttons,
6181 Error(ERR_EXIT, "cannot create gadget");
6183 level_editor_gadget[id] = gi;
6184 right_gadget_border[id] =
6185 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
6189 static void CreateRadiobuttonGadgets()
6191 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
6192 struct GadgetInfo *gi;
6193 unsigned long event_mask;
6194 int gd_x1, gd_x2, gd_x3, gd_x4, gd_y;
6197 event_mask = GD_EVENT_PRESSED;
6199 gd_x1 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_UNCHECKED_XPOS;
6200 gd_x2 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_UNCHECKED_XPOS;
6201 gd_x3 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_CHECKED_XPOS;
6202 gd_x4 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_CHECKED_XPOS;
6203 gd_y = DOOR_GFX_PAGEY1 + ED_RADIOBUTTON_YPOS;
6205 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
6207 int id = radiobutton_info[i].gadget_id;
6208 int x = SX + radiobutton_info[i].x;
6209 int y = SY + radiobutton_info[i].y;
6212 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
6214 /* determine horizontal position to the right of specified gadget */
6215 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
6216 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
6217 ED_GADGET_TEXT_DISTANCE);
6219 /* determine horizontal offset for leading text */
6220 if (radiobutton_info[i].text_left != NULL)
6221 x += getTextWidthForGadget(radiobutton_info[i].text_left);
6223 gi = CreateGadget(GDI_CUSTOM_ID, id,
6224 GDI_CUSTOM_TYPE_ID, i,
6225 GDI_INFO_TEXT, radiobutton_info[i].infotext,
6228 GDI_WIDTH, ED_CHECKBUTTON_XSIZE,
6229 GDI_HEIGHT, ED_CHECKBUTTON_YSIZE,
6230 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
6231 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
6232 GDI_CHECKED, checked,
6233 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
6234 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
6235 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y,
6236 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y,
6237 GDI_EVENT_MASK, event_mask,
6238 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6239 GDI_CALLBACK_ACTION, HandleRadiobuttons,
6243 Error(ERR_EXIT, "cannot create gadget");
6245 level_editor_gadget[id] = gi;
6246 right_gadget_border[id] =
6247 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
6251 void CreateLevelEditorGadgets()
6253 int old_game_status = game_status;
6255 /* setting 'game_status' is needed to get the right fonts for the editor */
6256 game_status = GAME_MODE_EDITOR;
6258 /* these values are not constant, but can change at runtime */
6259 ed_fieldx = MAX_ED_FIELDX - 1;
6260 ed_fieldy = MAX_ED_FIELDY - 1;
6262 ReinitializeElementList();
6264 CreateControlButtons();
6265 CreateScrollbarGadgets();
6267 /* order of function calls is important because of cross-references */
6268 CreateCheckbuttonGadgets();
6269 CreateCounterButtons();
6270 CreateRadiobuttonGadgets();
6271 CreateTextInputGadgets();
6272 CreateTextAreaGadgets();
6273 CreateSelectboxGadgets();
6274 CreateGraphicbuttonGadgets();
6275 CreateTextbuttonGadgets();
6276 CreateDrawingAreas();
6278 game_status = old_game_status;
6281 void FreeLevelEditorGadgets()
6285 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
6287 FreeGadget(level_editor_gadget[i]);
6289 level_editor_gadget[i] = NULL;
6293 static void MapCounterButtons(int id)
6295 int gadget_id_down = counterbutton_info[id].gadget_id_down;
6296 int gadget_id_text = counterbutton_info[id].gadget_id_text;
6297 int gadget_id_up = counterbutton_info[id].gadget_id_up;
6298 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
6299 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
6300 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
6301 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
6302 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6303 int yoffset_above = MINI_TILEX + ED_GADGET_DISTANCE;
6304 int yoffset = ED_BORDER_SIZE;
6305 int x_left = gi_down->x - xoffset_left;
6306 int x_right; /* set after gadget position was modified */
6307 int y_above = gi_down->y - yoffset_above;
6309 int y; /* set after gadget position was modified */
6311 /* counter limits must be changed first to prevent value truncation */
6312 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
6313 counterbutton_info[id].max_value);
6315 /* right text position might have changed after setting position above */
6316 x_right = gi_up->x + gi_up->width + xoffset_right;
6318 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
6320 /* set position for "value[1,2,3,4]" counter gadgets (score in most cases) */
6321 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
6322 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
6324 ModifyGadget(gi_down, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
6325 ModifyGadget(gi_text, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
6326 ModifyGadget(gi_up, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
6329 /* vertical position might have changed after setting position above */
6330 y = gi_up->y + yoffset;
6332 if (counterbutton_info[id].text_above)
6333 DrawText(x, y_above, counterbutton_info[id].text_above, FONT_TEXT_1);
6335 if (counterbutton_info[id].text_left)
6336 DrawText(x_left, y, counterbutton_info[id].text_left, FONT_TEXT_1);
6338 if (counterbutton_info[id].text_right)
6339 DrawText(x_right, y, counterbutton_info[id].text_right, FONT_TEXT_1);
6346 static void MapControlButtons()
6351 /* map toolbox buttons (excluding special CE toolbox buttons) */
6352 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
6353 MapGadget(level_editor_gadget[i]);
6355 /* map buttons to select elements */
6356 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6357 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
6358 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
6359 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
6360 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
6362 /* map buttons to select level */
6363 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
6364 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
6365 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
6366 MapCounterButtons(counter_id);
6369 static void MapDrawingArea(int id)
6371 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6372 int area_xsize = gi->drawing.area_xsize;
6373 int area_ysize = gi->drawing.area_ysize;
6374 int xoffset_left= getTextWidthForDrawingArea(drawingarea_info[id].text_left);
6375 int xoffset_below= getTextWidth(drawingarea_info[id].text_below,FONT_TEXT_1);
6376 int x_left = gi->x - xoffset_left;
6377 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
6378 int x_below = gi->x + (gi->width - xoffset_below) / 2;
6379 int y_side = gi->y + (gi->height - getFontHeight(FONT_TEXT_1)) / 2;
6380 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
6382 if (drawingarea_info[id].text_left)
6383 DrawText(x_left, y_side, drawingarea_info[id].text_left, FONT_TEXT_1);
6385 if (drawingarea_info[id].text_right)
6386 DrawText(x_right, y_side, drawingarea_info[id].text_right, FONT_TEXT_1);
6388 if (drawingarea_info[id].text_below)
6389 DrawText(x_below, y_below, drawingarea_info[id].text_below, FONT_TEXT_1);
6391 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
6393 DrawElementBorder(gi->x, gi->y,
6394 area_xsize * MINI_TILEX, area_ysize * MINI_TILEY, TRUE);
6396 DrawDrawingArea(id);
6402 static void MapTextInputGadget(int id)
6404 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
6405 int xoffset_above = 0;
6406 int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
6407 int x_above = textinput_info[id].x + xoffset_above;
6408 int y_above = textinput_info[id].y + yoffset_above;
6410 if (textinput_info[id].text_above)
6411 DrawTextS(x_above, y_above, FONT_TEXT_1, textinput_info[id].text_above);
6413 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
6418 static void MapTextAreaGadget(int id)
6420 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
6421 int xoffset_above = 0;
6422 int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
6423 int x_above = textarea_info[id].x + xoffset_above;
6424 int y_above = textarea_info[id].y + yoffset_above;
6426 if (textarea_info[id].text_above)
6427 DrawTextS(x_above, y_above, FONT_TEXT_1, textarea_info[id].text_above);
6429 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
6434 static void MapSelectboxGadget(int id)
6436 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
6437 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
6438 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6439 int yoffset = ED_BORDER_SIZE;
6440 int x_left = gi->x - xoffset_left;
6441 int x_right = gi->x + gi->width + xoffset_right;
6442 int y = gi->y + yoffset;
6444 if (selectbox_info[id].text_left)
6445 DrawText(x_left, y, selectbox_info[id].text_left, FONT_TEXT_1);
6447 if (selectbox_info[id].text_right)
6448 DrawText(x_right, y, selectbox_info[id].text_right, FONT_TEXT_1);
6450 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
6455 static void MapTextbuttonGadget(int id)
6457 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
6458 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
6459 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6460 int yoffset = ED_BORDER_SIZE;
6461 int x_left = gi->x - xoffset_left;
6462 int x_right = gi->x + gi->width + xoffset_right;
6463 int y = gi->y + yoffset;
6465 /* only show button to delete change pages when more than minimum pages */
6466 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
6467 custom_element.num_change_pages == MIN_CHANGE_PAGES)
6470 if (textbutton_info[id].text_left)
6471 DrawText(x_left, y, textbutton_info[id].text_left, FONT_TEXT_1);
6473 if (textbutton_info[id].text_right)
6474 DrawText(x_right, y, textbutton_info[id].text_right, FONT_TEXT_1);
6479 static void MapGraphicbuttonGadget(int id)
6481 struct GadgetInfo *gi= level_editor_gadget[graphicbutton_info[id].gadget_id];
6482 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
6483 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6484 int yoffset = ED_BORDER_SIZE;
6485 int x_left = gi->x - xoffset_left;
6486 int x_right = gi->x + gi->width + xoffset_right;
6487 int y = gi->y + yoffset;
6489 if (graphicbutton_info[id].text_left)
6490 DrawText(x_left, y, graphicbutton_info[id].text_left, FONT_TEXT_1);
6492 if (graphicbutton_info[id].text_right)
6493 DrawText(x_right, y, graphicbutton_info[id].text_right, FONT_TEXT_1);
6498 static void MapRadiobuttonGadget(int id)
6500 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
6501 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
6502 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6503 int yoffset = ED_BORDER_SIZE;
6504 int x_left = gi->x - xoffset_left;
6505 int x_right = gi->x + gi->width + xoffset_right;
6506 int y = gi->y + yoffset;
6508 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
6510 if (radiobutton_info[id].text_left)
6511 DrawText(x_left, y, radiobutton_info[id].text_left, FONT_TEXT_1);
6513 if (radiobutton_info[id].text_right)
6514 DrawText(x_right, y, radiobutton_info[id].text_right, FONT_TEXT_1);
6516 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
6521 static void MapCheckbuttonGadget(int id)
6523 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
6524 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
6525 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6526 int yoffset = ED_BORDER_SIZE;
6527 int x_left, x_right, y; /* set after gadget position was modified */
6529 /* set position for gadgets with dynamically determined position */
6530 if (checkbutton_info[id].x != -1) /* do not change dynamic positions */
6531 ModifyGadget(gi, GDI_X, SX + checkbutton_info[id].x, GDI_END);
6532 ModifyGadget(gi, GDI_Y, SY + checkbutton_info[id].y, GDI_END);
6534 x_left = gi->x - xoffset_left;
6535 x_right = gi->x + gi->width + xoffset_right;
6536 y = gi->y + yoffset;
6538 if (checkbutton_info[id].text_left)
6539 DrawText(x_left, y, checkbutton_info[id].text_left, FONT_TEXT_1);
6541 if (checkbutton_info[id].text_right)
6542 DrawText(x_right, y, checkbutton_info[id].text_right, FONT_TEXT_1);
6544 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
6549 static void MapMainDrawingArea()
6551 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
6552 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
6555 for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
6557 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
6558 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
6559 no_horizontal_scrollbar) ||
6560 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
6561 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
6562 no_vertical_scrollbar))
6565 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
6568 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
6570 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
6571 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
6574 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
6577 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
6580 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
6584 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6586 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
6587 i == GADGET_ID_CUSTOM_COPY_TO ||
6588 i == GADGET_ID_CUSTOM_EXCHANGE ||
6589 i == GADGET_ID_CUSTOM_COPY ||
6590 i == GADGET_ID_CUSTOM_PASTE)
6593 MapGadget(level_editor_gadget[i]);
6595 UnmapGadget(level_editor_gadget[i]);
6600 static void MapLevelEditorToolboxCustomGadgets()
6602 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
6605 static void UnmapLevelEditorToolboxCustomGadgets()
6607 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
6610 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
6612 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
6615 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
6617 if (i != GADGET_ID_SINGLE_ITEMS &&
6618 i != GADGET_ID_PROPERTIES &&
6619 i != GADGET_ID_PICK_ELEMENT)
6621 struct GadgetInfo *gi = level_editor_gadget[i];
6629 BlitBitmap(gd_bitmap, drawto,
6630 DOOR_GFX_PAGEX6 + ED_CTRL_NO_BUTTONS_GFX_XPOS,
6631 DOOR_GFX_PAGEY1 + ED_CTRL_NO_BUTTONS_GFX_YPOS,
6632 gi->width, gi->height, gi->x, gi->y);
6634 redraw_mask |= REDRAW_DOOR_3;
6640 static void MapLevelEditorToolboxDrawingGadgets()
6642 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
6645 static void UnmapLevelEditorToolboxDrawingGadgets()
6647 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
6650 static void UnmapDrawingArea(int id)
6652 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
6655 static void UnmapLevelEditorWindowGadgets()
6659 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
6660 if (level_editor_gadget[i]->x < SX + SXSIZE)
6661 UnmapGadget(level_editor_gadget[i]);
6664 void UnmapLevelEditorGadgets()
6668 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
6669 UnmapGadget(level_editor_gadget[i]);
6672 static void ResetUndoBuffer()
6674 undo_buffer_position = -1;
6675 undo_buffer_steps = -1;
6676 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
6678 level.changed = FALSE;
6681 static void DrawEditModeWindow()
6683 ModifyEditorElementList();
6684 RedrawDrawingElements();
6686 if (edit_mode == ED_MODE_INFO)
6687 DrawLevelInfoWindow();
6688 else if (edit_mode == ED_MODE_PROPERTIES)
6689 DrawPropertiesWindow();
6690 else /* edit_mode == ED_MODE_DRAWING */
6691 DrawDrawingWindow();
6694 static boolean LevelChanged()
6696 boolean field_changed = FALSE;
6700 /* changed read-only levels can now be saved in personal level set */
6702 if (leveldir_current->readonly)
6706 for (y = 0; y < lev_fieldy; y++)
6707 for (x = 0; x < lev_fieldx; x++)
6708 if (Feld[x][y] != level.field[x][y])
6709 field_changed = TRUE;
6711 return (level.changed || field_changed);
6714 static boolean PrepareSavingIntoPersonalLevelSet()
6716 static LevelDirTree *last_copied_leveldir = NULL;
6717 static LevelDirTree *last_written_leveldir = NULL;
6718 static int last_copied_level_nr = -1;
6719 static int last_written_level_nr = -1;
6720 LevelDirTree *leveldir_former = leveldir_current;
6721 int level_nr_former = level_nr;
6724 // remember last mod/save so that for current session, we write
6725 // back to the same personal copy, asking only about overwrite.
6726 if (leveldir_current == last_copied_leveldir &&
6727 level_nr == last_copied_level_nr)
6729 // "cd" to personal level set dir (as used when writing last copy)
6730 leveldir_current = last_written_leveldir;
6731 level_nr = last_written_level_nr;
6736 if (!Request("This level is read only ! "
6737 "Save into personal level set ?", REQ_ASK))
6740 // "cd" to personal level set dir (for writing copy the first time)
6742 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
6744 // find unused level number
6745 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
6747 static char *level_filename = NULL;
6749 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
6751 if (!fileExists(level_filename))
6755 last_copied_leveldir = leveldir_former;
6756 last_copied_level_nr = level_nr_former;
6758 last_written_leveldir = leveldir_current;
6759 last_written_level_nr = level_nr = new_level_nr;
6764 static void ModifyLevelInfoForSavingIntoPersonalLevelSet(char *former_name)
6766 static char *filename_levelinfo = NULL, *mod_name = NULL;
6769 // annotate this copy-and-mod in personal levelinfo.conf
6770 setString(&filename_levelinfo,
6771 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
6773 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
6775 fprintf(file, "\n");
6776 fprintf(file, "# level %d was modified from:\n", level_nr);
6777 fprintf(file, "# - previous level set name: %s\n",
6779 fprintf(file, "# - level within previous set: %d \"%s\"\n",
6780 level.file_info.nr, level.name);
6781 fprintf(file, "# - previous author: %s\n",
6783 fprintf(file, "# - previous save date: ");
6785 if (level.creation_date.src == DATE_SRC_LEVELFILE)
6787 fprintf(file, "%04d-%02d-%02d\n",
6788 level.creation_date.year,
6789 level.creation_date.month,
6790 level.creation_date.day);
6794 fprintf(file, "not recorded\n");
6800 if (level_nr > leveldir_current->last_level)
6802 static char *temp_levelinfo = NULL;
6803 FILE *temp_file = NULL;
6804 char line[MAX_LINE_LEN];
6806 setString(&temp_levelinfo,
6807 getPath2(getCurrentLevelDir(),
6808 getStringCat2(LEVELINFO_FILENAME, ".new")));
6810 if ((file = fopen(filename_levelinfo, MODE_READ)) &&
6811 (temp_file = fopen(temp_levelinfo, MODE_WRITE)))
6813 while (fgets(line, MAX_LINE_LEN, file))
6815 if (!strPrefix(line, "levels:"))
6816 fputs(line, temp_file);
6818 fprintf(temp_file, "%-32s%d\n", "levels:", level_nr + 9);
6828 // needs error handling; also, ok on dos/win?
6829 unlink(filename_levelinfo);
6830 rename(temp_levelinfo, filename_levelinfo);
6833 // else: allow the save even if annotation failed
6835 // now... spray graffiti on the old level vital statistics
6836 // user can change these; just trying to set a good baseline
6838 // don't truncate names for fear of making offensive or silly:
6839 // long-named original author only recorded in levelinfo.conf.
6840 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
6841 if (!strEqual(level.author, leveldir_current->author))
6843 setString(&mod_name, getStringCat3(leveldir_current->author,
6844 " after ", level.author));
6846 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
6847 setString(&mod_name,
6848 getStringCat2(leveldir_current->author, " (ed.)"));
6850 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
6851 setString(&mod_name, leveldir_current->author);
6853 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
6855 // less worried about truncation here
6856 setString(&mod_name, getStringCat2("Mod: ", level.name));
6857 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
6861 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
6862 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
6866 for (x = 0; x < lev_fieldx; x++)
6867 for (y = 0; y < lev_fieldy; y++)
6868 dst[x][y] = src[x][y];
6871 static int setSelectboxValue(int selectbox_id, int new_value)
6873 int new_index_value = 0;
6876 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
6877 if (selectbox_info[selectbox_id].options[i].value == new_value)
6878 new_index_value = i;
6880 *selectbox_info[selectbox_id].value =
6881 selectbox_info[selectbox_id].options[new_index_value].value;
6883 return new_index_value;
6886 static void setSelectboxSpecialActionVariablesIfNeeded()
6890 /* change action mode and arg variables according to action type variable */
6891 for (i = 0; action_arg_options[i].value != -1; i++)
6893 if (action_arg_options[i].value == custom_element_change.action_type)
6895 int mode = action_arg_options[i].mode;
6897 /* only change if corresponding selectbox has changed */
6898 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
6899 action_arg_modes[mode])
6900 custom_element_change.action_mode = -1;
6902 /* only change if corresponding selectbox has changed */
6903 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
6904 action_arg_options[i].options)
6905 custom_element_change.action_arg = -1;
6912 static void setSelectboxSpecialActionOptions()
6916 /* change action mode and arg selectbox according to action type selectbox */
6917 for (i = 0; action_arg_options[i].value != -1; i++)
6919 if (action_arg_options[i].value == custom_element_change.action_type)
6921 int mode = action_arg_options[i].mode;
6923 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
6924 action_arg_modes[mode]);
6925 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
6926 custom_element_change.action_mode);
6928 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
6929 action_arg_options[i].options);
6930 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
6931 custom_element_change.action_arg);
6937 static void copy_custom_element_settings(int element_from, int element_to)
6939 struct ElementInfo *ei_from = &element_info[element_from];
6940 struct ElementInfo *ei_to = &element_info[element_to];
6942 copyElementInfo(ei_from, ei_to);
6945 static void replace_custom_element_in_settings(int element_from,
6950 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6952 struct ElementInfo *ei = &element_info[i];
6954 for (y = 0; y < 3; y++)
6955 for (x = 0; x < 3; x++)
6956 if (ei->content.e[x][y] == element_from)
6957 ei->content.e[x][y] = element_to;
6959 for (j = 0; j < ei->num_change_pages; j++)
6961 struct ElementChangeInfo *change = &ei->change_page[j];
6963 if (change->target_element == element_from)
6964 change->target_element = element_to;
6966 if (change->initial_trigger_element == element_from)
6967 change->initial_trigger_element = element_to;
6969 if (change->action_element == element_from)
6970 change->action_element = element_to;
6972 for (y = 0; y < 3; y++)
6973 for (x = 0; x < 3; x++)
6974 if (change->target_content.e[x][y] == element_from)
6975 change->target_content.e[x][y] = element_to;
6978 if (ei->group != NULL) /* group or internal */
6979 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
6980 if (ei->group->element[j] == element_from)
6981 ei->group->element[j] = element_to;
6985 static void replace_custom_element_in_playfield(int element_from,
6990 for (x = 0; x < lev_fieldx; x++)
6991 for (y = 0; y < lev_fieldy; y++)
6992 if (Feld[x][y] == element_from)
6993 Feld[x][y] = element_to;
6996 static boolean CopyCustomElement(int element_old, int element_new,
6999 if (copy_mode == GADGET_ID_CUSTOM_COPY)
7001 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
7002 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
7003 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
7005 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
7007 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
7008 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
7009 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
7011 level.changed = TRUE;
7013 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
7015 Request("Please choose custom element !", REQ_CONFIRM);
7019 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
7021 Request("Please choose group element !", REQ_CONFIRM);
7027 level.changed = TRUE;
7030 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
7032 copy_custom_element_settings(element_new, element_old);
7034 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
7036 copy_custom_element_settings(element_old, element_new);
7038 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
7040 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
7041 copy_custom_element_settings(element_new, element_old);
7042 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
7044 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
7045 replace_custom_element_in_settings(element_new, element_old);
7046 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
7048 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
7049 replace_custom_element_in_playfield(element_new, element_old);
7050 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
7053 UpdateCustomElementGraphicGadgets();
7054 DrawPropertiesWindow();
7059 static void CopyCustomElementPropertiesToEditor(int element)
7062 int current_change_page = element_info[element].current_change_page;
7064 /* dynamically (re)build selectbox for selecting change page */
7065 for (i = 0; i < element_info[element].num_change_pages; i++)
7067 sprintf(options_change_page_strings[i], "%d", i + 1);
7069 options_change_page[i].value = i;
7070 options_change_page[i].text = options_change_page_strings[i];
7073 options_change_page[i].value = -1;
7074 options_change_page[i].text = NULL;
7076 /* needed here to initialize combined element properties */
7077 InitElementPropertiesEngine(level.game_version);
7079 element_info[element].change =
7080 &element_info[element].change_page[current_change_page];
7082 custom_element = element_info[element];
7083 custom_element_change = *element_info[element].change;
7085 /* needed to initially set selectbox options for special action options */
7086 setSelectboxSpecialActionOptions();
7088 /* needed to initially set selectbox value variables to reliable defaults */
7089 for (i = 0; i < ED_NUM_SELECTBOX; i++)
7090 setSelectboxValue(i, *selectbox_info[i].value);
7092 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
7093 custom_element_properties[i] = HAS_PROPERTY(element, i);
7095 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
7096 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
7098 /* ---------- element settings: configure (custom elements) ------------- */
7100 /* set accessible layer selectbox help value */
7101 custom_element.access_type =
7102 (IS_WALKABLE(element) ? EP_WALKABLE :
7103 IS_PASSABLE(element) ? EP_PASSABLE :
7104 custom_element.access_type);
7105 custom_element.access_layer =
7106 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
7107 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
7108 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
7109 custom_element.access_layer);
7110 custom_element.access_protected =
7111 (IS_PROTECTED(element) ? 1 : 0);
7112 custom_element_properties[EP_ACCESSIBLE] =
7113 (IS_ACCESSIBLE_OVER(element) ||
7114 IS_ACCESSIBLE_INSIDE(element) ||
7115 IS_ACCESSIBLE_UNDER(element));
7117 /* set walk-to-object action selectbox help value */
7118 custom_element.walk_to_action =
7119 (IS_DIGGABLE(element) ? EP_DIGGABLE :
7120 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
7121 IS_DROPPABLE(element) ? EP_DROPPABLE :
7122 IS_THROWABLE(element) ? EP_THROWABLE :
7123 IS_PUSHABLE(element) ? EP_PUSHABLE :
7124 custom_element.walk_to_action);
7125 custom_element_properties[EP_WALK_TO_OBJECT] =
7126 (IS_DIGGABLE(element) ||
7127 IS_COLLECTIBLE_ONLY(element) ||
7128 IS_DROPPABLE(element) ||
7129 IS_THROWABLE(element) ||
7130 IS_PUSHABLE(element));
7132 /* set smash targets selectbox help value */
7133 custom_element.smash_targets =
7134 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
7135 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
7136 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
7137 custom_element.smash_targets);
7138 custom_element_properties[EP_CAN_SMASH] =
7139 (CAN_SMASH_EVERYTHING(element) ||
7140 CAN_SMASH_ENEMIES(element) ||
7141 CAN_SMASH_PLAYER(element));
7143 /* set deadliness selectbox help value */
7144 custom_element.deadliness =
7145 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
7146 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
7147 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
7148 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
7149 custom_element.deadliness);
7150 custom_element_properties[EP_DEADLY] =
7151 (DONT_TOUCH(element) ||
7152 DONT_GET_HIT_BY(element) ||
7153 DONT_COLLIDE_WITH(element) ||
7154 DONT_RUN_INTO(element));
7156 /* ---------- element settings: advanced (custom elements) --------------- */
7158 /* set "change by direct action" selectbox help value */
7159 custom_element_change.direct_action =
7160 (HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
7161 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
7162 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
7163 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
7164 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
7165 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
7166 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
7167 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
7168 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
7169 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
7170 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
7171 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
7172 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
7173 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
7174 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
7175 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
7176 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
7177 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
7178 custom_element_change.direct_action);
7180 /* set "change by other element action" selectbox help value */
7181 custom_element_change.other_action =
7182 (HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
7183 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
7184 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
7185 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
7186 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
7187 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
7188 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
7189 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
7190 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
7191 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
7192 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
7193 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
7194 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
7195 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
7196 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
7197 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
7198 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
7199 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
7200 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
7201 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
7202 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
7203 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
7204 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
7205 custom_element_change.other_action);
7208 static void CopyGroupElementPropertiesToEditor(int element)
7210 group_element_info = *element_info[element].group;
7211 custom_element = element_info[element]; /* needed for description */
7214 static void CopyClassicElementPropertiesToEditor(int element)
7216 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
7217 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
7218 getMoveIntoAcidProperty(&level, element);
7220 if (MAYBE_DONT_COLLIDE_WITH(element))
7221 custom_element_properties[EP_DONT_COLLIDE_WITH] =
7222 getDontCollideWithProperty(&level, element);
7225 static void CopyElementPropertiesToEditor(int element)
7227 if (IS_CUSTOM_ELEMENT(element))
7228 CopyCustomElementPropertiesToEditor(element);
7229 else if (IS_GROUP_ELEMENT(element))
7230 CopyGroupElementPropertiesToEditor(element);
7232 CopyClassicElementPropertiesToEditor(element);
7235 static void CopyCustomElementPropertiesToGame(int element)
7238 int access_type_and_layer;
7240 /* mark that this custom element has been modified */
7241 custom_element.modified_settings = TRUE;
7242 level.changed = TRUE;
7244 if (level.use_custom_template)
7246 if (Request("Copy and modify level template ?", REQ_ASK))
7248 level.use_custom_template = FALSE;
7249 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE],
7250 GDI_CHECKED, FALSE, GDI_END);
7254 LoadLevelTemplate(-1); /* this resets all element modifications ... */
7256 DrawEditModeWindow(); /* ... and copies them to 'custom_element' */
7260 element_info[element] = custom_element;
7261 *element_info[element].change = custom_element_change;
7263 /* ---------- element settings: configure (custom elements) ------------- */
7265 /* set accessible property from checkbox and selectbox */
7266 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
7267 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
7268 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
7269 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
7270 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
7271 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
7272 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
7273 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
7274 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
7275 custom_element_properties[access_type_and_layer] =
7276 custom_element_properties[EP_ACCESSIBLE];
7277 custom_element_properties[EP_PROTECTED] =
7278 (custom_element.access_protected != 0 &&
7279 custom_element_properties[EP_ACCESSIBLE]);
7281 /* set walk-to-object property from checkbox and selectbox */
7282 custom_element_properties[EP_DIGGABLE] = FALSE;
7283 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
7284 custom_element_properties[EP_DROPPABLE] = FALSE;
7285 custom_element_properties[EP_THROWABLE] = FALSE;
7286 custom_element_properties[EP_PUSHABLE] = FALSE;
7287 custom_element_properties[custom_element.walk_to_action] =
7288 custom_element_properties[EP_WALK_TO_OBJECT];
7290 /* set smash property from checkbox and selectbox */
7291 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
7292 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
7293 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
7294 custom_element_properties[custom_element.smash_targets] =
7295 custom_element_properties[EP_CAN_SMASH];
7297 /* set deadliness property from checkbox and selectbox */
7298 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
7299 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
7300 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
7301 custom_element_properties[EP_DONT_TOUCH] = FALSE;
7302 custom_element_properties[custom_element.deadliness] =
7303 custom_element_properties[EP_DEADLY];
7305 /* ---------- element settings: advanced (custom elements) --------------- */
7307 /* set player change event from checkbox and selectbox */
7308 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
7309 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
7310 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
7311 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
7312 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
7313 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
7314 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
7315 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
7316 custom_element_change_events[CE_SWITCHED] = FALSE;
7317 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
7318 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
7319 custom_element_change_events[CE_BLOCKED] = FALSE;
7320 custom_element_change_events[CE_IMPACT] = FALSE;
7321 custom_element_change_events[CE_SMASHED] = FALSE;
7322 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
7323 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
7324 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
7325 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
7326 custom_element_change_events[custom_element_change.direct_action] =
7327 custom_element_change_events[CE_BY_DIRECT_ACTION];
7329 /* set other element action change event from checkbox and selectbox */
7330 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
7331 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
7332 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
7333 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
7334 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
7335 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
7336 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
7337 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
7338 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
7339 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
7340 custom_element_change_events[CE_TOUCHING_X] = FALSE;
7341 custom_element_change_events[CE_HITTING_X] = FALSE;
7342 custom_element_change_events[CE_DIGGING_X] = FALSE;
7343 custom_element_change_events[CE_HIT_BY_X] = FALSE;
7344 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
7345 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
7346 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
7347 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
7348 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
7349 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
7350 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
7351 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
7352 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
7353 custom_element_change_events[custom_element_change.other_action] =
7354 custom_element_change_events[CE_BY_OTHER_ACTION];
7356 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
7357 SET_PROPERTY(element, i, custom_element_properties[i]);
7359 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
7360 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
7362 /* copy change events also to special level editor variable */
7363 custom_element = element_info[element];
7364 custom_element_change = *element_info[element].change;
7367 static void CopyGroupElementPropertiesToGame(int element)
7369 element_info[element] = custom_element;
7370 *element_info[element].group = group_element_info;
7372 /* mark that this group element has been modified */
7373 element_info[element].modified_settings = TRUE;
7374 level.changed = TRUE;
7377 static void CopyClassicElementPropertiesToGame(int element)
7379 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
7380 setMoveIntoAcidProperty(&level, element,
7381 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
7383 if (MAYBE_DONT_COLLIDE_WITH(element))
7384 setDontCollideWithProperty(&level, element,
7385 custom_element_properties[EP_DONT_COLLIDE_WITH]);
7388 static void CopyElementPropertiesToGame(int element)
7390 if (IS_CUSTOM_ELEMENT(element))
7391 CopyCustomElementPropertiesToGame(element);
7392 else if (IS_GROUP_ELEMENT(element))
7393 CopyGroupElementPropertiesToGame(element);
7395 CopyClassicElementPropertiesToGame(element);
7398 void CheckElementDescriptions()
7402 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
7403 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
7404 Error(ERR_WARN, "no element description for element '%s'", EL_NAME(i));
7411 CloseDoor(DOOR_CLOSE_ALL);
7414 FadeOut(REDRAW_FIELD);
7418 /* needed if different viewport properties defined for editor */
7419 ChangeViewportPropertiesIfNeeded();
7422 OpenDoor(DOOR_OPEN_2 | DOOR_NO_DELAY);
7425 CheckElementDescriptions();
7428 if (level_editor_test_game)
7430 CopyPlayfield(level.field, Feld);
7431 CopyPlayfield(FieldBackup, level.field);
7433 level_editor_test_game = FALSE;
7437 edit_mode = ED_MODE_DRAWING;
7438 edit_mode_levelinfo = ED_MODE_LEVELINFO_LEVEL;
7439 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
7447 /* copy default editor door content to main double buffer */
7448 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
7449 DOOR_GFX_PAGEX6, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
7452 printf("::: %d, %d / %d, %d\n", VX, VY, EX, EY);
7455 /* draw bigger door */
7456 DrawSpecialEditorDoor();
7458 /* draw new control window */
7459 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
7460 DOOR_GFX_PAGEX8, 236, EXSIZE, EYSIZE, EX, EY);
7462 redraw_mask |= REDRAW_ALL;
7465 FreeLevelEditorGadgets();
7466 CreateLevelEditorGadgets();
7469 ReinitializeElementList(); /* update dynamic level element list */
7470 ReinitializeElementListButtons(); /* custom element may look different */
7472 InitElementPropertiesGfxElement();
7479 MapControlButtons();
7482 FadeOut(REDRAW_FIELD);
7485 DrawEditModeWindow();
7488 FadeIn(REDRAW_FIELD);
7491 /* copy actual editor door content to door double buffer for OpenDoor() */
7492 BlitBitmap(drawto, bitmap_db_door,
7493 DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
7496 /* draw new control window (with border) to window */
7497 redraw_mask |= REDRAW_ALL;
7501 OpenDoor(DOOR_OPEN_1);
7504 static void AdjustDrawingAreaGadgets()
7506 int ed_xsize = lev_fieldx + 2;
7507 int ed_ysize = lev_fieldy + 2;
7508 int max_ed_fieldx = MAX_ED_FIELDX;
7509 int max_ed_fieldy = MAX_ED_FIELDY;
7510 boolean horizontal_scrollbar_needed;
7511 boolean vertical_scrollbar_needed;
7512 int x, y, width, height;
7513 int xoffset, yoffset;
7515 /* check if we need any scrollbars */
7516 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
7517 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
7519 /* check if we have a smaller editor field because of scrollbars */
7520 if (horizontal_scrollbar_needed)
7521 max_ed_fieldy = MAX_ED_FIELDY - 1;
7522 if (vertical_scrollbar_needed)
7523 max_ed_fieldx = MAX_ED_FIELDX - 1;
7525 /* check again if we now need more scrollbars because of less space */
7526 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
7527 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
7529 /* check if editor field gets even smaller after adding new scrollbars */
7530 if (horizontal_scrollbar_needed)
7531 max_ed_fieldy = MAX_ED_FIELDY - 1;
7532 if (vertical_scrollbar_needed)
7533 max_ed_fieldx = MAX_ED_FIELDX - 1;
7535 ed_fieldx = (ed_xsize < MAX_ED_FIELDX ? ed_xsize : max_ed_fieldx);
7536 ed_fieldy = (ed_ysize < MAX_ED_FIELDY ? ed_ysize : max_ed_fieldy);
7538 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
7539 GDI_WIDTH, ed_fieldx * MINI_TILEX,
7540 GDI_HEIGHT, ed_fieldy * MINI_TILEY,
7541 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
7544 xoffset = (ed_fieldx == MAX_ED_FIELDX ? ED_SCROLLBUTTON_XSIZE : 0);
7545 yoffset = (ed_fieldy == MAX_ED_FIELDY ? ED_SCROLLBUTTON_YSIZE : 0);
7547 x = SX + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_RIGHT].x + xoffset;
7548 y = SX + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_DOWN].y + yoffset;
7550 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT], GDI_X, x, GDI_END);
7551 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN], GDI_Y, y, GDI_END);
7553 width = scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width + xoffset;
7554 height = scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].height + yoffset;
7556 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
7558 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
7560 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
7562 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
7566 static void AdjustLevelScrollPosition()
7568 if (level_xpos < -1)
7570 if (level_xpos > lev_fieldx - ed_fieldx + 1)
7571 level_xpos = lev_fieldx - ed_fieldx + 1;
7572 if (lev_fieldx < ed_fieldx - 2)
7575 if (level_ypos < -1)
7577 if (level_ypos > lev_fieldy - ed_fieldy + 1)
7578 level_ypos = lev_fieldy - ed_fieldy + 1;
7579 if (lev_fieldy < ed_fieldy - 2)
7583 static void AdjustEditorScrollbar(int id)
7585 struct GadgetInfo *gi = level_editor_gadget[id];
7586 int items_max, items_visible, item_position;
7588 if (id == GADGET_ID_SCROLL_HORIZONTAL)
7590 items_max = MAX(lev_fieldx + 2, ed_fieldx);
7591 items_visible = ed_fieldx;
7592 item_position = level_xpos + 1;
7596 items_max = MAX(lev_fieldy + 2, ed_fieldy);
7597 items_visible = ed_fieldy;
7598 item_position = level_ypos + 1;
7601 if (item_position > items_max - items_visible)
7602 item_position = items_max - items_visible;
7604 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
7605 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
7608 static void AdjustElementListScrollbar()
7610 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
7611 int items_max, items_visible, item_position;
7613 /* correct position of element list scrollbar */
7614 if (element_shift < 0)
7616 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
7617 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
7619 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
7620 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
7621 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
7623 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
7624 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7625 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
7628 static void ModifyEditorCounterValue(int counter_id, int new_value)
7630 int *counter_value = counterbutton_info[counter_id].value;
7631 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
7632 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7634 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
7636 if (counter_value != NULL)
7637 *counter_value = gi->textinput.number_value;
7640 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
7642 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
7643 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7645 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
7647 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
7648 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
7650 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
7651 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
7653 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
7654 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_DISTANCE,GDI_END);
7658 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
7660 int gadget_id = selectbox_info[selectbox_id].gadget_id;
7661 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7662 int new_index_value = setSelectboxValue(selectbox_id, new_value);
7664 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
7667 static void ModifyEditorSelectboxOptions(int selectbox_id,
7668 struct ValueTextInfo *options)
7670 int gadget_id = selectbox_info[selectbox_id].gadget_id;
7671 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7673 selectbox_info[selectbox_id].options = options;
7675 /* set index to zero -- list may be shorter now (correct later, if needed) */
7676 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
7677 GDI_SELECTBOX_OPTIONS, options, GDI_END);
7680 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
7682 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
7683 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7685 drawingarea_info[drawingarea_id].area_xsize = xsize;
7686 drawingarea_info[drawingarea_id].area_ysize = ysize;
7688 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
7691 static void ModifyEditorElementList()
7695 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7697 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
7698 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7699 struct GadgetDesign *gd = &gi->deco.design;
7700 int element = editor_elements[element_shift + i];
7704 getMiniGraphicSource(el2edimg(element), &gd->bitmap, &gd->x, &gd->y);
7705 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
7711 static void PickDrawingElement(int button, int element)
7713 if (button < 1 || button > 3)
7718 new_element1 = element;
7719 DrawMiniGraphicExt(drawto,
7720 DX + ED_WIN_MB_LEFT_XPOS, DY + ED_WIN_MB_LEFT_YPOS,
7721 el2edimg(new_element1));
7723 else if (button == 2)
7725 new_element2 = element;
7726 DrawMiniGraphicExt(drawto,
7727 DX + ED_WIN_MB_MIDDLE_XPOS, DY + ED_WIN_MB_MIDDLE_YPOS,
7728 el2edimg(new_element2));
7732 new_element3 = element;
7733 DrawMiniGraphicExt(drawto,
7734 DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS,
7735 el2edimg(new_element3));
7738 redraw_mask |= REDRAW_DOOR_1;
7741 static void RedrawDrawingElements()
7743 PickDrawingElement(1, new_element1);
7744 PickDrawingElement(2, new_element2);
7745 PickDrawingElement(3, new_element3);
7748 static void DrawDrawingWindow()
7750 stick_element_properties_window = FALSE;
7752 SetMainBackgroundImage(IMG_UNDEFINED);
7755 UnmapLevelEditorWindowGadgets();
7756 UnmapLevelEditorToolboxCustomGadgets();
7758 AdjustDrawingAreaGadgets();
7759 AdjustLevelScrollPosition();
7760 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
7761 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
7763 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7765 MapMainDrawingArea();
7766 MapLevelEditorToolboxDrawingGadgets();
7769 static int getTabulatorBarWidth()
7771 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
7772 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
7774 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
7777 static void DrawLevelInfoTabulatorGadgets()
7779 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELINFO_LEVEL];
7780 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
7781 int gd_x = gd->x + gd_gi1->border.width / 2;
7782 int gd_y = gd->y + gd_gi1->height - 1;
7783 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
7784 int id_first = ED_TEXTBUTTON_ID_LEVELINFO_LEVEL;
7785 int id_last = ED_TEXTBUTTON_ID_LEVELINFO_EDITOR;
7792 for (i = id_first; i <= id_last; i++)
7794 int gadget_id = textbutton_info[i].gadget_id;
7795 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7796 boolean active = (i != edit_mode_levelinfo);
7798 /* draw background line below tabulator button */
7799 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
7801 /* draw solid line below inactive tabulator buttons */
7802 if (!active && tab_color != BLACK_PIXEL) /* black => transparent */
7803 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width, 1, tab_color);
7805 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
7806 MapTextbuttonGadget(i);
7810 /* draw little border line below tabulator buttons */
7811 if (tab_color != BLACK_PIXEL) /* black => transparent */
7812 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height + 1,
7813 getTabulatorBarWidth(), ED_GADGET_DISTANCE,
7816 /* draw little border line below tabulator buttons */
7817 if (tab_color != BLACK_PIXEL) /* black => transparent */
7818 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height + 1,
7819 max_tabs * gd_gi1->width + (max_tabs -1) * ED_GADGET_DISTANCE,
7820 ED_GADGET_DISTANCE, tab_color);
7824 static void DrawPropertiesTabulatorGadgets()
7826 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
7827 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
7828 int gd_x = gd->x + gd_gi1->border.width / 2;
7829 int gd_y = gd->y + gd_gi1->height - 1;
7830 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
7831 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
7832 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
7839 /* draw two config tabulators for player elements */
7840 if (ELEM_IS_PLAYER(properties_element))
7841 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
7843 /* draw two config and one "change" tabulator for custom elements */
7844 if (IS_CUSTOM_ELEMENT(properties_element))
7845 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
7847 for (i = id_first; i <= id_last; i++)
7849 int gadget_id = textbutton_info[i].gadget_id;
7850 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7851 boolean active = (i != edit_mode_properties);
7853 /* use "config 1" and "config 2" instead of "config" for players and CEs */
7854 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
7855 (ELEM_IS_PLAYER(properties_element) ||
7856 IS_CUSTOM_ELEMENT(properties_element)))
7859 /* draw background line below tabulator button */
7860 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
7862 /* draw solid line below inactive tabulator buttons */
7863 if (!active && tab_color != BLACK_PIXEL) /* black => transparent */
7864 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width, 1, tab_color);
7866 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
7867 MapTextbuttonGadget(i);
7871 /* draw little border line below tabulator buttons */
7872 if (tab_color != BLACK_PIXEL) /* black => transparent */
7873 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height + 1,
7874 getTabulatorBarWidth(), ED_GADGET_DISTANCE,
7877 /* draw little border line below tabulator buttons */
7878 if (tab_color != BLACK_PIXEL) /* black => transparent */
7879 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height + 1,
7880 max_tabs * gd_gi1->width + (max_tabs -1) * ED_GADGET_DISTANCE,
7881 ED_GADGET_DISTANCE, tab_color);
7885 static void DrawLevelInfoLevel()
7889 /* draw counter gadgets */
7890 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
7891 MapCounterButtons(i);
7893 /* draw selectbox gadgets */
7894 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
7895 MapSelectboxGadget(i);
7897 /* draw text input gadgets */
7898 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
7899 MapTextInputGadget(i);
7902 static void DrawLevelInfoEditor()
7906 /* draw counter gadgets */
7907 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
7908 MapCounterButtons(i);
7910 /* draw checkbutton gadgets */
7911 for (i=ED_CHECKBUTTON_ID_EDITOR_FIRST; i<= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
7912 MapCheckbuttonGadget(i);
7914 /* draw radiobutton gadgets */
7915 for (i=ED_RADIOBUTTON_ID_EDITOR_FIRST; i<= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
7916 MapRadiobuttonGadget(i);
7918 /* draw drawing area */
7919 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
7922 static void DrawLevelInfoWindow()
7924 stick_element_properties_window = FALSE;
7926 UnmapLevelEditorWindowGadgets();
7928 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
7933 DrawTextSCentered(ED_SETTINGS1_YPOS, FONT_TITLE_1, "Global Settings");
7935 DrawTextSCentered(ED_SETTINGS1_YPOS, FONT_TITLE_1, "Level Settings");
7936 DrawTextSCentered(ED_SETTINGS2_YPOS, FONT_TITLE_1, "Editor Settings");
7939 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS1_YPOS,
7940 "Level Settings", FONT_TITLE_1);
7941 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS2_YPOS,
7942 "Editor Settings", FONT_TITLE_1);
7945 DrawLevelInfoTabulatorGadgets();
7947 if (edit_mode_levelinfo == ED_MODE_LEVELINFO_LEVEL)
7948 DrawLevelInfoLevel();
7949 else /* (edit_mode_levelinfo == ED_MODE_LEVELINFO_EDITOR) */
7950 DrawLevelInfoEditor();
7953 static void DrawCustomContentArea()
7955 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
7956 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
7957 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
7958 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
7959 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
7960 int xoffset = ED_DRAWINGAREA_TEXT_DISTANCE;
7962 /* add distance for potential left text (without drawing area border) */
7963 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
7965 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
7967 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
7970 static void DrawCustomChangeContentArea()
7972 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
7973 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
7974 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
7975 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
7976 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
7977 int xoffset = ED_DRAWINGAREA_TEXT_DISTANCE;
7979 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
7984 static void DrawYamYamContentAreas()
7986 int x = SX + ED_AREA_YAMYAM_CONTENT_XPOS(3) + 4 * MINI_TILEX;
7987 int y = SY + ED_AREA_YAMYAM_CONTENT_YPOS(0) + ED_BORDER_AREA_YSIZE;
7990 /* display counter to choose number of element content areas */
7991 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
7993 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
7995 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
7997 if (i < level.num_yamyam_contents)
8003 int font_height = getFontHeight(FONT_TEXT_1);
8005 UnmapDrawingArea(id);
8007 /* delete content areas in case of reducing number of them */
8008 DrawBackground(SX + drawingarea_info[id].x - MINI_TILEX / 2,
8009 SY + drawingarea_info[id].y - MINI_TILEY / 2,
8011 4 * MINI_TILEY + ED_GADGET_TEXT_DISTANCE + font_height);
8015 DrawText(x, y + 0 * MINI_TILEY, "content", FONT_TEXT_1);
8016 DrawText(x, y + 1 * MINI_TILEY, "when", FONT_TEXT_1);
8017 DrawText(x, y + 2 * MINI_TILEY, "smashed", FONT_TEXT_1);
8020 static void DrawMagicBallContentAreas()
8022 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_XPOS(3) + 4 * MINI_TILEX;
8023 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_YPOS(0) + ED_BORDER_AREA_YSIZE;
8026 /* display counter to choose number of element content areas */
8027 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
8029 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
8031 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
8033 if (i < level.num_ball_contents)
8039 int font_height = getFontHeight(FONT_TEXT_1);
8041 UnmapDrawingArea(id);
8043 /* delete content areas in case of reducing number of them */
8044 DrawBackground(SX + drawingarea_info[id].x - MINI_TILEX / 2,
8045 SY + drawingarea_info[id].y - MINI_TILEY / 2,
8047 4 * MINI_TILEY + ED_GADGET_TEXT_DISTANCE + font_height);
8051 DrawText(x, y + 0 * MINI_TILEY, "generated", FONT_TEXT_1);
8052 DrawText(x, y + 1 * MINI_TILEY, "when", FONT_TEXT_1);
8053 DrawText(x, y + 2 * MINI_TILEY, "active", FONT_TEXT_1);
8056 static void DrawAndroidElementArea(int element)
8058 int num_elements = level.num_android_clone_elements;
8059 int id = ED_DRAWING_ID_ANDROID_CONTENT;
8060 int sx = SX + drawingarea_info[id].x - MINI_TILEX / 2;
8061 int sy = SY + drawingarea_info[id].y - MINI_TILEY / 2;
8062 int xsize = MAX_ANDROID_ELEMENTS;
8065 /* display counter to choose number of element areas */
8066 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
8068 if (drawingarea_info[id].text_left != NULL)
8069 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
8071 UnmapDrawingArea(id);
8073 ModifyEditorDrawingArea(id, num_elements, 1);
8075 /* delete content areas in case of reducing number of them */
8076 DrawBackground(sx, sy, (xsize + 1) * MINI_TILEX, (ysize + 1) * MINI_TILEY);
8081 static void DrawGroupElementArea(int element)
8083 int num_elements = group_element_info.num_elements;
8084 int id = ED_DRAWING_ID_GROUP_CONTENT;
8085 int sx = SX + drawingarea_info[id].x - MINI_TILEX / 2;
8086 int sy = SY + drawingarea_info[id].y - MINI_TILEY / 2;
8087 int xsize = MAX_ELEMENTS_IN_GROUP;
8090 if (drawingarea_info[id].text_left != NULL)
8091 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
8093 UnmapDrawingArea(id);
8095 ModifyEditorDrawingArea(id, num_elements, 1);
8097 /* delete content areas in case of reducing number of them */
8098 DrawBackground(sx, sy, (xsize + 1) * MINI_TILEX, (ysize + 1) * MINI_TILEY);
8103 static void DrawPlayerInitialInventoryArea(int element)
8105 int player_nr = GET_PLAYER_NR(element);
8106 int num_elements = level.initial_inventory_size[player_nr];
8107 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
8108 int sx = SX + drawingarea_info[id].x - MINI_TILEX / 2;
8109 int sy = SY + drawingarea_info[id].y - MINI_TILEY / 2;
8110 int xsize = MAX_INITIAL_INVENTORY_SIZE;
8113 /* determine horizontal position to the right of specified gadget */
8114 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
8115 sx += (right_gadget_border[drawingarea_info[id].gadget_id_align] +
8116 ED_DRAWINGAREA_TEXT_DISTANCE);
8118 /* determine horizontal offset for leading text */
8119 if (drawingarea_info[id].text_left != NULL)
8120 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
8122 UnmapDrawingArea(id);
8124 ModifyEditorDrawingArea(id, num_elements, 1);
8126 /* delete content areas in case of reducing number of them */
8127 DrawBackground(sx, sy, (xsize + 1) * MINI_TILEX, (ysize + 1) * MINI_TILEY);
8132 static void DrawEnvelopeTextArea(int envelope_nr)
8134 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
8135 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
8138 DrawBackground(gi->x, gi->y, gi->width, gi->height);
8140 if (envelope_nr != -1)
8141 textarea_info[id].value = level.envelope[envelope_nr].text;
8143 ModifyGadget(gi, GDI_AREA_SIZE,
8144 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
8145 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
8148 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
8151 static boolean PrintInfoText(char *text, int font_nr, int start_line)
8153 int font_height = getFontHeight(font_nr);
8154 int pad_x = ED_ELEMENT_SETTINGS_XPOS(0);
8155 int pad_y = ED_ELEMENT_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
8156 int sx = SX + pad_x;
8157 int sy = SY + pad_y;
8158 int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
8160 if (start_line >= max_lines_per_screen)
8163 DrawText(sx, sy + start_line * font_height, text, font_nr);
8168 static int PrintElementDescriptionFromFile(char *filename, int start_line)
8170 int font_nr = FONT_TEXT_2;
8171 int font_width = getFontWidth(font_nr);
8172 int font_height = getFontHeight(font_nr);
8173 int pad_x = ED_ELEMENT_SETTINGS_XPOS(0);
8174 int pad_y = ED_ELEMENT_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
8175 int sx = SX + pad_x;
8176 int sy = SY + pad_y + start_line * font_height;
8177 int max_chars_per_line = (SXSIZE - 2 * pad_x) / font_width;
8178 int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
8180 return DrawTextFile(sx, sy, filename, font_nr, max_chars_per_line, -1,
8181 max_lines_per_screen, 0, -1, TRUE, FALSE, FALSE);
8184 static void DrawPropertiesInfo()
8193 /* configurable properties */
8195 { EP_WALKABLE_OVER, "- player can walk over it" },
8196 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
8197 { EP_WALKABLE_UNDER, "- player can walk under it" },
8198 { EP_PASSABLE_OVER, "- player can pass over it" },
8199 { EP_PASSABLE_INSIDE, "- player can pass through it" },
8200 { EP_PASSABLE_UNDER, "- player can pass under it" },
8201 { EP_PROTECTED, "- player is protected by it" },
8203 { EP_DIGGABLE, "- can be digged away" },
8204 { EP_COLLECTIBLE, "- can be collected" },
8205 { EP_DROPPABLE, "- can be dropped after collecting" },
8206 { EP_THROWABLE, "- can be thrown after collecting" },
8207 { EP_PUSHABLE, "- can be pushed" },
8209 { EP_CAN_FALL, "- can fall" },
8210 { EP_CAN_MOVE, "- can move" },
8212 { EP_CAN_SMASH_PLAYER, "- can smash player" },
8214 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
8216 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
8218 { EP_SLIPPERY, "- slippery for falling elements" },
8219 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
8221 { EP_DONT_RUN_INTO, "- deadly when running into" },
8222 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
8223 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
8224 { EP_DONT_TOUCH, "- deadly when touching" },
8226 { EP_INDESTRUCTIBLE, "- indestructible" },
8228 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
8229 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
8230 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
8232 { EP_CAN_CHANGE, "- can change to other element" },
8234 /* pre-defined properties */
8235 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
8236 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
8237 { EP_SWITCHABLE, "- can be switched" },
8239 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
8244 char *filename = getElementDescriptionFilename(properties_element);
8245 char *percentage_text = "In this level:";
8246 char *properties_text = "Standard properties:";
8248 int num_elements_in_level;
8249 int num_standard_properties = 0;
8250 int font1_nr = FONT_TEXT_1;
8251 int font2_nr = FONT_TEXT_2;
8252 int font1_width = getFontWidth(font1_nr);
8253 int font2_height = getFontHeight(font2_nr);
8254 int pad_x = ED_ELEMENT_SETTINGS_XPOS(0);
8255 int pad_y = ED_ELEMENT_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
8256 int screen_line = 0;
8259 if (setup.editor.show_element_token)
8261 DrawTextF(pad_x, pad_y + screen_line++ * font2_height, FONT_TEXT_3,
8262 "[%s]", element_info[properties_element].token_name);
8266 /* ----- print number of elements / percentage of this element in level */
8268 num_elements_in_level = 0;
8269 for (y = 0; y < lev_fieldy; y++)
8270 for (x = 0; x < lev_fieldx; x++)
8271 if (Feld[x][y] == properties_element)
8272 num_elements_in_level++;
8273 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
8275 DrawTextS(pad_x, pad_y + screen_line * font2_height, font1_nr,
8277 DrawTextF(pad_x + strlen(percentage_text) * font1_width,
8278 pad_y + screen_line++ * font2_height, font2_nr,
8279 "%d (%.2f%%)", num_elements_in_level, percentage);
8283 /* ----- print standard properties of this element */
8285 DrawTextS(pad_x, pad_y + screen_line++ * font2_height, font1_nr,
8288 for (i = 0; properties[i].value != -1; i++)
8290 if (!HAS_PROPERTY(properties_element, properties[i].value))
8293 DrawTextS(pad_x, pad_y + screen_line++ * font2_height, font2_nr,
8294 properties[i].text);
8295 num_standard_properties++;
8298 if (num_standard_properties == 0)
8299 DrawTextS(pad_x + strlen(properties_text) * font1_width,
8300 pad_y + (screen_line - 1) * font2_height, font2_nr, "none");
8304 /* ----- print special description of this element */
8306 PrintInfoText("Description:", FONT_TEXT_1, screen_line);
8307 if (PrintElementDescriptionFromFile(filename, screen_line + 1) == 0)
8308 PrintInfoText("No description available.", FONT_TEXT_1, screen_line);
8311 #define TEXT_COLLECTING "Score for collecting"
8312 #define TEXT_SMASHING "Score for smashing"
8313 #define TEXT_SLURPING "Score for slurping robot"
8314 #define TEXT_CRACKING "Score for cracking"
8315 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
8316 #define TEXT_DURATION "Duration when activated"
8317 #define TEXT_BALL_DELAY "Element generation delay"
8318 #define TEXT_MOVE_SPEED "Speed of android moving"
8319 #define TEXT_CLONE_SPEED "Speed of android cloning"
8320 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
8321 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
8322 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
8323 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
8324 #define TEXT_TIME_BONUS "Extra time to solve level"
8331 } elements_with_counter[] =
8333 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
8334 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
8335 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
8336 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
8337 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
8338 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
8339 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
8340 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
8341 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
8342 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
8343 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
8344 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
8345 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
8346 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
8347 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
8348 { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
8349 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
8350 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
8351 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
8352 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
8353 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8354 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8355 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8356 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8357 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8358 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8359 { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
8360 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8361 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8362 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8363 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8364 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
8365 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
8366 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
8367 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
8368 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
8369 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
8370 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
8371 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
8372 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
8373 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
8374 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
8375 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
8376 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
8377 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
8378 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
8379 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE],TEXT_COLLECTING },
8380 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
8381 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
8382 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
8383 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
8384 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
8385 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
8386 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
8387 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
8388 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
8389 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
8390 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
8391 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
8392 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
8393 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
8394 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
8395 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
8396 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
8397 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
8398 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
8399 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
8400 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
8401 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
8402 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
8403 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
8404 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
8405 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
8406 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
8408 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
8409 { EL_DC_TIMEGATE_SWITCH,&level.time_timegate, TEXT_DURATION },
8410 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
8411 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
8412 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
8413 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
8414 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
8415 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
8416 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
8417 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
8418 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
8419 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
8420 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
8421 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
8422 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
8423 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
8425 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
8426 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
8427 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
8428 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
8429 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
8430 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
8431 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
8432 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
8437 static boolean checkPropertiesConfig(int element)
8441 if (IS_GEM(element) ||
8442 IS_CUSTOM_ELEMENT(element) ||
8443 IS_GROUP_ELEMENT(element) ||
8444 IS_ENVELOPE(element) ||
8445 ELEM_IS_PLAYER(element) ||
8446 HAS_EDITOR_CONTENT(element) ||
8447 CAN_GROW(element) ||
8448 COULD_MOVE_INTO_ACID(element) ||
8449 MAYBE_DONT_COLLIDE_WITH(element) ||
8450 element == EL_SOKOBAN_OBJECT ||
8451 element == EL_SOKOBAN_FIELD_EMPTY ||
8452 element == EL_SOKOBAN_FIELD_FULL)
8455 for (i = 0; elements_with_counter[i].element != -1; i++)
8456 if (elements_with_counter[i].element == element)
8462 static void DrawPropertiesConfig()
8464 int max_num_element_counters = 4;
8465 int num_element_counters = 0;
8468 if (!checkPropertiesConfig(properties_element))
8470 PrintInfoText("No configuration options available.", FONT_TEXT_1, 0);
8475 /* check if there are elements where a value can be chosen for */
8476 for (i = 0; elements_with_counter[i].element != -1; i++)
8478 if (elements_with_counter[i].element == properties_element)
8480 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
8482 counterbutton_info[counter_id].y =
8483 ED_ELEMENT_SETTINGS_YPOS(
8484 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
8485 (CAN_GROW(properties_element) ? 1 : 0) +
8486 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
8487 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
8488 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
8489 num_element_counters);
8491 counterbutton_info[counter_id].value = elements_with_counter[i].value;
8492 counterbutton_info[counter_id].text_right= elements_with_counter[i].text;
8494 if (properties_element == EL_GAME_OF_LIFE ||
8495 properties_element == EL_BIOMAZE)
8497 counterbutton_info[counter_id].min_value = 0; /* min neighbours */
8498 counterbutton_info[counter_id].max_value = 8; /* max neighbours */
8502 /* !!! CHANGE THIS FOR CERTAIN ELEMENTS !!! */
8503 counterbutton_info[counter_id].min_value = MIN_SCORE;
8504 counterbutton_info[counter_id].max_value = MAX_SCORE;
8507 MapCounterButtons(counter_id);
8509 num_element_counters++;
8510 if (num_element_counters >= max_num_element_counters)
8515 if (HAS_EDITOR_CONTENT(properties_element))
8517 /* draw stickybutton gadget */
8518 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
8520 if (IS_AMOEBOID(properties_element))
8521 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
8522 else if (properties_element == EL_YAMYAM ||
8523 properties_element == EL_YAMYAM_LEFT ||
8524 properties_element == EL_YAMYAM_RIGHT ||
8525 properties_element == EL_YAMYAM_UP ||
8526 properties_element == EL_YAMYAM_DOWN)
8527 DrawYamYamContentAreas();
8528 else if (properties_element == EL_EMC_MAGIC_BALL)
8530 DrawMagicBallContentAreas();
8532 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
8533 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_STATE);
8535 else if (properties_element == EL_EMC_ANDROID)
8536 DrawAndroidElementArea(properties_element);
8539 if (ELEM_IS_PLAYER(properties_element))
8541 int player_nr = GET_PLAYER_NR(properties_element);
8543 /* these properties can be set for every player individually */
8545 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
8547 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
8548 &level.start_element[player_nr];
8549 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
8550 &level.artwork_element[player_nr];
8551 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
8552 &level.explosion_element[player_nr];
8554 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
8555 &level.use_start_element[player_nr];
8556 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
8557 &level.use_artwork_element[player_nr];
8558 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
8559 &level.use_explosion_element[player_nr];
8560 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
8561 &level.initial_player_gravity[player_nr];
8563 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
8564 &level.initial_player_stepsize[player_nr];
8566 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
8567 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
8568 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
8569 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
8570 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
8571 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
8572 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
8573 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
8574 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
8575 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
8576 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
8577 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
8578 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
8580 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
8581 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
8582 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
8584 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
8586 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
8588 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
8589 &level.initial_inventory_content[player_nr][0];
8591 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
8592 &level.initial_inventory_size[player_nr];
8594 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
8595 &level.use_initial_inventory[player_nr];
8597 /* draw checkbutton gadgets */
8598 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
8600 /* draw counter gadgets */
8601 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
8603 /* draw drawing area gadgets */
8604 DrawPlayerInitialInventoryArea(properties_element);
8608 if (IS_GEM(properties_element))
8609 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
8611 if (properties_element == EL_EM_DYNAMITE)
8612 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
8614 if (COULD_MOVE_INTO_ACID(properties_element) &&
8615 !ELEM_IS_PLAYER(properties_element) &&
8616 (!IS_CUSTOM_ELEMENT(properties_element) ||
8617 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
8619 /* set position for checkbutton for "can move into acid" */
8620 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
8621 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
8622 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
8623 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 6 :
8624 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
8626 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
8629 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
8630 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
8632 if (properties_element == EL_SPRING)
8633 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
8635 if (properties_element == EL_TIME_ORB_FULL)
8636 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
8638 if (CAN_GROW(properties_element))
8640 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
8641 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
8643 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
8646 if (properties_element == EL_SOKOBAN_OBJECT ||
8647 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
8648 properties_element == EL_SOKOBAN_FIELD_FULL)
8649 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
8651 if (IS_ENVELOPE(properties_element))
8653 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
8654 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
8655 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
8656 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
8657 int envelope_nr = properties_element - EL_ENVELOPE_1;
8659 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
8660 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
8662 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
8663 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
8665 /* display counter to choose size of envelope text area */
8666 MapCounterButtons(counter1_id);
8667 MapCounterButtons(counter2_id);
8669 /* display checkbuttons to choose auto-wrap and alignment properties */
8670 MapCheckbuttonGadget(button1_id);
8671 MapCheckbuttonGadget(button2_id);
8673 DrawEnvelopeTextArea(envelope_nr);
8676 if (IS_CUSTOM_ELEMENT(properties_element))
8678 /* draw stickybutton gadget */
8679 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
8681 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
8683 /* draw checkbutton gadgets */
8684 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
8685 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
8686 MapCheckbuttonGadget(i);
8688 /* draw counter gadgets */
8689 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
8690 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
8691 MapCounterButtons(i);
8693 /* draw selectbox gadgets */
8694 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
8695 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
8696 MapSelectboxGadget(i);
8698 /* draw textbutton gadgets */
8699 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE);
8701 /* draw text input gadgets */
8702 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
8704 /* draw drawing area gadgets */
8705 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
8707 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
8709 /* draw checkbutton gadgets */
8710 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
8711 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
8712 MapCheckbuttonGadget(i);
8714 /* draw counter gadgets */
8715 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
8716 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
8717 MapCounterButtons(i);
8719 /* draw selectbox gadgets */
8720 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
8721 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
8722 MapSelectboxGadget(i);
8724 /* draw drawing area gadgets */
8725 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
8726 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
8727 DrawCustomContentArea();
8730 else if (IS_GROUP_ELEMENT(properties_element))
8732 /* draw stickybutton gadget */
8733 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
8735 /* draw checkbutton gadgets */
8736 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
8737 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE);
8739 /* draw counter gadgets */
8740 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
8742 /* draw selectbox gadgets */
8743 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
8745 /* draw textbutton gadgets */
8746 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE);
8748 /* draw drawing area gadgets */
8749 DrawGroupElementArea(properties_element);
8751 /* draw text input gadgets */
8752 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
8754 /* draw drawing area gadgets */
8755 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
8759 static void DrawPropertiesChangeDrawingAreas()
8761 if (IS_CUSTOM_ELEMENT(properties_element))
8763 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
8764 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
8765 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
8767 DrawCustomChangeContentArea();
8770 redraw_mask |= REDRAW_FIELD;
8773 static void DrawPropertiesChange()
8777 /* needed to initially set selectbox options for special action options */
8778 setSelectboxSpecialActionOptions();
8780 /* draw stickybutton gadget */
8781 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
8783 /* draw checkbutton gadgets */
8784 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
8785 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
8786 MapCheckbuttonGadget(i);
8788 /* draw counter gadgets */
8789 for (i = ED_COUNTER_ID_CHANGE_FIRST;
8790 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
8791 MapCounterButtons(i);
8793 /* draw selectbox gadgets */
8794 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
8795 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
8796 MapSelectboxGadget(i);
8798 /* draw textbutton gadgets */
8799 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
8800 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
8801 MapTextbuttonGadget(i);
8803 /* draw graphicbutton gadgets */
8804 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
8805 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
8806 MapGraphicbuttonGadget(i);
8808 /* draw drawing area gadgets */
8809 DrawPropertiesChangeDrawingAreas();
8812 static void DrawEditorElementAnimation(int x, int y)
8814 int graphic = el2img(properties_element);
8815 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
8816 custom_element.ce_value_fixed_initial :
8817 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
8818 custom_element.collect_score_initial : FrameCounter);
8820 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
8823 static void DrawEditorElementName(int x, int y, int element)
8825 char *element_name = getElementInfoText(element);
8826 int font_nr = FONT_TEXT_1;
8827 int font_width = getFontWidth(font_nr);
8828 int font_height = getFontHeight(font_nr);
8829 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_XPOS(0);
8830 int max_chars_per_line = max_text_width / font_width;
8831 char buffer[max_chars_per_line + 1];
8833 if (strlen(element_name) <= max_chars_per_line)
8834 DrawTextS(x, y, font_nr, element_name);
8837 int next_pos = max_chars_per_line;
8839 strncpy(buffer, element_name, max_chars_per_line);
8840 buffer[max_chars_per_line] = '\0';
8842 if (element_name[max_chars_per_line] == ' ')
8848 for (i = max_chars_per_line - 1; i >= 0; i--)
8849 if (buffer[i] == ' ')
8852 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
8859 DrawTextS(x, y - font_height / 2, font_nr, buffer);
8861 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
8862 buffer[max_chars_per_line] = '\0';
8864 DrawTextS(x, y + font_height / 2, font_nr, buffer);
8868 static void DrawPropertiesWindow()
8873 stick_element_properties_window = FALSE;
8875 /* make sure that previous properties edit mode exists for this element */
8876 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
8877 !IS_CUSTOM_ELEMENT(properties_element))
8878 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
8880 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
8881 !ELEM_IS_PLAYER(properties_element) &&
8882 !IS_CUSTOM_ELEMENT(properties_element))
8883 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
8885 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
8886 (ELEM_IS_PLAYER(properties_element) ||
8887 IS_CUSTOM_ELEMENT(properties_element)))
8888 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
8890 CopyElementPropertiesToEditor(properties_element);
8892 UnmapLevelEditorWindowGadgets();
8893 UnmapLevelEditorToolboxDrawingGadgets();
8894 UnmapLevelEditorToolboxCustomGadgets();
8896 if (IS_CUSTOM_ELEMENT(properties_element) ||
8897 IS_GROUP_ELEMENT(properties_element))
8898 MapLevelEditorToolboxCustomGadgets();
8900 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
8904 DrawTextSCentered(ED_SETTINGS1_YPOS, FONT_TITLE_1, "Element Settings");
8906 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS1_YPOS,
8907 "Element Settings", FONT_TITLE_1);
8910 FrameCounter = 0; /* restart animation frame counter */
8912 DrawElementBorder(SX + xstart * MINI_TILEX,
8913 SY + ystart * MINI_TILEY + MINI_TILEY / 2,
8914 TILEX, TILEY, FALSE);
8916 DrawEditorElementAnimation(SX + xstart * MINI_TILEX,
8917 SY + ystart * MINI_TILEY + MINI_TILEY / 2);
8919 DrawEditorElementName((xstart + 3) * MINI_TILEX + 1,
8920 (ystart + 1) * MINI_TILEY + 1,
8921 properties_element);
8923 DrawPropertiesTabulatorGadgets();
8925 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
8926 DrawPropertiesInfo();
8927 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
8928 DrawPropertiesChange();
8929 else /* (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2]) */
8930 DrawPropertiesConfig();
8933 static void UpdateCustomElementGraphicGadgets()
8935 struct ElementInfo *ei = &element_info[properties_element];
8938 ei->gfx_element = (ei->use_gfx_element ? ei->gfx_element_initial :
8939 properties_element);
8941 ModifyEditorElementList();
8942 RedrawDrawingElements();
8944 /* force redraw of all mapped drawing area gadgets */
8945 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
8947 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
8954 static int getOpenDirectionFromTube(int element)
8958 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
8959 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
8960 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
8961 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
8962 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
8963 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
8964 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
8965 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
8966 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
8967 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
8968 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
8974 static int getTubeFromOpenDirection(int direction)
8978 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
8979 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
8980 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
8981 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
8982 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
8983 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
8984 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
8985 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
8986 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
8987 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
8988 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
8990 /* if only one direction, fall back to simple tube with that direction */
8991 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
8992 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
8993 case (MV_UP): return EL_TUBE_VERTICAL;
8994 case (MV_DOWN): return EL_TUBE_VERTICAL;
9000 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
9002 int element_new = getTubeFromOpenDirection(direction);
9004 return (element_new != EL_EMPTY ? element_new : element_old);
9007 static int getOpenDirectionFromBelt(int element)
9009 int belt_dir = getBeltDirFromBeltElement(element);
9011 return (belt_dir == MV_LEFT ? MV_RIGHT :
9012 belt_dir == MV_RIGHT ? MV_LEFT :
9013 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
9016 static int getBeltFromNrAndOpenDirection(int nr, int direction)
9018 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
9019 direction == MV_RIGHT ? MV_LEFT :
9020 direction == MV_HORIZONTAL ? MV_NONE : direction);
9022 if (direction == MV_NONE)
9025 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
9028 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
9031 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
9033 return (element_new != EL_EMPTY ? element_new : element_old);
9036 static int getOpenDirectionFromPool(int element)
9040 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
9041 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
9042 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
9043 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
9044 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
9045 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
9051 static int getPoolFromOpenDirection(int direction)
9055 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
9056 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
9057 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
9058 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
9059 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
9060 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
9066 static int getPoolFromOpenDirectionExt(int direction, int help_element)
9068 int element = getPoolFromOpenDirection(direction);
9069 int help_direction = getOpenDirectionFromPool(help_element);
9071 if (element == EL_EMPTY)
9073 int help_direction_vertical = help_direction & MV_VERTICAL;
9075 element = getPoolFromOpenDirection(direction | help_direction_vertical);
9078 if (element == EL_EMPTY)
9080 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
9082 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
9088 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
9090 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
9092 return (element_new != EL_EMPTY ? element_new : element_old);
9095 static int getOpenDirectionFromPillar(int element)
9099 case EL_EMC_WALL_1: return (MV_DOWN);
9100 case EL_EMC_WALL_2: return (MV_VERTICAL);
9101 case EL_EMC_WALL_3: return (MV_UP);
9107 static int getPillarFromOpenDirection(int direction)
9111 case (MV_DOWN): return EL_EMC_WALL_1;
9112 case (MV_VERTICAL): return EL_EMC_WALL_2;
9113 case (MV_UP): return EL_EMC_WALL_3;
9119 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
9121 int element_new = getPillarFromOpenDirection(direction);
9123 return (element_new != EL_EMPTY ? element_new : element_old);
9126 static int getOpenDirectionFromSteel2(int element)
9130 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
9131 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
9132 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
9133 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
9134 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
9135 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
9136 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
9137 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
9143 static int getSteel2FromOpenDirection(int direction)
9147 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
9148 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
9149 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
9150 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
9151 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
9152 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
9153 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
9154 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
9160 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
9162 int element_new = getSteel2FromOpenDirection(direction);
9164 return (element_new != EL_EMPTY ? element_new : element_old);
9167 static int getOpenDirectionFromChip(int element)
9171 case EL_SP_CHIP_SINGLE: return (MV_NONE);
9172 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
9173 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
9174 case EL_SP_CHIP_TOP: return (MV_DOWN);
9175 case EL_SP_CHIP_BOTTOM: return (MV_UP);
9181 static int getChipFromOpenDirection(int direction)
9185 case (MV_NONE): return EL_SP_CHIP_SINGLE;
9186 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
9187 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
9188 case (MV_UP): return EL_SP_CHIP_BOTTOM;
9189 case (MV_DOWN): return EL_SP_CHIP_TOP;
9195 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
9197 int element_new = getChipFromOpenDirection(direction);
9199 return (element_new != EL_EMPTY ? element_new : element_old);
9202 static int getClosedTube(int x, int y)
9204 static int xy[4][2] =
9211 int element_old = IntelliDrawBuffer[x][y];
9212 int direction_old = getOpenDirectionFromTube(element_old);
9213 int direction_new = MV_NONE;
9216 for (i = 0; i < NUM_DIRECTIONS; i++)
9218 int xx = x + xy[i][0];
9219 int yy = y + xy[i][1];
9220 int dir = MV_DIR_FROM_BIT(i);
9221 int dir_opposite = MV_DIR_OPPOSITE(dir);
9223 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
9224 (direction_old & dir) &&
9225 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
9226 direction_new |= dir;
9229 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
9232 static int getClosedBelt(int x, int y)
9234 static int xy[4][2] =
9241 int element_old = IntelliDrawBuffer[x][y];
9242 int nr = getBeltNrFromBeltElement(element_old);
9243 int direction_old = getOpenDirectionFromBelt(element_old);
9244 int direction_new = MV_NONE;
9247 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
9249 int xx = x + xy[i][0];
9250 int yy = y + xy[i][1];
9251 int dir = MV_DIR_FROM_BIT(i);
9252 int dir_opposite = MV_DIR_OPPOSITE(dir);
9254 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
9255 (direction_old & dir) &&
9256 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
9257 direction_new |= dir;
9260 return getBeltFromNrAndOpenDirection(nr, direction_new);
9263 static int getClosedPool(int x, int y)
9265 static int xy[4][2] =
9272 int element_old = IntelliDrawBuffer[x][y];
9273 int direction_old = getOpenDirectionFromPool(element_old);
9274 int direction_new = MV_NONE;
9277 for (i = 0; i < NUM_DIRECTIONS; i++)
9279 int xx = x + xy[i][0];
9280 int yy = y + xy[i][1];
9281 int dir = MV_DIR_FROM_BIT(i);
9282 int dir_opposite = MV_DIR_OPPOSITE(dir);
9284 if (IN_LEV_FIELD(xx, yy) &&
9285 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
9286 (direction_old & dir) &&
9287 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
9288 direction_new |= dir;
9291 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
9294 static int getClosedPillar(int x, int y)
9296 static int xy[4][2] =
9303 int element_old = IntelliDrawBuffer[x][y];
9304 int direction_old = getOpenDirectionFromPillar(element_old);
9305 int direction_new = MV_NONE;
9308 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
9310 int xx = x + xy[i][0];
9311 int yy = y + xy[i][1];
9312 int dir = MV_DIR_FROM_BIT(i);
9313 int dir_opposite = MV_DIR_OPPOSITE(dir);
9315 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
9316 (direction_old & dir) &&
9317 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
9318 direction_new |= dir;
9321 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
9324 static int getClosedSteel2(int x, int y)
9326 static int xy[4][2] =
9333 int element_old = IntelliDrawBuffer[x][y];
9334 int direction_old = getOpenDirectionFromSteel2(element_old);
9335 int direction_new = MV_NONE;
9338 for (i = 0; i < NUM_DIRECTIONS; i++)
9340 int xx = x + xy[i][0];
9341 int yy = y + xy[i][1];
9342 int dir = MV_DIR_FROM_BIT(i);
9343 int dir_opposite = MV_DIR_OPPOSITE(dir);
9345 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
9346 (direction_old & dir) &&
9347 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
9348 direction_new |= dir;
9351 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
9354 static int getClosedChip(int x, int y)
9356 static int xy[4][2] =
9363 int element_old = IntelliDrawBuffer[x][y];
9364 int direction_old = getOpenDirectionFromChip(element_old);
9365 int direction_new = MV_NONE;
9368 for (i = 0; i < NUM_DIRECTIONS; i++)
9370 int xx = x + xy[i][0];
9371 int yy = y + xy[i][1];
9372 int dir = MV_DIR_FROM_BIT(i);
9373 int dir_opposite = MV_DIR_OPPOSITE(dir);
9375 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
9376 (direction_old & dir) &&
9377 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
9378 direction_new |= dir;
9381 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
9384 static void SetElementSimple(int x, int y, int element, boolean change_level)
9386 int sx = x - level_xpos;
9387 int sy = y - level_ypos;
9389 IntelliDrawBuffer[x][y] = element;
9392 Feld[x][y] = element;
9394 if (IN_ED_FIELD(sx, sy))
9395 DrawMiniElement(sx, sy, element);
9398 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
9399 int x2, int y2, int *element2,
9400 int (*close_function)(int, int),
9401 boolean change_level)
9403 /* set neighbour elements to newly determined connections */
9404 SetElementSimple(x1, y1, *element1, change_level);
9405 SetElementSimple(x2, y2, *element2, change_level);
9407 /* remove all open connections of neighbour elements */
9408 *element1 = close_function(x1, y1);
9409 *element2 = close_function(x2, y2);
9411 /* set neighbour elements to new, minimized connections */
9412 SetElementSimple(x1, y1, *element1, change_level);
9413 SetElementSimple(x2, y2, *element2, change_level);
9416 static void SetElementIntelliDraw(int x, int y, int new_element,
9417 boolean change_level, int button)
9419 static int xy[4][2] =
9426 static int last_x = -1;
9427 static int last_y = -1;
9428 int old_element = IntelliDrawBuffer[x][y];
9430 if (new_element == EL_UNDEFINED)
9438 if (IS_TUBE(new_element))
9440 int last_element_new = EL_UNDEFINED;
9441 int direction = MV_NONE;
9444 /* if old element is of same kind, keep all existing directions */
9445 if (IS_TUBE(old_element))
9446 direction |= getOpenDirectionFromTube(old_element);
9448 for (i = 0; i < NUM_DIRECTIONS; i++)
9450 int xx = x + xy[i][0];
9451 int yy = y + xy[i][1];
9453 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9454 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
9456 int dir = MV_DIR_FROM_BIT(i);
9457 int dir_opposite = MV_DIR_OPPOSITE(dir);
9458 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9459 int last_direction_old = getOpenDirectionFromTube(last_element_old);
9460 int last_direction_new = last_direction_old | dir_opposite;
9462 last_element_new = getTubeFromOpenDirection(last_direction_new);
9468 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
9470 if (last_element_new != EL_UNDEFINED)
9471 MergeAndCloseNeighbourElements(x, y, &new_element,
9472 last_x, last_y, &last_element_new,
9473 getClosedTube, change_level);
9475 else if (IS_BELT(new_element))
9477 int belt_nr = getBeltNrFromBeltElement(new_element);
9478 int last_element_new = EL_UNDEFINED;
9479 int direction = MV_NONE;
9482 /* if old element is of same kind, keep all existing directions */
9483 if (IS_BELT(old_element))
9484 direction |= getOpenDirectionFromBelt(old_element);
9486 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
9488 int xx = x + xy[i][0];
9489 int yy = y + xy[i][1];
9491 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9492 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
9494 int dir = MV_DIR_FROM_BIT(i);
9495 int dir_opposite = MV_DIR_OPPOSITE(dir);
9496 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9497 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
9498 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
9499 int last_direction_new = last_direction_old | dir_opposite;
9501 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
9502 last_direction_new);
9507 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
9509 if (last_element_new != EL_UNDEFINED)
9510 MergeAndCloseNeighbourElements(x, y, &new_element,
9511 last_x, last_y, &last_element_new,
9512 getClosedBelt, change_level);
9514 else if (IS_ACID_POOL_OR_ACID(new_element))
9516 int last_element_new = EL_UNDEFINED;
9517 int direction = MV_NONE;
9520 /* if old element is of same kind, keep all existing directions */
9521 if (IS_ACID_POOL_OR_ACID(old_element))
9522 direction |= getOpenDirectionFromPool(old_element);
9524 for (i = 0; i < NUM_DIRECTIONS; i++)
9526 int xx = x + xy[i][0];
9527 int yy = y + xy[i][1];
9529 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9530 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
9532 int dir = MV_DIR_FROM_BIT(i);
9533 int dir_opposite = MV_DIR_OPPOSITE(dir);
9534 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9535 int last_direction_old = getOpenDirectionFromPool(last_element_old);
9536 int last_direction_new = last_direction_old | dir_opposite;
9538 last_element_new = getPoolFromOpenDirection(last_direction_new);
9544 /* special corrections needed for intuitively correct acid pool drawing */
9545 if (last_element_new == EL_EMPTY)
9546 last_element_new = new_element;
9547 else if (last_element_new != EL_UNDEFINED)
9548 new_element = last_element_new;
9550 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
9552 if (last_element_new != EL_UNDEFINED)
9553 MergeAndCloseNeighbourElements(x, y, &new_element,
9554 last_x, last_y, &last_element_new,
9555 getClosedPool, change_level);
9557 else if (IS_EMC_PILLAR(new_element))
9559 int last_element_new = EL_UNDEFINED;
9560 int direction = MV_NONE;
9563 /* if old element is of same kind, keep all existing directions */
9564 if (IS_EMC_PILLAR(old_element))
9565 direction |= getOpenDirectionFromPillar(old_element);
9567 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
9569 int xx = x + xy[i][0];
9570 int yy = y + xy[i][1];
9572 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9573 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
9575 int dir = MV_DIR_FROM_BIT(i);
9576 int dir_opposite = MV_DIR_OPPOSITE(dir);
9577 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9578 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
9579 int last_direction_new = last_direction_old | dir_opposite;
9581 last_element_new = getPillarFromOpenDirection(last_direction_new);
9587 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
9589 if (last_element_new != EL_UNDEFINED)
9590 MergeAndCloseNeighbourElements(x, y, &new_element,
9591 last_x, last_y, &last_element_new,
9592 getClosedPillar, change_level);
9594 else if (IS_DC_STEELWALL_2(new_element))
9596 int last_element_new = EL_UNDEFINED;
9597 int direction = MV_NONE;
9600 /* if old element is of same kind, keep all existing directions */
9601 if (IS_DC_STEELWALL_2(old_element))
9602 direction |= getOpenDirectionFromSteel2(old_element);
9604 for (i = 0; i < NUM_DIRECTIONS; i++)
9606 int xx = x + xy[i][0];
9607 int yy = y + xy[i][1];
9609 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9610 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
9612 int dir = MV_DIR_FROM_BIT(i);
9613 int dir_opposite = MV_DIR_OPPOSITE(dir);
9614 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9615 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
9616 int last_direction_new = last_direction_old | dir_opposite;
9618 last_element_new = getSteel2FromOpenDirection(last_direction_new);
9624 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
9626 if (last_element_new != EL_UNDEFINED)
9627 MergeAndCloseNeighbourElements(x, y, &new_element,
9628 last_x, last_y, &last_element_new,
9629 getClosedSteel2, change_level);
9631 else if (IS_SP_CHIP(new_element))
9633 int last_element_new = EL_UNDEFINED;
9634 int direction = MV_NONE;
9637 /* (do not keep existing directions, regardless of kind of old element) */
9639 for (i = 0; i < NUM_DIRECTIONS; i++)
9641 int xx = x + xy[i][0];
9642 int yy = y + xy[i][1];
9644 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9645 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
9647 int dir = MV_DIR_FROM_BIT(i);
9648 int dir_opposite = MV_DIR_OPPOSITE(dir);
9649 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9650 int last_direction_old = getOpenDirectionFromChip(last_element_old);
9651 int last_direction_new = last_direction_old | dir_opposite;
9653 if (last_direction_old == MV_NONE)
9655 last_element_new = getChipFromOpenDirection(last_direction_new);
9658 else if (last_direction_old & (dir | dir_opposite))
9660 direction |= MV_DIR_OPPOSITE(last_direction_old);
9664 direction |= MV_DIR_OPPOSITE(dir);
9669 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
9671 if (last_element_new != EL_UNDEFINED)
9672 MergeAndCloseNeighbourElements(x, y, &new_element,
9673 last_x, last_y, &last_element_new,
9674 getClosedChip, change_level);
9676 else if (IS_SP_HARDWARE_BASE(new_element))
9678 int nr = GetSimpleRandom(6);
9680 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
9681 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
9682 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
9683 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
9684 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
9686 else if (new_element == EL_SP_HARDWARE_GREEN ||
9687 new_element == EL_SP_HARDWARE_BLUE ||
9688 new_element == EL_SP_HARDWARE_RED)
9690 int nr = GetSimpleRandom(3);
9692 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
9693 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
9695 else if (IS_GROUP_ELEMENT(new_element))
9697 boolean connected_drawing = FALSE;
9700 for (i = 0; i < NUM_DIRECTIONS; i++)
9702 int xx = x + xy[i][0];
9703 int yy = y + xy[i][1];
9705 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9706 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
9707 connected_drawing = TRUE;
9710 if (!connected_drawing)
9711 ResolveGroupElement(new_element);
9713 new_element = GetElementFromGroupElement(new_element);
9715 else if (IS_BELT_SWITCH(old_element))
9717 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
9718 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
9720 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
9721 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
9723 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
9727 static int swappable_elements[][2] =
9729 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
9730 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
9731 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
9732 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
9733 { EL_EMERALD, EL_WALL_EMERALD },
9734 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
9735 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
9736 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
9737 { EL_DIAMOND, EL_WALL_DIAMOND },
9738 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
9739 { EL_GATE_1, EL_GATE_1_GRAY },
9740 { EL_GATE_2, EL_GATE_2_GRAY },
9741 { EL_GATE_3, EL_GATE_3_GRAY },
9742 { EL_GATE_4, EL_GATE_4_GRAY },
9743 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
9744 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
9745 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
9746 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
9747 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
9748 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
9749 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
9750 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
9751 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
9752 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
9753 { EL_LAMP, EL_LAMP_ACTIVE },
9754 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
9755 { EL_SP_BASE, EL_SP_BUGGY_BASE },
9756 { EL_PEARL, EL_WALL_PEARL },
9757 { EL_CRYSTAL, EL_WALL_CRYSTAL },
9758 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
9759 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
9760 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
9761 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
9762 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
9763 { EL_LANDMINE, EL_DC_LANDMINE },
9764 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
9765 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
9766 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
9767 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
9768 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
9772 static int rotatable_elements[][4] =
9790 EL_BD_BUTTERFLY_RIGHT,
9791 EL_BD_BUTTERFLY_DOWN,
9792 EL_BD_BUTTERFLY_LEFT
9797 EL_BD_FIREFLY_RIGHT,
9831 EL_SP_GRAVITY_PORT_UP,
9832 EL_SP_GRAVITY_PORT_RIGHT,
9833 EL_SP_GRAVITY_PORT_DOWN,
9834 EL_SP_GRAVITY_PORT_LEFT
9838 EL_SP_GRAVITY_ON_PORT_UP,
9839 EL_SP_GRAVITY_ON_PORT_RIGHT,
9840 EL_SP_GRAVITY_ON_PORT_DOWN,
9841 EL_SP_GRAVITY_ON_PORT_LEFT
9845 EL_SP_GRAVITY_OFF_PORT_UP,
9846 EL_SP_GRAVITY_OFF_PORT_RIGHT,
9847 EL_SP_GRAVITY_OFF_PORT_DOWN,
9848 EL_SP_GRAVITY_OFF_PORT_LEFT
9859 EL_BALLOON_SWITCH_UP,
9860 EL_BALLOON_SWITCH_RIGHT,
9861 EL_BALLOON_SWITCH_DOWN,
9862 EL_BALLOON_SWITCH_LEFT
9874 for (i = 0; swappable_elements[i][0] != -1; i++)
9876 int element1 = swappable_elements[i][0];
9877 int element2 = swappable_elements[i][1];
9879 if (old_element == element1 || old_element == element2)
9880 new_element = (old_element == element1 ? element2 : element1);
9883 for (i = 0; rotatable_elements[i][0] != -1; i++)
9885 for (j = 0; j < 4; j++)
9887 int element = rotatable_elements[i][j];
9889 if (old_element == element)
9890 new_element = (button == 1 ? rotatable_elements[i][(j + 3) % 4] :
9891 button == 2 ? rotatable_elements[i][0] :
9892 button == 3 ? rotatable_elements[i][(j + 1) % 4] :
9898 SetElementSimple(x, y, new_element, change_level);
9904 static void ResetIntelliDraw()
9908 for (x = 0; x < lev_fieldx; x++)
9909 for (y = 0; y < lev_fieldy; y++)
9910 IntelliDrawBuffer[x][y] = Feld[x][y];
9912 SetElementIntelliDraw(-1, -1, EL_UNDEFINED, FALSE, -1);
9915 static void SetElementExt(int x, int y, int element, boolean change_level,
9919 SetElementSimple(x, y, Feld[x][y], change_level);
9920 else if (GetKeyModState() & KMOD_Shift)
9921 SetElementIntelliDraw(x, y, element, change_level, button);
9923 SetElementSimple(x, y, element, change_level);
9926 static void SetElement(int x, int y, int element)
9928 SetElementExt(x, y, element, TRUE, -1);
9931 static void SetElementButton(int x, int y, int element, int button)
9933 SetElementExt(x, y, element, TRUE, button);
9936 static void DrawLineElement(int sx, int sy, int element, boolean change_level)
9938 int lx = sx + level_xpos;
9939 int ly = sy + level_ypos;
9941 SetElementExt(lx, ly, element, change_level, -1);
9944 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
9945 int element, boolean change_level)
9947 int xsize = ABS(to_x - from_x);
9948 int ysize = ABS(to_y - from_y);
9949 int dx = (to_x < from_x ? -1 : +1);
9950 int dy = (to_y < from_y ? -1 : +1);
9953 if (from_y == to_y) /* horizontal line */
9955 for (i = 0; i <= xsize; i++)
9956 DrawLineElement(from_x + i * dx, from_y, element, change_level);
9958 else if (from_x == to_x) /* vertical line */
9960 for (i = 0; i <= ysize; i++)
9961 DrawLineElement(from_x, from_y + i * dy, element, change_level);
9963 else /* diagonal line */
9965 if (ysize < xsize) /* a < 1 */
9967 float a = (float)ysize / (float)xsize;
9969 for (i = 0; i <= xsize; i++)
9972 int y = dy * (int)(a * i + 0.5);
9974 DrawLineElement(from_x + x, from_y + y, element, change_level);
9979 float a = (float)xsize / (float)ysize;
9981 for (i = 0; i <= ysize; i++)
9983 int x = dx * (int)(a * i + 0.5);
9986 DrawLineElement(from_x + x, from_y + y, element, change_level);
9992 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
9993 int element, boolean change_level)
9995 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
9996 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
9997 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
9998 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
10001 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
10002 int element, boolean change_level)
10007 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
10009 for (y = from_y; y <= to_y; y++)
10010 DrawLine(from_x, y, to_x, y, element, change_level);
10013 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
10014 int element, boolean change_level)
10016 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
10017 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
10018 int len_x = ABS(to_x - from_x);
10019 int len_y = ABS(to_y - from_y);
10022 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
10024 /* not optimal (some points get drawn twice) but simple,
10025 and fast enough for the few points we are drawing */
10027 for (x = 0; x <= radius; x++)
10029 int sx, sy, lx, ly;
10031 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
10033 sx = from_x + x * (from_x < to_x2 ? +1 : -1);
10034 sy = from_y + y * (from_y < to_y2 ? +1 : -1);
10035 lx = sx + level_xpos;
10036 ly = sy + level_ypos;
10038 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
10039 DrawLineElement(sx, sy, element, change_level);
10042 for (y = 0; y <= radius; y++)
10044 int sx, sy, lx, ly;
10046 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
10048 sx = from_x + x * (from_x < to_x2 ? +1 : -1);
10049 sy = from_y + y * (from_y < to_y2 ? +1 : -1);
10050 lx = sx + level_xpos;
10051 ly = sy + level_ypos;
10053 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
10054 DrawLineElement(sx, sy, element, change_level);
10058 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
10059 int element, boolean change_level)
10061 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
10062 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
10064 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
10067 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
10069 #if DRAW_CIRCLES_BUTTON_AVAILABLE
10070 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
10071 int element, boolean change_level)
10073 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
10074 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
10075 int mirror_to_x2 = from_x - (to_x2 - from_x);
10076 int mirror_to_y2 = from_y - (to_y2 - from_y);
10078 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
10079 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
10080 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
10081 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element,change_level);
10085 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
10087 int from_sx, from_sy;
10091 swap_numbers(&from_x, &to_x);
10094 swap_numbers(&from_y, &to_y);
10096 from_sx = SX + from_x * MINI_TILEX;
10097 from_sy = SY + from_y * MINI_TILEY;
10098 to_sx = SX + to_x * MINI_TILEX + MINI_TILEX - 1;
10099 to_sy = SY + to_y * MINI_TILEY + MINI_TILEY - 1;
10101 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
10102 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
10103 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
10104 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
10106 if (from_x == to_x && from_y == to_y)
10107 MarkTileDirty(from_x/2, from_y/2);
10109 redraw_mask |= REDRAW_FIELD;
10112 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
10113 int element, boolean change_level)
10115 if (element == -1 || change_level)
10116 DrawBox(from_x, from_y, to_x, to_y, -1, FALSE);
10118 DrawAreaBorder(from_x, from_y, to_x, to_y);
10121 /* values for CopyBrushExt() */
10122 #define CB_AREA_TO_BRUSH 0
10123 #define CB_BRUSH_TO_CURSOR 1
10124 #define CB_BRUSH_TO_LEVEL 2
10125 #define CB_DELETE_OLD_CURSOR 3
10126 #define CB_DUMP_BRUSH 4
10127 #define CB_DUMP_BRUSH_SMALL 5
10129 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
10130 int button, int mode)
10133 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
10135 static short brush_buffer[MAX_ED_FIELDX][MAX_ED_FIELDY];
10137 static int brush_width, brush_height;
10138 static int last_cursor_x = -1, last_cursor_y = -1;
10139 static boolean delete_old_brush;
10140 int new_element = BUTTON_ELEMENT(button);
10143 if (mode == CB_DUMP_BRUSH ||
10144 mode == CB_DUMP_BRUSH_SMALL)
10146 if (!draw_with_brush)
10148 Error(ERR_WARN, "no brush selected");
10153 for (y = 0; y < brush_height; y++)
10155 for (x = 0; x < brush_width; x++)
10157 int element = brush_buffer[x][y];
10158 int element_mapped = element;
10160 if (IS_CUSTOM_ELEMENT(element))
10161 element_mapped = EL_CUSTOM_START;
10162 else if (IS_GROUP_ELEMENT(element))
10163 element_mapped = EL_GROUP_START;
10164 else if (element >= NUM_FILE_ELEMENTS)
10165 element_mapped = EL_UNKNOWN;
10167 printf("%c%03d", (mode == CB_DUMP_BRUSH ? '`' : '¸'), element_mapped);
10176 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
10179 if (mode == CB_AREA_TO_BRUSH)
10181 int from_lx, from_ly;
10184 swap_numbers(&from_x, &to_x);
10187 swap_numbers(&from_y, &to_y);
10189 brush_width = to_x - from_x + 1;
10190 brush_height = to_y - from_y + 1;
10192 from_lx = from_x + level_xpos;
10193 from_ly = from_y + level_ypos;
10195 for (y = 0; y < brush_height; y++)
10197 for (x = 0; x < brush_width; x++)
10199 brush_buffer[x][y] = Feld[from_lx + x][from_ly + y];
10202 DrawLineElement(from_x + x, from_y + y, new_element, TRUE);
10207 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10209 delete_old_brush = FALSE;
10211 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
10212 mode == CB_BRUSH_TO_LEVEL)
10214 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
10215 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
10216 int cursor_from_x = cursor_x - brush_width / 2;
10217 int cursor_from_y = cursor_y - brush_height / 2;
10218 int border_from_x = cursor_x, border_from_y = cursor_y;
10219 int border_to_x = cursor_x, border_to_y = cursor_y;
10221 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
10222 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
10224 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
10225 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
10227 delete_old_brush = FALSE;
10231 for (y = 0; y < brush_height; y++)
10233 for (x = 0; x < brush_width; x++)
10235 int sx = cursor_from_x + x;
10236 int sy = cursor_from_y + y;
10237 int lx = sx + level_xpos;
10238 int ly = sy + level_ypos;
10239 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
10240 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
10241 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
10242 brush_buffer[x][y] : new_element);
10244 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
10246 if (sx < border_from_x)
10247 border_from_x = sx;
10248 else if (sx > border_to_x)
10250 if (sy < border_from_y)
10251 border_from_y = sy;
10252 else if (sy > border_to_y)
10255 DrawLineElement(sx, sy, element, change_level);
10260 if (mode != CB_DELETE_OLD_CURSOR)
10261 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
10263 last_cursor_x = cursor_x;
10264 last_cursor_y = cursor_y;
10265 delete_old_brush = TRUE;
10269 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
10272 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
10275 static void CopyBrushToLevel(int x, int y, int button)
10277 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
10280 static void CopyBrushToCursor(int x, int y)
10282 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
10285 static void DeleteBrushFromCursor()
10287 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
10292 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
10295 void DumpBrush_Small()
10297 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
10300 static void FloodFill(int from_x, int from_y, int fill_element)
10302 FloodFillLevel(from_x, from_y, fill_element, Feld, lev_fieldx, lev_fieldy);
10305 /* values for DrawLevelText() modes */
10306 #define TEXT_INIT 0
10307 #define TEXT_SETCURSOR 1
10308 #define TEXT_WRITECHAR 2
10309 #define TEXT_BACKSPACE 3
10310 #define TEXT_NEWLINE 4
10312 #define TEXT_QUERY_TYPING 6
10314 static int DrawLevelText(int sx, int sy, char letter, int mode)
10316 static short delete_buffer[MAX_LEV_FIELDX];
10317 static int start_sx, start_sy;
10318 static int last_sx, last_sy;
10319 static boolean typing = FALSE;
10320 int letter_element = EL_CHAR_ASCII0 + letter;
10321 int lx = 0, ly = 0;
10323 /* map lower case letters to upper case and convert special characters */
10324 if (letter >= 'a' && letter <= 'z')
10325 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
10326 else if (letter == 'ä' || letter == 'Ä')
10327 letter_element = EL_CHAR_AUMLAUT;
10328 else if (letter == 'ö' || letter == 'Ö')
10329 letter_element = EL_CHAR_OUMLAUT;
10330 else if (letter == 'ü' || letter == 'Ü')
10331 letter_element = EL_CHAR_UUMLAUT;
10332 else if (letter == '^')
10333 letter_element = EL_CHAR_COPYRIGHT;
10335 letter_element = EL_CHAR_ASCII0 + letter;
10337 if (mode != TEXT_INIT)
10342 if (mode != TEXT_SETCURSOR)
10348 lx = last_sx + level_xpos;
10349 ly = last_sy + level_ypos;
10356 DrawLevelText(0, 0, 0, TEXT_END);
10359 start_sx = last_sx = sx;
10360 start_sy = last_sy = sy;
10361 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
10364 case TEXT_SETCURSOR:
10365 DrawMiniElement(last_sx, last_sy, Feld[lx][ly]);
10366 DrawAreaBorder(sx, sy, sx, sy);
10371 case TEXT_WRITECHAR:
10372 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
10374 delete_buffer[sx - start_sx] = Feld[lx][ly];
10375 Feld[lx][ly] = letter_element;
10377 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
10378 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
10379 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
10380 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
10382 DrawLevelText(0, 0, 0, TEXT_END);
10384 level.changed = TRUE;
10388 case TEXT_BACKSPACE:
10391 Feld[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
10392 DrawMiniElement(sx - 1, sy, Feld[lx - 1][ly]);
10393 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
10398 if (sy + 1 < ed_fieldy - 1 && ly + 1 < lev_fieldy - 1)
10399 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
10401 DrawLevelText(0, 0, 0, TEXT_END);
10405 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10406 DrawMiniElement(sx, sy, Feld[lx][ly]);
10410 case TEXT_QUERY_TYPING:
10420 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
10421 int element, boolean change_level)
10423 int lx = sx + level_xpos;
10424 int ly = sy + level_ypos;
10427 DrawMiniElement(sx, sy, Feld[lx][ly]);
10429 DrawAreaBorder(sx, sy, sx, sy);
10432 static void CheckLevelBorderElement(boolean redraw_playfield)
10434 int last_border_element = BorderElement;
10436 SetBorderElement();
10438 if (redraw_playfield && BorderElement != last_border_element)
10439 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10442 static void CopyLevelToUndoBuffer(int mode)
10444 static boolean accumulated_undo = FALSE;
10445 boolean new_undo_buffer_position = TRUE;
10450 case UNDO_IMMEDIATE:
10451 accumulated_undo = FALSE;
10454 case UNDO_ACCUMULATE:
10455 if (accumulated_undo)
10456 new_undo_buffer_position = FALSE;
10457 accumulated_undo = TRUE;
10464 if (new_undo_buffer_position)
10466 /* new position in undo buffer ring */
10467 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
10469 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
10470 undo_buffer_steps++;
10473 for (x = 0; x < lev_fieldx; x++)
10474 for (y = 0; y < lev_fieldy; y++)
10475 UndoBuffer[undo_buffer_position][x][y] = Feld[x][y];
10477 /* check if drawing operation forces change of border style */
10478 CheckLevelBorderElement(TRUE);
10480 level.changed = TRUE;
10483 static void RandomPlacement(int new_element)
10485 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
10486 int num_free_positions = 0;
10487 int num_percentage, num_elements;
10491 ResetIntelliDraw();
10494 /* determine number of free positions for randomly placing the new element */
10495 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
10497 free_position[x][y] =
10498 (random_placement_background_restricted ?
10499 Feld[x][y] == random_placement_background_element :
10500 Feld[x][y] != new_element);
10502 if (free_position[x][y])
10503 num_free_positions++;
10506 /* determine number of new elements to place there */
10507 num_percentage = num_free_positions * random_placement_value / 100;
10508 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
10509 num_percentage : random_placement_value);
10511 /* if less free positions than elements to place, fill all these positions */
10512 if (num_free_positions < num_elements)
10514 for (x = 0; x < lev_fieldx; x++)
10515 for (y = 0; y < lev_fieldy; y++)
10516 if (free_position[x][y])
10518 SetElement(x, y, new_element);
10520 Feld[x][y] = new_element;
10525 while (num_elements > 0)
10527 x = GetSimpleRandom(lev_fieldx);
10528 y = GetSimpleRandom(lev_fieldy);
10530 /* don't place element at the same position twice */
10531 if (free_position[x][y])
10533 free_position[x][y] = FALSE;
10535 SetElement(x, y, new_element);
10537 Feld[x][y] = new_element;
10544 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10545 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10548 void WrapLevel(int dx, int dy)
10550 int wrap_dx = lev_fieldx - dx;
10551 int wrap_dy = lev_fieldy - dy;
10554 for (x = 0; x < lev_fieldx; x++)
10555 for (y = 0; y < lev_fieldy; y++)
10556 FieldBackup[x][y] = Feld[x][y];
10558 for (x = 0; x < lev_fieldx; x++)
10559 for (y = 0; y < lev_fieldy; y++)
10561 FieldBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
10563 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10564 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
10567 static void HandleDrawingAreas(struct GadgetInfo *gi)
10569 static boolean started_inside_drawing_area = FALSE;
10570 int id = gi->custom_id;
10571 boolean button_press_event;
10572 boolean button_release_event;
10573 boolean inside_drawing_area = !gi->event.off_borders;
10574 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
10575 int actual_drawing_function;
10576 int button = gi->event.button;
10577 int new_element = BUTTON_ELEMENT(button);
10578 int sx = gi->event.x, sy = gi->event.y;
10579 int min_sx = 0, min_sy = 0;
10580 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
10581 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
10582 int lx = 0, ly = 0;
10583 int min_lx = 0, min_ly = 0;
10584 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
10587 /* handle info callback for each invocation of action callback */
10588 gi->callback_info(gi);
10590 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
10591 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
10593 /* make sure to stay inside drawing area boundaries */
10594 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
10595 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
10599 /* get positions inside level field */
10600 lx = sx + level_xpos;
10601 ly = sy + level_ypos;
10603 if (!IN_LEV_FIELD(lx, ly))
10604 inside_drawing_area = FALSE;
10606 /* make sure to stay inside level field boundaries */
10607 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
10608 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
10610 /* correct drawing area positions accordingly */
10611 sx = lx - level_xpos;
10612 sy = ly - level_ypos;
10615 if (button_press_event)
10616 started_inside_drawing_area = inside_drawing_area;
10618 if (!started_inside_drawing_area)
10621 if (!IS_VALID_BUTTON(button))
10624 if (!button && !button_release_event)
10627 /* automatically switch to 'single item' drawing mode, if needed */
10628 actual_drawing_function =
10629 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
10630 drawing_function : GADGET_ID_SINGLE_ITEMS);
10632 /* clicking into drawing area with pressed Control key picks element */
10633 if (GetKeyModState() & KMOD_Control)
10635 last_drawing_function = drawing_function;
10636 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
10639 if (GetKeyModState() & KMOD_Shift)
10641 if (button_press_event || button_release_event)
10642 ResetIntelliDraw();
10645 switch (actual_drawing_function)
10647 case GADGET_ID_SINGLE_ITEMS:
10650 if (button_release_event)
10652 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10654 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
10655 !inside_drawing_area)
10656 DeleteBrushFromCursor();
10659 ResetIntelliDraw();
10663 if (!button || button_release_event)
10666 if (draw_with_brush)
10669 if (!button_release_event)
10671 CopyBrushToLevel(sx, sy, button);
10676 else if (new_element != Feld[lx][ly])
10679 if (new_element == EL_PLAYER_1)
10681 /* remove player at old position */
10682 for (y = 0; y < lev_fieldy; y++)
10684 for (x = 0; x < lev_fieldx; x++)
10686 if (Feld[x][y] == EL_PLAYER_1)
10689 SetElement(x, y, EL_EMPTY);
10691 Feld[x][y] = EL_EMPTY;
10693 if (IN_ED_FIELD(x - level_xpos, y - level_ypos))
10694 DrawMiniElement(x - level_xpos, y - level_ypos, EL_EMPTY);
10696 if (x - level_xpos >= 0 && x - level_xpos < ed_fieldx &&
10697 y - level_ypos >= 0 && y - level_ypos < ed_fieldy)
10698 DrawMiniElement(x - level_xpos, y - level_ypos, EL_EMPTY);
10707 SetElementButton(lx, ly, new_element, button);
10709 Feld[lx][ly] = new_element;
10710 DrawMiniElement(sx, sy, new_element);
10716 int type_id = gi->custom_type_id;
10717 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
10719 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
10720 DrawMiniGraphicExt(drawto,
10721 gi->x + sx * MINI_TILEX,
10722 gi->y + sy * MINI_TILEY,
10723 el2edimg(new_element));
10725 DrawFixedGraphicExt(drawto,
10726 gi->x + sx * TILEX,
10727 gi->y + sy * TILEY,
10728 el2img(new_element), 0);
10730 if (id == GADGET_ID_CUSTOM_GRAPHIC)
10731 new_element = GFX_ELEMENT(new_element);
10733 drawingarea_info[type_id].value[pos] = new_element;
10735 CopyElementPropertiesToGame(properties_element);
10737 if (id == GADGET_ID_CUSTOM_GRAPHIC)
10739 UpdateCustomElementGraphicGadgets();
10741 FrameCounter = 0; /* restart animation frame counter */
10746 case GADGET_ID_CONNECTED_ITEMS:
10748 static int last_sx = -1;
10749 static int last_sy = -1;
10751 if (button_release_event)
10752 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10756 if (!button_press_event)
10757 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
10765 case GADGET_ID_LINE:
10766 case GADGET_ID_ARC:
10767 case GADGET_ID_RECTANGLE:
10768 case GADGET_ID_FILLED_BOX:
10769 case GADGET_ID_GRAB_BRUSH:
10770 case GADGET_ID_TEXT:
10772 static int last_sx = -1;
10773 static int last_sy = -1;
10774 static int start_sx = -1;
10775 static int start_sy = -1;
10776 void (*draw_func)(int, int, int, int, int, boolean);
10778 if (drawing_function == GADGET_ID_LINE)
10779 draw_func = DrawLine;
10780 else if (drawing_function == GADGET_ID_ARC)
10781 draw_func = DrawArc;
10782 else if (drawing_function == GADGET_ID_RECTANGLE)
10783 draw_func = DrawBox;
10784 else if (drawing_function == GADGET_ID_FILLED_BOX)
10785 draw_func = DrawFilledBox;
10786 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
10787 draw_func = SelectArea;
10788 else /* (drawing_function == GADGET_ID_TEXT) */
10789 draw_func = SetTextCursor;
10791 if (button_press_event)
10793 draw_func(sx, sy, sx, sy, new_element, FALSE);
10794 start_sx = last_sx = sx;
10795 start_sy = last_sy = sy;
10797 if (drawing_function == GADGET_ID_TEXT)
10798 DrawLevelText(0, 0, 0, TEXT_END);
10800 else if (button_release_event)
10802 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
10803 if (drawing_function == GADGET_ID_GRAB_BRUSH)
10805 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
10806 CopyBrushToCursor(sx, sy);
10807 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
10809 draw_with_brush = TRUE;
10811 else if (drawing_function == GADGET_ID_TEXT)
10812 DrawLevelText(sx, sy, 0, TEXT_INIT);
10814 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10816 else if (last_sx != sx || last_sy != sy)
10818 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
10819 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
10826 case GADGET_ID_FLOOD_FILL:
10827 if (button_press_event && Feld[lx][ly] != new_element)
10829 FloodFill(lx, ly, new_element);
10830 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10831 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10835 case GADGET_ID_PICK_ELEMENT:
10836 if (button_release_event)
10837 ClickOnGadget(level_editor_gadget[last_drawing_function],
10839 else if (draw_level)
10840 PickDrawingElement(button, Feld[lx][ly]);
10843 int type_id = gi->custom_type_id;
10844 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
10846 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
10856 static void HandleCounterButtons(struct GadgetInfo *gi)
10858 int gadget_id = gi->custom_id;
10859 int counter_id = gi->custom_type_id;
10860 int button = gi->event.button;
10861 int *counter_value = counterbutton_info[counter_id].value;
10862 int step = BUTTON_STEPSIZE(button) *
10863 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
10865 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
10867 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
10868 boolean released = (gi->event.type == GD_EVENT_RELEASED);
10869 boolean level_changed = LevelChanged();
10871 if ((level_changed && pressed) || (!level_changed && released))
10874 if (level_changed && !Request("Level has changed ! Discard changes ?",
10877 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
10878 ModifyEditorCounterValue(counter_id, *counter_value);
10884 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
10885 *counter_value = gi->textinput.number_value;
10887 ModifyEditorCounterValue(counter_id, *counter_value + step);
10889 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
10891 LoadLevel(level_nr);
10892 LoadScore(level_nr);
10897 DrawEditModeWindow();
10902 switch (counter_id)
10904 case ED_COUNTER_ID_YAMYAM_CONTENT:
10905 DrawYamYamContentAreas();
10908 case ED_COUNTER_ID_BALL_CONTENT:
10909 DrawMagicBallContentAreas();
10912 case ED_COUNTER_ID_ANDROID_CONTENT:
10913 DrawAndroidElementArea(properties_element);
10916 case ED_COUNTER_ID_GROUP_CONTENT:
10917 DrawGroupElementArea(properties_element);
10918 CopyGroupElementPropertiesToGame(properties_element);
10921 case ED_COUNTER_ID_INVENTORY_SIZE:
10922 DrawPlayerInitialInventoryArea(properties_element);
10925 case ED_COUNTER_ID_ENVELOPE_XSIZE:
10926 case ED_COUNTER_ID_ENVELOPE_YSIZE:
10927 DrawEnvelopeTextArea(-1);
10930 case ED_COUNTER_ID_LEVEL_XSIZE:
10931 case ED_COUNTER_ID_LEVEL_YSIZE:
10932 lev_fieldx = level.fieldx;
10933 lev_fieldy = level.fieldy;
10940 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
10941 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
10942 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
10943 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
10944 CopyElementPropertiesToGame(properties_element);
10946 level.changed = TRUE;
10949 static void HandleTextInputGadgets(struct GadgetInfo *gi)
10951 int type_id = gi->custom_type_id;
10953 strcpy(textinput_info[type_id].value, gi->textinput.value);
10955 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
10957 CopyElementPropertiesToGame(properties_element);
10959 ModifyEditorElementList(); /* update changed button info text */
10962 level.changed = TRUE;
10965 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
10967 int type_id = gi->custom_type_id;
10970 strncpy(textarea_info[type_id].value, gi->textarea.value,
10971 MAX_ENVELOPE_TEXT_LEN);
10972 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
10974 /* !!! BUGGY !!! MAX_ENVELOPE_TEXT_LEN != MAX_GADGET_TEXTSIZE !!! */
10975 strcpy(textarea_info[type_id].value, gi->textarea.value);
10978 level.changed = TRUE;
10981 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
10983 int type_id = gi->custom_type_id;
10984 int value_old = *selectbox_info[type_id].value;
10985 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
10987 *selectbox_info[type_id].value = value_new;
10989 if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
10991 element_info[properties_element].current_change_page = gi->selectbox.index;
10993 DrawPropertiesWindow();
10995 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
10996 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
10997 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
10998 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
10999 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
11001 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
11003 /* when changing action type, also check action mode and action arg */
11004 if (value_old != value_new)
11005 setSelectboxSpecialActionVariablesIfNeeded();
11007 DrawPropertiesChange();
11010 CopyElementPropertiesToGame(properties_element);
11012 level.changed = TRUE;
11016 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
11018 int type_id = gi->custom_type_id;
11021 if (type_id >= ED_TEXTBUTTON_ID_LEVELINFO_FIRST &&
11022 type_id <= ED_TEXTBUTTON_ID_LEVELINFO_LAST)
11024 edit_mode_levelinfo = gi->custom_type_id;
11026 DrawLevelInfoWindow();
11028 else if (type_id >= ED_TEXTBUTTON_ID_PROPERTIES_FIRST &&
11029 type_id <= ED_TEXTBUTTON_ID_PROPERTIES_LAST)
11031 edit_mode_properties = gi->custom_type_id;
11033 DrawPropertiesWindow();
11035 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE)
11037 char *template_filename = getDefaultLevelFilename(-1);
11038 boolean new_template = !fileExists(template_filename);
11040 /* backup original "level.field" (needed to track playfield changes) */
11041 CopyPlayfield(level.field, FieldBackup);
11043 /* "SaveLevelTemplate()" uses "level.field", so copy editor playfield */
11044 CopyPlayfield(Feld, level.field);
11046 if (new_template ||
11047 Request("Save this template and kill the old ?", REQ_ASK))
11048 SaveLevelTemplate();
11051 Request("Template saved !", REQ_CONFIRM);
11053 /* restore original "level.field" (needed to track playfield changes) */
11054 CopyPlayfield(FieldBackup, level.field);
11056 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
11057 custom_element.num_change_pages < MAX_CHANGE_PAGES)
11059 struct ElementInfo *ei = &element_info[properties_element];
11061 setElementChangePages(ei, ei->num_change_pages + 1);
11063 /* set new change page to be new current change page */
11064 ei->current_change_page = ei->num_change_pages - 1;
11065 ei->change = &ei->change_page[ei->current_change_page];
11067 setElementChangeInfoToDefaults(ei->change);
11069 DrawPropertiesWindow();
11071 level.changed = TRUE;
11073 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
11074 custom_element.num_change_pages > MIN_CHANGE_PAGES)
11076 struct ElementInfo *ei = &element_info[properties_element];
11078 /* copy all change pages after change page to be deleted */
11079 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
11080 ei->change_page[i] = ei->change_page[i + 1];
11082 setElementChangePages(ei, ei->num_change_pages - 1);
11084 DrawPropertiesWindow();
11086 level.changed = TRUE;
11090 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
11092 int type_id = gi->custom_type_id;
11094 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
11095 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
11097 struct ElementInfo *ei = &element_info[properties_element];
11098 int step = BUTTON_STEPSIZE(gi->event.button);
11100 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
11101 ei->current_change_page += step;
11103 if (ei->current_change_page < 0)
11104 ei->current_change_page = 0;
11105 else if (ei->current_change_page >= ei->num_change_pages)
11106 ei->current_change_page = ei->num_change_pages - 1;
11108 DrawPropertiesWindow();
11110 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
11111 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
11113 struct ElementInfo *ei = &element_info[properties_element];
11114 int current_change_page = ei->current_change_page;
11116 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
11117 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
11118 ei->change_page[current_change_page];
11119 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
11121 ei->change_page[current_change_page] =
11122 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
11124 level.changed = TRUE;
11127 DrawPropertiesWindow();
11131 static void HandleRadiobuttons(struct GadgetInfo *gi)
11133 *radiobutton_info[gi->custom_type_id].value =
11134 radiobutton_info[gi->custom_type_id].checked_value;
11136 level.changed = TRUE;
11139 static void HandleCheckbuttons(struct GadgetInfo *gi)
11141 int type_id = gi->custom_type_id;
11143 *checkbutton_info[type_id].value ^= TRUE;
11145 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
11146 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
11147 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
11148 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
11149 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
11150 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
11151 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
11152 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE))
11154 CopyElementPropertiesToGame(properties_element);
11157 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
11159 UpdateCustomElementGraphicGadgets();
11161 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE)
11163 char *template_filename = getDefaultLevelFilename(-1);
11165 if (level.use_custom_template && !fileExists(template_filename))
11167 Request("No level template found !", REQ_CONFIRM);
11169 level.use_custom_template = FALSE;
11170 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
11175 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
11177 DrawEditModeWindow();
11180 level.changed = TRUE;
11183 static void HandleControlButtons(struct GadgetInfo *gi)
11185 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
11186 static int last_edit_mode = ED_MODE_DRAWING;
11187 static int last_custom_copy_mode = -1;
11188 int id = gi->custom_id;
11189 int button = gi->event.button;
11190 int step = BUTTON_STEPSIZE(button);
11191 int new_element = BUTTON_ELEMENT(button);
11194 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
11195 DrawLevelText(0, 0, 0, TEXT_END);
11197 if (id < ED_NUM_CTRL1_BUTTONS &&
11198 id != GADGET_ID_SINGLE_ITEMS &&
11199 id != GADGET_ID_PROPERTIES &&
11200 id != GADGET_ID_PICK_ELEMENT &&
11201 edit_mode != ED_MODE_DRAWING &&
11202 drawing_function != GADGET_ID_PICK_ELEMENT &&
11203 !(GetKeyModState() & KMOD_Control))
11205 DrawDrawingWindow();
11206 edit_mode = ED_MODE_DRAWING;
11209 /* element copy mode active, but no element button pressed => deactivate */
11210 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
11211 last_custom_copy_mode = -1;
11215 case GADGET_ID_SCROLL_LEFT:
11216 if (level_xpos >= 0)
11218 if (lev_fieldx < ed_fieldx - 2)
11221 level_xpos -= step;
11222 if (level_xpos < -1)
11225 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
11227 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11229 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
11230 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
11234 case GADGET_ID_SCROLL_RIGHT:
11235 if (level_xpos <= lev_fieldx - ed_fieldx)
11237 if (lev_fieldx < ed_fieldx - 2)
11240 level_xpos += step;
11241 if (level_xpos > lev_fieldx - ed_fieldx + 1)
11242 level_xpos = lev_fieldx - ed_fieldx + 1;
11244 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
11246 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11248 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
11249 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
11253 case GADGET_ID_SCROLL_UP:
11254 if (level_ypos >= 0)
11256 if (lev_fieldy < ed_fieldy - 2)
11259 level_ypos -= step;
11260 if (level_ypos < -1)
11263 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
11265 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11267 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
11268 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
11272 case GADGET_ID_SCROLL_DOWN:
11273 if (level_ypos <= lev_fieldy - ed_fieldy)
11275 if (lev_fieldy < ed_fieldy - 2)
11278 level_ypos += step;
11279 if (level_ypos > lev_fieldy - ed_fieldy + 1)
11280 level_ypos = lev_fieldy - ed_fieldy + 1;
11282 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_UP);
11284 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11286 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
11287 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
11291 case GADGET_ID_SCROLL_HORIZONTAL:
11292 level_xpos = gi->event.item_position - 1;
11293 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11296 case GADGET_ID_SCROLL_VERTICAL:
11297 level_ypos = gi->event.item_position - 1;
11298 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11301 case GADGET_ID_SCROLL_LIST_UP:
11302 case GADGET_ID_SCROLL_LIST_DOWN:
11303 case GADGET_ID_SCROLL_LIST_VERTICAL:
11304 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
11305 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
11308 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
11309 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
11311 if (element_shift < 0)
11313 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
11314 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
11316 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
11317 GDI_SCROLLBAR_ITEM_POSITION,
11318 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
11321 ModifyEditorElementList();
11325 case GADGET_ID_WRAP_LEFT:
11326 WrapLevel(-step, 0);
11329 case GADGET_ID_WRAP_RIGHT:
11330 WrapLevel(step, 0);
11333 case GADGET_ID_WRAP_UP:
11334 WrapLevel(0, -step);
11337 case GADGET_ID_WRAP_DOWN:
11338 WrapLevel(0, step);
11341 case GADGET_ID_SINGLE_ITEMS:
11342 case GADGET_ID_CONNECTED_ITEMS:
11343 case GADGET_ID_LINE:
11344 case GADGET_ID_ARC:
11345 case GADGET_ID_TEXT:
11346 case GADGET_ID_RECTANGLE:
11347 case GADGET_ID_FILLED_BOX:
11348 case GADGET_ID_FLOOD_FILL:
11349 case GADGET_ID_GRAB_BRUSH:
11350 case GADGET_ID_PICK_ELEMENT:
11351 if (drawing_function != GADGET_ID_PICK_ELEMENT)
11352 last_drawing_function = drawing_function;
11353 drawing_function = id;
11354 draw_with_brush = FALSE;
11357 case GADGET_ID_RANDOM_PLACEMENT:
11358 RandomPlacement(new_element);
11361 case GADGET_ID_PROPERTIES:
11362 if (edit_mode != ED_MODE_PROPERTIES)
11364 properties_element = new_element;
11365 DrawPropertiesWindow();
11366 edit_mode = ED_MODE_PROPERTIES;
11368 last_level_drawing_function = drawing_function;
11369 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
11374 DrawDrawingWindow();
11375 edit_mode = ED_MODE_DRAWING;
11377 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
11382 case GADGET_ID_CUSTOM_COPY_FROM:
11383 case GADGET_ID_CUSTOM_COPY_TO:
11384 case GADGET_ID_CUSTOM_EXCHANGE:
11385 last_custom_copy_mode = id;
11386 last_drawing_function = drawing_function;
11389 case GADGET_ID_CUSTOM_COPY:
11390 CopyCustomElement(properties_element, -1, id);
11393 case GADGET_ID_CUSTOM_PASTE:
11394 CopyCustomElement(-1, properties_element, id);
11397 case GADGET_ID_UNDO:
11398 if (undo_buffer_steps == 0)
11400 Request("Undo buffer empty !", REQ_CONFIRM);
11404 if (edit_mode != ED_MODE_DRAWING)
11406 DrawDrawingWindow();
11407 edit_mode = ED_MODE_DRAWING;
11410 undo_buffer_position =
11411 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
11412 undo_buffer_steps--;
11414 for (x = 0; x < lev_fieldx; x++)
11415 for (y = 0; y < lev_fieldy; y++)
11416 Feld[x][y] = UndoBuffer[undo_buffer_position][x][y];
11418 /* check if undo operation forces change of border style */
11419 CheckLevelBorderElement(FALSE);
11421 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11425 case GADGET_ID_INFO:
11426 if (edit_mode != ED_MODE_INFO)
11428 last_edit_mode = edit_mode;
11429 edit_mode = ED_MODE_INFO;
11431 DrawLevelInfoWindow();
11435 edit_mode = last_edit_mode;
11437 DrawEditModeWindow();
11441 case GADGET_ID_CLEAR:
11442 if (edit_mode != ED_MODE_DRAWING)
11444 DrawDrawingWindow();
11445 edit_mode = ED_MODE_DRAWING;
11448 for (x = 0; x < MAX_LEV_FIELDX; x++)
11449 for (y = 0; y < MAX_LEV_FIELDY; y++)
11450 Feld[x][y] = (button == 1 ? EL_EMPTY : new_element);
11452 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
11454 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11457 case GADGET_ID_SAVE:
11459 /* saving read-only levels into personal level set modifies global vars
11460 "leveldir_current" and "level_nr"; restore them after saving level */
11461 LevelDirTree *leveldir_former = leveldir_current;
11462 int level_nr_former = level_nr;
11463 char *level_filename;
11466 if (leveldir_current->readonly &&
11467 !PrepareSavingIntoPersonalLevelSet())
11470 level_filename = getDefaultLevelFilename(level_nr);
11471 new_level = !fileExists(level_filename);
11474 Request("Save this level and kill the old ?", REQ_ASK))
11476 if (leveldir_former->readonly)
11477 ModifyLevelInfoForSavingIntoPersonalLevelSet(leveldir_former->name);
11479 CopyPlayfield(Feld, level.field);
11480 SaveLevel(level_nr);
11482 level.changed = FALSE;
11486 char level_saved_msg[64];
11488 if (leveldir_former->readonly)
11489 sprintf(level_saved_msg,
11490 "Level saved as level %d into personal level set !",
11493 strcpy(level_saved_msg, "Level saved !");
11495 Request(level_saved_msg, REQ_CONFIRM);
11499 /* "cd" back to copied-from levelset (in case of saved read-only level) */
11500 leveldir_current = leveldir_former;
11501 level_nr = level_nr_former;
11506 case GADGET_ID_TEST:
11507 if (LevelChanged())
11508 level.game_version = GAME_VERSION_ACTUAL;
11510 CopyPlayfield(level.field, FieldBackup);
11511 CopyPlayfield(Feld, level.field);
11513 CopyNativeLevel_RND_to_Native(&level);
11515 UnmapLevelEditorGadgets();
11516 UndrawSpecialEditorDoor();
11518 CloseDoor(DOOR_CLOSE_ALL);
11520 BackToFront(); /* force redraw of undrawn special door */
11523 DrawCompleteVideoDisplay();
11526 level_editor_test_game = TRUE;
11528 StartGameActions(FALSE, setup.autorecord, level.random_seed);
11532 case GADGET_ID_EXIT:
11533 RequestExitLevelEditor(TRUE, FALSE); /* if level has changed, ask user */
11537 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
11538 id <= GADGET_ID_ELEMENTLIST_LAST)
11540 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
11541 int new_element = editor_elements[element_position + element_shift];
11543 if (IS_EDITOR_CASCADE(new_element))
11547 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
11549 int *cascade_element= &(*editor_elements_info[i].headline_list)[0];
11550 boolean *cascade_value=editor_elements_info[i].setup_cascade_value;
11552 if (*cascade_element == new_element)
11554 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
11555 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
11557 /* update element selection list */
11558 ReinitializeElementList();
11559 ModifyEditorElementList();
11561 /* update cascading gadget info text */
11562 PrintEditorGadgetInfoText(level_editor_gadget[id]);
11564 /* save current editor cascading state */
11565 SaveSetup_EditorCascade();
11574 if (last_custom_copy_mode != -1)
11576 if (CopyCustomElement(properties_element, new_element,
11577 last_custom_copy_mode))
11579 ClickOnGadget(level_editor_gadget[last_drawing_function],
11582 last_custom_copy_mode = -1;
11588 PickDrawingElement(button, new_element);
11590 if (!stick_element_properties_window &&
11591 drawing_function != GADGET_ID_PICK_ELEMENT &&
11592 !(GetKeyModState() & KMOD_Control))
11594 properties_element = new_element;
11595 if (edit_mode == ED_MODE_PROPERTIES)
11596 DrawPropertiesWindow();
11599 if (drawing_function == GADGET_ID_PICK_ELEMENT)
11600 ClickOnGadget(level_editor_gadget[last_drawing_function],
11604 else if (gi->event.type == GD_EVENT_PRESSED)
11605 printf("default: HandleControlButtons: GD_EVENT_PRESSED(%d)\n", id);
11606 else if (gi->event.type == GD_EVENT_RELEASED)
11607 printf("default: HandleControlButtons: GD_EVENT_RELEASED(%d)\n", id);
11608 else if (gi->event.type == GD_EVENT_MOVING)
11609 printf("default: HandleControlButtons: GD_EVENT_MOVING(%d)\n", id);
11611 printf("default: HandleControlButtons: ? (id == %d)\n", id);
11617 void HandleLevelEditorKeyInput(Key key)
11619 char letter = getCharFromKey(key);
11620 int button = MB_LEFTBUTTON;
11622 if (drawing_function == GADGET_ID_TEXT &&
11623 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
11626 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
11627 else if (key == KSYM_Delete || key == KSYM_BackSpace)
11628 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
11629 else if (key == KSYM_Return)
11630 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
11631 else if (key == KSYM_Escape)
11632 DrawLevelText(0, 0, 0, TEXT_END);
11634 else if (button_status == MB_RELEASED)
11636 int id = GADGET_ID_NONE;
11637 int new_element_shift = element_shift;
11643 id = GADGET_ID_SCROLL_LEFT;
11646 id = GADGET_ID_SCROLL_RIGHT;
11649 id = GADGET_ID_SCROLL_UP;
11652 id = GADGET_ID_SCROLL_DOWN;
11655 id = GADGET_ID_SCROLL_LIST_UP;
11656 button = MB_RIGHTBUTTON;
11658 case KSYM_Page_Down:
11659 id = GADGET_ID_SCROLL_LIST_DOWN;
11660 button = MB_RIGHTBUTTON;
11665 element_shift = (key == KSYM_Home ? 0 :
11666 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
11668 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
11669 GDI_SCROLLBAR_ITEM_POSITION,
11670 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
11672 ModifyEditorElementList();
11679 /* this is needed to prevent interference with running "True X-Mouse" */
11680 if (GetKeyModStateFromEvents() & KMOD_Control)
11683 /* check for last or next editor cascade block in element list */
11684 for (i = 0; i < num_editor_elements; i++)
11686 if ((key == KSYM_Insert && i == element_shift) ||
11687 (key == KSYM_Delete && new_element_shift > element_shift))
11690 /* jump to next cascade block (or to start of element list) */
11691 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
11692 new_element_shift = i;
11695 if (i < num_editor_elements)
11696 element_shift = new_element_shift;
11698 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
11699 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
11701 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
11702 GDI_SCROLLBAR_ITEM_POSITION,
11703 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
11705 ModifyEditorElementList();
11710 if (edit_mode == ED_MODE_DRAWING)
11712 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
11714 else if (edit_mode == ED_MODE_INFO)
11716 HandleControlButtons(level_editor_gadget[GADGET_ID_INFO]);
11718 else if (edit_mode == ED_MODE_PROPERTIES)
11720 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
11722 else /* should never happen */
11724 DrawDrawingWindow();
11725 edit_mode = ED_MODE_DRAWING;
11734 if (id != GADGET_ID_NONE)
11735 ClickOnGadget(level_editor_gadget[id], button);
11736 else if (letter == '.')
11737 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
11738 else if (key == KSYM_Return ||
11739 key == KSYM_space ||
11740 key == setup.shortcut.toggle_pause)
11741 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
11743 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
11744 if (letter && letter == control_info[i].shortcut)
11745 if (!anyTextGadgetActive())
11746 ClickOnGadget(level_editor_gadget[i], button);
11750 void HandleLevelEditorIdle()
11752 static unsigned long action_delay = 0;
11753 unsigned long action_delay_value = GameFrameDelay;
11754 int xpos = 1, ypos = 2;
11757 if (edit_mode != ED_MODE_PROPERTIES)
11760 if (!DelayReached(&action_delay, action_delay_value))
11763 for (i = 0; i < ED_NUM_SELECTBOX; i++)
11765 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
11767 if (gi->mapped && gi->active && gi->selectbox.open)
11771 DrawEditorElementAnimation(SX + xpos * TILEX,
11772 SY + ypos * TILEY + MINI_TILEY / 2);
11774 MarkTileDirty(xpos, ypos);
11775 MarkTileDirty(xpos, ypos + 1);
11777 FrameCounter++; /* increase animation frame counter */
11780 void ClearEditorGadgetInfoText()
11782 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
11785 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
11787 char infotext[MAX_OUTPUT_LINESIZE + 1];
11788 char shortcut[MAX_OUTPUT_LINESIZE + 1];
11789 int max_infotext_len = getMaxInfoTextLength();
11791 if (gi == NULL || gi->info_text == NULL)
11794 strncpy(infotext, gi->info_text, max_infotext_len);
11795 infotext[max_infotext_len] = '\0';
11797 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
11799 int key = control_info[gi->custom_id].shortcut;
11803 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS) /* special case 1 */
11804 sprintf(shortcut, " ('.' or '%c')", key);
11805 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT) /* special case 2 */
11806 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
11807 else if (gi->custom_id == GADGET_ID_TEST) /* special case 3 */
11808 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
11809 else /* normal case */
11810 sprintf(shortcut, " ('%s%c')",
11811 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
11813 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
11814 strcat(infotext, shortcut);
11818 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, FONT_TEXT_2);
11821 void HandleEditorGadgetInfoText(void *ptr)
11823 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
11825 if (game_status != GAME_MODE_EDITOR)
11828 ClearEditorGadgetInfoText();
11830 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
11833 /* misuse this function to delete brush cursor, if needed */
11834 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
11835 DeleteBrushFromCursor();
11837 PrintEditorGadgetInfoText(gi);
11840 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
11842 static int start_lx, start_ly;
11843 int id = gi->custom_id;
11844 int type_id = gi->custom_type_id;
11845 int sx = gi->event.x;
11846 int sy = gi->event.y;
11847 int lx = sx + level_xpos;
11848 int ly = sy + level_ypos;
11849 int min_sx = 0, min_sy = 0;
11850 int max_sx = gi->drawing.area_xsize - 1;
11851 int max_sy = gi->drawing.area_ysize - 1;
11852 int actual_drawing_function = drawing_function;
11853 int max_infotext_len = getMaxInfoTextLength();
11854 char infotext[MAX_OUTPUT_LINESIZE + 1];
11857 infotext[0] = '\0'; /* start with empty info text */
11859 /* pressed Control key: simulate picking element */
11860 if (GetKeyModState() & KMOD_Control)
11861 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
11863 ClearEditorGadgetInfoText();
11865 if (gi->event.type == GD_EVENT_INFO_LEAVING)
11868 /* make sure to stay inside drawing area boundaries */
11869 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
11870 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
11872 if (id == GADGET_ID_DRAWING_LEVEL)
11876 int min_lx = 0, min_ly = 0;
11877 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
11879 /* get positions inside level field */
11880 lx = sx + level_xpos;
11881 ly = sy + level_ypos;
11883 /* make sure to stay inside level field boundaries */
11884 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
11885 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
11887 /* correct drawing area positions accordingly */
11888 sx = lx - level_xpos;
11889 sy = ly - level_ypos;
11892 if (IN_ED_FIELD(sx,sy) && IN_LEV_FIELD(lx, ly))
11894 if (button_status) /* if (gi->state == GD_BUTTON_PRESSED) */
11896 if (gi->event.type == GD_EVENT_PRESSED)
11902 switch (actual_drawing_function)
11904 case GADGET_ID_SINGLE_ITEMS:
11905 text = "Drawing single items";
11907 case GADGET_ID_CONNECTED_ITEMS:
11908 text = "Drawing connected items";
11910 case GADGET_ID_LINE:
11911 text = "Drawing line";
11913 case GADGET_ID_ARC:
11914 text = "Drawing arc";
11916 case GADGET_ID_TEXT:
11917 text = "Setting text cursor";
11919 case GADGET_ID_RECTANGLE:
11920 text = "Drawing rectangle";
11922 case GADGET_ID_FILLED_BOX:
11923 text = "Drawing filled box";
11925 case GADGET_ID_FLOOD_FILL:
11926 text = "Flood fill";
11928 case GADGET_ID_GRAB_BRUSH:
11929 text = "Grabbing brush";
11931 case GADGET_ID_PICK_ELEMENT:
11932 text = "Picking element";
11936 text = "Drawing position";
11940 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
11941 sprintf(infotext, "%s: %d, %d", text, lx, ly);
11943 sprintf(infotext, "%s: %d, %d", text,
11944 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
11946 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
11947 strncpy(infotext, getElementInfoText(Feld[lx][ly]), max_infotext_len);
11949 sprintf(infotext, "Level position: %d, %d", lx, ly);
11952 /* misuse this function to draw brush cursor, if needed */
11953 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
11955 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
11956 CopyBrushToCursor(sx, sy);
11958 DeleteBrushFromCursor();
11961 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
11963 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
11964 int element = drawingarea_info[type_id].value[pos];
11966 strncpy(infotext, getElementInfoText(element), max_infotext_len);
11970 if (id == GADGET_ID_CUSTOM_CONTENT)
11971 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
11972 else if (id == GADGET_ID_GROUP_CONTENT)
11973 sprintf(infotext, "group element position: %d", sx + 1);
11974 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
11975 id <= GADGET_ID_YAMYAM_CONTENT_7)
11976 sprintf(infotext, "content area %d position: %d, %d",
11977 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
11978 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
11979 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
11980 sprintf(infotext, "content area %d position: %d, %d",
11981 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
11982 else if (id == GADGET_ID_ANDROID_CONTENT)
11983 sprintf(infotext, "android element position: %d", sx + 1);
11984 else if (drawingarea_info[type_id].infotext != NULL)
11985 strcpy(infotext, drawingarea_info[type_id].infotext);
11988 infotext[max_infotext_len] = '\0';
11990 if (strlen(infotext) > 0)
11991 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, infotext);
11994 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
11995 boolean quick_quit)
11997 if (!ask_if_level_has_changed ||
11999 Request("Level has changed ! Exit without saving ?",
12000 REQ_ASK | REQ_STAY_OPEN))
12002 CloseDoor(DOOR_CLOSE_1);
12003 SetDoorState(DOOR_CLOSE_2);
12007 FadeSkipNextFadeIn();
12010 fading = fading_none;
12013 game_status = GAME_MODE_MAIN;
12015 DrawAndFadeInMainMenu(REDRAW_FIELD);
12022 CloseDoor(DOOR_CLOSE_1);
12023 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);