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_X (editor.settings.tooltip.x)
350 #define INFOTEXT_Y (editor.settings.tooltip.y)
351 #define INFOTEXT_XY_REDEFINED (INFOTEXT_X != -1 || INFOTEXT_Y != -1)
352 #define INFOTEXT_XPOS SX + (INFOTEXT_XY_REDEFINED ? INFOTEXT_X : 0)
353 #define INFOTEXT_YPOS SY + (INFOTEXT_XY_REDEFINED ? INFOTEXT_Y : \
354 SYSIZE - INFOTEXT_YSIZE)
358 -----------------------------------------------------------------------------
359 editor gadget definitions
360 -----------------------------------------------------------------------------
363 /* drawing toolbox buttons */
364 #define GADGET_ID_NONE -1
365 #define GADGET_ID_TOOLBOX_FIRST 0
367 #define GADGET_ID_SINGLE_ITEMS (GADGET_ID_TOOLBOX_FIRST + 0)
368 #define GADGET_ID_CONNECTED_ITEMS (GADGET_ID_TOOLBOX_FIRST + 1)
369 #define GADGET_ID_LINE (GADGET_ID_TOOLBOX_FIRST + 2)
370 #define GADGET_ID_ARC (GADGET_ID_TOOLBOX_FIRST + 3)
371 #define GADGET_ID_RECTANGLE (GADGET_ID_TOOLBOX_FIRST + 4)
372 #define GADGET_ID_FILLED_BOX (GADGET_ID_TOOLBOX_FIRST + 5)
373 #define GADGET_ID_WRAP_UP (GADGET_ID_TOOLBOX_FIRST + 6)
374 #define GADGET_ID_TEXT (GADGET_ID_TOOLBOX_FIRST + 7)
375 #define GADGET_ID_FLOOD_FILL (GADGET_ID_TOOLBOX_FIRST + 8)
376 #define GADGET_ID_WRAP_LEFT (GADGET_ID_TOOLBOX_FIRST + 9)
377 #define GADGET_ID_ZOOM (GADGET_ID_TOOLBOX_FIRST + 10)
378 #define GADGET_ID_WRAP_RIGHT (GADGET_ID_TOOLBOX_FIRST + 11)
379 #define GADGET_ID_RANDOM_PLACEMENT (GADGET_ID_TOOLBOX_FIRST + 12)
380 #define GADGET_ID_GRAB_BRUSH (GADGET_ID_TOOLBOX_FIRST + 13)
381 #define GADGET_ID_WRAP_DOWN (GADGET_ID_TOOLBOX_FIRST + 14)
382 #define GADGET_ID_PICK_ELEMENT (GADGET_ID_TOOLBOX_FIRST + 15)
384 #define GADGET_ID_UNDO (GADGET_ID_TOOLBOX_FIRST + 16)
385 #define GADGET_ID_INFO (GADGET_ID_TOOLBOX_FIRST + 17)
386 #define GADGET_ID_SAVE (GADGET_ID_TOOLBOX_FIRST + 18)
387 #define GADGET_ID_CLEAR (GADGET_ID_TOOLBOX_FIRST + 19)
388 #define GADGET_ID_TEST (GADGET_ID_TOOLBOX_FIRST + 20)
389 #define GADGET_ID_EXIT (GADGET_ID_TOOLBOX_FIRST + 21)
391 #define GADGET_ID_CUSTOM_COPY_FROM (GADGET_ID_TOOLBOX_FIRST + 22)
392 #define GADGET_ID_CUSTOM_COPY_TO (GADGET_ID_TOOLBOX_FIRST + 23)
393 #define GADGET_ID_CUSTOM_EXCHANGE (GADGET_ID_TOOLBOX_FIRST + 24)
394 #define GADGET_ID_CUSTOM_COPY (GADGET_ID_TOOLBOX_FIRST + 25)
395 #define GADGET_ID_CUSTOM_PASTE (GADGET_ID_TOOLBOX_FIRST + 26)
397 #define GADGET_ID_PROPERTIES (GADGET_ID_TOOLBOX_FIRST + 27)
398 #define GADGET_ID_ELEMENT_LEFT (GADGET_ID_TOOLBOX_FIRST + 28)
399 #define GADGET_ID_ELEMENT_MIDDLE (GADGET_ID_TOOLBOX_FIRST + 29)
400 #define GADGET_ID_ELEMENT_RIGHT (GADGET_ID_TOOLBOX_FIRST + 30)
401 #define GADGET_ID_PALETTE (GADGET_ID_TOOLBOX_FIRST + 31)
403 /* counter gadget identifiers */
404 #define GADGET_ID_COUNTER_FIRST (GADGET_ID_TOOLBOX_FIRST + 32)
406 #define GADGET_ID_SELECT_LEVEL_DOWN (GADGET_ID_COUNTER_FIRST + 0)
407 #define GADGET_ID_SELECT_LEVEL_TEXT (GADGET_ID_COUNTER_FIRST + 1)
408 #define GADGET_ID_SELECT_LEVEL_UP (GADGET_ID_COUNTER_FIRST + 2)
409 #define GADGET_ID_LEVEL_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 3)
410 #define GADGET_ID_LEVEL_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 4)
411 #define GADGET_ID_LEVEL_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 5)
412 #define GADGET_ID_LEVEL_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 6)
413 #define GADGET_ID_LEVEL_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 7)
414 #define GADGET_ID_LEVEL_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 8)
415 #define GADGET_ID_LEVEL_RANDOM_DOWN (GADGET_ID_COUNTER_FIRST + 9)
416 #define GADGET_ID_LEVEL_RANDOM_TEXT (GADGET_ID_COUNTER_FIRST + 10)
417 #define GADGET_ID_LEVEL_RANDOM_UP (GADGET_ID_COUNTER_FIRST + 11)
418 #define GADGET_ID_LEVEL_GEMSLIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 12)
419 #define GADGET_ID_LEVEL_GEMSLIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 13)
420 #define GADGET_ID_LEVEL_GEMSLIMIT_UP (GADGET_ID_COUNTER_FIRST + 14)
421 #define GADGET_ID_LEVEL_TIMELIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 15)
422 #define GADGET_ID_LEVEL_TIMELIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 16)
423 #define GADGET_ID_LEVEL_TIMELIMIT_UP (GADGET_ID_COUNTER_FIRST + 17)
424 #define GADGET_ID_LEVEL_TIMESCORE_DOWN (GADGET_ID_COUNTER_FIRST + 18)
425 #define GADGET_ID_LEVEL_TIMESCORE_TEXT (GADGET_ID_COUNTER_FIRST + 19)
426 #define GADGET_ID_LEVEL_TIMESCORE_UP (GADGET_ID_COUNTER_FIRST + 20)
427 #define GADGET_ID_LEVEL_RANDOM_SEED_DOWN (GADGET_ID_COUNTER_FIRST + 21)
428 #define GADGET_ID_LEVEL_RANDOM_SEED_TEXT (GADGET_ID_COUNTER_FIRST + 22)
429 #define GADGET_ID_LEVEL_RANDOM_SEED_UP (GADGET_ID_COUNTER_FIRST + 23)
430 #define GADGET_ID_LEVELSET_NUM_LEVELS_DOWN (GADGET_ID_COUNTER_FIRST + 24)
431 #define GADGET_ID_LEVELSET_NUM_LEVELS_TEXT (GADGET_ID_COUNTER_FIRST + 25)
432 #define GADGET_ID_LEVELSET_NUM_LEVELS_UP (GADGET_ID_COUNTER_FIRST + 26)
433 #define GADGET_ID_ELEMENT_VALUE1_DOWN (GADGET_ID_COUNTER_FIRST + 27)
434 #define GADGET_ID_ELEMENT_VALUE1_TEXT (GADGET_ID_COUNTER_FIRST + 28)
435 #define GADGET_ID_ELEMENT_VALUE1_UP (GADGET_ID_COUNTER_FIRST + 29)
436 #define GADGET_ID_ELEMENT_VALUE2_DOWN (GADGET_ID_COUNTER_FIRST + 30)
437 #define GADGET_ID_ELEMENT_VALUE2_TEXT (GADGET_ID_COUNTER_FIRST + 31)
438 #define GADGET_ID_ELEMENT_VALUE2_UP (GADGET_ID_COUNTER_FIRST + 32)
439 #define GADGET_ID_ELEMENT_VALUE3_DOWN (GADGET_ID_COUNTER_FIRST + 33)
440 #define GADGET_ID_ELEMENT_VALUE3_TEXT (GADGET_ID_COUNTER_FIRST + 34)
441 #define GADGET_ID_ELEMENT_VALUE3_UP (GADGET_ID_COUNTER_FIRST + 35)
442 #define GADGET_ID_ELEMENT_VALUE4_DOWN (GADGET_ID_COUNTER_FIRST + 36)
443 #define GADGET_ID_ELEMENT_VALUE4_TEXT (GADGET_ID_COUNTER_FIRST + 37)
444 #define GADGET_ID_ELEMENT_VALUE4_UP (GADGET_ID_COUNTER_FIRST + 38)
445 #define GADGET_ID_YAMYAM_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 39)
446 #define GADGET_ID_YAMYAM_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 40)
447 #define GADGET_ID_YAMYAM_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 41)
448 #define GADGET_ID_BALL_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 42)
449 #define GADGET_ID_BALL_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 43)
450 #define GADGET_ID_BALL_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 44)
451 #define GADGET_ID_ANDROID_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 45)
452 #define GADGET_ID_ANDROID_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 46)
453 #define GADGET_ID_ANDROID_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 47)
454 #define GADGET_ID_ENVELOPE_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 48)
455 #define GADGET_ID_ENVELOPE_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 49)
456 #define GADGET_ID_ENVELOPE_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 50)
457 #define GADGET_ID_ENVELOPE_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 51)
458 #define GADGET_ID_ENVELOPE_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 52)
459 #define GADGET_ID_ENVELOPE_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 53)
460 #define GADGET_ID_INVENTORY_SIZE_DOWN (GADGET_ID_COUNTER_FIRST + 54)
461 #define GADGET_ID_INVENTORY_SIZE_TEXT (GADGET_ID_COUNTER_FIRST + 55)
462 #define GADGET_ID_INVENTORY_SIZE_UP (GADGET_ID_COUNTER_FIRST + 56)
463 #define GADGET_ID_CUSTOM_SCORE_DOWN (GADGET_ID_COUNTER_FIRST + 57)
464 #define GADGET_ID_CUSTOM_SCORE_TEXT (GADGET_ID_COUNTER_FIRST + 58)
465 #define GADGET_ID_CUSTOM_SCORE_UP (GADGET_ID_COUNTER_FIRST + 59)
466 #define GADGET_ID_CUSTOM_GEMCOUNT_DOWN (GADGET_ID_COUNTER_FIRST + 60)
467 #define GADGET_ID_CUSTOM_GEMCOUNT_TEXT (GADGET_ID_COUNTER_FIRST + 61)
468 #define GADGET_ID_CUSTOM_GEMCOUNT_UP (GADGET_ID_COUNTER_FIRST + 62)
469 #define GADGET_ID_CUSTOM_VALUE_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 63)
470 #define GADGET_ID_CUSTOM_VALUE_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 64)
471 #define GADGET_ID_CUSTOM_VALUE_FIX_UP (GADGET_ID_COUNTER_FIRST + 65)
472 #define GADGET_ID_CUSTOM_VALUE_RND_DOWN (GADGET_ID_COUNTER_FIRST + 66)
473 #define GADGET_ID_CUSTOM_VALUE_RND_TEXT (GADGET_ID_COUNTER_FIRST + 67)
474 #define GADGET_ID_CUSTOM_VALUE_RND_UP (GADGET_ID_COUNTER_FIRST + 68)
475 #define GADGET_ID_PUSH_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 69)
476 #define GADGET_ID_PUSH_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 70)
477 #define GADGET_ID_PUSH_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 71)
478 #define GADGET_ID_PUSH_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 72)
479 #define GADGET_ID_PUSH_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 73)
480 #define GADGET_ID_PUSH_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 74)
481 #define GADGET_ID_DROP_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 75)
482 #define GADGET_ID_DROP_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 76)
483 #define GADGET_ID_DROP_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 77)
484 #define GADGET_ID_DROP_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 78)
485 #define GADGET_ID_DROP_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 79)
486 #define GADGET_ID_DROP_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 80)
487 #define GADGET_ID_MOVE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 81)
488 #define GADGET_ID_MOVE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 82)
489 #define GADGET_ID_MOVE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 83)
490 #define GADGET_ID_MOVE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 84)
491 #define GADGET_ID_MOVE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 85)
492 #define GADGET_ID_MOVE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 86)
493 #define GADGET_ID_EXPLOSION_DELAY_DOWN (GADGET_ID_COUNTER_FIRST + 87)
494 #define GADGET_ID_EXPLOSION_DELAY_TEXT (GADGET_ID_COUNTER_FIRST + 88)
495 #define GADGET_ID_EXPLOSION_DELAY_UP (GADGET_ID_COUNTER_FIRST + 89)
496 #define GADGET_ID_IGNITION_DELAY_DOWN (GADGET_ID_COUNTER_FIRST + 90)
497 #define GADGET_ID_IGNITION_DELAY_TEXT (GADGET_ID_COUNTER_FIRST + 91)
498 #define GADGET_ID_IGNITION_DELAY_UP (GADGET_ID_COUNTER_FIRST + 92)
499 #define GADGET_ID_CHANGE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 93)
500 #define GADGET_ID_CHANGE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 94)
501 #define GADGET_ID_CHANGE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 95)
502 #define GADGET_ID_CHANGE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 96)
503 #define GADGET_ID_CHANGE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 97)
504 #define GADGET_ID_CHANGE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 98)
505 #define GADGET_ID_CHANGE_CONT_RND_DOWN (GADGET_ID_COUNTER_FIRST + 99)
506 #define GADGET_ID_CHANGE_CONT_RND_TEXT (GADGET_ID_COUNTER_FIRST + 100)
507 #define GADGET_ID_CHANGE_CONT_RND_UP (GADGET_ID_COUNTER_FIRST + 101)
508 #define GADGET_ID_GROUP_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 102)
509 #define GADGET_ID_GROUP_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 103)
510 #define GADGET_ID_GROUP_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 104)
512 /* drawing area identifiers */
513 #define GADGET_ID_DRAWING_AREA_FIRST (GADGET_ID_COUNTER_FIRST + 105)
515 #define GADGET_ID_DRAWING_LEVEL (GADGET_ID_DRAWING_AREA_FIRST + 0)
516 #define GADGET_ID_YAMYAM_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 1)
517 #define GADGET_ID_YAMYAM_CONTENT_1 (GADGET_ID_DRAWING_AREA_FIRST + 2)
518 #define GADGET_ID_YAMYAM_CONTENT_2 (GADGET_ID_DRAWING_AREA_FIRST + 3)
519 #define GADGET_ID_YAMYAM_CONTENT_3 (GADGET_ID_DRAWING_AREA_FIRST + 4)
520 #define GADGET_ID_YAMYAM_CONTENT_4 (GADGET_ID_DRAWING_AREA_FIRST + 5)
521 #define GADGET_ID_YAMYAM_CONTENT_5 (GADGET_ID_DRAWING_AREA_FIRST + 6)
522 #define GADGET_ID_YAMYAM_CONTENT_6 (GADGET_ID_DRAWING_AREA_FIRST + 7)
523 #define GADGET_ID_YAMYAM_CONTENT_7 (GADGET_ID_DRAWING_AREA_FIRST + 8)
524 #define GADGET_ID_MAGIC_BALL_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 9)
525 #define GADGET_ID_MAGIC_BALL_CONTENT_1 (GADGET_ID_DRAWING_AREA_FIRST + 10)
526 #define GADGET_ID_MAGIC_BALL_CONTENT_2 (GADGET_ID_DRAWING_AREA_FIRST + 11)
527 #define GADGET_ID_MAGIC_BALL_CONTENT_3 (GADGET_ID_DRAWING_AREA_FIRST + 12)
528 #define GADGET_ID_MAGIC_BALL_CONTENT_4 (GADGET_ID_DRAWING_AREA_FIRST + 13)
529 #define GADGET_ID_MAGIC_BALL_CONTENT_5 (GADGET_ID_DRAWING_AREA_FIRST + 14)
530 #define GADGET_ID_MAGIC_BALL_CONTENT_6 (GADGET_ID_DRAWING_AREA_FIRST + 15)
531 #define GADGET_ID_MAGIC_BALL_CONTENT_7 (GADGET_ID_DRAWING_AREA_FIRST + 16)
532 #define GADGET_ID_ANDROID_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 17)
533 #define GADGET_ID_AMOEBA_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 18)
534 #define GADGET_ID_START_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 19)
535 #define GADGET_ID_ARTWORK_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 20)
536 #define GADGET_ID_EXPLOSION_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 21)
537 #define GADGET_ID_INVENTORY_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 22)
538 #define GADGET_ID_CUSTOM_GRAPHIC (GADGET_ID_DRAWING_AREA_FIRST + 23)
539 #define GADGET_ID_CUSTOM_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 24)
540 #define GADGET_ID_CUSTOM_MOVE_ENTER (GADGET_ID_DRAWING_AREA_FIRST + 25)
541 #define GADGET_ID_CUSTOM_MOVE_LEAVE (GADGET_ID_DRAWING_AREA_FIRST + 26)
542 #define GADGET_ID_CUSTOM_CHANGE_TARGET (GADGET_ID_DRAWING_AREA_FIRST + 27)
543 #define GADGET_ID_CUSTOM_CHANGE_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 28)
544 #define GADGET_ID_CUSTOM_CHANGE_TRIGGER (GADGET_ID_DRAWING_AREA_FIRST + 29)
545 #define GADGET_ID_CUSTOM_CHANGE_ACTION (GADGET_ID_DRAWING_AREA_FIRST + 30)
546 #define GADGET_ID_GROUP_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 31)
547 #define GADGET_ID_RANDOM_BACKGROUND (GADGET_ID_DRAWING_AREA_FIRST + 32)
549 /* text input identifiers */
550 #define GADGET_ID_TEXT_INPUT_FIRST (GADGET_ID_DRAWING_AREA_FIRST + 33)
552 #define GADGET_ID_LEVEL_NAME (GADGET_ID_TEXT_INPUT_FIRST + 0)
553 #define GADGET_ID_LEVEL_AUTHOR (GADGET_ID_TEXT_INPUT_FIRST + 1)
554 #define GADGET_ID_LEVELSET_NAME (GADGET_ID_TEXT_INPUT_FIRST + 2)
555 #define GADGET_ID_LEVELSET_AUTHOR (GADGET_ID_TEXT_INPUT_FIRST + 3)
556 #define GADGET_ID_ELEMENT_NAME (GADGET_ID_TEXT_INPUT_FIRST + 4)
558 /* text area identifiers */
559 #define GADGET_ID_TEXT_AREA_FIRST (GADGET_ID_TEXT_INPUT_FIRST + 5)
561 #define GADGET_ID_ENVELOPE_INFO (GADGET_ID_TEXT_AREA_FIRST + 0)
563 /* selectbox identifiers */
564 #define GADGET_ID_SELECTBOX_FIRST (GADGET_ID_TEXT_AREA_FIRST + 1)
566 #define GADGET_ID_TIME_OR_STEPS (GADGET_ID_SELECTBOX_FIRST + 0)
567 #define GADGET_ID_GAME_ENGINE_TYPE (GADGET_ID_SELECTBOX_FIRST + 1)
568 #define GADGET_ID_LEVELSET_SAVE_MODE (GADGET_ID_SELECTBOX_FIRST + 2)
569 #define GADGET_ID_WIND_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 3)
570 #define GADGET_ID_PLAYER_SPEED (GADGET_ID_SELECTBOX_FIRST + 4)
571 #define GADGET_ID_CUSTOM_WALK_TO_ACTION (GADGET_ID_SELECTBOX_FIRST + 5)
572 #define GADGET_ID_CUSTOM_EXPLOSION_TYPE (GADGET_ID_SELECTBOX_FIRST + 6)
573 #define GADGET_ID_CUSTOM_DEADLINESS (GADGET_ID_SELECTBOX_FIRST + 7)
574 #define GADGET_ID_CUSTOM_MOVE_PATTERN (GADGET_ID_SELECTBOX_FIRST + 8)
575 #define GADGET_ID_CUSTOM_MOVE_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 9)
576 #define GADGET_ID_CUSTOM_MOVE_STEPSIZE (GADGET_ID_SELECTBOX_FIRST + 10)
577 #define GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE (GADGET_ID_SELECTBOX_FIRST + 11)
578 #define GADGET_ID_CUSTOM_SMASH_TARGETS (GADGET_ID_SELECTBOX_FIRST + 12)
579 #define GADGET_ID_CUSTOM_SLIPPERY_TYPE (GADGET_ID_SELECTBOX_FIRST + 13)
580 #define GADGET_ID_CUSTOM_ACCESS_TYPE (GADGET_ID_SELECTBOX_FIRST + 14)
581 #define GADGET_ID_CUSTOM_ACCESS_LAYER (GADGET_ID_SELECTBOX_FIRST + 15)
582 #define GADGET_ID_CUSTOM_ACCESS_PROTECTED (GADGET_ID_SELECTBOX_FIRST + 16)
583 #define GADGET_ID_CUSTOM_ACCESS_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 17)
584 #define GADGET_ID_CHANGE_TIME_UNITS (GADGET_ID_SELECTBOX_FIRST + 18)
585 #define GADGET_ID_CHANGE_DIRECT_ACTION (GADGET_ID_SELECTBOX_FIRST + 19)
586 #define GADGET_ID_CHANGE_OTHER_ACTION (GADGET_ID_SELECTBOX_FIRST + 20)
587 #define GADGET_ID_CHANGE_SIDE (GADGET_ID_SELECTBOX_FIRST + 21)
588 #define GADGET_ID_CHANGE_PLAYER (GADGET_ID_SELECTBOX_FIRST + 22)
589 #define GADGET_ID_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 23)
590 #define GADGET_ID_CHANGE_REPLACE_WHEN (GADGET_ID_SELECTBOX_FIRST + 24)
591 #define GADGET_ID_ACTION_TYPE (GADGET_ID_SELECTBOX_FIRST + 25)
592 #define GADGET_ID_ACTION_MODE (GADGET_ID_SELECTBOX_FIRST + 26)
593 #define GADGET_ID_ACTION_ARG (GADGET_ID_SELECTBOX_FIRST + 27)
594 #define GADGET_ID_SELECT_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 28)
595 #define GADGET_ID_GROUP_CHOICE_MODE (GADGET_ID_SELECTBOX_FIRST + 29)
597 /* textbutton identifiers */
598 #define GADGET_ID_TEXTBUTTON_FIRST (GADGET_ID_SELECTBOX_FIRST + 30)
600 #define GADGET_ID_LEVELINFO_LEVEL (GADGET_ID_TEXTBUTTON_FIRST + 0)
601 #define GADGET_ID_LEVELINFO_LEVELSET (GADGET_ID_TEXTBUTTON_FIRST + 1)
602 #define GADGET_ID_LEVELINFO_EDITOR (GADGET_ID_TEXTBUTTON_FIRST + 2)
603 #define GADGET_ID_PROPERTIES_INFO (GADGET_ID_TEXTBUTTON_FIRST + 3)
604 #define GADGET_ID_PROPERTIES_CONFIG (GADGET_ID_TEXTBUTTON_FIRST + 4)
605 #define GADGET_ID_PROPERTIES_CONFIG_1 (GADGET_ID_TEXTBUTTON_FIRST + 5)
606 #define GADGET_ID_PROPERTIES_CONFIG_2 (GADGET_ID_TEXTBUTTON_FIRST + 6)
607 #define GADGET_ID_PROPERTIES_CHANGE (GADGET_ID_TEXTBUTTON_FIRST + 7)
608 #define GADGET_ID_SAVE_AS_TEMPLATE_1 (GADGET_ID_TEXTBUTTON_FIRST + 8)
609 #define GADGET_ID_SAVE_AS_TEMPLATE_2 (GADGET_ID_TEXTBUTTON_FIRST + 9)
610 #define GADGET_ID_SAVE_LEVELSET (GADGET_ID_TEXTBUTTON_FIRST + 10)
611 #define GADGET_ID_ADD_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 11)
612 #define GADGET_ID_DEL_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 12)
614 /* graphicbutton identifiers */
615 #define GADGET_ID_GRAPHICBUTTON_FIRST (GADGET_ID_TEXTBUTTON_FIRST + 13)
617 #define GADGET_ID_PREV_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 0)
618 #define GADGET_ID_NEXT_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 1)
619 #define GADGET_ID_COPY_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 2)
620 #define GADGET_ID_PASTE_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 3)
622 /* gadgets for scrolling of drawing area */
623 #define GADGET_ID_SCROLLING_FIRST (GADGET_ID_GRAPHICBUTTON_FIRST + 4)
625 #define GADGET_ID_SCROLL_UP (GADGET_ID_SCROLLING_FIRST + 0)
626 #define GADGET_ID_SCROLL_DOWN (GADGET_ID_SCROLLING_FIRST + 1)
627 #define GADGET_ID_SCROLL_LEFT (GADGET_ID_SCROLLING_FIRST + 2)
628 #define GADGET_ID_SCROLL_RIGHT (GADGET_ID_SCROLLING_FIRST + 3)
629 #define GADGET_ID_SCROLL_HORIZONTAL (GADGET_ID_SCROLLING_FIRST + 4)
630 #define GADGET_ID_SCROLL_VERTICAL (GADGET_ID_SCROLLING_FIRST + 5)
632 /* gadgets for scrolling element list */
633 #define GADGET_ID_SCROLLING_LIST_FIRST (GADGET_ID_SCROLLING_FIRST + 6)
635 #define GADGET_ID_SCROLL_LIST_UP (GADGET_ID_SCROLLING_LIST_FIRST + 0)
636 #define GADGET_ID_SCROLL_LIST_DOWN (GADGET_ID_SCROLLING_LIST_FIRST + 1)
637 #define GADGET_ID_SCROLL_LIST_VERTICAL (GADGET_ID_SCROLLING_LIST_FIRST + 2)
639 /* checkbuttons/radiobuttons for level/element properties */
640 #define GADGET_ID_CHECKBUTTON_FIRST (GADGET_ID_SCROLLING_LIST_FIRST + 3)
642 #define GADGET_ID_AUTO_COUNT_GEMS (GADGET_ID_CHECKBUTTON_FIRST + 0)
643 #define GADGET_ID_USE_LEVELSET_ARTWORK (GADGET_ID_CHECKBUTTON_FIRST + 1)
644 #define GADGET_ID_COPY_LEVEL_TEMPLATE (GADGET_ID_CHECKBUTTON_FIRST + 2)
645 #define GADGET_ID_RANDOM_PERCENTAGE (GADGET_ID_CHECKBUTTON_FIRST + 3)
646 #define GADGET_ID_RANDOM_QUANTITY (GADGET_ID_CHECKBUTTON_FIRST + 4)
647 #define GADGET_ID_RANDOM_RESTRICTED (GADGET_ID_CHECKBUTTON_FIRST + 5)
648 #define GADGET_ID_STICK_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 6)
649 #define GADGET_ID_EM_SLIPPERY_GEMS (GADGET_ID_CHECKBUTTON_FIRST + 7)
650 #define GADGET_ID_EM_EXPLODES_BY_FIRE (GADGET_ID_CHECKBUTTON_FIRST + 8)
651 #define GADGET_ID_USE_SPRING_BUG (GADGET_ID_CHECKBUTTON_FIRST + 9)
652 #define GADGET_ID_USE_TIME_ORB_BUG (GADGET_ID_CHECKBUTTON_FIRST + 10)
653 #define GADGET_ID_USE_LIFE_BUGS (GADGET_ID_CHECKBUTTON_FIRST + 11)
654 #define GADGET_ID_RANDOM_BALL_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 12)
655 #define GADGET_ID_INITIAL_BALL_STATE (GADGET_ID_CHECKBUTTON_FIRST + 13)
656 #define GADGET_ID_GROW_INTO_DIGGABLE (GADGET_ID_CHECKBUTTON_FIRST + 14)
657 #define GADGET_ID_AUTO_EXIT_SOKOBAN (GADGET_ID_CHECKBUTTON_FIRST + 15)
658 #define GADGET_ID_SOLVED_BY_ONE_PLAYER (GADGET_ID_CHECKBUTTON_FIRST + 16)
659 #define GADGET_ID_CONTINUOUS_SNAPPING (GADGET_ID_CHECKBUTTON_FIRST + 17)
660 #define GADGET_ID_BLOCK_SNAP_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 18)
661 #define GADGET_ID_BLOCK_LAST_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 19)
662 #define GADGET_ID_SP_BLOCK_LAST_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 20)
663 #define GADGET_ID_INSTANT_RELOCATION (GADGET_ID_CHECKBUTTON_FIRST + 21)
664 #define GADGET_ID_SHIFTED_RELOCATION (GADGET_ID_CHECKBUTTON_FIRST + 22)
665 #define GADGET_ID_LAZY_RELOCATION (GADGET_ID_CHECKBUTTON_FIRST + 23)
666 #define GADGET_ID_USE_START_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 24)
667 #define GADGET_ID_USE_ARTWORK_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 25)
668 #define GADGET_ID_USE_EXPLOSION_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 26)
669 #define GADGET_ID_INITIAL_GRAVITY (GADGET_ID_CHECKBUTTON_FIRST + 27)
670 #define GADGET_ID_USE_INITIAL_INVENTORY (GADGET_ID_CHECKBUTTON_FIRST + 28)
671 #define GADGET_ID_CAN_PASS_TO_WALKABLE (GADGET_ID_CHECKBUTTON_FIRST + 29)
672 #define GADGET_ID_CAN_FALL_INTO_ACID (GADGET_ID_CHECKBUTTON_FIRST + 30)
673 #define GADGET_ID_CAN_MOVE_INTO_ACID (GADGET_ID_CHECKBUTTON_FIRST + 31)
674 #define GADGET_ID_DONT_COLLIDE_WITH (GADGET_ID_CHECKBUTTON_FIRST + 32)
675 #define GADGET_ID_ENVELOPE_AUTOWRAP (GADGET_ID_CHECKBUTTON_FIRST + 33)
676 #define GADGET_ID_ENVELOPE_CENTERED (GADGET_ID_CHECKBUTTON_FIRST + 34)
677 #define GADGET_ID_MM_LASER_RED (GADGET_ID_CHECKBUTTON_FIRST + 35)
678 #define GADGET_ID_MM_LASER_GREEN (GADGET_ID_CHECKBUTTON_FIRST + 36)
679 #define GADGET_ID_MM_LASER_BLUE (GADGET_ID_CHECKBUTTON_FIRST + 37)
680 #define GADGET_ID_DF_LASER_RED (GADGET_ID_CHECKBUTTON_FIRST + 38)
681 #define GADGET_ID_DF_LASER_GREEN (GADGET_ID_CHECKBUTTON_FIRST + 39)
682 #define GADGET_ID_DF_LASER_BLUE (GADGET_ID_CHECKBUTTON_FIRST + 40)
683 #define GADGET_ID_CUSTOM_INDESTRUCTIBLE (GADGET_ID_CHECKBUTTON_FIRST + 41)
684 #define GADGET_ID_CUSTOM_CAN_EXPLODE (GADGET_ID_CHECKBUTTON_FIRST + 42)
685 #define GADGET_ID_CUSTOM_EXPLODE_FIRE (GADGET_ID_CHECKBUTTON_FIRST + 43)
686 #define GADGET_ID_CUSTOM_EXPLODE_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 44)
687 #define GADGET_ID_CUSTOM_EXPLODE_IMPACT (GADGET_ID_CHECKBUTTON_FIRST + 45)
688 #define GADGET_ID_CUSTOM_WALK_TO_OBJECT (GADGET_ID_CHECKBUTTON_FIRST + 46)
689 #define GADGET_ID_CUSTOM_DEADLY (GADGET_ID_CHECKBUTTON_FIRST + 47)
690 #define GADGET_ID_CUSTOM_CAN_MOVE (GADGET_ID_CHECKBUTTON_FIRST + 48)
691 #define GADGET_ID_CUSTOM_CAN_FALL (GADGET_ID_CHECKBUTTON_FIRST + 49)
692 #define GADGET_ID_CUSTOM_CAN_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 50)
693 #define GADGET_ID_CUSTOM_SLIPPERY (GADGET_ID_CHECKBUTTON_FIRST + 51)
694 #define GADGET_ID_CUSTOM_ACCESSIBLE (GADGET_ID_CHECKBUTTON_FIRST + 52)
695 #define GADGET_ID_CUSTOM_GRAV_REACHABLE (GADGET_ID_CHECKBUTTON_FIRST + 53)
696 #define GADGET_ID_CUSTOM_USE_LAST_VALUE (GADGET_ID_CHECKBUTTON_FIRST + 54)
697 #define GADGET_ID_CUSTOM_USE_GRAPHIC (GADGET_ID_CHECKBUTTON_FIRST + 55)
698 #define GADGET_ID_CUSTOM_USE_TEMPLATE_1 (GADGET_ID_CHECKBUTTON_FIRST + 56)
699 #define GADGET_ID_CUSTOM_USE_TEMPLATE_2 (GADGET_ID_CHECKBUTTON_FIRST + 57)
700 #define GADGET_ID_CUSTOM_USE_TEMPLATE_3 (GADGET_ID_CHECKBUTTON_FIRST + 58)
701 #define GADGET_ID_CUSTOM_CAN_CHANGE (GADGET_ID_CHECKBUTTON_FIRST + 59)
702 #define GADGET_ID_CHANGE_USE_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 60)
703 #define GADGET_ID_CHANGE_USE_EXPLOSION (GADGET_ID_CHECKBUTTON_FIRST + 61)
704 #define GADGET_ID_CHANGE_ONLY_COMPLETE (GADGET_ID_CHECKBUTTON_FIRST + 62)
705 #define GADGET_ID_CHANGE_USE_RANDOM (GADGET_ID_CHECKBUTTON_FIRST + 63)
706 #define GADGET_ID_CHANGE_HAS_ACTION (GADGET_ID_CHECKBUTTON_FIRST + 64)
707 #define GADGET_ID_CHANGE_DELAY (GADGET_ID_CHECKBUTTON_FIRST + 65)
708 #define GADGET_ID_CHANGE_BY_DIRECT_ACT (GADGET_ID_CHECKBUTTON_FIRST + 66)
709 #define GADGET_ID_CHANGE_BY_OTHER_ACT (GADGET_ID_CHECKBUTTON_FIRST + 67)
711 /* gadgets for buttons in element list */
712 #define GADGET_ID_ELEMENTLIST_FIRST (GADGET_ID_CHECKBUTTON_FIRST + 68)
713 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
714 ED_NUM_ELEMENTLIST_BUTTONS - 1)
716 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
718 /* radio button numbers */
719 #define RADIO_NR_NONE 0
720 #define RADIO_NR_DRAWING_TOOLBOX 1
721 #define RADIO_NR_RANDOM_ELEMENTS 2
723 /* values for counter gadgets */
724 #define ED_COUNTER_ID_SELECT_LEVEL 0
725 #define ED_COUNTER_ID_LEVEL_XSIZE 1
726 #define ED_COUNTER_ID_LEVEL_YSIZE 2
727 #define ED_COUNTER_ID_LEVEL_GEMSLIMIT 3
728 #define ED_COUNTER_ID_LEVEL_TIMELIMIT 4
729 #define ED_COUNTER_ID_LEVEL_TIMESCORE 5
730 #define ED_COUNTER_ID_LEVEL_RANDOM_SEED 6
731 #define ED_COUNTER_ID_LEVELSET_NUM_LEVELS 7
732 #define ED_COUNTER_ID_LEVEL_RANDOM 8
733 #define ED_COUNTER_ID_ELEMENT_VALUE1 9
734 #define ED_COUNTER_ID_ELEMENT_VALUE2 10
735 #define ED_COUNTER_ID_ELEMENT_VALUE3 11
736 #define ED_COUNTER_ID_ELEMENT_VALUE4 12
737 #define ED_COUNTER_ID_YAMYAM_CONTENT 13
738 #define ED_COUNTER_ID_BALL_CONTENT 14
739 #define ED_COUNTER_ID_ANDROID_CONTENT 15
740 #define ED_COUNTER_ID_ENVELOPE_XSIZE 16
741 #define ED_COUNTER_ID_ENVELOPE_YSIZE 17
742 #define ED_COUNTER_ID_INVENTORY_SIZE 18
743 #define ED_COUNTER_ID_CUSTOM_SCORE 19
744 #define ED_COUNTER_ID_CUSTOM_GEMCOUNT 20
745 #define ED_COUNTER_ID_CUSTOM_VALUE_FIX 21
746 #define ED_COUNTER_ID_CUSTOM_VALUE_RND 22
747 #define ED_COUNTER_ID_PUSH_DELAY_FIX 23
748 #define ED_COUNTER_ID_PUSH_DELAY_RND 24
749 #define ED_COUNTER_ID_DROP_DELAY_FIX 25
750 #define ED_COUNTER_ID_DROP_DELAY_RND 26
751 #define ED_COUNTER_ID_MOVE_DELAY_FIX 27
752 #define ED_COUNTER_ID_MOVE_DELAY_RND 28
753 #define ED_COUNTER_ID_EXPLOSION_DELAY 29
754 #define ED_COUNTER_ID_IGNITION_DELAY 30
755 #define ED_COUNTER_ID_GROUP_CONTENT 31
756 #define ED_COUNTER_ID_CHANGE_DELAY_FIX 32
757 #define ED_COUNTER_ID_CHANGE_DELAY_RND 33
758 #define ED_COUNTER_ID_CHANGE_CONT_RND 34
760 #define ED_NUM_COUNTERBUTTONS 35
762 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
763 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
764 #define ED_COUNTER_ID_LEVELSET_FIRST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
765 #define ED_COUNTER_ID_LEVELSET_LAST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
766 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
767 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
769 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
770 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
771 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
772 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
773 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
774 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
776 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
777 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
779 /* values for scrollbutton gadgets */
780 #define ED_SCROLLBUTTON_ID_AREA_UP 0
781 #define ED_SCROLLBUTTON_ID_AREA_DOWN 1
782 #define ED_SCROLLBUTTON_ID_AREA_LEFT 2
783 #define ED_SCROLLBUTTON_ID_AREA_RIGHT 3
784 #define ED_SCROLLBUTTON_ID_LIST_UP 4
785 #define ED_SCROLLBUTTON_ID_LIST_DOWN 5
787 #define ED_NUM_SCROLLBUTTONS 6
789 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
790 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
792 /* values for scrollbar gadgets */
793 #define ED_SCROLLBAR_ID_AREA_HORIZONTAL 0
794 #define ED_SCROLLBAR_ID_AREA_VERTICAL 1
795 #define ED_SCROLLBAR_ID_LIST_VERTICAL 2
797 #define ED_NUM_SCROLLBARS 3
799 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
800 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
802 /* values for text input gadgets */
803 #define ED_TEXTINPUT_ID_LEVEL_NAME 0
804 #define ED_TEXTINPUT_ID_LEVEL_AUTHOR 1
805 #define ED_TEXTINPUT_ID_LEVELSET_NAME 2
806 #define ED_TEXTINPUT_ID_LEVELSET_AUTHOR 3
807 #define ED_TEXTINPUT_ID_ELEMENT_NAME 4
809 #define ED_NUM_TEXTINPUT 5
811 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
812 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
814 #define ED_TEXTINPUT_ID_LEVELSET_FIRST ED_TEXTINPUT_ID_LEVELSET_NAME
815 #define ED_TEXTINPUT_ID_LEVELSET_LAST ED_TEXTINPUT_ID_LEVELSET_AUTHOR
817 /* values for text area gadgets */
818 #define ED_TEXTAREA_ID_ENVELOPE_INFO 0
820 #define ED_NUM_TEXTAREAS 1
822 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
823 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
825 /* values for selectbox gadgets */
826 #define ED_SELECTBOX_ID_TIME_OR_STEPS 0
827 #define ED_SELECTBOX_ID_GAME_ENGINE_TYPE 1
828 #define ED_SELECTBOX_ID_LEVELSET_SAVE_MODE 2
829 #define ED_SELECTBOX_ID_WIND_DIRECTION 3
830 #define ED_SELECTBOX_ID_PLAYER_SPEED 4
831 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE 5
832 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER 6
833 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED 7
834 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION 8
835 #define ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION 9
836 #define ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN 10
837 #define ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION 11
838 #define ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE 12
839 #define ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE 13
840 #define ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS 14
841 #define ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE 15
842 #define ED_SELECTBOX_ID_CUSTOM_DEADLINESS 16
843 #define ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE 17
844 #define ED_SELECTBOX_ID_CHANGE_TIME_UNITS 18
845 #define ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION 19
846 #define ED_SELECTBOX_ID_CHANGE_OTHER_ACTION 20
847 #define ED_SELECTBOX_ID_CHANGE_SIDE 21
848 #define ED_SELECTBOX_ID_CHANGE_PLAYER 22
849 #define ED_SELECTBOX_ID_CHANGE_PAGE 23
850 #define ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN 24
851 #define ED_SELECTBOX_ID_ACTION_TYPE 25
852 #define ED_SELECTBOX_ID_ACTION_MODE 26
853 #define ED_SELECTBOX_ID_ACTION_ARG 27
854 #define ED_SELECTBOX_ID_SELECT_CHANGE_PAGE 28
855 #define ED_SELECTBOX_ID_GROUP_CHOICE_MODE 29
857 #define ED_NUM_SELECTBOX 30
859 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
860 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_GAME_ENGINE_TYPE
862 #define ED_SELECTBOX_ID_LEVELSET_FIRST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
863 #define ED_SELECTBOX_ID_LEVELSET_LAST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
865 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
866 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
867 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
868 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
869 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
870 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
872 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
873 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
875 /* values for textbutton gadgets */
876 #define ED_TEXTBUTTON_ID_LEVELINFO_LEVEL 0
877 #define ED_TEXTBUTTON_ID_LEVELINFO_LEVELSET 1
878 #define ED_TEXTBUTTON_ID_LEVELINFO_EDITOR 2
879 #define ED_TEXTBUTTON_ID_PROPERTIES_INFO 3
880 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG 4
881 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1 5
882 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2 6
883 #define ED_TEXTBUTTON_ID_PROPERTIES_CHANGE 7
884 #define ED_TEXTBUTTON_ID_SAVE_LEVELSET 8
885 #define ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2 9
886 #define ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 10
887 #define ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE 11
888 #define ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE 12
890 #define ED_NUM_TEXTBUTTONS 13
892 #define ED_TAB_BUTTON_ID_LEVELINFO_FIRST ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
893 #define ED_TAB_BUTTON_ID_LEVELINFO_LAST ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
895 #define ED_TAB_BUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
896 #define ED_TAB_BUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
898 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
899 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
901 /* values for graphicbutton gadgets */
902 #define ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE 0
903 #define ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE 1
904 #define ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE 2
905 #define ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE 3
907 #define ED_NUM_GRAPHICBUTTONS 4
909 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
910 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
912 /* values for checkbutton gadgets */
913 #define ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS 0
914 #define ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK 1
915 #define ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE 2
916 #define ED_CHECKBUTTON_ID_RANDOM_RESTRICTED 3
917 #define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3 4
918 #define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2 5
919 #define ED_CHECKBUTTON_ID_STICK_ELEMENT 6
920 #define ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS 7
921 #define ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE 8
922 #define ED_CHECKBUTTON_ID_USE_SPRING_BUG 9
923 #define ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG 10
924 #define ED_CHECKBUTTON_ID_USE_LIFE_BUGS 11
925 #define ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT 12
926 #define ED_CHECKBUTTON_ID_INITIAL_BALL_STATE 13
927 #define ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE 14
928 #define ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN 15
929 #define ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER 16
930 #define ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING 17
931 #define ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD 18
932 #define ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD 19
933 #define ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD 20
934 #define ED_CHECKBUTTON_ID_INSTANT_RELOCATION 21
935 #define ED_CHECKBUTTON_ID_SHIFTED_RELOCATION 22
936 #define ED_CHECKBUTTON_ID_LAZY_RELOCATION 23
937 #define ED_CHECKBUTTON_ID_USE_START_ELEMENT 24
938 #define ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT 25
939 #define ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT 26
940 #define ED_CHECKBUTTON_ID_INITIAL_GRAVITY 27
941 #define ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY 28
942 #define ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE 29
943 #define ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID 30
944 #define ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID 31
945 #define ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH 32
946 #define ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP 33
947 #define ED_CHECKBUTTON_ID_ENVELOPE_CENTERED 34
948 #define ED_CHECKBUTTON_ID_MM_LASER_RED 35
949 #define ED_CHECKBUTTON_ID_MM_LASER_GREEN 36
950 #define ED_CHECKBUTTON_ID_MM_LASER_BLUE 37
951 #define ED_CHECKBUTTON_ID_DF_LASER_RED 38
952 #define ED_CHECKBUTTON_ID_DF_LASER_GREEN 39
953 #define ED_CHECKBUTTON_ID_DF_LASER_BLUE 40
954 #define ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC 41
955 #define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 42
956 #define ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE 43
957 #define ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE 44
958 #define ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE 45
959 #define ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT 46
960 #define ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE 47
961 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE 48
962 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL 49
963 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH 50
964 #define ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY 51
965 #define ED_CHECKBUTTON_ID_CUSTOM_DEADLY 52
966 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE 53
967 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE 54
968 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH 55
969 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT 56
970 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE 57
971 #define ED_CHECKBUTTON_ID_CHANGE_DELAY 58
972 #define ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT 59
973 #define ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT 60
974 #define ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION 61
975 #define ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT 62
976 #define ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE 63
977 #define ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM 64
978 #define ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION 65
980 #define ED_NUM_CHECKBUTTONS 66
982 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
983 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
985 #define ED_CHECKBUTTON_ID_LEVELSET_FIRST ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK
986 #define ED_CHECKBUTTON_ID_LEVELSET_LAST ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE
988 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
989 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2
991 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
992 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
993 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
994 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
995 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
996 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
998 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
999 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
1001 /* values for radiobutton gadgets */
1002 #define ED_RADIOBUTTON_ID_PERCENTAGE 0
1003 #define ED_RADIOBUTTON_ID_QUANTITY 1
1005 #define ED_NUM_RADIOBUTTONS 2
1007 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
1008 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
1010 /* values for drawing area gadgets */
1011 #define ED_DRAWING_ID_DRAWING_LEVEL 0
1012 #define ED_DRAWING_ID_YAMYAM_CONTENT_0 1
1013 #define ED_DRAWING_ID_YAMYAM_CONTENT_1 2
1014 #define ED_DRAWING_ID_YAMYAM_CONTENT_2 3
1015 #define ED_DRAWING_ID_YAMYAM_CONTENT_3 4
1016 #define ED_DRAWING_ID_YAMYAM_CONTENT_4 5
1017 #define ED_DRAWING_ID_YAMYAM_CONTENT_5 6
1018 #define ED_DRAWING_ID_YAMYAM_CONTENT_6 7
1019 #define ED_DRAWING_ID_YAMYAM_CONTENT_7 8
1020 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 9
1021 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_1 10
1022 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_2 11
1023 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_3 12
1024 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_4 13
1025 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_5 14
1026 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_6 15
1027 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_7 16
1028 #define ED_DRAWING_ID_ANDROID_CONTENT 17
1029 #define ED_DRAWING_ID_AMOEBA_CONTENT 18
1030 #define ED_DRAWING_ID_START_ELEMENT 19
1031 #define ED_DRAWING_ID_ARTWORK_ELEMENT 20
1032 #define ED_DRAWING_ID_EXPLOSION_ELEMENT 21
1033 #define ED_DRAWING_ID_INVENTORY_CONTENT 22
1034 #define ED_DRAWING_ID_CUSTOM_GRAPHIC 23
1035 #define ED_DRAWING_ID_CUSTOM_CONTENT 24
1036 #define ED_DRAWING_ID_CUSTOM_MOVE_ENTER 25
1037 #define ED_DRAWING_ID_CUSTOM_MOVE_LEAVE 26
1038 #define ED_DRAWING_ID_CUSTOM_CHANGE_TARGET 27
1039 #define ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT 28
1040 #define ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER 29
1041 #define ED_DRAWING_ID_CUSTOM_CHANGE_ACTION 30
1042 #define ED_DRAWING_ID_GROUP_CONTENT 31
1043 #define ED_DRAWING_ID_RANDOM_BACKGROUND 32
1045 #define ED_NUM_DRAWING_AREAS 33
1047 #define ED_DRAWING_ID_EDITOR_FIRST ED_DRAWING_ID_RANDOM_BACKGROUND
1048 #define ED_DRAWING_ID_EDITOR_LAST ED_DRAWING_ID_RANDOM_BACKGROUND
1052 -----------------------------------------------------------------------------
1053 some internally used definitions
1054 -----------------------------------------------------------------------------
1057 /* values for CopyLevelToUndoBuffer() */
1058 #define UNDO_IMMEDIATE 0
1059 #define UNDO_ACCUMULATE 1
1061 /* values for scrollbars */
1062 #define ED_SCROLL_NO 0
1063 #define ED_SCROLL_LEFT 1
1064 #define ED_SCROLL_RIGHT 2
1065 #define ED_SCROLL_UP 4
1066 #define ED_SCROLL_DOWN 8
1068 /* screens in the level editor */
1069 #define ED_MODE_DRAWING 0
1070 #define ED_MODE_INFO 1
1071 #define ED_MODE_PROPERTIES 2
1072 #define ED_MODE_PALETTE 3
1074 /* sub-screens in the global settings section */
1075 #define ED_MODE_LEVELINFO_LEVEL ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
1076 #define ED_MODE_LEVELINFO_LEVELSET ED_TEXTBUTTON_ID_LEVELINFO_LEVELSET
1077 #define ED_MODE_LEVELINFO_EDITOR ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
1079 /* sub-screens in the element properties section */
1080 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
1081 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
1082 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
1083 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
1084 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
1086 /* how many steps can be cancelled */
1087 #define NUM_UNDO_STEPS (64 + 1)
1089 /* values for elements with score for certain actions */
1091 #define MAX_SCORE 999
1093 /* values for elements with count for collecting */
1094 #define MIN_COLLECT_COUNT 0
1095 #define MAX_COLLECT_COUNT 999
1097 /* values for random placement */
1098 #define RANDOM_USE_PERCENTAGE 0
1099 #define RANDOM_USE_QUANTITY 1
1101 /* values for level set save mode */
1102 #define LEVELSET_SAVE_MODE_UPDATE 0
1103 #define LEVELSET_SAVE_MODE_CREATE 1
1105 /* default value for element tile size in drawing area */
1106 #define DEFAULT_EDITOR_TILESIZE MINI_TILESIZE
1107 #define DEFAULT_EDITOR_TILESIZE_MM TILESIZE
1111 -----------------------------------------------------------------------------
1112 some internally used data structure definitions
1113 -----------------------------------------------------------------------------
1120 struct XYTileSize *pos;
1124 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
1126 /* note: some additional characters are already reserved for "cheat mode"
1127 shortcuts (":XYZ" style) -- for details, see "events.c" */
1129 /* ---------- toolbox control buttons ------------------------------------ */
1132 IMG_GFX_EDITOR_BUTTON_DRAW_SINGLE, GADGET_ID_SINGLE_ITEMS,
1133 &editor.button.draw_single, GD_TYPE_RADIO_BUTTON,
1134 "draw single items", 's'
1137 IMG_GFX_EDITOR_BUTTON_DRAW_CONNECTED, GADGET_ID_CONNECTED_ITEMS,
1138 &editor.button.draw_connected, GD_TYPE_RADIO_BUTTON,
1139 "draw connected items", 'd'
1142 IMG_GFX_EDITOR_BUTTON_DRAW_LINE, GADGET_ID_LINE,
1143 &editor.button.draw_line, GD_TYPE_RADIO_BUTTON,
1147 IMG_GFX_EDITOR_BUTTON_DRAW_ARC, GADGET_ID_ARC,
1148 &editor.button.draw_arc, GD_TYPE_RADIO_BUTTON,
1152 IMG_GFX_EDITOR_BUTTON_DRAW_RECTANGLE, GADGET_ID_RECTANGLE,
1153 &editor.button.draw_rectangle, GD_TYPE_RADIO_BUTTON,
1154 "draw outline rectangles", 'r'
1157 IMG_GFX_EDITOR_BUTTON_DRAW_FILLED_BOX, GADGET_ID_FILLED_BOX,
1158 &editor.button.draw_filled_box, GD_TYPE_RADIO_BUTTON,
1159 "draw filled rectangles", 'R'
1162 IMG_GFX_EDITOR_BUTTON_ROTATE_UP, GADGET_ID_WRAP_UP,
1163 &editor.button.rotate_up, GD_TYPE_NORMAL_BUTTON,
1164 "wrap (rotate) level up", 0
1167 IMG_GFX_EDITOR_BUTTON_DRAW_TEXT, GADGET_ID_TEXT,
1168 &editor.button.draw_text, GD_TYPE_RADIO_BUTTON,
1169 "enter text elements", 't'
1172 IMG_GFX_EDITOR_BUTTON_FLOOD_FILL, GADGET_ID_FLOOD_FILL,
1173 &editor.button.flood_fill, GD_TYPE_RADIO_BUTTON,
1177 IMG_GFX_EDITOR_BUTTON_ROTATE_LEFT, GADGET_ID_WRAP_LEFT,
1178 &editor.button.rotate_left, GD_TYPE_NORMAL_BUTTON,
1179 "wrap (rotate) level left", 0
1182 IMG_GFX_EDITOR_BUTTON_ZOOM_LEVEL, GADGET_ID_ZOOM,
1183 &editor.button.zoom_level, GD_TYPE_NORMAL_BUTTON,
1184 "zoom level tile size", '+'
1187 IMG_GFX_EDITOR_BUTTON_ROTATE_RIGHT, GADGET_ID_WRAP_RIGHT,
1188 &editor.button.rotate_right, GD_TYPE_NORMAL_BUTTON,
1189 "wrap (rotate) level right", 0
1192 IMG_GFX_EDITOR_BUTTON_DRAW_RANDOM, GADGET_ID_RANDOM_PLACEMENT,
1193 &editor.button.draw_random, GD_TYPE_NORMAL_BUTTON,
1194 "random element placement", 0
1197 IMG_GFX_EDITOR_BUTTON_GRAB_BRUSH, GADGET_ID_GRAB_BRUSH,
1198 &editor.button.grab_brush, GD_TYPE_RADIO_BUTTON,
1202 IMG_GFX_EDITOR_BUTTON_ROTATE_DOWN, GADGET_ID_WRAP_DOWN,
1203 &editor.button.rotate_down, GD_TYPE_NORMAL_BUTTON,
1204 "wrap (rotate) level down", 0
1207 IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT, GADGET_ID_PICK_ELEMENT,
1208 &editor.button.pick_element, GD_TYPE_RADIO_BUTTON,
1209 "pick drawing element", ','
1212 /* ---------- level control buttons -------------------------------------- */
1215 IMG_GFX_EDITOR_BUTTON_UNDO, GADGET_ID_UNDO,
1216 &editor.button.undo, GD_TYPE_NORMAL_BUTTON,
1217 "undo/redo last operation", 'u'
1220 IMG_GFX_EDITOR_BUTTON_CONF, GADGET_ID_INFO,
1221 &editor.button.conf, GD_TYPE_NORMAL_BUTTON,
1222 "properties of level", 'I'
1225 IMG_GFX_EDITOR_BUTTON_SAVE, GADGET_ID_SAVE,
1226 &editor.button.save, GD_TYPE_NORMAL_BUTTON,
1230 IMG_GFX_EDITOR_BUTTON_CLEAR, GADGET_ID_CLEAR,
1231 &editor.button.clear, GD_TYPE_NORMAL_BUTTON,
1235 IMG_GFX_EDITOR_BUTTON_TEST, GADGET_ID_TEST,
1236 &editor.button.test, GD_TYPE_NORMAL_BUTTON,
1240 IMG_GFX_EDITOR_BUTTON_EXIT, GADGET_ID_EXIT,
1241 &editor.button.exit, GD_TYPE_NORMAL_BUTTON,
1242 "exit level editor", 'E'
1245 /* ---------- CE and GE control buttons ---------------------------------- */
1248 IMG_GFX_EDITOR_BUTTON_CE_COPY_FROM, GADGET_ID_CUSTOM_COPY_FROM,
1249 &editor.button.ce_copy_from, GD_TYPE_RADIO_BUTTON,
1250 "copy settings from other element", 0
1253 IMG_GFX_EDITOR_BUTTON_CE_COPY_TO, GADGET_ID_CUSTOM_COPY_TO,
1254 &editor.button.ce_copy_to, GD_TYPE_RADIO_BUTTON,
1255 "copy settings to other element", 0
1258 IMG_GFX_EDITOR_BUTTON_CE_SWAP, GADGET_ID_CUSTOM_EXCHANGE,
1259 &editor.button.ce_swap, GD_TYPE_RADIO_BUTTON,
1260 "exchange element with other element", 0
1263 IMG_GFX_EDITOR_BUTTON_CE_COPY, GADGET_ID_CUSTOM_COPY,
1264 &editor.button.ce_copy, GD_TYPE_NORMAL_BUTTON,
1265 "copy settings from this element", 0
1268 IMG_GFX_EDITOR_BUTTON_CE_PASTE, GADGET_ID_CUSTOM_PASTE,
1269 &editor.button.ce_paste, GD_TYPE_NORMAL_BUTTON,
1270 "paste settings to this element", 0
1273 /* ---------- palette control buttons ------------------------------------ */
1276 IMG_GFX_EDITOR_BUTTON_PROPERTIES, GADGET_ID_PROPERTIES,
1277 &editor.button.properties, GD_TYPE_NORMAL_BUTTON,
1278 "properties of drawing element", 'p'
1281 IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT, GADGET_ID_ELEMENT_LEFT,
1282 &editor.button.element_left, GD_TYPE_NORMAL_BUTTON,
1283 "properties of drawing element 1", '1'
1286 IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE, GADGET_ID_ELEMENT_MIDDLE,
1287 &editor.button.element_middle, GD_TYPE_NORMAL_BUTTON,
1288 "properties of drawing element 2", '2'
1291 IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT, GADGET_ID_ELEMENT_RIGHT,
1292 &editor.button.element_right, GD_TYPE_NORMAL_BUTTON,
1293 "properties of drawing element 3", '3'
1296 IMG_GFX_EDITOR_BUTTON_PALETTE, GADGET_ID_PALETTE,
1297 &editor.button.palette, GD_TYPE_NORMAL_BUTTON,
1298 "show list of elements", 'e'
1302 static int random_placement_value = 10;
1303 static int random_placement_method = RANDOM_USE_QUANTITY;
1304 static int random_placement_background_element = EL_SAND;
1305 static boolean random_placement_background_restricted = FALSE;
1306 static boolean stick_element_properties_window = FALSE;
1307 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1308 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1309 static struct ElementChangeInfo custom_element_change;
1310 static struct ElementGroupInfo group_element_info;
1311 static struct ElementInfo custom_element;
1313 static char levelset_name[MAX_LEVEL_NAME_LEN + 1];
1314 static char levelset_author[MAX_LEVEL_AUTHOR_LEN + 1];
1315 static int levelset_num_levels = 100;
1316 static boolean levelset_use_levelset_artwork = FALSE;
1317 static boolean levelset_copy_level_template = FALSE;
1318 static int levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
1323 int min_value, max_value;
1324 int gadget_id_down, gadget_id_up;
1326 int gadget_id_align;
1328 char *text_above, *text_left, *text_right;
1329 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1331 /* ---------- current level number --------------------------------------- */
1334 -1, -1, /* these values are not constant, but can change at runtime */
1336 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1337 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1342 /* ---------- level and editor settings ---------------------------------- */
1345 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1346 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1347 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1348 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1350 "playfield size:", NULL, "width",
1353 -1, ED_LEVEL_SETTINGS_YPOS(4),
1354 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1355 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1356 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1358 NULL, " ", "height",
1361 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1363 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1364 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1366 NULL, "number of gems to collect:", NULL
1369 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
1371 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1372 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1374 "time or step limit to solve level:", NULL, NULL
1377 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
1379 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1380 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1381 &level.score[SC_TIME_BONUS],
1382 "score for each second/step left:", NULL, NULL
1385 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
1387 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1388 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1390 NULL, "random seed:", "(0 => random)"
1393 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1395 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN, GADGET_ID_LEVELSET_NUM_LEVELS_UP,
1396 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT, GADGET_ID_NONE,
1397 &levelset_num_levels,
1398 "number of levels:", NULL, NULL,
1401 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1403 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1404 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1405 &random_placement_value,
1406 "random element placement:", NULL, "in"
1409 /* ---------- element settings: configure (various elements) ------------- */
1412 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1413 MIN_SCORE, MAX_SCORE,
1414 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1415 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1416 NULL, /* will be set when used */
1420 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1421 MIN_SCORE, MAX_SCORE,
1422 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1423 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1424 NULL, /* will be set when used */
1428 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1429 MIN_SCORE, MAX_SCORE,
1430 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1431 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1432 NULL, /* will be set when used */
1436 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1437 MIN_SCORE, MAX_SCORE,
1438 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1439 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1440 NULL, /* will be set when used */
1444 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1445 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1446 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1447 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1448 &level.num_yamyam_contents,
1449 NULL, NULL, "number of content areas"
1452 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1453 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1454 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1455 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1456 &level.num_ball_contents,
1457 NULL, NULL, "number of content areas"
1460 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1461 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1462 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1463 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1464 &level.num_android_clone_elements,
1465 NULL, NULL, "number of clonable elements"
1468 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1469 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1470 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1471 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1472 NULL, /* will be set when used */
1473 NULL, NULL, "width",
1476 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1477 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1478 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1479 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1480 NULL, /* will be set when used */
1481 NULL, " ", "height",
1484 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1485 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1486 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1487 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1488 &level.initial_inventory_size[0],
1489 NULL, NULL, "number of inventory elements"
1492 /* ---------- element settings: configure 1 (custom elements) ------------ */
1495 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1496 MIN_SCORE, MAX_SCORE,
1497 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1498 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1499 &custom_element.collect_score_initial,
1500 NULL, "CE score", " "
1503 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1504 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1505 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1506 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1507 &custom_element.collect_count_initial,
1508 NULL, "CE count", NULL
1511 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1513 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1514 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1515 &custom_element.ce_value_fixed_initial,
1516 NULL, "CE value", NULL
1519 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1521 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1522 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1523 &custom_element.ce_value_random_initial,
1524 NULL, "+random", NULL
1527 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1529 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1530 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1531 &custom_element.push_delay_fixed,
1532 NULL, "push delay", NULL
1535 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1537 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1538 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1539 &custom_element.push_delay_random,
1540 NULL, "+random", NULL
1543 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1545 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1546 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1547 &custom_element.drop_delay_fixed,
1548 NULL, "drop delay", NULL
1551 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1553 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1554 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1555 &custom_element.drop_delay_random,
1556 NULL, "+random", NULL
1559 /* ---------- element settings: configure 2 (custom elements) ------------ */
1562 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1564 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1565 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1566 &custom_element.move_delay_fixed,
1567 NULL, "move delay", NULL
1570 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1572 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1573 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1574 &custom_element.move_delay_random,
1575 NULL, "+random", NULL
1578 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
1580 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1581 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1582 &custom_element.explosion_delay,
1583 NULL, "explosion delay", NULL
1586 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1588 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1589 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1590 &custom_element.ignition_delay,
1591 NULL, "ignition delay", "(by fire)"
1594 /* ---------- element settings: configure (group elements) --------------- */
1597 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1598 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1599 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1600 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1601 &group_element_info.num_elements,
1602 NULL, NULL, "number of elements in group"
1605 /* ---------- element settings: advanced (custom elements) --------------- */
1608 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1610 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1611 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1612 &custom_element_change.delay_fixed,
1613 NULL, "CE delay", NULL,
1616 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1618 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1619 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1620 &custom_element_change.delay_random,
1621 NULL, "+random", NULL
1624 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1626 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1627 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1628 &custom_element_change.random_percentage,
1629 NULL, "use random replace:", "%"
1639 char *text_above, *infotext;
1640 } textinput_info[ED_NUM_TEXTINPUT] =
1643 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1644 GADGET_ID_LEVEL_NAME,
1647 "Title:", "Title for this level"
1650 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1651 GADGET_ID_LEVEL_AUTHOR,
1652 MAX_LEVEL_AUTHOR_LEN,
1654 "Author:", "Author for this level"
1657 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1658 GADGET_ID_LEVELSET_NAME,
1661 "Title:", "Title for this or new level set"
1664 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1665 GADGET_ID_LEVELSET_AUTHOR,
1666 MAX_LEVEL_AUTHOR_LEN,
1668 "Author:", "Author for this or new level set"
1671 -1, -1, /* these values are not constant, but can change at runtime */
1672 GADGET_ID_ELEMENT_NAME,
1673 MAX_ELEMENT_NAME_LEN - 2, /* currently 2 chars less editable */
1674 custom_element.description,
1675 NULL, "Element name"
1685 char *text_above, *infotext;
1686 } textarea_info[ED_NUM_TEXTAREAS] =
1689 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1690 GADGET_ID_ENVELOPE_INFO,
1691 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1693 "Envelope Content:", "Envelope Content"
1697 static struct ValueTextInfo options_time_or_steps[] =
1705 static struct ValueTextInfo options_game_engine_type[] =
1707 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1708 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1709 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1710 { GAME_ENGINE_TYPE_MM, "Mirror Magic" },
1715 static struct ValueTextInfo options_levelset_save_mode[] =
1717 { LEVELSET_SAVE_MODE_UPDATE, "Update this level set" },
1718 { LEVELSET_SAVE_MODE_CREATE, "Create new level set" },
1723 static struct ValueTextInfo options_wind_direction[] =
1725 { MV_START_NONE, "none" },
1726 { MV_START_LEFT, "left" },
1727 { MV_START_RIGHT, "right" },
1728 { MV_START_UP, "up" },
1729 { MV_START_DOWN, "down" },
1734 static struct ValueTextInfo options_player_speed[] =
1741 { 16, "very fast" },
1742 { 32, "ultrafast" },
1747 static struct ValueTextInfo options_access_type[] =
1749 { EP_WALKABLE, "walkable" },
1750 { EP_PASSABLE, "passable" },
1755 static struct ValueTextInfo options_access_layer[] =
1757 { EP_ACCESSIBLE_OVER, "over" },
1758 { EP_ACCESSIBLE_INSIDE, "inside" },
1759 { EP_ACCESSIBLE_UNDER, "under" },
1764 static struct ValueTextInfo options_access_protected[] =
1766 { 0, "unprotected" },
1772 static struct ValueTextInfo options_access_direction[] =
1774 { MV_NO_DIRECTION, "no direction" },
1775 { MV_LEFT, "left" },
1776 { MV_RIGHT, "right" },
1778 { MV_DOWN, "down" },
1779 { MV_LEFT | MV_UP, "left + up" },
1780 { MV_LEFT | MV_DOWN, "left + down" },
1781 { MV_RIGHT | MV_UP, "right + up" },
1782 { MV_RIGHT | MV_DOWN, "right + down" },
1783 { MV_HORIZONTAL, "horizontal" },
1784 { MV_VERTICAL, "vertical" },
1785 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1786 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1787 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1788 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1789 { MV_ALL_DIRECTIONS, "all directions" },
1794 static struct ValueTextInfo options_walk_to_action[] =
1796 { EP_DIGGABLE, "diggable" },
1797 { EP_COLLECTIBLE_ONLY, "collectible" },
1798 { EP_DROPPABLE, "collectible & droppable" },
1799 { EP_THROWABLE, "collectible & throwable" },
1800 { EP_PUSHABLE, "pushable" },
1805 static struct ValueTextInfo options_move_pattern[] =
1807 { MV_LEFT, "left" },
1808 { MV_RIGHT, "right" },
1810 { MV_DOWN, "down" },
1811 { MV_HORIZONTAL, "horizontal" },
1812 { MV_VERTICAL, "vertical" },
1813 { MV_ALL_DIRECTIONS, "all directions" },
1814 { MV_WIND_DIRECTION, "wind direction" },
1815 { MV_TOWARDS_PLAYER, "towards player" },
1816 { MV_AWAY_FROM_PLAYER, "away from player" },
1817 { MV_ALONG_LEFT_SIDE, "along left side" },
1818 { MV_ALONG_RIGHT_SIDE, "along right side" },
1819 { MV_TURNING_LEFT, "turning left" },
1820 { MV_TURNING_RIGHT, "turning right" },
1821 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1822 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1823 { MV_TURNING_RANDOM, "turning random" },
1824 { MV_MAZE_RUNNER, "maze runner style" },
1825 { MV_MAZE_HUNTER, "maze hunter style" },
1826 { MV_WHEN_PUSHED, "when pushed" },
1827 { MV_WHEN_DROPPED, "when dropped/thrown" },
1832 static struct ValueTextInfo options_move_direction[] =
1834 { MV_START_AUTOMATIC, "automatic" },
1835 { MV_START_LEFT, "left" },
1836 { MV_START_RIGHT, "right" },
1837 { MV_START_UP, "up" },
1838 { MV_START_DOWN, "down" },
1839 { MV_START_RANDOM, "random" },
1840 { MV_START_PREVIOUS, "previous" },
1845 static struct ValueTextInfo options_move_stepsize[] =
1847 { 0, "not moving" },
1852 { 16, "very fast" },
1853 { 32, "even faster" },
1858 static struct ValueTextInfo options_move_leave_type[] =
1860 { LEAVE_TYPE_UNLIMITED, "leave behind" },
1861 { LEAVE_TYPE_LIMITED, "change it to" },
1866 static struct ValueTextInfo options_smash_targets[] =
1868 { EP_CAN_SMASH_PLAYER, "player" },
1870 { EP_CAN_SMASH_ENEMIES, "enemies" },
1872 { EP_CAN_SMASH_EVERYTHING, "everything" },
1877 static struct ValueTextInfo options_slippery_type[] =
1879 { SLIPPERY_ANY_RANDOM, "random" },
1880 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
1881 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
1882 { SLIPPERY_ONLY_LEFT, "only left" },
1883 { SLIPPERY_ONLY_RIGHT, "only right" },
1888 static struct ValueTextInfo options_deadliness[] =
1890 { EP_DONT_RUN_INTO, "running into" },
1891 { EP_DONT_COLLIDE_WITH, "colliding with" },
1892 { EP_DONT_GET_HIT_BY, "getting hit by" },
1893 { EP_DONT_TOUCH, "touching" },
1898 static struct ValueTextInfo options_explosion_type[] =
1900 { EXPLODES_3X3, "3x3" },
1901 { EXPLODES_CROSS, "3+3" },
1902 { EXPLODES_1X1, "1x1" },
1907 static struct ValueTextInfo options_time_units[] =
1910 { FRAMES_PER_SECOND, "seconds" },
1915 static struct ValueTextInfo options_change_direct_action[] =
1917 { CE_TOUCHED_BY_PLAYER, "touched by player" },
1918 { CE_PRESSED_BY_PLAYER, "pressed by player" },
1919 { CE_SWITCHED_BY_PLAYER, "switched by player" },
1920 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
1921 { CE_PUSHED_BY_PLAYER, "pushed by player" },
1922 { CE_ENTERED_BY_PLAYER, "entered by player" },
1923 { CE_LEFT_BY_PLAYER, "left by player" },
1924 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
1925 { CE_SWITCHED, "switched" },
1926 { CE_HITTING_SOMETHING, "hitting something" },
1927 { CE_HIT_BY_SOMETHING, "hit by something" },
1929 { CE_BLOCKED, "blocked" },
1931 { CE_IMPACT, "impact (on something)" },
1932 { CE_SMASHED, "smashed (from above)" },
1934 { CE_VALUE_CHANGES, "CE value changes" },
1935 { CE_SCORE_CHANGES, "CE score changes" },
1937 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
1938 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
1943 static struct ValueTextInfo options_change_other_action[] =
1945 { CE_PLAYER_TOUCHES_X, "player touches" },
1946 { CE_PLAYER_PRESSES_X, "player presses" },
1947 { CE_PLAYER_SWITCHES_X, "player switches" },
1948 { CE_PLAYER_SNAPS_X, "player snaps" },
1949 { CE_PLAYER_PUSHES_X, "player pushes" },
1950 { CE_PLAYER_ENTERS_X, "player enters" },
1951 { CE_PLAYER_LEAVES_X, "player leaves" },
1952 { CE_PLAYER_DIGS_X, "player digs" },
1953 { CE_PLAYER_COLLECTS_X, "player collects" },
1954 { CE_PLAYER_DROPS_X, "player drops/throws" },
1955 { CE_TOUCHING_X, "touching" },
1956 { CE_HITTING_X, "hitting" },
1957 { CE_DIGGING_X, "digging" },
1958 { CE_HIT_BY_X, "hit by" },
1959 { CE_SWITCH_OF_X, "switch of" },
1960 { CE_CHANGE_OF_X, "change by page of" },
1961 { CE_EXPLOSION_OF_X, "explosion of" },
1962 { CE_MOVE_OF_X, "move of" },
1963 { CE_CREATION_OF_X, "creation of" },
1964 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
1965 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
1966 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
1967 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
1972 static struct ValueTextInfo options_change_trigger_side[] =
1974 { CH_SIDE_LEFT, "left" },
1975 { CH_SIDE_RIGHT, "right" },
1976 { CH_SIDE_TOP, "top" },
1977 { CH_SIDE_BOTTOM, "bottom" },
1978 { CH_SIDE_LEFT_RIGHT, "left/right" },
1979 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
1980 { CH_SIDE_ANY, "any" },
1985 static struct ValueTextInfo options_change_trigger_player[] =
1987 { CH_PLAYER_1, "1" },
1988 { CH_PLAYER_2, "2" },
1989 { CH_PLAYER_3, "3" },
1990 { CH_PLAYER_4, "4" },
1991 { CH_PLAYER_ANY, "any" },
1996 static struct ValueTextInfo options_change_trigger_page[] =
2008 { (1 << 10), "11" },
2009 { (1 << 11), "12" },
2010 { (1 << 12), "13" },
2011 { (1 << 13), "14" },
2012 { (1 << 14), "15" },
2013 { (1 << 15), "16" },
2014 { (1 << 16), "17" },
2015 { (1 << 17), "18" },
2016 { (1 << 18), "19" },
2017 { (1 << 19), "20" },
2018 { (1 << 20), "21" },
2019 { (1 << 21), "22" },
2020 { (1 << 22), "23" },
2021 { (1 << 23), "24" },
2022 { (1 << 24), "25" },
2023 { (1 << 25), "26" },
2024 { (1 << 26), "27" },
2025 { (1 << 27), "28" },
2026 { (1 << 28), "29" },
2027 { (1 << 29), "30" },
2028 { (1 << 30), "31" },
2029 { (1 << 31), "32" },
2030 { CH_PAGE_ANY, "any" },
2035 static struct ValueTextInfo options_change_replace_when[] =
2037 { CP_WHEN_EMPTY, "empty" },
2038 { CP_WHEN_WALKABLE, "walkable" },
2039 { CP_WHEN_DIGGABLE, "diggable" },
2040 { CP_WHEN_COLLECTIBLE, "collectible" },
2041 { CP_WHEN_REMOVABLE, "removable" },
2042 { CP_WHEN_DESTRUCTIBLE, "destructible" },
2047 static struct ValueTextInfo options_action_type[] =
2049 { CA_NO_ACTION, "no action" },
2050 { CA_UNDEFINED, " " },
2051 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
2052 { CA_RESTART_LEVEL, "restart level" },
2053 { CA_SHOW_ENVELOPE, "show envelope" },
2054 { CA_SET_LEVEL_TIME, "set time" },
2055 { CA_SET_LEVEL_SCORE, "set score" },
2056 { CA_SET_LEVEL_GEMS, "set gems" },
2057 { CA_SET_LEVEL_WIND, "set wind dir." },
2058 { CA_SET_LEVEL_RANDOM_SEED, "set rand. seed" },
2059 { CA_UNDEFINED, " " },
2060 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
2061 { CA_MOVE_PLAYER, "move player" },
2062 { CA_EXIT_PLAYER, "exit player" },
2063 { CA_KILL_PLAYER, "kill player" },
2064 { CA_SET_PLAYER_KEYS, "set keys" },
2065 { CA_SET_PLAYER_SPEED, "set speed" },
2066 { CA_SET_PLAYER_SHIELD, "set shield" },
2067 { CA_SET_PLAYER_GRAVITY, "set gravity" },
2068 { CA_SET_PLAYER_ARTWORK, "set artwork" },
2069 { CA_SET_PLAYER_INVENTORY, "set inventory" },
2070 { CA_UNDEFINED, " " },
2071 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
2072 { CA_SET_CE_VALUE, "set CE value" },
2073 { CA_SET_CE_SCORE, "set CE score" },
2074 { CA_SET_CE_ARTWORK, "set CE artwork" },
2075 { CA_UNDEFINED, " " },
2076 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
2077 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
2082 static struct ValueTextInfo options_action_mode_none[] =
2084 { CA_MODE_UNDEFINED, " " },
2089 static struct ValueTextInfo options_action_mode_assign[] =
2091 { CA_MODE_SET, "=" },
2096 static struct ValueTextInfo options_action_mode_add_remove[] =
2098 { CA_MODE_ADD, "+" },
2099 { CA_MODE_SUBTRACT, "-" },
2104 static struct ValueTextInfo options_action_mode_calculate[] =
2106 { CA_MODE_SET, "=" },
2107 { CA_MODE_ADD, "+" },
2108 { CA_MODE_SUBTRACT, "-" },
2109 { CA_MODE_MULTIPLY, "*" },
2110 { CA_MODE_DIVIDE, "/" },
2111 { CA_MODE_MODULO, "%" },
2116 static struct ValueTextInfo options_action_arg_none[] =
2118 { CA_ARG_UNDEFINED, " " },
2123 static struct ValueTextInfo options_action_arg_player[] =
2125 { CA_ARG_PLAYER_HEADLINE, "[player]" },
2126 { CA_ARG_PLAYER_1, "1" },
2127 { CA_ARG_PLAYER_2, "2" },
2128 { CA_ARG_PLAYER_3, "3" },
2129 { CA_ARG_PLAYER_4, "4" },
2130 { CA_ARG_PLAYER_ANY, "any" },
2131 { CA_ARG_PLAYER_TRIGGER, "trigger" },
2132 { CA_ARG_PLAYER_ACTION, "action ->" },
2137 static struct ValueTextInfo options_action_arg_number[] =
2139 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2146 { CA_ARG_10, "10" },
2147 { CA_ARG_100, "100" },
2148 { CA_ARG_1000, "1000" },
2149 { CA_ARG_UNDEFINED, " " },
2150 { CA_ARG_NUMBER_MIN, "min" },
2151 { CA_ARG_NUMBER_MAX, "max" },
2152 { CA_ARG_UNDEFINED, " " },
2153 { CA_ARG_NUMBER_RESET, "reset" },
2154 { CA_ARG_UNDEFINED, " " },
2155 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2156 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2157 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2158 { CA_ARG_UNDEFINED, " " },
2159 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2160 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2161 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2162 { CA_ARG_UNDEFINED, " " },
2163 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2164 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2165 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2166 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2167 { CA_ARG_UNDEFINED, " " },
2168 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2169 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2170 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2171 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2176 static struct ValueTextInfo options_action_arg_value[] =
2178 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2185 { CA_ARG_10, "10" },
2186 { CA_ARG_100, "100" },
2187 { CA_ARG_1000, "1000" },
2188 { CA_ARG_UNDEFINED, " " },
2189 { CA_ARG_NUMBER_MIN, "min" },
2190 { CA_ARG_NUMBER_MAX, "max" },
2191 { CA_ARG_UNDEFINED, " " },
2192 { CA_ARG_NUMBER_RESET, "reset" },
2193 { CA_ARG_UNDEFINED, " " },
2194 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2195 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2196 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2197 { CA_ARG_UNDEFINED, " " },
2198 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2199 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2200 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2201 { CA_ARG_UNDEFINED, " " },
2202 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2203 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2204 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2205 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2206 { CA_ARG_UNDEFINED, " " },
2207 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2208 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2209 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2210 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2211 { CA_ARG_UNDEFINED, " " },
2212 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
2213 { CA_ARG_ELEMENT_NR_TARGET, "target" },
2214 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
2215 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
2220 static struct ValueTextInfo options_action_arg_envelope[] =
2222 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2227 { CA_ARG_UNDEFINED, " " },
2228 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2229 { CA_ARG_ELEMENT_TARGET, "target" },
2230 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2231 { CA_ARG_ELEMENT_ACTION, "action ->" },
2236 static struct ValueTextInfo options_action_arg_key[] =
2238 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2247 { CA_ARG_UNDEFINED, " " },
2248 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2249 { CA_ARG_ELEMENT_TARGET, "target" },
2250 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2251 { CA_ARG_ELEMENT_ACTION, "action ->" },
2256 static struct ValueTextInfo options_action_arg_speed[] =
2258 { CA_ARG_SPEED_HEADLINE, "[speed]" },
2259 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
2260 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
2261 { CA_ARG_SPEED_SLOW, "slow" },
2262 { CA_ARG_SPEED_NORMAL, "normal" },
2263 { CA_ARG_SPEED_FAST, "fast" },
2264 { CA_ARG_SPEED_VERY_FAST, "very fast" },
2265 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
2266 { CA_ARG_UNDEFINED, " " },
2267 { CA_ARG_SPEED_SLOWER, "slower" },
2268 { CA_ARG_SPEED_FASTER, "faster" },
2269 { CA_ARG_UNDEFINED, " " },
2270 { CA_ARG_SPEED_RESET, "reset" },
2275 static struct ValueTextInfo options_action_arg_shield[] =
2277 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
2278 { CA_ARG_SHIELD_OFF, "off" },
2279 { CA_ARG_SHIELD_NORMAL, "normal" },
2280 { CA_ARG_SHIELD_DEADLY, "deadly" },
2285 static struct ValueTextInfo options_action_arg_artwork[] =
2287 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2288 { CA_ARG_ELEMENT_TARGET, "target" },
2289 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2290 { CA_ARG_ELEMENT_ACTION, "action ->" },
2291 { CA_ARG_UNDEFINED, " " },
2292 { CA_ARG_ELEMENT_RESET, "reset" },
2297 static struct ValueTextInfo options_action_arg_gravity[] =
2299 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
2300 { CA_ARG_GRAVITY_ON, "on" },
2301 { CA_ARG_GRAVITY_OFF, "off" },
2302 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2307 static struct ValueTextInfo options_action_arg_direction[] =
2309 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2310 { CA_ARG_DIRECTION_NONE, "none" },
2311 { CA_ARG_DIRECTION_LEFT, "left" },
2312 { CA_ARG_DIRECTION_RIGHT, "right" },
2313 { CA_ARG_DIRECTION_UP, "up" },
2314 { CA_ARG_DIRECTION_DOWN, "down" },
2315 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2316 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2321 static struct ValueTextInfo options_action_arg_scan_mode[] =
2323 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2324 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2325 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2330 static struct ValueTextInfo options_action_arg_inventory[] =
2332 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2333 { CA_ARG_ELEMENT_TARGET, "+ target" },
2334 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2335 { CA_ARG_ELEMENT_ACTION, "+ action" },
2336 { CA_ARG_UNDEFINED, " " },
2337 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2338 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2339 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2340 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2341 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2342 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2343 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2344 { CA_ARG_UNDEFINED, " " },
2345 { CA_ARG_INVENTORY_RESET, "reset" },
2350 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2351 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2356 static struct ValueTextInfo options_group_choice_mode[] =
2358 { ANIM_RANDOM, "random" },
2359 { ANIM_LOOP, "loop" },
2360 { ANIM_LINEAR, "linear" },
2361 { ANIM_PINGPONG, "pingpong" },
2362 { ANIM_PINGPONG2, "pingpong 2" },
2367 static struct ValueTextInfo *action_arg_modes[] =
2369 options_action_mode_none,
2370 options_action_mode_assign,
2371 options_action_mode_add_remove,
2372 options_action_mode_calculate,
2379 struct ValueTextInfo *options;
2381 action_arg_options[] =
2383 { CA_NO_ACTION, 0, options_action_arg_none, },
2384 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2385 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2386 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2387 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2388 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2389 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2390 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2391 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2392 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2393 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2394 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2395 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2396 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2397 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2398 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2399 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2400 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2401 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2402 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2403 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2412 int gadget_id_align;
2413 int size; /* char size of selectbox or '-1' (dynamically determined) */
2414 struct ValueTextInfo *options;
2416 char *text_above, *text_left, *text_right, *infotext;
2417 } selectbox_info[ED_NUM_SELECTBOX] =
2419 /* ---------- level and editor settings ---------------------------------- */
2422 -1, ED_LEVEL_SETTINGS_YPOS(8),
2423 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2425 options_time_or_steps,
2426 &level.use_step_counter,
2427 NULL, NULL, "(0 => no limit)", "time or step limit"
2430 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
2431 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2433 options_game_engine_type,
2434 &level.game_engine_type,
2435 NULL, "game engine:", NULL, "game engine"
2438 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2439 GADGET_ID_LEVELSET_SAVE_MODE, GADGET_ID_NONE,
2441 options_levelset_save_mode,
2442 &levelset_save_mode,
2443 "Action:", NULL, NULL, "action when saving level set"
2446 /* ---------- element settings: configure (several elements) ------------- */
2449 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2450 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2452 options_wind_direction,
2453 &level.wind_direction_initial,
2454 NULL, "initial wind direction:", NULL, "initial wind direction"
2457 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2458 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2460 options_player_speed,
2461 &level.initial_player_stepsize[0],
2462 NULL, "initial player speed:", NULL, "initial player speed"
2465 /* ---------- element settings: configure 1 (custom elements) ------------ */
2468 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2469 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2471 options_access_type,
2472 &custom_element.access_type,
2473 NULL, NULL, NULL, "type of access to this field"
2476 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2477 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2479 options_access_layer,
2480 &custom_element.access_layer,
2481 NULL, NULL, NULL, "layer of access for this field"
2484 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2485 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2487 options_access_protected,
2488 &custom_element.access_protected,
2489 NULL, NULL, NULL, "protected access for this field"
2492 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2493 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2495 options_access_direction,
2496 &custom_element.access_direction,
2497 NULL, "from", NULL, "access direction for this field"
2500 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2501 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2503 options_walk_to_action,
2504 &custom_element.walk_to_action,
2505 NULL, NULL, NULL, "diggable/collectible/pushable"
2508 /* ---------- element settings: configure 2 (custom elements) ------------ */
2511 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2512 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2514 options_move_pattern,
2515 &custom_element.move_pattern,
2516 NULL, "can move", NULL, "element move pattern"
2519 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2520 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2522 options_move_direction,
2523 &custom_element.move_direction_initial,
2524 NULL, "starts moving", NULL, "initial element move direction"
2527 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2528 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2530 options_move_stepsize,
2531 &custom_element.move_stepsize,
2532 NULL, "move/fall speed", NULL, "speed of element movement"
2535 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2536 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2538 options_move_leave_type,
2539 &custom_element.move_leave_type,
2540 // left text with leading spaces to place gadget next to "can dig" gadget
2541 // (needed because drawing area gadgets created after selectbox gadgets)
2542 // NULL, "can dig: can", ":", "leave behind or change element"
2543 NULL, " can", ":", "leave behind or change element"
2546 -1, ED_ELEMENT_SETTINGS_YPOS(7),
2547 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2549 options_smash_targets,
2550 &custom_element.smash_targets,
2551 NULL, "can smash", NULL, "elements that can be smashed"
2554 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
2555 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2557 options_slippery_type,
2558 &custom_element.slippery_type,
2559 NULL, "slippery", NULL, "where other elements fall down"
2562 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2563 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2566 &custom_element.deadliness,
2567 NULL, "deadly when", NULL, "deadliness of element"
2570 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2571 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2573 options_explosion_type,
2574 &custom_element.explosion_type,
2575 NULL, "can explode", NULL, "explosion type"
2578 /* ---------- element settings: advanced (custom elements) --------------- */
2581 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2582 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2585 &custom_element_change.delay_frames,
2586 NULL, "delay time given in", NULL, "delay time units for change"
2589 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2590 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2592 options_change_direct_action,
2593 &custom_element_change.direct_action,
2594 NULL, NULL, NULL, "type of direct action"
2597 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2598 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2600 options_change_other_action,
2601 &custom_element_change.other_action,
2602 NULL, NULL, "element:", "type of other element action"
2605 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2606 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2608 options_change_trigger_side,
2609 &custom_element_change.trigger_side,
2610 NULL, "at", "side", "element side triggering change"
2613 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2614 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2616 options_change_trigger_player,
2617 &custom_element_change.trigger_player,
2618 NULL, "player:", " ", "player that causes change"
2621 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2622 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2624 options_change_trigger_page,
2625 &custom_element_change.trigger_page,
2626 NULL, "page:", NULL, "change page that causes change"
2629 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2630 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2632 options_change_replace_when,
2633 &custom_element_change.replace_when,
2634 NULL, "replace when", NULL, "which elements can be replaced"
2637 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2638 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2640 options_action_type,
2641 &custom_element_change.action_type,
2642 NULL, NULL, NULL, "action on specified condition"
2645 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2646 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2648 options_action_mode_none,
2649 &custom_element_change.action_mode,
2650 NULL, NULL, NULL, "action operator"
2653 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2654 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2656 options_action_arg_none,
2657 &custom_element_change.action_arg,
2658 NULL, NULL, NULL, "action parameter"
2661 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2662 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2664 options_change_page,
2665 &custom_element.current_change_page,
2666 NULL, NULL, NULL, "element change page"
2669 /* ---------- element settings: configure (group elements) --------------- */
2672 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2673 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2675 options_group_choice_mode,
2676 &group_element_info.choice_mode,
2677 NULL, "choice type:", NULL, "type of group element choice"
2685 int gadget_id_align;
2688 char *text_above, *text_left, *text_right, *infotext;
2689 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2691 /* ---------- level and editor settings (tabs) --------------------------- */
2694 ED_LEVEL_TABS_XPOS(0), ED_LEVEL_TABS_YPOS(0),
2695 GADGET_ID_LEVELINFO_LEVEL, GADGET_ID_NONE,
2697 NULL, NULL, NULL, "Configure level properties"
2701 GADGET_ID_LEVELINFO_LEVELSET, GADGET_ID_LEVELINFO_LEVEL,
2703 NULL, NULL, NULL, "Update this or create new level set"
2707 GADGET_ID_LEVELINFO_EDITOR, GADGET_ID_LEVELINFO_LEVELSET,
2709 NULL, NULL, NULL, "Configure editor properties"
2712 /* ---------- element settings (tabs) ------------------------------------ */
2715 ED_ELEMENT_TABS_XPOS(0), ED_ELEMENT_TABS_YPOS(0),
2716 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
2718 NULL, NULL, NULL, "Show information about element"
2722 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_PROPERTIES_INFO,
2724 NULL, NULL, NULL, "Configure element properties"
2728 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_PROPERTIES_INFO,
2730 NULL, NULL, NULL, "Configure element properties, part 1"
2734 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_PROPERTIES_CONFIG_1,
2736 NULL, NULL, NULL, "Configure element properties, part 2"
2740 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_PROPERTIES_CONFIG_2,
2742 NULL, NULL, NULL, "Configure custom element change pages"
2745 /* ---------- level and editor settings (buttons) ------------------------ */
2748 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2749 GADGET_ID_SAVE_LEVELSET, GADGET_ID_LEVELSET_SAVE_MODE,
2751 NULL, NULL, NULL, "Update or create level set"
2754 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
2755 GADGET_ID_SAVE_AS_TEMPLATE_2, GADGET_ID_NONE,
2757 NULL, NULL, "this level as level template",
2758 "Save current settings as new template"
2761 /* ---------- element settings (buttons) --------------------------------- */
2765 GADGET_ID_SAVE_AS_TEMPLATE_1, GADGET_ID_CUSTOM_USE_TEMPLATE_1,
2767 NULL, " ", "As Template",
2768 "Save current settings as new template"
2772 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
2774 NULL, NULL, NULL, "Add new change page"
2778 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
2780 NULL, NULL, NULL, "Delete current change page"
2789 int gadget_id_align;
2790 char *text_left, *text_right, *infotext;
2791 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
2794 IMG_EDITOR_COUNTER_DOWN,
2795 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
2796 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
2797 NULL, NULL, "select previous change page"
2800 IMG_EDITOR_COUNTER_UP,
2801 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2802 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
2803 NULL, "change page", "select next change page"
2806 IMG_GFX_EDITOR_BUTTON_CP_COPY,
2807 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2808 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
2809 " ", NULL, "copy settings from this change page"
2812 IMG_GFX_EDITOR_BUTTON_CP_PASTE,
2813 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2814 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
2815 NULL, NULL, "paste settings to this change page"
2822 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
2829 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
2832 IMG_EDITOR_PLAYFIELD_SCROLL_UP,
2833 GADGET_ID_SCROLL_UP,
2834 "scroll level editing area up"
2837 IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
2838 GADGET_ID_SCROLL_DOWN,
2839 "scroll level editing area down"
2842 IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
2843 GADGET_ID_SCROLL_LEFT,
2844 "scroll level editing area left"
2847 IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
2848 GADGET_ID_SCROLL_RIGHT,
2849 "scroll level editing area right"
2852 IMG_EDITOR_PALETTE_SCROLL_UP,
2853 GADGET_ID_SCROLL_LIST_UP,
2854 "scroll element list up ('Page Up')"
2857 IMG_EDITOR_PALETTE_SCROLL_DOWN,
2858 GADGET_ID_SCROLL_LIST_DOWN,
2859 "scroll element list down ('Page Down')"
2867 int wheel_x, wheel_y;
2868 int wheel_width, wheel_height;
2869 } scrollbar_pos[ED_NUM_SCROLLBARS];
2877 } scrollbar_info[ED_NUM_SCROLLBARS] =
2880 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
2881 GD_TYPE_SCROLLBAR_HORIZONTAL,
2882 GADGET_ID_SCROLL_HORIZONTAL,
2883 "scroll level editing area horizontally"
2886 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
2887 GD_TYPE_SCROLLBAR_VERTICAL,
2888 GADGET_ID_SCROLL_VERTICAL,
2889 "scroll level editing area vertically"
2892 IMG_EDITOR_PALETTE_SCROLLBAR,
2893 GD_TYPE_SCROLLBAR_VERTICAL,
2894 GADGET_ID_SCROLL_LIST_VERTICAL,
2895 "scroll element list vertically"
2904 int gadget_id_align;
2905 int radio_button_nr;
2908 char *text_left, *text_right, *infotext;
2909 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
2912 -1, ED_LEVEL_SETTINGS_YPOS(0),
2913 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
2914 RADIO_NR_RANDOM_ELEMENTS,
2915 &random_placement_method, RANDOM_USE_PERCENTAGE,
2916 " ", "percentage", "use percentage for random elements"
2919 -1, ED_LEVEL_SETTINGS_YPOS(0),
2920 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
2921 RADIO_NR_RANDOM_ELEMENTS,
2922 &random_placement_method, RANDOM_USE_QUANTITY,
2923 " ", "quantity", "use quantity for random elements"
2931 int gadget_id_align;
2933 char *text_above, *text_left, *text_right, *infotext;
2934 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
2936 /* ---------- level and editor settings ---------------------------------- */
2939 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
2940 GADGET_ID_AUTO_COUNT_GEMS, GADGET_ID_NONE,
2941 &level.auto_count_gems,
2943 "automatically count gems needed", "set counter to number of gems"
2946 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
2947 GADGET_ID_USE_LEVELSET_ARTWORK, GADGET_ID_NONE,
2948 &levelset_use_levelset_artwork,
2950 "use current custom artwork", "use custom artwork of this level set"
2953 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
2954 GADGET_ID_COPY_LEVEL_TEMPLATE, GADGET_ID_NONE,
2955 &levelset_copy_level_template,
2957 "copy current level template", "copy level template of this level set"
2960 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
2961 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
2962 &random_placement_background_restricted,
2964 "restrict random placement to:", "set random placement restriction"
2967 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
2968 GADGET_ID_CUSTOM_USE_TEMPLATE_3, GADGET_ID_NONE,
2969 &setup.editor.use_template_for_new_levels,
2970 "Template for new levels and CE/GE:", NULL,
2971 "use template for new levels", "use template for level properties"
2974 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
2975 GADGET_ID_CUSTOM_USE_TEMPLATE_2, GADGET_ID_NONE,
2976 &level.use_custom_template,
2978 "use template for custom elements", "use template for custom properties"
2981 /* ---------- element settings: configure (various elements) ------------- */
2984 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2985 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
2986 &stick_element_properties_window,
2988 "stick this screen to edit content","stick this screen to edit content"
2991 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2992 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
2993 &level.em_slippery_gems,
2995 "slip down from certain flat walls","use EM/DC style slipping behaviour"
2998 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2999 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
3000 &level.em_explodes_by_fire,
3002 "explodes with chain reaction", "use R'n'D style explosion behaviour"
3005 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3006 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
3007 &level.use_spring_bug,
3009 "use spring pushing bug", "use odd spring pushing behaviour"
3012 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3013 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
3014 &level.use_time_orb_bug,
3016 "use time orb bug", "use odd time orb behaviour"
3019 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3020 GADGET_ID_USE_LIFE_BUGS, GADGET_ID_NONE,
3021 &level.use_life_bugs,
3023 "use buggy element behaviour", "use odd (historic) element behaviour"
3026 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3027 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
3030 "create single random element", "only create one element from content"
3033 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3034 GADGET_ID_INITIAL_BALL_STATE, GADGET_ID_NONE,
3035 &level.ball_state_initial,
3037 "magic ball initially activated", "activate magic ball after level start"
3040 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3041 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
3042 &level.grow_into_diggable,
3044 "can grow into anything diggable", "grow into more than just sand"
3047 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3048 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
3049 &level.auto_exit_sokoban,
3051 "exit level if all fields solved", "automatically finish Sokoban levels"
3054 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3055 GADGET_ID_SOLVED_BY_ONE_PLAYER, GADGET_ID_NONE,
3056 &level.solved_by_one_player,
3058 "only one player must enter exit", "level solved by first player in exit"
3061 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3062 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
3063 &level.continuous_snapping,
3065 "continuous snapping", "use snapping without releasing key"
3068 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3069 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
3070 &level.block_snap_field,
3072 "block snapped field when snapping", "use snapping delay to show animation"
3075 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3076 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3077 &level.block_last_field,
3079 "block last field when moving", "player blocks last field when moving"
3082 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3083 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3084 &level.sp_block_last_field,
3086 "block last field when moving", "player blocks last field when moving"
3089 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3090 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
3091 &level.instant_relocation,
3093 "no scrolling when relocating", "player gets relocated without delay"
3096 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3097 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
3098 &level.shifted_relocation,
3100 "no centering when relocating", "level not centered after relocation"
3103 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3104 GADGET_ID_LAZY_RELOCATION, GADGET_ID_NONE,
3105 &level.lazy_relocation,
3107 "only redraw off-screen relocation","no redraw if relocation target visible"
3110 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3111 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
3112 &level.use_start_element[0],
3114 "use level start element:", "start level at this element's position"
3117 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3118 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
3119 &level.use_artwork_element[0],
3121 "use artwork from element:", "use player artwork from other element"
3124 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
3125 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
3126 &level.use_explosion_element[0],
3128 "use explosion from element:", "use explosion properties from element"
3131 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3132 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
3133 &level.initial_player_gravity[0],
3135 "use initial gravity", "set initial player gravity"
3138 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3139 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
3140 &level.use_initial_inventory[0],
3142 "use initial inventory:", "use collected elements on level start"
3145 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3146 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
3147 &level.can_pass_to_walkable,
3149 "can pass to walkable element", "player can pass to empty or walkable"
3152 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3153 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
3154 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3156 "can fall into acid (with gravity)","player can fall into acid pool"
3159 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3160 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
3161 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3163 "can move into acid", "element can move into acid pool"
3166 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3167 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
3168 &custom_element_properties[EP_DONT_COLLIDE_WITH],
3170 "deadly when colliding with", "element is deadly when hitting player"
3173 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3174 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
3175 &level.envelope[0].autowrap,
3177 "auto-wrap", "automatically wrap envelope text"
3180 -1, ED_ELEMENT_SETTINGS_YPOS(1),
3181 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
3182 &level.envelope[0].centered,
3184 "centered", "automatically center envelope text"
3187 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3188 GADGET_ID_MM_LASER_RED, GADGET_ID_NONE,
3189 &level.mm_laser_red,
3190 "choose color components for laser:", NULL,
3191 "red", "use red color components in laser"
3194 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3195 GADGET_ID_MM_LASER_GREEN, GADGET_ID_NONE,
3196 &level.mm_laser_green,
3198 "green", "use green color components in laser"
3201 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3202 GADGET_ID_MM_LASER_BLUE, GADGET_ID_NONE,
3203 &level.mm_laser_blue,
3205 "blue", "use blue color components in laser"
3208 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3209 GADGET_ID_DF_LASER_RED, GADGET_ID_NONE,
3210 &level.df_laser_red,
3211 "choose color components for laser:", NULL,
3212 "red", "use red color components in laser"
3215 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3216 GADGET_ID_DF_LASER_GREEN, GADGET_ID_NONE,
3217 &level.df_laser_green,
3219 "green", "use green color components in laser"
3222 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3223 GADGET_ID_DF_LASER_BLUE, GADGET_ID_NONE,
3224 &level.df_laser_blue,
3226 "blue", "use blue color components in laser"
3229 /* ---------- element settings: configure 1 (custom elements) ----------- */
3232 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3233 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
3234 &custom_element.use_gfx_element,
3236 "use graphic of element:", "use existing element graphic"
3239 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3240 GADGET_ID_CUSTOM_USE_TEMPLATE_1, GADGET_ID_NONE,
3241 &level.use_custom_template,
3243 "use template", "use template for custom properties"
3246 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3247 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
3248 &custom_element_properties[EP_ACCESSIBLE],
3250 NULL, "player can walk to or pass this field"
3253 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3254 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
3255 &custom_element_properties[EP_GRAVITY_REACHABLE],
3257 "reachable despite gravity", "player can walk/dig despite gravity"
3260 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3261 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
3262 &custom_element.use_last_ce_value,
3264 "use last CE value after change", "use last CE value after change"
3267 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3268 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
3269 &custom_element_properties[EP_WALK_TO_OBJECT],
3271 NULL, "player can dig/collect/push element"
3274 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3275 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
3276 &custom_element_properties[EP_INDESTRUCTIBLE],
3278 "indestructible", "element is indestructible"
3281 /* ---------- element settings: configure 2 (custom elements) ----------- */
3284 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3285 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
3286 &custom_element_properties[EP_CAN_MOVE],
3288 NULL, "element can move with some pattern"
3291 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
3292 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
3293 &custom_element_properties[EP_CAN_FALL],
3295 "can fall", "element can fall down"
3298 -1, ED_ELEMENT_SETTINGS_YPOS(7),
3299 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
3300 &custom_element_properties[EP_CAN_SMASH],
3302 NULL, "element can smash other elements"
3305 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3306 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
3307 &custom_element_properties[EP_SLIPPERY],
3309 NULL, "other elements can fall down from it"
3312 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3313 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
3314 &custom_element_properties[EP_DEADLY],
3316 NULL, "element can kill the player"
3319 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3320 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
3321 &custom_element_properties[EP_CAN_EXPLODE],
3323 NULL, "element can explode"
3326 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
3327 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
3328 &custom_element_properties[EP_EXPLODES_BY_FIRE],
3330 "by fire", "element can explode by fire/explosion"
3333 -1, ED_ELEMENT_SETTINGS_YPOS(11),
3334 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
3335 &custom_element_properties[EP_EXPLODES_SMASHED],
3337 "smashed", "element can explode when smashed"
3340 -1, ED_ELEMENT_SETTINGS_YPOS(11),
3341 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
3342 &custom_element_properties[EP_EXPLODES_IMPACT],
3344 "impact", "element can explode on impact"
3347 /* ---------- element settings: advanced (custom elements) --------------- */
3350 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3351 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
3352 &custom_element_change.can_change,
3354 "element changes to:", "change element on specified condition"
3357 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
3358 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
3359 &custom_element_change_events[CE_DELAY],
3361 NULL, "element changes after delay"
3364 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
3365 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
3366 &custom_element_change_events[CE_BY_DIRECT_ACTION],
3368 NULL, "element changes by direct action"
3371 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
3372 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
3373 &custom_element_change_events[CE_BY_OTHER_ACTION],
3375 NULL, "element changes by other element"
3378 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
3379 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
3380 &custom_element_change.explode,
3382 "explode instead of change", "element explodes instead of change"
3385 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
3386 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
3387 &custom_element_change.use_target_content,
3389 "use extended change target:", "element changes to more elements"
3392 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3393 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3394 &custom_element_change.only_if_complete,
3396 "replace all or nothing", "only replace when all can be changed"
3399 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3400 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3401 &custom_element_change.use_random_replace,
3403 NULL, "use percentage for random replace"
3406 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3407 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3408 &custom_element_change.has_action,
3410 NULL, "execute action on specified condition"
3417 int xoffset, yoffset;
3419 int gadget_id_align;
3421 int area_xsize, area_ysize;
3422 char *text_left, *text_right, *text_below, *infotext;
3423 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3425 /* ---------- level playfield content ------------------------------------ */
3430 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
3432 -1, -1, /* these values are not constant, but can change at runtime */
3433 NULL, NULL, NULL, NULL
3436 /* ---------- yam yam content -------------------------------------------- */
3439 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3440 ED_AREA_YAMYAM_CONTENT_XOFF(0), ED_AREA_YAMYAM_CONTENT_YOFF(0),
3441 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
3442 &level.yamyam_content[0].e[0][0], 3, 3,
3443 NULL, NULL, "1", NULL
3446 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3447 ED_AREA_YAMYAM_CONTENT_XOFF(1), ED_AREA_YAMYAM_CONTENT_YOFF(1),
3448 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
3449 &level.yamyam_content[1].e[0][0], 3, 3,
3450 NULL, NULL, "2", NULL
3453 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3454 ED_AREA_YAMYAM_CONTENT_XOFF(2), ED_AREA_YAMYAM_CONTENT_YOFF(2),
3455 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
3456 &level.yamyam_content[2].e[0][0], 3, 3,
3457 NULL, NULL, "3", NULL
3460 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3461 ED_AREA_YAMYAM_CONTENT_XOFF(3), ED_AREA_YAMYAM_CONTENT_YOFF(3),
3462 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
3463 &level.yamyam_content[3].e[0][0], 3, 3,
3464 NULL, NULL, "4", NULL
3467 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3468 ED_AREA_YAMYAM_CONTENT_XOFF(4), ED_AREA_YAMYAM_CONTENT_YOFF(4),
3469 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
3470 &level.yamyam_content[4].e[0][0], 3, 3,
3471 NULL, NULL, "5", NULL
3474 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3475 ED_AREA_YAMYAM_CONTENT_XOFF(5), ED_AREA_YAMYAM_CONTENT_YOFF(5),
3476 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
3477 &level.yamyam_content[5].e[0][0], 3, 3,
3478 NULL, NULL, "6", NULL
3481 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3482 ED_AREA_YAMYAM_CONTENT_XOFF(6), ED_AREA_YAMYAM_CONTENT_YOFF(6),
3483 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
3484 &level.yamyam_content[6].e[0][0], 3, 3,
3485 NULL, NULL, "7", NULL
3488 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3489 ED_AREA_YAMYAM_CONTENT_XOFF(7), ED_AREA_YAMYAM_CONTENT_YOFF(7),
3490 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
3491 &level.yamyam_content[7].e[0][0], 3, 3,
3492 NULL, NULL, "8", NULL
3495 /* ---------- magic ball content ----------------------------------------- */
3498 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3499 ED_AREA_MAGIC_BALL_CONTENT_XOFF(0), ED_AREA_MAGIC_BALL_CONTENT_YOFF(0),
3500 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
3501 &level.ball_content[0].e[0][0], 3, 3,
3502 NULL, NULL, "1", NULL
3505 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3506 ED_AREA_MAGIC_BALL_CONTENT_XOFF(1), ED_AREA_MAGIC_BALL_CONTENT_YOFF(1),
3507 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
3508 &level.ball_content[1].e[0][0], 3, 3,
3509 NULL, NULL, "2", NULL
3512 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3513 ED_AREA_MAGIC_BALL_CONTENT_XOFF(2), ED_AREA_MAGIC_BALL_CONTENT_YOFF(2),
3514 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
3515 &level.ball_content[2].e[0][0], 3, 3,
3516 NULL, NULL, "3", NULL
3519 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3520 ED_AREA_MAGIC_BALL_CONTENT_XOFF(3), ED_AREA_MAGIC_BALL_CONTENT_YOFF(3),
3521 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
3522 &level.ball_content[3].e[0][0], 3, 3,
3523 NULL, NULL, "4", NULL
3526 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3527 ED_AREA_MAGIC_BALL_CONTENT_XOFF(4), ED_AREA_MAGIC_BALL_CONTENT_YOFF(4),
3528 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
3529 &level.ball_content[4].e[0][0], 3, 3,
3530 NULL, NULL, "5", NULL
3533 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3534 ED_AREA_MAGIC_BALL_CONTENT_XOFF(5), ED_AREA_MAGIC_BALL_CONTENT_YOFF(5),
3535 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
3536 &level.ball_content[5].e[0][0], 3, 3,
3537 NULL, NULL, "6", NULL
3540 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3541 ED_AREA_MAGIC_BALL_CONTENT_XOFF(6), ED_AREA_MAGIC_BALL_CONTENT_YOFF(6),
3542 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
3543 &level.ball_content[6].e[0][0], 3, 3,
3544 NULL, NULL, "7", NULL
3547 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3548 ED_AREA_MAGIC_BALL_CONTENT_XOFF(7), ED_AREA_MAGIC_BALL_CONTENT_YOFF(7),
3549 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
3550 &level.ball_content[7].e[0][0], 3, 3,
3551 NULL, NULL, "8", NULL
3554 /* ---------- android content -------------------------------------------- */
3557 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(5),
3558 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3559 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
3560 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
3561 "elements:", NULL, NULL, "elements android can clone"
3564 /* ---------- amoeba content --------------------------------------------- */
3567 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
3568 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3569 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
3570 &level.amoeba_content, 1, 1,
3571 "content:", NULL, NULL, "amoeba content"
3574 /* ---------- level start element ---------------------------------------- */
3577 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
3578 0, ED_AREA_1X1_SETTINGS_YOFF,
3579 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
3580 &level.start_element[0], 1, 1,
3581 NULL, NULL, NULL, "level start element"
3584 /* ---------- player artwork element ------------------------------------- */
3587 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
3588 0, ED_AREA_1X1_SETTINGS_YOFF,
3589 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
3590 &level.artwork_element[0], 1, 1,
3591 NULL, NULL, NULL, "element for player artwork"
3594 /* ---------- player explosion element ----------------------------------- */
3597 -1, ED_AREA_1X1_SETTINGS_YPOS(12),
3598 0, ED_AREA_1X1_SETTINGS_YOFF,
3599 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
3600 &level.explosion_element[0], 1, 1,
3601 NULL, NULL, NULL, "element for player explosion"
3604 /* ---------- player initial inventory ----------------------------------- */
3607 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3608 0, ED_AREA_1X1_SETTINGS_YOFF,
3609 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
3610 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
3611 NULL, NULL, NULL, "content for initial inventory"
3614 /* ---------- element settings: configure 1 (custom elements) ----------- */
3616 /* ---------- custom graphic --------------------------------------------- */
3619 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3620 0, ED_AREA_1X1_SETTINGS_YOFF,
3621 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
3622 &custom_element.gfx_element_initial,1, 1,
3623 NULL, NULL, NULL, "custom graphic element"
3626 /* ---------- element settings: configure 2 (custom elements) ----------- */
3628 /* ---------- custom content (when exploding) ---------------------------- */
3631 -1, ED_AREA_3X3_SETTINGS_YPOS(10),
3632 0, ED_AREA_3X3_SETTINGS_YOFF,
3633 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, /* align three rows */
3634 &custom_element.content.e[0][0], 3, 3,
3635 "content:", NULL, NULL, NULL
3638 /* ---------- custom enter and leave element (when moving) --------------- */
3641 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
3642 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3643 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
3644 &custom_element.move_enter_element, 1, 1,
3645 "can dig:", " ", NULL, "element that can be digged/collected"
3648 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
3649 0, ED_AREA_1X1_SETTINGS_YOFF,
3650 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
3651 &custom_element.move_leave_element, 1, 1,
3652 NULL, NULL, NULL, "element that will be left behind"
3655 /* ---------- element settings: advanced (custom elements) --------------- */
3657 /* ---------- custom change target --------------------------------------- */
3660 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3661 0, ED_AREA_1X1_SETTINGS_YOFF,
3662 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
3663 &custom_element_change.target_element, 1, 1,
3664 NULL, "after/when:", NULL, "new target element after change"
3667 /* ---------- custom change content (extended change target) ------------- */
3670 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
3671 0, ED_AREA_3X3_SETTINGS_YOFF,
3672 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, /* align three rows */
3673 &custom_element_change.target_content.e[0][0], 3, 3,
3674 NULL, NULL, NULL, "new extended elements after change"
3677 /* ---------- custom change trigger (element causing change) ------------- */
3680 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
3681 0, ED_AREA_1X1_SETTINGS_YOFF,
3682 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
3683 &custom_element_change.initial_trigger_element, 1, 1,
3684 NULL, NULL, NULL, "other element triggering change"
3687 /* ---------- custom change action (element used for action) ------------- */
3690 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
3691 0, ED_AREA_1X1_SETTINGS_YOFF,
3692 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
3693 &custom_element_change.action_element, 1, 1,
3694 NULL, NULL, NULL, "element used as action parameter"
3697 /* ---------- group element content -------------------------------------- */
3700 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
3701 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3702 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
3703 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
3704 "content:", NULL, NULL, NULL
3707 /* ---------- random background (for random painting) -------------------- */
3710 -1, ED_AREA_1X1_LSETTINGS_YPOS(1),
3711 0, ED_AREA_1X1_LSETTINGS_YOFF,
3712 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
3713 &random_placement_background_element, 1, 1,
3714 NULL, NULL, NULL, "random placement background"
3720 -----------------------------------------------------------------------------
3721 some internally used variables
3722 -----------------------------------------------------------------------------
3725 /* maximal size of level editor drawing area */
3726 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
3728 /* actual size of level editor drawing area */
3729 static int ed_fieldx, ed_fieldy;
3731 /* actual position of level editor drawing area in level playfield */
3732 static int level_xpos = -1, level_ypos = -1;
3734 /* actual tile size used to display playfield drawing area */
3735 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
3736 static int ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
3738 #define IN_ED_FIELD(x,y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
3740 /* drawing elements on the three mouse buttons */
3741 static int new_element1 = EL_WALL;
3742 static int new_element2 = EL_EMPTY;
3743 static int new_element3 = EL_SAND;
3745 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
3746 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
3747 (button) == 2 ? new_element2 : \
3748 (button) == 3 ? new_element3 : EL_EMPTY)
3750 #define BUTTON_TILE_SIZE(x) ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE)
3752 static int use_permanent_palette = TRUE;
3754 #define PX (use_permanent_palette ? DX : SX)
3755 #define PY (use_permanent_palette ? DY : SY)
3756 #define PXSIZE (use_permanent_palette ? DXSIZE : SXSIZE)
3757 #define PYSIZE (use_permanent_palette ? DYSIZE : SYSIZE)
3759 /* forward declaration for internal use */
3760 static void ModifyEditorCounterValue(int, int);
3761 static void ModifyEditorCounterLimits(int, int, int);
3762 static void ModifyEditorSelectboxValue(int, int);
3763 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
3764 static void ModifyEditorDrawingArea(int, int, int);
3765 static void ModifyEditorElementList(void);
3766 static void AdjustElementListScrollbar(void);
3767 static void RedrawDrawingElements(void);
3768 static void DrawDrawingWindowExt(boolean);
3769 static void DrawDrawingWindow(void);
3770 static void DrawLevelInfoWindow(void);
3771 static void DrawPropertiesWindow(void);
3772 static void DrawPaletteWindow(void);
3773 static void UpdateCustomElementGraphicGadgets(void);
3774 static boolean checkPropertiesConfig(int);
3775 static void SetAutomaticNumberOfGemsNeeded(void);
3776 static void ClearEditorGadgetInfoText(void);
3777 static void CopyLevelToUndoBuffer(int);
3778 static void HandleDrawingAreas(struct GadgetInfo *);
3779 static void HandleCounterButtons(struct GadgetInfo *);
3780 static void HandleTextInputGadgets(struct GadgetInfo *);
3781 static void HandleTextAreaGadgets(struct GadgetInfo *);
3782 static void HandleSelectboxGadgets(struct GadgetInfo *);
3783 static void HandleTextbuttonGadgets(struct GadgetInfo *);
3784 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
3785 static void HandleRadiobuttons(struct GadgetInfo *);
3786 static void HandleCheckbuttons(struct GadgetInfo *);
3787 static void HandleControlButtons(struct GadgetInfo *);
3788 static void HandleDrawingAreaInfo(struct GadgetInfo *);
3789 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
3790 static boolean AskToCopyAndModifyLevelTemplate(void);
3791 static boolean getDrawModeHiRes(void);
3792 static int getTabulatorBarWidth(void);
3793 static int getTabulatorBarHeight(void);
3794 static Pixel getTabulatorBarColor(void);
3796 static int num_editor_gadgets = 0; /* dynamically determined */
3798 static struct GadgetInfo **level_editor_gadget = NULL;
3799 static int *right_gadget_border = NULL;
3801 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
3802 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
3803 static boolean draw_with_brush = FALSE;
3804 static int properties_element = 0;
3806 static short FieldBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3807 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3808 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3809 static int undo_buffer_position = 0;
3810 static int undo_buffer_steps = 0;
3811 static int redo_buffer_steps = 0;
3813 static int edit_mode;
3814 static int edit_mode_levelinfo;
3815 static int edit_mode_properties;
3817 static int element_shift = 0;
3819 static int editor_el_players[] =
3826 static int *editor_el_players_ptr = editor_el_players;
3827 static int num_editor_el_players = ARRAY_SIZE(editor_el_players);
3829 static int editor_hl_boulderdash[] =
3831 EL_INTERNAL_CASCADE_BD_ACTIVE,
3837 static int editor_el_boulderdash[] =
3846 EL_BD_EXPANDABLE_WALL,
3854 EL_BD_BUTTERFLY_LEFT,
3856 EL_BD_BUTTERFLY_RIGHT,
3857 EL_BD_FIREFLY_RIGHT,
3860 EL_BD_BUTTERFLY_DOWN,
3864 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
3865 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
3866 static int num_editor_hl_boulderdash = ARRAY_SIZE(editor_hl_boulderdash);
3867 static int num_editor_el_boulderdash = ARRAY_SIZE(editor_el_boulderdash);
3869 static int editor_hl_emerald_mine[] =
3871 EL_INTERNAL_CASCADE_EM_ACTIVE,
3877 static int editor_el_emerald_mine[] =
3895 EL_EM_DYNAMITE_ACTIVE,
3914 EL_ACID_POOL_TOPLEFT,
3916 EL_ACID_POOL_TOPRIGHT,
3919 EL_ACID_POOL_BOTTOMLEFT,
3920 EL_ACID_POOL_BOTTOM,
3921 EL_ACID_POOL_BOTTOMRIGHT,
3939 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
3940 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
3941 static int num_editor_hl_emerald_mine = ARRAY_SIZE(editor_hl_emerald_mine);
3942 static int num_editor_el_emerald_mine = ARRAY_SIZE(editor_el_emerald_mine);
3944 static int editor_hl_emerald_mine_club[] =
3946 EL_INTERNAL_CASCADE_EMC_ACTIVE,
3952 static int editor_el_emerald_mine_club[] =
3979 EL_EMC_WALL_SLIPPERY_1,
3980 EL_EMC_WALL_SLIPPERY_2,
3981 EL_EMC_WALL_SLIPPERY_3,
3982 EL_EMC_WALL_SLIPPERY_4,
4005 EL_EMC_MAGIC_BALL_SWITCH,
4007 EL_EMC_SPRING_BUMPER,
4016 EL_BALLOON_SWITCH_UP,
4017 EL_BALLOON_SWITCH_ANY,
4020 EL_BALLOON_SWITCH_LEFT,
4022 EL_BALLOON_SWITCH_RIGHT,
4026 EL_BALLOON_SWITCH_DOWN,
4027 EL_BALLOON_SWITCH_NONE,
4029 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
4030 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
4031 static int num_editor_hl_emerald_mine_club = ARRAY_SIZE(editor_hl_emerald_mine_club);
4032 static int num_editor_el_emerald_mine_club = ARRAY_SIZE(editor_el_emerald_mine_club);
4034 static int editor_hl_rnd[] =
4036 EL_INTERNAL_CASCADE_RND_ACTIVE,
4042 static int editor_el_rnd[] =
4044 EL_DYNAMITE, /* RND */
4045 EL_DYNAMITE_ACTIVE, /* RND */
4079 EL_WALL_EMERALD_YELLOW,
4080 EL_WALL_EMERALD_RED,
4081 EL_WALL_EMERALD_PURPLE,
4092 EL_YAMYAM, /* RND */
4099 EL_DYNABOMB_INCREASE_NUMBER,
4100 EL_DYNABOMB_INCREASE_SIZE,
4101 EL_DYNABOMB_INCREASE_POWER,
4121 EL_INVISIBLE_STEELWALL,
4125 EL_EXPANDABLE_WALL_HORIZONTAL,
4126 EL_EXPANDABLE_WALL_VERTICAL,
4127 EL_EXPANDABLE_WALL_ANY,
4129 static int *editor_hl_rnd_ptr = editor_hl_rnd;
4130 static int *editor_el_rnd_ptr = editor_el_rnd;
4131 static int num_editor_hl_rnd = ARRAY_SIZE(editor_hl_rnd);
4132 static int num_editor_el_rnd = ARRAY_SIZE(editor_el_rnd);
4134 static int editor_hl_sokoban[] =
4136 EL_INTERNAL_CASCADE_SB_ACTIVE,
4142 static int editor_el_sokoban[] =
4145 EL_SOKOBAN_FIELD_EMPTY,
4146 EL_SOKOBAN_FIELD_FULL,
4147 EL_SOKOBAN_FIELD_PLAYER,
4149 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
4150 static int *editor_el_sokoban_ptr = editor_el_sokoban;
4151 static int num_editor_hl_sokoban = ARRAY_SIZE(editor_hl_sokoban);
4152 static int num_editor_el_sokoban = ARRAY_SIZE(editor_el_sokoban);
4154 static int editor_hl_supaplex[] =
4156 EL_INTERNAL_CASCADE_SP_ACTIVE,
4162 static int editor_el_supaplex[] =
4180 EL_SP_PORT_HORIZONTAL,
4181 EL_SP_PORT_VERTICAL,
4189 EL_SP_GRAVITY_PORT_LEFT,
4190 EL_SP_GRAVITY_PORT_RIGHT,
4191 EL_SP_GRAVITY_PORT_UP,
4192 EL_SP_GRAVITY_PORT_DOWN,
4194 EL_SP_GRAVITY_ON_PORT_LEFT,
4195 EL_SP_GRAVITY_ON_PORT_RIGHT,
4196 EL_SP_GRAVITY_ON_PORT_UP,
4197 EL_SP_GRAVITY_ON_PORT_DOWN,
4199 EL_SP_GRAVITY_OFF_PORT_LEFT,
4200 EL_SP_GRAVITY_OFF_PORT_RIGHT,
4201 EL_SP_GRAVITY_OFF_PORT_UP,
4202 EL_SP_GRAVITY_OFF_PORT_DOWN,
4204 EL_SP_HARDWARE_GRAY,
4205 EL_SP_HARDWARE_GREEN,
4206 EL_SP_HARDWARE_BLUE,
4209 EL_SP_HARDWARE_BASE_1,
4210 EL_SP_HARDWARE_BASE_2,
4211 EL_SP_HARDWARE_BASE_3,
4212 EL_SP_HARDWARE_BASE_4,
4214 EL_SP_HARDWARE_BASE_5,
4215 EL_SP_HARDWARE_BASE_6,
4216 EL_SP_HARDWARE_YELLOW,
4224 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
4225 static int *editor_el_supaplex_ptr = editor_el_supaplex;
4226 static int num_editor_hl_supaplex = ARRAY_SIZE(editor_hl_supaplex);
4227 static int num_editor_el_supaplex = ARRAY_SIZE(editor_el_supaplex);
4229 static int editor_hl_diamond_caves[] =
4231 EL_INTERNAL_CASCADE_DC_ACTIVE,
4237 static int editor_el_diamond_caves[] =
4239 EL_EM_STEEL_EXIT_CLOSED, /* DC2 */
4240 EL_EM_STEEL_EXIT_OPEN, /* DC2 */
4241 EL_WALL_EMERALD, /* DC2 */
4242 EL_WALL_DIAMOND, /* DC2 */
4249 EL_CONVEYOR_BELT_1_LEFT,
4250 EL_CONVEYOR_BELT_1_MIDDLE,
4251 EL_CONVEYOR_BELT_1_RIGHT,
4252 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
4254 EL_CONVEYOR_BELT_2_LEFT,
4255 EL_CONVEYOR_BELT_2_MIDDLE,
4256 EL_CONVEYOR_BELT_2_RIGHT,
4257 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
4259 EL_CONVEYOR_BELT_3_LEFT,
4260 EL_CONVEYOR_BELT_3_MIDDLE,
4261 EL_CONVEYOR_BELT_3_RIGHT,
4262 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
4264 EL_CONVEYOR_BELT_4_LEFT,
4265 EL_CONVEYOR_BELT_4_MIDDLE,
4266 EL_CONVEYOR_BELT_4_RIGHT,
4267 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
4269 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
4270 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
4271 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
4272 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
4274 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
4275 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
4276 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
4277 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
4282 EL_DC_TIMEGATE_SWITCH,
4284 EL_SWITCHGATE_CLOSED,
4286 EL_SWITCHGATE_SWITCH_UP,
4287 EL_SWITCHGATE_SWITCH_DOWN,
4290 EL_LIGHT_SWITCH_ACTIVE,
4291 EL_DC_SWITCHGATE_SWITCH_UP,
4292 EL_DC_SWITCHGATE_SWITCH_DOWN,
4294 EL_STEEL_EXIT_CLOSED,
4296 EL_STEELWALL_SLIPPERY,
4299 EL_QUICKSAND_FAST_EMPTY,
4300 EL_QUICKSAND_FAST_FULL,
4314 EL_SIGN_RADIOACTIVITY,
4320 EL_SIGN_ENTRY_FORBIDDEN,
4321 EL_SIGN_EMERGENCY_EXIT,
4346 EL_DC_STEELWALL_2_SINGLE,
4347 EL_DC_STEELWALL_2_TOP,
4348 EL_SIGN_EXCLAMATION,
4351 EL_DC_STEELWALL_2_LEFT,
4352 EL_DC_STEELWALL_2_MIDDLE,
4353 EL_DC_STEELWALL_2_HORIZONTAL,
4354 EL_DC_STEELWALL_2_RIGHT,
4356 EL_DC_STEELWALL_1_TOPLEFT,
4357 EL_DC_STEELWALL_2_VERTICAL,
4358 EL_DC_STEELWALL_1_TOPRIGHT,
4361 EL_DC_STEELWALL_1_VERTICAL,
4362 EL_DC_STEELWALL_2_BOTTOM,
4364 EL_DC_GATE_WHITE_GRAY,
4366 EL_DC_STEELWALL_1_BOTTOMLEFT,
4367 EL_DC_STEELWALL_1_HORIZONTAL,
4368 EL_DC_STEELWALL_1_BOTTOMRIGHT,
4369 EL_DC_GATE_FAKE_GRAY,
4371 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
4372 EL_DC_STEELWALL_1_BOTTOM,
4373 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
4374 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
4376 EL_DC_STEELWALL_1_RIGHT,
4378 EL_DC_STEELWALL_1_LEFT,
4379 EL_EXPANDABLE_STEELWALL_VERTICAL,
4381 EL_DC_STEELWALL_1_TOPRIGHT_2,
4382 EL_DC_STEELWALL_1_TOP,
4383 EL_DC_STEELWALL_1_TOPLEFT_2,
4384 EL_EXPANDABLE_STEELWALL_ANY,
4386 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
4387 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
4388 static int num_editor_hl_diamond_caves = ARRAY_SIZE(editor_hl_diamond_caves);
4389 static int num_editor_el_diamond_caves = ARRAY_SIZE(editor_el_diamond_caves);
4391 static int editor_hl_dx_boulderdash[] =
4393 EL_INTERNAL_CASCADE_DX_ACTIVE,
4399 static int editor_el_dx_boulderdash[] =
4403 EL_TUBE_HORIZONTAL_DOWN,
4407 EL_TUBE_VERTICAL_RIGHT,
4409 EL_TUBE_VERTICAL_LEFT,
4413 EL_TUBE_HORIZONTAL_UP,
4421 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
4422 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
4423 static int num_editor_hl_dx_boulderdash = ARRAY_SIZE(editor_hl_dx_boulderdash);
4424 static int num_editor_el_dx_boulderdash = ARRAY_SIZE(editor_el_dx_boulderdash);
4426 static int editor_hl_mirror_magic[] =
4428 EL_INTERNAL_CASCADE_MM_ACTIVE,
4434 static int editor_el_mirror_magic[] =
4436 EL_MM_MCDUFFIN_RIGHT,
4438 EL_MM_MCDUFFIN_LEFT,
4439 EL_MM_MCDUFFIN_DOWN,
4442 EL_MM_MIRROR_FIXED_START,
4443 EL_MM_POLARIZER_START,
4444 EL_MM_POLARIZER_CROSS_START,
4446 EL_MM_TELEPORTER_RED_START,
4447 EL_MM_TELEPORTER_YELLOW_START,
4448 EL_MM_TELEPORTER_GREEN_START,
4449 EL_MM_TELEPORTER_BLUE_START,
4462 EL_MM_LIGHTBULB_ACTIVE,
4476 EL_MM_STEEL_GRID_FIXED_1,
4477 EL_MM_STEEL_GRID_FIXED_2,
4478 EL_MM_STEEL_GRID_FIXED_3,
4479 EL_MM_STEEL_GRID_FIXED_4,
4481 EL_MM_WOODEN_GRID_FIXED_1,
4482 EL_MM_WOODEN_GRID_FIXED_2,
4483 EL_MM_WOODEN_GRID_FIXED_3,
4484 EL_MM_WOODEN_GRID_FIXED_4
4486 static int *editor_hl_mirror_magic_ptr = editor_hl_mirror_magic;
4487 static int *editor_el_mirror_magic_ptr = editor_el_mirror_magic;
4488 static int num_editor_hl_mirror_magic = ARRAY_SIZE(editor_hl_mirror_magic);
4489 static int num_editor_el_mirror_magic = ARRAY_SIZE(editor_el_mirror_magic);
4491 static int editor_hl_deflektor[] =
4493 EL_INTERNAL_CASCADE_DF_ACTIVE,
4499 static int editor_el_deflektor[] =
4506 EL_DF_RECEIVER_RIGHT,
4508 EL_DF_RECEIVER_LEFT,
4509 EL_DF_RECEIVER_DOWN,
4512 EL_DF_MIRROR_ROTATING_START,
4516 EL_DF_FIBRE_OPTIC_RED_1,
4517 EL_DF_FIBRE_OPTIC_YELLOW_1,
4518 EL_DF_FIBRE_OPTIC_GREEN_1,
4519 EL_DF_FIBRE_OPTIC_BLUE_1,
4521 EL_DF_STEEL_GRID_FIXED_START,
4522 EL_DF_STEEL_GRID_ROTATING_START,
4523 EL_DF_WOODEN_GRID_FIXED_START,
4524 EL_DF_WOODEN_GRID_ROTATING_START,
4531 static int *editor_hl_deflektor_ptr = editor_hl_deflektor;
4532 static int *editor_el_deflektor_ptr = editor_el_deflektor;
4533 static int num_editor_hl_deflektor = ARRAY_SIZE(editor_hl_deflektor);
4534 static int num_editor_el_deflektor = ARRAY_SIZE(editor_el_deflektor);
4536 static int editor_hl_chars[] =
4538 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
4544 static int editor_el_chars[] =
4626 EL_CHAR(CHAR_BYTE_COPYRIGHT),
4627 EL_CHAR(CHAR_BYTE_UMLAUT_A),
4628 EL_CHAR(CHAR_BYTE_UMLAUT_O),
4629 EL_CHAR(CHAR_BYTE_UMLAUT_U),
4631 EL_CHAR(CHAR_BYTE_DEGREE),
4632 EL_CHAR(CHAR_BYTE_REGISTERED),
4633 EL_CHAR(FONT_ASCII_CURSOR),
4634 EL_CHAR(FONT_ASCII_BUTTON),
4636 EL_CHAR(FONT_ASCII_UP),
4637 EL_CHAR(FONT_ASCII_DOWN),
4641 static int *editor_hl_chars_ptr = editor_hl_chars;
4642 static int *editor_el_chars_ptr = editor_el_chars;
4643 static int num_editor_hl_chars = ARRAY_SIZE(editor_hl_chars);
4644 static int num_editor_el_chars = ARRAY_SIZE(editor_el_chars);
4646 static int editor_hl_steel_chars[] =
4648 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
4654 static int editor_el_steel_chars[] =
4664 EL_STEEL_CHAR('\''),
4731 EL_STEEL_CHAR('\\'),
4736 EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
4737 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
4738 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
4739 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
4741 EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
4742 EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
4743 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
4744 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
4746 EL_STEEL_CHAR(FONT_ASCII_UP),
4747 EL_STEEL_CHAR(FONT_ASCII_DOWN),
4751 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
4752 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
4753 static int num_editor_hl_steel_chars = ARRAY_SIZE(editor_hl_steel_chars);
4754 static int num_editor_el_steel_chars = ARRAY_SIZE(editor_el_steel_chars);
4756 static int editor_hl_custom[] =
4758 EL_INTERNAL_CASCADE_CE_ACTIVE,
4764 static int editor_el_custom[] =
4766 EL_CUSTOM_START + 0,
4767 EL_CUSTOM_START + 1,
4768 EL_CUSTOM_START + 2,
4769 EL_CUSTOM_START + 3,
4771 EL_CUSTOM_START + 4,
4772 EL_CUSTOM_START + 5,
4773 EL_CUSTOM_START + 6,
4774 EL_CUSTOM_START + 7,
4776 EL_CUSTOM_START + 8,
4777 EL_CUSTOM_START + 9,
4778 EL_CUSTOM_START + 10,
4779 EL_CUSTOM_START + 11,
4781 EL_CUSTOM_START + 12,
4782 EL_CUSTOM_START + 13,
4783 EL_CUSTOM_START + 14,
4784 EL_CUSTOM_START + 15,
4786 EL_CUSTOM_START + 16,
4787 EL_CUSTOM_START + 17,
4788 EL_CUSTOM_START + 18,
4789 EL_CUSTOM_START + 19,
4791 EL_CUSTOM_START + 20,
4792 EL_CUSTOM_START + 21,
4793 EL_CUSTOM_START + 22,
4794 EL_CUSTOM_START + 23,
4796 EL_CUSTOM_START + 24,
4797 EL_CUSTOM_START + 25,
4798 EL_CUSTOM_START + 26,
4799 EL_CUSTOM_START + 27,
4801 EL_CUSTOM_START + 28,
4802 EL_CUSTOM_START + 29,
4803 EL_CUSTOM_START + 30,
4804 EL_CUSTOM_START + 31,
4806 EL_CUSTOM_START + 32,
4807 EL_CUSTOM_START + 33,
4808 EL_CUSTOM_START + 34,
4809 EL_CUSTOM_START + 35,
4811 EL_CUSTOM_START + 36,
4812 EL_CUSTOM_START + 37,
4813 EL_CUSTOM_START + 38,
4814 EL_CUSTOM_START + 39,
4816 EL_CUSTOM_START + 40,
4817 EL_CUSTOM_START + 41,
4818 EL_CUSTOM_START + 42,
4819 EL_CUSTOM_START + 43,
4821 EL_CUSTOM_START + 44,
4822 EL_CUSTOM_START + 45,
4823 EL_CUSTOM_START + 46,
4824 EL_CUSTOM_START + 47,
4826 EL_CUSTOM_START + 48,
4827 EL_CUSTOM_START + 49,
4828 EL_CUSTOM_START + 50,
4829 EL_CUSTOM_START + 51,
4831 EL_CUSTOM_START + 52,
4832 EL_CUSTOM_START + 53,
4833 EL_CUSTOM_START + 54,
4834 EL_CUSTOM_START + 55,
4836 EL_CUSTOM_START + 56,
4837 EL_CUSTOM_START + 57,
4838 EL_CUSTOM_START + 58,
4839 EL_CUSTOM_START + 59,
4841 EL_CUSTOM_START + 60,
4842 EL_CUSTOM_START + 61,
4843 EL_CUSTOM_START + 62,
4844 EL_CUSTOM_START + 63,
4846 EL_CUSTOM_START + 64,
4847 EL_CUSTOM_START + 65,
4848 EL_CUSTOM_START + 66,
4849 EL_CUSTOM_START + 67,
4851 EL_CUSTOM_START + 68,
4852 EL_CUSTOM_START + 69,
4853 EL_CUSTOM_START + 70,
4854 EL_CUSTOM_START + 71,
4856 EL_CUSTOM_START + 72,
4857 EL_CUSTOM_START + 73,
4858 EL_CUSTOM_START + 74,
4859 EL_CUSTOM_START + 75,
4861 EL_CUSTOM_START + 76,
4862 EL_CUSTOM_START + 77,
4863 EL_CUSTOM_START + 78,
4864 EL_CUSTOM_START + 79,
4866 EL_CUSTOM_START + 80,
4867 EL_CUSTOM_START + 81,
4868 EL_CUSTOM_START + 82,
4869 EL_CUSTOM_START + 83,
4871 EL_CUSTOM_START + 84,
4872 EL_CUSTOM_START + 85,
4873 EL_CUSTOM_START + 86,
4874 EL_CUSTOM_START + 87,
4876 EL_CUSTOM_START + 88,
4877 EL_CUSTOM_START + 89,
4878 EL_CUSTOM_START + 90,
4879 EL_CUSTOM_START + 91,
4881 EL_CUSTOM_START + 92,
4882 EL_CUSTOM_START + 93,
4883 EL_CUSTOM_START + 94,
4884 EL_CUSTOM_START + 95,
4886 EL_CUSTOM_START + 96,
4887 EL_CUSTOM_START + 97,
4888 EL_CUSTOM_START + 98,
4889 EL_CUSTOM_START + 99,
4891 EL_CUSTOM_START + 100,
4892 EL_CUSTOM_START + 101,
4893 EL_CUSTOM_START + 102,
4894 EL_CUSTOM_START + 103,
4896 EL_CUSTOM_START + 104,
4897 EL_CUSTOM_START + 105,
4898 EL_CUSTOM_START + 106,
4899 EL_CUSTOM_START + 107,
4901 EL_CUSTOM_START + 108,
4902 EL_CUSTOM_START + 109,
4903 EL_CUSTOM_START + 110,
4904 EL_CUSTOM_START + 111,
4906 EL_CUSTOM_START + 112,
4907 EL_CUSTOM_START + 113,
4908 EL_CUSTOM_START + 114,
4909 EL_CUSTOM_START + 115,
4911 EL_CUSTOM_START + 116,
4912 EL_CUSTOM_START + 117,
4913 EL_CUSTOM_START + 118,
4914 EL_CUSTOM_START + 119,
4916 EL_CUSTOM_START + 120,
4917 EL_CUSTOM_START + 121,
4918 EL_CUSTOM_START + 122,
4919 EL_CUSTOM_START + 123,
4921 EL_CUSTOM_START + 124,
4922 EL_CUSTOM_START + 125,
4923 EL_CUSTOM_START + 126,
4924 EL_CUSTOM_START + 127,
4926 EL_CUSTOM_START + 128,
4927 EL_CUSTOM_START + 129,
4928 EL_CUSTOM_START + 130,
4929 EL_CUSTOM_START + 131,
4931 EL_CUSTOM_START + 132,
4932 EL_CUSTOM_START + 133,
4933 EL_CUSTOM_START + 134,
4934 EL_CUSTOM_START + 135,
4936 EL_CUSTOM_START + 136,
4937 EL_CUSTOM_START + 137,
4938 EL_CUSTOM_START + 138,
4939 EL_CUSTOM_START + 139,
4941 EL_CUSTOM_START + 140,
4942 EL_CUSTOM_START + 141,
4943 EL_CUSTOM_START + 142,
4944 EL_CUSTOM_START + 143,
4946 EL_CUSTOM_START + 144,
4947 EL_CUSTOM_START + 145,
4948 EL_CUSTOM_START + 146,
4949 EL_CUSTOM_START + 147,
4951 EL_CUSTOM_START + 148,
4952 EL_CUSTOM_START + 149,
4953 EL_CUSTOM_START + 150,
4954 EL_CUSTOM_START + 151,
4956 EL_CUSTOM_START + 152,
4957 EL_CUSTOM_START + 153,
4958 EL_CUSTOM_START + 154,
4959 EL_CUSTOM_START + 155,
4961 EL_CUSTOM_START + 156,
4962 EL_CUSTOM_START + 157,
4963 EL_CUSTOM_START + 158,
4964 EL_CUSTOM_START + 159,
4966 EL_CUSTOM_START + 160,
4967 EL_CUSTOM_START + 161,
4968 EL_CUSTOM_START + 162,
4969 EL_CUSTOM_START + 163,
4971 EL_CUSTOM_START + 164,
4972 EL_CUSTOM_START + 165,
4973 EL_CUSTOM_START + 166,
4974 EL_CUSTOM_START + 167,
4976 EL_CUSTOM_START + 168,
4977 EL_CUSTOM_START + 169,
4978 EL_CUSTOM_START + 170,
4979 EL_CUSTOM_START + 171,
4981 EL_CUSTOM_START + 172,
4982 EL_CUSTOM_START + 173,
4983 EL_CUSTOM_START + 174,
4984 EL_CUSTOM_START + 175,
4986 EL_CUSTOM_START + 176,
4987 EL_CUSTOM_START + 177,
4988 EL_CUSTOM_START + 178,
4989 EL_CUSTOM_START + 179,
4991 EL_CUSTOM_START + 180,
4992 EL_CUSTOM_START + 181,
4993 EL_CUSTOM_START + 182,
4994 EL_CUSTOM_START + 183,
4996 EL_CUSTOM_START + 184,
4997 EL_CUSTOM_START + 185,
4998 EL_CUSTOM_START + 186,
4999 EL_CUSTOM_START + 187,
5001 EL_CUSTOM_START + 188,
5002 EL_CUSTOM_START + 189,
5003 EL_CUSTOM_START + 190,
5004 EL_CUSTOM_START + 191,
5006 EL_CUSTOM_START + 192,
5007 EL_CUSTOM_START + 193,
5008 EL_CUSTOM_START + 194,
5009 EL_CUSTOM_START + 195,
5011 EL_CUSTOM_START + 196,
5012 EL_CUSTOM_START + 197,
5013 EL_CUSTOM_START + 198,
5014 EL_CUSTOM_START + 199,
5016 EL_CUSTOM_START + 200,
5017 EL_CUSTOM_START + 201,
5018 EL_CUSTOM_START + 202,
5019 EL_CUSTOM_START + 203,
5021 EL_CUSTOM_START + 204,
5022 EL_CUSTOM_START + 205,
5023 EL_CUSTOM_START + 206,
5024 EL_CUSTOM_START + 207,
5026 EL_CUSTOM_START + 208,
5027 EL_CUSTOM_START + 209,
5028 EL_CUSTOM_START + 210,
5029 EL_CUSTOM_START + 211,
5031 EL_CUSTOM_START + 212,
5032 EL_CUSTOM_START + 213,
5033 EL_CUSTOM_START + 214,
5034 EL_CUSTOM_START + 215,
5036 EL_CUSTOM_START + 216,
5037 EL_CUSTOM_START + 217,
5038 EL_CUSTOM_START + 218,
5039 EL_CUSTOM_START + 219,
5041 EL_CUSTOM_START + 220,
5042 EL_CUSTOM_START + 221,
5043 EL_CUSTOM_START + 222,
5044 EL_CUSTOM_START + 223,
5046 EL_CUSTOM_START + 224,
5047 EL_CUSTOM_START + 225,
5048 EL_CUSTOM_START + 226,
5049 EL_CUSTOM_START + 227,
5051 EL_CUSTOM_START + 228,
5052 EL_CUSTOM_START + 229,
5053 EL_CUSTOM_START + 230,
5054 EL_CUSTOM_START + 231,
5056 EL_CUSTOM_START + 232,
5057 EL_CUSTOM_START + 233,
5058 EL_CUSTOM_START + 234,
5059 EL_CUSTOM_START + 235,
5061 EL_CUSTOM_START + 236,
5062 EL_CUSTOM_START + 237,
5063 EL_CUSTOM_START + 238,
5064 EL_CUSTOM_START + 239,
5066 EL_CUSTOM_START + 240,
5067 EL_CUSTOM_START + 241,
5068 EL_CUSTOM_START + 242,
5069 EL_CUSTOM_START + 243,
5071 EL_CUSTOM_START + 244,
5072 EL_CUSTOM_START + 245,
5073 EL_CUSTOM_START + 246,
5074 EL_CUSTOM_START + 247,
5076 EL_CUSTOM_START + 248,
5077 EL_CUSTOM_START + 249,
5078 EL_CUSTOM_START + 250,
5079 EL_CUSTOM_START + 251,
5081 EL_CUSTOM_START + 252,
5082 EL_CUSTOM_START + 253,
5083 EL_CUSTOM_START + 254,
5084 EL_CUSTOM_START + 255
5086 static int *editor_hl_custom_ptr = editor_hl_custom;
5087 static int *editor_el_custom_ptr = editor_el_custom;
5088 static int num_editor_hl_custom = ARRAY_SIZE(editor_hl_custom);
5089 static int num_editor_el_custom = ARRAY_SIZE(editor_el_custom);
5091 static int editor_hl_group[] =
5093 EL_INTERNAL_CASCADE_GE_ACTIVE,
5099 static int editor_el_group[] =
5113 EL_GROUP_START + 10,
5114 EL_GROUP_START + 11,
5116 EL_GROUP_START + 12,
5117 EL_GROUP_START + 13,
5118 EL_GROUP_START + 14,
5119 EL_GROUP_START + 15,
5121 EL_GROUP_START + 16,
5122 EL_GROUP_START + 17,
5123 EL_GROUP_START + 18,
5124 EL_GROUP_START + 19,
5126 EL_GROUP_START + 20,
5127 EL_GROUP_START + 21,
5128 EL_GROUP_START + 22,
5129 EL_GROUP_START + 23,
5131 EL_GROUP_START + 24,
5132 EL_GROUP_START + 25,
5133 EL_GROUP_START + 26,
5134 EL_GROUP_START + 27,
5136 EL_GROUP_START + 28,
5137 EL_GROUP_START + 29,
5138 EL_GROUP_START + 30,
5141 static int *editor_hl_group_ptr = editor_hl_group;
5142 static int *editor_el_group_ptr = editor_el_group;
5143 static int num_editor_hl_group = ARRAY_SIZE(editor_hl_group);
5144 static int num_editor_el_group = ARRAY_SIZE(editor_el_group);
5146 static int editor_hl_reference[] =
5148 EL_INTERNAL_CASCADE_REF_ACTIVE,
5154 static int editor_el_reference[] =
5158 EL_TRIGGER_CE_VALUE,
5159 EL_TRIGGER_CE_SCORE,
5163 EL_CURRENT_CE_VALUE,
5164 EL_CURRENT_CE_SCORE,
5186 static int *editor_hl_reference_ptr = editor_hl_reference;
5187 static int *editor_el_reference_ptr = editor_el_reference;
5188 static int num_editor_hl_reference = ARRAY_SIZE(editor_hl_reference);
5189 static int num_editor_el_reference = ARRAY_SIZE(editor_el_reference);
5191 static int editor_hl_user_defined[] =
5193 EL_INTERNAL_CASCADE_USER_ACTIVE,
5199 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
5200 static int *editor_el_user_defined_ptr = NULL;
5201 static int num_editor_hl_user_defined = ARRAY_SIZE(editor_hl_user_defined);
5202 static int num_editor_el_user_defined = 0;
5204 static int editor_hl_dynamic[] =
5206 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
5212 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
5213 static int *editor_el_dynamic_ptr = NULL;
5214 static int num_editor_hl_dynamic = ARRAY_SIZE(editor_hl_dynamic);
5215 static int num_editor_el_dynamic = 0;
5217 static int editor_hl_empty[] = { EL_EMPTY };
5218 static int *editor_el_empty = NULL; /* dynamically allocated */
5220 static int *editor_hl_empty_ptr = editor_hl_empty;
5221 static int *editor_el_empty_ptr = NULL;
5222 static int num_editor_hl_empty = 0;
5223 static int num_editor_el_empty = 0; /* dynamically determined, if needed */
5225 static boolean use_el_empty = FALSE;
5227 static int *editor_elements = NULL; /* dynamically allocated */
5228 static int num_editor_elements = 0; /* dynamically determined */
5230 static boolean setup_editor_cascade_never = FALSE;
5232 static boolean setup_editor_el_players = TRUE;
5233 static boolean setup_editor_el_boulderdash = TRUE;
5234 static boolean setup_editor_el_emerald_mine = TRUE;
5235 static boolean setup_editor_el_emerald_mine_club = TRUE;
5236 static boolean setup_editor_el_more = TRUE;
5237 static boolean setup_editor_el_sokoban = TRUE;
5238 static boolean setup_editor_el_supaplex = TRUE;
5239 static boolean setup_editor_el_diamond_caves = TRUE;
5240 static boolean setup_editor_el_dx_boulderdash = TRUE;
5241 static boolean setup_editor_el_mirror_magic = TRUE;
5242 static boolean setup_editor_el_deflektor = TRUE;
5243 static boolean setup_editor_el_chars = TRUE;
5244 static boolean setup_editor_el_steel_chars = TRUE;
5245 static boolean setup_editor_el_custom = TRUE;
5246 static boolean setup_editor_el_user_defined = TRUE;
5247 static boolean setup_editor_el_dynamic = TRUE;
5249 static int editor_hl_unused[] = { EL_EMPTY };
5250 static int *editor_hl_unused_ptr = editor_hl_unused;
5251 static int num_editor_hl_unused = 0;
5255 boolean *setup_value;
5256 boolean *setup_cascade_value;
5258 int **headline_list;
5259 int *headline_list_size;
5262 int *element_list_size;
5264 boolean last_setup_value;
5266 editor_elements_info[] =
5269 &setup_editor_el_players,
5270 &setup_editor_cascade_never,
5271 &editor_hl_unused_ptr, &num_editor_hl_unused,
5272 &editor_el_players_ptr, &num_editor_el_players
5275 &setup_editor_el_boulderdash,
5276 &setup.editor_cascade.el_bd,
5277 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
5278 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
5281 &setup_editor_el_emerald_mine,
5282 &setup.editor_cascade.el_em,
5283 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
5284 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
5287 &setup_editor_el_emerald_mine_club,
5288 &setup.editor_cascade.el_emc,
5289 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
5290 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
5293 &setup_editor_el_more,
5294 &setup.editor_cascade.el_rnd,
5295 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
5296 &editor_el_rnd_ptr, &num_editor_el_rnd
5299 &setup_editor_el_sokoban,
5300 &setup.editor_cascade.el_sb,
5301 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
5302 &editor_el_sokoban_ptr, &num_editor_el_sokoban
5305 &setup_editor_el_supaplex,
5306 &setup.editor_cascade.el_sp,
5307 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
5308 &editor_el_supaplex_ptr, &num_editor_el_supaplex
5311 &setup_editor_el_diamond_caves,
5312 &setup.editor_cascade.el_dc,
5313 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
5314 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
5317 &setup_editor_el_dx_boulderdash,
5318 &setup.editor_cascade.el_dx,
5319 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
5320 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
5323 &setup_editor_el_mirror_magic,
5324 &setup.editor_cascade.el_mm,
5325 &editor_hl_mirror_magic_ptr, &num_editor_hl_mirror_magic,
5326 &editor_el_mirror_magic_ptr, &num_editor_el_mirror_magic
5329 &setup_editor_el_deflektor,
5330 &setup.editor_cascade.el_df,
5331 &editor_hl_deflektor_ptr, &num_editor_hl_deflektor,
5332 &editor_el_deflektor_ptr, &num_editor_el_deflektor
5335 &setup_editor_el_chars,
5336 &setup.editor_cascade.el_chars,
5337 &editor_hl_chars_ptr, &num_editor_hl_chars,
5338 &editor_el_chars_ptr, &num_editor_el_chars
5341 &setup_editor_el_steel_chars,
5342 &setup.editor_cascade.el_steel_chars,
5343 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
5344 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
5347 &setup_editor_el_custom,
5348 &setup.editor_cascade.el_ce,
5349 &editor_hl_custom_ptr, &num_editor_hl_custom,
5350 &editor_el_custom_ptr, &num_editor_el_custom
5353 &setup_editor_el_custom,
5354 &setup.editor_cascade.el_ge,
5355 &editor_hl_group_ptr, &num_editor_hl_group,
5356 &editor_el_group_ptr, &num_editor_el_group
5359 &setup_editor_el_custom,
5360 &setup.editor_cascade.el_ref,
5361 &editor_hl_reference_ptr, &num_editor_hl_reference,
5362 &editor_el_reference_ptr, &num_editor_el_reference
5365 &setup_editor_el_user_defined,
5366 &setup.editor_cascade.el_user,
5367 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
5368 &editor_el_user_defined_ptr, &num_editor_el_user_defined
5371 &setup_editor_el_dynamic,
5372 &setup.editor_cascade.el_dynamic,
5373 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
5374 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
5379 &editor_hl_empty_ptr, &num_editor_hl_empty,
5380 &editor_el_empty_ptr, &num_editor_el_empty,
5392 -----------------------------------------------------------------------------
5394 -----------------------------------------------------------------------------
5397 static int getMaxInfoTextLength(void)
5399 return (SXSIZE / getFontWidth(INFOTEXT_FONT));
5402 static int getTextWidthForGadget(char *text)
5407 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
5410 static int getTextWidthForDrawingArea(char *text)
5415 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
5418 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
5420 return (gi->x + gi->width + getTextWidthForGadget(text));
5423 static char *getElementInfoText(int element)
5425 char *info_text = NULL;
5427 if (element < MAX_NUM_ELEMENTS)
5429 if (strlen(element_info[element].description) > 0)
5430 info_text = element_info[element].description;
5431 else if (element_info[element].custom_description != NULL)
5432 info_text = element_info[element].custom_description;
5433 else if (element_info[element].editor_description != NULL)
5434 info_text = element_info[element].editor_description;
5437 if (info_text == NULL)
5438 info_text = INFOTEXT_UNKNOWN_ELEMENT;
5443 static char *getElementDescriptionFilenameExt(char *basename)
5445 char *elements_subdir = "elements";
5446 static char *elements_subdir2 = NULL;
5447 static char *filename = NULL;
5449 if (elements_subdir2 == NULL)
5450 elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
5452 checked_free(filename);
5454 /* 1st try: look for element description in current level set directory */
5455 filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
5456 if (fileExists(filename))
5461 /* 2nd try: look for element description in the game's base directory */
5462 filename = getPath3(options.docs_directory, elements_subdir, basename);
5463 if (fileExists(filename))
5469 static char *getElementDescriptionFilename(int element)
5471 char basename[MAX_FILENAME_LEN];
5474 /* 1st try: look for element description file for exactly this element */
5475 sprintf(basename, "%s.txt", element_info[element].token_name);
5476 filename = getElementDescriptionFilenameExt(basename);
5477 if (filename != NULL)
5480 /* 2nd try: look for element description file for this element's class */
5481 sprintf(basename, "%s.txt", element_info[element].class_name);
5482 filename = getElementDescriptionFilenameExt(basename);
5483 if (filename != NULL)
5489 static boolean suppressBorderElement(void)
5491 return (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
5492 lev_fieldx <= MAX_ED_FIELDX &&
5493 lev_fieldy <= MAX_ED_FIELDY);
5496 static void InitDynamicEditorElementList(int **elements, int *num_elements)
5498 boolean element_found[NUM_FILE_ELEMENTS];
5501 /* initialize list of used elements to "not used" */
5502 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5503 element_found[i] = FALSE;
5505 /* find all elements used in current level */
5506 for (y = 0; y < lev_fieldy; y++)
5507 for (x = 0; x < lev_fieldx; x++)
5508 if (Feld[x][y] < NUM_FILE_ELEMENTS) /* should always be true */
5509 element_found[Feld[x][y]] = TRUE;
5513 /* count number of elements used in current level */
5514 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5515 if (element_found[i])
5518 /* add space for up to 3 more elements for padding that may be needed */
5521 /* free memory for old list of elements, if needed */
5522 checked_free(*elements);
5524 /* allocate memory for new list of elements */
5525 *elements = checked_malloc(*num_elements * sizeof(int));
5529 /* add all elements used in current level (non-custom/group elements) */
5530 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5531 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
5532 (*elements)[(*num_elements)++] = i;
5534 /* add all elements used in current level (custom/group elements) */
5535 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5536 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
5537 (*elements)[(*num_elements)++] = i;
5539 while (*num_elements % 4) /* pad with empty elements, if needed */
5540 (*elements)[(*num_elements)++] = EL_EMPTY;
5543 static void ReinitializeElementList_EnableSections(void)
5545 /* default: enable all element sections */
5547 setup_editor_el_players = TRUE;
5548 setup_editor_el_boulderdash = TRUE;
5549 setup_editor_el_emerald_mine = TRUE;
5550 setup_editor_el_emerald_mine_club = TRUE;
5551 setup_editor_el_more = TRUE;
5552 setup_editor_el_sokoban = TRUE;
5553 setup_editor_el_supaplex = TRUE;
5554 setup_editor_el_diamond_caves = TRUE;
5555 setup_editor_el_dx_boulderdash = TRUE;
5556 setup_editor_el_mirror_magic = TRUE;
5557 setup_editor_el_deflektor = TRUE;
5558 setup_editor_el_chars = TRUE;
5559 setup_editor_el_steel_chars = TRUE;
5561 setup_editor_el_custom = TRUE;
5562 setup_editor_el_user_defined = TRUE;
5563 setup_editor_el_dynamic = TRUE;
5565 /* now disable all element sections not to be displayed */
5567 if (!setup.editor.el_classic)
5569 setup_editor_el_players = FALSE;
5570 setup_editor_el_boulderdash = FALSE;
5571 setup_editor_el_emerald_mine = FALSE;
5572 setup_editor_el_emerald_mine_club = FALSE;
5573 setup_editor_el_more = FALSE;
5574 setup_editor_el_sokoban = FALSE;
5575 setup_editor_el_supaplex = FALSE;
5576 setup_editor_el_diamond_caves = FALSE;
5577 setup_editor_el_dx_boulderdash = FALSE;
5578 setup_editor_el_mirror_magic = FALSE;
5579 setup_editor_el_deflektor = FALSE;
5580 setup_editor_el_chars = FALSE;
5581 setup_editor_el_steel_chars = FALSE;
5584 if (!setup.editor.el_custom)
5586 setup_editor_el_custom = FALSE;
5589 if (!setup.editor.el_user_defined)
5591 setup_editor_el_user_defined = FALSE;
5594 if (!setup.editor.el_dynamic)
5596 setup_editor_el_dynamic = FALSE;
5599 if (level.game_engine_type == GAME_ENGINE_TYPE_RND)
5601 setup_editor_el_mirror_magic = FALSE;
5602 setup_editor_el_deflektor = FALSE;
5604 else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
5606 setup_editor_el_boulderdash = FALSE;
5607 setup_editor_el_more = FALSE;
5608 setup_editor_el_sokoban = FALSE;
5609 setup_editor_el_supaplex = FALSE;
5610 setup_editor_el_diamond_caves = FALSE;
5611 setup_editor_el_dx_boulderdash = FALSE;
5612 setup_editor_el_mirror_magic = FALSE;
5613 setup_editor_el_deflektor = FALSE;
5614 setup_editor_el_steel_chars = FALSE;
5616 setup_editor_el_custom = FALSE;
5618 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
5620 setup_editor_el_players = FALSE;
5621 setup_editor_el_boulderdash = FALSE;
5622 setup_editor_el_emerald_mine = FALSE;
5623 setup_editor_el_emerald_mine_club = FALSE;
5624 setup_editor_el_more = FALSE;
5625 setup_editor_el_sokoban = FALSE;
5626 setup_editor_el_diamond_caves = FALSE;
5627 setup_editor_el_dx_boulderdash = FALSE;
5628 setup_editor_el_mirror_magic = FALSE;
5629 setup_editor_el_deflektor = FALSE;
5630 setup_editor_el_chars = FALSE;
5631 setup_editor_el_steel_chars = FALSE;
5633 setup_editor_el_custom = FALSE;
5635 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
5637 setup_editor_el_players = FALSE;
5638 setup_editor_el_boulderdash = FALSE;
5639 setup_editor_el_emerald_mine = FALSE;
5640 setup_editor_el_emerald_mine_club = FALSE;
5641 setup_editor_el_more = FALSE;
5642 setup_editor_el_sokoban = FALSE;
5643 setup_editor_el_supaplex = FALSE;
5644 setup_editor_el_diamond_caves = FALSE;
5645 setup_editor_el_dx_boulderdash = FALSE;
5646 setup_editor_el_steel_chars = FALSE;
5648 setup_editor_el_custom = FALSE;
5652 static void ReinitializeElementList(void)
5654 static boolean initialization_needed = TRUE;
5658 ReinitializeElementList_EnableSections();
5660 if (initialization_needed)
5662 LoadSetup_EditorCascade(); /* load last editor cascade state */
5664 /* initialize editor cascade element from saved cascade state */
5665 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5667 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
5668 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
5670 if (IS_EDITOR_CASCADE(*cascade_element))
5672 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
5673 EL_CASCADE_INACTIVE(*cascade_element));
5676 initialization_needed = FALSE;
5679 checked_free(editor_elements);
5681 /* reload optional user defined element list for each invocation of editor */
5682 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
5683 &num_editor_el_user_defined);
5685 /* initialize dynamic level element list for each invocation of editor */
5686 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
5687 &num_editor_el_dynamic);
5689 /* initialize list of empty elements (used for padding, if needed) */
5690 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
5691 editor_el_empty[i] = EL_EMPTY;
5693 /* do some sanity checks for each element from element list */
5694 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5696 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
5698 int element = (*editor_elements_info[i].element_list)[j];
5700 if (element >= NUM_FILE_ELEMENTS)
5701 Error(ERR_WARN, "editor element %d is runtime element", element);
5703 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
5704 Error(ERR_WARN, "no element description text for element %d", element);
5708 num_editor_elements = 0;
5709 use_el_empty = FALSE;
5711 /* determine size of element list */
5712 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5714 boolean found_inactive_cascade = FALSE;
5716 if (*editor_elements_info[i].setup_value)
5718 if (setup.editor.el_headlines)
5720 // required for correct padding of palette headline buttons
5721 if (*editor_elements_info[i].headline_list_size > 0)
5722 num_editor_elements += editor.palette.cols;
5724 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
5726 int element = (*editor_elements_info[i].headline_list)[j];
5728 if (IS_EDITOR_CASCADE_INACTIVE(element))
5729 found_inactive_cascade = TRUE;
5733 if (found_inactive_cascade)
5736 // required for correct padding of palette element buttons
5737 int element_list_size = *editor_elements_info[i].element_list_size;
5739 (element_list_size + editor.palette.cols - 1) / editor.palette.cols;
5740 int element_buttons = editor.palette.cols * element_rows;
5742 num_editor_elements += element_buttons;
5746 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
5748 /* offer at least as many elements as element buttons exist */
5749 use_el_empty = TRUE;
5750 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
5752 num_editor_elements += num_editor_el_empty;
5756 num_editor_el_empty = 0;
5759 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
5761 /* fill element list */
5762 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5764 boolean found_inactive_cascade = FALSE;
5766 if (*editor_elements_info[i].setup_value)
5768 if (setup.editor.el_headlines)
5770 // required for correct padding of palette headline buttons
5771 int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
5772 editor.palette.cols : 0);
5774 for (j = 0; j < headline_size; j++)
5776 // use empty elements for padding of palette headline buttons
5777 int element = (j < *editor_elements_info[i].headline_list_size ?
5778 (*editor_elements_info[i].headline_list)[j] :
5779 editor_el_empty[0]);
5781 editor_elements[pos++] = element;
5783 if (IS_EDITOR_CASCADE_INACTIVE(element))
5784 found_inactive_cascade = TRUE;
5788 if (found_inactive_cascade)
5791 // required for correct padding of palette element buttons
5792 int element_list_size = *editor_elements_info[i].element_list_size;
5794 (element_list_size + editor.palette.cols - 1) / editor.palette.cols;
5795 int element_buttons = editor.palette.cols * element_rows;
5797 // copy all elements from element list
5798 for (j = 0; j < element_list_size; j++)
5799 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
5801 // use empty elements for padding of palette element buttons
5802 for (j = 0; j < element_buttons - element_list_size; j++)
5803 editor_elements[pos++] = editor_el_empty[0];
5807 /* (this function is also called before editor gadgets are initialized!) */
5808 AdjustElementListScrollbar();
5811 void PrintEditorElementList(void)
5813 boolean *stop = &setup_editor_el_user_defined;
5816 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
5818 int cascade_element = (*editor_elements_info[i].headline_list)[0];
5820 if (IS_EDITOR_CASCADE(cascade_element))
5822 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
5823 char *headline = element_info[cascade_element_show].editor_description;
5825 PrintLineWithPrefix("# ", "-", 77);
5826 Print("# %s\n", headline);
5827 PrintLineWithPrefix("# ", "-", 77);
5830 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
5832 int element = (*editor_elements_info[i].headline_list)[j];
5834 if (IS_EDITOR_CASCADE(element))
5835 element = EL_CHAR_MINUS;
5837 Print("# %s\n", element_info[element].token_name);
5843 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
5845 int element = (*editor_elements_info[i].element_list)[j];
5847 Print("# %s\n", element_info[element].token_name);
5855 static void ReinitializeElementListButtons(void)
5857 static boolean last_setup_value_headlines = FALSE;
5858 static boolean initialization_needed = TRUE;
5861 if (!initialization_needed) /* check if editor element setup has changed */
5863 if (last_setup_value_headlines != setup.editor.el_headlines)
5864 initialization_needed = TRUE;
5866 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5867 if (editor_elements_info[i].last_setup_value !=
5868 *editor_elements_info[i].setup_value)
5869 initialization_needed = TRUE;
5872 if (!initialization_needed)
5875 FreeLevelEditorGadgets();
5876 CreateLevelEditorGadgets();
5878 /* store current setup values for next invocation of this function */
5879 last_setup_value_headlines = setup.editor.el_headlines;
5880 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5881 editor_elements_info[i].last_setup_value =
5882 *editor_elements_info[i].setup_value;
5884 initialization_needed = FALSE;
5887 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
5890 int border_graphic =
5891 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
5892 struct GraphicInfo *g = &graphic_info[border_graphic];
5893 Bitmap *src_bitmap = g->bitmap;
5894 int src_x = g->src_x;
5895 int src_y = g->src_y;
5896 int border_size = g->border_size;
5897 int border_xpos = g->width - border_size;
5898 int border_ypos = g->height - border_size;
5899 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
5902 BlitBitmap(src_bitmap, drawto, src_x, src_y,
5903 border_size, border_size,
5904 dest_x - border_size, dest_y - border_size);
5905 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y,
5906 border_size, border_size,
5907 dest_x + width, dest_y - border_size);
5908 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_ypos,
5909 border_size, border_size,
5910 dest_x - border_size, dest_y + height);
5911 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_ypos,
5912 border_size, border_size,
5913 dest_x + width, dest_y + height);
5915 for (i = 0; i < width / tilesize; i++)
5917 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y,
5918 tilesize, border_size,
5919 dest_x + i * tilesize, dest_y - border_size);
5920 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y + border_ypos,
5921 tilesize, border_size,
5922 dest_x + i * tilesize, dest_y + height);
5925 for (i = 0; i < height / tilesize; i++)
5927 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_size,
5928 border_size, tilesize,
5929 dest_x - border_size, dest_y + i * tilesize);
5930 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_size,
5931 border_size, tilesize,
5932 dest_x + width, dest_y + i * tilesize);
5935 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
5938 static void DrawEditorLevelBorderLine(int x, int y, int xsize, int ysize)
5940 int xsize_tile = MAX(ed_tilesize, xsize);
5941 int ysize_tile = MAX(ed_tilesize, ysize);
5942 int xsize_full = xsize + 1;
5943 int ysize_full = ysize + 1;
5944 int xsize_thin = (xsize < ed_tilesize ? 1 : xsize);
5945 int ysize_thin = (ysize < ed_tilesize ? 1 : ysize);
5946 Pixel line_color = getTabulatorBarColor();
5948 if (line_color == BLACK_PIXEL) /* black => transparent */
5951 FillRectangle(drawto, SX + x, SY + y, xsize_tile, ysize_tile, BLACK_PIXEL);
5952 FillRectangle(drawto, SX + x, SY + y, xsize_full, ysize_full, line_color);
5953 FillRectangle(drawto, SX + x, SY + y, xsize_thin, ysize_thin, BLACK_PIXEL);
5956 static void DrawEditorLevelBorderLinesIfNeeded(void)
5958 int xsize = lev_fieldx * ed_tilesize;
5959 int ysize = lev_fieldy * ed_tilesize;
5960 int line_size = getTabulatorBarHeight();
5962 if (!suppressBorderElement())
5965 /* draw little border line around editable level playfield */
5968 DrawEditorLevelBorderLine(xsize, 0, line_size, ysize);
5971 DrawEditorLevelBorderLine(0, ysize, xsize, line_size);
5973 if (xsize < SXSIZE && ysize < SYSIZE)
5974 DrawEditorLevelBorderLine(xsize, ysize, line_size, line_size);
5977 static void DrawEditorElement(int x, int y, int element)
5979 DrawSizedElement(x, y, element, ed_tilesize);
5982 static void DrawEditorElementThruMask(int x, int y, int element)
5984 DrawSizedElementThruMask(x, y, element, ed_tilesize);
5987 static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
5989 DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
5992 static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
5994 DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
5995 DrawEditorLevelBorderLinesIfNeeded();
5998 static void DrawDrawingArea(int id)
6000 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6003 int *value = drawingarea_info[id].value;
6004 int area_xsize = drawingarea_info[id].area_xsize;
6005 int area_ysize = drawingarea_info[id].area_ysize;
6006 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6008 for (x = 0; x < area_xsize; x++)
6009 for (y = 0; y < area_ysize; y++)
6010 DrawSizedGraphicExt(drawto,
6011 gi->x + x * tilesize,
6012 gi->y + y * tilesize,
6013 el2edimg(value[x * area_ysize + y]), 0, tilesize);
6016 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
6019 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
6020 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
6022 BlitBitmap(drawto, drawto,
6023 SX + (dx == -1 ? ed_tilesize : 0),
6024 SY + (dy == -1 ? ed_tilesize : 0),
6025 (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
6026 (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
6027 SX + (dx == +1 ? ed_tilesize : 0),
6028 SY + (dy == +1 ? ed_tilesize : 0));
6032 x = (dx == 1 ? 0 : ed_fieldx - 1);
6033 for (y = 0; y < ed_fieldy; y++)
6034 DrawEditorElementOrWall(x, y, from_x, from_y);
6038 y = (dy == 1 ? 0 : ed_fieldy - 1);
6039 for (x = 0; x < ed_fieldx; x++)
6040 DrawEditorElementOrWall(x, y, from_x, from_y);
6043 redraw_mask |= REDRAW_FIELD;
6047 static void getEditorGraphicSource(int element, int tile_size, Bitmap **bitmap,
6050 getSizedGraphicSource(el2edimg(element), 0, tile_size, bitmap, x, y);
6053 static void CreateControlButtons(void)
6055 struct GadgetInfo *gi;
6058 /* create toolbox buttons */
6059 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6061 int id = controlbutton_info[i].gadget_id;
6062 int type = controlbutton_info[i].gadget_type;
6063 int graphic = controlbutton_info[i].graphic;
6064 struct XYTileSize *pos = controlbutton_info[i].pos;
6065 struct GraphicInfo *gd = &graphic_info[graphic];
6066 Bitmap *deco_bitmap = NULL;
6067 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
6068 int tile_size = 0, deco_shift = 0;
6069 boolean deco_masked = FALSE;
6070 int gd_x1 = gd->src_x;
6071 int gd_y1 = gd->src_y;
6072 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6073 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6074 int gd_x1a = gd->src_x + gd->active_xoffset;
6075 int gd_y1a = gd->src_y + gd->active_yoffset;
6076 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6077 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
6080 unsigned int event_mask;
6081 int radio_button_nr = RADIO_NR_NONE;
6082 boolean checked = FALSE;
6084 if (type == GD_TYPE_RADIO_BUTTON)
6086 event_mask = GD_EVENT_PRESSED;
6087 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
6089 if (id == drawing_function)
6094 if (id == GADGET_ID_WRAP_LEFT ||
6095 id == GADGET_ID_WRAP_RIGHT ||
6096 id == GADGET_ID_WRAP_UP ||
6097 id == GADGET_ID_WRAP_DOWN)
6098 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6100 event_mask = GD_EVENT_RELEASED;
6103 if (id == GADGET_ID_PROPERTIES ||
6104 id == GADGET_ID_PALETTE)
6109 else if (id == GADGET_ID_ELEMENT_LEFT ||
6110 id == GADGET_ID_ELEMENT_MIDDLE ||
6111 id == GADGET_ID_ELEMENT_RIGHT)
6116 int element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
6117 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
6118 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : EL_EMPTY);
6120 tile_size = BUTTON_TILE_SIZE(id == GADGET_ID_ELEMENT_LEFT ?
6121 editor.button.element_left.tile_size :
6122 id == GADGET_ID_ELEMENT_MIDDLE ?
6123 editor.button.element_middle.tile_size :
6124 id == GADGET_ID_ELEMENT_RIGHT ?
6125 editor.button.element_right.tile_size : 0);
6127 // make sure that decoration does not overlap gadget border
6128 tile_size = MIN(tile_size, MIN(gd->width, gd->height));
6130 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x,&deco_y);
6132 deco_xpos = (gd->width - tile_size) / 2;
6133 deco_ypos = (gd->height - tile_size) / 2;
6135 deco_masked = gd->draw_masked;
6143 gi = CreateGadget(GDI_CUSTOM_ID, id,
6144 GDI_CUSTOM_TYPE_ID, i,
6145 GDI_IMAGE_ID, graphic,
6146 GDI_INFO_TEXT, controlbutton_info[i].infotext,
6149 GDI_WIDTH, gd->width,
6150 GDI_HEIGHT, gd->height,
6152 GDI_STATE, GD_BUTTON_UNPRESSED,
6153 GDI_RADIO_NR, radio_button_nr,
6154 GDI_CHECKED, checked,
6155 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6156 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6157 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6158 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
6159 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6160 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6161 GDI_DECORATION_SIZE, tile_size, tile_size,
6162 GDI_DECORATION_SHIFTING, deco_shift, deco_shift,
6163 GDI_DECORATION_MASKED, deco_masked,
6164 GDI_EVENT_MASK, event_mask,
6165 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6166 GDI_CALLBACK_ACTION, HandleControlButtons,
6170 Error(ERR_EXIT, "cannot create gadget");
6172 level_editor_gadget[id] = gi;
6175 /* these values are not constant, but can change at runtime */
6176 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
6177 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
6178 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
6179 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
6180 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
6181 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
6182 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
6183 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
6184 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].x = ED_SCROLL2_UP_XPOS;
6185 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y = ED_SCROLL2_UP_YPOS;
6186 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x = ED_SCROLL2_DOWN_XPOS;
6187 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y = ED_SCROLL2_DOWN_YPOS;
6189 /* create buttons for scrolling of drawing area and element list */
6190 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
6192 int id = scrollbutton_info[i].gadget_id;
6193 int graphic = scrollbutton_info[i].graphic;
6194 struct GraphicInfo *gd = &graphic_info[graphic];
6195 Bitmap *gd_bitmap = gd->bitmap;
6196 int gd_x1 = gd->src_x;
6197 int gd_y1 = gd->src_y;
6198 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6199 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6200 int width = gd->width;
6201 int height = gd->height;
6202 int x = scrollbutton_pos[i].x;
6203 int y = scrollbutton_pos[i].y;
6204 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6206 if (id == GADGET_ID_SCROLL_LIST_UP ||
6207 id == GADGET_ID_SCROLL_LIST_DOWN)
6218 gi = CreateGadget(GDI_CUSTOM_ID, id,
6219 GDI_CUSTOM_TYPE_ID, i,
6220 GDI_IMAGE_ID, graphic,
6221 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6226 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6227 GDI_STATE, GD_BUTTON_UNPRESSED,
6228 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6229 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6230 GDI_EVENT_MASK, event_mask,
6231 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6232 GDI_CALLBACK_ACTION, HandleControlButtons,
6236 Error(ERR_EXIT, "cannot create gadget");
6238 level_editor_gadget[id] = gi;
6241 /* create buttons for element list */
6242 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6244 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
6245 int graphic = IMG_EDITOR_PALETTE_BUTTON;
6246 struct GraphicInfo *gd = &graphic_info[graphic];
6247 Bitmap *gd_bitmap = gd->bitmap;
6248 Bitmap *deco_bitmap;
6249 int deco_x, deco_y, deco_xpos, deco_ypos;
6250 int gd_x1 = gd->src_x;
6251 int gd_y1 = gd->src_y;
6252 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6253 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6254 int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
6255 int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
6256 int x = PX + ED_ELEMENTLIST_XPOS + xx * gd->width;
6257 int y = PY + ED_ELEMENTLIST_YPOS + yy * gd->height;
6258 int element = editor_elements[i];
6259 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
6260 unsigned int event_mask = GD_EVENT_RELEASED;
6262 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
6264 deco_xpos = (gd->width - tile_size) / 2;
6265 deco_ypos = (gd->height - tile_size) / 2;
6267 gi = CreateGadget(GDI_CUSTOM_ID, id,
6268 GDI_CUSTOM_TYPE_ID, i,
6269 GDI_IMAGE_ID, graphic,
6270 GDI_INFO_TEXT, getElementInfoText(element),
6273 GDI_WIDTH, gd->width,
6274 GDI_HEIGHT, gd->height,
6275 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6276 GDI_STATE, GD_BUTTON_UNPRESSED,
6277 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6278 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6279 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6280 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6281 GDI_DECORATION_SIZE, tile_size, tile_size,
6282 GDI_DECORATION_SHIFTING, 1, 1,
6283 GDI_EVENT_MASK, event_mask,
6284 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6285 GDI_CALLBACK_ACTION, HandleControlButtons,
6289 Error(ERR_EXIT, "cannot create gadget");
6291 level_editor_gadget[id] = gi;
6295 static void CreateCounterButtons(void)
6297 int max_infotext_len = getMaxInfoTextLength();
6300 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
6303 int x = SX + ED_SETTINGS_X(counterbutton_info[i].x); /* down count button */
6304 int y = SY + ED_SETTINGS_Y(counterbutton_info[i].y);
6306 /* determine horizontal position to the right of specified gadget */
6307 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6308 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
6309 ED_GADGET_TEXT_DISTANCE);
6311 /* determine horizontal offset for leading text */
6312 if (counterbutton_info[i].text_left != NULL)
6313 x += getTextWidthForGadget(counterbutton_info[i].text_left);
6315 for (j = 0; j < 2; j++)
6317 struct GadgetInfo *gi;
6319 counterbutton_info[i].gadget_id_down :
6320 counterbutton_info[i].gadget_id_up);
6322 struct GraphicInfo *gd;
6323 int gd_x1, gd_x2, gd_y1, gd_y2;
6324 unsigned int event_mask;
6325 char infotext[max_infotext_len + 1];
6327 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6329 if (i == ED_COUNTER_ID_SELECT_LEVEL)
6332 IMG_GFX_EDITOR_BUTTON_PREV_LEVEL :
6333 IMG_GFX_EDITOR_BUTTON_NEXT_LEVEL);
6335 event_mask |= GD_EVENT_RELEASED;
6339 x = DX + editor.button.prev_level.x;
6340 y = DY + editor.button.prev_level.y;
6344 x = DX + editor.button.next_level.x;
6345 y = DY + editor.button.next_level.y;
6351 IMG_EDITOR_COUNTER_DOWN :
6352 IMG_EDITOR_COUNTER_UP);
6355 gd = &graphic_info[graphic];
6359 gd_x2 = gd->src_x + gd->pressed_xoffset;
6360 gd_y2 = gd->src_y + gd->pressed_yoffset;
6362 sprintf(infotext, "%s counter value by 1, 5 or 10",
6363 (j == 0 ? "decrease" : "increase"));
6365 gi = CreateGadget(GDI_CUSTOM_ID, id,
6366 GDI_CUSTOM_TYPE_ID, i,
6367 GDI_IMAGE_ID, graphic,
6368 GDI_INFO_TEXT, infotext,
6371 GDI_WIDTH, gd->width,
6372 GDI_HEIGHT, gd->height,
6373 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6374 GDI_STATE, GD_BUTTON_UNPRESSED,
6375 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6376 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6377 GDI_EVENT_MASK, event_mask,
6378 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6379 GDI_CALLBACK_ACTION, HandleCounterButtons,
6383 Error(ERR_EXIT, "cannot create gadget");
6385 level_editor_gadget[id] = gi;
6386 right_gadget_border[id] =
6387 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
6389 x += gi->width + ED_GADGET_SMALL_DISTANCE; /* text count button */
6393 int font_type = FONT_INPUT_1;
6394 int font_type_active = FONT_INPUT_1_ACTIVE;
6396 id = counterbutton_info[i].gadget_id_text;
6398 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6400 if (i == ED_COUNTER_ID_SELECT_LEVEL)
6402 graphic = IMG_GFX_EDITOR_INPUT_LEVEL_NUMBER;
6404 font_type = FONT_LEVEL_NUMBER;
6405 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
6407 x = DX + editor.input.level_number.x;
6408 y = DY + editor.input.level_number.y;
6412 graphic = IMG_EDITOR_COUNTER_INPUT;
6415 gd = &graphic_info[graphic];
6419 gd_x2 = gd->src_x + gd->active_xoffset;
6420 gd_y2 = gd->src_y + gd->active_yoffset;
6422 gi = CreateGadget(GDI_CUSTOM_ID, id,
6423 GDI_CUSTOM_TYPE_ID, i,
6424 GDI_IMAGE_ID, graphic,
6425 GDI_INFO_TEXT, "enter counter value",
6428 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
6429 GDI_NUMBER_VALUE, 0,
6430 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
6431 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
6432 GDI_TEXT_SIZE, 3, /* minimal counter text size */
6433 GDI_TEXT_FONT, font_type,
6434 GDI_TEXT_FONT_ACTIVE, font_type_active,
6435 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6436 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6437 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6438 GDI_DESIGN_WIDTH, gd->width,
6439 GDI_EVENT_MASK, event_mask,
6440 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6441 GDI_CALLBACK_ACTION, HandleCounterButtons,
6445 Error(ERR_EXIT, "cannot create gadget");
6447 level_editor_gadget[id] = gi;
6448 right_gadget_border[id] =
6449 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
6451 x += gi->width + ED_GADGET_SMALL_DISTANCE; /* up count button */
6457 static void CreateDrawingAreas(void)
6461 /* these values are not constant, but can change at runtime */
6462 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
6463 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
6465 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
6467 struct GadgetInfo *gi;
6468 unsigned int event_mask;
6469 int id = drawingarea_info[i].gadget_id;
6470 int x = SX + ED_AREA_SETTINGS_X(drawingarea_info[i]);
6471 int y = SY + ED_AREA_SETTINGS_Y(drawingarea_info[i]);
6472 int area_xsize = drawingarea_info[i].area_xsize;
6473 int area_ysize = drawingarea_info[i].area_ysize;
6474 int item_size = (id == GADGET_ID_DRAWING_LEVEL ?
6475 ed_tilesize : ED_DRAWINGAREA_TILE_SIZE);
6478 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
6479 GD_EVENT_OFF_BORDERS | GD_EVENT_PIXEL_PRECISE;
6481 /* determine horizontal position to the right of specified gadget */
6482 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
6483 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
6484 ED_DRAWINGAREA_TEXT_DISTANCE);
6486 /* determine horizontal offset for leading text */
6487 if (drawingarea_info[i].text_left != NULL)
6488 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
6490 gi = CreateGadget(GDI_CUSTOM_ID, id,
6491 GDI_CUSTOM_TYPE_ID, i,
6494 GDI_TYPE, GD_TYPE_DRAWING_AREA,
6495 GDI_AREA_SIZE, area_xsize, area_ysize,
6496 GDI_ITEM_SIZE, item_size, item_size,
6497 GDI_EVENT_MASK, event_mask,
6498 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
6499 GDI_CALLBACK_ACTION, HandleDrawingAreas,
6503 Error(ERR_EXIT, "cannot create gadget");
6505 level_editor_gadget[id] = gi;
6506 right_gadget_border[id] =
6507 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
6511 static void CreateTextInputGadgets(void)
6513 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
6514 int max_infotext_len = getMaxInfoTextLength();
6517 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
6519 int gd_x1 = gd->src_x;
6520 int gd_y1 = gd->src_y;
6521 int gd_x2 = gd->src_x + gd->active_xoffset;
6522 int gd_y2 = gd->src_y + gd->active_yoffset;
6523 struct GadgetInfo *gi;
6524 unsigned int event_mask;
6525 char infotext[MAX_OUTPUT_LINESIZE + 1];
6526 int id = textinput_info[i].gadget_id;
6529 if (i == ED_TEXTINPUT_ID_ELEMENT_NAME)
6531 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
6532 int border_size = gd->border_size;
6533 int font_nr = FONT_INPUT_1;
6534 int font_height = getFontHeight(font_nr);
6535 int xoffset = element_border + TILEX + element_border + 3 * border_size;
6536 int yoffset = element_border + (TILEY - font_height) / 2;
6538 x = (editor.settings.element_name.x != -1 ?
6539 editor.settings.element_name.x :
6540 editor.settings.element_graphic.x + xoffset) - border_size;
6541 y = (editor.settings.element_name.y != -1 ?
6542 editor.settings.element_name.y :
6543 editor.settings.element_graphic.y + yoffset) - border_size;
6547 x = ED_SETTINGS_X(textinput_info[i].x);
6548 y = ED_SETTINGS_Y(textinput_info[i].y);
6551 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6553 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
6554 infotext[max_infotext_len] = '\0';
6556 gi = CreateGadget(GDI_CUSTOM_ID, id,
6557 GDI_CUSTOM_TYPE_ID, i,
6558 GDI_INFO_TEXT, infotext,
6561 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
6562 GDI_TEXT_VALUE, textinput_info[i].value,
6563 GDI_TEXT_SIZE, textinput_info[i].size,
6564 GDI_TEXT_FONT, FONT_INPUT_1,
6565 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6566 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6567 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6568 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6569 GDI_DESIGN_WIDTH, gd->width,
6570 GDI_EVENT_MASK, event_mask,
6571 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6572 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
6576 Error(ERR_EXIT, "cannot create gadget");
6578 level_editor_gadget[id] = gi;
6582 static void CreateTextAreaGadgets(void)
6584 int max_infotext_len = getMaxInfoTextLength();
6587 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
6589 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXTAREA];
6590 int gd_x1 = gd->src_x;
6591 int gd_y1 = gd->src_y;
6592 int gd_x2 = gd->src_x + gd->active_xoffset;
6593 int gd_y2 = gd->src_y + gd->active_yoffset;
6594 struct GadgetInfo *gi;
6595 unsigned int event_mask;
6596 char infotext[MAX_OUTPUT_LINESIZE + 1];
6597 int id = textarea_info[i].gadget_id;
6598 int area_xsize = textarea_info[i].xsize;
6599 int area_ysize = textarea_info[i].ysize;
6601 event_mask = GD_EVENT_TEXT_LEAVING;
6603 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
6604 infotext[max_infotext_len] = '\0';
6606 gi = CreateGadget(GDI_CUSTOM_ID, id,
6607 GDI_CUSTOM_TYPE_ID, i,
6608 GDI_INFO_TEXT, infotext,
6609 GDI_X, SX + ED_SETTINGS_X(textarea_info[i].x),
6610 GDI_Y, SY + ED_SETTINGS_Y(textarea_info[i].y),
6611 GDI_TYPE, GD_TYPE_TEXT_AREA,
6612 GDI_AREA_SIZE, area_xsize, area_ysize,
6613 GDI_TEXT_FONT, FONT_INPUT_1,
6614 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6615 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6616 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6617 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6618 GDI_DESIGN_WIDTH, gd->width,
6619 GDI_EVENT_MASK, event_mask,
6620 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6621 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
6625 Error(ERR_EXIT, "cannot create gadget");
6627 level_editor_gadget[id] = gi;
6631 static void CreateSelectboxGadgets(void)
6633 int max_infotext_len = getMaxInfoTextLength();
6636 for (i = 0; i < ED_NUM_SELECTBOX; i++)
6638 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_SELECTBOX_INPUT];
6639 struct GraphicInfo *gd2 = &graphic_info[IMG_EDITOR_SELECTBOX_BUTTON];
6640 int gd_x1 = gd->src_x;
6641 int gd_y1 = gd->src_y;
6642 int gd_x2 = gd->src_x + gd->active_xoffset;
6643 int gd_y2 = gd->src_y + gd->active_yoffset;
6644 int selectbox_button_xsize = gd2->width;
6645 struct GadgetInfo *gi;
6646 unsigned int event_mask;
6647 char infotext[MAX_OUTPUT_LINESIZE + 1];
6648 int id = selectbox_info[i].gadget_id;
6649 int x = SX + ED_SETTINGS_X(selectbox_info[i].x);
6650 int y = SY + ED_SETTINGS_Y(selectbox_info[i].y);
6652 if (selectbox_info[i].size == -1) /* dynamically determine size */
6654 /* (we cannot use -1 for uninitialized values if we directly compare
6655 with results from strlen(), because the '<' and '>' operation will
6656 implicitely cast -1 to an unsigned integer value!) */
6657 selectbox_info[i].size = 0;
6659 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
6660 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
6661 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
6663 selectbox_info[i].size++; /* add one character empty space */
6666 event_mask = GD_EVENT_RELEASED |
6667 GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6669 /* determine horizontal position to the right of specified gadget */
6670 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
6671 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
6672 ED_GADGET_TEXT_DISTANCE);
6674 /* determine horizontal offset for leading text */
6675 if (selectbox_info[i].text_left != NULL)
6676 x += getTextWidthForGadget(selectbox_info[i].text_left);
6678 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
6679 infotext[max_infotext_len] = '\0';
6681 gi = CreateGadget(GDI_CUSTOM_ID, id,
6682 GDI_CUSTOM_TYPE_ID, i,
6683 GDI_INFO_TEXT, infotext,
6686 GDI_TYPE, GD_TYPE_SELECTBOX,
6687 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
6688 GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
6689 GDI_TEXT_SIZE, selectbox_info[i].size,
6690 GDI_TEXT_FONT, FONT_INPUT_1,
6691 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6692 GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
6693 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6694 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6695 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6696 GDI_BORDER_SIZE_SELECTBUTTON, selectbox_button_xsize,
6697 GDI_DESIGN_WIDTH, gd->width,
6698 GDI_EVENT_MASK, event_mask,
6699 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6700 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
6704 Error(ERR_EXIT, "cannot create gadget");
6706 level_editor_gadget[id] = gi;
6707 right_gadget_border[id] =
6708 getRightGadgetBorder(gi, selectbox_info[i].text_right);
6712 static void CreateTextbuttonGadgets(void)
6714 int max_infotext_len = getMaxInfoTextLength();
6717 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
6719 int id = textbutton_info[i].gadget_id;
6721 ((id >= GADGET_ID_LEVELINFO_LEVEL && id <= GADGET_ID_LEVELINFO_EDITOR) ||
6722 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE));
6724 (is_tab_button ? IMG_EDITOR_TABBUTTON : IMG_EDITOR_TEXTBUTTON);
6725 int gadget_distance =
6726 (is_tab_button ? ED_GADGET_SMALL_DISTANCE : ED_GADGET_TEXT_DISTANCE);
6727 struct GraphicInfo *gd = &graphic_info[graphic];
6728 int gd_x1 = gd->src_x;
6729 int gd_y1 = gd->src_y;
6730 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6731 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6732 int gd_x1a = gd->src_x + gd->active_xoffset;
6733 int gd_y1a = gd->src_y + gd->active_yoffset;
6734 int border_xsize = gd->border_size + gd->draw_xoffset;
6735 int border_ysize = gd->border_size;
6736 struct GadgetInfo *gi;
6737 unsigned int event_mask;
6738 char infotext[MAX_OUTPUT_LINESIZE + 1];
6739 int x = SX + ED_SETTINGS_X(textbutton_info[i].x);
6740 int y = SY + ED_SETTINGS_Y(textbutton_info[i].y);
6742 if (textbutton_info[i].size == -1) /* dynamically determine size */
6743 textbutton_info[i].size = strlen(textbutton_info[i].text);
6745 event_mask = GD_EVENT_RELEASED;
6747 sprintf(infotext, "%s", textbutton_info[i].infotext);
6748 infotext[max_infotext_len] = '\0';
6750 /* determine horizontal position to the right of specified gadget */
6751 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6753 int gadget_id_align = textbutton_info[i].gadget_id_align;
6755 x = right_gadget_border[gadget_id_align] + gadget_distance;
6757 if (textbutton_info[i].y == -1)
6758 y = level_editor_gadget[gadget_id_align]->y;
6761 /* determine horizontal offset for leading text */
6762 if (textbutton_info[i].text_left != NULL)
6763 x += getTextWidthForGadget(textbutton_info[i].text_left);
6765 gi = CreateGadget(GDI_CUSTOM_ID, id,
6766 GDI_CUSTOM_TYPE_ID, i,
6767 GDI_IMAGE_ID, graphic,
6768 GDI_INFO_TEXT, infotext,
6771 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
6772 GDI_TEXT_VALUE, textbutton_info[i].text,
6773 GDI_TEXT_SIZE, textbutton_info[i].size,
6774 GDI_TEXT_FONT, FONT_INPUT_2,
6775 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2_ACTIVE,
6776 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6777 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6778 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6779 GDI_BORDER_SIZE, border_xsize, border_ysize,
6780 GDI_DESIGN_WIDTH, gd->width,
6781 GDI_DECORATION_SHIFTING, 1, 1,
6782 GDI_EVENT_MASK, event_mask,
6783 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6784 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
6788 Error(ERR_EXIT, "cannot create gadget");
6790 level_editor_gadget[id] = gi;
6791 right_gadget_border[id] =
6792 getRightGadgetBorder(gi, textbutton_info[i].text_right);
6796 static void CreateGraphicbuttonGadgets(void)
6798 struct GadgetInfo *gi;
6799 unsigned int event_mask;
6802 /* create buttons for scrolling of drawing area and element list */
6803 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
6805 int id = graphicbutton_info[i].gadget_id;
6806 int x = SX + ED_SETTINGS_X(graphicbutton_info[i].x);
6807 int y = SY + ED_SETTINGS_Y(graphicbutton_info[i].y);
6808 int graphic = graphicbutton_info[i].graphic;
6809 struct GraphicInfo *gd = &graphic_info[graphic];
6810 int gd_x1 = gd->src_x;
6811 int gd_y1 = gd->src_y;
6812 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6813 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6815 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6817 /* determine horizontal position to the right of specified gadget */
6818 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6819 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
6820 ED_GADGET_TEXT_DISTANCE);
6822 /* determine horizontal offset for leading text */
6823 if (graphicbutton_info[i].text_left != NULL)
6824 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
6826 gi = CreateGadget(GDI_CUSTOM_ID, id,
6827 GDI_CUSTOM_TYPE_ID, i,
6828 GDI_IMAGE_ID, graphic,
6829 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
6832 GDI_WIDTH, gd->width,
6833 GDI_HEIGHT, gd->height,
6834 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6835 GDI_STATE, GD_BUTTON_UNPRESSED,
6836 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6837 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6838 GDI_EVENT_MASK, event_mask,
6839 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6840 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
6844 Error(ERR_EXIT, "cannot create gadget");
6846 level_editor_gadget[id] = gi;
6847 right_gadget_border[id] =
6848 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
6852 static void CreateScrollbarGadgets(void)
6856 /* these values are not constant, but can change at runtime */
6857 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
6858 SX + ED_SCROLL_HORIZONTAL_XPOS;
6859 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
6860 SY + ED_SCROLL_HORIZONTAL_YPOS;
6861 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
6862 ED_SCROLL_HORIZONTAL_XSIZE;
6863 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
6864 ED_SCROLL_HORIZONTAL_YSIZE;
6865 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
6866 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
6867 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
6868 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
6870 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
6871 SX + ED_SCROLL_VERTICAL_XPOS;
6872 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
6873 SY + ED_SCROLL_VERTICAL_YPOS;
6874 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
6875 ED_SCROLL_VERTICAL_XSIZE;
6876 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
6877 ED_SCROLL_VERTICAL_YSIZE;
6878 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
6879 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
6880 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
6881 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
6883 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
6884 PX + ED_SCROLL2_VERTICAL_XPOS;
6885 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
6886 PY + ED_SCROLL2_VERTICAL_YPOS;
6887 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
6888 ED_SCROLL2_VERTICAL_XSIZE;
6889 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
6890 ED_SCROLL2_VERTICAL_YSIZE;
6891 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = PX;
6892 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = PY;
6893 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width = PXSIZE;
6894 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = PYSIZE;
6896 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
6898 int id = scrollbar_info[i].gadget_id;
6899 int graphic = scrollbar_info[i].graphic;
6900 struct GraphicInfo *gd = &graphic_info[graphic];
6901 int gd_x1 = gd->src_x;
6902 int gd_y1 = gd->src_y;
6903 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6904 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6905 struct GadgetInfo *gi;
6906 int items_max, items_visible, item_position;
6907 unsigned int event_mask;
6909 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
6911 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
6912 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
6913 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
6915 else /* drawing area scrollbars */
6917 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
6919 items_max = MAX(lev_fieldx + 2, ed_fieldx);
6920 items_visible = ed_fieldx;
6925 items_max = MAX(lev_fieldy + 2, ed_fieldy);
6926 items_visible = ed_fieldy;
6931 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
6933 gi = CreateGadget(GDI_CUSTOM_ID, id,
6934 GDI_CUSTOM_TYPE_ID, i,
6935 GDI_IMAGE_ID, graphic,
6936 GDI_INFO_TEXT, scrollbar_info[i].infotext,
6937 GDI_X, scrollbar_pos[i].x,
6938 GDI_Y, scrollbar_pos[i].y,
6939 GDI_WIDTH, scrollbar_pos[i].width,
6940 GDI_HEIGHT, scrollbar_pos[i].height,
6941 GDI_TYPE, scrollbar_info[i].type,
6942 GDI_SCROLLBAR_ITEMS_MAX, items_max,
6943 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
6944 GDI_SCROLLBAR_ITEM_POSITION, item_position,
6945 GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
6946 GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
6947 GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
6948 GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
6949 GDI_STATE, GD_BUTTON_UNPRESSED,
6950 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6951 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6952 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6953 GDI_EVENT_MASK, event_mask,
6954 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6955 GDI_CALLBACK_ACTION, HandleControlButtons,
6959 Error(ERR_EXIT, "cannot create gadget");
6961 level_editor_gadget[id] = gi;
6965 static void CreateCheckbuttonGadgets(void)
6967 struct GadgetInfo *gi;
6968 unsigned int event_mask;
6971 event_mask = GD_EVENT_PRESSED;
6973 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
6975 int id = checkbutton_info[i].gadget_id;
6976 int graphic = (id == GADGET_ID_STICK_ELEMENT ? IMG_EDITOR_STICKYBUTTON :
6977 IMG_EDITOR_CHECKBOX);
6978 struct GraphicInfo *gd = &graphic_info[graphic];
6979 int gd_x1 = gd->src_x;
6980 int gd_y1 = gd->src_y;
6981 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6982 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6983 int gd_x1a = gd->src_x + gd->active_xoffset;
6984 int gd_y1a = gd->src_y + gd->active_yoffset;
6985 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6986 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
6987 int x = SX + ED_SETTINGS_X(checkbutton_info[i].x);
6988 int y = SY + ED_SETTINGS_Y(checkbutton_info[i].y);
6990 /* determine horizontal position to the right of specified gadget */
6991 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6992 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
6993 ED_GADGET_TEXT_DISTANCE);
6995 /* determine horizontal offset for leading text */
6996 if (checkbutton_info[i].text_left != NULL)
6997 x += getTextWidthForGadget(checkbutton_info[i].text_left);
6999 gi = CreateGadget(GDI_CUSTOM_ID, id,
7000 GDI_CUSTOM_TYPE_ID, i,
7001 GDI_IMAGE_ID, graphic,
7002 GDI_INFO_TEXT, checkbutton_info[i].infotext,
7005 GDI_WIDTH, gd->width,
7006 GDI_HEIGHT, gd->height,
7007 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
7008 GDI_CHECKED, *checkbutton_info[i].value,
7009 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7010 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7011 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7012 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7013 GDI_EVENT_MASK, event_mask,
7014 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7015 GDI_CALLBACK_ACTION, HandleCheckbuttons,
7019 Error(ERR_EXIT, "cannot create gadget");
7021 level_editor_gadget[id] = gi;
7022 right_gadget_border[id] =
7023 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
7027 static void CreateRadiobuttonGadgets(void)
7029 int graphic = IMG_EDITOR_RADIOBUTTON;
7030 struct GraphicInfo *gd = &graphic_info[graphic];
7031 int gd_x1 = gd->src_x;
7032 int gd_y1 = gd->src_y;
7033 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7034 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7035 int gd_x1a = gd->src_x + gd->active_xoffset;
7036 int gd_y1a = gd->src_y + gd->active_yoffset;
7037 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7038 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7039 struct GadgetInfo *gi;
7040 unsigned int event_mask;
7043 event_mask = GD_EVENT_PRESSED;
7045 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
7047 int id = radiobutton_info[i].gadget_id;
7048 int x = SX + ED_SETTINGS_X(radiobutton_info[i].x);
7049 int y = SY + ED_SETTINGS_Y(radiobutton_info[i].y);
7052 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
7054 /* determine horizontal position to the right of specified gadget */
7055 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
7056 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
7057 ED_GADGET_TEXT_DISTANCE);
7059 /* determine horizontal offset for leading text */
7060 if (radiobutton_info[i].text_left != NULL)
7061 x += getTextWidthForGadget(radiobutton_info[i].text_left);
7063 gi = CreateGadget(GDI_CUSTOM_ID, id,
7064 GDI_CUSTOM_TYPE_ID, i,
7065 GDI_IMAGE_ID, graphic,
7066 GDI_INFO_TEXT, radiobutton_info[i].infotext,
7069 GDI_WIDTH, gd->width,
7070 GDI_HEIGHT, gd->height,
7071 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
7072 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
7073 GDI_CHECKED, checked,
7074 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7075 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7076 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7077 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7078 GDI_EVENT_MASK, event_mask,
7079 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7080 GDI_CALLBACK_ACTION, HandleRadiobuttons,
7084 Error(ERR_EXIT, "cannot create gadget");
7086 level_editor_gadget[id] = gi;
7087 right_gadget_border[id] =
7088 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
7092 void CreateLevelEditorGadgets(void)
7094 /* force EDITOR font inside level editor */
7095 SetFontStatus(GAME_MODE_EDITOR);
7097 /* these values are not constant, but can change at runtime */
7098 ed_fieldx = MAX_ED_FIELDX - 1;
7099 ed_fieldy = MAX_ED_FIELDY - 1;
7101 num_editor_gadgets = NUM_EDITOR_GADGETS;
7103 // printf("::: allocating %d gadgets ...\n", num_editor_gadgets);
7105 level_editor_gadget =
7106 checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *));
7107 right_gadget_border =
7108 checked_calloc(num_editor_gadgets * sizeof(int));
7110 editor_el_empty = checked_calloc(ED_NUM_ELEMENTLIST_BUTTONS * sizeof(int));
7111 editor_el_empty_ptr = editor_el_empty;
7113 use_permanent_palette = !editor.palette.show_as_separate_screen;
7115 ReinitializeElementList();
7117 CreateControlButtons();
7118 CreateScrollbarGadgets();
7120 /* order of function calls is important because of cross-references */
7121 CreateCheckbuttonGadgets();
7122 CreateCounterButtons();
7123 CreateRadiobuttonGadgets();
7124 CreateTextInputGadgets();
7125 CreateTextAreaGadgets();
7126 CreateSelectboxGadgets();
7127 CreateGraphicbuttonGadgets();
7128 CreateTextbuttonGadgets();
7129 CreateDrawingAreas();
7134 void FreeLevelEditorGadgets(void)
7138 // printf("::: freeing %d gadgets ...\n", num_editor_gadgets);
7140 for (i = 0; i < num_editor_gadgets; i++)
7142 FreeGadget(level_editor_gadget[i]);
7144 level_editor_gadget[i] = NULL;
7147 checked_free(level_editor_gadget);
7148 checked_free(right_gadget_border);
7150 checked_free(editor_el_empty);
7153 static void MapCounterButtons(int id)
7155 int font_nr = FONT_TEXT_1;
7156 int font_height = getFontHeight(font_nr);
7157 int gadget_id_down = counterbutton_info[id].gadget_id_down;
7158 int gadget_id_text = counterbutton_info[id].gadget_id_text;
7159 int gadget_id_up = counterbutton_info[id].gadget_id_up;
7160 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
7161 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
7162 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
7163 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
7164 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7165 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7166 int yoffset = (gi_down->height - font_height) / 2;
7167 int x_left = gi_down->x - xoffset_left;
7168 int x_right; /* set after gadget position was modified */
7169 int y_above = gi_down->y - yoffset_above;
7171 int y; /* set after gadget position was modified */
7173 /* counter limits must be changed first to prevent value truncation */
7174 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
7175 counterbutton_info[id].max_value);
7177 /* right text position might have changed after setting position above */
7178 x_right = gi_up->x + gi_up->width + xoffset_right;
7180 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
7182 /* set position for "value[1,2,3,4]" counter gadgets (score in most cases) */
7183 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
7184 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
7186 ModifyGadget(gi_down, GDI_Y,
7187 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7188 ModifyGadget(gi_text, GDI_Y,
7189 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7190 ModifyGadget(gi_up, GDI_Y,
7191 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7194 /* vertical position might have changed after setting position above */
7195 y = gi_up->y + yoffset;
7197 if (counterbutton_info[id].text_above)
7198 DrawText(x, y_above, counterbutton_info[id].text_above, font_nr);
7200 if (counterbutton_info[id].text_left)
7201 DrawText(x_left, y, counterbutton_info[id].text_left, font_nr);
7203 if (counterbutton_info[id].text_right)
7204 DrawText(x_right, y, counterbutton_info[id].text_right, font_nr);
7211 static void MapControlButtons(void)
7216 /* map toolbox buttons (excluding special CE toolbox buttons) */
7217 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
7218 MapGadget(level_editor_gadget[i]);
7220 /* map toolbox buttons (element properties buttons) */
7221 for (i = ED_NUM_CTRL1_4_BUTTONS; i < ED_NUM_CTRL1_7_BUTTONS; i++)
7222 MapGadget(level_editor_gadget[i]);
7224 if (use_permanent_palette)
7226 /* map buttons to select elements */
7227 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7228 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
7229 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
7230 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
7231 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
7234 /* map buttons to select level */
7235 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
7236 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
7237 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
7238 MapCounterButtons(counter_id);
7241 static void MapDrawingArea(int id)
7243 int font_nr = FONT_TEXT_1;
7244 int font_height = getFontHeight(font_nr);
7245 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
7246 int area_xsize = gi->drawing.area_xsize;
7247 int area_ysize = gi->drawing.area_ysize;
7248 int xoffset_left = getTextWidthForDrawingArea(drawingarea_info[id].text_left);
7249 int xoffset_below = getTextWidth(drawingarea_info[id].text_below, font_nr);
7250 int x_left = gi->x - xoffset_left;
7251 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
7252 int x_below = gi->x + (gi->width - xoffset_below) / 2;
7253 int y_side = gi->y + (gi->height - font_height) / 2;
7254 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
7256 if (drawingarea_info[id].text_left)
7257 DrawText(x_left, y_side, drawingarea_info[id].text_left, font_nr);
7259 if (drawingarea_info[id].text_right)
7260 DrawText(x_right, y_side, drawingarea_info[id].text_right, font_nr);
7262 if (drawingarea_info[id].text_below)
7263 DrawText(x_below, y_below, drawingarea_info[id].text_below, font_nr);
7265 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
7267 DrawElementBorder(gi->x, gi->y,
7268 area_xsize * ED_DRAWINGAREA_TILE_SIZE,
7269 area_ysize * ED_DRAWINGAREA_TILE_SIZE, TRUE);
7271 DrawDrawingArea(id);
7277 static void MapTextInputGadget(int id)
7279 int font_nr = FONT_TEXT_1;
7280 int font_height = getFontHeight(font_nr);
7281 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
7282 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7283 int x_above = ED_SETTINGS_X(textinput_info[id].x);
7284 int y_above = ED_SETTINGS_Y(textinput_info[id].y) - yoffset_above;
7286 if (textinput_info[id].text_above)
7287 DrawTextS(x_above, y_above, font_nr, textinput_info[id].text_above);
7289 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
7294 static void MapTextAreaGadget(int id)
7296 int font_nr = FONT_TEXT_1;
7297 int font_height = getFontHeight(font_nr);
7298 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
7299 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7300 int x_above = ED_SETTINGS_X(textarea_info[id].x);
7301 int y_above = ED_SETTINGS_Y(textarea_info[id].y) - yoffset_above;
7303 if (textarea_info[id].text_above)
7304 DrawTextS(x_above, y_above, font_nr, textarea_info[id].text_above);
7306 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
7311 static void MapSelectboxGadget(int id)
7313 int font_nr = FONT_TEXT_1;
7314 int font_height = getFontHeight(font_nr);
7315 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
7316 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
7317 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7318 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7319 int yoffset = (gi->height - font_height) / 2;
7320 int x_left = gi->x - xoffset_left;
7321 int x_right = gi->x + gi->width + xoffset_right;
7322 int y_above = gi->y - yoffset_above;
7324 int y = gi->y + yoffset;
7326 if (selectbox_info[id].text_above)
7327 DrawText(x, y_above, selectbox_info[id].text_above, font_nr);
7329 if (selectbox_info[id].text_left)
7330 DrawText(x_left, y, selectbox_info[id].text_left, font_nr);
7332 if (selectbox_info[id].text_right)
7333 DrawText(x_right, y, selectbox_info[id].text_right, font_nr);
7335 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
7340 static void MapTextbuttonGadget(int id)
7342 int font_nr = FONT_TEXT_1;
7343 int font_height = getFontHeight(font_nr);
7344 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
7345 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
7346 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7347 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7348 int yoffset = (gi->height - font_height) / 2;
7349 int x_left = gi->x - xoffset_left;
7350 int x_right = gi->x + gi->width + xoffset_right;
7351 int y_above = gi->y - yoffset_above;
7353 int y = gi->y + yoffset;
7355 /* only show button to delete change pages when more than minimum pages */
7356 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
7357 custom_element.num_change_pages == MIN_CHANGE_PAGES)
7360 if (textbutton_info[id].text_above)
7361 DrawText(x, y_above, textbutton_info[id].text_above, font_nr);
7363 if (textbutton_info[id].text_left)
7364 DrawText(x_left, y, textbutton_info[id].text_left, font_nr);
7366 if (textbutton_info[id].text_right)
7367 DrawText(x_right, y, textbutton_info[id].text_right, font_nr);
7372 static void MapGraphicbuttonGadget(int id)
7374 int font_nr = FONT_TEXT_1;
7375 int font_height = getFontHeight(font_nr);
7376 struct GadgetInfo *gi= level_editor_gadget[graphicbutton_info[id].gadget_id];
7377 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
7378 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7379 int yoffset = (gi->height - font_height) / 2;
7380 int x_left = gi->x - xoffset_left;
7381 int x_right = gi->x + gi->width + xoffset_right;
7382 int y = gi->y + yoffset;
7384 if (graphicbutton_info[id].text_left)
7385 DrawText(x_left, y, graphicbutton_info[id].text_left, font_nr);
7387 if (graphicbutton_info[id].text_right)
7388 DrawText(x_right, y, graphicbutton_info[id].text_right, font_nr);
7393 static void MapRadiobuttonGadget(int id)
7395 int font_nr = FONT_TEXT_1;
7396 int font_height = getFontHeight(font_nr);
7397 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
7398 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
7399 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7400 int yoffset = (gi->height - font_height) / 2;
7401 int x_left = gi->x - xoffset_left;
7402 int x_right = gi->x + gi->width + xoffset_right;
7403 int y = gi->y + yoffset;
7405 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
7407 if (radiobutton_info[id].text_left)
7408 DrawText(x_left, y, radiobutton_info[id].text_left, font_nr);
7410 if (radiobutton_info[id].text_right)
7411 DrawText(x_right, y, radiobutton_info[id].text_right, font_nr);
7413 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
7418 static void MapCheckbuttonGadget(int id)
7420 int font_nr = FONT_TEXT_1;
7421 int font_height = getFontHeight(font_nr);
7422 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
7423 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
7424 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7425 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7426 int yoffset = (gi->height - font_height) / 2;
7427 int y_above = gi->y - yoffset_above;
7429 int x_left, x_right, y; /* set after gadget position was modified */
7431 /* set position for gadgets with dynamically determined position */
7432 if (checkbutton_info[id].x != -1) /* do not change dynamic positions */
7433 ModifyGadget(gi, GDI_X, SX + ED_SETTINGS_X(checkbutton_info[id].x),GDI_END);
7434 ModifyGadget(gi, GDI_Y, SY + ED_SETTINGS_Y(checkbutton_info[id].y), GDI_END);
7436 x_left = gi->x - xoffset_left;
7437 x_right = gi->x + gi->width + xoffset_right;
7438 y = gi->y + yoffset;
7440 if (checkbutton_info[id].text_above)
7441 DrawText(x, y_above, checkbutton_info[id].text_above, font_nr);
7443 if (checkbutton_info[id].text_left)
7444 DrawText(x_left, y, checkbutton_info[id].text_left, font_nr);
7446 if (checkbutton_info[id].text_right)
7447 DrawText(x_right, y, checkbutton_info[id].text_right, font_nr);
7449 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
7454 static void MapMainDrawingArea(void)
7456 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
7457 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
7460 if (suppressBorderElement())
7462 no_horizontal_scrollbar = (lev_fieldx <= ed_fieldx);
7463 no_vertical_scrollbar = (lev_fieldy <= ed_fieldy);
7466 for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
7468 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
7469 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
7470 no_horizontal_scrollbar) ||
7471 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
7472 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
7473 no_vertical_scrollbar))
7476 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
7479 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
7481 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
7482 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
7485 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
7488 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
7491 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
7495 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
7497 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
7498 i == GADGET_ID_CUSTOM_COPY_TO ||
7499 i == GADGET_ID_CUSTOM_EXCHANGE ||
7500 i == GADGET_ID_CUSTOM_COPY ||
7501 i == GADGET_ID_CUSTOM_PASTE)
7504 MapGadget(level_editor_gadget[i]);
7506 UnmapGadget(level_editor_gadget[i]);
7511 static void MapLevelEditorToolboxCustomGadgets(void)
7513 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
7516 static void UnmapLevelEditorToolboxCustomGadgets(void)
7518 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
7521 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
7525 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
7527 if (i != GADGET_ID_SINGLE_ITEMS &&
7528 i != GADGET_ID_PICK_ELEMENT)
7530 struct GadgetInfo *gi = level_editor_gadget[i];
7538 int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
7539 struct GraphicInfo *gd = &graphic_info[graphic];
7543 BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
7544 gi->width, gi->height, gi->x, gi->y);
7546 redraw_mask |= REDRAW_DOOR_3;
7552 static void MapLevelEditorToolboxDrawingGadgets(void)
7554 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
7557 static void UnmapLevelEditorToolboxDrawingGadgets(void)
7559 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
7562 static void UnmapDrawingArea(int id)
7564 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
7567 static void UnmapLevelEditorFieldGadgets(void)
7571 for (i = 0; i < num_editor_gadgets; i++)
7572 if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
7573 level_editor_gadget[i]->y))
7574 UnmapGadget(level_editor_gadget[i]);
7577 void UnmapLevelEditorGadgets(void)
7581 for (i = 0; i < num_editor_gadgets; i++)
7582 UnmapGadget(level_editor_gadget[i]);
7585 static void ResetUndoBuffer(void)
7587 undo_buffer_position = -1;
7588 undo_buffer_steps = -1;
7589 redo_buffer_steps = 0;
7591 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7593 level.changed = FALSE;
7596 static void DrawEditModeWindowExt(boolean remap_toolbox_gadgets)
7598 if (remap_toolbox_gadgets)
7600 ModifyEditorElementList();
7601 RedrawDrawingElements();
7604 if (edit_mode == ED_MODE_INFO)
7605 DrawLevelInfoWindow();
7606 else if (edit_mode == ED_MODE_PROPERTIES)
7607 DrawPropertiesWindow();
7608 else if (edit_mode == ED_MODE_PALETTE)
7609 DrawPaletteWindow();
7610 else /* edit_mode == ED_MODE_DRAWING */
7611 DrawDrawingWindowExt(remap_toolbox_gadgets);
7614 static void DrawEditModeWindow(void)
7616 DrawEditModeWindowExt(TRUE);
7619 static void DrawEditModeWindow_PlayfieldOnly(void)
7621 DrawEditModeWindowExt(FALSE);
7624 static void ChangeEditModeWindow(int new_edit_mode)
7626 edit_mode = (new_edit_mode != edit_mode ? new_edit_mode : ED_MODE_DRAWING);
7628 DrawEditModeWindow();
7631 static boolean LevelChanged(void)
7633 boolean field_changed = FALSE;
7636 for (y = 0; y < lev_fieldy; y++)
7637 for (x = 0; x < lev_fieldx; x++)
7638 if (Feld[x][y] != level.field[x][y])
7639 field_changed = TRUE;
7641 return (level.changed || field_changed);
7644 static boolean PrepareSavingIntoPersonalLevelSet(void)
7646 static LevelDirTree *last_copied_leveldir = NULL;
7647 static LevelDirTree *last_written_leveldir = NULL;
7648 static int last_copied_level_nr = -1;
7649 static int last_written_level_nr = -1;
7650 LevelDirTree *leveldir_former = leveldir_current;
7651 int level_nr_former = level_nr;
7654 // remember last mod/save so that for current session, we write
7655 // back to the same personal copy, asking only about overwrite.
7656 if (leveldir_current == last_copied_leveldir &&
7657 level_nr == last_copied_level_nr)
7659 // "cd" to personal level set dir (as used when writing last copy)
7660 leveldir_current = last_written_leveldir;
7661 level_nr = last_written_level_nr;
7666 if (!Request("This level is read only! "
7667 "Save into personal level set?", REQ_ASK))
7670 // "cd" to personal level set dir (for writing copy the first time)
7672 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
7674 // find unused level number
7675 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
7677 static char *level_filename = NULL;
7679 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
7681 if (!fileExists(level_filename))
7685 last_copied_leveldir = leveldir_former;
7686 last_copied_level_nr = level_nr_former;
7688 last_written_leveldir = leveldir_current;
7689 last_written_level_nr = level_nr = new_level_nr;
7694 static void ModifyLevelInfoForSavingIntoPersonalLevelSet(char *former_name)
7696 static char *filename_levelinfo = NULL, *mod_name = NULL;
7699 // annotate this copy-and-mod in personal levelinfo.conf
7700 setString(&filename_levelinfo,
7701 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
7703 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
7705 fprintf(file, "\n");
7706 fprintf(file, "# level %d was modified from:\n", level_nr);
7707 fprintf(file, "# - previous level set name: %s\n",
7709 fprintf(file, "# - level within previous set: %d \"%s\"\n",
7710 level.file_info.nr, level.name);
7711 fprintf(file, "# - previous author: %s\n",
7713 fprintf(file, "# - previous save date: ");
7715 if (level.creation_date.src == DATE_SRC_LEVELFILE)
7717 fprintf(file, "%04d-%02d-%02d\n",
7718 level.creation_date.year,
7719 level.creation_date.month,
7720 level.creation_date.day);
7724 fprintf(file, "not recorded\n");
7730 if (level_nr > leveldir_current->last_level)
7731 UpdateUserLevelSet(getLoginName(), NULL, NULL, level_nr + 9);
7733 // else: allow the save even if annotation failed
7735 // now... spray graffiti on the old level vital statistics
7736 // user can change these; just trying to set a good baseline
7738 // don't truncate names for fear of making offensive or silly:
7739 // long-named original author only recorded in levelinfo.conf.
7740 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
7741 if (!strEqual(level.author, leveldir_current->author))
7743 setString(&mod_name, getStringCat3(leveldir_current->author,
7744 " after ", level.author));
7746 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
7747 setString(&mod_name,
7748 getStringCat2(leveldir_current->author, " (ed.)"));
7750 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
7751 setString(&mod_name, leveldir_current->author);
7753 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
7755 // less worried about truncation here
7756 setString(&mod_name, getStringCat2("Mod: ", level.name));
7757 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
7761 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
7762 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
7766 for (x = 0; x < lev_fieldx; x++)
7767 for (y = 0; y < lev_fieldy; y++)
7768 dst[x][y] = src[x][y];
7771 static int setSelectboxValue(int selectbox_id, int new_value)
7773 int new_index_value = 0;
7776 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
7777 if (selectbox_info[selectbox_id].options[i].value == new_value)
7778 new_index_value = i;
7780 *selectbox_info[selectbox_id].value =
7781 selectbox_info[selectbox_id].options[new_index_value].value;
7783 return new_index_value;
7786 static void setSelectboxSpecialActionVariablesIfNeeded(void)
7790 /* change action mode and arg variables according to action type variable */
7791 for (i = 0; action_arg_options[i].value != -1; i++)
7793 if (action_arg_options[i].value == custom_element_change.action_type)
7795 int mode = action_arg_options[i].mode;
7797 /* only change if corresponding selectbox has changed */
7798 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
7799 action_arg_modes[mode])
7800 custom_element_change.action_mode = -1;
7802 /* only change if corresponding selectbox has changed */
7803 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
7804 action_arg_options[i].options)
7805 custom_element_change.action_arg = -1;
7812 static void setSelectboxSpecialActionOptions(void)
7816 /* change action mode and arg selectbox according to action type selectbox */
7817 for (i = 0; action_arg_options[i].value != -1; i++)
7819 if (action_arg_options[i].value == custom_element_change.action_type)
7821 int mode = action_arg_options[i].mode;
7823 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
7824 action_arg_modes[mode]);
7825 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
7826 custom_element_change.action_mode);
7828 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
7829 action_arg_options[i].options);
7830 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
7831 custom_element_change.action_arg);
7837 static void copy_custom_element_settings(int element_from, int element_to)
7839 struct ElementInfo *ei_from = &element_info[element_from];
7840 struct ElementInfo *ei_to = &element_info[element_to];
7842 copyElementInfo(ei_from, ei_to);
7845 static void replace_custom_element_in_settings(int element_from,
7850 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
7852 struct ElementInfo *ei = &element_info[i];
7854 for (y = 0; y < 3; y++)
7855 for (x = 0; x < 3; x++)
7856 if (ei->content.e[x][y] == element_from)
7857 ei->content.e[x][y] = element_to;
7859 for (j = 0; j < ei->num_change_pages; j++)
7861 struct ElementChangeInfo *change = &ei->change_page[j];
7863 if (change->target_element == element_from)
7864 change->target_element = element_to;
7866 if (change->initial_trigger_element == element_from)
7867 change->initial_trigger_element = element_to;
7869 if (change->action_element == element_from)
7870 change->action_element = element_to;
7872 for (y = 0; y < 3; y++)
7873 for (x = 0; x < 3; x++)
7874 if (change->target_content.e[x][y] == element_from)
7875 change->target_content.e[x][y] = element_to;
7878 if (ei->group != NULL) /* group or internal */
7879 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
7880 if (ei->group->element[j] == element_from)
7881 ei->group->element[j] = element_to;
7885 static void replace_custom_element_in_playfield(int element_from,
7890 for (x = 0; x < lev_fieldx; x++)
7891 for (y = 0; y < lev_fieldy; y++)
7892 if (Feld[x][y] == element_from)
7893 Feld[x][y] = element_to;
7896 static boolean CopyCustomElement(int element_old, int element_new,
7899 int copy_mode_orig = copy_mode;
7901 if (copy_mode == GADGET_ID_CUSTOM_COPY)
7903 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
7904 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
7905 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
7907 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
7909 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
7910 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
7911 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
7913 level.changed = TRUE;
7915 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
7917 Request("Please choose custom element!", REQ_CONFIRM);
7921 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
7923 Request("Please choose group element!", REQ_CONFIRM);
7929 level.changed = TRUE;
7932 /* when modifying custom/group element, ask for copying level template */
7933 if (copy_mode_orig != GADGET_ID_CUSTOM_COPY && level.use_custom_template)
7935 if (!AskToCopyAndModifyLevelTemplate())
7939 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
7941 copy_custom_element_settings(element_new, element_old);
7943 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
7945 copy_custom_element_settings(element_old, element_new);
7947 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
7949 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
7950 copy_custom_element_settings(element_new, element_old);
7951 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
7953 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
7954 replace_custom_element_in_settings(element_new, element_old);
7955 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
7957 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
7958 replace_custom_element_in_playfield(element_new, element_old);
7959 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
7962 UpdateCustomElementGraphicGadgets();
7963 DrawPropertiesWindow();
7968 static void CopyCustomElementPropertiesToEditor(int element)
7971 int current_change_page = element_info[element].current_change_page;
7973 /* dynamically (re)build selectbox for selecting change page */
7974 for (i = 0; i < element_info[element].num_change_pages; i++)
7976 sprintf(options_change_page_strings[i], "%d", i + 1);
7978 options_change_page[i].value = i;
7979 options_change_page[i].text = options_change_page_strings[i];
7982 options_change_page[i].value = -1;
7983 options_change_page[i].text = NULL;
7985 /* needed here to initialize combined element properties */
7986 InitElementPropertiesEngine(level.game_version);
7988 element_info[element].change =
7989 &element_info[element].change_page[current_change_page];
7991 custom_element = element_info[element];
7992 custom_element_change = *element_info[element].change;
7994 /* needed to initially set selectbox options for special action options */
7995 setSelectboxSpecialActionOptions();
7997 /* needed to initially set selectbox value variables to reliable defaults */
7998 for (i = 0; i < ED_NUM_SELECTBOX; i++)
7999 setSelectboxValue(i, *selectbox_info[i].value);
8001 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8002 custom_element_properties[i] = HAS_PROPERTY(element, i);
8004 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8005 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
8007 /* ---------- element settings: configure (custom elements) ------------- */
8009 /* set accessible layer selectbox help value */
8010 custom_element.access_type =
8011 (IS_WALKABLE(element) ? EP_WALKABLE :
8012 IS_PASSABLE(element) ? EP_PASSABLE :
8013 custom_element.access_type);
8014 custom_element.access_layer =
8015 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
8016 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
8017 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
8018 custom_element.access_layer);
8019 custom_element.access_protected =
8020 (IS_PROTECTED(element) ? 1 : 0);
8021 custom_element_properties[EP_ACCESSIBLE] =
8022 (IS_ACCESSIBLE_OVER(element) ||
8023 IS_ACCESSIBLE_INSIDE(element) ||
8024 IS_ACCESSIBLE_UNDER(element));
8026 /* set walk-to-object action selectbox help value */
8027 custom_element.walk_to_action =
8028 (IS_DIGGABLE(element) ? EP_DIGGABLE :
8029 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
8030 IS_DROPPABLE(element) ? EP_DROPPABLE :
8031 IS_THROWABLE(element) ? EP_THROWABLE :
8032 IS_PUSHABLE(element) ? EP_PUSHABLE :
8033 custom_element.walk_to_action);
8034 custom_element_properties[EP_WALK_TO_OBJECT] =
8035 (IS_DIGGABLE(element) ||
8036 IS_COLLECTIBLE_ONLY(element) ||
8037 IS_DROPPABLE(element) ||
8038 IS_THROWABLE(element) ||
8039 IS_PUSHABLE(element));
8041 /* set smash targets selectbox help value */
8042 custom_element.smash_targets =
8043 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
8044 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
8045 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
8046 custom_element.smash_targets);
8047 custom_element_properties[EP_CAN_SMASH] =
8048 (CAN_SMASH_EVERYTHING(element) ||
8049 CAN_SMASH_ENEMIES(element) ||
8050 CAN_SMASH_PLAYER(element));
8052 /* set deadliness selectbox help value */
8053 custom_element.deadliness =
8054 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
8055 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
8056 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
8057 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
8058 custom_element.deadliness);
8059 custom_element_properties[EP_DEADLY] =
8060 (DONT_TOUCH(element) ||
8061 DONT_GET_HIT_BY(element) ||
8062 DONT_COLLIDE_WITH(element) ||
8063 DONT_RUN_INTO(element));
8065 /* ---------- element settings: advanced (custom elements) --------------- */
8067 /* set "change by direct action" selectbox help value */
8068 custom_element_change.direct_action =
8069 (HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
8070 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
8071 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
8072 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
8073 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
8074 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
8075 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
8076 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
8077 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
8078 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
8079 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
8080 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
8081 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
8082 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
8083 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
8084 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
8085 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
8086 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
8087 custom_element_change.direct_action);
8089 /* set "change by other element action" selectbox help value */
8090 custom_element_change.other_action =
8091 (HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
8092 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
8093 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
8094 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
8095 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
8096 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
8097 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
8098 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
8099 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
8100 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
8101 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
8102 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
8103 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
8104 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
8105 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
8106 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
8107 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
8108 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
8109 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
8110 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
8111 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
8112 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
8113 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
8114 custom_element_change.other_action);
8117 static void CopyGroupElementPropertiesToEditor(int element)
8119 group_element_info = *element_info[element].group;
8120 custom_element = element_info[element]; /* needed for description */
8123 static void CopyClassicElementPropertiesToEditor(int element)
8125 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
8126 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
8127 getMoveIntoAcidProperty(&level, element);
8129 if (MAYBE_DONT_COLLIDE_WITH(element))
8130 custom_element_properties[EP_DONT_COLLIDE_WITH] =
8131 getDontCollideWithProperty(&level, element);
8134 static void CopyElementPropertiesToEditor(int element)
8136 if (IS_CUSTOM_ELEMENT(element))
8137 CopyCustomElementPropertiesToEditor(element);
8138 else if (IS_GROUP_ELEMENT(element))
8139 CopyGroupElementPropertiesToEditor(element);
8141 CopyClassicElementPropertiesToEditor(element);
8144 static boolean AskToCopyAndModifyLevelTemplate(void)
8146 if (Request("Copy and modify settings from level template?", REQ_ASK))
8148 level.use_custom_template = FALSE;
8150 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_1],
8151 GDI_CHECKED, FALSE, GDI_END);
8152 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_2],
8153 GDI_CHECKED, FALSE, GDI_END);
8159 LoadLevelTemplate(-1); /* this resets all element modifications ... */
8161 DrawEditModeWindow(); /* ... and copies them to 'custom_element' */
8167 static void CopyCustomElementPropertiesToGame(int element)
8170 int access_type_and_layer;
8172 /* mark that this custom element has been modified */
8173 custom_element.modified_settings = TRUE;
8174 level.changed = TRUE;
8176 if (level.use_custom_template)
8177 AskToCopyAndModifyLevelTemplate();
8179 element_info[element] = custom_element;
8180 *element_info[element].change = custom_element_change;
8182 /* ---------- element settings: configure (custom elements) ------------- */
8184 /* set accessible property from checkbox and selectbox */
8185 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
8186 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
8187 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
8188 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
8189 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
8190 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
8191 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
8192 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
8193 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
8194 custom_element_properties[access_type_and_layer] =
8195 custom_element_properties[EP_ACCESSIBLE];
8196 custom_element_properties[EP_PROTECTED] =
8197 (custom_element.access_protected != 0 &&
8198 custom_element_properties[EP_ACCESSIBLE]);
8200 /* set walk-to-object property from checkbox and selectbox */
8201 custom_element_properties[EP_DIGGABLE] = FALSE;
8202 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
8203 custom_element_properties[EP_DROPPABLE] = FALSE;
8204 custom_element_properties[EP_THROWABLE] = FALSE;
8205 custom_element_properties[EP_PUSHABLE] = FALSE;
8206 custom_element_properties[custom_element.walk_to_action] =
8207 custom_element_properties[EP_WALK_TO_OBJECT];
8209 /* set smash property from checkbox and selectbox */
8210 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
8211 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
8212 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
8213 custom_element_properties[custom_element.smash_targets] =
8214 custom_element_properties[EP_CAN_SMASH];
8216 /* set deadliness property from checkbox and selectbox */
8217 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
8218 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
8219 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
8220 custom_element_properties[EP_DONT_TOUCH] = FALSE;
8221 custom_element_properties[custom_element.deadliness] =
8222 custom_element_properties[EP_DEADLY];
8224 /* ---------- element settings: advanced (custom elements) --------------- */
8226 /* set player change event from checkbox and selectbox */
8227 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
8228 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
8229 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
8230 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
8231 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
8232 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
8233 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
8234 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
8235 custom_element_change_events[CE_SWITCHED] = FALSE;
8236 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
8237 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
8238 custom_element_change_events[CE_BLOCKED] = FALSE;
8239 custom_element_change_events[CE_IMPACT] = FALSE;
8240 custom_element_change_events[CE_SMASHED] = FALSE;
8241 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
8242 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
8243 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
8244 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
8245 custom_element_change_events[custom_element_change.direct_action] =
8246 custom_element_change_events[CE_BY_DIRECT_ACTION];
8248 /* set other element action change event from checkbox and selectbox */
8249 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
8250 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
8251 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
8252 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
8253 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
8254 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
8255 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
8256 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
8257 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
8258 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
8259 custom_element_change_events[CE_TOUCHING_X] = FALSE;
8260 custom_element_change_events[CE_HITTING_X] = FALSE;
8261 custom_element_change_events[CE_DIGGING_X] = FALSE;
8262 custom_element_change_events[CE_HIT_BY_X] = FALSE;
8263 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
8264 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
8265 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
8266 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
8267 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
8268 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
8269 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
8270 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
8271 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
8272 custom_element_change_events[custom_element_change.other_action] =
8273 custom_element_change_events[CE_BY_OTHER_ACTION];
8275 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8276 SET_PROPERTY(element, i, custom_element_properties[i]);
8278 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8279 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
8281 /* copy change events also to special level editor variable */
8282 custom_element = element_info[element];
8283 custom_element_change = *element_info[element].change;
8286 static void CopyGroupElementPropertiesToGame(int element)
8288 /* mark that this group element has been modified */
8289 custom_element.modified_settings = TRUE;
8290 level.changed = TRUE;
8292 if (level.use_custom_template)
8293 AskToCopyAndModifyLevelTemplate();
8295 element_info[element] = custom_element;
8296 *element_info[element].group = group_element_info;
8299 static void CopyClassicElementPropertiesToGame(int element)
8301 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
8302 setMoveIntoAcidProperty(&level, element,
8303 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
8305 if (MAYBE_DONT_COLLIDE_WITH(element))
8306 setDontCollideWithProperty(&level, element,
8307 custom_element_properties[EP_DONT_COLLIDE_WITH]);
8310 static void CopyElementPropertiesToGame(int element)
8312 if (IS_CUSTOM_ELEMENT(element))
8313 CopyCustomElementPropertiesToGame(element);
8314 else if (IS_GROUP_ELEMENT(element))
8315 CopyGroupElementPropertiesToGame(element);
8317 CopyClassicElementPropertiesToGame(element);
8321 static void CheckElementDescriptions(void)
8325 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8326 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
8327 Error(ERR_WARN, "no element description file for element '%s'",
8332 static int getMaxEdFieldX(boolean has_scrollbar)
8334 int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
8335 int sxsize = SXSIZE - scrollbar_width;
8336 int max_ed_fieldx = sxsize / ed_tilesize;
8338 return max_ed_fieldx;
8341 static int getMaxEdFieldY(boolean has_scrollbar)
8343 int infotext_height = (IN_PIX_FIELD(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY) ?
8344 INFOTEXT_YSIZE_FULL : 0);
8345 int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
8346 int sysize = SYSIZE - scrollbar_height - infotext_height;
8347 int max_ed_fieldy = sysize / ed_tilesize;
8349 return max_ed_fieldy;
8352 static void InitZoomLevelSettings(int zoom_tilesize)
8354 static int last_game_engine_type = GAME_ENGINE_TYPE_UNKNOWN;
8356 if (zoom_tilesize == -1 && level.game_engine_type != last_game_engine_type)
8358 ed_tilesize = setup.auto_setup.editor_zoom_tilesize;
8359 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
8361 if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
8363 ed_tilesize = DEFAULT_EDITOR_TILESIZE_MM;
8364 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE_MM;
8368 last_game_engine_type = level.game_engine_type;
8370 // limit zoom tilesize by upper and lower bound
8371 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
8373 // store zoom tilesize in auto setup file only if it was manually changed
8374 if (zoom_tilesize != -1)
8375 setup.auto_setup.editor_zoom_tilesize = ed_tilesize;
8377 MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
8378 MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
8381 static void InitDrawingElements(void)
8383 static int game_engine_type_last = GAME_ENGINE_TYPE_UNKNOWN;
8385 if (level.game_engine_type == game_engine_type_last)
8388 if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
8390 new_element1 = EL_SP_CHIP_SINGLE;
8391 new_element2 = EL_EMPTY;
8392 new_element3 = EL_SP_BASE;
8394 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
8396 new_element1 = EL_MM_MIRROR_START;
8397 new_element2 = EL_EMPTY;
8398 new_element3 = EL_MM_WOODEN_WALL;
8402 new_element1 = EL_WALL;
8403 new_element2 = EL_EMPTY;
8404 new_element3 = EL_SAND;
8407 game_engine_type_last = level.game_engine_type;
8410 static void InitLevelSetInfo(void)
8412 snprintf(levelset_name, MAX_LEVEL_NAME_LEN + 1,
8413 "%s", leveldir_current->name);
8414 snprintf(levelset_author, MAX_LEVEL_AUTHOR_LEN + 1,
8415 "%s", leveldir_current->author);
8417 levelset_num_levels = leveldir_current->levels;
8419 levelset_use_levelset_artwork = FALSE;
8420 levelset_copy_level_template = FALSE;
8422 levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
8425 static void ChangeEditorToLevelSet(char *levelset_subdir)
8427 leveldir_current = getTreeInfoFromIdentifier(leveldir_first, levelset_subdir);
8429 // the previous level set might have used custom artwork
8430 ReloadCustomArtwork(0);
8432 LoadLevelSetup_SeriesInfo();
8434 SaveLevelSetup_LastSeries();
8435 SaveLevelSetup_SeriesInfo();
8439 LoadLevel(level_nr);
8440 LoadScore(level_nr);
8445 static boolean useEditorDoorAnimation(void)
8447 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
8448 boolean door_1_viewport_unchanged =
8449 (vp_door_1->x == DX &&
8450 vp_door_1->y == DY &&
8451 vp_door_1->width == DXSIZE &&
8452 vp_door_1->height == DYSIZE);
8453 boolean door_1_contains_toolbox =
8456 EX + EXSIZE <= DX + DXSIZE &&
8457 EY + EYSIZE <= DY + DYSIZE);
8459 return (door_1_viewport_unchanged && door_1_contains_toolbox);
8462 static void DrawEditorDoorContent(void)
8464 /* needed for gadgets drawn on background (like palette scrollbar) */
8465 SetDoorBackgroundImage(IMG_UNDEFINED);
8467 /* copy default editor door content to main double buffer */
8468 BlitBitmap(graphic_info[IMG_BACKGROUND_PALETTE].bitmap, drawto,
8469 graphic_info[IMG_BACKGROUND_PALETTE].src_x,
8470 graphic_info[IMG_BACKGROUND_PALETTE].src_y,
8471 MIN(DXSIZE, graphic_info[IMG_BACKGROUND_PALETTE].width),
8472 MIN(DYSIZE, graphic_info[IMG_BACKGROUND_PALETTE].height),
8475 /* draw bigger door */
8476 DrawSpecialEditorDoor();
8478 /* draw new control window */
8479 BlitBitmap(graphic_info[IMG_BACKGROUND_TOOLBOX].bitmap, drawto,
8480 graphic_info[IMG_BACKGROUND_TOOLBOX].src_x,
8481 graphic_info[IMG_BACKGROUND_TOOLBOX].src_y,
8482 MIN(EXSIZE, graphic_info[IMG_BACKGROUND_TOOLBOX].width),
8483 MIN(EYSIZE, graphic_info[IMG_BACKGROUND_TOOLBOX].height),
8486 /* draw all toolbox gadgets to editor doors */
8487 MapControlButtons();
8489 /* draw all palette gadgets to editor doors */
8490 ModifyEditorElementList();
8491 RedrawDrawingElements();
8493 /* copy actual editor door content to door double buffer for OpenDoor() */
8494 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
8497 void DrawLevelEd(void)
8499 int fade_mask = REDRAW_FIELD;
8501 FadeSoundsAndMusic();
8503 if (CheckIfGlobalBorderOrPlayfieldViewportHasChanged())
8504 fade_mask = REDRAW_ALL;
8508 /* needed if different viewport properties defined for editor */
8509 ChangeViewportPropertiesIfNeeded();
8513 InitZoomLevelSettings(-1);
8514 InitDrawingElements();
8518 CheckElementDescriptions();
8521 if (level_editor_test_game)
8523 CopyPlayfield(level.field, Feld);
8524 CopyPlayfield(FieldBackup, level.field);
8526 level_editor_test_game = FALSE;
8530 edit_mode = ED_MODE_DRAWING;
8531 edit_mode_levelinfo = ED_MODE_LEVELINFO_LEVEL;
8532 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
8540 // redraw_mask |= REDRAW_ALL;
8542 FreeLevelEditorGadgets();
8543 CreateLevelEditorGadgets();
8545 ReinitializeElementList(); /* update dynamic level element list */
8546 ReinitializeElementListButtons(); /* custom element may look different */
8548 InitElementPropertiesGfxElement();
8552 DrawEditModeWindow_PlayfieldOnly();
8554 DrawMaskedBorder(fade_mask);
8556 // use door animation if door 1 viewport is unchanged and contains toolbox
8557 if (useEditorDoorAnimation())
8561 DrawEditorDoorContent();
8563 OpenDoor(DOOR_OPEN_1 | DOOR_FORCE_ANIM);
8567 DrawEditorDoorContent();
8572 SetDoorState(DOOR_OPEN_1 | DOOR_OPEN_2);
8575 static void AdjustDrawingAreaGadgets(void)
8577 int ed_xsize = lev_fieldx + 2;
8578 int ed_ysize = lev_fieldy + 2;
8579 int max_ed_fieldx = MAX_ED_FIELDX;
8580 int max_ed_fieldy = MAX_ED_FIELDY;
8581 boolean horizontal_scrollbar_needed;
8582 boolean vertical_scrollbar_needed;
8583 int x, y, width, height;
8585 if (suppressBorderElement())
8587 ed_xsize = max_ed_fieldx;
8588 ed_ysize = max_ed_fieldy;
8591 /* check if we need any scrollbars */
8592 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
8593 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
8595 /* check if we have a smaller editor field because of scrollbars */
8596 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
8597 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
8599 /* check again if we now need more scrollbars because of less space */
8600 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
8601 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
8603 /* check if editor field gets even smaller after adding new scrollbars */
8604 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
8605 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
8607 ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
8608 ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
8610 x = SX + ed_fieldx * ed_tilesize;
8611 y = SY + ed_fieldy * ed_tilesize;
8613 width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
8614 height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
8616 /* adjust drawing area gadget */
8617 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
8618 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
8619 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
8622 /* adjust horizontal scrollbar gadgets */
8623 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
8626 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
8627 GDI_X, x - ED_SCROLLBUTTON_XSIZE,
8630 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
8633 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
8636 /* adjust vertical scrollbar gadgets */
8637 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
8640 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
8642 GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
8644 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
8647 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
8651 static void AdjustLevelScrollPosition(void)
8653 if (level_xpos < -1)
8655 if (level_xpos > lev_fieldx - ed_fieldx + 1)
8656 level_xpos = lev_fieldx - ed_fieldx + 1;
8657 if (lev_fieldx < ed_fieldx - 2)
8660 if (level_ypos < -1)
8662 if (level_ypos > lev_fieldy - ed_fieldy + 1)
8663 level_ypos = lev_fieldy - ed_fieldy + 1;
8664 if (lev_fieldy < ed_fieldy - 2)
8667 if (suppressBorderElement())
8674 static void AdjustEditorScrollbar(int id)
8676 struct GadgetInfo *gi = level_editor_gadget[id];
8677 int items_max, items_visible, item_position;
8679 if (id == GADGET_ID_SCROLL_HORIZONTAL)
8681 items_max = MAX(lev_fieldx + 2, ed_fieldx);
8682 items_visible = ed_fieldx;
8683 item_position = level_xpos + 1;
8687 items_max = MAX(lev_fieldy + 2, ed_fieldy);
8688 items_visible = ed_fieldy;
8689 item_position = level_ypos + 1;
8692 if (item_position > items_max - items_visible)
8693 item_position = items_max - items_visible;
8695 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
8696 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
8699 static void AdjustElementListScrollbar(void)
8701 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
8702 int items_max, items_visible, item_position;
8704 /* correct position of element list scrollbar */
8705 if (element_shift < 0)
8707 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
8708 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
8710 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
8711 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
8712 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
8714 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
8715 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
8716 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
8719 static void ModifyEditorCounterValue(int counter_id, int new_value)
8721 int *counter_value = counterbutton_info[counter_id].value;
8722 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
8723 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8725 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
8727 if (counter_value != NULL)
8728 *counter_value = gi->textinput.number_value;
8731 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
8733 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
8734 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8736 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
8738 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
8739 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
8741 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
8742 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
8744 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
8745 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_SMALL_DISTANCE,
8750 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
8752 int gadget_id = selectbox_info[selectbox_id].gadget_id;
8753 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8754 int new_index_value = setSelectboxValue(selectbox_id, new_value);
8756 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
8759 static void ModifyEditorSelectboxOptions(int selectbox_id,
8760 struct ValueTextInfo *options)
8762 int gadget_id = selectbox_info[selectbox_id].gadget_id;
8763 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8765 selectbox_info[selectbox_id].options = options;
8767 /* set index to zero -- list may be shorter now (correct later, if needed) */
8768 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
8769 GDI_SELECTBOX_OPTIONS, options, GDI_END);
8772 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
8774 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
8775 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8777 drawingarea_info[drawingarea_id].area_xsize = xsize;
8778 drawingarea_info[drawingarea_id].area_ysize = ysize;
8780 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
8783 static void ModifyEditorElementList(void)
8787 if (!use_permanent_palette && edit_mode != ED_MODE_PALETTE)
8790 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
8792 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
8793 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8794 struct GadgetDesign *gd = &gi->deco.design;
8795 int element = editor_elements[element_shift + i];
8796 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
8800 getEditorGraphicSource(element, tile_size, &gd->bitmap, &gd->x, &gd->y);
8802 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
8808 static void DrawDrawingElementGraphic(int element, struct XYTileSize *pos)
8810 int graphic = el2edimg(element);
8811 int tile_size = BUTTON_TILE_SIZE(pos->tile_size);
8817 DrawSizedGraphicExt(drawto, DX + pos->x, DY + pos->y, graphic, 0, tile_size);
8820 static void ModifyDrawingElementButton(int element, int id)
8822 struct GadgetInfo *gi = level_editor_gadget[id];
8823 Bitmap *deco_bitmap;
8825 int tile_size = gi->deco.width;
8827 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
8829 ModifyGadget(gi, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_END);
8832 static void PickDrawingElement(int button, int element)
8837 struct XYTileSize *pos;
8839 } de, drawing_elements[] =
8841 { &new_element1, &editor.palette.element_left, GADGET_ID_ELEMENT_LEFT },
8842 { &new_element2, &editor.palette.element_middle, GADGET_ID_ELEMENT_MIDDLE },
8843 { &new_element3, &editor.palette.element_right, GADGET_ID_ELEMENT_RIGHT },
8846 if (button < 1 || button > 3)
8849 if (IS_MM_WALL(element))
8850 element = map_mm_wall_element(element);
8852 de = drawing_elements[button - 1];
8854 *de.new_element = element; // update global drawing element variable
8856 DrawDrawingElementGraphic(element, de.pos);
8857 ModifyDrawingElementButton(element, de.id);
8859 redraw_mask |= REDRAW_DOOR_1;
8862 static void RedrawDrawingElements(void)
8864 PickDrawingElement(1, new_element1);
8865 PickDrawingElement(2, new_element2);
8866 PickDrawingElement(3, new_element3);
8869 static void DrawDrawingWindowExt(boolean remap_toolbox_gadgets)
8871 stick_element_properties_window = FALSE;
8873 SetMainBackgroundImage(IMG_UNDEFINED);
8876 UnmapLevelEditorFieldGadgets();
8878 AdjustDrawingAreaGadgets();
8879 AdjustLevelScrollPosition();
8880 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
8881 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
8883 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8885 MapMainDrawingArea();
8887 if (remap_toolbox_gadgets)
8889 UnmapLevelEditorToolboxCustomGadgets();
8890 MapLevelEditorToolboxDrawingGadgets();
8894 static void DrawDrawingWindow(void)
8896 DrawDrawingWindowExt(TRUE);
8899 static int getTabulatorBarWidth(void)
8901 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
8902 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
8904 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
8907 static int getTabulatorBarHeight(void)
8909 return ED_TAB_BAR_HEIGHT;
8912 static Pixel getTabulatorBarColor(void)
8914 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELINFO_LEVEL];
8915 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
8916 int gd_x = gd->x + gd_gi1->border.width / 2;
8917 int gd_y = gd->y + gd_gi1->height - 1;
8919 return GetPixel(gd->bitmap, gd_x, gd_y);
8922 static void DrawLevelInfoTabulatorGadgets(void)
8924 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELINFO_LEVEL];
8925 Pixel tab_color = getTabulatorBarColor();
8926 int id_first = ED_TAB_BUTTON_ID_LEVELINFO_FIRST;
8927 int id_last = ED_TAB_BUTTON_ID_LEVELINFO_LAST;
8930 for (i = id_first; i <= id_last; i++)
8932 int gadget_id = textbutton_info[i].gadget_id;
8933 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8934 boolean active = (i != edit_mode_levelinfo);
8936 /* draw background line below tabulator button */
8937 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
8939 /* draw solid line below inactive tabulator buttons */
8940 if (!active && tab_color != BLACK_PIXEL) /* black => transparent */
8941 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
8942 ED_GADGET_TINY_DISTANCE, tab_color);
8944 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
8945 MapTextbuttonGadget(i);
8948 /* draw little border line below tabulator buttons */
8949 if (tab_color != BLACK_PIXEL) /* black => transparent */
8950 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
8951 ED_GADGET_TINY_DISTANCE,
8952 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
8955 static void DrawPropertiesTabulatorGadgets(void)
8957 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
8958 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
8959 int gd_x = gd->x + gd_gi1->border.width / 2;
8960 int gd_y = gd->y + gd_gi1->height - 1;
8961 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
8962 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
8963 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
8966 /* draw two config tabulators for player elements */
8967 if (ELEM_IS_PLAYER(properties_element))
8968 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
8970 /* draw two config and one "change" tabulator for custom elements */
8971 if (IS_CUSTOM_ELEMENT(properties_element))
8972 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
8974 for (i = id_first; i <= id_last; i++)
8976 int gadget_id = textbutton_info[i].gadget_id;
8977 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8978 boolean active = (i != edit_mode_properties);
8980 /* use "config 1" and "config 2" instead of "config" for players and CEs */
8981 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
8982 (ELEM_IS_PLAYER(properties_element) ||
8983 IS_CUSTOM_ELEMENT(properties_element)))
8986 /* draw background line below tabulator button */
8987 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
8989 /* draw solid line below inactive tabulator buttons */
8990 if (!active && tab_color != BLACK_PIXEL) /* black => transparent */
8991 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
8992 ED_GADGET_TINY_DISTANCE, tab_color);
8994 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
8995 MapTextbuttonGadget(i);
8998 /* draw little border line below tabulator buttons */
8999 if (tab_color != BLACK_PIXEL) /* black => transparent */
9000 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9001 ED_GADGET_TINY_DISTANCE,
9002 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9005 static void PrintInfoText(char *text, int font_nr, int xpos, int ypos)
9007 DrawText(SX + xpos, SY + ypos, text, font_nr);
9010 static int PrintElementDescriptionFromFile(char *filename, int font_nr,
9013 int font_width = getFontWidth(font_nr);
9014 int font_height = getFontHeight(font_nr);
9015 int max_chars_per_line = (SXSIZE - 2 * xpos) / font_width;
9016 int max_lines_drawable = (SYSIZE - ypos) / font_height - 1;
9018 return DrawTextFile(SX + xpos, SY + ypos, filename, font_nr,
9019 max_chars_per_line, -1, max_lines_drawable, 0, -1,
9020 TRUE, FALSE, FALSE);
9023 static void DrawLevelInfoLevel(void)
9027 /* draw counter gadgets */
9028 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
9029 MapCounterButtons(i);
9031 /* draw checkbutton gadgets */
9032 for (i = ED_CHECKBUTTON_ID_LEVEL_FIRST; i<= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
9033 MapCheckbuttonGadget(i);
9035 /* draw selectbox gadgets */
9036 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
9037 MapSelectboxGadget(i);
9039 /* draw text input gadgets */
9040 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
9041 MapTextInputGadget(i);
9044 static char *getLevelSubdirFromSaveMode(int save_mode)
9046 if (save_mode == LEVELSET_SAVE_MODE_CREATE)
9047 return getNewUserLevelSubdir();
9049 return leveldir_current->subdir;
9052 static void DrawLevelInfoLevelSet_DirectoryInfo(void)
9054 char *directory_text = "Level set directory:";
9055 char *directory_name = getLevelSubdirFromSaveMode(levelset_save_mode);
9056 int font1_nr = FONT_TEXT_1;
9057 int font2_nr = FONT_TEXT_2;
9058 int font1_height = getFontHeight(font1_nr);
9059 int yoffset_above = font1_height + ED_GADGET_LINE_DISTANCE;
9060 int x = ED_LEVEL_SETTINGS_X(0);
9061 int y = ED_LEVEL_SETTINGS_Y(6);
9063 PrintInfoText(directory_text, font1_nr, x, y - yoffset_above);
9064 PrintInfoText(directory_name, font2_nr, x, y);
9067 static void DrawLevelInfoLevelSet(void)
9069 boolean artwork_exists = checkIfCustomArtworkExistsForCurrentLevelSet();
9070 boolean template_exists = fileExists(getLocalLevelTemplateFilename());
9073 /* draw counter gadgets */
9074 for (i = ED_COUNTER_ID_LEVELSET_FIRST; i <= ED_COUNTER_ID_LEVELSET_LAST; i++)
9075 MapCounterButtons(i);
9077 /* draw checkbutton gadgets */
9078 for (i = ED_CHECKBUTTON_ID_LEVELSET_FIRST; i <= ED_CHECKBUTTON_ID_LEVELSET_LAST; i++)
9080 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE ||
9081 (i == ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK && !artwork_exists) ||
9082 (i == ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE && !template_exists))
9085 MapCheckbuttonGadget(i);
9088 /* draw selectbox gadgets */
9089 for (i = ED_SELECTBOX_ID_LEVELSET_FIRST; i <= ED_SELECTBOX_ID_LEVELSET_LAST; i++)
9090 MapSelectboxGadget(i);
9092 /* draw text input gadgets */
9093 for (i = ED_TEXTINPUT_ID_LEVELSET_FIRST; i <= ED_TEXTINPUT_ID_LEVELSET_LAST; i++)
9094 MapTextInputGadget(i);
9096 /* draw textbutton gadgets */
9097 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_LEVELSET);
9099 /* draw info text */
9100 DrawLevelInfoLevelSet_DirectoryInfo();
9103 static void DrawLevelInfoEditor(void)
9107 /* draw counter gadgets */
9108 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
9109 MapCounterButtons(i);
9111 /* draw checkbutton gadgets */
9112 for (i=ED_CHECKBUTTON_ID_EDITOR_FIRST; i<= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
9113 MapCheckbuttonGadget(i);
9115 /* draw radiobutton gadgets */
9116 for (i=ED_RADIOBUTTON_ID_EDITOR_FIRST; i<= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
9117 MapRadiobuttonGadget(i);
9119 /* draw drawing area */
9120 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
9122 /* draw textbutton gadgets */
9123 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2);
9126 static void DrawLevelInfoWindow(void)
9128 char *text = "Global Settings";
9129 int font_nr = FONT_TITLE_1;
9130 struct MenuPosInfo *pos = &editor.settings.headline;
9131 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font_nr), pos->align);
9132 int sy = SY + pos->y;
9134 stick_element_properties_window = FALSE;
9136 SetAutomaticNumberOfGemsNeeded();
9138 UnmapLevelEditorFieldGadgets();
9140 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
9143 DrawText(sx, sy, text, font_nr);
9145 DrawLevelInfoTabulatorGadgets();
9147 if (edit_mode_levelinfo == ED_MODE_LEVELINFO_LEVEL)
9148 DrawLevelInfoLevel();
9149 else if (edit_mode_levelinfo == ED_MODE_LEVELINFO_LEVELSET)
9150 DrawLevelInfoLevelSet();
9151 else if (edit_mode_levelinfo == ED_MODE_LEVELINFO_EDITOR)
9152 DrawLevelInfoEditor();
9155 static void DrawCustomContentArea(void)
9157 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
9158 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
9159 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
9160 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
9161 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
9162 int xoffset = ED_GADGET_SPACE_DISTANCE;
9164 /* add distance for potential left text (without drawing area border) */
9165 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
9167 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
9169 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
9172 static void DrawCustomChangeContentArea(void)
9174 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
9175 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
9176 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
9177 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
9178 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
9179 int xoffset = ED_GADGET_SPACE_DISTANCE;
9181 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
9186 static void RemoveElementContentArea(int id, int font_height)
9188 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9190 DrawBackground(SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size,
9191 SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size,
9192 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9193 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size +
9194 ED_GADGET_TEXT_DISTANCE + font_height);
9197 static void DrawYamYamContentAreas(void)
9199 int font_nr = FONT_TEXT_1;
9200 int font_height = getFontHeight(font_nr);
9201 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
9202 int yoffset = (tilesize - font_height) / 2;
9203 int x = SX + ED_AREA_YAMYAM_CONTENT_X(3) + 4 * tilesize;
9204 int y = SY + ED_AREA_YAMYAM_CONTENT_Y(3) + yoffset;
9207 /* display counter to choose number of element content areas */
9208 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
9210 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
9212 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
9214 if (i < level.num_yamyam_contents)
9220 UnmapDrawingArea(id);
9222 /* delete content areas in case of reducing number of them */
9223 RemoveElementContentArea(id, font_height);
9227 DrawText(x, y + 0 * tilesize, "content", font_nr);
9228 DrawText(x, y + 1 * tilesize, "when", font_nr);
9229 DrawText(x, y + 2 * tilesize, "smashed", font_nr);
9232 static void DrawMagicBallContentAreas(void)
9234 int font_nr = FONT_TEXT_1;
9235 int font_height = getFontHeight(font_nr);
9236 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
9237 int yoffset = (tilesize - font_height) / 2;
9238 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_X(3) + 4 * tilesize;
9239 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_Y(3) + yoffset;
9242 /* display counter to choose number of element content areas */
9243 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
9245 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
9247 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
9249 if (i < level.num_ball_contents)
9255 UnmapDrawingArea(id);
9257 /* delete content areas in case of reducing number of them */
9258 RemoveElementContentArea(id, font_height);
9262 DrawText(x, y + 0 * tilesize, "generated", font_nr);
9263 DrawText(x, y + 1 * tilesize, "when", font_nr);
9264 DrawText(x, y + 2 * tilesize, "active", font_nr);
9267 static void DrawAndroidElementArea(int element)
9269 int id = ED_DRAWING_ID_ANDROID_CONTENT;
9270 int num_elements = level.num_android_clone_elements;
9271 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9272 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9273 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9274 int xsize = MAX_ANDROID_ELEMENTS;
9277 /* display counter to choose number of element areas */
9278 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
9280 if (drawingarea_info[id].text_left != NULL)
9281 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9283 UnmapDrawingArea(id);
9285 ModifyEditorDrawingArea(id, num_elements, 1);
9287 /* delete content areas in case of reducing number of them */
9288 DrawBackground(sx, sy,
9289 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9290 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9295 static void DrawGroupElementArea(int element)
9297 int id = ED_DRAWING_ID_GROUP_CONTENT;
9298 int num_elements = group_element_info.num_elements;
9299 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9300 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9301 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9302 int xsize = MAX_ELEMENTS_IN_GROUP;
9305 if (drawingarea_info[id].text_left != NULL)
9306 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9308 UnmapDrawingArea(id);
9310 ModifyEditorDrawingArea(id, num_elements, 1);
9312 /* delete content areas in case of reducing number of them */
9313 DrawBackground(sx, sy,
9314 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9315 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9320 static void DrawPlayerInitialInventoryArea(int element)
9322 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
9323 int player_nr = GET_PLAYER_NR(element);
9324 int num_elements = level.initial_inventory_size[player_nr];
9325 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9326 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9327 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9328 int xsize = MAX_INITIAL_INVENTORY_SIZE;
9331 /* determine horizontal position to the right of specified gadget */
9332 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
9333 sx = (right_gadget_border[drawingarea_info[id].gadget_id_align] +
9334 ED_DRAWINGAREA_TEXT_DISTANCE);
9336 /* determine horizontal offset for leading text */
9337 if (drawingarea_info[id].text_left != NULL)
9338 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9340 UnmapDrawingArea(id);
9342 ModifyEditorDrawingArea(id, num_elements, 1);
9344 /* delete content areas in case of reducing number of them */
9345 DrawBackground(sx, sy,
9346 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9347 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9352 static void DrawEnvelopeTextArea(int envelope_nr)
9354 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
9355 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
9358 DrawBackground(gi->x, gi->y, gi->width, gi->height);
9360 if (envelope_nr != -1)
9361 textarea_info[id].value = level.envelope[envelope_nr].text;
9363 ModifyGadget(gi, GDI_AREA_SIZE,
9364 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
9365 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
9368 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
9371 static void DrawPropertiesInfo(void)
9380 /* configurable properties */
9382 { EP_WALKABLE_OVER, "- player can walk over it" },
9383 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
9384 { EP_WALKABLE_UNDER, "- player can walk under it" },
9385 { EP_PASSABLE_OVER, "- player can pass over it" },
9386 { EP_PASSABLE_INSIDE, "- player can pass through it" },
9387 { EP_PASSABLE_UNDER, "- player can pass under it" },
9388 { EP_PROTECTED, "- player is protected by it" },
9390 { EP_DIGGABLE, "- can be digged away" },
9391 { EP_COLLECTIBLE, "- can be collected" },
9392 { EP_DROPPABLE, "- can be dropped after collecting" },
9393 { EP_THROWABLE, "- can be thrown after collecting" },
9394 { EP_PUSHABLE, "- can be pushed" },
9396 { EP_CAN_FALL, "- can fall" },
9397 { EP_CAN_MOVE, "- can move" },
9399 { EP_CAN_SMASH_PLAYER, "- can smash player" },
9401 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
9403 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
9405 { EP_SLIPPERY, "- slippery for falling elements" },
9406 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
9408 { EP_DONT_RUN_INTO, "- deadly when running into" },
9409 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
9410 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
9411 { EP_DONT_TOUCH, "- deadly when touching" },
9413 { EP_INDESTRUCTIBLE, "- indestructible" },
9415 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
9416 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
9417 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
9419 { EP_CAN_CHANGE, "- can change to other element" },
9421 /* pre-defined properties */
9422 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
9423 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
9424 { EP_SWITCHABLE, "- can be switched" },
9426 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
9431 char *filename = getElementDescriptionFilename(properties_element);
9432 char *percentage_text = "In this level: ";
9433 char *properties_text = "Standard properties: ";
9434 char *description_text = "Description:";
9435 char *no_description_text = "No description available.";
9436 char *none_text = "None";
9438 int num_elements_in_level;
9439 int num_standard_properties = 0;
9440 int font1_nr = FONT_TEXT_1;
9441 int font2_nr = FONT_TEXT_2;
9442 int font1_width = getFontWidth(font1_nr);
9443 int font1_height = getFontHeight(font1_nr);
9444 int font2_height = getFontHeight(font2_nr);
9445 int line1_height = font1_height + ED_GADGET_LINE_DISTANCE;
9446 int font2_yoffset = (font1_height - font2_height) / 2;
9447 int percentage_text_len = strlen(percentage_text) * font1_width;
9448 int properties_text_len = strlen(properties_text) * font1_width;
9449 int xpos = ED_ELEMENT_SETTINGS_X(0);
9450 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
9453 if (setup.editor.show_element_token)
9455 int font3_nr = FONT_TEXT_3;
9456 int font3_height = getFontHeight(font3_nr);
9458 DrawTextF(xpos, ypos, font3_nr,
9459 "[%s]", element_info[properties_element].token_name);
9461 ypos += 2 * font3_height;
9464 /* ----- print number of elements / percentage of this element in level */
9466 num_elements_in_level = 0;
9467 for (y = 0; y < lev_fieldy; y++)
9468 for (x = 0; x < lev_fieldx; x++)
9469 if (Feld[x][y] == properties_element)
9470 num_elements_in_level++;
9471 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
9473 DrawTextS(xpos, ypos, font1_nr, percentage_text);
9475 if (num_elements_in_level > 0)
9476 DrawTextF(xpos + percentage_text_len, ypos + font2_yoffset, font2_nr,
9477 "%d (%.2f %%)", num_elements_in_level, percentage);
9479 DrawTextF(xpos + percentage_text_len, ypos + font2_yoffset, font2_nr,
9482 ypos += 2 * MAX(font1_height, font2_height);
9484 /* ----- print standard properties of this element */
9486 DrawTextS(xpos, ypos, font1_nr, properties_text);
9488 ypos += line1_height;
9490 for (i = 0; properties[i].value != -1; i++)
9492 if (!HAS_PROPERTY(properties_element, properties[i].value))
9495 DrawTextS(xpos, ypos, font2_nr, properties[i].text);
9497 ypos += font2_height;
9499 num_standard_properties++;
9502 if (num_standard_properties == 0)
9504 DrawTextS(xpos + properties_text_len, ypos - line1_height + font2_yoffset,
9505 font2_nr, none_text);
9507 ypos -= (line1_height - font1_height);
9510 ypos += MAX(font1_height, font2_height);
9512 /* ----- print special description of this element */
9514 PrintInfoText(description_text, font1_nr, xpos, ypos);
9516 ypos += line1_height;
9518 if (PrintElementDescriptionFromFile(filename, font2_nr, xpos, ypos) == 0)
9519 PrintInfoText(no_description_text, font1_nr, xpos, ypos - line1_height);
9522 #define TEXT_COLLECTING "Score for collecting"
9523 #define TEXT_SMASHING "Score for smashing"
9524 #define TEXT_SLURPING "Score for slurping robot"
9525 #define TEXT_CRACKING "Score for cracking"
9526 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
9527 #define TEXT_DURATION "Duration when activated"
9528 #define TEXT_DELAY_ON "Delay before activating"
9529 #define TEXT_DELAY_OFF "Delay before deactivating"
9530 #define TEXT_DELAY_EXPLODING "Delay before exploding"
9531 #define TEXT_DELAY_MOVING "Delay before moving"
9532 #define TEXT_BALL_DELAY "Element generation delay"
9533 #define TEXT_MOVE_SPEED "Speed of android moving"
9534 #define TEXT_CLONE_SPEED "Speed of android cloning"
9535 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
9536 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
9537 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
9538 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
9539 #define TEXT_TIME_BONUS "Extra time to solve level"
9546 } elements_with_counter[] =
9548 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
9549 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
9550 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
9551 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
9552 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
9553 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
9554 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
9555 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
9556 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
9557 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
9558 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
9559 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
9560 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
9561 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
9562 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
9563 { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
9564 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
9565 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
9566 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
9567 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
9568 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9569 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9570 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9571 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9572 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9573 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9574 { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
9575 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9576 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9577 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9578 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9579 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
9580 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
9581 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
9582 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
9583 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
9584 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
9585 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
9586 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
9587 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
9588 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
9589 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
9590 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
9591 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
9592 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
9593 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
9594 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE],TEXT_COLLECTING },
9595 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
9596 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
9597 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
9598 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
9599 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
9600 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
9601 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
9602 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
9603 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
9604 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
9605 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
9606 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
9607 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
9608 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
9609 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
9610 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
9611 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
9612 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
9613 { EL_MM_KETTLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
9614 { EL_DF_CELL, &level.score[SC_EMERALD], TEXT_COLLECTING },
9615 { EL_MM_KEY, &level.score[SC_KEY], TEXT_COLLECTING },
9616 { EL_MM_LIGHTBALL, &level.score[SC_ELEM_BONUS], TEXT_COLLECTING },
9617 { EL_MM_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
9618 { EL_MM_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
9619 { EL_MM_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
9620 { EL_MM_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
9621 { EL_MM_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
9622 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9623 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9624 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9625 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9626 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9627 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9628 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9629 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9630 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
9632 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
9633 { EL_DC_TIMEGATE_SWITCH,&level.time_timegate, TEXT_DURATION },
9634 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
9635 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
9636 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
9637 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
9638 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
9639 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
9640 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
9641 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
9642 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
9643 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
9644 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
9645 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
9646 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
9647 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
9649 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
9650 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
9651 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
9652 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
9653 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
9654 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
9655 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
9656 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
9657 { EL_MM_FUSE_ACTIVE, &level.mm_time_fuse, TEXT_DELAY_OFF },
9658 { EL_MM_BOMB, &level.mm_time_bomb, TEXT_DELAY_EXPLODING },
9659 { EL_MM_GRAY_BALL, &level.mm_time_ball, TEXT_DELAY_ON },
9660 { EL_MM_STEEL_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
9661 { EL_MM_WOODEN_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
9666 static boolean checkPropertiesConfig(int element)
9670 if (IS_GEM(element) ||
9671 IS_CUSTOM_ELEMENT(element) ||
9672 IS_GROUP_ELEMENT(element) ||
9673 IS_BALLOON_ELEMENT(element) ||
9674 IS_ENVELOPE(element) ||
9675 IS_MM_MCDUFFIN(element) ||
9676 IS_DF_LASER(element) ||
9677 ELEM_IS_PLAYER(element) ||
9678 HAS_EDITOR_CONTENT(element) ||
9679 CAN_GROW(element) ||
9680 COULD_MOVE_INTO_ACID(element) ||
9681 MAYBE_DONT_COLLIDE_WITH(element) ||
9682 element == EL_SOKOBAN_OBJECT ||
9683 element == EL_SOKOBAN_FIELD_EMPTY ||
9684 element == EL_SOKOBAN_FIELD_FULL)
9687 for (i = 0; elements_with_counter[i].element != -1; i++)
9688 if (elements_with_counter[i].element == element)
9694 static void SetAutomaticNumberOfGemsNeeded(void)
9698 if (!level.auto_count_gems)
9701 level.gems_needed = 0;
9703 for (x = 0; x < lev_fieldx; x++)
9705 for (y = 0; y < lev_fieldy; y++)
9707 int element = Feld[x][y];
9709 if (IS_GEM(element) ||
9710 element == EL_MM_KETTLE ||
9711 element == EL_DF_CELL)
9712 level.gems_needed++;
9716 ModifyEditorCounterValue(ED_COUNTER_ID_LEVEL_GEMSLIMIT, level.gems_needed);
9719 static void DrawPropertiesConfig(void)
9721 boolean draw_footer_line = FALSE;
9722 int max_num_element_counters = 4;
9723 int num_element_counters = 0;
9726 if (!checkPropertiesConfig(properties_element))
9728 int xpos = ED_ELEMENT_SETTINGS_X(0);
9729 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
9731 PrintInfoText("No configuration options available.",
9732 FONT_TEXT_1, xpos, ypos);
9737 /* check if there are elements where a value can be chosen for */
9738 for (i = 0; elements_with_counter[i].element != -1; i++)
9740 if (elements_with_counter[i].element == properties_element)
9742 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
9744 counterbutton_info[counter_id].y =
9745 ED_ELEMENT_SETTINGS_YPOS(
9746 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
9747 (CAN_GROW(properties_element) ? 1 : 0) +
9748 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
9749 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
9750 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
9751 num_element_counters);
9753 counterbutton_info[counter_id].value = elements_with_counter[i].value;
9754 counterbutton_info[counter_id].text_right= elements_with_counter[i].text;
9756 if (properties_element == EL_GAME_OF_LIFE ||
9757 properties_element == EL_BIOMAZE)
9759 counterbutton_info[counter_id].min_value = 0; /* min neighbours */
9760 counterbutton_info[counter_id].max_value = 8; /* max neighbours */
9764 /* !!! CHANGE THIS FOR CERTAIN ELEMENTS !!! */
9765 counterbutton_info[counter_id].min_value = MIN_SCORE;
9766 counterbutton_info[counter_id].max_value = MAX_SCORE;
9769 MapCounterButtons(counter_id);
9771 num_element_counters++;
9772 if (num_element_counters >= max_num_element_counters)
9777 if (HAS_EDITOR_CONTENT(properties_element))
9779 /* draw stickybutton gadget */
9780 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
9782 if (IS_AMOEBOID(properties_element))
9783 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
9784 else if (properties_element == EL_YAMYAM ||
9785 properties_element == EL_YAMYAM_LEFT ||
9786 properties_element == EL_YAMYAM_RIGHT ||
9787 properties_element == EL_YAMYAM_UP ||
9788 properties_element == EL_YAMYAM_DOWN)
9789 DrawYamYamContentAreas();
9790 else if (properties_element == EL_EMC_MAGIC_BALL)
9792 DrawMagicBallContentAreas();
9794 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
9795 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_STATE);
9797 else if (properties_element == EL_EMC_ANDROID)
9798 DrawAndroidElementArea(properties_element);
9801 if (ELEM_IS_PLAYER(properties_element))
9803 int player_nr = GET_PLAYER_NR(properties_element);
9805 /* these properties can be set for every player individually */
9807 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
9809 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
9810 &level.start_element[player_nr];
9811 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
9812 &level.artwork_element[player_nr];
9813 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
9814 &level.explosion_element[player_nr];
9816 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
9817 &level.use_start_element[player_nr];
9818 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
9819 &level.use_artwork_element[player_nr];
9820 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
9821 &level.use_explosion_element[player_nr];
9822 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
9823 &level.initial_player_gravity[player_nr];
9825 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
9826 &level.initial_player_stepsize[player_nr];
9828 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
9829 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
9830 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
9831 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
9832 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
9833 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
9834 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
9835 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
9836 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_LAZY_RELOCATION);
9837 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
9838 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
9839 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
9840 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
9841 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
9842 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER);
9844 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
9845 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
9846 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
9848 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
9850 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
9852 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
9853 &level.initial_inventory_content[player_nr][0];
9855 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
9856 &level.initial_inventory_size[player_nr];
9858 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
9859 &level.use_initial_inventory[player_nr];
9861 /* draw checkbutton gadgets */
9862 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
9864 /* draw counter gadgets */
9865 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
9867 /* draw drawing area gadgets */
9868 DrawPlayerInitialInventoryArea(properties_element);
9872 if (IS_GEM(properties_element))
9873 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
9875 if (properties_element == EL_EM_DYNAMITE)
9876 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
9878 if (COULD_MOVE_INTO_ACID(properties_element) &&
9879 !ELEM_IS_PLAYER(properties_element) &&
9880 (!IS_CUSTOM_ELEMENT(properties_element) ||
9881 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
9883 /* set position for checkbutton for "can move into acid" */
9884 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
9885 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
9886 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
9887 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 6 :
9888 IS_BALLOON_ELEMENT(properties_element) ||
9889 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
9891 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
9894 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
9895 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
9897 if (properties_element == EL_SPRING)
9898 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
9900 if (properties_element == EL_TIME_ORB_FULL)
9901 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
9903 if (properties_element == EL_GAME_OF_LIFE ||
9904 properties_element == EL_BIOMAZE)
9905 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_LIFE_BUGS);
9907 if (CAN_GROW(properties_element))
9909 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
9910 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
9912 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
9915 if (properties_element == EL_SOKOBAN_OBJECT ||
9916 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
9917 properties_element == EL_SOKOBAN_FIELD_FULL)
9918 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
9920 if (IS_BALLOON_ELEMENT(properties_element))
9921 MapSelectboxGadget(ED_SELECTBOX_ID_WIND_DIRECTION);
9923 if (IS_ENVELOPE(properties_element))
9925 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
9926 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
9927 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
9928 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
9929 int envelope_nr = properties_element - EL_ENVELOPE_1;
9931 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
9932 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
9934 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
9935 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
9937 /* display counter to choose size of envelope text area */
9938 MapCounterButtons(counter1_id);
9939 MapCounterButtons(counter2_id);
9941 /* display checkbuttons to choose auto-wrap and alignment properties */
9942 MapCheckbuttonGadget(button1_id);
9943 MapCheckbuttonGadget(button2_id);
9945 DrawEnvelopeTextArea(envelope_nr);
9948 if (IS_MM_MCDUFFIN(properties_element))
9950 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_RED);
9951 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_GREEN);
9952 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_BLUE);
9955 if (IS_DF_LASER(properties_element))
9957 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_RED);
9958 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_GREEN);
9959 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_BLUE);
9962 if (IS_CUSTOM_ELEMENT(properties_element))
9964 /* draw stickybutton gadget */
9965 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
9967 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
9969 /* draw checkbutton gadgets */
9970 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
9971 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
9972 MapCheckbuttonGadget(i);
9974 /* draw counter gadgets */
9975 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
9976 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
9977 MapCounterButtons(i);
9979 /* draw selectbox gadgets */
9980 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
9981 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
9982 MapSelectboxGadget(i);
9984 /* draw textbutton gadgets */
9985 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
9987 /* draw text input gadgets */
9988 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
9990 /* draw drawing area gadgets */
9991 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
9993 draw_footer_line = TRUE;
9995 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
9997 /* draw checkbutton gadgets */
9998 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
9999 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
10000 MapCheckbuttonGadget(i);
10002 /* draw counter gadgets */
10003 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
10004 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
10005 MapCounterButtons(i);
10007 /* draw selectbox gadgets */
10008 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
10009 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
10010 MapSelectboxGadget(i);
10012 /* draw drawing area gadgets */
10013 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
10014 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
10015 DrawCustomContentArea();
10018 else if (IS_GROUP_ELEMENT(properties_element))
10020 /* draw stickybutton gadget */
10021 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10023 /* draw checkbutton gadgets */
10024 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
10025 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
10027 /* draw counter gadgets */
10028 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
10030 /* draw selectbox gadgets */
10031 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
10033 /* draw textbutton gadgets */
10034 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10036 /* draw drawing area gadgets */
10037 DrawGroupElementArea(properties_element);
10039 /* draw text input gadgets */
10040 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
10042 /* draw drawing area gadgets */
10043 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10045 draw_footer_line = TRUE;
10048 /* draw little footer border line above CE/GE use/save template gadgets */
10049 if (draw_footer_line)
10051 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
10052 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
10053 int gd_x = gd->x + gd_gi1->border.width / 2;
10054 int gd_y = gd->y + gd_gi1->height - 1;
10055 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
10057 if (tab_color != BLACK_PIXEL) /* black => transparent */
10058 FillRectangle(drawto,
10059 SX + ED_ELEMENT_SETTINGS_X(0),
10060 SY + ED_ELEMENT_SETTINGS_Y(14) - ED_SETTINGS_TABS_YOFFSET -
10062 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
10066 static void DrawPropertiesChangeDrawingAreas(void)
10068 if (IS_CUSTOM_ELEMENT(properties_element))
10070 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
10071 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
10072 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
10074 DrawCustomChangeContentArea();
10077 redraw_mask |= REDRAW_FIELD;
10080 static void DrawPropertiesChange(void)
10084 /* needed to initially set selectbox options for special action options */
10085 setSelectboxSpecialActionOptions();
10087 /* draw stickybutton gadget */
10088 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10090 /* draw checkbutton gadgets */
10091 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
10092 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
10093 MapCheckbuttonGadget(i);
10095 /* draw counter gadgets */
10096 for (i = ED_COUNTER_ID_CHANGE_FIRST;
10097 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
10098 MapCounterButtons(i);
10100 /* draw selectbox gadgets */
10101 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
10102 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
10103 MapSelectboxGadget(i);
10105 /* draw textbutton gadgets */
10106 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
10107 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
10108 MapTextbuttonGadget(i);
10110 /* draw graphicbutton gadgets */
10111 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
10112 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
10113 MapGraphicbuttonGadget(i);
10115 /* draw drawing area gadgets */
10116 DrawPropertiesChangeDrawingAreas();
10119 static void DrawEditorElementAnimation(int x, int y)
10121 int graphic = el2img(properties_element);
10122 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
10123 custom_element.ce_value_fixed_initial :
10124 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
10125 custom_element.collect_score_initial : FrameCounter);
10127 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
10130 static void DrawEditorElementName(int x, int y, int font_nr)
10132 char *element_name = getElementInfoText(properties_element);
10133 int font_width = getFontWidth(font_nr);
10134 int font_height = getFontHeight(font_nr);
10135 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
10136 int max_chars_per_line = max_text_width / font_width;
10137 char buffer[max_chars_per_line + 1];
10139 if (strlen(element_name) <= max_chars_per_line)
10140 DrawTextS(x, y, font_nr, element_name);
10143 int next_pos = max_chars_per_line;
10145 strncpy(buffer, element_name, max_chars_per_line);
10146 buffer[max_chars_per_line] = '\0';
10148 if (element_name[max_chars_per_line] == ' ')
10154 for (i = max_chars_per_line - 1; i >= 0; i--)
10155 if (buffer[i] == ' ')
10158 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
10165 DrawTextS(x, y - font_height / 2, font_nr, buffer);
10167 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
10168 buffer[max_chars_per_line] = '\0';
10170 DrawTextS(x, y + font_height / 2, font_nr, buffer);
10174 static void DrawPropertiesWindow(void)
10176 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
10177 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
10178 int border_size = gd->border_size;
10179 int font_nr = FONT_TEXT_1;
10180 int font_height = getFontHeight(font_nr);
10181 int xoffset = TILEX + element_border + 3 * border_size;
10182 int yoffset = (TILEY - font_height) / 2;
10183 int x1 = editor.settings.element_graphic.x + element_border;
10184 int y1 = editor.settings.element_graphic.y + element_border;
10185 int x2 = (editor.settings.element_name.x == -1 ? x1 + xoffset :
10186 editor.settings.element_name.x);
10187 int y2 = (editor.settings.element_name.y == -1 ? y1 + yoffset :
10188 editor.settings.element_name.y);
10189 char *text = "Element Settings";
10190 int font2_nr = FONT_TITLE_1;
10191 struct MenuPosInfo *pos = &editor.settings.headline;
10192 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font2_nr), pos->align);
10193 int sy = SY + pos->y;
10195 stick_element_properties_window = FALSE;
10197 /* make sure that previous properties edit mode exists for this element */
10198 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
10199 !IS_CUSTOM_ELEMENT(properties_element))
10200 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
10202 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
10203 !ELEM_IS_PLAYER(properties_element) &&
10204 !IS_CUSTOM_ELEMENT(properties_element))
10205 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
10207 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
10208 (ELEM_IS_PLAYER(properties_element) ||
10209 IS_CUSTOM_ELEMENT(properties_element)))
10210 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
10212 CopyElementPropertiesToEditor(properties_element);
10214 UnmapLevelEditorFieldGadgets();
10215 UnmapLevelEditorToolboxDrawingGadgets();
10216 UnmapLevelEditorToolboxCustomGadgets();
10218 if (IS_CUSTOM_ELEMENT(properties_element) ||
10219 IS_GROUP_ELEMENT(properties_element))
10220 MapLevelEditorToolboxCustomGadgets();
10222 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10225 DrawText(sx, sy, text, font2_nr);
10227 FrameCounter = 0; /* restart animation frame counter */
10229 DrawElementBorder(SX + x1, SY + y1, TILEX, TILEY, FALSE);
10230 DrawEditorElementAnimation(SX + x1, SY + y1);
10231 DrawEditorElementName(x2, y2, font_nr);
10233 DrawPropertiesTabulatorGadgets();
10235 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
10236 DrawPropertiesInfo();
10237 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
10238 DrawPropertiesChange();
10239 else /* (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2]) */
10240 DrawPropertiesConfig();
10243 static void DrawPaletteWindow(void)
10247 UnmapLevelEditorFieldGadgets();
10249 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10252 /* map buttons to select elements */
10253 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
10254 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
10255 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
10256 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
10257 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
10260 static void UpdateCustomElementGraphicGadgets(void)
10264 InitElementPropertiesGfxElement();
10266 ModifyEditorElementList();
10267 RedrawDrawingElements();
10269 /* force redraw of all mapped drawing area gadgets */
10270 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
10272 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
10279 static int getOpenDirectionFromTube(int element)
10283 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
10284 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
10285 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
10286 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
10287 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
10288 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
10289 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
10290 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
10291 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
10292 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
10293 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
10299 static int getTubeFromOpenDirection(int direction)
10303 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
10304 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
10305 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
10306 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
10307 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
10308 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
10309 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
10310 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
10311 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
10312 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
10313 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
10315 /* if only one direction, fall back to simple tube with that direction */
10316 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
10317 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
10318 case (MV_UP): return EL_TUBE_VERTICAL;
10319 case (MV_DOWN): return EL_TUBE_VERTICAL;
10325 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
10327 int element_new = getTubeFromOpenDirection(direction);
10329 return (element_new != EL_EMPTY ? element_new : element_old);
10332 static int getOpenDirectionFromBelt(int element)
10334 int belt_dir = getBeltDirFromBeltElement(element);
10336 return (belt_dir == MV_LEFT ? MV_RIGHT :
10337 belt_dir == MV_RIGHT ? MV_LEFT :
10338 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
10341 static int getBeltFromNrAndOpenDirection(int nr, int direction)
10343 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
10344 direction == MV_RIGHT ? MV_LEFT :
10345 direction == MV_HORIZONTAL ? MV_NONE : direction);
10347 if (direction == MV_NONE)
10350 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
10353 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
10356 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
10358 return (element_new != EL_EMPTY ? element_new : element_old);
10361 static int getOpenDirectionFromPool(int element)
10365 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
10366 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
10367 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
10368 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
10369 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
10370 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
10376 static int getPoolFromOpenDirection(int direction)
10380 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
10381 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
10382 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
10383 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
10384 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
10385 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
10391 static int getPoolFromOpenDirectionExt(int direction, int help_element)
10393 int element = getPoolFromOpenDirection(direction);
10394 int help_direction = getOpenDirectionFromPool(help_element);
10396 if (element == EL_EMPTY)
10398 int help_direction_vertical = help_direction & MV_VERTICAL;
10400 element = getPoolFromOpenDirection(direction | help_direction_vertical);
10403 if (element == EL_EMPTY)
10405 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
10407 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
10413 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
10415 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
10417 return (element_new != EL_EMPTY ? element_new : element_old);
10420 static int getOpenDirectionFromPillar(int element)
10424 case EL_EMC_WALL_1: return (MV_DOWN);
10425 case EL_EMC_WALL_2: return (MV_VERTICAL);
10426 case EL_EMC_WALL_3: return (MV_UP);
10432 static int getPillarFromOpenDirection(int direction)
10436 case (MV_DOWN): return EL_EMC_WALL_1;
10437 case (MV_VERTICAL): return EL_EMC_WALL_2;
10438 case (MV_UP): return EL_EMC_WALL_3;
10444 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
10446 int element_new = getPillarFromOpenDirection(direction);
10448 return (element_new != EL_EMPTY ? element_new : element_old);
10451 static int getOpenDirectionFromSteel2(int element)
10455 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
10456 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
10457 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
10458 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
10459 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
10460 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
10461 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
10462 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
10468 static int getSteel2FromOpenDirection(int direction)
10472 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
10473 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
10474 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
10475 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
10476 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
10477 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
10478 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
10479 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
10485 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
10487 int element_new = getSteel2FromOpenDirection(direction);
10489 return (element_new != EL_EMPTY ? element_new : element_old);
10492 static int getOpenDirectionFromChip(int element)
10496 case EL_SP_CHIP_SINGLE: return (MV_NONE);
10497 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
10498 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
10499 case EL_SP_CHIP_TOP: return (MV_DOWN);
10500 case EL_SP_CHIP_BOTTOM: return (MV_UP);
10506 static int getChipFromOpenDirection(int direction)
10510 case (MV_NONE): return EL_SP_CHIP_SINGLE;
10511 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
10512 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
10513 case (MV_UP): return EL_SP_CHIP_BOTTOM;
10514 case (MV_DOWN): return EL_SP_CHIP_TOP;
10520 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
10522 int element_new = getChipFromOpenDirection(direction);
10524 return (element_new != EL_EMPTY ? element_new : element_old);
10527 static int getClosedTube(int x, int y)
10529 static int xy[4][2] =
10536 int element_old = IntelliDrawBuffer[x][y];
10537 int direction_old = getOpenDirectionFromTube(element_old);
10538 int direction_new = MV_NONE;
10541 for (i = 0; i < NUM_DIRECTIONS; i++)
10543 int xx = x + xy[i][0];
10544 int yy = y + xy[i][1];
10545 int dir = MV_DIR_FROM_BIT(i);
10546 int dir_opposite = MV_DIR_OPPOSITE(dir);
10548 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
10549 (direction_old & dir) &&
10550 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10551 direction_new |= dir;
10554 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
10557 static int getClosedBelt(int x, int y)
10559 static int xy[4][2] =
10566 int element_old = IntelliDrawBuffer[x][y];
10567 int nr = getBeltNrFromBeltElement(element_old);
10568 int direction_old = getOpenDirectionFromBelt(element_old);
10569 int direction_new = MV_NONE;
10572 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
10574 int xx = x + xy[i][0];
10575 int yy = y + xy[i][1];
10576 int dir = MV_DIR_FROM_BIT(i);
10577 int dir_opposite = MV_DIR_OPPOSITE(dir);
10579 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
10580 (direction_old & dir) &&
10581 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10582 direction_new |= dir;
10585 return getBeltFromNrAndOpenDirection(nr, direction_new);
10588 static int getClosedPool(int x, int y)
10590 static int xy[4][2] =
10597 int element_old = IntelliDrawBuffer[x][y];
10598 int direction_old = getOpenDirectionFromPool(element_old);
10599 int direction_new = MV_NONE;
10602 for (i = 0; i < NUM_DIRECTIONS; i++)
10604 int xx = x + xy[i][0];
10605 int yy = y + xy[i][1];
10606 int dir = MV_DIR_FROM_BIT(i);
10607 int dir_opposite = MV_DIR_OPPOSITE(dir);
10609 if (IN_LEV_FIELD(xx, yy) &&
10610 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
10611 (direction_old & dir) &&
10612 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10613 direction_new |= dir;
10616 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
10619 static int getClosedPillar(int x, int y)
10621 static int xy[4][2] =
10628 int element_old = IntelliDrawBuffer[x][y];
10629 int direction_old = getOpenDirectionFromPillar(element_old);
10630 int direction_new = MV_NONE;
10633 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
10635 int xx = x + xy[i][0];
10636 int yy = y + xy[i][1];
10637 int dir = MV_DIR_FROM_BIT(i);
10638 int dir_opposite = MV_DIR_OPPOSITE(dir);
10640 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
10641 (direction_old & dir) &&
10642 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10643 direction_new |= dir;
10646 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
10649 static int getClosedSteel2(int x, int y)
10651 static int xy[4][2] =
10658 int element_old = IntelliDrawBuffer[x][y];
10659 int direction_old = getOpenDirectionFromSteel2(element_old);
10660 int direction_new = MV_NONE;
10663 for (i = 0; i < NUM_DIRECTIONS; i++)
10665 int xx = x + xy[i][0];
10666 int yy = y + xy[i][1];
10667 int dir = MV_DIR_FROM_BIT(i);
10668 int dir_opposite = MV_DIR_OPPOSITE(dir);
10670 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
10671 (direction_old & dir) &&
10672 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10673 direction_new |= dir;
10676 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
10679 static int getClosedChip(int x, int y)
10681 static int xy[4][2] =
10688 int element_old = IntelliDrawBuffer[x][y];
10689 int direction_old = getOpenDirectionFromChip(element_old);
10690 int direction_new = MV_NONE;
10693 for (i = 0; i < NUM_DIRECTIONS; i++)
10695 int xx = x + xy[i][0];
10696 int yy = y + xy[i][1];
10697 int dir = MV_DIR_FROM_BIT(i);
10698 int dir_opposite = MV_DIR_OPPOSITE(dir);
10700 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
10701 (direction_old & dir) &&
10702 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10703 direction_new |= dir;
10706 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
10709 static void SetElementSimpleExt(int x, int y, int dx, int dy, int element,
10710 boolean change_level)
10712 int sx = x - level_xpos;
10713 int sy = y - level_ypos;
10714 int old_element = Feld[x][y];
10715 int new_element = element;
10716 unsigned int new_bitmask = (getDrawModeHiRes() ? (dx + 1) << (dy * 2) : 0x0f);
10717 boolean draw_masked = FALSE;
10719 if (IS_MM_WALL_EDITOR(element))
10721 element = map_mm_wall_element_editor(element) | new_bitmask;
10723 if (IS_MM_WALL(old_element))
10724 element |= MM_WALL_BITS(old_element);
10727 draw_masked = TRUE;
10729 else if (IS_MM_WALL(old_element) && element == EL_EMPTY)
10731 int element_changed = old_element & ~new_bitmask;
10733 if (MM_WALL_BITS(element_changed) != 0)
10734 element = element_changed;
10737 IntelliDrawBuffer[x][y] = element;
10740 Feld[x][y] = element;
10742 if (IN_ED_FIELD(sx, sy))
10744 if (IS_MM_WALL(old_element) && new_element == EL_EMPTY)
10745 DrawSizedWallParts_MM(sx, sy, EL_EMPTY, ed_tilesize, FALSE, new_bitmask);
10746 else if (draw_masked)
10747 DrawEditorElementThruMask(sx, sy, element);
10749 DrawEditorElement(sx, sy, element);
10753 static void SetElementSimple(int x, int y, int element, boolean change_level)
10755 SetElementSimpleExt(x, y, 0, 0, element, change_level);
10758 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
10759 int x2, int y2, int *element2,
10760 int (*close_function)(int, int),
10761 boolean change_level)
10763 /* set neighbour elements to newly determined connections */
10764 SetElementSimple(x1, y1, *element1, change_level);
10765 SetElementSimple(x2, y2, *element2, change_level);
10767 /* remove all open connections of neighbour elements */
10768 *element1 = close_function(x1, y1);
10769 *element2 = close_function(x2, y2);
10771 /* set neighbour elements to new, minimized connections */
10772 SetElementSimple(x1, y1, *element1, change_level);
10773 SetElementSimple(x2, y2, *element2, change_level);
10776 static void SetElementIntelliDraw(int x, int y, int new_element,
10777 boolean change_level, int button)
10779 static int xy[4][2] =
10786 static int last_x = -1;
10787 static int last_y = -1;
10788 int old_element = IntelliDrawBuffer[x][y];
10790 if (new_element == EL_UNDEFINED)
10798 if (IS_TUBE(new_element))
10800 int last_element_new = EL_UNDEFINED;
10801 int direction = MV_NONE;
10804 /* if old element is of same kind, keep all existing directions */
10805 if (IS_TUBE(old_element))
10806 direction |= getOpenDirectionFromTube(old_element);
10808 for (i = 0; i < NUM_DIRECTIONS; i++)
10810 int xx = x + xy[i][0];
10811 int yy = y + xy[i][1];
10813 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10814 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
10816 int dir = MV_DIR_FROM_BIT(i);
10817 int dir_opposite = MV_DIR_OPPOSITE(dir);
10818 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10819 int last_direction_old = getOpenDirectionFromTube(last_element_old);
10820 int last_direction_new = last_direction_old | dir_opposite;
10822 last_element_new = getTubeFromOpenDirection(last_direction_new);
10828 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
10830 if (last_element_new != EL_UNDEFINED)
10831 MergeAndCloseNeighbourElements(x, y, &new_element,
10832 last_x, last_y, &last_element_new,
10833 getClosedTube, change_level);
10835 else if (IS_BELT(new_element))
10837 int belt_nr = getBeltNrFromBeltElement(new_element);
10838 int last_element_new = EL_UNDEFINED;
10839 int direction = MV_NONE;
10842 /* if old element is of same kind, keep all existing directions */
10843 if (IS_BELT(old_element))
10844 direction |= getOpenDirectionFromBelt(old_element);
10846 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
10848 int xx = x + xy[i][0];
10849 int yy = y + xy[i][1];
10851 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10852 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
10854 int dir = MV_DIR_FROM_BIT(i);
10855 int dir_opposite = MV_DIR_OPPOSITE(dir);
10856 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10857 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
10858 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
10859 int last_direction_new = last_direction_old | dir_opposite;
10861 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
10862 last_direction_new);
10867 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
10869 if (last_element_new != EL_UNDEFINED)
10870 MergeAndCloseNeighbourElements(x, y, &new_element,
10871 last_x, last_y, &last_element_new,
10872 getClosedBelt, change_level);
10874 else if (IS_ACID_POOL_OR_ACID(new_element))
10876 int last_element_new = EL_UNDEFINED;
10877 int direction = MV_NONE;
10880 /* if old element is of same kind, keep all existing directions */
10881 if (IS_ACID_POOL_OR_ACID(old_element))
10882 direction |= getOpenDirectionFromPool(old_element);
10884 for (i = 0; i < NUM_DIRECTIONS; i++)
10886 int xx = x + xy[i][0];
10887 int yy = y + xy[i][1];
10889 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10890 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
10892 int dir = MV_DIR_FROM_BIT(i);
10893 int dir_opposite = MV_DIR_OPPOSITE(dir);
10894 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10895 int last_direction_old = getOpenDirectionFromPool(last_element_old);
10896 int last_direction_new = last_direction_old | dir_opposite;
10898 last_element_new = getPoolFromOpenDirection(last_direction_new);
10904 /* special corrections needed for intuitively correct acid pool drawing */
10905 if (last_element_new == EL_EMPTY)
10906 last_element_new = new_element;
10907 else if (last_element_new != EL_UNDEFINED)
10908 new_element = last_element_new;
10910 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
10912 if (last_element_new != EL_UNDEFINED)
10913 MergeAndCloseNeighbourElements(x, y, &new_element,
10914 last_x, last_y, &last_element_new,
10915 getClosedPool, change_level);
10917 else if (IS_EMC_PILLAR(new_element))
10919 int last_element_new = EL_UNDEFINED;
10920 int direction = MV_NONE;
10923 /* if old element is of same kind, keep all existing directions */
10924 if (IS_EMC_PILLAR(old_element))
10925 direction |= getOpenDirectionFromPillar(old_element);
10927 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
10929 int xx = x + xy[i][0];
10930 int yy = y + xy[i][1];
10932 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10933 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
10935 int dir = MV_DIR_FROM_BIT(i);
10936 int dir_opposite = MV_DIR_OPPOSITE(dir);
10937 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10938 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
10939 int last_direction_new = last_direction_old | dir_opposite;
10941 last_element_new = getPillarFromOpenDirection(last_direction_new);
10947 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
10949 if (last_element_new != EL_UNDEFINED)
10950 MergeAndCloseNeighbourElements(x, y, &new_element,
10951 last_x, last_y, &last_element_new,
10952 getClosedPillar, change_level);
10954 else if (IS_DC_STEELWALL_2(new_element))
10956 int last_element_new = EL_UNDEFINED;
10957 int direction = MV_NONE;
10960 /* if old element is of same kind, keep all existing directions */
10961 if (IS_DC_STEELWALL_2(old_element))
10962 direction |= getOpenDirectionFromSteel2(old_element);
10964 for (i = 0; i < NUM_DIRECTIONS; i++)
10966 int xx = x + xy[i][0];
10967 int yy = y + xy[i][1];
10969 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10970 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
10972 int dir = MV_DIR_FROM_BIT(i);
10973 int dir_opposite = MV_DIR_OPPOSITE(dir);
10974 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10975 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
10976 int last_direction_new = last_direction_old | dir_opposite;
10978 last_element_new = getSteel2FromOpenDirection(last_direction_new);
10984 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
10986 if (last_element_new != EL_UNDEFINED)
10987 MergeAndCloseNeighbourElements(x, y, &new_element,
10988 last_x, last_y, &last_element_new,
10989 getClosedSteel2, change_level);
10991 else if (IS_SP_CHIP(new_element))
10993 int last_element_new = EL_UNDEFINED;
10994 int direction = MV_NONE;
10997 /* (do not keep existing directions, regardless of kind of old element) */
10999 for (i = 0; i < NUM_DIRECTIONS; i++)
11001 int xx = x + xy[i][0];
11002 int yy = y + xy[i][1];
11004 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11005 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
11007 int dir = MV_DIR_FROM_BIT(i);
11008 int dir_opposite = MV_DIR_OPPOSITE(dir);
11009 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11010 int last_direction_old = getOpenDirectionFromChip(last_element_old);
11011 int last_direction_new = last_direction_old | dir_opposite;
11013 if (last_direction_old == MV_NONE)
11015 last_element_new = getChipFromOpenDirection(last_direction_new);
11018 else if (last_direction_old & (dir | dir_opposite))
11020 direction |= MV_DIR_OPPOSITE(last_direction_old);
11024 direction |= MV_DIR_OPPOSITE(dir);
11029 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
11031 if (last_element_new != EL_UNDEFINED)
11032 MergeAndCloseNeighbourElements(x, y, &new_element,
11033 last_x, last_y, &last_element_new,
11034 getClosedChip, change_level);
11036 else if (IS_SP_HARDWARE_BASE(new_element))
11038 int nr = GetSimpleRandom(6);
11040 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
11041 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
11042 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
11043 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
11044 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
11046 else if (new_element == EL_SP_HARDWARE_GREEN ||
11047 new_element == EL_SP_HARDWARE_BLUE ||
11048 new_element == EL_SP_HARDWARE_RED)
11050 int nr = GetSimpleRandom(3);
11052 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
11053 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
11055 else if (IS_GROUP_ELEMENT(new_element))
11057 boolean connected_drawing = FALSE;
11060 for (i = 0; i < NUM_DIRECTIONS; i++)
11062 int xx = x + xy[i][0];
11063 int yy = y + xy[i][1];
11065 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11066 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
11067 connected_drawing = TRUE;
11070 if (!connected_drawing)
11071 ResolveGroupElement(new_element);
11073 new_element = GetElementFromGroupElement(new_element);
11075 else if (IS_BELT_SWITCH(old_element))
11077 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
11078 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
11080 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
11081 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
11083 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
11087 static int swappable_elements[][2] =
11089 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
11090 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
11091 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
11092 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
11093 { EL_EMERALD, EL_WALL_EMERALD },
11094 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
11095 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
11096 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
11097 { EL_DIAMOND, EL_WALL_DIAMOND },
11098 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
11099 { EL_GATE_1, EL_GATE_1_GRAY },
11100 { EL_GATE_2, EL_GATE_2_GRAY },
11101 { EL_GATE_3, EL_GATE_3_GRAY },
11102 { EL_GATE_4, EL_GATE_4_GRAY },
11103 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
11104 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
11105 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
11106 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
11107 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
11108 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
11109 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
11110 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
11111 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
11112 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
11113 { EL_LAMP, EL_LAMP_ACTIVE },
11114 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
11115 { EL_SP_BASE, EL_SP_BUGGY_BASE },
11116 { EL_PEARL, EL_WALL_PEARL },
11117 { EL_CRYSTAL, EL_WALL_CRYSTAL },
11118 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
11119 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
11120 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
11121 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
11122 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
11123 { EL_LANDMINE, EL_DC_LANDMINE },
11124 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
11125 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
11126 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
11127 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
11128 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
11129 { EL_MM_EXIT_CLOSED, EL_MM_EXIT_OPEN },
11130 { EL_MM_FUSE, EL_MM_FUSE_ACTIVE },
11131 { EL_MM_LIGHTBULB, EL_MM_LIGHTBULB_ACTIVE },
11132 { EL_MM_FUEL_EMPTY, EL_MM_FUEL_FULL },
11136 static int rotatable_elements_4[][4] =
11146 EL_SPACESHIP_RIGHT,
11151 EL_BD_BUTTERFLY_UP,
11152 EL_BD_BUTTERFLY_RIGHT,
11153 EL_BD_BUTTERFLY_DOWN,
11154 EL_BD_BUTTERFLY_LEFT
11158 EL_BD_FIREFLY_RIGHT,
11159 EL_BD_FIREFLY_DOWN,
11187 EL_SP_GRAVITY_PORT_UP,
11188 EL_SP_GRAVITY_PORT_RIGHT,
11189 EL_SP_GRAVITY_PORT_DOWN,
11190 EL_SP_GRAVITY_PORT_LEFT
11193 EL_SP_GRAVITY_ON_PORT_UP,
11194 EL_SP_GRAVITY_ON_PORT_RIGHT,
11195 EL_SP_GRAVITY_ON_PORT_DOWN,
11196 EL_SP_GRAVITY_ON_PORT_LEFT
11199 EL_SP_GRAVITY_OFF_PORT_UP,
11200 EL_SP_GRAVITY_OFF_PORT_RIGHT,
11201 EL_SP_GRAVITY_OFF_PORT_DOWN,
11202 EL_SP_GRAVITY_OFF_PORT_LEFT
11211 EL_BALLOON_SWITCH_UP,
11212 EL_BALLOON_SWITCH_RIGHT,
11213 EL_BALLOON_SWITCH_DOWN,
11214 EL_BALLOON_SWITCH_LEFT
11218 EL_MM_MCDUFFIN_RIGHT,
11219 EL_MM_MCDUFFIN_DOWN,
11220 EL_MM_MCDUFFIN_LEFT
11223 EL_MM_MIRROR_FIXED_1,
11224 EL_MM_MIRROR_FIXED_4,
11225 EL_MM_MIRROR_FIXED_3,
11226 EL_MM_MIRROR_FIXED_2
11229 EL_MM_STEEL_GRID_FIXED_1,
11230 EL_MM_STEEL_GRID_FIXED_4,
11231 EL_MM_STEEL_GRID_FIXED_2,
11232 EL_MM_STEEL_GRID_FIXED_3
11235 EL_MM_WOODEN_GRID_FIXED_1,
11236 EL_MM_WOODEN_GRID_FIXED_4,
11237 EL_MM_WOODEN_GRID_FIXED_2,
11238 EL_MM_WOODEN_GRID_FIXED_3
11241 EL_MM_POLARIZER_CROSS_1,
11242 EL_MM_POLARIZER_CROSS_4,
11243 EL_MM_POLARIZER_CROSS_3,
11244 EL_MM_POLARIZER_CROSS_2
11248 EL_MM_PACMAN_RIGHT,
11260 EL_DF_RECEIVER_RIGHT,
11261 EL_DF_RECEIVER_DOWN,
11262 EL_DF_RECEIVER_LEFT
11269 static int rotatable_elements_8[][8] =
11272 EL_DF_STEEL_GRID_FIXED_1,
11273 EL_DF_STEEL_GRID_FIXED_8,
11274 EL_DF_STEEL_GRID_FIXED_7,
11275 EL_DF_STEEL_GRID_FIXED_6,
11276 EL_DF_STEEL_GRID_FIXED_5,
11277 EL_DF_STEEL_GRID_FIXED_4,
11278 EL_DF_STEEL_GRID_FIXED_3,
11279 EL_DF_STEEL_GRID_FIXED_2
11282 EL_DF_WOODEN_GRID_FIXED_1,
11283 EL_DF_WOODEN_GRID_FIXED_8,
11284 EL_DF_WOODEN_GRID_FIXED_7,
11285 EL_DF_WOODEN_GRID_FIXED_6,
11286 EL_DF_WOODEN_GRID_FIXED_5,
11287 EL_DF_WOODEN_GRID_FIXED_4,
11288 EL_DF_WOODEN_GRID_FIXED_3,
11289 EL_DF_WOODEN_GRID_FIXED_2
11292 EL_DF_STEEL_GRID_ROTATING_1,
11293 EL_DF_STEEL_GRID_ROTATING_8,
11294 EL_DF_STEEL_GRID_ROTATING_7,
11295 EL_DF_STEEL_GRID_ROTATING_6,
11296 EL_DF_STEEL_GRID_ROTATING_5,
11297 EL_DF_STEEL_GRID_ROTATING_4,
11298 EL_DF_STEEL_GRID_ROTATING_3,
11299 EL_DF_STEEL_GRID_ROTATING_2
11302 EL_DF_WOODEN_GRID_ROTATING_1,
11303 EL_DF_WOODEN_GRID_ROTATING_8,
11304 EL_DF_WOODEN_GRID_ROTATING_7,
11305 EL_DF_WOODEN_GRID_ROTATING_6,
11306 EL_DF_WOODEN_GRID_ROTATING_5,
11307 EL_DF_WOODEN_GRID_ROTATING_4,
11308 EL_DF_WOODEN_GRID_ROTATING_3,
11309 EL_DF_WOODEN_GRID_ROTATING_2
11316 static int rotatable_elements_16[][16] =
11337 EL_MM_TELEPORTER_5,
11338 EL_MM_TELEPORTER_4,
11339 EL_MM_TELEPORTER_3,
11340 EL_MM_TELEPORTER_2,
11341 EL_MM_TELEPORTER_1,
11342 EL_MM_TELEPORTER_16,
11343 EL_MM_TELEPORTER_15,
11344 EL_MM_TELEPORTER_14,
11345 EL_MM_TELEPORTER_13,
11346 EL_MM_TELEPORTER_12,
11347 EL_MM_TELEPORTER_11,
11348 EL_MM_TELEPORTER_10,
11349 EL_MM_TELEPORTER_9,
11350 EL_MM_TELEPORTER_8,
11351 EL_MM_TELEPORTER_7,
11355 EL_MM_TELEPORTER_RED_5,
11356 EL_MM_TELEPORTER_RED_4,
11357 EL_MM_TELEPORTER_RED_3,
11358 EL_MM_TELEPORTER_RED_2,
11359 EL_MM_TELEPORTER_RED_1,
11360 EL_MM_TELEPORTER_RED_16,
11361 EL_MM_TELEPORTER_RED_15,
11362 EL_MM_TELEPORTER_RED_14,
11363 EL_MM_TELEPORTER_RED_13,
11364 EL_MM_TELEPORTER_RED_12,
11365 EL_MM_TELEPORTER_RED_11,
11366 EL_MM_TELEPORTER_RED_10,
11367 EL_MM_TELEPORTER_RED_9,
11368 EL_MM_TELEPORTER_RED_8,
11369 EL_MM_TELEPORTER_RED_7,
11370 EL_MM_TELEPORTER_RED_6
11373 EL_MM_TELEPORTER_YELLOW_5,
11374 EL_MM_TELEPORTER_YELLOW_4,
11375 EL_MM_TELEPORTER_YELLOW_3,
11376 EL_MM_TELEPORTER_YELLOW_2,
11377 EL_MM_TELEPORTER_YELLOW_1,
11378 EL_MM_TELEPORTER_YELLOW_16,
11379 EL_MM_TELEPORTER_YELLOW_15,
11380 EL_MM_TELEPORTER_YELLOW_14,
11381 EL_MM_TELEPORTER_YELLOW_13,
11382 EL_MM_TELEPORTER_YELLOW_12,
11383 EL_MM_TELEPORTER_YELLOW_11,
11384 EL_MM_TELEPORTER_YELLOW_10,
11385 EL_MM_TELEPORTER_YELLOW_9,
11386 EL_MM_TELEPORTER_YELLOW_8,
11387 EL_MM_TELEPORTER_YELLOW_7,
11388 EL_MM_TELEPORTER_YELLOW_6
11391 EL_MM_TELEPORTER_GREEN_5,
11392 EL_MM_TELEPORTER_GREEN_4,
11393 EL_MM_TELEPORTER_GREEN_3,
11394 EL_MM_TELEPORTER_GREEN_2,
11395 EL_MM_TELEPORTER_GREEN_1,
11396 EL_MM_TELEPORTER_GREEN_16,
11397 EL_MM_TELEPORTER_GREEN_15,
11398 EL_MM_TELEPORTER_GREEN_14,
11399 EL_MM_TELEPORTER_GREEN_13,
11400 EL_MM_TELEPORTER_GREEN_12,
11401 EL_MM_TELEPORTER_GREEN_11,
11402 EL_MM_TELEPORTER_GREEN_10,
11403 EL_MM_TELEPORTER_GREEN_9,
11404 EL_MM_TELEPORTER_GREEN_8,
11405 EL_MM_TELEPORTER_GREEN_7,
11406 EL_MM_TELEPORTER_GREEN_6
11409 EL_MM_TELEPORTER_BLUE_5,
11410 EL_MM_TELEPORTER_BLUE_4,
11411 EL_MM_TELEPORTER_BLUE_3,
11412 EL_MM_TELEPORTER_BLUE_2,
11413 EL_MM_TELEPORTER_BLUE_1,
11414 EL_MM_TELEPORTER_BLUE_16,
11415 EL_MM_TELEPORTER_BLUE_15,
11416 EL_MM_TELEPORTER_BLUE_14,
11417 EL_MM_TELEPORTER_BLUE_13,
11418 EL_MM_TELEPORTER_BLUE_12,
11419 EL_MM_TELEPORTER_BLUE_11,
11420 EL_MM_TELEPORTER_BLUE_10,
11421 EL_MM_TELEPORTER_BLUE_9,
11422 EL_MM_TELEPORTER_BLUE_8,
11423 EL_MM_TELEPORTER_BLUE_7,
11424 EL_MM_TELEPORTER_BLUE_6
11428 EL_MM_POLARIZER_16,
11429 EL_MM_POLARIZER_15,
11430 EL_MM_POLARIZER_14,
11431 EL_MM_POLARIZER_13,
11432 EL_MM_POLARIZER_12,
11433 EL_MM_POLARIZER_11,
11434 EL_MM_POLARIZER_10,
11463 EL_DF_MIRROR_ROTATING_1,
11464 EL_DF_MIRROR_ROTATING_16,
11465 EL_DF_MIRROR_ROTATING_15,
11466 EL_DF_MIRROR_ROTATING_14,
11467 EL_DF_MIRROR_ROTATING_13,
11468 EL_DF_MIRROR_ROTATING_12,
11469 EL_DF_MIRROR_ROTATING_11,
11470 EL_DF_MIRROR_ROTATING_10,
11471 EL_DF_MIRROR_ROTATING_9,
11472 EL_DF_MIRROR_ROTATING_8,
11473 EL_DF_MIRROR_ROTATING_7,
11474 EL_DF_MIRROR_ROTATING_6,
11475 EL_DF_MIRROR_ROTATING_5,
11476 EL_DF_MIRROR_ROTATING_4,
11477 EL_DF_MIRROR_ROTATING_3,
11478 EL_DF_MIRROR_ROTATING_2
11487 for (i = 0; swappable_elements[i][0] != -1; i++)
11489 int element1 = swappable_elements[i][0];
11490 int element2 = swappable_elements[i][1];
11492 if (old_element == element1 || old_element == element2)
11493 new_element = (old_element == element1 ? element2 : element1);
11496 for (i = 0; rotatable_elements_4[i][0] != -1; i++)
11498 for (j = 0; j < 4; j++)
11500 int element = rotatable_elements_4[i][j];
11502 if (old_element == element)
11503 new_element = (button == 1 ? rotatable_elements_4[i][(j + 3) % 4] :
11504 button == 2 ? rotatable_elements_4[i][0] :
11505 button == 3 ? rotatable_elements_4[i][(j + 1) % 4] :
11510 for (i = 0; rotatable_elements_8[i][0] != -1; i++)
11512 for (j = 0; j < 8; j++)
11514 int element = rotatable_elements_8[i][j];
11516 if (old_element == element)
11517 new_element = (button == 1 ? rotatable_elements_8[i][(j + 7) % 8] :
11518 button == 2 ? rotatable_elements_8[i][0] :
11519 button == 3 ? rotatable_elements_8[i][(j + 1) % 8] :
11524 for (i = 0; rotatable_elements_16[i][0] != -1; i++)
11526 for (j = 0; j < 16; j++)
11528 int element = rotatable_elements_16[i][j];
11530 if (old_element == element)
11531 new_element = (button == 1 ? rotatable_elements_16[i][(j + 15) % 16] :
11532 button == 2 ? rotatable_elements_16[i][0] :
11533 button == 3 ? rotatable_elements_16[i][(j + 1) % 16] :
11538 if (old_element != new_element)
11540 int max_infotext_len = getMaxInfoTextLength();
11541 char infotext[MAX_OUTPUT_LINESIZE + 1];
11543 strncpy(infotext, getElementInfoText(new_element), max_infotext_len);
11544 infotext[max_infotext_len] = '\0';
11546 ClearEditorGadgetInfoText();
11548 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT,
11553 SetElementSimple(x, y, new_element, change_level);
11559 static void ResetIntelliDraw(void)
11563 for (x = 0; x < lev_fieldx; x++)
11564 for (y = 0; y < lev_fieldy; y++)
11565 IntelliDrawBuffer[x][y] = Feld[x][y];
11567 SetElementIntelliDraw(-1, -1, EL_UNDEFINED, FALSE, -1);
11570 static boolean draw_mode_hires = FALSE;
11572 static void SetDrawModeHiRes(int element)
11575 (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
11576 (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY));
11579 static boolean getDrawModeHiRes(void)
11581 return draw_mode_hires;
11584 static int getLoResScreenPos(int pos)
11586 return (getDrawModeHiRes() ? pos / 2 : pos);
11589 static int getLoResScreenMod(int pos)
11591 return (getDrawModeHiRes() ? pos % 2 : 0);
11594 static void SetElementExt(int x, int y, int dx, int dy, int element,
11595 boolean change_level, int button)
11598 SetElementSimple(x, y, Feld[x][y], change_level);
11599 else if (GetKeyModState() & KMOD_Shift && !IS_MM_WALL_EDITOR(element))
11600 SetElementIntelliDraw(x, y, element, change_level, button);
11602 SetElementSimpleExt(x, y, dx, dy, element, change_level);
11605 static void SetElement(int x, int y, int element)
11607 SetElementExt(x, y, 0, 0, element, TRUE, -1);
11610 static void SetElementButton(int x, int y, int dx, int dy, int element,
11613 SetElementExt(x, y, dx, dy, element, TRUE, button);
11616 static void SetElementHiRes(int sx2, int sy2, int element, boolean change_level)
11618 int lx = getLoResScreenPos(sx2) + level_xpos;
11619 int ly = getLoResScreenPos(sy2) + level_ypos;
11620 int dx = getLoResScreenMod(sx2);
11621 int dy = getLoResScreenMod(sy2);
11623 SetElementExt(lx, ly, dx, dy, element, change_level, -1);
11626 static void SetLevelElementHiRes(int lx2, int ly2, int element)
11633 SetElementExt(lx, ly, dx, dy, element, TRUE, -1);
11636 static int getLevelElementHiRes(int lx2, int ly2)
11642 int element = Feld[lx][ly];
11643 unsigned int bitmask = (dx + 1) << (dy * 2);
11645 if (IS_MM_WALL(element))
11647 if (element & bitmask)
11648 return map_mm_wall_element(element);
11656 static void DrawLineElement(int x, int y, int element, boolean change_level)
11658 SetElementHiRes(x, y, element, change_level);
11661 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
11662 int element, boolean change_level)
11664 int xsize = ABS(to_x - from_x);
11665 int ysize = ABS(to_y - from_y);
11666 int dx = (to_x < from_x ? -1 : +1);
11667 int dy = (to_y < from_y ? -1 : +1);
11670 if (from_y == to_y) /* horizontal line */
11672 for (i = 0; i <= xsize; i++)
11673 DrawLineElement(from_x + i * dx, from_y, element, change_level);
11675 else if (from_x == to_x) /* vertical line */
11677 for (i = 0; i <= ysize; i++)
11678 DrawLineElement(from_x, from_y + i * dy, element, change_level);
11680 else /* diagonal line */
11682 if (ysize < xsize) /* a < 1 */
11684 float a = (float)ysize / (float)xsize;
11686 for (i = 0; i <= xsize; i++)
11689 int y = dy * (int)(a * i + 0.5);
11691 DrawLineElement(from_x + x, from_y + y, element, change_level);
11696 float a = (float)xsize / (float)ysize;
11698 for (i = 0; i <= ysize; i++)
11700 int x = dx * (int)(a * i + 0.5);
11703 DrawLineElement(from_x + x, from_y + y, element, change_level);
11709 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
11710 int element, boolean change_level)
11712 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
11713 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
11714 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
11715 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
11718 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
11719 int element, boolean change_level)
11724 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
11726 for (y = from_y; y <= to_y; y++)
11727 DrawLine(from_x, y, to_x, y, element, change_level);
11730 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
11731 int element, boolean change_level)
11733 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
11734 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
11735 int len_x = ABS(to_x - from_x);
11736 int len_y = ABS(to_y - from_y);
11739 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
11741 /* not optimal (some points get drawn twice) but simple,
11742 and fast enough for the few points we are drawing */
11744 for (x = 0; x <= radius; x++)
11746 int sx, sy, sx2, sy2, lx, ly;
11748 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
11750 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
11751 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
11752 sx = getLoResScreenPos(sx2);
11753 sy = getLoResScreenPos(sy2);
11754 lx = sx + level_xpos;
11755 ly = sy + level_ypos;
11757 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
11758 DrawLineElement(sx2, sy2, element, change_level);
11761 for (y = 0; y <= radius; y++)
11763 int sx, sy, sx2, sy2, lx, ly;
11765 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
11767 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
11768 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
11769 sx = getLoResScreenPos(sx2);
11770 sy = getLoResScreenPos(sy2);
11771 lx = sx + level_xpos;
11772 ly = sy + level_ypos;
11774 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
11775 DrawLineElement(sx2, sy2, element, change_level);
11779 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
11780 int element, boolean change_level)
11782 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
11783 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
11785 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
11788 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
11790 #if DRAW_CIRCLES_BUTTON_AVAILABLE
11791 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
11792 int element, boolean change_level)
11794 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
11795 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
11796 int mirror_to_x2 = from_x - (to_x2 - from_x);
11797 int mirror_to_y2 = from_y - (to_y2 - from_y);
11799 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
11800 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
11801 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
11802 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element,change_level);
11806 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
11808 int from_sx, from_sy;
11812 swap_numbers(&from_x, &to_x);
11815 swap_numbers(&from_y, &to_y);
11817 from_sx = SX + from_x * ed_tilesize;
11818 from_sy = SY + from_y * ed_tilesize;
11819 to_sx = SX + (to_x + 1) * ed_tilesize - 1;
11820 to_sy = SY + (to_y + 1) * ed_tilesize - 1;
11822 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
11823 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
11824 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
11825 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
11827 if (from_x == to_x && from_y == to_y)
11828 MarkTileDirty(from_x/2, from_y/2);
11830 redraw_mask |= REDRAW_FIELD;
11833 static void DrawAreaBox(int from_x, int from_y, int to_x, int to_y,
11834 int element, boolean change_level)
11836 DrawBox(from_x, from_y, to_x, to_y, element, change_level);
11839 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
11840 int element, boolean change_level)
11842 if (element == -1 || change_level)
11843 DrawAreaBox(from_x, from_y, to_x, to_y, -1, FALSE);
11845 DrawAreaBorder(from_x, from_y, to_x, to_y);
11848 /* values for CopyBrushExt() */
11849 #define CB_AREA_TO_BRUSH 0
11850 #define CB_BRUSH_TO_CURSOR 1
11851 #define CB_BRUSH_TO_LEVEL 2
11852 #define CB_DELETE_OLD_CURSOR 3
11853 #define CB_DUMP_BRUSH 4
11854 #define CB_DUMP_BRUSH_SMALL 5
11856 static void DrawBrushElement(int sx, int sy, int element, boolean change_level)
11858 DrawLineElement(sx, sy, element, change_level);
11861 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
11862 int button, int mode)
11864 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
11865 static int brush_width, brush_height;
11866 static int last_cursor_x = -1, last_cursor_y = -1;
11867 static boolean delete_old_brush;
11868 int new_element = BUTTON_ELEMENT(button);
11871 if (mode == CB_DUMP_BRUSH ||
11872 mode == CB_DUMP_BRUSH_SMALL)
11874 if (!draw_with_brush)
11876 Error(ERR_WARN, "no brush selected");
11881 for (y = 0; y < brush_height; y++)
11883 for (x = 0; x < brush_width; x++)
11885 int element = brush_buffer[x][y];
11886 int element_mapped = element;
11888 if (IS_CUSTOM_ELEMENT(element))
11889 element_mapped = EL_CUSTOM_START;
11890 else if (IS_GROUP_ELEMENT(element))
11891 element_mapped = EL_GROUP_START;
11892 else if (element >= NUM_FILE_ELEMENTS)
11893 element_mapped = EL_UNKNOWN;
11895 // dump brush as level sketch text for the R'n'D forum:
11896 // - large tiles: `xxx (0x60 ASCII)
11897 // - small tiles: ¸xxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
11898 printf("%s%03d", (mode == CB_DUMP_BRUSH ? "`" : "¸"), element_mapped);
11907 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
11910 if (mode == CB_AREA_TO_BRUSH)
11912 int from_lx, from_ly;
11915 swap_numbers(&from_x, &to_x);
11918 swap_numbers(&from_y, &to_y);
11920 brush_width = to_x - from_x + 1;
11921 brush_height = to_y - from_y + 1;
11923 from_lx = from_x + level_xpos;
11924 from_ly = from_y + level_ypos;
11926 for (y = 0; y < brush_height; y++)
11928 for (x = 0; x < brush_width; x++)
11930 brush_buffer[x][y] = Feld[from_lx + x][from_ly + y];
11933 DrawBrushElement(from_x + x, from_y + y, new_element, TRUE);
11938 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
11940 delete_old_brush = FALSE;
11942 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
11943 mode == CB_BRUSH_TO_LEVEL)
11945 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
11946 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
11947 int cursor_from_x = cursor_x - brush_width / 2;
11948 int cursor_from_y = cursor_y - brush_height / 2;
11949 int border_from_x = cursor_x, border_from_y = cursor_y;
11950 int border_to_x = cursor_x, border_to_y = cursor_y;
11952 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
11953 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
11955 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
11956 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
11958 delete_old_brush = FALSE;
11962 for (y = 0; y < brush_height; y++)
11964 for (x = 0; x < brush_width; x++)
11966 int sx = cursor_from_x + x;
11967 int sy = cursor_from_y + y;
11968 int lx = sx + level_xpos;
11969 int ly = sy + level_ypos;
11970 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
11971 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
11972 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
11973 brush_buffer[x][y] : new_element);
11975 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
11977 if (sx < border_from_x)
11978 border_from_x = sx;
11979 else if (sx > border_to_x)
11981 if (sy < border_from_y)
11982 border_from_y = sy;
11983 else if (sy > border_to_y)
11986 DrawBrushElement(sx, sy, element, change_level);
11991 if (mode != CB_DELETE_OLD_CURSOR)
11992 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
11994 last_cursor_x = cursor_x;
11995 last_cursor_y = cursor_y;
11996 delete_old_brush = TRUE;
12000 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
12003 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
12006 static void CopyBrushToLevel(int x, int y, int button)
12008 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
12011 static void CopyBrushToCursor(int x, int y)
12013 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
12016 static void DeleteBrushFromCursor(void)
12018 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
12021 void DumpBrush(void)
12023 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
12026 void DumpBrush_Small(void)
12028 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
12031 static void FloodFill(int from_x, int from_y, int fill_element)
12033 FloodFillLevel(from_x, from_y, fill_element, Feld, lev_fieldx, lev_fieldy);
12036 static void FloodFillWall_MM(int from_sx2, int from_sy2, int fill_element)
12038 int from_x = from_sx2 + 2 * level_xpos;
12039 int from_y = from_sy2 + 2 * level_ypos;
12040 int max_fillx = lev_fieldx * 2;
12041 int max_filly = lev_fieldy * 2;
12042 short FillFeld[max_fillx][max_filly];
12045 for (x = 0; x < max_fillx; x++)
12046 for (y = 0; y < max_filly; y++)
12047 FillFeld[x][y] = getLevelElementHiRes(x, y);
12049 FloodFillLevelExt(from_x, from_y, fill_element, max_fillx, max_filly,
12050 FillFeld, max_fillx, max_filly);
12052 for (x = 0; x < max_fillx; x++)
12053 for (y = 0; y < max_filly; y++)
12054 if (FillFeld[x][y] == fill_element)
12055 SetLevelElementHiRes(x, y, FillFeld[x][y]);
12058 /* values for DrawLevelText() modes */
12059 #define TEXT_INIT 0
12060 #define TEXT_SETCURSOR 1
12061 #define TEXT_WRITECHAR 2
12062 #define TEXT_BACKSPACE 3
12063 #define TEXT_NEWLINE 4
12065 #define TEXT_QUERY_TYPING 6
12067 static int DrawLevelText(int sx, int sy, char letter, int mode)
12069 static short delete_buffer[MAX_LEV_FIELDX];
12070 static int start_sx;
12071 static int last_sx, last_sy;
12072 static boolean typing = FALSE;
12073 int letter_element = EL_CHAR_ASCII0 + letter;
12074 int lx = 0, ly = 0;
12076 /* map lower case letters to upper case and convert special characters */
12077 if (letter >= 'a' && letter <= 'z')
12078 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
12079 else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
12080 letter_element = EL_CHAR_AUMLAUT;
12081 else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
12082 letter_element = EL_CHAR_OUMLAUT;
12083 else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
12084 letter_element = EL_CHAR_UUMLAUT;
12085 else if (letter == '^')
12086 letter_element = EL_CHAR_COPYRIGHT;
12088 letter_element = EL_CHAR_ASCII0 + letter;
12090 if (mode != TEXT_INIT)
12095 if (mode != TEXT_SETCURSOR)
12101 lx = last_sx + level_xpos;
12102 ly = last_sy + level_ypos;
12109 DrawLevelText(0, 0, 0, TEXT_END);
12115 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
12118 case TEXT_SETCURSOR:
12119 DrawEditorElement(last_sx, last_sy, Feld[lx][ly]);
12120 DrawAreaBorder(sx, sy, sx, sy);
12125 case TEXT_WRITECHAR:
12126 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
12128 if (new_element1 >= EL_STEEL_CHAR_START &&
12129 new_element1 <= EL_STEEL_CHAR_END)
12130 letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
12132 delete_buffer[sx - start_sx] = Feld[lx][ly];
12133 Feld[lx][ly] = letter_element;
12135 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
12136 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
12137 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
12138 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
12140 DrawLevelText(0, 0, 0, TEXT_END);
12142 level.changed = TRUE;
12146 case TEXT_BACKSPACE:
12149 Feld[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
12150 DrawEditorElement(sx - 1, sy, Feld[lx - 1][ly]);
12151 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
12156 if (sy + 1 < ed_fieldy - 1 && ly + 1 < lev_fieldy - 1)
12157 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
12159 DrawLevelText(0, 0, 0, TEXT_END);
12163 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12164 DrawEditorElement(sx, sy, Feld[lx][ly]);
12168 case TEXT_QUERY_TYPING:
12178 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
12179 int element, boolean change_level)
12181 int lx = sx + level_xpos;
12182 int ly = sy + level_ypos;
12185 DrawEditorElement(sx, sy, Feld[lx][ly]);
12187 DrawAreaBorder(sx, sy, sx, sy);
12190 static void CheckLevelBorderElement(boolean redraw_playfield)
12192 int last_border_element = BorderElement;
12194 SetBorderElement();
12196 if (redraw_playfield && BorderElement != last_border_element)
12197 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12200 static void CopyLevelToUndoBuffer(int mode)
12202 static boolean accumulated_undo = FALSE;
12203 boolean new_undo_buffer_position = TRUE;
12206 if (undo_buffer_steps == 0)
12207 accumulated_undo = FALSE;
12211 case UNDO_IMMEDIATE:
12212 accumulated_undo = FALSE;
12215 case UNDO_ACCUMULATE:
12216 if (accumulated_undo)
12217 new_undo_buffer_position = FALSE;
12218 accumulated_undo = TRUE;
12225 if (new_undo_buffer_position)
12227 /* advance position in undo buffer ring */
12228 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
12230 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
12231 undo_buffer_steps++;
12234 /* always reset redo buffer when storing level change into undo buffer */
12235 redo_buffer_steps = 0;
12237 for (x = 0; x < lev_fieldx; x++)
12238 for (y = 0; y < lev_fieldy; y++)
12239 UndoBuffer[undo_buffer_position][x][y] = Feld[x][y];
12241 /* check if drawing operation forces change of border style */
12242 CheckLevelBorderElement(TRUE);
12244 level.changed = TRUE;
12247 static void RandomPlacement(int new_element)
12249 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
12250 int num_free_positions = 0;
12251 int num_percentage, num_elements;
12254 ResetIntelliDraw();
12256 /* determine number of free positions for randomly placing the new element */
12257 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
12259 free_position[x][y] =
12260 (random_placement_background_restricted ?
12261 Feld[x][y] == random_placement_background_element :
12262 Feld[x][y] != new_element);
12264 if (free_position[x][y])
12265 num_free_positions++;
12268 /* determine number of new elements to place there */
12269 num_percentage = num_free_positions * random_placement_value / 100;
12270 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
12271 num_percentage : random_placement_value);
12273 /* if less free positions than elements to place, fill all these positions */
12274 if (num_free_positions < num_elements)
12276 for (x = 0; x < lev_fieldx; x++)
12277 for (y = 0; y < lev_fieldy; y++)
12278 if (free_position[x][y])
12279 SetElement(x, y, new_element);
12283 while (num_elements > 0)
12285 x = GetSimpleRandom(lev_fieldx);
12286 y = GetSimpleRandom(lev_fieldy);
12288 /* don't place element at the same position twice */
12289 if (free_position[x][y])
12291 free_position[x][y] = FALSE;
12292 SetElement(x, y, new_element);
12298 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12299 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12302 static void WrapLevel(int dx, int dy)
12304 int wrap_dx = lev_fieldx - dx;
12305 int wrap_dy = lev_fieldy - dy;
12308 for (x = 0; x < lev_fieldx; x++)
12309 for (y = 0; y < lev_fieldy; y++)
12310 FieldBackup[x][y] = Feld[x][y];
12312 for (x = 0; x < lev_fieldx; x++)
12313 for (y = 0; y < lev_fieldy; y++)
12315 FieldBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
12317 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12318 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
12321 static void CopyLevelTemplateToUserLevelSet(char *levelset_subdir)
12323 char *template_filename_old = getLocalLevelTemplateFilename();
12324 char *template_filename_new =
12325 getPath2(getUserLevelDir(levelset_subdir), LEVELTEMPLATE_FILENAME);
12327 if (copyFile(template_filename_old, template_filename_new) != 0)
12328 Request("Cannot copy level template!", REQ_CONFIRM);
12330 free(template_filename_new);
12333 static void HandleDrawingAreas(struct GadgetInfo *gi)
12335 static boolean started_inside_drawing_area = FALSE;
12336 static int last_sx = -1, last_sy = -1;
12337 static int last_sx2 = -1, last_sy2 = -1;
12338 int id = gi->custom_id;
12339 int type_id = gi->custom_type_id;
12340 boolean button_press_event;
12341 boolean button_release_event;
12342 boolean inside_drawing_area = !gi->event.off_borders;
12343 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
12344 int actual_drawing_function;
12345 int button = gi->event.button;
12346 int new_element = BUTTON_ELEMENT(button);
12347 int sx = gi->event.x, sy = gi->event.y;
12348 int min_sx = 0, min_sy = 0;
12349 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
12350 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
12351 int mini_item_xsize = item_xsize / 2, mini_item_ysize = item_ysize / 2;
12352 int sx2 = gi->event.mx / mini_item_xsize;
12353 int sy2 = gi->event.my / mini_item_ysize;
12356 int lx = 0, ly = 0;
12357 int min_lx = 0, min_ly = 0;
12358 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
12361 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
12362 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
12364 /* make sure to stay inside drawing area boundaries */
12365 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
12366 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
12370 /* get positions inside level field */
12371 lx = sx + level_xpos;
12372 ly = sy + level_ypos;
12374 if (!IN_LEV_FIELD(lx, ly))
12375 inside_drawing_area = FALSE;
12377 /* make sure to stay inside level field boundaries */
12378 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
12379 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
12381 /* correct drawing area positions accordingly */
12382 sx = lx - level_xpos;
12383 sy = ly - level_ypos;
12386 /* also correct MM wall-sized (double) drawing area positions accordingly */
12387 if (sx2 / 2 < sx || sx2 / 2 > sx)
12389 dx = (sx2 / 2 < sx ? 0 : 1);
12392 if (sy2 / 2 < sy || sy2 / 2 > sy)
12394 dy = (sy2 / 2 < sy ? 0 : 1);
12398 if (button_release_event)
12405 else if (!button_press_event)
12407 /* prevent handling events for every pixel position when moving mouse */
12408 if ((sx == last_sx && sy == last_sy &&
12409 !IS_MM_WALL_EDITOR(new_element) && new_element != EL_EMPTY) ||
12410 (sx2 == last_sx2 && sy2 == last_sy2))
12419 if (button_press_event)
12420 started_inside_drawing_area = inside_drawing_area;
12422 if (!started_inside_drawing_area)
12425 if (!IS_VALID_BUTTON(button))
12428 if (!button && !button_release_event)
12431 /* handle info callback for each invocation of action callback */
12432 gi->callback_info(gi);
12434 /* automatically switch to 'single item' drawing mode, if needed */
12435 actual_drawing_function =
12436 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
12437 drawing_function : GADGET_ID_SINGLE_ITEMS);
12439 /* clicking into drawing area with pressed Control key picks element */
12440 if (GetKeyModState() & KMOD_Control)
12442 last_drawing_function = drawing_function;
12443 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
12446 if (GetKeyModState() & KMOD_Shift)
12448 if (button_press_event || button_release_event)
12449 ResetIntelliDraw();
12452 SetDrawModeHiRes(-1); /* reset to normal draw mode */
12454 switch (actual_drawing_function)
12456 case GADGET_ID_SINGLE_ITEMS:
12459 if (button_release_event)
12461 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12463 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
12464 !inside_drawing_area)
12465 DeleteBrushFromCursor();
12468 if (!button || button_release_event)
12471 if (draw_with_brush)
12473 CopyBrushToLevel(sx, sy, button);
12477 SetDrawModeHiRes(new_element);
12479 if (new_element == EL_PLAYER_1)
12481 /* remove player at old position */
12482 for (y = 0; y < lev_fieldy; y++)
12483 for (x = 0; x < lev_fieldx; x++)
12484 if (Feld[x][y] == EL_PLAYER_1)
12485 SetElement(x, y, EL_EMPTY);
12488 SetElementButton(lx, ly, dx, dy, new_element, button);
12491 else if (!button_release_event)
12493 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
12495 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
12496 DrawMiniGraphicExt(drawto,
12497 gi->x + sx * MINI_TILEX,
12498 gi->y + sy * MINI_TILEY,
12499 el2edimg(new_element));
12501 DrawFixedGraphicExt(drawto,
12502 gi->x + sx * TILEX,
12503 gi->y + sy * TILEY,
12504 el2edimg(new_element), 0);
12506 if (id == GADGET_ID_CUSTOM_GRAPHIC)
12507 new_element = GFX_ELEMENT(new_element);
12509 drawingarea_info[type_id].value[pos] = new_element;
12511 CopyElementPropertiesToGame(properties_element);
12513 if (id == GADGET_ID_CUSTOM_GRAPHIC)
12515 UpdateCustomElementGraphicGadgets();
12517 FrameCounter = 0; /* restart animation frame counter */
12522 case GADGET_ID_CONNECTED_ITEMS:
12524 static int last_sx = -1;
12525 static int last_sy = -1;
12527 if (button_release_event)
12528 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12532 SetDrawModeHiRes(new_element);
12534 if (getDrawModeHiRes())
12540 if (!button_press_event)
12541 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
12549 case GADGET_ID_LINE:
12550 case GADGET_ID_ARC:
12551 case GADGET_ID_RECTANGLE:
12552 case GADGET_ID_FILLED_BOX:
12553 SetDrawModeHiRes(new_element);
12555 if (getDrawModeHiRes())
12561 case GADGET_ID_GRAB_BRUSH:
12562 case GADGET_ID_TEXT:
12564 static int last_sx = -1;
12565 static int last_sy = -1;
12566 static int start_sx = -1;
12567 static int start_sy = -1;
12568 void (*draw_func)(int, int, int, int, int, boolean);
12570 if (drawing_function == GADGET_ID_LINE)
12571 draw_func = DrawLine;
12572 else if (drawing_function == GADGET_ID_ARC)
12573 draw_func = DrawArc;
12574 else if (drawing_function == GADGET_ID_RECTANGLE)
12575 draw_func = DrawBox;
12576 else if (drawing_function == GADGET_ID_FILLED_BOX)
12577 draw_func = DrawFilledBox;
12578 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
12579 draw_func = SelectArea;
12580 else /* (drawing_function == GADGET_ID_TEXT) */
12581 draw_func = SetTextCursor;
12583 if (button_press_event)
12585 draw_func(sx, sy, sx, sy, new_element, FALSE);
12586 start_sx = last_sx = sx;
12587 start_sy = last_sy = sy;
12589 if (drawing_function == GADGET_ID_TEXT)
12590 DrawLevelText(0, 0, 0, TEXT_END);
12592 else if (button_release_event)
12594 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
12595 if (drawing_function == GADGET_ID_GRAB_BRUSH)
12597 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
12598 CopyBrushToCursor(sx, sy);
12599 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
12601 draw_with_brush = TRUE;
12603 else if (drawing_function == GADGET_ID_TEXT)
12604 DrawLevelText(sx, sy, 0, TEXT_INIT);
12606 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12608 else if (last_sx != sx || last_sy != sy)
12610 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
12611 if (IS_MM_WALL_EDITOR(new_element)) /* clear wall background */
12612 draw_func(start_sx, start_sy, sx, sy, EL_EMPTY, FALSE);
12613 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
12620 case GADGET_ID_FLOOD_FILL:
12621 if (button_press_event && Feld[lx][ly] != new_element)
12623 if (IS_MM_WALL_EDITOR(new_element))
12624 FloodFillWall_MM(sx2, sy2, new_element);
12626 FloodFill(lx, ly, new_element);
12628 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12629 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12633 case GADGET_ID_PICK_ELEMENT:
12634 if (button_release_event)
12635 ClickOnGadget(level_editor_gadget[last_drawing_function],
12637 else if (draw_level)
12638 PickDrawingElement(button, Feld[lx][ly]);
12641 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
12643 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
12650 /* do not mark level as modified for certain non-level-changing gadgets */
12651 if ((type_id >= ED_DRAWING_ID_EDITOR_FIRST &&
12652 type_id <= ED_DRAWING_ID_EDITOR_LAST) ||
12653 actual_drawing_function == GADGET_ID_GRAB_BRUSH ||
12654 actual_drawing_function == GADGET_ID_PICK_ELEMENT)
12657 level.changed = TRUE;
12660 static void HandleCounterButtons(struct GadgetInfo *gi)
12662 int gadget_id = gi->custom_id;
12663 int counter_id = gi->custom_type_id;
12664 int button = gi->event.button;
12665 int *counter_value = counterbutton_info[counter_id].value;
12666 int step = BUTTON_STEPSIZE(button) *
12667 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
12669 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
12671 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
12672 boolean released = (gi->event.type == GD_EVENT_RELEASED);
12673 boolean level_changed = LevelChanged();
12675 if ((level_changed && pressed) || (!level_changed && released))
12678 if (level_changed && !Request("Level has changed! Discard changes?",
12681 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
12682 ModifyEditorCounterValue(counter_id, *counter_value);
12688 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
12689 *counter_value = gi->textinput.number_value;
12691 ModifyEditorCounterValue(counter_id, *counter_value + step);
12693 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
12695 int last_game_engine_type = level.game_engine_type;
12697 LoadLevel(level_nr);
12698 LoadScore(level_nr);
12700 SaveLevelSetup_SeriesInfo();
12705 DrawEditModeWindow();
12707 if (level.game_engine_type != last_game_engine_type)
12709 /* update element selection list */
12710 ReinitializeElementList();
12711 ModifyEditorElementList();
12717 switch (counter_id)
12719 case ED_COUNTER_ID_YAMYAM_CONTENT:
12720 DrawYamYamContentAreas();
12723 case ED_COUNTER_ID_BALL_CONTENT:
12724 DrawMagicBallContentAreas();
12727 case ED_COUNTER_ID_ANDROID_CONTENT:
12728 DrawAndroidElementArea(properties_element);
12731 case ED_COUNTER_ID_GROUP_CONTENT:
12732 DrawGroupElementArea(properties_element);
12733 CopyGroupElementPropertiesToGame(properties_element);
12736 case ED_COUNTER_ID_INVENTORY_SIZE:
12737 DrawPlayerInitialInventoryArea(properties_element);
12740 case ED_COUNTER_ID_ENVELOPE_XSIZE:
12741 case ED_COUNTER_ID_ENVELOPE_YSIZE:
12742 DrawEnvelopeTextArea(-1);
12745 case ED_COUNTER_ID_LEVEL_XSIZE:
12746 case ED_COUNTER_ID_LEVEL_YSIZE:
12747 lev_fieldx = level.fieldx;
12748 lev_fieldy = level.fieldy;
12750 /* check if resizing of level results in change of border border */
12751 SetBorderElement();
12759 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
12760 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
12761 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
12762 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
12763 CopyElementPropertiesToGame(properties_element);
12765 /* do not mark level as modified for certain non-level-changing gadgets */
12766 if ((counter_id >= ED_COUNTER_ID_LEVELSET_FIRST &&
12767 counter_id <= ED_COUNTER_ID_LEVELSET_LAST) ||
12768 (counter_id >= ED_COUNTER_ID_EDITOR_FIRST &&
12769 counter_id <= ED_COUNTER_ID_EDITOR_LAST))
12772 level.changed = TRUE;
12775 static void HandleTextInputGadgets(struct GadgetInfo *gi)
12777 int type_id = gi->custom_type_id;
12779 strcpy(textinput_info[type_id].value, gi->textinput.value);
12781 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
12783 CopyElementPropertiesToGame(properties_element);
12785 ModifyEditorElementList(); /* update changed button info text */
12788 /* do not mark level as modified for certain non-level-changing gadgets */
12789 if (type_id >= ED_TEXTINPUT_ID_LEVELSET_FIRST &&
12790 type_id <= ED_TEXTINPUT_ID_LEVELSET_LAST)
12793 level.changed = TRUE;
12796 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
12798 int type_id = gi->custom_type_id;
12800 strncpy(textarea_info[type_id].value, gi->textarea.value,
12801 MAX_ENVELOPE_TEXT_LEN);
12802 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
12804 level.changed = TRUE;
12807 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
12809 int type_id = gi->custom_type_id;
12810 int value_old = *selectbox_info[type_id].value;
12811 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
12813 *selectbox_info[type_id].value = value_new;
12815 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE)
12817 DrawLevelInfoWindow();
12819 else if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
12821 element_info[properties_element].current_change_page = gi->selectbox.index;
12823 DrawPropertiesWindow();
12825 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
12826 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
12827 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
12828 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
12829 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
12831 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
12833 /* when changing action type, also check action mode and action arg */
12834 if (value_old != value_new)
12835 setSelectboxSpecialActionVariablesIfNeeded();
12837 DrawPropertiesChange();
12840 CopyElementPropertiesToGame(properties_element);
12842 else if (type_id == ED_SELECTBOX_ID_GAME_ENGINE_TYPE)
12844 /* update element selection list */
12845 ReinitializeElementList();
12846 ModifyEditorElementList();
12849 /* do not mark level as modified for certain non-level-changing gadgets */
12850 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE ||
12851 type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
12854 level.changed = TRUE;
12857 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
12859 int type_id = gi->custom_type_id;
12862 if (type_id >= ED_TAB_BUTTON_ID_LEVELINFO_FIRST &&
12863 type_id <= ED_TAB_BUTTON_ID_LEVELINFO_LAST)
12865 edit_mode_levelinfo = gi->custom_type_id;
12867 DrawLevelInfoWindow();
12869 else if (type_id >= ED_TAB_BUTTON_ID_PROPERTIES_FIRST &&
12870 type_id <= ED_TAB_BUTTON_ID_PROPERTIES_LAST)
12872 edit_mode_properties = gi->custom_type_id;
12874 DrawPropertiesWindow();
12876 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 ||
12877 type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2)
12879 boolean new_template = !fileExists(getLocalLevelTemplateFilename());
12881 /* backup original "level.field" (needed to track playfield changes) */
12882 CopyPlayfield(level.field, FieldBackup);
12884 /* "SaveLevelTemplate()" uses "level.field", so copy editor playfield */
12885 CopyPlayfield(Feld, level.field);
12887 if (new_template ||
12888 Request("Save this template and kill the old?", REQ_ASK))
12889 SaveLevelTemplate();
12892 Request("Template saved!", REQ_CONFIRM);
12894 /* restore original "level.field" (needed to track playfield changes) */
12895 CopyPlayfield(FieldBackup, level.field);
12897 else if (type_id == ED_TEXTBUTTON_ID_SAVE_LEVELSET)
12899 char *levelset_subdir = getLevelSubdirFromSaveMode(levelset_save_mode);
12901 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE &&
12902 leveldir_current->readonly)
12904 Request("This level set is read only!", REQ_CONFIRM);
12909 if (strEqual(levelset_name, ""))
12911 Request("Please enter level set title!", REQ_CONFIRM);
12916 if (strEqual(levelset_author, ""))
12918 Request("Please enter level set author!", REQ_CONFIRM);
12923 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE)
12925 if (UpdateUserLevelSet(levelset_subdir,
12928 levelset_num_levels))
12930 Request("Level set updated!", REQ_CONFIRM);
12934 Request("Updating level set failed!", REQ_CONFIRM);
12937 else if (levelset_save_mode == LEVELSET_SAVE_MODE_CREATE)
12939 if (level.changed && !Request("Level has changed! Discard changes?",
12943 if (CreateUserLevelSet(levelset_subdir,
12946 levelset_num_levels,
12947 levelset_use_levelset_artwork))
12949 if (levelset_copy_level_template)
12950 CopyLevelTemplateToUserLevelSet(levelset_subdir);
12952 Request("New level set created!", REQ_CONFIRM);
12954 AddUserLevelSetToLevelInfo(levelset_subdir);
12955 ChangeEditorToLevelSet(levelset_subdir);
12959 Request("Creating new level set failed!", REQ_CONFIRM);
12963 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
12964 custom_element.num_change_pages < MAX_CHANGE_PAGES)
12966 struct ElementInfo *ei = &element_info[properties_element];
12968 /* when modifying custom element, ask for copying level template */
12969 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
12972 setElementChangePages(ei, ei->num_change_pages + 1);
12974 /* set new change page to be new current change page */
12975 ei->current_change_page = ei->num_change_pages - 1;
12976 ei->change = &ei->change_page[ei->current_change_page];
12978 setElementChangeInfoToDefaults(ei->change);
12980 DrawPropertiesWindow();
12982 level.changed = TRUE;
12984 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
12985 custom_element.num_change_pages > MIN_CHANGE_PAGES)
12987 struct ElementInfo *ei = &element_info[properties_element];
12989 /* when modifying custom element, ask for copying level template */
12990 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
12993 /* copy all change pages after change page to be deleted */
12994 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
12995 ei->change_page[i] = ei->change_page[i + 1];
12997 setElementChangePages(ei, ei->num_change_pages - 1);
12999 DrawPropertiesWindow();
13001 level.changed = TRUE;
13005 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
13007 int type_id = gi->custom_type_id;
13009 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
13010 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
13012 struct ElementInfo *ei = &element_info[properties_element];
13013 int step = BUTTON_STEPSIZE(gi->event.button);
13015 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
13016 ei->current_change_page += step;
13018 if (ei->current_change_page < 0)
13019 ei->current_change_page = 0;
13020 else if (ei->current_change_page >= ei->num_change_pages)
13021 ei->current_change_page = ei->num_change_pages - 1;
13023 DrawPropertiesWindow();
13025 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
13026 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
13028 struct ElementInfo *ei = &element_info[properties_element];
13029 int current_change_page = ei->current_change_page;
13031 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
13033 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
13034 ei->change_page[current_change_page];
13036 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
13038 /* when modifying custom element, ask for copying level template */
13039 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
13042 ei->change_page[current_change_page] =
13043 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
13045 level.changed = TRUE;
13048 DrawPropertiesWindow();
13052 static void HandleRadiobuttons(struct GadgetInfo *gi)
13054 int type_id = gi->custom_type_id;
13056 *radiobutton_info[type_id].value =
13057 radiobutton_info[type_id].checked_value;
13059 /* do not mark level as modified for certain non-level-changing gadgets */
13060 if (type_id >= ED_RADIOBUTTON_ID_EDITOR_FIRST &&
13061 type_id <= ED_RADIOBUTTON_ID_EDITOR_LAST)
13064 level.changed = TRUE;
13067 static void HandleCheckbuttons(struct GadgetInfo *gi)
13069 int type_id = gi->custom_type_id;
13071 *checkbutton_info[type_id].value ^= TRUE;
13073 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
13074 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
13075 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
13076 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
13077 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
13078 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
13079 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
13080 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1))
13082 CopyElementPropertiesToGame(properties_element);
13085 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
13087 UpdateCustomElementGraphicGadgets();
13089 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 ||
13090 type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2)
13092 boolean template_related_changes_found = FALSE;
13095 /* check if any custom or group elements have been changed */
13096 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
13097 if ((IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)) &&
13098 element_info[i].modified_settings)
13099 template_related_changes_found = TRUE;
13101 if (level.use_custom_template &&
13102 !fileExists(getGlobalLevelTemplateFilename()))
13104 Request("No level template found!", REQ_CONFIRM);
13106 level.use_custom_template = FALSE;
13108 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
13113 if (level.use_custom_template &&
13114 template_related_changes_found &&
13115 !Request("Discard changes and use level template?", REQ_ASK))
13117 level.use_custom_template = FALSE;
13119 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
13124 if (!level.use_custom_template &&
13125 Request("Copy settings from level template?", REQ_ASK))
13130 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
13132 DrawEditModeWindow();
13134 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3)
13136 if (setup.editor.use_template_for_new_levels &&
13137 !fileExists(getGlobalLevelTemplateFilename()))
13139 Request("No level template found!", REQ_CONFIRM);
13144 if (setup.editor.use_template_for_new_levels &&
13146 !Request("Discard level and load template?", REQ_ASK))
13151 if (!setup.editor.use_template_for_new_levels &&
13153 !Request("Discard level and use empty level?", REQ_ASK))
13158 LoadLevel(level_nr);
13159 LoadScore(level_nr);
13164 DrawEditModeWindow();
13166 else if (type_id == ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS)
13168 SetAutomaticNumberOfGemsNeeded();
13171 /* do not mark level as modified for certain non-level-changing gadgets */
13172 if ((type_id >= ED_CHECKBUTTON_ID_LEVELSET_FIRST &&
13173 type_id <= ED_CHECKBUTTON_ID_LEVELSET_LAST) ||
13174 (type_id >= ED_CHECKBUTTON_ID_EDITOR_FIRST &&
13175 type_id <= ED_CHECKBUTTON_ID_EDITOR_LAST &&
13176 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2) ||
13177 type_id == ED_CHECKBUTTON_ID_STICK_ELEMENT)
13180 level.changed = TRUE;
13183 static void HandleControlButtons(struct GadgetInfo *gi)
13185 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
13186 static int last_edit_mode = ED_MODE_DRAWING;
13187 static int last_custom_copy_mode = -1;
13188 static int last_button = 0;
13189 int id = gi->custom_id;
13190 int button = gi->event.button;
13191 int step = BUTTON_STEPSIZE(button);
13192 int new_element = BUTTON_ELEMENT(button);
13193 int last_properties_element = properties_element;
13196 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
13197 DrawLevelText(0, 0, 0, TEXT_END);
13199 if (id < ED_NUM_CTRL1_BUTTONS &&
13200 id != GADGET_ID_SINGLE_ITEMS &&
13201 id != GADGET_ID_PICK_ELEMENT &&
13202 edit_mode != ED_MODE_DRAWING &&
13203 drawing_function != GADGET_ID_PICK_ELEMENT &&
13204 !(GetKeyModState() & KMOD_Control))
13205 ChangeEditModeWindow(ED_MODE_DRAWING);
13207 /* element copy mode active, but no element button pressed => deactivate */
13208 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
13209 last_custom_copy_mode = -1;
13211 /* when showing palette on element buttons, change element of button used */
13212 if (editor.palette.show_on_element_buttons &&
13213 id >= GADGET_ID_ELEMENT_LEFT && id <= GADGET_ID_ELEMENT_RIGHT)
13215 last_button = id - GADGET_ID_ELEMENT_LEFT + 1;
13217 id = GADGET_ID_PALETTE;
13222 case GADGET_ID_SCROLL_LEFT:
13223 if (level_xpos >= 0)
13225 if (lev_fieldx < ed_fieldx - 2)
13228 level_xpos -= step;
13229 if (level_xpos < -1)
13232 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
13234 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13236 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
13237 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
13241 case GADGET_ID_SCROLL_RIGHT:
13242 if (level_xpos <= lev_fieldx - ed_fieldx)
13244 if (lev_fieldx < ed_fieldx - 2)
13247 level_xpos += step;
13248 if (level_xpos > lev_fieldx - ed_fieldx + 1)
13249 level_xpos = lev_fieldx - ed_fieldx + 1;
13251 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
13253 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13255 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
13256 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
13260 case GADGET_ID_SCROLL_UP:
13261 if (level_ypos >= 0)
13263 if (lev_fieldy < ed_fieldy - 2)
13266 level_ypos -= step;
13267 if (level_ypos < -1)
13270 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
13272 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13274 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
13275 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
13279 case GADGET_ID_SCROLL_DOWN:
13280 if (level_ypos <= lev_fieldy - ed_fieldy)
13282 if (lev_fieldy < ed_fieldy - 2)
13285 level_ypos += step;
13286 if (level_ypos > lev_fieldy - ed_fieldy + 1)
13287 level_ypos = lev_fieldy - ed_fieldy + 1;
13289 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
13291 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13293 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
13294 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
13298 case GADGET_ID_SCROLL_HORIZONTAL:
13299 level_xpos = gi->event.item_position - 1;
13301 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13306 case GADGET_ID_SCROLL_VERTICAL:
13307 level_ypos = gi->event.item_position - 1;
13309 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13314 case GADGET_ID_SCROLL_LIST_UP:
13315 case GADGET_ID_SCROLL_LIST_DOWN:
13316 case GADGET_ID_SCROLL_LIST_VERTICAL:
13317 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
13318 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
13321 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
13322 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
13324 if (element_shift < 0)
13326 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
13327 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
13329 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
13330 GDI_SCROLLBAR_ITEM_POSITION,
13331 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
13334 ModifyEditorElementList();
13338 case GADGET_ID_PROPERTIES:
13339 // always switch off element properties when they are already displayed
13340 last_properties_element = new_element;
13341 case GADGET_ID_ELEMENT_LEFT:
13342 case GADGET_ID_ELEMENT_MIDDLE:
13343 case GADGET_ID_ELEMENT_RIGHT:
13344 properties_element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
13345 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
13346 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 :
13349 if (edit_mode != ED_MODE_PROPERTIES)
13351 last_edit_mode = edit_mode;
13353 ChangeEditModeWindow(ED_MODE_PROPERTIES);
13355 last_level_drawing_function = drawing_function;
13356 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
13359 else if (properties_element != last_properties_element)
13361 DrawEditModeWindow();
13365 ChangeEditModeWindow(last_edit_mode);
13367 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
13372 case GADGET_ID_PALETTE:
13373 if (edit_mode != ED_MODE_PALETTE)
13375 last_edit_mode = edit_mode;
13377 ChangeEditModeWindow(ED_MODE_PALETTE);
13381 ChangeEditModeWindow(last_edit_mode);
13385 case GADGET_ID_WRAP_LEFT:
13386 WrapLevel(-step, 0);
13389 case GADGET_ID_WRAP_RIGHT:
13390 WrapLevel(step, 0);
13393 case GADGET_ID_WRAP_UP:
13394 WrapLevel(0, -step);
13397 case GADGET_ID_WRAP_DOWN:
13398 WrapLevel(0, step);
13401 case GADGET_ID_SINGLE_ITEMS:
13402 case GADGET_ID_CONNECTED_ITEMS:
13403 case GADGET_ID_LINE:
13404 case GADGET_ID_ARC:
13405 case GADGET_ID_TEXT:
13406 case GADGET_ID_RECTANGLE:
13407 case GADGET_ID_FILLED_BOX:
13408 case GADGET_ID_FLOOD_FILL:
13409 case GADGET_ID_GRAB_BRUSH:
13410 case GADGET_ID_PICK_ELEMENT:
13411 if (drawing_function != GADGET_ID_PICK_ELEMENT)
13412 last_drawing_function = drawing_function;
13413 drawing_function = id;
13414 draw_with_brush = FALSE;
13417 case GADGET_ID_RANDOM_PLACEMENT:
13418 RandomPlacement(new_element);
13421 case GADGET_ID_ZOOM:
13422 // zoom level editor tile size in or out (or reset to default size)
13423 ed_tilesize = (button == 1 ? ed_tilesize * 2 :
13424 button == 2 ? ed_tilesize_default :
13425 button == 3 ? ed_tilesize / 2 : ed_tilesize);
13427 // limit zoom level by upper and lower bound
13428 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
13430 InitZoomLevelSettings(ed_tilesize);
13432 if (edit_mode == ED_MODE_DRAWING)
13434 DrawDrawingWindow();
13436 /* redraw zoom gadget info text */
13437 PrintEditorGadgetInfoText(level_editor_gadget[id]);
13440 /* save current editor zoom tilesize */
13441 SaveSetup_AutoSetup();
13445 case GADGET_ID_CUSTOM_COPY_FROM:
13446 case GADGET_ID_CUSTOM_COPY_TO:
13447 case GADGET_ID_CUSTOM_EXCHANGE:
13448 last_custom_copy_mode = id;
13449 last_drawing_function = drawing_function;
13452 case GADGET_ID_CUSTOM_COPY:
13453 CopyCustomElement(properties_element, -1, id);
13456 case GADGET_ID_CUSTOM_PASTE:
13457 CopyCustomElement(-1, properties_element, id);
13460 case GADGET_ID_UNDO:
13461 if (button == 1 && GetKeyModState() & (KMOD_Shift|KMOD_Control))
13464 if (button == 1 && undo_buffer_steps == 0)
13466 Request("Undo buffer empty!", REQ_CONFIRM);
13470 else if (button == 2)
13474 else if (button == 3 && redo_buffer_steps == 0)
13476 Request("Redo buffer empty!", REQ_CONFIRM);
13481 if (edit_mode != ED_MODE_DRAWING)
13482 ChangeEditModeWindow(ED_MODE_DRAWING);
13488 undo_buffer_position =
13489 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
13491 undo_buffer_steps--;
13492 redo_buffer_steps++;
13498 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
13500 undo_buffer_steps++;
13501 redo_buffer_steps--;
13504 for (x = 0; x < lev_fieldx; x++)
13505 for (y = 0; y < lev_fieldy; y++)
13506 Feld[x][y] = UndoBuffer[undo_buffer_position][x][y];
13508 /* check if undo operation forces change of border style */
13509 CheckLevelBorderElement(FALSE);
13511 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13515 case GADGET_ID_INFO:
13516 if (edit_mode != ED_MODE_INFO)
13518 last_edit_mode = edit_mode;
13520 ChangeEditModeWindow(ED_MODE_INFO);
13524 ChangeEditModeWindow(last_edit_mode);
13528 case GADGET_ID_CLEAR:
13529 if (edit_mode != ED_MODE_DRAWING)
13530 ChangeEditModeWindow(ED_MODE_DRAWING);
13532 for (x = 0; x < MAX_LEV_FIELDX; x++)
13533 for (y = 0; y < MAX_LEV_FIELDY; y++)
13534 Feld[x][y] = (button == 1 ? EL_EMPTY : new_element);
13536 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
13538 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13541 case GADGET_ID_SAVE:
13543 /* saving read-only levels into personal level set modifies global vars
13544 "leveldir_current" and "level_nr"; restore them after saving level */
13545 LevelDirTree *leveldir_former = leveldir_current;
13546 int level_nr_former = level_nr;
13547 char *level_filename;
13550 if (leveldir_current->readonly &&
13551 !PrepareSavingIntoPersonalLevelSet())
13554 level_filename = getDefaultLevelFilename(level_nr);
13555 new_level = !fileExists(level_filename);
13558 Request("Save this level and kill the old?", REQ_ASK))
13560 if (leveldir_former->readonly)
13561 ModifyLevelInfoForSavingIntoPersonalLevelSet(leveldir_former->name);
13563 SetAutomaticNumberOfGemsNeeded();
13565 CopyPlayfield(Feld, level.field);
13566 SaveLevel(level_nr);
13568 level.changed = FALSE;
13572 char level_saved_msg[64];
13574 if (leveldir_former->readonly)
13575 sprintf(level_saved_msg,
13576 "Level saved as level %d into personal level set!",
13579 strcpy(level_saved_msg, "Level saved!");
13581 Request(level_saved_msg, REQ_CONFIRM);
13585 /* "cd" back to copied-from levelset (in case of saved read-only level) */
13586 leveldir_current = leveldir_former;
13587 level_nr = level_nr_former;
13592 case GADGET_ID_TEST:
13593 if (LevelChanged())
13594 level.game_version = GAME_VERSION_ACTUAL;
13596 CopyPlayfield(level.field, FieldBackup);
13597 CopyPlayfield(Feld, level.field);
13599 CopyNativeLevel_RND_to_Native(&level);
13601 UnmapLevelEditorGadgets();
13602 UndrawSpecialEditorDoor();
13604 CloseDoor(DOOR_CLOSE_ALL);
13606 /* needed before playing if editor playfield area has different size */
13607 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
13609 // redraw_mask = REDRAW_ALL;
13611 level_editor_test_game = TRUE;
13613 StartGameActions(FALSE, setup.autorecord, level.random_seed);
13617 case GADGET_ID_EXIT:
13618 RequestExitLevelEditor(TRUE, FALSE); /* if level has changed, ask user */
13622 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
13623 id <= GADGET_ID_ELEMENTLIST_LAST)
13625 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
13626 int new_element = editor_elements[element_position + element_shift];
13628 if (IS_EDITOR_CASCADE(new_element))
13632 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
13634 int *cascade_element= &(*editor_elements_info[i].headline_list)[0];
13635 boolean *cascade_value=editor_elements_info[i].setup_cascade_value;
13637 if (*cascade_element == new_element)
13639 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
13640 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
13642 /* update element selection list */
13643 ReinitializeElementList();
13644 ModifyEditorElementList();
13646 /* update cascading gadget info text */
13647 PrintEditorGadgetInfoText(level_editor_gadget[id]);
13649 /* save current editor cascading state */
13650 SaveSetup_EditorCascade();
13659 if (last_custom_copy_mode != -1)
13661 if (CopyCustomElement(properties_element, new_element,
13662 last_custom_copy_mode))
13664 ClickOnGadget(level_editor_gadget[last_drawing_function],
13667 last_custom_copy_mode = -1;
13673 /* change element of button used to show palette */
13674 if (editor.palette.show_on_element_buttons)
13675 button = last_button;
13677 PickDrawingElement(button, new_element);
13679 if (!stick_element_properties_window &&
13680 drawing_function != GADGET_ID_PICK_ELEMENT &&
13681 !(GetKeyModState() & KMOD_Control))
13683 properties_element = new_element;
13684 if (edit_mode == ED_MODE_PROPERTIES)
13685 DrawPropertiesWindow();
13688 if (drawing_function == GADGET_ID_PICK_ELEMENT)
13689 ClickOnGadget(level_editor_gadget[last_drawing_function],
13692 if (!use_permanent_palette)
13693 ChangeEditModeWindow(last_edit_mode);
13696 else if (gi->event.type == GD_EVENT_PRESSED)
13697 printf("default: HandleControlButtons: GD_EVENT_PRESSED(%d)\n", id);
13698 else if (gi->event.type == GD_EVENT_RELEASED)
13699 printf("default: HandleControlButtons: GD_EVENT_RELEASED(%d)\n", id);
13700 else if (gi->event.type == GD_EVENT_MOVING)
13701 printf("default: HandleControlButtons: GD_EVENT_MOVING(%d)\n", id);
13703 printf("default: HandleControlButtons: ? (id == %d)\n", id);
13709 void HandleLevelEditorKeyInput(Key key)
13711 char letter = getCharFromKey(key);
13712 int button = MB_LEFTBUTTON;
13714 if (drawing_function == GADGET_ID_TEXT &&
13715 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
13718 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
13719 else if (key == KSYM_Delete || key == KSYM_BackSpace)
13720 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
13721 else if (key == KSYM_Return)
13722 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
13723 else if (key == KSYM_Escape)
13724 DrawLevelText(0, 0, 0, TEXT_END);
13726 else if (button_status == MB_RELEASED)
13728 int id = GADGET_ID_NONE;
13729 int new_element_shift = element_shift;
13730 int step = ED_ELEMENTLIST_BUTTONS_VERT - 1;
13736 id = GADGET_ID_SCROLL_LEFT;
13739 id = GADGET_ID_SCROLL_RIGHT;
13742 id = GADGET_ID_SCROLL_UP;
13745 id = GADGET_ID_SCROLL_DOWN;
13749 case KSYM_Page_Down:
13750 step *= (key == KSYM_Page_Up ? -1 : +1);
13751 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
13753 if (element_shift < 0)
13755 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
13756 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
13758 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
13759 GDI_SCROLLBAR_ITEM_POSITION,
13760 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
13762 ModifyEditorElementList();
13768 element_shift = (key == KSYM_Home ? 0 :
13769 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
13771 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
13772 GDI_SCROLLBAR_ITEM_POSITION,
13773 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
13775 ModifyEditorElementList();
13782 /* this is needed to prevent interference with running "True X-Mouse" */
13783 if (GetKeyModStateFromEvents() & KMOD_Control)
13786 /* check for last or next editor cascade block in element list */
13787 for (i = 0; i < num_editor_elements; i++)
13789 if ((key == KSYM_Insert && i == element_shift) ||
13790 (key == KSYM_Delete && new_element_shift > element_shift))
13793 /* jump to next cascade block (or to start of element list) */
13794 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
13795 new_element_shift = i;
13798 if (i < num_editor_elements)
13799 element_shift = new_element_shift;
13801 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
13802 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
13804 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
13805 GDI_SCROLLBAR_ITEM_POSITION,
13806 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
13808 ModifyEditorElementList();
13813 if (edit_mode == ED_MODE_DRAWING)
13815 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
13817 else if (edit_mode == ED_MODE_INFO)
13819 HandleControlButtons(level_editor_gadget[GADGET_ID_INFO]);
13821 else if (edit_mode == ED_MODE_PROPERTIES)
13823 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
13825 else if (edit_mode == ED_MODE_PALETTE)
13827 HandleControlButtons(level_editor_gadget[GADGET_ID_PALETTE]);
13829 else /* should never happen */
13831 ChangeEditModeWindow(ED_MODE_DRAWING);
13840 if (id != GADGET_ID_NONE)
13841 ClickOnGadget(level_editor_gadget[id], button);
13842 else if (letter == '1' || letter == '?')
13843 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_LEFT], button);
13844 else if (letter == '2')
13845 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_MIDDLE], button);
13846 else if (letter == '3')
13847 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_RIGHT], button);
13848 else if (letter == '.')
13849 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
13850 else if (letter == 'U')
13851 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
13852 else if (letter == '-' || key == KSYM_KP_Subtract)
13853 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
13854 else if (letter == '0' || key == KSYM_KP_0)
13855 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
13856 else if (letter == '+' || key == KSYM_KP_Add ||
13857 letter == '=') // ("Shift-=" is "+" on US keyboards)
13858 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
13859 else if (key == KSYM_Return ||
13860 key == KSYM_space ||
13861 key == setup.shortcut.toggle_pause)
13862 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
13864 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
13865 if (letter && letter == controlbutton_info[i].shortcut)
13866 if (!anyTextGadgetActive())
13867 ClickOnGadget(level_editor_gadget[i], button);
13871 void HandleLevelEditorIdle(void)
13873 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
13874 int x = editor.settings.element_graphic.x + element_border;
13875 int y = editor.settings.element_graphic.y + element_border;
13876 static unsigned int action_delay = 0;
13877 unsigned int action_delay_value = GameFrameDelay;
13880 if (edit_mode != ED_MODE_PROPERTIES)
13883 if (!DelayReached(&action_delay, action_delay_value))
13886 for (i = 0; i < ED_NUM_SELECTBOX; i++)
13888 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
13890 if (gi->mapped && gi->active && gi->selectbox.open)
13894 DrawEditorElementAnimation(SX + x, SY + y);
13896 redraw_mask |= REDRAW_FIELD;
13898 FrameCounter++; /* increase animation frame counter */
13901 static void ClearEditorGadgetInfoText(void)
13903 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
13906 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
13908 char infotext[MAX_OUTPUT_LINESIZE + 1];
13909 char shortcut[MAX_OUTPUT_LINESIZE + 1];
13910 int max_infotext_len = getMaxInfoTextLength();
13912 if (gi == NULL || strlen(gi->info_text) == 0)
13915 strncpy(infotext, gi->info_text, max_infotext_len);
13916 infotext[max_infotext_len] = '\0';
13918 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
13920 int key = controlbutton_info[gi->custom_id].shortcut;
13924 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
13925 sprintf(shortcut, " ('.' or '%c')", key);
13926 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
13927 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
13928 else if (gi->custom_id == GADGET_ID_TEST)
13929 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
13930 else if (gi->custom_id == GADGET_ID_UNDO)
13931 sprintf(shortcut, " ('%c/Shift-U')", key);
13932 else if (gi->custom_id == GADGET_ID_ZOOM)
13933 sprintf(shortcut, " ('%c', '0', '-')", key);
13935 sprintf(shortcut, " ('%s%c')",
13936 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
13938 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
13939 strcat(infotext, shortcut);
13943 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, INFOTEXT_FONT);
13946 void HandleEditorGadgetInfoText(void *ptr)
13948 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
13950 if (game_status != GAME_MODE_EDITOR)
13953 ClearEditorGadgetInfoText();
13955 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
13958 /* misuse this function to delete brush cursor, if needed */
13959 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
13960 DeleteBrushFromCursor();
13962 PrintEditorGadgetInfoText(gi);
13965 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
13967 static int start_lx, start_ly;
13968 int id = gi->custom_id;
13969 int type_id = gi->custom_type_id;
13970 int sx = gi->event.x;
13971 int sy = gi->event.y;
13972 int lx = sx + level_xpos;
13973 int ly = sy + level_ypos;
13974 int min_sx = 0, min_sy = 0;
13975 int max_sx = gi->drawing.area_xsize - 1;
13976 int max_sy = gi->drawing.area_ysize - 1;
13977 int actual_drawing_function = drawing_function;
13978 int max_infotext_len = getMaxInfoTextLength();
13979 char infotext[MAX_OUTPUT_LINESIZE + 1];
13982 infotext[0] = '\0'; /* start with empty info text */
13984 /* pressed Control key: simulate picking element */
13985 if (GetKeyModState() & KMOD_Control)
13986 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
13988 ClearEditorGadgetInfoText();
13990 if (gi->event.type == GD_EVENT_INFO_LEAVING)
13993 /* make sure to stay inside drawing area boundaries */
13994 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
13995 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
13997 if (id == GADGET_ID_DRAWING_LEVEL)
14001 int min_lx = 0, min_ly = 0;
14002 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
14004 /* get positions inside level field */
14005 lx = sx + level_xpos;
14006 ly = sy + level_ypos;
14008 /* make sure to stay inside level field boundaries */
14009 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
14010 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
14012 /* correct drawing area positions accordingly */
14013 sx = lx - level_xpos;
14014 sy = ly - level_ypos;
14017 if (IN_ED_FIELD(sx,sy) && IN_LEV_FIELD(lx, ly))
14019 if (button_status) /* if (gi->state == GD_BUTTON_PRESSED) */
14021 if (gi->event.type == GD_EVENT_PRESSED)
14027 switch (actual_drawing_function)
14029 case GADGET_ID_SINGLE_ITEMS:
14030 text = "Drawing single items";
14032 case GADGET_ID_CONNECTED_ITEMS:
14033 text = "Drawing connected items";
14035 case GADGET_ID_LINE:
14036 text = "Drawing line";
14038 case GADGET_ID_ARC:
14039 text = "Drawing arc";
14041 case GADGET_ID_TEXT:
14042 text = "Setting text cursor";
14044 case GADGET_ID_RECTANGLE:
14045 text = "Drawing rectangle";
14047 case GADGET_ID_FILLED_BOX:
14048 text = "Drawing filled box";
14050 case GADGET_ID_FLOOD_FILL:
14051 text = "Flood fill";
14053 case GADGET_ID_GRAB_BRUSH:
14054 text = "Grabbing brush";
14056 case GADGET_ID_PICK_ELEMENT:
14057 text = "Picking element";
14061 text = "Drawing position";
14065 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14066 sprintf(infotext, "%s: %d, %d", text, lx, ly);
14068 sprintf(infotext, "%s: %d, %d", text,
14069 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
14071 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14072 strncpy(infotext, getElementInfoText(Feld[lx][ly]), max_infotext_len);
14074 sprintf(infotext, "Level position: %d, %d", lx, ly);
14077 /* misuse this function to draw brush cursor, if needed */
14078 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
14080 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
14081 CopyBrushToCursor(sx, sy);
14083 DeleteBrushFromCursor();
14086 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14088 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14089 int element = drawingarea_info[type_id].value[pos];
14091 strncpy(infotext, getElementInfoText(element), max_infotext_len);
14095 if (id == GADGET_ID_CUSTOM_CONTENT)
14096 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
14097 else if (id == GADGET_ID_GROUP_CONTENT)
14098 sprintf(infotext, "group element position: %d", sx + 1);
14099 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
14100 id <= GADGET_ID_YAMYAM_CONTENT_7)
14101 sprintf(infotext, "content area %d position: %d, %d",
14102 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
14103 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
14104 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
14105 sprintf(infotext, "content area %d position: %d, %d",
14106 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
14107 else if (id == GADGET_ID_ANDROID_CONTENT)
14108 sprintf(infotext, "android element position: %d", sx + 1);
14109 else if (drawingarea_info[type_id].infotext != NULL)
14110 strcpy(infotext, drawingarea_info[type_id].infotext);
14113 infotext[max_infotext_len] = '\0';
14115 if (strlen(infotext) > 0)
14116 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT, infotext);
14119 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
14120 boolean quick_quit)
14122 if (!ask_if_level_has_changed ||
14124 Request("Level has changed! Exit without saving?",
14125 REQ_ASK | REQ_STAY_OPEN))
14127 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
14128 struct RectWithBorder *vp_door_2 = &viewport.door_2[GAME_MODE_MAIN];
14130 /* draw normal door */
14131 UndrawSpecialEditorDoor();
14133 // use door animation if door 1 viewport is unchanged and contains toolbox
14134 if (useEditorDoorAnimation())
14135 CloseDoor(DOOR_CLOSE_1 | DOOR_FORCE_ANIM);
14137 // close editor doors if viewport definition is the same as in main menu
14138 if (vp_door_1->x == DX &&
14139 vp_door_1->y == DY &&
14140 vp_door_1->width == DXSIZE &&
14141 vp_door_1->height == DYSIZE &&
14142 vp_door_2->x == VX &&
14143 vp_door_2->y == VY &&
14144 vp_door_2->width == VXSIZE &&
14145 vp_door_2->height == VYSIZE)
14146 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
14148 SetDoorState(DOOR_CLOSE_2);
14153 FadeSkipNextFadeIn();
14155 SetGameStatus(GAME_MODE_MAIN);
14161 if (!global.use_envelope_request)
14163 CloseDoor(DOOR_CLOSE_1);
14164 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);