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