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_ELEMENT_VALUE1_DOWN (GADGET_ID_COUNTER_FIRST + 24)
427 #define GADGET_ID_ELEMENT_VALUE1_TEXT (GADGET_ID_COUNTER_FIRST + 25)
428 #define GADGET_ID_ELEMENT_VALUE1_UP (GADGET_ID_COUNTER_FIRST + 26)
429 #define GADGET_ID_ELEMENT_VALUE2_DOWN (GADGET_ID_COUNTER_FIRST + 27)
430 #define GADGET_ID_ELEMENT_VALUE2_TEXT (GADGET_ID_COUNTER_FIRST + 28)
431 #define GADGET_ID_ELEMENT_VALUE2_UP (GADGET_ID_COUNTER_FIRST + 29)
432 #define GADGET_ID_ELEMENT_VALUE3_DOWN (GADGET_ID_COUNTER_FIRST + 30)
433 #define GADGET_ID_ELEMENT_VALUE3_TEXT (GADGET_ID_COUNTER_FIRST + 31)
434 #define GADGET_ID_ELEMENT_VALUE3_UP (GADGET_ID_COUNTER_FIRST + 32)
435 #define GADGET_ID_ELEMENT_VALUE4_DOWN (GADGET_ID_COUNTER_FIRST + 33)
436 #define GADGET_ID_ELEMENT_VALUE4_TEXT (GADGET_ID_COUNTER_FIRST + 34)
437 #define GADGET_ID_ELEMENT_VALUE4_UP (GADGET_ID_COUNTER_FIRST + 35)
438 #define GADGET_ID_YAMYAM_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 36)
439 #define GADGET_ID_YAMYAM_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 37)
440 #define GADGET_ID_YAMYAM_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 38)
441 #define GADGET_ID_BALL_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 39)
442 #define GADGET_ID_BALL_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 40)
443 #define GADGET_ID_BALL_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 41)
444 #define GADGET_ID_ANDROID_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 42)
445 #define GADGET_ID_ANDROID_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 43)
446 #define GADGET_ID_ANDROID_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 44)
447 #define GADGET_ID_ENVELOPE_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 45)
448 #define GADGET_ID_ENVELOPE_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 46)
449 #define GADGET_ID_ENVELOPE_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 47)
450 #define GADGET_ID_ENVELOPE_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 48)
451 #define GADGET_ID_ENVELOPE_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 49)
452 #define GADGET_ID_ENVELOPE_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 50)
453 #define GADGET_ID_INVENTORY_SIZE_DOWN (GADGET_ID_COUNTER_FIRST + 51)
454 #define GADGET_ID_INVENTORY_SIZE_TEXT (GADGET_ID_COUNTER_FIRST + 52)
455 #define GADGET_ID_INVENTORY_SIZE_UP (GADGET_ID_COUNTER_FIRST + 53)
456 #define GADGET_ID_CUSTOM_SCORE_DOWN (GADGET_ID_COUNTER_FIRST + 54)
457 #define GADGET_ID_CUSTOM_SCORE_TEXT (GADGET_ID_COUNTER_FIRST + 55)
458 #define GADGET_ID_CUSTOM_SCORE_UP (GADGET_ID_COUNTER_FIRST + 56)
459 #define GADGET_ID_CUSTOM_GEMCOUNT_DOWN (GADGET_ID_COUNTER_FIRST + 57)
460 #define GADGET_ID_CUSTOM_GEMCOUNT_TEXT (GADGET_ID_COUNTER_FIRST + 58)
461 #define GADGET_ID_CUSTOM_GEMCOUNT_UP (GADGET_ID_COUNTER_FIRST + 59)
462 #define GADGET_ID_CUSTOM_VALUE_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 60)
463 #define GADGET_ID_CUSTOM_VALUE_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 61)
464 #define GADGET_ID_CUSTOM_VALUE_FIX_UP (GADGET_ID_COUNTER_FIRST + 62)
465 #define GADGET_ID_CUSTOM_VALUE_RND_DOWN (GADGET_ID_COUNTER_FIRST + 63)
466 #define GADGET_ID_CUSTOM_VALUE_RND_TEXT (GADGET_ID_COUNTER_FIRST + 64)
467 #define GADGET_ID_CUSTOM_VALUE_RND_UP (GADGET_ID_COUNTER_FIRST + 65)
468 #define GADGET_ID_PUSH_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 66)
469 #define GADGET_ID_PUSH_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 67)
470 #define GADGET_ID_PUSH_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 68)
471 #define GADGET_ID_PUSH_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 69)
472 #define GADGET_ID_PUSH_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 70)
473 #define GADGET_ID_PUSH_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 71)
474 #define GADGET_ID_DROP_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 72)
475 #define GADGET_ID_DROP_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 73)
476 #define GADGET_ID_DROP_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 74)
477 #define GADGET_ID_DROP_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 75)
478 #define GADGET_ID_DROP_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 76)
479 #define GADGET_ID_DROP_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 77)
480 #define GADGET_ID_MOVE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 78)
481 #define GADGET_ID_MOVE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 79)
482 #define GADGET_ID_MOVE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 80)
483 #define GADGET_ID_MOVE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 81)
484 #define GADGET_ID_MOVE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 82)
485 #define GADGET_ID_MOVE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 83)
486 #define GADGET_ID_EXPLOSION_DELAY_DOWN (GADGET_ID_COUNTER_FIRST + 84)
487 #define GADGET_ID_EXPLOSION_DELAY_TEXT (GADGET_ID_COUNTER_FIRST + 85)
488 #define GADGET_ID_EXPLOSION_DELAY_UP (GADGET_ID_COUNTER_FIRST + 86)
489 #define GADGET_ID_IGNITION_DELAY_DOWN (GADGET_ID_COUNTER_FIRST + 87)
490 #define GADGET_ID_IGNITION_DELAY_TEXT (GADGET_ID_COUNTER_FIRST + 88)
491 #define GADGET_ID_IGNITION_DELAY_UP (GADGET_ID_COUNTER_FIRST + 89)
492 #define GADGET_ID_CHANGE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 90)
493 #define GADGET_ID_CHANGE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 91)
494 #define GADGET_ID_CHANGE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 92)
495 #define GADGET_ID_CHANGE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 93)
496 #define GADGET_ID_CHANGE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 94)
497 #define GADGET_ID_CHANGE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 95)
498 #define GADGET_ID_CHANGE_CONT_RND_DOWN (GADGET_ID_COUNTER_FIRST + 96)
499 #define GADGET_ID_CHANGE_CONT_RND_TEXT (GADGET_ID_COUNTER_FIRST + 97)
500 #define GADGET_ID_CHANGE_CONT_RND_UP (GADGET_ID_COUNTER_FIRST + 98)
501 #define GADGET_ID_GROUP_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 99)
502 #define GADGET_ID_GROUP_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 100)
503 #define GADGET_ID_GROUP_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 101)
505 /* drawing area identifiers */
506 #define GADGET_ID_DRAWING_AREA_FIRST (GADGET_ID_COUNTER_FIRST + 102)
508 #define GADGET_ID_DRAWING_LEVEL (GADGET_ID_DRAWING_AREA_FIRST + 0)
509 #define GADGET_ID_YAMYAM_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 1)
510 #define GADGET_ID_YAMYAM_CONTENT_1 (GADGET_ID_DRAWING_AREA_FIRST + 2)
511 #define GADGET_ID_YAMYAM_CONTENT_2 (GADGET_ID_DRAWING_AREA_FIRST + 3)
512 #define GADGET_ID_YAMYAM_CONTENT_3 (GADGET_ID_DRAWING_AREA_FIRST + 4)
513 #define GADGET_ID_YAMYAM_CONTENT_4 (GADGET_ID_DRAWING_AREA_FIRST + 5)
514 #define GADGET_ID_YAMYAM_CONTENT_5 (GADGET_ID_DRAWING_AREA_FIRST + 6)
515 #define GADGET_ID_YAMYAM_CONTENT_6 (GADGET_ID_DRAWING_AREA_FIRST + 7)
516 #define GADGET_ID_YAMYAM_CONTENT_7 (GADGET_ID_DRAWING_AREA_FIRST + 8)
517 #define GADGET_ID_MAGIC_BALL_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 9)
518 #define GADGET_ID_MAGIC_BALL_CONTENT_1 (GADGET_ID_DRAWING_AREA_FIRST + 10)
519 #define GADGET_ID_MAGIC_BALL_CONTENT_2 (GADGET_ID_DRAWING_AREA_FIRST + 11)
520 #define GADGET_ID_MAGIC_BALL_CONTENT_3 (GADGET_ID_DRAWING_AREA_FIRST + 12)
521 #define GADGET_ID_MAGIC_BALL_CONTENT_4 (GADGET_ID_DRAWING_AREA_FIRST + 13)
522 #define GADGET_ID_MAGIC_BALL_CONTENT_5 (GADGET_ID_DRAWING_AREA_FIRST + 14)
523 #define GADGET_ID_MAGIC_BALL_CONTENT_6 (GADGET_ID_DRAWING_AREA_FIRST + 15)
524 #define GADGET_ID_MAGIC_BALL_CONTENT_7 (GADGET_ID_DRAWING_AREA_FIRST + 16)
525 #define GADGET_ID_ANDROID_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 17)
526 #define GADGET_ID_AMOEBA_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 18)
527 #define GADGET_ID_START_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 19)
528 #define GADGET_ID_ARTWORK_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 20)
529 #define GADGET_ID_EXPLOSION_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 21)
530 #define GADGET_ID_INVENTORY_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 22)
531 #define GADGET_ID_CUSTOM_GRAPHIC (GADGET_ID_DRAWING_AREA_FIRST + 23)
532 #define GADGET_ID_CUSTOM_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 24)
533 #define GADGET_ID_CUSTOM_MOVE_ENTER (GADGET_ID_DRAWING_AREA_FIRST + 25)
534 #define GADGET_ID_CUSTOM_MOVE_LEAVE (GADGET_ID_DRAWING_AREA_FIRST + 26)
535 #define GADGET_ID_CUSTOM_CHANGE_TARGET (GADGET_ID_DRAWING_AREA_FIRST + 27)
536 #define GADGET_ID_CUSTOM_CHANGE_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 28)
537 #define GADGET_ID_CUSTOM_CHANGE_TRIGGER (GADGET_ID_DRAWING_AREA_FIRST + 29)
538 #define GADGET_ID_CUSTOM_CHANGE_ACTION (GADGET_ID_DRAWING_AREA_FIRST + 30)
539 #define GADGET_ID_GROUP_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 31)
540 #define GADGET_ID_RANDOM_BACKGROUND (GADGET_ID_DRAWING_AREA_FIRST + 32)
542 /* text input identifiers */
543 #define GADGET_ID_TEXT_INPUT_FIRST (GADGET_ID_DRAWING_AREA_FIRST + 33)
545 #define GADGET_ID_LEVEL_NAME (GADGET_ID_TEXT_INPUT_FIRST + 0)
546 #define GADGET_ID_LEVEL_AUTHOR (GADGET_ID_TEXT_INPUT_FIRST + 1)
547 #define GADGET_ID_ELEMENT_NAME (GADGET_ID_TEXT_INPUT_FIRST + 2)
549 /* text area identifiers */
550 #define GADGET_ID_TEXT_AREA_FIRST (GADGET_ID_TEXT_INPUT_FIRST + 3)
552 #define GADGET_ID_ENVELOPE_INFO (GADGET_ID_TEXT_AREA_FIRST + 0)
554 /* selectbox identifiers */
555 #define GADGET_ID_SELECTBOX_FIRST (GADGET_ID_TEXT_AREA_FIRST + 1)
557 #define GADGET_ID_TIME_OR_STEPS (GADGET_ID_SELECTBOX_FIRST + 0)
558 #define GADGET_ID_GAME_ENGINE_TYPE (GADGET_ID_SELECTBOX_FIRST + 1)
559 #define GADGET_ID_WIND_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 2)
560 #define GADGET_ID_PLAYER_SPEED (GADGET_ID_SELECTBOX_FIRST + 3)
561 #define GADGET_ID_CUSTOM_WALK_TO_ACTION (GADGET_ID_SELECTBOX_FIRST + 4)
562 #define GADGET_ID_CUSTOM_EXPLOSION_TYPE (GADGET_ID_SELECTBOX_FIRST + 5)
563 #define GADGET_ID_CUSTOM_DEADLINESS (GADGET_ID_SELECTBOX_FIRST + 6)
564 #define GADGET_ID_CUSTOM_MOVE_PATTERN (GADGET_ID_SELECTBOX_FIRST + 7)
565 #define GADGET_ID_CUSTOM_MOVE_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 8)
566 #define GADGET_ID_CUSTOM_MOVE_STEPSIZE (GADGET_ID_SELECTBOX_FIRST + 9)
567 #define GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE (GADGET_ID_SELECTBOX_FIRST + 10)
568 #define GADGET_ID_CUSTOM_SMASH_TARGETS (GADGET_ID_SELECTBOX_FIRST + 11)
569 #define GADGET_ID_CUSTOM_SLIPPERY_TYPE (GADGET_ID_SELECTBOX_FIRST + 12)
570 #define GADGET_ID_CUSTOM_ACCESS_TYPE (GADGET_ID_SELECTBOX_FIRST + 13)
571 #define GADGET_ID_CUSTOM_ACCESS_LAYER (GADGET_ID_SELECTBOX_FIRST + 14)
572 #define GADGET_ID_CUSTOM_ACCESS_PROTECTED (GADGET_ID_SELECTBOX_FIRST + 15)
573 #define GADGET_ID_CUSTOM_ACCESS_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 16)
574 #define GADGET_ID_CHANGE_TIME_UNITS (GADGET_ID_SELECTBOX_FIRST + 17)
575 #define GADGET_ID_CHANGE_DIRECT_ACTION (GADGET_ID_SELECTBOX_FIRST + 18)
576 #define GADGET_ID_CHANGE_OTHER_ACTION (GADGET_ID_SELECTBOX_FIRST + 19)
577 #define GADGET_ID_CHANGE_SIDE (GADGET_ID_SELECTBOX_FIRST + 20)
578 #define GADGET_ID_CHANGE_PLAYER (GADGET_ID_SELECTBOX_FIRST + 21)
579 #define GADGET_ID_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 22)
580 #define GADGET_ID_CHANGE_REPLACE_WHEN (GADGET_ID_SELECTBOX_FIRST + 23)
581 #define GADGET_ID_ACTION_TYPE (GADGET_ID_SELECTBOX_FIRST + 24)
582 #define GADGET_ID_ACTION_MODE (GADGET_ID_SELECTBOX_FIRST + 25)
583 #define GADGET_ID_ACTION_ARG (GADGET_ID_SELECTBOX_FIRST + 26)
584 #define GADGET_ID_SELECT_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 27)
585 #define GADGET_ID_GROUP_CHOICE_MODE (GADGET_ID_SELECTBOX_FIRST + 28)
587 /* textbutton identifiers */
588 #define GADGET_ID_TEXTBUTTON_FIRST (GADGET_ID_SELECTBOX_FIRST + 29)
590 #define GADGET_ID_LEVELINFO_LEVEL (GADGET_ID_TEXTBUTTON_FIRST + 0)
591 #define GADGET_ID_LEVELINFO_EDITOR (GADGET_ID_TEXTBUTTON_FIRST + 1)
592 #define GADGET_ID_PROPERTIES_INFO (GADGET_ID_TEXTBUTTON_FIRST + 2)
593 #define GADGET_ID_PROPERTIES_CONFIG (GADGET_ID_TEXTBUTTON_FIRST + 3)
594 #define GADGET_ID_PROPERTIES_CONFIG_1 (GADGET_ID_TEXTBUTTON_FIRST + 4)
595 #define GADGET_ID_PROPERTIES_CONFIG_2 (GADGET_ID_TEXTBUTTON_FIRST + 5)
596 #define GADGET_ID_PROPERTIES_CHANGE (GADGET_ID_TEXTBUTTON_FIRST + 6)
597 #define GADGET_ID_SAVE_AS_TEMPLATE_1 (GADGET_ID_TEXTBUTTON_FIRST + 7)
598 #define GADGET_ID_SAVE_AS_TEMPLATE_2 (GADGET_ID_TEXTBUTTON_FIRST + 8)
599 #define GADGET_ID_ADD_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 9)
600 #define GADGET_ID_DEL_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 10)
602 /* graphicbutton identifiers */
603 #define GADGET_ID_GRAPHICBUTTON_FIRST (GADGET_ID_TEXTBUTTON_FIRST + 11)
605 #define GADGET_ID_PREV_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 0)
606 #define GADGET_ID_NEXT_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 1)
607 #define GADGET_ID_COPY_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 2)
608 #define GADGET_ID_PASTE_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 3)
610 /* gadgets for scrolling of drawing area */
611 #define GADGET_ID_SCROLLING_FIRST (GADGET_ID_GRAPHICBUTTON_FIRST + 4)
613 #define GADGET_ID_SCROLL_UP (GADGET_ID_SCROLLING_FIRST + 0)
614 #define GADGET_ID_SCROLL_DOWN (GADGET_ID_SCROLLING_FIRST + 1)
615 #define GADGET_ID_SCROLL_LEFT (GADGET_ID_SCROLLING_FIRST + 2)
616 #define GADGET_ID_SCROLL_RIGHT (GADGET_ID_SCROLLING_FIRST + 3)
617 #define GADGET_ID_SCROLL_HORIZONTAL (GADGET_ID_SCROLLING_FIRST + 4)
618 #define GADGET_ID_SCROLL_VERTICAL (GADGET_ID_SCROLLING_FIRST + 5)
620 /* gadgets for scrolling element list */
621 #define GADGET_ID_SCROLLING_LIST_FIRST (GADGET_ID_SCROLLING_FIRST + 6)
623 #define GADGET_ID_SCROLL_LIST_UP (GADGET_ID_SCROLLING_LIST_FIRST + 0)
624 #define GADGET_ID_SCROLL_LIST_DOWN (GADGET_ID_SCROLLING_LIST_FIRST + 1)
625 #define GADGET_ID_SCROLL_LIST_VERTICAL (GADGET_ID_SCROLLING_LIST_FIRST + 2)
627 /* checkbuttons/radiobuttons for level/element properties */
628 #define GADGET_ID_CHECKBUTTON_FIRST (GADGET_ID_SCROLLING_LIST_FIRST + 3)
630 #define GADGET_ID_AUTO_COUNT_GEMS (GADGET_ID_CHECKBUTTON_FIRST + 0)
631 #define GADGET_ID_RANDOM_PERCENTAGE (GADGET_ID_CHECKBUTTON_FIRST + 1)
632 #define GADGET_ID_RANDOM_QUANTITY (GADGET_ID_CHECKBUTTON_FIRST + 2)
633 #define GADGET_ID_RANDOM_RESTRICTED (GADGET_ID_CHECKBUTTON_FIRST + 3)
634 #define GADGET_ID_STICK_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 4)
635 #define GADGET_ID_EM_SLIPPERY_GEMS (GADGET_ID_CHECKBUTTON_FIRST + 5)
636 #define GADGET_ID_EM_EXPLODES_BY_FIRE (GADGET_ID_CHECKBUTTON_FIRST + 6)
637 #define GADGET_ID_USE_SPRING_BUG (GADGET_ID_CHECKBUTTON_FIRST + 7)
638 #define GADGET_ID_USE_TIME_ORB_BUG (GADGET_ID_CHECKBUTTON_FIRST + 8)
639 #define GADGET_ID_RANDOM_BALL_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 9)
640 #define GADGET_ID_INITIAL_BALL_STATE (GADGET_ID_CHECKBUTTON_FIRST + 10)
641 #define GADGET_ID_GROW_INTO_DIGGABLE (GADGET_ID_CHECKBUTTON_FIRST + 11)
642 #define GADGET_ID_AUTO_EXIT_SOKOBAN (GADGET_ID_CHECKBUTTON_FIRST + 12)
643 #define GADGET_ID_CONTINUOUS_SNAPPING (GADGET_ID_CHECKBUTTON_FIRST + 13)
644 #define GADGET_ID_BLOCK_SNAP_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 14)
645 #define GADGET_ID_BLOCK_LAST_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 15)
646 #define GADGET_ID_SP_BLOCK_LAST_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 16)
647 #define GADGET_ID_INSTANT_RELOCATION (GADGET_ID_CHECKBUTTON_FIRST + 17)
648 #define GADGET_ID_SHIFTED_RELOCATION (GADGET_ID_CHECKBUTTON_FIRST + 18)
649 #define GADGET_ID_LAZY_RELOCATION (GADGET_ID_CHECKBUTTON_FIRST + 19)
650 #define GADGET_ID_USE_START_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 20)
651 #define GADGET_ID_USE_ARTWORK_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 21)
652 #define GADGET_ID_USE_EXPLOSION_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 22)
653 #define GADGET_ID_INITIAL_GRAVITY (GADGET_ID_CHECKBUTTON_FIRST + 23)
654 #define GADGET_ID_USE_INITIAL_INVENTORY (GADGET_ID_CHECKBUTTON_FIRST + 24)
655 #define GADGET_ID_CAN_PASS_TO_WALKABLE (GADGET_ID_CHECKBUTTON_FIRST + 25)
656 #define GADGET_ID_CAN_FALL_INTO_ACID (GADGET_ID_CHECKBUTTON_FIRST + 26)
657 #define GADGET_ID_CAN_MOVE_INTO_ACID (GADGET_ID_CHECKBUTTON_FIRST + 27)
658 #define GADGET_ID_DONT_COLLIDE_WITH (GADGET_ID_CHECKBUTTON_FIRST + 28)
659 #define GADGET_ID_ENVELOPE_AUTOWRAP (GADGET_ID_CHECKBUTTON_FIRST + 29)
660 #define GADGET_ID_ENVELOPE_CENTERED (GADGET_ID_CHECKBUTTON_FIRST + 30)
661 #define GADGET_ID_MM_LASER_RED (GADGET_ID_CHECKBUTTON_FIRST + 31)
662 #define GADGET_ID_MM_LASER_GREEN (GADGET_ID_CHECKBUTTON_FIRST + 32)
663 #define GADGET_ID_MM_LASER_BLUE (GADGET_ID_CHECKBUTTON_FIRST + 33)
664 #define GADGET_ID_DF_LASER_RED (GADGET_ID_CHECKBUTTON_FIRST + 34)
665 #define GADGET_ID_DF_LASER_GREEN (GADGET_ID_CHECKBUTTON_FIRST + 35)
666 #define GADGET_ID_DF_LASER_BLUE (GADGET_ID_CHECKBUTTON_FIRST + 36)
667 #define GADGET_ID_CUSTOM_INDESTRUCTIBLE (GADGET_ID_CHECKBUTTON_FIRST + 37)
668 #define GADGET_ID_CUSTOM_CAN_EXPLODE (GADGET_ID_CHECKBUTTON_FIRST + 38)
669 #define GADGET_ID_CUSTOM_EXPLODE_FIRE (GADGET_ID_CHECKBUTTON_FIRST + 39)
670 #define GADGET_ID_CUSTOM_EXPLODE_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 40)
671 #define GADGET_ID_CUSTOM_EXPLODE_IMPACT (GADGET_ID_CHECKBUTTON_FIRST + 41)
672 #define GADGET_ID_CUSTOM_WALK_TO_OBJECT (GADGET_ID_CHECKBUTTON_FIRST + 42)
673 #define GADGET_ID_CUSTOM_DEADLY (GADGET_ID_CHECKBUTTON_FIRST + 43)
674 #define GADGET_ID_CUSTOM_CAN_MOVE (GADGET_ID_CHECKBUTTON_FIRST + 44)
675 #define GADGET_ID_CUSTOM_CAN_FALL (GADGET_ID_CHECKBUTTON_FIRST + 45)
676 #define GADGET_ID_CUSTOM_CAN_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 46)
677 #define GADGET_ID_CUSTOM_SLIPPERY (GADGET_ID_CHECKBUTTON_FIRST + 47)
678 #define GADGET_ID_CUSTOM_ACCESSIBLE (GADGET_ID_CHECKBUTTON_FIRST + 48)
679 #define GADGET_ID_CUSTOM_GRAV_REACHABLE (GADGET_ID_CHECKBUTTON_FIRST + 49)
680 #define GADGET_ID_CUSTOM_USE_LAST_VALUE (GADGET_ID_CHECKBUTTON_FIRST + 50)
681 #define GADGET_ID_CUSTOM_USE_GRAPHIC (GADGET_ID_CHECKBUTTON_FIRST + 51)
682 #define GADGET_ID_CUSTOM_USE_TEMPLATE_1 (GADGET_ID_CHECKBUTTON_FIRST + 52)
683 #define GADGET_ID_CUSTOM_USE_TEMPLATE_2 (GADGET_ID_CHECKBUTTON_FIRST + 53)
684 #define GADGET_ID_CUSTOM_USE_TEMPLATE_3 (GADGET_ID_CHECKBUTTON_FIRST + 54)
685 #define GADGET_ID_CUSTOM_CAN_CHANGE (GADGET_ID_CHECKBUTTON_FIRST + 55)
686 #define GADGET_ID_CHANGE_USE_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 56)
687 #define GADGET_ID_CHANGE_USE_EXPLOSION (GADGET_ID_CHECKBUTTON_FIRST + 57)
688 #define GADGET_ID_CHANGE_ONLY_COMPLETE (GADGET_ID_CHECKBUTTON_FIRST + 58)
689 #define GADGET_ID_CHANGE_USE_RANDOM (GADGET_ID_CHECKBUTTON_FIRST + 59)
690 #define GADGET_ID_CHANGE_HAS_ACTION (GADGET_ID_CHECKBUTTON_FIRST + 60)
691 #define GADGET_ID_CHANGE_DELAY (GADGET_ID_CHECKBUTTON_FIRST + 61)
692 #define GADGET_ID_CHANGE_BY_DIRECT_ACT (GADGET_ID_CHECKBUTTON_FIRST + 62)
693 #define GADGET_ID_CHANGE_BY_OTHER_ACT (GADGET_ID_CHECKBUTTON_FIRST + 63)
695 /* gadgets for buttons in element list */
696 #define GADGET_ID_ELEMENTLIST_FIRST (GADGET_ID_CHECKBUTTON_FIRST + 64)
697 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
698 ED_NUM_ELEMENTLIST_BUTTONS - 1)
700 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
702 /* radio button numbers */
703 #define RADIO_NR_NONE 0
704 #define RADIO_NR_DRAWING_TOOLBOX 1
705 #define RADIO_NR_RANDOM_ELEMENTS 2
707 /* values for counter gadgets */
708 #define ED_COUNTER_ID_SELECT_LEVEL 0
709 #define ED_COUNTER_ID_LEVEL_XSIZE 1
710 #define ED_COUNTER_ID_LEVEL_YSIZE 2
711 #define ED_COUNTER_ID_LEVEL_GEMSLIMIT 3
712 #define ED_COUNTER_ID_LEVEL_TIMELIMIT 4
713 #define ED_COUNTER_ID_LEVEL_TIMESCORE 5
714 #define ED_COUNTER_ID_LEVEL_RANDOM_SEED 6
715 #define ED_COUNTER_ID_LEVEL_RANDOM 7
716 #define ED_COUNTER_ID_ELEMENT_VALUE1 8
717 #define ED_COUNTER_ID_ELEMENT_VALUE2 9
718 #define ED_COUNTER_ID_ELEMENT_VALUE3 10
719 #define ED_COUNTER_ID_ELEMENT_VALUE4 11
720 #define ED_COUNTER_ID_YAMYAM_CONTENT 12
721 #define ED_COUNTER_ID_BALL_CONTENT 13
722 #define ED_COUNTER_ID_ANDROID_CONTENT 14
723 #define ED_COUNTER_ID_ENVELOPE_XSIZE 15
724 #define ED_COUNTER_ID_ENVELOPE_YSIZE 16
725 #define ED_COUNTER_ID_INVENTORY_SIZE 17
726 #define ED_COUNTER_ID_CUSTOM_SCORE 18
727 #define ED_COUNTER_ID_CUSTOM_GEMCOUNT 19
728 #define ED_COUNTER_ID_CUSTOM_VALUE_FIX 20
729 #define ED_COUNTER_ID_CUSTOM_VALUE_RND 21
730 #define ED_COUNTER_ID_PUSH_DELAY_FIX 22
731 #define ED_COUNTER_ID_PUSH_DELAY_RND 23
732 #define ED_COUNTER_ID_DROP_DELAY_FIX 24
733 #define ED_COUNTER_ID_DROP_DELAY_RND 25
734 #define ED_COUNTER_ID_MOVE_DELAY_FIX 26
735 #define ED_COUNTER_ID_MOVE_DELAY_RND 27
736 #define ED_COUNTER_ID_EXPLOSION_DELAY 28
737 #define ED_COUNTER_ID_IGNITION_DELAY 29
738 #define ED_COUNTER_ID_GROUP_CONTENT 30
739 #define ED_COUNTER_ID_CHANGE_DELAY_FIX 31
740 #define ED_COUNTER_ID_CHANGE_DELAY_RND 32
741 #define ED_COUNTER_ID_CHANGE_CONT_RND 33
743 #define ED_NUM_COUNTERBUTTONS 34
745 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
746 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
747 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
748 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
750 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
751 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
752 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
753 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
754 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
755 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
757 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
758 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
760 /* values for scrollbutton gadgets */
761 #define ED_SCROLLBUTTON_ID_AREA_UP 0
762 #define ED_SCROLLBUTTON_ID_AREA_DOWN 1
763 #define ED_SCROLLBUTTON_ID_AREA_LEFT 2
764 #define ED_SCROLLBUTTON_ID_AREA_RIGHT 3
765 #define ED_SCROLLBUTTON_ID_LIST_UP 4
766 #define ED_SCROLLBUTTON_ID_LIST_DOWN 5
768 #define ED_NUM_SCROLLBUTTONS 6
770 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
771 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
773 /* values for scrollbar gadgets */
774 #define ED_SCROLLBAR_ID_AREA_HORIZONTAL 0
775 #define ED_SCROLLBAR_ID_AREA_VERTICAL 1
776 #define ED_SCROLLBAR_ID_LIST_VERTICAL 2
778 #define ED_NUM_SCROLLBARS 3
780 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
781 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
783 /* values for text input gadgets */
784 #define ED_TEXTINPUT_ID_LEVEL_NAME 0
785 #define ED_TEXTINPUT_ID_LEVEL_AUTHOR 1
786 #define ED_TEXTINPUT_ID_ELEMENT_NAME 2
788 #define ED_NUM_TEXTINPUT 3
790 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
791 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
793 /* values for text area gadgets */
794 #define ED_TEXTAREA_ID_ENVELOPE_INFO 0
796 #define ED_NUM_TEXTAREAS 1
798 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
799 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
801 /* values for selectbox gadgets */
802 #define ED_SELECTBOX_ID_TIME_OR_STEPS 0
803 #define ED_SELECTBOX_ID_GAME_ENGINE_TYPE 1
804 #define ED_SELECTBOX_ID_WIND_DIRECTION 2
805 #define ED_SELECTBOX_ID_PLAYER_SPEED 3
806 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE 4
807 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER 5
808 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED 6
809 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION 7
810 #define ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION 8
811 #define ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN 9
812 #define ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION 10
813 #define ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE 11
814 #define ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE 12
815 #define ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS 13
816 #define ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE 14
817 #define ED_SELECTBOX_ID_CUSTOM_DEADLINESS 15
818 #define ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE 16
819 #define ED_SELECTBOX_ID_CHANGE_TIME_UNITS 17
820 #define ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION 18
821 #define ED_SELECTBOX_ID_CHANGE_OTHER_ACTION 19
822 #define ED_SELECTBOX_ID_CHANGE_SIDE 20
823 #define ED_SELECTBOX_ID_CHANGE_PLAYER 21
824 #define ED_SELECTBOX_ID_CHANGE_PAGE 22
825 #define ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN 23
826 #define ED_SELECTBOX_ID_ACTION_TYPE 24
827 #define ED_SELECTBOX_ID_ACTION_MODE 25
828 #define ED_SELECTBOX_ID_ACTION_ARG 26
829 #define ED_SELECTBOX_ID_SELECT_CHANGE_PAGE 27
830 #define ED_SELECTBOX_ID_GROUP_CHOICE_MODE 28
832 #define ED_NUM_SELECTBOX 29
834 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
835 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_WIND_DIRECTION
837 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
838 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
839 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
840 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
841 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
842 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
844 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
845 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
847 /* values for textbutton gadgets */
848 #define ED_TEXTBUTTON_ID_LEVELINFO_LEVEL 0
849 #define ED_TEXTBUTTON_ID_LEVELINFO_EDITOR 1
850 #define ED_TEXTBUTTON_ID_PROPERTIES_INFO 2
851 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG 3
852 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1 4
853 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2 5
854 #define ED_TEXTBUTTON_ID_PROPERTIES_CHANGE 6
855 #define ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2 7
856 #define ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 8
857 #define ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE 9
858 #define ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE 10
860 #define ED_NUM_TEXTBUTTONS 11
862 #define ED_TAB_BUTTON_ID_LEVELINFO_FIRST ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
863 #define ED_TAB_BUTTON_ID_LEVELINFO_LAST ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
865 #define ED_TAB_BUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
866 #define ED_TAB_BUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
868 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
869 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
871 /* values for graphicbutton gadgets */
872 #define ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE 0
873 #define ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE 1
874 #define ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE 2
875 #define ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE 3
877 #define ED_NUM_GRAPHICBUTTONS 4
879 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
880 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
882 /* values for checkbutton gadgets */
883 #define ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS 0
884 #define ED_CHECKBUTTON_ID_RANDOM_RESTRICTED 1
885 #define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3 2
886 #define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2 3
887 #define ED_CHECKBUTTON_ID_STICK_ELEMENT 4
888 #define ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS 5
889 #define ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE 6
890 #define ED_CHECKBUTTON_ID_USE_SPRING_BUG 7
891 #define ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG 8
892 #define ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT 9
893 #define ED_CHECKBUTTON_ID_INITIAL_BALL_STATE 10
894 #define ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE 11
895 #define ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN 12
896 #define ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING 13
897 #define ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD 14
898 #define ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD 15
899 #define ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD 16
900 #define ED_CHECKBUTTON_ID_INSTANT_RELOCATION 17
901 #define ED_CHECKBUTTON_ID_SHIFTED_RELOCATION 18
902 #define ED_CHECKBUTTON_ID_LAZY_RELOCATION 19
903 #define ED_CHECKBUTTON_ID_USE_START_ELEMENT 20
904 #define ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT 21
905 #define ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT 22
906 #define ED_CHECKBUTTON_ID_INITIAL_GRAVITY 23
907 #define ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY 24
908 #define ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE 25
909 #define ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID 26
910 #define ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID 27
911 #define ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH 28
912 #define ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP 29
913 #define ED_CHECKBUTTON_ID_ENVELOPE_CENTERED 30
914 #define ED_CHECKBUTTON_ID_MM_LASER_RED 31
915 #define ED_CHECKBUTTON_ID_MM_LASER_GREEN 32
916 #define ED_CHECKBUTTON_ID_MM_LASER_BLUE 33
917 #define ED_CHECKBUTTON_ID_DF_LASER_RED 34
918 #define ED_CHECKBUTTON_ID_DF_LASER_GREEN 35
919 #define ED_CHECKBUTTON_ID_DF_LASER_BLUE 36
920 #define ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC 37
921 #define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 38
922 #define ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE 39
923 #define ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE 40
924 #define ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE 41
925 #define ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT 42
926 #define ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE 43
927 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE 44
928 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL 45
929 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH 46
930 #define ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY 47
931 #define ED_CHECKBUTTON_ID_CUSTOM_DEADLY 48
932 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE 49
933 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE 50
934 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH 51
935 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT 52
936 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE 53
937 #define ED_CHECKBUTTON_ID_CHANGE_DELAY 54
938 #define ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT 55
939 #define ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT 56
940 #define ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION 57
941 #define ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT 58
942 #define ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE 59
943 #define ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM 60
944 #define ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION 61
946 #define ED_NUM_CHECKBUTTONS 62
948 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
949 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
951 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
952 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2
954 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
955 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
956 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
957 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
958 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
959 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
961 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
962 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
964 /* values for radiobutton gadgets */
965 #define ED_RADIOBUTTON_ID_PERCENTAGE 0
966 #define ED_RADIOBUTTON_ID_QUANTITY 1
968 #define ED_NUM_RADIOBUTTONS 2
970 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
971 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
973 /* values for drawing area gadgets */
974 #define ED_DRAWING_ID_DRAWING_LEVEL 0
975 #define ED_DRAWING_ID_YAMYAM_CONTENT_0 1
976 #define ED_DRAWING_ID_YAMYAM_CONTENT_1 2
977 #define ED_DRAWING_ID_YAMYAM_CONTENT_2 3
978 #define ED_DRAWING_ID_YAMYAM_CONTENT_3 4
979 #define ED_DRAWING_ID_YAMYAM_CONTENT_4 5
980 #define ED_DRAWING_ID_YAMYAM_CONTENT_5 6
981 #define ED_DRAWING_ID_YAMYAM_CONTENT_6 7
982 #define ED_DRAWING_ID_YAMYAM_CONTENT_7 8
983 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 9
984 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_1 10
985 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_2 11
986 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_3 12
987 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_4 13
988 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_5 14
989 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_6 15
990 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_7 16
991 #define ED_DRAWING_ID_ANDROID_CONTENT 17
992 #define ED_DRAWING_ID_AMOEBA_CONTENT 18
993 #define ED_DRAWING_ID_START_ELEMENT 19
994 #define ED_DRAWING_ID_ARTWORK_ELEMENT 20
995 #define ED_DRAWING_ID_EXPLOSION_ELEMENT 21
996 #define ED_DRAWING_ID_INVENTORY_CONTENT 22
997 #define ED_DRAWING_ID_CUSTOM_GRAPHIC 23
998 #define ED_DRAWING_ID_CUSTOM_CONTENT 24
999 #define ED_DRAWING_ID_CUSTOM_MOVE_ENTER 25
1000 #define ED_DRAWING_ID_CUSTOM_MOVE_LEAVE 26
1001 #define ED_DRAWING_ID_CUSTOM_CHANGE_TARGET 27
1002 #define ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT 28
1003 #define ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER 29
1004 #define ED_DRAWING_ID_CUSTOM_CHANGE_ACTION 30
1005 #define ED_DRAWING_ID_GROUP_CONTENT 31
1006 #define ED_DRAWING_ID_RANDOM_BACKGROUND 32
1008 #define ED_NUM_DRAWING_AREAS 33
1010 #define ED_DRAWING_ID_EDITOR_FIRST ED_DRAWING_ID_RANDOM_BACKGROUND
1011 #define ED_DRAWING_ID_EDITOR_LAST ED_DRAWING_ID_RANDOM_BACKGROUND
1015 -----------------------------------------------------------------------------
1016 some internally used definitions
1017 -----------------------------------------------------------------------------
1020 /* values for CopyLevelToUndoBuffer() */
1021 #define UNDO_IMMEDIATE 0
1022 #define UNDO_ACCUMULATE 1
1024 /* values for scrollbars */
1025 #define ED_SCROLL_NO 0
1026 #define ED_SCROLL_LEFT 1
1027 #define ED_SCROLL_RIGHT 2
1028 #define ED_SCROLL_UP 4
1029 #define ED_SCROLL_DOWN 8
1031 /* screens in the level editor */
1032 #define ED_MODE_DRAWING 0
1033 #define ED_MODE_INFO 1
1034 #define ED_MODE_PROPERTIES 2
1035 #define ED_MODE_PALETTE 3
1037 /* sub-screens in the global settings section */
1038 #define ED_MODE_LEVELINFO_LEVEL ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
1039 #define ED_MODE_LEVELINFO_EDITOR ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
1041 /* sub-screens in the element properties section */
1042 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
1043 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
1044 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
1045 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
1046 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
1048 /* how many steps can be cancelled */
1049 #define NUM_UNDO_STEPS (64 + 1)
1051 /* values for elements with score for certain actions */
1053 #define MAX_SCORE 999
1055 /* values for elements with count for collecting */
1056 #define MIN_COLLECT_COUNT 0
1057 #define MAX_COLLECT_COUNT 999
1059 /* values for random placement */
1060 #define RANDOM_USE_PERCENTAGE 0
1061 #define RANDOM_USE_QUANTITY 1
1063 /* default value for element tile size in drawing area */
1064 #define DEFAULT_EDITOR_TILESIZE MINI_TILESIZE
1068 -----------------------------------------------------------------------------
1069 some internally used data structure definitions
1070 -----------------------------------------------------------------------------
1077 struct XYTileSize *pos;
1081 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
1083 /* note: some additional characters are already reserved for "cheat mode"
1084 shortcuts (":XYZ" style) -- for details, see "events.c" */
1086 /* ---------- toolbox control buttons ------------------------------------ */
1089 IMG_GFX_EDITOR_BUTTON_DRAW_SINGLE, GADGET_ID_SINGLE_ITEMS,
1090 &editor.button.draw_single, GD_TYPE_RADIO_BUTTON,
1091 "draw single items", 's'
1094 IMG_GFX_EDITOR_BUTTON_DRAW_CONNECTED, GADGET_ID_CONNECTED_ITEMS,
1095 &editor.button.draw_connected, GD_TYPE_RADIO_BUTTON,
1096 "draw connected items", 'd'
1099 IMG_GFX_EDITOR_BUTTON_DRAW_LINE, GADGET_ID_LINE,
1100 &editor.button.draw_line, GD_TYPE_RADIO_BUTTON,
1104 IMG_GFX_EDITOR_BUTTON_DRAW_ARC, GADGET_ID_ARC,
1105 &editor.button.draw_arc, GD_TYPE_RADIO_BUTTON,
1109 IMG_GFX_EDITOR_BUTTON_DRAW_RECTANGLE, GADGET_ID_RECTANGLE,
1110 &editor.button.draw_rectangle, GD_TYPE_RADIO_BUTTON,
1111 "draw outline rectangles", 'r'
1114 IMG_GFX_EDITOR_BUTTON_DRAW_FILLED_BOX, GADGET_ID_FILLED_BOX,
1115 &editor.button.draw_filled_box, GD_TYPE_RADIO_BUTTON,
1116 "draw filled rectangles", 'R'
1119 IMG_GFX_EDITOR_BUTTON_ROTATE_UP, GADGET_ID_WRAP_UP,
1120 &editor.button.rotate_up, GD_TYPE_NORMAL_BUTTON,
1121 "wrap (rotate) level up", 0
1124 IMG_GFX_EDITOR_BUTTON_DRAW_TEXT, GADGET_ID_TEXT,
1125 &editor.button.draw_text, GD_TYPE_RADIO_BUTTON,
1126 "enter text elements", 't'
1129 IMG_GFX_EDITOR_BUTTON_FLOOD_FILL, GADGET_ID_FLOOD_FILL,
1130 &editor.button.flood_fill, GD_TYPE_RADIO_BUTTON,
1134 IMG_GFX_EDITOR_BUTTON_ROTATE_LEFT, GADGET_ID_WRAP_LEFT,
1135 &editor.button.rotate_left, GD_TYPE_NORMAL_BUTTON,
1136 "wrap (rotate) level left", 0
1139 IMG_GFX_EDITOR_BUTTON_ZOOM_LEVEL, GADGET_ID_ZOOM,
1140 &editor.button.zoom_level, GD_TYPE_NORMAL_BUTTON,
1141 "zoom level tile size", '+'
1144 IMG_GFX_EDITOR_BUTTON_ROTATE_RIGHT, GADGET_ID_WRAP_RIGHT,
1145 &editor.button.rotate_right, GD_TYPE_NORMAL_BUTTON,
1146 "wrap (rotate) level right", 0
1149 IMG_GFX_EDITOR_BUTTON_DRAW_RANDOM, GADGET_ID_RANDOM_PLACEMENT,
1150 &editor.button.draw_random, GD_TYPE_NORMAL_BUTTON,
1151 "random element placement", 0
1154 IMG_GFX_EDITOR_BUTTON_GRAB_BRUSH, GADGET_ID_GRAB_BRUSH,
1155 &editor.button.grab_brush, GD_TYPE_RADIO_BUTTON,
1159 IMG_GFX_EDITOR_BUTTON_ROTATE_DOWN, GADGET_ID_WRAP_DOWN,
1160 &editor.button.rotate_down, GD_TYPE_NORMAL_BUTTON,
1161 "wrap (rotate) level down", 0
1164 IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT, GADGET_ID_PICK_ELEMENT,
1165 &editor.button.pick_element, GD_TYPE_RADIO_BUTTON,
1166 "pick drawing element", ','
1169 /* ---------- level control buttons -------------------------------------- */
1172 IMG_GFX_EDITOR_BUTTON_UNDO, GADGET_ID_UNDO,
1173 &editor.button.undo, GD_TYPE_NORMAL_BUTTON,
1174 "undo/redo last operation", 'u'
1177 IMG_GFX_EDITOR_BUTTON_CONF, GADGET_ID_INFO,
1178 &editor.button.conf, GD_TYPE_NORMAL_BUTTON,
1179 "properties of level", 'I'
1182 IMG_GFX_EDITOR_BUTTON_SAVE, GADGET_ID_SAVE,
1183 &editor.button.save, GD_TYPE_NORMAL_BUTTON,
1187 IMG_GFX_EDITOR_BUTTON_CLEAR, GADGET_ID_CLEAR,
1188 &editor.button.clear, GD_TYPE_NORMAL_BUTTON,
1192 IMG_GFX_EDITOR_BUTTON_TEST, GADGET_ID_TEST,
1193 &editor.button.test, GD_TYPE_NORMAL_BUTTON,
1197 IMG_GFX_EDITOR_BUTTON_EXIT, GADGET_ID_EXIT,
1198 &editor.button.exit, GD_TYPE_NORMAL_BUTTON,
1199 "exit level editor", 'E'
1202 /* ---------- CE and GE control buttons ---------------------------------- */
1205 IMG_GFX_EDITOR_BUTTON_CE_COPY_FROM, GADGET_ID_CUSTOM_COPY_FROM,
1206 &editor.button.ce_copy_from, GD_TYPE_RADIO_BUTTON,
1207 "copy settings from other element", 0
1210 IMG_GFX_EDITOR_BUTTON_CE_COPY_TO, GADGET_ID_CUSTOM_COPY_TO,
1211 &editor.button.ce_copy_to, GD_TYPE_RADIO_BUTTON,
1212 "copy settings to other element", 0
1215 IMG_GFX_EDITOR_BUTTON_CE_SWAP, GADGET_ID_CUSTOM_EXCHANGE,
1216 &editor.button.ce_swap, GD_TYPE_RADIO_BUTTON,
1217 "exchange element with other element", 0
1220 IMG_GFX_EDITOR_BUTTON_CE_COPY, GADGET_ID_CUSTOM_COPY,
1221 &editor.button.ce_copy, GD_TYPE_NORMAL_BUTTON,
1222 "copy settings from this element", 0
1225 IMG_GFX_EDITOR_BUTTON_CE_PASTE, GADGET_ID_CUSTOM_PASTE,
1226 &editor.button.ce_paste, GD_TYPE_NORMAL_BUTTON,
1227 "paste settings to this element", 0
1230 /* ---------- palette control buttons ------------------------------------ */
1233 IMG_GFX_EDITOR_BUTTON_PROPERTIES, GADGET_ID_PROPERTIES,
1234 &editor.button.properties, GD_TYPE_NORMAL_BUTTON,
1235 "properties of drawing element", 'p'
1238 IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT, GADGET_ID_ELEMENT_LEFT,
1239 &editor.button.element_left, GD_TYPE_NORMAL_BUTTON,
1240 "properties of drawing element 1", '1'
1243 IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE, GADGET_ID_ELEMENT_MIDDLE,
1244 &editor.button.element_middle, GD_TYPE_NORMAL_BUTTON,
1245 "properties of drawing element 2", '2'
1248 IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT, GADGET_ID_ELEMENT_RIGHT,
1249 &editor.button.element_right, GD_TYPE_NORMAL_BUTTON,
1250 "properties of drawing element 3", '3'
1253 IMG_GFX_EDITOR_BUTTON_PALETTE, GADGET_ID_PALETTE,
1254 &editor.button.palette, GD_TYPE_NORMAL_BUTTON,
1255 "show list of elements", 'e'
1259 static int random_placement_value = 10;
1260 static int random_placement_method = RANDOM_USE_QUANTITY;
1261 static int random_placement_background_element = EL_SAND;
1262 static boolean random_placement_background_restricted = FALSE;
1263 static boolean stick_element_properties_window = FALSE;
1264 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1265 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1266 static struct ElementChangeInfo custom_element_change;
1267 static struct ElementGroupInfo group_element_info;
1268 static struct ElementInfo custom_element;
1273 int min_value, max_value;
1274 int gadget_id_down, gadget_id_up;
1276 int gadget_id_align;
1278 char *text_above, *text_left, *text_right;
1279 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1281 /* ---------- current level number --------------------------------------- */
1284 -1, -1, /* these values are not constant, but can change at runtime */
1286 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1287 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1292 /* ---------- level and editor settings ---------------------------------- */
1295 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1296 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1297 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1298 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1300 "playfield size:", NULL, "width",
1303 -1, ED_LEVEL_SETTINGS_YPOS(4),
1304 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1305 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1306 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1308 NULL, " ", "height",
1311 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1313 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1314 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1316 NULL, "number of gems to collect:", NULL
1319 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
1321 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1322 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1324 "time or step limit to solve level:", NULL, NULL
1327 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
1329 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1330 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1331 &level.score[SC_TIME_BONUS],
1332 "score for each second/step left:", NULL, NULL
1335 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(13),
1337 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1338 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1340 NULL, "random seed:", "(0 => random)"
1343 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1345 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1346 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1347 &random_placement_value,
1348 "random element placement:", NULL, "in"
1351 /* ---------- element settings: configure (various elements) ------------- */
1354 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1355 MIN_SCORE, MAX_SCORE,
1356 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1357 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1358 NULL, /* will be set when used */
1362 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1363 MIN_SCORE, MAX_SCORE,
1364 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1365 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1366 NULL, /* will be set when used */
1370 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1371 MIN_SCORE, MAX_SCORE,
1372 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1373 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1374 NULL, /* will be set when used */
1378 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1379 MIN_SCORE, MAX_SCORE,
1380 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1381 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1382 NULL, /* will be set when used */
1386 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1387 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1388 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1389 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1390 &level.num_yamyam_contents,
1391 NULL, NULL, "number of content areas"
1394 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1395 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1396 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1397 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1398 &level.num_ball_contents,
1399 NULL, NULL, "number of content areas"
1402 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1403 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1404 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1405 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1406 &level.num_android_clone_elements,
1407 NULL, NULL, "number of clonable elements"
1410 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1411 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1412 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1413 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1414 NULL, /* will be set when used */
1415 NULL, NULL, "width",
1418 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1419 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1420 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1421 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1422 NULL, /* will be set when used */
1423 NULL, " ", "height",
1426 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1427 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1428 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1429 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1430 &level.initial_inventory_size[0],
1431 NULL, NULL, "number of inventory elements"
1434 /* ---------- element settings: configure 1 (custom elements) ------------ */
1437 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1438 MIN_SCORE, MAX_SCORE,
1439 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1440 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1441 &custom_element.collect_score_initial,
1442 NULL, "CE score", " "
1445 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1446 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1447 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1448 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1449 &custom_element.collect_count_initial,
1450 NULL, "CE count", NULL
1453 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1455 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1456 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1457 &custom_element.ce_value_fixed_initial,
1458 NULL, "CE value", NULL
1461 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1463 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1464 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1465 &custom_element.ce_value_random_initial,
1466 NULL, "+random", NULL
1469 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1471 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1472 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1473 &custom_element.push_delay_fixed,
1474 NULL, "push delay", NULL
1477 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1479 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1480 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1481 &custom_element.push_delay_random,
1482 NULL, "+random", NULL
1485 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1487 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1488 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1489 &custom_element.drop_delay_fixed,
1490 NULL, "drop delay", NULL
1493 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1495 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1496 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1497 &custom_element.drop_delay_random,
1498 NULL, "+random", NULL
1501 /* ---------- element settings: configure 2 (custom elements) ------------ */
1504 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1506 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1507 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1508 &custom_element.move_delay_fixed,
1509 NULL, "move delay", NULL
1512 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1514 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1515 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1516 &custom_element.move_delay_random,
1517 NULL, "+random", NULL
1520 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
1522 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1523 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1524 &custom_element.explosion_delay,
1525 NULL, "explosion delay", NULL
1528 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1530 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1531 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1532 &custom_element.ignition_delay,
1533 NULL, "ignition delay", "(by fire)"
1536 /* ---------- element settings: configure (group elements) --------------- */
1539 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1540 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1541 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1542 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1543 &group_element_info.num_elements,
1544 NULL, NULL, "number of elements in group"
1547 /* ---------- element settings: advanced (custom elements) --------------- */
1550 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1552 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1553 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1554 &custom_element_change.delay_fixed,
1555 NULL, "CE delay", NULL,
1558 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1560 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1561 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1562 &custom_element_change.delay_random,
1563 NULL, "+random", NULL
1566 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1568 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1569 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1570 &custom_element_change.random_percentage,
1571 NULL, "use random replace:", "%"
1581 char *text_above, *infotext;
1582 } textinput_info[ED_NUM_TEXTINPUT] =
1585 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1586 GADGET_ID_LEVEL_NAME,
1592 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1593 GADGET_ID_LEVEL_AUTHOR,
1594 MAX_LEVEL_AUTHOR_LEN,
1599 -1, -1, /* these values are not constant, but can change at runtime */
1600 GADGET_ID_ELEMENT_NAME,
1601 MAX_ELEMENT_NAME_LEN - 2, /* currently 2 chars less editable */
1602 custom_element.description,
1603 NULL, "Element name"
1613 char *text_above, *infotext;
1614 } textarea_info[ED_NUM_TEXTAREAS] =
1617 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1618 GADGET_ID_ENVELOPE_INFO,
1619 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1621 "Envelope Content:", "Envelope Content"
1625 static struct ValueTextInfo options_time_or_steps[] =
1633 static struct ValueTextInfo options_game_engine_type[] =
1635 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1636 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1637 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1638 { GAME_ENGINE_TYPE_MM, "Mirror Magic" },
1643 static struct ValueTextInfo options_wind_direction[] =
1645 { MV_START_NONE, "none" },
1646 { MV_START_LEFT, "left" },
1647 { MV_START_RIGHT, "right" },
1648 { MV_START_UP, "up" },
1649 { MV_START_DOWN, "down" },
1654 static struct ValueTextInfo options_player_speed[] =
1661 { 16, "very fast" },
1662 { 32, "ultrafast" },
1667 static struct ValueTextInfo options_access_type[] =
1669 { EP_WALKABLE, "walkable" },
1670 { EP_PASSABLE, "passable" },
1675 static struct ValueTextInfo options_access_layer[] =
1677 { EP_ACCESSIBLE_OVER, "over" },
1678 { EP_ACCESSIBLE_INSIDE, "inside" },
1679 { EP_ACCESSIBLE_UNDER, "under" },
1684 static struct ValueTextInfo options_access_protected[] =
1686 { 0, "unprotected" },
1692 static struct ValueTextInfo options_access_direction[] =
1694 { MV_NO_DIRECTION, "no direction" },
1695 { MV_LEFT, "left" },
1696 { MV_RIGHT, "right" },
1698 { MV_DOWN, "down" },
1699 { MV_LEFT | MV_UP, "left + up" },
1700 { MV_LEFT | MV_DOWN, "left + down" },
1701 { MV_RIGHT | MV_UP, "right + up" },
1702 { MV_RIGHT | MV_DOWN, "right + down" },
1703 { MV_HORIZONTAL, "horizontal" },
1704 { MV_VERTICAL, "vertical" },
1705 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1706 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1707 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1708 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1709 { MV_ALL_DIRECTIONS, "all directions" },
1714 static struct ValueTextInfo options_walk_to_action[] =
1716 { EP_DIGGABLE, "diggable" },
1717 { EP_COLLECTIBLE_ONLY, "collectible" },
1718 { EP_DROPPABLE, "collectible & droppable" },
1719 { EP_THROWABLE, "collectible & throwable" },
1720 { EP_PUSHABLE, "pushable" },
1725 static struct ValueTextInfo options_move_pattern[] =
1727 { MV_LEFT, "left" },
1728 { MV_RIGHT, "right" },
1730 { MV_DOWN, "down" },
1731 { MV_HORIZONTAL, "horizontal" },
1732 { MV_VERTICAL, "vertical" },
1733 { MV_ALL_DIRECTIONS, "all directions" },
1734 { MV_WIND_DIRECTION, "wind direction" },
1735 { MV_TOWARDS_PLAYER, "towards player" },
1736 { MV_AWAY_FROM_PLAYER, "away from player" },
1737 { MV_ALONG_LEFT_SIDE, "along left side" },
1738 { MV_ALONG_RIGHT_SIDE, "along right side" },
1739 { MV_TURNING_LEFT, "turning left" },
1740 { MV_TURNING_RIGHT, "turning right" },
1741 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1742 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1743 { MV_TURNING_RANDOM, "turning random" },
1744 { MV_MAZE_RUNNER, "maze runner style" },
1745 { MV_MAZE_HUNTER, "maze hunter style" },
1746 { MV_WHEN_PUSHED, "when pushed" },
1747 { MV_WHEN_DROPPED, "when dropped/thrown" },
1752 static struct ValueTextInfo options_move_direction[] =
1754 { MV_START_AUTOMATIC, "automatic" },
1755 { MV_START_LEFT, "left" },
1756 { MV_START_RIGHT, "right" },
1757 { MV_START_UP, "up" },
1758 { MV_START_DOWN, "down" },
1759 { MV_START_RANDOM, "random" },
1760 { MV_START_PREVIOUS, "previous" },
1765 static struct ValueTextInfo options_move_stepsize[] =
1767 { 0, "not moving" },
1772 { 16, "very fast" },
1773 { 32, "even faster" },
1778 static struct ValueTextInfo options_move_leave_type[] =
1780 { LEAVE_TYPE_UNLIMITED, "leave behind" },
1781 { LEAVE_TYPE_LIMITED, "change it to" },
1786 static struct ValueTextInfo options_smash_targets[] =
1788 { EP_CAN_SMASH_PLAYER, "player" },
1790 { EP_CAN_SMASH_ENEMIES, "enemies" },
1792 { EP_CAN_SMASH_EVERYTHING, "everything" },
1797 static struct ValueTextInfo options_slippery_type[] =
1799 { SLIPPERY_ANY_RANDOM, "random" },
1800 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
1801 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
1802 { SLIPPERY_ONLY_LEFT, "only left" },
1803 { SLIPPERY_ONLY_RIGHT, "only right" },
1808 static struct ValueTextInfo options_deadliness[] =
1810 { EP_DONT_RUN_INTO, "running into" },
1811 { EP_DONT_COLLIDE_WITH, "colliding with" },
1812 { EP_DONT_GET_HIT_BY, "getting hit by" },
1813 { EP_DONT_TOUCH, "touching" },
1818 static struct ValueTextInfo options_explosion_type[] =
1820 { EXPLODES_3X3, "3x3" },
1821 { EXPLODES_CROSS, "3+3" },
1822 { EXPLODES_1X1, "1x1" },
1827 static struct ValueTextInfo options_time_units[] =
1830 { FRAMES_PER_SECOND, "seconds" },
1835 static struct ValueTextInfo options_change_direct_action[] =
1837 { CE_TOUCHED_BY_PLAYER, "touched by player" },
1838 { CE_PRESSED_BY_PLAYER, "pressed by player" },
1839 { CE_SWITCHED_BY_PLAYER, "switched by player" },
1840 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
1841 { CE_PUSHED_BY_PLAYER, "pushed by player" },
1842 { CE_ENTERED_BY_PLAYER, "entered by player" },
1843 { CE_LEFT_BY_PLAYER, "left by player" },
1844 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
1845 { CE_SWITCHED, "switched" },
1846 { CE_HITTING_SOMETHING, "hitting something" },
1847 { CE_HIT_BY_SOMETHING, "hit by something" },
1849 { CE_BLOCKED, "blocked" },
1851 { CE_IMPACT, "impact (on something)" },
1852 { CE_SMASHED, "smashed (from above)" },
1854 { CE_VALUE_CHANGES, "CE value changes" },
1855 { CE_SCORE_CHANGES, "CE score changes" },
1857 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
1858 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
1863 static struct ValueTextInfo options_change_other_action[] =
1865 { CE_PLAYER_TOUCHES_X, "player touches" },
1866 { CE_PLAYER_PRESSES_X, "player presses" },
1867 { CE_PLAYER_SWITCHES_X, "player switches" },
1868 { CE_PLAYER_SNAPS_X, "player snaps" },
1869 { CE_PLAYER_PUSHES_X, "player pushes" },
1870 { CE_PLAYER_ENTERS_X, "player enters" },
1871 { CE_PLAYER_LEAVES_X, "player leaves" },
1872 { CE_PLAYER_DIGS_X, "player digs" },
1873 { CE_PLAYER_COLLECTS_X, "player collects" },
1874 { CE_PLAYER_DROPS_X, "player drops/throws" },
1875 { CE_TOUCHING_X, "touching" },
1876 { CE_HITTING_X, "hitting" },
1877 { CE_DIGGING_X, "digging" },
1878 { CE_HIT_BY_X, "hit by" },
1879 { CE_SWITCH_OF_X, "switch of" },
1880 { CE_CHANGE_OF_X, "change by page of" },
1881 { CE_EXPLOSION_OF_X, "explosion of" },
1882 { CE_MOVE_OF_X, "move of" },
1883 { CE_CREATION_OF_X, "creation of" },
1884 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
1885 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
1886 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
1887 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
1892 static struct ValueTextInfo options_change_trigger_side[] =
1894 { CH_SIDE_LEFT, "left" },
1895 { CH_SIDE_RIGHT, "right" },
1896 { CH_SIDE_TOP, "top" },
1897 { CH_SIDE_BOTTOM, "bottom" },
1898 { CH_SIDE_LEFT_RIGHT, "left/right" },
1899 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
1900 { CH_SIDE_ANY, "any" },
1905 static struct ValueTextInfo options_change_trigger_player[] =
1907 { CH_PLAYER_1, "1" },
1908 { CH_PLAYER_2, "2" },
1909 { CH_PLAYER_3, "3" },
1910 { CH_PLAYER_4, "4" },
1911 { CH_PLAYER_ANY, "any" },
1916 static struct ValueTextInfo options_change_trigger_page[] =
1928 { (1 << 10), "11" },
1929 { (1 << 11), "12" },
1930 { (1 << 12), "13" },
1931 { (1 << 13), "14" },
1932 { (1 << 14), "15" },
1933 { (1 << 15), "16" },
1934 { (1 << 16), "17" },
1935 { (1 << 17), "18" },
1936 { (1 << 18), "19" },
1937 { (1 << 19), "20" },
1938 { (1 << 20), "21" },
1939 { (1 << 21), "22" },
1940 { (1 << 22), "23" },
1941 { (1 << 23), "24" },
1942 { (1 << 24), "25" },
1943 { (1 << 25), "26" },
1944 { (1 << 26), "27" },
1945 { (1 << 27), "28" },
1946 { (1 << 28), "29" },
1947 { (1 << 29), "30" },
1948 { (1 << 30), "31" },
1949 { (1 << 31), "32" },
1950 { CH_PAGE_ANY, "any" },
1955 static struct ValueTextInfo options_change_replace_when[] =
1957 { CP_WHEN_EMPTY, "empty" },
1958 { CP_WHEN_WALKABLE, "walkable" },
1959 { CP_WHEN_DIGGABLE, "diggable" },
1960 { CP_WHEN_COLLECTIBLE, "collectible" },
1961 { CP_WHEN_REMOVABLE, "removable" },
1962 { CP_WHEN_DESTRUCTIBLE, "destructible" },
1967 static struct ValueTextInfo options_action_type[] =
1969 { CA_NO_ACTION, "no action" },
1970 { CA_UNDEFINED, " " },
1971 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
1972 { CA_RESTART_LEVEL, "restart level" },
1973 { CA_SHOW_ENVELOPE, "show envelope" },
1974 { CA_SET_LEVEL_TIME, "set time" },
1975 { CA_SET_LEVEL_SCORE, "set score" },
1976 { CA_SET_LEVEL_GEMS, "set gems" },
1977 { CA_SET_LEVEL_WIND, "set wind dir." },
1978 { CA_SET_LEVEL_RANDOM_SEED, "set rand. seed" },
1979 { CA_UNDEFINED, " " },
1980 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
1981 { CA_MOVE_PLAYER, "move player" },
1982 { CA_EXIT_PLAYER, "exit player" },
1983 { CA_KILL_PLAYER, "kill player" },
1984 { CA_SET_PLAYER_KEYS, "set keys" },
1985 { CA_SET_PLAYER_SPEED, "set speed" },
1986 { CA_SET_PLAYER_SHIELD, "set shield" },
1987 { CA_SET_PLAYER_GRAVITY, "set gravity" },
1988 { CA_SET_PLAYER_ARTWORK, "set artwork" },
1989 { CA_SET_PLAYER_INVENTORY, "set inventory" },
1990 { CA_UNDEFINED, " " },
1991 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
1992 { CA_SET_CE_VALUE, "set CE value" },
1993 { CA_SET_CE_SCORE, "set CE score" },
1994 { CA_SET_CE_ARTWORK, "set CE artwork" },
1995 { CA_UNDEFINED, " " },
1996 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
1997 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
2002 static struct ValueTextInfo options_action_mode_none[] =
2004 { CA_MODE_UNDEFINED, " " },
2009 static struct ValueTextInfo options_action_mode_assign[] =
2011 { CA_MODE_SET, "=" },
2016 static struct ValueTextInfo options_action_mode_add_remove[] =
2018 { CA_MODE_ADD, "+" },
2019 { CA_MODE_SUBTRACT, "-" },
2024 static struct ValueTextInfo options_action_mode_calculate[] =
2026 { CA_MODE_SET, "=" },
2027 { CA_MODE_ADD, "+" },
2028 { CA_MODE_SUBTRACT, "-" },
2029 { CA_MODE_MULTIPLY, "*" },
2030 { CA_MODE_DIVIDE, "/" },
2031 { CA_MODE_MODULO, "%" },
2036 static struct ValueTextInfo options_action_arg_none[] =
2038 { CA_ARG_UNDEFINED, " " },
2043 static struct ValueTextInfo options_action_arg_player[] =
2045 { CA_ARG_PLAYER_HEADLINE, "[player]" },
2046 { CA_ARG_PLAYER_1, "1" },
2047 { CA_ARG_PLAYER_2, "2" },
2048 { CA_ARG_PLAYER_3, "3" },
2049 { CA_ARG_PLAYER_4, "4" },
2050 { CA_ARG_PLAYER_ANY, "any" },
2051 { CA_ARG_PLAYER_TRIGGER, "trigger" },
2052 { CA_ARG_PLAYER_ACTION, "action ->" },
2057 static struct ValueTextInfo options_action_arg_number[] =
2059 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2066 { CA_ARG_10, "10" },
2067 { CA_ARG_100, "100" },
2068 { CA_ARG_1000, "1000" },
2069 { CA_ARG_UNDEFINED, " " },
2070 { CA_ARG_NUMBER_MIN, "min" },
2071 { CA_ARG_NUMBER_MAX, "max" },
2072 { CA_ARG_UNDEFINED, " " },
2073 { CA_ARG_NUMBER_RESET, "reset" },
2074 { CA_ARG_UNDEFINED, " " },
2075 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2076 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2077 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2078 { CA_ARG_UNDEFINED, " " },
2079 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2080 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2081 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2082 { CA_ARG_UNDEFINED, " " },
2083 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2084 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2085 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2086 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2087 { CA_ARG_UNDEFINED, " " },
2088 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2089 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2090 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2091 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2096 static struct ValueTextInfo options_action_arg_value[] =
2098 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2105 { CA_ARG_10, "10" },
2106 { CA_ARG_100, "100" },
2107 { CA_ARG_1000, "1000" },
2108 { CA_ARG_UNDEFINED, " " },
2109 { CA_ARG_NUMBER_MIN, "min" },
2110 { CA_ARG_NUMBER_MAX, "max" },
2111 { CA_ARG_UNDEFINED, " " },
2112 { CA_ARG_NUMBER_RESET, "reset" },
2113 { CA_ARG_UNDEFINED, " " },
2114 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2115 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2116 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2117 { CA_ARG_UNDEFINED, " " },
2118 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2119 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2120 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2121 { CA_ARG_UNDEFINED, " " },
2122 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2123 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2124 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2125 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2126 { CA_ARG_UNDEFINED, " " },
2127 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2128 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2129 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2130 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2131 { CA_ARG_UNDEFINED, " " },
2132 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
2133 { CA_ARG_ELEMENT_NR_TARGET, "target" },
2134 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
2135 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
2140 static struct ValueTextInfo options_action_arg_envelope[] =
2142 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2147 { CA_ARG_UNDEFINED, " " },
2148 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2149 { CA_ARG_ELEMENT_TARGET, "target" },
2150 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2151 { CA_ARG_ELEMENT_ACTION, "action ->" },
2156 static struct ValueTextInfo options_action_arg_key[] =
2158 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2167 { CA_ARG_UNDEFINED, " " },
2168 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2169 { CA_ARG_ELEMENT_TARGET, "target" },
2170 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2171 { CA_ARG_ELEMENT_ACTION, "action ->" },
2176 static struct ValueTextInfo options_action_arg_speed[] =
2178 { CA_ARG_SPEED_HEADLINE, "[speed]" },
2179 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
2180 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
2181 { CA_ARG_SPEED_SLOW, "slow" },
2182 { CA_ARG_SPEED_NORMAL, "normal" },
2183 { CA_ARG_SPEED_FAST, "fast" },
2184 { CA_ARG_SPEED_VERY_FAST, "very fast" },
2185 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
2186 { CA_ARG_UNDEFINED, " " },
2187 { CA_ARG_SPEED_SLOWER, "slower" },
2188 { CA_ARG_SPEED_FASTER, "faster" },
2189 { CA_ARG_UNDEFINED, " " },
2190 { CA_ARG_SPEED_RESET, "reset" },
2195 static struct ValueTextInfo options_action_arg_shield[] =
2197 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
2198 { CA_ARG_SHIELD_OFF, "off" },
2199 { CA_ARG_SHIELD_NORMAL, "normal" },
2200 { CA_ARG_SHIELD_DEADLY, "deadly" },
2205 static struct ValueTextInfo options_action_arg_artwork[] =
2207 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2208 { CA_ARG_ELEMENT_TARGET, "target" },
2209 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2210 { CA_ARG_ELEMENT_ACTION, "action ->" },
2211 { CA_ARG_UNDEFINED, " " },
2212 { CA_ARG_ELEMENT_RESET, "reset" },
2217 static struct ValueTextInfo options_action_arg_gravity[] =
2219 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
2220 { CA_ARG_GRAVITY_ON, "on" },
2221 { CA_ARG_GRAVITY_OFF, "off" },
2222 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2227 static struct ValueTextInfo options_action_arg_direction[] =
2229 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2230 { CA_ARG_DIRECTION_NONE, "none" },
2231 { CA_ARG_DIRECTION_LEFT, "left" },
2232 { CA_ARG_DIRECTION_RIGHT, "right" },
2233 { CA_ARG_DIRECTION_UP, "up" },
2234 { CA_ARG_DIRECTION_DOWN, "down" },
2235 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2236 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2241 static struct ValueTextInfo options_action_arg_scan_mode[] =
2243 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2244 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2245 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2250 static struct ValueTextInfo options_action_arg_inventory[] =
2252 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2253 { CA_ARG_ELEMENT_TARGET, "+ target" },
2254 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2255 { CA_ARG_ELEMENT_ACTION, "+ action" },
2256 { CA_ARG_UNDEFINED, " " },
2257 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2258 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2259 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2260 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2261 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2262 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2263 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2264 { CA_ARG_UNDEFINED, " " },
2265 { CA_ARG_INVENTORY_RESET, "reset" },
2270 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2271 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2276 static struct ValueTextInfo options_group_choice_mode[] =
2278 { ANIM_RANDOM, "random" },
2279 { ANIM_LOOP, "loop" },
2280 { ANIM_LINEAR, "linear" },
2281 { ANIM_PINGPONG, "pingpong" },
2282 { ANIM_PINGPONG2, "pingpong 2" },
2287 static struct ValueTextInfo *action_arg_modes[] =
2289 options_action_mode_none,
2290 options_action_mode_assign,
2291 options_action_mode_add_remove,
2292 options_action_mode_calculate,
2299 struct ValueTextInfo *options;
2301 action_arg_options[] =
2303 { CA_NO_ACTION, 0, options_action_arg_none, },
2304 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2305 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2306 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2307 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2308 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2309 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2310 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2311 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2312 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2313 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2314 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2315 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2316 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2317 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2318 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2319 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2320 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2321 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2322 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2323 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2332 int gadget_id_align;
2333 int size; /* char size of selectbox or '-1' (dynamically determined) */
2334 struct ValueTextInfo *options;
2336 char *text_left, *text_right, *infotext;
2337 } selectbox_info[ED_NUM_SELECTBOX] =
2339 /* ---------- level and editor settings ---------------------------------- */
2342 -1, ED_LEVEL_SETTINGS_YPOS(8),
2343 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2345 options_time_or_steps,
2346 &level.use_step_counter,
2347 NULL, "(0 => no limit)", "time or step limit"
2350 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
2351 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2353 options_game_engine_type,
2354 &level.game_engine_type,
2355 "game engine:", NULL, "game engine"
2358 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
2359 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2361 options_wind_direction,
2362 &level.wind_direction_initial,
2363 "initial wind direction:", NULL, "initial wind direction"
2366 /* ---------- element settings: configure (several elements) ------------- */
2369 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2370 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2372 options_player_speed,
2373 &level.initial_player_stepsize[0],
2374 "initial player speed:", NULL, "initial player speed"
2377 /* ---------- element settings: configure 1 (custom elements) ------------ */
2380 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2381 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2383 options_access_type,
2384 &custom_element.access_type,
2385 NULL, NULL, "type of access to this field"
2388 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2389 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2391 options_access_layer,
2392 &custom_element.access_layer,
2393 NULL, NULL, "layer of access for this field"
2396 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2397 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2399 options_access_protected,
2400 &custom_element.access_protected,
2401 NULL, NULL, "protected access for this field"
2404 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2405 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2407 options_access_direction,
2408 &custom_element.access_direction,
2409 "from", NULL, "access direction for this field"
2412 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2413 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2415 options_walk_to_action,
2416 &custom_element.walk_to_action,
2417 NULL, NULL, "diggable/collectible/pushable"
2420 /* ---------- element settings: configure 2 (custom elements) ------------ */
2423 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2424 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2426 options_move_pattern,
2427 &custom_element.move_pattern,
2428 "can move", NULL, "element move pattern"
2431 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2432 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2434 options_move_direction,
2435 &custom_element.move_direction_initial,
2436 "starts moving", NULL, "initial element move direction"
2439 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2440 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2442 options_move_stepsize,
2443 &custom_element.move_stepsize,
2444 "move/fall speed", NULL, "speed of element movement"
2447 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2448 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2450 options_move_leave_type,
2451 &custom_element.move_leave_type,
2452 // left text with leading spaces to place gadget next to "can dig" gadget
2453 // (needed because drawing area gadgets created after selectbox gadgets)
2454 // "can dig: can", ":", "leave behind or change element"
2455 " can", ":", "leave behind or change element"
2458 -1, ED_ELEMENT_SETTINGS_YPOS(7),
2459 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2461 options_smash_targets,
2462 &custom_element.smash_targets,
2463 "can smash", NULL, "elements that can be smashed"
2466 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
2467 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2469 options_slippery_type,
2470 &custom_element.slippery_type,
2471 "slippery", NULL, "where other elements fall down"
2474 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2475 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2478 &custom_element.deadliness,
2479 "deadly when", NULL, "deadliness of element"
2482 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2483 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2485 options_explosion_type,
2486 &custom_element.explosion_type,
2487 "can explode", NULL, "explosion type"
2490 /* ---------- element settings: advanced (custom elements) --------------- */
2493 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2494 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2497 &custom_element_change.delay_frames,
2498 "delay time given in", NULL, "delay time units for change"
2501 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2502 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2504 options_change_direct_action,
2505 &custom_element_change.direct_action,
2506 NULL, NULL, "type of direct action"
2509 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2510 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2512 options_change_other_action,
2513 &custom_element_change.other_action,
2514 NULL, "element:", "type of other element action"
2517 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2518 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2520 options_change_trigger_side,
2521 &custom_element_change.trigger_side,
2522 "at", "side", "element side triggering change"
2525 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2526 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2528 options_change_trigger_player,
2529 &custom_element_change.trigger_player,
2530 "player:", " ", "player that causes change"
2533 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2534 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2536 options_change_trigger_page,
2537 &custom_element_change.trigger_page,
2538 "page:", NULL, "change page that causes change"
2541 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2542 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2544 options_change_replace_when,
2545 &custom_element_change.replace_when,
2546 "replace when", NULL, "which elements can be replaced"
2549 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2550 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2552 options_action_type,
2553 &custom_element_change.action_type,
2554 NULL, NULL, "action on specified condition"
2557 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2558 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2560 options_action_mode_none,
2561 &custom_element_change.action_mode,
2562 NULL, NULL, "action operator"
2565 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2566 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2568 options_action_arg_none,
2569 &custom_element_change.action_arg,
2570 NULL, NULL, "action parameter"
2573 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2574 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2576 options_change_page,
2577 &custom_element.current_change_page,
2578 NULL, NULL, "element change page"
2581 /* ---------- element settings: configure (group elements) --------------- */
2584 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2585 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2587 options_group_choice_mode,
2588 &group_element_info.choice_mode,
2589 "choice type:", NULL, "type of group element choice"
2597 int gadget_id_align;
2600 char *text_above, *text_left, *text_right, *infotext;
2601 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2603 /* ---------- level and editor settings (tabs) --------------------------- */
2606 ED_LEVEL_TABS_XPOS(0), ED_LEVEL_TABS_YPOS(0),
2607 GADGET_ID_LEVELINFO_LEVEL, GADGET_ID_NONE,
2609 NULL, NULL, NULL, "Configure level properties"
2613 GADGET_ID_LEVELINFO_EDITOR, GADGET_ID_LEVELINFO_LEVEL,
2615 NULL, NULL, NULL, "Configure editor properties"
2618 /* ---------- element settings (tabs) ------------------------------------ */
2621 ED_ELEMENT_TABS_XPOS(0), ED_ELEMENT_TABS_YPOS(0),
2622 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
2624 NULL, NULL, NULL, "Show information about element"
2628 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_PROPERTIES_INFO,
2630 NULL, NULL, NULL, "Configure element properties"
2634 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_PROPERTIES_INFO,
2636 NULL, NULL, NULL, "Configure element properties, part 1"
2640 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_PROPERTIES_CONFIG_1,
2642 NULL, NULL, NULL, "Configure element properties, part 2"
2646 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_PROPERTIES_CONFIG_2,
2648 NULL, NULL, NULL, "Configure custom element change pages"
2651 /* ---------- level and editor settings (buttons) ------------------------ */
2654 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
2655 GADGET_ID_SAVE_AS_TEMPLATE_2, GADGET_ID_NONE,
2657 NULL, NULL, "this level as level template",
2658 "Save current settings as new template"
2661 /* ---------- element settings (buttons) --------------------------------- */
2665 GADGET_ID_SAVE_AS_TEMPLATE_1, GADGET_ID_CUSTOM_USE_TEMPLATE_1,
2667 NULL, " ", "As Template",
2668 "Save current settings as new template"
2672 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
2674 NULL, NULL, NULL, "Add new change page"
2678 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
2680 NULL, NULL, NULL, "Delete current change page"
2689 int gadget_id_align;
2690 char *text_left, *text_right, *infotext;
2691 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
2694 IMG_EDITOR_COUNTER_DOWN,
2695 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
2696 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
2697 NULL, NULL, "select previous change page"
2700 IMG_EDITOR_COUNTER_UP,
2701 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2702 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
2703 NULL, "change page", "select next change page"
2706 IMG_GFX_EDITOR_BUTTON_CP_COPY,
2707 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2708 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
2709 " ", NULL, "copy settings from this change page"
2712 IMG_GFX_EDITOR_BUTTON_CP_PASTE,
2713 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2714 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
2715 NULL, NULL, "paste settings to this change page"
2722 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
2729 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
2732 IMG_EDITOR_PLAYFIELD_SCROLL_UP,
2733 GADGET_ID_SCROLL_UP,
2734 "scroll level editing area up"
2737 IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
2738 GADGET_ID_SCROLL_DOWN,
2739 "scroll level editing area down"
2742 IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
2743 GADGET_ID_SCROLL_LEFT,
2744 "scroll level editing area left"
2747 IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
2748 GADGET_ID_SCROLL_RIGHT,
2749 "scroll level editing area right"
2752 IMG_EDITOR_PALETTE_SCROLL_UP,
2753 GADGET_ID_SCROLL_LIST_UP,
2754 "scroll element list up ('Page Up')"
2757 IMG_EDITOR_PALETTE_SCROLL_DOWN,
2758 GADGET_ID_SCROLL_LIST_DOWN,
2759 "scroll element list down ('Page Down')"
2767 int wheel_x, wheel_y;
2768 int wheel_width, wheel_height;
2769 } scrollbar_pos[ED_NUM_SCROLLBARS];
2777 } scrollbar_info[ED_NUM_SCROLLBARS] =
2780 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
2781 GD_TYPE_SCROLLBAR_HORIZONTAL,
2782 GADGET_ID_SCROLL_HORIZONTAL,
2783 "scroll level editing area horizontally"
2786 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
2787 GD_TYPE_SCROLLBAR_VERTICAL,
2788 GADGET_ID_SCROLL_VERTICAL,
2789 "scroll level editing area vertically"
2792 IMG_EDITOR_PALETTE_SCROLLBAR,
2793 GD_TYPE_SCROLLBAR_VERTICAL,
2794 GADGET_ID_SCROLL_LIST_VERTICAL,
2795 "scroll element list vertically"
2804 int gadget_id_align;
2805 int radio_button_nr;
2808 char *text_left, *text_right, *infotext;
2809 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
2812 -1, ED_LEVEL_SETTINGS_YPOS(0),
2813 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
2814 RADIO_NR_RANDOM_ELEMENTS,
2815 &random_placement_method, RANDOM_USE_PERCENTAGE,
2816 " ", "percentage", "use percentage for random elements"
2819 -1, ED_LEVEL_SETTINGS_YPOS(0),
2820 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
2821 RADIO_NR_RANDOM_ELEMENTS,
2822 &random_placement_method, RANDOM_USE_QUANTITY,
2823 " ", "quantity", "use quantity for random elements"
2831 int gadget_id_align;
2833 char *text_above, *text_left, *text_right, *infotext;
2834 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
2836 /* ---------- level and editor settings ---------------------------------- */
2839 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
2840 GADGET_ID_AUTO_COUNT_GEMS, GADGET_ID_NONE,
2841 &level.auto_count_gems,
2843 "automatically count gems needed", "set counter to number of gems"
2846 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
2847 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
2848 &random_placement_background_restricted,
2850 "restrict random placement to:", "set random placement restriction"
2853 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
2854 GADGET_ID_CUSTOM_USE_TEMPLATE_3, GADGET_ID_NONE,
2855 &setup.editor.use_template_for_new_levels,
2856 "Template for new levels and CE/GE:", NULL,
2857 "use template for new levels", "use template for level properties"
2860 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
2861 GADGET_ID_CUSTOM_USE_TEMPLATE_2, GADGET_ID_NONE,
2862 &level.use_custom_template,
2864 "use template for custom elements", "use template for custom properties"
2867 /* ---------- element settings: configure (various elements) ------------- */
2870 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2871 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
2872 &stick_element_properties_window,
2874 "stick this screen to edit content","stick this screen to edit content"
2877 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2878 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
2879 &level.em_slippery_gems,
2881 "slip down from certain flat walls","use EM/DC style slipping behaviour"
2884 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2885 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
2886 &level.em_explodes_by_fire,
2888 "explodes with chain reaction", "use R'n'D style explosion behaviour"
2891 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2892 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
2893 &level.use_spring_bug,
2895 "use spring pushing bug", "use odd spring pushing behaviour"
2898 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2899 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
2900 &level.use_time_orb_bug,
2902 "use time orb bug", "use odd time orb behaviour"
2905 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2906 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
2909 "create single random element", "only create one element from content"
2912 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2913 GADGET_ID_INITIAL_BALL_STATE, GADGET_ID_NONE,
2914 &level.ball_state_initial,
2916 "magic ball initially activated", "activate magic ball after level start"
2919 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2920 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
2921 &level.grow_into_diggable,
2923 "can grow into anything diggable", "grow into more than just sand"
2926 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2927 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
2928 &level.auto_exit_sokoban,
2930 "exit level if all fields solved", "automatically finish Sokoban levels"
2933 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
2934 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
2935 &level.continuous_snapping,
2937 "continuous snapping", "use snapping without releasing key"
2940 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
2941 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
2942 &level.block_snap_field,
2944 "block snapped field when snapping", "use snapping delay to show animation"
2947 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2948 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
2949 &level.block_last_field,
2951 "block last field when moving", "player blocks last field when moving"
2954 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2955 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
2956 &level.sp_block_last_field,
2958 "block last field when moving", "player blocks last field when moving"
2961 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
2962 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
2963 &level.instant_relocation,
2965 "no scrolling when relocating", "player gets relocated without delay"
2968 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2969 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
2970 &level.shifted_relocation,
2972 "no centering when relocating", "level not centered after relocation"
2975 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
2976 GADGET_ID_LAZY_RELOCATION, GADGET_ID_NONE,
2977 &level.lazy_relocation,
2979 "only redraw off-screen relocation","no redraw if relocation target visible"
2982 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
2983 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
2984 &level.use_start_element[0],
2986 "use level start element:", "start level at this element's position"
2989 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
2990 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
2991 &level.use_artwork_element[0],
2993 "use artwork from element:", "use player artwork from other element"
2996 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
2997 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
2998 &level.use_explosion_element[0],
3000 "use explosion from element:", "use explosion properties from element"
3003 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3004 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
3005 &level.initial_player_gravity[0],
3007 "use initial gravity", "set initial player gravity"
3010 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3011 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
3012 &level.use_initial_inventory[0],
3014 "use initial inventory:", "use collected elements on level start"
3017 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3018 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
3019 &level.can_pass_to_walkable,
3021 "can pass to walkable element", "player can pass to empty or walkable"
3024 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3025 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
3026 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3028 "can fall into acid (with gravity)","player can fall into acid pool"
3031 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3032 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
3033 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3035 "can move into acid", "element can move into acid pool"
3038 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3039 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
3040 &custom_element_properties[EP_DONT_COLLIDE_WITH],
3042 "deadly when colliding with", "element is deadly when hitting player"
3045 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3046 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
3047 &level.envelope[0].autowrap,
3049 "auto-wrap", "automatically wrap envelope text"
3052 -1, ED_ELEMENT_SETTINGS_YPOS(1),
3053 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
3054 &level.envelope[0].centered,
3056 "centered", "automatically center envelope text"
3059 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3060 GADGET_ID_MM_LASER_RED, GADGET_ID_NONE,
3061 &level.mm_laser_red,
3062 "choose color components for laser:", NULL,
3063 "red", "use red color components in laser"
3066 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3067 GADGET_ID_MM_LASER_GREEN, GADGET_ID_NONE,
3068 &level.mm_laser_green,
3070 "green", "use green color components in laser"
3073 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3074 GADGET_ID_MM_LASER_BLUE, GADGET_ID_NONE,
3075 &level.mm_laser_blue,
3077 "blue", "use blue color components in laser"
3080 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3081 GADGET_ID_DF_LASER_RED, GADGET_ID_NONE,
3082 &level.df_laser_red,
3083 "choose color components for laser:", NULL,
3084 "red", "use red color components in laser"
3087 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3088 GADGET_ID_DF_LASER_GREEN, GADGET_ID_NONE,
3089 &level.df_laser_green,
3091 "green", "use green color components in laser"
3094 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3095 GADGET_ID_DF_LASER_BLUE, GADGET_ID_NONE,
3096 &level.df_laser_blue,
3098 "blue", "use blue color components in laser"
3101 /* ---------- element settings: configure 1 (custom elements) ----------- */
3104 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3105 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
3106 &custom_element.use_gfx_element,
3108 "use graphic of element:", "use existing element graphic"
3111 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3112 GADGET_ID_CUSTOM_USE_TEMPLATE_1, GADGET_ID_NONE,
3113 &level.use_custom_template,
3115 "use template", "use template for custom properties"
3118 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3119 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
3120 &custom_element_properties[EP_ACCESSIBLE],
3122 NULL, "player can walk to or pass this field"
3125 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3126 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
3127 &custom_element_properties[EP_GRAVITY_REACHABLE],
3129 "reachable despite gravity", "player can walk/dig despite gravity"
3132 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3133 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
3134 &custom_element.use_last_ce_value,
3136 "use last CE value after change", "use last CE value after change"
3139 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3140 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
3141 &custom_element_properties[EP_WALK_TO_OBJECT],
3143 NULL, "player can dig/collect/push element"
3146 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3147 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
3148 &custom_element_properties[EP_INDESTRUCTIBLE],
3150 "indestructible", "element is indestructible"
3153 /* ---------- element settings: configure 2 (custom elements) ----------- */
3156 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3157 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
3158 &custom_element_properties[EP_CAN_MOVE],
3160 NULL, "element can move with some pattern"
3163 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
3164 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
3165 &custom_element_properties[EP_CAN_FALL],
3167 "can fall", "element can fall down"
3170 -1, ED_ELEMENT_SETTINGS_YPOS(7),
3171 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
3172 &custom_element_properties[EP_CAN_SMASH],
3174 NULL, "element can smash other elements"
3177 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3178 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
3179 &custom_element_properties[EP_SLIPPERY],
3181 NULL, "other elements can fall down from it"
3184 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3185 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
3186 &custom_element_properties[EP_DEADLY],
3188 NULL, "element can kill the player"
3191 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3192 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
3193 &custom_element_properties[EP_CAN_EXPLODE],
3195 NULL, "element can explode"
3198 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
3199 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
3200 &custom_element_properties[EP_EXPLODES_BY_FIRE],
3202 "by fire", "element can explode by fire/explosion"
3205 -1, ED_ELEMENT_SETTINGS_YPOS(11),
3206 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
3207 &custom_element_properties[EP_EXPLODES_SMASHED],
3209 "smashed", "element can explode when smashed"
3212 -1, ED_ELEMENT_SETTINGS_YPOS(11),
3213 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
3214 &custom_element_properties[EP_EXPLODES_IMPACT],
3216 "impact", "element can explode on impact"
3219 /* ---------- element settings: advanced (custom elements) --------------- */
3222 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3223 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
3224 &custom_element_change.can_change,
3226 "element changes to:", "change element on specified condition"
3229 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
3230 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
3231 &custom_element_change_events[CE_DELAY],
3233 NULL, "element changes after delay"
3236 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
3237 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
3238 &custom_element_change_events[CE_BY_DIRECT_ACTION],
3240 NULL, "element changes by direct action"
3243 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
3244 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
3245 &custom_element_change_events[CE_BY_OTHER_ACTION],
3247 NULL, "element changes by other element"
3250 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
3251 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
3252 &custom_element_change.explode,
3254 "explode instead of change", "element explodes instead of change"
3257 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
3258 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
3259 &custom_element_change.use_target_content,
3261 "use extended change target:", "element changes to more elements"
3264 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3265 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3266 &custom_element_change.only_if_complete,
3268 "replace all or nothing", "only replace when all can be changed"
3271 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3272 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3273 &custom_element_change.use_random_replace,
3275 NULL, "use percentage for random replace"
3278 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3279 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3280 &custom_element_change.has_action,
3282 NULL, "execute action on specified condition"
3289 int xoffset, yoffset;
3291 int gadget_id_align;
3293 int area_xsize, area_ysize;
3294 char *text_left, *text_right, *text_below, *infotext;
3295 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3297 /* ---------- level playfield content ------------------------------------ */
3302 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
3304 -1, -1, /* these values are not constant, but can change at runtime */
3305 NULL, NULL, NULL, NULL
3308 /* ---------- yam yam content -------------------------------------------- */
3311 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3312 ED_AREA_YAMYAM_CONTENT_XOFF(0), ED_AREA_YAMYAM_CONTENT_YOFF(0),
3313 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
3314 &level.yamyam_content[0].e[0][0], 3, 3,
3315 NULL, NULL, "1", NULL
3318 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3319 ED_AREA_YAMYAM_CONTENT_XOFF(1), ED_AREA_YAMYAM_CONTENT_YOFF(1),
3320 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
3321 &level.yamyam_content[1].e[0][0], 3, 3,
3322 NULL, NULL, "2", NULL
3325 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3326 ED_AREA_YAMYAM_CONTENT_XOFF(2), ED_AREA_YAMYAM_CONTENT_YOFF(2),
3327 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
3328 &level.yamyam_content[2].e[0][0], 3, 3,
3329 NULL, NULL, "3", NULL
3332 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3333 ED_AREA_YAMYAM_CONTENT_XOFF(3), ED_AREA_YAMYAM_CONTENT_YOFF(3),
3334 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
3335 &level.yamyam_content[3].e[0][0], 3, 3,
3336 NULL, NULL, "4", NULL
3339 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3340 ED_AREA_YAMYAM_CONTENT_XOFF(4), ED_AREA_YAMYAM_CONTENT_YOFF(4),
3341 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
3342 &level.yamyam_content[4].e[0][0], 3, 3,
3343 NULL, NULL, "5", NULL
3346 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3347 ED_AREA_YAMYAM_CONTENT_XOFF(5), ED_AREA_YAMYAM_CONTENT_YOFF(5),
3348 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
3349 &level.yamyam_content[5].e[0][0], 3, 3,
3350 NULL, NULL, "6", NULL
3353 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3354 ED_AREA_YAMYAM_CONTENT_XOFF(6), ED_AREA_YAMYAM_CONTENT_YOFF(6),
3355 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
3356 &level.yamyam_content[6].e[0][0], 3, 3,
3357 NULL, NULL, "7", NULL
3360 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3361 ED_AREA_YAMYAM_CONTENT_XOFF(7), ED_AREA_YAMYAM_CONTENT_YOFF(7),
3362 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
3363 &level.yamyam_content[7].e[0][0], 3, 3,
3364 NULL, NULL, "8", NULL
3367 /* ---------- magic ball content ----------------------------------------- */
3370 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3371 ED_AREA_MAGIC_BALL_CONTENT_XOFF(0), ED_AREA_MAGIC_BALL_CONTENT_YOFF(0),
3372 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
3373 &level.ball_content[0].e[0][0], 3, 3,
3374 NULL, NULL, "1", NULL
3377 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3378 ED_AREA_MAGIC_BALL_CONTENT_XOFF(1), ED_AREA_MAGIC_BALL_CONTENT_YOFF(1),
3379 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
3380 &level.ball_content[1].e[0][0], 3, 3,
3381 NULL, NULL, "2", NULL
3384 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3385 ED_AREA_MAGIC_BALL_CONTENT_XOFF(2), ED_AREA_MAGIC_BALL_CONTENT_YOFF(2),
3386 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
3387 &level.ball_content[2].e[0][0], 3, 3,
3388 NULL, NULL, "3", NULL
3391 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3392 ED_AREA_MAGIC_BALL_CONTENT_XOFF(3), ED_AREA_MAGIC_BALL_CONTENT_YOFF(3),
3393 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
3394 &level.ball_content[3].e[0][0], 3, 3,
3395 NULL, NULL, "4", NULL
3398 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3399 ED_AREA_MAGIC_BALL_CONTENT_XOFF(4), ED_AREA_MAGIC_BALL_CONTENT_YOFF(4),
3400 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
3401 &level.ball_content[4].e[0][0], 3, 3,
3402 NULL, NULL, "5", NULL
3405 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3406 ED_AREA_MAGIC_BALL_CONTENT_XOFF(5), ED_AREA_MAGIC_BALL_CONTENT_YOFF(5),
3407 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
3408 &level.ball_content[5].e[0][0], 3, 3,
3409 NULL, NULL, "6", NULL
3412 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3413 ED_AREA_MAGIC_BALL_CONTENT_XOFF(6), ED_AREA_MAGIC_BALL_CONTENT_YOFF(6),
3414 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
3415 &level.ball_content[6].e[0][0], 3, 3,
3416 NULL, NULL, "7", NULL
3419 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3420 ED_AREA_MAGIC_BALL_CONTENT_XOFF(7), ED_AREA_MAGIC_BALL_CONTENT_YOFF(7),
3421 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
3422 &level.ball_content[7].e[0][0], 3, 3,
3423 NULL, NULL, "8", NULL
3426 /* ---------- android content -------------------------------------------- */
3429 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(5),
3430 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3431 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
3432 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
3433 "elements:", NULL, NULL, "elements android can clone"
3436 /* ---------- amoeba content --------------------------------------------- */
3439 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
3440 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3441 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
3442 &level.amoeba_content, 1, 1,
3443 "content:", NULL, NULL, "amoeba content"
3446 /* ---------- level start element ---------------------------------------- */
3449 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
3450 0, ED_AREA_1X1_SETTINGS_YOFF,
3451 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
3452 &level.start_element[0], 1, 1,
3453 NULL, NULL, NULL, "level start element"
3456 /* ---------- player artwork element ------------------------------------- */
3459 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
3460 0, ED_AREA_1X1_SETTINGS_YOFF,
3461 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
3462 &level.artwork_element[0], 1, 1,
3463 NULL, NULL, NULL, "element for player artwork"
3466 /* ---------- player explosion element ----------------------------------- */
3469 -1, ED_AREA_1X1_SETTINGS_YPOS(12),
3470 0, ED_AREA_1X1_SETTINGS_YOFF,
3471 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
3472 &level.explosion_element[0], 1, 1,
3473 NULL, NULL, NULL, "element for player explosion"
3476 /* ---------- player initial inventory ----------------------------------- */
3479 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3480 0, ED_AREA_1X1_SETTINGS_YOFF,
3481 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
3482 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
3483 NULL, NULL, NULL, "content for initial inventory"
3486 /* ---------- element settings: configure 1 (custom elements) ----------- */
3488 /* ---------- custom graphic --------------------------------------------- */
3491 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3492 0, ED_AREA_1X1_SETTINGS_YOFF,
3493 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
3494 &custom_element.gfx_element_initial,1, 1,
3495 NULL, NULL, NULL, "custom graphic element"
3498 /* ---------- element settings: configure 2 (custom elements) ----------- */
3500 /* ---------- custom content (when exploding) ---------------------------- */
3503 -1, ED_AREA_3X3_SETTINGS_YPOS(10),
3504 0, ED_AREA_3X3_SETTINGS_YOFF,
3505 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, /* align three rows */
3506 &custom_element.content.e[0][0], 3, 3,
3507 "content:", NULL, NULL, NULL
3510 /* ---------- custom enter and leave element (when moving) --------------- */
3513 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
3514 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3515 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
3516 &custom_element.move_enter_element, 1, 1,
3517 "can dig:", " ", NULL, "element that can be digged/collected"
3520 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
3521 0, ED_AREA_1X1_SETTINGS_YOFF,
3522 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
3523 &custom_element.move_leave_element, 1, 1,
3524 NULL, NULL, NULL, "element that will be left behind"
3527 /* ---------- element settings: advanced (custom elements) --------------- */
3529 /* ---------- custom change target --------------------------------------- */
3532 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3533 0, ED_AREA_1X1_SETTINGS_YOFF,
3534 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
3535 &custom_element_change.target_element, 1, 1,
3536 NULL, "after/when:", NULL, "new target element after change"
3539 /* ---------- custom change content (extended change target) ------------- */
3542 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
3543 0, ED_AREA_3X3_SETTINGS_YOFF,
3544 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, /* align three rows */
3545 &custom_element_change.target_content.e[0][0], 3, 3,
3546 NULL, NULL, NULL, "new extended elements after change"
3549 /* ---------- custom change trigger (element causing change) ------------- */
3552 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
3553 0, ED_AREA_1X1_SETTINGS_YOFF,
3554 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
3555 &custom_element_change.initial_trigger_element, 1, 1,
3556 NULL, NULL, NULL, "other element triggering change"
3559 /* ---------- custom change action (element used for action) ------------- */
3562 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
3563 0, ED_AREA_1X1_SETTINGS_YOFF,
3564 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
3565 &custom_element_change.action_element, 1, 1,
3566 NULL, NULL, NULL, "element used as action parameter"
3569 /* ---------- group element content -------------------------------------- */
3572 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
3573 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3574 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
3575 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
3576 "content:", NULL, NULL, NULL
3579 /* ---------- random background (for random painting) -------------------- */
3582 -1, ED_AREA_1X1_LSETTINGS_YPOS(1),
3583 0, ED_AREA_1X1_LSETTINGS_YOFF,
3584 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
3585 &random_placement_background_element, 1, 1,
3586 NULL, NULL, NULL, "random placement background"
3592 -----------------------------------------------------------------------------
3593 some internally used variables
3594 -----------------------------------------------------------------------------
3597 /* maximal size of level editor drawing area */
3598 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
3600 /* actual size of level editor drawing area */
3601 static int ed_fieldx, ed_fieldy;
3603 /* actual position of level editor drawing area in level playfield */
3604 static int level_xpos = -1, level_ypos = -1;
3606 /* actual tile size used to display playfield drawing area */
3607 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
3609 #define IN_ED_FIELD(x,y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
3611 /* drawing elements on the three mouse buttons */
3612 static int new_element1 = EL_WALL;
3613 static int new_element2 = EL_EMPTY;
3614 static int new_element3 = EL_SAND;
3616 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
3617 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
3618 (button) == 2 ? new_element2 : \
3619 (button) == 3 ? new_element3 : EL_EMPTY)
3621 #define BUTTON_TILE_SIZE(x) ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE)
3623 static int use_permanent_palette = TRUE;
3625 #define PX (use_permanent_palette ? DX : SX)
3626 #define PY (use_permanent_palette ? DY : SY)
3627 #define PXSIZE (use_permanent_palette ? DXSIZE : SXSIZE)
3628 #define PYSIZE (use_permanent_palette ? DYSIZE : SYSIZE)
3630 /* forward declaration for internal use */
3631 static void ModifyEditorCounterValue(int, int);
3632 static void ModifyEditorCounterLimits(int, int, int);
3633 static void ModifyEditorSelectboxValue(int, int);
3634 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
3635 static void ModifyEditorDrawingArea(int, int, int);
3636 static void ModifyEditorElementList();
3637 static void AdjustElementListScrollbar();
3638 static void RedrawDrawingElements();
3639 static void DrawDrawingWindow();
3640 static void DrawLevelInfoWindow();
3641 static void DrawPropertiesWindow();
3642 static void DrawPaletteWindow();
3643 static void UpdateCustomElementGraphicGadgets();
3644 static boolean checkPropertiesConfig(int);
3645 static void SetAutomaticNumberOfGemsNeeded();
3646 static void ClearEditorGadgetInfoText();
3647 static void CopyLevelToUndoBuffer(int);
3648 static void HandleDrawingAreas(struct GadgetInfo *);
3649 static void HandleCounterButtons(struct GadgetInfo *);
3650 static void HandleTextInputGadgets(struct GadgetInfo *);
3651 static void HandleTextAreaGadgets(struct GadgetInfo *);
3652 static void HandleSelectboxGadgets(struct GadgetInfo *);
3653 static void HandleTextbuttonGadgets(struct GadgetInfo *);
3654 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
3655 static void HandleRadiobuttons(struct GadgetInfo *);
3656 static void HandleCheckbuttons(struct GadgetInfo *);
3657 static void HandleControlButtons(struct GadgetInfo *);
3658 static void HandleDrawingAreaInfo(struct GadgetInfo *);
3659 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
3660 static boolean AskToCopyAndModifyLevelTemplate();
3662 static int num_editor_gadgets = 0; /* dynamically determined */
3664 static struct GadgetInfo **level_editor_gadget = NULL;
3665 static int *right_gadget_border = NULL;
3667 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
3668 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
3669 static boolean draw_with_brush = FALSE;
3670 static int properties_element = 0;
3672 static short FieldBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3673 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3674 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3675 static int undo_buffer_position = 0;
3676 static int undo_buffer_steps = 0;
3677 static int redo_buffer_steps = 0;
3679 static int edit_mode;
3680 static int edit_mode_levelinfo;
3681 static int edit_mode_properties;
3683 static int element_shift = 0;
3685 static int editor_el_players[] =
3692 static int *editor_el_players_ptr = editor_el_players;
3693 static int num_editor_el_players = SIZEOF_ARRAY_INT(editor_el_players);
3695 static int editor_hl_boulderdash[] =
3697 EL_INTERNAL_CASCADE_BD_ACTIVE,
3703 static int editor_el_boulderdash[] =
3712 EL_BD_EXPANDABLE_WALL,
3720 EL_BD_BUTTERFLY_LEFT,
3722 EL_BD_BUTTERFLY_RIGHT,
3723 EL_BD_FIREFLY_RIGHT,
3726 EL_BD_BUTTERFLY_DOWN,
3730 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
3731 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
3732 static int num_editor_hl_boulderdash = SIZEOF_ARRAY_INT(editor_hl_boulderdash);
3733 static int num_editor_el_boulderdash = SIZEOF_ARRAY_INT(editor_el_boulderdash);
3735 static int editor_hl_emerald_mine[] =
3737 EL_INTERNAL_CASCADE_EM_ACTIVE,
3743 static int editor_el_emerald_mine[] =
3780 EL_ACID_POOL_TOPLEFT,
3782 EL_ACID_POOL_TOPRIGHT,
3785 EL_ACID_POOL_BOTTOMLEFT,
3786 EL_ACID_POOL_BOTTOM,
3787 EL_ACID_POOL_BOTTOMRIGHT,
3807 EL_EM_STEEL_EXIT_CLOSED,
3808 EL_EM_STEEL_EXIT_OPEN,
3810 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
3811 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
3812 static int num_editor_hl_emerald_mine=SIZEOF_ARRAY_INT(editor_hl_emerald_mine);
3813 static int num_editor_el_emerald_mine=SIZEOF_ARRAY_INT(editor_el_emerald_mine);
3815 static int editor_hl_emerald_mine_club[] =
3817 EL_INTERNAL_CASCADE_EMC_ACTIVE,
3823 static int editor_el_emerald_mine_club[] =
3850 EL_EMC_WALL_SLIPPERY_1,
3851 EL_EMC_WALL_SLIPPERY_2,
3852 EL_EMC_WALL_SLIPPERY_3,
3853 EL_EMC_WALL_SLIPPERY_4,
3876 EL_EMC_MAGIC_BALL_SWITCH,
3878 EL_EMC_SPRING_BUMPER,
3883 EL_EM_DYNAMITE_ACTIVE,
3887 EL_BALLOON_SWITCH_UP,
3888 EL_BALLOON_SWITCH_ANY,
3891 EL_BALLOON_SWITCH_LEFT,
3893 EL_BALLOON_SWITCH_RIGHT,
3897 EL_BALLOON_SWITCH_DOWN,
3898 EL_BALLOON_SWITCH_NONE,
3900 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
3901 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
3902 static int num_editor_hl_emerald_mine_club=SIZEOF_ARRAY_INT(editor_hl_emerald_mine_club);
3903 static int num_editor_el_emerald_mine_club=SIZEOF_ARRAY_INT(editor_el_emerald_mine_club);
3905 static int editor_hl_rnd[] =
3907 EL_INTERNAL_CASCADE_RND_ACTIVE,
3913 static int editor_el_rnd[] =
3945 EL_WALL_EMERALD_YELLOW,
3946 EL_WALL_EMERALD_RED,
3947 EL_WALL_EMERALD_PURPLE,
3965 EL_DYNABOMB_INCREASE_NUMBER,
3966 EL_DYNABOMB_INCREASE_SIZE,
3967 EL_DYNABOMB_INCREASE_POWER,
3987 EL_INVISIBLE_STEELWALL,
3991 EL_EXPANDABLE_WALL_HORIZONTAL,
3992 EL_EXPANDABLE_WALL_VERTICAL,
3993 EL_EXPANDABLE_WALL_ANY,
3995 static int *editor_hl_rnd_ptr = editor_hl_rnd;
3996 static int *editor_el_rnd_ptr = editor_el_rnd;
3997 static int num_editor_hl_rnd = SIZEOF_ARRAY_INT(editor_hl_rnd);
3998 static int num_editor_el_rnd = SIZEOF_ARRAY_INT(editor_el_rnd);
4000 static int editor_hl_sokoban[] =
4002 EL_INTERNAL_CASCADE_SB_ACTIVE,
4008 static int editor_el_sokoban[] =
4011 EL_SOKOBAN_FIELD_EMPTY,
4012 EL_SOKOBAN_FIELD_FULL,
4013 EL_SOKOBAN_FIELD_PLAYER,
4015 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
4016 static int *editor_el_sokoban_ptr = editor_el_sokoban;
4017 static int num_editor_hl_sokoban = SIZEOF_ARRAY_INT(editor_hl_sokoban);
4018 static int num_editor_el_sokoban = SIZEOF_ARRAY_INT(editor_el_sokoban);
4020 static int editor_hl_supaplex[] =
4022 EL_INTERNAL_CASCADE_SP_ACTIVE,
4028 static int editor_el_supaplex[] =
4046 EL_SP_PORT_HORIZONTAL,
4047 EL_SP_PORT_VERTICAL,
4055 EL_SP_GRAVITY_PORT_LEFT,
4056 EL_SP_GRAVITY_PORT_RIGHT,
4057 EL_SP_GRAVITY_PORT_UP,
4058 EL_SP_GRAVITY_PORT_DOWN,
4060 EL_SP_GRAVITY_ON_PORT_LEFT,
4061 EL_SP_GRAVITY_ON_PORT_RIGHT,
4062 EL_SP_GRAVITY_ON_PORT_UP,
4063 EL_SP_GRAVITY_ON_PORT_DOWN,
4065 EL_SP_GRAVITY_OFF_PORT_LEFT,
4066 EL_SP_GRAVITY_OFF_PORT_RIGHT,
4067 EL_SP_GRAVITY_OFF_PORT_UP,
4068 EL_SP_GRAVITY_OFF_PORT_DOWN,
4070 EL_SP_HARDWARE_GRAY,
4071 EL_SP_HARDWARE_GREEN,
4072 EL_SP_HARDWARE_BLUE,
4075 EL_SP_HARDWARE_BASE_1,
4076 EL_SP_HARDWARE_BASE_2,
4077 EL_SP_HARDWARE_BASE_3,
4078 EL_SP_HARDWARE_BASE_4,
4080 EL_SP_HARDWARE_BASE_5,
4081 EL_SP_HARDWARE_BASE_6,
4082 EL_SP_HARDWARE_YELLOW,
4090 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
4091 static int *editor_el_supaplex_ptr = editor_el_supaplex;
4092 static int num_editor_hl_supaplex = SIZEOF_ARRAY_INT(editor_hl_supaplex);
4093 static int num_editor_el_supaplex = SIZEOF_ARRAY_INT(editor_el_supaplex);
4095 static int editor_hl_diamond_caves[] =
4097 EL_INTERNAL_CASCADE_DC_ACTIVE,
4103 static int editor_el_diamond_caves[] =
4110 EL_CONVEYOR_BELT_1_LEFT,
4111 EL_CONVEYOR_BELT_1_MIDDLE,
4112 EL_CONVEYOR_BELT_1_RIGHT,
4113 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
4115 EL_CONVEYOR_BELT_2_LEFT,
4116 EL_CONVEYOR_BELT_2_MIDDLE,
4117 EL_CONVEYOR_BELT_2_RIGHT,
4118 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
4120 EL_CONVEYOR_BELT_3_LEFT,
4121 EL_CONVEYOR_BELT_3_MIDDLE,
4122 EL_CONVEYOR_BELT_3_RIGHT,
4123 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
4125 EL_CONVEYOR_BELT_4_LEFT,
4126 EL_CONVEYOR_BELT_4_MIDDLE,
4127 EL_CONVEYOR_BELT_4_RIGHT,
4128 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
4130 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
4131 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
4132 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
4133 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
4135 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
4136 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
4137 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
4138 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
4143 EL_DC_TIMEGATE_SWITCH,
4145 EL_SWITCHGATE_CLOSED,
4147 EL_SWITCHGATE_SWITCH_UP,
4148 EL_SWITCHGATE_SWITCH_DOWN,
4151 EL_LIGHT_SWITCH_ACTIVE,
4152 EL_DC_SWITCHGATE_SWITCH_UP,
4153 EL_DC_SWITCHGATE_SWITCH_DOWN,
4155 EL_STEEL_EXIT_CLOSED,
4157 EL_STEELWALL_SLIPPERY,
4160 EL_QUICKSAND_FAST_EMPTY,
4161 EL_QUICKSAND_FAST_FULL,
4175 EL_SIGN_RADIOACTIVITY,
4181 EL_SIGN_ENTRY_FORBIDDEN,
4182 EL_SIGN_EMERGENCY_EXIT,
4207 EL_DC_STEELWALL_2_SINGLE,
4208 EL_DC_STEELWALL_2_TOP,
4209 EL_SIGN_EXCLAMATION,
4212 EL_DC_STEELWALL_2_LEFT,
4213 EL_DC_STEELWALL_2_MIDDLE,
4214 EL_DC_STEELWALL_2_HORIZONTAL,
4215 EL_DC_STEELWALL_2_RIGHT,
4217 EL_DC_STEELWALL_1_TOPLEFT,
4218 EL_DC_STEELWALL_2_VERTICAL,
4219 EL_DC_STEELWALL_1_TOPRIGHT,
4222 EL_DC_STEELWALL_1_VERTICAL,
4223 EL_DC_STEELWALL_2_BOTTOM,
4225 EL_DC_GATE_WHITE_GRAY,
4227 EL_DC_STEELWALL_1_BOTTOMLEFT,
4228 EL_DC_STEELWALL_1_HORIZONTAL,
4229 EL_DC_STEELWALL_1_BOTTOMRIGHT,
4230 EL_DC_GATE_FAKE_GRAY,
4232 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
4233 EL_DC_STEELWALL_1_BOTTOM,
4234 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
4235 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
4237 EL_DC_STEELWALL_1_RIGHT,
4239 EL_DC_STEELWALL_1_LEFT,
4240 EL_EXPANDABLE_STEELWALL_VERTICAL,
4242 EL_DC_STEELWALL_1_TOPRIGHT_2,
4243 EL_DC_STEELWALL_1_TOP,
4244 EL_DC_STEELWALL_1_TOPLEFT_2,
4245 EL_EXPANDABLE_STEELWALL_ANY,
4247 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
4248 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
4249 static int num_editor_hl_diamond_caves = SIZEOF_ARRAY_INT(editor_hl_diamond_caves);
4250 static int num_editor_el_diamond_caves = SIZEOF_ARRAY_INT(editor_el_diamond_caves);
4252 static int editor_hl_dx_boulderdash[] =
4254 EL_INTERNAL_CASCADE_DX_ACTIVE,
4260 static int editor_el_dx_boulderdash[] =
4264 EL_TUBE_HORIZONTAL_DOWN,
4268 EL_TUBE_VERTICAL_RIGHT,
4270 EL_TUBE_VERTICAL_LEFT,
4274 EL_TUBE_HORIZONTAL_UP,
4282 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
4283 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
4284 static int num_editor_hl_dx_boulderdash = SIZEOF_ARRAY_INT(editor_hl_dx_boulderdash);
4285 static int num_editor_el_dx_boulderdash = SIZEOF_ARRAY_INT(editor_el_dx_boulderdash);
4287 static int editor_hl_mirror_magic[] =
4289 EL_INTERNAL_CASCADE_MM_ACTIVE,
4295 static int editor_el_mirror_magic[] =
4297 EL_MM_MCDUFFIN_RIGHT,
4299 EL_MM_MCDUFFIN_LEFT,
4300 EL_MM_MCDUFFIN_DOWN,
4303 EL_MM_MIRROR_FIXED_START,
4304 EL_MM_POLARISATOR_START,
4305 EL_MM_POLARISATOR_CROSS_START,
4307 EL_MM_BEAMER_RED_START,
4308 EL_MM_BEAMER_YELLOW_START,
4309 EL_MM_BEAMER_GREEN_START,
4310 EL_MM_BEAMER_BLUE_START,
4323 EL_MM_LIGHTBULB_ACTIVE,
4337 EL_MM_STEEL_GRID_FIXED_1,
4338 EL_MM_STEEL_GRID_FIXED_2,
4339 EL_MM_STEEL_GRID_FIXED_3,
4340 EL_MM_STEEL_GRID_FIXED_4,
4342 EL_MM_WOODEN_GRID_FIXED_1,
4343 EL_MM_WOODEN_GRID_FIXED_2,
4344 EL_MM_WOODEN_GRID_FIXED_3,
4345 EL_MM_WOODEN_GRID_FIXED_4
4347 static int *editor_hl_mirror_magic_ptr = editor_hl_mirror_magic;
4348 static int *editor_el_mirror_magic_ptr = editor_el_mirror_magic;
4349 static int num_editor_hl_mirror_magic = SIZEOF_ARRAY_INT(editor_hl_mirror_magic);
4350 static int num_editor_el_mirror_magic = SIZEOF_ARRAY_INT(editor_el_mirror_magic);
4352 static int editor_hl_deflektor[] =
4354 EL_INTERNAL_CASCADE_DF_ACTIVE,
4360 static int editor_el_deflektor[] =
4367 EL_DF_RECEIVER_RIGHT,
4369 EL_DF_RECEIVER_LEFT,
4370 EL_DF_RECEIVER_DOWN,
4373 EL_DF_MIRROR_ROTATING_START,
4377 EL_DF_FIBRE_OPTIC_RED_1,
4378 EL_DF_FIBRE_OPTIC_YELLOW_1,
4379 EL_DF_FIBRE_OPTIC_GREEN_1,
4380 EL_DF_FIBRE_OPTIC_BLUE_1,
4382 EL_DF_STEEL_GRID_FIXED_START,
4383 EL_DF_STEEL_GRID_ROTATING_START,
4384 EL_DF_WOODEN_GRID_FIXED_START,
4385 EL_DF_WOODEN_GRID_ROTATING_START,
4392 static int *editor_hl_deflektor_ptr = editor_hl_deflektor;
4393 static int *editor_el_deflektor_ptr = editor_el_deflektor;
4394 static int num_editor_hl_deflektor = SIZEOF_ARRAY_INT(editor_hl_deflektor);
4395 static int num_editor_el_deflektor = SIZEOF_ARRAY_INT(editor_el_deflektor);
4397 static int editor_hl_chars[] =
4399 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
4405 static int editor_el_chars[] =
4487 EL_CHAR(CHAR_BYTE_COPYRIGHT),
4488 EL_CHAR(CHAR_BYTE_UMLAUT_A),
4489 EL_CHAR(CHAR_BYTE_UMLAUT_O),
4490 EL_CHAR(CHAR_BYTE_UMLAUT_U),
4492 EL_CHAR(CHAR_BYTE_DEGREE),
4493 EL_CHAR(CHAR_BYTE_REGISTERED),
4494 EL_CHAR(FONT_ASCII_CURSOR),
4495 EL_CHAR(FONT_ASCII_BUTTON),
4497 EL_CHAR(FONT_ASCII_UP),
4498 EL_CHAR(FONT_ASCII_DOWN),
4502 static int *editor_hl_chars_ptr = editor_hl_chars;
4503 static int *editor_el_chars_ptr = editor_el_chars;
4504 static int num_editor_hl_chars = SIZEOF_ARRAY_INT(editor_hl_chars);
4505 static int num_editor_el_chars = SIZEOF_ARRAY_INT(editor_el_chars);
4507 static int editor_hl_steel_chars[] =
4509 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
4515 static int editor_el_steel_chars[] =
4525 EL_STEEL_CHAR('\''),
4592 EL_STEEL_CHAR('\\'),
4597 EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
4598 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
4599 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
4600 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
4602 EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
4603 EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
4604 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
4605 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
4607 EL_STEEL_CHAR(FONT_ASCII_UP),
4608 EL_STEEL_CHAR(FONT_ASCII_DOWN),
4612 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
4613 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
4614 static int num_editor_hl_steel_chars = SIZEOF_ARRAY_INT(editor_hl_steel_chars);
4615 static int num_editor_el_steel_chars = SIZEOF_ARRAY_INT(editor_el_steel_chars);
4617 static int editor_hl_custom[] =
4619 EL_INTERNAL_CASCADE_CE_ACTIVE,
4625 static int editor_el_custom[] =
4627 EL_CUSTOM_START + 0,
4628 EL_CUSTOM_START + 1,
4629 EL_CUSTOM_START + 2,
4630 EL_CUSTOM_START + 3,
4632 EL_CUSTOM_START + 4,
4633 EL_CUSTOM_START + 5,
4634 EL_CUSTOM_START + 6,
4635 EL_CUSTOM_START + 7,
4637 EL_CUSTOM_START + 8,
4638 EL_CUSTOM_START + 9,
4639 EL_CUSTOM_START + 10,
4640 EL_CUSTOM_START + 11,
4642 EL_CUSTOM_START + 12,
4643 EL_CUSTOM_START + 13,
4644 EL_CUSTOM_START + 14,
4645 EL_CUSTOM_START + 15,
4647 EL_CUSTOM_START + 16,
4648 EL_CUSTOM_START + 17,
4649 EL_CUSTOM_START + 18,
4650 EL_CUSTOM_START + 19,
4652 EL_CUSTOM_START + 20,
4653 EL_CUSTOM_START + 21,
4654 EL_CUSTOM_START + 22,
4655 EL_CUSTOM_START + 23,
4657 EL_CUSTOM_START + 24,
4658 EL_CUSTOM_START + 25,
4659 EL_CUSTOM_START + 26,
4660 EL_CUSTOM_START + 27,
4662 EL_CUSTOM_START + 28,
4663 EL_CUSTOM_START + 29,
4664 EL_CUSTOM_START + 30,
4665 EL_CUSTOM_START + 31,
4667 EL_CUSTOM_START + 32,
4668 EL_CUSTOM_START + 33,
4669 EL_CUSTOM_START + 34,
4670 EL_CUSTOM_START + 35,
4672 EL_CUSTOM_START + 36,
4673 EL_CUSTOM_START + 37,
4674 EL_CUSTOM_START + 38,
4675 EL_CUSTOM_START + 39,
4677 EL_CUSTOM_START + 40,
4678 EL_CUSTOM_START + 41,
4679 EL_CUSTOM_START + 42,
4680 EL_CUSTOM_START + 43,
4682 EL_CUSTOM_START + 44,
4683 EL_CUSTOM_START + 45,
4684 EL_CUSTOM_START + 46,
4685 EL_CUSTOM_START + 47,
4687 EL_CUSTOM_START + 48,
4688 EL_CUSTOM_START + 49,
4689 EL_CUSTOM_START + 50,
4690 EL_CUSTOM_START + 51,
4692 EL_CUSTOM_START + 52,
4693 EL_CUSTOM_START + 53,
4694 EL_CUSTOM_START + 54,
4695 EL_CUSTOM_START + 55,
4697 EL_CUSTOM_START + 56,
4698 EL_CUSTOM_START + 57,
4699 EL_CUSTOM_START + 58,
4700 EL_CUSTOM_START + 59,
4702 EL_CUSTOM_START + 60,
4703 EL_CUSTOM_START + 61,
4704 EL_CUSTOM_START + 62,
4705 EL_CUSTOM_START + 63,
4707 EL_CUSTOM_START + 64,
4708 EL_CUSTOM_START + 65,
4709 EL_CUSTOM_START + 66,
4710 EL_CUSTOM_START + 67,
4712 EL_CUSTOM_START + 68,
4713 EL_CUSTOM_START + 69,
4714 EL_CUSTOM_START + 70,
4715 EL_CUSTOM_START + 71,
4717 EL_CUSTOM_START + 72,
4718 EL_CUSTOM_START + 73,
4719 EL_CUSTOM_START + 74,
4720 EL_CUSTOM_START + 75,
4722 EL_CUSTOM_START + 76,
4723 EL_CUSTOM_START + 77,
4724 EL_CUSTOM_START + 78,
4725 EL_CUSTOM_START + 79,
4727 EL_CUSTOM_START + 80,
4728 EL_CUSTOM_START + 81,
4729 EL_CUSTOM_START + 82,
4730 EL_CUSTOM_START + 83,
4732 EL_CUSTOM_START + 84,
4733 EL_CUSTOM_START + 85,
4734 EL_CUSTOM_START + 86,
4735 EL_CUSTOM_START + 87,
4737 EL_CUSTOM_START + 88,
4738 EL_CUSTOM_START + 89,
4739 EL_CUSTOM_START + 90,
4740 EL_CUSTOM_START + 91,
4742 EL_CUSTOM_START + 92,
4743 EL_CUSTOM_START + 93,
4744 EL_CUSTOM_START + 94,
4745 EL_CUSTOM_START + 95,
4747 EL_CUSTOM_START + 96,
4748 EL_CUSTOM_START + 97,
4749 EL_CUSTOM_START + 98,
4750 EL_CUSTOM_START + 99,
4752 EL_CUSTOM_START + 100,
4753 EL_CUSTOM_START + 101,
4754 EL_CUSTOM_START + 102,
4755 EL_CUSTOM_START + 103,
4757 EL_CUSTOM_START + 104,
4758 EL_CUSTOM_START + 105,
4759 EL_CUSTOM_START + 106,
4760 EL_CUSTOM_START + 107,
4762 EL_CUSTOM_START + 108,
4763 EL_CUSTOM_START + 109,
4764 EL_CUSTOM_START + 110,
4765 EL_CUSTOM_START + 111,
4767 EL_CUSTOM_START + 112,
4768 EL_CUSTOM_START + 113,
4769 EL_CUSTOM_START + 114,
4770 EL_CUSTOM_START + 115,
4772 EL_CUSTOM_START + 116,
4773 EL_CUSTOM_START + 117,
4774 EL_CUSTOM_START + 118,
4775 EL_CUSTOM_START + 119,
4777 EL_CUSTOM_START + 120,
4778 EL_CUSTOM_START + 121,
4779 EL_CUSTOM_START + 122,
4780 EL_CUSTOM_START + 123,
4782 EL_CUSTOM_START + 124,
4783 EL_CUSTOM_START + 125,
4784 EL_CUSTOM_START + 126,
4785 EL_CUSTOM_START + 127,
4787 EL_CUSTOM_START + 128,
4788 EL_CUSTOM_START + 129,
4789 EL_CUSTOM_START + 130,
4790 EL_CUSTOM_START + 131,
4792 EL_CUSTOM_START + 132,
4793 EL_CUSTOM_START + 133,
4794 EL_CUSTOM_START + 134,
4795 EL_CUSTOM_START + 135,
4797 EL_CUSTOM_START + 136,
4798 EL_CUSTOM_START + 137,
4799 EL_CUSTOM_START + 138,
4800 EL_CUSTOM_START + 139,
4802 EL_CUSTOM_START + 140,
4803 EL_CUSTOM_START + 141,
4804 EL_CUSTOM_START + 142,
4805 EL_CUSTOM_START + 143,
4807 EL_CUSTOM_START + 144,
4808 EL_CUSTOM_START + 145,
4809 EL_CUSTOM_START + 146,
4810 EL_CUSTOM_START + 147,
4812 EL_CUSTOM_START + 148,
4813 EL_CUSTOM_START + 149,
4814 EL_CUSTOM_START + 150,
4815 EL_CUSTOM_START + 151,
4817 EL_CUSTOM_START + 152,
4818 EL_CUSTOM_START + 153,
4819 EL_CUSTOM_START + 154,
4820 EL_CUSTOM_START + 155,
4822 EL_CUSTOM_START + 156,
4823 EL_CUSTOM_START + 157,
4824 EL_CUSTOM_START + 158,
4825 EL_CUSTOM_START + 159,
4827 EL_CUSTOM_START + 160,
4828 EL_CUSTOM_START + 161,
4829 EL_CUSTOM_START + 162,
4830 EL_CUSTOM_START + 163,
4832 EL_CUSTOM_START + 164,
4833 EL_CUSTOM_START + 165,
4834 EL_CUSTOM_START + 166,
4835 EL_CUSTOM_START + 167,
4837 EL_CUSTOM_START + 168,
4838 EL_CUSTOM_START + 169,
4839 EL_CUSTOM_START + 170,
4840 EL_CUSTOM_START + 171,
4842 EL_CUSTOM_START + 172,
4843 EL_CUSTOM_START + 173,
4844 EL_CUSTOM_START + 174,
4845 EL_CUSTOM_START + 175,
4847 EL_CUSTOM_START + 176,
4848 EL_CUSTOM_START + 177,
4849 EL_CUSTOM_START + 178,
4850 EL_CUSTOM_START + 179,
4852 EL_CUSTOM_START + 180,
4853 EL_CUSTOM_START + 181,
4854 EL_CUSTOM_START + 182,
4855 EL_CUSTOM_START + 183,
4857 EL_CUSTOM_START + 184,
4858 EL_CUSTOM_START + 185,
4859 EL_CUSTOM_START + 186,
4860 EL_CUSTOM_START + 187,
4862 EL_CUSTOM_START + 188,
4863 EL_CUSTOM_START + 189,
4864 EL_CUSTOM_START + 190,
4865 EL_CUSTOM_START + 191,
4867 EL_CUSTOM_START + 192,
4868 EL_CUSTOM_START + 193,
4869 EL_CUSTOM_START + 194,
4870 EL_CUSTOM_START + 195,
4872 EL_CUSTOM_START + 196,
4873 EL_CUSTOM_START + 197,
4874 EL_CUSTOM_START + 198,
4875 EL_CUSTOM_START + 199,
4877 EL_CUSTOM_START + 200,
4878 EL_CUSTOM_START + 201,
4879 EL_CUSTOM_START + 202,
4880 EL_CUSTOM_START + 203,
4882 EL_CUSTOM_START + 204,
4883 EL_CUSTOM_START + 205,
4884 EL_CUSTOM_START + 206,
4885 EL_CUSTOM_START + 207,
4887 EL_CUSTOM_START + 208,
4888 EL_CUSTOM_START + 209,
4889 EL_CUSTOM_START + 210,
4890 EL_CUSTOM_START + 211,
4892 EL_CUSTOM_START + 212,
4893 EL_CUSTOM_START + 213,
4894 EL_CUSTOM_START + 214,
4895 EL_CUSTOM_START + 215,
4897 EL_CUSTOM_START + 216,
4898 EL_CUSTOM_START + 217,
4899 EL_CUSTOM_START + 218,
4900 EL_CUSTOM_START + 219,
4902 EL_CUSTOM_START + 220,
4903 EL_CUSTOM_START + 221,
4904 EL_CUSTOM_START + 222,
4905 EL_CUSTOM_START + 223,
4907 EL_CUSTOM_START + 224,
4908 EL_CUSTOM_START + 225,
4909 EL_CUSTOM_START + 226,
4910 EL_CUSTOM_START + 227,
4912 EL_CUSTOM_START + 228,
4913 EL_CUSTOM_START + 229,
4914 EL_CUSTOM_START + 230,
4915 EL_CUSTOM_START + 231,
4917 EL_CUSTOM_START + 232,
4918 EL_CUSTOM_START + 233,
4919 EL_CUSTOM_START + 234,
4920 EL_CUSTOM_START + 235,
4922 EL_CUSTOM_START + 236,
4923 EL_CUSTOM_START + 237,
4924 EL_CUSTOM_START + 238,
4925 EL_CUSTOM_START + 239,
4927 EL_CUSTOM_START + 240,
4928 EL_CUSTOM_START + 241,
4929 EL_CUSTOM_START + 242,
4930 EL_CUSTOM_START + 243,
4932 EL_CUSTOM_START + 244,
4933 EL_CUSTOM_START + 245,
4934 EL_CUSTOM_START + 246,
4935 EL_CUSTOM_START + 247,
4937 EL_CUSTOM_START + 248,
4938 EL_CUSTOM_START + 249,
4939 EL_CUSTOM_START + 250,
4940 EL_CUSTOM_START + 251,
4942 EL_CUSTOM_START + 252,
4943 EL_CUSTOM_START + 253,
4944 EL_CUSTOM_START + 254,
4945 EL_CUSTOM_START + 255
4947 static int *editor_hl_custom_ptr = editor_hl_custom;
4948 static int *editor_el_custom_ptr = editor_el_custom;
4949 static int num_editor_hl_custom = SIZEOF_ARRAY_INT(editor_hl_custom);
4950 static int num_editor_el_custom = SIZEOF_ARRAY_INT(editor_el_custom);
4952 static int editor_hl_group[] =
4954 EL_INTERNAL_CASCADE_GE_ACTIVE,
4960 static int editor_el_group[] =
4974 EL_GROUP_START + 10,
4975 EL_GROUP_START + 11,
4977 EL_GROUP_START + 12,
4978 EL_GROUP_START + 13,
4979 EL_GROUP_START + 14,
4980 EL_GROUP_START + 15,
4982 EL_GROUP_START + 16,
4983 EL_GROUP_START + 17,
4984 EL_GROUP_START + 18,
4985 EL_GROUP_START + 19,
4987 EL_GROUP_START + 20,
4988 EL_GROUP_START + 21,
4989 EL_GROUP_START + 22,
4990 EL_GROUP_START + 23,
4992 EL_GROUP_START + 24,
4993 EL_GROUP_START + 25,
4994 EL_GROUP_START + 26,
4995 EL_GROUP_START + 27,
4997 EL_GROUP_START + 28,
4998 EL_GROUP_START + 29,
4999 EL_GROUP_START + 30,
5002 static int *editor_hl_group_ptr = editor_hl_group;
5003 static int *editor_el_group_ptr = editor_el_group;
5004 static int num_editor_hl_group = SIZEOF_ARRAY_INT(editor_hl_group);
5005 static int num_editor_el_group = SIZEOF_ARRAY_INT(editor_el_group);
5007 static int editor_hl_reference[] =
5009 EL_INTERNAL_CASCADE_REF_ACTIVE,
5015 static int editor_el_reference[] =
5019 EL_TRIGGER_CE_VALUE,
5020 EL_TRIGGER_CE_SCORE,
5024 EL_CURRENT_CE_VALUE,
5025 EL_CURRENT_CE_SCORE,
5047 static int *editor_hl_reference_ptr = editor_hl_reference;
5048 static int *editor_el_reference_ptr = editor_el_reference;
5049 static int num_editor_hl_reference = SIZEOF_ARRAY_INT(editor_hl_reference);
5050 static int num_editor_el_reference = SIZEOF_ARRAY_INT(editor_el_reference);
5052 static int editor_hl_user_defined[] =
5054 EL_INTERNAL_CASCADE_USER_ACTIVE,
5060 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
5061 static int *editor_el_user_defined_ptr = NULL;
5062 static int num_editor_hl_user_defined=SIZEOF_ARRAY_INT(editor_hl_user_defined);
5063 static int num_editor_el_user_defined = 0;
5065 static int editor_hl_dynamic[] =
5067 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
5073 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
5074 static int *editor_el_dynamic_ptr = NULL;
5075 static int num_editor_hl_dynamic = SIZEOF_ARRAY_INT(editor_hl_dynamic);
5076 static int num_editor_el_dynamic = 0;
5078 static int editor_hl_empty[] = { EL_EMPTY };
5079 static int *editor_el_empty = NULL; /* dynamically allocated */
5081 static int *editor_hl_empty_ptr = editor_hl_empty;
5082 static int *editor_el_empty_ptr = NULL;
5083 static int num_editor_hl_empty = 0;
5084 static int num_editor_el_empty = 0; /* dynamically determined, if needed */
5086 static boolean use_el_empty = FALSE;
5088 static int *editor_elements = NULL; /* dynamically allocated */
5089 static int num_editor_elements = 0; /* dynamically determined */
5091 static boolean setup_editor_cascade_never = FALSE;
5093 static boolean setup_editor_el_players = TRUE;
5094 static boolean setup_editor_el_boulderdash = TRUE;
5095 static boolean setup_editor_el_emerald_mine = TRUE;
5096 static boolean setup_editor_el_emerald_mine_club = TRUE;
5097 static boolean setup_editor_el_more = TRUE;
5098 static boolean setup_editor_el_sokoban = TRUE;
5099 static boolean setup_editor_el_supaplex = TRUE;
5100 static boolean setup_editor_el_diamond_caves = TRUE;
5101 static boolean setup_editor_el_dx_boulderdash = TRUE;
5102 static boolean setup_editor_el_mirror_magic = TRUE;
5103 static boolean setup_editor_el_deflektor = TRUE;
5104 static boolean setup_editor_el_chars = TRUE;
5105 static boolean setup_editor_el_steel_chars = TRUE;
5106 static boolean setup_editor_el_custom = TRUE;
5107 static boolean setup_editor_el_user_defined = TRUE;
5108 static boolean setup_editor_el_dynamic = TRUE;
5110 static int editor_hl_unused[] = { EL_EMPTY };
5111 static int *editor_hl_unused_ptr = editor_hl_unused;
5112 static int num_editor_hl_unused = 0;
5116 boolean *setup_value;
5117 boolean *setup_cascade_value;
5119 int **headline_list;
5120 int *headline_list_size;
5123 int *element_list_size;
5125 boolean last_setup_value;
5127 editor_elements_info[] =
5130 &setup_editor_el_players,
5131 &setup_editor_cascade_never,
5132 &editor_hl_unused_ptr, &num_editor_hl_unused,
5133 &editor_el_players_ptr, &num_editor_el_players
5136 &setup_editor_el_boulderdash,
5137 &setup.editor_cascade.el_bd,
5138 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
5139 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
5142 &setup_editor_el_emerald_mine,
5143 &setup.editor_cascade.el_em,
5144 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
5145 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
5148 &setup_editor_el_emerald_mine_club,
5149 &setup.editor_cascade.el_emc,
5150 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
5151 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
5154 &setup_editor_el_more,
5155 &setup.editor_cascade.el_rnd,
5156 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
5157 &editor_el_rnd_ptr, &num_editor_el_rnd
5160 &setup_editor_el_sokoban,
5161 &setup.editor_cascade.el_sb,
5162 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
5163 &editor_el_sokoban_ptr, &num_editor_el_sokoban
5166 &setup_editor_el_supaplex,
5167 &setup.editor_cascade.el_sp,
5168 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
5169 &editor_el_supaplex_ptr, &num_editor_el_supaplex
5172 &setup_editor_el_diamond_caves,
5173 &setup.editor_cascade.el_dc,
5174 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
5175 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
5178 &setup_editor_el_dx_boulderdash,
5179 &setup.editor_cascade.el_dx,
5180 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
5181 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
5184 &setup_editor_el_mirror_magic,
5185 &setup.editor_cascade.el_mm,
5186 &editor_hl_mirror_magic_ptr, &num_editor_hl_mirror_magic,
5187 &editor_el_mirror_magic_ptr, &num_editor_el_mirror_magic
5190 &setup_editor_el_deflektor,
5191 &setup.editor_cascade.el_df,
5192 &editor_hl_deflektor_ptr, &num_editor_hl_deflektor,
5193 &editor_el_deflektor_ptr, &num_editor_el_deflektor
5196 &setup_editor_el_chars,
5197 &setup.editor_cascade.el_chars,
5198 &editor_hl_chars_ptr, &num_editor_hl_chars,
5199 &editor_el_chars_ptr, &num_editor_el_chars
5202 &setup_editor_el_steel_chars,
5203 &setup.editor_cascade.el_steel_chars,
5204 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
5205 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
5208 &setup_editor_el_custom,
5209 &setup.editor_cascade.el_ce,
5210 &editor_hl_custom_ptr, &num_editor_hl_custom,
5211 &editor_el_custom_ptr, &num_editor_el_custom
5214 &setup_editor_el_custom,
5215 &setup.editor_cascade.el_ge,
5216 &editor_hl_group_ptr, &num_editor_hl_group,
5217 &editor_el_group_ptr, &num_editor_el_group
5220 &setup_editor_el_custom,
5221 &setup.editor_cascade.el_ref,
5222 &editor_hl_reference_ptr, &num_editor_hl_reference,
5223 &editor_el_reference_ptr, &num_editor_el_reference
5226 &setup_editor_el_user_defined,
5227 &setup.editor_cascade.el_user,
5228 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
5229 &editor_el_user_defined_ptr, &num_editor_el_user_defined
5232 &setup_editor_el_dynamic,
5233 &setup.editor_cascade.el_dynamic,
5234 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
5235 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
5240 &editor_hl_empty_ptr, &num_editor_hl_empty,
5241 &editor_el_empty_ptr, &num_editor_el_empty,
5253 -----------------------------------------------------------------------------
5255 -----------------------------------------------------------------------------
5258 static int getMaxInfoTextLength()
5260 return (SXSIZE / getFontWidth(INFOTEXT_FONT));
5263 static int getTextWidthForGadget(char *text)
5268 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
5271 static int getTextWidthForDrawingArea(char *text)
5276 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
5279 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
5281 return (gi->x + gi->width + getTextWidthForGadget(text));
5284 static char *getElementInfoText(int element)
5286 char *info_text = NULL;
5288 if (element < MAX_NUM_ELEMENTS)
5290 if (strlen(element_info[element].description) > 0)
5291 info_text = element_info[element].description;
5292 else if (element_info[element].custom_description != NULL)
5293 info_text = element_info[element].custom_description;
5294 else if (element_info[element].editor_description != NULL)
5295 info_text = element_info[element].editor_description;
5298 if (info_text == NULL)
5299 info_text = INFOTEXT_UNKNOWN_ELEMENT;
5304 static char *getElementDescriptionFilenameExt(char *basename)
5306 char *elements_subdir = "elements";
5307 static char *elements_subdir2 = NULL;
5308 static char *filename = NULL;
5310 if (elements_subdir2 == NULL)
5311 elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
5313 checked_free(filename);
5315 /* 1st try: look for element description in current level set directory */
5316 filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
5317 if (fileExists(filename))
5322 /* 2nd try: look for element description in the game's base directory */
5323 filename = getPath3(options.docs_directory, elements_subdir, basename);
5324 if (fileExists(filename))
5330 char *getElementDescriptionFilename(int element)
5332 char basename[MAX_FILENAME_LEN];
5335 /* 1st try: look for element description file for exactly this element */
5336 sprintf(basename, "%s.txt", element_info[element].token_name);
5337 filename = getElementDescriptionFilenameExt(basename);
5338 if (filename != NULL)
5341 /* 2nd try: look for element description file for this element's class */
5342 sprintf(basename, "%s.txt", element_info[element].class_name);
5343 filename = getElementDescriptionFilenameExt(basename);
5344 if (filename != NULL)
5350 static void InitDynamicEditorElementList(int **elements, int *num_elements)
5352 boolean element_found[NUM_FILE_ELEMENTS];
5355 /* initialize list of used elements to "not used" */
5356 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5357 element_found[i] = FALSE;
5359 /* find all elements used in current level */
5360 for (y = 0; y < lev_fieldy; y++)
5361 for (x = 0; x < lev_fieldx; x++)
5362 if (Feld[x][y] < NUM_FILE_ELEMENTS) /* should always be true */
5363 element_found[Feld[x][y]] = TRUE;
5367 /* count number of elements used in current level */
5368 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5369 if (element_found[i])
5372 /* add space for up to 3 more elements for padding that may be needed */
5375 /* free memory for old list of elements, if needed */
5376 checked_free(*elements);
5378 /* allocate memory for new list of elements */
5379 *elements = checked_malloc(*num_elements * sizeof(int));
5383 /* add all elements used in current level (non-custom/group elements) */
5384 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5385 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
5386 (*elements)[(*num_elements)++] = i;
5388 /* add all elements used in current level (custom/group elements) */
5389 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5390 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
5391 (*elements)[(*num_elements)++] = i;
5393 while (*num_elements % 4) /* pad with empty elements, if needed */
5394 (*elements)[(*num_elements)++] = EL_EMPTY;
5397 static void ReinitializeElementList_EnableSections()
5399 /* default: enable all element sections */
5401 setup_editor_el_players = TRUE;
5402 setup_editor_el_boulderdash = TRUE;
5403 setup_editor_el_emerald_mine = TRUE;
5404 setup_editor_el_emerald_mine_club = TRUE;
5405 setup_editor_el_more = TRUE;
5406 setup_editor_el_sokoban = TRUE;
5407 setup_editor_el_supaplex = TRUE;
5408 setup_editor_el_diamond_caves = TRUE;
5409 setup_editor_el_dx_boulderdash = TRUE;
5410 setup_editor_el_mirror_magic = TRUE;
5411 setup_editor_el_deflektor = TRUE;
5412 setup_editor_el_chars = TRUE;
5413 setup_editor_el_steel_chars = TRUE;
5415 setup_editor_el_custom = TRUE;
5416 setup_editor_el_user_defined = TRUE;
5417 setup_editor_el_dynamic = TRUE;
5419 /* now disable all element sections not to be displayed */
5421 if (!setup.editor.el_classic)
5423 setup_editor_el_players = FALSE;
5424 setup_editor_el_boulderdash = FALSE;
5425 setup_editor_el_emerald_mine = FALSE;
5426 setup_editor_el_emerald_mine_club = FALSE;
5427 setup_editor_el_more = FALSE;
5428 setup_editor_el_sokoban = FALSE;
5429 setup_editor_el_supaplex = FALSE;
5430 setup_editor_el_diamond_caves = FALSE;
5431 setup_editor_el_dx_boulderdash = FALSE;
5432 setup_editor_el_mirror_magic = FALSE;
5433 setup_editor_el_deflektor = FALSE;
5434 setup_editor_el_chars = FALSE;
5435 setup_editor_el_steel_chars = FALSE;
5438 if (!setup.editor.el_custom)
5440 setup_editor_el_custom = FALSE;
5443 if (!setup.editor.el_user_defined)
5445 setup_editor_el_user_defined = FALSE;
5448 if (!setup.editor.el_dynamic)
5450 setup_editor_el_dynamic = FALSE;
5453 if (level.game_engine_type == GAME_ENGINE_TYPE_RND)
5455 setup_editor_el_mirror_magic = FALSE;
5456 setup_editor_el_deflektor = FALSE;
5458 else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
5460 setup_editor_el_boulderdash = FALSE;
5461 setup_editor_el_more = FALSE;
5462 setup_editor_el_sokoban = FALSE;
5463 setup_editor_el_supaplex = FALSE;
5464 setup_editor_el_dx_boulderdash = FALSE;
5465 setup_editor_el_mirror_magic = FALSE;
5466 setup_editor_el_deflektor = FALSE;
5467 setup_editor_el_steel_chars = FALSE;
5469 setup_editor_el_custom = FALSE;
5471 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
5473 setup_editor_el_players = FALSE;
5474 setup_editor_el_boulderdash = FALSE;
5475 setup_editor_el_emerald_mine = FALSE;
5476 setup_editor_el_emerald_mine_club = FALSE;
5477 setup_editor_el_more = FALSE;
5478 setup_editor_el_sokoban = FALSE;
5479 setup_editor_el_diamond_caves = FALSE;
5480 setup_editor_el_dx_boulderdash = FALSE;
5481 setup_editor_el_mirror_magic = FALSE;
5482 setup_editor_el_deflektor = FALSE;
5483 setup_editor_el_chars = FALSE;
5484 setup_editor_el_steel_chars = FALSE;
5486 setup_editor_el_custom = FALSE;
5488 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
5490 setup_editor_el_players = FALSE;
5491 setup_editor_el_boulderdash = FALSE;
5492 setup_editor_el_emerald_mine = FALSE;
5493 setup_editor_el_emerald_mine_club = FALSE;
5494 setup_editor_el_more = FALSE;
5495 setup_editor_el_sokoban = FALSE;
5496 setup_editor_el_supaplex = FALSE;
5497 setup_editor_el_diamond_caves = FALSE;
5498 setup_editor_el_dx_boulderdash = FALSE;
5499 setup_editor_el_steel_chars = FALSE;
5501 setup_editor_el_custom = FALSE;
5505 static void ReinitializeElementList()
5507 static boolean initialization_needed = TRUE;
5511 ReinitializeElementList_EnableSections();
5513 if (initialization_needed)
5515 LoadSetup_EditorCascade(); /* load last editor cascade state */
5517 /* initialize editor cascade element from saved cascade state */
5518 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5520 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
5521 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
5523 if (IS_EDITOR_CASCADE(*cascade_element))
5525 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
5526 EL_CASCADE_INACTIVE(*cascade_element));
5529 initialization_needed = FALSE;
5532 checked_free(editor_elements);
5534 /* reload optional user defined element list for each invocation of editor */
5535 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
5536 &num_editor_el_user_defined);
5538 /* initialize dynamic level element list for each invocation of editor */
5539 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
5540 &num_editor_el_dynamic);
5542 /* initialize list of empty elements (used for padding, if needed) */
5543 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
5544 editor_el_empty[i] = EL_EMPTY;
5546 /* do some sanity checks for each element from element list */
5547 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5549 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
5551 int element = (*editor_elements_info[i].element_list)[j];
5553 if (element >= NUM_FILE_ELEMENTS)
5554 Error(ERR_WARN, "editor element %d is runtime element", element);
5556 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
5557 Error(ERR_WARN, "no element description text for element %d", element);
5561 num_editor_elements = 0;
5562 use_el_empty = FALSE;
5564 /* determine size of element list */
5565 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5567 boolean found_inactive_cascade = FALSE;
5569 if (*editor_elements_info[i].setup_value)
5571 if (setup.editor.el_headlines)
5573 // required for correct padding of palette headline buttons
5574 if (*editor_elements_info[i].headline_list_size > 0)
5575 num_editor_elements += editor.palette.cols;
5577 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
5579 int element = (*editor_elements_info[i].headline_list)[j];
5581 if (IS_EDITOR_CASCADE_INACTIVE(element))
5582 found_inactive_cascade = TRUE;
5586 if (found_inactive_cascade)
5589 // required for correct padding of palette element buttons
5590 int element_list_size = *editor_elements_info[i].element_list_size;
5592 (element_list_size + editor.palette.cols - 1) / editor.palette.cols;
5593 int element_buttons = editor.palette.cols * element_rows;
5595 num_editor_elements += element_buttons;
5599 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
5601 /* offer at least as many elements as element buttons exist */
5602 use_el_empty = TRUE;
5603 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
5605 num_editor_elements += num_editor_el_empty;
5608 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
5610 /* fill element list */
5611 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5613 boolean found_inactive_cascade = FALSE;
5615 if (*editor_elements_info[i].setup_value)
5617 if (setup.editor.el_headlines)
5619 // required for correct padding of palette headline buttons
5620 int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
5621 editor.palette.cols : 0);
5623 for (j = 0; j < headline_size; j++)
5625 // use empty elements for padding of palette headline buttons
5626 int element = (j < *editor_elements_info[i].headline_list_size ?
5627 (*editor_elements_info[i].headline_list)[j] :
5628 editor_el_empty[0]);
5630 editor_elements[pos++] = element;
5632 if (IS_EDITOR_CASCADE_INACTIVE(element))
5633 found_inactive_cascade = TRUE;
5637 if (found_inactive_cascade)
5640 // required for correct padding of palette element buttons
5641 int element_list_size = *editor_elements_info[i].element_list_size;
5643 (element_list_size + editor.palette.cols - 1) / editor.palette.cols;
5644 int element_buttons = editor.palette.cols * element_rows;
5646 // copy all elements from element list
5647 for (j = 0; j < element_list_size; j++)
5648 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
5650 // use empty elements for padding of palette element buttons
5651 for (j = 0; j < element_buttons - element_list_size; j++)
5652 editor_elements[pos++] = editor_el_empty[0];
5656 /* (this function is also called before editor gadgets are initialized!) */
5657 AdjustElementListScrollbar();
5660 void PrintEditorElementList()
5662 boolean *stop = &setup.editor.el_user_defined;
5665 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
5667 int cascade_element = (*editor_elements_info[i].headline_list)[0];
5669 if (IS_EDITOR_CASCADE(cascade_element))
5671 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
5672 char *headline = element_info[cascade_element_show].editor_description;
5674 PrintLineWithPrefix("# ", "-", 77);
5675 Print("# %s\n", headline);
5676 PrintLineWithPrefix("# ", "-", 77);
5679 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
5681 int element = (*editor_elements_info[i].headline_list)[j];
5683 if (IS_EDITOR_CASCADE(element))
5684 element = EL_CHAR_MINUS;
5686 Print("# %s\n", element_info[element].token_name);
5692 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
5694 int element = (*editor_elements_info[i].element_list)[j];
5696 Print("# %s\n", element_info[element].token_name);
5704 static void ReinitializeElementListButtons()
5706 static boolean last_setup_value_headlines = FALSE;
5707 static boolean initialization_needed = TRUE;
5710 if (!initialization_needed) /* check if editor element setup has changed */
5712 if (last_setup_value_headlines != setup.editor.el_headlines)
5713 initialization_needed = TRUE;
5715 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5716 if (editor_elements_info[i].last_setup_value !=
5717 *editor_elements_info[i].setup_value)
5718 initialization_needed = TRUE;
5721 if (!initialization_needed)
5724 FreeLevelEditorGadgets();
5725 CreateLevelEditorGadgets();
5727 /* store current setup values for next invocation of this function */
5728 last_setup_value_headlines = setup.editor.el_headlines;
5729 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5730 editor_elements_info[i].last_setup_value =
5731 *editor_elements_info[i].setup_value;
5733 initialization_needed = FALSE;
5736 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
5739 int border_graphic =
5740 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
5741 struct GraphicInfo *g = &graphic_info[border_graphic];
5742 Bitmap *src_bitmap = g->bitmap;
5743 int src_x = g->src_x;
5744 int src_y = g->src_y;
5745 int border_size = g->border_size;
5746 int border_xpos = g->width - border_size;
5747 int border_ypos = g->height - border_size;
5748 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
5751 BlitBitmap(src_bitmap, drawto, src_x, src_y,
5752 border_size, border_size,
5753 dest_x - border_size, dest_y - border_size);
5754 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y,
5755 border_size, border_size,
5756 dest_x + width, dest_y - border_size);
5757 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_ypos,
5758 border_size, border_size,
5759 dest_x - border_size, dest_y + height);
5760 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_ypos,
5761 border_size, border_size,
5762 dest_x + width, dest_y + height);
5764 for (i = 0; i < width / tilesize; i++)
5766 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y,
5767 tilesize, border_size,
5768 dest_x + i * tilesize, dest_y - border_size);
5769 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y + border_ypos,
5770 tilesize, border_size,
5771 dest_x + i * tilesize, dest_y + height);
5774 for (i = 0; i < height / tilesize; i++)
5776 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_size,
5777 border_size, tilesize,
5778 dest_x - border_size, dest_y + i * tilesize);
5779 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_size,
5780 border_size, tilesize,
5781 dest_x + width, dest_y + i * tilesize);
5784 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
5787 static void DrawEditorElement(int x, int y, int element)
5789 DrawSizedElement(x, y, element, ed_tilesize);
5792 static void DrawEditorElementThruMask(int x, int y, int element)
5794 DrawSizedElementThruMask(x, y, element, ed_tilesize);
5797 static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
5799 DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
5802 static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
5804 DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
5807 static void DrawDrawingArea(int id)
5809 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
5812 int *value = drawingarea_info[id].value;
5813 int area_xsize = drawingarea_info[id].area_xsize;
5814 int area_ysize = drawingarea_info[id].area_ysize;
5815 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
5817 for (x = 0; x < area_xsize; x++)
5818 for (y = 0; y < area_ysize; y++)
5819 DrawSizedGraphicExt(drawto,
5820 gi->x + x * tilesize,
5821 gi->y + y * tilesize,
5822 el2edimg(value[x * area_ysize + y]), 0, tilesize);
5825 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
5828 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
5829 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
5831 BlitBitmap(drawto, drawto,
5832 SX + (dx == -1 ? ed_tilesize : 0),
5833 SY + (dy == -1 ? ed_tilesize : 0),
5834 (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
5835 (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
5836 SX + (dx == +1 ? ed_tilesize : 0),
5837 SY + (dy == +1 ? ed_tilesize : 0));
5841 x = (dx == 1 ? 0 : ed_fieldx - 1);
5842 for (y = 0; y < ed_fieldy; y++)
5843 DrawEditorElementOrWall(x, y, from_x, from_y);
5847 y = (dy == 1 ? 0 : ed_fieldy - 1);
5848 for (x = 0; x < ed_fieldx; x++)
5849 DrawEditorElementOrWall(x, y, from_x, from_y);
5852 redraw_mask |= REDRAW_FIELD;
5856 void getEditorGraphicSource(int element, int tile_size, Bitmap **bitmap,
5859 getSizedGraphicSource(el2edimg(element), 0, tile_size, bitmap, x, y);
5862 static void CreateControlButtons()
5864 struct GadgetInfo *gi;
5867 /* create toolbox buttons */
5868 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
5870 int id = controlbutton_info[i].gadget_id;
5871 int type = controlbutton_info[i].gadget_type;
5872 int graphic = controlbutton_info[i].graphic;
5873 struct XYTileSize *pos = controlbutton_info[i].pos;
5874 struct GraphicInfo *gd = &graphic_info[graphic];
5875 Bitmap *deco_bitmap = NULL;
5876 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
5877 int tile_size = 0, deco_shift = 0;
5878 boolean deco_masked = FALSE;
5879 int gd_x1 = gd->src_x;
5880 int gd_y1 = gd->src_y;
5881 int gd_x2 = gd->src_x + gd->pressed_xoffset;
5882 int gd_y2 = gd->src_y + gd->pressed_yoffset;
5883 int gd_x1a = gd->src_x + gd->active_xoffset;
5884 int gd_y1a = gd->src_y + gd->active_yoffset;
5885 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
5886 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
5889 unsigned int event_mask;
5890 int radio_button_nr = RADIO_NR_NONE;
5891 boolean checked = FALSE;
5893 if (type == GD_TYPE_RADIO_BUTTON)
5895 event_mask = GD_EVENT_PRESSED;
5896 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
5898 if (id == drawing_function)
5903 if (id == GADGET_ID_WRAP_LEFT ||
5904 id == GADGET_ID_WRAP_RIGHT ||
5905 id == GADGET_ID_WRAP_UP ||
5906 id == GADGET_ID_WRAP_DOWN)
5907 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5909 event_mask = GD_EVENT_RELEASED;
5912 if (id == GADGET_ID_PROPERTIES ||
5913 id == GADGET_ID_PALETTE)
5918 else if (id == GADGET_ID_ELEMENT_LEFT ||
5919 id == GADGET_ID_ELEMENT_MIDDLE ||
5920 id == GADGET_ID_ELEMENT_RIGHT)
5925 int element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
5926 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
5927 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : EL_EMPTY);
5929 tile_size = BUTTON_TILE_SIZE(id == GADGET_ID_ELEMENT_LEFT ?
5930 editor.button.element_left.tile_size :
5931 id == GADGET_ID_ELEMENT_MIDDLE ?
5932 editor.button.element_middle.tile_size :
5933 id == GADGET_ID_ELEMENT_RIGHT ?
5934 editor.button.element_right.tile_size : 0);
5936 // make sure that decoration does not overlap gadget border
5937 tile_size = MIN(tile_size, MIN(gd->width, gd->height));
5939 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x,&deco_y);
5941 deco_xpos = (gd->width - tile_size) / 2;
5942 deco_ypos = (gd->height - tile_size) / 2;
5944 deco_masked = gd->draw_masked;
5952 gi = CreateGadget(GDI_CUSTOM_ID, id,
5953 GDI_CUSTOM_TYPE_ID, i,
5954 GDI_INFO_TEXT, controlbutton_info[i].infotext,
5957 GDI_WIDTH, gd->width,
5958 GDI_HEIGHT, gd->height,
5960 GDI_STATE, GD_BUTTON_UNPRESSED,
5961 GDI_RADIO_NR, radio_button_nr,
5962 GDI_CHECKED, checked,
5963 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
5964 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
5965 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
5966 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
5967 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
5968 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
5969 GDI_DECORATION_SIZE, tile_size, tile_size,
5970 GDI_DECORATION_SHIFTING, deco_shift, deco_shift,
5971 GDI_DECORATION_MASKED, deco_masked,
5972 GDI_EVENT_MASK, event_mask,
5973 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5974 GDI_CALLBACK_ACTION, HandleControlButtons,
5978 Error(ERR_EXIT, "cannot create gadget");
5980 level_editor_gadget[id] = gi;
5983 /* these values are not constant, but can change at runtime */
5984 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
5985 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
5986 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
5987 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
5988 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
5989 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
5990 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
5991 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
5992 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].x = ED_SCROLL2_UP_XPOS;
5993 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y = ED_SCROLL2_UP_YPOS;
5994 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x = ED_SCROLL2_DOWN_XPOS;
5995 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y = ED_SCROLL2_DOWN_YPOS;
5997 /* create buttons for scrolling of drawing area and element list */
5998 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
6000 int id = scrollbutton_info[i].gadget_id;
6001 int graphic = scrollbutton_info[i].graphic;
6002 struct GraphicInfo *gd = &graphic_info[graphic];
6003 Bitmap *gd_bitmap = gd->bitmap;
6004 int gd_x1 = gd->src_x;
6005 int gd_y1 = gd->src_y;
6006 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6007 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6008 int width = gd->width;
6009 int height = gd->height;
6010 int x = scrollbutton_pos[i].x;
6011 int y = scrollbutton_pos[i].y;
6012 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6014 if (id == GADGET_ID_SCROLL_LIST_UP ||
6015 id == GADGET_ID_SCROLL_LIST_DOWN)
6026 gi = CreateGadget(GDI_CUSTOM_ID, id,
6027 GDI_CUSTOM_TYPE_ID, i,
6028 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6033 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6034 GDI_STATE, GD_BUTTON_UNPRESSED,
6035 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6036 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6037 GDI_EVENT_MASK, event_mask,
6038 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6039 GDI_CALLBACK_ACTION, HandleControlButtons,
6043 Error(ERR_EXIT, "cannot create gadget");
6045 level_editor_gadget[id] = gi;
6048 /* create buttons for element list */
6049 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6051 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
6052 int graphic = IMG_EDITOR_PALETTE_BUTTON;
6053 struct GraphicInfo *gd = &graphic_info[graphic];
6054 Bitmap *gd_bitmap = gd->bitmap;
6055 Bitmap *deco_bitmap;
6056 int deco_x, deco_y, deco_xpos, deco_ypos;
6057 int gd_x1 = gd->src_x;
6058 int gd_y1 = gd->src_y;
6059 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6060 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6061 int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
6062 int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
6063 int x = PX + ED_ELEMENTLIST_XPOS + xx * gd->width;
6064 int y = PY + ED_ELEMENTLIST_YPOS + yy * gd->height;
6065 int element = editor_elements[i];
6066 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
6067 unsigned int event_mask = GD_EVENT_RELEASED;
6069 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
6071 deco_xpos = (gd->width - tile_size) / 2;
6072 deco_ypos = (gd->height - tile_size) / 2;
6074 gi = CreateGadget(GDI_CUSTOM_ID, id,
6075 GDI_CUSTOM_TYPE_ID, i,
6076 GDI_INFO_TEXT, getElementInfoText(element),
6079 GDI_WIDTH, gd->width,
6080 GDI_HEIGHT, gd->height,
6081 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6082 GDI_STATE, GD_BUTTON_UNPRESSED,
6083 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6084 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6085 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6086 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6087 GDI_DECORATION_SIZE, tile_size, tile_size,
6088 GDI_DECORATION_SHIFTING, 1, 1,
6089 GDI_EVENT_MASK, event_mask,
6090 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6091 GDI_CALLBACK_ACTION, HandleControlButtons,
6095 Error(ERR_EXIT, "cannot create gadget");
6097 level_editor_gadget[id] = gi;
6101 static void CreateCounterButtons()
6103 int max_infotext_len = getMaxInfoTextLength();
6106 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
6109 int x = SX + ED_SETTINGS_X(counterbutton_info[i].x); /* down count button */
6110 int y = SY + ED_SETTINGS_Y(counterbutton_info[i].y);
6112 /* determine horizontal position to the right of specified gadget */
6113 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6114 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
6115 ED_GADGET_TEXT_DISTANCE);
6117 /* determine horizontal offset for leading text */
6118 if (counterbutton_info[i].text_left != NULL)
6119 x += getTextWidthForGadget(counterbutton_info[i].text_left);
6121 for (j = 0; j < 2; j++)
6123 struct GadgetInfo *gi;
6125 counterbutton_info[i].gadget_id_down :
6126 counterbutton_info[i].gadget_id_up);
6128 struct GraphicInfo *gd;
6129 int gd_x1, gd_x2, gd_y1, gd_y2;
6130 unsigned int event_mask;
6131 char infotext[max_infotext_len + 1];
6133 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6135 if (i == ED_COUNTER_ID_SELECT_LEVEL)
6138 IMG_GFX_EDITOR_BUTTON_PREV_LEVEL :
6139 IMG_GFX_EDITOR_BUTTON_NEXT_LEVEL);
6141 event_mask |= GD_EVENT_RELEASED;
6145 x = DX + editor.button.prev_level.x;
6146 y = DY + editor.button.prev_level.y;
6150 x = DX + editor.button.next_level.x;
6151 y = DY + editor.button.next_level.y;
6157 IMG_EDITOR_COUNTER_DOWN :
6158 IMG_EDITOR_COUNTER_UP);
6161 gd = &graphic_info[graphic];
6165 gd_x2 = gd->src_x + gd->pressed_xoffset;
6166 gd_y2 = gd->src_y + gd->pressed_yoffset;
6168 sprintf(infotext, "%s counter value by 1, 5 or 10",
6169 (j == 0 ? "decrease" : "increase"));
6171 gi = CreateGadget(GDI_CUSTOM_ID, id,
6172 GDI_CUSTOM_TYPE_ID, i,
6173 GDI_INFO_TEXT, infotext,
6176 GDI_WIDTH, gd->width,
6177 GDI_HEIGHT, gd->height,
6178 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6179 GDI_STATE, GD_BUTTON_UNPRESSED,
6180 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6181 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6182 GDI_EVENT_MASK, event_mask,
6183 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6184 GDI_CALLBACK_ACTION, HandleCounterButtons,
6188 Error(ERR_EXIT, "cannot create gadget");
6190 level_editor_gadget[id] = gi;
6191 right_gadget_border[id] =
6192 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
6194 x += gi->width + ED_GADGET_SMALL_DISTANCE; /* text count button */
6198 int font_type = FONT_INPUT_1;
6199 int font_type_active = FONT_INPUT_1_ACTIVE;
6201 id = counterbutton_info[i].gadget_id_text;
6203 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6205 if (i == ED_COUNTER_ID_SELECT_LEVEL)
6207 graphic = IMG_GFX_EDITOR_INPUT_LEVEL_NUMBER;
6209 font_type = FONT_LEVEL_NUMBER;
6210 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
6212 x = DX + editor.input.level_number.x;
6213 y = DY + editor.input.level_number.y;
6217 graphic = IMG_EDITOR_COUNTER_INPUT;
6220 gd = &graphic_info[graphic];
6224 gd_x2 = gd->src_x + gd->active_xoffset;
6225 gd_y2 = gd->src_y + gd->active_yoffset;
6227 gi = CreateGadget(GDI_CUSTOM_ID, id,
6228 GDI_CUSTOM_TYPE_ID, i,
6229 GDI_INFO_TEXT, "enter counter value",
6232 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
6233 GDI_NUMBER_VALUE, 0,
6234 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
6235 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
6236 GDI_TEXT_SIZE, 3, /* minimal counter text size */
6237 GDI_TEXT_FONT, font_type,
6238 GDI_TEXT_FONT_ACTIVE, font_type_active,
6239 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6240 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6241 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6242 GDI_DESIGN_WIDTH, gd->width,
6243 GDI_EVENT_MASK, event_mask,
6244 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6245 GDI_CALLBACK_ACTION, HandleCounterButtons,
6249 Error(ERR_EXIT, "cannot create gadget");
6251 level_editor_gadget[id] = gi;
6252 right_gadget_border[id] =
6253 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
6255 x += gi->width + ED_GADGET_SMALL_DISTANCE; /* up count button */
6261 static void CreateDrawingAreas()
6265 /* these values are not constant, but can change at runtime */
6266 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
6267 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
6269 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
6271 struct GadgetInfo *gi;
6272 unsigned int event_mask;
6273 int id = drawingarea_info[i].gadget_id;
6274 int x = SX + ED_AREA_SETTINGS_X(drawingarea_info[i]);
6275 int y = SY + ED_AREA_SETTINGS_Y(drawingarea_info[i]);
6276 int area_xsize = drawingarea_info[i].area_xsize;
6277 int area_ysize = drawingarea_info[i].area_ysize;
6278 int item_size = (id == GADGET_ID_DRAWING_LEVEL ?
6279 ed_tilesize : ED_DRAWINGAREA_TILE_SIZE);
6282 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
6283 GD_EVENT_OFF_BORDERS | GD_EVENT_PIXEL_PRECISE;
6285 /* determine horizontal position to the right of specified gadget */
6286 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
6287 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
6288 ED_DRAWINGAREA_TEXT_DISTANCE);
6290 /* determine horizontal offset for leading text */
6291 if (drawingarea_info[i].text_left != NULL)
6292 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
6294 gi = CreateGadget(GDI_CUSTOM_ID, id,
6295 GDI_CUSTOM_TYPE_ID, i,
6298 GDI_TYPE, GD_TYPE_DRAWING_AREA,
6299 GDI_AREA_SIZE, area_xsize, area_ysize,
6300 GDI_ITEM_SIZE, item_size, item_size,
6301 GDI_EVENT_MASK, event_mask,
6302 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
6303 GDI_CALLBACK_ACTION, HandleDrawingAreas,
6307 Error(ERR_EXIT, "cannot create gadget");
6309 level_editor_gadget[id] = gi;
6310 right_gadget_border[id] =
6311 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
6315 static void CreateTextInputGadgets()
6317 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
6318 int max_infotext_len = getMaxInfoTextLength();
6321 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
6323 int gd_x1 = gd->src_x;
6324 int gd_y1 = gd->src_y;
6325 int gd_x2 = gd->src_x + gd->active_xoffset;
6326 int gd_y2 = gd->src_y + gd->active_yoffset;
6327 struct GadgetInfo *gi;
6328 unsigned int event_mask;
6329 char infotext[MAX_OUTPUT_LINESIZE + 1];
6330 int id = textinput_info[i].gadget_id;
6333 if (i == ED_TEXTINPUT_ID_ELEMENT_NAME)
6335 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
6336 int border_size = gd->border_size;
6337 int font_nr = FONT_INPUT_1;
6338 int font_height = getFontHeight(font_nr);
6339 int xoffset = element_border + TILEX + element_border + 3 * border_size;
6340 int yoffset = element_border + (TILEY - font_height) / 2;
6342 x = (editor.settings.element_name.x != -1 ?
6343 editor.settings.element_name.x :
6344 editor.settings.element_graphic.x + xoffset) - border_size;
6345 y = (editor.settings.element_name.y != -1 ?
6346 editor.settings.element_name.y :
6347 editor.settings.element_graphic.y + yoffset) - border_size;
6351 x = ED_SETTINGS_X(textinput_info[i].x);
6352 y = ED_SETTINGS_Y(textinput_info[i].y);
6355 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6357 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
6358 infotext[max_infotext_len] = '\0';
6360 gi = CreateGadget(GDI_CUSTOM_ID, id,
6361 GDI_CUSTOM_TYPE_ID, i,
6362 GDI_INFO_TEXT, infotext,
6365 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
6366 GDI_TEXT_VALUE, textinput_info[i].value,
6367 GDI_TEXT_SIZE, textinput_info[i].size,
6368 GDI_TEXT_FONT, FONT_INPUT_1,
6369 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6370 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6371 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6372 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6373 GDI_DESIGN_WIDTH, gd->width,
6374 GDI_EVENT_MASK, event_mask,
6375 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6376 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
6380 Error(ERR_EXIT, "cannot create gadget");
6382 level_editor_gadget[id] = gi;
6386 static void CreateTextAreaGadgets()
6388 int max_infotext_len = getMaxInfoTextLength();
6391 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
6393 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXTAREA];
6394 int gd_x1 = gd->src_x;
6395 int gd_y1 = gd->src_y;
6396 int gd_x2 = gd->src_x + gd->active_xoffset;
6397 int gd_y2 = gd->src_y + gd->active_yoffset;
6398 struct GadgetInfo *gi;
6399 unsigned int event_mask;
6400 char infotext[MAX_OUTPUT_LINESIZE + 1];
6401 int id = textarea_info[i].gadget_id;
6402 int area_xsize = textarea_info[i].xsize;
6403 int area_ysize = textarea_info[i].ysize;
6405 event_mask = GD_EVENT_TEXT_LEAVING;
6407 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
6408 infotext[max_infotext_len] = '\0';
6410 gi = CreateGadget(GDI_CUSTOM_ID, id,
6411 GDI_CUSTOM_TYPE_ID, i,
6412 GDI_INFO_TEXT, infotext,
6413 GDI_X, SX + ED_SETTINGS_X(textarea_info[i].x),
6414 GDI_Y, SY + ED_SETTINGS_Y(textarea_info[i].y),
6415 GDI_TYPE, GD_TYPE_TEXT_AREA,
6416 GDI_AREA_SIZE, area_xsize, area_ysize,
6417 GDI_TEXT_FONT, FONT_INPUT_1,
6418 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6419 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6420 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6421 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6422 GDI_DESIGN_WIDTH, gd->width,
6423 GDI_EVENT_MASK, event_mask,
6424 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6425 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
6429 Error(ERR_EXIT, "cannot create gadget");
6431 level_editor_gadget[id] = gi;
6435 static void CreateSelectboxGadgets()
6437 int max_infotext_len = getMaxInfoTextLength();
6440 for (i = 0; i < ED_NUM_SELECTBOX; i++)
6442 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_SELECTBOX_INPUT];
6443 struct GraphicInfo *gd2 = &graphic_info[IMG_EDITOR_SELECTBOX_BUTTON];
6444 int gd_x1 = gd->src_x;
6445 int gd_y1 = gd->src_y;
6446 int gd_x2 = gd->src_x + gd->active_xoffset;
6447 int gd_y2 = gd->src_y + gd->active_yoffset;
6448 int selectbox_button_xsize = gd2->width;
6449 struct GadgetInfo *gi;
6450 unsigned int event_mask;
6451 char infotext[MAX_OUTPUT_LINESIZE + 1];
6452 int id = selectbox_info[i].gadget_id;
6453 int x = SX + ED_SETTINGS_X(selectbox_info[i].x);
6454 int y = SY + ED_SETTINGS_Y(selectbox_info[i].y);
6456 if (selectbox_info[i].size == -1) /* dynamically determine size */
6458 /* (we cannot use -1 for uninitialized values if we directly compare
6459 with results from strlen(), because the '<' and '>' operation will
6460 implicitely cast -1 to an unsigned integer value!) */
6461 selectbox_info[i].size = 0;
6463 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
6464 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
6465 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
6467 selectbox_info[i].size++; /* add one character empty space */
6470 event_mask = GD_EVENT_RELEASED |
6471 GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6473 /* determine horizontal position to the right of specified gadget */
6474 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
6475 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
6476 ED_GADGET_TEXT_DISTANCE);
6478 /* determine horizontal offset for leading text */
6479 if (selectbox_info[i].text_left != NULL)
6480 x += getTextWidthForGadget(selectbox_info[i].text_left);
6482 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
6483 infotext[max_infotext_len] = '\0';
6485 gi = CreateGadget(GDI_CUSTOM_ID, id,
6486 GDI_CUSTOM_TYPE_ID, i,
6487 GDI_INFO_TEXT, infotext,
6490 GDI_TYPE, GD_TYPE_SELECTBOX,
6491 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
6492 GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
6493 GDI_TEXT_SIZE, selectbox_info[i].size,
6494 GDI_TEXT_FONT, FONT_INPUT_1,
6495 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6496 GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
6497 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6498 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6499 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6500 GDI_BORDER_SIZE_SELECTBUTTON, selectbox_button_xsize,
6501 GDI_DESIGN_WIDTH, gd->width,
6502 GDI_EVENT_MASK, event_mask,
6503 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6504 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
6508 Error(ERR_EXIT, "cannot create gadget");
6510 level_editor_gadget[id] = gi;
6511 right_gadget_border[id] =
6512 getRightGadgetBorder(gi, selectbox_info[i].text_right);
6516 static void CreateTextbuttonGadgets()
6518 int max_infotext_len = getMaxInfoTextLength();
6521 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
6523 int id = textbutton_info[i].gadget_id;
6525 ((id >= GADGET_ID_LEVELINFO_LEVEL && id <= GADGET_ID_LEVELINFO_EDITOR) ||
6526 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE));
6528 (is_tab_button ? IMG_EDITOR_TABBUTTON : IMG_EDITOR_TEXTBUTTON);
6529 int gadget_distance =
6530 (is_tab_button ? ED_GADGET_SMALL_DISTANCE : ED_GADGET_TEXT_DISTANCE);
6531 struct GraphicInfo *gd = &graphic_info[graphic];
6532 int gd_x1 = gd->src_x;
6533 int gd_y1 = gd->src_y;
6534 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6535 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6536 int gd_x1a = gd->src_x + gd->active_xoffset;
6537 int gd_y1a = gd->src_y + gd->active_yoffset;
6538 int border_xsize = gd->border_size + gd->draw_xoffset;
6539 int border_ysize = gd->border_size;
6540 struct GadgetInfo *gi;
6541 unsigned int event_mask;
6542 char infotext[MAX_OUTPUT_LINESIZE + 1];
6543 int x = SX + ED_SETTINGS_X(textbutton_info[i].x);
6544 int y = SY + ED_SETTINGS_Y(textbutton_info[i].y);
6546 if (textbutton_info[i].size == -1) /* dynamically determine size */
6547 textbutton_info[i].size = strlen(textbutton_info[i].text);
6549 event_mask = GD_EVENT_RELEASED;
6551 sprintf(infotext, "%s", textbutton_info[i].infotext);
6552 infotext[max_infotext_len] = '\0';
6554 /* determine horizontal position to the right of specified gadget */
6555 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6557 int gadget_id_align = textbutton_info[i].gadget_id_align;
6559 x = right_gadget_border[gadget_id_align] + gadget_distance;
6561 if (textbutton_info[i].y == -1)
6562 y = level_editor_gadget[gadget_id_align]->y;
6565 /* determine horizontal offset for leading text */
6566 if (textbutton_info[i].text_left != NULL)
6567 x += getTextWidthForGadget(textbutton_info[i].text_left);
6569 gi = CreateGadget(GDI_CUSTOM_ID, id,
6570 GDI_CUSTOM_TYPE_ID, i,
6571 GDI_INFO_TEXT, infotext,
6574 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
6575 GDI_TEXT_VALUE, textbutton_info[i].text,
6576 GDI_TEXT_SIZE, textbutton_info[i].size,
6577 GDI_TEXT_FONT, FONT_INPUT_2,
6578 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2_ACTIVE,
6579 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6580 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6581 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6582 GDI_BORDER_SIZE, border_xsize, border_ysize,
6583 GDI_DESIGN_WIDTH, gd->width,
6584 GDI_DECORATION_SHIFTING, 1, 1,
6585 GDI_EVENT_MASK, event_mask,
6586 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6587 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
6591 Error(ERR_EXIT, "cannot create gadget");
6593 level_editor_gadget[id] = gi;
6594 right_gadget_border[id] =
6595 getRightGadgetBorder(gi, textbutton_info[i].text_right);
6599 static void CreateGraphicbuttonGadgets()
6601 struct GadgetInfo *gi;
6602 unsigned int event_mask;
6605 /* create buttons for scrolling of drawing area and element list */
6606 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
6608 int id = graphicbutton_info[i].gadget_id;
6609 int x = SX + ED_SETTINGS_X(graphicbutton_info[i].x);
6610 int y = SY + ED_SETTINGS_Y(graphicbutton_info[i].y);
6611 struct GraphicInfo *gd = &graphic_info[graphicbutton_info[i].graphic];
6612 int gd_x1 = gd->src_x;
6613 int gd_y1 = gd->src_y;
6614 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6615 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6617 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6619 /* determine horizontal position to the right of specified gadget */
6620 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6621 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
6622 ED_GADGET_TEXT_DISTANCE);
6624 /* determine horizontal offset for leading text */
6625 if (graphicbutton_info[i].text_left != NULL)
6626 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
6628 gi = CreateGadget(GDI_CUSTOM_ID, id,
6629 GDI_CUSTOM_TYPE_ID, i,
6630 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
6633 GDI_WIDTH, gd->width,
6634 GDI_HEIGHT, gd->height,
6635 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6636 GDI_STATE, GD_BUTTON_UNPRESSED,
6637 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6638 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6639 GDI_EVENT_MASK, event_mask,
6640 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6641 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
6645 Error(ERR_EXIT, "cannot create gadget");
6647 level_editor_gadget[id] = gi;
6648 right_gadget_border[id] =
6649 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
6653 static void CreateScrollbarGadgets()
6657 /* these values are not constant, but can change at runtime */
6658 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
6659 SX + ED_SCROLL_HORIZONTAL_XPOS;
6660 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
6661 SY + ED_SCROLL_HORIZONTAL_YPOS;
6662 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
6663 ED_SCROLL_HORIZONTAL_XSIZE;
6664 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
6665 ED_SCROLL_HORIZONTAL_YSIZE;
6666 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
6667 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
6668 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
6669 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
6671 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
6672 SX + ED_SCROLL_VERTICAL_XPOS;
6673 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
6674 SY + ED_SCROLL_VERTICAL_YPOS;
6675 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
6676 ED_SCROLL_VERTICAL_XSIZE;
6677 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
6678 ED_SCROLL_VERTICAL_YSIZE;
6679 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
6680 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
6681 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
6682 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
6684 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
6685 PX + ED_SCROLL2_VERTICAL_XPOS;
6686 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
6687 PY + ED_SCROLL2_VERTICAL_YPOS;
6688 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
6689 ED_SCROLL2_VERTICAL_XSIZE;
6690 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
6691 ED_SCROLL2_VERTICAL_YSIZE;
6692 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = PX;
6693 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = PY;
6694 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width = PXSIZE;
6695 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = PYSIZE;
6697 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
6699 int id = scrollbar_info[i].gadget_id;
6700 int graphic = scrollbar_info[i].graphic;
6701 struct GraphicInfo *gd = &graphic_info[graphic];
6702 int gd_x1 = gd->src_x;
6703 int gd_y1 = gd->src_y;
6704 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6705 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6706 struct GadgetInfo *gi;
6707 int items_max, items_visible, item_position;
6708 unsigned int event_mask;
6710 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
6712 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
6713 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
6714 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
6716 else /* drawing area scrollbars */
6718 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
6720 items_max = MAX(lev_fieldx + 2, ed_fieldx);
6721 items_visible = ed_fieldx;
6726 items_max = MAX(lev_fieldy + 2, ed_fieldy);
6727 items_visible = ed_fieldy;
6732 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
6734 gi = CreateGadget(GDI_CUSTOM_ID, id,
6735 GDI_CUSTOM_TYPE_ID, i,
6736 GDI_INFO_TEXT, scrollbar_info[i].infotext,
6737 GDI_X, scrollbar_pos[i].x,
6738 GDI_Y, scrollbar_pos[i].y,
6739 GDI_WIDTH, scrollbar_pos[i].width,
6740 GDI_HEIGHT, scrollbar_pos[i].height,
6741 GDI_TYPE, scrollbar_info[i].type,
6742 GDI_SCROLLBAR_ITEMS_MAX, items_max,
6743 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
6744 GDI_SCROLLBAR_ITEM_POSITION, item_position,
6745 GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
6746 GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
6747 GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
6748 GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
6749 GDI_STATE, GD_BUTTON_UNPRESSED,
6750 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6751 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6752 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6753 GDI_EVENT_MASK, event_mask,
6754 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6755 GDI_CALLBACK_ACTION, HandleControlButtons,
6759 Error(ERR_EXIT, "cannot create gadget");
6761 level_editor_gadget[id] = gi;
6765 static void CreateCheckbuttonGadgets()
6767 struct GadgetInfo *gi;
6768 unsigned int event_mask;
6771 event_mask = GD_EVENT_PRESSED;
6773 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
6775 int id = checkbutton_info[i].gadget_id;
6776 int graphic = (id == GADGET_ID_STICK_ELEMENT ? IMG_EDITOR_STICKYBUTTON :
6777 IMG_EDITOR_CHECKBOX);
6778 struct GraphicInfo *gd = &graphic_info[graphic];
6779 int gd_x1 = gd->src_x;
6780 int gd_y1 = gd->src_y;
6781 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6782 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6783 int gd_x1a = gd->src_x + gd->active_xoffset;
6784 int gd_y1a = gd->src_y + gd->active_yoffset;
6785 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6786 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
6787 int x = SX + ED_SETTINGS_X(checkbutton_info[i].x);
6788 int y = SY + ED_SETTINGS_Y(checkbutton_info[i].y);
6790 /* determine horizontal position to the right of specified gadget */
6791 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6792 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
6793 ED_GADGET_TEXT_DISTANCE);
6795 /* determine horizontal offset for leading text */
6796 if (checkbutton_info[i].text_left != NULL)
6797 x += getTextWidthForGadget(checkbutton_info[i].text_left);
6799 gi = CreateGadget(GDI_CUSTOM_ID, id,
6800 GDI_CUSTOM_TYPE_ID, i,
6801 GDI_INFO_TEXT, checkbutton_info[i].infotext,
6804 GDI_WIDTH, gd->width,
6805 GDI_HEIGHT, gd->height,
6806 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
6807 GDI_CHECKED, *checkbutton_info[i].value,
6808 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6809 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6810 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6811 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
6812 GDI_EVENT_MASK, event_mask,
6813 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6814 GDI_CALLBACK_ACTION, HandleCheckbuttons,
6818 Error(ERR_EXIT, "cannot create gadget");
6820 level_editor_gadget[id] = gi;
6821 right_gadget_border[id] =
6822 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
6826 static void CreateRadiobuttonGadgets()
6828 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_RADIOBUTTON];
6829 int gd_x1 = gd->src_x;
6830 int gd_y1 = gd->src_y;
6831 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6832 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6833 int gd_x1a = gd->src_x + gd->active_xoffset;
6834 int gd_y1a = gd->src_y + gd->active_yoffset;
6835 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6836 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
6837 struct GadgetInfo *gi;
6838 unsigned int event_mask;
6841 event_mask = GD_EVENT_PRESSED;
6843 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
6845 int id = radiobutton_info[i].gadget_id;
6846 int x = SX + ED_SETTINGS_X(radiobutton_info[i].x);
6847 int y = SY + ED_SETTINGS_Y(radiobutton_info[i].y);
6850 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
6852 /* determine horizontal position to the right of specified gadget */
6853 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
6854 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
6855 ED_GADGET_TEXT_DISTANCE);
6857 /* determine horizontal offset for leading text */
6858 if (radiobutton_info[i].text_left != NULL)
6859 x += getTextWidthForGadget(radiobutton_info[i].text_left);
6861 gi = CreateGadget(GDI_CUSTOM_ID, id,
6862 GDI_CUSTOM_TYPE_ID, i,
6863 GDI_INFO_TEXT, radiobutton_info[i].infotext,
6866 GDI_WIDTH, gd->width,
6867 GDI_HEIGHT, gd->height,
6868 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
6869 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
6870 GDI_CHECKED, checked,
6871 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6872 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6873 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6874 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
6875 GDI_EVENT_MASK, event_mask,
6876 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6877 GDI_CALLBACK_ACTION, HandleRadiobuttons,
6881 Error(ERR_EXIT, "cannot create gadget");
6883 level_editor_gadget[id] = gi;
6884 right_gadget_border[id] =
6885 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
6889 void CreateLevelEditorGadgets()
6891 /* force EDITOR font inside level editor */
6892 SetFontStatus(GAME_MODE_EDITOR);
6894 /* these values are not constant, but can change at runtime */
6895 ed_fieldx = MAX_ED_FIELDX - 1;
6896 ed_fieldy = MAX_ED_FIELDY - 1;
6898 num_editor_gadgets = NUM_EDITOR_GADGETS;
6900 // printf("::: allocating %d gadgets ...\n", num_editor_gadgets);
6902 level_editor_gadget =
6903 checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *));
6904 right_gadget_border =
6905 checked_calloc(num_editor_gadgets * sizeof(int));
6907 editor_el_empty = checked_calloc(ED_NUM_ELEMENTLIST_BUTTONS * sizeof(int));
6908 editor_el_empty_ptr = editor_el_empty;
6910 use_permanent_palette = !editor.palette.show_as_separate_screen;
6912 ReinitializeElementList();
6914 CreateControlButtons();
6915 CreateScrollbarGadgets();
6917 /* order of function calls is important because of cross-references */
6918 CreateCheckbuttonGadgets();
6919 CreateCounterButtons();
6920 CreateRadiobuttonGadgets();
6921 CreateTextInputGadgets();
6922 CreateTextAreaGadgets();
6923 CreateSelectboxGadgets();
6924 CreateGraphicbuttonGadgets();
6925 CreateTextbuttonGadgets();
6926 CreateDrawingAreas();
6931 void FreeLevelEditorGadgets()
6935 // printf("::: freeing %d gadgets ...\n", num_editor_gadgets);
6937 for (i = 0; i < num_editor_gadgets; i++)
6939 FreeGadget(level_editor_gadget[i]);
6941 level_editor_gadget[i] = NULL;
6944 checked_free(level_editor_gadget);
6945 checked_free(right_gadget_border);
6947 checked_free(editor_el_empty);
6950 static void MapCounterButtons(int id)
6952 int font_nr = FONT_TEXT_1;
6953 int font_height = getFontHeight(font_nr);
6954 int gadget_id_down = counterbutton_info[id].gadget_id_down;
6955 int gadget_id_text = counterbutton_info[id].gadget_id_text;
6956 int gadget_id_up = counterbutton_info[id].gadget_id_up;
6957 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
6958 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
6959 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
6960 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
6961 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6962 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
6963 int yoffset = (gi_down->height - font_height) / 2;
6964 int x_left = gi_down->x - xoffset_left;
6965 int x_right; /* set after gadget position was modified */
6966 int y_above = gi_down->y - yoffset_above;
6968 int y; /* set after gadget position was modified */
6970 /* counter limits must be changed first to prevent value truncation */
6971 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
6972 counterbutton_info[id].max_value);
6974 /* right text position might have changed after setting position above */
6975 x_right = gi_up->x + gi_up->width + xoffset_right;
6977 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
6979 /* set position for "value[1,2,3,4]" counter gadgets (score in most cases) */
6980 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
6981 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
6983 ModifyGadget(gi_down, GDI_Y,
6984 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
6985 ModifyGadget(gi_text, GDI_Y,
6986 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
6987 ModifyGadget(gi_up, GDI_Y,
6988 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
6991 /* vertical position might have changed after setting position above */
6992 y = gi_up->y + yoffset;
6994 if (counterbutton_info[id].text_above)
6995 DrawText(x, y_above, counterbutton_info[id].text_above, font_nr);
6997 if (counterbutton_info[id].text_left)
6998 DrawText(x_left, y, counterbutton_info[id].text_left, font_nr);
7000 if (counterbutton_info[id].text_right)
7001 DrawText(x_right, y, counterbutton_info[id].text_right, font_nr);
7008 static void MapControlButtons()
7013 /* map toolbox buttons (excluding special CE toolbox buttons) */
7014 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
7015 MapGadget(level_editor_gadget[i]);
7017 /* map toolbox buttons (element properties buttons) */
7018 for (i = ED_NUM_CTRL1_4_BUTTONS; i < ED_NUM_CTRL1_7_BUTTONS; i++)
7019 MapGadget(level_editor_gadget[i]);
7021 if (use_permanent_palette)
7023 /* map buttons to select elements */
7024 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7025 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
7026 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
7027 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
7028 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
7031 /* map buttons to select level */
7032 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
7033 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
7034 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
7035 MapCounterButtons(counter_id);
7038 static void MapDrawingArea(int id)
7040 int font_nr = FONT_TEXT_1;
7041 int font_height = getFontHeight(font_nr);
7042 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
7043 int area_xsize = gi->drawing.area_xsize;
7044 int area_ysize = gi->drawing.area_ysize;
7045 int xoffset_left = getTextWidthForDrawingArea(drawingarea_info[id].text_left);
7046 int xoffset_below = getTextWidth(drawingarea_info[id].text_below, font_nr);
7047 int x_left = gi->x - xoffset_left;
7048 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
7049 int x_below = gi->x + (gi->width - xoffset_below) / 2;
7050 int y_side = gi->y + (gi->height - font_height) / 2;
7051 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
7053 if (drawingarea_info[id].text_left)
7054 DrawText(x_left, y_side, drawingarea_info[id].text_left, font_nr);
7056 if (drawingarea_info[id].text_right)
7057 DrawText(x_right, y_side, drawingarea_info[id].text_right, font_nr);
7059 if (drawingarea_info[id].text_below)
7060 DrawText(x_below, y_below, drawingarea_info[id].text_below, font_nr);
7062 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
7064 DrawElementBorder(gi->x, gi->y,
7065 area_xsize * ED_DRAWINGAREA_TILE_SIZE,
7066 area_ysize * ED_DRAWINGAREA_TILE_SIZE, TRUE);
7068 DrawDrawingArea(id);
7074 static void MapTextInputGadget(int id)
7076 int font_nr = FONT_TEXT_1;
7077 int font_height = getFontHeight(font_nr);
7078 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
7079 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7080 int x_above = ED_SETTINGS_X(textinput_info[id].x);
7081 int y_above = ED_SETTINGS_Y(textinput_info[id].y) - yoffset_above;
7083 if (textinput_info[id].text_above)
7084 DrawTextS(x_above, y_above, font_nr, textinput_info[id].text_above);
7086 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
7091 static void MapTextAreaGadget(int id)
7093 int font_nr = FONT_TEXT_1;
7094 int font_height = getFontHeight(font_nr);
7095 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
7096 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7097 int x_above = ED_SETTINGS_X(textarea_info[id].x);
7098 int y_above = ED_SETTINGS_Y(textarea_info[id].y) - yoffset_above;
7100 if (textarea_info[id].text_above)
7101 DrawTextS(x_above, y_above, font_nr, textarea_info[id].text_above);
7103 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
7108 static void MapSelectboxGadget(int id)
7110 int font_nr = FONT_TEXT_1;
7111 int font_height = getFontHeight(font_nr);
7112 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
7113 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
7114 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7115 int yoffset = (gi->height - font_height) / 2;
7116 int x_left = gi->x - xoffset_left;
7117 int x_right = gi->x + gi->width + xoffset_right;
7118 int y = gi->y + yoffset;
7120 if (selectbox_info[id].text_left)
7121 DrawText(x_left, y, selectbox_info[id].text_left, font_nr);
7123 if (selectbox_info[id].text_right)
7124 DrawText(x_right, y, selectbox_info[id].text_right, font_nr);
7126 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
7131 static void MapTextbuttonGadget(int id)
7133 int font_nr = FONT_TEXT_1;
7134 int font_height = getFontHeight(font_nr);
7135 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
7136 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
7137 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7138 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7139 int yoffset = (gi->height - font_height) / 2;
7140 int x_left = gi->x - xoffset_left;
7141 int x_right = gi->x + gi->width + xoffset_right;
7142 int y_above = gi->y - yoffset_above;
7144 int y = gi->y + yoffset;
7146 /* only show button to delete change pages when more than minimum pages */
7147 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
7148 custom_element.num_change_pages == MIN_CHANGE_PAGES)
7151 if (textbutton_info[id].text_above)
7152 DrawText(x, y_above, textbutton_info[id].text_above, font_nr);
7154 if (textbutton_info[id].text_left)
7155 DrawText(x_left, y, textbutton_info[id].text_left, font_nr);
7157 if (textbutton_info[id].text_right)
7158 DrawText(x_right, y, textbutton_info[id].text_right, font_nr);
7163 static void MapGraphicbuttonGadget(int id)
7165 int font_nr = FONT_TEXT_1;
7166 int font_height = getFontHeight(font_nr);
7167 struct GadgetInfo *gi= level_editor_gadget[graphicbutton_info[id].gadget_id];
7168 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
7169 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7170 int yoffset = (gi->height - font_height) / 2;
7171 int x_left = gi->x - xoffset_left;
7172 int x_right = gi->x + gi->width + xoffset_right;
7173 int y = gi->y + yoffset;
7175 if (graphicbutton_info[id].text_left)
7176 DrawText(x_left, y, graphicbutton_info[id].text_left, font_nr);
7178 if (graphicbutton_info[id].text_right)
7179 DrawText(x_right, y, graphicbutton_info[id].text_right, font_nr);
7184 static void MapRadiobuttonGadget(int id)
7186 int font_nr = FONT_TEXT_1;
7187 int font_height = getFontHeight(font_nr);
7188 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
7189 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
7190 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7191 int yoffset = (gi->height - font_height) / 2;
7192 int x_left = gi->x - xoffset_left;
7193 int x_right = gi->x + gi->width + xoffset_right;
7194 int y = gi->y + yoffset;
7196 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
7198 if (radiobutton_info[id].text_left)
7199 DrawText(x_left, y, radiobutton_info[id].text_left, font_nr);
7201 if (radiobutton_info[id].text_right)
7202 DrawText(x_right, y, radiobutton_info[id].text_right, font_nr);
7204 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
7209 static void MapCheckbuttonGadget(int id)
7211 int font_nr = FONT_TEXT_1;
7212 int font_height = getFontHeight(font_nr);
7213 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
7214 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
7215 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7216 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7217 int yoffset = (gi->height - font_height) / 2;
7218 int y_above = gi->y - yoffset_above;
7220 int x_left, x_right, y; /* set after gadget position was modified */
7222 /* set position for gadgets with dynamically determined position */
7223 if (checkbutton_info[id].x != -1) /* do not change dynamic positions */
7224 ModifyGadget(gi, GDI_X, SX + ED_SETTINGS_X(checkbutton_info[id].x),GDI_END);
7225 ModifyGadget(gi, GDI_Y, SY + ED_SETTINGS_Y(checkbutton_info[id].y), GDI_END);
7227 x_left = gi->x - xoffset_left;
7228 x_right = gi->x + gi->width + xoffset_right;
7229 y = gi->y + yoffset;
7231 if (checkbutton_info[id].text_above)
7232 DrawText(x, y_above, checkbutton_info[id].text_above, font_nr);
7234 if (checkbutton_info[id].text_left)
7235 DrawText(x_left, y, checkbutton_info[id].text_left, font_nr);
7237 if (checkbutton_info[id].text_right)
7238 DrawText(x_right, y, checkbutton_info[id].text_right, font_nr);
7240 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
7245 static void MapMainDrawingArea()
7247 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
7248 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
7251 for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
7253 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
7254 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
7255 no_horizontal_scrollbar) ||
7256 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
7257 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
7258 no_vertical_scrollbar))
7261 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
7264 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
7266 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
7267 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
7270 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
7273 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
7276 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
7280 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
7282 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
7283 i == GADGET_ID_CUSTOM_COPY_TO ||
7284 i == GADGET_ID_CUSTOM_EXCHANGE ||
7285 i == GADGET_ID_CUSTOM_COPY ||
7286 i == GADGET_ID_CUSTOM_PASTE)
7289 MapGadget(level_editor_gadget[i]);
7291 UnmapGadget(level_editor_gadget[i]);
7296 static void MapLevelEditorToolboxCustomGadgets()
7298 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
7301 static void UnmapLevelEditorToolboxCustomGadgets()
7303 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
7306 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
7310 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
7312 if (i != GADGET_ID_SINGLE_ITEMS &&
7313 i != GADGET_ID_PICK_ELEMENT)
7315 struct GadgetInfo *gi = level_editor_gadget[i];
7323 int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
7324 struct GraphicInfo *gd = &graphic_info[graphic];
7328 BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
7329 gi->width, gi->height, gi->x, gi->y);
7331 redraw_mask |= REDRAW_DOOR_3;
7337 static void MapLevelEditorToolboxDrawingGadgets()
7339 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
7342 static void UnmapLevelEditorToolboxDrawingGadgets()
7344 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
7347 static void UnmapDrawingArea(int id)
7349 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
7352 static void UnmapLevelEditorFieldGadgets()
7356 for (i = 0; i < num_editor_gadgets; i++)
7357 if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
7358 level_editor_gadget[i]->y))
7359 UnmapGadget(level_editor_gadget[i]);
7362 void UnmapLevelEditorGadgets()
7366 for (i = 0; i < num_editor_gadgets; i++)
7367 UnmapGadget(level_editor_gadget[i]);
7370 static void ResetUndoBuffer()
7372 undo_buffer_position = -1;
7373 undo_buffer_steps = -1;
7374 redo_buffer_steps = 0;
7376 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7378 level.changed = FALSE;
7381 static void DrawEditModeWindow()
7383 ModifyEditorElementList();
7384 RedrawDrawingElements();
7386 if (edit_mode == ED_MODE_INFO)
7387 DrawLevelInfoWindow();
7388 else if (edit_mode == ED_MODE_PROPERTIES)
7389 DrawPropertiesWindow();
7390 else if (edit_mode == ED_MODE_PALETTE)
7391 DrawPaletteWindow();
7392 else /* edit_mode == ED_MODE_DRAWING */
7393 DrawDrawingWindow();
7396 static void ChangeEditModeWindow(int new_edit_mode)
7398 edit_mode = (new_edit_mode != edit_mode ? new_edit_mode : ED_MODE_DRAWING);
7400 DrawEditModeWindow();
7403 static boolean LevelChanged()
7405 boolean field_changed = FALSE;
7408 for (y = 0; y < lev_fieldy; y++)
7409 for (x = 0; x < lev_fieldx; x++)
7410 if (Feld[x][y] != level.field[x][y])
7411 field_changed = TRUE;
7413 return (level.changed || field_changed);
7416 static boolean PrepareSavingIntoPersonalLevelSet()
7418 static LevelDirTree *last_copied_leveldir = NULL;
7419 static LevelDirTree *last_written_leveldir = NULL;
7420 static int last_copied_level_nr = -1;
7421 static int last_written_level_nr = -1;
7422 LevelDirTree *leveldir_former = leveldir_current;
7423 int level_nr_former = level_nr;
7426 // remember last mod/save so that for current session, we write
7427 // back to the same personal copy, asking only about overwrite.
7428 if (leveldir_current == last_copied_leveldir &&
7429 level_nr == last_copied_level_nr)
7431 // "cd" to personal level set dir (as used when writing last copy)
7432 leveldir_current = last_written_leveldir;
7433 level_nr = last_written_level_nr;
7438 if (!Request("This level is read only! "
7439 "Save into personal level set?", REQ_ASK))
7442 // "cd" to personal level set dir (for writing copy the first time)
7444 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
7446 // find unused level number
7447 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
7449 static char *level_filename = NULL;
7451 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
7453 if (!fileExists(level_filename))
7457 last_copied_leveldir = leveldir_former;
7458 last_copied_level_nr = level_nr_former;
7460 last_written_leveldir = leveldir_current;
7461 last_written_level_nr = level_nr = new_level_nr;
7466 static void ModifyLevelInfoForSavingIntoPersonalLevelSet(char *former_name)
7468 static char *filename_levelinfo = NULL, *mod_name = NULL;
7471 // annotate this copy-and-mod in personal levelinfo.conf
7472 setString(&filename_levelinfo,
7473 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
7475 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
7477 fprintf(file, "\n");
7478 fprintf(file, "# level %d was modified from:\n", level_nr);
7479 fprintf(file, "# - previous level set name: %s\n",
7481 fprintf(file, "# - level within previous set: %d \"%s\"\n",
7482 level.file_info.nr, level.name);
7483 fprintf(file, "# - previous author: %s\n",
7485 fprintf(file, "# - previous save date: ");
7487 if (level.creation_date.src == DATE_SRC_LEVELFILE)
7489 fprintf(file, "%04d-%02d-%02d\n",
7490 level.creation_date.year,
7491 level.creation_date.month,
7492 level.creation_date.day);
7496 fprintf(file, "not recorded\n");
7502 if (level_nr > leveldir_current->last_level)
7504 static char *temp_levelinfo = NULL;
7505 FILE *temp_file = NULL;
7506 char line[MAX_LINE_LEN];
7508 setString(&temp_levelinfo,
7509 getPath2(getCurrentLevelDir(),
7510 getStringCat2(LEVELINFO_FILENAME, ".new")));
7512 if ((file = fopen(filename_levelinfo, MODE_READ)) &&
7513 (temp_file = fopen(temp_levelinfo, MODE_WRITE)))
7515 while (fgets(line, MAX_LINE_LEN, file))
7517 if (!strPrefix(line, "levels:"))
7518 fputs(line, temp_file);
7520 fprintf(temp_file, "%-32s%d\n", "levels:", level_nr + 9);
7530 // needs error handling; also, ok on dos/win?
7531 unlink(filename_levelinfo);
7532 rename(temp_levelinfo, filename_levelinfo);
7535 // else: allow the save even if annotation failed
7537 // now... spray graffiti on the old level vital statistics
7538 // user can change these; just trying to set a good baseline
7540 // don't truncate names for fear of making offensive or silly:
7541 // long-named original author only recorded in levelinfo.conf.
7542 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
7543 if (!strEqual(level.author, leveldir_current->author))
7545 setString(&mod_name, getStringCat3(leveldir_current->author,
7546 " after ", level.author));
7548 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
7549 setString(&mod_name,
7550 getStringCat2(leveldir_current->author, " (ed.)"));
7552 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
7553 setString(&mod_name, leveldir_current->author);
7555 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
7557 // less worried about truncation here
7558 setString(&mod_name, getStringCat2("Mod: ", level.name));
7559 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
7563 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
7564 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
7568 for (x = 0; x < lev_fieldx; x++)
7569 for (y = 0; y < lev_fieldy; y++)
7570 dst[x][y] = src[x][y];
7573 static int setSelectboxValue(int selectbox_id, int new_value)
7575 int new_index_value = 0;
7578 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
7579 if (selectbox_info[selectbox_id].options[i].value == new_value)
7580 new_index_value = i;
7582 *selectbox_info[selectbox_id].value =
7583 selectbox_info[selectbox_id].options[new_index_value].value;
7585 return new_index_value;
7588 static void setSelectboxSpecialActionVariablesIfNeeded()
7592 /* change action mode and arg variables according to action type variable */
7593 for (i = 0; action_arg_options[i].value != -1; i++)
7595 if (action_arg_options[i].value == custom_element_change.action_type)
7597 int mode = action_arg_options[i].mode;
7599 /* only change if corresponding selectbox has changed */
7600 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
7601 action_arg_modes[mode])
7602 custom_element_change.action_mode = -1;
7604 /* only change if corresponding selectbox has changed */
7605 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
7606 action_arg_options[i].options)
7607 custom_element_change.action_arg = -1;
7614 static void setSelectboxSpecialActionOptions()
7618 /* change action mode and arg selectbox according to action type selectbox */
7619 for (i = 0; action_arg_options[i].value != -1; i++)
7621 if (action_arg_options[i].value == custom_element_change.action_type)
7623 int mode = action_arg_options[i].mode;
7625 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
7626 action_arg_modes[mode]);
7627 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
7628 custom_element_change.action_mode);
7630 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
7631 action_arg_options[i].options);
7632 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
7633 custom_element_change.action_arg);
7639 static void copy_custom_element_settings(int element_from, int element_to)
7641 struct ElementInfo *ei_from = &element_info[element_from];
7642 struct ElementInfo *ei_to = &element_info[element_to];
7644 copyElementInfo(ei_from, ei_to);
7647 static void replace_custom_element_in_settings(int element_from,
7652 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
7654 struct ElementInfo *ei = &element_info[i];
7656 for (y = 0; y < 3; y++)
7657 for (x = 0; x < 3; x++)
7658 if (ei->content.e[x][y] == element_from)
7659 ei->content.e[x][y] = element_to;
7661 for (j = 0; j < ei->num_change_pages; j++)
7663 struct ElementChangeInfo *change = &ei->change_page[j];
7665 if (change->target_element == element_from)
7666 change->target_element = element_to;
7668 if (change->initial_trigger_element == element_from)
7669 change->initial_trigger_element = element_to;
7671 if (change->action_element == element_from)
7672 change->action_element = element_to;
7674 for (y = 0; y < 3; y++)
7675 for (x = 0; x < 3; x++)
7676 if (change->target_content.e[x][y] == element_from)
7677 change->target_content.e[x][y] = element_to;
7680 if (ei->group != NULL) /* group or internal */
7681 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
7682 if (ei->group->element[j] == element_from)
7683 ei->group->element[j] = element_to;
7687 static void replace_custom_element_in_playfield(int element_from,
7692 for (x = 0; x < lev_fieldx; x++)
7693 for (y = 0; y < lev_fieldy; y++)
7694 if (Feld[x][y] == element_from)
7695 Feld[x][y] = element_to;
7698 static boolean CopyCustomElement(int element_old, int element_new,
7701 int copy_mode_orig = copy_mode;
7703 if (copy_mode == GADGET_ID_CUSTOM_COPY)
7705 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
7706 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
7707 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
7709 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
7711 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
7712 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
7713 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
7715 level.changed = TRUE;
7717 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
7719 Request("Please choose custom element!", REQ_CONFIRM);
7723 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
7725 Request("Please choose group element!", REQ_CONFIRM);
7731 level.changed = TRUE;
7734 /* when modifying custom/group element, ask for copying level template */
7735 if (copy_mode_orig != GADGET_ID_CUSTOM_COPY && level.use_custom_template)
7737 if (!AskToCopyAndModifyLevelTemplate())
7741 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
7743 copy_custom_element_settings(element_new, element_old);
7745 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
7747 copy_custom_element_settings(element_old, element_new);
7749 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
7751 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
7752 copy_custom_element_settings(element_new, element_old);
7753 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
7755 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
7756 replace_custom_element_in_settings(element_new, element_old);
7757 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
7759 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
7760 replace_custom_element_in_playfield(element_new, element_old);
7761 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
7764 UpdateCustomElementGraphicGadgets();
7765 DrawPropertiesWindow();
7770 static void CopyCustomElementPropertiesToEditor(int element)
7773 int current_change_page = element_info[element].current_change_page;
7775 /* dynamically (re)build selectbox for selecting change page */
7776 for (i = 0; i < element_info[element].num_change_pages; i++)
7778 sprintf(options_change_page_strings[i], "%d", i + 1);
7780 options_change_page[i].value = i;
7781 options_change_page[i].text = options_change_page_strings[i];
7784 options_change_page[i].value = -1;
7785 options_change_page[i].text = NULL;
7787 /* needed here to initialize combined element properties */
7788 InitElementPropertiesEngine(level.game_version);
7790 element_info[element].change =
7791 &element_info[element].change_page[current_change_page];
7793 custom_element = element_info[element];
7794 custom_element_change = *element_info[element].change;
7796 /* needed to initially set selectbox options for special action options */
7797 setSelectboxSpecialActionOptions();
7799 /* needed to initially set selectbox value variables to reliable defaults */
7800 for (i = 0; i < ED_NUM_SELECTBOX; i++)
7801 setSelectboxValue(i, *selectbox_info[i].value);
7803 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
7804 custom_element_properties[i] = HAS_PROPERTY(element, i);
7806 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
7807 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
7809 /* ---------- element settings: configure (custom elements) ------------- */
7811 /* set accessible layer selectbox help value */
7812 custom_element.access_type =
7813 (IS_WALKABLE(element) ? EP_WALKABLE :
7814 IS_PASSABLE(element) ? EP_PASSABLE :
7815 custom_element.access_type);
7816 custom_element.access_layer =
7817 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
7818 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
7819 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
7820 custom_element.access_layer);
7821 custom_element.access_protected =
7822 (IS_PROTECTED(element) ? 1 : 0);
7823 custom_element_properties[EP_ACCESSIBLE] =
7824 (IS_ACCESSIBLE_OVER(element) ||
7825 IS_ACCESSIBLE_INSIDE(element) ||
7826 IS_ACCESSIBLE_UNDER(element));
7828 /* set walk-to-object action selectbox help value */
7829 custom_element.walk_to_action =
7830 (IS_DIGGABLE(element) ? EP_DIGGABLE :
7831 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
7832 IS_DROPPABLE(element) ? EP_DROPPABLE :
7833 IS_THROWABLE(element) ? EP_THROWABLE :
7834 IS_PUSHABLE(element) ? EP_PUSHABLE :
7835 custom_element.walk_to_action);
7836 custom_element_properties[EP_WALK_TO_OBJECT] =
7837 (IS_DIGGABLE(element) ||
7838 IS_COLLECTIBLE_ONLY(element) ||
7839 IS_DROPPABLE(element) ||
7840 IS_THROWABLE(element) ||
7841 IS_PUSHABLE(element));
7843 /* set smash targets selectbox help value */
7844 custom_element.smash_targets =
7845 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
7846 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
7847 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
7848 custom_element.smash_targets);
7849 custom_element_properties[EP_CAN_SMASH] =
7850 (CAN_SMASH_EVERYTHING(element) ||
7851 CAN_SMASH_ENEMIES(element) ||
7852 CAN_SMASH_PLAYER(element));
7854 /* set deadliness selectbox help value */
7855 custom_element.deadliness =
7856 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
7857 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
7858 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
7859 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
7860 custom_element.deadliness);
7861 custom_element_properties[EP_DEADLY] =
7862 (DONT_TOUCH(element) ||
7863 DONT_GET_HIT_BY(element) ||
7864 DONT_COLLIDE_WITH(element) ||
7865 DONT_RUN_INTO(element));
7867 /* ---------- element settings: advanced (custom elements) --------------- */
7869 /* set "change by direct action" selectbox help value */
7870 custom_element_change.direct_action =
7871 (HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
7872 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
7873 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
7874 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
7875 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
7876 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
7877 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
7878 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
7879 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
7880 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
7881 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
7882 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
7883 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
7884 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
7885 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
7886 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
7887 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
7888 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
7889 custom_element_change.direct_action);
7891 /* set "change by other element action" selectbox help value */
7892 custom_element_change.other_action =
7893 (HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
7894 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
7895 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
7896 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
7897 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
7898 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
7899 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
7900 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
7901 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
7902 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
7903 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
7904 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
7905 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
7906 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
7907 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
7908 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
7909 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
7910 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
7911 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
7912 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
7913 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
7914 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
7915 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
7916 custom_element_change.other_action);
7919 static void CopyGroupElementPropertiesToEditor(int element)
7921 group_element_info = *element_info[element].group;
7922 custom_element = element_info[element]; /* needed for description */
7925 static void CopyClassicElementPropertiesToEditor(int element)
7927 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
7928 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
7929 getMoveIntoAcidProperty(&level, element);
7931 if (MAYBE_DONT_COLLIDE_WITH(element))
7932 custom_element_properties[EP_DONT_COLLIDE_WITH] =
7933 getDontCollideWithProperty(&level, element);
7936 static void CopyElementPropertiesToEditor(int element)
7938 if (IS_CUSTOM_ELEMENT(element))
7939 CopyCustomElementPropertiesToEditor(element);
7940 else if (IS_GROUP_ELEMENT(element))
7941 CopyGroupElementPropertiesToEditor(element);
7943 CopyClassicElementPropertiesToEditor(element);
7946 static boolean AskToCopyAndModifyLevelTemplate()
7948 if (Request("Copy and modify settings from level template?", REQ_ASK))
7950 level.use_custom_template = FALSE;
7952 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_1],
7953 GDI_CHECKED, FALSE, GDI_END);
7954 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_2],
7955 GDI_CHECKED, FALSE, GDI_END);
7961 LoadLevelTemplate(-1); /* this resets all element modifications ... */
7963 DrawEditModeWindow(); /* ... and copies them to 'custom_element' */
7969 static void CopyCustomElementPropertiesToGame(int element)
7972 int access_type_and_layer;
7974 /* mark that this custom element has been modified */
7975 custom_element.modified_settings = TRUE;
7976 level.changed = TRUE;
7978 if (level.use_custom_template)
7979 AskToCopyAndModifyLevelTemplate();
7981 element_info[element] = custom_element;
7982 *element_info[element].change = custom_element_change;
7984 /* ---------- element settings: configure (custom elements) ------------- */
7986 /* set accessible property from checkbox and selectbox */
7987 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
7988 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
7989 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
7990 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
7991 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
7992 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
7993 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
7994 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
7995 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
7996 custom_element_properties[access_type_and_layer] =
7997 custom_element_properties[EP_ACCESSIBLE];
7998 custom_element_properties[EP_PROTECTED] =
7999 (custom_element.access_protected != 0 &&
8000 custom_element_properties[EP_ACCESSIBLE]);
8002 /* set walk-to-object property from checkbox and selectbox */
8003 custom_element_properties[EP_DIGGABLE] = FALSE;
8004 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
8005 custom_element_properties[EP_DROPPABLE] = FALSE;
8006 custom_element_properties[EP_THROWABLE] = FALSE;
8007 custom_element_properties[EP_PUSHABLE] = FALSE;
8008 custom_element_properties[custom_element.walk_to_action] =
8009 custom_element_properties[EP_WALK_TO_OBJECT];
8011 /* set smash property from checkbox and selectbox */
8012 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
8013 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
8014 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
8015 custom_element_properties[custom_element.smash_targets] =
8016 custom_element_properties[EP_CAN_SMASH];
8018 /* set deadliness property from checkbox and selectbox */
8019 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
8020 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
8021 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
8022 custom_element_properties[EP_DONT_TOUCH] = FALSE;
8023 custom_element_properties[custom_element.deadliness] =
8024 custom_element_properties[EP_DEADLY];
8026 /* ---------- element settings: advanced (custom elements) --------------- */
8028 /* set player change event from checkbox and selectbox */
8029 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
8030 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
8031 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
8032 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
8033 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
8034 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
8035 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
8036 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
8037 custom_element_change_events[CE_SWITCHED] = FALSE;
8038 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
8039 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
8040 custom_element_change_events[CE_BLOCKED] = FALSE;
8041 custom_element_change_events[CE_IMPACT] = FALSE;
8042 custom_element_change_events[CE_SMASHED] = FALSE;
8043 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
8044 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
8045 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
8046 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
8047 custom_element_change_events[custom_element_change.direct_action] =
8048 custom_element_change_events[CE_BY_DIRECT_ACTION];
8050 /* set other element action change event from checkbox and selectbox */
8051 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
8052 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
8053 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
8054 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
8055 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
8056 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
8057 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
8058 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
8059 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
8060 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
8061 custom_element_change_events[CE_TOUCHING_X] = FALSE;
8062 custom_element_change_events[CE_HITTING_X] = FALSE;
8063 custom_element_change_events[CE_DIGGING_X] = FALSE;
8064 custom_element_change_events[CE_HIT_BY_X] = FALSE;
8065 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
8066 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
8067 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
8068 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
8069 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
8070 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
8071 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
8072 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
8073 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
8074 custom_element_change_events[custom_element_change.other_action] =
8075 custom_element_change_events[CE_BY_OTHER_ACTION];
8077 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8078 SET_PROPERTY(element, i, custom_element_properties[i]);
8080 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8081 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
8083 /* copy change events also to special level editor variable */
8084 custom_element = element_info[element];
8085 custom_element_change = *element_info[element].change;
8088 static void CopyGroupElementPropertiesToGame(int element)
8090 /* mark that this group element has been modified */
8091 custom_element.modified_settings = TRUE;
8092 level.changed = TRUE;
8094 if (level.use_custom_template)
8095 AskToCopyAndModifyLevelTemplate();
8097 element_info[element] = custom_element;
8098 *element_info[element].group = group_element_info;
8101 static void CopyClassicElementPropertiesToGame(int element)
8103 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
8104 setMoveIntoAcidProperty(&level, element,
8105 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
8107 if (MAYBE_DONT_COLLIDE_WITH(element))
8108 setDontCollideWithProperty(&level, element,
8109 custom_element_properties[EP_DONT_COLLIDE_WITH]);
8112 static void CopyElementPropertiesToGame(int element)
8114 if (IS_CUSTOM_ELEMENT(element))
8115 CopyCustomElementPropertiesToGame(element);
8116 else if (IS_GROUP_ELEMENT(element))
8117 CopyGroupElementPropertiesToGame(element);
8119 CopyClassicElementPropertiesToGame(element);
8122 void CheckElementDescriptions()
8126 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8127 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
8128 Error(ERR_WARN, "no element description file for element '%s'",
8132 static int getMaxEdFieldX(boolean has_scrollbar)
8134 int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
8135 int sxsize = SXSIZE - scrollbar_width;
8136 int max_ed_fieldx = sxsize / ed_tilesize;
8138 return max_ed_fieldx;
8141 static int getMaxEdFieldY(boolean has_scrollbar)
8143 int infotext_height = INFOTEXT_YSIZE_FULL;
8144 int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
8145 int sysize = SYSIZE - scrollbar_height - infotext_height;
8146 int max_ed_fieldy = sysize / ed_tilesize;
8148 return max_ed_fieldy;
8151 void InitZoomLevelSettings()
8153 MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
8154 MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
8159 int fade_mask = REDRAW_FIELD;
8161 FadeSoundsAndMusic();
8163 if (CheckIfGlobalBorderHasChanged())
8164 fade_mask = REDRAW_ALL;
8168 /* needed if different viewport properties defined for editor */
8169 ChangeViewportPropertiesIfNeeded();
8173 InitZoomLevelSettings();
8175 OpenDoor(DOOR_OPEN_1 | DOOR_OPEN_2 | DOOR_NO_DELAY);
8178 CheckElementDescriptions();
8181 if (level_editor_test_game)
8183 CopyPlayfield(level.field, Feld);
8184 CopyPlayfield(FieldBackup, level.field);
8186 level_editor_test_game = FALSE;
8190 edit_mode = ED_MODE_DRAWING;
8191 edit_mode_levelinfo = ED_MODE_LEVELINFO_LEVEL;
8192 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
8200 /* needed for gadgets drawn on background (like palette scrollbar) */
8201 SetDoorBackgroundImage(IMG_UNDEFINED);
8203 /* copy default editor door content to main double buffer */
8204 BlitBitmap(graphic_info[IMG_BACKGROUND_PALETTE].bitmap, drawto,
8205 graphic_info[IMG_BACKGROUND_PALETTE].src_x,
8206 graphic_info[IMG_BACKGROUND_PALETTE].src_y,
8207 MIN(DXSIZE, graphic_info[IMG_BACKGROUND_PALETTE].width),
8208 MIN(DYSIZE, graphic_info[IMG_BACKGROUND_PALETTE].height),
8211 /* draw bigger door */
8212 DrawSpecialEditorDoor();
8214 /* draw new control window */
8215 BlitBitmap(graphic_info[IMG_BACKGROUND_TOOLBOX].bitmap, drawto,
8216 graphic_info[IMG_BACKGROUND_TOOLBOX].src_x,
8217 graphic_info[IMG_BACKGROUND_TOOLBOX].src_y,
8218 MIN(EXSIZE, graphic_info[IMG_BACKGROUND_TOOLBOX].width),
8219 MIN(EYSIZE, graphic_info[IMG_BACKGROUND_TOOLBOX].height),
8222 // redraw_mask |= REDRAW_ALL;
8224 FreeLevelEditorGadgets();
8225 CreateLevelEditorGadgets();
8227 ReinitializeElementList(); /* update dynamic level element list */
8228 ReinitializeElementListButtons(); /* custom element may look different */
8230 InitElementPropertiesGfxElement();
8233 MapControlButtons();
8235 DrawEditModeWindow();
8237 DrawMaskedBorder(fade_mask);
8241 /* copy actual editor door content to door double buffer for OpenDoor() */
8242 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
8245 static void AdjustDrawingAreaGadgets()
8247 int ed_xsize = lev_fieldx + 2;
8248 int ed_ysize = lev_fieldy + 2;
8249 int max_ed_fieldx = MAX_ED_FIELDX;
8250 int max_ed_fieldy = MAX_ED_FIELDY;
8251 boolean horizontal_scrollbar_needed;
8252 boolean vertical_scrollbar_needed;
8253 int x, y, width, height;
8255 /* check if we need any scrollbars */
8256 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
8257 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
8259 /* check if we have a smaller editor field because of scrollbars */
8260 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
8261 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
8263 /* check again if we now need more scrollbars because of less space */
8264 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
8265 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
8267 /* check if editor field gets even smaller after adding new scrollbars */
8268 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
8269 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
8271 ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
8272 ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
8274 x = SX + ed_fieldx * ed_tilesize;
8275 y = SY + ed_fieldy * ed_tilesize;
8277 width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
8278 height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
8280 /* adjust drawing area gadget */
8281 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
8282 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
8283 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
8286 /* adjust horizontal scrollbar gadgets */
8287 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
8290 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
8291 GDI_X, x - ED_SCROLLBUTTON_XSIZE,
8294 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
8297 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
8300 /* adjust vertical scrollbar gadgets */
8301 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
8304 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
8306 GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
8308 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
8311 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
8315 static void AdjustLevelScrollPosition()
8317 if (level_xpos < -1)
8319 if (level_xpos > lev_fieldx - ed_fieldx + 1)
8320 level_xpos = lev_fieldx - ed_fieldx + 1;
8321 if (lev_fieldx < ed_fieldx - 2)
8324 if (level_ypos < -1)
8326 if (level_ypos > lev_fieldy - ed_fieldy + 1)
8327 level_ypos = lev_fieldy - ed_fieldy + 1;
8328 if (lev_fieldy < ed_fieldy - 2)
8332 static void AdjustEditorScrollbar(int id)
8334 struct GadgetInfo *gi = level_editor_gadget[id];
8335 int items_max, items_visible, item_position;
8337 if (id == GADGET_ID_SCROLL_HORIZONTAL)
8339 items_max = MAX(lev_fieldx + 2, ed_fieldx);
8340 items_visible = ed_fieldx;
8341 item_position = level_xpos + 1;
8345 items_max = MAX(lev_fieldy + 2, ed_fieldy);
8346 items_visible = ed_fieldy;
8347 item_position = level_ypos + 1;
8350 if (item_position > items_max - items_visible)
8351 item_position = items_max - items_visible;
8353 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
8354 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
8357 static void AdjustElementListScrollbar()
8359 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
8360 int items_max, items_visible, item_position;
8362 /* correct position of element list scrollbar */
8363 if (element_shift < 0)
8365 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
8366 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
8368 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
8369 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
8370 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
8372 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
8373 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
8374 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
8377 static void ModifyEditorCounterValue(int counter_id, int new_value)
8379 int *counter_value = counterbutton_info[counter_id].value;
8380 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
8381 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8383 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
8385 if (counter_value != NULL)
8386 *counter_value = gi->textinput.number_value;
8389 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
8391 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
8392 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8394 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
8396 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
8397 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
8399 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
8400 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
8402 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
8403 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_SMALL_DISTANCE,
8408 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
8410 int gadget_id = selectbox_info[selectbox_id].gadget_id;
8411 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8412 int new_index_value = setSelectboxValue(selectbox_id, new_value);
8414 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
8417 static void ModifyEditorSelectboxOptions(int selectbox_id,
8418 struct ValueTextInfo *options)
8420 int gadget_id = selectbox_info[selectbox_id].gadget_id;
8421 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8423 selectbox_info[selectbox_id].options = options;
8425 /* set index to zero -- list may be shorter now (correct later, if needed) */
8426 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
8427 GDI_SELECTBOX_OPTIONS, options, GDI_END);
8430 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
8432 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
8433 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8435 drawingarea_info[drawingarea_id].area_xsize = xsize;
8436 drawingarea_info[drawingarea_id].area_ysize = ysize;
8438 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
8441 static void ModifyEditorElementList()
8445 if (!use_permanent_palette && edit_mode != ED_MODE_PALETTE)
8448 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
8450 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
8451 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8452 struct GadgetDesign *gd = &gi->deco.design;
8453 int element = editor_elements[element_shift + i];
8454 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
8458 getEditorGraphicSource(element, tile_size, &gd->bitmap, &gd->x, &gd->y);
8460 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
8466 static void DrawDrawingElementGraphic(int element, struct XYTileSize *pos)
8468 int graphic = el2edimg(element);
8469 int tile_size = BUTTON_TILE_SIZE(pos->tile_size);
8475 DrawSizedGraphicExt(drawto, DX + pos->x, DY + pos->y, graphic, 0, tile_size);
8478 static void ModifyDrawingElementButton(int element, int id)
8480 struct GadgetInfo *gi = level_editor_gadget[id];
8481 Bitmap *deco_bitmap;
8483 int tile_size = gi->deco.width;
8485 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
8487 ModifyGadget(gi, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_END);
8490 static void PickDrawingElement(int button, int element)
8495 struct XYTileSize *pos;
8497 } de, drawing_elements[] =
8499 { &new_element1, &editor.palette.element_left, GADGET_ID_ELEMENT_LEFT },
8500 { &new_element2, &editor.palette.element_middle, GADGET_ID_ELEMENT_MIDDLE },
8501 { &new_element3, &editor.palette.element_right, GADGET_ID_ELEMENT_RIGHT },
8504 if (button < 1 || button > 3)
8507 if (IS_MM_WALL(element))
8508 element = map_mm_wall_element(element);
8510 de = drawing_elements[button - 1];
8512 *de.new_element = element; // update global drawing element variable
8514 DrawDrawingElementGraphic(element, de.pos);
8515 ModifyDrawingElementButton(element, de.id);
8517 redraw_mask |= REDRAW_DOOR_1;
8520 static void RedrawDrawingElements()
8522 PickDrawingElement(1, new_element1);
8523 PickDrawingElement(2, new_element2);
8524 PickDrawingElement(3, new_element3);
8527 static void DrawDrawingWindow()
8529 stick_element_properties_window = FALSE;
8531 SetMainBackgroundImage(IMG_UNDEFINED);
8534 UnmapLevelEditorFieldGadgets();
8535 UnmapLevelEditorToolboxCustomGadgets();
8537 AdjustDrawingAreaGadgets();
8538 AdjustLevelScrollPosition();
8539 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
8540 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
8542 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8544 MapMainDrawingArea();
8545 MapLevelEditorToolboxDrawingGadgets();
8548 static int getTabulatorBarWidth()
8550 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
8551 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
8553 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
8556 static int getTabulatorBarHeight()
8558 return ED_TAB_BAR_HEIGHT;
8561 static void DrawLevelInfoTabulatorGadgets()
8563 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELINFO_LEVEL];
8564 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
8565 int gd_x = gd->x + gd_gi1->border.width / 2;
8566 int gd_y = gd->y + gd_gi1->height - 1;
8567 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
8568 int id_first = ED_TAB_BUTTON_ID_LEVELINFO_FIRST;
8569 int id_last = ED_TAB_BUTTON_ID_LEVELINFO_LAST;
8572 for (i = id_first; i <= id_last; i++)
8574 int gadget_id = textbutton_info[i].gadget_id;
8575 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8576 boolean active = (i != edit_mode_levelinfo);
8578 /* draw background line below tabulator button */
8579 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
8581 /* draw solid line below inactive tabulator buttons */
8582 if (!active && tab_color != BLACK_PIXEL) /* black => transparent */
8583 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
8584 ED_GADGET_TINY_DISTANCE, tab_color);
8586 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
8587 MapTextbuttonGadget(i);
8590 /* draw little border line below tabulator buttons */
8591 if (tab_color != BLACK_PIXEL) /* black => transparent */
8592 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
8593 ED_GADGET_TINY_DISTANCE,
8594 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
8597 static void DrawPropertiesTabulatorGadgets()
8599 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
8600 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
8601 int gd_x = gd->x + gd_gi1->border.width / 2;
8602 int gd_y = gd->y + gd_gi1->height - 1;
8603 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
8604 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
8605 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
8608 /* draw two config tabulators for player elements */
8609 if (ELEM_IS_PLAYER(properties_element))
8610 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
8612 /* draw two config and one "change" tabulator for custom elements */
8613 if (IS_CUSTOM_ELEMENT(properties_element))
8614 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
8616 for (i = id_first; i <= id_last; i++)
8618 int gadget_id = textbutton_info[i].gadget_id;
8619 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8620 boolean active = (i != edit_mode_properties);
8622 /* use "config 1" and "config 2" instead of "config" for players and CEs */
8623 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
8624 (ELEM_IS_PLAYER(properties_element) ||
8625 IS_CUSTOM_ELEMENT(properties_element)))
8628 /* draw background line below tabulator button */
8629 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
8631 /* draw solid line below inactive tabulator buttons */
8632 if (!active && tab_color != BLACK_PIXEL) /* black => transparent */
8633 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
8634 ED_GADGET_TINY_DISTANCE, tab_color);
8636 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
8637 MapTextbuttonGadget(i);
8640 /* draw little border line below tabulator buttons */
8641 if (tab_color != BLACK_PIXEL) /* black => transparent */
8642 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
8643 ED_GADGET_TINY_DISTANCE,
8644 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
8647 static void DrawLevelInfoLevel()
8651 /* draw counter gadgets */
8652 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
8653 MapCounterButtons(i);
8655 /* draw checkbutton gadgets */
8656 for (i = ED_CHECKBUTTON_ID_LEVEL_FIRST; i<= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
8657 MapCheckbuttonGadget(i);
8659 /* draw selectbox gadgets */
8660 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
8661 MapSelectboxGadget(i);
8663 /* draw text input gadgets */
8664 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
8665 MapTextInputGadget(i);
8668 static void DrawLevelInfoEditor()
8672 /* draw counter gadgets */
8673 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
8674 MapCounterButtons(i);
8676 /* draw checkbutton gadgets */
8677 for (i=ED_CHECKBUTTON_ID_EDITOR_FIRST; i<= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
8678 MapCheckbuttonGadget(i);
8680 /* draw radiobutton gadgets */
8681 for (i=ED_RADIOBUTTON_ID_EDITOR_FIRST; i<= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
8682 MapRadiobuttonGadget(i);
8684 /* draw drawing area */
8685 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
8687 /* draw textbutton gadgets */
8688 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2);
8691 static void DrawLevelInfoWindow()
8693 char *text = "Global Settings";
8694 int font_nr = FONT_TITLE_1;
8695 struct MenuPosInfo *pos = &editor.settings.headline;
8696 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font_nr), pos->align);
8697 int sy = SY + pos->y;
8699 stick_element_properties_window = FALSE;
8701 SetAutomaticNumberOfGemsNeeded();
8703 UnmapLevelEditorFieldGadgets();
8705 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
8708 DrawText(sx, sy, text, font_nr);
8710 DrawLevelInfoTabulatorGadgets();
8712 if (edit_mode_levelinfo == ED_MODE_LEVELINFO_LEVEL)
8713 DrawLevelInfoLevel();
8714 else /* (edit_mode_levelinfo == ED_MODE_LEVELINFO_EDITOR) */
8715 DrawLevelInfoEditor();
8718 static void DrawCustomContentArea()
8720 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
8721 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
8722 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
8723 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
8724 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
8725 int xoffset = ED_GADGET_SPACE_DISTANCE;
8727 /* add distance for potential left text (without drawing area border) */
8728 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
8730 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
8732 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
8735 static void DrawCustomChangeContentArea()
8737 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
8738 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
8739 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
8740 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
8741 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
8742 int xoffset = ED_GADGET_SPACE_DISTANCE;
8744 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
8749 static void RemoveElementContentArea(int id, int font_height)
8751 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
8753 DrawBackground(SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size,
8754 SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size,
8755 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
8756 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size +
8757 ED_GADGET_TEXT_DISTANCE + font_height);
8760 static void DrawYamYamContentAreas()
8762 int font_nr = FONT_TEXT_1;
8763 int font_height = getFontHeight(font_nr);
8764 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
8765 int yoffset = (tilesize - font_height) / 2;
8766 int x = SX + ED_AREA_YAMYAM_CONTENT_X(3) + 4 * tilesize;
8767 int y = SY + ED_AREA_YAMYAM_CONTENT_Y(3) + yoffset;
8770 /* display counter to choose number of element content areas */
8771 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
8773 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
8775 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
8777 if (i < level.num_yamyam_contents)
8783 UnmapDrawingArea(id);
8785 /* delete content areas in case of reducing number of them */
8786 RemoveElementContentArea(id, font_height);
8790 DrawText(x, y + 0 * tilesize, "content", font_nr);
8791 DrawText(x, y + 1 * tilesize, "when", font_nr);
8792 DrawText(x, y + 2 * tilesize, "smashed", font_nr);
8795 static void DrawMagicBallContentAreas()
8797 int font_nr = FONT_TEXT_1;
8798 int font_height = getFontHeight(font_nr);
8799 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
8800 int yoffset = (tilesize - font_height) / 2;
8801 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_X(3) + 4 * tilesize;
8802 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_Y(3) + yoffset;
8805 /* display counter to choose number of element content areas */
8806 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
8808 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
8810 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
8812 if (i < level.num_ball_contents)
8818 UnmapDrawingArea(id);
8820 /* delete content areas in case of reducing number of them */
8821 RemoveElementContentArea(id, font_height);
8825 DrawText(x, y + 0 * tilesize, "generated", font_nr);
8826 DrawText(x, y + 1 * tilesize, "when", font_nr);
8827 DrawText(x, y + 2 * tilesize, "active", font_nr);
8830 static void DrawAndroidElementArea(int element)
8832 int id = ED_DRAWING_ID_ANDROID_CONTENT;
8833 int num_elements = level.num_android_clone_elements;
8834 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
8835 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
8836 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
8837 int xsize = MAX_ANDROID_ELEMENTS;
8840 /* display counter to choose number of element areas */
8841 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
8843 if (drawingarea_info[id].text_left != NULL)
8844 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
8846 UnmapDrawingArea(id);
8848 ModifyEditorDrawingArea(id, num_elements, 1);
8850 /* delete content areas in case of reducing number of them */
8851 DrawBackground(sx, sy,
8852 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
8853 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
8858 static void DrawGroupElementArea(int element)
8860 int id = ED_DRAWING_ID_GROUP_CONTENT;
8861 int num_elements = group_element_info.num_elements;
8862 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
8863 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
8864 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
8865 int xsize = MAX_ELEMENTS_IN_GROUP;
8868 if (drawingarea_info[id].text_left != NULL)
8869 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
8871 UnmapDrawingArea(id);
8873 ModifyEditorDrawingArea(id, num_elements, 1);
8875 /* delete content areas in case of reducing number of them */
8876 DrawBackground(sx, sy,
8877 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
8878 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
8883 static void DrawPlayerInitialInventoryArea(int element)
8885 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
8886 int player_nr = GET_PLAYER_NR(element);
8887 int num_elements = level.initial_inventory_size[player_nr];
8888 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
8889 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
8890 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
8891 int xsize = MAX_INITIAL_INVENTORY_SIZE;
8894 /* determine horizontal position to the right of specified gadget */
8895 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
8896 sx = (right_gadget_border[drawingarea_info[id].gadget_id_align] +
8897 ED_DRAWINGAREA_TEXT_DISTANCE);
8899 /* determine horizontal offset for leading text */
8900 if (drawingarea_info[id].text_left != NULL)
8901 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
8903 UnmapDrawingArea(id);
8905 ModifyEditorDrawingArea(id, num_elements, 1);
8907 /* delete content areas in case of reducing number of them */
8908 DrawBackground(sx, sy,
8909 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
8910 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
8915 static void DrawEnvelopeTextArea(int envelope_nr)
8917 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
8918 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
8921 DrawBackground(gi->x, gi->y, gi->width, gi->height);
8923 if (envelope_nr != -1)
8924 textarea_info[id].value = level.envelope[envelope_nr].text;
8926 ModifyGadget(gi, GDI_AREA_SIZE,
8927 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
8928 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
8931 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
8934 static void PrintInfoText(char *text, int font_nr, int xpos, int ypos)
8936 DrawText(SX + xpos, SY + ypos, text, font_nr);
8939 static int PrintElementDescriptionFromFile(char *filename, int font_nr,
8942 int font_width = getFontWidth(font_nr);
8943 int font_height = getFontHeight(font_nr);
8944 int max_chars_per_line = (SXSIZE - 2 * xpos) / font_width;
8945 int max_lines_drawable = (SYSIZE - ypos) / font_height - 1;
8947 return DrawTextFile(SX + xpos, SY + ypos, filename, font_nr,
8948 max_chars_per_line, -1, max_lines_drawable, 0, -1,
8949 TRUE, FALSE, FALSE);
8952 static void DrawPropertiesInfo()
8961 /* configurable properties */
8963 { EP_WALKABLE_OVER, "- player can walk over it" },
8964 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
8965 { EP_WALKABLE_UNDER, "- player can walk under it" },
8966 { EP_PASSABLE_OVER, "- player can pass over it" },
8967 { EP_PASSABLE_INSIDE, "- player can pass through it" },
8968 { EP_PASSABLE_UNDER, "- player can pass under it" },
8969 { EP_PROTECTED, "- player is protected by it" },
8971 { EP_DIGGABLE, "- can be digged away" },
8972 { EP_COLLECTIBLE, "- can be collected" },
8973 { EP_DROPPABLE, "- can be dropped after collecting" },
8974 { EP_THROWABLE, "- can be thrown after collecting" },
8975 { EP_PUSHABLE, "- can be pushed" },
8977 { EP_CAN_FALL, "- can fall" },
8978 { EP_CAN_MOVE, "- can move" },
8980 { EP_CAN_SMASH_PLAYER, "- can smash player" },
8982 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
8984 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
8986 { EP_SLIPPERY, "- slippery for falling elements" },
8987 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
8989 { EP_DONT_RUN_INTO, "- deadly when running into" },
8990 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
8991 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
8992 { EP_DONT_TOUCH, "- deadly when touching" },
8994 { EP_INDESTRUCTIBLE, "- indestructible" },
8996 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
8997 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
8998 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
9000 { EP_CAN_CHANGE, "- can change to other element" },
9002 /* pre-defined properties */
9003 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
9004 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
9005 { EP_SWITCHABLE, "- can be switched" },
9007 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
9012 char *filename = getElementDescriptionFilename(properties_element);
9013 char *percentage_text = "In this level: ";
9014 char *properties_text = "Standard properties: ";
9015 char *description_text = "Description:";
9016 char *no_description_text = "No description available.";
9017 char *none_text = "None";
9019 int num_elements_in_level;
9020 int num_standard_properties = 0;
9021 int font1_nr = FONT_TEXT_1;
9022 int font2_nr = FONT_TEXT_2;
9023 int font1_width = getFontWidth(font1_nr);
9024 int font1_height = getFontHeight(font1_nr);
9025 int font2_height = getFontHeight(font2_nr);
9026 int line1_height = font1_height + ED_GADGET_LINE_DISTANCE;
9027 int font2_yoffset = (font1_height - font2_height) / 2;
9028 int percentage_text_len = strlen(percentage_text) * font1_width;
9029 int properties_text_len = strlen(properties_text) * font1_width;
9030 int xpos = ED_ELEMENT_SETTINGS_X(0);
9031 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
9034 if (setup.editor.show_element_token)
9036 int font3_nr = FONT_TEXT_3;
9037 int font3_height = getFontHeight(font3_nr);
9039 DrawTextF(xpos, ypos, font3_nr,
9040 "[%s]", element_info[properties_element].token_name);
9042 ypos += 2 * font3_height;
9045 /* ----- print number of elements / percentage of this element in level */
9047 num_elements_in_level = 0;
9048 for (y = 0; y < lev_fieldy; y++)
9049 for (x = 0; x < lev_fieldx; x++)
9050 if (Feld[x][y] == properties_element)
9051 num_elements_in_level++;
9052 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
9054 DrawTextS(xpos, ypos, font1_nr, percentage_text);
9056 if (num_elements_in_level > 0)
9057 DrawTextF(xpos + percentage_text_len, ypos + font2_yoffset, font2_nr,
9058 "%d (%.2f %%)", num_elements_in_level, percentage);
9060 DrawTextF(xpos + percentage_text_len, ypos + font2_yoffset, font2_nr,
9063 ypos += 2 * MAX(font1_height, font2_height);
9065 /* ----- print standard properties of this element */
9067 DrawTextS(xpos, ypos, font1_nr, properties_text);
9069 ypos += line1_height;
9071 for (i = 0; properties[i].value != -1; i++)
9073 if (!HAS_PROPERTY(properties_element, properties[i].value))
9076 DrawTextS(xpos, ypos, font2_nr, properties[i].text);
9078 ypos += font2_height;
9080 num_standard_properties++;
9083 if (num_standard_properties == 0)
9085 DrawTextS(xpos + properties_text_len, ypos - line1_height + font2_yoffset,
9086 font2_nr, none_text);
9088 ypos -= (line1_height - font1_height);
9091 ypos += MAX(font1_height, font2_height);
9093 /* ----- print special description of this element */
9095 PrintInfoText(description_text, font1_nr, xpos, ypos);
9097 ypos += line1_height;
9099 if (PrintElementDescriptionFromFile(filename, font2_nr, xpos, ypos) == 0)
9100 PrintInfoText(no_description_text, font1_nr, xpos, ypos - line1_height);
9103 #define TEXT_COLLECTING "Score for collecting"
9104 #define TEXT_SMASHING "Score for smashing"
9105 #define TEXT_SLURPING "Score for slurping robot"
9106 #define TEXT_CRACKING "Score for cracking"
9107 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
9108 #define TEXT_DURATION "Duration when activated"
9109 #define TEXT_BALL_DELAY "Element generation delay"
9110 #define TEXT_MOVE_SPEED "Speed of android moving"
9111 #define TEXT_CLONE_SPEED "Speed of android cloning"
9112 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
9113 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
9114 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
9115 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
9116 #define TEXT_TIME_BONUS "Extra time to solve level"
9123 } elements_with_counter[] =
9125 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
9126 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
9127 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
9128 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
9129 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
9130 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
9131 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
9132 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
9133 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
9134 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
9135 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
9136 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
9137 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
9138 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
9139 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
9140 { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
9141 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
9142 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
9143 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
9144 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
9145 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9146 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9147 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9148 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9149 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9150 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9151 { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
9152 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9153 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9154 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9155 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9156 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
9157 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
9158 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
9159 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
9160 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
9161 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
9162 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
9163 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
9164 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
9165 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
9166 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
9167 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
9168 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
9169 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
9170 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
9171 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE],TEXT_COLLECTING },
9172 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
9173 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
9174 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
9175 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
9176 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
9177 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
9178 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
9179 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
9180 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
9181 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
9182 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
9183 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
9184 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
9185 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
9186 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
9187 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
9188 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
9189 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
9190 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9191 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9192 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9193 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9194 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9195 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9196 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9197 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9198 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
9200 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
9201 { EL_DC_TIMEGATE_SWITCH,&level.time_timegate, TEXT_DURATION },
9202 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
9203 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
9204 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
9205 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
9206 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
9207 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
9208 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
9209 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
9210 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
9211 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
9212 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
9213 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
9214 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
9215 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
9217 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
9218 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
9219 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
9220 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
9221 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
9222 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
9223 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
9224 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
9226 /* defined, but currently not used in MM engine */
9227 { EL_MM_FUSE_ACTIVE, &level.mm_time_fuse, TEXT_DURATION },
9233 static boolean checkPropertiesConfig(int element)
9237 if (IS_GEM(element) ||
9238 IS_CUSTOM_ELEMENT(element) ||
9239 IS_GROUP_ELEMENT(element) ||
9240 IS_ENVELOPE(element) ||
9241 IS_MM_MCDUFFIN(element) ||
9242 IS_DF_LASER(element) ||
9243 ELEM_IS_PLAYER(element) ||
9244 HAS_EDITOR_CONTENT(element) ||
9245 CAN_GROW(element) ||
9246 COULD_MOVE_INTO_ACID(element) ||
9247 MAYBE_DONT_COLLIDE_WITH(element) ||
9248 element == EL_SOKOBAN_OBJECT ||
9249 element == EL_SOKOBAN_FIELD_EMPTY ||
9250 element == EL_SOKOBAN_FIELD_FULL)
9253 for (i = 0; elements_with_counter[i].element != -1; i++)
9254 if (elements_with_counter[i].element == element)
9260 static void SetAutomaticNumberOfGemsNeeded()
9264 if (!level.auto_count_gems)
9267 level.gems_needed = 0;
9269 for (x = 0; x < lev_fieldx; x++)
9271 for (y = 0; y < lev_fieldy; y++)
9273 int element = Feld[x][y];
9275 if (IS_GEM(element) ||
9276 element == EL_MM_KETTLE ||
9277 element == EL_DF_CELL)
9278 level.gems_needed++;
9282 ModifyEditorCounterValue(ED_COUNTER_ID_LEVEL_GEMSLIMIT, level.gems_needed);
9285 static void DrawPropertiesConfig()
9287 boolean draw_footer_line = FALSE;
9288 int max_num_element_counters = 4;
9289 int num_element_counters = 0;
9292 if (!checkPropertiesConfig(properties_element))
9294 int xpos = ED_ELEMENT_SETTINGS_X(0);
9295 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
9297 PrintInfoText("No configuration options available.",
9298 FONT_TEXT_1, xpos, ypos);
9303 /* check if there are elements where a value can be chosen for */
9304 for (i = 0; elements_with_counter[i].element != -1; i++)
9306 if (elements_with_counter[i].element == properties_element)
9308 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
9310 counterbutton_info[counter_id].y =
9311 ED_ELEMENT_SETTINGS_YPOS(
9312 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
9313 (CAN_GROW(properties_element) ? 1 : 0) +
9314 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
9315 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
9316 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
9317 num_element_counters);
9319 counterbutton_info[counter_id].value = elements_with_counter[i].value;
9320 counterbutton_info[counter_id].text_right= elements_with_counter[i].text;
9322 if (properties_element == EL_GAME_OF_LIFE ||
9323 properties_element == EL_BIOMAZE)
9325 counterbutton_info[counter_id].min_value = 0; /* min neighbours */
9326 counterbutton_info[counter_id].max_value = 8; /* max neighbours */
9330 /* !!! CHANGE THIS FOR CERTAIN ELEMENTS !!! */
9331 counterbutton_info[counter_id].min_value = MIN_SCORE;
9332 counterbutton_info[counter_id].max_value = MAX_SCORE;
9335 MapCounterButtons(counter_id);
9337 num_element_counters++;
9338 if (num_element_counters >= max_num_element_counters)
9343 if (HAS_EDITOR_CONTENT(properties_element))
9345 /* draw stickybutton gadget */
9346 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
9348 if (IS_AMOEBOID(properties_element))
9349 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
9350 else if (properties_element == EL_YAMYAM ||
9351 properties_element == EL_YAMYAM_LEFT ||
9352 properties_element == EL_YAMYAM_RIGHT ||
9353 properties_element == EL_YAMYAM_UP ||
9354 properties_element == EL_YAMYAM_DOWN)
9355 DrawYamYamContentAreas();
9356 else if (properties_element == EL_EMC_MAGIC_BALL)
9358 DrawMagicBallContentAreas();
9360 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
9361 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_STATE);
9363 else if (properties_element == EL_EMC_ANDROID)
9364 DrawAndroidElementArea(properties_element);
9367 if (ELEM_IS_PLAYER(properties_element))
9369 int player_nr = GET_PLAYER_NR(properties_element);
9371 /* these properties can be set for every player individually */
9373 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
9375 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
9376 &level.start_element[player_nr];
9377 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
9378 &level.artwork_element[player_nr];
9379 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
9380 &level.explosion_element[player_nr];
9382 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
9383 &level.use_start_element[player_nr];
9384 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
9385 &level.use_artwork_element[player_nr];
9386 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
9387 &level.use_explosion_element[player_nr];
9388 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
9389 &level.initial_player_gravity[player_nr];
9391 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
9392 &level.initial_player_stepsize[player_nr];
9394 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
9395 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
9396 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
9397 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
9398 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
9399 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
9400 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
9401 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
9402 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_LAZY_RELOCATION);
9403 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
9404 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
9405 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
9406 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
9407 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
9409 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
9410 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
9411 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
9413 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
9415 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
9417 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
9418 &level.initial_inventory_content[player_nr][0];
9420 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
9421 &level.initial_inventory_size[player_nr];
9423 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
9424 &level.use_initial_inventory[player_nr];
9426 /* draw checkbutton gadgets */
9427 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
9429 /* draw counter gadgets */
9430 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
9432 /* draw drawing area gadgets */
9433 DrawPlayerInitialInventoryArea(properties_element);
9437 if (IS_GEM(properties_element))
9438 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
9440 if (properties_element == EL_EM_DYNAMITE)
9441 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
9443 if (COULD_MOVE_INTO_ACID(properties_element) &&
9444 !ELEM_IS_PLAYER(properties_element) &&
9445 (!IS_CUSTOM_ELEMENT(properties_element) ||
9446 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
9448 /* set position for checkbutton for "can move into acid" */
9449 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
9450 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
9451 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
9452 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 6 :
9453 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
9455 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
9458 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
9459 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
9461 if (properties_element == EL_SPRING)
9462 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
9464 if (properties_element == EL_TIME_ORB_FULL)
9465 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
9467 if (CAN_GROW(properties_element))
9469 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
9470 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
9472 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
9475 if (properties_element == EL_SOKOBAN_OBJECT ||
9476 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
9477 properties_element == EL_SOKOBAN_FIELD_FULL)
9478 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
9480 if (IS_ENVELOPE(properties_element))
9482 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
9483 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
9484 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
9485 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
9486 int envelope_nr = properties_element - EL_ENVELOPE_1;
9488 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
9489 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
9491 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
9492 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
9494 /* display counter to choose size of envelope text area */
9495 MapCounterButtons(counter1_id);
9496 MapCounterButtons(counter2_id);
9498 /* display checkbuttons to choose auto-wrap and alignment properties */
9499 MapCheckbuttonGadget(button1_id);
9500 MapCheckbuttonGadget(button2_id);
9502 DrawEnvelopeTextArea(envelope_nr);
9505 if (IS_MM_MCDUFFIN(properties_element))
9507 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_RED);
9508 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_GREEN);
9509 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_BLUE);
9512 if (IS_DF_LASER(properties_element))
9514 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_RED);
9515 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_GREEN);
9516 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_BLUE);
9519 if (IS_CUSTOM_ELEMENT(properties_element))
9521 /* draw stickybutton gadget */
9522 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
9524 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
9526 /* draw checkbutton gadgets */
9527 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
9528 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
9529 MapCheckbuttonGadget(i);
9531 /* draw counter gadgets */
9532 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
9533 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
9534 MapCounterButtons(i);
9536 /* draw selectbox gadgets */
9537 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
9538 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
9539 MapSelectboxGadget(i);
9541 /* draw textbutton gadgets */
9542 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
9544 /* draw text input gadgets */
9545 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
9547 /* draw drawing area gadgets */
9548 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
9550 draw_footer_line = TRUE;
9552 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
9554 /* draw checkbutton gadgets */
9555 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
9556 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
9557 MapCheckbuttonGadget(i);
9559 /* draw counter gadgets */
9560 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
9561 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
9562 MapCounterButtons(i);
9564 /* draw selectbox gadgets */
9565 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
9566 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
9567 MapSelectboxGadget(i);
9569 /* draw drawing area gadgets */
9570 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
9571 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
9572 DrawCustomContentArea();
9575 else if (IS_GROUP_ELEMENT(properties_element))
9577 /* draw stickybutton gadget */
9578 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
9580 /* draw checkbutton gadgets */
9581 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
9582 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
9584 /* draw counter gadgets */
9585 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
9587 /* draw selectbox gadgets */
9588 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
9590 /* draw textbutton gadgets */
9591 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
9593 /* draw drawing area gadgets */
9594 DrawGroupElementArea(properties_element);
9596 /* draw text input gadgets */
9597 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
9599 /* draw drawing area gadgets */
9600 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
9602 draw_footer_line = TRUE;
9605 /* draw little footer border line above CE/GE use/save template gadgets */
9606 if (draw_footer_line)
9608 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9609 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9610 int gd_x = gd->x + gd_gi1->border.width / 2;
9611 int gd_y = gd->y + gd_gi1->height - 1;
9612 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
9614 if (tab_color != BLACK_PIXEL) /* black => transparent */
9615 FillRectangle(drawto,
9616 SX + ED_ELEMENT_SETTINGS_X(0),
9617 SY + ED_ELEMENT_SETTINGS_Y(14) - ED_SETTINGS_TABS_YOFFSET -
9619 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9623 static void DrawPropertiesChangeDrawingAreas()
9625 if (IS_CUSTOM_ELEMENT(properties_element))
9627 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
9628 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
9629 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
9631 DrawCustomChangeContentArea();
9634 redraw_mask |= REDRAW_FIELD;
9637 static void DrawPropertiesChange()
9641 /* needed to initially set selectbox options for special action options */
9642 setSelectboxSpecialActionOptions();
9644 /* draw stickybutton gadget */
9645 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
9647 /* draw checkbutton gadgets */
9648 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
9649 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
9650 MapCheckbuttonGadget(i);
9652 /* draw counter gadgets */
9653 for (i = ED_COUNTER_ID_CHANGE_FIRST;
9654 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
9655 MapCounterButtons(i);
9657 /* draw selectbox gadgets */
9658 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
9659 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
9660 MapSelectboxGadget(i);
9662 /* draw textbutton gadgets */
9663 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
9664 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
9665 MapTextbuttonGadget(i);
9667 /* draw graphicbutton gadgets */
9668 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
9669 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
9670 MapGraphicbuttonGadget(i);
9672 /* draw drawing area gadgets */
9673 DrawPropertiesChangeDrawingAreas();
9676 static void DrawEditorElementAnimation(int x, int y)
9678 int graphic = el2img(properties_element);
9679 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
9680 custom_element.ce_value_fixed_initial :
9681 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
9682 custom_element.collect_score_initial : FrameCounter);
9684 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
9687 static void DrawEditorElementName(int x, int y, int font_nr)
9689 char *element_name = getElementInfoText(properties_element);
9690 int font_width = getFontWidth(font_nr);
9691 int font_height = getFontHeight(font_nr);
9692 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
9693 int max_chars_per_line = max_text_width / font_width;
9694 char buffer[max_chars_per_line + 1];
9696 if (strlen(element_name) <= max_chars_per_line)
9697 DrawTextS(x, y, font_nr, element_name);
9700 int next_pos = max_chars_per_line;
9702 strncpy(buffer, element_name, max_chars_per_line);
9703 buffer[max_chars_per_line] = '\0';
9705 if (element_name[max_chars_per_line] == ' ')
9711 for (i = max_chars_per_line - 1; i >= 0; i--)
9712 if (buffer[i] == ' ')
9715 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
9722 DrawTextS(x, y - font_height / 2, font_nr, buffer);
9724 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
9725 buffer[max_chars_per_line] = '\0';
9727 DrawTextS(x, y + font_height / 2, font_nr, buffer);
9731 static void DrawPropertiesWindow()
9733 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
9734 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
9735 int border_size = gd->border_size;
9736 int font_nr = FONT_TEXT_1;
9737 int font_height = getFontHeight(font_nr);
9738 int xoffset = TILEX + element_border + 3 * border_size;
9739 int yoffset = (TILEY - font_height) / 2;
9740 int x1 = editor.settings.element_graphic.x + element_border;
9741 int y1 = editor.settings.element_graphic.y + element_border;
9742 int x2 = (editor.settings.element_name.x == -1 ? x1 + xoffset :
9743 editor.settings.element_name.x);
9744 int y2 = (editor.settings.element_name.y == -1 ? y1 + yoffset :
9745 editor.settings.element_name.y);
9746 char *text = "Element Settings";
9747 int font2_nr = FONT_TITLE_1;
9748 struct MenuPosInfo *pos = &editor.settings.headline;
9749 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font2_nr), pos->align);
9750 int sy = SY + pos->y;
9752 stick_element_properties_window = FALSE;
9754 /* make sure that previous properties edit mode exists for this element */
9755 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
9756 !IS_CUSTOM_ELEMENT(properties_element))
9757 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
9759 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
9760 !ELEM_IS_PLAYER(properties_element) &&
9761 !IS_CUSTOM_ELEMENT(properties_element))
9762 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
9764 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
9765 (ELEM_IS_PLAYER(properties_element) ||
9766 IS_CUSTOM_ELEMENT(properties_element)))
9767 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
9769 CopyElementPropertiesToEditor(properties_element);
9771 UnmapLevelEditorFieldGadgets();
9772 UnmapLevelEditorToolboxDrawingGadgets();
9773 UnmapLevelEditorToolboxCustomGadgets();
9775 if (IS_CUSTOM_ELEMENT(properties_element) ||
9776 IS_GROUP_ELEMENT(properties_element))
9777 MapLevelEditorToolboxCustomGadgets();
9779 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
9782 DrawText(sx, sy, text, font2_nr);
9784 FrameCounter = 0; /* restart animation frame counter */
9786 DrawElementBorder(SX + x1, SY + y1, TILEX, TILEY, FALSE);
9787 DrawEditorElementAnimation(SX + x1, SY + y1);
9788 DrawEditorElementName(x2, y2, font_nr);
9790 DrawPropertiesTabulatorGadgets();
9792 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
9793 DrawPropertiesInfo();
9794 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
9795 DrawPropertiesChange();
9796 else /* (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2]) */
9797 DrawPropertiesConfig();
9800 static void DrawPaletteWindow()
9804 UnmapLevelEditorFieldGadgets();
9806 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
9809 /* map buttons to select elements */
9810 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
9811 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
9812 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
9813 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
9814 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
9817 static void UpdateCustomElementGraphicGadgets()
9821 InitElementPropertiesGfxElement();
9823 ModifyEditorElementList();
9824 RedrawDrawingElements();
9826 /* force redraw of all mapped drawing area gadgets */
9827 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
9829 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
9836 static int getOpenDirectionFromTube(int element)
9840 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
9841 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
9842 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
9843 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
9844 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
9845 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
9846 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
9847 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
9848 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
9849 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
9850 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
9856 static int getTubeFromOpenDirection(int direction)
9860 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
9861 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
9862 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
9863 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
9864 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
9865 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
9866 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
9867 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
9868 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
9869 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
9870 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
9872 /* if only one direction, fall back to simple tube with that direction */
9873 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
9874 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
9875 case (MV_UP): return EL_TUBE_VERTICAL;
9876 case (MV_DOWN): return EL_TUBE_VERTICAL;
9882 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
9884 int element_new = getTubeFromOpenDirection(direction);
9886 return (element_new != EL_EMPTY ? element_new : element_old);
9889 static int getOpenDirectionFromBelt(int element)
9891 int belt_dir = getBeltDirFromBeltElement(element);
9893 return (belt_dir == MV_LEFT ? MV_RIGHT :
9894 belt_dir == MV_RIGHT ? MV_LEFT :
9895 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
9898 static int getBeltFromNrAndOpenDirection(int nr, int direction)
9900 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
9901 direction == MV_RIGHT ? MV_LEFT :
9902 direction == MV_HORIZONTAL ? MV_NONE : direction);
9904 if (direction == MV_NONE)
9907 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
9910 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
9913 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
9915 return (element_new != EL_EMPTY ? element_new : element_old);
9918 static int getOpenDirectionFromPool(int element)
9922 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
9923 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
9924 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
9925 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
9926 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
9927 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
9933 static int getPoolFromOpenDirection(int direction)
9937 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
9938 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
9939 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
9940 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
9941 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
9942 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
9948 static int getPoolFromOpenDirectionExt(int direction, int help_element)
9950 int element = getPoolFromOpenDirection(direction);
9951 int help_direction = getOpenDirectionFromPool(help_element);
9953 if (element == EL_EMPTY)
9955 int help_direction_vertical = help_direction & MV_VERTICAL;
9957 element = getPoolFromOpenDirection(direction | help_direction_vertical);
9960 if (element == EL_EMPTY)
9962 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
9964 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
9970 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
9972 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
9974 return (element_new != EL_EMPTY ? element_new : element_old);
9977 static int getOpenDirectionFromPillar(int element)
9981 case EL_EMC_WALL_1: return (MV_DOWN);
9982 case EL_EMC_WALL_2: return (MV_VERTICAL);
9983 case EL_EMC_WALL_3: return (MV_UP);
9989 static int getPillarFromOpenDirection(int direction)
9993 case (MV_DOWN): return EL_EMC_WALL_1;
9994 case (MV_VERTICAL): return EL_EMC_WALL_2;
9995 case (MV_UP): return EL_EMC_WALL_3;
10001 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
10003 int element_new = getPillarFromOpenDirection(direction);
10005 return (element_new != EL_EMPTY ? element_new : element_old);
10008 static int getOpenDirectionFromSteel2(int element)
10012 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
10013 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
10014 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
10015 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
10016 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
10017 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
10018 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
10019 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
10025 static int getSteel2FromOpenDirection(int direction)
10029 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
10030 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
10031 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
10032 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
10033 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
10034 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
10035 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
10036 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
10042 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
10044 int element_new = getSteel2FromOpenDirection(direction);
10046 return (element_new != EL_EMPTY ? element_new : element_old);
10049 static int getOpenDirectionFromChip(int element)
10053 case EL_SP_CHIP_SINGLE: return (MV_NONE);
10054 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
10055 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
10056 case EL_SP_CHIP_TOP: return (MV_DOWN);
10057 case EL_SP_CHIP_BOTTOM: return (MV_UP);
10063 static int getChipFromOpenDirection(int direction)
10067 case (MV_NONE): return EL_SP_CHIP_SINGLE;
10068 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
10069 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
10070 case (MV_UP): return EL_SP_CHIP_BOTTOM;
10071 case (MV_DOWN): return EL_SP_CHIP_TOP;
10077 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
10079 int element_new = getChipFromOpenDirection(direction);
10081 return (element_new != EL_EMPTY ? element_new : element_old);
10084 static int getClosedTube(int x, int y)
10086 static int xy[4][2] =
10093 int element_old = IntelliDrawBuffer[x][y];
10094 int direction_old = getOpenDirectionFromTube(element_old);
10095 int direction_new = MV_NONE;
10098 for (i = 0; i < NUM_DIRECTIONS; i++)
10100 int xx = x + xy[i][0];
10101 int yy = y + xy[i][1];
10102 int dir = MV_DIR_FROM_BIT(i);
10103 int dir_opposite = MV_DIR_OPPOSITE(dir);
10105 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
10106 (direction_old & dir) &&
10107 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10108 direction_new |= dir;
10111 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
10114 static int getClosedBelt(int x, int y)
10116 static int xy[4][2] =
10123 int element_old = IntelliDrawBuffer[x][y];
10124 int nr = getBeltNrFromBeltElement(element_old);
10125 int direction_old = getOpenDirectionFromBelt(element_old);
10126 int direction_new = MV_NONE;
10129 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
10131 int xx = x + xy[i][0];
10132 int yy = y + xy[i][1];
10133 int dir = MV_DIR_FROM_BIT(i);
10134 int dir_opposite = MV_DIR_OPPOSITE(dir);
10136 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
10137 (direction_old & dir) &&
10138 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10139 direction_new |= dir;
10142 return getBeltFromNrAndOpenDirection(nr, direction_new);
10145 static int getClosedPool(int x, int y)
10147 static int xy[4][2] =
10154 int element_old = IntelliDrawBuffer[x][y];
10155 int direction_old = getOpenDirectionFromPool(element_old);
10156 int direction_new = MV_NONE;
10159 for (i = 0; i < NUM_DIRECTIONS; i++)
10161 int xx = x + xy[i][0];
10162 int yy = y + xy[i][1];
10163 int dir = MV_DIR_FROM_BIT(i);
10164 int dir_opposite = MV_DIR_OPPOSITE(dir);
10166 if (IN_LEV_FIELD(xx, yy) &&
10167 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
10168 (direction_old & dir) &&
10169 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10170 direction_new |= dir;
10173 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
10176 static int getClosedPillar(int x, int y)
10178 static int xy[4][2] =
10185 int element_old = IntelliDrawBuffer[x][y];
10186 int direction_old = getOpenDirectionFromPillar(element_old);
10187 int direction_new = MV_NONE;
10190 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
10192 int xx = x + xy[i][0];
10193 int yy = y + xy[i][1];
10194 int dir = MV_DIR_FROM_BIT(i);
10195 int dir_opposite = MV_DIR_OPPOSITE(dir);
10197 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
10198 (direction_old & dir) &&
10199 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10200 direction_new |= dir;
10203 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
10206 static int getClosedSteel2(int x, int y)
10208 static int xy[4][2] =
10215 int element_old = IntelliDrawBuffer[x][y];
10216 int direction_old = getOpenDirectionFromSteel2(element_old);
10217 int direction_new = MV_NONE;
10220 for (i = 0; i < NUM_DIRECTIONS; i++)
10222 int xx = x + xy[i][0];
10223 int yy = y + xy[i][1];
10224 int dir = MV_DIR_FROM_BIT(i);
10225 int dir_opposite = MV_DIR_OPPOSITE(dir);
10227 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
10228 (direction_old & dir) &&
10229 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10230 direction_new |= dir;
10233 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
10236 static int getClosedChip(int x, int y)
10238 static int xy[4][2] =
10245 int element_old = IntelliDrawBuffer[x][y];
10246 int direction_old = getOpenDirectionFromChip(element_old);
10247 int direction_new = MV_NONE;
10250 for (i = 0; i < NUM_DIRECTIONS; i++)
10252 int xx = x + xy[i][0];
10253 int yy = y + xy[i][1];
10254 int dir = MV_DIR_FROM_BIT(i);
10255 int dir_opposite = MV_DIR_OPPOSITE(dir);
10257 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
10258 (direction_old & dir) &&
10259 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10260 direction_new |= dir;
10263 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
10266 static void SetElementSimpleExt(int x, int y, int dx, int dy, int element,
10267 boolean change_level)
10269 int sx = x - level_xpos;
10270 int sy = y - level_ypos;
10271 int old_element = Feld[x][y];
10272 unsigned int new_bitmask = (dx + 1) << (dy * 2);
10273 boolean draw_masked = FALSE;
10275 if (IS_MM_WALL_EDITOR(element))
10277 element = map_mm_wall_element_editor(element) | new_bitmask;
10279 if (IS_MM_WALL(old_element))
10280 element |= MM_WALL_BITS(old_element);
10283 draw_masked = TRUE;
10285 else if (IS_MM_WALL(old_element) && element == EL_EMPTY)
10287 int element_changed = old_element & ~new_bitmask;
10289 if (MM_WALL_BITS(element_changed) != 0)
10290 element = element_changed;
10293 IntelliDrawBuffer[x][y] = element;
10296 Feld[x][y] = element;
10298 if (IN_ED_FIELD(sx, sy))
10301 DrawEditorElementThruMask(sx, sy, element);
10303 DrawEditorElement(sx, sy, element);
10307 static void SetElementSimple(int x, int y, int element, boolean change_level)
10309 SetElementSimpleExt(x, y, 0, 0, element, change_level);
10312 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
10313 int x2, int y2, int *element2,
10314 int (*close_function)(int, int),
10315 boolean change_level)
10317 /* set neighbour elements to newly determined connections */
10318 SetElementSimple(x1, y1, *element1, change_level);
10319 SetElementSimple(x2, y2, *element2, change_level);
10321 /* remove all open connections of neighbour elements */
10322 *element1 = close_function(x1, y1);
10323 *element2 = close_function(x2, y2);
10325 /* set neighbour elements to new, minimized connections */
10326 SetElementSimple(x1, y1, *element1, change_level);
10327 SetElementSimple(x2, y2, *element2, change_level);
10330 static void SetElementIntelliDraw(int x, int y, int new_element,
10331 boolean change_level, int button)
10333 static int xy[4][2] =
10340 static int last_x = -1;
10341 static int last_y = -1;
10342 int old_element = IntelliDrawBuffer[x][y];
10344 if (new_element == EL_UNDEFINED)
10352 if (IS_TUBE(new_element))
10354 int last_element_new = EL_UNDEFINED;
10355 int direction = MV_NONE;
10358 /* if old element is of same kind, keep all existing directions */
10359 if (IS_TUBE(old_element))
10360 direction |= getOpenDirectionFromTube(old_element);
10362 for (i = 0; i < NUM_DIRECTIONS; i++)
10364 int xx = x + xy[i][0];
10365 int yy = y + xy[i][1];
10367 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10368 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
10370 int dir = MV_DIR_FROM_BIT(i);
10371 int dir_opposite = MV_DIR_OPPOSITE(dir);
10372 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10373 int last_direction_old = getOpenDirectionFromTube(last_element_old);
10374 int last_direction_new = last_direction_old | dir_opposite;
10376 last_element_new = getTubeFromOpenDirection(last_direction_new);
10382 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
10384 if (last_element_new != EL_UNDEFINED)
10385 MergeAndCloseNeighbourElements(x, y, &new_element,
10386 last_x, last_y, &last_element_new,
10387 getClosedTube, change_level);
10389 else if (IS_BELT(new_element))
10391 int belt_nr = getBeltNrFromBeltElement(new_element);
10392 int last_element_new = EL_UNDEFINED;
10393 int direction = MV_NONE;
10396 /* if old element is of same kind, keep all existing directions */
10397 if (IS_BELT(old_element))
10398 direction |= getOpenDirectionFromBelt(old_element);
10400 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
10402 int xx = x + xy[i][0];
10403 int yy = y + xy[i][1];
10405 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10406 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
10408 int dir = MV_DIR_FROM_BIT(i);
10409 int dir_opposite = MV_DIR_OPPOSITE(dir);
10410 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10411 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
10412 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
10413 int last_direction_new = last_direction_old | dir_opposite;
10415 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
10416 last_direction_new);
10421 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
10423 if (last_element_new != EL_UNDEFINED)
10424 MergeAndCloseNeighbourElements(x, y, &new_element,
10425 last_x, last_y, &last_element_new,
10426 getClosedBelt, change_level);
10428 else if (IS_ACID_POOL_OR_ACID(new_element))
10430 int last_element_new = EL_UNDEFINED;
10431 int direction = MV_NONE;
10434 /* if old element is of same kind, keep all existing directions */
10435 if (IS_ACID_POOL_OR_ACID(old_element))
10436 direction |= getOpenDirectionFromPool(old_element);
10438 for (i = 0; i < NUM_DIRECTIONS; i++)
10440 int xx = x + xy[i][0];
10441 int yy = y + xy[i][1];
10443 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10444 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
10446 int dir = MV_DIR_FROM_BIT(i);
10447 int dir_opposite = MV_DIR_OPPOSITE(dir);
10448 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10449 int last_direction_old = getOpenDirectionFromPool(last_element_old);
10450 int last_direction_new = last_direction_old | dir_opposite;
10452 last_element_new = getPoolFromOpenDirection(last_direction_new);
10458 /* special corrections needed for intuitively correct acid pool drawing */
10459 if (last_element_new == EL_EMPTY)
10460 last_element_new = new_element;
10461 else if (last_element_new != EL_UNDEFINED)
10462 new_element = last_element_new;
10464 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
10466 if (last_element_new != EL_UNDEFINED)
10467 MergeAndCloseNeighbourElements(x, y, &new_element,
10468 last_x, last_y, &last_element_new,
10469 getClosedPool, change_level);
10471 else if (IS_EMC_PILLAR(new_element))
10473 int last_element_new = EL_UNDEFINED;
10474 int direction = MV_NONE;
10477 /* if old element is of same kind, keep all existing directions */
10478 if (IS_EMC_PILLAR(old_element))
10479 direction |= getOpenDirectionFromPillar(old_element);
10481 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
10483 int xx = x + xy[i][0];
10484 int yy = y + xy[i][1];
10486 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10487 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
10489 int dir = MV_DIR_FROM_BIT(i);
10490 int dir_opposite = MV_DIR_OPPOSITE(dir);
10491 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10492 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
10493 int last_direction_new = last_direction_old | dir_opposite;
10495 last_element_new = getPillarFromOpenDirection(last_direction_new);
10501 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
10503 if (last_element_new != EL_UNDEFINED)
10504 MergeAndCloseNeighbourElements(x, y, &new_element,
10505 last_x, last_y, &last_element_new,
10506 getClosedPillar, change_level);
10508 else if (IS_DC_STEELWALL_2(new_element))
10510 int last_element_new = EL_UNDEFINED;
10511 int direction = MV_NONE;
10514 /* if old element is of same kind, keep all existing directions */
10515 if (IS_DC_STEELWALL_2(old_element))
10516 direction |= getOpenDirectionFromSteel2(old_element);
10518 for (i = 0; i < NUM_DIRECTIONS; i++)
10520 int xx = x + xy[i][0];
10521 int yy = y + xy[i][1];
10523 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10524 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
10526 int dir = MV_DIR_FROM_BIT(i);
10527 int dir_opposite = MV_DIR_OPPOSITE(dir);
10528 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10529 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
10530 int last_direction_new = last_direction_old | dir_opposite;
10532 last_element_new = getSteel2FromOpenDirection(last_direction_new);
10538 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
10540 if (last_element_new != EL_UNDEFINED)
10541 MergeAndCloseNeighbourElements(x, y, &new_element,
10542 last_x, last_y, &last_element_new,
10543 getClosedSteel2, change_level);
10545 else if (IS_SP_CHIP(new_element))
10547 int last_element_new = EL_UNDEFINED;
10548 int direction = MV_NONE;
10551 /* (do not keep existing directions, regardless of kind of old element) */
10553 for (i = 0; i < NUM_DIRECTIONS; i++)
10555 int xx = x + xy[i][0];
10556 int yy = y + xy[i][1];
10558 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10559 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
10561 int dir = MV_DIR_FROM_BIT(i);
10562 int dir_opposite = MV_DIR_OPPOSITE(dir);
10563 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10564 int last_direction_old = getOpenDirectionFromChip(last_element_old);
10565 int last_direction_new = last_direction_old | dir_opposite;
10567 if (last_direction_old == MV_NONE)
10569 last_element_new = getChipFromOpenDirection(last_direction_new);
10572 else if (last_direction_old & (dir | dir_opposite))
10574 direction |= MV_DIR_OPPOSITE(last_direction_old);
10578 direction |= MV_DIR_OPPOSITE(dir);
10583 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
10585 if (last_element_new != EL_UNDEFINED)
10586 MergeAndCloseNeighbourElements(x, y, &new_element,
10587 last_x, last_y, &last_element_new,
10588 getClosedChip, change_level);
10590 else if (IS_SP_HARDWARE_BASE(new_element))
10592 int nr = GetSimpleRandom(6);
10594 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
10595 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
10596 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
10597 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
10598 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
10600 else if (new_element == EL_SP_HARDWARE_GREEN ||
10601 new_element == EL_SP_HARDWARE_BLUE ||
10602 new_element == EL_SP_HARDWARE_RED)
10604 int nr = GetSimpleRandom(3);
10606 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
10607 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
10609 else if (IS_GROUP_ELEMENT(new_element))
10611 boolean connected_drawing = FALSE;
10614 for (i = 0; i < NUM_DIRECTIONS; i++)
10616 int xx = x + xy[i][0];
10617 int yy = y + xy[i][1];
10619 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10620 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
10621 connected_drawing = TRUE;
10624 if (!connected_drawing)
10625 ResolveGroupElement(new_element);
10627 new_element = GetElementFromGroupElement(new_element);
10629 else if (IS_BELT_SWITCH(old_element))
10631 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
10632 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
10634 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
10635 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
10637 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
10641 static int swappable_elements[][2] =
10643 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
10644 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
10645 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
10646 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
10647 { EL_EMERALD, EL_WALL_EMERALD },
10648 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
10649 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
10650 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
10651 { EL_DIAMOND, EL_WALL_DIAMOND },
10652 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
10653 { EL_GATE_1, EL_GATE_1_GRAY },
10654 { EL_GATE_2, EL_GATE_2_GRAY },
10655 { EL_GATE_3, EL_GATE_3_GRAY },
10656 { EL_GATE_4, EL_GATE_4_GRAY },
10657 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
10658 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
10659 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
10660 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
10661 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
10662 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
10663 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
10664 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
10665 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
10666 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
10667 { EL_LAMP, EL_LAMP_ACTIVE },
10668 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
10669 { EL_SP_BASE, EL_SP_BUGGY_BASE },
10670 { EL_PEARL, EL_WALL_PEARL },
10671 { EL_CRYSTAL, EL_WALL_CRYSTAL },
10672 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
10673 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
10674 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
10675 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
10676 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
10677 { EL_LANDMINE, EL_DC_LANDMINE },
10678 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
10679 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
10680 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
10681 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
10682 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
10683 { EL_MM_EXIT_CLOSED, EL_MM_EXIT_OPEN },
10684 { EL_MM_FUSE, EL_MM_FUSE_ACTIVE },
10685 { EL_MM_LIGHTBULB, EL_MM_LIGHTBULB_ACTIVE },
10686 { EL_MM_FUEL_EMPTY, EL_MM_FUEL_FULL },
10690 static int rotatable_elements_4[][4] =
10700 EL_SPACESHIP_RIGHT,
10705 EL_BD_BUTTERFLY_UP,
10706 EL_BD_BUTTERFLY_RIGHT,
10707 EL_BD_BUTTERFLY_DOWN,
10708 EL_BD_BUTTERFLY_LEFT
10712 EL_BD_FIREFLY_RIGHT,
10713 EL_BD_FIREFLY_DOWN,
10741 EL_SP_GRAVITY_PORT_UP,
10742 EL_SP_GRAVITY_PORT_RIGHT,
10743 EL_SP_GRAVITY_PORT_DOWN,
10744 EL_SP_GRAVITY_PORT_LEFT
10747 EL_SP_GRAVITY_ON_PORT_UP,
10748 EL_SP_GRAVITY_ON_PORT_RIGHT,
10749 EL_SP_GRAVITY_ON_PORT_DOWN,
10750 EL_SP_GRAVITY_ON_PORT_LEFT
10753 EL_SP_GRAVITY_OFF_PORT_UP,
10754 EL_SP_GRAVITY_OFF_PORT_RIGHT,
10755 EL_SP_GRAVITY_OFF_PORT_DOWN,
10756 EL_SP_GRAVITY_OFF_PORT_LEFT
10765 EL_BALLOON_SWITCH_UP,
10766 EL_BALLOON_SWITCH_RIGHT,
10767 EL_BALLOON_SWITCH_DOWN,
10768 EL_BALLOON_SWITCH_LEFT
10772 EL_MM_MCDUFFIN_RIGHT,
10773 EL_MM_MCDUFFIN_DOWN,
10774 EL_MM_MCDUFFIN_LEFT
10777 EL_MM_MIRROR_FIXED_1,
10778 EL_MM_MIRROR_FIXED_4,
10779 EL_MM_MIRROR_FIXED_3,
10780 EL_MM_MIRROR_FIXED_2
10783 EL_MM_STEEL_GRID_FIXED_1,
10784 EL_MM_STEEL_GRID_FIXED_4,
10785 EL_MM_STEEL_GRID_FIXED_2,
10786 EL_MM_STEEL_GRID_FIXED_3
10789 EL_MM_WOODEN_GRID_FIXED_1,
10790 EL_MM_WOODEN_GRID_FIXED_4,
10791 EL_MM_WOODEN_GRID_FIXED_2,
10792 EL_MM_WOODEN_GRID_FIXED_3
10795 EL_MM_POLARISATOR_CROSS_1,
10796 EL_MM_POLARISATOR_CROSS_4,
10797 EL_MM_POLARISATOR_CROSS_3,
10798 EL_MM_POLARISATOR_CROSS_2
10802 EL_MM_PACMAN_RIGHT,
10814 EL_DF_RECEIVER_RIGHT,
10815 EL_DF_RECEIVER_DOWN,
10816 EL_DF_RECEIVER_LEFT
10823 static int rotatable_elements_8[][8] =
10826 EL_DF_STEEL_GRID_FIXED_1,
10827 EL_DF_STEEL_GRID_FIXED_8,
10828 EL_DF_STEEL_GRID_FIXED_7,
10829 EL_DF_STEEL_GRID_FIXED_6,
10830 EL_DF_STEEL_GRID_FIXED_5,
10831 EL_DF_STEEL_GRID_FIXED_4,
10832 EL_DF_STEEL_GRID_FIXED_3,
10833 EL_DF_STEEL_GRID_FIXED_2
10836 EL_DF_WOODEN_GRID_FIXED_1,
10837 EL_DF_WOODEN_GRID_FIXED_8,
10838 EL_DF_WOODEN_GRID_FIXED_7,
10839 EL_DF_WOODEN_GRID_FIXED_6,
10840 EL_DF_WOODEN_GRID_FIXED_5,
10841 EL_DF_WOODEN_GRID_FIXED_4,
10842 EL_DF_WOODEN_GRID_FIXED_3,
10843 EL_DF_WOODEN_GRID_FIXED_2
10846 EL_DF_STEEL_GRID_ROTATING_1,
10847 EL_DF_STEEL_GRID_ROTATING_8,
10848 EL_DF_STEEL_GRID_ROTATING_7,
10849 EL_DF_STEEL_GRID_ROTATING_6,
10850 EL_DF_STEEL_GRID_ROTATING_5,
10851 EL_DF_STEEL_GRID_ROTATING_4,
10852 EL_DF_STEEL_GRID_ROTATING_3,
10853 EL_DF_STEEL_GRID_ROTATING_2
10856 EL_DF_WOODEN_GRID_ROTATING_1,
10857 EL_DF_WOODEN_GRID_ROTATING_8,
10858 EL_DF_WOODEN_GRID_ROTATING_7,
10859 EL_DF_WOODEN_GRID_ROTATING_6,
10860 EL_DF_WOODEN_GRID_ROTATING_5,
10861 EL_DF_WOODEN_GRID_ROTATING_4,
10862 EL_DF_WOODEN_GRID_ROTATING_3,
10863 EL_DF_WOODEN_GRID_ROTATING_2
10870 static int rotatable_elements_16[][16] =
10909 EL_MM_BEAMER_RED_5,
10910 EL_MM_BEAMER_RED_4,
10911 EL_MM_BEAMER_RED_3,
10912 EL_MM_BEAMER_RED_2,
10913 EL_MM_BEAMER_RED_1,
10914 EL_MM_BEAMER_RED_16,
10915 EL_MM_BEAMER_RED_15,
10916 EL_MM_BEAMER_RED_14,
10917 EL_MM_BEAMER_RED_13,
10918 EL_MM_BEAMER_RED_12,
10919 EL_MM_BEAMER_RED_11,
10920 EL_MM_BEAMER_RED_10,
10921 EL_MM_BEAMER_RED_9,
10922 EL_MM_BEAMER_RED_8,
10923 EL_MM_BEAMER_RED_7,
10927 EL_MM_BEAMER_YELLOW_5,
10928 EL_MM_BEAMER_YELLOW_4,
10929 EL_MM_BEAMER_YELLOW_3,
10930 EL_MM_BEAMER_YELLOW_2,
10931 EL_MM_BEAMER_YELLOW_1,
10932 EL_MM_BEAMER_YELLOW_16,
10933 EL_MM_BEAMER_YELLOW_15,
10934 EL_MM_BEAMER_YELLOW_14,
10935 EL_MM_BEAMER_YELLOW_13,
10936 EL_MM_BEAMER_YELLOW_12,
10937 EL_MM_BEAMER_YELLOW_11,
10938 EL_MM_BEAMER_YELLOW_10,
10939 EL_MM_BEAMER_YELLOW_9,
10940 EL_MM_BEAMER_YELLOW_8,
10941 EL_MM_BEAMER_YELLOW_7,
10942 EL_MM_BEAMER_YELLOW_6
10945 EL_MM_BEAMER_GREEN_5,
10946 EL_MM_BEAMER_GREEN_4,
10947 EL_MM_BEAMER_GREEN_3,
10948 EL_MM_BEAMER_GREEN_2,
10949 EL_MM_BEAMER_GREEN_1,
10950 EL_MM_BEAMER_GREEN_16,
10951 EL_MM_BEAMER_GREEN_15,
10952 EL_MM_BEAMER_GREEN_14,
10953 EL_MM_BEAMER_GREEN_13,
10954 EL_MM_BEAMER_GREEN_12,
10955 EL_MM_BEAMER_GREEN_11,
10956 EL_MM_BEAMER_GREEN_10,
10957 EL_MM_BEAMER_GREEN_9,
10958 EL_MM_BEAMER_GREEN_8,
10959 EL_MM_BEAMER_GREEN_7,
10960 EL_MM_BEAMER_GREEN_6
10963 EL_MM_BEAMER_BLUE_5,
10964 EL_MM_BEAMER_BLUE_4,
10965 EL_MM_BEAMER_BLUE_3,
10966 EL_MM_BEAMER_BLUE_2,
10967 EL_MM_BEAMER_BLUE_1,
10968 EL_MM_BEAMER_BLUE_16,
10969 EL_MM_BEAMER_BLUE_15,
10970 EL_MM_BEAMER_BLUE_14,
10971 EL_MM_BEAMER_BLUE_13,
10972 EL_MM_BEAMER_BLUE_12,
10973 EL_MM_BEAMER_BLUE_11,
10974 EL_MM_BEAMER_BLUE_10,
10975 EL_MM_BEAMER_BLUE_9,
10976 EL_MM_BEAMER_BLUE_8,
10977 EL_MM_BEAMER_BLUE_7,
10978 EL_MM_BEAMER_BLUE_6
10981 EL_MM_POLARISATOR_1,
10982 EL_MM_POLARISATOR_16,
10983 EL_MM_POLARISATOR_15,
10984 EL_MM_POLARISATOR_14,
10985 EL_MM_POLARISATOR_13,
10986 EL_MM_POLARISATOR_12,
10987 EL_MM_POLARISATOR_11,
10988 EL_MM_POLARISATOR_10,
10989 EL_MM_POLARISATOR_9,
10990 EL_MM_POLARISATOR_8,
10991 EL_MM_POLARISATOR_7,
10992 EL_MM_POLARISATOR_6,
10993 EL_MM_POLARISATOR_5,
10994 EL_MM_POLARISATOR_4,
10995 EL_MM_POLARISATOR_3,
10996 EL_MM_POLARISATOR_2
11017 EL_DF_MIRROR_ROTATING_1,
11018 EL_DF_MIRROR_ROTATING_16,
11019 EL_DF_MIRROR_ROTATING_15,
11020 EL_DF_MIRROR_ROTATING_14,
11021 EL_DF_MIRROR_ROTATING_13,
11022 EL_DF_MIRROR_ROTATING_12,
11023 EL_DF_MIRROR_ROTATING_11,
11024 EL_DF_MIRROR_ROTATING_10,
11025 EL_DF_MIRROR_ROTATING_9,
11026 EL_DF_MIRROR_ROTATING_8,
11027 EL_DF_MIRROR_ROTATING_7,
11028 EL_DF_MIRROR_ROTATING_6,
11029 EL_DF_MIRROR_ROTATING_5,
11030 EL_DF_MIRROR_ROTATING_4,
11031 EL_DF_MIRROR_ROTATING_3,
11032 EL_DF_MIRROR_ROTATING_2
11041 for (i = 0; swappable_elements[i][0] != -1; i++)
11043 int element1 = swappable_elements[i][0];
11044 int element2 = swappable_elements[i][1];
11046 if (old_element == element1 || old_element == element2)
11047 new_element = (old_element == element1 ? element2 : element1);
11050 for (i = 0; rotatable_elements_4[i][0] != -1; i++)
11052 for (j = 0; j < 4; j++)
11054 int element = rotatable_elements_4[i][j];
11056 if (old_element == element)
11057 new_element = (button == 1 ? rotatable_elements_4[i][(j + 3) % 4] :
11058 button == 2 ? rotatable_elements_4[i][0] :
11059 button == 3 ? rotatable_elements_4[i][(j + 1) % 4] :
11064 for (i = 0; rotatable_elements_8[i][0] != -1; i++)
11066 for (j = 0; j < 8; j++)
11068 int element = rotatable_elements_8[i][j];
11070 if (old_element == element)
11071 new_element = (button == 1 ? rotatable_elements_8[i][(j + 7) % 8] :
11072 button == 2 ? rotatable_elements_8[i][0] :
11073 button == 3 ? rotatable_elements_8[i][(j + 1) % 8] :
11078 for (i = 0; rotatable_elements_16[i][0] != -1; i++)
11080 for (j = 0; j < 16; j++)
11082 int element = rotatable_elements_16[i][j];
11084 if (old_element == element)
11085 new_element = (button == 1 ? rotatable_elements_16[i][(j + 15) % 16] :
11086 button == 2 ? rotatable_elements_16[i][0] :
11087 button == 3 ? rotatable_elements_16[i][(j + 1) % 16] :
11092 if (old_element != new_element)
11094 int max_infotext_len = getMaxInfoTextLength();
11095 char infotext[MAX_OUTPUT_LINESIZE + 1];
11097 strncpy(infotext, getElementInfoText(new_element), max_infotext_len);
11098 infotext[max_infotext_len] = '\0';
11100 ClearEditorGadgetInfoText();
11102 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT,
11107 SetElementSimple(x, y, new_element, change_level);
11113 static void ResetIntelliDraw()
11117 for (x = 0; x < lev_fieldx; x++)
11118 for (y = 0; y < lev_fieldy; y++)
11119 IntelliDrawBuffer[x][y] = Feld[x][y];
11121 SetElementIntelliDraw(-1, -1, EL_UNDEFINED, FALSE, -1);
11124 static boolean draw_mode_hires = FALSE;
11126 static void SetDrawModeHiRes(int element)
11129 (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
11130 (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY));
11133 static boolean getDrawModeHiRes()
11135 return draw_mode_hires;
11138 static int getLoResScreenPos(int pos)
11140 return (getDrawModeHiRes() ? pos / 2 : pos);
11143 static int getLoResScreenMod(int pos)
11145 return (getDrawModeHiRes() ? pos % 2 : 0);
11148 static void SetElementExt(int x, int y, int dx, int dy, int element,
11149 boolean change_level, int button)
11152 SetElementSimple(x, y, Feld[x][y], change_level);
11153 else if (GetKeyModState() & KMOD_Shift && !IS_MM_WALL_EDITOR(element))
11154 SetElementIntelliDraw(x, y, element, change_level, button);
11156 SetElementSimpleExt(x, y, dx, dy, element, change_level);
11159 static void SetElement(int x, int y, int element)
11161 SetElementExt(x, y, 0, 0, element, TRUE, -1);
11164 static void SetElementButton(int x, int y, int dx, int dy, int element,
11167 SetElementExt(x, y, dx, dy, element, TRUE, button);
11170 static void SetElementHiRes(int sx2, int sy2, int element, boolean change_level)
11172 int lx = getLoResScreenPos(sx2) + level_xpos;
11173 int ly = getLoResScreenPos(sy2) + level_ypos;
11174 int dx = getLoResScreenMod(sx2);
11175 int dy = getLoResScreenMod(sy2);
11177 SetElementExt(lx, ly, dx, dy, element, change_level, -1);
11180 static void SetLevelElementHiRes(int lx2, int ly2, int element)
11187 SetElementExt(lx, ly, dx, dy, element, TRUE, -1);
11190 static int getLevelElementHiRes(int lx2, int ly2)
11196 int element = Feld[lx][ly];
11197 unsigned int bitmask = (dx + 1) << (dy * 2);
11199 if (IS_MM_WALL(element))
11201 if (element & bitmask)
11202 return map_mm_wall_element(element);
11210 static void DrawLineElement(int x, int y, int element, boolean change_level)
11212 SetElementHiRes(x, y, element, change_level);
11215 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
11216 int element, boolean change_level)
11218 int xsize = ABS(to_x - from_x);
11219 int ysize = ABS(to_y - from_y);
11220 int dx = (to_x < from_x ? -1 : +1);
11221 int dy = (to_y < from_y ? -1 : +1);
11224 if (from_y == to_y) /* horizontal line */
11226 for (i = 0; i <= xsize; i++)
11227 DrawLineElement(from_x + i * dx, from_y, element, change_level);
11229 else if (from_x == to_x) /* vertical line */
11231 for (i = 0; i <= ysize; i++)
11232 DrawLineElement(from_x, from_y + i * dy, element, change_level);
11234 else /* diagonal line */
11236 if (ysize < xsize) /* a < 1 */
11238 float a = (float)ysize / (float)xsize;
11240 for (i = 0; i <= xsize; i++)
11243 int y = dy * (int)(a * i + 0.5);
11245 DrawLineElement(from_x + x, from_y + y, element, change_level);
11250 float a = (float)xsize / (float)ysize;
11252 for (i = 0; i <= ysize; i++)
11254 int x = dx * (int)(a * i + 0.5);
11257 DrawLineElement(from_x + x, from_y + y, element, change_level);
11263 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
11264 int element, boolean change_level)
11266 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
11267 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
11268 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
11269 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
11272 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
11273 int element, boolean change_level)
11278 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
11280 for (y = from_y; y <= to_y; y++)
11281 DrawLine(from_x, y, to_x, y, element, change_level);
11284 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
11285 int element, boolean change_level)
11287 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
11288 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
11289 int len_x = ABS(to_x - from_x);
11290 int len_y = ABS(to_y - from_y);
11293 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
11295 /* not optimal (some points get drawn twice) but simple,
11296 and fast enough for the few points we are drawing */
11298 for (x = 0; x <= radius; x++)
11300 int sx, sy, sx2, sy2, lx, ly;
11302 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
11304 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
11305 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
11306 sx = getLoResScreenPos(sx2);
11307 sy = getLoResScreenPos(sy2);
11308 lx = sx + level_xpos;
11309 ly = sy + level_ypos;
11311 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
11312 DrawLineElement(sx2, sy2, element, change_level);
11315 for (y = 0; y <= radius; y++)
11317 int sx, sy, sx2, sy2, lx, ly;
11319 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
11321 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
11322 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
11323 sx = getLoResScreenPos(sx2);
11324 sy = getLoResScreenPos(sy2);
11325 lx = sx + level_xpos;
11326 ly = sy + level_ypos;
11328 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
11329 DrawLineElement(sx2, sy2, element, change_level);
11333 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
11334 int element, boolean change_level)
11336 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
11337 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
11339 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
11342 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
11344 #if DRAW_CIRCLES_BUTTON_AVAILABLE
11345 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
11346 int element, boolean change_level)
11348 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
11349 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
11350 int mirror_to_x2 = from_x - (to_x2 - from_x);
11351 int mirror_to_y2 = from_y - (to_y2 - from_y);
11353 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
11354 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
11355 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
11356 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element,change_level);
11360 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
11362 int from_sx, from_sy;
11366 swap_numbers(&from_x, &to_x);
11369 swap_numbers(&from_y, &to_y);
11371 from_sx = SX + from_x * ed_tilesize;
11372 from_sy = SY + from_y * ed_tilesize;
11373 to_sx = SX + (to_x + 1) * ed_tilesize - 1;
11374 to_sy = SY + (to_y + 1) * ed_tilesize - 1;
11376 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
11377 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
11378 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
11379 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
11381 if (from_x == to_x && from_y == to_y)
11382 MarkTileDirty(from_x/2, from_y/2);
11384 redraw_mask |= REDRAW_FIELD;
11387 static void DrawAreaBox(int from_x, int from_y, int to_x, int to_y,
11388 int element, boolean change_level)
11390 DrawBox(from_x, from_y, to_x, to_y, element, change_level);
11393 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
11394 int element, boolean change_level)
11396 if (element == -1 || change_level)
11397 DrawAreaBox(from_x, from_y, to_x, to_y, -1, FALSE);
11399 DrawAreaBorder(from_x, from_y, to_x, to_y);
11402 /* values for CopyBrushExt() */
11403 #define CB_AREA_TO_BRUSH 0
11404 #define CB_BRUSH_TO_CURSOR 1
11405 #define CB_BRUSH_TO_LEVEL 2
11406 #define CB_DELETE_OLD_CURSOR 3
11407 #define CB_DUMP_BRUSH 4
11408 #define CB_DUMP_BRUSH_SMALL 5
11410 static void DrawBrushElement(int sx, int sy, int element, boolean change_level)
11412 DrawLineElement(sx, sy, element, change_level);
11415 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
11416 int button, int mode)
11418 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
11419 static int brush_width, brush_height;
11420 static int last_cursor_x = -1, last_cursor_y = -1;
11421 static boolean delete_old_brush;
11422 int new_element = BUTTON_ELEMENT(button);
11425 if (mode == CB_DUMP_BRUSH ||
11426 mode == CB_DUMP_BRUSH_SMALL)
11428 if (!draw_with_brush)
11430 Error(ERR_WARN, "no brush selected");
11435 for (y = 0; y < brush_height; y++)
11437 for (x = 0; x < brush_width; x++)
11439 int element = brush_buffer[x][y];
11440 int element_mapped = element;
11442 if (IS_CUSTOM_ELEMENT(element))
11443 element_mapped = EL_CUSTOM_START;
11444 else if (IS_GROUP_ELEMENT(element))
11445 element_mapped = EL_GROUP_START;
11446 else if (element >= NUM_FILE_ELEMENTS)
11447 element_mapped = EL_UNKNOWN;
11449 // dump brush as level sketch text for the R'n'D forum:
11450 // - large tiles: `xxx (0x60 ASCII)
11451 // - small tiles: ¸xxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
11452 printf("%s%03d", (mode == CB_DUMP_BRUSH ? "`" : "¸"), element_mapped);
11461 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
11464 if (mode == CB_AREA_TO_BRUSH)
11466 int from_lx, from_ly;
11469 swap_numbers(&from_x, &to_x);
11472 swap_numbers(&from_y, &to_y);
11474 brush_width = to_x - from_x + 1;
11475 brush_height = to_y - from_y + 1;
11477 from_lx = from_x + level_xpos;
11478 from_ly = from_y + level_ypos;
11480 for (y = 0; y < brush_height; y++)
11482 for (x = 0; x < brush_width; x++)
11484 brush_buffer[x][y] = Feld[from_lx + x][from_ly + y];
11487 DrawBrushElement(from_x + x, from_y + y, new_element, TRUE);
11492 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
11494 delete_old_brush = FALSE;
11496 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
11497 mode == CB_BRUSH_TO_LEVEL)
11499 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
11500 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
11501 int cursor_from_x = cursor_x - brush_width / 2;
11502 int cursor_from_y = cursor_y - brush_height / 2;
11503 int border_from_x = cursor_x, border_from_y = cursor_y;
11504 int border_to_x = cursor_x, border_to_y = cursor_y;
11506 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
11507 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
11509 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
11510 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
11512 delete_old_brush = FALSE;
11516 for (y = 0; y < brush_height; y++)
11518 for (x = 0; x < brush_width; x++)
11520 int sx = cursor_from_x + x;
11521 int sy = cursor_from_y + y;
11522 int lx = sx + level_xpos;
11523 int ly = sy + level_ypos;
11524 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
11525 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
11526 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
11527 brush_buffer[x][y] : new_element);
11529 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
11531 if (sx < border_from_x)
11532 border_from_x = sx;
11533 else if (sx > border_to_x)
11535 if (sy < border_from_y)
11536 border_from_y = sy;
11537 else if (sy > border_to_y)
11540 DrawBrushElement(sx, sy, element, change_level);
11545 if (mode != CB_DELETE_OLD_CURSOR)
11546 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
11548 last_cursor_x = cursor_x;
11549 last_cursor_y = cursor_y;
11550 delete_old_brush = TRUE;
11554 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
11557 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
11560 static void CopyBrushToLevel(int x, int y, int button)
11562 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
11565 static void CopyBrushToCursor(int x, int y)
11567 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
11570 static void DeleteBrushFromCursor()
11572 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
11577 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
11580 void DumpBrush_Small()
11582 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
11585 static void FloodFill(int from_x, int from_y, int fill_element)
11587 FloodFillLevel(from_x, from_y, fill_element, Feld, lev_fieldx, lev_fieldy);
11590 static void FloodFillWall_MM(int from_sx2, int from_sy2, int fill_element)
11592 int from_x = from_sx2 + 2 * level_xpos;
11593 int from_y = from_sy2 + 2 * level_ypos;
11594 int max_fillx = lev_fieldx * 2;
11595 int max_filly = lev_fieldy * 2;
11596 short FillFeld[max_fillx][max_filly];
11599 for (x = 0; x < max_fillx; x++)
11600 for (y = 0; y < max_filly; y++)
11601 FillFeld[x][y] = getLevelElementHiRes(x, y);
11603 FloodFillLevelExt(from_x, from_y, fill_element, max_fillx, max_filly,
11604 FillFeld, max_fillx, max_filly);
11606 for (x = 0; x < max_fillx; x++)
11607 for (y = 0; y < max_filly; y++)
11608 if (FillFeld[x][y] == fill_element)
11609 SetLevelElementHiRes(x, y, FillFeld[x][y]);
11612 /* values for DrawLevelText() modes */
11613 #define TEXT_INIT 0
11614 #define TEXT_SETCURSOR 1
11615 #define TEXT_WRITECHAR 2
11616 #define TEXT_BACKSPACE 3
11617 #define TEXT_NEWLINE 4
11619 #define TEXT_QUERY_TYPING 6
11621 static int DrawLevelText(int sx, int sy, char letter, int mode)
11623 static short delete_buffer[MAX_LEV_FIELDX];
11624 static int start_sx;
11625 static int last_sx, last_sy;
11626 static boolean typing = FALSE;
11627 int letter_element = EL_CHAR_ASCII0 + letter;
11628 int lx = 0, ly = 0;
11630 /* map lower case letters to upper case and convert special characters */
11631 if (letter >= 'a' && letter <= 'z')
11632 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
11633 else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
11634 letter_element = EL_CHAR_AUMLAUT;
11635 else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
11636 letter_element = EL_CHAR_OUMLAUT;
11637 else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
11638 letter_element = EL_CHAR_UUMLAUT;
11639 else if (letter == '^')
11640 letter_element = EL_CHAR_COPYRIGHT;
11642 letter_element = EL_CHAR_ASCII0 + letter;
11644 if (mode != TEXT_INIT)
11649 if (mode != TEXT_SETCURSOR)
11655 lx = last_sx + level_xpos;
11656 ly = last_sy + level_ypos;
11663 DrawLevelText(0, 0, 0, TEXT_END);
11669 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
11672 case TEXT_SETCURSOR:
11673 DrawEditorElement(last_sx, last_sy, Feld[lx][ly]);
11674 DrawAreaBorder(sx, sy, sx, sy);
11679 case TEXT_WRITECHAR:
11680 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
11682 if (new_element1 >= EL_STEEL_CHAR_START &&
11683 new_element1 <= EL_STEEL_CHAR_END)
11684 letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
11686 delete_buffer[sx - start_sx] = Feld[lx][ly];
11687 Feld[lx][ly] = letter_element;
11689 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
11690 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
11691 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
11692 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
11694 DrawLevelText(0, 0, 0, TEXT_END);
11696 level.changed = TRUE;
11700 case TEXT_BACKSPACE:
11703 Feld[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
11704 DrawEditorElement(sx - 1, sy, Feld[lx - 1][ly]);
11705 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
11710 if (sy + 1 < ed_fieldy - 1 && ly + 1 < lev_fieldy - 1)
11711 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
11713 DrawLevelText(0, 0, 0, TEXT_END);
11717 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
11718 DrawEditorElement(sx, sy, Feld[lx][ly]);
11722 case TEXT_QUERY_TYPING:
11732 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
11733 int element, boolean change_level)
11735 int lx = sx + level_xpos;
11736 int ly = sy + level_ypos;
11739 DrawEditorElement(sx, sy, Feld[lx][ly]);
11741 DrawAreaBorder(sx, sy, sx, sy);
11744 static void CheckLevelBorderElement(boolean redraw_playfield)
11746 int last_border_element = BorderElement;
11748 SetBorderElement();
11750 if (redraw_playfield && BorderElement != last_border_element)
11751 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11754 static void CopyLevelToUndoBuffer(int mode)
11756 static boolean accumulated_undo = FALSE;
11757 boolean new_undo_buffer_position = TRUE;
11760 if (undo_buffer_steps == 0)
11761 accumulated_undo = FALSE;
11765 case UNDO_IMMEDIATE:
11766 accumulated_undo = FALSE;
11769 case UNDO_ACCUMULATE:
11770 if (accumulated_undo)
11771 new_undo_buffer_position = FALSE;
11772 accumulated_undo = TRUE;
11779 if (new_undo_buffer_position)
11781 /* advance position in undo buffer ring */
11782 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
11784 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
11785 undo_buffer_steps++;
11788 /* always reset redo buffer when storing level change into undo buffer */
11789 redo_buffer_steps = 0;
11791 for (x = 0; x < lev_fieldx; x++)
11792 for (y = 0; y < lev_fieldy; y++)
11793 UndoBuffer[undo_buffer_position][x][y] = Feld[x][y];
11795 /* check if drawing operation forces change of border style */
11796 CheckLevelBorderElement(TRUE);
11798 level.changed = TRUE;
11801 static void RandomPlacement(int new_element)
11803 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
11804 int num_free_positions = 0;
11805 int num_percentage, num_elements;
11808 ResetIntelliDraw();
11810 /* determine number of free positions for randomly placing the new element */
11811 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
11813 free_position[x][y] =
11814 (random_placement_background_restricted ?
11815 Feld[x][y] == random_placement_background_element :
11816 Feld[x][y] != new_element);
11818 if (free_position[x][y])
11819 num_free_positions++;
11822 /* determine number of new elements to place there */
11823 num_percentage = num_free_positions * random_placement_value / 100;
11824 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
11825 num_percentage : random_placement_value);
11827 /* if less free positions than elements to place, fill all these positions */
11828 if (num_free_positions < num_elements)
11830 for (x = 0; x < lev_fieldx; x++)
11831 for (y = 0; y < lev_fieldy; y++)
11832 if (free_position[x][y])
11833 SetElement(x, y, new_element);
11837 while (num_elements > 0)
11839 x = GetSimpleRandom(lev_fieldx);
11840 y = GetSimpleRandom(lev_fieldy);
11842 /* don't place element at the same position twice */
11843 if (free_position[x][y])
11845 free_position[x][y] = FALSE;
11846 SetElement(x, y, new_element);
11852 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11853 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
11856 void WrapLevel(int dx, int dy)
11858 int wrap_dx = lev_fieldx - dx;
11859 int wrap_dy = lev_fieldy - dy;
11862 for (x = 0; x < lev_fieldx; x++)
11863 for (y = 0; y < lev_fieldy; y++)
11864 FieldBackup[x][y] = Feld[x][y];
11866 for (x = 0; x < lev_fieldx; x++)
11867 for (y = 0; y < lev_fieldy; y++)
11869 FieldBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
11871 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11872 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
11875 static void HandleDrawingAreas(struct GadgetInfo *gi)
11877 static boolean started_inside_drawing_area = FALSE;
11878 static int last_sx = -1, last_sy = -1;
11879 static int last_sx2 = -1, last_sy2 = -1;
11880 int id = gi->custom_id;
11881 int type_id = gi->custom_type_id;
11882 boolean button_press_event;
11883 boolean button_release_event;
11884 boolean inside_drawing_area = !gi->event.off_borders;
11885 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
11886 int actual_drawing_function;
11887 int button = gi->event.button;
11888 int new_element = BUTTON_ELEMENT(button);
11889 int sx = gi->event.x, sy = gi->event.y;
11890 int min_sx = 0, min_sy = 0;
11891 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
11892 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
11893 int mini_item_xsize = item_xsize / 2, mini_item_ysize = item_ysize / 2;
11894 int sx2 = gi->event.mx / mini_item_xsize;
11895 int sy2 = gi->event.my / mini_item_ysize;
11898 int lx = 0, ly = 0;
11899 int min_lx = 0, min_ly = 0;
11900 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
11903 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
11904 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
11906 /* make sure to stay inside drawing area boundaries */
11907 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
11908 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
11912 /* get positions inside level field */
11913 lx = sx + level_xpos;
11914 ly = sy + level_ypos;
11916 if (!IN_LEV_FIELD(lx, ly))
11917 inside_drawing_area = FALSE;
11919 /* make sure to stay inside level field boundaries */
11920 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
11921 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
11923 /* correct drawing area positions accordingly */
11924 sx = lx - level_xpos;
11925 sy = ly - level_ypos;
11928 /* also correct MM wall-sized (double) drawing area positions accordingly */
11929 if (sx2 / 2 < sx || sx2 / 2 > sx)
11931 dx = (sx2 / 2 < sx ? 0 : 1);
11934 if (sy2 / 2 < sy || sy2 / 2 > sy)
11936 dy = (sy2 / 2 < sy ? 0 : 1);
11940 if (button_release_event)
11947 else if (!button_press_event)
11949 /* prevent handling events for every pixel position when moving mouse */
11950 if ((sx == last_sx && sy == last_sy &&
11951 !IS_MM_WALL_EDITOR(new_element) && new_element != EL_EMPTY) ||
11952 (sx2 == last_sx2 && sy2 == last_sy2))
11961 if (button_press_event)
11962 started_inside_drawing_area = inside_drawing_area;
11964 if (!started_inside_drawing_area)
11967 if (!IS_VALID_BUTTON(button))
11970 if (!button && !button_release_event)
11973 /* handle info callback for each invocation of action callback */
11974 gi->callback_info(gi);
11976 /* automatically switch to 'single item' drawing mode, if needed */
11977 actual_drawing_function =
11978 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
11979 drawing_function : GADGET_ID_SINGLE_ITEMS);
11981 /* clicking into drawing area with pressed Control key picks element */
11982 if (GetKeyModState() & KMOD_Control)
11984 last_drawing_function = drawing_function;
11985 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
11988 if (GetKeyModState() & KMOD_Shift)
11990 if (button_press_event || button_release_event)
11991 ResetIntelliDraw();
11994 SetDrawModeHiRes(-1); /* reset to normal draw mode */
11996 switch (actual_drawing_function)
11998 case GADGET_ID_SINGLE_ITEMS:
12001 if (button_release_event)
12003 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12005 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
12006 !inside_drawing_area)
12007 DeleteBrushFromCursor();
12010 if (!button || button_release_event)
12013 if (draw_with_brush)
12015 CopyBrushToLevel(sx, sy, button);
12019 if (new_element == EL_PLAYER_1)
12021 /* remove player at old position */
12022 for (y = 0; y < lev_fieldy; y++)
12023 for (x = 0; x < lev_fieldx; x++)
12024 if (Feld[x][y] == EL_PLAYER_1)
12025 SetElement(x, y, EL_EMPTY);
12028 SetElementButton(lx, ly, dx, dy, new_element, button);
12031 else if (!button_release_event)
12033 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
12035 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
12036 DrawMiniGraphicExt(drawto,
12037 gi->x + sx * MINI_TILEX,
12038 gi->y + sy * MINI_TILEY,
12039 el2edimg(new_element));
12041 DrawFixedGraphicExt(drawto,
12042 gi->x + sx * TILEX,
12043 gi->y + sy * TILEY,
12044 el2edimg(new_element), 0);
12046 if (id == GADGET_ID_CUSTOM_GRAPHIC)
12047 new_element = GFX_ELEMENT(new_element);
12049 drawingarea_info[type_id].value[pos] = new_element;
12051 CopyElementPropertiesToGame(properties_element);
12053 if (id == GADGET_ID_CUSTOM_GRAPHIC)
12055 UpdateCustomElementGraphicGadgets();
12057 FrameCounter = 0; /* restart animation frame counter */
12062 case GADGET_ID_CONNECTED_ITEMS:
12064 static int last_sx = -1;
12065 static int last_sy = -1;
12067 if (button_release_event)
12068 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12072 SetDrawModeHiRes(new_element);
12074 if (getDrawModeHiRes())
12080 if (!button_press_event)
12081 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
12089 case GADGET_ID_LINE:
12090 case GADGET_ID_ARC:
12091 case GADGET_ID_RECTANGLE:
12092 case GADGET_ID_FILLED_BOX:
12093 SetDrawModeHiRes(new_element);
12095 if (getDrawModeHiRes())
12101 case GADGET_ID_GRAB_BRUSH:
12102 case GADGET_ID_TEXT:
12104 static int last_sx = -1;
12105 static int last_sy = -1;
12106 static int start_sx = -1;
12107 static int start_sy = -1;
12108 void (*draw_func)(int, int, int, int, int, boolean);
12110 if (drawing_function == GADGET_ID_LINE)
12111 draw_func = DrawLine;
12112 else if (drawing_function == GADGET_ID_ARC)
12113 draw_func = DrawArc;
12114 else if (drawing_function == GADGET_ID_RECTANGLE)
12115 draw_func = DrawBox;
12116 else if (drawing_function == GADGET_ID_FILLED_BOX)
12117 draw_func = DrawFilledBox;
12118 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
12119 draw_func = SelectArea;
12120 else /* (drawing_function == GADGET_ID_TEXT) */
12121 draw_func = SetTextCursor;
12123 if (button_press_event)
12125 draw_func(sx, sy, sx, sy, new_element, FALSE);
12126 start_sx = last_sx = sx;
12127 start_sy = last_sy = sy;
12129 if (drawing_function == GADGET_ID_TEXT)
12130 DrawLevelText(0, 0, 0, TEXT_END);
12132 else if (button_release_event)
12134 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
12135 if (drawing_function == GADGET_ID_GRAB_BRUSH)
12137 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
12138 CopyBrushToCursor(sx, sy);
12139 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
12141 draw_with_brush = TRUE;
12143 else if (drawing_function == GADGET_ID_TEXT)
12144 DrawLevelText(sx, sy, 0, TEXT_INIT);
12146 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12148 else if (last_sx != sx || last_sy != sy)
12150 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
12151 if (IS_MM_WALL_EDITOR(new_element)) /* clear wall background */
12152 draw_func(start_sx, start_sy, sx, sy, EL_EMPTY, FALSE);
12153 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
12160 case GADGET_ID_FLOOD_FILL:
12161 if (button_press_event && Feld[lx][ly] != new_element)
12163 if (IS_MM_WALL_EDITOR(new_element))
12164 FloodFillWall_MM(sx2, sy2, new_element);
12166 FloodFill(lx, ly, new_element);
12168 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12169 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12173 case GADGET_ID_PICK_ELEMENT:
12174 if (button_release_event)
12175 ClickOnGadget(level_editor_gadget[last_drawing_function],
12177 else if (draw_level)
12178 PickDrawingElement(button, Feld[lx][ly]);
12181 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
12183 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
12190 /* do not mark level as modified for certain non-level-changing gadgets */
12191 if ((type_id >= ED_DRAWING_ID_EDITOR_FIRST &&
12192 type_id <= ED_DRAWING_ID_EDITOR_LAST) ||
12193 actual_drawing_function == GADGET_ID_PICK_ELEMENT)
12196 level.changed = TRUE;
12199 static void HandleCounterButtons(struct GadgetInfo *gi)
12201 int gadget_id = gi->custom_id;
12202 int counter_id = gi->custom_type_id;
12203 int button = gi->event.button;
12204 int *counter_value = counterbutton_info[counter_id].value;
12205 int step = BUTTON_STEPSIZE(button) *
12206 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
12208 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
12210 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
12211 boolean released = (gi->event.type == GD_EVENT_RELEASED);
12212 boolean level_changed = LevelChanged();
12214 if ((level_changed && pressed) || (!level_changed && released))
12217 if (level_changed && !Request("Level has changed! Discard changes?",
12220 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
12221 ModifyEditorCounterValue(counter_id, *counter_value);
12227 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
12228 *counter_value = gi->textinput.number_value;
12230 ModifyEditorCounterValue(counter_id, *counter_value + step);
12232 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
12234 int last_game_engine_type = level.game_engine_type;
12236 LoadLevel(level_nr);
12237 LoadScore(level_nr);
12239 SaveLevelSetup_SeriesInfo();
12244 DrawEditModeWindow();
12246 if (level.game_engine_type != last_game_engine_type)
12248 /* update element selection list */
12249 ReinitializeElementList();
12250 ModifyEditorElementList();
12256 switch (counter_id)
12258 case ED_COUNTER_ID_YAMYAM_CONTENT:
12259 DrawYamYamContentAreas();
12262 case ED_COUNTER_ID_BALL_CONTENT:
12263 DrawMagicBallContentAreas();
12266 case ED_COUNTER_ID_ANDROID_CONTENT:
12267 DrawAndroidElementArea(properties_element);
12270 case ED_COUNTER_ID_GROUP_CONTENT:
12271 DrawGroupElementArea(properties_element);
12272 CopyGroupElementPropertiesToGame(properties_element);
12275 case ED_COUNTER_ID_INVENTORY_SIZE:
12276 DrawPlayerInitialInventoryArea(properties_element);
12279 case ED_COUNTER_ID_ENVELOPE_XSIZE:
12280 case ED_COUNTER_ID_ENVELOPE_YSIZE:
12281 DrawEnvelopeTextArea(-1);
12284 case ED_COUNTER_ID_LEVEL_XSIZE:
12285 case ED_COUNTER_ID_LEVEL_YSIZE:
12286 lev_fieldx = level.fieldx;
12287 lev_fieldy = level.fieldy;
12289 /* check if resizing of level results in change of border border */
12290 SetBorderElement();
12298 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
12299 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
12300 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
12301 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
12302 CopyElementPropertiesToGame(properties_element);
12304 /* do not mark level as modified for certain non-level-changing gadgets */
12305 if (counter_id >= ED_COUNTER_ID_EDITOR_FIRST &&
12306 counter_id <= ED_COUNTER_ID_EDITOR_LAST)
12309 level.changed = TRUE;
12312 static void HandleTextInputGadgets(struct GadgetInfo *gi)
12314 int type_id = gi->custom_type_id;
12316 strcpy(textinput_info[type_id].value, gi->textinput.value);
12318 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
12320 CopyElementPropertiesToGame(properties_element);
12322 ModifyEditorElementList(); /* update changed button info text */
12325 level.changed = TRUE;
12328 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
12330 int type_id = gi->custom_type_id;
12332 strncpy(textarea_info[type_id].value, gi->textarea.value,
12333 MAX_ENVELOPE_TEXT_LEN);
12334 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
12336 level.changed = TRUE;
12339 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
12341 int type_id = gi->custom_type_id;
12342 int value_old = *selectbox_info[type_id].value;
12343 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
12345 *selectbox_info[type_id].value = value_new;
12347 if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
12349 element_info[properties_element].current_change_page = gi->selectbox.index;
12351 DrawPropertiesWindow();
12353 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
12354 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
12355 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
12356 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
12357 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
12359 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
12361 /* when changing action type, also check action mode and action arg */
12362 if (value_old != value_new)
12363 setSelectboxSpecialActionVariablesIfNeeded();
12365 DrawPropertiesChange();
12368 CopyElementPropertiesToGame(properties_element);
12370 level.changed = TRUE;
12372 else if (type_id == ED_SELECTBOX_ID_GAME_ENGINE_TYPE)
12374 /* update element selection list */
12375 ReinitializeElementList();
12376 ModifyEditorElementList();
12380 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
12382 int type_id = gi->custom_type_id;
12385 if (type_id >= ED_TAB_BUTTON_ID_LEVELINFO_FIRST &&
12386 type_id <= ED_TAB_BUTTON_ID_LEVELINFO_LAST)
12388 edit_mode_levelinfo = gi->custom_type_id;
12390 DrawLevelInfoWindow();
12392 else if (type_id >= ED_TAB_BUTTON_ID_PROPERTIES_FIRST &&
12393 type_id <= ED_TAB_BUTTON_ID_PROPERTIES_LAST)
12395 edit_mode_properties = gi->custom_type_id;
12397 DrawPropertiesWindow();
12399 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 ||
12400 type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2)
12402 boolean new_template = !fileExists(getLocalLevelTemplateFilename());
12404 /* backup original "level.field" (needed to track playfield changes) */
12405 CopyPlayfield(level.field, FieldBackup);
12407 /* "SaveLevelTemplate()" uses "level.field", so copy editor playfield */
12408 CopyPlayfield(Feld, level.field);
12410 if (new_template ||
12411 Request("Save this template and kill the old?", REQ_ASK))
12412 SaveLevelTemplate();
12415 Request("Template saved!", REQ_CONFIRM);
12417 /* restore original "level.field" (needed to track playfield changes) */
12418 CopyPlayfield(FieldBackup, level.field);
12420 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
12421 custom_element.num_change_pages < MAX_CHANGE_PAGES)
12423 struct ElementInfo *ei = &element_info[properties_element];
12425 /* when modifying custom element, ask for copying level template */
12426 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
12429 setElementChangePages(ei, ei->num_change_pages + 1);
12431 /* set new change page to be new current change page */
12432 ei->current_change_page = ei->num_change_pages - 1;
12433 ei->change = &ei->change_page[ei->current_change_page];
12435 setElementChangeInfoToDefaults(ei->change);
12437 DrawPropertiesWindow();
12439 level.changed = TRUE;
12441 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
12442 custom_element.num_change_pages > MIN_CHANGE_PAGES)
12444 struct ElementInfo *ei = &element_info[properties_element];
12446 /* when modifying custom element, ask for copying level template */
12447 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
12450 /* copy all change pages after change page to be deleted */
12451 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
12452 ei->change_page[i] = ei->change_page[i + 1];
12454 setElementChangePages(ei, ei->num_change_pages - 1);
12456 DrawPropertiesWindow();
12458 level.changed = TRUE;
12462 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
12464 int type_id = gi->custom_type_id;
12466 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
12467 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
12469 struct ElementInfo *ei = &element_info[properties_element];
12470 int step = BUTTON_STEPSIZE(gi->event.button);
12472 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
12473 ei->current_change_page += step;
12475 if (ei->current_change_page < 0)
12476 ei->current_change_page = 0;
12477 else if (ei->current_change_page >= ei->num_change_pages)
12478 ei->current_change_page = ei->num_change_pages - 1;
12480 DrawPropertiesWindow();
12482 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
12483 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
12485 struct ElementInfo *ei = &element_info[properties_element];
12486 int current_change_page = ei->current_change_page;
12488 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
12490 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
12491 ei->change_page[current_change_page];
12493 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
12495 /* when modifying custom element, ask for copying level template */
12496 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
12499 ei->change_page[current_change_page] =
12500 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
12502 level.changed = TRUE;
12505 DrawPropertiesWindow();
12509 static void HandleRadiobuttons(struct GadgetInfo *gi)
12511 int type_id = gi->custom_type_id;
12513 *radiobutton_info[type_id].value =
12514 radiobutton_info[type_id].checked_value;
12516 /* do not mark level as modified for certain non-level-changing gadgets */
12517 if (type_id >= ED_RADIOBUTTON_ID_EDITOR_FIRST &&
12518 type_id <= ED_RADIOBUTTON_ID_EDITOR_LAST)
12521 level.changed = TRUE;
12524 static void HandleCheckbuttons(struct GadgetInfo *gi)
12526 int type_id = gi->custom_type_id;
12528 *checkbutton_info[type_id].value ^= TRUE;
12530 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
12531 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
12532 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
12533 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
12534 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
12535 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
12536 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
12537 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1))
12539 CopyElementPropertiesToGame(properties_element);
12542 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
12544 UpdateCustomElementGraphicGadgets();
12546 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 ||
12547 type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2)
12549 boolean template_related_changes_found = FALSE;
12552 /* check if any custom or group elements have been changed */
12553 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
12554 if ((IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)) &&
12555 element_info[i].modified_settings)
12556 template_related_changes_found = TRUE;
12558 if (level.use_custom_template &&
12559 !fileExists(getGlobalLevelTemplateFilename()))
12561 Request("No level template found!", REQ_CONFIRM);
12563 level.use_custom_template = FALSE;
12565 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
12570 if (level.use_custom_template &&
12571 template_related_changes_found &&
12572 !Request("Discard changes and use level template?", REQ_ASK))
12574 level.use_custom_template = FALSE;
12576 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
12581 if (!level.use_custom_template &&
12582 Request("Copy settings from level template?", REQ_ASK))
12587 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
12589 DrawEditModeWindow();
12591 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3)
12593 if (setup.editor.use_template_for_new_levels &&
12594 !fileExists(getGlobalLevelTemplateFilename()))
12596 Request("No level template found!", REQ_CONFIRM);
12601 if (setup.editor.use_template_for_new_levels &&
12603 !Request("Discard level and load template?", REQ_ASK))
12608 if (!setup.editor.use_template_for_new_levels &&
12610 !Request("Discard level and use empty level?", REQ_ASK))
12615 LoadLevel(level_nr);
12616 LoadScore(level_nr);
12621 DrawEditModeWindow();
12623 else if (type_id == ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS)
12625 SetAutomaticNumberOfGemsNeeded();
12628 /* do not mark level as modified for certain non-level-changing gadgets */
12629 if ((type_id >= ED_CHECKBUTTON_ID_EDITOR_FIRST &&
12630 type_id <= ED_CHECKBUTTON_ID_EDITOR_LAST) ||
12631 type_id == ED_CHECKBUTTON_ID_STICK_ELEMENT)
12634 level.changed = TRUE;
12637 static void HandleControlButtons(struct GadgetInfo *gi)
12639 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
12640 static int last_edit_mode = ED_MODE_DRAWING;
12641 static int last_custom_copy_mode = -1;
12642 static int last_button = 0;
12643 int id = gi->custom_id;
12644 int button = gi->event.button;
12645 int step = BUTTON_STEPSIZE(button);
12646 int new_element = BUTTON_ELEMENT(button);
12647 int last_properties_element = properties_element;
12650 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
12651 DrawLevelText(0, 0, 0, TEXT_END);
12653 if (id < ED_NUM_CTRL1_BUTTONS &&
12654 id != GADGET_ID_SINGLE_ITEMS &&
12655 id != GADGET_ID_PICK_ELEMENT &&
12656 edit_mode != ED_MODE_DRAWING &&
12657 drawing_function != GADGET_ID_PICK_ELEMENT &&
12658 !(GetKeyModState() & KMOD_Control))
12659 ChangeEditModeWindow(ED_MODE_DRAWING);
12661 /* element copy mode active, but no element button pressed => deactivate */
12662 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
12663 last_custom_copy_mode = -1;
12665 /* when showing palette on element buttons, change element of button used */
12666 if (editor.palette.show_on_element_buttons &&
12667 id >= GADGET_ID_ELEMENT_LEFT && id <= GADGET_ID_ELEMENT_RIGHT)
12669 last_button = id - GADGET_ID_ELEMENT_LEFT + 1;
12671 id = GADGET_ID_PALETTE;
12676 case GADGET_ID_SCROLL_LEFT:
12677 if (level_xpos >= 0)
12679 if (lev_fieldx < ed_fieldx - 2)
12682 level_xpos -= step;
12683 if (level_xpos < -1)
12686 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
12688 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12690 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
12691 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
12695 case GADGET_ID_SCROLL_RIGHT:
12696 if (level_xpos <= lev_fieldx - ed_fieldx)
12698 if (lev_fieldx < ed_fieldx - 2)
12701 level_xpos += step;
12702 if (level_xpos > lev_fieldx - ed_fieldx + 1)
12703 level_xpos = lev_fieldx - ed_fieldx + 1;
12705 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
12707 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12709 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
12710 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
12714 case GADGET_ID_SCROLL_UP:
12715 if (level_ypos >= 0)
12717 if (lev_fieldy < ed_fieldy - 2)
12720 level_ypos -= step;
12721 if (level_ypos < -1)
12724 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
12726 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12728 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
12729 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
12733 case GADGET_ID_SCROLL_DOWN:
12734 if (level_ypos <= lev_fieldy - ed_fieldy)
12736 if (lev_fieldy < ed_fieldy - 2)
12739 level_ypos += step;
12740 if (level_ypos > lev_fieldy - ed_fieldy + 1)
12741 level_ypos = lev_fieldy - ed_fieldy + 1;
12743 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
12745 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12747 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
12748 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
12752 case GADGET_ID_SCROLL_HORIZONTAL:
12753 level_xpos = gi->event.item_position - 1;
12755 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12760 case GADGET_ID_SCROLL_VERTICAL:
12761 level_ypos = gi->event.item_position - 1;
12763 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12768 case GADGET_ID_SCROLL_LIST_UP:
12769 case GADGET_ID_SCROLL_LIST_DOWN:
12770 case GADGET_ID_SCROLL_LIST_VERTICAL:
12771 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
12772 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
12775 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
12776 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
12778 if (element_shift < 0)
12780 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
12781 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
12783 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
12784 GDI_SCROLLBAR_ITEM_POSITION,
12785 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
12788 ModifyEditorElementList();
12792 case GADGET_ID_PROPERTIES:
12793 // always switch off element properties when they are already displayed
12794 last_properties_element = new_element;
12795 case GADGET_ID_ELEMENT_LEFT:
12796 case GADGET_ID_ELEMENT_MIDDLE:
12797 case GADGET_ID_ELEMENT_RIGHT:
12798 properties_element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
12799 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
12800 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 :
12803 if (edit_mode != ED_MODE_PROPERTIES)
12805 last_edit_mode = edit_mode;
12807 ChangeEditModeWindow(ED_MODE_PROPERTIES);
12809 last_level_drawing_function = drawing_function;
12810 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
12813 else if (properties_element != last_properties_element)
12815 DrawEditModeWindow();
12819 ChangeEditModeWindow(last_edit_mode);
12821 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
12826 case GADGET_ID_PALETTE:
12827 if (edit_mode != ED_MODE_PALETTE)
12829 last_edit_mode = edit_mode;
12831 ChangeEditModeWindow(ED_MODE_PALETTE);
12835 ChangeEditModeWindow(last_edit_mode);
12839 case GADGET_ID_WRAP_LEFT:
12840 WrapLevel(-step, 0);
12843 case GADGET_ID_WRAP_RIGHT:
12844 WrapLevel(step, 0);
12847 case GADGET_ID_WRAP_UP:
12848 WrapLevel(0, -step);
12851 case GADGET_ID_WRAP_DOWN:
12852 WrapLevel(0, step);
12855 case GADGET_ID_SINGLE_ITEMS:
12856 case GADGET_ID_CONNECTED_ITEMS:
12857 case GADGET_ID_LINE:
12858 case GADGET_ID_ARC:
12859 case GADGET_ID_TEXT:
12860 case GADGET_ID_RECTANGLE:
12861 case GADGET_ID_FILLED_BOX:
12862 case GADGET_ID_FLOOD_FILL:
12863 case GADGET_ID_GRAB_BRUSH:
12864 case GADGET_ID_PICK_ELEMENT:
12865 if (drawing_function != GADGET_ID_PICK_ELEMENT)
12866 last_drawing_function = drawing_function;
12867 drawing_function = id;
12868 draw_with_brush = FALSE;
12871 case GADGET_ID_RANDOM_PLACEMENT:
12872 RandomPlacement(new_element);
12875 case GADGET_ID_ZOOM:
12876 // zoom level editor tile size in or out (or reset to default size)
12877 ed_tilesize = (button == 1 ? ed_tilesize * 2 :
12878 button == 2 ? DEFAULT_EDITOR_TILESIZE :
12879 button == 3 ? ed_tilesize / 2 : ed_tilesize);
12881 // limit zoom level by upper and lower bound
12882 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
12884 InitZoomLevelSettings();
12886 if (edit_mode == ED_MODE_DRAWING)
12888 DrawDrawingWindow();
12890 /* redraw zoom gadget info text */
12891 PrintEditorGadgetInfoText(level_editor_gadget[id]);
12896 case GADGET_ID_CUSTOM_COPY_FROM:
12897 case GADGET_ID_CUSTOM_COPY_TO:
12898 case GADGET_ID_CUSTOM_EXCHANGE:
12899 last_custom_copy_mode = id;
12900 last_drawing_function = drawing_function;
12903 case GADGET_ID_CUSTOM_COPY:
12904 CopyCustomElement(properties_element, -1, id);
12907 case GADGET_ID_CUSTOM_PASTE:
12908 CopyCustomElement(-1, properties_element, id);
12911 case GADGET_ID_UNDO:
12912 if (button == 1 && GetKeyModState() & (KMOD_Shift|KMOD_Control))
12915 if (button == 1 && undo_buffer_steps == 0)
12917 Request("Undo buffer empty!", REQ_CONFIRM);
12921 else if (button == 2)
12925 else if (button == 3 && redo_buffer_steps == 0)
12927 Request("Redo buffer empty!", REQ_CONFIRM);
12932 if (edit_mode != ED_MODE_DRAWING)
12933 ChangeEditModeWindow(ED_MODE_DRAWING);
12939 undo_buffer_position =
12940 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
12942 undo_buffer_steps--;
12943 redo_buffer_steps++;
12949 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
12951 undo_buffer_steps++;
12952 redo_buffer_steps--;
12955 for (x = 0; x < lev_fieldx; x++)
12956 for (y = 0; y < lev_fieldy; y++)
12957 Feld[x][y] = UndoBuffer[undo_buffer_position][x][y];
12959 /* check if undo operation forces change of border style */
12960 CheckLevelBorderElement(FALSE);
12962 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12966 case GADGET_ID_INFO:
12967 if (edit_mode != ED_MODE_INFO)
12969 last_edit_mode = edit_mode;
12971 ChangeEditModeWindow(ED_MODE_INFO);
12975 ChangeEditModeWindow(last_edit_mode);
12979 case GADGET_ID_CLEAR:
12980 if (edit_mode != ED_MODE_DRAWING)
12981 ChangeEditModeWindow(ED_MODE_DRAWING);
12983 for (x = 0; x < MAX_LEV_FIELDX; x++)
12984 for (y = 0; y < MAX_LEV_FIELDY; y++)
12985 Feld[x][y] = (button == 1 ? EL_EMPTY : new_element);
12987 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
12989 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12992 case GADGET_ID_SAVE:
12994 /* saving read-only levels into personal level set modifies global vars
12995 "leveldir_current" and "level_nr"; restore them after saving level */
12996 LevelDirTree *leveldir_former = leveldir_current;
12997 int level_nr_former = level_nr;
12998 char *level_filename;
13001 if (leveldir_current->readonly &&
13002 !PrepareSavingIntoPersonalLevelSet())
13005 level_filename = getDefaultLevelFilename(level_nr);
13006 new_level = !fileExists(level_filename);
13009 Request("Save this level and kill the old?", REQ_ASK))
13011 if (leveldir_former->readonly)
13012 ModifyLevelInfoForSavingIntoPersonalLevelSet(leveldir_former->name);
13014 SetAutomaticNumberOfGemsNeeded();
13016 CopyPlayfield(Feld, level.field);
13017 SaveLevel(level_nr);
13019 level.changed = FALSE;
13023 char level_saved_msg[64];
13025 if (leveldir_former->readonly)
13026 sprintf(level_saved_msg,
13027 "Level saved as level %d into personal level set!",
13030 strcpy(level_saved_msg, "Level saved!");
13032 Request(level_saved_msg, REQ_CONFIRM);
13036 /* "cd" back to copied-from levelset (in case of saved read-only level) */
13037 leveldir_current = leveldir_former;
13038 level_nr = level_nr_former;
13043 case GADGET_ID_TEST:
13044 if (LevelChanged())
13045 level.game_version = GAME_VERSION_ACTUAL;
13047 CopyPlayfield(level.field, FieldBackup);
13048 CopyPlayfield(Feld, level.field);
13050 CopyNativeLevel_RND_to_Native(&level);
13052 UnmapLevelEditorGadgets();
13053 UndrawSpecialEditorDoor();
13055 CloseDoor(DOOR_CLOSE_ALL);
13057 /* needed before playing if editor playfield area has different size */
13058 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
13060 // redraw_mask = REDRAW_ALL;
13062 level_editor_test_game = TRUE;
13064 StartGameActions(FALSE, setup.autorecord, level.random_seed);
13068 case GADGET_ID_EXIT:
13069 RequestExitLevelEditor(TRUE, FALSE); /* if level has changed, ask user */
13073 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
13074 id <= GADGET_ID_ELEMENTLIST_LAST)
13076 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
13077 int new_element = editor_elements[element_position + element_shift];
13079 if (IS_EDITOR_CASCADE(new_element))
13083 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
13085 int *cascade_element= &(*editor_elements_info[i].headline_list)[0];
13086 boolean *cascade_value=editor_elements_info[i].setup_cascade_value;
13088 if (*cascade_element == new_element)
13090 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
13091 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
13093 /* update element selection list */
13094 ReinitializeElementList();
13095 ModifyEditorElementList();
13097 /* update cascading gadget info text */
13098 PrintEditorGadgetInfoText(level_editor_gadget[id]);
13100 /* save current editor cascading state */
13101 SaveSetup_EditorCascade();
13110 if (last_custom_copy_mode != -1)
13112 if (CopyCustomElement(properties_element, new_element,
13113 last_custom_copy_mode))
13115 ClickOnGadget(level_editor_gadget[last_drawing_function],
13118 last_custom_copy_mode = -1;
13124 /* change element of button used to show palette */
13125 if (editor.palette.show_on_element_buttons)
13126 button = last_button;
13128 PickDrawingElement(button, new_element);
13130 if (!stick_element_properties_window &&
13131 drawing_function != GADGET_ID_PICK_ELEMENT &&
13132 !(GetKeyModState() & KMOD_Control))
13134 properties_element = new_element;
13135 if (edit_mode == ED_MODE_PROPERTIES)
13136 DrawPropertiesWindow();
13139 if (drawing_function == GADGET_ID_PICK_ELEMENT)
13140 ClickOnGadget(level_editor_gadget[last_drawing_function],
13143 if (!use_permanent_palette)
13144 ChangeEditModeWindow(last_edit_mode);
13147 else if (gi->event.type == GD_EVENT_PRESSED)
13148 printf("default: HandleControlButtons: GD_EVENT_PRESSED(%d)\n", id);
13149 else if (gi->event.type == GD_EVENT_RELEASED)
13150 printf("default: HandleControlButtons: GD_EVENT_RELEASED(%d)\n", id);
13151 else if (gi->event.type == GD_EVENT_MOVING)
13152 printf("default: HandleControlButtons: GD_EVENT_MOVING(%d)\n", id);
13154 printf("default: HandleControlButtons: ? (id == %d)\n", id);
13160 void HandleLevelEditorKeyInput(Key key)
13162 char letter = getCharFromKey(key);
13163 int button = MB_LEFTBUTTON;
13165 if (drawing_function == GADGET_ID_TEXT &&
13166 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
13169 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
13170 else if (key == KSYM_Delete || key == KSYM_BackSpace)
13171 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
13172 else if (key == KSYM_Return)
13173 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
13174 else if (key == KSYM_Escape)
13175 DrawLevelText(0, 0, 0, TEXT_END);
13177 else if (button_status == MB_RELEASED)
13179 int id = GADGET_ID_NONE;
13180 int new_element_shift = element_shift;
13181 int step = ED_ELEMENTLIST_BUTTONS_VERT - 1;
13187 id = GADGET_ID_SCROLL_LEFT;
13190 id = GADGET_ID_SCROLL_RIGHT;
13193 id = GADGET_ID_SCROLL_UP;
13196 id = GADGET_ID_SCROLL_DOWN;
13200 case KSYM_Page_Down:
13201 step *= (key == KSYM_Page_Up ? -1 : +1);
13202 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
13204 if (element_shift < 0)
13206 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
13207 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
13209 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
13210 GDI_SCROLLBAR_ITEM_POSITION,
13211 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
13213 ModifyEditorElementList();
13219 element_shift = (key == KSYM_Home ? 0 :
13220 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
13222 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
13223 GDI_SCROLLBAR_ITEM_POSITION,
13224 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
13226 ModifyEditorElementList();
13233 /* this is needed to prevent interference with running "True X-Mouse" */
13234 if (GetKeyModStateFromEvents() & KMOD_Control)
13237 /* check for last or next editor cascade block in element list */
13238 for (i = 0; i < num_editor_elements; i++)
13240 if ((key == KSYM_Insert && i == element_shift) ||
13241 (key == KSYM_Delete && new_element_shift > element_shift))
13244 /* jump to next cascade block (or to start of element list) */
13245 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
13246 new_element_shift = i;
13249 if (i < num_editor_elements)
13250 element_shift = new_element_shift;
13252 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
13253 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
13255 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
13256 GDI_SCROLLBAR_ITEM_POSITION,
13257 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
13259 ModifyEditorElementList();
13264 if (edit_mode == ED_MODE_DRAWING)
13266 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
13268 else if (edit_mode == ED_MODE_INFO)
13270 HandleControlButtons(level_editor_gadget[GADGET_ID_INFO]);
13272 else if (edit_mode == ED_MODE_PROPERTIES)
13274 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
13276 else if (edit_mode == ED_MODE_PALETTE)
13278 HandleControlButtons(level_editor_gadget[GADGET_ID_PALETTE]);
13280 else /* should never happen */
13282 ChangeEditModeWindow(ED_MODE_DRAWING);
13291 if (id != GADGET_ID_NONE)
13292 ClickOnGadget(level_editor_gadget[id], button);
13293 else if (letter == '1' || letter == '?')
13294 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_LEFT], button);
13295 else if (letter == '2')
13296 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_MIDDLE], button);
13297 else if (letter == '3')
13298 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_RIGHT], button);
13299 else if (letter == '.')
13300 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
13301 else if (letter == 'U')
13302 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
13303 else if (letter == '-' || key == KSYM_KP_Subtract)
13304 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
13305 else if (letter == '0' || key == KSYM_KP_0)
13306 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
13307 else if (letter == '+' || key == KSYM_KP_Add ||
13308 letter == '=') // ("Shift-=" is "+" on US keyboards)
13309 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
13310 else if (key == KSYM_Return ||
13311 key == KSYM_space ||
13312 key == setup.shortcut.toggle_pause)
13313 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
13315 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
13316 if (letter && letter == controlbutton_info[i].shortcut)
13317 if (!anyTextGadgetActive())
13318 ClickOnGadget(level_editor_gadget[i], button);
13322 void HandleLevelEditorIdle()
13324 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
13325 int x = editor.settings.element_graphic.x + element_border;
13326 int y = editor.settings.element_graphic.y + element_border;
13327 static unsigned int action_delay = 0;
13328 unsigned int action_delay_value = GameFrameDelay;
13331 if (edit_mode != ED_MODE_PROPERTIES)
13334 if (!DelayReached(&action_delay, action_delay_value))
13337 for (i = 0; i < ED_NUM_SELECTBOX; i++)
13339 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
13341 if (gi->mapped && gi->active && gi->selectbox.open)
13345 DrawEditorElementAnimation(SX + x, SY + y);
13347 redraw_mask |= REDRAW_FIELD;
13349 FrameCounter++; /* increase animation frame counter */
13352 static void ClearEditorGadgetInfoText()
13354 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
13357 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
13359 char infotext[MAX_OUTPUT_LINESIZE + 1];
13360 char shortcut[MAX_OUTPUT_LINESIZE + 1];
13361 int max_infotext_len = getMaxInfoTextLength();
13363 if (gi == NULL || strlen(gi->info_text) == 0)
13366 strncpy(infotext, gi->info_text, max_infotext_len);
13367 infotext[max_infotext_len] = '\0';
13369 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
13371 int key = controlbutton_info[gi->custom_id].shortcut;
13375 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
13376 sprintf(shortcut, " ('.' or '%c')", key);
13377 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
13378 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
13379 else if (gi->custom_id == GADGET_ID_TEST)
13380 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
13381 else if (gi->custom_id == GADGET_ID_UNDO)
13382 sprintf(shortcut, " ('%c/Shift-U')", key);
13383 else if (gi->custom_id == GADGET_ID_ZOOM)
13384 sprintf(shortcut, " ('%c', '0', '-')", key);
13386 sprintf(shortcut, " ('%s%c')",
13387 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
13389 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
13390 strcat(infotext, shortcut);
13394 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, INFOTEXT_FONT);
13397 void HandleEditorGadgetInfoText(void *ptr)
13399 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
13401 if (game_status != GAME_MODE_EDITOR)
13404 ClearEditorGadgetInfoText();
13406 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
13409 /* misuse this function to delete brush cursor, if needed */
13410 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
13411 DeleteBrushFromCursor();
13413 PrintEditorGadgetInfoText(gi);
13416 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
13418 static int start_lx, start_ly;
13419 int id = gi->custom_id;
13420 int type_id = gi->custom_type_id;
13421 int sx = gi->event.x;
13422 int sy = gi->event.y;
13423 int lx = sx + level_xpos;
13424 int ly = sy + level_ypos;
13425 int min_sx = 0, min_sy = 0;
13426 int max_sx = gi->drawing.area_xsize - 1;
13427 int max_sy = gi->drawing.area_ysize - 1;
13428 int actual_drawing_function = drawing_function;
13429 int max_infotext_len = getMaxInfoTextLength();
13430 char infotext[MAX_OUTPUT_LINESIZE + 1];
13433 infotext[0] = '\0'; /* start with empty info text */
13435 /* pressed Control key: simulate picking element */
13436 if (GetKeyModState() & KMOD_Control)
13437 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
13439 ClearEditorGadgetInfoText();
13441 if (gi->event.type == GD_EVENT_INFO_LEAVING)
13444 /* make sure to stay inside drawing area boundaries */
13445 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
13446 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
13448 if (id == GADGET_ID_DRAWING_LEVEL)
13452 int min_lx = 0, min_ly = 0;
13453 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
13455 /* get positions inside level field */
13456 lx = sx + level_xpos;
13457 ly = sy + level_ypos;
13459 /* make sure to stay inside level field boundaries */
13460 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
13461 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
13463 /* correct drawing area positions accordingly */
13464 sx = lx - level_xpos;
13465 sy = ly - level_ypos;
13468 if (IN_ED_FIELD(sx,sy) && IN_LEV_FIELD(lx, ly))
13470 if (button_status) /* if (gi->state == GD_BUTTON_PRESSED) */
13472 if (gi->event.type == GD_EVENT_PRESSED)
13478 switch (actual_drawing_function)
13480 case GADGET_ID_SINGLE_ITEMS:
13481 text = "Drawing single items";
13483 case GADGET_ID_CONNECTED_ITEMS:
13484 text = "Drawing connected items";
13486 case GADGET_ID_LINE:
13487 text = "Drawing line";
13489 case GADGET_ID_ARC:
13490 text = "Drawing arc";
13492 case GADGET_ID_TEXT:
13493 text = "Setting text cursor";
13495 case GADGET_ID_RECTANGLE:
13496 text = "Drawing rectangle";
13498 case GADGET_ID_FILLED_BOX:
13499 text = "Drawing filled box";
13501 case GADGET_ID_FLOOD_FILL:
13502 text = "Flood fill";
13504 case GADGET_ID_GRAB_BRUSH:
13505 text = "Grabbing brush";
13507 case GADGET_ID_PICK_ELEMENT:
13508 text = "Picking element";
13512 text = "Drawing position";
13516 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
13517 sprintf(infotext, "%s: %d, %d", text, lx, ly);
13519 sprintf(infotext, "%s: %d, %d", text,
13520 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
13522 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
13523 strncpy(infotext, getElementInfoText(Feld[lx][ly]), max_infotext_len);
13525 sprintf(infotext, "Level position: %d, %d", lx, ly);
13528 /* misuse this function to draw brush cursor, if needed */
13529 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
13531 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
13532 CopyBrushToCursor(sx, sy);
13534 DeleteBrushFromCursor();
13537 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
13539 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
13540 int element = drawingarea_info[type_id].value[pos];
13542 strncpy(infotext, getElementInfoText(element), max_infotext_len);
13546 if (id == GADGET_ID_CUSTOM_CONTENT)
13547 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
13548 else if (id == GADGET_ID_GROUP_CONTENT)
13549 sprintf(infotext, "group element position: %d", sx + 1);
13550 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
13551 id <= GADGET_ID_YAMYAM_CONTENT_7)
13552 sprintf(infotext, "content area %d position: %d, %d",
13553 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
13554 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
13555 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
13556 sprintf(infotext, "content area %d position: %d, %d",
13557 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
13558 else if (id == GADGET_ID_ANDROID_CONTENT)
13559 sprintf(infotext, "android element position: %d", sx + 1);
13560 else if (drawingarea_info[type_id].infotext != NULL)
13561 strcpy(infotext, drawingarea_info[type_id].infotext);
13564 infotext[max_infotext_len] = '\0';
13566 if (strlen(infotext) > 0)
13567 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT, infotext);
13570 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
13571 boolean quick_quit)
13573 if (!ask_if_level_has_changed ||
13575 Request("Level has changed! Exit without saving?",
13576 REQ_ASK | REQ_STAY_OPEN))
13578 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
13579 struct RectWithBorder *vp_door_2 = &viewport.door_2[GAME_MODE_MAIN];
13581 /* draw normal door */
13582 UndrawSpecialEditorDoor();
13584 // close editor doors if viewport definition is the same as in main menu
13585 if (vp_door_1->x == DX &&
13586 vp_door_1->y == DY &&
13587 vp_door_1->width == DXSIZE &&
13588 vp_door_1->height == DYSIZE &&
13589 vp_door_2->x == VX &&
13590 vp_door_2->y == VY &&
13591 vp_door_2->width == VXSIZE &&
13592 vp_door_2->height == VYSIZE)
13593 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
13595 SetDoorState(DOOR_CLOSE_2);
13600 FadeSkipNextFadeIn();
13602 SetGameStatus(GAME_MODE_MAIN);
13608 if (!global.use_envelope_request)
13610 CloseDoor(DOOR_CLOSE_1);
13611 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);