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_CONSISTENCY (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_EXPLODE_RESULT (GADGET_ID_CHECKBUTTON_FIRST + 16)
511 #define GADGET_ID_CUSTOM_EXPLODE_FIRE (GADGET_ID_CHECKBUTTON_FIRST + 17)
512 #define GADGET_ID_CUSTOM_EXPLODE_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 18)
513 #define GADGET_ID_CUSTOM_EXPLODE_IMPACT (GADGET_ID_CHECKBUTTON_FIRST + 19)
514 #define GADGET_ID_CUSTOM_WALK_TO_OBJECT (GADGET_ID_CHECKBUTTON_FIRST + 20)
515 #define GADGET_ID_CUSTOM_DEADLY (GADGET_ID_CHECKBUTTON_FIRST + 21)
516 #define GADGET_ID_CUSTOM_CAN_MOVE (GADGET_ID_CHECKBUTTON_FIRST + 22)
517 #define GADGET_ID_CUSTOM_CAN_FALL (GADGET_ID_CHECKBUTTON_FIRST + 23)
518 #define GADGET_ID_CUSTOM_CAN_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 24)
519 #define GADGET_ID_CUSTOM_SLIPPERY (GADGET_ID_CHECKBUTTON_FIRST + 25)
520 #define GADGET_ID_CUSTOM_ACCESSIBLE (GADGET_ID_CHECKBUTTON_FIRST + 26)
521 #define GADGET_ID_CUSTOM_USE_GRAPHIC (GADGET_ID_CHECKBUTTON_FIRST + 27)
522 #define GADGET_ID_CUSTOM_USE_TEMPLATE (GADGET_ID_CHECKBUTTON_FIRST + 28)
523 #define GADGET_ID_CUSTOM_CAN_CHANGE (GADGET_ID_CHECKBUTTON_FIRST + 29)
524 #define GADGET_ID_CHANGE_USE_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 30)
525 #define GADGET_ID_CHANGE_USE_EXPLOSION (GADGET_ID_CHECKBUTTON_FIRST + 31)
526 #define GADGET_ID_CHANGE_ONLY_COMPLETE (GADGET_ID_CHECKBUTTON_FIRST + 32)
527 #define GADGET_ID_CHANGE_USE_RANDOM (GADGET_ID_CHECKBUTTON_FIRST + 33)
528 #define GADGET_ID_CHANGE_DELAY (GADGET_ID_CHECKBUTTON_FIRST + 34)
529 #define GADGET_ID_CHANGE_BY_DIRECT_ACT (GADGET_ID_CHECKBUTTON_FIRST + 35)
530 #define GADGET_ID_CHANGE_BY_OTHER_ACT (GADGET_ID_CHECKBUTTON_FIRST + 36)
532 /* gadgets for buttons in element list */
533 #define GADGET_ID_ELEMENTLIST_FIRST (GADGET_ID_CHECKBUTTON_FIRST + 37)
534 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
535 ED_NUM_ELEMENTLIST_BUTTONS - 1)
537 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
539 /* radio button numbers */
540 #define RADIO_NR_NONE 0
541 #define RADIO_NR_DRAWING_TOOLBOX 1
542 #define RADIO_NR_RANDOM_ELEMENTS 2
544 /* values for counter gadgets */
545 #define ED_COUNTER_ID_SELECT_LEVEL 0
546 #define ED_COUNTER_ID_LEVEL_XSIZE 1
547 #define ED_COUNTER_ID_LEVEL_YSIZE 2
548 #define ED_COUNTER_ID_LEVEL_GEMSLIMIT 3
549 #define ED_COUNTER_ID_LEVEL_TIMELIMIT 4
550 #define ED_COUNTER_ID_LEVEL_TIMESCORE 5
551 #define ED_COUNTER_ID_LEVEL_RANDOM 6
552 #define ED_COUNTER_ID_ELEMENT_SCORE 7
553 #define ED_COUNTER_ID_ELEMENT_CONTENT 8
554 #define ED_COUNTER_ID_ENVELOPE_XSIZE 9
555 #define ED_COUNTER_ID_ENVELOPE_YSIZE 10
556 #define ED_COUNTER_ID_CUSTOM_SCORE 11
557 #define ED_COUNTER_ID_CUSTOM_GEMCOUNT 12
558 #define ED_COUNTER_ID_PUSH_DELAY_FIX 13
559 #define ED_COUNTER_ID_PUSH_DELAY_RND 14
560 #define ED_COUNTER_ID_DROP_DELAY_FIX 15
561 #define ED_COUNTER_ID_DROP_DELAY_RND 16
562 #define ED_COUNTER_ID_MOVE_DELAY_FIX 17
563 #define ED_COUNTER_ID_MOVE_DELAY_RND 18
564 #define ED_COUNTER_ID_EXPLOSION_DELAY 19
565 #define ED_COUNTER_ID_IGNITION_DELAY 20
566 #define ED_COUNTER_ID_GROUP_CONTENT 21
567 #define ED_COUNTER_ID_CHANGE_DELAY_FIX 22
568 #define ED_COUNTER_ID_CHANGE_DELAY_RND 23
569 #define ED_COUNTER_ID_CHANGE_CONT_RND 24
571 #define ED_NUM_COUNTERBUTTONS 25
573 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
574 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM
576 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
577 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_MOVE_DELAY_RND
578 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_EXPLOSION_DELAY
579 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
580 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
581 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
583 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
584 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
586 /* values for scrollbutton gadgets */
587 #define ED_SCROLLBUTTON_ID_AREA_UP 0
588 #define ED_SCROLLBUTTON_ID_AREA_DOWN 1
589 #define ED_SCROLLBUTTON_ID_AREA_LEFT 2
590 #define ED_SCROLLBUTTON_ID_AREA_RIGHT 3
591 #define ED_SCROLLBUTTON_ID_LIST_UP 4
592 #define ED_SCROLLBUTTON_ID_LIST_DOWN 5
594 #define ED_NUM_SCROLLBUTTONS 6
596 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
597 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
599 /* values for scrollbar gadgets */
600 #define ED_SCROLLBAR_ID_AREA_HORIZONTAL 0
601 #define ED_SCROLLBAR_ID_AREA_VERTICAL 1
602 #define ED_SCROLLBAR_ID_LIST_VERTICAL 2
604 #define ED_NUM_SCROLLBARS 3
606 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
607 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
609 /* values for text input gadgets */
610 #define ED_TEXTINPUT_ID_LEVEL_NAME 0
611 #define ED_TEXTINPUT_ID_LEVEL_AUTHOR 1
612 #define ED_TEXTINPUT_ID_ELEMENT_NAME 2
614 #define ED_NUM_TEXTINPUT 3
616 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
617 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
619 /* values for text area gadgets */
620 #define ED_TEXTAREA_ID_ENVELOPE_INFO 0
622 #define ED_NUM_TEXTAREAS 1
624 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
625 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
627 /* values for selectbox gadgets */
628 #define ED_SELECTBOX_ID_TIME_OR_STEPS 0
629 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE 1
630 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER 2
631 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED 3
632 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION 4
633 #define ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION 5
634 #define ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN 6
635 #define ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION 7
636 #define ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE 8
637 #define ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE 9
638 #define ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS 10
639 #define ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE 11
640 #define ED_SELECTBOX_ID_CUSTOM_DEADLINESS 12
641 #define ED_SELECTBOX_ID_CUSTOM_CONSISTENCY 13
642 #define ED_SELECTBOX_ID_CHANGE_TIME_UNITS 14
643 #define ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION 15
644 #define ED_SELECTBOX_ID_CHANGE_OTHER_ACTION 16
645 #define ED_SELECTBOX_ID_CHANGE_SIDE 17
646 #define ED_SELECTBOX_ID_CHANGE_PLAYER 18
647 #define ED_SELECTBOX_ID_CHANGE_PAGE 19
648 #define ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN 20
649 #define ED_SELECTBOX_ID_SELECT_CHANGE_PAGE 21
650 #define ED_SELECTBOX_ID_GROUP_CHOICE_MODE 22
652 #define ED_NUM_SELECTBOX 23
654 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
655 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_TIME_OR_STEPS
657 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
658 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE
659 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS
660 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_CONSISTENCY
661 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
662 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
664 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
665 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
667 /* values for textbutton gadgets */
668 #define ED_TEXTBUTTON_ID_PROPERTIES_INFO 0
669 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG 1
670 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1 2
671 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2 3
672 #define ED_TEXTBUTTON_ID_PROPERTIES_CHANGE 4
673 #define ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE 5
674 #define ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE 6
675 #define ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE 7
677 #define ED_NUM_TEXTBUTTONS 8
679 #define ED_TEXTBUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
680 #define ED_TEXTBUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
682 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
683 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
685 /* values for graphicbutton gadgets */
686 #define ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE 0
687 #define ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE 1
688 #define ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE 2
689 #define ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE 3
691 #define ED_NUM_GRAPHICBUTTONS 4
693 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
694 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
696 /* values for checkbutton gadgets */
697 #define ED_CHECKBUTTON_ID_DOUBLE_SPEED 0
698 #define ED_CHECKBUTTON_ID_GRAVITY 1
699 #define ED_CHECKBUTTON_ID_RANDOM_RESTRICTED 2
700 #define ED_CHECKBUTTON_ID_STICK_ELEMENT 3
701 #define ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS 4
702 #define ED_CHECKBUTTON_ID_USE_SPRING_BUG 5
703 #define ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE 6
704 #define ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD 7
705 #define ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD 8
706 #define ED_CHECKBUTTON_ID_INSTANT_RELOCATION 9
707 #define ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE 10
708 #define ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID 11
709 #define ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID 12
710 #define ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH 13
711 #define ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC 14
712 #define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE 15
713 #define ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE 16
714 #define ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT 17
715 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE 18
716 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL 19
717 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH 20
718 #define ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY 21
719 #define ED_CHECKBUTTON_ID_CUSTOM_DEADLY 22
720 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_RESULT 23
721 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE 24
722 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH 25
723 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT 26
724 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE 27
725 #define ED_CHECKBUTTON_ID_CHANGE_DELAY 28
726 #define ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT 29
727 #define ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT 30
728 #define ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION 31
729 #define ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT 32
730 #define ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE 33
731 #define ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM 34
733 #define ED_NUM_CHECKBUTTONS 35
735 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_DOUBLE_SPEED
736 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
738 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
739 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
740 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL
741 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
742 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
743 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
745 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
746 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM
748 /* values for radiobutton gadgets */
749 #define ED_RADIOBUTTON_ID_PERCENTAGE 0
750 #define ED_RADIOBUTTON_ID_QUANTITY 1
752 #define ED_NUM_RADIOBUTTONS 2
754 #define ED_RADIOBUTTON_ID_LEVEL_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
755 #define ED_RADIOBUTTON_ID_LEVEL_LAST ED_RADIOBUTTON_ID_QUANTITY
757 /* values for drawing area gadgets */
758 #define ED_DRAWING_ID_DRAWING_LEVEL 0
759 #define ED_DRAWING_ID_ELEMENT_CONTENT_0 1
760 #define ED_DRAWING_ID_ELEMENT_CONTENT_1 2
761 #define ED_DRAWING_ID_ELEMENT_CONTENT_2 3
762 #define ED_DRAWING_ID_ELEMENT_CONTENT_3 4
763 #define ED_DRAWING_ID_ELEMENT_CONTENT_4 5
764 #define ED_DRAWING_ID_ELEMENT_CONTENT_5 6
765 #define ED_DRAWING_ID_ELEMENT_CONTENT_6 7
766 #define ED_DRAWING_ID_ELEMENT_CONTENT_7 8
767 #define ED_DRAWING_ID_AMOEBA_CONTENT 9
768 #define ED_DRAWING_ID_CUSTOM_GRAPHIC 10
769 #define ED_DRAWING_ID_CUSTOM_CONTENT 11
770 #define ED_DRAWING_ID_CUSTOM_MOVE_ENTER 12
771 #define ED_DRAWING_ID_CUSTOM_MOVE_LEAVE 13
772 #define ED_DRAWING_ID_CUSTOM_CHANGE_TARGET 14
773 #define ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT 15
774 #define ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER 16
775 #define ED_DRAWING_ID_GROUP_CONTENT 17
776 #define ED_DRAWING_ID_RANDOM_BACKGROUND 18
778 #define ED_NUM_DRAWING_AREAS 19
782 -----------------------------------------------------------------------------
783 some internally used definitions
784 -----------------------------------------------------------------------------
787 /* values for CopyLevelToUndoBuffer() */
788 #define UNDO_IMMEDIATE 0
789 #define UNDO_ACCUMULATE 1
791 /* values for scrollbars */
792 #define ED_SCROLL_NO 0
793 #define ED_SCROLL_LEFT 1
794 #define ED_SCROLL_RIGHT 2
795 #define ED_SCROLL_UP 4
796 #define ED_SCROLL_DOWN 8
798 /* screens in the level editor */
799 #define ED_MODE_DRAWING 0
800 #define ED_MODE_INFO 1
801 #define ED_MODE_PROPERTIES 2
803 /* sub-screens in the element properties section */
804 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
805 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
806 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
807 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
808 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
810 /* how many steps can be cancelled */
811 #define NUM_UNDO_STEPS (10 + 1)
813 /* values for elements with score for certain actions */
815 #define MAX_SCORE 255
817 /* values for elements with count for collecting */
818 #define MIN_COLLECT_COUNT 0
819 #define MAX_COLLECT_COUNT 100
821 /* values for random placement */
822 #define RANDOM_USE_PERCENTAGE 0
823 #define RANDOM_USE_QUANTITY 1
825 /* maximal size of level editor drawing area */
826 #define MAX_ED_FIELDX (2 * SCR_FIELDX)
827 #define MAX_ED_FIELDY (2 * SCR_FIELDY - 1)
831 -----------------------------------------------------------------------------
832 some internally used data structure definitions
833 -----------------------------------------------------------------------------
840 } control_info[ED_NUM_CTRL_BUTTONS] =
842 { 's', "draw single items" },
843 { 'd', "draw connected items" },
844 { 'l', "draw lines" },
845 { 'a', "draw arcs" },
846 { 'r', "draw outline rectangles" },
847 { 'R', "draw filled rectangles" },
848 { '\0', "wrap (rotate) level up" },
849 { 't', "enter text elements" },
850 { 'f', "flood fill" },
851 { '\0', "wrap (rotate) level left" },
852 { '?', "properties of drawing element" },
853 { '\0', "wrap (rotate) level right" },
854 { '\0', "random element placement" },
855 { 'b', "grab brush" },
856 { '\0', "wrap (rotate) level down" },
857 { ',', "pick drawing element" },
859 { 'U', "undo last operation" },
860 { 'I', "level properties" },
861 { 'S', "save level" },
862 { 'C', "clear level" },
863 { 'T', "test level" },
864 { 'E', "exit level editor" },
866 { '\0', "copy settings from other element" },
867 { '\0', "copy settings to other element" },
868 { '\0', "exchange element with other element" },
870 { '\0', "copy settings from this element" },
871 { '\0', "paste settings to this element" },
874 static int random_placement_value = 10;
875 static int random_placement_method = RANDOM_USE_QUANTITY;
876 static int random_placement_background_element = EL_SAND;
877 static boolean random_placement_background_restricted = FALSE;
878 static boolean stick_element_properties_window = FALSE;
879 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
880 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
881 static struct ElementChangeInfo custom_element_change;
882 static struct ElementGroupInfo group_element_info;
883 static struct ElementInfo custom_element;
888 int min_value, max_value;
889 int gadget_id_down, gadget_id_up;
893 char *text_above, *text_left, *text_right;
894 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
896 /* ---------- level and editor settings ---------------------------------- */
899 DX + 5 - SX, DY + 3 - SY,
901 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
902 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
907 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(2),
908 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
909 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
910 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
912 "playfield size:", NULL, "width",
915 -1, ED_COUNTER_YPOS(2),
916 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
917 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
918 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
923 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(3),
925 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
926 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
928 "number of gems to collect:", NULL, NULL
931 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(4),
933 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
934 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
936 "time or step limit to solve level:", NULL, NULL
939 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(5),
941 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
942 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
943 &level.score[SC_TIME_BONUS],
944 "score for each 10 sec/steps left:", NULL, NULL
947 ED_SETTINGS_XPOS(0), ED_COUNTER2_YPOS(8),
949 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
950 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
951 &random_placement_value,
952 "random element placement:", NULL, "in"
955 /* ---------- element settings: configure (various elements) ------------- */
958 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(0),
959 MIN_SCORE, MAX_SCORE,
960 GADGET_ID_ELEMENT_SCORE_DOWN, GADGET_ID_ELEMENT_SCORE_UP,
961 GADGET_ID_ELEMENT_SCORE_TEXT, GADGET_ID_NONE,
962 NULL, /* will be set when used */
966 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(3),
967 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
968 GADGET_ID_ELEMENT_CONTENT_DOWN, GADGET_ID_ELEMENT_CONTENT_UP,
969 GADGET_ID_ELEMENT_CONTENT_TEXT, GADGET_ID_NONE,
970 &level.num_yamyam_contents,
971 NULL, NULL, "number of content areas"
974 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(0),
975 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
976 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
977 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
982 -1, ED_SETTINGS_YPOS(0),
983 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
984 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
985 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
990 /* ---------- element settings: configure 1 (custom elements) ------------ */
993 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(6),
994 MIN_SCORE, MAX_SCORE,
995 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
996 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
997 &custom_element.collect_score,
1001 -1, ED_SETTINGS_YPOS(6),
1002 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1003 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1004 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1005 &custom_element.collect_count,
1009 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(7),
1011 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1012 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1013 &custom_element.push_delay_fixed,
1014 NULL, "push delay", NULL
1017 -1, ED_SETTINGS_YPOS(7),
1019 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1020 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1021 &custom_element.push_delay_random,
1022 NULL, "+random", NULL
1025 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(8),
1027 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1028 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1029 &custom_element.drop_delay_fixed,
1030 NULL, "drop delay", NULL
1033 -1, ED_SETTINGS_YPOS(8),
1035 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1036 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1037 &custom_element.drop_delay_random,
1038 NULL, "+random", NULL
1041 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(13),
1043 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1044 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1045 &custom_element.move_delay_fixed,
1046 NULL, "move delay", NULL
1049 -1, ED_SETTINGS_YPOS(13),
1051 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1052 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1053 &custom_element.move_delay_random,
1054 NULL, "+random", NULL
1057 /* ---------- element settings: configure 2 (custom elements) ------------ */
1060 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(4),
1062 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1063 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1064 &custom_element.explosion_delay,
1065 NULL, "explosion delay", NULL
1068 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(5),
1070 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1071 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1072 &custom_element.ignition_delay,
1073 NULL, "ignition delay", "(by fire)"
1076 /* ---------- element settings: configure (group elements) --------------- */
1079 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(5),
1080 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1081 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1082 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1083 &group_element_info.num_elements,
1084 NULL, NULL, "number of elements in group"
1087 /* ---------- element settings: advanced (custom elements) --------------- */
1090 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(2),
1092 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1093 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1094 &custom_element_change.delay_fixed,
1095 NULL, "delay", NULL,
1098 -1, ED_SETTINGS_YPOS(2),
1100 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1101 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1102 &custom_element_change.delay_random,
1103 NULL, "+random", NULL
1106 ED_SETTINGS_XPOS(3), ED_SETTINGS_YPOS(12),
1108 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1109 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1110 &custom_element_change.random_percentage,
1111 NULL, "use random replace:", "%"
1121 char *text_above, *infotext;
1122 } textinput_info[ED_NUM_TEXTINPUT] =
1125 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(0),
1126 GADGET_ID_LEVEL_NAME,
1132 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(1),
1133 GADGET_ID_LEVEL_AUTHOR,
1134 MAX_LEVEL_AUTHOR_LEN,
1139 5 * MINI_TILEX - 2, 5 * MINI_TILEY - ED_BORDER_SIZE + 1,
1140 GADGET_ID_ELEMENT_NAME,
1141 MAX_ELEMENT_NAME_LEN - 2, /* currently 2 chars less editable */
1142 custom_element.description,
1143 NULL, "Element name"
1153 char *text_above, *infotext;
1154 } textarea_info[ED_NUM_TEXTAREAS] =
1157 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(2),
1158 GADGET_ID_ENVELOPE_INFO,
1159 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1161 "Envelope Info:", "Envelope Info"
1165 static struct ValueTextInfo options_time_or_steps[] =
1173 static struct ValueTextInfo options_access_type[] =
1175 { EP_WALKABLE, "walkable" },
1176 { EP_PASSABLE, "passable" },
1181 static struct ValueTextInfo options_access_layer[] =
1183 { EP_ACCESSIBLE_OVER, "over" },
1184 { EP_ACCESSIBLE_INSIDE, "inside" },
1185 { EP_ACCESSIBLE_UNDER, "under" },
1190 static struct ValueTextInfo options_access_protected[] =
1192 { 0, "unprotected" },
1198 static struct ValueTextInfo options_access_direction[] =
1200 { MV_LEFT, "left" },
1201 { MV_RIGHT, "right" },
1203 { MV_DOWN, "down" },
1204 { MV_LEFT | MV_UP, "left + up" },
1205 { MV_LEFT | MV_DOWN, "left + down" },
1206 { MV_RIGHT | MV_UP, "right + up" },
1207 { MV_RIGHT | MV_DOWN, "right + down" },
1208 { MV_HORIZONTAL, "horizontal" },
1209 { MV_VERTICAL, "vertical" },
1210 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1211 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1212 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1213 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1214 { MV_ALL_DIRECTIONS, "all directions" },
1219 static struct ValueTextInfo options_walk_to_action[] =
1221 { EP_DIGGABLE, "diggable" },
1222 { EP_COLLECTIBLE_ONLY, "collectible" },
1223 { EP_DROPPABLE, "collectible & droppable" },
1224 { EP_PUSHABLE, "pushable" },
1229 static struct ValueTextInfo options_move_pattern[] =
1231 { MV_LEFT, "left" },
1232 { MV_RIGHT, "right" },
1234 { MV_DOWN, "down" },
1235 { MV_HORIZONTAL, "horizontal" },
1236 { MV_VERTICAL, "vertical" },
1237 { MV_ALL_DIRECTIONS, "all directions" },
1238 { MV_TOWARDS_PLAYER, "towards player" },
1239 { MV_AWAY_FROM_PLAYER, "away from player" },
1240 { MV_ALONG_LEFT_SIDE, "along left side" },
1241 { MV_ALONG_RIGHT_SIDE, "along right side" },
1242 { MV_TURNING_LEFT, "turning left" },
1243 { MV_TURNING_RIGHT, "turning right" },
1244 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1245 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1246 { MV_TURNING_RANDOM, "turning random" },
1247 { MV_WHEN_PUSHED, "when pushed" },
1248 { MV_WHEN_DROPPED, "when dropped" },
1249 { MV_MAZE_RUNNER, "maze runner style" },
1250 { MV_MAZE_HUNTER, "maze hunter style" },
1255 static struct ValueTextInfo options_move_direction[] =
1257 { MV_START_AUTOMATIC, "automatic" },
1258 { MV_START_LEFT, "left" },
1259 { MV_START_RIGHT, "right" },
1260 { MV_START_UP, "up" },
1261 { MV_START_DOWN, "down" },
1262 { MV_START_RANDOM, "random" },
1263 { MV_START_PREVIOUS, "previous" },
1268 static struct ValueTextInfo options_move_stepsize[] =
1274 { 16, "very fast" },
1276 { 32, "even faster" },
1282 static struct ValueTextInfo options_move_leave_type[] =
1284 { LEAVE_TYPE_UNLIMITED, "leave behind" },
1285 { LEAVE_TYPE_LIMITED, "change it to" },
1290 static struct ValueTextInfo options_smash_targets[] =
1292 { EP_CAN_SMASH_PLAYER, "player" },
1294 { EP_CAN_SMASH_ENEMIES, "enemies" },
1296 { EP_CAN_SMASH_EVERYTHING, "everything" },
1301 static struct ValueTextInfo options_slippery_type[] =
1303 { SLIPPERY_ANY_RANDOM, "random" },
1304 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
1305 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
1306 { SLIPPERY_ONLY_LEFT, "only left" },
1307 { SLIPPERY_ONLY_RIGHT, "only right" },
1312 static struct ValueTextInfo options_deadliness[] =
1314 { EP_DONT_RUN_INTO, "running into" },
1315 { EP_DONT_COLLIDE_WITH, "colliding with" },
1316 { EP_DONT_TOUCH, "touching" },
1321 static struct ValueTextInfo options_consistency[] =
1323 { EP_CAN_EXPLODE_3X3, "can explode 3x3" },
1324 { EP_CAN_EXPLODE_CROSS, "can explode 3+3" },
1325 { EP_CAN_EXPLODE_1X1, "can explode 1x1" },
1326 { EP_INDESTRUCTIBLE, "indestructible" },
1331 static struct ValueTextInfo options_time_units[] =
1334 { FRAMES_PER_SECOND, "seconds" },
1339 static struct ValueTextInfo options_change_direct_action[] =
1341 { CE_TOUCHED_BY_PLAYER, "touched by player ..." },
1342 { CE_PRESSED_BY_PLAYER, "pressed by player ..." },
1343 { CE_PUSHED_BY_PLAYER, "pushed by player ..." },
1344 { CE_ENTERED_BY_PLAYER, "entered by player ..." },
1345 { CE_LEFT_BY_PLAYER, "left by player ..." },
1346 { CE_DROPPED_BY_PLAYER, "dropped by player" },
1347 { CE_SWITCHED, "switched ..." },
1349 { CE_HITTING_SOMETHING, "hitting something ..." },
1350 { CE_HIT_BY_SOMETHING, "hit by something ..." },
1352 { CE_HITTING_SOMETHING, "collision ..." },
1354 { CE_IMPACT, "impact (on something)" },
1355 { CE_SMASHED, "smashed (from above)" },
1360 static struct ValueTextInfo options_change_other_action[] =
1362 { CE_OTHER_GETS_TOUCHED, "player touches ..." },
1363 { CE_OTHER_GETS_PRESSED, "player presses ..." },
1364 { CE_OTHER_GETS_PUSHED, "player pushes ..." },
1365 { CE_OTHER_GETS_ENTERED, "player enters ..." },
1366 { CE_OTHER_GETS_LEFT, "player leaves ..." },
1367 { CE_OTHER_GETS_DIGGED, "player digs" },
1368 { CE_OTHER_GETS_COLLECTED, "player collects" },
1369 { CE_OTHER_GETS_DROPPED, "player drops" },
1370 { CE_OTHER_IS_TOUCHING, "touching ..." },
1372 { CE_OTHER_IS_HITTING, "hitting ..." },
1373 { CE_OTHER_GETS_HIT, "hit by ..." },
1375 { CE_OTHER_IS_SWITCHING, "switch of ..." },
1376 { CE_OTHER_IS_CHANGING, "change by page of" },
1377 { CE_OTHER_IS_EXPLODING, "explosion of" },
1382 static struct ValueTextInfo options_change_trigger_side[] =
1384 { CH_SIDE_LEFT, "left" },
1385 { CH_SIDE_RIGHT, "right" },
1386 { CH_SIDE_TOP, "top" },
1387 { CH_SIDE_BOTTOM, "bottom" },
1388 { CH_SIDE_LEFT_RIGHT, "left/right" },
1389 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
1390 { CH_SIDE_ANY, "any" },
1395 static struct ValueTextInfo options_change_trigger_player[] =
1397 { CH_PLAYER_1, "1" },
1398 { CH_PLAYER_2, "2" },
1399 { CH_PLAYER_3, "3" },
1400 { CH_PLAYER_4, "4" },
1401 { CH_PLAYER_ANY, "any" },
1406 static struct ValueTextInfo options_change_trigger_page[] =
1418 { (1 << 10), "11" },
1419 { (1 << 11), "12" },
1420 { (1 << 12), "13" },
1421 { (1 << 13), "14" },
1422 { (1 << 14), "15" },
1423 { (1 << 15), "16" },
1424 { (1 << 16), "17" },
1425 { (1 << 17), "18" },
1426 { (1 << 18), "19" },
1427 { (1 << 19), "20" },
1428 { (1 << 20), "21" },
1429 { (1 << 21), "22" },
1430 { (1 << 22), "23" },
1431 { (1 << 23), "24" },
1432 { (1 << 24), "25" },
1433 { (1 << 25), "26" },
1434 { (1 << 26), "27" },
1435 { (1 << 27), "28" },
1436 { (1 << 28), "29" },
1437 { (1 << 29), "30" },
1438 { (1 << 30), "31" },
1439 { (1 << 31), "32" },
1440 { CH_PAGE_ANY, "any" },
1445 static struct ValueTextInfo options_change_replace_when[] =
1447 { CP_WHEN_EMPTY, "empty" },
1448 { CP_WHEN_DIGGABLE, "diggable" },
1449 { CP_WHEN_DESTRUCTIBLE, "destructible" },
1454 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
1455 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
1460 static struct ValueTextInfo options_group_choice_mode[] =
1462 { ANIM_RANDOM, "random" },
1463 { ANIM_LOOP, "loop" },
1464 { ANIM_LINEAR, "linear" },
1465 { ANIM_PINGPONG, "pingpong" },
1466 { ANIM_PINGPONG2, "pingpong 2" },
1475 int gadget_id_align;
1476 int size; /* char size of selectbox or '-1' (dynamically determined) */
1477 struct ValueTextInfo *options;
1479 char *text_left, *text_right, *infotext;
1480 } selectbox_info[ED_NUM_SELECTBOX] =
1482 /* ---------- level and editor settings ---------------------------------- */
1485 -1, ED_COUNTER_YPOS(4),
1486 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
1488 options_time_or_steps,
1489 &level.use_step_counter,
1490 NULL, "(0 => no limit)", "time or step limit"
1493 /* ---------- element settings: configure 1 (custom elements) ----------- */
1496 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(3),
1497 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
1499 options_access_type,
1500 &custom_element.access_type,
1501 NULL, NULL, "type of access to this field"
1504 -1, ED_SETTINGS_YPOS(3),
1505 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
1507 options_access_layer,
1508 &custom_element.access_layer,
1509 NULL, NULL, "layer of access for this field"
1512 -1, ED_SETTINGS_YPOS(3),
1513 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
1515 options_access_protected,
1516 &custom_element.access_protected,
1517 NULL, NULL, "protected access for this field"
1520 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(4),
1521 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
1523 options_access_direction,
1524 &custom_element.access_direction,
1525 "from", NULL, "access direction for this field"
1528 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(5),
1529 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
1531 options_walk_to_action,
1532 &custom_element.walk_to_action,
1533 NULL, NULL, "diggable/collectible/pushable"
1536 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(9),
1537 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
1539 options_move_pattern,
1540 &custom_element.move_pattern,
1541 "can move", NULL, "element move direction"
1544 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(10),
1545 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
1547 options_move_direction,
1548 &custom_element.move_direction_initial,
1549 "starts moving", NULL, "initial element move direction"
1552 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(12),
1553 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
1555 options_move_stepsize,
1556 &custom_element.move_stepsize,
1557 "move/fall speed", NULL, "speed of element movement"
1560 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(11),
1561 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
1563 options_move_leave_type,
1564 &custom_element.move_leave_type,
1565 "can dig: can", ":", "leave behind or change element"
1568 -1, ED_SETTINGS_YPOS(13),
1569 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
1571 options_smash_targets,
1572 &custom_element.smash_targets,
1573 "can smash", NULL, "elements that can be smashed"
1576 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(14),
1577 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
1579 options_slippery_type,
1580 &custom_element.slippery_type,
1581 "slippery", NULL, "where other elements fall down"
1584 /* ---------- element settings: configure 2 (custom elements) ----------- */
1587 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(1),
1588 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
1591 &custom_element.deadliness,
1592 "deadly when", NULL, "deadliness of element"
1595 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(2),
1596 GADGET_ID_CUSTOM_CONSISTENCY, GADGET_ID_NONE,
1598 options_consistency,
1599 &custom_element.consistency,
1600 NULL, NULL, "consistency/destructibility"
1603 /* ---------- element settings: advanced (custom elements) --------------- */
1606 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(3),
1607 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
1610 &custom_element_change.delay_frames,
1611 "delay time given in", NULL, "delay time units for change"
1614 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(4),
1615 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
1617 options_change_direct_action,
1618 &custom_element_change.direct_action,
1619 NULL, NULL, "type of direct action"
1622 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(5),
1623 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
1625 options_change_other_action,
1626 &custom_element_change.other_action,
1627 NULL, "element:", "type of other element action"
1630 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(6),
1631 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
1633 options_change_trigger_side,
1634 &custom_element_change.trigger_side,
1635 "... at", "side", "element side that causes change"
1638 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(7),
1639 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
1641 options_change_trigger_player,
1642 &custom_element_change.trigger_player,
1643 "player:", " ", "player that causes change"
1646 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(7),
1647 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
1649 options_change_trigger_page,
1650 &custom_element_change.trigger_page,
1651 "page:", NULL, "change page that causes change"
1654 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(10),
1655 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
1657 options_change_replace_when,
1658 &custom_element_change.replace_when,
1659 "replace when", NULL, "which elements can be replaced"
1662 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(14),
1663 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
1665 options_change_page,
1666 &custom_element.current_change_page,
1667 NULL, NULL, "element change page"
1670 /* ---------- element settings: configure (group elements) --------------- */
1673 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(6),
1674 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
1676 options_group_choice_mode,
1677 &group_element_info.choice_mode,
1678 "choice type:", NULL, "type of group element choice"
1686 int gadget_id_align;
1689 char *text_left, *text_right, *infotext;
1690 } textbutton_info[ED_NUM_TEXTBUTTONS] =
1694 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(1),
1695 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
1697 NULL, NULL, "Show information about element"
1700 ED_SETTINGS_XPOS(0) + 124, ED_COUNTER_YPOS(1),
1701 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_NONE,
1703 NULL, NULL, "Configure element properties"
1706 ED_SETTINGS_XPOS(0) + 124, ED_COUNTER_YPOS(1),
1707 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_NONE,
1709 NULL, NULL, "Configure custom element properties"
1712 ED_SETTINGS_XPOS(0) + 248, ED_COUNTER_YPOS(1),
1713 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_NONE,
1715 NULL, NULL, "Configure custom element properties"
1718 ED_SETTINGS_XPOS(0) + 372, ED_COUNTER_YPOS(1),
1719 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_NONE,
1721 NULL, NULL, "Custom element change configuration"
1725 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(1),
1726 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
1728 NULL, NULL, "Show information about element"
1731 ED_SETTINGS_XPOS(0) + 166, ED_COUNTER_YPOS(1),
1732 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_NONE,
1734 NULL, NULL, "Configure element properties"
1737 ED_SETTINGS_XPOS(0) + 332, ED_COUNTER_YPOS(1),
1738 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_NONE,
1740 NULL, NULL, "Advanced element configuration"
1744 -1, ED_SETTINGS_YPOS(2),
1745 GADGET_ID_SAVE_AS_TEMPLATE, GADGET_ID_CUSTOM_USE_TEMPLATE,
1747 " ", "As Template", "Save current settings as new template"
1750 -1, ED_SETTINGS_YPOS(14),
1751 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
1753 NULL, NULL, "Add new change page"
1756 -1, ED_SETTINGS_YPOS(14),
1757 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
1759 NULL, NULL, "Delete current change page"
1769 int gadget_id_align;
1770 char *text_left, *text_right, *infotext;
1771 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
1774 ED_BUTTON_MINUS_XPOS, ED_BUTTON_COUNT_YPOS,
1775 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(14),
1776 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
1777 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
1778 NULL, NULL, "select previous change page"
1781 ED_BUTTON_PLUS_XPOS, ED_BUTTON_COUNT_YPOS,
1782 -1, ED_SETTINGS_YPOS(14),
1783 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
1784 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
1785 NULL, "change page", "select next change page"
1788 ED_COPY_CHANGE_PAGE_XPOS, ED_COPY_CHANGE_PAGE_YPOS,
1789 -1, ED_SETTINGS_YPOS(14),
1790 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
1791 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
1792 " ", NULL, "copy settings from this change page"
1795 ED_PASTE_CHANGE_PAGE_XPOS, ED_PASTE_CHANGE_PAGE_YPOS,
1796 -1, ED_SETTINGS_YPOS(14),
1797 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
1798 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
1799 NULL, NULL, "paste settings to this change page"
1809 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
1812 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 0 * ED_SCROLLBUTTON_YSIZE,
1813 ED_SCROLL_UP_XPOS, ED_SCROLL_UP_YPOS,
1814 GADGET_ID_SCROLL_UP,
1815 "scroll level editing area up"
1818 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 1 * ED_SCROLLBUTTON_YSIZE,
1819 ED_SCROLL_DOWN_XPOS, ED_SCROLL_DOWN_YPOS,
1820 GADGET_ID_SCROLL_DOWN,
1821 "scroll level editing area down"
1824 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 2 * ED_SCROLLBUTTON_YSIZE,
1825 ED_SCROLL_LEFT_XPOS, ED_SCROLL_LEFT_YPOS,
1826 GADGET_ID_SCROLL_LEFT,
1827 "scroll level editing area left"
1830 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 3 * ED_SCROLLBUTTON_YSIZE,
1831 ED_SCROLL_RIGHT_XPOS, ED_SCROLL_RIGHT_YPOS,
1832 GADGET_ID_SCROLL_RIGHT,
1833 "scroll level editing area right"
1836 ED_SCROLLBUTTON2_XPOS, ED_SCROLLBUTTON2_YPOS + 0 * ED_SCROLLBUTTON2_YSIZE,
1837 ED_SCROLL2_UP_XPOS, ED_SCROLL2_UP_YPOS,
1838 GADGET_ID_SCROLL_LIST_UP,
1839 "scroll element list up ('Page Up')"
1842 ED_SCROLLBUTTON2_XPOS, ED_SCROLLBUTTON2_YPOS + 1 * ED_SCROLLBUTTON2_YSIZE,
1843 ED_SCROLL2_DOWN_XPOS, ED_SCROLL2_DOWN_YPOS,
1844 GADGET_ID_SCROLL_LIST_DOWN,
1845 "scroll element list down ('Page Down')"
1857 } scrollbar_info[ED_NUM_SCROLLBARS] =
1860 ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
1861 SX + ED_SCROLL_HORIZONTAL_XPOS, SY + ED_SCROLL_HORIZONTAL_YPOS,
1862 ED_SCROLL_HORIZONTAL_XSIZE, ED_SCROLL_HORIZONTAL_YSIZE,
1863 GD_TYPE_SCROLLBAR_HORIZONTAL,
1864 GADGET_ID_SCROLL_HORIZONTAL,
1865 "scroll level editing area horizontally"
1868 ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
1869 SX + ED_SCROLL_VERTICAL_XPOS, SY + ED_SCROLL_VERTICAL_YPOS,
1870 ED_SCROLL_VERTICAL_XSIZE, ED_SCROLL_VERTICAL_YSIZE,
1871 GD_TYPE_SCROLLBAR_VERTICAL,
1872 GADGET_ID_SCROLL_VERTICAL,
1873 "scroll level editing area vertically"
1876 ED_SCROLLBAR2_XPOS, ED_SCROLLBAR2_YPOS,
1877 DX + ED_SCROLL2_VERTICAL_XPOS, DY + ED_SCROLL2_VERTICAL_YPOS,
1878 ED_SCROLL2_VERTICAL_XSIZE, ED_SCROLL2_VERTICAL_YSIZE,
1879 GD_TYPE_SCROLLBAR_VERTICAL,
1880 GADGET_ID_SCROLL_LIST_VERTICAL,
1881 "scroll element list vertically"
1889 int gadget_id_align;
1890 int radio_button_nr;
1893 char *text_left, *text_right, *infotext;
1894 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
1897 -1, ED_COUNTER2_YPOS(8),
1898 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
1899 RADIO_NR_RANDOM_ELEMENTS,
1900 &random_placement_method, RANDOM_USE_PERCENTAGE,
1901 " ", "percentage", "use percentage for random elements"
1904 -1, ED_COUNTER2_YPOS(8),
1905 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
1906 RADIO_NR_RANDOM_ELEMENTS,
1907 &random_placement_method, RANDOM_USE_QUANTITY,
1908 " ", "quantity", "use quantity for random elements"
1916 int gadget_id_align;
1918 char *text_left, *text_right, *infotext;
1919 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
1921 /* ---------- level and editor settings ---------------------------------- */
1924 ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(6) - MINI_TILEY,
1925 GADGET_ID_DOUBLE_SPEED, GADGET_ID_NONE,
1926 &level.double_speed,
1927 NULL, "double speed movement", "set movement speed of player"
1930 -1, ED_COUNTER_YPOS(6) - MINI_TILEY,
1931 GADGET_ID_GRAVITY, GADGET_ID_DOUBLE_SPEED,
1932 &level.initial_gravity,
1933 " ", "gravity", "set level gravity"
1936 ED_SETTINGS_XPOS(0), ED_COUNTER2_YPOS(9) - MINI_TILEY,
1937 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
1938 &random_placement_background_restricted,
1940 "restrict random placement to:", "set random placement restriction"
1943 /* ---------- element settings: configure (various elements) ------------- */
1946 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(0),
1947 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
1948 &stick_element_properties_window,
1950 "stick this screen to edit content","stick this screen to edit content"
1953 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1),
1954 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
1955 &level.em_slippery_gems,
1957 "slip down from certain flat walls","use EM style slipping behaviour"
1960 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1),
1961 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
1962 &level.use_spring_bug,
1964 "use spring pushing bug", "use odd spring pushing behaviour"
1967 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(0),
1968 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
1969 &level.grow_into_diggable,
1971 "can grow into anything diggable", "grow into more than just sand"
1974 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1),
1975 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
1976 &level.block_last_field,
1978 "block last field when moving", "player blocks last field when moving"
1981 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1),
1982 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
1983 &level.sp_block_last_field,
1985 "block last field when moving", "player blocks last field when moving"
1988 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(2),
1989 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
1990 &level.instant_relocation,
1992 "no scrolling when relocating", "player gets relocated without delay"
1995 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(3),
1996 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
1997 &level.can_pass_to_walkable,
1999 "can pass to walkable element", "player can pass to empty or walkable"
2002 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(0),
2003 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
2004 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
2006 "can fall into acid (with gravity)","player can fall into acid pool"
2009 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(0),
2010 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
2011 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
2013 "can move into acid", "element can move into acid pool"
2016 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1),
2017 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
2018 &custom_element_properties[EP_DONT_COLLIDE_WITH],
2020 "deadly when colliding with", "element is deadly when hitting player"
2023 /* ---------- element settings: configure 1 (custom elements) ----------- */
2026 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1),
2027 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
2028 &custom_element.use_gfx_element,
2029 NULL, "use graphic of element:", "use graphic for custom element"
2032 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(2),
2033 GADGET_ID_CUSTOM_USE_TEMPLATE, GADGET_ID_NONE,
2034 &level.use_custom_template,
2035 NULL, "use template", "use template for custom properties"
2038 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(3),
2039 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
2040 &custom_element_properties[EP_ACCESSIBLE],
2041 NULL, NULL, "player can walk to or pass this field"
2044 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(5),
2045 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
2046 &custom_element_properties[EP_WALK_TO_OBJECT],
2047 NULL, NULL, "player can dig/collect/push element"
2050 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(9),
2051 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
2052 &custom_element_properties[EP_CAN_MOVE],
2053 NULL, NULL, "element can move in some direction"
2056 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(13),
2057 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
2058 &custom_element_properties[EP_CAN_FALL],
2059 NULL, "can fall", "element can fall down"
2062 -1, ED_SETTINGS_YPOS(13),
2063 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
2064 &custom_element_properties[EP_CAN_SMASH],
2065 " ", NULL, "element can smash other elements"
2068 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(14),
2069 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
2070 &custom_element_properties[EP_SLIPPERY],
2071 NULL, NULL, "other elements can fall down from it"
2074 /* ---------- element settings: configure 2 (custom elements) ----------- */
2077 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1),
2078 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
2079 &custom_element_properties[EP_DEADLY],
2080 NULL, NULL, "element can kill the player"
2083 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(2),
2084 GADGET_ID_CUSTOM_EXPLODE_RESULT, GADGET_ID_NONE,
2085 &custom_element_properties[EP_EXPLODE_RESULT],
2086 NULL, NULL, "set consistency/destructibility"
2089 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(3),
2090 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
2091 &custom_element.can_explode_by_fire,
2092 NULL, "by fire", "element can explode by fire/explosion"
2095 -1, ED_SETTINGS_YPOS(3),
2096 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
2097 &custom_element.can_explode_smashed,
2098 " ", "smashed", "element can explode when smashed"
2101 -1, ED_SETTINGS_YPOS(3),
2102 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
2103 &custom_element.can_explode_impact,
2104 " ", "impact", "element can explode on impact"
2107 /* ---------- element settings: advanced (custom elements) --------------- */
2110 ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1),
2111 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
2112 &custom_element_change.can_change,
2113 NULL, "element changes to:", "element can change to other element"
2116 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(2),
2117 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
2118 &custom_element_change_events[CE_DELAY],
2119 NULL, NULL, "element changes after delay"
2122 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(4),
2123 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
2124 &custom_element_change_events[CE_BY_DIRECT_ACTION],
2125 NULL, NULL, "element changes by direct action"
2128 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(5),
2129 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
2130 &custom_element_change_events[CE_BY_OTHER_ACTION],
2131 NULL, NULL, "element changes by other element"
2134 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(8),
2135 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
2136 &custom_element_change.explode,
2137 NULL, "explode instead of change", "element explodes instead of change"
2140 ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(9),
2141 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
2142 &custom_element_change.use_target_content,
2143 NULL, "use extended change target:","element changes to more elements"
2146 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(11),
2147 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
2148 &custom_element_change.only_if_complete,
2149 NULL, "replace all or nothing", "only replace when all can be changed"
2152 ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(12),
2153 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
2154 &custom_element_change.use_random_replace,
2155 NULL, NULL, "use percentage for random replace"
2162 int area_xsize, area_ysize;
2164 int gadget_id_align;
2165 char *text_left, *text_right, *text_below;
2166 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
2168 /* ---------- level playfield content ------------------------------------ */
2172 MAX_ED_FIELDX, MAX_ED_FIELDY,
2173 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
2177 /* ---------- yam yam content -------------------------------------------- */
2180 ED_AREA_YAMYAM_CONTENT_XPOS(0), ED_AREA_YAMYAM_CONTENT_YPOS(0),
2182 GADGET_ID_ELEMENT_CONTENT_0, GADGET_ID_NONE,
2186 ED_AREA_YAMYAM_CONTENT_XPOS(1), ED_AREA_YAMYAM_CONTENT_YPOS(1),
2188 GADGET_ID_ELEMENT_CONTENT_1, GADGET_ID_NONE,
2192 ED_AREA_YAMYAM_CONTENT_XPOS(2), ED_AREA_YAMYAM_CONTENT_YPOS(2),
2194 GADGET_ID_ELEMENT_CONTENT_2, GADGET_ID_NONE,
2198 ED_AREA_YAMYAM_CONTENT_XPOS(3), ED_AREA_YAMYAM_CONTENT_YPOS(3),
2200 GADGET_ID_ELEMENT_CONTENT_3, GADGET_ID_NONE,
2204 ED_AREA_YAMYAM_CONTENT_XPOS(4), ED_AREA_YAMYAM_CONTENT_YPOS(4),
2206 GADGET_ID_ELEMENT_CONTENT_4, GADGET_ID_NONE,
2210 ED_AREA_YAMYAM_CONTENT_XPOS(5), ED_AREA_YAMYAM_CONTENT_YPOS(5),
2212 GADGET_ID_ELEMENT_CONTENT_5, GADGET_ID_NONE,
2216 ED_AREA_YAMYAM_CONTENT_XPOS(6), ED_AREA_YAMYAM_CONTENT_YPOS(6),
2218 GADGET_ID_ELEMENT_CONTENT_6, GADGET_ID_NONE,
2222 ED_AREA_YAMYAM_CONTENT_XPOS(7), ED_AREA_YAMYAM_CONTENT_YPOS(7),
2224 GADGET_ID_ELEMENT_CONTENT_7, GADGET_ID_NONE,
2228 /* ---------- amoeba content --------------------------------------------- */
2231 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
2233 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
2234 "content:", NULL, NULL
2237 /* ---------- custom graphic --------------------------------------------- */
2240 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
2242 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
2246 /* ---------- custom content (when exploding) ---------------------------- */
2249 -1, ED_AREA_3X3_SETTINGS_YPOS(2),
2251 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, /* align three rows */
2252 "content:", NULL, NULL
2255 /* ---------- custom enter and leave element (when moving) --------------- */
2258 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(11),
2260 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
2261 "can dig:", " ", NULL
2264 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
2266 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
2270 /* ---------- custom change target --------------------------------------- */
2273 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
2275 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
2276 NULL, "after/when:", NULL
2279 /* ---------- custom change content (extended change target) ------------- */
2282 -1, ED_AREA_3X3_SETTINGS_YPOS(10),
2284 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, /* align three rows */
2288 /* ---------- custom change trigger (element causing change) ------------- */
2291 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
2293 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
2297 /* ---------- group element content -------------------------------------- */
2300 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(4),
2301 MAX_ELEMENTS_IN_GROUP, 1,
2302 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
2303 "content:", NULL, NULL
2306 /* ---------- random background (for random painting) -------------------- */
2309 -1, ED_SETTINGS_YPOS(14),
2311 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
2318 -----------------------------------------------------------------------------
2319 some internally used variables
2320 -----------------------------------------------------------------------------
2323 /* actual size of level editor drawing area */
2324 static int ed_fieldx = MAX_ED_FIELDX - 1, ed_fieldy = MAX_ED_FIELDY - 1;
2326 /* actual position of level editor drawing area in level playfield */
2327 static int level_xpos = -1, level_ypos = -1;
2329 #define IN_ED_FIELD(x,y) ((x)>=0 && (x)<ed_fieldx && (y)>=0 &&(y)<ed_fieldy)
2331 /* drawing elements on the three mouse buttons */
2332 static int new_element1 = EL_WALL;
2333 static int new_element2 = EL_EMPTY;
2334 static int new_element3 = EL_SAND;
2336 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
2337 (button) == 2 ? new_element2 : \
2338 (button) == 3 ? new_element3 : EL_EMPTY)
2339 #define BUTTON_STEPSIZE(button) ((button) == 1 ? 1 : (button) == 2 ? 5 : 10)
2341 /* forward declaration for internal use */
2342 static void ModifyEditorCounter(int, int);
2343 static void ModifyEditorCounterLimits(int, int, int);
2344 static void ModifyEditorSelectbox(int, int);
2345 static void ModifyEditorDrawingArea(int, int, int);
2346 static void ModifyEditorElementList();
2347 static void RedrawDrawingElements();
2348 static void DrawDrawingWindow();
2349 static void DrawLevelInfoWindow();
2350 static void DrawPropertiesWindow();
2351 static void UpdateCustomElementGraphicGadgets();
2352 static boolean checkPropertiesConfig(int);
2353 static void CopyLevelToUndoBuffer(int);
2354 static void HandleDrawingAreas(struct GadgetInfo *);
2355 static void HandleCounterButtons(struct GadgetInfo *);
2356 static void HandleTextInputGadgets(struct GadgetInfo *);
2357 static void HandleTextAreaGadgets(struct GadgetInfo *);
2358 static void HandleSelectboxGadgets(struct GadgetInfo *);
2359 static void HandleTextbuttonGadgets(struct GadgetInfo *);
2360 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
2361 static void HandleRadiobuttons(struct GadgetInfo *);
2362 static void HandleCheckbuttons(struct GadgetInfo *);
2363 static void HandleControlButtons(struct GadgetInfo *);
2364 static void HandleDrawingAreaInfo(struct GadgetInfo *);
2366 static struct GadgetInfo *level_editor_gadget[NUM_EDITOR_GADGETS];
2367 static int right_gadget_border[NUM_EDITOR_GADGETS];
2369 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
2370 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
2371 static boolean draw_with_brush = FALSE;
2372 static int properties_element = 0;
2374 static short FieldBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2375 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2376 static int undo_buffer_position = 0;
2377 static int undo_buffer_steps = 0;
2379 static int edit_mode;
2380 static int edit_mode_properties;
2382 static int element_shift = 0;
2384 static int editor_hl_boulderdash[] =
2402 static int editor_el_boulderdash[] =
2419 EL_BD_BUTTERFLY_LEFT,
2421 EL_BD_BUTTERFLY_RIGHT,
2422 EL_BD_FIREFLY_RIGHT,
2425 EL_BD_BUTTERFLY_DOWN,
2429 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
2430 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
2431 static int num_editor_hl_boulderdash = SIZEOF_ARRAY_INT(editor_hl_boulderdash);
2432 static int num_editor_el_boulderdash = SIZEOF_ARRAY_INT(editor_el_boulderdash);
2434 static int editor_hl_emerald_mine[] =
2452 static int editor_el_emerald_mine[] =
2499 EL_ACID_POOL_TOPLEFT,
2501 EL_ACID_POOL_TOPRIGHT,
2504 EL_ACID_POOL_BOTTOMLEFT,
2505 EL_ACID_POOL_BOTTOM,
2506 EL_ACID_POOL_BOTTOMRIGHT,
2536 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
2537 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
2538 static int num_editor_hl_emerald_mine=SIZEOF_ARRAY_INT(editor_hl_emerald_mine);
2539 static int num_editor_el_emerald_mine=SIZEOF_ARRAY_INT(editor_el_emerald_mine);
2541 static int editor_hl_more[] =
2549 static int editor_el_more[] =
2577 EL_WALL_EMERALD_YELLOW,
2578 EL_WALL_EMERALD_RED,
2579 EL_WALL_EMERALD_PURPLE,
2596 EL_DYNABOMB_INCREASE_NUMBER,
2597 EL_DYNABOMB_INCREASE_SIZE,
2598 EL_DYNABOMB_INCREASE_POWER,
2619 EL_BALLOON_SWITCH_ANY,
2621 EL_BALLOON_SWITCH_LEFT,
2622 EL_BALLOON_SWITCH_RIGHT,
2623 EL_BALLOON_SWITCH_UP,
2624 EL_BALLOON_SWITCH_DOWN,
2627 EL_EXPANDABLE_WALL_HORIZONTAL,
2628 EL_EXPANDABLE_WALL_VERTICAL,
2629 EL_EXPANDABLE_WALL_ANY,
2631 EL_INVISIBLE_STEELWALL,
2646 static int *editor_hl_more_ptr = editor_hl_more;
2647 static int *editor_el_more_ptr = editor_el_more;
2648 static int num_editor_hl_more = SIZEOF_ARRAY_INT(editor_hl_more);
2649 static int num_editor_el_more = SIZEOF_ARRAY_INT(editor_el_more);
2651 static int editor_hl_sokoban[] =
2664 static int editor_el_sokoban[] =
2667 EL_SOKOBAN_FIELD_EMPTY,
2668 EL_SOKOBAN_FIELD_FULL,
2669 EL_SOKOBAN_FIELD_PLAYER,
2671 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
2672 static int *editor_el_sokoban_ptr = editor_el_sokoban;
2673 static int num_editor_hl_sokoban = SIZEOF_ARRAY_INT(editor_hl_sokoban);
2674 static int num_editor_el_sokoban = SIZEOF_ARRAY_INT(editor_el_sokoban);
2676 static int editor_hl_supaplex[] =
2689 static int editor_el_supaplex[] =
2702 EL_SP_HARDWARE_GRAY,
2711 EL_SP_GRAVITY_PORT_RIGHT,
2712 EL_SP_GRAVITY_PORT_DOWN,
2713 EL_SP_GRAVITY_PORT_LEFT,
2715 EL_SP_GRAVITY_PORT_UP,
2721 EL_SP_PORT_VERTICAL,
2722 EL_SP_PORT_HORIZONTAL,
2730 EL_SP_HARDWARE_BASE_1,
2731 EL_SP_HARDWARE_GREEN,
2732 EL_SP_HARDWARE_BLUE,
2735 EL_SP_HARDWARE_YELLOW,
2736 EL_SP_HARDWARE_BASE_2,
2737 EL_SP_HARDWARE_BASE_3,
2738 EL_SP_HARDWARE_BASE_4,
2740 EL_SP_HARDWARE_BASE_5,
2741 EL_SP_HARDWARE_BASE_6,
2745 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
2746 static int *editor_el_supaplex_ptr = editor_el_supaplex;
2747 static int num_editor_hl_supaplex = SIZEOF_ARRAY_INT(editor_hl_supaplex);
2748 static int num_editor_el_supaplex = SIZEOF_ARRAY_INT(editor_el_supaplex);
2750 static int editor_hl_diamond_caves[] =
2773 static int editor_el_diamond_caves[] =
2780 EL_CONVEYOR_BELT_1_LEFT,
2781 EL_CONVEYOR_BELT_1_MIDDLE,
2782 EL_CONVEYOR_BELT_1_RIGHT,
2783 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
2785 EL_CONVEYOR_BELT_2_LEFT,
2786 EL_CONVEYOR_BELT_2_MIDDLE,
2787 EL_CONVEYOR_BELT_2_RIGHT,
2788 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
2790 EL_CONVEYOR_BELT_3_LEFT,
2791 EL_CONVEYOR_BELT_3_MIDDLE,
2792 EL_CONVEYOR_BELT_3_RIGHT,
2793 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
2795 EL_CONVEYOR_BELT_4_LEFT,
2796 EL_CONVEYOR_BELT_4_MIDDLE,
2797 EL_CONVEYOR_BELT_4_RIGHT,
2798 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
2800 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
2801 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
2802 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
2803 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
2805 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
2806 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
2807 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
2808 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
2811 EL_SWITCHGATE_CLOSED,
2812 EL_SWITCHGATE_SWITCH_UP,
2827 EL_STEELWALL_SLIPPERY,
2830 EL_SIGN_EXCLAMATION,
2833 EL_LIGHT_SWITCH_ACTIVE,
2840 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
2841 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
2842 static int num_editor_hl_diamond_caves = SIZEOF_ARRAY_INT(editor_hl_diamond_caves);
2843 static int num_editor_el_diamond_caves = SIZEOF_ARRAY_INT(editor_el_diamond_caves);
2845 static int editor_hl_dx_boulderdash[] =
2868 static int editor_el_dx_boulderdash[] =
2872 EL_TUBE_HORIZONTAL_DOWN,
2876 EL_TUBE_VERTICAL_RIGHT,
2878 EL_TUBE_VERTICAL_LEFT,
2882 EL_TUBE_HORIZONTAL_UP,
2890 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
2891 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
2892 static int num_editor_hl_dx_boulderdash = SIZEOF_ARRAY_INT(editor_hl_dx_boulderdash);
2893 static int num_editor_el_dx_boulderdash = SIZEOF_ARRAY_INT(editor_el_dx_boulderdash);
2895 static int editor_hl_chars[] =
2903 static int editor_el_chars[] =
2992 EL_CHAR(FONT_ASCII_CURSOR),
2995 static int *editor_hl_chars_ptr = editor_hl_chars;
2996 static int *editor_el_chars_ptr = editor_el_chars;
2997 static int num_editor_hl_chars = SIZEOF_ARRAY_INT(editor_hl_chars);
2998 static int num_editor_el_chars = SIZEOF_ARRAY_INT(editor_el_chars);
3000 static int editor_hl_custom[] =
3023 static int editor_el_custom[] =
3025 EL_CUSTOM_START + 0,
3026 EL_CUSTOM_START + 1,
3027 EL_CUSTOM_START + 2,
3028 EL_CUSTOM_START + 3,
3030 EL_CUSTOM_START + 4,
3031 EL_CUSTOM_START + 5,
3032 EL_CUSTOM_START + 6,
3033 EL_CUSTOM_START + 7,
3035 EL_CUSTOM_START + 8,
3036 EL_CUSTOM_START + 9,
3037 EL_CUSTOM_START + 10,
3038 EL_CUSTOM_START + 11,
3040 EL_CUSTOM_START + 12,
3041 EL_CUSTOM_START + 13,
3042 EL_CUSTOM_START + 14,
3043 EL_CUSTOM_START + 15,
3045 EL_CUSTOM_START + 16,
3046 EL_CUSTOM_START + 17,
3047 EL_CUSTOM_START + 18,
3048 EL_CUSTOM_START + 19,
3050 EL_CUSTOM_START + 20,
3051 EL_CUSTOM_START + 21,
3052 EL_CUSTOM_START + 22,
3053 EL_CUSTOM_START + 23,
3055 EL_CUSTOM_START + 24,
3056 EL_CUSTOM_START + 25,
3057 EL_CUSTOM_START + 26,
3058 EL_CUSTOM_START + 27,
3060 EL_CUSTOM_START + 28,
3061 EL_CUSTOM_START + 29,
3062 EL_CUSTOM_START + 30,
3063 EL_CUSTOM_START + 31,
3065 EL_CUSTOM_START + 32,
3066 EL_CUSTOM_START + 33,
3067 EL_CUSTOM_START + 34,
3068 EL_CUSTOM_START + 35,
3070 EL_CUSTOM_START + 36,
3071 EL_CUSTOM_START + 37,
3072 EL_CUSTOM_START + 38,
3073 EL_CUSTOM_START + 39,
3075 EL_CUSTOM_START + 40,
3076 EL_CUSTOM_START + 41,
3077 EL_CUSTOM_START + 42,
3078 EL_CUSTOM_START + 43,
3080 EL_CUSTOM_START + 44,
3081 EL_CUSTOM_START + 45,
3082 EL_CUSTOM_START + 46,
3083 EL_CUSTOM_START + 47,
3085 EL_CUSTOM_START + 48,
3086 EL_CUSTOM_START + 49,
3087 EL_CUSTOM_START + 50,
3088 EL_CUSTOM_START + 51,
3090 EL_CUSTOM_START + 52,
3091 EL_CUSTOM_START + 53,
3092 EL_CUSTOM_START + 54,
3093 EL_CUSTOM_START + 55,
3095 EL_CUSTOM_START + 56,
3096 EL_CUSTOM_START + 57,
3097 EL_CUSTOM_START + 58,
3098 EL_CUSTOM_START + 59,
3100 EL_CUSTOM_START + 60,
3101 EL_CUSTOM_START + 61,
3102 EL_CUSTOM_START + 62,
3103 EL_CUSTOM_START + 63,
3105 EL_CUSTOM_START + 64,
3106 EL_CUSTOM_START + 65,
3107 EL_CUSTOM_START + 66,
3108 EL_CUSTOM_START + 67,
3110 EL_CUSTOM_START + 68,
3111 EL_CUSTOM_START + 69,
3112 EL_CUSTOM_START + 70,
3113 EL_CUSTOM_START + 71,
3115 EL_CUSTOM_START + 72,
3116 EL_CUSTOM_START + 73,
3117 EL_CUSTOM_START + 74,
3118 EL_CUSTOM_START + 75,
3120 EL_CUSTOM_START + 76,
3121 EL_CUSTOM_START + 77,
3122 EL_CUSTOM_START + 78,
3123 EL_CUSTOM_START + 79,
3125 EL_CUSTOM_START + 80,
3126 EL_CUSTOM_START + 81,
3127 EL_CUSTOM_START + 82,
3128 EL_CUSTOM_START + 83,
3130 EL_CUSTOM_START + 84,
3131 EL_CUSTOM_START + 85,
3132 EL_CUSTOM_START + 86,
3133 EL_CUSTOM_START + 87,
3135 EL_CUSTOM_START + 88,
3136 EL_CUSTOM_START + 89,
3137 EL_CUSTOM_START + 90,
3138 EL_CUSTOM_START + 91,
3140 EL_CUSTOM_START + 92,
3141 EL_CUSTOM_START + 93,
3142 EL_CUSTOM_START + 94,
3143 EL_CUSTOM_START + 95,
3145 EL_CUSTOM_START + 96,
3146 EL_CUSTOM_START + 97,
3147 EL_CUSTOM_START + 98,
3148 EL_CUSTOM_START + 99,
3150 EL_CUSTOM_START + 100,
3151 EL_CUSTOM_START + 101,
3152 EL_CUSTOM_START + 102,
3153 EL_CUSTOM_START + 103,
3155 EL_CUSTOM_START + 104,
3156 EL_CUSTOM_START + 105,
3157 EL_CUSTOM_START + 106,
3158 EL_CUSTOM_START + 107,
3160 EL_CUSTOM_START + 108,
3161 EL_CUSTOM_START + 109,
3162 EL_CUSTOM_START + 110,
3163 EL_CUSTOM_START + 111,
3165 EL_CUSTOM_START + 112,
3166 EL_CUSTOM_START + 113,
3167 EL_CUSTOM_START + 114,
3168 EL_CUSTOM_START + 115,
3170 EL_CUSTOM_START + 116,
3171 EL_CUSTOM_START + 117,
3172 EL_CUSTOM_START + 118,
3173 EL_CUSTOM_START + 119,
3175 EL_CUSTOM_START + 120,
3176 EL_CUSTOM_START + 121,
3177 EL_CUSTOM_START + 122,
3178 EL_CUSTOM_START + 123,
3180 EL_CUSTOM_START + 124,
3181 EL_CUSTOM_START + 125,
3182 EL_CUSTOM_START + 126,
3183 EL_CUSTOM_START + 127
3185 static int *editor_hl_custom_ptr = editor_hl_custom;
3186 static int *editor_el_custom_ptr = editor_el_custom;
3187 static int num_editor_hl_custom = SIZEOF_ARRAY_INT(editor_hl_custom);
3188 static int num_editor_el_custom = SIZEOF_ARRAY_INT(editor_el_custom);
3190 static int editor_hl_custom_more[] =
3194 static int editor_el_custom_more[] =
3196 EL_CUSTOM_START + 128,
3197 EL_CUSTOM_START + 129,
3198 EL_CUSTOM_START + 130,
3199 EL_CUSTOM_START + 131,
3201 EL_CUSTOM_START + 132,
3202 EL_CUSTOM_START + 133,
3203 EL_CUSTOM_START + 134,
3204 EL_CUSTOM_START + 135,
3206 EL_CUSTOM_START + 136,
3207 EL_CUSTOM_START + 137,
3208 EL_CUSTOM_START + 138,
3209 EL_CUSTOM_START + 139,
3211 EL_CUSTOM_START + 140,
3212 EL_CUSTOM_START + 141,
3213 EL_CUSTOM_START + 142,
3214 EL_CUSTOM_START + 143,
3216 EL_CUSTOM_START + 144,
3217 EL_CUSTOM_START + 145,
3218 EL_CUSTOM_START + 146,
3219 EL_CUSTOM_START + 147,
3221 EL_CUSTOM_START + 148,
3222 EL_CUSTOM_START + 149,
3223 EL_CUSTOM_START + 150,
3224 EL_CUSTOM_START + 151,
3226 EL_CUSTOM_START + 152,
3227 EL_CUSTOM_START + 153,
3228 EL_CUSTOM_START + 154,
3229 EL_CUSTOM_START + 155,
3231 EL_CUSTOM_START + 156,
3232 EL_CUSTOM_START + 157,
3233 EL_CUSTOM_START + 158,
3234 EL_CUSTOM_START + 159,
3236 EL_CUSTOM_START + 160,
3237 EL_CUSTOM_START + 161,
3238 EL_CUSTOM_START + 162,
3239 EL_CUSTOM_START + 163,
3241 EL_CUSTOM_START + 164,
3242 EL_CUSTOM_START + 165,
3243 EL_CUSTOM_START + 166,
3244 EL_CUSTOM_START + 167,
3246 EL_CUSTOM_START + 168,
3247 EL_CUSTOM_START + 169,
3248 EL_CUSTOM_START + 170,
3249 EL_CUSTOM_START + 171,
3251 EL_CUSTOM_START + 172,
3252 EL_CUSTOM_START + 173,
3253 EL_CUSTOM_START + 174,
3254 EL_CUSTOM_START + 175,
3256 EL_CUSTOM_START + 176,
3257 EL_CUSTOM_START + 177,
3258 EL_CUSTOM_START + 178,
3259 EL_CUSTOM_START + 179,
3261 EL_CUSTOM_START + 180,
3262 EL_CUSTOM_START + 181,
3263 EL_CUSTOM_START + 182,
3264 EL_CUSTOM_START + 183,
3266 EL_CUSTOM_START + 184,
3267 EL_CUSTOM_START + 185,
3268 EL_CUSTOM_START + 186,
3269 EL_CUSTOM_START + 187,
3271 EL_CUSTOM_START + 188,
3272 EL_CUSTOM_START + 189,
3273 EL_CUSTOM_START + 190,
3274 EL_CUSTOM_START + 191,
3276 EL_CUSTOM_START + 192,
3277 EL_CUSTOM_START + 193,
3278 EL_CUSTOM_START + 194,
3279 EL_CUSTOM_START + 195,
3281 EL_CUSTOM_START + 196,
3282 EL_CUSTOM_START + 197,
3283 EL_CUSTOM_START + 198,
3284 EL_CUSTOM_START + 199,
3286 EL_CUSTOM_START + 200,
3287 EL_CUSTOM_START + 201,
3288 EL_CUSTOM_START + 202,
3289 EL_CUSTOM_START + 203,
3291 EL_CUSTOM_START + 204,
3292 EL_CUSTOM_START + 205,
3293 EL_CUSTOM_START + 206,
3294 EL_CUSTOM_START + 207,
3296 EL_CUSTOM_START + 208,
3297 EL_CUSTOM_START + 209,
3298 EL_CUSTOM_START + 210,
3299 EL_CUSTOM_START + 211,
3301 EL_CUSTOM_START + 212,
3302 EL_CUSTOM_START + 213,
3303 EL_CUSTOM_START + 214,
3304 EL_CUSTOM_START + 215,
3306 EL_CUSTOM_START + 216,
3307 EL_CUSTOM_START + 217,
3308 EL_CUSTOM_START + 218,
3309 EL_CUSTOM_START + 219,
3311 EL_CUSTOM_START + 220,
3312 EL_CUSTOM_START + 221,
3313 EL_CUSTOM_START + 222,
3314 EL_CUSTOM_START + 223,
3316 EL_CUSTOM_START + 224,
3317 EL_CUSTOM_START + 225,
3318 EL_CUSTOM_START + 226,
3319 EL_CUSTOM_START + 227,
3321 EL_CUSTOM_START + 228,
3322 EL_CUSTOM_START + 229,
3323 EL_CUSTOM_START + 230,
3324 EL_CUSTOM_START + 231,
3326 EL_CUSTOM_START + 232,
3327 EL_CUSTOM_START + 233,
3328 EL_CUSTOM_START + 234,
3329 EL_CUSTOM_START + 235,
3331 EL_CUSTOM_START + 236,
3332 EL_CUSTOM_START + 237,
3333 EL_CUSTOM_START + 238,
3334 EL_CUSTOM_START + 239,
3336 EL_CUSTOM_START + 240,
3337 EL_CUSTOM_START + 241,
3338 EL_CUSTOM_START + 242,
3339 EL_CUSTOM_START + 243,
3341 EL_CUSTOM_START + 244,
3342 EL_CUSTOM_START + 245,
3343 EL_CUSTOM_START + 246,
3344 EL_CUSTOM_START + 247,
3346 EL_CUSTOM_START + 248,
3347 EL_CUSTOM_START + 249,
3348 EL_CUSTOM_START + 250,
3349 EL_CUSTOM_START + 251,
3351 EL_CUSTOM_START + 252,
3352 EL_CUSTOM_START + 253,
3353 EL_CUSTOM_START + 254,
3354 EL_CUSTOM_START + 255
3356 static int *editor_hl_custom_more_ptr = editor_hl_custom_more;
3357 static int *editor_el_custom_more_ptr = editor_el_custom_more;
3358 static int num_editor_hl_custom_more = SIZEOF_ARRAY_INT(editor_hl_custom_more);
3359 static int num_editor_el_custom_more = SIZEOF_ARRAY_INT(editor_el_custom_more);
3361 static int editor_hl_custom_special[] =
3365 static int editor_el_custom_special[] =
3372 static int *editor_hl_custom_special_ptr = editor_hl_custom_special;
3373 static int *editor_el_custom_special_ptr = editor_el_custom_special;
3374 static int num_editor_hl_custom_special = SIZEOF_ARRAY_INT(editor_hl_custom_special);
3375 static int num_editor_el_custom_special = SIZEOF_ARRAY_INT(editor_el_custom_special);
3377 static int editor_hl_group[] =
3400 static int editor_el_group[] =
3414 EL_GROUP_START + 10,
3415 EL_GROUP_START + 11,
3417 EL_GROUP_START + 12,
3418 EL_GROUP_START + 13,
3419 EL_GROUP_START + 14,
3422 static int *editor_hl_group_ptr = editor_hl_group;
3423 static int *editor_el_group_ptr = editor_el_group;
3424 static int num_editor_hl_group = SIZEOF_ARRAY_INT(editor_hl_group);
3425 static int num_editor_el_group = SIZEOF_ARRAY_INT(editor_el_group);
3427 static int editor_hl_group_more[] =
3431 static int editor_el_group_more[] =
3433 EL_GROUP_START + 16,
3434 EL_GROUP_START + 17,
3435 EL_GROUP_START + 18,
3436 EL_GROUP_START + 19,
3438 EL_GROUP_START + 20,
3439 EL_GROUP_START + 21,
3440 EL_GROUP_START + 22,
3441 EL_GROUP_START + 23,
3443 EL_GROUP_START + 24,
3444 EL_GROUP_START + 25,
3445 EL_GROUP_START + 26,
3446 EL_GROUP_START + 27,
3448 EL_GROUP_START + 28,
3449 EL_GROUP_START + 29,
3450 EL_GROUP_START + 30,
3453 static int *editor_hl_group_more_ptr = editor_hl_group_more;
3454 static int *editor_el_group_more_ptr = editor_el_group_more;
3455 static int num_editor_hl_group_more = SIZEOF_ARRAY_INT(editor_hl_group_more);
3456 static int num_editor_el_group_more = SIZEOF_ARRAY_INT(editor_el_group_more);
3458 static int editor_hl_user_defined[] =
3476 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
3477 static int *editor_el_user_defined_ptr = NULL;
3478 static int num_editor_hl_user_defined=SIZEOF_ARRAY_INT(editor_hl_user_defined);
3479 static int num_editor_el_user_defined = 0;
3481 static int editor_hl_empty[] = { };
3482 static int editor_el_empty[ED_NUM_ELEMENTLIST_BUTTONS];
3484 static int *editor_hl_empty_ptr = editor_hl_empty;
3485 static int *editor_el_empty_ptr = editor_el_empty;
3486 static int num_editor_hl_empty = 0;
3487 static int num_editor_el_empty = 0; /* dynamically determined, if needed */
3489 static boolean use_el_empty = FALSE;
3491 static int *editor_elements = NULL; /* dynamically allocated */
3492 static int num_editor_elements = 0; /* dynamically determined */
3496 boolean *setup_value;
3498 int **headline_list;
3499 int *headline_list_size;
3502 int *element_list_size;
3504 boolean last_setup_value;
3506 editor_elements_info[] =
3509 &setup.editor.el_boulderdash,
3510 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
3511 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
3514 &setup.editor.el_emerald_mine,
3515 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
3516 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
3519 &setup.editor.el_more,
3520 &editor_hl_more_ptr, &num_editor_hl_more,
3521 &editor_el_more_ptr, &num_editor_el_more
3524 &setup.editor.el_sokoban,
3525 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
3526 &editor_el_sokoban_ptr, &num_editor_el_sokoban
3529 &setup.editor.el_supaplex,
3530 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
3531 &editor_el_supaplex_ptr, &num_editor_el_supaplex
3534 &setup.editor.el_diamond_caves,
3535 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
3536 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
3539 &setup.editor.el_dx_boulderdash,
3540 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
3541 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
3544 &setup.editor.el_chars,
3545 &editor_hl_chars_ptr, &num_editor_hl_chars,
3546 &editor_el_chars_ptr, &num_editor_el_chars
3549 &setup.editor.el_custom,
3550 &editor_hl_custom_ptr, &num_editor_hl_custom,
3551 &editor_el_custom_ptr, &num_editor_el_custom
3554 &setup.editor.el_custom_more,
3555 &editor_hl_custom_more_ptr, &num_editor_hl_custom_more,
3556 &editor_el_custom_more_ptr, &num_editor_el_custom_more
3559 &setup.editor.el_custom,
3560 &editor_hl_custom_special_ptr, &num_editor_hl_custom_special,
3561 &editor_el_custom_special_ptr, &num_editor_el_custom_special
3564 &setup.editor.el_custom,
3565 &editor_hl_group_ptr, &num_editor_hl_group,
3566 &editor_el_group_ptr, &num_editor_el_group
3569 &setup.editor.el_custom_more,
3570 &editor_hl_group_more_ptr, &num_editor_hl_group_more,
3571 &editor_el_group_more_ptr, &num_editor_el_group_more
3574 &setup.editor.el_user_defined,
3575 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
3576 &editor_el_user_defined_ptr, &num_editor_el_user_defined
3580 &editor_hl_empty_ptr, &num_editor_hl_empty,
3581 &editor_el_empty_ptr, &num_editor_el_empty,
3595 short element_mapped;
3597 forum_sketch_element_mapping[] =
3599 { EL_WALL_SLIPPERY, EL_WALL },
3600 { EL_EXPANDABLE_WALL, EL_WALL },
3601 { EL_EXPANDABLE_WALL_HORIZONTAL, EL_WALL },
3602 { EL_EXPANDABLE_WALL_VERTICAL, EL_WALL },
3603 { EL_EXPANDABLE_WALL_ANY, EL_WALL },
3604 { EL_WALL_EMERALD, EL_WALL },
3605 { EL_WALL_DIAMOND, EL_WALL },
3606 { EL_WALL_BD_DIAMOND, EL_WALL },
3607 { EL_WALL_EMERALD_YELLOW, EL_WALL },
3608 { EL_WALL_EMERALD_RED, EL_WALL },
3609 { EL_WALL_EMERALD_PURPLE, EL_WALL },
3610 { EL_ACID_POOL_TOPLEFT, EL_WALL },
3611 { EL_ACID_POOL_TOPRIGHT, EL_WALL },
3612 { EL_ACID_POOL_BOTTOMLEFT, EL_WALL },
3613 { EL_ACID_POOL_BOTTOM, EL_WALL },
3614 { EL_ACID_POOL_BOTTOMRIGHT, EL_WALL },
3615 { EL_BD_WALL, EL_WALL },
3617 { EL_BD_ROCK, EL_ROCK },
3619 { EL_SP_ZONK, EL_ROCK },
3620 { EL_SP_BASE, EL_SAND },
3621 { EL_SP_MURPHY, EL_PLAYER_1 },
3622 { EL_SP_INFOTRON, EL_EMERALD },
3623 { EL_SP_HARDWARE_GRAY, EL_STEELWALL },
3624 { EL_SP_EXIT_CLOSED, EL_EXIT_OPEN },
3625 { EL_SP_DISK_ORANGE, EL_BOMB },
3626 { EL_SP_DISK_RED, EL_BOMB },
3627 { EL_SP_DISK_YELLOW, EL_BOMB },
3628 { EL_SP_PORT_RIGHT, EL_GATE_1_GRAY },
3629 { EL_SP_PORT_DOWN, EL_GATE_1_GRAY },
3630 { EL_SP_PORT_LEFT, EL_GATE_1_GRAY },
3631 { EL_SP_PORT_UP, EL_GATE_1_GRAY },
3632 { EL_SP_GRAVITY_PORT_RIGHT, EL_GATE_1_GRAY },
3633 { EL_SP_GRAVITY_PORT_DOWN, EL_GATE_1_GRAY },
3634 { EL_SP_GRAVITY_PORT_LEFT, EL_GATE_1_GRAY },
3635 { EL_SP_GRAVITY_PORT_UP, EL_GATE_1_GRAY },
3636 { EL_SP_PORT_VERTICAL, EL_GATE_1_GRAY },
3637 { EL_SP_PORT_HORIZONTAL, EL_GATE_1_GRAY },
3638 { EL_SP_PORT_ANY, EL_GATE_1_GRAY },
3639 { EL_SP_SNIKSNAK, EL_BUG },
3640 { EL_SP_ELECTRON, EL_SPACESHIP },
3641 { EL_SP_CHIP_SINGLE, EL_WALL },
3642 { EL_SP_CHIP_LEFT, EL_WALL },
3643 { EL_SP_CHIP_RIGHT, EL_WALL },
3644 { EL_SP_CHIP_TOP, EL_WALL },
3645 { EL_SP_CHIP_BOTTOM, EL_WALL },
3646 { EL_SP_HARDWARE_BASE_1, EL_STEELWALL },
3647 { EL_SP_HARDWARE_GREEN, EL_STEELWALL },
3648 { EL_SP_HARDWARE_BLUE, EL_STEELWALL },
3649 { EL_SP_HARDWARE_RED, EL_STEELWALL },
3650 { EL_SP_HARDWARE_YELLOW, EL_STEELWALL },
3651 { EL_SP_HARDWARE_BASE_2, EL_STEELWALL },
3652 { EL_SP_HARDWARE_BASE_3, EL_STEELWALL },
3653 { EL_SP_HARDWARE_BASE_3, EL_STEELWALL },
3654 { EL_SP_HARDWARE_BASE_4, EL_STEELWALL },
3655 { EL_SP_HARDWARE_BASE_5, EL_STEELWALL },
3656 { EL_SP_HARDWARE_BASE_6, EL_STEELWALL },
3658 { EL_STEELWALL_SLIPPERY, EL_STEELWALL },
3660 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
3662 { EL_DIAMOND, EL_EMERALD },
3663 { EL_BD_DIAMOND, EL_EMERALD },
3664 { EL_EMERALD_YELLOW, EL_EMERALD },
3665 { EL_EMERALD_RED, EL_EMERALD },
3666 { EL_EMERALD_PURPLE, EL_EMERALD },
3668 { EL_AMOEBA_DEAD, EL_AMOEBA },
3669 { EL_AMOEBA_DROP, EL_AMOEBA },
3670 { EL_AMOEBA_WET, EL_AMOEBA },
3671 { EL_AMOEBA_DRY, EL_AMOEBA },
3672 { EL_AMOEBA_FULL, EL_AMOEBA },
3673 { EL_BD_AMOEBA, EL_AMOEBA },
3674 { EL_AMOEBA_TO_DIAMOND, EL_AMOEBA },
3676 { EL_DYNAMITE_ACTIVE, EL_DYNAMITE },
3678 { EL_GATE_2_GRAY, EL_GATE_1_GRAY },
3679 { EL_GATE_3_GRAY, EL_GATE_1_GRAY },
3680 { EL_GATE_4_GRAY, EL_GATE_1_GRAY },
3682 { EL_EM_KEY_1, EL_KEY_1 },
3683 { EL_EM_KEY_2, EL_KEY_2 },
3684 { EL_EM_KEY_3, EL_KEY_3 },
3685 { EL_EM_KEY_4, EL_KEY_4 },
3687 { EL_EM_GATE_1, EL_GATE_1 },
3688 { EL_EM_GATE_2, EL_GATE_2 },
3689 { EL_EM_GATE_3, EL_GATE_3 },
3690 { EL_EM_GATE_4, EL_GATE_4 },
3692 { EL_EM_GATE_1_GRAY, EL_GATE_1_GRAY },
3693 { EL_EM_GATE_2_GRAY, EL_GATE_1_GRAY },
3694 { EL_EM_GATE_3_GRAY, EL_GATE_1_GRAY },
3695 { EL_EM_GATE_4_GRAY, EL_GATE_1_GRAY },
3697 { EL_INVISIBLE_SAND, EL_EMPTY },
3698 { EL_INVISIBLE_WALL, EL_EMPTY },
3699 { EL_INVISIBLE_STEELWALL, EL_EMPTY },
3701 { EL_PACMAN, EL_YAMYAM },
3702 { EL_DARK_YAMYAM, EL_YAMYAM },
3704 { EL_BD_MAGIC_WALL, EL_MAGIC_WALL },
3706 { EL_DYNABOMB_INCREASE_NUMBER, EL_BOMB },
3707 { EL_DYNABOMB_INCREASE_SIZE, EL_BOMB },
3708 { EL_DYNABOMB_INCREASE_POWER, EL_BOMB },
3709 { EL_BLACK_ORB, EL_BOMB },
3710 { EL_DX_SUPABOMB, EL_BOMB },
3712 { EL_SOKOBAN_OBJECT, EL_KEY_1 },
3713 { EL_SOKOBAN_FIELD_EMPTY, EL_GATE_1_GRAY },
3714 { EL_SOKOBAN_FIELD_FULL, EL_GATE_1 },
3715 { EL_SOKOBAN_FIELD_PLAYER, EL_PLAYER_1 },
3717 { EL_BD_BUTTERFLY_RIGHT, EL_BD_BUTTERFLY },
3718 { EL_BD_BUTTERFLY_UP, EL_BD_BUTTERFLY },
3719 { EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY },
3720 { EL_BD_BUTTERFLY_DOWN, EL_BD_BUTTERFLY },
3722 { EL_BD_FIREFLY_RIGHT, EL_BD_FIREFLY },
3723 { EL_BD_FIREFLY_UP, EL_BD_FIREFLY },
3724 { EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY },
3725 { EL_BD_FIREFLY_DOWN, EL_BD_FIREFLY },
3727 { EL_PLAYER_2, EL_PLAYER_1 },
3728 { EL_PLAYER_3, EL_PLAYER_1 },
3729 { EL_PLAYER_4, EL_PLAYER_1 },
3731 { EL_BUG_RIGHT, EL_BUG },
3732 { EL_BUG_UP, EL_BUG },
3733 { EL_BUG_LEFT, EL_BUG },
3734 { EL_BUG_DOWN, EL_BUG },
3736 { EL_SPACESHIP_RIGHT, EL_SPACESHIP },
3737 { EL_SPACESHIP_UP, EL_SPACESHIP },
3738 { EL_SPACESHIP_LEFT, EL_SPACESHIP },
3739 { EL_SPACESHIP_DOWN, EL_SPACESHIP },
3741 { EL_PACMAN_RIGHT, EL_YAMYAM },
3742 { EL_PACMAN_UP, EL_YAMYAM },
3743 { EL_PACMAN_LEFT, EL_YAMYAM },
3744 { EL_PACMAN_DOWN, EL_YAMYAM },
3752 char *element_string;
3754 forum_sketch_element_strings[] =
3756 { EL_PLAYER_1, "p" },
3760 { EL_EMERALD, "e" },
3762 { EL_SPACESHIP, "h" },
3763 { EL_BD_FIREFLY, "f" },
3764 { EL_BD_BUTTERFLY, "b" },
3768 { EL_STEELWALL, "t" },
3769 { EL_MAGIC_WALL, "m" },
3770 { EL_EXIT_OPEN, "x" },
3771 { EL_DYNAMITE, "d" },
3780 { EL_GATE_1_GRAY, "9" },
3783 { EL_ROBOT_WHEEL, "0" },
3785 { EL_CUSTOM_1, "c" },
3786 { EL_CHAR_QUESTION, "?" },
3795 -----------------------------------------------------------------------------
3797 -----------------------------------------------------------------------------
3800 static int getMaxInfoTextLength()
3802 return (SXSIZE / getFontWidth(FONT_TEXT_2));
3805 static int getTextWidthForGadget(char *text)
3810 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
3813 static int getTextWidthForDrawingArea(char *text)
3818 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
3821 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
3823 return (gi->x + gi->width + getTextWidthForGadget(text));
3826 static char *getElementInfoText(int element)
3828 char *info_text = NULL;
3830 if (element < NUM_FILE_ELEMENTS)
3832 if (strlen(element_info[element].description) > 0)
3833 info_text = element_info[element].description;
3834 else if (element_info[element].custom_description != NULL)
3835 info_text = element_info[element].custom_description;
3836 else if (element_info[element].editor_description != NULL)
3837 info_text = element_info[element].editor_description;
3840 if (info_text == NULL)
3841 info_text = INFOTEXT_UNKNOWN_ELEMENT;
3846 static void ReinitializeElementList()
3848 static boolean initialized = FALSE;
3852 checked_free(editor_elements);
3856 /* initialize optional user defined element list */
3857 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
3858 &num_editor_el_user_defined);
3860 /* initialize list of empty elements (used for padding, if needed) */
3861 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
3862 editor_el_empty[i] = EL_EMPTY;
3864 /* do some sanity checks for each element from element list */
3865 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
3867 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
3869 int element = (*editor_elements_info[i].element_list)[j];
3871 if (element >= NUM_FILE_ELEMENTS)
3872 Error(ERR_WARN, "editor element %d is runtime element", element);
3874 if (strcmp(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT) == 0)
3875 Error(ERR_WARN, "no element description for element %d", element);
3882 num_editor_elements = 0;
3883 use_el_empty = FALSE;
3885 /* determine size of element list */
3886 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
3888 if (*editor_elements_info[i].setup_value)
3890 if (setup.editor.el_headlines)
3891 num_editor_elements += *editor_elements_info[i].headline_list_size;
3893 num_editor_elements += *editor_elements_info[i].element_list_size;
3897 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
3899 /* offer at least as many elements as element buttons exist */
3900 use_el_empty = TRUE;
3901 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
3903 num_editor_elements += num_editor_el_empty;
3906 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
3908 /* fill element list */
3909 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
3911 if (*editor_elements_info[i].setup_value)
3913 if (setup.editor.el_headlines)
3914 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
3915 editor_elements[pos++] = (*editor_elements_info[i].headline_list)[j];
3917 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
3918 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
3922 /* correct position of element list scrollbar */
3923 if (element_shift < 0)
3925 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
3926 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
3929 void PrintEditorElementList()
3931 boolean *stop = &setup.editor.el_user_defined;
3934 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
3936 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
3938 int element = (*editor_elements_info[i].headline_list)[j];
3940 printf("# %s\n", element_info[element].token_name);
3946 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
3948 int element = (*editor_elements_info[i].element_list)[j];
3950 printf("# %s\n", element_info[element].token_name);
3958 static void ReinitializeElementListButtons()
3960 static boolean last_setup_value_headlines = FALSE;
3961 static boolean initialization_needed = TRUE;
3964 if (!initialization_needed) /* check if editor element setup has changed */
3966 if (last_setup_value_headlines != setup.editor.el_headlines)
3967 initialization_needed = TRUE;
3969 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
3970 if (editor_elements_info[i].last_setup_value !=
3971 *editor_elements_info[i].setup_value)
3972 initialization_needed = TRUE;
3975 if (!initialization_needed)
3978 FreeLevelEditorGadgets();
3979 CreateLevelEditorGadgets();
3981 /* store current setup values for next invocation of this function */
3982 last_setup_value_headlines = setup.editor.el_headlines;
3983 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
3984 editor_elements_info[i].last_setup_value =
3985 *editor_elements_info[i].setup_value;
3987 initialization_needed = FALSE;
3990 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
3993 int border_graphic =
3994 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
3997 int num_mini_tilex = width / MINI_TILEX + 1;
3998 int num_mini_tiley = height / MINI_TILEY + 1;
4001 getMiniGraphicSource(border_graphic, &src_bitmap, &src_x, &src_y);
4003 for (y = 0; y < num_mini_tiley; y++)
4004 for (x = 0; x < num_mini_tilex; x++)
4005 BlitBitmap(src_bitmap, drawto, src_x, src_y, MINI_TILEX, MINI_TILEY,
4006 dest_x - MINI_TILEX / 2 + x * MINI_TILEX,
4007 dest_y - MINI_TILEY / 2 + y * MINI_TILEY);
4009 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
4012 static void DrawDrawingArea(int id)
4014 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
4017 if (id == ED_DRAWING_ID_RANDOM_BACKGROUND)
4018 DrawMiniGraphicExt(drawto, gi->x, gi->y,
4019 el2edimg(random_placement_background_element));
4020 else if (id == ED_DRAWING_ID_AMOEBA_CONTENT)
4021 DrawMiniGraphicExt(drawto, gi->x, gi->y, el2edimg(level.amoeba_content));
4022 else if (id == ED_DRAWING_ID_CUSTOM_GRAPHIC)
4023 DrawMiniGraphicExt(drawto, gi->x, gi->y,
4024 el2edimg(custom_element.gfx_element));
4025 else if (id == ED_DRAWING_ID_CUSTOM_CONTENT)
4026 for (y = 0; y < 3; y++)
4027 for (x = 0; x < 3; x++)
4028 DrawMiniGraphicExt(drawto,
4029 gi->x + x * MINI_TILEX, gi->y + y * MINI_TILEY,
4030 el2edimg(custom_element.content[x][y]));
4031 else if (id == ED_DRAWING_ID_CUSTOM_MOVE_ENTER)
4032 DrawMiniGraphicExt(drawto, gi->x, gi->y,
4033 el2edimg(custom_element.move_enter_element));
4034 else if (id == ED_DRAWING_ID_CUSTOM_MOVE_LEAVE)
4035 DrawMiniGraphicExt(drawto, gi->x, gi->y,
4036 el2edimg(custom_element.move_leave_element));
4037 else if (id == ED_DRAWING_ID_CUSTOM_CHANGE_TARGET)
4038 DrawMiniGraphicExt(drawto, gi->x, gi->y,
4039 el2edimg(custom_element_change.target_element));
4040 else if (id == ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT)
4041 for (y = 0; y < 3; y++)
4042 for (x = 0; x < 3; x++)
4043 DrawMiniGraphicExt(drawto,
4044 gi->x + x * MINI_TILEX, gi->y + y * MINI_TILEY,
4045 el2edimg(custom_element_change.target_content[x][y]));
4046 else if (id == ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER)
4047 DrawMiniGraphicExt(drawto, gi->x, gi->y,
4048 el2edimg(custom_element_change.trigger_element));
4049 else if (id == ED_DRAWING_ID_GROUP_CONTENT)
4050 for (x = 0; x < group_element_info.num_elements; x++)
4051 DrawMiniGraphicExt(drawto, gi->x + x * MINI_TILEX, gi->y,
4052 el2edimg(group_element_info.element[x]));
4053 else if (id >= ED_DRAWING_ID_ELEMENT_CONTENT_0 &&
4054 id <= ED_DRAWING_ID_ELEMENT_CONTENT_7)
4056 int nr = id - ED_DRAWING_ID_ELEMENT_CONTENT_0;
4058 for (y = 0; y < 3; y++)
4059 for (x = 0; x < 3; x++)
4060 DrawMiniGraphicExt(drawto,
4061 gi->x + x * MINI_TILEX, gi->y + y * MINI_TILEY,
4062 el2edimg(level.yamyam_content[nr][x][y]));
4066 static void ScrollMiniLevel(int from_x, int from_y, int scroll)
4069 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
4070 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
4072 BlitBitmap(drawto, drawto,
4073 SX + (dx == -1 ? MINI_TILEX : 0),
4074 SY + (dy == -1 ? MINI_TILEY : 0),
4075 (ed_fieldx * MINI_TILEX) - (dx != 0 ? MINI_TILEX : 0),
4076 (ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0),
4077 SX + (dx == +1 ? MINI_TILEX : 0),
4078 SY + (dy == +1 ? MINI_TILEY : 0));
4081 x = (dx == 1 ? 0 : ed_fieldx - 1);
4082 for (y = 0; y < ed_fieldy; y++)
4083 DrawMiniElementOrWall(x, y, from_x, from_y);
4087 y = (dy == 1 ? 0 : ed_fieldy - 1);
4088 for (x = 0; x < ed_fieldx; x++)
4089 DrawMiniElementOrWall(x, y, from_x, from_y);
4092 redraw_mask |= REDRAW_FIELD;
4096 static void CreateControlButtons()
4098 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4099 struct GadgetInfo *gi;
4100 unsigned long event_mask;
4103 /* create toolbox buttons */
4104 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
4108 int gd_xoffset, gd_yoffset;
4109 int gd_x1, gd_x2, gd_y1, gd_y2;
4111 int radio_button_nr;
4114 if (id == GADGET_ID_SINGLE_ITEMS ||
4115 id == GADGET_ID_CONNECTED_ITEMS ||
4116 id == GADGET_ID_LINE ||
4117 id == GADGET_ID_ARC ||
4118 id == GADGET_ID_TEXT ||
4119 id == GADGET_ID_RECTANGLE ||
4120 id == GADGET_ID_FILLED_BOX ||
4121 id == GADGET_ID_FLOOD_FILL ||
4122 id == GADGET_ID_GRAB_BRUSH ||
4123 id == GADGET_ID_PICK_ELEMENT ||
4124 id == GADGET_ID_CUSTOM_COPY_FROM ||
4125 id == GADGET_ID_CUSTOM_COPY_TO ||
4126 id == GADGET_ID_CUSTOM_EXCHANGE)
4128 button_type = GD_TYPE_RADIO_BUTTON;
4129 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
4130 checked = (id == drawing_function ? TRUE : FALSE);
4131 event_mask = GD_EVENT_PRESSED;
4135 button_type = GD_TYPE_NORMAL_BUTTON;
4136 radio_button_nr = RADIO_NR_NONE;
4139 if (id == GADGET_ID_WRAP_LEFT ||
4140 id == GADGET_ID_WRAP_RIGHT ||
4141 id == GADGET_ID_WRAP_UP ||
4142 id == GADGET_ID_WRAP_DOWN)
4143 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
4145 event_mask = GD_EVENT_RELEASED;
4148 if (id < ED_NUM_CTRL1_BUTTONS)
4150 int x = i % ED_CTRL1_BUTTONS_HORIZ;
4151 int y = i / ED_CTRL1_BUTTONS_HORIZ;
4153 gd_xoffset = ED_CTRL1_BUTTONS_XPOS + x * ED_CTRL1_BUTTON_XSIZE;
4154 gd_yoffset = ED_CTRL1_BUTTONS_YPOS + y * ED_CTRL1_BUTTON_YSIZE;
4155 width = ED_CTRL1_BUTTON_XSIZE;
4156 height = ED_CTRL1_BUTTON_YSIZE;
4158 gd_x1 = DOOR_GFX_PAGEX8 + gd_xoffset;
4159 gd_x2 = DOOR_GFX_PAGEX7 + gd_xoffset;
4160 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL1_BUTTONS_GFX_YPOS + gd_yoffset;
4161 gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL1_BUTTONS_ALT_GFX_YPOS + gd_yoffset;
4163 else if (id < ED_NUM_CTRL1_2_BUTTONS)
4165 int x = (i - ED_NUM_CTRL1_BUTTONS) % ED_CTRL2_BUTTONS_HORIZ;
4166 int y = (i - ED_NUM_CTRL1_BUTTONS) / ED_CTRL2_BUTTONS_HORIZ;
4168 gd_xoffset = ED_CTRL2_BUTTONS_XPOS + x * ED_CTRL2_BUTTON_XSIZE;
4169 gd_yoffset = ED_CTRL2_BUTTONS_YPOS + y * ED_CTRL2_BUTTON_YSIZE;
4170 width = ED_CTRL2_BUTTON_XSIZE;
4171 height = ED_CTRL2_BUTTON_YSIZE;
4173 gd_x1 = DOOR_GFX_PAGEX8 + gd_xoffset;
4174 gd_x2 = DOOR_GFX_PAGEX7 + gd_xoffset;
4175 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL2_BUTTONS_GFX_YPOS + gd_yoffset;
4176 gd_y2 = 0; /* no alternative graphic for these buttons */
4178 else if (id < ED_NUM_CTRL1_3_BUTTONS)
4180 int x = (i - ED_NUM_CTRL1_2_BUTTONS) % ED_CTRL3_BUTTONS_HORIZ + 1;
4181 int y = (i - ED_NUM_CTRL1_2_BUTTONS) / ED_CTRL3_BUTTONS_HORIZ;
4183 gd_xoffset = ED_CTRL3_BUTTONS_XPOS + x * ED_CTRL3_BUTTON_XSIZE;
4184 gd_yoffset = ED_CTRL3_BUTTONS_YPOS + y * ED_CTRL3_BUTTON_YSIZE;
4185 width = ED_CTRL3_BUTTON_XSIZE;
4186 height = ED_CTRL3_BUTTON_YSIZE;
4188 gd_x1 = DOOR_GFX_PAGEX6 + gd_xoffset;
4189 gd_x2 = DOOR_GFX_PAGEX5 + gd_xoffset;
4190 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL3_BUTTONS_GFX_YPOS + gd_yoffset;
4191 gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL3_BUTTONS_ALT_GFX_YPOS + gd_yoffset;
4195 int x = (i - ED_NUM_CTRL1_3_BUTTONS) % ED_CTRL4_BUTTONS_HORIZ;
4196 int y = (i - ED_NUM_CTRL1_3_BUTTONS) / ED_CTRL4_BUTTONS_HORIZ + 3;
4198 gd_xoffset = ED_CTRL4_BUTTONS_XPOS + x * ED_CTRL4_BUTTON_XSIZE;
4199 gd_yoffset = ED_CTRL4_BUTTONS_YPOS + y * ED_CTRL4_BUTTON_YSIZE;
4200 width = ED_CTRL4_BUTTON_XSIZE;
4201 height = ED_CTRL4_BUTTON_YSIZE;
4203 gd_x1 = DOOR_GFX_PAGEX6 + ED_CTRL4_BUTTONS_GFX_XPOS + gd_xoffset;
4204 gd_x2 = DOOR_GFX_PAGEX5 + ED_CTRL4_BUTTONS_GFX_XPOS + gd_xoffset;
4205 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL4_BUTTONS_GFX_YPOS + gd_yoffset;
4206 gd_y2 = 0; /* no alternative graphic for these buttons */
4209 gi = CreateGadget(GDI_CUSTOM_ID, id,
4210 GDI_CUSTOM_TYPE_ID, i,
4211 GDI_INFO_TEXT, control_info[i].text,
4212 GDI_X, EX + gd_xoffset,
4213 GDI_Y, EY + gd_yoffset,
4216 GDI_TYPE, button_type,
4217 GDI_STATE, GD_BUTTON_UNPRESSED,
4218 GDI_RADIO_NR, radio_button_nr,
4219 GDI_CHECKED, checked,
4220 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
4221 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y1,
4222 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2,
4223 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
4224 GDI_EVENT_MASK, event_mask,
4225 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4226 GDI_CALLBACK_ACTION, HandleControlButtons,
4230 Error(ERR_EXIT, "cannot create gadget");
4232 level_editor_gadget[id] = gi;
4235 /* create buttons for scrolling of drawing area and element list */
4236 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
4238 int id = scrollbutton_info[i].gadget_id;
4239 int x, y, width, height;
4240 int gd_x1, gd_x2, gd_y1, gd_y2;
4242 x = scrollbutton_info[i].x;
4243 y = scrollbutton_info[i].y;
4245 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
4247 if (id == GADGET_ID_SCROLL_LIST_UP ||
4248 id == GADGET_ID_SCROLL_LIST_DOWN)
4252 width = ED_SCROLLBUTTON2_XSIZE;
4253 height = ED_SCROLLBUTTON2_YSIZE;
4254 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].gd_x;
4255 gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].gd_y;
4256 gd_x2 = gd_x1 - ED_SCROLLBUTTON2_XSIZE;
4263 width = ED_SCROLLBUTTON_XSIZE;
4264 height = ED_SCROLLBUTTON_YSIZE;
4265 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].gd_x;
4266 gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].gd_y;
4267 gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE;
4271 gi = CreateGadget(GDI_CUSTOM_ID, id,
4272 GDI_CUSTOM_TYPE_ID, i,
4273 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
4278 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
4279 GDI_STATE, GD_BUTTON_UNPRESSED,
4280 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
4281 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
4282 GDI_EVENT_MASK, event_mask,
4283 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4284 GDI_CALLBACK_ACTION, HandleControlButtons,
4288 Error(ERR_EXIT, "cannot create gadget");
4290 level_editor_gadget[id] = gi;
4293 /* create buttons for element list */
4294 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
4296 Bitmap *deco_bitmap;
4297 int deco_x, deco_y, deco_xpos, deco_ypos;
4298 int gd_xoffset, gd_yoffset;
4299 int gd_x1, gd_x2, gd_y;
4300 int x = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
4301 int y = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
4302 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
4303 int element = editor_elements[i];
4305 event_mask = GD_EVENT_RELEASED;
4307 gd_xoffset = ED_ELEMENTLIST_XPOS + x * ED_ELEMENTLIST_XSIZE;
4308 gd_yoffset = ED_ELEMENTLIST_YPOS + y * ED_ELEMENTLIST_YSIZE;
4310 gd_x1 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS + ED_ELEMENTLIST_XSIZE;
4311 gd_x2 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS;
4312 gd_y = DOOR_GFX_PAGEY1 + ED_ELEMENTLIST_YPOS;
4314 getMiniGraphicSource(el2edimg(element), &deco_bitmap, &deco_x, &deco_y);
4315 deco_xpos = (ED_ELEMENTLIST_XSIZE - MINI_TILEX) / 2;
4316 deco_ypos = (ED_ELEMENTLIST_YSIZE - MINI_TILEY) / 2;
4318 gi = CreateGadget(GDI_CUSTOM_ID, id,
4319 GDI_CUSTOM_TYPE_ID, i,
4320 GDI_INFO_TEXT, getElementInfoText(element),
4321 GDI_X, DX + gd_xoffset,
4322 GDI_Y, DY + gd_yoffset,
4323 GDI_WIDTH, ED_ELEMENTLIST_XSIZE,
4324 GDI_HEIGHT, ED_ELEMENTLIST_YSIZE,
4325 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
4326 GDI_STATE, GD_BUTTON_UNPRESSED,
4327 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
4328 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
4329 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
4330 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
4331 GDI_DECORATION_SIZE, MINI_TILEX, MINI_TILEY,
4332 GDI_DECORATION_SHIFTING, 1, 1,
4333 GDI_EVENT_MASK, event_mask,
4334 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4335 GDI_CALLBACK_ACTION, HandleControlButtons,
4339 Error(ERR_EXIT, "cannot create gadget");
4341 level_editor_gadget[id] = gi;
4345 static void CreateCounterButtons()
4347 int max_infotext_len = getMaxInfoTextLength();
4350 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
4353 int x = SX + counterbutton_info[i].x; /* down count button */
4354 int y = SY + counterbutton_info[i].y;
4356 /* determine horizontal position to the right of specified gadget */
4357 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
4358 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
4359 ED_GADGET_TEXT_DISTANCE);
4361 /* determine horizontal offset for leading text */
4362 if (counterbutton_info[i].text_left != NULL)
4363 x += getTextWidthForGadget(counterbutton_info[i].text_left);
4365 for (j = 0; j < 2; j++)
4367 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4368 struct GadgetInfo *gi;
4370 counterbutton_info[i].gadget_id_down :
4371 counterbutton_info[i].gadget_id_up);
4373 int gd_x, gd_x1, gd_x2, gd_y;
4375 unsigned long event_mask;
4376 char infotext[max_infotext_len + 1];
4378 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
4380 if (i == ED_COUNTER_ID_SELECT_LEVEL)
4383 ED_SCROLLBUTTON_ID_AREA_LEFT :
4384 ED_SCROLLBUTTON_ID_AREA_RIGHT);
4386 event_mask |= GD_EVENT_RELEASED;
4389 x += 2 * ED_GADGET_DISTANCE;
4390 y += ED_GADGET_DISTANCE;
4392 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[sid].gd_x;
4393 gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE;
4394 gd_y = DOOR_GFX_PAGEY1 + scrollbutton_info[sid].gd_y;
4395 x_size = ED_SCROLLBUTTON_XSIZE;
4396 y_size = ED_SCROLLBUTTON_YSIZE;
4400 gd_xoffset = (j == 0 ? ED_BUTTON_MINUS_XPOS : ED_BUTTON_PLUS_XPOS);
4401 gd_x1 = DOOR_GFX_PAGEX4 + gd_xoffset;
4402 gd_x2 = DOOR_GFX_PAGEX3 + gd_xoffset;
4403 gd_y = DOOR_GFX_PAGEY1 + ED_BUTTON_COUNT_YPOS;
4404 x_size = ED_BUTTON_COUNT_XSIZE;
4405 y_size = ED_BUTTON_COUNT_YSIZE;
4408 sprintf(infotext, "%s counter value by 1, 5 or 10",
4409 (j == 0 ? "decrease" : "increase"));
4411 gi = CreateGadget(GDI_CUSTOM_ID, id,
4412 GDI_CUSTOM_TYPE_ID, i,
4413 GDI_INFO_TEXT, infotext,
4418 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
4419 GDI_STATE, GD_BUTTON_UNPRESSED,
4420 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
4421 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
4422 GDI_EVENT_MASK, event_mask,
4423 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4424 GDI_CALLBACK_ACTION, HandleCounterButtons,
4428 Error(ERR_EXIT, "cannot create gadget");
4430 level_editor_gadget[id] = gi;
4431 right_gadget_border[id] =
4432 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
4434 x += gi->width + ED_GADGET_DISTANCE; /* text count button */
4438 int font_type = FONT_INPUT_1;
4439 int font_type_active = FONT_INPUT_1_ACTIVE;
4440 int gd_width = ED_WIN_COUNT_XSIZE;
4442 id = counterbutton_info[i].gadget_id_text;
4443 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
4445 if (i == ED_COUNTER_ID_SELECT_LEVEL)
4447 font_type = FONT_LEVEL_NUMBER;
4448 font_type_active = FONT_LEVEL_NUMBER;
4450 x += 2 * ED_GADGET_DISTANCE;
4451 y -= ED_GADGET_DISTANCE;
4453 gd_x = DOOR_GFX_PAGEX6 + ED_WIN_COUNT2_XPOS;
4454 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT2_YPOS;
4455 gd_width = ED_WIN_COUNT2_XSIZE;
4459 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
4460 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
4463 gi = CreateGadget(GDI_CUSTOM_ID, id,
4464 GDI_CUSTOM_TYPE_ID, i,
4465 GDI_INFO_TEXT, "enter counter value",
4468 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
4469 GDI_NUMBER_VALUE, 0,
4470 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
4471 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
4472 GDI_TEXT_SIZE, 3, /* minimal counter text size */
4473 GDI_TEXT_FONT, font_type,
4474 GDI_TEXT_FONT_ACTIVE, font_type_active,
4475 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
4476 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
4477 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
4478 GDI_DESIGN_WIDTH, gd_width,
4479 GDI_EVENT_MASK, event_mask,
4480 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4481 GDI_CALLBACK_ACTION, HandleCounterButtons,
4485 Error(ERR_EXIT, "cannot create gadget");
4487 level_editor_gadget[id] = gi;
4488 right_gadget_border[id] =
4489 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
4491 x += gi->width + ED_GADGET_DISTANCE; /* up count button */
4497 static void CreateDrawingAreas()
4501 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
4503 struct GadgetInfo *gi;
4504 unsigned long event_mask;
4505 int id = drawingarea_info[i].gadget_id;
4506 int x = SX + drawingarea_info[i].x;
4507 int y = SY + drawingarea_info[i].y;
4508 int area_xsize = drawingarea_info[i].area_xsize;
4509 int area_ysize = drawingarea_info[i].area_ysize;
4512 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
4513 GD_EVENT_OFF_BORDERS;
4515 /* determine horizontal position to the right of specified gadget */
4516 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
4517 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
4518 ED_DRAWINGAREA_TEXT_DISTANCE);
4520 /* determine horizontal offset for leading text */
4521 if (drawingarea_info[i].text_left != NULL)
4522 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
4524 gi = CreateGadget(GDI_CUSTOM_ID, id,
4525 GDI_CUSTOM_TYPE_ID, i,
4528 GDI_TYPE, GD_TYPE_DRAWING_AREA,
4529 GDI_AREA_SIZE, area_xsize, area_ysize,
4530 GDI_ITEM_SIZE, MINI_TILEX, MINI_TILEY,
4531 GDI_EVENT_MASK, event_mask,
4532 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
4533 GDI_CALLBACK_ACTION, HandleDrawingAreas,
4537 Error(ERR_EXIT, "cannot create gadget");
4539 level_editor_gadget[id] = gi;
4540 right_gadget_border[id] =
4541 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
4545 static void CreateTextInputGadgets()
4547 int max_infotext_len = getMaxInfoTextLength();
4550 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
4552 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4554 struct GadgetInfo *gi;
4555 unsigned long event_mask;
4556 char infotext[MAX_OUTPUT_LINESIZE + 1];
4557 int id = textinput_info[i].gadget_id;
4559 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
4561 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
4562 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
4564 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
4565 infotext[max_infotext_len] = '\0';
4567 gi = CreateGadget(GDI_CUSTOM_ID, id,
4568 GDI_CUSTOM_TYPE_ID, i,
4569 GDI_INFO_TEXT, infotext,
4570 GDI_X, SX + textinput_info[i].x,
4571 GDI_Y, SY + textinput_info[i].y,
4572 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
4573 GDI_TEXT_VALUE, textinput_info[i].value,
4574 GDI_TEXT_SIZE, textinput_info[i].size,
4575 GDI_TEXT_FONT, FONT_INPUT_1,
4576 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
4577 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
4578 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
4579 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
4580 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
4581 GDI_EVENT_MASK, event_mask,
4582 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4583 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
4587 Error(ERR_EXIT, "cannot create gadget");
4589 level_editor_gadget[id] = gi;
4593 static void CreateTextAreaGadgets()
4595 int max_infotext_len = getMaxInfoTextLength();
4598 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
4600 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4602 struct GadgetInfo *gi;
4603 unsigned long event_mask;
4604 char infotext[MAX_OUTPUT_LINESIZE + 1];
4605 int id = textarea_info[i].gadget_id;
4606 int area_xsize = textarea_info[i].xsize;
4607 int area_ysize = textarea_info[i].ysize;
4609 event_mask = GD_EVENT_TEXT_LEAVING;
4611 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
4612 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
4614 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
4615 infotext[max_infotext_len] = '\0';
4617 gi = CreateGadget(GDI_CUSTOM_ID, id,
4618 GDI_CUSTOM_TYPE_ID, i,
4619 GDI_INFO_TEXT, infotext,
4620 GDI_X, SX + textarea_info[i].x,
4621 GDI_Y, SY + textarea_info[i].y,
4622 GDI_TYPE, GD_TYPE_TEXT_AREA,
4623 GDI_AREA_SIZE, area_xsize, area_ysize,
4624 GDI_TEXT_FONT, FONT_INPUT_1,
4625 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
4626 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
4627 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
4628 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
4629 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
4630 GDI_EVENT_MASK, event_mask,
4631 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4632 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
4636 Error(ERR_EXIT, "cannot create gadget");
4638 level_editor_gadget[id] = gi;
4642 static void CreateSelectboxGadgets()
4644 int max_infotext_len = getMaxInfoTextLength();
4647 for (i = 0; i < ED_NUM_SELECTBOX; i++)
4649 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4651 struct GadgetInfo *gi;
4652 unsigned long event_mask;
4653 char infotext[MAX_OUTPUT_LINESIZE + 1];
4654 int id = selectbox_info[i].gadget_id;
4655 int x = SX + selectbox_info[i].x;
4656 int y = SY + selectbox_info[i].y;
4658 if (selectbox_info[i].size == -1) /* dynamically determine size */
4660 /* (we cannot use -1 for uninitialized values if we directly compare
4661 with results from strlen(), because the '<' and '>' operation will
4662 implicitely cast -1 to an unsigned integer value!) */
4663 selectbox_info[i].size = 0;
4665 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
4666 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
4667 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
4669 selectbox_info[i].size++; /* add one character empty space */
4672 event_mask = GD_EVENT_RELEASED |
4673 GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
4675 gd_x = DOOR_GFX_PAGEX4 + ED_SELECTBOX_XPOS;
4676 gd_y = DOOR_GFX_PAGEY1 + ED_SELECTBOX_YPOS;
4678 /* determine horizontal position to the right of specified gadget */
4679 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
4680 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
4681 ED_GADGET_TEXT_DISTANCE);
4683 /* determine horizontal offset for leading text */
4684 if (selectbox_info[i].text_left != NULL)
4685 x += getTextWidthForGadget(selectbox_info[i].text_left);
4687 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
4688 infotext[max_infotext_len] = '\0';
4690 gi = CreateGadget(GDI_CUSTOM_ID, id,
4691 GDI_CUSTOM_TYPE_ID, i,
4692 GDI_INFO_TEXT, infotext,
4695 GDI_TYPE, GD_TYPE_SELECTBOX,
4696 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
4697 GDI_TEXT_SIZE, selectbox_info[i].size,
4698 GDI_TEXT_FONT, FONT_INPUT_1,
4699 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
4700 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
4701 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
4702 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
4703 GDI_BORDER_SIZE_SELECTBUTTON, ED_SELECTBOX_BUTTON_XSIZE,
4704 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
4705 GDI_EVENT_MASK, event_mask,
4706 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4707 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
4711 Error(ERR_EXIT, "cannot create gadget");
4713 level_editor_gadget[id] = gi;
4714 right_gadget_border[id] =
4715 getRightGadgetBorder(gi, selectbox_info[i].text_right);
4719 static void CreateTextbuttonGadgets()
4721 int max_infotext_len = getMaxInfoTextLength();
4724 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
4726 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4727 int gd_x1, gd_x2, gd_y1, gd_y2;
4728 struct GadgetInfo *gi;
4729 unsigned long event_mask;
4730 char infotext[MAX_OUTPUT_LINESIZE + 1];
4731 int id = textbutton_info[i].gadget_id;
4732 int x = SX + textbutton_info[i].x;
4733 int y = SY + textbutton_info[i].y;
4735 if (textbutton_info[i].size == -1) /* dynamically determine size */
4736 textbutton_info[i].size = strlen(textbutton_info[i].text);
4738 event_mask = GD_EVENT_RELEASED;
4740 if (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE)
4742 gd_x1 = DOOR_GFX_PAGEX4 + ED_TEXTBUTTON_TAB_XPOS;
4743 gd_x2 = DOOR_GFX_PAGEX3 + ED_TEXTBUTTON_TAB_XPOS;
4744 gd_y1 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_TAB_YPOS;
4745 gd_y2 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_TAB_INACTIVE_YPOS;
4749 gd_x1 = DOOR_GFX_PAGEX4 + ED_TEXTBUTTON_XPOS;
4750 gd_x2 = DOOR_GFX_PAGEX3 + ED_TEXTBUTTON_XPOS;
4751 gd_y1 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_YPOS;
4752 gd_y2 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_INACTIVE_YPOS;
4755 sprintf(infotext, "%s", textbutton_info[i].infotext);
4756 infotext[max_infotext_len] = '\0';
4758 /* determine horizontal position to the right of specified gadget */
4759 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
4760 x = (right_gadget_border[textbutton_info[i].gadget_id_align] +
4761 ED_GADGET_TEXT_DISTANCE);
4763 /* determine horizontal offset for leading text */
4764 if (textbutton_info[i].text_left != NULL)
4765 x += getTextWidthForGadget(textbutton_info[i].text_left);
4767 gi = CreateGadget(GDI_CUSTOM_ID, id,
4768 GDI_CUSTOM_TYPE_ID, i,
4769 GDI_INFO_TEXT, infotext,
4772 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
4773 GDI_TEXT_VALUE, textbutton_info[i].text,
4774 GDI_TEXT_SIZE, textbutton_info[i].size,
4775 GDI_TEXT_FONT, FONT_INPUT_2_ACTIVE,
4776 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2,
4777 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
4778 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y1,
4779 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2,
4780 GDI_BORDER_SIZE, ED_BORDER_TEXT_XSIZE, ED_BORDER_SIZE,
4781 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
4782 GDI_DECORATION_SHIFTING, 1, 1,
4783 GDI_EVENT_MASK, event_mask,
4784 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4785 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
4789 Error(ERR_EXIT, "cannot create gadget");
4791 level_editor_gadget[id] = gi;
4792 right_gadget_border[id] =
4793 getRightGadgetBorder(gi, textbutton_info[i].text_right);
4797 static void CreateGraphicbuttonGadgets()
4799 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4800 struct GadgetInfo *gi;
4801 unsigned long event_mask;
4804 /* create buttons for scrolling of drawing area and element list */
4805 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
4807 int id = graphicbutton_info[i].gadget_id;
4808 int gd_x1, gd_x2, gd_y1, gd_y2;
4809 int x = SX + graphicbutton_info[i].x;
4810 int y = SY + graphicbutton_info[i].y;
4812 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
4814 if (i <= ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
4816 gd_x1 = DOOR_GFX_PAGEX4 + graphicbutton_info[i].gd_x;
4817 gd_y1 = DOOR_GFX_PAGEY1 + graphicbutton_info[i].gd_y;
4818 gd_x2 = DOOR_GFX_PAGEX3 + graphicbutton_info[i].gd_x;
4821 else /* (i <= ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE) */
4823 gd_x1 = DOOR_GFX_PAGEX6 + graphicbutton_info[i].gd_x;
4824 gd_y1 = DOOR_GFX_PAGEY1 + graphicbutton_info[i].gd_y;
4825 gd_x2 = gd_x1 - ED_BUTTON_COUNT_XSIZE;
4829 /* determine horizontal position to the right of specified gadget */
4830 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
4831 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
4832 ED_GADGET_TEXT_DISTANCE);
4834 /* determine horizontal offset for leading text */
4835 if (graphicbutton_info[i].text_left != NULL)
4836 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
4838 gi = CreateGadget(GDI_CUSTOM_ID, id,
4839 GDI_CUSTOM_TYPE_ID, i,
4840 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
4843 GDI_WIDTH, graphicbutton_info[i].width,
4844 GDI_HEIGHT, graphicbutton_info[i].height,
4845 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
4846 GDI_STATE, GD_BUTTON_UNPRESSED,
4847 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
4848 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
4849 GDI_EVENT_MASK, event_mask,
4850 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4851 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
4855 Error(ERR_EXIT, "cannot create gadget");
4857 level_editor_gadget[id] = gi;
4858 right_gadget_border[id] =
4859 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
4863 static void CreateScrollbarGadgets()
4867 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
4869 int id = scrollbar_info[i].gadget_id;
4870 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4871 int gd_x1, gd_x2, gd_y1, gd_y2;
4872 struct GadgetInfo *gi;
4873 int items_max, items_visible, item_position;
4874 unsigned long event_mask;
4876 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
4878 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
4879 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
4880 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
4882 else /* drawing area scrollbars */
4884 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
4886 items_max = MAX(lev_fieldx + 2, ed_fieldx);
4887 items_visible = ed_fieldx;
4892 items_max = MAX(lev_fieldy + 2, ed_fieldy);
4893 items_visible = ed_fieldy;
4898 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
4900 gd_x1 = DOOR_GFX_PAGEX8 + scrollbar_info[i].gd_x;
4901 gd_x2 = (gd_x1 - (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL ?
4902 scrollbar_info[i].height : scrollbar_info[i].width));
4903 gd_y1 = DOOR_GFX_PAGEY1 + scrollbar_info[i].gd_y;
4904 gd_y2 = DOOR_GFX_PAGEY1 + scrollbar_info[i].gd_y;
4906 gi = CreateGadget(GDI_CUSTOM_ID, id,
4907 GDI_CUSTOM_TYPE_ID, i,
4908 GDI_INFO_TEXT, scrollbar_info[i].infotext,
4909 GDI_X, scrollbar_info[i].x,
4910 GDI_Y, scrollbar_info[i].y,
4911 GDI_WIDTH, scrollbar_info[i].width,
4912 GDI_HEIGHT, scrollbar_info[i].height,
4913 GDI_TYPE, scrollbar_info[i].type,
4914 GDI_SCROLLBAR_ITEMS_MAX, items_max,
4915 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
4916 GDI_SCROLLBAR_ITEM_POSITION, item_position,
4917 GDI_STATE, GD_BUTTON_UNPRESSED,
4918 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
4919 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
4920 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
4921 GDI_EVENT_MASK, event_mask,
4922 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4923 GDI_CALLBACK_ACTION, HandleControlButtons,
4927 Error(ERR_EXIT, "cannot create gadget");
4929 level_editor_gadget[id] = gi;
4933 static void CreateCheckbuttonGadgets()
4935 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4936 struct GadgetInfo *gi;
4937 unsigned long event_mask;
4938 int gd_x1, gd_x2, gd_x3, gd_x4, gd_y;
4941 event_mask = GD_EVENT_PRESSED;
4943 gd_x1 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_UNCHECKED_XPOS;
4944 gd_x2 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_UNCHECKED_XPOS;
4945 gd_x3 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_CHECKED_XPOS;
4946 gd_x4 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_CHECKED_XPOS;
4947 gd_y = DOOR_GFX_PAGEY1 + ED_RADIOBUTTON_YPOS;
4949 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
4951 int id = checkbutton_info[i].gadget_id;
4952 int x = SX + checkbutton_info[i].x;
4953 int y = SY + checkbutton_info[i].y;
4955 if (id == GADGET_ID_STICK_ELEMENT)
4956 gd_y = DOOR_GFX_PAGEY1 + ED_STICKYBUTTON_YPOS;
4958 gd_y = DOOR_GFX_PAGEY1 + ED_CHECKBUTTON_YPOS;
4960 /* determine horizontal position to the right of specified gadget */
4961 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
4962 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
4963 ED_GADGET_TEXT_DISTANCE);
4965 /* determine horizontal offset for leading text */
4966 if (checkbutton_info[i].text_left != NULL)
4967 x += getTextWidthForGadget(checkbutton_info[i].text_left);
4969 gi = CreateGadget(GDI_CUSTOM_ID, id,
4970 GDI_CUSTOM_TYPE_ID, i,
4971 GDI_INFO_TEXT, checkbutton_info[i].infotext,
4974 GDI_WIDTH, ED_CHECKBUTTON_XSIZE,
4975 GDI_HEIGHT, ED_CHECKBUTTON_YSIZE,
4976 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
4977 GDI_CHECKED, *checkbutton_info[i].value,
4978 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
4979 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
4980 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y,
4981 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y,
4982 GDI_EVENT_MASK, event_mask,
4983 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
4984 GDI_CALLBACK_ACTION, HandleCheckbuttons,
4988 Error(ERR_EXIT, "cannot create gadget");
4990 level_editor_gadget[id] = gi;
4991 right_gadget_border[id] =
4992 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
4996 static void CreateRadiobuttonGadgets()
4998 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
4999 struct GadgetInfo *gi;
5000 unsigned long event_mask;
5001 int gd_x1, gd_x2, gd_x3, gd_x4, gd_y;
5004 event_mask = GD_EVENT_PRESSED;
5006 gd_x1 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_UNCHECKED_XPOS;
5007 gd_x2 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_UNCHECKED_XPOS;
5008 gd_x3 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_CHECKED_XPOS;
5009 gd_x4 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_CHECKED_XPOS;
5010 gd_y = DOOR_GFX_PAGEY1 + ED_RADIOBUTTON_YPOS;
5012 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
5014 int id = radiobutton_info[i].gadget_id;
5015 int x = SX + radiobutton_info[i].x;
5016 int y = SY + radiobutton_info[i].y;
5019 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
5021 /* determine horizontal position to the right of specified gadget */
5022 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
5023 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
5024 ED_GADGET_TEXT_DISTANCE);
5026 /* determine horizontal offset for leading text */
5027 if (radiobutton_info[i].text_left != NULL)
5028 x += getTextWidthForGadget(radiobutton_info[i].text_left);
5030 gi = CreateGadget(GDI_CUSTOM_ID, id,
5031 GDI_CUSTOM_TYPE_ID, i,
5032 GDI_INFO_TEXT, radiobutton_info[i].infotext,
5035 GDI_WIDTH, ED_CHECKBUTTON_XSIZE,
5036 GDI_HEIGHT, ED_CHECKBUTTON_YSIZE,
5037 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
5038 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
5039 GDI_CHECKED, checked,
5040 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
5041 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
5042 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y,
5043 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y,
5044 GDI_EVENT_MASK, event_mask,
5045 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5046 GDI_CALLBACK_ACTION, HandleRadiobuttons,
5050 Error(ERR_EXIT, "cannot create gadget");
5052 level_editor_gadget[id] = gi;
5053 right_gadget_border[id] =
5054 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
5058 void CreateLevelEditorGadgets()
5060 int old_game_status = game_status;
5062 /* setting 'game_status' is needed to get the right fonts for the editor */
5063 game_status = GAME_MODE_EDITOR;
5065 ReinitializeElementList();
5067 CreateControlButtons();
5068 CreateScrollbarGadgets();
5070 /* order of function calls is important because of cross-references */
5071 CreateCheckbuttonGadgets();
5072 CreateCounterButtons();
5073 CreateRadiobuttonGadgets();
5074 CreateTextInputGadgets();
5075 CreateTextAreaGadgets();
5076 CreateSelectboxGadgets();
5077 CreateGraphicbuttonGadgets();
5078 CreateTextbuttonGadgets();
5079 CreateDrawingAreas();
5081 game_status = old_game_status;
5084 void FreeLevelEditorGadgets()
5088 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
5089 FreeGadget(level_editor_gadget[i]);
5092 static void MapCounterButtons(int id)
5094 int gadget_id_down = counterbutton_info[id].gadget_id_down;
5095 int gadget_id_text = counterbutton_info[id].gadget_id_text;
5096 int gadget_id_up = counterbutton_info[id].gadget_id_up;
5097 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
5098 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
5099 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
5101 char infotext[MAX_OUTPUT_LINESIZE + 1];
5102 int max_infotext_len = getMaxInfoTextLength();
5103 int xoffset_left = 0;
5104 int yoffset_left = ED_BORDER_SIZE;
5105 int xoffset_right = getCounterGadgetWidth();
5106 int yoffset_right = ED_BORDER_SIZE;
5108 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
5109 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
5110 int yoffset_above = MINI_TILEX + ED_GADGET_DISTANCE;
5111 int yoffset = ED_BORDER_SIZE;
5112 int x_left = gi_down->x - xoffset_left;
5113 int x_right = gi_up->x + gi_up->width + xoffset_right;
5114 int y_above = gi_down->y - yoffset_above;
5116 int y; /* set after gadget position was modified */
5119 /* set position for "score" counter gadget */
5120 if (id == ED_COUNTER_ID_ELEMENT_SCORE)
5122 ModifyGadget(gi_down, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
5123 ModifyGadget(gi_text, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
5124 ModifyGadget(gi_up, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
5127 y = gi_up->y + yoffset;
5129 if (counterbutton_info[id].text_above)
5130 DrawText(x, y_above, counterbutton_info[id].text_above, FONT_TEXT_1);
5132 if (counterbutton_info[id].text_left)
5133 DrawText(x_left, y, counterbutton_info[id].text_left, FONT_TEXT_1);
5135 if (counterbutton_info[id].text_right)
5136 DrawText(x_right, y, counterbutton_info[id].text_right, FONT_TEXT_1);
5138 ModifyEditorCounter(id, *counterbutton_info[id].value);
5145 static void MapControlButtons()
5150 /* map toolbox buttons (excluding special CE toolbox buttons) */
5151 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
5152 MapGadget(level_editor_gadget[i]);
5154 /* map buttons to select elements */
5155 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
5156 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
5157 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
5158 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
5159 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
5161 /* map buttons to select level */
5162 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
5163 ModifyEditorCounterLimits(counter_id,
5164 leveldir_current->first_level,
5165 leveldir_current->last_level);
5166 MapCounterButtons(counter_id);
5169 static void MapDrawingArea(int id)
5171 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
5172 int area_xsize = gi->drawing.area_xsize;
5173 int area_ysize = gi->drawing.area_ysize;
5174 int xoffset_left= getTextWidthForDrawingArea(drawingarea_info[id].text_left);
5175 int xoffset_below= getTextWidth(drawingarea_info[id].text_below,FONT_TEXT_1);
5176 int x_left = gi->x - xoffset_left;
5177 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
5178 int x_below = gi->x + (gi->width - xoffset_below) / 2;
5179 int y_side = gi->y + (gi->height - getFontHeight(FONT_TEXT_1)) / 2;
5180 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
5182 if (drawingarea_info[id].text_left)
5183 DrawText(x_left, y_side, drawingarea_info[id].text_left, FONT_TEXT_1);
5185 if (drawingarea_info[id].text_right)
5186 DrawText(x_right, y_side, drawingarea_info[id].text_right, FONT_TEXT_1);
5188 if (drawingarea_info[id].text_below)
5189 DrawText(x_below, y_below, drawingarea_info[id].text_below, FONT_TEXT_1);
5191 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
5193 DrawElementBorder(gi->x, gi->y,
5194 area_xsize * MINI_TILEX, area_ysize * MINI_TILEY, TRUE);
5196 DrawDrawingArea(id);
5202 static void MapTextInputGadget(int id)
5204 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
5205 int xoffset_above = 0;
5206 int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
5207 int x_above = textinput_info[id].x + xoffset_above;
5208 int y_above = textinput_info[id].y + yoffset_above;
5210 if (textinput_info[id].text_above)
5211 DrawTextS(x_above, y_above, FONT_TEXT_1, textinput_info[id].text_above);
5213 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
5218 static void MapTextAreaGadget(int id)
5220 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
5221 int xoffset_above = 0;
5222 int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
5223 int x_above = textarea_info[id].x + xoffset_above;
5224 int y_above = textarea_info[id].y + yoffset_above;
5226 if (textarea_info[id].text_above)
5227 DrawTextS(x_above, y_above, FONT_TEXT_1, textarea_info[id].text_above);
5229 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
5234 static void MapSelectboxGadget(int id)
5236 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
5237 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
5238 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
5239 int yoffset = ED_BORDER_SIZE;
5240 int x_left = gi->x - xoffset_left;
5241 int x_right = gi->x + gi->width + xoffset_right;
5242 int y = gi->y + yoffset;
5244 if (selectbox_info[id].text_left)
5245 DrawText(x_left, y, selectbox_info[id].text_left, FONT_TEXT_1);
5247 if (selectbox_info[id].text_right)
5248 DrawText(x_right, y, selectbox_info[id].text_right, FONT_TEXT_1);
5250 ModifyEditorSelectbox(id, *selectbox_info[id].value);
5255 static void MapTextbuttonGadget(int id)
5257 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
5258 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
5259 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
5260 int yoffset = ED_BORDER_SIZE;
5261 int x_left = gi->x - xoffset_left;
5262 int x_right = gi->x + gi->width + xoffset_right;
5263 int y = gi->y + yoffset;
5265 /* only show button to delete change pages when more than minimum pages */
5266 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
5267 custom_element.num_change_pages == MIN_CHANGE_PAGES)
5270 if (textbutton_info[id].text_left)
5271 DrawText(x_left, y, textbutton_info[id].text_left, FONT_TEXT_1);
5273 if (textbutton_info[id].text_right)
5274 DrawText(x_right, y, textbutton_info[id].text_right, FONT_TEXT_1);
5279 static void MapGraphicbuttonGadget(int id)
5281 struct GadgetInfo *gi= level_editor_gadget[graphicbutton_info[id].gadget_id];
5282 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
5283 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
5284 int yoffset = ED_BORDER_SIZE;
5285 int x_left = gi->x - xoffset_left;
5286 int x_right = gi->x + gi->width + xoffset_right;
5287 int y = gi->y + yoffset;
5289 if (graphicbutton_info[id].text_left)
5290 DrawText(x_left, y, graphicbutton_info[id].text_left, FONT_TEXT_1);
5292 if (graphicbutton_info[id].text_right)
5293 DrawText(x_right, y, graphicbutton_info[id].text_right, FONT_TEXT_1);
5298 static void MapRadiobuttonGadget(int id)
5300 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
5301 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
5302 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
5303 int yoffset = ED_BORDER_SIZE;
5304 int x_left = gi->x - xoffset_left;
5305 int x_right = gi->x + gi->width + xoffset_right;
5306 int y = gi->y + yoffset;
5308 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
5310 if (radiobutton_info[id].text_left)
5311 DrawText(x_left, y, radiobutton_info[id].text_left, FONT_TEXT_1);
5313 if (radiobutton_info[id].text_right)
5314 DrawText(x_right, y, radiobutton_info[id].text_right, FONT_TEXT_1);
5316 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
5321 static void MapCheckbuttonGadget(int id)
5323 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
5324 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
5325 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
5326 int yoffset = ED_BORDER_SIZE;
5327 int x_left = gi->x - xoffset_left;
5328 int x_right = gi->x + gi->width + xoffset_right;
5329 int y; /* set after gadget position was modified */
5331 /* set position for gadgets with dynamically determined vertical position */
5332 ModifyGadget(gi, GDI_Y, SY + checkbutton_info[id].y, GDI_END);
5334 y = gi->y + yoffset;
5336 if (checkbutton_info[id].text_left)
5337 DrawText(x_left, y, checkbutton_info[id].text_left, FONT_TEXT_1);
5339 if (checkbutton_info[id].text_right)
5340 DrawText(x_right, y, checkbutton_info[id].text_right, FONT_TEXT_1);
5342 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
5347 static void MapMainDrawingArea()
5349 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
5350 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
5353 for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
5355 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
5356 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
5357 no_horizontal_scrollbar) ||
5358 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
5359 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
5360 no_vertical_scrollbar))
5363 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
5366 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
5368 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
5369 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
5372 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
5375 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
5378 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
5382 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
5384 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
5385 i == GADGET_ID_CUSTOM_COPY_TO ||
5386 i == GADGET_ID_CUSTOM_EXCHANGE ||
5387 i == GADGET_ID_CUSTOM_COPY ||
5388 i == GADGET_ID_CUSTOM_PASTE)
5391 MapGadget(level_editor_gadget[i]);
5393 UnmapGadget(level_editor_gadget[i]);
5398 static void MapLevelEditorToolboxCustomGadgets()
5400 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
5403 static void UnmapLevelEditorToolboxCustomGadgets()
5405 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
5408 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
5410 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5413 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
5415 if (i != GADGET_ID_SINGLE_ITEMS &&
5416 i != GADGET_ID_PROPERTIES &&
5417 i != GADGET_ID_PICK_ELEMENT)
5419 struct GadgetInfo *gi = level_editor_gadget[i];
5427 BlitBitmap(gd_bitmap, drawto,
5428 DOOR_GFX_PAGEX6 + ED_CTRL_NO_BUTTONS_GFX_XPOS,
5429 DOOR_GFX_PAGEY1 + ED_CTRL_NO_BUTTONS_GFX_YPOS,
5430 gi->width, gi->height, gi->x, gi->y);
5432 redraw_mask |= REDRAW_DOOR_3;
5438 static void MapLevelEditorToolboxDrawingGadgets()
5440 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
5443 static void UnmapLevelEditorToolboxDrawingGadgets()
5445 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
5448 static void UnmapDrawingArea(int id)
5450 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
5453 static void UnmapLevelEditorWindowGadgets()
5457 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
5458 if (level_editor_gadget[i]->x < SX + SXSIZE)
5459 UnmapGadget(level_editor_gadget[i]);
5462 void UnmapLevelEditorGadgets()
5466 for (i = 0; i < NUM_EDITOR_GADGETS; i++)
5467 UnmapGadget(level_editor_gadget[i]);
5470 static void ResetUndoBuffer()
5472 undo_buffer_position = -1;
5473 undo_buffer_steps = -1;
5474 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
5477 static void DrawEditModeWindow()
5479 ModifyEditorElementList();
5480 RedrawDrawingElements();
5482 if (edit_mode == ED_MODE_INFO)
5483 DrawLevelInfoWindow();
5484 else if (edit_mode == ED_MODE_PROPERTIES)
5485 DrawPropertiesWindow();
5486 else /* edit_mode == ED_MODE_DRAWING */
5487 DrawDrawingWindow();
5490 static boolean LevelChanged()
5492 boolean level_changed = FALSE;
5495 for (y = 0; y < lev_fieldy; y++)
5496 for (x = 0; x < lev_fieldx; x++)
5497 if (Feld[x][y] != level.field[x][y])
5498 level_changed = TRUE;
5500 return level_changed;
5503 static boolean LevelContainsPlayer()
5505 boolean player_found = FALSE;
5508 for (y = 0; y < lev_fieldy; y++)
5509 for (x = 0; x < lev_fieldx; x++)
5510 if (Feld[x][y] == EL_PLAYER_1 ||
5511 Feld[x][y] == EL_SP_MURPHY)
5512 player_found = TRUE;
5514 return player_found;
5517 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
5518 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
5522 for (x = 0; x < lev_fieldx; x++)
5523 for (y = 0; y < lev_fieldy; y++)
5524 dst[x][y] = src[x][y];
5527 static int setSelectboxValue(int selectbox_id, int new_value)
5529 int new_index_value = 0;
5532 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
5533 if (selectbox_info[selectbox_id].options[i].value == new_value)
5534 new_index_value = i;
5536 *selectbox_info[selectbox_id].value =
5537 selectbox_info[selectbox_id].options[new_index_value].value;
5539 return new_index_value;
5542 static void copy_custom_element_settings(int element_from, int element_to)
5545 struct ElementInfo ei_to_old = element_info[element_to];
5546 struct ElementInfo *ei_from = &element_info[element_from];
5547 struct ElementInfo *ei_to = &element_info[element_to];
5550 /* ---------- copy whole element structure ---------- */
5553 /* ---------- restore structure pointers which cannot be copied ---------- */
5554 ei_to->token_name = ei_to_old.token_name;
5555 ei_to->class_name = ei_to_old.class_name;
5556 ei_to->editor_description = ei_to_old.editor_description;
5557 ei_to->custom_description = ei_to_old.custom_description;
5558 ei_to->change_page = ei_to_old.change_page;
5559 ei_to->change = ei_to_old.change;
5560 ei_to->group = ei_to_old.group;
5562 /* ---------- copy element base properties ---------- */
5563 Properties[element_to][EP_BITFIELD_BASE] =
5564 Properties[element_from][EP_BITFIELD_BASE];
5566 /* ---------- reinitialize and copy change pages ---------- */
5567 setElementChangePages(ei_to, ei_to->num_change_pages);
5569 for (i=0; i < ei_to->num_change_pages; i++)
5570 ei_to->change_page[i] = ei_from->change_page[i];
5572 /* ---------- copy group element info ---------- */
5573 if (ei_from->group != NULL && ei_to->group != NULL) /* group or internal */
5574 *ei_to->group = *ei_from->group;
5578 struct ElementInfo *ei_from = &element_info[element_from];
5579 struct ElementInfo *ei_to = &element_info[element_to];
5582 /* ---------- copy element description ---------- */
5583 for (i = 0; i < MAX_ELEMENT_NAME_LEN + 1; i++)
5584 ei_to->description[i] = ei_from->description[i];
5586 /* ---------- copy element base properties ---------- */
5587 Properties[element_to][EP_BITFIELD_BASE] =
5588 Properties[element_from][EP_BITFIELD_BASE];
5590 /* ---------- copy custom property values ---------- */
5592 ei_to->use_gfx_element = ei_from->use_gfx_element;
5593 ei_to->gfx_element = ei_from->gfx_element;
5595 ei_to->access_direction = ei_from->access_direction;
5597 ei_to->collect_score = ei_from->collect_score;
5598 ei_to->collect_count = ei_from->collect_count;
5600 ei_to->push_delay_fixed = ei_from->push_delay_fixed;
5601 ei_to->push_delay_random = ei_from->push_delay_random;
5602 ei_to->drop_delay_fixed = ei_from->drop_delay_fixed;
5603 ei_to->drop_delay_random = ei_from->drop_delay_random;
5604 ei_to->move_delay_fixed = ei_from->move_delay_fixed;
5605 ei_to->move_delay_random = ei_from->move_delay_random;
5607 ei_to->move_pattern = ei_from->move_pattern;
5608 ei_to->move_direction_initial = ei_from->move_direction_initial;
5609 ei_to->move_stepsize = ei_from->move_stepsize;
5611 ei_to->move_enter_element = ei_from->move_enter_element;
5612 ei_to->move_leave_element = ei_from->move_leave_element;
5613 ei_to->move_leave_type = ei_from->move_leave_type;
5615 ei_to->slippery_type = ei_from->slippery_type;
5617 for (y = 0; y < 3; y++)
5618 for (x = 0; x < 3; x++)
5619 ei_to->content[x][y] = ei_from->content[x][y];
5621 ei_to->explosion_delay = ei_from->explosion_delay;
5622 ei_to->ignition_delay = ei_from->ignition_delay;
5624 /* ---------- reinitialize and copy change pages ---------- */
5626 ei_to->num_change_pages = ei_from->num_change_pages;
5627 ei_to->current_change_page = ei_from->current_change_page;
5629 setElementChangePages(ei_to, ei_to->num_change_pages);
5631 for (i=0; i < ei_to->num_change_pages; i++)
5632 ei_to->change_page[i] = ei_from->change_page[i];
5634 /* ---------- copy group element info ---------- */
5635 if (ei_from->group != NULL && ei_to->group != NULL) /* group or internal */
5636 *ei_to->group = *ei_from->group;
5640 /* mark this custom element as modified */
5641 ei_to->modified_settings = TRUE;
5644 static void replace_custom_element_in_settings(int element_from,
5649 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5651 struct ElementInfo *ei = &element_info[i];
5653 for (y = 0; y < 3; y++)
5654 for (x = 0; x < 3; x++)
5655 if (ei->content[x][y] == element_from)
5656 ei->content[x][y] = element_to;
5658 for (j = 0; j < ei->num_change_pages; j++)
5660 struct ElementChangeInfo *change = &ei->change_page[j];
5662 if (change->target_element == element_from)
5663 change->target_element = element_to;
5665 if (change->trigger_element == element_from)
5666 change->trigger_element = element_to;
5668 for (y = 0; y < 3; y++)
5669 for (x = 0; x < 3; x++)
5670 if (change->target_content[x][y] == element_from)
5671 change->target_content[x][y] = element_to;
5674 if (ei->group != NULL) /* group or internal */
5675 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
5676 if (ei->group->element[j] == element_from)
5677 ei->group->element[j] = element_to;
5681 static void replace_custom_element_in_playfield(int element_from,
5686 for (x = 0; x < lev_fieldx; x++)
5687 for (y = 0; y < lev_fieldy; y++)
5688 if (Feld[x][y] == element_from)
5689 Feld[x][y] = element_to;
5692 static boolean CopyCustomElement(int element_old, int element_new,
5695 if (copy_mode == GADGET_ID_CUSTOM_COPY)
5697 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
5698 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
5699 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
5701 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
5703 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
5704 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
5705 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
5707 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
5709 Request("Please choose custom element !", REQ_CONFIRM);
5713 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
5715 Request("Please choose group element !", REQ_CONFIRM);
5720 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
5722 copy_custom_element_settings(element_new, element_old);
5724 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
5726 copy_custom_element_settings(element_old, element_new);
5728 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
5730 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
5731 copy_custom_element_settings(element_new, element_old);
5732 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
5734 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
5735 replace_custom_element_in_settings(element_new, element_old);
5736 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
5738 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
5739 replace_custom_element_in_playfield(element_new, element_old);
5740 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
5743 UpdateCustomElementGraphicGadgets();
5744 DrawPropertiesWindow();
5749 static void CopyCustomElementPropertiesToEditor(int element)
5752 int current_change_page = element_info[element].current_change_page;
5754 /* dynamically (re)build selectbox for selecting change page */
5755 for (i = 0; i < element_info[element].num_change_pages; i++)
5757 sprintf(options_change_page_strings[i], "%d", i + 1);
5759 options_change_page[i].value = i;
5760 options_change_page[i].text = options_change_page_strings[i];
5763 options_change_page[i].value = -1;
5764 options_change_page[i].text = NULL;
5766 /* needed here to initialize combined element properties */
5767 InitElementPropertiesEngine(level.game_version);
5769 element_info[element].change =
5770 &element_info[element].change_page[current_change_page];
5772 custom_element = element_info[element];
5773 custom_element_change = *element_info[element].change;
5775 /* needed to initially set selectbox value variables to reliable defaults */
5776 for (i = 0; i < ED_NUM_SELECTBOX; i++)
5777 setSelectboxValue(i, *selectbox_info[i].value);
5779 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
5780 custom_element_properties[i] = HAS_PROPERTY(element, i);
5782 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
5783 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
5785 /* ---------- element settings: configure (custom elements) ------------- */
5787 /* set accessible layer selectbox help value */
5788 custom_element.access_type =
5789 (IS_WALKABLE(element) ? EP_WALKABLE :
5790 IS_PASSABLE(element) ? EP_PASSABLE :
5791 custom_element.access_type);
5792 custom_element.access_layer =
5793 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
5794 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
5795 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
5796 custom_element.access_layer);
5797 custom_element.access_protected =
5798 (IS_PROTECTED(element) ? 1 : 0);
5799 custom_element_properties[EP_ACCESSIBLE] =
5800 (IS_ACCESSIBLE_OVER(element) ||
5801 IS_ACCESSIBLE_INSIDE(element) ||
5802 IS_ACCESSIBLE_UNDER(element));
5804 /* set walk-to-object action selectbox help value */
5805 custom_element.walk_to_action =
5806 (IS_DIGGABLE(element) ? EP_DIGGABLE :
5807 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
5808 IS_DROPPABLE(element) ? EP_DROPPABLE :
5809 IS_PUSHABLE(element) ? EP_PUSHABLE :
5810 custom_element.walk_to_action);
5811 custom_element_properties[EP_WALK_TO_OBJECT] =
5812 (IS_DIGGABLE(element) ||
5813 IS_COLLECTIBLE_ONLY(element) ||
5814 IS_DROPPABLE(element) ||
5815 IS_PUSHABLE(element));
5817 /* set smash targets selectbox help value */
5818 custom_element.smash_targets =
5819 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
5820 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
5821 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
5822 custom_element.smash_targets);
5823 custom_element_properties[EP_CAN_SMASH] =
5824 (CAN_SMASH_EVERYTHING(element) ||
5825 CAN_SMASH_ENEMIES(element) ||
5826 CAN_SMASH_PLAYER(element));
5828 /* set deadliness selectbox help value */
5829 custom_element.deadliness =
5830 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
5831 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
5832 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
5833 custom_element.deadliness);
5834 custom_element_properties[EP_DEADLY] =
5835 (DONT_TOUCH(element) ||
5836 DONT_COLLIDE_WITH(element) ||
5837 DONT_RUN_INTO(element));
5839 /* set consistency selectbox help value */
5840 custom_element.consistency =
5841 (IS_INDESTRUCTIBLE(element) ? EP_INDESTRUCTIBLE :
5842 CAN_EXPLODE_1X1(element) ? EP_CAN_EXPLODE_1X1 :
5843 CAN_EXPLODE_3X3(element) ? EP_CAN_EXPLODE_3X3 :
5844 CAN_EXPLODE_CROSS(element) ? EP_CAN_EXPLODE_CROSS :
5845 custom_element.consistency);
5846 custom_element_properties[EP_EXPLODE_RESULT] =
5847 (IS_INDESTRUCTIBLE(element) ||
5848 CAN_EXPLODE_1X1(element) ||
5849 CAN_EXPLODE_3X3(element) ||
5850 CAN_EXPLODE_CROSS(element));
5852 /* special case: sub-settings dependent from main setting */
5853 if (CAN_EXPLODE_BY_FIRE(element))
5854 custom_element.can_explode_by_fire = TRUE;
5855 if (CAN_EXPLODE_SMASHED(element))
5856 custom_element.can_explode_smashed = TRUE;
5857 if (CAN_EXPLODE_IMPACT(element))
5858 custom_element.can_explode_impact = TRUE;
5860 /* ---------- element settings: advanced (custom elements) --------------- */
5862 /* set "change by direct action" selectbox help value */
5863 custom_element_change.direct_action =
5864 (HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
5865 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
5866 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
5867 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
5868 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
5869 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
5870 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
5871 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
5872 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
5873 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
5874 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
5875 custom_element_change.direct_action);
5877 /* set "change by other element action" selectbox help value */
5878 custom_element_change.other_action =
5879 (HAS_CHANGE_EVENT(element, CE_OTHER_GETS_TOUCHED) ? CE_OTHER_GETS_TOUCHED :
5880 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_PRESSED) ? CE_OTHER_GETS_PRESSED :
5881 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_PUSHED) ? CE_OTHER_GETS_PUSHED :
5882 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_ENTERED) ? CE_OTHER_GETS_ENTERED :
5883 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_LEFT) ? CE_OTHER_GETS_LEFT :
5884 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_DIGGED) ? CE_OTHER_GETS_DIGGED :
5885 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_COLLECTED) ? CE_OTHER_GETS_COLLECTED :
5886 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_DROPPED) ? CE_OTHER_GETS_DROPPED :
5887 HAS_CHANGE_EVENT(element, CE_OTHER_IS_TOUCHING) ? CE_OTHER_IS_TOUCHING :
5888 HAS_CHANGE_EVENT(element, CE_OTHER_IS_HITTING) ? CE_OTHER_IS_HITTING :
5889 HAS_CHANGE_EVENT(element, CE_OTHER_GETS_HIT) ? CE_OTHER_GETS_HIT :
5890 HAS_CHANGE_EVENT(element, CE_OTHER_IS_SWITCHING) ? CE_OTHER_IS_SWITCHING :
5891 HAS_CHANGE_EVENT(element, CE_OTHER_IS_CHANGING) ? CE_OTHER_IS_CHANGING :
5892 HAS_CHANGE_EVENT(element, CE_OTHER_IS_EXPLODING) ? CE_OTHER_IS_EXPLODING :
5893 custom_element_change.other_action);
5896 static void CopyGroupElementPropertiesToEditor(int element)
5898 group_element_info = *element_info[element].group;
5899 custom_element = element_info[element]; /* needed for description */
5902 static void CopyClassicElementPropertiesToEditor(int element)
5905 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
5906 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
5907 getMoveIntoAcidProperty(&level, element);
5909 if (MAYBE_DONT_COLLIDE_WITH(element))
5910 custom_element_properties[EP_DONT_COLLIDE_WITH] =
5911 getDontCollideWithProperty(&level, element);
5914 if (COULD_MOVE_INTO_ACID(element))
5916 int bit_nr = get_special_property_bit(element, EP_CAN_MOVE_INTO_ACID);
5919 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
5920 ((level.can_move_into_acid_bits & (1 << bit_nr)) != 0);
5925 static void CopyElementPropertiesToEditor(int element)
5927 if (IS_CUSTOM_ELEMENT(element))
5928 CopyCustomElementPropertiesToEditor(element);
5929 else if (IS_GROUP_ELEMENT(element))
5930 CopyGroupElementPropertiesToEditor(element);
5932 CopyClassicElementPropertiesToEditor(element);
5935 static void CopyCustomElementPropertiesToGame(int element)
5938 int access_type_and_layer;
5940 /* mark that this custom element has been modified */
5941 custom_element.modified_settings = TRUE;
5943 if (level.use_custom_template)
5945 if (Request("Copy and modify level template ?", REQ_ASK))
5947 level.use_custom_template = FALSE;
5948 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE],
5949 GDI_CHECKED, FALSE, GDI_END);
5953 LoadLevelTemplate(-1); /* this resets all element modifications ... */
5955 DrawEditModeWindow(); /* ... and copies them to 'custom_element' */
5959 element_info[element] = custom_element;
5960 *element_info[element].change = custom_element_change;
5962 /* ---------- element settings: configure (custom elements) ------------- */
5964 /* set accessible property from checkbox and selectbox */
5965 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
5966 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
5967 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
5968 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
5969 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
5970 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
5971 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
5972 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
5973 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
5974 custom_element_properties[access_type_and_layer] =
5975 custom_element_properties[EP_ACCESSIBLE];
5976 custom_element_properties[EP_PROTECTED] =
5977 (custom_element.access_protected != 0 &&
5978 custom_element_properties[EP_ACCESSIBLE]);
5980 /* set walk-to-object property from checkbox and selectbox */
5981 custom_element_properties[EP_DIGGABLE] = FALSE;
5982 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
5983 custom_element_properties[EP_DROPPABLE] = FALSE;
5984 custom_element_properties[EP_PUSHABLE] = FALSE;
5985 custom_element_properties[custom_element.walk_to_action] =
5986 custom_element_properties[EP_WALK_TO_OBJECT];
5988 /* set smash property from checkbox and selectbox */
5989 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
5990 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
5991 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
5992 custom_element_properties[custom_element.smash_targets] =
5993 custom_element_properties[EP_CAN_SMASH];
5995 /* set deadliness property from checkbox and selectbox */
5996 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
5997 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
5998 custom_element_properties[EP_DONT_TOUCH] = FALSE;
5999 custom_element_properties[custom_element.deadliness] =
6000 custom_element_properties[EP_DEADLY];
6002 /* set consistency property from checkbox and selectbox */
6003 custom_element_properties[EP_INDESTRUCTIBLE] = FALSE;
6004 custom_element_properties[EP_CAN_EXPLODE_1X1] = FALSE;
6005 custom_element_properties[EP_CAN_EXPLODE_3X3] = FALSE;
6006 custom_element_properties[EP_CAN_EXPLODE_CROSS] = FALSE;
6007 custom_element_properties[EP_CAN_EXPLODE_BY_FIRE] = FALSE;
6008 custom_element_properties[EP_CAN_EXPLODE_SMASHED] = FALSE;
6009 custom_element_properties[EP_CAN_EXPLODE_IMPACT] = FALSE;
6010 custom_element_properties[custom_element.consistency] =
6011 custom_element_properties[EP_EXPLODE_RESULT];
6013 /* special case: sub-settings dependent from main setting */
6014 if (custom_element_properties[EP_CAN_EXPLODE_1X1] ||
6015 custom_element_properties[EP_CAN_EXPLODE_3X3] ||
6016 custom_element_properties[EP_CAN_EXPLODE_CROSS])
6018 custom_element_properties[EP_CAN_EXPLODE_BY_FIRE] =
6019 custom_element.can_explode_by_fire;
6020 custom_element_properties[EP_CAN_EXPLODE_SMASHED] =
6021 custom_element.can_explode_smashed;
6022 custom_element_properties[EP_CAN_EXPLODE_IMPACT] =
6023 custom_element.can_explode_impact;
6026 /* ---------- element settings: advanced (custom elements) --------------- */
6028 /* set player change event from checkbox and selectbox */
6029 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
6030 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
6031 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
6032 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
6033 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
6034 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
6035 custom_element_change_events[CE_SWITCHED] = FALSE;
6036 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
6037 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
6038 custom_element_change_events[CE_IMPACT] = FALSE;
6039 custom_element_change_events[CE_SMASHED] = FALSE;
6040 custom_element_change_events[custom_element_change.direct_action] =
6041 custom_element_change_events[CE_BY_DIRECT_ACTION];
6043 /* set other element action change event from checkbox and selectbox */
6044 custom_element_change_events[CE_OTHER_GETS_TOUCHED] = FALSE;
6045 custom_element_change_events[CE_OTHER_GETS_PRESSED] = FALSE;
6046 custom_element_change_events[CE_OTHER_GETS_PUSHED] = FALSE;
6047 custom_element_change_events[CE_OTHER_GETS_ENTERED] = FALSE;
6048 custom_element_change_events[CE_OTHER_GETS_LEFT] = FALSE;
6049 custom_element_change_events[CE_OTHER_GETS_DIGGED] = FALSE;
6050 custom_element_change_events[CE_OTHER_GETS_COLLECTED] = FALSE;
6051 custom_element_change_events[CE_OTHER_GETS_DROPPED] = FALSE;
6052 custom_element_change_events[CE_OTHER_IS_TOUCHING] = FALSE;
6053 custom_element_change_events[CE_OTHER_IS_HITTING] = FALSE;
6054 custom_element_change_events[CE_OTHER_GETS_HIT] = FALSE;
6055 custom_element_change_events[CE_OTHER_IS_SWITCHING] = FALSE;
6056 custom_element_change_events[CE_OTHER_IS_CHANGING] = FALSE;
6057 custom_element_change_events[CE_OTHER_IS_EXPLODING] = FALSE;
6058 custom_element_change_events[custom_element_change.other_action] =
6059 custom_element_change_events[CE_BY_OTHER_ACTION];
6061 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
6062 SET_PROPERTY(element, i, custom_element_properties[i]);
6064 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
6065 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
6067 /* copy change events also to special level editor variable */
6068 custom_element = element_info[element];
6069 custom_element_change = *element_info[element].change;
6072 static void CopyGroupElementPropertiesToGame(int element)
6074 element_info[element] = custom_element;
6075 *element_info[element].group = group_element_info;
6077 /* mark that this group element has been modified */
6078 element_info[element].modified_settings = TRUE;
6081 static void CopyClassicElementPropertiesToGame(int element)
6084 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
6085 setMoveIntoAcidProperty(&level, element,
6086 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
6088 if (MAYBE_DONT_COLLIDE_WITH(element))
6089 setDontCollideWithProperty(&level, element,
6090 custom_element_properties[EP_DONT_COLLIDE_WITH]);
6093 if (COULD_MOVE_INTO_ACID(element))
6095 int bit_nr = get_special_property_bit(element, EP_CAN_MOVE_INTO_ACID);
6099 level.can_move_into_acid_bits &= ~(1 << bit_nr);
6101 if (custom_element_properties[EP_CAN_MOVE_INTO_ACID])
6102 level.can_move_into_acid_bits |= (1 << bit_nr);
6108 static void CopyElementPropertiesToGame(int element)
6110 if (IS_CUSTOM_ELEMENT(element))
6111 CopyCustomElementPropertiesToGame(element);
6112 else if (IS_GROUP_ELEMENT(element))
6113 CopyGroupElementPropertiesToGame(element);
6115 CopyClassicElementPropertiesToGame(element);
6120 CloseDoor(DOOR_CLOSE_ALL);
6121 OpenDoor(DOOR_OPEN_2 | DOOR_NO_DELAY);
6123 if (level_editor_test_game)
6125 CopyPlayfield(level.field, Feld);
6126 CopyPlayfield(FieldBackup, level.field);
6128 level_editor_test_game = FALSE;
6132 edit_mode = ED_MODE_DRAWING;
6133 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
6141 /* copy default editor door content to main double buffer */
6142 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
6143 DOOR_GFX_PAGEX6, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
6146 /* draw mouse button brush elements */
6147 RedrawDrawingElements();
6150 /* draw bigger door */
6151 DrawSpecialEditorDoor();
6153 /* draw new control window */
6154 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
6155 DOOR_GFX_PAGEX8, 236, EXSIZE, EYSIZE, EX, EY);
6157 redraw_mask |= REDRAW_ALL;
6159 ReinitializeElementListButtons(); /* only needed after setup changes */
6161 ModifyEditorElementList(); /* may be needed for custom elements */
6165 MapControlButtons();
6167 DrawEditModeWindow();
6169 /* copy actual editor door content to door double buffer for OpenDoor() */
6170 BlitBitmap(drawto, bitmap_db_door,
6171 DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
6173 OpenDoor(DOOR_OPEN_1);
6176 static void AdjustDrawingAreaGadgets()
6178 int ed_xsize = lev_fieldx + 2;
6179 int ed_ysize = lev_fieldy + 2;
6180 int max_ed_fieldx = MAX_ED_FIELDX;
6181 int max_ed_fieldy = MAX_ED_FIELDY;
6182 boolean horizontal_scrollbar_needed;
6183 boolean vertical_scrollbar_needed;
6184 int x, y, width, height;
6185 int xoffset, yoffset;
6187 /* check if we need any scrollbars */
6188 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
6189 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
6191 /* check if we have a smaller editor field because of scrollbars */
6192 if (horizontal_scrollbar_needed)
6193 max_ed_fieldy = MAX_ED_FIELDY - 1;
6194 if (vertical_scrollbar_needed)
6195 max_ed_fieldx = MAX_ED_FIELDX - 1;
6197 /* check again if we now need more scrollbars because of less space */
6198 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
6199 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
6201 /* check if editor field gets even smaller after adding new scrollbars */
6202 if (horizontal_scrollbar_needed)
6203 max_ed_fieldy = MAX_ED_FIELDY - 1;
6204 if (vertical_scrollbar_needed)
6205 max_ed_fieldx = MAX_ED_FIELDX - 1;
6207 ed_fieldx = (ed_xsize < MAX_ED_FIELDX ? ed_xsize : max_ed_fieldx);
6208 ed_fieldy = (ed_ysize < MAX_ED_FIELDY ? ed_ysize : max_ed_fieldy);
6210 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
6211 GDI_WIDTH, ed_fieldx * MINI_TILEX,
6212 GDI_HEIGHT, ed_fieldy * MINI_TILEY,
6213 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
6216 xoffset = (ed_fieldx == MAX_ED_FIELDX ? ED_SCROLLBUTTON_XSIZE : 0);
6217 yoffset = (ed_fieldy == MAX_ED_FIELDY ? ED_SCROLLBUTTON_YSIZE : 0);
6219 x = SX + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_RIGHT].x + xoffset;
6220 y = SX + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_DOWN].y + yoffset;
6222 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT], GDI_X, x, GDI_END);
6223 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN], GDI_Y, y, GDI_END);
6225 width = scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width + xoffset;
6226 height = scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].height + yoffset;
6228 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
6230 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
6232 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
6234 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
6238 static void AdjustLevelScrollPosition()
6240 if (level_xpos < -1)
6242 if (level_xpos > lev_fieldx - ed_fieldx + 1)
6243 level_xpos = lev_fieldx - ed_fieldx + 1;
6244 if (lev_fieldx < ed_fieldx - 2)
6247 if (level_ypos < -1)
6249 if (level_ypos > lev_fieldy - ed_fieldy + 1)
6250 level_ypos = lev_fieldy - ed_fieldy + 1;
6251 if (lev_fieldy < ed_fieldy - 2)
6255 static void AdjustEditorScrollbar(int id)
6257 struct GadgetInfo *gi = level_editor_gadget[id];
6258 int items_max, items_visible, item_position;
6260 if (id == GADGET_ID_SCROLL_HORIZONTAL)
6262 items_max = MAX(lev_fieldx + 2, ed_fieldx);
6263 items_visible = ed_fieldx;
6264 item_position = level_xpos + 1;
6268 items_max = MAX(lev_fieldy + 2, ed_fieldy);
6269 items_visible = ed_fieldy;
6270 item_position = level_ypos + 1;
6273 if (item_position > items_max - items_visible)
6274 item_position = items_max - items_visible;
6276 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
6277 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
6280 static void ModifyEditorCounter(int counter_id, int new_value)
6282 int *counter_value = counterbutton_info[counter_id].value;
6283 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
6284 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
6286 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
6288 if (counter_value != NULL)
6289 *counter_value = gi->textinput.number_value;
6292 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
6294 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
6295 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
6297 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
6300 static void ModifyEditorSelectbox(int selectbox_id, int new_value)
6302 int gadget_id = selectbox_info[selectbox_id].gadget_id;
6303 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
6304 int new_index_value = setSelectboxValue(selectbox_id, new_value);
6306 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
6309 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
6311 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
6312 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
6314 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
6317 static void ModifyEditorElementList()
6321 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6323 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
6324 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
6325 struct GadgetDesign *gd = &gi->deco.design;
6326 int element = editor_elements[element_shift + i];
6329 getMiniGraphicSource(el2edimg(element), &gd->bitmap, &gd->x, &gd->y);
6330 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
6335 static void PickDrawingElement(int button, int element)
6337 if (button < 1 || button > 3)
6342 new_element1 = element;
6343 DrawMiniGraphicExt(drawto,
6344 DX + ED_WIN_MB_LEFT_XPOS, DY + ED_WIN_MB_LEFT_YPOS,
6345 el2edimg(new_element1));
6347 else if (button == 2)
6349 new_element2 = element;
6350 DrawMiniGraphicExt(drawto,
6351 DX + ED_WIN_MB_MIDDLE_XPOS, DY + ED_WIN_MB_MIDDLE_YPOS,
6352 el2edimg(new_element2));
6356 new_element3 = element;
6357 DrawMiniGraphicExt(drawto,
6358 DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS,
6359 el2edimg(new_element3));
6362 redraw_mask |= REDRAW_DOOR_1;
6365 static void RedrawDrawingElements()
6367 PickDrawingElement(1, new_element1);
6368 PickDrawingElement(2, new_element2);
6369 PickDrawingElement(3, new_element3);
6372 static void DrawDrawingWindow()
6374 stick_element_properties_window = FALSE;
6376 SetMainBackgroundImage(IMG_UNDEFINED);
6379 UnmapLevelEditorWindowGadgets();
6380 UnmapLevelEditorToolboxCustomGadgets();
6382 AdjustDrawingAreaGadgets();
6383 AdjustLevelScrollPosition();
6384 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
6385 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
6387 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
6389 MapMainDrawingArea();
6390 MapLevelEditorToolboxDrawingGadgets();
6393 static void DrawLevelInfoWindow()
6397 stick_element_properties_window = FALSE;
6399 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
6401 UnmapLevelEditorWindowGadgets();
6403 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS1_YPOS,
6404 "Level Settings", FONT_TITLE_1);
6405 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS2_YPOS,
6406 "Editor Settings", FONT_TITLE_1);
6408 /* draw counter gadgets */
6409 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
6410 MapCounterButtons(i);
6412 /* draw selectbox gadgets */
6413 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
6414 MapSelectboxGadget(i);
6416 /* draw checkbutton gadgets */
6417 for (i=ED_CHECKBUTTON_ID_LEVEL_FIRST; i <= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
6418 MapCheckbuttonGadget(i);
6420 /* draw radiobutton gadgets */
6421 for (i=ED_RADIOBUTTON_ID_LEVEL_FIRST; i <= ED_RADIOBUTTON_ID_LEVEL_LAST; i++)
6422 MapRadiobuttonGadget(i);
6424 /* draw text input gadgets */
6425 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
6426 MapTextInputGadget(i);
6428 /* draw drawing area */
6429 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
6432 static void DrawCustomContentArea()
6434 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
6435 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6436 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
6437 int x2 = right_gadget_border[GADGET_ID_CUSTOM_CONSISTENCY];
6438 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
6439 int xoffset = ED_DRAWINGAREA_TEXT_DISTANCE;
6441 /* add distance for potential left text (without drawing area border) */
6442 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
6444 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
6446 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
6449 static void DrawCustomChangeContentArea()
6451 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
6452 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6453 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
6454 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
6455 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
6456 int xoffset = ED_DRAWINGAREA_TEXT_DISTANCE;
6458 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
6463 static void DrawElementContentAreas()
6465 int x = SX + ED_AREA_YAMYAM_CONTENT_XPOS(3) + 4 * MINI_TILEX;
6466 int y = SY + ED_AREA_YAMYAM_CONTENT_YPOS(0) + ED_BORDER_AREA_YSIZE;
6469 /* display counter to choose number of element content areas */
6470 MapCounterButtons(ED_COUNTER_ID_ELEMENT_CONTENT);
6472 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
6474 int id = ED_DRAWING_ID_ELEMENT_CONTENT_0 + i;
6475 int font_height = getFontHeight(FONT_TEXT_1);
6477 if (i < level.num_yamyam_contents)
6481 UnmapDrawingArea(id);
6483 /* delete content areas in case of reducing number of them */
6484 DrawBackground(SX + drawingarea_info[id].x - MINI_TILEX / 2,
6485 SY + drawingarea_info[id].y - MINI_TILEY / 2,
6487 4 * MINI_TILEY + ED_GADGET_TEXT_DISTANCE + font_height);
6491 DrawText(x, y + 0 * MINI_TILEY, "content", FONT_TEXT_1);
6492 DrawText(x, y + 1 * MINI_TILEY, "when", FONT_TEXT_1);
6493 DrawText(x, y + 2 * MINI_TILEY, "smashed", FONT_TEXT_1);
6496 static void DrawGroupElementArea(int element)
6498 int num_elements = group_element_info.num_elements;
6499 int id = ED_DRAWING_ID_GROUP_CONTENT;
6500 int sx = SX + drawingarea_info[id].x - MINI_TILEX / 2;
6501 int sy = SY + drawingarea_info[id].y - MINI_TILEY / 2;
6502 int xsize = MAX_ELEMENTS_IN_GROUP;
6505 if (drawingarea_info[id].text_left != NULL)
6506 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
6508 UnmapDrawingArea(id);
6510 ModifyEditorDrawingArea(id, num_elements, 1);
6512 /* delete content areas in case of reducing number of them */
6513 DrawBackground(sx, sy, (xsize + 1) * MINI_TILEX, (ysize + 1) * MINI_TILEY);
6518 static void DrawEnvelopeTextArea(int envelope_nr)
6520 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
6521 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
6524 DrawBackground(gi->x, gi->y, gi->width, gi->height);
6526 if (envelope_nr != -1)
6527 textarea_info[id].value = level.envelope_text[envelope_nr];
6529 ModifyGadget(gi, GDI_AREA_SIZE,
6530 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
6531 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
6534 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
6537 char *getElementDescriptionFilename(int element)
6539 char *docs_dir = options.docs_directory;
6540 char *elements_subdir = "elements";
6541 static char *filename = NULL;
6542 char basename[MAX_FILENAME_LEN];
6544 checked_free(filename);
6546 /* 1st try: look for element description file for exactly this element */
6547 sprintf(basename, "%s.txt", element_info[element].token_name);
6548 filename = getPath3(docs_dir, elements_subdir, basename);
6549 if (fileExists(filename))
6554 /* 2nd try: look for element description file for this element's class */
6555 sprintf(basename, "%s.txt", element_info[element].class_name);
6556 filename = getPath3(docs_dir, elements_subdir, basename);
6557 if (fileExists(filename))
6563 static boolean PrintInfoText(char *text, int font_nr, int start_line)
6565 int font_height = getFontHeight(font_nr);
6566 int pad_x = ED_SETTINGS_XPOS(0);
6567 int pad_y = ED_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
6568 int sx = SX + pad_x;
6569 int sy = SY + pad_y;
6570 int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
6572 if (start_line >= max_lines_per_screen)
6575 DrawText(sx, sy + start_line * font_height, text, font_nr);
6582 static int PrintElementDescriptionFromFile(char *filename, int start_line)
6584 int font_nr = FONT_TEXT_2;
6585 int font_width = getFontWidth(font_nr);
6586 int font_height = getFontHeight(font_nr);
6587 int pad_x = ED_SETTINGS_XPOS(0);
6588 int pad_y = ED_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
6589 int sx = SX + pad_x;
6590 int sy = SY + pad_y + start_line * font_height;
6591 int max_chars_per_line = (SXSIZE - 2 * pad_x) / font_width;
6592 int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
6594 return DrawTextFromFile(sx, sy, filename, font_nr, max_chars_per_line,
6595 max_lines_per_screen);
6600 static int PrintElementDescriptionFromFile(char *filename, int start_line)
6602 int font_nr = FONT_TEXT_2;
6603 int font_width = getFontWidth(font_nr);
6604 int font_height = getFontHeight(font_nr);
6605 int pad_x = ED_SETTINGS_XPOS(0);
6606 int pad_y = ED_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
6607 int sx = SX + pad_x;
6608 int sy = SY + pad_y;
6609 int max_chars_per_line = (SXSIZE - 2 * pad_x) / font_width;
6610 int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
6611 int current_line = start_line;
6612 char line[MAX_LINE_LEN];
6613 char buffer[max_chars_per_line + 1];
6617 if (current_line >= max_lines_per_screen)
6620 if (filename == NULL)
6623 if (!(file = fopen(filename, MODE_READ)))
6629 while (!feof(file) && current_line < max_lines_per_screen)
6632 boolean last_line_was_empty = TRUE;
6634 /* read next line of input file */
6635 if (!fgets(line, MAX_LINE_LEN, file))
6638 /* skip comments (lines directly beginning with '#') */
6642 /* cut trailing newline from input line */
6643 for (line_ptr = line; *line_ptr; line_ptr++)
6645 if (*line_ptr == '\n' || *line_ptr == '\r')
6652 if (strlen(line) == 0) /* special case: force empty line */
6657 while (*line_ptr && current_line < max_lines_per_screen)
6659 boolean buffer_filled = RenderLineToBuffer(&line_ptr,
6660 buffer, &buffer_len,
6661 last_line_was_empty,
6662 max_chars_per_line);
6665 DrawText(sx, sy + current_line * font_height, buffer, font_nr);
6668 last_line_was_empty = (buffer_len == 0);
6678 if (buffer_len > 0 && current_line < max_lines_per_screen)
6680 DrawText(sx, sy + current_line * font_height, buffer, font_nr);
6684 return (current_line - start_line);
6689 static void DrawPropertiesTabulatorGadgets()
6691 struct GadgetInfo *gd_gi = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
6692 struct GadgetDesign *gd = &gd_gi->alt_design[GD_BUTTON_UNPRESSED];
6693 int gd_x = gd->x + gd_gi->border.width / 2;
6694 int gd_y = gd->y + gd_gi->height - 1;
6695 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
6696 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
6697 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
6701 /* draw additional "advanced" tabulator for custom elements */
6702 if (IS_CUSTOM_ELEMENT(properties_element))
6703 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
6705 for (i = id_first; i <= id_last; i++)
6707 int gadget_id = textbutton_info[i].gadget_id;
6708 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
6709 boolean active = (i != edit_mode_properties);
6711 /* use "config 1" and "config 2" instead of "config" */
6712 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
6713 IS_CUSTOM_ELEMENT(properties_element))
6716 /* draw background line below tabulator button */
6717 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width,1);
6719 /* draw solid line below inactive tabulator buttons */
6720 if (!active && tab_color != BLACK_PIXEL) /* black => transparent */
6721 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,1, tab_color);
6723 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
6724 MapTextbuttonGadget(i);
6727 /* draw little border line below tabulator buttons */
6728 if (tab_color != BLACK_PIXEL) /* black => transparent */
6729 FillRectangle(drawto, gd_gi->x, gd_gi->y + gd_gi->height + 1,
6730 max_tabs * gd_gi->width + (max_tabs -1) * ED_GADGET_DISTANCE,
6731 ED_GADGET_DISTANCE, tab_color);
6734 static void DrawPropertiesInfo()
6743 /* configurable properties */
6745 { EP_WALKABLE_OVER, "- player can walk over it" },
6746 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
6747 { EP_WALKABLE_UNDER, "- player can walk under it" },
6748 { EP_PASSABLE_OVER, "- player can pass over it" },
6749 { EP_PASSABLE_INSIDE, "- player can pass through it" },
6750 { EP_PASSABLE_UNDER, "- player can pass under it" },
6752 { EP_DIGGABLE, "- can be digged away" },
6753 { EP_COLLECTIBLE, "- can be collected" },
6754 { EP_DROPPABLE, "- can be dropped after collecting" },
6755 { EP_PUSHABLE, "- can be pushed" },
6757 { EP_CAN_MOVE, "- can move" },
6758 { EP_CAN_FALL, "- can fall" },
6760 { EP_CAN_SMASH_PLAYER, "- can smash player" },
6762 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
6764 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
6766 { EP_SLIPPERY, "- slippery for falling objects" },
6767 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
6769 { EP_DONT_RUN_INTO, "- deadly when running into" },
6770 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
6771 { EP_DONT_TOUCH, "- deadly when touching" },
6773 { EP_INDESTRUCTIBLE, "- indestructible" },
6775 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
6776 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
6777 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
6779 { EP_CAN_CHANGE, "- can change to other element" },
6781 /* pre-defined properties */
6782 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
6783 { EP_HAS_CONTENT, "- can contain other elements" },
6787 char *filename = getElementDescriptionFilename(properties_element);
6788 char *percentage_text = "In this level:";
6789 char *properties_text = "Standard properties:";
6791 int num_elements_in_level;
6792 int num_standard_properties = 0;
6793 int font1_nr = FONT_TEXT_1;
6794 int font2_nr = FONT_TEXT_2;
6795 int font1_width = getFontWidth(font1_nr);
6796 int font2_height = getFontHeight(font2_nr);
6797 int pad_x = ED_SETTINGS_XPOS(0);
6798 int pad_y = ED_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
6799 int screen_line = 0;
6803 if (IS_CUSTOM_ELEMENT(properties_element))
6805 DrawTextF(pad_x, pad_y + screen_line++ * font2_height, FONT_TEXT_3,
6806 "[Custom Element %d]", properties_element - EL_CUSTOM_START + 1);
6809 else if (IS_GROUP_ELEMENT(properties_element))
6811 DrawTextF(pad_x, pad_y + screen_line++ * font2_height, FONT_TEXT_3,
6812 "[Group Element %d]", properties_element - EL_GROUP_START + 1);
6817 /* ----- print number of elements / percentage of this element in level */
6819 num_elements_in_level = 0;
6820 for (y = 0; y < lev_fieldy; y++)
6821 for (x = 0; x < lev_fieldx; x++)
6822 if (Feld[x][y] == properties_element)
6823 num_elements_in_level++;
6824 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
6826 DrawTextS(pad_x, pad_y + screen_line * font2_height, font1_nr,
6828 DrawTextF(pad_x + strlen(percentage_text) * font1_width,
6829 pad_y + screen_line++ * font2_height, font2_nr,
6830 "%d (%.2f%%)", num_elements_in_level, percentage);
6834 /* ----- print standard properties of this element */
6836 DrawTextS(pad_x, pad_y + screen_line++ * font2_height, font1_nr,
6839 for (i = 0; properties[i].value != -1; i++)
6841 if (!HAS_PROPERTY(properties_element, properties[i].value))
6844 DrawTextS(pad_x, pad_y + screen_line++ * font2_height, font2_nr,
6845 properties[i].text);
6846 num_standard_properties++;
6849 if (num_standard_properties == 0)
6850 DrawTextS(pad_x + strlen(properties_text) * font1_width,
6851 pad_y + (screen_line - 1) * font2_height, font2_nr, "none");
6855 /* ----- print special description of this element */
6857 PrintInfoText("Description:", FONT_TEXT_1, screen_line);
6858 if (PrintElementDescriptionFromFile(filename, screen_line + 1) == 0)
6859 PrintInfoText("No description available.", FONT_TEXT_1, screen_line);
6862 #define TEXT_COLLECTING "Score for collecting"
6863 #define TEXT_SMASHING "Score for smashing"
6864 #define TEXT_CRACKING "Score for cracking"
6865 #define TEXT_SPEED "Speed of amoeba growth"
6866 #define TEXT_DURATION "Duration when activated"
6873 } elements_with_counter[] =
6875 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
6876 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
6877 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
6878 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
6879 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
6880 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
6881 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
6882 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
6883 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
6884 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
6885 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
6886 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
6887 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
6888 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
6889 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
6890 { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
6891 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
6892 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
6893 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
6894 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
6895 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6896 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6897 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6898 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6899 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6900 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6901 { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
6902 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6903 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6904 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6905 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
6906 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
6907 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
6908 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
6909 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
6910 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
6911 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
6912 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
6913 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
6914 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
6915 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
6916 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE],TEXT_COLLECTING },
6917 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
6918 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
6919 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
6920 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
6921 { EL_EXTRA_TIME, &level.score[SC_TIME_BONUS], TEXT_COLLECTING },
6922 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
6923 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
6924 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
6925 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
6927 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
6928 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
6929 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
6930 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
6932 { EL_EM_KEY_1_FILE, &level.score[SC_KEY], TEXT_COLLECTING },
6933 { EL_EM_KEY_2_FILE, &level.score[SC_KEY], TEXT_COLLECTING },
6934 { EL_EM_KEY_3_FILE, &level.score[SC_KEY], TEXT_COLLECTING },
6935 { EL_EM_KEY_4_FILE, &level.score[SC_KEY], TEXT_COLLECTING },
6937 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_SPEED },
6938 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_SPEED },
6939 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_SPEED },
6940 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_SPEED },
6941 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
6942 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
6946 static boolean checkPropertiesConfig(int element)
6950 if (IS_GEM(element) ||
6951 IS_CUSTOM_ELEMENT(element) ||
6952 IS_GROUP_ELEMENT(element) ||
6953 IS_ENVELOPE(element) ||
6954 ELEM_IS_PLAYER(element) ||
6955 HAS_CONTENT(element) ||
6956 CAN_GROW(element) ||
6957 COULD_MOVE_INTO_ACID(element) ||
6958 MAYBE_DONT_COLLIDE_WITH(element))
6961 for (i = 0; elements_with_counter[i].element != -1; i++)
6962 if (elements_with_counter[i].element == element)
6968 static void DrawPropertiesConfig()
6972 if (!checkPropertiesConfig(properties_element))
6974 PrintInfoText("No configuration options available.", FONT_TEXT_1, 0);
6979 /* check if there are elements where a score can be chosen for */
6980 for (i = 0; elements_with_counter[i].element != -1; i++)
6982 if (elements_with_counter[i].element == properties_element)
6984 int counter_id = ED_COUNTER_ID_ELEMENT_SCORE;
6986 counterbutton_info[counter_id].y =
6987 ED_SETTINGS_YPOS((HAS_CONTENT(properties_element) ? 1 : 0) +
6988 (CAN_GROW(properties_element) ? 1 : 0) +
6989 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
6990 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 :0));
6992 counterbutton_info[counter_id].value = elements_with_counter[i].value;
6993 counterbutton_info[counter_id].text_right= elements_with_counter[i].text;
6995 MapCounterButtons(counter_id);
7001 if (HAS_CONTENT(properties_element))
7003 /* draw stickybutton gadget */
7004 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
7006 if (IS_AMOEBOID(properties_element))
7007 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
7009 DrawElementContentAreas();
7012 if (ELEM_IS_PLAYER(properties_element))
7014 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
7015 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
7016 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
7017 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
7018 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
7019 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
7022 if (IS_GEM(properties_element))
7023 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
7025 if (COULD_MOVE_INTO_ACID(properties_element) &&
7026 !ELEM_IS_PLAYER(properties_element) &&
7027 (!IS_CUSTOM_ELEMENT(properties_element) ||
7028 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
7030 /* set position for checkbutton for "can move into acid" */
7031 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
7032 ED_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 6 :
7033 HAS_CONTENT(properties_element) ? 1 : 0);
7035 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
7038 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
7039 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
7041 if (properties_element == EL_SPRING)
7042 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
7044 if (CAN_GROW(properties_element))
7046 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
7047 ED_SETTINGS_YPOS(HAS_CONTENT(properties_element) ? 1 : 0);
7049 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
7052 if (IS_ENVELOPE(properties_element))
7054 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
7055 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
7056 int envelope_nr = properties_element - EL_ENVELOPE_1;
7058 counterbutton_info[counter1_id].value = &level.envelope_xsize[envelope_nr];
7059 counterbutton_info[counter2_id].value = &level.envelope_ysize[envelope_nr];
7061 /* display counter to choose size of envelope text area */
7062 MapCounterButtons(ED_COUNTER_ID_ENVELOPE_XSIZE);
7063 MapCounterButtons(ED_COUNTER_ID_ENVELOPE_YSIZE);
7065 DrawEnvelopeTextArea(envelope_nr);
7068 if (IS_CUSTOM_ELEMENT(properties_element))
7070 /* draw stickybutton gadget */
7071 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
7073 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
7075 /* draw checkbutton gadgets */
7076 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
7077 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
7078 MapCheckbuttonGadget(i);
7080 /* draw counter gadgets */
7081 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
7082 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
7083 MapCounterButtons(i);
7085 /* draw selectbox gadgets */
7086 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
7087 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
7088 MapSelectboxGadget(i);
7090 /* draw textbutton gadgets */
7091 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE);
7093 /* draw text input gadgets */
7094 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
7096 /* draw drawing area gadgets */
7097 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
7098 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
7099 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
7101 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
7103 /* draw checkbutton gadgets */
7104 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
7105 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
7106 MapCheckbuttonGadget(i);
7108 /* draw counter gadgets */
7109 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
7110 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
7111 MapCounterButtons(i);
7113 /* draw selectbox gadgets */
7114 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
7115 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
7116 MapSelectboxGadget(i);
7118 /* draw drawing area gadgets */
7119 DrawCustomContentArea();
7122 else if (IS_GROUP_ELEMENT(properties_element))
7124 /* draw stickybutton gadget */
7125 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
7127 /* draw checkbutton gadgets */
7128 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
7129 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE);
7131 /* draw counter gadgets */
7132 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
7134 /* draw selectbox gadgets */
7135 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
7137 /* draw textbutton gadgets */
7138 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE);
7140 /* draw drawing area gadgets */
7141 DrawGroupElementArea(properties_element);
7143 /* draw text input gadgets */
7144 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
7146 /* draw drawing area gadgets */
7147 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
7151 static void DrawPropertiesChangeDrawingAreas()
7153 if (IS_CUSTOM_ELEMENT(properties_element))
7155 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
7156 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
7158 DrawCustomChangeContentArea();
7161 redraw_mask |= REDRAW_FIELD;
7164 static void DrawPropertiesChange()
7168 /* draw stickybutton gadget */
7169 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
7171 /* draw checkbutton gadgets */
7172 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
7173 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
7174 MapCheckbuttonGadget(i);
7176 /* draw counter gadgets */
7177 for (i = ED_COUNTER_ID_CHANGE_FIRST;
7178 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
7179 MapCounterButtons(i);
7181 /* draw selectbox gadgets */
7182 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
7183 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
7184 MapSelectboxGadget(i);
7186 /* draw textbutton gadgets */
7187 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
7188 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
7189 MapTextbuttonGadget(i);
7191 /* draw graphicbutton gadgets */
7192 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
7193 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
7194 MapGraphicbuttonGadget(i);
7196 /* draw drawing area gadgets */
7197 DrawPropertiesChangeDrawingAreas();
7200 static void DrawElementName(int x, int y, int element)
7202 char *element_name = getElementInfoText(element);
7203 int font_nr = FONT_TEXT_1;
7204 int font_width = getFontWidth(font_nr);
7205 int font_height = getFontHeight(font_nr);
7206 int max_text_width = SXSIZE - x - ED_SETTINGS_XPOS(0);
7207 int max_chars_per_line = max_text_width / font_width;
7208 char buffer[max_chars_per_line + 1];
7210 if (strlen(element_name) <= max_chars_per_line)
7211 DrawTextS(x, y, font_nr, element_name);
7214 int next_pos = max_chars_per_line;
7216 strncpy(buffer, element_name, max_chars_per_line);
7217 buffer[max_chars_per_line] = '\0';
7219 if (element_name[max_chars_per_line] == ' ')
7225 for (i = max_chars_per_line - 1; i >= 0; i--)
7226 if (buffer[i] == ' ')
7229 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
7236 DrawTextS(x, y - font_height / 2, font_nr, buffer);
7238 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
7239 buffer[max_chars_per_line] = '\0';
7241 DrawTextS(x, y + font_height / 2, font_nr, buffer);
7245 static void DrawPropertiesWindow()
7250 stick_element_properties_window = FALSE;
7252 /* make sure that previous properties edit mode exists for this element */
7253 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
7254 !IS_CUSTOM_ELEMENT(properties_element))
7255 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
7257 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
7258 IS_CUSTOM_ELEMENT(properties_element))
7259 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
7261 CopyElementPropertiesToEditor(properties_element);
7263 UnmapLevelEditorWindowGadgets();
7264 UnmapLevelEditorToolboxDrawingGadgets();
7265 UnmapLevelEditorToolboxCustomGadgets();
7267 if (IS_CUSTOM_ELEMENT(properties_element) ||
7268 IS_GROUP_ELEMENT(properties_element))
7269 MapLevelEditorToolboxCustomGadgets();
7271 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
7274 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS1_YPOS,
7275 "Element Settings", FONT_TITLE_1);
7277 DrawElementBorder(SX + xstart * MINI_TILEX,
7278 SY + ystart * MINI_TILEY + MINI_TILEY / 2,
7279 TILEX, TILEY, FALSE);
7280 DrawGraphicAnimationExt(drawto,
7281 SX + xstart * MINI_TILEX,
7282 SY + ystart * MINI_TILEY + MINI_TILEY / 2,
7283 el2img(properties_element), -1, NO_MASKING);
7285 FrameCounter = 0; /* restart animation frame counter */
7287 DrawElementName((xstart + 3) * MINI_TILEX + 1, (ystart + 1) * MINI_TILEY + 1,
7288 properties_element);
7290 DrawPropertiesTabulatorGadgets();
7292 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
7293 DrawPropertiesInfo();
7294 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
7295 DrawPropertiesChange();
7296 else /* (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2]) */
7297 DrawPropertiesConfig();
7300 static void UpdateCustomElementGraphicGadgets()
7304 ModifyEditorElementList();
7305 RedrawDrawingElements();
7307 /* force redraw of all mapped drawing area gadgets */
7308 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
7310 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
7317 static void DrawLineElement(int sx, int sy, int element, boolean change_level)
7319 int lx = sx + level_xpos;
7320 int ly = sy + level_ypos;
7322 DrawMiniElement(sx, sy, (element < 0 ? Feld[lx][ly] : element));
7325 Feld[lx][ly] = element;
7328 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
7329 int element, boolean change_level)
7331 if (from_y == to_y) /* horizontal line */
7337 swap_numbers(&from_x, &to_x);
7339 for (x = from_x; x <= to_x; x++)
7340 DrawLineElement(x, y, element, change_level);
7342 else if (from_x == to_x) /* vertical line */
7348 swap_numbers(&from_y, &to_y);
7350 for (y = from_y; y <= to_y; y++)
7351 DrawLineElement(x, y, element, change_level);
7353 else /* diagonal line */
7355 int len_x = ABS(to_x - from_x);
7356 int len_y = ABS(to_y - from_y);
7359 if (len_y < len_x) /* a < 1 */
7361 float a = (float)len_y / (float)len_x;
7364 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
7366 for (x = 0; x <= len_x; x++)
7368 y = (int)(a * x + 0.5) * (to_y < from_y ? -1 : +1);
7369 DrawLineElement(from_x + x, from_y + y, element, change_level);
7374 float a = (float)len_x / (float)len_y;
7377 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
7379 for (y = 0; y <= len_y; y++)
7381 x = (int)(a * y + 0.5) * (to_x < from_x ? -1 : +1);
7382 DrawLineElement(from_x + x, from_y + y, element, change_level);
7388 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
7389 int element, boolean change_level)
7391 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
7392 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
7393 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
7394 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
7397 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
7398 int element, boolean change_level)
7403 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
7405 for (y = from_y; y <= to_y; y++)
7406 DrawLine(from_x, y, to_x, y, element, change_level);
7409 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
7410 int element, boolean change_level)
7412 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
7413 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
7414 int len_x = ABS(to_x - from_x);
7415 int len_y = ABS(to_y - from_y);
7418 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
7420 /* not optimal (some points get drawn twice) but simple,
7421 and fast enough for the few points we are drawing */
7423 for (x = 0; x <= radius; x++)
7427 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
7429 sx = from_x + x * (from_x < to_x2 ? +1 : -1);
7430 sy = from_y + y * (from_y < to_y2 ? +1 : -1);
7431 lx = sx + level_xpos;
7432 ly = sy + level_ypos;
7434 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
7435 DrawLineElement(sx, sy, element, change_level);
7438 for (y = 0; y <= radius; y++)
7442 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
7444 sx = from_x + x * (from_x < to_x2 ? +1 : -1);
7445 sy = from_y + y * (from_y < to_y2 ? +1 : -1);
7446 lx = sx + level_xpos;
7447 ly = sy + level_ypos;
7449 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
7450 DrawLineElement(sx, sy, element, change_level);
7454 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
7455 int element, boolean change_level)
7457 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
7458 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
7460 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
7463 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
7464 #if DRAW_CIRCLES_BUTTON_AVAILABLE
7465 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
7466 int element, boolean change_level)
7468 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
7469 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
7470 int mirror_to_x2 = from_x - (to_x2 - from_x);
7471 int mirror_to_y2 = from_y - (to_y2 - from_y);
7473 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
7474 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
7475 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
7476 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element,change_level);
7480 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
7482 int from_sx, from_sy;
7486 swap_numbers(&from_x, &to_x);
7489 swap_numbers(&from_y, &to_y);
7491 from_sx = SX + from_x * MINI_TILEX;
7492 from_sy = SY + from_y * MINI_TILEY;
7493 to_sx = SX + to_x * MINI_TILEX + MINI_TILEX - 1;
7494 to_sy = SY + to_y * MINI_TILEY + MINI_TILEY - 1;
7496 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
7497 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
7498 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
7499 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
7501 if (from_x == to_x && from_y == to_y)
7502 MarkTileDirty(from_x/2, from_y/2);
7504 redraw_mask |= REDRAW_FIELD;
7507 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
7508 int element, boolean change_level)
7510 if (element == -1 || change_level)
7511 DrawBox(from_x, from_y, to_x, to_y, -1, FALSE);
7513 DrawAreaBorder(from_x, from_y, to_x, to_y);
7516 /* values for CopyBrushExt() */
7517 #define CB_AREA_TO_BRUSH 0
7518 #define CB_BRUSH_TO_CURSOR 1
7519 #define CB_BRUSH_TO_LEVEL 2
7520 #define CB_DELETE_OLD_CURSOR 3
7521 #define CB_DUMP_BRUSH 4
7523 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
7524 int button, int mode)
7526 static short brush_buffer[MAX_ED_FIELDX][MAX_ED_FIELDY];
7527 static int brush_width, brush_height;
7528 static int last_cursor_x = -1, last_cursor_y = -1;
7529 static boolean delete_old_brush;
7530 int new_element = BUTTON_ELEMENT(button);
7533 if (mode == CB_DUMP_BRUSH)
7535 if (!draw_with_brush)
7537 Error(ERR_WARN, "no brush selected");
7542 for (y = 0; y < brush_height; y++)
7544 for (x = 0; x < brush_width; x++)
7546 int element = brush_buffer[x][y];
7547 int element_mapped = element;
7550 char *element_string = "?";
7553 for (k = 0; forum_sketch_element_mapping[k].element != -1; k++)
7555 if (forum_sketch_element_mapping[k].element == element)
7557 element_mapped = forum_sketch_element_mapping[k].element_mapped;
7562 if (IS_CUSTOM_ELEMENT(element))
7563 element_mapped = EL_CUSTOM_1;
7565 for (k = 0; forum_sketch_element_strings[k].element != -1; k++)
7567 if (forum_sketch_element_strings[k].element == element_mapped)
7569 element_string = forum_sketch_element_strings[k].element_string;
7574 printf("`%s", element_string);
7578 if (IS_CUSTOM_ELEMENT(element))
7579 element_mapped = EL_CUSTOM_START;
7580 else if (element > EL_ENVELOPE_4)
7581 element_mapped = EL_CHAR_QUESTION; /* change to EL_UNKNOWN ... */
7583 printf("`%03d", element_mapped);
7593 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
7596 if (mode == CB_AREA_TO_BRUSH)
7598 int from_lx, from_ly;
7601 swap_numbers(&from_x, &to_x);
7604 swap_numbers(&from_y, &to_y);
7606 brush_width = to_x - from_x + 1;
7607 brush_height = to_y - from_y + 1;
7609 from_lx = from_x + level_xpos;
7610 from_ly = from_y + level_ypos;
7612 for (y = 0; y < brush_height; y++)
7614 for (x=0; x < brush_width; x++)
7616 brush_buffer[x][y] = Feld[from_lx + x][from_ly + y];
7619 DrawLineElement(from_x + x, from_y + y, new_element, TRUE);
7624 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7626 delete_old_brush = FALSE;
7628 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
7629 mode == CB_BRUSH_TO_LEVEL)
7631 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
7632 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
7633 int cursor_from_x = cursor_x - brush_width / 2;
7634 int cursor_from_y = cursor_y - brush_height / 2;
7635 int border_from_x = cursor_x, border_from_y = cursor_y;
7636 int border_to_x = cursor_x, border_to_y = cursor_y;
7638 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
7639 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
7641 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
7642 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
7644 delete_old_brush = FALSE;
7648 for (y = 0; y < brush_height; y++)
7650 for (x = 0; x < brush_width; x++)
7652 int sx = cursor_from_x + x;
7653 int sy = cursor_from_y + y;
7654 int lx = sx + level_xpos;
7655 int ly = sy + level_ypos;
7656 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
7657 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
7658 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
7659 brush_buffer[x][y] : new_element);
7661 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
7663 if (sx < border_from_x)
7665 else if (sx > border_to_x)
7667 if (sy < border_from_y)
7669 else if (sy > border_to_y)
7672 DrawLineElement(sx, sy, element, change_level);
7677 if (mode != CB_DELETE_OLD_CURSOR)
7678 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
7680 last_cursor_x = cursor_x;
7681 last_cursor_y = cursor_y;
7682 delete_old_brush = TRUE;
7686 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
7689 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
7692 static void CopyBrushToLevel(int x, int y, int button)
7694 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
7697 static void CopyBrushToCursor(int x, int y)
7699 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
7702 static void DeleteBrushFromCursor()
7704 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
7709 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
7712 static void FloodFill(int from_x, int from_y, int fill_element)
7716 static int check[4][2] = { {-1,0}, {0,-1}, {1,0}, {0,1} };
7717 static int safety = 0;
7719 /* check if starting field still has the desired content */
7720 if (Feld[from_x][from_y] == fill_element)
7725 if (safety > lev_fieldx*lev_fieldy)
7726 Error(ERR_EXIT, "Something went wrong in 'FloodFill()'. Please debug.");
7728 old_element = Feld[from_x][from_y];
7729 Feld[from_x][from_y] = fill_element;
7731 for (i = 0; i < 4; i++)
7733 x = from_x + check[i][0];
7734 y = from_y + check[i][1];
7736 if (IN_LEV_FIELD(x,y) && Feld[x][y] == old_element)
7737 FloodFill(x, y, fill_element);
7743 /* values for DrawLevelText() modes */
7745 #define TEXT_SETCURSOR 1
7746 #define TEXT_WRITECHAR 2
7747 #define TEXT_BACKSPACE 3
7748 #define TEXT_NEWLINE 4
7750 #define TEXT_QUERY_TYPING 6
7752 static int DrawLevelText(int sx, int sy, char letter, int mode)
7754 static short delete_buffer[MAX_LEV_FIELDX];
7755 static int start_sx, start_sy;
7756 static int last_sx, last_sy;
7757 static boolean typing = FALSE;
7758 int letter_element = EL_CHAR_ASCII0 + letter;
7761 /* map lower case letters to upper case and convert special characters */
7762 if (letter >= 'a' && letter <= 'z')
7763 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
7764 else if (letter == 'ä' || letter == 'Ä')
7765 letter_element = EL_CHAR_AUMLAUT;
7766 else if (letter == 'ö' || letter == 'Ö')
7767 letter_element = EL_CHAR_OUMLAUT;
7768 else if (letter == 'ü' || letter == 'Ü')
7769 letter_element = EL_CHAR_UUMLAUT;
7770 else if (letter == '^')
7771 letter_element = EL_CHAR_COPYRIGHT;
7773 letter_element = EL_CHAR_ASCII0 + letter;
7775 if (mode != TEXT_INIT)
7780 if (mode != TEXT_SETCURSOR)
7786 lx = last_sx + level_xpos;
7787 ly = last_sy + level_ypos;
7794 DrawLevelText(0, 0, 0, TEXT_END);
7797 start_sx = last_sx = sx;
7798 start_sy = last_sy = sy;
7799 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
7802 case TEXT_SETCURSOR:
7803 DrawMiniElement(last_sx, last_sy, Feld[lx][ly]);
7804 DrawAreaBorder(sx, sy, sx, sy);
7809 case TEXT_WRITECHAR:
7810 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
7812 delete_buffer[sx - start_sx] = Feld[lx][ly];
7813 Feld[lx][ly] = letter_element;
7815 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
7816 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
7817 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
7818 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
7820 DrawLevelText(0, 0, 0, TEXT_END);
7824 case TEXT_BACKSPACE:
7827 Feld[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
7828 DrawMiniElement(sx - 1, sy, Feld[lx - 1][ly]);
7829 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
7834 if (sy + 1 < ed_fieldy - 1 && ly + 1 < lev_fieldy - 1)
7835 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
7837 DrawLevelText(0, 0, 0, TEXT_END);
7841 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7842 DrawMiniElement(sx, sy, Feld[lx][ly]);
7846 case TEXT_QUERY_TYPING:
7856 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
7857 int element, boolean change_level)
7859 int lx = sx + level_xpos;
7860 int ly = sy + level_ypos;
7863 DrawMiniElement(sx, sy, Feld[lx][ly]);
7865 DrawAreaBorder(sx, sy, sx, sy);
7868 static void CopyLevelToUndoBuffer(int mode)
7870 static boolean accumulated_undo = FALSE;
7871 boolean new_undo_buffer_position = TRUE;
7872 int last_border_element;
7877 case UNDO_IMMEDIATE:
7878 accumulated_undo = FALSE;
7881 case UNDO_ACCUMULATE:
7882 if (accumulated_undo)
7883 new_undo_buffer_position = FALSE;
7884 accumulated_undo = TRUE;
7891 if (new_undo_buffer_position)
7893 /* new position in undo buffer ring */
7894 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
7896 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
7897 undo_buffer_steps++;
7900 for (x = 0; x < lev_fieldx; x++)
7901 for (y = 0; y < lev_fieldy; y++)
7902 UndoBuffer[undo_buffer_position][x][y] = Feld[x][y];
7904 /* check if drawing operation forces change of border style */
7905 last_border_element = BorderElement;
7907 if (BorderElement != last_border_element)
7908 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7911 static void RandomPlacement(int new_element)
7913 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
7914 int num_free_positions;
7919 /* determine number of free positions for the new elements */
7920 /* (maybe this statement should be formatted a bit more readable...) */
7921 num_free_positions = 0;
7922 for (x = 0; x < lev_fieldx; x++)
7923 for (y = 0; y < lev_fieldy; y++)
7924 if ((free_position[x][y] =
7925 ((random_placement_background_restricted &&
7926 Feld[x][y] == random_placement_background_element) ||
7927 (!random_placement_background_restricted &&
7928 Feld[x][y] != new_element))) == TRUE)
7929 num_free_positions++;
7931 /* determine number of new elements to place there */
7932 num_percentage = num_free_positions * random_placement_value / 100;
7933 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
7934 num_percentage : random_placement_value);
7936 /* if not more free positions than elements to place, fill whole level */
7937 if (num_elements >= num_free_positions)
7939 for (x = 0; x < lev_fieldx; x++)
7940 for (y = 0; y < lev_fieldy; y++)
7941 Feld[x][y] = new_element;
7943 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7944 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7948 while (num_elements > 0)
7950 x = RND(lev_fieldx);
7951 y = RND(lev_fieldy);
7953 /* don't place element at the same position twice */
7954 if (free_position[x][y])
7956 free_position[x][y] = FALSE;
7957 Feld[x][y] = new_element;
7962 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7963 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7966 void WrapLevel(int dx, int dy)
7968 int wrap_dx = lev_fieldx - dx;
7969 int wrap_dy = lev_fieldy - dy;
7972 for (x = 0; x < lev_fieldx; x++)
7973 for (y = 0; y < lev_fieldy; y++)
7974 FieldBackup[x][y] = Feld[x][y];
7976 for (x = 0; x < lev_fieldx; x++)
7977 for (y = 0; y < lev_fieldy; y++)
7979 FieldBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
7981 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7982 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
7985 static void HandleDrawingAreas(struct GadgetInfo *gi)
7987 static boolean started_inside_drawing_area = FALSE;
7988 int id = gi->custom_id;
7989 boolean button_press_event;
7990 boolean button_release_event;
7991 boolean inside_drawing_area = !gi->event.off_borders;
7992 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
7993 int actual_drawing_function;
7994 int button = gi->event.button;
7995 int new_element = BUTTON_ELEMENT(button);
7996 int sx = gi->event.x, sy = gi->event.y;
7997 int min_sx = 0, min_sy = 0;
7998 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
7999 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
8001 int min_lx = 0, min_ly = 0;
8002 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
8005 /* handle info callback for each invocation of action callback */
8006 gi->callback_info(gi);
8008 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
8009 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
8011 /* make sure to stay inside drawing area boundaries */
8012 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
8013 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
8017 /* get positions inside level field */
8018 lx = sx + level_xpos;
8019 ly = sy + level_ypos;
8021 if (!IN_LEV_FIELD(lx, ly))
8022 inside_drawing_area = FALSE;
8024 /* make sure to stay inside level field boundaries */
8025 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
8026 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
8028 /* correct drawing area positions accordingly */
8029 sx = lx - level_xpos;
8030 sy = ly - level_ypos;
8033 if (button_press_event)
8034 started_inside_drawing_area = inside_drawing_area;
8036 if (!started_inside_drawing_area)
8039 if (!button && !button_release_event)
8042 /* automatically switch to 'single item' drawing mode, if needed */
8043 actual_drawing_function =
8044 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
8045 drawing_function : GADGET_ID_SINGLE_ITEMS);
8047 /* clicking into drawing area with pressed Control key picks element */
8048 if (GetKeyModState() & KMOD_Control)
8050 last_drawing_function = drawing_function;
8051 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
8054 switch (actual_drawing_function)
8056 case GADGET_ID_SINGLE_ITEMS:
8059 if (button_release_event)
8061 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8063 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
8064 !inside_drawing_area)
8065 DeleteBrushFromCursor();
8071 if (draw_with_brush)
8073 if (!button_release_event)
8074 CopyBrushToLevel(sx, sy, button);
8076 else if (new_element != Feld[lx][ly])
8078 if (new_element == EL_PLAYER_1)
8080 /* remove player at old position */
8081 for (y = 0; y < lev_fieldy; y++)
8083 for (x = 0; x < lev_fieldx; x++)
8085 if (Feld[x][y] == EL_PLAYER_1)
8087 Feld[x][y] = EL_EMPTY;
8088 if (x - level_xpos >= 0 && x - level_xpos < ed_fieldx &&
8089 y - level_ypos >= 0 && y - level_ypos < ed_fieldy)
8090 DrawMiniElement(x - level_xpos, y - level_ypos,
8097 Feld[lx][ly] = new_element;
8098 DrawMiniElement(sx, sy, new_element);
8103 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
8104 DrawMiniGraphicExt(drawto,
8105 gi->x + sx * MINI_TILEX,
8106 gi->y + sy * MINI_TILEY,
8107 el2edimg(new_element));
8109 DrawGraphicExt(drawto,
8112 el2img(new_element), 0);
8114 if (id == GADGET_ID_AMOEBA_CONTENT)
8115 level.amoeba_content = new_element;
8116 else if (id == GADGET_ID_CUSTOM_GRAPHIC)
8118 new_element = GFX_ELEMENT(new_element);
8119 custom_element.gfx_element = new_element;
8121 CopyElementPropertiesToGame(properties_element);
8123 UpdateCustomElementGraphicGadgets();
8125 FrameCounter = 0; /* restart animation frame counter */
8127 else if (id == GADGET_ID_CUSTOM_CONTENT)
8129 custom_element.content[sx][sy] = new_element;
8131 CopyCustomElementPropertiesToGame(properties_element);
8133 else if (id == GADGET_ID_CUSTOM_MOVE_ENTER)
8135 custom_element.move_enter_element = new_element;
8137 CopyCustomElementPropertiesToGame(properties_element);
8139 else if (id == GADGET_ID_CUSTOM_MOVE_LEAVE)
8141 custom_element.move_leave_element = new_element;
8143 CopyCustomElementPropertiesToGame(properties_element);
8145 else if (id == GADGET_ID_CUSTOM_CHANGE_TARGET)
8147 custom_element_change.target_element = new_element;
8149 CopyCustomElementPropertiesToGame(properties_element);
8151 else if (id == GADGET_ID_CUSTOM_CHANGE_CONTENT)
8153 custom_element_change.target_content[sx][sy] = new_element;
8155 CopyCustomElementPropertiesToGame(properties_element);
8157 else if (id == GADGET_ID_CUSTOM_CHANGE_TRIGGER)
8159 custom_element_change.trigger_element = new_element;
8161 CopyCustomElementPropertiesToGame(properties_element);
8163 else if (id == GADGET_ID_GROUP_CONTENT)
8165 group_element_info.element[sx] = new_element;
8167 CopyGroupElementPropertiesToGame(properties_element);
8169 else if (id == GADGET_ID_RANDOM_BACKGROUND)
8170 random_placement_background_element = new_element;
8171 else if (id >= GADGET_ID_ELEMENT_CONTENT_0 &&
8172 id <= GADGET_ID_ELEMENT_CONTENT_7)
8173 level.yamyam_content[id - GADGET_ID_ELEMENT_CONTENT_0][sx][sy] =
8178 case GADGET_ID_CONNECTED_ITEMS:
8180 static int last_sx = -1;
8181 static int last_sy = -1;
8183 if (button_release_event)
8184 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8188 if (!button_press_event)
8189 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
8197 case GADGET_ID_LINE:
8199 case GADGET_ID_RECTANGLE:
8200 case GADGET_ID_FILLED_BOX:
8201 case GADGET_ID_GRAB_BRUSH:
8202 case GADGET_ID_TEXT:
8204 static int last_sx = -1;
8205 static int last_sy = -1;
8206 static int start_sx = -1;
8207 static int start_sy = -1;
8208 void (*draw_func)(int, int, int, int, int, boolean);
8210 if (drawing_function == GADGET_ID_LINE)
8211 draw_func = DrawLine;
8212 else if (drawing_function == GADGET_ID_ARC)
8213 draw_func = DrawArc;
8214 else if (drawing_function == GADGET_ID_RECTANGLE)
8215 draw_func = DrawBox;
8216 else if (drawing_function == GADGET_ID_FILLED_BOX)
8217 draw_func = DrawFilledBox;
8218 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
8219 draw_func = SelectArea;
8220 else /* (drawing_function == GADGET_ID_TEXT) */
8221 draw_func = SetTextCursor;
8223 if (button_press_event)
8225 draw_func(sx, sy, sx, sy, new_element, FALSE);
8226 start_sx = last_sx = sx;
8227 start_sy = last_sy = sy;
8229 if (drawing_function == GADGET_ID_TEXT)
8230 DrawLevelText(0, 0, 0, TEXT_END);
8232 else if (button_release_event)
8234 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
8235 if (drawing_function == GADGET_ID_GRAB_BRUSH)
8237 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
8238 CopyBrushToCursor(sx, sy);
8239 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
8241 draw_with_brush = TRUE;
8243 else if (drawing_function == GADGET_ID_TEXT)
8244 DrawLevelText(sx, sy, 0, TEXT_INIT);
8246 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8248 else if (last_sx != sx || last_sy != sy)
8250 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
8251 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
8258 case GADGET_ID_FLOOD_FILL:
8259 if (button_press_event && Feld[lx][ly] != new_element)
8261 FloodFill(lx, ly, new_element);
8262 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8263 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8267 case GADGET_ID_PICK_ELEMENT:
8268 if (button_release_event)
8269 ClickOnGadget(level_editor_gadget[last_drawing_function],
8271 else if (draw_level)
8272 PickDrawingElement(button, Feld[lx][ly]);
8273 else if (id == GADGET_ID_AMOEBA_CONTENT)
8274 PickDrawingElement(button, level.amoeba_content);
8275 else if (id == GADGET_ID_CUSTOM_GRAPHIC)
8276 PickDrawingElement(button, custom_element.gfx_element);
8277 else if (id == GADGET_ID_CUSTOM_CONTENT)
8278 PickDrawingElement(button, custom_element.content[sx][sy]);
8279 else if (id == GADGET_ID_CUSTOM_MOVE_ENTER)
8280 PickDrawingElement(button, custom_element.move_enter_element);
8281 else if (id == GADGET_ID_CUSTOM_MOVE_LEAVE)
8282 PickDrawingElement(button, custom_element.move_leave_element);
8283 else if (id == GADGET_ID_CUSTOM_CHANGE_TARGET)
8284 PickDrawingElement(button, custom_element_change.target_element);
8285 else if (id == GADGET_ID_CUSTOM_CHANGE_CONTENT)
8286 PickDrawingElement(button, custom_element_change.target_content[sx][sy]);
8287 else if (id == GADGET_ID_CUSTOM_CHANGE_TRIGGER)
8288 PickDrawingElement(button, custom_element_change.trigger_element);
8289 else if (id == GADGET_ID_GROUP_CONTENT)
8290 PickDrawingElement(button, group_element_info.element[sx]);
8291 else if (id == GADGET_ID_RANDOM_BACKGROUND)
8292 PickDrawingElement(button, random_placement_background_element);
8293 else if (id >= GADGET_ID_ELEMENT_CONTENT_0 &&
8294 id <= GADGET_ID_ELEMENT_CONTENT_7)
8296 int i = id - GADGET_ID_ELEMENT_CONTENT_0;
8298 PickDrawingElement(button, level.yamyam_content[i][sx][sy]);
8308 static void HandleCounterButtons(struct GadgetInfo *gi)
8310 int gadget_id = gi->custom_id;
8311 int counter_id = gi->custom_type_id;
8312 int button = gi->event.button;
8313 int *counter_value = counterbutton_info[counter_id].value;
8314 int step = BUTTON_STEPSIZE(button) *
8315 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
8317 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
8319 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
8320 boolean released = (gi->event.type == GD_EVENT_RELEASED);
8321 boolean level_changed = LevelChanged();
8323 if ((level_changed && pressed) || (!level_changed && released))
8326 if (level_changed && !Request("Level has changed! Discard changes ?",
8329 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
8330 ModifyEditorCounter(counter_id, *counter_value);
8335 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
8336 *counter_value = gi->textinput.number_value;
8338 ModifyEditorCounter(counter_id, *counter_value + step);
8342 case ED_COUNTER_ID_ELEMENT_CONTENT:
8343 DrawElementContentAreas();
8346 case ED_COUNTER_ID_GROUP_CONTENT:
8347 DrawGroupElementArea(properties_element);
8348 CopyGroupElementPropertiesToGame(properties_element);
8351 case ED_COUNTER_ID_ENVELOPE_XSIZE:
8352 case ED_COUNTER_ID_ENVELOPE_YSIZE:
8353 DrawEnvelopeTextArea(-1);
8356 case ED_COUNTER_ID_LEVEL_XSIZE:
8357 case ED_COUNTER_ID_LEVEL_YSIZE:
8358 lev_fieldx = level.fieldx;
8359 lev_fieldy = level.fieldy;
8362 case ED_COUNTER_ID_SELECT_LEVEL:
8363 LoadLevel(level_nr);
8366 DrawEditModeWindow();
8373 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
8374 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
8375 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
8376 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
8377 CopyElementPropertiesToGame(properties_element);
8380 static void HandleTextInputGadgets(struct GadgetInfo *gi)
8382 int type_id = gi->custom_type_id;
8384 strcpy(textinput_info[type_id].value, gi->textinput.value);
8386 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
8388 CopyElementPropertiesToGame(properties_element);
8390 ModifyEditorElementList(); /* update changed button info text */
8394 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
8396 int type_id = gi->custom_type_id;
8398 strcpy(textarea_info[type_id].value, gi->textarea.value);
8401 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
8403 int type_id = gi->custom_type_id;
8405 *selectbox_info[type_id].value =
8406 selectbox_info[type_id].options[gi->selectbox.index].value;
8408 if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
8410 element_info[properties_element].current_change_page = gi->selectbox.index;
8412 DrawPropertiesWindow();
8414 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
8415 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
8416 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
8417 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
8418 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
8419 CopyElementPropertiesToGame(properties_element);
8422 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
8424 int type_id = gi->custom_type_id;
8427 if (type_id >= ED_TEXTBUTTON_ID_PROPERTIES_FIRST &&
8428 type_id <= ED_TEXTBUTTON_ID_PROPERTIES_LAST)
8430 edit_mode_properties = gi->custom_type_id;
8432 DrawPropertiesWindow();
8434 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE)
8436 char *template_filename = getDefaultLevelFilename(-1);
8437 boolean new_template = !fileExists(template_filename);
8440 Request("Save this template and kill the old ?", REQ_ASK))
8441 SaveLevelTemplate();
8444 Request("Template saved !", REQ_CONFIRM);
8446 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
8447 custom_element.num_change_pages < MAX_CHANGE_PAGES)
8449 struct ElementInfo *ei = &element_info[properties_element];
8451 setElementChangePages(ei, ei->num_change_pages + 1);
8453 /* set new change page to be new current change page */
8454 ei->current_change_page = ei->num_change_pages - 1;
8455 ei->change = &ei->change_page[ei->current_change_page];
8457 setElementChangeInfoToDefaults(ei->change);
8459 DrawPropertiesWindow();
8461 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
8462 custom_element.num_change_pages > MIN_CHANGE_PAGES)
8464 struct ElementInfo *ei = &element_info[properties_element];
8466 /* copy all change pages after change page to be deleted */
8467 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
8468 ei->change_page[i] = ei->change_page[i + 1];
8470 setElementChangePages(ei, ei->num_change_pages - 1);
8472 DrawPropertiesWindow();
8476 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
8478 int type_id = gi->custom_type_id;
8480 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
8481 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
8483 struct ElementInfo *ei = &element_info[properties_element];
8484 int step = BUTTON_STEPSIZE(gi->event.button);
8486 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
8487 ei->current_change_page += step;
8489 if (ei->current_change_page < 0)
8490 ei->current_change_page = 0;
8491 else if (ei->current_change_page >= ei->num_change_pages)
8492 ei->current_change_page = ei->num_change_pages - 1;
8494 DrawPropertiesWindow();
8496 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
8497 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
8499 struct ElementInfo *ei = &element_info[properties_element];
8500 int current_change_page = ei->current_change_page;
8502 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
8503 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
8504 ei->change_page[current_change_page];
8505 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
8506 ei->change_page[current_change_page] =
8507 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
8509 DrawPropertiesWindow();
8513 static void HandleRadiobuttons(struct GadgetInfo *gi)
8515 *radiobutton_info[gi->custom_type_id].value =
8516 radiobutton_info[gi->custom_type_id].checked_value;
8519 static void HandleCheckbuttons(struct GadgetInfo *gi)
8521 int type_id = gi->custom_type_id;
8523 *checkbutton_info[type_id].value ^= TRUE;
8525 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
8526 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
8527 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
8528 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
8529 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
8530 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
8531 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
8532 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE))
8534 CopyElementPropertiesToGame(properties_element);
8537 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
8539 UpdateCustomElementGraphicGadgets();
8541 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE)
8543 char *template_filename = getDefaultLevelFilename(-1);
8545 if (level.use_custom_template && !fileExists(template_filename))
8547 Request("No level template found !", REQ_CONFIRM);
8549 level.use_custom_template = FALSE;
8550 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
8555 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
8557 DrawEditModeWindow();
8561 static void HandleControlButtons(struct GadgetInfo *gi)
8563 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
8564 static int last_edit_mode = ED_MODE_DRAWING;
8565 static int last_custom_copy_mode = -1;
8566 int id = gi->custom_id;
8567 int button = gi->event.button;
8568 int step = BUTTON_STEPSIZE(button);
8569 int new_element = BUTTON_ELEMENT(button);
8572 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
8573 DrawLevelText(0, 0, 0, TEXT_END);
8575 if (id < ED_NUM_CTRL1_BUTTONS &&
8576 id != GADGET_ID_SINGLE_ITEMS &&
8577 id != GADGET_ID_PROPERTIES &&
8578 id != GADGET_ID_PICK_ELEMENT &&
8579 edit_mode != ED_MODE_DRAWING &&
8580 drawing_function != GADGET_ID_PICK_ELEMENT &&
8581 !(GetKeyModState() & KMOD_Control))
8583 DrawDrawingWindow();
8584 edit_mode = ED_MODE_DRAWING;
8587 /* element copy mode active, but no element button pressed => deactivate */
8588 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
8589 last_custom_copy_mode = -1;
8593 case GADGET_ID_SCROLL_LEFT:
8594 if (level_xpos >= 0)
8596 if (lev_fieldx < ed_fieldx - 2)
8600 if (level_xpos < -1)
8603 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
8605 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8607 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
8608 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
8612 case GADGET_ID_SCROLL_RIGHT:
8613 if (level_xpos <= lev_fieldx - ed_fieldx)
8615 if (lev_fieldx < ed_fieldx - 2)
8619 if (level_xpos > lev_fieldx - ed_fieldx + 1)
8620 level_xpos = lev_fieldx - ed_fieldx + 1;
8622 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
8624 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8626 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
8627 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
8631 case GADGET_ID_SCROLL_UP:
8632 if (level_ypos >= 0)
8634 if (lev_fieldy < ed_fieldy - 2)
8638 if (level_ypos < -1)
8641 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
8643 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8645 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
8646 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
8650 case GADGET_ID_SCROLL_DOWN:
8651 if (level_ypos <= lev_fieldy - ed_fieldy)
8653 if (lev_fieldy < ed_fieldy - 2)
8657 if (level_ypos > lev_fieldy - ed_fieldy + 1)
8658 level_ypos = lev_fieldy - ed_fieldy + 1;
8660 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_UP);
8662 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8664 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
8665 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
8669 case GADGET_ID_SCROLL_HORIZONTAL:
8670 level_xpos = gi->event.item_position - 1;
8671 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8674 case GADGET_ID_SCROLL_VERTICAL:
8675 level_ypos = gi->event.item_position - 1;
8676 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8679 case GADGET_ID_SCROLL_LIST_UP:
8680 case GADGET_ID_SCROLL_LIST_DOWN:
8681 case GADGET_ID_SCROLL_LIST_VERTICAL:
8682 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
8683 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
8686 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
8687 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
8689 if (element_shift < 0)
8691 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
8692 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
8694 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
8695 GDI_SCROLLBAR_ITEM_POSITION,
8696 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
8699 ModifyEditorElementList();
8703 case GADGET_ID_WRAP_LEFT:
8704 WrapLevel(-step, 0);
8707 case GADGET_ID_WRAP_RIGHT:
8711 case GADGET_ID_WRAP_UP:
8712 WrapLevel(0, -step);
8715 case GADGET_ID_WRAP_DOWN:
8719 case GADGET_ID_SINGLE_ITEMS:
8720 case GADGET_ID_CONNECTED_ITEMS:
8721 case GADGET_ID_LINE:
8723 case GADGET_ID_TEXT:
8724 case GADGET_ID_RECTANGLE:
8725 case GADGET_ID_FILLED_BOX:
8726 case GADGET_ID_FLOOD_FILL:
8727 case GADGET_ID_GRAB_BRUSH:
8728 case GADGET_ID_PICK_ELEMENT:
8729 if (drawing_function != GADGET_ID_PICK_ELEMENT)
8730 last_drawing_function = drawing_function;
8731 drawing_function = id;
8732 draw_with_brush = FALSE;
8735 case GADGET_ID_RANDOM_PLACEMENT:
8736 RandomPlacement(new_element);
8739 case GADGET_ID_PROPERTIES:
8740 if (edit_mode != ED_MODE_PROPERTIES)
8742 properties_element = new_element;
8743 DrawPropertiesWindow();
8744 edit_mode = ED_MODE_PROPERTIES;
8746 last_level_drawing_function = drawing_function;
8747 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
8752 DrawDrawingWindow();
8753 edit_mode = ED_MODE_DRAWING;
8755 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
8760 case GADGET_ID_CUSTOM_COPY_FROM:
8761 case GADGET_ID_CUSTOM_COPY_TO:
8762 case GADGET_ID_CUSTOM_EXCHANGE:
8763 last_custom_copy_mode = id;
8764 last_drawing_function = drawing_function;
8767 case GADGET_ID_CUSTOM_COPY:
8768 CopyCustomElement(properties_element, -1, id);
8771 case GADGET_ID_CUSTOM_PASTE:
8772 CopyCustomElement(-1, properties_element, id);
8775 case GADGET_ID_UNDO:
8776 if (undo_buffer_steps == 0)
8778 Request("Undo buffer empty !", REQ_CONFIRM);
8782 if (edit_mode != ED_MODE_DRAWING)
8784 DrawDrawingWindow();
8785 edit_mode = ED_MODE_DRAWING;
8788 undo_buffer_position =
8789 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
8790 undo_buffer_steps--;
8792 for (x = 0; x < lev_fieldx; x++)
8793 for (y = 0; y < lev_fieldy; y++)
8794 Feld[x][y] = UndoBuffer[undo_buffer_position][x][y];
8795 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos,level_ypos);
8798 case GADGET_ID_INFO:
8799 if (edit_mode != ED_MODE_INFO)
8801 last_edit_mode = edit_mode;
8802 edit_mode = ED_MODE_INFO;
8804 DrawLevelInfoWindow();
8808 edit_mode = last_edit_mode;
8810 DrawEditModeWindow();
8814 case GADGET_ID_CLEAR:
8815 if (edit_mode != ED_MODE_DRAWING)
8817 DrawDrawingWindow();
8818 edit_mode = ED_MODE_DRAWING;
8821 for (x = 0; x < MAX_LEV_FIELDX; x++)
8822 for (y = 0; y < MAX_LEV_FIELDY; y++)
8823 Feld[x][y] = (button == 1 ? EL_EMPTY : new_element);
8824 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
8826 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8829 case GADGET_ID_SAVE:
8830 if (leveldir_current->readonly)
8832 Request("This level is read only !", REQ_CONFIRM);
8836 if (!LevelContainsPlayer)
8837 Request("No Level without Gregor Mc Duffin please !", REQ_CONFIRM);
8840 char *level_filename = getDefaultLevelFilename(level_nr);
8841 boolean new_level = !fileExists(level_filename);
8844 Request("Save this level and kill the old ?", REQ_ASK))
8846 CopyPlayfield(Feld, level.field);
8848 SaveLevel(level_nr);
8852 Request("Level saved !", REQ_CONFIRM);
8856 case GADGET_ID_TEST:
8857 if (!LevelContainsPlayer)
8858 Request("No Level without Gregor Mc Duffin please !", REQ_CONFIRM);
8862 level.game_version = GAME_VERSION_ACTUAL;
8864 CopyPlayfield(level.field, FieldBackup);
8865 CopyPlayfield(Feld, level.field);
8867 UnmapLevelEditorGadgets();
8868 UndrawSpecialEditorDoor();
8870 CloseDoor(DOOR_CLOSE_ALL);
8872 DrawCompleteVideoDisplay();
8874 if (setup.autorecord)
8875 TapeStartRecording();
8877 level_editor_test_game = TRUE;
8878 game_status = GAME_MODE_PLAYING;
8884 case GADGET_ID_EXIT:
8885 RequestExitLevelEditor(TRUE); /* if level has changed, ask user */
8889 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
8890 id <= GADGET_ID_ELEMENTLIST_LAST)
8892 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
8893 int new_element = editor_elements[element_position + element_shift];
8895 if (last_custom_copy_mode != -1)
8897 if (CopyCustomElement(properties_element, new_element,
8898 last_custom_copy_mode))
8900 ClickOnGadget(level_editor_gadget[last_drawing_function],
8903 last_custom_copy_mode = -1;
8909 PickDrawingElement(button, new_element);
8911 if (!stick_element_properties_window &&
8912 drawing_function != GADGET_ID_PICK_ELEMENT &&
8913 !(GetKeyModState() & KMOD_Control))
8915 properties_element = new_element;
8916 if (edit_mode == ED_MODE_PROPERTIES)
8917 DrawPropertiesWindow();
8920 if (drawing_function == GADGET_ID_PICK_ELEMENT)
8921 ClickOnGadget(level_editor_gadget[last_drawing_function],
8925 else if (gi->event.type == GD_EVENT_PRESSED)
8926 printf("default: HandleControlButtons: GD_EVENT_PRESSED(%d)\n", id);
8927 else if (gi->event.type == GD_EVENT_RELEASED)
8928 printf("default: HandleControlButtons: GD_EVENT_RELEASED(%d)\n", id);
8929 else if (gi->event.type == GD_EVENT_MOVING)
8930 printf("default: HandleControlButtons: GD_EVENT_MOVING(%d)\n", id);
8932 printf("default: HandleControlButtons: ? (id == %d)\n", id);
8938 void HandleLevelEditorKeyInput(Key key)
8940 char letter = getCharFromKey(key);
8941 int button = MB_LEFTBUTTON;
8943 if (drawing_function == GADGET_ID_TEXT &&
8944 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
8947 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
8948 else if (key == KSYM_Delete || key == KSYM_BackSpace)
8949 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
8950 else if (key == KSYM_Return)
8951 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
8952 else if (key == KSYM_Escape)
8953 DrawLevelText(0, 0, 0, TEXT_END);
8955 else if (button_status == MB_RELEASED)
8957 int i, id = GADGET_ID_NONE;
8962 id = GADGET_ID_SCROLL_LEFT;
8965 id = GADGET_ID_SCROLL_RIGHT;
8968 id = GADGET_ID_SCROLL_UP;
8971 id = GADGET_ID_SCROLL_DOWN;
8974 id = GADGET_ID_SCROLL_LIST_UP;
8975 button = MB_RIGHTBUTTON;
8977 case KSYM_Page_Down:
8978 id = GADGET_ID_SCROLL_LIST_DOWN;
8979 button = MB_RIGHTBUTTON;
8983 if (edit_mode == ED_MODE_DRAWING)
8985 RequestExitLevelEditor(setup.ask_on_escape);
8989 DrawDrawingWindow();
8990 edit_mode = ED_MODE_DRAWING;
8998 if (id != GADGET_ID_NONE)
8999 ClickOnGadget(level_editor_gadget[id], button);
9000 else if (letter == '.')
9001 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
9002 else if (key == KSYM_Return || key == setup.shortcut.toggle_pause)
9003 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
9005 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
9006 if (letter && letter == control_info[i].shortcut)
9007 if (!anyTextGadgetActive())
9008 ClickOnGadget(level_editor_gadget[i], button);
9012 void HandleLevelEditorIdle()
9014 static unsigned long action_delay = 0;
9015 unsigned long action_delay_value = GameFrameDelay;
9016 int xpos = 1, ypos = 2;
9018 if (edit_mode != ED_MODE_PROPERTIES)
9021 if (!DelayReached(&action_delay, action_delay_value))
9024 DrawGraphicAnimationExt(drawto,
9026 SY + ypos * TILEY + MINI_TILEY / 2,
9027 el2img(properties_element), -1, NO_MASKING);
9029 MarkTileDirty(xpos, ypos);
9030 MarkTileDirty(xpos, ypos + 1);
9032 FrameCounter++; /* increase animation frame counter */
9035 void ClearEditorGadgetInfoText()
9037 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
9040 void HandleEditorGadgetInfoText(void *ptr)
9042 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
9043 char infotext[MAX_OUTPUT_LINESIZE + 1];
9044 char shortcut[MAX_OUTPUT_LINESIZE + 1];
9045 int max_infotext_len = getMaxInfoTextLength();
9047 if (game_status != GAME_MODE_EDITOR)
9050 ClearEditorGadgetInfoText();
9052 if (gi->event.type == GD_EVENT_INFO_LEAVING)
9055 /* misuse this function to delete brush cursor, if needed */
9056 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
9057 DeleteBrushFromCursor();
9059 if (gi == NULL || gi->info_text == NULL)
9062 strncpy(infotext, gi->info_text, max_infotext_len);
9063 infotext[max_infotext_len] = '\0';
9065 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
9067 int key = control_info[gi->custom_id].shortcut;
9071 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS) /* special case 1 */
9072 sprintf(shortcut, " ('.' or '%c')", key);
9073 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT) /* special case 2 */
9074 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
9075 else if (gi->custom_id == GADGET_ID_TEST) /* special case 3 */
9076 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
9077 else /* normal case */
9078 sprintf(shortcut, " ('%s%c')",
9079 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
9081 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
9082 strcat(infotext, shortcut);
9086 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, FONT_TEXT_2);
9089 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
9091 static int start_lx, start_ly;
9092 int id = gi->custom_id;
9093 int sx = gi->event.x;
9094 int sy = gi->event.y;
9095 int lx = sx + level_xpos;
9096 int ly = sy + level_ypos;
9097 int min_sx = 0, min_sy = 0;
9098 int max_sx = gi->drawing.area_xsize - 1;
9099 int max_sy = gi->drawing.area_ysize - 1;
9100 int actual_drawing_function = drawing_function;
9101 int max_infotext_len = getMaxInfoTextLength();
9102 char infotext[MAX_OUTPUT_LINESIZE + 1];
9105 infotext[0] = '\0'; /* start with empty info text */
9107 /* pressed Control key: simulate picking element */
9108 if (GetKeyModState() & KMOD_Control)
9109 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
9111 ClearEditorGadgetInfoText();
9113 if (gi->event.type == GD_EVENT_INFO_LEAVING)
9116 /* make sure to stay inside drawing area boundaries */
9117 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
9118 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
9120 if (id == GADGET_ID_DRAWING_LEVEL)
9124 int min_lx = 0, min_ly = 0;
9125 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
9127 /* get positions inside level field */
9128 lx = sx + level_xpos;
9129 ly = sy + level_ypos;
9131 /* make sure to stay inside level field boundaries */
9132 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
9133 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
9135 /* correct drawing area positions accordingly */
9136 sx = lx - level_xpos;
9137 sy = ly - level_ypos;
9140 if (IN_ED_FIELD(sx,sy) && IN_LEV_FIELD(lx, ly))
9142 if (button_status) /* if (gi->state == GD_BUTTON_PRESSED) */
9144 if (gi->event.type == GD_EVENT_PRESSED)
9150 switch (actual_drawing_function)
9152 case GADGET_ID_SINGLE_ITEMS:
9153 text = "Drawing single items";
9155 case GADGET_ID_CONNECTED_ITEMS:
9156 text = "Drawing connected items";
9158 case GADGET_ID_LINE:
9159 text = "Drawing line";
9162 text = "Drawing arc";
9164 case GADGET_ID_TEXT:
9165 text = "Setting text cursor";
9167 case GADGET_ID_RECTANGLE:
9168 text = "Drawing rectangle";
9170 case GADGET_ID_FILLED_BOX:
9171 text = "Drawing filled box";
9173 case GADGET_ID_FLOOD_FILL:
9174 text = "Flood fill";
9176 case GADGET_ID_GRAB_BRUSH:
9177 text = "Grabbing brush";
9179 case GADGET_ID_PICK_ELEMENT:
9180 text = "Picking element";
9184 text = "Drawing position";
9189 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
9190 sprintf(infotext, "%s: %d, %d", text, lx, ly);
9192 sprintf(infotext, "%s: %d, %d", text,
9193 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
9195 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
9196 DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
9197 "%s: %d, %d", infotext, lx, ly);
9199 DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
9200 "%s: %d, %d", infotext,
9201 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
9205 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
9206 strncpy(infotext, getElementInfoText(Feld[lx][ly]), max_infotext_len);
9208 sprintf(infotext, "Level position: %d, %d", lx, ly);
9210 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
9211 DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
9212 "%s", getElementInfoText(Feld[lx][ly]));
9214 DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
9215 "Level position: %d, %d", lx, ly);
9219 /* misuse this function to draw brush cursor, if needed */
9220 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
9222 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
9223 CopyBrushToCursor(sx, sy);
9225 DeleteBrushFromCursor();
9228 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
9230 int element = EL_EMPTY;
9232 if (id == GADGET_ID_AMOEBA_CONTENT)
9233 element = level.amoeba_content;
9234 else if (id == GADGET_ID_CUSTOM_GRAPHIC)
9235 element = custom_element.gfx_element;
9236 else if (id == GADGET_ID_CUSTOM_CONTENT)
9237 element = custom_element.content[sx][sy];
9238 else if (id == GADGET_ID_CUSTOM_MOVE_ENTER)
9239 element = custom_element.move_enter_element;
9240 else if (id == GADGET_ID_CUSTOM_MOVE_LEAVE)
9241 element = custom_element.move_leave_element;
9242 else if (id == GADGET_ID_CUSTOM_CHANGE_TARGET)
9243 element = custom_element_change.target_element;
9244 else if (id == GADGET_ID_CUSTOM_CHANGE_CONTENT)
9245 element = custom_element_change.target_content[sx][sy];
9246 else if (id == GADGET_ID_CUSTOM_CHANGE_TRIGGER)
9247 element = custom_element_change.trigger_element;
9248 else if (id == GADGET_ID_GROUP_CONTENT)
9249 element = group_element_info.element[sx];
9250 else if (id == GADGET_ID_RANDOM_BACKGROUND)
9251 element = random_placement_background_element;
9252 else if (id >= GADGET_ID_ELEMENT_CONTENT_0 &&
9253 id <= GADGET_ID_ELEMENT_CONTENT_7)
9254 element = level.yamyam_content[id - GADGET_ID_ELEMENT_CONTENT_0][sx][sy];
9256 strncpy(infotext, getElementInfoText(element), max_infotext_len);
9260 if (id == GADGET_ID_AMOEBA_CONTENT)
9261 strcpy(infotext, "Amoeba content");
9262 else if (id == GADGET_ID_CUSTOM_GRAPHIC)
9263 strcpy(infotext, "Custom graphic element");
9264 else if (id == GADGET_ID_CUSTOM_CONTENT)
9265 sprintf(infotext, "Custom element content position: %d, %d", sx, sy);
9266 else if (id == GADGET_ID_CUSTOM_MOVE_ENTER)
9267 strcpy(infotext, "Element that can be digged/collected");
9268 else if (id == GADGET_ID_CUSTOM_MOVE_LEAVE)
9269 strcpy(infotext, "Element that will be left behind");
9270 else if (id == GADGET_ID_CUSTOM_CHANGE_TARGET)
9271 strcpy(infotext, "New element after change");
9272 else if (id == GADGET_ID_CUSTOM_CHANGE_CONTENT)
9273 strcpy(infotext, "New extended elements after change");
9274 else if (id == GADGET_ID_CUSTOM_CHANGE_TRIGGER)
9275 strcpy(infotext, "Other element triggering change");
9276 else if (id == GADGET_ID_GROUP_CONTENT)
9277 sprintf(infotext, "Group element position: %d", sx + 1);
9278 else if (id == GADGET_ID_RANDOM_BACKGROUND)
9279 strcpy(infotext, "Random placement background");
9280 else if (id >= GADGET_ID_ELEMENT_CONTENT_0 &&
9281 id <= GADGET_ID_ELEMENT_CONTENT_7)
9282 sprintf(infotext, "Content area %d position: %d, %d",
9283 id - GADGET_ID_ELEMENT_CONTENT_0 + 1, sx, sy);
9286 infotext[max_infotext_len] = '\0';
9288 if (strlen(infotext) > 0)
9289 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, infotext);
9292 void RequestExitLevelEditor(boolean ask_if_level_has_changed)
9294 if (!ask_if_level_has_changed ||
9296 Request("Level has changed! Exit without saving ?",
9297 REQ_ASK | REQ_STAY_OPEN))
9300 CloseDoor(DOOR_CLOSE_1);
9301 SetDoorState(DOOR_CLOSE_2);
9303 CloseDoor(DOOR_CLOSE_ALL);
9305 game_status = GAME_MODE_MAIN;
9310 CloseDoor(DOOR_CLOSE_1);
9311 BlitBitmap(bitmap_db_door, bitmap_db_door,
9312 DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1, DXSIZE,DYSIZE,
9313 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
9314 OpenDoor(DOOR_OPEN_1);