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