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_SETTINGS_XSTART (3 * MINI_TILEX / 2)
114 #define ED_SETTINGS_YSTART (MINI_TILEY * 10)
116 #define ED_XOFFSET_CHECKBOX (ED_CHECKBUTTON_XSIZE + \
117 2 * ED_GADGET_DISTANCE)
119 #define ED_SETTINGS_XOFFSET ED_XOFFSET_CHECKBOX
120 #define ED_SETTINGS_YOFFSET (3 * MINI_TILEY / 2)
122 #define ED_SETTINGS_XPOS(n) (ED_SETTINGS_XSTART + \
123 (n) * ED_SETTINGS_XOFFSET)
124 #define ED_SETTINGS_YPOS(n) (ED_SETTINGS_YSTART + \
125 (n) * ED_SETTINGS_YOFFSET)
127 #define ED_SETTINGS1_YPOS MINI_TILEY
128 #define ED_SETTINGS2_XPOS MINI_TILEX
129 #define ED_SETTINGS2_YPOS (ED_SETTINGS1_YPOS + 12 * TILEY - 2)
131 /* values for counter gadgets */
132 #define ED_COUNTER_YSTART (ED_SETTINGS1_YPOS + 2 * TILEY)
133 #define ED_COUNTER_YDISTANCE (3 * MINI_TILEY)
134 #define ED_COUNTER_YPOS(n) (ED_COUNTER_YSTART + \
135 (n) * ED_COUNTER_YDISTANCE)
136 #define ED_COUNTER2_YPOS(n) (ED_COUNTER_YSTART + \
137 (n) * ED_COUNTER_YDISTANCE - 2)
139 /* values for element content drawing areas */
140 #define ED_AREA_1X1_SETTINGS_XPOS(n) (ED_SETTINGS_XPOS(n))
141 #define ED_AREA_1X1_SETTINGS_YPOS(n) (ED_SETTINGS_YPOS(n) + \
144 #define ED_AREA_3X3_SETTINGS_XPOS(n) (ED_SETTINGS_XPOS(n))
145 #define ED_AREA_3X3_SETTINGS_YPOS(n) (ED_SETTINGS_YPOS(n) + \
146 ED_GADGET_DISTANCE - MINI_TILEY)
149 #define ED_AREA_YAMYAM_CONTENT_XPOS(n) (2 * MINI_TILEX + \
150 5 * ((n) % 4) * MINI_TILEX)
151 #define ED_AREA_YAMYAM_CONTENT_YPOS(n) (17 * MINI_TILEY + \
152 6 * ((n) / 4) * MINI_TILEY)
154 /* values for scrolling gadgets for drawing area */
155 #define ED_SCROLLBUTTON_XPOS 24
156 #define ED_SCROLLBUTTON_YPOS 0
157 #define ED_SCROLLBAR_XPOS 24
158 #define ED_SCROLLBAR_YPOS 64
160 #define ED_SCROLLBUTTON_XSIZE 16
161 #define ED_SCROLLBUTTON_YSIZE 16
163 #define ED_SCROLL_UP_XPOS (SXSIZE - ED_SCROLLBUTTON_XSIZE)
164 #define ED_SCROLL_UP_YPOS (0)
165 #define ED_SCROLL_DOWN_XPOS ED_SCROLL_UP_XPOS
166 #define ED_SCROLL_DOWN_YPOS (SYSIZE - 3 * ED_SCROLLBUTTON_YSIZE)
167 #define ED_SCROLL_LEFT_XPOS (0)
168 #define ED_SCROLL_LEFT_YPOS (SYSIZE - 2 * ED_SCROLLBUTTON_YSIZE)
169 #define ED_SCROLL_RIGHT_XPOS (SXSIZE - 2 * ED_SCROLLBUTTON_XSIZE)
170 #define ED_SCROLL_RIGHT_YPOS ED_SCROLL_LEFT_YPOS
171 #define ED_SCROLL_HORIZONTAL_XPOS (ED_SCROLL_LEFT_XPOS + \
172 ED_SCROLLBUTTON_XSIZE)
173 #define ED_SCROLL_HORIZONTAL_YPOS ED_SCROLL_LEFT_YPOS
174 #define ED_SCROLL_HORIZONTAL_XSIZE (SXSIZE - 3 * ED_SCROLLBUTTON_XSIZE)
175 #define ED_SCROLL_HORIZONTAL_YSIZE ED_SCROLLBUTTON_YSIZE
176 #define ED_SCROLL_VERTICAL_XPOS ED_SCROLL_UP_XPOS
177 #define ED_SCROLL_VERTICAL_YPOS (ED_SCROLL_UP_YPOS + \
178 ED_SCROLLBUTTON_YSIZE)
179 #define ED_SCROLL_VERTICAL_XSIZE ED_SCROLLBUTTON_XSIZE
180 #define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - 4 * ED_SCROLLBUTTON_YSIZE)
182 /* values for scrolling gadgets for element list */
183 #define ED_SCROLLBUTTON2_XPOS 50
184 #define ED_SCROLLBUTTON2_YPOS 0
185 #define ED_SCROLLBAR2_XPOS 50
186 #define ED_SCROLLBAR2_YPOS 20
188 #define ED_SCROLLBUTTON2_XSIZE 10
189 #define ED_SCROLLBUTTON2_YSIZE 10
191 #define ED_SCROLL2_UP_XPOS 85
192 #define ED_SCROLL2_UP_YPOS 30
193 #define ED_SCROLL2_DOWN_XPOS ED_SCROLL2_UP_XPOS
194 #define ED_SCROLL2_DOWN_YPOS (ED_SCROLL2_UP_YPOS + \
195 ED_ELEMENTLIST_BUTTONS_VERT * \
196 ED_ELEMENTLIST_YSIZE - \
197 ED_SCROLLBUTTON2_YSIZE)
198 #define ED_SCROLL2_VERTICAL_XPOS ED_SCROLL2_UP_XPOS
199 #define ED_SCROLL2_VERTICAL_YPOS (ED_SCROLL2_UP_YPOS + \
200 ED_SCROLLBUTTON2_YSIZE)
201 #define ED_SCROLL2_VERTICAL_XSIZE ED_SCROLLBUTTON2_XSIZE
202 #define ED_SCROLL2_VERTICAL_YSIZE (ED_ELEMENTLIST_BUTTONS_VERT * \
203 ED_ELEMENTLIST_YSIZE - \
204 2 * ED_SCROLLBUTTON2_YSIZE)
206 /* values for checkbutton gadgets */
207 #define ED_CHECKBUTTON_XSIZE ED_BUTTON_COUNT_XSIZE
208 #define ED_CHECKBUTTON_YSIZE ED_BUTTON_COUNT_YSIZE
209 #define ED_CHECKBUTTON_UNCHECKED_XPOS ED_BUTTON_MINUS_XPOS
210 #define ED_CHECKBUTTON_CHECKED_XPOS ED_BUTTON_PLUS_XPOS
211 #define ED_CHECKBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 22)
212 #define ED_RADIOBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 44)
213 #define ED_STICKYBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 66)
215 /* values for some special graphic buttons */
216 #define ED_COPY_CHANGE_PAGE_XPOS 25
217 #define ED_COPY_CHANGE_PAGE_YPOS 50
218 #define ED_PASTE_CHANGE_PAGE_XPOS 25
219 #define ED_PASTE_CHANGE_PAGE_YPOS 70
221 /* some values for text input, selectbox and counter gadgets */
222 #define ED_BUTTON_COUNT_YPOS 60
223 #define ED_BUTTON_COUNT_XSIZE 20
224 #define ED_BUTTON_COUNT_YSIZE 20
225 #define ED_WIN_COUNT_XPOS (2 + ED_BUTTON_COUNT_XSIZE + 2)
226 #define ED_WIN_COUNT_YPOS ED_BUTTON_COUNT_YPOS
227 #define ED_WIN_COUNT_XSIZE 52
228 #define ED_WIN_COUNT_YSIZE ED_BUTTON_COUNT_YSIZE
229 #define ED_WIN_COUNT2_XPOS 27
230 #define ED_WIN_COUNT2_YPOS 3
231 #define ED_WIN_COUNT2_XSIZE 46
232 #define ED_WIN_COUNT2_YSIZE ED_BUTTON_COUNT_YSIZE
234 #define ED_BUTTON_MINUS_XPOS 2
235 #define ED_BUTTON_MINUS_YPOS ED_BUTTON_COUNT_YPOS
236 #define ED_BUTTON_MINUS_XSIZE ED_BUTTON_COUNT_XSIZE
237 #define ED_BUTTON_MINUS_YSIZE ED_BUTTON_COUNT_YSIZE
238 #define ED_BUTTON_PLUS_XPOS (ED_WIN_COUNT_XPOS + \
239 ED_WIN_COUNT_XSIZE + 2)
240 #define ED_BUTTON_PLUS_YPOS ED_BUTTON_COUNT_YPOS
241 #define ED_BUTTON_PLUS_XSIZE ED_BUTTON_COUNT_XSIZE
242 #define ED_BUTTON_PLUS_YSIZE ED_BUTTON_COUNT_YSIZE
244 #define ED_SELECTBOX_XPOS ED_WIN_COUNT_XPOS
245 #define ED_SELECTBOX_YPOS (ED_WIN_COUNT_YPOS + \
246 2 + ED_WIN_COUNT_YSIZE)
247 #define ED_SELECTBOX_XSIZE ED_WIN_COUNT_XSIZE
248 #define ED_SELECTBOX_YSIZE ED_WIN_COUNT_YSIZE
250 #define ED_SELECTBOX_BUTTON_XSIZE 14
252 #define ED_TEXTBUTTON_XPOS ED_WIN_COUNT_XPOS
253 #define ED_TEXTBUTTON_YPOS (ED_WIN_COUNT_YPOS + \
254 4 * (2 + ED_WIN_COUNT_YSIZE))
255 #define ED_TEXTBUTTON_INACTIVE_YPOS ED_TEXTBUTTON_YPOS
257 #define ED_TEXTBUTTON_TAB_XPOS ED_WIN_COUNT_XPOS
258 #define ED_TEXTBUTTON_TAB_YPOS (ED_WIN_COUNT_YPOS + \
259 2 * (2 + ED_WIN_COUNT_YSIZE))
260 #define ED_TEXTBUTTON_TAB_INACTIVE_YPOS (ED_WIN_COUNT_YPOS + \
261 3 * (2 + ED_WIN_COUNT_YSIZE))
263 #define ED_TEXTBUTTON_XSIZE ED_WIN_COUNT_XSIZE
264 #define ED_TEXTBUTTON_YSIZE ED_WIN_COUNT_YSIZE
266 /* values for ClearEditorGadgetInfoText() and HandleGadgetInfoText() */
267 #define INFOTEXT_XPOS SX
268 #define INFOTEXT_YPOS (SY + SYSIZE - MINI_TILEX + 2)
269 #define INFOTEXT_XSIZE SXSIZE
270 #define INFOTEXT_YSIZE MINI_TILEX
274 -----------------------------------------------------------------------------
275 editor gadget definitions
276 -----------------------------------------------------------------------------
279 /* drawing toolbox buttons */
280 #define GADGET_ID_NONE -1
281 #define GADGET_ID_TOOLBOX_FIRST 0
283 #define GADGET_ID_SINGLE_ITEMS (GADGET_ID_TOOLBOX_FIRST + 0)
284 #define GADGET_ID_CONNECTED_ITEMS (GADGET_ID_TOOLBOX_FIRST + 1)
285 #define GADGET_ID_LINE (GADGET_ID_TOOLBOX_FIRST + 2)
286 #define GADGET_ID_ARC (GADGET_ID_TOOLBOX_FIRST + 3)
287 #define GADGET_ID_RECTANGLE (GADGET_ID_TOOLBOX_FIRST + 4)
288 #define GADGET_ID_FILLED_BOX (GADGET_ID_TOOLBOX_FIRST + 5)
289 #define GADGET_ID_WRAP_UP (GADGET_ID_TOOLBOX_FIRST + 6)
290 #define GADGET_ID_TEXT (GADGET_ID_TOOLBOX_FIRST + 7)
291 #define GADGET_ID_FLOOD_FILL (GADGET_ID_TOOLBOX_FIRST + 8)
292 #define GADGET_ID_WRAP_LEFT (GADGET_ID_TOOLBOX_FIRST + 9)
293 #define GADGET_ID_PROPERTIES (GADGET_ID_TOOLBOX_FIRST + 10)
294 #define GADGET_ID_WRAP_RIGHT (GADGET_ID_TOOLBOX_FIRST + 11)
295 #define GADGET_ID_RANDOM_PLACEMENT (GADGET_ID_TOOLBOX_FIRST + 12)
296 #define GADGET_ID_GRAB_BRUSH (GADGET_ID_TOOLBOX_FIRST + 13)
297 #define GADGET_ID_WRAP_DOWN (GADGET_ID_TOOLBOX_FIRST + 14)
298 #define GADGET_ID_PICK_ELEMENT (GADGET_ID_TOOLBOX_FIRST + 15)
300 #define GADGET_ID_UNDO (GADGET_ID_TOOLBOX_FIRST + 16)
301 #define GADGET_ID_INFO (GADGET_ID_TOOLBOX_FIRST + 17)
302 #define GADGET_ID_SAVE (GADGET_ID_TOOLBOX_FIRST + 18)
303 #define GADGET_ID_CLEAR (GADGET_ID_TOOLBOX_FIRST + 19)
304 #define GADGET_ID_TEST (GADGET_ID_TOOLBOX_FIRST + 20)
305 #define GADGET_ID_EXIT (GADGET_ID_TOOLBOX_FIRST + 21)
307 #define GADGET_ID_CUSTOM_COPY_FROM (GADGET_ID_TOOLBOX_FIRST + 22)
308 #define GADGET_ID_CUSTOM_COPY_TO (GADGET_ID_TOOLBOX_FIRST + 23)
309 #define GADGET_ID_CUSTOM_EXCHANGE (GADGET_ID_TOOLBOX_FIRST + 24)
310 #define GADGET_ID_CUSTOM_COPY (GADGET_ID_TOOLBOX_FIRST + 25)
311 #define GADGET_ID_CUSTOM_PASTE (GADGET_ID_TOOLBOX_FIRST + 26)
313 /* counter button identifiers */
314 #define GADGET_ID_COUNTER_FIRST (GADGET_ID_TOOLBOX_FIRST + 27)
316 #define GADGET_ID_SELECT_LEVEL_DOWN (GADGET_ID_COUNTER_FIRST + 0)
317 #define GADGET_ID_SELECT_LEVEL_TEXT (GADGET_ID_COUNTER_FIRST + 1)
318 #define GADGET_ID_SELECT_LEVEL_UP (GADGET_ID_COUNTER_FIRST + 2)
319 #define GADGET_ID_LEVEL_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 3)
320 #define GADGET_ID_LEVEL_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 4)
321 #define GADGET_ID_LEVEL_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 5)
322 #define GADGET_ID_LEVEL_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 6)
323 #define GADGET_ID_LEVEL_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 7)
324 #define GADGET_ID_LEVEL_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 8)
325 #define GADGET_ID_LEVEL_RANDOM_DOWN (GADGET_ID_COUNTER_FIRST + 9)
326 #define GADGET_ID_LEVEL_RANDOM_TEXT (GADGET_ID_COUNTER_FIRST + 10)
327 #define GADGET_ID_LEVEL_RANDOM_UP (GADGET_ID_COUNTER_FIRST + 11)
328 #define GADGET_ID_LEVEL_GEMSLIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 12)
329 #define GADGET_ID_LEVEL_GEMSLIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 13)
330 #define GADGET_ID_LEVEL_GEMSLIMIT_UP (GADGET_ID_COUNTER_FIRST + 14)
331 #define GADGET_ID_LEVEL_TIMELIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 15)
332 #define GADGET_ID_LEVEL_TIMELIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 16)
333 #define GADGET_ID_LEVEL_TIMELIMIT_UP (GADGET_ID_COUNTER_FIRST + 17)
334 #define GADGET_ID_LEVEL_TIMESCORE_DOWN (GADGET_ID_COUNTER_FIRST + 18)
335 #define GADGET_ID_LEVEL_TIMESCORE_TEXT (GADGET_ID_COUNTER_FIRST + 19)
336 #define GADGET_ID_LEVEL_TIMESCORE_UP (GADGET_ID_COUNTER_FIRST + 20)
337 #define GADGET_ID_ELEMENT_SCORE_DOWN (GADGET_ID_COUNTER_FIRST + 21)
338 #define GADGET_ID_ELEMENT_SCORE_TEXT (GADGET_ID_COUNTER_FIRST + 22)
339 #define GADGET_ID_ELEMENT_SCORE_UP (GADGET_ID_COUNTER_FIRST + 23)
340 #define GADGET_ID_ELEMENT_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 24)
341 #define GADGET_ID_ELEMENT_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 25)
342 #define GADGET_ID_ELEMENT_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 26)
343 #define GADGET_ID_ENVELOPE_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 27)
344 #define GADGET_ID_ENVELOPE_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 28)
345 #define GADGET_ID_ENVELOPE_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 29)
346 #define GADGET_ID_ENVELOPE_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 30)
347 #define GADGET_ID_ENVELOPE_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 31)
348 #define GADGET_ID_ENVELOPE_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 32)
349 #define GADGET_ID_CUSTOM_SCORE_DOWN (GADGET_ID_COUNTER_FIRST + 33)
350 #define GADGET_ID_CUSTOM_SCORE_TEXT (GADGET_ID_COUNTER_FIRST + 34)
351 #define GADGET_ID_CUSTOM_SCORE_UP (GADGET_ID_COUNTER_FIRST + 35)
352 #define GADGET_ID_CUSTOM_GEMCOUNT_DOWN (GADGET_ID_COUNTER_FIRST + 36)
353 #define GADGET_ID_CUSTOM_GEMCOUNT_TEXT (GADGET_ID_COUNTER_FIRST + 37)
354 #define GADGET_ID_CUSTOM_GEMCOUNT_UP (GADGET_ID_COUNTER_FIRST + 38)
355 #define GADGET_ID_PUSH_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 39)
356 #define GADGET_ID_PUSH_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 40)
357 #define GADGET_ID_PUSH_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 41)
358 #define GADGET_ID_PUSH_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 42)
359 #define GADGET_ID_PUSH_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 43)
360 #define GADGET_ID_PUSH_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 44)
361 #define GADGET_ID_DROP_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 45)
362 #define GADGET_ID_DROP_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 46)
363 #define GADGET_ID_DROP_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 47)
364 #define GADGET_ID_DROP_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 48)
365 #define GADGET_ID_DROP_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 49)
366 #define GADGET_ID_DROP_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 50)
367 #define GADGET_ID_MOVE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 51)
368 #define GADGET_ID_MOVE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 52)
369 #define GADGET_ID_MOVE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 53)
370 #define GADGET_ID_MOVE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 54)
371 #define GADGET_ID_MOVE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 55)
372 #define GADGET_ID_MOVE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 56)
373 #define GADGET_ID_EXPLOSION_DELAY_DOWN (GADGET_ID_COUNTER_FIRST + 57)
374 #define GADGET_ID_EXPLOSION_DELAY_TEXT (GADGET_ID_COUNTER_FIRST + 58)
375 #define GADGET_ID_EXPLOSION_DELAY_UP (GADGET_ID_COUNTER_FIRST + 59)
376 #define GADGET_ID_IGNITION_DELAY_DOWN (GADGET_ID_COUNTER_FIRST + 60)
377 #define GADGET_ID_IGNITION_DELAY_TEXT (GADGET_ID_COUNTER_FIRST + 61)
378 #define GADGET_ID_IGNITION_DELAY_UP (GADGET_ID_COUNTER_FIRST + 62)
379 #define GADGET_ID_CHANGE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 63)
380 #define GADGET_ID_CHANGE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 64)
381 #define GADGET_ID_CHANGE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 65)
382 #define GADGET_ID_CHANGE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 66)
383 #define GADGET_ID_CHANGE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 67)
384 #define GADGET_ID_CHANGE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 68)
385 #define GADGET_ID_CHANGE_CONT_RND_DOWN (GADGET_ID_COUNTER_FIRST + 69)
386 #define GADGET_ID_CHANGE_CONT_RND_TEXT (GADGET_ID_COUNTER_FIRST + 70)
387 #define GADGET_ID_CHANGE_CONT_RND_UP (GADGET_ID_COUNTER_FIRST + 71)
388 #define GADGET_ID_GROUP_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 72)
389 #define GADGET_ID_GROUP_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 73)
390 #define GADGET_ID_GROUP_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 74)
392 /* drawing area identifiers */
393 #define GADGET_ID_DRAWING_AREA_FIRST (GADGET_ID_COUNTER_FIRST + 75)
395 #define GADGET_ID_DRAWING_LEVEL (GADGET_ID_DRAWING_AREA_FIRST + 0)
396 #define GADGET_ID_ELEMENT_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 1)
397 #define GADGET_ID_ELEMENT_CONTENT_1 (GADGET_ID_DRAWING_AREA_FIRST + 2)
398 #define GADGET_ID_ELEMENT_CONTENT_2 (GADGET_ID_DRAWING_AREA_FIRST + 3)
399 #define GADGET_ID_ELEMENT_CONTENT_3 (GADGET_ID_DRAWING_AREA_FIRST + 4)
400 #define GADGET_ID_ELEMENT_CONTENT_4 (GADGET_ID_DRAWING_AREA_FIRST + 5)
401 #define GADGET_ID_ELEMENT_CONTENT_5 (GADGET_ID_DRAWING_AREA_FIRST + 6)
402 #define GADGET_ID_ELEMENT_CONTENT_6 (GADGET_ID_DRAWING_AREA_FIRST + 7)
403 #define GADGET_ID_ELEMENT_CONTENT_7 (GADGET_ID_DRAWING_AREA_FIRST + 8)
404 #define GADGET_ID_AMOEBA_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 9)
405 #define GADGET_ID_CUSTOM_GRAPHIC (GADGET_ID_DRAWING_AREA_FIRST + 10)
406 #define GADGET_ID_CUSTOM_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 11)
407 #define GADGET_ID_CUSTOM_MOVE_ENTER (GADGET_ID_DRAWING_AREA_FIRST + 12)
408 #define GADGET_ID_CUSTOM_MOVE_LEAVE (GADGET_ID_DRAWING_AREA_FIRST + 13)
409 #define GADGET_ID_CUSTOM_CHANGE_TARGET (GADGET_ID_DRAWING_AREA_FIRST + 14)
410 #define GADGET_ID_CUSTOM_CHANGE_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 15)
411 #define GADGET_ID_CUSTOM_CHANGE_TRIGGER (GADGET_ID_DRAWING_AREA_FIRST + 16)
412 #define GADGET_ID_GROUP_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 17)
413 #define GADGET_ID_RANDOM_BACKGROUND (GADGET_ID_DRAWING_AREA_FIRST + 18)
415 /* text input identifiers */
416 #define GADGET_ID_TEXT_INPUT_FIRST (GADGET_ID_DRAWING_AREA_FIRST + 19)
418 #define GADGET_ID_LEVEL_NAME (GADGET_ID_TEXT_INPUT_FIRST + 0)
419 #define GADGET_ID_LEVEL_AUTHOR (GADGET_ID_TEXT_INPUT_FIRST + 1)
420 #define GADGET_ID_ELEMENT_NAME (GADGET_ID_TEXT_INPUT_FIRST + 2)
422 /* text area identifiers */
423 #define GADGET_ID_TEXT_AREA_FIRST (GADGET_ID_TEXT_INPUT_FIRST + 3)
425 #define GADGET_ID_ENVELOPE_INFO (GADGET_ID_TEXT_AREA_FIRST + 0)
427 /* selectbox identifiers */
428 #define GADGET_ID_SELECTBOX_FIRST (GADGET_ID_TEXT_AREA_FIRST + 1)
430 #define GADGET_ID_TIME_OR_STEPS (GADGET_ID_SELECTBOX_FIRST + 0)
431 #define GADGET_ID_CUSTOM_WALK_TO_ACTION (GADGET_ID_SELECTBOX_FIRST + 1)
432 #define GADGET_ID_CUSTOM_EXPLOSION_TYPE (GADGET_ID_SELECTBOX_FIRST + 2)
433 #define GADGET_ID_CUSTOM_DEADLINESS (GADGET_ID_SELECTBOX_FIRST + 3)
434 #define GADGET_ID_CUSTOM_MOVE_PATTERN (GADGET_ID_SELECTBOX_FIRST + 4)
435 #define GADGET_ID_CUSTOM_MOVE_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 5)
436 #define GADGET_ID_CUSTOM_MOVE_STEPSIZE (GADGET_ID_SELECTBOX_FIRST + 6)
437 #define GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE (GADGET_ID_SELECTBOX_FIRST + 7)
438 #define GADGET_ID_CUSTOM_SMASH_TARGETS (GADGET_ID_SELECTBOX_FIRST + 8)
439 #define GADGET_ID_CUSTOM_SLIPPERY_TYPE (GADGET_ID_SELECTBOX_FIRST + 9)
440 #define GADGET_ID_CUSTOM_ACCESS_TYPE (GADGET_ID_SELECTBOX_FIRST + 10)
441 #define GADGET_ID_CUSTOM_ACCESS_LAYER (GADGET_ID_SELECTBOX_FIRST + 11)
442 #define GADGET_ID_CUSTOM_ACCESS_PROTECTED (GADGET_ID_SELECTBOX_FIRST + 12)
443 #define GADGET_ID_CUSTOM_ACCESS_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 13)
444 #define GADGET_ID_CHANGE_TIME_UNITS (GADGET_ID_SELECTBOX_FIRST + 14)
445 #define GADGET_ID_CHANGE_DIRECT_ACTION (GADGET_ID_SELECTBOX_FIRST + 15)
446 #define GADGET_ID_CHANGE_OTHER_ACTION (GADGET_ID_SELECTBOX_FIRST + 16)
447 #define GADGET_ID_CHANGE_SIDE (GADGET_ID_SELECTBOX_FIRST + 17)
448 #define GADGET_ID_CHANGE_PLAYER (GADGET_ID_SELECTBOX_FIRST + 18)
449 #define GADGET_ID_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 19)
450 #define GADGET_ID_CHANGE_REPLACE_WHEN (GADGET_ID_SELECTBOX_FIRST + 20)
451 #define GADGET_ID_SELECT_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 21)
452 #define GADGET_ID_GROUP_CHOICE_MODE (GADGET_ID_SELECTBOX_FIRST + 22)
454 /* textbutton identifiers */
455 #define GADGET_ID_TEXTBUTTON_FIRST (GADGET_ID_SELECTBOX_FIRST + 23)
457 #define GADGET_ID_PROPERTIES_INFO (GADGET_ID_TEXTBUTTON_FIRST + 0)
458 #define GADGET_ID_PROPERTIES_CONFIG (GADGET_ID_TEXTBUTTON_FIRST + 1)
459 #define GADGET_ID_PROPERTIES_CONFIG_1 (GADGET_ID_TEXTBUTTON_FIRST + 2)
460 #define GADGET_ID_PROPERTIES_CONFIG_2 (GADGET_ID_TEXTBUTTON_FIRST + 3)
461 #define GADGET_ID_PROPERTIES_CHANGE (GADGET_ID_TEXTBUTTON_FIRST + 4)
462 #define GADGET_ID_SAVE_AS_TEMPLATE (GADGET_ID_TEXTBUTTON_FIRST + 5)
463 #define GADGET_ID_ADD_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 6)
464 #define GADGET_ID_DEL_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 7)
466 /* graphicbutton identifiers */
467 #define GADGET_ID_GRAPHICBUTTON_FIRST (GADGET_ID_TEXTBUTTON_FIRST + 8)
469 #define GADGET_ID_PREV_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 0)
470 #define GADGET_ID_NEXT_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 1)
471 #define GADGET_ID_COPY_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 2)
472 #define GADGET_ID_PASTE_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 3)
474 /* gadgets for scrolling of drawing area */
475 #define GADGET_ID_SCROLLING_FIRST (GADGET_ID_GRAPHICBUTTON_FIRST + 4)
477 #define GADGET_ID_SCROLL_UP (GADGET_ID_SCROLLING_FIRST + 0)
478 #define GADGET_ID_SCROLL_DOWN (GADGET_ID_SCROLLING_FIRST + 1)
479 #define GADGET_ID_SCROLL_LEFT (GADGET_ID_SCROLLING_FIRST + 2)
480 #define GADGET_ID_SCROLL_RIGHT (GADGET_ID_SCROLLING_FIRST + 3)
481 #define GADGET_ID_SCROLL_HORIZONTAL (GADGET_ID_SCROLLING_FIRST + 4)
482 #define GADGET_ID_SCROLL_VERTICAL (GADGET_ID_SCROLLING_FIRST + 5)
484 /* gadgets for scrolling element list */
485 #define GADGET_ID_SCROLLING_LIST_FIRST (GADGET_ID_SCROLLING_FIRST + 6)
487 #define GADGET_ID_SCROLL_LIST_UP (GADGET_ID_SCROLLING_LIST_FIRST + 0)
488 #define GADGET_ID_SCROLL_LIST_DOWN (GADGET_ID_SCROLLING_LIST_FIRST + 1)
489 #define GADGET_ID_SCROLL_LIST_VERTICAL (GADGET_ID_SCROLLING_LIST_FIRST + 2)
491 /* checkbuttons/radiobuttons for level/element properties */
492 #define GADGET_ID_CHECKBUTTON_FIRST (GADGET_ID_SCROLLING_LIST_FIRST + 3)
494 #define GADGET_ID_RANDOM_PERCENTAGE (GADGET_ID_CHECKBUTTON_FIRST + 0)
495 #define GADGET_ID_RANDOM_QUANTITY (GADGET_ID_CHECKBUTTON_FIRST + 1)
496 #define GADGET_ID_RANDOM_RESTRICTED (GADGET_ID_CHECKBUTTON_FIRST + 2)
497 #define GADGET_ID_DOUBLE_SPEED (GADGET_ID_CHECKBUTTON_FIRST + 3)
498 #define GADGET_ID_GRAVITY (GADGET_ID_CHECKBUTTON_FIRST + 4)
499 #define GADGET_ID_STICK_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 5)
500 #define GADGET_ID_EM_SLIPPERY_GEMS (GADGET_ID_CHECKBUTTON_FIRST + 6)
501 #define GADGET_ID_USE_SPRING_BUG (GADGET_ID_CHECKBUTTON_FIRST + 7)
502 #define GADGET_ID_GROW_INTO_DIGGABLE (GADGET_ID_CHECKBUTTON_FIRST + 8)
503 #define GADGET_ID_BLOCK_LAST_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 9)
504 #define GADGET_ID_SP_BLOCK_LAST_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 10)
505 #define GADGET_ID_INSTANT_RELOCATION (GADGET_ID_CHECKBUTTON_FIRST + 11)
506 #define GADGET_ID_CAN_PASS_TO_WALKABLE (GADGET_ID_CHECKBUTTON_FIRST + 12)
507 #define GADGET_ID_CAN_FALL_INTO_ACID (GADGET_ID_CHECKBUTTON_FIRST + 13)
508 #define GADGET_ID_CAN_MOVE_INTO_ACID (GADGET_ID_CHECKBUTTON_FIRST + 14)
509 #define GADGET_ID_DONT_COLLIDE_WITH (GADGET_ID_CHECKBUTTON_FIRST + 15)
510 #define GADGET_ID_CUSTOM_INDESTRUCTIBLE (GADGET_ID_CHECKBUTTON_FIRST + 16)
511 #define GADGET_ID_CUSTOM_CAN_EXPLODE (GADGET_ID_CHECKBUTTON_FIRST + 17)
512 #define GADGET_ID_CUSTOM_EXPLODE_FIRE (GADGET_ID_CHECKBUTTON_FIRST + 18)
513 #define GADGET_ID_CUSTOM_EXPLODE_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 19)
514 #define GADGET_ID_CUSTOM_EXPLODE_IMPACT (GADGET_ID_CHECKBUTTON_FIRST + 20)
515 #define GADGET_ID_CUSTOM_WALK_TO_OBJECT (GADGET_ID_CHECKBUTTON_FIRST + 21)
516 #define GADGET_ID_CUSTOM_DEADLY (GADGET_ID_CHECKBUTTON_FIRST + 22)
517 #define GADGET_ID_CUSTOM_CAN_MOVE (GADGET_ID_CHECKBUTTON_FIRST + 23)
518 #define GADGET_ID_CUSTOM_CAN_FALL (GADGET_ID_CHECKBUTTON_FIRST + 24)
519 #define GADGET_ID_CUSTOM_CAN_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 25)
520 #define GADGET_ID_CUSTOM_SLIPPERY (GADGET_ID_CHECKBUTTON_FIRST + 26)
521 #define GADGET_ID_CUSTOM_ACCESSIBLE (GADGET_ID_CHECKBUTTON_FIRST + 27)
522 #define GADGET_ID_CUSTOM_GRAV_REACHABLE (GADGET_ID_CHECKBUTTON_FIRST + 28)
523 #define GADGET_ID_CUSTOM_USE_GRAPHIC (GADGET_ID_CHECKBUTTON_FIRST + 29)
524 #define GADGET_ID_CUSTOM_USE_TEMPLATE (GADGET_ID_CHECKBUTTON_FIRST + 30)
525 #define GADGET_ID_CUSTOM_CAN_CHANGE (GADGET_ID_CHECKBUTTON_FIRST + 31)
526 #define GADGET_ID_CHANGE_USE_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 32)
527 #define GADGET_ID_CHANGE_USE_EXPLOSION (GADGET_ID_CHECKBUTTON_FIRST + 33)
528 #define GADGET_ID_CHANGE_ONLY_COMPLETE (GADGET_ID_CHECKBUTTON_FIRST + 34)
529 #define GADGET_ID_CHANGE_USE_RANDOM (GADGET_ID_CHECKBUTTON_FIRST + 35)
530 #define GADGET_ID_CHANGE_DELAY (GADGET_ID_CHECKBUTTON_FIRST + 36)
531 #define GADGET_ID_CHANGE_BY_DIRECT_ACT (GADGET_ID_CHECKBUTTON_FIRST + 37)
532 #define GADGET_ID_CHANGE_BY_OTHER_ACT (GADGET_ID_CHECKBUTTON_FIRST + 38)
534 /* gadgets for buttons in element list */
535 #define GADGET_ID_ELEMENTLIST_FIRST (GADGET_ID_CHECKBUTTON_FIRST + 39)
536 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
537 ED_NUM_ELEMENTLIST_BUTTONS - 1)
539 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
541 /* radio button numbers */
542 #define RADIO_NR_NONE 0
543 #define RADIO_NR_DRAWING_TOOLBOX 1
544 #define RADIO_NR_RANDOM_ELEMENTS 2
546 /* values for counter gadgets */
547 #define ED_COUNTER_ID_SELECT_LEVEL 0
548 #define ED_COUNTER_ID_LEVEL_XSIZE 1
549 #define ED_COUNTER_ID_LEVEL_YSIZE 2
550 #define ED_COUNTER_ID_LEVEL_GEMSLIMIT 3
551 #define ED_COUNTER_ID_LEVEL_TIMELIMIT 4
552 #define ED_COUNTER_ID_LEVEL_TIMESCORE 5
553 #define ED_COUNTER_ID_LEVEL_RANDOM 6
554 #define ED_COUNTER_ID_ELEMENT_SCORE 7
555 #define ED_COUNTER_ID_ELEMENT_CONTENT 8
556 #define ED_COUNTER_ID_ENVELOPE_XSIZE 9
557 #define ED_COUNTER_ID_ENVELOPE_YSIZE 10
558 #define ED_COUNTER_ID_CUSTOM_SCORE 11
559 #define ED_COUNTER_ID_CUSTOM_GEMCOUNT 12
560 #define ED_COUNTER_ID_PUSH_DELAY_FIX 13
561 #define ED_COUNTER_ID_PUSH_DELAY_RND 14
562 #define ED_COUNTER_ID_DROP_DELAY_FIX 15
563 #define ED_COUNTER_ID_DROP_DELAY_RND 16
564 #define ED_COUNTER_ID_MOVE_DELAY_FIX 17
565 #define ED_COUNTER_ID_MOVE_DELAY_RND 18
566 #define ED_COUNTER_ID_EXPLOSION_DELAY 19
567 #define ED_COUNTER_ID_IGNITION_DELAY 20
568 #define ED_COUNTER_ID_GROUP_CONTENT 21
569 #define ED_COUNTER_ID_CHANGE_DELAY_FIX 22
570 #define ED_COUNTER_ID_CHANGE_DELAY_RND 23
571 #define ED_COUNTER_ID_CHANGE_CONT_RND 24
573 #define ED_NUM_COUNTERBUTTONS 25
575 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
576 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM
578 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
579 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
580 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
581 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
582 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
583 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
585 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
586 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
588 /* values for scrollbutton gadgets */
589 #define ED_SCROLLBUTTON_ID_AREA_UP 0
590 #define ED_SCROLLBUTTON_ID_AREA_DOWN 1
591 #define ED_SCROLLBUTTON_ID_AREA_LEFT 2
592 #define ED_SCROLLBUTTON_ID_AREA_RIGHT 3
593 #define ED_SCROLLBUTTON_ID_LIST_UP 4
594 #define ED_SCROLLBUTTON_ID_LIST_DOWN 5
596 #define ED_NUM_SCROLLBUTTONS 6
598 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
599 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
601 /* values for scrollbar gadgets */
602 #define ED_SCROLLBAR_ID_AREA_HORIZONTAL 0
603 #define ED_SCROLLBAR_ID_AREA_VERTICAL 1
604 #define ED_SCROLLBAR_ID_LIST_VERTICAL 2
606 #define ED_NUM_SCROLLBARS 3
608 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
609 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
611 /* values for text input gadgets */
612 #define ED_TEXTINPUT_ID_LEVEL_NAME 0
613 #define ED_TEXTINPUT_ID_LEVEL_AUTHOR 1
614 #define ED_TEXTINPUT_ID_ELEMENT_NAME 2
616 #define ED_NUM_TEXTINPUT 3
618 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
619 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
621 /* values for text area gadgets */
622 #define ED_TEXTAREA_ID_ENVELOPE_INFO 0
624 #define ED_NUM_TEXTAREAS 1
626 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
627 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
629 /* values for selectbox gadgets */
630 #define ED_SELECTBOX_ID_TIME_OR_STEPS 0
631 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE 1
632 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER 2
633 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED 3
634 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION 4
635 #define ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION 5
636 #define ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN 6
637 #define ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION 7
638 #define ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE 8
639 #define ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE 9
640 #define ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS 10
641 #define ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE 11
642 #define ED_SELECTBOX_ID_CUSTOM_DEADLINESS 12
643 #define ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE 13
644 #define ED_SELECTBOX_ID_CHANGE_TIME_UNITS 14
645 #define ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION 15
646 #define ED_SELECTBOX_ID_CHANGE_OTHER_ACTION 16
647 #define ED_SELECTBOX_ID_CHANGE_SIDE 17
648 #define ED_SELECTBOX_ID_CHANGE_PLAYER 18
649 #define ED_SELECTBOX_ID_CHANGE_PAGE 19
650 #define ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN 20
651 #define ED_SELECTBOX_ID_SELECT_CHANGE_PAGE 21
652 #define ED_SELECTBOX_ID_GROUP_CHOICE_MODE 22
654 #define ED_NUM_SELECTBOX 23
656 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
657 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_TIME_OR_STEPS
659 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
660 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
661 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
662 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
663 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
664 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
666 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
667 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
669 /* values for textbutton gadgets */
670 #define ED_TEXTBUTTON_ID_PROPERTIES_INFO 0
671 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG 1
672 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1 2
673 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2 3
674 #define ED_TEXTBUTTON_ID_PROPERTIES_CHANGE 4
675 #define ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE 5
676 #define ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE 6
677 #define ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE 7
679 #define ED_NUM_TEXTBUTTONS 8
681 #define ED_TEXTBUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
682 #define ED_TEXTBUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
684 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
685 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
687 /* values for graphicbutton gadgets */
688 #define ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE 0
689 #define ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE 1
690 #define ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE 2
691 #define ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE 3
693 #define ED_NUM_GRAPHICBUTTONS 4
695 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
696 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
698 /* values for checkbutton gadgets */
699 #define ED_CHECKBUTTON_ID_DOUBLE_SPEED 0
700 #define ED_CHECKBUTTON_ID_GRAVITY 1
701 #define ED_CHECKBUTTON_ID_RANDOM_RESTRICTED 2
702 #define ED_CHECKBUTTON_ID_STICK_ELEMENT 3
703 #define ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS 4
704 #define ED_CHECKBUTTON_ID_USE_SPRING_BUG 5
705 #define ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE 6
706 #define ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD 7
707 #define ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD 8
708 #define ED_CHECKBUTTON_ID_INSTANT_RELOCATION 9
709 #define ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE 10
710 #define ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID 11
711 #define ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID 12
712 #define ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH 13
713 #define ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC 14
714 #define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE 15
715 #define ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE 16
716 #define ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE 17
717 #define ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT 18
718 #define ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE 19
719 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE 20
720 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL 21
721 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH 22
722 #define ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY 23
723 #define ED_CHECKBUTTON_ID_CUSTOM_DEADLY 24
724 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE 25
725 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE 26
726 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH 27
727 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT 28
728 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE 29
729 #define ED_CHECKBUTTON_ID_CHANGE_DELAY 30
730 #define ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT 31
731 #define ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT 32
732 #define ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION 33
733 #define ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT 34
734 #define ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE 35
735 #define ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM 36
737 #define ED_NUM_CHECKBUTTONS 37
739 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_DOUBLE_SPEED
740 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
742 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
743 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
744 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
745 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
746 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
747 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
749 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
750 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM
752 /* values for radiobutton gadgets */
753 #define ED_RADIOBUTTON_ID_PERCENTAGE 0
754 #define ED_RADIOBUTTON_ID_QUANTITY 1
756 #define ED_NUM_RADIOBUTTONS 2
758 #define ED_RADIOBUTTON_ID_LEVEL_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
759 #define ED_RADIOBUTTON_ID_LEVEL_LAST ED_RADIOBUTTON_ID_QUANTITY
761 /* values for drawing area gadgets */
762 #define ED_DRAWING_ID_DRAWING_LEVEL 0
763 #define ED_DRAWING_ID_ELEMENT_CONTENT_0 1
764 #define ED_DRAWING_ID_ELEMENT_CONTENT_1 2
765 #define ED_DRAWING_ID_ELEMENT_CONTENT_2 3
766 #define ED_DRAWING_ID_ELEMENT_CONTENT_3 4
767 #define ED_DRAWING_ID_ELEMENT_CONTENT_4 5
768 #define ED_DRAWING_ID_ELEMENT_CONTENT_5 6
769 #define ED_DRAWING_ID_ELEMENT_CONTENT_6 7
770 #define ED_DRAWING_ID_ELEMENT_CONTENT_7 8
771 #define ED_DRAWING_ID_AMOEBA_CONTENT 9
772 #define ED_DRAWING_ID_CUSTOM_GRAPHIC 10
773 #define ED_DRAWING_ID_CUSTOM_CONTENT 11
774 #define ED_DRAWING_ID_CUSTOM_MOVE_ENTER 12
775 #define ED_DRAWING_ID_CUSTOM_MOVE_LEAVE 13
776 #define ED_DRAWING_ID_CUSTOM_CHANGE_TARGET 14
777 #define ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT 15
778 #define ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER 16
779 #define ED_DRAWING_ID_GROUP_CONTENT 17
780 #define ED_DRAWING_ID_RANDOM_BACKGROUND 18
782 #define ED_NUM_DRAWING_AREAS 19
786 -----------------------------------------------------------------------------
787 some internally used definitions
788 -----------------------------------------------------------------------------
791 /* values for CopyLevelToUndoBuffer() */
792 #define UNDO_IMMEDIATE 0
793 #define UNDO_ACCUMULATE 1
795 /* values for scrollbars */
796 #define ED_SCROLL_NO 0
797 #define ED_SCROLL_LEFT 1
798 #define ED_SCROLL_RIGHT 2
799 #define ED_SCROLL_UP 4
800 #define ED_SCROLL_DOWN 8
802 /* screens in the level editor */
803 #define ED_MODE_DRAWING 0
804 #define ED_MODE_INFO 1
805 #define ED_MODE_PROPERTIES 2
807 /* sub-screens in the element properties section */
808 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
809 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
810 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
811 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
812 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
814 /* how many steps can be cancelled */
815 #define NUM_UNDO_STEPS (10 + 1)
817 /* values for elements with score for certain actions */
819 #define MAX_SCORE 255
821 /* values for elements with count for collecting */
822 #define MIN_COLLECT_COUNT 0
823 #define MAX_COLLECT_COUNT 100
825 /* values for random placement */
826 #define RANDOM_USE_PERCENTAGE 0
827 #define RANDOM_USE_QUANTITY 1
829 /* maximal size of level editor drawing area */
830 #define MAX_ED_FIELDX (2 * SCR_FIELDX)
831 #define MAX_ED_FIELDY (2 * SCR_FIELDY - 1)
835 -----------------------------------------------------------------------------
836 some internally used data structure definitions
837 -----------------------------------------------------------------------------
844 } control_info[ED_NUM_CTRL_BUTTONS] =
846 { 's', "draw single items" },
847 { 'd', "draw connected items" },
848 { 'l', "draw lines" },
849 { 'a', "draw arcs" },
850 { 'r', "draw outline rectangles" },
851 { 'R', "draw filled rectangles" },
852 { '\0', "wrap (rotate) level up" },
853 { 't', "enter text elements" },
854 { 'f', "flood fill" },
855 { '\0', "wrap (rotate) level left" },
856 { '?', "properties of drawing element" },
857 { '\0', "wrap (rotate) level right" },
858 { '\0', "random element placement" },
859 { 'b', "grab brush" },
860 { '\0', "wrap (rotate) level down" },
861 { ',', "pick drawing element" },
863 { 'U', "undo last operation" },
864 { 'I', "level properties" },
865 { 'S', "save level" },
866 { 'C', "clear level" },
867 { 'T', "test level" },
868 { 'E', "exit level editor" },
870 { '\0', "copy settings from other element" },
871 { '\0', "copy settings to other element" },
872 { '\0', "exchange element with other element" },
874 { '\0', "copy settings from this element" },
875 { '\0', "paste settings to this element" },
878 static int random_placement_value = 10;
879 static int random_placement_method = RANDOM_USE_QUANTITY;
880 static int random_placement_background_element = EL_SAND;
881 static boolean random_placement_background_restricted = FALSE;
882 static boolean stick_element_properties_window = FALSE;
883 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
884 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
885 static struct ElementChangeInfo custom_element_change;
886 static struct ElementGroupInfo group_element_info;
887 static struct ElementInfo custom_element;
892 int min_value, max_value;
893 int gadget_id_down, gadget_id_up;
897 char *text_above, *text_left, *text_right;
898 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
900 /* ---------- level and editor settings ---------------------------------- */
903 DX + 5 - SX, DY + 3 - SY,
905 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
906 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
911 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(2),
912 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
913 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
914 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
916 "playfield size:", NULL, "width",
919 -1, ED_COUNTER_YPOS(2),
920 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
921 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
922 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
927 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(3),
929 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
930 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
932 "number of gems to collect:", NULL, NULL
935 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(4),
937 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
938 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
940 "time or step limit to solve level:", NULL, NULL
943 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(5),
945 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
946 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
947 &level.score[SC_TIME_BONUS],
948 "score for each 10 sec/steps left:", NULL, NULL
951 ED_SETTINGS_XPOS(0), ED_COUNTER2_YPOS(8),
953 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
954 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
955 &random_placement_value,
956 "random element placement:", NULL, "in"
959 /* ---------- element settings: configure (various elements) ------------- */
962 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(0),
963 MIN_SCORE, MAX_SCORE,
964 GADGET_ID_ELEMENT_SCORE_DOWN, GADGET_ID_ELEMENT_SCORE_UP,
965 GADGET_ID_ELEMENT_SCORE_TEXT, GADGET_ID_NONE,
966 NULL, /* will be set when used */
970 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(3),
971 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
972 GADGET_ID_ELEMENT_CONTENT_DOWN, GADGET_ID_ELEMENT_CONTENT_UP,
973 GADGET_ID_ELEMENT_CONTENT_TEXT, GADGET_ID_NONE,
974 &level.num_yamyam_contents,
975 NULL, NULL, "number of content areas"
978 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(0),
979 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
980 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
981 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
986 -1, ED_SETTINGS_YPOS(0),
987 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
988 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
989 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
994 /* ---------- element settings: configure 1 (custom elements) ------------ */
997 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(6),
998 MIN_SCORE, MAX_SCORE,
999 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1000 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1001 &custom_element.collect_score,
1005 -1, ED_SETTINGS_YPOS(6),
1006 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1007 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1008 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1009 &custom_element.collect_count,
1013 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(7),
1015 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1016 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1017 &custom_element.push_delay_fixed,
1018 NULL, "push delay", NULL
1021 -1, ED_SETTINGS_YPOS(7),
1023 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1024 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1025 &custom_element.push_delay_random,
1026 NULL, "+random", NULL
1029 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(8),
1031 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1032 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1033 &custom_element.drop_delay_fixed,
1034 NULL, "drop delay", NULL
1037 -1, ED_SETTINGS_YPOS(8),
1039 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1040 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1041 &custom_element.drop_delay_random,
1042 NULL, "+random", NULL
1045 /* ---------- element settings: configure 2 (custom elements) ------------ */
1048 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(5),
1050 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1051 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1052 &custom_element.move_delay_fixed,
1053 NULL, "move delay", NULL
1056 -1, ED_SETTINGS_YPOS(5),
1058 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1059 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1060 &custom_element.move_delay_random,
1061 NULL, "+random", NULL
1064 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(12),
1066 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1067 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1068 &custom_element.explosion_delay,
1069 NULL, "explosion delay", NULL
1072 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(13),
1074 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1075 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1076 &custom_element.ignition_delay,
1077 NULL, "ignition delay", "(by fire)"
1080 /* ---------- element settings: configure (group elements) --------------- */
1083 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(5),
1084 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1085 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1086 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1087 &group_element_info.num_elements,
1088 NULL, NULL, "number of elements in group"
1091 /* ---------- element settings: advanced (custom elements) --------------- */
1094 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(2),
1096 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1097 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1098 &custom_element_change.delay_fixed,
1099 NULL, "delay", NULL,
1102 -1, ED_SETTINGS_YPOS(2),
1104 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1105 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1106 &custom_element_change.delay_random,
1107 NULL, "+random", NULL
1110 ED_SETTINGS_XPOS(3), ED_SETTINGS_YPOS(12),
1112 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1113 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1114 &custom_element_change.random_percentage,
1115 NULL, "use random replace:", "%"
1125 char *text_above, *infotext;
1126 } textinput_info[ED_NUM_TEXTINPUT] =
1129 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(0),
1130 GADGET_ID_LEVEL_NAME,
1136 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(1),
1137 GADGET_ID_LEVEL_AUTHOR,
1138 MAX_LEVEL_AUTHOR_LEN,
1143 5 * MINI_TILEX - 2, 5 * MINI_TILEY - ED_BORDER_SIZE + 1,
1144 GADGET_ID_ELEMENT_NAME,
1145 MAX_ELEMENT_NAME_LEN - 2, /* currently 2 chars less editable */
1146 custom_element.description,
1147 NULL, "Element name"
1157 char *text_above, *infotext;
1158 } textarea_info[ED_NUM_TEXTAREAS] =
1161 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(2),
1162 GADGET_ID_ENVELOPE_INFO,
1163 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1165 "Envelope Info:", "Envelope Info"
1169 static struct ValueTextInfo options_time_or_steps[] =
1177 static struct ValueTextInfo options_access_type[] =
1179 { EP_WALKABLE, "walkable" },
1180 { EP_PASSABLE, "passable" },
1185 static struct ValueTextInfo options_access_layer[] =
1187 { EP_ACCESSIBLE_OVER, "over" },
1188 { EP_ACCESSIBLE_INSIDE, "inside" },
1189 { EP_ACCESSIBLE_UNDER, "under" },
1194 static struct ValueTextInfo options_access_protected[] =
1196 { 0, "unprotected" },
1202 static struct ValueTextInfo options_access_direction[] =
1204 { MV_LEFT, "left" },
1205 { MV_RIGHT, "right" },
1207 { MV_DOWN, "down" },
1208 { MV_LEFT | MV_UP, "left + up" },
1209 { MV_LEFT | MV_DOWN, "left + down" },
1210 { MV_RIGHT | MV_UP, "right + up" },
1211 { MV_RIGHT | MV_DOWN, "right + down" },
1212 { MV_HORIZONTAL, "horizontal" },
1213 { MV_VERTICAL, "vertical" },
1214 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1215 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1216 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1217 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1218 { MV_ALL_DIRECTIONS, "all directions" },
1223 static struct ValueTextInfo options_walk_to_action[] =
1225 { EP_DIGGABLE, "diggable" },
1226 { EP_COLLECTIBLE_ONLY, "collectible" },
1227 { EP_DROPPABLE, "collectible & droppable" },
1228 { EP_THROWABLE, "collectible & throwable" },
1229 { EP_PUSHABLE, "pushable" },
1234 static struct ValueTextInfo options_move_pattern[] =
1236 { MV_LEFT, "left" },
1237 { MV_RIGHT, "right" },
1239 { MV_DOWN, "down" },
1240 { MV_HORIZONTAL, "horizontal" },
1241 { MV_VERTICAL, "vertical" },
1242 { MV_ALL_DIRECTIONS, "all directions" },
1243 { MV_TOWARDS_PLAYER, "towards player" },
1244 { MV_AWAY_FROM_PLAYER, "away from player" },
1245 { MV_ALONG_LEFT_SIDE, "along left side" },
1246 { MV_ALONG_RIGHT_SIDE, "along right side" },
1247 { MV_TURNING_LEFT, "turning left" },
1248 { MV_TURNING_RIGHT, "turning right" },
1249 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1250 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1251 { MV_TURNING_RANDOM, "turning random" },
1252 { MV_MAZE_RUNNER, "maze runner style" },
1253 { MV_MAZE_HUNTER, "maze hunter style" },
1254 { MV_WHEN_PUSHED, "when pushed" },
1255 { MV_WHEN_DROPPED, "when dropped/thrown" },
1260 static struct ValueTextInfo options_move_direction[] =
1262 { MV_START_AUTOMATIC, "automatic" },
1263 { MV_START_LEFT, "left" },
1264 { MV_START_RIGHT, "right" },
1265 { MV_START_UP, "up" },
1266 { MV_START_DOWN, "down" },
1267 { MV_START_RANDOM, "random" },
1268 { MV_START_PREVIOUS, "previous" },
1273 static struct ValueTextInfo options_move_stepsize[] =
1279 { 16, "very fast" },
1281 { 32, "even faster" },
1287 static struct ValueTextInfo options_move_leave_type[] =
1289 { LEAVE_TYPE_UNLIMITED, "leave behind" },
1290 { LEAVE_TYPE_LIMITED, "change it to" },
1295 static struct ValueTextInfo options_smash_targets[] =
1297 { EP_CAN_SMASH_PLAYER, "player" },
1299 { EP_CAN_SMASH_ENEMIES, "enemies" },
1301 { EP_CAN_SMASH_EVERYTHING, "everything" },
1306 static struct ValueTextInfo options_slippery_type[] =
1308 { SLIPPERY_ANY_RANDOM, "random" },
1309 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
1310 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
1311 { SLIPPERY_ONLY_LEFT, "only left" },
1312 { SLIPPERY_ONLY_RIGHT, "only right" },
1317 static struct ValueTextInfo options_deadliness[] =
1319 { EP_DONT_RUN_INTO, "running into" },
1320 { EP_DONT_COLLIDE_WITH, "colliding with" },
1321 { EP_DONT_TOUCH, "touching" },
1326 static struct ValueTextInfo options_explosion_type[] =
1328 { EXPLODES_3X3, "3x3" },
1329 { EXPLODES_CROSS, "3+3" },
1330 { EXPLODES_1X1, "1x1" },
1332 { EP_INDESTRUCTIBLE, "indestructible" },
1338 static struct ValueTextInfo options_time_units[] =
1341 { FRAMES_PER_SECOND, "seconds" },
1346 static struct ValueTextInfo options_change_direct_action[] =
1348 { CE_TOUCHED_BY_PLAYER, "touched by player" },
1349 { CE_PRESSED_BY_PLAYER, "pressed by player" },
1350 { CE_PUSHED_BY_PLAYER, "pushed by player" },
1351 { CE_ENTERED_BY_PLAYER, "entered by player" },
1352 { CE_LEFT_BY_PLAYER, "left by player" },
1353 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
1354 { CE_SWITCHED, "switched" },
1356 { CE_HITTING_SOMETHING, "hitting something" },
1357 { CE_HIT_BY_SOMETHING, "hit by something" },
1359 { CE_HITTING_SOMETHING, "collision" },
1362 { CE_BLOCKED, "blocked" },
1364 { CE_IMPACT, "impact (on something)" },
1365 { CE_SMASHED, "smashed (from above)" },
1370 static struct ValueTextInfo options_change_other_action[] =
1372 { CE_OTHER_GETS_TOUCHED, "player touches" },
1373 { CE_OTHER_GETS_PRESSED, "player presses" },
1374 { CE_OTHER_GETS_PUSHED, "player pushes" },
1375 { CE_OTHER_GETS_ENTERED, "player enters" },
1376 { CE_OTHER_GETS_LEFT, "player leaves" },
1377 { CE_OTHER_GETS_DIGGED, "player digs" },
1378 { CE_OTHER_GETS_COLLECTED, "player collects" },
1379 { CE_OTHER_GETS_DROPPED, "player drops/throws" },
1380 { CE_OTHER_IS_TOUCHING, "touching" },
1382 { CE_OTHER_IS_HITTING, "hitting" },
1383 { CE_OTHER_GETS_HIT, "hit by" },
1385 { CE_OTHER_IS_SWITCHING, "switch of" },
1386 { CE_OTHER_IS_CHANGING, "change by page of" },
1387 { CE_OTHER_IS_EXPLODING, "explosion of" },
1392 static struct ValueTextInfo options_change_trigger_side[] =
1394 { CH_SIDE_LEFT, "left" },
1395 { CH_SIDE_RIGHT, "right" },
1396 { CH_SIDE_TOP, "top" },
1397 { CH_SIDE_BOTTOM, "bottom" },
1398 { CH_SIDE_LEFT_RIGHT, "left/right" },
1399 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
1400 { CH_SIDE_ANY, "any" },
1405 static struct ValueTextInfo options_change_trigger_player[] =
1407 { CH_PLAYER_1, "1" },
1408 { CH_PLAYER_2, "2" },
1409 { CH_PLAYER_3, "3" },
1410 { CH_PLAYER_4, "4" },
1411 { CH_PLAYER_ANY, "any" },
1416 static struct ValueTextInfo options_change_trigger_page[] =
1428 { (1 << 10), "11" },
1429 { (1 << 11), "12" },
1430 { (1 << 12), "13" },
1431 { (1 << 13), "14" },
1432 { (1 << 14), "15" },
1433 { (1 << 15), "16" },
1434 { (1 << 16), "17" },
1435 { (1 << 17), "18" },
1436 { (1 << 18), "19" },
1437 { (1 << 19), "20" },
1438 { (1 << 20), "21" },
1439 { (1 << 21), "22" },
1440 { (1 << 22), "23" },
1441 { (1 << 23), "24" },
1442 { (1 << 24), "25" },
1443 { (1 << 25), "26" },
1444 { (1 << 26), "27" },
1445 { (1 << 27), "28" },
1446 { (1 << 28), "29" },
1447 { (1 << 29), "30" },
1448 { (1 << 30), "31" },
1449 { (1 << 31), "32" },
1450 { CH_PAGE_ANY, "any" },
1455 static struct ValueTextInfo options_change_replace_when[] =
1457 { CP_WHEN_EMPTY, "empty" },
1458 { CP_WHEN_WALKABLE, "walkable" },
1459 { CP_WHEN_DIGGABLE, "diggable" },
1460 { CP_WHEN_COLLECTIBLE, "collectible" },
1461 { CP_WHEN_REMOVABLE, "removable" },
1462 { CP_WHEN_DESTRUCTIBLE, "destructible" },
1467 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
1468 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
1473 static struct ValueTextInfo options_group_choice_mode[] =
1475 { ANIM_RANDOM, "random" },
1476 { ANIM_LOOP, "loop" },
1477 { ANIM_LINEAR, "linear" },
1478 { ANIM_PINGPONG, "pingpong" },
1479 { ANIM_PINGPONG2, "pingpong 2" },
1488 int gadget_id_align;
1489 int size; /* char size of selectbox or '-1' (dynamically determined) */
1490 struct ValueTextInfo *options;
1492 char *text_left, *text_right, *infotext;
1493 } selectbox_info[ED_NUM_SELECTBOX] =
1495 /* ---------- level and editor settings ---------------------------------- */
1498 -1, ED_COUNTER_YPOS(4),
1499 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
1501 options_time_or_steps,
1502 &level.use_step_counter,
1503 NULL, "(0 => no limit)", "time or step limit"
1506 /* ---------- element settings: configure 1 (custom elements) ----------- */
1509 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(3),
1510 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
1512 options_access_type,
1513 &custom_element.access_type,
1514 NULL, NULL, "type of access to this field"
1517 -1, ED_SETTINGS_YPOS(3),
1518 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
1520 options_access_layer,
1521 &custom_element.access_layer,
1522 NULL, NULL, "layer of access for this field"
1525 -1, ED_SETTINGS_YPOS(3),
1526 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
1528 options_access_protected,
1529 &custom_element.access_protected,
1530 NULL, NULL, "protected access for this field"
1533 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(4),
1534 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
1536 options_access_direction,
1537 &custom_element.access_direction,
1538 "from", NULL, "access direction for this field"
1541 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(5),
1542 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
1544 options_walk_to_action,
1545 &custom_element.walk_to_action,
1546 NULL, NULL, "diggable/collectible/pushable"
1549 /* ---------- element settings: configure 2 (custom elements) ----------- */
1552 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(1),
1553 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
1555 options_move_pattern,
1556 &custom_element.move_pattern,
1557 "can move", NULL, "element move pattern"
1560 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(2),
1561 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
1563 options_move_direction,
1564 &custom_element.move_direction_initial,
1565 "starts moving", NULL, "initial element move direction"
1568 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(4),
1569 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
1571 options_move_stepsize,
1572 &custom_element.move_stepsize,
1573 "move/fall speed", NULL, "speed of element movement"
1576 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(3),
1577 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
1579 options_move_leave_type,
1580 &custom_element.move_leave_type,
1581 "can dig: can", ":", "leave behind or change element"
1584 -1, ED_SETTINGS_YPOS(7),
1585 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
1587 options_smash_targets,
1588 &custom_element.smash_targets,
1589 "can smash", NULL, "elements that can be smashed"
1592 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(8),
1593 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
1595 options_slippery_type,
1596 &custom_element.slippery_type,
1597 "slippery", NULL, "where other elements fall down"
1600 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(9),
1601 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
1604 &custom_element.deadliness,
1605 "deadly when", NULL, "deadliness of element"
1608 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(10),
1609 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
1611 options_explosion_type,
1612 &custom_element.explosion_type,
1613 "can explode", NULL, "explosion type"
1616 /* ---------- element settings: advanced (custom elements) --------------- */
1619 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(3),
1620 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
1623 &custom_element_change.delay_frames,
1624 "delay time given in", NULL, "delay time units for change"
1627 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(4),
1628 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
1630 options_change_direct_action,
1631 &custom_element_change.direct_action,
1632 NULL, NULL, "type of direct action"
1635 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(5),
1636 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
1638 options_change_other_action,
1639 &custom_element_change.other_action,
1640 NULL, "element:", "type of other element action"
1643 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(6),
1644 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
1646 options_change_trigger_side,
1647 &custom_element_change.trigger_side,
1648 "at", "side", "element side that causes change"
1651 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(7),
1652 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
1654 options_change_trigger_player,
1655 &custom_element_change.trigger_player,
1656 "player:", " ", "player that causes change"
1659 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(7),
1660 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
1662 options_change_trigger_page,
1663 &custom_element_change.trigger_page,
1664 "page:", NULL, "change page that causes change"
1667 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(10),
1668 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
1670 options_change_replace_when,
1671 &custom_element_change.replace_when,
1672 "replace when", NULL, "which elements can be replaced"
1675 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(14),
1676 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
1678 options_change_page,
1679 &custom_element.current_change_page,
1680 NULL, NULL, "element change page"
1683 /* ---------- element settings: configure (group elements) --------------- */
1686 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(6),
1687 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
1689 options_group_choice_mode,
1690 &group_element_info.choice_mode,
1691 "choice type:", NULL, "type of group element choice"
1699 int gadget_id_align;
1702 char *text_left, *text_right, *infotext;
1703 } textbutton_info[ED_NUM_TEXTBUTTONS] =
1707 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(1),
1708 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
1710 NULL, NULL, "Show information about element"
1713 ED_SETTINGS_XPOS(0) + 124, ED_COUNTER_YPOS(1),
1714 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_NONE,
1716 NULL, NULL, "Configure element properties"
1719 ED_SETTINGS_XPOS(0) + 124, ED_COUNTER_YPOS(1),
1720 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_NONE,
1722 NULL, NULL, "Configure custom element properties"
1725 ED_SETTINGS_XPOS(0) + 248, ED_COUNTER_YPOS(1),
1726 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_NONE,
1728 NULL, NULL, "Configure custom element properties"
1731 ED_SETTINGS_XPOS(0) + 372, ED_COUNTER_YPOS(1),
1732 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_NONE,
1734 NULL, NULL, "Custom element change configuration"
1738 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(1),
1739 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
1741 NULL, NULL, "Show information about element"
1744 ED_SETTINGS_XPOS(0) + 166, ED_COUNTER_YPOS(1),
1745 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_NONE,
1747 NULL, NULL, "Configure element properties"
1750 ED_SETTINGS_XPOS(0) + 332, ED_COUNTER_YPOS(1),
1751 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_NONE,
1753 NULL, NULL, "Advanced element configuration"
1757 -1, ED_SETTINGS_YPOS(2),
1758 GADGET_ID_SAVE_AS_TEMPLATE, GADGET_ID_CUSTOM_USE_TEMPLATE,
1760 " ", "As Template", "Save current settings as new template"
1763 -1, ED_SETTINGS_YPOS(14),
1764 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
1766 NULL, NULL, "Add new change page"
1769 -1, ED_SETTINGS_YPOS(14),
1770 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
1772 NULL, NULL, "Delete current change page"
1782 int gadget_id_align;
1783 char *text_left, *text_right, *infotext;
1784 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
1787 ED_BUTTON_MINUS_XPOS, ED_BUTTON_COUNT_YPOS,
1788 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(14),
1789 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
1790 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
1791 NULL, NULL, "select previous change page"
1794 ED_BUTTON_PLUS_XPOS, ED_BUTTON_COUNT_YPOS,
1795 -1, ED_SETTINGS_YPOS(14),
1796 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
1797 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
1798 NULL, "change page", "select next change page"
1801 ED_COPY_CHANGE_PAGE_XPOS, ED_COPY_CHANGE_PAGE_YPOS,
1802 -1, ED_SETTINGS_YPOS(14),
1803 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
1804 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
1805 " ", NULL, "copy settings from this change page"
1808 ED_PASTE_CHANGE_PAGE_XPOS, ED_PASTE_CHANGE_PAGE_YPOS,
1809 -1, ED_SETTINGS_YPOS(14),
1810 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
1811 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
1812 NULL, NULL, "paste settings to this change page"
1822 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
1825 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 0 * ED_SCROLLBUTTON_YSIZE,
1826 ED_SCROLL_UP_XPOS, ED_SCROLL_UP_YPOS,
1827 GADGET_ID_SCROLL_UP,
1828 "scroll level editing area up"
1831 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 1 * ED_SCROLLBUTTON_YSIZE,
1832 ED_SCROLL_DOWN_XPOS, ED_SCROLL_DOWN_YPOS,
1833 GADGET_ID_SCROLL_DOWN,
1834 "scroll level editing area down"
1837 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 2 * ED_SCROLLBUTTON_YSIZE,
1838 ED_SCROLL_LEFT_XPOS, ED_SCROLL_LEFT_YPOS,
1839 GADGET_ID_SCROLL_LEFT,
1840 "scroll level editing area left"
1843 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 3 * ED_SCROLLBUTTON_YSIZE,
1844 ED_SCROLL_RIGHT_XPOS, ED_SCROLL_RIGHT_YPOS,
1845 GADGET_ID_SCROLL_RIGHT,
1846 "scroll level editing area right"
1849 ED_SCROLLBUTTON2_XPOS, ED_SCROLLBUTTON2_YPOS + 0 * ED_SCROLLBUTTON2_YSIZE,
1850 ED_SCROLL2_UP_XPOS, ED_SCROLL2_UP_YPOS,
1851 GADGET_ID_SCROLL_LIST_UP,
1852 "scroll element list up ('Page Up')"
1855 ED_SCROLLBUTTON2_XPOS, ED_SCROLLBUTTON2_YPOS + 1 * ED_SCROLLBUTTON2_YSIZE,
1856 ED_SCROLL2_DOWN_XPOS, ED_SCROLL2_DOWN_YPOS,
1857 GADGET_ID_SCROLL_LIST_DOWN,
1858 "scroll element list down ('Page Down')"
1870 } scrollbar_info[ED_NUM_SCROLLBARS] =
1873 ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
1874 SX + ED_SCROLL_HORIZONTAL_XPOS, SY + ED_SCROLL_HORIZONTAL_YPOS,
1875 ED_SCROLL_HORIZONTAL_XSIZE, ED_SCROLL_HORIZONTAL_YSIZE,
1876 GD_TYPE_SCROLLBAR_HORIZONTAL,
1877 GADGET_ID_SCROLL_HORIZONTAL,
1878 "scroll level editing area horizontally"
1881 ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
1882 SX + ED_SCROLL_VERTICAL_XPOS, SY + ED_SCROLL_VERTICAL_YPOS,
1883 ED_SCROLL_VERTICAL_XSIZE, ED_SCROLL_VERTICAL_YSIZE,
1884 GD_TYPE_SCROLLBAR_VERTICAL,
1885 GADGET_ID_SCROLL_VERTICAL,
1886 "scroll level editing area vertically"
1889 ED_SCROLLBAR2_XPOS, ED_SCROLLBAR2_YPOS,
1890 DX + ED_SCROLL2_VERTICAL_XPOS, DY + ED_SCROLL2_VERTICAL_YPOS,
1891 ED_SCROLL2_VERTICAL_XSIZE, ED_SCROLL2_VERTICAL_YSIZE,
1892 GD_TYPE_SCROLLBAR_VERTICAL,
1893 GADGET_ID_SCROLL_LIST_VERTICAL,
1894 "scroll element list vertically"
1902 int gadget_id_align;
1903 int radio_button_nr;
1906 char *text_left, *text_right, *infotext;
1907 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
1910 -1, ED_COUNTER2_YPOS(8),
1911 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
1912 RADIO_NR_RANDOM_ELEMENTS,
1913 &random_placement_method, RANDOM_USE_PERCENTAGE,
1914 " ", "percentage", "use percentage for random elements"
1917 -1, ED_COUNTER2_YPOS(8),
1918 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
1919 RADIO_NR_RANDOM_ELEMENTS,
1920 &random_placement_method, RANDOM_USE_QUANTITY,
1921 " ", "quantity", "use quantity for random elements"
1929 int gadget_id_align;
1931 char *text_left, *text_right, *infotext;
1932 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
1934 /* ---------- level and editor settings ---------------------------------- */
1937 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(6) - MINI_TILEY,
1938 GADGET_ID_DOUBLE_SPEED, GADGET_ID_NONE,
1939 &level.double_speed,
1940 NULL, "double speed movement", "set movement speed of player"
1943 -1, ED_COUNTER_YPOS(6) - MINI_TILEY,
1944 GADGET_ID_GRAVITY, GADGET_ID_DOUBLE_SPEED,
1945 &level.initial_gravity,
1946 " ", "gravity", "set level gravity"
1949 ED_SETTINGS_XPOS(0), ED_COUNTER2_YPOS(9) - MINI_TILEY,
1950 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
1951 &random_placement_background_restricted,
1953 "restrict random placement to:", "set random placement restriction"
1956 /* ---------- element settings: configure (various elements) ------------- */
1959 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(0),
1960 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
1961 &stick_element_properties_window,
1963 "stick this screen to edit content","stick this screen to edit content"
1966 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1),
1967 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
1968 &level.em_slippery_gems,
1970 "slip down from certain flat walls","use EM style slipping behaviour"
1973 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1),
1974 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
1975 &level.use_spring_bug,
1977 "use spring pushing bug", "use odd spring pushing behaviour"
1980 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(0),
1981 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
1982 &level.grow_into_diggable,
1984 "can grow into anything diggable", "grow into more than just sand"
1987 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1),
1988 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
1989 &level.block_last_field,
1991 "block last field when moving", "player blocks last field when moving"
1994 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1),
1995 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
1996 &level.sp_block_last_field,
1998 "block last field when moving", "player blocks last field when moving"
2001 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(2),
2002 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
2003 &level.instant_relocation,
2005 "no scrolling when relocating", "player gets relocated without delay"
2008 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(3),
2009 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
2010 &level.can_pass_to_walkable,
2012 "can pass to walkable element", "player can pass to empty or walkable"
2015 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(0),
2016 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
2017 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
2019 "can fall into acid (with gravity)","player can fall into acid pool"
2022 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(0),
2023 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
2024 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
2026 "can move into acid", "element can move into acid pool"
2029 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1),
2030 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
2031 &custom_element_properties[EP_DONT_COLLIDE_WITH],
2033 "deadly when colliding with", "element is deadly when hitting player"
2036 /* ---------- element settings: configure 1 (custom elements) ----------- */
2039 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1),
2040 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
2041 &custom_element.use_gfx_element,
2042 NULL, "use graphic/sound of element:", "use existing graphic and sound"
2045 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(2),
2046 GADGET_ID_CUSTOM_USE_TEMPLATE, GADGET_ID_NONE,
2047 &level.use_custom_template,
2048 NULL, "use template", "use template for custom properties"
2051 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(3),
2052 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
2053 &custom_element_properties[EP_ACCESSIBLE],
2054 NULL, NULL, "player can walk to or pass this field"
2057 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(10),
2058 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
2059 &custom_element_properties[EP_GRAVITY_REACHABLE],
2060 NULL, "reachable despite gravity", "player can walk/dig despite gravity"
2063 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(5),
2064 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
2065 &custom_element_properties[EP_WALK_TO_OBJECT],
2066 NULL, NULL, "player can dig/collect/push element"
2069 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(9),
2070 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
2071 &custom_element_properties[EP_INDESTRUCTIBLE],
2072 NULL, "indestructible", "element is indestructible"
2075 /* ---------- element settings: configure 2 (custom elements) ----------- */
2078 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1),
2079 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
2080 &custom_element_properties[EP_CAN_MOVE],
2081 NULL, NULL, "element can move with some pattern"
2084 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(7),
2085 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
2086 &custom_element_properties[EP_CAN_FALL],
2087 NULL, "can fall", "element can fall down"
2090 -1, ED_SETTINGS_YPOS(7),
2091 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
2092 &custom_element_properties[EP_CAN_SMASH],
2093 " ", NULL, "element can smash other elements"
2096 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(8),
2097 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
2098 &custom_element_properties[EP_SLIPPERY],
2099 NULL, NULL, "other elements can fall down from it"
2102 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(9),
2103 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
2104 &custom_element_properties[EP_DEADLY],
2105 NULL, NULL, "element can kill the player"
2108 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(10),
2109 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
2110 &custom_element_properties[EP_CAN_EXPLODE],
2111 NULL, NULL, "element can explode"
2114 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(11),
2115 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
2116 &custom_element_properties[EP_EXPLODES_BY_FIRE],
2117 NULL, "by fire", "element can explode by fire/explosion"
2120 -1, ED_SETTINGS_YPOS(11),
2121 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
2122 &custom_element_properties[EP_EXPLODES_SMASHED],
2123 " ", "smashed", "element can explode when smashed"
2126 -1, ED_SETTINGS_YPOS(11),
2127 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
2128 &custom_element_properties[EP_EXPLODES_IMPACT],
2129 " ", "impact", "element can explode on impact"
2132 /* ---------- element settings: advanced (custom elements) --------------- */
2135 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1),
2136 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
2137 &custom_element_change.can_change,
2138 NULL, "element changes to:", "element can change to other element"
2141 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(2),
2142 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
2143 &custom_element_change_events[CE_DELAY],
2144 NULL, NULL, "element changes after delay"
2147 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(4),
2148 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
2149 &custom_element_change_events[CE_BY_DIRECT_ACTION],
2150 NULL, NULL, "element changes by direct action"
2153 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(5),
2154 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
2155 &custom_element_change_events[CE_BY_OTHER_ACTION],
2156 NULL, NULL, "element changes by other element"
2159 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(8),
2160 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
2161 &custom_element_change.explode,
2162 NULL, "explode instead of change", "element explodes instead of change"
2165 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(9),
2166 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
2167 &custom_element_change.use_target_content,
2168 NULL, "use extended change target:","element changes to more elements"
2171 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(11),
2172 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
2173 &custom_element_change.only_if_complete,
2174 NULL, "replace all or nothing", "only replace when all can be changed"
2177 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(12),
2178 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
2179 &custom_element_change.use_random_replace,
2180 NULL, NULL, "use percentage for random replace"
2187 int area_xsize, area_ysize;
2189 int gadget_id_align;
2190 char *text_left, *text_right, *text_below;
2191 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
2193 /* ---------- level playfield content ------------------------------------ */
2197 MAX_ED_FIELDX, MAX_ED_FIELDY,
2198 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
2202 /* ---------- yam yam content -------------------------------------------- */
2205 ED_AREA_YAMYAM_CONTENT_XPOS(0), ED_AREA_YAMYAM_CONTENT_YPOS(0),
2207 GADGET_ID_ELEMENT_CONTENT_0, GADGET_ID_NONE,
2211 ED_AREA_YAMYAM_CONTENT_XPOS(1), ED_AREA_YAMYAM_CONTENT_YPOS(1),
2213 GADGET_ID_ELEMENT_CONTENT_1, GADGET_ID_NONE,
2217 ED_AREA_YAMYAM_CONTENT_XPOS(2), ED_AREA_YAMYAM_CONTENT_YPOS(2),
2219 GADGET_ID_ELEMENT_CONTENT_2, GADGET_ID_NONE,
2223 ED_AREA_YAMYAM_CONTENT_XPOS(3), ED_AREA_YAMYAM_CONTENT_YPOS(3),
2225 GADGET_ID_ELEMENT_CONTENT_3, GADGET_ID_NONE,
2229 ED_AREA_YAMYAM_CONTENT_XPOS(4), ED_AREA_YAMYAM_CONTENT_YPOS(4),
2231 GADGET_ID_ELEMENT_CONTENT_4, GADGET_ID_NONE,
2235 ED_AREA_YAMYAM_CONTENT_XPOS(5), ED_AREA_YAMYAM_CONTENT_YPOS(5),
2237 GADGET_ID_ELEMENT_CONTENT_5, GADGET_ID_NONE,
2241 ED_AREA_YAMYAM_CONTENT_XPOS(6), ED_AREA_YAMYAM_CONTENT_YPOS(6),
2243 GADGET_ID_ELEMENT_CONTENT_6, GADGET_ID_NONE,
2247 ED_AREA_YAMYAM_CONTENT_XPOS(7), ED_AREA_YAMYAM_CONTENT_YPOS(7),
2249 GADGET_ID_ELEMENT_CONTENT_7, GADGET_ID_NONE,
2253 /* ---------- amoeba content --------------------------------------------- */
2256 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
2258 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
2259 "content:", NULL, NULL
2262 /* ---------- element settings: configure 1 (custom elements) ----------- */
2264 /* ---------- custom graphic --------------------------------------------- */
2267 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
2269 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
2273 /* ---------- element settings: configure 2 (custom elements) ----------- */
2275 /* ---------- custom content (when exploding) ---------------------------- */
2278 -1, ED_AREA_3X3_SETTINGS_YPOS(10),
2280 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, /* align three rows */
2281 "content:", NULL, NULL
2284 /* ---------- custom enter and leave element (when moving) --------------- */
2287 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
2289 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
2290 "can dig:", " ", NULL
2293 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
2295 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
2299 /* ---------- element settings: advanced (custom elements) --------------- */
2301 /* ---------- custom change target --------------------------------------- */
2304 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
2306 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
2307 NULL, "after/when:", NULL
2310 /* ---------- custom change content (extended change target) ------------- */
2313 -1, ED_AREA_3X3_SETTINGS_YPOS(10),
2315 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, /* align three rows */
2319 /* ---------- custom change trigger (element causing change) ------------- */
2322 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
2324 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
2328 /* ---------- group element content -------------------------------------- */
2331 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(4),
2332 MAX_ELEMENTS_IN_GROUP, 1,
2333 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
2334 "content:", NULL, NULL
2337 /* ---------- random background (for random painting) -------------------- */
2340 -1, ED_SETTINGS_YPOS(14),
2342 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
2349 -----------------------------------------------------------------------------
2350 some internally used variables
2351 -----------------------------------------------------------------------------
2354 /* actual size of level editor drawing area */
2355 static int ed_fieldx = MAX_ED_FIELDX - 1, ed_fieldy = MAX_ED_FIELDY - 1;
2357 /* actual position of level editor drawing area in level playfield */
2358 static int level_xpos = -1, level_ypos = -1;
2360 #define IN_ED_FIELD(x,y) ((x)>=0 && (x)<ed_fieldx && (y)>=0 &&(y)<ed_fieldy)
2362 /* drawing elements on the three mouse buttons */
2363 static int new_element1 = EL_WALL;
2364 static int new_element2 = EL_EMPTY;
2365 static int new_element3 = EL_SAND;
2367 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
2368 (button) == 2 ? new_element2 : \
2369 (button) == 3 ? new_element3 : EL_EMPTY)
2370 #define BUTTON_STEPSIZE(button) ((button) == 1 ? 1 : (button) == 2 ? 5 : 10)
2372 /* forward declaration for internal use */
2373 static void ModifyEditorCounter(int, int);
2374 static void ModifyEditorCounterLimits(int, int, int);
2375 static void ModifyEditorSelectbox(int, int);
2376 static void ModifyEditorDrawingArea(int, int, int);
2377 static void ModifyEditorElementList();
2378 static void RedrawDrawingElements();
2379 static void DrawDrawingWindow();
2380 static void DrawLevelInfoWindow();
2381 static void DrawPropertiesWindow();
2382 static void UpdateCustomElementGraphicGadgets();
2383 static boolean checkPropertiesConfig(int);
2384 static void CopyLevelToUndoBuffer(int);
2385 static void HandleDrawingAreas(struct GadgetInfo *);
2386 static void HandleCounterButtons(struct GadgetInfo *);
2387 static void HandleTextInputGadgets(struct GadgetInfo *);
2388 static void HandleTextAreaGadgets(struct GadgetInfo *);
2389 static void HandleSelectboxGadgets(struct GadgetInfo *);
2390 static void HandleTextbuttonGadgets(struct GadgetInfo *);
2391 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
2392 static void HandleRadiobuttons(struct GadgetInfo *);
2393 static void HandleCheckbuttons(struct GadgetInfo *);
2394 static void HandleControlButtons(struct GadgetInfo *);
2395 static void HandleDrawingAreaInfo(struct GadgetInfo *);
2397 static struct GadgetInfo *level_editor_gadget[NUM_EDITOR_GADGETS];
2398 static int right_gadget_border[NUM_EDITOR_GADGETS];
2400 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
2401 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
2402 static boolean draw_with_brush = FALSE;
2403 static int properties_element = 0;
2405 static short FieldBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2406 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2407 static int undo_buffer_position = 0;
2408 static int undo_buffer_steps = 0;
2410 static int edit_mode;
2411 static int edit_mode_properties;
2413 static int element_shift = 0;
2415 static int editor_hl_boulderdash[] =
2433 static int editor_el_boulderdash[] =
2450 EL_BD_BUTTERFLY_LEFT,
2452 EL_BD_BUTTERFLY_RIGHT,
2453 EL_BD_FIREFLY_RIGHT,
2456 EL_BD_BUTTERFLY_DOWN,
2460 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
2461 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
2462 static int num_editor_hl_boulderdash = SIZEOF_ARRAY_INT(editor_hl_boulderdash);
2463 static int num_editor_el_boulderdash = SIZEOF_ARRAY_INT(editor_el_boulderdash);
2465 static int editor_hl_emerald_mine[] =
2483 static int editor_el_emerald_mine[] =
2530 EL_ACID_POOL_TOPLEFT,
2532 EL_ACID_POOL_TOPRIGHT,
2535 EL_ACID_POOL_BOTTOMLEFT,
2536 EL_ACID_POOL_BOTTOM,
2537 EL_ACID_POOL_BOTTOMRIGHT,
2567 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
2568 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
2569 static int num_editor_hl_emerald_mine=SIZEOF_ARRAY_INT(editor_hl_emerald_mine);
2570 static int num_editor_el_emerald_mine=SIZEOF_ARRAY_INT(editor_el_emerald_mine);
2572 static int editor_hl_more[] =
2580 static int editor_el_more[] =
2608 EL_WALL_EMERALD_YELLOW,
2609 EL_WALL_EMERALD_RED,
2610 EL_WALL_EMERALD_PURPLE,
2627 EL_DYNABOMB_INCREASE_NUMBER,
2628 EL_DYNABOMB_INCREASE_SIZE,
2629 EL_DYNABOMB_INCREASE_POWER,
2650 EL_BALLOON_SWITCH_ANY,
2652 EL_BALLOON_SWITCH_LEFT,
2653 EL_BALLOON_SWITCH_RIGHT,
2654 EL_BALLOON_SWITCH_UP,
2655 EL_BALLOON_SWITCH_DOWN,
2658 EL_EXPANDABLE_WALL_HORIZONTAL,
2659 EL_EXPANDABLE_WALL_VERTICAL,
2660 EL_EXPANDABLE_WALL_ANY,
2662 EL_INVISIBLE_STEELWALL,
2677 static int *editor_hl_more_ptr = editor_hl_more;
2678 static int *editor_el_more_ptr = editor_el_more;
2679 static int num_editor_hl_more = SIZEOF_ARRAY_INT(editor_hl_more);
2680 static int num_editor_el_more = SIZEOF_ARRAY_INT(editor_el_more);
2682 static int editor_hl_sokoban[] =
2695 static int editor_el_sokoban[] =
2698 EL_SOKOBAN_FIELD_EMPTY,
2699 EL_SOKOBAN_FIELD_FULL,
2700 EL_SOKOBAN_FIELD_PLAYER,
2702 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
2703 static int *editor_el_sokoban_ptr = editor_el_sokoban;
2704 static int num_editor_hl_sokoban = SIZEOF_ARRAY_INT(editor_hl_sokoban);
2705 static int num_editor_el_sokoban = SIZEOF_ARRAY_INT(editor_el_sokoban);
2707 static int editor_hl_supaplex[] =
2720 static int editor_el_supaplex[] =
2733 EL_SP_HARDWARE_GRAY,
2742 EL_SP_GRAVITY_PORT_RIGHT,
2743 EL_SP_GRAVITY_PORT_DOWN,
2744 EL_SP_GRAVITY_PORT_LEFT,
2746 EL_SP_GRAVITY_PORT_UP,
2752 EL_SP_PORT_VERTICAL,
2753 EL_SP_PORT_HORIZONTAL,
2761 EL_SP_HARDWARE_BASE_1,
2762 EL_SP_HARDWARE_GREEN,
2763 EL_SP_HARDWARE_BLUE,
2766 EL_SP_HARDWARE_YELLOW,
2767 EL_SP_HARDWARE_BASE_2,
2768 EL_SP_HARDWARE_BASE_3,
2769 EL_SP_HARDWARE_BASE_4,
2771 EL_SP_HARDWARE_BASE_5,
2772 EL_SP_HARDWARE_BASE_6,
2776 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
2777 static int *editor_el_supaplex_ptr = editor_el_supaplex;
2778 static int num_editor_hl_supaplex = SIZEOF_ARRAY_INT(editor_hl_supaplex);
2779 static int num_editor_el_supaplex = SIZEOF_ARRAY_INT(editor_el_supaplex);
2781 static int editor_hl_diamond_caves[] =
2804 static int editor_el_diamond_caves[] =
2811 EL_CONVEYOR_BELT_1_LEFT,
2812 EL_CONVEYOR_BELT_1_MIDDLE,
2813 EL_CONVEYOR_BELT_1_RIGHT,
2814 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
2816 EL_CONVEYOR_BELT_2_LEFT,
2817 EL_CONVEYOR_BELT_2_MIDDLE,
2818 EL_CONVEYOR_BELT_2_RIGHT,
2819 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
2821 EL_CONVEYOR_BELT_3_LEFT,
2822 EL_CONVEYOR_BELT_3_MIDDLE,
2823 EL_CONVEYOR_BELT_3_RIGHT,
2824 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
2826 EL_CONVEYOR_BELT_4_LEFT,
2827 EL_CONVEYOR_BELT_4_MIDDLE,
2828 EL_CONVEYOR_BELT_4_RIGHT,
2829 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
2831 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
2832 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
2833 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
2834 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
2836 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
2837 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
2838 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
2839 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
2842 EL_SWITCHGATE_CLOSED,
2843 EL_SWITCHGATE_SWITCH_UP,
2858 EL_STEELWALL_SLIPPERY,
2861 EL_SIGN_EXCLAMATION,
2864 EL_LIGHT_SWITCH_ACTIVE,
2871 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
2872 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
2873 static int num_editor_hl_diamond_caves = SIZEOF_ARRAY_INT(editor_hl_diamond_caves);
2874 static int num_editor_el_diamond_caves = SIZEOF_ARRAY_INT(editor_el_diamond_caves);
2876 static int editor_hl_dx_boulderdash[] =
2899 static int editor_el_dx_boulderdash[] =
2903 EL_TUBE_HORIZONTAL_DOWN,
2907 EL_TUBE_VERTICAL_RIGHT,
2909 EL_TUBE_VERTICAL_LEFT,
2913 EL_TUBE_HORIZONTAL_UP,
2921 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
2922 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
2923 static int num_editor_hl_dx_boulderdash = SIZEOF_ARRAY_INT(editor_hl_dx_boulderdash);
2924 static int num_editor_el_dx_boulderdash = SIZEOF_ARRAY_INT(editor_el_dx_boulderdash);
2926 static int editor_hl_chars[] =
2934 static int editor_el_chars[] =
3023 EL_CHAR(FONT_ASCII_CURSOR),
3026 static int *editor_hl_chars_ptr = editor_hl_chars;
3027 static int *editor_el_chars_ptr = editor_el_chars;
3028 static int num_editor_hl_chars = SIZEOF_ARRAY_INT(editor_hl_chars);
3029 static int num_editor_el_chars = SIZEOF_ARRAY_INT(editor_el_chars);
3031 static int editor_hl_custom[] =
3054 static int editor_el_custom[] =
3056 EL_CUSTOM_START + 0,
3057 EL_CUSTOM_START + 1,
3058 EL_CUSTOM_START + 2,
3059 EL_CUSTOM_START + 3,
3061 EL_CUSTOM_START + 4,
3062 EL_CUSTOM_START + 5,
3063 EL_CUSTOM_START + 6,
3064 EL_CUSTOM_START + 7,
3066 EL_CUSTOM_START + 8,
3067 EL_CUSTOM_START + 9,
3068 EL_CUSTOM_START + 10,
3069 EL_CUSTOM_START + 11,
3071 EL_CUSTOM_START + 12,
3072 EL_CUSTOM_START + 13,
3073 EL_CUSTOM_START + 14,
3074 EL_CUSTOM_START + 15,
3076 EL_CUSTOM_START + 16,
3077 EL_CUSTOM_START + 17,
3078 EL_CUSTOM_START + 18,
3079 EL_CUSTOM_START + 19,
3081 EL_CUSTOM_START + 20,
3082 EL_CUSTOM_START + 21,
3083 EL_CUSTOM_START + 22,
3084 EL_CUSTOM_START + 23,
3086 EL_CUSTOM_START + 24,
3087 EL_CUSTOM_START + 25,
3088 EL_CUSTOM_START + 26,
3089 EL_CUSTOM_START + 27,
3091 EL_CUSTOM_START + 28,
3092 EL_CUSTOM_START + 29,
3093 EL_CUSTOM_START + 30,
3094 EL_CUSTOM_START + 31,
3096 EL_CUSTOM_START + 32,
3097 EL_CUSTOM_START + 33,
3098 EL_CUSTOM_START + 34,
3099 EL_CUSTOM_START + 35,
3101 EL_CUSTOM_START + 36,
3102 EL_CUSTOM_START + 37,
3103 EL_CUSTOM_START + 38,
3104 EL_CUSTOM_START + 39,
3106 EL_CUSTOM_START + 40,
3107 EL_CUSTOM_START + 41,
3108 EL_CUSTOM_START + 42,
3109 EL_CUSTOM_START + 43,
3111 EL_CUSTOM_START + 44,
3112 EL_CUSTOM_START + 45,
3113 EL_CUSTOM_START + 46,
3114 EL_CUSTOM_START + 47,
3116 EL_CUSTOM_START + 48,
3117 EL_CUSTOM_START + 49,
3118 EL_CUSTOM_START + 50,
3119 EL_CUSTOM_START + 51,
3121 EL_CUSTOM_START + 52,
3122 EL_CUSTOM_START + 53,
3123 EL_CUSTOM_START + 54,
3124 EL_CUSTOM_START + 55,
3126 EL_CUSTOM_START + 56,
3127 EL_CUSTOM_START + 57,
3128 EL_CUSTOM_START + 58,
3129 EL_CUSTOM_START + 59,
3131 EL_CUSTOM_START + 60,
3132 EL_CUSTOM_START + 61,
3133 EL_CUSTOM_START + 62,
3134 EL_CUSTOM_START + 63,
3136 EL_CUSTOM_START + 64,
3137 EL_CUSTOM_START + 65,
3138 EL_CUSTOM_START + 66,
3139 EL_CUSTOM_START + 67,
3141 EL_CUSTOM_START + 68,
3142 EL_CUSTOM_START + 69,
3143 EL_CUSTOM_START + 70,
3144 EL_CUSTOM_START + 71,
3146 EL_CUSTOM_START + 72,
3147 EL_CUSTOM_START + 73,
3148 EL_CUSTOM_START + 74,
3149 EL_CUSTOM_START + 75,
3151 EL_CUSTOM_START + 76,
3152 EL_CUSTOM_START + 77,
3153 EL_CUSTOM_START + 78,
3154 EL_CUSTOM_START + 79,
3156 EL_CUSTOM_START + 80,
3157 EL_CUSTOM_START + 81,
3158 EL_CUSTOM_START + 82,
3159 EL_CUSTOM_START + 83,
3161 EL_CUSTOM_START + 84,
3162 EL_CUSTOM_START + 85,
3163 EL_CUSTOM_START + 86,
3164 EL_CUSTOM_START + 87,
3166 EL_CUSTOM_START + 88,
3167 EL_CUSTOM_START + 89,
3168 EL_CUSTOM_START + 90,
3169 EL_CUSTOM_START + 91,
3171 EL_CUSTOM_START + 92,
3172 EL_CUSTOM_START + 93,
3173 EL_CUSTOM_START + 94,
3174 EL_CUSTOM_START + 95,
3176 EL_CUSTOM_START + 96,
3177 EL_CUSTOM_START + 97,
3178 EL_CUSTOM_START + 98,
3179 EL_CUSTOM_START + 99,
3181 EL_CUSTOM_START + 100,
3182 EL_CUSTOM_START + 101,
3183 EL_CUSTOM_START + 102,
3184 EL_CUSTOM_START + 103,
3186 EL_CUSTOM_START + 104,
3187 EL_CUSTOM_START + 105,
3188 EL_CUSTOM_START + 106,
3189 EL_CUSTOM_START + 107,
3191 EL_CUSTOM_START + 108,
3192 EL_CUSTOM_START + 109,
3193 EL_CUSTOM_START + 110,
3194 EL_CUSTOM_START + 111,
3196 EL_CUSTOM_START + 112,
3197 EL_CUSTOM_START + 113,
3198 EL_CUSTOM_START + 114,
3199 EL_CUSTOM_START + 115,
3201 EL_CUSTOM_START + 116,
3202 EL_CUSTOM_START + 117,
3203 EL_CUSTOM_START + 118,
3204 EL_CUSTOM_START + 119,
3206 EL_CUSTOM_START + 120,
3207 EL_CUSTOM_START + 121,
3208 EL_CUSTOM_START + 122,
3209 EL_CUSTOM_START + 123,
3211 EL_CUSTOM_START + 124,
3212 EL_CUSTOM_START + 125,
3213 EL_CUSTOM_START + 126,
3214 EL_CUSTOM_START + 127
3216 static int *editor_hl_custom_ptr = editor_hl_custom;
3217 static int *editor_el_custom_ptr = editor_el_custom;
3218 static int num_editor_hl_custom = SIZEOF_ARRAY_INT(editor_hl_custom);
3219 static int num_editor_el_custom = SIZEOF_ARRAY_INT(editor_el_custom);
3221 static int editor_hl_custom_more[] =
3225 static int editor_el_custom_more[] =
3227 EL_CUSTOM_START + 128,
3228 EL_CUSTOM_START + 129,
3229 EL_CUSTOM_START + 130,
3230 EL_CUSTOM_START + 131,
3232 EL_CUSTOM_START + 132,
3233 EL_CUSTOM_START + 133,
3234 EL_CUSTOM_START + 134,
3235 EL_CUSTOM_START + 135,
3237 EL_CUSTOM_START + 136,
3238 EL_CUSTOM_START + 137,
3239 EL_CUSTOM_START + 138,
3240 EL_CUSTOM_START + 139,
3242 EL_CUSTOM_START + 140,
3243 EL_CUSTOM_START + 141,
3244 EL_CUSTOM_START + 142,
3245 EL_CUSTOM_START + 143,
3247 EL_CUSTOM_START + 144,
3248 EL_CUSTOM_START + 145,
3249 EL_CUSTOM_START + 146,
3250 EL_CUSTOM_START + 147,
3252 EL_CUSTOM_START + 148,
3253 EL_CUSTOM_START + 149,
3254 EL_CUSTOM_START + 150,
3255 EL_CUSTOM_START + 151,
3257 EL_CUSTOM_START + 152,
3258 EL_CUSTOM_START + 153,
3259 EL_CUSTOM_START + 154,
3260 EL_CUSTOM_START + 155,
3262 EL_CUSTOM_START + 156,
3263 EL_CUSTOM_START + 157,
3264 EL_CUSTOM_START + 158,
3265 EL_CUSTOM_START + 159,
3267 EL_CUSTOM_START + 160,
3268 EL_CUSTOM_START + 161,
3269 EL_CUSTOM_START + 162,
3270 EL_CUSTOM_START + 163,
3272 EL_CUSTOM_START + 164,
3273 EL_CUSTOM_START + 165,
3274 EL_CUSTOM_START + 166,
3275 EL_CUSTOM_START + 167,
3277 EL_CUSTOM_START + 168,
3278 EL_CUSTOM_START + 169,
3279 EL_CUSTOM_START + 170,
3280 EL_CUSTOM_START + 171,
3282 EL_CUSTOM_START + 172,
3283 EL_CUSTOM_START + 173,
3284 EL_CUSTOM_START + 174,
3285 EL_CUSTOM_START + 175,
3287 EL_CUSTOM_START + 176,
3288 EL_CUSTOM_START + 177,
3289 EL_CUSTOM_START + 178,
3290 EL_CUSTOM_START + 179,
3292 EL_CUSTOM_START + 180,
3293 EL_CUSTOM_START + 181,
3294 EL_CUSTOM_START + 182,
3295 EL_CUSTOM_START + 183,
3297 EL_CUSTOM_START + 184,
3298 EL_CUSTOM_START + 185,
3299 EL_CUSTOM_START + 186,
3300 EL_CUSTOM_START + 187,
3302 EL_CUSTOM_START + 188,
3303 EL_CUSTOM_START + 189,
3304 EL_CUSTOM_START + 190,
3305 EL_CUSTOM_START + 191,
3307 EL_CUSTOM_START + 192,
3308 EL_CUSTOM_START + 193,
3309 EL_CUSTOM_START + 194,
3310 EL_CUSTOM_START + 195,
3312 EL_CUSTOM_START + 196,
3313 EL_CUSTOM_START + 197,
3314 EL_CUSTOM_START + 198,
3315 EL_CUSTOM_START + 199,
3317 EL_CUSTOM_START + 200,
3318 EL_CUSTOM_START + 201,
3319 EL_CUSTOM_START + 202,
3320 EL_CUSTOM_START + 203,
3322 EL_CUSTOM_START + 204,
3323 EL_CUSTOM_START + 205,
3324 EL_CUSTOM_START + 206,
3325 EL_CUSTOM_START + 207,
3327 EL_CUSTOM_START + 208,
3328 EL_CUSTOM_START + 209,
3329 EL_CUSTOM_START + 210,
3330 EL_CUSTOM_START + 211,
3332 EL_CUSTOM_START + 212,
3333 EL_CUSTOM_START + 213,
3334 EL_CUSTOM_START + 214,
3335 EL_CUSTOM_START + 215,
3337 EL_CUSTOM_START + 216,
3338 EL_CUSTOM_START + 217,
3339 EL_CUSTOM_START + 218,
3340 EL_CUSTOM_START + 219,
3342 EL_CUSTOM_START + 220,
3343 EL_CUSTOM_START + 221,
3344 EL_CUSTOM_START + 222,
3345 EL_CUSTOM_START + 223,
3347 EL_CUSTOM_START + 224,
3348 EL_CUSTOM_START + 225,
3349 EL_CUSTOM_START + 226,
3350 EL_CUSTOM_START + 227,
3352 EL_CUSTOM_START + 228,
3353 EL_CUSTOM_START + 229,
3354 EL_CUSTOM_START + 230,
3355 EL_CUSTOM_START + 231,
3357 EL_CUSTOM_START + 232,
3358 EL_CUSTOM_START + 233,
3359 EL_CUSTOM_START + 234,
3360 EL_CUSTOM_START + 235,
3362 EL_CUSTOM_START + 236,
3363 EL_CUSTOM_START + 237,
3364 EL_CUSTOM_START + 238,
3365 EL_CUSTOM_START + 239,
3367 EL_CUSTOM_START + 240,
3368 EL_CUSTOM_START + 241,
3369 EL_CUSTOM_START + 242,
3370 EL_CUSTOM_START + 243,
3372 EL_CUSTOM_START + 244,
3373 EL_CUSTOM_START + 245,
3374 EL_CUSTOM_START + 246,
3375 EL_CUSTOM_START + 247,
3377 EL_CUSTOM_START + 248,
3378 EL_CUSTOM_START + 249,
3379 EL_CUSTOM_START + 250,
3380 EL_CUSTOM_START + 251,
3382 EL_CUSTOM_START + 252,
3383 EL_CUSTOM_START + 253,
3384 EL_CUSTOM_START + 254,
3385 EL_CUSTOM_START + 255
3387 static int *editor_hl_custom_more_ptr = editor_hl_custom_more;
3388 static int *editor_el_custom_more_ptr = editor_el_custom_more;
3389 static int num_editor_hl_custom_more = SIZEOF_ARRAY_INT(editor_hl_custom_more);
3390 static int num_editor_el_custom_more = SIZEOF_ARRAY_INT(editor_el_custom_more);
3392 static int editor_hl_custom_special[] =
3396 static int editor_el_custom_special[] =
3403 static int *editor_hl_custom_special_ptr = editor_hl_custom_special;
3404 static int *editor_el_custom_special_ptr = editor_el_custom_special;
3405 static int num_editor_hl_custom_special = SIZEOF_ARRAY_INT(editor_hl_custom_special);
3406 static int num_editor_el_custom_special = SIZEOF_ARRAY_INT(editor_el_custom_special);
3408 static int editor_hl_group[] =
3431 static int editor_el_group[] =
3445 EL_GROUP_START + 10,
3446 EL_GROUP_START + 11,
3448 EL_GROUP_START + 12,
3449 EL_GROUP_START + 13,
3450 EL_GROUP_START + 14,
3453 static int *editor_hl_group_ptr = editor_hl_group;
3454 static int *editor_el_group_ptr = editor_el_group;
3455 static int num_editor_hl_group = SIZEOF_ARRAY_INT(editor_hl_group);
3456 static int num_editor_el_group = SIZEOF_ARRAY_INT(editor_el_group);
3458 static int editor_hl_group_more[] =
3462 static int editor_el_group_more[] =
3464 EL_GROUP_START + 16,
3465 EL_GROUP_START + 17,
3466 EL_GROUP_START + 18,
3467 EL_GROUP_START + 19,
3469 EL_GROUP_START + 20,
3470 EL_GROUP_START + 21,
3471 EL_GROUP_START + 22,
3472 EL_GROUP_START + 23,
3474 EL_GROUP_START + 24,
3475 EL_GROUP_START + 25,
3476 EL_GROUP_START + 26,
3477 EL_GROUP_START + 27,
3479 EL_GROUP_START + 28,
3480 EL_GROUP_START + 29,
3481 EL_GROUP_START + 30,
3484 static int *editor_hl_group_more_ptr = editor_hl_group_more;
3485 static int *editor_el_group_more_ptr = editor_el_group_more;
3486 static int num_editor_hl_group_more = SIZEOF_ARRAY_INT(editor_hl_group_more);
3487 static int num_editor_el_group_more = SIZEOF_ARRAY_INT(editor_el_group_more);
3489 static int editor_hl_user_defined[] =
3507 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
3508 static int *editor_el_user_defined_ptr = NULL;
3509 static int num_editor_hl_user_defined=SIZEOF_ARRAY_INT(editor_hl_user_defined);
3510 static int num_editor_el_user_defined = 0;
3512 static int editor_hl_empty[] = { };
3513 static int editor_el_empty[ED_NUM_ELEMENTLIST_BUTTONS];
3515 static int *editor_hl_empty_ptr = editor_hl_empty;
3516 static int *editor_el_empty_ptr = editor_el_empty;
3517 static int num_editor_hl_empty = 0;
3518 static int num_editor_el_empty = 0; /* dynamically determined, if needed */
3520 static boolean use_el_empty = FALSE;
3522 static int *editor_elements = NULL; /* dynamically allocated */
3523 static int num_editor_elements = 0; /* dynamically determined */
3527 boolean *setup_value;
3529 int **headline_list;
3530 int *headline_list_size;
3533 int *element_list_size;
3535 boolean last_setup_value;
3537 editor_elements_info[] =
3540 &setup.editor.el_boulderdash,
3541 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
3542 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
3545 &setup.editor.el_emerald_mine,
3546 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
3547 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
3550 &setup.editor.el_more,
3551 &editor_hl_more_ptr, &num_editor_hl_more,
3552 &editor_el_more_ptr, &num_editor_el_more
3555 &setup.editor.el_sokoban,
3556 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
3557 &editor_el_sokoban_ptr, &num_editor_el_sokoban
3560 &setup.editor.el_supaplex,
3561 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
3562 &editor_el_supaplex_ptr, &num_editor_el_supaplex
3565 &setup.editor.el_diamond_caves,
3566 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
3567 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
3570 &setup.editor.el_dx_boulderdash,
3571 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
3572 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
3575 &setup.editor.el_chars,
3576 &editor_hl_chars_ptr, &num_editor_hl_chars,
3577 &editor_el_chars_ptr, &num_editor_el_chars
3580 &setup.editor.el_custom,
3581 &editor_hl_custom_ptr, &num_editor_hl_custom,
3582 &editor_el_custom_ptr, &num_editor_el_custom
3585 &setup.editor.el_custom_more,
3586 &editor_hl_custom_more_ptr, &num_editor_hl_custom_more,
3587 &editor_el_custom_more_ptr, &num_editor_el_custom_more
3590 &setup.editor.el_custom,
3591 &editor_hl_custom_special_ptr, &num_editor_hl_custom_special,
3592 &editor_el_custom_special_ptr, &num_editor_el_custom_special
3595 &setup.editor.el_custom,
3596 &editor_hl_group_ptr, &num_editor_hl_group,
3597 &editor_el_group_ptr, &num_editor_el_group
3600 &setup.editor.el_custom_more,
3601 &editor_hl_group_more_ptr, &num_editor_hl_group_more,
3602 &editor_el_group_more_ptr, &num_editor_el_group_more
3605 &setup.editor.el_user_defined,
3606 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
3607 &editor_el_user_defined_ptr, &num_editor_el_user_defined
3611 &editor_hl_empty_ptr, &num_editor_hl_empty,
3612 &editor_el_empty_ptr, &num_editor_el_empty,
3626 short element_mapped;
3628 forum_sketch_element_mapping[] =
3630 { EL_WALL_SLIPPERY, EL_WALL },
3631 { EL_EXPANDABLE_WALL, EL_WALL },
3632 { EL_EXPANDABLE_WALL_HORIZONTAL, EL_WALL },
3633 { EL_EXPANDABLE_WALL_VERTICAL, EL_WALL },
3634 { EL_EXPANDABLE_WALL_ANY, EL_WALL },
3635 { EL_WALL_EMERALD, EL_WALL },
3636 { EL_WALL_DIAMOND, EL_WALL },
3637 { EL_WALL_BD_DIAMOND, EL_WALL },
3638 { EL_WALL_EMERALD_YELLOW, EL_WALL },
3639 { EL_WALL_EMERALD_RED, EL_WALL },
3640 { EL_WALL_EMERALD_PURPLE, EL_WALL },
3641 { EL_ACID_POOL_TOPLEFT, EL_WALL },
3642 { EL_ACID_POOL_TOPRIGHT, EL_WALL },
3643 { EL_ACID_POOL_BOTTOMLEFT, EL_WALL },
3644 { EL_ACID_POOL_BOTTOM, EL_WALL },
3645 { EL_ACID_POOL_BOTTOMRIGHT, EL_WALL },
3646 { EL_BD_WALL, EL_WALL },
3648 { EL_BD_ROCK, EL_ROCK },
3650 { EL_SP_ZONK, EL_ROCK },
3651 { EL_SP_BASE, EL_SAND },
3652 { EL_SP_MURPHY, EL_PLAYER_1 },
3653 { EL_SP_INFOTRON, EL_EMERALD },
3654 { EL_SP_HARDWARE_GRAY, EL_STEELWALL },
3655 { EL_SP_EXIT_CLOSED, EL_EXIT_OPEN },
3656 { EL_SP_DISK_ORANGE, EL_BOMB },
3657 { EL_SP_DISK_RED, EL_BOMB },
3658 { EL_SP_DISK_YELLOW, EL_BOMB },
3659 { EL_SP_PORT_RIGHT, EL_GATE_1_GRAY },
3660 { EL_SP_PORT_DOWN, EL_GATE_1_GRAY },
3661 { EL_SP_PORT_LEFT, EL_GATE_1_GRAY },
3662 { EL_SP_PORT_UP, EL_GATE_1_GRAY },
3663 { EL_SP_GRAVITY_PORT_RIGHT, EL_GATE_1_GRAY },
3664 { EL_SP_GRAVITY_PORT_DOWN, EL_GATE_1_GRAY },
3665 { EL_SP_GRAVITY_PORT_LEFT, EL_GATE_1_GRAY },
3666 { EL_SP_GRAVITY_PORT_UP, EL_GATE_1_GRAY },
3667 { EL_SP_PORT_VERTICAL, EL_GATE_1_GRAY },
3668 { EL_SP_PORT_HORIZONTAL, EL_GATE_1_GRAY },
3669 { EL_SP_PORT_ANY, EL_GATE_1_GRAY },
3670 { EL_SP_SNIKSNAK, EL_BUG },
3671 { EL_SP_ELECTRON, EL_SPACESHIP },
3672 { EL_SP_CHIP_SINGLE, EL_WALL },
3673 { EL_SP_CHIP_LEFT, EL_WALL },
3674 { EL_SP_CHIP_RIGHT, EL_WALL },
3675 { EL_SP_CHIP_TOP, EL_WALL },
3676 { EL_SP_CHIP_BOTTOM, EL_WALL },
3677 { EL_SP_HARDWARE_BASE_1, EL_STEELWALL },
3678 { EL_SP_HARDWARE_GREEN, EL_STEELWALL },
3679 { EL_SP_HARDWARE_BLUE, EL_STEELWALL },
3680 { EL_SP_HARDWARE_RED, EL_STEELWALL },
3681 { EL_SP_HARDWARE_YELLOW, EL_STEELWALL },
3682 { EL_SP_HARDWARE_BASE_2, EL_STEELWALL },
3683 { EL_SP_HARDWARE_BASE_3, EL_STEELWALL },
3684 { EL_SP_HARDWARE_BASE_3, EL_STEELWALL },
3685 { EL_SP_HARDWARE_BASE_4, EL_STEELWALL },
3686 { EL_SP_HARDWARE_BASE_5, EL_STEELWALL },
3687 { EL_SP_HARDWARE_BASE_6, EL_STEELWALL },
3689 { EL_STEELWALL_SLIPPERY, EL_STEELWALL },
3691 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
3693 { EL_DIAMOND, EL_EMERALD },
3694 { EL_BD_DIAMOND, EL_EMERALD },
3695 { EL_EMERALD_YELLOW, EL_EMERALD },
3696 { EL_EMERALD_RED, EL_EMERALD },
3697 { EL_EMERALD_PURPLE, EL_EMERALD },
3699 { EL_AMOEBA_DEAD, EL_AMOEBA },
3700 { EL_AMOEBA_DROP, EL_AMOEBA },
3701 { EL_AMOEBA_WET, EL_AMOEBA },
3702 { EL_AMOEBA_DRY, EL_AMOEBA },
3703 { EL_AMOEBA_FULL, EL_AMOEBA },
3704 { EL_BD_AMOEBA, EL_AMOEBA },
3705 { EL_AMOEBA_TO_DIAMOND, EL_AMOEBA },
3707 { EL_DYNAMITE_ACTIVE, EL_DYNAMITE },
3709 { EL_GATE_2_GRAY, EL_GATE_1_GRAY },
3710 { EL_GATE_3_GRAY, EL_GATE_1_GRAY },
3711 { EL_GATE_4_GRAY, EL_GATE_1_GRAY },
3713 { EL_EM_KEY_1, EL_KEY_1 },
3714 { EL_EM_KEY_2, EL_KEY_2 },
3715 { EL_EM_KEY_3, EL_KEY_3 },
3716 { EL_EM_KEY_4, EL_KEY_4 },
3718 { EL_EM_GATE_1, EL_GATE_1 },
3719 { EL_EM_GATE_2, EL_GATE_2 },
3720 { EL_EM_GATE_3, EL_GATE_3 },
3721 { EL_EM_GATE_4, EL_GATE_4 },
3723 { EL_EM_GATE_1_GRAY, EL_GATE_1_GRAY },
3724 { EL_EM_GATE_2_GRAY, EL_GATE_1_GRAY },
3725 { EL_EM_GATE_3_GRAY, EL_GATE_1_GRAY },
3726 { EL_EM_GATE_4_GRAY, EL_GATE_1_GRAY },
3728 { EL_INVISIBLE_SAND, EL_EMPTY },
3729 { EL_INVISIBLE_WALL, EL_EMPTY },
3730 { EL_INVISIBLE_STEELWALL, EL_EMPTY },
3732 { EL_PACMAN, EL_YAMYAM },
3733 { EL_DARK_YAMYAM, EL_YAMYAM },
3735 { EL_BD_MAGIC_WALL, EL_MAGIC_WALL },
3737 { EL_DYNABOMB_INCREASE_NUMBER, EL_BOMB },
3738 { EL_DYNABOMB_INCREASE_SIZE, EL_BOMB },
3739 { EL_DYNABOMB_INCREASE_POWER, EL_BOMB },
3740 { EL_BLACK_ORB, EL_BOMB },
3741 { EL_DX_SUPABOMB, EL_BOMB },
3743 { EL_SOKOBAN_OBJECT, EL_KEY_1 },
3744 { EL_SOKOBAN_FIELD_EMPTY, EL_GATE_1_GRAY },
3745 { EL_SOKOBAN_FIELD_FULL, EL_GATE_1 },
3746 { EL_SOKOBAN_FIELD_PLAYER, EL_PLAYER_1 },
3748 { EL_BD_BUTTERFLY_RIGHT, EL_BD_BUTTERFLY },
3749 { EL_BD_BUTTERFLY_UP, EL_BD_BUTTERFLY },
3750 { EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY },
3751 { EL_BD_BUTTERFLY_DOWN, EL_BD_BUTTERFLY },
3753 { EL_BD_FIREFLY_RIGHT, EL_BD_FIREFLY },
3754 { EL_BD_FIREFLY_UP, EL_BD_FIREFLY },
3755 { EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY },
3756 { EL_BD_FIREFLY_DOWN, EL_BD_FIREFLY },
3758 { EL_PLAYER_2, EL_PLAYER_1 },
3759 { EL_PLAYER_3, EL_PLAYER_1 },
3760 { EL_PLAYER_4, EL_PLAYER_1 },
3762 { EL_BUG_RIGHT, EL_BUG },
3763 { EL_BUG_UP, EL_BUG },
3764 { EL_BUG_LEFT, EL_BUG },
3765 { EL_BUG_DOWN, EL_BUG },
3767 { EL_SPACESHIP_RIGHT, EL_SPACESHIP },
3768 { EL_SPACESHIP_UP, EL_SPACESHIP },
3769 { EL_SPACESHIP_LEFT, EL_SPACESHIP },
3770 { EL_SPACESHIP_DOWN, EL_SPACESHIP },
3772 { EL_PACMAN_RIGHT, EL_YAMYAM },
3773 { EL_PACMAN_UP, EL_YAMYAM },
3774 { EL_PACMAN_LEFT, EL_YAMYAM },
3775 { EL_PACMAN_DOWN, EL_YAMYAM },
3783 char *element_string;
3785 forum_sketch_element_strings[] =
3787 { EL_PLAYER_1, "p" },
3791 { EL_EMERALD, "e" },
3793 { EL_SPACESHIP, "h" },
3794 { EL_BD_FIREFLY, "f" },
3795 { EL_BD_BUTTERFLY, "b" },
3799 { EL_STEELWALL, "t" },
3800 { EL_MAGIC_WALL, "m" },
3801 { EL_EXIT_OPEN, "x" },
3802 { EL_DYNAMITE, "d" },
3811 { EL_GATE_1_GRAY, "9" },
3814 { EL_ROBOT_WHEEL, "0" },
3816 { EL_CUSTOM_1, "c" },
3817 { EL_CHAR_QUESTION, "?" },
3826 -----------------------------------------------------------------------------
3828 -----------------------------------------------------------------------------
3831 static int getMaxInfoTextLength()
3833 return (SXSIZE / getFontWidth(FONT_TEXT_2));
3836 static int getTextWidthForGadget(char *text)
3841 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
3844 static int getTextWidthForDrawingArea(char *text)
3849 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
3852 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
3854 return (gi->x + gi->width + getTextWidthForGadget(text));
3857 static char *getElementInfoText(int element)
3859 char *info_text = NULL;
3861 if (element < NUM_FILE_ELEMENTS)
3863 if (strlen(element_info[element].description) > 0)
3864 info_text = element_info[element].description;
3865 else if (element_info[element].custom_description != NULL)
3866 info_text = element_info[element].custom_description;
3867 else if (element_info[element].editor_description != NULL)
3868 info_text = element_info[element].editor_description;
3871 if (info_text == NULL)
3872 info_text = INFOTEXT_UNKNOWN_ELEMENT;
3877 static void ReinitializeElementList()
3879 static boolean initialized = FALSE;
3883 checked_free(editor_elements);
3887 /* initialize optional user defined element list */
3888 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
3889 &num_editor_el_user_defined);
3891 /* initialize list of empty elements (used for padding, if needed) */
3892 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
3893 editor_el_empty[i] = EL_EMPTY;
3895 /* do some sanity checks for each element from element list */
3896 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
3898 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
3900 int element = (*editor_elements_info[i].element_list)[j];
3902 if (element >= NUM_FILE_ELEMENTS)
3903 Error(ERR_WARN, "editor element %d is runtime element", element);
3905 if (strcmp(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT) == 0)
3906 Error(ERR_WARN, "no element description for element %d", element);
3913 num_editor_elements = 0;
3914 use_el_empty = FALSE;
3916 /* determine size of element list */
3917 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
3919 if (*editor_elements_info[i].setup_value)
3921 if (setup.editor.el_headlines)
3922 num_editor_elements += *editor_elements_info[i].headline_list_size;
3924 num_editor_elements += *editor_elements_info[i].element_list_size;
3928 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
3930 /* offer at least as many elements as element buttons exist */
3931 use_el_empty = TRUE;
3932 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
3934 num_editor_elements += num_editor_el_empty;
3937 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
3939 /* fill element list */
3940 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
3942 if (*editor_elements_info[i].setup_value)
3944 if (setup.editor.el_headlines)
3945 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
3946 editor_elements[pos++] = (*editor_elements_info[i].headline_list)[j];
3948 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
3949 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
3953 /* correct position of element list scrollbar */
3954 if (element_shift < 0)
3956 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
3957 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
3960 void PrintEditorElementList()
3962 boolean *stop = &setup.editor.el_user_defined;
3965 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
3967 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
3969 int element = (*editor_elements_info[i].headline_list)[j];
3971 printf("# %s\n", element_info[element].token_name);
3977 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
3979 int element = (*editor_elements_info[i].element_list)[j];
3981 printf("# %s\n", element_info[element].token_name);
3989 static void ReinitializeElementListButtons()
3991 static boolean last_setup_value_headlines = FALSE;
3992 static boolean initialization_needed = TRUE;
3995 if (!initialization_needed) /* check if editor element setup has changed */
3997 if (last_setup_value_headlines != setup.editor.el_headlines)
3998 initialization_needed = TRUE;
4000 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4001 if (editor_elements_info[i].last_setup_value !=
4002 *editor_elements_info[i].setup_value)
4003 initialization_needed = TRUE;
4006 if (!initialization_needed)
4009 FreeLevelEditorGadgets();
4010 CreateLevelEditorGadgets();
4012 /* store current setup values for next invocation of this function */
4013 last_setup_value_headlines = setup.editor.el_headlines;
4014 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4015 editor_elements_info[i].last_setup_value =
4016 *editor_elements_info[i].setup_value;
4018 initialization_needed = FALSE;
4021 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
4024 int border_graphic =
4025 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
4028 int num_mini_tilex = width / MINI_TILEX + 1;
4029 int num_mini_tiley = height / MINI_TILEY + 1;
4032 getMiniGraphicSource(border_graphic, &src_bitmap, &src_x, &src_y);
4034 for (y = 0; y < num_mini_tiley; y++)
4035 for (x = 0; x < num_mini_tilex; x++)
4036 BlitBitmap(src_bitmap, drawto, src_x, src_y, MINI_TILEX, MINI_TILEY,
4037 dest_x - MINI_TILEX / 2 + x * MINI_TILEX,
4038 dest_y - MINI_TILEY / 2 + y * MINI_TILEY);
4040 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
4043 static void DrawDrawingArea(int id)
4045 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
4048 if (id == ED_DRAWING_ID_RANDOM_BACKGROUND)
4049 DrawMiniGraphicExt(drawto, gi->x, gi->y,
4050 el2edimg(random_placement_background_element));
4051 else if (id == ED_DRAWING_ID_AMOEBA_CONTENT)
4052 DrawMiniGraphicExt(drawto, gi->x, gi->y, el2edimg(level.amoeba_content));
4053 else if (id == ED_DRAWING_ID_CUSTOM_GRAPHIC)
4054 DrawMiniGraphicExt(drawto, gi->x, gi->y,
4055 el2edimg(custom_element.gfx_element));
4056 else if (id == ED_DRAWING_ID_CUSTOM_CONTENT)
4057 for (y = 0; y < 3; y++)
4058 for (x = 0; x < 3; x++)
4059 DrawMiniGraphicExt(drawto,
4060 gi->x + x * MINI_TILEX, gi->y + y * MINI_TILEY,
4061 el2edimg(custom_element.content[x][y]));
4062 else if (id == ED_DRAWING_ID_CUSTOM_MOVE_ENTER)
4063 DrawMiniGraphicExt(drawto, gi->x, gi->y,
4064 el2edimg(custom_element.move_enter_element));
4065 else if (id == ED_DRAWING_ID_CUSTOM_MOVE_LEAVE)
4066 DrawMiniGraphicExt(drawto, gi->x, gi->y,
4067 el2edimg(custom_element.move_leave_element));
4068 else if (id == ED_DRAWING_ID_CUSTOM_CHANGE_TARGET)
4069 DrawMiniGraphicExt(drawto, gi->x, gi->y,
4070 el2edimg(custom_element_change.target_element));
4071 else if (id == ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT)
4072 for (y = 0; y < 3; y++)
4073 for (x = 0; x < 3; x++)
4074 DrawMiniGraphicExt(drawto,
4075 gi->x + x * MINI_TILEX, gi->y + y * MINI_TILEY,
4076 el2edimg(custom_element_change.target_content[x][y]));
4077 else if (id == ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER)
4078 DrawMiniGraphicExt(drawto, gi->x, gi->y,
4079 el2edimg(custom_element_change.trigger_element));
4080 else if (id == ED_DRAWING_ID_GROUP_CONTENT)
4081 for (x = 0; x < group_element_info.num_elements; x++)
4082 DrawMiniGraphicExt(drawto, gi->x + x * MINI_TILEX, gi->y,
4083 el2edimg(group_element_info.element[x]));
4084 else if (id >= ED_DRAWING_ID_ELEMENT_CONTENT_0 &&
4085 id <= ED_DRAWING_ID_ELEMENT_CONTENT_7)
4087 int nr = id - ED_DRAWING_ID_ELEMENT_CONTENT_0;
4089 for (y = 0; y < 3; y++)
4090 for (x = 0; x < 3; x++)
4091 DrawMiniGraphicExt(drawto,
4092 gi->x + x * MINI_TILEX, gi->y + y * MINI_TILEY,
4093 el2edimg(level.yamyam_content[nr][x][y]));
4097 static void ScrollMiniLevel(int from_x, int from_y, int scroll)
4100 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
4101 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
4103 BlitBitmap(drawto, drawto,
4104 SX + (dx == -1 ? MINI_TILEX : 0),
4105 SY + (dy == -1 ? MINI_TILEY : 0),
4106 (ed_fieldx * MINI_TILEX) - (dx != 0 ? MINI_TILEX : 0),
4107 (ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0),
4108 SX + (dx == +1 ? MINI_TILEX : 0),
4109 SY + (dy == +1 ? MINI_TILEY : 0));
4112 x = (dx == 1 ? 0 : ed_fieldx - 1);
4113 for (y = 0; y < ed_fieldy; y++)
4114 DrawMiniElementOrWall(x, y, from_x, from_y);
4118 y = (dy == 1 ? 0 : ed_fieldy - 1);
4119 for (x = 0; x < ed_fieldx; x++)
4120 DrawMiniElementOrWall(x, y, from_x, from_y);
4123 redraw_mask |= REDRAW_FIELD;
4127 static void CreateControlButtons()
4129 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4130 struct GadgetInfo *gi;
4131 unsigned long event_mask;
4134 /* create toolbox buttons */
4135 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
4139 int gd_xoffset, gd_yoffset;
4140 int gd_x1, gd_x2, gd_y1, gd_y2;
4142 int radio_button_nr;
4145 if (id == GADGET_ID_SINGLE_ITEMS ||
4146 id == GADGET_ID_CONNECTED_ITEMS ||
4147 id == GADGET_ID_LINE ||
4148 id == GADGET_ID_ARC ||
4149 id == GADGET_ID_TEXT ||
4150 id == GADGET_ID_RECTANGLE ||
4151 id == GADGET_ID_FILLED_BOX ||
4152 id == GADGET_ID_FLOOD_FILL ||
4153 id == GADGET_ID_GRAB_BRUSH ||
4154 id == GADGET_ID_PICK_ELEMENT ||
4155 id == GADGET_ID_CUSTOM_COPY_FROM ||
4156 id == GADGET_ID_CUSTOM_COPY_TO ||
4157 id == GADGET_ID_CUSTOM_EXCHANGE)
4159 button_type = GD_TYPE_RADIO_BUTTON;
4160 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
4161 checked = (id == drawing_function ? TRUE : FALSE);
4162 event_mask = GD_EVENT_PRESSED;
4166 button_type = GD_TYPE_NORMAL_BUTTON;
4167 radio_button_nr = RADIO_NR_NONE;
4170 if (id == GADGET_ID_WRAP_LEFT ||
4171 id == GADGET_ID_WRAP_RIGHT ||
4172 id == GADGET_ID_WRAP_UP ||
4173 id == GADGET_ID_WRAP_DOWN)
4174 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
4176 event_mask = GD_EVENT_RELEASED;
4179 if (id < ED_NUM_CTRL1_BUTTONS)
4181 int x = i % ED_CTRL1_BUTTONS_HORIZ;
4182 int y = i / ED_CTRL1_BUTTONS_HORIZ;
4184 gd_xoffset = ED_CTRL1_BUTTONS_XPOS + x * ED_CTRL1_BUTTON_XSIZE;
4185 gd_yoffset = ED_CTRL1_BUTTONS_YPOS + y * ED_CTRL1_BUTTON_YSIZE;
4186 width = ED_CTRL1_BUTTON_XSIZE;
4187 height = ED_CTRL1_BUTTON_YSIZE;
4189 gd_x1 = DOOR_GFX_PAGEX8 + gd_xoffset;
4190 gd_x2 = DOOR_GFX_PAGEX7 + gd_xoffset;
4191 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL1_BUTTONS_GFX_YPOS + gd_yoffset;
4192 gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL1_BUTTONS_ALT_GFX_YPOS + gd_yoffset;
4194 else if (id < ED_NUM_CTRL1_2_BUTTONS)
4196 int x = (i - ED_NUM_CTRL1_BUTTONS) % ED_CTRL2_BUTTONS_HORIZ;
4197 int y = (i - ED_NUM_CTRL1_BUTTONS) / ED_CTRL2_BUTTONS_HORIZ;
4199 gd_xoffset = ED_CTRL2_BUTTONS_XPOS + x * ED_CTRL2_BUTTON_XSIZE;
4200 gd_yoffset = ED_CTRL2_BUTTONS_YPOS + y * ED_CTRL2_BUTTON_YSIZE;
4201 width = ED_CTRL2_BUTTON_XSIZE;
4202 height = ED_CTRL2_BUTTON_YSIZE;
4204 gd_x1 = DOOR_GFX_PAGEX8 + gd_xoffset;
4205 gd_x2 = DOOR_GFX_PAGEX7 + gd_xoffset;
4206 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL2_BUTTONS_GFX_YPOS + gd_yoffset;
4207 gd_y2 = 0; /* no alternative graphic for these buttons */
4209 else if (id < ED_NUM_CTRL1_3_BUTTONS)
4211 int x = (i - ED_NUM_CTRL1_2_BUTTONS) % ED_CTRL3_BUTTONS_HORIZ + 1;
4212 int y = (i - ED_NUM_CTRL1_2_BUTTONS) / ED_CTRL3_BUTTONS_HORIZ;
4214 gd_xoffset = ED_CTRL3_BUTTONS_XPOS + x * ED_CTRL3_BUTTON_XSIZE;
4215 gd_yoffset = ED_CTRL3_BUTTONS_YPOS + y * ED_CTRL3_BUTTON_YSIZE;
4216 width = ED_CTRL3_BUTTON_XSIZE;
4217 height = ED_CTRL3_BUTTON_YSIZE;
4219 gd_x1 = DOOR_GFX_PAGEX6 + gd_xoffset;
4220 gd_x2 = DOOR_GFX_PAGEX5 + gd_xoffset;
4221 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL3_BUTTONS_GFX_YPOS + gd_yoffset;
4222 gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL3_BUTTONS_ALT_GFX_YPOS + gd_yoffset;
4226 int x = (i - ED_NUM_CTRL1_3_BUTTONS) % ED_CTRL4_BUTTONS_HORIZ;
4227 int y = (i - ED_NUM_CTRL1_3_BUTTONS) / ED_CTRL4_BUTTONS_HORIZ + 3;
4229 gd_xoffset = ED_CTRL4_BUTTONS_XPOS + x * ED_CTRL4_BUTTON_XSIZE;
4230 gd_yoffset = ED_CTRL4_BUTTONS_YPOS + y * ED_CTRL4_BUTTON_YSIZE;
4231 width = ED_CTRL4_BUTTON_XSIZE;
4232 height = ED_CTRL4_BUTTON_YSIZE;
4234 gd_x1 = DOOR_GFX_PAGEX6 + ED_CTRL4_BUTTONS_GFX_XPOS + gd_xoffset;
4235 gd_x2 = DOOR_GFX_PAGEX5 + ED_CTRL4_BUTTONS_GFX_XPOS + gd_xoffset;
4236 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL4_BUTTONS_GFX_YPOS + gd_yoffset;
4237 gd_y2 = 0; /* no alternative graphic for these buttons */
4240 gi = CreateGadget(GDI_CUSTOM_ID, id,
4241 GDI_CUSTOM_TYPE_ID, i,
4242 GDI_INFO_TEXT, control_info[i].text,
4243 GDI_X, EX + gd_xoffset,
4244 GDI_Y, EY + gd_yoffset,
4247 GDI_TYPE, button_type,
4248 GDI_STATE, GD_BUTTON_UNPRESSED,
4249 GDI_RADIO_NR, radio_button_nr,
4250 GDI_CHECKED, checked,
4251 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
4252 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y1,
4253 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2,
4254 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
4255 GDI_EVENT_MASK, event_mask,
4256 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4257 GDI_CALLBACK_ACTION, HandleControlButtons,
4261 Error(ERR_EXIT, "cannot create gadget");
4263 level_editor_gadget[id] = gi;
4266 /* create buttons for scrolling of drawing area and element list */
4267 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
4269 int id = scrollbutton_info[i].gadget_id;
4270 int x, y, width, height;
4271 int gd_x1, gd_x2, gd_y1, gd_y2;
4273 x = scrollbutton_info[i].x;
4274 y = scrollbutton_info[i].y;
4276 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
4278 if (id == GADGET_ID_SCROLL_LIST_UP ||
4279 id == GADGET_ID_SCROLL_LIST_DOWN)
4283 width = ED_SCROLLBUTTON2_XSIZE;
4284 height = ED_SCROLLBUTTON2_YSIZE;
4285 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].gd_x;
4286 gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].gd_y;
4287 gd_x2 = gd_x1 - ED_SCROLLBUTTON2_XSIZE;
4294 width = ED_SCROLLBUTTON_XSIZE;
4295 height = ED_SCROLLBUTTON_YSIZE;
4296 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].gd_x;
4297 gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].gd_y;
4298 gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE;
4302 gi = CreateGadget(GDI_CUSTOM_ID, id,
4303 GDI_CUSTOM_TYPE_ID, i,
4304 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
4309 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
4310 GDI_STATE, GD_BUTTON_UNPRESSED,
4311 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
4312 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
4313 GDI_EVENT_MASK, event_mask,
4314 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4315 GDI_CALLBACK_ACTION, HandleControlButtons,
4319 Error(ERR_EXIT, "cannot create gadget");
4321 level_editor_gadget[id] = gi;
4324 /* create buttons for element list */
4325 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
4327 Bitmap *deco_bitmap;
4328 int deco_x, deco_y, deco_xpos, deco_ypos;
4329 int gd_xoffset, gd_yoffset;
4330 int gd_x1, gd_x2, gd_y;
4331 int x = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
4332 int y = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
4333 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
4334 int element = editor_elements[i];
4336 event_mask = GD_EVENT_RELEASED;
4338 gd_xoffset = ED_ELEMENTLIST_XPOS + x * ED_ELEMENTLIST_XSIZE;
4339 gd_yoffset = ED_ELEMENTLIST_YPOS + y * ED_ELEMENTLIST_YSIZE;
4341 gd_x1 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS + ED_ELEMENTLIST_XSIZE;
4342 gd_x2 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS;
4343 gd_y = DOOR_GFX_PAGEY1 + ED_ELEMENTLIST_YPOS;
4345 getMiniGraphicSource(el2edimg(element), &deco_bitmap, &deco_x, &deco_y);
4346 deco_xpos = (ED_ELEMENTLIST_XSIZE - MINI_TILEX) / 2;
4347 deco_ypos = (ED_ELEMENTLIST_YSIZE - MINI_TILEY) / 2;
4349 gi = CreateGadget(GDI_CUSTOM_ID, id,
4350 GDI_CUSTOM_TYPE_ID, i,
4351 GDI_INFO_TEXT, getElementInfoText(element),
4352 GDI_X, DX + gd_xoffset,
4353 GDI_Y, DY + gd_yoffset,
4354 GDI_WIDTH, ED_ELEMENTLIST_XSIZE,
4355 GDI_HEIGHT, ED_ELEMENTLIST_YSIZE,
4356 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
4357 GDI_STATE, GD_BUTTON_UNPRESSED,
4358 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
4359 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
4360 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
4361 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
4362 GDI_DECORATION_SIZE, MINI_TILEX, MINI_TILEY,
4363 GDI_DECORATION_SHIFTING, 1, 1,
4364 GDI_EVENT_MASK, event_mask,
4365 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4366 GDI_CALLBACK_ACTION, HandleControlButtons,
4370 Error(ERR_EXIT, "cannot create gadget");
4372 level_editor_gadget[id] = gi;
4376 static void CreateCounterButtons()
4378 int max_infotext_len = getMaxInfoTextLength();
4381 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
4384 int x = SX + counterbutton_info[i].x; /* down count button */
4385 int y = SY + counterbutton_info[i].y;
4387 /* determine horizontal position to the right of specified gadget */
4388 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
4389 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
4390 ED_GADGET_TEXT_DISTANCE);
4392 /* determine horizontal offset for leading text */
4393 if (counterbutton_info[i].text_left != NULL)
4394 x += getTextWidthForGadget(counterbutton_info[i].text_left);
4396 for (j = 0; j < 2; j++)
4398 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4399 struct GadgetInfo *gi;
4401 counterbutton_info[i].gadget_id_down :
4402 counterbutton_info[i].gadget_id_up);
4404 int gd_x, gd_x1, gd_x2, gd_y;
4406 unsigned long event_mask;
4407 char infotext[max_infotext_len + 1];
4409 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
4411 if (i == ED_COUNTER_ID_SELECT_LEVEL)
4414 ED_SCROLLBUTTON_ID_AREA_LEFT :
4415 ED_SCROLLBUTTON_ID_AREA_RIGHT);
4417 event_mask |= GD_EVENT_RELEASED;
4420 x += 2 * ED_GADGET_DISTANCE;
4421 y += ED_GADGET_DISTANCE;
4423 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[sid].gd_x;
4424 gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE;
4425 gd_y = DOOR_GFX_PAGEY1 + scrollbutton_info[sid].gd_y;
4426 x_size = ED_SCROLLBUTTON_XSIZE;
4427 y_size = ED_SCROLLBUTTON_YSIZE;
4431 gd_xoffset = (j == 0 ? ED_BUTTON_MINUS_XPOS : ED_BUTTON_PLUS_XPOS);
4432 gd_x1 = DOOR_GFX_PAGEX4 + gd_xoffset;
4433 gd_x2 = DOOR_GFX_PAGEX3 + gd_xoffset;
4434 gd_y = DOOR_GFX_PAGEY1 + ED_BUTTON_COUNT_YPOS;
4435 x_size = ED_BUTTON_COUNT_XSIZE;
4436 y_size = ED_BUTTON_COUNT_YSIZE;
4439 sprintf(infotext, "%s counter value by 1, 5 or 10",
4440 (j == 0 ? "decrease" : "increase"));
4442 gi = CreateGadget(GDI_CUSTOM_ID, id,
4443 GDI_CUSTOM_TYPE_ID, i,
4444 GDI_INFO_TEXT, infotext,
4449 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
4450 GDI_STATE, GD_BUTTON_UNPRESSED,
4451 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
4452 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
4453 GDI_EVENT_MASK, event_mask,
4454 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4455 GDI_CALLBACK_ACTION, HandleCounterButtons,
4459 Error(ERR_EXIT, "cannot create gadget");
4461 level_editor_gadget[id] = gi;
4462 right_gadget_border[id] =
4463 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
4465 x += gi->width + ED_GADGET_DISTANCE; /* text count button */
4469 int font_type = FONT_INPUT_1;
4470 int font_type_active = FONT_INPUT_1_ACTIVE;
4471 int gd_width = ED_WIN_COUNT_XSIZE;
4473 id = counterbutton_info[i].gadget_id_text;
4474 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
4476 if (i == ED_COUNTER_ID_SELECT_LEVEL)
4478 font_type = FONT_LEVEL_NUMBER;
4479 font_type_active = FONT_LEVEL_NUMBER;
4481 x += 2 * ED_GADGET_DISTANCE;
4482 y -= ED_GADGET_DISTANCE;
4484 gd_x = DOOR_GFX_PAGEX6 + ED_WIN_COUNT2_XPOS;
4485 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT2_YPOS;
4486 gd_width = ED_WIN_COUNT2_XSIZE;
4490 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
4491 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
4494 gi = CreateGadget(GDI_CUSTOM_ID, id,
4495 GDI_CUSTOM_TYPE_ID, i,
4496 GDI_INFO_TEXT, "enter counter value",
4499 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
4500 GDI_NUMBER_VALUE, 0,
4501 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
4502 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
4503 GDI_TEXT_SIZE, 3, /* minimal counter text size */
4504 GDI_TEXT_FONT, font_type,
4505 GDI_TEXT_FONT_ACTIVE, font_type_active,
4506 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
4507 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
4508 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
4509 GDI_DESIGN_WIDTH, gd_width,
4510 GDI_EVENT_MASK, event_mask,
4511 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4512 GDI_CALLBACK_ACTION, HandleCounterButtons,
4516 Error(ERR_EXIT, "cannot create gadget");
4518 level_editor_gadget[id] = gi;
4519 right_gadget_border[id] =
4520 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
4522 x += gi->width + ED_GADGET_DISTANCE; /* up count button */
4528 static void CreateDrawingAreas()
4532 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
4534 struct GadgetInfo *gi;
4535 unsigned long event_mask;
4536 int id = drawingarea_info[i].gadget_id;
4537 int x = SX + drawingarea_info[i].x;
4538 int y = SY + drawingarea_info[i].y;
4539 int area_xsize = drawingarea_info[i].area_xsize;
4540 int area_ysize = drawingarea_info[i].area_ysize;
4543 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
4544 GD_EVENT_OFF_BORDERS;
4546 /* determine horizontal position to the right of specified gadget */
4547 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
4548 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
4549 ED_DRAWINGAREA_TEXT_DISTANCE);
4551 /* determine horizontal offset for leading text */
4552 if (drawingarea_info[i].text_left != NULL)
4553 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
4555 gi = CreateGadget(GDI_CUSTOM_ID, id,
4556 GDI_CUSTOM_TYPE_ID, i,
4559 GDI_TYPE, GD_TYPE_DRAWING_AREA,
4560 GDI_AREA_SIZE, area_xsize, area_ysize,
4561 GDI_ITEM_SIZE, MINI_TILEX, MINI_TILEY,
4562 GDI_EVENT_MASK, event_mask,
4563 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
4564 GDI_CALLBACK_ACTION, HandleDrawingAreas,
4568 Error(ERR_EXIT, "cannot create gadget");
4570 level_editor_gadget[id] = gi;
4571 right_gadget_border[id] =
4572 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
4576 static void CreateTextInputGadgets()
4578 int max_infotext_len = getMaxInfoTextLength();
4581 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
4583 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4585 struct GadgetInfo *gi;
4586 unsigned long event_mask;
4587 char infotext[MAX_OUTPUT_LINESIZE + 1];
4588 int id = textinput_info[i].gadget_id;
4590 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
4592 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
4593 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
4595 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
4596 infotext[max_infotext_len] = '\0';
4598 gi = CreateGadget(GDI_CUSTOM_ID, id,
4599 GDI_CUSTOM_TYPE_ID, i,
4600 GDI_INFO_TEXT, infotext,
4601 GDI_X, SX + textinput_info[i].x,
4602 GDI_Y, SY + textinput_info[i].y,
4603 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
4604 GDI_TEXT_VALUE, textinput_info[i].value,
4605 GDI_TEXT_SIZE, textinput_info[i].size,
4606 GDI_TEXT_FONT, FONT_INPUT_1,
4607 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
4608 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
4609 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
4610 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
4611 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
4612 GDI_EVENT_MASK, event_mask,
4613 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4614 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
4618 Error(ERR_EXIT, "cannot create gadget");
4620 level_editor_gadget[id] = gi;
4624 static void CreateTextAreaGadgets()
4626 int max_infotext_len = getMaxInfoTextLength();
4629 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
4631 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4633 struct GadgetInfo *gi;
4634 unsigned long event_mask;
4635 char infotext[MAX_OUTPUT_LINESIZE + 1];
4636 int id = textarea_info[i].gadget_id;
4637 int area_xsize = textarea_info[i].xsize;
4638 int area_ysize = textarea_info[i].ysize;
4640 event_mask = GD_EVENT_TEXT_LEAVING;
4642 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
4643 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
4645 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
4646 infotext[max_infotext_len] = '\0';
4648 gi = CreateGadget(GDI_CUSTOM_ID, id,
4649 GDI_CUSTOM_TYPE_ID, i,
4650 GDI_INFO_TEXT, infotext,
4651 GDI_X, SX + textarea_info[i].x,
4652 GDI_Y, SY + textarea_info[i].y,
4653 GDI_TYPE, GD_TYPE_TEXT_AREA,
4654 GDI_AREA_SIZE, area_xsize, area_ysize,
4655 GDI_TEXT_FONT, FONT_INPUT_1,
4656 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
4657 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
4658 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
4659 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
4660 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
4661 GDI_EVENT_MASK, event_mask,
4662 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4663 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
4667 Error(ERR_EXIT, "cannot create gadget");
4669 level_editor_gadget[id] = gi;
4673 static void CreateSelectboxGadgets()
4675 int max_infotext_len = getMaxInfoTextLength();
4678 for (i = 0; i < ED_NUM_SELECTBOX; i++)
4680 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4682 struct GadgetInfo *gi;
4683 unsigned long event_mask;
4684 char infotext[MAX_OUTPUT_LINESIZE + 1];
4685 int id = selectbox_info[i].gadget_id;
4686 int x = SX + selectbox_info[i].x;
4687 int y = SY + selectbox_info[i].y;
4689 if (selectbox_info[i].size == -1) /* dynamically determine size */
4691 /* (we cannot use -1 for uninitialized values if we directly compare
4692 with results from strlen(), because the '<' and '>' operation will
4693 implicitely cast -1 to an unsigned integer value!) */
4694 selectbox_info[i].size = 0;
4696 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
4697 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
4698 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
4700 selectbox_info[i].size++; /* add one character empty space */
4703 event_mask = GD_EVENT_RELEASED |
4704 GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
4706 gd_x = DOOR_GFX_PAGEX4 + ED_SELECTBOX_XPOS;
4707 gd_y = DOOR_GFX_PAGEY1 + ED_SELECTBOX_YPOS;
4709 /* determine horizontal position to the right of specified gadget */
4710 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
4711 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
4712 ED_GADGET_TEXT_DISTANCE);
4714 /* determine horizontal offset for leading text */
4715 if (selectbox_info[i].text_left != NULL)
4716 x += getTextWidthForGadget(selectbox_info[i].text_left);
4718 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
4719 infotext[max_infotext_len] = '\0';
4721 gi = CreateGadget(GDI_CUSTOM_ID, id,
4722 GDI_CUSTOM_TYPE_ID, i,
4723 GDI_INFO_TEXT, infotext,
4726 GDI_TYPE, GD_TYPE_SELECTBOX,
4727 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
4728 GDI_TEXT_SIZE, selectbox_info[i].size,
4729 GDI_TEXT_FONT, FONT_INPUT_1,
4730 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
4731 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
4732 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
4733 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
4734 GDI_BORDER_SIZE_SELECTBUTTON, ED_SELECTBOX_BUTTON_XSIZE,
4735 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
4736 GDI_EVENT_MASK, event_mask,
4737 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4738 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
4742 Error(ERR_EXIT, "cannot create gadget");
4744 level_editor_gadget[id] = gi;
4745 right_gadget_border[id] =
4746 getRightGadgetBorder(gi, selectbox_info[i].text_right);
4750 static void CreateTextbuttonGadgets()
4752 int max_infotext_len = getMaxInfoTextLength();
4755 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
4757 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4758 int gd_x1, gd_x2, gd_y1, gd_y2;
4759 struct GadgetInfo *gi;
4760 unsigned long event_mask;
4761 char infotext[MAX_OUTPUT_LINESIZE + 1];
4762 int id = textbutton_info[i].gadget_id;
4763 int x = SX + textbutton_info[i].x;
4764 int y = SY + textbutton_info[i].y;
4766 if (textbutton_info[i].size == -1) /* dynamically determine size */
4767 textbutton_info[i].size = strlen(textbutton_info[i].text);
4769 event_mask = GD_EVENT_RELEASED;
4771 if (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE)
4773 gd_x1 = DOOR_GFX_PAGEX4 + ED_TEXTBUTTON_TAB_XPOS;
4774 gd_x2 = DOOR_GFX_PAGEX3 + ED_TEXTBUTTON_TAB_XPOS;
4775 gd_y1 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_TAB_YPOS;
4776 gd_y2 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_TAB_INACTIVE_YPOS;
4780 gd_x1 = DOOR_GFX_PAGEX4 + ED_TEXTBUTTON_XPOS;
4781 gd_x2 = DOOR_GFX_PAGEX3 + ED_TEXTBUTTON_XPOS;
4782 gd_y1 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_YPOS;
4783 gd_y2 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_INACTIVE_YPOS;
4786 sprintf(infotext, "%s", textbutton_info[i].infotext);
4787 infotext[max_infotext_len] = '\0';
4789 /* determine horizontal position to the right of specified gadget */
4790 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
4791 x = (right_gadget_border[textbutton_info[i].gadget_id_align] +
4792 ED_GADGET_TEXT_DISTANCE);
4794 /* determine horizontal offset for leading text */
4795 if (textbutton_info[i].text_left != NULL)
4796 x += getTextWidthForGadget(textbutton_info[i].text_left);
4798 gi = CreateGadget(GDI_CUSTOM_ID, id,
4799 GDI_CUSTOM_TYPE_ID, i,
4800 GDI_INFO_TEXT, infotext,
4803 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
4804 GDI_TEXT_VALUE, textbutton_info[i].text,
4805 GDI_TEXT_SIZE, textbutton_info[i].size,
4806 GDI_TEXT_FONT, FONT_INPUT_2_ACTIVE,
4807 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2,
4808 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
4809 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y1,
4810 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2,
4811 GDI_BORDER_SIZE, ED_BORDER_TEXT_XSIZE, ED_BORDER_SIZE,
4812 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
4813 GDI_DECORATION_SHIFTING, 1, 1,
4814 GDI_EVENT_MASK, event_mask,
4815 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4816 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
4820 Error(ERR_EXIT, "cannot create gadget");
4822 level_editor_gadget[id] = gi;
4823 right_gadget_border[id] =
4824 getRightGadgetBorder(gi, textbutton_info[i].text_right);
4828 static void CreateGraphicbuttonGadgets()
4830 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4831 struct GadgetInfo *gi;
4832 unsigned long event_mask;
4835 /* create buttons for scrolling of drawing area and element list */
4836 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
4838 int id = graphicbutton_info[i].gadget_id;
4839 int gd_x1, gd_x2, gd_y1, gd_y2;
4840 int x = SX + graphicbutton_info[i].x;
4841 int y = SY + graphicbutton_info[i].y;
4843 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
4845 if (i <= ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
4847 gd_x1 = DOOR_GFX_PAGEX4 + graphicbutton_info[i].gd_x;
4848 gd_y1 = DOOR_GFX_PAGEY1 + graphicbutton_info[i].gd_y;
4849 gd_x2 = DOOR_GFX_PAGEX3 + graphicbutton_info[i].gd_x;
4852 else /* (i <= ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE) */
4854 gd_x1 = DOOR_GFX_PAGEX6 + graphicbutton_info[i].gd_x;
4855 gd_y1 = DOOR_GFX_PAGEY1 + graphicbutton_info[i].gd_y;
4856 gd_x2 = gd_x1 - ED_BUTTON_COUNT_XSIZE;
4860 /* determine horizontal position to the right of specified gadget */
4861 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
4862 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
4863 ED_GADGET_TEXT_DISTANCE);
4865 /* determine horizontal offset for leading text */
4866 if (graphicbutton_info[i].text_left != NULL)
4867 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
4869 gi = CreateGadget(GDI_CUSTOM_ID, id,
4870 GDI_CUSTOM_TYPE_ID, i,
4871 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
4874 GDI_WIDTH, graphicbutton_info[i].width,
4875 GDI_HEIGHT, graphicbutton_info[i].height,
4876 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
4877 GDI_STATE, GD_BUTTON_UNPRESSED,
4878 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
4879 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
4880 GDI_EVENT_MASK, event_mask,
4881 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4882 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
4886 Error(ERR_EXIT, "cannot create gadget");
4888 level_editor_gadget[id] = gi;
4889 right_gadget_border[id] =
4890 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
4894 static void CreateScrollbarGadgets()
4898 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
4900 int id = scrollbar_info[i].gadget_id;
4901 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4902 int gd_x1, gd_x2, gd_y1, gd_y2;
4903 struct GadgetInfo *gi;
4904 int items_max, items_visible, item_position;
4905 unsigned long event_mask;
4907 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
4909 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
4910 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
4911 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
4913 else /* drawing area scrollbars */
4915 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
4917 items_max = MAX(lev_fieldx + 2, ed_fieldx);
4918 items_visible = ed_fieldx;
4923 items_max = MAX(lev_fieldy + 2, ed_fieldy);
4924 items_visible = ed_fieldy;
4929 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
4931 gd_x1 = DOOR_GFX_PAGEX8 + scrollbar_info[i].gd_x;
4932 gd_x2 = (gd_x1 - (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL ?
4933 scrollbar_info[i].height : scrollbar_info[i].width));
4934 gd_y1 = DOOR_GFX_PAGEY1 + scrollbar_info[i].gd_y;
4935 gd_y2 = DOOR_GFX_PAGEY1 + scrollbar_info[i].gd_y;
4937 gi = CreateGadget(GDI_CUSTOM_ID, id,
4938 GDI_CUSTOM_TYPE_ID, i,
4939 GDI_INFO_TEXT, scrollbar_info[i].infotext,
4940 GDI_X, scrollbar_info[i].x,
4941 GDI_Y, scrollbar_info[i].y,
4942 GDI_WIDTH, scrollbar_info[i].width,
4943 GDI_HEIGHT, scrollbar_info[i].height,
4944 GDI_TYPE, scrollbar_info[i].type,
4945 GDI_SCROLLBAR_ITEMS_MAX, items_max,
4946 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
4947 GDI_SCROLLBAR_ITEM_POSITION, item_position,
4948 GDI_STATE, GD_BUTTON_UNPRESSED,
4949 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
4950 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
4951 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
4952 GDI_EVENT_MASK, event_mask,
4953 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4954 GDI_CALLBACK_ACTION, HandleControlButtons,
4958 Error(ERR_EXIT, "cannot create gadget");
4960 level_editor_gadget[id] = gi;
4964 static void CreateCheckbuttonGadgets()
4966 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4967 struct GadgetInfo *gi;
4968 unsigned long event_mask;
4969 int gd_x1, gd_x2, gd_x3, gd_x4, gd_y;
4972 event_mask = GD_EVENT_PRESSED;
4974 gd_x1 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_UNCHECKED_XPOS;
4975 gd_x2 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_UNCHECKED_XPOS;
4976 gd_x3 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_CHECKED_XPOS;
4977 gd_x4 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_CHECKED_XPOS;
4978 gd_y = DOOR_GFX_PAGEY1 + ED_RADIOBUTTON_YPOS;
4980 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
4982 int id = checkbutton_info[i].gadget_id;
4983 int x = SX + checkbutton_info[i].x;
4984 int y = SY + checkbutton_info[i].y;
4986 if (id == GADGET_ID_STICK_ELEMENT)
4987 gd_y = DOOR_GFX_PAGEY1 + ED_STICKYBUTTON_YPOS;
4989 gd_y = DOOR_GFX_PAGEY1 + ED_CHECKBUTTON_YPOS;
4991 /* determine horizontal position to the right of specified gadget */
4992 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
4993 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
4994 ED_GADGET_TEXT_DISTANCE);
4996 /* determine horizontal offset for leading text */
4997 if (checkbutton_info[i].text_left != NULL)
4998 x += getTextWidthForGadget(checkbutton_info[i].text_left);
5000 gi = CreateGadget(GDI_CUSTOM_ID, id,
5001 GDI_CUSTOM_TYPE_ID, i,
5002 GDI_INFO_TEXT, checkbutton_info[i].infotext,
5005 GDI_WIDTH, ED_CHECKBUTTON_XSIZE,
5006 GDI_HEIGHT, ED_CHECKBUTTON_YSIZE,
5007 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
5008 GDI_CHECKED, *checkbutton_info[i].value,
5009 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
5010 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
5011 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y,
5012 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y,
5013 GDI_EVENT_MASK, event_mask,
5014 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5015 GDI_CALLBACK_ACTION, HandleCheckbuttons,
5019 Error(ERR_EXIT, "cannot create gadget");
5021 level_editor_gadget[id] = gi;
5022 right_gadget_border[id] =
5023 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
5027 static void CreateRadiobuttonGadgets()
5029 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5030 struct GadgetInfo *gi;
5031 unsigned long event_mask;
5032 int gd_x1, gd_x2, gd_x3, gd_x4, gd_y;
5035 event_mask = GD_EVENT_PRESSED;
5037 gd_x1 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_UNCHECKED_XPOS;
5038 gd_x2 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_UNCHECKED_XPOS;
5039 gd_x3 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_CHECKED_XPOS;
5040 gd_x4 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_CHECKED_XPOS;
5041 gd_y = DOOR_GFX_PAGEY1 + ED_RADIOBUTTON_YPOS;
5043 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
5045 int id = radiobutton_info[i].gadget_id;
5046 int x = SX + radiobutton_info[i].x;
5047 int y = SY + radiobutton_info[i].y;
5050 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
5052 /* determine horizontal position to the right of specified gadget */
5053 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
5054 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
5055 ED_GADGET_TEXT_DISTANCE);
5057 /* determine horizontal offset for leading text */
5058 if (radiobutton_info[i].text_left != NULL)
5059 x += getTextWidthForGadget(radiobutton_info[i].text_left);
5061 gi = CreateGadget(GDI_CUSTOM_ID, id,
5062 GDI_CUSTOM_TYPE_ID, i,
5063 GDI_INFO_TEXT, radiobutton_info[i].infotext,
5066 GDI_WIDTH, ED_CHECKBUTTON_XSIZE,
5067 GDI_HEIGHT, ED_CHECKBUTTON_YSIZE,
5068 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
5069 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
5070 GDI_CHECKED, checked,
5071 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
5072 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
5073 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y,
5074 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y,
5075 GDI_EVENT_MASK, event_mask,
5076 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5077 GDI_CALLBACK_ACTION, HandleRadiobuttons,
5081 Error(ERR_EXIT, "cannot create gadget");
5083 level_editor_gadget[id] = gi;
5084 right_gadget_border[id] =
5085 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
5089 void CreateLevelEditorGadgets()
5091 int old_game_status = game_status;
5093 /* setting 'game_status' is needed to get the right fonts for the editor */
5094 game_status = GAME_MODE_EDITOR;
5096 ReinitializeElementList();
5098 CreateControlButtons();
5099 CreateScrollbarGadgets();
5101 /* order of function calls is important because of cross-references */
5102 CreateCheckbuttonGadgets();
5103 CreateCounterButtons();
5104 CreateRadiobuttonGadgets();
5105 CreateTextInputGadgets();
5106 CreateTextAreaGadgets();
5107 CreateSelectboxGadgets();
5108 CreateGraphicbuttonGadgets();
5109 CreateTextbuttonGadgets();
5110 CreateDrawingAreas();
5112 game_status = old_game_status;
5115 void FreeLevelEditorGadgets()
5119 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
5120 FreeGadget(level_editor_gadget[i]);
5123 static void MapCounterButtons(int id)
5125 int gadget_id_down = counterbutton_info[id].gadget_id_down;
5126 int gadget_id_text = counterbutton_info[id].gadget_id_text;
5127 int gadget_id_up = counterbutton_info[id].gadget_id_up;
5128 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
5129 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
5130 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
5132 char infotext[MAX_OUTPUT_LINESIZE + 1];
5133 int max_infotext_len = getMaxInfoTextLength();
5134 int xoffset_left = 0;
5135 int yoffset_left = ED_BORDER_SIZE;
5136 int xoffset_right = getCounterGadgetWidth();
5137 int yoffset_right = ED_BORDER_SIZE;
5139 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
5140 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
5141 int yoffset_above = MINI_TILEX + ED_GADGET_DISTANCE;
5142 int yoffset = ED_BORDER_SIZE;
5143 int x_left = gi_down->x - xoffset_left;
5144 int x_right = gi_up->x + gi_up->width + xoffset_right;
5145 int y_above = gi_down->y - yoffset_above;
5147 int y; /* set after gadget position was modified */
5150 /* set position for "score" counter gadget */
5151 if (id == ED_COUNTER_ID_ELEMENT_SCORE)
5153 ModifyGadget(gi_down, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
5154 ModifyGadget(gi_text, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
5155 ModifyGadget(gi_up, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
5158 y = gi_up->y + yoffset;
5160 if (counterbutton_info[id].text_above)
5161 DrawText(x, y_above, counterbutton_info[id].text_above, FONT_TEXT_1);
5163 if (counterbutton_info[id].text_left)
5164 DrawText(x_left, y, counterbutton_info[id].text_left, FONT_TEXT_1);
5166 if (counterbutton_info[id].text_right)
5167 DrawText(x_right, y, counterbutton_info[id].text_right, FONT_TEXT_1);
5169 ModifyEditorCounter(id, *counterbutton_info[id].value);
5176 static void MapControlButtons()
5181 /* map toolbox buttons (excluding special CE toolbox buttons) */
5182 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
5183 MapGadget(level_editor_gadget[i]);
5185 /* map buttons to select elements */
5186 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
5187 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
5188 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
5189 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
5190 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
5192 /* map buttons to select level */
5193 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
5194 ModifyEditorCounterLimits(counter_id,
5195 leveldir_current->first_level,
5196 leveldir_current->last_level);
5197 MapCounterButtons(counter_id);
5200 static void MapDrawingArea(int id)
5202 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
5203 int area_xsize = gi->drawing.area_xsize;
5204 int area_ysize = gi->drawing.area_ysize;
5205 int xoffset_left= getTextWidthForDrawingArea(drawingarea_info[id].text_left);
5206 int xoffset_below= getTextWidth(drawingarea_info[id].text_below,FONT_TEXT_1);
5207 int x_left = gi->x - xoffset_left;
5208 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
5209 int x_below = gi->x + (gi->width - xoffset_below) / 2;
5210 int y_side = gi->y + (gi->height - getFontHeight(FONT_TEXT_1)) / 2;
5211 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
5213 if (drawingarea_info[id].text_left)
5214 DrawText(x_left, y_side, drawingarea_info[id].text_left, FONT_TEXT_1);
5216 if (drawingarea_info[id].text_right)
5217 DrawText(x_right, y_side, drawingarea_info[id].text_right, FONT_TEXT_1);
5219 if (drawingarea_info[id].text_below)
5220 DrawText(x_below, y_below, drawingarea_info[id].text_below, FONT_TEXT_1);
5222 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
5224 DrawElementBorder(gi->x, gi->y,
5225 area_xsize * MINI_TILEX, area_ysize * MINI_TILEY, TRUE);
5227 DrawDrawingArea(id);
5233 static void MapTextInputGadget(int id)
5235 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
5236 int xoffset_above = 0;
5237 int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
5238 int x_above = textinput_info[id].x + xoffset_above;
5239 int y_above = textinput_info[id].y + yoffset_above;
5241 if (textinput_info[id].text_above)
5242 DrawTextS(x_above, y_above, FONT_TEXT_1, textinput_info[id].text_above);
5244 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
5249 static void MapTextAreaGadget(int id)
5251 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
5252 int xoffset_above = 0;
5253 int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
5254 int x_above = textarea_info[id].x + xoffset_above;
5255 int y_above = textarea_info[id].y + yoffset_above;
5257 if (textarea_info[id].text_above)
5258 DrawTextS(x_above, y_above, FONT_TEXT_1, textarea_info[id].text_above);
5260 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
5265 static void MapSelectboxGadget(int id)
5267 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
5268 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
5269 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
5270 int yoffset = ED_BORDER_SIZE;
5271 int x_left = gi->x - xoffset_left;
5272 int x_right = gi->x + gi->width + xoffset_right;
5273 int y = gi->y + yoffset;
5275 if (selectbox_info[id].text_left)
5276 DrawText(x_left, y, selectbox_info[id].text_left, FONT_TEXT_1);
5278 if (selectbox_info[id].text_right)
5279 DrawText(x_right, y, selectbox_info[id].text_right, FONT_TEXT_1);
5281 ModifyEditorSelectbox(id, *selectbox_info[id].value);
5286 static void MapTextbuttonGadget(int id)
5288 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
5289 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
5290 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
5291 int yoffset = ED_BORDER_SIZE;
5292 int x_left = gi->x - xoffset_left;
5293 int x_right = gi->x + gi->width + xoffset_right;
5294 int y = gi->y + yoffset;
5296 /* only show button to delete change pages when more than minimum pages */
5297 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
5298 custom_element.num_change_pages == MIN_CHANGE_PAGES)
5301 if (textbutton_info[id].text_left)
5302 DrawText(x_left, y, textbutton_info[id].text_left, FONT_TEXT_1);
5304 if (textbutton_info[id].text_right)
5305 DrawText(x_right, y, textbutton_info[id].text_right, FONT_TEXT_1);
5310 static void MapGraphicbuttonGadget(int id)
5312 struct GadgetInfo *gi= level_editor_gadget[graphicbutton_info[id].gadget_id];
5313 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
5314 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
5315 int yoffset = ED_BORDER_SIZE;
5316 int x_left = gi->x - xoffset_left;
5317 int x_right = gi->x + gi->width + xoffset_right;
5318 int y = gi->y + yoffset;
5320 if (graphicbutton_info[id].text_left)
5321 DrawText(x_left, y, graphicbutton_info[id].text_left, FONT_TEXT_1);
5323 if (graphicbutton_info[id].text_right)
5324 DrawText(x_right, y, graphicbutton_info[id].text_right, FONT_TEXT_1);
5329 static void MapRadiobuttonGadget(int id)
5331 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
5332 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
5333 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
5334 int yoffset = ED_BORDER_SIZE;
5335 int x_left = gi->x - xoffset_left;
5336 int x_right = gi->x + gi->width + xoffset_right;
5337 int y = gi->y + yoffset;
5339 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
5341 if (radiobutton_info[id].text_left)
5342 DrawText(x_left, y, radiobutton_info[id].text_left, FONT_TEXT_1);
5344 if (radiobutton_info[id].text_right)
5345 DrawText(x_right, y, radiobutton_info[id].text_right, FONT_TEXT_1);
5347 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
5352 static void MapCheckbuttonGadget(int id)
5354 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
5355 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
5356 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
5357 int yoffset = ED_BORDER_SIZE;
5358 int x_left, x_right, y; /* set after gadget position was modified */
5360 /* set position for gadgets with dynamically determined position */
5361 if (checkbutton_info[id].x != -1) /* do not change dynamic positions */
5362 ModifyGadget(gi, GDI_X, SX + checkbutton_info[id].x, GDI_END);
5363 ModifyGadget(gi, GDI_Y, SY + checkbutton_info[id].y, GDI_END);
5365 x_left = gi->x - xoffset_left;
5366 x_right = gi->x + gi->width + xoffset_right;
5367 y = gi->y + yoffset;
5369 if (checkbutton_info[id].text_left)
5370 DrawText(x_left, y, checkbutton_info[id].text_left, FONT_TEXT_1);
5372 if (checkbutton_info[id].text_right)
5373 DrawText(x_right, y, checkbutton_info[id].text_right, FONT_TEXT_1);
5375 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
5380 static void MapMainDrawingArea()
5382 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
5383 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
5386 for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
5388 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
5389 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
5390 no_horizontal_scrollbar) ||
5391 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
5392 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
5393 no_vertical_scrollbar))
5396 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
5399 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
5401 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
5402 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
5405 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
5408 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
5411 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
5415 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
5417 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
5418 i == GADGET_ID_CUSTOM_COPY_TO ||
5419 i == GADGET_ID_CUSTOM_EXCHANGE ||
5420 i == GADGET_ID_CUSTOM_COPY ||
5421 i == GADGET_ID_CUSTOM_PASTE)
5424 MapGadget(level_editor_gadget[i]);
5426 UnmapGadget(level_editor_gadget[i]);
5431 static void MapLevelEditorToolboxCustomGadgets()
5433 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
5436 static void UnmapLevelEditorToolboxCustomGadgets()
5438 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
5441 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
5443 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5446 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
5448 if (i != GADGET_ID_SINGLE_ITEMS &&
5449 i != GADGET_ID_PROPERTIES &&
5450 i != GADGET_ID_PICK_ELEMENT)
5452 struct GadgetInfo *gi = level_editor_gadget[i];
5460 BlitBitmap(gd_bitmap, drawto,
5461 DOOR_GFX_PAGEX6 + ED_CTRL_NO_BUTTONS_GFX_XPOS,
5462 DOOR_GFX_PAGEY1 + ED_CTRL_NO_BUTTONS_GFX_YPOS,
5463 gi->width, gi->height, gi->x, gi->y);
5465 redraw_mask |= REDRAW_DOOR_3;
5471 static void MapLevelEditorToolboxDrawingGadgets()
5473 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
5476 static void UnmapLevelEditorToolboxDrawingGadgets()
5478 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
5481 static void UnmapDrawingArea(int id)
5483 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
5486 static void UnmapLevelEditorWindowGadgets()
5490 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
5491 if (level_editor_gadget[i]->x < SX + SXSIZE)
5492 UnmapGadget(level_editor_gadget[i]);
5495 void UnmapLevelEditorGadgets()
5499 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
5500 UnmapGadget(level_editor_gadget[i]);
5503 static void ResetUndoBuffer()
5505 undo_buffer_position = -1;
5506 undo_buffer_steps = -1;
5507 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
5510 static void DrawEditModeWindow()
5512 ModifyEditorElementList();
5513 RedrawDrawingElements();
5515 if (edit_mode == ED_MODE_INFO)
5516 DrawLevelInfoWindow();
5517 else if (edit_mode == ED_MODE_PROPERTIES)
5518 DrawPropertiesWindow();
5519 else /* edit_mode == ED_MODE_DRAWING */
5520 DrawDrawingWindow();
5523 static boolean LevelChanged()
5525 boolean level_changed = FALSE;
5528 for (y = 0; y < lev_fieldy; y++)
5529 for (x = 0; x < lev_fieldx; x++)
5530 if (Feld[x][y] != level.field[x][y])
5531 level_changed = TRUE;
5533 return level_changed;
5536 static boolean LevelContainsPlayer()
5538 boolean player_found = FALSE;
5541 for (y = 0; y < lev_fieldy; y++)
5542 for (x = 0; x < lev_fieldx; x++)
5543 if (Feld[x][y] == EL_PLAYER_1 ||
5544 Feld[x][y] == EL_SP_MURPHY)
5545 player_found = TRUE;
5547 return player_found;
5550 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
5551 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
5555 for (x = 0; x < lev_fieldx; x++)
5556 for (y = 0; y < lev_fieldy; y++)
5557 dst[x][y] = src[x][y];
5560 static int setSelectboxValue(int selectbox_id, int new_value)
5562 int new_index_value = 0;
5565 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
5566 if (selectbox_info[selectbox_id].options[i].value == new_value)
5567 new_index_value = i;
5569 *selectbox_info[selectbox_id].value =
5570 selectbox_info[selectbox_id].options[new_index_value].value;
5572 return new_index_value;
5575 static void copy_custom_element_settings(int element_from, int element_to)
5578 struct ElementInfo ei_to_old = element_info[element_to];
5579 struct ElementInfo *ei_from = &element_info[element_from];
5580 struct ElementInfo *ei_to = &element_info[element_to];
5583 /* ---------- copy whole element structure ---------- */
5586 /* ---------- restore structure pointers which cannot be copied ---------- */
5587 ei_to->token_name = ei_to_old.token_name;
5588 ei_to->class_name = ei_to_old.class_name;
5589 ei_to->editor_description = ei_to_old.editor_description;
5590 ei_to->custom_description = ei_to_old.custom_description;
5591 ei_to->change_page = ei_to_old.change_page;
5592 ei_to->change = ei_to_old.change;
5593 ei_to->group = ei_to_old.group;
5595 /* ---------- copy element base properties ---------- */
5596 Properties[element_to][EP_BITFIELD_BASE] =
5597 Properties[element_from][EP_BITFIELD_BASE];
5599 /* ---------- reinitialize and copy change pages ---------- */
5600 setElementChangePages(ei_to, ei_to->num_change_pages);
5602 for (i=0; i < ei_to->num_change_pages; i++)
5603 ei_to->change_page[i] = ei_from->change_page[i];
5605 /* ---------- copy group element info ---------- */
5606 if (ei_from->group != NULL && ei_to->group != NULL) /* group or internal */
5607 *ei_to->group = *ei_from->group;
5611 struct ElementInfo *ei_from = &element_info[element_from];
5612 struct ElementInfo *ei_to = &element_info[element_to];
5615 /* ---------- copy element description ---------- */
5616 for (i = 0; i < MAX_ELEMENT_NAME_LEN + 1; i++)
5617 ei_to->description[i] = ei_from->description[i];
5619 /* ---------- copy element base properties ---------- */
5620 Properties[element_to][EP_BITFIELD_BASE] =
5621 Properties[element_from][EP_BITFIELD_BASE];
5623 /* ---------- copy custom property values ---------- */
5625 ei_to->use_gfx_element = ei_from->use_gfx_element;
5626 ei_to->gfx_element = ei_from->gfx_element;
5628 ei_to->access_direction = ei_from->access_direction;
5630 ei_to->collect_score = ei_from->collect_score;
5631 ei_to->collect_count = ei_from->collect_count;
5633 ei_to->push_delay_fixed = ei_from->push_delay_fixed;
5634 ei_to->push_delay_random = ei_from->push_delay_random;
5635 ei_to->drop_delay_fixed = ei_from->drop_delay_fixed;
5636 ei_to->drop_delay_random = ei_from->drop_delay_random;
5637 ei_to->move_delay_fixed = ei_from->move_delay_fixed;
5638 ei_to->move_delay_random = ei_from->move_delay_random;
5640 ei_to->move_pattern = ei_from->move_pattern;
5641 ei_to->move_direction_initial = ei_from->move_direction_initial;
5642 ei_to->move_stepsize = ei_from->move_stepsize;
5644 ei_to->move_enter_element = ei_from->move_enter_element;
5645 ei_to->move_leave_element = ei_from->move_leave_element;
5646 ei_to->move_leave_type = ei_from->move_leave_type;
5648 ei_to->slippery_type = ei_from->slippery_type;
5650 for (y = 0; y < 3; y++)
5651 for (x = 0; x < 3; x++)
5652 ei_to->content[x][y] = ei_from->content[x][y];
5654 ei_to->explosion_delay = ei_from->explosion_delay;
5655 ei_to->ignition_delay = ei_from->ignition_delay;
5657 /* ---------- reinitialize and copy change pages ---------- */
5659 ei_to->num_change_pages = ei_from->num_change_pages;
5660 ei_to->current_change_page = ei_from->current_change_page;
5662 setElementChangePages(ei_to, ei_to->num_change_pages);
5664 for (i=0; i < ei_to->num_change_pages; i++)
5665 ei_to->change_page[i] = ei_from->change_page[i];
5667 /* ---------- copy group element info ---------- */
5668 if (ei_from->group != NULL && ei_to->group != NULL) /* group or internal */
5669 *ei_to->group = *ei_from->group;
5673 /* mark this custom element as modified */
5674 ei_to->modified_settings = TRUE;
5677 static void replace_custom_element_in_settings(int element_from,
5682 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5684 struct ElementInfo *ei = &element_info[i];
5686 for (y = 0; y < 3; y++)
5687 for (x = 0; x < 3; x++)
5688 if (ei->content[x][y] == element_from)
5689 ei->content[x][y] = element_to;
5691 for (j = 0; j < ei->num_change_pages; j++)
5693 struct ElementChangeInfo *change = &ei->change_page[j];
5695 if (change->target_element == element_from)
5696 change->target_element = element_to;
5698 if (change->trigger_element == element_from)
5699 change->trigger_element = element_to;
5701 for (y = 0; y < 3; y++)
5702 for (x = 0; x < 3; x++)
5703 if (change->target_content[x][y] == element_from)
5704 change->target_content[x][y] = element_to;
5707 if (ei->group != NULL) /* group or internal */
5708 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
5709 if (ei->group->element[j] == element_from)
5710 ei->group->element[j] = element_to;
5714 static void replace_custom_element_in_playfield(int element_from,
5719 for (x = 0; x < lev_fieldx; x++)
5720 for (y = 0; y < lev_fieldy; y++)
5721 if (Feld[x][y] == element_from)
5722 Feld[x][y] = element_to;
5725 static boolean CopyCustomElement(int element_old, int element_new,
5728 if (copy_mode == GADGET_ID_CUSTOM_COPY)
5730 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
5731 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
5732 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
5734 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
5736 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
5737 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
5738 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
5740 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
5742 Request("Please choose custom element !", REQ_CONFIRM);
5746 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
5748 Request("Please choose group element !", REQ_CONFIRM);
5753 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
5755 copy_custom_element_settings(element_new, element_old);
5757 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
5759 copy_custom_element_settings(element_old, element_new);
5761 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
5763 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
5764 copy_custom_element_settings(element_new, element_old);
5765 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
5767 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
5768 replace_custom_element_in_settings(element_new, element_old);
5769 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
5771 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
5772 replace_custom_element_in_playfield(element_new, element_old);
5773 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
5776 UpdateCustomElementGraphicGadgets();
5777 DrawPropertiesWindow();
5782 static void CopyCustomElementPropertiesToEditor(int element)
5785 int current_change_page = element_info[element].current_change_page;
5787 /* dynamically (re)build selectbox for selecting change page */
5788 for (i = 0; i < element_info[element].num_change_pages; i++)
5790 sprintf(options_change_page_strings[i], "%d", i + 1);
5792 options_change_page[i].value = i;
5793 options_change_page[i].text = options_change_page_strings[i];
5796 options_change_page[i].value = -1;
5797 options_change_page[i].text = NULL;
5799 /* needed here to initialize combined element properties */
5800 InitElementPropertiesEngine(level.game_version);
5802 element_info[element].change =
5803 &element_info[element].change_page[current_change_page];
5805 custom_element = element_info[element];
5806 custom_element_change = *element_info[element].change;
5808 /* needed to initially set selectbox value variables to reliable defaults */
5809 for (i = 0; i < ED_NUM_SELECTBOX; i++)
5810 setSelectboxValue(i, *selectbox_info[i].value);
5812 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
5813 custom_element_properties[i] = HAS_PROPERTY(element, i);
5815 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
5816 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
5818 /* ---------- element settings: configure (custom elements) ------------- */
5820 /* set accessible layer selectbox help value */
5821 custom_element.access_type =
5822 (IS_WALKABLE(element) ? EP_WALKABLE :
5823 IS_PASSABLE(element) ? EP_PASSABLE :
5824 custom_element.access_type);
5825 custom_element.access_layer =
5826 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
5827 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
5828 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
5829 custom_element.access_layer);
5830 custom_element.access_protected =
5831 (IS_PROTECTED(element) ? 1 : 0);
5832 custom_element_properties[EP_ACCESSIBLE] =
5833 (IS_ACCESSIBLE_OVER(element) ||
5834 IS_ACCESSIBLE_INSIDE(element) ||
5835 IS_ACCESSIBLE_UNDER(element));
5837 /* set walk-to-object action selectbox help value */
5838 custom_element.walk_to_action =
5839 (IS_DIGGABLE(element) ? EP_DIGGABLE :
5840 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
5841 IS_DROPPABLE(element) ? EP_DROPPABLE :
5842 IS_THROWABLE(element) ? EP_THROWABLE :
5843 IS_PUSHABLE(element) ? EP_PUSHABLE :
5844 custom_element.walk_to_action);
5845 custom_element_properties[EP_WALK_TO_OBJECT] =
5846 (IS_DIGGABLE(element) ||
5847 IS_COLLECTIBLE_ONLY(element) ||
5848 IS_DROPPABLE(element) ||
5849 IS_THROWABLE(element) ||
5850 IS_PUSHABLE(element));
5852 /* set smash targets selectbox help value */
5853 custom_element.smash_targets =
5854 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
5855 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
5856 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
5857 custom_element.smash_targets);
5858 custom_element_properties[EP_CAN_SMASH] =
5859 (CAN_SMASH_EVERYTHING(element) ||
5860 CAN_SMASH_ENEMIES(element) ||
5861 CAN_SMASH_PLAYER(element));
5863 /* set deadliness selectbox help value */
5864 custom_element.deadliness =
5865 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
5866 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
5867 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
5868 custom_element.deadliness);
5869 custom_element_properties[EP_DEADLY] =
5870 (DONT_TOUCH(element) ||
5871 DONT_COLLIDE_WITH(element) ||
5872 DONT_RUN_INTO(element));
5875 /* set explosion type selectbox help value */
5876 custom_element.explosion_type =
5879 IS_INDESTRUCTIBLE(element) ? EP_INDESTRUCTIBLE :
5881 CAN_EXPLODE_1X1(element) ? EP_CAN_EXPLODE_1X1 :
5882 CAN_EXPLODE_3X3(element) ? EP_CAN_EXPLODE_3X3 :
5883 CAN_EXPLODE_CROSS(element) ? EP_CAN_EXPLODE_CROSS :
5884 custom_element.explosion_type);
5885 custom_element_properties[EP_CAN_EXPLODE_AT_ALL] =
5888 IS_INDESTRUCTIBLE(element) ||
5890 CAN_EXPLODE_1X1(element) ||
5891 CAN_EXPLODE_3X3(element) ||
5892 CAN_EXPLODE_CROSS(element));
5896 /* special case: sub-settings dependent from main setting */
5898 custom_element.can_explode_by_fire = CAN_EXPLODE_BY_FIRE(element);
5899 custom_element.can_explode_smashed = CAN_EXPLODE_SMASHED(element);
5900 custom_element.can_explode_impact = CAN_EXPLODE_IMPACT(element);
5902 if (CAN_EXPLODE_BY_FIRE(element))
5903 custom_element.can_explode_by_fire = TRUE;
5904 if (CAN_EXPLODE_SMASHED(element))
5905 custom_element.can_explode_smashed = TRUE;
5906 if (CAN_EXPLODE_IMPACT(element))
5907 custom_element.can_explode_impact = TRUE;
5911 /* ---------- element settings: advanced (custom elements) --------------- */
5913 /* set "change by direct action" selectbox help value */
5914 custom_element_change.direct_action =
5915 (HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
5916 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
5917 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
5918 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
5919 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
5920 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
5921 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
5922 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
5923 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
5924 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
5925 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
5926 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
5927 custom_element_change.direct_action);
5929 /* set "change by other element action" selectbox help value */
5930 custom_element_change.other_action =
5931 (HAS_CHANGE_EVENT(element, CE_OTHER_GETS_TOUCHED) ? CE_OTHER_GETS_TOUCHED :
5932 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_PRESSED) ? CE_OTHER_GETS_PRESSED :
5933 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_PUSHED) ? CE_OTHER_GETS_PUSHED :
5934 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_ENTERED) ? CE_OTHER_GETS_ENTERED :
5935 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_LEFT) ? CE_OTHER_GETS_LEFT :
5936 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_DIGGED) ? CE_OTHER_GETS_DIGGED :
5937 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_COLLECTED) ? CE_OTHER_GETS_COLLECTED :
5938 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_DROPPED) ? CE_OTHER_GETS_DROPPED :
5939 HAS_CHANGE_EVENT(element, CE_OTHER_IS_TOUCHING) ? CE_OTHER_IS_TOUCHING :
5940 HAS_CHANGE_EVENT(element, CE_OTHER_IS_HITTING) ? CE_OTHER_IS_HITTING :
5941 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_HIT) ? CE_OTHER_GETS_HIT :
5942 HAS_CHANGE_EVENT(element, CE_OTHER_IS_SWITCHING) ? CE_OTHER_IS_SWITCHING :
5943 HAS_CHANGE_EVENT(element, CE_OTHER_IS_CHANGING) ? CE_OTHER_IS_CHANGING :
5944 HAS_CHANGE_EVENT(element, CE_OTHER_IS_EXPLODING) ? CE_OTHER_IS_EXPLODING :
5945 custom_element_change.other_action);
5948 static void CopyGroupElementPropertiesToEditor(int element)
5950 group_element_info = *element_info[element].group;
5951 custom_element = element_info[element]; /* needed for description */
5954 static void CopyClassicElementPropertiesToEditor(int element)
5957 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
5958 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
5959 getMoveIntoAcidProperty(&level, element);
5961 if (MAYBE_DONT_COLLIDE_WITH(element))
5962 custom_element_properties[EP_DONT_COLLIDE_WITH] =
5963 getDontCollideWithProperty(&level, element);
5966 if (COULD_MOVE_INTO_ACID(element))
5968 int bit_nr = get_special_property_bit(element, EP_CAN_MOVE_INTO_ACID);
5971 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
5972 ((level.can_move_into_acid_bits & (1 << bit_nr)) != 0);
5977 static void CopyElementPropertiesToEditor(int element)
5979 if (IS_CUSTOM_ELEMENT(element))
5980 CopyCustomElementPropertiesToEditor(element);
5981 else if (IS_GROUP_ELEMENT(element))
5982 CopyGroupElementPropertiesToEditor(element);
5984 CopyClassicElementPropertiesToEditor(element);
5987 static void CopyCustomElementPropertiesToGame(int element)
5990 int access_type_and_layer;
5992 boolean can_explode;
5995 /* mark that this custom element has been modified */
5996 custom_element.modified_settings = TRUE;
5998 if (level.use_custom_template)
6000 if (Request("Copy and modify level template ?", REQ_ASK))
6002 level.use_custom_template = FALSE;
6003 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE],
6004 GDI_CHECKED, FALSE, GDI_END);
6008 LoadLevelTemplate(-1); /* this resets all element modifications ... */
6010 DrawEditModeWindow(); /* ... and copies them to 'custom_element' */
6014 element_info[element] = custom_element;
6015 *element_info[element].change = custom_element_change;
6017 /* ---------- element settings: configure (custom elements) ------------- */
6019 /* set accessible property from checkbox and selectbox */
6020 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
6021 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
6022 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
6023 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
6024 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
6025 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
6026 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
6027 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
6028 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
6029 custom_element_properties[access_type_and_layer] =
6030 custom_element_properties[EP_ACCESSIBLE];
6031 custom_element_properties[EP_PROTECTED] =
6032 (custom_element.access_protected != 0 &&
6033 custom_element_properties[EP_ACCESSIBLE]);
6035 /* set walk-to-object property from checkbox and selectbox */
6036 custom_element_properties[EP_DIGGABLE] = FALSE;
6037 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
6038 custom_element_properties[EP_DROPPABLE] = FALSE;
6039 custom_element_properties[EP_THROWABLE] = FALSE;
6040 custom_element_properties[EP_PUSHABLE] = FALSE;
6041 custom_element_properties[custom_element.walk_to_action] =
6042 custom_element_properties[EP_WALK_TO_OBJECT];
6044 /* set smash property from checkbox and selectbox */
6045 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
6046 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
6047 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
6048 custom_element_properties[custom_element.smash_targets] =
6049 custom_element_properties[EP_CAN_SMASH];
6051 /* set deadliness property from checkbox and selectbox */
6052 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
6053 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
6054 custom_element_properties[EP_DONT_TOUCH] = FALSE;
6055 custom_element_properties[custom_element.deadliness] =
6056 custom_element_properties[EP_DEADLY];
6059 /* set explosion type property from checkbox and selectbox */
6061 custom_element_properties[EP_INDESTRUCTIBLE] = FALSE;
6063 custom_element_properties[EP_CAN_EXPLODE_1X1] = FALSE;
6064 custom_element_properties[EP_CAN_EXPLODE_3X3] = FALSE;
6065 custom_element_properties[EP_CAN_EXPLODE_CROSS] = FALSE;
6066 custom_element_properties[EP_CAN_EXPLODE_BY_FIRE] = FALSE;
6067 custom_element_properties[EP_CAN_EXPLODE_SMASHED] = FALSE;
6068 custom_element_properties[EP_CAN_EXPLODE_IMPACT] = FALSE;
6069 custom_element_properties[custom_element.explosion_type] =
6070 custom_element_properties[EP_CAN_EXPLODE_AT_ALL];
6074 /* special case: sub-settings dependent from main setting */
6076 can_explode = (custom_element_properties[EP_CAN_EXPLODE_1X1] ||
6077 custom_element_properties[EP_CAN_EXPLODE_3X3] ||
6078 custom_element_properties[EP_CAN_EXPLODE_CROSS]);
6079 custom_element_properties[EP_CAN_EXPLODE_BY_FIRE] =
6080 (can_explode && custom_element.can_explode_by_fire);
6081 custom_element_properties[EP_CAN_EXPLODE_SMASHED] =
6082 (can_explode && custom_element.can_explode_smashed);
6083 custom_element_properties[EP_CAN_EXPLODE_IMPACT] =
6084 (can_explode && custom_element.can_explode_impact);
6086 if (custom_element_properties[EP_CAN_EXPLODE_1X1] ||
6087 custom_element_properties[EP_CAN_EXPLODE_3X3] ||
6088 custom_element_properties[EP_CAN_EXPLODE_CROSS])
6090 custom_element_properties[EP_CAN_EXPLODE_BY_FIRE] =
6091 custom_element.can_explode_by_fire;
6092 custom_element_properties[EP_CAN_EXPLODE_SMASHED] =
6093 custom_element.can_explode_smashed;
6094 custom_element_properties[EP_CAN_EXPLODE_IMPACT] =
6095 custom_element.can_explode_impact;
6100 /* ---------- element settings: advanced (custom elements) --------------- */
6102 /* set player change event from checkbox and selectbox */
6103 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
6104 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
6105 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
6106 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
6107 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
6108 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
6109 custom_element_change_events[CE_SWITCHED] = FALSE;
6110 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
6111 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
6112 custom_element_change_events[CE_BLOCKED] = FALSE;
6113 custom_element_change_events[CE_IMPACT] = FALSE;
6114 custom_element_change_events[CE_SMASHED] = FALSE;
6115 custom_element_change_events[custom_element_change.direct_action] =
6116 custom_element_change_events[CE_BY_DIRECT_ACTION];
6118 /* set other element action change event from checkbox and selectbox */
6119 custom_element_change_events[CE_OTHER_GETS_TOUCHED] = FALSE;
6120 custom_element_change_events[CE_OTHER_GETS_PRESSED] = FALSE;
6121 custom_element_change_events[CE_OTHER_GETS_PUSHED] = FALSE;
6122 custom_element_change_events[CE_OTHER_GETS_ENTERED] = FALSE;
6123 custom_element_change_events[CE_OTHER_GETS_LEFT] = FALSE;
6124 custom_element_change_events[CE_OTHER_GETS_DIGGED] = FALSE;
6125 custom_element_change_events[CE_OTHER_GETS_COLLECTED] = FALSE;
6126 custom_element_change_events[CE_OTHER_GETS_DROPPED] = FALSE;
6127 custom_element_change_events[CE_OTHER_IS_TOUCHING] = FALSE;
6128 custom_element_change_events[CE_OTHER_IS_HITTING] = FALSE;
6129 custom_element_change_events[CE_OTHER_GETS_HIT] = FALSE;
6130 custom_element_change_events[CE_OTHER_IS_SWITCHING] = FALSE;
6131 custom_element_change_events[CE_OTHER_IS_CHANGING] = FALSE;
6132 custom_element_change_events[CE_OTHER_IS_EXPLODING] = FALSE;
6133 custom_element_change_events[custom_element_change.other_action] =
6134 custom_element_change_events[CE_BY_OTHER_ACTION];
6136 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
6137 SET_PROPERTY(element, i, custom_element_properties[i]);
6139 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
6140 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
6142 /* copy change events also to special level editor variable */
6143 custom_element = element_info[element];
6144 custom_element_change = *element_info[element].change;
6147 static void CopyGroupElementPropertiesToGame(int element)
6149 element_info[element] = custom_element;
6150 *element_info[element].group = group_element_info;
6152 /* mark that this group element has been modified */
6153 element_info[element].modified_settings = TRUE;
6156 static void CopyClassicElementPropertiesToGame(int element)
6159 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
6160 setMoveIntoAcidProperty(&level, element,
6161 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
6163 if (MAYBE_DONT_COLLIDE_WITH(element))
6164 setDontCollideWithProperty(&level, element,
6165 custom_element_properties[EP_DONT_COLLIDE_WITH]);
6168 if (COULD_MOVE_INTO_ACID(element))
6170 int bit_nr = get_special_property_bit(element, EP_CAN_MOVE_INTO_ACID);
6174 level.can_move_into_acid_bits &= ~(1 << bit_nr);
6176 if (custom_element_properties[EP_CAN_MOVE_INTO_ACID])
6177 level.can_move_into_acid_bits |= (1 << bit_nr);
6183 static void CopyElementPropertiesToGame(int element)
6185 if (IS_CUSTOM_ELEMENT(element))
6186 CopyCustomElementPropertiesToGame(element);
6187 else if (IS_GROUP_ELEMENT(element))
6188 CopyGroupElementPropertiesToGame(element);
6190 CopyClassicElementPropertiesToGame(element);
6195 CloseDoor(DOOR_CLOSE_ALL);
6196 OpenDoor(DOOR_OPEN_2 | DOOR_NO_DELAY);
6198 if (level_editor_test_game)
6200 CopyPlayfield(level.field, Feld);
6201 CopyPlayfield(FieldBackup, level.field);
6203 level_editor_test_game = FALSE;
6207 edit_mode = ED_MODE_DRAWING;
6208 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
6216 /* copy default editor door content to main double buffer */
6217 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
6218 DOOR_GFX_PAGEX6, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
6221 /* draw mouse button brush elements */
6222 RedrawDrawingElements();
6225 /* draw bigger door */
6226 DrawSpecialEditorDoor();
6228 /* draw new control window */
6229 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
6230 DOOR_GFX_PAGEX8, 236, EXSIZE, EYSIZE, EX, EY);
6232 redraw_mask |= REDRAW_ALL;
6234 ReinitializeElementListButtons(); /* custom element may look different */
6236 ModifyEditorElementList(); /* may be needed for custom elements */
6240 MapControlButtons();
6242 DrawEditModeWindow();
6244 /* copy actual editor door content to door double buffer for OpenDoor() */
6245 BlitBitmap(drawto, bitmap_db_door,
6246 DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
6248 OpenDoor(DOOR_OPEN_1);
6251 static void AdjustDrawingAreaGadgets()
6253 int ed_xsize = lev_fieldx + 2;
6254 int ed_ysize = lev_fieldy + 2;
6255 int max_ed_fieldx = MAX_ED_FIELDX;
6256 int max_ed_fieldy = MAX_ED_FIELDY;
6257 boolean horizontal_scrollbar_needed;
6258 boolean vertical_scrollbar_needed;
6259 int x, y, width, height;
6260 int xoffset, yoffset;
6262 /* check if we need any scrollbars */
6263 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
6264 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
6266 /* check if we have a smaller editor field because of scrollbars */
6267 if (horizontal_scrollbar_needed)
6268 max_ed_fieldy = MAX_ED_FIELDY - 1;
6269 if (vertical_scrollbar_needed)
6270 max_ed_fieldx = MAX_ED_FIELDX - 1;
6272 /* check again if we now need more scrollbars because of less space */
6273 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
6274 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
6276 /* check if editor field gets even smaller after adding new scrollbars */
6277 if (horizontal_scrollbar_needed)
6278 max_ed_fieldy = MAX_ED_FIELDY - 1;
6279 if (vertical_scrollbar_needed)
6280 max_ed_fieldx = MAX_ED_FIELDX - 1;
6282 ed_fieldx = (ed_xsize < MAX_ED_FIELDX ? ed_xsize : max_ed_fieldx);
6283 ed_fieldy = (ed_ysize < MAX_ED_FIELDY ? ed_ysize : max_ed_fieldy);
6285 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
6286 GDI_WIDTH, ed_fieldx * MINI_TILEX,
6287 GDI_HEIGHT, ed_fieldy * MINI_TILEY,
6288 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
6291 xoffset = (ed_fieldx == MAX_ED_FIELDX ? ED_SCROLLBUTTON_XSIZE : 0);
6292 yoffset = (ed_fieldy == MAX_ED_FIELDY ? ED_SCROLLBUTTON_YSIZE : 0);
6294 x = SX + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_RIGHT].x + xoffset;
6295 y = SX + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_DOWN].y + yoffset;
6297 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT], GDI_X, x, GDI_END);
6298 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN], GDI_Y, y, GDI_END);
6300 width = scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width + xoffset;
6301 height = scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].height + yoffset;
6303 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
6305 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
6307 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
6309 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
6313 static void AdjustLevelScrollPosition()
6315 if (level_xpos < -1)
6317 if (level_xpos > lev_fieldx - ed_fieldx + 1)
6318 level_xpos = lev_fieldx - ed_fieldx + 1;
6319 if (lev_fieldx < ed_fieldx - 2)
6322 if (level_ypos < -1)
6324 if (level_ypos > lev_fieldy - ed_fieldy + 1)
6325 level_ypos = lev_fieldy - ed_fieldy + 1;
6326 if (lev_fieldy < ed_fieldy - 2)
6330 static void AdjustEditorScrollbar(int id)
6332 struct GadgetInfo *gi = level_editor_gadget[id];
6333 int items_max, items_visible, item_position;
6335 if (id == GADGET_ID_SCROLL_HORIZONTAL)
6337 items_max = MAX(lev_fieldx + 2, ed_fieldx);
6338 items_visible = ed_fieldx;
6339 item_position = level_xpos + 1;
6343 items_max = MAX(lev_fieldy + 2, ed_fieldy);
6344 items_visible = ed_fieldy;
6345 item_position = level_ypos + 1;
6348 if (item_position > items_max - items_visible)
6349 item_position = items_max - items_visible;
6351 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
6352 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
6355 static void ModifyEditorCounter(int counter_id, int new_value)
6357 int *counter_value = counterbutton_info[counter_id].value;
6358 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
6359 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
6361 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
6363 if (counter_value != NULL)
6364 *counter_value = gi->textinput.number_value;
6367 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
6369 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
6370 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
6372 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
6375 static void ModifyEditorSelectbox(int selectbox_id, int new_value)
6377 int gadget_id = selectbox_info[selectbox_id].gadget_id;
6378 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
6379 int new_index_value = setSelectboxValue(selectbox_id, new_value);
6381 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
6384 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
6386 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
6387 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
6389 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
6392 static void ModifyEditorElementList()
6396 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6398 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
6399 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
6400 struct GadgetDesign *gd = &gi->deco.design;
6401 int element = editor_elements[element_shift + i];
6404 getMiniGraphicSource(el2edimg(element), &gd->bitmap, &gd->x, &gd->y);
6405 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
6410 static void PickDrawingElement(int button, int element)
6412 if (button < 1 || button > 3)
6417 new_element1 = element;
6418 DrawMiniGraphicExt(drawto,
6419 DX + ED_WIN_MB_LEFT_XPOS, DY + ED_WIN_MB_LEFT_YPOS,
6420 el2edimg(new_element1));
6422 else if (button == 2)
6424 new_element2 = element;
6425 DrawMiniGraphicExt(drawto,
6426 DX + ED_WIN_MB_MIDDLE_XPOS, DY + ED_WIN_MB_MIDDLE_YPOS,
6427 el2edimg(new_element2));
6431 new_element3 = element;
6432 DrawMiniGraphicExt(drawto,
6433 DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS,
6434 el2edimg(new_element3));
6437 redraw_mask |= REDRAW_DOOR_1;
6440 static void RedrawDrawingElements()
6442 PickDrawingElement(1, new_element1);
6443 PickDrawingElement(2, new_element2);
6444 PickDrawingElement(3, new_element3);
6447 static void DrawDrawingWindow()
6449 stick_element_properties_window = FALSE;
6451 SetMainBackgroundImage(IMG_UNDEFINED);
6454 UnmapLevelEditorWindowGadgets();
6455 UnmapLevelEditorToolboxCustomGadgets();
6457 AdjustDrawingAreaGadgets();
6458 AdjustLevelScrollPosition();
6459 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
6460 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
6462 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
6464 MapMainDrawingArea();
6465 MapLevelEditorToolboxDrawingGadgets();
6468 static void DrawLevelInfoWindow()
6472 stick_element_properties_window = FALSE;
6474 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
6476 UnmapLevelEditorWindowGadgets();
6478 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS1_YPOS,
6479 "Level Settings", FONT_TITLE_1);
6480 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS2_YPOS,
6481 "Editor Settings", FONT_TITLE_1);
6483 /* draw counter gadgets */
6484 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
6485 MapCounterButtons(i);
6487 /* draw selectbox gadgets */
6488 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
6489 MapSelectboxGadget(i);
6491 /* draw checkbutton gadgets */
6492 for (i=ED_CHECKBUTTON_ID_LEVEL_FIRST; i <= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
6493 MapCheckbuttonGadget(i);
6495 /* draw radiobutton gadgets */
6496 for (i=ED_RADIOBUTTON_ID_LEVEL_FIRST; i <= ED_RADIOBUTTON_ID_LEVEL_LAST; i++)
6497 MapRadiobuttonGadget(i);
6499 /* draw text input gadgets */
6500 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
6501 MapTextInputGadget(i);
6503 /* draw drawing area */
6504 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
6507 static void DrawCustomContentArea()
6509 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
6510 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6511 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
6512 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
6513 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
6514 int xoffset = ED_DRAWINGAREA_TEXT_DISTANCE;
6516 /* add distance for potential left text (without drawing area border) */
6517 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
6519 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
6521 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
6524 static void DrawCustomChangeContentArea()
6526 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
6527 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6528 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
6529 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
6530 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
6531 int xoffset = ED_DRAWINGAREA_TEXT_DISTANCE;
6533 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
6538 static void DrawElementContentAreas()
6540 int x = SX + ED_AREA_YAMYAM_CONTENT_XPOS(3) + 4 * MINI_TILEX;
6541 int y = SY + ED_AREA_YAMYAM_CONTENT_YPOS(0) + ED_BORDER_AREA_YSIZE;
6544 /* display counter to choose number of element content areas */
6545 MapCounterButtons(ED_COUNTER_ID_ELEMENT_CONTENT);
6547 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
6549 int id = ED_DRAWING_ID_ELEMENT_CONTENT_0 + i;
6550 int font_height = getFontHeight(FONT_TEXT_1);
6552 if (i < level.num_yamyam_contents)
6556 UnmapDrawingArea(id);
6558 /* delete content areas in case of reducing number of them */
6559 DrawBackground(SX + drawingarea_info[id].x - MINI_TILEX / 2,
6560 SY + drawingarea_info[id].y - MINI_TILEY / 2,
6562 4 * MINI_TILEY + ED_GADGET_TEXT_DISTANCE + font_height);
6566 DrawText(x, y + 0 * MINI_TILEY, "content", FONT_TEXT_1);
6567 DrawText(x, y + 1 * MINI_TILEY, "when", FONT_TEXT_1);
6568 DrawText(x, y + 2 * MINI_TILEY, "smashed", FONT_TEXT_1);
6571 static void DrawGroupElementArea(int element)
6573 int num_elements = group_element_info.num_elements;
6574 int id = ED_DRAWING_ID_GROUP_CONTENT;
6575 int sx = SX + drawingarea_info[id].x - MINI_TILEX / 2;
6576 int sy = SY + drawingarea_info[id].y - MINI_TILEY / 2;
6577 int xsize = MAX_ELEMENTS_IN_GROUP;
6580 if (drawingarea_info[id].text_left != NULL)
6581 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
6583 UnmapDrawingArea(id);
6585 ModifyEditorDrawingArea(id, num_elements, 1);
6587 /* delete content areas in case of reducing number of them */
6588 DrawBackground(sx, sy, (xsize + 1) * MINI_TILEX, (ysize + 1) * MINI_TILEY);
6593 static void DrawEnvelopeTextArea(int envelope_nr)
6595 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
6596 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
6599 DrawBackground(gi->x, gi->y, gi->width, gi->height);
6601 if (envelope_nr != -1)
6602 textarea_info[id].value = level.envelope_text[envelope_nr];
6604 ModifyGadget(gi, GDI_AREA_SIZE,
6605 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
6606 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
6609 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
6612 char *getElementDescriptionFilename(int element)
6614 char *docs_dir = options.docs_directory;
6615 char *elements_subdir = "elements";
6616 static char *filename = NULL;
6617 char basename[MAX_FILENAME_LEN];
6619 checked_free(filename);
6621 /* 1st try: look for element description file for exactly this element */
6622 sprintf(basename, "%s.txt", element_info[element].token_name);
6623 filename = getPath3(docs_dir, elements_subdir, basename);
6624 if (fileExists(filename))
6629 /* 2nd try: look for element description file for this element's class */
6630 sprintf(basename, "%s.txt", element_info[element].class_name);
6631 filename = getPath3(docs_dir, elements_subdir, basename);
6632 if (fileExists(filename))
6638 static boolean PrintInfoText(char *text, int font_nr, int start_line)
6640 int font_height = getFontHeight(font_nr);
6641 int pad_x = ED_SETTINGS_XPOS(0);
6642 int pad_y = ED_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
6643 int sx = SX + pad_x;
6644 int sy = SY + pad_y;
6645 int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
6647 if (start_line >= max_lines_per_screen)
6650 DrawText(sx, sy + start_line * font_height, text, font_nr);
6657 static int PrintElementDescriptionFromFile(char *filename, int start_line)
6659 int font_nr = FONT_TEXT_2;
6660 int font_width = getFontWidth(font_nr);
6661 int font_height = getFontHeight(font_nr);
6662 int pad_x = ED_SETTINGS_XPOS(0);
6663 int pad_y = ED_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
6664 int sx = SX + pad_x;
6665 int sy = SY + pad_y + start_line * font_height;
6666 int max_chars_per_line = (SXSIZE - 2 * pad_x) / font_width;
6667 int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
6669 return DrawTextFromFile(sx, sy, filename, font_nr, max_chars_per_line,
6670 max_lines_per_screen);
6675 static int PrintElementDescriptionFromFile(char *filename, int start_line)
6677 int font_nr = FONT_TEXT_2;
6678 int font_width = getFontWidth(font_nr);
6679 int font_height = getFontHeight(font_nr);
6680 int pad_x = ED_SETTINGS_XPOS(0);
6681 int pad_y = ED_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
6682 int sx = SX + pad_x;
6683 int sy = SY + pad_y;
6684 int max_chars_per_line = (SXSIZE - 2 * pad_x) / font_width;
6685 int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
6686 int current_line = start_line;
6687 char line[MAX_LINE_LEN];
6688 char buffer[max_chars_per_line + 1];
6692 if (current_line >= max_lines_per_screen)
6695 if (filename == NULL)
6698 if (!(file = fopen(filename, MODE_READ)))
6704 while (!feof(file) && current_line < max_lines_per_screen)
6707 boolean last_line_was_empty = TRUE;
6709 /* read next line of input file */
6710 if (!fgets(line, MAX_LINE_LEN, file))
6713 /* skip comments (lines directly beginning with '#') */
6717 /* cut trailing newline from input line */
6718 for (line_ptr = line; *line_ptr; line_ptr++)
6720 if (*line_ptr == '\n' || *line_ptr == '\r')
6727 if (strlen(line) == 0) /* special case: force empty line */
6732 while (*line_ptr && current_line < max_lines_per_screen)
6734 boolean buffer_filled = RenderLineToBuffer(&line_ptr,
6735 buffer, &buffer_len,
6736 last_line_was_empty,
6737 max_chars_per_line);
6740 DrawText(sx, sy + current_line * font_height, buffer, font_nr);
6743 last_line_was_empty = (buffer_len == 0);
6753 if (buffer_len > 0 && current_line < max_lines_per_screen)
6755 DrawText(sx, sy + current_line * font_height, buffer, font_nr);
6759 return (current_line - start_line);
6764 static void DrawPropertiesTabulatorGadgets()
6766 struct GadgetInfo *gd_gi = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
6767 struct GadgetDesign *gd = &gd_gi->alt_design[GD_BUTTON_UNPRESSED];
6768 int gd_x = gd->x + gd_gi->border.width / 2;
6769 int gd_y = gd->y + gd_gi->height - 1;
6770 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
6771 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
6772 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
6776 /* draw additional "advanced" tabulator for custom elements */
6777 if (IS_CUSTOM_ELEMENT(properties_element))
6778 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
6780 for (i = id_first; i <= id_last; i++)
6782 int gadget_id = textbutton_info[i].gadget_id;
6783 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
6784 boolean active = (i != edit_mode_properties);
6786 /* use "config 1" and "config 2" instead of "config" */
6787 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
6788 IS_CUSTOM_ELEMENT(properties_element))
6791 /* draw background line below tabulator button */
6792 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width,1);
6794 /* draw solid line below inactive tabulator buttons */
6795 if (!active && tab_color != BLACK_PIXEL) /* black => transparent */
6796 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,1, tab_color);
6798 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
6799 MapTextbuttonGadget(i);
6802 /* draw little border line below tabulator buttons */
6803 if (tab_color != BLACK_PIXEL) /* black => transparent */
6804 FillRectangle(drawto, gd_gi->x, gd_gi->y + gd_gi->height + 1,
6805 max_tabs * gd_gi->width + (max_tabs -1) * ED_GADGET_DISTANCE,
6806 ED_GADGET_DISTANCE, tab_color);
6809 static void DrawPropertiesInfo()
6818 /* configurable properties */
6820 { EP_WALKABLE_OVER, "- player can walk over it" },
6821 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
6822 { EP_WALKABLE_UNDER, "- player can walk under it" },
6823 { EP_PASSABLE_OVER, "- player can pass over it" },
6824 { EP_PASSABLE_INSIDE, "- player can pass through it" },
6825 { EP_PASSABLE_UNDER, "- player can pass under it" },
6826 { EP_PROTECTED, "- player is protected by it" },
6828 { EP_DIGGABLE, "- can be digged away" },
6829 { EP_COLLECTIBLE, "- can be collected" },
6830 { EP_DROPPABLE, "- can be dropped after collecting" },
6831 { EP_THROWABLE, "- can be thrown after collecting" },
6832 { EP_PUSHABLE, "- can be pushed" },
6834 { EP_CAN_FALL, "- can fall" },
6835 { EP_CAN_MOVE, "- can move" },
6837 { EP_CAN_SMASH_PLAYER, "- can smash player" },
6839 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
6841 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
6843 { EP_SLIPPERY, "- slippery for falling elements" },
6844 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
6846 { EP_DONT_RUN_INTO, "- deadly when running into" },
6847 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
6848 { EP_DONT_TOUCH, "- deadly when touching" },
6850 { EP_INDESTRUCTIBLE, "- indestructible" },
6852 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
6853 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
6854 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
6856 { EP_CAN_CHANGE, "- can change to other element" },
6858 /* pre-defined properties */
6859 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
6860 { EP_SWITCHABLE, "- can be switched" },
6861 { EP_HAS_CONTENT, "- can contain other elements" },
6865 char *filename = getElementDescriptionFilename(properties_element);
6866 char *percentage_text = "In this level:";
6867 char *properties_text = "Standard properties:";
6869 int num_elements_in_level;
6870 int num_standard_properties = 0;
6871 int font1_nr = FONT_TEXT_1;
6872 int font2_nr = FONT_TEXT_2;
6873 int font1_width = getFontWidth(font1_nr);
6874 int font2_height = getFontHeight(font2_nr);
6875 int pad_x = ED_SETTINGS_XPOS(0);
6876 int pad_y = ED_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
6877 int screen_line = 0;
6881 if (IS_CUSTOM_ELEMENT(properties_element))
6883 DrawTextF(pad_x, pad_y + screen_line++ * font2_height, FONT_TEXT_3,
6884 "[Custom Element %d]", properties_element - EL_CUSTOM_START + 1);
6887 else if (IS_GROUP_ELEMENT(properties_element))
6889 DrawTextF(pad_x, pad_y + screen_line++ * font2_height, FONT_TEXT_3,
6890 "[Group Element %d]", properties_element - EL_GROUP_START + 1);
6895 /* ----- print number of elements / percentage of this element in level */
6897 num_elements_in_level = 0;
6898 for (y = 0; y < lev_fieldy; y++)
6899 for (x = 0; x < lev_fieldx; x++)
6900 if (Feld[x][y] == properties_element)
6901 num_elements_in_level++;
6902 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
6904 DrawTextS(pad_x, pad_y + screen_line * font2_height, font1_nr,
6906 DrawTextF(pad_x + strlen(percentage_text) * font1_width,
6907 pad_y + screen_line++ * font2_height, font2_nr,
6908 "%d (%.2f%%)", num_elements_in_level, percentage);
6912 /* ----- print standard properties of this element */
6914 DrawTextS(pad_x, pad_y + screen_line++ * font2_height, font1_nr,
6917 for (i = 0; properties[i].value != -1; i++)
6919 if (!HAS_PROPERTY(properties_element, properties[i].value))
6922 DrawTextS(pad_x, pad_y + screen_line++ * font2_height, font2_nr,
6923 properties[i].text);
6924 num_standard_properties++;
6927 if (num_standard_properties == 0)
6928 DrawTextS(pad_x + strlen(properties_text) * font1_width,
6929 pad_y + (screen_line - 1) * font2_height, font2_nr, "none");
6933 /* ----- print special description of this element */
6935 PrintInfoText("Description:", FONT_TEXT_1, screen_line);
6936 if (PrintElementDescriptionFromFile(filename, screen_line + 1) == 0)
6937 PrintInfoText("No description available.", FONT_TEXT_1, screen_line);
6940 #define TEXT_COLLECTING "Score for collecting"
6941 #define TEXT_SMASHING "Score for smashing"
6942 #define TEXT_CRACKING "Score for cracking"
6943 #define TEXT_SPEED "Speed of amoeba growth"
6944 #define TEXT_DURATION "Duration when activated"
6951 } elements_with_counter[] =
6953 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
6954 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
6955 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
6956 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
6957 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
6958 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
6959 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
6960 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
6961 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
6962 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
6963 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
6964 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
6965 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
6966 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
6967 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
6968 { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
6969 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
6970 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
6971 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
6972 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
6973 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6974 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6975 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6976 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6977 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6978 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6979 { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
6980 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6981 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6982 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6983 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6984 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
6985 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
6986 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
6987 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
6988 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
6989 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
6990 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
6991 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
6992 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
6993 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
6994 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE],TEXT_COLLECTING },
6995 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
6996 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
6997 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
6998 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
6999 { EL_EXTRA_TIME, &level.score[SC_TIME_BONUS], TEXT_COLLECTING },
7000 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
7001 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
7002 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
7003 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
7005 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
7006 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
7007 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
7008 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
7010 { EL_EM_KEY_1_FILE, &level.score[SC_KEY], TEXT_COLLECTING },
7011 { EL_EM_KEY_2_FILE, &level.score[SC_KEY], TEXT_COLLECTING },
7012 { EL_EM_KEY_3_FILE, &level.score[SC_KEY], TEXT_COLLECTING },
7013 { EL_EM_KEY_4_FILE, &level.score[SC_KEY], TEXT_COLLECTING },
7015 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_SPEED },
7016 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_SPEED },
7017 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_SPEED },
7018 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_SPEED },
7019 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
7020 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
7024 static boolean checkPropertiesConfig(int element)
7028 if (IS_GEM(element) ||
7029 IS_CUSTOM_ELEMENT(element) ||
7030 IS_GROUP_ELEMENT(element) ||
7031 IS_ENVELOPE(element) ||
7032 ELEM_IS_PLAYER(element) ||
7033 HAS_CONTENT(element) ||
7034 CAN_GROW(element) ||
7035 COULD_MOVE_INTO_ACID(element) ||
7036 MAYBE_DONT_COLLIDE_WITH(element))
7039 for (i = 0; elements_with_counter[i].element != -1; i++)
7040 if (elements_with_counter[i].element == element)
7046 static void DrawPropertiesConfig()
7050 if (!checkPropertiesConfig(properties_element))
7052 PrintInfoText("No configuration options available.", FONT_TEXT_1, 0);
7057 /* check if there are elements where a score can be chosen for */
7058 for (i = 0; elements_with_counter[i].element != -1; i++)
7060 if (elements_with_counter[i].element == properties_element)
7062 int counter_id = ED_COUNTER_ID_ELEMENT_SCORE;
7064 counterbutton_info[counter_id].y =
7065 ED_SETTINGS_YPOS((HAS_CONTENT(properties_element) ? 1 : 0) +
7066 (CAN_GROW(properties_element) ? 1 : 0) +
7067 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
7068 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 :0));
7070 counterbutton_info[counter_id].value = elements_with_counter[i].value;
7071 counterbutton_info[counter_id].text_right= elements_with_counter[i].text;
7073 MapCounterButtons(counter_id);
7079 if (HAS_CONTENT(properties_element))
7081 /* draw stickybutton gadget */
7082 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
7084 if (IS_AMOEBOID(properties_element))
7085 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
7087 DrawElementContentAreas();
7090 if (ELEM_IS_PLAYER(properties_element))
7092 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
7093 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
7094 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
7095 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
7096 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
7097 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
7100 if (IS_GEM(properties_element))
7101 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
7103 if (COULD_MOVE_INTO_ACID(properties_element) &&
7104 !ELEM_IS_PLAYER(properties_element) &&
7105 (!IS_CUSTOM_ELEMENT(properties_element) ||
7106 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
7108 /* set position for checkbutton for "can move into acid" */
7109 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
7110 ED_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
7111 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
7112 ED_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 6 :
7113 HAS_CONTENT(properties_element) ? 1 : 0);
7115 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
7118 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
7119 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
7121 if (properties_element == EL_SPRING)
7122 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
7124 if (CAN_GROW(properties_element))
7126 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
7127 ED_SETTINGS_YPOS(HAS_CONTENT(properties_element) ? 1 : 0);
7129 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
7132 if (IS_ENVELOPE(properties_element))
7134 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
7135 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
7136 int envelope_nr = properties_element - EL_ENVELOPE_1;
7138 counterbutton_info[counter1_id].value = &level.envelope_xsize[envelope_nr];
7139 counterbutton_info[counter2_id].value = &level.envelope_ysize[envelope_nr];
7141 /* display counter to choose size of envelope text area */
7142 MapCounterButtons(ED_COUNTER_ID_ENVELOPE_XSIZE);
7143 MapCounterButtons(ED_COUNTER_ID_ENVELOPE_YSIZE);
7145 DrawEnvelopeTextArea(envelope_nr);
7148 if (IS_CUSTOM_ELEMENT(properties_element))
7150 /* draw stickybutton gadget */
7151 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
7153 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
7155 /* draw checkbutton gadgets */
7156 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
7157 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
7158 MapCheckbuttonGadget(i);
7160 /* draw counter gadgets */
7161 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
7162 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
7163 MapCounterButtons(i);
7165 /* draw selectbox gadgets */
7166 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
7167 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
7168 MapSelectboxGadget(i);
7170 /* draw textbutton gadgets */
7171 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE);
7173 /* draw text input gadgets */
7174 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
7176 /* draw drawing area gadgets */
7177 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
7179 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
7181 /* draw checkbutton gadgets */
7182 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
7183 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
7184 MapCheckbuttonGadget(i);
7186 /* draw counter gadgets */
7187 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
7188 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
7189 MapCounterButtons(i);
7191 /* draw selectbox gadgets */
7192 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
7193 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
7194 MapSelectboxGadget(i);
7196 /* draw drawing area gadgets */
7197 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
7198 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
7199 DrawCustomContentArea();
7202 else if (IS_GROUP_ELEMENT(properties_element))
7204 /* draw stickybutton gadget */
7205 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
7207 /* draw checkbutton gadgets */
7208 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
7209 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE);
7211 /* draw counter gadgets */
7212 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
7214 /* draw selectbox gadgets */
7215 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
7217 /* draw textbutton gadgets */
7218 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE);
7220 /* draw drawing area gadgets */
7221 DrawGroupElementArea(properties_element);
7223 /* draw text input gadgets */
7224 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
7226 /* draw drawing area gadgets */
7227 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
7231 static void DrawPropertiesChangeDrawingAreas()
7233 if (IS_CUSTOM_ELEMENT(properties_element))
7235 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
7236 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
7238 DrawCustomChangeContentArea();
7241 redraw_mask |= REDRAW_FIELD;
7244 static void DrawPropertiesChange()
7248 /* draw stickybutton gadget */
7249 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
7251 /* draw checkbutton gadgets */
7252 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
7253 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
7254 MapCheckbuttonGadget(i);
7256 /* draw counter gadgets */
7257 for (i = ED_COUNTER_ID_CHANGE_FIRST;
7258 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
7259 MapCounterButtons(i);
7261 /* draw selectbox gadgets */
7262 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
7263 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
7264 MapSelectboxGadget(i);
7266 /* draw textbutton gadgets */
7267 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
7268 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
7269 MapTextbuttonGadget(i);
7271 /* draw graphicbutton gadgets */
7272 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
7273 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
7274 MapGraphicbuttonGadget(i);
7276 /* draw drawing area gadgets */
7277 DrawPropertiesChangeDrawingAreas();
7280 static void DrawElementName(int x, int y, int element)
7282 char *element_name = getElementInfoText(element);
7283 int font_nr = FONT_TEXT_1;
7284 int font_width = getFontWidth(font_nr);
7285 int font_height = getFontHeight(font_nr);
7286 int max_text_width = SXSIZE - x - ED_SETTINGS_XPOS(0);
7287 int max_chars_per_line = max_text_width / font_width;
7288 char buffer[max_chars_per_line + 1];
7290 if (strlen(element_name) <= max_chars_per_line)
7291 DrawTextS(x, y, font_nr, element_name);
7294 int next_pos = max_chars_per_line;
7296 strncpy(buffer, element_name, max_chars_per_line);
7297 buffer[max_chars_per_line] = '\0';
7299 if (element_name[max_chars_per_line] == ' ')
7305 for (i = max_chars_per_line - 1; i >= 0; i--)
7306 if (buffer[i] == ' ')
7309 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
7316 DrawTextS(x, y - font_height / 2, font_nr, buffer);
7318 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
7319 buffer[max_chars_per_line] = '\0';
7321 DrawTextS(x, y + font_height / 2, font_nr, buffer);
7325 static void DrawPropertiesWindow()
7330 stick_element_properties_window = FALSE;
7332 /* make sure that previous properties edit mode exists for this element */
7333 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
7334 !IS_CUSTOM_ELEMENT(properties_element))
7335 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
7337 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
7338 IS_CUSTOM_ELEMENT(properties_element))
7339 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
7341 CopyElementPropertiesToEditor(properties_element);
7343 UnmapLevelEditorWindowGadgets();
7344 UnmapLevelEditorToolboxDrawingGadgets();
7345 UnmapLevelEditorToolboxCustomGadgets();
7347 if (IS_CUSTOM_ELEMENT(properties_element) ||
7348 IS_GROUP_ELEMENT(properties_element))
7349 MapLevelEditorToolboxCustomGadgets();
7351 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
7354 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS1_YPOS,
7355 "Element Settings", FONT_TITLE_1);
7357 DrawElementBorder(SX + xstart * MINI_TILEX,
7358 SY + ystart * MINI_TILEY + MINI_TILEY / 2,
7359 TILEX, TILEY, FALSE);
7360 DrawGraphicAnimationExt(drawto,
7361 SX + xstart * MINI_TILEX,
7362 SY + ystart * MINI_TILEY + MINI_TILEY / 2,
7363 el2img(properties_element), -1, NO_MASKING);
7365 FrameCounter = 0; /* restart animation frame counter */
7367 DrawElementName((xstart + 3) * MINI_TILEX + 1, (ystart + 1) * MINI_TILEY + 1,
7368 properties_element);
7370 DrawPropertiesTabulatorGadgets();
7372 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
7373 DrawPropertiesInfo();
7374 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
7375 DrawPropertiesChange();
7376 else /* (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2]) */
7377 DrawPropertiesConfig();
7380 static void UpdateCustomElementGraphicGadgets()
7384 ModifyEditorElementList();
7385 RedrawDrawingElements();
7387 /* force redraw of all mapped drawing area gadgets */
7388 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
7390 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
7397 static void DrawLineElement(int sx, int sy, int element, boolean change_level)
7399 int lx = sx + level_xpos;
7400 int ly = sy + level_ypos;
7402 DrawMiniElement(sx, sy, (element < 0 ? Feld[lx][ly] : element));
7405 Feld[lx][ly] = element;
7408 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
7409 int element, boolean change_level)
7411 if (from_y == to_y) /* horizontal line */
7417 swap_numbers(&from_x, &to_x);
7419 for (x = from_x; x <= to_x; x++)
7420 DrawLineElement(x, y, element, change_level);
7422 else if (from_x == to_x) /* vertical line */
7428 swap_numbers(&from_y, &to_y);
7430 for (y = from_y; y <= to_y; y++)
7431 DrawLineElement(x, y, element, change_level);
7433 else /* diagonal line */
7435 int len_x = ABS(to_x - from_x);
7436 int len_y = ABS(to_y - from_y);
7439 if (len_y < len_x) /* a < 1 */
7441 float a = (float)len_y / (float)len_x;
7444 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
7446 for (x = 0; x <= len_x; x++)
7448 y = (int)(a * x + 0.5) * (to_y < from_y ? -1 : +1);
7449 DrawLineElement(from_x + x, from_y + y, element, change_level);
7454 float a = (float)len_x / (float)len_y;
7457 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
7459 for (y = 0; y <= len_y; y++)
7461 x = (int)(a * y + 0.5) * (to_x < from_x ? -1 : +1);
7462 DrawLineElement(from_x + x, from_y + y, element, change_level);
7468 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
7469 int element, boolean change_level)
7471 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
7472 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
7473 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
7474 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
7477 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
7478 int element, boolean change_level)
7483 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
7485 for (y = from_y; y <= to_y; y++)
7486 DrawLine(from_x, y, to_x, y, element, change_level);
7489 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
7490 int element, boolean change_level)
7492 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
7493 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
7494 int len_x = ABS(to_x - from_x);
7495 int len_y = ABS(to_y - from_y);
7498 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
7500 /* not optimal (some points get drawn twice) but simple,
7501 and fast enough for the few points we are drawing */
7503 for (x = 0; x <= radius; x++)
7507 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
7509 sx = from_x + x * (from_x < to_x2 ? +1 : -1);
7510 sy = from_y + y * (from_y < to_y2 ? +1 : -1);
7511 lx = sx + level_xpos;
7512 ly = sy + level_ypos;
7514 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
7515 DrawLineElement(sx, sy, element, change_level);
7518 for (y = 0; y <= radius; y++)
7522 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
7524 sx = from_x + x * (from_x < to_x2 ? +1 : -1);
7525 sy = from_y + y * (from_y < to_y2 ? +1 : -1);
7526 lx = sx + level_xpos;
7527 ly = sy + level_ypos;
7529 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
7530 DrawLineElement(sx, sy, element, change_level);
7534 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
7535 int element, boolean change_level)
7537 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
7538 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
7540 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
7543 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
7544 #if DRAW_CIRCLES_BUTTON_AVAILABLE
7545 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
7546 int element, boolean change_level)
7548 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
7549 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
7550 int mirror_to_x2 = from_x - (to_x2 - from_x);
7551 int mirror_to_y2 = from_y - (to_y2 - from_y);
7553 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
7554 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
7555 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
7556 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element,change_level);
7560 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
7562 int from_sx, from_sy;
7566 swap_numbers(&from_x, &to_x);
7569 swap_numbers(&from_y, &to_y);
7571 from_sx = SX + from_x * MINI_TILEX;
7572 from_sy = SY + from_y * MINI_TILEY;
7573 to_sx = SX + to_x * MINI_TILEX + MINI_TILEX - 1;
7574 to_sy = SY + to_y * MINI_TILEY + MINI_TILEY - 1;
7576 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
7577 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
7578 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
7579 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
7581 if (from_x == to_x && from_y == to_y)
7582 MarkTileDirty(from_x/2, from_y/2);
7584 redraw_mask |= REDRAW_FIELD;
7587 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
7588 int element, boolean change_level)
7590 if (element == -1 || change_level)
7591 DrawBox(from_x, from_y, to_x, to_y, -1, FALSE);
7593 DrawAreaBorder(from_x, from_y, to_x, to_y);
7596 /* values for CopyBrushExt() */
7597 #define CB_AREA_TO_BRUSH 0
7598 #define CB_BRUSH_TO_CURSOR 1
7599 #define CB_BRUSH_TO_LEVEL 2
7600 #define CB_DELETE_OLD_CURSOR 3
7601 #define CB_DUMP_BRUSH 4
7603 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
7604 int button, int mode)
7606 static short brush_buffer[MAX_ED_FIELDX][MAX_ED_FIELDY];
7607 static int brush_width, brush_height;
7608 static int last_cursor_x = -1, last_cursor_y = -1;
7609 static boolean delete_old_brush;
7610 int new_element = BUTTON_ELEMENT(button);
7613 if (mode == CB_DUMP_BRUSH)
7615 if (!draw_with_brush)
7617 Error(ERR_WARN, "no brush selected");
7622 for (y = 0; y < brush_height; y++)
7624 for (x = 0; x < brush_width; x++)
7626 int element = brush_buffer[x][y];
7627 int element_mapped = element;
7630 char *element_string = "?";
7633 for (k = 0; forum_sketch_element_mapping[k].element != -1; k++)
7635 if (forum_sketch_element_mapping[k].element == element)
7637 element_mapped = forum_sketch_element_mapping[k].element_mapped;
7642 if (IS_CUSTOM_ELEMENT(element))
7643 element_mapped = EL_CUSTOM_1;
7645 for (k = 0; forum_sketch_element_strings[k].element != -1; k++)
7647 if (forum_sketch_element_strings[k].element == element_mapped)
7649 element_string = forum_sketch_element_strings[k].element_string;
7654 printf("`%s", element_string);
7658 if (IS_CUSTOM_ELEMENT(element))
7659 element_mapped = EL_CUSTOM_START;
7660 else if (element > EL_ENVELOPE_4)
7661 element_mapped = EL_CHAR_QUESTION; /* change to EL_UNKNOWN ... */
7663 printf("`%03d", element_mapped);
7673 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
7676 if (mode == CB_AREA_TO_BRUSH)
7678 int from_lx, from_ly;
7681 swap_numbers(&from_x, &to_x);
7684 swap_numbers(&from_y, &to_y);
7686 brush_width = to_x - from_x + 1;
7687 brush_height = to_y - from_y + 1;
7689 from_lx = from_x + level_xpos;
7690 from_ly = from_y + level_ypos;
7692 for (y = 0; y < brush_height; y++)
7694 for (x=0; x < brush_width; x++)
7696 brush_buffer[x][y] = Feld[from_lx + x][from_ly + y];
7699 DrawLineElement(from_x + x, from_y + y, new_element, TRUE);
7704 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7706 delete_old_brush = FALSE;
7708 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
7709 mode == CB_BRUSH_TO_LEVEL)
7711 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
7712 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
7713 int cursor_from_x = cursor_x - brush_width / 2;
7714 int cursor_from_y = cursor_y - brush_height / 2;
7715 int border_from_x = cursor_x, border_from_y = cursor_y;
7716 int border_to_x = cursor_x, border_to_y = cursor_y;
7718 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
7719 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
7721 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
7722 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
7724 delete_old_brush = FALSE;
7728 for (y = 0; y < brush_height; y++)
7730 for (x = 0; x < brush_width; x++)
7732 int sx = cursor_from_x + x;
7733 int sy = cursor_from_y + y;
7734 int lx = sx + level_xpos;
7735 int ly = sy + level_ypos;
7736 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
7737 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
7738 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
7739 brush_buffer[x][y] : new_element);
7741 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
7743 if (sx < border_from_x)
7745 else if (sx > border_to_x)
7747 if (sy < border_from_y)
7749 else if (sy > border_to_y)
7752 DrawLineElement(sx, sy, element, change_level);
7757 if (mode != CB_DELETE_OLD_CURSOR)
7758 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
7760 last_cursor_x = cursor_x;
7761 last_cursor_y = cursor_y;
7762 delete_old_brush = TRUE;
7766 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
7769 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
7772 static void CopyBrushToLevel(int x, int y, int button)
7774 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
7777 static void CopyBrushToCursor(int x, int y)
7779 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
7782 static void DeleteBrushFromCursor()
7784 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
7789 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
7792 static void FloodFill(int from_x, int from_y, int fill_element)
7796 static int check[4][2] = { {-1,0}, {0,-1}, {1,0}, {0,1} };
7797 static int safety = 0;
7799 /* check if starting field still has the desired content */
7800 if (Feld[from_x][from_y] == fill_element)
7805 if (safety > lev_fieldx*lev_fieldy)
7806 Error(ERR_EXIT, "Something went wrong in 'FloodFill()'. Please debug.");
7808 old_element = Feld[from_x][from_y];
7809 Feld[from_x][from_y] = fill_element;
7811 for (i = 0; i < 4; i++)
7813 x = from_x + check[i][0];
7814 y = from_y + check[i][1];
7816 if (IN_LEV_FIELD(x,y) && Feld[x][y] == old_element)
7817 FloodFill(x, y, fill_element);
7823 /* values for DrawLevelText() modes */
7825 #define TEXT_SETCURSOR 1
7826 #define TEXT_WRITECHAR 2
7827 #define TEXT_BACKSPACE 3
7828 #define TEXT_NEWLINE 4
7830 #define TEXT_QUERY_TYPING 6
7832 static int DrawLevelText(int sx, int sy, char letter, int mode)
7834 static short delete_buffer[MAX_LEV_FIELDX];
7835 static int start_sx, start_sy;
7836 static int last_sx, last_sy;
7837 static boolean typing = FALSE;
7838 int letter_element = EL_CHAR_ASCII0 + letter;
7841 /* map lower case letters to upper case and convert special characters */
7842 if (letter >= 'a' && letter <= 'z')
7843 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
7844 else if (letter == 'ä' || letter == 'Ä')
7845 letter_element = EL_CHAR_AUMLAUT;
7846 else if (letter == 'ö' || letter == 'Ö')
7847 letter_element = EL_CHAR_OUMLAUT;
7848 else if (letter == 'ü' || letter == 'Ü')
7849 letter_element = EL_CHAR_UUMLAUT;
7850 else if (letter == '^')
7851 letter_element = EL_CHAR_COPYRIGHT;
7853 letter_element = EL_CHAR_ASCII0 + letter;
7855 if (mode != TEXT_INIT)
7860 if (mode != TEXT_SETCURSOR)
7866 lx = last_sx + level_xpos;
7867 ly = last_sy + level_ypos;
7874 DrawLevelText(0, 0, 0, TEXT_END);
7877 start_sx = last_sx = sx;
7878 start_sy = last_sy = sy;
7879 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
7882 case TEXT_SETCURSOR:
7883 DrawMiniElement(last_sx, last_sy, Feld[lx][ly]);
7884 DrawAreaBorder(sx, sy, sx, sy);
7889 case TEXT_WRITECHAR:
7890 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
7892 delete_buffer[sx - start_sx] = Feld[lx][ly];
7893 Feld[lx][ly] = letter_element;
7895 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
7896 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
7897 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
7898 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
7900 DrawLevelText(0, 0, 0, TEXT_END);
7904 case TEXT_BACKSPACE:
7907 Feld[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
7908 DrawMiniElement(sx - 1, sy, Feld[lx - 1][ly]);
7909 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
7914 if (sy + 1 < ed_fieldy - 1 && ly + 1 < lev_fieldy - 1)
7915 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
7917 DrawLevelText(0, 0, 0, TEXT_END);
7921 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7922 DrawMiniElement(sx, sy, Feld[lx][ly]);
7926 case TEXT_QUERY_TYPING:
7936 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
7937 int element, boolean change_level)
7939 int lx = sx + level_xpos;
7940 int ly = sy + level_ypos;
7943 DrawMiniElement(sx, sy, Feld[lx][ly]);
7945 DrawAreaBorder(sx, sy, sx, sy);
7948 static void CopyLevelToUndoBuffer(int mode)
7950 static boolean accumulated_undo = FALSE;
7951 boolean new_undo_buffer_position = TRUE;
7952 int last_border_element;
7957 case UNDO_IMMEDIATE:
7958 accumulated_undo = FALSE;
7961 case UNDO_ACCUMULATE:
7962 if (accumulated_undo)
7963 new_undo_buffer_position = FALSE;
7964 accumulated_undo = TRUE;
7971 if (new_undo_buffer_position)
7973 /* new position in undo buffer ring */
7974 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
7976 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
7977 undo_buffer_steps++;
7980 for (x = 0; x < lev_fieldx; x++)
7981 for (y = 0; y < lev_fieldy; y++)
7982 UndoBuffer[undo_buffer_position][x][y] = Feld[x][y];
7984 /* check if drawing operation forces change of border style */
7985 last_border_element = BorderElement;
7987 if (BorderElement != last_border_element)
7988 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7991 static void RandomPlacement(int new_element)
7993 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
7994 int num_free_positions;
7999 /* determine number of free positions for the new elements */
8000 /* (maybe this statement should be formatted a bit more readable...) */
8001 num_free_positions = 0;
8002 for (x = 0; x < lev_fieldx; x++)
8003 for (y = 0; y < lev_fieldy; y++)
8004 if ((free_position[x][y] =
8005 ((random_placement_background_restricted &&
8006 Feld[x][y] == random_placement_background_element) ||
8007 (!random_placement_background_restricted &&
8008 Feld[x][y] != new_element))) == TRUE)
8009 num_free_positions++;
8011 /* determine number of new elements to place there */
8012 num_percentage = num_free_positions * random_placement_value / 100;
8013 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
8014 num_percentage : random_placement_value);
8016 /* if not more free positions than elements to place, fill whole level */
8017 if (num_elements >= num_free_positions)
8019 for (x = 0; x < lev_fieldx; x++)
8020 for (y = 0; y < lev_fieldy; y++)
8021 Feld[x][y] = new_element;
8023 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8024 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8028 while (num_elements > 0)
8030 x = RND(lev_fieldx);
8031 y = RND(lev_fieldy);
8033 /* don't place element at the same position twice */
8034 if (free_position[x][y])
8036 free_position[x][y] = FALSE;
8037 Feld[x][y] = new_element;
8042 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8043 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8046 void WrapLevel(int dx, int dy)
8048 int wrap_dx = lev_fieldx - dx;
8049 int wrap_dy = lev_fieldy - dy;
8052 for (x = 0; x < lev_fieldx; x++)
8053 for (y = 0; y < lev_fieldy; y++)
8054 FieldBackup[x][y] = Feld[x][y];
8056 for (x = 0; x < lev_fieldx; x++)
8057 for (y = 0; y < lev_fieldy; y++)
8059 FieldBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
8061 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8062 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
8065 static void HandleDrawingAreas(struct GadgetInfo *gi)
8067 static boolean started_inside_drawing_area = FALSE;
8068 int id = gi->custom_id;
8069 boolean button_press_event;
8070 boolean button_release_event;
8071 boolean inside_drawing_area = !gi->event.off_borders;
8072 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
8073 int actual_drawing_function;
8074 int button = gi->event.button;
8075 int new_element = BUTTON_ELEMENT(button);
8076 int sx = gi->event.x, sy = gi->event.y;
8077 int min_sx = 0, min_sy = 0;
8078 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
8079 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
8081 int min_lx = 0, min_ly = 0;
8082 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
8085 /* handle info callback for each invocation of action callback */
8086 gi->callback_info(gi);
8088 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
8089 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
8091 /* make sure to stay inside drawing area boundaries */
8092 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
8093 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
8097 /* get positions inside level field */
8098 lx = sx + level_xpos;
8099 ly = sy + level_ypos;
8101 if (!IN_LEV_FIELD(lx, ly))
8102 inside_drawing_area = FALSE;
8104 /* make sure to stay inside level field boundaries */
8105 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
8106 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
8108 /* correct drawing area positions accordingly */
8109 sx = lx - level_xpos;
8110 sy = ly - level_ypos;
8113 if (button_press_event)
8114 started_inside_drawing_area = inside_drawing_area;
8116 if (!started_inside_drawing_area)
8119 if (!button && !button_release_event)
8122 /* automatically switch to 'single item' drawing mode, if needed */
8123 actual_drawing_function =
8124 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
8125 drawing_function : GADGET_ID_SINGLE_ITEMS);
8127 /* clicking into drawing area with pressed Control key picks element */
8128 if (GetKeyModState() & KMOD_Control)
8130 last_drawing_function = drawing_function;
8131 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
8134 switch (actual_drawing_function)
8136 case GADGET_ID_SINGLE_ITEMS:
8139 if (button_release_event)
8141 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8143 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
8144 !inside_drawing_area)
8145 DeleteBrushFromCursor();
8151 if (draw_with_brush)
8153 if (!button_release_event)
8154 CopyBrushToLevel(sx, sy, button);
8156 else if (new_element != Feld[lx][ly])
8158 if (new_element == EL_PLAYER_1)
8160 /* remove player at old position */
8161 for (y = 0; y < lev_fieldy; y++)
8163 for (x = 0; x < lev_fieldx; x++)
8165 if (Feld[x][y] == EL_PLAYER_1)
8167 Feld[x][y] = EL_EMPTY;
8168 if (x - level_xpos >= 0 && x - level_xpos < ed_fieldx &&
8169 y - level_ypos >= 0 && y - level_ypos < ed_fieldy)
8170 DrawMiniElement(x - level_xpos, y - level_ypos,
8177 Feld[lx][ly] = new_element;
8178 DrawMiniElement(sx, sy, new_element);
8183 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
8184 DrawMiniGraphicExt(drawto,
8185 gi->x + sx * MINI_TILEX,
8186 gi->y + sy * MINI_TILEY,
8187 el2edimg(new_element));
8189 DrawGraphicExt(drawto,
8192 el2img(new_element), 0);
8194 if (id == GADGET_ID_AMOEBA_CONTENT)
8195 level.amoeba_content = new_element;
8196 else if (id == GADGET_ID_CUSTOM_GRAPHIC)
8198 new_element = GFX_ELEMENT(new_element);
8199 custom_element.gfx_element = new_element;
8201 CopyElementPropertiesToGame(properties_element);
8203 UpdateCustomElementGraphicGadgets();
8205 FrameCounter = 0; /* restart animation frame counter */
8207 else if (id == GADGET_ID_CUSTOM_CONTENT)
8209 custom_element.content[sx][sy] = new_element;
8211 CopyCustomElementPropertiesToGame(properties_element);
8213 else if (id == GADGET_ID_CUSTOM_MOVE_ENTER)
8215 custom_element.move_enter_element = new_element;
8217 CopyCustomElementPropertiesToGame(properties_element);
8219 else if (id == GADGET_ID_CUSTOM_MOVE_LEAVE)
8221 custom_element.move_leave_element = new_element;
8223 CopyCustomElementPropertiesToGame(properties_element);
8225 else if (id == GADGET_ID_CUSTOM_CHANGE_TARGET)
8227 custom_element_change.target_element = new_element;
8229 CopyCustomElementPropertiesToGame(properties_element);
8231 else if (id == GADGET_ID_CUSTOM_CHANGE_CONTENT)
8233 custom_element_change.target_content[sx][sy] = new_element;
8235 CopyCustomElementPropertiesToGame(properties_element);
8237 else if (id == GADGET_ID_CUSTOM_CHANGE_TRIGGER)
8239 custom_element_change.trigger_element = new_element;
8241 CopyCustomElementPropertiesToGame(properties_element);
8243 else if (id == GADGET_ID_GROUP_CONTENT)
8245 group_element_info.element[sx] = new_element;
8247 CopyGroupElementPropertiesToGame(properties_element);
8249 else if (id == GADGET_ID_RANDOM_BACKGROUND)
8250 random_placement_background_element = new_element;
8251 else if (id >= GADGET_ID_ELEMENT_CONTENT_0 &&
8252 id <= GADGET_ID_ELEMENT_CONTENT_7)
8253 level.yamyam_content[id - GADGET_ID_ELEMENT_CONTENT_0][sx][sy] =
8258 case GADGET_ID_CONNECTED_ITEMS:
8260 static int last_sx = -1;
8261 static int last_sy = -1;
8263 if (button_release_event)
8264 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8268 if (!button_press_event)
8269 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
8277 case GADGET_ID_LINE:
8279 case GADGET_ID_RECTANGLE:
8280 case GADGET_ID_FILLED_BOX:
8281 case GADGET_ID_GRAB_BRUSH:
8282 case GADGET_ID_TEXT:
8284 static int last_sx = -1;
8285 static int last_sy = -1;
8286 static int start_sx = -1;
8287 static int start_sy = -1;
8288 void (*draw_func)(int, int, int, int, int, boolean);
8290 if (drawing_function == GADGET_ID_LINE)
8291 draw_func = DrawLine;
8292 else if (drawing_function == GADGET_ID_ARC)
8293 draw_func = DrawArc;
8294 else if (drawing_function == GADGET_ID_RECTANGLE)
8295 draw_func = DrawBox;
8296 else if (drawing_function == GADGET_ID_FILLED_BOX)
8297 draw_func = DrawFilledBox;
8298 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
8299 draw_func = SelectArea;
8300 else /* (drawing_function == GADGET_ID_TEXT) */
8301 draw_func = SetTextCursor;
8303 if (button_press_event)
8305 draw_func(sx, sy, sx, sy, new_element, FALSE);
8306 start_sx = last_sx = sx;
8307 start_sy = last_sy = sy;
8309 if (drawing_function == GADGET_ID_TEXT)
8310 DrawLevelText(0, 0, 0, TEXT_END);
8312 else if (button_release_event)
8314 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
8315 if (drawing_function == GADGET_ID_GRAB_BRUSH)
8317 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
8318 CopyBrushToCursor(sx, sy);
8319 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
8321 draw_with_brush = TRUE;
8323 else if (drawing_function == GADGET_ID_TEXT)
8324 DrawLevelText(sx, sy, 0, TEXT_INIT);
8326 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8328 else if (last_sx != sx || last_sy != sy)
8330 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
8331 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
8338 case GADGET_ID_FLOOD_FILL:
8339 if (button_press_event && Feld[lx][ly] != new_element)
8341 FloodFill(lx, ly, new_element);
8342 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8343 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8347 case GADGET_ID_PICK_ELEMENT:
8348 if (button_release_event)
8349 ClickOnGadget(level_editor_gadget[last_drawing_function],
8351 else if (draw_level)
8352 PickDrawingElement(button, Feld[lx][ly]);
8353 else if (id == GADGET_ID_AMOEBA_CONTENT)
8354 PickDrawingElement(button, level.amoeba_content);
8355 else if (id == GADGET_ID_CUSTOM_GRAPHIC)
8356 PickDrawingElement(button, custom_element.gfx_element);
8357 else if (id == GADGET_ID_CUSTOM_CONTENT)
8358 PickDrawingElement(button, custom_element.content[sx][sy]);
8359 else if (id == GADGET_ID_CUSTOM_MOVE_ENTER)
8360 PickDrawingElement(button, custom_element.move_enter_element);
8361 else if (id == GADGET_ID_CUSTOM_MOVE_LEAVE)
8362 PickDrawingElement(button, custom_element.move_leave_element);
8363 else if (id == GADGET_ID_CUSTOM_CHANGE_TARGET)
8364 PickDrawingElement(button, custom_element_change.target_element);
8365 else if (id == GADGET_ID_CUSTOM_CHANGE_CONTENT)
8366 PickDrawingElement(button, custom_element_change.target_content[sx][sy]);
8367 else if (id == GADGET_ID_CUSTOM_CHANGE_TRIGGER)
8368 PickDrawingElement(button, custom_element_change.trigger_element);
8369 else if (id == GADGET_ID_GROUP_CONTENT)
8370 PickDrawingElement(button, group_element_info.element[sx]);
8371 else if (id == GADGET_ID_RANDOM_BACKGROUND)
8372 PickDrawingElement(button, random_placement_background_element);
8373 else if (id >= GADGET_ID_ELEMENT_CONTENT_0 &&
8374 id <= GADGET_ID_ELEMENT_CONTENT_7)
8376 int i = id - GADGET_ID_ELEMENT_CONTENT_0;
8378 PickDrawingElement(button, level.yamyam_content[i][sx][sy]);
8388 static void HandleCounterButtons(struct GadgetInfo *gi)
8390 int gadget_id = gi->custom_id;
8391 int counter_id = gi->custom_type_id;
8392 int button = gi->event.button;
8393 int *counter_value = counterbutton_info[counter_id].value;
8394 int step = BUTTON_STEPSIZE(button) *
8395 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
8397 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
8399 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
8400 boolean released = (gi->event.type == GD_EVENT_RELEASED);
8401 boolean level_changed = LevelChanged();
8403 if ((level_changed && pressed) || (!level_changed && released))
8406 if (level_changed && !Request("Level has changed! Discard changes ?",
8409 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
8410 ModifyEditorCounter(counter_id, *counter_value);
8415 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
8416 *counter_value = gi->textinput.number_value;
8418 ModifyEditorCounter(counter_id, *counter_value + step);
8422 case ED_COUNTER_ID_ELEMENT_CONTENT:
8423 DrawElementContentAreas();
8426 case ED_COUNTER_ID_GROUP_CONTENT:
8427 DrawGroupElementArea(properties_element);
8428 CopyGroupElementPropertiesToGame(properties_element);
8431 case ED_COUNTER_ID_ENVELOPE_XSIZE:
8432 case ED_COUNTER_ID_ENVELOPE_YSIZE:
8433 DrawEnvelopeTextArea(-1);
8436 case ED_COUNTER_ID_LEVEL_XSIZE:
8437 case ED_COUNTER_ID_LEVEL_YSIZE:
8438 lev_fieldx = level.fieldx;
8439 lev_fieldy = level.fieldy;
8442 case ED_COUNTER_ID_SELECT_LEVEL:
8443 LoadLevel(level_nr);
8446 DrawEditModeWindow();
8453 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
8454 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
8455 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
8456 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
8457 CopyElementPropertiesToGame(properties_element);
8460 static void HandleTextInputGadgets(struct GadgetInfo *gi)
8462 int type_id = gi->custom_type_id;
8464 strcpy(textinput_info[type_id].value, gi->textinput.value);
8466 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
8468 CopyElementPropertiesToGame(properties_element);
8470 ModifyEditorElementList(); /* update changed button info text */
8474 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
8476 int type_id = gi->custom_type_id;
8478 strcpy(textarea_info[type_id].value, gi->textarea.value);
8481 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
8483 int type_id = gi->custom_type_id;
8485 *selectbox_info[type_id].value =
8486 selectbox_info[type_id].options[gi->selectbox.index].value;
8488 if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
8490 element_info[properties_element].current_change_page = gi->selectbox.index;
8492 DrawPropertiesWindow();
8494 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
8495 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
8496 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
8497 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
8498 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
8499 CopyElementPropertiesToGame(properties_element);
8502 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
8504 int type_id = gi->custom_type_id;
8507 if (type_id >= ED_TEXTBUTTON_ID_PROPERTIES_FIRST &&
8508 type_id <= ED_TEXTBUTTON_ID_PROPERTIES_LAST)
8510 edit_mode_properties = gi->custom_type_id;
8512 DrawPropertiesWindow();
8514 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE)
8516 char *template_filename = getDefaultLevelFilename(-1);
8517 boolean new_template = !fileExists(template_filename);
8520 Request("Save this template and kill the old ?", REQ_ASK))
8521 SaveLevelTemplate();
8524 Request("Template saved !", REQ_CONFIRM);
8526 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
8527 custom_element.num_change_pages < MAX_CHANGE_PAGES)
8529 struct ElementInfo *ei = &element_info[properties_element];
8531 setElementChangePages(ei, ei->num_change_pages + 1);
8533 /* set new change page to be new current change page */
8534 ei->current_change_page = ei->num_change_pages - 1;
8535 ei->change = &ei->change_page[ei->current_change_page];
8537 setElementChangeInfoToDefaults(ei->change);
8539 DrawPropertiesWindow();
8541 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
8542 custom_element.num_change_pages > MIN_CHANGE_PAGES)
8544 struct ElementInfo *ei = &element_info[properties_element];
8546 /* copy all change pages after change page to be deleted */
8547 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
8548 ei->change_page[i] = ei->change_page[i + 1];
8550 setElementChangePages(ei, ei->num_change_pages - 1);
8552 DrawPropertiesWindow();
8556 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
8558 int type_id = gi->custom_type_id;
8560 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
8561 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
8563 struct ElementInfo *ei = &element_info[properties_element];
8564 int step = BUTTON_STEPSIZE(gi->event.button);
8566 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
8567 ei->current_change_page += step;
8569 if (ei->current_change_page < 0)
8570 ei->current_change_page = 0;
8571 else if (ei->current_change_page >= ei->num_change_pages)
8572 ei->current_change_page = ei->num_change_pages - 1;
8574 DrawPropertiesWindow();
8576 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
8577 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
8579 struct ElementInfo *ei = &element_info[properties_element];
8580 int current_change_page = ei->current_change_page;
8582 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
8583 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
8584 ei->change_page[current_change_page];
8585 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
8586 ei->change_page[current_change_page] =
8587 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
8589 DrawPropertiesWindow();
8593 static void HandleRadiobuttons(struct GadgetInfo *gi)
8595 *radiobutton_info[gi->custom_type_id].value =
8596 radiobutton_info[gi->custom_type_id].checked_value;
8599 static void HandleCheckbuttons(struct GadgetInfo *gi)
8601 int type_id = gi->custom_type_id;
8603 *checkbutton_info[type_id].value ^= TRUE;
8605 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
8606 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
8607 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
8608 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
8609 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
8610 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
8611 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
8612 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE))
8614 CopyElementPropertiesToGame(properties_element);
8617 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
8619 UpdateCustomElementGraphicGadgets();
8621 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE)
8623 char *template_filename = getDefaultLevelFilename(-1);
8625 if (level.use_custom_template && !fileExists(template_filename))
8627 Request("No level template found !", REQ_CONFIRM);
8629 level.use_custom_template = FALSE;
8630 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
8635 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
8637 DrawEditModeWindow();
8641 static void HandleControlButtons(struct GadgetInfo *gi)
8643 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
8644 static int last_edit_mode = ED_MODE_DRAWING;
8645 static int last_custom_copy_mode = -1;
8646 int id = gi->custom_id;
8647 int button = gi->event.button;
8648 int step = BUTTON_STEPSIZE(button);
8649 int new_element = BUTTON_ELEMENT(button);
8652 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
8653 DrawLevelText(0, 0, 0, TEXT_END);
8655 if (id < ED_NUM_CTRL1_BUTTONS &&
8656 id != GADGET_ID_SINGLE_ITEMS &&
8657 id != GADGET_ID_PROPERTIES &&
8658 id != GADGET_ID_PICK_ELEMENT &&
8659 edit_mode != ED_MODE_DRAWING &&
8660 drawing_function != GADGET_ID_PICK_ELEMENT &&
8661 !(GetKeyModState() & KMOD_Control))
8663 DrawDrawingWindow();
8664 edit_mode = ED_MODE_DRAWING;
8667 /* element copy mode active, but no element button pressed => deactivate */
8668 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
8669 last_custom_copy_mode = -1;
8673 case GADGET_ID_SCROLL_LEFT:
8674 if (level_xpos >= 0)
8676 if (lev_fieldx < ed_fieldx - 2)
8680 if (level_xpos < -1)
8683 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
8685 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8687 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
8688 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
8692 case GADGET_ID_SCROLL_RIGHT:
8693 if (level_xpos <= lev_fieldx - ed_fieldx)
8695 if (lev_fieldx < ed_fieldx - 2)
8699 if (level_xpos > lev_fieldx - ed_fieldx + 1)
8700 level_xpos = lev_fieldx - ed_fieldx + 1;
8702 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
8704 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8706 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
8707 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
8711 case GADGET_ID_SCROLL_UP:
8712 if (level_ypos >= 0)
8714 if (lev_fieldy < ed_fieldy - 2)
8718 if (level_ypos < -1)
8721 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
8723 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8725 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
8726 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
8730 case GADGET_ID_SCROLL_DOWN:
8731 if (level_ypos <= lev_fieldy - ed_fieldy)
8733 if (lev_fieldy < ed_fieldy - 2)
8737 if (level_ypos > lev_fieldy - ed_fieldy + 1)
8738 level_ypos = lev_fieldy - ed_fieldy + 1;
8740 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_UP);
8742 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8744 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
8745 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
8749 case GADGET_ID_SCROLL_HORIZONTAL:
8750 level_xpos = gi->event.item_position - 1;
8751 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8754 case GADGET_ID_SCROLL_VERTICAL:
8755 level_ypos = gi->event.item_position - 1;
8756 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8759 case GADGET_ID_SCROLL_LIST_UP:
8760 case GADGET_ID_SCROLL_LIST_DOWN:
8761 case GADGET_ID_SCROLL_LIST_VERTICAL:
8762 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
8763 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
8766 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
8767 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
8769 if (element_shift < 0)
8771 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
8772 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
8774 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
8775 GDI_SCROLLBAR_ITEM_POSITION,
8776 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
8779 ModifyEditorElementList();
8783 case GADGET_ID_WRAP_LEFT:
8784 WrapLevel(-step, 0);
8787 case GADGET_ID_WRAP_RIGHT:
8791 case GADGET_ID_WRAP_UP:
8792 WrapLevel(0, -step);
8795 case GADGET_ID_WRAP_DOWN:
8799 case GADGET_ID_SINGLE_ITEMS:
8800 case GADGET_ID_CONNECTED_ITEMS:
8801 case GADGET_ID_LINE:
8803 case GADGET_ID_TEXT:
8804 case GADGET_ID_RECTANGLE:
8805 case GADGET_ID_FILLED_BOX:
8806 case GADGET_ID_FLOOD_FILL:
8807 case GADGET_ID_GRAB_BRUSH:
8808 case GADGET_ID_PICK_ELEMENT:
8809 if (drawing_function != GADGET_ID_PICK_ELEMENT)
8810 last_drawing_function = drawing_function;
8811 drawing_function = id;
8812 draw_with_brush = FALSE;
8815 case GADGET_ID_RANDOM_PLACEMENT:
8816 RandomPlacement(new_element);
8819 case GADGET_ID_PROPERTIES:
8820 if (edit_mode != ED_MODE_PROPERTIES)
8822 properties_element = new_element;
8823 DrawPropertiesWindow();
8824 edit_mode = ED_MODE_PROPERTIES;
8826 last_level_drawing_function = drawing_function;
8827 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
8832 DrawDrawingWindow();
8833 edit_mode = ED_MODE_DRAWING;
8835 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
8840 case GADGET_ID_CUSTOM_COPY_FROM:
8841 case GADGET_ID_CUSTOM_COPY_TO:
8842 case GADGET_ID_CUSTOM_EXCHANGE:
8843 last_custom_copy_mode = id;
8844 last_drawing_function = drawing_function;
8847 case GADGET_ID_CUSTOM_COPY:
8848 CopyCustomElement(properties_element, -1, id);
8851 case GADGET_ID_CUSTOM_PASTE:
8852 CopyCustomElement(-1, properties_element, id);
8855 case GADGET_ID_UNDO:
8856 if (undo_buffer_steps == 0)
8858 Request("Undo buffer empty !", REQ_CONFIRM);
8862 if (edit_mode != ED_MODE_DRAWING)
8864 DrawDrawingWindow();
8865 edit_mode = ED_MODE_DRAWING;
8868 undo_buffer_position =
8869 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
8870 undo_buffer_steps--;
8872 for (x = 0; x < lev_fieldx; x++)
8873 for (y = 0; y < lev_fieldy; y++)
8874 Feld[x][y] = UndoBuffer[undo_buffer_position][x][y];
8875 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos,level_ypos);
8878 case GADGET_ID_INFO:
8879 if (edit_mode != ED_MODE_INFO)
8881 last_edit_mode = edit_mode;
8882 edit_mode = ED_MODE_INFO;
8884 DrawLevelInfoWindow();
8888 edit_mode = last_edit_mode;
8890 DrawEditModeWindow();
8894 case GADGET_ID_CLEAR:
8895 if (edit_mode != ED_MODE_DRAWING)
8897 DrawDrawingWindow();
8898 edit_mode = ED_MODE_DRAWING;
8901 for (x = 0; x < MAX_LEV_FIELDX; x++)
8902 for (y = 0; y < MAX_LEV_FIELDY; y++)
8903 Feld[x][y] = (button == 1 ? EL_EMPTY : new_element);
8904 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
8906 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8909 case GADGET_ID_SAVE:
8910 if (leveldir_current->readonly)
8912 Request("This level is read only !", REQ_CONFIRM);
8916 if (!LevelContainsPlayer)
8917 Request("No Level without Gregor Mc Duffin please !", REQ_CONFIRM);
8920 char *level_filename = getDefaultLevelFilename(level_nr);
8921 boolean new_level = !fileExists(level_filename);
8924 Request("Save this level and kill the old ?", REQ_ASK))
8926 CopyPlayfield(Feld, level.field);
8928 SaveLevel(level_nr);
8932 Request("Level saved !", REQ_CONFIRM);
8936 case GADGET_ID_TEST:
8937 if (!LevelContainsPlayer)
8938 Request("No Level without Gregor Mc Duffin please !", REQ_CONFIRM);
8942 level.game_version = GAME_VERSION_ACTUAL;
8944 CopyPlayfield(level.field, FieldBackup);
8945 CopyPlayfield(Feld, level.field);
8947 UnmapLevelEditorGadgets();
8948 UndrawSpecialEditorDoor();
8950 CloseDoor(DOOR_CLOSE_ALL);
8952 DrawCompleteVideoDisplay();
8954 if (setup.autorecord)
8955 TapeStartRecording();
8957 level_editor_test_game = TRUE;
8958 game_status = GAME_MODE_PLAYING;
8964 case GADGET_ID_EXIT:
8965 RequestExitLevelEditor(TRUE); /* if level has changed, ask user */
8969 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
8970 id <= GADGET_ID_ELEMENTLIST_LAST)
8972 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
8973 int new_element = editor_elements[element_position + element_shift];
8975 if (last_custom_copy_mode != -1)
8977 if (CopyCustomElement(properties_element, new_element,
8978 last_custom_copy_mode))
8980 ClickOnGadget(level_editor_gadget[last_drawing_function],
8983 last_custom_copy_mode = -1;
8989 PickDrawingElement(button, new_element);
8991 if (!stick_element_properties_window &&
8992 drawing_function != GADGET_ID_PICK_ELEMENT &&
8993 !(GetKeyModState() & KMOD_Control))
8995 properties_element = new_element;
8996 if (edit_mode == ED_MODE_PROPERTIES)
8997 DrawPropertiesWindow();
9000 if (drawing_function == GADGET_ID_PICK_ELEMENT)
9001 ClickOnGadget(level_editor_gadget[last_drawing_function],
9005 else if (gi->event.type == GD_EVENT_PRESSED)
9006 printf("default: HandleControlButtons: GD_EVENT_PRESSED(%d)\n", id);
9007 else if (gi->event.type == GD_EVENT_RELEASED)
9008 printf("default: HandleControlButtons: GD_EVENT_RELEASED(%d)\n", id);
9009 else if (gi->event.type == GD_EVENT_MOVING)
9010 printf("default: HandleControlButtons: GD_EVENT_MOVING(%d)\n", id);
9012 printf("default: HandleControlButtons: ? (id == %d)\n", id);
9018 void HandleLevelEditorKeyInput(Key key)
9020 char letter = getCharFromKey(key);
9021 int button = MB_LEFTBUTTON;
9023 if (drawing_function == GADGET_ID_TEXT &&
9024 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
9027 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
9028 else if (key == KSYM_Delete || key == KSYM_BackSpace)
9029 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
9030 else if (key == KSYM_Return)
9031 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
9032 else if (key == KSYM_Escape)
9033 DrawLevelText(0, 0, 0, TEXT_END);
9035 else if (button_status == MB_RELEASED)
9037 int i, id = GADGET_ID_NONE;
9042 id = GADGET_ID_SCROLL_LEFT;
9045 id = GADGET_ID_SCROLL_RIGHT;
9048 id = GADGET_ID_SCROLL_UP;
9051 id = GADGET_ID_SCROLL_DOWN;
9054 id = GADGET_ID_SCROLL_LIST_UP;
9055 button = MB_RIGHTBUTTON;
9057 case KSYM_Page_Down:
9058 id = GADGET_ID_SCROLL_LIST_DOWN;
9059 button = MB_RIGHTBUTTON;
9063 if (edit_mode == ED_MODE_DRAWING)
9065 RequestExitLevelEditor(setup.ask_on_escape);
9069 DrawDrawingWindow();
9070 edit_mode = ED_MODE_DRAWING;
9078 if (id != GADGET_ID_NONE)
9079 ClickOnGadget(level_editor_gadget[id], button);
9080 else if (letter == '.')
9081 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
9082 else if (key == KSYM_Return || key == setup.shortcut.toggle_pause)
9083 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
9085 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
9086 if (letter && letter == control_info[i].shortcut)
9087 if (!anyTextGadgetActive())
9088 ClickOnGadget(level_editor_gadget[i], button);
9092 void HandleLevelEditorIdle()
9094 static unsigned long action_delay = 0;
9095 unsigned long action_delay_value = GameFrameDelay;
9096 int xpos = 1, ypos = 2;
9098 if (edit_mode != ED_MODE_PROPERTIES)
9101 if (!DelayReached(&action_delay, action_delay_value))
9104 DrawGraphicAnimationExt(drawto,
9106 SY + ypos * TILEY + MINI_TILEY / 2,
9107 el2img(properties_element), -1, NO_MASKING);
9109 MarkTileDirty(xpos, ypos);
9110 MarkTileDirty(xpos, ypos + 1);
9112 FrameCounter++; /* increase animation frame counter */
9115 void ClearEditorGadgetInfoText()
9117 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
9120 void HandleEditorGadgetInfoText(void *ptr)
9122 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
9123 char infotext[MAX_OUTPUT_LINESIZE + 1];
9124 char shortcut[MAX_OUTPUT_LINESIZE + 1];
9125 int max_infotext_len = getMaxInfoTextLength();
9127 if (game_status != GAME_MODE_EDITOR)
9130 ClearEditorGadgetInfoText();
9132 if (gi->event.type == GD_EVENT_INFO_LEAVING)
9135 /* misuse this function to delete brush cursor, if needed */
9136 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
9137 DeleteBrushFromCursor();
9139 if (gi == NULL || gi->info_text == NULL)
9142 strncpy(infotext, gi->info_text, max_infotext_len);
9143 infotext[max_infotext_len] = '\0';
9145 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
9147 int key = control_info[gi->custom_id].shortcut;
9151 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS) /* special case 1 */
9152 sprintf(shortcut, " ('.' or '%c')", key);
9153 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT) /* special case 2 */
9154 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
9155 else if (gi->custom_id == GADGET_ID_TEST) /* special case 3 */
9156 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
9157 else /* normal case */
9158 sprintf(shortcut, " ('%s%c')",
9159 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
9161 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
9162 strcat(infotext, shortcut);
9166 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, FONT_TEXT_2);
9169 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
9171 static int start_lx, start_ly;
9172 int id = gi->custom_id;
9173 int sx = gi->event.x;
9174 int sy = gi->event.y;
9175 int lx = sx + level_xpos;
9176 int ly = sy + level_ypos;
9177 int min_sx = 0, min_sy = 0;
9178 int max_sx = gi->drawing.area_xsize - 1;
9179 int max_sy = gi->drawing.area_ysize - 1;
9180 int actual_drawing_function = drawing_function;
9181 int max_infotext_len = getMaxInfoTextLength();
9182 char infotext[MAX_OUTPUT_LINESIZE + 1];
9185 infotext[0] = '\0'; /* start with empty info text */
9187 /* pressed Control key: simulate picking element */
9188 if (GetKeyModState() & KMOD_Control)
9189 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
9191 ClearEditorGadgetInfoText();
9193 if (gi->event.type == GD_EVENT_INFO_LEAVING)
9196 /* make sure to stay inside drawing area boundaries */
9197 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
9198 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
9200 if (id == GADGET_ID_DRAWING_LEVEL)
9204 int min_lx = 0, min_ly = 0;
9205 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
9207 /* get positions inside level field */
9208 lx = sx + level_xpos;
9209 ly = sy + level_ypos;
9211 /* make sure to stay inside level field boundaries */
9212 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
9213 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
9215 /* correct drawing area positions accordingly */
9216 sx = lx - level_xpos;
9217 sy = ly - level_ypos;
9220 if (IN_ED_FIELD(sx,sy) && IN_LEV_FIELD(lx, ly))
9222 if (button_status) /* if (gi->state == GD_BUTTON_PRESSED) */
9224 if (gi->event.type == GD_EVENT_PRESSED)
9230 switch (actual_drawing_function)
9232 case GADGET_ID_SINGLE_ITEMS:
9233 text = "Drawing single items";
9235 case GADGET_ID_CONNECTED_ITEMS:
9236 text = "Drawing connected items";
9238 case GADGET_ID_LINE:
9239 text = "Drawing line";
9242 text = "Drawing arc";
9244 case GADGET_ID_TEXT:
9245 text = "Setting text cursor";
9247 case GADGET_ID_RECTANGLE:
9248 text = "Drawing rectangle";
9250 case GADGET_ID_FILLED_BOX:
9251 text = "Drawing filled box";
9253 case GADGET_ID_FLOOD_FILL:
9254 text = "Flood fill";
9256 case GADGET_ID_GRAB_BRUSH:
9257 text = "Grabbing brush";
9259 case GADGET_ID_PICK_ELEMENT:
9260 text = "Picking element";
9264 text = "Drawing position";
9269 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
9270 sprintf(infotext, "%s: %d, %d", text, lx, ly);
9272 sprintf(infotext, "%s: %d, %d", text,
9273 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
9275 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
9276 DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
9277 "%s: %d, %d", infotext, lx, ly);
9279 DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
9280 "%s: %d, %d", infotext,
9281 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
9285 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
9286 strncpy(infotext, getElementInfoText(Feld[lx][ly]), max_infotext_len);
9288 sprintf(infotext, "Level position: %d, %d", lx, ly);
9290 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
9291 DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
9292 "%s", getElementInfoText(Feld[lx][ly]));
9294 DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
9295 "Level position: %d, %d", lx, ly);
9299 /* misuse this function to draw brush cursor, if needed */
9300 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
9302 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
9303 CopyBrushToCursor(sx, sy);
9305 DeleteBrushFromCursor();
9308 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
9310 int element = EL_EMPTY;
9312 if (id == GADGET_ID_AMOEBA_CONTENT)
9313 element = level.amoeba_content;
9314 else if (id == GADGET_ID_CUSTOM_GRAPHIC)
9315 element = custom_element.gfx_element;
9316 else if (id == GADGET_ID_CUSTOM_CONTENT)
9317 element = custom_element.content[sx][sy];
9318 else if (id == GADGET_ID_CUSTOM_MOVE_ENTER)
9319 element = custom_element.move_enter_element;
9320 else if (id == GADGET_ID_CUSTOM_MOVE_LEAVE)
9321 element = custom_element.move_leave_element;
9322 else if (id == GADGET_ID_CUSTOM_CHANGE_TARGET)
9323 element = custom_element_change.target_element;
9324 else if (id == GADGET_ID_CUSTOM_CHANGE_CONTENT)
9325 element = custom_element_change.target_content[sx][sy];
9326 else if (id == GADGET_ID_CUSTOM_CHANGE_TRIGGER)
9327 element = custom_element_change.trigger_element;
9328 else if (id == GADGET_ID_GROUP_CONTENT)
9329 element = group_element_info.element[sx];
9330 else if (id == GADGET_ID_RANDOM_BACKGROUND)
9331 element = random_placement_background_element;
9332 else if (id >= GADGET_ID_ELEMENT_CONTENT_0 &&
9333 id <= GADGET_ID_ELEMENT_CONTENT_7)
9334 element = level.yamyam_content[id - GADGET_ID_ELEMENT_CONTENT_0][sx][sy];
9336 strncpy(infotext, getElementInfoText(element), max_infotext_len);
9340 if (id == GADGET_ID_AMOEBA_CONTENT)
9341 strcpy(infotext, "Amoeba content");
9342 else if (id == GADGET_ID_CUSTOM_GRAPHIC)
9343 strcpy(infotext, "Custom graphic element");
9344 else if (id == GADGET_ID_CUSTOM_CONTENT)
9345 sprintf(infotext, "Custom element content position: %d, %d", sx, sy);
9346 else if (id == GADGET_ID_CUSTOM_MOVE_ENTER)
9347 strcpy(infotext, "Element that can be digged/collected");
9348 else if (id == GADGET_ID_CUSTOM_MOVE_LEAVE)
9349 strcpy(infotext, "Element that will be left behind");
9350 else if (id == GADGET_ID_CUSTOM_CHANGE_TARGET)
9351 strcpy(infotext, "New element after change");
9352 else if (id == GADGET_ID_CUSTOM_CHANGE_CONTENT)
9353 strcpy(infotext, "New extended elements after change");
9354 else if (id == GADGET_ID_CUSTOM_CHANGE_TRIGGER)
9355 strcpy(infotext, "Other element triggering change");
9356 else if (id == GADGET_ID_GROUP_CONTENT)
9357 sprintf(infotext, "Group element position: %d", sx + 1);
9358 else if (id == GADGET_ID_RANDOM_BACKGROUND)
9359 strcpy(infotext, "Random placement background");
9360 else if (id >= GADGET_ID_ELEMENT_CONTENT_0 &&
9361 id <= GADGET_ID_ELEMENT_CONTENT_7)
9362 sprintf(infotext, "Content area %d position: %d, %d",
9363 id - GADGET_ID_ELEMENT_CONTENT_0 + 1, sx, sy);
9366 infotext[max_infotext_len] = '\0';
9368 if (strlen(infotext) > 0)
9369 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, infotext);
9372 void RequestExitLevelEditor(boolean ask_if_level_has_changed)
9374 if (!ask_if_level_has_changed ||
9376 Request("Level has changed! Exit without saving ?",
9377 REQ_ASK | REQ_STAY_OPEN))
9380 CloseDoor(DOOR_CLOSE_1);
9381 SetDoorState(DOOR_CLOSE_2);
9383 CloseDoor(DOOR_CLOSE_ALL);
9385 game_status = GAME_MODE_MAIN;
9390 CloseDoor(DOOR_CLOSE_1);
9391 BlitBitmap(bitmap_db_door, bitmap_db_door,
9392 DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1, DXSIZE,DYSIZE,
9393 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
9394 OpenDoor(DOOR_OPEN_1);