1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-2002 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
16 #include "libgame/libgame.h"
27 #define INFOTEXT_UNKNOWN_ELEMENT "unknown"
31 -----------------------------------------------------------------------------
32 screen and artwork graphic pixel position definitions
33 -----------------------------------------------------------------------------
36 /* positions in the level editor */
37 #define ED_WIN_MB_LEFT_XPOS 6
38 #define ED_WIN_MB_LEFT_YPOS 258
39 #define ED_WIN_MB_MIDDLE_XPOS 42
40 #define ED_WIN_MB_MIDDLE_YPOS ED_WIN_MB_LEFT_YPOS
41 #define ED_WIN_MB_RIGHT_XPOS 78
42 #define ED_WIN_MB_RIGHT_YPOS ED_WIN_MB_LEFT_YPOS
44 /* values for the control window */
45 #define ED_CTRL_NO_BUTTONS_GFX_XPOS 6
46 #define ED_CTRL_NO_BUTTONS_GFX_YPOS 286
47 #define ED_CTRL1_BUTTONS_GFX_YPOS 236
48 #define ED_CTRL2_BUTTONS_GFX_YPOS 236
49 #define ED_CTRL3_BUTTONS_GFX_YPOS 324
50 #define ED_CTRL4_BUTTONS_GFX_XPOS 44
51 #define ED_CTRL4_BUTTONS_GFX_YPOS 214
52 #define ED_CTRL1_BUTTONS_ALT_GFX_YPOS 142
53 #define ED_CTRL3_BUTTONS_ALT_GFX_YPOS 302
55 #define ED_CTRL1_BUTTON_XSIZE 22
56 #define ED_CTRL1_BUTTON_YSIZE 22
57 #define ED_CTRL1_BUTTONS_XPOS 6
58 #define ED_CTRL1_BUTTONS_YPOS 6
59 #define ED_CTRL2_BUTTON_XSIZE 30
60 #define ED_CTRL2_BUTTON_YSIZE 20
61 #define ED_CTRL2_BUTTONS_XPOS 5
62 #define ED_CTRL2_BUTTONS_YPOS 99
63 #define ED_CTRL3_BUTTON_XSIZE 22
64 #define ED_CTRL3_BUTTON_YSIZE 22
65 #define ED_CTRL3_BUTTONS_XPOS 6
66 #define ED_CTRL3_BUTTONS_YPOS 6
67 #define ED_CTRL4_BUTTON_XSIZE 22
68 #define ED_CTRL4_BUTTON_YSIZE 22
69 #define ED_CTRL4_BUTTONS_XPOS 6
70 #define ED_CTRL4_BUTTONS_YPOS 6
72 #define ED_CTRL1_BUTTONS_HORIZ 4
73 #define ED_CTRL1_BUTTONS_VERT 4
74 #define ED_CTRL2_BUTTONS_HORIZ 3
75 #define ED_CTRL2_BUTTONS_VERT 2
76 #define ED_CTRL3_BUTTONS_HORIZ 3
77 #define ED_CTRL3_BUTTONS_VERT 1
78 #define ED_CTRL4_BUTTONS_HORIZ 2
79 #define ED_CTRL4_BUTTONS_VERT 1
81 #define ED_NUM_CTRL1_BUTTONS (ED_CTRL1_BUTTONS_HORIZ * ED_CTRL1_BUTTONS_VERT)
82 #define ED_NUM_CTRL2_BUTTONS (ED_CTRL2_BUTTONS_HORIZ * ED_CTRL2_BUTTONS_VERT)
83 #define ED_NUM_CTRL3_BUTTONS (ED_CTRL3_BUTTONS_HORIZ * ED_CTRL3_BUTTONS_VERT)
84 #define ED_NUM_CTRL4_BUTTONS (ED_CTRL4_BUTTONS_HORIZ * ED_CTRL4_BUTTONS_VERT)
85 #define ED_NUM_CTRL1_2_BUTTONS (ED_NUM_CTRL1_BUTTONS + ED_NUM_CTRL2_BUTTONS)
86 #define ED_NUM_CTRL1_3_BUTTONS (ED_NUM_CTRL1_2_BUTTONS + ED_NUM_CTRL3_BUTTONS)
87 #define ED_NUM_CTRL_BUTTONS (ED_NUM_CTRL1_BUTTONS + \
88 ED_NUM_CTRL2_BUTTONS + \
89 ED_NUM_CTRL3_BUTTONS + \
92 /* values for the element list */
93 #define ED_ELEMENTLIST_XPOS 5
94 #define ED_ELEMENTLIST_YPOS 30
95 #define ED_ELEMENTLIST_XSIZE 20
96 #define ED_ELEMENTLIST_YSIZE 20
97 #define ED_ELEMENTLIST_BUTTONS_HORIZ 4
98 #define ED_ELEMENTLIST_BUTTONS_VERT 11
99 #define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \
100 ED_ELEMENTLIST_BUTTONS_VERT)
102 /* standard distances */
103 #define ED_BORDER_SIZE 3
104 #define ED_BORDER_TEXT_XSIZE 5
105 #define ED_BORDER_AREA_YSIZE 1
107 #define ED_GADGET_DISTANCE 2
108 #define ED_GADGET_TEXT_DISTANCE (2 * ED_GADGET_DISTANCE)
109 #define ED_DRAWINGAREA_TEXT_DISTANCE (ED_GADGET_TEXT_DISTANCE + \
112 /* values for the settings windows */
113 #define ED_LEVEL_SETTINGS_XSTART (3 * MINI_TILEX / 2)
114 #define ED_LEVEL_SETTINGS_YSTART (5 * MINI_TILEY)
116 #define ED_ELEMENT_SETTINGS_XSTART (3 * MINI_TILEX / 2)
117 #define ED_ELEMENT_SETTINGS_YSTART (10 * MINI_TILEY)
119 #define ED_XOFFSET_CHECKBOX (ED_CHECKBUTTON_XSIZE + \
120 2 * ED_GADGET_DISTANCE)
122 #define ED_SETTINGS_XOFFSET ED_XOFFSET_CHECKBOX
123 #define ED_SETTINGS_YOFFSET (3 * MINI_TILEY / 2)
125 #define ED_LEVEL_SETTINGS_XPOS(n) (ED_LEVEL_SETTINGS_XSTART + \
126 (n) * ED_SETTINGS_XOFFSET)
127 #define ED_LEVEL_SETTINGS_YPOS(n) (ED_LEVEL_SETTINGS_YSTART + \
128 (n) * ED_SETTINGS_YOFFSET)
130 #define ED_ELEMENT_SETTINGS_XPOS(n) (ED_ELEMENT_SETTINGS_XSTART + \
131 (n) * ED_SETTINGS_XOFFSET)
132 #define ED_ELEMENT_SETTINGS_YPOS(n) (ED_ELEMENT_SETTINGS_YSTART + \
133 (n) * ED_SETTINGS_YOFFSET)
135 #define ED_SETTINGS1_YPOS MINI_TILEY
136 #define ED_SETTINGS2_XPOS MINI_TILEX
137 #define ED_SETTINGS2_YPOS (ED_SETTINGS1_YPOS + 12 * TILEY - 2)
139 /* values for counter gadgets */
140 #define ED_COUNTER_YSTART (ED_SETTINGS1_YPOS + 2 * TILEY)
141 #define ED_COUNTER_YDISTANCE (3 * MINI_TILEY)
142 #define ED_COUNTER_YPOS(n) (ED_COUNTER_YSTART + \
143 (n) * ED_COUNTER_YDISTANCE)
144 #define ED_COUNTER2_YPOS(n) (ED_COUNTER_YSTART + \
145 (n) * ED_COUNTER_YDISTANCE - 2)
147 /* values for element content drawing areas */
148 #define ED_AREA_1X1_SETTINGS_XPOS(n) (ED_ELEMENT_SETTINGS_XPOS(n))
149 #define ED_AREA_1X1_SETTINGS_YPOS(n) (ED_ELEMENT_SETTINGS_YPOS(n) + \
152 #define ED_AREA_3X3_SETTINGS_XPOS(n) (ED_ELEMENT_SETTINGS_XPOS(n))
153 #define ED_AREA_3X3_SETTINGS_YPOS(n) (ED_ELEMENT_SETTINGS_YPOS(n) + \
154 ED_GADGET_DISTANCE - MINI_TILEY)
157 #define ED_AREA_YAMYAM_CONTENT_XPOS(n) (2 * MINI_TILEX + \
158 5 * ((n) % 4) * MINI_TILEX)
159 #define ED_AREA_YAMYAM_CONTENT_YPOS(n) (11 * ED_SETTINGS_YOFFSET + \
160 6 * ((n) / 4) * MINI_TILEY)
162 /* magic ball content */
163 #define ED_AREA_MAGIC_BALL_CONTENT_XPOS(n) (2 * MINI_TILEX + \
164 5 * ((n) % 4) * MINI_TILEX)
165 #define ED_AREA_MAGIC_BALL_CONTENT_YPOS(n) (12 * ED_SETTINGS_YOFFSET + \
166 6 * ((n) / 4) * MINI_TILEY)
168 /* values for scrolling gadgets for drawing area */
169 #define ED_SCROLLBUTTON_XPOS 24
170 #define ED_SCROLLBUTTON_YPOS 0
171 #define ED_SCROLLBAR_XPOS 24
172 #define ED_SCROLLBAR_YPOS 64
174 #define ED_SCROLLBUTTON_XSIZE 16
175 #define ED_SCROLLBUTTON_YSIZE 16
177 #define ED_SCROLL_UP_XPOS (SXSIZE - ED_SCROLLBUTTON_XSIZE)
178 #define ED_SCROLL_UP_YPOS (0)
179 #define ED_SCROLL_DOWN_XPOS ED_SCROLL_UP_XPOS
180 #define ED_SCROLL_DOWN_YPOS (SYSIZE - 3 * ED_SCROLLBUTTON_YSIZE)
181 #define ED_SCROLL_LEFT_XPOS (0)
182 #define ED_SCROLL_LEFT_YPOS (SYSIZE - 2 * ED_SCROLLBUTTON_YSIZE)
183 #define ED_SCROLL_RIGHT_XPOS (SXSIZE - 2 * ED_SCROLLBUTTON_XSIZE)
184 #define ED_SCROLL_RIGHT_YPOS ED_SCROLL_LEFT_YPOS
185 #define ED_SCROLL_HORIZONTAL_XPOS (ED_SCROLL_LEFT_XPOS + \
186 ED_SCROLLBUTTON_XSIZE)
187 #define ED_SCROLL_HORIZONTAL_YPOS ED_SCROLL_LEFT_YPOS
188 #define ED_SCROLL_HORIZONTAL_XSIZE (SXSIZE - 3 * ED_SCROLLBUTTON_XSIZE)
189 #define ED_SCROLL_HORIZONTAL_YSIZE ED_SCROLLBUTTON_YSIZE
190 #define ED_SCROLL_VERTICAL_XPOS ED_SCROLL_UP_XPOS
191 #define ED_SCROLL_VERTICAL_YPOS (ED_SCROLL_UP_YPOS + \
192 ED_SCROLLBUTTON_YSIZE)
193 #define ED_SCROLL_VERTICAL_XSIZE ED_SCROLLBUTTON_XSIZE
194 #define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - 4 * ED_SCROLLBUTTON_YSIZE)
196 /* values for scrolling gadgets for element list */
197 #define ED_SCROLLBUTTON2_XPOS 50
198 #define ED_SCROLLBUTTON2_YPOS 0
199 #define ED_SCROLLBAR2_XPOS 50
200 #define ED_SCROLLBAR2_YPOS 20
202 #define ED_SCROLLBUTTON2_XSIZE 10
203 #define ED_SCROLLBUTTON2_YSIZE 10
205 #define ED_SCROLL2_UP_XPOS 85
206 #define ED_SCROLL2_UP_YPOS 30
207 #define ED_SCROLL2_DOWN_XPOS ED_SCROLL2_UP_XPOS
208 #define ED_SCROLL2_DOWN_YPOS (ED_SCROLL2_UP_YPOS + \
209 ED_ELEMENTLIST_BUTTONS_VERT * \
210 ED_ELEMENTLIST_YSIZE - \
211 ED_SCROLLBUTTON2_YSIZE)
212 #define ED_SCROLL2_VERTICAL_XPOS ED_SCROLL2_UP_XPOS
213 #define ED_SCROLL2_VERTICAL_YPOS (ED_SCROLL2_UP_YPOS + \
214 ED_SCROLLBUTTON2_YSIZE)
215 #define ED_SCROLL2_VERTICAL_XSIZE ED_SCROLLBUTTON2_XSIZE
216 #define ED_SCROLL2_VERTICAL_YSIZE (ED_ELEMENTLIST_BUTTONS_VERT * \
217 ED_ELEMENTLIST_YSIZE - \
218 2 * ED_SCROLLBUTTON2_YSIZE)
220 /* values for checkbutton gadgets */
221 #define ED_CHECKBUTTON_XSIZE ED_BUTTON_COUNT_XSIZE
222 #define ED_CHECKBUTTON_YSIZE ED_BUTTON_COUNT_YSIZE
223 #define ED_CHECKBUTTON_UNCHECKED_XPOS ED_BUTTON_MINUS_XPOS
224 #define ED_CHECKBUTTON_CHECKED_XPOS ED_BUTTON_PLUS_XPOS
225 #define ED_CHECKBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 22)
226 #define ED_RADIOBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 44)
227 #define ED_STICKYBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 66)
229 /* values for some special graphic buttons */
230 #define ED_COPY_CHANGE_PAGE_XPOS 25
231 #define ED_COPY_CHANGE_PAGE_YPOS 50
232 #define ED_PASTE_CHANGE_PAGE_XPOS 25
233 #define ED_PASTE_CHANGE_PAGE_YPOS 70
235 /* some values for text input, selectbox and counter gadgets */
236 #define ED_BUTTON_COUNT_YPOS 60
237 #define ED_BUTTON_COUNT_XSIZE 20
238 #define ED_BUTTON_COUNT_YSIZE 20
239 #define ED_WIN_COUNT_XPOS (2 + ED_BUTTON_COUNT_XSIZE + 2)
240 #define ED_WIN_COUNT_YPOS ED_BUTTON_COUNT_YPOS
241 #define ED_WIN_COUNT_XSIZE 52
242 #define ED_WIN_COUNT_YSIZE ED_BUTTON_COUNT_YSIZE
243 #define ED_WIN_COUNT2_XPOS 27
244 #define ED_WIN_COUNT2_YPOS 3
245 #define ED_WIN_COUNT2_XSIZE 46
246 #define ED_WIN_COUNT2_YSIZE ED_BUTTON_COUNT_YSIZE
248 #define ED_BUTTON_MINUS_XPOS 2
249 #define ED_BUTTON_MINUS_YPOS ED_BUTTON_COUNT_YPOS
250 #define ED_BUTTON_MINUS_XSIZE ED_BUTTON_COUNT_XSIZE
251 #define ED_BUTTON_MINUS_YSIZE ED_BUTTON_COUNT_YSIZE
252 #define ED_BUTTON_PLUS_XPOS (ED_WIN_COUNT_XPOS + \
253 ED_WIN_COUNT_XSIZE + 2)
254 #define ED_BUTTON_PLUS_YPOS ED_BUTTON_COUNT_YPOS
255 #define ED_BUTTON_PLUS_XSIZE ED_BUTTON_COUNT_XSIZE
256 #define ED_BUTTON_PLUS_YSIZE ED_BUTTON_COUNT_YSIZE
258 #define ED_SELECTBOX_XPOS ED_WIN_COUNT_XPOS
259 #define ED_SELECTBOX_YPOS (ED_WIN_COUNT_YPOS + \
260 2 + ED_WIN_COUNT_YSIZE)
261 #define ED_SELECTBOX_XSIZE ED_WIN_COUNT_XSIZE
262 #define ED_SELECTBOX_YSIZE ED_WIN_COUNT_YSIZE
264 #define ED_SELECTBOX_BUTTON_XSIZE 14
266 #define ED_TEXTBUTTON_XPOS ED_WIN_COUNT_XPOS
267 #define ED_TEXTBUTTON_YPOS (ED_WIN_COUNT_YPOS + \
268 4 * (2 + ED_WIN_COUNT_YSIZE))
269 #define ED_TEXTBUTTON_INACTIVE_YPOS ED_TEXTBUTTON_YPOS
271 #define ED_TEXTBUTTON_TAB_XPOS ED_WIN_COUNT_XPOS
272 #define ED_TEXTBUTTON_TAB_YPOS (ED_WIN_COUNT_YPOS + \
273 2 * (2 + ED_WIN_COUNT_YSIZE))
274 #define ED_TEXTBUTTON_TAB_INACTIVE_YPOS (ED_WIN_COUNT_YPOS + \
275 3 * (2 + ED_WIN_COUNT_YSIZE))
277 #define ED_TEXTBUTTON_XSIZE ED_WIN_COUNT_XSIZE
278 #define ED_TEXTBUTTON_YSIZE ED_WIN_COUNT_YSIZE
280 /* values for ClearEditorGadgetInfoText() and HandleEditorGadgetInfoText() */
281 #define INFOTEXT_XPOS SX
282 #define INFOTEXT_YPOS (SY + SYSIZE - MINI_TILEX + 2)
283 #define INFOTEXT_XSIZE SXSIZE
284 #define INFOTEXT_YSIZE MINI_TILEX
288 -----------------------------------------------------------------------------
289 editor gadget definitions
290 -----------------------------------------------------------------------------
293 /* drawing toolbox buttons */
294 #define GADGET_ID_NONE -1
295 #define GADGET_ID_TOOLBOX_FIRST 0
297 #define GADGET_ID_SINGLE_ITEMS (GADGET_ID_TOOLBOX_FIRST + 0)
298 #define GADGET_ID_CONNECTED_ITEMS (GADGET_ID_TOOLBOX_FIRST + 1)
299 #define GADGET_ID_LINE (GADGET_ID_TOOLBOX_FIRST + 2)
300 #define GADGET_ID_ARC (GADGET_ID_TOOLBOX_FIRST + 3)
301 #define GADGET_ID_RECTANGLE (GADGET_ID_TOOLBOX_FIRST + 4)
302 #define GADGET_ID_FILLED_BOX (GADGET_ID_TOOLBOX_FIRST + 5)
303 #define GADGET_ID_WRAP_UP (GADGET_ID_TOOLBOX_FIRST + 6)
304 #define GADGET_ID_TEXT (GADGET_ID_TOOLBOX_FIRST + 7)
305 #define GADGET_ID_FLOOD_FILL (GADGET_ID_TOOLBOX_FIRST + 8)
306 #define GADGET_ID_WRAP_LEFT (GADGET_ID_TOOLBOX_FIRST + 9)
307 #define GADGET_ID_PROPERTIES (GADGET_ID_TOOLBOX_FIRST + 10)
308 #define GADGET_ID_WRAP_RIGHT (GADGET_ID_TOOLBOX_FIRST + 11)
309 #define GADGET_ID_RANDOM_PLACEMENT (GADGET_ID_TOOLBOX_FIRST + 12)
310 #define GADGET_ID_GRAB_BRUSH (GADGET_ID_TOOLBOX_FIRST + 13)
311 #define GADGET_ID_WRAP_DOWN (GADGET_ID_TOOLBOX_FIRST + 14)
312 #define GADGET_ID_PICK_ELEMENT (GADGET_ID_TOOLBOX_FIRST + 15)
314 #define GADGET_ID_UNDO (GADGET_ID_TOOLBOX_FIRST + 16)
315 #define GADGET_ID_INFO (GADGET_ID_TOOLBOX_FIRST + 17)
316 #define GADGET_ID_SAVE (GADGET_ID_TOOLBOX_FIRST + 18)
317 #define GADGET_ID_CLEAR (GADGET_ID_TOOLBOX_FIRST + 19)
318 #define GADGET_ID_TEST (GADGET_ID_TOOLBOX_FIRST + 20)
319 #define GADGET_ID_EXIT (GADGET_ID_TOOLBOX_FIRST + 21)
321 #define GADGET_ID_CUSTOM_COPY_FROM (GADGET_ID_TOOLBOX_FIRST + 22)
322 #define GADGET_ID_CUSTOM_COPY_TO (GADGET_ID_TOOLBOX_FIRST + 23)
323 #define GADGET_ID_CUSTOM_EXCHANGE (GADGET_ID_TOOLBOX_FIRST + 24)
324 #define GADGET_ID_CUSTOM_COPY (GADGET_ID_TOOLBOX_FIRST + 25)
325 #define GADGET_ID_CUSTOM_PASTE (GADGET_ID_TOOLBOX_FIRST + 26)
327 /* counter button identifiers */
328 #define GADGET_ID_COUNTER_FIRST (GADGET_ID_TOOLBOX_FIRST + 27)
330 #define GADGET_ID_SELECT_LEVEL_DOWN (GADGET_ID_COUNTER_FIRST + 0)
331 #define GADGET_ID_SELECT_LEVEL_TEXT (GADGET_ID_COUNTER_FIRST + 1)
332 #define GADGET_ID_SELECT_LEVEL_UP (GADGET_ID_COUNTER_FIRST + 2)
333 #define GADGET_ID_LEVEL_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 3)
334 #define GADGET_ID_LEVEL_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 4)
335 #define GADGET_ID_LEVEL_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 5)
336 #define GADGET_ID_LEVEL_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 6)
337 #define GADGET_ID_LEVEL_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 7)
338 #define GADGET_ID_LEVEL_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 8)
339 #define GADGET_ID_LEVEL_RANDOM_DOWN (GADGET_ID_COUNTER_FIRST + 9)
340 #define GADGET_ID_LEVEL_RANDOM_TEXT (GADGET_ID_COUNTER_FIRST + 10)
341 #define GADGET_ID_LEVEL_RANDOM_UP (GADGET_ID_COUNTER_FIRST + 11)
342 #define GADGET_ID_LEVEL_GEMSLIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 12)
343 #define GADGET_ID_LEVEL_GEMSLIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 13)
344 #define GADGET_ID_LEVEL_GEMSLIMIT_UP (GADGET_ID_COUNTER_FIRST + 14)
345 #define GADGET_ID_LEVEL_TIMELIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 15)
346 #define GADGET_ID_LEVEL_TIMELIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 16)
347 #define GADGET_ID_LEVEL_TIMELIMIT_UP (GADGET_ID_COUNTER_FIRST + 17)
348 #define GADGET_ID_LEVEL_TIMESCORE_DOWN (GADGET_ID_COUNTER_FIRST + 18)
349 #define GADGET_ID_LEVEL_TIMESCORE_TEXT (GADGET_ID_COUNTER_FIRST + 19)
350 #define GADGET_ID_LEVEL_TIMESCORE_UP (GADGET_ID_COUNTER_FIRST + 20)
351 #define GADGET_ID_ELEMENT_VALUE1_DOWN (GADGET_ID_COUNTER_FIRST + 21)
352 #define GADGET_ID_ELEMENT_VALUE1_TEXT (GADGET_ID_COUNTER_FIRST + 22)
353 #define GADGET_ID_ELEMENT_VALUE1_UP (GADGET_ID_COUNTER_FIRST + 23)
354 #define GADGET_ID_ELEMENT_VALUE2_DOWN (GADGET_ID_COUNTER_FIRST + 24)
355 #define GADGET_ID_ELEMENT_VALUE2_TEXT (GADGET_ID_COUNTER_FIRST + 25)
356 #define GADGET_ID_ELEMENT_VALUE2_UP (GADGET_ID_COUNTER_FIRST + 26)
357 #define GADGET_ID_ELEMENT_VALUE3_DOWN (GADGET_ID_COUNTER_FIRST + 27)
358 #define GADGET_ID_ELEMENT_VALUE3_TEXT (GADGET_ID_COUNTER_FIRST + 28)
359 #define GADGET_ID_ELEMENT_VALUE3_UP (GADGET_ID_COUNTER_FIRST + 29)
360 #define GADGET_ID_ELEMENT_VALUE4_DOWN (GADGET_ID_COUNTER_FIRST + 30)
361 #define GADGET_ID_ELEMENT_VALUE4_TEXT (GADGET_ID_COUNTER_FIRST + 31)
362 #define GADGET_ID_ELEMENT_VALUE4_UP (GADGET_ID_COUNTER_FIRST + 32)
363 #define GADGET_ID_YAMYAM_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 33)
364 #define GADGET_ID_YAMYAM_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 34)
365 #define GADGET_ID_YAMYAM_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 35)
366 #define GADGET_ID_BALL_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 36)
367 #define GADGET_ID_BALL_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 37)
368 #define GADGET_ID_BALL_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 38)
369 #define GADGET_ID_ENVELOPE_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 39)
370 #define GADGET_ID_ENVELOPE_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 40)
371 #define GADGET_ID_ENVELOPE_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 41)
372 #define GADGET_ID_ENVELOPE_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 42)
373 #define GADGET_ID_ENVELOPE_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 43)
374 #define GADGET_ID_ENVELOPE_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 44)
375 #define GADGET_ID_CUSTOM_SCORE_DOWN (GADGET_ID_COUNTER_FIRST + 45)
376 #define GADGET_ID_CUSTOM_SCORE_TEXT (GADGET_ID_COUNTER_FIRST + 46)
377 #define GADGET_ID_CUSTOM_SCORE_UP (GADGET_ID_COUNTER_FIRST + 47)
378 #define GADGET_ID_CUSTOM_GEMCOUNT_DOWN (GADGET_ID_COUNTER_FIRST + 48)
379 #define GADGET_ID_CUSTOM_GEMCOUNT_TEXT (GADGET_ID_COUNTER_FIRST + 49)
380 #define GADGET_ID_CUSTOM_GEMCOUNT_UP (GADGET_ID_COUNTER_FIRST + 50)
381 #define GADGET_ID_CUSTOM_VALUE_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 51)
382 #define GADGET_ID_CUSTOM_VALUE_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 52)
383 #define GADGET_ID_CUSTOM_VALUE_FIX_UP (GADGET_ID_COUNTER_FIRST + 53)
384 #define GADGET_ID_CUSTOM_VALUE_RND_DOWN (GADGET_ID_COUNTER_FIRST + 54)
385 #define GADGET_ID_CUSTOM_VALUE_RND_TEXT (GADGET_ID_COUNTER_FIRST + 55)
386 #define GADGET_ID_CUSTOM_VALUE_RND_UP (GADGET_ID_COUNTER_FIRST + 56)
387 #define GADGET_ID_PUSH_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 57)
388 #define GADGET_ID_PUSH_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 58)
389 #define GADGET_ID_PUSH_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 59)
390 #define GADGET_ID_PUSH_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 60)
391 #define GADGET_ID_PUSH_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 61)
392 #define GADGET_ID_PUSH_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 62)
393 #define GADGET_ID_DROP_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 63)
394 #define GADGET_ID_DROP_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 64)
395 #define GADGET_ID_DROP_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 65)
396 #define GADGET_ID_DROP_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 66)
397 #define GADGET_ID_DROP_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 67)
398 #define GADGET_ID_DROP_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 68)
399 #define GADGET_ID_MOVE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 69)
400 #define GADGET_ID_MOVE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 70)
401 #define GADGET_ID_MOVE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 71)
402 #define GADGET_ID_MOVE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 72)
403 #define GADGET_ID_MOVE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 73)
404 #define GADGET_ID_MOVE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 74)
405 #define GADGET_ID_EXPLOSION_DELAY_DOWN (GADGET_ID_COUNTER_FIRST + 75)
406 #define GADGET_ID_EXPLOSION_DELAY_TEXT (GADGET_ID_COUNTER_FIRST + 76)
407 #define GADGET_ID_EXPLOSION_DELAY_UP (GADGET_ID_COUNTER_FIRST + 77)
408 #define GADGET_ID_IGNITION_DELAY_DOWN (GADGET_ID_COUNTER_FIRST + 78)
409 #define GADGET_ID_IGNITION_DELAY_TEXT (GADGET_ID_COUNTER_FIRST + 79)
410 #define GADGET_ID_IGNITION_DELAY_UP (GADGET_ID_COUNTER_FIRST + 80)
411 #define GADGET_ID_CHANGE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 81)
412 #define GADGET_ID_CHANGE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 82)
413 #define GADGET_ID_CHANGE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 83)
414 #define GADGET_ID_CHANGE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 84)
415 #define GADGET_ID_CHANGE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 85)
416 #define GADGET_ID_CHANGE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 86)
417 #define GADGET_ID_CHANGE_CONT_RND_DOWN (GADGET_ID_COUNTER_FIRST + 87)
418 #define GADGET_ID_CHANGE_CONT_RND_TEXT (GADGET_ID_COUNTER_FIRST + 88)
419 #define GADGET_ID_CHANGE_CONT_RND_UP (GADGET_ID_COUNTER_FIRST + 89)
420 #define GADGET_ID_GROUP_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 90)
421 #define GADGET_ID_GROUP_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 91)
422 #define GADGET_ID_GROUP_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 92)
424 /* drawing area identifiers */
425 #define GADGET_ID_DRAWING_AREA_FIRST (GADGET_ID_COUNTER_FIRST + 93)
427 #define GADGET_ID_DRAWING_LEVEL (GADGET_ID_DRAWING_AREA_FIRST + 0)
428 #define GADGET_ID_YAMYAM_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 1)
429 #define GADGET_ID_YAMYAM_CONTENT_1 (GADGET_ID_DRAWING_AREA_FIRST + 2)
430 #define GADGET_ID_YAMYAM_CONTENT_2 (GADGET_ID_DRAWING_AREA_FIRST + 3)
431 #define GADGET_ID_YAMYAM_CONTENT_3 (GADGET_ID_DRAWING_AREA_FIRST + 4)
432 #define GADGET_ID_YAMYAM_CONTENT_4 (GADGET_ID_DRAWING_AREA_FIRST + 5)
433 #define GADGET_ID_YAMYAM_CONTENT_5 (GADGET_ID_DRAWING_AREA_FIRST + 6)
434 #define GADGET_ID_YAMYAM_CONTENT_6 (GADGET_ID_DRAWING_AREA_FIRST + 7)
435 #define GADGET_ID_YAMYAM_CONTENT_7 (GADGET_ID_DRAWING_AREA_FIRST + 8)
436 #define GADGET_ID_MAGIC_BALL_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 9)
437 #define GADGET_ID_MAGIC_BALL_CONTENT_1 (GADGET_ID_DRAWING_AREA_FIRST + 10)
438 #define GADGET_ID_MAGIC_BALL_CONTENT_2 (GADGET_ID_DRAWING_AREA_FIRST + 11)
439 #define GADGET_ID_MAGIC_BALL_CONTENT_3 (GADGET_ID_DRAWING_AREA_FIRST + 12)
440 #define GADGET_ID_MAGIC_BALL_CONTENT_4 (GADGET_ID_DRAWING_AREA_FIRST + 13)
441 #define GADGET_ID_MAGIC_BALL_CONTENT_5 (GADGET_ID_DRAWING_AREA_FIRST + 14)
442 #define GADGET_ID_MAGIC_BALL_CONTENT_6 (GADGET_ID_DRAWING_AREA_FIRST + 15)
443 #define GADGET_ID_MAGIC_BALL_CONTENT_7 (GADGET_ID_DRAWING_AREA_FIRST + 16)
444 #define GADGET_ID_AMOEBA_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 17)
445 #define GADGET_ID_START_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 18)
446 #define GADGET_ID_ARTWORK_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 19)
447 #define GADGET_ID_EXPLOSION_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 20)
448 #define GADGET_ID_CUSTOM_GRAPHIC (GADGET_ID_DRAWING_AREA_FIRST + 21)
449 #define GADGET_ID_CUSTOM_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 22)
450 #define GADGET_ID_CUSTOM_MOVE_ENTER (GADGET_ID_DRAWING_AREA_FIRST + 23)
451 #define GADGET_ID_CUSTOM_MOVE_LEAVE (GADGET_ID_DRAWING_AREA_FIRST + 24)
452 #define GADGET_ID_CUSTOM_CHANGE_TARGET (GADGET_ID_DRAWING_AREA_FIRST + 25)
453 #define GADGET_ID_CUSTOM_CHANGE_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 26)
454 #define GADGET_ID_CUSTOM_CHANGE_TRIGGER (GADGET_ID_DRAWING_AREA_FIRST + 27)
455 #define GADGET_ID_GROUP_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 28)
456 #define GADGET_ID_RANDOM_BACKGROUND (GADGET_ID_DRAWING_AREA_FIRST + 29)
458 /* text input identifiers */
459 #define GADGET_ID_TEXT_INPUT_FIRST (GADGET_ID_DRAWING_AREA_FIRST + 30)
461 #define GADGET_ID_LEVEL_NAME (GADGET_ID_TEXT_INPUT_FIRST + 0)
462 #define GADGET_ID_LEVEL_AUTHOR (GADGET_ID_TEXT_INPUT_FIRST + 1)
463 #define GADGET_ID_ELEMENT_NAME (GADGET_ID_TEXT_INPUT_FIRST + 2)
465 /* text area identifiers */
466 #define GADGET_ID_TEXT_AREA_FIRST (GADGET_ID_TEXT_INPUT_FIRST + 3)
468 #define GADGET_ID_ENVELOPE_INFO (GADGET_ID_TEXT_AREA_FIRST + 0)
470 /* selectbox identifiers */
471 #define GADGET_ID_SELECTBOX_FIRST (GADGET_ID_TEXT_AREA_FIRST + 1)
473 #define GADGET_ID_TIME_OR_STEPS (GADGET_ID_SELECTBOX_FIRST + 0)
474 #define GADGET_ID_GAME_ENGINE_TYPE (GADGET_ID_SELECTBOX_FIRST + 1)
475 #define GADGET_ID_WIND_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 2)
476 #define GADGET_ID_CUSTOM_WALK_TO_ACTION (GADGET_ID_SELECTBOX_FIRST + 3)
477 #define GADGET_ID_CUSTOM_EXPLOSION_TYPE (GADGET_ID_SELECTBOX_FIRST + 4)
478 #define GADGET_ID_CUSTOM_DEADLINESS (GADGET_ID_SELECTBOX_FIRST + 5)
479 #define GADGET_ID_CUSTOM_MOVE_PATTERN (GADGET_ID_SELECTBOX_FIRST + 6)
480 #define GADGET_ID_CUSTOM_MOVE_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 7)
481 #define GADGET_ID_CUSTOM_MOVE_STEPSIZE (GADGET_ID_SELECTBOX_FIRST + 8)
482 #define GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE (GADGET_ID_SELECTBOX_FIRST + 9)
483 #define GADGET_ID_CUSTOM_SMASH_TARGETS (GADGET_ID_SELECTBOX_FIRST + 10)
484 #define GADGET_ID_CUSTOM_SLIPPERY_TYPE (GADGET_ID_SELECTBOX_FIRST + 11)
485 #define GADGET_ID_CUSTOM_ACCESS_TYPE (GADGET_ID_SELECTBOX_FIRST + 12)
486 #define GADGET_ID_CUSTOM_ACCESS_LAYER (GADGET_ID_SELECTBOX_FIRST + 13)
487 #define GADGET_ID_CUSTOM_ACCESS_PROTECTED (GADGET_ID_SELECTBOX_FIRST + 14)
488 #define GADGET_ID_CUSTOM_ACCESS_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 15)
489 #define GADGET_ID_CHANGE_TIME_UNITS (GADGET_ID_SELECTBOX_FIRST + 16)
490 #define GADGET_ID_CHANGE_DIRECT_ACTION (GADGET_ID_SELECTBOX_FIRST + 17)
491 #define GADGET_ID_CHANGE_OTHER_ACTION (GADGET_ID_SELECTBOX_FIRST + 18)
492 #define GADGET_ID_CHANGE_SIDE (GADGET_ID_SELECTBOX_FIRST + 19)
493 #define GADGET_ID_CHANGE_PLAYER (GADGET_ID_SELECTBOX_FIRST + 20)
494 #define GADGET_ID_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 21)
495 #define GADGET_ID_CHANGE_REPLACE_WHEN (GADGET_ID_SELECTBOX_FIRST + 22)
496 #define GADGET_ID_ACTION_TYPE (GADGET_ID_SELECTBOX_FIRST + 23)
497 #define GADGET_ID_ACTION_MODE (GADGET_ID_SELECTBOX_FIRST + 24)
498 #define GADGET_ID_ACTION_ARG (GADGET_ID_SELECTBOX_FIRST + 25)
499 #define GADGET_ID_SELECT_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 26)
500 #define GADGET_ID_GROUP_CHOICE_MODE (GADGET_ID_SELECTBOX_FIRST + 27)
502 /* textbutton identifiers */
503 #define GADGET_ID_TEXTBUTTON_FIRST (GADGET_ID_SELECTBOX_FIRST + 28)
505 #define GADGET_ID_PROPERTIES_INFO (GADGET_ID_TEXTBUTTON_FIRST + 0)
506 #define GADGET_ID_PROPERTIES_CONFIG (GADGET_ID_TEXTBUTTON_FIRST + 1)
507 #define GADGET_ID_PROPERTIES_CONFIG_1 (GADGET_ID_TEXTBUTTON_FIRST + 2)
508 #define GADGET_ID_PROPERTIES_CONFIG_2 (GADGET_ID_TEXTBUTTON_FIRST + 3)
509 #define GADGET_ID_PROPERTIES_CHANGE (GADGET_ID_TEXTBUTTON_FIRST + 4)
510 #define GADGET_ID_SAVE_AS_TEMPLATE (GADGET_ID_TEXTBUTTON_FIRST + 5)
511 #define GADGET_ID_ADD_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 6)
512 #define GADGET_ID_DEL_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 7)
514 /* graphicbutton identifiers */
515 #define GADGET_ID_GRAPHICBUTTON_FIRST (GADGET_ID_TEXTBUTTON_FIRST + 8)
517 #define GADGET_ID_PREV_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 0)
518 #define GADGET_ID_NEXT_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 1)
519 #define GADGET_ID_COPY_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 2)
520 #define GADGET_ID_PASTE_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 3)
522 /* gadgets for scrolling of drawing area */
523 #define GADGET_ID_SCROLLING_FIRST (GADGET_ID_GRAPHICBUTTON_FIRST + 4)
525 #define GADGET_ID_SCROLL_UP (GADGET_ID_SCROLLING_FIRST + 0)
526 #define GADGET_ID_SCROLL_DOWN (GADGET_ID_SCROLLING_FIRST + 1)
527 #define GADGET_ID_SCROLL_LEFT (GADGET_ID_SCROLLING_FIRST + 2)
528 #define GADGET_ID_SCROLL_RIGHT (GADGET_ID_SCROLLING_FIRST + 3)
529 #define GADGET_ID_SCROLL_HORIZONTAL (GADGET_ID_SCROLLING_FIRST + 4)
530 #define GADGET_ID_SCROLL_VERTICAL (GADGET_ID_SCROLLING_FIRST + 5)
532 /* gadgets for scrolling element list */
533 #define GADGET_ID_SCROLLING_LIST_FIRST (GADGET_ID_SCROLLING_FIRST + 6)
535 #define GADGET_ID_SCROLL_LIST_UP (GADGET_ID_SCROLLING_LIST_FIRST + 0)
536 #define GADGET_ID_SCROLL_LIST_DOWN (GADGET_ID_SCROLLING_LIST_FIRST + 1)
537 #define GADGET_ID_SCROLL_LIST_VERTICAL (GADGET_ID_SCROLLING_LIST_FIRST + 2)
539 /* checkbuttons/radiobuttons for level/element properties */
540 #define GADGET_ID_CHECKBUTTON_FIRST (GADGET_ID_SCROLLING_LIST_FIRST + 3)
542 #define GADGET_ID_RANDOM_PERCENTAGE (GADGET_ID_CHECKBUTTON_FIRST + 0)
543 #define GADGET_ID_RANDOM_QUANTITY (GADGET_ID_CHECKBUTTON_FIRST + 1)
544 #define GADGET_ID_RANDOM_RESTRICTED (GADGET_ID_CHECKBUTTON_FIRST + 2)
545 #define GADGET_ID_INITIAL_GRAVITY (GADGET_ID_CHECKBUTTON_FIRST + 3)
546 #define GADGET_ID_STICK_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 4)
547 #define GADGET_ID_EM_SLIPPERY_GEMS (GADGET_ID_CHECKBUTTON_FIRST + 5)
548 #define GADGET_ID_USE_SPRING_BUG (GADGET_ID_CHECKBUTTON_FIRST + 6)
549 #define GADGET_ID_USE_TIME_ORB_BUG (GADGET_ID_CHECKBUTTON_FIRST + 7)
550 #define GADGET_ID_RANDOM_BALL_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 8)
551 #define GADGET_ID_INITIAL_BALL_STATE (GADGET_ID_CHECKBUTTON_FIRST + 9)
552 #define GADGET_ID_GROW_INTO_DIGGABLE (GADGET_ID_CHECKBUTTON_FIRST + 10)
553 #define GADGET_ID_DOUBLE_SPEED (GADGET_ID_CHECKBUTTON_FIRST + 11)
554 #define GADGET_ID_BLOCK_SNAP_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 12)
555 #define GADGET_ID_BLOCK_LAST_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 13)
556 #define GADGET_ID_SP_BLOCK_LAST_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 14)
557 #define GADGET_ID_INSTANT_RELOCATION (GADGET_ID_CHECKBUTTON_FIRST + 15)
558 #define GADGET_ID_USE_START_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 16)
559 #define GADGET_ID_USE_ARTWORK_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 17)
560 #define GADGET_ID_USE_EXPLOSION_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 18)
561 #define GADGET_ID_CAN_PASS_TO_WALKABLE (GADGET_ID_CHECKBUTTON_FIRST + 19)
562 #define GADGET_ID_CAN_FALL_INTO_ACID (GADGET_ID_CHECKBUTTON_FIRST + 20)
563 #define GADGET_ID_CAN_MOVE_INTO_ACID (GADGET_ID_CHECKBUTTON_FIRST + 21)
564 #define GADGET_ID_DONT_COLLIDE_WITH (GADGET_ID_CHECKBUTTON_FIRST + 22)
565 #define GADGET_ID_CUSTOM_INDESTRUCTIBLE (GADGET_ID_CHECKBUTTON_FIRST + 23)
566 #define GADGET_ID_CUSTOM_CAN_EXPLODE (GADGET_ID_CHECKBUTTON_FIRST + 24)
567 #define GADGET_ID_CUSTOM_EXPLODE_FIRE (GADGET_ID_CHECKBUTTON_FIRST + 25)
568 #define GADGET_ID_CUSTOM_EXPLODE_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 26)
569 #define GADGET_ID_CUSTOM_EXPLODE_IMPACT (GADGET_ID_CHECKBUTTON_FIRST + 27)
570 #define GADGET_ID_CUSTOM_WALK_TO_OBJECT (GADGET_ID_CHECKBUTTON_FIRST + 28)
571 #define GADGET_ID_CUSTOM_DEADLY (GADGET_ID_CHECKBUTTON_FIRST + 29)
572 #define GADGET_ID_CUSTOM_CAN_MOVE (GADGET_ID_CHECKBUTTON_FIRST + 30)
573 #define GADGET_ID_CUSTOM_CAN_FALL (GADGET_ID_CHECKBUTTON_FIRST + 31)
574 #define GADGET_ID_CUSTOM_CAN_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 32)
575 #define GADGET_ID_CUSTOM_SLIPPERY (GADGET_ID_CHECKBUTTON_FIRST + 33)
576 #define GADGET_ID_CUSTOM_ACCESSIBLE (GADGET_ID_CHECKBUTTON_FIRST + 34)
577 #define GADGET_ID_CUSTOM_GRAV_REACHABLE (GADGET_ID_CHECKBUTTON_FIRST + 35)
578 #define GADGET_ID_CUSTOM_USE_LAST_VALUE (GADGET_ID_CHECKBUTTON_FIRST + 36)
579 #define GADGET_ID_CUSTOM_USE_GRAPHIC (GADGET_ID_CHECKBUTTON_FIRST + 37)
580 #define GADGET_ID_CUSTOM_USE_TEMPLATE (GADGET_ID_CHECKBUTTON_FIRST + 38)
581 #define GADGET_ID_CUSTOM_CAN_CHANGE (GADGET_ID_CHECKBUTTON_FIRST + 39)
582 #define GADGET_ID_CHANGE_USE_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 40)
583 #define GADGET_ID_CHANGE_USE_EXPLOSION (GADGET_ID_CHECKBUTTON_FIRST + 41)
584 #define GADGET_ID_CHANGE_ONLY_COMPLETE (GADGET_ID_CHECKBUTTON_FIRST + 42)
585 #define GADGET_ID_CHANGE_USE_RANDOM (GADGET_ID_CHECKBUTTON_FIRST + 43)
586 #define GADGET_ID_CHANGE_HAS_ACTION (GADGET_ID_CHECKBUTTON_FIRST + 44)
587 #define GADGET_ID_CHANGE_DELAY (GADGET_ID_CHECKBUTTON_FIRST + 45)
588 #define GADGET_ID_CHANGE_BY_DIRECT_ACT (GADGET_ID_CHECKBUTTON_FIRST + 46)
589 #define GADGET_ID_CHANGE_BY_OTHER_ACT (GADGET_ID_CHECKBUTTON_FIRST + 47)
591 /* gadgets for buttons in element list */
592 #define GADGET_ID_ELEMENTLIST_FIRST (GADGET_ID_CHECKBUTTON_FIRST + 48)
593 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
594 ED_NUM_ELEMENTLIST_BUTTONS - 1)
596 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
598 /* radio button numbers */
599 #define RADIO_NR_NONE 0
600 #define RADIO_NR_DRAWING_TOOLBOX 1
601 #define RADIO_NR_RANDOM_ELEMENTS 2
603 /* values for counter gadgets */
604 #define ED_COUNTER_ID_SELECT_LEVEL 0
605 #define ED_COUNTER_ID_LEVEL_XSIZE 1
606 #define ED_COUNTER_ID_LEVEL_YSIZE 2
607 #define ED_COUNTER_ID_LEVEL_GEMSLIMIT 3
608 #define ED_COUNTER_ID_LEVEL_TIMELIMIT 4
609 #define ED_COUNTER_ID_LEVEL_TIMESCORE 5
610 #define ED_COUNTER_ID_LEVEL_RANDOM 6
611 #define ED_COUNTER_ID_ELEMENT_VALUE1 7
612 #define ED_COUNTER_ID_ELEMENT_VALUE2 8
613 #define ED_COUNTER_ID_ELEMENT_VALUE3 9
614 #define ED_COUNTER_ID_ELEMENT_VALUE4 10
615 #define ED_COUNTER_ID_YAMYAM_CONTENT 11
616 #define ED_COUNTER_ID_BALL_CONTENT 12
617 #define ED_COUNTER_ID_ENVELOPE_XSIZE 13
618 #define ED_COUNTER_ID_ENVELOPE_YSIZE 14
619 #define ED_COUNTER_ID_CUSTOM_SCORE 15
620 #define ED_COUNTER_ID_CUSTOM_GEMCOUNT 16
621 #define ED_COUNTER_ID_CUSTOM_VALUE_FIX 17
622 #define ED_COUNTER_ID_CUSTOM_VALUE_RND 18
623 #define ED_COUNTER_ID_PUSH_DELAY_FIX 19
624 #define ED_COUNTER_ID_PUSH_DELAY_RND 20
625 #define ED_COUNTER_ID_DROP_DELAY_FIX 21
626 #define ED_COUNTER_ID_DROP_DELAY_RND 22
627 #define ED_COUNTER_ID_MOVE_DELAY_FIX 23
628 #define ED_COUNTER_ID_MOVE_DELAY_RND 24
629 #define ED_COUNTER_ID_EXPLOSION_DELAY 25
630 #define ED_COUNTER_ID_IGNITION_DELAY 26
631 #define ED_COUNTER_ID_GROUP_CONTENT 27
632 #define ED_COUNTER_ID_CHANGE_DELAY_FIX 28
633 #define ED_COUNTER_ID_CHANGE_DELAY_RND 29
634 #define ED_COUNTER_ID_CHANGE_CONT_RND 30
636 #define ED_NUM_COUNTERBUTTONS 31
638 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
639 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM
641 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
642 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
643 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
644 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
645 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
646 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
648 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
649 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
651 /* values for scrollbutton gadgets */
652 #define ED_SCROLLBUTTON_ID_AREA_UP 0
653 #define ED_SCROLLBUTTON_ID_AREA_DOWN 1
654 #define ED_SCROLLBUTTON_ID_AREA_LEFT 2
655 #define ED_SCROLLBUTTON_ID_AREA_RIGHT 3
656 #define ED_SCROLLBUTTON_ID_LIST_UP 4
657 #define ED_SCROLLBUTTON_ID_LIST_DOWN 5
659 #define ED_NUM_SCROLLBUTTONS 6
661 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
662 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
664 /* values for scrollbar gadgets */
665 #define ED_SCROLLBAR_ID_AREA_HORIZONTAL 0
666 #define ED_SCROLLBAR_ID_AREA_VERTICAL 1
667 #define ED_SCROLLBAR_ID_LIST_VERTICAL 2
669 #define ED_NUM_SCROLLBARS 3
671 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
672 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
674 /* values for text input gadgets */
675 #define ED_TEXTINPUT_ID_LEVEL_NAME 0
676 #define ED_TEXTINPUT_ID_LEVEL_AUTHOR 1
677 #define ED_TEXTINPUT_ID_ELEMENT_NAME 2
679 #define ED_NUM_TEXTINPUT 3
681 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
682 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
684 /* values for text area gadgets */
685 #define ED_TEXTAREA_ID_ENVELOPE_INFO 0
687 #define ED_NUM_TEXTAREAS 1
689 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
690 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
692 /* values for selectbox gadgets */
693 #define ED_SELECTBOX_ID_TIME_OR_STEPS 0
694 #define ED_SELECTBOX_ID_GAME_ENGINE_TYPE 1
695 #define ED_SELECTBOX_ID_WIND_DIRECTION 2
696 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE 3
697 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER 4
698 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED 5
699 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION 6
700 #define ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION 7
701 #define ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN 8
702 #define ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION 9
703 #define ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE 10
704 #define ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE 11
705 #define ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS 12
706 #define ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE 13
707 #define ED_SELECTBOX_ID_CUSTOM_DEADLINESS 14
708 #define ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE 15
709 #define ED_SELECTBOX_ID_CHANGE_TIME_UNITS 16
710 #define ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION 17
711 #define ED_SELECTBOX_ID_CHANGE_OTHER_ACTION 18
712 #define ED_SELECTBOX_ID_CHANGE_SIDE 19
713 #define ED_SELECTBOX_ID_CHANGE_PLAYER 20
714 #define ED_SELECTBOX_ID_CHANGE_PAGE 21
715 #define ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN 22
716 #define ED_SELECTBOX_ID_ACTION_TYPE 23
717 #define ED_SELECTBOX_ID_ACTION_MODE 24
718 #define ED_SELECTBOX_ID_ACTION_ARG 25
719 #define ED_SELECTBOX_ID_SELECT_CHANGE_PAGE 26
720 #define ED_SELECTBOX_ID_GROUP_CHOICE_MODE 27
722 #define ED_NUM_SELECTBOX 28
724 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
725 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_WIND_DIRECTION
727 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
728 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
729 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
730 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
731 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
732 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
734 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
735 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
737 /* values for textbutton gadgets */
738 #define ED_TEXTBUTTON_ID_PROPERTIES_INFO 0
739 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG 1
740 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1 2
741 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2 3
742 #define ED_TEXTBUTTON_ID_PROPERTIES_CHANGE 4
743 #define ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE 5
744 #define ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE 6
745 #define ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE 7
747 #define ED_NUM_TEXTBUTTONS 8
749 #define ED_TEXTBUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
750 #define ED_TEXTBUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
752 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
753 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
755 /* values for graphicbutton gadgets */
756 #define ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE 0
757 #define ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE 1
758 #define ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE 2
759 #define ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE 3
761 #define ED_NUM_GRAPHICBUTTONS 4
763 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
764 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
766 /* values for checkbutton gadgets */
767 #define ED_CHECKBUTTON_ID_INITIAL_GRAVITY 0
768 #define ED_CHECKBUTTON_ID_RANDOM_RESTRICTED 1
769 #define ED_CHECKBUTTON_ID_STICK_ELEMENT 2
770 #define ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS 3
771 #define ED_CHECKBUTTON_ID_USE_SPRING_BUG 4
772 #define ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG 5
773 #define ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT 6
774 #define ED_CHECKBUTTON_ID_INITIAL_BALL_STATE 7
775 #define ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE 8
776 #define ED_CHECKBUTTON_ID_DOUBLE_SPEED 9
777 #define ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD 10
778 #define ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD 11
779 #define ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD 12
780 #define ED_CHECKBUTTON_ID_INSTANT_RELOCATION 13
781 #define ED_CHECKBUTTON_ID_USE_START_ELEMENT 14
782 #define ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT 15
783 #define ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT 16
784 #define ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE 17
785 #define ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID 18
786 #define ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID 19
787 #define ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH 20
788 #define ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC 21
789 #define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE 22
790 #define ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE 23
791 #define ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE 24
792 #define ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE 25
793 #define ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT 26
794 #define ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE 27
795 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE 28
796 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL 29
797 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH 30
798 #define ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY 31
799 #define ED_CHECKBUTTON_ID_CUSTOM_DEADLY 32
800 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE 33
801 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE 34
802 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH 35
803 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT 36
804 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE 37
805 #define ED_CHECKBUTTON_ID_CHANGE_DELAY 38
806 #define ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT 39
807 #define ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT 40
808 #define ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION 41
809 #define ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT 42
810 #define ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE 43
811 #define ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM 44
812 #define ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION 45
814 #define ED_NUM_CHECKBUTTONS 46
816 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_INITIAL_GRAVITY
817 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
819 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
820 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
821 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
822 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
823 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
824 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
826 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
827 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
829 /* values for radiobutton gadgets */
830 #define ED_RADIOBUTTON_ID_PERCENTAGE 0
831 #define ED_RADIOBUTTON_ID_QUANTITY 1
833 #define ED_NUM_RADIOBUTTONS 2
835 #define ED_RADIOBUTTON_ID_LEVEL_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
836 #define ED_RADIOBUTTON_ID_LEVEL_LAST ED_RADIOBUTTON_ID_QUANTITY
838 /* values for drawing area gadgets */
839 #define ED_DRAWING_ID_DRAWING_LEVEL 0
840 #define ED_DRAWING_ID_YAMYAM_CONTENT_0 1
841 #define ED_DRAWING_ID_YAMYAM_CONTENT_1 2
842 #define ED_DRAWING_ID_YAMYAM_CONTENT_2 3
843 #define ED_DRAWING_ID_YAMYAM_CONTENT_3 4
844 #define ED_DRAWING_ID_YAMYAM_CONTENT_4 5
845 #define ED_DRAWING_ID_YAMYAM_CONTENT_5 6
846 #define ED_DRAWING_ID_YAMYAM_CONTENT_6 7
847 #define ED_DRAWING_ID_YAMYAM_CONTENT_7 8
848 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 9
849 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_1 10
850 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_2 11
851 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_3 12
852 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_4 13
853 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_5 14
854 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_6 15
855 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_7 16
856 #define ED_DRAWING_ID_AMOEBA_CONTENT 17
857 #define ED_DRAWING_ID_START_ELEMENT 18
858 #define ED_DRAWING_ID_ARTWORK_ELEMENT 19
859 #define ED_DRAWING_ID_EXPLOSION_ELEMENT 20
860 #define ED_DRAWING_ID_CUSTOM_GRAPHIC 21
861 #define ED_DRAWING_ID_CUSTOM_CONTENT 22
862 #define ED_DRAWING_ID_CUSTOM_MOVE_ENTER 23
863 #define ED_DRAWING_ID_CUSTOM_MOVE_LEAVE 24
864 #define ED_DRAWING_ID_CUSTOM_CHANGE_TARGET 25
865 #define ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT 26
866 #define ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER 27
867 #define ED_DRAWING_ID_GROUP_CONTENT 28
868 #define ED_DRAWING_ID_RANDOM_BACKGROUND 29
870 #define ED_NUM_DRAWING_AREAS 30
874 -----------------------------------------------------------------------------
875 some internally used definitions
876 -----------------------------------------------------------------------------
879 /* values for CopyLevelToUndoBuffer() */
880 #define UNDO_IMMEDIATE 0
881 #define UNDO_ACCUMULATE 1
883 /* values for scrollbars */
884 #define ED_SCROLL_NO 0
885 #define ED_SCROLL_LEFT 1
886 #define ED_SCROLL_RIGHT 2
887 #define ED_SCROLL_UP 4
888 #define ED_SCROLL_DOWN 8
890 /* screens in the level editor */
891 #define ED_MODE_DRAWING 0
892 #define ED_MODE_INFO 1
893 #define ED_MODE_PROPERTIES 2
895 /* sub-screens in the element properties section */
896 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
897 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
898 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
899 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
900 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
902 /* how many steps can be cancelled */
903 #define NUM_UNDO_STEPS (10 + 1)
905 /* values for elements with score for certain actions */
907 #define MAX_SCORE 255
909 /* values for elements with count for collecting */
910 #define MIN_COLLECT_COUNT 0
911 #define MAX_COLLECT_COUNT 255
913 /* values for random placement */
914 #define RANDOM_USE_PERCENTAGE 0
915 #define RANDOM_USE_QUANTITY 1
917 /* maximal size of level editor drawing area */
918 #define MAX_ED_FIELDX (2 * SCR_FIELDX)
919 #define MAX_ED_FIELDY (2 * SCR_FIELDY - 1)
923 -----------------------------------------------------------------------------
924 some internally used data structure definitions
925 -----------------------------------------------------------------------------
932 } control_info[ED_NUM_CTRL_BUTTONS] =
934 /* note: some additional characters are already reserved for "cheat mode"
935 shortcuts (":XYZ" style) -- for details, see "events.c" */
937 { 's', "draw single items" },
938 { 'd', "draw connected items" },
939 { 'l', "draw lines" },
940 { 'a', "draw arcs" },
941 { 'r', "draw outline rectangles" },
942 { 'R', "draw filled rectangles" },
943 { '\0', "wrap (rotate) level up" },
944 { 't', "enter text elements" },
945 { 'f', "flood fill" },
946 { '\0', "wrap (rotate) level left" },
947 { '?', "properties of drawing element" },
948 { '\0', "wrap (rotate) level right" },
949 { '\0', "random element placement" },
950 { 'b', "grab brush" },
951 { '\0', "wrap (rotate) level down" },
952 { ',', "pick drawing element" },
954 { 'U', "undo last operation" },
955 { 'I', "level properties" },
956 { 'S', "save level" },
957 { 'C', "clear level" },
958 { 'T', "test level" },
959 { 'E', "exit level editor" },
961 { '\0', "copy settings from other element" },
962 { '\0', "copy settings to other element" },
963 { '\0', "exchange element with other element" },
965 { '\0', "copy settings from this element" },
966 { '\0', "paste settings to this element" },
969 static int random_placement_value = 10;
970 static int random_placement_method = RANDOM_USE_QUANTITY;
971 static int random_placement_background_element = EL_SAND;
972 static boolean random_placement_background_restricted = FALSE;
973 static boolean stick_element_properties_window = FALSE;
974 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
975 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
976 static struct ElementChangeInfo custom_element_change;
977 static struct ElementGroupInfo group_element_info;
978 static struct ElementInfo custom_element;
983 int min_value, max_value;
984 int gadget_id_down, gadget_id_up;
988 char *text_above, *text_left, *text_right;
989 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
991 /* ---------- current level number --------------------------------------- */
994 DX + 5 - SX, DY + 3 - SY,
996 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
997 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1002 /* ---------- level and editor settings ---------------------------------- */
1005 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1006 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1007 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1008 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1010 "playfield size:", NULL, "width",
1013 -1, ED_LEVEL_SETTINGS_YPOS(4),
1014 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1015 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1016 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1018 NULL, " ", "height",
1021 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
1023 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1024 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1026 NULL, "number of gems to collect:", NULL
1029 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
1031 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1032 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1034 "time or step limit to solve level:", NULL, NULL
1037 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
1039 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1040 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1041 &level.score[SC_TIME_BONUS],
1042 "score for each second/step left:", NULL, NULL
1045 ED_LEVEL_SETTINGS_XPOS(0), ED_COUNTER2_YPOS(8),
1047 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1048 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1049 &random_placement_value,
1050 "random element placement:", NULL, "in"
1053 /* ---------- element settings: configure (various elements) ------------- */
1056 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1057 MIN_SCORE, MAX_SCORE,
1058 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1059 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1060 NULL, /* will be set when used */
1064 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1065 MIN_SCORE, MAX_SCORE,
1066 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1067 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1068 NULL, /* will be set when used */
1072 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1073 MIN_SCORE, MAX_SCORE,
1074 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1075 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1076 NULL, /* will be set when used */
1080 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1081 MIN_SCORE, MAX_SCORE,
1082 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1083 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1084 NULL, /* will be set when used */
1088 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1089 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1090 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1091 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1092 &level.num_yamyam_contents,
1093 NULL, NULL, "number of content areas"
1096 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1097 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1098 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1099 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1100 &level.num_ball_contents,
1101 NULL, NULL, "number of content areas"
1104 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1105 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1106 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1107 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1109 NULL, NULL, "width",
1112 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1113 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1114 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1115 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1117 NULL, " ", "height",
1120 /* ---------- element settings: configure 1 (custom elements) ------------ */
1123 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1124 MIN_SCORE, MAX_SCORE,
1125 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1126 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1127 &custom_element.collect_score_initial,
1128 NULL, "CE score", " "
1131 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1132 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1133 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1134 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1135 &custom_element.collect_count_initial,
1136 NULL, "CE count", NULL
1139 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
1141 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1142 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1143 &custom_element.ce_value_fixed_initial,
1144 NULL, "CE value", NULL
1147 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
1149 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1150 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1151 &custom_element.ce_value_random_initial,
1152 NULL, "+random", NULL
1155 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1157 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1158 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1159 &custom_element.push_delay_fixed,
1160 NULL, "push delay", NULL
1163 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1165 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1166 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1167 &custom_element.push_delay_random,
1168 NULL, "+random", NULL
1171 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
1173 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1174 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1175 &custom_element.drop_delay_fixed,
1176 NULL, "drop delay", NULL
1179 -1, ED_ELEMENT_SETTINGS_YPOS(8),
1181 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1182 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1183 &custom_element.drop_delay_random,
1184 NULL, "+random", NULL
1187 /* ---------- element settings: configure 2 (custom elements) ------------ */
1190 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1192 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1193 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1194 &custom_element.move_delay_fixed,
1195 NULL, "move delay", NULL
1198 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1200 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1201 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1202 &custom_element.move_delay_random,
1203 NULL, "+random", NULL
1206 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
1208 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1209 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1210 &custom_element.explosion_delay,
1211 NULL, "explosion delay", NULL
1214 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1216 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1217 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1218 &custom_element.ignition_delay,
1219 NULL, "ignition delay", "(by fire)"
1222 /* ---------- element settings: configure (group elements) --------------- */
1225 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
1226 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1227 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1228 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1229 &group_element_info.num_elements,
1230 NULL, NULL, "number of elements in group"
1233 /* ---------- element settings: advanced (custom elements) --------------- */
1236 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1238 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1239 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1240 &custom_element_change.delay_fixed,
1241 NULL, "CE delay", NULL,
1244 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1246 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1247 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1248 &custom_element_change.delay_random,
1249 NULL, "+random", NULL
1252 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1254 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1255 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1256 &custom_element_change.random_percentage,
1257 NULL, "use random replace:", "%"
1267 char *text_above, *infotext;
1268 } textinput_info[ED_NUM_TEXTINPUT] =
1271 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1272 GADGET_ID_LEVEL_NAME,
1278 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1279 GADGET_ID_LEVEL_AUTHOR,
1280 MAX_LEVEL_AUTHOR_LEN,
1285 5 * MINI_TILEX - 2, 5 * MINI_TILEY - ED_BORDER_SIZE + 1,
1286 GADGET_ID_ELEMENT_NAME,
1287 MAX_ELEMENT_NAME_LEN - 2, /* currently 2 chars less editable */
1288 custom_element.description,
1289 NULL, "Element name"
1299 char *text_above, *infotext;
1300 } textarea_info[ED_NUM_TEXTAREAS] =
1303 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1304 GADGET_ID_ENVELOPE_INFO,
1305 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1307 "Envelope Info:", "Envelope Info"
1311 static struct ValueTextInfo options_time_or_steps[] =
1319 static struct ValueTextInfo options_game_engine_type[] =
1321 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1322 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1327 static struct ValueTextInfo options_wind_direction[] =
1329 { MV_START_NONE, "none" },
1330 { MV_START_LEFT, "left" },
1331 { MV_START_RIGHT, "right" },
1332 { MV_START_UP, "up" },
1333 { MV_START_DOWN, "down" },
1338 static struct ValueTextInfo options_access_type[] =
1340 { EP_WALKABLE, "walkable" },
1341 { EP_PASSABLE, "passable" },
1346 static struct ValueTextInfo options_access_layer[] =
1348 { EP_ACCESSIBLE_OVER, "over" },
1349 { EP_ACCESSIBLE_INSIDE, "inside" },
1350 { EP_ACCESSIBLE_UNDER, "under" },
1355 static struct ValueTextInfo options_access_protected[] =
1357 { 0, "unprotected" },
1363 static struct ValueTextInfo options_access_direction[] =
1365 { MV_NO_DIRECTION, "no direction" },
1366 { MV_LEFT, "left" },
1367 { MV_RIGHT, "right" },
1369 { MV_DOWN, "down" },
1370 { MV_LEFT | MV_UP, "left + up" },
1371 { MV_LEFT | MV_DOWN, "left + down" },
1372 { MV_RIGHT | MV_UP, "right + up" },
1373 { MV_RIGHT | MV_DOWN, "right + down" },
1374 { MV_HORIZONTAL, "horizontal" },
1375 { MV_VERTICAL, "vertical" },
1376 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1377 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1378 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1379 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1380 { MV_ALL_DIRECTIONS, "all directions" },
1385 static struct ValueTextInfo options_walk_to_action[] =
1387 { EP_DIGGABLE, "diggable" },
1388 { EP_COLLECTIBLE_ONLY, "collectible" },
1389 { EP_DROPPABLE, "collectible & droppable" },
1390 { EP_THROWABLE, "collectible & throwable" },
1391 { EP_PUSHABLE, "pushable" },
1396 static struct ValueTextInfo options_move_pattern[] =
1398 { MV_LEFT, "left" },
1399 { MV_RIGHT, "right" },
1401 { MV_DOWN, "down" },
1402 { MV_HORIZONTAL, "horizontal" },
1403 { MV_VERTICAL, "vertical" },
1404 { MV_ALL_DIRECTIONS, "all directions" },
1405 { MV_WIND_DIRECTION, "wind direction" },
1406 { MV_TOWARDS_PLAYER, "towards player" },
1407 { MV_AWAY_FROM_PLAYER, "away from player" },
1408 { MV_ALONG_LEFT_SIDE, "along left side" },
1409 { MV_ALONG_RIGHT_SIDE, "along right side" },
1410 { MV_TURNING_LEFT, "turning left" },
1411 { MV_TURNING_RIGHT, "turning right" },
1412 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1413 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1414 { MV_TURNING_RANDOM, "turning random" },
1415 { MV_MAZE_RUNNER, "maze runner style" },
1416 { MV_MAZE_HUNTER, "maze hunter style" },
1417 { MV_WHEN_PUSHED, "when pushed" },
1418 { MV_WHEN_DROPPED, "when dropped/thrown" },
1423 static struct ValueTextInfo options_move_direction[] =
1425 { MV_START_AUTOMATIC, "automatic" },
1426 { MV_START_LEFT, "left" },
1427 { MV_START_RIGHT, "right" },
1428 { MV_START_UP, "up" },
1429 { MV_START_DOWN, "down" },
1430 { MV_START_RANDOM, "random" },
1431 { MV_START_PREVIOUS, "previous" },
1436 static struct ValueTextInfo options_move_stepsize[] =
1438 { 0, "not moving" },
1443 { 16, "very fast" },
1444 { 32, "even faster" },
1449 static struct ValueTextInfo options_move_leave_type[] =
1451 { LEAVE_TYPE_UNLIMITED, "leave behind" },
1452 { LEAVE_TYPE_LIMITED, "change it to" },
1457 static struct ValueTextInfo options_smash_targets[] =
1459 { EP_CAN_SMASH_PLAYER, "player" },
1461 { EP_CAN_SMASH_ENEMIES, "enemies" },
1463 { EP_CAN_SMASH_EVERYTHING, "everything" },
1468 static struct ValueTextInfo options_slippery_type[] =
1470 { SLIPPERY_ANY_RANDOM, "random" },
1471 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
1472 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
1473 { SLIPPERY_ONLY_LEFT, "only left" },
1474 { SLIPPERY_ONLY_RIGHT, "only right" },
1479 static struct ValueTextInfo options_deadliness[] =
1481 { EP_DONT_RUN_INTO, "running into" },
1482 { EP_DONT_COLLIDE_WITH, "colliding with" },
1483 { EP_DONT_TOUCH, "touching" },
1488 static struct ValueTextInfo options_explosion_type[] =
1490 { EXPLODES_3X3, "3x3" },
1491 { EXPLODES_CROSS, "3+3" },
1492 { EXPLODES_1X1, "1x1" },
1497 static struct ValueTextInfo options_time_units[] =
1500 { FRAMES_PER_SECOND, "seconds" },
1505 static struct ValueTextInfo options_change_direct_action[] =
1507 { CE_TOUCHED_BY_PLAYER, "touched by player" },
1508 { CE_PRESSED_BY_PLAYER, "pressed by player" },
1509 { CE_SWITCHED_BY_PLAYER, "switched by player" },
1510 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
1511 { CE_PUSHED_BY_PLAYER, "pushed by player" },
1512 { CE_ENTERED_BY_PLAYER, "entered by player" },
1513 { CE_LEFT_BY_PLAYER, "left by player" },
1514 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
1515 { CE_SWITCHED, "switched" },
1516 { CE_HITTING_SOMETHING, "hitting something" },
1517 { CE_HIT_BY_SOMETHING, "hit by something" },
1519 { CE_BLOCKED, "blocked" },
1521 { CE_IMPACT, "impact (on something)" },
1522 { CE_SMASHED, "smashed (from above)" },
1523 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
1528 static struct ValueTextInfo options_change_other_action[] =
1530 { CE_PLAYER_TOUCHES_X, "player touches" },
1531 { CE_PLAYER_PRESSES_X, "player presses" },
1532 { CE_PLAYER_SWITCHES_X, "player switches" },
1533 { CE_PLAYER_SNAPS_X, "player snaps" },
1534 { CE_PLAYER_PUSHES_X, "player pushes" },
1535 { CE_PLAYER_ENTERS_X, "player enters" },
1536 { CE_PLAYER_LEAVES_X, "player leaves" },
1537 { CE_PLAYER_DIGS_X, "player digs" },
1538 { CE_PLAYER_COLLECTS_X, "player collects" },
1539 { CE_PLAYER_DROPS_X, "player drops/throws" },
1540 { CE_TOUCHING_X, "touching" },
1541 { CE_HITTING_X, "hitting" },
1542 { CE_HIT_BY_X, "hit by" },
1543 { CE_SWITCH_OF_X, "switch of" },
1544 { CE_CHANGE_OF_X, "change by page of" },
1545 { CE_EXPLOSION_OF_X, "explosion of" },
1546 { CE_MOVE_OF_X, "move of" },
1547 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
1552 static struct ValueTextInfo options_change_trigger_side[] =
1554 { CH_SIDE_LEFT, "left" },
1555 { CH_SIDE_RIGHT, "right" },
1556 { CH_SIDE_TOP, "top" },
1557 { CH_SIDE_BOTTOM, "bottom" },
1558 { CH_SIDE_LEFT_RIGHT, "left/right" },
1559 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
1560 { CH_SIDE_ANY, "any" },
1565 static struct ValueTextInfo options_change_trigger_player[] =
1567 { CH_PLAYER_1, "1" },
1568 { CH_PLAYER_2, "2" },
1569 { CH_PLAYER_3, "3" },
1570 { CH_PLAYER_4, "4" },
1571 { CH_PLAYER_ANY, "any" },
1576 static struct ValueTextInfo options_change_trigger_page[] =
1588 { (1 << 10), "11" },
1589 { (1 << 11), "12" },
1590 { (1 << 12), "13" },
1591 { (1 << 13), "14" },
1592 { (1 << 14), "15" },
1593 { (1 << 15), "16" },
1594 { (1 << 16), "17" },
1595 { (1 << 17), "18" },
1596 { (1 << 18), "19" },
1597 { (1 << 19), "20" },
1598 { (1 << 20), "21" },
1599 { (1 << 21), "22" },
1600 { (1 << 22), "23" },
1601 { (1 << 23), "24" },
1602 { (1 << 24), "25" },
1603 { (1 << 25), "26" },
1604 { (1 << 26), "27" },
1605 { (1 << 27), "28" },
1606 { (1 << 28), "29" },
1607 { (1 << 29), "30" },
1608 { (1 << 30), "31" },
1609 { (1 << 31), "32" },
1610 { CH_PAGE_ANY, "any" },
1615 static struct ValueTextInfo options_change_replace_when[] =
1617 { CP_WHEN_EMPTY, "empty" },
1618 { CP_WHEN_WALKABLE, "walkable" },
1619 { CP_WHEN_DIGGABLE, "diggable" },
1620 { CP_WHEN_COLLECTIBLE, "collectible" },
1621 { CP_WHEN_REMOVABLE, "removable" },
1622 { CP_WHEN_DESTRUCTIBLE, "destructible" },
1627 static struct ValueTextInfo options_action_type[] =
1629 { CA_NO_ACTION, "no action" },
1630 { CA_UNDEFINED, " " },
1631 { CA_HEADLINE_LEVEL_ACTIONS, "[level actions]" },
1632 { CA_RESTART_LEVEL, "restart level" },
1633 { CA_SHOW_ENVELOPE, "show envelope" },
1634 { CA_SET_LEVEL_TIME, "set time" },
1635 { CA_SET_LEVEL_SCORE, "set score" },
1636 { CA_SET_LEVEL_GEMS, "set needed gems" },
1637 { CA_SET_LEVEL_GRAVITY, "set gravity" },
1638 { CA_SET_LEVEL_WIND, "set wind dir." },
1639 { CA_UNDEFINED, " " },
1640 { CA_HEADLINE_PLAYER_ACTIONS, "[player actions]" },
1641 { CA_MOVE_PLAYER, "move player" },
1642 { CA_EXIT_PLAYER, "exit player" },
1643 { CA_KILL_PLAYER, "kill player" },
1644 { CA_SET_PLAYER_KEYS, "set keys" },
1645 { CA_SET_PLAYER_SPEED, "set speed" },
1646 { CA_SET_PLAYER_SHIELD, "set shield" },
1647 { CA_SET_PLAYER_ARTWORK, "set artwork" },
1648 { CA_UNDEFINED, " " },
1649 { CA_HEADLINE_CE_ACTIONS, "[CE actions]" },
1650 { CA_SET_CE_SCORE, "set CE score" },
1651 { CA_SET_CE_VALUE, "set CE value" },
1656 static struct ValueTextInfo options_action_mode_none[] =
1658 { CA_ARG_UNDEFINED, " " },
1663 static struct ValueTextInfo options_action_mode_assign[] =
1665 { CA_MODE_SET, "=" },
1670 static struct ValueTextInfo options_action_mode_add_remove[] =
1672 { CA_MODE_ADD, "+" },
1673 { CA_MODE_SUBTRACT, "-" },
1678 static struct ValueTextInfo options_action_mode_calculate[] =
1680 { CA_MODE_SET, "=" },
1681 { CA_MODE_ADD, "+" },
1682 { CA_MODE_SUBTRACT, "-" },
1683 { CA_MODE_MULTIPLY, "*" },
1684 { CA_MODE_DIVIDE, "/" },
1685 { CA_MODE_MODULO, "%" },
1690 static struct ValueTextInfo options_action_arg_none[] =
1692 { CA_ARG_UNDEFINED, " " },
1697 static struct ValueTextInfo options_action_arg_player[] =
1699 { CA_ARG_PLAYER_HEADLINE, "[player]" },
1700 { CA_ARG_PLAYER_1, "1" },
1701 { CA_ARG_PLAYER_2, "2" },
1702 { CA_ARG_PLAYER_3, "3" },
1703 { CA_ARG_PLAYER_4, "4" },
1704 { CA_ARG_PLAYER_ANY, "any" },
1705 { CA_ARG_PLAYER_TRIGGER, "trigger" },
1710 static struct ValueTextInfo options_action_arg_number[] =
1712 { CA_ARG_NUMBER_HEADLINE, "[number]" },
1719 { CA_ARG_10, "10" },
1720 { CA_ARG_100, "100" },
1721 { CA_ARG_1000, "1000" },
1722 { CA_ARG_UNDEFINED, " " },
1723 { CA_ARG_NUMBER_MIN, "min" },
1724 { CA_ARG_NUMBER_MAX, "max" },
1725 { CA_ARG_UNDEFINED, " " },
1726 { CA_ARG_NUMBER_RESET, "reset" },
1727 { CA_ARG_UNDEFINED, " " },
1728 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
1729 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
1730 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
1731 { CA_ARG_UNDEFINED, " " },
1732 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
1733 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
1734 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
1735 { CA_ARG_UNDEFINED, " " },
1736 { CA_ARG_ELEMENT_HEADLINE, "[CE value" },
1737 { CA_ARG_ELEMENT_HEADLINE, " of" },
1738 { CA_ARG_ELEMENT_HEADLINE, " element]" },
1739 { CA_ARG_ELEMENT_TARGET, "target" },
1740 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
1745 static struct ValueTextInfo options_action_arg_envelope[] =
1747 { CA_ARG_NUMBER_HEADLINE, "[number]" },
1752 { CA_ARG_UNDEFINED, " " },
1753 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
1754 { CA_ARG_ELEMENT_TARGET, "target" },
1755 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
1760 static struct ValueTextInfo options_action_arg_key[] =
1762 { CA_ARG_NUMBER_HEADLINE, "[number]" },
1771 { CA_ARG_UNDEFINED, " " },
1772 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
1773 { CA_ARG_ELEMENT_TARGET, "target" },
1774 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
1779 static struct ValueTextInfo options_action_arg_speed[] =
1781 { CA_ARG_SPEED_HEADLINE, "[speed]" },
1782 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
1783 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
1784 { CA_ARG_SPEED_SLOW, "slow" },
1785 { CA_ARG_SPEED_NORMAL, "normal" },
1786 { CA_ARG_SPEED_FAST, "fast" },
1787 { CA_ARG_SPEED_VERY_FAST, "very fast" },
1788 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
1789 { CA_ARG_UNDEFINED, " " },
1790 { CA_ARG_SPEED_SLOWER, "slower" },
1791 { CA_ARG_SPEED_FASTER, "faster" },
1792 { CA_ARG_UNDEFINED, " " },
1793 { CA_ARG_SPEED_RESET, "reset" },
1798 static struct ValueTextInfo options_action_arg_shield[] =
1800 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
1801 { CA_ARG_SHIELD_OFF, "off" },
1802 { CA_ARG_SHIELD_NORMAL, "normal" },
1803 { CA_ARG_SHIELD_DEADLY, "deadly" },
1808 static struct ValueTextInfo options_action_arg_artwork[] =
1810 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
1811 { CA_ARG_ELEMENT_TARGET, "target" },
1812 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
1813 { CA_ARG_UNDEFINED, " " },
1814 { CA_ARG_ELEMENT_RESET, "reset" },
1819 static struct ValueTextInfo options_action_arg_gravity[] =
1821 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
1822 { CA_ARG_GRAVITY_ON, "on" },
1823 { CA_ARG_GRAVITY_OFF, "off" },
1824 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
1829 static struct ValueTextInfo options_action_arg_direction[] =
1831 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
1832 { CA_ARG_DIRECTION_NONE, "none" },
1833 { CA_ARG_DIRECTION_LEFT, "left" },
1834 { CA_ARG_DIRECTION_RIGHT, "right" },
1835 { CA_ARG_DIRECTION_UP, "up" },
1836 { CA_ARG_DIRECTION_DOWN, "down" },
1837 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
1838 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
1843 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
1844 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
1849 static struct ValueTextInfo options_group_choice_mode[] =
1851 { ANIM_RANDOM, "random" },
1852 { ANIM_LOOP, "loop" },
1853 { ANIM_LINEAR, "linear" },
1854 { ANIM_PINGPONG, "pingpong" },
1855 { ANIM_PINGPONG2, "pingpong 2" },
1860 static struct ValueTextInfo *action_arg_modes[] =
1862 options_action_mode_none,
1863 options_action_mode_assign,
1864 options_action_mode_add_remove,
1865 options_action_mode_calculate,
1872 struct ValueTextInfo *options;
1874 action_arg_options[] =
1876 { CA_NO_ACTION, 0, options_action_arg_none, },
1877 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
1878 { CA_KILL_PLAYER, 0, options_action_arg_player, },
1879 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
1880 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
1881 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
1882 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
1883 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
1884 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
1885 { CA_SET_LEVEL_GRAVITY, 1, options_action_arg_gravity, },
1886 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
1887 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
1888 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
1889 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
1890 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
1891 { CA_SET_CE_SCORE, 3, options_action_arg_number, },
1892 { CA_SET_CE_VALUE, 3, options_action_arg_number, },
1901 int gadget_id_align;
1902 int size; /* char size of selectbox or '-1' (dynamically determined) */
1903 struct ValueTextInfo *options;
1905 char *text_left, *text_right, *infotext;
1906 } selectbox_info[ED_NUM_SELECTBOX] =
1908 /* ---------- level and editor settings ---------------------------------- */
1911 -1, ED_LEVEL_SETTINGS_YPOS(8),
1912 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
1914 options_time_or_steps,
1915 &level.use_step_counter,
1916 NULL, "(0 => no limit)", "time or step limit"
1919 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1920 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
1922 options_game_engine_type,
1923 &level.game_engine_type,
1924 "game engine:", NULL, "game engine"
1927 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
1928 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
1930 options_wind_direction,
1931 &level.wind_direction_initial,
1932 "initial wind direction:", NULL, "initial wind direction"
1935 /* ---------- element settings: configure (several elements) ------------- */
1937 /* ---------- element settings: configure 1 (custom elements) ------------ */
1940 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
1941 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
1943 options_access_type,
1944 &custom_element.access_type,
1945 NULL, NULL, "type of access to this field"
1948 -1, ED_ELEMENT_SETTINGS_YPOS(3),
1949 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
1951 options_access_layer,
1952 &custom_element.access_layer,
1953 NULL, NULL, "layer of access for this field"
1956 -1, ED_ELEMENT_SETTINGS_YPOS(3),
1957 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
1959 options_access_protected,
1960 &custom_element.access_protected,
1961 NULL, NULL, "protected access for this field"
1964 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
1965 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
1967 options_access_direction,
1968 &custom_element.access_direction,
1969 "from", NULL, "access direction for this field"
1972 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1973 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
1975 options_walk_to_action,
1976 &custom_element.walk_to_action,
1977 NULL, NULL, "diggable/collectible/pushable"
1980 /* ---------- element settings: configure 2 (custom elements) ------------ */
1983 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
1984 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
1986 options_move_pattern,
1987 &custom_element.move_pattern,
1988 "can move", NULL, "element move pattern"
1991 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
1992 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
1994 options_move_direction,
1995 &custom_element.move_direction_initial,
1996 "starts moving", NULL, "initial element move direction"
1999 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2000 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2002 options_move_stepsize,
2003 &custom_element.move_stepsize,
2004 "move/fall speed", NULL, "speed of element movement"
2007 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2008 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2010 options_move_leave_type,
2011 &custom_element.move_leave_type,
2012 "can dig: can", ":", "leave behind or change element"
2015 -1, ED_ELEMENT_SETTINGS_YPOS(7),
2016 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2018 options_smash_targets,
2019 &custom_element.smash_targets,
2020 "can smash", NULL, "elements that can be smashed"
2023 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
2024 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2026 options_slippery_type,
2027 &custom_element.slippery_type,
2028 "slippery", NULL, "where other elements fall down"
2031 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2032 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2035 &custom_element.deadliness,
2036 "deadly when", NULL, "deadliness of element"
2039 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2040 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2042 options_explosion_type,
2043 &custom_element.explosion_type,
2044 "can explode", NULL, "explosion type"
2047 /* ---------- element settings: advanced (custom elements) --------------- */
2050 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2051 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2054 &custom_element_change.delay_frames,
2055 "delay time given in", NULL, "delay time units for change"
2058 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2059 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2061 options_change_direct_action,
2062 &custom_element_change.direct_action,
2063 NULL, NULL, "type of direct action"
2066 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2067 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2069 options_change_other_action,
2070 &custom_element_change.other_action,
2071 NULL, "element:", "type of other element action"
2074 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2075 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2077 options_change_trigger_side,
2078 &custom_element_change.trigger_side,
2079 "at", "side", "element side triggering change"
2082 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2083 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2085 options_change_trigger_player,
2086 &custom_element_change.trigger_player,
2087 "player:", " ", "player that causes change"
2090 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2091 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2093 options_change_trigger_page,
2094 &custom_element_change.trigger_page,
2095 "page:", NULL, "change page that causes change"
2098 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2099 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2101 options_change_replace_when,
2102 &custom_element_change.replace_when,
2103 "replace when", NULL, "which elements can be replaced"
2106 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2107 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2109 options_action_type,
2110 &custom_element_change.action_type,
2111 NULL, NULL, "action on specified condition"
2114 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2115 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2117 options_action_mode_none,
2118 &custom_element_change.action_mode,
2119 NULL, NULL, "action operator"
2122 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2123 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2125 options_action_arg_none,
2126 &custom_element_change.action_arg,
2127 NULL, NULL, "action parameter"
2130 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2131 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2133 options_change_page,
2134 &custom_element.current_change_page,
2135 NULL, NULL, "element change page"
2138 /* ---------- element settings: configure (group elements) --------------- */
2141 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
2142 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2144 options_group_choice_mode,
2145 &group_element_info.choice_mode,
2146 "choice type:", NULL, "type of group element choice"
2154 int gadget_id_align;
2157 char *text_left, *text_right, *infotext;
2158 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2161 ED_ELEMENT_SETTINGS_XPOS(0), ED_COUNTER_YPOS(1),
2162 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
2164 NULL, NULL, "Show information about element"
2167 ED_ELEMENT_SETTINGS_XPOS(0) + 124, ED_COUNTER_YPOS(1),
2168 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_NONE,
2170 NULL, NULL, "Configure element properties"
2173 ED_ELEMENT_SETTINGS_XPOS(0) + 124, ED_COUNTER_YPOS(1),
2174 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_NONE,
2176 NULL, NULL, "Configure custom element properties"
2179 ED_ELEMENT_SETTINGS_XPOS(0) + 248, ED_COUNTER_YPOS(1),
2180 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_NONE,
2182 NULL, NULL, "Configure custom element properties"
2185 ED_ELEMENT_SETTINGS_XPOS(0) + 372, ED_COUNTER_YPOS(1),
2186 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_NONE,
2188 NULL, NULL, "Custom element change configuration"
2191 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2192 GADGET_ID_SAVE_AS_TEMPLATE, GADGET_ID_CUSTOM_USE_TEMPLATE,
2194 " ", "As Template", "Save current settings as new template"
2197 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2198 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
2200 NULL, NULL, "Add new change page"
2203 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2204 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
2206 NULL, NULL, "Delete current change page"
2216 int gadget_id_align;
2217 char *text_left, *text_right, *infotext;
2218 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
2221 ED_BUTTON_MINUS_XPOS, ED_BUTTON_COUNT_YPOS,
2222 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
2223 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
2224 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
2225 NULL, NULL, "select previous change page"
2228 ED_BUTTON_PLUS_XPOS, ED_BUTTON_COUNT_YPOS,
2229 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2230 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
2231 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
2232 NULL, "change page", "select next change page"
2235 ED_COPY_CHANGE_PAGE_XPOS, ED_COPY_CHANGE_PAGE_YPOS,
2236 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2237 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
2238 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
2239 " ", NULL, "copy settings from this change page"
2242 ED_PASTE_CHANGE_PAGE_XPOS, ED_PASTE_CHANGE_PAGE_YPOS,
2243 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2244 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
2245 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
2246 NULL, NULL, "paste settings to this change page"
2256 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
2259 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 0 * ED_SCROLLBUTTON_YSIZE,
2260 ED_SCROLL_UP_XPOS, ED_SCROLL_UP_YPOS,
2261 GADGET_ID_SCROLL_UP,
2262 "scroll level editing area up"
2265 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 1 * ED_SCROLLBUTTON_YSIZE,
2266 ED_SCROLL_DOWN_XPOS, ED_SCROLL_DOWN_YPOS,
2267 GADGET_ID_SCROLL_DOWN,
2268 "scroll level editing area down"
2271 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 2 * ED_SCROLLBUTTON_YSIZE,
2272 ED_SCROLL_LEFT_XPOS, ED_SCROLL_LEFT_YPOS,
2273 GADGET_ID_SCROLL_LEFT,
2274 "scroll level editing area left"
2277 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 3 * ED_SCROLLBUTTON_YSIZE,
2278 ED_SCROLL_RIGHT_XPOS, ED_SCROLL_RIGHT_YPOS,
2279 GADGET_ID_SCROLL_RIGHT,
2280 "scroll level editing area right"
2283 ED_SCROLLBUTTON2_XPOS, ED_SCROLLBUTTON2_YPOS + 0 * ED_SCROLLBUTTON2_YSIZE,
2284 ED_SCROLL2_UP_XPOS, ED_SCROLL2_UP_YPOS,
2285 GADGET_ID_SCROLL_LIST_UP,
2286 "scroll element list up ('Page Up')"
2289 ED_SCROLLBUTTON2_XPOS, ED_SCROLLBUTTON2_YPOS + 1 * ED_SCROLLBUTTON2_YSIZE,
2290 ED_SCROLL2_DOWN_XPOS, ED_SCROLL2_DOWN_YPOS,
2291 GADGET_ID_SCROLL_LIST_DOWN,
2292 "scroll element list down ('Page Down')"
2304 } scrollbar_info[ED_NUM_SCROLLBARS] =
2307 ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
2308 SX + ED_SCROLL_HORIZONTAL_XPOS, SY + ED_SCROLL_HORIZONTAL_YPOS,
2309 ED_SCROLL_HORIZONTAL_XSIZE, ED_SCROLL_HORIZONTAL_YSIZE,
2310 GD_TYPE_SCROLLBAR_HORIZONTAL,
2311 GADGET_ID_SCROLL_HORIZONTAL,
2312 "scroll level editing area horizontally"
2315 ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
2316 SX + ED_SCROLL_VERTICAL_XPOS, SY + ED_SCROLL_VERTICAL_YPOS,
2317 ED_SCROLL_VERTICAL_XSIZE, ED_SCROLL_VERTICAL_YSIZE,
2318 GD_TYPE_SCROLLBAR_VERTICAL,
2319 GADGET_ID_SCROLL_VERTICAL,
2320 "scroll level editing area vertically"
2323 ED_SCROLLBAR2_XPOS, ED_SCROLLBAR2_YPOS,
2324 DX + ED_SCROLL2_VERTICAL_XPOS, DY + ED_SCROLL2_VERTICAL_YPOS,
2325 ED_SCROLL2_VERTICAL_XSIZE, ED_SCROLL2_VERTICAL_YSIZE,
2326 GD_TYPE_SCROLLBAR_VERTICAL,
2327 GADGET_ID_SCROLL_LIST_VERTICAL,
2328 "scroll element list vertically"
2336 int gadget_id_align;
2337 int radio_button_nr;
2340 char *text_left, *text_right, *infotext;
2341 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
2344 -1, ED_COUNTER2_YPOS(8),
2345 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
2346 RADIO_NR_RANDOM_ELEMENTS,
2347 &random_placement_method, RANDOM_USE_PERCENTAGE,
2348 " ", "percentage", "use percentage for random elements"
2351 -1, ED_COUNTER2_YPOS(8),
2352 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
2353 RADIO_NR_RANDOM_ELEMENTS,
2354 &random_placement_method, RANDOM_USE_QUANTITY,
2355 " ", "quantity", "use quantity for random elements"
2363 int gadget_id_align;
2365 char *text_left, *text_right, *infotext;
2366 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
2368 /* ---------- level and editor settings ---------------------------------- */
2371 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
2372 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
2373 &level.initial_gravity,
2375 "initial gravity", "set initial level gravity"
2378 ED_LEVEL_SETTINGS_XPOS(0), ED_COUNTER2_YPOS(9) - MINI_TILEY,
2379 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
2380 &random_placement_background_restricted,
2382 "restrict random placement to:", "set random placement restriction"
2385 /* ---------- element settings: configure (various elements) ------------- */
2388 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2389 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
2390 &stick_element_properties_window,
2392 "stick this screen to edit content","stick this screen to edit content"
2395 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2396 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
2397 &level.em_slippery_gems,
2399 "slip down from certain flat walls","use EM style slipping behaviour"
2402 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2403 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
2404 &level.use_spring_bug,
2406 "use spring pushing bug", "use odd spring pushing behaviour"
2409 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2410 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
2411 &level.use_time_orb_bug,
2413 "use time orb bug", "use odd time orb behaviour"
2416 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2417 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
2420 "create single random element", "only create one element from content"
2423 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2424 GADGET_ID_INITIAL_BALL_STATE, GADGET_ID_NONE,
2425 &level.ball_state_initial,
2427 "magic ball initially activated", "activate magic ball after level start"
2430 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2431 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
2432 &level.grow_into_diggable,
2434 "can grow into anything diggable", "grow into more than just sand"
2437 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
2438 GADGET_ID_DOUBLE_SPEED, GADGET_ID_NONE,
2439 &level.double_speed,
2441 "double speed movement", "set initial movement speed of player"
2444 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
2445 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
2446 &level.block_snap_field,
2448 "block snapped field when snapping", "use snapping delay to show animation"
2451 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2452 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
2453 &level.block_last_field,
2455 "block last field when moving", "player blocks last field when moving"
2458 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2459 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
2460 &level.sp_block_last_field,
2462 "block last field when moving", "player blocks last field when moving"
2465 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
2466 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
2467 &level.instant_relocation,
2469 "no scrolling when relocating", "player gets relocated without delay"
2472 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2473 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
2474 &level.use_start_element[0],
2476 "use level start element:", "start level at this element's position"
2479 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
2480 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
2481 &level.use_artwork_element[0],
2483 "use artwork from element:", "use player artwork from other element"
2486 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
2487 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
2488 &level.use_explosion_element[0],
2490 "use explosion from element:", "use explosion properties from element"
2493 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2494 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
2495 &level.can_pass_to_walkable,
2497 "can pass to walkable element", "player can pass to empty or walkable"
2500 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2501 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
2502 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
2504 "can fall into acid (with gravity)","player can fall into acid pool"
2507 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2508 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
2509 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
2511 "can move into acid", "element can move into acid pool"
2514 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2515 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
2516 &custom_element_properties[EP_DONT_COLLIDE_WITH],
2518 "deadly when colliding with", "element is deadly when hitting player"
2521 /* ---------- element settings: configure 1 (custom elements) ----------- */
2524 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2525 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
2526 &custom_element.use_gfx_element,
2528 /* !!! add separate "use existing element sound" !!! */
2530 NULL, "use graphic/sound of element:", "use existing graphic and sound"
2532 NULL, "use graphic of element:", "use existing element graphic"
2536 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2537 GADGET_ID_CUSTOM_USE_TEMPLATE, GADGET_ID_NONE,
2538 &level.use_custom_template,
2539 NULL, "use template", "use template for custom properties"
2542 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
2543 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
2544 &custom_element_properties[EP_ACCESSIBLE],
2545 NULL, NULL, "player can walk to or pass this field"
2548 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
2549 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
2550 &custom_element_properties[EP_GRAVITY_REACHABLE],
2551 NULL, "reachable despite gravity", "player can walk/dig despite gravity"
2554 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
2555 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
2556 &custom_element.use_last_ce_value,
2557 NULL, "use last CE value after change", "use last CE value after change"
2560 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
2561 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
2562 &custom_element_properties[EP_WALK_TO_OBJECT],
2563 NULL, NULL, "player can dig/collect/push element"
2566 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
2567 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
2568 &custom_element_properties[EP_INDESTRUCTIBLE],
2569 NULL, "indestructible", "element is indestructible"
2572 /* ---------- element settings: configure 2 (custom elements) ----------- */
2575 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2576 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
2577 &custom_element_properties[EP_CAN_MOVE],
2578 NULL, NULL, "element can move with some pattern"
2581 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2582 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
2583 &custom_element_properties[EP_CAN_FALL],
2584 NULL, "can fall", "element can fall down"
2587 -1, ED_ELEMENT_SETTINGS_YPOS(7),
2588 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
2589 &custom_element_properties[EP_CAN_SMASH],
2590 " ", NULL, "element can smash other elements"
2593 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
2594 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
2595 &custom_element_properties[EP_SLIPPERY],
2596 NULL, NULL, "other elements can fall down from it"
2599 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
2600 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
2601 &custom_element_properties[EP_DEADLY],
2602 NULL, NULL, "element can kill the player"
2605 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
2606 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
2607 &custom_element_properties[EP_CAN_EXPLODE],
2608 NULL, NULL, "element can explode"
2611 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
2612 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
2613 &custom_element_properties[EP_EXPLODES_BY_FIRE],
2614 NULL, "by fire", "element can explode by fire/explosion"
2617 -1, ED_ELEMENT_SETTINGS_YPOS(11),
2618 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
2619 &custom_element_properties[EP_EXPLODES_SMASHED],
2620 " ", "smashed", "element can explode when smashed"
2623 -1, ED_ELEMENT_SETTINGS_YPOS(11),
2624 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
2625 &custom_element_properties[EP_EXPLODES_IMPACT],
2626 " ", "impact", "element can explode on impact"
2629 /* ---------- element settings: advanced (custom elements) --------------- */
2632 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2633 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
2634 &custom_element_change.can_change,
2635 NULL, "element changes to:", "change element on specified condition"
2638 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2639 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
2640 &custom_element_change_events[CE_DELAY],
2641 NULL, NULL, "element changes after delay"
2644 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2645 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
2646 &custom_element_change_events[CE_BY_DIRECT_ACTION],
2647 NULL, NULL, "element changes by direct action"
2650 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
2651 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
2652 &custom_element_change_events[CE_BY_OTHER_ACTION],
2653 NULL, NULL, "element changes by other element"
2656 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
2657 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
2658 &custom_element_change.explode,
2659 NULL, "explode instead of change", "element explodes instead of change"
2662 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2663 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
2664 &custom_element_change.use_target_content,
2665 NULL, "use extended change target:","element changes to more elements"
2668 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
2669 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
2670 &custom_element_change.only_if_complete,
2671 NULL, "replace all or nothing", "only replace when all can be changed"
2674 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
2675 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
2676 &custom_element_change.use_random_replace,
2677 NULL, NULL, "use percentage for random replace"
2680 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
2681 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
2682 &custom_element_change.has_action,
2683 NULL, NULL, "execute action on specified condition"
2691 int gadget_id_align;
2693 int area_xsize, area_ysize;
2694 char *text_left, *text_right, *text_below, *infotext;
2695 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
2697 /* ---------- level playfield content ------------------------------------ */
2701 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
2702 NULL, MAX_ED_FIELDX, MAX_ED_FIELDY,
2703 NULL, NULL, NULL, NULL
2706 /* ---------- yam yam content -------------------------------------------- */
2709 ED_AREA_YAMYAM_CONTENT_XPOS(0), ED_AREA_YAMYAM_CONTENT_YPOS(0),
2710 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
2711 &level.yamyam_content[0].e[0][0], 3, 3,
2712 NULL, NULL, "1", NULL
2715 ED_AREA_YAMYAM_CONTENT_XPOS(1), ED_AREA_YAMYAM_CONTENT_YPOS(1),
2716 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
2717 &level.yamyam_content[1].e[0][0], 3, 3,
2718 NULL, NULL, "2", NULL
2721 ED_AREA_YAMYAM_CONTENT_XPOS(2), ED_AREA_YAMYAM_CONTENT_YPOS(2),
2722 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
2723 &level.yamyam_content[2].e[0][0], 3, 3,
2724 NULL, NULL, "3", NULL
2727 ED_AREA_YAMYAM_CONTENT_XPOS(3), ED_AREA_YAMYAM_CONTENT_YPOS(3),
2728 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
2729 &level.yamyam_content[3].e[0][0], 3, 3,
2730 NULL, NULL, "4", NULL
2733 ED_AREA_YAMYAM_CONTENT_XPOS(4), ED_AREA_YAMYAM_CONTENT_YPOS(4),
2734 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
2735 &level.yamyam_content[4].e[0][0], 3, 3,
2736 NULL, NULL, "5", NULL
2739 ED_AREA_YAMYAM_CONTENT_XPOS(5), ED_AREA_YAMYAM_CONTENT_YPOS(5),
2740 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
2741 &level.yamyam_content[5].e[0][0], 3, 3,
2742 NULL, NULL, "6", NULL
2745 ED_AREA_YAMYAM_CONTENT_XPOS(6), ED_AREA_YAMYAM_CONTENT_YPOS(6),
2746 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
2747 &level.yamyam_content[6].e[0][0], 3, 3,
2748 NULL, NULL, "7", NULL
2751 ED_AREA_YAMYAM_CONTENT_XPOS(7), ED_AREA_YAMYAM_CONTENT_YPOS(7),
2752 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
2753 &level.yamyam_content[7].e[0][0], 3, 3,
2754 NULL, NULL, "8", NULL
2757 /* ---------- magic ball content ----------------------------------------- */
2760 ED_AREA_MAGIC_BALL_CONTENT_XPOS(0), ED_AREA_MAGIC_BALL_CONTENT_YPOS(0),
2761 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
2762 &level.ball_content[0].e[0][0], 3, 3,
2763 NULL, NULL, "1", NULL
2766 ED_AREA_MAGIC_BALL_CONTENT_XPOS(1), ED_AREA_MAGIC_BALL_CONTENT_YPOS(1),
2767 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
2768 &level.ball_content[1].e[0][0], 3, 3,
2769 NULL, NULL, "2", NULL
2772 ED_AREA_MAGIC_BALL_CONTENT_XPOS(2), ED_AREA_MAGIC_BALL_CONTENT_YPOS(2),
2773 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
2774 &level.ball_content[2].e[0][0], 3, 3,
2775 NULL, NULL, "3", NULL
2778 ED_AREA_MAGIC_BALL_CONTENT_XPOS(3), ED_AREA_MAGIC_BALL_CONTENT_YPOS(3),
2779 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
2780 &level.ball_content[3].e[0][0], 3, 3,
2781 NULL, NULL, "4", NULL
2784 ED_AREA_MAGIC_BALL_CONTENT_XPOS(4), ED_AREA_MAGIC_BALL_CONTENT_YPOS(4),
2785 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
2786 &level.ball_content[4].e[0][0], 3, 3,
2787 NULL, NULL, "5", NULL
2790 ED_AREA_MAGIC_BALL_CONTENT_XPOS(5), ED_AREA_MAGIC_BALL_CONTENT_YPOS(5),
2791 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
2792 &level.ball_content[5].e[0][0], 3, 3,
2793 NULL, NULL, "6", NULL
2796 ED_AREA_MAGIC_BALL_CONTENT_XPOS(6), ED_AREA_MAGIC_BALL_CONTENT_YPOS(6),
2797 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
2798 &level.ball_content[6].e[0][0], 3, 3,
2799 NULL, NULL, "7", NULL
2802 ED_AREA_MAGIC_BALL_CONTENT_XPOS(7), ED_AREA_MAGIC_BALL_CONTENT_YPOS(7),
2803 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
2804 &level.ball_content[7].e[0][0], 3, 3,
2805 NULL, NULL, "8", NULL
2808 /* ---------- amoeba content --------------------------------------------- */
2811 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
2812 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
2813 &level.amoeba_content, 1, 1,
2814 "content:", NULL, NULL, "amoeba content"
2817 /* ---------- level start element ---------------------------------------- */
2820 -1, ED_AREA_1X1_SETTINGS_YPOS(7),
2821 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
2822 &level.start_element[0], 1, 1,
2823 NULL, NULL, NULL, "level start element"
2826 /* ---------- player artwork element ------------------------------------- */
2829 -1, ED_AREA_1X1_SETTINGS_YPOS(8),
2830 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
2831 &level.artwork_element[0], 1, 1,
2832 NULL, NULL, NULL, "element for player artwork"
2835 /* ---------- player explosion element ----------------------------------- */
2838 -1, ED_AREA_1X1_SETTINGS_YPOS(9),
2839 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
2840 &level.explosion_element[0], 1, 1,
2841 NULL, NULL, NULL, "element for player explosion"
2844 /* ---------- element settings: configure 1 (custom elements) ----------- */
2846 /* ---------- custom graphic --------------------------------------------- */
2849 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
2850 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
2851 &custom_element.gfx_element, 1, 1,
2852 NULL, NULL, NULL, "custom graphic element"
2855 /* ---------- element settings: configure 2 (custom elements) ----------- */
2857 /* ---------- custom content (when exploding) ---------------------------- */
2860 -1, ED_AREA_3X3_SETTINGS_YPOS(10),
2861 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, /* align three rows */
2862 &custom_element.content.e[0][0], 3, 3,
2863 "content:", NULL, NULL, NULL
2866 /* ---------- custom enter and leave element (when moving) --------------- */
2869 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
2870 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
2871 &custom_element.move_enter_element, 1, 1,
2872 "can dig:", " ", NULL, "element that can be digged/collected"
2875 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
2876 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
2877 &custom_element.move_leave_element, 1, 1,
2878 NULL, NULL, NULL, "element that will be left behind"
2881 /* ---------- element settings: advanced (custom elements) --------------- */
2883 /* ---------- custom change target --------------------------------------- */
2886 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
2887 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
2888 &custom_element_change.target_element, 1, 1,
2889 NULL, "after/when:", NULL, "new target element after change"
2892 /* ---------- custom change content (extended change target) ------------- */
2895 -1, ED_AREA_3X3_SETTINGS_YPOS(10),
2896 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, /* align three rows */
2897 &custom_element_change.target_content.e[0][0], 3, 3,
2898 NULL, NULL, NULL, "new extended elements after change"
2901 /* ---------- custom change trigger (element causing change) ------------- */
2904 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
2905 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
2906 &custom_element_change.trigger_element, 1, 1,
2907 NULL, NULL, NULL, "other element triggering change"
2910 /* ---------- group element content -------------------------------------- */
2913 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(4),
2914 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
2915 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
2916 "content:", NULL, NULL, NULL
2919 /* ---------- random background (for random painting) -------------------- */
2922 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2923 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
2924 &random_placement_background_element, 1, 1,
2925 NULL, NULL, NULL, "random placement background"
2931 -----------------------------------------------------------------------------
2932 some internally used variables
2933 -----------------------------------------------------------------------------
2936 /* actual size of level editor drawing area */
2937 static int ed_fieldx = MAX_ED_FIELDX - 1, ed_fieldy = MAX_ED_FIELDY - 1;
2939 /* actual position of level editor drawing area in level playfield */
2940 static int level_xpos = -1, level_ypos = -1;
2942 #define IN_ED_FIELD(x,y) ((x)>=0 && (x)<ed_fieldx && (y)>=0 &&(y)<ed_fieldy)
2944 /* drawing elements on the three mouse buttons */
2945 static int new_element1 = EL_WALL;
2946 static int new_element2 = EL_EMPTY;
2947 static int new_element3 = EL_SAND;
2949 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
2950 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
2951 (button) == 2 ? new_element2 : \
2952 (button) == 3 ? new_element3 : EL_EMPTY)
2953 #define BUTTON_STEPSIZE(button) ((button) == 1 ? 1 : (button) == 2 ? 5 : 10)
2955 /* forward declaration for internal use */
2956 static void ModifyEditorCounterValue(int, int);
2957 static void ModifyEditorCounterLimits(int, int, int);
2958 static void ModifyEditorSelectboxValue(int, int);
2959 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
2960 static void ModifyEditorDrawingArea(int, int, int);
2961 static void ModifyEditorElementList();
2962 static void AdjustElementListScrollbar();
2963 static void RedrawDrawingElements();
2964 static void DrawDrawingWindow();
2965 static void DrawLevelInfoWindow();
2966 static void DrawPropertiesWindow();
2967 static void UpdateCustomElementGraphicGadgets();
2968 static boolean checkPropertiesConfig(int);
2969 static void CopyLevelToUndoBuffer(int);
2970 static void HandleDrawingAreas(struct GadgetInfo *);
2971 static void HandleCounterButtons(struct GadgetInfo *);
2972 static void HandleTextInputGadgets(struct GadgetInfo *);
2973 static void HandleTextAreaGadgets(struct GadgetInfo *);
2974 static void HandleSelectboxGadgets(struct GadgetInfo *);
2975 static void HandleTextbuttonGadgets(struct GadgetInfo *);
2976 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
2977 static void HandleRadiobuttons(struct GadgetInfo *);
2978 static void HandleCheckbuttons(struct GadgetInfo *);
2979 static void HandleControlButtons(struct GadgetInfo *);
2980 static void HandleDrawingAreaInfo(struct GadgetInfo *);
2981 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
2983 static struct GadgetInfo *level_editor_gadget[NUM_EDITOR_GADGETS];
2984 static int right_gadget_border[NUM_EDITOR_GADGETS];
2986 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
2987 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
2988 static boolean draw_with_brush = FALSE;
2989 static int properties_element = 0;
2991 static short FieldBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2992 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2993 static int undo_buffer_position = 0;
2994 static int undo_buffer_steps = 0;
2996 static int edit_mode;
2997 static int edit_mode_properties;
2999 static int element_shift = 0;
3001 static int editor_hl_boulderdash[] =
3003 EL_INTERNAL_CASCADE_BD_ACTIVE,
3026 static int editor_el_boulderdash[] =
3043 EL_BD_BUTTERFLY_LEFT,
3045 EL_BD_BUTTERFLY_RIGHT,
3046 EL_BD_FIREFLY_RIGHT,
3049 EL_BD_BUTTERFLY_DOWN,
3053 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
3054 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
3055 static int num_editor_hl_boulderdash = SIZEOF_ARRAY_INT(editor_hl_boulderdash);
3056 static int num_editor_el_boulderdash = SIZEOF_ARRAY_INT(editor_el_boulderdash);
3058 static int editor_hl_emerald_mine[] =
3060 EL_INTERNAL_CASCADE_EM_ACTIVE,
3083 static int editor_el_emerald_mine[] =
3130 EL_ACID_POOL_TOPLEFT,
3132 EL_ACID_POOL_TOPRIGHT,
3135 EL_ACID_POOL_BOTTOMLEFT,
3136 EL_ACID_POOL_BOTTOM,
3137 EL_ACID_POOL_BOTTOMRIGHT,
3160 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
3161 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
3162 static int num_editor_hl_emerald_mine=SIZEOF_ARRAY_INT(editor_hl_emerald_mine);
3163 static int num_editor_el_emerald_mine=SIZEOF_ARRAY_INT(editor_el_emerald_mine);
3165 static int editor_hl_emerald_mine_club[] =
3167 EL_INTERNAL_CASCADE_EMC_ACTIVE,
3195 static int editor_el_emerald_mine_club[] =
3222 EL_EMC_WALL_SLIPPERY_1,
3223 EL_EMC_WALL_SLIPPERY_2,
3224 EL_EMC_WALL_SLIPPERY_3,
3225 EL_EMC_WALL_SLIPPERY_4,
3248 EL_BALLOON_SWITCH_ANY,
3252 EL_BALLOON_SWITCH_NONE,
3255 EL_BALLOON_SWITCH_LEFT,
3256 EL_BALLOON_SWITCH_RIGHT,
3257 EL_BALLOON_SWITCH_UP,
3258 EL_BALLOON_SWITCH_DOWN,
3275 EL_EMC_MAGIC_BALL_SWITCH,
3281 EL_EMC_SPRING_BUMPER,
3299 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
3300 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
3301 static int num_editor_hl_emerald_mine_club=SIZEOF_ARRAY_INT(editor_hl_emerald_mine_club);
3302 static int num_editor_el_emerald_mine_club=SIZEOF_ARRAY_INT(editor_el_emerald_mine_club);
3304 static int editor_hl_more[] =
3306 EL_INTERNAL_CASCADE_RND_ACTIVE,
3319 static int editor_el_more[] =
3347 EL_WALL_EMERALD_YELLOW,
3348 EL_WALL_EMERALD_RED,
3349 EL_WALL_EMERALD_PURPLE,
3366 EL_DYNABOMB_INCREASE_NUMBER,
3367 EL_DYNABOMB_INCREASE_SIZE,
3368 EL_DYNABOMB_INCREASE_POWER,
3392 EL_EXPANDABLE_WALL_HORIZONTAL,
3393 EL_EXPANDABLE_WALL_VERTICAL,
3394 EL_EXPANDABLE_WALL_ANY,
3396 EL_INVISIBLE_STEELWALL,
3401 static int *editor_hl_more_ptr = editor_hl_more;
3402 static int *editor_el_more_ptr = editor_el_more;
3403 static int num_editor_hl_more = SIZEOF_ARRAY_INT(editor_hl_more);
3404 static int num_editor_el_more = SIZEOF_ARRAY_INT(editor_el_more);
3406 static int editor_hl_sokoban[] =
3408 EL_INTERNAL_CASCADE_SB_ACTIVE,
3426 static int editor_el_sokoban[] =
3429 EL_SOKOBAN_FIELD_EMPTY,
3430 EL_SOKOBAN_FIELD_FULL,
3431 EL_SOKOBAN_FIELD_PLAYER,
3433 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
3434 static int *editor_el_sokoban_ptr = editor_el_sokoban;
3435 static int num_editor_hl_sokoban = SIZEOF_ARRAY_INT(editor_hl_sokoban);
3436 static int num_editor_el_sokoban = SIZEOF_ARRAY_INT(editor_el_sokoban);
3438 static int editor_hl_supaplex[] =
3440 EL_INTERNAL_CASCADE_SP_ACTIVE,
3458 static int editor_el_supaplex[] =
3471 EL_SP_HARDWARE_GRAY,
3480 EL_SP_GRAVITY_PORT_RIGHT,
3481 EL_SP_GRAVITY_PORT_DOWN,
3482 EL_SP_GRAVITY_PORT_LEFT,
3484 EL_SP_GRAVITY_PORT_UP,
3490 EL_SP_PORT_VERTICAL,
3491 EL_SP_PORT_HORIZONTAL,
3499 EL_SP_HARDWARE_BASE_1,
3500 EL_SP_HARDWARE_GREEN,
3501 EL_SP_HARDWARE_BLUE,
3504 EL_SP_HARDWARE_YELLOW,
3505 EL_SP_HARDWARE_BASE_2,
3506 EL_SP_HARDWARE_BASE_3,
3507 EL_SP_HARDWARE_BASE_4,
3509 EL_SP_HARDWARE_BASE_5,
3510 EL_SP_HARDWARE_BASE_6,
3514 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
3515 static int *editor_el_supaplex_ptr = editor_el_supaplex;
3516 static int num_editor_hl_supaplex = SIZEOF_ARRAY_INT(editor_hl_supaplex);
3517 static int num_editor_el_supaplex = SIZEOF_ARRAY_INT(editor_el_supaplex);
3519 static int editor_hl_diamond_caves[] =
3521 EL_INTERNAL_CASCADE_DC_ACTIVE,
3549 static int editor_el_diamond_caves[] =
3556 EL_CONVEYOR_BELT_1_LEFT,
3557 EL_CONVEYOR_BELT_1_MIDDLE,
3558 EL_CONVEYOR_BELT_1_RIGHT,
3559 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
3561 EL_CONVEYOR_BELT_2_LEFT,
3562 EL_CONVEYOR_BELT_2_MIDDLE,
3563 EL_CONVEYOR_BELT_2_RIGHT,
3564 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
3566 EL_CONVEYOR_BELT_3_LEFT,
3567 EL_CONVEYOR_BELT_3_MIDDLE,
3568 EL_CONVEYOR_BELT_3_RIGHT,
3569 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
3571 EL_CONVEYOR_BELT_4_LEFT,
3572 EL_CONVEYOR_BELT_4_MIDDLE,
3573 EL_CONVEYOR_BELT_4_RIGHT,
3574 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
3576 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
3577 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
3578 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
3579 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
3581 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
3582 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
3583 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
3584 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
3587 EL_SWITCHGATE_CLOSED,
3588 EL_SWITCHGATE_SWITCH_UP,
3603 EL_STEELWALL_SLIPPERY,
3606 EL_SIGN_EXCLAMATION,
3609 EL_LIGHT_SWITCH_ACTIVE,
3616 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
3617 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
3618 static int num_editor_hl_diamond_caves = SIZEOF_ARRAY_INT(editor_hl_diamond_caves);
3619 static int num_editor_el_diamond_caves = SIZEOF_ARRAY_INT(editor_el_diamond_caves);
3621 static int editor_hl_dx_boulderdash[] =
3623 EL_INTERNAL_CASCADE_DX_ACTIVE,
3651 static int editor_el_dx_boulderdash[] =
3655 EL_TUBE_HORIZONTAL_DOWN,
3659 EL_TUBE_VERTICAL_RIGHT,
3661 EL_TUBE_VERTICAL_LEFT,
3665 EL_TUBE_HORIZONTAL_UP,
3673 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
3674 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
3675 static int num_editor_hl_dx_boulderdash = SIZEOF_ARRAY_INT(editor_hl_dx_boulderdash);
3676 static int num_editor_el_dx_boulderdash = SIZEOF_ARRAY_INT(editor_el_dx_boulderdash);
3678 static int editor_hl_chars[] =
3680 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
3693 static int editor_el_chars[] =
3782 EL_CHAR(FONT_ASCII_CURSOR),
3785 static int *editor_hl_chars_ptr = editor_hl_chars;
3786 static int *editor_el_chars_ptr = editor_el_chars;
3787 static int num_editor_hl_chars = SIZEOF_ARRAY_INT(editor_hl_chars);
3788 static int num_editor_el_chars = SIZEOF_ARRAY_INT(editor_el_chars);
3790 static int editor_hl_custom[] =
3792 EL_INTERNAL_CASCADE_CE_ACTIVE,
3820 static int editor_el_custom[] =
3822 EL_CUSTOM_START + 0,
3823 EL_CUSTOM_START + 1,
3824 EL_CUSTOM_START + 2,
3825 EL_CUSTOM_START + 3,
3827 EL_CUSTOM_START + 4,
3828 EL_CUSTOM_START + 5,
3829 EL_CUSTOM_START + 6,
3830 EL_CUSTOM_START + 7,
3832 EL_CUSTOM_START + 8,
3833 EL_CUSTOM_START + 9,
3834 EL_CUSTOM_START + 10,
3835 EL_CUSTOM_START + 11,
3837 EL_CUSTOM_START + 12,
3838 EL_CUSTOM_START + 13,
3839 EL_CUSTOM_START + 14,
3840 EL_CUSTOM_START + 15,
3842 EL_CUSTOM_START + 16,
3843 EL_CUSTOM_START + 17,
3844 EL_CUSTOM_START + 18,
3845 EL_CUSTOM_START + 19,
3847 EL_CUSTOM_START + 20,
3848 EL_CUSTOM_START + 21,
3849 EL_CUSTOM_START + 22,
3850 EL_CUSTOM_START + 23,
3852 EL_CUSTOM_START + 24,
3853 EL_CUSTOM_START + 25,
3854 EL_CUSTOM_START + 26,
3855 EL_CUSTOM_START + 27,
3857 EL_CUSTOM_START + 28,
3858 EL_CUSTOM_START + 29,
3859 EL_CUSTOM_START + 30,
3860 EL_CUSTOM_START + 31,
3862 EL_CUSTOM_START + 32,
3863 EL_CUSTOM_START + 33,
3864 EL_CUSTOM_START + 34,
3865 EL_CUSTOM_START + 35,
3867 EL_CUSTOM_START + 36,
3868 EL_CUSTOM_START + 37,
3869 EL_CUSTOM_START + 38,
3870 EL_CUSTOM_START + 39,
3872 EL_CUSTOM_START + 40,
3873 EL_CUSTOM_START + 41,
3874 EL_CUSTOM_START + 42,
3875 EL_CUSTOM_START + 43,
3877 EL_CUSTOM_START + 44,
3878 EL_CUSTOM_START + 45,
3879 EL_CUSTOM_START + 46,
3880 EL_CUSTOM_START + 47,
3882 EL_CUSTOM_START + 48,
3883 EL_CUSTOM_START + 49,
3884 EL_CUSTOM_START + 50,
3885 EL_CUSTOM_START + 51,
3887 EL_CUSTOM_START + 52,
3888 EL_CUSTOM_START + 53,
3889 EL_CUSTOM_START + 54,
3890 EL_CUSTOM_START + 55,
3892 EL_CUSTOM_START + 56,
3893 EL_CUSTOM_START + 57,
3894 EL_CUSTOM_START + 58,
3895 EL_CUSTOM_START + 59,
3897 EL_CUSTOM_START + 60,
3898 EL_CUSTOM_START + 61,
3899 EL_CUSTOM_START + 62,
3900 EL_CUSTOM_START + 63,
3902 EL_CUSTOM_START + 64,
3903 EL_CUSTOM_START + 65,
3904 EL_CUSTOM_START + 66,
3905 EL_CUSTOM_START + 67,
3907 EL_CUSTOM_START + 68,
3908 EL_CUSTOM_START + 69,
3909 EL_CUSTOM_START + 70,
3910 EL_CUSTOM_START + 71,
3912 EL_CUSTOM_START + 72,
3913 EL_CUSTOM_START + 73,
3914 EL_CUSTOM_START + 74,
3915 EL_CUSTOM_START + 75,
3917 EL_CUSTOM_START + 76,
3918 EL_CUSTOM_START + 77,
3919 EL_CUSTOM_START + 78,
3920 EL_CUSTOM_START + 79,
3922 EL_CUSTOM_START + 80,
3923 EL_CUSTOM_START + 81,
3924 EL_CUSTOM_START + 82,
3925 EL_CUSTOM_START + 83,
3927 EL_CUSTOM_START + 84,
3928 EL_CUSTOM_START + 85,
3929 EL_CUSTOM_START + 86,
3930 EL_CUSTOM_START + 87,
3932 EL_CUSTOM_START + 88,
3933 EL_CUSTOM_START + 89,
3934 EL_CUSTOM_START + 90,
3935 EL_CUSTOM_START + 91,
3937 EL_CUSTOM_START + 92,
3938 EL_CUSTOM_START + 93,
3939 EL_CUSTOM_START + 94,
3940 EL_CUSTOM_START + 95,
3942 EL_CUSTOM_START + 96,
3943 EL_CUSTOM_START + 97,
3944 EL_CUSTOM_START + 98,
3945 EL_CUSTOM_START + 99,
3947 EL_CUSTOM_START + 100,
3948 EL_CUSTOM_START + 101,
3949 EL_CUSTOM_START + 102,
3950 EL_CUSTOM_START + 103,
3952 EL_CUSTOM_START + 104,
3953 EL_CUSTOM_START + 105,
3954 EL_CUSTOM_START + 106,
3955 EL_CUSTOM_START + 107,
3957 EL_CUSTOM_START + 108,
3958 EL_CUSTOM_START + 109,
3959 EL_CUSTOM_START + 110,
3960 EL_CUSTOM_START + 111,
3962 EL_CUSTOM_START + 112,
3963 EL_CUSTOM_START + 113,
3964 EL_CUSTOM_START + 114,
3965 EL_CUSTOM_START + 115,
3967 EL_CUSTOM_START + 116,
3968 EL_CUSTOM_START + 117,
3969 EL_CUSTOM_START + 118,
3970 EL_CUSTOM_START + 119,
3972 EL_CUSTOM_START + 120,
3973 EL_CUSTOM_START + 121,
3974 EL_CUSTOM_START + 122,
3975 EL_CUSTOM_START + 123,
3977 EL_CUSTOM_START + 124,
3978 EL_CUSTOM_START + 125,
3979 EL_CUSTOM_START + 126,
3980 EL_CUSTOM_START + 127,
3982 EL_CUSTOM_START + 128,
3983 EL_CUSTOM_START + 129,
3984 EL_CUSTOM_START + 130,
3985 EL_CUSTOM_START + 131,
3987 EL_CUSTOM_START + 132,
3988 EL_CUSTOM_START + 133,
3989 EL_CUSTOM_START + 134,
3990 EL_CUSTOM_START + 135,
3992 EL_CUSTOM_START + 136,
3993 EL_CUSTOM_START + 137,
3994 EL_CUSTOM_START + 138,
3995 EL_CUSTOM_START + 139,
3997 EL_CUSTOM_START + 140,
3998 EL_CUSTOM_START + 141,
3999 EL_CUSTOM_START + 142,
4000 EL_CUSTOM_START + 143,
4002 EL_CUSTOM_START + 144,
4003 EL_CUSTOM_START + 145,
4004 EL_CUSTOM_START + 146,
4005 EL_CUSTOM_START + 147,
4007 EL_CUSTOM_START + 148,
4008 EL_CUSTOM_START + 149,
4009 EL_CUSTOM_START + 150,
4010 EL_CUSTOM_START + 151,
4012 EL_CUSTOM_START + 152,
4013 EL_CUSTOM_START + 153,
4014 EL_CUSTOM_START + 154,
4015 EL_CUSTOM_START + 155,
4017 EL_CUSTOM_START + 156,
4018 EL_CUSTOM_START + 157,
4019 EL_CUSTOM_START + 158,
4020 EL_CUSTOM_START + 159,
4022 EL_CUSTOM_START + 160,
4023 EL_CUSTOM_START + 161,
4024 EL_CUSTOM_START + 162,
4025 EL_CUSTOM_START + 163,
4027 EL_CUSTOM_START + 164,
4028 EL_CUSTOM_START + 165,
4029 EL_CUSTOM_START + 166,
4030 EL_CUSTOM_START + 167,
4032 EL_CUSTOM_START + 168,
4033 EL_CUSTOM_START + 169,
4034 EL_CUSTOM_START + 170,
4035 EL_CUSTOM_START + 171,
4037 EL_CUSTOM_START + 172,
4038 EL_CUSTOM_START + 173,
4039 EL_CUSTOM_START + 174,
4040 EL_CUSTOM_START + 175,
4042 EL_CUSTOM_START + 176,
4043 EL_CUSTOM_START + 177,
4044 EL_CUSTOM_START + 178,
4045 EL_CUSTOM_START + 179,
4047 EL_CUSTOM_START + 180,
4048 EL_CUSTOM_START + 181,
4049 EL_CUSTOM_START + 182,
4050 EL_CUSTOM_START + 183,
4052 EL_CUSTOM_START + 184,
4053 EL_CUSTOM_START + 185,
4054 EL_CUSTOM_START + 186,
4055 EL_CUSTOM_START + 187,
4057 EL_CUSTOM_START + 188,
4058 EL_CUSTOM_START + 189,
4059 EL_CUSTOM_START + 190,
4060 EL_CUSTOM_START + 191,
4062 EL_CUSTOM_START + 192,
4063 EL_CUSTOM_START + 193,
4064 EL_CUSTOM_START + 194,
4065 EL_CUSTOM_START + 195,
4067 EL_CUSTOM_START + 196,
4068 EL_CUSTOM_START + 197,
4069 EL_CUSTOM_START + 198,
4070 EL_CUSTOM_START + 199,
4072 EL_CUSTOM_START + 200,
4073 EL_CUSTOM_START + 201,
4074 EL_CUSTOM_START + 202,
4075 EL_CUSTOM_START + 203,
4077 EL_CUSTOM_START + 204,
4078 EL_CUSTOM_START + 205,
4079 EL_CUSTOM_START + 206,
4080 EL_CUSTOM_START + 207,
4082 EL_CUSTOM_START + 208,
4083 EL_CUSTOM_START + 209,
4084 EL_CUSTOM_START + 210,
4085 EL_CUSTOM_START + 211,
4087 EL_CUSTOM_START + 212,
4088 EL_CUSTOM_START + 213,
4089 EL_CUSTOM_START + 214,
4090 EL_CUSTOM_START + 215,
4092 EL_CUSTOM_START + 216,
4093 EL_CUSTOM_START + 217,
4094 EL_CUSTOM_START + 218,
4095 EL_CUSTOM_START + 219,
4097 EL_CUSTOM_START + 220,
4098 EL_CUSTOM_START + 221,
4099 EL_CUSTOM_START + 222,
4100 EL_CUSTOM_START + 223,
4102 EL_CUSTOM_START + 224,
4103 EL_CUSTOM_START + 225,
4104 EL_CUSTOM_START + 226,
4105 EL_CUSTOM_START + 227,
4107 EL_CUSTOM_START + 228,
4108 EL_CUSTOM_START + 229,
4109 EL_CUSTOM_START + 230,
4110 EL_CUSTOM_START + 231,
4112 EL_CUSTOM_START + 232,
4113 EL_CUSTOM_START + 233,
4114 EL_CUSTOM_START + 234,
4115 EL_CUSTOM_START + 235,
4117 EL_CUSTOM_START + 236,
4118 EL_CUSTOM_START + 237,
4119 EL_CUSTOM_START + 238,
4120 EL_CUSTOM_START + 239,
4122 EL_CUSTOM_START + 240,
4123 EL_CUSTOM_START + 241,
4124 EL_CUSTOM_START + 242,
4125 EL_CUSTOM_START + 243,
4127 EL_CUSTOM_START + 244,
4128 EL_CUSTOM_START + 245,
4129 EL_CUSTOM_START + 246,
4130 EL_CUSTOM_START + 247,
4132 EL_CUSTOM_START + 248,
4133 EL_CUSTOM_START + 249,
4134 EL_CUSTOM_START + 250,
4135 EL_CUSTOM_START + 251,
4137 EL_CUSTOM_START + 252,
4138 EL_CUSTOM_START + 253,
4139 EL_CUSTOM_START + 254,
4140 EL_CUSTOM_START + 255,
4147 static int *editor_hl_custom_ptr = editor_hl_custom;
4148 static int *editor_el_custom_ptr = editor_el_custom;
4149 static int num_editor_hl_custom = SIZEOF_ARRAY_INT(editor_hl_custom);
4150 static int num_editor_el_custom = SIZEOF_ARRAY_INT(editor_el_custom);
4152 static int editor_hl_group[] =
4154 EL_INTERNAL_CASCADE_GE_ACTIVE,
4182 static int editor_el_group[] =
4196 EL_GROUP_START + 10,
4197 EL_GROUP_START + 11,
4199 EL_GROUP_START + 12,
4200 EL_GROUP_START + 13,
4201 EL_GROUP_START + 14,
4202 EL_GROUP_START + 15,
4204 EL_GROUP_START + 16,
4205 EL_GROUP_START + 17,
4206 EL_GROUP_START + 18,
4207 EL_GROUP_START + 19,
4209 EL_GROUP_START + 20,
4210 EL_GROUP_START + 21,
4211 EL_GROUP_START + 22,
4212 EL_GROUP_START + 23,
4214 EL_GROUP_START + 24,
4215 EL_GROUP_START + 25,
4216 EL_GROUP_START + 26,
4217 EL_GROUP_START + 27,
4219 EL_GROUP_START + 28,
4220 EL_GROUP_START + 29,
4221 EL_GROUP_START + 30,
4224 static int *editor_hl_group_ptr = editor_hl_group;
4225 static int *editor_el_group_ptr = editor_el_group;
4226 static int num_editor_hl_group = SIZEOF_ARRAY_INT(editor_hl_group);
4227 static int num_editor_el_group = SIZEOF_ARRAY_INT(editor_el_group);
4229 static int editor_hl_user_defined[] =
4231 EL_INTERNAL_CASCADE_USER_ACTIVE,
4254 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
4255 static int *editor_el_user_defined_ptr = NULL;
4256 static int num_editor_hl_user_defined=SIZEOF_ARRAY_INT(editor_hl_user_defined);
4257 static int num_editor_el_user_defined = 0;
4259 static int editor_hl_dynamic[] =
4261 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
4267 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
4268 static int *editor_el_dynamic_ptr = NULL;
4269 static int num_editor_hl_dynamic = SIZEOF_ARRAY_INT(editor_hl_dynamic);
4270 static int num_editor_el_dynamic = 0;
4272 static int editor_hl_empty[] = { };
4273 static int editor_el_empty[ED_NUM_ELEMENTLIST_BUTTONS];
4275 static int *editor_hl_empty_ptr = editor_hl_empty;
4276 static int *editor_el_empty_ptr = editor_el_empty;
4277 static int num_editor_hl_empty = 0;
4278 static int num_editor_el_empty = 0; /* dynamically determined, if needed */
4280 static boolean use_el_empty = FALSE;
4282 static int *editor_elements = NULL; /* dynamically allocated */
4283 static int num_editor_elements = 0; /* dynamically determined */
4287 boolean *setup_value;
4288 boolean *setup_cascade_value;
4290 int **headline_list;
4291 int *headline_list_size;
4294 int *element_list_size;
4296 boolean last_setup_value;
4298 editor_elements_info[] =
4301 &setup.editor.el_boulderdash,
4302 &setup.editor_cascade.el_bd,
4303 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
4304 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
4307 &setup.editor.el_emerald_mine,
4308 &setup.editor_cascade.el_em,
4309 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
4310 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
4313 &setup.editor.el_emerald_mine_club,
4314 &setup.editor_cascade.el_emc,
4315 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
4316 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
4319 &setup.editor.el_more,
4320 &setup.editor_cascade.el_rnd,
4321 &editor_hl_more_ptr, &num_editor_hl_more,
4322 &editor_el_more_ptr, &num_editor_el_more
4325 &setup.editor.el_sokoban,
4326 &setup.editor_cascade.el_sb,
4327 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
4328 &editor_el_sokoban_ptr, &num_editor_el_sokoban
4331 &setup.editor.el_supaplex,
4332 &setup.editor_cascade.el_sp,
4333 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
4334 &editor_el_supaplex_ptr, &num_editor_el_supaplex
4337 &setup.editor.el_diamond_caves,
4338 &setup.editor_cascade.el_dc,
4339 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
4340 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
4343 &setup.editor.el_dx_boulderdash,
4344 &setup.editor_cascade.el_dx,
4345 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
4346 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
4349 &setup.editor.el_chars,
4350 &setup.editor_cascade.el_chars,
4351 &editor_hl_chars_ptr, &num_editor_hl_chars,
4352 &editor_el_chars_ptr, &num_editor_el_chars
4355 &setup.editor.el_custom,
4356 &setup.editor_cascade.el_ce,
4357 &editor_hl_custom_ptr, &num_editor_hl_custom,
4358 &editor_el_custom_ptr, &num_editor_el_custom
4361 &setup.editor.el_custom,
4362 &setup.editor_cascade.el_ge,
4363 &editor_hl_group_ptr, &num_editor_hl_group,
4364 &editor_el_group_ptr, &num_editor_el_group
4367 &setup.editor.el_user_defined,
4368 &setup.editor_cascade.el_user,
4369 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
4370 &editor_el_user_defined_ptr, &num_editor_el_user_defined
4373 &setup.editor.el_dynamic,
4374 &setup.editor_cascade.el_dynamic,
4375 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
4376 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
4381 &editor_hl_empty_ptr, &num_editor_hl_empty,
4382 &editor_el_empty_ptr, &num_editor_el_empty,
4394 -----------------------------------------------------------------------------
4396 -----------------------------------------------------------------------------
4399 static int getMaxInfoTextLength()
4401 return (SXSIZE / getFontWidth(FONT_TEXT_2));
4404 static int getTextWidthForGadget(char *text)
4409 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
4412 static int getTextWidthForDrawingArea(char *text)
4417 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
4420 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
4422 return (gi->x + gi->width + getTextWidthForGadget(text));
4425 static char *getElementInfoText(int element)
4427 char *info_text = NULL;
4430 if (element < MAX_NUM_ELEMENTS)
4432 if (element < NUM_FILE_ELEMENTS)
4435 if (strlen(element_info[element].description) > 0)
4436 info_text = element_info[element].description;
4437 else if (element_info[element].custom_description != NULL)
4438 info_text = element_info[element].custom_description;
4439 else if (element_info[element].editor_description != NULL)
4440 info_text = element_info[element].editor_description;
4443 if (info_text == NULL)
4444 info_text = INFOTEXT_UNKNOWN_ELEMENT;
4449 static void InitDynamicEditorElementList(int **elements, int *num_elements)
4451 boolean element_found[NUM_FILE_ELEMENTS];
4454 /* initialize list of used elements to "not used" */
4455 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
4456 element_found[i] = FALSE;
4458 /* find all elements used in current level */
4459 for (y = 0; y < lev_fieldy; y++)
4460 for (x = 0; x < lev_fieldx; x++)
4461 if (Feld[x][y] < NUM_FILE_ELEMENTS) /* should always be true */
4462 element_found[Feld[x][y]] = TRUE;
4466 /* count number of elements used in current level */
4467 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
4468 if (element_found[i])
4471 /* add space for up to 3 more elements for padding that may be needed */
4474 /* free memory for old list of elements, if needed */
4475 checked_free(*elements);
4477 /* allocate memory for new list of elements */
4478 *elements = checked_malloc(*num_elements * sizeof(int));
4482 /* add all elements used in current level (non-custom/group elements) */
4483 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
4484 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
4485 (*elements)[(*num_elements)++] = i;
4487 /* add all elements used in current level (custom/group elements) */
4488 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
4489 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
4490 (*elements)[(*num_elements)++] = i;
4492 while (*num_elements % 4) /* pad with empty elements, if needed */
4493 (*elements)[(*num_elements)++] = EL_EMPTY;
4496 static void ReinitializeElementList()
4498 static boolean initialization_needed = TRUE;
4502 if (initialization_needed)
4504 LoadSetup_EditorCascade(); /* load last editor cascade state */
4506 /* initialize editor cascade element from saved cascade state */
4507 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4509 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
4510 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
4512 if (IS_EDITOR_CASCADE(*cascade_element))
4514 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
4515 EL_CASCADE_INACTIVE(*cascade_element));
4518 initialization_needed = FALSE;
4521 checked_free(editor_elements);
4523 /* reload optional user defined element list for each invocation of editor */
4524 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
4525 &num_editor_el_user_defined);
4527 /* initialize dynamic level element list for each invocation of editor */
4528 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
4529 &num_editor_el_dynamic);
4531 /* initialize list of empty elements (used for padding, if needed) */
4532 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
4533 editor_el_empty[i] = EL_EMPTY;
4535 /* do some sanity checks for each element from element list */
4536 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4538 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
4540 int element = (*editor_elements_info[i].element_list)[j];
4542 if (element >= NUM_FILE_ELEMENTS)
4543 Error(ERR_WARN, "editor element %d is runtime element", element);
4545 if (strcmp(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT) == 0)
4546 Error(ERR_WARN, "no element description for element %d", element);
4550 num_editor_elements = 0;
4551 use_el_empty = FALSE;
4553 /* determine size of element list */
4554 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4556 boolean found_inactive_cascade = FALSE;
4558 if (*editor_elements_info[i].setup_value)
4560 if (setup.editor.el_headlines)
4562 num_editor_elements += *editor_elements_info[i].headline_list_size;
4564 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
4566 int element = (*editor_elements_info[i].headline_list)[j];
4568 if (IS_EDITOR_CASCADE_INACTIVE(element))
4569 found_inactive_cascade = TRUE;
4573 if (found_inactive_cascade)
4576 num_editor_elements += *editor_elements_info[i].element_list_size;
4580 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
4582 /* offer at least as many elements as element buttons exist */
4583 use_el_empty = TRUE;
4584 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
4586 num_editor_elements += num_editor_el_empty;
4589 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
4591 /* fill element list */
4592 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4594 boolean found_inactive_cascade = FALSE;
4596 if (*editor_elements_info[i].setup_value)
4598 if (setup.editor.el_headlines)
4600 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
4602 int element = (*editor_elements_info[i].headline_list)[j];
4604 editor_elements[pos++] = element;
4606 if (IS_EDITOR_CASCADE_INACTIVE(element))
4607 found_inactive_cascade = TRUE;
4611 if (found_inactive_cascade)
4614 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
4615 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
4619 /* this function is also called before editor gadgets are initialized */
4620 if (level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL] != NULL)
4621 AdjustElementListScrollbar();
4624 void PrintEditorElementList()
4626 boolean *stop = &setup.editor.el_user_defined;
4629 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
4631 int cascade_element = (*editor_elements_info[i].headline_list)[0];
4633 if (IS_EDITOR_CASCADE(cascade_element))
4635 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
4636 char *headline = element_info[cascade_element_show].editor_description;
4638 printf_line_with_prefix("# ", "-", 77);
4639 printf("# %s\n", headline);
4640 printf_line_with_prefix("# ", "-", 77);
4643 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
4645 int element = (*editor_elements_info[i].headline_list)[j];
4647 if (IS_EDITOR_CASCADE(element))
4648 element = EL_CHAR_MINUS;
4650 printf("# %s\n", element_info[element].token_name);
4656 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
4658 int element = (*editor_elements_info[i].element_list)[j];
4660 printf("# %s\n", element_info[element].token_name);
4668 static void ReinitializeElementListButtons()
4670 static boolean last_setup_value_headlines = FALSE;
4671 static boolean initialization_needed = TRUE;
4674 if (!initialization_needed) /* check if editor element setup has changed */
4676 if (last_setup_value_headlines != setup.editor.el_headlines)
4677 initialization_needed = TRUE;
4679 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4680 if (editor_elements_info[i].last_setup_value !=
4681 *editor_elements_info[i].setup_value)
4682 initialization_needed = TRUE;
4685 if (!initialization_needed)
4688 FreeLevelEditorGadgets();
4689 CreateLevelEditorGadgets();
4691 /* store current setup values for next invocation of this function */
4692 last_setup_value_headlines = setup.editor.el_headlines;
4693 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4694 editor_elements_info[i].last_setup_value =
4695 *editor_elements_info[i].setup_value;
4697 initialization_needed = FALSE;
4700 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
4703 int border_graphic =
4704 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
4707 int num_mini_tilex = width / MINI_TILEX + 1;
4708 int num_mini_tiley = height / MINI_TILEY + 1;
4709 int from_x = dest_x - MINI_TILEX / 2;
4710 int from_y = dest_y - MINI_TILEY / 2;
4711 int to_x = from_x + num_mini_tilex * MINI_TILEX - 1;
4712 int to_y = from_y + num_mini_tiley * MINI_TILEY - 1;
4715 getMiniGraphicSource(border_graphic, &src_bitmap, &src_x, &src_y);
4717 for (y = 0; y < num_mini_tiley; y++)
4718 for (x = 0; x < num_mini_tilex; x++)
4719 BlitBitmap(src_bitmap, drawto, src_x, src_y, MINI_TILEX, MINI_TILEY,
4720 from_x + x * MINI_TILEX, from_y + y * MINI_TILEY);
4722 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
4724 DrawSimpleBlackLine(drawto, from_x, from_y, to_x, from_y);
4725 DrawSimpleBlackLine(drawto, to_x, from_y, to_x, to_y);
4726 DrawSimpleBlackLine(drawto, to_x, to_y, from_x, to_y);
4727 DrawSimpleBlackLine(drawto, from_x, to_y, from_x, from_y);
4730 static void DrawDrawingArea(int id)
4732 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
4735 int *value = drawingarea_info[id].value;
4736 int area_xsize = drawingarea_info[id].area_xsize;
4737 int area_ysize = drawingarea_info[id].area_ysize;
4739 for (x = 0; x < area_xsize; x++)
4740 for (y = 0; y < area_ysize; y++)
4741 DrawMiniGraphicExt(drawto,
4742 gi->x + x * MINI_TILEX,
4743 gi->y + y * MINI_TILEY,
4744 el2edimg(value[x * area_ysize + y]));
4747 static void ScrollMiniLevel(int from_x, int from_y, int scroll)
4750 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
4751 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
4753 BlitBitmap(drawto, drawto,
4754 SX + (dx == -1 ? MINI_TILEX : 0),
4755 SY + (dy == -1 ? MINI_TILEY : 0),
4756 (ed_fieldx * MINI_TILEX) - (dx != 0 ? MINI_TILEX : 0),
4757 (ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0),
4758 SX + (dx == +1 ? MINI_TILEX : 0),
4759 SY + (dy == +1 ? MINI_TILEY : 0));
4762 x = (dx == 1 ? 0 : ed_fieldx - 1);
4763 for (y = 0; y < ed_fieldy; y++)
4764 DrawMiniElementOrWall(x, y, from_x, from_y);
4768 y = (dy == 1 ? 0 : ed_fieldy - 1);
4769 for (x = 0; x < ed_fieldx; x++)
4770 DrawMiniElementOrWall(x, y, from_x, from_y);
4773 redraw_mask |= REDRAW_FIELD;
4777 static void CreateControlButtons()
4779 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4780 struct GadgetInfo *gi;
4781 unsigned long event_mask;
4784 /* create toolbox buttons */
4785 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
4789 int gd_xoffset, gd_yoffset;
4790 int gd_x1, gd_x2, gd_y1, gd_y2;
4792 int radio_button_nr;
4795 if (id == GADGET_ID_SINGLE_ITEMS ||
4796 id == GADGET_ID_CONNECTED_ITEMS ||
4797 id == GADGET_ID_LINE ||
4798 id == GADGET_ID_ARC ||
4799 id == GADGET_ID_TEXT ||
4800 id == GADGET_ID_RECTANGLE ||
4801 id == GADGET_ID_FILLED_BOX ||
4802 id == GADGET_ID_FLOOD_FILL ||
4803 id == GADGET_ID_GRAB_BRUSH ||
4804 id == GADGET_ID_PICK_ELEMENT ||
4805 id == GADGET_ID_CUSTOM_COPY_FROM ||
4806 id == GADGET_ID_CUSTOM_COPY_TO ||
4807 id == GADGET_ID_CUSTOM_EXCHANGE)
4809 button_type = GD_TYPE_RADIO_BUTTON;
4810 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
4811 checked = (id == drawing_function ? TRUE : FALSE);
4812 event_mask = GD_EVENT_PRESSED;
4816 button_type = GD_TYPE_NORMAL_BUTTON;
4817 radio_button_nr = RADIO_NR_NONE;
4820 if (id == GADGET_ID_WRAP_LEFT ||
4821 id == GADGET_ID_WRAP_RIGHT ||
4822 id == GADGET_ID_WRAP_UP ||
4823 id == GADGET_ID_WRAP_DOWN)
4824 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
4826 event_mask = GD_EVENT_RELEASED;
4829 if (id < ED_NUM_CTRL1_BUTTONS)
4831 int x = i % ED_CTRL1_BUTTONS_HORIZ;
4832 int y = i / ED_CTRL1_BUTTONS_HORIZ;
4834 gd_xoffset = ED_CTRL1_BUTTONS_XPOS + x * ED_CTRL1_BUTTON_XSIZE;
4835 gd_yoffset = ED_CTRL1_BUTTONS_YPOS + y * ED_CTRL1_BUTTON_YSIZE;
4836 width = ED_CTRL1_BUTTON_XSIZE;
4837 height = ED_CTRL1_BUTTON_YSIZE;
4839 gd_x1 = DOOR_GFX_PAGEX8 + gd_xoffset;
4840 gd_x2 = DOOR_GFX_PAGEX7 + gd_xoffset;
4841 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL1_BUTTONS_GFX_YPOS + gd_yoffset;
4842 gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL1_BUTTONS_ALT_GFX_YPOS + gd_yoffset;
4844 else if (id < ED_NUM_CTRL1_2_BUTTONS)
4846 int x = (i - ED_NUM_CTRL1_BUTTONS) % ED_CTRL2_BUTTONS_HORIZ;
4847 int y = (i - ED_NUM_CTRL1_BUTTONS) / ED_CTRL2_BUTTONS_HORIZ;
4849 gd_xoffset = ED_CTRL2_BUTTONS_XPOS + x * ED_CTRL2_BUTTON_XSIZE;
4850 gd_yoffset = ED_CTRL2_BUTTONS_YPOS + y * ED_CTRL2_BUTTON_YSIZE;
4851 width = ED_CTRL2_BUTTON_XSIZE;
4852 height = ED_CTRL2_BUTTON_YSIZE;
4854 gd_x1 = DOOR_GFX_PAGEX8 + gd_xoffset;
4855 gd_x2 = DOOR_GFX_PAGEX7 + gd_xoffset;
4856 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL2_BUTTONS_GFX_YPOS + gd_yoffset;
4857 gd_y2 = 0; /* no alternative graphic for these buttons */
4859 else if (id < ED_NUM_CTRL1_3_BUTTONS)
4861 int x = (i - ED_NUM_CTRL1_2_BUTTONS) % ED_CTRL3_BUTTONS_HORIZ + 1;
4862 int y = (i - ED_NUM_CTRL1_2_BUTTONS) / ED_CTRL3_BUTTONS_HORIZ;
4864 gd_xoffset = ED_CTRL3_BUTTONS_XPOS + x * ED_CTRL3_BUTTON_XSIZE;
4865 gd_yoffset = ED_CTRL3_BUTTONS_YPOS + y * ED_CTRL3_BUTTON_YSIZE;
4866 width = ED_CTRL3_BUTTON_XSIZE;
4867 height = ED_CTRL3_BUTTON_YSIZE;
4869 gd_x1 = DOOR_GFX_PAGEX6 + gd_xoffset;
4870 gd_x2 = DOOR_GFX_PAGEX5 + gd_xoffset;
4871 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL3_BUTTONS_GFX_YPOS + gd_yoffset;
4872 gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL3_BUTTONS_ALT_GFX_YPOS + gd_yoffset;
4876 int x = (i - ED_NUM_CTRL1_3_BUTTONS) % ED_CTRL4_BUTTONS_HORIZ;
4877 int y = (i - ED_NUM_CTRL1_3_BUTTONS) / ED_CTRL4_BUTTONS_HORIZ + 3;
4879 gd_xoffset = ED_CTRL4_BUTTONS_XPOS + x * ED_CTRL4_BUTTON_XSIZE;
4880 gd_yoffset = ED_CTRL4_BUTTONS_YPOS + y * ED_CTRL4_BUTTON_YSIZE;
4881 width = ED_CTRL4_BUTTON_XSIZE;
4882 height = ED_CTRL4_BUTTON_YSIZE;
4884 gd_x1 = DOOR_GFX_PAGEX6 + ED_CTRL4_BUTTONS_GFX_XPOS + gd_xoffset;
4885 gd_x2 = DOOR_GFX_PAGEX5 + ED_CTRL4_BUTTONS_GFX_XPOS + gd_xoffset;
4886 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL4_BUTTONS_GFX_YPOS + gd_yoffset;
4887 gd_y2 = 0; /* no alternative graphic for these buttons */
4890 gi = CreateGadget(GDI_CUSTOM_ID, id,
4891 GDI_CUSTOM_TYPE_ID, i,
4892 GDI_INFO_TEXT, control_info[i].text,
4893 GDI_X, EX + gd_xoffset,
4894 GDI_Y, EY + gd_yoffset,
4897 GDI_TYPE, button_type,
4898 GDI_STATE, GD_BUTTON_UNPRESSED,
4899 GDI_RADIO_NR, radio_button_nr,
4900 GDI_CHECKED, checked,
4901 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
4902 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y1,
4903 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2,
4904 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
4905 GDI_EVENT_MASK, event_mask,
4906 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4907 GDI_CALLBACK_ACTION, HandleControlButtons,
4911 Error(ERR_EXIT, "cannot create gadget");
4913 level_editor_gadget[id] = gi;
4916 /* create buttons for scrolling of drawing area and element list */
4917 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
4919 int id = scrollbutton_info[i].gadget_id;
4920 int x, y, width, height;
4921 int gd_x1, gd_x2, gd_y1, gd_y2;
4923 x = scrollbutton_info[i].x;
4924 y = scrollbutton_info[i].y;
4926 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
4928 if (id == GADGET_ID_SCROLL_LIST_UP ||
4929 id == GADGET_ID_SCROLL_LIST_DOWN)
4933 width = ED_SCROLLBUTTON2_XSIZE;
4934 height = ED_SCROLLBUTTON2_YSIZE;
4935 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].gd_x;
4936 gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].gd_y;
4937 gd_x2 = gd_x1 - ED_SCROLLBUTTON2_XSIZE;
4944 width = ED_SCROLLBUTTON_XSIZE;
4945 height = ED_SCROLLBUTTON_YSIZE;
4946 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].gd_x;
4947 gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].gd_y;
4948 gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE;
4952 gi = CreateGadget(GDI_CUSTOM_ID, id,
4953 GDI_CUSTOM_TYPE_ID, i,
4954 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
4959 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
4960 GDI_STATE, GD_BUTTON_UNPRESSED,
4961 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
4962 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
4963 GDI_EVENT_MASK, event_mask,
4964 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4965 GDI_CALLBACK_ACTION, HandleControlButtons,
4969 Error(ERR_EXIT, "cannot create gadget");
4971 level_editor_gadget[id] = gi;
4974 /* create buttons for element list */
4975 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
4977 Bitmap *deco_bitmap;
4978 int deco_x, deco_y, deco_xpos, deco_ypos;
4979 int gd_xoffset, gd_yoffset;
4980 int gd_x1, gd_x2, gd_y;
4981 int x = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
4982 int y = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
4983 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
4984 int element = editor_elements[i];
4986 event_mask = GD_EVENT_RELEASED;
4988 gd_xoffset = ED_ELEMENTLIST_XPOS + x * ED_ELEMENTLIST_XSIZE;
4989 gd_yoffset = ED_ELEMENTLIST_YPOS + y * ED_ELEMENTLIST_YSIZE;
4991 gd_x1 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS + ED_ELEMENTLIST_XSIZE;
4992 gd_x2 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS;
4993 gd_y = DOOR_GFX_PAGEY1 + ED_ELEMENTLIST_YPOS;
4995 getMiniGraphicSource(el2edimg(element), &deco_bitmap, &deco_x, &deco_y);
4996 deco_xpos = (ED_ELEMENTLIST_XSIZE - MINI_TILEX) / 2;
4997 deco_ypos = (ED_ELEMENTLIST_YSIZE - MINI_TILEY) / 2;
4999 gi = CreateGadget(GDI_CUSTOM_ID, id,
5000 GDI_CUSTOM_TYPE_ID, i,
5001 GDI_INFO_TEXT, getElementInfoText(element),
5002 GDI_X, DX + gd_xoffset,
5003 GDI_Y, DY + gd_yoffset,
5004 GDI_WIDTH, ED_ELEMENTLIST_XSIZE,
5005 GDI_HEIGHT, ED_ELEMENTLIST_YSIZE,
5006 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
5007 GDI_STATE, GD_BUTTON_UNPRESSED,
5008 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
5009 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
5010 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
5011 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
5012 GDI_DECORATION_SIZE, MINI_TILEX, MINI_TILEY,
5013 GDI_DECORATION_SHIFTING, 1, 1,
5014 GDI_EVENT_MASK, event_mask,
5015 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5016 GDI_CALLBACK_ACTION, HandleControlButtons,
5020 Error(ERR_EXIT, "cannot create gadget");
5022 level_editor_gadget[id] = gi;
5026 static void CreateCounterButtons()
5028 int max_infotext_len = getMaxInfoTextLength();
5031 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
5034 int x = SX + counterbutton_info[i].x; /* down count button */
5035 int y = SY + counterbutton_info[i].y;
5037 /* determine horizontal position to the right of specified gadget */
5038 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
5039 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
5040 ED_GADGET_TEXT_DISTANCE);
5042 /* determine horizontal offset for leading text */
5043 if (counterbutton_info[i].text_left != NULL)
5044 x += getTextWidthForGadget(counterbutton_info[i].text_left);
5046 for (j = 0; j < 2; j++)
5048 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5049 struct GadgetInfo *gi;
5051 counterbutton_info[i].gadget_id_down :
5052 counterbutton_info[i].gadget_id_up);
5054 int gd_x, gd_x1, gd_x2, gd_y;
5056 unsigned long event_mask;
5057 char infotext[max_infotext_len + 1];
5059 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5061 if (i == ED_COUNTER_ID_SELECT_LEVEL)
5064 ED_SCROLLBUTTON_ID_AREA_LEFT :
5065 ED_SCROLLBUTTON_ID_AREA_RIGHT);
5067 event_mask |= GD_EVENT_RELEASED;
5070 x += 2 * ED_GADGET_DISTANCE;
5071 y += ED_GADGET_DISTANCE;
5073 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[sid].gd_x;
5074 gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE;
5075 gd_y = DOOR_GFX_PAGEY1 + scrollbutton_info[sid].gd_y;
5076 x_size = ED_SCROLLBUTTON_XSIZE;
5077 y_size = ED_SCROLLBUTTON_YSIZE;
5081 gd_xoffset = (j == 0 ? ED_BUTTON_MINUS_XPOS : ED_BUTTON_PLUS_XPOS);
5082 gd_x1 = DOOR_GFX_PAGEX4 + gd_xoffset;
5083 gd_x2 = DOOR_GFX_PAGEX3 + gd_xoffset;
5084 gd_y = DOOR_GFX_PAGEY1 + ED_BUTTON_COUNT_YPOS;
5085 x_size = ED_BUTTON_COUNT_XSIZE;
5086 y_size = ED_BUTTON_COUNT_YSIZE;
5089 sprintf(infotext, "%s counter value by 1, 5 or 10",
5090 (j == 0 ? "decrease" : "increase"));
5092 gi = CreateGadget(GDI_CUSTOM_ID, id,
5093 GDI_CUSTOM_TYPE_ID, i,
5094 GDI_INFO_TEXT, infotext,
5099 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
5100 GDI_STATE, GD_BUTTON_UNPRESSED,
5101 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
5102 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
5103 GDI_EVENT_MASK, event_mask,
5104 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5105 GDI_CALLBACK_ACTION, HandleCounterButtons,
5109 Error(ERR_EXIT, "cannot create gadget");
5111 level_editor_gadget[id] = gi;
5112 right_gadget_border[id] =
5113 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
5115 x += gi->width + ED_GADGET_DISTANCE; /* text count button */
5119 int font_type = FONT_INPUT_1;
5120 int font_type_active = FONT_INPUT_1_ACTIVE;
5121 int gd_width = ED_WIN_COUNT_XSIZE;
5123 id = counterbutton_info[i].gadget_id_text;
5124 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
5126 if (i == ED_COUNTER_ID_SELECT_LEVEL)
5128 font_type = FONT_LEVEL_NUMBER;
5129 font_type_active = FONT_LEVEL_NUMBER;
5131 x += 2 * ED_GADGET_DISTANCE;
5132 y -= ED_GADGET_DISTANCE;
5134 gd_x = DOOR_GFX_PAGEX6 + ED_WIN_COUNT2_XPOS;
5135 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT2_YPOS;
5136 gd_width = ED_WIN_COUNT2_XSIZE;
5140 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
5141 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
5144 gi = CreateGadget(GDI_CUSTOM_ID, id,
5145 GDI_CUSTOM_TYPE_ID, i,
5146 GDI_INFO_TEXT, "enter counter value",
5149 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
5150 GDI_NUMBER_VALUE, 0,
5151 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
5152 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
5153 GDI_TEXT_SIZE, 3, /* minimal counter text size */
5154 GDI_TEXT_FONT, font_type,
5155 GDI_TEXT_FONT_ACTIVE, font_type_active,
5156 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
5157 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
5158 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5159 GDI_DESIGN_WIDTH, gd_width,
5160 GDI_EVENT_MASK, event_mask,
5161 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5162 GDI_CALLBACK_ACTION, HandleCounterButtons,
5166 Error(ERR_EXIT, "cannot create gadget");
5168 level_editor_gadget[id] = gi;
5169 right_gadget_border[id] =
5170 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
5172 x += gi->width + ED_GADGET_DISTANCE; /* up count button */
5178 static void CreateDrawingAreas()
5182 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
5184 struct GadgetInfo *gi;
5185 unsigned long event_mask;
5186 int id = drawingarea_info[i].gadget_id;
5187 int x = SX + drawingarea_info[i].x;
5188 int y = SY + drawingarea_info[i].y;
5189 int area_xsize = drawingarea_info[i].area_xsize;
5190 int area_ysize = drawingarea_info[i].area_ysize;
5193 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
5194 GD_EVENT_OFF_BORDERS;
5196 /* determine horizontal position to the right of specified gadget */
5197 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
5198 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
5199 ED_DRAWINGAREA_TEXT_DISTANCE);
5201 /* determine horizontal offset for leading text */
5202 if (drawingarea_info[i].text_left != NULL)
5203 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
5205 gi = CreateGadget(GDI_CUSTOM_ID, id,
5206 GDI_CUSTOM_TYPE_ID, i,
5209 GDI_TYPE, GD_TYPE_DRAWING_AREA,
5210 GDI_AREA_SIZE, area_xsize, area_ysize,
5211 GDI_ITEM_SIZE, MINI_TILEX, MINI_TILEY,
5212 GDI_EVENT_MASK, event_mask,
5213 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
5214 GDI_CALLBACK_ACTION, HandleDrawingAreas,
5218 Error(ERR_EXIT, "cannot create gadget");
5220 level_editor_gadget[id] = gi;
5221 right_gadget_border[id] =
5222 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
5226 static void CreateTextInputGadgets()
5228 int max_infotext_len = getMaxInfoTextLength();
5231 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
5233 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5235 struct GadgetInfo *gi;
5236 unsigned long event_mask;
5237 char infotext[MAX_OUTPUT_LINESIZE + 1];
5238 int id = textinput_info[i].gadget_id;
5240 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
5242 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
5243 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
5245 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
5246 infotext[max_infotext_len] = '\0';
5248 gi = CreateGadget(GDI_CUSTOM_ID, id,
5249 GDI_CUSTOM_TYPE_ID, i,
5250 GDI_INFO_TEXT, infotext,
5251 GDI_X, SX + textinput_info[i].x,
5252 GDI_Y, SY + textinput_info[i].y,
5253 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
5254 GDI_TEXT_VALUE, textinput_info[i].value,
5255 GDI_TEXT_SIZE, textinput_info[i].size,
5256 GDI_TEXT_FONT, FONT_INPUT_1,
5257 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
5258 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
5259 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
5260 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5261 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
5262 GDI_EVENT_MASK, event_mask,
5263 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5264 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
5268 Error(ERR_EXIT, "cannot create gadget");
5270 level_editor_gadget[id] = gi;
5274 static void CreateTextAreaGadgets()
5276 int max_infotext_len = getMaxInfoTextLength();
5279 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
5281 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5283 struct GadgetInfo *gi;
5284 unsigned long event_mask;
5285 char infotext[MAX_OUTPUT_LINESIZE + 1];
5286 int id = textarea_info[i].gadget_id;
5287 int area_xsize = textarea_info[i].xsize;
5288 int area_ysize = textarea_info[i].ysize;
5290 event_mask = GD_EVENT_TEXT_LEAVING;
5292 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
5293 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
5295 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
5296 infotext[max_infotext_len] = '\0';
5298 gi = CreateGadget(GDI_CUSTOM_ID, id,
5299 GDI_CUSTOM_TYPE_ID, i,
5300 GDI_INFO_TEXT, infotext,
5301 GDI_X, SX + textarea_info[i].x,
5302 GDI_Y, SY + textarea_info[i].y,
5303 GDI_TYPE, GD_TYPE_TEXT_AREA,
5304 GDI_AREA_SIZE, area_xsize, area_ysize,
5305 GDI_TEXT_FONT, FONT_INPUT_1,
5306 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
5307 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
5308 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
5309 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5310 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
5311 GDI_EVENT_MASK, event_mask,
5312 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5313 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
5317 Error(ERR_EXIT, "cannot create gadget");
5319 level_editor_gadget[id] = gi;
5323 static void CreateSelectboxGadgets()
5325 int max_infotext_len = getMaxInfoTextLength();
5328 for (i = 0; i < ED_NUM_SELECTBOX; i++)
5330 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5332 struct GadgetInfo *gi;
5333 unsigned long event_mask;
5334 char infotext[MAX_OUTPUT_LINESIZE + 1];
5335 int id = selectbox_info[i].gadget_id;
5336 int x = SX + selectbox_info[i].x;
5337 int y = SY + selectbox_info[i].y;
5339 if (selectbox_info[i].size == -1) /* dynamically determine size */
5341 /* (we cannot use -1 for uninitialized values if we directly compare
5342 with results from strlen(), because the '<' and '>' operation will
5343 implicitely cast -1 to an unsigned integer value!) */
5344 selectbox_info[i].size = 0;
5346 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
5347 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
5348 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
5350 selectbox_info[i].size++; /* add one character empty space */
5353 event_mask = GD_EVENT_RELEASED |
5354 GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
5356 gd_x = DOOR_GFX_PAGEX4 + ED_SELECTBOX_XPOS;
5357 gd_y = DOOR_GFX_PAGEY1 + ED_SELECTBOX_YPOS;
5359 /* determine horizontal position to the right of specified gadget */
5360 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
5361 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
5362 ED_GADGET_TEXT_DISTANCE);
5364 /* determine horizontal offset for leading text */
5365 if (selectbox_info[i].text_left != NULL)
5366 x += getTextWidthForGadget(selectbox_info[i].text_left);
5368 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
5369 infotext[max_infotext_len] = '\0';
5371 gi = CreateGadget(GDI_CUSTOM_ID, id,
5372 GDI_CUSTOM_TYPE_ID, i,
5373 GDI_INFO_TEXT, infotext,
5376 GDI_TYPE, GD_TYPE_SELECTBOX,
5377 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
5378 GDI_TEXT_SIZE, selectbox_info[i].size,
5379 GDI_TEXT_FONT, FONT_INPUT_1,
5380 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
5381 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
5382 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
5383 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5384 GDI_BORDER_SIZE_SELECTBUTTON, ED_SELECTBOX_BUTTON_XSIZE,
5385 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
5386 GDI_EVENT_MASK, event_mask,
5387 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5388 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
5392 Error(ERR_EXIT, "cannot create gadget");
5394 level_editor_gadget[id] = gi;
5395 right_gadget_border[id] =
5396 getRightGadgetBorder(gi, selectbox_info[i].text_right);
5400 static void CreateTextbuttonGadgets()
5402 int max_infotext_len = getMaxInfoTextLength();
5405 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
5407 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5408 int gd_x1, gd_x2, gd_y1, gd_y2;
5409 struct GadgetInfo *gi;
5410 unsigned long event_mask;
5411 char infotext[MAX_OUTPUT_LINESIZE + 1];
5412 int id = textbutton_info[i].gadget_id;
5413 int x = SX + textbutton_info[i].x;
5414 int y = SY + textbutton_info[i].y;
5416 if (textbutton_info[i].size == -1) /* dynamically determine size */
5417 textbutton_info[i].size = strlen(textbutton_info[i].text);
5419 event_mask = GD_EVENT_RELEASED;
5421 if (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE)
5423 gd_x1 = DOOR_GFX_PAGEX4 + ED_TEXTBUTTON_TAB_XPOS;
5424 gd_x2 = DOOR_GFX_PAGEX3 + ED_TEXTBUTTON_TAB_XPOS;
5425 gd_y1 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_TAB_YPOS;
5426 gd_y2 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_TAB_INACTIVE_YPOS;
5430 gd_x1 = DOOR_GFX_PAGEX4 + ED_TEXTBUTTON_XPOS;
5431 gd_x2 = DOOR_GFX_PAGEX3 + ED_TEXTBUTTON_XPOS;
5432 gd_y1 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_YPOS;
5433 gd_y2 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_INACTIVE_YPOS;
5436 sprintf(infotext, "%s", textbutton_info[i].infotext);
5437 infotext[max_infotext_len] = '\0';
5439 /* determine horizontal position to the right of specified gadget */
5440 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
5441 x = (right_gadget_border[textbutton_info[i].gadget_id_align] +
5442 ED_GADGET_TEXT_DISTANCE);
5444 /* determine horizontal offset for leading text */
5445 if (textbutton_info[i].text_left != NULL)
5446 x += getTextWidthForGadget(textbutton_info[i].text_left);
5448 gi = CreateGadget(GDI_CUSTOM_ID, id,
5449 GDI_CUSTOM_TYPE_ID, i,
5450 GDI_INFO_TEXT, infotext,
5453 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
5454 GDI_TEXT_VALUE, textbutton_info[i].text,
5455 GDI_TEXT_SIZE, textbutton_info[i].size,
5456 GDI_TEXT_FONT, FONT_INPUT_2_ACTIVE,
5457 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2,
5458 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5459 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y1,
5460 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2,
5461 GDI_BORDER_SIZE, ED_BORDER_TEXT_XSIZE, ED_BORDER_SIZE,
5462 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
5463 GDI_DECORATION_SHIFTING, 1, 1,
5464 GDI_EVENT_MASK, event_mask,
5465 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5466 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
5470 Error(ERR_EXIT, "cannot create gadget");
5472 level_editor_gadget[id] = gi;
5473 right_gadget_border[id] =
5474 getRightGadgetBorder(gi, textbutton_info[i].text_right);
5478 static void CreateGraphicbuttonGadgets()
5480 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5481 struct GadgetInfo *gi;
5482 unsigned long event_mask;
5485 /* create buttons for scrolling of drawing area and element list */
5486 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
5488 int id = graphicbutton_info[i].gadget_id;
5489 int gd_x1, gd_x2, gd_y1, gd_y2;
5490 int x = SX + graphicbutton_info[i].x;
5491 int y = SY + graphicbutton_info[i].y;
5493 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5495 if (i <= ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
5497 gd_x1 = DOOR_GFX_PAGEX4 + graphicbutton_info[i].gd_x;
5498 gd_y1 = DOOR_GFX_PAGEY1 + graphicbutton_info[i].gd_y;
5499 gd_x2 = DOOR_GFX_PAGEX3 + graphicbutton_info[i].gd_x;
5502 else /* (i <= ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE) */
5504 gd_x1 = DOOR_GFX_PAGEX6 + graphicbutton_info[i].gd_x;
5505 gd_y1 = DOOR_GFX_PAGEY1 + graphicbutton_info[i].gd_y;
5506 gd_x2 = gd_x1 - ED_BUTTON_COUNT_XSIZE;
5510 /* determine horizontal position to the right of specified gadget */
5511 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
5512 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
5513 ED_GADGET_TEXT_DISTANCE);
5515 /* determine horizontal offset for leading text */
5516 if (graphicbutton_info[i].text_left != NULL)
5517 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
5519 gi = CreateGadget(GDI_CUSTOM_ID, id,
5520 GDI_CUSTOM_TYPE_ID, i,
5521 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
5524 GDI_WIDTH, graphicbutton_info[i].width,
5525 GDI_HEIGHT, graphicbutton_info[i].height,
5526 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
5527 GDI_STATE, GD_BUTTON_UNPRESSED,
5528 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5529 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
5530 GDI_EVENT_MASK, event_mask,
5531 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5532 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
5536 Error(ERR_EXIT, "cannot create gadget");
5538 level_editor_gadget[id] = gi;
5539 right_gadget_border[id] =
5540 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
5544 static void CreateScrollbarGadgets()
5548 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
5550 int id = scrollbar_info[i].gadget_id;
5551 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5552 int gd_x1, gd_x2, gd_y1, gd_y2;
5553 struct GadgetInfo *gi;
5554 int items_max, items_visible, item_position;
5555 unsigned long event_mask;
5557 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
5559 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
5560 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
5561 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
5563 else /* drawing area scrollbars */
5565 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
5567 items_max = MAX(lev_fieldx + 2, ed_fieldx);
5568 items_visible = ed_fieldx;
5573 items_max = MAX(lev_fieldy + 2, ed_fieldy);
5574 items_visible = ed_fieldy;
5579 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
5581 gd_x1 = DOOR_GFX_PAGEX8 + scrollbar_info[i].gd_x;
5582 gd_x2 = (gd_x1 - (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL ?
5583 scrollbar_info[i].height : scrollbar_info[i].width));
5584 gd_y1 = DOOR_GFX_PAGEY1 + scrollbar_info[i].gd_y;
5585 gd_y2 = DOOR_GFX_PAGEY1 + scrollbar_info[i].gd_y;
5587 gi = CreateGadget(GDI_CUSTOM_ID, id,
5588 GDI_CUSTOM_TYPE_ID, i,
5589 GDI_INFO_TEXT, scrollbar_info[i].infotext,
5590 GDI_X, scrollbar_info[i].x,
5591 GDI_Y, scrollbar_info[i].y,
5592 GDI_WIDTH, scrollbar_info[i].width,
5593 GDI_HEIGHT, scrollbar_info[i].height,
5594 GDI_TYPE, scrollbar_info[i].type,
5595 GDI_SCROLLBAR_ITEMS_MAX, items_max,
5596 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
5597 GDI_SCROLLBAR_ITEM_POSITION, item_position,
5598 GDI_STATE, GD_BUTTON_UNPRESSED,
5599 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5600 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
5601 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5602 GDI_EVENT_MASK, event_mask,
5603 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5604 GDI_CALLBACK_ACTION, HandleControlButtons,
5608 Error(ERR_EXIT, "cannot create gadget");
5610 level_editor_gadget[id] = gi;
5614 static void CreateCheckbuttonGadgets()
5616 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5617 struct GadgetInfo *gi;
5618 unsigned long event_mask;
5619 int gd_x1, gd_x2, gd_x3, gd_x4, gd_y;
5622 event_mask = GD_EVENT_PRESSED;
5624 gd_x1 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_UNCHECKED_XPOS;
5625 gd_x2 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_UNCHECKED_XPOS;
5626 gd_x3 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_CHECKED_XPOS;
5627 gd_x4 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_CHECKED_XPOS;
5628 gd_y = DOOR_GFX_PAGEY1 + ED_RADIOBUTTON_YPOS;
5630 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
5632 int id = checkbutton_info[i].gadget_id;
5633 int x = SX + checkbutton_info[i].x;
5634 int y = SY + checkbutton_info[i].y;
5636 if (id == GADGET_ID_STICK_ELEMENT)
5637 gd_y = DOOR_GFX_PAGEY1 + ED_STICKYBUTTON_YPOS;
5639 gd_y = DOOR_GFX_PAGEY1 + ED_CHECKBUTTON_YPOS;
5641 /* determine horizontal position to the right of specified gadget */
5642 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
5643 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
5644 ED_GADGET_TEXT_DISTANCE);
5646 /* determine horizontal offset for leading text */
5647 if (checkbutton_info[i].text_left != NULL)
5648 x += getTextWidthForGadget(checkbutton_info[i].text_left);
5650 gi = CreateGadget(GDI_CUSTOM_ID, id,
5651 GDI_CUSTOM_TYPE_ID, i,
5652 GDI_INFO_TEXT, checkbutton_info[i].infotext,
5655 GDI_WIDTH, ED_CHECKBUTTON_XSIZE,
5656 GDI_HEIGHT, ED_CHECKBUTTON_YSIZE,
5657 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
5658 GDI_CHECKED, *checkbutton_info[i].value,
5659 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
5660 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
5661 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y,
5662 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y,
5663 GDI_EVENT_MASK, event_mask,
5664 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5665 GDI_CALLBACK_ACTION, HandleCheckbuttons,
5669 Error(ERR_EXIT, "cannot create gadget");
5671 level_editor_gadget[id] = gi;
5672 right_gadget_border[id] =
5673 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
5677 static void CreateRadiobuttonGadgets()
5679 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5680 struct GadgetInfo *gi;
5681 unsigned long event_mask;
5682 int gd_x1, gd_x2, gd_x3, gd_x4, gd_y;
5685 event_mask = GD_EVENT_PRESSED;
5687 gd_x1 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_UNCHECKED_XPOS;
5688 gd_x2 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_UNCHECKED_XPOS;
5689 gd_x3 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_CHECKED_XPOS;
5690 gd_x4 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_CHECKED_XPOS;
5691 gd_y = DOOR_GFX_PAGEY1 + ED_RADIOBUTTON_YPOS;
5693 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
5695 int id = radiobutton_info[i].gadget_id;
5696 int x = SX + radiobutton_info[i].x;
5697 int y = SY + radiobutton_info[i].y;
5700 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
5702 /* determine horizontal position to the right of specified gadget */
5703 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
5704 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
5705 ED_GADGET_TEXT_DISTANCE);
5707 /* determine horizontal offset for leading text */
5708 if (radiobutton_info[i].text_left != NULL)
5709 x += getTextWidthForGadget(radiobutton_info[i].text_left);
5711 gi = CreateGadget(GDI_CUSTOM_ID, id,
5712 GDI_CUSTOM_TYPE_ID, i,
5713 GDI_INFO_TEXT, radiobutton_info[i].infotext,
5716 GDI_WIDTH, ED_CHECKBUTTON_XSIZE,
5717 GDI_HEIGHT, ED_CHECKBUTTON_YSIZE,
5718 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
5719 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
5720 GDI_CHECKED, checked,
5721 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
5722 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
5723 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y,
5724 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y,
5725 GDI_EVENT_MASK, event_mask,
5726 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5727 GDI_CALLBACK_ACTION, HandleRadiobuttons,
5731 Error(ERR_EXIT, "cannot create gadget");
5733 level_editor_gadget[id] = gi;
5734 right_gadget_border[id] =
5735 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
5739 void CreateLevelEditorGadgets()
5741 int old_game_status = game_status;
5743 /* setting 'game_status' is needed to get the right fonts for the editor */
5744 game_status = GAME_MODE_EDITOR;
5746 ReinitializeElementList();
5748 CreateControlButtons();
5749 CreateScrollbarGadgets();
5751 /* order of function calls is important because of cross-references */
5752 CreateCheckbuttonGadgets();
5753 CreateCounterButtons();
5754 CreateRadiobuttonGadgets();
5755 CreateTextInputGadgets();
5756 CreateTextAreaGadgets();
5757 CreateSelectboxGadgets();
5758 CreateGraphicbuttonGadgets();
5759 CreateTextbuttonGadgets();
5760 CreateDrawingAreas();
5762 game_status = old_game_status;
5765 void FreeLevelEditorGadgets()
5769 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
5770 FreeGadget(level_editor_gadget[i]);
5773 static void MapCounterButtons(int id)
5775 int gadget_id_down = counterbutton_info[id].gadget_id_down;
5776 int gadget_id_text = counterbutton_info[id].gadget_id_text;
5777 int gadget_id_up = counterbutton_info[id].gadget_id_up;
5778 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
5779 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
5780 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
5781 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
5782 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
5783 int yoffset_above = MINI_TILEX + ED_GADGET_DISTANCE;
5784 int yoffset = ED_BORDER_SIZE;
5785 int x_left = gi_down->x - xoffset_left;
5787 int x_right; /* set after gadget position was modified */
5789 int x_right = gi_up->x + gi_up->width + xoffset_right;
5791 int y_above = gi_down->y - yoffset_above;
5793 int y; /* set after gadget position was modified */
5795 /* counter limits must be changed first to prevent value truncation */
5796 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
5797 counterbutton_info[id].max_value);
5799 /* right text position might have changed after setting position above */
5800 x_right = gi_up->x + gi_up->width + xoffset_right;
5802 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
5804 /* set position for "value[1,2,3,4]" counter gadgets (score in most cases) */
5805 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
5806 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
5808 ModifyGadget(gi_down, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
5809 ModifyGadget(gi_text, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
5810 ModifyGadget(gi_up, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
5813 /* vertical position might have changed after setting position above */
5814 y = gi_up->y + yoffset;
5816 if (counterbutton_info[id].text_above)
5817 DrawText(x, y_above, counterbutton_info[id].text_above, FONT_TEXT_1);
5819 if (counterbutton_info[id].text_left)
5820 DrawText(x_left, y, counterbutton_info[id].text_left, FONT_TEXT_1);
5822 if (counterbutton_info[id].text_right)
5823 DrawText(x_right, y, counterbutton_info[id].text_right, FONT_TEXT_1);
5830 static void MapControlButtons()
5835 /* map toolbox buttons (excluding special CE toolbox buttons) */
5836 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
5837 MapGadget(level_editor_gadget[i]);
5839 /* map buttons to select elements */
5840 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
5841 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
5842 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
5843 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
5844 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
5846 /* map buttons to select level */
5847 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
5848 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
5849 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
5850 MapCounterButtons(counter_id);
5853 static void MapDrawingArea(int id)
5855 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
5856 int area_xsize = gi->drawing.area_xsize;
5857 int area_ysize = gi->drawing.area_ysize;
5858 int xoffset_left= getTextWidthForDrawingArea(drawingarea_info[id].text_left);
5859 int xoffset_below= getTextWidth(drawingarea_info[id].text_below,FONT_TEXT_1);
5860 int x_left = gi->x - xoffset_left;
5861 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
5862 int x_below = gi->x + (gi->width - xoffset_below) / 2;
5863 int y_side = gi->y + (gi->height - getFontHeight(FONT_TEXT_1)) / 2;
5864 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
5866 if (drawingarea_info[id].text_left)
5867 DrawText(x_left, y_side, drawingarea_info[id].text_left, FONT_TEXT_1);
5869 if (drawingarea_info[id].text_right)
5870 DrawText(x_right, y_side, drawingarea_info[id].text_right, FONT_TEXT_1);
5872 if (drawingarea_info[id].text_below)
5873 DrawText(x_below, y_below, drawingarea_info[id].text_below, FONT_TEXT_1);
5875 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
5877 DrawElementBorder(gi->x, gi->y,
5878 area_xsize * MINI_TILEX, area_ysize * MINI_TILEY, TRUE);
5880 DrawDrawingArea(id);
5886 static void MapTextInputGadget(int id)
5888 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
5889 int xoffset_above = 0;
5890 int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
5891 int x_above = textinput_info[id].x + xoffset_above;
5892 int y_above = textinput_info[id].y + yoffset_above;
5894 if (textinput_info[id].text_above)
5895 DrawTextS(x_above, y_above, FONT_TEXT_1, textinput_info[id].text_above);
5897 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
5902 static void MapTextAreaGadget(int id)
5904 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
5905 int xoffset_above = 0;
5906 int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
5907 int x_above = textarea_info[id].x + xoffset_above;
5908 int y_above = textarea_info[id].y + yoffset_above;
5910 if (textarea_info[id].text_above)
5911 DrawTextS(x_above, y_above, FONT_TEXT_1, textarea_info[id].text_above);
5913 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
5918 static void MapSelectboxGadget(int id)
5920 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
5921 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
5922 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
5923 int yoffset = ED_BORDER_SIZE;
5924 int x_left = gi->x - xoffset_left;
5925 int x_right = gi->x + gi->width + xoffset_right;
5926 int y = gi->y + yoffset;
5928 if (selectbox_info[id].text_left)
5929 DrawText(x_left, y, selectbox_info[id].text_left, FONT_TEXT_1);
5931 if (selectbox_info[id].text_right)
5932 DrawText(x_right, y, selectbox_info[id].text_right, FONT_TEXT_1);
5934 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
5939 static void MapTextbuttonGadget(int id)
5941 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
5942 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
5943 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
5944 int yoffset = ED_BORDER_SIZE;
5945 int x_left = gi->x - xoffset_left;
5946 int x_right = gi->x + gi->width + xoffset_right;
5947 int y = gi->y + yoffset;
5949 /* only show button to delete change pages when more than minimum pages */
5950 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
5951 custom_element.num_change_pages == MIN_CHANGE_PAGES)
5954 if (textbutton_info[id].text_left)
5955 DrawText(x_left, y, textbutton_info[id].text_left, FONT_TEXT_1);
5957 if (textbutton_info[id].text_right)
5958 DrawText(x_right, y, textbutton_info[id].text_right, FONT_TEXT_1);
5963 static void MapGraphicbuttonGadget(int id)
5965 struct GadgetInfo *gi= level_editor_gadget[graphicbutton_info[id].gadget_id];
5966 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
5967 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
5968 int yoffset = ED_BORDER_SIZE;
5969 int x_left = gi->x - xoffset_left;
5970 int x_right = gi->x + gi->width + xoffset_right;
5971 int y = gi->y + yoffset;
5973 if (graphicbutton_info[id].text_left)
5974 DrawText(x_left, y, graphicbutton_info[id].text_left, FONT_TEXT_1);
5976 if (graphicbutton_info[id].text_right)
5977 DrawText(x_right, y, graphicbutton_info[id].text_right, FONT_TEXT_1);
5982 static void MapRadiobuttonGadget(int id)
5984 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
5985 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
5986 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
5987 int yoffset = ED_BORDER_SIZE;
5988 int x_left = gi->x - xoffset_left;
5989 int x_right = gi->x + gi->width + xoffset_right;
5990 int y = gi->y + yoffset;
5992 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
5994 if (radiobutton_info[id].text_left)
5995 DrawText(x_left, y, radiobutton_info[id].text_left, FONT_TEXT_1);
5997 if (radiobutton_info[id].text_right)
5998 DrawText(x_right, y, radiobutton_info[id].text_right, FONT_TEXT_1);
6000 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
6005 static void MapCheckbuttonGadget(int id)
6007 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
6008 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
6009 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6010 int yoffset = ED_BORDER_SIZE;
6011 int x_left, x_right, y; /* set after gadget position was modified */
6013 /* set position for gadgets with dynamically determined position */
6014 if (checkbutton_info[id].x != -1) /* do not change dynamic positions */
6015 ModifyGadget(gi, GDI_X, SX + checkbutton_info[id].x, GDI_END);
6016 ModifyGadget(gi, GDI_Y, SY + checkbutton_info[id].y, GDI_END);
6018 x_left = gi->x - xoffset_left;
6019 x_right = gi->x + gi->width + xoffset_right;
6020 y = gi->y + yoffset;
6022 if (checkbutton_info[id].text_left)
6023 DrawText(x_left, y, checkbutton_info[id].text_left, FONT_TEXT_1);
6025 if (checkbutton_info[id].text_right)
6026 DrawText(x_right, y, checkbutton_info[id].text_right, FONT_TEXT_1);
6028 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
6033 static void MapMainDrawingArea()
6035 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
6036 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
6039 for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
6041 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
6042 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
6043 no_horizontal_scrollbar) ||
6044 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
6045 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
6046 no_vertical_scrollbar))
6049 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
6052 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
6054 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
6055 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
6058 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
6061 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
6064 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
6068 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6070 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
6071 i == GADGET_ID_CUSTOM_COPY_TO ||
6072 i == GADGET_ID_CUSTOM_EXCHANGE ||
6073 i == GADGET_ID_CUSTOM_COPY ||
6074 i == GADGET_ID_CUSTOM_PASTE)
6077 MapGadget(level_editor_gadget[i]);
6079 UnmapGadget(level_editor_gadget[i]);
6084 static void MapLevelEditorToolboxCustomGadgets()
6086 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
6089 static void UnmapLevelEditorToolboxCustomGadgets()
6091 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
6094 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
6096 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
6099 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
6101 if (i != GADGET_ID_SINGLE_ITEMS &&
6102 i != GADGET_ID_PROPERTIES &&
6103 i != GADGET_ID_PICK_ELEMENT)
6105 struct GadgetInfo *gi = level_editor_gadget[i];
6113 BlitBitmap(gd_bitmap, drawto,
6114 DOOR_GFX_PAGEX6 + ED_CTRL_NO_BUTTONS_GFX_XPOS,
6115 DOOR_GFX_PAGEY1 + ED_CTRL_NO_BUTTONS_GFX_YPOS,
6116 gi->width, gi->height, gi->x, gi->y);
6118 redraw_mask |= REDRAW_DOOR_3;
6124 static void MapLevelEditorToolboxDrawingGadgets()
6126 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
6129 static void UnmapLevelEditorToolboxDrawingGadgets()
6131 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
6134 static void UnmapDrawingArea(int id)
6136 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
6139 static void UnmapLevelEditorWindowGadgets()
6143 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
6144 if (level_editor_gadget[i]->x < SX + SXSIZE)
6145 UnmapGadget(level_editor_gadget[i]);
6148 void UnmapLevelEditorGadgets()
6152 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
6153 UnmapGadget(level_editor_gadget[i]);
6156 static void ResetUndoBuffer()
6158 undo_buffer_position = -1;
6159 undo_buffer_steps = -1;
6160 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
6162 level.changed = FALSE;
6165 static void DrawEditModeWindow()
6167 ModifyEditorElementList();
6168 RedrawDrawingElements();
6170 if (edit_mode == ED_MODE_INFO)
6171 DrawLevelInfoWindow();
6172 else if (edit_mode == ED_MODE_PROPERTIES)
6173 DrawPropertiesWindow();
6174 else /* edit_mode == ED_MODE_DRAWING */
6175 DrawDrawingWindow();
6178 static boolean LevelChanged()
6180 boolean field_changed = FALSE;
6183 if (leveldir_current->readonly)
6186 for (y = 0; y < lev_fieldy; y++)
6187 for (x = 0; x < lev_fieldx; x++)
6188 if (Feld[x][y] != level.field[x][y])
6189 field_changed = TRUE;
6191 return (level.changed || field_changed);
6194 static boolean LevelContainsPlayer()
6196 boolean player_found = FALSE;
6199 return TRUE; /* !!! CURRENTLY DEACTIVATED !!! */
6201 for (y = 0; y < lev_fieldy; y++) for (x = 0; x < lev_fieldx; x++)
6203 if (Feld[x][y] == EL_PLAYER_1 ||
6204 Feld[x][y] == EL_SP_MURPHY)
6205 player_found = TRUE;
6208 return player_found;
6211 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
6212 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
6216 for (x = 0; x < lev_fieldx; x++)
6217 for (y = 0; y < lev_fieldy; y++)
6218 dst[x][y] = src[x][y];
6221 static int setSelectboxValue(int selectbox_id, int new_value)
6223 int new_index_value = 0;
6226 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
6227 if (selectbox_info[selectbox_id].options[i].value == new_value)
6228 new_index_value = i;
6230 *selectbox_info[selectbox_id].value =
6231 selectbox_info[selectbox_id].options[new_index_value].value;
6233 return new_index_value;
6236 static void setSelectboxSpecialActionOptions()
6240 /* change action mode and arg selectbox according to action type selectbox */
6241 for (i = 0; action_arg_options[i].value != -1; i++)
6243 if (action_arg_options[i].value == custom_element_change.action_type)
6245 int mode = action_arg_options[i].mode;
6247 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
6248 action_arg_modes[mode]);
6249 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
6250 custom_element_change.action_mode);
6252 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
6253 action_arg_options[i].options);
6254 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
6255 custom_element_change.action_arg);
6260 static void copy_custom_element_settings(int element_from, int element_to)
6262 struct ElementInfo *ei_from = &element_info[element_from];
6263 struct ElementInfo *ei_to = &element_info[element_to];
6266 /* ---------- copy element description ---------- */
6267 for (i = 0; i < MAX_ELEMENT_NAME_LEN + 1; i++)
6268 ei_to->description[i] = ei_from->description[i];
6270 /* ---------- copy element base properties ---------- */
6271 Properties[element_to][EP_BITFIELD_BASE] =
6272 Properties[element_from][EP_BITFIELD_BASE];
6274 /* ---------- copy custom property values ---------- */
6276 ei_to->use_gfx_element = ei_from->use_gfx_element;
6277 ei_to->gfx_element = ei_from->gfx_element;
6279 ei_to->access_direction = ei_from->access_direction;
6281 ei_to->collect_score_initial = ei_from->collect_score_initial;
6282 ei_to->collect_count_initial = ei_from->collect_count_initial;
6284 ei_to->ce_value_fixed_initial = ei_from->ce_value_fixed_initial;
6285 ei_to->ce_value_random_initial = ei_from->ce_value_random_initial;
6286 ei_to->use_last_ce_value = ei_from->use_last_ce_value;
6288 ei_to->push_delay_fixed = ei_from->push_delay_fixed;
6289 ei_to->push_delay_random = ei_from->push_delay_random;
6290 ei_to->drop_delay_fixed = ei_from->drop_delay_fixed;
6291 ei_to->drop_delay_random = ei_from->drop_delay_random;
6292 ei_to->move_delay_fixed = ei_from->move_delay_fixed;
6293 ei_to->move_delay_random = ei_from->move_delay_random;
6295 ei_to->move_pattern = ei_from->move_pattern;
6296 ei_to->move_direction_initial = ei_from->move_direction_initial;
6297 ei_to->move_stepsize = ei_from->move_stepsize;
6299 ei_to->move_enter_element = ei_from->move_enter_element;
6300 ei_to->move_leave_element = ei_from->move_leave_element;
6301 ei_to->move_leave_type = ei_from->move_leave_type;
6303 ei_to->slippery_type = ei_from->slippery_type;
6305 for (y = 0; y < 3; y++)
6306 for (x = 0; x < 3; x++)
6307 ei_to->content.e[x][y] = ei_from->content.e[x][y];
6309 ei_to->explosion_type = ei_from->explosion_type;
6310 ei_to->explosion_delay = ei_from->explosion_delay;
6311 ei_to->ignition_delay = ei_from->ignition_delay;
6313 /* ---------- reinitialize and copy change pages ---------- */
6315 ei_to->num_change_pages = ei_from->num_change_pages;
6316 ei_to->current_change_page = ei_from->current_change_page;
6318 setElementChangePages(ei_to, ei_to->num_change_pages);
6320 for (i=0; i < ei_to->num_change_pages; i++)
6321 ei_to->change_page[i] = ei_from->change_page[i];
6323 /* ---------- copy group element info ---------- */
6324 if (ei_from->group != NULL && ei_to->group != NULL) /* group or internal */
6325 *ei_to->group = *ei_from->group;
6327 /* mark this custom element as modified */
6328 ei_to->modified_settings = TRUE;
6331 static void replace_custom_element_in_settings(int element_from,
6336 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6338 struct ElementInfo *ei = &element_info[i];
6340 for (y = 0; y < 3; y++)
6341 for (x = 0; x < 3; x++)
6342 if (ei->content.e[x][y] == element_from)
6343 ei->content.e[x][y] = element_to;
6345 for (j = 0; j < ei->num_change_pages; j++)
6347 struct ElementChangeInfo *change = &ei->change_page[j];
6349 if (change->target_element == element_from)
6350 change->target_element = element_to;
6352 if (change->trigger_element == element_from)
6353 change->trigger_element = element_to;
6355 for (y = 0; y < 3; y++)
6356 for (x = 0; x < 3; x++)
6357 if (change->target_content.e[x][y] == element_from)
6358 change->target_content.e[x][y] = element_to;
6361 if (ei->group != NULL) /* group or internal */
6362 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
6363 if (ei->group->element[j] == element_from)
6364 ei->group->element[j] = element_to;
6368 static void replace_custom_element_in_playfield(int element_from,
6373 for (x = 0; x < lev_fieldx; x++)
6374 for (y = 0; y < lev_fieldy; y++)
6375 if (Feld[x][y] == element_from)
6376 Feld[x][y] = element_to;
6379 static boolean CopyCustomElement(int element_old, int element_new,
6382 if (copy_mode == GADGET_ID_CUSTOM_COPY)
6384 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
6385 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
6386 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
6388 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
6390 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
6391 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
6392 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
6394 level.changed = TRUE;
6396 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
6398 Request("Please choose custom element !", REQ_CONFIRM);
6402 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
6404 Request("Please choose group element !", REQ_CONFIRM);
6410 level.changed = TRUE;
6413 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
6415 copy_custom_element_settings(element_new, element_old);
6417 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
6419 copy_custom_element_settings(element_old, element_new);
6421 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
6423 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
6424 copy_custom_element_settings(element_new, element_old);
6425 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
6427 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
6428 replace_custom_element_in_settings(element_new, element_old);
6429 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
6431 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
6432 replace_custom_element_in_playfield(element_new, element_old);
6433 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
6436 UpdateCustomElementGraphicGadgets();
6437 DrawPropertiesWindow();
6442 static void CopyCustomElementPropertiesToEditor(int element)
6445 int current_change_page = element_info[element].current_change_page;
6447 /* dynamically (re)build selectbox for selecting change page */
6448 for (i = 0; i < element_info[element].num_change_pages; i++)
6450 sprintf(options_change_page_strings[i], "%d", i + 1);
6452 options_change_page[i].value = i;
6453 options_change_page[i].text = options_change_page_strings[i];
6456 options_change_page[i].value = -1;
6457 options_change_page[i].text = NULL;
6459 /* needed here to initialize combined element properties */
6460 InitElementPropertiesEngine(level.game_version);
6462 element_info[element].change =
6463 &element_info[element].change_page[current_change_page];
6465 custom_element = element_info[element];
6466 custom_element_change = *element_info[element].change;
6468 /* needed to initially set selectbox options for special action options */
6469 setSelectboxSpecialActionOptions();
6471 /* needed to initially set selectbox value variables to reliable defaults */
6472 for (i = 0; i < ED_NUM_SELECTBOX; i++)
6473 setSelectboxValue(i, *selectbox_info[i].value);
6475 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
6476 custom_element_properties[i] = HAS_PROPERTY(element, i);
6478 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
6479 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
6481 /* ---------- element settings: configure (custom elements) ------------- */
6483 /* set accessible layer selectbox help value */
6484 custom_element.access_type =
6485 (IS_WALKABLE(element) ? EP_WALKABLE :
6486 IS_PASSABLE(element) ? EP_PASSABLE :
6487 custom_element.access_type);
6488 custom_element.access_layer =
6489 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
6490 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
6491 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
6492 custom_element.access_layer);
6493 custom_element.access_protected =
6494 (IS_PROTECTED(element) ? 1 : 0);
6495 custom_element_properties[EP_ACCESSIBLE] =
6496 (IS_ACCESSIBLE_OVER(element) ||
6497 IS_ACCESSIBLE_INSIDE(element) ||
6498 IS_ACCESSIBLE_UNDER(element));
6500 /* set walk-to-object action selectbox help value */
6501 custom_element.walk_to_action =
6502 (IS_DIGGABLE(element) ? EP_DIGGABLE :
6503 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
6504 IS_DROPPABLE(element) ? EP_DROPPABLE :
6505 IS_THROWABLE(element) ? EP_THROWABLE :
6506 IS_PUSHABLE(element) ? EP_PUSHABLE :
6507 custom_element.walk_to_action);
6508 custom_element_properties[EP_WALK_TO_OBJECT] =
6509 (IS_DIGGABLE(element) ||
6510 IS_COLLECTIBLE_ONLY(element) ||
6511 IS_DROPPABLE(element) ||
6512 IS_THROWABLE(element) ||
6513 IS_PUSHABLE(element));
6515 /* set smash targets selectbox help value */
6516 custom_element.smash_targets =
6517 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
6518 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
6519 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
6520 custom_element.smash_targets);
6521 custom_element_properties[EP_CAN_SMASH] =
6522 (CAN_SMASH_EVERYTHING(element) ||
6523 CAN_SMASH_ENEMIES(element) ||
6524 CAN_SMASH_PLAYER(element));
6526 /* set deadliness selectbox help value */
6527 custom_element.deadliness =
6528 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
6529 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
6530 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
6531 custom_element.deadliness);
6532 custom_element_properties[EP_DEADLY] =
6533 (DONT_TOUCH(element) ||
6534 DONT_COLLIDE_WITH(element) ||
6535 DONT_RUN_INTO(element));
6537 /* ---------- element settings: advanced (custom elements) --------------- */
6539 /* set "change by direct action" selectbox help value */
6540 custom_element_change.direct_action =
6541 (HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
6542 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
6543 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
6544 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
6545 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
6546 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
6547 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
6548 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
6549 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
6550 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
6551 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
6552 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
6553 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
6554 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
6555 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
6556 custom_element_change.direct_action);
6558 /* set "change by other element action" selectbox help value */
6559 custom_element_change.other_action =
6560 (HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
6561 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
6562 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
6563 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
6564 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
6565 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
6566 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
6567 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
6568 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
6569 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
6570 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
6571 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
6572 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
6573 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
6574 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
6575 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
6576 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
6577 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
6578 custom_element_change.other_action);
6581 static void CopyGroupElementPropertiesToEditor(int element)
6583 group_element_info = *element_info[element].group;
6584 custom_element = element_info[element]; /* needed for description */
6587 static void CopyClassicElementPropertiesToEditor(int element)
6589 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
6590 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
6591 getMoveIntoAcidProperty(&level, element);
6593 if (MAYBE_DONT_COLLIDE_WITH(element))
6594 custom_element_properties[EP_DONT_COLLIDE_WITH] =
6595 getDontCollideWithProperty(&level, element);
6598 static void CopyElementPropertiesToEditor(int element)
6600 if (IS_CUSTOM_ELEMENT(element))
6601 CopyCustomElementPropertiesToEditor(element);
6602 else if (IS_GROUP_ELEMENT(element))
6603 CopyGroupElementPropertiesToEditor(element);
6605 CopyClassicElementPropertiesToEditor(element);
6608 static void CopyCustomElementPropertiesToGame(int element)
6611 int access_type_and_layer;
6613 /* mark that this custom element has been modified */
6614 custom_element.modified_settings = TRUE;
6615 level.changed = TRUE;
6617 if (level.use_custom_template)
6619 if (Request("Copy and modify level template ?", REQ_ASK))
6621 level.use_custom_template = FALSE;
6622 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE],
6623 GDI_CHECKED, FALSE, GDI_END);
6627 LoadLevelTemplate(-1); /* this resets all element modifications ... */
6629 DrawEditModeWindow(); /* ... and copies them to 'custom_element' */
6633 element_info[element] = custom_element;
6634 *element_info[element].change = custom_element_change;
6636 /* ---------- element settings: configure (custom elements) ------------- */
6638 /* set accessible property from checkbox and selectbox */
6639 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
6640 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
6641 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
6642 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
6643 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
6644 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
6645 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
6646 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
6647 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
6648 custom_element_properties[access_type_and_layer] =
6649 custom_element_properties[EP_ACCESSIBLE];
6650 custom_element_properties[EP_PROTECTED] =
6651 (custom_element.access_protected != 0 &&
6652 custom_element_properties[EP_ACCESSIBLE]);
6654 /* set walk-to-object property from checkbox and selectbox */
6655 custom_element_properties[EP_DIGGABLE] = FALSE;
6656 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
6657 custom_element_properties[EP_DROPPABLE] = FALSE;
6658 custom_element_properties[EP_THROWABLE] = FALSE;
6659 custom_element_properties[EP_PUSHABLE] = FALSE;
6660 custom_element_properties[custom_element.walk_to_action] =
6661 custom_element_properties[EP_WALK_TO_OBJECT];
6663 /* set smash property from checkbox and selectbox */
6664 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
6665 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
6666 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
6667 custom_element_properties[custom_element.smash_targets] =
6668 custom_element_properties[EP_CAN_SMASH];
6670 /* set deadliness property from checkbox and selectbox */
6671 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
6672 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
6673 custom_element_properties[EP_DONT_TOUCH] = FALSE;
6674 custom_element_properties[custom_element.deadliness] =
6675 custom_element_properties[EP_DEADLY];
6677 /* ---------- element settings: advanced (custom elements) --------------- */
6679 /* set player change event from checkbox and selectbox */
6680 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
6681 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
6682 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
6683 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
6684 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
6685 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
6686 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
6687 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
6688 custom_element_change_events[CE_SWITCHED] = FALSE;
6689 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
6690 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
6691 custom_element_change_events[CE_BLOCKED] = FALSE;
6692 custom_element_change_events[CE_IMPACT] = FALSE;
6693 custom_element_change_events[CE_SMASHED] = FALSE;
6694 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
6695 custom_element_change_events[custom_element_change.direct_action] =
6696 custom_element_change_events[CE_BY_DIRECT_ACTION];
6698 /* set other element action change event from checkbox and selectbox */
6699 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
6700 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
6701 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
6702 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
6703 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
6704 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
6705 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
6706 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
6707 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
6708 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
6709 custom_element_change_events[CE_TOUCHING_X] = FALSE;
6710 custom_element_change_events[CE_HITTING_X] = FALSE;
6711 custom_element_change_events[CE_HIT_BY_X] = FALSE;
6712 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
6713 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
6714 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
6715 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
6716 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
6717 custom_element_change_events[custom_element_change.other_action] =
6718 custom_element_change_events[CE_BY_OTHER_ACTION];
6720 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
6721 SET_PROPERTY(element, i, custom_element_properties[i]);
6723 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
6724 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
6726 /* copy change events also to special level editor variable */
6727 custom_element = element_info[element];
6728 custom_element_change = *element_info[element].change;
6731 static void CopyGroupElementPropertiesToGame(int element)
6733 element_info[element] = custom_element;
6734 *element_info[element].group = group_element_info;
6736 /* mark that this group element has been modified */
6737 element_info[element].modified_settings = TRUE;
6738 level.changed = TRUE;
6741 static void CopyClassicElementPropertiesToGame(int element)
6743 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
6744 setMoveIntoAcidProperty(&level, element,
6745 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
6747 if (MAYBE_DONT_COLLIDE_WITH(element))
6748 setDontCollideWithProperty(&level, element,
6749 custom_element_properties[EP_DONT_COLLIDE_WITH]);
6752 static void CopyElementPropertiesToGame(int element)
6754 if (IS_CUSTOM_ELEMENT(element))
6755 CopyCustomElementPropertiesToGame(element);
6756 else if (IS_GROUP_ELEMENT(element))
6757 CopyGroupElementPropertiesToGame(element);
6759 CopyClassicElementPropertiesToGame(element);
6764 CloseDoor(DOOR_CLOSE_ALL);
6765 OpenDoor(DOOR_OPEN_2 | DOOR_NO_DELAY);
6767 if (level_editor_test_game)
6769 CopyPlayfield(level.field, Feld);
6770 CopyPlayfield(FieldBackup, level.field);
6772 level_editor_test_game = FALSE;
6776 edit_mode = ED_MODE_DRAWING;
6777 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
6785 /* copy default editor door content to main double buffer */
6786 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
6787 DOOR_GFX_PAGEX6, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
6789 /* draw bigger door */
6790 DrawSpecialEditorDoor();
6792 /* draw new control window */
6793 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
6794 DOOR_GFX_PAGEX8, 236, EXSIZE, EYSIZE, EX, EY);
6796 redraw_mask |= REDRAW_ALL;
6798 ReinitializeElementList(); /* update dynamic level element list */
6799 ReinitializeElementListButtons(); /* custom element may look different */
6802 MapControlButtons();
6804 DrawEditModeWindow();
6806 /* copy actual editor door content to door double buffer for OpenDoor() */
6807 BlitBitmap(drawto, bitmap_db_door,
6808 DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
6810 OpenDoor(DOOR_OPEN_1);
6813 static void AdjustDrawingAreaGadgets()
6815 int ed_xsize = lev_fieldx + 2;
6816 int ed_ysize = lev_fieldy + 2;
6817 int max_ed_fieldx = MAX_ED_FIELDX;
6818 int max_ed_fieldy = MAX_ED_FIELDY;
6819 boolean horizontal_scrollbar_needed;
6820 boolean vertical_scrollbar_needed;
6821 int x, y, width, height;
6822 int xoffset, yoffset;
6824 /* check if we need any scrollbars */
6825 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
6826 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
6828 /* check if we have a smaller editor field because of scrollbars */
6829 if (horizontal_scrollbar_needed)
6830 max_ed_fieldy = MAX_ED_FIELDY - 1;
6831 if (vertical_scrollbar_needed)
6832 max_ed_fieldx = MAX_ED_FIELDX - 1;
6834 /* check again if we now need more scrollbars because of less space */
6835 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
6836 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
6838 /* check if editor field gets even smaller after adding new scrollbars */
6839 if (horizontal_scrollbar_needed)
6840 max_ed_fieldy = MAX_ED_FIELDY - 1;
6841 if (vertical_scrollbar_needed)
6842 max_ed_fieldx = MAX_ED_FIELDX - 1;
6844 ed_fieldx = (ed_xsize < MAX_ED_FIELDX ? ed_xsize : max_ed_fieldx);
6845 ed_fieldy = (ed_ysize < MAX_ED_FIELDY ? ed_ysize : max_ed_fieldy);
6847 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
6848 GDI_WIDTH, ed_fieldx * MINI_TILEX,
6849 GDI_HEIGHT, ed_fieldy * MINI_TILEY,
6850 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
6853 xoffset = (ed_fieldx == MAX_ED_FIELDX ? ED_SCROLLBUTTON_XSIZE : 0);
6854 yoffset = (ed_fieldy == MAX_ED_FIELDY ? ED_SCROLLBUTTON_YSIZE : 0);
6856 x = SX + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_RIGHT].x + xoffset;
6857 y = SX + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_DOWN].y + yoffset;
6859 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT], GDI_X, x, GDI_END);
6860 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN], GDI_Y, y, GDI_END);
6862 width = scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width + xoffset;
6863 height = scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].height + yoffset;
6865 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
6867 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
6869 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
6871 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
6875 static void AdjustLevelScrollPosition()
6877 if (level_xpos < -1)
6879 if (level_xpos > lev_fieldx - ed_fieldx + 1)
6880 level_xpos = lev_fieldx - ed_fieldx + 1;
6881 if (lev_fieldx < ed_fieldx - 2)
6884 if (level_ypos < -1)
6886 if (level_ypos > lev_fieldy - ed_fieldy + 1)
6887 level_ypos = lev_fieldy - ed_fieldy + 1;
6888 if (lev_fieldy < ed_fieldy - 2)
6892 static void AdjustEditorScrollbar(int id)
6894 struct GadgetInfo *gi = level_editor_gadget[id];
6895 int items_max, items_visible, item_position;
6897 if (id == GADGET_ID_SCROLL_HORIZONTAL)
6899 items_max = MAX(lev_fieldx + 2, ed_fieldx);
6900 items_visible = ed_fieldx;
6901 item_position = level_xpos + 1;
6905 items_max = MAX(lev_fieldy + 2, ed_fieldy);
6906 items_visible = ed_fieldy;
6907 item_position = level_ypos + 1;
6910 if (item_position > items_max - items_visible)
6911 item_position = items_max - items_visible;
6913 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
6914 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
6917 static void AdjustElementListScrollbar()
6919 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
6920 int items_max, items_visible, item_position;
6922 /* correct position of element list scrollbar */
6923 if (element_shift < 0)
6925 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
6926 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
6928 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
6929 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
6930 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
6932 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
6933 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
6934 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
6937 static void ModifyEditorCounterValue(int counter_id, int new_value)
6939 int *counter_value = counterbutton_info[counter_id].value;
6940 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
6941 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
6943 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
6945 if (counter_value != NULL)
6946 *counter_value = gi->textinput.number_value;
6949 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
6951 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
6952 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
6954 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
6956 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
6957 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
6959 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
6960 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
6962 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
6963 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_DISTANCE,GDI_END);
6967 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
6969 int gadget_id = selectbox_info[selectbox_id].gadget_id;
6970 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
6971 int new_index_value = setSelectboxValue(selectbox_id, new_value);
6973 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
6976 static void ModifyEditorSelectboxOptions(int selectbox_id,
6977 struct ValueTextInfo *options)
6979 int gadget_id = selectbox_info[selectbox_id].gadget_id;
6980 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
6982 selectbox_info[selectbox_id].options = options;
6984 /* set index to zero -- list may be shorter now (correct later, if needed) */
6985 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
6986 GDI_SELECTBOX_OPTIONS, options, GDI_END);
6989 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
6991 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
6992 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
6994 drawingarea_info[drawingarea_id].area_xsize = xsize;
6995 drawingarea_info[drawingarea_id].area_ysize = ysize;
6997 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
7000 static void ModifyEditorElementList()
7004 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7006 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
7007 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7008 struct GadgetDesign *gd = &gi->deco.design;
7009 int element = editor_elements[element_shift + i];
7013 getMiniGraphicSource(el2edimg(element), &gd->bitmap, &gd->x, &gd->y);
7014 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
7020 static void PickDrawingElement(int button, int element)
7022 if (button < 1 || button > 3)
7027 new_element1 = element;
7028 DrawMiniGraphicExt(drawto,
7029 DX + ED_WIN_MB_LEFT_XPOS, DY + ED_WIN_MB_LEFT_YPOS,
7030 el2edimg(new_element1));
7032 else if (button == 2)
7034 new_element2 = element;
7035 DrawMiniGraphicExt(drawto,
7036 DX + ED_WIN_MB_MIDDLE_XPOS, DY + ED_WIN_MB_MIDDLE_YPOS,
7037 el2edimg(new_element2));
7041 new_element3 = element;
7042 DrawMiniGraphicExt(drawto,
7043 DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS,
7044 el2edimg(new_element3));
7047 redraw_mask |= REDRAW_DOOR_1;
7050 static void RedrawDrawingElements()
7052 PickDrawingElement(1, new_element1);
7053 PickDrawingElement(2, new_element2);
7054 PickDrawingElement(3, new_element3);
7057 static void DrawDrawingWindow()
7059 stick_element_properties_window = FALSE;
7061 SetMainBackgroundImage(IMG_UNDEFINED);
7064 UnmapLevelEditorWindowGadgets();
7065 UnmapLevelEditorToolboxCustomGadgets();
7067 AdjustDrawingAreaGadgets();
7068 AdjustLevelScrollPosition();
7069 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
7070 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
7072 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7074 MapMainDrawingArea();
7075 MapLevelEditorToolboxDrawingGadgets();
7078 static void DrawLevelInfoWindow()
7082 stick_element_properties_window = FALSE;
7084 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
7086 UnmapLevelEditorWindowGadgets();
7089 DrawTextSCentered(ED_SETTINGS1_YPOS, FONT_TITLE_1, "Level Settings");
7090 DrawTextSCentered(ED_SETTINGS2_YPOS, FONT_TITLE_1, "Editor Settings");
7092 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS1_YPOS,
7093 "Level Settings", FONT_TITLE_1);
7094 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS2_YPOS,
7095 "Editor Settings", FONT_TITLE_1);
7098 /* draw counter gadgets */
7099 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
7100 MapCounterButtons(i);
7102 /* draw selectbox gadgets */
7103 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
7104 MapSelectboxGadget(i);
7106 /* draw checkbutton gadgets */
7107 for (i=ED_CHECKBUTTON_ID_LEVEL_FIRST; i <= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
7108 MapCheckbuttonGadget(i);
7110 /* draw radiobutton gadgets */
7111 for (i=ED_RADIOBUTTON_ID_LEVEL_FIRST; i <= ED_RADIOBUTTON_ID_LEVEL_LAST; i++)
7112 MapRadiobuttonGadget(i);
7114 /* draw text input gadgets */
7115 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
7116 MapTextInputGadget(i);
7118 /* draw drawing area */
7119 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
7122 static void DrawCustomContentArea()
7124 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
7125 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
7126 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
7127 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
7128 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
7129 int xoffset = ED_DRAWINGAREA_TEXT_DISTANCE;
7131 /* add distance for potential left text (without drawing area border) */
7132 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
7134 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
7136 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
7139 static void DrawCustomChangeContentArea()
7141 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
7142 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
7143 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
7144 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
7145 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
7146 int xoffset = ED_DRAWINGAREA_TEXT_DISTANCE;
7148 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
7153 static void DrawYamYamContentAreas()
7155 int x = SX + ED_AREA_YAMYAM_CONTENT_XPOS(3) + 4 * MINI_TILEX;
7156 int y = SY + ED_AREA_YAMYAM_CONTENT_YPOS(0) + ED_BORDER_AREA_YSIZE;
7159 /* display counter to choose number of element content areas */
7160 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
7162 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
7164 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
7166 if (i < level.num_yamyam_contents)
7172 int font_height = getFontHeight(FONT_TEXT_1);
7174 UnmapDrawingArea(id);
7176 /* delete content areas in case of reducing number of them */
7177 DrawBackground(SX + drawingarea_info[id].x - MINI_TILEX / 2,
7178 SY + drawingarea_info[id].y - MINI_TILEY / 2,
7180 4 * MINI_TILEY + ED_GADGET_TEXT_DISTANCE + font_height);
7184 DrawText(x, y + 0 * MINI_TILEY, "content", FONT_TEXT_1);
7185 DrawText(x, y + 1 * MINI_TILEY, "when", FONT_TEXT_1);
7186 DrawText(x, y + 2 * MINI_TILEY, "smashed", FONT_TEXT_1);
7189 static void DrawMagicBallContentAreas()
7191 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_XPOS(3) + 4 * MINI_TILEX;
7192 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_YPOS(0) + ED_BORDER_AREA_YSIZE;
7195 /* display counter to choose number of element content areas */
7196 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
7198 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
7200 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
7202 if (i < level.num_ball_contents)
7208 int font_height = getFontHeight(FONT_TEXT_1);
7210 UnmapDrawingArea(id);
7212 /* delete content areas in case of reducing number of them */
7213 DrawBackground(SX + drawingarea_info[id].x - MINI_TILEX / 2,
7214 SY + drawingarea_info[id].y - MINI_TILEY / 2,
7216 4 * MINI_TILEY + ED_GADGET_TEXT_DISTANCE + font_height);
7220 DrawText(x, y + 0 * MINI_TILEY, "generated", FONT_TEXT_1);
7221 DrawText(x, y + 1 * MINI_TILEY, "when", FONT_TEXT_1);
7222 DrawText(x, y + 2 * MINI_TILEY, "active", FONT_TEXT_1);
7225 static void DrawGroupElementArea(int element)
7227 int num_elements = group_element_info.num_elements;
7228 int id = ED_DRAWING_ID_GROUP_CONTENT;
7229 int sx = SX + drawingarea_info[id].x - MINI_TILEX / 2;
7230 int sy = SY + drawingarea_info[id].y - MINI_TILEY / 2;
7231 int xsize = MAX_ELEMENTS_IN_GROUP;
7234 if (drawingarea_info[id].text_left != NULL)
7235 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
7237 UnmapDrawingArea(id);
7239 ModifyEditorDrawingArea(id, num_elements, 1);
7241 /* delete content areas in case of reducing number of them */
7242 DrawBackground(sx, sy, (xsize + 1) * MINI_TILEX, (ysize + 1) * MINI_TILEY);
7247 static void DrawEnvelopeTextArea(int envelope_nr)
7249 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
7250 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
7253 DrawBackground(gi->x, gi->y, gi->width, gi->height);
7255 if (envelope_nr != -1)
7256 textarea_info[id].value = level.envelope_text[envelope_nr];
7258 ModifyGadget(gi, GDI_AREA_SIZE,
7259 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
7260 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
7263 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
7266 char *getElementDescriptionFilename(int element)
7268 char *docs_dir = options.docs_directory;
7269 char *elements_subdir = "elements";
7270 static char *filename = NULL;
7271 char basename[MAX_FILENAME_LEN];
7273 checked_free(filename);
7275 /* 1st try: look for element description file for exactly this element */
7276 sprintf(basename, "%s.txt", element_info[element].token_name);
7277 filename = getPath3(docs_dir, elements_subdir, basename);
7278 if (fileExists(filename))
7283 /* 2nd try: look for element description file for this element's class */
7284 sprintf(basename, "%s.txt", element_info[element].class_name);
7285 filename = getPath3(docs_dir, elements_subdir, basename);
7286 if (fileExists(filename))
7292 static boolean PrintInfoText(char *text, int font_nr, int start_line)
7294 int font_height = getFontHeight(font_nr);
7295 int pad_x = ED_ELEMENT_SETTINGS_XPOS(0);
7296 int pad_y = ED_ELEMENT_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
7297 int sx = SX + pad_x;
7298 int sy = SY + pad_y;
7299 int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
7301 if (start_line >= max_lines_per_screen)
7304 DrawText(sx, sy + start_line * font_height, text, font_nr);
7309 static int PrintElementDescriptionFromFile(char *filename, int start_line)
7311 int font_nr = FONT_TEXT_2;
7312 int font_width = getFontWidth(font_nr);
7313 int font_height = getFontHeight(font_nr);
7314 int pad_x = ED_ELEMENT_SETTINGS_XPOS(0);
7315 int pad_y = ED_ELEMENT_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
7316 int sx = SX + pad_x;
7317 int sy = SY + pad_y + start_line * font_height;
7318 int max_chars_per_line = (SXSIZE - 2 * pad_x) / font_width;
7319 int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
7321 return DrawTextFromFile(sx, sy, filename, font_nr, max_chars_per_line,
7322 max_lines_per_screen);
7325 static void DrawPropertiesTabulatorGadgets()
7327 struct GadgetInfo *gd_gi = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
7328 struct GadgetDesign *gd = &gd_gi->alt_design[GD_BUTTON_UNPRESSED];
7329 int gd_x = gd->x + gd_gi->border.width / 2;
7330 int gd_y = gd->y + gd_gi->height - 1;
7331 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
7332 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
7333 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
7337 /* draw additional "advanced" tabulator for custom elements */
7338 if (IS_CUSTOM_ELEMENT(properties_element))
7339 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
7341 for (i = id_first; i <= id_last; i++)
7343 int gadget_id = textbutton_info[i].gadget_id;
7344 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7345 boolean active = (i != edit_mode_properties);
7347 /* use "config 1" and "config 2" instead of "config" */
7348 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
7349 IS_CUSTOM_ELEMENT(properties_element))
7352 /* draw background line below tabulator button */
7353 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width,1);
7355 /* draw solid line below inactive tabulator buttons */
7356 if (!active && tab_color != BLACK_PIXEL) /* black => transparent */
7357 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,1, tab_color);
7359 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
7360 MapTextbuttonGadget(i);
7363 /* draw little border line below tabulator buttons */
7364 if (tab_color != BLACK_PIXEL) /* black => transparent */
7365 FillRectangle(drawto, gd_gi->x, gd_gi->y + gd_gi->height + 1,
7366 max_tabs * gd_gi->width + (max_tabs -1) * ED_GADGET_DISTANCE,
7367 ED_GADGET_DISTANCE, tab_color);
7370 static void DrawPropertiesInfo()
7379 /* configurable properties */
7381 { EP_WALKABLE_OVER, "- player can walk over it" },
7382 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
7383 { EP_WALKABLE_UNDER, "- player can walk under it" },
7384 { EP_PASSABLE_OVER, "- player can pass over it" },
7385 { EP_PASSABLE_INSIDE, "- player can pass through it" },
7386 { EP_PASSABLE_UNDER, "- player can pass under it" },
7387 { EP_PROTECTED, "- player is protected by it" },
7389 { EP_DIGGABLE, "- can be digged away" },
7390 { EP_COLLECTIBLE, "- can be collected" },
7391 { EP_DROPPABLE, "- can be dropped after collecting" },
7392 { EP_THROWABLE, "- can be thrown after collecting" },
7393 { EP_PUSHABLE, "- can be pushed" },
7395 { EP_CAN_FALL, "- can fall" },
7396 { EP_CAN_MOVE, "- can move" },
7398 { EP_CAN_SMASH_PLAYER, "- can smash player" },
7400 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
7402 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
7404 { EP_SLIPPERY, "- slippery for falling elements" },
7405 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
7407 { EP_DONT_RUN_INTO, "- deadly when running into" },
7408 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
7409 { EP_DONT_TOUCH, "- deadly when touching" },
7411 { EP_INDESTRUCTIBLE, "- indestructible" },
7413 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
7414 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
7415 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
7417 { EP_CAN_CHANGE, "- can change to other element" },
7419 /* pre-defined properties */
7420 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
7421 { EP_SWITCHABLE, "- can be switched" },
7422 { EP_HAS_CONTENT, "- can contain other elements" },
7426 char *filename = getElementDescriptionFilename(properties_element);
7427 char *percentage_text = "In this level:";
7428 char *properties_text = "Standard properties:";
7430 int num_elements_in_level;
7431 int num_standard_properties = 0;
7432 int font1_nr = FONT_TEXT_1;
7433 int font2_nr = FONT_TEXT_2;
7434 int font1_width = getFontWidth(font1_nr);
7435 int font2_height = getFontHeight(font2_nr);
7436 int pad_x = ED_ELEMENT_SETTINGS_XPOS(0);
7437 int pad_y = ED_ELEMENT_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
7438 int screen_line = 0;
7442 if (IS_CUSTOM_ELEMENT(properties_element))
7444 DrawTextF(pad_x, pad_y + screen_line++ * font2_height, FONT_TEXT_3,
7445 "[Custom Element %d]", properties_element - EL_CUSTOM_START + 1);
7448 else if (IS_GROUP_ELEMENT(properties_element))
7450 DrawTextF(pad_x, pad_y + screen_line++ * font2_height, FONT_TEXT_3,
7451 "[Group Element %d]", properties_element - EL_GROUP_START + 1);
7456 /* ----- print number of elements / percentage of this element in level */
7458 num_elements_in_level = 0;
7459 for (y = 0; y < lev_fieldy; y++)
7460 for (x = 0; x < lev_fieldx; x++)
7461 if (Feld[x][y] == properties_element)
7462 num_elements_in_level++;
7463 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
7465 DrawTextS(pad_x, pad_y + screen_line * font2_height, font1_nr,
7467 DrawTextF(pad_x + strlen(percentage_text) * font1_width,
7468 pad_y + screen_line++ * font2_height, font2_nr,
7469 "%d (%.2f%%)", num_elements_in_level, percentage);
7473 /* ----- print standard properties of this element */
7475 DrawTextS(pad_x, pad_y + screen_line++ * font2_height, font1_nr,
7478 for (i = 0; properties[i].value != -1; i++)
7480 if (!HAS_PROPERTY(properties_element, properties[i].value))
7483 DrawTextS(pad_x, pad_y + screen_line++ * font2_height, font2_nr,
7484 properties[i].text);
7485 num_standard_properties++;
7488 if (num_standard_properties == 0)
7489 DrawTextS(pad_x + strlen(properties_text) * font1_width,
7490 pad_y + (screen_line - 1) * font2_height, font2_nr, "none");
7494 /* ----- print special description of this element */
7496 PrintInfoText("Description:", FONT_TEXT_1, screen_line);
7497 if (PrintElementDescriptionFromFile(filename, screen_line + 1) == 0)
7498 PrintInfoText("No description available.", FONT_TEXT_1, screen_line);
7501 #define TEXT_COLLECTING "Score for collecting"
7502 #define TEXT_SMASHING "Score for smashing"
7503 #define TEXT_SLURPING "Score for slurping"
7504 #define TEXT_CRACKING "Score for cracking"
7505 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
7506 #define TEXT_DURATION "Duration when activated"
7507 #define TEXT_BALL_DELAY "Element generation delay"
7508 #define TEXT_MOVE_SPEED "Speed of android moving"
7509 #define TEXT_CLONE_SPEED "Speed of android cloning"
7510 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
7511 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
7512 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
7513 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
7514 #define TEXT_TIME_BONUS "Extra time to solve level"
7521 } elements_with_counter[] =
7523 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
7524 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
7525 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
7526 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
7527 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
7528 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
7529 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
7530 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
7531 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
7532 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
7533 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
7534 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
7535 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
7536 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
7537 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
7538 { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
7539 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
7540 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
7541 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
7542 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
7543 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7544 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7545 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7546 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7547 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7548 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7549 { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
7550 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7551 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7552 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7553 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
7554 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
7555 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
7556 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
7557 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
7558 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
7559 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
7560 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
7561 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
7562 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
7563 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
7564 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE],TEXT_COLLECTING },
7565 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
7566 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
7567 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
7568 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
7569 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
7570 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
7571 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
7572 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
7573 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
7574 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
7575 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
7576 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
7577 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
7578 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
7579 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
7580 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
7581 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
7582 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
7583 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
7584 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
7585 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
7586 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
7587 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
7588 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
7591 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
7592 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
7593 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
7594 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
7595 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
7596 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
7597 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
7598 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
7599 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
7600 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
7601 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
7602 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
7603 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
7604 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
7608 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
7609 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
7610 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
7611 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
7612 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
7613 { EL_ROBOT, &level.slurp_score, TEXT_SLURPING },
7614 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
7615 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
7621 static boolean checkPropertiesConfig(int element)
7625 if (IS_GEM(element) ||
7626 IS_CUSTOM_ELEMENT(element) ||
7627 IS_GROUP_ELEMENT(element) ||
7628 IS_ENVELOPE(element) ||
7629 ELEM_IS_PLAYER(element) ||
7630 HAS_CONTENT(element) ||
7631 CAN_GROW(element) ||
7632 COULD_MOVE_INTO_ACID(element) ||
7633 MAYBE_DONT_COLLIDE_WITH(element))
7636 for (i = 0; elements_with_counter[i].element != -1; i++)
7637 if (elements_with_counter[i].element == element)
7643 static void DrawPropertiesConfig()
7645 int max_num_element_counters = 4;
7646 int num_element_counters = 0;
7649 if (!checkPropertiesConfig(properties_element))
7651 PrintInfoText("No configuration options available.", FONT_TEXT_1, 0);
7656 /* check if there are elements where a value can be chosen for */
7657 for (i = 0; elements_with_counter[i].element != -1; i++)
7659 if (elements_with_counter[i].element == properties_element)
7661 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
7663 counterbutton_info[counter_id].y =
7664 ED_ELEMENT_SETTINGS_YPOS((HAS_CONTENT(properties_element) ? 1 : 0) +
7665 (CAN_GROW(properties_element) ? 1 : 0) +
7666 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
7667 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0)+
7668 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
7669 num_element_counters);
7671 counterbutton_info[counter_id].value = elements_with_counter[i].value;
7672 counterbutton_info[counter_id].text_right= elements_with_counter[i].text;
7674 if (properties_element == EL_GAME_OF_LIFE ||
7675 properties_element == EL_BIOMAZE)
7677 counterbutton_info[counter_id].min_value = 0; /* min neighbours */
7678 counterbutton_info[counter_id].max_value = 8; /* max neighbours */
7682 /* !!! CHANGE THIS FOR CERTAIN ELEMENTS !!! */
7683 counterbutton_info[counter_id].min_value = MIN_SCORE;
7684 counterbutton_info[counter_id].max_value = MAX_SCORE;
7687 MapCounterButtons(counter_id);
7689 num_element_counters++;
7690 if (num_element_counters >= max_num_element_counters)
7695 if (HAS_CONTENT(properties_element))
7697 /* draw stickybutton gadget */
7698 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
7700 if (IS_AMOEBOID(properties_element))
7701 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
7702 else if (properties_element == EL_YAMYAM)
7703 DrawYamYamContentAreas();
7704 else if (properties_element == EL_EMC_MAGIC_BALL)
7706 DrawMagicBallContentAreas();
7708 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
7709 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_STATE);
7713 if (ELEM_IS_PLAYER(properties_element))
7715 int player_nr = GET_PLAYER_NR(properties_element);
7717 /* these properties can be set for every player individually */
7718 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
7719 &level.start_element[player_nr];
7720 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
7721 &level.artwork_element[player_nr];
7722 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
7723 &level.explosion_element[player_nr];
7725 /* these properties can be set for every player individually */
7726 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
7727 &level.use_start_element[player_nr];
7728 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
7729 &level.use_artwork_element[player_nr];
7730 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
7731 &level.use_explosion_element[player_nr];
7733 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
7734 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
7735 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
7736 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
7737 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
7738 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
7739 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
7740 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
7741 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
7742 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
7743 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DOUBLE_SPEED);
7745 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
7746 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
7747 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
7750 if (IS_GEM(properties_element))
7751 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
7753 if (COULD_MOVE_INTO_ACID(properties_element) &&
7754 !ELEM_IS_PLAYER(properties_element) &&
7755 (!IS_CUSTOM_ELEMENT(properties_element) ||
7756 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
7758 /* set position for checkbutton for "can move into acid" */
7759 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
7760 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
7761 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
7762 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 6 :
7763 HAS_CONTENT(properties_element) ? 1 : 0);
7765 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
7768 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
7769 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
7771 if (properties_element == EL_SPRING)
7772 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
7774 if (properties_element == EL_TIME_ORB_FULL)
7775 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
7778 if (properties_element == EL_BALLOON)
7779 MapSelectboxGadget(ED_SELECTBOX_ID_WIND_DIRECTION);
7782 if (CAN_GROW(properties_element))
7784 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
7785 ED_ELEMENT_SETTINGS_YPOS(HAS_CONTENT(properties_element) ? 1 : 0);
7787 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
7790 if (IS_ENVELOPE(properties_element))
7792 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
7793 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
7794 int envelope_nr = properties_element - EL_ENVELOPE_1;
7796 counterbutton_info[counter1_id].value = &level.envelope_xsize[envelope_nr];
7797 counterbutton_info[counter2_id].value = &level.envelope_ysize[envelope_nr];
7799 /* display counter to choose size of envelope text area */
7800 MapCounterButtons(ED_COUNTER_ID_ENVELOPE_XSIZE);
7801 MapCounterButtons(ED_COUNTER_ID_ENVELOPE_YSIZE);
7803 DrawEnvelopeTextArea(envelope_nr);
7806 if (IS_CUSTOM_ELEMENT(properties_element))
7808 /* draw stickybutton gadget */
7809 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
7811 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
7813 /* draw checkbutton gadgets */
7814 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
7815 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
7816 MapCheckbuttonGadget(i);
7818 /* draw counter gadgets */
7819 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
7820 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
7821 MapCounterButtons(i);
7823 /* draw selectbox gadgets */
7824 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
7825 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
7826 MapSelectboxGadget(i);
7828 /* draw textbutton gadgets */
7829 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE);
7831 /* draw text input gadgets */
7832 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
7834 /* draw drawing area gadgets */
7835 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
7837 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
7839 /* draw checkbutton gadgets */
7840 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
7841 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
7842 MapCheckbuttonGadget(i);
7844 /* draw counter gadgets */
7845 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
7846 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
7847 MapCounterButtons(i);
7849 /* draw selectbox gadgets */
7850 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
7851 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
7852 MapSelectboxGadget(i);
7854 /* draw drawing area gadgets */
7855 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
7856 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
7857 DrawCustomContentArea();
7860 else if (IS_GROUP_ELEMENT(properties_element))
7862 /* draw stickybutton gadget */
7863 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
7865 /* draw checkbutton gadgets */
7866 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
7867 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE);
7869 /* draw counter gadgets */
7870 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
7872 /* draw selectbox gadgets */
7873 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
7875 /* draw textbutton gadgets */
7876 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE);
7878 /* draw drawing area gadgets */
7879 DrawGroupElementArea(properties_element);
7881 /* draw text input gadgets */
7882 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
7884 /* draw drawing area gadgets */
7885 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
7889 static void DrawPropertiesChangeDrawingAreas()
7891 if (IS_CUSTOM_ELEMENT(properties_element))
7893 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
7894 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
7896 DrawCustomChangeContentArea();
7899 redraw_mask |= REDRAW_FIELD;
7902 static void DrawPropertiesChange()
7906 /* needed to initially set selectbox options for special action options */
7907 setSelectboxSpecialActionOptions();
7909 /* draw stickybutton gadget */
7910 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
7912 /* draw checkbutton gadgets */
7913 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
7914 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
7915 MapCheckbuttonGadget(i);
7917 /* draw counter gadgets */
7918 for (i = ED_COUNTER_ID_CHANGE_FIRST;
7919 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
7920 MapCounterButtons(i);
7922 /* draw selectbox gadgets */
7923 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
7924 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
7925 MapSelectboxGadget(i);
7927 /* draw textbutton gadgets */
7928 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
7929 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
7930 MapTextbuttonGadget(i);
7932 /* draw graphicbutton gadgets */
7933 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
7934 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
7935 MapGraphicbuttonGadget(i);
7937 /* draw drawing area gadgets */
7938 DrawPropertiesChangeDrawingAreas();
7941 static void DrawElementName(int x, int y, int element)
7943 char *element_name = getElementInfoText(element);
7944 int font_nr = FONT_TEXT_1;
7945 int font_width = getFontWidth(font_nr);
7946 int font_height = getFontHeight(font_nr);
7947 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_XPOS(0);
7948 int max_chars_per_line = max_text_width / font_width;
7949 char buffer[max_chars_per_line + 1];
7951 if (strlen(element_name) <= max_chars_per_line)
7952 DrawTextS(x, y, font_nr, element_name);
7955 int next_pos = max_chars_per_line;
7957 strncpy(buffer, element_name, max_chars_per_line);
7958 buffer[max_chars_per_line] = '\0';
7960 if (element_name[max_chars_per_line] == ' ')
7966 for (i = max_chars_per_line - 1; i >= 0; i--)
7967 if (buffer[i] == ' ')
7970 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
7977 DrawTextS(x, y - font_height / 2, font_nr, buffer);
7979 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
7980 buffer[max_chars_per_line] = '\0';
7982 DrawTextS(x, y + font_height / 2, font_nr, buffer);
7986 static void DrawPropertiesWindow()
7991 stick_element_properties_window = FALSE;
7993 /* make sure that previous properties edit mode exists for this element */
7994 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
7995 !IS_CUSTOM_ELEMENT(properties_element))
7996 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
7998 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
7999 IS_CUSTOM_ELEMENT(properties_element))
8000 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
8002 CopyElementPropertiesToEditor(properties_element);
8004 UnmapLevelEditorWindowGadgets();
8005 UnmapLevelEditorToolboxDrawingGadgets();
8006 UnmapLevelEditorToolboxCustomGadgets();
8008 if (IS_CUSTOM_ELEMENT(properties_element) ||
8009 IS_GROUP_ELEMENT(properties_element))
8010 MapLevelEditorToolboxCustomGadgets();
8012 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
8016 DrawTextSCentered(ED_SETTINGS1_YPOS, FONT_TITLE_1, "Element Settings");
8018 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS1_YPOS,
8019 "Element Settings", FONT_TITLE_1);
8022 DrawElementBorder(SX + xstart * MINI_TILEX,
8023 SY + ystart * MINI_TILEY + MINI_TILEY / 2,
8024 TILEX, TILEY, FALSE);
8025 DrawGraphicAnimationExt(drawto,
8026 SX + xstart * MINI_TILEX,
8027 SY + ystart * MINI_TILEY + MINI_TILEY / 2,
8028 el2img(properties_element), -1, NO_MASKING);
8030 FrameCounter = 0; /* restart animation frame counter */
8032 DrawElementName((xstart + 3) * MINI_TILEX + 1, (ystart + 1) * MINI_TILEY + 1,
8033 properties_element);
8035 DrawPropertiesTabulatorGadgets();
8037 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
8038 DrawPropertiesInfo();
8039 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
8040 DrawPropertiesChange();
8041 else /* (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2]) */
8042 DrawPropertiesConfig();
8045 static void UpdateCustomElementGraphicGadgets()
8049 ModifyEditorElementList();
8050 RedrawDrawingElements();
8052 /* force redraw of all mapped drawing area gadgets */
8053 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
8055 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
8062 static void DrawLineElement(int sx, int sy, int element, boolean change_level)
8064 int lx = sx + level_xpos;
8065 int ly = sy + level_ypos;
8067 DrawMiniElement(sx, sy, (element < 0 ? Feld[lx][ly] : element));
8070 Feld[lx][ly] = element;
8073 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
8074 int element, boolean change_level)
8076 if (from_y == to_y) /* horizontal line */
8082 swap_numbers(&from_x, &to_x);
8084 for (x = from_x; x <= to_x; x++)
8085 DrawLineElement(x, y, element, change_level);
8087 else if (from_x == to_x) /* vertical line */
8093 swap_numbers(&from_y, &to_y);
8095 for (y = from_y; y <= to_y; y++)
8096 DrawLineElement(x, y, element, change_level);
8098 else /* diagonal line */
8100 int len_x = ABS(to_x - from_x);
8101 int len_y = ABS(to_y - from_y);
8104 if (len_y < len_x) /* a < 1 */
8106 float a = (float)len_y / (float)len_x;
8109 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
8111 for (x = 0; x <= len_x; x++)
8113 y = (int)(a * x + 0.5) * (to_y < from_y ? -1 : +1);
8114 DrawLineElement(from_x + x, from_y + y, element, change_level);
8119 float a = (float)len_x / (float)len_y;
8122 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
8124 for (y = 0; y <= len_y; y++)
8126 x = (int)(a * y + 0.5) * (to_x < from_x ? -1 : +1);
8127 DrawLineElement(from_x + x, from_y + y, element, change_level);
8133 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
8134 int element, boolean change_level)
8136 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
8137 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
8138 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
8139 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
8142 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
8143 int element, boolean change_level)
8148 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
8150 for (y = from_y; y <= to_y; y++)
8151 DrawLine(from_x, y, to_x, y, element, change_level);
8154 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
8155 int element, boolean change_level)
8157 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
8158 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
8159 int len_x = ABS(to_x - from_x);
8160 int len_y = ABS(to_y - from_y);
8163 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
8165 /* not optimal (some points get drawn twice) but simple,
8166 and fast enough for the few points we are drawing */
8168 for (x = 0; x <= radius; x++)
8172 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
8174 sx = from_x + x * (from_x < to_x2 ? +1 : -1);
8175 sy = from_y + y * (from_y < to_y2 ? +1 : -1);
8176 lx = sx + level_xpos;
8177 ly = sy + level_ypos;
8179 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
8180 DrawLineElement(sx, sy, element, change_level);
8183 for (y = 0; y <= radius; y++)
8187 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
8189 sx = from_x + x * (from_x < to_x2 ? +1 : -1);
8190 sy = from_y + y * (from_y < to_y2 ? +1 : -1);
8191 lx = sx + level_xpos;
8192 ly = sy + level_ypos;
8194 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
8195 DrawLineElement(sx, sy, element, change_level);
8199 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
8200 int element, boolean change_level)
8202 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
8203 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
8205 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
8208 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
8210 #if DRAW_CIRCLES_BUTTON_AVAILABLE
8211 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
8212 int element, boolean change_level)
8214 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
8215 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
8216 int mirror_to_x2 = from_x - (to_x2 - from_x);
8217 int mirror_to_y2 = from_y - (to_y2 - from_y);
8219 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
8220 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
8221 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
8222 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element,change_level);
8226 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
8228 int from_sx, from_sy;
8232 swap_numbers(&from_x, &to_x);
8235 swap_numbers(&from_y, &to_y);
8237 from_sx = SX + from_x * MINI_TILEX;
8238 from_sy = SY + from_y * MINI_TILEY;
8239 to_sx = SX + to_x * MINI_TILEX + MINI_TILEX - 1;
8240 to_sy = SY + to_y * MINI_TILEY + MINI_TILEY - 1;
8242 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
8243 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
8244 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
8245 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
8247 if (from_x == to_x && from_y == to_y)
8248 MarkTileDirty(from_x/2, from_y/2);
8250 redraw_mask |= REDRAW_FIELD;
8253 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
8254 int element, boolean change_level)
8256 if (element == -1 || change_level)
8257 DrawBox(from_x, from_y, to_x, to_y, -1, FALSE);
8259 DrawAreaBorder(from_x, from_y, to_x, to_y);
8262 /* values for CopyBrushExt() */
8263 #define CB_AREA_TO_BRUSH 0
8264 #define CB_BRUSH_TO_CURSOR 1
8265 #define CB_BRUSH_TO_LEVEL 2
8266 #define CB_DELETE_OLD_CURSOR 3
8267 #define CB_DUMP_BRUSH 4
8268 #define CB_DUMP_BRUSH_SMALL 5
8270 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
8271 int button, int mode)
8273 static short brush_buffer[MAX_ED_FIELDX][MAX_ED_FIELDY];
8274 static int brush_width, brush_height;
8275 static int last_cursor_x = -1, last_cursor_y = -1;
8276 static boolean delete_old_brush;
8277 int new_element = BUTTON_ELEMENT(button);
8280 if (mode == CB_DUMP_BRUSH ||
8281 mode == CB_DUMP_BRUSH_SMALL)
8283 if (!draw_with_brush)
8285 Error(ERR_WARN, "no brush selected");
8290 for (y = 0; y < brush_height; y++)
8292 for (x = 0; x < brush_width; x++)
8294 int element = brush_buffer[x][y];
8295 int element_mapped = element;
8297 if (IS_CUSTOM_ELEMENT(element))
8298 element_mapped = EL_CUSTOM_START;
8299 else if (IS_GROUP_ELEMENT(element))
8300 element_mapped = EL_GROUP_START;
8301 else if (element >= NUM_FILE_ELEMENTS)
8302 element_mapped = EL_UNKNOWN;
8304 printf("%c%03d", (mode == CB_DUMP_BRUSH ? '`' : '¸'), element_mapped);
8313 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
8316 if (mode == CB_AREA_TO_BRUSH)
8318 int from_lx, from_ly;
8321 swap_numbers(&from_x, &to_x);
8324 swap_numbers(&from_y, &to_y);
8326 brush_width = to_x - from_x + 1;
8327 brush_height = to_y - from_y + 1;
8329 from_lx = from_x + level_xpos;
8330 from_ly = from_y + level_ypos;
8332 for (y = 0; y < brush_height; y++)
8334 for (x=0; x < brush_width; x++)
8336 brush_buffer[x][y] = Feld[from_lx + x][from_ly + y];
8339 DrawLineElement(from_x + x, from_y + y, new_element, TRUE);
8344 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8346 delete_old_brush = FALSE;
8348 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
8349 mode == CB_BRUSH_TO_LEVEL)
8351 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
8352 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
8353 int cursor_from_x = cursor_x - brush_width / 2;
8354 int cursor_from_y = cursor_y - brush_height / 2;
8355 int border_from_x = cursor_x, border_from_y = cursor_y;
8356 int border_to_x = cursor_x, border_to_y = cursor_y;
8358 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
8359 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
8361 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
8362 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
8364 delete_old_brush = FALSE;
8368 for (y = 0; y < brush_height; y++)
8370 for (x = 0; x < brush_width; x++)
8372 int sx = cursor_from_x + x;
8373 int sy = cursor_from_y + y;
8374 int lx = sx + level_xpos;
8375 int ly = sy + level_ypos;
8376 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
8377 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
8378 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
8379 brush_buffer[x][y] : new_element);
8381 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
8383 if (sx < border_from_x)
8385 else if (sx > border_to_x)
8387 if (sy < border_from_y)
8389 else if (sy > border_to_y)
8392 DrawLineElement(sx, sy, element, change_level);
8397 if (mode != CB_DELETE_OLD_CURSOR)
8398 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
8400 last_cursor_x = cursor_x;
8401 last_cursor_y = cursor_y;
8402 delete_old_brush = TRUE;
8406 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
8409 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
8412 static void CopyBrushToLevel(int x, int y, int button)
8414 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
8417 static void CopyBrushToCursor(int x, int y)
8419 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
8422 static void DeleteBrushFromCursor()
8424 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
8429 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
8432 void DumpBrush_Small()
8434 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
8437 static void FloodFill(int from_x, int from_y, int fill_element)
8441 static int check[4][2] = { {-1,0}, {0,-1}, {1,0}, {0,1} };
8442 static int safety = 0;
8444 /* check if starting field still has the desired content */
8445 if (Feld[from_x][from_y] == fill_element)
8450 if (safety > lev_fieldx*lev_fieldy)
8451 Error(ERR_EXIT, "Something went wrong in 'FloodFill()'. Please debug.");
8453 old_element = Feld[from_x][from_y];
8454 Feld[from_x][from_y] = fill_element;
8456 for (i = 0; i < 4; i++)
8458 x = from_x + check[i][0];
8459 y = from_y + check[i][1];
8461 if (IN_LEV_FIELD(x,y) && Feld[x][y] == old_element)
8462 FloodFill(x, y, fill_element);
8468 /* values for DrawLevelText() modes */
8470 #define TEXT_SETCURSOR 1
8471 #define TEXT_WRITECHAR 2
8472 #define TEXT_BACKSPACE 3
8473 #define TEXT_NEWLINE 4
8475 #define TEXT_QUERY_TYPING 6
8477 static int DrawLevelText(int sx, int sy, char letter, int mode)
8479 static short delete_buffer[MAX_LEV_FIELDX];
8480 static int start_sx, start_sy;
8481 static int last_sx, last_sy;
8482 static boolean typing = FALSE;
8483 int letter_element = EL_CHAR_ASCII0 + letter;
8486 /* map lower case letters to upper case and convert special characters */
8487 if (letter >= 'a' && letter <= 'z')
8488 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
8489 else if (letter == 'ä' || letter == 'Ä')
8490 letter_element = EL_CHAR_AUMLAUT;
8491 else if (letter == 'ö' || letter == 'Ö')
8492 letter_element = EL_CHAR_OUMLAUT;
8493 else if (letter == 'ü' || letter == 'Ü')
8494 letter_element = EL_CHAR_UUMLAUT;
8495 else if (letter == '^')
8496 letter_element = EL_CHAR_COPYRIGHT;
8498 letter_element = EL_CHAR_ASCII0 + letter;
8500 if (mode != TEXT_INIT)
8505 if (mode != TEXT_SETCURSOR)
8511 lx = last_sx + level_xpos;
8512 ly = last_sy + level_ypos;
8519 DrawLevelText(0, 0, 0, TEXT_END);
8522 start_sx = last_sx = sx;
8523 start_sy = last_sy = sy;
8524 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
8527 case TEXT_SETCURSOR:
8528 DrawMiniElement(last_sx, last_sy, Feld[lx][ly]);
8529 DrawAreaBorder(sx, sy, sx, sy);
8534 case TEXT_WRITECHAR:
8535 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
8537 delete_buffer[sx - start_sx] = Feld[lx][ly];
8538 Feld[lx][ly] = letter_element;
8540 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
8541 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
8542 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
8543 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
8545 DrawLevelText(0, 0, 0, TEXT_END);
8547 level.changed = TRUE;
8551 case TEXT_BACKSPACE:
8554 Feld[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
8555 DrawMiniElement(sx - 1, sy, Feld[lx - 1][ly]);
8556 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
8561 if (sy + 1 < ed_fieldy - 1 && ly + 1 < lev_fieldy - 1)
8562 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
8564 DrawLevelText(0, 0, 0, TEXT_END);
8568 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8569 DrawMiniElement(sx, sy, Feld[lx][ly]);
8573 case TEXT_QUERY_TYPING:
8583 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
8584 int element, boolean change_level)
8586 int lx = sx + level_xpos;
8587 int ly = sy + level_ypos;
8590 DrawMiniElement(sx, sy, Feld[lx][ly]);
8592 DrawAreaBorder(sx, sy, sx, sy);
8595 static void CopyLevelToUndoBuffer(int mode)
8597 static boolean accumulated_undo = FALSE;
8598 boolean new_undo_buffer_position = TRUE;
8599 int last_border_element;
8604 case UNDO_IMMEDIATE:
8605 accumulated_undo = FALSE;
8608 case UNDO_ACCUMULATE:
8609 if (accumulated_undo)
8610 new_undo_buffer_position = FALSE;
8611 accumulated_undo = TRUE;
8618 if (new_undo_buffer_position)
8620 /* new position in undo buffer ring */
8621 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
8623 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
8624 undo_buffer_steps++;
8627 for (x = 0; x < lev_fieldx; x++)
8628 for (y = 0; y < lev_fieldy; y++)
8629 UndoBuffer[undo_buffer_position][x][y] = Feld[x][y];
8631 /* check if drawing operation forces change of border style */
8632 last_border_element = BorderElement;
8634 if (BorderElement != last_border_element)
8635 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8637 level.changed = TRUE;
8640 static void RandomPlacement(int new_element)
8642 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
8643 int num_free_positions = 0;
8644 int num_percentage, num_elements;
8647 /* determine number of free positions for randomly placing the new element */
8648 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
8650 free_position[x][y] =
8651 (random_placement_background_restricted ?
8652 Feld[x][y] == random_placement_background_element :
8653 Feld[x][y] != new_element);
8655 if (free_position[x][y])
8656 num_free_positions++;
8659 /* determine number of new elements to place there */
8660 num_percentage = num_free_positions * random_placement_value / 100;
8661 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
8662 num_percentage : random_placement_value);
8664 /* if less free positions than elements to place, fill all these positions */
8665 if (num_free_positions < num_elements)
8667 for (x = 0; x < lev_fieldx; x++)
8668 for (y = 0; y < lev_fieldy; y++)
8669 if (free_position[x][y])
8670 Feld[x][y] = new_element;
8674 while (num_elements > 0)
8676 x = RND(lev_fieldx);
8677 y = RND(lev_fieldy);
8679 /* don't place element at the same position twice */
8680 if (free_position[x][y])
8682 free_position[x][y] = FALSE;
8683 Feld[x][y] = new_element;
8689 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8690 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8693 void WrapLevel(int dx, int dy)
8695 int wrap_dx = lev_fieldx - dx;
8696 int wrap_dy = lev_fieldy - dy;
8699 for (x = 0; x < lev_fieldx; x++)
8700 for (y = 0; y < lev_fieldy; y++)
8701 FieldBackup[x][y] = Feld[x][y];
8703 for (x = 0; x < lev_fieldx; x++)
8704 for (y = 0; y < lev_fieldy; y++)
8706 FieldBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
8708 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8709 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
8712 static void HandleDrawingAreas(struct GadgetInfo *gi)
8714 static boolean started_inside_drawing_area = FALSE;
8715 int id = gi->custom_id;
8716 boolean button_press_event;
8717 boolean button_release_event;
8718 boolean inside_drawing_area = !gi->event.off_borders;
8719 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
8720 int actual_drawing_function;
8721 int button = gi->event.button;
8722 int new_element = BUTTON_ELEMENT(button);
8723 int sx = gi->event.x, sy = gi->event.y;
8724 int min_sx = 0, min_sy = 0;
8725 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
8726 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
8728 int min_lx = 0, min_ly = 0;
8729 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
8732 /* handle info callback for each invocation of action callback */
8733 gi->callback_info(gi);
8735 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
8736 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
8738 /* make sure to stay inside drawing area boundaries */
8739 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
8740 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
8744 /* get positions inside level field */
8745 lx = sx + level_xpos;
8746 ly = sy + level_ypos;
8748 if (!IN_LEV_FIELD(lx, ly))
8749 inside_drawing_area = FALSE;
8751 /* make sure to stay inside level field boundaries */
8752 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
8753 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
8755 /* correct drawing area positions accordingly */
8756 sx = lx - level_xpos;
8757 sy = ly - level_ypos;
8760 if (button_press_event)
8761 started_inside_drawing_area = inside_drawing_area;
8763 if (!started_inside_drawing_area)
8767 if (!IS_VALID_BUTTON(button))
8771 if (!button && !button_release_event)
8774 /* automatically switch to 'single item' drawing mode, if needed */
8775 actual_drawing_function =
8776 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
8777 drawing_function : GADGET_ID_SINGLE_ITEMS);
8779 /* clicking into drawing area with pressed Control key picks element */
8780 if (GetKeyModState() & KMOD_Control)
8782 last_drawing_function = drawing_function;
8783 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
8786 switch (actual_drawing_function)
8788 case GADGET_ID_SINGLE_ITEMS:
8791 if (button_release_event)
8793 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8795 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
8796 !inside_drawing_area)
8797 DeleteBrushFromCursor();
8803 if (draw_with_brush)
8805 if (!button_release_event)
8806 CopyBrushToLevel(sx, sy, button);
8808 else if (new_element != Feld[lx][ly])
8810 if (new_element == EL_PLAYER_1)
8812 /* remove player at old position */
8813 for (y = 0; y < lev_fieldy; y++)
8815 for (x = 0; x < lev_fieldx; x++)
8817 if (Feld[x][y] == EL_PLAYER_1)
8819 Feld[x][y] = EL_EMPTY;
8820 if (x - level_xpos >= 0 && x - level_xpos < ed_fieldx &&
8821 y - level_ypos >= 0 && y - level_ypos < ed_fieldy)
8822 DrawMiniElement(x - level_xpos, y - level_ypos,
8829 Feld[lx][ly] = new_element;
8830 DrawMiniElement(sx, sy, new_element);
8835 int type_id = gi->custom_type_id;
8836 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
8838 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
8839 DrawMiniGraphicExt(drawto,
8840 gi->x + sx * MINI_TILEX,
8841 gi->y + sy * MINI_TILEY,
8842 el2edimg(new_element));
8844 DrawGraphicExt(drawto,
8847 el2img(new_element), 0);
8849 if (id == GADGET_ID_CUSTOM_GRAPHIC)
8850 new_element = GFX_ELEMENT(new_element);
8852 drawingarea_info[type_id].value[pos] = new_element;
8854 CopyElementPropertiesToGame(properties_element);
8856 if (id == GADGET_ID_CUSTOM_GRAPHIC)
8858 UpdateCustomElementGraphicGadgets();
8860 FrameCounter = 0; /* restart animation frame counter */
8865 case GADGET_ID_CONNECTED_ITEMS:
8867 static int last_sx = -1;
8868 static int last_sy = -1;
8870 if (button_release_event)
8871 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8875 if (!button_press_event)
8876 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
8884 case GADGET_ID_LINE:
8886 case GADGET_ID_RECTANGLE:
8887 case GADGET_ID_FILLED_BOX:
8888 case GADGET_ID_GRAB_BRUSH:
8889 case GADGET_ID_TEXT:
8891 static int last_sx = -1;
8892 static int last_sy = -1;
8893 static int start_sx = -1;
8894 static int start_sy = -1;
8895 void (*draw_func)(int, int, int, int, int, boolean);
8897 if (drawing_function == GADGET_ID_LINE)
8898 draw_func = DrawLine;
8899 else if (drawing_function == GADGET_ID_ARC)
8900 draw_func = DrawArc;
8901 else if (drawing_function == GADGET_ID_RECTANGLE)
8902 draw_func = DrawBox;
8903 else if (drawing_function == GADGET_ID_FILLED_BOX)
8904 draw_func = DrawFilledBox;
8905 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
8906 draw_func = SelectArea;
8907 else /* (drawing_function == GADGET_ID_TEXT) */
8908 draw_func = SetTextCursor;
8910 if (button_press_event)
8912 draw_func(sx, sy, sx, sy, new_element, FALSE);
8913 start_sx = last_sx = sx;
8914 start_sy = last_sy = sy;
8916 if (drawing_function == GADGET_ID_TEXT)
8917 DrawLevelText(0, 0, 0, TEXT_END);
8919 else if (button_release_event)
8921 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
8922 if (drawing_function == GADGET_ID_GRAB_BRUSH)
8924 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
8925 CopyBrushToCursor(sx, sy);
8926 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
8928 draw_with_brush = TRUE;
8930 else if (drawing_function == GADGET_ID_TEXT)
8931 DrawLevelText(sx, sy, 0, TEXT_INIT);
8933 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8935 else if (last_sx != sx || last_sy != sy)
8937 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
8938 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
8945 case GADGET_ID_FLOOD_FILL:
8946 if (button_press_event && Feld[lx][ly] != new_element)
8948 FloodFill(lx, ly, new_element);
8949 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8950 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8954 case GADGET_ID_PICK_ELEMENT:
8955 if (button_release_event)
8956 ClickOnGadget(level_editor_gadget[last_drawing_function],
8958 else if (draw_level)
8959 PickDrawingElement(button, Feld[lx][ly]);
8962 int type_id = gi->custom_type_id;
8963 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
8965 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
8975 static void HandleCounterButtons(struct GadgetInfo *gi)
8977 int gadget_id = gi->custom_id;
8978 int counter_id = gi->custom_type_id;
8979 int button = gi->event.button;
8980 int *counter_value = counterbutton_info[counter_id].value;
8981 int step = BUTTON_STEPSIZE(button) *
8982 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
8984 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
8986 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
8987 boolean released = (gi->event.type == GD_EVENT_RELEASED);
8988 boolean level_changed = LevelChanged();
8990 if ((level_changed && pressed) || (!level_changed && released))
8993 if (level_changed && !Request("Level has changed ! Discard changes ?",
8996 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
8997 ModifyEditorCounterValue(counter_id, *counter_value);
9003 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
9004 *counter_value = gi->textinput.number_value;
9006 ModifyEditorCounterValue(counter_id, *counter_value + step);
9008 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
9010 LoadLevel(level_nr);
9013 DrawEditModeWindow();
9020 case ED_COUNTER_ID_YAMYAM_CONTENT:
9021 DrawYamYamContentAreas();
9024 case ED_COUNTER_ID_BALL_CONTENT:
9025 DrawMagicBallContentAreas();
9028 case ED_COUNTER_ID_GROUP_CONTENT:
9029 DrawGroupElementArea(properties_element);
9030 CopyGroupElementPropertiesToGame(properties_element);
9033 case ED_COUNTER_ID_ENVELOPE_XSIZE:
9034 case ED_COUNTER_ID_ENVELOPE_YSIZE:
9035 DrawEnvelopeTextArea(-1);
9038 case ED_COUNTER_ID_LEVEL_XSIZE:
9039 case ED_COUNTER_ID_LEVEL_YSIZE:
9040 lev_fieldx = level.fieldx;
9041 lev_fieldy = level.fieldy;
9048 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
9049 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
9050 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
9051 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
9052 CopyElementPropertiesToGame(properties_element);
9054 level.changed = TRUE;
9057 static void HandleTextInputGadgets(struct GadgetInfo *gi)
9059 int type_id = gi->custom_type_id;
9061 strcpy(textinput_info[type_id].value, gi->textinput.value);
9063 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
9065 CopyElementPropertiesToGame(properties_element);
9067 ModifyEditorElementList(); /* update changed button info text */
9070 level.changed = TRUE;
9073 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
9075 int type_id = gi->custom_type_id;
9077 strcpy(textarea_info[type_id].value, gi->textarea.value);
9079 level.changed = TRUE;
9082 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
9084 int type_id = gi->custom_type_id;
9085 int value_old = *selectbox_info[type_id].value;
9086 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
9088 *selectbox_info[type_id].value = value_new;
9090 if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
9092 element_info[properties_element].current_change_page = gi->selectbox.index;
9094 DrawPropertiesWindow();
9096 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
9097 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
9098 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
9099 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
9100 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
9102 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
9104 /* when changing action type, reset action mode and action arg */
9105 if (value_old != value_new)
9107 custom_element_change.action_mode = -1;
9108 custom_element_change.action_arg = -1;
9111 DrawPropertiesChange();
9114 CopyElementPropertiesToGame(properties_element);
9116 level.changed = TRUE;
9120 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
9122 int type_id = gi->custom_type_id;
9125 if (type_id >= ED_TEXTBUTTON_ID_PROPERTIES_FIRST &&
9126 type_id <= ED_TEXTBUTTON_ID_PROPERTIES_LAST)
9128 edit_mode_properties = gi->custom_type_id;
9130 DrawPropertiesWindow();
9132 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE)
9134 char *template_filename = getDefaultLevelFilename(-1);
9135 boolean new_template = !fileExists(template_filename);
9138 Request("Save this template and kill the old ?", REQ_ASK))
9139 SaveLevelTemplate();
9142 Request("Template saved !", REQ_CONFIRM);
9144 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
9145 custom_element.num_change_pages < MAX_CHANGE_PAGES)
9147 struct ElementInfo *ei = &element_info[properties_element];
9149 setElementChangePages(ei, ei->num_change_pages + 1);
9151 /* set new change page to be new current change page */
9152 ei->current_change_page = ei->num_change_pages - 1;
9153 ei->change = &ei->change_page[ei->current_change_page];
9155 setElementChangeInfoToDefaults(ei->change);
9157 DrawPropertiesWindow();
9159 level.changed = TRUE;
9161 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
9162 custom_element.num_change_pages > MIN_CHANGE_PAGES)
9164 struct ElementInfo *ei = &element_info[properties_element];
9166 /* copy all change pages after change page to be deleted */
9167 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
9168 ei->change_page[i] = ei->change_page[i + 1];
9170 setElementChangePages(ei, ei->num_change_pages - 1);
9172 DrawPropertiesWindow();
9174 level.changed = TRUE;
9178 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
9180 int type_id = gi->custom_type_id;
9182 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
9183 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
9185 struct ElementInfo *ei = &element_info[properties_element];
9186 int step = BUTTON_STEPSIZE(gi->event.button);
9188 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
9189 ei->current_change_page += step;
9191 if (ei->current_change_page < 0)
9192 ei->current_change_page = 0;
9193 else if (ei->current_change_page >= ei->num_change_pages)
9194 ei->current_change_page = ei->num_change_pages - 1;
9196 DrawPropertiesWindow();
9198 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
9199 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
9201 struct ElementInfo *ei = &element_info[properties_element];
9202 int current_change_page = ei->current_change_page;
9204 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
9205 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
9206 ei->change_page[current_change_page];
9207 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
9209 ei->change_page[current_change_page] =
9210 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
9212 level.changed = TRUE;
9215 DrawPropertiesWindow();
9219 static void HandleRadiobuttons(struct GadgetInfo *gi)
9221 *radiobutton_info[gi->custom_type_id].value =
9222 radiobutton_info[gi->custom_type_id].checked_value;
9224 level.changed = TRUE;
9227 static void HandleCheckbuttons(struct GadgetInfo *gi)
9229 int type_id = gi->custom_type_id;
9231 *checkbutton_info[type_id].value ^= TRUE;
9233 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
9234 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
9235 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
9236 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
9237 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
9238 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
9239 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
9240 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE))
9242 CopyElementPropertiesToGame(properties_element);
9245 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
9247 UpdateCustomElementGraphicGadgets();
9249 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE)
9251 char *template_filename = getDefaultLevelFilename(-1);
9253 if (level.use_custom_template && !fileExists(template_filename))
9255 Request("No level template found !", REQ_CONFIRM);
9257 level.use_custom_template = FALSE;
9258 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
9263 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
9265 DrawEditModeWindow();
9268 level.changed = TRUE;
9271 static void HandleControlButtons(struct GadgetInfo *gi)
9273 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
9274 static int last_edit_mode = ED_MODE_DRAWING;
9275 static int last_custom_copy_mode = -1;
9276 int id = gi->custom_id;
9277 int button = gi->event.button;
9278 int step = BUTTON_STEPSIZE(button);
9279 int new_element = BUTTON_ELEMENT(button);
9283 /* MAKES PROBLEMS WITH ELEMENT LIST SCROLLBAR AND IS PROBABLY NOT NEEDED */
9284 /* !!! CHECK WHAT HAPPENS WHEN MOUSE WHEEL IS USED OVER ELEMENT LIST !!! */
9286 if (!IS_VALID_BUTTON(button))
9290 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
9291 DrawLevelText(0, 0, 0, TEXT_END);
9293 if (id < ED_NUM_CTRL1_BUTTONS &&
9294 id != GADGET_ID_SINGLE_ITEMS &&
9295 id != GADGET_ID_PROPERTIES &&
9296 id != GADGET_ID_PICK_ELEMENT &&
9297 edit_mode != ED_MODE_DRAWING &&
9298 drawing_function != GADGET_ID_PICK_ELEMENT &&
9299 !(GetKeyModState() & KMOD_Control))
9301 DrawDrawingWindow();
9302 edit_mode = ED_MODE_DRAWING;
9305 /* element copy mode active, but no element button pressed => deactivate */
9306 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
9307 last_custom_copy_mode = -1;
9311 case GADGET_ID_SCROLL_LEFT:
9312 if (level_xpos >= 0)
9314 if (lev_fieldx < ed_fieldx - 2)
9318 if (level_xpos < -1)
9321 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
9323 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9325 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
9326 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
9330 case GADGET_ID_SCROLL_RIGHT:
9331 if (level_xpos <= lev_fieldx - ed_fieldx)
9333 if (lev_fieldx < ed_fieldx - 2)
9337 if (level_xpos > lev_fieldx - ed_fieldx + 1)
9338 level_xpos = lev_fieldx - ed_fieldx + 1;
9340 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
9342 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9344 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
9345 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
9349 case GADGET_ID_SCROLL_UP:
9350 if (level_ypos >= 0)
9352 if (lev_fieldy < ed_fieldy - 2)
9356 if (level_ypos < -1)
9359 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
9361 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9363 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
9364 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
9368 case GADGET_ID_SCROLL_DOWN:
9369 if (level_ypos <= lev_fieldy - ed_fieldy)
9371 if (lev_fieldy < ed_fieldy - 2)
9375 if (level_ypos > lev_fieldy - ed_fieldy + 1)
9376 level_ypos = lev_fieldy - ed_fieldy + 1;
9378 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_UP);
9380 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9382 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
9383 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
9387 case GADGET_ID_SCROLL_HORIZONTAL:
9388 level_xpos = gi->event.item_position - 1;
9389 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9392 case GADGET_ID_SCROLL_VERTICAL:
9393 level_ypos = gi->event.item_position - 1;
9394 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9397 case GADGET_ID_SCROLL_LIST_UP:
9398 case GADGET_ID_SCROLL_LIST_DOWN:
9399 case GADGET_ID_SCROLL_LIST_VERTICAL:
9400 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
9401 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
9404 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
9405 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
9407 if (element_shift < 0)
9409 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
9410 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
9412 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
9413 GDI_SCROLLBAR_ITEM_POSITION,
9414 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
9417 ModifyEditorElementList();
9421 case GADGET_ID_WRAP_LEFT:
9422 WrapLevel(-step, 0);
9425 case GADGET_ID_WRAP_RIGHT:
9429 case GADGET_ID_WRAP_UP:
9430 WrapLevel(0, -step);
9433 case GADGET_ID_WRAP_DOWN:
9437 case GADGET_ID_SINGLE_ITEMS:
9438 case GADGET_ID_CONNECTED_ITEMS:
9439 case GADGET_ID_LINE:
9441 case GADGET_ID_TEXT:
9442 case GADGET_ID_RECTANGLE:
9443 case GADGET_ID_FILLED_BOX:
9444 case GADGET_ID_FLOOD_FILL:
9445 case GADGET_ID_GRAB_BRUSH:
9446 case GADGET_ID_PICK_ELEMENT:
9447 if (drawing_function != GADGET_ID_PICK_ELEMENT)
9448 last_drawing_function = drawing_function;
9449 drawing_function = id;
9450 draw_with_brush = FALSE;
9453 case GADGET_ID_RANDOM_PLACEMENT:
9454 RandomPlacement(new_element);
9457 case GADGET_ID_PROPERTIES:
9458 if (edit_mode != ED_MODE_PROPERTIES)
9460 properties_element = new_element;
9461 DrawPropertiesWindow();
9462 edit_mode = ED_MODE_PROPERTIES;
9464 last_level_drawing_function = drawing_function;
9465 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
9470 DrawDrawingWindow();
9471 edit_mode = ED_MODE_DRAWING;
9473 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
9478 case GADGET_ID_CUSTOM_COPY_FROM:
9479 case GADGET_ID_CUSTOM_COPY_TO:
9480 case GADGET_ID_CUSTOM_EXCHANGE:
9481 last_custom_copy_mode = id;
9482 last_drawing_function = drawing_function;
9485 case GADGET_ID_CUSTOM_COPY:
9486 CopyCustomElement(properties_element, -1, id);
9489 case GADGET_ID_CUSTOM_PASTE:
9490 CopyCustomElement(-1, properties_element, id);
9493 case GADGET_ID_UNDO:
9494 if (undo_buffer_steps == 0)
9496 Request("Undo buffer empty !", REQ_CONFIRM);
9500 if (edit_mode != ED_MODE_DRAWING)
9502 DrawDrawingWindow();
9503 edit_mode = ED_MODE_DRAWING;
9506 undo_buffer_position =
9507 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
9508 undo_buffer_steps--;
9510 for (x = 0; x < lev_fieldx; x++)
9511 for (y = 0; y < lev_fieldy; y++)
9512 Feld[x][y] = UndoBuffer[undo_buffer_position][x][y];
9513 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos,level_ypos);
9516 case GADGET_ID_INFO:
9517 if (edit_mode != ED_MODE_INFO)
9519 last_edit_mode = edit_mode;
9520 edit_mode = ED_MODE_INFO;
9522 DrawLevelInfoWindow();
9526 edit_mode = last_edit_mode;
9528 DrawEditModeWindow();
9532 case GADGET_ID_CLEAR:
9533 if (edit_mode != ED_MODE_DRAWING)
9535 DrawDrawingWindow();
9536 edit_mode = ED_MODE_DRAWING;
9539 for (x = 0; x < MAX_LEV_FIELDX; x++)
9540 for (y = 0; y < MAX_LEV_FIELDY; y++)
9541 Feld[x][y] = (button == 1 ? EL_EMPTY : new_element);
9543 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
9545 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9548 case GADGET_ID_SAVE:
9549 if (leveldir_current->readonly)
9551 Request("This level is read only !", REQ_CONFIRM);
9555 if (!LevelContainsPlayer())
9556 Request("No Level without Gregor Mc Duffin please !", REQ_CONFIRM);
9559 char *level_filename = getDefaultLevelFilename(level_nr);
9560 boolean new_level = !fileExists(level_filename);
9563 Request("Save this level and kill the old ?", REQ_ASK))
9565 CopyPlayfield(Feld, level.field);
9567 SaveLevel(level_nr);
9571 Request("Level saved !", REQ_CONFIRM);
9573 level.changed = FALSE;
9577 case GADGET_ID_TEST:
9578 if (!LevelContainsPlayer())
9579 Request("No Level without Gregor Mc Duffin please !", REQ_CONFIRM);
9583 level.game_version = GAME_VERSION_ACTUAL;
9585 CopyPlayfield(level.field, FieldBackup);
9586 CopyPlayfield(Feld, level.field);
9588 CopyNativeLevel_RND_to_Native(&level);
9590 UnmapLevelEditorGadgets();
9591 UndrawSpecialEditorDoor();
9593 CloseDoor(DOOR_CLOSE_ALL);
9595 DrawCompleteVideoDisplay();
9597 level_editor_test_game = TRUE;
9599 StartGameActions(FALSE, setup.autorecord, NEW_RANDOMIZE);
9603 case GADGET_ID_EXIT:
9604 RequestExitLevelEditor(TRUE); /* if level has changed, ask user */
9608 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
9609 id <= GADGET_ID_ELEMENTLIST_LAST)
9611 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
9612 int new_element = editor_elements[element_position + element_shift];
9614 if (IS_EDITOR_CASCADE(new_element))
9618 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
9620 int *cascade_element= &(*editor_elements_info[i].headline_list)[0];
9621 boolean *cascade_value=editor_elements_info[i].setup_cascade_value;
9623 if (*cascade_element == new_element)
9625 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
9626 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
9628 /* update element selection list */
9629 ReinitializeElementList();
9630 ModifyEditorElementList();
9632 /* update cascading gadget info text */
9633 PrintEditorGadgetInfoText(level_editor_gadget[id]);
9635 /* save current editor cascading state */
9636 SaveSetup_EditorCascade();
9645 if (last_custom_copy_mode != -1)
9647 if (CopyCustomElement(properties_element, new_element,
9648 last_custom_copy_mode))
9650 ClickOnGadget(level_editor_gadget[last_drawing_function],
9653 last_custom_copy_mode = -1;
9659 PickDrawingElement(button, new_element);
9661 if (!stick_element_properties_window &&
9662 drawing_function != GADGET_ID_PICK_ELEMENT &&
9663 !(GetKeyModState() & KMOD_Control))
9665 properties_element = new_element;
9666 if (edit_mode == ED_MODE_PROPERTIES)
9667 DrawPropertiesWindow();
9670 if (drawing_function == GADGET_ID_PICK_ELEMENT)
9671 ClickOnGadget(level_editor_gadget[last_drawing_function],
9675 else if (gi->event.type == GD_EVENT_PRESSED)
9676 printf("default: HandleControlButtons: GD_EVENT_PRESSED(%d)\n", id);
9677 else if (gi->event.type == GD_EVENT_RELEASED)
9678 printf("default: HandleControlButtons: GD_EVENT_RELEASED(%d)\n", id);
9679 else if (gi->event.type == GD_EVENT_MOVING)
9680 printf("default: HandleControlButtons: GD_EVENT_MOVING(%d)\n", id);
9682 printf("default: HandleControlButtons: ? (id == %d)\n", id);
9688 void HandleLevelEditorKeyInput(Key key)
9690 char letter = getCharFromKey(key);
9691 int button = MB_LEFTBUTTON;
9693 if (drawing_function == GADGET_ID_TEXT &&
9694 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
9697 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
9698 else if (key == KSYM_Delete || key == KSYM_BackSpace)
9699 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
9700 else if (key == KSYM_Return)
9701 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
9702 else if (key == KSYM_Escape)
9703 DrawLevelText(0, 0, 0, TEXT_END);
9705 else if (button_status == MB_RELEASED)
9707 int i, id = GADGET_ID_NONE;
9712 id = GADGET_ID_SCROLL_LEFT;
9715 id = GADGET_ID_SCROLL_RIGHT;
9718 id = GADGET_ID_SCROLL_UP;
9721 id = GADGET_ID_SCROLL_DOWN;
9724 id = GADGET_ID_SCROLL_LIST_UP;
9725 button = MB_RIGHTBUTTON;
9727 case KSYM_Page_Down:
9728 id = GADGET_ID_SCROLL_LIST_DOWN;
9729 button = MB_RIGHTBUTTON;
9733 if (edit_mode == ED_MODE_DRAWING)
9735 RequestExitLevelEditor(setup.ask_on_escape);
9737 else if (edit_mode == ED_MODE_INFO)
9739 HandleControlButtons(level_editor_gadget[GADGET_ID_INFO]);
9741 else if (edit_mode == ED_MODE_PROPERTIES)
9743 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
9745 else /* should never happen */
9747 DrawDrawingWindow();
9748 edit_mode = ED_MODE_DRAWING;
9756 if (id != GADGET_ID_NONE)
9757 ClickOnGadget(level_editor_gadget[id], button);
9758 else if (letter == '.')
9759 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
9760 else if (key == KSYM_Return || key == setup.shortcut.toggle_pause)
9761 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
9763 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
9764 if (letter && letter == control_info[i].shortcut)
9765 if (!anyTextGadgetActive())
9766 ClickOnGadget(level_editor_gadget[i], button);
9770 void HandleLevelEditorIdle()
9772 static unsigned long action_delay = 0;
9773 unsigned long action_delay_value = GameFrameDelay;
9774 int xpos = 1, ypos = 2;
9776 if (edit_mode != ED_MODE_PROPERTIES)
9779 if (!DelayReached(&action_delay, action_delay_value))
9782 DrawGraphicAnimationExt(drawto,
9784 SY + ypos * TILEY + MINI_TILEY / 2,
9785 el2img(properties_element), -1, NO_MASKING);
9787 MarkTileDirty(xpos, ypos);
9788 MarkTileDirty(xpos, ypos + 1);
9790 FrameCounter++; /* increase animation frame counter */
9793 void ClearEditorGadgetInfoText()
9795 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
9798 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
9800 char infotext[MAX_OUTPUT_LINESIZE + 1];
9801 char shortcut[MAX_OUTPUT_LINESIZE + 1];
9802 int max_infotext_len = getMaxInfoTextLength();
9804 if (gi == NULL || gi->info_text == NULL)
9807 strncpy(infotext, gi->info_text, max_infotext_len);
9808 infotext[max_infotext_len] = '\0';
9810 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
9812 int key = control_info[gi->custom_id].shortcut;
9816 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS) /* special case 1 */
9817 sprintf(shortcut, " ('.' or '%c')", key);
9818 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT) /* special case 2 */
9819 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
9820 else if (gi->custom_id == GADGET_ID_TEST) /* special case 3 */
9821 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
9822 else /* normal case */
9823 sprintf(shortcut, " ('%s%c')",
9824 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
9826 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
9827 strcat(infotext, shortcut);
9831 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, FONT_TEXT_2);
9834 void HandleEditorGadgetInfoText(void *ptr)
9836 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
9838 char infotext[MAX_OUTPUT_LINESIZE + 1];
9839 char shortcut[MAX_OUTPUT_LINESIZE + 1];
9840 int max_infotext_len = getMaxInfoTextLength();
9843 if (game_status != GAME_MODE_EDITOR)
9846 ClearEditorGadgetInfoText();
9848 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
9851 /* misuse this function to delete brush cursor, if needed */
9852 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
9853 DeleteBrushFromCursor();
9856 PrintEditorGadgetInfoText(gi);
9858 if (gi == NULL || gi->info_text == NULL)
9861 strncpy(infotext, gi->info_text, max_infotext_len);
9862 infotext[max_infotext_len] = '\0';
9864 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
9866 int key = control_info[gi->custom_id].shortcut;
9870 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS) /* special case 1 */
9871 sprintf(shortcut, " ('.' or '%c')", key);
9872 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT) /* special case 2 */
9873 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
9874 else if (gi->custom_id == GADGET_ID_TEST) /* special case 3 */
9875 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
9876 else /* normal case */
9877 sprintf(shortcut, " ('%s%c')",
9878 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
9880 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
9881 strcat(infotext, shortcut);
9885 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, FONT_TEXT_2);
9889 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
9891 static int start_lx, start_ly;
9892 int id = gi->custom_id;
9893 int type_id = gi->custom_type_id;
9894 int sx = gi->event.x;
9895 int sy = gi->event.y;
9896 int lx = sx + level_xpos;
9897 int ly = sy + level_ypos;
9898 int min_sx = 0, min_sy = 0;
9899 int max_sx = gi->drawing.area_xsize - 1;
9900 int max_sy = gi->drawing.area_ysize - 1;
9901 int actual_drawing_function = drawing_function;
9902 int max_infotext_len = getMaxInfoTextLength();
9903 char infotext[MAX_OUTPUT_LINESIZE + 1];
9906 infotext[0] = '\0'; /* start with empty info text */
9908 /* pressed Control key: simulate picking element */
9909 if (GetKeyModState() & KMOD_Control)
9910 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
9912 ClearEditorGadgetInfoText();
9914 if (gi->event.type == GD_EVENT_INFO_LEAVING)
9917 /* make sure to stay inside drawing area boundaries */
9918 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
9919 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
9921 if (id == GADGET_ID_DRAWING_LEVEL)
9925 int min_lx = 0, min_ly = 0;
9926 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
9928 /* get positions inside level field */
9929 lx = sx + level_xpos;
9930 ly = sy + level_ypos;
9932 /* make sure to stay inside level field boundaries */
9933 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
9934 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
9936 /* correct drawing area positions accordingly */
9937 sx = lx - level_xpos;
9938 sy = ly - level_ypos;
9941 if (IN_ED_FIELD(sx,sy) && IN_LEV_FIELD(lx, ly))
9943 if (button_status) /* if (gi->state == GD_BUTTON_PRESSED) */
9945 if (gi->event.type == GD_EVENT_PRESSED)
9951 switch (actual_drawing_function)
9953 case GADGET_ID_SINGLE_ITEMS:
9954 text = "Drawing single items";
9956 case GADGET_ID_CONNECTED_ITEMS:
9957 text = "Drawing connected items";
9959 case GADGET_ID_LINE:
9960 text = "Drawing line";
9963 text = "Drawing arc";
9965 case GADGET_ID_TEXT:
9966 text = "Setting text cursor";
9968 case GADGET_ID_RECTANGLE:
9969 text = "Drawing rectangle";
9971 case GADGET_ID_FILLED_BOX:
9972 text = "Drawing filled box";
9974 case GADGET_ID_FLOOD_FILL:
9975 text = "Flood fill";
9977 case GADGET_ID_GRAB_BRUSH:
9978 text = "Grabbing brush";
9980 case GADGET_ID_PICK_ELEMENT:
9981 text = "Picking element";
9985 text = "Drawing position";
9989 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
9990 sprintf(infotext, "%s: %d, %d", text, lx, ly);
9992 sprintf(infotext, "%s: %d, %d", text,
9993 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
9995 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
9996 strncpy(infotext, getElementInfoText(Feld[lx][ly]), max_infotext_len);
9998 sprintf(infotext, "Level position: %d, %d", lx, ly);
10001 /* misuse this function to draw brush cursor, if needed */
10002 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
10004 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
10005 CopyBrushToCursor(sx, sy);
10007 DeleteBrushFromCursor();
10010 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
10012 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
10013 int element = drawingarea_info[type_id].value[pos];
10015 strncpy(infotext, getElementInfoText(element), max_infotext_len);
10019 if (id == GADGET_ID_CUSTOM_CONTENT)
10020 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
10021 else if (id == GADGET_ID_GROUP_CONTENT)
10022 sprintf(infotext, "group element position: %d", sx + 1);
10023 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
10024 id <= GADGET_ID_YAMYAM_CONTENT_7)
10025 sprintf(infotext, "content area %d position: %d, %d",
10026 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
10027 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
10028 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
10029 sprintf(infotext, "content area %d position: %d, %d",
10030 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
10031 else if (drawingarea_info[type_id].infotext != NULL)
10032 strcpy(infotext, drawingarea_info[type_id].infotext);
10035 infotext[max_infotext_len] = '\0';
10037 if (strlen(infotext) > 0)
10038 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, infotext);
10041 void RequestExitLevelEditor(boolean ask_if_level_has_changed)
10043 if (!ask_if_level_has_changed ||
10045 Request("Level has changed ! Exit without saving ?",
10046 REQ_ASK | REQ_STAY_OPEN))
10049 CloseDoor(DOOR_CLOSE_1);
10050 SetDoorState(DOOR_CLOSE_2);
10052 CloseDoor(DOOR_CLOSE_ALL);
10054 game_status = GAME_MODE_MAIN;
10059 CloseDoor(DOOR_CLOSE_1);
10060 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);