1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // http://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
14 #include "libgame/libgame.h"
25 #define INFOTEXT_UNKNOWN_ELEMENT "unknown"
29 -----------------------------------------------------------------------------
30 screen and artwork graphic pixel position definitions
31 -----------------------------------------------------------------------------
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
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
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)
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))
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)
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)
97 #define ED_TABBUTTON_XSIZE (graphic_info[IMG_EDITOR_TABBUTTON].width)
98 #define ED_TABBUTTON_YSIZE (graphic_info[IMG_EDITOR_TABBUTTON].height)
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)
106 #define ED_SETTINGS_TABS_XOFFSET (editor.settings.tabs.draw_xoffset)
107 #define ED_SETTINGS_TABS_YOFFSET (editor.settings.tabs.draw_yoffset)
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)
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)
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)
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))
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))
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))
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))
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)
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)
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)
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)
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)
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)
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)))
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)))
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)))
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)))
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))
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)
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)
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)
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))
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)
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)
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)
268 /* element content */
269 #define ED_AREA_ELEMENT_CONTENT_XOFF(n) (n)
270 #define ED_AREA_ELEMENT_CONTENT_YOFF(n) (n)
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) + \
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))
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) + \
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))
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)
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)
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)
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)
344 /* values for ClearEditorGadgetInfoText() and HandleEditorGadgetInfoText() */
345 #define INFOTEXT_FONT FONT_TEXT_2
346 #define INFOTEXT_XSIZE SXSIZE
347 #define INFOTEXT_YSIZE getFontHeight(INFOTEXT_FONT)
348 #define INFOTEXT_YSIZE_FULL (INFOTEXT_YSIZE + ED_GADGET_SMALL_DISTANCE)
349 #define INFOTEXT_XPOS SX
350 #define INFOTEXT_YPOS (SY + SYSIZE - INFOTEXT_YSIZE)
354 -----------------------------------------------------------------------------
355 editor gadget definitions
356 -----------------------------------------------------------------------------
359 /* drawing toolbox buttons */
360 #define GADGET_ID_NONE -1
361 #define GADGET_ID_TOOLBOX_FIRST 0
363 #define GADGET_ID_SINGLE_ITEMS (GADGET_ID_TOOLBOX_FIRST + 0)
364 #define GADGET_ID_CONNECTED_ITEMS (GADGET_ID_TOOLBOX_FIRST + 1)
365 #define GADGET_ID_LINE (GADGET_ID_TOOLBOX_FIRST + 2)
366 #define GADGET_ID_ARC (GADGET_ID_TOOLBOX_FIRST + 3)
367 #define GADGET_ID_RECTANGLE (GADGET_ID_TOOLBOX_FIRST + 4)
368 #define GADGET_ID_FILLED_BOX (GADGET_ID_TOOLBOX_FIRST + 5)
369 #define GADGET_ID_WRAP_UP (GADGET_ID_TOOLBOX_FIRST + 6)
370 #define GADGET_ID_TEXT (GADGET_ID_TOOLBOX_FIRST + 7)
371 #define GADGET_ID_FLOOD_FILL (GADGET_ID_TOOLBOX_FIRST + 8)
372 #define GADGET_ID_WRAP_LEFT (GADGET_ID_TOOLBOX_FIRST + 9)
373 #define GADGET_ID_ZOOM (GADGET_ID_TOOLBOX_FIRST + 10)
374 #define GADGET_ID_WRAP_RIGHT (GADGET_ID_TOOLBOX_FIRST + 11)
375 #define GADGET_ID_RANDOM_PLACEMENT (GADGET_ID_TOOLBOX_FIRST + 12)
376 #define GADGET_ID_GRAB_BRUSH (GADGET_ID_TOOLBOX_FIRST + 13)
377 #define GADGET_ID_WRAP_DOWN (GADGET_ID_TOOLBOX_FIRST + 14)
378 #define GADGET_ID_PICK_ELEMENT (GADGET_ID_TOOLBOX_FIRST + 15)
380 #define GADGET_ID_UNDO (GADGET_ID_TOOLBOX_FIRST + 16)
381 #define GADGET_ID_INFO (GADGET_ID_TOOLBOX_FIRST + 17)
382 #define GADGET_ID_SAVE (GADGET_ID_TOOLBOX_FIRST + 18)
383 #define GADGET_ID_CLEAR (GADGET_ID_TOOLBOX_FIRST + 19)
384 #define GADGET_ID_TEST (GADGET_ID_TOOLBOX_FIRST + 20)
385 #define GADGET_ID_EXIT (GADGET_ID_TOOLBOX_FIRST + 21)
387 #define GADGET_ID_CUSTOM_COPY_FROM (GADGET_ID_TOOLBOX_FIRST + 22)
388 #define GADGET_ID_CUSTOM_COPY_TO (GADGET_ID_TOOLBOX_FIRST + 23)
389 #define GADGET_ID_CUSTOM_EXCHANGE (GADGET_ID_TOOLBOX_FIRST + 24)
390 #define GADGET_ID_CUSTOM_COPY (GADGET_ID_TOOLBOX_FIRST + 25)
391 #define GADGET_ID_CUSTOM_PASTE (GADGET_ID_TOOLBOX_FIRST + 26)
393 #define GADGET_ID_PROPERTIES (GADGET_ID_TOOLBOX_FIRST + 27)
394 #define GADGET_ID_ELEMENT_LEFT (GADGET_ID_TOOLBOX_FIRST + 28)
395 #define GADGET_ID_ELEMENT_MIDDLE (GADGET_ID_TOOLBOX_FIRST + 29)
396 #define GADGET_ID_ELEMENT_RIGHT (GADGET_ID_TOOLBOX_FIRST + 30)
397 #define GADGET_ID_PALETTE (GADGET_ID_TOOLBOX_FIRST + 31)
399 /* counter gadget identifiers */
400 #define GADGET_ID_COUNTER_FIRST (GADGET_ID_TOOLBOX_FIRST + 32)
402 #define GADGET_ID_SELECT_LEVEL_DOWN (GADGET_ID_COUNTER_FIRST + 0)
403 #define GADGET_ID_SELECT_LEVEL_TEXT (GADGET_ID_COUNTER_FIRST + 1)
404 #define GADGET_ID_SELECT_LEVEL_UP (GADGET_ID_COUNTER_FIRST + 2)
405 #define GADGET_ID_LEVEL_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 3)
406 #define GADGET_ID_LEVEL_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 4)
407 #define GADGET_ID_LEVEL_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 5)
408 #define GADGET_ID_LEVEL_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 6)
409 #define GADGET_ID_LEVEL_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 7)
410 #define GADGET_ID_LEVEL_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 8)
411 #define GADGET_ID_LEVEL_RANDOM_DOWN (GADGET_ID_COUNTER_FIRST + 9)
412 #define GADGET_ID_LEVEL_RANDOM_TEXT (GADGET_ID_COUNTER_FIRST + 10)
413 #define GADGET_ID_LEVEL_RANDOM_UP (GADGET_ID_COUNTER_FIRST + 11)
414 #define GADGET_ID_LEVEL_GEMSLIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 12)
415 #define GADGET_ID_LEVEL_GEMSLIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 13)
416 #define GADGET_ID_LEVEL_GEMSLIMIT_UP (GADGET_ID_COUNTER_FIRST + 14)
417 #define GADGET_ID_LEVEL_TIMELIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 15)
418 #define GADGET_ID_LEVEL_TIMELIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 16)
419 #define GADGET_ID_LEVEL_TIMELIMIT_UP (GADGET_ID_COUNTER_FIRST + 17)
420 #define GADGET_ID_LEVEL_TIMESCORE_DOWN (GADGET_ID_COUNTER_FIRST + 18)
421 #define GADGET_ID_LEVEL_TIMESCORE_TEXT (GADGET_ID_COUNTER_FIRST + 19)
422 #define GADGET_ID_LEVEL_TIMESCORE_UP (GADGET_ID_COUNTER_FIRST + 20)
423 #define GADGET_ID_LEVEL_RANDOM_SEED_DOWN (GADGET_ID_COUNTER_FIRST + 21)
424 #define GADGET_ID_LEVEL_RANDOM_SEED_TEXT (GADGET_ID_COUNTER_FIRST + 22)
425 #define GADGET_ID_LEVEL_RANDOM_SEED_UP (GADGET_ID_COUNTER_FIRST + 23)
426 #define GADGET_ID_LEVELSET_NUM_LEVELS_DOWN (GADGET_ID_COUNTER_FIRST + 24)
427 #define GADGET_ID_LEVELSET_NUM_LEVELS_TEXT (GADGET_ID_COUNTER_FIRST + 25)
428 #define GADGET_ID_LEVELSET_NUM_LEVELS_UP (GADGET_ID_COUNTER_FIRST + 26)
429 #define GADGET_ID_ELEMENT_VALUE1_DOWN (GADGET_ID_COUNTER_FIRST + 27)
430 #define GADGET_ID_ELEMENT_VALUE1_TEXT (GADGET_ID_COUNTER_FIRST + 28)
431 #define GADGET_ID_ELEMENT_VALUE1_UP (GADGET_ID_COUNTER_FIRST + 29)
432 #define GADGET_ID_ELEMENT_VALUE2_DOWN (GADGET_ID_COUNTER_FIRST + 30)
433 #define GADGET_ID_ELEMENT_VALUE2_TEXT (GADGET_ID_COUNTER_FIRST + 31)
434 #define GADGET_ID_ELEMENT_VALUE2_UP (GADGET_ID_COUNTER_FIRST + 32)
435 #define GADGET_ID_ELEMENT_VALUE3_DOWN (GADGET_ID_COUNTER_FIRST + 33)
436 #define GADGET_ID_ELEMENT_VALUE3_TEXT (GADGET_ID_COUNTER_FIRST + 34)
437 #define GADGET_ID_ELEMENT_VALUE3_UP (GADGET_ID_COUNTER_FIRST + 35)
438 #define GADGET_ID_ELEMENT_VALUE4_DOWN (GADGET_ID_COUNTER_FIRST + 36)
439 #define GADGET_ID_ELEMENT_VALUE4_TEXT (GADGET_ID_COUNTER_FIRST + 37)
440 #define GADGET_ID_ELEMENT_VALUE4_UP (GADGET_ID_COUNTER_FIRST + 38)
441 #define GADGET_ID_YAMYAM_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 39)
442 #define GADGET_ID_YAMYAM_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 40)
443 #define GADGET_ID_YAMYAM_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 41)
444 #define GADGET_ID_BALL_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 42)
445 #define GADGET_ID_BALL_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 43)
446 #define GADGET_ID_BALL_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 44)
447 #define GADGET_ID_ANDROID_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 45)
448 #define GADGET_ID_ANDROID_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 46)
449 #define GADGET_ID_ANDROID_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 47)
450 #define GADGET_ID_ENVELOPE_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 48)
451 #define GADGET_ID_ENVELOPE_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 49)
452 #define GADGET_ID_ENVELOPE_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 50)
453 #define GADGET_ID_ENVELOPE_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 51)
454 #define GADGET_ID_ENVELOPE_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 52)
455 #define GADGET_ID_ENVELOPE_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 53)
456 #define GADGET_ID_INVENTORY_SIZE_DOWN (GADGET_ID_COUNTER_FIRST + 54)
457 #define GADGET_ID_INVENTORY_SIZE_TEXT (GADGET_ID_COUNTER_FIRST + 55)
458 #define GADGET_ID_INVENTORY_SIZE_UP (GADGET_ID_COUNTER_FIRST + 56)
459 #define GADGET_ID_CUSTOM_SCORE_DOWN (GADGET_ID_COUNTER_FIRST + 57)
460 #define GADGET_ID_CUSTOM_SCORE_TEXT (GADGET_ID_COUNTER_FIRST + 58)
461 #define GADGET_ID_CUSTOM_SCORE_UP (GADGET_ID_COUNTER_FIRST + 59)
462 #define GADGET_ID_CUSTOM_GEMCOUNT_DOWN (GADGET_ID_COUNTER_FIRST + 60)
463 #define GADGET_ID_CUSTOM_GEMCOUNT_TEXT (GADGET_ID_COUNTER_FIRST + 61)
464 #define GADGET_ID_CUSTOM_GEMCOUNT_UP (GADGET_ID_COUNTER_FIRST + 62)
465 #define GADGET_ID_CUSTOM_VALUE_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 63)
466 #define GADGET_ID_CUSTOM_VALUE_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 64)
467 #define GADGET_ID_CUSTOM_VALUE_FIX_UP (GADGET_ID_COUNTER_FIRST + 65)
468 #define GADGET_ID_CUSTOM_VALUE_RND_DOWN (GADGET_ID_COUNTER_FIRST + 66)
469 #define GADGET_ID_CUSTOM_VALUE_RND_TEXT (GADGET_ID_COUNTER_FIRST + 67)
470 #define GADGET_ID_CUSTOM_VALUE_RND_UP (GADGET_ID_COUNTER_FIRST + 68)
471 #define GADGET_ID_PUSH_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 69)
472 #define GADGET_ID_PUSH_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 70)
473 #define GADGET_ID_PUSH_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 71)
474 #define GADGET_ID_PUSH_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 72)
475 #define GADGET_ID_PUSH_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 73)
476 #define GADGET_ID_PUSH_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 74)
477 #define GADGET_ID_DROP_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 75)
478 #define GADGET_ID_DROP_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 76)
479 #define GADGET_ID_DROP_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 77)
480 #define GADGET_ID_DROP_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 78)
481 #define GADGET_ID_DROP_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 79)
482 #define GADGET_ID_DROP_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 80)
483 #define GADGET_ID_MOVE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 81)
484 #define GADGET_ID_MOVE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 82)
485 #define GADGET_ID_MOVE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 83)
486 #define GADGET_ID_MOVE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 84)
487 #define GADGET_ID_MOVE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 85)
488 #define GADGET_ID_MOVE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 86)
489 #define GADGET_ID_EXPLOSION_DELAY_DOWN (GADGET_ID_COUNTER_FIRST + 87)
490 #define GADGET_ID_EXPLOSION_DELAY_TEXT (GADGET_ID_COUNTER_FIRST + 88)
491 #define GADGET_ID_EXPLOSION_DELAY_UP (GADGET_ID_COUNTER_FIRST + 89)
492 #define GADGET_ID_IGNITION_DELAY_DOWN (GADGET_ID_COUNTER_FIRST + 90)
493 #define GADGET_ID_IGNITION_DELAY_TEXT (GADGET_ID_COUNTER_FIRST + 91)
494 #define GADGET_ID_IGNITION_DELAY_UP (GADGET_ID_COUNTER_FIRST + 92)
495 #define GADGET_ID_CHANGE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 93)
496 #define GADGET_ID_CHANGE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 94)
497 #define GADGET_ID_CHANGE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 95)
498 #define GADGET_ID_CHANGE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 96)
499 #define GADGET_ID_CHANGE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 97)
500 #define GADGET_ID_CHANGE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 98)
501 #define GADGET_ID_CHANGE_CONT_RND_DOWN (GADGET_ID_COUNTER_FIRST + 99)
502 #define GADGET_ID_CHANGE_CONT_RND_TEXT (GADGET_ID_COUNTER_FIRST + 100)
503 #define GADGET_ID_CHANGE_CONT_RND_UP (GADGET_ID_COUNTER_FIRST + 101)
504 #define GADGET_ID_GROUP_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 102)
505 #define GADGET_ID_GROUP_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 103)
506 #define GADGET_ID_GROUP_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 104)
508 /* drawing area identifiers */
509 #define GADGET_ID_DRAWING_AREA_FIRST (GADGET_ID_COUNTER_FIRST + 105)
511 #define GADGET_ID_DRAWING_LEVEL (GADGET_ID_DRAWING_AREA_FIRST + 0)
512 #define GADGET_ID_YAMYAM_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 1)
513 #define GADGET_ID_YAMYAM_CONTENT_1 (GADGET_ID_DRAWING_AREA_FIRST + 2)
514 #define GADGET_ID_YAMYAM_CONTENT_2 (GADGET_ID_DRAWING_AREA_FIRST + 3)
515 #define GADGET_ID_YAMYAM_CONTENT_3 (GADGET_ID_DRAWING_AREA_FIRST + 4)
516 #define GADGET_ID_YAMYAM_CONTENT_4 (GADGET_ID_DRAWING_AREA_FIRST + 5)
517 #define GADGET_ID_YAMYAM_CONTENT_5 (GADGET_ID_DRAWING_AREA_FIRST + 6)
518 #define GADGET_ID_YAMYAM_CONTENT_6 (GADGET_ID_DRAWING_AREA_FIRST + 7)
519 #define GADGET_ID_YAMYAM_CONTENT_7 (GADGET_ID_DRAWING_AREA_FIRST + 8)
520 #define GADGET_ID_MAGIC_BALL_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 9)
521 #define GADGET_ID_MAGIC_BALL_CONTENT_1 (GADGET_ID_DRAWING_AREA_FIRST + 10)
522 #define GADGET_ID_MAGIC_BALL_CONTENT_2 (GADGET_ID_DRAWING_AREA_FIRST + 11)
523 #define GADGET_ID_MAGIC_BALL_CONTENT_3 (GADGET_ID_DRAWING_AREA_FIRST + 12)
524 #define GADGET_ID_MAGIC_BALL_CONTENT_4 (GADGET_ID_DRAWING_AREA_FIRST + 13)
525 #define GADGET_ID_MAGIC_BALL_CONTENT_5 (GADGET_ID_DRAWING_AREA_FIRST + 14)
526 #define GADGET_ID_MAGIC_BALL_CONTENT_6 (GADGET_ID_DRAWING_AREA_FIRST + 15)
527 #define GADGET_ID_MAGIC_BALL_CONTENT_7 (GADGET_ID_DRAWING_AREA_FIRST + 16)
528 #define GADGET_ID_ANDROID_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 17)
529 #define GADGET_ID_AMOEBA_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 18)
530 #define GADGET_ID_START_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 19)
531 #define GADGET_ID_ARTWORK_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 20)
532 #define GADGET_ID_EXPLOSION_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 21)
533 #define GADGET_ID_INVENTORY_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 22)
534 #define GADGET_ID_CUSTOM_GRAPHIC (GADGET_ID_DRAWING_AREA_FIRST + 23)
535 #define GADGET_ID_CUSTOM_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 24)
536 #define GADGET_ID_CUSTOM_MOVE_ENTER (GADGET_ID_DRAWING_AREA_FIRST + 25)
537 #define GADGET_ID_CUSTOM_MOVE_LEAVE (GADGET_ID_DRAWING_AREA_FIRST + 26)
538 #define GADGET_ID_CUSTOM_CHANGE_TARGET (GADGET_ID_DRAWING_AREA_FIRST + 27)
539 #define GADGET_ID_CUSTOM_CHANGE_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 28)
540 #define GADGET_ID_CUSTOM_CHANGE_TRIGGER (GADGET_ID_DRAWING_AREA_FIRST + 29)
541 #define GADGET_ID_CUSTOM_CHANGE_ACTION (GADGET_ID_DRAWING_AREA_FIRST + 30)
542 #define GADGET_ID_GROUP_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 31)
543 #define GADGET_ID_RANDOM_BACKGROUND (GADGET_ID_DRAWING_AREA_FIRST + 32)
545 /* text input identifiers */
546 #define GADGET_ID_TEXT_INPUT_FIRST (GADGET_ID_DRAWING_AREA_FIRST + 33)
548 #define GADGET_ID_LEVEL_NAME (GADGET_ID_TEXT_INPUT_FIRST + 0)
549 #define GADGET_ID_LEVEL_AUTHOR (GADGET_ID_TEXT_INPUT_FIRST + 1)
550 #define GADGET_ID_LEVELSET_NAME (GADGET_ID_TEXT_INPUT_FIRST + 2)
551 #define GADGET_ID_LEVELSET_AUTHOR (GADGET_ID_TEXT_INPUT_FIRST + 3)
552 #define GADGET_ID_ELEMENT_NAME (GADGET_ID_TEXT_INPUT_FIRST + 4)
554 /* text area identifiers */
555 #define GADGET_ID_TEXT_AREA_FIRST (GADGET_ID_TEXT_INPUT_FIRST + 5)
557 #define GADGET_ID_ENVELOPE_INFO (GADGET_ID_TEXT_AREA_FIRST + 0)
559 /* selectbox identifiers */
560 #define GADGET_ID_SELECTBOX_FIRST (GADGET_ID_TEXT_AREA_FIRST + 1)
562 #define GADGET_ID_TIME_OR_STEPS (GADGET_ID_SELECTBOX_FIRST + 0)
563 #define GADGET_ID_GAME_ENGINE_TYPE (GADGET_ID_SELECTBOX_FIRST + 1)
564 #define GADGET_ID_LEVELSET_SAVE_MODE (GADGET_ID_SELECTBOX_FIRST + 2)
565 #define GADGET_ID_WIND_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 3)
566 #define GADGET_ID_PLAYER_SPEED (GADGET_ID_SELECTBOX_FIRST + 4)
567 #define GADGET_ID_CUSTOM_WALK_TO_ACTION (GADGET_ID_SELECTBOX_FIRST + 5)
568 #define GADGET_ID_CUSTOM_EXPLOSION_TYPE (GADGET_ID_SELECTBOX_FIRST + 6)
569 #define GADGET_ID_CUSTOM_DEADLINESS (GADGET_ID_SELECTBOX_FIRST + 7)
570 #define GADGET_ID_CUSTOM_MOVE_PATTERN (GADGET_ID_SELECTBOX_FIRST + 8)
571 #define GADGET_ID_CUSTOM_MOVE_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 9)
572 #define GADGET_ID_CUSTOM_MOVE_STEPSIZE (GADGET_ID_SELECTBOX_FIRST + 10)
573 #define GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE (GADGET_ID_SELECTBOX_FIRST + 11)
574 #define GADGET_ID_CUSTOM_SMASH_TARGETS (GADGET_ID_SELECTBOX_FIRST + 12)
575 #define GADGET_ID_CUSTOM_SLIPPERY_TYPE (GADGET_ID_SELECTBOX_FIRST + 13)
576 #define GADGET_ID_CUSTOM_ACCESS_TYPE (GADGET_ID_SELECTBOX_FIRST + 14)
577 #define GADGET_ID_CUSTOM_ACCESS_LAYER (GADGET_ID_SELECTBOX_FIRST + 15)
578 #define GADGET_ID_CUSTOM_ACCESS_PROTECTED (GADGET_ID_SELECTBOX_FIRST + 16)
579 #define GADGET_ID_CUSTOM_ACCESS_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 17)
580 #define GADGET_ID_CHANGE_TIME_UNITS (GADGET_ID_SELECTBOX_FIRST + 18)
581 #define GADGET_ID_CHANGE_DIRECT_ACTION (GADGET_ID_SELECTBOX_FIRST + 19)
582 #define GADGET_ID_CHANGE_OTHER_ACTION (GADGET_ID_SELECTBOX_FIRST + 20)
583 #define GADGET_ID_CHANGE_SIDE (GADGET_ID_SELECTBOX_FIRST + 21)
584 #define GADGET_ID_CHANGE_PLAYER (GADGET_ID_SELECTBOX_FIRST + 22)
585 #define GADGET_ID_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 23)
586 #define GADGET_ID_CHANGE_REPLACE_WHEN (GADGET_ID_SELECTBOX_FIRST + 24)
587 #define GADGET_ID_ACTION_TYPE (GADGET_ID_SELECTBOX_FIRST + 25)
588 #define GADGET_ID_ACTION_MODE (GADGET_ID_SELECTBOX_FIRST + 26)
589 #define GADGET_ID_ACTION_ARG (GADGET_ID_SELECTBOX_FIRST + 27)
590 #define GADGET_ID_SELECT_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 28)
591 #define GADGET_ID_GROUP_CHOICE_MODE (GADGET_ID_SELECTBOX_FIRST + 29)
593 /* textbutton identifiers */
594 #define GADGET_ID_TEXTBUTTON_FIRST (GADGET_ID_SELECTBOX_FIRST + 30)
596 #define GADGET_ID_LEVELINFO_LEVEL (GADGET_ID_TEXTBUTTON_FIRST + 0)
597 #define GADGET_ID_LEVELINFO_LEVELSET (GADGET_ID_TEXTBUTTON_FIRST + 1)
598 #define GADGET_ID_LEVELINFO_EDITOR (GADGET_ID_TEXTBUTTON_FIRST + 2)
599 #define GADGET_ID_PROPERTIES_INFO (GADGET_ID_TEXTBUTTON_FIRST + 3)
600 #define GADGET_ID_PROPERTIES_CONFIG (GADGET_ID_TEXTBUTTON_FIRST + 4)
601 #define GADGET_ID_PROPERTIES_CONFIG_1 (GADGET_ID_TEXTBUTTON_FIRST + 5)
602 #define GADGET_ID_PROPERTIES_CONFIG_2 (GADGET_ID_TEXTBUTTON_FIRST + 6)
603 #define GADGET_ID_PROPERTIES_CHANGE (GADGET_ID_TEXTBUTTON_FIRST + 7)
604 #define GADGET_ID_SAVE_AS_TEMPLATE_1 (GADGET_ID_TEXTBUTTON_FIRST + 8)
605 #define GADGET_ID_SAVE_AS_TEMPLATE_2 (GADGET_ID_TEXTBUTTON_FIRST + 9)
606 #define GADGET_ID_SAVE_LEVELSET (GADGET_ID_TEXTBUTTON_FIRST + 10)
607 #define GADGET_ID_ADD_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 11)
608 #define GADGET_ID_DEL_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 12)
610 /* graphicbutton identifiers */
611 #define GADGET_ID_GRAPHICBUTTON_FIRST (GADGET_ID_TEXTBUTTON_FIRST + 13)
613 #define GADGET_ID_PREV_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 0)
614 #define GADGET_ID_NEXT_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 1)
615 #define GADGET_ID_COPY_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 2)
616 #define GADGET_ID_PASTE_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 3)
618 /* gadgets for scrolling of drawing area */
619 #define GADGET_ID_SCROLLING_FIRST (GADGET_ID_GRAPHICBUTTON_FIRST + 4)
621 #define GADGET_ID_SCROLL_UP (GADGET_ID_SCROLLING_FIRST + 0)
622 #define GADGET_ID_SCROLL_DOWN (GADGET_ID_SCROLLING_FIRST + 1)
623 #define GADGET_ID_SCROLL_LEFT (GADGET_ID_SCROLLING_FIRST + 2)
624 #define GADGET_ID_SCROLL_RIGHT (GADGET_ID_SCROLLING_FIRST + 3)
625 #define GADGET_ID_SCROLL_HORIZONTAL (GADGET_ID_SCROLLING_FIRST + 4)
626 #define GADGET_ID_SCROLL_VERTICAL (GADGET_ID_SCROLLING_FIRST + 5)
628 /* gadgets for scrolling element list */
629 #define GADGET_ID_SCROLLING_LIST_FIRST (GADGET_ID_SCROLLING_FIRST + 6)
631 #define GADGET_ID_SCROLL_LIST_UP (GADGET_ID_SCROLLING_LIST_FIRST + 0)
632 #define GADGET_ID_SCROLL_LIST_DOWN (GADGET_ID_SCROLLING_LIST_FIRST + 1)
633 #define GADGET_ID_SCROLL_LIST_VERTICAL (GADGET_ID_SCROLLING_LIST_FIRST + 2)
635 /* checkbuttons/radiobuttons for level/element properties */
636 #define GADGET_ID_CHECKBUTTON_FIRST (GADGET_ID_SCROLLING_LIST_FIRST + 3)
638 #define GADGET_ID_AUTO_COUNT_GEMS (GADGET_ID_CHECKBUTTON_FIRST + 0)
639 #define GADGET_ID_RANDOM_PERCENTAGE (GADGET_ID_CHECKBUTTON_FIRST + 1)
640 #define GADGET_ID_RANDOM_QUANTITY (GADGET_ID_CHECKBUTTON_FIRST + 2)
641 #define GADGET_ID_RANDOM_RESTRICTED (GADGET_ID_CHECKBUTTON_FIRST + 3)
642 #define GADGET_ID_STICK_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 4)
643 #define GADGET_ID_EM_SLIPPERY_GEMS (GADGET_ID_CHECKBUTTON_FIRST + 5)
644 #define GADGET_ID_EM_EXPLODES_BY_FIRE (GADGET_ID_CHECKBUTTON_FIRST + 6)
645 #define GADGET_ID_USE_SPRING_BUG (GADGET_ID_CHECKBUTTON_FIRST + 7)
646 #define GADGET_ID_USE_TIME_ORB_BUG (GADGET_ID_CHECKBUTTON_FIRST + 8)
647 #define GADGET_ID_RANDOM_BALL_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 9)
648 #define GADGET_ID_INITIAL_BALL_STATE (GADGET_ID_CHECKBUTTON_FIRST + 10)
649 #define GADGET_ID_GROW_INTO_DIGGABLE (GADGET_ID_CHECKBUTTON_FIRST + 11)
650 #define GADGET_ID_AUTO_EXIT_SOKOBAN (GADGET_ID_CHECKBUTTON_FIRST + 12)
651 #define GADGET_ID_CONTINUOUS_SNAPPING (GADGET_ID_CHECKBUTTON_FIRST + 13)
652 #define GADGET_ID_BLOCK_SNAP_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 14)
653 #define GADGET_ID_BLOCK_LAST_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 15)
654 #define GADGET_ID_SP_BLOCK_LAST_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 16)
655 #define GADGET_ID_INSTANT_RELOCATION (GADGET_ID_CHECKBUTTON_FIRST + 17)
656 #define GADGET_ID_SHIFTED_RELOCATION (GADGET_ID_CHECKBUTTON_FIRST + 18)
657 #define GADGET_ID_LAZY_RELOCATION (GADGET_ID_CHECKBUTTON_FIRST + 19)
658 #define GADGET_ID_USE_START_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 20)
659 #define GADGET_ID_USE_ARTWORK_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 21)
660 #define GADGET_ID_USE_EXPLOSION_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 22)
661 #define GADGET_ID_INITIAL_GRAVITY (GADGET_ID_CHECKBUTTON_FIRST + 23)
662 #define GADGET_ID_USE_INITIAL_INVENTORY (GADGET_ID_CHECKBUTTON_FIRST + 24)
663 #define GADGET_ID_CAN_PASS_TO_WALKABLE (GADGET_ID_CHECKBUTTON_FIRST + 25)
664 #define GADGET_ID_CAN_FALL_INTO_ACID (GADGET_ID_CHECKBUTTON_FIRST + 26)
665 #define GADGET_ID_CAN_MOVE_INTO_ACID (GADGET_ID_CHECKBUTTON_FIRST + 27)
666 #define GADGET_ID_DONT_COLLIDE_WITH (GADGET_ID_CHECKBUTTON_FIRST + 28)
667 #define GADGET_ID_ENVELOPE_AUTOWRAP (GADGET_ID_CHECKBUTTON_FIRST + 29)
668 #define GADGET_ID_ENVELOPE_CENTERED (GADGET_ID_CHECKBUTTON_FIRST + 30)
669 #define GADGET_ID_MM_LASER_RED (GADGET_ID_CHECKBUTTON_FIRST + 31)
670 #define GADGET_ID_MM_LASER_GREEN (GADGET_ID_CHECKBUTTON_FIRST + 32)
671 #define GADGET_ID_MM_LASER_BLUE (GADGET_ID_CHECKBUTTON_FIRST + 33)
672 #define GADGET_ID_DF_LASER_RED (GADGET_ID_CHECKBUTTON_FIRST + 34)
673 #define GADGET_ID_DF_LASER_GREEN (GADGET_ID_CHECKBUTTON_FIRST + 35)
674 #define GADGET_ID_DF_LASER_BLUE (GADGET_ID_CHECKBUTTON_FIRST + 36)
675 #define GADGET_ID_CUSTOM_INDESTRUCTIBLE (GADGET_ID_CHECKBUTTON_FIRST + 37)
676 #define GADGET_ID_CUSTOM_CAN_EXPLODE (GADGET_ID_CHECKBUTTON_FIRST + 38)
677 #define GADGET_ID_CUSTOM_EXPLODE_FIRE (GADGET_ID_CHECKBUTTON_FIRST + 39)
678 #define GADGET_ID_CUSTOM_EXPLODE_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 40)
679 #define GADGET_ID_CUSTOM_EXPLODE_IMPACT (GADGET_ID_CHECKBUTTON_FIRST + 41)
680 #define GADGET_ID_CUSTOM_WALK_TO_OBJECT (GADGET_ID_CHECKBUTTON_FIRST + 42)
681 #define GADGET_ID_CUSTOM_DEADLY (GADGET_ID_CHECKBUTTON_FIRST + 43)
682 #define GADGET_ID_CUSTOM_CAN_MOVE (GADGET_ID_CHECKBUTTON_FIRST + 44)
683 #define GADGET_ID_CUSTOM_CAN_FALL (GADGET_ID_CHECKBUTTON_FIRST + 45)
684 #define GADGET_ID_CUSTOM_CAN_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 46)
685 #define GADGET_ID_CUSTOM_SLIPPERY (GADGET_ID_CHECKBUTTON_FIRST + 47)
686 #define GADGET_ID_CUSTOM_ACCESSIBLE (GADGET_ID_CHECKBUTTON_FIRST + 48)
687 #define GADGET_ID_CUSTOM_GRAV_REACHABLE (GADGET_ID_CHECKBUTTON_FIRST + 49)
688 #define GADGET_ID_CUSTOM_USE_LAST_VALUE (GADGET_ID_CHECKBUTTON_FIRST + 50)
689 #define GADGET_ID_CUSTOM_USE_GRAPHIC (GADGET_ID_CHECKBUTTON_FIRST + 51)
690 #define GADGET_ID_CUSTOM_USE_TEMPLATE_1 (GADGET_ID_CHECKBUTTON_FIRST + 52)
691 #define GADGET_ID_CUSTOM_USE_TEMPLATE_2 (GADGET_ID_CHECKBUTTON_FIRST + 53)
692 #define GADGET_ID_CUSTOM_USE_TEMPLATE_3 (GADGET_ID_CHECKBUTTON_FIRST + 54)
693 #define GADGET_ID_CUSTOM_CAN_CHANGE (GADGET_ID_CHECKBUTTON_FIRST + 55)
694 #define GADGET_ID_CHANGE_USE_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 56)
695 #define GADGET_ID_CHANGE_USE_EXPLOSION (GADGET_ID_CHECKBUTTON_FIRST + 57)
696 #define GADGET_ID_CHANGE_ONLY_COMPLETE (GADGET_ID_CHECKBUTTON_FIRST + 58)
697 #define GADGET_ID_CHANGE_USE_RANDOM (GADGET_ID_CHECKBUTTON_FIRST + 59)
698 #define GADGET_ID_CHANGE_HAS_ACTION (GADGET_ID_CHECKBUTTON_FIRST + 60)
699 #define GADGET_ID_CHANGE_DELAY (GADGET_ID_CHECKBUTTON_FIRST + 61)
700 #define GADGET_ID_CHANGE_BY_DIRECT_ACT (GADGET_ID_CHECKBUTTON_FIRST + 62)
701 #define GADGET_ID_CHANGE_BY_OTHER_ACT (GADGET_ID_CHECKBUTTON_FIRST + 63)
703 /* gadgets for buttons in element list */
704 #define GADGET_ID_ELEMENTLIST_FIRST (GADGET_ID_CHECKBUTTON_FIRST + 64)
705 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
706 ED_NUM_ELEMENTLIST_BUTTONS - 1)
708 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
710 /* radio button numbers */
711 #define RADIO_NR_NONE 0
712 #define RADIO_NR_DRAWING_TOOLBOX 1
713 #define RADIO_NR_RANDOM_ELEMENTS 2
715 /* values for counter gadgets */
716 #define ED_COUNTER_ID_SELECT_LEVEL 0
717 #define ED_COUNTER_ID_LEVEL_XSIZE 1
718 #define ED_COUNTER_ID_LEVEL_YSIZE 2
719 #define ED_COUNTER_ID_LEVEL_GEMSLIMIT 3
720 #define ED_COUNTER_ID_LEVEL_TIMELIMIT 4
721 #define ED_COUNTER_ID_LEVEL_TIMESCORE 5
722 #define ED_COUNTER_ID_LEVEL_RANDOM_SEED 6
723 #define ED_COUNTER_ID_LEVELSET_NUM_LEVELS 7
724 #define ED_COUNTER_ID_LEVEL_RANDOM 8
725 #define ED_COUNTER_ID_ELEMENT_VALUE1 9
726 #define ED_COUNTER_ID_ELEMENT_VALUE2 10
727 #define ED_COUNTER_ID_ELEMENT_VALUE3 11
728 #define ED_COUNTER_ID_ELEMENT_VALUE4 12
729 #define ED_COUNTER_ID_YAMYAM_CONTENT 13
730 #define ED_COUNTER_ID_BALL_CONTENT 14
731 #define ED_COUNTER_ID_ANDROID_CONTENT 15
732 #define ED_COUNTER_ID_ENVELOPE_XSIZE 16
733 #define ED_COUNTER_ID_ENVELOPE_YSIZE 17
734 #define ED_COUNTER_ID_INVENTORY_SIZE 18
735 #define ED_COUNTER_ID_CUSTOM_SCORE 19
736 #define ED_COUNTER_ID_CUSTOM_GEMCOUNT 20
737 #define ED_COUNTER_ID_CUSTOM_VALUE_FIX 21
738 #define ED_COUNTER_ID_CUSTOM_VALUE_RND 22
739 #define ED_COUNTER_ID_PUSH_DELAY_FIX 23
740 #define ED_COUNTER_ID_PUSH_DELAY_RND 24
741 #define ED_COUNTER_ID_DROP_DELAY_FIX 25
742 #define ED_COUNTER_ID_DROP_DELAY_RND 26
743 #define ED_COUNTER_ID_MOVE_DELAY_FIX 27
744 #define ED_COUNTER_ID_MOVE_DELAY_RND 28
745 #define ED_COUNTER_ID_EXPLOSION_DELAY 29
746 #define ED_COUNTER_ID_IGNITION_DELAY 30
747 #define ED_COUNTER_ID_GROUP_CONTENT 31
748 #define ED_COUNTER_ID_CHANGE_DELAY_FIX 32
749 #define ED_COUNTER_ID_CHANGE_DELAY_RND 33
750 #define ED_COUNTER_ID_CHANGE_CONT_RND 34
752 #define ED_NUM_COUNTERBUTTONS 35
754 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
755 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
756 #define ED_COUNTER_ID_LEVELSET_FIRST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
757 #define ED_COUNTER_ID_LEVELSET_LAST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
758 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
759 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
761 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
762 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
763 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
764 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
765 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
766 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
768 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
769 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
771 /* values for scrollbutton gadgets */
772 #define ED_SCROLLBUTTON_ID_AREA_UP 0
773 #define ED_SCROLLBUTTON_ID_AREA_DOWN 1
774 #define ED_SCROLLBUTTON_ID_AREA_LEFT 2
775 #define ED_SCROLLBUTTON_ID_AREA_RIGHT 3
776 #define ED_SCROLLBUTTON_ID_LIST_UP 4
777 #define ED_SCROLLBUTTON_ID_LIST_DOWN 5
779 #define ED_NUM_SCROLLBUTTONS 6
781 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
782 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
784 /* values for scrollbar gadgets */
785 #define ED_SCROLLBAR_ID_AREA_HORIZONTAL 0
786 #define ED_SCROLLBAR_ID_AREA_VERTICAL 1
787 #define ED_SCROLLBAR_ID_LIST_VERTICAL 2
789 #define ED_NUM_SCROLLBARS 3
791 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
792 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
794 /* values for text input gadgets */
795 #define ED_TEXTINPUT_ID_LEVEL_NAME 0
796 #define ED_TEXTINPUT_ID_LEVEL_AUTHOR 1
797 #define ED_TEXTINPUT_ID_LEVELSET_NAME 2
798 #define ED_TEXTINPUT_ID_LEVELSET_AUTHOR 3
799 #define ED_TEXTINPUT_ID_ELEMENT_NAME 4
801 #define ED_NUM_TEXTINPUT 5
803 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
804 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
806 #define ED_TEXTINPUT_ID_LEVELSET_FIRST ED_TEXTINPUT_ID_LEVELSET_NAME
807 #define ED_TEXTINPUT_ID_LEVELSET_LAST ED_TEXTINPUT_ID_LEVELSET_AUTHOR
809 /* values for text area gadgets */
810 #define ED_TEXTAREA_ID_ENVELOPE_INFO 0
812 #define ED_NUM_TEXTAREAS 1
814 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
815 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
817 /* values for selectbox gadgets */
818 #define ED_SELECTBOX_ID_TIME_OR_STEPS 0
819 #define ED_SELECTBOX_ID_GAME_ENGINE_TYPE 1
820 #define ED_SELECTBOX_ID_LEVELSET_SAVE_MODE 2
821 #define ED_SELECTBOX_ID_WIND_DIRECTION 3
822 #define ED_SELECTBOX_ID_PLAYER_SPEED 4
823 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE 5
824 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER 6
825 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED 7
826 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION 8
827 #define ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION 9
828 #define ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN 10
829 #define ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION 11
830 #define ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE 12
831 #define ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE 13
832 #define ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS 14
833 #define ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE 15
834 #define ED_SELECTBOX_ID_CUSTOM_DEADLINESS 16
835 #define ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE 17
836 #define ED_SELECTBOX_ID_CHANGE_TIME_UNITS 18
837 #define ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION 19
838 #define ED_SELECTBOX_ID_CHANGE_OTHER_ACTION 20
839 #define ED_SELECTBOX_ID_CHANGE_SIDE 21
840 #define ED_SELECTBOX_ID_CHANGE_PLAYER 22
841 #define ED_SELECTBOX_ID_CHANGE_PAGE 23
842 #define ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN 24
843 #define ED_SELECTBOX_ID_ACTION_TYPE 25
844 #define ED_SELECTBOX_ID_ACTION_MODE 26
845 #define ED_SELECTBOX_ID_ACTION_ARG 27
846 #define ED_SELECTBOX_ID_SELECT_CHANGE_PAGE 28
847 #define ED_SELECTBOX_ID_GROUP_CHOICE_MODE 29
849 #define ED_NUM_SELECTBOX 30
851 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
852 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_GAME_ENGINE_TYPE
854 #define ED_SELECTBOX_ID_LEVELSET_FIRST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
855 #define ED_SELECTBOX_ID_LEVELSET_LAST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
857 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
858 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
859 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
860 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
861 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
862 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
864 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
865 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
867 /* values for textbutton gadgets */
868 #define ED_TEXTBUTTON_ID_LEVELINFO_LEVEL 0
869 #define ED_TEXTBUTTON_ID_LEVELINFO_LEVELSET 1
870 #define ED_TEXTBUTTON_ID_LEVELINFO_EDITOR 2
871 #define ED_TEXTBUTTON_ID_PROPERTIES_INFO 3
872 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG 4
873 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1 5
874 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2 6
875 #define ED_TEXTBUTTON_ID_PROPERTIES_CHANGE 7
876 #define ED_TEXTBUTTON_ID_SAVE_LEVELSET 8
877 #define ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2 9
878 #define ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 10
879 #define ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE 11
880 #define ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE 12
882 #define ED_NUM_TEXTBUTTONS 13
884 #define ED_TAB_BUTTON_ID_LEVELINFO_FIRST ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
885 #define ED_TAB_BUTTON_ID_LEVELINFO_LAST ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
887 #define ED_TAB_BUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
888 #define ED_TAB_BUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
890 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
891 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
893 /* values for graphicbutton gadgets */
894 #define ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE 0
895 #define ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE 1
896 #define ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE 2
897 #define ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE 3
899 #define ED_NUM_GRAPHICBUTTONS 4
901 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
902 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
904 /* values for checkbutton gadgets */
905 #define ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS 0
906 #define ED_CHECKBUTTON_ID_RANDOM_RESTRICTED 1
907 #define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3 2
908 #define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2 3
909 #define ED_CHECKBUTTON_ID_STICK_ELEMENT 4
910 #define ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS 5
911 #define ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE 6
912 #define ED_CHECKBUTTON_ID_USE_SPRING_BUG 7
913 #define ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG 8
914 #define ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT 9
915 #define ED_CHECKBUTTON_ID_INITIAL_BALL_STATE 10
916 #define ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE 11
917 #define ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN 12
918 #define ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING 13
919 #define ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD 14
920 #define ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD 15
921 #define ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD 16
922 #define ED_CHECKBUTTON_ID_INSTANT_RELOCATION 17
923 #define ED_CHECKBUTTON_ID_SHIFTED_RELOCATION 18
924 #define ED_CHECKBUTTON_ID_LAZY_RELOCATION 19
925 #define ED_CHECKBUTTON_ID_USE_START_ELEMENT 20
926 #define ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT 21
927 #define ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT 22
928 #define ED_CHECKBUTTON_ID_INITIAL_GRAVITY 23
929 #define ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY 24
930 #define ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE 25
931 #define ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID 26
932 #define ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID 27
933 #define ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH 28
934 #define ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP 29
935 #define ED_CHECKBUTTON_ID_ENVELOPE_CENTERED 30
936 #define ED_CHECKBUTTON_ID_MM_LASER_RED 31
937 #define ED_CHECKBUTTON_ID_MM_LASER_GREEN 32
938 #define ED_CHECKBUTTON_ID_MM_LASER_BLUE 33
939 #define ED_CHECKBUTTON_ID_DF_LASER_RED 34
940 #define ED_CHECKBUTTON_ID_DF_LASER_GREEN 35
941 #define ED_CHECKBUTTON_ID_DF_LASER_BLUE 36
942 #define ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC 37
943 #define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 38
944 #define ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE 39
945 #define ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE 40
946 #define ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE 41
947 #define ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT 42
948 #define ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE 43
949 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE 44
950 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL 45
951 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH 46
952 #define ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY 47
953 #define ED_CHECKBUTTON_ID_CUSTOM_DEADLY 48
954 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE 49
955 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE 50
956 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH 51
957 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT 52
958 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE 53
959 #define ED_CHECKBUTTON_ID_CHANGE_DELAY 54
960 #define ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT 55
961 #define ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT 56
962 #define ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION 57
963 #define ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT 58
964 #define ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE 59
965 #define ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM 60
966 #define ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION 61
968 #define ED_NUM_CHECKBUTTONS 62
970 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
971 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
973 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
974 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2
976 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
977 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
978 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
979 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
980 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
981 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
983 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
984 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
986 /* values for radiobutton gadgets */
987 #define ED_RADIOBUTTON_ID_PERCENTAGE 0
988 #define ED_RADIOBUTTON_ID_QUANTITY 1
990 #define ED_NUM_RADIOBUTTONS 2
992 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
993 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
995 /* values for drawing area gadgets */
996 #define ED_DRAWING_ID_DRAWING_LEVEL 0
997 #define ED_DRAWING_ID_YAMYAM_CONTENT_0 1
998 #define ED_DRAWING_ID_YAMYAM_CONTENT_1 2
999 #define ED_DRAWING_ID_YAMYAM_CONTENT_2 3
1000 #define ED_DRAWING_ID_YAMYAM_CONTENT_3 4
1001 #define ED_DRAWING_ID_YAMYAM_CONTENT_4 5
1002 #define ED_DRAWING_ID_YAMYAM_CONTENT_5 6
1003 #define ED_DRAWING_ID_YAMYAM_CONTENT_6 7
1004 #define ED_DRAWING_ID_YAMYAM_CONTENT_7 8
1005 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 9
1006 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_1 10
1007 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_2 11
1008 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_3 12
1009 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_4 13
1010 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_5 14
1011 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_6 15
1012 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_7 16
1013 #define ED_DRAWING_ID_ANDROID_CONTENT 17
1014 #define ED_DRAWING_ID_AMOEBA_CONTENT 18
1015 #define ED_DRAWING_ID_START_ELEMENT 19
1016 #define ED_DRAWING_ID_ARTWORK_ELEMENT 20
1017 #define ED_DRAWING_ID_EXPLOSION_ELEMENT 21
1018 #define ED_DRAWING_ID_INVENTORY_CONTENT 22
1019 #define ED_DRAWING_ID_CUSTOM_GRAPHIC 23
1020 #define ED_DRAWING_ID_CUSTOM_CONTENT 24
1021 #define ED_DRAWING_ID_CUSTOM_MOVE_ENTER 25
1022 #define ED_DRAWING_ID_CUSTOM_MOVE_LEAVE 26
1023 #define ED_DRAWING_ID_CUSTOM_CHANGE_TARGET 27
1024 #define ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT 28
1025 #define ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER 29
1026 #define ED_DRAWING_ID_CUSTOM_CHANGE_ACTION 30
1027 #define ED_DRAWING_ID_GROUP_CONTENT 31
1028 #define ED_DRAWING_ID_RANDOM_BACKGROUND 32
1030 #define ED_NUM_DRAWING_AREAS 33
1032 #define ED_DRAWING_ID_EDITOR_FIRST ED_DRAWING_ID_RANDOM_BACKGROUND
1033 #define ED_DRAWING_ID_EDITOR_LAST ED_DRAWING_ID_RANDOM_BACKGROUND
1037 -----------------------------------------------------------------------------
1038 some internally used definitions
1039 -----------------------------------------------------------------------------
1042 /* values for CopyLevelToUndoBuffer() */
1043 #define UNDO_IMMEDIATE 0
1044 #define UNDO_ACCUMULATE 1
1046 /* values for scrollbars */
1047 #define ED_SCROLL_NO 0
1048 #define ED_SCROLL_LEFT 1
1049 #define ED_SCROLL_RIGHT 2
1050 #define ED_SCROLL_UP 4
1051 #define ED_SCROLL_DOWN 8
1053 /* screens in the level editor */
1054 #define ED_MODE_DRAWING 0
1055 #define ED_MODE_INFO 1
1056 #define ED_MODE_PROPERTIES 2
1057 #define ED_MODE_PALETTE 3
1059 /* sub-screens in the global settings section */
1060 #define ED_MODE_LEVELINFO_LEVEL ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
1061 #define ED_MODE_LEVELINFO_LEVELSET ED_TEXTBUTTON_ID_LEVELINFO_LEVELSET
1062 #define ED_MODE_LEVELINFO_EDITOR ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
1064 /* sub-screens in the element properties section */
1065 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
1066 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
1067 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
1068 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
1069 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
1071 /* how many steps can be cancelled */
1072 #define NUM_UNDO_STEPS (64 + 1)
1074 /* values for elements with score for certain actions */
1076 #define MAX_SCORE 999
1078 /* values for elements with count for collecting */
1079 #define MIN_COLLECT_COUNT 0
1080 #define MAX_COLLECT_COUNT 999
1082 /* values for random placement */
1083 #define RANDOM_USE_PERCENTAGE 0
1084 #define RANDOM_USE_QUANTITY 1
1086 /* values for level set save mode */
1087 #define LEVELSET_SAVE_MODE_UPDATE 0
1088 #define LEVELSET_SAVE_MODE_CREATE 1
1090 /* default value for element tile size in drawing area */
1091 #define DEFAULT_EDITOR_TILESIZE MINI_TILESIZE
1095 -----------------------------------------------------------------------------
1096 some internally used data structure definitions
1097 -----------------------------------------------------------------------------
1104 struct XYTileSize *pos;
1108 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
1110 /* note: some additional characters are already reserved for "cheat mode"
1111 shortcuts (":XYZ" style) -- for details, see "events.c" */
1113 /* ---------- toolbox control buttons ------------------------------------ */
1116 IMG_GFX_EDITOR_BUTTON_DRAW_SINGLE, GADGET_ID_SINGLE_ITEMS,
1117 &editor.button.draw_single, GD_TYPE_RADIO_BUTTON,
1118 "draw single items", 's'
1121 IMG_GFX_EDITOR_BUTTON_DRAW_CONNECTED, GADGET_ID_CONNECTED_ITEMS,
1122 &editor.button.draw_connected, GD_TYPE_RADIO_BUTTON,
1123 "draw connected items", 'd'
1126 IMG_GFX_EDITOR_BUTTON_DRAW_LINE, GADGET_ID_LINE,
1127 &editor.button.draw_line, GD_TYPE_RADIO_BUTTON,
1131 IMG_GFX_EDITOR_BUTTON_DRAW_ARC, GADGET_ID_ARC,
1132 &editor.button.draw_arc, GD_TYPE_RADIO_BUTTON,
1136 IMG_GFX_EDITOR_BUTTON_DRAW_RECTANGLE, GADGET_ID_RECTANGLE,
1137 &editor.button.draw_rectangle, GD_TYPE_RADIO_BUTTON,
1138 "draw outline rectangles", 'r'
1141 IMG_GFX_EDITOR_BUTTON_DRAW_FILLED_BOX, GADGET_ID_FILLED_BOX,
1142 &editor.button.draw_filled_box, GD_TYPE_RADIO_BUTTON,
1143 "draw filled rectangles", 'R'
1146 IMG_GFX_EDITOR_BUTTON_ROTATE_UP, GADGET_ID_WRAP_UP,
1147 &editor.button.rotate_up, GD_TYPE_NORMAL_BUTTON,
1148 "wrap (rotate) level up", 0
1151 IMG_GFX_EDITOR_BUTTON_DRAW_TEXT, GADGET_ID_TEXT,
1152 &editor.button.draw_text, GD_TYPE_RADIO_BUTTON,
1153 "enter text elements", 't'
1156 IMG_GFX_EDITOR_BUTTON_FLOOD_FILL, GADGET_ID_FLOOD_FILL,
1157 &editor.button.flood_fill, GD_TYPE_RADIO_BUTTON,
1161 IMG_GFX_EDITOR_BUTTON_ROTATE_LEFT, GADGET_ID_WRAP_LEFT,
1162 &editor.button.rotate_left, GD_TYPE_NORMAL_BUTTON,
1163 "wrap (rotate) level left", 0
1166 IMG_GFX_EDITOR_BUTTON_ZOOM_LEVEL, GADGET_ID_ZOOM,
1167 &editor.button.zoom_level, GD_TYPE_NORMAL_BUTTON,
1168 "zoom level tile size", '+'
1171 IMG_GFX_EDITOR_BUTTON_ROTATE_RIGHT, GADGET_ID_WRAP_RIGHT,
1172 &editor.button.rotate_right, GD_TYPE_NORMAL_BUTTON,
1173 "wrap (rotate) level right", 0
1176 IMG_GFX_EDITOR_BUTTON_DRAW_RANDOM, GADGET_ID_RANDOM_PLACEMENT,
1177 &editor.button.draw_random, GD_TYPE_NORMAL_BUTTON,
1178 "random element placement", 0
1181 IMG_GFX_EDITOR_BUTTON_GRAB_BRUSH, GADGET_ID_GRAB_BRUSH,
1182 &editor.button.grab_brush, GD_TYPE_RADIO_BUTTON,
1186 IMG_GFX_EDITOR_BUTTON_ROTATE_DOWN, GADGET_ID_WRAP_DOWN,
1187 &editor.button.rotate_down, GD_TYPE_NORMAL_BUTTON,
1188 "wrap (rotate) level down", 0
1191 IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT, GADGET_ID_PICK_ELEMENT,
1192 &editor.button.pick_element, GD_TYPE_RADIO_BUTTON,
1193 "pick drawing element", ','
1196 /* ---------- level control buttons -------------------------------------- */
1199 IMG_GFX_EDITOR_BUTTON_UNDO, GADGET_ID_UNDO,
1200 &editor.button.undo, GD_TYPE_NORMAL_BUTTON,
1201 "undo/redo last operation", 'u'
1204 IMG_GFX_EDITOR_BUTTON_CONF, GADGET_ID_INFO,
1205 &editor.button.conf, GD_TYPE_NORMAL_BUTTON,
1206 "properties of level", 'I'
1209 IMG_GFX_EDITOR_BUTTON_SAVE, GADGET_ID_SAVE,
1210 &editor.button.save, GD_TYPE_NORMAL_BUTTON,
1214 IMG_GFX_EDITOR_BUTTON_CLEAR, GADGET_ID_CLEAR,
1215 &editor.button.clear, GD_TYPE_NORMAL_BUTTON,
1219 IMG_GFX_EDITOR_BUTTON_TEST, GADGET_ID_TEST,
1220 &editor.button.test, GD_TYPE_NORMAL_BUTTON,
1224 IMG_GFX_EDITOR_BUTTON_EXIT, GADGET_ID_EXIT,
1225 &editor.button.exit, GD_TYPE_NORMAL_BUTTON,
1226 "exit level editor", 'E'
1229 /* ---------- CE and GE control buttons ---------------------------------- */
1232 IMG_GFX_EDITOR_BUTTON_CE_COPY_FROM, GADGET_ID_CUSTOM_COPY_FROM,
1233 &editor.button.ce_copy_from, GD_TYPE_RADIO_BUTTON,
1234 "copy settings from other element", 0
1237 IMG_GFX_EDITOR_BUTTON_CE_COPY_TO, GADGET_ID_CUSTOM_COPY_TO,
1238 &editor.button.ce_copy_to, GD_TYPE_RADIO_BUTTON,
1239 "copy settings to other element", 0
1242 IMG_GFX_EDITOR_BUTTON_CE_SWAP, GADGET_ID_CUSTOM_EXCHANGE,
1243 &editor.button.ce_swap, GD_TYPE_RADIO_BUTTON,
1244 "exchange element with other element", 0
1247 IMG_GFX_EDITOR_BUTTON_CE_COPY, GADGET_ID_CUSTOM_COPY,
1248 &editor.button.ce_copy, GD_TYPE_NORMAL_BUTTON,
1249 "copy settings from this element", 0
1252 IMG_GFX_EDITOR_BUTTON_CE_PASTE, GADGET_ID_CUSTOM_PASTE,
1253 &editor.button.ce_paste, GD_TYPE_NORMAL_BUTTON,
1254 "paste settings to this element", 0
1257 /* ---------- palette control buttons ------------------------------------ */
1260 IMG_GFX_EDITOR_BUTTON_PROPERTIES, GADGET_ID_PROPERTIES,
1261 &editor.button.properties, GD_TYPE_NORMAL_BUTTON,
1262 "properties of drawing element", 'p'
1265 IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT, GADGET_ID_ELEMENT_LEFT,
1266 &editor.button.element_left, GD_TYPE_NORMAL_BUTTON,
1267 "properties of drawing element 1", '1'
1270 IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE, GADGET_ID_ELEMENT_MIDDLE,
1271 &editor.button.element_middle, GD_TYPE_NORMAL_BUTTON,
1272 "properties of drawing element 2", '2'
1275 IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT, GADGET_ID_ELEMENT_RIGHT,
1276 &editor.button.element_right, GD_TYPE_NORMAL_BUTTON,
1277 "properties of drawing element 3", '3'
1280 IMG_GFX_EDITOR_BUTTON_PALETTE, GADGET_ID_PALETTE,
1281 &editor.button.palette, GD_TYPE_NORMAL_BUTTON,
1282 "show list of elements", 'e'
1286 static int random_placement_value = 10;
1287 static int random_placement_method = RANDOM_USE_QUANTITY;
1288 static int random_placement_background_element = EL_SAND;
1289 static boolean random_placement_background_restricted = FALSE;
1290 static boolean stick_element_properties_window = FALSE;
1291 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1292 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1293 static struct ElementChangeInfo custom_element_change;
1294 static struct ElementGroupInfo group_element_info;
1295 static struct ElementInfo custom_element;
1297 static char levelset_name[MAX_LEVEL_NAME_LEN + 1];
1298 static char levelset_author[MAX_LEVEL_AUTHOR_LEN + 1];
1299 static int levelset_num_levels = 100;
1300 static int levelset_first_level_nr = 1;
1301 static int levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
1306 int min_value, max_value;
1307 int gadget_id_down, gadget_id_up;
1309 int gadget_id_align;
1311 char *text_above, *text_left, *text_right;
1312 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1314 /* ---------- current level number --------------------------------------- */
1317 -1, -1, /* these values are not constant, but can change at runtime */
1319 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1320 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1325 /* ---------- level and editor settings ---------------------------------- */
1328 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1329 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1330 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1331 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1333 "playfield size:", NULL, "width",
1336 -1, ED_LEVEL_SETTINGS_YPOS(4),
1337 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1338 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1339 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1341 NULL, " ", "height",
1344 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1346 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1347 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1349 NULL, "number of gems to collect:", NULL
1352 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
1354 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1355 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1357 "time or step limit to solve level:", NULL, NULL
1360 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
1362 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1363 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1364 &level.score[SC_TIME_BONUS],
1365 "score for each second/step left:", NULL, NULL
1368 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
1370 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1371 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1373 NULL, "random seed:", "(0 => random)"
1376 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1378 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN, GADGET_ID_LEVELSET_NUM_LEVELS_UP,
1379 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT, GADGET_ID_NONE,
1380 &levelset_num_levels,
1381 "number of levels:", NULL, NULL,
1384 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1386 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1387 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1388 &random_placement_value,
1389 "random element placement:", NULL, "in"
1392 /* ---------- element settings: configure (various elements) ------------- */
1395 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1396 MIN_SCORE, MAX_SCORE,
1397 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1398 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1399 NULL, /* will be set when used */
1403 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1404 MIN_SCORE, MAX_SCORE,
1405 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1406 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1407 NULL, /* will be set when used */
1411 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1412 MIN_SCORE, MAX_SCORE,
1413 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1414 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1415 NULL, /* will be set when used */
1419 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1420 MIN_SCORE, MAX_SCORE,
1421 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1422 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1423 NULL, /* will be set when used */
1427 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1428 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1429 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1430 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1431 &level.num_yamyam_contents,
1432 NULL, NULL, "number of content areas"
1435 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1436 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1437 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1438 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1439 &level.num_ball_contents,
1440 NULL, NULL, "number of content areas"
1443 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1444 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1445 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1446 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1447 &level.num_android_clone_elements,
1448 NULL, NULL, "number of clonable elements"
1451 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1452 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1453 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1454 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1455 NULL, /* will be set when used */
1456 NULL, NULL, "width",
1459 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1460 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1461 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1462 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1463 NULL, /* will be set when used */
1464 NULL, " ", "height",
1467 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1468 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1469 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1470 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1471 &level.initial_inventory_size[0],
1472 NULL, NULL, "number of inventory elements"
1475 /* ---------- element settings: configure 1 (custom elements) ------------ */
1478 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1479 MIN_SCORE, MAX_SCORE,
1480 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1481 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1482 &custom_element.collect_score_initial,
1483 NULL, "CE score", " "
1486 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1487 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1488 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1489 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1490 &custom_element.collect_count_initial,
1491 NULL, "CE count", NULL
1494 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1496 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1497 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1498 &custom_element.ce_value_fixed_initial,
1499 NULL, "CE value", NULL
1502 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1504 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1505 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1506 &custom_element.ce_value_random_initial,
1507 NULL, "+random", NULL
1510 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1512 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1513 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1514 &custom_element.push_delay_fixed,
1515 NULL, "push delay", NULL
1518 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1520 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1521 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1522 &custom_element.push_delay_random,
1523 NULL, "+random", NULL
1526 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1528 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1529 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1530 &custom_element.drop_delay_fixed,
1531 NULL, "drop delay", NULL
1534 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1536 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1537 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1538 &custom_element.drop_delay_random,
1539 NULL, "+random", NULL
1542 /* ---------- element settings: configure 2 (custom elements) ------------ */
1545 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1547 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1548 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1549 &custom_element.move_delay_fixed,
1550 NULL, "move delay", NULL
1553 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1555 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1556 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1557 &custom_element.move_delay_random,
1558 NULL, "+random", NULL
1561 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
1563 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1564 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1565 &custom_element.explosion_delay,
1566 NULL, "explosion delay", NULL
1569 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1571 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1572 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1573 &custom_element.ignition_delay,
1574 NULL, "ignition delay", "(by fire)"
1577 /* ---------- element settings: configure (group elements) --------------- */
1580 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1581 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1582 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1583 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1584 &group_element_info.num_elements,
1585 NULL, NULL, "number of elements in group"
1588 /* ---------- element settings: advanced (custom elements) --------------- */
1591 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1593 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1594 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1595 &custom_element_change.delay_fixed,
1596 NULL, "CE delay", NULL,
1599 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1601 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1602 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1603 &custom_element_change.delay_random,
1604 NULL, "+random", NULL
1607 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1609 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1610 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1611 &custom_element_change.random_percentage,
1612 NULL, "use random replace:", "%"
1622 char *text_above, *infotext;
1623 } textinput_info[ED_NUM_TEXTINPUT] =
1626 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1627 GADGET_ID_LEVEL_NAME,
1630 "Title:", "Title for this level"
1633 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1634 GADGET_ID_LEVEL_AUTHOR,
1635 MAX_LEVEL_AUTHOR_LEN,
1637 "Author:", "Author for this level"
1640 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1641 GADGET_ID_LEVELSET_NAME,
1644 "Title:", "Title for this or new level set"
1647 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1648 GADGET_ID_LEVELSET_AUTHOR,
1649 MAX_LEVEL_AUTHOR_LEN,
1651 "Author:", "Author for this or new level set"
1654 -1, -1, /* these values are not constant, but can change at runtime */
1655 GADGET_ID_ELEMENT_NAME,
1656 MAX_ELEMENT_NAME_LEN - 2, /* currently 2 chars less editable */
1657 custom_element.description,
1658 NULL, "Element name"
1668 char *text_above, *infotext;
1669 } textarea_info[ED_NUM_TEXTAREAS] =
1672 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1673 GADGET_ID_ENVELOPE_INFO,
1674 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1676 "Envelope Content:", "Envelope Content"
1680 static struct ValueTextInfo options_time_or_steps[] =
1688 static struct ValueTextInfo options_game_engine_type[] =
1690 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1691 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1692 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1693 { GAME_ENGINE_TYPE_MM, "Mirror Magic" },
1698 static struct ValueTextInfo options_levelset_save_mode[] =
1700 { LEVELSET_SAVE_MODE_UPDATE, "Update this level set" },
1701 { LEVELSET_SAVE_MODE_CREATE, "Create new level set" },
1706 static struct ValueTextInfo options_wind_direction[] =
1708 { MV_START_NONE, "none" },
1709 { MV_START_LEFT, "left" },
1710 { MV_START_RIGHT, "right" },
1711 { MV_START_UP, "up" },
1712 { MV_START_DOWN, "down" },
1717 static struct ValueTextInfo options_player_speed[] =
1724 { 16, "very fast" },
1725 { 32, "ultrafast" },
1730 static struct ValueTextInfo options_access_type[] =
1732 { EP_WALKABLE, "walkable" },
1733 { EP_PASSABLE, "passable" },
1738 static struct ValueTextInfo options_access_layer[] =
1740 { EP_ACCESSIBLE_OVER, "over" },
1741 { EP_ACCESSIBLE_INSIDE, "inside" },
1742 { EP_ACCESSIBLE_UNDER, "under" },
1747 static struct ValueTextInfo options_access_protected[] =
1749 { 0, "unprotected" },
1755 static struct ValueTextInfo options_access_direction[] =
1757 { MV_NO_DIRECTION, "no direction" },
1758 { MV_LEFT, "left" },
1759 { MV_RIGHT, "right" },
1761 { MV_DOWN, "down" },
1762 { MV_LEFT | MV_UP, "left + up" },
1763 { MV_LEFT | MV_DOWN, "left + down" },
1764 { MV_RIGHT | MV_UP, "right + up" },
1765 { MV_RIGHT | MV_DOWN, "right + down" },
1766 { MV_HORIZONTAL, "horizontal" },
1767 { MV_VERTICAL, "vertical" },
1768 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1769 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1770 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1771 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1772 { MV_ALL_DIRECTIONS, "all directions" },
1777 static struct ValueTextInfo options_walk_to_action[] =
1779 { EP_DIGGABLE, "diggable" },
1780 { EP_COLLECTIBLE_ONLY, "collectible" },
1781 { EP_DROPPABLE, "collectible & droppable" },
1782 { EP_THROWABLE, "collectible & throwable" },
1783 { EP_PUSHABLE, "pushable" },
1788 static struct ValueTextInfo options_move_pattern[] =
1790 { MV_LEFT, "left" },
1791 { MV_RIGHT, "right" },
1793 { MV_DOWN, "down" },
1794 { MV_HORIZONTAL, "horizontal" },
1795 { MV_VERTICAL, "vertical" },
1796 { MV_ALL_DIRECTIONS, "all directions" },
1797 { MV_WIND_DIRECTION, "wind direction" },
1798 { MV_TOWARDS_PLAYER, "towards player" },
1799 { MV_AWAY_FROM_PLAYER, "away from player" },
1800 { MV_ALONG_LEFT_SIDE, "along left side" },
1801 { MV_ALONG_RIGHT_SIDE, "along right side" },
1802 { MV_TURNING_LEFT, "turning left" },
1803 { MV_TURNING_RIGHT, "turning right" },
1804 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1805 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1806 { MV_TURNING_RANDOM, "turning random" },
1807 { MV_MAZE_RUNNER, "maze runner style" },
1808 { MV_MAZE_HUNTER, "maze hunter style" },
1809 { MV_WHEN_PUSHED, "when pushed" },
1810 { MV_WHEN_DROPPED, "when dropped/thrown" },
1815 static struct ValueTextInfo options_move_direction[] =
1817 { MV_START_AUTOMATIC, "automatic" },
1818 { MV_START_LEFT, "left" },
1819 { MV_START_RIGHT, "right" },
1820 { MV_START_UP, "up" },
1821 { MV_START_DOWN, "down" },
1822 { MV_START_RANDOM, "random" },
1823 { MV_START_PREVIOUS, "previous" },
1828 static struct ValueTextInfo options_move_stepsize[] =
1830 { 0, "not moving" },
1835 { 16, "very fast" },
1836 { 32, "even faster" },
1841 static struct ValueTextInfo options_move_leave_type[] =
1843 { LEAVE_TYPE_UNLIMITED, "leave behind" },
1844 { LEAVE_TYPE_LIMITED, "change it to" },
1849 static struct ValueTextInfo options_smash_targets[] =
1851 { EP_CAN_SMASH_PLAYER, "player" },
1853 { EP_CAN_SMASH_ENEMIES, "enemies" },
1855 { EP_CAN_SMASH_EVERYTHING, "everything" },
1860 static struct ValueTextInfo options_slippery_type[] =
1862 { SLIPPERY_ANY_RANDOM, "random" },
1863 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
1864 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
1865 { SLIPPERY_ONLY_LEFT, "only left" },
1866 { SLIPPERY_ONLY_RIGHT, "only right" },
1871 static struct ValueTextInfo options_deadliness[] =
1873 { EP_DONT_RUN_INTO, "running into" },
1874 { EP_DONT_COLLIDE_WITH, "colliding with" },
1875 { EP_DONT_GET_HIT_BY, "getting hit by" },
1876 { EP_DONT_TOUCH, "touching" },
1881 static struct ValueTextInfo options_explosion_type[] =
1883 { EXPLODES_3X3, "3x3" },
1884 { EXPLODES_CROSS, "3+3" },
1885 { EXPLODES_1X1, "1x1" },
1890 static struct ValueTextInfo options_time_units[] =
1893 { FRAMES_PER_SECOND, "seconds" },
1898 static struct ValueTextInfo options_change_direct_action[] =
1900 { CE_TOUCHED_BY_PLAYER, "touched by player" },
1901 { CE_PRESSED_BY_PLAYER, "pressed by player" },
1902 { CE_SWITCHED_BY_PLAYER, "switched by player" },
1903 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
1904 { CE_PUSHED_BY_PLAYER, "pushed by player" },
1905 { CE_ENTERED_BY_PLAYER, "entered by player" },
1906 { CE_LEFT_BY_PLAYER, "left by player" },
1907 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
1908 { CE_SWITCHED, "switched" },
1909 { CE_HITTING_SOMETHING, "hitting something" },
1910 { CE_HIT_BY_SOMETHING, "hit by something" },
1912 { CE_BLOCKED, "blocked" },
1914 { CE_IMPACT, "impact (on something)" },
1915 { CE_SMASHED, "smashed (from above)" },
1917 { CE_VALUE_CHANGES, "CE value changes" },
1918 { CE_SCORE_CHANGES, "CE score changes" },
1920 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
1921 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
1926 static struct ValueTextInfo options_change_other_action[] =
1928 { CE_PLAYER_TOUCHES_X, "player touches" },
1929 { CE_PLAYER_PRESSES_X, "player presses" },
1930 { CE_PLAYER_SWITCHES_X, "player switches" },
1931 { CE_PLAYER_SNAPS_X, "player snaps" },
1932 { CE_PLAYER_PUSHES_X, "player pushes" },
1933 { CE_PLAYER_ENTERS_X, "player enters" },
1934 { CE_PLAYER_LEAVES_X, "player leaves" },
1935 { CE_PLAYER_DIGS_X, "player digs" },
1936 { CE_PLAYER_COLLECTS_X, "player collects" },
1937 { CE_PLAYER_DROPS_X, "player drops/throws" },
1938 { CE_TOUCHING_X, "touching" },
1939 { CE_HITTING_X, "hitting" },
1940 { CE_DIGGING_X, "digging" },
1941 { CE_HIT_BY_X, "hit by" },
1942 { CE_SWITCH_OF_X, "switch of" },
1943 { CE_CHANGE_OF_X, "change by page of" },
1944 { CE_EXPLOSION_OF_X, "explosion of" },
1945 { CE_MOVE_OF_X, "move of" },
1946 { CE_CREATION_OF_X, "creation of" },
1947 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
1948 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
1949 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
1950 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
1955 static struct ValueTextInfo options_change_trigger_side[] =
1957 { CH_SIDE_LEFT, "left" },
1958 { CH_SIDE_RIGHT, "right" },
1959 { CH_SIDE_TOP, "top" },
1960 { CH_SIDE_BOTTOM, "bottom" },
1961 { CH_SIDE_LEFT_RIGHT, "left/right" },
1962 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
1963 { CH_SIDE_ANY, "any" },
1968 static struct ValueTextInfo options_change_trigger_player[] =
1970 { CH_PLAYER_1, "1" },
1971 { CH_PLAYER_2, "2" },
1972 { CH_PLAYER_3, "3" },
1973 { CH_PLAYER_4, "4" },
1974 { CH_PLAYER_ANY, "any" },
1979 static struct ValueTextInfo options_change_trigger_page[] =
1991 { (1 << 10), "11" },
1992 { (1 << 11), "12" },
1993 { (1 << 12), "13" },
1994 { (1 << 13), "14" },
1995 { (1 << 14), "15" },
1996 { (1 << 15), "16" },
1997 { (1 << 16), "17" },
1998 { (1 << 17), "18" },
1999 { (1 << 18), "19" },
2000 { (1 << 19), "20" },
2001 { (1 << 20), "21" },
2002 { (1 << 21), "22" },
2003 { (1 << 22), "23" },
2004 { (1 << 23), "24" },
2005 { (1 << 24), "25" },
2006 { (1 << 25), "26" },
2007 { (1 << 26), "27" },
2008 { (1 << 27), "28" },
2009 { (1 << 28), "29" },
2010 { (1 << 29), "30" },
2011 { (1 << 30), "31" },
2012 { (1 << 31), "32" },
2013 { CH_PAGE_ANY, "any" },
2018 static struct ValueTextInfo options_change_replace_when[] =
2020 { CP_WHEN_EMPTY, "empty" },
2021 { CP_WHEN_WALKABLE, "walkable" },
2022 { CP_WHEN_DIGGABLE, "diggable" },
2023 { CP_WHEN_COLLECTIBLE, "collectible" },
2024 { CP_WHEN_REMOVABLE, "removable" },
2025 { CP_WHEN_DESTRUCTIBLE, "destructible" },
2030 static struct ValueTextInfo options_action_type[] =
2032 { CA_NO_ACTION, "no action" },
2033 { CA_UNDEFINED, " " },
2034 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
2035 { CA_RESTART_LEVEL, "restart level" },
2036 { CA_SHOW_ENVELOPE, "show envelope" },
2037 { CA_SET_LEVEL_TIME, "set time" },
2038 { CA_SET_LEVEL_SCORE, "set score" },
2039 { CA_SET_LEVEL_GEMS, "set gems" },
2040 { CA_SET_LEVEL_WIND, "set wind dir." },
2041 { CA_SET_LEVEL_RANDOM_SEED, "set rand. seed" },
2042 { CA_UNDEFINED, " " },
2043 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
2044 { CA_MOVE_PLAYER, "move player" },
2045 { CA_EXIT_PLAYER, "exit player" },
2046 { CA_KILL_PLAYER, "kill player" },
2047 { CA_SET_PLAYER_KEYS, "set keys" },
2048 { CA_SET_PLAYER_SPEED, "set speed" },
2049 { CA_SET_PLAYER_SHIELD, "set shield" },
2050 { CA_SET_PLAYER_GRAVITY, "set gravity" },
2051 { CA_SET_PLAYER_ARTWORK, "set artwork" },
2052 { CA_SET_PLAYER_INVENTORY, "set inventory" },
2053 { CA_UNDEFINED, " " },
2054 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
2055 { CA_SET_CE_VALUE, "set CE value" },
2056 { CA_SET_CE_SCORE, "set CE score" },
2057 { CA_SET_CE_ARTWORK, "set CE artwork" },
2058 { CA_UNDEFINED, " " },
2059 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
2060 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
2065 static struct ValueTextInfo options_action_mode_none[] =
2067 { CA_MODE_UNDEFINED, " " },
2072 static struct ValueTextInfo options_action_mode_assign[] =
2074 { CA_MODE_SET, "=" },
2079 static struct ValueTextInfo options_action_mode_add_remove[] =
2081 { CA_MODE_ADD, "+" },
2082 { CA_MODE_SUBTRACT, "-" },
2087 static struct ValueTextInfo options_action_mode_calculate[] =
2089 { CA_MODE_SET, "=" },
2090 { CA_MODE_ADD, "+" },
2091 { CA_MODE_SUBTRACT, "-" },
2092 { CA_MODE_MULTIPLY, "*" },
2093 { CA_MODE_DIVIDE, "/" },
2094 { CA_MODE_MODULO, "%" },
2099 static struct ValueTextInfo options_action_arg_none[] =
2101 { CA_ARG_UNDEFINED, " " },
2106 static struct ValueTextInfo options_action_arg_player[] =
2108 { CA_ARG_PLAYER_HEADLINE, "[player]" },
2109 { CA_ARG_PLAYER_1, "1" },
2110 { CA_ARG_PLAYER_2, "2" },
2111 { CA_ARG_PLAYER_3, "3" },
2112 { CA_ARG_PLAYER_4, "4" },
2113 { CA_ARG_PLAYER_ANY, "any" },
2114 { CA_ARG_PLAYER_TRIGGER, "trigger" },
2115 { CA_ARG_PLAYER_ACTION, "action ->" },
2120 static struct ValueTextInfo options_action_arg_number[] =
2122 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2129 { CA_ARG_10, "10" },
2130 { CA_ARG_100, "100" },
2131 { CA_ARG_1000, "1000" },
2132 { CA_ARG_UNDEFINED, " " },
2133 { CA_ARG_NUMBER_MIN, "min" },
2134 { CA_ARG_NUMBER_MAX, "max" },
2135 { CA_ARG_UNDEFINED, " " },
2136 { CA_ARG_NUMBER_RESET, "reset" },
2137 { CA_ARG_UNDEFINED, " " },
2138 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2139 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2140 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2141 { CA_ARG_UNDEFINED, " " },
2142 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2143 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2144 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2145 { CA_ARG_UNDEFINED, " " },
2146 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2147 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2148 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2149 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2150 { CA_ARG_UNDEFINED, " " },
2151 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2152 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2153 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2154 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2159 static struct ValueTextInfo options_action_arg_value[] =
2161 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2168 { CA_ARG_10, "10" },
2169 { CA_ARG_100, "100" },
2170 { CA_ARG_1000, "1000" },
2171 { CA_ARG_UNDEFINED, " " },
2172 { CA_ARG_NUMBER_MIN, "min" },
2173 { CA_ARG_NUMBER_MAX, "max" },
2174 { CA_ARG_UNDEFINED, " " },
2175 { CA_ARG_NUMBER_RESET, "reset" },
2176 { CA_ARG_UNDEFINED, " " },
2177 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2178 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2179 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2180 { CA_ARG_UNDEFINED, " " },
2181 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2182 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2183 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2184 { CA_ARG_UNDEFINED, " " },
2185 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2186 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2187 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2188 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2189 { CA_ARG_UNDEFINED, " " },
2190 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2191 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2192 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2193 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2194 { CA_ARG_UNDEFINED, " " },
2195 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
2196 { CA_ARG_ELEMENT_NR_TARGET, "target" },
2197 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
2198 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
2203 static struct ValueTextInfo options_action_arg_envelope[] =
2205 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2210 { CA_ARG_UNDEFINED, " " },
2211 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2212 { CA_ARG_ELEMENT_TARGET, "target" },
2213 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2214 { CA_ARG_ELEMENT_ACTION, "action ->" },
2219 static struct ValueTextInfo options_action_arg_key[] =
2221 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2230 { CA_ARG_UNDEFINED, " " },
2231 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2232 { CA_ARG_ELEMENT_TARGET, "target" },
2233 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2234 { CA_ARG_ELEMENT_ACTION, "action ->" },
2239 static struct ValueTextInfo options_action_arg_speed[] =
2241 { CA_ARG_SPEED_HEADLINE, "[speed]" },
2242 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
2243 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
2244 { CA_ARG_SPEED_SLOW, "slow" },
2245 { CA_ARG_SPEED_NORMAL, "normal" },
2246 { CA_ARG_SPEED_FAST, "fast" },
2247 { CA_ARG_SPEED_VERY_FAST, "very fast" },
2248 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
2249 { CA_ARG_UNDEFINED, " " },
2250 { CA_ARG_SPEED_SLOWER, "slower" },
2251 { CA_ARG_SPEED_FASTER, "faster" },
2252 { CA_ARG_UNDEFINED, " " },
2253 { CA_ARG_SPEED_RESET, "reset" },
2258 static struct ValueTextInfo options_action_arg_shield[] =
2260 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
2261 { CA_ARG_SHIELD_OFF, "off" },
2262 { CA_ARG_SHIELD_NORMAL, "normal" },
2263 { CA_ARG_SHIELD_DEADLY, "deadly" },
2268 static struct ValueTextInfo options_action_arg_artwork[] =
2270 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2271 { CA_ARG_ELEMENT_TARGET, "target" },
2272 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2273 { CA_ARG_ELEMENT_ACTION, "action ->" },
2274 { CA_ARG_UNDEFINED, " " },
2275 { CA_ARG_ELEMENT_RESET, "reset" },
2280 static struct ValueTextInfo options_action_arg_gravity[] =
2282 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
2283 { CA_ARG_GRAVITY_ON, "on" },
2284 { CA_ARG_GRAVITY_OFF, "off" },
2285 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2290 static struct ValueTextInfo options_action_arg_direction[] =
2292 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2293 { CA_ARG_DIRECTION_NONE, "none" },
2294 { CA_ARG_DIRECTION_LEFT, "left" },
2295 { CA_ARG_DIRECTION_RIGHT, "right" },
2296 { CA_ARG_DIRECTION_UP, "up" },
2297 { CA_ARG_DIRECTION_DOWN, "down" },
2298 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2299 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2304 static struct ValueTextInfo options_action_arg_scan_mode[] =
2306 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2307 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2308 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2313 static struct ValueTextInfo options_action_arg_inventory[] =
2315 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2316 { CA_ARG_ELEMENT_TARGET, "+ target" },
2317 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2318 { CA_ARG_ELEMENT_ACTION, "+ action" },
2319 { CA_ARG_UNDEFINED, " " },
2320 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2321 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2322 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2323 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2324 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2325 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2326 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2327 { CA_ARG_UNDEFINED, " " },
2328 { CA_ARG_INVENTORY_RESET, "reset" },
2333 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2334 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2339 static struct ValueTextInfo options_group_choice_mode[] =
2341 { ANIM_RANDOM, "random" },
2342 { ANIM_LOOP, "loop" },
2343 { ANIM_LINEAR, "linear" },
2344 { ANIM_PINGPONG, "pingpong" },
2345 { ANIM_PINGPONG2, "pingpong 2" },
2350 static struct ValueTextInfo *action_arg_modes[] =
2352 options_action_mode_none,
2353 options_action_mode_assign,
2354 options_action_mode_add_remove,
2355 options_action_mode_calculate,
2362 struct ValueTextInfo *options;
2364 action_arg_options[] =
2366 { CA_NO_ACTION, 0, options_action_arg_none, },
2367 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2368 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2369 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2370 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2371 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2372 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2373 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2374 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2375 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2376 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2377 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2378 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2379 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2380 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2381 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2382 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2383 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2384 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2385 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2386 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2395 int gadget_id_align;
2396 int size; /* char size of selectbox or '-1' (dynamically determined) */
2397 struct ValueTextInfo *options;
2399 char *text_above, *text_left, *text_right, *infotext;
2400 } selectbox_info[ED_NUM_SELECTBOX] =
2402 /* ---------- level and editor settings ---------------------------------- */
2405 -1, ED_LEVEL_SETTINGS_YPOS(8),
2406 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2408 options_time_or_steps,
2409 &level.use_step_counter,
2410 NULL, NULL, "(0 => no limit)", "time or step limit"
2413 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
2414 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2416 options_game_engine_type,
2417 &level.game_engine_type,
2418 NULL, "game engine:", NULL, "game engine"
2421 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(9),
2422 GADGET_ID_LEVELSET_SAVE_MODE, GADGET_ID_NONE,
2424 options_levelset_save_mode,
2425 &levelset_save_mode,
2426 "Action:", NULL, NULL, "action when saving level set"
2429 /* ---------- element settings: configure (several elements) ------------- */
2432 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2433 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2435 options_wind_direction,
2436 &level.wind_direction_initial,
2437 NULL, "initial wind direction:", NULL, "initial wind direction"
2440 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2441 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2443 options_player_speed,
2444 &level.initial_player_stepsize[0],
2445 NULL, "initial player speed:", NULL, "initial player speed"
2448 /* ---------- element settings: configure 1 (custom elements) ------------ */
2451 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2452 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2454 options_access_type,
2455 &custom_element.access_type,
2456 NULL, NULL, NULL, "type of access to this field"
2459 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2460 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2462 options_access_layer,
2463 &custom_element.access_layer,
2464 NULL, NULL, NULL, "layer of access for this field"
2467 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2468 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2470 options_access_protected,
2471 &custom_element.access_protected,
2472 NULL, NULL, NULL, "protected access for this field"
2475 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2476 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2478 options_access_direction,
2479 &custom_element.access_direction,
2480 NULL, "from", NULL, "access direction for this field"
2483 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2484 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2486 options_walk_to_action,
2487 &custom_element.walk_to_action,
2488 NULL, NULL, NULL, "diggable/collectible/pushable"
2491 /* ---------- element settings: configure 2 (custom elements) ------------ */
2494 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2495 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2497 options_move_pattern,
2498 &custom_element.move_pattern,
2499 NULL, "can move", NULL, "element move pattern"
2502 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2503 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2505 options_move_direction,
2506 &custom_element.move_direction_initial,
2507 NULL, "starts moving", NULL, "initial element move direction"
2510 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2511 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2513 options_move_stepsize,
2514 &custom_element.move_stepsize,
2515 NULL, "move/fall speed", NULL, "speed of element movement"
2518 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2519 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2521 options_move_leave_type,
2522 &custom_element.move_leave_type,
2523 // left text with leading spaces to place gadget next to "can dig" gadget
2524 // (needed because drawing area gadgets created after selectbox gadgets)
2525 // NULL, "can dig: can", ":", "leave behind or change element"
2526 NULL, " can", ":", "leave behind or change element"
2529 -1, ED_ELEMENT_SETTINGS_YPOS(7),
2530 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2532 options_smash_targets,
2533 &custom_element.smash_targets,
2534 NULL, "can smash", NULL, "elements that can be smashed"
2537 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
2538 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2540 options_slippery_type,
2541 &custom_element.slippery_type,
2542 NULL, "slippery", NULL, "where other elements fall down"
2545 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2546 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2549 &custom_element.deadliness,
2550 NULL, "deadly when", NULL, "deadliness of element"
2553 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2554 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2556 options_explosion_type,
2557 &custom_element.explosion_type,
2558 NULL, "can explode", NULL, "explosion type"
2561 /* ---------- element settings: advanced (custom elements) --------------- */
2564 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2565 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2568 &custom_element_change.delay_frames,
2569 NULL, "delay time given in", NULL, "delay time units for change"
2572 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2573 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2575 options_change_direct_action,
2576 &custom_element_change.direct_action,
2577 NULL, NULL, NULL, "type of direct action"
2580 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2581 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2583 options_change_other_action,
2584 &custom_element_change.other_action,
2585 NULL, NULL, "element:", "type of other element action"
2588 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2589 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2591 options_change_trigger_side,
2592 &custom_element_change.trigger_side,
2593 NULL, "at", "side", "element side triggering change"
2596 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2597 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2599 options_change_trigger_player,
2600 &custom_element_change.trigger_player,
2601 NULL, "player:", " ", "player that causes change"
2604 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2605 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2607 options_change_trigger_page,
2608 &custom_element_change.trigger_page,
2609 NULL, "page:", NULL, "change page that causes change"
2612 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2613 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2615 options_change_replace_when,
2616 &custom_element_change.replace_when,
2617 NULL, "replace when", NULL, "which elements can be replaced"
2620 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2621 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2623 options_action_type,
2624 &custom_element_change.action_type,
2625 NULL, NULL, NULL, "action on specified condition"
2628 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2629 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2631 options_action_mode_none,
2632 &custom_element_change.action_mode,
2633 NULL, NULL, NULL, "action operator"
2636 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2637 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2639 options_action_arg_none,
2640 &custom_element_change.action_arg,
2641 NULL, NULL, NULL, "action parameter"
2644 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2645 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2647 options_change_page,
2648 &custom_element.current_change_page,
2649 NULL, NULL, NULL, "element change page"
2652 /* ---------- element settings: configure (group elements) --------------- */
2655 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2656 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2658 options_group_choice_mode,
2659 &group_element_info.choice_mode,
2660 NULL, "choice type:", NULL, "type of group element choice"
2668 int gadget_id_align;
2671 char *text_above, *text_left, *text_right, *infotext;
2672 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2674 /* ---------- level and editor settings (tabs) --------------------------- */
2677 ED_LEVEL_TABS_XPOS(0), ED_LEVEL_TABS_YPOS(0),
2678 GADGET_ID_LEVELINFO_LEVEL, GADGET_ID_NONE,
2680 NULL, NULL, NULL, "Configure level properties"
2684 GADGET_ID_LEVELINFO_LEVELSET, GADGET_ID_LEVELINFO_LEVEL,
2686 NULL, NULL, NULL, "Update this or create new level set"
2690 GADGET_ID_LEVELINFO_EDITOR, GADGET_ID_LEVELINFO_LEVELSET,
2692 NULL, NULL, NULL, "Configure editor properties"
2695 /* ---------- element settings (tabs) ------------------------------------ */
2698 ED_ELEMENT_TABS_XPOS(0), ED_ELEMENT_TABS_YPOS(0),
2699 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
2701 NULL, NULL, NULL, "Show information about element"
2705 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_PROPERTIES_INFO,
2707 NULL, NULL, NULL, "Configure element properties"
2711 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_PROPERTIES_INFO,
2713 NULL, NULL, NULL, "Configure element properties, part 1"
2717 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_PROPERTIES_CONFIG_1,
2719 NULL, NULL, NULL, "Configure element properties, part 2"
2723 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_PROPERTIES_CONFIG_2,
2725 NULL, NULL, NULL, "Configure custom element change pages"
2728 /* ---------- level and editor settings (buttons) ------------------------ */
2731 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(9),
2732 GADGET_ID_SAVE_LEVELSET, GADGET_ID_LEVELSET_SAVE_MODE,
2734 NULL, NULL, NULL, "Update or create level set"
2737 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
2738 GADGET_ID_SAVE_AS_TEMPLATE_2, GADGET_ID_NONE,
2740 NULL, NULL, "this level as level template",
2741 "Save current settings as new template"
2744 /* ---------- element settings (buttons) --------------------------------- */
2748 GADGET_ID_SAVE_AS_TEMPLATE_1, GADGET_ID_CUSTOM_USE_TEMPLATE_1,
2750 NULL, " ", "As Template",
2751 "Save current settings as new template"
2755 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
2757 NULL, NULL, NULL, "Add new change page"
2761 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
2763 NULL, NULL, NULL, "Delete current change page"
2772 int gadget_id_align;
2773 char *text_left, *text_right, *infotext;
2774 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
2777 IMG_EDITOR_COUNTER_DOWN,
2778 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
2779 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
2780 NULL, NULL, "select previous change page"
2783 IMG_EDITOR_COUNTER_UP,
2784 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2785 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
2786 NULL, "change page", "select next change page"
2789 IMG_GFX_EDITOR_BUTTON_CP_COPY,
2790 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2791 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
2792 " ", NULL, "copy settings from this change page"
2795 IMG_GFX_EDITOR_BUTTON_CP_PASTE,
2796 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2797 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
2798 NULL, NULL, "paste settings to this change page"
2805 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
2812 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
2815 IMG_EDITOR_PLAYFIELD_SCROLL_UP,
2816 GADGET_ID_SCROLL_UP,
2817 "scroll level editing area up"
2820 IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
2821 GADGET_ID_SCROLL_DOWN,
2822 "scroll level editing area down"
2825 IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
2826 GADGET_ID_SCROLL_LEFT,
2827 "scroll level editing area left"
2830 IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
2831 GADGET_ID_SCROLL_RIGHT,
2832 "scroll level editing area right"
2835 IMG_EDITOR_PALETTE_SCROLL_UP,
2836 GADGET_ID_SCROLL_LIST_UP,
2837 "scroll element list up ('Page Up')"
2840 IMG_EDITOR_PALETTE_SCROLL_DOWN,
2841 GADGET_ID_SCROLL_LIST_DOWN,
2842 "scroll element list down ('Page Down')"
2850 int wheel_x, wheel_y;
2851 int wheel_width, wheel_height;
2852 } scrollbar_pos[ED_NUM_SCROLLBARS];
2860 } scrollbar_info[ED_NUM_SCROLLBARS] =
2863 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
2864 GD_TYPE_SCROLLBAR_HORIZONTAL,
2865 GADGET_ID_SCROLL_HORIZONTAL,
2866 "scroll level editing area horizontally"
2869 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
2870 GD_TYPE_SCROLLBAR_VERTICAL,
2871 GADGET_ID_SCROLL_VERTICAL,
2872 "scroll level editing area vertically"
2875 IMG_EDITOR_PALETTE_SCROLLBAR,
2876 GD_TYPE_SCROLLBAR_VERTICAL,
2877 GADGET_ID_SCROLL_LIST_VERTICAL,
2878 "scroll element list vertically"
2887 int gadget_id_align;
2888 int radio_button_nr;
2891 char *text_left, *text_right, *infotext;
2892 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
2895 -1, ED_LEVEL_SETTINGS_YPOS(0),
2896 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
2897 RADIO_NR_RANDOM_ELEMENTS,
2898 &random_placement_method, RANDOM_USE_PERCENTAGE,
2899 " ", "percentage", "use percentage for random elements"
2902 -1, ED_LEVEL_SETTINGS_YPOS(0),
2903 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
2904 RADIO_NR_RANDOM_ELEMENTS,
2905 &random_placement_method, RANDOM_USE_QUANTITY,
2906 " ", "quantity", "use quantity for random elements"
2914 int gadget_id_align;
2916 char *text_above, *text_left, *text_right, *infotext;
2917 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
2919 /* ---------- level and editor settings ---------------------------------- */
2922 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
2923 GADGET_ID_AUTO_COUNT_GEMS, GADGET_ID_NONE,
2924 &level.auto_count_gems,
2926 "automatically count gems needed", "set counter to number of gems"
2929 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
2930 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
2931 &random_placement_background_restricted,
2933 "restrict random placement to:", "set random placement restriction"
2936 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
2937 GADGET_ID_CUSTOM_USE_TEMPLATE_3, GADGET_ID_NONE,
2938 &setup.editor.use_template_for_new_levels,
2939 "Template for new levels and CE/GE:", NULL,
2940 "use template for new levels", "use template for level properties"
2943 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
2944 GADGET_ID_CUSTOM_USE_TEMPLATE_2, GADGET_ID_NONE,
2945 &level.use_custom_template,
2947 "use template for custom elements", "use template for custom properties"
2950 /* ---------- element settings: configure (various elements) ------------- */
2953 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2954 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
2955 &stick_element_properties_window,
2957 "stick this screen to edit content","stick this screen to edit content"
2960 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2961 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
2962 &level.em_slippery_gems,
2964 "slip down from certain flat walls","use EM/DC style slipping behaviour"
2967 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2968 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
2969 &level.em_explodes_by_fire,
2971 "explodes with chain reaction", "use R'n'D style explosion behaviour"
2974 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2975 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
2976 &level.use_spring_bug,
2978 "use spring pushing bug", "use odd spring pushing behaviour"
2981 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2982 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
2983 &level.use_time_orb_bug,
2985 "use time orb bug", "use odd time orb behaviour"
2988 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2989 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
2992 "create single random element", "only create one element from content"
2995 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2996 GADGET_ID_INITIAL_BALL_STATE, GADGET_ID_NONE,
2997 &level.ball_state_initial,
2999 "magic ball initially activated", "activate magic ball after level start"
3002 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3003 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
3004 &level.grow_into_diggable,
3006 "can grow into anything diggable", "grow into more than just sand"
3009 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3010 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
3011 &level.auto_exit_sokoban,
3013 "exit level if all fields solved", "automatically finish Sokoban levels"
3016 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3017 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
3018 &level.continuous_snapping,
3020 "continuous snapping", "use snapping without releasing key"
3023 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3024 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
3025 &level.block_snap_field,
3027 "block snapped field when snapping", "use snapping delay to show animation"
3030 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3031 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3032 &level.block_last_field,
3034 "block last field when moving", "player blocks last field when moving"
3037 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3038 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3039 &level.sp_block_last_field,
3041 "block last field when moving", "player blocks last field when moving"
3044 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3045 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
3046 &level.instant_relocation,
3048 "no scrolling when relocating", "player gets relocated without delay"
3051 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3052 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
3053 &level.shifted_relocation,
3055 "no centering when relocating", "level not centered after relocation"
3058 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3059 GADGET_ID_LAZY_RELOCATION, GADGET_ID_NONE,
3060 &level.lazy_relocation,
3062 "only redraw off-screen relocation","no redraw if relocation target visible"
3065 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3066 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
3067 &level.use_start_element[0],
3069 "use level start element:", "start level at this element's position"
3072 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3073 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
3074 &level.use_artwork_element[0],
3076 "use artwork from element:", "use player artwork from other element"
3079 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
3080 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
3081 &level.use_explosion_element[0],
3083 "use explosion from element:", "use explosion properties from element"
3086 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3087 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
3088 &level.initial_player_gravity[0],
3090 "use initial gravity", "set initial player gravity"
3093 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3094 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
3095 &level.use_initial_inventory[0],
3097 "use initial inventory:", "use collected elements on level start"
3100 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3101 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
3102 &level.can_pass_to_walkable,
3104 "can pass to walkable element", "player can pass to empty or walkable"
3107 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3108 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
3109 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3111 "can fall into acid (with gravity)","player can fall into acid pool"
3114 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3115 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
3116 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3118 "can move into acid", "element can move into acid pool"
3121 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3122 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
3123 &custom_element_properties[EP_DONT_COLLIDE_WITH],
3125 "deadly when colliding with", "element is deadly when hitting player"
3128 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3129 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
3130 &level.envelope[0].autowrap,
3132 "auto-wrap", "automatically wrap envelope text"
3135 -1, ED_ELEMENT_SETTINGS_YPOS(1),
3136 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
3137 &level.envelope[0].centered,
3139 "centered", "automatically center envelope text"
3142 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3143 GADGET_ID_MM_LASER_RED, GADGET_ID_NONE,
3144 &level.mm_laser_red,
3145 "choose color components for laser:", NULL,
3146 "red", "use red color components in laser"
3149 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3150 GADGET_ID_MM_LASER_GREEN, GADGET_ID_NONE,
3151 &level.mm_laser_green,
3153 "green", "use green color components in laser"
3156 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3157 GADGET_ID_MM_LASER_BLUE, GADGET_ID_NONE,
3158 &level.mm_laser_blue,
3160 "blue", "use blue color components in laser"
3163 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3164 GADGET_ID_DF_LASER_RED, GADGET_ID_NONE,
3165 &level.df_laser_red,
3166 "choose color components for laser:", NULL,
3167 "red", "use red color components in laser"
3170 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3171 GADGET_ID_DF_LASER_GREEN, GADGET_ID_NONE,
3172 &level.df_laser_green,
3174 "green", "use green color components in laser"
3177 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3178 GADGET_ID_DF_LASER_BLUE, GADGET_ID_NONE,
3179 &level.df_laser_blue,
3181 "blue", "use blue color components in laser"
3184 /* ---------- element settings: configure 1 (custom elements) ----------- */
3187 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3188 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
3189 &custom_element.use_gfx_element,
3191 "use graphic of element:", "use existing element graphic"
3194 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3195 GADGET_ID_CUSTOM_USE_TEMPLATE_1, GADGET_ID_NONE,
3196 &level.use_custom_template,
3198 "use template", "use template for custom properties"
3201 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3202 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
3203 &custom_element_properties[EP_ACCESSIBLE],
3205 NULL, "player can walk to or pass this field"
3208 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3209 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
3210 &custom_element_properties[EP_GRAVITY_REACHABLE],
3212 "reachable despite gravity", "player can walk/dig despite gravity"
3215 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3216 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
3217 &custom_element.use_last_ce_value,
3219 "use last CE value after change", "use last CE value after change"
3222 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3223 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
3224 &custom_element_properties[EP_WALK_TO_OBJECT],
3226 NULL, "player can dig/collect/push element"
3229 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3230 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
3231 &custom_element_properties[EP_INDESTRUCTIBLE],
3233 "indestructible", "element is indestructible"
3236 /* ---------- element settings: configure 2 (custom elements) ----------- */
3239 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3240 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
3241 &custom_element_properties[EP_CAN_MOVE],
3243 NULL, "element can move with some pattern"
3246 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
3247 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
3248 &custom_element_properties[EP_CAN_FALL],
3250 "can fall", "element can fall down"
3253 -1, ED_ELEMENT_SETTINGS_YPOS(7),
3254 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
3255 &custom_element_properties[EP_CAN_SMASH],
3257 NULL, "element can smash other elements"
3260 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3261 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
3262 &custom_element_properties[EP_SLIPPERY],
3264 NULL, "other elements can fall down from it"
3267 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3268 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
3269 &custom_element_properties[EP_DEADLY],
3271 NULL, "element can kill the player"
3274 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3275 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
3276 &custom_element_properties[EP_CAN_EXPLODE],
3278 NULL, "element can explode"
3281 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
3282 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
3283 &custom_element_properties[EP_EXPLODES_BY_FIRE],
3285 "by fire", "element can explode by fire/explosion"
3288 -1, ED_ELEMENT_SETTINGS_YPOS(11),
3289 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
3290 &custom_element_properties[EP_EXPLODES_SMASHED],
3292 "smashed", "element can explode when smashed"
3295 -1, ED_ELEMENT_SETTINGS_YPOS(11),
3296 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
3297 &custom_element_properties[EP_EXPLODES_IMPACT],
3299 "impact", "element can explode on impact"
3302 /* ---------- element settings: advanced (custom elements) --------------- */
3305 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3306 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
3307 &custom_element_change.can_change,
3309 "element changes to:", "change element on specified condition"
3312 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
3313 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
3314 &custom_element_change_events[CE_DELAY],
3316 NULL, "element changes after delay"
3319 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
3320 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
3321 &custom_element_change_events[CE_BY_DIRECT_ACTION],
3323 NULL, "element changes by direct action"
3326 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
3327 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
3328 &custom_element_change_events[CE_BY_OTHER_ACTION],
3330 NULL, "element changes by other element"
3333 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
3334 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
3335 &custom_element_change.explode,
3337 "explode instead of change", "element explodes instead of change"
3340 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
3341 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
3342 &custom_element_change.use_target_content,
3344 "use extended change target:", "element changes to more elements"
3347 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3348 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3349 &custom_element_change.only_if_complete,
3351 "replace all or nothing", "only replace when all can be changed"
3354 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3355 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3356 &custom_element_change.use_random_replace,
3358 NULL, "use percentage for random replace"
3361 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3362 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3363 &custom_element_change.has_action,
3365 NULL, "execute action on specified condition"
3372 int xoffset, yoffset;
3374 int gadget_id_align;
3376 int area_xsize, area_ysize;
3377 char *text_left, *text_right, *text_below, *infotext;
3378 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3380 /* ---------- level playfield content ------------------------------------ */
3385 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
3387 -1, -1, /* these values are not constant, but can change at runtime */
3388 NULL, NULL, NULL, NULL
3391 /* ---------- yam yam content -------------------------------------------- */
3394 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3395 ED_AREA_YAMYAM_CONTENT_XOFF(0), ED_AREA_YAMYAM_CONTENT_YOFF(0),
3396 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
3397 &level.yamyam_content[0].e[0][0], 3, 3,
3398 NULL, NULL, "1", NULL
3401 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3402 ED_AREA_YAMYAM_CONTENT_XOFF(1), ED_AREA_YAMYAM_CONTENT_YOFF(1),
3403 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
3404 &level.yamyam_content[1].e[0][0], 3, 3,
3405 NULL, NULL, "2", NULL
3408 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3409 ED_AREA_YAMYAM_CONTENT_XOFF(2), ED_AREA_YAMYAM_CONTENT_YOFF(2),
3410 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
3411 &level.yamyam_content[2].e[0][0], 3, 3,
3412 NULL, NULL, "3", NULL
3415 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3416 ED_AREA_YAMYAM_CONTENT_XOFF(3), ED_AREA_YAMYAM_CONTENT_YOFF(3),
3417 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
3418 &level.yamyam_content[3].e[0][0], 3, 3,
3419 NULL, NULL, "4", NULL
3422 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3423 ED_AREA_YAMYAM_CONTENT_XOFF(4), ED_AREA_YAMYAM_CONTENT_YOFF(4),
3424 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
3425 &level.yamyam_content[4].e[0][0], 3, 3,
3426 NULL, NULL, "5", NULL
3429 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3430 ED_AREA_YAMYAM_CONTENT_XOFF(5), ED_AREA_YAMYAM_CONTENT_YOFF(5),
3431 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
3432 &level.yamyam_content[5].e[0][0], 3, 3,
3433 NULL, NULL, "6", NULL
3436 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3437 ED_AREA_YAMYAM_CONTENT_XOFF(6), ED_AREA_YAMYAM_CONTENT_YOFF(6),
3438 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
3439 &level.yamyam_content[6].e[0][0], 3, 3,
3440 NULL, NULL, "7", NULL
3443 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3444 ED_AREA_YAMYAM_CONTENT_XOFF(7), ED_AREA_YAMYAM_CONTENT_YOFF(7),
3445 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
3446 &level.yamyam_content[7].e[0][0], 3, 3,
3447 NULL, NULL, "8", NULL
3450 /* ---------- magic ball content ----------------------------------------- */
3453 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3454 ED_AREA_MAGIC_BALL_CONTENT_XOFF(0), ED_AREA_MAGIC_BALL_CONTENT_YOFF(0),
3455 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
3456 &level.ball_content[0].e[0][0], 3, 3,
3457 NULL, NULL, "1", NULL
3460 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3461 ED_AREA_MAGIC_BALL_CONTENT_XOFF(1), ED_AREA_MAGIC_BALL_CONTENT_YOFF(1),
3462 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
3463 &level.ball_content[1].e[0][0], 3, 3,
3464 NULL, NULL, "2", NULL
3467 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3468 ED_AREA_MAGIC_BALL_CONTENT_XOFF(2), ED_AREA_MAGIC_BALL_CONTENT_YOFF(2),
3469 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
3470 &level.ball_content[2].e[0][0], 3, 3,
3471 NULL, NULL, "3", NULL
3474 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3475 ED_AREA_MAGIC_BALL_CONTENT_XOFF(3), ED_AREA_MAGIC_BALL_CONTENT_YOFF(3),
3476 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
3477 &level.ball_content[3].e[0][0], 3, 3,
3478 NULL, NULL, "4", NULL
3481 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3482 ED_AREA_MAGIC_BALL_CONTENT_XOFF(4), ED_AREA_MAGIC_BALL_CONTENT_YOFF(4),
3483 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
3484 &level.ball_content[4].e[0][0], 3, 3,
3485 NULL, NULL, "5", NULL
3488 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3489 ED_AREA_MAGIC_BALL_CONTENT_XOFF(5), ED_AREA_MAGIC_BALL_CONTENT_YOFF(5),
3490 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
3491 &level.ball_content[5].e[0][0], 3, 3,
3492 NULL, NULL, "6", NULL
3495 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3496 ED_AREA_MAGIC_BALL_CONTENT_XOFF(6), ED_AREA_MAGIC_BALL_CONTENT_YOFF(6),
3497 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
3498 &level.ball_content[6].e[0][0], 3, 3,
3499 NULL, NULL, "7", NULL
3502 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3503 ED_AREA_MAGIC_BALL_CONTENT_XOFF(7), ED_AREA_MAGIC_BALL_CONTENT_YOFF(7),
3504 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
3505 &level.ball_content[7].e[0][0], 3, 3,
3506 NULL, NULL, "8", NULL
3509 /* ---------- android content -------------------------------------------- */
3512 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(5),
3513 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3514 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
3515 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
3516 "elements:", NULL, NULL, "elements android can clone"
3519 /* ---------- amoeba content --------------------------------------------- */
3522 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
3523 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3524 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
3525 &level.amoeba_content, 1, 1,
3526 "content:", NULL, NULL, "amoeba content"
3529 /* ---------- level start element ---------------------------------------- */
3532 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
3533 0, ED_AREA_1X1_SETTINGS_YOFF,
3534 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
3535 &level.start_element[0], 1, 1,
3536 NULL, NULL, NULL, "level start element"
3539 /* ---------- player artwork element ------------------------------------- */
3542 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
3543 0, ED_AREA_1X1_SETTINGS_YOFF,
3544 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
3545 &level.artwork_element[0], 1, 1,
3546 NULL, NULL, NULL, "element for player artwork"
3549 /* ---------- player explosion element ----------------------------------- */
3552 -1, ED_AREA_1X1_SETTINGS_YPOS(12),
3553 0, ED_AREA_1X1_SETTINGS_YOFF,
3554 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
3555 &level.explosion_element[0], 1, 1,
3556 NULL, NULL, NULL, "element for player explosion"
3559 /* ---------- player initial inventory ----------------------------------- */
3562 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3563 0, ED_AREA_1X1_SETTINGS_YOFF,
3564 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
3565 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
3566 NULL, NULL, NULL, "content for initial inventory"
3569 /* ---------- element settings: configure 1 (custom elements) ----------- */
3571 /* ---------- custom graphic --------------------------------------------- */
3574 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3575 0, ED_AREA_1X1_SETTINGS_YOFF,
3576 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
3577 &custom_element.gfx_element_initial,1, 1,
3578 NULL, NULL, NULL, "custom graphic element"
3581 /* ---------- element settings: configure 2 (custom elements) ----------- */
3583 /* ---------- custom content (when exploding) ---------------------------- */
3586 -1, ED_AREA_3X3_SETTINGS_YPOS(10),
3587 0, ED_AREA_3X3_SETTINGS_YOFF,
3588 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, /* align three rows */
3589 &custom_element.content.e[0][0], 3, 3,
3590 "content:", NULL, NULL, NULL
3593 /* ---------- custom enter and leave element (when moving) --------------- */
3596 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
3597 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3598 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
3599 &custom_element.move_enter_element, 1, 1,
3600 "can dig:", " ", NULL, "element that can be digged/collected"
3603 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
3604 0, ED_AREA_1X1_SETTINGS_YOFF,
3605 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
3606 &custom_element.move_leave_element, 1, 1,
3607 NULL, NULL, NULL, "element that will be left behind"
3610 /* ---------- element settings: advanced (custom elements) --------------- */
3612 /* ---------- custom change target --------------------------------------- */
3615 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3616 0, ED_AREA_1X1_SETTINGS_YOFF,
3617 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
3618 &custom_element_change.target_element, 1, 1,
3619 NULL, "after/when:", NULL, "new target element after change"
3622 /* ---------- custom change content (extended change target) ------------- */
3625 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
3626 0, ED_AREA_3X3_SETTINGS_YOFF,
3627 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, /* align three rows */
3628 &custom_element_change.target_content.e[0][0], 3, 3,
3629 NULL, NULL, NULL, "new extended elements after change"
3632 /* ---------- custom change trigger (element causing change) ------------- */
3635 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
3636 0, ED_AREA_1X1_SETTINGS_YOFF,
3637 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
3638 &custom_element_change.initial_trigger_element, 1, 1,
3639 NULL, NULL, NULL, "other element triggering change"
3642 /* ---------- custom change action (element used for action) ------------- */
3645 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
3646 0, ED_AREA_1X1_SETTINGS_YOFF,
3647 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
3648 &custom_element_change.action_element, 1, 1,
3649 NULL, NULL, NULL, "element used as action parameter"
3652 /* ---------- group element content -------------------------------------- */
3655 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
3656 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3657 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
3658 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
3659 "content:", NULL, NULL, NULL
3662 /* ---------- random background (for random painting) -------------------- */
3665 -1, ED_AREA_1X1_LSETTINGS_YPOS(1),
3666 0, ED_AREA_1X1_LSETTINGS_YOFF,
3667 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
3668 &random_placement_background_element, 1, 1,
3669 NULL, NULL, NULL, "random placement background"
3675 -----------------------------------------------------------------------------
3676 some internally used variables
3677 -----------------------------------------------------------------------------
3680 /* maximal size of level editor drawing area */
3681 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
3683 /* actual size of level editor drawing area */
3684 static int ed_fieldx, ed_fieldy;
3686 /* actual position of level editor drawing area in level playfield */
3687 static int level_xpos = -1, level_ypos = -1;
3689 /* actual tile size used to display playfield drawing area */
3690 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
3692 #define IN_ED_FIELD(x,y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
3694 /* drawing elements on the three mouse buttons */
3695 static int new_element1 = EL_WALL;
3696 static int new_element2 = EL_EMPTY;
3697 static int new_element3 = EL_SAND;
3699 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
3700 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
3701 (button) == 2 ? new_element2 : \
3702 (button) == 3 ? new_element3 : EL_EMPTY)
3704 #define BUTTON_TILE_SIZE(x) ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE)
3706 static int use_permanent_palette = TRUE;
3708 #define PX (use_permanent_palette ? DX : SX)
3709 #define PY (use_permanent_palette ? DY : SY)
3710 #define PXSIZE (use_permanent_palette ? DXSIZE : SXSIZE)
3711 #define PYSIZE (use_permanent_palette ? DYSIZE : SYSIZE)
3713 /* forward declaration for internal use */
3714 static void ModifyEditorCounterValue(int, int);
3715 static void ModifyEditorCounterLimits(int, int, int);
3716 static void ModifyEditorSelectboxValue(int, int);
3717 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
3718 static void ModifyEditorDrawingArea(int, int, int);
3719 static void ModifyEditorElementList();
3720 static void AdjustElementListScrollbar();
3721 static void RedrawDrawingElements();
3722 static void DrawDrawingWindow();
3723 static void DrawLevelInfoWindow();
3724 static void DrawPropertiesWindow();
3725 static void DrawPaletteWindow();
3726 static void UpdateCustomElementGraphicGadgets();
3727 static boolean checkPropertiesConfig(int);
3728 static void SetAutomaticNumberOfGemsNeeded();
3729 static void ClearEditorGadgetInfoText();
3730 static void CopyLevelToUndoBuffer(int);
3731 static void HandleDrawingAreas(struct GadgetInfo *);
3732 static void HandleCounterButtons(struct GadgetInfo *);
3733 static void HandleTextInputGadgets(struct GadgetInfo *);
3734 static void HandleTextAreaGadgets(struct GadgetInfo *);
3735 static void HandleSelectboxGadgets(struct GadgetInfo *);
3736 static void HandleTextbuttonGadgets(struct GadgetInfo *);
3737 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
3738 static void HandleRadiobuttons(struct GadgetInfo *);
3739 static void HandleCheckbuttons(struct GadgetInfo *);
3740 static void HandleControlButtons(struct GadgetInfo *);
3741 static void HandleDrawingAreaInfo(struct GadgetInfo *);
3742 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
3743 static boolean AskToCopyAndModifyLevelTemplate();
3744 static boolean getDrawModeHiRes();
3746 static int num_editor_gadgets = 0; /* dynamically determined */
3748 static struct GadgetInfo **level_editor_gadget = NULL;
3749 static int *right_gadget_border = NULL;
3751 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
3752 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
3753 static boolean draw_with_brush = FALSE;
3754 static int properties_element = 0;
3756 static short FieldBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3757 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3758 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3759 static int undo_buffer_position = 0;
3760 static int undo_buffer_steps = 0;
3761 static int redo_buffer_steps = 0;
3763 static int edit_mode;
3764 static int edit_mode_levelinfo;
3765 static int edit_mode_properties;
3767 static int element_shift = 0;
3769 static int editor_el_players[] =
3776 static int *editor_el_players_ptr = editor_el_players;
3777 static int num_editor_el_players = SIZEOF_ARRAY_INT(editor_el_players);
3779 static int editor_hl_boulderdash[] =
3781 EL_INTERNAL_CASCADE_BD_ACTIVE,
3787 static int editor_el_boulderdash[] =
3796 EL_BD_EXPANDABLE_WALL,
3804 EL_BD_BUTTERFLY_LEFT,
3806 EL_BD_BUTTERFLY_RIGHT,
3807 EL_BD_FIREFLY_RIGHT,
3810 EL_BD_BUTTERFLY_DOWN,
3814 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
3815 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
3816 static int num_editor_hl_boulderdash = SIZEOF_ARRAY_INT(editor_hl_boulderdash);
3817 static int num_editor_el_boulderdash = SIZEOF_ARRAY_INT(editor_el_boulderdash);
3819 static int editor_hl_emerald_mine[] =
3821 EL_INTERNAL_CASCADE_EM_ACTIVE,
3827 static int editor_el_emerald_mine[] =
3864 EL_ACID_POOL_TOPLEFT,
3866 EL_ACID_POOL_TOPRIGHT,
3869 EL_ACID_POOL_BOTTOMLEFT,
3870 EL_ACID_POOL_BOTTOM,
3871 EL_ACID_POOL_BOTTOMRIGHT,
3891 EL_EM_STEEL_EXIT_CLOSED,
3892 EL_EM_STEEL_EXIT_OPEN,
3894 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
3895 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
3896 static int num_editor_hl_emerald_mine=SIZEOF_ARRAY_INT(editor_hl_emerald_mine);
3897 static int num_editor_el_emerald_mine=SIZEOF_ARRAY_INT(editor_el_emerald_mine);
3899 static int editor_hl_emerald_mine_club[] =
3901 EL_INTERNAL_CASCADE_EMC_ACTIVE,
3907 static int editor_el_emerald_mine_club[] =
3934 EL_EMC_WALL_SLIPPERY_1,
3935 EL_EMC_WALL_SLIPPERY_2,
3936 EL_EMC_WALL_SLIPPERY_3,
3937 EL_EMC_WALL_SLIPPERY_4,
3960 EL_EMC_MAGIC_BALL_SWITCH,
3962 EL_EMC_SPRING_BUMPER,
3967 EL_EM_DYNAMITE_ACTIVE,
3971 EL_BALLOON_SWITCH_UP,
3972 EL_BALLOON_SWITCH_ANY,
3975 EL_BALLOON_SWITCH_LEFT,
3977 EL_BALLOON_SWITCH_RIGHT,
3981 EL_BALLOON_SWITCH_DOWN,
3982 EL_BALLOON_SWITCH_NONE,
3984 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
3985 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
3986 static int num_editor_hl_emerald_mine_club=SIZEOF_ARRAY_INT(editor_hl_emerald_mine_club);
3987 static int num_editor_el_emerald_mine_club=SIZEOF_ARRAY_INT(editor_el_emerald_mine_club);
3989 static int editor_hl_rnd[] =
3991 EL_INTERNAL_CASCADE_RND_ACTIVE,
3997 static int editor_el_rnd[] =
4029 EL_WALL_EMERALD_YELLOW,
4030 EL_WALL_EMERALD_RED,
4031 EL_WALL_EMERALD_PURPLE,
4049 EL_DYNABOMB_INCREASE_NUMBER,
4050 EL_DYNABOMB_INCREASE_SIZE,
4051 EL_DYNABOMB_INCREASE_POWER,
4071 EL_INVISIBLE_STEELWALL,
4075 EL_EXPANDABLE_WALL_HORIZONTAL,
4076 EL_EXPANDABLE_WALL_VERTICAL,
4077 EL_EXPANDABLE_WALL_ANY,
4079 static int *editor_hl_rnd_ptr = editor_hl_rnd;
4080 static int *editor_el_rnd_ptr = editor_el_rnd;
4081 static int num_editor_hl_rnd = SIZEOF_ARRAY_INT(editor_hl_rnd);
4082 static int num_editor_el_rnd = SIZEOF_ARRAY_INT(editor_el_rnd);
4084 static int editor_hl_sokoban[] =
4086 EL_INTERNAL_CASCADE_SB_ACTIVE,
4092 static int editor_el_sokoban[] =
4095 EL_SOKOBAN_FIELD_EMPTY,
4096 EL_SOKOBAN_FIELD_FULL,
4097 EL_SOKOBAN_FIELD_PLAYER,
4099 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
4100 static int *editor_el_sokoban_ptr = editor_el_sokoban;
4101 static int num_editor_hl_sokoban = SIZEOF_ARRAY_INT(editor_hl_sokoban);
4102 static int num_editor_el_sokoban = SIZEOF_ARRAY_INT(editor_el_sokoban);
4104 static int editor_hl_supaplex[] =
4106 EL_INTERNAL_CASCADE_SP_ACTIVE,
4112 static int editor_el_supaplex[] =
4130 EL_SP_PORT_HORIZONTAL,
4131 EL_SP_PORT_VERTICAL,
4139 EL_SP_GRAVITY_PORT_LEFT,
4140 EL_SP_GRAVITY_PORT_RIGHT,
4141 EL_SP_GRAVITY_PORT_UP,
4142 EL_SP_GRAVITY_PORT_DOWN,
4144 EL_SP_GRAVITY_ON_PORT_LEFT,
4145 EL_SP_GRAVITY_ON_PORT_RIGHT,
4146 EL_SP_GRAVITY_ON_PORT_UP,
4147 EL_SP_GRAVITY_ON_PORT_DOWN,
4149 EL_SP_GRAVITY_OFF_PORT_LEFT,
4150 EL_SP_GRAVITY_OFF_PORT_RIGHT,
4151 EL_SP_GRAVITY_OFF_PORT_UP,
4152 EL_SP_GRAVITY_OFF_PORT_DOWN,
4154 EL_SP_HARDWARE_GRAY,
4155 EL_SP_HARDWARE_GREEN,
4156 EL_SP_HARDWARE_BLUE,
4159 EL_SP_HARDWARE_BASE_1,
4160 EL_SP_HARDWARE_BASE_2,
4161 EL_SP_HARDWARE_BASE_3,
4162 EL_SP_HARDWARE_BASE_4,
4164 EL_SP_HARDWARE_BASE_5,
4165 EL_SP_HARDWARE_BASE_6,
4166 EL_SP_HARDWARE_YELLOW,
4174 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
4175 static int *editor_el_supaplex_ptr = editor_el_supaplex;
4176 static int num_editor_hl_supaplex = SIZEOF_ARRAY_INT(editor_hl_supaplex);
4177 static int num_editor_el_supaplex = SIZEOF_ARRAY_INT(editor_el_supaplex);
4179 static int editor_hl_diamond_caves[] =
4181 EL_INTERNAL_CASCADE_DC_ACTIVE,
4187 static int editor_el_diamond_caves[] =
4194 EL_CONVEYOR_BELT_1_LEFT,
4195 EL_CONVEYOR_BELT_1_MIDDLE,
4196 EL_CONVEYOR_BELT_1_RIGHT,
4197 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
4199 EL_CONVEYOR_BELT_2_LEFT,
4200 EL_CONVEYOR_BELT_2_MIDDLE,
4201 EL_CONVEYOR_BELT_2_RIGHT,
4202 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
4204 EL_CONVEYOR_BELT_3_LEFT,
4205 EL_CONVEYOR_BELT_3_MIDDLE,
4206 EL_CONVEYOR_BELT_3_RIGHT,
4207 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
4209 EL_CONVEYOR_BELT_4_LEFT,
4210 EL_CONVEYOR_BELT_4_MIDDLE,
4211 EL_CONVEYOR_BELT_4_RIGHT,
4212 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
4214 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
4215 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
4216 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
4217 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
4219 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
4220 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
4221 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
4222 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
4227 EL_DC_TIMEGATE_SWITCH,
4229 EL_SWITCHGATE_CLOSED,
4231 EL_SWITCHGATE_SWITCH_UP,
4232 EL_SWITCHGATE_SWITCH_DOWN,
4235 EL_LIGHT_SWITCH_ACTIVE,
4236 EL_DC_SWITCHGATE_SWITCH_UP,
4237 EL_DC_SWITCHGATE_SWITCH_DOWN,
4239 EL_STEEL_EXIT_CLOSED,
4241 EL_STEELWALL_SLIPPERY,
4244 EL_QUICKSAND_FAST_EMPTY,
4245 EL_QUICKSAND_FAST_FULL,
4259 EL_SIGN_RADIOACTIVITY,
4265 EL_SIGN_ENTRY_FORBIDDEN,
4266 EL_SIGN_EMERGENCY_EXIT,
4291 EL_DC_STEELWALL_2_SINGLE,
4292 EL_DC_STEELWALL_2_TOP,
4293 EL_SIGN_EXCLAMATION,
4296 EL_DC_STEELWALL_2_LEFT,
4297 EL_DC_STEELWALL_2_MIDDLE,
4298 EL_DC_STEELWALL_2_HORIZONTAL,
4299 EL_DC_STEELWALL_2_RIGHT,
4301 EL_DC_STEELWALL_1_TOPLEFT,
4302 EL_DC_STEELWALL_2_VERTICAL,
4303 EL_DC_STEELWALL_1_TOPRIGHT,
4306 EL_DC_STEELWALL_1_VERTICAL,
4307 EL_DC_STEELWALL_2_BOTTOM,
4309 EL_DC_GATE_WHITE_GRAY,
4311 EL_DC_STEELWALL_1_BOTTOMLEFT,
4312 EL_DC_STEELWALL_1_HORIZONTAL,
4313 EL_DC_STEELWALL_1_BOTTOMRIGHT,
4314 EL_DC_GATE_FAKE_GRAY,
4316 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
4317 EL_DC_STEELWALL_1_BOTTOM,
4318 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
4319 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
4321 EL_DC_STEELWALL_1_RIGHT,
4323 EL_DC_STEELWALL_1_LEFT,
4324 EL_EXPANDABLE_STEELWALL_VERTICAL,
4326 EL_DC_STEELWALL_1_TOPRIGHT_2,
4327 EL_DC_STEELWALL_1_TOP,
4328 EL_DC_STEELWALL_1_TOPLEFT_2,
4329 EL_EXPANDABLE_STEELWALL_ANY,
4331 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
4332 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
4333 static int num_editor_hl_diamond_caves = SIZEOF_ARRAY_INT(editor_hl_diamond_caves);
4334 static int num_editor_el_diamond_caves = SIZEOF_ARRAY_INT(editor_el_diamond_caves);
4336 static int editor_hl_dx_boulderdash[] =
4338 EL_INTERNAL_CASCADE_DX_ACTIVE,
4344 static int editor_el_dx_boulderdash[] =
4348 EL_TUBE_HORIZONTAL_DOWN,
4352 EL_TUBE_VERTICAL_RIGHT,
4354 EL_TUBE_VERTICAL_LEFT,
4358 EL_TUBE_HORIZONTAL_UP,
4366 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
4367 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
4368 static int num_editor_hl_dx_boulderdash = SIZEOF_ARRAY_INT(editor_hl_dx_boulderdash);
4369 static int num_editor_el_dx_boulderdash = SIZEOF_ARRAY_INT(editor_el_dx_boulderdash);
4371 static int editor_hl_mirror_magic[] =
4373 EL_INTERNAL_CASCADE_MM_ACTIVE,
4379 static int editor_el_mirror_magic[] =
4381 EL_MM_MCDUFFIN_RIGHT,
4383 EL_MM_MCDUFFIN_LEFT,
4384 EL_MM_MCDUFFIN_DOWN,
4387 EL_MM_MIRROR_FIXED_START,
4388 EL_MM_POLARISATOR_START,
4389 EL_MM_POLARISATOR_CROSS_START,
4391 EL_MM_BEAMER_RED_START,
4392 EL_MM_BEAMER_YELLOW_START,
4393 EL_MM_BEAMER_GREEN_START,
4394 EL_MM_BEAMER_BLUE_START,
4407 EL_MM_LIGHTBULB_ACTIVE,
4421 EL_MM_STEEL_GRID_FIXED_1,
4422 EL_MM_STEEL_GRID_FIXED_2,
4423 EL_MM_STEEL_GRID_FIXED_3,
4424 EL_MM_STEEL_GRID_FIXED_4,
4426 EL_MM_WOODEN_GRID_FIXED_1,
4427 EL_MM_WOODEN_GRID_FIXED_2,
4428 EL_MM_WOODEN_GRID_FIXED_3,
4429 EL_MM_WOODEN_GRID_FIXED_4
4431 static int *editor_hl_mirror_magic_ptr = editor_hl_mirror_magic;
4432 static int *editor_el_mirror_magic_ptr = editor_el_mirror_magic;
4433 static int num_editor_hl_mirror_magic = SIZEOF_ARRAY_INT(editor_hl_mirror_magic);
4434 static int num_editor_el_mirror_magic = SIZEOF_ARRAY_INT(editor_el_mirror_magic);
4436 static int editor_hl_deflektor[] =
4438 EL_INTERNAL_CASCADE_DF_ACTIVE,
4444 static int editor_el_deflektor[] =
4451 EL_DF_RECEIVER_RIGHT,
4453 EL_DF_RECEIVER_LEFT,
4454 EL_DF_RECEIVER_DOWN,
4457 EL_DF_MIRROR_ROTATING_START,
4461 EL_DF_FIBRE_OPTIC_RED_1,
4462 EL_DF_FIBRE_OPTIC_YELLOW_1,
4463 EL_DF_FIBRE_OPTIC_GREEN_1,
4464 EL_DF_FIBRE_OPTIC_BLUE_1,
4466 EL_DF_STEEL_GRID_FIXED_START,
4467 EL_DF_STEEL_GRID_ROTATING_START,
4468 EL_DF_WOODEN_GRID_FIXED_START,
4469 EL_DF_WOODEN_GRID_ROTATING_START,
4476 static int *editor_hl_deflektor_ptr = editor_hl_deflektor;
4477 static int *editor_el_deflektor_ptr = editor_el_deflektor;
4478 static int num_editor_hl_deflektor = SIZEOF_ARRAY_INT(editor_hl_deflektor);
4479 static int num_editor_el_deflektor = SIZEOF_ARRAY_INT(editor_el_deflektor);
4481 static int editor_hl_chars[] =
4483 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
4489 static int editor_el_chars[] =
4571 EL_CHAR(CHAR_BYTE_COPYRIGHT),
4572 EL_CHAR(CHAR_BYTE_UMLAUT_A),
4573 EL_CHAR(CHAR_BYTE_UMLAUT_O),
4574 EL_CHAR(CHAR_BYTE_UMLAUT_U),
4576 EL_CHAR(CHAR_BYTE_DEGREE),
4577 EL_CHAR(CHAR_BYTE_REGISTERED),
4578 EL_CHAR(FONT_ASCII_CURSOR),
4579 EL_CHAR(FONT_ASCII_BUTTON),
4581 EL_CHAR(FONT_ASCII_UP),
4582 EL_CHAR(FONT_ASCII_DOWN),
4586 static int *editor_hl_chars_ptr = editor_hl_chars;
4587 static int *editor_el_chars_ptr = editor_el_chars;
4588 static int num_editor_hl_chars = SIZEOF_ARRAY_INT(editor_hl_chars);
4589 static int num_editor_el_chars = SIZEOF_ARRAY_INT(editor_el_chars);
4591 static int editor_hl_steel_chars[] =
4593 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
4599 static int editor_el_steel_chars[] =
4609 EL_STEEL_CHAR('\''),
4676 EL_STEEL_CHAR('\\'),
4681 EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
4682 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
4683 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
4684 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
4686 EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
4687 EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
4688 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
4689 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
4691 EL_STEEL_CHAR(FONT_ASCII_UP),
4692 EL_STEEL_CHAR(FONT_ASCII_DOWN),
4696 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
4697 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
4698 static int num_editor_hl_steel_chars = SIZEOF_ARRAY_INT(editor_hl_steel_chars);
4699 static int num_editor_el_steel_chars = SIZEOF_ARRAY_INT(editor_el_steel_chars);
4701 static int editor_hl_custom[] =
4703 EL_INTERNAL_CASCADE_CE_ACTIVE,
4709 static int editor_el_custom[] =
4711 EL_CUSTOM_START + 0,
4712 EL_CUSTOM_START + 1,
4713 EL_CUSTOM_START + 2,
4714 EL_CUSTOM_START + 3,
4716 EL_CUSTOM_START + 4,
4717 EL_CUSTOM_START + 5,
4718 EL_CUSTOM_START + 6,
4719 EL_CUSTOM_START + 7,
4721 EL_CUSTOM_START + 8,
4722 EL_CUSTOM_START + 9,
4723 EL_CUSTOM_START + 10,
4724 EL_CUSTOM_START + 11,
4726 EL_CUSTOM_START + 12,
4727 EL_CUSTOM_START + 13,
4728 EL_CUSTOM_START + 14,
4729 EL_CUSTOM_START + 15,
4731 EL_CUSTOM_START + 16,
4732 EL_CUSTOM_START + 17,
4733 EL_CUSTOM_START + 18,
4734 EL_CUSTOM_START + 19,
4736 EL_CUSTOM_START + 20,
4737 EL_CUSTOM_START + 21,
4738 EL_CUSTOM_START + 22,
4739 EL_CUSTOM_START + 23,
4741 EL_CUSTOM_START + 24,
4742 EL_CUSTOM_START + 25,
4743 EL_CUSTOM_START + 26,
4744 EL_CUSTOM_START + 27,
4746 EL_CUSTOM_START + 28,
4747 EL_CUSTOM_START + 29,
4748 EL_CUSTOM_START + 30,
4749 EL_CUSTOM_START + 31,
4751 EL_CUSTOM_START + 32,
4752 EL_CUSTOM_START + 33,
4753 EL_CUSTOM_START + 34,
4754 EL_CUSTOM_START + 35,
4756 EL_CUSTOM_START + 36,
4757 EL_CUSTOM_START + 37,
4758 EL_CUSTOM_START + 38,
4759 EL_CUSTOM_START + 39,
4761 EL_CUSTOM_START + 40,
4762 EL_CUSTOM_START + 41,
4763 EL_CUSTOM_START + 42,
4764 EL_CUSTOM_START + 43,
4766 EL_CUSTOM_START + 44,
4767 EL_CUSTOM_START + 45,
4768 EL_CUSTOM_START + 46,
4769 EL_CUSTOM_START + 47,
4771 EL_CUSTOM_START + 48,
4772 EL_CUSTOM_START + 49,
4773 EL_CUSTOM_START + 50,
4774 EL_CUSTOM_START + 51,
4776 EL_CUSTOM_START + 52,
4777 EL_CUSTOM_START + 53,
4778 EL_CUSTOM_START + 54,
4779 EL_CUSTOM_START + 55,
4781 EL_CUSTOM_START + 56,
4782 EL_CUSTOM_START + 57,
4783 EL_CUSTOM_START + 58,
4784 EL_CUSTOM_START + 59,
4786 EL_CUSTOM_START + 60,
4787 EL_CUSTOM_START + 61,
4788 EL_CUSTOM_START + 62,
4789 EL_CUSTOM_START + 63,
4791 EL_CUSTOM_START + 64,
4792 EL_CUSTOM_START + 65,
4793 EL_CUSTOM_START + 66,
4794 EL_CUSTOM_START + 67,
4796 EL_CUSTOM_START + 68,
4797 EL_CUSTOM_START + 69,
4798 EL_CUSTOM_START + 70,
4799 EL_CUSTOM_START + 71,
4801 EL_CUSTOM_START + 72,
4802 EL_CUSTOM_START + 73,
4803 EL_CUSTOM_START + 74,
4804 EL_CUSTOM_START + 75,
4806 EL_CUSTOM_START + 76,
4807 EL_CUSTOM_START + 77,
4808 EL_CUSTOM_START + 78,
4809 EL_CUSTOM_START + 79,
4811 EL_CUSTOM_START + 80,
4812 EL_CUSTOM_START + 81,
4813 EL_CUSTOM_START + 82,
4814 EL_CUSTOM_START + 83,
4816 EL_CUSTOM_START + 84,
4817 EL_CUSTOM_START + 85,
4818 EL_CUSTOM_START + 86,
4819 EL_CUSTOM_START + 87,
4821 EL_CUSTOM_START + 88,
4822 EL_CUSTOM_START + 89,
4823 EL_CUSTOM_START + 90,
4824 EL_CUSTOM_START + 91,
4826 EL_CUSTOM_START + 92,
4827 EL_CUSTOM_START + 93,
4828 EL_CUSTOM_START + 94,
4829 EL_CUSTOM_START + 95,
4831 EL_CUSTOM_START + 96,
4832 EL_CUSTOM_START + 97,
4833 EL_CUSTOM_START + 98,
4834 EL_CUSTOM_START + 99,
4836 EL_CUSTOM_START + 100,
4837 EL_CUSTOM_START + 101,
4838 EL_CUSTOM_START + 102,
4839 EL_CUSTOM_START + 103,
4841 EL_CUSTOM_START + 104,
4842 EL_CUSTOM_START + 105,
4843 EL_CUSTOM_START + 106,
4844 EL_CUSTOM_START + 107,
4846 EL_CUSTOM_START + 108,
4847 EL_CUSTOM_START + 109,
4848 EL_CUSTOM_START + 110,
4849 EL_CUSTOM_START + 111,
4851 EL_CUSTOM_START + 112,
4852 EL_CUSTOM_START + 113,
4853 EL_CUSTOM_START + 114,
4854 EL_CUSTOM_START + 115,
4856 EL_CUSTOM_START + 116,
4857 EL_CUSTOM_START + 117,
4858 EL_CUSTOM_START + 118,
4859 EL_CUSTOM_START + 119,
4861 EL_CUSTOM_START + 120,
4862 EL_CUSTOM_START + 121,
4863 EL_CUSTOM_START + 122,
4864 EL_CUSTOM_START + 123,
4866 EL_CUSTOM_START + 124,
4867 EL_CUSTOM_START + 125,
4868 EL_CUSTOM_START + 126,
4869 EL_CUSTOM_START + 127,
4871 EL_CUSTOM_START + 128,
4872 EL_CUSTOM_START + 129,
4873 EL_CUSTOM_START + 130,
4874 EL_CUSTOM_START + 131,
4876 EL_CUSTOM_START + 132,
4877 EL_CUSTOM_START + 133,
4878 EL_CUSTOM_START + 134,
4879 EL_CUSTOM_START + 135,
4881 EL_CUSTOM_START + 136,
4882 EL_CUSTOM_START + 137,
4883 EL_CUSTOM_START + 138,
4884 EL_CUSTOM_START + 139,
4886 EL_CUSTOM_START + 140,
4887 EL_CUSTOM_START + 141,
4888 EL_CUSTOM_START + 142,
4889 EL_CUSTOM_START + 143,
4891 EL_CUSTOM_START + 144,
4892 EL_CUSTOM_START + 145,
4893 EL_CUSTOM_START + 146,
4894 EL_CUSTOM_START + 147,
4896 EL_CUSTOM_START + 148,
4897 EL_CUSTOM_START + 149,
4898 EL_CUSTOM_START + 150,
4899 EL_CUSTOM_START + 151,
4901 EL_CUSTOM_START + 152,
4902 EL_CUSTOM_START + 153,
4903 EL_CUSTOM_START + 154,
4904 EL_CUSTOM_START + 155,
4906 EL_CUSTOM_START + 156,
4907 EL_CUSTOM_START + 157,
4908 EL_CUSTOM_START + 158,
4909 EL_CUSTOM_START + 159,
4911 EL_CUSTOM_START + 160,
4912 EL_CUSTOM_START + 161,
4913 EL_CUSTOM_START + 162,
4914 EL_CUSTOM_START + 163,
4916 EL_CUSTOM_START + 164,
4917 EL_CUSTOM_START + 165,
4918 EL_CUSTOM_START + 166,
4919 EL_CUSTOM_START + 167,
4921 EL_CUSTOM_START + 168,
4922 EL_CUSTOM_START + 169,
4923 EL_CUSTOM_START + 170,
4924 EL_CUSTOM_START + 171,
4926 EL_CUSTOM_START + 172,
4927 EL_CUSTOM_START + 173,
4928 EL_CUSTOM_START + 174,
4929 EL_CUSTOM_START + 175,
4931 EL_CUSTOM_START + 176,
4932 EL_CUSTOM_START + 177,
4933 EL_CUSTOM_START + 178,
4934 EL_CUSTOM_START + 179,
4936 EL_CUSTOM_START + 180,
4937 EL_CUSTOM_START + 181,
4938 EL_CUSTOM_START + 182,
4939 EL_CUSTOM_START + 183,
4941 EL_CUSTOM_START + 184,
4942 EL_CUSTOM_START + 185,
4943 EL_CUSTOM_START + 186,
4944 EL_CUSTOM_START + 187,
4946 EL_CUSTOM_START + 188,
4947 EL_CUSTOM_START + 189,
4948 EL_CUSTOM_START + 190,
4949 EL_CUSTOM_START + 191,
4951 EL_CUSTOM_START + 192,
4952 EL_CUSTOM_START + 193,
4953 EL_CUSTOM_START + 194,
4954 EL_CUSTOM_START + 195,
4956 EL_CUSTOM_START + 196,
4957 EL_CUSTOM_START + 197,
4958 EL_CUSTOM_START + 198,
4959 EL_CUSTOM_START + 199,
4961 EL_CUSTOM_START + 200,
4962 EL_CUSTOM_START + 201,
4963 EL_CUSTOM_START + 202,
4964 EL_CUSTOM_START + 203,
4966 EL_CUSTOM_START + 204,
4967 EL_CUSTOM_START + 205,
4968 EL_CUSTOM_START + 206,
4969 EL_CUSTOM_START + 207,
4971 EL_CUSTOM_START + 208,
4972 EL_CUSTOM_START + 209,
4973 EL_CUSTOM_START + 210,
4974 EL_CUSTOM_START + 211,
4976 EL_CUSTOM_START + 212,
4977 EL_CUSTOM_START + 213,
4978 EL_CUSTOM_START + 214,
4979 EL_CUSTOM_START + 215,
4981 EL_CUSTOM_START + 216,
4982 EL_CUSTOM_START + 217,
4983 EL_CUSTOM_START + 218,
4984 EL_CUSTOM_START + 219,
4986 EL_CUSTOM_START + 220,
4987 EL_CUSTOM_START + 221,
4988 EL_CUSTOM_START + 222,
4989 EL_CUSTOM_START + 223,
4991 EL_CUSTOM_START + 224,
4992 EL_CUSTOM_START + 225,
4993 EL_CUSTOM_START + 226,
4994 EL_CUSTOM_START + 227,
4996 EL_CUSTOM_START + 228,
4997 EL_CUSTOM_START + 229,
4998 EL_CUSTOM_START + 230,
4999 EL_CUSTOM_START + 231,
5001 EL_CUSTOM_START + 232,
5002 EL_CUSTOM_START + 233,
5003 EL_CUSTOM_START + 234,
5004 EL_CUSTOM_START + 235,
5006 EL_CUSTOM_START + 236,
5007 EL_CUSTOM_START + 237,
5008 EL_CUSTOM_START + 238,
5009 EL_CUSTOM_START + 239,
5011 EL_CUSTOM_START + 240,
5012 EL_CUSTOM_START + 241,
5013 EL_CUSTOM_START + 242,
5014 EL_CUSTOM_START + 243,
5016 EL_CUSTOM_START + 244,
5017 EL_CUSTOM_START + 245,
5018 EL_CUSTOM_START + 246,
5019 EL_CUSTOM_START + 247,
5021 EL_CUSTOM_START + 248,
5022 EL_CUSTOM_START + 249,
5023 EL_CUSTOM_START + 250,
5024 EL_CUSTOM_START + 251,
5026 EL_CUSTOM_START + 252,
5027 EL_CUSTOM_START + 253,
5028 EL_CUSTOM_START + 254,
5029 EL_CUSTOM_START + 255
5031 static int *editor_hl_custom_ptr = editor_hl_custom;
5032 static int *editor_el_custom_ptr = editor_el_custom;
5033 static int num_editor_hl_custom = SIZEOF_ARRAY_INT(editor_hl_custom);
5034 static int num_editor_el_custom = SIZEOF_ARRAY_INT(editor_el_custom);
5036 static int editor_hl_group[] =
5038 EL_INTERNAL_CASCADE_GE_ACTIVE,
5044 static int editor_el_group[] =
5058 EL_GROUP_START + 10,
5059 EL_GROUP_START + 11,
5061 EL_GROUP_START + 12,
5062 EL_GROUP_START + 13,
5063 EL_GROUP_START + 14,
5064 EL_GROUP_START + 15,
5066 EL_GROUP_START + 16,
5067 EL_GROUP_START + 17,
5068 EL_GROUP_START + 18,
5069 EL_GROUP_START + 19,
5071 EL_GROUP_START + 20,
5072 EL_GROUP_START + 21,
5073 EL_GROUP_START + 22,
5074 EL_GROUP_START + 23,
5076 EL_GROUP_START + 24,
5077 EL_GROUP_START + 25,
5078 EL_GROUP_START + 26,
5079 EL_GROUP_START + 27,
5081 EL_GROUP_START + 28,
5082 EL_GROUP_START + 29,
5083 EL_GROUP_START + 30,
5086 static int *editor_hl_group_ptr = editor_hl_group;
5087 static int *editor_el_group_ptr = editor_el_group;
5088 static int num_editor_hl_group = SIZEOF_ARRAY_INT(editor_hl_group);
5089 static int num_editor_el_group = SIZEOF_ARRAY_INT(editor_el_group);
5091 static int editor_hl_reference[] =
5093 EL_INTERNAL_CASCADE_REF_ACTIVE,
5099 static int editor_el_reference[] =
5103 EL_TRIGGER_CE_VALUE,
5104 EL_TRIGGER_CE_SCORE,
5108 EL_CURRENT_CE_VALUE,
5109 EL_CURRENT_CE_SCORE,
5131 static int *editor_hl_reference_ptr = editor_hl_reference;
5132 static int *editor_el_reference_ptr = editor_el_reference;
5133 static int num_editor_hl_reference = SIZEOF_ARRAY_INT(editor_hl_reference);
5134 static int num_editor_el_reference = SIZEOF_ARRAY_INT(editor_el_reference);
5136 static int editor_hl_user_defined[] =
5138 EL_INTERNAL_CASCADE_USER_ACTIVE,
5144 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
5145 static int *editor_el_user_defined_ptr = NULL;
5146 static int num_editor_hl_user_defined=SIZEOF_ARRAY_INT(editor_hl_user_defined);
5147 static int num_editor_el_user_defined = 0;
5149 static int editor_hl_dynamic[] =
5151 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
5157 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
5158 static int *editor_el_dynamic_ptr = NULL;
5159 static int num_editor_hl_dynamic = SIZEOF_ARRAY_INT(editor_hl_dynamic);
5160 static int num_editor_el_dynamic = 0;
5162 static int editor_hl_empty[] = { EL_EMPTY };
5163 static int *editor_el_empty = NULL; /* dynamically allocated */
5165 static int *editor_hl_empty_ptr = editor_hl_empty;
5166 static int *editor_el_empty_ptr = NULL;
5167 static int num_editor_hl_empty = 0;
5168 static int num_editor_el_empty = 0; /* dynamically determined, if needed */
5170 static boolean use_el_empty = FALSE;
5172 static int *editor_elements = NULL; /* dynamically allocated */
5173 static int num_editor_elements = 0; /* dynamically determined */
5175 static boolean setup_editor_cascade_never = FALSE;
5177 static boolean setup_editor_el_players = TRUE;
5178 static boolean setup_editor_el_boulderdash = TRUE;
5179 static boolean setup_editor_el_emerald_mine = TRUE;
5180 static boolean setup_editor_el_emerald_mine_club = TRUE;
5181 static boolean setup_editor_el_more = TRUE;
5182 static boolean setup_editor_el_sokoban = TRUE;
5183 static boolean setup_editor_el_supaplex = TRUE;
5184 static boolean setup_editor_el_diamond_caves = TRUE;
5185 static boolean setup_editor_el_dx_boulderdash = TRUE;
5186 static boolean setup_editor_el_mirror_magic = TRUE;
5187 static boolean setup_editor_el_deflektor = TRUE;
5188 static boolean setup_editor_el_chars = TRUE;
5189 static boolean setup_editor_el_steel_chars = TRUE;
5190 static boolean setup_editor_el_custom = TRUE;
5191 static boolean setup_editor_el_user_defined = TRUE;
5192 static boolean setup_editor_el_dynamic = TRUE;
5194 static int editor_hl_unused[] = { EL_EMPTY };
5195 static int *editor_hl_unused_ptr = editor_hl_unused;
5196 static int num_editor_hl_unused = 0;
5200 boolean *setup_value;
5201 boolean *setup_cascade_value;
5203 int **headline_list;
5204 int *headline_list_size;
5207 int *element_list_size;
5209 boolean last_setup_value;
5211 editor_elements_info[] =
5214 &setup_editor_el_players,
5215 &setup_editor_cascade_never,
5216 &editor_hl_unused_ptr, &num_editor_hl_unused,
5217 &editor_el_players_ptr, &num_editor_el_players
5220 &setup_editor_el_boulderdash,
5221 &setup.editor_cascade.el_bd,
5222 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
5223 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
5226 &setup_editor_el_emerald_mine,
5227 &setup.editor_cascade.el_em,
5228 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
5229 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
5232 &setup_editor_el_emerald_mine_club,
5233 &setup.editor_cascade.el_emc,
5234 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
5235 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
5238 &setup_editor_el_more,
5239 &setup.editor_cascade.el_rnd,
5240 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
5241 &editor_el_rnd_ptr, &num_editor_el_rnd
5244 &setup_editor_el_sokoban,
5245 &setup.editor_cascade.el_sb,
5246 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
5247 &editor_el_sokoban_ptr, &num_editor_el_sokoban
5250 &setup_editor_el_supaplex,
5251 &setup.editor_cascade.el_sp,
5252 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
5253 &editor_el_supaplex_ptr, &num_editor_el_supaplex
5256 &setup_editor_el_diamond_caves,
5257 &setup.editor_cascade.el_dc,
5258 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
5259 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
5262 &setup_editor_el_dx_boulderdash,
5263 &setup.editor_cascade.el_dx,
5264 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
5265 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
5268 &setup_editor_el_mirror_magic,
5269 &setup.editor_cascade.el_mm,
5270 &editor_hl_mirror_magic_ptr, &num_editor_hl_mirror_magic,
5271 &editor_el_mirror_magic_ptr, &num_editor_el_mirror_magic
5274 &setup_editor_el_deflektor,
5275 &setup.editor_cascade.el_df,
5276 &editor_hl_deflektor_ptr, &num_editor_hl_deflektor,
5277 &editor_el_deflektor_ptr, &num_editor_el_deflektor
5280 &setup_editor_el_chars,
5281 &setup.editor_cascade.el_chars,
5282 &editor_hl_chars_ptr, &num_editor_hl_chars,
5283 &editor_el_chars_ptr, &num_editor_el_chars
5286 &setup_editor_el_steel_chars,
5287 &setup.editor_cascade.el_steel_chars,
5288 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
5289 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
5292 &setup_editor_el_custom,
5293 &setup.editor_cascade.el_ce,
5294 &editor_hl_custom_ptr, &num_editor_hl_custom,
5295 &editor_el_custom_ptr, &num_editor_el_custom
5298 &setup_editor_el_custom,
5299 &setup.editor_cascade.el_ge,
5300 &editor_hl_group_ptr, &num_editor_hl_group,
5301 &editor_el_group_ptr, &num_editor_el_group
5304 &setup_editor_el_custom,
5305 &setup.editor_cascade.el_ref,
5306 &editor_hl_reference_ptr, &num_editor_hl_reference,
5307 &editor_el_reference_ptr, &num_editor_el_reference
5310 &setup_editor_el_user_defined,
5311 &setup.editor_cascade.el_user,
5312 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
5313 &editor_el_user_defined_ptr, &num_editor_el_user_defined
5316 &setup_editor_el_dynamic,
5317 &setup.editor_cascade.el_dynamic,
5318 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
5319 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
5324 &editor_hl_empty_ptr, &num_editor_hl_empty,
5325 &editor_el_empty_ptr, &num_editor_el_empty,
5337 -----------------------------------------------------------------------------
5339 -----------------------------------------------------------------------------
5342 static int getMaxInfoTextLength()
5344 return (SXSIZE / getFontWidth(INFOTEXT_FONT));
5347 static int getTextWidthForGadget(char *text)
5352 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
5355 static int getTextWidthForDrawingArea(char *text)
5360 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
5363 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
5365 return (gi->x + gi->width + getTextWidthForGadget(text));
5368 static char *getElementInfoText(int element)
5370 char *info_text = NULL;
5372 if (element < MAX_NUM_ELEMENTS)
5374 if (strlen(element_info[element].description) > 0)
5375 info_text = element_info[element].description;
5376 else if (element_info[element].custom_description != NULL)
5377 info_text = element_info[element].custom_description;
5378 else if (element_info[element].editor_description != NULL)
5379 info_text = element_info[element].editor_description;
5382 if (info_text == NULL)
5383 info_text = INFOTEXT_UNKNOWN_ELEMENT;
5388 static char *getElementDescriptionFilenameExt(char *basename)
5390 char *elements_subdir = "elements";
5391 static char *elements_subdir2 = NULL;
5392 static char *filename = NULL;
5394 if (elements_subdir2 == NULL)
5395 elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
5397 checked_free(filename);
5399 /* 1st try: look for element description in current level set directory */
5400 filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
5401 if (fileExists(filename))
5406 /* 2nd try: look for element description in the game's base directory */
5407 filename = getPath3(options.docs_directory, elements_subdir, basename);
5408 if (fileExists(filename))
5414 char *getElementDescriptionFilename(int element)
5416 char basename[MAX_FILENAME_LEN];
5419 /* 1st try: look for element description file for exactly this element */
5420 sprintf(basename, "%s.txt", element_info[element].token_name);
5421 filename = getElementDescriptionFilenameExt(basename);
5422 if (filename != NULL)
5425 /* 2nd try: look for element description file for this element's class */
5426 sprintf(basename, "%s.txt", element_info[element].class_name);
5427 filename = getElementDescriptionFilenameExt(basename);
5428 if (filename != NULL)
5434 static void InitDynamicEditorElementList(int **elements, int *num_elements)
5436 boolean element_found[NUM_FILE_ELEMENTS];
5439 /* initialize list of used elements to "not used" */
5440 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5441 element_found[i] = FALSE;
5443 /* find all elements used in current level */
5444 for (y = 0; y < lev_fieldy; y++)
5445 for (x = 0; x < lev_fieldx; x++)
5446 if (Feld[x][y] < NUM_FILE_ELEMENTS) /* should always be true */
5447 element_found[Feld[x][y]] = TRUE;
5451 /* count number of elements used in current level */
5452 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5453 if (element_found[i])
5456 /* add space for up to 3 more elements for padding that may be needed */
5459 /* free memory for old list of elements, if needed */
5460 checked_free(*elements);
5462 /* allocate memory for new list of elements */
5463 *elements = checked_malloc(*num_elements * sizeof(int));
5467 /* add all elements used in current level (non-custom/group elements) */
5468 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5469 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
5470 (*elements)[(*num_elements)++] = i;
5472 /* add all elements used in current level (custom/group elements) */
5473 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5474 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
5475 (*elements)[(*num_elements)++] = i;
5477 while (*num_elements % 4) /* pad with empty elements, if needed */
5478 (*elements)[(*num_elements)++] = EL_EMPTY;
5481 static void ReinitializeElementList_EnableSections()
5483 /* default: enable all element sections */
5485 setup_editor_el_players = TRUE;
5486 setup_editor_el_boulderdash = TRUE;
5487 setup_editor_el_emerald_mine = TRUE;
5488 setup_editor_el_emerald_mine_club = TRUE;
5489 setup_editor_el_more = TRUE;
5490 setup_editor_el_sokoban = TRUE;
5491 setup_editor_el_supaplex = TRUE;
5492 setup_editor_el_diamond_caves = TRUE;
5493 setup_editor_el_dx_boulderdash = TRUE;
5494 setup_editor_el_mirror_magic = TRUE;
5495 setup_editor_el_deflektor = TRUE;
5496 setup_editor_el_chars = TRUE;
5497 setup_editor_el_steel_chars = TRUE;
5499 setup_editor_el_custom = TRUE;
5500 setup_editor_el_user_defined = TRUE;
5501 setup_editor_el_dynamic = TRUE;
5503 /* now disable all element sections not to be displayed */
5505 if (!setup.editor.el_classic)
5507 setup_editor_el_players = FALSE;
5508 setup_editor_el_boulderdash = FALSE;
5509 setup_editor_el_emerald_mine = FALSE;
5510 setup_editor_el_emerald_mine_club = FALSE;
5511 setup_editor_el_more = FALSE;
5512 setup_editor_el_sokoban = FALSE;
5513 setup_editor_el_supaplex = FALSE;
5514 setup_editor_el_diamond_caves = FALSE;
5515 setup_editor_el_dx_boulderdash = FALSE;
5516 setup_editor_el_mirror_magic = FALSE;
5517 setup_editor_el_deflektor = FALSE;
5518 setup_editor_el_chars = FALSE;
5519 setup_editor_el_steel_chars = FALSE;
5522 if (!setup.editor.el_custom)
5524 setup_editor_el_custom = FALSE;
5527 if (!setup.editor.el_user_defined)
5529 setup_editor_el_user_defined = FALSE;
5532 if (!setup.editor.el_dynamic)
5534 setup_editor_el_dynamic = FALSE;
5537 if (level.game_engine_type == GAME_ENGINE_TYPE_RND)
5539 setup_editor_el_mirror_magic = FALSE;
5540 setup_editor_el_deflektor = FALSE;
5542 else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
5544 setup_editor_el_boulderdash = FALSE;
5545 setup_editor_el_more = FALSE;
5546 setup_editor_el_sokoban = FALSE;
5547 setup_editor_el_supaplex = FALSE;
5548 setup_editor_el_diamond_caves = FALSE;
5549 setup_editor_el_dx_boulderdash = FALSE;
5550 setup_editor_el_mirror_magic = FALSE;
5551 setup_editor_el_deflektor = FALSE;
5552 setup_editor_el_steel_chars = FALSE;
5554 setup_editor_el_custom = FALSE;
5556 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
5558 setup_editor_el_players = FALSE;
5559 setup_editor_el_boulderdash = FALSE;
5560 setup_editor_el_emerald_mine = FALSE;
5561 setup_editor_el_emerald_mine_club = FALSE;
5562 setup_editor_el_more = FALSE;
5563 setup_editor_el_sokoban = FALSE;
5564 setup_editor_el_diamond_caves = FALSE;
5565 setup_editor_el_dx_boulderdash = FALSE;
5566 setup_editor_el_mirror_magic = FALSE;
5567 setup_editor_el_deflektor = FALSE;
5568 setup_editor_el_chars = FALSE;
5569 setup_editor_el_steel_chars = FALSE;
5571 setup_editor_el_custom = FALSE;
5573 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
5575 setup_editor_el_players = FALSE;
5576 setup_editor_el_boulderdash = FALSE;
5577 setup_editor_el_emerald_mine = FALSE;
5578 setup_editor_el_emerald_mine_club = FALSE;
5579 setup_editor_el_more = FALSE;
5580 setup_editor_el_sokoban = FALSE;
5581 setup_editor_el_supaplex = FALSE;
5582 setup_editor_el_diamond_caves = FALSE;
5583 setup_editor_el_dx_boulderdash = FALSE;
5584 setup_editor_el_steel_chars = FALSE;
5586 setup_editor_el_custom = FALSE;
5590 static void ReinitializeElementList()
5592 static boolean initialization_needed = TRUE;
5596 ReinitializeElementList_EnableSections();
5598 if (initialization_needed)
5600 LoadSetup_EditorCascade(); /* load last editor cascade state */
5602 /* initialize editor cascade element from saved cascade state */
5603 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5605 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
5606 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
5608 if (IS_EDITOR_CASCADE(*cascade_element))
5610 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
5611 EL_CASCADE_INACTIVE(*cascade_element));
5614 initialization_needed = FALSE;
5617 checked_free(editor_elements);
5619 /* reload optional user defined element list for each invocation of editor */
5620 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
5621 &num_editor_el_user_defined);
5623 /* initialize dynamic level element list for each invocation of editor */
5624 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
5625 &num_editor_el_dynamic);
5627 /* initialize list of empty elements (used for padding, if needed) */
5628 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
5629 editor_el_empty[i] = EL_EMPTY;
5631 /* do some sanity checks for each element from element list */
5632 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5634 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
5636 int element = (*editor_elements_info[i].element_list)[j];
5638 if (element >= NUM_FILE_ELEMENTS)
5639 Error(ERR_WARN, "editor element %d is runtime element", element);
5641 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
5642 Error(ERR_WARN, "no element description text for element %d", element);
5646 num_editor_elements = 0;
5647 use_el_empty = FALSE;
5649 /* determine size of element list */
5650 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5652 boolean found_inactive_cascade = FALSE;
5654 if (*editor_elements_info[i].setup_value)
5656 if (setup.editor.el_headlines)
5658 // required for correct padding of palette headline buttons
5659 if (*editor_elements_info[i].headline_list_size > 0)
5660 num_editor_elements += editor.palette.cols;
5662 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
5664 int element = (*editor_elements_info[i].headline_list)[j];
5666 if (IS_EDITOR_CASCADE_INACTIVE(element))
5667 found_inactive_cascade = TRUE;
5671 if (found_inactive_cascade)
5674 // required for correct padding of palette element buttons
5675 int element_list_size = *editor_elements_info[i].element_list_size;
5677 (element_list_size + editor.palette.cols - 1) / editor.palette.cols;
5678 int element_buttons = editor.palette.cols * element_rows;
5680 num_editor_elements += element_buttons;
5684 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
5686 /* offer at least as many elements as element buttons exist */
5687 use_el_empty = TRUE;
5688 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
5690 num_editor_elements += num_editor_el_empty;
5693 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
5695 /* fill element list */
5696 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5698 boolean found_inactive_cascade = FALSE;
5700 if (*editor_elements_info[i].setup_value)
5702 if (setup.editor.el_headlines)
5704 // required for correct padding of palette headline buttons
5705 int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
5706 editor.palette.cols : 0);
5708 for (j = 0; j < headline_size; j++)
5710 // use empty elements for padding of palette headline buttons
5711 int element = (j < *editor_elements_info[i].headline_list_size ?
5712 (*editor_elements_info[i].headline_list)[j] :
5713 editor_el_empty[0]);
5715 editor_elements[pos++] = element;
5717 if (IS_EDITOR_CASCADE_INACTIVE(element))
5718 found_inactive_cascade = TRUE;
5722 if (found_inactive_cascade)
5725 // required for correct padding of palette element buttons
5726 int element_list_size = *editor_elements_info[i].element_list_size;
5728 (element_list_size + editor.palette.cols - 1) / editor.palette.cols;
5729 int element_buttons = editor.palette.cols * element_rows;
5731 // copy all elements from element list
5732 for (j = 0; j < element_list_size; j++)
5733 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
5735 // use empty elements for padding of palette element buttons
5736 for (j = 0; j < element_buttons - element_list_size; j++)
5737 editor_elements[pos++] = editor_el_empty[0];
5741 /* (this function is also called before editor gadgets are initialized!) */
5742 AdjustElementListScrollbar();
5745 void PrintEditorElementList()
5747 boolean *stop = &setup_editor_el_user_defined;
5750 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
5752 int cascade_element = (*editor_elements_info[i].headline_list)[0];
5754 if (IS_EDITOR_CASCADE(cascade_element))
5756 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
5757 char *headline = element_info[cascade_element_show].editor_description;
5759 PrintLineWithPrefix("# ", "-", 77);
5760 Print("# %s\n", headline);
5761 PrintLineWithPrefix("# ", "-", 77);
5764 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
5766 int element = (*editor_elements_info[i].headline_list)[j];
5768 if (IS_EDITOR_CASCADE(element))
5769 element = EL_CHAR_MINUS;
5771 Print("# %s\n", element_info[element].token_name);
5777 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
5779 int element = (*editor_elements_info[i].element_list)[j];
5781 Print("# %s\n", element_info[element].token_name);
5789 static void ReinitializeElementListButtons()
5791 static boolean last_setup_value_headlines = FALSE;
5792 static boolean initialization_needed = TRUE;
5795 if (!initialization_needed) /* check if editor element setup has changed */
5797 if (last_setup_value_headlines != setup.editor.el_headlines)
5798 initialization_needed = TRUE;
5800 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5801 if (editor_elements_info[i].last_setup_value !=
5802 *editor_elements_info[i].setup_value)
5803 initialization_needed = TRUE;
5806 if (!initialization_needed)
5809 FreeLevelEditorGadgets();
5810 CreateLevelEditorGadgets();
5812 /* store current setup values for next invocation of this function */
5813 last_setup_value_headlines = setup.editor.el_headlines;
5814 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5815 editor_elements_info[i].last_setup_value =
5816 *editor_elements_info[i].setup_value;
5818 initialization_needed = FALSE;
5821 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
5824 int border_graphic =
5825 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
5826 struct GraphicInfo *g = &graphic_info[border_graphic];
5827 Bitmap *src_bitmap = g->bitmap;
5828 int src_x = g->src_x;
5829 int src_y = g->src_y;
5830 int border_size = g->border_size;
5831 int border_xpos = g->width - border_size;
5832 int border_ypos = g->height - border_size;
5833 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
5836 BlitBitmap(src_bitmap, drawto, src_x, src_y,
5837 border_size, border_size,
5838 dest_x - border_size, dest_y - border_size);
5839 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y,
5840 border_size, border_size,
5841 dest_x + width, dest_y - border_size);
5842 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_ypos,
5843 border_size, border_size,
5844 dest_x - border_size, dest_y + height);
5845 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_ypos,
5846 border_size, border_size,
5847 dest_x + width, dest_y + height);
5849 for (i = 0; i < width / tilesize; i++)
5851 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y,
5852 tilesize, border_size,
5853 dest_x + i * tilesize, dest_y - border_size);
5854 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y + border_ypos,
5855 tilesize, border_size,
5856 dest_x + i * tilesize, dest_y + height);
5859 for (i = 0; i < height / tilesize; i++)
5861 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_size,
5862 border_size, tilesize,
5863 dest_x - border_size, dest_y + i * tilesize);
5864 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_size,
5865 border_size, tilesize,
5866 dest_x + width, dest_y + i * tilesize);
5869 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
5872 static void DrawEditorElement(int x, int y, int element)
5874 DrawSizedElement(x, y, element, ed_tilesize);
5877 static void DrawEditorElementThruMask(int x, int y, int element)
5879 DrawSizedElementThruMask(x, y, element, ed_tilesize);
5882 static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
5884 DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
5887 static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
5889 DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
5892 static void DrawDrawingArea(int id)
5894 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
5897 int *value = drawingarea_info[id].value;
5898 int area_xsize = drawingarea_info[id].area_xsize;
5899 int area_ysize = drawingarea_info[id].area_ysize;
5900 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
5902 for (x = 0; x < area_xsize; x++)
5903 for (y = 0; y < area_ysize; y++)
5904 DrawSizedGraphicExt(drawto,
5905 gi->x + x * tilesize,
5906 gi->y + y * tilesize,
5907 el2edimg(value[x * area_ysize + y]), 0, tilesize);
5910 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
5913 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
5914 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
5916 BlitBitmap(drawto, drawto,
5917 SX + (dx == -1 ? ed_tilesize : 0),
5918 SY + (dy == -1 ? ed_tilesize : 0),
5919 (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
5920 (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
5921 SX + (dx == +1 ? ed_tilesize : 0),
5922 SY + (dy == +1 ? ed_tilesize : 0));
5926 x = (dx == 1 ? 0 : ed_fieldx - 1);
5927 for (y = 0; y < ed_fieldy; y++)
5928 DrawEditorElementOrWall(x, y, from_x, from_y);
5932 y = (dy == 1 ? 0 : ed_fieldy - 1);
5933 for (x = 0; x < ed_fieldx; x++)
5934 DrawEditorElementOrWall(x, y, from_x, from_y);
5937 redraw_mask |= REDRAW_FIELD;
5941 void getEditorGraphicSource(int element, int tile_size, Bitmap **bitmap,
5944 getSizedGraphicSource(el2edimg(element), 0, tile_size, bitmap, x, y);
5947 static void CreateControlButtons()
5949 struct GadgetInfo *gi;
5952 /* create toolbox buttons */
5953 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
5955 int id = controlbutton_info[i].gadget_id;
5956 int type = controlbutton_info[i].gadget_type;
5957 int graphic = controlbutton_info[i].graphic;
5958 struct XYTileSize *pos = controlbutton_info[i].pos;
5959 struct GraphicInfo *gd = &graphic_info[graphic];
5960 Bitmap *deco_bitmap = NULL;
5961 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
5962 int tile_size = 0, deco_shift = 0;
5963 boolean deco_masked = FALSE;
5964 int gd_x1 = gd->src_x;
5965 int gd_y1 = gd->src_y;
5966 int gd_x2 = gd->src_x + gd->pressed_xoffset;
5967 int gd_y2 = gd->src_y + gd->pressed_yoffset;
5968 int gd_x1a = gd->src_x + gd->active_xoffset;
5969 int gd_y1a = gd->src_y + gd->active_yoffset;
5970 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
5971 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
5974 unsigned int event_mask;
5975 int radio_button_nr = RADIO_NR_NONE;
5976 boolean checked = FALSE;
5978 if (type == GD_TYPE_RADIO_BUTTON)
5980 event_mask = GD_EVENT_PRESSED;
5981 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
5983 if (id == drawing_function)
5988 if (id == GADGET_ID_WRAP_LEFT ||
5989 id == GADGET_ID_WRAP_RIGHT ||
5990 id == GADGET_ID_WRAP_UP ||
5991 id == GADGET_ID_WRAP_DOWN)
5992 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5994 event_mask = GD_EVENT_RELEASED;
5997 if (id == GADGET_ID_PROPERTIES ||
5998 id == GADGET_ID_PALETTE)
6003 else if (id == GADGET_ID_ELEMENT_LEFT ||
6004 id == GADGET_ID_ELEMENT_MIDDLE ||
6005 id == GADGET_ID_ELEMENT_RIGHT)
6010 int element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
6011 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
6012 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : EL_EMPTY);
6014 tile_size = BUTTON_TILE_SIZE(id == GADGET_ID_ELEMENT_LEFT ?
6015 editor.button.element_left.tile_size :
6016 id == GADGET_ID_ELEMENT_MIDDLE ?
6017 editor.button.element_middle.tile_size :
6018 id == GADGET_ID_ELEMENT_RIGHT ?
6019 editor.button.element_right.tile_size : 0);
6021 // make sure that decoration does not overlap gadget border
6022 tile_size = MIN(tile_size, MIN(gd->width, gd->height));
6024 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x,&deco_y);
6026 deco_xpos = (gd->width - tile_size) / 2;
6027 deco_ypos = (gd->height - tile_size) / 2;
6029 deco_masked = gd->draw_masked;
6037 gi = CreateGadget(GDI_CUSTOM_ID, id,
6038 GDI_CUSTOM_TYPE_ID, i,
6039 GDI_INFO_TEXT, controlbutton_info[i].infotext,
6042 GDI_WIDTH, gd->width,
6043 GDI_HEIGHT, gd->height,
6045 GDI_STATE, GD_BUTTON_UNPRESSED,
6046 GDI_RADIO_NR, radio_button_nr,
6047 GDI_CHECKED, checked,
6048 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6049 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6050 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6051 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
6052 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6053 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6054 GDI_DECORATION_SIZE, tile_size, tile_size,
6055 GDI_DECORATION_SHIFTING, deco_shift, deco_shift,
6056 GDI_DECORATION_MASKED, deco_masked,
6057 GDI_EVENT_MASK, event_mask,
6058 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6059 GDI_CALLBACK_ACTION, HandleControlButtons,
6063 Error(ERR_EXIT, "cannot create gadget");
6065 level_editor_gadget[id] = gi;
6068 /* these values are not constant, but can change at runtime */
6069 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
6070 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
6071 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
6072 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
6073 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
6074 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
6075 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
6076 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
6077 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].x = ED_SCROLL2_UP_XPOS;
6078 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y = ED_SCROLL2_UP_YPOS;
6079 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x = ED_SCROLL2_DOWN_XPOS;
6080 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y = ED_SCROLL2_DOWN_YPOS;
6082 /* create buttons for scrolling of drawing area and element list */
6083 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
6085 int id = scrollbutton_info[i].gadget_id;
6086 int graphic = scrollbutton_info[i].graphic;
6087 struct GraphicInfo *gd = &graphic_info[graphic];
6088 Bitmap *gd_bitmap = gd->bitmap;
6089 int gd_x1 = gd->src_x;
6090 int gd_y1 = gd->src_y;
6091 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6092 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6093 int width = gd->width;
6094 int height = gd->height;
6095 int x = scrollbutton_pos[i].x;
6096 int y = scrollbutton_pos[i].y;
6097 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6099 if (id == GADGET_ID_SCROLL_LIST_UP ||
6100 id == GADGET_ID_SCROLL_LIST_DOWN)
6111 gi = CreateGadget(GDI_CUSTOM_ID, id,
6112 GDI_CUSTOM_TYPE_ID, i,
6113 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6118 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6119 GDI_STATE, GD_BUTTON_UNPRESSED,
6120 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6121 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6122 GDI_EVENT_MASK, event_mask,
6123 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6124 GDI_CALLBACK_ACTION, HandleControlButtons,
6128 Error(ERR_EXIT, "cannot create gadget");
6130 level_editor_gadget[id] = gi;
6133 /* create buttons for element list */
6134 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6136 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
6137 int graphic = IMG_EDITOR_PALETTE_BUTTON;
6138 struct GraphicInfo *gd = &graphic_info[graphic];
6139 Bitmap *gd_bitmap = gd->bitmap;
6140 Bitmap *deco_bitmap;
6141 int deco_x, deco_y, deco_xpos, deco_ypos;
6142 int gd_x1 = gd->src_x;
6143 int gd_y1 = gd->src_y;
6144 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6145 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6146 int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
6147 int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
6148 int x = PX + ED_ELEMENTLIST_XPOS + xx * gd->width;
6149 int y = PY + ED_ELEMENTLIST_YPOS + yy * gd->height;
6150 int element = editor_elements[i];
6151 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
6152 unsigned int event_mask = GD_EVENT_RELEASED;
6154 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
6156 deco_xpos = (gd->width - tile_size) / 2;
6157 deco_ypos = (gd->height - tile_size) / 2;
6159 gi = CreateGadget(GDI_CUSTOM_ID, id,
6160 GDI_CUSTOM_TYPE_ID, i,
6161 GDI_INFO_TEXT, getElementInfoText(element),
6164 GDI_WIDTH, gd->width,
6165 GDI_HEIGHT, gd->height,
6166 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6167 GDI_STATE, GD_BUTTON_UNPRESSED,
6168 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6169 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6170 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6171 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6172 GDI_DECORATION_SIZE, tile_size, tile_size,
6173 GDI_DECORATION_SHIFTING, 1, 1,
6174 GDI_EVENT_MASK, event_mask,
6175 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6176 GDI_CALLBACK_ACTION, HandleControlButtons,
6180 Error(ERR_EXIT, "cannot create gadget");
6182 level_editor_gadget[id] = gi;
6186 static void CreateCounterButtons()
6188 int max_infotext_len = getMaxInfoTextLength();
6191 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
6194 int x = SX + ED_SETTINGS_X(counterbutton_info[i].x); /* down count button */
6195 int y = SY + ED_SETTINGS_Y(counterbutton_info[i].y);
6197 /* determine horizontal position to the right of specified gadget */
6198 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6199 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
6200 ED_GADGET_TEXT_DISTANCE);
6202 /* determine horizontal offset for leading text */
6203 if (counterbutton_info[i].text_left != NULL)
6204 x += getTextWidthForGadget(counterbutton_info[i].text_left);
6206 for (j = 0; j < 2; j++)
6208 struct GadgetInfo *gi;
6210 counterbutton_info[i].gadget_id_down :
6211 counterbutton_info[i].gadget_id_up);
6213 struct GraphicInfo *gd;
6214 int gd_x1, gd_x2, gd_y1, gd_y2;
6215 unsigned int event_mask;
6216 char infotext[max_infotext_len + 1];
6218 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6220 if (i == ED_COUNTER_ID_SELECT_LEVEL)
6223 IMG_GFX_EDITOR_BUTTON_PREV_LEVEL :
6224 IMG_GFX_EDITOR_BUTTON_NEXT_LEVEL);
6226 event_mask |= GD_EVENT_RELEASED;
6230 x = DX + editor.button.prev_level.x;
6231 y = DY + editor.button.prev_level.y;
6235 x = DX + editor.button.next_level.x;
6236 y = DY + editor.button.next_level.y;
6242 IMG_EDITOR_COUNTER_DOWN :
6243 IMG_EDITOR_COUNTER_UP);
6246 gd = &graphic_info[graphic];
6250 gd_x2 = gd->src_x + gd->pressed_xoffset;
6251 gd_y2 = gd->src_y + gd->pressed_yoffset;
6253 sprintf(infotext, "%s counter value by 1, 5 or 10",
6254 (j == 0 ? "decrease" : "increase"));
6256 gi = CreateGadget(GDI_CUSTOM_ID, id,
6257 GDI_CUSTOM_TYPE_ID, i,
6258 GDI_INFO_TEXT, infotext,
6261 GDI_WIDTH, gd->width,
6262 GDI_HEIGHT, gd->height,
6263 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6264 GDI_STATE, GD_BUTTON_UNPRESSED,
6265 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6266 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6267 GDI_EVENT_MASK, event_mask,
6268 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6269 GDI_CALLBACK_ACTION, HandleCounterButtons,
6273 Error(ERR_EXIT, "cannot create gadget");
6275 level_editor_gadget[id] = gi;
6276 right_gadget_border[id] =
6277 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
6279 x += gi->width + ED_GADGET_SMALL_DISTANCE; /* text count button */
6283 int font_type = FONT_INPUT_1;
6284 int font_type_active = FONT_INPUT_1_ACTIVE;
6286 id = counterbutton_info[i].gadget_id_text;
6288 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6290 if (i == ED_COUNTER_ID_SELECT_LEVEL)
6292 graphic = IMG_GFX_EDITOR_INPUT_LEVEL_NUMBER;
6294 font_type = FONT_LEVEL_NUMBER;
6295 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
6297 x = DX + editor.input.level_number.x;
6298 y = DY + editor.input.level_number.y;
6302 graphic = IMG_EDITOR_COUNTER_INPUT;
6305 gd = &graphic_info[graphic];
6309 gd_x2 = gd->src_x + gd->active_xoffset;
6310 gd_y2 = gd->src_y + gd->active_yoffset;
6312 gi = CreateGadget(GDI_CUSTOM_ID, id,
6313 GDI_CUSTOM_TYPE_ID, i,
6314 GDI_INFO_TEXT, "enter counter value",
6317 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
6318 GDI_NUMBER_VALUE, 0,
6319 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
6320 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
6321 GDI_TEXT_SIZE, 3, /* minimal counter text size */
6322 GDI_TEXT_FONT, font_type,
6323 GDI_TEXT_FONT_ACTIVE, font_type_active,
6324 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6325 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6326 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6327 GDI_DESIGN_WIDTH, gd->width,
6328 GDI_EVENT_MASK, event_mask,
6329 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6330 GDI_CALLBACK_ACTION, HandleCounterButtons,
6334 Error(ERR_EXIT, "cannot create gadget");
6336 level_editor_gadget[id] = gi;
6337 right_gadget_border[id] =
6338 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
6340 x += gi->width + ED_GADGET_SMALL_DISTANCE; /* up count button */
6346 static void CreateDrawingAreas()
6350 /* these values are not constant, but can change at runtime */
6351 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
6352 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
6354 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
6356 struct GadgetInfo *gi;
6357 unsigned int event_mask;
6358 int id = drawingarea_info[i].gadget_id;
6359 int x = SX + ED_AREA_SETTINGS_X(drawingarea_info[i]);
6360 int y = SY + ED_AREA_SETTINGS_Y(drawingarea_info[i]);
6361 int area_xsize = drawingarea_info[i].area_xsize;
6362 int area_ysize = drawingarea_info[i].area_ysize;
6363 int item_size = (id == GADGET_ID_DRAWING_LEVEL ?
6364 ed_tilesize : ED_DRAWINGAREA_TILE_SIZE);
6367 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
6368 GD_EVENT_OFF_BORDERS | GD_EVENT_PIXEL_PRECISE;
6370 /* determine horizontal position to the right of specified gadget */
6371 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
6372 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
6373 ED_DRAWINGAREA_TEXT_DISTANCE);
6375 /* determine horizontal offset for leading text */
6376 if (drawingarea_info[i].text_left != NULL)
6377 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
6379 gi = CreateGadget(GDI_CUSTOM_ID, id,
6380 GDI_CUSTOM_TYPE_ID, i,
6383 GDI_TYPE, GD_TYPE_DRAWING_AREA,
6384 GDI_AREA_SIZE, area_xsize, area_ysize,
6385 GDI_ITEM_SIZE, item_size, item_size,
6386 GDI_EVENT_MASK, event_mask,
6387 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
6388 GDI_CALLBACK_ACTION, HandleDrawingAreas,
6392 Error(ERR_EXIT, "cannot create gadget");
6394 level_editor_gadget[id] = gi;
6395 right_gadget_border[id] =
6396 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
6400 static void CreateTextInputGadgets()
6402 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
6403 int max_infotext_len = getMaxInfoTextLength();
6406 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
6408 int gd_x1 = gd->src_x;
6409 int gd_y1 = gd->src_y;
6410 int gd_x2 = gd->src_x + gd->active_xoffset;
6411 int gd_y2 = gd->src_y + gd->active_yoffset;
6412 struct GadgetInfo *gi;
6413 unsigned int event_mask;
6414 char infotext[MAX_OUTPUT_LINESIZE + 1];
6415 int id = textinput_info[i].gadget_id;
6418 if (i == ED_TEXTINPUT_ID_ELEMENT_NAME)
6420 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
6421 int border_size = gd->border_size;
6422 int font_nr = FONT_INPUT_1;
6423 int font_height = getFontHeight(font_nr);
6424 int xoffset = element_border + TILEX + element_border + 3 * border_size;
6425 int yoffset = element_border + (TILEY - font_height) / 2;
6427 x = (editor.settings.element_name.x != -1 ?
6428 editor.settings.element_name.x :
6429 editor.settings.element_graphic.x + xoffset) - border_size;
6430 y = (editor.settings.element_name.y != -1 ?
6431 editor.settings.element_name.y :
6432 editor.settings.element_graphic.y + yoffset) - border_size;
6436 x = ED_SETTINGS_X(textinput_info[i].x);
6437 y = ED_SETTINGS_Y(textinput_info[i].y);
6440 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6442 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
6443 infotext[max_infotext_len] = '\0';
6445 gi = CreateGadget(GDI_CUSTOM_ID, id,
6446 GDI_CUSTOM_TYPE_ID, i,
6447 GDI_INFO_TEXT, infotext,
6450 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
6451 GDI_TEXT_VALUE, textinput_info[i].value,
6452 GDI_TEXT_SIZE, textinput_info[i].size,
6453 GDI_TEXT_FONT, FONT_INPUT_1,
6454 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6455 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6456 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6457 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6458 GDI_DESIGN_WIDTH, gd->width,
6459 GDI_EVENT_MASK, event_mask,
6460 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6461 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
6465 Error(ERR_EXIT, "cannot create gadget");
6467 level_editor_gadget[id] = gi;
6471 static void CreateTextAreaGadgets()
6473 int max_infotext_len = getMaxInfoTextLength();
6476 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
6478 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXTAREA];
6479 int gd_x1 = gd->src_x;
6480 int gd_y1 = gd->src_y;
6481 int gd_x2 = gd->src_x + gd->active_xoffset;
6482 int gd_y2 = gd->src_y + gd->active_yoffset;
6483 struct GadgetInfo *gi;
6484 unsigned int event_mask;
6485 char infotext[MAX_OUTPUT_LINESIZE + 1];
6486 int id = textarea_info[i].gadget_id;
6487 int area_xsize = textarea_info[i].xsize;
6488 int area_ysize = textarea_info[i].ysize;
6490 event_mask = GD_EVENT_TEXT_LEAVING;
6492 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
6493 infotext[max_infotext_len] = '\0';
6495 gi = CreateGadget(GDI_CUSTOM_ID, id,
6496 GDI_CUSTOM_TYPE_ID, i,
6497 GDI_INFO_TEXT, infotext,
6498 GDI_X, SX + ED_SETTINGS_X(textarea_info[i].x),
6499 GDI_Y, SY + ED_SETTINGS_Y(textarea_info[i].y),
6500 GDI_TYPE, GD_TYPE_TEXT_AREA,
6501 GDI_AREA_SIZE, area_xsize, area_ysize,
6502 GDI_TEXT_FONT, FONT_INPUT_1,
6503 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6504 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6505 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6506 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6507 GDI_DESIGN_WIDTH, gd->width,
6508 GDI_EVENT_MASK, event_mask,
6509 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6510 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
6514 Error(ERR_EXIT, "cannot create gadget");
6516 level_editor_gadget[id] = gi;
6520 static void CreateSelectboxGadgets()
6522 int max_infotext_len = getMaxInfoTextLength();
6525 for (i = 0; i < ED_NUM_SELECTBOX; i++)
6527 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_SELECTBOX_INPUT];
6528 struct GraphicInfo *gd2 = &graphic_info[IMG_EDITOR_SELECTBOX_BUTTON];
6529 int gd_x1 = gd->src_x;
6530 int gd_y1 = gd->src_y;
6531 int gd_x2 = gd->src_x + gd->active_xoffset;
6532 int gd_y2 = gd->src_y + gd->active_yoffset;
6533 int selectbox_button_xsize = gd2->width;
6534 struct GadgetInfo *gi;
6535 unsigned int event_mask;
6536 char infotext[MAX_OUTPUT_LINESIZE + 1];
6537 int id = selectbox_info[i].gadget_id;
6538 int x = SX + ED_SETTINGS_X(selectbox_info[i].x);
6539 int y = SY + ED_SETTINGS_Y(selectbox_info[i].y);
6541 if (selectbox_info[i].size == -1) /* dynamically determine size */
6543 /* (we cannot use -1 for uninitialized values if we directly compare
6544 with results from strlen(), because the '<' and '>' operation will
6545 implicitely cast -1 to an unsigned integer value!) */
6546 selectbox_info[i].size = 0;
6548 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
6549 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
6550 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
6552 selectbox_info[i].size++; /* add one character empty space */
6555 event_mask = GD_EVENT_RELEASED |
6556 GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6558 /* determine horizontal position to the right of specified gadget */
6559 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
6560 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
6561 ED_GADGET_TEXT_DISTANCE);
6563 /* determine horizontal offset for leading text */
6564 if (selectbox_info[i].text_left != NULL)
6565 x += getTextWidthForGadget(selectbox_info[i].text_left);
6567 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
6568 infotext[max_infotext_len] = '\0';
6570 gi = CreateGadget(GDI_CUSTOM_ID, id,
6571 GDI_CUSTOM_TYPE_ID, i,
6572 GDI_INFO_TEXT, infotext,
6575 GDI_TYPE, GD_TYPE_SELECTBOX,
6576 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
6577 GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
6578 GDI_TEXT_SIZE, selectbox_info[i].size,
6579 GDI_TEXT_FONT, FONT_INPUT_1,
6580 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6581 GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
6582 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6583 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6584 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6585 GDI_BORDER_SIZE_SELECTBUTTON, selectbox_button_xsize,
6586 GDI_DESIGN_WIDTH, gd->width,
6587 GDI_EVENT_MASK, event_mask,
6588 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6589 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
6593 Error(ERR_EXIT, "cannot create gadget");
6595 level_editor_gadget[id] = gi;
6596 right_gadget_border[id] =
6597 getRightGadgetBorder(gi, selectbox_info[i].text_right);
6601 static void CreateTextbuttonGadgets()
6603 int max_infotext_len = getMaxInfoTextLength();
6606 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
6608 int id = textbutton_info[i].gadget_id;
6610 ((id >= GADGET_ID_LEVELINFO_LEVEL && id <= GADGET_ID_LEVELINFO_EDITOR) ||
6611 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE));
6613 (is_tab_button ? IMG_EDITOR_TABBUTTON : IMG_EDITOR_TEXTBUTTON);
6614 int gadget_distance =
6615 (is_tab_button ? ED_GADGET_SMALL_DISTANCE : ED_GADGET_TEXT_DISTANCE);
6616 struct GraphicInfo *gd = &graphic_info[graphic];
6617 int gd_x1 = gd->src_x;
6618 int gd_y1 = gd->src_y;
6619 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6620 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6621 int gd_x1a = gd->src_x + gd->active_xoffset;
6622 int gd_y1a = gd->src_y + gd->active_yoffset;
6623 int border_xsize = gd->border_size + gd->draw_xoffset;
6624 int border_ysize = gd->border_size;
6625 struct GadgetInfo *gi;
6626 unsigned int event_mask;
6627 char infotext[MAX_OUTPUT_LINESIZE + 1];
6628 int x = SX + ED_SETTINGS_X(textbutton_info[i].x);
6629 int y = SY + ED_SETTINGS_Y(textbutton_info[i].y);
6631 if (textbutton_info[i].size == -1) /* dynamically determine size */
6632 textbutton_info[i].size = strlen(textbutton_info[i].text);
6634 event_mask = GD_EVENT_RELEASED;
6636 sprintf(infotext, "%s", textbutton_info[i].infotext);
6637 infotext[max_infotext_len] = '\0';
6639 /* determine horizontal position to the right of specified gadget */
6640 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6642 int gadget_id_align = textbutton_info[i].gadget_id_align;
6644 x = right_gadget_border[gadget_id_align] + gadget_distance;
6646 if (textbutton_info[i].y == -1)
6647 y = level_editor_gadget[gadget_id_align]->y;
6650 /* determine horizontal offset for leading text */
6651 if (textbutton_info[i].text_left != NULL)
6652 x += getTextWidthForGadget(textbutton_info[i].text_left);
6654 gi = CreateGadget(GDI_CUSTOM_ID, id,
6655 GDI_CUSTOM_TYPE_ID, i,
6656 GDI_INFO_TEXT, infotext,
6659 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
6660 GDI_TEXT_VALUE, textbutton_info[i].text,
6661 GDI_TEXT_SIZE, textbutton_info[i].size,
6662 GDI_TEXT_FONT, FONT_INPUT_2,
6663 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2_ACTIVE,
6664 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6665 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6666 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6667 GDI_BORDER_SIZE, border_xsize, border_ysize,
6668 GDI_DESIGN_WIDTH, gd->width,
6669 GDI_DECORATION_SHIFTING, 1, 1,
6670 GDI_EVENT_MASK, event_mask,
6671 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6672 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
6676 Error(ERR_EXIT, "cannot create gadget");
6678 level_editor_gadget[id] = gi;
6679 right_gadget_border[id] =
6680 getRightGadgetBorder(gi, textbutton_info[i].text_right);
6684 static void CreateGraphicbuttonGadgets()
6686 struct GadgetInfo *gi;
6687 unsigned int event_mask;
6690 /* create buttons for scrolling of drawing area and element list */
6691 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
6693 int id = graphicbutton_info[i].gadget_id;
6694 int x = SX + ED_SETTINGS_X(graphicbutton_info[i].x);
6695 int y = SY + ED_SETTINGS_Y(graphicbutton_info[i].y);
6696 struct GraphicInfo *gd = &graphic_info[graphicbutton_info[i].graphic];
6697 int gd_x1 = gd->src_x;
6698 int gd_y1 = gd->src_y;
6699 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6700 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6702 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6704 /* determine horizontal position to the right of specified gadget */
6705 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6706 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
6707 ED_GADGET_TEXT_DISTANCE);
6709 /* determine horizontal offset for leading text */
6710 if (graphicbutton_info[i].text_left != NULL)
6711 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
6713 gi = CreateGadget(GDI_CUSTOM_ID, id,
6714 GDI_CUSTOM_TYPE_ID, i,
6715 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
6718 GDI_WIDTH, gd->width,
6719 GDI_HEIGHT, gd->height,
6720 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6721 GDI_STATE, GD_BUTTON_UNPRESSED,
6722 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6723 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6724 GDI_EVENT_MASK, event_mask,
6725 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6726 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
6730 Error(ERR_EXIT, "cannot create gadget");
6732 level_editor_gadget[id] = gi;
6733 right_gadget_border[id] =
6734 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
6738 static void CreateScrollbarGadgets()
6742 /* these values are not constant, but can change at runtime */
6743 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
6744 SX + ED_SCROLL_HORIZONTAL_XPOS;
6745 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
6746 SY + ED_SCROLL_HORIZONTAL_YPOS;
6747 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
6748 ED_SCROLL_HORIZONTAL_XSIZE;
6749 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
6750 ED_SCROLL_HORIZONTAL_YSIZE;
6751 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
6752 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
6753 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
6754 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
6756 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
6757 SX + ED_SCROLL_VERTICAL_XPOS;
6758 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
6759 SY + ED_SCROLL_VERTICAL_YPOS;
6760 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
6761 ED_SCROLL_VERTICAL_XSIZE;
6762 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
6763 ED_SCROLL_VERTICAL_YSIZE;
6764 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
6765 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
6766 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
6767 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
6769 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
6770 PX + ED_SCROLL2_VERTICAL_XPOS;
6771 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
6772 PY + ED_SCROLL2_VERTICAL_YPOS;
6773 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
6774 ED_SCROLL2_VERTICAL_XSIZE;
6775 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
6776 ED_SCROLL2_VERTICAL_YSIZE;
6777 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = PX;
6778 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = PY;
6779 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width = PXSIZE;
6780 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = PYSIZE;
6782 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
6784 int id = scrollbar_info[i].gadget_id;
6785 int graphic = scrollbar_info[i].graphic;
6786 struct GraphicInfo *gd = &graphic_info[graphic];
6787 int gd_x1 = gd->src_x;
6788 int gd_y1 = gd->src_y;
6789 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6790 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6791 struct GadgetInfo *gi;
6792 int items_max, items_visible, item_position;
6793 unsigned int event_mask;
6795 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
6797 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
6798 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
6799 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
6801 else /* drawing area scrollbars */
6803 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
6805 items_max = MAX(lev_fieldx + 2, ed_fieldx);
6806 items_visible = ed_fieldx;
6811 items_max = MAX(lev_fieldy + 2, ed_fieldy);
6812 items_visible = ed_fieldy;
6817 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
6819 gi = CreateGadget(GDI_CUSTOM_ID, id,
6820 GDI_CUSTOM_TYPE_ID, i,
6821 GDI_INFO_TEXT, scrollbar_info[i].infotext,
6822 GDI_X, scrollbar_pos[i].x,
6823 GDI_Y, scrollbar_pos[i].y,
6824 GDI_WIDTH, scrollbar_pos[i].width,
6825 GDI_HEIGHT, scrollbar_pos[i].height,
6826 GDI_TYPE, scrollbar_info[i].type,
6827 GDI_SCROLLBAR_ITEMS_MAX, items_max,
6828 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
6829 GDI_SCROLLBAR_ITEM_POSITION, item_position,
6830 GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
6831 GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
6832 GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
6833 GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
6834 GDI_STATE, GD_BUTTON_UNPRESSED,
6835 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6836 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6837 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6838 GDI_EVENT_MASK, event_mask,
6839 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6840 GDI_CALLBACK_ACTION, HandleControlButtons,
6844 Error(ERR_EXIT, "cannot create gadget");
6846 level_editor_gadget[id] = gi;
6850 static void CreateCheckbuttonGadgets()
6852 struct GadgetInfo *gi;
6853 unsigned int event_mask;
6856 event_mask = GD_EVENT_PRESSED;
6858 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
6860 int id = checkbutton_info[i].gadget_id;
6861 int graphic = (id == GADGET_ID_STICK_ELEMENT ? IMG_EDITOR_STICKYBUTTON :
6862 IMG_EDITOR_CHECKBOX);
6863 struct GraphicInfo *gd = &graphic_info[graphic];
6864 int gd_x1 = gd->src_x;
6865 int gd_y1 = gd->src_y;
6866 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6867 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6868 int gd_x1a = gd->src_x + gd->active_xoffset;
6869 int gd_y1a = gd->src_y + gd->active_yoffset;
6870 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6871 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
6872 int x = SX + ED_SETTINGS_X(checkbutton_info[i].x);
6873 int y = SY + ED_SETTINGS_Y(checkbutton_info[i].y);
6875 /* determine horizontal position to the right of specified gadget */
6876 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6877 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
6878 ED_GADGET_TEXT_DISTANCE);
6880 /* determine horizontal offset for leading text */
6881 if (checkbutton_info[i].text_left != NULL)
6882 x += getTextWidthForGadget(checkbutton_info[i].text_left);
6884 gi = CreateGadget(GDI_CUSTOM_ID, id,
6885 GDI_CUSTOM_TYPE_ID, i,
6886 GDI_INFO_TEXT, checkbutton_info[i].infotext,
6889 GDI_WIDTH, gd->width,
6890 GDI_HEIGHT, gd->height,
6891 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
6892 GDI_CHECKED, *checkbutton_info[i].value,
6893 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6894 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6895 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6896 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
6897 GDI_EVENT_MASK, event_mask,
6898 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6899 GDI_CALLBACK_ACTION, HandleCheckbuttons,
6903 Error(ERR_EXIT, "cannot create gadget");
6905 level_editor_gadget[id] = gi;
6906 right_gadget_border[id] =
6907 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
6911 static void CreateRadiobuttonGadgets()
6913 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_RADIOBUTTON];
6914 int gd_x1 = gd->src_x;
6915 int gd_y1 = gd->src_y;
6916 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6917 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6918 int gd_x1a = gd->src_x + gd->active_xoffset;
6919 int gd_y1a = gd->src_y + gd->active_yoffset;
6920 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6921 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
6922 struct GadgetInfo *gi;
6923 unsigned int event_mask;
6926 event_mask = GD_EVENT_PRESSED;
6928 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
6930 int id = radiobutton_info[i].gadget_id;
6931 int x = SX + ED_SETTINGS_X(radiobutton_info[i].x);
6932 int y = SY + ED_SETTINGS_Y(radiobutton_info[i].y);
6935 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
6937 /* determine horizontal position to the right of specified gadget */
6938 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
6939 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
6940 ED_GADGET_TEXT_DISTANCE);
6942 /* determine horizontal offset for leading text */
6943 if (radiobutton_info[i].text_left != NULL)
6944 x += getTextWidthForGadget(radiobutton_info[i].text_left);
6946 gi = CreateGadget(GDI_CUSTOM_ID, id,
6947 GDI_CUSTOM_TYPE_ID, i,
6948 GDI_INFO_TEXT, radiobutton_info[i].infotext,
6951 GDI_WIDTH, gd->width,
6952 GDI_HEIGHT, gd->height,
6953 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
6954 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
6955 GDI_CHECKED, checked,
6956 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6957 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6958 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6959 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
6960 GDI_EVENT_MASK, event_mask,
6961 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6962 GDI_CALLBACK_ACTION, HandleRadiobuttons,
6966 Error(ERR_EXIT, "cannot create gadget");
6968 level_editor_gadget[id] = gi;
6969 right_gadget_border[id] =
6970 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
6974 void CreateLevelEditorGadgets()
6976 /* force EDITOR font inside level editor */
6977 SetFontStatus(GAME_MODE_EDITOR);
6979 /* these values are not constant, but can change at runtime */
6980 ed_fieldx = MAX_ED_FIELDX - 1;
6981 ed_fieldy = MAX_ED_FIELDY - 1;
6983 num_editor_gadgets = NUM_EDITOR_GADGETS;
6985 // printf("::: allocating %d gadgets ...\n", num_editor_gadgets);
6987 level_editor_gadget =
6988 checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *));
6989 right_gadget_border =
6990 checked_calloc(num_editor_gadgets * sizeof(int));
6992 editor_el_empty = checked_calloc(ED_NUM_ELEMENTLIST_BUTTONS * sizeof(int));
6993 editor_el_empty_ptr = editor_el_empty;
6995 use_permanent_palette = !editor.palette.show_as_separate_screen;
6997 ReinitializeElementList();
6999 CreateControlButtons();
7000 CreateScrollbarGadgets();
7002 /* order of function calls is important because of cross-references */
7003 CreateCheckbuttonGadgets();
7004 CreateCounterButtons();
7005 CreateRadiobuttonGadgets();
7006 CreateTextInputGadgets();
7007 CreateTextAreaGadgets();
7008 CreateSelectboxGadgets();
7009 CreateGraphicbuttonGadgets();
7010 CreateTextbuttonGadgets();
7011 CreateDrawingAreas();
7016 void FreeLevelEditorGadgets()
7020 // printf("::: freeing %d gadgets ...\n", num_editor_gadgets);
7022 for (i = 0; i < num_editor_gadgets; i++)
7024 FreeGadget(level_editor_gadget[i]);
7026 level_editor_gadget[i] = NULL;
7029 checked_free(level_editor_gadget);
7030 checked_free(right_gadget_border);
7032 checked_free(editor_el_empty);
7035 static void MapCounterButtons(int id)
7037 int font_nr = FONT_TEXT_1;
7038 int font_height = getFontHeight(font_nr);
7039 int gadget_id_down = counterbutton_info[id].gadget_id_down;
7040 int gadget_id_text = counterbutton_info[id].gadget_id_text;
7041 int gadget_id_up = counterbutton_info[id].gadget_id_up;
7042 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
7043 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
7044 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
7045 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
7046 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7047 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7048 int yoffset = (gi_down->height - font_height) / 2;
7049 int x_left = gi_down->x - xoffset_left;
7050 int x_right; /* set after gadget position was modified */
7051 int y_above = gi_down->y - yoffset_above;
7053 int y; /* set after gadget position was modified */
7055 /* counter limits must be changed first to prevent value truncation */
7056 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
7057 counterbutton_info[id].max_value);
7059 /* right text position might have changed after setting position above */
7060 x_right = gi_up->x + gi_up->width + xoffset_right;
7062 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
7064 /* set position for "value[1,2,3,4]" counter gadgets (score in most cases) */
7065 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
7066 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
7068 ModifyGadget(gi_down, GDI_Y,
7069 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7070 ModifyGadget(gi_text, GDI_Y,
7071 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7072 ModifyGadget(gi_up, GDI_Y,
7073 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7076 /* vertical position might have changed after setting position above */
7077 y = gi_up->y + yoffset;
7079 if (counterbutton_info[id].text_above)
7080 DrawText(x, y_above, counterbutton_info[id].text_above, font_nr);
7082 if (counterbutton_info[id].text_left)
7083 DrawText(x_left, y, counterbutton_info[id].text_left, font_nr);
7085 if (counterbutton_info[id].text_right)
7086 DrawText(x_right, y, counterbutton_info[id].text_right, font_nr);
7093 static void MapControlButtons()
7098 /* map toolbox buttons (excluding special CE toolbox buttons) */
7099 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
7100 MapGadget(level_editor_gadget[i]);
7102 /* map toolbox buttons (element properties buttons) */
7103 for (i = ED_NUM_CTRL1_4_BUTTONS; i < ED_NUM_CTRL1_7_BUTTONS; i++)
7104 MapGadget(level_editor_gadget[i]);
7106 if (use_permanent_palette)
7108 /* map buttons to select elements */
7109 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7110 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
7111 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
7112 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
7113 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
7116 /* map buttons to select level */
7117 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
7118 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
7119 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
7120 MapCounterButtons(counter_id);
7123 static void MapDrawingArea(int id)
7125 int font_nr = FONT_TEXT_1;
7126 int font_height = getFontHeight(font_nr);
7127 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
7128 int area_xsize = gi->drawing.area_xsize;
7129 int area_ysize = gi->drawing.area_ysize;
7130 int xoffset_left = getTextWidthForDrawingArea(drawingarea_info[id].text_left);
7131 int xoffset_below = getTextWidth(drawingarea_info[id].text_below, font_nr);
7132 int x_left = gi->x - xoffset_left;
7133 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
7134 int x_below = gi->x + (gi->width - xoffset_below) / 2;
7135 int y_side = gi->y + (gi->height - font_height) / 2;
7136 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
7138 if (drawingarea_info[id].text_left)
7139 DrawText(x_left, y_side, drawingarea_info[id].text_left, font_nr);
7141 if (drawingarea_info[id].text_right)
7142 DrawText(x_right, y_side, drawingarea_info[id].text_right, font_nr);
7144 if (drawingarea_info[id].text_below)
7145 DrawText(x_below, y_below, drawingarea_info[id].text_below, font_nr);
7147 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
7149 DrawElementBorder(gi->x, gi->y,
7150 area_xsize * ED_DRAWINGAREA_TILE_SIZE,
7151 area_ysize * ED_DRAWINGAREA_TILE_SIZE, TRUE);
7153 DrawDrawingArea(id);
7159 static void MapTextInputGadget(int id)
7161 int font_nr = FONT_TEXT_1;
7162 int font_height = getFontHeight(font_nr);
7163 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
7164 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7165 int x_above = ED_SETTINGS_X(textinput_info[id].x);
7166 int y_above = ED_SETTINGS_Y(textinput_info[id].y) - yoffset_above;
7168 if (textinput_info[id].text_above)
7169 DrawTextS(x_above, y_above, font_nr, textinput_info[id].text_above);
7171 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
7176 static void MapTextAreaGadget(int id)
7178 int font_nr = FONT_TEXT_1;
7179 int font_height = getFontHeight(font_nr);
7180 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
7181 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7182 int x_above = ED_SETTINGS_X(textarea_info[id].x);
7183 int y_above = ED_SETTINGS_Y(textarea_info[id].y) - yoffset_above;
7185 if (textarea_info[id].text_above)
7186 DrawTextS(x_above, y_above, font_nr, textarea_info[id].text_above);
7188 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
7193 static void MapSelectboxGadget(int id)
7195 int font_nr = FONT_TEXT_1;
7196 int font_height = getFontHeight(font_nr);
7197 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
7198 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
7199 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7200 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7201 int yoffset = (gi->height - font_height) / 2;
7202 int x_left = gi->x - xoffset_left;
7203 int x_right = gi->x + gi->width + xoffset_right;
7204 int y_above = gi->y - yoffset_above;
7206 int y = gi->y + yoffset;
7208 if (selectbox_info[id].text_above)
7209 DrawText(x, y_above, selectbox_info[id].text_above, font_nr);
7211 if (selectbox_info[id].text_left)
7212 DrawText(x_left, y, selectbox_info[id].text_left, font_nr);
7214 if (selectbox_info[id].text_right)
7215 DrawText(x_right, y, selectbox_info[id].text_right, font_nr);
7217 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
7222 static void MapTextbuttonGadget(int id)
7224 int font_nr = FONT_TEXT_1;
7225 int font_height = getFontHeight(font_nr);
7226 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
7227 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
7228 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7229 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7230 int yoffset = (gi->height - font_height) / 2;
7231 int x_left = gi->x - xoffset_left;
7232 int x_right = gi->x + gi->width + xoffset_right;
7233 int y_above = gi->y - yoffset_above;
7235 int y = gi->y + yoffset;
7237 /* only show button to delete change pages when more than minimum pages */
7238 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
7239 custom_element.num_change_pages == MIN_CHANGE_PAGES)
7242 if (textbutton_info[id].text_above)
7243 DrawText(x, y_above, textbutton_info[id].text_above, font_nr);
7245 if (textbutton_info[id].text_left)
7246 DrawText(x_left, y, textbutton_info[id].text_left, font_nr);
7248 if (textbutton_info[id].text_right)
7249 DrawText(x_right, y, textbutton_info[id].text_right, font_nr);
7254 static void MapGraphicbuttonGadget(int id)
7256 int font_nr = FONT_TEXT_1;
7257 int font_height = getFontHeight(font_nr);
7258 struct GadgetInfo *gi= level_editor_gadget[graphicbutton_info[id].gadget_id];
7259 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
7260 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7261 int yoffset = (gi->height - font_height) / 2;
7262 int x_left = gi->x - xoffset_left;
7263 int x_right = gi->x + gi->width + xoffset_right;
7264 int y = gi->y + yoffset;
7266 if (graphicbutton_info[id].text_left)
7267 DrawText(x_left, y, graphicbutton_info[id].text_left, font_nr);
7269 if (graphicbutton_info[id].text_right)
7270 DrawText(x_right, y, graphicbutton_info[id].text_right, font_nr);
7275 static void MapRadiobuttonGadget(int id)
7277 int font_nr = FONT_TEXT_1;
7278 int font_height = getFontHeight(font_nr);
7279 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
7280 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
7281 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7282 int yoffset = (gi->height - font_height) / 2;
7283 int x_left = gi->x - xoffset_left;
7284 int x_right = gi->x + gi->width + xoffset_right;
7285 int y = gi->y + yoffset;
7287 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
7289 if (radiobutton_info[id].text_left)
7290 DrawText(x_left, y, radiobutton_info[id].text_left, font_nr);
7292 if (radiobutton_info[id].text_right)
7293 DrawText(x_right, y, radiobutton_info[id].text_right, font_nr);
7295 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
7300 static void MapCheckbuttonGadget(int id)
7302 int font_nr = FONT_TEXT_1;
7303 int font_height = getFontHeight(font_nr);
7304 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
7305 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
7306 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7307 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7308 int yoffset = (gi->height - font_height) / 2;
7309 int y_above = gi->y - yoffset_above;
7311 int x_left, x_right, y; /* set after gadget position was modified */
7313 /* set position for gadgets with dynamically determined position */
7314 if (checkbutton_info[id].x != -1) /* do not change dynamic positions */
7315 ModifyGadget(gi, GDI_X, SX + ED_SETTINGS_X(checkbutton_info[id].x),GDI_END);
7316 ModifyGadget(gi, GDI_Y, SY + ED_SETTINGS_Y(checkbutton_info[id].y), GDI_END);
7318 x_left = gi->x - xoffset_left;
7319 x_right = gi->x + gi->width + xoffset_right;
7320 y = gi->y + yoffset;
7322 if (checkbutton_info[id].text_above)
7323 DrawText(x, y_above, checkbutton_info[id].text_above, font_nr);
7325 if (checkbutton_info[id].text_left)
7326 DrawText(x_left, y, checkbutton_info[id].text_left, font_nr);
7328 if (checkbutton_info[id].text_right)
7329 DrawText(x_right, y, checkbutton_info[id].text_right, font_nr);
7331 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
7336 static void MapMainDrawingArea()
7338 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
7339 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
7342 for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
7344 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
7345 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
7346 no_horizontal_scrollbar) ||
7347 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
7348 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
7349 no_vertical_scrollbar))
7352 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
7355 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
7357 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
7358 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
7361 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
7364 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
7367 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
7371 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
7373 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
7374 i == GADGET_ID_CUSTOM_COPY_TO ||
7375 i == GADGET_ID_CUSTOM_EXCHANGE ||
7376 i == GADGET_ID_CUSTOM_COPY ||
7377 i == GADGET_ID_CUSTOM_PASTE)
7380 MapGadget(level_editor_gadget[i]);
7382 UnmapGadget(level_editor_gadget[i]);
7387 static void MapLevelEditorToolboxCustomGadgets()
7389 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
7392 static void UnmapLevelEditorToolboxCustomGadgets()
7394 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
7397 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
7401 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
7403 if (i != GADGET_ID_SINGLE_ITEMS &&
7404 i != GADGET_ID_PICK_ELEMENT)
7406 struct GadgetInfo *gi = level_editor_gadget[i];
7414 int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
7415 struct GraphicInfo *gd = &graphic_info[graphic];
7419 BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
7420 gi->width, gi->height, gi->x, gi->y);
7422 redraw_mask |= REDRAW_DOOR_3;
7428 static void MapLevelEditorToolboxDrawingGadgets()
7430 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
7433 static void UnmapLevelEditorToolboxDrawingGadgets()
7435 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
7438 static void UnmapDrawingArea(int id)
7440 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
7443 static void UnmapLevelEditorFieldGadgets()
7447 for (i = 0; i < num_editor_gadgets; i++)
7448 if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
7449 level_editor_gadget[i]->y))
7450 UnmapGadget(level_editor_gadget[i]);
7453 void UnmapLevelEditorGadgets()
7457 for (i = 0; i < num_editor_gadgets; i++)
7458 UnmapGadget(level_editor_gadget[i]);
7461 static void ResetUndoBuffer()
7463 undo_buffer_position = -1;
7464 undo_buffer_steps = -1;
7465 redo_buffer_steps = 0;
7467 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7469 level.changed = FALSE;
7472 static void DrawEditModeWindow()
7474 ModifyEditorElementList();
7475 RedrawDrawingElements();
7477 if (edit_mode == ED_MODE_INFO)
7478 DrawLevelInfoWindow();
7479 else if (edit_mode == ED_MODE_PROPERTIES)
7480 DrawPropertiesWindow();
7481 else if (edit_mode == ED_MODE_PALETTE)
7482 DrawPaletteWindow();
7483 else /* edit_mode == ED_MODE_DRAWING */
7484 DrawDrawingWindow();
7487 static void ChangeEditModeWindow(int new_edit_mode)
7489 edit_mode = (new_edit_mode != edit_mode ? new_edit_mode : ED_MODE_DRAWING);
7491 DrawEditModeWindow();
7494 static boolean LevelChanged()
7496 boolean field_changed = FALSE;
7499 for (y = 0; y < lev_fieldy; y++)
7500 for (x = 0; x < lev_fieldx; x++)
7501 if (Feld[x][y] != level.field[x][y])
7502 field_changed = TRUE;
7504 return (level.changed || field_changed);
7507 static boolean PrepareSavingIntoPersonalLevelSet()
7509 static LevelDirTree *last_copied_leveldir = NULL;
7510 static LevelDirTree *last_written_leveldir = NULL;
7511 static int last_copied_level_nr = -1;
7512 static int last_written_level_nr = -1;
7513 LevelDirTree *leveldir_former = leveldir_current;
7514 int level_nr_former = level_nr;
7517 // remember last mod/save so that for current session, we write
7518 // back to the same personal copy, asking only about overwrite.
7519 if (leveldir_current == last_copied_leveldir &&
7520 level_nr == last_copied_level_nr)
7522 // "cd" to personal level set dir (as used when writing last copy)
7523 leveldir_current = last_written_leveldir;
7524 level_nr = last_written_level_nr;
7529 if (!Request("This level is read only! "
7530 "Save into personal level set?", REQ_ASK))
7533 // "cd" to personal level set dir (for writing copy the first time)
7535 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
7537 // find unused level number
7538 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
7540 static char *level_filename = NULL;
7542 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
7544 if (!fileExists(level_filename))
7548 last_copied_leveldir = leveldir_former;
7549 last_copied_level_nr = level_nr_former;
7551 last_written_leveldir = leveldir_current;
7552 last_written_level_nr = level_nr = new_level_nr;
7557 static void ModifyLevelInfoForSavingIntoPersonalLevelSet(char *former_name)
7559 static char *filename_levelinfo = NULL, *mod_name = NULL;
7562 // annotate this copy-and-mod in personal levelinfo.conf
7563 setString(&filename_levelinfo,
7564 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
7566 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
7568 fprintf(file, "\n");
7569 fprintf(file, "# level %d was modified from:\n", level_nr);
7570 fprintf(file, "# - previous level set name: %s\n",
7572 fprintf(file, "# - level within previous set: %d \"%s\"\n",
7573 level.file_info.nr, level.name);
7574 fprintf(file, "# - previous author: %s\n",
7576 fprintf(file, "# - previous save date: ");
7578 if (level.creation_date.src == DATE_SRC_LEVELFILE)
7580 fprintf(file, "%04d-%02d-%02d\n",
7581 level.creation_date.year,
7582 level.creation_date.month,
7583 level.creation_date.day);
7587 fprintf(file, "not recorded\n");
7593 if (level_nr > leveldir_current->last_level)
7594 UpdateUserLevelSet(getLoginName(), NULL, NULL, level_nr + 9, -1);
7596 // else: allow the save even if annotation failed
7598 // now... spray graffiti on the old level vital statistics
7599 // user can change these; just trying to set a good baseline
7601 // don't truncate names for fear of making offensive or silly:
7602 // long-named original author only recorded in levelinfo.conf.
7603 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
7604 if (!strEqual(level.author, leveldir_current->author))
7606 setString(&mod_name, getStringCat3(leveldir_current->author,
7607 " after ", level.author));
7609 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
7610 setString(&mod_name,
7611 getStringCat2(leveldir_current->author, " (ed.)"));
7613 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
7614 setString(&mod_name, leveldir_current->author);
7616 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
7618 // less worried about truncation here
7619 setString(&mod_name, getStringCat2("Mod: ", level.name));
7620 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
7624 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
7625 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
7629 for (x = 0; x < lev_fieldx; x++)
7630 for (y = 0; y < lev_fieldy; y++)
7631 dst[x][y] = src[x][y];
7634 static int setSelectboxValue(int selectbox_id, int new_value)
7636 int new_index_value = 0;
7639 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
7640 if (selectbox_info[selectbox_id].options[i].value == new_value)
7641 new_index_value = i;
7643 *selectbox_info[selectbox_id].value =
7644 selectbox_info[selectbox_id].options[new_index_value].value;
7646 return new_index_value;
7649 static void setSelectboxSpecialActionVariablesIfNeeded()
7653 /* change action mode and arg variables according to action type variable */
7654 for (i = 0; action_arg_options[i].value != -1; i++)
7656 if (action_arg_options[i].value == custom_element_change.action_type)
7658 int mode = action_arg_options[i].mode;
7660 /* only change if corresponding selectbox has changed */
7661 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
7662 action_arg_modes[mode])
7663 custom_element_change.action_mode = -1;
7665 /* only change if corresponding selectbox has changed */
7666 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
7667 action_arg_options[i].options)
7668 custom_element_change.action_arg = -1;
7675 static void setSelectboxSpecialActionOptions()
7679 /* change action mode and arg selectbox according to action type selectbox */
7680 for (i = 0; action_arg_options[i].value != -1; i++)
7682 if (action_arg_options[i].value == custom_element_change.action_type)
7684 int mode = action_arg_options[i].mode;
7686 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
7687 action_arg_modes[mode]);
7688 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
7689 custom_element_change.action_mode);
7691 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
7692 action_arg_options[i].options);
7693 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
7694 custom_element_change.action_arg);
7700 static void copy_custom_element_settings(int element_from, int element_to)
7702 struct ElementInfo *ei_from = &element_info[element_from];
7703 struct ElementInfo *ei_to = &element_info[element_to];
7705 copyElementInfo(ei_from, ei_to);
7708 static void replace_custom_element_in_settings(int element_from,
7713 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
7715 struct ElementInfo *ei = &element_info[i];
7717 for (y = 0; y < 3; y++)
7718 for (x = 0; x < 3; x++)
7719 if (ei->content.e[x][y] == element_from)
7720 ei->content.e[x][y] = element_to;
7722 for (j = 0; j < ei->num_change_pages; j++)
7724 struct ElementChangeInfo *change = &ei->change_page[j];
7726 if (change->target_element == element_from)
7727 change->target_element = element_to;
7729 if (change->initial_trigger_element == element_from)
7730 change->initial_trigger_element = element_to;
7732 if (change->action_element == element_from)
7733 change->action_element = element_to;
7735 for (y = 0; y < 3; y++)
7736 for (x = 0; x < 3; x++)
7737 if (change->target_content.e[x][y] == element_from)
7738 change->target_content.e[x][y] = element_to;
7741 if (ei->group != NULL) /* group or internal */
7742 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
7743 if (ei->group->element[j] == element_from)
7744 ei->group->element[j] = element_to;
7748 static void replace_custom_element_in_playfield(int element_from,
7753 for (x = 0; x < lev_fieldx; x++)
7754 for (y = 0; y < lev_fieldy; y++)
7755 if (Feld[x][y] == element_from)
7756 Feld[x][y] = element_to;
7759 static boolean CopyCustomElement(int element_old, int element_new,
7762 int copy_mode_orig = copy_mode;
7764 if (copy_mode == GADGET_ID_CUSTOM_COPY)
7766 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
7767 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
7768 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
7770 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
7772 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
7773 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
7774 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
7776 level.changed = TRUE;
7778 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
7780 Request("Please choose custom element!", REQ_CONFIRM);
7784 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
7786 Request("Please choose group element!", REQ_CONFIRM);
7792 level.changed = TRUE;
7795 /* when modifying custom/group element, ask for copying level template */
7796 if (copy_mode_orig != GADGET_ID_CUSTOM_COPY && level.use_custom_template)
7798 if (!AskToCopyAndModifyLevelTemplate())
7802 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
7804 copy_custom_element_settings(element_new, element_old);
7806 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
7808 copy_custom_element_settings(element_old, element_new);
7810 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
7812 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
7813 copy_custom_element_settings(element_new, element_old);
7814 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
7816 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
7817 replace_custom_element_in_settings(element_new, element_old);
7818 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
7820 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
7821 replace_custom_element_in_playfield(element_new, element_old);
7822 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
7825 UpdateCustomElementGraphicGadgets();
7826 DrawPropertiesWindow();
7831 static void CopyCustomElementPropertiesToEditor(int element)
7834 int current_change_page = element_info[element].current_change_page;
7836 /* dynamically (re)build selectbox for selecting change page */
7837 for (i = 0; i < element_info[element].num_change_pages; i++)
7839 sprintf(options_change_page_strings[i], "%d", i + 1);
7841 options_change_page[i].value = i;
7842 options_change_page[i].text = options_change_page_strings[i];
7845 options_change_page[i].value = -1;
7846 options_change_page[i].text = NULL;
7848 /* needed here to initialize combined element properties */
7849 InitElementPropertiesEngine(level.game_version);
7851 element_info[element].change =
7852 &element_info[element].change_page[current_change_page];
7854 custom_element = element_info[element];
7855 custom_element_change = *element_info[element].change;
7857 /* needed to initially set selectbox options for special action options */
7858 setSelectboxSpecialActionOptions();
7860 /* needed to initially set selectbox value variables to reliable defaults */
7861 for (i = 0; i < ED_NUM_SELECTBOX; i++)
7862 setSelectboxValue(i, *selectbox_info[i].value);
7864 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
7865 custom_element_properties[i] = HAS_PROPERTY(element, i);
7867 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
7868 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
7870 /* ---------- element settings: configure (custom elements) ------------- */
7872 /* set accessible layer selectbox help value */
7873 custom_element.access_type =
7874 (IS_WALKABLE(element) ? EP_WALKABLE :
7875 IS_PASSABLE(element) ? EP_PASSABLE :
7876 custom_element.access_type);
7877 custom_element.access_layer =
7878 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
7879 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
7880 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
7881 custom_element.access_layer);
7882 custom_element.access_protected =
7883 (IS_PROTECTED(element) ? 1 : 0);
7884 custom_element_properties[EP_ACCESSIBLE] =
7885 (IS_ACCESSIBLE_OVER(element) ||
7886 IS_ACCESSIBLE_INSIDE(element) ||
7887 IS_ACCESSIBLE_UNDER(element));
7889 /* set walk-to-object action selectbox help value */
7890 custom_element.walk_to_action =
7891 (IS_DIGGABLE(element) ? EP_DIGGABLE :
7892 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
7893 IS_DROPPABLE(element) ? EP_DROPPABLE :
7894 IS_THROWABLE(element) ? EP_THROWABLE :
7895 IS_PUSHABLE(element) ? EP_PUSHABLE :
7896 custom_element.walk_to_action);
7897 custom_element_properties[EP_WALK_TO_OBJECT] =
7898 (IS_DIGGABLE(element) ||
7899 IS_COLLECTIBLE_ONLY(element) ||
7900 IS_DROPPABLE(element) ||
7901 IS_THROWABLE(element) ||
7902 IS_PUSHABLE(element));
7904 /* set smash targets selectbox help value */
7905 custom_element.smash_targets =
7906 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
7907 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
7908 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
7909 custom_element.smash_targets);
7910 custom_element_properties[EP_CAN_SMASH] =
7911 (CAN_SMASH_EVERYTHING(element) ||
7912 CAN_SMASH_ENEMIES(element) ||
7913 CAN_SMASH_PLAYER(element));
7915 /* set deadliness selectbox help value */
7916 custom_element.deadliness =
7917 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
7918 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
7919 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
7920 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
7921 custom_element.deadliness);
7922 custom_element_properties[EP_DEADLY] =
7923 (DONT_TOUCH(element) ||
7924 DONT_GET_HIT_BY(element) ||
7925 DONT_COLLIDE_WITH(element) ||
7926 DONT_RUN_INTO(element));
7928 /* ---------- element settings: advanced (custom elements) --------------- */
7930 /* set "change by direct action" selectbox help value */
7931 custom_element_change.direct_action =
7932 (HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
7933 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
7934 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
7935 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
7936 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
7937 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
7938 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
7939 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
7940 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
7941 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
7942 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
7943 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
7944 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
7945 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
7946 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
7947 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
7948 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
7949 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
7950 custom_element_change.direct_action);
7952 /* set "change by other element action" selectbox help value */
7953 custom_element_change.other_action =
7954 (HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
7955 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
7956 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
7957 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
7958 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
7959 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
7960 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
7961 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
7962 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
7963 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
7964 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
7965 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
7966 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
7967 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
7968 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
7969 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
7970 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
7971 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
7972 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
7973 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
7974 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
7975 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
7976 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
7977 custom_element_change.other_action);
7980 static void CopyGroupElementPropertiesToEditor(int element)
7982 group_element_info = *element_info[element].group;
7983 custom_element = element_info[element]; /* needed for description */
7986 static void CopyClassicElementPropertiesToEditor(int element)
7988 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
7989 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
7990 getMoveIntoAcidProperty(&level, element);
7992 if (MAYBE_DONT_COLLIDE_WITH(element))
7993 custom_element_properties[EP_DONT_COLLIDE_WITH] =
7994 getDontCollideWithProperty(&level, element);
7997 static void CopyElementPropertiesToEditor(int element)
7999 if (IS_CUSTOM_ELEMENT(element))
8000 CopyCustomElementPropertiesToEditor(element);
8001 else if (IS_GROUP_ELEMENT(element))
8002 CopyGroupElementPropertiesToEditor(element);
8004 CopyClassicElementPropertiesToEditor(element);
8007 static boolean AskToCopyAndModifyLevelTemplate()
8009 if (Request("Copy and modify settings from level template?", REQ_ASK))
8011 level.use_custom_template = FALSE;
8013 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_1],
8014 GDI_CHECKED, FALSE, GDI_END);
8015 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_2],
8016 GDI_CHECKED, FALSE, GDI_END);
8022 LoadLevelTemplate(-1); /* this resets all element modifications ... */
8024 DrawEditModeWindow(); /* ... and copies them to 'custom_element' */
8030 static void CopyCustomElementPropertiesToGame(int element)
8033 int access_type_and_layer;
8035 /* mark that this custom element has been modified */
8036 custom_element.modified_settings = TRUE;
8037 level.changed = TRUE;
8039 if (level.use_custom_template)
8040 AskToCopyAndModifyLevelTemplate();
8042 element_info[element] = custom_element;
8043 *element_info[element].change = custom_element_change;
8045 /* ---------- element settings: configure (custom elements) ------------- */
8047 /* set accessible property from checkbox and selectbox */
8048 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
8049 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
8050 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
8051 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
8052 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
8053 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
8054 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
8055 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
8056 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
8057 custom_element_properties[access_type_and_layer] =
8058 custom_element_properties[EP_ACCESSIBLE];
8059 custom_element_properties[EP_PROTECTED] =
8060 (custom_element.access_protected != 0 &&
8061 custom_element_properties[EP_ACCESSIBLE]);
8063 /* set walk-to-object property from checkbox and selectbox */
8064 custom_element_properties[EP_DIGGABLE] = FALSE;
8065 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
8066 custom_element_properties[EP_DROPPABLE] = FALSE;
8067 custom_element_properties[EP_THROWABLE] = FALSE;
8068 custom_element_properties[EP_PUSHABLE] = FALSE;
8069 custom_element_properties[custom_element.walk_to_action] =
8070 custom_element_properties[EP_WALK_TO_OBJECT];
8072 /* set smash property from checkbox and selectbox */
8073 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
8074 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
8075 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
8076 custom_element_properties[custom_element.smash_targets] =
8077 custom_element_properties[EP_CAN_SMASH];
8079 /* set deadliness property from checkbox and selectbox */
8080 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
8081 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
8082 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
8083 custom_element_properties[EP_DONT_TOUCH] = FALSE;
8084 custom_element_properties[custom_element.deadliness] =
8085 custom_element_properties[EP_DEADLY];
8087 /* ---------- element settings: advanced (custom elements) --------------- */
8089 /* set player change event from checkbox and selectbox */
8090 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
8091 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
8092 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
8093 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
8094 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
8095 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
8096 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
8097 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
8098 custom_element_change_events[CE_SWITCHED] = FALSE;
8099 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
8100 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
8101 custom_element_change_events[CE_BLOCKED] = FALSE;
8102 custom_element_change_events[CE_IMPACT] = FALSE;
8103 custom_element_change_events[CE_SMASHED] = FALSE;
8104 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
8105 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
8106 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
8107 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
8108 custom_element_change_events[custom_element_change.direct_action] =
8109 custom_element_change_events[CE_BY_DIRECT_ACTION];
8111 /* set other element action change event from checkbox and selectbox */
8112 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
8113 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
8114 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
8115 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
8116 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
8117 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
8118 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
8119 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
8120 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
8121 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
8122 custom_element_change_events[CE_TOUCHING_X] = FALSE;
8123 custom_element_change_events[CE_HITTING_X] = FALSE;
8124 custom_element_change_events[CE_DIGGING_X] = FALSE;
8125 custom_element_change_events[CE_HIT_BY_X] = FALSE;
8126 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
8127 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
8128 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
8129 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
8130 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
8131 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
8132 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
8133 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
8134 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
8135 custom_element_change_events[custom_element_change.other_action] =
8136 custom_element_change_events[CE_BY_OTHER_ACTION];
8138 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8139 SET_PROPERTY(element, i, custom_element_properties[i]);
8141 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8142 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
8144 /* copy change events also to special level editor variable */
8145 custom_element = element_info[element];
8146 custom_element_change = *element_info[element].change;
8149 static void CopyGroupElementPropertiesToGame(int element)
8151 /* mark that this group element has been modified */
8152 custom_element.modified_settings = TRUE;
8153 level.changed = TRUE;
8155 if (level.use_custom_template)
8156 AskToCopyAndModifyLevelTemplate();
8158 element_info[element] = custom_element;
8159 *element_info[element].group = group_element_info;
8162 static void CopyClassicElementPropertiesToGame(int element)
8164 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
8165 setMoveIntoAcidProperty(&level, element,
8166 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
8168 if (MAYBE_DONT_COLLIDE_WITH(element))
8169 setDontCollideWithProperty(&level, element,
8170 custom_element_properties[EP_DONT_COLLIDE_WITH]);
8173 static void CopyElementPropertiesToGame(int element)
8175 if (IS_CUSTOM_ELEMENT(element))
8176 CopyCustomElementPropertiesToGame(element);
8177 else if (IS_GROUP_ELEMENT(element))
8178 CopyGroupElementPropertiesToGame(element);
8180 CopyClassicElementPropertiesToGame(element);
8183 void CheckElementDescriptions()
8187 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8188 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
8189 Error(ERR_WARN, "no element description file for element '%s'",
8193 static int getMaxEdFieldX(boolean has_scrollbar)
8195 int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
8196 int sxsize = SXSIZE - scrollbar_width;
8197 int max_ed_fieldx = sxsize / ed_tilesize;
8199 return max_ed_fieldx;
8202 static int getMaxEdFieldY(boolean has_scrollbar)
8204 int infotext_height = INFOTEXT_YSIZE_FULL;
8205 int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
8206 int sysize = SYSIZE - scrollbar_height - infotext_height;
8207 int max_ed_fieldy = sysize / ed_tilesize;
8209 return max_ed_fieldy;
8212 void InitZoomLevelSettings(int zoom_tilesize)
8214 if (zoom_tilesize == -1)
8215 zoom_tilesize = setup.auto_setup.editor_zoom_tilesize;
8217 // limit zoom tilesize by upper and lower bound
8218 zoom_tilesize = MIN(MAX(MICRO_TILESIZE, zoom_tilesize), TILESIZE);
8220 ed_tilesize = setup.auto_setup.editor_zoom_tilesize = zoom_tilesize;
8222 MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
8223 MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
8226 static void InitLevelSetInfo()
8228 snprintf(levelset_name, MAX_LEVEL_NAME_LEN + 1,
8229 "%s", leveldir_current->name);
8230 snprintf(levelset_author, MAX_LEVEL_AUTHOR_LEN + 1,
8231 "%s", leveldir_current->author);
8233 levelset_num_levels = leveldir_current->levels;
8234 levelset_first_level_nr = leveldir_current->first_level;
8236 levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
8239 static void ChangeEditorToLevelSet(char *levelset_subdir)
8241 leveldir_current = getTreeInfoFromIdentifier(leveldir_first, levelset_subdir);
8243 // the previous level set might have used custom artwork
8244 ReloadCustomArtwork(0);
8246 LoadLevelSetup_SeriesInfo();
8248 SaveLevelSetup_LastSeries();
8249 SaveLevelSetup_SeriesInfo();
8253 LoadLevel(level_nr);
8254 LoadScore(level_nr);
8261 int fade_mask = REDRAW_FIELD;
8263 FadeSoundsAndMusic();
8265 if (CheckIfGlobalBorderHasChanged())
8266 fade_mask = REDRAW_ALL;
8270 /* needed if different viewport properties defined for editor */
8271 ChangeViewportPropertiesIfNeeded();
8275 InitZoomLevelSettings(-1);
8278 OpenDoor(DOOR_OPEN_1 | DOOR_OPEN_2 | DOOR_NO_DELAY);
8281 CheckElementDescriptions();
8284 if (level_editor_test_game)
8286 CopyPlayfield(level.field, Feld);
8287 CopyPlayfield(FieldBackup, level.field);
8289 level_editor_test_game = FALSE;
8293 edit_mode = ED_MODE_DRAWING;
8294 edit_mode_levelinfo = ED_MODE_LEVELINFO_LEVEL;
8295 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
8303 /* needed for gadgets drawn on background (like palette scrollbar) */
8304 SetDoorBackgroundImage(IMG_UNDEFINED);
8306 /* copy default editor door content to main double buffer */
8307 BlitBitmap(graphic_info[IMG_BACKGROUND_PALETTE].bitmap, drawto,
8308 graphic_info[IMG_BACKGROUND_PALETTE].src_x,
8309 graphic_info[IMG_BACKGROUND_PALETTE].src_y,
8310 MIN(DXSIZE, graphic_info[IMG_BACKGROUND_PALETTE].width),
8311 MIN(DYSIZE, graphic_info[IMG_BACKGROUND_PALETTE].height),
8314 /* draw bigger door */
8315 DrawSpecialEditorDoor();
8317 /* draw new control window */
8318 BlitBitmap(graphic_info[IMG_BACKGROUND_TOOLBOX].bitmap, drawto,
8319 graphic_info[IMG_BACKGROUND_TOOLBOX].src_x,
8320 graphic_info[IMG_BACKGROUND_TOOLBOX].src_y,
8321 MIN(EXSIZE, graphic_info[IMG_BACKGROUND_TOOLBOX].width),
8322 MIN(EYSIZE, graphic_info[IMG_BACKGROUND_TOOLBOX].height),
8325 // redraw_mask |= REDRAW_ALL;
8327 FreeLevelEditorGadgets();
8328 CreateLevelEditorGadgets();
8330 ReinitializeElementList(); /* update dynamic level element list */
8331 ReinitializeElementListButtons(); /* custom element may look different */
8333 InitElementPropertiesGfxElement();
8336 MapControlButtons();
8338 DrawEditModeWindow();
8340 DrawMaskedBorder(fade_mask);
8344 /* copy actual editor door content to door double buffer for OpenDoor() */
8345 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
8348 static void AdjustDrawingAreaGadgets()
8350 int ed_xsize = lev_fieldx + 2;
8351 int ed_ysize = lev_fieldy + 2;
8352 int max_ed_fieldx = MAX_ED_FIELDX;
8353 int max_ed_fieldy = MAX_ED_FIELDY;
8354 boolean horizontal_scrollbar_needed;
8355 boolean vertical_scrollbar_needed;
8356 int x, y, width, height;
8358 /* check if we need any scrollbars */
8359 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
8360 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
8362 /* check if we have a smaller editor field because of scrollbars */
8363 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
8364 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
8366 /* check again if we now need more scrollbars because of less space */
8367 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
8368 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
8370 /* check if editor field gets even smaller after adding new scrollbars */
8371 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
8372 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
8374 ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
8375 ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
8377 x = SX + ed_fieldx * ed_tilesize;
8378 y = SY + ed_fieldy * ed_tilesize;
8380 width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
8381 height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
8383 /* adjust drawing area gadget */
8384 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
8385 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
8386 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
8389 /* adjust horizontal scrollbar gadgets */
8390 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
8393 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
8394 GDI_X, x - ED_SCROLLBUTTON_XSIZE,
8397 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
8400 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
8403 /* adjust vertical scrollbar gadgets */
8404 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
8407 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
8409 GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
8411 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
8414 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
8418 static void AdjustLevelScrollPosition()
8420 if (level_xpos < -1)
8422 if (level_xpos > lev_fieldx - ed_fieldx + 1)
8423 level_xpos = lev_fieldx - ed_fieldx + 1;
8424 if (lev_fieldx < ed_fieldx - 2)
8427 if (level_ypos < -1)
8429 if (level_ypos > lev_fieldy - ed_fieldy + 1)
8430 level_ypos = lev_fieldy - ed_fieldy + 1;
8431 if (lev_fieldy < ed_fieldy - 2)
8435 static void AdjustEditorScrollbar(int id)
8437 struct GadgetInfo *gi = level_editor_gadget[id];
8438 int items_max, items_visible, item_position;
8440 if (id == GADGET_ID_SCROLL_HORIZONTAL)
8442 items_max = MAX(lev_fieldx + 2, ed_fieldx);
8443 items_visible = ed_fieldx;
8444 item_position = level_xpos + 1;
8448 items_max = MAX(lev_fieldy + 2, ed_fieldy);
8449 items_visible = ed_fieldy;
8450 item_position = level_ypos + 1;
8453 if (item_position > items_max - items_visible)
8454 item_position = items_max - items_visible;
8456 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
8457 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
8460 static void AdjustElementListScrollbar()
8462 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
8463 int items_max, items_visible, item_position;
8465 /* correct position of element list scrollbar */
8466 if (element_shift < 0)
8468 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
8469 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
8471 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
8472 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
8473 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
8475 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
8476 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
8477 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
8480 static void ModifyEditorCounterValue(int counter_id, int new_value)
8482 int *counter_value = counterbutton_info[counter_id].value;
8483 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
8484 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8486 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
8488 if (counter_value != NULL)
8489 *counter_value = gi->textinput.number_value;
8492 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
8494 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
8495 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8497 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
8499 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
8500 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
8502 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
8503 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
8505 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
8506 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_SMALL_DISTANCE,
8511 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
8513 int gadget_id = selectbox_info[selectbox_id].gadget_id;
8514 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8515 int new_index_value = setSelectboxValue(selectbox_id, new_value);
8517 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
8520 static void ModifyEditorSelectboxOptions(int selectbox_id,
8521 struct ValueTextInfo *options)
8523 int gadget_id = selectbox_info[selectbox_id].gadget_id;
8524 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8526 selectbox_info[selectbox_id].options = options;
8528 /* set index to zero -- list may be shorter now (correct later, if needed) */
8529 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
8530 GDI_SELECTBOX_OPTIONS, options, GDI_END);
8533 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
8535 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
8536 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8538 drawingarea_info[drawingarea_id].area_xsize = xsize;
8539 drawingarea_info[drawingarea_id].area_ysize = ysize;
8541 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
8544 static void ModifyEditorElementList()
8548 if (!use_permanent_palette && edit_mode != ED_MODE_PALETTE)
8551 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
8553 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
8554 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8555 struct GadgetDesign *gd = &gi->deco.design;
8556 int element = editor_elements[element_shift + i];
8557 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
8561 getEditorGraphicSource(element, tile_size, &gd->bitmap, &gd->x, &gd->y);
8563 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
8569 static void DrawDrawingElementGraphic(int element, struct XYTileSize *pos)
8571 int graphic = el2edimg(element);
8572 int tile_size = BUTTON_TILE_SIZE(pos->tile_size);
8578 DrawSizedGraphicExt(drawto, DX + pos->x, DY + pos->y, graphic, 0, tile_size);
8581 static void ModifyDrawingElementButton(int element, int id)
8583 struct GadgetInfo *gi = level_editor_gadget[id];
8584 Bitmap *deco_bitmap;
8586 int tile_size = gi->deco.width;
8588 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
8590 ModifyGadget(gi, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_END);
8593 static void PickDrawingElement(int button, int element)
8598 struct XYTileSize *pos;
8600 } de, drawing_elements[] =
8602 { &new_element1, &editor.palette.element_left, GADGET_ID_ELEMENT_LEFT },
8603 { &new_element2, &editor.palette.element_middle, GADGET_ID_ELEMENT_MIDDLE },
8604 { &new_element3, &editor.palette.element_right, GADGET_ID_ELEMENT_RIGHT },
8607 if (button < 1 || button > 3)
8610 if (IS_MM_WALL(element))
8611 element = map_mm_wall_element(element);
8613 de = drawing_elements[button - 1];
8615 *de.new_element = element; // update global drawing element variable
8617 DrawDrawingElementGraphic(element, de.pos);
8618 ModifyDrawingElementButton(element, de.id);
8620 redraw_mask |= REDRAW_DOOR_1;
8623 static void RedrawDrawingElements()
8625 PickDrawingElement(1, new_element1);
8626 PickDrawingElement(2, new_element2);
8627 PickDrawingElement(3, new_element3);
8630 static void DrawDrawingWindow()
8632 stick_element_properties_window = FALSE;
8634 SetMainBackgroundImage(IMG_UNDEFINED);
8637 UnmapLevelEditorFieldGadgets();
8638 UnmapLevelEditorToolboxCustomGadgets();
8640 AdjustDrawingAreaGadgets();
8641 AdjustLevelScrollPosition();
8642 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
8643 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
8645 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8647 MapMainDrawingArea();
8648 MapLevelEditorToolboxDrawingGadgets();
8651 static int getTabulatorBarWidth()
8653 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
8654 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
8656 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
8659 static int getTabulatorBarHeight()
8661 return ED_TAB_BAR_HEIGHT;
8664 static void DrawLevelInfoTabulatorGadgets()
8666 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELINFO_LEVEL];
8667 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
8668 int gd_x = gd->x + gd_gi1->border.width / 2;
8669 int gd_y = gd->y + gd_gi1->height - 1;
8670 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
8671 int id_first = ED_TAB_BUTTON_ID_LEVELINFO_FIRST;
8672 int id_last = ED_TAB_BUTTON_ID_LEVELINFO_LAST;
8675 for (i = id_first; i <= id_last; i++)
8677 int gadget_id = textbutton_info[i].gadget_id;
8678 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8679 boolean active = (i != edit_mode_levelinfo);
8681 /* draw background line below tabulator button */
8682 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
8684 /* draw solid line below inactive tabulator buttons */
8685 if (!active && tab_color != BLACK_PIXEL) /* black => transparent */
8686 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
8687 ED_GADGET_TINY_DISTANCE, tab_color);
8689 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
8690 MapTextbuttonGadget(i);
8693 /* draw little border line below tabulator buttons */
8694 if (tab_color != BLACK_PIXEL) /* black => transparent */
8695 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
8696 ED_GADGET_TINY_DISTANCE,
8697 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
8700 static void DrawPropertiesTabulatorGadgets()
8702 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
8703 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
8704 int gd_x = gd->x + gd_gi1->border.width / 2;
8705 int gd_y = gd->y + gd_gi1->height - 1;
8706 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
8707 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
8708 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
8711 /* draw two config tabulators for player elements */
8712 if (ELEM_IS_PLAYER(properties_element))
8713 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
8715 /* draw two config and one "change" tabulator for custom elements */
8716 if (IS_CUSTOM_ELEMENT(properties_element))
8717 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
8719 for (i = id_first; i <= id_last; i++)
8721 int gadget_id = textbutton_info[i].gadget_id;
8722 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8723 boolean active = (i != edit_mode_properties);
8725 /* use "config 1" and "config 2" instead of "config" for players and CEs */
8726 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
8727 (ELEM_IS_PLAYER(properties_element) ||
8728 IS_CUSTOM_ELEMENT(properties_element)))
8731 /* draw background line below tabulator button */
8732 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
8734 /* draw solid line below inactive tabulator buttons */
8735 if (!active && tab_color != BLACK_PIXEL) /* black => transparent */
8736 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
8737 ED_GADGET_TINY_DISTANCE, tab_color);
8739 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
8740 MapTextbuttonGadget(i);
8743 /* draw little border line below tabulator buttons */
8744 if (tab_color != BLACK_PIXEL) /* black => transparent */
8745 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
8746 ED_GADGET_TINY_DISTANCE,
8747 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
8750 static void PrintInfoText(char *text, int font_nr, int xpos, int ypos)
8752 DrawText(SX + xpos, SY + ypos, text, font_nr);
8755 static int PrintElementDescriptionFromFile(char *filename, int font_nr,
8758 int font_width = getFontWidth(font_nr);
8759 int font_height = getFontHeight(font_nr);
8760 int max_chars_per_line = (SXSIZE - 2 * xpos) / font_width;
8761 int max_lines_drawable = (SYSIZE - ypos) / font_height - 1;
8763 return DrawTextFile(SX + xpos, SY + ypos, filename, font_nr,
8764 max_chars_per_line, -1, max_lines_drawable, 0, -1,
8765 TRUE, FALSE, FALSE);
8768 static void DrawLevelInfoLevel()
8772 /* draw counter gadgets */
8773 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
8774 MapCounterButtons(i);
8776 /* draw checkbutton gadgets */
8777 for (i = ED_CHECKBUTTON_ID_LEVEL_FIRST; i<= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
8778 MapCheckbuttonGadget(i);
8780 /* draw selectbox gadgets */
8781 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
8782 MapSelectboxGadget(i);
8784 /* draw text input gadgets */
8785 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
8786 MapTextInputGadget(i);
8789 static char *getLevelSubdirFromSaveMode(int save_mode)
8791 if (save_mode == LEVELSET_SAVE_MODE_CREATE)
8792 return getNewUserLevelSubdir();
8794 return leveldir_current->subdir;
8797 static void DrawLevelInfoLevelSet_DirectoryInfo()
8799 char *directory_text = "Level set directory:";
8800 char *directory_name = getLevelSubdirFromSaveMode(levelset_save_mode);
8801 int font1_nr = FONT_TEXT_1;
8802 int font2_nr = FONT_TEXT_2;
8803 int font1_height = getFontHeight(font1_nr);
8804 int yoffset_above = font1_height + ED_GADGET_LINE_DISTANCE;
8805 int x = ED_LEVEL_SETTINGS_X(0);
8806 int y = ED_LEVEL_SETTINGS_Y(6);
8808 PrintInfoText(directory_text, font1_nr, x, y - yoffset_above);
8809 PrintInfoText(directory_name, font2_nr, x, y);
8812 static void DrawLevelInfoLevelSet()
8816 /* draw counter gadgets */
8817 for (i = ED_COUNTER_ID_LEVELSET_FIRST; i <= ED_COUNTER_ID_LEVELSET_LAST; i++)
8818 MapCounterButtons(i);
8820 /* draw selectbox gadgets */
8821 for (i = ED_SELECTBOX_ID_LEVELSET_FIRST; i <= ED_SELECTBOX_ID_LEVELSET_LAST; i++)
8822 MapSelectboxGadget(i);
8824 /* draw text input gadgets */
8825 for (i = ED_TEXTINPUT_ID_LEVELSET_FIRST; i <= ED_TEXTINPUT_ID_LEVELSET_LAST; i++)
8826 MapTextInputGadget(i);
8828 /* draw textbutton gadgets */
8829 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_LEVELSET);
8831 /* draw info text */
8832 DrawLevelInfoLevelSet_DirectoryInfo();
8835 static void DrawLevelInfoEditor()
8839 /* draw counter gadgets */
8840 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
8841 MapCounterButtons(i);
8843 /* draw checkbutton gadgets */
8844 for (i=ED_CHECKBUTTON_ID_EDITOR_FIRST; i<= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
8845 MapCheckbuttonGadget(i);
8847 /* draw radiobutton gadgets */
8848 for (i=ED_RADIOBUTTON_ID_EDITOR_FIRST; i<= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
8849 MapRadiobuttonGadget(i);
8851 /* draw drawing area */
8852 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
8854 /* draw textbutton gadgets */
8855 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2);
8858 static void DrawLevelInfoWindow()
8860 char *text = "Global Settings";
8861 int font_nr = FONT_TITLE_1;
8862 struct MenuPosInfo *pos = &editor.settings.headline;
8863 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font_nr), pos->align);
8864 int sy = SY + pos->y;
8866 stick_element_properties_window = FALSE;
8868 SetAutomaticNumberOfGemsNeeded();
8870 UnmapLevelEditorFieldGadgets();
8872 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
8875 DrawText(sx, sy, text, font_nr);
8877 DrawLevelInfoTabulatorGadgets();
8879 if (edit_mode_levelinfo == ED_MODE_LEVELINFO_LEVEL)
8880 DrawLevelInfoLevel();
8881 else if (edit_mode_levelinfo == ED_MODE_LEVELINFO_LEVELSET)
8882 DrawLevelInfoLevelSet();
8883 else if (edit_mode_levelinfo == ED_MODE_LEVELINFO_EDITOR)
8884 DrawLevelInfoEditor();
8887 static void DrawCustomContentArea()
8889 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
8890 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
8891 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
8892 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
8893 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
8894 int xoffset = ED_GADGET_SPACE_DISTANCE;
8896 /* add distance for potential left text (without drawing area border) */
8897 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
8899 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
8901 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
8904 static void DrawCustomChangeContentArea()
8906 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
8907 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
8908 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
8909 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
8910 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
8911 int xoffset = ED_GADGET_SPACE_DISTANCE;
8913 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
8918 static void RemoveElementContentArea(int id, int font_height)
8920 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
8922 DrawBackground(SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size,
8923 SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size,
8924 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
8925 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size +
8926 ED_GADGET_TEXT_DISTANCE + font_height);
8929 static void DrawYamYamContentAreas()
8931 int font_nr = FONT_TEXT_1;
8932 int font_height = getFontHeight(font_nr);
8933 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
8934 int yoffset = (tilesize - font_height) / 2;
8935 int x = SX + ED_AREA_YAMYAM_CONTENT_X(3) + 4 * tilesize;
8936 int y = SY + ED_AREA_YAMYAM_CONTENT_Y(3) + yoffset;
8939 /* display counter to choose number of element content areas */
8940 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
8942 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
8944 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
8946 if (i < level.num_yamyam_contents)
8952 UnmapDrawingArea(id);
8954 /* delete content areas in case of reducing number of them */
8955 RemoveElementContentArea(id, font_height);
8959 DrawText(x, y + 0 * tilesize, "content", font_nr);
8960 DrawText(x, y + 1 * tilesize, "when", font_nr);
8961 DrawText(x, y + 2 * tilesize, "smashed", font_nr);
8964 static void DrawMagicBallContentAreas()
8966 int font_nr = FONT_TEXT_1;
8967 int font_height = getFontHeight(font_nr);
8968 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
8969 int yoffset = (tilesize - font_height) / 2;
8970 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_X(3) + 4 * tilesize;
8971 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_Y(3) + yoffset;
8974 /* display counter to choose number of element content areas */
8975 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
8977 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
8979 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
8981 if (i < level.num_ball_contents)
8987 UnmapDrawingArea(id);
8989 /* delete content areas in case of reducing number of them */
8990 RemoveElementContentArea(id, font_height);
8994 DrawText(x, y + 0 * tilesize, "generated", font_nr);
8995 DrawText(x, y + 1 * tilesize, "when", font_nr);
8996 DrawText(x, y + 2 * tilesize, "active", font_nr);
8999 static void DrawAndroidElementArea(int element)
9001 int id = ED_DRAWING_ID_ANDROID_CONTENT;
9002 int num_elements = level.num_android_clone_elements;
9003 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9004 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9005 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9006 int xsize = MAX_ANDROID_ELEMENTS;
9009 /* display counter to choose number of element areas */
9010 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
9012 if (drawingarea_info[id].text_left != NULL)
9013 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9015 UnmapDrawingArea(id);
9017 ModifyEditorDrawingArea(id, num_elements, 1);
9019 /* delete content areas in case of reducing number of them */
9020 DrawBackground(sx, sy,
9021 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9022 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9027 static void DrawGroupElementArea(int element)
9029 int id = ED_DRAWING_ID_GROUP_CONTENT;
9030 int num_elements = group_element_info.num_elements;
9031 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9032 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9033 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9034 int xsize = MAX_ELEMENTS_IN_GROUP;
9037 if (drawingarea_info[id].text_left != NULL)
9038 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9040 UnmapDrawingArea(id);
9042 ModifyEditorDrawingArea(id, num_elements, 1);
9044 /* delete content areas in case of reducing number of them */
9045 DrawBackground(sx, sy,
9046 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9047 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9052 static void DrawPlayerInitialInventoryArea(int element)
9054 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
9055 int player_nr = GET_PLAYER_NR(element);
9056 int num_elements = level.initial_inventory_size[player_nr];
9057 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9058 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9059 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9060 int xsize = MAX_INITIAL_INVENTORY_SIZE;
9063 /* determine horizontal position to the right of specified gadget */
9064 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
9065 sx = (right_gadget_border[drawingarea_info[id].gadget_id_align] +
9066 ED_DRAWINGAREA_TEXT_DISTANCE);
9068 /* determine horizontal offset for leading text */
9069 if (drawingarea_info[id].text_left != NULL)
9070 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9072 UnmapDrawingArea(id);
9074 ModifyEditorDrawingArea(id, num_elements, 1);
9076 /* delete content areas in case of reducing number of them */
9077 DrawBackground(sx, sy,
9078 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9079 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9084 static void DrawEnvelopeTextArea(int envelope_nr)
9086 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
9087 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
9090 DrawBackground(gi->x, gi->y, gi->width, gi->height);
9092 if (envelope_nr != -1)
9093 textarea_info[id].value = level.envelope[envelope_nr].text;
9095 ModifyGadget(gi, GDI_AREA_SIZE,
9096 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
9097 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
9100 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
9103 static void DrawPropertiesInfo()
9112 /* configurable properties */
9114 { EP_WALKABLE_OVER, "- player can walk over it" },
9115 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
9116 { EP_WALKABLE_UNDER, "- player can walk under it" },
9117 { EP_PASSABLE_OVER, "- player can pass over it" },
9118 { EP_PASSABLE_INSIDE, "- player can pass through it" },
9119 { EP_PASSABLE_UNDER, "- player can pass under it" },
9120 { EP_PROTECTED, "- player is protected by it" },
9122 { EP_DIGGABLE, "- can be digged away" },
9123 { EP_COLLECTIBLE, "- can be collected" },
9124 { EP_DROPPABLE, "- can be dropped after collecting" },
9125 { EP_THROWABLE, "- can be thrown after collecting" },
9126 { EP_PUSHABLE, "- can be pushed" },
9128 { EP_CAN_FALL, "- can fall" },
9129 { EP_CAN_MOVE, "- can move" },
9131 { EP_CAN_SMASH_PLAYER, "- can smash player" },
9133 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
9135 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
9137 { EP_SLIPPERY, "- slippery for falling elements" },
9138 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
9140 { EP_DONT_RUN_INTO, "- deadly when running into" },
9141 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
9142 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
9143 { EP_DONT_TOUCH, "- deadly when touching" },
9145 { EP_INDESTRUCTIBLE, "- indestructible" },
9147 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
9148 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
9149 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
9151 { EP_CAN_CHANGE, "- can change to other element" },
9153 /* pre-defined properties */
9154 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
9155 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
9156 { EP_SWITCHABLE, "- can be switched" },
9158 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
9163 char *filename = getElementDescriptionFilename(properties_element);
9164 char *percentage_text = "In this level: ";
9165 char *properties_text = "Standard properties: ";
9166 char *description_text = "Description:";
9167 char *no_description_text = "No description available.";
9168 char *none_text = "None";
9170 int num_elements_in_level;
9171 int num_standard_properties = 0;
9172 int font1_nr = FONT_TEXT_1;
9173 int font2_nr = FONT_TEXT_2;
9174 int font1_width = getFontWidth(font1_nr);
9175 int font1_height = getFontHeight(font1_nr);
9176 int font2_height = getFontHeight(font2_nr);
9177 int line1_height = font1_height + ED_GADGET_LINE_DISTANCE;
9178 int font2_yoffset = (font1_height - font2_height) / 2;
9179 int percentage_text_len = strlen(percentage_text) * font1_width;
9180 int properties_text_len = strlen(properties_text) * font1_width;
9181 int xpos = ED_ELEMENT_SETTINGS_X(0);
9182 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
9185 if (setup.editor.show_element_token)
9187 int font3_nr = FONT_TEXT_3;
9188 int font3_height = getFontHeight(font3_nr);
9190 DrawTextF(xpos, ypos, font3_nr,
9191 "[%s]", element_info[properties_element].token_name);
9193 ypos += 2 * font3_height;
9196 /* ----- print number of elements / percentage of this element in level */
9198 num_elements_in_level = 0;
9199 for (y = 0; y < lev_fieldy; y++)
9200 for (x = 0; x < lev_fieldx; x++)
9201 if (Feld[x][y] == properties_element)
9202 num_elements_in_level++;
9203 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
9205 DrawTextS(xpos, ypos, font1_nr, percentage_text);
9207 if (num_elements_in_level > 0)
9208 DrawTextF(xpos + percentage_text_len, ypos + font2_yoffset, font2_nr,
9209 "%d (%.2f %%)", num_elements_in_level, percentage);
9211 DrawTextF(xpos + percentage_text_len, ypos + font2_yoffset, font2_nr,
9214 ypos += 2 * MAX(font1_height, font2_height);
9216 /* ----- print standard properties of this element */
9218 DrawTextS(xpos, ypos, font1_nr, properties_text);
9220 ypos += line1_height;
9222 for (i = 0; properties[i].value != -1; i++)
9224 if (!HAS_PROPERTY(properties_element, properties[i].value))
9227 DrawTextS(xpos, ypos, font2_nr, properties[i].text);
9229 ypos += font2_height;
9231 num_standard_properties++;
9234 if (num_standard_properties == 0)
9236 DrawTextS(xpos + properties_text_len, ypos - line1_height + font2_yoffset,
9237 font2_nr, none_text);
9239 ypos -= (line1_height - font1_height);
9242 ypos += MAX(font1_height, font2_height);
9244 /* ----- print special description of this element */
9246 PrintInfoText(description_text, font1_nr, xpos, ypos);
9248 ypos += line1_height;
9250 if (PrintElementDescriptionFromFile(filename, font2_nr, xpos, ypos) == 0)
9251 PrintInfoText(no_description_text, font1_nr, xpos, ypos - line1_height);
9254 #define TEXT_COLLECTING "Score for collecting"
9255 #define TEXT_SMASHING "Score for smashing"
9256 #define TEXT_SLURPING "Score for slurping robot"
9257 #define TEXT_CRACKING "Score for cracking"
9258 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
9259 #define TEXT_DURATION "Duration when activated"
9260 #define TEXT_DELAY_ON "Delay before activating"
9261 #define TEXT_DELAY_OFF "Delay before deactivating"
9262 #define TEXT_DELAY_EXPLODING "Delay before exploding"
9263 #define TEXT_DELAY_MOVING "Delay before moving"
9264 #define TEXT_BALL_DELAY "Element generation delay"
9265 #define TEXT_MOVE_SPEED "Speed of android moving"
9266 #define TEXT_CLONE_SPEED "Speed of android cloning"
9267 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
9268 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
9269 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
9270 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
9271 #define TEXT_TIME_BONUS "Extra time to solve level"
9278 } elements_with_counter[] =
9280 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
9281 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
9282 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
9283 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
9284 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
9285 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
9286 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
9287 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
9288 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
9289 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
9290 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
9291 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
9292 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
9293 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
9294 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
9295 { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
9296 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
9297 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
9298 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
9299 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
9300 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9301 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9302 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9303 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9304 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9305 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9306 { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
9307 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9308 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9309 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9310 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9311 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
9312 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
9313 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
9314 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
9315 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
9316 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
9317 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
9318 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
9319 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
9320 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
9321 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
9322 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
9323 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
9324 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
9325 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
9326 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE],TEXT_COLLECTING },
9327 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
9328 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
9329 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
9330 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
9331 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
9332 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
9333 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
9334 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
9335 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
9336 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
9337 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
9338 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
9339 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
9340 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
9341 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
9342 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
9343 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
9344 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
9345 { EL_MM_KETTLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
9346 { EL_DF_CELL, &level.score[SC_EMERALD], TEXT_COLLECTING },
9347 { EL_MM_KEY, &level.score[SC_KEY], TEXT_COLLECTING },
9348 { EL_MM_LIGHTBALL, &level.score[SC_ELEM_BONUS], TEXT_COLLECTING },
9349 { EL_MM_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
9350 { EL_MM_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
9351 { EL_MM_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
9352 { EL_MM_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
9353 { EL_MM_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
9354 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9355 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9356 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9357 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9358 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9359 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9360 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9361 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9362 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
9364 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
9365 { EL_DC_TIMEGATE_SWITCH,&level.time_timegate, TEXT_DURATION },
9366 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
9367 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
9368 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
9369 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
9370 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
9371 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
9372 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
9373 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
9374 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
9375 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
9376 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
9377 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
9378 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
9379 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
9381 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
9382 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
9383 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
9384 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
9385 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
9386 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
9387 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
9388 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
9389 { EL_MM_FUSE_ACTIVE, &level.mm_time_fuse, TEXT_DELAY_OFF },
9390 { EL_MM_BOMB, &level.mm_time_bomb, TEXT_DELAY_EXPLODING },
9391 { EL_MM_GRAY_BALL, &level.mm_time_ball, TEXT_DELAY_ON },
9392 { EL_MM_STEEL_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
9393 { EL_MM_WOODEN_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
9398 static boolean checkPropertiesConfig(int element)
9402 if (IS_GEM(element) ||
9403 IS_CUSTOM_ELEMENT(element) ||
9404 IS_GROUP_ELEMENT(element) ||
9405 IS_BALLOON_ELEMENT(element) ||
9406 IS_ENVELOPE(element) ||
9407 IS_MM_MCDUFFIN(element) ||
9408 IS_DF_LASER(element) ||
9409 ELEM_IS_PLAYER(element) ||
9410 HAS_EDITOR_CONTENT(element) ||
9411 CAN_GROW(element) ||
9412 COULD_MOVE_INTO_ACID(element) ||
9413 MAYBE_DONT_COLLIDE_WITH(element) ||
9414 element == EL_SOKOBAN_OBJECT ||
9415 element == EL_SOKOBAN_FIELD_EMPTY ||
9416 element == EL_SOKOBAN_FIELD_FULL)
9419 for (i = 0; elements_with_counter[i].element != -1; i++)
9420 if (elements_with_counter[i].element == element)
9426 static void SetAutomaticNumberOfGemsNeeded()
9430 if (!level.auto_count_gems)
9433 level.gems_needed = 0;
9435 for (x = 0; x < lev_fieldx; x++)
9437 for (y = 0; y < lev_fieldy; y++)
9439 int element = Feld[x][y];
9441 if (IS_GEM(element) ||
9442 element == EL_MM_KETTLE ||
9443 element == EL_DF_CELL)
9444 level.gems_needed++;
9448 ModifyEditorCounterValue(ED_COUNTER_ID_LEVEL_GEMSLIMIT, level.gems_needed);
9451 static void DrawPropertiesConfig()
9453 boolean draw_footer_line = FALSE;
9454 int max_num_element_counters = 4;
9455 int num_element_counters = 0;
9458 if (!checkPropertiesConfig(properties_element))
9460 int xpos = ED_ELEMENT_SETTINGS_X(0);
9461 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
9463 PrintInfoText("No configuration options available.",
9464 FONT_TEXT_1, xpos, ypos);
9469 /* check if there are elements where a value can be chosen for */
9470 for (i = 0; elements_with_counter[i].element != -1; i++)
9472 if (elements_with_counter[i].element == properties_element)
9474 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
9476 counterbutton_info[counter_id].y =
9477 ED_ELEMENT_SETTINGS_YPOS(
9478 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
9479 (CAN_GROW(properties_element) ? 1 : 0) +
9480 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
9481 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
9482 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
9483 num_element_counters);
9485 counterbutton_info[counter_id].value = elements_with_counter[i].value;
9486 counterbutton_info[counter_id].text_right= elements_with_counter[i].text;
9488 if (properties_element == EL_GAME_OF_LIFE ||
9489 properties_element == EL_BIOMAZE)
9491 counterbutton_info[counter_id].min_value = 0; /* min neighbours */
9492 counterbutton_info[counter_id].max_value = 8; /* max neighbours */
9496 /* !!! CHANGE THIS FOR CERTAIN ELEMENTS !!! */
9497 counterbutton_info[counter_id].min_value = MIN_SCORE;
9498 counterbutton_info[counter_id].max_value = MAX_SCORE;
9501 MapCounterButtons(counter_id);
9503 num_element_counters++;
9504 if (num_element_counters >= max_num_element_counters)
9509 if (HAS_EDITOR_CONTENT(properties_element))
9511 /* draw stickybutton gadget */
9512 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
9514 if (IS_AMOEBOID(properties_element))
9515 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
9516 else if (properties_element == EL_YAMYAM ||
9517 properties_element == EL_YAMYAM_LEFT ||
9518 properties_element == EL_YAMYAM_RIGHT ||
9519 properties_element == EL_YAMYAM_UP ||
9520 properties_element == EL_YAMYAM_DOWN)
9521 DrawYamYamContentAreas();
9522 else if (properties_element == EL_EMC_MAGIC_BALL)
9524 DrawMagicBallContentAreas();
9526 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
9527 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_STATE);
9529 else if (properties_element == EL_EMC_ANDROID)
9530 DrawAndroidElementArea(properties_element);
9533 if (ELEM_IS_PLAYER(properties_element))
9535 int player_nr = GET_PLAYER_NR(properties_element);
9537 /* these properties can be set for every player individually */
9539 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
9541 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
9542 &level.start_element[player_nr];
9543 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
9544 &level.artwork_element[player_nr];
9545 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
9546 &level.explosion_element[player_nr];
9548 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
9549 &level.use_start_element[player_nr];
9550 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
9551 &level.use_artwork_element[player_nr];
9552 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
9553 &level.use_explosion_element[player_nr];
9554 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
9555 &level.initial_player_gravity[player_nr];
9557 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
9558 &level.initial_player_stepsize[player_nr];
9560 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
9561 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
9562 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
9563 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
9564 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
9565 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
9566 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
9567 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
9568 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_LAZY_RELOCATION);
9569 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
9570 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
9571 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
9572 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
9573 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
9575 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
9576 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
9577 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
9579 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
9581 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
9583 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
9584 &level.initial_inventory_content[player_nr][0];
9586 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
9587 &level.initial_inventory_size[player_nr];
9589 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
9590 &level.use_initial_inventory[player_nr];
9592 /* draw checkbutton gadgets */
9593 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
9595 /* draw counter gadgets */
9596 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
9598 /* draw drawing area gadgets */
9599 DrawPlayerInitialInventoryArea(properties_element);
9603 if (IS_GEM(properties_element))
9604 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
9606 if (properties_element == EL_EM_DYNAMITE)
9607 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
9609 if (COULD_MOVE_INTO_ACID(properties_element) &&
9610 !ELEM_IS_PLAYER(properties_element) &&
9611 (!IS_CUSTOM_ELEMENT(properties_element) ||
9612 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
9614 /* set position for checkbutton for "can move into acid" */
9615 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
9616 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
9617 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
9618 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 6 :
9619 IS_BALLOON_ELEMENT(properties_element) ||
9620 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
9622 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
9625 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
9626 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
9628 if (properties_element == EL_SPRING)
9629 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
9631 if (properties_element == EL_TIME_ORB_FULL)
9632 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
9634 if (CAN_GROW(properties_element))
9636 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
9637 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
9639 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
9642 if (properties_element == EL_SOKOBAN_OBJECT ||
9643 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
9644 properties_element == EL_SOKOBAN_FIELD_FULL)
9645 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
9647 if (IS_BALLOON_ELEMENT(properties_element))
9648 MapSelectboxGadget(ED_SELECTBOX_ID_WIND_DIRECTION);
9650 if (IS_ENVELOPE(properties_element))
9652 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
9653 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
9654 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
9655 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
9656 int envelope_nr = properties_element - EL_ENVELOPE_1;
9658 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
9659 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
9661 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
9662 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
9664 /* display counter to choose size of envelope text area */
9665 MapCounterButtons(counter1_id);
9666 MapCounterButtons(counter2_id);
9668 /* display checkbuttons to choose auto-wrap and alignment properties */
9669 MapCheckbuttonGadget(button1_id);
9670 MapCheckbuttonGadget(button2_id);
9672 DrawEnvelopeTextArea(envelope_nr);
9675 if (IS_MM_MCDUFFIN(properties_element))
9677 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_RED);
9678 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_GREEN);
9679 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_BLUE);
9682 if (IS_DF_LASER(properties_element))
9684 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_RED);
9685 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_GREEN);
9686 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_BLUE);
9689 if (IS_CUSTOM_ELEMENT(properties_element))
9691 /* draw stickybutton gadget */
9692 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
9694 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
9696 /* draw checkbutton gadgets */
9697 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
9698 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
9699 MapCheckbuttonGadget(i);
9701 /* draw counter gadgets */
9702 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
9703 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
9704 MapCounterButtons(i);
9706 /* draw selectbox gadgets */
9707 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
9708 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
9709 MapSelectboxGadget(i);
9711 /* draw textbutton gadgets */
9712 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
9714 /* draw text input gadgets */
9715 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
9717 /* draw drawing area gadgets */
9718 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
9720 draw_footer_line = TRUE;
9722 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
9724 /* draw checkbutton gadgets */
9725 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
9726 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
9727 MapCheckbuttonGadget(i);
9729 /* draw counter gadgets */
9730 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
9731 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
9732 MapCounterButtons(i);
9734 /* draw selectbox gadgets */
9735 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
9736 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
9737 MapSelectboxGadget(i);
9739 /* draw drawing area gadgets */
9740 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
9741 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
9742 DrawCustomContentArea();
9745 else if (IS_GROUP_ELEMENT(properties_element))
9747 /* draw stickybutton gadget */
9748 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
9750 /* draw checkbutton gadgets */
9751 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
9752 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
9754 /* draw counter gadgets */
9755 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
9757 /* draw selectbox gadgets */
9758 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
9760 /* draw textbutton gadgets */
9761 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
9763 /* draw drawing area gadgets */
9764 DrawGroupElementArea(properties_element);
9766 /* draw text input gadgets */
9767 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
9769 /* draw drawing area gadgets */
9770 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
9772 draw_footer_line = TRUE;
9775 /* draw little footer border line above CE/GE use/save template gadgets */
9776 if (draw_footer_line)
9778 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9779 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9780 int gd_x = gd->x + gd_gi1->border.width / 2;
9781 int gd_y = gd->y + gd_gi1->height - 1;
9782 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
9784 if (tab_color != BLACK_PIXEL) /* black => transparent */
9785 FillRectangle(drawto,
9786 SX + ED_ELEMENT_SETTINGS_X(0),
9787 SY + ED_ELEMENT_SETTINGS_Y(14) - ED_SETTINGS_TABS_YOFFSET -
9789 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9793 static void DrawPropertiesChangeDrawingAreas()
9795 if (IS_CUSTOM_ELEMENT(properties_element))
9797 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
9798 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
9799 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
9801 DrawCustomChangeContentArea();
9804 redraw_mask |= REDRAW_FIELD;
9807 static void DrawPropertiesChange()
9811 /* needed to initially set selectbox options for special action options */
9812 setSelectboxSpecialActionOptions();
9814 /* draw stickybutton gadget */
9815 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
9817 /* draw checkbutton gadgets */
9818 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
9819 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
9820 MapCheckbuttonGadget(i);
9822 /* draw counter gadgets */
9823 for (i = ED_COUNTER_ID_CHANGE_FIRST;
9824 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
9825 MapCounterButtons(i);
9827 /* draw selectbox gadgets */
9828 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
9829 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
9830 MapSelectboxGadget(i);
9832 /* draw textbutton gadgets */
9833 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
9834 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
9835 MapTextbuttonGadget(i);
9837 /* draw graphicbutton gadgets */
9838 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
9839 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
9840 MapGraphicbuttonGadget(i);
9842 /* draw drawing area gadgets */
9843 DrawPropertiesChangeDrawingAreas();
9846 static void DrawEditorElementAnimation(int x, int y)
9848 int graphic = el2img(properties_element);
9849 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
9850 custom_element.ce_value_fixed_initial :
9851 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
9852 custom_element.collect_score_initial : FrameCounter);
9854 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
9857 static void DrawEditorElementName(int x, int y, int font_nr)
9859 char *element_name = getElementInfoText(properties_element);
9860 int font_width = getFontWidth(font_nr);
9861 int font_height = getFontHeight(font_nr);
9862 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
9863 int max_chars_per_line = max_text_width / font_width;
9864 char buffer[max_chars_per_line + 1];
9866 if (strlen(element_name) <= max_chars_per_line)
9867 DrawTextS(x, y, font_nr, element_name);
9870 int next_pos = max_chars_per_line;
9872 strncpy(buffer, element_name, max_chars_per_line);
9873 buffer[max_chars_per_line] = '\0';
9875 if (element_name[max_chars_per_line] == ' ')
9881 for (i = max_chars_per_line - 1; i >= 0; i--)
9882 if (buffer[i] == ' ')
9885 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
9892 DrawTextS(x, y - font_height / 2, font_nr, buffer);
9894 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
9895 buffer[max_chars_per_line] = '\0';
9897 DrawTextS(x, y + font_height / 2, font_nr, buffer);
9901 static void DrawPropertiesWindow()
9903 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
9904 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
9905 int border_size = gd->border_size;
9906 int font_nr = FONT_TEXT_1;
9907 int font_height = getFontHeight(font_nr);
9908 int xoffset = TILEX + element_border + 3 * border_size;
9909 int yoffset = (TILEY - font_height) / 2;
9910 int x1 = editor.settings.element_graphic.x + element_border;
9911 int y1 = editor.settings.element_graphic.y + element_border;
9912 int x2 = (editor.settings.element_name.x == -1 ? x1 + xoffset :
9913 editor.settings.element_name.x);
9914 int y2 = (editor.settings.element_name.y == -1 ? y1 + yoffset :
9915 editor.settings.element_name.y);
9916 char *text = "Element Settings";
9917 int font2_nr = FONT_TITLE_1;
9918 struct MenuPosInfo *pos = &editor.settings.headline;
9919 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font2_nr), pos->align);
9920 int sy = SY + pos->y;
9922 stick_element_properties_window = FALSE;
9924 /* make sure that previous properties edit mode exists for this element */
9925 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
9926 !IS_CUSTOM_ELEMENT(properties_element))
9927 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
9929 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
9930 !ELEM_IS_PLAYER(properties_element) &&
9931 !IS_CUSTOM_ELEMENT(properties_element))
9932 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
9934 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
9935 (ELEM_IS_PLAYER(properties_element) ||
9936 IS_CUSTOM_ELEMENT(properties_element)))
9937 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
9939 CopyElementPropertiesToEditor(properties_element);
9941 UnmapLevelEditorFieldGadgets();
9942 UnmapLevelEditorToolboxDrawingGadgets();
9943 UnmapLevelEditorToolboxCustomGadgets();
9945 if (IS_CUSTOM_ELEMENT(properties_element) ||
9946 IS_GROUP_ELEMENT(properties_element))
9947 MapLevelEditorToolboxCustomGadgets();
9949 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
9952 DrawText(sx, sy, text, font2_nr);
9954 FrameCounter = 0; /* restart animation frame counter */
9956 DrawElementBorder(SX + x1, SY + y1, TILEX, TILEY, FALSE);
9957 DrawEditorElementAnimation(SX + x1, SY + y1);
9958 DrawEditorElementName(x2, y2, font_nr);
9960 DrawPropertiesTabulatorGadgets();
9962 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
9963 DrawPropertiesInfo();
9964 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
9965 DrawPropertiesChange();
9966 else /* (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2]) */
9967 DrawPropertiesConfig();
9970 static void DrawPaletteWindow()
9974 UnmapLevelEditorFieldGadgets();
9976 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
9979 /* map buttons to select elements */
9980 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
9981 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
9982 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
9983 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
9984 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
9987 static void UpdateCustomElementGraphicGadgets()
9991 InitElementPropertiesGfxElement();
9993 ModifyEditorElementList();
9994 RedrawDrawingElements();
9996 /* force redraw of all mapped drawing area gadgets */
9997 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
9999 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
10006 static int getOpenDirectionFromTube(int element)
10010 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
10011 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
10012 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
10013 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
10014 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
10015 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
10016 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
10017 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
10018 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
10019 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
10020 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
10026 static int getTubeFromOpenDirection(int direction)
10030 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
10031 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
10032 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
10033 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
10034 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
10035 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
10036 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
10037 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
10038 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
10039 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
10040 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
10042 /* if only one direction, fall back to simple tube with that direction */
10043 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
10044 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
10045 case (MV_UP): return EL_TUBE_VERTICAL;
10046 case (MV_DOWN): return EL_TUBE_VERTICAL;
10052 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
10054 int element_new = getTubeFromOpenDirection(direction);
10056 return (element_new != EL_EMPTY ? element_new : element_old);
10059 static int getOpenDirectionFromBelt(int element)
10061 int belt_dir = getBeltDirFromBeltElement(element);
10063 return (belt_dir == MV_LEFT ? MV_RIGHT :
10064 belt_dir == MV_RIGHT ? MV_LEFT :
10065 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
10068 static int getBeltFromNrAndOpenDirection(int nr, int direction)
10070 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
10071 direction == MV_RIGHT ? MV_LEFT :
10072 direction == MV_HORIZONTAL ? MV_NONE : direction);
10074 if (direction == MV_NONE)
10077 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
10080 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
10083 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
10085 return (element_new != EL_EMPTY ? element_new : element_old);
10088 static int getOpenDirectionFromPool(int element)
10092 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
10093 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
10094 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
10095 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
10096 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
10097 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
10103 static int getPoolFromOpenDirection(int direction)
10107 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
10108 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
10109 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
10110 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
10111 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
10112 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
10118 static int getPoolFromOpenDirectionExt(int direction, int help_element)
10120 int element = getPoolFromOpenDirection(direction);
10121 int help_direction = getOpenDirectionFromPool(help_element);
10123 if (element == EL_EMPTY)
10125 int help_direction_vertical = help_direction & MV_VERTICAL;
10127 element = getPoolFromOpenDirection(direction | help_direction_vertical);
10130 if (element == EL_EMPTY)
10132 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
10134 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
10140 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
10142 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
10144 return (element_new != EL_EMPTY ? element_new : element_old);
10147 static int getOpenDirectionFromPillar(int element)
10151 case EL_EMC_WALL_1: return (MV_DOWN);
10152 case EL_EMC_WALL_2: return (MV_VERTICAL);
10153 case EL_EMC_WALL_3: return (MV_UP);
10159 static int getPillarFromOpenDirection(int direction)
10163 case (MV_DOWN): return EL_EMC_WALL_1;
10164 case (MV_VERTICAL): return EL_EMC_WALL_2;
10165 case (MV_UP): return EL_EMC_WALL_3;
10171 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
10173 int element_new = getPillarFromOpenDirection(direction);
10175 return (element_new != EL_EMPTY ? element_new : element_old);
10178 static int getOpenDirectionFromSteel2(int element)
10182 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
10183 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
10184 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
10185 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
10186 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
10187 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
10188 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
10189 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
10195 static int getSteel2FromOpenDirection(int direction)
10199 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
10200 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
10201 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
10202 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
10203 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
10204 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
10205 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
10206 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
10212 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
10214 int element_new = getSteel2FromOpenDirection(direction);
10216 return (element_new != EL_EMPTY ? element_new : element_old);
10219 static int getOpenDirectionFromChip(int element)
10223 case EL_SP_CHIP_SINGLE: return (MV_NONE);
10224 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
10225 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
10226 case EL_SP_CHIP_TOP: return (MV_DOWN);
10227 case EL_SP_CHIP_BOTTOM: return (MV_UP);
10233 static int getChipFromOpenDirection(int direction)
10237 case (MV_NONE): return EL_SP_CHIP_SINGLE;
10238 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
10239 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
10240 case (MV_UP): return EL_SP_CHIP_BOTTOM;
10241 case (MV_DOWN): return EL_SP_CHIP_TOP;
10247 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
10249 int element_new = getChipFromOpenDirection(direction);
10251 return (element_new != EL_EMPTY ? element_new : element_old);
10254 static int getClosedTube(int x, int y)
10256 static int xy[4][2] =
10263 int element_old = IntelliDrawBuffer[x][y];
10264 int direction_old = getOpenDirectionFromTube(element_old);
10265 int direction_new = MV_NONE;
10268 for (i = 0; i < NUM_DIRECTIONS; i++)
10270 int xx = x + xy[i][0];
10271 int yy = y + xy[i][1];
10272 int dir = MV_DIR_FROM_BIT(i);
10273 int dir_opposite = MV_DIR_OPPOSITE(dir);
10275 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
10276 (direction_old & dir) &&
10277 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10278 direction_new |= dir;
10281 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
10284 static int getClosedBelt(int x, int y)
10286 static int xy[4][2] =
10293 int element_old = IntelliDrawBuffer[x][y];
10294 int nr = getBeltNrFromBeltElement(element_old);
10295 int direction_old = getOpenDirectionFromBelt(element_old);
10296 int direction_new = MV_NONE;
10299 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
10301 int xx = x + xy[i][0];
10302 int yy = y + xy[i][1];
10303 int dir = MV_DIR_FROM_BIT(i);
10304 int dir_opposite = MV_DIR_OPPOSITE(dir);
10306 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
10307 (direction_old & dir) &&
10308 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10309 direction_new |= dir;
10312 return getBeltFromNrAndOpenDirection(nr, direction_new);
10315 static int getClosedPool(int x, int y)
10317 static int xy[4][2] =
10324 int element_old = IntelliDrawBuffer[x][y];
10325 int direction_old = getOpenDirectionFromPool(element_old);
10326 int direction_new = MV_NONE;
10329 for (i = 0; i < NUM_DIRECTIONS; i++)
10331 int xx = x + xy[i][0];
10332 int yy = y + xy[i][1];
10333 int dir = MV_DIR_FROM_BIT(i);
10334 int dir_opposite = MV_DIR_OPPOSITE(dir);
10336 if (IN_LEV_FIELD(xx, yy) &&
10337 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
10338 (direction_old & dir) &&
10339 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10340 direction_new |= dir;
10343 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
10346 static int getClosedPillar(int x, int y)
10348 static int xy[4][2] =
10355 int element_old = IntelliDrawBuffer[x][y];
10356 int direction_old = getOpenDirectionFromPillar(element_old);
10357 int direction_new = MV_NONE;
10360 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
10362 int xx = x + xy[i][0];
10363 int yy = y + xy[i][1];
10364 int dir = MV_DIR_FROM_BIT(i);
10365 int dir_opposite = MV_DIR_OPPOSITE(dir);
10367 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
10368 (direction_old & dir) &&
10369 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10370 direction_new |= dir;
10373 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
10376 static int getClosedSteel2(int x, int y)
10378 static int xy[4][2] =
10385 int element_old = IntelliDrawBuffer[x][y];
10386 int direction_old = getOpenDirectionFromSteel2(element_old);
10387 int direction_new = MV_NONE;
10390 for (i = 0; i < NUM_DIRECTIONS; i++)
10392 int xx = x + xy[i][0];
10393 int yy = y + xy[i][1];
10394 int dir = MV_DIR_FROM_BIT(i);
10395 int dir_opposite = MV_DIR_OPPOSITE(dir);
10397 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
10398 (direction_old & dir) &&
10399 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10400 direction_new |= dir;
10403 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
10406 static int getClosedChip(int x, int y)
10408 static int xy[4][2] =
10415 int element_old = IntelliDrawBuffer[x][y];
10416 int direction_old = getOpenDirectionFromChip(element_old);
10417 int direction_new = MV_NONE;
10420 for (i = 0; i < NUM_DIRECTIONS; i++)
10422 int xx = x + xy[i][0];
10423 int yy = y + xy[i][1];
10424 int dir = MV_DIR_FROM_BIT(i);
10425 int dir_opposite = MV_DIR_OPPOSITE(dir);
10427 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
10428 (direction_old & dir) &&
10429 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10430 direction_new |= dir;
10433 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
10436 static void SetElementSimpleExt(int x, int y, int dx, int dy, int element,
10437 boolean change_level)
10439 int sx = x - level_xpos;
10440 int sy = y - level_ypos;
10441 int old_element = Feld[x][y];
10442 int new_element = element;
10443 unsigned int new_bitmask = (getDrawModeHiRes() ? (dx + 1) << (dy * 2) : 0x0f);
10444 boolean draw_masked = FALSE;
10446 if (IS_MM_WALL_EDITOR(element))
10448 element = map_mm_wall_element_editor(element) | new_bitmask;
10450 if (IS_MM_WALL(old_element))
10451 element |= MM_WALL_BITS(old_element);
10454 draw_masked = TRUE;
10456 else if (IS_MM_WALL(old_element) && element == EL_EMPTY)
10458 int element_changed = old_element & ~new_bitmask;
10460 if (MM_WALL_BITS(element_changed) != 0)
10461 element = element_changed;
10464 IntelliDrawBuffer[x][y] = element;
10467 Feld[x][y] = element;
10469 if (IN_ED_FIELD(sx, sy))
10471 if (IS_MM_WALL(old_element) && new_element == EL_EMPTY)
10472 DrawSizedWallParts_MM(sx, sy, EL_EMPTY, ed_tilesize, FALSE, new_bitmask);
10473 else if (draw_masked)
10474 DrawEditorElementThruMask(sx, sy, element);
10476 DrawEditorElement(sx, sy, element);
10480 static void SetElementSimple(int x, int y, int element, boolean change_level)
10482 SetElementSimpleExt(x, y, 0, 0, element, change_level);
10485 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
10486 int x2, int y2, int *element2,
10487 int (*close_function)(int, int),
10488 boolean change_level)
10490 /* set neighbour elements to newly determined connections */
10491 SetElementSimple(x1, y1, *element1, change_level);
10492 SetElementSimple(x2, y2, *element2, change_level);
10494 /* remove all open connections of neighbour elements */
10495 *element1 = close_function(x1, y1);
10496 *element2 = close_function(x2, y2);
10498 /* set neighbour elements to new, minimized connections */
10499 SetElementSimple(x1, y1, *element1, change_level);
10500 SetElementSimple(x2, y2, *element2, change_level);
10503 static void SetElementIntelliDraw(int x, int y, int new_element,
10504 boolean change_level, int button)
10506 static int xy[4][2] =
10513 static int last_x = -1;
10514 static int last_y = -1;
10515 int old_element = IntelliDrawBuffer[x][y];
10517 if (new_element == EL_UNDEFINED)
10525 if (IS_TUBE(new_element))
10527 int last_element_new = EL_UNDEFINED;
10528 int direction = MV_NONE;
10531 /* if old element is of same kind, keep all existing directions */
10532 if (IS_TUBE(old_element))
10533 direction |= getOpenDirectionFromTube(old_element);
10535 for (i = 0; i < NUM_DIRECTIONS; i++)
10537 int xx = x + xy[i][0];
10538 int yy = y + xy[i][1];
10540 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10541 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
10543 int dir = MV_DIR_FROM_BIT(i);
10544 int dir_opposite = MV_DIR_OPPOSITE(dir);
10545 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10546 int last_direction_old = getOpenDirectionFromTube(last_element_old);
10547 int last_direction_new = last_direction_old | dir_opposite;
10549 last_element_new = getTubeFromOpenDirection(last_direction_new);
10555 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
10557 if (last_element_new != EL_UNDEFINED)
10558 MergeAndCloseNeighbourElements(x, y, &new_element,
10559 last_x, last_y, &last_element_new,
10560 getClosedTube, change_level);
10562 else if (IS_BELT(new_element))
10564 int belt_nr = getBeltNrFromBeltElement(new_element);
10565 int last_element_new = EL_UNDEFINED;
10566 int direction = MV_NONE;
10569 /* if old element is of same kind, keep all existing directions */
10570 if (IS_BELT(old_element))
10571 direction |= getOpenDirectionFromBelt(old_element);
10573 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
10575 int xx = x + xy[i][0];
10576 int yy = y + xy[i][1];
10578 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10579 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
10581 int dir = MV_DIR_FROM_BIT(i);
10582 int dir_opposite = MV_DIR_OPPOSITE(dir);
10583 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10584 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
10585 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
10586 int last_direction_new = last_direction_old | dir_opposite;
10588 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
10589 last_direction_new);
10594 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
10596 if (last_element_new != EL_UNDEFINED)
10597 MergeAndCloseNeighbourElements(x, y, &new_element,
10598 last_x, last_y, &last_element_new,
10599 getClosedBelt, change_level);
10601 else if (IS_ACID_POOL_OR_ACID(new_element))
10603 int last_element_new = EL_UNDEFINED;
10604 int direction = MV_NONE;
10607 /* if old element is of same kind, keep all existing directions */
10608 if (IS_ACID_POOL_OR_ACID(old_element))
10609 direction |= getOpenDirectionFromPool(old_element);
10611 for (i = 0; i < NUM_DIRECTIONS; i++)
10613 int xx = x + xy[i][0];
10614 int yy = y + xy[i][1];
10616 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10617 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
10619 int dir = MV_DIR_FROM_BIT(i);
10620 int dir_opposite = MV_DIR_OPPOSITE(dir);
10621 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10622 int last_direction_old = getOpenDirectionFromPool(last_element_old);
10623 int last_direction_new = last_direction_old | dir_opposite;
10625 last_element_new = getPoolFromOpenDirection(last_direction_new);
10631 /* special corrections needed for intuitively correct acid pool drawing */
10632 if (last_element_new == EL_EMPTY)
10633 last_element_new = new_element;
10634 else if (last_element_new != EL_UNDEFINED)
10635 new_element = last_element_new;
10637 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
10639 if (last_element_new != EL_UNDEFINED)
10640 MergeAndCloseNeighbourElements(x, y, &new_element,
10641 last_x, last_y, &last_element_new,
10642 getClosedPool, change_level);
10644 else if (IS_EMC_PILLAR(new_element))
10646 int last_element_new = EL_UNDEFINED;
10647 int direction = MV_NONE;
10650 /* if old element is of same kind, keep all existing directions */
10651 if (IS_EMC_PILLAR(old_element))
10652 direction |= getOpenDirectionFromPillar(old_element);
10654 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
10656 int xx = x + xy[i][0];
10657 int yy = y + xy[i][1];
10659 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10660 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
10662 int dir = MV_DIR_FROM_BIT(i);
10663 int dir_opposite = MV_DIR_OPPOSITE(dir);
10664 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10665 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
10666 int last_direction_new = last_direction_old | dir_opposite;
10668 last_element_new = getPillarFromOpenDirection(last_direction_new);
10674 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
10676 if (last_element_new != EL_UNDEFINED)
10677 MergeAndCloseNeighbourElements(x, y, &new_element,
10678 last_x, last_y, &last_element_new,
10679 getClosedPillar, change_level);
10681 else if (IS_DC_STEELWALL_2(new_element))
10683 int last_element_new = EL_UNDEFINED;
10684 int direction = MV_NONE;
10687 /* if old element is of same kind, keep all existing directions */
10688 if (IS_DC_STEELWALL_2(old_element))
10689 direction |= getOpenDirectionFromSteel2(old_element);
10691 for (i = 0; i < NUM_DIRECTIONS; i++)
10693 int xx = x + xy[i][0];
10694 int yy = y + xy[i][1];
10696 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10697 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
10699 int dir = MV_DIR_FROM_BIT(i);
10700 int dir_opposite = MV_DIR_OPPOSITE(dir);
10701 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10702 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
10703 int last_direction_new = last_direction_old | dir_opposite;
10705 last_element_new = getSteel2FromOpenDirection(last_direction_new);
10711 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
10713 if (last_element_new != EL_UNDEFINED)
10714 MergeAndCloseNeighbourElements(x, y, &new_element,
10715 last_x, last_y, &last_element_new,
10716 getClosedSteel2, change_level);
10718 else if (IS_SP_CHIP(new_element))
10720 int last_element_new = EL_UNDEFINED;
10721 int direction = MV_NONE;
10724 /* (do not keep existing directions, regardless of kind of old element) */
10726 for (i = 0; i < NUM_DIRECTIONS; i++)
10728 int xx = x + xy[i][0];
10729 int yy = y + xy[i][1];
10731 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10732 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
10734 int dir = MV_DIR_FROM_BIT(i);
10735 int dir_opposite = MV_DIR_OPPOSITE(dir);
10736 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10737 int last_direction_old = getOpenDirectionFromChip(last_element_old);
10738 int last_direction_new = last_direction_old | dir_opposite;
10740 if (last_direction_old == MV_NONE)
10742 last_element_new = getChipFromOpenDirection(last_direction_new);
10745 else if (last_direction_old & (dir | dir_opposite))
10747 direction |= MV_DIR_OPPOSITE(last_direction_old);
10751 direction |= MV_DIR_OPPOSITE(dir);
10756 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
10758 if (last_element_new != EL_UNDEFINED)
10759 MergeAndCloseNeighbourElements(x, y, &new_element,
10760 last_x, last_y, &last_element_new,
10761 getClosedChip, change_level);
10763 else if (IS_SP_HARDWARE_BASE(new_element))
10765 int nr = GetSimpleRandom(6);
10767 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
10768 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
10769 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
10770 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
10771 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
10773 else if (new_element == EL_SP_HARDWARE_GREEN ||
10774 new_element == EL_SP_HARDWARE_BLUE ||
10775 new_element == EL_SP_HARDWARE_RED)
10777 int nr = GetSimpleRandom(3);
10779 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
10780 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
10782 else if (IS_GROUP_ELEMENT(new_element))
10784 boolean connected_drawing = FALSE;
10787 for (i = 0; i < NUM_DIRECTIONS; i++)
10789 int xx = x + xy[i][0];
10790 int yy = y + xy[i][1];
10792 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10793 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
10794 connected_drawing = TRUE;
10797 if (!connected_drawing)
10798 ResolveGroupElement(new_element);
10800 new_element = GetElementFromGroupElement(new_element);
10802 else if (IS_BELT_SWITCH(old_element))
10804 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
10805 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
10807 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
10808 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
10810 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
10814 static int swappable_elements[][2] =
10816 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
10817 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
10818 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
10819 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
10820 { EL_EMERALD, EL_WALL_EMERALD },
10821 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
10822 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
10823 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
10824 { EL_DIAMOND, EL_WALL_DIAMOND },
10825 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
10826 { EL_GATE_1, EL_GATE_1_GRAY },
10827 { EL_GATE_2, EL_GATE_2_GRAY },
10828 { EL_GATE_3, EL_GATE_3_GRAY },
10829 { EL_GATE_4, EL_GATE_4_GRAY },
10830 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
10831 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
10832 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
10833 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
10834 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
10835 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
10836 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
10837 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
10838 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
10839 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
10840 { EL_LAMP, EL_LAMP_ACTIVE },
10841 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
10842 { EL_SP_BASE, EL_SP_BUGGY_BASE },
10843 { EL_PEARL, EL_WALL_PEARL },
10844 { EL_CRYSTAL, EL_WALL_CRYSTAL },
10845 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
10846 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
10847 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
10848 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
10849 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
10850 { EL_LANDMINE, EL_DC_LANDMINE },
10851 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
10852 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
10853 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
10854 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
10855 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
10856 { EL_MM_EXIT_CLOSED, EL_MM_EXIT_OPEN },
10857 { EL_MM_FUSE, EL_MM_FUSE_ACTIVE },
10858 { EL_MM_LIGHTBULB, EL_MM_LIGHTBULB_ACTIVE },
10859 { EL_MM_FUEL_EMPTY, EL_MM_FUEL_FULL },
10863 static int rotatable_elements_4[][4] =
10873 EL_SPACESHIP_RIGHT,
10878 EL_BD_BUTTERFLY_UP,
10879 EL_BD_BUTTERFLY_RIGHT,
10880 EL_BD_BUTTERFLY_DOWN,
10881 EL_BD_BUTTERFLY_LEFT
10885 EL_BD_FIREFLY_RIGHT,
10886 EL_BD_FIREFLY_DOWN,
10914 EL_SP_GRAVITY_PORT_UP,
10915 EL_SP_GRAVITY_PORT_RIGHT,
10916 EL_SP_GRAVITY_PORT_DOWN,
10917 EL_SP_GRAVITY_PORT_LEFT
10920 EL_SP_GRAVITY_ON_PORT_UP,
10921 EL_SP_GRAVITY_ON_PORT_RIGHT,
10922 EL_SP_GRAVITY_ON_PORT_DOWN,
10923 EL_SP_GRAVITY_ON_PORT_LEFT
10926 EL_SP_GRAVITY_OFF_PORT_UP,
10927 EL_SP_GRAVITY_OFF_PORT_RIGHT,
10928 EL_SP_GRAVITY_OFF_PORT_DOWN,
10929 EL_SP_GRAVITY_OFF_PORT_LEFT
10938 EL_BALLOON_SWITCH_UP,
10939 EL_BALLOON_SWITCH_RIGHT,
10940 EL_BALLOON_SWITCH_DOWN,
10941 EL_BALLOON_SWITCH_LEFT
10945 EL_MM_MCDUFFIN_RIGHT,
10946 EL_MM_MCDUFFIN_DOWN,
10947 EL_MM_MCDUFFIN_LEFT
10950 EL_MM_MIRROR_FIXED_1,
10951 EL_MM_MIRROR_FIXED_4,
10952 EL_MM_MIRROR_FIXED_3,
10953 EL_MM_MIRROR_FIXED_2
10956 EL_MM_STEEL_GRID_FIXED_1,
10957 EL_MM_STEEL_GRID_FIXED_4,
10958 EL_MM_STEEL_GRID_FIXED_2,
10959 EL_MM_STEEL_GRID_FIXED_3
10962 EL_MM_WOODEN_GRID_FIXED_1,
10963 EL_MM_WOODEN_GRID_FIXED_4,
10964 EL_MM_WOODEN_GRID_FIXED_2,
10965 EL_MM_WOODEN_GRID_FIXED_3
10968 EL_MM_POLARISATOR_CROSS_1,
10969 EL_MM_POLARISATOR_CROSS_4,
10970 EL_MM_POLARISATOR_CROSS_3,
10971 EL_MM_POLARISATOR_CROSS_2
10975 EL_MM_PACMAN_RIGHT,
10987 EL_DF_RECEIVER_RIGHT,
10988 EL_DF_RECEIVER_DOWN,
10989 EL_DF_RECEIVER_LEFT
10996 static int rotatable_elements_8[][8] =
10999 EL_DF_STEEL_GRID_FIXED_1,
11000 EL_DF_STEEL_GRID_FIXED_8,
11001 EL_DF_STEEL_GRID_FIXED_7,
11002 EL_DF_STEEL_GRID_FIXED_6,
11003 EL_DF_STEEL_GRID_FIXED_5,
11004 EL_DF_STEEL_GRID_FIXED_4,
11005 EL_DF_STEEL_GRID_FIXED_3,
11006 EL_DF_STEEL_GRID_FIXED_2
11009 EL_DF_WOODEN_GRID_FIXED_1,
11010 EL_DF_WOODEN_GRID_FIXED_8,
11011 EL_DF_WOODEN_GRID_FIXED_7,
11012 EL_DF_WOODEN_GRID_FIXED_6,
11013 EL_DF_WOODEN_GRID_FIXED_5,
11014 EL_DF_WOODEN_GRID_FIXED_4,
11015 EL_DF_WOODEN_GRID_FIXED_3,
11016 EL_DF_WOODEN_GRID_FIXED_2
11019 EL_DF_STEEL_GRID_ROTATING_1,
11020 EL_DF_STEEL_GRID_ROTATING_8,
11021 EL_DF_STEEL_GRID_ROTATING_7,
11022 EL_DF_STEEL_GRID_ROTATING_6,
11023 EL_DF_STEEL_GRID_ROTATING_5,
11024 EL_DF_STEEL_GRID_ROTATING_4,
11025 EL_DF_STEEL_GRID_ROTATING_3,
11026 EL_DF_STEEL_GRID_ROTATING_2
11029 EL_DF_WOODEN_GRID_ROTATING_1,
11030 EL_DF_WOODEN_GRID_ROTATING_8,
11031 EL_DF_WOODEN_GRID_ROTATING_7,
11032 EL_DF_WOODEN_GRID_ROTATING_6,
11033 EL_DF_WOODEN_GRID_ROTATING_5,
11034 EL_DF_WOODEN_GRID_ROTATING_4,
11035 EL_DF_WOODEN_GRID_ROTATING_3,
11036 EL_DF_WOODEN_GRID_ROTATING_2
11043 static int rotatable_elements_16[][16] =
11082 EL_MM_BEAMER_RED_5,
11083 EL_MM_BEAMER_RED_4,
11084 EL_MM_BEAMER_RED_3,
11085 EL_MM_BEAMER_RED_2,
11086 EL_MM_BEAMER_RED_1,
11087 EL_MM_BEAMER_RED_16,
11088 EL_MM_BEAMER_RED_15,
11089 EL_MM_BEAMER_RED_14,
11090 EL_MM_BEAMER_RED_13,
11091 EL_MM_BEAMER_RED_12,
11092 EL_MM_BEAMER_RED_11,
11093 EL_MM_BEAMER_RED_10,
11094 EL_MM_BEAMER_RED_9,
11095 EL_MM_BEAMER_RED_8,
11096 EL_MM_BEAMER_RED_7,
11100 EL_MM_BEAMER_YELLOW_5,
11101 EL_MM_BEAMER_YELLOW_4,
11102 EL_MM_BEAMER_YELLOW_3,
11103 EL_MM_BEAMER_YELLOW_2,
11104 EL_MM_BEAMER_YELLOW_1,
11105 EL_MM_BEAMER_YELLOW_16,
11106 EL_MM_BEAMER_YELLOW_15,
11107 EL_MM_BEAMER_YELLOW_14,
11108 EL_MM_BEAMER_YELLOW_13,
11109 EL_MM_BEAMER_YELLOW_12,
11110 EL_MM_BEAMER_YELLOW_11,
11111 EL_MM_BEAMER_YELLOW_10,
11112 EL_MM_BEAMER_YELLOW_9,
11113 EL_MM_BEAMER_YELLOW_8,
11114 EL_MM_BEAMER_YELLOW_7,
11115 EL_MM_BEAMER_YELLOW_6
11118 EL_MM_BEAMER_GREEN_5,
11119 EL_MM_BEAMER_GREEN_4,
11120 EL_MM_BEAMER_GREEN_3,
11121 EL_MM_BEAMER_GREEN_2,
11122 EL_MM_BEAMER_GREEN_1,
11123 EL_MM_BEAMER_GREEN_16,
11124 EL_MM_BEAMER_GREEN_15,
11125 EL_MM_BEAMER_GREEN_14,
11126 EL_MM_BEAMER_GREEN_13,
11127 EL_MM_BEAMER_GREEN_12,
11128 EL_MM_BEAMER_GREEN_11,
11129 EL_MM_BEAMER_GREEN_10,
11130 EL_MM_BEAMER_GREEN_9,
11131 EL_MM_BEAMER_GREEN_8,
11132 EL_MM_BEAMER_GREEN_7,
11133 EL_MM_BEAMER_GREEN_6
11136 EL_MM_BEAMER_BLUE_5,
11137 EL_MM_BEAMER_BLUE_4,
11138 EL_MM_BEAMER_BLUE_3,
11139 EL_MM_BEAMER_BLUE_2,
11140 EL_MM_BEAMER_BLUE_1,
11141 EL_MM_BEAMER_BLUE_16,
11142 EL_MM_BEAMER_BLUE_15,
11143 EL_MM_BEAMER_BLUE_14,
11144 EL_MM_BEAMER_BLUE_13,
11145 EL_MM_BEAMER_BLUE_12,
11146 EL_MM_BEAMER_BLUE_11,
11147 EL_MM_BEAMER_BLUE_10,
11148 EL_MM_BEAMER_BLUE_9,
11149 EL_MM_BEAMER_BLUE_8,
11150 EL_MM_BEAMER_BLUE_7,
11151 EL_MM_BEAMER_BLUE_6
11154 EL_MM_POLARISATOR_1,
11155 EL_MM_POLARISATOR_16,
11156 EL_MM_POLARISATOR_15,
11157 EL_MM_POLARISATOR_14,
11158 EL_MM_POLARISATOR_13,
11159 EL_MM_POLARISATOR_12,
11160 EL_MM_POLARISATOR_11,
11161 EL_MM_POLARISATOR_10,
11162 EL_MM_POLARISATOR_9,
11163 EL_MM_POLARISATOR_8,
11164 EL_MM_POLARISATOR_7,
11165 EL_MM_POLARISATOR_6,
11166 EL_MM_POLARISATOR_5,
11167 EL_MM_POLARISATOR_4,
11168 EL_MM_POLARISATOR_3,
11169 EL_MM_POLARISATOR_2
11190 EL_DF_MIRROR_ROTATING_1,
11191 EL_DF_MIRROR_ROTATING_16,
11192 EL_DF_MIRROR_ROTATING_15,
11193 EL_DF_MIRROR_ROTATING_14,
11194 EL_DF_MIRROR_ROTATING_13,
11195 EL_DF_MIRROR_ROTATING_12,
11196 EL_DF_MIRROR_ROTATING_11,
11197 EL_DF_MIRROR_ROTATING_10,
11198 EL_DF_MIRROR_ROTATING_9,
11199 EL_DF_MIRROR_ROTATING_8,
11200 EL_DF_MIRROR_ROTATING_7,
11201 EL_DF_MIRROR_ROTATING_6,
11202 EL_DF_MIRROR_ROTATING_5,
11203 EL_DF_MIRROR_ROTATING_4,
11204 EL_DF_MIRROR_ROTATING_3,
11205 EL_DF_MIRROR_ROTATING_2
11214 for (i = 0; swappable_elements[i][0] != -1; i++)
11216 int element1 = swappable_elements[i][0];
11217 int element2 = swappable_elements[i][1];
11219 if (old_element == element1 || old_element == element2)
11220 new_element = (old_element == element1 ? element2 : element1);
11223 for (i = 0; rotatable_elements_4[i][0] != -1; i++)
11225 for (j = 0; j < 4; j++)
11227 int element = rotatable_elements_4[i][j];
11229 if (old_element == element)
11230 new_element = (button == 1 ? rotatable_elements_4[i][(j + 3) % 4] :
11231 button == 2 ? rotatable_elements_4[i][0] :
11232 button == 3 ? rotatable_elements_4[i][(j + 1) % 4] :
11237 for (i = 0; rotatable_elements_8[i][0] != -1; i++)
11239 for (j = 0; j < 8; j++)
11241 int element = rotatable_elements_8[i][j];
11243 if (old_element == element)
11244 new_element = (button == 1 ? rotatable_elements_8[i][(j + 7) % 8] :
11245 button == 2 ? rotatable_elements_8[i][0] :
11246 button == 3 ? rotatable_elements_8[i][(j + 1) % 8] :
11251 for (i = 0; rotatable_elements_16[i][0] != -1; i++)
11253 for (j = 0; j < 16; j++)
11255 int element = rotatable_elements_16[i][j];
11257 if (old_element == element)
11258 new_element = (button == 1 ? rotatable_elements_16[i][(j + 15) % 16] :
11259 button == 2 ? rotatable_elements_16[i][0] :
11260 button == 3 ? rotatable_elements_16[i][(j + 1) % 16] :
11265 if (old_element != new_element)
11267 int max_infotext_len = getMaxInfoTextLength();
11268 char infotext[MAX_OUTPUT_LINESIZE + 1];
11270 strncpy(infotext, getElementInfoText(new_element), max_infotext_len);
11271 infotext[max_infotext_len] = '\0';
11273 ClearEditorGadgetInfoText();
11275 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT,
11280 SetElementSimple(x, y, new_element, change_level);
11286 static void ResetIntelliDraw()
11290 for (x = 0; x < lev_fieldx; x++)
11291 for (y = 0; y < lev_fieldy; y++)
11292 IntelliDrawBuffer[x][y] = Feld[x][y];
11294 SetElementIntelliDraw(-1, -1, EL_UNDEFINED, FALSE, -1);
11297 static boolean draw_mode_hires = FALSE;
11299 static void SetDrawModeHiRes(int element)
11302 (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
11303 (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY));
11306 static boolean getDrawModeHiRes()
11308 return draw_mode_hires;
11311 static int getLoResScreenPos(int pos)
11313 return (getDrawModeHiRes() ? pos / 2 : pos);
11316 static int getLoResScreenMod(int pos)
11318 return (getDrawModeHiRes() ? pos % 2 : 0);
11321 static void SetElementExt(int x, int y, int dx, int dy, int element,
11322 boolean change_level, int button)
11325 SetElementSimple(x, y, Feld[x][y], change_level);
11326 else if (GetKeyModState() & KMOD_Shift && !IS_MM_WALL_EDITOR(element))
11327 SetElementIntelliDraw(x, y, element, change_level, button);
11329 SetElementSimpleExt(x, y, dx, dy, element, change_level);
11332 static void SetElement(int x, int y, int element)
11334 SetElementExt(x, y, 0, 0, element, TRUE, -1);
11337 static void SetElementButton(int x, int y, int dx, int dy, int element,
11340 SetElementExt(x, y, dx, dy, element, TRUE, button);
11343 static void SetElementHiRes(int sx2, int sy2, int element, boolean change_level)
11345 int lx = getLoResScreenPos(sx2) + level_xpos;
11346 int ly = getLoResScreenPos(sy2) + level_ypos;
11347 int dx = getLoResScreenMod(sx2);
11348 int dy = getLoResScreenMod(sy2);
11350 SetElementExt(lx, ly, dx, dy, element, change_level, -1);
11353 static void SetLevelElementHiRes(int lx2, int ly2, int element)
11360 SetElementExt(lx, ly, dx, dy, element, TRUE, -1);
11363 static int getLevelElementHiRes(int lx2, int ly2)
11369 int element = Feld[lx][ly];
11370 unsigned int bitmask = (dx + 1) << (dy * 2);
11372 if (IS_MM_WALL(element))
11374 if (element & bitmask)
11375 return map_mm_wall_element(element);
11383 static void DrawLineElement(int x, int y, int element, boolean change_level)
11385 SetElementHiRes(x, y, element, change_level);
11388 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
11389 int element, boolean change_level)
11391 int xsize = ABS(to_x - from_x);
11392 int ysize = ABS(to_y - from_y);
11393 int dx = (to_x < from_x ? -1 : +1);
11394 int dy = (to_y < from_y ? -1 : +1);
11397 if (from_y == to_y) /* horizontal line */
11399 for (i = 0; i <= xsize; i++)
11400 DrawLineElement(from_x + i * dx, from_y, element, change_level);
11402 else if (from_x == to_x) /* vertical line */
11404 for (i = 0; i <= ysize; i++)
11405 DrawLineElement(from_x, from_y + i * dy, element, change_level);
11407 else /* diagonal line */
11409 if (ysize < xsize) /* a < 1 */
11411 float a = (float)ysize / (float)xsize;
11413 for (i = 0; i <= xsize; i++)
11416 int y = dy * (int)(a * i + 0.5);
11418 DrawLineElement(from_x + x, from_y + y, element, change_level);
11423 float a = (float)xsize / (float)ysize;
11425 for (i = 0; i <= ysize; i++)
11427 int x = dx * (int)(a * i + 0.5);
11430 DrawLineElement(from_x + x, from_y + y, element, change_level);
11436 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
11437 int element, boolean change_level)
11439 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
11440 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
11441 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
11442 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
11445 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
11446 int element, boolean change_level)
11451 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
11453 for (y = from_y; y <= to_y; y++)
11454 DrawLine(from_x, y, to_x, y, element, change_level);
11457 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
11458 int element, boolean change_level)
11460 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
11461 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
11462 int len_x = ABS(to_x - from_x);
11463 int len_y = ABS(to_y - from_y);
11466 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
11468 /* not optimal (some points get drawn twice) but simple,
11469 and fast enough for the few points we are drawing */
11471 for (x = 0; x <= radius; x++)
11473 int sx, sy, sx2, sy2, lx, ly;
11475 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
11477 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
11478 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
11479 sx = getLoResScreenPos(sx2);
11480 sy = getLoResScreenPos(sy2);
11481 lx = sx + level_xpos;
11482 ly = sy + level_ypos;
11484 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
11485 DrawLineElement(sx2, sy2, element, change_level);
11488 for (y = 0; y <= radius; y++)
11490 int sx, sy, sx2, sy2, lx, ly;
11492 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
11494 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
11495 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
11496 sx = getLoResScreenPos(sx2);
11497 sy = getLoResScreenPos(sy2);
11498 lx = sx + level_xpos;
11499 ly = sy + level_ypos;
11501 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
11502 DrawLineElement(sx2, sy2, element, change_level);
11506 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
11507 int element, boolean change_level)
11509 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
11510 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
11512 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
11515 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
11517 #if DRAW_CIRCLES_BUTTON_AVAILABLE
11518 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
11519 int element, boolean change_level)
11521 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
11522 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
11523 int mirror_to_x2 = from_x - (to_x2 - from_x);
11524 int mirror_to_y2 = from_y - (to_y2 - from_y);
11526 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
11527 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
11528 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
11529 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element,change_level);
11533 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
11535 int from_sx, from_sy;
11539 swap_numbers(&from_x, &to_x);
11542 swap_numbers(&from_y, &to_y);
11544 from_sx = SX + from_x * ed_tilesize;
11545 from_sy = SY + from_y * ed_tilesize;
11546 to_sx = SX + (to_x + 1) * ed_tilesize - 1;
11547 to_sy = SY + (to_y + 1) * ed_tilesize - 1;
11549 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
11550 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
11551 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
11552 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
11554 if (from_x == to_x && from_y == to_y)
11555 MarkTileDirty(from_x/2, from_y/2);
11557 redraw_mask |= REDRAW_FIELD;
11560 static void DrawAreaBox(int from_x, int from_y, int to_x, int to_y,
11561 int element, boolean change_level)
11563 DrawBox(from_x, from_y, to_x, to_y, element, change_level);
11566 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
11567 int element, boolean change_level)
11569 if (element == -1 || change_level)
11570 DrawAreaBox(from_x, from_y, to_x, to_y, -1, FALSE);
11572 DrawAreaBorder(from_x, from_y, to_x, to_y);
11575 /* values for CopyBrushExt() */
11576 #define CB_AREA_TO_BRUSH 0
11577 #define CB_BRUSH_TO_CURSOR 1
11578 #define CB_BRUSH_TO_LEVEL 2
11579 #define CB_DELETE_OLD_CURSOR 3
11580 #define CB_DUMP_BRUSH 4
11581 #define CB_DUMP_BRUSH_SMALL 5
11583 static void DrawBrushElement(int sx, int sy, int element, boolean change_level)
11585 DrawLineElement(sx, sy, element, change_level);
11588 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
11589 int button, int mode)
11591 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
11592 static int brush_width, brush_height;
11593 static int last_cursor_x = -1, last_cursor_y = -1;
11594 static boolean delete_old_brush;
11595 int new_element = BUTTON_ELEMENT(button);
11598 if (mode == CB_DUMP_BRUSH ||
11599 mode == CB_DUMP_BRUSH_SMALL)
11601 if (!draw_with_brush)
11603 Error(ERR_WARN, "no brush selected");
11608 for (y = 0; y < brush_height; y++)
11610 for (x = 0; x < brush_width; x++)
11612 int element = brush_buffer[x][y];
11613 int element_mapped = element;
11615 if (IS_CUSTOM_ELEMENT(element))
11616 element_mapped = EL_CUSTOM_START;
11617 else if (IS_GROUP_ELEMENT(element))
11618 element_mapped = EL_GROUP_START;
11619 else if (element >= NUM_FILE_ELEMENTS)
11620 element_mapped = EL_UNKNOWN;
11622 // dump brush as level sketch text for the R'n'D forum:
11623 // - large tiles: `xxx (0x60 ASCII)
11624 // - small tiles: ¸xxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
11625 printf("%s%03d", (mode == CB_DUMP_BRUSH ? "`" : "¸"), element_mapped);
11634 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
11637 if (mode == CB_AREA_TO_BRUSH)
11639 int from_lx, from_ly;
11642 swap_numbers(&from_x, &to_x);
11645 swap_numbers(&from_y, &to_y);
11647 brush_width = to_x - from_x + 1;
11648 brush_height = to_y - from_y + 1;
11650 from_lx = from_x + level_xpos;
11651 from_ly = from_y + level_ypos;
11653 for (y = 0; y < brush_height; y++)
11655 for (x = 0; x < brush_width; x++)
11657 brush_buffer[x][y] = Feld[from_lx + x][from_ly + y];
11660 DrawBrushElement(from_x + x, from_y + y, new_element, TRUE);
11665 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
11667 delete_old_brush = FALSE;
11669 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
11670 mode == CB_BRUSH_TO_LEVEL)
11672 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
11673 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
11674 int cursor_from_x = cursor_x - brush_width / 2;
11675 int cursor_from_y = cursor_y - brush_height / 2;
11676 int border_from_x = cursor_x, border_from_y = cursor_y;
11677 int border_to_x = cursor_x, border_to_y = cursor_y;
11679 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
11680 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
11682 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
11683 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
11685 delete_old_brush = FALSE;
11689 for (y = 0; y < brush_height; y++)
11691 for (x = 0; x < brush_width; x++)
11693 int sx = cursor_from_x + x;
11694 int sy = cursor_from_y + y;
11695 int lx = sx + level_xpos;
11696 int ly = sy + level_ypos;
11697 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
11698 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
11699 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
11700 brush_buffer[x][y] : new_element);
11702 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
11704 if (sx < border_from_x)
11705 border_from_x = sx;
11706 else if (sx > border_to_x)
11708 if (sy < border_from_y)
11709 border_from_y = sy;
11710 else if (sy > border_to_y)
11713 DrawBrushElement(sx, sy, element, change_level);
11718 if (mode != CB_DELETE_OLD_CURSOR)
11719 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
11721 last_cursor_x = cursor_x;
11722 last_cursor_y = cursor_y;
11723 delete_old_brush = TRUE;
11727 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
11730 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
11733 static void CopyBrushToLevel(int x, int y, int button)
11735 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
11738 static void CopyBrushToCursor(int x, int y)
11740 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
11743 static void DeleteBrushFromCursor()
11745 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
11750 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
11753 void DumpBrush_Small()
11755 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
11758 static void FloodFill(int from_x, int from_y, int fill_element)
11760 FloodFillLevel(from_x, from_y, fill_element, Feld, lev_fieldx, lev_fieldy);
11763 static void FloodFillWall_MM(int from_sx2, int from_sy2, int fill_element)
11765 int from_x = from_sx2 + 2 * level_xpos;
11766 int from_y = from_sy2 + 2 * level_ypos;
11767 int max_fillx = lev_fieldx * 2;
11768 int max_filly = lev_fieldy * 2;
11769 short FillFeld[max_fillx][max_filly];
11772 for (x = 0; x < max_fillx; x++)
11773 for (y = 0; y < max_filly; y++)
11774 FillFeld[x][y] = getLevelElementHiRes(x, y);
11776 FloodFillLevelExt(from_x, from_y, fill_element, max_fillx, max_filly,
11777 FillFeld, max_fillx, max_filly);
11779 for (x = 0; x < max_fillx; x++)
11780 for (y = 0; y < max_filly; y++)
11781 if (FillFeld[x][y] == fill_element)
11782 SetLevelElementHiRes(x, y, FillFeld[x][y]);
11785 /* values for DrawLevelText() modes */
11786 #define TEXT_INIT 0
11787 #define TEXT_SETCURSOR 1
11788 #define TEXT_WRITECHAR 2
11789 #define TEXT_BACKSPACE 3
11790 #define TEXT_NEWLINE 4
11792 #define TEXT_QUERY_TYPING 6
11794 static int DrawLevelText(int sx, int sy, char letter, int mode)
11796 static short delete_buffer[MAX_LEV_FIELDX];
11797 static int start_sx;
11798 static int last_sx, last_sy;
11799 static boolean typing = FALSE;
11800 int letter_element = EL_CHAR_ASCII0 + letter;
11801 int lx = 0, ly = 0;
11803 /* map lower case letters to upper case and convert special characters */
11804 if (letter >= 'a' && letter <= 'z')
11805 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
11806 else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
11807 letter_element = EL_CHAR_AUMLAUT;
11808 else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
11809 letter_element = EL_CHAR_OUMLAUT;
11810 else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
11811 letter_element = EL_CHAR_UUMLAUT;
11812 else if (letter == '^')
11813 letter_element = EL_CHAR_COPYRIGHT;
11815 letter_element = EL_CHAR_ASCII0 + letter;
11817 if (mode != TEXT_INIT)
11822 if (mode != TEXT_SETCURSOR)
11828 lx = last_sx + level_xpos;
11829 ly = last_sy + level_ypos;
11836 DrawLevelText(0, 0, 0, TEXT_END);
11842 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
11845 case TEXT_SETCURSOR:
11846 DrawEditorElement(last_sx, last_sy, Feld[lx][ly]);
11847 DrawAreaBorder(sx, sy, sx, sy);
11852 case TEXT_WRITECHAR:
11853 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
11855 if (new_element1 >= EL_STEEL_CHAR_START &&
11856 new_element1 <= EL_STEEL_CHAR_END)
11857 letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
11859 delete_buffer[sx - start_sx] = Feld[lx][ly];
11860 Feld[lx][ly] = letter_element;
11862 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
11863 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
11864 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
11865 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
11867 DrawLevelText(0, 0, 0, TEXT_END);
11869 level.changed = TRUE;
11873 case TEXT_BACKSPACE:
11876 Feld[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
11877 DrawEditorElement(sx - 1, sy, Feld[lx - 1][ly]);
11878 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
11883 if (sy + 1 < ed_fieldy - 1 && ly + 1 < lev_fieldy - 1)
11884 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
11886 DrawLevelText(0, 0, 0, TEXT_END);
11890 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
11891 DrawEditorElement(sx, sy, Feld[lx][ly]);
11895 case TEXT_QUERY_TYPING:
11905 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
11906 int element, boolean change_level)
11908 int lx = sx + level_xpos;
11909 int ly = sy + level_ypos;
11912 DrawEditorElement(sx, sy, Feld[lx][ly]);
11914 DrawAreaBorder(sx, sy, sx, sy);
11917 static void CheckLevelBorderElement(boolean redraw_playfield)
11919 int last_border_element = BorderElement;
11921 SetBorderElement();
11923 if (redraw_playfield && BorderElement != last_border_element)
11924 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11927 static void CopyLevelToUndoBuffer(int mode)
11929 static boolean accumulated_undo = FALSE;
11930 boolean new_undo_buffer_position = TRUE;
11933 if (undo_buffer_steps == 0)
11934 accumulated_undo = FALSE;
11938 case UNDO_IMMEDIATE:
11939 accumulated_undo = FALSE;
11942 case UNDO_ACCUMULATE:
11943 if (accumulated_undo)
11944 new_undo_buffer_position = FALSE;
11945 accumulated_undo = TRUE;
11952 if (new_undo_buffer_position)
11954 /* advance position in undo buffer ring */
11955 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
11957 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
11958 undo_buffer_steps++;
11961 /* always reset redo buffer when storing level change into undo buffer */
11962 redo_buffer_steps = 0;
11964 for (x = 0; x < lev_fieldx; x++)
11965 for (y = 0; y < lev_fieldy; y++)
11966 UndoBuffer[undo_buffer_position][x][y] = Feld[x][y];
11968 /* check if drawing operation forces change of border style */
11969 CheckLevelBorderElement(TRUE);
11971 level.changed = TRUE;
11974 static void RandomPlacement(int new_element)
11976 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
11977 int num_free_positions = 0;
11978 int num_percentage, num_elements;
11981 ResetIntelliDraw();
11983 /* determine number of free positions for randomly placing the new element */
11984 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
11986 free_position[x][y] =
11987 (random_placement_background_restricted ?
11988 Feld[x][y] == random_placement_background_element :
11989 Feld[x][y] != new_element);
11991 if (free_position[x][y])
11992 num_free_positions++;
11995 /* determine number of new elements to place there */
11996 num_percentage = num_free_positions * random_placement_value / 100;
11997 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
11998 num_percentage : random_placement_value);
12000 /* if less free positions than elements to place, fill all these positions */
12001 if (num_free_positions < num_elements)
12003 for (x = 0; x < lev_fieldx; x++)
12004 for (y = 0; y < lev_fieldy; y++)
12005 if (free_position[x][y])
12006 SetElement(x, y, new_element);
12010 while (num_elements > 0)
12012 x = GetSimpleRandom(lev_fieldx);
12013 y = GetSimpleRandom(lev_fieldy);
12015 /* don't place element at the same position twice */
12016 if (free_position[x][y])
12018 free_position[x][y] = FALSE;
12019 SetElement(x, y, new_element);
12025 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12026 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12029 void WrapLevel(int dx, int dy)
12031 int wrap_dx = lev_fieldx - dx;
12032 int wrap_dy = lev_fieldy - dy;
12035 for (x = 0; x < lev_fieldx; x++)
12036 for (y = 0; y < lev_fieldy; y++)
12037 FieldBackup[x][y] = Feld[x][y];
12039 for (x = 0; x < lev_fieldx; x++)
12040 for (y = 0; y < lev_fieldy; y++)
12042 FieldBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
12044 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12045 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
12048 static void HandleDrawingAreas(struct GadgetInfo *gi)
12050 static boolean started_inside_drawing_area = FALSE;
12051 static int last_sx = -1, last_sy = -1;
12052 static int last_sx2 = -1, last_sy2 = -1;
12053 int id = gi->custom_id;
12054 int type_id = gi->custom_type_id;
12055 boolean button_press_event;
12056 boolean button_release_event;
12057 boolean inside_drawing_area = !gi->event.off_borders;
12058 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
12059 int actual_drawing_function;
12060 int button = gi->event.button;
12061 int new_element = BUTTON_ELEMENT(button);
12062 int sx = gi->event.x, sy = gi->event.y;
12063 int min_sx = 0, min_sy = 0;
12064 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
12065 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
12066 int mini_item_xsize = item_xsize / 2, mini_item_ysize = item_ysize / 2;
12067 int sx2 = gi->event.mx / mini_item_xsize;
12068 int sy2 = gi->event.my / mini_item_ysize;
12071 int lx = 0, ly = 0;
12072 int min_lx = 0, min_ly = 0;
12073 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
12076 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
12077 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
12079 /* make sure to stay inside drawing area boundaries */
12080 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
12081 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
12085 /* get positions inside level field */
12086 lx = sx + level_xpos;
12087 ly = sy + level_ypos;
12089 if (!IN_LEV_FIELD(lx, ly))
12090 inside_drawing_area = FALSE;
12092 /* make sure to stay inside level field boundaries */
12093 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
12094 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
12096 /* correct drawing area positions accordingly */
12097 sx = lx - level_xpos;
12098 sy = ly - level_ypos;
12101 /* also correct MM wall-sized (double) drawing area positions accordingly */
12102 if (sx2 / 2 < sx || sx2 / 2 > sx)
12104 dx = (sx2 / 2 < sx ? 0 : 1);
12107 if (sy2 / 2 < sy || sy2 / 2 > sy)
12109 dy = (sy2 / 2 < sy ? 0 : 1);
12113 if (button_release_event)
12120 else if (!button_press_event)
12122 /* prevent handling events for every pixel position when moving mouse */
12123 if ((sx == last_sx && sy == last_sy &&
12124 !IS_MM_WALL_EDITOR(new_element) && new_element != EL_EMPTY) ||
12125 (sx2 == last_sx2 && sy2 == last_sy2))
12134 if (button_press_event)
12135 started_inside_drawing_area = inside_drawing_area;
12137 if (!started_inside_drawing_area)
12140 if (!IS_VALID_BUTTON(button))
12143 if (!button && !button_release_event)
12146 /* handle info callback for each invocation of action callback */
12147 gi->callback_info(gi);
12149 /* automatically switch to 'single item' drawing mode, if needed */
12150 actual_drawing_function =
12151 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
12152 drawing_function : GADGET_ID_SINGLE_ITEMS);
12154 /* clicking into drawing area with pressed Control key picks element */
12155 if (GetKeyModState() & KMOD_Control)
12157 last_drawing_function = drawing_function;
12158 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
12161 if (GetKeyModState() & KMOD_Shift)
12163 if (button_press_event || button_release_event)
12164 ResetIntelliDraw();
12167 SetDrawModeHiRes(-1); /* reset to normal draw mode */
12169 switch (actual_drawing_function)
12171 case GADGET_ID_SINGLE_ITEMS:
12174 if (button_release_event)
12176 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12178 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
12179 !inside_drawing_area)
12180 DeleteBrushFromCursor();
12183 if (!button || button_release_event)
12186 if (draw_with_brush)
12188 CopyBrushToLevel(sx, sy, button);
12192 SetDrawModeHiRes(new_element);
12194 if (new_element == EL_PLAYER_1)
12196 /* remove player at old position */
12197 for (y = 0; y < lev_fieldy; y++)
12198 for (x = 0; x < lev_fieldx; x++)
12199 if (Feld[x][y] == EL_PLAYER_1)
12200 SetElement(x, y, EL_EMPTY);
12203 SetElementButton(lx, ly, dx, dy, new_element, button);
12206 else if (!button_release_event)
12208 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
12210 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
12211 DrawMiniGraphicExt(drawto,
12212 gi->x + sx * MINI_TILEX,
12213 gi->y + sy * MINI_TILEY,
12214 el2edimg(new_element));
12216 DrawFixedGraphicExt(drawto,
12217 gi->x + sx * TILEX,
12218 gi->y + sy * TILEY,
12219 el2edimg(new_element), 0);
12221 if (id == GADGET_ID_CUSTOM_GRAPHIC)
12222 new_element = GFX_ELEMENT(new_element);
12224 drawingarea_info[type_id].value[pos] = new_element;
12226 CopyElementPropertiesToGame(properties_element);
12228 if (id == GADGET_ID_CUSTOM_GRAPHIC)
12230 UpdateCustomElementGraphicGadgets();
12232 FrameCounter = 0; /* restart animation frame counter */
12237 case GADGET_ID_CONNECTED_ITEMS:
12239 static int last_sx = -1;
12240 static int last_sy = -1;
12242 if (button_release_event)
12243 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12247 SetDrawModeHiRes(new_element);
12249 if (getDrawModeHiRes())
12255 if (!button_press_event)
12256 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
12264 case GADGET_ID_LINE:
12265 case GADGET_ID_ARC:
12266 case GADGET_ID_RECTANGLE:
12267 case GADGET_ID_FILLED_BOX:
12268 SetDrawModeHiRes(new_element);
12270 if (getDrawModeHiRes())
12276 case GADGET_ID_GRAB_BRUSH:
12277 case GADGET_ID_TEXT:
12279 static int last_sx = -1;
12280 static int last_sy = -1;
12281 static int start_sx = -1;
12282 static int start_sy = -1;
12283 void (*draw_func)(int, int, int, int, int, boolean);
12285 if (drawing_function == GADGET_ID_LINE)
12286 draw_func = DrawLine;
12287 else if (drawing_function == GADGET_ID_ARC)
12288 draw_func = DrawArc;
12289 else if (drawing_function == GADGET_ID_RECTANGLE)
12290 draw_func = DrawBox;
12291 else if (drawing_function == GADGET_ID_FILLED_BOX)
12292 draw_func = DrawFilledBox;
12293 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
12294 draw_func = SelectArea;
12295 else /* (drawing_function == GADGET_ID_TEXT) */
12296 draw_func = SetTextCursor;
12298 if (button_press_event)
12300 draw_func(sx, sy, sx, sy, new_element, FALSE);
12301 start_sx = last_sx = sx;
12302 start_sy = last_sy = sy;
12304 if (drawing_function == GADGET_ID_TEXT)
12305 DrawLevelText(0, 0, 0, TEXT_END);
12307 else if (button_release_event)
12309 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
12310 if (drawing_function == GADGET_ID_GRAB_BRUSH)
12312 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
12313 CopyBrushToCursor(sx, sy);
12314 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
12316 draw_with_brush = TRUE;
12318 else if (drawing_function == GADGET_ID_TEXT)
12319 DrawLevelText(sx, sy, 0, TEXT_INIT);
12321 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12323 else if (last_sx != sx || last_sy != sy)
12325 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
12326 if (IS_MM_WALL_EDITOR(new_element)) /* clear wall background */
12327 draw_func(start_sx, start_sy, sx, sy, EL_EMPTY, FALSE);
12328 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
12335 case GADGET_ID_FLOOD_FILL:
12336 if (button_press_event && Feld[lx][ly] != new_element)
12338 if (IS_MM_WALL_EDITOR(new_element))
12339 FloodFillWall_MM(sx2, sy2, new_element);
12341 FloodFill(lx, ly, new_element);
12343 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12344 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12348 case GADGET_ID_PICK_ELEMENT:
12349 if (button_release_event)
12350 ClickOnGadget(level_editor_gadget[last_drawing_function],
12352 else if (draw_level)
12353 PickDrawingElement(button, Feld[lx][ly]);
12356 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
12358 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
12365 /* do not mark level as modified for certain non-level-changing gadgets */
12366 if ((type_id >= ED_DRAWING_ID_EDITOR_FIRST &&
12367 type_id <= ED_DRAWING_ID_EDITOR_LAST) ||
12368 actual_drawing_function == GADGET_ID_GRAB_BRUSH ||
12369 actual_drawing_function == GADGET_ID_PICK_ELEMENT)
12372 level.changed = TRUE;
12375 static void HandleCounterButtons(struct GadgetInfo *gi)
12377 int gadget_id = gi->custom_id;
12378 int counter_id = gi->custom_type_id;
12379 int button = gi->event.button;
12380 int *counter_value = counterbutton_info[counter_id].value;
12381 int step = BUTTON_STEPSIZE(button) *
12382 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
12384 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
12386 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
12387 boolean released = (gi->event.type == GD_EVENT_RELEASED);
12388 boolean level_changed = LevelChanged();
12390 if ((level_changed && pressed) || (!level_changed && released))
12393 if (level_changed && !Request("Level has changed! Discard changes?",
12396 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
12397 ModifyEditorCounterValue(counter_id, *counter_value);
12403 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
12404 *counter_value = gi->textinput.number_value;
12406 ModifyEditorCounterValue(counter_id, *counter_value + step);
12408 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
12410 int last_game_engine_type = level.game_engine_type;
12412 LoadLevel(level_nr);
12413 LoadScore(level_nr);
12415 SaveLevelSetup_SeriesInfo();
12420 DrawEditModeWindow();
12422 if (level.game_engine_type != last_game_engine_type)
12424 /* update element selection list */
12425 ReinitializeElementList();
12426 ModifyEditorElementList();
12432 switch (counter_id)
12434 case ED_COUNTER_ID_YAMYAM_CONTENT:
12435 DrawYamYamContentAreas();
12438 case ED_COUNTER_ID_BALL_CONTENT:
12439 DrawMagicBallContentAreas();
12442 case ED_COUNTER_ID_ANDROID_CONTENT:
12443 DrawAndroidElementArea(properties_element);
12446 case ED_COUNTER_ID_GROUP_CONTENT:
12447 DrawGroupElementArea(properties_element);
12448 CopyGroupElementPropertiesToGame(properties_element);
12451 case ED_COUNTER_ID_INVENTORY_SIZE:
12452 DrawPlayerInitialInventoryArea(properties_element);
12455 case ED_COUNTER_ID_ENVELOPE_XSIZE:
12456 case ED_COUNTER_ID_ENVELOPE_YSIZE:
12457 DrawEnvelopeTextArea(-1);
12460 case ED_COUNTER_ID_LEVEL_XSIZE:
12461 case ED_COUNTER_ID_LEVEL_YSIZE:
12462 lev_fieldx = level.fieldx;
12463 lev_fieldy = level.fieldy;
12465 /* check if resizing of level results in change of border border */
12466 SetBorderElement();
12474 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
12475 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
12476 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
12477 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
12478 CopyElementPropertiesToGame(properties_element);
12480 /* do not mark level as modified for certain non-level-changing gadgets */
12481 if ((counter_id >= ED_COUNTER_ID_LEVELSET_FIRST &&
12482 counter_id <= ED_COUNTER_ID_LEVELSET_LAST) ||
12483 (counter_id >= ED_COUNTER_ID_EDITOR_FIRST &&
12484 counter_id <= ED_COUNTER_ID_EDITOR_LAST))
12487 level.changed = TRUE;
12490 static void HandleTextInputGadgets(struct GadgetInfo *gi)
12492 int type_id = gi->custom_type_id;
12494 strcpy(textinput_info[type_id].value, gi->textinput.value);
12496 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
12498 CopyElementPropertiesToGame(properties_element);
12500 ModifyEditorElementList(); /* update changed button info text */
12503 /* do not mark level as modified for certain non-level-changing gadgets */
12504 if (type_id >= ED_TEXTINPUT_ID_LEVELSET_FIRST &&
12505 type_id <= ED_TEXTINPUT_ID_LEVELSET_LAST)
12508 level.changed = TRUE;
12511 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
12513 int type_id = gi->custom_type_id;
12515 strncpy(textarea_info[type_id].value, gi->textarea.value,
12516 MAX_ENVELOPE_TEXT_LEN);
12517 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
12519 level.changed = TRUE;
12522 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
12524 int type_id = gi->custom_type_id;
12525 int value_old = *selectbox_info[type_id].value;
12526 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
12528 *selectbox_info[type_id].value = value_new;
12530 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE)
12532 DrawLevelInfoWindow();
12534 else if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
12536 element_info[properties_element].current_change_page = gi->selectbox.index;
12538 DrawPropertiesWindow();
12540 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
12541 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
12542 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
12543 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
12544 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
12546 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
12548 /* when changing action type, also check action mode and action arg */
12549 if (value_old != value_new)
12550 setSelectboxSpecialActionVariablesIfNeeded();
12552 DrawPropertiesChange();
12555 CopyElementPropertiesToGame(properties_element);
12557 else if (type_id == ED_SELECTBOX_ID_GAME_ENGINE_TYPE)
12559 /* update element selection list */
12560 ReinitializeElementList();
12561 ModifyEditorElementList();
12564 /* do not mark level as modified for certain non-level-changing gadgets */
12565 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE ||
12566 type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
12569 level.changed = TRUE;
12572 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
12574 int type_id = gi->custom_type_id;
12577 if (type_id >= ED_TAB_BUTTON_ID_LEVELINFO_FIRST &&
12578 type_id <= ED_TAB_BUTTON_ID_LEVELINFO_LAST)
12580 edit_mode_levelinfo = gi->custom_type_id;
12582 DrawLevelInfoWindow();
12584 else if (type_id >= ED_TAB_BUTTON_ID_PROPERTIES_FIRST &&
12585 type_id <= ED_TAB_BUTTON_ID_PROPERTIES_LAST)
12587 edit_mode_properties = gi->custom_type_id;
12589 DrawPropertiesWindow();
12591 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 ||
12592 type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2)
12594 boolean new_template = !fileExists(getLocalLevelTemplateFilename());
12596 /* backup original "level.field" (needed to track playfield changes) */
12597 CopyPlayfield(level.field, FieldBackup);
12599 /* "SaveLevelTemplate()" uses "level.field", so copy editor playfield */
12600 CopyPlayfield(Feld, level.field);
12602 if (new_template ||
12603 Request("Save this template and kill the old?", REQ_ASK))
12604 SaveLevelTemplate();
12607 Request("Template saved!", REQ_CONFIRM);
12609 /* restore original "level.field" (needed to track playfield changes) */
12610 CopyPlayfield(FieldBackup, level.field);
12612 else if (type_id == ED_TEXTBUTTON_ID_SAVE_LEVELSET)
12614 char *levelset_subdir = getLevelSubdirFromSaveMode(levelset_save_mode);
12616 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE &&
12617 leveldir_current->readonly)
12619 Request("This level set is read only!", REQ_CONFIRM);
12624 if (strEqual(levelset_name, ""))
12626 Request("Please enter level set title!", REQ_CONFIRM);
12631 if (strEqual(levelset_author, ""))
12633 Request("Please enter level set author!", REQ_CONFIRM);
12638 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE)
12640 if (UpdateUserLevelSet(levelset_subdir,
12643 levelset_num_levels,
12644 levelset_first_level_nr))
12646 Request("Level set updated!", REQ_CONFIRM);
12650 Request("Updating level set failed!", REQ_CONFIRM);
12655 if (CreateUserLevelSet(levelset_subdir,
12658 levelset_num_levels,
12661 Request("New level set created!", REQ_CONFIRM);
12663 AddUserLevelSetToLevelInfo(levelset_subdir);
12664 ChangeEditorToLevelSet(levelset_subdir);
12668 Request("Creating new level set failed!", REQ_CONFIRM);
12672 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
12673 custom_element.num_change_pages < MAX_CHANGE_PAGES)
12675 struct ElementInfo *ei = &element_info[properties_element];
12677 /* when modifying custom element, ask for copying level template */
12678 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
12681 setElementChangePages(ei, ei->num_change_pages + 1);
12683 /* set new change page to be new current change page */
12684 ei->current_change_page = ei->num_change_pages - 1;
12685 ei->change = &ei->change_page[ei->current_change_page];
12687 setElementChangeInfoToDefaults(ei->change);
12689 DrawPropertiesWindow();
12691 level.changed = TRUE;
12693 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
12694 custom_element.num_change_pages > MIN_CHANGE_PAGES)
12696 struct ElementInfo *ei = &element_info[properties_element];
12698 /* when modifying custom element, ask for copying level template */
12699 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
12702 /* copy all change pages after change page to be deleted */
12703 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
12704 ei->change_page[i] = ei->change_page[i + 1];
12706 setElementChangePages(ei, ei->num_change_pages - 1);
12708 DrawPropertiesWindow();
12710 level.changed = TRUE;
12714 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
12716 int type_id = gi->custom_type_id;
12718 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
12719 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
12721 struct ElementInfo *ei = &element_info[properties_element];
12722 int step = BUTTON_STEPSIZE(gi->event.button);
12724 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
12725 ei->current_change_page += step;
12727 if (ei->current_change_page < 0)
12728 ei->current_change_page = 0;
12729 else if (ei->current_change_page >= ei->num_change_pages)
12730 ei->current_change_page = ei->num_change_pages - 1;
12732 DrawPropertiesWindow();
12734 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
12735 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
12737 struct ElementInfo *ei = &element_info[properties_element];
12738 int current_change_page = ei->current_change_page;
12740 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
12742 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
12743 ei->change_page[current_change_page];
12745 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
12747 /* when modifying custom element, ask for copying level template */
12748 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
12751 ei->change_page[current_change_page] =
12752 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
12754 level.changed = TRUE;
12757 DrawPropertiesWindow();
12761 static void HandleRadiobuttons(struct GadgetInfo *gi)
12763 int type_id = gi->custom_type_id;
12765 *radiobutton_info[type_id].value =
12766 radiobutton_info[type_id].checked_value;
12768 /* do not mark level as modified for certain non-level-changing gadgets */
12769 if (type_id >= ED_RADIOBUTTON_ID_EDITOR_FIRST &&
12770 type_id <= ED_RADIOBUTTON_ID_EDITOR_LAST)
12773 level.changed = TRUE;
12776 static void HandleCheckbuttons(struct GadgetInfo *gi)
12778 int type_id = gi->custom_type_id;
12780 *checkbutton_info[type_id].value ^= TRUE;
12782 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
12783 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
12784 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
12785 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
12786 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
12787 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
12788 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
12789 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1))
12791 CopyElementPropertiesToGame(properties_element);
12794 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
12796 UpdateCustomElementGraphicGadgets();
12798 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 ||
12799 type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2)
12801 boolean template_related_changes_found = FALSE;
12804 /* check if any custom or group elements have been changed */
12805 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
12806 if ((IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)) &&
12807 element_info[i].modified_settings)
12808 template_related_changes_found = TRUE;
12810 if (level.use_custom_template &&
12811 !fileExists(getGlobalLevelTemplateFilename()))
12813 Request("No level template found!", REQ_CONFIRM);
12815 level.use_custom_template = FALSE;
12817 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
12822 if (level.use_custom_template &&
12823 template_related_changes_found &&
12824 !Request("Discard changes and use level template?", REQ_ASK))
12826 level.use_custom_template = FALSE;
12828 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
12833 if (!level.use_custom_template &&
12834 Request("Copy settings from level template?", REQ_ASK))
12839 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
12841 DrawEditModeWindow();
12843 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3)
12845 if (setup.editor.use_template_for_new_levels &&
12846 !fileExists(getGlobalLevelTemplateFilename()))
12848 Request("No level template found!", REQ_CONFIRM);
12853 if (setup.editor.use_template_for_new_levels &&
12855 !Request("Discard level and load template?", REQ_ASK))
12860 if (!setup.editor.use_template_for_new_levels &&
12862 !Request("Discard level and use empty level?", REQ_ASK))
12867 LoadLevel(level_nr);
12868 LoadScore(level_nr);
12873 DrawEditModeWindow();
12875 else if (type_id == ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS)
12877 SetAutomaticNumberOfGemsNeeded();
12880 /* do not mark level as modified for certain non-level-changing gadgets */
12881 if ((type_id >= ED_CHECKBUTTON_ID_EDITOR_FIRST &&
12882 type_id <= ED_CHECKBUTTON_ID_EDITOR_LAST) ||
12883 type_id == ED_CHECKBUTTON_ID_STICK_ELEMENT)
12886 level.changed = TRUE;
12889 static void HandleControlButtons(struct GadgetInfo *gi)
12891 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
12892 static int last_edit_mode = ED_MODE_DRAWING;
12893 static int last_custom_copy_mode = -1;
12894 static int last_button = 0;
12895 int id = gi->custom_id;
12896 int button = gi->event.button;
12897 int step = BUTTON_STEPSIZE(button);
12898 int new_element = BUTTON_ELEMENT(button);
12899 int last_properties_element = properties_element;
12902 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
12903 DrawLevelText(0, 0, 0, TEXT_END);
12905 if (id < ED_NUM_CTRL1_BUTTONS &&
12906 id != GADGET_ID_SINGLE_ITEMS &&
12907 id != GADGET_ID_PICK_ELEMENT &&
12908 edit_mode != ED_MODE_DRAWING &&
12909 drawing_function != GADGET_ID_PICK_ELEMENT &&
12910 !(GetKeyModState() & KMOD_Control))
12911 ChangeEditModeWindow(ED_MODE_DRAWING);
12913 /* element copy mode active, but no element button pressed => deactivate */
12914 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
12915 last_custom_copy_mode = -1;
12917 /* when showing palette on element buttons, change element of button used */
12918 if (editor.palette.show_on_element_buttons &&
12919 id >= GADGET_ID_ELEMENT_LEFT && id <= GADGET_ID_ELEMENT_RIGHT)
12921 last_button = id - GADGET_ID_ELEMENT_LEFT + 1;
12923 id = GADGET_ID_PALETTE;
12928 case GADGET_ID_SCROLL_LEFT:
12929 if (level_xpos >= 0)
12931 if (lev_fieldx < ed_fieldx - 2)
12934 level_xpos -= step;
12935 if (level_xpos < -1)
12938 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
12940 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12942 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
12943 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
12947 case GADGET_ID_SCROLL_RIGHT:
12948 if (level_xpos <= lev_fieldx - ed_fieldx)
12950 if (lev_fieldx < ed_fieldx - 2)
12953 level_xpos += step;
12954 if (level_xpos > lev_fieldx - ed_fieldx + 1)
12955 level_xpos = lev_fieldx - ed_fieldx + 1;
12957 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
12959 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12961 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
12962 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
12966 case GADGET_ID_SCROLL_UP:
12967 if (level_ypos >= 0)
12969 if (lev_fieldy < ed_fieldy - 2)
12972 level_ypos -= step;
12973 if (level_ypos < -1)
12976 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
12978 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12980 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
12981 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
12985 case GADGET_ID_SCROLL_DOWN:
12986 if (level_ypos <= lev_fieldy - ed_fieldy)
12988 if (lev_fieldy < ed_fieldy - 2)
12991 level_ypos += step;
12992 if (level_ypos > lev_fieldy - ed_fieldy + 1)
12993 level_ypos = lev_fieldy - ed_fieldy + 1;
12995 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
12997 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12999 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
13000 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
13004 case GADGET_ID_SCROLL_HORIZONTAL:
13005 level_xpos = gi->event.item_position - 1;
13007 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13012 case GADGET_ID_SCROLL_VERTICAL:
13013 level_ypos = gi->event.item_position - 1;
13015 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13020 case GADGET_ID_SCROLL_LIST_UP:
13021 case GADGET_ID_SCROLL_LIST_DOWN:
13022 case GADGET_ID_SCROLL_LIST_VERTICAL:
13023 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
13024 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
13027 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
13028 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
13030 if (element_shift < 0)
13032 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
13033 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
13035 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
13036 GDI_SCROLLBAR_ITEM_POSITION,
13037 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
13040 ModifyEditorElementList();
13044 case GADGET_ID_PROPERTIES:
13045 // always switch off element properties when they are already displayed
13046 last_properties_element = new_element;
13047 case GADGET_ID_ELEMENT_LEFT:
13048 case GADGET_ID_ELEMENT_MIDDLE:
13049 case GADGET_ID_ELEMENT_RIGHT:
13050 properties_element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
13051 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
13052 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 :
13055 if (edit_mode != ED_MODE_PROPERTIES)
13057 last_edit_mode = edit_mode;
13059 ChangeEditModeWindow(ED_MODE_PROPERTIES);
13061 last_level_drawing_function = drawing_function;
13062 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
13065 else if (properties_element != last_properties_element)
13067 DrawEditModeWindow();
13071 ChangeEditModeWindow(last_edit_mode);
13073 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
13078 case GADGET_ID_PALETTE:
13079 if (edit_mode != ED_MODE_PALETTE)
13081 last_edit_mode = edit_mode;
13083 ChangeEditModeWindow(ED_MODE_PALETTE);
13087 ChangeEditModeWindow(last_edit_mode);
13091 case GADGET_ID_WRAP_LEFT:
13092 WrapLevel(-step, 0);
13095 case GADGET_ID_WRAP_RIGHT:
13096 WrapLevel(step, 0);
13099 case GADGET_ID_WRAP_UP:
13100 WrapLevel(0, -step);
13103 case GADGET_ID_WRAP_DOWN:
13104 WrapLevel(0, step);
13107 case GADGET_ID_SINGLE_ITEMS:
13108 case GADGET_ID_CONNECTED_ITEMS:
13109 case GADGET_ID_LINE:
13110 case GADGET_ID_ARC:
13111 case GADGET_ID_TEXT:
13112 case GADGET_ID_RECTANGLE:
13113 case GADGET_ID_FILLED_BOX:
13114 case GADGET_ID_FLOOD_FILL:
13115 case GADGET_ID_GRAB_BRUSH:
13116 case GADGET_ID_PICK_ELEMENT:
13117 if (drawing_function != GADGET_ID_PICK_ELEMENT)
13118 last_drawing_function = drawing_function;
13119 drawing_function = id;
13120 draw_with_brush = FALSE;
13123 case GADGET_ID_RANDOM_PLACEMENT:
13124 RandomPlacement(new_element);
13127 case GADGET_ID_ZOOM:
13128 // zoom level editor tile size in or out (or reset to default size)
13129 ed_tilesize = (button == 1 ? ed_tilesize * 2 :
13130 button == 2 ? DEFAULT_EDITOR_TILESIZE :
13131 button == 3 ? ed_tilesize / 2 : ed_tilesize);
13133 // limit zoom level by upper and lower bound
13134 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
13136 InitZoomLevelSettings(ed_tilesize);
13138 if (edit_mode == ED_MODE_DRAWING)
13140 DrawDrawingWindow();
13142 /* redraw zoom gadget info text */
13143 PrintEditorGadgetInfoText(level_editor_gadget[id]);
13146 /* save current editor zoom tilesize */
13147 SaveSetup_AutoSetup();
13151 case GADGET_ID_CUSTOM_COPY_FROM:
13152 case GADGET_ID_CUSTOM_COPY_TO:
13153 case GADGET_ID_CUSTOM_EXCHANGE:
13154 last_custom_copy_mode = id;
13155 last_drawing_function = drawing_function;
13158 case GADGET_ID_CUSTOM_COPY:
13159 CopyCustomElement(properties_element, -1, id);
13162 case GADGET_ID_CUSTOM_PASTE:
13163 CopyCustomElement(-1, properties_element, id);
13166 case GADGET_ID_UNDO:
13167 if (button == 1 && GetKeyModState() & (KMOD_Shift|KMOD_Control))
13170 if (button == 1 && undo_buffer_steps == 0)
13172 Request("Undo buffer empty!", REQ_CONFIRM);
13176 else if (button == 2)
13180 else if (button == 3 && redo_buffer_steps == 0)
13182 Request("Redo buffer empty!", REQ_CONFIRM);
13187 if (edit_mode != ED_MODE_DRAWING)
13188 ChangeEditModeWindow(ED_MODE_DRAWING);
13194 undo_buffer_position =
13195 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
13197 undo_buffer_steps--;
13198 redo_buffer_steps++;
13204 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
13206 undo_buffer_steps++;
13207 redo_buffer_steps--;
13210 for (x = 0; x < lev_fieldx; x++)
13211 for (y = 0; y < lev_fieldy; y++)
13212 Feld[x][y] = UndoBuffer[undo_buffer_position][x][y];
13214 /* check if undo operation forces change of border style */
13215 CheckLevelBorderElement(FALSE);
13217 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13221 case GADGET_ID_INFO:
13222 if (edit_mode != ED_MODE_INFO)
13224 last_edit_mode = edit_mode;
13226 ChangeEditModeWindow(ED_MODE_INFO);
13230 ChangeEditModeWindow(last_edit_mode);
13234 case GADGET_ID_CLEAR:
13235 if (edit_mode != ED_MODE_DRAWING)
13236 ChangeEditModeWindow(ED_MODE_DRAWING);
13238 for (x = 0; x < MAX_LEV_FIELDX; x++)
13239 for (y = 0; y < MAX_LEV_FIELDY; y++)
13240 Feld[x][y] = (button == 1 ? EL_EMPTY : new_element);
13242 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
13244 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13247 case GADGET_ID_SAVE:
13249 /* saving read-only levels into personal level set modifies global vars
13250 "leveldir_current" and "level_nr"; restore them after saving level */
13251 LevelDirTree *leveldir_former = leveldir_current;
13252 int level_nr_former = level_nr;
13253 char *level_filename;
13256 if (leveldir_current->readonly &&
13257 !PrepareSavingIntoPersonalLevelSet())
13260 level_filename = getDefaultLevelFilename(level_nr);
13261 new_level = !fileExists(level_filename);
13264 Request("Save this level and kill the old?", REQ_ASK))
13266 if (leveldir_former->readonly)
13267 ModifyLevelInfoForSavingIntoPersonalLevelSet(leveldir_former->name);
13269 SetAutomaticNumberOfGemsNeeded();
13271 CopyPlayfield(Feld, level.field);
13272 SaveLevel(level_nr);
13274 level.changed = FALSE;
13278 char level_saved_msg[64];
13280 if (leveldir_former->readonly)
13281 sprintf(level_saved_msg,
13282 "Level saved as level %d into personal level set!",
13285 strcpy(level_saved_msg, "Level saved!");
13287 Request(level_saved_msg, REQ_CONFIRM);
13291 /* "cd" back to copied-from levelset (in case of saved read-only level) */
13292 leveldir_current = leveldir_former;
13293 level_nr = level_nr_former;
13298 case GADGET_ID_TEST:
13299 if (LevelChanged())
13300 level.game_version = GAME_VERSION_ACTUAL;
13302 CopyPlayfield(level.field, FieldBackup);
13303 CopyPlayfield(Feld, level.field);
13305 CopyNativeLevel_RND_to_Native(&level);
13307 UnmapLevelEditorGadgets();
13308 UndrawSpecialEditorDoor();
13310 CloseDoor(DOOR_CLOSE_ALL);
13312 /* needed before playing if editor playfield area has different size */
13313 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
13315 // redraw_mask = REDRAW_ALL;
13317 level_editor_test_game = TRUE;
13319 StartGameActions(FALSE, setup.autorecord, level.random_seed);
13323 case GADGET_ID_EXIT:
13324 RequestExitLevelEditor(TRUE, FALSE); /* if level has changed, ask user */
13328 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
13329 id <= GADGET_ID_ELEMENTLIST_LAST)
13331 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
13332 int new_element = editor_elements[element_position + element_shift];
13334 if (IS_EDITOR_CASCADE(new_element))
13338 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
13340 int *cascade_element= &(*editor_elements_info[i].headline_list)[0];
13341 boolean *cascade_value=editor_elements_info[i].setup_cascade_value;
13343 if (*cascade_element == new_element)
13345 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
13346 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
13348 /* update element selection list */
13349 ReinitializeElementList();
13350 ModifyEditorElementList();
13352 /* update cascading gadget info text */
13353 PrintEditorGadgetInfoText(level_editor_gadget[id]);
13355 /* save current editor cascading state */
13356 SaveSetup_EditorCascade();
13365 if (last_custom_copy_mode != -1)
13367 if (CopyCustomElement(properties_element, new_element,
13368 last_custom_copy_mode))
13370 ClickOnGadget(level_editor_gadget[last_drawing_function],
13373 last_custom_copy_mode = -1;
13379 /* change element of button used to show palette */
13380 if (editor.palette.show_on_element_buttons)
13381 button = last_button;
13383 PickDrawingElement(button, new_element);
13385 if (!stick_element_properties_window &&
13386 drawing_function != GADGET_ID_PICK_ELEMENT &&
13387 !(GetKeyModState() & KMOD_Control))
13389 properties_element = new_element;
13390 if (edit_mode == ED_MODE_PROPERTIES)
13391 DrawPropertiesWindow();
13394 if (drawing_function == GADGET_ID_PICK_ELEMENT)
13395 ClickOnGadget(level_editor_gadget[last_drawing_function],
13398 if (!use_permanent_palette)
13399 ChangeEditModeWindow(last_edit_mode);
13402 else if (gi->event.type == GD_EVENT_PRESSED)
13403 printf("default: HandleControlButtons: GD_EVENT_PRESSED(%d)\n", id);
13404 else if (gi->event.type == GD_EVENT_RELEASED)
13405 printf("default: HandleControlButtons: GD_EVENT_RELEASED(%d)\n", id);
13406 else if (gi->event.type == GD_EVENT_MOVING)
13407 printf("default: HandleControlButtons: GD_EVENT_MOVING(%d)\n", id);
13409 printf("default: HandleControlButtons: ? (id == %d)\n", id);
13415 void HandleLevelEditorKeyInput(Key key)
13417 char letter = getCharFromKey(key);
13418 int button = MB_LEFTBUTTON;
13420 if (drawing_function == GADGET_ID_TEXT &&
13421 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
13424 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
13425 else if (key == KSYM_Delete || key == KSYM_BackSpace)
13426 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
13427 else if (key == KSYM_Return)
13428 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
13429 else if (key == KSYM_Escape)
13430 DrawLevelText(0, 0, 0, TEXT_END);
13432 else if (button_status == MB_RELEASED)
13434 int id = GADGET_ID_NONE;
13435 int new_element_shift = element_shift;
13436 int step = ED_ELEMENTLIST_BUTTONS_VERT - 1;
13442 id = GADGET_ID_SCROLL_LEFT;
13445 id = GADGET_ID_SCROLL_RIGHT;
13448 id = GADGET_ID_SCROLL_UP;
13451 id = GADGET_ID_SCROLL_DOWN;
13455 case KSYM_Page_Down:
13456 step *= (key == KSYM_Page_Up ? -1 : +1);
13457 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
13459 if (element_shift < 0)
13461 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
13462 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
13464 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
13465 GDI_SCROLLBAR_ITEM_POSITION,
13466 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
13468 ModifyEditorElementList();
13474 element_shift = (key == KSYM_Home ? 0 :
13475 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
13477 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
13478 GDI_SCROLLBAR_ITEM_POSITION,
13479 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
13481 ModifyEditorElementList();
13488 /* this is needed to prevent interference with running "True X-Mouse" */
13489 if (GetKeyModStateFromEvents() & KMOD_Control)
13492 /* check for last or next editor cascade block in element list */
13493 for (i = 0; i < num_editor_elements; i++)
13495 if ((key == KSYM_Insert && i == element_shift) ||
13496 (key == KSYM_Delete && new_element_shift > element_shift))
13499 /* jump to next cascade block (or to start of element list) */
13500 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
13501 new_element_shift = i;
13504 if (i < num_editor_elements)
13505 element_shift = new_element_shift;
13507 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
13508 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
13510 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
13511 GDI_SCROLLBAR_ITEM_POSITION,
13512 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
13514 ModifyEditorElementList();
13519 if (edit_mode == ED_MODE_DRAWING)
13521 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
13523 else if (edit_mode == ED_MODE_INFO)
13525 HandleControlButtons(level_editor_gadget[GADGET_ID_INFO]);
13527 else if (edit_mode == ED_MODE_PROPERTIES)
13529 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
13531 else if (edit_mode == ED_MODE_PALETTE)
13533 HandleControlButtons(level_editor_gadget[GADGET_ID_PALETTE]);
13535 else /* should never happen */
13537 ChangeEditModeWindow(ED_MODE_DRAWING);
13546 if (id != GADGET_ID_NONE)
13547 ClickOnGadget(level_editor_gadget[id], button);
13548 else if (letter == '1' || letter == '?')
13549 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_LEFT], button);
13550 else if (letter == '2')
13551 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_MIDDLE], button);
13552 else if (letter == '3')
13553 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_RIGHT], button);
13554 else if (letter == '.')
13555 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
13556 else if (letter == 'U')
13557 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
13558 else if (letter == '-' || key == KSYM_KP_Subtract)
13559 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
13560 else if (letter == '0' || key == KSYM_KP_0)
13561 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
13562 else if (letter == '+' || key == KSYM_KP_Add ||
13563 letter == '=') // ("Shift-=" is "+" on US keyboards)
13564 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
13565 else if (key == KSYM_Return ||
13566 key == KSYM_space ||
13567 key == setup.shortcut.toggle_pause)
13568 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
13570 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
13571 if (letter && letter == controlbutton_info[i].shortcut)
13572 if (!anyTextGadgetActive())
13573 ClickOnGadget(level_editor_gadget[i], button);
13577 void HandleLevelEditorIdle()
13579 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
13580 int x = editor.settings.element_graphic.x + element_border;
13581 int y = editor.settings.element_graphic.y + element_border;
13582 static unsigned int action_delay = 0;
13583 unsigned int action_delay_value = GameFrameDelay;
13586 if (edit_mode != ED_MODE_PROPERTIES)
13589 if (!DelayReached(&action_delay, action_delay_value))
13592 for (i = 0; i < ED_NUM_SELECTBOX; i++)
13594 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
13596 if (gi->mapped && gi->active && gi->selectbox.open)
13600 DrawEditorElementAnimation(SX + x, SY + y);
13602 redraw_mask |= REDRAW_FIELD;
13604 FrameCounter++; /* increase animation frame counter */
13607 static void ClearEditorGadgetInfoText()
13609 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
13612 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
13614 char infotext[MAX_OUTPUT_LINESIZE + 1];
13615 char shortcut[MAX_OUTPUT_LINESIZE + 1];
13616 int max_infotext_len = getMaxInfoTextLength();
13618 if (gi == NULL || strlen(gi->info_text) == 0)
13621 strncpy(infotext, gi->info_text, max_infotext_len);
13622 infotext[max_infotext_len] = '\0';
13624 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
13626 int key = controlbutton_info[gi->custom_id].shortcut;
13630 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
13631 sprintf(shortcut, " ('.' or '%c')", key);
13632 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
13633 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
13634 else if (gi->custom_id == GADGET_ID_TEST)
13635 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
13636 else if (gi->custom_id == GADGET_ID_UNDO)
13637 sprintf(shortcut, " ('%c/Shift-U')", key);
13638 else if (gi->custom_id == GADGET_ID_ZOOM)
13639 sprintf(shortcut, " ('%c', '0', '-')", key);
13641 sprintf(shortcut, " ('%s%c')",
13642 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
13644 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
13645 strcat(infotext, shortcut);
13649 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, INFOTEXT_FONT);
13652 void HandleEditorGadgetInfoText(void *ptr)
13654 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
13656 if (game_status != GAME_MODE_EDITOR)
13659 ClearEditorGadgetInfoText();
13661 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
13664 /* misuse this function to delete brush cursor, if needed */
13665 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
13666 DeleteBrushFromCursor();
13668 PrintEditorGadgetInfoText(gi);
13671 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
13673 static int start_lx, start_ly;
13674 int id = gi->custom_id;
13675 int type_id = gi->custom_type_id;
13676 int sx = gi->event.x;
13677 int sy = gi->event.y;
13678 int lx = sx + level_xpos;
13679 int ly = sy + level_ypos;
13680 int min_sx = 0, min_sy = 0;
13681 int max_sx = gi->drawing.area_xsize - 1;
13682 int max_sy = gi->drawing.area_ysize - 1;
13683 int actual_drawing_function = drawing_function;
13684 int max_infotext_len = getMaxInfoTextLength();
13685 char infotext[MAX_OUTPUT_LINESIZE + 1];
13688 infotext[0] = '\0'; /* start with empty info text */
13690 /* pressed Control key: simulate picking element */
13691 if (GetKeyModState() & KMOD_Control)
13692 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
13694 ClearEditorGadgetInfoText();
13696 if (gi->event.type == GD_EVENT_INFO_LEAVING)
13699 /* make sure to stay inside drawing area boundaries */
13700 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
13701 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
13703 if (id == GADGET_ID_DRAWING_LEVEL)
13707 int min_lx = 0, min_ly = 0;
13708 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
13710 /* get positions inside level field */
13711 lx = sx + level_xpos;
13712 ly = sy + level_ypos;
13714 /* make sure to stay inside level field boundaries */
13715 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
13716 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
13718 /* correct drawing area positions accordingly */
13719 sx = lx - level_xpos;
13720 sy = ly - level_ypos;
13723 if (IN_ED_FIELD(sx,sy) && IN_LEV_FIELD(lx, ly))
13725 if (button_status) /* if (gi->state == GD_BUTTON_PRESSED) */
13727 if (gi->event.type == GD_EVENT_PRESSED)
13733 switch (actual_drawing_function)
13735 case GADGET_ID_SINGLE_ITEMS:
13736 text = "Drawing single items";
13738 case GADGET_ID_CONNECTED_ITEMS:
13739 text = "Drawing connected items";
13741 case GADGET_ID_LINE:
13742 text = "Drawing line";
13744 case GADGET_ID_ARC:
13745 text = "Drawing arc";
13747 case GADGET_ID_TEXT:
13748 text = "Setting text cursor";
13750 case GADGET_ID_RECTANGLE:
13751 text = "Drawing rectangle";
13753 case GADGET_ID_FILLED_BOX:
13754 text = "Drawing filled box";
13756 case GADGET_ID_FLOOD_FILL:
13757 text = "Flood fill";
13759 case GADGET_ID_GRAB_BRUSH:
13760 text = "Grabbing brush";
13762 case GADGET_ID_PICK_ELEMENT:
13763 text = "Picking element";
13767 text = "Drawing position";
13771 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
13772 sprintf(infotext, "%s: %d, %d", text, lx, ly);
13774 sprintf(infotext, "%s: %d, %d", text,
13775 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
13777 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
13778 strncpy(infotext, getElementInfoText(Feld[lx][ly]), max_infotext_len);
13780 sprintf(infotext, "Level position: %d, %d", lx, ly);
13783 /* misuse this function to draw brush cursor, if needed */
13784 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
13786 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
13787 CopyBrushToCursor(sx, sy);
13789 DeleteBrushFromCursor();
13792 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
13794 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
13795 int element = drawingarea_info[type_id].value[pos];
13797 strncpy(infotext, getElementInfoText(element), max_infotext_len);
13801 if (id == GADGET_ID_CUSTOM_CONTENT)
13802 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
13803 else if (id == GADGET_ID_GROUP_CONTENT)
13804 sprintf(infotext, "group element position: %d", sx + 1);
13805 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
13806 id <= GADGET_ID_YAMYAM_CONTENT_7)
13807 sprintf(infotext, "content area %d position: %d, %d",
13808 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
13809 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
13810 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
13811 sprintf(infotext, "content area %d position: %d, %d",
13812 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
13813 else if (id == GADGET_ID_ANDROID_CONTENT)
13814 sprintf(infotext, "android element position: %d", sx + 1);
13815 else if (drawingarea_info[type_id].infotext != NULL)
13816 strcpy(infotext, drawingarea_info[type_id].infotext);
13819 infotext[max_infotext_len] = '\0';
13821 if (strlen(infotext) > 0)
13822 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT, infotext);
13825 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
13826 boolean quick_quit)
13828 if (!ask_if_level_has_changed ||
13830 Request("Level has changed! Exit without saving?",
13831 REQ_ASK | REQ_STAY_OPEN))
13833 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
13834 struct RectWithBorder *vp_door_2 = &viewport.door_2[GAME_MODE_MAIN];
13836 /* draw normal door */
13837 UndrawSpecialEditorDoor();
13839 // close editor doors if viewport definition is the same as in main menu
13840 if (vp_door_1->x == DX &&
13841 vp_door_1->y == DY &&
13842 vp_door_1->width == DXSIZE &&
13843 vp_door_1->height == DYSIZE &&
13844 vp_door_2->x == VX &&
13845 vp_door_2->y == VY &&
13846 vp_door_2->width == VXSIZE &&
13847 vp_door_2->height == VYSIZE)
13848 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
13850 SetDoorState(DOOR_CLOSE_2);
13855 FadeSkipNextFadeIn();
13857 SetGameStatus(GAME_MODE_MAIN);
13863 if (!global.use_envelope_request)
13865 CloseDoor(DOOR_CLOSE_1);
13866 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);