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