8175781421f3343dedb2b4023e599eb7ef5f943f
[rocksndiamonds.git] / src / editor.c
1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
5 //                  Holger Schemel
6 //                  info@artsoft.org
7 //                  http://www.artsoft.org/
8 // ----------------------------------------------------------------------------
9 // editor.c
10 // ============================================================================
11
12 #include <math.h>
13
14 #include "libgame/libgame.h"
15
16 #include "editor.h"
17 #include "screens.h"
18 #include "tools.h"
19 #include "files.h"
20 #include "game.h"
21 #include "init.h"
22 #include "tape.h"
23
24
25 #define INFOTEXT_UNKNOWN_ELEMENT        "unknown"
26
27
28 // ----------------------------------------------------------------------------
29 // screen and artwork graphic pixel position definitions
30 // ----------------------------------------------------------------------------
31
32 // values for the control window
33 #define ED_CTRL1_BUTTONS_HORIZ          4       // toolbox
34 #define ED_CTRL1_BUTTONS_VERT           4
35 #define ED_CTRL2_BUTTONS_HORIZ          3       // level
36 #define ED_CTRL2_BUTTONS_VERT           2
37 #define ED_CTRL3_BUTTONS_HORIZ          3       // CE and GE
38 #define ED_CTRL3_BUTTONS_VERT           1
39 #define ED_CTRL4_BUTTONS_HORIZ          2       // CE and GE
40 #define ED_CTRL4_BUTTONS_VERT           1
41 #define ED_CTRL5_BUTTONS_HORIZ          1       // properties
42 #define ED_CTRL5_BUTTONS_VERT           1
43 #define ED_CTRL6_BUTTONS_HORIZ          3       // properties
44 #define ED_CTRL6_BUTTONS_VERT           1
45 #define ED_CTRL7_BUTTONS_HORIZ          1       // palette
46 #define ED_CTRL7_BUTTONS_VERT           1
47
48 #define ED_NUM_CTRL1_BUTTONS   (ED_CTRL1_BUTTONS_HORIZ * ED_CTRL1_BUTTONS_VERT)
49 #define ED_NUM_CTRL2_BUTTONS   (ED_CTRL2_BUTTONS_HORIZ * ED_CTRL2_BUTTONS_VERT)
50 #define ED_NUM_CTRL3_BUTTONS   (ED_CTRL3_BUTTONS_HORIZ * ED_CTRL3_BUTTONS_VERT)
51 #define ED_NUM_CTRL4_BUTTONS   (ED_CTRL4_BUTTONS_HORIZ * ED_CTRL4_BUTTONS_VERT)
52 #define ED_NUM_CTRL5_BUTTONS   (ED_CTRL5_BUTTONS_HORIZ * ED_CTRL5_BUTTONS_VERT)
53 #define ED_NUM_CTRL6_BUTTONS   (ED_CTRL6_BUTTONS_HORIZ * ED_CTRL6_BUTTONS_VERT)
54 #define ED_NUM_CTRL7_BUTTONS   (ED_CTRL7_BUTTONS_HORIZ * ED_CTRL7_BUTTONS_VERT)
55 #define ED_NUM_CTRL1_2_BUTTONS (ED_NUM_CTRL1_BUTTONS   + ED_NUM_CTRL2_BUTTONS)
56 #define ED_NUM_CTRL1_3_BUTTONS (ED_NUM_CTRL1_2_BUTTONS + ED_NUM_CTRL3_BUTTONS)
57 #define ED_NUM_CTRL1_4_BUTTONS (ED_NUM_CTRL1_3_BUTTONS + ED_NUM_CTRL4_BUTTONS)
58 #define ED_NUM_CTRL1_5_BUTTONS (ED_NUM_CTRL1_4_BUTTONS + ED_NUM_CTRL5_BUTTONS)
59 #define ED_NUM_CTRL1_6_BUTTONS (ED_NUM_CTRL1_5_BUTTONS + ED_NUM_CTRL6_BUTTONS)
60 #define ED_NUM_CTRL1_7_BUTTONS (ED_NUM_CTRL1_6_BUTTONS + ED_NUM_CTRL7_BUTTONS)
61 #define ED_NUM_CTRL_BUTTONS    ED_NUM_CTRL1_7_BUTTONS
62
63 // values for the element list
64 #define ED_ELEMENTLIST_XPOS             (editor.palette.x)
65 #define ED_ELEMENTLIST_YPOS             (editor.palette.y)
66 #define ED_ELEMENTLIST_XSIZE            (graphic_info[IMG_EDITOR_PALETTE_BUTTON].width)
67 #define ED_ELEMENTLIST_YSIZE            (graphic_info[IMG_EDITOR_PALETTE_BUTTON].height)
68 #define ED_ELEMENTLIST_COLS             MAX(1, editor.palette.cols)
69 #define ED_ELEMENTLIST_ROWS             MAX(1, editor.palette.rows)
70 #define ED_ELEMENTLIST_BUTTONS_HORIZ    (ED_ELEMENTLIST_COLS)
71 #define ED_ELEMENTLIST_BUTTONS_VERT     (ED_ELEMENTLIST_ROWS)
72 #define ED_NUM_ELEMENTLIST_BUTTONS      (ED_ELEMENTLIST_BUTTONS_HORIZ * \
73                                          ED_ELEMENTLIST_BUTTONS_VERT)
74
75 // standard distances
76 #define ED_GADGET_NORMAL_DISTANCE       (editor.gadget.normal_spacing)
77 #define ED_GADGET_SMALL_DISTANCE        (editor.gadget.small_spacing)
78 #define ED_GADGET_TINY_DISTANCE         (editor.gadget.tiny_spacing)
79 #define ED_GADGET_LINE_DISTANCE         (editor.gadget.line_spacing)
80 #define ED_GADGET_TEXT_DISTANCE         (editor.gadget.text_spacing)
81 #define ED_TAB_BAR_HEIGHT               (editor.gadget.separator_line.height)
82 #define ED_DRAWINGAREA_TEXT_DISTANCE    (ED_GADGET_TEXT_DISTANCE +      \
83                                          ED_DRAWINGAREA_BORDER_SIZE)
84 #define ED_GADGET_SPACE_DISTANCE        (getFontWidth(FONT_TEXT_1))
85
86 // values for drawingarea gadgets
87 #define IMG_BORDER_1                    IMG_EDITOR_ELEMENT_BORDER
88 #define IMG_BORDER_2                    IMG_EDITOR_ELEMENT_BORDER_INPUT
89 #define ED_ELEMENT_BORDER               (graphic_info[IMG_BORDER_1].border_size)
90 #define ED_DRAWINGAREA_BORDER_SIZE      (graphic_info[IMG_BORDER_2].border_size)
91 #define ED_DRAWINGAREA_TILE_SIZE        (editor.drawingarea.tile_size)
92
93 // values for checkbutton gadgets
94 #define ED_CHECKBUTTON_XSIZE         (graphic_info[IMG_EDITOR_CHECKBOX].width)
95 #define ED_CHECKBUTTON_YSIZE         (graphic_info[IMG_EDITOR_CHECKBOX].height)
96
97 #define ED_TABBUTTON_XSIZE           (graphic_info[IMG_EDITOR_TABBUTTON].width)
98 #define ED_TABBUTTON_YSIZE           (graphic_info[IMG_EDITOR_TABBUTTON].height)
99
100 #define ED_SETTINGS_LEVEL_TABS_X        (editor.settings.tabs.x)
101 #define ED_SETTINGS_LEVEL_TABS_Y        (editor.settings.tabs.y)
102 #define ED_SETTINGS_ELEMENT_TABS_X      (editor.settings.tabs.x)
103 #define ED_SETTINGS_ELEMENT_TABS_Y      (editor.settings.tabs.y +       \
104                                          editor.settings.tabs.yoffset2)
105
106 #define ED_SETTINGS_TABS_XOFFSET        (editor.settings.tabs.draw_xoffset)
107 #define ED_SETTINGS_TABS_YOFFSET        (editor.settings.tabs.draw_yoffset)
108
109 #define ED_LEVEL_TABS_XSTART            (ED_SETTINGS_LEVEL_TABS_X)
110 #define ED_LEVEL_TABS_YSTART            (ED_SETTINGS_LEVEL_TABS_Y)
111 #define ED_LEVEL_SETTINGS_XSTART        (ED_SETTINGS_LEVEL_TABS_X +     \
112                                          ED_SETTINGS_TABS_XOFFSET)
113 #define ED_LEVEL_SETTINGS_YSTART        (ED_SETTINGS_LEVEL_TABS_Y +     \
114                                          ED_TABBUTTON_YSIZE +           \
115                                          ED_GADGET_TINY_DISTANCE +      \
116                                          ED_TAB_BAR_HEIGHT +            \
117                                          ED_SETTINGS_TABS_YOFFSET +     \
118                                          getFontHeight(FONT_TEXT_1) +   \
119                                          ED_GADGET_TEXT_DISTANCE)
120 #define ED_ELEMENT_TABS_XSTART          (ED_SETTINGS_ELEMENT_TABS_X)
121 #define ED_ELEMENT_TABS_YSTART          (ED_SETTINGS_ELEMENT_TABS_Y)
122 #define ED_ELEMENT_SETTINGS_XSTART      (ED_SETTINGS_ELEMENT_TABS_X +   \
123                                          ED_SETTINGS_TABS_XOFFSET)
124 #define ED_ELEMENT_SETTINGS_YSTART      (ED_SETTINGS_ELEMENT_TABS_Y +   \
125                                          ED_TABBUTTON_YSIZE +           \
126                                          ED_GADGET_TINY_DISTANCE +      \
127                                          ED_TAB_BAR_HEIGHT +            \
128                                          ED_SETTINGS_TABS_YOFFSET)
129
130 #define ED_SETTINGS_XOFFSET             (ED_CHECKBUTTON_XSIZE +         \
131                                          ED_GADGET_TEXT_DISTANCE)
132 #define ED_SETTINGS_YOFFSET             (ED_CHECKBUTTON_YSIZE +         \
133                                          ED_GADGET_LINE_DISTANCE)
134
135 #define ED_POS_RANGE                    (10000)
136 #define ED_POS_LEVEL_TABS_FIRST         (1 * ED_POS_RANGE)
137 #define ED_POS_LEVEL_TABS_LAST          (2 * ED_POS_RANGE - 1)
138 #define ED_POS_LEVEL_SETTINGS_FIRST     (2 * ED_POS_RANGE)
139 #define ED_POS_LEVEL_SETTINGS_LAST      (3 * ED_POS_RANGE - 1)
140 #define ED_POS_ELEMENT_TABS_FIRST       (3 * ED_POS_RANGE)
141 #define ED_POS_ELEMENT_TABS_LAST        (4 * ED_POS_RANGE - 1)
142 #define ED_POS_ELEMENT_SETTINGS_FIRST   (4 * ED_POS_RANGE)
143 #define ED_POS_ELEMENT_SETTINGS_LAST    (5 * ED_POS_RANGE - 1)
144
145 #define ED_LEVEL_TABS_XPOS(n)           (ED_POS_LEVEL_TABS_FIRST + (n))
146 #define ED_LEVEL_TABS_YPOS(n)           (ED_POS_LEVEL_TABS_FIRST + (n))
147
148 #define ED_LEVEL_SETTINGS_XPOS(n)       (ED_POS_LEVEL_SETTINGS_FIRST + (n))
149 #define ED_LEVEL_SETTINGS_YPOS(n)       (ED_POS_LEVEL_SETTINGS_FIRST + (n))
150
151 #define ED_ELEMENT_TABS_XPOS(n)         (ED_POS_ELEMENT_TABS_FIRST + (n))
152 #define ED_ELEMENT_TABS_YPOS(n)         (ED_POS_ELEMENT_TABS_FIRST + (n))
153
154 #define ED_ELEMENT_SETTINGS_XPOS(n)     (ED_POS_ELEMENT_SETTINGS_FIRST + (n))
155 #define ED_ELEMENT_SETTINGS_YPOS(n)     (ED_POS_ELEMENT_SETTINGS_FIRST + (n))
156
157 #define IS_POS_LEVEL_TABS(n)          ((n) >= ED_POS_LEVEL_TABS_FIRST && \
158                                        (n) <= ED_POS_LEVEL_TABS_LAST)
159 #define IS_POS_LEVEL_SETTINGS(n)      ((n) >= ED_POS_LEVEL_SETTINGS_FIRST && \
160                                        (n) <= ED_POS_LEVEL_SETTINGS_LAST)
161 #define IS_POS_ELEMENT_TABS(n)        ((n) >= ED_POS_ELEMENT_TABS_FIRST && \
162                                        (n) <= ED_POS_ELEMENT_TABS_LAST)
163 #define IS_POS_ELEMENT_SETTINGS(n)    ((n) >= ED_POS_ELEMENT_SETTINGS_FIRST && \
164                                        (n) <= ED_POS_ELEMENT_SETTINGS_LAST)
165
166 #define ED_LEVEL_TABS_LINE(n)           ((n) - ED_POS_LEVEL_TABS_FIRST)
167 #define ED_LEVEL_SETTINGS_LINE(n)       ((n) - ED_POS_LEVEL_SETTINGS_FIRST)
168 #define ED_ELEMENT_TABS_LINE(n)         ((n) - ED_POS_ELEMENT_TABS_FIRST)
169 #define ED_ELEMENT_SETTINGS_LINE(n)     ((n) - ED_POS_ELEMENT_SETTINGS_FIRST)
170
171 #define ED_LEVEL_TABS_X(n)              (ED_LEVEL_TABS_XSTART + \
172                                          (n) * ED_SETTINGS_TABS_XOFFSET)
173 #define ED_LEVEL_TABS_Y(n)              (ED_LEVEL_TABS_YSTART + \
174                                          (n) * ED_SETTINGS_TABS_YOFFSET)
175
176 #define ED_LEVEL_SETTINGS_X(n)          (ED_LEVEL_SETTINGS_XSTART +     \
177                                          (n) * ED_SETTINGS_XOFFSET)
178 #define ED_LEVEL_SETTINGS_Y(n)          (ED_LEVEL_SETTINGS_YSTART +     \
179                                          (n) * ED_SETTINGS_YOFFSET)
180
181 #define ED_ELEMENT_TABS_X(n)            (ED_ELEMENT_TABS_XSTART +       \
182                                          (n) * ED_SETTINGS_TABS_XOFFSET)
183 #define ED_ELEMENT_TABS_Y(n)            (ED_ELEMENT_TABS_YSTART +       \
184                                          (n) * ED_SETTINGS_TABS_YOFFSET)
185
186 #define ED_ELEMENT_SETTINGS_X(n)        (ED_ELEMENT_SETTINGS_XSTART +   \
187                                          (n) * ED_SETTINGS_XOFFSET)
188 #define ED_ELEMENT_SETTINGS_Y(n)        (ED_ELEMENT_SETTINGS_YSTART +   \
189                                          (n) * ED_SETTINGS_YOFFSET)
190
191 #define ED_POS_TO_LEVEL_TABS_X(n)       \
192   (ED_LEVEL_TABS_X(ED_LEVEL_TABS_LINE(n)))
193 #define ED_POS_TO_LEVEL_TABS_Y(n)       \
194   (ED_LEVEL_TABS_Y(ED_LEVEL_TABS_LINE(n)))
195
196 #define ED_POS_TO_LEVEL_SETTINGS_X(n)   \
197   (ED_LEVEL_SETTINGS_X(ED_LEVEL_SETTINGS_LINE(n)))
198 #define ED_POS_TO_LEVEL_SETTINGS_Y(n)   \
199   (ED_LEVEL_SETTINGS_Y(ED_LEVEL_SETTINGS_LINE(n)))
200
201 #define ED_POS_TO_ELEMENT_TABS_X(n)     \
202   (ED_ELEMENT_TABS_X(ED_ELEMENT_TABS_LINE(n)))
203 #define ED_POS_TO_ELEMENT_TABS_Y(n)     \
204   (ED_ELEMENT_TABS_Y(ED_ELEMENT_TABS_LINE(n)))
205
206 #define ED_POS_TO_ELEMENT_SETTINGS_X(n) \
207   (ED_ELEMENT_SETTINGS_X(ED_ELEMENT_SETTINGS_LINE(n)))
208 #define ED_POS_TO_ELEMENT_SETTINGS_Y(n) \
209   (ED_ELEMENT_SETTINGS_Y(ED_ELEMENT_SETTINGS_LINE(n)))
210
211 #define ED_SETTINGS_X(n)                (IS_POS_LEVEL_TABS(n) ? \
212                                          ED_POS_TO_LEVEL_TABS_X(n) : \
213                                          IS_POS_LEVEL_SETTINGS(n) ?     \
214                                          ED_POS_TO_LEVEL_SETTINGS_X(n) : \
215                                          IS_POS_ELEMENT_TABS(n) ?       \
216                                          ED_POS_TO_ELEMENT_TABS_X(n) : \
217                                          IS_POS_ELEMENT_SETTINGS(n) ?   \
218                                          ED_POS_TO_ELEMENT_SETTINGS_X(n) : (n))
219 #define ED_SETTINGS_Y(n)                (IS_POS_LEVEL_TABS(n) ? \
220                                          ED_POS_TO_LEVEL_TABS_Y(n) : \
221                                          IS_POS_LEVEL_SETTINGS(n) ?     \
222                                          ED_POS_TO_LEVEL_SETTINGS_Y(n) : \
223                                          IS_POS_ELEMENT_TABS(n) ?       \
224                                          ED_POS_TO_ELEMENT_TABS_Y(n) : \
225                                          IS_POS_ELEMENT_SETTINGS(n) ?   \
226                                          ED_POS_TO_ELEMENT_SETTINGS_Y(n) : (n))
227
228 #define ED_SETTINGS_XOFF(n)             (5 * ((n) % 4) *                \
229                                          ED_DRAWINGAREA_TILE_SIZE)
230 #define ED_SETTINGS_YOFF(n)             (5 * ((n) / 4) *                \
231                                          ED_DRAWINGAREA_TILE_SIZE)
232
233 #define ED_AREA_XOFFSET_1(n)            ((n) != 0 ?                     \
234                                          ED_DRAWINGAREA_BORDER_SIZE : 0)
235 #define ED_AREA_YOFFSET_1(n)            ((n) != 0 ?                     \
236                                          (ED_CHECKBUTTON_YSIZE -        \
237                                           ED_DRAWINGAREA_TILE_SIZE) / 2 : 0)
238
239 #define ED_AREA_XOFFSET_2(n)      (0)
240 #define ED_AREA_YOFFSET_2(n)      ((n) == 3 ?                   \
241                                    ((n) - 1) * ED_DRAWINGAREA_TILE_SIZE / 2 : 0)
242
243 #define ED_AREA_SETTINGS_X(i)      (ED_SETTINGS_X((i).x) +              \
244                                     ED_SETTINGS_XOFF((i).xoffset) +     \
245                                     ED_AREA_XOFFSET_1((i).x) -          \
246                                     ED_AREA_XOFFSET_2((i).area_xsize))
247 #define ED_AREA_SETTINGS_Y(i)      (ED_SETTINGS_Y((i).y) +              \
248                                     ED_SETTINGS_YOFF((i).yoffset) +     \
249                                     ED_AREA_YOFFSET_1((i).y) -          \
250                                     ED_AREA_YOFFSET_2((i).area_ysize))
251
252 // values for element content drawing areas
253 #define ED_AREA_1X1_LSETTINGS_XPOS(n)   ED_LEVEL_SETTINGS_XPOS(n)
254 #define ED_AREA_1X1_LSETTINGS_YPOS(n)   ED_LEVEL_SETTINGS_YPOS(n)
255 #define ED_AREA_1X1_LSETTINGS_XOFF      (0)
256 #define ED_AREA_1X1_LSETTINGS_YOFF      (0)
257
258 #define ED_AREA_1X1_SETTINGS_XPOS(n)    ED_ELEMENT_SETTINGS_XPOS(n)
259 #define ED_AREA_1X1_SETTINGS_YPOS(n)    ED_ELEMENT_SETTINGS_YPOS(n)
260 #define ED_AREA_1X1_SETTINGS_XOFF       (0)
261 #define ED_AREA_1X1_SETTINGS_YOFF       (0)
262
263 #define ED_AREA_3X3_SETTINGS_XPOS(n)    ED_ELEMENT_SETTINGS_XPOS(n)
264 #define ED_AREA_3X3_SETTINGS_YPOS(n)    ED_ELEMENT_SETTINGS_YPOS(n)
265 #define ED_AREA_3X3_SETTINGS_XOFF       (0)
266 #define ED_AREA_3X3_SETTINGS_YOFF       (0)
267
268 // element content
269 #define ED_AREA_ELEMENT_CONTENT_XOFF(n) (n)
270 #define ED_AREA_ELEMENT_CONTENT_YOFF(n) (n)
271
272 // yamyam content
273 #define ED_XPOS_YAM                     0
274 #define ED_YPOS_YAM                     5
275 #define ED_AREA_YAMYAM_CONTENT_XPOS     ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_YAM)
276 #define ED_AREA_YAMYAM_CONTENT_YPOS     ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_YAM)
277 #define ED_AREA_YAMYAM_CONTENT_XOFF(n)  ED_AREA_ELEMENT_CONTENT_XOFF(n)
278 #define ED_AREA_YAMYAM_CONTENT_YOFF(n)  ED_AREA_ELEMENT_CONTENT_YOFF(n)
279 #define ED_AREA_YAMYAM_CONTENT_X(n)     (ED_ELEMENT_SETTINGS_X(ED_XPOS_YAM) + \
280                                          ED_SETTINGS_XOFF(n))
281 #define ED_AREA_YAMYAM_CONTENT_Y(n)     (ED_ELEMENT_SETTINGS_Y(ED_YPOS_YAM) + \
282                                          ED_SETTINGS_YOFF(n) +          \
283                                          ED_AREA_YOFFSET_1(ED_YPOS_YAM) - \
284                                          ED_AREA_YOFFSET_2(3))
285
286 // magic ball content
287 #define ED_XPOS_BALL                    0
288 #define ED_YPOS_BALL                    6
289 #define ED_AREA_MAGIC_BALL_CONTENT_XPOS ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_BALL)
290 #define ED_AREA_MAGIC_BALL_CONTENT_YPOS ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_BALL)
291 #define ED_AREA_MAGIC_BALL_CONTENT_XOFF(n) ED_AREA_ELEMENT_CONTENT_XOFF(n)
292 #define ED_AREA_MAGIC_BALL_CONTENT_YOFF(n) ED_AREA_ELEMENT_CONTENT_YOFF(n)
293 #define ED_AREA_MAGIC_BALL_CONTENT_X(n) (ED_ELEMENT_SETTINGS_X(ED_XPOS_BALL) + \
294                                          ED_SETTINGS_XOFF(n))
295 #define ED_AREA_MAGIC_BALL_CONTENT_Y(n) (ED_ELEMENT_SETTINGS_Y(ED_YPOS_BALL) + \
296                                          ED_SETTINGS_YOFF(n) +          \
297                                          ED_AREA_YOFFSET_1(ED_YPOS_BALL) - \
298                                          ED_AREA_YOFFSET_2(3))
299
300 // values for scrolling gadgets for drawing area
301 #define ED_SCROLLBUTTON_XSIZE           (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].width)
302 #define ED_SCROLLBUTTON_YSIZE           (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].height)
303
304 #define ED_SCROLL_UP_XPOS               (SXSIZE - ED_SCROLLBUTTON_XSIZE)
305 #define ED_SCROLL_UP_YPOS               (0)
306 #define ED_SCROLL_DOWN_XPOS             ED_SCROLL_UP_XPOS
307 #define ED_SCROLL_DOWN_YPOS             (SYSIZE - 3 * ED_SCROLLBUTTON_YSIZE)
308 #define ED_SCROLL_LEFT_XPOS             (0)
309 #define ED_SCROLL_LEFT_YPOS             (SYSIZE - 2 * ED_SCROLLBUTTON_YSIZE)
310 #define ED_SCROLL_RIGHT_XPOS            (SXSIZE - 2 * ED_SCROLLBUTTON_XSIZE)
311 #define ED_SCROLL_RIGHT_YPOS            ED_SCROLL_LEFT_YPOS
312 #define ED_SCROLL_HORIZONTAL_XPOS       (ED_SCROLL_LEFT_XPOS +          \
313                                          ED_SCROLLBUTTON_XSIZE)
314 #define ED_SCROLL_HORIZONTAL_YPOS       ED_SCROLL_LEFT_YPOS
315 #define ED_SCROLL_HORIZONTAL_XSIZE      (SXSIZE - 3 * ED_SCROLLBUTTON_XSIZE)
316 #define ED_SCROLL_HORIZONTAL_YSIZE      ED_SCROLLBUTTON_YSIZE
317 #define ED_SCROLL_VERTICAL_XPOS         ED_SCROLL_UP_XPOS
318 #define ED_SCROLL_VERTICAL_YPOS         (ED_SCROLL_UP_YPOS +            \
319                                          ED_SCROLLBUTTON_YSIZE)
320 #define ED_SCROLL_VERTICAL_XSIZE        ED_SCROLLBUTTON_XSIZE
321 #define ED_SCROLL_VERTICAL_YSIZE        (SYSIZE - 4 * ED_SCROLLBUTTON_YSIZE)
322
323 // values for scrolling gadgets for element list
324 #define ED_SCROLLBUTTON2_XSIZE          (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].width)
325 #define ED_SCROLLBUTTON2_YSIZE          (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].height)
326
327 #define ED_SCROLL2_UP_XPOS              (ED_ELEMENTLIST_XPOS +          \
328                                          ED_ELEMENTLIST_BUTTONS_HORIZ * \
329                                          ED_ELEMENTLIST_XSIZE)
330 #define ED_SCROLL2_UP_YPOS              ED_ELEMENTLIST_YPOS
331 #define ED_SCROLL2_DOWN_XPOS            ED_SCROLL2_UP_XPOS
332 #define ED_SCROLL2_DOWN_YPOS            (ED_SCROLL2_UP_YPOS +           \
333                                          ED_ELEMENTLIST_BUTTONS_VERT *  \
334                                          ED_ELEMENTLIST_YSIZE -         \
335                                          ED_SCROLLBUTTON2_YSIZE)
336 #define ED_SCROLL2_VERTICAL_XPOS        ED_SCROLL2_UP_XPOS
337 #define ED_SCROLL2_VERTICAL_YPOS        (ED_SCROLL2_UP_YPOS +           \
338                                          ED_SCROLLBUTTON2_YSIZE)
339 #define ED_SCROLL2_VERTICAL_XSIZE       ED_SCROLLBUTTON2_XSIZE
340 #define ED_SCROLL2_VERTICAL_YSIZE       (ED_ELEMENTLIST_BUTTONS_VERT *  \
341                                          ED_ELEMENTLIST_YSIZE -         \
342                                          2 * ED_SCROLLBUTTON2_YSIZE)
343
344 // values for ClearEditorGadgetInfoText() and HandleEditorGadgetInfoText()
345 #define INFOTEXT_FONT           FONT_TEXT_2
346 #define INFOTEXT_XSIZE          SXSIZE
347 #define INFOTEXT_YSIZE          getFontHeight(INFOTEXT_FONT)
348 #define INFOTEXT_YSIZE_FULL     (INFOTEXT_YSIZE + ED_GADGET_SMALL_DISTANCE)
349 #define INFOTEXT_X              (editor.settings.tooltip.x)
350 #define INFOTEXT_Y              (editor.settings.tooltip.y)
351 #define INFOTEXT_XY_REDEFINED   (INFOTEXT_X != -1 || INFOTEXT_Y != -1)
352 #define INFOTEXT_XPOS           SX + (INFOTEXT_XY_REDEFINED ? INFOTEXT_X : 0)
353 #define INFOTEXT_YPOS           SY + (INFOTEXT_XY_REDEFINED ? INFOTEXT_Y : \
354                                       SYSIZE - INFOTEXT_YSIZE)
355
356
357 // ----------------------------------------------------------------------------
358 // editor gadget definitions
359 // ----------------------------------------------------------------------------
360
361 enum
362 {
363   GADGET_ID_NONE = -1,
364
365   // drawing toolbox buttons
366
367   GADGET_ID_SINGLE_ITEMS,
368   GADGET_ID_CONNECTED_ITEMS,
369   GADGET_ID_LINE,
370   GADGET_ID_ARC,
371   GADGET_ID_RECTANGLE,
372   GADGET_ID_FILLED_BOX,
373   GADGET_ID_WRAP_UP,
374   GADGET_ID_TEXT,
375   GADGET_ID_FLOOD_FILL,
376   GADGET_ID_WRAP_LEFT,
377   GADGET_ID_ZOOM,
378   GADGET_ID_WRAP_RIGHT,
379   GADGET_ID_RANDOM_PLACEMENT,
380   GADGET_ID_GRAB_BRUSH,
381   GADGET_ID_WRAP_DOWN,
382   GADGET_ID_PICK_ELEMENT,
383
384   GADGET_ID_UNDO,
385   GADGET_ID_INFO,
386   GADGET_ID_SAVE,
387   GADGET_ID_CLEAR,
388   GADGET_ID_TEST,
389   GADGET_ID_EXIT,
390
391   GADGET_ID_CUSTOM_COPY_FROM,
392   GADGET_ID_CUSTOM_COPY_TO,
393   GADGET_ID_CUSTOM_EXCHANGE,
394   GADGET_ID_CUSTOM_COPY,
395   GADGET_ID_CUSTOM_PASTE,
396
397   GADGET_ID_PROPERTIES,
398   GADGET_ID_ELEMENT_LEFT,
399   GADGET_ID_ELEMENT_MIDDLE,
400   GADGET_ID_ELEMENT_RIGHT,
401   GADGET_ID_PALETTE,
402
403   // counter gadget identifiers
404
405   GADGET_ID_SELECT_LEVEL_DOWN,
406   GADGET_ID_SELECT_LEVEL_TEXT,
407   GADGET_ID_SELECT_LEVEL_UP,
408   GADGET_ID_LEVEL_XSIZE_DOWN,
409   GADGET_ID_LEVEL_XSIZE_TEXT,
410   GADGET_ID_LEVEL_XSIZE_UP,
411   GADGET_ID_LEVEL_YSIZE_DOWN,
412   GADGET_ID_LEVEL_YSIZE_TEXT,
413   GADGET_ID_LEVEL_YSIZE_UP,
414   GADGET_ID_LEVEL_RANDOM_DOWN,
415   GADGET_ID_LEVEL_RANDOM_TEXT,
416   GADGET_ID_LEVEL_RANDOM_UP,
417   GADGET_ID_LEVEL_GEMSLIMIT_DOWN,
418   GADGET_ID_LEVEL_GEMSLIMIT_TEXT,
419   GADGET_ID_LEVEL_GEMSLIMIT_UP,
420   GADGET_ID_LEVEL_TIMELIMIT_DOWN,
421   GADGET_ID_LEVEL_TIMELIMIT_TEXT,
422   GADGET_ID_LEVEL_TIMELIMIT_UP,
423   GADGET_ID_LEVEL_TIMESCORE_DOWN,
424   GADGET_ID_LEVEL_TIMESCORE_TEXT,
425   GADGET_ID_LEVEL_TIMESCORE_UP,
426   GADGET_ID_LEVEL_RANDOM_SEED_DOWN,
427   GADGET_ID_LEVEL_RANDOM_SEED_TEXT,
428   GADGET_ID_LEVEL_RANDOM_SEED_UP,
429   GADGET_ID_LEVELSET_NUM_LEVELS_DOWN,
430   GADGET_ID_LEVELSET_NUM_LEVELS_TEXT,
431   GADGET_ID_LEVELSET_NUM_LEVELS_UP,
432   GADGET_ID_ELEMENT_VALUE1_DOWN,
433   GADGET_ID_ELEMENT_VALUE1_TEXT,
434   GADGET_ID_ELEMENT_VALUE1_UP,
435   GADGET_ID_ELEMENT_VALUE2_DOWN,
436   GADGET_ID_ELEMENT_VALUE2_TEXT,
437   GADGET_ID_ELEMENT_VALUE2_UP,
438   GADGET_ID_ELEMENT_VALUE3_DOWN,
439   GADGET_ID_ELEMENT_VALUE3_TEXT,
440   GADGET_ID_ELEMENT_VALUE3_UP,
441   GADGET_ID_ELEMENT_VALUE4_DOWN,
442   GADGET_ID_ELEMENT_VALUE4_TEXT,
443   GADGET_ID_ELEMENT_VALUE4_UP,
444   GADGET_ID_YAMYAM_CONTENT_DOWN,
445   GADGET_ID_YAMYAM_CONTENT_TEXT,
446   GADGET_ID_YAMYAM_CONTENT_UP,
447   GADGET_ID_BALL_CONTENT_DOWN,
448   GADGET_ID_BALL_CONTENT_TEXT,
449   GADGET_ID_BALL_CONTENT_UP,
450   GADGET_ID_ANDROID_CONTENT_DOWN,
451   GADGET_ID_ANDROID_CONTENT_TEXT,
452   GADGET_ID_ANDROID_CONTENT_UP,
453   GADGET_ID_ENVELOPE_XSIZE_DOWN,
454   GADGET_ID_ENVELOPE_XSIZE_TEXT,
455   GADGET_ID_ENVELOPE_XSIZE_UP,
456   GADGET_ID_ENVELOPE_YSIZE_DOWN,
457   GADGET_ID_ENVELOPE_YSIZE_TEXT,
458   GADGET_ID_ENVELOPE_YSIZE_UP,
459   GADGET_ID_INVENTORY_SIZE_DOWN,
460   GADGET_ID_INVENTORY_SIZE_TEXT,
461   GADGET_ID_INVENTORY_SIZE_UP,
462   GADGET_ID_CUSTOM_SCORE_DOWN,
463   GADGET_ID_CUSTOM_SCORE_TEXT,
464   GADGET_ID_CUSTOM_SCORE_UP,
465   GADGET_ID_CUSTOM_GEMCOUNT_DOWN,
466   GADGET_ID_CUSTOM_GEMCOUNT_TEXT,
467   GADGET_ID_CUSTOM_GEMCOUNT_UP,
468   GADGET_ID_CUSTOM_VALUE_FIX_DOWN,
469   GADGET_ID_CUSTOM_VALUE_FIX_TEXT,
470   GADGET_ID_CUSTOM_VALUE_FIX_UP,
471   GADGET_ID_CUSTOM_VALUE_RND_DOWN,
472   GADGET_ID_CUSTOM_VALUE_RND_TEXT,
473   GADGET_ID_CUSTOM_VALUE_RND_UP,
474   GADGET_ID_PUSH_DELAY_FIX_DOWN,
475   GADGET_ID_PUSH_DELAY_FIX_TEXT,
476   GADGET_ID_PUSH_DELAY_FIX_UP,
477   GADGET_ID_PUSH_DELAY_RND_DOWN,
478   GADGET_ID_PUSH_DELAY_RND_TEXT,
479   GADGET_ID_PUSH_DELAY_RND_UP,
480   GADGET_ID_DROP_DELAY_FIX_DOWN,
481   GADGET_ID_DROP_DELAY_FIX_TEXT,
482   GADGET_ID_DROP_DELAY_FIX_UP,
483   GADGET_ID_DROP_DELAY_RND_DOWN,
484   GADGET_ID_DROP_DELAY_RND_TEXT,
485   GADGET_ID_DROP_DELAY_RND_UP,
486   GADGET_ID_MOVE_DELAY_FIX_DOWN,
487   GADGET_ID_MOVE_DELAY_FIX_TEXT,
488   GADGET_ID_MOVE_DELAY_FIX_UP,
489   GADGET_ID_MOVE_DELAY_RND_DOWN,
490   GADGET_ID_MOVE_DELAY_RND_TEXT,
491   GADGET_ID_MOVE_DELAY_RND_UP,
492   GADGET_ID_EXPLOSION_DELAY_DOWN,
493   GADGET_ID_EXPLOSION_DELAY_TEXT,
494   GADGET_ID_EXPLOSION_DELAY_UP,
495   GADGET_ID_IGNITION_DELAY_DOWN,
496   GADGET_ID_IGNITION_DELAY_TEXT,
497   GADGET_ID_IGNITION_DELAY_UP,
498   GADGET_ID_CHANGE_DELAY_FIX_DOWN,
499   GADGET_ID_CHANGE_DELAY_FIX_TEXT,
500   GADGET_ID_CHANGE_DELAY_FIX_UP,
501   GADGET_ID_CHANGE_DELAY_RND_DOWN,
502   GADGET_ID_CHANGE_DELAY_RND_TEXT,
503   GADGET_ID_CHANGE_DELAY_RND_UP,
504   GADGET_ID_CHANGE_CONT_RND_DOWN,
505   GADGET_ID_CHANGE_CONT_RND_TEXT,
506   GADGET_ID_CHANGE_CONT_RND_UP,
507   GADGET_ID_GROUP_CONTENT_DOWN,
508   GADGET_ID_GROUP_CONTENT_TEXT,
509   GADGET_ID_GROUP_CONTENT_UP,
510
511   // drawing area identifiers
512
513   GADGET_ID_DRAWING_LEVEL,
514   GADGET_ID_YAMYAM_CONTENT_0,
515   GADGET_ID_YAMYAM_CONTENT_1,
516   GADGET_ID_YAMYAM_CONTENT_2,
517   GADGET_ID_YAMYAM_CONTENT_3,
518   GADGET_ID_YAMYAM_CONTENT_4,
519   GADGET_ID_YAMYAM_CONTENT_5,
520   GADGET_ID_YAMYAM_CONTENT_6,
521   GADGET_ID_YAMYAM_CONTENT_7,
522   GADGET_ID_MAGIC_BALL_CONTENT_0,
523   GADGET_ID_MAGIC_BALL_CONTENT_1,
524   GADGET_ID_MAGIC_BALL_CONTENT_2,
525   GADGET_ID_MAGIC_BALL_CONTENT_3,
526   GADGET_ID_MAGIC_BALL_CONTENT_4,
527   GADGET_ID_MAGIC_BALL_CONTENT_5,
528   GADGET_ID_MAGIC_BALL_CONTENT_6,
529   GADGET_ID_MAGIC_BALL_CONTENT_7,
530   GADGET_ID_ANDROID_CONTENT,
531   GADGET_ID_AMOEBA_CONTENT,
532   GADGET_ID_START_ELEMENT,
533   GADGET_ID_ARTWORK_ELEMENT,
534   GADGET_ID_EXPLOSION_ELEMENT,
535   GADGET_ID_INVENTORY_CONTENT,
536   GADGET_ID_CUSTOM_GRAPHIC,
537   GADGET_ID_CUSTOM_CONTENT,
538   GADGET_ID_CUSTOM_MOVE_ENTER,
539   GADGET_ID_CUSTOM_MOVE_LEAVE,
540   GADGET_ID_CUSTOM_CHANGE_TARGET,
541   GADGET_ID_CUSTOM_CHANGE_CONTENT,
542   GADGET_ID_CUSTOM_CHANGE_TRIGGER,
543   GADGET_ID_CUSTOM_CHANGE_ACTION,
544   GADGET_ID_GROUP_CONTENT,
545   GADGET_ID_RANDOM_BACKGROUND,
546
547   // text input identifiers
548
549   GADGET_ID_LEVEL_NAME,
550   GADGET_ID_LEVEL_AUTHOR,
551   GADGET_ID_LEVELSET_NAME,
552   GADGET_ID_LEVELSET_AUTHOR,
553   GADGET_ID_ELEMENT_NAME,
554
555   // text area identifiers
556
557   GADGET_ID_ENVELOPE_INFO,
558
559   // selectbox identifiers
560
561   GADGET_ID_TIME_OR_STEPS,
562   GADGET_ID_GAME_ENGINE_TYPE,
563   GADGET_ID_LEVELSET_SAVE_MODE,
564   GADGET_ID_WIND_DIRECTION,
565   GADGET_ID_PLAYER_SPEED,
566   GADGET_ID_CUSTOM_WALK_TO_ACTION,
567   GADGET_ID_CUSTOM_EXPLOSION_TYPE,
568   GADGET_ID_CUSTOM_DEADLINESS,
569   GADGET_ID_CUSTOM_MOVE_PATTERN,
570   GADGET_ID_CUSTOM_MOVE_DIRECTION,
571   GADGET_ID_CUSTOM_MOVE_STEPSIZE,
572   GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
573   GADGET_ID_CUSTOM_SMASH_TARGETS,
574   GADGET_ID_CUSTOM_SLIPPERY_TYPE,
575   GADGET_ID_CUSTOM_ACCESS_TYPE,
576   GADGET_ID_CUSTOM_ACCESS_LAYER,
577   GADGET_ID_CUSTOM_ACCESS_PROTECTED,
578   GADGET_ID_CUSTOM_ACCESS_DIRECTION,
579   GADGET_ID_CHANGE_TIME_UNITS,
580   GADGET_ID_CHANGE_DIRECT_ACTION,
581   GADGET_ID_CHANGE_OTHER_ACTION,
582   GADGET_ID_CHANGE_SIDE,
583   GADGET_ID_CHANGE_PLAYER,
584   GADGET_ID_CHANGE_PAGE,
585   GADGET_ID_CHANGE_REPLACE_WHEN,
586   GADGET_ID_ACTION_TYPE,
587   GADGET_ID_ACTION_MODE,
588   GADGET_ID_ACTION_ARG,
589   GADGET_ID_SELECT_CHANGE_PAGE,
590   GADGET_ID_GROUP_CHOICE_MODE,
591
592   // textbutton identifiers
593
594   GADGET_ID_LEVELINFO_LEVEL,
595   GADGET_ID_LEVELINFO_LEVELSET,
596   GADGET_ID_LEVELINFO_EDITOR,
597   GADGET_ID_PROPERTIES_INFO,
598   GADGET_ID_PROPERTIES_CONFIG,
599   GADGET_ID_PROPERTIES_CONFIG_1,
600   GADGET_ID_PROPERTIES_CONFIG_2,
601   GADGET_ID_PROPERTIES_CHANGE,
602   GADGET_ID_SAVE_AS_TEMPLATE_1,
603   GADGET_ID_SAVE_AS_TEMPLATE_2,
604   GADGET_ID_SAVE_LEVELSET,
605   GADGET_ID_ADD_CHANGE_PAGE,
606   GADGET_ID_DEL_CHANGE_PAGE,
607
608   // graphicbutton identifiers
609
610   GADGET_ID_PREV_CHANGE_PAGE,
611   GADGET_ID_NEXT_CHANGE_PAGE,
612   GADGET_ID_COPY_CHANGE_PAGE,
613   GADGET_ID_PASTE_CHANGE_PAGE,
614
615   // gadgets for scrolling of drawing area
616
617   GADGET_ID_SCROLL_UP,
618   GADGET_ID_SCROLL_DOWN,
619   GADGET_ID_SCROLL_LEFT,
620   GADGET_ID_SCROLL_RIGHT,
621   GADGET_ID_SCROLL_HORIZONTAL,
622   GADGET_ID_SCROLL_VERTICAL,
623
624   // gadgets for scrolling element list
625
626   GADGET_ID_SCROLL_LIST_UP,
627   GADGET_ID_SCROLL_LIST_DOWN,
628   GADGET_ID_SCROLL_LIST_VERTICAL,
629
630   // checkbuttons/radiobuttons for level/element properties
631
632   GADGET_ID_AUTO_COUNT_GEMS,
633   GADGET_ID_USE_LEVELSET_ARTWORK,
634   GADGET_ID_COPY_LEVEL_TEMPLATE,
635   GADGET_ID_RANDOM_PERCENTAGE,
636   GADGET_ID_RANDOM_QUANTITY,
637   GADGET_ID_RANDOM_RESTRICTED,
638   GADGET_ID_STICK_ELEMENT,
639   GADGET_ID_EM_SLIPPERY_GEMS,
640   GADGET_ID_EM_EXPLODES_BY_FIRE,
641   GADGET_ID_USE_SPRING_BUG,
642   GADGET_ID_USE_TIME_ORB_BUG,
643   GADGET_ID_USE_LIFE_BUGS,
644   GADGET_ID_RANDOM_BALL_CONTENT,
645   GADGET_ID_INITIAL_BALL_STATE,
646   GADGET_ID_GROW_INTO_DIGGABLE,
647   GADGET_ID_SB_FIELDS_NEEDED,
648   GADGET_ID_SB_OBJECTS_NEEDED,
649   GADGET_ID_AUTO_EXIT_SOKOBAN,
650   GADGET_ID_SOLVED_BY_ONE_PLAYER,
651   GADGET_ID_CONTINUOUS_SNAPPING,
652   GADGET_ID_BLOCK_SNAP_FIELD,
653   GADGET_ID_BLOCK_LAST_FIELD,
654   GADGET_ID_SP_BLOCK_LAST_FIELD,
655   GADGET_ID_INSTANT_RELOCATION,
656   GADGET_ID_SHIFTED_RELOCATION,
657   GADGET_ID_LAZY_RELOCATION,
658   GADGET_ID_USE_START_ELEMENT,
659   GADGET_ID_USE_ARTWORK_ELEMENT,
660   GADGET_ID_USE_EXPLOSION_ELEMENT,
661   GADGET_ID_INITIAL_GRAVITY,
662   GADGET_ID_USE_INITIAL_INVENTORY,
663   GADGET_ID_CAN_PASS_TO_WALKABLE,
664   GADGET_ID_CAN_FALL_INTO_ACID,
665   GADGET_ID_CAN_MOVE_INTO_ACID,
666   GADGET_ID_DONT_COLLIDE_WITH,
667   GADGET_ID_ENVELOPE_AUTOWRAP,
668   GADGET_ID_ENVELOPE_CENTERED,
669   GADGET_ID_MM_LASER_RED,
670   GADGET_ID_MM_LASER_GREEN,
671   GADGET_ID_MM_LASER_BLUE,
672   GADGET_ID_DF_LASER_RED,
673   GADGET_ID_DF_LASER_GREEN,
674   GADGET_ID_DF_LASER_BLUE,
675   GADGET_ID_CUSTOM_INDESTRUCTIBLE,
676   GADGET_ID_CUSTOM_CAN_EXPLODE,
677   GADGET_ID_CUSTOM_EXPLODE_FIRE,
678   GADGET_ID_CUSTOM_EXPLODE_SMASH,
679   GADGET_ID_CUSTOM_EXPLODE_IMPACT,
680   GADGET_ID_CUSTOM_WALK_TO_OBJECT,
681   GADGET_ID_CUSTOM_DEADLY,
682   GADGET_ID_CUSTOM_CAN_MOVE,
683   GADGET_ID_CUSTOM_CAN_FALL,
684   GADGET_ID_CUSTOM_CAN_SMASH,
685   GADGET_ID_CUSTOM_SLIPPERY,
686   GADGET_ID_CUSTOM_ACCESSIBLE,
687   GADGET_ID_CUSTOM_GRAV_REACHABLE,
688   GADGET_ID_CUSTOM_USE_LAST_VALUE,
689   GADGET_ID_CUSTOM_USE_GRAPHIC,
690   GADGET_ID_CUSTOM_USE_TEMPLATE_1,
691   GADGET_ID_CUSTOM_USE_TEMPLATE_2,
692   GADGET_ID_CUSTOM_USE_TEMPLATE_3,
693   GADGET_ID_CUSTOM_CAN_CHANGE,
694   GADGET_ID_CHANGE_USE_CONTENT,
695   GADGET_ID_CHANGE_USE_EXPLOSION,
696   GADGET_ID_CHANGE_ONLY_COMPLETE,
697   GADGET_ID_CHANGE_USE_RANDOM,
698   GADGET_ID_CHANGE_HAS_ACTION,
699   GADGET_ID_CHANGE_DELAY,
700   GADGET_ID_CHANGE_BY_DIRECT_ACT,
701   GADGET_ID_CHANGE_BY_OTHER_ACT,
702
703   NUM_STATIC_GADGET_IDS
704 };
705
706 // gadgets for buttons in element list (dynamic)
707 #define GADGET_ID_ELEMENTLIST_FIRST     (NUM_STATIC_GADGET_IDS)
708 #define GADGET_ID_ELEMENTLIST_LAST      (GADGET_ID_ELEMENTLIST_FIRST +  \
709                                         ED_NUM_ELEMENTLIST_BUTTONS - 1)
710
711 #define NUM_EDITOR_GADGETS              (GADGET_ID_ELEMENTLIST_LAST + 1)
712
713 // radio button numbers
714 enum
715 {
716   RADIO_NR_NONE,
717   RADIO_NR_DRAWING_TOOLBOX,
718   RADIO_NR_RANDOM_ELEMENTS
719 };
720
721 // values for counter gadgets
722 enum
723 {
724   ED_COUNTER_ID_SELECT_LEVEL,
725   ED_COUNTER_ID_LEVEL_XSIZE,
726   ED_COUNTER_ID_LEVEL_YSIZE,
727   ED_COUNTER_ID_LEVEL_GEMSLIMIT,
728   ED_COUNTER_ID_LEVEL_TIMELIMIT,
729   ED_COUNTER_ID_LEVEL_TIMESCORE,
730   ED_COUNTER_ID_LEVEL_RANDOM_SEED,
731   ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
732   ED_COUNTER_ID_LEVEL_RANDOM,
733   ED_COUNTER_ID_ELEMENT_VALUE1,
734   ED_COUNTER_ID_ELEMENT_VALUE2,
735   ED_COUNTER_ID_ELEMENT_VALUE3,
736   ED_COUNTER_ID_ELEMENT_VALUE4,
737   ED_COUNTER_ID_YAMYAM_CONTENT,
738   ED_COUNTER_ID_BALL_CONTENT,
739   ED_COUNTER_ID_ANDROID_CONTENT,
740   ED_COUNTER_ID_ENVELOPE_XSIZE,
741   ED_COUNTER_ID_ENVELOPE_YSIZE,
742   ED_COUNTER_ID_INVENTORY_SIZE,
743   ED_COUNTER_ID_CUSTOM_SCORE,
744   ED_COUNTER_ID_CUSTOM_GEMCOUNT,
745   ED_COUNTER_ID_CUSTOM_VALUE_FIX,
746   ED_COUNTER_ID_CUSTOM_VALUE_RND,
747   ED_COUNTER_ID_PUSH_DELAY_FIX,
748   ED_COUNTER_ID_PUSH_DELAY_RND,
749   ED_COUNTER_ID_DROP_DELAY_FIX,
750   ED_COUNTER_ID_DROP_DELAY_RND,
751   ED_COUNTER_ID_MOVE_DELAY_FIX,
752   ED_COUNTER_ID_MOVE_DELAY_RND,
753   ED_COUNTER_ID_EXPLOSION_DELAY,
754   ED_COUNTER_ID_IGNITION_DELAY,
755   ED_COUNTER_ID_GROUP_CONTENT,
756   ED_COUNTER_ID_CHANGE_DELAY_FIX,
757   ED_COUNTER_ID_CHANGE_DELAY_RND,
758   ED_COUNTER_ID_CHANGE_CONT_RND,
759
760   ED_NUM_COUNTERBUTTONS
761 };
762
763 #define ED_COUNTER_ID_LEVEL_FIRST       ED_COUNTER_ID_LEVEL_XSIZE
764 #define ED_COUNTER_ID_LEVEL_LAST        ED_COUNTER_ID_LEVEL_RANDOM_SEED
765 #define ED_COUNTER_ID_LEVELSET_FIRST    ED_COUNTER_ID_LEVELSET_NUM_LEVELS
766 #define ED_COUNTER_ID_LEVELSET_LAST     ED_COUNTER_ID_LEVELSET_NUM_LEVELS
767 #define ED_COUNTER_ID_EDITOR_FIRST      ED_COUNTER_ID_LEVEL_RANDOM
768 #define ED_COUNTER_ID_EDITOR_LAST       ED_COUNTER_ID_LEVEL_RANDOM
769
770 #define ED_COUNTER_ID_CUSTOM1_FIRST     ED_COUNTER_ID_CUSTOM_SCORE
771 #define ED_COUNTER_ID_CUSTOM1_LAST      ED_COUNTER_ID_DROP_DELAY_RND
772 #define ED_COUNTER_ID_CUSTOM2_FIRST     ED_COUNTER_ID_MOVE_DELAY_FIX
773 #define ED_COUNTER_ID_CUSTOM2_LAST      ED_COUNTER_ID_IGNITION_DELAY
774 #define ED_COUNTER_ID_CUSTOM_FIRST      ED_COUNTER_ID_CUSTOM1_FIRST
775 #define ED_COUNTER_ID_CUSTOM_LAST       ED_COUNTER_ID_CUSTOM2_LAST
776
777 #define ED_COUNTER_ID_CHANGE_FIRST      ED_COUNTER_ID_CHANGE_DELAY_FIX
778 #define ED_COUNTER_ID_CHANGE_LAST       ED_COUNTER_ID_CHANGE_CONT_RND
779
780 // values for scrollbutton gadgets
781 enum
782 {
783   ED_SCROLLBUTTON_ID_AREA_UP,
784   ED_SCROLLBUTTON_ID_AREA_DOWN,
785   ED_SCROLLBUTTON_ID_AREA_LEFT,
786   ED_SCROLLBUTTON_ID_AREA_RIGHT,
787   ED_SCROLLBUTTON_ID_LIST_UP,
788   ED_SCROLLBUTTON_ID_LIST_DOWN,
789
790   ED_NUM_SCROLLBUTTONS
791 };
792
793 #define ED_SCROLLBUTTON_ID_AREA_FIRST   ED_SCROLLBUTTON_ID_AREA_UP
794 #define ED_SCROLLBUTTON_ID_AREA_LAST    ED_SCROLLBUTTON_ID_AREA_RIGHT
795
796 // values for scrollbar gadgets
797 enum
798 {
799   ED_SCROLLBAR_ID_AREA_HORIZONTAL,
800   ED_SCROLLBAR_ID_AREA_VERTICAL,
801   ED_SCROLLBAR_ID_LIST_VERTICAL,
802
803   ED_NUM_SCROLLBARS
804 };
805
806 #define ED_SCROLLBAR_ID_AREA_FIRST      ED_SCROLLBAR_ID_AREA_HORIZONTAL
807 #define ED_SCROLLBAR_ID_AREA_LAST       ED_SCROLLBAR_ID_AREA_VERTICAL
808
809 // values for text input gadgets
810 enum
811 {
812   ED_TEXTINPUT_ID_LEVEL_NAME,
813   ED_TEXTINPUT_ID_LEVEL_AUTHOR,
814   ED_TEXTINPUT_ID_LEVELSET_NAME,
815   ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
816   ED_TEXTINPUT_ID_ELEMENT_NAME,
817
818   ED_NUM_TEXTINPUT
819 };
820
821 #define ED_TEXTINPUT_ID_LEVEL_FIRST     ED_TEXTINPUT_ID_LEVEL_NAME
822 #define ED_TEXTINPUT_ID_LEVEL_LAST      ED_TEXTINPUT_ID_LEVEL_AUTHOR
823
824 #define ED_TEXTINPUT_ID_LEVELSET_FIRST  ED_TEXTINPUT_ID_LEVELSET_NAME
825 #define ED_TEXTINPUT_ID_LEVELSET_LAST   ED_TEXTINPUT_ID_LEVELSET_AUTHOR
826
827 // values for text area gadgets
828 enum
829 {
830   ED_TEXTAREA_ID_ENVELOPE_INFO,
831
832   ED_NUM_TEXTAREAS
833 };
834
835 #define ED_TEXTAREA_ID_LEVEL_FIRST      ED_TEXTAREA_ID_ENVELOPE
836 #define ED_TEXTAREA_ID_LEVEL_LAST       ED_TEXTAREA_ID_ENVELOPE
837
838 // values for selectbox gadgets
839 enum
840 {
841   ED_SELECTBOX_ID_TIME_OR_STEPS,
842   ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
843   ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
844   ED_SELECTBOX_ID_WIND_DIRECTION,
845   ED_SELECTBOX_ID_PLAYER_SPEED,
846   ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
847   ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
848   ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
849   ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
850   ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
851   ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
852   ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
853   ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
854   ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
855   ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
856   ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
857   ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
858   ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
859   ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
860   ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
861   ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
862   ED_SELECTBOX_ID_CHANGE_SIDE,
863   ED_SELECTBOX_ID_CHANGE_PLAYER,
864   ED_SELECTBOX_ID_CHANGE_PAGE,
865   ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
866   ED_SELECTBOX_ID_ACTION_TYPE,
867   ED_SELECTBOX_ID_ACTION_MODE,
868   ED_SELECTBOX_ID_ACTION_ARG,
869   ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
870   ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
871
872   ED_NUM_SELECTBOX
873 };
874
875 #define ED_SELECTBOX_ID_LEVEL_FIRST     ED_SELECTBOX_ID_TIME_OR_STEPS
876 #define ED_SELECTBOX_ID_LEVEL_LAST      ED_SELECTBOX_ID_GAME_ENGINE_TYPE
877
878 #define ED_SELECTBOX_ID_LEVELSET_FIRST  ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
879 #define ED_SELECTBOX_ID_LEVELSET_LAST   ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
880
881 #define ED_SELECTBOX_ID_CUSTOM1_FIRST   ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
882 #define ED_SELECTBOX_ID_CUSTOM1_LAST    ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
883 #define ED_SELECTBOX_ID_CUSTOM2_FIRST   ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
884 #define ED_SELECTBOX_ID_CUSTOM2_LAST    ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
885 #define ED_SELECTBOX_ID_CUSTOM_FIRST    ED_SELECTBOX_ID_CUSTOM1_FIRST
886 #define ED_SELECTBOX_ID_CUSTOM_LAST     ED_SELECTBOX_ID_CUSTOM2_LAST
887
888 #define ED_SELECTBOX_ID_CHANGE_FIRST    ED_SELECTBOX_ID_CHANGE_TIME_UNITS
889 #define ED_SELECTBOX_ID_CHANGE_LAST     ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
890
891 // values for textbutton gadgets
892 enum
893 {
894   ED_TEXTBUTTON_ID_LEVELINFO_LEVEL,
895   ED_TEXTBUTTON_ID_LEVELINFO_LEVELSET,
896   ED_TEXTBUTTON_ID_LEVELINFO_EDITOR,
897   ED_TEXTBUTTON_ID_PROPERTIES_INFO,
898   ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
899   ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
900   ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
901   ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
902   ED_TEXTBUTTON_ID_SAVE_LEVELSET,
903   ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
904   ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
905   ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
906   ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
907
908   ED_NUM_TEXTBUTTONS
909 };
910
911 #define ED_TAB_BUTTON_ID_LEVELINFO_FIRST ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
912 #define ED_TAB_BUTTON_ID_LEVELINFO_LAST  ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
913
914 #define ED_TAB_BUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
915 #define ED_TAB_BUTTON_ID_PROPERTIES_LAST  ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
916
917 #define ED_TEXTBUTTON_ID_CHANGE_FIRST   ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
918 #define ED_TEXTBUTTON_ID_CHANGE_LAST    ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
919
920 // values for graphicbutton gadgets
921 enum
922 {
923   ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
924   ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
925   ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
926   ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
927
928   ED_NUM_GRAPHICBUTTONS
929 };
930
931 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST  ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
932 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST   ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
933
934 // values for checkbutton gadgets
935 enum
936 {
937   ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
938   ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
939   ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
940   ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
941   ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
942   ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
943   ED_CHECKBUTTON_ID_STICK_ELEMENT,
944   ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
945   ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
946   ED_CHECKBUTTON_ID_USE_SPRING_BUG,
947   ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
948   ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
949   ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
950   ED_CHECKBUTTON_ID_INITIAL_BALL_STATE,
951   ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
952   ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
953   ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
954   ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
955   ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
956   ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
957   ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
958   ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
959   ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
960   ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
961   ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
962   ED_CHECKBUTTON_ID_LAZY_RELOCATION,
963   ED_CHECKBUTTON_ID_USE_START_ELEMENT,
964   ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
965   ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
966   ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
967   ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
968   ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
969   ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
970   ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
971   ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
972   ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
973   ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
974   ED_CHECKBUTTON_ID_MM_LASER_RED,
975   ED_CHECKBUTTON_ID_MM_LASER_GREEN,
976   ED_CHECKBUTTON_ID_MM_LASER_BLUE,
977   ED_CHECKBUTTON_ID_DF_LASER_RED,
978   ED_CHECKBUTTON_ID_DF_LASER_GREEN,
979   ED_CHECKBUTTON_ID_DF_LASER_BLUE,
980   ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
981   ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
982   ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
983   ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
984   ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
985   ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
986   ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
987   ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
988   ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
989   ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
990   ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
991   ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
992   ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
993   ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
994   ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
995   ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
996   ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
997   ED_CHECKBUTTON_ID_CHANGE_DELAY,
998   ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
999   ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
1000   ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
1001   ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
1002   ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
1003   ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
1004   ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
1005
1006   ED_NUM_CHECKBUTTONS
1007 };
1008
1009 #define ED_CHECKBUTTON_ID_LEVEL_FIRST   ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
1010 #define ED_CHECKBUTTON_ID_LEVEL_LAST    ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
1011
1012 #define ED_CHECKBUTTON_ID_LEVELSET_FIRST ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK
1013 #define ED_CHECKBUTTON_ID_LEVELSET_LAST  ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE
1014
1015 #define ED_CHECKBUTTON_ID_EDITOR_FIRST  ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
1016 #define ED_CHECKBUTTON_ID_EDITOR_LAST   ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2
1017
1018 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
1019 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST  ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
1020 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
1021 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST  ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
1022 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST  ED_CHECKBUTTON_ID_CUSTOM1_FIRST
1023 #define ED_CHECKBUTTON_ID_CUSTOM_LAST   ED_CHECKBUTTON_ID_CUSTOM2_LAST
1024
1025 #define ED_CHECKBUTTON_ID_CHANGE_FIRST  ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
1026 #define ED_CHECKBUTTON_ID_CHANGE_LAST   ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
1027
1028 // values for radiobutton gadgets
1029 enum
1030 {
1031   ED_RADIOBUTTON_ID_PERCENTAGE,
1032   ED_RADIOBUTTON_ID_QUANTITY,
1033
1034   ED_NUM_RADIOBUTTONS
1035 };
1036
1037 #define ED_RADIOBUTTON_ID_EDITOR_FIRST  ED_RADIOBUTTON_ID_PERCENTAGE
1038 #define ED_RADIOBUTTON_ID_EDITOR_LAST   ED_RADIOBUTTON_ID_QUANTITY
1039
1040 // values for drawing area gadgets
1041 enum
1042 {
1043   ED_DRAWING_ID_DRAWING_LEVEL,
1044   ED_DRAWING_ID_YAMYAM_CONTENT_0,
1045   ED_DRAWING_ID_YAMYAM_CONTENT_1,
1046   ED_DRAWING_ID_YAMYAM_CONTENT_2,
1047   ED_DRAWING_ID_YAMYAM_CONTENT_3,
1048   ED_DRAWING_ID_YAMYAM_CONTENT_4,
1049   ED_DRAWING_ID_YAMYAM_CONTENT_5,
1050   ED_DRAWING_ID_YAMYAM_CONTENT_6,
1051   ED_DRAWING_ID_YAMYAM_CONTENT_7,
1052   ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
1053   ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
1054   ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
1055   ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
1056   ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
1057   ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
1058   ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
1059   ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
1060   ED_DRAWING_ID_ANDROID_CONTENT,
1061   ED_DRAWING_ID_AMOEBA_CONTENT,
1062   ED_DRAWING_ID_START_ELEMENT,
1063   ED_DRAWING_ID_ARTWORK_ELEMENT,
1064   ED_DRAWING_ID_EXPLOSION_ELEMENT,
1065   ED_DRAWING_ID_INVENTORY_CONTENT,
1066   ED_DRAWING_ID_CUSTOM_GRAPHIC,
1067   ED_DRAWING_ID_CUSTOM_CONTENT,
1068   ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
1069   ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
1070   ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
1071   ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
1072   ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
1073   ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
1074   ED_DRAWING_ID_GROUP_CONTENT,
1075   ED_DRAWING_ID_RANDOM_BACKGROUND,
1076
1077   ED_NUM_DRAWING_AREAS
1078 };
1079
1080 #define ED_DRAWING_ID_EDITOR_FIRST      ED_DRAWING_ID_RANDOM_BACKGROUND
1081 #define ED_DRAWING_ID_EDITOR_LAST       ED_DRAWING_ID_RANDOM_BACKGROUND
1082
1083
1084 // ----------------------------------------------------------------------------
1085 // some internally used definitions
1086 // ----------------------------------------------------------------------------
1087
1088 // values for CopyLevelToUndoBuffer()
1089 #define UNDO_IMMEDIATE                  0
1090 #define UNDO_ACCUMULATE                 1
1091
1092 // values for scrollbars
1093 #define ED_SCROLL_NO                    0
1094 #define ED_SCROLL_LEFT                  1
1095 #define ED_SCROLL_RIGHT                 2
1096 #define ED_SCROLL_UP                    4
1097 #define ED_SCROLL_DOWN                  8
1098
1099 // screens in the level editor
1100 #define ED_MODE_DRAWING                 0
1101 #define ED_MODE_INFO                    1
1102 #define ED_MODE_PROPERTIES              2
1103 #define ED_MODE_PALETTE                 3
1104
1105 // sub-screens in the global settings section
1106 #define ED_MODE_LEVELINFO_LEVEL         ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
1107 #define ED_MODE_LEVELINFO_LEVELSET      ED_TEXTBUTTON_ID_LEVELINFO_LEVELSET
1108 #define ED_MODE_LEVELINFO_EDITOR        ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
1109
1110 // sub-screens in the element properties section
1111 #define ED_MODE_PROPERTIES_INFO         ED_TEXTBUTTON_ID_PROPERTIES_INFO
1112 #define ED_MODE_PROPERTIES_CONFIG       ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
1113 #define ED_MODE_PROPERTIES_CONFIG_1     ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
1114 #define ED_MODE_PROPERTIES_CONFIG_2     ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
1115 #define ED_MODE_PROPERTIES_CHANGE       ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
1116
1117 // how many steps can be cancelled
1118 #define NUM_UNDO_STEPS                  (64 + 1)
1119
1120 // values for elements with score for certain actions
1121 #define MIN_SCORE                       0
1122 #define MAX_SCORE                       999
1123
1124 // values for elements with count for collecting
1125 #define MIN_COLLECT_COUNT               0
1126 #define MAX_COLLECT_COUNT               999
1127
1128 // values for random placement
1129 #define RANDOM_USE_PERCENTAGE           0
1130 #define RANDOM_USE_QUANTITY             1
1131
1132 // values for level set save mode
1133 #define LEVELSET_SAVE_MODE_UPDATE       0
1134 #define LEVELSET_SAVE_MODE_CREATE       1
1135
1136 // default value for element tile size in drawing area
1137 #define DEFAULT_EDITOR_TILESIZE         MINI_TILESIZE
1138 #define DEFAULT_EDITOR_TILESIZE_MM      TILESIZE
1139
1140
1141 // ----------------------------------------------------------------------------
1142 // some internally used data structure definitions
1143 // ----------------------------------------------------------------------------
1144
1145 static struct
1146 {
1147   int graphic;
1148   int gadget_id;
1149   struct XYTileSize *pos;
1150   int gadget_type;
1151   char *infotext;
1152   char shortcut;
1153 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
1154 {
1155   // note: some additional characters are already reserved for "cheat mode"
1156   // shortcuts (":XYZ" style) -- for details, see "events.c"
1157
1158   // ---------- toolbox control buttons ---------------------------------------
1159
1160   {
1161     IMG_GFX_EDITOR_BUTTON_DRAW_SINGLE,          GADGET_ID_SINGLE_ITEMS,
1162     &editor.button.draw_single,                 GD_TYPE_RADIO_BUTTON,
1163     "draw single items",                        's'
1164   },
1165   {
1166     IMG_GFX_EDITOR_BUTTON_DRAW_CONNECTED,       GADGET_ID_CONNECTED_ITEMS,
1167     &editor.button.draw_connected,              GD_TYPE_RADIO_BUTTON,
1168     "draw connected items",                     'd'
1169   },
1170   {
1171     IMG_GFX_EDITOR_BUTTON_DRAW_LINE,            GADGET_ID_LINE,
1172     &editor.button.draw_line,                   GD_TYPE_RADIO_BUTTON,
1173     "draw lines",                               'l'
1174   },
1175   {
1176     IMG_GFX_EDITOR_BUTTON_DRAW_ARC,             GADGET_ID_ARC,
1177     &editor.button.draw_arc,                    GD_TYPE_RADIO_BUTTON,
1178     "draw arcs",                                'a'
1179   },
1180   {
1181     IMG_GFX_EDITOR_BUTTON_DRAW_RECTANGLE,       GADGET_ID_RECTANGLE,
1182     &editor.button.draw_rectangle,              GD_TYPE_RADIO_BUTTON,
1183     "draw outline rectangles",                  'r'
1184   },
1185   {
1186     IMG_GFX_EDITOR_BUTTON_DRAW_FILLED_BOX,      GADGET_ID_FILLED_BOX,
1187     &editor.button.draw_filled_box,             GD_TYPE_RADIO_BUTTON,
1188     "draw filled rectangles",                   'R'
1189   },
1190   {
1191     IMG_GFX_EDITOR_BUTTON_ROTATE_UP,            GADGET_ID_WRAP_UP,
1192     &editor.button.rotate_up,                   GD_TYPE_NORMAL_BUTTON,
1193     "wrap (rotate) level up",                   0
1194   },
1195   {
1196     IMG_GFX_EDITOR_BUTTON_DRAW_TEXT,            GADGET_ID_TEXT,
1197     &editor.button.draw_text,                   GD_TYPE_RADIO_BUTTON,
1198     "enter text elements",                      't'
1199   },
1200   {
1201     IMG_GFX_EDITOR_BUTTON_FLOOD_FILL,           GADGET_ID_FLOOD_FILL,
1202     &editor.button.flood_fill,                  GD_TYPE_RADIO_BUTTON,
1203     "flood fill",                               'f'
1204   },
1205   {
1206     IMG_GFX_EDITOR_BUTTON_ROTATE_LEFT,          GADGET_ID_WRAP_LEFT,
1207     &editor.button.rotate_left,                 GD_TYPE_NORMAL_BUTTON,
1208     "wrap (rotate) level left",                 0
1209   },
1210   {
1211     IMG_GFX_EDITOR_BUTTON_ZOOM_LEVEL,           GADGET_ID_ZOOM,
1212     &editor.button.zoom_level,                  GD_TYPE_NORMAL_BUTTON,
1213     "zoom level tile size",                     '+'
1214   },
1215   {
1216     IMG_GFX_EDITOR_BUTTON_ROTATE_RIGHT,         GADGET_ID_WRAP_RIGHT,
1217     &editor.button.rotate_right,                GD_TYPE_NORMAL_BUTTON,
1218     "wrap (rotate) level right",                0
1219   },
1220   {
1221     IMG_GFX_EDITOR_BUTTON_DRAW_RANDOM,          GADGET_ID_RANDOM_PLACEMENT,
1222     &editor.button.draw_random,                 GD_TYPE_NORMAL_BUTTON,
1223     "random element placement",                 0
1224   },
1225   {
1226     IMG_GFX_EDITOR_BUTTON_GRAB_BRUSH,           GADGET_ID_GRAB_BRUSH,
1227     &editor.button.grab_brush,                  GD_TYPE_RADIO_BUTTON,
1228     "grab brush",                               'b'
1229   },
1230   {
1231     IMG_GFX_EDITOR_BUTTON_ROTATE_DOWN,          GADGET_ID_WRAP_DOWN,
1232     &editor.button.rotate_down,                 GD_TYPE_NORMAL_BUTTON,
1233     "wrap (rotate) level down",                 0
1234   },
1235   {
1236     IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT,         GADGET_ID_PICK_ELEMENT,
1237     &editor.button.pick_element,                GD_TYPE_RADIO_BUTTON,
1238     "pick drawing element",                     ','
1239   },
1240
1241   // ---------- level control buttons -----------------------------------------
1242
1243   {
1244     IMG_GFX_EDITOR_BUTTON_UNDO,                 GADGET_ID_UNDO,
1245     &editor.button.undo,                        GD_TYPE_NORMAL_BUTTON,
1246     "undo/redo last operation",                 'u'
1247   },
1248   {
1249     IMG_GFX_EDITOR_BUTTON_CONF,                 GADGET_ID_INFO,
1250     &editor.button.conf,                        GD_TYPE_NORMAL_BUTTON,
1251     "properties of level",                      'I'
1252   },
1253   {
1254     IMG_GFX_EDITOR_BUTTON_SAVE,                 GADGET_ID_SAVE,
1255     &editor.button.save,                        GD_TYPE_NORMAL_BUTTON,
1256     "save level",                               'S'
1257   },
1258   {
1259     IMG_GFX_EDITOR_BUTTON_CLEAR,                GADGET_ID_CLEAR,
1260     &editor.button.clear,                       GD_TYPE_NORMAL_BUTTON,
1261     "clear level",                              'C'
1262   },
1263   {
1264     IMG_GFX_EDITOR_BUTTON_TEST,                 GADGET_ID_TEST,
1265     &editor.button.test,                        GD_TYPE_NORMAL_BUTTON,
1266     "test level",                               'T'
1267   },
1268   {
1269     IMG_GFX_EDITOR_BUTTON_EXIT,                 GADGET_ID_EXIT,
1270     &editor.button.exit,                        GD_TYPE_NORMAL_BUTTON,
1271     "exit level editor",                        'E'
1272   },
1273
1274   // ---------- CE and GE control buttons -------------------------------------
1275
1276   {
1277     IMG_GFX_EDITOR_BUTTON_CE_COPY_FROM,         GADGET_ID_CUSTOM_COPY_FROM,
1278     &editor.button.ce_copy_from,                GD_TYPE_RADIO_BUTTON,
1279     "copy settings from other element",         0
1280   },
1281   {
1282     IMG_GFX_EDITOR_BUTTON_CE_COPY_TO,           GADGET_ID_CUSTOM_COPY_TO,
1283     &editor.button.ce_copy_to,                  GD_TYPE_RADIO_BUTTON,
1284     "copy settings to other element",           0
1285   },
1286   {
1287     IMG_GFX_EDITOR_BUTTON_CE_SWAP,              GADGET_ID_CUSTOM_EXCHANGE,
1288     &editor.button.ce_swap,                     GD_TYPE_RADIO_BUTTON,
1289     "exchange element with other element",      0
1290   },
1291   {
1292     IMG_GFX_EDITOR_BUTTON_CE_COPY,              GADGET_ID_CUSTOM_COPY,
1293     &editor.button.ce_copy,                     GD_TYPE_NORMAL_BUTTON,
1294     "copy settings from this element",          0
1295   },
1296   {
1297     IMG_GFX_EDITOR_BUTTON_CE_PASTE,             GADGET_ID_CUSTOM_PASTE,
1298     &editor.button.ce_paste,                    GD_TYPE_NORMAL_BUTTON,
1299     "paste settings to this element",           0
1300   },
1301
1302   // ---------- palette control buttons ---------------------------------------
1303
1304   {
1305     IMG_GFX_EDITOR_BUTTON_PROPERTIES,           GADGET_ID_PROPERTIES,
1306     &editor.button.properties,                  GD_TYPE_NORMAL_BUTTON,
1307     "properties of drawing element",            'p'
1308   },
1309   {
1310     IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT,         GADGET_ID_ELEMENT_LEFT,
1311     &editor.button.element_left,                GD_TYPE_NORMAL_BUTTON,
1312     "properties of drawing element 1",          '1'
1313   },
1314   {
1315     IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE,       GADGET_ID_ELEMENT_MIDDLE,
1316     &editor.button.element_middle,              GD_TYPE_NORMAL_BUTTON,
1317     "properties of drawing element 2",          '2'
1318   },
1319   {
1320     IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT,        GADGET_ID_ELEMENT_RIGHT,
1321     &editor.button.element_right,               GD_TYPE_NORMAL_BUTTON,
1322     "properties of drawing element 3",          '3'
1323   },
1324   {
1325     IMG_GFX_EDITOR_BUTTON_PALETTE,              GADGET_ID_PALETTE,
1326     &editor.button.palette,                     GD_TYPE_NORMAL_BUTTON,
1327     "show list of elements",                    'e'
1328   }
1329 };
1330
1331 static int random_placement_value = 10;
1332 static int random_placement_method = RANDOM_USE_QUANTITY;
1333 static int random_placement_background_element = EL_SAND;
1334 static boolean random_placement_background_restricted = FALSE;
1335 static boolean stick_element_properties_window = FALSE;
1336 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1337 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1338 static struct ElementChangeInfo custom_element_change;
1339 static struct ElementGroupInfo group_element_info;
1340 static struct ElementInfo custom_element;
1341
1342 static char levelset_name[MAX_LEVEL_NAME_LEN + 1];
1343 static char levelset_author[MAX_LEVEL_AUTHOR_LEN + 1];
1344 static int levelset_num_levels = 100;
1345 static boolean levelset_use_levelset_artwork = FALSE;
1346 static boolean levelset_copy_level_template = FALSE;
1347 static int levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
1348
1349 static struct
1350 {
1351   int x, y;
1352   int min_value, max_value;
1353   int gadget_id_down, gadget_id_up;
1354   int gadget_id_text;
1355   int gadget_id_align;
1356   int *value;
1357   char *text_above, *text_left, *text_right;
1358 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1359 {
1360   // ---------- current level number ------------------------------------------
1361
1362   {
1363     -1, -1,     // these values are not constant, but can change at runtime
1364     1,                                  100,
1365     GADGET_ID_SELECT_LEVEL_DOWN,        GADGET_ID_SELECT_LEVEL_UP,
1366     GADGET_ID_SELECT_LEVEL_TEXT,        GADGET_ID_NONE,
1367     &level_nr,
1368     NULL,                               NULL, NULL
1369   },
1370
1371   // ---------- level and editor settings -------------------------------------
1372
1373   {
1374     ED_LEVEL_SETTINGS_XPOS(0),          ED_LEVEL_SETTINGS_YPOS(4),
1375     MIN_LEV_FIELDX,                     MAX_LEV_FIELDX,
1376     GADGET_ID_LEVEL_XSIZE_DOWN,         GADGET_ID_LEVEL_XSIZE_UP,
1377     GADGET_ID_LEVEL_XSIZE_TEXT,         GADGET_ID_NONE,
1378     &level.fieldx,
1379     "playfield size:",                  NULL, "width",
1380   },
1381   {
1382     -1,                                 ED_LEVEL_SETTINGS_YPOS(4),
1383     MIN_LEV_FIELDY,                     MAX_LEV_FIELDY,
1384     GADGET_ID_LEVEL_YSIZE_DOWN,         GADGET_ID_LEVEL_YSIZE_UP,
1385     GADGET_ID_LEVEL_YSIZE_TEXT,         GADGET_ID_LEVEL_XSIZE_UP,
1386     &level.fieldy,
1387     NULL,                               " ", "height",
1388   },
1389   {
1390     ED_LEVEL_SETTINGS_XPOS(0),          ED_LEVEL_SETTINGS_YPOS(5),
1391     0,                                  999,
1392     GADGET_ID_LEVEL_GEMSLIMIT_DOWN,     GADGET_ID_LEVEL_GEMSLIMIT_UP,
1393     GADGET_ID_LEVEL_GEMSLIMIT_TEXT,     GADGET_ID_NONE,
1394     &level.gems_needed,
1395     NULL,                               "number of gems to collect:", NULL
1396   },
1397   {
1398     ED_LEVEL_SETTINGS_XPOS(0),          ED_LEVEL_SETTINGS_YPOS(8),
1399     0,                                  9999,
1400     GADGET_ID_LEVEL_TIMELIMIT_DOWN,     GADGET_ID_LEVEL_TIMELIMIT_UP,
1401     GADGET_ID_LEVEL_TIMELIMIT_TEXT,     GADGET_ID_NONE,
1402     &level.time,
1403     "time or step limit to solve level:", NULL, NULL
1404   },
1405   {
1406     ED_LEVEL_SETTINGS_XPOS(0),          ED_LEVEL_SETTINGS_YPOS(10),
1407     0,                                  999,
1408     GADGET_ID_LEVEL_TIMESCORE_DOWN,     GADGET_ID_LEVEL_TIMESCORE_UP,
1409     GADGET_ID_LEVEL_TIMESCORE_TEXT,     GADGET_ID_NONE,
1410     &level.score[SC_TIME_BONUS],
1411     "score for each second/step left:", NULL, NULL
1412   },
1413   {
1414     ED_LEVEL_SETTINGS_XPOS(0),          ED_LEVEL_SETTINGS_YPOS(12),
1415     0,                                  9999,
1416     GADGET_ID_LEVEL_RANDOM_SEED_DOWN,   GADGET_ID_LEVEL_RANDOM_SEED_UP,
1417     GADGET_ID_LEVEL_RANDOM_SEED_TEXT,   GADGET_ID_NONE,
1418     &level.random_seed,
1419     NULL,                               "random seed:", "(0 => random)"
1420   },
1421   {
1422     ED_LEVEL_SETTINGS_XPOS(0),          ED_LEVEL_SETTINGS_YPOS(4),
1423     1,                                  MAX_LEVELS,
1424     GADGET_ID_LEVELSET_NUM_LEVELS_DOWN, GADGET_ID_LEVELSET_NUM_LEVELS_UP,
1425     GADGET_ID_LEVELSET_NUM_LEVELS_TEXT, GADGET_ID_NONE,
1426     &levelset_num_levels,
1427     "number of levels:",                NULL, NULL,
1428   },
1429   {
1430     ED_LEVEL_SETTINGS_XPOS(0),          ED_LEVEL_SETTINGS_YPOS(0),
1431     1,                                  100,
1432     GADGET_ID_LEVEL_RANDOM_DOWN,        GADGET_ID_LEVEL_RANDOM_UP,
1433     GADGET_ID_LEVEL_RANDOM_TEXT,        GADGET_ID_NONE,
1434     &random_placement_value,
1435     "random element placement:",        NULL, "in"
1436   },
1437
1438   // ---------- element settings: configure (various elements) ----------------
1439
1440   {
1441     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(0),
1442     MIN_SCORE,                          MAX_SCORE,
1443     GADGET_ID_ELEMENT_VALUE1_DOWN,      GADGET_ID_ELEMENT_VALUE1_UP,
1444     GADGET_ID_ELEMENT_VALUE1_TEXT,      GADGET_ID_NONE,
1445     NULL,                               // will be set when used
1446     NULL,                               NULL, NULL
1447   },
1448   {
1449     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(1),
1450     MIN_SCORE,                          MAX_SCORE,
1451     GADGET_ID_ELEMENT_VALUE2_DOWN,      GADGET_ID_ELEMENT_VALUE2_UP,
1452     GADGET_ID_ELEMENT_VALUE2_TEXT,      GADGET_ID_NONE,
1453     NULL,                               // will be set when used
1454     NULL,                               NULL, NULL
1455   },
1456   {
1457     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(2),
1458     MIN_SCORE,                          MAX_SCORE,
1459     GADGET_ID_ELEMENT_VALUE3_DOWN,      GADGET_ID_ELEMENT_VALUE3_UP,
1460     GADGET_ID_ELEMENT_VALUE3_TEXT,      GADGET_ID_NONE,
1461     NULL,                               // will be set when used
1462     NULL,                               NULL, NULL
1463   },
1464   {
1465     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(3),
1466     MIN_SCORE,                          MAX_SCORE,
1467     GADGET_ID_ELEMENT_VALUE4_DOWN,      GADGET_ID_ELEMENT_VALUE4_UP,
1468     GADGET_ID_ELEMENT_VALUE4_TEXT,      GADGET_ID_NONE,
1469     NULL,                               // will be set when used
1470     NULL,                               NULL, NULL
1471   },
1472   {
1473     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(3),
1474     MIN_ELEMENT_CONTENTS,               MAX_ELEMENT_CONTENTS,
1475     GADGET_ID_YAMYAM_CONTENT_DOWN,      GADGET_ID_YAMYAM_CONTENT_UP,
1476     GADGET_ID_YAMYAM_CONTENT_TEXT,      GADGET_ID_NONE,
1477     &level.num_yamyam_contents,
1478     NULL,                               NULL, "number of content areas"
1479   },
1480   {
1481     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(4),
1482     MIN_ELEMENT_CONTENTS,               MAX_ELEMENT_CONTENTS,
1483     GADGET_ID_BALL_CONTENT_DOWN,        GADGET_ID_BALL_CONTENT_UP,
1484     GADGET_ID_BALL_CONTENT_TEXT,        GADGET_ID_NONE,
1485     &level.num_ball_contents,
1486     NULL,                               NULL, "number of content areas"
1487   },
1488   {
1489     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(4),
1490     MIN_ANDROID_ELEMENTS,               MAX_ANDROID_ELEMENTS,
1491     GADGET_ID_ANDROID_CONTENT_DOWN,     GADGET_ID_ANDROID_CONTENT_UP,
1492     GADGET_ID_ANDROID_CONTENT_TEXT,     GADGET_ID_NONE,
1493     &level.num_android_clone_elements,
1494     NULL,                               NULL, "number of clonable elements"
1495   },
1496   {
1497     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(0),
1498     MIN_ENVELOPE_XSIZE,                 MAX_ENVELOPE_XSIZE,
1499     GADGET_ID_ENVELOPE_XSIZE_DOWN,      GADGET_ID_ENVELOPE_XSIZE_UP,
1500     GADGET_ID_ENVELOPE_XSIZE_TEXT,      GADGET_ID_NONE,
1501     NULL,                               // will be set when used
1502     NULL,                               NULL, "width",
1503   },
1504   {
1505     -1,                                 ED_ELEMENT_SETTINGS_YPOS(0),
1506     MIN_ENVELOPE_YSIZE,                 MAX_ENVELOPE_YSIZE,
1507     GADGET_ID_ENVELOPE_YSIZE_DOWN,      GADGET_ID_ENVELOPE_YSIZE_UP,
1508     GADGET_ID_ENVELOPE_YSIZE_TEXT,      GADGET_ID_ENVELOPE_XSIZE_UP,
1509     NULL,                               // will be set when used
1510     NULL,                               " ", "height",
1511   },
1512   {
1513     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(2),
1514     MIN_INITIAL_INVENTORY_SIZE,         MAX_INITIAL_INVENTORY_SIZE,
1515     GADGET_ID_INVENTORY_SIZE_DOWN,      GADGET_ID_INVENTORY_SIZE_UP,
1516     GADGET_ID_INVENTORY_SIZE_TEXT,      GADGET_ID_NONE,
1517     &level.initial_inventory_size[0],
1518     NULL,                               NULL, "number of inventory elements"
1519   },
1520
1521   // ---------- element settings: configure 1 (custom elements) ---------------
1522
1523   {
1524     ED_ELEMENT_SETTINGS_XPOS(1),        ED_ELEMENT_SETTINGS_YPOS(5),
1525     MIN_SCORE,                          MAX_SCORE,
1526     GADGET_ID_CUSTOM_SCORE_DOWN,        GADGET_ID_CUSTOM_SCORE_UP,
1527     GADGET_ID_CUSTOM_SCORE_TEXT,        GADGET_ID_NONE,
1528     &custom_element.collect_score_initial,
1529     NULL,                               "CE score", " "
1530   },
1531   {
1532     -1,                                 ED_ELEMENT_SETTINGS_YPOS(5),
1533     MIN_COLLECT_COUNT,                  MAX_COLLECT_COUNT,
1534     GADGET_ID_CUSTOM_GEMCOUNT_DOWN,     GADGET_ID_CUSTOM_GEMCOUNT_UP,
1535     GADGET_ID_CUSTOM_GEMCOUNT_TEXT,     GADGET_ID_CUSTOM_SCORE_UP,
1536     &custom_element.collect_count_initial,
1537     NULL,                               "CE count", NULL
1538   },
1539   {
1540     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(10),
1541     0,                                  9999,
1542     GADGET_ID_CUSTOM_VALUE_FIX_DOWN,    GADGET_ID_CUSTOM_VALUE_FIX_UP,
1543     GADGET_ID_CUSTOM_VALUE_FIX_TEXT,    GADGET_ID_NONE,
1544     &custom_element.ce_value_fixed_initial,
1545     NULL,                               "CE value", NULL
1546   },
1547   {
1548     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(10),
1549     0,                                  9999,
1550     GADGET_ID_CUSTOM_VALUE_RND_DOWN,    GADGET_ID_CUSTOM_VALUE_RND_UP,
1551     GADGET_ID_CUSTOM_VALUE_RND_TEXT,    GADGET_ID_CUSTOM_VALUE_FIX_UP,
1552     &custom_element.ce_value_random_initial,
1553     NULL,                               "+random", NULL
1554   },
1555   {
1556     ED_ELEMENT_SETTINGS_XPOS(1),        ED_ELEMENT_SETTINGS_YPOS(6),
1557     0,                                  999,
1558     GADGET_ID_PUSH_DELAY_FIX_DOWN,      GADGET_ID_PUSH_DELAY_FIX_UP,
1559     GADGET_ID_PUSH_DELAY_FIX_TEXT,      GADGET_ID_NONE,
1560     &custom_element.push_delay_fixed,
1561     NULL,                               "push delay", NULL
1562   },
1563   {
1564     -1,                                 ED_ELEMENT_SETTINGS_YPOS(6),
1565     0,                                  999,
1566     GADGET_ID_PUSH_DELAY_RND_DOWN,      GADGET_ID_PUSH_DELAY_RND_UP,
1567     GADGET_ID_PUSH_DELAY_RND_TEXT,      GADGET_ID_PUSH_DELAY_FIX_UP,
1568     &custom_element.push_delay_random,
1569     NULL,                               "+random", NULL
1570   },
1571   {
1572     ED_ELEMENT_SETTINGS_XPOS(1),        ED_ELEMENT_SETTINGS_YPOS(7),
1573     0,                                  999,
1574     GADGET_ID_DROP_DELAY_FIX_DOWN,      GADGET_ID_DROP_DELAY_FIX_UP,
1575     GADGET_ID_DROP_DELAY_FIX_TEXT,      GADGET_ID_NONE,
1576     &custom_element.drop_delay_fixed,
1577     NULL,                               "drop delay", NULL
1578   },
1579   {
1580     -1,                                 ED_ELEMENT_SETTINGS_YPOS(7),
1581     0,                                  999,
1582     GADGET_ID_DROP_DELAY_RND_DOWN,      GADGET_ID_DROP_DELAY_RND_UP,
1583     GADGET_ID_DROP_DELAY_RND_TEXT,      GADGET_ID_DROP_DELAY_FIX_UP,
1584     &custom_element.drop_delay_random,
1585     NULL,                               "+random", NULL
1586   },
1587
1588   // ---------- element settings: configure 2 (custom elements) ---------------
1589
1590   {
1591     ED_ELEMENT_SETTINGS_XPOS(1),        ED_ELEMENT_SETTINGS_YPOS(5),
1592     0,                                  999,
1593     GADGET_ID_MOVE_DELAY_FIX_DOWN,      GADGET_ID_MOVE_DELAY_FIX_UP,
1594     GADGET_ID_MOVE_DELAY_FIX_TEXT,      GADGET_ID_NONE,
1595     &custom_element.move_delay_fixed,
1596     NULL,                               "move delay", NULL
1597   },
1598   {
1599     -1,                                 ED_ELEMENT_SETTINGS_YPOS(5),
1600     0,                                  999,
1601     GADGET_ID_MOVE_DELAY_RND_DOWN,      GADGET_ID_MOVE_DELAY_RND_UP,
1602     GADGET_ID_MOVE_DELAY_RND_TEXT,      GADGET_ID_MOVE_DELAY_FIX_UP,
1603     &custom_element.move_delay_random,
1604     NULL,                               "+random", NULL
1605   },
1606   {
1607     ED_ELEMENT_SETTINGS_XPOS(1),        ED_ELEMENT_SETTINGS_YPOS(12),
1608     0,                                  999,
1609     GADGET_ID_EXPLOSION_DELAY_DOWN,     GADGET_ID_EXPLOSION_DELAY_UP,
1610     GADGET_ID_EXPLOSION_DELAY_TEXT,     GADGET_ID_NONE,
1611     &custom_element.explosion_delay,
1612     NULL,                               "explosion delay", NULL
1613   },
1614   {
1615     ED_ELEMENT_SETTINGS_XPOS(1),        ED_ELEMENT_SETTINGS_YPOS(13),
1616     0,                                  999,
1617     GADGET_ID_IGNITION_DELAY_DOWN,      GADGET_ID_IGNITION_DELAY_UP,
1618     GADGET_ID_IGNITION_DELAY_TEXT,      GADGET_ID_NONE,
1619     &custom_element.ignition_delay,
1620     NULL,                               "ignition delay", "(by fire)"
1621   },
1622
1623   // ---------- element settings: configure (group elements) ------------------
1624
1625   {
1626     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(3),
1627     MIN_ELEMENTS_IN_GROUP,              MAX_ELEMENTS_IN_GROUP,
1628     GADGET_ID_GROUP_CONTENT_DOWN,       GADGET_ID_GROUP_CONTENT_UP,
1629     GADGET_ID_GROUP_CONTENT_TEXT,       GADGET_ID_NONE,
1630     &group_element_info.num_elements,
1631     NULL,                               NULL, "number of elements in group"
1632   },
1633
1634   // ---------- element settings: advanced (custom elements) ------------------
1635
1636   {
1637     ED_ELEMENT_SETTINGS_XPOS(2),        ED_ELEMENT_SETTINGS_YPOS(2),
1638     0,                                  999,
1639     GADGET_ID_CHANGE_DELAY_FIX_DOWN,    GADGET_ID_CHANGE_DELAY_FIX_UP,
1640     GADGET_ID_CHANGE_DELAY_FIX_TEXT,    GADGET_ID_NONE,
1641     &custom_element_change.delay_fixed,
1642     NULL,                               "CE delay", NULL,
1643   },
1644   {
1645     -1,                                 ED_ELEMENT_SETTINGS_YPOS(2),
1646     0,                                  999,
1647     GADGET_ID_CHANGE_DELAY_RND_DOWN,    GADGET_ID_CHANGE_DELAY_RND_UP,
1648     GADGET_ID_CHANGE_DELAY_RND_TEXT,    GADGET_ID_CHANGE_DELAY_FIX_UP,
1649     &custom_element_change.delay_random,
1650     NULL,                               "+random", NULL
1651   },
1652   {
1653     ED_ELEMENT_SETTINGS_XPOS(3),        ED_ELEMENT_SETTINGS_YPOS(12),
1654     0,                                  100,
1655     GADGET_ID_CHANGE_CONT_RND_DOWN,     GADGET_ID_CHANGE_CONT_RND_UP,
1656     GADGET_ID_CHANGE_CONT_RND_TEXT,     GADGET_ID_NONE,
1657     &custom_element_change.random_percentage,
1658     NULL,                               "use random replace:", "%"
1659   },
1660 };
1661
1662 static struct
1663 {
1664   int x, y;
1665   int gadget_id;
1666   int size;
1667   char *value;
1668   char *text_above, *infotext;
1669 } textinput_info[ED_NUM_TEXTINPUT] =
1670 {
1671   {
1672     ED_LEVEL_SETTINGS_XPOS(0),          ED_LEVEL_SETTINGS_YPOS(0),
1673     GADGET_ID_LEVEL_NAME,
1674     MAX_LEVEL_NAME_LEN,
1675     level.name,
1676     "Title:", "Title for this level"
1677   },
1678   {
1679     ED_LEVEL_SETTINGS_XPOS(0),          ED_LEVEL_SETTINGS_YPOS(2),
1680     GADGET_ID_LEVEL_AUTHOR,
1681     MAX_LEVEL_AUTHOR_LEN,
1682     level.author,
1683     "Author:", "Author for this level"
1684   },
1685   {
1686     ED_LEVEL_SETTINGS_XPOS(0),          ED_LEVEL_SETTINGS_YPOS(0),
1687     GADGET_ID_LEVELSET_NAME,
1688     MAX_LEVEL_NAME_LEN,
1689     levelset_name,
1690     "Title:", "Title for this or new level set"
1691   },
1692   {
1693     ED_LEVEL_SETTINGS_XPOS(0),          ED_LEVEL_SETTINGS_YPOS(2),
1694     GADGET_ID_LEVELSET_AUTHOR,
1695     MAX_LEVEL_AUTHOR_LEN,
1696     levelset_author,
1697     "Author:", "Author for this or new level set"
1698   },
1699   {
1700     -1, -1,     // these values are not constant, but can change at runtime
1701     GADGET_ID_ELEMENT_NAME,
1702     MAX_ELEMENT_NAME_LEN - 2,           // currently 2 chars less editable
1703     custom_element.description,
1704     NULL, "Element name"
1705   }
1706 };
1707
1708 static struct
1709 {
1710   int x, y;
1711   int gadget_id;
1712   int xsize, ysize;
1713   char *value;
1714   char *text_above, *infotext;
1715 } textarea_info[ED_NUM_TEXTAREAS] =
1716 {
1717   {
1718     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(3),
1719     GADGET_ID_ENVELOPE_INFO,
1720     MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1721     NULL,
1722     "Envelope Content:", "Envelope Content"
1723   }
1724 };
1725
1726 static struct ValueTextInfo options_time_or_steps[] =
1727 {
1728   { 0,                          "seconds"                       },
1729   { 1,                          "steps"                         },
1730
1731   { -1,                         NULL                            }
1732 };
1733
1734 static struct ValueTextInfo options_game_engine_type[] =
1735 {
1736   { GAME_ENGINE_TYPE_RND,       "Rocks'n'Diamonds"              },
1737   { GAME_ENGINE_TYPE_EM,        "Emerald Mine"                  },
1738   { GAME_ENGINE_TYPE_SP,        "Supaplex"                      },
1739   { GAME_ENGINE_TYPE_MM,        "Mirror Magic"                  },
1740
1741   { -1,                         NULL                            }
1742 };
1743
1744 static struct ValueTextInfo options_levelset_save_mode[] =
1745 {
1746   { LEVELSET_SAVE_MODE_UPDATE,  "Update this level set"         },
1747   { LEVELSET_SAVE_MODE_CREATE,  "Create new level set"          },
1748
1749   { -1,                         NULL                            }
1750 };
1751
1752 static struct ValueTextInfo options_wind_direction[] =
1753 {
1754   { MV_START_NONE,              "none"                          },
1755   { MV_START_LEFT,              "left"                          },
1756   { MV_START_RIGHT,             "right"                         },
1757   { MV_START_UP,                "up"                            },
1758   { MV_START_DOWN,              "down"                          },
1759
1760   { -1,                         NULL                            }
1761 };
1762
1763 static struct ValueTextInfo options_player_speed[] =
1764 {
1765   { 0,                          "frozen"                        },
1766   { 1,                          "very slow"                     },
1767   { 2,                          "slow"                          },
1768   { 4,                          "normal"                        },
1769   { 8,                          "fast"                          },
1770   { 16,                         "very fast"                     },
1771   { 32,                         "ultrafast"                     },
1772
1773   { -1,                         NULL                            }
1774 };
1775
1776 static struct ValueTextInfo options_access_type[] =
1777 {
1778   { EP_WALKABLE,                "walkable"                      },
1779   { EP_PASSABLE,                "passable"                      },
1780
1781   { -1,                         NULL                            }
1782 };
1783
1784 static struct ValueTextInfo options_access_layer[] =
1785 {
1786   { EP_ACCESSIBLE_OVER,         "over"                          },
1787   { EP_ACCESSIBLE_INSIDE,       "inside"                        },
1788   { EP_ACCESSIBLE_UNDER,        "under"                         },
1789
1790   { -1,                         NULL                            }
1791 };
1792
1793 static struct ValueTextInfo options_access_protected[] =
1794 {
1795   { 0,                          "unprotected"                   },
1796   { 1,                          "protected"                     },
1797
1798   { -1,                         NULL                            }
1799 };
1800
1801 static struct ValueTextInfo options_access_direction[] =
1802 {
1803   { MV_NO_DIRECTION,            "no direction"                  },
1804   { MV_LEFT,                    "left"                          },
1805   { MV_RIGHT,                   "right"                         },
1806   { MV_UP,                      "up"                            },
1807   { MV_DOWN,                    "down"                          },
1808   { MV_LEFT  | MV_UP,           "left + up"                     },
1809   { MV_LEFT  | MV_DOWN,         "left + down"                   },
1810   { MV_RIGHT | MV_UP,           "right + up"                    },
1811   { MV_RIGHT | MV_DOWN,         "right + down"                  },
1812   { MV_HORIZONTAL,              "horizontal"                    },
1813   { MV_VERTICAL,                "vertical"                      },
1814   { MV_HORIZONTAL | MV_UP,      "horizontal + up"               },
1815   { MV_HORIZONTAL | MV_DOWN,    "horizontal + down"             },
1816   { MV_VERTICAL   | MV_LEFT,    "vertical + left"               },
1817   { MV_VERTICAL   | MV_RIGHT,   "vertical + right"              },
1818   { MV_ALL_DIRECTIONS,          "all directions"                },
1819
1820   { -1,                         NULL                            }
1821 };
1822
1823 static struct ValueTextInfo options_walk_to_action[] =
1824 {
1825   { EP_DIGGABLE,                "diggable"                      },
1826   { EP_COLLECTIBLE_ONLY,        "collectible"                   },
1827   { EP_DROPPABLE,               "collectible & droppable"       },
1828   { EP_THROWABLE,               "collectible & throwable"       },
1829   { EP_PUSHABLE,                "pushable"                      },
1830
1831   { -1,                         NULL                            }
1832 };
1833
1834 static struct ValueTextInfo options_move_pattern[] =
1835 {
1836   { MV_LEFT,                    "left"                          },
1837   { MV_RIGHT,                   "right"                         },
1838   { MV_UP,                      "up"                            },
1839   { MV_DOWN,                    "down"                          },
1840   { MV_HORIZONTAL,              "horizontal"                    },
1841   { MV_VERTICAL,                "vertical"                      },
1842   { MV_ALL_DIRECTIONS,          "all directions"                },
1843   { MV_WIND_DIRECTION,          "wind direction"                },
1844   { MV_TOWARDS_PLAYER,          "towards player"                },
1845   { MV_AWAY_FROM_PLAYER,        "away from player"              },
1846   { MV_ALONG_LEFT_SIDE,         "along left side"               },
1847   { MV_ALONG_RIGHT_SIDE,        "along right side"              },
1848   { MV_TURNING_LEFT,            "turning left"                  },
1849   { MV_TURNING_RIGHT,           "turning right"                 },
1850   { MV_TURNING_LEFT_RIGHT,      "turning left, right"           },
1851   { MV_TURNING_RIGHT_LEFT,      "turning right, left"           },
1852   { MV_TURNING_RANDOM,          "turning random"                },
1853   { MV_MAZE_RUNNER,             "maze runner style"             },
1854   { MV_MAZE_HUNTER,             "maze hunter style"             },
1855   { MV_WHEN_PUSHED,             "when pushed"                   },
1856   { MV_WHEN_DROPPED,            "when dropped/thrown"           },
1857
1858   { -1,                         NULL                            }
1859 };
1860
1861 static struct ValueTextInfo options_move_direction[] =
1862 {
1863   { MV_START_AUTOMATIC,         "automatic"                     },
1864   { MV_START_LEFT,              "left"                          },
1865   { MV_START_RIGHT,             "right"                         },
1866   { MV_START_UP,                "up"                            },
1867   { MV_START_DOWN,              "down"                          },
1868   { MV_START_RANDOM,            "random"                        },
1869   { MV_START_PREVIOUS,          "previous"                      },
1870
1871   { -1,                         NULL                            }
1872 };
1873
1874 static struct ValueTextInfo options_move_stepsize[] =
1875 {
1876   { 0,                          "not moving"                    },
1877   { 1,                          "very slow"                     },
1878   { 2,                          "slow"                          },
1879   { 4,                          "normal"                        },
1880   { 8,                          "fast"                          },
1881   { 16,                         "very fast"                     },
1882   { 32,                         "even faster"                   },
1883
1884   { -1,                         NULL                            }
1885 };
1886
1887 static struct ValueTextInfo options_move_leave_type[] =
1888 {
1889   { LEAVE_TYPE_UNLIMITED,       "leave behind"                  },
1890   { LEAVE_TYPE_LIMITED,         "change it to"                  },
1891
1892   { -1,                         NULL                            }
1893 };
1894
1895 static struct ValueTextInfo options_smash_targets[] =
1896 {
1897   { EP_CAN_SMASH_PLAYER,        "player"                        },
1898 #if 0
1899   { EP_CAN_SMASH_ENEMIES,       "enemies"                       },
1900 #endif
1901   { EP_CAN_SMASH_EVERYTHING,    "everything"                    },
1902
1903   { -1,                         NULL                            }
1904 };
1905
1906 static struct ValueTextInfo options_slippery_type[] =
1907 {
1908   { SLIPPERY_ANY_RANDOM,        "random"                        },
1909   { SLIPPERY_ANY_LEFT_RIGHT,    "left, right"                   },
1910   { SLIPPERY_ANY_RIGHT_LEFT,    "right, left"                   },
1911   { SLIPPERY_ONLY_LEFT,         "only left"                     },
1912   { SLIPPERY_ONLY_RIGHT,        "only right"                    },
1913
1914   { -1,                         NULL                            }
1915 };
1916
1917 static struct ValueTextInfo options_deadliness[] =
1918 {
1919   { EP_DONT_RUN_INTO,           "running into"                  },
1920   { EP_DONT_COLLIDE_WITH,       "colliding with"                },
1921   { EP_DONT_GET_HIT_BY,         "getting hit by"                },
1922   { EP_DONT_TOUCH,              "touching"                      },
1923
1924   { -1,                         NULL                            }
1925 };
1926
1927 static struct ValueTextInfo options_explosion_type[] =
1928 {
1929   { EXPLODES_3X3,               "3x3"                           },
1930   { EXPLODES_CROSS,             "3+3"                           },
1931   { EXPLODES_1X1,               "1x1"                           },
1932
1933   { -1,                         NULL                            }
1934 };
1935
1936 static struct ValueTextInfo options_time_units[] =
1937 {
1938   { 1,                          "frames"                        },
1939   { FRAMES_PER_SECOND,          "seconds"                       },
1940
1941   { -1,                         NULL                            }
1942 };
1943
1944 static struct ValueTextInfo options_change_direct_action[] =
1945 {
1946   { CE_TOUCHED_BY_PLAYER,       "touched by player"             },
1947   { CE_PRESSED_BY_PLAYER,       "pressed by player"             },
1948   { CE_SWITCHED_BY_PLAYER,      "switched by player"            },
1949   { CE_SNAPPED_BY_PLAYER,       "snapped by player"             },
1950   { CE_PUSHED_BY_PLAYER,        "pushed by player"              },
1951   { CE_ENTERED_BY_PLAYER,       "entered by player"             },
1952   { CE_LEFT_BY_PLAYER,          "left by player"                },
1953   { CE_DROPPED_BY_PLAYER,       "dropped/thrown by player"      },
1954   { CE_SWITCHED,                "switched"                      },
1955   { CE_HITTING_SOMETHING,       "hitting something"             },
1956   { CE_HIT_BY_SOMETHING,        "hit by something"              },
1957 #if 0
1958   { CE_BLOCKED,                 "blocked"                       },
1959 #endif
1960   { CE_IMPACT,                  "impact (on something)"         },
1961   { CE_SMASHED,                 "smashed (from above)"          },
1962 #if 0
1963   { CE_VALUE_CHANGES,           "CE value changes"              },
1964   { CE_SCORE_CHANGES,           "CE score changes"              },
1965 #endif
1966   { CE_VALUE_GETS_ZERO,         "CE value gets 0"               },
1967   { CE_SCORE_GETS_ZERO,         "CE score gets 0"               },
1968
1969   { -1,                         NULL                            }
1970 };
1971
1972 static struct ValueTextInfo options_change_other_action[] =
1973 {
1974   { CE_PLAYER_TOUCHES_X,        "player touches"                },
1975   { CE_PLAYER_PRESSES_X,        "player presses"                },
1976   { CE_PLAYER_SWITCHES_X,       "player switches"               },
1977   { CE_PLAYER_SNAPS_X,          "player snaps"                  },
1978   { CE_PLAYER_PUSHES_X,         "player pushes"                 },
1979   { CE_PLAYER_ENTERS_X,         "player enters"                 },
1980   { CE_PLAYER_LEAVES_X,         "player leaves"                 },
1981   { CE_PLAYER_DIGS_X,           "player digs"                   },
1982   { CE_PLAYER_COLLECTS_X,       "player collects"               },
1983   { CE_PLAYER_DROPS_X,          "player drops/throws"           },
1984   { CE_TOUCHING_X,              "touching"                      },
1985   { CE_HITTING_X,               "hitting"                       },
1986   { CE_DIGGING_X,               "digging"                       },
1987   { CE_HIT_BY_X,                "hit by"                        },
1988   { CE_SWITCH_OF_X,             "switch of"                     },
1989   { CE_CHANGE_OF_X,             "change by page of"             },
1990   { CE_EXPLOSION_OF_X,          "explosion of"                  },
1991   { CE_MOVE_OF_X,               "move of"                       },
1992   { CE_CREATION_OF_X,           "creation of"                   },
1993   { CE_VALUE_CHANGES_OF_X,      "CE value changes of"           },
1994   { CE_SCORE_CHANGES_OF_X,      "CE score changes of"           },
1995   { CE_VALUE_GETS_ZERO_OF_X,    "CE value gets 0 of"            },
1996   { CE_SCORE_GETS_ZERO_OF_X,    "CE score gets 0 of"            },
1997
1998   { -1,                         NULL                            }
1999 };
2000
2001 static struct ValueTextInfo options_change_trigger_side[] =
2002 {
2003   { CH_SIDE_LEFT,               "left"                          },
2004   { CH_SIDE_RIGHT,              "right"                         },
2005   { CH_SIDE_TOP,                "top"                           },
2006   { CH_SIDE_BOTTOM,             "bottom"                        },
2007   { CH_SIDE_LEFT_RIGHT,         "left/right"                    },
2008   { CH_SIDE_TOP_BOTTOM,         "top/bottom"                    },
2009   { CH_SIDE_ANY,                "any"                           },
2010
2011   { -1,                         NULL                            }
2012 };
2013
2014 static struct ValueTextInfo options_change_trigger_player[] =
2015 {
2016   { CH_PLAYER_1,                "1"                             },
2017   { CH_PLAYER_2,                "2"                             },
2018   { CH_PLAYER_3,                "3"                             },
2019   { CH_PLAYER_4,                "4"                             },
2020   { CH_PLAYER_ANY,              "any"                           },
2021
2022   { -1,                         NULL                            }
2023 };
2024
2025 static struct ValueTextInfo options_change_trigger_page[] =
2026 {
2027   { (1 << 0),                   "1"                             },
2028   { (1 << 1),                   "2"                             },
2029   { (1 << 2),                   "3"                             },
2030   { (1 << 3),                   "4"                             },
2031   { (1 << 4),                   "5"                             },
2032   { (1 << 5),                   "6"                             },
2033   { (1 << 6),                   "7"                             },
2034   { (1 << 7),                   "8"                             },
2035   { (1 << 8),                   "9"                             },
2036   { (1 << 9),                   "10"                            },
2037   { (1 << 10),                  "11"                            },
2038   { (1 << 11),                  "12"                            },
2039   { (1 << 12),                  "13"                            },
2040   { (1 << 13),                  "14"                            },
2041   { (1 << 14),                  "15"                            },
2042   { (1 << 15),                  "16"                            },
2043   { (1 << 16),                  "17"                            },
2044   { (1 << 17),                  "18"                            },
2045   { (1 << 18),                  "19"                            },
2046   { (1 << 19),                  "20"                            },
2047   { (1 << 20),                  "21"                            },
2048   { (1 << 21),                  "22"                            },
2049   { (1 << 22),                  "23"                            },
2050   { (1 << 23),                  "24"                            },
2051   { (1 << 24),                  "25"                            },
2052   { (1 << 25),                  "26"                            },
2053   { (1 << 26),                  "27"                            },
2054   { (1 << 27),                  "28"                            },
2055   { (1 << 28),                  "29"                            },
2056   { (1 << 29),                  "30"                            },
2057   { (1 << 30),                  "31"                            },
2058   { (1 << 31),                  "32"                            },
2059   { CH_PAGE_ANY,                "any"                           },
2060
2061   { -1,                         NULL                            }
2062 };
2063
2064 static struct ValueTextInfo options_change_replace_when[] =
2065 {
2066   { CP_WHEN_EMPTY,              "empty"                         },
2067   { CP_WHEN_WALKABLE,           "walkable"                      },
2068   { CP_WHEN_DIGGABLE,           "diggable"                      },
2069   { CP_WHEN_COLLECTIBLE,        "collectible"                   },
2070   { CP_WHEN_REMOVABLE,          "removable"                     },
2071   { CP_WHEN_DESTRUCTIBLE,       "destructible"                  },
2072
2073   { -1,                         NULL                            }
2074 };
2075
2076 static struct ValueTextInfo options_action_type[] =
2077 {
2078   { CA_NO_ACTION,               "no action"                     },
2079   { CA_UNDEFINED,               " "                             },
2080   { CA_HEADLINE_LEVEL_ACTIONS,  "[level]"                       },
2081   { CA_RESTART_LEVEL,           "restart level"                 },
2082   { CA_SHOW_ENVELOPE,           "show envelope"                 },
2083   { CA_SET_LEVEL_TIME,          "set time"                      },
2084   { CA_SET_LEVEL_SCORE,         "set score"                     },
2085   { CA_SET_LEVEL_GEMS,          "set gems"                      },
2086   { CA_SET_LEVEL_WIND,          "set wind dir."                 },
2087   { CA_SET_LEVEL_RANDOM_SEED,   "set rand. seed"                },
2088   { CA_UNDEFINED,               " "                             },
2089   { CA_HEADLINE_PLAYER_ACTIONS, "[player]"                      },
2090   { CA_MOVE_PLAYER,             "move player"                   },
2091   { CA_EXIT_PLAYER,             "exit player"                   },
2092   { CA_KILL_PLAYER,             "kill player"                   },
2093   { CA_SET_PLAYER_KEYS,         "set keys"                      },
2094   { CA_SET_PLAYER_SPEED,        "set speed"                     },
2095   { CA_SET_PLAYER_SHIELD,       "set shield"                    },
2096   { CA_SET_PLAYER_GRAVITY,      "set gravity"                   },
2097   { CA_SET_PLAYER_ARTWORK,      "set artwork"                   },
2098   { CA_SET_PLAYER_INVENTORY,    "set inventory"                 },
2099   { CA_UNDEFINED,               " "                             },
2100   { CA_HEADLINE_CE_ACTIONS,     "[CE]"                          },
2101   { CA_SET_CE_VALUE,            "set CE value"                  },
2102   { CA_SET_CE_SCORE,            "set CE score"                  },
2103   { CA_SET_CE_ARTWORK,          "set CE artwork"                },
2104   { CA_UNDEFINED,               " "                             },
2105   { CA_HEADLINE_ENGINE_ACTIONS, "[engine]"                      },
2106   { CA_SET_ENGINE_SCAN_MODE,    "set scan mode"                 },
2107
2108   { -1,                         NULL                            }
2109 };
2110
2111 static struct ValueTextInfo options_action_mode_none[] =
2112 {
2113   { CA_MODE_UNDEFINED,          " "                             },
2114
2115   { -1,                         NULL                            }
2116 };
2117
2118 static struct ValueTextInfo options_action_mode_assign[] =
2119 {
2120   { CA_MODE_SET,                "="                             },
2121
2122   { -1,                         NULL                            }
2123 };
2124
2125 static struct ValueTextInfo options_action_mode_add_remove[] =
2126 {
2127   { CA_MODE_ADD,                "+"                             },
2128   { CA_MODE_SUBTRACT,           "-"                             },
2129
2130   { -1,                         NULL                            }
2131 };
2132
2133 static struct ValueTextInfo options_action_mode_calculate[] =
2134 {
2135   { CA_MODE_SET,                "="                             },
2136   { CA_MODE_ADD,                "+"                             },
2137   { CA_MODE_SUBTRACT,           "-"                             },
2138   { CA_MODE_MULTIPLY,           "*"                             },
2139   { CA_MODE_DIVIDE,             "/"                             },
2140   { CA_MODE_MODULO,             "%"                             },
2141
2142   { -1,                         NULL                            }
2143 };
2144
2145 static struct ValueTextInfo options_action_arg_none[] =
2146 {
2147   { CA_ARG_UNDEFINED,           "         "                     },
2148
2149   { -1,                         NULL                            }
2150 };
2151
2152 static struct ValueTextInfo options_action_arg_player[] =
2153 {
2154   { CA_ARG_PLAYER_HEADLINE,     "[player]"                      },
2155   { CA_ARG_PLAYER_1,            "1"                             },
2156   { CA_ARG_PLAYER_2,            "2"                             },
2157   { CA_ARG_PLAYER_3,            "3"                             },
2158   { CA_ARG_PLAYER_4,            "4"                             },
2159   { CA_ARG_PLAYER_ANY,          "any"                           },
2160   { CA_ARG_PLAYER_TRIGGER,      "trigger"                       },
2161   { CA_ARG_PLAYER_ACTION,       "action ->"                     },
2162
2163   { -1,                         NULL                            }
2164 };
2165
2166 static struct ValueTextInfo options_action_arg_number[] =
2167 {
2168   { CA_ARG_NUMBER_HEADLINE,     "[number]"                      },
2169   { CA_ARG_0,                   "0"                             },
2170   { CA_ARG_1,                   "1"                             },
2171   { CA_ARG_2,                   "2"                             },
2172   { CA_ARG_3,                   "3"                             },
2173   { CA_ARG_4,                   "4"                             },
2174   { CA_ARG_5,                   "5"                             },
2175   { CA_ARG_10,                  "10"                            },
2176   { CA_ARG_100,                 "100"                           },
2177   { CA_ARG_1000,                "1000"                          },
2178   { CA_ARG_UNDEFINED,           " "                             },
2179   { CA_ARG_NUMBER_MIN,          "min"                           },
2180   { CA_ARG_NUMBER_MAX,          "max"                           },
2181   { CA_ARG_UNDEFINED,           " "                             },
2182   { CA_ARG_NUMBER_RESET,        "reset"                         },
2183   { CA_ARG_UNDEFINED,           " "                             },
2184   { CA_ARG_NUMBER_CE_VALUE,     "CE value"                      },
2185   { CA_ARG_NUMBER_CE_SCORE,     "CE score"                      },
2186   { CA_ARG_NUMBER_CE_DELAY,     "CE delay"                      },
2187   { CA_ARG_UNDEFINED,           " "                             },
2188   { CA_ARG_NUMBER_LEVEL_TIME,   "time"                          },
2189   { CA_ARG_NUMBER_LEVEL_GEMS,   "gems"                          },
2190   { CA_ARG_NUMBER_LEVEL_SCORE,  "score"                         },
2191   { CA_ARG_UNDEFINED,           " "                             },
2192   { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]"                    },
2193   { CA_ARG_ELEMENT_CV_TARGET,   "target"                        },
2194   { CA_ARG_ELEMENT_CV_TRIGGER,  "trigger"                       },
2195   { CA_ARG_ELEMENT_CV_ACTION,   "action ->"                     },
2196   { CA_ARG_UNDEFINED,           " "                             },
2197   { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]"                    },
2198   { CA_ARG_ELEMENT_CS_TARGET,   "target"                        },
2199   { CA_ARG_ELEMENT_CS_TRIGGER,  "trigger"                       },
2200   { CA_ARG_ELEMENT_CS_ACTION,   "action ->"                     },
2201
2202   { -1,                         NULL                            }
2203 };
2204
2205 static struct ValueTextInfo options_action_arg_value[] =
2206 {
2207   { CA_ARG_NUMBER_HEADLINE,     "[number]"                      },
2208   { CA_ARG_0,                   "0"                             },
2209   { CA_ARG_1,                   "1"                             },
2210   { CA_ARG_2,                   "2"                             },
2211   { CA_ARG_3,                   "3"                             },
2212   { CA_ARG_4,                   "4"                             },
2213   { CA_ARG_5,                   "5"                             },
2214   { CA_ARG_10,                  "10"                            },
2215   { CA_ARG_100,                 "100"                           },
2216   { CA_ARG_1000,                "1000"                          },
2217   { CA_ARG_UNDEFINED,           " "                             },
2218   { CA_ARG_NUMBER_MIN,          "min"                           },
2219   { CA_ARG_NUMBER_MAX,          "max"                           },
2220   { CA_ARG_UNDEFINED,           " "                             },
2221   { CA_ARG_NUMBER_RESET,        "reset"                         },
2222   { CA_ARG_UNDEFINED,           " "                             },
2223   { CA_ARG_NUMBER_CE_VALUE,     "CE value"                      },
2224   { CA_ARG_NUMBER_CE_SCORE,     "CE score"                      },
2225   { CA_ARG_NUMBER_CE_DELAY,     "CE delay"                      },
2226   { CA_ARG_UNDEFINED,           " "                             },
2227   { CA_ARG_NUMBER_LEVEL_TIME,   "time"                          },
2228   { CA_ARG_NUMBER_LEVEL_GEMS,   "gems"                          },
2229   { CA_ARG_NUMBER_LEVEL_SCORE,  "score"                         },
2230   { CA_ARG_UNDEFINED,           " "                             },
2231   { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]"                    },
2232   { CA_ARG_ELEMENT_CV_TARGET,   "target"                        },
2233   { CA_ARG_ELEMENT_CV_TRIGGER,  "trigger"                       },
2234   { CA_ARG_ELEMENT_CV_ACTION,   "action ->"                     },
2235   { CA_ARG_UNDEFINED,           " "                             },
2236   { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]"                    },
2237   { CA_ARG_ELEMENT_CS_TARGET,   "target"                        },
2238   { CA_ARG_ELEMENT_CS_TRIGGER,  "trigger"                       },
2239   { CA_ARG_ELEMENT_CS_ACTION,   "action ->"                     },
2240   { CA_ARG_UNDEFINED,           " "                             },
2241   { CA_ARG_ELEMENT_NR_HEADLINE, "[element]"                     },
2242   { CA_ARG_ELEMENT_NR_TARGET,   "target"                        },
2243   { CA_ARG_ELEMENT_NR_TRIGGER,  "trigger"                       },
2244   { CA_ARG_ELEMENT_NR_ACTION,   "action ->"                     },
2245
2246   { -1,                         NULL                            }
2247 };
2248
2249 static struct ValueTextInfo options_action_arg_envelope[] =
2250 {
2251   { CA_ARG_NUMBER_HEADLINE,     "[number]"                      },
2252   { CA_ARG_1,                   "1"                             },
2253   { CA_ARG_2,                   "2"                             },
2254   { CA_ARG_3,                   "3"                             },
2255   { CA_ARG_4,                   "4"                             },
2256   { CA_ARG_UNDEFINED,           " "                             },
2257   { CA_ARG_ELEMENT_HEADLINE,    "[element]"                     },
2258   { CA_ARG_ELEMENT_TARGET,      "target"                        },
2259   { CA_ARG_ELEMENT_TRIGGER,     "trigger"                       },
2260   { CA_ARG_ELEMENT_ACTION,      "action ->"                     },
2261
2262   { -1,                         NULL                            }
2263 };
2264
2265 static struct ValueTextInfo options_action_arg_key[] =
2266 {
2267   { CA_ARG_NUMBER_HEADLINE,     "[number]"                      },
2268   { CA_ARG_1,                   "1"                             },
2269   { CA_ARG_2,                   "2"                             },
2270   { CA_ARG_3,                   "3"                             },
2271   { CA_ARG_4,                   "4"                             },
2272   { CA_ARG_5,                   "5"                             },
2273   { CA_ARG_6,                   "6"                             },
2274   { CA_ARG_7,                   "7"                             },
2275   { CA_ARG_8,                   "8"                             },
2276   { CA_ARG_UNDEFINED,           " "                             },
2277   { CA_ARG_ELEMENT_HEADLINE,    "[element]"                     },
2278   { CA_ARG_ELEMENT_TARGET,      "target"                        },
2279   { CA_ARG_ELEMENT_TRIGGER,     "trigger"                       },
2280   { CA_ARG_ELEMENT_ACTION,      "action ->"                     },
2281
2282   { -1,                         NULL                            }
2283 };
2284
2285 static struct ValueTextInfo options_action_arg_speed[] =
2286 {
2287   { CA_ARG_SPEED_HEADLINE,      "[speed]"                       },
2288   { CA_ARG_SPEED_NOT_MOVING,    "frozen"                        },
2289   { CA_ARG_SPEED_VERY_SLOW,     "very slow"                     },
2290   { CA_ARG_SPEED_SLOW,          "slow"                          },
2291   { CA_ARG_SPEED_NORMAL,        "normal"                        },
2292   { CA_ARG_SPEED_FAST,          "fast"                          },
2293   { CA_ARG_SPEED_VERY_FAST,     "very fast"                     },
2294   { CA_ARG_SPEED_EVEN_FASTER,   "ultrafast"                     },
2295   { CA_ARG_UNDEFINED,           " "                             },
2296   { CA_ARG_SPEED_SLOWER,        "slower"                        },
2297   { CA_ARG_SPEED_FASTER,        "faster"                        },
2298   { CA_ARG_UNDEFINED,           " "                             },
2299   { CA_ARG_SPEED_RESET,         "reset"                         },
2300
2301   { -1,                         NULL                            }
2302 };
2303
2304 static struct ValueTextInfo options_action_arg_shield[] =
2305 {
2306   { CA_ARG_SHIELD_HEADLINE,     "[shield]"                      },
2307   { CA_ARG_SHIELD_OFF,          "off"                           },
2308   { CA_ARG_SHIELD_NORMAL,       "normal"                        },
2309   { CA_ARG_SHIELD_DEADLY,       "deadly"                        },
2310
2311   { -1,                         NULL                            }
2312 };
2313
2314 static struct ValueTextInfo options_action_arg_artwork[] =
2315 {
2316   { CA_ARG_ELEMENT_HEADLINE,    "[element]"                     },
2317   { CA_ARG_ELEMENT_TARGET,      "target"                        },
2318   { CA_ARG_ELEMENT_TRIGGER,     "trigger"                       },
2319   { CA_ARG_ELEMENT_ACTION,      "action ->"                     },
2320   { CA_ARG_UNDEFINED,           " "                             },
2321   { CA_ARG_ELEMENT_RESET,       "reset"                         },
2322
2323   { -1,                         NULL                            }
2324 };
2325
2326 static struct ValueTextInfo options_action_arg_gravity[] =
2327 {
2328   { CA_ARG_GRAVITY_HEADLINE,    "[gravity]"                     },
2329   { CA_ARG_GRAVITY_ON,          "on"                            },
2330   { CA_ARG_GRAVITY_OFF,         "off"                           },
2331   { CA_ARG_GRAVITY_TOGGLE,      "toggle"                        },
2332
2333   { -1,                         NULL                            }
2334 };
2335
2336 static struct ValueTextInfo options_action_arg_direction[] =
2337 {
2338   { CA_ARG_DIRECTION_HEADLINE,  "[dir.]"                        },
2339   { CA_ARG_DIRECTION_NONE,      "none"                          },
2340   { CA_ARG_DIRECTION_LEFT,      "left"                          },
2341   { CA_ARG_DIRECTION_RIGHT,     "right"                         },
2342   { CA_ARG_DIRECTION_UP,        "up"                            },
2343   { CA_ARG_DIRECTION_DOWN,      "down"                          },
2344   { CA_ARG_DIRECTION_TRIGGER,   "trigger"                       },
2345   { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger"                   },
2346
2347   { -1,                         NULL                            }
2348 };
2349
2350 static struct ValueTextInfo options_action_arg_scan_mode[] =
2351 {
2352   { CA_ARG_SCAN_MODE_HEADLINE,  "[mode]"                        },
2353   { CA_ARG_SCAN_MODE_NORMAL,    "normal"                        },
2354   { CA_ARG_SCAN_MODE_REVERSE,   "reverse"                       },
2355
2356   { -1,                         NULL                            }
2357 };
2358
2359 static struct ValueTextInfo options_action_arg_inventory[] =
2360 {
2361   { CA_ARG_INVENTORY_HEADLINE,  "[add]"                         },
2362   { CA_ARG_ELEMENT_TARGET,      "+ target"                      },
2363   { CA_ARG_ELEMENT_TRIGGER,     "+ trigger"                     },
2364   { CA_ARG_ELEMENT_ACTION,      "+ action"                      },
2365   { CA_ARG_UNDEFINED,           " "                             },
2366   { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]"                     },
2367   { CA_ARG_INVENTORY_RM_TARGET, "- target"                      },
2368   { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger"                     },
2369   { CA_ARG_INVENTORY_RM_ACTION, "- action"                      },
2370   { CA_ARG_INVENTORY_RM_FIRST,  "- first"                       },
2371   { CA_ARG_INVENTORY_RM_LAST,   "- last"                        },
2372   { CA_ARG_INVENTORY_RM_ALL,    "- all"                         },
2373   { CA_ARG_UNDEFINED,           " "                             },
2374   { CA_ARG_INVENTORY_RESET,     "reset"                         },
2375
2376   { -1,                         NULL                            }
2377 };
2378
2379 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2380 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2381 {
2382   { -1,                         NULL                            }
2383 };
2384
2385 static struct ValueTextInfo options_group_choice_mode[] =
2386 {
2387   { ANIM_RANDOM,                "random"                        },
2388   { ANIM_LOOP,                  "loop"                          },
2389   { ANIM_LINEAR,                "linear"                        },
2390   { ANIM_PINGPONG,              "pingpong"                      },
2391   { ANIM_PINGPONG2,             "pingpong 2"                    },
2392
2393   { -1,                         NULL                            }
2394 };
2395
2396 static struct ValueTextInfo *action_arg_modes[] =
2397 {
2398   options_action_mode_none,
2399   options_action_mode_assign,
2400   options_action_mode_add_remove,
2401   options_action_mode_calculate,
2402 };
2403
2404 static struct
2405 {
2406   int value;
2407   int mode;
2408   struct ValueTextInfo *options;
2409 }
2410 action_arg_options[] =
2411 {
2412   { CA_NO_ACTION,               0,      options_action_arg_none,        },
2413   { CA_EXIT_PLAYER,             0,      options_action_arg_player,      },
2414   { CA_KILL_PLAYER,             0,      options_action_arg_player,      },
2415   { CA_MOVE_PLAYER,             0,      options_action_arg_direction,   },
2416   { CA_RESTART_LEVEL,           0,      options_action_arg_none,        },
2417   { CA_SHOW_ENVELOPE,           0,      options_action_arg_envelope,    },
2418   { CA_SET_LEVEL_TIME,          3,      options_action_arg_number,      },
2419   { CA_SET_LEVEL_GEMS,          3,      options_action_arg_number,      },
2420   { CA_SET_LEVEL_SCORE,         3,      options_action_arg_number,      },
2421   { CA_SET_LEVEL_WIND,          1,      options_action_arg_direction,   },
2422   { CA_SET_LEVEL_RANDOM_SEED,   1,      options_action_arg_number,      },
2423   { CA_SET_PLAYER_KEYS,         2,      options_action_arg_key,         },
2424   { CA_SET_PLAYER_SPEED,        1,      options_action_arg_speed,       },
2425   { CA_SET_PLAYER_SHIELD,       1,      options_action_arg_shield,      },
2426   { CA_SET_PLAYER_GRAVITY,      1,      options_action_arg_gravity,     },
2427   { CA_SET_PLAYER_ARTWORK,      1,      options_action_arg_artwork,     },
2428   { CA_SET_PLAYER_INVENTORY,    0,      options_action_arg_inventory,   },
2429   { CA_SET_CE_VALUE,            3,      options_action_arg_value,       },
2430   { CA_SET_CE_SCORE,            3,      options_action_arg_value,       },
2431   { CA_SET_CE_ARTWORK,          1,      options_action_arg_artwork,     },
2432   { CA_SET_ENGINE_SCAN_MODE,    1,      options_action_arg_scan_mode,   },
2433
2434   { -1,                         FALSE,  NULL                            }
2435 };
2436
2437 static struct
2438 {
2439   int x, y;
2440   int gadget_id;
2441   int gadget_id_align;
2442   int size;     // char size of selectbox or '-1' (dynamically determined)
2443   struct ValueTextInfo *options;
2444   int *value;
2445   char *text_above, *text_left, *text_right, *infotext;
2446 } selectbox_info[ED_NUM_SELECTBOX] =
2447 {
2448   // ---------- level and editor settings -------------------------------------
2449
2450   {
2451     -1,                                 ED_LEVEL_SETTINGS_YPOS(8),
2452     GADGET_ID_TIME_OR_STEPS,            GADGET_ID_LEVEL_TIMELIMIT_UP,
2453     -1,
2454     options_time_or_steps,
2455     &level.use_step_counter,
2456     NULL, NULL, "(0 => no limit)",      "time or step limit"
2457   },
2458   {
2459     ED_LEVEL_SETTINGS_XPOS(0),          ED_LEVEL_SETTINGS_YPOS(11),
2460     GADGET_ID_GAME_ENGINE_TYPE,         GADGET_ID_NONE,
2461     -1,
2462     options_game_engine_type,
2463     &level.game_engine_type,
2464     NULL, "game engine:", NULL,         "game engine"
2465   },
2466   {
2467     ED_LEVEL_SETTINGS_XPOS(0),          ED_LEVEL_SETTINGS_YPOS(10),
2468     GADGET_ID_LEVELSET_SAVE_MODE,       GADGET_ID_NONE,
2469     -1,
2470     options_levelset_save_mode,
2471     &levelset_save_mode,
2472     "Action:", NULL, NULL,              "action when saving level set"
2473   },
2474
2475   // ---------- element settings: configure (several elements) ----------------
2476
2477   {
2478     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(0),
2479     GADGET_ID_WIND_DIRECTION,           GADGET_ID_NONE,
2480     -1,
2481     options_wind_direction,
2482     &level.wind_direction_initial,
2483     NULL, "initial wind direction:", NULL,      "initial wind direction"
2484   },
2485   {
2486     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(7),
2487     GADGET_ID_PLAYER_SPEED,             GADGET_ID_NONE,
2488     -1,
2489     options_player_speed,
2490     &level.initial_player_stepsize[0],
2491     NULL, "initial player speed:", NULL,        "initial player speed"
2492   },
2493
2494   // ---------- element settings: configure 1 (custom elements) ---------------
2495
2496   {
2497     ED_ELEMENT_SETTINGS_XPOS(1),        ED_ELEMENT_SETTINGS_YPOS(2),
2498     GADGET_ID_CUSTOM_ACCESS_TYPE,       GADGET_ID_NONE,
2499     -1,
2500     options_access_type,
2501     &custom_element.access_type,
2502     NULL, NULL, NULL,                   "type of access to this field"
2503   },
2504   {
2505     -1,                                 ED_ELEMENT_SETTINGS_YPOS(2),
2506     GADGET_ID_CUSTOM_ACCESS_LAYER,      GADGET_ID_CUSTOM_ACCESS_TYPE,
2507     -1,
2508     options_access_layer,
2509     &custom_element.access_layer,
2510     NULL, NULL, NULL,                   "layer of access for this field"
2511   },
2512   {
2513     -1,                                 ED_ELEMENT_SETTINGS_YPOS(2),
2514     GADGET_ID_CUSTOM_ACCESS_PROTECTED,  GADGET_ID_CUSTOM_ACCESS_LAYER,
2515     -1,
2516     options_access_protected,
2517     &custom_element.access_protected,
2518     NULL, NULL, NULL,                   "protected access for this field"
2519   },
2520   {
2521     ED_ELEMENT_SETTINGS_XPOS(1),        ED_ELEMENT_SETTINGS_YPOS(3),
2522     GADGET_ID_CUSTOM_ACCESS_DIRECTION,  GADGET_ID_NONE,
2523     -1,
2524     options_access_direction,
2525     &custom_element.access_direction,
2526     NULL, "from", NULL,                 "access direction for this field"
2527   },
2528   {
2529     ED_ELEMENT_SETTINGS_XPOS(1),        ED_ELEMENT_SETTINGS_YPOS(4),
2530     GADGET_ID_CUSTOM_WALK_TO_ACTION,    GADGET_ID_NONE,
2531     -1,
2532     options_walk_to_action,
2533     &custom_element.walk_to_action,
2534     NULL, NULL, NULL,                   "diggable/collectible/pushable"
2535   },
2536
2537   // ---------- element settings: configure 2 (custom elements) ---------------
2538
2539   {
2540     ED_ELEMENT_SETTINGS_XPOS(1),        ED_ELEMENT_SETTINGS_YPOS(1),
2541     GADGET_ID_CUSTOM_MOVE_PATTERN,      GADGET_ID_NONE,
2542     -1,
2543     options_move_pattern,
2544     &custom_element.move_pattern,
2545     NULL, "can move", NULL,             "element move pattern"
2546   },
2547   {
2548     ED_ELEMENT_SETTINGS_XPOS(1),        ED_ELEMENT_SETTINGS_YPOS(2),
2549     GADGET_ID_CUSTOM_MOVE_DIRECTION,    GADGET_ID_NONE,
2550     -1,
2551     options_move_direction,
2552     &custom_element.move_direction_initial,
2553     NULL, "starts moving", NULL,        "initial element move direction"
2554   },
2555   {
2556     ED_ELEMENT_SETTINGS_XPOS(1),        ED_ELEMENT_SETTINGS_YPOS(4),
2557     GADGET_ID_CUSTOM_MOVE_STEPSIZE,     GADGET_ID_NONE,
2558     -1,
2559     options_move_stepsize,
2560     &custom_element.move_stepsize,
2561     NULL, "move/fall speed", NULL,      "speed of element movement"
2562   },
2563   {
2564     ED_ELEMENT_SETTINGS_XPOS(1),        ED_ELEMENT_SETTINGS_YPOS(3),
2565     GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,   GADGET_ID_NONE,
2566     -1,
2567     options_move_leave_type,
2568     &custom_element.move_leave_type,
2569     // left text with leading spaces to place gadget next to "can dig" gadget
2570     // (needed because drawing area gadgets created after selectbox gadgets)
2571     // NULL, "can dig:    can", ":",    "leave behind or change element"
2572     NULL, "            can", ":",       "leave behind or change element"
2573   },
2574   {
2575     -1,                                 ED_ELEMENT_SETTINGS_YPOS(7),
2576     GADGET_ID_CUSTOM_SMASH_TARGETS,     GADGET_ID_CUSTOM_CAN_SMASH,
2577     -1,
2578     options_smash_targets,
2579     &custom_element.smash_targets,
2580     NULL, "can smash", NULL,            "elements that can be smashed"
2581   },
2582   {
2583     ED_ELEMENT_SETTINGS_XPOS(1),        ED_ELEMENT_SETTINGS_YPOS(8),
2584     GADGET_ID_CUSTOM_SLIPPERY_TYPE,     GADGET_ID_NONE,
2585     -1,
2586     options_slippery_type,
2587     &custom_element.slippery_type,
2588     NULL, "slippery", NULL,             "where other elements fall down"
2589   },
2590   {
2591     ED_ELEMENT_SETTINGS_XPOS(1),        ED_ELEMENT_SETTINGS_YPOS(9),
2592     GADGET_ID_CUSTOM_DEADLINESS,        GADGET_ID_NONE,
2593     -1,
2594     options_deadliness,
2595     &custom_element.deadliness,
2596     NULL, "deadly when", NULL,          "deadliness of element"
2597   },
2598   {
2599     ED_ELEMENT_SETTINGS_XPOS(1),        ED_ELEMENT_SETTINGS_YPOS(10),
2600     GADGET_ID_CUSTOM_EXPLOSION_TYPE,    GADGET_ID_NONE,
2601     -1,
2602     options_explosion_type,
2603     &custom_element.explosion_type,
2604     NULL, "can explode", NULL,          "explosion type"
2605   },
2606
2607   // ---------- element settings: advanced (custom elements) ------------------
2608
2609   {
2610     ED_ELEMENT_SETTINGS_XPOS(2),        ED_ELEMENT_SETTINGS_YPOS(3),
2611     GADGET_ID_CHANGE_TIME_UNITS,        GADGET_ID_NONE,
2612     -1,
2613     options_time_units,
2614     &custom_element_change.delay_frames,
2615     NULL, "delay time given in", NULL,  "delay time units for change"
2616   },
2617   {
2618     ED_ELEMENT_SETTINGS_XPOS(2),        ED_ELEMENT_SETTINGS_YPOS(4),
2619     GADGET_ID_CHANGE_DIRECT_ACTION,     GADGET_ID_NONE,
2620     -1,
2621     options_change_direct_action,
2622     &custom_element_change.direct_action,
2623     NULL, NULL, NULL,                   "type of direct action"
2624   },
2625   {
2626     ED_ELEMENT_SETTINGS_XPOS(2),        ED_ELEMENT_SETTINGS_YPOS(5),
2627     GADGET_ID_CHANGE_OTHER_ACTION,      GADGET_ID_NONE,
2628     -1,
2629     options_change_other_action,
2630     &custom_element_change.other_action,
2631     NULL, NULL, "element:",             "type of other element action"
2632   },
2633   {
2634     ED_ELEMENT_SETTINGS_XPOS(2),        ED_ELEMENT_SETTINGS_YPOS(6),
2635     GADGET_ID_CHANGE_SIDE,              GADGET_ID_NONE,
2636     -1,
2637     options_change_trigger_side,
2638     &custom_element_change.trigger_side,
2639     NULL, "at", "side",                 "element side triggering change"
2640   },
2641   {
2642     ED_ELEMENT_SETTINGS_XPOS(2),        ED_ELEMENT_SETTINGS_YPOS(7),
2643     GADGET_ID_CHANGE_PLAYER,            GADGET_ID_NONE,
2644     -1,
2645     options_change_trigger_player,
2646     &custom_element_change.trigger_player,
2647     NULL, "player:", " ",               "player that causes change"
2648   },
2649   {
2650     ED_ELEMENT_SETTINGS_XPOS(2),        ED_ELEMENT_SETTINGS_YPOS(7),
2651     GADGET_ID_CHANGE_PAGE,              GADGET_ID_CHANGE_PLAYER,
2652     -1,
2653     options_change_trigger_page,
2654     &custom_element_change.trigger_page,
2655     NULL, "page:", NULL,                "change page that causes change"
2656   },
2657   {
2658     ED_ELEMENT_SETTINGS_XPOS(2),        ED_ELEMENT_SETTINGS_YPOS(10),
2659     GADGET_ID_CHANGE_REPLACE_WHEN,      GADGET_ID_NONE,
2660     -1,
2661     options_change_replace_when,
2662     &custom_element_change.replace_when,
2663     NULL, "replace when", NULL,         "which elements can be replaced"
2664   },
2665   {
2666     ED_ELEMENT_SETTINGS_XPOS(1),        ED_ELEMENT_SETTINGS_YPOS(13),
2667     GADGET_ID_ACTION_TYPE,              GADGET_ID_NONE,
2668     -1,
2669     options_action_type,
2670     &custom_element_change.action_type,
2671     NULL, NULL, NULL,                   "action on specified condition"
2672   },
2673   {
2674     -1,                                 ED_ELEMENT_SETTINGS_YPOS(13),
2675     GADGET_ID_ACTION_MODE,              GADGET_ID_ACTION_TYPE,
2676     -1,
2677     options_action_mode_none,
2678     &custom_element_change.action_mode,
2679     NULL, NULL, NULL,                   "action operator"
2680   },
2681   {
2682     -1,                                 ED_ELEMENT_SETTINGS_YPOS(13),
2683     GADGET_ID_ACTION_ARG,               GADGET_ID_ACTION_MODE,
2684     -1,
2685     options_action_arg_none,
2686     &custom_element_change.action_arg,
2687     NULL, NULL, NULL,                   "action parameter"
2688   },
2689   {
2690     ED_ELEMENT_SETTINGS_XPOS(1),        ED_ELEMENT_SETTINGS_YPOS(14),
2691     GADGET_ID_SELECT_CHANGE_PAGE,       GADGET_ID_NONE,
2692     3,
2693     options_change_page,
2694     &custom_element.current_change_page,
2695     NULL, NULL, NULL,                   "element change page"
2696   },
2697
2698   // ---------- element settings: configure (group elements) ------------------
2699
2700   {
2701     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(4),
2702     GADGET_ID_GROUP_CHOICE_MODE,        GADGET_ID_NONE,
2703     -1,
2704     options_group_choice_mode,
2705     &group_element_info.choice_mode,
2706     NULL, "choice type:", NULL,         "type of group element choice"
2707   },
2708 };
2709
2710 static struct
2711 {
2712   int x, y;
2713   int gadget_id;
2714   int gadget_id_align;
2715   int size;
2716   char *text;
2717   char *text_above, *text_left, *text_right, *infotext;
2718 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2719 {
2720   // ---------- level and editor settings (tabs) ------------------------------
2721
2722   {
2723     ED_LEVEL_TABS_XPOS(0),              ED_LEVEL_TABS_YPOS(0),
2724     GADGET_ID_LEVELINFO_LEVEL,          GADGET_ID_NONE,
2725     8,                                  "Level",
2726     NULL, NULL, NULL,                   "Configure level properties"
2727   },
2728   {
2729     -1,                                 -1,
2730     GADGET_ID_LEVELINFO_LEVELSET,       GADGET_ID_LEVELINFO_LEVEL,
2731     8,                                  "Levelset",
2732     NULL, NULL, NULL,                   "Update this or create new level set"
2733   },
2734   {
2735     -1,                                 -1,
2736     GADGET_ID_LEVELINFO_EDITOR,         GADGET_ID_LEVELINFO_LEVELSET,
2737     8,                                  "Editor",
2738     NULL, NULL, NULL,                   "Configure editor properties"
2739   },
2740
2741   // ---------- element settings (tabs) ---------------------------------------
2742
2743   {
2744     ED_ELEMENT_TABS_XPOS(0),            ED_ELEMENT_TABS_YPOS(0),
2745     GADGET_ID_PROPERTIES_INFO,          GADGET_ID_NONE,
2746     8,                                  "Info",
2747     NULL, NULL, NULL,                   "Show information about element"
2748   },
2749   {
2750     -1,                                 -1,
2751     GADGET_ID_PROPERTIES_CONFIG,        GADGET_ID_PROPERTIES_INFO,
2752     8,                                  "Config",
2753     NULL, NULL, NULL,                   "Configure element properties"
2754   },
2755   {
2756     -1,                                 -1,
2757     GADGET_ID_PROPERTIES_CONFIG_1,      GADGET_ID_PROPERTIES_INFO,
2758     8,                                  "Config 1",
2759     NULL, NULL, NULL,                   "Configure element properties, part 1"
2760   },
2761   {
2762     -1,                                 -1,
2763     GADGET_ID_PROPERTIES_CONFIG_2,      GADGET_ID_PROPERTIES_CONFIG_1,
2764     8,                                  "Config 2",
2765     NULL, NULL, NULL,                   "Configure element properties, part 2"
2766   },
2767   {
2768     -1,                                 -1,
2769     GADGET_ID_PROPERTIES_CHANGE,        GADGET_ID_PROPERTIES_CONFIG_2,
2770     8,                                  "Change",
2771     NULL, NULL, NULL,                   "Configure custom element change pages"
2772   },
2773
2774   // ---------- level and editor settings (buttons) ---------------------------
2775
2776   {
2777     ED_LEVEL_SETTINGS_XPOS(0),          ED_LEVEL_SETTINGS_YPOS(10),
2778     GADGET_ID_SAVE_LEVELSET,            GADGET_ID_LEVELSET_SAVE_MODE,
2779     -1,                                 "Save",
2780     NULL, NULL, NULL,                   "Update or create level set"
2781   },
2782   {
2783     ED_LEVEL_SETTINGS_XPOS(0),          ED_LEVEL_SETTINGS_YPOS(6),
2784     GADGET_ID_SAVE_AS_TEMPLATE_2,       GADGET_ID_NONE,
2785     -1,                                 "Save",
2786     NULL, NULL,                         "this level as level template",
2787     "Save current settings as new template"
2788   },
2789
2790   // ---------- element settings (buttons) ------------------------------------
2791
2792   {
2793     -1,                                 -1,
2794     GADGET_ID_SAVE_AS_TEMPLATE_1,       GADGET_ID_CUSTOM_USE_TEMPLATE_1,
2795     -1,                                 "Save",
2796     NULL, " ",                          "As Template",
2797     "Save current settings as new template"
2798   },
2799   {
2800     -1,                                 -1,
2801     GADGET_ID_ADD_CHANGE_PAGE,          GADGET_ID_PASTE_CHANGE_PAGE,
2802     -1,                                 "New",
2803     NULL, NULL, NULL,                   "Add new change page"
2804   },
2805   {
2806     -1,                                 -1,
2807     GADGET_ID_DEL_CHANGE_PAGE,          GADGET_ID_ADD_CHANGE_PAGE,
2808     -1,                                 "Delete",
2809     NULL, NULL, NULL,                   "Delete current change page"
2810   },
2811 };
2812
2813 static struct
2814 {
2815   int graphic;
2816   int x, y;
2817   int gadget_id;
2818   int gadget_id_align;
2819   char *text_left, *text_right, *infotext;
2820 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
2821 {
2822   {
2823     IMG_EDITOR_COUNTER_DOWN,
2824     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(14),
2825     GADGET_ID_PREV_CHANGE_PAGE,         GADGET_ID_NONE,
2826     NULL, NULL,                         "select previous change page"
2827   },
2828   {
2829     IMG_EDITOR_COUNTER_UP,
2830     -1,                                 ED_ELEMENT_SETTINGS_YPOS(14),
2831     GADGET_ID_NEXT_CHANGE_PAGE,         GADGET_ID_SELECT_CHANGE_PAGE,
2832     NULL, "change page",                "select next change page"
2833   },
2834   {
2835     IMG_GFX_EDITOR_BUTTON_CP_COPY,
2836     -1,                                 ED_ELEMENT_SETTINGS_YPOS(14),
2837     GADGET_ID_COPY_CHANGE_PAGE,         GADGET_ID_NEXT_CHANGE_PAGE,
2838     " ", NULL,                          "copy settings from this change page"
2839   },
2840   {
2841     IMG_GFX_EDITOR_BUTTON_CP_PASTE,
2842     -1,                                 ED_ELEMENT_SETTINGS_YPOS(14),
2843     GADGET_ID_PASTE_CHANGE_PAGE,        GADGET_ID_COPY_CHANGE_PAGE,
2844     NULL, NULL,                         "paste settings to this change page"
2845   },
2846 };
2847
2848 static struct
2849 {
2850   int x, y;
2851 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
2852
2853 static struct
2854 {
2855   int graphic;
2856   int gadget_id;
2857   char *infotext;
2858 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
2859 {
2860   {
2861     IMG_EDITOR_PLAYFIELD_SCROLL_UP,
2862     GADGET_ID_SCROLL_UP,
2863     "scroll level editing area up"
2864   },
2865   {
2866     IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
2867     GADGET_ID_SCROLL_DOWN,
2868     "scroll level editing area down"
2869   },
2870   {
2871     IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
2872     GADGET_ID_SCROLL_LEFT,
2873     "scroll level editing area left"
2874   },
2875   {
2876     IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
2877     GADGET_ID_SCROLL_RIGHT,
2878     "scroll level editing area right"
2879   },
2880   {
2881     IMG_EDITOR_PALETTE_SCROLL_UP,
2882     GADGET_ID_SCROLL_LIST_UP,
2883     "scroll element list up ('Page Up')"
2884   },
2885   {
2886     IMG_EDITOR_PALETTE_SCROLL_DOWN,
2887     GADGET_ID_SCROLL_LIST_DOWN,
2888     "scroll element list down ('Page Down')"
2889   },
2890 };
2891
2892 static struct
2893 {
2894   int x, y;
2895   int width, height;
2896   int wheel_x, wheel_y;
2897   int wheel_width, wheel_height;
2898 } scrollbar_pos[ED_NUM_SCROLLBARS];
2899
2900 static struct
2901 {
2902   int graphic;
2903   int type;
2904   int gadget_id;
2905   char *infotext;
2906 } scrollbar_info[ED_NUM_SCROLLBARS] =
2907 {
2908   {
2909     IMG_EDITOR_PLAYFIELD_SCROLLBAR,
2910     GD_TYPE_SCROLLBAR_HORIZONTAL,
2911     GADGET_ID_SCROLL_HORIZONTAL,
2912     "scroll level editing area horizontally"
2913   },
2914   {
2915     IMG_EDITOR_PLAYFIELD_SCROLLBAR,
2916     GD_TYPE_SCROLLBAR_VERTICAL,
2917     GADGET_ID_SCROLL_VERTICAL,
2918     "scroll level editing area vertically"
2919   },
2920   {
2921     IMG_EDITOR_PALETTE_SCROLLBAR,
2922     GD_TYPE_SCROLLBAR_VERTICAL,
2923     GADGET_ID_SCROLL_LIST_VERTICAL,
2924     "scroll element list vertically"
2925   }
2926 };
2927
2928
2929 static struct
2930 {
2931   int x, y;
2932   int gadget_id;
2933   int gadget_id_align;
2934   int radio_button_nr;
2935   int *value;
2936   int checked_value;
2937   char *text_left, *text_right, *infotext;
2938 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
2939 {
2940   {
2941     -1,                                 ED_LEVEL_SETTINGS_YPOS(0),
2942     GADGET_ID_RANDOM_PERCENTAGE,        GADGET_ID_LEVEL_RANDOM_UP,
2943     RADIO_NR_RANDOM_ELEMENTS,
2944     &random_placement_method,           RANDOM_USE_PERCENTAGE,
2945     " ", "percentage",                  "use percentage for random elements"
2946   },
2947   {
2948     -1,                                 ED_LEVEL_SETTINGS_YPOS(0),
2949     GADGET_ID_RANDOM_QUANTITY,          GADGET_ID_RANDOM_PERCENTAGE,
2950     RADIO_NR_RANDOM_ELEMENTS,
2951     &random_placement_method,           RANDOM_USE_QUANTITY,
2952     " ", "quantity",                    "use quantity for random elements"
2953   }
2954 };
2955
2956 static struct
2957 {
2958   int x, y;
2959   int gadget_id;
2960   int gadget_id_align;
2961   boolean *value;
2962   char *text_above, *text_left, *text_right, *infotext;
2963 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
2964 {
2965   // ---------- level and editor settings -------------------------------------
2966
2967   {
2968     ED_LEVEL_SETTINGS_XPOS(0),          ED_LEVEL_SETTINGS_YPOS(6),
2969     GADGET_ID_AUTO_COUNT_GEMS,          GADGET_ID_NONE,
2970     &level.auto_count_gems,
2971     NULL, NULL,
2972     "automatically count gems needed",  "set counter to number of gems"
2973   },
2974   {
2975     ED_LEVEL_SETTINGS_XPOS(0),          ED_LEVEL_SETTINGS_YPOS(7),
2976     GADGET_ID_USE_LEVELSET_ARTWORK,     GADGET_ID_NONE,
2977     &levelset_use_levelset_artwork,
2978     NULL, NULL,
2979     "use current custom artwork",       "use custom artwork of this level set"
2980   },
2981   {
2982     ED_LEVEL_SETTINGS_XPOS(0),          ED_LEVEL_SETTINGS_YPOS(8),
2983     GADGET_ID_COPY_LEVEL_TEMPLATE,      GADGET_ID_NONE,
2984     &levelset_copy_level_template,
2985     NULL, NULL,
2986     "copy current level template",      "copy level template of this level set"
2987   },
2988   {
2989     ED_LEVEL_SETTINGS_XPOS(0),          ED_LEVEL_SETTINGS_YPOS(1),
2990     GADGET_ID_RANDOM_RESTRICTED,        GADGET_ID_NONE,
2991     &random_placement_background_restricted,
2992     NULL, NULL,
2993     "restrict random placement to:",    "set random placement restriction"
2994   },
2995   {
2996     ED_LEVEL_SETTINGS_XPOS(0),          ED_LEVEL_SETTINGS_YPOS(4),
2997     GADGET_ID_CUSTOM_USE_TEMPLATE_3,    GADGET_ID_NONE,
2998     &setup.editor.use_template_for_new_levels,
2999     "Template for new levels and CE/GE:", NULL,
3000     "use template for new levels",      "use template for level properties"
3001   },
3002   {
3003     ED_LEVEL_SETTINGS_XPOS(0),          ED_LEVEL_SETTINGS_YPOS(5),
3004     GADGET_ID_CUSTOM_USE_TEMPLATE_2,    GADGET_ID_NONE,
3005     &level.use_custom_template,
3006     NULL, NULL,
3007     "use template for custom elements", "use template for custom properties"
3008   },
3009
3010   // ---------- element settings: configure (various elements) ----------------
3011
3012   {
3013     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(0),
3014     GADGET_ID_STICK_ELEMENT,            GADGET_ID_NONE,
3015     &stick_element_properties_window,
3016     NULL, NULL,
3017     "stick this screen to edit content","stick this screen to edit content"
3018   },
3019   {
3020     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(1),
3021     GADGET_ID_EM_SLIPPERY_GEMS,         GADGET_ID_NONE,
3022     &level.em_slippery_gems,
3023     NULL, NULL,
3024     "slip down from certain flat walls","use EM/DC style slipping behaviour"
3025   },
3026   {
3027     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(1),
3028     GADGET_ID_EM_EXPLODES_BY_FIRE,      GADGET_ID_NONE,
3029     &level.em_explodes_by_fire,
3030     NULL, NULL,
3031     "explodes with chain reaction",     "use R'n'D style explosion behaviour"
3032   },
3033   {
3034     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(2),
3035     GADGET_ID_USE_SPRING_BUG,           GADGET_ID_NONE,
3036     &level.use_spring_bug,
3037     NULL, NULL,
3038     "use spring pushing bug",           "use odd spring pushing behaviour"
3039   },
3040   {
3041     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(1),
3042     GADGET_ID_USE_TIME_ORB_BUG,         GADGET_ID_NONE,
3043     &level.use_time_orb_bug,
3044     NULL, NULL,
3045     "use time orb bug",                 "use odd time orb behaviour"
3046   },
3047   {
3048     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(5),
3049     GADGET_ID_USE_LIFE_BUGS,            GADGET_ID_NONE,
3050     &level.use_life_bugs,
3051     NULL, NULL,
3052     "use buggy element behaviour",      "use odd (historic) element behaviour"
3053   },
3054   {
3055     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(2),
3056     GADGET_ID_RANDOM_BALL_CONTENT,      GADGET_ID_NONE,
3057     &level.ball_random,
3058     NULL, NULL,
3059     "create single random element",     "only create one element from content"
3060   },
3061   {
3062     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(1),
3063     GADGET_ID_INITIAL_BALL_STATE,       GADGET_ID_NONE,
3064     &level.ball_state_initial,
3065     NULL, NULL,
3066     "magic ball initially activated",   "activate magic ball after level start"
3067   },
3068   {
3069     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(0),
3070     GADGET_ID_GROW_INTO_DIGGABLE,       GADGET_ID_NONE,
3071     &level.grow_into_diggable,
3072     NULL, NULL,
3073     "can grow into anything diggable",  "grow into more than just sand"
3074   },
3075   {
3076     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(0),
3077     GADGET_ID_SB_FIELDS_NEEDED,         GADGET_ID_NONE,
3078     &level.sb_fields_needed,
3079     NULL, NULL,
3080     "all fields need to be filled",     "require all SB fields to be solved"
3081   },
3082   {
3083     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(0),
3084     GADGET_ID_SB_OBJECTS_NEEDED,        GADGET_ID_NONE,
3085     &level.sb_objects_needed,
3086     NULL, NULL,
3087     "all objects need to be placed",    "require all SB objects to be solved"
3088   },
3089   {
3090     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(1),
3091     GADGET_ID_AUTO_EXIT_SOKOBAN,        GADGET_ID_NONE,
3092     &level.auto_exit_sokoban,
3093     NULL, NULL,
3094     "exit level if all tasks solved",   "automatically finish Sokoban levels"
3095   },
3096   {
3097     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(14),
3098     GADGET_ID_SOLVED_BY_ONE_PLAYER,     GADGET_ID_NONE,
3099     &level.solved_by_one_player,
3100     NULL, NULL,
3101     "only one player must enter exit",  "level solved by first player in exit"
3102   },
3103   {
3104     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(9),
3105     GADGET_ID_CONTINUOUS_SNAPPING,      GADGET_ID_NONE,
3106     &level.continuous_snapping,
3107     NULL, NULL,
3108     "continuous snapping",              "use snapping without releasing key"
3109   },
3110   {
3111     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(8),
3112     GADGET_ID_BLOCK_SNAP_FIELD,         GADGET_ID_NONE,
3113     &level.block_snap_field,
3114     NULL, NULL,
3115     "block snapped field when snapping", "use snapping delay to show animation"
3116   },
3117   {
3118     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(2),
3119     GADGET_ID_BLOCK_LAST_FIELD,         GADGET_ID_NONE,
3120     &level.block_last_field,
3121     NULL, NULL,
3122     "block last field when moving",     "player blocks last field when moving"
3123   },
3124   {
3125     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(2),
3126     GADGET_ID_SP_BLOCK_LAST_FIELD,      GADGET_ID_NONE,
3127     &level.sp_block_last_field,
3128     NULL, NULL,
3129     "block last field when moving",     "player blocks last field when moving"
3130   },
3131   {
3132     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(3),
3133     GADGET_ID_INSTANT_RELOCATION,       GADGET_ID_NONE,
3134     &level.instant_relocation,
3135     NULL, NULL,
3136     "no scrolling when relocating",     "player gets relocated without delay"
3137   },
3138   {
3139     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(4),
3140     GADGET_ID_SHIFTED_RELOCATION,       GADGET_ID_NONE,
3141     &level.shifted_relocation,
3142     NULL, NULL,
3143     "no centering when relocating",     "level not centered after relocation"
3144   },
3145   {
3146     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(5),
3147     GADGET_ID_LAZY_RELOCATION,          GADGET_ID_NONE,
3148     &level.lazy_relocation,
3149     NULL, NULL,
3150     "only redraw off-screen relocation","no redraw if relocation target visible"
3151   },
3152   {
3153     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(10),
3154     GADGET_ID_USE_START_ELEMENT,        GADGET_ID_NONE,
3155     &level.use_start_element[0],
3156     NULL, NULL,
3157     "use level start element:",        "start level at this element's position"
3158   },
3159   {
3160     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(11),
3161     GADGET_ID_USE_ARTWORK_ELEMENT,      GADGET_ID_NONE,
3162     &level.use_artwork_element[0],
3163     NULL, NULL,
3164     "use artwork from element:",        "use player artwork from other element"
3165   },
3166   {
3167     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(12),
3168     GADGET_ID_USE_EXPLOSION_ELEMENT,    GADGET_ID_NONE,
3169     &level.use_explosion_element[0],
3170     NULL, NULL,
3171     "use explosion from element:",      "use explosion properties from element"
3172   },
3173   {
3174     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(13),
3175     GADGET_ID_INITIAL_GRAVITY,          GADGET_ID_NONE,
3176     &level.initial_player_gravity[0],
3177     NULL, NULL,
3178     "use initial gravity",              "set initial player gravity"
3179   },
3180   {
3181     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(1),
3182     GADGET_ID_USE_INITIAL_INVENTORY,    GADGET_ID_NONE,
3183     &level.use_initial_inventory[0],
3184     NULL, NULL,
3185     "use initial inventory:",           "use collected elements on level start"
3186   },
3187   {
3188     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(6),
3189     GADGET_ID_CAN_PASS_TO_WALKABLE,     GADGET_ID_NONE,
3190     &level.can_pass_to_walkable,
3191     NULL, NULL,
3192     "can pass to walkable element",     "player can pass to empty or walkable"
3193   },
3194   {
3195     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(1),
3196     GADGET_ID_CAN_FALL_INTO_ACID,       GADGET_ID_NONE,
3197     &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3198     NULL, NULL,
3199     "can fall into acid (with gravity)","player can fall into acid pool"
3200   },
3201   {
3202     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(0),
3203     GADGET_ID_CAN_MOVE_INTO_ACID,       GADGET_ID_NONE,
3204     &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3205     NULL, NULL,
3206     "can move into acid",               "element can move into acid pool"
3207   },
3208   {
3209     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(1),
3210     GADGET_ID_DONT_COLLIDE_WITH,        GADGET_ID_NONE,
3211     &custom_element_properties[EP_DONT_COLLIDE_WITH],
3212     NULL, NULL,
3213     "deadly when colliding with",       "element is deadly when hitting player"
3214   },
3215   {
3216     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(1),
3217     GADGET_ID_ENVELOPE_AUTOWRAP,        GADGET_ID_NONE,
3218     &level.envelope[0].autowrap,
3219     NULL, NULL,
3220     "auto-wrap",                        "automatically wrap envelope text"
3221   },
3222   {
3223     -1,                                 ED_ELEMENT_SETTINGS_YPOS(1),
3224     GADGET_ID_ENVELOPE_CENTERED,        GADGET_ID_ENVELOPE_AUTOWRAP,
3225     &level.envelope[0].centered,
3226     NULL, " ",
3227     "centered",                         "automatically center envelope text"
3228   },
3229   {
3230     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(1),
3231     GADGET_ID_MM_LASER_RED,             GADGET_ID_NONE,
3232     &level.mm_laser_red,
3233     "choose color components for laser:", NULL,
3234     "red",                              "use red color components in laser"
3235   },
3236   {
3237     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(2),
3238     GADGET_ID_MM_LASER_GREEN,           GADGET_ID_NONE,
3239     &level.mm_laser_green,
3240     NULL, NULL,
3241     "green",                            "use green color components in laser"
3242   },
3243   {
3244     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(3),
3245     GADGET_ID_MM_LASER_BLUE,            GADGET_ID_NONE,
3246     &level.mm_laser_blue,
3247     NULL, NULL,
3248     "blue",                             "use blue color components in laser"
3249   },
3250   {
3251     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(1),
3252     GADGET_ID_DF_LASER_RED,             GADGET_ID_NONE,
3253     &level.df_laser_red,
3254     "choose color components for laser:", NULL,
3255     "red",                              "use red color components in laser"
3256   },
3257   {
3258     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(2),
3259     GADGET_ID_DF_LASER_GREEN,           GADGET_ID_NONE,
3260     &level.df_laser_green,
3261     NULL, NULL,
3262     "green",                            "use green color components in laser"
3263   },
3264   {
3265     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(3),
3266     GADGET_ID_DF_LASER_BLUE,            GADGET_ID_NONE,
3267     &level.df_laser_blue,
3268     NULL, NULL,
3269     "blue",                             "use blue color components in laser"
3270   },
3271
3272   // ---------- element settings: configure 1 (custom elements) ---------------
3273
3274   {
3275     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(1),
3276     GADGET_ID_CUSTOM_USE_GRAPHIC,       GADGET_ID_NONE,
3277     &custom_element.use_gfx_element,
3278     NULL, NULL,
3279     "use graphic of element:",          "use existing element graphic"
3280   },
3281   {
3282     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(14),
3283     GADGET_ID_CUSTOM_USE_TEMPLATE_1,    GADGET_ID_NONE,
3284     &level.use_custom_template,
3285     NULL, NULL,
3286     "use template",                     "use template for custom properties"
3287   },
3288   {
3289     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(2),
3290     GADGET_ID_CUSTOM_ACCESSIBLE,        GADGET_ID_NONE,
3291     &custom_element_properties[EP_ACCESSIBLE],
3292     NULL, NULL,
3293     NULL,                               "player can walk to or pass this field"
3294   },
3295   {
3296     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(9),
3297     GADGET_ID_CUSTOM_GRAV_REACHABLE,    GADGET_ID_NONE,
3298     &custom_element_properties[EP_GRAVITY_REACHABLE],
3299     NULL, NULL,
3300     "reachable despite gravity",        "player can walk/dig despite gravity"
3301   },
3302   {
3303     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(11),
3304     GADGET_ID_CUSTOM_USE_LAST_VALUE,    GADGET_ID_NONE,
3305     &custom_element.use_last_ce_value,
3306     NULL, NULL,
3307     "use last CE value after change",   "use last CE value after change"
3308   },
3309   {
3310     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(4),
3311     GADGET_ID_CUSTOM_WALK_TO_OBJECT,    GADGET_ID_NONE,
3312     &custom_element_properties[EP_WALK_TO_OBJECT],
3313     NULL, NULL,
3314     NULL,                               "player can dig/collect/push element"
3315   },
3316   {
3317     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(8),
3318     GADGET_ID_CUSTOM_INDESTRUCTIBLE,    GADGET_ID_NONE,
3319     &custom_element_properties[EP_INDESTRUCTIBLE],
3320     NULL, NULL,
3321     "indestructible",                   "element is indestructible"
3322   },
3323
3324   // ---------- element settings: configure 2 (custom elements) ---------------
3325
3326   {
3327     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(1),
3328     GADGET_ID_CUSTOM_CAN_MOVE,          GADGET_ID_NONE,
3329     &custom_element_properties[EP_CAN_MOVE],
3330     NULL, NULL,
3331     NULL,                               "element can move with some pattern"
3332   },
3333   {
3334     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(7),
3335     GADGET_ID_CUSTOM_CAN_FALL,          GADGET_ID_NONE,
3336     &custom_element_properties[EP_CAN_FALL],
3337     NULL, NULL,
3338     "can fall",                         "element can fall down"
3339   },
3340   {
3341     -1,                                 ED_ELEMENT_SETTINGS_YPOS(7),
3342     GADGET_ID_CUSTOM_CAN_SMASH,         GADGET_ID_CUSTOM_CAN_FALL,
3343     &custom_element_properties[EP_CAN_SMASH],
3344     NULL, " ",
3345     NULL,                               "element can smash other elements"
3346   },
3347   {
3348     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(8),
3349     GADGET_ID_CUSTOM_SLIPPERY,          GADGET_ID_NONE,
3350     &custom_element_properties[EP_SLIPPERY],
3351     NULL, NULL,
3352     NULL,                               "other elements can fall down from it"
3353   },
3354   {
3355     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(9),
3356     GADGET_ID_CUSTOM_DEADLY,            GADGET_ID_NONE,
3357     &custom_element_properties[EP_DEADLY],
3358     NULL, NULL,
3359     NULL,                               "element can kill the player"
3360   },
3361   {
3362     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(10),
3363     GADGET_ID_CUSTOM_CAN_EXPLODE,       GADGET_ID_NONE,
3364     &custom_element_properties[EP_CAN_EXPLODE],
3365     NULL, NULL,
3366     NULL,                               "element can explode"
3367   },
3368   {
3369     ED_ELEMENT_SETTINGS_XPOS(1),        ED_ELEMENT_SETTINGS_YPOS(11),
3370     GADGET_ID_CUSTOM_EXPLODE_FIRE,      GADGET_ID_NONE,
3371     &custom_element_properties[EP_EXPLODES_BY_FIRE],
3372     NULL, NULL,
3373     "by fire",                          "element can explode by fire/explosion"
3374   },
3375   {
3376     -1,                                 ED_ELEMENT_SETTINGS_YPOS(11),
3377     GADGET_ID_CUSTOM_EXPLODE_SMASH,     GADGET_ID_CUSTOM_EXPLODE_FIRE,
3378     &custom_element_properties[EP_EXPLODES_SMASHED],
3379     NULL, " ",
3380     "smashed",                          "element can explode when smashed"
3381   },
3382   {
3383     -1,                                 ED_ELEMENT_SETTINGS_YPOS(11),
3384     GADGET_ID_CUSTOM_EXPLODE_IMPACT,    GADGET_ID_CUSTOM_EXPLODE_SMASH,
3385     &custom_element_properties[EP_EXPLODES_IMPACT],
3386     NULL, " ",
3387     "impact",                           "element can explode on impact"
3388   },
3389
3390   // ---------- element settings: advanced (custom elements) ------------------
3391
3392   {
3393     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(1),
3394     GADGET_ID_CUSTOM_CAN_CHANGE,        GADGET_ID_NONE,
3395     &custom_element_change.can_change,
3396     NULL, NULL,
3397     "element changes to:",              "change element on specified condition"
3398   },
3399   {
3400     ED_ELEMENT_SETTINGS_XPOS(1),        ED_ELEMENT_SETTINGS_YPOS(2),
3401     GADGET_ID_CHANGE_DELAY,             GADGET_ID_NONE,
3402     &custom_element_change_events[CE_DELAY],
3403     NULL, NULL,
3404     NULL,                               "element changes after delay"
3405   },
3406   {
3407     ED_ELEMENT_SETTINGS_XPOS(1),        ED_ELEMENT_SETTINGS_YPOS(4),
3408     GADGET_ID_CHANGE_BY_DIRECT_ACT,     GADGET_ID_NONE,
3409     &custom_element_change_events[CE_BY_DIRECT_ACTION],
3410     NULL, NULL,
3411     NULL,                               "element changes by direct action"
3412   },
3413   {
3414     ED_ELEMENT_SETTINGS_XPOS(1),        ED_ELEMENT_SETTINGS_YPOS(5),
3415     GADGET_ID_CHANGE_BY_OTHER_ACT,      GADGET_ID_NONE,
3416     &custom_element_change_events[CE_BY_OTHER_ACTION],
3417     NULL, NULL,
3418     NULL,                               "element changes by other element"
3419   },
3420   {
3421     ED_ELEMENT_SETTINGS_XPOS(1),        ED_ELEMENT_SETTINGS_YPOS(8),
3422     GADGET_ID_CHANGE_USE_EXPLOSION,     GADGET_ID_NONE,
3423     &custom_element_change.explode,
3424     NULL, NULL,
3425     "explode instead of change",        "element explodes instead of change"
3426   },
3427   {
3428     ED_ELEMENT_SETTINGS_XPOS(1),        ED_ELEMENT_SETTINGS_YPOS(9),
3429     GADGET_ID_CHANGE_USE_CONTENT,       GADGET_ID_NONE,
3430     &custom_element_change.use_target_content,
3431     NULL, NULL,
3432     "use extended change target:",      "element changes to more elements"
3433   },
3434   {
3435     ED_ELEMENT_SETTINGS_XPOS(2),        ED_ELEMENT_SETTINGS_YPOS(11),
3436     GADGET_ID_CHANGE_ONLY_COMPLETE,     GADGET_ID_NONE,
3437     &custom_element_change.only_if_complete,
3438     NULL, NULL,
3439     "replace all or nothing",           "only replace when all can be changed"
3440   },
3441   {
3442     ED_ELEMENT_SETTINGS_XPOS(2),        ED_ELEMENT_SETTINGS_YPOS(12),
3443     GADGET_ID_CHANGE_USE_RANDOM,        GADGET_ID_NONE,
3444     &custom_element_change.use_random_replace,
3445     NULL, NULL,
3446     NULL,                               "use percentage for random replace"
3447   },
3448   {
3449     ED_ELEMENT_SETTINGS_XPOS(0),        ED_ELEMENT_SETTINGS_YPOS(13),
3450     GADGET_ID_CHANGE_HAS_ACTION,        GADGET_ID_NONE,
3451     &custom_element_change.has_action,
3452     NULL, NULL,
3453     NULL,                               "execute action on specified condition"
3454   },
3455 };
3456
3457 static struct
3458 {
3459   int x, y;
3460   int xoffset, yoffset;
3461   int gadget_id;
3462   int gadget_id_align;
3463   int *value;
3464   int area_xsize, area_ysize;
3465   char *text_left, *text_right, *text_below, *infotext;
3466 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3467 {
3468   // ---------- level playfield content ---------------------------------------
3469
3470   {
3471     0,                                  0,
3472     0,                                  0,
3473     GADGET_ID_DRAWING_LEVEL,            GADGET_ID_NONE,
3474     NULL,
3475     -1, -1,     // these values are not constant, but can change at runtime
3476     NULL, NULL, NULL,                   NULL
3477   },
3478
3479   // ---------- yam yam content -----------------------------------------------
3480
3481   {
3482     ED_AREA_YAMYAM_CONTENT_XPOS,        ED_AREA_YAMYAM_CONTENT_YPOS,
3483     ED_AREA_YAMYAM_CONTENT_XOFF(0),     ED_AREA_YAMYAM_CONTENT_YOFF(0),
3484     GADGET_ID_YAMYAM_CONTENT_0,         GADGET_ID_NONE,
3485     &level.yamyam_content[0].e[0][0],   3, 3,
3486     NULL, NULL, "1",                    NULL
3487   },
3488   {
3489     ED_AREA_YAMYAM_CONTENT_XPOS,        ED_AREA_YAMYAM_CONTENT_YPOS,
3490     ED_AREA_YAMYAM_CONTENT_XOFF(1),     ED_AREA_YAMYAM_CONTENT_YOFF(1),
3491     GADGET_ID_YAMYAM_CONTENT_1,         GADGET_ID_NONE,
3492     &level.yamyam_content[1].e[0][0],   3, 3,
3493     NULL, NULL, "2",                    NULL
3494   },
3495   {
3496     ED_AREA_YAMYAM_CONTENT_XPOS,        ED_AREA_YAMYAM_CONTENT_YPOS,
3497     ED_AREA_YAMYAM_CONTENT_XOFF(2),     ED_AREA_YAMYAM_CONTENT_YOFF(2),
3498     GADGET_ID_YAMYAM_CONTENT_2,         GADGET_ID_NONE,
3499     &level.yamyam_content[2].e[0][0],   3, 3,
3500     NULL, NULL, "3",                    NULL
3501   },
3502   {
3503     ED_AREA_YAMYAM_CONTENT_XPOS,        ED_AREA_YAMYAM_CONTENT_YPOS,
3504     ED_AREA_YAMYAM_CONTENT_XOFF(3),     ED_AREA_YAMYAM_CONTENT_YOFF(3),
3505     GADGET_ID_YAMYAM_CONTENT_3,         GADGET_ID_NONE,
3506     &level.yamyam_content[3].e[0][0],   3, 3,
3507     NULL, NULL, "4",                    NULL
3508   },
3509   {
3510     ED_AREA_YAMYAM_CONTENT_XPOS,        ED_AREA_YAMYAM_CONTENT_YPOS,
3511     ED_AREA_YAMYAM_CONTENT_XOFF(4),     ED_AREA_YAMYAM_CONTENT_YOFF(4),
3512     GADGET_ID_YAMYAM_CONTENT_4,         GADGET_ID_NONE,
3513     &level.yamyam_content[4].e[0][0],   3, 3,
3514     NULL, NULL, "5",                    NULL
3515   },
3516   {
3517     ED_AREA_YAMYAM_CONTENT_XPOS,        ED_AREA_YAMYAM_CONTENT_YPOS,
3518     ED_AREA_YAMYAM_CONTENT_XOFF(5),     ED_AREA_YAMYAM_CONTENT_YOFF(5),
3519     GADGET_ID_YAMYAM_CONTENT_5,         GADGET_ID_NONE,
3520     &level.yamyam_content[5].e[0][0],   3, 3,
3521     NULL, NULL, "6",                    NULL
3522   },
3523   {
3524     ED_AREA_YAMYAM_CONTENT_XPOS,        ED_AREA_YAMYAM_CONTENT_YPOS,
3525     ED_AREA_YAMYAM_CONTENT_XOFF(6),     ED_AREA_YAMYAM_CONTENT_YOFF(6),
3526     GADGET_ID_YAMYAM_CONTENT_6,         GADGET_ID_NONE,
3527     &level.yamyam_content[6].e[0][0],   3, 3,
3528     NULL, NULL, "7",                    NULL
3529   },
3530   {
3531     ED_AREA_YAMYAM_CONTENT_XPOS,        ED_AREA_YAMYAM_CONTENT_YPOS,
3532     ED_AREA_YAMYAM_CONTENT_XOFF(7),     ED_AREA_YAMYAM_CONTENT_YOFF(7),
3533     GADGET_ID_YAMYAM_CONTENT_7,         GADGET_ID_NONE,
3534     &level.yamyam_content[7].e[0][0],   3, 3,
3535     NULL, NULL, "8",                    NULL
3536   },
3537
3538   // ---------- magic ball content --------------------------------------------
3539
3540   {
3541     ED_AREA_MAGIC_BALL_CONTENT_XPOS,    ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3542     ED_AREA_MAGIC_BALL_CONTENT_XOFF(0), ED_AREA_MAGIC_BALL_CONTENT_YOFF(0),
3543     GADGET_ID_MAGIC_BALL_CONTENT_0,     GADGET_ID_NONE,
3544     &level.ball_content[0].e[0][0],     3, 3,
3545     NULL, NULL, "1",                    NULL
3546   },
3547   {
3548     ED_AREA_MAGIC_BALL_CONTENT_XPOS,    ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3549     ED_AREA_MAGIC_BALL_CONTENT_XOFF(1), ED_AREA_MAGIC_BALL_CONTENT_YOFF(1),
3550     GADGET_ID_MAGIC_BALL_CONTENT_1,     GADGET_ID_NONE,
3551     &level.ball_content[1].e[0][0],     3, 3,
3552     NULL, NULL, "2",                    NULL
3553   },
3554   {
3555     ED_AREA_MAGIC_BALL_CONTENT_XPOS,    ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3556     ED_AREA_MAGIC_BALL_CONTENT_XOFF(2), ED_AREA_MAGIC_BALL_CONTENT_YOFF(2),
3557     GADGET_ID_MAGIC_BALL_CONTENT_2,     GADGET_ID_NONE,
3558     &level.ball_content[2].e[0][0],     3, 3,
3559     NULL, NULL, "3",                    NULL
3560   },
3561   {
3562     ED_AREA_MAGIC_BALL_CONTENT_XPOS,    ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3563     ED_AREA_MAGIC_BALL_CONTENT_XOFF(3), ED_AREA_MAGIC_BALL_CONTENT_YOFF(3),
3564     GADGET_ID_MAGIC_BALL_CONTENT_3,     GADGET_ID_NONE,
3565     &level.ball_content[3].e[0][0],     3, 3,
3566     NULL, NULL, "4",                    NULL
3567   },
3568   {
3569     ED_AREA_MAGIC_BALL_CONTENT_XPOS,    ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3570     ED_AREA_MAGIC_BALL_CONTENT_XOFF(4), ED_AREA_MAGIC_BALL_CONTENT_YOFF(4),
3571     GADGET_ID_MAGIC_BALL_CONTENT_4,     GADGET_ID_NONE,
3572     &level.ball_content[4].e[0][0],     3, 3,
3573     NULL, NULL, "5",                    NULL
3574   },
3575   {
3576     ED_AREA_MAGIC_BALL_CONTENT_XPOS,    ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3577     ED_AREA_MAGIC_BALL_CONTENT_XOFF(5), ED_AREA_MAGIC_BALL_CONTENT_YOFF(5),
3578     GADGET_ID_MAGIC_BALL_CONTENT_5,     GADGET_ID_NONE,
3579     &level.ball_content[5].e[0][0],     3, 3,
3580     NULL, NULL, "6",                    NULL
3581   },
3582   {
3583     ED_AREA_MAGIC_BALL_CONTENT_XPOS,    ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3584     ED_AREA_MAGIC_BALL_CONTENT_XOFF(6), ED_AREA_MAGIC_BALL_CONTENT_YOFF(6),
3585     GADGET_ID_MAGIC_BALL_CONTENT_6,     GADGET_ID_NONE,
3586     &level.ball_content[6].e[0][0],     3, 3,
3587     NULL, NULL, "7",                    NULL
3588   },
3589   {
3590     ED_AREA_MAGIC_BALL_CONTENT_XPOS,    ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3591     ED_AREA_MAGIC_BALL_CONTENT_XOFF(7), ED_AREA_MAGIC_BALL_CONTENT_YOFF(7),
3592     GADGET_ID_MAGIC_BALL_CONTENT_7,     GADGET_ID_NONE,
3593     &level.ball_content[7].e[0][0],     3, 3,
3594     NULL, NULL, "8",                    NULL
3595   },
3596
3597   // ---------- android content -----------------------------------------------
3598
3599   {
3600     ED_AREA_1X1_SETTINGS_XPOS(0),       ED_AREA_1X1_SETTINGS_YPOS(5),
3601     ED_AREA_1X1_SETTINGS_XOFF,          ED_AREA_1X1_SETTINGS_YOFF,
3602     GADGET_ID_ANDROID_CONTENT,          GADGET_ID_NONE,
3603     &level.android_clone_element[0],    MAX_ANDROID_ELEMENTS, 1,
3604     "elements:", NULL, NULL,            "elements android can clone"
3605   },
3606
3607   // ---------- amoeba content ------------------------------------------------
3608
3609   {
3610     ED_AREA_1X1_SETTINGS_XPOS(0),       ED_AREA_1X1_SETTINGS_YPOS(3),
3611     ED_AREA_1X1_SETTINGS_XOFF,          ED_AREA_1X1_SETTINGS_YOFF,
3612     GADGET_ID_AMOEBA_CONTENT,           GADGET_ID_NONE,
3613     &level.amoeba_content,              1, 1,
3614     "content:", NULL, NULL,             "amoeba content"
3615   },
3616
3617   // ---------- level start element -------------------------------------------
3618
3619   {
3620     -1,                                 ED_AREA_1X1_SETTINGS_YPOS(10),
3621     0,                                  ED_AREA_1X1_SETTINGS_YOFF,
3622     GADGET_ID_START_ELEMENT,            GADGET_ID_USE_START_ELEMENT,
3623     &level.start_element[0],            1, 1,
3624     NULL, NULL, NULL,                   "level start element"
3625   },
3626
3627   // ---------- player artwork element ----------------------------------------
3628
3629   {
3630     -1,                                 ED_AREA_1X1_SETTINGS_YPOS(11),
3631     0,                                  ED_AREA_1X1_SETTINGS_YOFF,
3632     GADGET_ID_ARTWORK_ELEMENT,          GADGET_ID_USE_ARTWORK_ELEMENT,
3633     &level.artwork_element[0],          1, 1,
3634     NULL, NULL, NULL,                   "element for player artwork"
3635   },
3636
3637   // ---------- player explosion element --------------------------------------
3638
3639   {
3640     -1,                                 ED_AREA_1X1_SETTINGS_YPOS(12),
3641     0,                                  ED_AREA_1X1_SETTINGS_YOFF,
3642     GADGET_ID_EXPLOSION_ELEMENT,        GADGET_ID_USE_EXPLOSION_ELEMENT,
3643     &level.explosion_element[0],        1, 1,
3644     NULL, NULL, NULL,                   "element for player explosion"
3645   },
3646
3647   // ---------- player initial inventory --------------------------------------
3648
3649   {
3650     -1,                                 ED_AREA_1X1_SETTINGS_YPOS(1),
3651     0,                                  ED_AREA_1X1_SETTINGS_YOFF,
3652     GADGET_ID_INVENTORY_CONTENT,        GADGET_ID_USE_INITIAL_INVENTORY,
3653     &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
3654     NULL, NULL, NULL,                   "content for initial inventory"
3655   },
3656
3657   // ---------- element settings: configure 1 (custom elements) ---------------
3658
3659   // ---------- custom graphic ------------------------------------------------
3660
3661   {
3662     -1,                                 ED_AREA_1X1_SETTINGS_YPOS(1),
3663     0,                                  ED_AREA_1X1_SETTINGS_YOFF,
3664     GADGET_ID_CUSTOM_GRAPHIC,           GADGET_ID_CUSTOM_USE_GRAPHIC,
3665     &custom_element.gfx_element_initial,1, 1,
3666     NULL, NULL, NULL,                   "custom graphic element"
3667   },
3668
3669   // ---------- element settings: configure 2 (custom elements) ---------------
3670
3671   // ---------- custom content (when exploding) -------------------------------
3672
3673   {
3674     -1,                                 ED_AREA_3X3_SETTINGS_YPOS(10),
3675     0,                                  ED_AREA_3X3_SETTINGS_YOFF,
3676     GADGET_ID_CUSTOM_CONTENT,           GADGET_ID_NONE, // align three rows
3677     &custom_element.content.e[0][0],    3, 3,
3678     "content:", NULL, NULL,             NULL
3679   },
3680
3681   // ---------- custom enter and leave element (when moving) ------------------
3682
3683   {
3684     ED_AREA_1X1_SETTINGS_XPOS(1),       ED_AREA_1X1_SETTINGS_YPOS(3),
3685     ED_AREA_1X1_SETTINGS_XOFF,          ED_AREA_1X1_SETTINGS_YOFF,
3686     GADGET_ID_CUSTOM_MOVE_ENTER,        GADGET_ID_NONE,
3687     &custom_element.move_enter_element, 1, 1,
3688     "can dig:", " ", NULL,              "element that can be digged/collected"
3689   },
3690   {
3691     -1,                                 ED_AREA_1X1_SETTINGS_YPOS(3),
3692     0,                                  ED_AREA_1X1_SETTINGS_YOFF,
3693     GADGET_ID_CUSTOM_MOVE_LEAVE,        GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
3694     &custom_element.move_leave_element, 1, 1,
3695     NULL, NULL, NULL,                   "element that will be left behind"
3696   },
3697
3698   // ---------- element settings: advanced (custom elements) ------------------
3699
3700   // ---------- custom change target ------------------------------------------
3701
3702   {
3703     -1,                                 ED_AREA_1X1_SETTINGS_YPOS(1),
3704     0,                                  ED_AREA_1X1_SETTINGS_YOFF,
3705     GADGET_ID_CUSTOM_CHANGE_TARGET,     GADGET_ID_CUSTOM_CAN_CHANGE,
3706     &custom_element_change.target_element, 1, 1,
3707     NULL, "after/when:", NULL,          "new target element after change"
3708   },
3709
3710   // ---------- custom change content (extended change target) ----------------
3711
3712   {
3713     -1,                                 ED_AREA_3X3_SETTINGS_YPOS(9),
3714     0,                                  ED_AREA_3X3_SETTINGS_YOFF,
3715     GADGET_ID_CUSTOM_CHANGE_CONTENT,    GADGET_ID_NONE, // align three rows
3716     &custom_element_change.target_content.e[0][0], 3, 3,
3717     NULL, NULL, NULL,                   "new extended elements after change"
3718   },
3719
3720   // ---------- custom change trigger (element causing change) ----------------
3721
3722   {
3723     -1,                                 ED_AREA_1X1_SETTINGS_YPOS(5),
3724     0,                                  ED_AREA_1X1_SETTINGS_YOFF,
3725     GADGET_ID_CUSTOM_CHANGE_TRIGGER,    GADGET_ID_CHANGE_OTHER_ACTION,
3726     &custom_element_change.initial_trigger_element, 1, 1,
3727     NULL, NULL, NULL,                   "other element triggering change"
3728   },
3729
3730   // ---------- custom change action (element used for action) ----------------
3731
3732   {
3733     -1,                                 ED_AREA_1X1_SETTINGS_YPOS(13),
3734     0,                                  ED_AREA_1X1_SETTINGS_YOFF,
3735     GADGET_ID_CUSTOM_CHANGE_ACTION,     GADGET_ID_ACTION_ARG,
3736     &custom_element_change.action_element, 1, 1,
3737     NULL, NULL, NULL,                   "element used as action parameter"
3738   },
3739
3740   // ---------- group element content -----------------------------------------
3741
3742   {
3743     ED_AREA_1X1_SETTINGS_XPOS(0),       ED_AREA_1X1_SETTINGS_YPOS(2),
3744     ED_AREA_1X1_SETTINGS_XOFF,          ED_AREA_1X1_SETTINGS_YOFF,
3745     GADGET_ID_GROUP_CONTENT,            GADGET_ID_NONE,
3746     &group_element_info.element[0],     MAX_ELEMENTS_IN_GROUP, 1,
3747     "content:", NULL, NULL,             NULL
3748   },
3749
3750   // ---------- random background (for random painting) -----------------------
3751
3752   {
3753     -1,                                 ED_AREA_1X1_LSETTINGS_YPOS(1),
3754     0,                                  ED_AREA_1X1_LSETTINGS_YOFF,
3755     GADGET_ID_RANDOM_BACKGROUND,        GADGET_ID_RANDOM_RESTRICTED,
3756     &random_placement_background_element, 1, 1,
3757     NULL, NULL, NULL,                   "random placement background"
3758   },
3759 };
3760
3761
3762 // ----------------------------------------------------------------------------
3763 // some internally used variables
3764 // ----------------------------------------------------------------------------
3765
3766 // maximal size of level editor drawing area
3767 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
3768
3769 // actual size of level editor drawing area
3770 static int ed_fieldx, ed_fieldy;
3771
3772 // actual position of level editor drawing area in level playfield
3773 static int level_xpos = -1, level_ypos = -1;
3774
3775 // actual tile size used to display playfield drawing area
3776 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
3777 static int ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
3778
3779 #define IN_ED_FIELD(x,y)        IN_FIELD(x, y, ed_fieldx, ed_fieldy)
3780
3781 // drawing elements on the three mouse buttons
3782 static int new_element1 = EL_WALL;
3783 static int new_element2 = EL_EMPTY;
3784 static int new_element3 = EL_SAND;
3785
3786 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
3787 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
3788                                 (button) == 2 ? new_element2 : \
3789                                 (button) == 3 ? new_element3 : EL_EMPTY)
3790
3791 #define BUTTON_TILE_SIZE(x)     ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE)
3792
3793 static int use_permanent_palette = TRUE;
3794
3795 #define PX              (use_permanent_palette ? DX : SX)
3796 #define PY              (use_permanent_palette ? DY : SY)
3797 #define PXSIZE          (use_permanent_palette ? DXSIZE : SXSIZE)
3798 #define PYSIZE          (use_permanent_palette ? DYSIZE : SYSIZE)
3799
3800 // forward declaration for internal use
3801 static void CopyBrushToCursor(int, int);
3802 static void DeleteBrushFromCursor(void);
3803 static void ModifyEditorCounterValue(int, int);
3804 static void ModifyEditorCounterLimits(int, int, int);
3805 static void ModifyEditorSelectboxValue(int, int);
3806 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
3807 static void ModifyEditorDrawingArea(int, int, int);
3808 static void ModifyEditorElementList(void);
3809 static void AdjustElementListScrollbar(void);
3810 static void RedrawDrawingElements(void);
3811 static void DrawDrawingWindowExt(boolean);
3812 static void DrawDrawingWindow(void);
3813 static void DrawLevelInfoWindow(void);
3814 static void DrawPropertiesWindow(void);
3815 static void DrawPaletteWindow(void);
3816 static void UpdateCustomElementGraphicGadgets(void);
3817 static boolean checkPropertiesConfig(int);
3818 static void SetAutomaticNumberOfGemsNeeded(void);
3819 static void ClearEditorGadgetInfoText(void);
3820 static void CopyLevelToUndoBuffer(int);
3821 static void HandleDrawingAreas(struct GadgetInfo *);
3822 static void HandleCounterButtons(struct GadgetInfo *);
3823 static void HandleTextInputGadgets(struct GadgetInfo *);
3824 static void HandleTextAreaGadgets(struct GadgetInfo *);
3825 static void HandleSelectboxGadgets(struct GadgetInfo *);
3826 static void HandleTextbuttonGadgets(struct GadgetInfo *);
3827 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
3828 static void HandleRadiobuttons(struct GadgetInfo *);
3829 static void HandleCheckbuttons(struct GadgetInfo *);
3830 static void HandleControlButtons(struct GadgetInfo *);
3831 static void HandleDrawingAreaInfo(struct GadgetInfo *);
3832 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
3833 static boolean AskToCopyAndModifyLevelTemplate(void);
3834 static boolean getDrawModeHiRes(void);
3835 static int getTabulatorBarWidth(void);
3836 static int getTabulatorBarHeight(void);
3837 static Pixel getTabulatorBarColor(void);
3838
3839 static int num_editor_gadgets = 0;      // dynamically determined
3840
3841 static struct GadgetInfo **level_editor_gadget = NULL;
3842 static int *right_gadget_border = NULL;
3843
3844 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
3845 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
3846 static boolean draw_with_brush = FALSE;
3847 static int properties_element = 0;
3848
3849 static short FieldBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3850 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3851 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3852 static int undo_buffer_position = 0;
3853 static int undo_buffer_steps = 0;
3854 static int redo_buffer_steps = 0;
3855
3856 static int edit_mode;
3857 static int edit_mode_levelinfo;
3858 static int edit_mode_properties;
3859
3860 static int element_shift = 0;
3861
3862 static int editor_el_players[] =
3863 {
3864   EL_PLAYER_1,
3865   EL_PLAYER_2,
3866   EL_PLAYER_3,
3867   EL_PLAYER_4
3868 };
3869 static int *editor_el_players_ptr = editor_el_players;
3870 static int num_editor_el_players = ARRAY_SIZE(editor_el_players);
3871
3872 static int editor_hl_boulderdash[] =
3873 {
3874   EL_INTERNAL_CASCADE_BD_ACTIVE,
3875   EL_CHAR('B'),
3876   EL_CHAR('D'),
3877   EL_EMPTY,
3878 };
3879
3880 static int editor_el_boulderdash[] =
3881 {
3882   EL_EMPTY,
3883   EL_SAND,
3884   EL_BD_ROCK,
3885   EL_BD_DIAMOND,
3886
3887   EL_STEELWALL,
3888   EL_BD_WALL,
3889   EL_BD_EXPANDABLE_WALL,
3890   EL_BD_MAGIC_WALL,
3891
3892   EL_BD_AMOEBA,
3893   EL_BD_BUTTERFLY_UP,
3894   EL_BD_FIREFLY_UP,
3895   EL_EXIT_CLOSED,
3896
3897   EL_BD_BUTTERFLY_LEFT,
3898   EL_BD_FIREFLY_LEFT,
3899   EL_BD_BUTTERFLY_RIGHT,
3900   EL_BD_FIREFLY_RIGHT,
3901
3902   EL_EMPTY,
3903   EL_BD_BUTTERFLY_DOWN,
3904   EL_BD_FIREFLY_DOWN,
3905   EL_EXIT_OPEN,
3906 };
3907 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
3908 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
3909 static int num_editor_hl_boulderdash = ARRAY_SIZE(editor_hl_boulderdash);
3910 static int num_editor_el_boulderdash = ARRAY_SIZE(editor_el_boulderdash);
3911
3912 static int editor_hl_emerald_mine[] =
3913 {
3914   EL_INTERNAL_CASCADE_EM_ACTIVE,
3915   EL_CHAR('E'),
3916   EL_CHAR('M'),
3917   EL_EMPTY,
3918 };
3919
3920 static int editor_el_emerald_mine[] =
3921 {
3922   EL_SAND,
3923   EL_ROCK,
3924   EL_QUICKSAND_EMPTY,
3925   EL_QUICKSAND_FULL,
3926
3927   EL_STEELWALL,
3928   EL_WALL,
3929   EL_WALL_SLIPPERY,
3930   EL_MAGIC_WALL,
3931
3932   EL_EMERALD,
3933   EL_DIAMOND,
3934   EL_NUT,
3935   EL_BOMB,
3936
3937   EL_EM_DYNAMITE,
3938   EL_EM_DYNAMITE_ACTIVE,
3939   EL_EM_EXIT_CLOSED,
3940   EL_EM_EXIT_OPEN,
3941
3942   EL_YAMYAM_UP,
3943   EL_BUG_UP,
3944   EL_SPACESHIP_UP,
3945   EL_ROBOT,
3946
3947   EL_BUG_LEFT,
3948   EL_SPACESHIP_LEFT,
3949   EL_BUG_RIGHT,
3950   EL_SPACESHIP_RIGHT,
3951
3952   EL_ROBOT_WHEEL,
3953   EL_BUG_DOWN,
3954   EL_SPACESHIP_DOWN,
3955   EL_INVISIBLE_WALL,
3956
3957   EL_ACID_POOL_TOPLEFT,
3958   EL_ACID,
3959   EL_ACID_POOL_TOPRIGHT,
3960   EL_AMOEBA_DROP,
3961
3962   EL_ACID_POOL_BOTTOMLEFT,
3963   EL_ACID_POOL_BOTTOM,
3964   EL_ACID_POOL_BOTTOMRIGHT,
3965   EL_AMOEBA_WET,
3966
3967   EL_EM_KEY_1,
3968   EL_EM_KEY_2,
3969   EL_EM_KEY_3,
3970   EL_EM_KEY_4,
3971
3972   EL_EM_GATE_1,
3973   EL_EM_GATE_2,
3974   EL_EM_GATE_3,
3975   EL_EM_GATE_4,
3976
3977   EL_EM_GATE_1_GRAY,
3978   EL_EM_GATE_2_GRAY,
3979   EL_EM_GATE_3_GRAY,
3980   EL_EM_GATE_4_GRAY,
3981 };
3982 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
3983 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
3984 static int num_editor_hl_emerald_mine = ARRAY_SIZE(editor_hl_emerald_mine);
3985 static int num_editor_el_emerald_mine = ARRAY_SIZE(editor_el_emerald_mine);
3986
3987 static int editor_hl_emerald_mine_club[] =
3988 {
3989   EL_INTERNAL_CASCADE_EMC_ACTIVE,
3990   EL_CHAR('E'),
3991   EL_CHAR('M'),
3992   EL_CHAR('C'),
3993 };
3994
3995 static int editor_el_emerald_mine_club[] =
3996 {
3997   EL_EMC_KEY_5,
3998   EL_EMC_KEY_6,
3999   EL_EMC_KEY_7,
4000   EL_EMC_KEY_8,
4001
4002   EL_EMC_GATE_5,
4003   EL_EMC_GATE_6,
4004   EL_EMC_GATE_7,
4005   EL_EMC_GATE_8,
4006
4007   EL_EMC_GATE_5_GRAY,
4008   EL_EMC_GATE_6_GRAY,
4009   EL_EMC_GATE_7_GRAY,
4010   EL_EMC_GATE_8_GRAY,
4011
4012   EL_EMC_STEELWALL_1,
4013   EL_EMC_STEELWALL_2,
4014   EL_EMC_STEELWALL_3,
4015   EL_EMC_STEELWALL_4,
4016
4017   EL_EMC_WALL_13,
4018   EL_EMC_WALL_14,
4019   EL_EMC_WALL_15,
4020   EL_EMC_WALL_16,
4021
4022   EL_EMC_WALL_SLIPPERY_1,
4023   EL_EMC_WALL_SLIPPERY_2,
4024   EL_EMC_WALL_SLIPPERY_3,
4025   EL_EMC_WALL_SLIPPERY_4,
4026
4027   EL_EMC_WALL_1,
4028   EL_EMC_WALL_2,
4029   EL_EMC_WALL_3,
4030   EL_EMC_WALL_4,