1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // http://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
14 #include "libgame/libgame.h"
25 #define INFOTEXT_UNKNOWN_ELEMENT "unknown"
29 -----------------------------------------------------------------------------
30 screen and artwork graphic pixel position definitions
31 -----------------------------------------------------------------------------
34 /* values for the control window */
35 #define ED_CTRL1_BUTTONS_HORIZ 4
36 #define ED_CTRL1_BUTTONS_VERT 4
37 #define ED_CTRL2_BUTTONS_HORIZ 3
38 #define ED_CTRL2_BUTTONS_VERT 2
39 #define ED_CTRL3_BUTTONS_HORIZ 3
40 #define ED_CTRL3_BUTTONS_VERT 1
41 #define ED_CTRL4_BUTTONS_HORIZ 2
42 #define ED_CTRL4_BUTTONS_VERT 1
43 #define ED_CTRL5_BUTTONS_HORIZ 1
44 #define ED_CTRL5_BUTTONS_VERT 1
46 #define ED_NUM_CTRL1_BUTTONS (ED_CTRL1_BUTTONS_HORIZ * ED_CTRL1_BUTTONS_VERT)
47 #define ED_NUM_CTRL2_BUTTONS (ED_CTRL2_BUTTONS_HORIZ * ED_CTRL2_BUTTONS_VERT)
48 #define ED_NUM_CTRL3_BUTTONS (ED_CTRL3_BUTTONS_HORIZ * ED_CTRL3_BUTTONS_VERT)
49 #define ED_NUM_CTRL4_BUTTONS (ED_CTRL4_BUTTONS_HORIZ * ED_CTRL4_BUTTONS_VERT)
50 #define ED_NUM_CTRL5_BUTTONS (ED_CTRL5_BUTTONS_HORIZ * ED_CTRL5_BUTTONS_VERT)
51 #define ED_NUM_CTRL1_2_BUTTONS (ED_NUM_CTRL1_BUTTONS + ED_NUM_CTRL2_BUTTONS)
52 #define ED_NUM_CTRL1_3_BUTTONS (ED_NUM_CTRL1_2_BUTTONS + ED_NUM_CTRL3_BUTTONS)
53 #define ED_NUM_CTRL1_4_BUTTONS (ED_NUM_CTRL1_3_BUTTONS + ED_NUM_CTRL4_BUTTONS)
54 #define ED_NUM_CTRL_BUTTONS (ED_NUM_CTRL1_4_BUTTONS + ED_NUM_CTRL5_BUTTONS)
56 /* values for the element list */
57 #define ED_ELEMENTLIST_XPOS (editor.palette.x)
58 #define ED_ELEMENTLIST_YPOS (editor.palette.y)
59 #define ED_ELEMENTLIST_XSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].width)
60 #define ED_ELEMENTLIST_YSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].height)
61 #define ED_ELEMENTLIST_BUTTONS_HORIZ (editor.palette.cols)
62 #define ED_ELEMENTLIST_BUTTONS_VERT (editor.palette.rows)
63 #define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \
64 ED_ELEMENTLIST_BUTTONS_VERT)
66 /* standard distances */
67 #define ED_BORDER_SIZE 3
68 #define ED_BORDER_TEXT_XSIZE 5
69 #define ED_BORDER_AREA_YSIZE 1
70 #define ED_ELEMENT_BORDER 8
71 #define ED_ELEMENT_BORDER_INPUT 4
73 #define ED_GADGET_DISTANCE 2
74 #define ED_GADGET_TEXT_DISTANCE (2 * ED_GADGET_DISTANCE)
75 #define ED_DRAWINGAREA_TEXT_DISTANCE (ED_GADGET_TEXT_DISTANCE + \
78 /* values for the settings windows */
79 #define ED_LEVEL_SETTINGS_XSTART (3 * MINI_TILEX / 2)
80 #define ED_LEVEL_SETTINGS_YSTART (7 * MINI_TILEY)
82 #define ED_ELEMENT_SETTINGS_XSTART (3 * MINI_TILEX / 2)
83 #define ED_ELEMENT_SETTINGS_YSTART (10 * MINI_TILEY)
85 #define ED_XOFFSET_CHECKBOX (ED_CHECKBUTTON_XSIZE + \
86 2 * ED_GADGET_DISTANCE)
88 #define ED_SETTINGS_XOFFSET ED_XOFFSET_CHECKBOX
89 #define ED_SETTINGS_YOFFSET (3 * MINI_TILEY / 2)
90 #define ED_SETTINGS_TAB_XOFFSET 124
92 #define ED_LEVEL_SETTINGS_XPOS(n) (ED_LEVEL_SETTINGS_XSTART + \
93 (n) * ED_SETTINGS_XOFFSET)
94 #define ED_LEVEL_SETTINGS_YPOS(n) (ED_LEVEL_SETTINGS_YSTART + \
95 (n) * ED_SETTINGS_YOFFSET)
97 #define ED_ELEMENT_SETTINGS_XPOS(n) (ED_ELEMENT_SETTINGS_XSTART + \
98 (n) * ED_SETTINGS_XOFFSET)
99 #define ED_ELEMENT_SETTINGS_YPOS(n) (ED_ELEMENT_SETTINGS_YSTART + \
100 (n) * ED_SETTINGS_YOFFSET)
102 #define ED_LEVEL_SETTINGS_TABS_XPOS(n) (ED_LEVEL_SETTINGS_XPOS(0) + \
103 (n) * ED_SETTINGS_TAB_XOFFSET)
104 #define ED_LEVEL_SETTINGS_TABS_YPOS(n) (ED_LEVEL_SETTINGS_YSTART - \
107 #define ED_ELEMENT_SETTINGS_TABS_XPOS(n) (ED_ELEMENT_SETTINGS_XPOS(0) + \
108 (n) * ED_SETTINGS_TAB_XOFFSET)
109 #define ED_ELEMENT_SETTINGS_TABS_YPOS(n) (ED_ELEMENT_SETTINGS_YSTART - \
112 #define ED_SETTINGS1_YPOS MINI_TILEY
113 #define ED_SETTINGS2_XPOS MINI_TILEX
114 #define ED_SETTINGS2_YPOS (ED_SETTINGS1_YPOS + 12 * TILEY - 2)
116 /* values for counter gadgets */
117 #define ED_COUNTER_YSTART (ED_SETTINGS1_YPOS + 2 * TILEY)
118 #define ED_COUNTER_YDISTANCE (3 * MINI_TILEY)
119 #define ED_COUNTER_YPOS(n) (ED_COUNTER_YSTART + \
120 (n) * ED_COUNTER_YDISTANCE)
121 #define ED_COUNTER2_YPOS(n) (ED_COUNTER_YSTART + \
122 (n) * ED_COUNTER_YDISTANCE - 2)
124 /* values for element content drawing areas */
125 #define ED_AREA_1X1_SETTINGS_XPOS(n) (ED_ELEMENT_SETTINGS_XPOS(n))
126 #define ED_AREA_1X1_SETTINGS_YPOS(n) (ED_ELEMENT_SETTINGS_YPOS(n) + \
129 #define ED_AREA_3X3_SETTINGS_XPOS(n) (ED_ELEMENT_SETTINGS_XPOS(n))
130 #define ED_AREA_3X3_SETTINGS_YPOS(n) (ED_ELEMENT_SETTINGS_YPOS(n) + \
131 ED_GADGET_DISTANCE - MINI_TILEY)
134 #define ED_AREA_YAMYAM_CONTENT_XPOS(n) (2 * MINI_TILEX + \
135 5 * ((n) % 4) * MINI_TILEX)
136 #define ED_AREA_YAMYAM_CONTENT_YPOS(n) (11 * ED_SETTINGS_YOFFSET + \
137 6 * ((n) / 4) * MINI_TILEY)
139 /* magic ball content */
140 #define ED_AREA_MAGIC_BALL_CONTENT_XPOS(n) (2 * MINI_TILEX + \
141 5 * ((n) % 4) * MINI_TILEX)
142 #define ED_AREA_MAGIC_BALL_CONTENT_YPOS(n) (12 * ED_SETTINGS_YOFFSET + \
143 6 * ((n) / 4) * MINI_TILEY)
145 /* values for scrolling gadgets for drawing area */
146 #define ED_SCROLLBUTTON_XPOS 24
147 #define ED_SCROLLBUTTON_YPOS 0
148 #define ED_SCROLLBAR_XPOS 24
149 #define ED_SCROLLBAR_YPOS 64
151 #define ED_SCROLLBUTTON_XSIZE 16
152 #define ED_SCROLLBUTTON_YSIZE 16
154 #define ED_SCROLL_UP_XPOS (SXSIZE - ED_SCROLLBUTTON_XSIZE)
155 #define ED_SCROLL_UP_YPOS (0)
156 #define ED_SCROLL_DOWN_XPOS ED_SCROLL_UP_XPOS
157 #define ED_SCROLL_DOWN_YPOS (SYSIZE - 3 * ED_SCROLLBUTTON_YSIZE)
158 #define ED_SCROLL_LEFT_XPOS (0)
159 #define ED_SCROLL_LEFT_YPOS (SYSIZE - 2 * ED_SCROLLBUTTON_YSIZE)
160 #define ED_SCROLL_RIGHT_XPOS (SXSIZE - 2 * ED_SCROLLBUTTON_XSIZE)
161 #define ED_SCROLL_RIGHT_YPOS ED_SCROLL_LEFT_YPOS
162 #define ED_SCROLL_HORIZONTAL_XPOS (ED_SCROLL_LEFT_XPOS + \
163 ED_SCROLLBUTTON_XSIZE)
164 #define ED_SCROLL_HORIZONTAL_YPOS ED_SCROLL_LEFT_YPOS
165 #define ED_SCROLL_HORIZONTAL_XSIZE (SXSIZE - 3 * ED_SCROLLBUTTON_XSIZE)
166 #define ED_SCROLL_HORIZONTAL_YSIZE ED_SCROLLBUTTON_YSIZE
167 #define ED_SCROLL_VERTICAL_XPOS ED_SCROLL_UP_XPOS
168 #define ED_SCROLL_VERTICAL_YPOS (ED_SCROLL_UP_YPOS + \
169 ED_SCROLLBUTTON_YSIZE)
170 #define ED_SCROLL_VERTICAL_XSIZE ED_SCROLLBUTTON_XSIZE
171 #define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - 4 * ED_SCROLLBUTTON_YSIZE)
173 /* values for scrolling gadgets for element list */
174 #define ED_SCROLLBUTTON2_XPOS 50
175 #define ED_SCROLLBUTTON2_YPOS 0
176 #define ED_SCROLLBAR2_XPOS 50
177 #define ED_SCROLLBAR2_YPOS 20
179 #define ED_SCROLLBUTTON2_XSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].width)
180 #define ED_SCROLLBUTTON2_YSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].height)
182 #define ED_SCROLL2_UP_XPOS (ED_ELEMENTLIST_XPOS + \
183 ED_ELEMENTLIST_BUTTONS_HORIZ * \
184 ED_ELEMENTLIST_XSIZE)
185 #define ED_SCROLL2_UP_YPOS ED_ELEMENTLIST_YPOS
186 #define ED_SCROLL2_DOWN_XPOS ED_SCROLL2_UP_XPOS
187 #define ED_SCROLL2_DOWN_YPOS (ED_SCROLL2_UP_YPOS + \
188 ED_ELEMENTLIST_BUTTONS_VERT * \
189 ED_ELEMENTLIST_YSIZE - \
190 ED_SCROLLBUTTON2_YSIZE)
191 #define ED_SCROLL2_VERTICAL_XPOS ED_SCROLL2_UP_XPOS
192 #define ED_SCROLL2_VERTICAL_YPOS (ED_SCROLL2_UP_YPOS + \
193 ED_SCROLLBUTTON2_YSIZE)
194 #define ED_SCROLL2_VERTICAL_XSIZE ED_SCROLLBUTTON2_XSIZE
195 #define ED_SCROLL2_VERTICAL_YSIZE (ED_ELEMENTLIST_BUTTONS_VERT * \
196 ED_ELEMENTLIST_YSIZE - \
197 2 * ED_SCROLLBUTTON2_YSIZE)
199 /* values for checkbutton gadgets */
200 #define ED_CHECKBUTTON_XSIZE ED_BUTTON_COUNT_XSIZE
201 #define ED_CHECKBUTTON_YSIZE ED_BUTTON_COUNT_YSIZE
202 #define ED_CHECKBUTTON_UNCHECKED_XPOS ED_BUTTON_MINUS_XPOS
203 #define ED_CHECKBUTTON_CHECKED_XPOS ED_BUTTON_PLUS_XPOS
204 #define ED_CHECKBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 22)
205 #define ED_RADIOBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 44)
206 #define ED_STICKYBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 66)
208 /* values for some special graphic buttons */
209 #define ED_COPY_CHANGE_PAGE_XPOS 25
210 #define ED_COPY_CHANGE_PAGE_YPOS 50
211 #define ED_PASTE_CHANGE_PAGE_XPOS 25
212 #define ED_PASTE_CHANGE_PAGE_YPOS 70
214 /* some values for text input, selectbox and counter gadgets */
215 #define ED_BUTTON_COUNT_YPOS 60
216 #define ED_BUTTON_COUNT_XSIZE 20
217 #define ED_BUTTON_COUNT_YSIZE 20
218 #define ED_WIN_COUNT_XPOS (2 + ED_BUTTON_COUNT_XSIZE + 2)
219 #define ED_WIN_COUNT_YPOS ED_BUTTON_COUNT_YPOS
220 #define ED_WIN_COUNT_XSIZE 52
221 #define ED_WIN_COUNT_YSIZE ED_BUTTON_COUNT_YSIZE
223 #define ED_BUTTON_MINUS_XPOS 2
224 #define ED_BUTTON_MINUS_YPOS ED_BUTTON_COUNT_YPOS
225 #define ED_BUTTON_MINUS_XSIZE ED_BUTTON_COUNT_XSIZE
226 #define ED_BUTTON_MINUS_YSIZE ED_BUTTON_COUNT_YSIZE
227 #define ED_BUTTON_PLUS_XPOS (ED_WIN_COUNT_XPOS + \
228 ED_WIN_COUNT_XSIZE + 2)
229 #define ED_BUTTON_PLUS_YPOS ED_BUTTON_COUNT_YPOS
230 #define ED_BUTTON_PLUS_XSIZE ED_BUTTON_COUNT_XSIZE
231 #define ED_BUTTON_PLUS_YSIZE ED_BUTTON_COUNT_YSIZE
233 #define ED_SELECTBOX_XPOS ED_WIN_COUNT_XPOS
234 #define ED_SELECTBOX_YPOS (ED_WIN_COUNT_YPOS + \
235 2 + ED_WIN_COUNT_YSIZE)
236 #define ED_SELECTBOX_XSIZE ED_WIN_COUNT_XSIZE
237 #define ED_SELECTBOX_YSIZE ED_WIN_COUNT_YSIZE
239 #define ED_SELECTBOX_BUTTON_XSIZE 14
241 #define ED_TEXTBUTTON_XPOS ED_WIN_COUNT_XPOS
242 #define ED_TEXTBUTTON_YPOS (ED_WIN_COUNT_YPOS + \
243 4 * (2 + ED_WIN_COUNT_YSIZE))
244 #define ED_TEXTBUTTON_INACTIVE_YPOS ED_TEXTBUTTON_YPOS
246 #define ED_TEXTBUTTON_TAB_XPOS ED_WIN_COUNT_XPOS
247 #define ED_TEXTBUTTON_TAB_YPOS (ED_WIN_COUNT_YPOS + \
248 2 * (2 + ED_WIN_COUNT_YSIZE))
249 #define ED_TEXTBUTTON_TAB_INACTIVE_YPOS (ED_WIN_COUNT_YPOS + \
250 3 * (2 + ED_WIN_COUNT_YSIZE))
252 #define ED_TEXTBUTTON_XSIZE ED_WIN_COUNT_XSIZE
253 #define ED_TEXTBUTTON_YSIZE ED_WIN_COUNT_YSIZE
255 /* values for ClearEditorGadgetInfoText() and HandleEditorGadgetInfoText() */
256 #define INFOTEXT_XPOS SX
257 #define INFOTEXT_YPOS (SY + SYSIZE - MINI_TILEX + 2)
258 #define INFOTEXT_XSIZE SXSIZE
259 #define INFOTEXT_YSIZE MINI_TILEY
263 -----------------------------------------------------------------------------
264 editor gadget definitions
265 -----------------------------------------------------------------------------
268 /* drawing toolbox buttons */
269 #define GADGET_ID_NONE -1
270 #define GADGET_ID_TOOLBOX_FIRST 0
272 #define GADGET_ID_SINGLE_ITEMS (GADGET_ID_TOOLBOX_FIRST + 0)
273 #define GADGET_ID_CONNECTED_ITEMS (GADGET_ID_TOOLBOX_FIRST + 1)
274 #define GADGET_ID_LINE (GADGET_ID_TOOLBOX_FIRST + 2)
275 #define GADGET_ID_ARC (GADGET_ID_TOOLBOX_FIRST + 3)
276 #define GADGET_ID_RECTANGLE (GADGET_ID_TOOLBOX_FIRST + 4)
277 #define GADGET_ID_FILLED_BOX (GADGET_ID_TOOLBOX_FIRST + 5)
278 #define GADGET_ID_WRAP_UP (GADGET_ID_TOOLBOX_FIRST + 6)
279 #define GADGET_ID_TEXT (GADGET_ID_TOOLBOX_FIRST + 7)
280 #define GADGET_ID_FLOOD_FILL (GADGET_ID_TOOLBOX_FIRST + 8)
281 #define GADGET_ID_WRAP_LEFT (GADGET_ID_TOOLBOX_FIRST + 9)
282 #define GADGET_ID_ZOOM (GADGET_ID_TOOLBOX_FIRST + 10)
283 #define GADGET_ID_WRAP_RIGHT (GADGET_ID_TOOLBOX_FIRST + 11)
284 #define GADGET_ID_RANDOM_PLACEMENT (GADGET_ID_TOOLBOX_FIRST + 12)
285 #define GADGET_ID_GRAB_BRUSH (GADGET_ID_TOOLBOX_FIRST + 13)
286 #define GADGET_ID_WRAP_DOWN (GADGET_ID_TOOLBOX_FIRST + 14)
287 #define GADGET_ID_PICK_ELEMENT (GADGET_ID_TOOLBOX_FIRST + 15)
289 #define GADGET_ID_UNDO (GADGET_ID_TOOLBOX_FIRST + 16)
290 #define GADGET_ID_INFO (GADGET_ID_TOOLBOX_FIRST + 17)
291 #define GADGET_ID_SAVE (GADGET_ID_TOOLBOX_FIRST + 18)
292 #define GADGET_ID_CLEAR (GADGET_ID_TOOLBOX_FIRST + 19)
293 #define GADGET_ID_TEST (GADGET_ID_TOOLBOX_FIRST + 20)
294 #define GADGET_ID_EXIT (GADGET_ID_TOOLBOX_FIRST + 21)
296 #define GADGET_ID_CUSTOM_COPY_FROM (GADGET_ID_TOOLBOX_FIRST + 22)
297 #define GADGET_ID_CUSTOM_COPY_TO (GADGET_ID_TOOLBOX_FIRST + 23)
298 #define GADGET_ID_CUSTOM_EXCHANGE (GADGET_ID_TOOLBOX_FIRST + 24)
299 #define GADGET_ID_CUSTOM_COPY (GADGET_ID_TOOLBOX_FIRST + 25)
300 #define GADGET_ID_CUSTOM_PASTE (GADGET_ID_TOOLBOX_FIRST + 26)
302 #define GADGET_ID_PROPERTIES (GADGET_ID_TOOLBOX_FIRST + 27)
304 /* counter gadget identifiers */
305 #define GADGET_ID_COUNTER_FIRST (GADGET_ID_TOOLBOX_FIRST + 28)
307 #define GADGET_ID_SELECT_LEVEL_DOWN (GADGET_ID_COUNTER_FIRST + 0)
308 #define GADGET_ID_SELECT_LEVEL_TEXT (GADGET_ID_COUNTER_FIRST + 1)
309 #define GADGET_ID_SELECT_LEVEL_UP (GADGET_ID_COUNTER_FIRST + 2)
310 #define GADGET_ID_LEVEL_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 3)
311 #define GADGET_ID_LEVEL_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 4)
312 #define GADGET_ID_LEVEL_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 5)
313 #define GADGET_ID_LEVEL_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 6)
314 #define GADGET_ID_LEVEL_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 7)
315 #define GADGET_ID_LEVEL_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 8)
316 #define GADGET_ID_LEVEL_RANDOM_DOWN (GADGET_ID_COUNTER_FIRST + 9)
317 #define GADGET_ID_LEVEL_RANDOM_TEXT (GADGET_ID_COUNTER_FIRST + 10)
318 #define GADGET_ID_LEVEL_RANDOM_UP (GADGET_ID_COUNTER_FIRST + 11)
319 #define GADGET_ID_LEVEL_GEMSLIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 12)
320 #define GADGET_ID_LEVEL_GEMSLIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 13)
321 #define GADGET_ID_LEVEL_GEMSLIMIT_UP (GADGET_ID_COUNTER_FIRST + 14)
322 #define GADGET_ID_LEVEL_TIMELIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 15)
323 #define GADGET_ID_LEVEL_TIMELIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 16)
324 #define GADGET_ID_LEVEL_TIMELIMIT_UP (GADGET_ID_COUNTER_FIRST + 17)
325 #define GADGET_ID_LEVEL_TIMESCORE_DOWN (GADGET_ID_COUNTER_FIRST + 18)
326 #define GADGET_ID_LEVEL_TIMESCORE_TEXT (GADGET_ID_COUNTER_FIRST + 19)
327 #define GADGET_ID_LEVEL_TIMESCORE_UP (GADGET_ID_COUNTER_FIRST + 20)
328 #define GADGET_ID_LEVEL_RANDOM_SEED_DOWN (GADGET_ID_COUNTER_FIRST + 21)
329 #define GADGET_ID_LEVEL_RANDOM_SEED_TEXT (GADGET_ID_COUNTER_FIRST + 22)
330 #define GADGET_ID_LEVEL_RANDOM_SEED_UP (GADGET_ID_COUNTER_FIRST + 23)
331 #define GADGET_ID_ELEMENT_VALUE1_DOWN (GADGET_ID_COUNTER_FIRST + 24)
332 #define GADGET_ID_ELEMENT_VALUE1_TEXT (GADGET_ID_COUNTER_FIRST + 25)
333 #define GADGET_ID_ELEMENT_VALUE1_UP (GADGET_ID_COUNTER_FIRST + 26)
334 #define GADGET_ID_ELEMENT_VALUE2_DOWN (GADGET_ID_COUNTER_FIRST + 27)
335 #define GADGET_ID_ELEMENT_VALUE2_TEXT (GADGET_ID_COUNTER_FIRST + 28)
336 #define GADGET_ID_ELEMENT_VALUE2_UP (GADGET_ID_COUNTER_FIRST + 29)
337 #define GADGET_ID_ELEMENT_VALUE3_DOWN (GADGET_ID_COUNTER_FIRST + 30)
338 #define GADGET_ID_ELEMENT_VALUE3_TEXT (GADGET_ID_COUNTER_FIRST + 31)
339 #define GADGET_ID_ELEMENT_VALUE3_UP (GADGET_ID_COUNTER_FIRST + 32)
340 #define GADGET_ID_ELEMENT_VALUE4_DOWN (GADGET_ID_COUNTER_FIRST + 33)
341 #define GADGET_ID_ELEMENT_VALUE4_TEXT (GADGET_ID_COUNTER_FIRST + 34)
342 #define GADGET_ID_ELEMENT_VALUE4_UP (GADGET_ID_COUNTER_FIRST + 35)
343 #define GADGET_ID_YAMYAM_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 36)
344 #define GADGET_ID_YAMYAM_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 37)
345 #define GADGET_ID_YAMYAM_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 38)
346 #define GADGET_ID_BALL_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 39)
347 #define GADGET_ID_BALL_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 40)
348 #define GADGET_ID_BALL_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 41)
349 #define GADGET_ID_ANDROID_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 42)
350 #define GADGET_ID_ANDROID_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 43)
351 #define GADGET_ID_ANDROID_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 44)
352 #define GADGET_ID_ENVELOPE_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 45)
353 #define GADGET_ID_ENVELOPE_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 46)
354 #define GADGET_ID_ENVELOPE_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 47)
355 #define GADGET_ID_ENVELOPE_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 48)
356 #define GADGET_ID_ENVELOPE_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 49)
357 #define GADGET_ID_ENVELOPE_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 50)
358 #define GADGET_ID_INVENTORY_SIZE_DOWN (GADGET_ID_COUNTER_FIRST + 51)
359 #define GADGET_ID_INVENTORY_SIZE_TEXT (GADGET_ID_COUNTER_FIRST + 52)
360 #define GADGET_ID_INVENTORY_SIZE_UP (GADGET_ID_COUNTER_FIRST + 53)
361 #define GADGET_ID_CUSTOM_SCORE_DOWN (GADGET_ID_COUNTER_FIRST + 54)
362 #define GADGET_ID_CUSTOM_SCORE_TEXT (GADGET_ID_COUNTER_FIRST + 55)
363 #define GADGET_ID_CUSTOM_SCORE_UP (GADGET_ID_COUNTER_FIRST + 56)
364 #define GADGET_ID_CUSTOM_GEMCOUNT_DOWN (GADGET_ID_COUNTER_FIRST + 57)
365 #define GADGET_ID_CUSTOM_GEMCOUNT_TEXT (GADGET_ID_COUNTER_FIRST + 58)
366 #define GADGET_ID_CUSTOM_GEMCOUNT_UP (GADGET_ID_COUNTER_FIRST + 59)
367 #define GADGET_ID_CUSTOM_VALUE_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 60)
368 #define GADGET_ID_CUSTOM_VALUE_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 61)
369 #define GADGET_ID_CUSTOM_VALUE_FIX_UP (GADGET_ID_COUNTER_FIRST + 62)
370 #define GADGET_ID_CUSTOM_VALUE_RND_DOWN (GADGET_ID_COUNTER_FIRST + 63)
371 #define GADGET_ID_CUSTOM_VALUE_RND_TEXT (GADGET_ID_COUNTER_FIRST + 64)
372 #define GADGET_ID_CUSTOM_VALUE_RND_UP (GADGET_ID_COUNTER_FIRST + 65)
373 #define GADGET_ID_PUSH_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 66)
374 #define GADGET_ID_PUSH_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 67)
375 #define GADGET_ID_PUSH_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 68)
376 #define GADGET_ID_PUSH_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 69)
377 #define GADGET_ID_PUSH_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 70)
378 #define GADGET_ID_PUSH_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 71)
379 #define GADGET_ID_DROP_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 72)
380 #define GADGET_ID_DROP_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 73)
381 #define GADGET_ID_DROP_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 74)
382 #define GADGET_ID_DROP_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 75)
383 #define GADGET_ID_DROP_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 76)
384 #define GADGET_ID_DROP_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 77)
385 #define GADGET_ID_MOVE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 78)
386 #define GADGET_ID_MOVE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 79)
387 #define GADGET_ID_MOVE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 80)
388 #define GADGET_ID_MOVE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 81)
389 #define GADGET_ID_MOVE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 82)
390 #define GADGET_ID_MOVE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 83)
391 #define GADGET_ID_EXPLOSION_DELAY_DOWN (GADGET_ID_COUNTER_FIRST + 84)
392 #define GADGET_ID_EXPLOSION_DELAY_TEXT (GADGET_ID_COUNTER_FIRST + 85)
393 #define GADGET_ID_EXPLOSION_DELAY_UP (GADGET_ID_COUNTER_FIRST + 86)
394 #define GADGET_ID_IGNITION_DELAY_DOWN (GADGET_ID_COUNTER_FIRST + 87)
395 #define GADGET_ID_IGNITION_DELAY_TEXT (GADGET_ID_COUNTER_FIRST + 88)
396 #define GADGET_ID_IGNITION_DELAY_UP (GADGET_ID_COUNTER_FIRST + 89)
397 #define GADGET_ID_CHANGE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 90)
398 #define GADGET_ID_CHANGE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 91)
399 #define GADGET_ID_CHANGE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 92)
400 #define GADGET_ID_CHANGE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 93)
401 #define GADGET_ID_CHANGE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 94)
402 #define GADGET_ID_CHANGE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 95)
403 #define GADGET_ID_CHANGE_CONT_RND_DOWN (GADGET_ID_COUNTER_FIRST + 96)
404 #define GADGET_ID_CHANGE_CONT_RND_TEXT (GADGET_ID_COUNTER_FIRST + 97)
405 #define GADGET_ID_CHANGE_CONT_RND_UP (GADGET_ID_COUNTER_FIRST + 98)
406 #define GADGET_ID_GROUP_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 99)
407 #define GADGET_ID_GROUP_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 100)
408 #define GADGET_ID_GROUP_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 101)
410 /* drawing area identifiers */
411 #define GADGET_ID_DRAWING_AREA_FIRST (GADGET_ID_COUNTER_FIRST + 102)
413 #define GADGET_ID_DRAWING_LEVEL (GADGET_ID_DRAWING_AREA_FIRST + 0)
414 #define GADGET_ID_YAMYAM_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 1)
415 #define GADGET_ID_YAMYAM_CONTENT_1 (GADGET_ID_DRAWING_AREA_FIRST + 2)
416 #define GADGET_ID_YAMYAM_CONTENT_2 (GADGET_ID_DRAWING_AREA_FIRST + 3)
417 #define GADGET_ID_YAMYAM_CONTENT_3 (GADGET_ID_DRAWING_AREA_FIRST + 4)
418 #define GADGET_ID_YAMYAM_CONTENT_4 (GADGET_ID_DRAWING_AREA_FIRST + 5)
419 #define GADGET_ID_YAMYAM_CONTENT_5 (GADGET_ID_DRAWING_AREA_FIRST + 6)
420 #define GADGET_ID_YAMYAM_CONTENT_6 (GADGET_ID_DRAWING_AREA_FIRST + 7)
421 #define GADGET_ID_YAMYAM_CONTENT_7 (GADGET_ID_DRAWING_AREA_FIRST + 8)
422 #define GADGET_ID_MAGIC_BALL_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 9)
423 #define GADGET_ID_MAGIC_BALL_CONTENT_1 (GADGET_ID_DRAWING_AREA_FIRST + 10)
424 #define GADGET_ID_MAGIC_BALL_CONTENT_2 (GADGET_ID_DRAWING_AREA_FIRST + 11)
425 #define GADGET_ID_MAGIC_BALL_CONTENT_3 (GADGET_ID_DRAWING_AREA_FIRST + 12)
426 #define GADGET_ID_MAGIC_BALL_CONTENT_4 (GADGET_ID_DRAWING_AREA_FIRST + 13)
427 #define GADGET_ID_MAGIC_BALL_CONTENT_5 (GADGET_ID_DRAWING_AREA_FIRST + 14)
428 #define GADGET_ID_MAGIC_BALL_CONTENT_6 (GADGET_ID_DRAWING_AREA_FIRST + 15)
429 #define GADGET_ID_MAGIC_BALL_CONTENT_7 (GADGET_ID_DRAWING_AREA_FIRST + 16)
430 #define GADGET_ID_ANDROID_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 17)
431 #define GADGET_ID_AMOEBA_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 18)
432 #define GADGET_ID_START_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 19)
433 #define GADGET_ID_ARTWORK_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 20)
434 #define GADGET_ID_EXPLOSION_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 21)
435 #define GADGET_ID_INVENTORY_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 22)
436 #define GADGET_ID_CUSTOM_GRAPHIC (GADGET_ID_DRAWING_AREA_FIRST + 23)
437 #define GADGET_ID_CUSTOM_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 24)
438 #define GADGET_ID_CUSTOM_MOVE_ENTER (GADGET_ID_DRAWING_AREA_FIRST + 25)
439 #define GADGET_ID_CUSTOM_MOVE_LEAVE (GADGET_ID_DRAWING_AREA_FIRST + 26)
440 #define GADGET_ID_CUSTOM_CHANGE_TARGET (GADGET_ID_DRAWING_AREA_FIRST + 27)
441 #define GADGET_ID_CUSTOM_CHANGE_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 28)
442 #define GADGET_ID_CUSTOM_CHANGE_TRIGGER (GADGET_ID_DRAWING_AREA_FIRST + 29)
443 #define GADGET_ID_CUSTOM_CHANGE_ACTION (GADGET_ID_DRAWING_AREA_FIRST + 30)
444 #define GADGET_ID_GROUP_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 31)
445 #define GADGET_ID_RANDOM_BACKGROUND (GADGET_ID_DRAWING_AREA_FIRST + 32)
447 /* text input identifiers */
448 #define GADGET_ID_TEXT_INPUT_FIRST (GADGET_ID_DRAWING_AREA_FIRST + 33)
450 #define GADGET_ID_LEVEL_NAME (GADGET_ID_TEXT_INPUT_FIRST + 0)
451 #define GADGET_ID_LEVEL_AUTHOR (GADGET_ID_TEXT_INPUT_FIRST + 1)
452 #define GADGET_ID_ELEMENT_NAME (GADGET_ID_TEXT_INPUT_FIRST + 2)
454 /* text area identifiers */
455 #define GADGET_ID_TEXT_AREA_FIRST (GADGET_ID_TEXT_INPUT_FIRST + 3)
457 #define GADGET_ID_ENVELOPE_INFO (GADGET_ID_TEXT_AREA_FIRST + 0)
459 /* selectbox identifiers */
460 #define GADGET_ID_SELECTBOX_FIRST (GADGET_ID_TEXT_AREA_FIRST + 1)
462 #define GADGET_ID_TIME_OR_STEPS (GADGET_ID_SELECTBOX_FIRST + 0)
463 #define GADGET_ID_GAME_ENGINE_TYPE (GADGET_ID_SELECTBOX_FIRST + 1)
464 #define GADGET_ID_WIND_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 2)
465 #define GADGET_ID_PLAYER_SPEED (GADGET_ID_SELECTBOX_FIRST + 3)
466 #define GADGET_ID_CUSTOM_WALK_TO_ACTION (GADGET_ID_SELECTBOX_FIRST + 4)
467 #define GADGET_ID_CUSTOM_EXPLOSION_TYPE (GADGET_ID_SELECTBOX_FIRST + 5)
468 #define GADGET_ID_CUSTOM_DEADLINESS (GADGET_ID_SELECTBOX_FIRST + 6)
469 #define GADGET_ID_CUSTOM_MOVE_PATTERN (GADGET_ID_SELECTBOX_FIRST + 7)
470 #define GADGET_ID_CUSTOM_MOVE_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 8)
471 #define GADGET_ID_CUSTOM_MOVE_STEPSIZE (GADGET_ID_SELECTBOX_FIRST + 9)
472 #define GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE (GADGET_ID_SELECTBOX_FIRST + 10)
473 #define GADGET_ID_CUSTOM_SMASH_TARGETS (GADGET_ID_SELECTBOX_FIRST + 11)
474 #define GADGET_ID_CUSTOM_SLIPPERY_TYPE (GADGET_ID_SELECTBOX_FIRST + 12)
475 #define GADGET_ID_CUSTOM_ACCESS_TYPE (GADGET_ID_SELECTBOX_FIRST + 13)
476 #define GADGET_ID_CUSTOM_ACCESS_LAYER (GADGET_ID_SELECTBOX_FIRST + 14)
477 #define GADGET_ID_CUSTOM_ACCESS_PROTECTED (GADGET_ID_SELECTBOX_FIRST + 15)
478 #define GADGET_ID_CUSTOM_ACCESS_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 16)
479 #define GADGET_ID_CHANGE_TIME_UNITS (GADGET_ID_SELECTBOX_FIRST + 17)
480 #define GADGET_ID_CHANGE_DIRECT_ACTION (GADGET_ID_SELECTBOX_FIRST + 18)
481 #define GADGET_ID_CHANGE_OTHER_ACTION (GADGET_ID_SELECTBOX_FIRST + 19)
482 #define GADGET_ID_CHANGE_SIDE (GADGET_ID_SELECTBOX_FIRST + 20)
483 #define GADGET_ID_CHANGE_PLAYER (GADGET_ID_SELECTBOX_FIRST + 21)
484 #define GADGET_ID_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 22)
485 #define GADGET_ID_CHANGE_REPLACE_WHEN (GADGET_ID_SELECTBOX_FIRST + 23)
486 #define GADGET_ID_ACTION_TYPE (GADGET_ID_SELECTBOX_FIRST + 24)
487 #define GADGET_ID_ACTION_MODE (GADGET_ID_SELECTBOX_FIRST + 25)
488 #define GADGET_ID_ACTION_ARG (GADGET_ID_SELECTBOX_FIRST + 26)
489 #define GADGET_ID_SELECT_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 27)
490 #define GADGET_ID_GROUP_CHOICE_MODE (GADGET_ID_SELECTBOX_FIRST + 28)
492 /* textbutton identifiers */
493 #define GADGET_ID_TEXTBUTTON_FIRST (GADGET_ID_SELECTBOX_FIRST + 29)
495 #define GADGET_ID_LEVELINFO_LEVEL (GADGET_ID_TEXTBUTTON_FIRST + 0)
496 #define GADGET_ID_LEVELINFO_EDITOR (GADGET_ID_TEXTBUTTON_FIRST + 1)
497 #define GADGET_ID_PROPERTIES_INFO (GADGET_ID_TEXTBUTTON_FIRST + 2)
498 #define GADGET_ID_PROPERTIES_CONFIG (GADGET_ID_TEXTBUTTON_FIRST + 3)
499 #define GADGET_ID_PROPERTIES_CONFIG_1 (GADGET_ID_TEXTBUTTON_FIRST + 4)
500 #define GADGET_ID_PROPERTIES_CONFIG_2 (GADGET_ID_TEXTBUTTON_FIRST + 5)
501 #define GADGET_ID_PROPERTIES_CHANGE (GADGET_ID_TEXTBUTTON_FIRST + 6)
502 #define GADGET_ID_SAVE_AS_TEMPLATE (GADGET_ID_TEXTBUTTON_FIRST + 7)
503 #define GADGET_ID_ADD_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 8)
504 #define GADGET_ID_DEL_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 9)
506 /* graphicbutton identifiers */
507 #define GADGET_ID_GRAPHICBUTTON_FIRST (GADGET_ID_TEXTBUTTON_FIRST + 10)
509 #define GADGET_ID_PREV_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 0)
510 #define GADGET_ID_NEXT_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 1)
511 #define GADGET_ID_COPY_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 2)
512 #define GADGET_ID_PASTE_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 3)
514 /* gadgets for scrolling of drawing area */
515 #define GADGET_ID_SCROLLING_FIRST (GADGET_ID_GRAPHICBUTTON_FIRST + 4)
517 #define GADGET_ID_SCROLL_UP (GADGET_ID_SCROLLING_FIRST + 0)
518 #define GADGET_ID_SCROLL_DOWN (GADGET_ID_SCROLLING_FIRST + 1)
519 #define GADGET_ID_SCROLL_LEFT (GADGET_ID_SCROLLING_FIRST + 2)
520 #define GADGET_ID_SCROLL_RIGHT (GADGET_ID_SCROLLING_FIRST + 3)
521 #define GADGET_ID_SCROLL_HORIZONTAL (GADGET_ID_SCROLLING_FIRST + 4)
522 #define GADGET_ID_SCROLL_VERTICAL (GADGET_ID_SCROLLING_FIRST + 5)
524 /* gadgets for scrolling element list */
525 #define GADGET_ID_SCROLLING_LIST_FIRST (GADGET_ID_SCROLLING_FIRST + 6)
527 #define GADGET_ID_SCROLL_LIST_UP (GADGET_ID_SCROLLING_LIST_FIRST + 0)
528 #define GADGET_ID_SCROLL_LIST_DOWN (GADGET_ID_SCROLLING_LIST_FIRST + 1)
529 #define GADGET_ID_SCROLL_LIST_VERTICAL (GADGET_ID_SCROLLING_LIST_FIRST + 2)
531 /* checkbuttons/radiobuttons for level/element properties */
532 #define GADGET_ID_CHECKBUTTON_FIRST (GADGET_ID_SCROLLING_LIST_FIRST + 3)
534 #define GADGET_ID_RANDOM_PERCENTAGE (GADGET_ID_CHECKBUTTON_FIRST + 0)
535 #define GADGET_ID_RANDOM_QUANTITY (GADGET_ID_CHECKBUTTON_FIRST + 1)
536 #define GADGET_ID_RANDOM_RESTRICTED (GADGET_ID_CHECKBUTTON_FIRST + 2)
537 #define GADGET_ID_STICK_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 3)
538 #define GADGET_ID_EM_SLIPPERY_GEMS (GADGET_ID_CHECKBUTTON_FIRST + 4)
539 #define GADGET_ID_EM_EXPLODES_BY_FIRE (GADGET_ID_CHECKBUTTON_FIRST + 5)
540 #define GADGET_ID_USE_SPRING_BUG (GADGET_ID_CHECKBUTTON_FIRST + 6)
541 #define GADGET_ID_USE_TIME_ORB_BUG (GADGET_ID_CHECKBUTTON_FIRST + 7)
542 #define GADGET_ID_RANDOM_BALL_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 8)
543 #define GADGET_ID_INITIAL_BALL_STATE (GADGET_ID_CHECKBUTTON_FIRST + 9)
544 #define GADGET_ID_GROW_INTO_DIGGABLE (GADGET_ID_CHECKBUTTON_FIRST + 10)
545 #define GADGET_ID_AUTO_EXIT_SOKOBAN (GADGET_ID_CHECKBUTTON_FIRST + 11)
546 #define GADGET_ID_CONTINUOUS_SNAPPING (GADGET_ID_CHECKBUTTON_FIRST + 12)
547 #define GADGET_ID_BLOCK_SNAP_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 13)
548 #define GADGET_ID_BLOCK_LAST_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 14)
549 #define GADGET_ID_SP_BLOCK_LAST_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 15)
550 #define GADGET_ID_INSTANT_RELOCATION (GADGET_ID_CHECKBUTTON_FIRST + 16)
551 #define GADGET_ID_SHIFTED_RELOCATION (GADGET_ID_CHECKBUTTON_FIRST + 17)
552 #define GADGET_ID_USE_START_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 18)
553 #define GADGET_ID_USE_ARTWORK_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 19)
554 #define GADGET_ID_USE_EXPLOSION_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 20)
555 #define GADGET_ID_INITIAL_GRAVITY (GADGET_ID_CHECKBUTTON_FIRST + 21)
556 #define GADGET_ID_USE_INITIAL_INVENTORY (GADGET_ID_CHECKBUTTON_FIRST + 22)
557 #define GADGET_ID_CAN_PASS_TO_WALKABLE (GADGET_ID_CHECKBUTTON_FIRST + 23)
558 #define GADGET_ID_CAN_FALL_INTO_ACID (GADGET_ID_CHECKBUTTON_FIRST + 24)
559 #define GADGET_ID_CAN_MOVE_INTO_ACID (GADGET_ID_CHECKBUTTON_FIRST + 25)
560 #define GADGET_ID_DONT_COLLIDE_WITH (GADGET_ID_CHECKBUTTON_FIRST + 26)
561 #define GADGET_ID_ENVELOPE_AUTOWRAP (GADGET_ID_CHECKBUTTON_FIRST + 27)
562 #define GADGET_ID_ENVELOPE_CENTERED (GADGET_ID_CHECKBUTTON_FIRST + 28)
563 #define GADGET_ID_CUSTOM_INDESTRUCTIBLE (GADGET_ID_CHECKBUTTON_FIRST + 29)
564 #define GADGET_ID_CUSTOM_CAN_EXPLODE (GADGET_ID_CHECKBUTTON_FIRST + 30)
565 #define GADGET_ID_CUSTOM_EXPLODE_FIRE (GADGET_ID_CHECKBUTTON_FIRST + 31)
566 #define GADGET_ID_CUSTOM_EXPLODE_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 32)
567 #define GADGET_ID_CUSTOM_EXPLODE_IMPACT (GADGET_ID_CHECKBUTTON_FIRST + 33)
568 #define GADGET_ID_CUSTOM_WALK_TO_OBJECT (GADGET_ID_CHECKBUTTON_FIRST + 34)
569 #define GADGET_ID_CUSTOM_DEADLY (GADGET_ID_CHECKBUTTON_FIRST + 35)
570 #define GADGET_ID_CUSTOM_CAN_MOVE (GADGET_ID_CHECKBUTTON_FIRST + 36)
571 #define GADGET_ID_CUSTOM_CAN_FALL (GADGET_ID_CHECKBUTTON_FIRST + 37)
572 #define GADGET_ID_CUSTOM_CAN_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 38)
573 #define GADGET_ID_CUSTOM_SLIPPERY (GADGET_ID_CHECKBUTTON_FIRST + 39)
574 #define GADGET_ID_CUSTOM_ACCESSIBLE (GADGET_ID_CHECKBUTTON_FIRST + 40)
575 #define GADGET_ID_CUSTOM_GRAV_REACHABLE (GADGET_ID_CHECKBUTTON_FIRST + 41)
576 #define GADGET_ID_CUSTOM_USE_LAST_VALUE (GADGET_ID_CHECKBUTTON_FIRST + 42)
577 #define GADGET_ID_CUSTOM_USE_GRAPHIC (GADGET_ID_CHECKBUTTON_FIRST + 43)
578 #define GADGET_ID_CUSTOM_USE_TEMPLATE (GADGET_ID_CHECKBUTTON_FIRST + 44)
579 #define GADGET_ID_CUSTOM_CAN_CHANGE (GADGET_ID_CHECKBUTTON_FIRST + 45)
580 #define GADGET_ID_CHANGE_USE_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 46)
581 #define GADGET_ID_CHANGE_USE_EXPLOSION (GADGET_ID_CHECKBUTTON_FIRST + 47)
582 #define GADGET_ID_CHANGE_ONLY_COMPLETE (GADGET_ID_CHECKBUTTON_FIRST + 48)
583 #define GADGET_ID_CHANGE_USE_RANDOM (GADGET_ID_CHECKBUTTON_FIRST + 49)
584 #define GADGET_ID_CHANGE_HAS_ACTION (GADGET_ID_CHECKBUTTON_FIRST + 50)
585 #define GADGET_ID_CHANGE_DELAY (GADGET_ID_CHECKBUTTON_FIRST + 51)
586 #define GADGET_ID_CHANGE_BY_DIRECT_ACT (GADGET_ID_CHECKBUTTON_FIRST + 52)
587 #define GADGET_ID_CHANGE_BY_OTHER_ACT (GADGET_ID_CHECKBUTTON_FIRST + 53)
589 /* gadgets for buttons in element list */
590 #define GADGET_ID_ELEMENTLIST_FIRST (GADGET_ID_CHECKBUTTON_FIRST + 54)
591 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
592 ED_NUM_ELEMENTLIST_BUTTONS - 1)
594 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
596 /* radio button numbers */
597 #define RADIO_NR_NONE 0
598 #define RADIO_NR_DRAWING_TOOLBOX 1
599 #define RADIO_NR_RANDOM_ELEMENTS 2
601 /* values for counter gadgets */
602 #define ED_COUNTER_ID_SELECT_LEVEL 0
603 #define ED_COUNTER_ID_LEVEL_XSIZE 1
604 #define ED_COUNTER_ID_LEVEL_YSIZE 2
605 #define ED_COUNTER_ID_LEVEL_GEMSLIMIT 3
606 #define ED_COUNTER_ID_LEVEL_TIMELIMIT 4
607 #define ED_COUNTER_ID_LEVEL_TIMESCORE 5
608 #define ED_COUNTER_ID_LEVEL_RANDOM_SEED 6
609 #define ED_COUNTER_ID_LEVEL_RANDOM 7
610 #define ED_COUNTER_ID_ELEMENT_VALUE1 8
611 #define ED_COUNTER_ID_ELEMENT_VALUE2 9
612 #define ED_COUNTER_ID_ELEMENT_VALUE3 10
613 #define ED_COUNTER_ID_ELEMENT_VALUE4 11
614 #define ED_COUNTER_ID_YAMYAM_CONTENT 12
615 #define ED_COUNTER_ID_BALL_CONTENT 13
616 #define ED_COUNTER_ID_ANDROID_CONTENT 14
617 #define ED_COUNTER_ID_ENVELOPE_XSIZE 15
618 #define ED_COUNTER_ID_ENVELOPE_YSIZE 16
619 #define ED_COUNTER_ID_INVENTORY_SIZE 17
620 #define ED_COUNTER_ID_CUSTOM_SCORE 18
621 #define ED_COUNTER_ID_CUSTOM_GEMCOUNT 19
622 #define ED_COUNTER_ID_CUSTOM_VALUE_FIX 20
623 #define ED_COUNTER_ID_CUSTOM_VALUE_RND 21
624 #define ED_COUNTER_ID_PUSH_DELAY_FIX 22
625 #define ED_COUNTER_ID_PUSH_DELAY_RND 23
626 #define ED_COUNTER_ID_DROP_DELAY_FIX 24
627 #define ED_COUNTER_ID_DROP_DELAY_RND 25
628 #define ED_COUNTER_ID_MOVE_DELAY_FIX 26
629 #define ED_COUNTER_ID_MOVE_DELAY_RND 27
630 #define ED_COUNTER_ID_EXPLOSION_DELAY 28
631 #define ED_COUNTER_ID_IGNITION_DELAY 29
632 #define ED_COUNTER_ID_GROUP_CONTENT 30
633 #define ED_COUNTER_ID_CHANGE_DELAY_FIX 31
634 #define ED_COUNTER_ID_CHANGE_DELAY_RND 32
635 #define ED_COUNTER_ID_CHANGE_CONT_RND 33
637 #define ED_NUM_COUNTERBUTTONS 34
639 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
640 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
641 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
642 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
644 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
645 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
646 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
647 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
648 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
649 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
651 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
652 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
654 /* values for scrollbutton gadgets */
655 #define ED_SCROLLBUTTON_ID_AREA_UP 0
656 #define ED_SCROLLBUTTON_ID_AREA_DOWN 1
657 #define ED_SCROLLBUTTON_ID_AREA_LEFT 2
658 #define ED_SCROLLBUTTON_ID_AREA_RIGHT 3
659 #define ED_SCROLLBUTTON_ID_LIST_UP 4
660 #define ED_SCROLLBUTTON_ID_LIST_DOWN 5
662 #define ED_NUM_SCROLLBUTTONS 6
664 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
665 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
667 /* values for scrollbar gadgets */
668 #define ED_SCROLLBAR_ID_AREA_HORIZONTAL 0
669 #define ED_SCROLLBAR_ID_AREA_VERTICAL 1
670 #define ED_SCROLLBAR_ID_LIST_VERTICAL 2
672 #define ED_NUM_SCROLLBARS 3
674 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
675 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
677 /* values for text input gadgets */
678 #define ED_TEXTINPUT_ID_LEVEL_NAME 0
679 #define ED_TEXTINPUT_ID_LEVEL_AUTHOR 1
680 #define ED_TEXTINPUT_ID_ELEMENT_NAME 2
682 #define ED_NUM_TEXTINPUT 3
684 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
685 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
687 /* values for text area gadgets */
688 #define ED_TEXTAREA_ID_ENVELOPE_INFO 0
690 #define ED_NUM_TEXTAREAS 1
692 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
693 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
695 /* values for selectbox gadgets */
696 #define ED_SELECTBOX_ID_TIME_OR_STEPS 0
697 #define ED_SELECTBOX_ID_GAME_ENGINE_TYPE 1
698 #define ED_SELECTBOX_ID_WIND_DIRECTION 2
699 #define ED_SELECTBOX_ID_PLAYER_SPEED 3
700 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE 4
701 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER 5
702 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED 6
703 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION 7
704 #define ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION 8
705 #define ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN 9
706 #define ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION 10
707 #define ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE 11
708 #define ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE 12
709 #define ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS 13
710 #define ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE 14
711 #define ED_SELECTBOX_ID_CUSTOM_DEADLINESS 15
712 #define ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE 16
713 #define ED_SELECTBOX_ID_CHANGE_TIME_UNITS 17
714 #define ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION 18
715 #define ED_SELECTBOX_ID_CHANGE_OTHER_ACTION 19
716 #define ED_SELECTBOX_ID_CHANGE_SIDE 20
717 #define ED_SELECTBOX_ID_CHANGE_PLAYER 21
718 #define ED_SELECTBOX_ID_CHANGE_PAGE 22
719 #define ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN 23
720 #define ED_SELECTBOX_ID_ACTION_TYPE 24
721 #define ED_SELECTBOX_ID_ACTION_MODE 25
722 #define ED_SELECTBOX_ID_ACTION_ARG 26
723 #define ED_SELECTBOX_ID_SELECT_CHANGE_PAGE 27
724 #define ED_SELECTBOX_ID_GROUP_CHOICE_MODE 28
726 #define ED_NUM_SELECTBOX 29
728 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
729 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_WIND_DIRECTION
731 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
732 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
733 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
734 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
735 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
736 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
738 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
739 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
741 /* values for textbutton gadgets */
742 #define ED_TEXTBUTTON_ID_LEVELINFO_LEVEL 0
743 #define ED_TEXTBUTTON_ID_LEVELINFO_EDITOR 1
744 #define ED_TEXTBUTTON_ID_PROPERTIES_INFO 2
745 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG 3
746 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1 4
747 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2 5
748 #define ED_TEXTBUTTON_ID_PROPERTIES_CHANGE 6
749 #define ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE 7
750 #define ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE 8
751 #define ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE 9
753 #define ED_NUM_TEXTBUTTONS 10
755 #define ED_TEXTBUTTON_ID_LEVELINFO_FIRST ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
756 #define ED_TEXTBUTTON_ID_LEVELINFO_LAST ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
758 #define ED_TEXTBUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
759 #define ED_TEXTBUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
761 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
762 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
764 /* values for graphicbutton gadgets */
765 #define ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE 0
766 #define ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE 1
767 #define ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE 2
768 #define ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE 3
770 #define ED_NUM_GRAPHICBUTTONS 4
772 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
773 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
775 /* values for checkbutton gadgets */
776 #define ED_CHECKBUTTON_ID_RANDOM_RESTRICTED 0
777 #define ED_CHECKBUTTON_ID_STICK_ELEMENT 1
778 #define ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS 2
779 #define ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE 3
780 #define ED_CHECKBUTTON_ID_USE_SPRING_BUG 4
781 #define ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG 5
782 #define ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT 6
783 #define ED_CHECKBUTTON_ID_INITIAL_BALL_STATE 7
784 #define ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE 8
785 #define ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN 9
786 #define ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING 10
787 #define ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD 11
788 #define ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD 12
789 #define ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD 13
790 #define ED_CHECKBUTTON_ID_INSTANT_RELOCATION 14
791 #define ED_CHECKBUTTON_ID_SHIFTED_RELOCATION 15
792 #define ED_CHECKBUTTON_ID_USE_START_ELEMENT 16
793 #define ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT 17
794 #define ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT 18
795 #define ED_CHECKBUTTON_ID_INITIAL_GRAVITY 19
796 #define ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY 20
797 #define ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE 21
798 #define ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID 22
799 #define ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID 23
800 #define ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH 24
801 #define ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP 25
802 #define ED_CHECKBUTTON_ID_ENVELOPE_CENTERED 26
803 #define ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC 27
804 #define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE 28
805 #define ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE 29
806 #define ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE 30
807 #define ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE 31
808 #define ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT 32
809 #define ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE 33
810 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE 34
811 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL 35
812 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH 36
813 #define ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY 37
814 #define ED_CHECKBUTTON_ID_CUSTOM_DEADLY 38
815 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE 39
816 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE 40
817 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH 41
818 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT 42
819 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE 43
820 #define ED_CHECKBUTTON_ID_CHANGE_DELAY 44
821 #define ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT 45
822 #define ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT 46
823 #define ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION 47
824 #define ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT 48
825 #define ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE 49
826 #define ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM 50
827 #define ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION 51
829 #define ED_NUM_CHECKBUTTONS 52
831 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
832 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
834 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
835 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
836 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
837 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
838 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
839 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
841 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
842 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
844 /* values for radiobutton gadgets */
845 #define ED_RADIOBUTTON_ID_PERCENTAGE 0
846 #define ED_RADIOBUTTON_ID_QUANTITY 1
848 #define ED_NUM_RADIOBUTTONS 2
850 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
851 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
853 /* values for drawing area gadgets */
854 #define ED_DRAWING_ID_DRAWING_LEVEL 0
855 #define ED_DRAWING_ID_YAMYAM_CONTENT_0 1
856 #define ED_DRAWING_ID_YAMYAM_CONTENT_1 2
857 #define ED_DRAWING_ID_YAMYAM_CONTENT_2 3
858 #define ED_DRAWING_ID_YAMYAM_CONTENT_3 4
859 #define ED_DRAWING_ID_YAMYAM_CONTENT_4 5
860 #define ED_DRAWING_ID_YAMYAM_CONTENT_5 6
861 #define ED_DRAWING_ID_YAMYAM_CONTENT_6 7
862 #define ED_DRAWING_ID_YAMYAM_CONTENT_7 8
863 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 9
864 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_1 10
865 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_2 11
866 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_3 12
867 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_4 13
868 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_5 14
869 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_6 15
870 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_7 16
871 #define ED_DRAWING_ID_ANDROID_CONTENT 17
872 #define ED_DRAWING_ID_AMOEBA_CONTENT 18
873 #define ED_DRAWING_ID_START_ELEMENT 19
874 #define ED_DRAWING_ID_ARTWORK_ELEMENT 20
875 #define ED_DRAWING_ID_EXPLOSION_ELEMENT 21
876 #define ED_DRAWING_ID_INVENTORY_CONTENT 22
877 #define ED_DRAWING_ID_CUSTOM_GRAPHIC 23
878 #define ED_DRAWING_ID_CUSTOM_CONTENT 24
879 #define ED_DRAWING_ID_CUSTOM_MOVE_ENTER 25
880 #define ED_DRAWING_ID_CUSTOM_MOVE_LEAVE 26
881 #define ED_DRAWING_ID_CUSTOM_CHANGE_TARGET 27
882 #define ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT 28
883 #define ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER 29
884 #define ED_DRAWING_ID_CUSTOM_CHANGE_ACTION 30
885 #define ED_DRAWING_ID_GROUP_CONTENT 31
886 #define ED_DRAWING_ID_RANDOM_BACKGROUND 32
888 #define ED_NUM_DRAWING_AREAS 33
892 -----------------------------------------------------------------------------
893 some internally used definitions
894 -----------------------------------------------------------------------------
897 /* values for CopyLevelToUndoBuffer() */
898 #define UNDO_IMMEDIATE 0
899 #define UNDO_ACCUMULATE 1
901 /* values for scrollbars */
902 #define ED_SCROLL_NO 0
903 #define ED_SCROLL_LEFT 1
904 #define ED_SCROLL_RIGHT 2
905 #define ED_SCROLL_UP 4
906 #define ED_SCROLL_DOWN 8
908 /* screens in the level editor */
909 #define ED_MODE_DRAWING 0
910 #define ED_MODE_INFO 1
911 #define ED_MODE_PROPERTIES 2
913 /* sub-screens in the global settings section */
914 #define ED_MODE_LEVELINFO_LEVEL ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
915 #define ED_MODE_LEVELINFO_EDITOR ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
917 /* sub-screens in the element properties section */
918 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
919 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
920 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
921 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
922 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
924 /* how many steps can be cancelled */
925 #define NUM_UNDO_STEPS (64 + 1)
927 /* values for elements with score for certain actions */
929 #define MAX_SCORE 999
931 /* values for elements with count for collecting */
932 #define MIN_COLLECT_COUNT 0
933 #define MAX_COLLECT_COUNT 999
935 /* values for random placement */
936 #define RANDOM_USE_PERCENTAGE 0
937 #define RANDOM_USE_QUANTITY 1
939 /* default value for element tile size in drawing area */
940 #define DEFAULT_EDITOR_TILESIZE MINI_TILESIZE
944 -----------------------------------------------------------------------------
945 some internally used data structure definitions
946 -----------------------------------------------------------------------------
957 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
959 /* note: some additional characters are already reserved for "cheat mode"
960 shortcuts (":XYZ" style) -- for details, see "events.c" */
962 /* ---------- toolbox control buttons ------------------------------------ */
965 IMG_EDITOR_BUTTON_GFX_DRAW_SINGLE, GADGET_ID_SINGLE_ITEMS,
966 &editor.button.draw_single, GD_TYPE_RADIO_BUTTON,
967 "draw single items", 's'
970 IMG_EDITOR_BUTTON_GFX_DRAW_CONNECTED, GADGET_ID_CONNECTED_ITEMS,
971 &editor.button.draw_connected, GD_TYPE_RADIO_BUTTON,
972 "draw connected items", 'd'
975 IMG_EDITOR_BUTTON_GFX_DRAW_LINE, GADGET_ID_LINE,
976 &editor.button.draw_line, GD_TYPE_RADIO_BUTTON,
980 IMG_EDITOR_BUTTON_GFX_DRAW_ARC, GADGET_ID_ARC,
981 &editor.button.draw_arc, GD_TYPE_RADIO_BUTTON,
985 IMG_EDITOR_BUTTON_GFX_DRAW_RECTANGLE, GADGET_ID_RECTANGLE,
986 &editor.button.draw_rectangle, GD_TYPE_RADIO_BUTTON,
987 "draw outline rectangles", 'r'
990 IMG_EDITOR_BUTTON_GFX_DRAW_FILLED_BOX, GADGET_ID_FILLED_BOX,
991 &editor.button.draw_filled_box, GD_TYPE_RADIO_BUTTON,
992 "draw filled rectangles", 'R'
995 IMG_EDITOR_BUTTON_GFX_ROTATE_UP, GADGET_ID_WRAP_UP,
996 &editor.button.rotate_up, GD_TYPE_NORMAL_BUTTON,
997 "wrap (rotate) level up", 0
1000 IMG_EDITOR_BUTTON_GFX_DRAW_TEXT, GADGET_ID_TEXT,
1001 &editor.button.draw_text, GD_TYPE_RADIO_BUTTON,
1002 "enter text elements", 't'
1005 IMG_EDITOR_BUTTON_GFX_FLOOD_FILL, GADGET_ID_FLOOD_FILL,
1006 &editor.button.flood_fill, GD_TYPE_RADIO_BUTTON,
1010 IMG_EDITOR_BUTTON_GFX_ROTATE_LEFT, GADGET_ID_WRAP_LEFT,
1011 &editor.button.rotate_left, GD_TYPE_NORMAL_BUTTON,
1012 "wrap (rotate) level left", 0
1015 IMG_EDITOR_BUTTON_GFX_ZOOM_LEVEL, GADGET_ID_ZOOM,
1016 &editor.button.zoom_level, GD_TYPE_NORMAL_BUTTON,
1017 "zoom level tile size", '-'
1020 IMG_EDITOR_BUTTON_GFX_ROTATE_RIGHT, GADGET_ID_WRAP_RIGHT,
1021 &editor.button.rotate_right, GD_TYPE_NORMAL_BUTTON,
1022 "wrap (rotate) level right", 0
1025 IMG_EDITOR_BUTTON_GFX_DRAW_RANDOM, GADGET_ID_RANDOM_PLACEMENT,
1026 &editor.button.draw_random, GD_TYPE_NORMAL_BUTTON,
1027 "random element placement", 0
1030 IMG_EDITOR_BUTTON_GFX_GRAB_BRUSH, GADGET_ID_GRAB_BRUSH,
1031 &editor.button.grab_brush, GD_TYPE_RADIO_BUTTON,
1035 IMG_EDITOR_BUTTON_GFX_ROTATE_DOWN, GADGET_ID_WRAP_DOWN,
1036 &editor.button.rotate_down, GD_TYPE_NORMAL_BUTTON,
1037 "wrap (rotate) level down", 0
1040 IMG_EDITOR_BUTTON_GFX_PICK_ELEMENT, GADGET_ID_PICK_ELEMENT,
1041 &editor.button.pick_element, GD_TYPE_RADIO_BUTTON,
1042 "pick drawing element", ','
1045 /* ---------- level control buttons -------------------------------------- */
1048 IMG_EDITOR_BUTTON_GFX_UNDO, GADGET_ID_UNDO,
1049 &editor.button.undo, GD_TYPE_NORMAL_BUTTON,
1050 "undo/redo last operation", 'u'
1053 IMG_EDITOR_BUTTON_GFX_CONF, GADGET_ID_INFO,
1054 &editor.button.conf, GD_TYPE_NORMAL_BUTTON,
1055 "properties of level", 'I'
1058 IMG_EDITOR_BUTTON_GFX_SAVE, GADGET_ID_SAVE,
1059 &editor.button.save, GD_TYPE_NORMAL_BUTTON,
1063 IMG_EDITOR_BUTTON_GFX_CLEAR, GADGET_ID_CLEAR,
1064 &editor.button.clear, GD_TYPE_NORMAL_BUTTON,
1068 IMG_EDITOR_BUTTON_GFX_TEST, GADGET_ID_TEST,
1069 &editor.button.test, GD_TYPE_NORMAL_BUTTON,
1073 IMG_EDITOR_BUTTON_GFX_EXIT, GADGET_ID_EXIT,
1074 &editor.button.exit, GD_TYPE_NORMAL_BUTTON,
1075 "exit level editor", 'E'
1078 /* ---------- CE and GE control buttons ---------------------------------- */
1081 IMG_EDITOR_BUTTON_GFX_CE_COPY_FROM, GADGET_ID_CUSTOM_COPY_FROM,
1082 &editor.button.ce_copy_from, GD_TYPE_RADIO_BUTTON,
1083 "copy settings from other element", 0
1086 IMG_EDITOR_BUTTON_GFX_CE_COPY_TO, GADGET_ID_CUSTOM_COPY_TO,
1087 &editor.button.ce_copy_to, GD_TYPE_RADIO_BUTTON,
1088 "copy settings to other element", 0
1091 IMG_EDITOR_BUTTON_GFX_CE_SWAP, GADGET_ID_CUSTOM_EXCHANGE,
1092 &editor.button.ce_swap, GD_TYPE_RADIO_BUTTON,
1093 "exchange element with other element", 0
1096 IMG_EDITOR_BUTTON_GFX_CE_COPY, GADGET_ID_CUSTOM_COPY,
1097 &editor.button.ce_copy, GD_TYPE_NORMAL_BUTTON,
1098 "copy settings from this element", 0
1101 IMG_EDITOR_BUTTON_GFX_CE_PASTE, GADGET_ID_CUSTOM_PASTE,
1102 &editor.button.ce_paste, GD_TYPE_NORMAL_BUTTON,
1103 "paste settings to this element", 0
1106 /* ---------- palette control buttons ------------------------------------ */
1109 IMG_EDITOR_BUTTON_GFX_PROPERTIES, GADGET_ID_PROPERTIES,
1110 &editor.button.properties, GD_TYPE_NORMAL_BUTTON,
1111 "properties of drawing element", 'p'
1115 static int random_placement_value = 10;
1116 static int random_placement_method = RANDOM_USE_QUANTITY;
1117 static int random_placement_background_element = EL_SAND;
1118 static boolean random_placement_background_restricted = FALSE;
1119 static boolean stick_element_properties_window = FALSE;
1120 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1121 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1122 static struct ElementChangeInfo custom_element_change;
1123 static struct ElementGroupInfo group_element_info;
1124 static struct ElementInfo custom_element;
1129 int min_value, max_value;
1130 int gadget_id_down, gadget_id_up;
1132 int gadget_id_align;
1134 char *text_above, *text_left, *text_right;
1135 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1137 /* ---------- current level number --------------------------------------- */
1140 -1, -1, /* these values are not constant, but can change at runtime */
1142 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1143 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1148 /* ---------- level and editor settings ---------------------------------- */
1151 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1152 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1153 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1154 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1156 "playfield size:", NULL, "width",
1159 -1, ED_LEVEL_SETTINGS_YPOS(4),
1160 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1161 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1162 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1164 NULL, " ", "height",
1167 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1169 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1170 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1172 NULL, "number of gems to collect:", NULL
1175 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
1177 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1178 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1180 "time or step limit to solve level:", NULL, NULL
1183 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(9),
1185 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1186 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1187 &level.score[SC_TIME_BONUS],
1188 "score for each second/step left:", NULL, NULL
1191 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
1193 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1194 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1196 NULL, "random seed:", "(0 => random)"
1199 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1201 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1202 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1203 &random_placement_value,
1204 "random element placement:", NULL, "in"
1207 /* ---------- element settings: configure (various elements) ------------- */
1210 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1211 MIN_SCORE, MAX_SCORE,
1212 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1213 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1214 NULL, /* will be set when used */
1218 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1219 MIN_SCORE, MAX_SCORE,
1220 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1221 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1222 NULL, /* will be set when used */
1226 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1227 MIN_SCORE, MAX_SCORE,
1228 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1229 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1230 NULL, /* will be set when used */
1234 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1235 MIN_SCORE, MAX_SCORE,
1236 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1237 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1238 NULL, /* will be set when used */
1242 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1243 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1244 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1245 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1246 &level.num_yamyam_contents,
1247 NULL, NULL, "number of content areas"
1250 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1251 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1252 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1253 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1254 &level.num_ball_contents,
1255 NULL, NULL, "number of content areas"
1258 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1259 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1260 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1261 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1262 &level.num_android_clone_elements,
1263 NULL, NULL, "number of clonable elements"
1266 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1267 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1268 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1269 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1270 NULL, /* will be set when used */
1271 NULL, NULL, "width",
1274 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1275 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1276 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1277 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1278 NULL, /* will be set when used */
1279 NULL, " ", "height",
1282 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1283 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1284 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1285 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1286 &level.initial_inventory_size[0],
1287 NULL, NULL, "number of inventory elements"
1290 /* ---------- element settings: configure 1 (custom elements) ------------ */
1293 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1294 MIN_SCORE, MAX_SCORE,
1295 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1296 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1297 &custom_element.collect_score_initial,
1298 NULL, "CE score", " "
1301 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1302 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1303 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1304 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1305 &custom_element.collect_count_initial,
1306 NULL, "CE count", NULL
1309 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1311 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1312 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1313 &custom_element.ce_value_fixed_initial,
1314 NULL, "CE value", NULL
1317 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1319 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1320 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1321 &custom_element.ce_value_random_initial,
1322 NULL, "+random", NULL
1325 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1327 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1328 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1329 &custom_element.push_delay_fixed,
1330 NULL, "push delay", NULL
1333 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1335 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1336 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1337 &custom_element.push_delay_random,
1338 NULL, "+random", NULL
1341 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1343 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1344 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1345 &custom_element.drop_delay_fixed,
1346 NULL, "drop delay", NULL
1349 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1351 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1352 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1353 &custom_element.drop_delay_random,
1354 NULL, "+random", NULL
1357 /* ---------- element settings: configure 2 (custom elements) ------------ */
1360 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1362 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1363 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1364 &custom_element.move_delay_fixed,
1365 NULL, "move delay", NULL
1368 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1370 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1371 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1372 &custom_element.move_delay_random,
1373 NULL, "+random", NULL
1376 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
1378 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1379 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1380 &custom_element.explosion_delay,
1381 NULL, "explosion delay", NULL
1384 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1386 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1387 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1388 &custom_element.ignition_delay,
1389 NULL, "ignition delay", "(by fire)"
1392 /* ---------- element settings: configure (group elements) --------------- */
1395 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1396 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1397 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1398 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1399 &group_element_info.num_elements,
1400 NULL, NULL, "number of elements in group"
1403 /* ---------- element settings: advanced (custom elements) --------------- */
1406 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1408 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1409 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1410 &custom_element_change.delay_fixed,
1411 NULL, "CE delay", NULL,
1414 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1416 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1417 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1418 &custom_element_change.delay_random,
1419 NULL, "+random", NULL
1422 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1424 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1425 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1426 &custom_element_change.random_percentage,
1427 NULL, "use random replace:", "%"
1437 char *text_above, *infotext;
1438 } textinput_info[ED_NUM_TEXTINPUT] =
1441 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1442 GADGET_ID_LEVEL_NAME,
1448 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1449 GADGET_ID_LEVEL_AUTHOR,
1450 MAX_LEVEL_AUTHOR_LEN,
1455 5 * MINI_TILEX - 2, 5 * MINI_TILEY - ED_BORDER_SIZE + 1,
1456 GADGET_ID_ELEMENT_NAME,
1457 MAX_ELEMENT_NAME_LEN - 2, /* currently 2 chars less editable */
1458 custom_element.description,
1459 NULL, "Element name"
1469 char *text_above, *infotext;
1470 } textarea_info[ED_NUM_TEXTAREAS] =
1473 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1474 GADGET_ID_ENVELOPE_INFO,
1475 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1477 "Envelope Content:", "Envelope Content"
1481 static struct ValueTextInfo options_time_or_steps[] =
1489 static struct ValueTextInfo options_game_engine_type[] =
1491 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1492 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1493 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1498 static struct ValueTextInfo options_wind_direction[] =
1500 { MV_START_NONE, "none" },
1501 { MV_START_LEFT, "left" },
1502 { MV_START_RIGHT, "right" },
1503 { MV_START_UP, "up" },
1504 { MV_START_DOWN, "down" },
1509 static struct ValueTextInfo options_player_speed[] =
1516 { 16, "very fast" },
1517 { 32, "ultrafast" },
1522 static struct ValueTextInfo options_access_type[] =
1524 { EP_WALKABLE, "walkable" },
1525 { EP_PASSABLE, "passable" },
1530 static struct ValueTextInfo options_access_layer[] =
1532 { EP_ACCESSIBLE_OVER, "over" },
1533 { EP_ACCESSIBLE_INSIDE, "inside" },
1534 { EP_ACCESSIBLE_UNDER, "under" },
1539 static struct ValueTextInfo options_access_protected[] =
1541 { 0, "unprotected" },
1547 static struct ValueTextInfo options_access_direction[] =
1549 { MV_NO_DIRECTION, "no direction" },
1550 { MV_LEFT, "left" },
1551 { MV_RIGHT, "right" },
1553 { MV_DOWN, "down" },
1554 { MV_LEFT | MV_UP, "left + up" },
1555 { MV_LEFT | MV_DOWN, "left + down" },
1556 { MV_RIGHT | MV_UP, "right + up" },
1557 { MV_RIGHT | MV_DOWN, "right + down" },
1558 { MV_HORIZONTAL, "horizontal" },
1559 { MV_VERTICAL, "vertical" },
1560 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1561 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1562 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1563 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1564 { MV_ALL_DIRECTIONS, "all directions" },
1569 static struct ValueTextInfo options_walk_to_action[] =
1571 { EP_DIGGABLE, "diggable" },
1572 { EP_COLLECTIBLE_ONLY, "collectible" },
1573 { EP_DROPPABLE, "collectible & droppable" },
1574 { EP_THROWABLE, "collectible & throwable" },
1575 { EP_PUSHABLE, "pushable" },
1580 static struct ValueTextInfo options_move_pattern[] =
1582 { MV_LEFT, "left" },
1583 { MV_RIGHT, "right" },
1585 { MV_DOWN, "down" },
1586 { MV_HORIZONTAL, "horizontal" },
1587 { MV_VERTICAL, "vertical" },
1588 { MV_ALL_DIRECTIONS, "all directions" },
1589 { MV_WIND_DIRECTION, "wind direction" },
1590 { MV_TOWARDS_PLAYER, "towards player" },
1591 { MV_AWAY_FROM_PLAYER, "away from player" },
1592 { MV_ALONG_LEFT_SIDE, "along left side" },
1593 { MV_ALONG_RIGHT_SIDE, "along right side" },
1594 { MV_TURNING_LEFT, "turning left" },
1595 { MV_TURNING_RIGHT, "turning right" },
1596 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1597 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1598 { MV_TURNING_RANDOM, "turning random" },
1599 { MV_MAZE_RUNNER, "maze runner style" },
1600 { MV_MAZE_HUNTER, "maze hunter style" },
1601 { MV_WHEN_PUSHED, "when pushed" },
1602 { MV_WHEN_DROPPED, "when dropped/thrown" },
1607 static struct ValueTextInfo options_move_direction[] =
1609 { MV_START_AUTOMATIC, "automatic" },
1610 { MV_START_LEFT, "left" },
1611 { MV_START_RIGHT, "right" },
1612 { MV_START_UP, "up" },
1613 { MV_START_DOWN, "down" },
1614 { MV_START_RANDOM, "random" },
1615 { MV_START_PREVIOUS, "previous" },
1620 static struct ValueTextInfo options_move_stepsize[] =
1622 { 0, "not moving" },
1627 { 16, "very fast" },
1628 { 32, "even faster" },
1633 static struct ValueTextInfo options_move_leave_type[] =
1635 { LEAVE_TYPE_UNLIMITED, "leave behind" },
1636 { LEAVE_TYPE_LIMITED, "change it to" },
1641 static struct ValueTextInfo options_smash_targets[] =
1643 { EP_CAN_SMASH_PLAYER, "player" },
1645 { EP_CAN_SMASH_ENEMIES, "enemies" },
1647 { EP_CAN_SMASH_EVERYTHING, "everything" },
1652 static struct ValueTextInfo options_slippery_type[] =
1654 { SLIPPERY_ANY_RANDOM, "random" },
1655 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
1656 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
1657 { SLIPPERY_ONLY_LEFT, "only left" },
1658 { SLIPPERY_ONLY_RIGHT, "only right" },
1663 static struct ValueTextInfo options_deadliness[] =
1665 { EP_DONT_RUN_INTO, "running into" },
1666 { EP_DONT_COLLIDE_WITH, "colliding with" },
1667 { EP_DONT_GET_HIT_BY, "getting hit by" },
1668 { EP_DONT_TOUCH, "touching" },
1673 static struct ValueTextInfo options_explosion_type[] =
1675 { EXPLODES_3X3, "3x3" },
1676 { EXPLODES_CROSS, "3+3" },
1677 { EXPLODES_1X1, "1x1" },
1682 static struct ValueTextInfo options_time_units[] =
1685 { FRAMES_PER_SECOND, "seconds" },
1690 static struct ValueTextInfo options_change_direct_action[] =
1692 { CE_TOUCHED_BY_PLAYER, "touched by player" },
1693 { CE_PRESSED_BY_PLAYER, "pressed by player" },
1694 { CE_SWITCHED_BY_PLAYER, "switched by player" },
1695 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
1696 { CE_PUSHED_BY_PLAYER, "pushed by player" },
1697 { CE_ENTERED_BY_PLAYER, "entered by player" },
1698 { CE_LEFT_BY_PLAYER, "left by player" },
1699 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
1700 { CE_SWITCHED, "switched" },
1701 { CE_HITTING_SOMETHING, "hitting something" },
1702 { CE_HIT_BY_SOMETHING, "hit by something" },
1704 { CE_BLOCKED, "blocked" },
1706 { CE_IMPACT, "impact (on something)" },
1707 { CE_SMASHED, "smashed (from above)" },
1709 { CE_VALUE_CHANGES, "CE value changes" },
1710 { CE_SCORE_CHANGES, "CE score changes" },
1712 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
1713 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
1718 static struct ValueTextInfo options_change_other_action[] =
1720 { CE_PLAYER_TOUCHES_X, "player touches" },
1721 { CE_PLAYER_PRESSES_X, "player presses" },
1722 { CE_PLAYER_SWITCHES_X, "player switches" },
1723 { CE_PLAYER_SNAPS_X, "player snaps" },
1724 { CE_PLAYER_PUSHES_X, "player pushes" },
1725 { CE_PLAYER_ENTERS_X, "player enters" },
1726 { CE_PLAYER_LEAVES_X, "player leaves" },
1727 { CE_PLAYER_DIGS_X, "player digs" },
1728 { CE_PLAYER_COLLECTS_X, "player collects" },
1729 { CE_PLAYER_DROPS_X, "player drops/throws" },
1730 { CE_TOUCHING_X, "touching" },
1731 { CE_HITTING_X, "hitting" },
1732 { CE_DIGGING_X, "digging" },
1733 { CE_HIT_BY_X, "hit by" },
1734 { CE_SWITCH_OF_X, "switch of" },
1735 { CE_CHANGE_OF_X, "change by page of" },
1736 { CE_EXPLOSION_OF_X, "explosion of" },
1737 { CE_MOVE_OF_X, "move of" },
1738 { CE_CREATION_OF_X, "creation of" },
1739 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
1740 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
1741 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
1742 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
1747 static struct ValueTextInfo options_change_trigger_side[] =
1749 { CH_SIDE_LEFT, "left" },
1750 { CH_SIDE_RIGHT, "right" },
1751 { CH_SIDE_TOP, "top" },
1752 { CH_SIDE_BOTTOM, "bottom" },
1753 { CH_SIDE_LEFT_RIGHT, "left/right" },
1754 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
1755 { CH_SIDE_ANY, "any" },
1760 static struct ValueTextInfo options_change_trigger_player[] =
1762 { CH_PLAYER_1, "1" },
1763 { CH_PLAYER_2, "2" },
1764 { CH_PLAYER_3, "3" },
1765 { CH_PLAYER_4, "4" },
1766 { CH_PLAYER_ANY, "any" },
1771 static struct ValueTextInfo options_change_trigger_page[] =
1783 { (1 << 10), "11" },
1784 { (1 << 11), "12" },
1785 { (1 << 12), "13" },
1786 { (1 << 13), "14" },
1787 { (1 << 14), "15" },
1788 { (1 << 15), "16" },
1789 { (1 << 16), "17" },
1790 { (1 << 17), "18" },
1791 { (1 << 18), "19" },
1792 { (1 << 19), "20" },
1793 { (1 << 20), "21" },
1794 { (1 << 21), "22" },
1795 { (1 << 22), "23" },
1796 { (1 << 23), "24" },
1797 { (1 << 24), "25" },
1798 { (1 << 25), "26" },
1799 { (1 << 26), "27" },
1800 { (1 << 27), "28" },
1801 { (1 << 28), "29" },
1802 { (1 << 29), "30" },
1803 { (1 << 30), "31" },
1804 { (1 << 31), "32" },
1805 { CH_PAGE_ANY, "any" },
1810 static struct ValueTextInfo options_change_replace_when[] =
1812 { CP_WHEN_EMPTY, "empty" },
1813 { CP_WHEN_WALKABLE, "walkable" },
1814 { CP_WHEN_DIGGABLE, "diggable" },
1815 { CP_WHEN_COLLECTIBLE, "collectible" },
1816 { CP_WHEN_REMOVABLE, "removable" },
1817 { CP_WHEN_DESTRUCTIBLE, "destructible" },
1822 static struct ValueTextInfo options_action_type[] =
1824 { CA_NO_ACTION, "no action" },
1825 { CA_UNDEFINED, " " },
1826 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
1827 { CA_RESTART_LEVEL, "restart level" },
1828 { CA_SHOW_ENVELOPE, "show envelope" },
1829 { CA_SET_LEVEL_TIME, "set time" },
1830 { CA_SET_LEVEL_SCORE, "set score" },
1831 { CA_SET_LEVEL_GEMS, "set gems" },
1832 { CA_SET_LEVEL_WIND, "set wind dir." },
1833 { CA_SET_LEVEL_RANDOM_SEED, "set rand. seed" },
1834 { CA_UNDEFINED, " " },
1835 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
1836 { CA_MOVE_PLAYER, "move player" },
1837 { CA_EXIT_PLAYER, "exit player" },
1838 { CA_KILL_PLAYER, "kill player" },
1839 { CA_SET_PLAYER_KEYS, "set keys" },
1840 { CA_SET_PLAYER_SPEED, "set speed" },
1841 { CA_SET_PLAYER_SHIELD, "set shield" },
1842 { CA_SET_PLAYER_GRAVITY, "set gravity" },
1843 { CA_SET_PLAYER_ARTWORK, "set artwork" },
1844 { CA_SET_PLAYER_INVENTORY, "set inventory" },
1845 { CA_UNDEFINED, " " },
1846 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
1847 { CA_SET_CE_VALUE, "set CE value" },
1848 { CA_SET_CE_SCORE, "set CE score" },
1849 { CA_SET_CE_ARTWORK, "set CE artwork" },
1850 { CA_UNDEFINED, " " },
1851 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
1852 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
1857 static struct ValueTextInfo options_action_mode_none[] =
1859 { CA_MODE_UNDEFINED, " " },
1864 static struct ValueTextInfo options_action_mode_assign[] =
1866 { CA_MODE_SET, "=" },
1871 static struct ValueTextInfo options_action_mode_add_remove[] =
1873 { CA_MODE_ADD, "+" },
1874 { CA_MODE_SUBTRACT, "-" },
1879 static struct ValueTextInfo options_action_mode_calculate[] =
1881 { CA_MODE_SET, "=" },
1882 { CA_MODE_ADD, "+" },
1883 { CA_MODE_SUBTRACT, "-" },
1884 { CA_MODE_MULTIPLY, "*" },
1885 { CA_MODE_DIVIDE, "/" },
1886 { CA_MODE_MODULO, "%" },
1891 static struct ValueTextInfo options_action_arg_none[] =
1893 { CA_ARG_UNDEFINED, " " },
1898 static struct ValueTextInfo options_action_arg_player[] =
1900 { CA_ARG_PLAYER_HEADLINE, "[player]" },
1901 { CA_ARG_PLAYER_1, "1" },
1902 { CA_ARG_PLAYER_2, "2" },
1903 { CA_ARG_PLAYER_3, "3" },
1904 { CA_ARG_PLAYER_4, "4" },
1905 { CA_ARG_PLAYER_ANY, "any" },
1906 { CA_ARG_PLAYER_TRIGGER, "trigger" },
1907 { CA_ARG_PLAYER_ACTION, "action ->" },
1912 static struct ValueTextInfo options_action_arg_number[] =
1914 { CA_ARG_NUMBER_HEADLINE, "[number]" },
1921 { CA_ARG_10, "10" },
1922 { CA_ARG_100, "100" },
1923 { CA_ARG_1000, "1000" },
1924 { CA_ARG_UNDEFINED, " " },
1925 { CA_ARG_NUMBER_MIN, "min" },
1926 { CA_ARG_NUMBER_MAX, "max" },
1927 { CA_ARG_UNDEFINED, " " },
1928 { CA_ARG_NUMBER_RESET, "reset" },
1929 { CA_ARG_UNDEFINED, " " },
1930 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
1931 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
1932 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
1933 { CA_ARG_UNDEFINED, " " },
1934 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
1935 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
1936 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
1937 { CA_ARG_UNDEFINED, " " },
1938 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
1939 { CA_ARG_ELEMENT_CV_TARGET, "target" },
1940 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
1941 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
1942 { CA_ARG_UNDEFINED, " " },
1943 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
1944 { CA_ARG_ELEMENT_CS_TARGET, "target" },
1945 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
1946 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
1951 static struct ValueTextInfo options_action_arg_value[] =
1953 { CA_ARG_NUMBER_HEADLINE, "[number]" },
1960 { CA_ARG_10, "10" },
1961 { CA_ARG_100, "100" },
1962 { CA_ARG_1000, "1000" },
1963 { CA_ARG_UNDEFINED, " " },
1964 { CA_ARG_NUMBER_MIN, "min" },
1965 { CA_ARG_NUMBER_MAX, "max" },
1966 { CA_ARG_UNDEFINED, " " },
1967 { CA_ARG_NUMBER_RESET, "reset" },
1968 { CA_ARG_UNDEFINED, " " },
1969 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
1970 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
1971 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
1972 { CA_ARG_UNDEFINED, " " },
1973 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
1974 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
1975 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
1976 { CA_ARG_UNDEFINED, " " },
1977 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
1978 { CA_ARG_ELEMENT_CV_TARGET, "target" },
1979 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
1980 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
1981 { CA_ARG_UNDEFINED, " " },
1982 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
1983 { CA_ARG_ELEMENT_CS_TARGET, "target" },
1984 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
1985 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
1986 { CA_ARG_UNDEFINED, " " },
1987 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
1988 { CA_ARG_ELEMENT_NR_TARGET, "target" },
1989 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
1990 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
1995 static struct ValueTextInfo options_action_arg_envelope[] =
1997 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2002 { CA_ARG_UNDEFINED, " " },
2003 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2004 { CA_ARG_ELEMENT_TARGET, "target" },
2005 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2006 { CA_ARG_ELEMENT_ACTION, "action ->" },
2011 static struct ValueTextInfo options_action_arg_key[] =
2013 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2022 { CA_ARG_UNDEFINED, " " },
2023 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2024 { CA_ARG_ELEMENT_TARGET, "target" },
2025 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2026 { CA_ARG_ELEMENT_ACTION, "action ->" },
2031 static struct ValueTextInfo options_action_arg_speed[] =
2033 { CA_ARG_SPEED_HEADLINE, "[speed]" },
2034 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
2035 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
2036 { CA_ARG_SPEED_SLOW, "slow" },
2037 { CA_ARG_SPEED_NORMAL, "normal" },
2038 { CA_ARG_SPEED_FAST, "fast" },
2039 { CA_ARG_SPEED_VERY_FAST, "very fast" },
2040 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
2041 { CA_ARG_UNDEFINED, " " },
2042 { CA_ARG_SPEED_SLOWER, "slower" },
2043 { CA_ARG_SPEED_FASTER, "faster" },
2044 { CA_ARG_UNDEFINED, " " },
2045 { CA_ARG_SPEED_RESET, "reset" },
2050 static struct ValueTextInfo options_action_arg_shield[] =
2052 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
2053 { CA_ARG_SHIELD_OFF, "off" },
2054 { CA_ARG_SHIELD_NORMAL, "normal" },
2055 { CA_ARG_SHIELD_DEADLY, "deadly" },
2060 static struct ValueTextInfo options_action_arg_artwork[] =
2062 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2063 { CA_ARG_ELEMENT_TARGET, "target" },
2064 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2065 { CA_ARG_ELEMENT_ACTION, "action ->" },
2066 { CA_ARG_UNDEFINED, " " },
2067 { CA_ARG_ELEMENT_RESET, "reset" },
2072 static struct ValueTextInfo options_action_arg_gravity[] =
2074 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
2075 { CA_ARG_GRAVITY_ON, "on" },
2076 { CA_ARG_GRAVITY_OFF, "off" },
2077 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2082 static struct ValueTextInfo options_action_arg_direction[] =
2084 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2085 { CA_ARG_DIRECTION_NONE, "none" },
2086 { CA_ARG_DIRECTION_LEFT, "left" },
2087 { CA_ARG_DIRECTION_RIGHT, "right" },
2088 { CA_ARG_DIRECTION_UP, "up" },
2089 { CA_ARG_DIRECTION_DOWN, "down" },
2090 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2091 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2096 static struct ValueTextInfo options_action_arg_scan_mode[] =
2098 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2099 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2100 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2105 static struct ValueTextInfo options_action_arg_inventory[] =
2107 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2108 { CA_ARG_ELEMENT_TARGET, "+ target" },
2109 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2110 { CA_ARG_ELEMENT_ACTION, "+ action" },
2111 { CA_ARG_UNDEFINED, " " },
2112 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2113 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2114 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2115 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2116 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2117 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2118 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2119 { CA_ARG_UNDEFINED, " " },
2120 { CA_ARG_INVENTORY_RESET, "reset" },
2125 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2126 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2131 static struct ValueTextInfo options_group_choice_mode[] =
2133 { ANIM_RANDOM, "random" },
2134 { ANIM_LOOP, "loop" },
2135 { ANIM_LINEAR, "linear" },
2136 { ANIM_PINGPONG, "pingpong" },
2137 { ANIM_PINGPONG2, "pingpong 2" },
2142 static struct ValueTextInfo *action_arg_modes[] =
2144 options_action_mode_none,
2145 options_action_mode_assign,
2146 options_action_mode_add_remove,
2147 options_action_mode_calculate,
2154 struct ValueTextInfo *options;
2156 action_arg_options[] =
2158 { CA_NO_ACTION, 0, options_action_arg_none, },
2159 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2160 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2161 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2162 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2163 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2164 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2165 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2166 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2167 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2168 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2169 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2170 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2171 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2172 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2173 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2174 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2175 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2176 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2177 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2178 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2187 int gadget_id_align;
2188 int size; /* char size of selectbox or '-1' (dynamically determined) */
2189 struct ValueTextInfo *options;
2191 char *text_left, *text_right, *infotext;
2192 } selectbox_info[ED_NUM_SELECTBOX] =
2194 /* ---------- level and editor settings ---------------------------------- */
2197 -1, ED_LEVEL_SETTINGS_YPOS(7),
2198 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2200 options_time_or_steps,
2201 &level.use_step_counter,
2202 NULL, "(0 => no limit)", "time or step limit"
2205 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
2206 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2208 options_game_engine_type,
2209 &level.game_engine_type,
2210 "game engine:", NULL, "game engine"
2213 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2214 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2216 options_wind_direction,
2217 &level.wind_direction_initial,
2218 "initial wind direction:", NULL, "initial wind direction"
2221 /* ---------- element settings: configure (several elements) ------------- */
2224 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
2225 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2227 options_player_speed,
2228 &level.initial_player_stepsize[0],
2229 "initial player speed:", NULL, "initial player speed"
2232 /* ---------- element settings: configure 1 (custom elements) ------------ */
2235 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2236 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2238 options_access_type,
2239 &custom_element.access_type,
2240 NULL, NULL, "type of access to this field"
2243 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2244 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2246 options_access_layer,
2247 &custom_element.access_layer,
2248 NULL, NULL, "layer of access for this field"
2251 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2252 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2254 options_access_protected,
2255 &custom_element.access_protected,
2256 NULL, NULL, "protected access for this field"
2259 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2260 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2262 options_access_direction,
2263 &custom_element.access_direction,
2264 "from", NULL, "access direction for this field"
2267 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2268 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2270 options_walk_to_action,
2271 &custom_element.walk_to_action,
2272 NULL, NULL, "diggable/collectible/pushable"
2275 /* ---------- element settings: configure 2 (custom elements) ------------ */
2278 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2279 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2281 options_move_pattern,
2282 &custom_element.move_pattern,
2283 "can move", NULL, "element move pattern"
2286 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2287 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2289 options_move_direction,
2290 &custom_element.move_direction_initial,
2291 "starts moving", NULL, "initial element move direction"
2294 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2295 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2297 options_move_stepsize,
2298 &custom_element.move_stepsize,
2299 "move/fall speed", NULL, "speed of element movement"
2302 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2303 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2305 options_move_leave_type,
2306 &custom_element.move_leave_type,
2307 "can dig: can", ":", "leave behind or change element"
2310 -1, ED_ELEMENT_SETTINGS_YPOS(7),
2311 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2313 options_smash_targets,
2314 &custom_element.smash_targets,
2315 "can smash", NULL, "elements that can be smashed"
2318 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
2319 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2321 options_slippery_type,
2322 &custom_element.slippery_type,
2323 "slippery", NULL, "where other elements fall down"
2326 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2327 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2330 &custom_element.deadliness,
2331 "deadly when", NULL, "deadliness of element"
2334 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2335 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2337 options_explosion_type,
2338 &custom_element.explosion_type,
2339 "can explode", NULL, "explosion type"
2342 /* ---------- element settings: advanced (custom elements) --------------- */
2345 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2346 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2349 &custom_element_change.delay_frames,
2350 "delay time given in", NULL, "delay time units for change"
2353 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2354 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2356 options_change_direct_action,
2357 &custom_element_change.direct_action,
2358 NULL, NULL, "type of direct action"
2361 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2362 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2364 options_change_other_action,
2365 &custom_element_change.other_action,
2366 NULL, "element:", "type of other element action"
2369 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2370 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2372 options_change_trigger_side,
2373 &custom_element_change.trigger_side,
2374 "at", "side", "element side triggering change"
2377 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2378 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2380 options_change_trigger_player,
2381 &custom_element_change.trigger_player,
2382 "player:", " ", "player that causes change"
2385 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2386 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2388 options_change_trigger_page,
2389 &custom_element_change.trigger_page,
2390 "page:", NULL, "change page that causes change"
2393 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2394 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2396 options_change_replace_when,
2397 &custom_element_change.replace_when,
2398 "replace when", NULL, "which elements can be replaced"
2401 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2402 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2404 options_action_type,
2405 &custom_element_change.action_type,
2406 NULL, NULL, "action on specified condition"
2409 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2410 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2412 options_action_mode_none,
2413 &custom_element_change.action_mode,
2414 NULL, NULL, "action operator"
2417 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2418 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2420 options_action_arg_none,
2421 &custom_element_change.action_arg,
2422 NULL, NULL, "action parameter"
2425 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2426 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2428 options_change_page,
2429 &custom_element.current_change_page,
2430 NULL, NULL, "element change page"
2433 /* ---------- element settings: configure (group elements) --------------- */
2436 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2437 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2439 options_group_choice_mode,
2440 &group_element_info.choice_mode,
2441 "choice type:", NULL, "type of group element choice"
2449 int gadget_id_align;
2452 char *text_left, *text_right, *infotext;
2453 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2456 ED_LEVEL_SETTINGS_TABS_XPOS(0), ED_LEVEL_SETTINGS_TABS_YPOS(0),
2457 GADGET_ID_LEVELINFO_LEVEL, GADGET_ID_NONE,
2459 NULL, NULL, "Configure level properties"
2462 ED_LEVEL_SETTINGS_TABS_XPOS(1), ED_LEVEL_SETTINGS_TABS_YPOS(0),
2463 GADGET_ID_LEVELINFO_EDITOR, GADGET_ID_NONE,
2465 NULL, NULL, "Configure editor properties"
2468 ED_ELEMENT_SETTINGS_TABS_XPOS(0), ED_ELEMENT_SETTINGS_TABS_YPOS(0),
2469 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
2471 NULL, NULL, "Show information about element"
2474 ED_ELEMENT_SETTINGS_TABS_XPOS(1), ED_ELEMENT_SETTINGS_TABS_YPOS(0),
2475 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_NONE,
2477 NULL, NULL, "Configure element properties"
2480 ED_ELEMENT_SETTINGS_TABS_XPOS(1), ED_ELEMENT_SETTINGS_TABS_YPOS(0),
2481 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_NONE,
2483 NULL, NULL, "Configure element properties, part 1"
2486 ED_ELEMENT_SETTINGS_TABS_XPOS(2), ED_ELEMENT_SETTINGS_TABS_YPOS(0),
2487 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_NONE,
2489 NULL, NULL, "Configure element properties, part 2"
2492 ED_ELEMENT_SETTINGS_TABS_XPOS(3), ED_ELEMENT_SETTINGS_TABS_YPOS(0),
2493 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_NONE,
2495 NULL, NULL, "Configure custom element change pages"
2498 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2499 GADGET_ID_SAVE_AS_TEMPLATE, GADGET_ID_CUSTOM_USE_TEMPLATE,
2501 " ", "As Template", "Save current settings as new template"
2504 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2505 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
2507 NULL, NULL, "Add new change page"
2510 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2511 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
2513 NULL, NULL, "Delete current change page"
2523 int gadget_id_align;
2524 char *text_left, *text_right, *infotext;
2525 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
2528 ED_BUTTON_MINUS_XPOS, ED_BUTTON_COUNT_YPOS,
2529 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
2530 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
2531 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
2532 NULL, NULL, "select previous change page"
2535 ED_BUTTON_PLUS_XPOS, ED_BUTTON_COUNT_YPOS,
2536 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2537 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
2538 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
2539 NULL, "change page", "select next change page"
2542 ED_COPY_CHANGE_PAGE_XPOS, ED_COPY_CHANGE_PAGE_YPOS,
2543 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2544 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
2545 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
2546 " ", NULL, "copy settings from this change page"
2549 ED_PASTE_CHANGE_PAGE_XPOS, ED_PASTE_CHANGE_PAGE_YPOS,
2550 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2551 ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
2552 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
2553 NULL, NULL, "paste settings to this change page"
2560 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
2567 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
2570 IMG_EDITOR_PLAYFIELD_SCROLL_UP,
2571 GADGET_ID_SCROLL_UP,
2572 "scroll level editing area up"
2575 IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
2576 GADGET_ID_SCROLL_DOWN,
2577 "scroll level editing area down"
2580 IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
2581 GADGET_ID_SCROLL_LEFT,
2582 "scroll level editing area left"
2585 IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
2586 GADGET_ID_SCROLL_RIGHT,
2587 "scroll level editing area right"
2590 IMG_EDITOR_PALETTE_SCROLL_UP,
2591 GADGET_ID_SCROLL_LIST_UP,
2592 "scroll element list up ('Page Up')"
2595 IMG_EDITOR_PALETTE_SCROLL_DOWN,
2596 GADGET_ID_SCROLL_LIST_DOWN,
2597 "scroll element list down ('Page Down')"
2605 int wheel_x, wheel_y;
2606 int wheel_width, wheel_height;
2607 } scrollbar_pos[ED_NUM_SCROLLBARS];
2615 } scrollbar_info[ED_NUM_SCROLLBARS] =
2618 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
2619 GD_TYPE_SCROLLBAR_HORIZONTAL,
2620 GADGET_ID_SCROLL_HORIZONTAL,
2621 "scroll level editing area horizontally"
2624 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
2625 GD_TYPE_SCROLLBAR_VERTICAL,
2626 GADGET_ID_SCROLL_VERTICAL,
2627 "scroll level editing area vertically"
2630 IMG_EDITOR_PALETTE_SCROLLBAR,
2631 GD_TYPE_SCROLLBAR_VERTICAL,
2632 GADGET_ID_SCROLL_LIST_VERTICAL,
2633 "scroll element list vertically"
2642 int gadget_id_align;
2643 int radio_button_nr;
2646 char *text_left, *text_right, *infotext;
2647 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
2650 -1, ED_LEVEL_SETTINGS_YPOS(0),
2651 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
2652 RADIO_NR_RANDOM_ELEMENTS,
2653 &random_placement_method, RANDOM_USE_PERCENTAGE,
2654 " ", "percentage", "use percentage for random elements"
2657 -1, ED_LEVEL_SETTINGS_YPOS(0),
2658 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
2659 RADIO_NR_RANDOM_ELEMENTS,
2660 &random_placement_method, RANDOM_USE_QUANTITY,
2661 " ", "quantity", "use quantity for random elements"
2669 int gadget_id_align;
2671 char *text_left, *text_right, *infotext;
2672 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
2674 /* ---------- level and editor settings ---------------------------------- */
2677 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
2678 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
2679 &random_placement_background_restricted,
2681 "restrict random placement to:", "set random placement restriction"
2684 /* ---------- element settings: configure (various elements) ------------- */
2687 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2688 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
2689 &stick_element_properties_window,
2691 "stick this screen to edit content","stick this screen to edit content"
2694 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2695 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
2696 &level.em_slippery_gems,
2698 "slip down from certain flat walls","use EM/DC style slipping behaviour"
2701 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2702 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
2703 &level.em_explodes_by_fire,
2705 "explodes with chain reaction", "use R'n'D style explosion behaviour"
2708 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2709 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
2710 &level.use_spring_bug,
2712 "use spring pushing bug", "use odd spring pushing behaviour"
2715 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2716 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
2717 &level.use_time_orb_bug,
2719 "use time orb bug", "use odd time orb behaviour"
2722 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2723 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
2726 "create single random element", "only create one element from content"
2729 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2730 GADGET_ID_INITIAL_BALL_STATE, GADGET_ID_NONE,
2731 &level.ball_state_initial,
2733 "magic ball initially activated", "activate magic ball after level start"
2736 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2737 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
2738 &level.grow_into_diggable,
2740 "can grow into anything diggable", "grow into more than just sand"
2743 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2744 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
2745 &level.auto_exit_sokoban,
2747 "exit level if all fields solved", "automatically finish Sokoban levels"
2750 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
2751 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
2752 &level.continuous_snapping,
2754 "continuous snapping", "use snapping without releasing key"
2757 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2758 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
2759 &level.block_snap_field,
2761 "block snapped field when snapping", "use snapping delay to show animation"
2764 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2765 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
2766 &level.block_last_field,
2768 "block last field when moving", "player blocks last field when moving"
2771 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2772 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
2773 &level.sp_block_last_field,
2775 "block last field when moving", "player blocks last field when moving"
2778 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
2779 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
2780 &level.instant_relocation,
2782 "no scrolling when relocating", "player gets relocated without delay"
2785 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2786 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
2787 &level.shifted_relocation,
2789 "no centering when relocating", "level not centered after relocation"
2792 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
2793 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
2794 &level.use_start_element[0],
2796 "use level start element:", "start level at this element's position"
2799 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
2800 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
2801 &level.use_artwork_element[0],
2803 "use artwork from element:", "use player artwork from other element"
2806 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
2807 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
2808 &level.use_explosion_element[0],
2810 "use explosion from element:", "use explosion properties from element"
2813 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
2814 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
2815 &level.initial_player_gravity[0],
2817 "use initial gravity", "set initial player gravity"
2820 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2821 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
2822 &level.use_initial_inventory[0],
2824 "use initial inventory:", "use collected elements on level start"
2827 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
2828 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
2829 &level.can_pass_to_walkable,
2831 "can pass to walkable element", "player can pass to empty or walkable"
2834 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2835 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
2836 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
2838 "can fall into acid (with gravity)","player can fall into acid pool"
2841 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2842 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
2843 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
2845 "can move into acid", "element can move into acid pool"
2848 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2849 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
2850 &custom_element_properties[EP_DONT_COLLIDE_WITH],
2852 "deadly when colliding with", "element is deadly when hitting player"
2855 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2856 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
2857 &level.envelope[0].autowrap,
2859 "auto-wrap", "automatically wrap envelope text"
2862 -1, ED_ELEMENT_SETTINGS_YPOS(1),
2863 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
2864 &level.envelope[0].centered,
2866 "centered", "automatically center envelope text"
2869 /* ---------- element settings: configure 1 (custom elements) ----------- */
2872 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2873 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
2874 &custom_element.use_gfx_element,
2876 "use graphic of element:", "use existing element graphic"
2879 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
2880 GADGET_ID_CUSTOM_USE_TEMPLATE, GADGET_ID_NONE,
2881 &level.use_custom_template,
2883 "use template", "use template for custom properties"
2886 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2887 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
2888 &custom_element_properties[EP_ACCESSIBLE],
2890 NULL, "player can walk to or pass this field"
2893 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
2894 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
2895 &custom_element_properties[EP_GRAVITY_REACHABLE],
2897 "reachable despite gravity", "player can walk/dig despite gravity"
2900 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
2901 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
2902 &custom_element.use_last_ce_value,
2904 "use last CE value after change", "use last CE value after change"
2907 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2908 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
2909 &custom_element_properties[EP_WALK_TO_OBJECT],
2911 NULL, "player can dig/collect/push element"
2914 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
2915 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
2916 &custom_element_properties[EP_INDESTRUCTIBLE],
2918 "indestructible", "element is indestructible"
2921 /* ---------- element settings: configure 2 (custom elements) ----------- */
2924 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2925 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
2926 &custom_element_properties[EP_CAN_MOVE],
2928 NULL, "element can move with some pattern"
2931 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2932 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
2933 &custom_element_properties[EP_CAN_FALL],
2935 "can fall", "element can fall down"
2938 -1, ED_ELEMENT_SETTINGS_YPOS(7),
2939 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
2940 &custom_element_properties[EP_CAN_SMASH],
2942 NULL, "element can smash other elements"
2945 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
2946 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
2947 &custom_element_properties[EP_SLIPPERY],
2949 NULL, "other elements can fall down from it"
2952 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
2953 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
2954 &custom_element_properties[EP_DEADLY],
2956 NULL, "element can kill the player"
2959 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
2960 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
2961 &custom_element_properties[EP_CAN_EXPLODE],
2963 NULL, "element can explode"
2966 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
2967 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
2968 &custom_element_properties[EP_EXPLODES_BY_FIRE],
2970 "by fire", "element can explode by fire/explosion"
2973 -1, ED_ELEMENT_SETTINGS_YPOS(11),
2974 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
2975 &custom_element_properties[EP_EXPLODES_SMASHED],
2977 "smashed", "element can explode when smashed"
2980 -1, ED_ELEMENT_SETTINGS_YPOS(11),
2981 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
2982 &custom_element_properties[EP_EXPLODES_IMPACT],
2984 "impact", "element can explode on impact"
2987 /* ---------- element settings: advanced (custom elements) --------------- */
2990 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2991 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
2992 &custom_element_change.can_change,
2994 "element changes to:", "change element on specified condition"
2997 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2998 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
2999 &custom_element_change_events[CE_DELAY],
3001 NULL, "element changes after delay"
3004 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
3005 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
3006 &custom_element_change_events[CE_BY_DIRECT_ACTION],
3008 NULL, "element changes by direct action"
3011 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
3012 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
3013 &custom_element_change_events[CE_BY_OTHER_ACTION],
3015 NULL, "element changes by other element"
3018 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
3019 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
3020 &custom_element_change.explode,
3022 "explode instead of change", "element explodes instead of change"
3025 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
3026 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
3027 &custom_element_change.use_target_content,
3029 "use extended change target:", "element changes to more elements"
3032 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3033 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3034 &custom_element_change.only_if_complete,
3036 "replace all or nothing", "only replace when all can be changed"
3039 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3040 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3041 &custom_element_change.use_random_replace,
3043 NULL, "use percentage for random replace"
3046 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3047 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3048 &custom_element_change.has_action,
3050 NULL, "execute action on specified condition"
3058 int gadget_id_align;
3060 int area_xsize, area_ysize;
3061 char *text_left, *text_right, *text_below, *infotext;
3062 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3064 /* ---------- level playfield content ------------------------------------ */
3068 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
3070 -1, -1, /* these values are not constant, but can change at runtime */
3071 NULL, NULL, NULL, NULL
3074 /* ---------- yam yam content -------------------------------------------- */
3077 ED_AREA_YAMYAM_CONTENT_XPOS(0), ED_AREA_YAMYAM_CONTENT_YPOS(0),
3078 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
3079 &level.yamyam_content[0].e[0][0], 3, 3,
3080 NULL, NULL, "1", NULL
3083 ED_AREA_YAMYAM_CONTENT_XPOS(1), ED_AREA_YAMYAM_CONTENT_YPOS(1),
3084 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
3085 &level.yamyam_content[1].e[0][0], 3, 3,
3086 NULL, NULL, "2", NULL
3089 ED_AREA_YAMYAM_CONTENT_XPOS(2), ED_AREA_YAMYAM_CONTENT_YPOS(2),
3090 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
3091 &level.yamyam_content[2].e[0][0], 3, 3,
3092 NULL, NULL, "3", NULL
3095 ED_AREA_YAMYAM_CONTENT_XPOS(3), ED_AREA_YAMYAM_CONTENT_YPOS(3),
3096 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
3097 &level.yamyam_content[3].e[0][0], 3, 3,
3098 NULL, NULL, "4", NULL
3101 ED_AREA_YAMYAM_CONTENT_XPOS(4), ED_AREA_YAMYAM_CONTENT_YPOS(4),
3102 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
3103 &level.yamyam_content[4].e[0][0], 3, 3,
3104 NULL, NULL, "5", NULL
3107 ED_AREA_YAMYAM_CONTENT_XPOS(5), ED_AREA_YAMYAM_CONTENT_YPOS(5),
3108 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
3109 &level.yamyam_content[5].e[0][0], 3, 3,
3110 NULL, NULL, "6", NULL
3113 ED_AREA_YAMYAM_CONTENT_XPOS(6), ED_AREA_YAMYAM_CONTENT_YPOS(6),
3114 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
3115 &level.yamyam_content[6].e[0][0], 3, 3,
3116 NULL, NULL, "7", NULL
3119 ED_AREA_YAMYAM_CONTENT_XPOS(7), ED_AREA_YAMYAM_CONTENT_YPOS(7),
3120 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
3121 &level.yamyam_content[7].e[0][0], 3, 3,
3122 NULL, NULL, "8", NULL
3125 /* ---------- magic ball content ----------------------------------------- */
3128 ED_AREA_MAGIC_BALL_CONTENT_XPOS(0), ED_AREA_MAGIC_BALL_CONTENT_YPOS(0),
3129 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
3130 &level.ball_content[0].e[0][0], 3, 3,
3131 NULL, NULL, "1", NULL
3134 ED_AREA_MAGIC_BALL_CONTENT_XPOS(1), ED_AREA_MAGIC_BALL_CONTENT_YPOS(1),
3135 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
3136 &level.ball_content[1].e[0][0], 3, 3,
3137 NULL, NULL, "2", NULL
3140 ED_AREA_MAGIC_BALL_CONTENT_XPOS(2), ED_AREA_MAGIC_BALL_CONTENT_YPOS(2),
3141 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
3142 &level.ball_content[2].e[0][0], 3, 3,
3143 NULL, NULL, "3", NULL
3146 ED_AREA_MAGIC_BALL_CONTENT_XPOS(3), ED_AREA_MAGIC_BALL_CONTENT_YPOS(3),
3147 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
3148 &level.ball_content[3].e[0][0], 3, 3,
3149 NULL, NULL, "4", NULL
3152 ED_AREA_MAGIC_BALL_CONTENT_XPOS(4), ED_AREA_MAGIC_BALL_CONTENT_YPOS(4),
3153 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
3154 &level.ball_content[4].e[0][0], 3, 3,
3155 NULL, NULL, "5", NULL
3158 ED_AREA_MAGIC_BALL_CONTENT_XPOS(5), ED_AREA_MAGIC_BALL_CONTENT_YPOS(5),
3159 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
3160 &level.ball_content[5].e[0][0], 3, 3,
3161 NULL, NULL, "6", NULL
3164 ED_AREA_MAGIC_BALL_CONTENT_XPOS(6), ED_AREA_MAGIC_BALL_CONTENT_YPOS(6),
3165 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
3166 &level.ball_content[6].e[0][0], 3, 3,
3167 NULL, NULL, "7", NULL
3170 ED_AREA_MAGIC_BALL_CONTENT_XPOS(7), ED_AREA_MAGIC_BALL_CONTENT_YPOS(7),
3171 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
3172 &level.ball_content[7].e[0][0], 3, 3,
3173 NULL, NULL, "8", NULL
3176 /* ---------- android content -------------------------------------------- */
3179 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(5),
3180 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
3181 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
3182 "elements:", NULL, NULL, "elements android can clone"
3185 /* ---------- amoeba content --------------------------------------------- */
3188 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
3189 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
3190 &level.amoeba_content, 1, 1,
3191 "content:", NULL, NULL, "amoeba content"
3194 /* ---------- level start element ---------------------------------------- */
3197 -1, ED_AREA_1X1_SETTINGS_YPOS(9),
3198 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
3199 &level.start_element[0], 1, 1,
3200 NULL, NULL, NULL, "level start element"
3203 /* ---------- player artwork element ------------------------------------- */
3206 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
3207 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
3208 &level.artwork_element[0], 1, 1,
3209 NULL, NULL, NULL, "element for player artwork"
3212 /* ---------- player explosion element ----------------------------------- */
3215 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
3216 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
3217 &level.explosion_element[0], 1, 1,
3218 NULL, NULL, NULL, "element for player explosion"
3221 /* ---------- player initial inventory ----------------------------------- */
3224 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3225 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
3226 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
3227 NULL, NULL, NULL, "content for initial inventory"
3230 /* ---------- element settings: configure 1 (custom elements) ----------- */
3232 /* ---------- custom graphic --------------------------------------------- */
3235 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3236 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
3237 &custom_element.gfx_element_initial,1, 1,
3238 NULL, NULL, NULL, "custom graphic element"
3241 /* ---------- element settings: configure 2 (custom elements) ----------- */
3243 /* ---------- custom content (when exploding) ---------------------------- */
3246 -1, ED_AREA_3X3_SETTINGS_YPOS(10),
3247 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, /* align three rows */
3248 &custom_element.content.e[0][0], 3, 3,
3249 "content:", NULL, NULL, NULL
3252 /* ---------- custom enter and leave element (when moving) --------------- */
3255 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
3256 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
3257 &custom_element.move_enter_element, 1, 1,
3258 "can dig:", " ", NULL, "element that can be digged/collected"
3261 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
3262 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
3263 &custom_element.move_leave_element, 1, 1,
3264 NULL, NULL, NULL, "element that will be left behind"
3267 /* ---------- element settings: advanced (custom elements) --------------- */
3269 /* ---------- custom change target --------------------------------------- */
3272 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3273 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
3274 &custom_element_change.target_element, 1, 1,
3275 NULL, "after/when:", NULL, "new target element after change"
3278 /* ---------- custom change content (extended change target) ------------- */
3281 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
3282 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, /* align three rows */
3283 &custom_element_change.target_content.e[0][0], 3, 3,
3284 NULL, NULL, NULL, "new extended elements after change"
3287 /* ---------- custom change trigger (element causing change) ------------- */
3290 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
3291 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
3292 &custom_element_change.initial_trigger_element, 1, 1,
3293 NULL, NULL, NULL, "other element triggering change"
3296 /* ---------- custom change action (element used for action) ------------- */
3299 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
3300 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
3301 &custom_element_change.action_element, 1, 1,
3302 NULL, NULL, NULL, "element used as action parameter"
3305 /* ---------- group element content -------------------------------------- */
3308 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
3309 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
3310 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
3311 "content:", NULL, NULL, NULL
3314 /* ---------- random background (for random painting) -------------------- */
3317 -1, ED_AREA_1X1_SETTINGS_YPOS(-1),
3318 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
3319 &random_placement_background_element, 1, 1,
3320 NULL, NULL, NULL, "random placement background"
3326 -----------------------------------------------------------------------------
3327 some internally used variables
3328 -----------------------------------------------------------------------------
3331 /* maximal size of level editor drawing area */
3332 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
3334 /* actual size of level editor drawing area */
3335 static int ed_fieldx, ed_fieldy;
3337 /* actual position of level editor drawing area in level playfield */
3338 static int level_xpos = -1, level_ypos = -1;
3340 /* actual tile size used to display level editor playfield */
3341 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
3343 #define IN_ED_FIELD(x,y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
3345 /* drawing elements on the three mouse buttons */
3346 static int new_element1 = EL_WALL;
3347 static int new_element2 = EL_EMPTY;
3348 static int new_element3 = EL_SAND;
3350 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
3351 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
3352 (button) == 2 ? new_element2 : \
3353 (button) == 3 ? new_element3 : EL_EMPTY)
3354 #define BUTTON_STEPSIZE(button) ((button) == 1 ? 1 : \
3355 (button) == 2 ? 5 : \
3356 (button) == 3 ? 10 : \
3359 /* forward declaration for internal use */
3360 static void ModifyEditorCounterValue(int, int);
3361 static void ModifyEditorCounterLimits(int, int, int);
3362 static void ModifyEditorSelectboxValue(int, int);
3363 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
3364 static void ModifyEditorDrawingArea(int, int, int);
3365 static void ModifyEditorElementList();
3366 static void AdjustElementListScrollbar();
3367 static void RedrawDrawingElements();
3368 static void DrawDrawingWindow();
3369 static void DrawLevelInfoWindow();
3370 static void DrawPropertiesWindow();
3371 static void UpdateCustomElementGraphicGadgets();
3372 static boolean checkPropertiesConfig(int);
3373 static void CopyLevelToUndoBuffer(int);
3374 static void HandleDrawingAreas(struct GadgetInfo *);
3375 static void HandleCounterButtons(struct GadgetInfo *);
3376 static void HandleTextInputGadgets(struct GadgetInfo *);
3377 static void HandleTextAreaGadgets(struct GadgetInfo *);
3378 static void HandleSelectboxGadgets(struct GadgetInfo *);
3379 static void HandleTextbuttonGadgets(struct GadgetInfo *);
3380 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
3381 static void HandleRadiobuttons(struct GadgetInfo *);
3382 static void HandleCheckbuttons(struct GadgetInfo *);
3383 static void HandleControlButtons(struct GadgetInfo *);
3384 static void HandleDrawingAreaInfo(struct GadgetInfo *);
3385 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
3387 static int num_editor_gadgets = 0; /* dynamically determined */
3389 static struct GadgetInfo **level_editor_gadget = NULL;
3390 static int *right_gadget_border = NULL;
3392 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
3393 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
3394 static boolean draw_with_brush = FALSE;
3395 static int properties_element = 0;
3397 static short FieldBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3398 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3399 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3400 static int undo_buffer_position = 0;
3401 static int undo_buffer_steps = 0;
3402 static int redo_buffer_steps = 0;
3404 static int edit_mode;
3405 static int edit_mode_levelinfo;
3406 static int edit_mode_properties;
3408 static int element_shift = 0;
3410 static int editor_el_players[] =
3417 static int *editor_el_players_ptr = editor_el_players;
3418 static int num_editor_el_players = SIZEOF_ARRAY_INT(editor_el_players);
3420 static int editor_hl_boulderdash[] =
3422 EL_INTERNAL_CASCADE_BD_ACTIVE,
3428 static int editor_el_boulderdash[] =
3437 EL_BD_EXPANDABLE_WALL,
3445 EL_BD_BUTTERFLY_LEFT,
3447 EL_BD_BUTTERFLY_RIGHT,
3448 EL_BD_FIREFLY_RIGHT,
3451 EL_BD_BUTTERFLY_DOWN,
3455 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
3456 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
3457 static int num_editor_hl_boulderdash = SIZEOF_ARRAY_INT(editor_hl_boulderdash);
3458 static int num_editor_el_boulderdash = SIZEOF_ARRAY_INT(editor_el_boulderdash);
3460 static int editor_hl_emerald_mine[] =
3462 EL_INTERNAL_CASCADE_EM_ACTIVE,
3468 static int editor_el_emerald_mine[] =
3505 EL_ACID_POOL_TOPLEFT,
3507 EL_ACID_POOL_TOPRIGHT,
3510 EL_ACID_POOL_BOTTOMLEFT,
3511 EL_ACID_POOL_BOTTOM,
3512 EL_ACID_POOL_BOTTOMRIGHT,
3532 EL_EM_STEEL_EXIT_CLOSED,
3533 EL_EM_STEEL_EXIT_OPEN,
3535 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
3536 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
3537 static int num_editor_hl_emerald_mine=SIZEOF_ARRAY_INT(editor_hl_emerald_mine);
3538 static int num_editor_el_emerald_mine=SIZEOF_ARRAY_INT(editor_el_emerald_mine);
3540 static int editor_hl_emerald_mine_club[] =
3542 EL_INTERNAL_CASCADE_EMC_ACTIVE,
3548 static int editor_el_emerald_mine_club[] =
3575 EL_EMC_WALL_SLIPPERY_1,
3576 EL_EMC_WALL_SLIPPERY_2,
3577 EL_EMC_WALL_SLIPPERY_3,
3578 EL_EMC_WALL_SLIPPERY_4,
3601 EL_EMC_MAGIC_BALL_SWITCH,
3603 EL_EMC_SPRING_BUMPER,
3608 EL_EM_DYNAMITE_ACTIVE,
3612 EL_BALLOON_SWITCH_UP,
3613 EL_BALLOON_SWITCH_ANY,
3616 EL_BALLOON_SWITCH_LEFT,
3618 EL_BALLOON_SWITCH_RIGHT,
3622 EL_BALLOON_SWITCH_DOWN,
3623 EL_BALLOON_SWITCH_NONE,
3625 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
3626 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
3627 static int num_editor_hl_emerald_mine_club=SIZEOF_ARRAY_INT(editor_hl_emerald_mine_club);
3628 static int num_editor_el_emerald_mine_club=SIZEOF_ARRAY_INT(editor_el_emerald_mine_club);
3630 static int editor_hl_rnd[] =
3632 EL_INTERNAL_CASCADE_RND_ACTIVE,
3638 static int editor_el_rnd[] =
3670 EL_WALL_EMERALD_YELLOW,
3671 EL_WALL_EMERALD_RED,
3672 EL_WALL_EMERALD_PURPLE,
3690 EL_DYNABOMB_INCREASE_NUMBER,
3691 EL_DYNABOMB_INCREASE_SIZE,
3692 EL_DYNABOMB_INCREASE_POWER,
3712 EL_INVISIBLE_STEELWALL,
3716 EL_EXPANDABLE_WALL_HORIZONTAL,
3717 EL_EXPANDABLE_WALL_VERTICAL,
3718 EL_EXPANDABLE_WALL_ANY,
3720 static int *editor_hl_rnd_ptr = editor_hl_rnd;
3721 static int *editor_el_rnd_ptr = editor_el_rnd;
3722 static int num_editor_hl_rnd = SIZEOF_ARRAY_INT(editor_hl_rnd);
3723 static int num_editor_el_rnd = SIZEOF_ARRAY_INT(editor_el_rnd);
3725 static int editor_hl_sokoban[] =
3727 EL_INTERNAL_CASCADE_SB_ACTIVE,
3733 static int editor_el_sokoban[] =
3736 EL_SOKOBAN_FIELD_EMPTY,
3737 EL_SOKOBAN_FIELD_FULL,
3738 EL_SOKOBAN_FIELD_PLAYER,
3740 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
3741 static int *editor_el_sokoban_ptr = editor_el_sokoban;
3742 static int num_editor_hl_sokoban = SIZEOF_ARRAY_INT(editor_hl_sokoban);
3743 static int num_editor_el_sokoban = SIZEOF_ARRAY_INT(editor_el_sokoban);
3745 static int editor_hl_supaplex[] =
3747 EL_INTERNAL_CASCADE_SP_ACTIVE,
3753 static int editor_el_supaplex[] =
3771 EL_SP_PORT_HORIZONTAL,
3772 EL_SP_PORT_VERTICAL,
3780 EL_SP_GRAVITY_PORT_LEFT,
3781 EL_SP_GRAVITY_PORT_RIGHT,
3782 EL_SP_GRAVITY_PORT_UP,
3783 EL_SP_GRAVITY_PORT_DOWN,
3785 EL_SP_GRAVITY_ON_PORT_LEFT,
3786 EL_SP_GRAVITY_ON_PORT_RIGHT,
3787 EL_SP_GRAVITY_ON_PORT_UP,
3788 EL_SP_GRAVITY_ON_PORT_DOWN,
3790 EL_SP_GRAVITY_OFF_PORT_LEFT,
3791 EL_SP_GRAVITY_OFF_PORT_RIGHT,
3792 EL_SP_GRAVITY_OFF_PORT_UP,
3793 EL_SP_GRAVITY_OFF_PORT_DOWN,
3795 EL_SP_HARDWARE_GRAY,
3796 EL_SP_HARDWARE_GREEN,
3797 EL_SP_HARDWARE_BLUE,
3800 EL_SP_HARDWARE_BASE_1,
3801 EL_SP_HARDWARE_BASE_2,
3802 EL_SP_HARDWARE_BASE_3,
3803 EL_SP_HARDWARE_BASE_4,
3805 EL_SP_HARDWARE_BASE_5,
3806 EL_SP_HARDWARE_BASE_6,
3807 EL_SP_HARDWARE_YELLOW,
3815 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
3816 static int *editor_el_supaplex_ptr = editor_el_supaplex;
3817 static int num_editor_hl_supaplex = SIZEOF_ARRAY_INT(editor_hl_supaplex);
3818 static int num_editor_el_supaplex = SIZEOF_ARRAY_INT(editor_el_supaplex);
3820 static int editor_hl_diamond_caves[] =
3822 EL_INTERNAL_CASCADE_DC_ACTIVE,
3828 static int editor_el_diamond_caves[] =
3835 EL_CONVEYOR_BELT_1_LEFT,
3836 EL_CONVEYOR_BELT_1_MIDDLE,
3837 EL_CONVEYOR_BELT_1_RIGHT,
3838 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
3840 EL_CONVEYOR_BELT_2_LEFT,
3841 EL_CONVEYOR_BELT_2_MIDDLE,
3842 EL_CONVEYOR_BELT_2_RIGHT,
3843 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
3845 EL_CONVEYOR_BELT_3_LEFT,
3846 EL_CONVEYOR_BELT_3_MIDDLE,
3847 EL_CONVEYOR_BELT_3_RIGHT,
3848 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
3850 EL_CONVEYOR_BELT_4_LEFT,
3851 EL_CONVEYOR_BELT_4_MIDDLE,
3852 EL_CONVEYOR_BELT_4_RIGHT,
3853 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
3855 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
3856 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
3857 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
3858 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
3860 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
3861 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
3862 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
3863 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
3868 EL_DC_TIMEGATE_SWITCH,
3870 EL_SWITCHGATE_CLOSED,
3872 EL_SWITCHGATE_SWITCH_UP,
3873 EL_SWITCHGATE_SWITCH_DOWN,
3876 EL_LIGHT_SWITCH_ACTIVE,
3877 EL_DC_SWITCHGATE_SWITCH_UP,
3878 EL_DC_SWITCHGATE_SWITCH_DOWN,
3880 EL_STEEL_EXIT_CLOSED,
3882 EL_STEELWALL_SLIPPERY,
3885 EL_QUICKSAND_FAST_EMPTY,
3886 EL_QUICKSAND_FAST_FULL,
3900 EL_SIGN_RADIOACTIVITY,
3906 EL_SIGN_ENTRY_FORBIDDEN,
3907 EL_SIGN_EMERGENCY_EXIT,
3932 EL_DC_STEELWALL_2_SINGLE,
3933 EL_DC_STEELWALL_2_TOP,
3934 EL_SIGN_EXCLAMATION,
3937 EL_DC_STEELWALL_2_LEFT,
3938 EL_DC_STEELWALL_2_MIDDLE,
3939 EL_DC_STEELWALL_2_HORIZONTAL,
3940 EL_DC_STEELWALL_2_RIGHT,
3942 EL_DC_STEELWALL_1_TOPLEFT,
3943 EL_DC_STEELWALL_2_VERTICAL,
3944 EL_DC_STEELWALL_1_TOPRIGHT,
3947 EL_DC_STEELWALL_1_VERTICAL,
3948 EL_DC_STEELWALL_2_BOTTOM,
3950 EL_DC_GATE_WHITE_GRAY,
3952 EL_DC_STEELWALL_1_BOTTOMLEFT,
3953 EL_DC_STEELWALL_1_HORIZONTAL,
3954 EL_DC_STEELWALL_1_BOTTOMRIGHT,
3955 EL_DC_GATE_FAKE_GRAY,
3957 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
3958 EL_DC_STEELWALL_1_BOTTOM,
3959 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
3960 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
3962 EL_DC_STEELWALL_1_RIGHT,
3964 EL_DC_STEELWALL_1_LEFT,
3965 EL_EXPANDABLE_STEELWALL_VERTICAL,
3967 EL_DC_STEELWALL_1_TOPRIGHT_2,
3968 EL_DC_STEELWALL_1_TOP,
3969 EL_DC_STEELWALL_1_TOPLEFT_2,
3970 EL_EXPANDABLE_STEELWALL_ANY,
3972 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
3973 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
3974 static int num_editor_hl_diamond_caves = SIZEOF_ARRAY_INT(editor_hl_diamond_caves);
3975 static int num_editor_el_diamond_caves = SIZEOF_ARRAY_INT(editor_el_diamond_caves);
3977 static int editor_hl_dx_boulderdash[] =
3979 EL_INTERNAL_CASCADE_DX_ACTIVE,
3985 static int editor_el_dx_boulderdash[] =
3989 EL_TUBE_HORIZONTAL_DOWN,
3993 EL_TUBE_VERTICAL_RIGHT,
3995 EL_TUBE_VERTICAL_LEFT,
3999 EL_TUBE_HORIZONTAL_UP,
4007 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
4008 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
4009 static int num_editor_hl_dx_boulderdash = SIZEOF_ARRAY_INT(editor_hl_dx_boulderdash);
4010 static int num_editor_el_dx_boulderdash = SIZEOF_ARRAY_INT(editor_el_dx_boulderdash);
4012 static int editor_hl_chars[] =
4014 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
4020 static int editor_el_chars[] =
4102 EL_CHAR(CHAR_BYTE_COPYRIGHT),
4103 EL_CHAR(CHAR_BYTE_UMLAUT_A),
4104 EL_CHAR(CHAR_BYTE_UMLAUT_O),
4105 EL_CHAR(CHAR_BYTE_UMLAUT_U),
4107 EL_CHAR(CHAR_BYTE_DEGREE),
4108 EL_CHAR(CHAR_BYTE_REGISTERED),
4109 EL_CHAR(FONT_ASCII_CURSOR),
4110 EL_CHAR(FONT_ASCII_BUTTON),
4112 EL_CHAR(FONT_ASCII_UP),
4113 EL_CHAR(FONT_ASCII_DOWN),
4117 static int *editor_hl_chars_ptr = editor_hl_chars;
4118 static int *editor_el_chars_ptr = editor_el_chars;
4119 static int num_editor_hl_chars = SIZEOF_ARRAY_INT(editor_hl_chars);
4120 static int num_editor_el_chars = SIZEOF_ARRAY_INT(editor_el_chars);
4122 static int editor_hl_steel_chars[] =
4124 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
4130 static int editor_el_steel_chars[] =
4140 EL_STEEL_CHAR('\''),
4207 EL_STEEL_CHAR('\\'),
4212 EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
4213 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
4214 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
4215 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
4217 EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
4218 EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
4219 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
4220 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
4222 EL_STEEL_CHAR(FONT_ASCII_UP),
4223 EL_STEEL_CHAR(FONT_ASCII_DOWN),
4227 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
4228 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
4229 static int num_editor_hl_steel_chars = SIZEOF_ARRAY_INT(editor_hl_steel_chars);
4230 static int num_editor_el_steel_chars = SIZEOF_ARRAY_INT(editor_el_steel_chars);
4232 static int editor_hl_custom[] =
4234 EL_INTERNAL_CASCADE_CE_ACTIVE,
4240 static int editor_el_custom[] =
4242 EL_CUSTOM_START + 0,
4243 EL_CUSTOM_START + 1,
4244 EL_CUSTOM_START + 2,
4245 EL_CUSTOM_START + 3,
4247 EL_CUSTOM_START + 4,
4248 EL_CUSTOM_START + 5,
4249 EL_CUSTOM_START + 6,
4250 EL_CUSTOM_START + 7,
4252 EL_CUSTOM_START + 8,
4253 EL_CUSTOM_START + 9,
4254 EL_CUSTOM_START + 10,
4255 EL_CUSTOM_START + 11,
4257 EL_CUSTOM_START + 12,
4258 EL_CUSTOM_START + 13,
4259 EL_CUSTOM_START + 14,
4260 EL_CUSTOM_START + 15,
4262 EL_CUSTOM_START + 16,
4263 EL_CUSTOM_START + 17,
4264 EL_CUSTOM_START + 18,
4265 EL_CUSTOM_START + 19,
4267 EL_CUSTOM_START + 20,
4268 EL_CUSTOM_START + 21,
4269 EL_CUSTOM_START + 22,
4270 EL_CUSTOM_START + 23,
4272 EL_CUSTOM_START + 24,
4273 EL_CUSTOM_START + 25,
4274 EL_CUSTOM_START + 26,
4275 EL_CUSTOM_START + 27,
4277 EL_CUSTOM_START + 28,
4278 EL_CUSTOM_START + 29,
4279 EL_CUSTOM_START + 30,
4280 EL_CUSTOM_START + 31,
4282 EL_CUSTOM_START + 32,
4283 EL_CUSTOM_START + 33,
4284 EL_CUSTOM_START + 34,
4285 EL_CUSTOM_START + 35,
4287 EL_CUSTOM_START + 36,
4288 EL_CUSTOM_START + 37,
4289 EL_CUSTOM_START + 38,
4290 EL_CUSTOM_START + 39,
4292 EL_CUSTOM_START + 40,
4293 EL_CUSTOM_START + 41,
4294 EL_CUSTOM_START + 42,
4295 EL_CUSTOM_START + 43,
4297 EL_CUSTOM_START + 44,
4298 EL_CUSTOM_START + 45,
4299 EL_CUSTOM_START + 46,
4300 EL_CUSTOM_START + 47,
4302 EL_CUSTOM_START + 48,
4303 EL_CUSTOM_START + 49,
4304 EL_CUSTOM_START + 50,
4305 EL_CUSTOM_START + 51,
4307 EL_CUSTOM_START + 52,
4308 EL_CUSTOM_START + 53,
4309 EL_CUSTOM_START + 54,
4310 EL_CUSTOM_START + 55,
4312 EL_CUSTOM_START + 56,
4313 EL_CUSTOM_START + 57,
4314 EL_CUSTOM_START + 58,
4315 EL_CUSTOM_START + 59,
4317 EL_CUSTOM_START + 60,
4318 EL_CUSTOM_START + 61,
4319 EL_CUSTOM_START + 62,
4320 EL_CUSTOM_START + 63,
4322 EL_CUSTOM_START + 64,
4323 EL_CUSTOM_START + 65,
4324 EL_CUSTOM_START + 66,
4325 EL_CUSTOM_START + 67,
4327 EL_CUSTOM_START + 68,
4328 EL_CUSTOM_START + 69,
4329 EL_CUSTOM_START + 70,
4330 EL_CUSTOM_START + 71,
4332 EL_CUSTOM_START + 72,
4333 EL_CUSTOM_START + 73,
4334 EL_CUSTOM_START + 74,
4335 EL_CUSTOM_START + 75,
4337 EL_CUSTOM_START + 76,
4338 EL_CUSTOM_START + 77,
4339 EL_CUSTOM_START + 78,
4340 EL_CUSTOM_START + 79,
4342 EL_CUSTOM_START + 80,
4343 EL_CUSTOM_START + 81,
4344 EL_CUSTOM_START + 82,
4345 EL_CUSTOM_START + 83,
4347 EL_CUSTOM_START + 84,
4348 EL_CUSTOM_START + 85,
4349 EL_CUSTOM_START + 86,
4350 EL_CUSTOM_START + 87,
4352 EL_CUSTOM_START + 88,
4353 EL_CUSTOM_START + 89,
4354 EL_CUSTOM_START + 90,
4355 EL_CUSTOM_START + 91,
4357 EL_CUSTOM_START + 92,
4358 EL_CUSTOM_START + 93,
4359 EL_CUSTOM_START + 94,
4360 EL_CUSTOM_START + 95,
4362 EL_CUSTOM_START + 96,
4363 EL_CUSTOM_START + 97,
4364 EL_CUSTOM_START + 98,
4365 EL_CUSTOM_START + 99,
4367 EL_CUSTOM_START + 100,
4368 EL_CUSTOM_START + 101,
4369 EL_CUSTOM_START + 102,
4370 EL_CUSTOM_START + 103,
4372 EL_CUSTOM_START + 104,
4373 EL_CUSTOM_START + 105,
4374 EL_CUSTOM_START + 106,
4375 EL_CUSTOM_START + 107,
4377 EL_CUSTOM_START + 108,
4378 EL_CUSTOM_START + 109,
4379 EL_CUSTOM_START + 110,
4380 EL_CUSTOM_START + 111,
4382 EL_CUSTOM_START + 112,
4383 EL_CUSTOM_START + 113,
4384 EL_CUSTOM_START + 114,
4385 EL_CUSTOM_START + 115,
4387 EL_CUSTOM_START + 116,
4388 EL_CUSTOM_START + 117,
4389 EL_CUSTOM_START + 118,
4390 EL_CUSTOM_START + 119,
4392 EL_CUSTOM_START + 120,
4393 EL_CUSTOM_START + 121,
4394 EL_CUSTOM_START + 122,
4395 EL_CUSTOM_START + 123,
4397 EL_CUSTOM_START + 124,
4398 EL_CUSTOM_START + 125,
4399 EL_CUSTOM_START + 126,
4400 EL_CUSTOM_START + 127,
4402 EL_CUSTOM_START + 128,
4403 EL_CUSTOM_START + 129,
4404 EL_CUSTOM_START + 130,
4405 EL_CUSTOM_START + 131,
4407 EL_CUSTOM_START + 132,
4408 EL_CUSTOM_START + 133,
4409 EL_CUSTOM_START + 134,
4410 EL_CUSTOM_START + 135,
4412 EL_CUSTOM_START + 136,
4413 EL_CUSTOM_START + 137,
4414 EL_CUSTOM_START + 138,
4415 EL_CUSTOM_START + 139,
4417 EL_CUSTOM_START + 140,
4418 EL_CUSTOM_START + 141,
4419 EL_CUSTOM_START + 142,
4420 EL_CUSTOM_START + 143,
4422 EL_CUSTOM_START + 144,
4423 EL_CUSTOM_START + 145,
4424 EL_CUSTOM_START + 146,
4425 EL_CUSTOM_START + 147,
4427 EL_CUSTOM_START + 148,
4428 EL_CUSTOM_START + 149,
4429 EL_CUSTOM_START + 150,
4430 EL_CUSTOM_START + 151,
4432 EL_CUSTOM_START + 152,
4433 EL_CUSTOM_START + 153,
4434 EL_CUSTOM_START + 154,
4435 EL_CUSTOM_START + 155,
4437 EL_CUSTOM_START + 156,
4438 EL_CUSTOM_START + 157,
4439 EL_CUSTOM_START + 158,
4440 EL_CUSTOM_START + 159,
4442 EL_CUSTOM_START + 160,
4443 EL_CUSTOM_START + 161,
4444 EL_CUSTOM_START + 162,
4445 EL_CUSTOM_START + 163,
4447 EL_CUSTOM_START + 164,
4448 EL_CUSTOM_START + 165,
4449 EL_CUSTOM_START + 166,
4450 EL_CUSTOM_START + 167,
4452 EL_CUSTOM_START + 168,
4453 EL_CUSTOM_START + 169,
4454 EL_CUSTOM_START + 170,
4455 EL_CUSTOM_START + 171,
4457 EL_CUSTOM_START + 172,
4458 EL_CUSTOM_START + 173,
4459 EL_CUSTOM_START + 174,
4460 EL_CUSTOM_START + 175,
4462 EL_CUSTOM_START + 176,
4463 EL_CUSTOM_START + 177,
4464 EL_CUSTOM_START + 178,
4465 EL_CUSTOM_START + 179,
4467 EL_CUSTOM_START + 180,
4468 EL_CUSTOM_START + 181,
4469 EL_CUSTOM_START + 182,
4470 EL_CUSTOM_START + 183,
4472 EL_CUSTOM_START + 184,
4473 EL_CUSTOM_START + 185,
4474 EL_CUSTOM_START + 186,
4475 EL_CUSTOM_START + 187,
4477 EL_CUSTOM_START + 188,
4478 EL_CUSTOM_START + 189,
4479 EL_CUSTOM_START + 190,
4480 EL_CUSTOM_START + 191,
4482 EL_CUSTOM_START + 192,
4483 EL_CUSTOM_START + 193,
4484 EL_CUSTOM_START + 194,
4485 EL_CUSTOM_START + 195,
4487 EL_CUSTOM_START + 196,
4488 EL_CUSTOM_START + 197,
4489 EL_CUSTOM_START + 198,
4490 EL_CUSTOM_START + 199,
4492 EL_CUSTOM_START + 200,
4493 EL_CUSTOM_START + 201,
4494 EL_CUSTOM_START + 202,
4495 EL_CUSTOM_START + 203,
4497 EL_CUSTOM_START + 204,
4498 EL_CUSTOM_START + 205,
4499 EL_CUSTOM_START + 206,
4500 EL_CUSTOM_START + 207,
4502 EL_CUSTOM_START + 208,
4503 EL_CUSTOM_START + 209,
4504 EL_CUSTOM_START + 210,
4505 EL_CUSTOM_START + 211,
4507 EL_CUSTOM_START + 212,
4508 EL_CUSTOM_START + 213,
4509 EL_CUSTOM_START + 214,
4510 EL_CUSTOM_START + 215,
4512 EL_CUSTOM_START + 216,
4513 EL_CUSTOM_START + 217,
4514 EL_CUSTOM_START + 218,
4515 EL_CUSTOM_START + 219,
4517 EL_CUSTOM_START + 220,
4518 EL_CUSTOM_START + 221,
4519 EL_CUSTOM_START + 222,
4520 EL_CUSTOM_START + 223,
4522 EL_CUSTOM_START + 224,
4523 EL_CUSTOM_START + 225,
4524 EL_CUSTOM_START + 226,
4525 EL_CUSTOM_START + 227,
4527 EL_CUSTOM_START + 228,
4528 EL_CUSTOM_START + 229,
4529 EL_CUSTOM_START + 230,
4530 EL_CUSTOM_START + 231,
4532 EL_CUSTOM_START + 232,
4533 EL_CUSTOM_START + 233,
4534 EL_CUSTOM_START + 234,
4535 EL_CUSTOM_START + 235,
4537 EL_CUSTOM_START + 236,
4538 EL_CUSTOM_START + 237,
4539 EL_CUSTOM_START + 238,
4540 EL_CUSTOM_START + 239,
4542 EL_CUSTOM_START + 240,
4543 EL_CUSTOM_START + 241,
4544 EL_CUSTOM_START + 242,
4545 EL_CUSTOM_START + 243,
4547 EL_CUSTOM_START + 244,
4548 EL_CUSTOM_START + 245,
4549 EL_CUSTOM_START + 246,
4550 EL_CUSTOM_START + 247,
4552 EL_CUSTOM_START + 248,
4553 EL_CUSTOM_START + 249,
4554 EL_CUSTOM_START + 250,
4555 EL_CUSTOM_START + 251,
4557 EL_CUSTOM_START + 252,
4558 EL_CUSTOM_START + 253,
4559 EL_CUSTOM_START + 254,
4560 EL_CUSTOM_START + 255
4562 static int *editor_hl_custom_ptr = editor_hl_custom;
4563 static int *editor_el_custom_ptr = editor_el_custom;
4564 static int num_editor_hl_custom = SIZEOF_ARRAY_INT(editor_hl_custom);
4565 static int num_editor_el_custom = SIZEOF_ARRAY_INT(editor_el_custom);
4567 static int editor_hl_group[] =
4569 EL_INTERNAL_CASCADE_GE_ACTIVE,
4575 static int editor_el_group[] =
4589 EL_GROUP_START + 10,
4590 EL_GROUP_START + 11,
4592 EL_GROUP_START + 12,
4593 EL_GROUP_START + 13,
4594 EL_GROUP_START + 14,
4595 EL_GROUP_START + 15,
4597 EL_GROUP_START + 16,
4598 EL_GROUP_START + 17,
4599 EL_GROUP_START + 18,
4600 EL_GROUP_START + 19,
4602 EL_GROUP_START + 20,
4603 EL_GROUP_START + 21,
4604 EL_GROUP_START + 22,
4605 EL_GROUP_START + 23,
4607 EL_GROUP_START + 24,
4608 EL_GROUP_START + 25,
4609 EL_GROUP_START + 26,
4610 EL_GROUP_START + 27,
4612 EL_GROUP_START + 28,
4613 EL_GROUP_START + 29,
4614 EL_GROUP_START + 30,
4617 static int *editor_hl_group_ptr = editor_hl_group;
4618 static int *editor_el_group_ptr = editor_el_group;
4619 static int num_editor_hl_group = SIZEOF_ARRAY_INT(editor_hl_group);
4620 static int num_editor_el_group = SIZEOF_ARRAY_INT(editor_el_group);
4622 static int editor_hl_reference[] =
4624 EL_INTERNAL_CASCADE_REF_ACTIVE,
4630 static int editor_el_reference[] =
4634 EL_TRIGGER_CE_VALUE,
4635 EL_TRIGGER_CE_SCORE,
4639 EL_CURRENT_CE_VALUE,
4640 EL_CURRENT_CE_SCORE,
4662 static int *editor_hl_reference_ptr = editor_hl_reference;
4663 static int *editor_el_reference_ptr = editor_el_reference;
4664 static int num_editor_hl_reference = SIZEOF_ARRAY_INT(editor_hl_reference);
4665 static int num_editor_el_reference = SIZEOF_ARRAY_INT(editor_el_reference);
4667 static int editor_hl_user_defined[] =
4669 EL_INTERNAL_CASCADE_USER_ACTIVE,
4675 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
4676 static int *editor_el_user_defined_ptr = NULL;
4677 static int num_editor_hl_user_defined=SIZEOF_ARRAY_INT(editor_hl_user_defined);
4678 static int num_editor_el_user_defined = 0;
4680 static int editor_hl_dynamic[] =
4682 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
4688 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
4689 static int *editor_el_dynamic_ptr = NULL;
4690 static int num_editor_hl_dynamic = SIZEOF_ARRAY_INT(editor_hl_dynamic);
4691 static int num_editor_el_dynamic = 0;
4693 static int editor_hl_empty[] = { EL_EMPTY };
4694 static int *editor_el_empty = NULL; /* dynamically allocated */
4696 static int *editor_hl_empty_ptr = editor_hl_empty;
4697 static int *editor_el_empty_ptr = NULL;
4698 static int num_editor_hl_empty = 0;
4699 static int num_editor_el_empty = 0; /* dynamically determined, if needed */
4701 static boolean use_el_empty = FALSE;
4703 static int *editor_elements = NULL; /* dynamically allocated */
4704 static int num_editor_elements = 0; /* dynamically determined */
4706 static boolean setup_editor_show_always = TRUE;
4707 static boolean setup_editor_cascade_never = FALSE;
4709 static int editor_hl_unused[] = { EL_EMPTY };
4710 static int *editor_hl_unused_ptr = editor_hl_unused;
4711 static int num_editor_hl_unused = 0;
4715 boolean *setup_value;
4716 boolean *setup_cascade_value;
4718 int **headline_list;
4719 int *headline_list_size;
4722 int *element_list_size;
4724 boolean last_setup_value;
4726 editor_elements_info[] =
4729 &setup_editor_show_always,
4730 &setup_editor_cascade_never,
4731 &editor_hl_unused_ptr, &num_editor_hl_unused,
4732 &editor_el_players_ptr, &num_editor_el_players
4735 &setup.editor.el_boulderdash,
4736 &setup.editor_cascade.el_bd,
4737 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
4738 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
4741 &setup.editor.el_emerald_mine,
4742 &setup.editor_cascade.el_em,
4743 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
4744 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
4747 &setup.editor.el_emerald_mine_club,
4748 &setup.editor_cascade.el_emc,
4749 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
4750 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
4753 &setup.editor.el_more,
4754 &setup.editor_cascade.el_rnd,
4755 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
4756 &editor_el_rnd_ptr, &num_editor_el_rnd
4759 &setup.editor.el_sokoban,
4760 &setup.editor_cascade.el_sb,
4761 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
4762 &editor_el_sokoban_ptr, &num_editor_el_sokoban
4765 &setup.editor.el_supaplex,
4766 &setup.editor_cascade.el_sp,
4767 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
4768 &editor_el_supaplex_ptr, &num_editor_el_supaplex
4771 &setup.editor.el_diamond_caves,
4772 &setup.editor_cascade.el_dc,
4773 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
4774 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
4777 &setup.editor.el_dx_boulderdash,
4778 &setup.editor_cascade.el_dx,
4779 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
4780 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
4783 &setup.editor.el_chars,
4784 &setup.editor_cascade.el_chars,
4785 &editor_hl_chars_ptr, &num_editor_hl_chars,
4786 &editor_el_chars_ptr, &num_editor_el_chars
4789 &setup.editor.el_steel_chars,
4790 &setup.editor_cascade.el_steel_chars,
4791 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
4792 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
4795 &setup.editor.el_custom,
4796 &setup.editor_cascade.el_ce,
4797 &editor_hl_custom_ptr, &num_editor_hl_custom,
4798 &editor_el_custom_ptr, &num_editor_el_custom
4801 &setup.editor.el_custom,
4802 &setup.editor_cascade.el_ge,
4803 &editor_hl_group_ptr, &num_editor_hl_group,
4804 &editor_el_group_ptr, &num_editor_el_group
4807 &setup.editor.el_custom,
4808 &setup.editor_cascade.el_ref,
4809 &editor_hl_reference_ptr, &num_editor_hl_reference,
4810 &editor_el_reference_ptr, &num_editor_el_reference
4813 &setup.editor.el_user_defined,
4814 &setup.editor_cascade.el_user,
4815 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
4816 &editor_el_user_defined_ptr, &num_editor_el_user_defined
4819 &setup.editor.el_dynamic,
4820 &setup.editor_cascade.el_dynamic,
4821 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
4822 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
4827 &editor_hl_empty_ptr, &num_editor_hl_empty,
4828 &editor_el_empty_ptr, &num_editor_el_empty,
4840 -----------------------------------------------------------------------------
4842 -----------------------------------------------------------------------------
4845 static int getMaxInfoTextLength()
4847 return (SXSIZE / getFontWidth(FONT_TEXT_2));
4850 static int getTextWidthForGadget(char *text)
4855 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
4858 static int getTextWidthForDrawingArea(char *text)
4863 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
4866 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
4868 return (gi->x + gi->width + getTextWidthForGadget(text));
4871 static char *getElementInfoText(int element)
4873 char *info_text = NULL;
4875 if (element < MAX_NUM_ELEMENTS)
4877 if (strlen(element_info[element].description) > 0)
4878 info_text = element_info[element].description;
4879 else if (element_info[element].custom_description != NULL)
4880 info_text = element_info[element].custom_description;
4881 else if (element_info[element].editor_description != NULL)
4882 info_text = element_info[element].editor_description;
4885 if (info_text == NULL)
4886 info_text = INFOTEXT_UNKNOWN_ELEMENT;
4891 static char *getElementDescriptionFilenameExt(char *basename)
4893 char *elements_subdir = "elements";
4894 static char *elements_subdir2 = NULL;
4895 static char *filename = NULL;
4897 if (elements_subdir2 == NULL)
4898 elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
4900 checked_free(filename);
4902 /* 1st try: look for element description in current level set directory */
4903 filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
4904 if (fileExists(filename))
4909 /* 2nd try: look for element description in the game's base directory */
4910 filename = getPath3(options.docs_directory, elements_subdir, basename);
4911 if (fileExists(filename))
4917 char *getElementDescriptionFilename(int element)
4919 char basename[MAX_FILENAME_LEN];
4922 /* 1st try: look for element description file for exactly this element */
4923 sprintf(basename, "%s.txt", element_info[element].token_name);
4924 filename = getElementDescriptionFilenameExt(basename);
4925 if (filename != NULL)
4928 /* 2nd try: look for element description file for this element's class */
4929 sprintf(basename, "%s.txt", element_info[element].class_name);
4930 filename = getElementDescriptionFilenameExt(basename);
4931 if (filename != NULL)
4937 static void InitDynamicEditorElementList(int **elements, int *num_elements)
4939 boolean element_found[NUM_FILE_ELEMENTS];
4942 /* initialize list of used elements to "not used" */
4943 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
4944 element_found[i] = FALSE;
4946 /* find all elements used in current level */
4947 for (y = 0; y < lev_fieldy; y++)
4948 for (x = 0; x < lev_fieldx; x++)
4949 if (Feld[x][y] < NUM_FILE_ELEMENTS) /* should always be true */
4950 element_found[Feld[x][y]] = TRUE;
4954 /* count number of elements used in current level */
4955 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
4956 if (element_found[i])
4959 /* add space for up to 3 more elements for padding that may be needed */
4962 /* free memory for old list of elements, if needed */
4963 checked_free(*elements);
4965 /* allocate memory for new list of elements */
4966 *elements = checked_malloc(*num_elements * sizeof(int));
4970 /* add all elements used in current level (non-custom/group elements) */
4971 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
4972 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
4973 (*elements)[(*num_elements)++] = i;
4975 /* add all elements used in current level (custom/group elements) */
4976 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
4977 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
4978 (*elements)[(*num_elements)++] = i;
4980 while (*num_elements % 4) /* pad with empty elements, if needed */
4981 (*elements)[(*num_elements)++] = EL_EMPTY;
4984 static void ReinitializeElementList()
4986 static boolean initialization_needed = TRUE;
4990 if (initialization_needed)
4992 LoadSetup_EditorCascade(); /* load last editor cascade state */
4994 /* initialize editor cascade element from saved cascade state */
4995 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
4997 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
4998 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
5000 if (IS_EDITOR_CASCADE(*cascade_element))
5002 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
5003 EL_CASCADE_INACTIVE(*cascade_element));
5006 initialization_needed = FALSE;
5009 checked_free(editor_elements);
5011 /* reload optional user defined element list for each invocation of editor */
5012 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
5013 &num_editor_el_user_defined);
5015 /* initialize dynamic level element list for each invocation of editor */
5016 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
5017 &num_editor_el_dynamic);
5019 /* initialize list of empty elements (used for padding, if needed) */
5020 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
5021 editor_el_empty[i] = EL_EMPTY;
5023 /* do some sanity checks for each element from element list */
5024 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5026 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
5028 int element = (*editor_elements_info[i].element_list)[j];
5030 if (element >= NUM_FILE_ELEMENTS)
5031 Error(ERR_WARN, "editor element %d is runtime element", element);
5033 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
5034 Error(ERR_WARN, "no element description for element %d", element);
5038 num_editor_elements = 0;
5039 use_el_empty = FALSE;
5041 /* determine size of element list */
5042 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5044 boolean found_inactive_cascade = FALSE;
5046 if (*editor_elements_info[i].setup_value)
5048 if (setup.editor.el_headlines)
5050 // required for correct padding of palette headline buttons
5051 if (*editor_elements_info[i].headline_list_size > 0)
5052 num_editor_elements += editor.palette.cols;
5054 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
5056 int element = (*editor_elements_info[i].headline_list)[j];
5058 if (IS_EDITOR_CASCADE_INACTIVE(element))
5059 found_inactive_cascade = TRUE;
5063 if (found_inactive_cascade)
5066 // required for correct padding of palette element buttons
5067 int element_list_size = *editor_elements_info[i].element_list_size;
5069 (element_list_size + editor.palette.cols - 1) / editor.palette.cols;
5070 int element_buttons = editor.palette.cols * element_rows;
5072 num_editor_elements += element_buttons;
5076 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
5078 /* offer at least as many elements as element buttons exist */
5079 use_el_empty = TRUE;
5080 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
5082 num_editor_elements += num_editor_el_empty;
5085 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
5087 /* fill element list */
5088 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5090 boolean found_inactive_cascade = FALSE;
5092 if (*editor_elements_info[i].setup_value)
5094 if (setup.editor.el_headlines)
5096 // required for correct padding of palette headline buttons
5097 int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
5098 editor.palette.cols : 0);
5100 for (j = 0; j < headline_size; j++)
5102 // use empty elements for padding of palette headline buttons
5103 int element = (j < *editor_elements_info[i].headline_list_size ?
5104 (*editor_elements_info[i].headline_list)[j] :
5105 editor_el_empty[0]);
5107 editor_elements[pos++] = element;
5109 if (IS_EDITOR_CASCADE_INACTIVE(element))
5110 found_inactive_cascade = TRUE;
5114 if (found_inactive_cascade)
5117 // required for correct padding of palette element buttons
5118 int element_list_size = *editor_elements_info[i].element_list_size;
5120 (element_list_size + editor.palette.cols - 1) / editor.palette.cols;
5121 int element_buttons = editor.palette.cols * element_rows;
5123 // copy all elements from element list
5124 for (j = 0; j < element_list_size; j++)
5125 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
5127 // use empty elements for padding of palette element buttons
5128 for (j = 0; j < element_buttons - element_list_size; j++)
5129 editor_elements[pos++] = editor_el_empty[0];
5133 /* (this function is also called before editor gadgets are initialized!) */
5134 AdjustElementListScrollbar();
5137 void PrintEditorElementList()
5139 boolean *stop = &setup.editor.el_user_defined;
5142 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
5144 int cascade_element = (*editor_elements_info[i].headline_list)[0];
5146 if (IS_EDITOR_CASCADE(cascade_element))
5148 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
5149 char *headline = element_info[cascade_element_show].editor_description;
5151 printf_line_with_prefix("# ", "-", 77);
5152 printf("# %s\n", headline);
5153 printf_line_with_prefix("# ", "-", 77);
5156 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
5158 int element = (*editor_elements_info[i].headline_list)[j];
5160 if (IS_EDITOR_CASCADE(element))
5161 element = EL_CHAR_MINUS;
5163 printf("# %s\n", element_info[element].token_name);
5169 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
5171 int element = (*editor_elements_info[i].element_list)[j];
5173 printf("# %s\n", element_info[element].token_name);
5181 static void ReinitializeElementListButtons()
5183 static boolean last_setup_value_headlines = FALSE;
5184 static boolean initialization_needed = TRUE;
5187 if (!initialization_needed) /* check if editor element setup has changed */
5189 if (last_setup_value_headlines != setup.editor.el_headlines)
5190 initialization_needed = TRUE;
5192 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5193 if (editor_elements_info[i].last_setup_value !=
5194 *editor_elements_info[i].setup_value)
5195 initialization_needed = TRUE;
5198 if (!initialization_needed)
5201 FreeLevelEditorGadgets();
5202 CreateLevelEditorGadgets();
5204 /* store current setup values for next invocation of this function */
5205 last_setup_value_headlines = setup.editor.el_headlines;
5206 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5207 editor_elements_info[i].last_setup_value =
5208 *editor_elements_info[i].setup_value;
5210 initialization_needed = FALSE;
5213 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
5216 int border_graphic =
5217 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
5220 int bx = (input ? ED_ELEMENT_BORDER_INPUT : ED_ELEMENT_BORDER);
5221 int by = (input ? ED_ELEMENT_BORDER_INPUT : ED_ELEMENT_BORDER);
5222 int bx2 = TILEX - bx;
5223 int by2 = TILEY - by;
5226 getFixedGraphicSource(border_graphic, 0, &src_bitmap, &src_x, &src_y);
5228 BlitBitmap(src_bitmap, drawto, src_x, src_y,
5229 bx, by, dest_x - bx, dest_y - by);
5230 BlitBitmap(src_bitmap, drawto, src_x + bx2, src_y,
5231 bx, by, dest_x + width, dest_y - by);
5232 BlitBitmap(src_bitmap, drawto, src_x, src_y + by2,
5233 bx, by, dest_x - bx, dest_y + height);
5234 BlitBitmap(src_bitmap, drawto, src_x + bx2, src_y + by2,
5235 bx, by, dest_x + width, dest_y + height);
5237 for (i = 0; i < width / MINI_TILEX; i++)
5239 BlitBitmap(src_bitmap, drawto, src_x + bx, src_y, MINI_TILEX, by,
5240 dest_x + i * MINI_TILEX, dest_y - by);
5241 BlitBitmap(src_bitmap, drawto, src_x + bx, src_y + by2, MINI_TILEX, by,
5242 dest_x + i * MINI_TILEX, dest_y + height);
5245 for (i = 0; i < height / MINI_TILEY; i++)
5247 BlitBitmap(src_bitmap, drawto, src_x, src_y + by, bx, MINI_TILEY,
5248 dest_x - bx, dest_y + i * MINI_TILEY);
5249 BlitBitmap(src_bitmap, drawto, src_x + bx2, src_y + by, bx, MINI_TILEY,
5250 dest_x + width, dest_y + i * MINI_TILEY);
5253 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
5256 static void DrawEditorElement(int x, int y, int element)
5258 DrawSizedElement(x, y, element, ed_tilesize);
5261 static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
5263 DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
5266 static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
5268 DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
5271 static void DrawDrawingArea(int id)
5273 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
5276 int *value = drawingarea_info[id].value;
5277 int area_xsize = drawingarea_info[id].area_xsize;
5278 int area_ysize = drawingarea_info[id].area_ysize;
5280 for (x = 0; x < area_xsize; x++)
5281 for (y = 0; y < area_ysize; y++)
5282 DrawMiniGraphicExt(drawto,
5283 gi->x + x * MINI_TILEX,
5284 gi->y + y * MINI_TILEY,
5285 el2edimg(value[x * area_ysize + y]));
5288 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
5291 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
5292 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
5294 BlitBitmap(drawto, drawto,
5295 SX + (dx == -1 ? ed_tilesize : 0),
5296 SY + (dy == -1 ? ed_tilesize : 0),
5297 (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
5298 (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
5299 SX + (dx == +1 ? ed_tilesize : 0),
5300 SY + (dy == +1 ? ed_tilesize : 0));
5304 x = (dx == 1 ? 0 : ed_fieldx - 1);
5305 for (y = 0; y < ed_fieldy; y++)
5306 DrawEditorElementOrWall(x, y, from_x, from_y);
5310 y = (dy == 1 ? 0 : ed_fieldy - 1);
5311 for (x = 0; x < ed_fieldx; x++)
5312 DrawEditorElementOrWall(x, y, from_x, from_y);
5315 redraw_mask |= REDRAW_FIELD;
5319 void getElementListGraphicSource(int element, Bitmap **bitmap, int *x, int *y)
5321 int graphic = el2edimg(element);
5322 int tile_size = (editor.palette.tile_size >= TILESIZE ? TILESIZE :
5325 getSizedGraphicSource(graphic, 0, tile_size, bitmap, x, y);
5328 static void CreateControlButtons()
5330 struct GadgetInfo *gi;
5333 /* create toolbox buttons */
5334 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
5336 int id = controlbutton_info[i].gadget_id;
5337 int type = controlbutton_info[i].gadget_type;
5338 int graphic = controlbutton_info[i].graphic;
5339 struct XY *pos = controlbutton_info[i].pos;
5340 struct GraphicInfo *gd = &graphic_info[graphic];
5341 Bitmap *gd_bitmap = gd->bitmap;
5342 int gd_x1 = gd->src_x;
5343 int gd_y1 = gd->src_y;
5344 int gd_x2 = gd->src_x + gd->pressed_xoffset;
5345 int gd_y2 = gd->src_y + gd->pressed_yoffset;
5346 int gd_x1a = gd->src_x + gd->active_xoffset;
5347 int gd_y1a = gd->src_y + gd->active_yoffset;
5348 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
5349 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
5350 int width = gd->width;
5351 int height = gd->height;
5354 unsigned int event_mask;
5355 int radio_button_nr = RADIO_NR_NONE;
5356 boolean checked = FALSE;
5358 if (type == GD_TYPE_RADIO_BUTTON)
5360 event_mask = GD_EVENT_PRESSED;
5361 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
5363 if (id == drawing_function)
5368 if (id == GADGET_ID_WRAP_LEFT ||
5369 id == GADGET_ID_WRAP_RIGHT ||
5370 id == GADGET_ID_WRAP_UP ||
5371 id == GADGET_ID_WRAP_DOWN)
5372 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5374 event_mask = GD_EVENT_RELEASED;
5377 if (id == GADGET_ID_PROPERTIES)
5388 gi = CreateGadget(GDI_CUSTOM_ID, id,
5389 GDI_CUSTOM_TYPE_ID, i,
5390 GDI_INFO_TEXT, controlbutton_info[i].infotext,
5396 GDI_STATE, GD_BUTTON_UNPRESSED,
5397 GDI_RADIO_NR, radio_button_nr,
5398 GDI_CHECKED, checked,
5399 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5400 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
5401 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1a, gd_y1a,
5402 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x2a, gd_y2a,
5403 GDI_EVENT_MASK, event_mask,
5404 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5405 GDI_CALLBACK_ACTION, HandleControlButtons,
5409 Error(ERR_EXIT, "cannot create gadget");
5411 level_editor_gadget[id] = gi;
5414 /* these values are not constant, but can change at runtime */
5415 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
5416 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
5417 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
5418 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
5419 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
5420 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
5421 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
5422 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
5423 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].x = ED_SCROLL2_UP_XPOS;
5424 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y = ED_SCROLL2_UP_YPOS;
5425 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x = ED_SCROLL2_DOWN_XPOS;
5426 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y = ED_SCROLL2_DOWN_YPOS;
5428 /* create buttons for scrolling of drawing area and element list */
5429 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
5431 int id = scrollbutton_info[i].gadget_id;
5432 int graphic = scrollbutton_info[i].graphic;
5433 struct GraphicInfo *gd = &graphic_info[graphic];
5434 Bitmap *gd_bitmap = gd->bitmap;
5435 int gd_x1 = gd->src_x;
5436 int gd_y1 = gd->src_y;
5437 int gd_x2 = gd->src_x + gd->pressed_xoffset;
5438 int gd_y2 = gd->src_y + gd->pressed_yoffset;
5439 int width = gd->width;
5440 int height = gd->height;
5441 int x = scrollbutton_pos[i].x;
5442 int y = scrollbutton_pos[i].y;
5443 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5445 if (id == GADGET_ID_SCROLL_LIST_UP ||
5446 id == GADGET_ID_SCROLL_LIST_DOWN)
5457 gi = CreateGadget(GDI_CUSTOM_ID, id,
5458 GDI_CUSTOM_TYPE_ID, i,
5459 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
5464 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
5465 GDI_STATE, GD_BUTTON_UNPRESSED,
5466 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5467 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
5468 GDI_EVENT_MASK, event_mask,
5469 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5470 GDI_CALLBACK_ACTION, HandleControlButtons,
5474 Error(ERR_EXIT, "cannot create gadget");
5476 level_editor_gadget[id] = gi;
5479 /* create buttons for element list */
5480 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
5482 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
5483 int graphic = IMG_EDITOR_PALETTE_BUTTON;
5484 struct GraphicInfo *gd = &graphic_info[graphic];
5485 Bitmap *gd_bitmap = gd->bitmap;
5486 Bitmap *deco_bitmap;
5487 int deco_x, deco_y, deco_xpos, deco_ypos;
5488 int gd_x1 = gd->src_x;
5489 int gd_y1 = gd->src_y;
5490 int gd_x2 = gd->src_x + gd->pressed_xoffset;
5491 int gd_y2 = gd->src_y + gd->pressed_yoffset;
5492 int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
5493 int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
5494 int x = DX + ED_ELEMENTLIST_XPOS + xx * gd->width;
5495 int y = DY + ED_ELEMENTLIST_YPOS + yy * gd->height;
5496 int element = editor_elements[i];
5497 int tile_size = (editor.palette.tile_size >= TILESIZE ? TILESIZE :
5499 unsigned int event_mask = GD_EVENT_RELEASED;
5501 getElementListGraphicSource(element, &deco_bitmap, &deco_x, &deco_y);
5502 deco_xpos = (gd->width - tile_size) / 2;
5503 deco_ypos = (gd->height - tile_size) / 2;
5505 gi = CreateGadget(GDI_CUSTOM_ID, id,
5506 GDI_CUSTOM_TYPE_ID, i,
5507 GDI_INFO_TEXT, getElementInfoText(element),
5510 GDI_WIDTH, gd->width,
5511 GDI_HEIGHT, gd->height,
5512 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
5513 GDI_STATE, GD_BUTTON_UNPRESSED,
5514 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5515 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
5516 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
5517 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
5518 GDI_DECORATION_SIZE, tile_size, tile_size,
5519 GDI_DECORATION_SHIFTING, 1, 1,
5520 GDI_EVENT_MASK, event_mask,
5521 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5522 GDI_CALLBACK_ACTION, HandleControlButtons,
5526 Error(ERR_EXIT, "cannot create gadget");
5528 level_editor_gadget[id] = gi;
5532 static void CreateCounterButtons()
5534 int max_infotext_len = getMaxInfoTextLength();
5537 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
5540 int x = SX + counterbutton_info[i].x; /* down count button */
5541 int y = SY + counterbutton_info[i].y;
5543 /* determine horizontal position to the right of specified gadget */
5544 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
5545 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
5546 ED_GADGET_TEXT_DISTANCE);
5548 /* determine horizontal offset for leading text */
5549 if (counterbutton_info[i].text_left != NULL)
5550 x += getTextWidthForGadget(counterbutton_info[i].text_left);
5552 for (j = 0; j < 2; j++)
5554 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5555 struct GadgetInfo *gi;
5557 counterbutton_info[i].gadget_id_down :
5558 counterbutton_info[i].gadget_id_up);
5560 int gd_x, gd_y, gd_x1, gd_x2, gd_y1, gd_y2;
5562 unsigned int event_mask;
5563 char infotext[max_infotext_len + 1];
5565 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5567 if (i == ED_COUNTER_ID_SELECT_LEVEL)
5569 int graphic = (j == 0 ?
5570 IMG_EDITOR_BUTTON_GFX_PREV_LEVEL :
5571 IMG_EDITOR_BUTTON_GFX_NEXT_LEVEL);
5572 struct GraphicInfo *gd = &graphic_info[graphic];
5574 gd_bitmap = gd->bitmap;
5576 event_mask |= GD_EVENT_RELEASED;
5580 x = DX + editor.button.prev_level.x;
5581 y = DY + editor.button.prev_level.y;
5585 x = DX + editor.button.next_level.x;
5586 y = DY + editor.button.next_level.y;
5591 gd_x2 = gd->src_x + gd->pressed_xoffset;
5592 gd_y2 = gd->src_y + gd->pressed_yoffset;
5594 y_size = gd->height;
5598 gd_xoffset = (j == 0 ? ED_BUTTON_MINUS_XPOS : ED_BUTTON_PLUS_XPOS);
5599 gd_x1 = DOOR_GFX_PAGEX4 + gd_xoffset;
5600 gd_x2 = DOOR_GFX_PAGEX3 + gd_xoffset;
5601 gd_y1 = DOOR_GFX_PAGEY1 + ED_BUTTON_COUNT_YPOS;
5603 x_size = ED_BUTTON_COUNT_XSIZE;
5604 y_size = ED_BUTTON_COUNT_YSIZE;
5607 sprintf(infotext, "%s counter value by 1, 5 or 10",
5608 (j == 0 ? "decrease" : "increase"));
5610 gi = CreateGadget(GDI_CUSTOM_ID, id,
5611 GDI_CUSTOM_TYPE_ID, i,
5612 GDI_INFO_TEXT, infotext,
5617 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
5618 GDI_STATE, GD_BUTTON_UNPRESSED,
5619 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5620 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
5621 GDI_EVENT_MASK, event_mask,
5622 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5623 GDI_CALLBACK_ACTION, HandleCounterButtons,
5627 Error(ERR_EXIT, "cannot create gadget");
5629 level_editor_gadget[id] = gi;
5630 right_gadget_border[id] =
5631 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
5633 x += gi->width + ED_GADGET_DISTANCE; /* text count button */
5637 int font_type = FONT_INPUT_1;
5638 int font_type_active = FONT_INPUT_1_ACTIVE;
5639 int gd_width = ED_WIN_COUNT_XSIZE;
5640 int border_size = ED_BORDER_SIZE;
5642 id = counterbutton_info[i].gadget_id_text;
5643 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
5645 if (i == ED_COUNTER_ID_SELECT_LEVEL)
5647 int graphic = IMG_EDITOR_INPUT_GFX_LEVEL_NUMBER;
5648 struct GraphicInfo *gd = &graphic_info[graphic];
5650 gd_bitmap = gd->bitmap;
5652 x = DX + editor.input.level_number.x;
5653 y = DY + editor.input.level_number.y;
5657 gd_width = gd->width;
5658 border_size = gd->border_size;
5660 font_type = FONT_LEVEL_NUMBER;
5661 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
5665 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
5666 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
5669 gi = CreateGadget(GDI_CUSTOM_ID, id,
5670 GDI_CUSTOM_TYPE_ID, i,
5671 GDI_INFO_TEXT, "enter counter value",
5674 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
5675 GDI_NUMBER_VALUE, 0,
5676 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
5677 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
5678 GDI_TEXT_SIZE, 3, /* minimal counter text size */
5679 GDI_TEXT_FONT, font_type,
5680 GDI_TEXT_FONT_ACTIVE, font_type_active,
5681 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
5682 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
5683 GDI_BORDER_SIZE, border_size, border_size,
5684 GDI_DESIGN_WIDTH, gd_width,
5685 GDI_EVENT_MASK, event_mask,
5686 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5687 GDI_CALLBACK_ACTION, HandleCounterButtons,
5691 Error(ERR_EXIT, "cannot create gadget");
5693 level_editor_gadget[id] = gi;
5694 right_gadget_border[id] =
5695 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
5697 x += gi->width + ED_GADGET_DISTANCE; /* up count button */
5703 static void CreateDrawingAreas()
5707 /* these values are not constant, but can change at runtime */
5708 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
5709 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
5711 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
5713 struct GadgetInfo *gi;
5714 unsigned int event_mask;
5715 int id = drawingarea_info[i].gadget_id;
5716 int x = SX + drawingarea_info[i].x;
5717 int y = SY + drawingarea_info[i].y;
5718 int area_xsize = drawingarea_info[i].area_xsize;
5719 int area_ysize = drawingarea_info[i].area_ysize;
5722 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
5723 GD_EVENT_OFF_BORDERS;
5725 /* determine horizontal position to the right of specified gadget */
5726 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
5727 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
5728 ED_DRAWINGAREA_TEXT_DISTANCE);
5730 /* determine horizontal offset for leading text */
5731 if (drawingarea_info[i].text_left != NULL)
5732 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
5734 gi = CreateGadget(GDI_CUSTOM_ID, id,
5735 GDI_CUSTOM_TYPE_ID, i,
5738 GDI_TYPE, GD_TYPE_DRAWING_AREA,
5739 GDI_AREA_SIZE, area_xsize, area_ysize,
5740 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
5741 GDI_EVENT_MASK, event_mask,
5742 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
5743 GDI_CALLBACK_ACTION, HandleDrawingAreas,
5747 Error(ERR_EXIT, "cannot create gadget");
5749 level_editor_gadget[id] = gi;
5750 right_gadget_border[id] =
5751 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
5755 static void CreateTextInputGadgets()
5757 int max_infotext_len = getMaxInfoTextLength();
5760 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
5762 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5764 struct GadgetInfo *gi;
5765 unsigned int event_mask;
5766 char infotext[MAX_OUTPUT_LINESIZE + 1];
5767 int id = textinput_info[i].gadget_id;
5769 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
5771 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
5772 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
5774 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
5775 infotext[max_infotext_len] = '\0';
5777 gi = CreateGadget(GDI_CUSTOM_ID, id,
5778 GDI_CUSTOM_TYPE_ID, i,
5779 GDI_INFO_TEXT, infotext,
5780 GDI_X, SX + textinput_info[i].x,
5781 GDI_Y, SY + textinput_info[i].y,
5782 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
5783 GDI_TEXT_VALUE, textinput_info[i].value,
5784 GDI_TEXT_SIZE, textinput_info[i].size,
5785 GDI_TEXT_FONT, FONT_INPUT_1,
5786 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
5787 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
5788 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
5789 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5790 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
5791 GDI_EVENT_MASK, event_mask,
5792 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5793 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
5797 Error(ERR_EXIT, "cannot create gadget");
5799 level_editor_gadget[id] = gi;
5803 static void CreateTextAreaGadgets()
5805 int max_infotext_len = getMaxInfoTextLength();
5808 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
5810 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5812 struct GadgetInfo *gi;
5813 unsigned int event_mask;
5814 char infotext[MAX_OUTPUT_LINESIZE + 1];
5815 int id = textarea_info[i].gadget_id;
5816 int area_xsize = textarea_info[i].xsize;
5817 int area_ysize = textarea_info[i].ysize;
5819 event_mask = GD_EVENT_TEXT_LEAVING;
5821 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
5822 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
5824 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
5825 infotext[max_infotext_len] = '\0';
5827 gi = CreateGadget(GDI_CUSTOM_ID, id,
5828 GDI_CUSTOM_TYPE_ID, i,
5829 GDI_INFO_TEXT, infotext,
5830 GDI_X, SX + textarea_info[i].x,
5831 GDI_Y, SY + textarea_info[i].y,
5832 GDI_TYPE, GD_TYPE_TEXT_AREA,
5833 GDI_AREA_SIZE, area_xsize, area_ysize,
5834 GDI_TEXT_FONT, FONT_INPUT_1,
5835 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
5836 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
5837 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
5838 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5839 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
5840 GDI_EVENT_MASK, event_mask,
5841 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5842 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
5846 Error(ERR_EXIT, "cannot create gadget");
5848 level_editor_gadget[id] = gi;
5852 static void CreateSelectboxGadgets()
5854 int max_infotext_len = getMaxInfoTextLength();
5857 for (i = 0; i < ED_NUM_SELECTBOX; i++)
5859 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5861 struct GadgetInfo *gi;
5862 unsigned int event_mask;
5863 char infotext[MAX_OUTPUT_LINESIZE + 1];
5864 int id = selectbox_info[i].gadget_id;
5865 int x = SX + selectbox_info[i].x;
5866 int y = SY + selectbox_info[i].y;
5868 if (selectbox_info[i].size == -1) /* dynamically determine size */
5870 /* (we cannot use -1 for uninitialized values if we directly compare
5871 with results from strlen(), because the '<' and '>' operation will
5872 implicitely cast -1 to an unsigned integer value!) */
5873 selectbox_info[i].size = 0;
5875 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
5876 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
5877 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
5879 selectbox_info[i].size++; /* add one character empty space */
5882 event_mask = GD_EVENT_RELEASED |
5883 GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
5885 gd_x = DOOR_GFX_PAGEX4 + ED_SELECTBOX_XPOS;
5886 gd_y = DOOR_GFX_PAGEY1 + ED_SELECTBOX_YPOS;
5888 /* determine horizontal position to the right of specified gadget */
5889 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
5890 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
5891 ED_GADGET_TEXT_DISTANCE);
5893 /* determine horizontal offset for leading text */
5894 if (selectbox_info[i].text_left != NULL)
5895 x += getTextWidthForGadget(selectbox_info[i].text_left);
5897 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
5898 infotext[max_infotext_len] = '\0';
5900 gi = CreateGadget(GDI_CUSTOM_ID, id,
5901 GDI_CUSTOM_TYPE_ID, i,
5902 GDI_INFO_TEXT, infotext,
5905 GDI_TYPE, GD_TYPE_SELECTBOX,
5906 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
5907 GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
5908 GDI_TEXT_SIZE, selectbox_info[i].size,
5909 GDI_TEXT_FONT, FONT_INPUT_1,
5910 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
5911 GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
5912 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
5913 GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
5914 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
5915 GDI_BORDER_SIZE_SELECTBUTTON, ED_SELECTBOX_BUTTON_XSIZE,
5916 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
5917 GDI_EVENT_MASK, event_mask,
5918 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5919 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
5923 Error(ERR_EXIT, "cannot create gadget");
5925 level_editor_gadget[id] = gi;
5926 right_gadget_border[id] =
5927 getRightGadgetBorder(gi, selectbox_info[i].text_right);
5931 static void CreateTextbuttonGadgets()
5933 int max_infotext_len = getMaxInfoTextLength();
5936 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
5938 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
5939 int gd_x1, gd_x2, gd_y1, gd_y2;
5940 struct GadgetInfo *gi;
5941 unsigned int event_mask;
5942 char infotext[MAX_OUTPUT_LINESIZE + 1];
5943 int id = textbutton_info[i].gadget_id;
5944 int x = SX + textbutton_info[i].x;
5945 int y = SY + textbutton_info[i].y;
5947 if (textbutton_info[i].size == -1) /* dynamically determine size */
5948 textbutton_info[i].size = strlen(textbutton_info[i].text);
5950 event_mask = GD_EVENT_RELEASED;
5952 if ((id >= GADGET_ID_LEVELINFO_LEVEL && id <= GADGET_ID_LEVELINFO_EDITOR) ||
5953 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE))
5955 gd_x1 = DOOR_GFX_PAGEX4 + ED_TEXTBUTTON_TAB_XPOS;
5956 gd_x2 = DOOR_GFX_PAGEX3 + ED_TEXTBUTTON_TAB_XPOS;
5957 gd_y1 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_TAB_YPOS;
5958 gd_y2 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_TAB_INACTIVE_YPOS;
5962 gd_x1 = DOOR_GFX_PAGEX4 + ED_TEXTBUTTON_XPOS;
5963 gd_x2 = DOOR_GFX_PAGEX3 + ED_TEXTBUTTON_XPOS;
5964 gd_y1 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_YPOS;
5965 gd_y2 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_INACTIVE_YPOS;
5968 sprintf(infotext, "%s", textbutton_info[i].infotext);
5969 infotext[max_infotext_len] = '\0';
5971 /* determine horizontal position to the right of specified gadget */
5972 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
5973 x = (right_gadget_border[textbutton_info[i].gadget_id_align] +
5974 ED_GADGET_TEXT_DISTANCE);
5976 /* determine horizontal offset for leading text */
5977 if (textbutton_info[i].text_left != NULL)
5978 x += getTextWidthForGadget(textbutton_info[i].text_left);
5980 gi = CreateGadget(GDI_CUSTOM_ID, id,
5981 GDI_CUSTOM_TYPE_ID, i,
5982 GDI_INFO_TEXT, infotext,
5985 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
5986 GDI_TEXT_VALUE, textbutton_info[i].text,
5987 GDI_TEXT_SIZE, textbutton_info[i].size,
5988 GDI_TEXT_FONT, FONT_INPUT_2_ACTIVE,
5989 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2,
5990 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5991 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y1,
5992 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2,
5993 GDI_BORDER_SIZE, ED_BORDER_TEXT_XSIZE, ED_BORDER_SIZE,
5994 GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
5995 GDI_DECORATION_SHIFTING, 1, 1,
5996 GDI_EVENT_MASK, event_mask,
5997 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5998 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
6002 Error(ERR_EXIT, "cannot create gadget");
6004 level_editor_gadget[id] = gi;
6005 right_gadget_border[id] =
6006 getRightGadgetBorder(gi, textbutton_info[i].text_right);
6010 static void CreateGraphicbuttonGadgets()
6012 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
6013 struct GadgetInfo *gi;
6014 unsigned int event_mask;
6017 /* create buttons for scrolling of drawing area and element list */
6018 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
6020 int id = graphicbutton_info[i].gadget_id;
6021 int gd_x1, gd_x2, gd_y1, gd_y2;
6022 int x = SX + graphicbutton_info[i].x;
6023 int y = SY + graphicbutton_info[i].y;
6025 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6027 if (i <= ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
6029 gd_x1 = DOOR_GFX_PAGEX4 + graphicbutton_info[i].gd_x;
6030 gd_y1 = DOOR_GFX_PAGEY1 + graphicbutton_info[i].gd_y;
6031 gd_x2 = DOOR_GFX_PAGEX3 + graphicbutton_info[i].gd_x;
6034 else /* (i <= ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE) */
6036 gd_x1 = DOOR_GFX_PAGEX6 + graphicbutton_info[i].gd_x;
6037 gd_y1 = DOOR_GFX_PAGEY1 + graphicbutton_info[i].gd_y;
6038 gd_x2 = gd_x1 - ED_BUTTON_COUNT_XSIZE;
6042 /* determine horizontal position to the right of specified gadget */
6043 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6044 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
6045 ED_GADGET_TEXT_DISTANCE);
6047 /* determine horizontal offset for leading text */
6048 if (graphicbutton_info[i].text_left != NULL)
6049 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
6051 gi = CreateGadget(GDI_CUSTOM_ID, id,
6052 GDI_CUSTOM_TYPE_ID, i,
6053 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
6056 GDI_WIDTH, graphicbutton_info[i].width,
6057 GDI_HEIGHT, graphicbutton_info[i].height,
6058 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6059 GDI_STATE, GD_BUTTON_UNPRESSED,
6060 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6061 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6062 GDI_EVENT_MASK, event_mask,
6063 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6064 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
6068 Error(ERR_EXIT, "cannot create gadget");
6070 level_editor_gadget[id] = gi;
6071 right_gadget_border[id] =
6072 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
6076 static void CreateScrollbarGadgets()
6080 /* these values are not constant, but can change at runtime */
6081 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
6082 SX + ED_SCROLL_HORIZONTAL_XPOS;
6083 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
6084 SY + ED_SCROLL_HORIZONTAL_YPOS;
6085 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
6086 ED_SCROLL_HORIZONTAL_XSIZE;
6087 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
6088 ED_SCROLL_HORIZONTAL_YSIZE;
6089 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
6090 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
6091 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
6092 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
6094 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
6095 SX + ED_SCROLL_VERTICAL_XPOS;
6096 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
6097 SY + ED_SCROLL_VERTICAL_YPOS;
6098 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
6099 ED_SCROLL_VERTICAL_XSIZE;
6100 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
6101 ED_SCROLL_VERTICAL_YSIZE;
6102 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
6103 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
6104 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
6105 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
6107 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
6108 DX + ED_SCROLL2_VERTICAL_XPOS;
6109 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
6110 DY + ED_SCROLL2_VERTICAL_YPOS;
6111 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
6112 ED_SCROLL2_VERTICAL_XSIZE;
6113 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
6114 ED_SCROLL2_VERTICAL_YSIZE;
6115 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = DX;
6116 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = DY;
6117 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width = DXSIZE;
6118 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = DYSIZE;
6120 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
6122 int id = scrollbar_info[i].gadget_id;
6123 int graphic = scrollbar_info[i].graphic;
6124 struct GraphicInfo *gd = &graphic_info[graphic];
6125 Bitmap *gd_bitmap = gd->bitmap;
6126 int gd_x1, gd_x2, gd_y1, gd_y2;
6127 struct GadgetInfo *gi;
6128 int items_max, items_visible, item_position;
6129 unsigned int event_mask;
6131 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
6133 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
6134 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
6135 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
6137 else /* drawing area scrollbars */
6139 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
6141 items_max = MAX(lev_fieldx + 2, ed_fieldx);
6142 items_visible = ed_fieldx;
6147 items_max = MAX(lev_fieldy + 2, ed_fieldy);
6148 items_visible = ed_fieldy;
6153 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
6157 gd_x2 = gd->src_x + gd->pressed_xoffset;
6158 gd_y2 = gd->src_y + gd->pressed_yoffset;
6160 gi = CreateGadget(GDI_CUSTOM_ID, id,
6161 GDI_CUSTOM_TYPE_ID, i,
6162 GDI_INFO_TEXT, scrollbar_info[i].infotext,
6163 GDI_X, scrollbar_pos[i].x,
6164 GDI_Y, scrollbar_pos[i].y,
6165 GDI_WIDTH, scrollbar_pos[i].width,
6166 GDI_HEIGHT, scrollbar_pos[i].height,
6167 GDI_TYPE, scrollbar_info[i].type,
6168 GDI_SCROLLBAR_ITEMS_MAX, items_max,
6169 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
6170 GDI_SCROLLBAR_ITEM_POSITION, item_position,
6171 GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
6172 GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
6173 GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
6174 GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
6175 GDI_STATE, GD_BUTTON_UNPRESSED,
6176 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6177 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6178 GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
6179 GDI_EVENT_MASK, event_mask,
6180 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6181 GDI_CALLBACK_ACTION, HandleControlButtons,
6185 Error(ERR_EXIT, "cannot create gadget");
6187 level_editor_gadget[id] = gi;
6191 static void CreateCheckbuttonGadgets()
6193 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
6194 struct GadgetInfo *gi;
6195 unsigned int event_mask;
6196 int gd_x1, gd_x2, gd_x3, gd_x4, gd_y;
6199 event_mask = GD_EVENT_PRESSED;
6201 gd_x1 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_UNCHECKED_XPOS;
6202 gd_x2 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_UNCHECKED_XPOS;
6203 gd_x3 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_CHECKED_XPOS;
6204 gd_x4 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_CHECKED_XPOS;
6205 gd_y = DOOR_GFX_PAGEY1 + ED_RADIOBUTTON_YPOS;
6207 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
6209 int id = checkbutton_info[i].gadget_id;
6210 int x = SX + checkbutton_info[i].x;
6211 int y = SY + checkbutton_info[i].y;
6213 if (id == GADGET_ID_STICK_ELEMENT)
6214 gd_y = DOOR_GFX_PAGEY1 + ED_STICKYBUTTON_YPOS;
6216 gd_y = DOOR_GFX_PAGEY1 + ED_CHECKBUTTON_YPOS;
6218 /* determine horizontal position to the right of specified gadget */
6219 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6220 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
6221 ED_GADGET_TEXT_DISTANCE);
6223 /* determine horizontal offset for leading text */
6224 if (checkbutton_info[i].text_left != NULL)
6225 x += getTextWidthForGadget(checkbutton_info[i].text_left);
6227 gi = CreateGadget(GDI_CUSTOM_ID, id,
6228 GDI_CUSTOM_TYPE_ID, i,
6229 GDI_INFO_TEXT, checkbutton_info[i].infotext,
6232 GDI_WIDTH, ED_CHECKBUTTON_XSIZE,
6233 GDI_HEIGHT, ED_CHECKBUTTON_YSIZE,
6234 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
6235 GDI_CHECKED, *checkbutton_info[i].value,
6236 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
6237 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
6238 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y,
6239 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y,
6240 GDI_EVENT_MASK, event_mask,
6241 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6242 GDI_CALLBACK_ACTION, HandleCheckbuttons,
6246 Error(ERR_EXIT, "cannot create gadget");
6248 level_editor_gadget[id] = gi;
6249 right_gadget_border[id] =
6250 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
6254 static void CreateRadiobuttonGadgets()
6256 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
6257 struct GadgetInfo *gi;
6258 unsigned int event_mask;
6259 int gd_x1, gd_x2, gd_x3, gd_x4, gd_y;
6262 event_mask = GD_EVENT_PRESSED;
6264 gd_x1 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_UNCHECKED_XPOS;
6265 gd_x2 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_UNCHECKED_XPOS;
6266 gd_x3 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_CHECKED_XPOS;
6267 gd_x4 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_CHECKED_XPOS;
6268 gd_y = DOOR_GFX_PAGEY1 + ED_RADIOBUTTON_YPOS;
6270 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
6272 int id = radiobutton_info[i].gadget_id;
6273 int x = SX + radiobutton_info[i].x;
6274 int y = SY + radiobutton_info[i].y;
6277 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
6279 /* determine horizontal position to the right of specified gadget */
6280 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
6281 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
6282 ED_GADGET_TEXT_DISTANCE);
6284 /* determine horizontal offset for leading text */
6285 if (radiobutton_info[i].text_left != NULL)
6286 x += getTextWidthForGadget(radiobutton_info[i].text_left);
6288 gi = CreateGadget(GDI_CUSTOM_ID, id,
6289 GDI_CUSTOM_TYPE_ID, i,
6290 GDI_INFO_TEXT, radiobutton_info[i].infotext,
6293 GDI_WIDTH, ED_CHECKBUTTON_XSIZE,
6294 GDI_HEIGHT, ED_CHECKBUTTON_YSIZE,
6295 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
6296 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
6297 GDI_CHECKED, checked,
6298 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
6299 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
6300 GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y,
6301 GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y,
6302 GDI_EVENT_MASK, event_mask,
6303 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6304 GDI_CALLBACK_ACTION, HandleRadiobuttons,
6308 Error(ERR_EXIT, "cannot create gadget");
6310 level_editor_gadget[id] = gi;
6311 right_gadget_border[id] =
6312 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
6316 void CreateLevelEditorGadgets()
6318 int old_game_status = game_status;
6320 /* setting 'game_status' is needed to get the right fonts for the editor */
6321 game_status = GAME_MODE_EDITOR;
6323 /* these values are not constant, but can change at runtime */
6324 ed_fieldx = MAX_ED_FIELDX - 1;
6325 ed_fieldy = MAX_ED_FIELDY - 1;
6327 num_editor_gadgets = NUM_EDITOR_GADGETS;
6329 // printf("::: allocating %d gadgets ...\n", num_editor_gadgets);
6331 level_editor_gadget =
6332 checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *));
6333 right_gadget_border =
6334 checked_calloc(num_editor_gadgets * sizeof(int));
6336 editor_el_empty = checked_calloc(ED_NUM_ELEMENTLIST_BUTTONS * sizeof(int));
6337 editor_el_empty_ptr = editor_el_empty;
6339 ReinitializeElementList();
6341 CreateControlButtons();
6342 CreateScrollbarGadgets();
6344 /* order of function calls is important because of cross-references */
6345 CreateCheckbuttonGadgets();
6346 CreateCounterButtons();
6347 CreateRadiobuttonGadgets();
6348 CreateTextInputGadgets();
6349 CreateTextAreaGadgets();
6350 CreateSelectboxGadgets();
6351 CreateGraphicbuttonGadgets();
6352 CreateTextbuttonGadgets();
6353 CreateDrawingAreas();
6355 game_status = old_game_status;
6358 void FreeLevelEditorGadgets()
6362 // printf("::: freeing %d gadgets ...\n", num_editor_gadgets);
6364 for (i = 0; i < num_editor_gadgets; i++)
6366 FreeGadget(level_editor_gadget[i]);
6368 level_editor_gadget[i] = NULL;
6371 checked_free(level_editor_gadget);
6372 checked_free(right_gadget_border);
6374 checked_free(editor_el_empty);
6377 static void MapCounterButtons(int id)
6379 int gadget_id_down = counterbutton_info[id].gadget_id_down;
6380 int gadget_id_text = counterbutton_info[id].gadget_id_text;
6381 int gadget_id_up = counterbutton_info[id].gadget_id_up;
6382 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
6383 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
6384 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
6385 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
6386 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6387 int yoffset_above = MINI_TILEX + ED_GADGET_DISTANCE;
6388 int yoffset = ED_BORDER_SIZE;
6389 int x_left = gi_down->x - xoffset_left;
6390 int x_right; /* set after gadget position was modified */
6391 int y_above = gi_down->y - yoffset_above;
6393 int y; /* set after gadget position was modified */
6395 /* counter limits must be changed first to prevent value truncation */
6396 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
6397 counterbutton_info[id].max_value);
6399 /* right text position might have changed after setting position above */
6400 x_right = gi_up->x + gi_up->width + xoffset_right;
6402 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
6404 /* set position for "value[1,2,3,4]" counter gadgets (score in most cases) */
6405 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
6406 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
6408 ModifyGadget(gi_down, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
6409 ModifyGadget(gi_text, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
6410 ModifyGadget(gi_up, GDI_Y, SY + counterbutton_info[id].y, GDI_END);
6413 /* vertical position might have changed after setting position above */
6414 y = gi_up->y + yoffset;
6416 if (counterbutton_info[id].text_above)
6417 DrawText(x, y_above, counterbutton_info[id].text_above, FONT_TEXT_1);
6419 if (counterbutton_info[id].text_left)
6420 DrawText(x_left, y, counterbutton_info[id].text_left, FONT_TEXT_1);
6422 if (counterbutton_info[id].text_right)
6423 DrawText(x_right, y, counterbutton_info[id].text_right, FONT_TEXT_1);
6430 static void MapControlButtons()
6435 /* map toolbox buttons (excluding special CE toolbox buttons) */
6436 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
6437 MapGadget(level_editor_gadget[i]);
6439 /* map toolbox buttons (element properties button) */
6440 MapGadget(level_editor_gadget[ED_NUM_CTRL1_4_BUTTONS]);
6442 /* map buttons to select elements */
6443 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6444 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
6445 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
6446 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
6447 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
6449 /* map buttons to select level */
6450 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
6451 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
6452 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
6453 MapCounterButtons(counter_id);
6456 static void MapDrawingArea(int id)
6458 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6459 int area_xsize = gi->drawing.area_xsize;
6460 int area_ysize = gi->drawing.area_ysize;
6461 int xoffset_left= getTextWidthForDrawingArea(drawingarea_info[id].text_left);
6462 int xoffset_below= getTextWidth(drawingarea_info[id].text_below,FONT_TEXT_1);
6463 int x_left = gi->x - xoffset_left;
6464 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
6465 int x_below = gi->x + (gi->width - xoffset_below) / 2;
6466 int y_side = gi->y + (gi->height - getFontHeight(FONT_TEXT_1)) / 2;
6467 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
6469 if (drawingarea_info[id].text_left)
6470 DrawText(x_left, y_side, drawingarea_info[id].text_left, FONT_TEXT_1);
6472 if (drawingarea_info[id].text_right)
6473 DrawText(x_right, y_side, drawingarea_info[id].text_right, FONT_TEXT_1);
6475 if (drawingarea_info[id].text_below)
6476 DrawText(x_below, y_below, drawingarea_info[id].text_below, FONT_TEXT_1);
6478 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
6480 DrawElementBorder(gi->x, gi->y,
6481 area_xsize * MINI_TILEX, area_ysize * MINI_TILEY, TRUE);
6483 DrawDrawingArea(id);
6489 static void MapTextInputGadget(int id)
6491 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
6492 int xoffset_above = 0;
6493 int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
6494 int x_above = textinput_info[id].x + xoffset_above;
6495 int y_above = textinput_info[id].y + yoffset_above;
6497 if (textinput_info[id].text_above)
6498 DrawTextS(x_above, y_above, FONT_TEXT_1, textinput_info[id].text_above);
6500 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
6505 static void MapTextAreaGadget(int id)
6507 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
6508 int xoffset_above = 0;
6509 int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
6510 int x_above = textarea_info[id].x + xoffset_above;
6511 int y_above = textarea_info[id].y + yoffset_above;
6513 if (textarea_info[id].text_above)
6514 DrawTextS(x_above, y_above, FONT_TEXT_1, textarea_info[id].text_above);
6516 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
6521 static void MapSelectboxGadget(int id)
6523 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
6524 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
6525 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6526 int yoffset = ED_BORDER_SIZE;
6527 int x_left = gi->x - xoffset_left;
6528 int x_right = gi->x + gi->width + xoffset_right;
6529 int y = gi->y + yoffset;
6531 if (selectbox_info[id].text_left)
6532 DrawText(x_left, y, selectbox_info[id].text_left, FONT_TEXT_1);
6534 if (selectbox_info[id].text_right)
6535 DrawText(x_right, y, selectbox_info[id].text_right, FONT_TEXT_1);
6537 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
6542 static void MapTextbuttonGadget(int id)
6544 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
6545 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
6546 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6547 int yoffset = ED_BORDER_SIZE;
6548 int x_left = gi->x - xoffset_left;
6549 int x_right = gi->x + gi->width + xoffset_right;
6550 int y = gi->y + yoffset;
6552 /* only show button to delete change pages when more than minimum pages */
6553 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
6554 custom_element.num_change_pages == MIN_CHANGE_PAGES)
6557 if (textbutton_info[id].text_left)
6558 DrawText(x_left, y, textbutton_info[id].text_left, FONT_TEXT_1);
6560 if (textbutton_info[id].text_right)
6561 DrawText(x_right, y, textbutton_info[id].text_right, FONT_TEXT_1);
6566 static void MapGraphicbuttonGadget(int id)
6568 struct GadgetInfo *gi= level_editor_gadget[graphicbutton_info[id].gadget_id];
6569 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
6570 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6571 int yoffset = ED_BORDER_SIZE;
6572 int x_left = gi->x - xoffset_left;
6573 int x_right = gi->x + gi->width + xoffset_right;
6574 int y = gi->y + yoffset;
6576 if (graphicbutton_info[id].text_left)
6577 DrawText(x_left, y, graphicbutton_info[id].text_left, FONT_TEXT_1);
6579 if (graphicbutton_info[id].text_right)
6580 DrawText(x_right, y, graphicbutton_info[id].text_right, FONT_TEXT_1);
6585 static void MapRadiobuttonGadget(int id)
6587 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
6588 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
6589 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6590 int yoffset = ED_BORDER_SIZE;
6591 int x_left = gi->x - xoffset_left;
6592 int x_right = gi->x + gi->width + xoffset_right;
6593 int y = gi->y + yoffset;
6595 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
6597 if (radiobutton_info[id].text_left)
6598 DrawText(x_left, y, radiobutton_info[id].text_left, FONT_TEXT_1);
6600 if (radiobutton_info[id].text_right)
6601 DrawText(x_right, y, radiobutton_info[id].text_right, FONT_TEXT_1);
6603 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
6608 static void MapCheckbuttonGadget(int id)
6610 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
6611 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
6612 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6613 int yoffset = ED_BORDER_SIZE;
6614 int x_left, x_right, y; /* set after gadget position was modified */
6616 /* set position for gadgets with dynamically determined position */
6617 if (checkbutton_info[id].x != -1) /* do not change dynamic positions */
6618 ModifyGadget(gi, GDI_X, SX + checkbutton_info[id].x, GDI_END);
6619 ModifyGadget(gi, GDI_Y, SY + checkbutton_info[id].y, GDI_END);
6621 x_left = gi->x - xoffset_left;
6622 x_right = gi->x + gi->width + xoffset_right;
6623 y = gi->y + yoffset;
6625 if (checkbutton_info[id].text_left)
6626 DrawText(x_left, y, checkbutton_info[id].text_left, FONT_TEXT_1);
6628 if (checkbutton_info[id].text_right)
6629 DrawText(x_right, y, checkbutton_info[id].text_right, FONT_TEXT_1);
6631 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
6636 static void MapMainDrawingArea()
6638 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
6639 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
6642 for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
6644 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
6645 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
6646 no_horizontal_scrollbar) ||
6647 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
6648 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
6649 no_vertical_scrollbar))
6652 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
6655 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
6657 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
6658 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
6661 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
6664 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
6667 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
6671 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6673 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
6674 i == GADGET_ID_CUSTOM_COPY_TO ||
6675 i == GADGET_ID_CUSTOM_EXCHANGE ||
6676 i == GADGET_ID_CUSTOM_COPY ||
6677 i == GADGET_ID_CUSTOM_PASTE)
6680 MapGadget(level_editor_gadget[i]);
6682 UnmapGadget(level_editor_gadget[i]);
6687 static void MapLevelEditorToolboxCustomGadgets()
6689 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
6692 static void UnmapLevelEditorToolboxCustomGadgets()
6694 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
6697 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
6701 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
6703 if (i != GADGET_ID_SINGLE_ITEMS &&
6704 i != GADGET_ID_PICK_ELEMENT)
6706 struct GadgetInfo *gi = level_editor_gadget[i];
6714 int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
6715 struct GraphicInfo *gd = &graphic_info[graphic];
6719 BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
6720 gi->width, gi->height, gi->x, gi->y);
6722 redraw_mask |= REDRAW_DOOR_3;
6728 static void MapLevelEditorToolboxDrawingGadgets()
6730 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
6733 static void UnmapLevelEditorToolboxDrawingGadgets()
6735 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
6738 static void UnmapDrawingArea(int id)
6740 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
6743 static void UnmapLevelEditorFieldGadgets()
6747 for (i = 0; i < num_editor_gadgets; i++)
6748 if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
6749 level_editor_gadget[i]->y))
6750 UnmapGadget(level_editor_gadget[i]);
6753 void UnmapLevelEditorGadgets()
6757 for (i = 0; i < num_editor_gadgets; i++)
6758 UnmapGadget(level_editor_gadget[i]);
6761 static void ResetUndoBuffer()
6763 undo_buffer_position = -1;
6764 undo_buffer_steps = -1;
6765 redo_buffer_steps = 0;
6767 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
6769 level.changed = FALSE;
6772 static void DrawEditModeWindow()
6774 ModifyEditorElementList();
6775 RedrawDrawingElements();
6777 if (edit_mode == ED_MODE_INFO)
6778 DrawLevelInfoWindow();
6779 else if (edit_mode == ED_MODE_PROPERTIES)
6780 DrawPropertiesWindow();
6781 else /* edit_mode == ED_MODE_DRAWING */
6782 DrawDrawingWindow();
6785 static boolean LevelChanged()
6787 boolean field_changed = FALSE;
6790 for (y = 0; y < lev_fieldy; y++)
6791 for (x = 0; x < lev_fieldx; x++)
6792 if (Feld[x][y] != level.field[x][y])
6793 field_changed = TRUE;
6795 return (level.changed || field_changed);
6798 static boolean PrepareSavingIntoPersonalLevelSet()
6800 static LevelDirTree *last_copied_leveldir = NULL;
6801 static LevelDirTree *last_written_leveldir = NULL;
6802 static int last_copied_level_nr = -1;
6803 static int last_written_level_nr = -1;
6804 LevelDirTree *leveldir_former = leveldir_current;
6805 int level_nr_former = level_nr;
6808 // remember last mod/save so that for current session, we write
6809 // back to the same personal copy, asking only about overwrite.
6810 if (leveldir_current == last_copied_leveldir &&
6811 level_nr == last_copied_level_nr)
6813 // "cd" to personal level set dir (as used when writing last copy)
6814 leveldir_current = last_written_leveldir;
6815 level_nr = last_written_level_nr;
6820 if (!Request("This level is read only! "
6821 "Save into personal level set?", REQ_ASK))
6824 // "cd" to personal level set dir (for writing copy the first time)
6826 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
6828 // find unused level number
6829 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
6831 static char *level_filename = NULL;
6833 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
6835 if (!fileExists(level_filename))
6839 last_copied_leveldir = leveldir_former;
6840 last_copied_level_nr = level_nr_former;
6842 last_written_leveldir = leveldir_current;
6843 last_written_level_nr = level_nr = new_level_nr;
6848 static void ModifyLevelInfoForSavingIntoPersonalLevelSet(char *former_name)
6850 static char *filename_levelinfo = NULL, *mod_name = NULL;
6853 // annotate this copy-and-mod in personal levelinfo.conf
6854 setString(&filename_levelinfo,
6855 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
6857 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
6859 fprintf(file, "\n");
6860 fprintf(file, "# level %d was modified from:\n", level_nr);
6861 fprintf(file, "# - previous level set name: %s\n",
6863 fprintf(file, "# - level within previous set: %d \"%s\"\n",
6864 level.file_info.nr, level.name);
6865 fprintf(file, "# - previous author: %s\n",
6867 fprintf(file, "# - previous save date: ");
6869 if (level.creation_date.src == DATE_SRC_LEVELFILE)
6871 fprintf(file, "%04d-%02d-%02d\n",
6872 level.creation_date.year,
6873 level.creation_date.month,
6874 level.creation_date.day);
6878 fprintf(file, "not recorded\n");
6884 if (level_nr > leveldir_current->last_level)
6886 static char *temp_levelinfo = NULL;
6887 FILE *temp_file = NULL;
6888 char line[MAX_LINE_LEN];
6890 setString(&temp_levelinfo,
6891 getPath2(getCurrentLevelDir(),
6892 getStringCat2(LEVELINFO_FILENAME, ".new")));
6894 if ((file = fopen(filename_levelinfo, MODE_READ)) &&
6895 (temp_file = fopen(temp_levelinfo, MODE_WRITE)))
6897 while (fgets(line, MAX_LINE_LEN, file))
6899 if (!strPrefix(line, "levels:"))
6900 fputs(line, temp_file);
6902 fprintf(temp_file, "%-32s%d\n", "levels:", level_nr + 9);
6912 // needs error handling; also, ok on dos/win?
6913 unlink(filename_levelinfo);
6914 rename(temp_levelinfo, filename_levelinfo);
6917 // else: allow the save even if annotation failed
6919 // now... spray graffiti on the old level vital statistics
6920 // user can change these; just trying to set a good baseline
6922 // don't truncate names for fear of making offensive or silly:
6923 // long-named original author only recorded in levelinfo.conf.
6924 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
6925 if (!strEqual(level.author, leveldir_current->author))
6927 setString(&mod_name, getStringCat3(leveldir_current->author,
6928 " after ", level.author));
6930 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
6931 setString(&mod_name,
6932 getStringCat2(leveldir_current->author, " (ed.)"));
6934 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
6935 setString(&mod_name, leveldir_current->author);
6937 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
6939 // less worried about truncation here
6940 setString(&mod_name, getStringCat2("Mod: ", level.name));
6941 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
6945 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
6946 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
6950 for (x = 0; x < lev_fieldx; x++)
6951 for (y = 0; y < lev_fieldy; y++)
6952 dst[x][y] = src[x][y];
6955 static int setSelectboxValue(int selectbox_id, int new_value)
6957 int new_index_value = 0;
6960 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
6961 if (selectbox_info[selectbox_id].options[i].value == new_value)
6962 new_index_value = i;
6964 *selectbox_info[selectbox_id].value =
6965 selectbox_info[selectbox_id].options[new_index_value].value;
6967 return new_index_value;
6970 static void setSelectboxSpecialActionVariablesIfNeeded()
6974 /* change action mode and arg variables according to action type variable */
6975 for (i = 0; action_arg_options[i].value != -1; i++)
6977 if (action_arg_options[i].value == custom_element_change.action_type)
6979 int mode = action_arg_options[i].mode;
6981 /* only change if corresponding selectbox has changed */
6982 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
6983 action_arg_modes[mode])
6984 custom_element_change.action_mode = -1;
6986 /* only change if corresponding selectbox has changed */
6987 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
6988 action_arg_options[i].options)
6989 custom_element_change.action_arg = -1;
6996 static void setSelectboxSpecialActionOptions()
7000 /* change action mode and arg selectbox according to action type selectbox */
7001 for (i = 0; action_arg_options[i].value != -1; i++)
7003 if (action_arg_options[i].value == custom_element_change.action_type)
7005 int mode = action_arg_options[i].mode;
7007 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
7008 action_arg_modes[mode]);
7009 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
7010 custom_element_change.action_mode);
7012 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
7013 action_arg_options[i].options);
7014 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
7015 custom_element_change.action_arg);
7021 static void copy_custom_element_settings(int element_from, int element_to)
7023 struct ElementInfo *ei_from = &element_info[element_from];
7024 struct ElementInfo *ei_to = &element_info[element_to];
7026 copyElementInfo(ei_from, ei_to);
7029 static void replace_custom_element_in_settings(int element_from,
7034 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
7036 struct ElementInfo *ei = &element_info[i];
7038 for (y = 0; y < 3; y++)
7039 for (x = 0; x < 3; x++)
7040 if (ei->content.e[x][y] == element_from)
7041 ei->content.e[x][y] = element_to;
7043 for (j = 0; j < ei->num_change_pages; j++)
7045 struct ElementChangeInfo *change = &ei->change_page[j];
7047 if (change->target_element == element_from)
7048 change->target_element = element_to;
7050 if (change->initial_trigger_element == element_from)
7051 change->initial_trigger_element = element_to;
7053 if (change->action_element == element_from)
7054 change->action_element = element_to;
7056 for (y = 0; y < 3; y++)
7057 for (x = 0; x < 3; x++)
7058 if (change->target_content.e[x][y] == element_from)
7059 change->target_content.e[x][y] = element_to;
7062 if (ei->group != NULL) /* group or internal */
7063 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
7064 if (ei->group->element[j] == element_from)
7065 ei->group->element[j] = element_to;
7069 static void replace_custom_element_in_playfield(int element_from,
7074 for (x = 0; x < lev_fieldx; x++)
7075 for (y = 0; y < lev_fieldy; y++)
7076 if (Feld[x][y] == element_from)
7077 Feld[x][y] = element_to;
7080 static boolean CopyCustomElement(int element_old, int element_new,
7083 if (copy_mode == GADGET_ID_CUSTOM_COPY)
7085 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
7086 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
7087 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
7089 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
7091 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
7092 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
7093 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
7095 level.changed = TRUE;
7097 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
7099 Request("Please choose custom element!", REQ_CONFIRM);
7103 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
7105 Request("Please choose group element!", REQ_CONFIRM);
7111 level.changed = TRUE;
7114 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
7116 copy_custom_element_settings(element_new, element_old);
7118 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
7120 copy_custom_element_settings(element_old, element_new);
7122 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
7124 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
7125 copy_custom_element_settings(element_new, element_old);
7126 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
7128 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
7129 replace_custom_element_in_settings(element_new, element_old);
7130 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
7132 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
7133 replace_custom_element_in_playfield(element_new, element_old);
7134 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
7137 UpdateCustomElementGraphicGadgets();
7138 DrawPropertiesWindow();
7143 static void CopyCustomElementPropertiesToEditor(int element)
7146 int current_change_page = element_info[element].current_change_page;
7148 /* dynamically (re)build selectbox for selecting change page */
7149 for (i = 0; i < element_info[element].num_change_pages; i++)
7151 sprintf(options_change_page_strings[i], "%d", i + 1);
7153 options_change_page[i].value = i;
7154 options_change_page[i].text = options_change_page_strings[i];
7157 options_change_page[i].value = -1;
7158 options_change_page[i].text = NULL;
7160 /* needed here to initialize combined element properties */
7161 InitElementPropertiesEngine(level.game_version);
7163 element_info[element].change =
7164 &element_info[element].change_page[current_change_page];
7166 custom_element = element_info[element];
7167 custom_element_change = *element_info[element].change;
7169 /* needed to initially set selectbox options for special action options */
7170 setSelectboxSpecialActionOptions();
7172 /* needed to initially set selectbox value variables to reliable defaults */
7173 for (i = 0; i < ED_NUM_SELECTBOX; i++)
7174 setSelectboxValue(i, *selectbox_info[i].value);
7176 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
7177 custom_element_properties[i] = HAS_PROPERTY(element, i);
7179 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
7180 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
7182 /* ---------- element settings: configure (custom elements) ------------- */
7184 /* set accessible layer selectbox help value */
7185 custom_element.access_type =
7186 (IS_WALKABLE(element) ? EP_WALKABLE :
7187 IS_PASSABLE(element) ? EP_PASSABLE :
7188 custom_element.access_type);
7189 custom_element.access_layer =
7190 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
7191 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
7192 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
7193 custom_element.access_layer);
7194 custom_element.access_protected =
7195 (IS_PROTECTED(element) ? 1 : 0);
7196 custom_element_properties[EP_ACCESSIBLE] =
7197 (IS_ACCESSIBLE_OVER(element) ||
7198 IS_ACCESSIBLE_INSIDE(element) ||
7199 IS_ACCESSIBLE_UNDER(element));
7201 /* set walk-to-object action selectbox help value */
7202 custom_element.walk_to_action =
7203 (IS_DIGGABLE(element) ? EP_DIGGABLE :
7204 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
7205 IS_DROPPABLE(element) ? EP_DROPPABLE :
7206 IS_THROWABLE(element) ? EP_THROWABLE :
7207 IS_PUSHABLE(element) ? EP_PUSHABLE :
7208 custom_element.walk_to_action);
7209 custom_element_properties[EP_WALK_TO_OBJECT] =
7210 (IS_DIGGABLE(element) ||
7211 IS_COLLECTIBLE_ONLY(element) ||
7212 IS_DROPPABLE(element) ||
7213 IS_THROWABLE(element) ||
7214 IS_PUSHABLE(element));
7216 /* set smash targets selectbox help value */
7217 custom_element.smash_targets =
7218 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
7219 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
7220 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
7221 custom_element.smash_targets);
7222 custom_element_properties[EP_CAN_SMASH] =
7223 (CAN_SMASH_EVERYTHING(element) ||
7224 CAN_SMASH_ENEMIES(element) ||
7225 CAN_SMASH_PLAYER(element));
7227 /* set deadliness selectbox help value */
7228 custom_element.deadliness =
7229 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
7230 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
7231 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
7232 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
7233 custom_element.deadliness);
7234 custom_element_properties[EP_DEADLY] =
7235 (DONT_TOUCH(element) ||
7236 DONT_GET_HIT_BY(element) ||
7237 DONT_COLLIDE_WITH(element) ||
7238 DONT_RUN_INTO(element));
7240 /* ---------- element settings: advanced (custom elements) --------------- */
7242 /* set "change by direct action" selectbox help value */
7243 custom_element_change.direct_action =
7244 (HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
7245 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
7246 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
7247 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
7248 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
7249 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
7250 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
7251 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
7252 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
7253 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
7254 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
7255 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
7256 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
7257 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
7258 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
7259 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
7260 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
7261 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
7262 custom_element_change.direct_action);
7264 /* set "change by other element action" selectbox help value */
7265 custom_element_change.other_action =
7266 (HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
7267 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
7268 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
7269 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
7270 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
7271 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
7272 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
7273 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
7274 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
7275 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
7276 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
7277 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
7278 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
7279 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
7280 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
7281 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
7282 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
7283 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
7284 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
7285 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
7286 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
7287 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
7288 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
7289 custom_element_change.other_action);
7292 static void CopyGroupElementPropertiesToEditor(int element)
7294 group_element_info = *element_info[element].group;
7295 custom_element = element_info[element]; /* needed for description */
7298 static void CopyClassicElementPropertiesToEditor(int element)
7300 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
7301 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
7302 getMoveIntoAcidProperty(&level, element);
7304 if (MAYBE_DONT_COLLIDE_WITH(element))
7305 custom_element_properties[EP_DONT_COLLIDE_WITH] =
7306 getDontCollideWithProperty(&level, element);
7309 static void CopyElementPropertiesToEditor(int element)
7311 if (IS_CUSTOM_ELEMENT(element))
7312 CopyCustomElementPropertiesToEditor(element);
7313 else if (IS_GROUP_ELEMENT(element))
7314 CopyGroupElementPropertiesToEditor(element);
7316 CopyClassicElementPropertiesToEditor(element);
7319 static void CopyCustomElementPropertiesToGame(int element)
7322 int access_type_and_layer;
7324 /* mark that this custom element has been modified */
7325 custom_element.modified_settings = TRUE;
7326 level.changed = TRUE;
7328 if (level.use_custom_template)
7330 if (Request("Copy and modify level template?", REQ_ASK))
7332 level.use_custom_template = FALSE;
7333 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE],
7334 GDI_CHECKED, FALSE, GDI_END);
7338 LoadLevelTemplate(-1); /* this resets all element modifications ... */
7340 DrawEditModeWindow(); /* ... and copies them to 'custom_element' */
7344 element_info[element] = custom_element;
7345 *element_info[element].change = custom_element_change;
7347 /* ---------- element settings: configure (custom elements) ------------- */
7349 /* set accessible property from checkbox and selectbox */
7350 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
7351 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
7352 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
7353 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
7354 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
7355 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
7356 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
7357 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
7358 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
7359 custom_element_properties[access_type_and_layer] =
7360 custom_element_properties[EP_ACCESSIBLE];
7361 custom_element_properties[EP_PROTECTED] =
7362 (custom_element.access_protected != 0 &&
7363 custom_element_properties[EP_ACCESSIBLE]);
7365 /* set walk-to-object property from checkbox and selectbox */
7366 custom_element_properties[EP_DIGGABLE] = FALSE;
7367 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
7368 custom_element_properties[EP_DROPPABLE] = FALSE;
7369 custom_element_properties[EP_THROWABLE] = FALSE;
7370 custom_element_properties[EP_PUSHABLE] = FALSE;
7371 custom_element_properties[custom_element.walk_to_action] =
7372 custom_element_properties[EP_WALK_TO_OBJECT];
7374 /* set smash property from checkbox and selectbox */
7375 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
7376 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
7377 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
7378 custom_element_properties[custom_element.smash_targets] =
7379 custom_element_properties[EP_CAN_SMASH];
7381 /* set deadliness property from checkbox and selectbox */
7382 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
7383 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
7384 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
7385 custom_element_properties[EP_DONT_TOUCH] = FALSE;
7386 custom_element_properties[custom_element.deadliness] =
7387 custom_element_properties[EP_DEADLY];
7389 /* ---------- element settings: advanced (custom elements) --------------- */
7391 /* set player change event from checkbox and selectbox */
7392 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
7393 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
7394 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
7395 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
7396 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
7397 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
7398 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
7399 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
7400 custom_element_change_events[CE_SWITCHED] = FALSE;
7401 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
7402 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
7403 custom_element_change_events[CE_BLOCKED] = FALSE;
7404 custom_element_change_events[CE_IMPACT] = FALSE;
7405 custom_element_change_events[CE_SMASHED] = FALSE;
7406 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
7407 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
7408 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
7409 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
7410 custom_element_change_events[custom_element_change.direct_action] =
7411 custom_element_change_events[CE_BY_DIRECT_ACTION];
7413 /* set other element action change event from checkbox and selectbox */
7414 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
7415 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
7416 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
7417 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
7418 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
7419 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
7420 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
7421 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
7422 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
7423 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
7424 custom_element_change_events[CE_TOUCHING_X] = FALSE;
7425 custom_element_change_events[CE_HITTING_X] = FALSE;
7426 custom_element_change_events[CE_DIGGING_X] = FALSE;
7427 custom_element_change_events[CE_HIT_BY_X] = FALSE;
7428 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
7429 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
7430 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
7431 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
7432 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
7433 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
7434 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
7435 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
7436 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
7437 custom_element_change_events[custom_element_change.other_action] =
7438 custom_element_change_events[CE_BY_OTHER_ACTION];
7440 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
7441 SET_PROPERTY(element, i, custom_element_properties[i]);
7443 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
7444 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
7446 /* copy change events also to special level editor variable */
7447 custom_element = element_info[element];
7448 custom_element_change = *element_info[element].change;
7451 static void CopyGroupElementPropertiesToGame(int element)
7453 element_info[element] = custom_element;
7454 *element_info[element].group = group_element_info;
7456 /* mark that this group element has been modified */
7457 element_info[element].modified_settings = TRUE;
7458 level.changed = TRUE;
7461 static void CopyClassicElementPropertiesToGame(int element)
7463 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
7464 setMoveIntoAcidProperty(&level, element,
7465 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
7467 if (MAYBE_DONT_COLLIDE_WITH(element))
7468 setDontCollideWithProperty(&level, element,
7469 custom_element_properties[EP_DONT_COLLIDE_WITH]);
7472 static void CopyElementPropertiesToGame(int element)
7474 if (IS_CUSTOM_ELEMENT(element))
7475 CopyCustomElementPropertiesToGame(element);
7476 else if (IS_GROUP_ELEMENT(element))
7477 CopyGroupElementPropertiesToGame(element);
7479 CopyClassicElementPropertiesToGame(element);
7482 void CheckElementDescriptions()
7486 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
7487 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
7488 Error(ERR_WARN, "no element description for element '%s'", EL_NAME(i));
7491 static int getMaxEdFieldX(boolean has_scrollbar)
7493 int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
7494 int sxsize = SXSIZE - scrollbar_width;
7495 int max_ed_fieldx = sxsize / ed_tilesize;
7497 return max_ed_fieldx;
7500 static int getMaxEdFieldY(boolean has_scrollbar)
7502 int infotext_height = INFOTEXT_YSIZE;
7503 int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
7504 int sysize = SYSIZE - scrollbar_height - infotext_height;
7505 int max_ed_fieldy = sysize / ed_tilesize;
7507 return max_ed_fieldy;
7510 void InitZoomLevelSettings()
7512 MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
7513 MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
7516 static boolean playfield_area_changed = FALSE;
7522 CloseDoor(DOOR_CLOSE_ALL);
7524 FadeOut(REDRAW_FIELD);
7526 /* needed after playing if editor playfield area has different size */
7527 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
7529 /* needed if different viewport properties defined for editor */
7530 ChangeViewportPropertiesIfNeeded();
7532 InitZoomLevelSettings();
7534 playfield_area_changed = DrawingAreaChanged();
7536 OpenDoor(DOOR_OPEN_1 | DOOR_OPEN_2 | DOOR_NO_DELAY);
7539 CheckElementDescriptions();
7542 if (level_editor_test_game)
7544 CopyPlayfield(level.field, Feld);
7545 CopyPlayfield(FieldBackup, level.field);
7547 level_editor_test_game = FALSE;
7551 edit_mode = ED_MODE_DRAWING;
7552 edit_mode_levelinfo = ED_MODE_LEVELINFO_LEVEL;
7553 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
7561 /* needed for gadgets drawn on background (like palette scrollbar) */
7562 SetDoorBackgroundImage(IMG_UNDEFINED);
7564 /* copy default editor door content to main double buffer */
7565 BlitBitmap(graphic_info[IMG_BACKGROUND_PALETTE].bitmap, drawto,
7566 graphic_info[IMG_BACKGROUND_PALETTE].src_x,
7567 graphic_info[IMG_BACKGROUND_PALETTE].src_y,
7568 DXSIZE, DYSIZE, DX, DY);
7570 /* draw bigger door */
7571 DrawSpecialEditorDoor();
7573 /* draw new control window */
7574 BlitBitmap(graphic_info[IMG_BACKGROUND_TOOLBOX].bitmap, drawto,
7575 graphic_info[IMG_BACKGROUND_TOOLBOX].src_x,
7576 graphic_info[IMG_BACKGROUND_TOOLBOX].src_y,
7577 EXSIZE, EYSIZE, EX, EY);
7579 // redraw_mask |= REDRAW_ALL;
7581 FreeLevelEditorGadgets();
7582 CreateLevelEditorGadgets();
7584 ReinitializeElementList(); /* update dynamic level element list */
7585 ReinitializeElementListButtons(); /* custom element may look different */
7587 InitElementPropertiesGfxElement();
7590 MapControlButtons();
7592 DrawEditModeWindow();
7594 FadeIn(playfield_area_changed ? REDRAW_ALL : REDRAW_FIELD);
7596 /* copy actual editor door content to door double buffer for OpenDoor() */
7597 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
7600 static void AdjustDrawingAreaGadgets()
7602 int ed_xsize = lev_fieldx + 2;
7603 int ed_ysize = lev_fieldy + 2;
7604 int max_ed_fieldx = MAX_ED_FIELDX;
7605 int max_ed_fieldy = MAX_ED_FIELDY;
7606 boolean horizontal_scrollbar_needed;
7607 boolean vertical_scrollbar_needed;
7608 int x, y, width, height;
7610 /* check if we need any scrollbars */
7611 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
7612 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
7614 /* check if we have a smaller editor field because of scrollbars */
7615 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
7616 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
7618 /* check again if we now need more scrollbars because of less space */
7619 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
7620 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
7622 /* check if editor field gets even smaller after adding new scrollbars */
7623 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
7624 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
7626 ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
7627 ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
7629 x = SX + ed_fieldx * ed_tilesize;
7630 y = SY + ed_fieldy * ed_tilesize;
7632 width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
7633 height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
7635 /* adjust drawing area gadget */
7636 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
7637 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
7638 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
7641 /* adjust horizontal scrollbar gadgets */
7642 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
7645 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
7646 GDI_X, x - ED_SCROLLBUTTON_XSIZE,
7649 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
7652 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
7655 /* adjust vertical scrollbar gadgets */
7656 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
7659 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
7661 GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
7663 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
7666 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
7670 static void AdjustLevelScrollPosition()
7672 if (level_xpos < -1)
7674 if (level_xpos > lev_fieldx - ed_fieldx + 1)
7675 level_xpos = lev_fieldx - ed_fieldx + 1;
7676 if (lev_fieldx < ed_fieldx - 2)
7679 if (level_ypos < -1)
7681 if (level_ypos > lev_fieldy - ed_fieldy + 1)
7682 level_ypos = lev_fieldy - ed_fieldy + 1;
7683 if (lev_fieldy < ed_fieldy - 2)
7687 static void AdjustEditorScrollbar(int id)
7689 struct GadgetInfo *gi = level_editor_gadget[id];
7690 int items_max, items_visible, item_position;
7692 if (id == GADGET_ID_SCROLL_HORIZONTAL)
7694 items_max = MAX(lev_fieldx + 2, ed_fieldx);
7695 items_visible = ed_fieldx;
7696 item_position = level_xpos + 1;
7700 items_max = MAX(lev_fieldy + 2, ed_fieldy);
7701 items_visible = ed_fieldy;
7702 item_position = level_ypos + 1;
7705 if (item_position > items_max - items_visible)
7706 item_position = items_max - items_visible;
7708 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
7709 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
7712 static void AdjustElementListScrollbar()
7714 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
7715 int items_max, items_visible, item_position;
7717 /* correct position of element list scrollbar */
7718 if (element_shift < 0)
7720 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
7721 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
7723 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
7724 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
7725 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
7727 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
7728 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7729 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
7732 static void ModifyEditorCounterValue(int counter_id, int new_value)
7734 int *counter_value = counterbutton_info[counter_id].value;
7735 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
7736 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7738 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
7740 if (counter_value != NULL)
7741 *counter_value = gi->textinput.number_value;
7744 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
7746 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
7747 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7749 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
7751 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
7752 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
7754 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
7755 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
7757 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
7758 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_DISTANCE,GDI_END);
7762 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
7764 int gadget_id = selectbox_info[selectbox_id].gadget_id;
7765 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7766 int new_index_value = setSelectboxValue(selectbox_id, new_value);
7768 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
7771 static void ModifyEditorSelectboxOptions(int selectbox_id,
7772 struct ValueTextInfo *options)
7774 int gadget_id = selectbox_info[selectbox_id].gadget_id;
7775 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7777 selectbox_info[selectbox_id].options = options;
7779 /* set index to zero -- list may be shorter now (correct later, if needed) */
7780 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
7781 GDI_SELECTBOX_OPTIONS, options, GDI_END);
7784 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
7786 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
7787 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7789 drawingarea_info[drawingarea_id].area_xsize = xsize;
7790 drawingarea_info[drawingarea_id].area_ysize = ysize;
7792 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
7795 static void ModifyEditorElementList()
7799 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7801 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
7802 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7803 struct GadgetDesign *gd = &gi->deco.design;
7804 int element = editor_elements[element_shift + i];
7808 getElementListGraphicSource(element, &gd->bitmap, &gd->x, &gd->y);
7810 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
7816 static void DrawDrawingElement(int element, struct EditorPaletteElementInfo *e)
7818 int graphic = el2edimg(element);
7819 int tile_size = (e->tile_size >= TILESIZE ? TILESIZE : MINI_TILESIZE);
7821 DrawSizedGraphicExt(drawto, DX + e->x, DY + e->y, graphic, 0, tile_size);
7824 static void PickDrawingElement(int button, int element)
7829 struct EditorPaletteElementInfo *e;
7830 } de, drawing_elements[] =
7832 { &new_element1, &editor.palette.element_left },
7833 { &new_element2, &editor.palette.element_middle },
7834 { &new_element3, &editor.palette.element_right },
7837 if (button < 1 || button > 3)
7840 de = drawing_elements[button - 1];
7842 DrawDrawingElement((*de.new_element = element), de.e);
7844 redraw_mask |= REDRAW_DOOR_1;
7847 static void RedrawDrawingElements()
7849 PickDrawingElement(1, new_element1);
7850 PickDrawingElement(2, new_element2);
7851 PickDrawingElement(3, new_element3);
7854 static void DrawDrawingWindow()
7856 stick_element_properties_window = FALSE;
7858 SetMainBackgroundImage(IMG_UNDEFINED);
7861 UnmapLevelEditorFieldGadgets();
7862 UnmapLevelEditorToolboxCustomGadgets();
7864 AdjustDrawingAreaGadgets();
7865 AdjustLevelScrollPosition();
7866 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
7867 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
7869 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
7871 MapMainDrawingArea();
7872 MapLevelEditorToolboxDrawingGadgets();
7875 static int getTabulatorBarWidth()
7877 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
7878 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
7880 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
7883 static void DrawLevelInfoTabulatorGadgets()
7885 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELINFO_LEVEL];
7886 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
7887 int gd_x = gd->x + gd_gi1->border.width / 2;
7888 int gd_y = gd->y + gd_gi1->height - 1;
7889 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
7890 int id_first = ED_TEXTBUTTON_ID_LEVELINFO_LEVEL;
7891 int id_last = ED_TEXTBUTTON_ID_LEVELINFO_EDITOR;
7894 for (i = id_first; i <= id_last; i++)
7896 int gadget_id = textbutton_info[i].gadget_id;
7897 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7898 boolean active = (i != edit_mode_levelinfo);
7900 /* draw background line below tabulator button */
7901 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
7903 /* draw solid line below inactive tabulator buttons */
7904 if (!active && tab_color != BLACK_PIXEL) /* black => transparent */
7905 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width, 1, tab_color);
7907 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
7908 MapTextbuttonGadget(i);
7911 /* draw little border line below tabulator buttons */
7912 if (tab_color != BLACK_PIXEL) /* black => transparent */
7913 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height + 1,
7914 getTabulatorBarWidth(), ED_GADGET_DISTANCE,
7918 static void DrawPropertiesTabulatorGadgets()
7920 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
7921 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
7922 int gd_x = gd->x + gd_gi1->border.width / 2;
7923 int gd_y = gd->y + gd_gi1->height - 1;
7924 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
7925 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
7926 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
7929 /* draw two config tabulators for player elements */
7930 if (ELEM_IS_PLAYER(properties_element))
7931 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
7933 /* draw two config and one "change" tabulator for custom elements */
7934 if (IS_CUSTOM_ELEMENT(properties_element))
7935 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
7937 for (i = id_first; i <= id_last; i++)
7939 int gadget_id = textbutton_info[i].gadget_id;
7940 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
7941 boolean active = (i != edit_mode_properties);
7943 /* use "config 1" and "config 2" instead of "config" for players and CEs */
7944 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
7945 (ELEM_IS_PLAYER(properties_element) ||
7946 IS_CUSTOM_ELEMENT(properties_element)))
7949 /* draw background line below tabulator button */
7950 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
7952 /* draw solid line below inactive tabulator buttons */
7953 if (!active && tab_color != BLACK_PIXEL) /* black => transparent */
7954 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width, 1, tab_color);
7956 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
7957 MapTextbuttonGadget(i);
7960 /* draw little border line below tabulator buttons */
7961 if (tab_color != BLACK_PIXEL) /* black => transparent */
7962 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height + 1,
7963 getTabulatorBarWidth(), ED_GADGET_DISTANCE,
7967 static void DrawLevelInfoLevel()
7971 /* draw counter gadgets */
7972 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
7973 MapCounterButtons(i);
7975 /* draw selectbox gadgets */
7976 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
7977 MapSelectboxGadget(i);
7979 /* draw text input gadgets */
7980 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
7981 MapTextInputGadget(i);
7984 static void DrawLevelInfoEditor()
7988 /* draw counter gadgets */
7989 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
7990 MapCounterButtons(i);
7992 /* draw checkbutton gadgets */
7993 for (i=ED_CHECKBUTTON_ID_EDITOR_FIRST; i<= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
7994 MapCheckbuttonGadget(i);
7996 /* draw radiobutton gadgets */
7997 for (i=ED_RADIOBUTTON_ID_EDITOR_FIRST; i<= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
7998 MapRadiobuttonGadget(i);
8000 /* draw drawing area */
8001 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
8004 static void DrawLevelInfoWindow()
8006 stick_element_properties_window = FALSE;
8008 UnmapLevelEditorFieldGadgets();
8010 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
8013 DrawTextSCentered(ED_SETTINGS1_YPOS, FONT_TITLE_1, "Global Settings");
8015 DrawLevelInfoTabulatorGadgets();
8017 if (edit_mode_levelinfo == ED_MODE_LEVELINFO_LEVEL)
8018 DrawLevelInfoLevel();
8019 else /* (edit_mode_levelinfo == ED_MODE_LEVELINFO_EDITOR) */
8020 DrawLevelInfoEditor();
8023 static void DrawCustomContentArea()
8025 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
8026 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
8027 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
8028 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
8029 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
8030 int xoffset = ED_DRAWINGAREA_TEXT_DISTANCE;
8032 /* add distance for potential left text (without drawing area border) */
8033 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
8035 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
8037 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
8040 static void DrawCustomChangeContentArea()
8042 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
8043 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
8044 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
8045 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
8046 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
8047 int xoffset = ED_DRAWINGAREA_TEXT_DISTANCE;
8049 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
8054 static void DrawYamYamContentAreas()
8056 int x = SX + ED_AREA_YAMYAM_CONTENT_XPOS(3) + 4 * MINI_TILEX;
8057 int y = SY + ED_AREA_YAMYAM_CONTENT_YPOS(0) + ED_BORDER_AREA_YSIZE;
8060 /* display counter to choose number of element content areas */
8061 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
8063 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
8065 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
8067 if (i < level.num_yamyam_contents)
8073 int font_height = getFontHeight(FONT_TEXT_1);
8075 UnmapDrawingArea(id);
8077 /* delete content areas in case of reducing number of them */
8078 DrawBackground(SX + drawingarea_info[id].x - MINI_TILEX / 2,
8079 SY + drawingarea_info[id].y - MINI_TILEY / 2,
8081 4 * MINI_TILEY + ED_GADGET_TEXT_DISTANCE + font_height);
8085 DrawText(x, y + 0 * MINI_TILEY, "content", FONT_TEXT_1);
8086 DrawText(x, y + 1 * MINI_TILEY, "when", FONT_TEXT_1);
8087 DrawText(x, y + 2 * MINI_TILEY, "smashed", FONT_TEXT_1);
8090 static void DrawMagicBallContentAreas()
8092 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_XPOS(3) + 4 * MINI_TILEX;
8093 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_YPOS(0) + ED_BORDER_AREA_YSIZE;
8096 /* display counter to choose number of element content areas */
8097 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
8099 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
8101 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
8103 if (i < level.num_ball_contents)
8109 int font_height = getFontHeight(FONT_TEXT_1);
8111 UnmapDrawingArea(id);
8113 /* delete content areas in case of reducing number of them */
8114 DrawBackground(SX + drawingarea_info[id].x - MINI_TILEX / 2,
8115 SY + drawingarea_info[id].y - MINI_TILEY / 2,
8117 4 * MINI_TILEY + ED_GADGET_TEXT_DISTANCE + font_height);
8121 DrawText(x, y + 0 * MINI_TILEY, "generated", FONT_TEXT_1);
8122 DrawText(x, y + 1 * MINI_TILEY, "when", FONT_TEXT_1);
8123 DrawText(x, y + 2 * MINI_TILEY, "active", FONT_TEXT_1);
8126 static void DrawAndroidElementArea(int element)
8128 int num_elements = level.num_android_clone_elements;
8129 int id = ED_DRAWING_ID_ANDROID_CONTENT;
8130 int sx = SX + drawingarea_info[id].x - MINI_TILEX / 2;
8131 int sy = SY + drawingarea_info[id].y - MINI_TILEY / 2;
8132 int xsize = MAX_ANDROID_ELEMENTS;
8135 /* display counter to choose number of element areas */
8136 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
8138 if (drawingarea_info[id].text_left != NULL)
8139 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
8141 UnmapDrawingArea(id);
8143 ModifyEditorDrawingArea(id, num_elements, 1);
8145 /* delete content areas in case of reducing number of them */
8146 DrawBackground(sx, sy, (xsize + 1) * MINI_TILEX, (ysize + 1) * MINI_TILEY);
8151 static void DrawGroupElementArea(int element)
8153 int num_elements = group_element_info.num_elements;
8154 int id = ED_DRAWING_ID_GROUP_CONTENT;
8155 int bx = ED_ELEMENT_BORDER_INPUT;
8156 int by = ED_ELEMENT_BORDER_INPUT;
8157 int sx = SX + drawingarea_info[id].x - bx;
8158 int sy = SY + drawingarea_info[id].y - by;
8159 int xsize = MAX_ELEMENTS_IN_GROUP;
8162 if (drawingarea_info[id].text_left != NULL)
8163 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
8165 UnmapDrawingArea(id);
8167 ModifyEditorDrawingArea(id, num_elements, 1);
8169 /* delete content areas in case of reducing number of them */
8170 DrawBackground(sx, sy, xsize * MINI_TILEX + 2*bx, ysize * MINI_TILEY + 2*by);
8175 static void DrawPlayerInitialInventoryArea(int element)
8177 int player_nr = GET_PLAYER_NR(element);
8178 int num_elements = level.initial_inventory_size[player_nr];
8179 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
8180 int sx = SX + drawingarea_info[id].x - MINI_TILEX / 2;
8181 int sy = SY + drawingarea_info[id].y - MINI_TILEY / 2;
8182 int xsize = MAX_INITIAL_INVENTORY_SIZE;
8185 /* determine horizontal position to the right of specified gadget */
8186 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
8187 sx += (right_gadget_border[drawingarea_info[id].gadget_id_align] +
8188 ED_DRAWINGAREA_TEXT_DISTANCE);
8190 /* determine horizontal offset for leading text */
8191 if (drawingarea_info[id].text_left != NULL)
8192 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
8194 UnmapDrawingArea(id);
8196 ModifyEditorDrawingArea(id, num_elements, 1);
8198 /* delete content areas in case of reducing number of them */
8199 DrawBackground(sx, sy, (xsize + 1) * MINI_TILEX, (ysize + 1) * MINI_TILEY);
8204 static void DrawEnvelopeTextArea(int envelope_nr)
8206 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
8207 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
8210 DrawBackground(gi->x, gi->y, gi->width, gi->height);
8212 if (envelope_nr != -1)
8213 textarea_info[id].value = level.envelope[envelope_nr].text;
8215 ModifyGadget(gi, GDI_AREA_SIZE,
8216 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
8217 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
8220 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
8223 static boolean PrintInfoText(char *text, int font_nr, int start_line)
8225 int font_height = getFontHeight(font_nr);
8226 int pad_x = ED_ELEMENT_SETTINGS_XPOS(0);
8227 int pad_y = ED_ELEMENT_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
8228 int sx = SX + pad_x;
8229 int sy = SY + pad_y;
8230 int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
8232 if (start_line >= max_lines_per_screen)
8235 DrawText(sx, sy + start_line * font_height, text, font_nr);
8240 static int PrintElementDescriptionFromFile(char *filename, int start_line)
8242 int font_nr = FONT_TEXT_2;
8243 int font_width = getFontWidth(font_nr);
8244 int font_height = getFontHeight(font_nr);
8245 int pad_x = ED_ELEMENT_SETTINGS_XPOS(0);
8246 int pad_y = ED_ELEMENT_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
8247 int sx = SX + pad_x;
8248 int sy = SY + pad_y + start_line * font_height;
8249 int max_chars_per_line = (SXSIZE - 2 * pad_x) / font_width;
8250 int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
8251 int max_lines_drawable = max_lines_per_screen - start_line;
8253 if (start_line >= max_lines_per_screen)
8256 return DrawTextFile(sx, sy, filename, font_nr, max_chars_per_line, -1,
8257 max_lines_drawable, 0, -1, TRUE, FALSE, FALSE);
8260 static void DrawPropertiesInfo()
8269 /* configurable properties */
8271 { EP_WALKABLE_OVER, "- player can walk over it" },
8272 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
8273 { EP_WALKABLE_UNDER, "- player can walk under it" },
8274 { EP_PASSABLE_OVER, "- player can pass over it" },
8275 { EP_PASSABLE_INSIDE, "- player can pass through it" },
8276 { EP_PASSABLE_UNDER, "- player can pass under it" },
8277 { EP_PROTECTED, "- player is protected by it" },
8279 { EP_DIGGABLE, "- can be digged away" },
8280 { EP_COLLECTIBLE, "- can be collected" },
8281 { EP_DROPPABLE, "- can be dropped after collecting" },
8282 { EP_THROWABLE, "- can be thrown after collecting" },
8283 { EP_PUSHABLE, "- can be pushed" },
8285 { EP_CAN_FALL, "- can fall" },
8286 { EP_CAN_MOVE, "- can move" },
8288 { EP_CAN_SMASH_PLAYER, "- can smash player" },
8290 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
8292 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
8294 { EP_SLIPPERY, "- slippery for falling elements" },
8295 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
8297 { EP_DONT_RUN_INTO, "- deadly when running into" },
8298 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
8299 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
8300 { EP_DONT_TOUCH, "- deadly when touching" },
8302 { EP_INDESTRUCTIBLE, "- indestructible" },
8304 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
8305 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
8306 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
8308 { EP_CAN_CHANGE, "- can change to other element" },
8310 /* pre-defined properties */
8311 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
8312 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
8313 { EP_SWITCHABLE, "- can be switched" },
8315 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
8320 char *filename = getElementDescriptionFilename(properties_element);
8321 char *percentage_text = "In this level: ";
8322 char *properties_text = "Standard properties: ";
8324 int num_elements_in_level;
8325 int num_standard_properties = 0;
8326 int font1_nr = FONT_TEXT_1;
8327 int font2_nr = FONT_TEXT_2;
8328 int font1_width = getFontWidth(font1_nr);
8329 int font2_height = getFontHeight(font2_nr);
8330 int pad_x = ED_ELEMENT_SETTINGS_XPOS(0);
8331 int pad_y = ED_ELEMENT_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
8332 int screen_line = 0;
8335 if (setup.editor.show_element_token)
8337 DrawTextF(pad_x, pad_y + screen_line++ * font2_height, FONT_TEXT_3,
8338 "[%s]", element_info[properties_element].token_name);
8342 /* ----- print number of elements / percentage of this element in level */
8344 num_elements_in_level = 0;
8345 for (y = 0; y < lev_fieldy; y++)
8346 for (x = 0; x < lev_fieldx; x++)
8347 if (Feld[x][y] == properties_element)
8348 num_elements_in_level++;
8349 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
8351 DrawTextS(pad_x, pad_y + screen_line * font2_height, font1_nr,
8353 DrawTextF(pad_x + strlen(percentage_text) * font1_width,
8354 pad_y + screen_line++ * font2_height, font2_nr,
8355 "%d (%.2f%%)", num_elements_in_level, percentage);
8359 /* ----- print standard properties of this element */
8361 DrawTextS(pad_x, pad_y + screen_line++ * font2_height, font1_nr,
8364 for (i = 0; properties[i].value != -1; i++)
8366 if (!HAS_PROPERTY(properties_element, properties[i].value))
8369 DrawTextS(pad_x, pad_y + screen_line++ * font2_height, font2_nr,
8370 properties[i].text);
8371 num_standard_properties++;
8374 if (num_standard_properties == 0)
8375 DrawTextS(pad_x + strlen(properties_text) * font1_width,
8376 pad_y + (screen_line - 1) * font2_height, font2_nr, "none");
8380 /* ----- print special description of this element */
8382 PrintInfoText("Description:", FONT_TEXT_1, screen_line);
8383 if (PrintElementDescriptionFromFile(filename, screen_line + 1) == 0)
8384 PrintInfoText("No description available.", FONT_TEXT_1, screen_line);
8387 #define TEXT_COLLECTING "Score for collecting"
8388 #define TEXT_SMASHING "Score for smashing"
8389 #define TEXT_SLURPING "Score for slurping robot"
8390 #define TEXT_CRACKING "Score for cracking"
8391 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
8392 #define TEXT_DURATION "Duration when activated"
8393 #define TEXT_BALL_DELAY "Element generation delay"
8394 #define TEXT_MOVE_SPEED "Speed of android moving"
8395 #define TEXT_CLONE_SPEED "Speed of android cloning"
8396 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
8397 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
8398 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
8399 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
8400 #define TEXT_TIME_BONUS "Extra time to solve level"
8407 } elements_with_counter[] =
8409 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
8410 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
8411 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
8412 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
8413 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
8414 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
8415 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
8416 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
8417 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
8418 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
8419 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
8420 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
8421 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
8422 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
8423 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
8424 { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
8425 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
8426 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
8427 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
8428 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
8429 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8430 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8431 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8432 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8433 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8434 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8435 { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
8436 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8437 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8438 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8439 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8440 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
8441 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
8442 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
8443 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
8444 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
8445 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
8446 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
8447 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
8448 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
8449 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
8450 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
8451 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
8452 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
8453 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
8454 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
8455 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE],TEXT_COLLECTING },
8456 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
8457 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
8458 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
8459 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
8460 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
8461 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
8462 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
8463 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
8464 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
8465 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
8466 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
8467 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
8468 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
8469 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
8470 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
8471 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
8472 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
8473 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
8474 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
8475 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
8476 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
8477 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
8478 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
8479 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
8480 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
8481 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
8482 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
8484 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
8485 { EL_DC_TIMEGATE_SWITCH,&level.time_timegate, TEXT_DURATION },
8486 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
8487 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
8488 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
8489 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
8490 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
8491 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
8492 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
8493 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
8494 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
8495 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
8496 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
8497 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
8498 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
8499 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
8501 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
8502 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
8503 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
8504 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
8505 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
8506 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
8507 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
8508 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
8513 static boolean checkPropertiesConfig(int element)
8517 if (IS_GEM(element) ||
8518 IS_CUSTOM_ELEMENT(element) ||
8519 IS_GROUP_ELEMENT(element) ||
8520 IS_ENVELOPE(element) ||
8521 ELEM_IS_PLAYER(element) ||
8522 HAS_EDITOR_CONTENT(element) ||
8523 CAN_GROW(element) ||
8524 COULD_MOVE_INTO_ACID(element) ||
8525 MAYBE_DONT_COLLIDE_WITH(element) ||
8526 element == EL_SOKOBAN_OBJECT ||
8527 element == EL_SOKOBAN_FIELD_EMPTY ||
8528 element == EL_SOKOBAN_FIELD_FULL)
8531 for (i = 0; elements_with_counter[i].element != -1; i++)
8532 if (elements_with_counter[i].element == element)
8538 static void DrawPropertiesConfig()
8540 boolean draw_footer_line = FALSE;
8541 int max_num_element_counters = 4;
8542 int num_element_counters = 0;
8545 if (!checkPropertiesConfig(properties_element))
8547 PrintInfoText("No configuration options available.", FONT_TEXT_1, 0);
8552 /* check if there are elements where a value can be chosen for */
8553 for (i = 0; elements_with_counter[i].element != -1; i++)
8555 if (elements_with_counter[i].element == properties_element)
8557 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
8559 counterbutton_info[counter_id].y =
8560 ED_ELEMENT_SETTINGS_YPOS(
8561 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
8562 (CAN_GROW(properties_element) ? 1 : 0) +
8563 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
8564 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
8565 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
8566 num_element_counters);
8568 counterbutton_info[counter_id].value = elements_with_counter[i].value;
8569 counterbutton_info[counter_id].text_right= elements_with_counter[i].text;
8571 if (properties_element == EL_GAME_OF_LIFE ||
8572 properties_element == EL_BIOMAZE)
8574 counterbutton_info[counter_id].min_value = 0; /* min neighbours */
8575 counterbutton_info[counter_id].max_value = 8; /* max neighbours */
8579 /* !!! CHANGE THIS FOR CERTAIN ELEMENTS !!! */
8580 counterbutton_info[counter_id].min_value = MIN_SCORE;
8581 counterbutton_info[counter_id].max_value = MAX_SCORE;
8584 MapCounterButtons(counter_id);
8586 num_element_counters++;
8587 if (num_element_counters >= max_num_element_counters)
8592 if (HAS_EDITOR_CONTENT(properties_element))
8594 /* draw stickybutton gadget */
8595 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
8597 if (IS_AMOEBOID(properties_element))
8598 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
8599 else if (properties_element == EL_YAMYAM ||
8600 properties_element == EL_YAMYAM_LEFT ||
8601 properties_element == EL_YAMYAM_RIGHT ||
8602 properties_element == EL_YAMYAM_UP ||
8603 properties_element == EL_YAMYAM_DOWN)
8604 DrawYamYamContentAreas();
8605 else if (properties_element == EL_EMC_MAGIC_BALL)
8607 DrawMagicBallContentAreas();
8609 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
8610 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_STATE);
8612 else if (properties_element == EL_EMC_ANDROID)
8613 DrawAndroidElementArea(properties_element);
8616 if (ELEM_IS_PLAYER(properties_element))
8618 int player_nr = GET_PLAYER_NR(properties_element);
8620 /* these properties can be set for every player individually */
8622 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
8624 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
8625 &level.start_element[player_nr];
8626 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
8627 &level.artwork_element[player_nr];
8628 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
8629 &level.explosion_element[player_nr];
8631 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
8632 &level.use_start_element[player_nr];
8633 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
8634 &level.use_artwork_element[player_nr];
8635 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
8636 &level.use_explosion_element[player_nr];
8637 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
8638 &level.initial_player_gravity[player_nr];
8640 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
8641 &level.initial_player_stepsize[player_nr];
8643 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
8644 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
8645 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
8646 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
8647 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
8648 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
8649 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
8650 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
8651 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
8652 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
8653 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
8654 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
8655 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
8657 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
8658 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
8659 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
8661 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
8663 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
8665 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
8666 &level.initial_inventory_content[player_nr][0];
8668 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
8669 &level.initial_inventory_size[player_nr];
8671 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
8672 &level.use_initial_inventory[player_nr];
8674 /* draw checkbutton gadgets */
8675 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
8677 /* draw counter gadgets */
8678 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
8680 /* draw drawing area gadgets */
8681 DrawPlayerInitialInventoryArea(properties_element);
8685 if (IS_GEM(properties_element))
8686 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
8688 if (properties_element == EL_EM_DYNAMITE)
8689 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
8691 if (COULD_MOVE_INTO_ACID(properties_element) &&
8692 !ELEM_IS_PLAYER(properties_element) &&
8693 (!IS_CUSTOM_ELEMENT(properties_element) ||
8694 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
8696 /* set position for checkbutton for "can move into acid" */
8697 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
8698 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
8699 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
8700 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 6 :
8701 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
8703 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
8706 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
8707 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
8709 if (properties_element == EL_SPRING)
8710 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
8712 if (properties_element == EL_TIME_ORB_FULL)
8713 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
8715 if (CAN_GROW(properties_element))
8717 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
8718 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
8720 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
8723 if (properties_element == EL_SOKOBAN_OBJECT ||
8724 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
8725 properties_element == EL_SOKOBAN_FIELD_FULL)
8726 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
8728 if (IS_ENVELOPE(properties_element))
8730 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
8731 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
8732 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
8733 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
8734 int envelope_nr = properties_element - EL_ENVELOPE_1;
8736 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
8737 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
8739 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
8740 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
8742 /* display counter to choose size of envelope text area */
8743 MapCounterButtons(counter1_id);
8744 MapCounterButtons(counter2_id);
8746 /* display checkbuttons to choose auto-wrap and alignment properties */
8747 MapCheckbuttonGadget(button1_id);
8748 MapCheckbuttonGadget(button2_id);
8750 DrawEnvelopeTextArea(envelope_nr);
8753 if (IS_CUSTOM_ELEMENT(properties_element))
8755 /* draw stickybutton gadget */
8756 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
8758 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
8760 /* draw checkbutton gadgets */
8761 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
8762 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
8763 MapCheckbuttonGadget(i);
8765 /* draw counter gadgets */
8766 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
8767 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
8768 MapCounterButtons(i);
8770 /* draw selectbox gadgets */
8771 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
8772 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
8773 MapSelectboxGadget(i);
8775 /* draw textbutton gadgets */
8776 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE);
8778 /* draw text input gadgets */
8779 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
8781 /* draw drawing area gadgets */
8782 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
8784 draw_footer_line = TRUE;
8786 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
8788 /* draw checkbutton gadgets */
8789 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
8790 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
8791 MapCheckbuttonGadget(i);
8793 /* draw counter gadgets */
8794 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
8795 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
8796 MapCounterButtons(i);
8798 /* draw selectbox gadgets */
8799 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
8800 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
8801 MapSelectboxGadget(i);
8803 /* draw drawing area gadgets */
8804 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
8805 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
8806 DrawCustomContentArea();
8809 else if (IS_GROUP_ELEMENT(properties_element))
8811 /* draw stickybutton gadget */
8812 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
8814 /* draw checkbutton gadgets */
8815 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
8816 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE);
8818 /* draw counter gadgets */
8819 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
8821 /* draw selectbox gadgets */
8822 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
8824 /* draw textbutton gadgets */
8825 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE);
8827 /* draw drawing area gadgets */
8828 DrawGroupElementArea(properties_element);
8830 /* draw text input gadgets */
8831 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
8833 /* draw drawing area gadgets */
8834 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
8836 draw_footer_line = TRUE;
8839 /* draw little footer border line above CE/GE use/save template gadgets */
8840 if (draw_footer_line)
8842 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
8843 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
8844 int gd_x = gd->x + gd_gi1->border.width / 2;
8845 int gd_y = gd->y + gd_gi1->height - 1;
8846 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
8848 if (tab_color != BLACK_PIXEL) /* black => transparent */
8849 FillRectangle(drawto,
8850 SX + ED_ELEMENT_SETTINGS_XPOS(0),
8851 SY + ED_ELEMENT_SETTINGS_YPOS(14) - MINI_TILEY / 2,
8852 getTabulatorBarWidth(), ED_GADGET_DISTANCE,
8857 static void DrawPropertiesChangeDrawingAreas()
8859 if (IS_CUSTOM_ELEMENT(properties_element))
8861 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
8862 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
8863 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
8865 DrawCustomChangeContentArea();
8868 redraw_mask |= REDRAW_FIELD;
8871 static void DrawPropertiesChange()
8875 /* needed to initially set selectbox options for special action options */
8876 setSelectboxSpecialActionOptions();
8878 /* draw stickybutton gadget */
8879 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
8881 /* draw checkbutton gadgets */
8882 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
8883 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
8884 MapCheckbuttonGadget(i);
8886 /* draw counter gadgets */
8887 for (i = ED_COUNTER_ID_CHANGE_FIRST;
8888 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
8889 MapCounterButtons(i);
8891 /* draw selectbox gadgets */
8892 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
8893 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
8894 MapSelectboxGadget(i);
8896 /* draw textbutton gadgets */
8897 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
8898 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
8899 MapTextbuttonGadget(i);
8901 /* draw graphicbutton gadgets */
8902 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
8903 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
8904 MapGraphicbuttonGadget(i);
8906 /* draw drawing area gadgets */
8907 DrawPropertiesChangeDrawingAreas();
8910 static void DrawEditorElementAnimation(int x, int y)
8912 int graphic = el2img(properties_element);
8913 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
8914 custom_element.ce_value_fixed_initial :
8915 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
8916 custom_element.collect_score_initial : FrameCounter);
8918 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
8921 static void DrawEditorElementName(int x, int y, int element)
8923 char *element_name = getElementInfoText(element);
8924 int font_nr = FONT_TEXT_1;
8925 int font_width = getFontWidth(font_nr);
8926 int font_height = getFontHeight(font_nr);
8927 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_XPOS(0);
8928 int max_chars_per_line = max_text_width / font_width;
8929 char buffer[max_chars_per_line + 1];
8931 if (strlen(element_name) <= max_chars_per_line)
8932 DrawTextS(x, y, font_nr, element_name);
8935 int next_pos = max_chars_per_line;
8937 strncpy(buffer, element_name, max_chars_per_line);
8938 buffer[max_chars_per_line] = '\0';
8940 if (element_name[max_chars_per_line] == ' ')
8946 for (i = max_chars_per_line - 1; i >= 0; i--)
8947 if (buffer[i] == ' ')
8950 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
8957 DrawTextS(x, y - font_height / 2, font_nr, buffer);
8959 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
8960 buffer[max_chars_per_line] = '\0';
8962 DrawTextS(x, y + font_height / 2, font_nr, buffer);
8966 static void DrawPropertiesWindow()
8971 stick_element_properties_window = FALSE;
8973 /* make sure that previous properties edit mode exists for this element */
8974 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
8975 !IS_CUSTOM_ELEMENT(properties_element))
8976 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
8978 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
8979 !ELEM_IS_PLAYER(properties_element) &&
8980 !IS_CUSTOM_ELEMENT(properties_element))
8981 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
8983 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
8984 (ELEM_IS_PLAYER(properties_element) ||
8985 IS_CUSTOM_ELEMENT(properties_element)))
8986 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
8988 CopyElementPropertiesToEditor(properties_element);
8990 UnmapLevelEditorFieldGadgets();
8991 UnmapLevelEditorToolboxDrawingGadgets();
8992 UnmapLevelEditorToolboxCustomGadgets();
8994 if (IS_CUSTOM_ELEMENT(properties_element) ||
8995 IS_GROUP_ELEMENT(properties_element))
8996 MapLevelEditorToolboxCustomGadgets();
8998 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
9001 DrawTextSCentered(ED_SETTINGS1_YPOS, FONT_TITLE_1, "Element Settings");
9003 FrameCounter = 0; /* restart animation frame counter */
9005 DrawElementBorder(SX + xstart * MINI_TILEX,
9006 SY + ystart * MINI_TILEY + MINI_TILEY / 2,
9007 TILEX, TILEY, FALSE);
9009 DrawEditorElementAnimation(SX + xstart * MINI_TILEX,
9010 SY + ystart * MINI_TILEY + MINI_TILEY / 2);
9012 DrawEditorElementName((xstart + 3) * MINI_TILEX + 1,
9013 (ystart + 1) * MINI_TILEY + 1,
9014 properties_element);
9016 DrawPropertiesTabulatorGadgets();
9018 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
9019 DrawPropertiesInfo();
9020 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
9021 DrawPropertiesChange();
9022 else /* (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2]) */
9023 DrawPropertiesConfig();
9026 static void UpdateCustomElementGraphicGadgets()
9028 struct ElementInfo *ei = &element_info[properties_element];
9031 ei->gfx_element = (ei->use_gfx_element ? ei->gfx_element_initial :
9032 properties_element);
9034 ModifyEditorElementList();
9035 RedrawDrawingElements();
9037 /* force redraw of all mapped drawing area gadgets */
9038 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
9040 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
9047 static int getOpenDirectionFromTube(int element)
9051 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
9052 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
9053 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
9054 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
9055 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
9056 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
9057 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
9058 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
9059 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
9060 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
9061 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
9067 static int getTubeFromOpenDirection(int direction)
9071 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
9072 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
9073 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
9074 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
9075 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
9076 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
9077 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
9078 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
9079 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
9080 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
9081 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
9083 /* if only one direction, fall back to simple tube with that direction */
9084 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
9085 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
9086 case (MV_UP): return EL_TUBE_VERTICAL;
9087 case (MV_DOWN): return EL_TUBE_VERTICAL;
9093 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
9095 int element_new = getTubeFromOpenDirection(direction);
9097 return (element_new != EL_EMPTY ? element_new : element_old);
9100 static int getOpenDirectionFromBelt(int element)
9102 int belt_dir = getBeltDirFromBeltElement(element);
9104 return (belt_dir == MV_LEFT ? MV_RIGHT :
9105 belt_dir == MV_RIGHT ? MV_LEFT :
9106 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
9109 static int getBeltFromNrAndOpenDirection(int nr, int direction)
9111 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
9112 direction == MV_RIGHT ? MV_LEFT :
9113 direction == MV_HORIZONTAL ? MV_NONE : direction);
9115 if (direction == MV_NONE)
9118 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
9121 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
9124 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
9126 return (element_new != EL_EMPTY ? element_new : element_old);
9129 static int getOpenDirectionFromPool(int element)
9133 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
9134 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
9135 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
9136 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
9137 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
9138 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
9144 static int getPoolFromOpenDirection(int direction)
9148 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
9149 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
9150 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
9151 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
9152 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
9153 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
9159 static int getPoolFromOpenDirectionExt(int direction, int help_element)
9161 int element = getPoolFromOpenDirection(direction);
9162 int help_direction = getOpenDirectionFromPool(help_element);
9164 if (element == EL_EMPTY)
9166 int help_direction_vertical = help_direction & MV_VERTICAL;
9168 element = getPoolFromOpenDirection(direction | help_direction_vertical);
9171 if (element == EL_EMPTY)
9173 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
9175 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
9181 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
9183 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
9185 return (element_new != EL_EMPTY ? element_new : element_old);
9188 static int getOpenDirectionFromPillar(int element)
9192 case EL_EMC_WALL_1: return (MV_DOWN);
9193 case EL_EMC_WALL_2: return (MV_VERTICAL);
9194 case EL_EMC_WALL_3: return (MV_UP);
9200 static int getPillarFromOpenDirection(int direction)
9204 case (MV_DOWN): return EL_EMC_WALL_1;
9205 case (MV_VERTICAL): return EL_EMC_WALL_2;
9206 case (MV_UP): return EL_EMC_WALL_3;
9212 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
9214 int element_new = getPillarFromOpenDirection(direction);
9216 return (element_new != EL_EMPTY ? element_new : element_old);
9219 static int getOpenDirectionFromSteel2(int element)
9223 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
9224 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
9225 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
9226 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
9227 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
9228 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
9229 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
9230 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
9236 static int getSteel2FromOpenDirection(int direction)
9240 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
9241 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
9242 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
9243 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
9244 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
9245 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
9246 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
9247 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
9253 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
9255 int element_new = getSteel2FromOpenDirection(direction);
9257 return (element_new != EL_EMPTY ? element_new : element_old);
9260 static int getOpenDirectionFromChip(int element)
9264 case EL_SP_CHIP_SINGLE: return (MV_NONE);
9265 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
9266 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
9267 case EL_SP_CHIP_TOP: return (MV_DOWN);
9268 case EL_SP_CHIP_BOTTOM: return (MV_UP);
9274 static int getChipFromOpenDirection(int direction)
9278 case (MV_NONE): return EL_SP_CHIP_SINGLE;
9279 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
9280 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
9281 case (MV_UP): return EL_SP_CHIP_BOTTOM;
9282 case (MV_DOWN): return EL_SP_CHIP_TOP;
9288 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
9290 int element_new = getChipFromOpenDirection(direction);
9292 return (element_new != EL_EMPTY ? element_new : element_old);
9295 static int getClosedTube(int x, int y)
9297 static int xy[4][2] =
9304 int element_old = IntelliDrawBuffer[x][y];
9305 int direction_old = getOpenDirectionFromTube(element_old);
9306 int direction_new = MV_NONE;
9309 for (i = 0; i < NUM_DIRECTIONS; i++)
9311 int xx = x + xy[i][0];
9312 int yy = y + xy[i][1];
9313 int dir = MV_DIR_FROM_BIT(i);
9314 int dir_opposite = MV_DIR_OPPOSITE(dir);
9316 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
9317 (direction_old & dir) &&
9318 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
9319 direction_new |= dir;
9322 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
9325 static int getClosedBelt(int x, int y)
9327 static int xy[4][2] =
9334 int element_old = IntelliDrawBuffer[x][y];
9335 int nr = getBeltNrFromBeltElement(element_old);
9336 int direction_old = getOpenDirectionFromBelt(element_old);
9337 int direction_new = MV_NONE;
9340 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
9342 int xx = x + xy[i][0];
9343 int yy = y + xy[i][1];
9344 int dir = MV_DIR_FROM_BIT(i);
9345 int dir_opposite = MV_DIR_OPPOSITE(dir);
9347 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
9348 (direction_old & dir) &&
9349 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
9350 direction_new |= dir;
9353 return getBeltFromNrAndOpenDirection(nr, direction_new);
9356 static int getClosedPool(int x, int y)
9358 static int xy[4][2] =
9365 int element_old = IntelliDrawBuffer[x][y];
9366 int direction_old = getOpenDirectionFromPool(element_old);
9367 int direction_new = MV_NONE;
9370 for (i = 0; i < NUM_DIRECTIONS; i++)
9372 int xx = x + xy[i][0];
9373 int yy = y + xy[i][1];
9374 int dir = MV_DIR_FROM_BIT(i);
9375 int dir_opposite = MV_DIR_OPPOSITE(dir);
9377 if (IN_LEV_FIELD(xx, yy) &&
9378 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
9379 (direction_old & dir) &&
9380 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
9381 direction_new |= dir;
9384 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
9387 static int getClosedPillar(int x, int y)
9389 static int xy[4][2] =
9396 int element_old = IntelliDrawBuffer[x][y];
9397 int direction_old = getOpenDirectionFromPillar(element_old);
9398 int direction_new = MV_NONE;
9401 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
9403 int xx = x + xy[i][0];
9404 int yy = y + xy[i][1];
9405 int dir = MV_DIR_FROM_BIT(i);
9406 int dir_opposite = MV_DIR_OPPOSITE(dir);
9408 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
9409 (direction_old & dir) &&
9410 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
9411 direction_new |= dir;
9414 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
9417 static int getClosedSteel2(int x, int y)
9419 static int xy[4][2] =
9426 int element_old = IntelliDrawBuffer[x][y];
9427 int direction_old = getOpenDirectionFromSteel2(element_old);
9428 int direction_new = MV_NONE;
9431 for (i = 0; i < NUM_DIRECTIONS; i++)
9433 int xx = x + xy[i][0];
9434 int yy = y + xy[i][1];
9435 int dir = MV_DIR_FROM_BIT(i);
9436 int dir_opposite = MV_DIR_OPPOSITE(dir);
9438 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
9439 (direction_old & dir) &&
9440 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
9441 direction_new |= dir;
9444 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
9447 static int getClosedChip(int x, int y)
9449 static int xy[4][2] =
9456 int element_old = IntelliDrawBuffer[x][y];
9457 int direction_old = getOpenDirectionFromChip(element_old);
9458 int direction_new = MV_NONE;
9461 for (i = 0; i < NUM_DIRECTIONS; i++)
9463 int xx = x + xy[i][0];
9464 int yy = y + xy[i][1];
9465 int dir = MV_DIR_FROM_BIT(i);
9466 int dir_opposite = MV_DIR_OPPOSITE(dir);
9468 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
9469 (direction_old & dir) &&
9470 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
9471 direction_new |= dir;
9474 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
9477 static void SetElementSimple(int x, int y, int element, boolean change_level)
9479 int sx = x - level_xpos;
9480 int sy = y - level_ypos;
9482 IntelliDrawBuffer[x][y] = element;
9485 Feld[x][y] = element;
9487 if (IN_ED_FIELD(sx, sy))
9488 DrawEditorElement(sx, sy, element);
9491 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
9492 int x2, int y2, int *element2,
9493 int (*close_function)(int, int),
9494 boolean change_level)
9496 /* set neighbour elements to newly determined connections */
9497 SetElementSimple(x1, y1, *element1, change_level);
9498 SetElementSimple(x2, y2, *element2, change_level);
9500 /* remove all open connections of neighbour elements */
9501 *element1 = close_function(x1, y1);
9502 *element2 = close_function(x2, y2);
9504 /* set neighbour elements to new, minimized connections */
9505 SetElementSimple(x1, y1, *element1, change_level);
9506 SetElementSimple(x2, y2, *element2, change_level);
9509 static void SetElementIntelliDraw(int x, int y, int new_element,
9510 boolean change_level, int button)
9512 static int xy[4][2] =
9519 static int last_x = -1;
9520 static int last_y = -1;
9521 int old_element = IntelliDrawBuffer[x][y];
9523 if (new_element == EL_UNDEFINED)
9531 if (IS_TUBE(new_element))
9533 int last_element_new = EL_UNDEFINED;
9534 int direction = MV_NONE;
9537 /* if old element is of same kind, keep all existing directions */
9538 if (IS_TUBE(old_element))
9539 direction |= getOpenDirectionFromTube(old_element);
9541 for (i = 0; i < NUM_DIRECTIONS; i++)
9543 int xx = x + xy[i][0];
9544 int yy = y + xy[i][1];
9546 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9547 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
9549 int dir = MV_DIR_FROM_BIT(i);
9550 int dir_opposite = MV_DIR_OPPOSITE(dir);
9551 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9552 int last_direction_old = getOpenDirectionFromTube(last_element_old);
9553 int last_direction_new = last_direction_old | dir_opposite;
9555 last_element_new = getTubeFromOpenDirection(last_direction_new);
9561 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
9563 if (last_element_new != EL_UNDEFINED)
9564 MergeAndCloseNeighbourElements(x, y, &new_element,
9565 last_x, last_y, &last_element_new,
9566 getClosedTube, change_level);
9568 else if (IS_BELT(new_element))
9570 int belt_nr = getBeltNrFromBeltElement(new_element);
9571 int last_element_new = EL_UNDEFINED;
9572 int direction = MV_NONE;
9575 /* if old element is of same kind, keep all existing directions */
9576 if (IS_BELT(old_element))
9577 direction |= getOpenDirectionFromBelt(old_element);
9579 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
9581 int xx = x + xy[i][0];
9582 int yy = y + xy[i][1];
9584 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9585 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
9587 int dir = MV_DIR_FROM_BIT(i);
9588 int dir_opposite = MV_DIR_OPPOSITE(dir);
9589 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9590 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
9591 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
9592 int last_direction_new = last_direction_old | dir_opposite;
9594 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
9595 last_direction_new);
9600 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
9602 if (last_element_new != EL_UNDEFINED)
9603 MergeAndCloseNeighbourElements(x, y, &new_element,
9604 last_x, last_y, &last_element_new,
9605 getClosedBelt, change_level);
9607 else if (IS_ACID_POOL_OR_ACID(new_element))
9609 int last_element_new = EL_UNDEFINED;
9610 int direction = MV_NONE;
9613 /* if old element is of same kind, keep all existing directions */
9614 if (IS_ACID_POOL_OR_ACID(old_element))
9615 direction |= getOpenDirectionFromPool(old_element);
9617 for (i = 0; i < NUM_DIRECTIONS; i++)
9619 int xx = x + xy[i][0];
9620 int yy = y + xy[i][1];
9622 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9623 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
9625 int dir = MV_DIR_FROM_BIT(i);
9626 int dir_opposite = MV_DIR_OPPOSITE(dir);
9627 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9628 int last_direction_old = getOpenDirectionFromPool(last_element_old);
9629 int last_direction_new = last_direction_old | dir_opposite;
9631 last_element_new = getPoolFromOpenDirection(last_direction_new);
9637 /* special corrections needed for intuitively correct acid pool drawing */
9638 if (last_element_new == EL_EMPTY)
9639 last_element_new = new_element;
9640 else if (last_element_new != EL_UNDEFINED)
9641 new_element = last_element_new;
9643 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
9645 if (last_element_new != EL_UNDEFINED)
9646 MergeAndCloseNeighbourElements(x, y, &new_element,
9647 last_x, last_y, &last_element_new,
9648 getClosedPool, change_level);
9650 else if (IS_EMC_PILLAR(new_element))
9652 int last_element_new = EL_UNDEFINED;
9653 int direction = MV_NONE;
9656 /* if old element is of same kind, keep all existing directions */
9657 if (IS_EMC_PILLAR(old_element))
9658 direction |= getOpenDirectionFromPillar(old_element);
9660 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
9662 int xx = x + xy[i][0];
9663 int yy = y + xy[i][1];
9665 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9666 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
9668 int dir = MV_DIR_FROM_BIT(i);
9669 int dir_opposite = MV_DIR_OPPOSITE(dir);
9670 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9671 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
9672 int last_direction_new = last_direction_old | dir_opposite;
9674 last_element_new = getPillarFromOpenDirection(last_direction_new);
9680 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
9682 if (last_element_new != EL_UNDEFINED)
9683 MergeAndCloseNeighbourElements(x, y, &new_element,
9684 last_x, last_y, &last_element_new,
9685 getClosedPillar, change_level);
9687 else if (IS_DC_STEELWALL_2(new_element))
9689 int last_element_new = EL_UNDEFINED;
9690 int direction = MV_NONE;
9693 /* if old element is of same kind, keep all existing directions */
9694 if (IS_DC_STEELWALL_2(old_element))
9695 direction |= getOpenDirectionFromSteel2(old_element);
9697 for (i = 0; i < NUM_DIRECTIONS; i++)
9699 int xx = x + xy[i][0];
9700 int yy = y + xy[i][1];
9702 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9703 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
9705 int dir = MV_DIR_FROM_BIT(i);
9706 int dir_opposite = MV_DIR_OPPOSITE(dir);
9707 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9708 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
9709 int last_direction_new = last_direction_old | dir_opposite;
9711 last_element_new = getSteel2FromOpenDirection(last_direction_new);
9717 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
9719 if (last_element_new != EL_UNDEFINED)
9720 MergeAndCloseNeighbourElements(x, y, &new_element,
9721 last_x, last_y, &last_element_new,
9722 getClosedSteel2, change_level);
9724 else if (IS_SP_CHIP(new_element))
9726 int last_element_new = EL_UNDEFINED;
9727 int direction = MV_NONE;
9730 /* (do not keep existing directions, regardless of kind of old element) */
9732 for (i = 0; i < NUM_DIRECTIONS; i++)
9734 int xx = x + xy[i][0];
9735 int yy = y + xy[i][1];
9737 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9738 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
9740 int dir = MV_DIR_FROM_BIT(i);
9741 int dir_opposite = MV_DIR_OPPOSITE(dir);
9742 int last_element_old = IntelliDrawBuffer[last_x][last_y];
9743 int last_direction_old = getOpenDirectionFromChip(last_element_old);
9744 int last_direction_new = last_direction_old | dir_opposite;
9746 if (last_direction_old == MV_NONE)
9748 last_element_new = getChipFromOpenDirection(last_direction_new);
9751 else if (last_direction_old & (dir | dir_opposite))
9753 direction |= MV_DIR_OPPOSITE(last_direction_old);
9757 direction |= MV_DIR_OPPOSITE(dir);
9762 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
9764 if (last_element_new != EL_UNDEFINED)
9765 MergeAndCloseNeighbourElements(x, y, &new_element,
9766 last_x, last_y, &last_element_new,
9767 getClosedChip, change_level);
9769 else if (IS_SP_HARDWARE_BASE(new_element))
9771 int nr = GetSimpleRandom(6);
9773 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
9774 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
9775 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
9776 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
9777 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
9779 else if (new_element == EL_SP_HARDWARE_GREEN ||
9780 new_element == EL_SP_HARDWARE_BLUE ||
9781 new_element == EL_SP_HARDWARE_RED)
9783 int nr = GetSimpleRandom(3);
9785 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
9786 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
9788 else if (IS_GROUP_ELEMENT(new_element))
9790 boolean connected_drawing = FALSE;
9793 for (i = 0; i < NUM_DIRECTIONS; i++)
9795 int xx = x + xy[i][0];
9796 int yy = y + xy[i][1];
9798 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
9799 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
9800 connected_drawing = TRUE;
9803 if (!connected_drawing)
9804 ResolveGroupElement(new_element);
9806 new_element = GetElementFromGroupElement(new_element);
9808 else if (IS_BELT_SWITCH(old_element))
9810 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
9811 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
9813 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
9814 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
9816 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
9820 static int swappable_elements[][2] =
9822 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
9823 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
9824 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
9825 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
9826 { EL_EMERALD, EL_WALL_EMERALD },
9827 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
9828 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
9829 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
9830 { EL_DIAMOND, EL_WALL_DIAMOND },
9831 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
9832 { EL_GATE_1, EL_GATE_1_GRAY },
9833 { EL_GATE_2, EL_GATE_2_GRAY },
9834 { EL_GATE_3, EL_GATE_3_GRAY },
9835 { EL_GATE_4, EL_GATE_4_GRAY },
9836 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
9837 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
9838 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
9839 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
9840 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
9841 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
9842 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
9843 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
9844 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
9845 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
9846 { EL_LAMP, EL_LAMP_ACTIVE },
9847 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
9848 { EL_SP_BASE, EL_SP_BUGGY_BASE },
9849 { EL_PEARL, EL_WALL_PEARL },
9850 { EL_CRYSTAL, EL_WALL_CRYSTAL },
9851 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
9852 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
9853 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
9854 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
9855 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
9856 { EL_LANDMINE, EL_DC_LANDMINE },
9857 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
9858 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
9859 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
9860 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
9861 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
9865 static int rotatable_elements[][4] =
9883 EL_BD_BUTTERFLY_RIGHT,
9884 EL_BD_BUTTERFLY_DOWN,
9885 EL_BD_BUTTERFLY_LEFT
9890 EL_BD_FIREFLY_RIGHT,
9924 EL_SP_GRAVITY_PORT_UP,
9925 EL_SP_GRAVITY_PORT_RIGHT,
9926 EL_SP_GRAVITY_PORT_DOWN,
9927 EL_SP_GRAVITY_PORT_LEFT
9931 EL_SP_GRAVITY_ON_PORT_UP,
9932 EL_SP_GRAVITY_ON_PORT_RIGHT,
9933 EL_SP_GRAVITY_ON_PORT_DOWN,
9934 EL_SP_GRAVITY_ON_PORT_LEFT
9938 EL_SP_GRAVITY_OFF_PORT_UP,
9939 EL_SP_GRAVITY_OFF_PORT_RIGHT,
9940 EL_SP_GRAVITY_OFF_PORT_DOWN,
9941 EL_SP_GRAVITY_OFF_PORT_LEFT
9952 EL_BALLOON_SWITCH_UP,
9953 EL_BALLOON_SWITCH_RIGHT,
9954 EL_BALLOON_SWITCH_DOWN,
9955 EL_BALLOON_SWITCH_LEFT
9967 for (i = 0; swappable_elements[i][0] != -1; i++)
9969 int element1 = swappable_elements[i][0];
9970 int element2 = swappable_elements[i][1];
9972 if (old_element == element1 || old_element == element2)
9973 new_element = (old_element == element1 ? element2 : element1);
9976 for (i = 0; rotatable_elements[i][0] != -1; i++)
9978 for (j = 0; j < 4; j++)
9980 int element = rotatable_elements[i][j];
9982 if (old_element == element)
9983 new_element = (button == 1 ? rotatable_elements[i][(j + 3) % 4] :
9984 button == 2 ? rotatable_elements[i][0] :
9985 button == 3 ? rotatable_elements[i][(j + 1) % 4] :
9991 SetElementSimple(x, y, new_element, change_level);
9997 static void ResetIntelliDraw()
10001 for (x = 0; x < lev_fieldx; x++)
10002 for (y = 0; y < lev_fieldy; y++)
10003 IntelliDrawBuffer[x][y] = Feld[x][y];
10005 SetElementIntelliDraw(-1, -1, EL_UNDEFINED, FALSE, -1);
10008 static void SetElementExt(int x, int y, int element, boolean change_level,
10012 SetElementSimple(x, y, Feld[x][y], change_level);
10013 else if (GetKeyModState() & KMOD_Shift)
10014 SetElementIntelliDraw(x, y, element, change_level, button);
10016 SetElementSimple(x, y, element, change_level);
10019 static void SetElement(int x, int y, int element)
10021 SetElementExt(x, y, element, TRUE, -1);
10024 static void SetElementButton(int x, int y, int element, int button)
10026 SetElementExt(x, y, element, TRUE, button);
10029 static void DrawLineElement(int sx, int sy, int element, boolean change_level)
10031 int lx = sx + level_xpos;
10032 int ly = sy + level_ypos;
10034 SetElementExt(lx, ly, element, change_level, -1);
10037 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
10038 int element, boolean change_level)
10040 int xsize = ABS(to_x - from_x);
10041 int ysize = ABS(to_y - from_y);
10042 int dx = (to_x < from_x ? -1 : +1);
10043 int dy = (to_y < from_y ? -1 : +1);
10046 if (from_y == to_y) /* horizontal line */
10048 for (i = 0; i <= xsize; i++)
10049 DrawLineElement(from_x + i * dx, from_y, element, change_level);
10051 else if (from_x == to_x) /* vertical line */
10053 for (i = 0; i <= ysize; i++)
10054 DrawLineElement(from_x, from_y + i * dy, element, change_level);
10056 else /* diagonal line */
10058 if (ysize < xsize) /* a < 1 */
10060 float a = (float)ysize / (float)xsize;
10062 for (i = 0; i <= xsize; i++)
10065 int y = dy * (int)(a * i + 0.5);
10067 DrawLineElement(from_x + x, from_y + y, element, change_level);
10072 float a = (float)xsize / (float)ysize;
10074 for (i = 0; i <= ysize; i++)
10076 int x = dx * (int)(a * i + 0.5);
10079 DrawLineElement(from_x + x, from_y + y, element, change_level);
10085 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
10086 int element, boolean change_level)
10088 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
10089 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
10090 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
10091 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
10094 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
10095 int element, boolean change_level)
10100 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
10102 for (y = from_y; y <= to_y; y++)
10103 DrawLine(from_x, y, to_x, y, element, change_level);
10106 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
10107 int element, boolean change_level)
10109 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
10110 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
10111 int len_x = ABS(to_x - from_x);
10112 int len_y = ABS(to_y - from_y);
10115 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
10117 /* not optimal (some points get drawn twice) but simple,
10118 and fast enough for the few points we are drawing */
10120 for (x = 0; x <= radius; x++)
10122 int sx, sy, lx, ly;
10124 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
10126 sx = from_x + x * (from_x < to_x2 ? +1 : -1);
10127 sy = from_y + y * (from_y < to_y2 ? +1 : -1);
10128 lx = sx + level_xpos;
10129 ly = sy + level_ypos;
10131 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
10132 DrawLineElement(sx, sy, element, change_level);
10135 for (y = 0; y <= radius; y++)
10137 int sx, sy, lx, ly;
10139 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
10141 sx = from_x + x * (from_x < to_x2 ? +1 : -1);
10142 sy = from_y + y * (from_y < to_y2 ? +1 : -1);
10143 lx = sx + level_xpos;
10144 ly = sy + level_ypos;
10146 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
10147 DrawLineElement(sx, sy, element, change_level);
10151 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
10152 int element, boolean change_level)
10154 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
10155 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
10157 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
10160 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
10162 #if DRAW_CIRCLES_BUTTON_AVAILABLE
10163 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
10164 int element, boolean change_level)
10166 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
10167 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
10168 int mirror_to_x2 = from_x - (to_x2 - from_x);
10169 int mirror_to_y2 = from_y - (to_y2 - from_y);
10171 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
10172 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
10173 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
10174 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element,change_level);
10178 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
10180 int from_sx, from_sy;
10184 swap_numbers(&from_x, &to_x);
10187 swap_numbers(&from_y, &to_y);
10189 from_sx = SX + from_x * ed_tilesize;
10190 from_sy = SY + from_y * ed_tilesize;
10191 to_sx = SX + (to_x + 1) * ed_tilesize - 1;
10192 to_sy = SY + (to_y + 1) * ed_tilesize - 1;
10194 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
10195 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
10196 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
10197 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
10199 if (from_x == to_x && from_y == to_y)
10200 MarkTileDirty(from_x/2, from_y/2);
10202 redraw_mask |= REDRAW_FIELD;
10205 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
10206 int element, boolean change_level)
10208 if (element == -1 || change_level)
10209 DrawBox(from_x, from_y, to_x, to_y, -1, FALSE);
10211 DrawAreaBorder(from_x, from_y, to_x, to_y);
10214 /* values for CopyBrushExt() */
10215 #define CB_AREA_TO_BRUSH 0
10216 #define CB_BRUSH_TO_CURSOR 1
10217 #define CB_BRUSH_TO_LEVEL 2
10218 #define CB_DELETE_OLD_CURSOR 3
10219 #define CB_DUMP_BRUSH 4
10220 #define CB_DUMP_BRUSH_SMALL 5
10222 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
10223 int button, int mode)
10225 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
10226 static int brush_width, brush_height;
10227 static int last_cursor_x = -1, last_cursor_y = -1;
10228 static boolean delete_old_brush;
10229 int new_element = BUTTON_ELEMENT(button);
10232 if (mode == CB_DUMP_BRUSH ||
10233 mode == CB_DUMP_BRUSH_SMALL)
10235 if (!draw_with_brush)
10237 Error(ERR_WARN, "no brush selected");
10242 for (y = 0; y < brush_height; y++)
10244 for (x = 0; x < brush_width; x++)
10246 int element = brush_buffer[x][y];
10247 int element_mapped = element;
10249 if (IS_CUSTOM_ELEMENT(element))
10250 element_mapped = EL_CUSTOM_START;
10251 else if (IS_GROUP_ELEMENT(element))
10252 element_mapped = EL_GROUP_START;
10253 else if (element >= NUM_FILE_ELEMENTS)
10254 element_mapped = EL_UNKNOWN;
10256 // dump brush as level sketch text for the R'n'D forum:
10257 // - large tiles: `xxx (0x60 ASCII)
10258 // - small tiles: ¸xxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
10259 printf("%s%03d", (mode == CB_DUMP_BRUSH ? "`" : "¸"), element_mapped);
10268 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
10271 if (mode == CB_AREA_TO_BRUSH)
10273 int from_lx, from_ly;
10276 swap_numbers(&from_x, &to_x);
10279 swap_numbers(&from_y, &to_y);
10281 brush_width = to_x - from_x + 1;
10282 brush_height = to_y - from_y + 1;
10284 from_lx = from_x + level_xpos;
10285 from_ly = from_y + level_ypos;
10287 for (y = 0; y < brush_height; y++)
10289 for (x = 0; x < brush_width; x++)
10291 brush_buffer[x][y] = Feld[from_lx + x][from_ly + y];
10294 DrawLineElement(from_x + x, from_y + y, new_element, TRUE);
10299 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10301 delete_old_brush = FALSE;
10303 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
10304 mode == CB_BRUSH_TO_LEVEL)
10306 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
10307 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
10308 int cursor_from_x = cursor_x - brush_width / 2;
10309 int cursor_from_y = cursor_y - brush_height / 2;
10310 int border_from_x = cursor_x, border_from_y = cursor_y;
10311 int border_to_x = cursor_x, border_to_y = cursor_y;
10313 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
10314 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
10316 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
10317 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
10319 delete_old_brush = FALSE;
10323 for (y = 0; y < brush_height; y++)
10325 for (x = 0; x < brush_width; x++)
10327 int sx = cursor_from_x + x;
10328 int sy = cursor_from_y + y;
10329 int lx = sx + level_xpos;
10330 int ly = sy + level_ypos;
10331 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
10332 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
10333 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
10334 brush_buffer[x][y] : new_element);
10336 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
10338 if (sx < border_from_x)
10339 border_from_x = sx;
10340 else if (sx > border_to_x)
10342 if (sy < border_from_y)
10343 border_from_y = sy;
10344 else if (sy > border_to_y)
10347 DrawLineElement(sx, sy, element, change_level);
10352 if (mode != CB_DELETE_OLD_CURSOR)
10353 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
10355 last_cursor_x = cursor_x;
10356 last_cursor_y = cursor_y;
10357 delete_old_brush = TRUE;
10361 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
10364 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
10367 static void CopyBrushToLevel(int x, int y, int button)
10369 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
10372 static void CopyBrushToCursor(int x, int y)
10374 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
10377 static void DeleteBrushFromCursor()
10379 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
10384 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
10387 void DumpBrush_Small()
10389 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
10392 static void FloodFill(int from_x, int from_y, int fill_element)
10394 FloodFillLevel(from_x, from_y, fill_element, Feld, lev_fieldx, lev_fieldy);
10397 /* values for DrawLevelText() modes */
10398 #define TEXT_INIT 0
10399 #define TEXT_SETCURSOR 1
10400 #define TEXT_WRITECHAR 2
10401 #define TEXT_BACKSPACE 3
10402 #define TEXT_NEWLINE 4
10404 #define TEXT_QUERY_TYPING 6
10406 static int DrawLevelText(int sx, int sy, char letter, int mode)
10408 static short delete_buffer[MAX_LEV_FIELDX];
10409 static int start_sx;
10410 static int last_sx, last_sy;
10411 static boolean typing = FALSE;
10412 int letter_element = EL_CHAR_ASCII0 + letter;
10413 int lx = 0, ly = 0;
10415 /* map lower case letters to upper case and convert special characters */
10416 if (letter >= 'a' && letter <= 'z')
10417 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
10418 else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
10419 letter_element = EL_CHAR_AUMLAUT;
10420 else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
10421 letter_element = EL_CHAR_OUMLAUT;
10422 else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
10423 letter_element = EL_CHAR_UUMLAUT;
10424 else if (letter == '^')
10425 letter_element = EL_CHAR_COPYRIGHT;
10427 letter_element = EL_CHAR_ASCII0 + letter;
10429 if (mode != TEXT_INIT)
10434 if (mode != TEXT_SETCURSOR)
10440 lx = last_sx + level_xpos;
10441 ly = last_sy + level_ypos;
10448 DrawLevelText(0, 0, 0, TEXT_END);
10454 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
10457 case TEXT_SETCURSOR:
10458 DrawEditorElement(last_sx, last_sy, Feld[lx][ly]);
10459 DrawAreaBorder(sx, sy, sx, sy);
10464 case TEXT_WRITECHAR:
10465 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
10467 if (new_element1 >= EL_STEEL_CHAR_START &&
10468 new_element1 <= EL_STEEL_CHAR_END)
10469 letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
10471 delete_buffer[sx - start_sx] = Feld[lx][ly];
10472 Feld[lx][ly] = letter_element;
10474 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
10475 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
10476 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
10477 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
10479 DrawLevelText(0, 0, 0, TEXT_END);
10481 level.changed = TRUE;
10485 case TEXT_BACKSPACE:
10488 Feld[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
10489 DrawEditorElement(sx - 1, sy, Feld[lx - 1][ly]);
10490 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
10495 if (sy + 1 < ed_fieldy - 1 && ly + 1 < lev_fieldy - 1)
10496 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
10498 DrawLevelText(0, 0, 0, TEXT_END);
10502 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10503 DrawEditorElement(sx, sy, Feld[lx][ly]);
10507 case TEXT_QUERY_TYPING:
10517 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
10518 int element, boolean change_level)
10520 int lx = sx + level_xpos;
10521 int ly = sy + level_ypos;
10524 DrawEditorElement(sx, sy, Feld[lx][ly]);
10526 DrawAreaBorder(sx, sy, sx, sy);
10529 static void CheckLevelBorderElement(boolean redraw_playfield)
10531 int last_border_element = BorderElement;
10533 SetBorderElement();
10535 if (redraw_playfield && BorderElement != last_border_element)
10536 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10539 static void CopyLevelToUndoBuffer(int mode)
10541 static boolean accumulated_undo = FALSE;
10542 boolean new_undo_buffer_position = TRUE;
10545 if (undo_buffer_steps == 0)
10546 accumulated_undo = FALSE;
10550 case UNDO_IMMEDIATE:
10551 accumulated_undo = FALSE;
10554 case UNDO_ACCUMULATE:
10555 if (accumulated_undo)
10556 new_undo_buffer_position = FALSE;
10557 accumulated_undo = TRUE;
10564 if (new_undo_buffer_position)
10566 /* advance position in undo buffer ring */
10567 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
10569 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
10570 undo_buffer_steps++;
10573 /* always reset redo buffer when storing level change into undo buffer */
10574 redo_buffer_steps = 0;
10576 for (x = 0; x < lev_fieldx; x++)
10577 for (y = 0; y < lev_fieldy; y++)
10578 UndoBuffer[undo_buffer_position][x][y] = Feld[x][y];
10580 /* check if drawing operation forces change of border style */
10581 CheckLevelBorderElement(TRUE);
10583 level.changed = TRUE;
10586 static void RandomPlacement(int new_element)
10588 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
10589 int num_free_positions = 0;
10590 int num_percentage, num_elements;
10593 ResetIntelliDraw();
10595 /* determine number of free positions for randomly placing the new element */
10596 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
10598 free_position[x][y] =
10599 (random_placement_background_restricted ?
10600 Feld[x][y] == random_placement_background_element :
10601 Feld[x][y] != new_element);
10603 if (free_position[x][y])
10604 num_free_positions++;
10607 /* determine number of new elements to place there */
10608 num_percentage = num_free_positions * random_placement_value / 100;
10609 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
10610 num_percentage : random_placement_value);
10612 /* if less free positions than elements to place, fill all these positions */
10613 if (num_free_positions < num_elements)
10615 for (x = 0; x < lev_fieldx; x++)
10616 for (y = 0; y < lev_fieldy; y++)
10617 if (free_position[x][y])
10618 SetElement(x, y, new_element);
10622 while (num_elements > 0)
10624 x = GetSimpleRandom(lev_fieldx);
10625 y = GetSimpleRandom(lev_fieldy);
10627 /* don't place element at the same position twice */
10628 if (free_position[x][y])
10630 free_position[x][y] = FALSE;
10631 SetElement(x, y, new_element);
10637 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10638 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10641 void WrapLevel(int dx, int dy)
10643 int wrap_dx = lev_fieldx - dx;
10644 int wrap_dy = lev_fieldy - dy;
10647 for (x = 0; x < lev_fieldx; x++)
10648 for (y = 0; y < lev_fieldy; y++)
10649 FieldBackup[x][y] = Feld[x][y];
10651 for (x = 0; x < lev_fieldx; x++)
10652 for (y = 0; y < lev_fieldy; y++)
10654 FieldBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
10656 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10657 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
10660 static void HandleDrawingAreas(struct GadgetInfo *gi)
10662 static boolean started_inside_drawing_area = FALSE;
10663 int id = gi->custom_id;
10664 boolean button_press_event;
10665 boolean button_release_event;
10666 boolean inside_drawing_area = !gi->event.off_borders;
10667 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
10668 int actual_drawing_function;
10669 int button = gi->event.button;
10670 int new_element = BUTTON_ELEMENT(button);
10671 int sx = gi->event.x, sy = gi->event.y;
10672 int min_sx = 0, min_sy = 0;
10673 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
10674 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
10675 int lx = 0, ly = 0;
10676 int min_lx = 0, min_ly = 0;
10677 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
10680 /* handle info callback for each invocation of action callback */
10681 gi->callback_info(gi);
10683 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
10684 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
10686 /* make sure to stay inside drawing area boundaries */
10687 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
10688 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
10692 /* get positions inside level field */
10693 lx = sx + level_xpos;
10694 ly = sy + level_ypos;
10696 if (!IN_LEV_FIELD(lx, ly))
10697 inside_drawing_area = FALSE;
10699 /* make sure to stay inside level field boundaries */
10700 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
10701 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
10703 /* correct drawing area positions accordingly */
10704 sx = lx - level_xpos;
10705 sy = ly - level_ypos;
10708 if (button_press_event)
10709 started_inside_drawing_area = inside_drawing_area;
10711 if (!started_inside_drawing_area)
10714 if (!IS_VALID_BUTTON(button))
10717 if (!button && !button_release_event)
10720 /* automatically switch to 'single item' drawing mode, if needed */
10721 actual_drawing_function =
10722 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
10723 drawing_function : GADGET_ID_SINGLE_ITEMS);
10725 /* clicking into drawing area with pressed Control key picks element */
10726 if (GetKeyModState() & KMOD_Control)
10728 last_drawing_function = drawing_function;
10729 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
10732 if (GetKeyModState() & KMOD_Shift)
10734 if (button_press_event || button_release_event)
10735 ResetIntelliDraw();
10738 switch (actual_drawing_function)
10740 case GADGET_ID_SINGLE_ITEMS:
10743 if (button_release_event)
10745 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10747 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
10748 !inside_drawing_area)
10749 DeleteBrushFromCursor();
10752 if (!button || button_release_event)
10755 if (draw_with_brush)
10757 CopyBrushToLevel(sx, sy, button);
10761 if (new_element == EL_PLAYER_1)
10763 /* remove player at old position */
10764 for (y = 0; y < lev_fieldy; y++)
10765 for (x = 0; x < lev_fieldx; x++)
10766 if (Feld[x][y] == EL_PLAYER_1)
10767 SetElement(x, y, EL_EMPTY);
10770 SetElementButton(lx, ly, new_element, button);
10775 int type_id = gi->custom_type_id;
10776 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
10778 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
10779 DrawMiniGraphicExt(drawto,
10780 gi->x + sx * MINI_TILEX,
10781 gi->y + sy * MINI_TILEY,
10782 el2edimg(new_element));
10784 DrawFixedGraphicExt(drawto,
10785 gi->x + sx * TILEX,
10786 gi->y + sy * TILEY,
10787 el2img(new_element), 0);
10789 if (id == GADGET_ID_CUSTOM_GRAPHIC)
10790 new_element = GFX_ELEMENT(new_element);
10792 drawingarea_info[type_id].value[pos] = new_element;
10794 CopyElementPropertiesToGame(properties_element);
10796 if (id == GADGET_ID_CUSTOM_GRAPHIC)
10798 UpdateCustomElementGraphicGadgets();
10800 FrameCounter = 0; /* restart animation frame counter */
10805 case GADGET_ID_CONNECTED_ITEMS:
10807 static int last_sx = -1;
10808 static int last_sy = -1;
10810 if (button_release_event)
10811 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10815 if (!button_press_event)
10816 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
10824 case GADGET_ID_LINE:
10825 case GADGET_ID_ARC:
10826 case GADGET_ID_RECTANGLE:
10827 case GADGET_ID_FILLED_BOX:
10828 case GADGET_ID_GRAB_BRUSH:
10829 case GADGET_ID_TEXT:
10831 static int last_sx = -1;
10832 static int last_sy = -1;
10833 static int start_sx = -1;
10834 static int start_sy = -1;
10835 void (*draw_func)(int, int, int, int, int, boolean);
10837 if (drawing_function == GADGET_ID_LINE)
10838 draw_func = DrawLine;
10839 else if (drawing_function == GADGET_ID_ARC)
10840 draw_func = DrawArc;
10841 else if (drawing_function == GADGET_ID_RECTANGLE)
10842 draw_func = DrawBox;
10843 else if (drawing_function == GADGET_ID_FILLED_BOX)
10844 draw_func = DrawFilledBox;
10845 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
10846 draw_func = SelectArea;
10847 else /* (drawing_function == GADGET_ID_TEXT) */
10848 draw_func = SetTextCursor;
10850 if (button_press_event)
10852 draw_func(sx, sy, sx, sy, new_element, FALSE);
10853 start_sx = last_sx = sx;
10854 start_sy = last_sy = sy;
10856 if (drawing_function == GADGET_ID_TEXT)
10857 DrawLevelText(0, 0, 0, TEXT_END);
10859 else if (button_release_event)
10861 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
10862 if (drawing_function == GADGET_ID_GRAB_BRUSH)
10864 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
10865 CopyBrushToCursor(sx, sy);
10866 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
10868 draw_with_brush = TRUE;
10870 else if (drawing_function == GADGET_ID_TEXT)
10871 DrawLevelText(sx, sy, 0, TEXT_INIT);
10873 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10875 else if (last_sx != sx || last_sy != sy)
10877 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
10878 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
10885 case GADGET_ID_FLOOD_FILL:
10886 if (button_press_event && Feld[lx][ly] != new_element)
10888 FloodFill(lx, ly, new_element);
10889 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
10890 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10894 case GADGET_ID_PICK_ELEMENT:
10895 if (button_release_event)
10896 ClickOnGadget(level_editor_gadget[last_drawing_function],
10898 else if (draw_level)
10899 PickDrawingElement(button, Feld[lx][ly]);
10902 int type_id = gi->custom_type_id;
10903 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
10905 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
10915 static void HandleCounterButtons(struct GadgetInfo *gi)
10917 int gadget_id = gi->custom_id;
10918 int counter_id = gi->custom_type_id;
10919 int button = gi->event.button;
10920 int *counter_value = counterbutton_info[counter_id].value;
10921 int step = BUTTON_STEPSIZE(button) *
10922 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
10924 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
10926 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
10927 boolean released = (gi->event.type == GD_EVENT_RELEASED);
10928 boolean level_changed = LevelChanged();
10930 if ((level_changed && pressed) || (!level_changed && released))
10933 if (level_changed && !Request("Level has changed! Discard changes?",
10936 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
10937 ModifyEditorCounterValue(counter_id, *counter_value);
10943 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
10944 *counter_value = gi->textinput.number_value;
10946 ModifyEditorCounterValue(counter_id, *counter_value + step);
10948 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
10950 LoadLevel(level_nr);
10951 LoadScore(level_nr);
10956 DrawEditModeWindow();
10961 switch (counter_id)
10963 case ED_COUNTER_ID_YAMYAM_CONTENT:
10964 DrawYamYamContentAreas();
10967 case ED_COUNTER_ID_BALL_CONTENT:
10968 DrawMagicBallContentAreas();
10971 case ED_COUNTER_ID_ANDROID_CONTENT:
10972 DrawAndroidElementArea(properties_element);
10975 case ED_COUNTER_ID_GROUP_CONTENT:
10976 DrawGroupElementArea(properties_element);
10977 CopyGroupElementPropertiesToGame(properties_element);
10980 case ED_COUNTER_ID_INVENTORY_SIZE:
10981 DrawPlayerInitialInventoryArea(properties_element);
10984 case ED_COUNTER_ID_ENVELOPE_XSIZE:
10985 case ED_COUNTER_ID_ENVELOPE_YSIZE:
10986 DrawEnvelopeTextArea(-1);
10989 case ED_COUNTER_ID_LEVEL_XSIZE:
10990 case ED_COUNTER_ID_LEVEL_YSIZE:
10991 lev_fieldx = level.fieldx;
10992 lev_fieldy = level.fieldy;
10994 /* check if resizing of level results in change of border border */
10995 SetBorderElement();
11003 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
11004 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
11005 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
11006 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
11007 CopyElementPropertiesToGame(properties_element);
11009 level.changed = TRUE;
11012 static void HandleTextInputGadgets(struct GadgetInfo *gi)
11014 int type_id = gi->custom_type_id;
11016 strcpy(textinput_info[type_id].value, gi->textinput.value);
11018 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
11020 CopyElementPropertiesToGame(properties_element);
11022 ModifyEditorElementList(); /* update changed button info text */
11025 level.changed = TRUE;
11028 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
11030 int type_id = gi->custom_type_id;
11032 strncpy(textarea_info[type_id].value, gi->textarea.value,
11033 MAX_ENVELOPE_TEXT_LEN);
11034 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
11036 level.changed = TRUE;
11039 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
11041 int type_id = gi->custom_type_id;
11042 int value_old = *selectbox_info[type_id].value;
11043 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
11045 *selectbox_info[type_id].value = value_new;
11047 if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
11049 element_info[properties_element].current_change_page = gi->selectbox.index;
11051 DrawPropertiesWindow();
11053 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
11054 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
11055 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
11056 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
11057 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
11059 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
11061 /* when changing action type, also check action mode and action arg */
11062 if (value_old != value_new)
11063 setSelectboxSpecialActionVariablesIfNeeded();
11065 DrawPropertiesChange();
11068 CopyElementPropertiesToGame(properties_element);
11070 level.changed = TRUE;
11074 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
11076 int type_id = gi->custom_type_id;
11079 if (type_id >= ED_TEXTBUTTON_ID_LEVELINFO_FIRST &&
11080 type_id <= ED_TEXTBUTTON_ID_LEVELINFO_LAST)
11082 edit_mode_levelinfo = gi->custom_type_id;
11084 DrawLevelInfoWindow();
11086 else if (type_id >= ED_TEXTBUTTON_ID_PROPERTIES_FIRST &&
11087 type_id <= ED_TEXTBUTTON_ID_PROPERTIES_LAST)
11089 edit_mode_properties = gi->custom_type_id;
11091 DrawPropertiesWindow();
11093 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE)
11095 char *template_filename = getDefaultLevelFilename(-1);
11096 boolean new_template = !fileExists(template_filename);
11098 /* backup original "level.field" (needed to track playfield changes) */
11099 CopyPlayfield(level.field, FieldBackup);
11101 /* "SaveLevelTemplate()" uses "level.field", so copy editor playfield */
11102 CopyPlayfield(Feld, level.field);
11104 if (new_template ||
11105 Request("Save this template and kill the old?", REQ_ASK))
11106 SaveLevelTemplate();
11109 Request("Template saved!", REQ_CONFIRM);
11111 /* restore original "level.field" (needed to track playfield changes) */
11112 CopyPlayfield(FieldBackup, level.field);
11114 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
11115 custom_element.num_change_pages < MAX_CHANGE_PAGES)
11117 struct ElementInfo *ei = &element_info[properties_element];
11119 setElementChangePages(ei, ei->num_change_pages + 1);
11121 /* set new change page to be new current change page */
11122 ei->current_change_page = ei->num_change_pages - 1;
11123 ei->change = &ei->change_page[ei->current_change_page];
11125 setElementChangeInfoToDefaults(ei->change);
11127 DrawPropertiesWindow();
11129 level.changed = TRUE;
11131 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
11132 custom_element.num_change_pages > MIN_CHANGE_PAGES)
11134 struct ElementInfo *ei = &element_info[properties_element];
11136 /* copy all change pages after change page to be deleted */
11137 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
11138 ei->change_page[i] = ei->change_page[i + 1];
11140 setElementChangePages(ei, ei->num_change_pages - 1);
11142 DrawPropertiesWindow();
11144 level.changed = TRUE;
11148 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
11150 int type_id = gi->custom_type_id;
11152 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
11153 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
11155 struct ElementInfo *ei = &element_info[properties_element];
11156 int step = BUTTON_STEPSIZE(gi->event.button);
11158 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
11159 ei->current_change_page += step;
11161 if (ei->current_change_page < 0)
11162 ei->current_change_page = 0;
11163 else if (ei->current_change_page >= ei->num_change_pages)
11164 ei->current_change_page = ei->num_change_pages - 1;
11166 DrawPropertiesWindow();
11168 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
11169 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
11171 struct ElementInfo *ei = &element_info[properties_element];
11172 int current_change_page = ei->current_change_page;
11174 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
11175 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
11176 ei->change_page[current_change_page];
11177 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
11179 ei->change_page[current_change_page] =
11180 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
11182 level.changed = TRUE;
11185 DrawPropertiesWindow();
11189 static void HandleRadiobuttons(struct GadgetInfo *gi)
11191 *radiobutton_info[gi->custom_type_id].value =
11192 radiobutton_info[gi->custom_type_id].checked_value;
11194 level.changed = TRUE;
11197 static void HandleCheckbuttons(struct GadgetInfo *gi)
11199 int type_id = gi->custom_type_id;
11201 *checkbutton_info[type_id].value ^= TRUE;
11203 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
11204 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
11205 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
11206 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
11207 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
11208 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
11209 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
11210 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE))
11212 CopyElementPropertiesToGame(properties_element);
11215 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
11217 UpdateCustomElementGraphicGadgets();
11219 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE)
11221 char *template_filename = getDefaultLevelFilename(-1);
11223 if (level.use_custom_template && !fileExists(template_filename))
11225 Request("No level template found!", REQ_CONFIRM);
11227 level.use_custom_template = FALSE;
11228 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
11233 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
11235 DrawEditModeWindow();
11238 level.changed = TRUE;
11241 static void HandleControlButtons(struct GadgetInfo *gi)
11243 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
11244 static int last_edit_mode = ED_MODE_DRAWING;
11245 static int last_custom_copy_mode = -1;
11246 int id = gi->custom_id;
11247 int button = gi->event.button;
11248 int step = BUTTON_STEPSIZE(button);
11249 int new_element = BUTTON_ELEMENT(button);
11252 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
11253 DrawLevelText(0, 0, 0, TEXT_END);
11255 if (id < ED_NUM_CTRL1_BUTTONS &&
11256 id != GADGET_ID_SINGLE_ITEMS &&
11257 id != GADGET_ID_PICK_ELEMENT &&
11258 edit_mode != ED_MODE_DRAWING &&
11259 drawing_function != GADGET_ID_PICK_ELEMENT &&
11260 !(GetKeyModState() & KMOD_Control))
11262 DrawDrawingWindow();
11263 edit_mode = ED_MODE_DRAWING;
11266 /* element copy mode active, but no element button pressed => deactivate */
11267 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
11268 last_custom_copy_mode = -1;
11272 case GADGET_ID_SCROLL_LEFT:
11273 if (level_xpos >= 0)
11275 if (lev_fieldx < ed_fieldx - 2)
11278 level_xpos -= step;
11279 if (level_xpos < -1)
11282 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
11284 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11286 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
11287 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
11291 case GADGET_ID_SCROLL_RIGHT:
11292 if (level_xpos <= lev_fieldx - ed_fieldx)
11294 if (lev_fieldx < ed_fieldx - 2)
11297 level_xpos += step;
11298 if (level_xpos > lev_fieldx - ed_fieldx + 1)
11299 level_xpos = lev_fieldx - ed_fieldx + 1;
11301 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
11303 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11305 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
11306 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
11310 case GADGET_ID_SCROLL_UP:
11311 if (level_ypos >= 0)
11313 if (lev_fieldy < ed_fieldy - 2)
11316 level_ypos -= step;
11317 if (level_ypos < -1)
11320 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
11322 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11324 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
11325 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
11329 case GADGET_ID_SCROLL_DOWN:
11330 if (level_ypos <= lev_fieldy - ed_fieldy)
11332 if (lev_fieldy < ed_fieldy - 2)
11335 level_ypos += step;
11336 if (level_ypos > lev_fieldy - ed_fieldy + 1)
11337 level_ypos = lev_fieldy - ed_fieldy + 1;
11339 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
11341 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11343 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
11344 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
11348 case GADGET_ID_SCROLL_HORIZONTAL:
11349 level_xpos = gi->event.item_position - 1;
11350 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11353 case GADGET_ID_SCROLL_VERTICAL:
11354 level_ypos = gi->event.item_position - 1;
11355 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11358 case GADGET_ID_SCROLL_LIST_UP:
11359 case GADGET_ID_SCROLL_LIST_DOWN:
11360 case GADGET_ID_SCROLL_LIST_VERTICAL:
11361 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
11362 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
11365 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
11366 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
11368 if (element_shift < 0)
11370 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
11371 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
11373 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
11374 GDI_SCROLLBAR_ITEM_POSITION,
11375 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
11378 ModifyEditorElementList();
11382 case GADGET_ID_PROPERTIES:
11383 if (edit_mode != ED_MODE_PROPERTIES)
11385 properties_element = new_element;
11386 DrawPropertiesWindow();
11387 edit_mode = ED_MODE_PROPERTIES;
11389 last_level_drawing_function = drawing_function;
11390 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
11395 DrawDrawingWindow();
11396 edit_mode = ED_MODE_DRAWING;
11398 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
11403 case GADGET_ID_WRAP_LEFT:
11404 WrapLevel(-step, 0);
11407 case GADGET_ID_WRAP_RIGHT:
11408 WrapLevel(step, 0);
11411 case GADGET_ID_WRAP_UP:
11412 WrapLevel(0, -step);
11415 case GADGET_ID_WRAP_DOWN:
11416 WrapLevel(0, step);
11419 case GADGET_ID_SINGLE_ITEMS:
11420 case GADGET_ID_CONNECTED_ITEMS:
11421 case GADGET_ID_LINE:
11422 case GADGET_ID_ARC:
11423 case GADGET_ID_TEXT:
11424 case GADGET_ID_RECTANGLE:
11425 case GADGET_ID_FILLED_BOX:
11426 case GADGET_ID_FLOOD_FILL:
11427 case GADGET_ID_GRAB_BRUSH:
11428 case GADGET_ID_PICK_ELEMENT:
11429 if (drawing_function != GADGET_ID_PICK_ELEMENT)
11430 last_drawing_function = drawing_function;
11431 drawing_function = id;
11432 draw_with_brush = FALSE;
11435 case GADGET_ID_RANDOM_PLACEMENT:
11436 RandomPlacement(new_element);
11439 case GADGET_ID_ZOOM:
11440 // zoom level editor tile size in or out (or reset to default size)
11441 ed_tilesize = (button == 1 ? ed_tilesize / 2 :
11442 button == 2 ? DEFAULT_EDITOR_TILESIZE :
11443 button == 3 ? ed_tilesize * 2 : ed_tilesize);
11445 // limit zoom level by upper and lower bound
11446 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
11448 InitZoomLevelSettings();
11450 if (edit_mode == ED_MODE_DRAWING)
11451 DrawDrawingWindow();
11455 case GADGET_ID_CUSTOM_COPY_FROM:
11456 case GADGET_ID_CUSTOM_COPY_TO:
11457 case GADGET_ID_CUSTOM_EXCHANGE:
11458 last_custom_copy_mode = id;
11459 last_drawing_function = drawing_function;
11462 case GADGET_ID_CUSTOM_COPY:
11463 CopyCustomElement(properties_element, -1, id);
11466 case GADGET_ID_CUSTOM_PASTE:
11467 CopyCustomElement(-1, properties_element, id);
11470 case GADGET_ID_UNDO:
11471 if (button == 1 && undo_buffer_steps == 0)
11473 Request("Undo buffer empty!", REQ_CONFIRM);
11477 else if (button == 2)
11481 else if (button == 3 && redo_buffer_steps == 0)
11483 Request("Redo buffer empty!", REQ_CONFIRM);
11488 if (edit_mode != ED_MODE_DRAWING)
11490 DrawDrawingWindow();
11491 edit_mode = ED_MODE_DRAWING;
11498 undo_buffer_position =
11499 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
11501 undo_buffer_steps--;
11502 redo_buffer_steps++;
11508 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
11510 undo_buffer_steps++;
11511 redo_buffer_steps--;
11514 for (x = 0; x < lev_fieldx; x++)
11515 for (y = 0; y < lev_fieldy; y++)
11516 Feld[x][y] = UndoBuffer[undo_buffer_position][x][y];
11518 /* check if undo operation forces change of border style */
11519 CheckLevelBorderElement(FALSE);
11521 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11525 case GADGET_ID_INFO:
11526 if (edit_mode != ED_MODE_INFO)
11528 last_edit_mode = edit_mode;
11529 edit_mode = ED_MODE_INFO;
11531 DrawLevelInfoWindow();
11535 edit_mode = last_edit_mode;
11537 DrawEditModeWindow();
11541 case GADGET_ID_CLEAR:
11542 if (edit_mode != ED_MODE_DRAWING)
11544 DrawDrawingWindow();
11545 edit_mode = ED_MODE_DRAWING;
11548 for (x = 0; x < MAX_LEV_FIELDX; x++)
11549 for (y = 0; y < MAX_LEV_FIELDY; y++)
11550 Feld[x][y] = (button == 1 ? EL_EMPTY : new_element);
11552 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
11554 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11557 case GADGET_ID_SAVE:
11559 /* saving read-only levels into personal level set modifies global vars
11560 "leveldir_current" and "level_nr"; restore them after saving level */
11561 LevelDirTree *leveldir_former = leveldir_current;
11562 int level_nr_former = level_nr;
11563 char *level_filename;
11566 if (leveldir_current->readonly &&
11567 !PrepareSavingIntoPersonalLevelSet())
11570 level_filename = getDefaultLevelFilename(level_nr);
11571 new_level = !fileExists(level_filename);
11574 Request("Save this level and kill the old?", REQ_ASK))
11576 if (leveldir_former->readonly)
11577 ModifyLevelInfoForSavingIntoPersonalLevelSet(leveldir_former->name);
11579 CopyPlayfield(Feld, level.field);
11580 SaveLevel(level_nr);
11582 level.changed = FALSE;
11586 char level_saved_msg[64];
11588 if (leveldir_former->readonly)
11589 sprintf(level_saved_msg,
11590 "Level saved as level %d into personal level set!",
11593 strcpy(level_saved_msg, "Level saved!");
11595 Request(level_saved_msg, REQ_CONFIRM);
11599 /* "cd" back to copied-from levelset (in case of saved read-only level) */
11600 leveldir_current = leveldir_former;
11601 level_nr = level_nr_former;
11606 case GADGET_ID_TEST:
11607 if (LevelChanged())
11608 level.game_version = GAME_VERSION_ACTUAL;
11610 CopyPlayfield(level.field, FieldBackup);
11611 CopyPlayfield(Feld, level.field);
11613 CopyNativeLevel_RND_to_Native(&level);
11615 UnmapLevelEditorGadgets();
11616 UndrawSpecialEditorDoor();
11618 CloseDoor(DOOR_CLOSE_ALL);
11620 /* needed before playing if editor playfield area has different size */
11621 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
11623 // redraw_mask = REDRAW_ALL;
11625 level_editor_test_game = TRUE;
11627 StartGameActions(FALSE, setup.autorecord, level.random_seed);
11631 case GADGET_ID_EXIT:
11632 RequestExitLevelEditor(TRUE, FALSE); /* if level has changed, ask user */
11636 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
11637 id <= GADGET_ID_ELEMENTLIST_LAST)
11639 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
11640 int new_element = editor_elements[element_position + element_shift];
11642 if (IS_EDITOR_CASCADE(new_element))
11646 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
11648 int *cascade_element= &(*editor_elements_info[i].headline_list)[0];
11649 boolean *cascade_value=editor_elements_info[i].setup_cascade_value;
11651 if (*cascade_element == new_element)
11653 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
11654 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
11656 /* update element selection list */
11657 ReinitializeElementList();
11658 ModifyEditorElementList();
11660 /* update cascading gadget info text */
11661 PrintEditorGadgetInfoText(level_editor_gadget[id]);
11663 /* save current editor cascading state */
11664 SaveSetup_EditorCascade();
11673 if (last_custom_copy_mode != -1)
11675 if (CopyCustomElement(properties_element, new_element,
11676 last_custom_copy_mode))
11678 ClickOnGadget(level_editor_gadget[last_drawing_function],
11681 last_custom_copy_mode = -1;
11687 PickDrawingElement(button, new_element);
11689 if (!stick_element_properties_window &&
11690 drawing_function != GADGET_ID_PICK_ELEMENT &&
11691 !(GetKeyModState() & KMOD_Control))
11693 properties_element = new_element;
11694 if (edit_mode == ED_MODE_PROPERTIES)
11695 DrawPropertiesWindow();
11698 if (drawing_function == GADGET_ID_PICK_ELEMENT)
11699 ClickOnGadget(level_editor_gadget[last_drawing_function],
11703 else if (gi->event.type == GD_EVENT_PRESSED)
11704 printf("default: HandleControlButtons: GD_EVENT_PRESSED(%d)\n", id);
11705 else if (gi->event.type == GD_EVENT_RELEASED)
11706 printf("default: HandleControlButtons: GD_EVENT_RELEASED(%d)\n", id);
11707 else if (gi->event.type == GD_EVENT_MOVING)
11708 printf("default: HandleControlButtons: GD_EVENT_MOVING(%d)\n", id);
11710 printf("default: HandleControlButtons: ? (id == %d)\n", id);
11716 void HandleLevelEditorKeyInput(Key key)
11718 char letter = getCharFromKey(key);
11719 int button = MB_LEFTBUTTON;
11721 if (drawing_function == GADGET_ID_TEXT &&
11722 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
11725 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
11726 else if (key == KSYM_Delete || key == KSYM_BackSpace)
11727 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
11728 else if (key == KSYM_Return)
11729 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
11730 else if (key == KSYM_Escape)
11731 DrawLevelText(0, 0, 0, TEXT_END);
11733 else if (button_status == MB_RELEASED)
11735 int id = GADGET_ID_NONE;
11736 int new_element_shift = element_shift;
11742 id = GADGET_ID_SCROLL_LEFT;
11745 id = GADGET_ID_SCROLL_RIGHT;
11748 id = GADGET_ID_SCROLL_UP;
11751 id = GADGET_ID_SCROLL_DOWN;
11754 id = GADGET_ID_SCROLL_LIST_UP;
11755 button = ED_ELEMENTLIST_BUTTONS_VERT - 1;
11757 case KSYM_Page_Down:
11758 id = GADGET_ID_SCROLL_LIST_DOWN;
11759 button = ED_ELEMENTLIST_BUTTONS_VERT - 1;
11764 element_shift = (key == KSYM_Home ? 0 :
11765 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
11767 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
11768 GDI_SCROLLBAR_ITEM_POSITION,
11769 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
11771 ModifyEditorElementList();
11778 /* this is needed to prevent interference with running "True X-Mouse" */
11779 if (GetKeyModStateFromEvents() & KMOD_Control)
11782 /* check for last or next editor cascade block in element list */
11783 for (i = 0; i < num_editor_elements; i++)
11785 if ((key == KSYM_Insert && i == element_shift) ||
11786 (key == KSYM_Delete && new_element_shift > element_shift))
11789 /* jump to next cascade block (or to start of element list) */
11790 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
11791 new_element_shift = i;
11794 if (i < num_editor_elements)
11795 element_shift = new_element_shift;
11797 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
11798 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
11800 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
11801 GDI_SCROLLBAR_ITEM_POSITION,
11802 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
11804 ModifyEditorElementList();
11809 if (edit_mode == ED_MODE_DRAWING)
11811 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
11813 else if (edit_mode == ED_MODE_INFO)
11815 HandleControlButtons(level_editor_gadget[GADGET_ID_INFO]);
11817 else if (edit_mode == ED_MODE_PROPERTIES)
11819 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
11821 else /* should never happen */
11823 DrawDrawingWindow();
11824 edit_mode = ED_MODE_DRAWING;
11833 if (id != GADGET_ID_NONE)
11834 ClickOnGadget(level_editor_gadget[id], button);
11835 else if (letter >= '1' && letter <= '3')
11836 ClickOnGadget(level_editor_gadget[GADGET_ID_PROPERTIES], letter - '0');
11837 else if (letter == '?')
11838 ClickOnGadget(level_editor_gadget[GADGET_ID_PROPERTIES], button);
11839 else if (letter == '.')
11840 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
11841 else if (letter == 'U')
11842 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
11843 else if (key == KSYM_KP_Subtract)
11844 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
11845 else if (key == KSYM_KP_0 || letter == '0')
11846 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
11847 else if (key == KSYM_KP_Add || letter == '+')
11848 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
11849 else if (key == KSYM_Return ||
11850 key == KSYM_space ||
11851 key == setup.shortcut.toggle_pause)
11852 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
11854 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
11855 if (letter && letter == controlbutton_info[i].shortcut)
11856 if (!anyTextGadgetActive())
11857 ClickOnGadget(level_editor_gadget[i], button);
11861 void HandleLevelEditorIdle()
11863 static unsigned int action_delay = 0;
11864 unsigned int action_delay_value = GameFrameDelay;
11865 int xpos = 1, ypos = 2;
11868 if (edit_mode != ED_MODE_PROPERTIES)
11871 if (!DelayReached(&action_delay, action_delay_value))
11874 for (i = 0; i < ED_NUM_SELECTBOX; i++)
11876 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
11878 if (gi->mapped && gi->active && gi->selectbox.open)
11882 DrawEditorElementAnimation(SX + xpos * TILEX,
11883 SY + ypos * TILEY + MINI_TILEY / 2);
11885 MarkTileDirty(xpos, ypos);
11886 MarkTileDirty(xpos, ypos + 1);
11888 FrameCounter++; /* increase animation frame counter */
11891 void ClearEditorGadgetInfoText()
11893 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
11896 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
11898 char infotext[MAX_OUTPUT_LINESIZE + 1];
11899 char shortcut[MAX_OUTPUT_LINESIZE + 1];
11900 int max_infotext_len = getMaxInfoTextLength();
11902 if (gi == NULL || gi->info_text == NULL)
11905 strncpy(infotext, gi->info_text, max_infotext_len);
11906 infotext[max_infotext_len] = '\0';
11908 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
11910 int key = controlbutton_info[gi->custom_id].shortcut;
11914 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
11915 sprintf(shortcut, " ('.' or '%c')", key);
11916 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
11917 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
11918 else if (gi->custom_id == GADGET_ID_TEST)
11919 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
11920 else if (gi->custom_id == GADGET_ID_UNDO)
11921 sprintf(shortcut, " ('%c/Shift-U')", key);
11922 else if (gi->custom_id == GADGET_ID_ZOOM)
11923 sprintf(shortcut, " ('%c', '0', '+')", key);
11925 sprintf(shortcut, " ('%s%c')",
11926 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
11928 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
11929 strcat(infotext, shortcut);
11933 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, FONT_TEXT_2);
11936 void HandleEditorGadgetInfoText(void *ptr)
11938 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
11940 if (game_status != GAME_MODE_EDITOR)
11943 ClearEditorGadgetInfoText();
11945 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
11948 /* misuse this function to delete brush cursor, if needed */
11949 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
11950 DeleteBrushFromCursor();
11952 PrintEditorGadgetInfoText(gi);
11955 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
11957 static int start_lx, start_ly;
11958 int id = gi->custom_id;
11959 int type_id = gi->custom_type_id;
11960 int sx = gi->event.x;
11961 int sy = gi->event.y;
11962 int lx = sx + level_xpos;
11963 int ly = sy + level_ypos;
11964 int min_sx = 0, min_sy = 0;
11965 int max_sx = gi->drawing.area_xsize - 1;
11966 int max_sy = gi->drawing.area_ysize - 1;
11967 int actual_drawing_function = drawing_function;
11968 int max_infotext_len = getMaxInfoTextLength();
11969 char infotext[MAX_OUTPUT_LINESIZE + 1];
11972 infotext[0] = '\0'; /* start with empty info text */
11974 /* pressed Control key: simulate picking element */
11975 if (GetKeyModState() & KMOD_Control)
11976 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
11978 ClearEditorGadgetInfoText();
11980 if (gi->event.type == GD_EVENT_INFO_LEAVING)
11983 /* make sure to stay inside drawing area boundaries */
11984 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
11985 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
11987 if (id == GADGET_ID_DRAWING_LEVEL)
11991 int min_lx = 0, min_ly = 0;
11992 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
11994 /* get positions inside level field */
11995 lx = sx + level_xpos;
11996 ly = sy + level_ypos;
11998 /* make sure to stay inside level field boundaries */
11999 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
12000 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
12002 /* correct drawing area positions accordingly */
12003 sx = lx - level_xpos;
12004 sy = ly - level_ypos;
12007 if (IN_ED_FIELD(sx,sy) && IN_LEV_FIELD(lx, ly))
12009 if (button_status) /* if (gi->state == GD_BUTTON_PRESSED) */
12011 if (gi->event.type == GD_EVENT_PRESSED)
12017 switch (actual_drawing_function)
12019 case GADGET_ID_SINGLE_ITEMS:
12020 text = "Drawing single items";
12022 case GADGET_ID_CONNECTED_ITEMS:
12023 text = "Drawing connected items";
12025 case GADGET_ID_LINE:
12026 text = "Drawing line";
12028 case GADGET_ID_ARC:
12029 text = "Drawing arc";
12031 case GADGET_ID_TEXT:
12032 text = "Setting text cursor";
12034 case GADGET_ID_RECTANGLE:
12035 text = "Drawing rectangle";
12037 case GADGET_ID_FILLED_BOX:
12038 text = "Drawing filled box";
12040 case GADGET_ID_FLOOD_FILL:
12041 text = "Flood fill";
12043 case GADGET_ID_GRAB_BRUSH:
12044 text = "Grabbing brush";
12046 case GADGET_ID_PICK_ELEMENT:
12047 text = "Picking element";
12051 text = "Drawing position";
12055 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
12056 sprintf(infotext, "%s: %d, %d", text, lx, ly);
12058 sprintf(infotext, "%s: %d, %d", text,
12059 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
12061 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
12062 strncpy(infotext, getElementInfoText(Feld[lx][ly]), max_infotext_len);
12064 sprintf(infotext, "Level position: %d, %d", lx, ly);
12067 /* misuse this function to draw brush cursor, if needed */
12068 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
12070 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12071 CopyBrushToCursor(sx, sy);
12073 DeleteBrushFromCursor();
12076 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
12078 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
12079 int element = drawingarea_info[type_id].value[pos];
12081 strncpy(infotext, getElementInfoText(element), max_infotext_len);
12085 if (id == GADGET_ID_CUSTOM_CONTENT)
12086 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
12087 else if (id == GADGET_ID_GROUP_CONTENT)
12088 sprintf(infotext, "group element position: %d", sx + 1);
12089 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
12090 id <= GADGET_ID_YAMYAM_CONTENT_7)
12091 sprintf(infotext, "content area %d position: %d, %d",
12092 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
12093 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
12094 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
12095 sprintf(infotext, "content area %d position: %d, %d",
12096 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
12097 else if (id == GADGET_ID_ANDROID_CONTENT)
12098 sprintf(infotext, "android element position: %d", sx + 1);
12099 else if (drawingarea_info[type_id].infotext != NULL)
12100 strcpy(infotext, drawingarea_info[type_id].infotext);
12103 infotext[max_infotext_len] = '\0';
12105 if (strlen(infotext) > 0)
12106 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, infotext);
12109 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
12110 boolean quick_quit)
12112 if (!ask_if_level_has_changed ||
12114 Request("Level has changed! Exit without saving?",
12115 REQ_ASK | REQ_STAY_OPEN))
12117 SetDoorState(DOOR_CLOSE_2);
12120 FadeSkipNextFadeIn();
12122 game_status = GAME_MODE_MAIN;
12124 DrawAndFadeInMainMenu(playfield_area_changed ? REDRAW_ALL : REDRAW_FIELD);
12128 if (!global.use_envelope_request)
12130 CloseDoor(DOOR_CLOSE_1);
12131 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);