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