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