1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // http://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
14 #include "libgame/libgame.h"
25 #define INFOTEXT_UNKNOWN_ELEMENT "unknown"
29 -----------------------------------------------------------------------------
30 screen and artwork graphic pixel position definitions
31 -----------------------------------------------------------------------------
34 /* values for the control window */
35 #define ED_CTRL1_BUTTONS_HORIZ 4 /* toolbox */
36 #define ED_CTRL1_BUTTONS_VERT 4
37 #define ED_CTRL2_BUTTONS_HORIZ 3 /* level */
38 #define ED_CTRL2_BUTTONS_VERT 2
39 #define ED_CTRL3_BUTTONS_HORIZ 3 /* CE and GE */
40 #define ED_CTRL3_BUTTONS_VERT 1
41 #define ED_CTRL4_BUTTONS_HORIZ 2 /* CE and GE */
42 #define ED_CTRL4_BUTTONS_VERT 1
43 #define ED_CTRL5_BUTTONS_HORIZ 1 /* properties */
44 #define ED_CTRL5_BUTTONS_VERT 1
45 #define ED_CTRL6_BUTTONS_HORIZ 3 /* properties */
46 #define ED_CTRL6_BUTTONS_VERT 1
47 #define ED_CTRL7_BUTTONS_HORIZ 1 /* palette */
48 #define ED_CTRL7_BUTTONS_VERT 1
50 #define ED_NUM_CTRL1_BUTTONS (ED_CTRL1_BUTTONS_HORIZ * ED_CTRL1_BUTTONS_VERT)
51 #define ED_NUM_CTRL2_BUTTONS (ED_CTRL2_BUTTONS_HORIZ * ED_CTRL2_BUTTONS_VERT)
52 #define ED_NUM_CTRL3_BUTTONS (ED_CTRL3_BUTTONS_HORIZ * ED_CTRL3_BUTTONS_VERT)
53 #define ED_NUM_CTRL4_BUTTONS (ED_CTRL4_BUTTONS_HORIZ * ED_CTRL4_BUTTONS_VERT)
54 #define ED_NUM_CTRL5_BUTTONS (ED_CTRL5_BUTTONS_HORIZ * ED_CTRL5_BUTTONS_VERT)
55 #define ED_NUM_CTRL6_BUTTONS (ED_CTRL6_BUTTONS_HORIZ * ED_CTRL6_BUTTONS_VERT)
56 #define ED_NUM_CTRL7_BUTTONS (ED_CTRL7_BUTTONS_HORIZ * ED_CTRL7_BUTTONS_VERT)
57 #define ED_NUM_CTRL1_2_BUTTONS (ED_NUM_CTRL1_BUTTONS + ED_NUM_CTRL2_BUTTONS)
58 #define ED_NUM_CTRL1_3_BUTTONS (ED_NUM_CTRL1_2_BUTTONS + ED_NUM_CTRL3_BUTTONS)
59 #define ED_NUM_CTRL1_4_BUTTONS (ED_NUM_CTRL1_3_BUTTONS + ED_NUM_CTRL4_BUTTONS)
60 #define ED_NUM_CTRL1_5_BUTTONS (ED_NUM_CTRL1_4_BUTTONS + ED_NUM_CTRL5_BUTTONS)
61 #define ED_NUM_CTRL1_6_BUTTONS (ED_NUM_CTRL1_5_BUTTONS + ED_NUM_CTRL6_BUTTONS)
62 #define ED_NUM_CTRL1_7_BUTTONS (ED_NUM_CTRL1_6_BUTTONS + ED_NUM_CTRL7_BUTTONS)
63 #define ED_NUM_CTRL_BUTTONS ED_NUM_CTRL1_7_BUTTONS
65 /* values for the element list */
66 #define ED_ELEMENTLIST_XPOS (editor.palette.x)
67 #define ED_ELEMENTLIST_YPOS (editor.palette.y)
68 #define ED_ELEMENTLIST_XSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].width)
69 #define ED_ELEMENTLIST_YSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].height)
70 #define ED_ELEMENTLIST_BUTTONS_HORIZ (editor.palette.cols)
71 #define ED_ELEMENTLIST_BUTTONS_VERT (editor.palette.rows)
72 #define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \
73 ED_ELEMENTLIST_BUTTONS_VERT)
75 /* standard distances */
76 #define ED_GADGET_NORMAL_DISTANCE (editor.gadget.normal_spacing)
77 #define ED_GADGET_SMALL_DISTANCE (editor.gadget.small_spacing)
78 #define ED_GADGET_TINY_DISTANCE (editor.gadget.tiny_spacing)
79 #define ED_GADGET_LINE_DISTANCE (editor.gadget.line_spacing)
80 #define ED_GADGET_TEXT_DISTANCE (editor.gadget.text_spacing)
81 #define ED_TAB_BAR_HEIGHT (editor.gadget.separator_line.height)
82 #define ED_DRAWINGAREA_TEXT_DISTANCE (ED_GADGET_TEXT_DISTANCE + \
83 ED_DRAWINGAREA_BORDER_SIZE)
84 #define ED_GADGET_SPACE_DISTANCE (getFontWidth(FONT_TEXT_1))
86 /* values for drawingarea gadgets */
87 #define IMG_BORDER_1 IMG_EDITOR_ELEMENT_BORDER
88 #define IMG_BORDER_2 IMG_EDITOR_ELEMENT_BORDER_INPUT
89 #define ED_ELEMENT_BORDER (graphic_info[IMG_BORDER_1].border_size)
90 #define ED_DRAWINGAREA_BORDER_SIZE (graphic_info[IMG_BORDER_2].border_size)
91 #define ED_DRAWINGAREA_TILE_SIZE (editor.drawingarea.tile_size)
93 /* values for checkbutton gadgets */
94 #define ED_CHECKBUTTON_XSIZE (graphic_info[IMG_EDITOR_CHECKBOX].width)
95 #define ED_CHECKBUTTON_YSIZE (graphic_info[IMG_EDITOR_CHECKBOX].height)
97 #define ED_TABBUTTON_XSIZE (graphic_info[IMG_EDITOR_TABBUTTON].width)
98 #define ED_TABBUTTON_YSIZE (graphic_info[IMG_EDITOR_TABBUTTON].height)
100 #define ED_SETTINGS_LEVEL_TABS_X (editor.settings.tabs.x)
101 #define ED_SETTINGS_LEVEL_TABS_Y (editor.settings.tabs.y)
102 #define ED_SETTINGS_ELEMENT_TABS_X (editor.settings.tabs.x)
103 #define ED_SETTINGS_ELEMENT_TABS_Y (editor.settings.tabs.y + \
104 editor.settings.tabs.yoffset2)
106 #define ED_SETTINGS_TABS_XOFFSET (editor.settings.tabs.draw_xoffset)
107 #define ED_SETTINGS_TABS_YOFFSET (editor.settings.tabs.draw_yoffset)
109 #define ED_LEVEL_TABS_XSTART (ED_SETTINGS_LEVEL_TABS_X)
110 #define ED_LEVEL_TABS_YSTART (ED_SETTINGS_LEVEL_TABS_Y)
111 #define ED_LEVEL_SETTINGS_XSTART (ED_SETTINGS_LEVEL_TABS_X + \
112 ED_SETTINGS_TABS_XOFFSET)
113 #define ED_LEVEL_SETTINGS_YSTART (ED_SETTINGS_LEVEL_TABS_Y + \
114 ED_TABBUTTON_YSIZE + \
115 ED_GADGET_TINY_DISTANCE + \
116 ED_TAB_BAR_HEIGHT + \
117 ED_SETTINGS_TABS_YOFFSET + \
118 getFontHeight(FONT_TEXT_1) + \
119 ED_GADGET_TEXT_DISTANCE)
120 #define ED_ELEMENT_TABS_XSTART (ED_SETTINGS_ELEMENT_TABS_X)
121 #define ED_ELEMENT_TABS_YSTART (ED_SETTINGS_ELEMENT_TABS_Y)
122 #define ED_ELEMENT_SETTINGS_XSTART (ED_SETTINGS_ELEMENT_TABS_X + \
123 ED_SETTINGS_TABS_XOFFSET)
124 #define ED_ELEMENT_SETTINGS_YSTART (ED_SETTINGS_ELEMENT_TABS_Y + \
125 ED_TABBUTTON_YSIZE + \
126 ED_GADGET_TINY_DISTANCE + \
127 ED_TAB_BAR_HEIGHT + \
128 ED_SETTINGS_TABS_YOFFSET)
130 #define ED_SETTINGS_XOFFSET (ED_CHECKBUTTON_XSIZE + \
131 ED_GADGET_TEXT_DISTANCE)
132 #define ED_SETTINGS_YOFFSET (ED_CHECKBUTTON_YSIZE + \
133 ED_GADGET_LINE_DISTANCE)
135 #define ED_POS_RANGE (10000)
136 #define ED_POS_LEVEL_TABS_FIRST (1 * ED_POS_RANGE)
137 #define ED_POS_LEVEL_TABS_LAST (2 * ED_POS_RANGE - 1)
138 #define ED_POS_LEVEL_SETTINGS_FIRST (2 * ED_POS_RANGE)
139 #define ED_POS_LEVEL_SETTINGS_LAST (3 * ED_POS_RANGE - 1)
140 #define ED_POS_ELEMENT_TABS_FIRST (3 * ED_POS_RANGE)
141 #define ED_POS_ELEMENT_TABS_LAST (4 * ED_POS_RANGE - 1)
142 #define ED_POS_ELEMENT_SETTINGS_FIRST (4 * ED_POS_RANGE)
143 #define ED_POS_ELEMENT_SETTINGS_LAST (5 * ED_POS_RANGE - 1)
145 #define ED_LEVEL_TABS_XPOS(n) (ED_POS_LEVEL_TABS_FIRST + (n))
146 #define ED_LEVEL_TABS_YPOS(n) (ED_POS_LEVEL_TABS_FIRST + (n))
148 #define ED_LEVEL_SETTINGS_XPOS(n) (ED_POS_LEVEL_SETTINGS_FIRST + (n))
149 #define ED_LEVEL_SETTINGS_YPOS(n) (ED_POS_LEVEL_SETTINGS_FIRST + (n))
151 #define ED_ELEMENT_TABS_XPOS(n) (ED_POS_ELEMENT_TABS_FIRST + (n))
152 #define ED_ELEMENT_TABS_YPOS(n) (ED_POS_ELEMENT_TABS_FIRST + (n))
154 #define ED_ELEMENT_SETTINGS_XPOS(n) (ED_POS_ELEMENT_SETTINGS_FIRST + (n))
155 #define ED_ELEMENT_SETTINGS_YPOS(n) (ED_POS_ELEMENT_SETTINGS_FIRST + (n))
157 #define IS_POS_LEVEL_TABS(n) ((n) >= ED_POS_LEVEL_TABS_FIRST && \
158 (n) <= ED_POS_LEVEL_TABS_LAST)
159 #define IS_POS_LEVEL_SETTINGS(n) ((n) >= ED_POS_LEVEL_SETTINGS_FIRST && \
160 (n) <= ED_POS_LEVEL_SETTINGS_LAST)
161 #define IS_POS_ELEMENT_TABS(n) ((n) >= ED_POS_ELEMENT_TABS_FIRST && \
162 (n) <= ED_POS_ELEMENT_TABS_LAST)
163 #define IS_POS_ELEMENT_SETTINGS(n) ((n) >= ED_POS_ELEMENT_SETTINGS_FIRST && \
164 (n) <= ED_POS_ELEMENT_SETTINGS_LAST)
166 #define ED_LEVEL_TABS_LINE(n) ((n) - ED_POS_LEVEL_TABS_FIRST)
167 #define ED_LEVEL_SETTINGS_LINE(n) ((n) - ED_POS_LEVEL_SETTINGS_FIRST)
168 #define ED_ELEMENT_TABS_LINE(n) ((n) - ED_POS_ELEMENT_TABS_FIRST)
169 #define ED_ELEMENT_SETTINGS_LINE(n) ((n) - ED_POS_ELEMENT_SETTINGS_FIRST)
171 #define ED_LEVEL_TABS_X(n) (ED_LEVEL_TABS_XSTART + \
172 (n) * ED_SETTINGS_TABS_XOFFSET)
173 #define ED_LEVEL_TABS_Y(n) (ED_LEVEL_TABS_YSTART + \
174 (n) * ED_SETTINGS_TABS_YOFFSET)
176 #define ED_LEVEL_SETTINGS_X(n) (ED_LEVEL_SETTINGS_XSTART + \
177 (n) * ED_SETTINGS_XOFFSET)
178 #define ED_LEVEL_SETTINGS_Y(n) (ED_LEVEL_SETTINGS_YSTART + \
179 (n) * ED_SETTINGS_YOFFSET)
181 #define ED_ELEMENT_TABS_X(n) (ED_ELEMENT_TABS_XSTART + \
182 (n) * ED_SETTINGS_TABS_XOFFSET)
183 #define ED_ELEMENT_TABS_Y(n) (ED_ELEMENT_TABS_YSTART + \
184 (n) * ED_SETTINGS_TABS_YOFFSET)
186 #define ED_ELEMENT_SETTINGS_X(n) (ED_ELEMENT_SETTINGS_XSTART + \
187 (n) * ED_SETTINGS_XOFFSET)
188 #define ED_ELEMENT_SETTINGS_Y(n) (ED_ELEMENT_SETTINGS_YSTART + \
189 (n) * ED_SETTINGS_YOFFSET)
191 #define ED_POS_TO_LEVEL_TABS_X(n) \
192 (ED_LEVEL_TABS_X(ED_LEVEL_TABS_LINE(n)))
193 #define ED_POS_TO_LEVEL_TABS_Y(n) \
194 (ED_LEVEL_TABS_Y(ED_LEVEL_TABS_LINE(n)))
196 #define ED_POS_TO_LEVEL_SETTINGS_X(n) \
197 (ED_LEVEL_SETTINGS_X(ED_LEVEL_SETTINGS_LINE(n)))
198 #define ED_POS_TO_LEVEL_SETTINGS_Y(n) \
199 (ED_LEVEL_SETTINGS_Y(ED_LEVEL_SETTINGS_LINE(n)))
201 #define ED_POS_TO_ELEMENT_TABS_X(n) \
202 (ED_ELEMENT_TABS_X(ED_ELEMENT_TABS_LINE(n)))
203 #define ED_POS_TO_ELEMENT_TABS_Y(n) \
204 (ED_ELEMENT_TABS_Y(ED_ELEMENT_TABS_LINE(n)))
206 #define ED_POS_TO_ELEMENT_SETTINGS_X(n) \
207 (ED_ELEMENT_SETTINGS_X(ED_ELEMENT_SETTINGS_LINE(n)))
208 #define ED_POS_TO_ELEMENT_SETTINGS_Y(n) \
209 (ED_ELEMENT_SETTINGS_Y(ED_ELEMENT_SETTINGS_LINE(n)))
211 #define ED_SETTINGS_X(n) (IS_POS_LEVEL_TABS(n) ? \
212 ED_POS_TO_LEVEL_TABS_X(n) : \
213 IS_POS_LEVEL_SETTINGS(n) ? \
214 ED_POS_TO_LEVEL_SETTINGS_X(n) : \
215 IS_POS_ELEMENT_TABS(n) ? \
216 ED_POS_TO_ELEMENT_TABS_X(n) : \
217 IS_POS_ELEMENT_SETTINGS(n) ? \
218 ED_POS_TO_ELEMENT_SETTINGS_X(n) : (n))
219 #define ED_SETTINGS_Y(n) (IS_POS_LEVEL_TABS(n) ? \
220 ED_POS_TO_LEVEL_TABS_Y(n) : \
221 IS_POS_LEVEL_SETTINGS(n) ? \
222 ED_POS_TO_LEVEL_SETTINGS_Y(n) : \
223 IS_POS_ELEMENT_TABS(n) ? \
224 ED_POS_TO_ELEMENT_TABS_Y(n) : \
225 IS_POS_ELEMENT_SETTINGS(n) ? \
226 ED_POS_TO_ELEMENT_SETTINGS_Y(n) : (n))
228 #define ED_SETTINGS_XOFF(n) (5 * ((n) % 4) * \
229 ED_DRAWINGAREA_TILE_SIZE)
230 #define ED_SETTINGS_YOFF(n) (5 * ((n) / 4) * \
231 ED_DRAWINGAREA_TILE_SIZE)
233 #define ED_AREA_XOFFSET_1(n) ((n) != 0 ? \
234 ED_DRAWINGAREA_BORDER_SIZE : 0)
235 #define ED_AREA_YOFFSET_1(n) ((n) != 0 ? \
236 (ED_CHECKBUTTON_YSIZE - \
237 ED_DRAWINGAREA_TILE_SIZE) / 2 : 0)
239 #define ED_AREA_XOFFSET_2(n) (0)
240 #define ED_AREA_YOFFSET_2(n) ((n) == 3 ? \
241 ((n) - 1) * ED_DRAWINGAREA_TILE_SIZE / 2 : 0)
243 #define ED_AREA_SETTINGS_X(i) (ED_SETTINGS_X((i).x) + \
244 ED_SETTINGS_XOFF((i).xoffset) + \
245 ED_AREA_XOFFSET_1((i).x) - \
246 ED_AREA_XOFFSET_2((i).area_xsize))
247 #define ED_AREA_SETTINGS_Y(i) (ED_SETTINGS_Y((i).y) + \
248 ED_SETTINGS_YOFF((i).yoffset) + \
249 ED_AREA_YOFFSET_1((i).y) - \
250 ED_AREA_YOFFSET_2((i).area_ysize))
252 /* values for element content drawing areas */
253 #define ED_AREA_1X1_LSETTINGS_XPOS(n) ED_LEVEL_SETTINGS_XPOS(n)
254 #define ED_AREA_1X1_LSETTINGS_YPOS(n) ED_LEVEL_SETTINGS_YPOS(n)
255 #define ED_AREA_1X1_LSETTINGS_XOFF (0)
256 #define ED_AREA_1X1_LSETTINGS_YOFF (0)
258 #define ED_AREA_1X1_SETTINGS_XPOS(n) ED_ELEMENT_SETTINGS_XPOS(n)
259 #define ED_AREA_1X1_SETTINGS_YPOS(n) ED_ELEMENT_SETTINGS_YPOS(n)
260 #define ED_AREA_1X1_SETTINGS_XOFF (0)
261 #define ED_AREA_1X1_SETTINGS_YOFF (0)
263 #define ED_AREA_3X3_SETTINGS_XPOS(n) ED_ELEMENT_SETTINGS_XPOS(n)
264 #define ED_AREA_3X3_SETTINGS_YPOS(n) ED_ELEMENT_SETTINGS_YPOS(n)
265 #define ED_AREA_3X3_SETTINGS_XOFF (0)
266 #define ED_AREA_3X3_SETTINGS_YOFF (0)
268 /* element content */
269 #define ED_AREA_ELEMENT_CONTENT_XOFF(n) (n)
270 #define ED_AREA_ELEMENT_CONTENT_YOFF(n) (n)
273 #define ED_XPOS_YAM 0
274 #define ED_YPOS_YAM 5
275 #define ED_AREA_YAMYAM_CONTENT_XPOS ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_YAM)
276 #define ED_AREA_YAMYAM_CONTENT_YPOS ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_YAM)
277 #define ED_AREA_YAMYAM_CONTENT_XOFF(n) ED_AREA_ELEMENT_CONTENT_XOFF(n)
278 #define ED_AREA_YAMYAM_CONTENT_YOFF(n) ED_AREA_ELEMENT_CONTENT_YOFF(n)
279 #define ED_AREA_YAMYAM_CONTENT_X(n) (ED_ELEMENT_SETTINGS_X(ED_XPOS_YAM) + \
281 #define ED_AREA_YAMYAM_CONTENT_Y(n) (ED_ELEMENT_SETTINGS_Y(ED_YPOS_YAM) + \
282 ED_SETTINGS_YOFF(n) + \
283 ED_AREA_YOFFSET_1(ED_YPOS_YAM) - \
284 ED_AREA_YOFFSET_2(3))
286 /* magic ball content */
287 #define ED_XPOS_BALL 0
288 #define ED_YPOS_BALL 6
289 #define ED_AREA_MAGIC_BALL_CONTENT_XPOS ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_BALL)
290 #define ED_AREA_MAGIC_BALL_CONTENT_YPOS ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_BALL)
291 #define ED_AREA_MAGIC_BALL_CONTENT_XOFF(n) ED_AREA_ELEMENT_CONTENT_XOFF(n)
292 #define ED_AREA_MAGIC_BALL_CONTENT_YOFF(n) ED_AREA_ELEMENT_CONTENT_YOFF(n)
293 #define ED_AREA_MAGIC_BALL_CONTENT_X(n) (ED_ELEMENT_SETTINGS_X(ED_XPOS_BALL) + \
295 #define ED_AREA_MAGIC_BALL_CONTENT_Y(n) (ED_ELEMENT_SETTINGS_Y(ED_YPOS_BALL) + \
296 ED_SETTINGS_YOFF(n) + \
297 ED_AREA_YOFFSET_1(ED_YPOS_BALL) - \
298 ED_AREA_YOFFSET_2(3))
300 /* values for scrolling gadgets for drawing area */
301 #define ED_SCROLLBUTTON_XSIZE (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].width)
302 #define ED_SCROLLBUTTON_YSIZE (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].height)
304 #define ED_SCROLL_UP_XPOS (SXSIZE - ED_SCROLLBUTTON_XSIZE)
305 #define ED_SCROLL_UP_YPOS (0)
306 #define ED_SCROLL_DOWN_XPOS ED_SCROLL_UP_XPOS
307 #define ED_SCROLL_DOWN_YPOS (SYSIZE - 3 * ED_SCROLLBUTTON_YSIZE)
308 #define ED_SCROLL_LEFT_XPOS (0)
309 #define ED_SCROLL_LEFT_YPOS (SYSIZE - 2 * ED_SCROLLBUTTON_YSIZE)
310 #define ED_SCROLL_RIGHT_XPOS (SXSIZE - 2 * ED_SCROLLBUTTON_XSIZE)
311 #define ED_SCROLL_RIGHT_YPOS ED_SCROLL_LEFT_YPOS
312 #define ED_SCROLL_HORIZONTAL_XPOS (ED_SCROLL_LEFT_XPOS + \
313 ED_SCROLLBUTTON_XSIZE)
314 #define ED_SCROLL_HORIZONTAL_YPOS ED_SCROLL_LEFT_YPOS
315 #define ED_SCROLL_HORIZONTAL_XSIZE (SXSIZE - 3 * ED_SCROLLBUTTON_XSIZE)
316 #define ED_SCROLL_HORIZONTAL_YSIZE ED_SCROLLBUTTON_YSIZE
317 #define ED_SCROLL_VERTICAL_XPOS ED_SCROLL_UP_XPOS
318 #define ED_SCROLL_VERTICAL_YPOS (ED_SCROLL_UP_YPOS + \
319 ED_SCROLLBUTTON_YSIZE)
320 #define ED_SCROLL_VERTICAL_XSIZE ED_SCROLLBUTTON_XSIZE
321 #define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - 4 * ED_SCROLLBUTTON_YSIZE)
323 /* values for scrolling gadgets for element list */
324 #define ED_SCROLLBUTTON2_XSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].width)
325 #define ED_SCROLLBUTTON2_YSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].height)
327 #define ED_SCROLL2_UP_XPOS (ED_ELEMENTLIST_XPOS + \
328 ED_ELEMENTLIST_BUTTONS_HORIZ * \
329 ED_ELEMENTLIST_XSIZE)
330 #define ED_SCROLL2_UP_YPOS ED_ELEMENTLIST_YPOS
331 #define ED_SCROLL2_DOWN_XPOS ED_SCROLL2_UP_XPOS
332 #define ED_SCROLL2_DOWN_YPOS (ED_SCROLL2_UP_YPOS + \
333 ED_ELEMENTLIST_BUTTONS_VERT * \
334 ED_ELEMENTLIST_YSIZE - \
335 ED_SCROLLBUTTON2_YSIZE)
336 #define ED_SCROLL2_VERTICAL_XPOS ED_SCROLL2_UP_XPOS
337 #define ED_SCROLL2_VERTICAL_YPOS (ED_SCROLL2_UP_YPOS + \
338 ED_SCROLLBUTTON2_YSIZE)
339 #define ED_SCROLL2_VERTICAL_XSIZE ED_SCROLLBUTTON2_XSIZE
340 #define ED_SCROLL2_VERTICAL_YSIZE (ED_ELEMENTLIST_BUTTONS_VERT * \
341 ED_ELEMENTLIST_YSIZE - \
342 2 * ED_SCROLLBUTTON2_YSIZE)
344 /* values for ClearEditorGadgetInfoText() and HandleEditorGadgetInfoText() */
345 #define INFOTEXT_FONT FONT_TEXT_2
346 #define INFOTEXT_XSIZE SXSIZE
347 #define INFOTEXT_YSIZE getFontHeight(INFOTEXT_FONT)
348 #define INFOTEXT_YSIZE_FULL (INFOTEXT_YSIZE + ED_GADGET_SMALL_DISTANCE)
349 #define INFOTEXT_XPOS SX
350 #define INFOTEXT_YPOS (SY + SYSIZE - INFOTEXT_YSIZE)
354 -----------------------------------------------------------------------------
355 editor gadget definitions
356 -----------------------------------------------------------------------------
359 /* drawing toolbox buttons */
360 #define GADGET_ID_NONE -1
361 #define GADGET_ID_TOOLBOX_FIRST 0
363 #define GADGET_ID_SINGLE_ITEMS (GADGET_ID_TOOLBOX_FIRST + 0)
364 #define GADGET_ID_CONNECTED_ITEMS (GADGET_ID_TOOLBOX_FIRST + 1)
365 #define GADGET_ID_LINE (GADGET_ID_TOOLBOX_FIRST + 2)
366 #define GADGET_ID_ARC (GADGET_ID_TOOLBOX_FIRST + 3)
367 #define GADGET_ID_RECTANGLE (GADGET_ID_TOOLBOX_FIRST + 4)
368 #define GADGET_ID_FILLED_BOX (GADGET_ID_TOOLBOX_FIRST + 5)
369 #define GADGET_ID_WRAP_UP (GADGET_ID_TOOLBOX_FIRST + 6)
370 #define GADGET_ID_TEXT (GADGET_ID_TOOLBOX_FIRST + 7)
371 #define GADGET_ID_FLOOD_FILL (GADGET_ID_TOOLBOX_FIRST + 8)
372 #define GADGET_ID_WRAP_LEFT (GADGET_ID_TOOLBOX_FIRST + 9)
373 #define GADGET_ID_ZOOM (GADGET_ID_TOOLBOX_FIRST + 10)
374 #define GADGET_ID_WRAP_RIGHT (GADGET_ID_TOOLBOX_FIRST + 11)
375 #define GADGET_ID_RANDOM_PLACEMENT (GADGET_ID_TOOLBOX_FIRST + 12)
376 #define GADGET_ID_GRAB_BRUSH (GADGET_ID_TOOLBOX_FIRST + 13)
377 #define GADGET_ID_WRAP_DOWN (GADGET_ID_TOOLBOX_FIRST + 14)
378 #define GADGET_ID_PICK_ELEMENT (GADGET_ID_TOOLBOX_FIRST + 15)
380 #define GADGET_ID_UNDO (GADGET_ID_TOOLBOX_FIRST + 16)
381 #define GADGET_ID_INFO (GADGET_ID_TOOLBOX_FIRST + 17)
382 #define GADGET_ID_SAVE (GADGET_ID_TOOLBOX_FIRST + 18)
383 #define GADGET_ID_CLEAR (GADGET_ID_TOOLBOX_FIRST + 19)
384 #define GADGET_ID_TEST (GADGET_ID_TOOLBOX_FIRST + 20)
385 #define GADGET_ID_EXIT (GADGET_ID_TOOLBOX_FIRST + 21)
387 #define GADGET_ID_CUSTOM_COPY_FROM (GADGET_ID_TOOLBOX_FIRST + 22)
388 #define GADGET_ID_CUSTOM_COPY_TO (GADGET_ID_TOOLBOX_FIRST + 23)
389 #define GADGET_ID_CUSTOM_EXCHANGE (GADGET_ID_TOOLBOX_FIRST + 24)
390 #define GADGET_ID_CUSTOM_COPY (GADGET_ID_TOOLBOX_FIRST + 25)
391 #define GADGET_ID_CUSTOM_PASTE (GADGET_ID_TOOLBOX_FIRST + 26)
393 #define GADGET_ID_PROPERTIES (GADGET_ID_TOOLBOX_FIRST + 27)
394 #define GADGET_ID_ELEMENT_LEFT (GADGET_ID_TOOLBOX_FIRST + 28)
395 #define GADGET_ID_ELEMENT_MIDDLE (GADGET_ID_TOOLBOX_FIRST + 29)
396 #define GADGET_ID_ELEMENT_RIGHT (GADGET_ID_TOOLBOX_FIRST + 30)
397 #define GADGET_ID_PALETTE (GADGET_ID_TOOLBOX_FIRST + 31)
399 /* counter gadget identifiers */
400 #define GADGET_ID_COUNTER_FIRST (GADGET_ID_TOOLBOX_FIRST + 32)
402 #define GADGET_ID_SELECT_LEVEL_DOWN (GADGET_ID_COUNTER_FIRST + 0)
403 #define GADGET_ID_SELECT_LEVEL_TEXT (GADGET_ID_COUNTER_FIRST + 1)
404 #define GADGET_ID_SELECT_LEVEL_UP (GADGET_ID_COUNTER_FIRST + 2)
405 #define GADGET_ID_LEVEL_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 3)
406 #define GADGET_ID_LEVEL_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 4)
407 #define GADGET_ID_LEVEL_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 5)
408 #define GADGET_ID_LEVEL_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 6)
409 #define GADGET_ID_LEVEL_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 7)
410 #define GADGET_ID_LEVEL_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 8)
411 #define GADGET_ID_LEVEL_RANDOM_DOWN (GADGET_ID_COUNTER_FIRST + 9)
412 #define GADGET_ID_LEVEL_RANDOM_TEXT (GADGET_ID_COUNTER_FIRST + 10)
413 #define GADGET_ID_LEVEL_RANDOM_UP (GADGET_ID_COUNTER_FIRST + 11)
414 #define GADGET_ID_LEVEL_GEMSLIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 12)
415 #define GADGET_ID_LEVEL_GEMSLIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 13)
416 #define GADGET_ID_LEVEL_GEMSLIMIT_UP (GADGET_ID_COUNTER_FIRST + 14)
417 #define GADGET_ID_LEVEL_TIMELIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 15)
418 #define GADGET_ID_LEVEL_TIMELIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 16)
419 #define GADGET_ID_LEVEL_TIMELIMIT_UP (GADGET_ID_COUNTER_FIRST + 17)
420 #define GADGET_ID_LEVEL_TIMESCORE_DOWN (GADGET_ID_COUNTER_FIRST + 18)
421 #define GADGET_ID_LEVEL_TIMESCORE_TEXT (GADGET_ID_COUNTER_FIRST + 19)
422 #define GADGET_ID_LEVEL_TIMESCORE_UP (GADGET_ID_COUNTER_FIRST + 20)
423 #define GADGET_ID_LEVEL_RANDOM_SEED_DOWN (GADGET_ID_COUNTER_FIRST + 21)
424 #define GADGET_ID_LEVEL_RANDOM_SEED_TEXT (GADGET_ID_COUNTER_FIRST + 22)
425 #define GADGET_ID_LEVEL_RANDOM_SEED_UP (GADGET_ID_COUNTER_FIRST + 23)
426 #define GADGET_ID_ELEMENT_VALUE1_DOWN (GADGET_ID_COUNTER_FIRST + 24)
427 #define GADGET_ID_ELEMENT_VALUE1_TEXT (GADGET_ID_COUNTER_FIRST + 25)
428 #define GADGET_ID_ELEMENT_VALUE1_UP (GADGET_ID_COUNTER_FIRST + 26)
429 #define GADGET_ID_ELEMENT_VALUE2_DOWN (GADGET_ID_COUNTER_FIRST + 27)
430 #define GADGET_ID_ELEMENT_VALUE2_TEXT (GADGET_ID_COUNTER_FIRST + 28)
431 #define GADGET_ID_ELEMENT_VALUE2_UP (GADGET_ID_COUNTER_FIRST + 29)
432 #define GADGET_ID_ELEMENT_VALUE3_DOWN (GADGET_ID_COUNTER_FIRST + 30)
433 #define GADGET_ID_ELEMENT_VALUE3_TEXT (GADGET_ID_COUNTER_FIRST + 31)
434 #define GADGET_ID_ELEMENT_VALUE3_UP (GADGET_ID_COUNTER_FIRST + 32)
435 #define GADGET_ID_ELEMENT_VALUE4_DOWN (GADGET_ID_COUNTER_FIRST + 33)
436 #define GADGET_ID_ELEMENT_VALUE4_TEXT (GADGET_ID_COUNTER_FIRST + 34)
437 #define GADGET_ID_ELEMENT_VALUE4_UP (GADGET_ID_COUNTER_FIRST + 35)
438 #define GADGET_ID_YAMYAM_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 36)
439 #define GADGET_ID_YAMYAM_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 37)
440 #define GADGET_ID_YAMYAM_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 38)
441 #define GADGET_ID_BALL_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 39)
442 #define GADGET_ID_BALL_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 40)
443 #define GADGET_ID_BALL_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 41)
444 #define GADGET_ID_ANDROID_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 42)
445 #define GADGET_ID_ANDROID_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 43)
446 #define GADGET_ID_ANDROID_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 44)
447 #define GADGET_ID_ENVELOPE_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 45)
448 #define GADGET_ID_ENVELOPE_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 46)
449 #define GADGET_ID_ENVELOPE_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 47)
450 #define GADGET_ID_ENVELOPE_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 48)
451 #define GADGET_ID_ENVELOPE_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 49)
452 #define GADGET_ID_ENVELOPE_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 50)
453 #define GADGET_ID_INVENTORY_SIZE_DOWN (GADGET_ID_COUNTER_FIRST + 51)
454 #define GADGET_ID_INVENTORY_SIZE_TEXT (GADGET_ID_COUNTER_FIRST + 52)
455 #define GADGET_ID_INVENTORY_SIZE_UP (GADGET_ID_COUNTER_FIRST + 53)
456 #define GADGET_ID_CUSTOM_SCORE_DOWN (GADGET_ID_COUNTER_FIRST + 54)
457 #define GADGET_ID_CUSTOM_SCORE_TEXT (GADGET_ID_COUNTER_FIRST + 55)
458 #define GADGET_ID_CUSTOM_SCORE_UP (GADGET_ID_COUNTER_FIRST + 56)
459 #define GADGET_ID_CUSTOM_GEMCOUNT_DOWN (GADGET_ID_COUNTER_FIRST + 57)
460 #define GADGET_ID_CUSTOM_GEMCOUNT_TEXT (GADGET_ID_COUNTER_FIRST + 58)
461 #define GADGET_ID_CUSTOM_GEMCOUNT_UP (GADGET_ID_COUNTER_FIRST + 59)
462 #define GADGET_ID_CUSTOM_VALUE_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 60)
463 #define GADGET_ID_CUSTOM_VALUE_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 61)
464 #define GADGET_ID_CUSTOM_VALUE_FIX_UP (GADGET_ID_COUNTER_FIRST + 62)
465 #define GADGET_ID_CUSTOM_VALUE_RND_DOWN (GADGET_ID_COUNTER_FIRST + 63)
466 #define GADGET_ID_CUSTOM_VALUE_RND_TEXT (GADGET_ID_COUNTER_FIRST + 64)
467 #define GADGET_ID_CUSTOM_VALUE_RND_UP (GADGET_ID_COUNTER_FIRST + 65)
468 #define GADGET_ID_PUSH_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 66)
469 #define GADGET_ID_PUSH_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 67)
470 #define GADGET_ID_PUSH_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 68)
471 #define GADGET_ID_PUSH_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 69)
472 #define GADGET_ID_PUSH_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 70)
473 #define GADGET_ID_PUSH_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 71)
474 #define GADGET_ID_DROP_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 72)
475 #define GADGET_ID_DROP_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 73)
476 #define GADGET_ID_DROP_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 74)
477 #define GADGET_ID_DROP_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 75)
478 #define GADGET_ID_DROP_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 76)
479 #define GADGET_ID_DROP_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 77)
480 #define GADGET_ID_MOVE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 78)
481 #define GADGET_ID_MOVE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 79)
482 #define GADGET_ID_MOVE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 80)
483 #define GADGET_ID_MOVE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 81)
484 #define GADGET_ID_MOVE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 82)
485 #define GADGET_ID_MOVE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 83)
486 #define GADGET_ID_EXPLOSION_DELAY_DOWN (GADGET_ID_COUNTER_FIRST + 84)
487 #define GADGET_ID_EXPLOSION_DELAY_TEXT (GADGET_ID_COUNTER_FIRST + 85)
488 #define GADGET_ID_EXPLOSION_DELAY_UP (GADGET_ID_COUNTER_FIRST + 86)
489 #define GADGET_ID_IGNITION_DELAY_DOWN (GADGET_ID_COUNTER_FIRST + 87)
490 #define GADGET_ID_IGNITION_DELAY_TEXT (GADGET_ID_COUNTER_FIRST + 88)
491 #define GADGET_ID_IGNITION_DELAY_UP (GADGET_ID_COUNTER_FIRST + 89)
492 #define GADGET_ID_CHANGE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 90)
493 #define GADGET_ID_CHANGE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 91)
494 #define GADGET_ID_CHANGE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 92)
495 #define GADGET_ID_CHANGE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 93)
496 #define GADGET_ID_CHANGE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 94)
497 #define GADGET_ID_CHANGE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 95)
498 #define GADGET_ID_CHANGE_CONT_RND_DOWN (GADGET_ID_COUNTER_FIRST + 96)
499 #define GADGET_ID_CHANGE_CONT_RND_TEXT (GADGET_ID_COUNTER_FIRST + 97)
500 #define GADGET_ID_CHANGE_CONT_RND_UP (GADGET_ID_COUNTER_FIRST + 98)
501 #define GADGET_ID_GROUP_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 99)
502 #define GADGET_ID_GROUP_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 100)
503 #define GADGET_ID_GROUP_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 101)
505 /* drawing area identifiers */
506 #define GADGET_ID_DRAWING_AREA_FIRST (GADGET_ID_COUNTER_FIRST + 102)
508 #define GADGET_ID_DRAWING_LEVEL (GADGET_ID_DRAWING_AREA_FIRST + 0)
509 #define GADGET_ID_YAMYAM_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 1)
510 #define GADGET_ID_YAMYAM_CONTENT_1 (GADGET_ID_DRAWING_AREA_FIRST + 2)
511 #define GADGET_ID_YAMYAM_CONTENT_2 (GADGET_ID_DRAWING_AREA_FIRST + 3)
512 #define GADGET_ID_YAMYAM_CONTENT_3 (GADGET_ID_DRAWING_AREA_FIRST + 4)
513 #define GADGET_ID_YAMYAM_CONTENT_4 (GADGET_ID_DRAWING_AREA_FIRST + 5)
514 #define GADGET_ID_YAMYAM_CONTENT_5 (GADGET_ID_DRAWING_AREA_FIRST + 6)
515 #define GADGET_ID_YAMYAM_CONTENT_6 (GADGET_ID_DRAWING_AREA_FIRST + 7)
516 #define GADGET_ID_YAMYAM_CONTENT_7 (GADGET_ID_DRAWING_AREA_FIRST + 8)
517 #define GADGET_ID_MAGIC_BALL_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 9)
518 #define GADGET_ID_MAGIC_BALL_CONTENT_1 (GADGET_ID_DRAWING_AREA_FIRST + 10)
519 #define GADGET_ID_MAGIC_BALL_CONTENT_2 (GADGET_ID_DRAWING_AREA_FIRST + 11)
520 #define GADGET_ID_MAGIC_BALL_CONTENT_3 (GADGET_ID_DRAWING_AREA_FIRST + 12)
521 #define GADGET_ID_MAGIC_BALL_CONTENT_4 (GADGET_ID_DRAWING_AREA_FIRST + 13)
522 #define GADGET_ID_MAGIC_BALL_CONTENT_5 (GADGET_ID_DRAWING_AREA_FIRST + 14)
523 #define GADGET_ID_MAGIC_BALL_CONTENT_6 (GADGET_ID_DRAWING_AREA_FIRST + 15)
524 #define GADGET_ID_MAGIC_BALL_CONTENT_7 (GADGET_ID_DRAWING_AREA_FIRST + 16)
525 #define GADGET_ID_ANDROID_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 17)
526 #define GADGET_ID_AMOEBA_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 18)
527 #define GADGET_ID_START_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 19)
528 #define GADGET_ID_ARTWORK_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 20)
529 #define GADGET_ID_EXPLOSION_ELEMENT (GADGET_ID_DRAWING_AREA_FIRST + 21)
530 #define GADGET_ID_INVENTORY_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 22)
531 #define GADGET_ID_CUSTOM_GRAPHIC (GADGET_ID_DRAWING_AREA_FIRST + 23)
532 #define GADGET_ID_CUSTOM_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 24)
533 #define GADGET_ID_CUSTOM_MOVE_ENTER (GADGET_ID_DRAWING_AREA_FIRST + 25)
534 #define GADGET_ID_CUSTOM_MOVE_LEAVE (GADGET_ID_DRAWING_AREA_FIRST + 26)
535 #define GADGET_ID_CUSTOM_CHANGE_TARGET (GADGET_ID_DRAWING_AREA_FIRST + 27)
536 #define GADGET_ID_CUSTOM_CHANGE_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 28)
537 #define GADGET_ID_CUSTOM_CHANGE_TRIGGER (GADGET_ID_DRAWING_AREA_FIRST + 29)
538 #define GADGET_ID_CUSTOM_CHANGE_ACTION (GADGET_ID_DRAWING_AREA_FIRST + 30)
539 #define GADGET_ID_GROUP_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 31)
540 #define GADGET_ID_RANDOM_BACKGROUND (GADGET_ID_DRAWING_AREA_FIRST + 32)
542 /* text input identifiers */
543 #define GADGET_ID_TEXT_INPUT_FIRST (GADGET_ID_DRAWING_AREA_FIRST + 33)
545 #define GADGET_ID_LEVEL_NAME (GADGET_ID_TEXT_INPUT_FIRST + 0)
546 #define GADGET_ID_LEVEL_AUTHOR (GADGET_ID_TEXT_INPUT_FIRST + 1)
547 #define GADGET_ID_ELEMENT_NAME (GADGET_ID_TEXT_INPUT_FIRST + 2)
549 /* text area identifiers */
550 #define GADGET_ID_TEXT_AREA_FIRST (GADGET_ID_TEXT_INPUT_FIRST + 3)
552 #define GADGET_ID_ENVELOPE_INFO (GADGET_ID_TEXT_AREA_FIRST + 0)
554 /* selectbox identifiers */
555 #define GADGET_ID_SELECTBOX_FIRST (GADGET_ID_TEXT_AREA_FIRST + 1)
557 #define GADGET_ID_TIME_OR_STEPS (GADGET_ID_SELECTBOX_FIRST + 0)
558 #define GADGET_ID_GAME_ENGINE_TYPE (GADGET_ID_SELECTBOX_FIRST + 1)
559 #define GADGET_ID_WIND_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 2)
560 #define GADGET_ID_PLAYER_SPEED (GADGET_ID_SELECTBOX_FIRST + 3)
561 #define GADGET_ID_CUSTOM_WALK_TO_ACTION (GADGET_ID_SELECTBOX_FIRST + 4)
562 #define GADGET_ID_CUSTOM_EXPLOSION_TYPE (GADGET_ID_SELECTBOX_FIRST + 5)
563 #define GADGET_ID_CUSTOM_DEADLINESS (GADGET_ID_SELECTBOX_FIRST + 6)
564 #define GADGET_ID_CUSTOM_MOVE_PATTERN (GADGET_ID_SELECTBOX_FIRST + 7)
565 #define GADGET_ID_CUSTOM_MOVE_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 8)
566 #define GADGET_ID_CUSTOM_MOVE_STEPSIZE (GADGET_ID_SELECTBOX_FIRST + 9)
567 #define GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE (GADGET_ID_SELECTBOX_FIRST + 10)
568 #define GADGET_ID_CUSTOM_SMASH_TARGETS (GADGET_ID_SELECTBOX_FIRST + 11)
569 #define GADGET_ID_CUSTOM_SLIPPERY_TYPE (GADGET_ID_SELECTBOX_FIRST + 12)
570 #define GADGET_ID_CUSTOM_ACCESS_TYPE (GADGET_ID_SELECTBOX_FIRST + 13)
571 #define GADGET_ID_CUSTOM_ACCESS_LAYER (GADGET_ID_SELECTBOX_FIRST + 14)
572 #define GADGET_ID_CUSTOM_ACCESS_PROTECTED (GADGET_ID_SELECTBOX_FIRST + 15)
573 #define GADGET_ID_CUSTOM_ACCESS_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 16)
574 #define GADGET_ID_CHANGE_TIME_UNITS (GADGET_ID_SELECTBOX_FIRST + 17)
575 #define GADGET_ID_CHANGE_DIRECT_ACTION (GADGET_ID_SELECTBOX_FIRST + 18)
576 #define GADGET_ID_CHANGE_OTHER_ACTION (GADGET_ID_SELECTBOX_FIRST + 19)
577 #define GADGET_ID_CHANGE_SIDE (GADGET_ID_SELECTBOX_FIRST + 20)
578 #define GADGET_ID_CHANGE_PLAYER (GADGET_ID_SELECTBOX_FIRST + 21)
579 #define GADGET_ID_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 22)
580 #define GADGET_ID_CHANGE_REPLACE_WHEN (GADGET_ID_SELECTBOX_FIRST + 23)
581 #define GADGET_ID_ACTION_TYPE (GADGET_ID_SELECTBOX_FIRST + 24)
582 #define GADGET_ID_ACTION_MODE (GADGET_ID_SELECTBOX_FIRST + 25)
583 #define GADGET_ID_ACTION_ARG (GADGET_ID_SELECTBOX_FIRST + 26)
584 #define GADGET_ID_SELECT_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 27)
585 #define GADGET_ID_GROUP_CHOICE_MODE (GADGET_ID_SELECTBOX_FIRST + 28)
587 /* textbutton identifiers */
588 #define GADGET_ID_TEXTBUTTON_FIRST (GADGET_ID_SELECTBOX_FIRST + 29)
590 #define GADGET_ID_LEVELINFO_LEVEL (GADGET_ID_TEXTBUTTON_FIRST + 0)
591 #define GADGET_ID_LEVELINFO_EDITOR (GADGET_ID_TEXTBUTTON_FIRST + 1)
592 #define GADGET_ID_PROPERTIES_INFO (GADGET_ID_TEXTBUTTON_FIRST + 2)
593 #define GADGET_ID_PROPERTIES_CONFIG (GADGET_ID_TEXTBUTTON_FIRST + 3)
594 #define GADGET_ID_PROPERTIES_CONFIG_1 (GADGET_ID_TEXTBUTTON_FIRST + 4)
595 #define GADGET_ID_PROPERTIES_CONFIG_2 (GADGET_ID_TEXTBUTTON_FIRST + 5)
596 #define GADGET_ID_PROPERTIES_CHANGE (GADGET_ID_TEXTBUTTON_FIRST + 6)
597 #define GADGET_ID_SAVE_AS_TEMPLATE_1 (GADGET_ID_TEXTBUTTON_FIRST + 7)
598 #define GADGET_ID_SAVE_AS_TEMPLATE_2 (GADGET_ID_TEXTBUTTON_FIRST + 8)
599 #define GADGET_ID_ADD_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 9)
600 #define GADGET_ID_DEL_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 10)
602 /* graphicbutton identifiers */
603 #define GADGET_ID_GRAPHICBUTTON_FIRST (GADGET_ID_TEXTBUTTON_FIRST + 11)
605 #define GADGET_ID_PREV_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 0)
606 #define GADGET_ID_NEXT_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 1)
607 #define GADGET_ID_COPY_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 2)
608 #define GADGET_ID_PASTE_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 3)
610 /* gadgets for scrolling of drawing area */
611 #define GADGET_ID_SCROLLING_FIRST (GADGET_ID_GRAPHICBUTTON_FIRST + 4)
613 #define GADGET_ID_SCROLL_UP (GADGET_ID_SCROLLING_FIRST + 0)
614 #define GADGET_ID_SCROLL_DOWN (GADGET_ID_SCROLLING_FIRST + 1)
615 #define GADGET_ID_SCROLL_LEFT (GADGET_ID_SCROLLING_FIRST + 2)
616 #define GADGET_ID_SCROLL_RIGHT (GADGET_ID_SCROLLING_FIRST + 3)
617 #define GADGET_ID_SCROLL_HORIZONTAL (GADGET_ID_SCROLLING_FIRST + 4)
618 #define GADGET_ID_SCROLL_VERTICAL (GADGET_ID_SCROLLING_FIRST + 5)
620 /* gadgets for scrolling element list */
621 #define GADGET_ID_SCROLLING_LIST_FIRST (GADGET_ID_SCROLLING_FIRST + 6)
623 #define GADGET_ID_SCROLL_LIST_UP (GADGET_ID_SCROLLING_LIST_FIRST + 0)
624 #define GADGET_ID_SCROLL_LIST_DOWN (GADGET_ID_SCROLLING_LIST_FIRST + 1)
625 #define GADGET_ID_SCROLL_LIST_VERTICAL (GADGET_ID_SCROLLING_LIST_FIRST + 2)
627 /* checkbuttons/radiobuttons for level/element properties */
628 #define GADGET_ID_CHECKBUTTON_FIRST (GADGET_ID_SCROLLING_LIST_FIRST + 3)
630 #define GADGET_ID_RANDOM_PERCENTAGE (GADGET_ID_CHECKBUTTON_FIRST + 0)
631 #define GADGET_ID_RANDOM_QUANTITY (GADGET_ID_CHECKBUTTON_FIRST + 1)
632 #define GADGET_ID_RANDOM_RESTRICTED (GADGET_ID_CHECKBUTTON_FIRST + 2)
633 #define GADGET_ID_STICK_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 3)
634 #define GADGET_ID_EM_SLIPPERY_GEMS (GADGET_ID_CHECKBUTTON_FIRST + 4)
635 #define GADGET_ID_EM_EXPLODES_BY_FIRE (GADGET_ID_CHECKBUTTON_FIRST + 5)
636 #define GADGET_ID_USE_SPRING_BUG (GADGET_ID_CHECKBUTTON_FIRST + 6)
637 #define GADGET_ID_USE_TIME_ORB_BUG (GADGET_ID_CHECKBUTTON_FIRST + 7)
638 #define GADGET_ID_RANDOM_BALL_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 8)
639 #define GADGET_ID_INITIAL_BALL_STATE (GADGET_ID_CHECKBUTTON_FIRST + 9)
640 #define GADGET_ID_GROW_INTO_DIGGABLE (GADGET_ID_CHECKBUTTON_FIRST + 10)
641 #define GADGET_ID_AUTO_EXIT_SOKOBAN (GADGET_ID_CHECKBUTTON_FIRST + 11)
642 #define GADGET_ID_CONTINUOUS_SNAPPING (GADGET_ID_CHECKBUTTON_FIRST + 12)
643 #define GADGET_ID_BLOCK_SNAP_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 13)
644 #define GADGET_ID_BLOCK_LAST_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 14)
645 #define GADGET_ID_SP_BLOCK_LAST_FIELD (GADGET_ID_CHECKBUTTON_FIRST + 15)
646 #define GADGET_ID_INSTANT_RELOCATION (GADGET_ID_CHECKBUTTON_FIRST + 16)
647 #define GADGET_ID_SHIFTED_RELOCATION (GADGET_ID_CHECKBUTTON_FIRST + 17)
648 #define GADGET_ID_LAZY_RELOCATION (GADGET_ID_CHECKBUTTON_FIRST + 18)
649 #define GADGET_ID_USE_START_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 19)
650 #define GADGET_ID_USE_ARTWORK_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 20)
651 #define GADGET_ID_USE_EXPLOSION_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 21)
652 #define GADGET_ID_INITIAL_GRAVITY (GADGET_ID_CHECKBUTTON_FIRST + 22)
653 #define GADGET_ID_USE_INITIAL_INVENTORY (GADGET_ID_CHECKBUTTON_FIRST + 23)
654 #define GADGET_ID_CAN_PASS_TO_WALKABLE (GADGET_ID_CHECKBUTTON_FIRST + 24)
655 #define GADGET_ID_CAN_FALL_INTO_ACID (GADGET_ID_CHECKBUTTON_FIRST + 25)
656 #define GADGET_ID_CAN_MOVE_INTO_ACID (GADGET_ID_CHECKBUTTON_FIRST + 26)
657 #define GADGET_ID_DONT_COLLIDE_WITH (GADGET_ID_CHECKBUTTON_FIRST + 27)
658 #define GADGET_ID_ENVELOPE_AUTOWRAP (GADGET_ID_CHECKBUTTON_FIRST + 28)
659 #define GADGET_ID_ENVELOPE_CENTERED (GADGET_ID_CHECKBUTTON_FIRST + 29)
660 #define GADGET_ID_CUSTOM_INDESTRUCTIBLE (GADGET_ID_CHECKBUTTON_FIRST + 30)
661 #define GADGET_ID_CUSTOM_CAN_EXPLODE (GADGET_ID_CHECKBUTTON_FIRST + 31)
662 #define GADGET_ID_CUSTOM_EXPLODE_FIRE (GADGET_ID_CHECKBUTTON_FIRST + 32)
663 #define GADGET_ID_CUSTOM_EXPLODE_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 33)
664 #define GADGET_ID_CUSTOM_EXPLODE_IMPACT (GADGET_ID_CHECKBUTTON_FIRST + 34)
665 #define GADGET_ID_CUSTOM_WALK_TO_OBJECT (GADGET_ID_CHECKBUTTON_FIRST + 35)
666 #define GADGET_ID_CUSTOM_DEADLY (GADGET_ID_CHECKBUTTON_FIRST + 36)
667 #define GADGET_ID_CUSTOM_CAN_MOVE (GADGET_ID_CHECKBUTTON_FIRST + 37)
668 #define GADGET_ID_CUSTOM_CAN_FALL (GADGET_ID_CHECKBUTTON_FIRST + 38)
669 #define GADGET_ID_CUSTOM_CAN_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 39)
670 #define GADGET_ID_CUSTOM_SLIPPERY (GADGET_ID_CHECKBUTTON_FIRST + 40)
671 #define GADGET_ID_CUSTOM_ACCESSIBLE (GADGET_ID_CHECKBUTTON_FIRST + 41)
672 #define GADGET_ID_CUSTOM_GRAV_REACHABLE (GADGET_ID_CHECKBUTTON_FIRST + 42)
673 #define GADGET_ID_CUSTOM_USE_LAST_VALUE (GADGET_ID_CHECKBUTTON_FIRST + 43)
674 #define GADGET_ID_CUSTOM_USE_GRAPHIC (GADGET_ID_CHECKBUTTON_FIRST + 44)
675 #define GADGET_ID_CUSTOM_USE_TEMPLATE_1 (GADGET_ID_CHECKBUTTON_FIRST + 45)
676 #define GADGET_ID_CUSTOM_USE_TEMPLATE_2 (GADGET_ID_CHECKBUTTON_FIRST + 46)
677 #define GADGET_ID_CUSTOM_USE_TEMPLATE_3 (GADGET_ID_CHECKBUTTON_FIRST + 47)
678 #define GADGET_ID_CUSTOM_CAN_CHANGE (GADGET_ID_CHECKBUTTON_FIRST + 48)
679 #define GADGET_ID_CHANGE_USE_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 49)
680 #define GADGET_ID_CHANGE_USE_EXPLOSION (GADGET_ID_CHECKBUTTON_FIRST + 50)
681 #define GADGET_ID_CHANGE_ONLY_COMPLETE (GADGET_ID_CHECKBUTTON_FIRST + 51)
682 #define GADGET_ID_CHANGE_USE_RANDOM (GADGET_ID_CHECKBUTTON_FIRST + 52)
683 #define GADGET_ID_CHANGE_HAS_ACTION (GADGET_ID_CHECKBUTTON_FIRST + 53)
684 #define GADGET_ID_CHANGE_DELAY (GADGET_ID_CHECKBUTTON_FIRST + 54)
685 #define GADGET_ID_CHANGE_BY_DIRECT_ACT (GADGET_ID_CHECKBUTTON_FIRST + 55)
686 #define GADGET_ID_CHANGE_BY_OTHER_ACT (GADGET_ID_CHECKBUTTON_FIRST + 56)
688 /* gadgets for buttons in element list */
689 #define GADGET_ID_ELEMENTLIST_FIRST (GADGET_ID_CHECKBUTTON_FIRST + 57)
690 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
691 ED_NUM_ELEMENTLIST_BUTTONS - 1)
693 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
695 /* radio button numbers */
696 #define RADIO_NR_NONE 0
697 #define RADIO_NR_DRAWING_TOOLBOX 1
698 #define RADIO_NR_RANDOM_ELEMENTS 2
700 /* values for counter gadgets */
701 #define ED_COUNTER_ID_SELECT_LEVEL 0
702 #define ED_COUNTER_ID_LEVEL_XSIZE 1
703 #define ED_COUNTER_ID_LEVEL_YSIZE 2
704 #define ED_COUNTER_ID_LEVEL_GEMSLIMIT 3
705 #define ED_COUNTER_ID_LEVEL_TIMELIMIT 4
706 #define ED_COUNTER_ID_LEVEL_TIMESCORE 5
707 #define ED_COUNTER_ID_LEVEL_RANDOM_SEED 6
708 #define ED_COUNTER_ID_LEVEL_RANDOM 7
709 #define ED_COUNTER_ID_ELEMENT_VALUE1 8
710 #define ED_COUNTER_ID_ELEMENT_VALUE2 9
711 #define ED_COUNTER_ID_ELEMENT_VALUE3 10
712 #define ED_COUNTER_ID_ELEMENT_VALUE4 11
713 #define ED_COUNTER_ID_YAMYAM_CONTENT 12
714 #define ED_COUNTER_ID_BALL_CONTENT 13
715 #define ED_COUNTER_ID_ANDROID_CONTENT 14
716 #define ED_COUNTER_ID_ENVELOPE_XSIZE 15
717 #define ED_COUNTER_ID_ENVELOPE_YSIZE 16
718 #define ED_COUNTER_ID_INVENTORY_SIZE 17
719 #define ED_COUNTER_ID_CUSTOM_SCORE 18
720 #define ED_COUNTER_ID_CUSTOM_GEMCOUNT 19
721 #define ED_COUNTER_ID_CUSTOM_VALUE_FIX 20
722 #define ED_COUNTER_ID_CUSTOM_VALUE_RND 21
723 #define ED_COUNTER_ID_PUSH_DELAY_FIX 22
724 #define ED_COUNTER_ID_PUSH_DELAY_RND 23
725 #define ED_COUNTER_ID_DROP_DELAY_FIX 24
726 #define ED_COUNTER_ID_DROP_DELAY_RND 25
727 #define ED_COUNTER_ID_MOVE_DELAY_FIX 26
728 #define ED_COUNTER_ID_MOVE_DELAY_RND 27
729 #define ED_COUNTER_ID_EXPLOSION_DELAY 28
730 #define ED_COUNTER_ID_IGNITION_DELAY 29
731 #define ED_COUNTER_ID_GROUP_CONTENT 30
732 #define ED_COUNTER_ID_CHANGE_DELAY_FIX 31
733 #define ED_COUNTER_ID_CHANGE_DELAY_RND 32
734 #define ED_COUNTER_ID_CHANGE_CONT_RND 33
736 #define ED_NUM_COUNTERBUTTONS 34
738 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
739 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
740 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
741 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
743 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
744 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
745 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
746 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
747 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
748 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
750 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
751 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
753 /* values for scrollbutton gadgets */
754 #define ED_SCROLLBUTTON_ID_AREA_UP 0
755 #define ED_SCROLLBUTTON_ID_AREA_DOWN 1
756 #define ED_SCROLLBUTTON_ID_AREA_LEFT 2
757 #define ED_SCROLLBUTTON_ID_AREA_RIGHT 3
758 #define ED_SCROLLBUTTON_ID_LIST_UP 4
759 #define ED_SCROLLBUTTON_ID_LIST_DOWN 5
761 #define ED_NUM_SCROLLBUTTONS 6
763 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
764 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
766 /* values for scrollbar gadgets */
767 #define ED_SCROLLBAR_ID_AREA_HORIZONTAL 0
768 #define ED_SCROLLBAR_ID_AREA_VERTICAL 1
769 #define ED_SCROLLBAR_ID_LIST_VERTICAL 2
771 #define ED_NUM_SCROLLBARS 3
773 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
774 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
776 /* values for text input gadgets */
777 #define ED_TEXTINPUT_ID_LEVEL_NAME 0
778 #define ED_TEXTINPUT_ID_LEVEL_AUTHOR 1
779 #define ED_TEXTINPUT_ID_ELEMENT_NAME 2
781 #define ED_NUM_TEXTINPUT 3
783 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
784 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
786 /* values for text area gadgets */
787 #define ED_TEXTAREA_ID_ENVELOPE_INFO 0
789 #define ED_NUM_TEXTAREAS 1
791 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
792 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
794 /* values for selectbox gadgets */
795 #define ED_SELECTBOX_ID_TIME_OR_STEPS 0
796 #define ED_SELECTBOX_ID_GAME_ENGINE_TYPE 1
797 #define ED_SELECTBOX_ID_WIND_DIRECTION 2
798 #define ED_SELECTBOX_ID_PLAYER_SPEED 3
799 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE 4
800 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER 5
801 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED 6
802 #define ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION 7
803 #define ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION 8
804 #define ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN 9
805 #define ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION 10
806 #define ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE 11
807 #define ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE 12
808 #define ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS 13
809 #define ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE 14
810 #define ED_SELECTBOX_ID_CUSTOM_DEADLINESS 15
811 #define ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE 16
812 #define ED_SELECTBOX_ID_CHANGE_TIME_UNITS 17
813 #define ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION 18
814 #define ED_SELECTBOX_ID_CHANGE_OTHER_ACTION 19
815 #define ED_SELECTBOX_ID_CHANGE_SIDE 20
816 #define ED_SELECTBOX_ID_CHANGE_PLAYER 21
817 #define ED_SELECTBOX_ID_CHANGE_PAGE 22
818 #define ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN 23
819 #define ED_SELECTBOX_ID_ACTION_TYPE 24
820 #define ED_SELECTBOX_ID_ACTION_MODE 25
821 #define ED_SELECTBOX_ID_ACTION_ARG 26
822 #define ED_SELECTBOX_ID_SELECT_CHANGE_PAGE 27
823 #define ED_SELECTBOX_ID_GROUP_CHOICE_MODE 28
825 #define ED_NUM_SELECTBOX 29
827 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
828 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_WIND_DIRECTION
830 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
831 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
832 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
833 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
834 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
835 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
837 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
838 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
840 /* values for textbutton gadgets */
841 #define ED_TEXTBUTTON_ID_LEVELINFO_LEVEL 0
842 #define ED_TEXTBUTTON_ID_LEVELINFO_EDITOR 1
843 #define ED_TEXTBUTTON_ID_PROPERTIES_INFO 2
844 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG 3
845 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1 4
846 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2 5
847 #define ED_TEXTBUTTON_ID_PROPERTIES_CHANGE 6
848 #define ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2 7
849 #define ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 8
850 #define ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE 9
851 #define ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE 10
853 #define ED_NUM_TEXTBUTTONS 11
855 #define ED_TAB_BUTTON_ID_LEVELINFO_FIRST ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
856 #define ED_TAB_BUTTON_ID_LEVELINFO_LAST ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
858 #define ED_TAB_BUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
859 #define ED_TAB_BUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
861 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
862 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
864 /* values for graphicbutton gadgets */
865 #define ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE 0
866 #define ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE 1
867 #define ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE 2
868 #define ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE 3
870 #define ED_NUM_GRAPHICBUTTONS 4
872 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
873 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
875 /* values for checkbutton gadgets */
876 #define ED_CHECKBUTTON_ID_RANDOM_RESTRICTED 0
877 #define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3 1
878 #define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2 2
879 #define ED_CHECKBUTTON_ID_STICK_ELEMENT 3
880 #define ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS 4
881 #define ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE 5
882 #define ED_CHECKBUTTON_ID_USE_SPRING_BUG 6
883 #define ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG 7
884 #define ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT 8
885 #define ED_CHECKBUTTON_ID_INITIAL_BALL_STATE 9
886 #define ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE 10
887 #define ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN 11
888 #define ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING 12
889 #define ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD 13
890 #define ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD 14
891 #define ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD 15
892 #define ED_CHECKBUTTON_ID_INSTANT_RELOCATION 16
893 #define ED_CHECKBUTTON_ID_SHIFTED_RELOCATION 17
894 #define ED_CHECKBUTTON_ID_LAZY_RELOCATION 18
895 #define ED_CHECKBUTTON_ID_USE_START_ELEMENT 19
896 #define ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT 20
897 #define ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT 21
898 #define ED_CHECKBUTTON_ID_INITIAL_GRAVITY 22
899 #define ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY 23
900 #define ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE 24
901 #define ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID 25
902 #define ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID 26
903 #define ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH 27
904 #define ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP 28
905 #define ED_CHECKBUTTON_ID_ENVELOPE_CENTERED 29
906 #define ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC 30
907 #define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 31
908 #define ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE 32
909 #define ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE 33
910 #define ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE 34
911 #define ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT 35
912 #define ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE 36
913 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE 37
914 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL 38
915 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH 39
916 #define ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY 40
917 #define ED_CHECKBUTTON_ID_CUSTOM_DEADLY 41
918 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE 42
919 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE 43
920 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH 44
921 #define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT 45
922 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE 46
923 #define ED_CHECKBUTTON_ID_CHANGE_DELAY 47
924 #define ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT 48
925 #define ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT 49
926 #define ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION 50
927 #define ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT 51
928 #define ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE 52
929 #define ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM 53
930 #define ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION 54
932 #define ED_NUM_CHECKBUTTONS 55
934 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
935 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2
937 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
938 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
939 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
940 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
941 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
942 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
944 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
945 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
947 /* values for radiobutton gadgets */
948 #define ED_RADIOBUTTON_ID_PERCENTAGE 0
949 #define ED_RADIOBUTTON_ID_QUANTITY 1
951 #define ED_NUM_RADIOBUTTONS 2
953 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
954 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
956 /* values for drawing area gadgets */
957 #define ED_DRAWING_ID_DRAWING_LEVEL 0
958 #define ED_DRAWING_ID_YAMYAM_CONTENT_0 1
959 #define ED_DRAWING_ID_YAMYAM_CONTENT_1 2
960 #define ED_DRAWING_ID_YAMYAM_CONTENT_2 3
961 #define ED_DRAWING_ID_YAMYAM_CONTENT_3 4
962 #define ED_DRAWING_ID_YAMYAM_CONTENT_4 5
963 #define ED_DRAWING_ID_YAMYAM_CONTENT_5 6
964 #define ED_DRAWING_ID_YAMYAM_CONTENT_6 7
965 #define ED_DRAWING_ID_YAMYAM_CONTENT_7 8
966 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 9
967 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_1 10
968 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_2 11
969 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_3 12
970 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_4 13
971 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_5 14
972 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_6 15
973 #define ED_DRAWING_ID_MAGIC_BALL_CONTENT_7 16
974 #define ED_DRAWING_ID_ANDROID_CONTENT 17
975 #define ED_DRAWING_ID_AMOEBA_CONTENT 18
976 #define ED_DRAWING_ID_START_ELEMENT 19
977 #define ED_DRAWING_ID_ARTWORK_ELEMENT 20
978 #define ED_DRAWING_ID_EXPLOSION_ELEMENT 21
979 #define ED_DRAWING_ID_INVENTORY_CONTENT 22
980 #define ED_DRAWING_ID_CUSTOM_GRAPHIC 23
981 #define ED_DRAWING_ID_CUSTOM_CONTENT 24
982 #define ED_DRAWING_ID_CUSTOM_MOVE_ENTER 25
983 #define ED_DRAWING_ID_CUSTOM_MOVE_LEAVE 26
984 #define ED_DRAWING_ID_CUSTOM_CHANGE_TARGET 27
985 #define ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT 28
986 #define ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER 29
987 #define ED_DRAWING_ID_CUSTOM_CHANGE_ACTION 30
988 #define ED_DRAWING_ID_GROUP_CONTENT 31
989 #define ED_DRAWING_ID_RANDOM_BACKGROUND 32
991 #define ED_NUM_DRAWING_AREAS 33
993 #define ED_DRAWING_ID_EDITOR_FIRST ED_DRAWING_ID_RANDOM_BACKGROUND
994 #define ED_DRAWING_ID_EDITOR_LAST ED_DRAWING_ID_RANDOM_BACKGROUND
998 -----------------------------------------------------------------------------
999 some internally used definitions
1000 -----------------------------------------------------------------------------
1003 /* values for CopyLevelToUndoBuffer() */
1004 #define UNDO_IMMEDIATE 0
1005 #define UNDO_ACCUMULATE 1
1007 /* values for scrollbars */
1008 #define ED_SCROLL_NO 0
1009 #define ED_SCROLL_LEFT 1
1010 #define ED_SCROLL_RIGHT 2
1011 #define ED_SCROLL_UP 4
1012 #define ED_SCROLL_DOWN 8
1014 /* screens in the level editor */
1015 #define ED_MODE_DRAWING 0
1016 #define ED_MODE_INFO 1
1017 #define ED_MODE_PROPERTIES 2
1018 #define ED_MODE_PALETTE 3
1020 /* sub-screens in the global settings section */
1021 #define ED_MODE_LEVELINFO_LEVEL ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
1022 #define ED_MODE_LEVELINFO_EDITOR ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
1024 /* sub-screens in the element properties section */
1025 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
1026 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
1027 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
1028 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
1029 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
1031 /* how many steps can be cancelled */
1032 #define NUM_UNDO_STEPS (64 + 1)
1034 /* values for elements with score for certain actions */
1036 #define MAX_SCORE 999
1038 /* values for elements with count for collecting */
1039 #define MIN_COLLECT_COUNT 0
1040 #define MAX_COLLECT_COUNT 999
1042 /* values for random placement */
1043 #define RANDOM_USE_PERCENTAGE 0
1044 #define RANDOM_USE_QUANTITY 1
1046 /* default value for element tile size in drawing area */
1047 #define DEFAULT_EDITOR_TILESIZE MINI_TILESIZE
1051 -----------------------------------------------------------------------------
1052 some internally used data structure definitions
1053 -----------------------------------------------------------------------------
1060 struct XYTileSize *pos;
1064 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
1066 /* note: some additional characters are already reserved for "cheat mode"
1067 shortcuts (":XYZ" style) -- for details, see "events.c" */
1069 /* ---------- toolbox control buttons ------------------------------------ */
1072 IMG_GFX_EDITOR_BUTTON_DRAW_SINGLE, GADGET_ID_SINGLE_ITEMS,
1073 &editor.button.draw_single, GD_TYPE_RADIO_BUTTON,
1074 "draw single items", 's'
1077 IMG_GFX_EDITOR_BUTTON_DRAW_CONNECTED, GADGET_ID_CONNECTED_ITEMS,
1078 &editor.button.draw_connected, GD_TYPE_RADIO_BUTTON,
1079 "draw connected items", 'd'
1082 IMG_GFX_EDITOR_BUTTON_DRAW_LINE, GADGET_ID_LINE,
1083 &editor.button.draw_line, GD_TYPE_RADIO_BUTTON,
1087 IMG_GFX_EDITOR_BUTTON_DRAW_ARC, GADGET_ID_ARC,
1088 &editor.button.draw_arc, GD_TYPE_RADIO_BUTTON,
1092 IMG_GFX_EDITOR_BUTTON_DRAW_RECTANGLE, GADGET_ID_RECTANGLE,
1093 &editor.button.draw_rectangle, GD_TYPE_RADIO_BUTTON,
1094 "draw outline rectangles", 'r'
1097 IMG_GFX_EDITOR_BUTTON_DRAW_FILLED_BOX, GADGET_ID_FILLED_BOX,
1098 &editor.button.draw_filled_box, GD_TYPE_RADIO_BUTTON,
1099 "draw filled rectangles", 'R'
1102 IMG_GFX_EDITOR_BUTTON_ROTATE_UP, GADGET_ID_WRAP_UP,
1103 &editor.button.rotate_up, GD_TYPE_NORMAL_BUTTON,
1104 "wrap (rotate) level up", 0
1107 IMG_GFX_EDITOR_BUTTON_DRAW_TEXT, GADGET_ID_TEXT,
1108 &editor.button.draw_text, GD_TYPE_RADIO_BUTTON,
1109 "enter text elements", 't'
1112 IMG_GFX_EDITOR_BUTTON_FLOOD_FILL, GADGET_ID_FLOOD_FILL,
1113 &editor.button.flood_fill, GD_TYPE_RADIO_BUTTON,
1117 IMG_GFX_EDITOR_BUTTON_ROTATE_LEFT, GADGET_ID_WRAP_LEFT,
1118 &editor.button.rotate_left, GD_TYPE_NORMAL_BUTTON,
1119 "wrap (rotate) level left", 0
1122 IMG_GFX_EDITOR_BUTTON_ZOOM_LEVEL, GADGET_ID_ZOOM,
1123 &editor.button.zoom_level, GD_TYPE_NORMAL_BUTTON,
1124 "zoom level tile size", '+'
1127 IMG_GFX_EDITOR_BUTTON_ROTATE_RIGHT, GADGET_ID_WRAP_RIGHT,
1128 &editor.button.rotate_right, GD_TYPE_NORMAL_BUTTON,
1129 "wrap (rotate) level right", 0
1132 IMG_GFX_EDITOR_BUTTON_DRAW_RANDOM, GADGET_ID_RANDOM_PLACEMENT,
1133 &editor.button.draw_random, GD_TYPE_NORMAL_BUTTON,
1134 "random element placement", 0
1137 IMG_GFX_EDITOR_BUTTON_GRAB_BRUSH, GADGET_ID_GRAB_BRUSH,
1138 &editor.button.grab_brush, GD_TYPE_RADIO_BUTTON,
1142 IMG_GFX_EDITOR_BUTTON_ROTATE_DOWN, GADGET_ID_WRAP_DOWN,
1143 &editor.button.rotate_down, GD_TYPE_NORMAL_BUTTON,
1144 "wrap (rotate) level down", 0
1147 IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT, GADGET_ID_PICK_ELEMENT,
1148 &editor.button.pick_element, GD_TYPE_RADIO_BUTTON,
1149 "pick drawing element", ','
1152 /* ---------- level control buttons -------------------------------------- */
1155 IMG_GFX_EDITOR_BUTTON_UNDO, GADGET_ID_UNDO,
1156 &editor.button.undo, GD_TYPE_NORMAL_BUTTON,
1157 "undo/redo last operation", 'u'
1160 IMG_GFX_EDITOR_BUTTON_CONF, GADGET_ID_INFO,
1161 &editor.button.conf, GD_TYPE_NORMAL_BUTTON,
1162 "properties of level", 'I'
1165 IMG_GFX_EDITOR_BUTTON_SAVE, GADGET_ID_SAVE,
1166 &editor.button.save, GD_TYPE_NORMAL_BUTTON,
1170 IMG_GFX_EDITOR_BUTTON_CLEAR, GADGET_ID_CLEAR,
1171 &editor.button.clear, GD_TYPE_NORMAL_BUTTON,
1175 IMG_GFX_EDITOR_BUTTON_TEST, GADGET_ID_TEST,
1176 &editor.button.test, GD_TYPE_NORMAL_BUTTON,
1180 IMG_GFX_EDITOR_BUTTON_EXIT, GADGET_ID_EXIT,
1181 &editor.button.exit, GD_TYPE_NORMAL_BUTTON,
1182 "exit level editor", 'E'
1185 /* ---------- CE and GE control buttons ---------------------------------- */
1188 IMG_GFX_EDITOR_BUTTON_CE_COPY_FROM, GADGET_ID_CUSTOM_COPY_FROM,
1189 &editor.button.ce_copy_from, GD_TYPE_RADIO_BUTTON,
1190 "copy settings from other element", 0
1193 IMG_GFX_EDITOR_BUTTON_CE_COPY_TO, GADGET_ID_CUSTOM_COPY_TO,
1194 &editor.button.ce_copy_to, GD_TYPE_RADIO_BUTTON,
1195 "copy settings to other element", 0
1198 IMG_GFX_EDITOR_BUTTON_CE_SWAP, GADGET_ID_CUSTOM_EXCHANGE,
1199 &editor.button.ce_swap, GD_TYPE_RADIO_BUTTON,
1200 "exchange element with other element", 0
1203 IMG_GFX_EDITOR_BUTTON_CE_COPY, GADGET_ID_CUSTOM_COPY,
1204 &editor.button.ce_copy, GD_TYPE_NORMAL_BUTTON,
1205 "copy settings from this element", 0
1208 IMG_GFX_EDITOR_BUTTON_CE_PASTE, GADGET_ID_CUSTOM_PASTE,
1209 &editor.button.ce_paste, GD_TYPE_NORMAL_BUTTON,
1210 "paste settings to this element", 0
1213 /* ---------- palette control buttons ------------------------------------ */
1216 IMG_GFX_EDITOR_BUTTON_PROPERTIES, GADGET_ID_PROPERTIES,
1217 &editor.button.properties, GD_TYPE_NORMAL_BUTTON,
1218 "properties of drawing element", 'p'
1221 IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT, GADGET_ID_ELEMENT_LEFT,
1222 &editor.button.element_left, GD_TYPE_NORMAL_BUTTON,
1223 "properties of drawing element 1", '1'
1226 IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE, GADGET_ID_ELEMENT_MIDDLE,
1227 &editor.button.element_middle, GD_TYPE_NORMAL_BUTTON,
1228 "properties of drawing element 2", '2'
1231 IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT, GADGET_ID_ELEMENT_RIGHT,
1232 &editor.button.element_right, GD_TYPE_NORMAL_BUTTON,
1233 "properties of drawing element 3", '3'
1236 IMG_GFX_EDITOR_BUTTON_PALETTE, GADGET_ID_PALETTE,
1237 &editor.button.palette, GD_TYPE_NORMAL_BUTTON,
1238 "show list of elements", 'e'
1242 static int random_placement_value = 10;
1243 static int random_placement_method = RANDOM_USE_QUANTITY;
1244 static int random_placement_background_element = EL_SAND;
1245 static boolean random_placement_background_restricted = FALSE;
1246 static boolean stick_element_properties_window = FALSE;
1247 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1248 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1249 static struct ElementChangeInfo custom_element_change;
1250 static struct ElementGroupInfo group_element_info;
1251 static struct ElementInfo custom_element;
1256 int min_value, max_value;
1257 int gadget_id_down, gadget_id_up;
1259 int gadget_id_align;
1261 char *text_above, *text_left, *text_right;
1262 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1264 /* ---------- current level number --------------------------------------- */
1267 -1, -1, /* these values are not constant, but can change at runtime */
1269 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1270 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1275 /* ---------- level and editor settings ---------------------------------- */
1278 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1279 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1280 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1281 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1283 "playfield size:", NULL, "width",
1286 -1, ED_LEVEL_SETTINGS_YPOS(4),
1287 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1288 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1289 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1291 NULL, " ", "height",
1294 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1296 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1297 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1299 NULL, "number of gems to collect:", NULL
1302 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
1304 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1305 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1307 "time or step limit to solve level:", NULL, NULL
1310 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(9),
1312 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1313 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1314 &level.score[SC_TIME_BONUS],
1315 "score for each second/step left:", NULL, NULL
1318 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
1320 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1321 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1323 NULL, "random seed:", "(0 => random)"
1326 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1328 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1329 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1330 &random_placement_value,
1331 "random element placement:", NULL, "in"
1334 /* ---------- element settings: configure (various elements) ------------- */
1337 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1338 MIN_SCORE, MAX_SCORE,
1339 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1340 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1341 NULL, /* will be set when used */
1345 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1346 MIN_SCORE, MAX_SCORE,
1347 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1348 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1349 NULL, /* will be set when used */
1353 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1354 MIN_SCORE, MAX_SCORE,
1355 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1356 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1357 NULL, /* will be set when used */
1361 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1362 MIN_SCORE, MAX_SCORE,
1363 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1364 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1365 NULL, /* will be set when used */
1369 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1370 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1371 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1372 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1373 &level.num_yamyam_contents,
1374 NULL, NULL, "number of content areas"
1377 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1378 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1379 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1380 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1381 &level.num_ball_contents,
1382 NULL, NULL, "number of content areas"
1385 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1386 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1387 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1388 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1389 &level.num_android_clone_elements,
1390 NULL, NULL, "number of clonable elements"
1393 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1394 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1395 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1396 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1397 NULL, /* will be set when used */
1398 NULL, NULL, "width",
1401 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1402 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1403 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1404 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1405 NULL, /* will be set when used */
1406 NULL, " ", "height",
1409 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1410 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1411 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1412 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1413 &level.initial_inventory_size[0],
1414 NULL, NULL, "number of inventory elements"
1417 /* ---------- element settings: configure 1 (custom elements) ------------ */
1420 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1421 MIN_SCORE, MAX_SCORE,
1422 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1423 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1424 &custom_element.collect_score_initial,
1425 NULL, "CE score", " "
1428 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1429 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1430 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1431 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1432 &custom_element.collect_count_initial,
1433 NULL, "CE count", NULL
1436 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1438 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1439 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1440 &custom_element.ce_value_fixed_initial,
1441 NULL, "CE value", NULL
1444 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1446 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1447 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1448 &custom_element.ce_value_random_initial,
1449 NULL, "+random", NULL
1452 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1454 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1455 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1456 &custom_element.push_delay_fixed,
1457 NULL, "push delay", NULL
1460 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1462 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1463 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1464 &custom_element.push_delay_random,
1465 NULL, "+random", NULL
1468 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1470 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1471 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1472 &custom_element.drop_delay_fixed,
1473 NULL, "drop delay", NULL
1476 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1478 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1479 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1480 &custom_element.drop_delay_random,
1481 NULL, "+random", NULL
1484 /* ---------- element settings: configure 2 (custom elements) ------------ */
1487 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1489 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1490 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1491 &custom_element.move_delay_fixed,
1492 NULL, "move delay", NULL
1495 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1497 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1498 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1499 &custom_element.move_delay_random,
1500 NULL, "+random", NULL
1503 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
1505 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1506 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1507 &custom_element.explosion_delay,
1508 NULL, "explosion delay", NULL
1511 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1513 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1514 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1515 &custom_element.ignition_delay,
1516 NULL, "ignition delay", "(by fire)"
1519 /* ---------- element settings: configure (group elements) --------------- */
1522 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1523 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1524 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1525 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1526 &group_element_info.num_elements,
1527 NULL, NULL, "number of elements in group"
1530 /* ---------- element settings: advanced (custom elements) --------------- */
1533 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1535 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1536 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1537 &custom_element_change.delay_fixed,
1538 NULL, "CE delay", NULL,
1541 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1543 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1544 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1545 &custom_element_change.delay_random,
1546 NULL, "+random", NULL
1549 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1551 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1552 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1553 &custom_element_change.random_percentage,
1554 NULL, "use random replace:", "%"
1564 char *text_above, *infotext;
1565 } textinput_info[ED_NUM_TEXTINPUT] =
1568 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1569 GADGET_ID_LEVEL_NAME,
1575 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1576 GADGET_ID_LEVEL_AUTHOR,
1577 MAX_LEVEL_AUTHOR_LEN,
1582 -1, -1, /* these values are not constant, but can change at runtime */
1583 GADGET_ID_ELEMENT_NAME,
1584 MAX_ELEMENT_NAME_LEN - 2, /* currently 2 chars less editable */
1585 custom_element.description,
1586 NULL, "Element name"
1596 char *text_above, *infotext;
1597 } textarea_info[ED_NUM_TEXTAREAS] =
1600 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1601 GADGET_ID_ENVELOPE_INFO,
1602 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1604 "Envelope Content:", "Envelope Content"
1608 static struct ValueTextInfo options_time_or_steps[] =
1616 static struct ValueTextInfo options_game_engine_type[] =
1618 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1619 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1620 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1625 static struct ValueTextInfo options_wind_direction[] =
1627 { MV_START_NONE, "none" },
1628 { MV_START_LEFT, "left" },
1629 { MV_START_RIGHT, "right" },
1630 { MV_START_UP, "up" },
1631 { MV_START_DOWN, "down" },
1636 static struct ValueTextInfo options_player_speed[] =
1643 { 16, "very fast" },
1644 { 32, "ultrafast" },
1649 static struct ValueTextInfo options_access_type[] =
1651 { EP_WALKABLE, "walkable" },
1652 { EP_PASSABLE, "passable" },
1657 static struct ValueTextInfo options_access_layer[] =
1659 { EP_ACCESSIBLE_OVER, "over" },
1660 { EP_ACCESSIBLE_INSIDE, "inside" },
1661 { EP_ACCESSIBLE_UNDER, "under" },
1666 static struct ValueTextInfo options_access_protected[] =
1668 { 0, "unprotected" },
1674 static struct ValueTextInfo options_access_direction[] =
1676 { MV_NO_DIRECTION, "no direction" },
1677 { MV_LEFT, "left" },
1678 { MV_RIGHT, "right" },
1680 { MV_DOWN, "down" },
1681 { MV_LEFT | MV_UP, "left + up" },
1682 { MV_LEFT | MV_DOWN, "left + down" },
1683 { MV_RIGHT | MV_UP, "right + up" },
1684 { MV_RIGHT | MV_DOWN, "right + down" },
1685 { MV_HORIZONTAL, "horizontal" },
1686 { MV_VERTICAL, "vertical" },
1687 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1688 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1689 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1690 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1691 { MV_ALL_DIRECTIONS, "all directions" },
1696 static struct ValueTextInfo options_walk_to_action[] =
1698 { EP_DIGGABLE, "diggable" },
1699 { EP_COLLECTIBLE_ONLY, "collectible" },
1700 { EP_DROPPABLE, "collectible & droppable" },
1701 { EP_THROWABLE, "collectible & throwable" },
1702 { EP_PUSHABLE, "pushable" },
1707 static struct ValueTextInfo options_move_pattern[] =
1709 { MV_LEFT, "left" },
1710 { MV_RIGHT, "right" },
1712 { MV_DOWN, "down" },
1713 { MV_HORIZONTAL, "horizontal" },
1714 { MV_VERTICAL, "vertical" },
1715 { MV_ALL_DIRECTIONS, "all directions" },
1716 { MV_WIND_DIRECTION, "wind direction" },
1717 { MV_TOWARDS_PLAYER, "towards player" },
1718 { MV_AWAY_FROM_PLAYER, "away from player" },
1719 { MV_ALONG_LEFT_SIDE, "along left side" },
1720 { MV_ALONG_RIGHT_SIDE, "along right side" },
1721 { MV_TURNING_LEFT, "turning left" },
1722 { MV_TURNING_RIGHT, "turning right" },
1723 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1724 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1725 { MV_TURNING_RANDOM, "turning random" },
1726 { MV_MAZE_RUNNER, "maze runner style" },
1727 { MV_MAZE_HUNTER, "maze hunter style" },
1728 { MV_WHEN_PUSHED, "when pushed" },
1729 { MV_WHEN_DROPPED, "when dropped/thrown" },
1734 static struct ValueTextInfo options_move_direction[] =
1736 { MV_START_AUTOMATIC, "automatic" },
1737 { MV_START_LEFT, "left" },
1738 { MV_START_RIGHT, "right" },
1739 { MV_START_UP, "up" },
1740 { MV_START_DOWN, "down" },
1741 { MV_START_RANDOM, "random" },
1742 { MV_START_PREVIOUS, "previous" },
1747 static struct ValueTextInfo options_move_stepsize[] =
1749 { 0, "not moving" },
1754 { 16, "very fast" },
1755 { 32, "even faster" },
1760 static struct ValueTextInfo options_move_leave_type[] =
1762 { LEAVE_TYPE_UNLIMITED, "leave behind" },
1763 { LEAVE_TYPE_LIMITED, "change it to" },
1768 static struct ValueTextInfo options_smash_targets[] =
1770 { EP_CAN_SMASH_PLAYER, "player" },
1772 { EP_CAN_SMASH_ENEMIES, "enemies" },
1774 { EP_CAN_SMASH_EVERYTHING, "everything" },
1779 static struct ValueTextInfo options_slippery_type[] =
1781 { SLIPPERY_ANY_RANDOM, "random" },
1782 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
1783 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
1784 { SLIPPERY_ONLY_LEFT, "only left" },
1785 { SLIPPERY_ONLY_RIGHT, "only right" },
1790 static struct ValueTextInfo options_deadliness[] =
1792 { EP_DONT_RUN_INTO, "running into" },
1793 { EP_DONT_COLLIDE_WITH, "colliding with" },
1794 { EP_DONT_GET_HIT_BY, "getting hit by" },
1795 { EP_DONT_TOUCH, "touching" },
1800 static struct ValueTextInfo options_explosion_type[] =
1802 { EXPLODES_3X3, "3x3" },
1803 { EXPLODES_CROSS, "3+3" },
1804 { EXPLODES_1X1, "1x1" },
1809 static struct ValueTextInfo options_time_units[] =
1812 { FRAMES_PER_SECOND, "seconds" },
1817 static struct ValueTextInfo options_change_direct_action[] =
1819 { CE_TOUCHED_BY_PLAYER, "touched by player" },
1820 { CE_PRESSED_BY_PLAYER, "pressed by player" },
1821 { CE_SWITCHED_BY_PLAYER, "switched by player" },
1822 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
1823 { CE_PUSHED_BY_PLAYER, "pushed by player" },
1824 { CE_ENTERED_BY_PLAYER, "entered by player" },
1825 { CE_LEFT_BY_PLAYER, "left by player" },
1826 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
1827 { CE_SWITCHED, "switched" },
1828 { CE_HITTING_SOMETHING, "hitting something" },
1829 { CE_HIT_BY_SOMETHING, "hit by something" },
1831 { CE_BLOCKED, "blocked" },
1833 { CE_IMPACT, "impact (on something)" },
1834 { CE_SMASHED, "smashed (from above)" },
1836 { CE_VALUE_CHANGES, "CE value changes" },
1837 { CE_SCORE_CHANGES, "CE score changes" },
1839 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
1840 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
1845 static struct ValueTextInfo options_change_other_action[] =
1847 { CE_PLAYER_TOUCHES_X, "player touches" },
1848 { CE_PLAYER_PRESSES_X, "player presses" },
1849 { CE_PLAYER_SWITCHES_X, "player switches" },
1850 { CE_PLAYER_SNAPS_X, "player snaps" },
1851 { CE_PLAYER_PUSHES_X, "player pushes" },
1852 { CE_PLAYER_ENTERS_X, "player enters" },
1853 { CE_PLAYER_LEAVES_X, "player leaves" },
1854 { CE_PLAYER_DIGS_X, "player digs" },
1855 { CE_PLAYER_COLLECTS_X, "player collects" },
1856 { CE_PLAYER_DROPS_X, "player drops/throws" },
1857 { CE_TOUCHING_X, "touching" },
1858 { CE_HITTING_X, "hitting" },
1859 { CE_DIGGING_X, "digging" },
1860 { CE_HIT_BY_X, "hit by" },
1861 { CE_SWITCH_OF_X, "switch of" },
1862 { CE_CHANGE_OF_X, "change by page of" },
1863 { CE_EXPLOSION_OF_X, "explosion of" },
1864 { CE_MOVE_OF_X, "move of" },
1865 { CE_CREATION_OF_X, "creation of" },
1866 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
1867 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
1868 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
1869 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
1874 static struct ValueTextInfo options_change_trigger_side[] =
1876 { CH_SIDE_LEFT, "left" },
1877 { CH_SIDE_RIGHT, "right" },
1878 { CH_SIDE_TOP, "top" },
1879 { CH_SIDE_BOTTOM, "bottom" },
1880 { CH_SIDE_LEFT_RIGHT, "left/right" },
1881 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
1882 { CH_SIDE_ANY, "any" },
1887 static struct ValueTextInfo options_change_trigger_player[] =
1889 { CH_PLAYER_1, "1" },
1890 { CH_PLAYER_2, "2" },
1891 { CH_PLAYER_3, "3" },
1892 { CH_PLAYER_4, "4" },
1893 { CH_PLAYER_ANY, "any" },
1898 static struct ValueTextInfo options_change_trigger_page[] =
1910 { (1 << 10), "11" },
1911 { (1 << 11), "12" },
1912 { (1 << 12), "13" },
1913 { (1 << 13), "14" },
1914 { (1 << 14), "15" },
1915 { (1 << 15), "16" },
1916 { (1 << 16), "17" },
1917 { (1 << 17), "18" },
1918 { (1 << 18), "19" },
1919 { (1 << 19), "20" },
1920 { (1 << 20), "21" },
1921 { (1 << 21), "22" },
1922 { (1 << 22), "23" },
1923 { (1 << 23), "24" },
1924 { (1 << 24), "25" },
1925 { (1 << 25), "26" },
1926 { (1 << 26), "27" },
1927 { (1 << 27), "28" },
1928 { (1 << 28), "29" },
1929 { (1 << 29), "30" },
1930 { (1 << 30), "31" },
1931 { (1 << 31), "32" },
1932 { CH_PAGE_ANY, "any" },
1937 static struct ValueTextInfo options_change_replace_when[] =
1939 { CP_WHEN_EMPTY, "empty" },
1940 { CP_WHEN_WALKABLE, "walkable" },
1941 { CP_WHEN_DIGGABLE, "diggable" },
1942 { CP_WHEN_COLLECTIBLE, "collectible" },
1943 { CP_WHEN_REMOVABLE, "removable" },
1944 { CP_WHEN_DESTRUCTIBLE, "destructible" },
1949 static struct ValueTextInfo options_action_type[] =
1951 { CA_NO_ACTION, "no action" },
1952 { CA_UNDEFINED, " " },
1953 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
1954 { CA_RESTART_LEVEL, "restart level" },
1955 { CA_SHOW_ENVELOPE, "show envelope" },
1956 { CA_SET_LEVEL_TIME, "set time" },
1957 { CA_SET_LEVEL_SCORE, "set score" },
1958 { CA_SET_LEVEL_GEMS, "set gems" },
1959 { CA_SET_LEVEL_WIND, "set wind dir." },
1960 { CA_SET_LEVEL_RANDOM_SEED, "set rand. seed" },
1961 { CA_UNDEFINED, " " },
1962 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
1963 { CA_MOVE_PLAYER, "move player" },
1964 { CA_EXIT_PLAYER, "exit player" },
1965 { CA_KILL_PLAYER, "kill player" },
1966 { CA_SET_PLAYER_KEYS, "set keys" },
1967 { CA_SET_PLAYER_SPEED, "set speed" },
1968 { CA_SET_PLAYER_SHIELD, "set shield" },
1969 { CA_SET_PLAYER_GRAVITY, "set gravity" },
1970 { CA_SET_PLAYER_ARTWORK, "set artwork" },
1971 { CA_SET_PLAYER_INVENTORY, "set inventory" },
1972 { CA_UNDEFINED, " " },
1973 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
1974 { CA_SET_CE_VALUE, "set CE value" },
1975 { CA_SET_CE_SCORE, "set CE score" },
1976 { CA_SET_CE_ARTWORK, "set CE artwork" },
1977 { CA_UNDEFINED, " " },
1978 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
1979 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
1984 static struct ValueTextInfo options_action_mode_none[] =
1986 { CA_MODE_UNDEFINED, " " },
1991 static struct ValueTextInfo options_action_mode_assign[] =
1993 { CA_MODE_SET, "=" },
1998 static struct ValueTextInfo options_action_mode_add_remove[] =
2000 { CA_MODE_ADD, "+" },
2001 { CA_MODE_SUBTRACT, "-" },
2006 static struct ValueTextInfo options_action_mode_calculate[] =
2008 { CA_MODE_SET, "=" },
2009 { CA_MODE_ADD, "+" },
2010 { CA_MODE_SUBTRACT, "-" },
2011 { CA_MODE_MULTIPLY, "*" },
2012 { CA_MODE_DIVIDE, "/" },
2013 { CA_MODE_MODULO, "%" },
2018 static struct ValueTextInfo options_action_arg_none[] =
2020 { CA_ARG_UNDEFINED, " " },
2025 static struct ValueTextInfo options_action_arg_player[] =
2027 { CA_ARG_PLAYER_HEADLINE, "[player]" },
2028 { CA_ARG_PLAYER_1, "1" },
2029 { CA_ARG_PLAYER_2, "2" },
2030 { CA_ARG_PLAYER_3, "3" },
2031 { CA_ARG_PLAYER_4, "4" },
2032 { CA_ARG_PLAYER_ANY, "any" },
2033 { CA_ARG_PLAYER_TRIGGER, "trigger" },
2034 { CA_ARG_PLAYER_ACTION, "action ->" },
2039 static struct ValueTextInfo options_action_arg_number[] =
2041 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2048 { CA_ARG_10, "10" },
2049 { CA_ARG_100, "100" },
2050 { CA_ARG_1000, "1000" },
2051 { CA_ARG_UNDEFINED, " " },
2052 { CA_ARG_NUMBER_MIN, "min" },
2053 { CA_ARG_NUMBER_MAX, "max" },
2054 { CA_ARG_UNDEFINED, " " },
2055 { CA_ARG_NUMBER_RESET, "reset" },
2056 { CA_ARG_UNDEFINED, " " },
2057 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2058 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2059 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2060 { CA_ARG_UNDEFINED, " " },
2061 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2062 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2063 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2064 { CA_ARG_UNDEFINED, " " },
2065 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2066 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2067 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2068 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2069 { CA_ARG_UNDEFINED, " " },
2070 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2071 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2072 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2073 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2078 static struct ValueTextInfo options_action_arg_value[] =
2080 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2087 { CA_ARG_10, "10" },
2088 { CA_ARG_100, "100" },
2089 { CA_ARG_1000, "1000" },
2090 { CA_ARG_UNDEFINED, " " },
2091 { CA_ARG_NUMBER_MIN, "min" },
2092 { CA_ARG_NUMBER_MAX, "max" },
2093 { CA_ARG_UNDEFINED, " " },
2094 { CA_ARG_NUMBER_RESET, "reset" },
2095 { CA_ARG_UNDEFINED, " " },
2096 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2097 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2098 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2099 { CA_ARG_UNDEFINED, " " },
2100 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2101 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2102 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2103 { CA_ARG_UNDEFINED, " " },
2104 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2105 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2106 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2107 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2108 { CA_ARG_UNDEFINED, " " },
2109 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2110 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2111 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2112 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2113 { CA_ARG_UNDEFINED, " " },
2114 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
2115 { CA_ARG_ELEMENT_NR_TARGET, "target" },
2116 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
2117 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
2122 static struct ValueTextInfo options_action_arg_envelope[] =
2124 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2129 { CA_ARG_UNDEFINED, " " },
2130 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2131 { CA_ARG_ELEMENT_TARGET, "target" },
2132 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2133 { CA_ARG_ELEMENT_ACTION, "action ->" },
2138 static struct ValueTextInfo options_action_arg_key[] =
2140 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2149 { CA_ARG_UNDEFINED, " " },
2150 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2151 { CA_ARG_ELEMENT_TARGET, "target" },
2152 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2153 { CA_ARG_ELEMENT_ACTION, "action ->" },
2158 static struct ValueTextInfo options_action_arg_speed[] =
2160 { CA_ARG_SPEED_HEADLINE, "[speed]" },
2161 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
2162 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
2163 { CA_ARG_SPEED_SLOW, "slow" },
2164 { CA_ARG_SPEED_NORMAL, "normal" },
2165 { CA_ARG_SPEED_FAST, "fast" },
2166 { CA_ARG_SPEED_VERY_FAST, "very fast" },
2167 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
2168 { CA_ARG_UNDEFINED, " " },
2169 { CA_ARG_SPEED_SLOWER, "slower" },
2170 { CA_ARG_SPEED_FASTER, "faster" },
2171 { CA_ARG_UNDEFINED, " " },
2172 { CA_ARG_SPEED_RESET, "reset" },
2177 static struct ValueTextInfo options_action_arg_shield[] =
2179 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
2180 { CA_ARG_SHIELD_OFF, "off" },
2181 { CA_ARG_SHIELD_NORMAL, "normal" },
2182 { CA_ARG_SHIELD_DEADLY, "deadly" },
2187 static struct ValueTextInfo options_action_arg_artwork[] =
2189 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2190 { CA_ARG_ELEMENT_TARGET, "target" },
2191 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2192 { CA_ARG_ELEMENT_ACTION, "action ->" },
2193 { CA_ARG_UNDEFINED, " " },
2194 { CA_ARG_ELEMENT_RESET, "reset" },
2199 static struct ValueTextInfo options_action_arg_gravity[] =
2201 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
2202 { CA_ARG_GRAVITY_ON, "on" },
2203 { CA_ARG_GRAVITY_OFF, "off" },
2204 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2209 static struct ValueTextInfo options_action_arg_direction[] =
2211 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2212 { CA_ARG_DIRECTION_NONE, "none" },
2213 { CA_ARG_DIRECTION_LEFT, "left" },
2214 { CA_ARG_DIRECTION_RIGHT, "right" },
2215 { CA_ARG_DIRECTION_UP, "up" },
2216 { CA_ARG_DIRECTION_DOWN, "down" },
2217 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2218 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2223 static struct ValueTextInfo options_action_arg_scan_mode[] =
2225 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2226 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2227 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2232 static struct ValueTextInfo options_action_arg_inventory[] =
2234 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2235 { CA_ARG_ELEMENT_TARGET, "+ target" },
2236 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2237 { CA_ARG_ELEMENT_ACTION, "+ action" },
2238 { CA_ARG_UNDEFINED, " " },
2239 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2240 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2241 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2242 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2243 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2244 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2245 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2246 { CA_ARG_UNDEFINED, " " },
2247 { CA_ARG_INVENTORY_RESET, "reset" },
2252 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2253 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2258 static struct ValueTextInfo options_group_choice_mode[] =
2260 { ANIM_RANDOM, "random" },
2261 { ANIM_LOOP, "loop" },
2262 { ANIM_LINEAR, "linear" },
2263 { ANIM_PINGPONG, "pingpong" },
2264 { ANIM_PINGPONG2, "pingpong 2" },
2269 static struct ValueTextInfo *action_arg_modes[] =
2271 options_action_mode_none,
2272 options_action_mode_assign,
2273 options_action_mode_add_remove,
2274 options_action_mode_calculate,
2281 struct ValueTextInfo *options;
2283 action_arg_options[] =
2285 { CA_NO_ACTION, 0, options_action_arg_none, },
2286 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2287 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2288 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2289 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2290 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2291 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2292 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2293 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2294 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2295 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2296 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2297 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2298 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2299 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2300 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2301 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2302 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2303 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2304 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2305 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2314 int gadget_id_align;
2315 int size; /* char size of selectbox or '-1' (dynamically determined) */
2316 struct ValueTextInfo *options;
2318 char *text_left, *text_right, *infotext;
2319 } selectbox_info[ED_NUM_SELECTBOX] =
2321 /* ---------- level and editor settings ---------------------------------- */
2324 -1, ED_LEVEL_SETTINGS_YPOS(7),
2325 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2327 options_time_or_steps,
2328 &level.use_step_counter,
2329 NULL, "(0 => no limit)", "time or step limit"
2332 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
2333 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2335 options_game_engine_type,
2336 &level.game_engine_type,
2337 "game engine:", NULL, "game engine"
2340 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2341 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2343 options_wind_direction,
2344 &level.wind_direction_initial,
2345 "initial wind direction:", NULL, "initial wind direction"
2348 /* ---------- element settings: configure (several elements) ------------- */
2351 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2352 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2354 options_player_speed,
2355 &level.initial_player_stepsize[0],
2356 "initial player speed:", NULL, "initial player speed"
2359 /* ---------- element settings: configure 1 (custom elements) ------------ */
2362 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2363 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2365 options_access_type,
2366 &custom_element.access_type,
2367 NULL, NULL, "type of access to this field"
2370 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2371 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2373 options_access_layer,
2374 &custom_element.access_layer,
2375 NULL, NULL, "layer of access for this field"
2378 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2379 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2381 options_access_protected,
2382 &custom_element.access_protected,
2383 NULL, NULL, "protected access for this field"
2386 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2387 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2389 options_access_direction,
2390 &custom_element.access_direction,
2391 "from", NULL, "access direction for this field"
2394 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2395 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2397 options_walk_to_action,
2398 &custom_element.walk_to_action,
2399 NULL, NULL, "diggable/collectible/pushable"
2402 /* ---------- element settings: configure 2 (custom elements) ------------ */
2405 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2406 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2408 options_move_pattern,
2409 &custom_element.move_pattern,
2410 "can move", NULL, "element move pattern"
2413 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2414 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2416 options_move_direction,
2417 &custom_element.move_direction_initial,
2418 "starts moving", NULL, "initial element move direction"
2421 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2422 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2424 options_move_stepsize,
2425 &custom_element.move_stepsize,
2426 "move/fall speed", NULL, "speed of element movement"
2429 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2430 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2432 options_move_leave_type,
2433 &custom_element.move_leave_type,
2434 // left text with leading spaces to place gadget next to "can dig" gadget
2435 // (needed because drawing area gadgets created after selectbox gadgets)
2436 // "can dig: can", ":", "leave behind or change element"
2437 " can", ":", "leave behind or change element"
2440 -1, ED_ELEMENT_SETTINGS_YPOS(7),
2441 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2443 options_smash_targets,
2444 &custom_element.smash_targets,
2445 "can smash", NULL, "elements that can be smashed"
2448 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
2449 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2451 options_slippery_type,
2452 &custom_element.slippery_type,
2453 "slippery", NULL, "where other elements fall down"
2456 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2457 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2460 &custom_element.deadliness,
2461 "deadly when", NULL, "deadliness of element"
2464 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2465 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2467 options_explosion_type,
2468 &custom_element.explosion_type,
2469 "can explode", NULL, "explosion type"
2472 /* ---------- element settings: advanced (custom elements) --------------- */
2475 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2476 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2479 &custom_element_change.delay_frames,
2480 "delay time given in", NULL, "delay time units for change"
2483 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2484 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2486 options_change_direct_action,
2487 &custom_element_change.direct_action,
2488 NULL, NULL, "type of direct action"
2491 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2492 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2494 options_change_other_action,
2495 &custom_element_change.other_action,
2496 NULL, "element:", "type of other element action"
2499 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2500 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2502 options_change_trigger_side,
2503 &custom_element_change.trigger_side,
2504 "at", "side", "element side triggering change"
2507 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2508 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2510 options_change_trigger_player,
2511 &custom_element_change.trigger_player,
2512 "player:", " ", "player that causes change"
2515 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2516 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2518 options_change_trigger_page,
2519 &custom_element_change.trigger_page,
2520 "page:", NULL, "change page that causes change"
2523 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2524 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2526 options_change_replace_when,
2527 &custom_element_change.replace_when,
2528 "replace when", NULL, "which elements can be replaced"
2531 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2532 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2534 options_action_type,
2535 &custom_element_change.action_type,
2536 NULL, NULL, "action on specified condition"
2539 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2540 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2542 options_action_mode_none,
2543 &custom_element_change.action_mode,
2544 NULL, NULL, "action operator"
2547 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2548 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2550 options_action_arg_none,
2551 &custom_element_change.action_arg,
2552 NULL, NULL, "action parameter"
2555 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2556 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2558 options_change_page,
2559 &custom_element.current_change_page,
2560 NULL, NULL, "element change page"
2563 /* ---------- element settings: configure (group elements) --------------- */
2566 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2567 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2569 options_group_choice_mode,
2570 &group_element_info.choice_mode,
2571 "choice type:", NULL, "type of group element choice"
2579 int gadget_id_align;
2582 char *text_above, *text_left, *text_right, *infotext;
2583 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2585 /* ---------- level and editor settings (tabs) --------------------------- */
2588 ED_LEVEL_TABS_XPOS(0), ED_LEVEL_TABS_YPOS(0),
2589 GADGET_ID_LEVELINFO_LEVEL, GADGET_ID_NONE,
2591 NULL, NULL, NULL, "Configure level properties"
2595 GADGET_ID_LEVELINFO_EDITOR, GADGET_ID_LEVELINFO_LEVEL,
2597 NULL, NULL, NULL, "Configure editor properties"
2600 /* ---------- element settings (tabs) ------------------------------------ */
2603 ED_ELEMENT_TABS_XPOS(0), ED_ELEMENT_TABS_YPOS(0),
2604 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
2606 NULL, NULL, NULL, "Show information about element"
2610 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_PROPERTIES_INFO,
2612 NULL, NULL, NULL, "Configure element properties"
2616 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_PROPERTIES_INFO,
2618 NULL, NULL, NULL, "Configure element properties, part 1"
2622 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_PROPERTIES_CONFIG_1,
2624 NULL, NULL, NULL, "Configure element properties, part 2"
2628 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_PROPERTIES_CONFIG_2,
2630 NULL, NULL, NULL, "Configure custom element change pages"
2633 /* ---------- level and editor settings (buttons) ------------------------ */
2636 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
2637 GADGET_ID_SAVE_AS_TEMPLATE_2, GADGET_ID_NONE,
2639 NULL, NULL, "this level as level template",
2640 "Save current settings as new template"
2643 /* ---------- element settings (buttons) --------------------------------- */
2647 GADGET_ID_SAVE_AS_TEMPLATE_1, GADGET_ID_CUSTOM_USE_TEMPLATE_1,
2649 NULL, " ", "As Template",
2650 "Save current settings as new template"
2654 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
2656 NULL, NULL, NULL, "Add new change page"
2660 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
2662 NULL, NULL, NULL, "Delete current change page"
2671 int gadget_id_align;
2672 char *text_left, *text_right, *infotext;
2673 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
2676 IMG_EDITOR_COUNTER_DOWN,
2677 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
2678 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
2679 NULL, NULL, "select previous change page"
2682 IMG_EDITOR_COUNTER_UP,
2683 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2684 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
2685 NULL, "change page", "select next change page"
2688 IMG_GFX_EDITOR_BUTTON_CP_COPY,
2689 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2690 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
2691 " ", NULL, "copy settings from this change page"
2694 IMG_GFX_EDITOR_BUTTON_CP_PASTE,
2695 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2696 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
2697 NULL, NULL, "paste settings to this change page"
2704 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
2711 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
2714 IMG_EDITOR_PLAYFIELD_SCROLL_UP,
2715 GADGET_ID_SCROLL_UP,
2716 "scroll level editing area up"
2719 IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
2720 GADGET_ID_SCROLL_DOWN,
2721 "scroll level editing area down"
2724 IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
2725 GADGET_ID_SCROLL_LEFT,
2726 "scroll level editing area left"
2729 IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
2730 GADGET_ID_SCROLL_RIGHT,
2731 "scroll level editing area right"
2734 IMG_EDITOR_PALETTE_SCROLL_UP,
2735 GADGET_ID_SCROLL_LIST_UP,
2736 "scroll element list up ('Page Up')"
2739 IMG_EDITOR_PALETTE_SCROLL_DOWN,
2740 GADGET_ID_SCROLL_LIST_DOWN,
2741 "scroll element list down ('Page Down')"
2749 int wheel_x, wheel_y;
2750 int wheel_width, wheel_height;
2751 } scrollbar_pos[ED_NUM_SCROLLBARS];
2759 } scrollbar_info[ED_NUM_SCROLLBARS] =
2762 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
2763 GD_TYPE_SCROLLBAR_HORIZONTAL,
2764 GADGET_ID_SCROLL_HORIZONTAL,
2765 "scroll level editing area horizontally"
2768 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
2769 GD_TYPE_SCROLLBAR_VERTICAL,
2770 GADGET_ID_SCROLL_VERTICAL,
2771 "scroll level editing area vertically"
2774 IMG_EDITOR_PALETTE_SCROLLBAR,
2775 GD_TYPE_SCROLLBAR_VERTICAL,
2776 GADGET_ID_SCROLL_LIST_VERTICAL,
2777 "scroll element list vertically"
2786 int gadget_id_align;
2787 int radio_button_nr;
2790 char *text_left, *text_right, *infotext;
2791 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
2794 -1, ED_LEVEL_SETTINGS_YPOS(0),
2795 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
2796 RADIO_NR_RANDOM_ELEMENTS,
2797 &random_placement_method, RANDOM_USE_PERCENTAGE,
2798 " ", "percentage", "use percentage for random elements"
2801 -1, ED_LEVEL_SETTINGS_YPOS(0),
2802 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
2803 RADIO_NR_RANDOM_ELEMENTS,
2804 &random_placement_method, RANDOM_USE_QUANTITY,
2805 " ", "quantity", "use quantity for random elements"
2813 int gadget_id_align;
2815 char *text_above, *text_left, *text_right, *infotext;
2816 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
2818 /* ---------- level and editor settings ---------------------------------- */
2821 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
2822 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
2823 &random_placement_background_restricted,
2825 "restrict random placement to:", "set random placement restriction"
2828 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
2829 GADGET_ID_CUSTOM_USE_TEMPLATE_3, GADGET_ID_NONE,
2830 &setup.editor.use_template_for_new_levels,
2831 "Template for new levels and CE/GE:", NULL,
2832 "use template for new levels", "use template for level properties"
2835 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
2836 GADGET_ID_CUSTOM_USE_TEMPLATE_2, GADGET_ID_NONE,
2837 &level.use_custom_template,
2839 "use template for custom elements", "use template for custom properties"
2842 /* ---------- element settings: configure (various elements) ------------- */
2845 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2846 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
2847 &stick_element_properties_window,
2849 "stick this screen to edit content","stick this screen to edit content"
2852 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2853 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
2854 &level.em_slippery_gems,
2856 "slip down from certain flat walls","use EM/DC style slipping behaviour"
2859 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2860 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
2861 &level.em_explodes_by_fire,
2863 "explodes with chain reaction", "use R'n'D style explosion behaviour"
2866 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2867 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
2868 &level.use_spring_bug,
2870 "use spring pushing bug", "use odd spring pushing behaviour"
2873 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2874 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
2875 &level.use_time_orb_bug,
2877 "use time orb bug", "use odd time orb behaviour"
2880 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2881 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
2884 "create single random element", "only create one element from content"
2887 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2888 GADGET_ID_INITIAL_BALL_STATE, GADGET_ID_NONE,
2889 &level.ball_state_initial,
2891 "magic ball initially activated", "activate magic ball after level start"
2894 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2895 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
2896 &level.grow_into_diggable,
2898 "can grow into anything diggable", "grow into more than just sand"
2901 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2902 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
2903 &level.auto_exit_sokoban,
2905 "exit level if all fields solved", "automatically finish Sokoban levels"
2908 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
2909 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
2910 &level.continuous_snapping,
2912 "continuous snapping", "use snapping without releasing key"
2915 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
2916 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
2917 &level.block_snap_field,
2919 "block snapped field when snapping", "use snapping delay to show animation"
2922 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2923 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
2924 &level.block_last_field,
2926 "block last field when moving", "player blocks last field when moving"
2929 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
2930 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
2931 &level.sp_block_last_field,
2933 "block last field when moving", "player blocks last field when moving"
2936 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
2937 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
2938 &level.instant_relocation,
2940 "no scrolling when relocating", "player gets relocated without delay"
2943 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2944 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
2945 &level.shifted_relocation,
2947 "no centering when relocating", "level not centered after relocation"
2950 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
2951 GADGET_ID_LAZY_RELOCATION, GADGET_ID_NONE,
2952 &level.lazy_relocation,
2954 "only redraw off-screen relocation","no redraw if relocation target visible"
2957 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
2958 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
2959 &level.use_start_element[0],
2961 "use level start element:", "start level at this element's position"
2964 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
2965 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
2966 &level.use_artwork_element[0],
2968 "use artwork from element:", "use player artwork from other element"
2971 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
2972 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
2973 &level.use_explosion_element[0],
2975 "use explosion from element:", "use explosion properties from element"
2978 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
2979 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
2980 &level.initial_player_gravity[0],
2982 "use initial gravity", "set initial player gravity"
2985 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
2986 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
2987 &level.use_initial_inventory[0],
2989 "use initial inventory:", "use collected elements on level start"
2992 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
2993 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
2994 &level.can_pass_to_walkable,
2996 "can pass to walkable element", "player can pass to empty or walkable"
2999 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3000 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
3001 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3003 "can fall into acid (with gravity)","player can fall into acid pool"
3006 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3007 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
3008 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3010 "can move into acid", "element can move into acid pool"
3013 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3014 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
3015 &custom_element_properties[EP_DONT_COLLIDE_WITH],
3017 "deadly when colliding with", "element is deadly when hitting player"
3020 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3021 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
3022 &level.envelope[0].autowrap,
3024 "auto-wrap", "automatically wrap envelope text"
3027 -1, ED_ELEMENT_SETTINGS_YPOS(1),
3028 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
3029 &level.envelope[0].centered,
3031 "centered", "automatically center envelope text"
3034 /* ---------- element settings: configure 1 (custom elements) ----------- */
3037 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3038 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
3039 &custom_element.use_gfx_element,
3041 "use graphic of element:", "use existing element graphic"
3044 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3045 GADGET_ID_CUSTOM_USE_TEMPLATE_1, GADGET_ID_NONE,
3046 &level.use_custom_template,
3048 "use template", "use template for custom properties"
3051 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3052 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
3053 &custom_element_properties[EP_ACCESSIBLE],
3055 NULL, "player can walk to or pass this field"
3058 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3059 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
3060 &custom_element_properties[EP_GRAVITY_REACHABLE],
3062 "reachable despite gravity", "player can walk/dig despite gravity"
3065 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3066 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
3067 &custom_element.use_last_ce_value,
3069 "use last CE value after change", "use last CE value after change"
3072 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3073 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
3074 &custom_element_properties[EP_WALK_TO_OBJECT],
3076 NULL, "player can dig/collect/push element"
3079 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3080 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
3081 &custom_element_properties[EP_INDESTRUCTIBLE],
3083 "indestructible", "element is indestructible"
3086 /* ---------- element settings: configure 2 (custom elements) ----------- */
3089 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3090 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
3091 &custom_element_properties[EP_CAN_MOVE],
3093 NULL, "element can move with some pattern"
3096 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
3097 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
3098 &custom_element_properties[EP_CAN_FALL],
3100 "can fall", "element can fall down"
3103 -1, ED_ELEMENT_SETTINGS_YPOS(7),
3104 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
3105 &custom_element_properties[EP_CAN_SMASH],
3107 NULL, "element can smash other elements"
3110 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3111 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
3112 &custom_element_properties[EP_SLIPPERY],
3114 NULL, "other elements can fall down from it"
3117 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3118 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
3119 &custom_element_properties[EP_DEADLY],
3121 NULL, "element can kill the player"
3124 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3125 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
3126 &custom_element_properties[EP_CAN_EXPLODE],
3128 NULL, "element can explode"
3131 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
3132 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
3133 &custom_element_properties[EP_EXPLODES_BY_FIRE],
3135 "by fire", "element can explode by fire/explosion"
3138 -1, ED_ELEMENT_SETTINGS_YPOS(11),
3139 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
3140 &custom_element_properties[EP_EXPLODES_SMASHED],
3142 "smashed", "element can explode when smashed"
3145 -1, ED_ELEMENT_SETTINGS_YPOS(11),
3146 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
3147 &custom_element_properties[EP_EXPLODES_IMPACT],
3149 "impact", "element can explode on impact"
3152 /* ---------- element settings: advanced (custom elements) --------------- */
3155 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3156 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
3157 &custom_element_change.can_change,
3159 "element changes to:", "change element on specified condition"
3162 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
3163 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
3164 &custom_element_change_events[CE_DELAY],
3166 NULL, "element changes after delay"
3169 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
3170 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
3171 &custom_element_change_events[CE_BY_DIRECT_ACTION],
3173 NULL, "element changes by direct action"
3176 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
3177 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
3178 &custom_element_change_events[CE_BY_OTHER_ACTION],
3180 NULL, "element changes by other element"
3183 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
3184 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
3185 &custom_element_change.explode,
3187 "explode instead of change", "element explodes instead of change"
3190 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
3191 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
3192 &custom_element_change.use_target_content,
3194 "use extended change target:", "element changes to more elements"
3197 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3198 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3199 &custom_element_change.only_if_complete,
3201 "replace all or nothing", "only replace when all can be changed"
3204 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3205 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3206 &custom_element_change.use_random_replace,
3208 NULL, "use percentage for random replace"
3211 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3212 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3213 &custom_element_change.has_action,
3215 NULL, "execute action on specified condition"
3222 int xoffset, yoffset;
3224 int gadget_id_align;
3226 int area_xsize, area_ysize;
3227 char *text_left, *text_right, *text_below, *infotext;
3228 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3230 /* ---------- level playfield content ------------------------------------ */
3235 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
3237 -1, -1, /* these values are not constant, but can change at runtime */
3238 NULL, NULL, NULL, NULL
3241 /* ---------- yam yam content -------------------------------------------- */
3244 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3245 ED_AREA_YAMYAM_CONTENT_XOFF(0), ED_AREA_YAMYAM_CONTENT_YOFF(0),
3246 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
3247 &level.yamyam_content[0].e[0][0], 3, 3,
3248 NULL, NULL, "1", NULL
3251 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3252 ED_AREA_YAMYAM_CONTENT_XOFF(1), ED_AREA_YAMYAM_CONTENT_YOFF(1),
3253 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
3254 &level.yamyam_content[1].e[0][0], 3, 3,
3255 NULL, NULL, "2", NULL
3258 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3259 ED_AREA_YAMYAM_CONTENT_XOFF(2), ED_AREA_YAMYAM_CONTENT_YOFF(2),
3260 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
3261 &level.yamyam_content[2].e[0][0], 3, 3,
3262 NULL, NULL, "3", NULL
3265 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3266 ED_AREA_YAMYAM_CONTENT_XOFF(3), ED_AREA_YAMYAM_CONTENT_YOFF(3),
3267 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
3268 &level.yamyam_content[3].e[0][0], 3, 3,
3269 NULL, NULL, "4", NULL
3272 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3273 ED_AREA_YAMYAM_CONTENT_XOFF(4), ED_AREA_YAMYAM_CONTENT_YOFF(4),
3274 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
3275 &level.yamyam_content[4].e[0][0], 3, 3,
3276 NULL, NULL, "5", NULL
3279 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3280 ED_AREA_YAMYAM_CONTENT_XOFF(5), ED_AREA_YAMYAM_CONTENT_YOFF(5),
3281 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
3282 &level.yamyam_content[5].e[0][0], 3, 3,
3283 NULL, NULL, "6", NULL
3286 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3287 ED_AREA_YAMYAM_CONTENT_XOFF(6), ED_AREA_YAMYAM_CONTENT_YOFF(6),
3288 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
3289 &level.yamyam_content[6].e[0][0], 3, 3,
3290 NULL, NULL, "7", NULL
3293 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3294 ED_AREA_YAMYAM_CONTENT_XOFF(7), ED_AREA_YAMYAM_CONTENT_YOFF(7),
3295 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
3296 &level.yamyam_content[7].e[0][0], 3, 3,
3297 NULL, NULL, "8", NULL
3300 /* ---------- magic ball content ----------------------------------------- */
3303 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3304 ED_AREA_MAGIC_BALL_CONTENT_XOFF(0), ED_AREA_MAGIC_BALL_CONTENT_YOFF(0),
3305 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
3306 &level.ball_content[0].e[0][0], 3, 3,
3307 NULL, NULL, "1", NULL
3310 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3311 ED_AREA_MAGIC_BALL_CONTENT_XOFF(1), ED_AREA_MAGIC_BALL_CONTENT_YOFF(1),
3312 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
3313 &level.ball_content[1].e[0][0], 3, 3,
3314 NULL, NULL, "2", NULL
3317 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3318 ED_AREA_MAGIC_BALL_CONTENT_XOFF(2), ED_AREA_MAGIC_BALL_CONTENT_YOFF(2),
3319 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
3320 &level.ball_content[2].e[0][0], 3, 3,
3321 NULL, NULL, "3", NULL
3324 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3325 ED_AREA_MAGIC_BALL_CONTENT_XOFF(3), ED_AREA_MAGIC_BALL_CONTENT_YOFF(3),
3326 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
3327 &level.ball_content[3].e[0][0], 3, 3,
3328 NULL, NULL, "4", NULL
3331 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3332 ED_AREA_MAGIC_BALL_CONTENT_XOFF(4), ED_AREA_MAGIC_BALL_CONTENT_YOFF(4),
3333 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
3334 &level.ball_content[4].e[0][0], 3, 3,
3335 NULL, NULL, "5", NULL
3338 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3339 ED_AREA_MAGIC_BALL_CONTENT_XOFF(5), ED_AREA_MAGIC_BALL_CONTENT_YOFF(5),
3340 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
3341 &level.ball_content[5].e[0][0], 3, 3,
3342 NULL, NULL, "6", NULL
3345 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3346 ED_AREA_MAGIC_BALL_CONTENT_XOFF(6), ED_AREA_MAGIC_BALL_CONTENT_YOFF(6),
3347 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
3348 &level.ball_content[6].e[0][0], 3, 3,
3349 NULL, NULL, "7", NULL
3352 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3353 ED_AREA_MAGIC_BALL_CONTENT_XOFF(7), ED_AREA_MAGIC_BALL_CONTENT_YOFF(7),
3354 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
3355 &level.ball_content[7].e[0][0], 3, 3,
3356 NULL, NULL, "8", NULL
3359 /* ---------- android content -------------------------------------------- */
3362 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(5),
3363 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3364 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
3365 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
3366 "elements:", NULL, NULL, "elements android can clone"
3369 /* ---------- amoeba content --------------------------------------------- */
3372 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
3373 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3374 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
3375 &level.amoeba_content, 1, 1,
3376 "content:", NULL, NULL, "amoeba content"
3379 /* ---------- level start element ---------------------------------------- */
3382 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
3383 0, ED_AREA_1X1_SETTINGS_YOFF,
3384 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
3385 &level.start_element[0], 1, 1,
3386 NULL, NULL, NULL, "level start element"
3389 /* ---------- player artwork element ------------------------------------- */
3392 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
3393 0, ED_AREA_1X1_SETTINGS_YOFF,
3394 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
3395 &level.artwork_element[0], 1, 1,
3396 NULL, NULL, NULL, "element for player artwork"
3399 /* ---------- player explosion element ----------------------------------- */
3402 -1, ED_AREA_1X1_SETTINGS_YPOS(12),
3403 0, ED_AREA_1X1_SETTINGS_YOFF,
3404 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
3405 &level.explosion_element[0], 1, 1,
3406 NULL, NULL, NULL, "element for player explosion"
3409 /* ---------- player initial inventory ----------------------------------- */
3412 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3413 0, ED_AREA_1X1_SETTINGS_YOFF,
3414 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
3415 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
3416 NULL, NULL, NULL, "content for initial inventory"
3419 /* ---------- element settings: configure 1 (custom elements) ----------- */
3421 /* ---------- custom graphic --------------------------------------------- */
3424 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3425 0, ED_AREA_1X1_SETTINGS_YOFF,
3426 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
3427 &custom_element.gfx_element_initial,1, 1,
3428 NULL, NULL, NULL, "custom graphic element"
3431 /* ---------- element settings: configure 2 (custom elements) ----------- */
3433 /* ---------- custom content (when exploding) ---------------------------- */
3436 -1, ED_AREA_3X3_SETTINGS_YPOS(10),
3437 0, ED_AREA_3X3_SETTINGS_YOFF,
3438 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, /* align three rows */
3439 &custom_element.content.e[0][0], 3, 3,
3440 "content:", NULL, NULL, NULL
3443 /* ---------- custom enter and leave element (when moving) --------------- */
3446 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
3447 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3448 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
3449 &custom_element.move_enter_element, 1, 1,
3450 "can dig:", " ", NULL, "element that can be digged/collected"
3453 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
3454 0, ED_AREA_1X1_SETTINGS_YOFF,
3455 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
3456 &custom_element.move_leave_element, 1, 1,
3457 NULL, NULL, NULL, "element that will be left behind"
3460 /* ---------- element settings: advanced (custom elements) --------------- */
3462 /* ---------- custom change target --------------------------------------- */
3465 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3466 0, ED_AREA_1X1_SETTINGS_YOFF,
3467 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
3468 &custom_element_change.target_element, 1, 1,
3469 NULL, "after/when:", NULL, "new target element after change"
3472 /* ---------- custom change content (extended change target) ------------- */
3475 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
3476 0, ED_AREA_3X3_SETTINGS_YOFF,
3477 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, /* align three rows */
3478 &custom_element_change.target_content.e[0][0], 3, 3,
3479 NULL, NULL, NULL, "new extended elements after change"
3482 /* ---------- custom change trigger (element causing change) ------------- */
3485 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
3486 0, ED_AREA_1X1_SETTINGS_YOFF,
3487 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
3488 &custom_element_change.initial_trigger_element, 1, 1,
3489 NULL, NULL, NULL, "other element triggering change"
3492 /* ---------- custom change action (element used for action) ------------- */
3495 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
3496 0, ED_AREA_1X1_SETTINGS_YOFF,
3497 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
3498 &custom_element_change.action_element, 1, 1,
3499 NULL, NULL, NULL, "element used as action parameter"
3502 /* ---------- group element content -------------------------------------- */
3505 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
3506 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3507 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
3508 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
3509 "content:", NULL, NULL, NULL
3512 /* ---------- random background (for random painting) -------------------- */
3515 -1, ED_AREA_1X1_LSETTINGS_YPOS(1),
3516 0, ED_AREA_1X1_LSETTINGS_YOFF,
3517 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
3518 &random_placement_background_element, 1, 1,
3519 NULL, NULL, NULL, "random placement background"
3525 -----------------------------------------------------------------------------
3526 some internally used variables
3527 -----------------------------------------------------------------------------
3530 /* maximal size of level editor drawing area */
3531 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
3533 /* actual size of level editor drawing area */
3534 static int ed_fieldx, ed_fieldy;
3536 /* actual position of level editor drawing area in level playfield */
3537 static int level_xpos = -1, level_ypos = -1;
3539 /* actual tile size used to display playfield drawing area */
3540 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
3542 #define IN_ED_FIELD(x,y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
3544 /* drawing elements on the three mouse buttons */
3545 static int new_element1 = EL_WALL;
3546 static int new_element2 = EL_EMPTY;
3547 static int new_element3 = EL_SAND;
3549 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
3550 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
3551 (button) == 2 ? new_element2 : \
3552 (button) == 3 ? new_element3 : EL_EMPTY)
3554 #define BUTTON_TILE_SIZE(x) ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE)
3556 static int use_permanent_palette = TRUE;
3558 #define PX (use_permanent_palette ? DX : SX)
3559 #define PY (use_permanent_palette ? DY : SY)
3560 #define PXSIZE (use_permanent_palette ? DXSIZE : SXSIZE)
3561 #define PYSIZE (use_permanent_palette ? DYSIZE : SYSIZE)
3563 /* forward declaration for internal use */
3564 static void ModifyEditorCounterValue(int, int);
3565 static void ModifyEditorCounterLimits(int, int, int);
3566 static void ModifyEditorSelectboxValue(int, int);
3567 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
3568 static void ModifyEditorDrawingArea(int, int, int);
3569 static void ModifyEditorElementList();
3570 static void AdjustElementListScrollbar();
3571 static void RedrawDrawingElements();
3572 static void DrawDrawingWindow();
3573 static void DrawLevelInfoWindow();
3574 static void DrawPropertiesWindow();
3575 static void DrawPaletteWindow();
3576 static void UpdateCustomElementGraphicGadgets();
3577 static boolean checkPropertiesConfig(int);
3578 static void CopyLevelToUndoBuffer(int);
3579 static void HandleDrawingAreas(struct GadgetInfo *);
3580 static void HandleCounterButtons(struct GadgetInfo *);
3581 static void HandleTextInputGadgets(struct GadgetInfo *);
3582 static void HandleTextAreaGadgets(struct GadgetInfo *);
3583 static void HandleSelectboxGadgets(struct GadgetInfo *);
3584 static void HandleTextbuttonGadgets(struct GadgetInfo *);
3585 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
3586 static void HandleRadiobuttons(struct GadgetInfo *);
3587 static void HandleCheckbuttons(struct GadgetInfo *);
3588 static void HandleControlButtons(struct GadgetInfo *);
3589 static void HandleDrawingAreaInfo(struct GadgetInfo *);
3590 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
3591 static boolean AskToCopyAndModifyLevelTemplate();
3593 static int num_editor_gadgets = 0; /* dynamically determined */
3595 static struct GadgetInfo **level_editor_gadget = NULL;
3596 static int *right_gadget_border = NULL;
3598 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
3599 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
3600 static boolean draw_with_brush = FALSE;
3601 static int properties_element = 0;
3603 static short FieldBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3604 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3605 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3606 static int undo_buffer_position = 0;
3607 static int undo_buffer_steps = 0;
3608 static int redo_buffer_steps = 0;
3610 static int edit_mode;
3611 static int edit_mode_levelinfo;
3612 static int edit_mode_properties;
3614 static int element_shift = 0;
3616 static int editor_el_players[] =
3623 static int *editor_el_players_ptr = editor_el_players;
3624 static int num_editor_el_players = SIZEOF_ARRAY_INT(editor_el_players);
3626 static int editor_hl_boulderdash[] =
3628 EL_INTERNAL_CASCADE_BD_ACTIVE,
3634 static int editor_el_boulderdash[] =
3643 EL_BD_EXPANDABLE_WALL,
3651 EL_BD_BUTTERFLY_LEFT,
3653 EL_BD_BUTTERFLY_RIGHT,
3654 EL_BD_FIREFLY_RIGHT,
3657 EL_BD_BUTTERFLY_DOWN,
3661 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
3662 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
3663 static int num_editor_hl_boulderdash = SIZEOF_ARRAY_INT(editor_hl_boulderdash);
3664 static int num_editor_el_boulderdash = SIZEOF_ARRAY_INT(editor_el_boulderdash);
3666 static int editor_hl_emerald_mine[] =
3668 EL_INTERNAL_CASCADE_EM_ACTIVE,
3674 static int editor_el_emerald_mine[] =
3711 EL_ACID_POOL_TOPLEFT,
3713 EL_ACID_POOL_TOPRIGHT,
3716 EL_ACID_POOL_BOTTOMLEFT,
3717 EL_ACID_POOL_BOTTOM,
3718 EL_ACID_POOL_BOTTOMRIGHT,
3738 EL_EM_STEEL_EXIT_CLOSED,
3739 EL_EM_STEEL_EXIT_OPEN,
3741 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
3742 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
3743 static int num_editor_hl_emerald_mine=SIZEOF_ARRAY_INT(editor_hl_emerald_mine);
3744 static int num_editor_el_emerald_mine=SIZEOF_ARRAY_INT(editor_el_emerald_mine);
3746 static int editor_hl_emerald_mine_club[] =
3748 EL_INTERNAL_CASCADE_EMC_ACTIVE,
3754 static int editor_el_emerald_mine_club[] =
3781 EL_EMC_WALL_SLIPPERY_1,
3782 EL_EMC_WALL_SLIPPERY_2,
3783 EL_EMC_WALL_SLIPPERY_3,
3784 EL_EMC_WALL_SLIPPERY_4,
3807 EL_EMC_MAGIC_BALL_SWITCH,
3809 EL_EMC_SPRING_BUMPER,
3814 EL_EM_DYNAMITE_ACTIVE,
3818 EL_BALLOON_SWITCH_UP,
3819 EL_BALLOON_SWITCH_ANY,
3822 EL_BALLOON_SWITCH_LEFT,
3824 EL_BALLOON_SWITCH_RIGHT,
3828 EL_BALLOON_SWITCH_DOWN,
3829 EL_BALLOON_SWITCH_NONE,
3831 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
3832 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
3833 static int num_editor_hl_emerald_mine_club=SIZEOF_ARRAY_INT(editor_hl_emerald_mine_club);
3834 static int num_editor_el_emerald_mine_club=SIZEOF_ARRAY_INT(editor_el_emerald_mine_club);
3836 static int editor_hl_rnd[] =
3838 EL_INTERNAL_CASCADE_RND_ACTIVE,
3844 static int editor_el_rnd[] =
3876 EL_WALL_EMERALD_YELLOW,
3877 EL_WALL_EMERALD_RED,
3878 EL_WALL_EMERALD_PURPLE,
3896 EL_DYNABOMB_INCREASE_NUMBER,
3897 EL_DYNABOMB_INCREASE_SIZE,
3898 EL_DYNABOMB_INCREASE_POWER,
3918 EL_INVISIBLE_STEELWALL,
3922 EL_EXPANDABLE_WALL_HORIZONTAL,
3923 EL_EXPANDABLE_WALL_VERTICAL,
3924 EL_EXPANDABLE_WALL_ANY,
3926 static int *editor_hl_rnd_ptr = editor_hl_rnd;
3927 static int *editor_el_rnd_ptr = editor_el_rnd;
3928 static int num_editor_hl_rnd = SIZEOF_ARRAY_INT(editor_hl_rnd);
3929 static int num_editor_el_rnd = SIZEOF_ARRAY_INT(editor_el_rnd);
3931 static int editor_hl_sokoban[] =
3933 EL_INTERNAL_CASCADE_SB_ACTIVE,
3939 static int editor_el_sokoban[] =
3942 EL_SOKOBAN_FIELD_EMPTY,
3943 EL_SOKOBAN_FIELD_FULL,
3944 EL_SOKOBAN_FIELD_PLAYER,
3946 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
3947 static int *editor_el_sokoban_ptr = editor_el_sokoban;
3948 static int num_editor_hl_sokoban = SIZEOF_ARRAY_INT(editor_hl_sokoban);
3949 static int num_editor_el_sokoban = SIZEOF_ARRAY_INT(editor_el_sokoban);
3951 static int editor_hl_supaplex[] =
3953 EL_INTERNAL_CASCADE_SP_ACTIVE,
3959 static int editor_el_supaplex[] =
3977 EL_SP_PORT_HORIZONTAL,
3978 EL_SP_PORT_VERTICAL,
3986 EL_SP_GRAVITY_PORT_LEFT,
3987 EL_SP_GRAVITY_PORT_RIGHT,
3988 EL_SP_GRAVITY_PORT_UP,
3989 EL_SP_GRAVITY_PORT_DOWN,
3991 EL_SP_GRAVITY_ON_PORT_LEFT,
3992 EL_SP_GRAVITY_ON_PORT_RIGHT,
3993 EL_SP_GRAVITY_ON_PORT_UP,
3994 EL_SP_GRAVITY_ON_PORT_DOWN,
3996 EL_SP_GRAVITY_OFF_PORT_LEFT,
3997 EL_SP_GRAVITY_OFF_PORT_RIGHT,
3998 EL_SP_GRAVITY_OFF_PORT_UP,
3999 EL_SP_GRAVITY_OFF_PORT_DOWN,
4001 EL_SP_HARDWARE_GRAY,
4002 EL_SP_HARDWARE_GREEN,
4003 EL_SP_HARDWARE_BLUE,
4006 EL_SP_HARDWARE_BASE_1,
4007 EL_SP_HARDWARE_BASE_2,
4008 EL_SP_HARDWARE_BASE_3,
4009 EL_SP_HARDWARE_BASE_4,
4011 EL_SP_HARDWARE_BASE_5,
4012 EL_SP_HARDWARE_BASE_6,
4013 EL_SP_HARDWARE_YELLOW,
4021 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
4022 static int *editor_el_supaplex_ptr = editor_el_supaplex;
4023 static int num_editor_hl_supaplex = SIZEOF_ARRAY_INT(editor_hl_supaplex);
4024 static int num_editor_el_supaplex = SIZEOF_ARRAY_INT(editor_el_supaplex);
4026 static int editor_hl_diamond_caves[] =
4028 EL_INTERNAL_CASCADE_DC_ACTIVE,
4034 static int editor_el_diamond_caves[] =
4041 EL_CONVEYOR_BELT_1_LEFT,
4042 EL_CONVEYOR_BELT_1_MIDDLE,
4043 EL_CONVEYOR_BELT_1_RIGHT,
4044 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
4046 EL_CONVEYOR_BELT_2_LEFT,
4047 EL_CONVEYOR_BELT_2_MIDDLE,
4048 EL_CONVEYOR_BELT_2_RIGHT,
4049 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
4051 EL_CONVEYOR_BELT_3_LEFT,
4052 EL_CONVEYOR_BELT_3_MIDDLE,
4053 EL_CONVEYOR_BELT_3_RIGHT,
4054 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
4056 EL_CONVEYOR_BELT_4_LEFT,
4057 EL_CONVEYOR_BELT_4_MIDDLE,
4058 EL_CONVEYOR_BELT_4_RIGHT,
4059 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
4061 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
4062 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
4063 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
4064 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
4066 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
4067 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
4068 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
4069 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
4074 EL_DC_TIMEGATE_SWITCH,
4076 EL_SWITCHGATE_CLOSED,
4078 EL_SWITCHGATE_SWITCH_UP,
4079 EL_SWITCHGATE_SWITCH_DOWN,
4082 EL_LIGHT_SWITCH_ACTIVE,
4083 EL_DC_SWITCHGATE_SWITCH_UP,
4084 EL_DC_SWITCHGATE_SWITCH_DOWN,
4086 EL_STEEL_EXIT_CLOSED,
4088 EL_STEELWALL_SLIPPERY,
4091 EL_QUICKSAND_FAST_EMPTY,
4092 EL_QUICKSAND_FAST_FULL,
4106 EL_SIGN_RADIOACTIVITY,
4112 EL_SIGN_ENTRY_FORBIDDEN,
4113 EL_SIGN_EMERGENCY_EXIT,
4138 EL_DC_STEELWALL_2_SINGLE,
4139 EL_DC_STEELWALL_2_TOP,
4140 EL_SIGN_EXCLAMATION,
4143 EL_DC_STEELWALL_2_LEFT,
4144 EL_DC_STEELWALL_2_MIDDLE,
4145 EL_DC_STEELWALL_2_HORIZONTAL,
4146 EL_DC_STEELWALL_2_RIGHT,
4148 EL_DC_STEELWALL_1_TOPLEFT,
4149 EL_DC_STEELWALL_2_VERTICAL,
4150 EL_DC_STEELWALL_1_TOPRIGHT,
4153 EL_DC_STEELWALL_1_VERTICAL,
4154 EL_DC_STEELWALL_2_BOTTOM,
4156 EL_DC_GATE_WHITE_GRAY,
4158 EL_DC_STEELWALL_1_BOTTOMLEFT,
4159 EL_DC_STEELWALL_1_HORIZONTAL,
4160 EL_DC_STEELWALL_1_BOTTOMRIGHT,
4161 EL_DC_GATE_FAKE_GRAY,
4163 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
4164 EL_DC_STEELWALL_1_BOTTOM,
4165 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
4166 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
4168 EL_DC_STEELWALL_1_RIGHT,
4170 EL_DC_STEELWALL_1_LEFT,
4171 EL_EXPANDABLE_STEELWALL_VERTICAL,
4173 EL_DC_STEELWALL_1_TOPRIGHT_2,
4174 EL_DC_STEELWALL_1_TOP,
4175 EL_DC_STEELWALL_1_TOPLEFT_2,
4176 EL_EXPANDABLE_STEELWALL_ANY,
4178 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
4179 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
4180 static int num_editor_hl_diamond_caves = SIZEOF_ARRAY_INT(editor_hl_diamond_caves);
4181 static int num_editor_el_diamond_caves = SIZEOF_ARRAY_INT(editor_el_diamond_caves);
4183 static int editor_hl_dx_boulderdash[] =
4185 EL_INTERNAL_CASCADE_DX_ACTIVE,
4191 static int editor_el_dx_boulderdash[] =
4195 EL_TUBE_HORIZONTAL_DOWN,
4199 EL_TUBE_VERTICAL_RIGHT,
4201 EL_TUBE_VERTICAL_LEFT,
4205 EL_TUBE_HORIZONTAL_UP,
4213 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
4214 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
4215 static int num_editor_hl_dx_boulderdash = SIZEOF_ARRAY_INT(editor_hl_dx_boulderdash);
4216 static int num_editor_el_dx_boulderdash = SIZEOF_ARRAY_INT(editor_el_dx_boulderdash);
4218 static int editor_hl_mirror_magic[] =
4220 EL_INTERNAL_CASCADE_MM_ACTIVE,
4226 static int editor_el_mirror_magic[] =
4228 EL_MM_MCDUFFIN_RIGHT,
4230 EL_MM_MCDUFFIN_LEFT,
4231 EL_MM_MCDUFFIN_DOWN,
4234 EL_MM_MIRROR_FIXED_START,
4235 EL_MM_POLARISATOR_START,
4236 EL_MM_POLARISATOR_CROSS_START,
4238 EL_MM_BEAMER_RED_START,
4239 EL_MM_BEAMER_YELLOW_START,
4240 EL_MM_BEAMER_GREEN_START,
4241 EL_MM_BEAMER_BLUE_START,
4254 EL_MM_LIGHTBULB_ACTIVE,
4268 EL_MM_STEEL_GRID_FIXED_1,
4269 EL_MM_STEEL_GRID_FIXED_2,
4270 EL_MM_STEEL_GRID_FIXED_3,
4271 EL_MM_STEEL_GRID_FIXED_4,
4273 EL_MM_WOODEN_GRID_FIXED_1,
4274 EL_MM_WOODEN_GRID_FIXED_2,
4275 EL_MM_WOODEN_GRID_FIXED_3,
4276 EL_MM_WOODEN_GRID_FIXED_4
4278 static int *editor_hl_mirror_magic_ptr = editor_hl_mirror_magic;
4279 static int *editor_el_mirror_magic_ptr = editor_el_mirror_magic;
4280 static int num_editor_hl_mirror_magic = SIZEOF_ARRAY_INT(editor_hl_mirror_magic);
4281 static int num_editor_el_mirror_magic = SIZEOF_ARRAY_INT(editor_el_mirror_magic);
4283 static int editor_hl_deflektor[] =
4285 EL_INTERNAL_CASCADE_DF_ACTIVE,
4291 static int editor_el_deflektor[] =
4298 EL_DF_RECEIVER_RIGHT,
4300 EL_DF_RECEIVER_LEFT,
4301 EL_DF_RECEIVER_DOWN,
4304 EL_DF_MIRROR_ROTATING_START,
4308 EL_DF_FIBRE_OPTIC_RED_1,
4309 EL_DF_FIBRE_OPTIC_YELLOW_1,
4310 EL_DF_FIBRE_OPTIC_GREEN_1,
4311 EL_DF_FIBRE_OPTIC_BLUE_1,
4313 EL_DF_STEEL_GRID_FIXED_START,
4314 EL_DF_STEEL_GRID_ROTATING_START,
4315 EL_DF_WOODEN_GRID_FIXED_START,
4316 EL_DF_WOODEN_GRID_ROTATING_START,
4323 static int *editor_hl_deflektor_ptr = editor_hl_deflektor;
4324 static int *editor_el_deflektor_ptr = editor_el_deflektor;
4325 static int num_editor_hl_deflektor = SIZEOF_ARRAY_INT(editor_hl_deflektor);
4326 static int num_editor_el_deflektor = SIZEOF_ARRAY_INT(editor_el_deflektor);
4328 static int editor_hl_chars[] =
4330 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
4336 static int editor_el_chars[] =
4418 EL_CHAR(CHAR_BYTE_COPYRIGHT),
4419 EL_CHAR(CHAR_BYTE_UMLAUT_A),
4420 EL_CHAR(CHAR_BYTE_UMLAUT_O),
4421 EL_CHAR(CHAR_BYTE_UMLAUT_U),
4423 EL_CHAR(CHAR_BYTE_DEGREE),
4424 EL_CHAR(CHAR_BYTE_REGISTERED),
4425 EL_CHAR(FONT_ASCII_CURSOR),
4426 EL_CHAR(FONT_ASCII_BUTTON),
4428 EL_CHAR(FONT_ASCII_UP),
4429 EL_CHAR(FONT_ASCII_DOWN),
4433 static int *editor_hl_chars_ptr = editor_hl_chars;
4434 static int *editor_el_chars_ptr = editor_el_chars;
4435 static int num_editor_hl_chars = SIZEOF_ARRAY_INT(editor_hl_chars);
4436 static int num_editor_el_chars = SIZEOF_ARRAY_INT(editor_el_chars);
4438 static int editor_hl_steel_chars[] =
4440 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
4446 static int editor_el_steel_chars[] =
4456 EL_STEEL_CHAR('\''),
4523 EL_STEEL_CHAR('\\'),
4528 EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
4529 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
4530 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
4531 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
4533 EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
4534 EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
4535 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
4536 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
4538 EL_STEEL_CHAR(FONT_ASCII_UP),
4539 EL_STEEL_CHAR(FONT_ASCII_DOWN),
4543 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
4544 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
4545 static int num_editor_hl_steel_chars = SIZEOF_ARRAY_INT(editor_hl_steel_chars);
4546 static int num_editor_el_steel_chars = SIZEOF_ARRAY_INT(editor_el_steel_chars);
4548 static int editor_hl_custom[] =
4550 EL_INTERNAL_CASCADE_CE_ACTIVE,
4556 static int editor_el_custom[] =
4558 EL_CUSTOM_START + 0,
4559 EL_CUSTOM_START + 1,
4560 EL_CUSTOM_START + 2,
4561 EL_CUSTOM_START + 3,
4563 EL_CUSTOM_START + 4,
4564 EL_CUSTOM_START + 5,
4565 EL_CUSTOM_START + 6,
4566 EL_CUSTOM_START + 7,
4568 EL_CUSTOM_START + 8,
4569 EL_CUSTOM_START + 9,
4570 EL_CUSTOM_START + 10,
4571 EL_CUSTOM_START + 11,
4573 EL_CUSTOM_START + 12,
4574 EL_CUSTOM_START + 13,
4575 EL_CUSTOM_START + 14,
4576 EL_CUSTOM_START + 15,
4578 EL_CUSTOM_START + 16,
4579 EL_CUSTOM_START + 17,
4580 EL_CUSTOM_START + 18,
4581 EL_CUSTOM_START + 19,
4583 EL_CUSTOM_START + 20,
4584 EL_CUSTOM_START + 21,
4585 EL_CUSTOM_START + 22,
4586 EL_CUSTOM_START + 23,
4588 EL_CUSTOM_START + 24,
4589 EL_CUSTOM_START + 25,
4590 EL_CUSTOM_START + 26,
4591 EL_CUSTOM_START + 27,
4593 EL_CUSTOM_START + 28,
4594 EL_CUSTOM_START + 29,
4595 EL_CUSTOM_START + 30,
4596 EL_CUSTOM_START + 31,
4598 EL_CUSTOM_START + 32,
4599 EL_CUSTOM_START + 33,
4600 EL_CUSTOM_START + 34,
4601 EL_CUSTOM_START + 35,
4603 EL_CUSTOM_START + 36,
4604 EL_CUSTOM_START + 37,
4605 EL_CUSTOM_START + 38,
4606 EL_CUSTOM_START + 39,
4608 EL_CUSTOM_START + 40,
4609 EL_CUSTOM_START + 41,
4610 EL_CUSTOM_START + 42,
4611 EL_CUSTOM_START + 43,
4613 EL_CUSTOM_START + 44,
4614 EL_CUSTOM_START + 45,
4615 EL_CUSTOM_START + 46,
4616 EL_CUSTOM_START + 47,
4618 EL_CUSTOM_START + 48,
4619 EL_CUSTOM_START + 49,
4620 EL_CUSTOM_START + 50,
4621 EL_CUSTOM_START + 51,
4623 EL_CUSTOM_START + 52,
4624 EL_CUSTOM_START + 53,
4625 EL_CUSTOM_START + 54,
4626 EL_CUSTOM_START + 55,
4628 EL_CUSTOM_START + 56,
4629 EL_CUSTOM_START + 57,
4630 EL_CUSTOM_START + 58,
4631 EL_CUSTOM_START + 59,
4633 EL_CUSTOM_START + 60,
4634 EL_CUSTOM_START + 61,
4635 EL_CUSTOM_START + 62,
4636 EL_CUSTOM_START + 63,
4638 EL_CUSTOM_START + 64,
4639 EL_CUSTOM_START + 65,
4640 EL_CUSTOM_START + 66,
4641 EL_CUSTOM_START + 67,
4643 EL_CUSTOM_START + 68,
4644 EL_CUSTOM_START + 69,
4645 EL_CUSTOM_START + 70,
4646 EL_CUSTOM_START + 71,
4648 EL_CUSTOM_START + 72,
4649 EL_CUSTOM_START + 73,
4650 EL_CUSTOM_START + 74,
4651 EL_CUSTOM_START + 75,
4653 EL_CUSTOM_START + 76,
4654 EL_CUSTOM_START + 77,
4655 EL_CUSTOM_START + 78,
4656 EL_CUSTOM_START + 79,
4658 EL_CUSTOM_START + 80,
4659 EL_CUSTOM_START + 81,
4660 EL_CUSTOM_START + 82,
4661 EL_CUSTOM_START + 83,
4663 EL_CUSTOM_START + 84,
4664 EL_CUSTOM_START + 85,
4665 EL_CUSTOM_START + 86,
4666 EL_CUSTOM_START + 87,
4668 EL_CUSTOM_START + 88,
4669 EL_CUSTOM_START + 89,
4670 EL_CUSTOM_START + 90,
4671 EL_CUSTOM_START + 91,
4673 EL_CUSTOM_START + 92,
4674 EL_CUSTOM_START + 93,
4675 EL_CUSTOM_START + 94,
4676 EL_CUSTOM_START + 95,
4678 EL_CUSTOM_START + 96,
4679 EL_CUSTOM_START + 97,
4680 EL_CUSTOM_START + 98,
4681 EL_CUSTOM_START + 99,
4683 EL_CUSTOM_START + 100,
4684 EL_CUSTOM_START + 101,
4685 EL_CUSTOM_START + 102,
4686 EL_CUSTOM_START + 103,
4688 EL_CUSTOM_START + 104,
4689 EL_CUSTOM_START + 105,
4690 EL_CUSTOM_START + 106,
4691 EL_CUSTOM_START + 107,
4693 EL_CUSTOM_START + 108,
4694 EL_CUSTOM_START + 109,
4695 EL_CUSTOM_START + 110,
4696 EL_CUSTOM_START + 111,
4698 EL_CUSTOM_START + 112,
4699 EL_CUSTOM_START + 113,
4700 EL_CUSTOM_START + 114,
4701 EL_CUSTOM_START + 115,
4703 EL_CUSTOM_START + 116,
4704 EL_CUSTOM_START + 117,
4705 EL_CUSTOM_START + 118,
4706 EL_CUSTOM_START + 119,
4708 EL_CUSTOM_START + 120,
4709 EL_CUSTOM_START + 121,
4710 EL_CUSTOM_START + 122,
4711 EL_CUSTOM_START + 123,
4713 EL_CUSTOM_START + 124,
4714 EL_CUSTOM_START + 125,
4715 EL_CUSTOM_START + 126,
4716 EL_CUSTOM_START + 127,
4718 EL_CUSTOM_START + 128,
4719 EL_CUSTOM_START + 129,
4720 EL_CUSTOM_START + 130,
4721 EL_CUSTOM_START + 131,
4723 EL_CUSTOM_START + 132,
4724 EL_CUSTOM_START + 133,
4725 EL_CUSTOM_START + 134,
4726 EL_CUSTOM_START + 135,
4728 EL_CUSTOM_START + 136,
4729 EL_CUSTOM_START + 137,
4730 EL_CUSTOM_START + 138,
4731 EL_CUSTOM_START + 139,
4733 EL_CUSTOM_START + 140,
4734 EL_CUSTOM_START + 141,
4735 EL_CUSTOM_START + 142,
4736 EL_CUSTOM_START + 143,
4738 EL_CUSTOM_START + 144,
4739 EL_CUSTOM_START + 145,
4740 EL_CUSTOM_START + 146,
4741 EL_CUSTOM_START + 147,
4743 EL_CUSTOM_START + 148,
4744 EL_CUSTOM_START + 149,
4745 EL_CUSTOM_START + 150,
4746 EL_CUSTOM_START + 151,
4748 EL_CUSTOM_START + 152,
4749 EL_CUSTOM_START + 153,
4750 EL_CUSTOM_START + 154,
4751 EL_CUSTOM_START + 155,
4753 EL_CUSTOM_START + 156,
4754 EL_CUSTOM_START + 157,
4755 EL_CUSTOM_START + 158,
4756 EL_CUSTOM_START + 159,
4758 EL_CUSTOM_START + 160,
4759 EL_CUSTOM_START + 161,
4760 EL_CUSTOM_START + 162,
4761 EL_CUSTOM_START + 163,
4763 EL_CUSTOM_START + 164,
4764 EL_CUSTOM_START + 165,
4765 EL_CUSTOM_START + 166,
4766 EL_CUSTOM_START + 167,
4768 EL_CUSTOM_START + 168,
4769 EL_CUSTOM_START + 169,
4770 EL_CUSTOM_START + 170,
4771 EL_CUSTOM_START + 171,
4773 EL_CUSTOM_START + 172,
4774 EL_CUSTOM_START + 173,
4775 EL_CUSTOM_START + 174,
4776 EL_CUSTOM_START + 175,
4778 EL_CUSTOM_START + 176,
4779 EL_CUSTOM_START + 177,
4780 EL_CUSTOM_START + 178,
4781 EL_CUSTOM_START + 179,
4783 EL_CUSTOM_START + 180,
4784 EL_CUSTOM_START + 181,
4785 EL_CUSTOM_START + 182,
4786 EL_CUSTOM_START + 183,
4788 EL_CUSTOM_START + 184,
4789 EL_CUSTOM_START + 185,
4790 EL_CUSTOM_START + 186,
4791 EL_CUSTOM_START + 187,
4793 EL_CUSTOM_START + 188,
4794 EL_CUSTOM_START + 189,
4795 EL_CUSTOM_START + 190,
4796 EL_CUSTOM_START + 191,
4798 EL_CUSTOM_START + 192,
4799 EL_CUSTOM_START + 193,
4800 EL_CUSTOM_START + 194,
4801 EL_CUSTOM_START + 195,
4803 EL_CUSTOM_START + 196,
4804 EL_CUSTOM_START + 197,
4805 EL_CUSTOM_START + 198,
4806 EL_CUSTOM_START + 199,
4808 EL_CUSTOM_START + 200,
4809 EL_CUSTOM_START + 201,
4810 EL_CUSTOM_START + 202,
4811 EL_CUSTOM_START + 203,
4813 EL_CUSTOM_START + 204,
4814 EL_CUSTOM_START + 205,
4815 EL_CUSTOM_START + 206,
4816 EL_CUSTOM_START + 207,
4818 EL_CUSTOM_START + 208,
4819 EL_CUSTOM_START + 209,
4820 EL_CUSTOM_START + 210,
4821 EL_CUSTOM_START + 211,
4823 EL_CUSTOM_START + 212,
4824 EL_CUSTOM_START + 213,
4825 EL_CUSTOM_START + 214,
4826 EL_CUSTOM_START + 215,
4828 EL_CUSTOM_START + 216,
4829 EL_CUSTOM_START + 217,
4830 EL_CUSTOM_START + 218,
4831 EL_CUSTOM_START + 219,
4833 EL_CUSTOM_START + 220,
4834 EL_CUSTOM_START + 221,
4835 EL_CUSTOM_START + 222,
4836 EL_CUSTOM_START + 223,
4838 EL_CUSTOM_START + 224,
4839 EL_CUSTOM_START + 225,
4840 EL_CUSTOM_START + 226,
4841 EL_CUSTOM_START + 227,
4843 EL_CUSTOM_START + 228,
4844 EL_CUSTOM_START + 229,
4845 EL_CUSTOM_START + 230,
4846 EL_CUSTOM_START + 231,
4848 EL_CUSTOM_START + 232,
4849 EL_CUSTOM_START + 233,
4850 EL_CUSTOM_START + 234,
4851 EL_CUSTOM_START + 235,
4853 EL_CUSTOM_START + 236,
4854 EL_CUSTOM_START + 237,
4855 EL_CUSTOM_START + 238,
4856 EL_CUSTOM_START + 239,
4858 EL_CUSTOM_START + 240,
4859 EL_CUSTOM_START + 241,
4860 EL_CUSTOM_START + 242,
4861 EL_CUSTOM_START + 243,
4863 EL_CUSTOM_START + 244,
4864 EL_CUSTOM_START + 245,
4865 EL_CUSTOM_START + 246,
4866 EL_CUSTOM_START + 247,
4868 EL_CUSTOM_START + 248,
4869 EL_CUSTOM_START + 249,
4870 EL_CUSTOM_START + 250,
4871 EL_CUSTOM_START + 251,
4873 EL_CUSTOM_START + 252,
4874 EL_CUSTOM_START + 253,
4875 EL_CUSTOM_START + 254,
4876 EL_CUSTOM_START + 255
4878 static int *editor_hl_custom_ptr = editor_hl_custom;
4879 static int *editor_el_custom_ptr = editor_el_custom;
4880 static int num_editor_hl_custom = SIZEOF_ARRAY_INT(editor_hl_custom);
4881 static int num_editor_el_custom = SIZEOF_ARRAY_INT(editor_el_custom);
4883 static int editor_hl_group[] =
4885 EL_INTERNAL_CASCADE_GE_ACTIVE,
4891 static int editor_el_group[] =
4905 EL_GROUP_START + 10,
4906 EL_GROUP_START + 11,
4908 EL_GROUP_START + 12,
4909 EL_GROUP_START + 13,
4910 EL_GROUP_START + 14,
4911 EL_GROUP_START + 15,
4913 EL_GROUP_START + 16,
4914 EL_GROUP_START + 17,
4915 EL_GROUP_START + 18,
4916 EL_GROUP_START + 19,
4918 EL_GROUP_START + 20,
4919 EL_GROUP_START + 21,
4920 EL_GROUP_START + 22,
4921 EL_GROUP_START + 23,
4923 EL_GROUP_START + 24,
4924 EL_GROUP_START + 25,
4925 EL_GROUP_START + 26,
4926 EL_GROUP_START + 27,
4928 EL_GROUP_START + 28,
4929 EL_GROUP_START + 29,
4930 EL_GROUP_START + 30,
4933 static int *editor_hl_group_ptr = editor_hl_group;
4934 static int *editor_el_group_ptr = editor_el_group;
4935 static int num_editor_hl_group = SIZEOF_ARRAY_INT(editor_hl_group);
4936 static int num_editor_el_group = SIZEOF_ARRAY_INT(editor_el_group);
4938 static int editor_hl_reference[] =
4940 EL_INTERNAL_CASCADE_REF_ACTIVE,
4946 static int editor_el_reference[] =
4950 EL_TRIGGER_CE_VALUE,
4951 EL_TRIGGER_CE_SCORE,
4955 EL_CURRENT_CE_VALUE,
4956 EL_CURRENT_CE_SCORE,
4978 static int *editor_hl_reference_ptr = editor_hl_reference;
4979 static int *editor_el_reference_ptr = editor_el_reference;
4980 static int num_editor_hl_reference = SIZEOF_ARRAY_INT(editor_hl_reference);
4981 static int num_editor_el_reference = SIZEOF_ARRAY_INT(editor_el_reference);
4983 static int editor_hl_user_defined[] =
4985 EL_INTERNAL_CASCADE_USER_ACTIVE,
4991 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
4992 static int *editor_el_user_defined_ptr = NULL;
4993 static int num_editor_hl_user_defined=SIZEOF_ARRAY_INT(editor_hl_user_defined);
4994 static int num_editor_el_user_defined = 0;
4996 static int editor_hl_dynamic[] =
4998 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
5004 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
5005 static int *editor_el_dynamic_ptr = NULL;
5006 static int num_editor_hl_dynamic = SIZEOF_ARRAY_INT(editor_hl_dynamic);
5007 static int num_editor_el_dynamic = 0;
5009 static int editor_hl_empty[] = { EL_EMPTY };
5010 static int *editor_el_empty = NULL; /* dynamically allocated */
5012 static int *editor_hl_empty_ptr = editor_hl_empty;
5013 static int *editor_el_empty_ptr = NULL;
5014 static int num_editor_hl_empty = 0;
5015 static int num_editor_el_empty = 0; /* dynamically determined, if needed */
5017 static boolean use_el_empty = FALSE;
5019 static int *editor_elements = NULL; /* dynamically allocated */
5020 static int num_editor_elements = 0; /* dynamically determined */
5022 static boolean setup_editor_cascade_never = FALSE;
5024 static int editor_hl_unused[] = { EL_EMPTY };
5025 static int *editor_hl_unused_ptr = editor_hl_unused;
5026 static int num_editor_hl_unused = 0;
5030 boolean *setup_value;
5031 boolean *setup_cascade_value;
5033 int **headline_list;
5034 int *headline_list_size;
5037 int *element_list_size;
5039 boolean last_setup_value;
5041 editor_elements_info[] =
5044 &setup.editor.el_classic,
5045 &setup_editor_cascade_never,
5046 &editor_hl_unused_ptr, &num_editor_hl_unused,
5047 &editor_el_players_ptr, &num_editor_el_players
5050 &setup.editor.el_classic,
5051 &setup.editor_cascade.el_bd,
5052 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
5053 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
5056 &setup.editor.el_classic,
5057 &setup.editor_cascade.el_em,
5058 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
5059 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
5062 &setup.editor.el_classic,
5063 &setup.editor_cascade.el_emc,
5064 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
5065 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
5068 &setup.editor.el_classic,
5069 &setup.editor_cascade.el_rnd,
5070 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
5071 &editor_el_rnd_ptr, &num_editor_el_rnd
5074 &setup.editor.el_classic,
5075 &setup.editor_cascade.el_sb,
5076 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
5077 &editor_el_sokoban_ptr, &num_editor_el_sokoban
5080 &setup.editor.el_classic,
5081 &setup.editor_cascade.el_sp,
5082 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
5083 &editor_el_supaplex_ptr, &num_editor_el_supaplex
5086 &setup.editor.el_classic,
5087 &setup.editor_cascade.el_dc,
5088 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
5089 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
5092 &setup.editor.el_classic,
5093 &setup.editor_cascade.el_dx,
5094 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
5095 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
5098 &setup.editor.el_classic,
5099 &setup.editor_cascade.el_mm,
5100 &editor_hl_mirror_magic_ptr, &num_editor_hl_mirror_magic,
5101 &editor_el_mirror_magic_ptr, &num_editor_el_mirror_magic
5104 &setup.editor.el_classic,
5105 &setup.editor_cascade.el_df,
5106 &editor_hl_deflektor_ptr, &num_editor_hl_deflektor,
5107 &editor_el_deflektor_ptr, &num_editor_el_deflektor
5110 &setup.editor.el_classic,
5111 &setup.editor_cascade.el_chars,
5112 &editor_hl_chars_ptr, &num_editor_hl_chars,
5113 &editor_el_chars_ptr, &num_editor_el_chars
5116 &setup.editor.el_classic,
5117 &setup.editor_cascade.el_steel_chars,
5118 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
5119 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
5122 &setup.editor.el_custom,
5123 &setup.editor_cascade.el_ce,
5124 &editor_hl_custom_ptr, &num_editor_hl_custom,
5125 &editor_el_custom_ptr, &num_editor_el_custom
5128 &setup.editor.el_custom,
5129 &setup.editor_cascade.el_ge,
5130 &editor_hl_group_ptr, &num_editor_hl_group,
5131 &editor_el_group_ptr, &num_editor_el_group
5134 &setup.editor.el_custom,
5135 &setup.editor_cascade.el_ref,
5136 &editor_hl_reference_ptr, &num_editor_hl_reference,
5137 &editor_el_reference_ptr, &num_editor_el_reference
5140 &setup.editor.el_user_defined,
5141 &setup.editor_cascade.el_user,
5142 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
5143 &editor_el_user_defined_ptr, &num_editor_el_user_defined
5146 &setup.editor.el_dynamic,
5147 &setup.editor_cascade.el_dynamic,
5148 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
5149 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
5154 &editor_hl_empty_ptr, &num_editor_hl_empty,
5155 &editor_el_empty_ptr, &num_editor_el_empty,
5167 -----------------------------------------------------------------------------
5169 -----------------------------------------------------------------------------
5172 static int getMaxInfoTextLength()
5174 return (SXSIZE / getFontWidth(INFOTEXT_FONT));
5177 static int getTextWidthForGadget(char *text)
5182 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
5185 static int getTextWidthForDrawingArea(char *text)
5190 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
5193 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
5195 return (gi->x + gi->width + getTextWidthForGadget(text));
5198 static char *getElementInfoText(int element)
5200 char *info_text = NULL;
5202 if (element < MAX_NUM_ELEMENTS)
5204 if (strlen(element_info[element].description) > 0)
5205 info_text = element_info[element].description;
5206 else if (element_info[element].custom_description != NULL)
5207 info_text = element_info[element].custom_description;
5208 else if (element_info[element].editor_description != NULL)
5209 info_text = element_info[element].editor_description;
5212 if (info_text == NULL)
5213 info_text = INFOTEXT_UNKNOWN_ELEMENT;
5218 static char *getElementDescriptionFilenameExt(char *basename)
5220 char *elements_subdir = "elements";
5221 static char *elements_subdir2 = NULL;
5222 static char *filename = NULL;
5224 if (elements_subdir2 == NULL)
5225 elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
5227 checked_free(filename);
5229 /* 1st try: look for element description in current level set directory */
5230 filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
5231 if (fileExists(filename))
5236 /* 2nd try: look for element description in the game's base directory */
5237 filename = getPath3(options.docs_directory, elements_subdir, basename);
5238 if (fileExists(filename))
5244 char *getElementDescriptionFilename(int element)
5246 char basename[MAX_FILENAME_LEN];
5249 /* 1st try: look for element description file for exactly this element */
5250 sprintf(basename, "%s.txt", element_info[element].token_name);
5251 filename = getElementDescriptionFilenameExt(basename);
5252 if (filename != NULL)
5255 /* 2nd try: look for element description file for this element's class */
5256 sprintf(basename, "%s.txt", element_info[element].class_name);
5257 filename = getElementDescriptionFilenameExt(basename);
5258 if (filename != NULL)
5264 static void InitDynamicEditorElementList(int **elements, int *num_elements)
5266 boolean element_found[NUM_FILE_ELEMENTS];
5269 /* initialize list of used elements to "not used" */
5270 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5271 element_found[i] = FALSE;
5273 /* find all elements used in current level */
5274 for (y = 0; y < lev_fieldy; y++)
5275 for (x = 0; x < lev_fieldx; x++)
5276 if (Feld[x][y] < NUM_FILE_ELEMENTS) /* should always be true */
5277 element_found[Feld[x][y]] = TRUE;
5281 /* count number of elements used in current level */
5282 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5283 if (element_found[i])
5286 /* add space for up to 3 more elements for padding that may be needed */
5289 /* free memory for old list of elements, if needed */
5290 checked_free(*elements);
5292 /* allocate memory for new list of elements */
5293 *elements = checked_malloc(*num_elements * sizeof(int));
5297 /* add all elements used in current level (non-custom/group elements) */
5298 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5299 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
5300 (*elements)[(*num_elements)++] = i;
5302 /* add all elements used in current level (custom/group elements) */
5303 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5304 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
5305 (*elements)[(*num_elements)++] = i;
5307 while (*num_elements % 4) /* pad with empty elements, if needed */
5308 (*elements)[(*num_elements)++] = EL_EMPTY;
5311 static void ReinitializeElementList()
5313 static boolean initialization_needed = TRUE;
5317 if (initialization_needed)
5319 LoadSetup_EditorCascade(); /* load last editor cascade state */
5321 /* initialize editor cascade element from saved cascade state */
5322 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5324 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
5325 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
5327 if (IS_EDITOR_CASCADE(*cascade_element))
5329 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
5330 EL_CASCADE_INACTIVE(*cascade_element));
5333 initialization_needed = FALSE;
5336 checked_free(editor_elements);
5338 /* reload optional user defined element list for each invocation of editor */
5339 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
5340 &num_editor_el_user_defined);
5342 /* initialize dynamic level element list for each invocation of editor */
5343 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
5344 &num_editor_el_dynamic);
5346 /* initialize list of empty elements (used for padding, if needed) */
5347 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
5348 editor_el_empty[i] = EL_EMPTY;
5350 /* do some sanity checks for each element from element list */
5351 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5353 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
5355 int element = (*editor_elements_info[i].element_list)[j];
5357 if (element >= NUM_FILE_ELEMENTS)
5358 Error(ERR_WARN, "editor element %d is runtime element", element);
5360 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
5361 Error(ERR_WARN, "no element description text for element %d", element);
5365 num_editor_elements = 0;
5366 use_el_empty = FALSE;
5368 /* determine size of element list */
5369 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5371 boolean found_inactive_cascade = FALSE;
5373 if (*editor_elements_info[i].setup_value)
5375 if (setup.editor.el_headlines)
5377 // required for correct padding of palette headline buttons
5378 if (*editor_elements_info[i].headline_list_size > 0)
5379 num_editor_elements += editor.palette.cols;
5381 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
5383 int element = (*editor_elements_info[i].headline_list)[j];
5385 if (IS_EDITOR_CASCADE_INACTIVE(element))
5386 found_inactive_cascade = TRUE;
5390 if (found_inactive_cascade)
5393 // required for correct padding of palette element buttons
5394 int element_list_size = *editor_elements_info[i].element_list_size;
5396 (element_list_size + editor.palette.cols - 1) / editor.palette.cols;
5397 int element_buttons = editor.palette.cols * element_rows;
5399 num_editor_elements += element_buttons;
5403 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
5405 /* offer at least as many elements as element buttons exist */
5406 use_el_empty = TRUE;
5407 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
5409 num_editor_elements += num_editor_el_empty;
5412 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
5414 /* fill element list */
5415 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5417 boolean found_inactive_cascade = FALSE;
5419 if (*editor_elements_info[i].setup_value)
5421 if (setup.editor.el_headlines)
5423 // required for correct padding of palette headline buttons
5424 int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
5425 editor.palette.cols : 0);
5427 for (j = 0; j < headline_size; j++)
5429 // use empty elements for padding of palette headline buttons
5430 int element = (j < *editor_elements_info[i].headline_list_size ?
5431 (*editor_elements_info[i].headline_list)[j] :
5432 editor_el_empty[0]);
5434 editor_elements[pos++] = element;
5436 if (IS_EDITOR_CASCADE_INACTIVE(element))
5437 found_inactive_cascade = TRUE;
5441 if (found_inactive_cascade)
5444 // required for correct padding of palette element buttons
5445 int element_list_size = *editor_elements_info[i].element_list_size;
5447 (element_list_size + editor.palette.cols - 1) / editor.palette.cols;
5448 int element_buttons = editor.palette.cols * element_rows;
5450 // copy all elements from element list
5451 for (j = 0; j < element_list_size; j++)
5452 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
5454 // use empty elements for padding of palette element buttons
5455 for (j = 0; j < element_buttons - element_list_size; j++)
5456 editor_elements[pos++] = editor_el_empty[0];
5460 /* (this function is also called before editor gadgets are initialized!) */
5461 AdjustElementListScrollbar();
5464 void PrintEditorElementList()
5466 boolean *stop = &setup.editor.el_user_defined;
5469 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
5471 int cascade_element = (*editor_elements_info[i].headline_list)[0];
5473 if (IS_EDITOR_CASCADE(cascade_element))
5475 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
5476 char *headline = element_info[cascade_element_show].editor_description;
5478 PrintLineWithPrefix("# ", "-", 77);
5479 Print("# %s\n", headline);
5480 PrintLineWithPrefix("# ", "-", 77);
5483 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
5485 int element = (*editor_elements_info[i].headline_list)[j];
5487 if (IS_EDITOR_CASCADE(element))
5488 element = EL_CHAR_MINUS;
5490 Print("# %s\n", element_info[element].token_name);
5496 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
5498 int element = (*editor_elements_info[i].element_list)[j];
5500 Print("# %s\n", element_info[element].token_name);
5508 static void ReinitializeElementListButtons()
5510 static boolean last_setup_value_headlines = FALSE;
5511 static boolean initialization_needed = TRUE;
5514 if (!initialization_needed) /* check if editor element setup has changed */
5516 if (last_setup_value_headlines != setup.editor.el_headlines)
5517 initialization_needed = TRUE;
5519 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5520 if (editor_elements_info[i].last_setup_value !=
5521 *editor_elements_info[i].setup_value)
5522 initialization_needed = TRUE;
5525 if (!initialization_needed)
5528 FreeLevelEditorGadgets();
5529 CreateLevelEditorGadgets();
5531 /* store current setup values for next invocation of this function */
5532 last_setup_value_headlines = setup.editor.el_headlines;
5533 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5534 editor_elements_info[i].last_setup_value =
5535 *editor_elements_info[i].setup_value;
5537 initialization_needed = FALSE;
5540 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
5543 int border_graphic =
5544 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
5545 struct GraphicInfo *g = &graphic_info[border_graphic];
5546 Bitmap *src_bitmap = g->bitmap;
5547 int src_x = g->src_x;
5548 int src_y = g->src_y;
5549 int border_size = g->border_size;
5550 int border_xpos = g->width - border_size;
5551 int border_ypos = g->height - border_size;
5552 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
5555 BlitBitmap(src_bitmap, drawto, src_x, src_y,
5556 border_size, border_size,
5557 dest_x - border_size, dest_y - border_size);
5558 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y,
5559 border_size, border_size,
5560 dest_x + width, dest_y - border_size);
5561 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_ypos,
5562 border_size, border_size,
5563 dest_x - border_size, dest_y + height);
5564 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_ypos,
5565 border_size, border_size,
5566 dest_x + width, dest_y + height);
5568 for (i = 0; i < width / tilesize; i++)
5570 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y,
5571 tilesize, border_size,
5572 dest_x + i * tilesize, dest_y - border_size);
5573 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y + border_ypos,
5574 tilesize, border_size,
5575 dest_x + i * tilesize, dest_y + height);
5578 for (i = 0; i < height / tilesize; i++)
5580 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_size,
5581 border_size, tilesize,
5582 dest_x - border_size, dest_y + i * tilesize);
5583 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_size,
5584 border_size, tilesize,
5585 dest_x + width, dest_y + i * tilesize);
5588 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
5591 static void DrawEditorElement(int x, int y, int element)
5593 DrawSizedElement(x, y, element, ed_tilesize);
5596 static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
5598 DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
5601 static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
5603 DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
5606 static void DrawDrawingArea(int id)
5608 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
5611 int *value = drawingarea_info[id].value;
5612 int area_xsize = drawingarea_info[id].area_xsize;
5613 int area_ysize = drawingarea_info[id].area_ysize;
5614 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
5616 for (x = 0; x < area_xsize; x++)
5617 for (y = 0; y < area_ysize; y++)
5618 DrawSizedGraphicExt(drawto,
5619 gi->x + x * tilesize,
5620 gi->y + y * tilesize,
5621 el2edimg(value[x * area_ysize + y]), 0, tilesize);
5624 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
5627 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
5628 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
5630 BlitBitmap(drawto, drawto,
5631 SX + (dx == -1 ? ed_tilesize : 0),
5632 SY + (dy == -1 ? ed_tilesize : 0),
5633 (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
5634 (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
5635 SX + (dx == +1 ? ed_tilesize : 0),
5636 SY + (dy == +1 ? ed_tilesize : 0));
5640 x = (dx == 1 ? 0 : ed_fieldx - 1);
5641 for (y = 0; y < ed_fieldy; y++)
5642 DrawEditorElementOrWall(x, y, from_x, from_y);
5646 y = (dy == 1 ? 0 : ed_fieldy - 1);
5647 for (x = 0; x < ed_fieldx; x++)
5648 DrawEditorElementOrWall(x, y, from_x, from_y);
5651 redraw_mask |= REDRAW_FIELD;
5655 void getEditorGraphicSource(int element, int tile_size, Bitmap **bitmap,
5658 getSizedGraphicSource(el2edimg(element), 0, tile_size, bitmap, x, y);
5661 static void CreateControlButtons()
5663 struct GadgetInfo *gi;
5666 /* create toolbox buttons */
5667 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
5669 int id = controlbutton_info[i].gadget_id;
5670 int type = controlbutton_info[i].gadget_type;
5671 int graphic = controlbutton_info[i].graphic;
5672 struct XYTileSize *pos = controlbutton_info[i].pos;
5673 struct GraphicInfo *gd = &graphic_info[graphic];
5674 Bitmap *deco_bitmap = NULL;
5675 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
5676 int tile_size = 0, deco_shift = 0;
5677 boolean deco_masked = FALSE;
5678 int gd_x1 = gd->src_x;
5679 int gd_y1 = gd->src_y;
5680 int gd_x2 = gd->src_x + gd->pressed_xoffset;
5681 int gd_y2 = gd->src_y + gd->pressed_yoffset;
5682 int gd_x1a = gd->src_x + gd->active_xoffset;
5683 int gd_y1a = gd->src_y + gd->active_yoffset;
5684 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
5685 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
5688 unsigned int event_mask;
5689 int radio_button_nr = RADIO_NR_NONE;
5690 boolean checked = FALSE;
5692 if (type == GD_TYPE_RADIO_BUTTON)
5694 event_mask = GD_EVENT_PRESSED;
5695 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
5697 if (id == drawing_function)
5702 if (id == GADGET_ID_WRAP_LEFT ||
5703 id == GADGET_ID_WRAP_RIGHT ||
5704 id == GADGET_ID_WRAP_UP ||
5705 id == GADGET_ID_WRAP_DOWN)
5706 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5708 event_mask = GD_EVENT_RELEASED;
5711 if (id == GADGET_ID_PROPERTIES ||
5712 id == GADGET_ID_PALETTE)
5717 else if (id == GADGET_ID_ELEMENT_LEFT ||
5718 id == GADGET_ID_ELEMENT_MIDDLE ||
5719 id == GADGET_ID_ELEMENT_RIGHT)
5724 int element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
5725 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
5726 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : EL_EMPTY);
5728 tile_size = BUTTON_TILE_SIZE(id == GADGET_ID_ELEMENT_LEFT ?
5729 editor.button.element_left.tile_size :
5730 id == GADGET_ID_ELEMENT_MIDDLE ?
5731 editor.button.element_middle.tile_size :
5732 id == GADGET_ID_ELEMENT_RIGHT ?
5733 editor.button.element_right.tile_size : 0);
5735 // make sure that decoration does not overlap gadget border
5736 tile_size = MIN(tile_size, MIN(gd->width, gd->height));
5738 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x,&deco_y);
5740 deco_xpos = (gd->width - tile_size) / 2;
5741 deco_ypos = (gd->height - tile_size) / 2;
5743 deco_masked = gd->draw_masked;
5751 gi = CreateGadget(GDI_CUSTOM_ID, id,
5752 GDI_CUSTOM_TYPE_ID, i,
5753 GDI_INFO_TEXT, controlbutton_info[i].infotext,
5756 GDI_WIDTH, gd->width,
5757 GDI_HEIGHT, gd->height,
5759 GDI_STATE, GD_BUTTON_UNPRESSED,
5760 GDI_RADIO_NR, radio_button_nr,
5761 GDI_CHECKED, checked,
5762 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
5763 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
5764 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
5765 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
5766 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
5767 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
5768 GDI_DECORATION_SIZE, tile_size, tile_size,
5769 GDI_DECORATION_SHIFTING, deco_shift, deco_shift,
5770 GDI_DECORATION_MASKED, deco_masked,
5771 GDI_EVENT_MASK, event_mask,
5772 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5773 GDI_CALLBACK_ACTION, HandleControlButtons,
5777 Error(ERR_EXIT, "cannot create gadget");
5779 level_editor_gadget[id] = gi;
5782 /* these values are not constant, but can change at runtime */
5783 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
5784 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
5785 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
5786 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
5787 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
5788 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
5789 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
5790 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
5791 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].x = ED_SCROLL2_UP_XPOS;
5792 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y = ED_SCROLL2_UP_YPOS;
5793 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x = ED_SCROLL2_DOWN_XPOS;
5794 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y = ED_SCROLL2_DOWN_YPOS;
5796 /* create buttons for scrolling of drawing area and element list */
5797 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
5799 int id = scrollbutton_info[i].gadget_id;
5800 int graphic = scrollbutton_info[i].graphic;
5801 struct GraphicInfo *gd = &graphic_info[graphic];
5802 Bitmap *gd_bitmap = gd->bitmap;
5803 int gd_x1 = gd->src_x;
5804 int gd_y1 = gd->src_y;
5805 int gd_x2 = gd->src_x + gd->pressed_xoffset;
5806 int gd_y2 = gd->src_y + gd->pressed_yoffset;
5807 int width = gd->width;
5808 int height = gd->height;
5809 int x = scrollbutton_pos[i].x;
5810 int y = scrollbutton_pos[i].y;
5811 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5813 if (id == GADGET_ID_SCROLL_LIST_UP ||
5814 id == GADGET_ID_SCROLL_LIST_DOWN)
5825 gi = CreateGadget(GDI_CUSTOM_ID, id,
5826 GDI_CUSTOM_TYPE_ID, i,
5827 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
5832 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
5833 GDI_STATE, GD_BUTTON_UNPRESSED,
5834 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5835 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
5836 GDI_EVENT_MASK, event_mask,
5837 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5838 GDI_CALLBACK_ACTION, HandleControlButtons,
5842 Error(ERR_EXIT, "cannot create gadget");
5844 level_editor_gadget[id] = gi;
5847 /* create buttons for element list */
5848 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
5850 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
5851 int graphic = IMG_EDITOR_PALETTE_BUTTON;
5852 struct GraphicInfo *gd = &graphic_info[graphic];
5853 Bitmap *gd_bitmap = gd->bitmap;
5854 Bitmap *deco_bitmap;
5855 int deco_x, deco_y, deco_xpos, deco_ypos;
5856 int gd_x1 = gd->src_x;
5857 int gd_y1 = gd->src_y;
5858 int gd_x2 = gd->src_x + gd->pressed_xoffset;
5859 int gd_y2 = gd->src_y + gd->pressed_yoffset;
5860 int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
5861 int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
5862 int x = PX + ED_ELEMENTLIST_XPOS + xx * gd->width;
5863 int y = PY + ED_ELEMENTLIST_YPOS + yy * gd->height;
5864 int element = editor_elements[i];
5865 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
5866 unsigned int event_mask = GD_EVENT_RELEASED;
5868 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
5870 deco_xpos = (gd->width - tile_size) / 2;
5871 deco_ypos = (gd->height - tile_size) / 2;
5873 gi = CreateGadget(GDI_CUSTOM_ID, id,
5874 GDI_CUSTOM_TYPE_ID, i,
5875 GDI_INFO_TEXT, getElementInfoText(element),
5878 GDI_WIDTH, gd->width,
5879 GDI_HEIGHT, gd->height,
5880 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
5881 GDI_STATE, GD_BUTTON_UNPRESSED,
5882 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
5883 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
5884 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
5885 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
5886 GDI_DECORATION_SIZE, tile_size, tile_size,
5887 GDI_DECORATION_SHIFTING, 1, 1,
5888 GDI_EVENT_MASK, event_mask,
5889 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5890 GDI_CALLBACK_ACTION, HandleControlButtons,
5894 Error(ERR_EXIT, "cannot create gadget");
5896 level_editor_gadget[id] = gi;
5900 static void CreateCounterButtons()
5902 int max_infotext_len = getMaxInfoTextLength();
5905 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
5908 int x = SX + ED_SETTINGS_X(counterbutton_info[i].x); /* down count button */
5909 int y = SY + ED_SETTINGS_Y(counterbutton_info[i].y);
5911 /* determine horizontal position to the right of specified gadget */
5912 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
5913 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
5914 ED_GADGET_TEXT_DISTANCE);
5916 /* determine horizontal offset for leading text */
5917 if (counterbutton_info[i].text_left != NULL)
5918 x += getTextWidthForGadget(counterbutton_info[i].text_left);
5920 for (j = 0; j < 2; j++)
5922 struct GadgetInfo *gi;
5924 counterbutton_info[i].gadget_id_down :
5925 counterbutton_info[i].gadget_id_up);
5927 struct GraphicInfo *gd;
5928 int gd_x1, gd_x2, gd_y1, gd_y2;
5929 unsigned int event_mask;
5930 char infotext[max_infotext_len + 1];
5932 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
5934 if (i == ED_COUNTER_ID_SELECT_LEVEL)
5937 IMG_GFX_EDITOR_BUTTON_PREV_LEVEL :
5938 IMG_GFX_EDITOR_BUTTON_NEXT_LEVEL);
5940 event_mask |= GD_EVENT_RELEASED;
5944 x = DX + editor.button.prev_level.x;
5945 y = DY + editor.button.prev_level.y;
5949 x = DX + editor.button.next_level.x;
5950 y = DY + editor.button.next_level.y;
5956 IMG_EDITOR_COUNTER_DOWN :
5957 IMG_EDITOR_COUNTER_UP);
5960 gd = &graphic_info[graphic];
5964 gd_x2 = gd->src_x + gd->pressed_xoffset;
5965 gd_y2 = gd->src_y + gd->pressed_yoffset;
5967 sprintf(infotext, "%s counter value by 1, 5 or 10",
5968 (j == 0 ? "decrease" : "increase"));
5970 gi = CreateGadget(GDI_CUSTOM_ID, id,
5971 GDI_CUSTOM_TYPE_ID, i,
5972 GDI_INFO_TEXT, infotext,
5975 GDI_WIDTH, gd->width,
5976 GDI_HEIGHT, gd->height,
5977 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
5978 GDI_STATE, GD_BUTTON_UNPRESSED,
5979 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
5980 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
5981 GDI_EVENT_MASK, event_mask,
5982 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
5983 GDI_CALLBACK_ACTION, HandleCounterButtons,
5987 Error(ERR_EXIT, "cannot create gadget");
5989 level_editor_gadget[id] = gi;
5990 right_gadget_border[id] =
5991 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
5993 x += gi->width + ED_GADGET_SMALL_DISTANCE; /* text count button */
5997 int font_type = FONT_INPUT_1;
5998 int font_type_active = FONT_INPUT_1_ACTIVE;
6000 id = counterbutton_info[i].gadget_id_text;
6002 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6004 if (i == ED_COUNTER_ID_SELECT_LEVEL)
6006 graphic = IMG_GFX_EDITOR_INPUT_LEVEL_NUMBER;
6008 font_type = FONT_LEVEL_NUMBER;
6009 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
6011 x = DX + editor.input.level_number.x;
6012 y = DY + editor.input.level_number.y;
6016 graphic = IMG_EDITOR_COUNTER_INPUT;
6019 gd = &graphic_info[graphic];
6023 gd_x2 = gd->src_x + gd->active_xoffset;
6024 gd_y2 = gd->src_y + gd->active_yoffset;
6026 gi = CreateGadget(GDI_CUSTOM_ID, id,
6027 GDI_CUSTOM_TYPE_ID, i,
6028 GDI_INFO_TEXT, "enter counter value",
6031 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
6032 GDI_NUMBER_VALUE, 0,
6033 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
6034 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
6035 GDI_TEXT_SIZE, 3, /* minimal counter text size */
6036 GDI_TEXT_FONT, font_type,
6037 GDI_TEXT_FONT_ACTIVE, font_type_active,
6038 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6039 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6040 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6041 GDI_DESIGN_WIDTH, gd->width,
6042 GDI_EVENT_MASK, event_mask,
6043 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6044 GDI_CALLBACK_ACTION, HandleCounterButtons,
6048 Error(ERR_EXIT, "cannot create gadget");
6050 level_editor_gadget[id] = gi;
6051 right_gadget_border[id] =
6052 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
6054 x += gi->width + ED_GADGET_SMALL_DISTANCE; /* up count button */
6060 static void CreateDrawingAreas()
6064 /* these values are not constant, but can change at runtime */
6065 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
6066 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
6068 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
6070 struct GadgetInfo *gi;
6071 unsigned int event_mask;
6072 int id = drawingarea_info[i].gadget_id;
6073 int x = SX + ED_AREA_SETTINGS_X(drawingarea_info[i]);
6074 int y = SY + ED_AREA_SETTINGS_Y(drawingarea_info[i]);
6075 int area_xsize = drawingarea_info[i].area_xsize;
6076 int area_ysize = drawingarea_info[i].area_ysize;
6077 int item_size = (id == GADGET_ID_DRAWING_LEVEL ?
6078 ed_tilesize : ED_DRAWINGAREA_TILE_SIZE);
6081 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
6082 GD_EVENT_OFF_BORDERS;
6084 /* determine horizontal position to the right of specified gadget */
6085 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
6086 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
6087 ED_DRAWINGAREA_TEXT_DISTANCE);
6089 /* determine horizontal offset for leading text */
6090 if (drawingarea_info[i].text_left != NULL)
6091 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
6093 gi = CreateGadget(GDI_CUSTOM_ID, id,
6094 GDI_CUSTOM_TYPE_ID, i,
6097 GDI_TYPE, GD_TYPE_DRAWING_AREA,
6098 GDI_AREA_SIZE, area_xsize, area_ysize,
6099 GDI_ITEM_SIZE, item_size, item_size,
6100 GDI_EVENT_MASK, event_mask,
6101 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
6102 GDI_CALLBACK_ACTION, HandleDrawingAreas,
6106 Error(ERR_EXIT, "cannot create gadget");
6108 level_editor_gadget[id] = gi;
6109 right_gadget_border[id] =
6110 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
6114 static void CreateTextInputGadgets()
6116 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
6117 int max_infotext_len = getMaxInfoTextLength();
6120 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
6122 int gd_x1 = gd->src_x;
6123 int gd_y1 = gd->src_y;
6124 int gd_x2 = gd->src_x + gd->active_xoffset;
6125 int gd_y2 = gd->src_y + gd->active_yoffset;
6126 struct GadgetInfo *gi;
6127 unsigned int event_mask;
6128 char infotext[MAX_OUTPUT_LINESIZE + 1];
6129 int id = textinput_info[i].gadget_id;
6132 if (i == ED_TEXTINPUT_ID_ELEMENT_NAME)
6134 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
6135 int border_size = gd->border_size;
6136 int font_nr = FONT_INPUT_1;
6137 int font_height = getFontHeight(font_nr);
6138 int xoffset = element_border + TILEX + element_border + 3 * border_size;
6139 int yoffset = element_border + (TILEY - font_height) / 2;
6141 x = (editor.settings.element_name.x != -1 ?
6142 editor.settings.element_name.x :
6143 editor.settings.element_graphic.x + xoffset) - border_size;
6144 y = (editor.settings.element_name.y != -1 ?
6145 editor.settings.element_name.y :
6146 editor.settings.element_graphic.y + yoffset) - border_size;
6150 x = ED_SETTINGS_X(textinput_info[i].x);
6151 y = ED_SETTINGS_Y(textinput_info[i].y);
6154 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6156 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
6157 infotext[max_infotext_len] = '\0';
6159 gi = CreateGadget(GDI_CUSTOM_ID, id,
6160 GDI_CUSTOM_TYPE_ID, i,
6161 GDI_INFO_TEXT, infotext,
6164 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
6165 GDI_TEXT_VALUE, textinput_info[i].value,
6166 GDI_TEXT_SIZE, textinput_info[i].size,
6167 GDI_TEXT_FONT, FONT_INPUT_1,
6168 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6169 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6170 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6171 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6172 GDI_DESIGN_WIDTH, gd->width,
6173 GDI_EVENT_MASK, event_mask,
6174 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6175 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
6179 Error(ERR_EXIT, "cannot create gadget");
6181 level_editor_gadget[id] = gi;
6185 static void CreateTextAreaGadgets()
6187 int max_infotext_len = getMaxInfoTextLength();
6190 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
6192 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXTAREA];
6193 int gd_x1 = gd->src_x;
6194 int gd_y1 = gd->src_y;
6195 int gd_x2 = gd->src_x + gd->active_xoffset;
6196 int gd_y2 = gd->src_y + gd->active_yoffset;
6197 struct GadgetInfo *gi;
6198 unsigned int event_mask;
6199 char infotext[MAX_OUTPUT_LINESIZE + 1];
6200 int id = textarea_info[i].gadget_id;
6201 int area_xsize = textarea_info[i].xsize;
6202 int area_ysize = textarea_info[i].ysize;
6204 event_mask = GD_EVENT_TEXT_LEAVING;
6206 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
6207 infotext[max_infotext_len] = '\0';
6209 gi = CreateGadget(GDI_CUSTOM_ID, id,
6210 GDI_CUSTOM_TYPE_ID, i,
6211 GDI_INFO_TEXT, infotext,
6212 GDI_X, SX + ED_SETTINGS_X(textarea_info[i].x),
6213 GDI_Y, SY + ED_SETTINGS_Y(textarea_info[i].y),
6214 GDI_TYPE, GD_TYPE_TEXT_AREA,
6215 GDI_AREA_SIZE, area_xsize, area_ysize,
6216 GDI_TEXT_FONT, FONT_INPUT_1,
6217 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6218 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6219 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6220 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6221 GDI_DESIGN_WIDTH, gd->width,
6222 GDI_EVENT_MASK, event_mask,
6223 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6224 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
6228 Error(ERR_EXIT, "cannot create gadget");
6230 level_editor_gadget[id] = gi;
6234 static void CreateSelectboxGadgets()
6236 int max_infotext_len = getMaxInfoTextLength();
6239 for (i = 0; i < ED_NUM_SELECTBOX; i++)
6241 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_SELECTBOX_INPUT];
6242 struct GraphicInfo *gd2 = &graphic_info[IMG_EDITOR_SELECTBOX_BUTTON];
6243 int gd_x1 = gd->src_x;
6244 int gd_y1 = gd->src_y;
6245 int gd_x2 = gd->src_x + gd->active_xoffset;
6246 int gd_y2 = gd->src_y + gd->active_yoffset;
6247 int selectbox_button_xsize = gd2->width;
6248 struct GadgetInfo *gi;
6249 unsigned int event_mask;
6250 char infotext[MAX_OUTPUT_LINESIZE + 1];
6251 int id = selectbox_info[i].gadget_id;
6252 int x = SX + ED_SETTINGS_X(selectbox_info[i].x);
6253 int y = SY + ED_SETTINGS_Y(selectbox_info[i].y);
6255 if (selectbox_info[i].size == -1) /* dynamically determine size */
6257 /* (we cannot use -1 for uninitialized values if we directly compare
6258 with results from strlen(), because the '<' and '>' operation will
6259 implicitely cast -1 to an unsigned integer value!) */
6260 selectbox_info[i].size = 0;
6262 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
6263 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
6264 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
6266 selectbox_info[i].size++; /* add one character empty space */
6269 event_mask = GD_EVENT_RELEASED |
6270 GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6272 /* determine horizontal position to the right of specified gadget */
6273 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
6274 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
6275 ED_GADGET_TEXT_DISTANCE);
6277 /* determine horizontal offset for leading text */
6278 if (selectbox_info[i].text_left != NULL)
6279 x += getTextWidthForGadget(selectbox_info[i].text_left);
6281 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
6282 infotext[max_infotext_len] = '\0';
6284 gi = CreateGadget(GDI_CUSTOM_ID, id,
6285 GDI_CUSTOM_TYPE_ID, i,
6286 GDI_INFO_TEXT, infotext,
6289 GDI_TYPE, GD_TYPE_SELECTBOX,
6290 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
6291 GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
6292 GDI_TEXT_SIZE, selectbox_info[i].size,
6293 GDI_TEXT_FONT, FONT_INPUT_1,
6294 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6295 GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
6296 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6297 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6298 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6299 GDI_BORDER_SIZE_SELECTBUTTON, selectbox_button_xsize,
6300 GDI_DESIGN_WIDTH, gd->width,
6301 GDI_EVENT_MASK, event_mask,
6302 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6303 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
6307 Error(ERR_EXIT, "cannot create gadget");
6309 level_editor_gadget[id] = gi;
6310 right_gadget_border[id] =
6311 getRightGadgetBorder(gi, selectbox_info[i].text_right);
6315 static void CreateTextbuttonGadgets()
6317 int max_infotext_len = getMaxInfoTextLength();
6320 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
6322 int id = textbutton_info[i].gadget_id;
6324 ((id >= GADGET_ID_LEVELINFO_LEVEL && id <= GADGET_ID_LEVELINFO_EDITOR) ||
6325 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE));
6327 (is_tab_button ? IMG_EDITOR_TABBUTTON : IMG_EDITOR_TEXTBUTTON);
6328 int gadget_distance =
6329 (is_tab_button ? ED_GADGET_SMALL_DISTANCE : ED_GADGET_TEXT_DISTANCE);
6330 struct GraphicInfo *gd = &graphic_info[graphic];
6331 int gd_x1 = gd->src_x;
6332 int gd_y1 = gd->src_y;
6333 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6334 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6335 int gd_x1a = gd->src_x + gd->active_xoffset;
6336 int gd_y1a = gd->src_y + gd->active_yoffset;
6337 int border_xsize = gd->border_size + gd->draw_xoffset;
6338 int border_ysize = gd->border_size;
6339 struct GadgetInfo *gi;
6340 unsigned int event_mask;
6341 char infotext[MAX_OUTPUT_LINESIZE + 1];
6342 int x = SX + ED_SETTINGS_X(textbutton_info[i].x);
6343 int y = SY + ED_SETTINGS_Y(textbutton_info[i].y);
6345 if (textbutton_info[i].size == -1) /* dynamically determine size */
6346 textbutton_info[i].size = strlen(textbutton_info[i].text);
6348 event_mask = GD_EVENT_RELEASED;
6350 sprintf(infotext, "%s", textbutton_info[i].infotext);
6351 infotext[max_infotext_len] = '\0';
6353 /* determine horizontal position to the right of specified gadget */
6354 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6356 int gadget_id_align = textbutton_info[i].gadget_id_align;
6358 x = right_gadget_border[gadget_id_align] + gadget_distance;
6360 if (textbutton_info[i].y == -1)
6361 y = level_editor_gadget[gadget_id_align]->y;
6364 /* determine horizontal offset for leading text */
6365 if (textbutton_info[i].text_left != NULL)
6366 x += getTextWidthForGadget(textbutton_info[i].text_left);
6368 gi = CreateGadget(GDI_CUSTOM_ID, id,
6369 GDI_CUSTOM_TYPE_ID, i,
6370 GDI_INFO_TEXT, infotext,
6373 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
6374 GDI_TEXT_VALUE, textbutton_info[i].text,
6375 GDI_TEXT_SIZE, textbutton_info[i].size,
6376 GDI_TEXT_FONT, FONT_INPUT_2,
6377 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2_ACTIVE,
6378 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6379 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6380 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6381 GDI_BORDER_SIZE, border_xsize, border_ysize,
6382 GDI_DESIGN_WIDTH, gd->width,
6383 GDI_DECORATION_SHIFTING, 1, 1,
6384 GDI_EVENT_MASK, event_mask,
6385 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6386 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
6390 Error(ERR_EXIT, "cannot create gadget");
6392 level_editor_gadget[id] = gi;
6393 right_gadget_border[id] =
6394 getRightGadgetBorder(gi, textbutton_info[i].text_right);
6398 static void CreateGraphicbuttonGadgets()
6400 struct GadgetInfo *gi;
6401 unsigned int event_mask;
6404 /* create buttons for scrolling of drawing area and element list */
6405 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
6407 int id = graphicbutton_info[i].gadget_id;
6408 int x = SX + ED_SETTINGS_X(graphicbutton_info[i].x);
6409 int y = SY + ED_SETTINGS_Y(graphicbutton_info[i].y);
6410 struct GraphicInfo *gd = &graphic_info[graphicbutton_info[i].graphic];
6411 int gd_x1 = gd->src_x;
6412 int gd_y1 = gd->src_y;
6413 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6414 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6416 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6418 /* determine horizontal position to the right of specified gadget */
6419 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6420 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
6421 ED_GADGET_TEXT_DISTANCE);
6423 /* determine horizontal offset for leading text */
6424 if (graphicbutton_info[i].text_left != NULL)
6425 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
6427 gi = CreateGadget(GDI_CUSTOM_ID, id,
6428 GDI_CUSTOM_TYPE_ID, i,
6429 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
6432 GDI_WIDTH, gd->width,
6433 GDI_HEIGHT, gd->height,
6434 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6435 GDI_STATE, GD_BUTTON_UNPRESSED,
6436 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6437 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6438 GDI_EVENT_MASK, event_mask,
6439 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6440 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
6444 Error(ERR_EXIT, "cannot create gadget");
6446 level_editor_gadget[id] = gi;
6447 right_gadget_border[id] =
6448 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
6452 static void CreateScrollbarGadgets()
6456 /* these values are not constant, but can change at runtime */
6457 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
6458 SX + ED_SCROLL_HORIZONTAL_XPOS;
6459 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
6460 SY + ED_SCROLL_HORIZONTAL_YPOS;
6461 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
6462 ED_SCROLL_HORIZONTAL_XSIZE;
6463 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
6464 ED_SCROLL_HORIZONTAL_YSIZE;
6465 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
6466 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
6467 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
6468 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
6470 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
6471 SX + ED_SCROLL_VERTICAL_XPOS;
6472 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
6473 SY + ED_SCROLL_VERTICAL_YPOS;
6474 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
6475 ED_SCROLL_VERTICAL_XSIZE;
6476 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
6477 ED_SCROLL_VERTICAL_YSIZE;
6478 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
6479 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
6480 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
6481 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
6483 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
6484 PX + ED_SCROLL2_VERTICAL_XPOS;
6485 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
6486 PY + ED_SCROLL2_VERTICAL_YPOS;
6487 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
6488 ED_SCROLL2_VERTICAL_XSIZE;
6489 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
6490 ED_SCROLL2_VERTICAL_YSIZE;
6491 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = PX;
6492 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = PY;
6493 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width = PXSIZE;
6494 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = PYSIZE;
6496 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
6498 int id = scrollbar_info[i].gadget_id;
6499 int graphic = scrollbar_info[i].graphic;
6500 struct GraphicInfo *gd = &graphic_info[graphic];
6501 int gd_x1 = gd->src_x;
6502 int gd_y1 = gd->src_y;
6503 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6504 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6505 struct GadgetInfo *gi;
6506 int items_max, items_visible, item_position;
6507 unsigned int event_mask;
6509 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
6511 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
6512 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
6513 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
6515 else /* drawing area scrollbars */
6517 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
6519 items_max = MAX(lev_fieldx + 2, ed_fieldx);
6520 items_visible = ed_fieldx;
6525 items_max = MAX(lev_fieldy + 2, ed_fieldy);
6526 items_visible = ed_fieldy;
6531 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
6533 gi = CreateGadget(GDI_CUSTOM_ID, id,
6534 GDI_CUSTOM_TYPE_ID, i,
6535 GDI_INFO_TEXT, scrollbar_info[i].infotext,
6536 GDI_X, scrollbar_pos[i].x,
6537 GDI_Y, scrollbar_pos[i].y,
6538 GDI_WIDTH, scrollbar_pos[i].width,
6539 GDI_HEIGHT, scrollbar_pos[i].height,
6540 GDI_TYPE, scrollbar_info[i].type,
6541 GDI_SCROLLBAR_ITEMS_MAX, items_max,
6542 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
6543 GDI_SCROLLBAR_ITEM_POSITION, item_position,
6544 GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
6545 GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
6546 GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
6547 GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
6548 GDI_STATE, GD_BUTTON_UNPRESSED,
6549 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6550 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6551 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6552 GDI_EVENT_MASK, event_mask,
6553 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6554 GDI_CALLBACK_ACTION, HandleControlButtons,
6558 Error(ERR_EXIT, "cannot create gadget");
6560 level_editor_gadget[id] = gi;
6564 static void CreateCheckbuttonGadgets()
6566 struct GadgetInfo *gi;
6567 unsigned int event_mask;
6570 event_mask = GD_EVENT_PRESSED;
6572 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
6574 int id = checkbutton_info[i].gadget_id;
6575 int graphic = (id == GADGET_ID_STICK_ELEMENT ? IMG_EDITOR_STICKYBUTTON :
6576 IMG_EDITOR_CHECKBOX);
6577 struct GraphicInfo *gd = &graphic_info[graphic];
6578 int gd_x1 = gd->src_x;
6579 int gd_y1 = gd->src_y;
6580 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6581 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6582 int gd_x1a = gd->src_x + gd->active_xoffset;
6583 int gd_y1a = gd->src_y + gd->active_yoffset;
6584 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6585 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
6586 int x = SX + ED_SETTINGS_X(checkbutton_info[i].x);
6587 int y = SY + ED_SETTINGS_Y(checkbutton_info[i].y);
6589 /* determine horizontal position to the right of specified gadget */
6590 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6591 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
6592 ED_GADGET_TEXT_DISTANCE);
6594 /* determine horizontal offset for leading text */
6595 if (checkbutton_info[i].text_left != NULL)
6596 x += getTextWidthForGadget(checkbutton_info[i].text_left);
6598 gi = CreateGadget(GDI_CUSTOM_ID, id,
6599 GDI_CUSTOM_TYPE_ID, i,
6600 GDI_INFO_TEXT, checkbutton_info[i].infotext,
6603 GDI_WIDTH, gd->width,
6604 GDI_HEIGHT, gd->height,
6605 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
6606 GDI_CHECKED, *checkbutton_info[i].value,
6607 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6608 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6609 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6610 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
6611 GDI_EVENT_MASK, event_mask,
6612 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6613 GDI_CALLBACK_ACTION, HandleCheckbuttons,
6617 Error(ERR_EXIT, "cannot create gadget");
6619 level_editor_gadget[id] = gi;
6620 right_gadget_border[id] =
6621 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
6625 static void CreateRadiobuttonGadgets()
6627 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_RADIOBUTTON];
6628 int gd_x1 = gd->src_x;
6629 int gd_y1 = gd->src_y;
6630 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6631 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6632 int gd_x1a = gd->src_x + gd->active_xoffset;
6633 int gd_y1a = gd->src_y + gd->active_yoffset;
6634 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6635 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
6636 struct GadgetInfo *gi;
6637 unsigned int event_mask;
6640 event_mask = GD_EVENT_PRESSED;
6642 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
6644 int id = radiobutton_info[i].gadget_id;
6645 int x = SX + ED_SETTINGS_X(radiobutton_info[i].x);
6646 int y = SY + ED_SETTINGS_Y(radiobutton_info[i].y);
6649 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
6651 /* determine horizontal position to the right of specified gadget */
6652 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
6653 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
6654 ED_GADGET_TEXT_DISTANCE);
6656 /* determine horizontal offset for leading text */
6657 if (radiobutton_info[i].text_left != NULL)
6658 x += getTextWidthForGadget(radiobutton_info[i].text_left);
6660 gi = CreateGadget(GDI_CUSTOM_ID, id,
6661 GDI_CUSTOM_TYPE_ID, i,
6662 GDI_INFO_TEXT, radiobutton_info[i].infotext,
6665 GDI_WIDTH, gd->width,
6666 GDI_HEIGHT, gd->height,
6667 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
6668 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
6669 GDI_CHECKED, checked,
6670 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6671 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6672 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6673 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
6674 GDI_EVENT_MASK, event_mask,
6675 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6676 GDI_CALLBACK_ACTION, HandleRadiobuttons,
6680 Error(ERR_EXIT, "cannot create gadget");
6682 level_editor_gadget[id] = gi;
6683 right_gadget_border[id] =
6684 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
6688 void CreateLevelEditorGadgets()
6690 /* force EDITOR font inside level editor */
6691 SetFontStatus(GAME_MODE_EDITOR);
6693 /* these values are not constant, but can change at runtime */
6694 ed_fieldx = MAX_ED_FIELDX - 1;
6695 ed_fieldy = MAX_ED_FIELDY - 1;
6697 num_editor_gadgets = NUM_EDITOR_GADGETS;
6699 // printf("::: allocating %d gadgets ...\n", num_editor_gadgets);
6701 level_editor_gadget =
6702 checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *));
6703 right_gadget_border =
6704 checked_calloc(num_editor_gadgets * sizeof(int));
6706 editor_el_empty = checked_calloc(ED_NUM_ELEMENTLIST_BUTTONS * sizeof(int));
6707 editor_el_empty_ptr = editor_el_empty;
6709 use_permanent_palette = !editor.palette.show_as_separate_screen;
6711 ReinitializeElementList();
6713 CreateControlButtons();
6714 CreateScrollbarGadgets();
6716 /* order of function calls is important because of cross-references */
6717 CreateCheckbuttonGadgets();
6718 CreateCounterButtons();
6719 CreateRadiobuttonGadgets();
6720 CreateTextInputGadgets();
6721 CreateTextAreaGadgets();
6722 CreateSelectboxGadgets();
6723 CreateGraphicbuttonGadgets();
6724 CreateTextbuttonGadgets();
6725 CreateDrawingAreas();
6730 void FreeLevelEditorGadgets()
6734 // printf("::: freeing %d gadgets ...\n", num_editor_gadgets);
6736 for (i = 0; i < num_editor_gadgets; i++)
6738 FreeGadget(level_editor_gadget[i]);
6740 level_editor_gadget[i] = NULL;
6743 checked_free(level_editor_gadget);
6744 checked_free(right_gadget_border);
6746 checked_free(editor_el_empty);
6749 static void MapCounterButtons(int id)
6751 int font_nr = FONT_TEXT_1;
6752 int font_height = getFontHeight(font_nr);
6753 int gadget_id_down = counterbutton_info[id].gadget_id_down;
6754 int gadget_id_text = counterbutton_info[id].gadget_id_text;
6755 int gadget_id_up = counterbutton_info[id].gadget_id_up;
6756 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
6757 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
6758 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
6759 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
6760 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6761 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
6762 int yoffset = (gi_down->height - font_height) / 2;
6763 int x_left = gi_down->x - xoffset_left;
6764 int x_right; /* set after gadget position was modified */
6765 int y_above = gi_down->y - yoffset_above;
6767 int y; /* set after gadget position was modified */
6769 /* counter limits must be changed first to prevent value truncation */
6770 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
6771 counterbutton_info[id].max_value);
6773 /* right text position might have changed after setting position above */
6774 x_right = gi_up->x + gi_up->width + xoffset_right;
6776 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
6778 /* set position for "value[1,2,3,4]" counter gadgets (score in most cases) */
6779 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
6780 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
6782 ModifyGadget(gi_down, GDI_Y,
6783 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
6784 ModifyGadget(gi_text, GDI_Y,
6785 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
6786 ModifyGadget(gi_up, GDI_Y,
6787 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
6790 /* vertical position might have changed after setting position above */
6791 y = gi_up->y + yoffset;
6793 if (counterbutton_info[id].text_above)
6794 DrawText(x, y_above, counterbutton_info[id].text_above, font_nr);
6796 if (counterbutton_info[id].text_left)
6797 DrawText(x_left, y, counterbutton_info[id].text_left, font_nr);
6799 if (counterbutton_info[id].text_right)
6800 DrawText(x_right, y, counterbutton_info[id].text_right, font_nr);
6807 static void MapControlButtons()
6812 /* map toolbox buttons (excluding special CE toolbox buttons) */
6813 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
6814 MapGadget(level_editor_gadget[i]);
6816 /* map toolbox buttons (element properties buttons) */
6817 for (i = ED_NUM_CTRL1_4_BUTTONS; i < ED_NUM_CTRL1_7_BUTTONS; i++)
6818 MapGadget(level_editor_gadget[i]);
6820 if (use_permanent_palette)
6822 /* map buttons to select elements */
6823 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6824 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
6825 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
6826 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
6827 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
6830 /* map buttons to select level */
6831 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
6832 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
6833 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
6834 MapCounterButtons(counter_id);
6837 static void MapDrawingArea(int id)
6839 int font_nr = FONT_TEXT_1;
6840 int font_height = getFontHeight(font_nr);
6841 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6842 int area_xsize = gi->drawing.area_xsize;
6843 int area_ysize = gi->drawing.area_ysize;
6844 int xoffset_left = getTextWidthForDrawingArea(drawingarea_info[id].text_left);
6845 int xoffset_below = getTextWidth(drawingarea_info[id].text_below, font_nr);
6846 int x_left = gi->x - xoffset_left;
6847 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
6848 int x_below = gi->x + (gi->width - xoffset_below) / 2;
6849 int y_side = gi->y + (gi->height - font_height) / 2;
6850 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
6852 if (drawingarea_info[id].text_left)
6853 DrawText(x_left, y_side, drawingarea_info[id].text_left, font_nr);
6855 if (drawingarea_info[id].text_right)
6856 DrawText(x_right, y_side, drawingarea_info[id].text_right, font_nr);
6858 if (drawingarea_info[id].text_below)
6859 DrawText(x_below, y_below, drawingarea_info[id].text_below, font_nr);
6861 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
6863 DrawElementBorder(gi->x, gi->y,
6864 area_xsize * ED_DRAWINGAREA_TILE_SIZE,
6865 area_ysize * ED_DRAWINGAREA_TILE_SIZE, TRUE);
6867 DrawDrawingArea(id);
6873 static void MapTextInputGadget(int id)
6875 int font_nr = FONT_TEXT_1;
6876 int font_height = getFontHeight(font_nr);
6877 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
6878 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
6879 int x_above = ED_SETTINGS_X(textinput_info[id].x);
6880 int y_above = ED_SETTINGS_Y(textinput_info[id].y) - yoffset_above;
6882 if (textinput_info[id].text_above)
6883 DrawTextS(x_above, y_above, font_nr, textinput_info[id].text_above);
6885 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
6890 static void MapTextAreaGadget(int id)
6892 int font_nr = FONT_TEXT_1;
6893 int font_height = getFontHeight(font_nr);
6894 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
6895 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
6896 int x_above = ED_SETTINGS_X(textarea_info[id].x);
6897 int y_above = ED_SETTINGS_Y(textarea_info[id].y) - yoffset_above;
6899 if (textarea_info[id].text_above)
6900 DrawTextS(x_above, y_above, font_nr, textarea_info[id].text_above);
6902 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
6907 static void MapSelectboxGadget(int id)
6909 int font_nr = FONT_TEXT_1;
6910 int font_height = getFontHeight(font_nr);
6911 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
6912 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
6913 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6914 int yoffset = (gi->height - font_height) / 2;
6915 int x_left = gi->x - xoffset_left;
6916 int x_right = gi->x + gi->width + xoffset_right;
6917 int y = gi->y + yoffset;
6919 if (selectbox_info[id].text_left)
6920 DrawText(x_left, y, selectbox_info[id].text_left, font_nr);
6922 if (selectbox_info[id].text_right)
6923 DrawText(x_right, y, selectbox_info[id].text_right, font_nr);
6925 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
6930 static void MapTextbuttonGadget(int id)
6932 int font_nr = FONT_TEXT_1;
6933 int font_height = getFontHeight(font_nr);
6934 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
6935 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
6936 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6937 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
6938 int yoffset = (gi->height - font_height) / 2;
6939 int x_left = gi->x - xoffset_left;
6940 int x_right = gi->x + gi->width + xoffset_right;
6941 int y_above = gi->y - yoffset_above;
6943 int y = gi->y + yoffset;
6945 /* only show button to delete change pages when more than minimum pages */
6946 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
6947 custom_element.num_change_pages == MIN_CHANGE_PAGES)
6950 if (textbutton_info[id].text_above)
6951 DrawText(x, y_above, textbutton_info[id].text_above, font_nr);
6953 if (textbutton_info[id].text_left)
6954 DrawText(x_left, y, textbutton_info[id].text_left, font_nr);
6956 if (textbutton_info[id].text_right)
6957 DrawText(x_right, y, textbutton_info[id].text_right, font_nr);
6962 static void MapGraphicbuttonGadget(int id)
6964 int font_nr = FONT_TEXT_1;
6965 int font_height = getFontHeight(font_nr);
6966 struct GadgetInfo *gi= level_editor_gadget[graphicbutton_info[id].gadget_id];
6967 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
6968 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6969 int yoffset = (gi->height - font_height) / 2;
6970 int x_left = gi->x - xoffset_left;
6971 int x_right = gi->x + gi->width + xoffset_right;
6972 int y = gi->y + yoffset;
6974 if (graphicbutton_info[id].text_left)
6975 DrawText(x_left, y, graphicbutton_info[id].text_left, font_nr);
6977 if (graphicbutton_info[id].text_right)
6978 DrawText(x_right, y, graphicbutton_info[id].text_right, font_nr);
6983 static void MapRadiobuttonGadget(int id)
6985 int font_nr = FONT_TEXT_1;
6986 int font_height = getFontHeight(font_nr);
6987 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
6988 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
6989 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
6990 int yoffset = (gi->height - font_height) / 2;
6991 int x_left = gi->x - xoffset_left;
6992 int x_right = gi->x + gi->width + xoffset_right;
6993 int y = gi->y + yoffset;
6995 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
6997 if (radiobutton_info[id].text_left)
6998 DrawText(x_left, y, radiobutton_info[id].text_left, font_nr);
7000 if (radiobutton_info[id].text_right)
7001 DrawText(x_right, y, radiobutton_info[id].text_right, font_nr);
7003 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
7008 static void MapCheckbuttonGadget(int id)
7010 int font_nr = FONT_TEXT_1;
7011 int font_height = getFontHeight(font_nr);
7012 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
7013 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
7014 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7015 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7016 int yoffset = (gi->height - font_height) / 2;
7017 int y_above = gi->y - yoffset_above;
7019 int x_left, x_right, y; /* set after gadget position was modified */
7021 /* set position for gadgets with dynamically determined position */
7022 if (checkbutton_info[id].x != -1) /* do not change dynamic positions */
7023 ModifyGadget(gi, GDI_X, SX + ED_SETTINGS_X(checkbutton_info[id].x),GDI_END);
7024 ModifyGadget(gi, GDI_Y, SY + ED_SETTINGS_Y(checkbutton_info[id].y), GDI_END);
7026 x_left = gi->x - xoffset_left;
7027 x_right = gi->x + gi->width + xoffset_right;
7028 y = gi->y + yoffset;
7030 if (checkbutton_info[id].text_above)
7031 DrawText(x, y_above, checkbutton_info[id].text_above, font_nr);
7033 if (checkbutton_info[id].text_left)
7034 DrawText(x_left, y, checkbutton_info[id].text_left, font_nr);
7036 if (checkbutton_info[id].text_right)
7037 DrawText(x_right, y, checkbutton_info[id].text_right, font_nr);
7039 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
7044 static void MapMainDrawingArea()
7046 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
7047 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
7050 for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
7052 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
7053 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
7054 no_horizontal_scrollbar) ||
7055 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
7056 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
7057 no_vertical_scrollbar))
7060 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
7063 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
7065 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
7066 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
7069 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
7072 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
7075 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
7079 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
7081 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
7082 i == GADGET_ID_CUSTOM_COPY_TO ||
7083 i == GADGET_ID_CUSTOM_EXCHANGE ||
7084 i == GADGET_ID_CUSTOM_COPY ||
7085 i == GADGET_ID_CUSTOM_PASTE)
7088 MapGadget(level_editor_gadget[i]);
7090 UnmapGadget(level_editor_gadget[i]);
7095 static void MapLevelEditorToolboxCustomGadgets()
7097 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
7100 static void UnmapLevelEditorToolboxCustomGadgets()
7102 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
7105 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
7109 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
7111 if (i != GADGET_ID_SINGLE_ITEMS &&
7112 i != GADGET_ID_PICK_ELEMENT)
7114 struct GadgetInfo *gi = level_editor_gadget[i];
7122 int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
7123 struct GraphicInfo *gd = &graphic_info[graphic];
7127 BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
7128 gi->width, gi->height, gi->x, gi->y);
7130 redraw_mask |= REDRAW_DOOR_3;
7136 static void MapLevelEditorToolboxDrawingGadgets()
7138 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
7141 static void UnmapLevelEditorToolboxDrawingGadgets()
7143 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
7146 static void UnmapDrawingArea(int id)
7148 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
7151 static void UnmapLevelEditorFieldGadgets()
7155 for (i = 0; i < num_editor_gadgets; i++)
7156 if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
7157 level_editor_gadget[i]->y))
7158 UnmapGadget(level_editor_gadget[i]);
7161 void UnmapLevelEditorGadgets()
7165 for (i = 0; i < num_editor_gadgets; i++)
7166 UnmapGadget(level_editor_gadget[i]);
7169 static void ResetUndoBuffer()
7171 undo_buffer_position = -1;
7172 undo_buffer_steps = -1;
7173 redo_buffer_steps = 0;
7175 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7177 level.changed = FALSE;
7180 static void DrawEditModeWindow()
7182 ModifyEditorElementList();
7183 RedrawDrawingElements();
7185 if (edit_mode == ED_MODE_INFO)
7186 DrawLevelInfoWindow();
7187 else if (edit_mode == ED_MODE_PROPERTIES)
7188 DrawPropertiesWindow();
7189 else if (edit_mode == ED_MODE_PALETTE)
7190 DrawPaletteWindow();
7191 else /* edit_mode == ED_MODE_DRAWING */
7192 DrawDrawingWindow();
7195 static void ChangeEditModeWindow(int new_edit_mode)
7197 edit_mode = (new_edit_mode != edit_mode ? new_edit_mode : ED_MODE_DRAWING);
7199 DrawEditModeWindow();
7202 static boolean LevelChanged()
7204 boolean field_changed = FALSE;
7207 for (y = 0; y < lev_fieldy; y++)
7208 for (x = 0; x < lev_fieldx; x++)
7209 if (Feld[x][y] != level.field[x][y])
7210 field_changed = TRUE;
7212 return (level.changed || field_changed);
7215 static boolean PrepareSavingIntoPersonalLevelSet()
7217 static LevelDirTree *last_copied_leveldir = NULL;
7218 static LevelDirTree *last_written_leveldir = NULL;
7219 static int last_copied_level_nr = -1;
7220 static int last_written_level_nr = -1;
7221 LevelDirTree *leveldir_former = leveldir_current;
7222 int level_nr_former = level_nr;
7225 // remember last mod/save so that for current session, we write
7226 // back to the same personal copy, asking only about overwrite.
7227 if (leveldir_current == last_copied_leveldir &&
7228 level_nr == last_copied_level_nr)
7230 // "cd" to personal level set dir (as used when writing last copy)
7231 leveldir_current = last_written_leveldir;
7232 level_nr = last_written_level_nr;
7237 if (!Request("This level is read only! "
7238 "Save into personal level set?", REQ_ASK))
7241 // "cd" to personal level set dir (for writing copy the first time)
7243 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
7245 // find unused level number
7246 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
7248 static char *level_filename = NULL;
7250 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
7252 if (!fileExists(level_filename))
7256 last_copied_leveldir = leveldir_former;
7257 last_copied_level_nr = level_nr_former;
7259 last_written_leveldir = leveldir_current;
7260 last_written_level_nr = level_nr = new_level_nr;
7265 static void ModifyLevelInfoForSavingIntoPersonalLevelSet(char *former_name)
7267 static char *filename_levelinfo = NULL, *mod_name = NULL;
7270 // annotate this copy-and-mod in personal levelinfo.conf
7271 setString(&filename_levelinfo,
7272 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
7274 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
7276 fprintf(file, "\n");
7277 fprintf(file, "# level %d was modified from:\n", level_nr);
7278 fprintf(file, "# - previous level set name: %s\n",
7280 fprintf(file, "# - level within previous set: %d \"%s\"\n",
7281 level.file_info.nr, level.name);
7282 fprintf(file, "# - previous author: %s\n",
7284 fprintf(file, "# - previous save date: ");
7286 if (level.creation_date.src == DATE_SRC_LEVELFILE)
7288 fprintf(file, "%04d-%02d-%02d\n",
7289 level.creation_date.year,
7290 level.creation_date.month,
7291 level.creation_date.day);
7295 fprintf(file, "not recorded\n");
7301 if (level_nr > leveldir_current->last_level)
7303 static char *temp_levelinfo = NULL;
7304 FILE *temp_file = NULL;
7305 char line[MAX_LINE_LEN];
7307 setString(&temp_levelinfo,
7308 getPath2(getCurrentLevelDir(),
7309 getStringCat2(LEVELINFO_FILENAME, ".new")));
7311 if ((file = fopen(filename_levelinfo, MODE_READ)) &&
7312 (temp_file = fopen(temp_levelinfo, MODE_WRITE)))
7314 while (fgets(line, MAX_LINE_LEN, file))
7316 if (!strPrefix(line, "levels:"))
7317 fputs(line, temp_file);
7319 fprintf(temp_file, "%-32s%d\n", "levels:", level_nr + 9);
7329 // needs error handling; also, ok on dos/win?
7330 unlink(filename_levelinfo);
7331 rename(temp_levelinfo, filename_levelinfo);
7334 // else: allow the save even if annotation failed
7336 // now... spray graffiti on the old level vital statistics
7337 // user can change these; just trying to set a good baseline
7339 // don't truncate names for fear of making offensive or silly:
7340 // long-named original author only recorded in levelinfo.conf.
7341 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
7342 if (!strEqual(level.author, leveldir_current->author))
7344 setString(&mod_name, getStringCat3(leveldir_current->author,
7345 " after ", level.author));
7347 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
7348 setString(&mod_name,
7349 getStringCat2(leveldir_current->author, " (ed.)"));
7351 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
7352 setString(&mod_name, leveldir_current->author);
7354 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
7356 // less worried about truncation here
7357 setString(&mod_name, getStringCat2("Mod: ", level.name));
7358 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
7362 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
7363 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
7367 for (x = 0; x < lev_fieldx; x++)
7368 for (y = 0; y < lev_fieldy; y++)
7369 dst[x][y] = src[x][y];
7372 static int setSelectboxValue(int selectbox_id, int new_value)
7374 int new_index_value = 0;
7377 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
7378 if (selectbox_info[selectbox_id].options[i].value == new_value)
7379 new_index_value = i;
7381 *selectbox_info[selectbox_id].value =
7382 selectbox_info[selectbox_id].options[new_index_value].value;
7384 return new_index_value;
7387 static void setSelectboxSpecialActionVariablesIfNeeded()
7391 /* change action mode and arg variables according to action type variable */
7392 for (i = 0; action_arg_options[i].value != -1; i++)
7394 if (action_arg_options[i].value == custom_element_change.action_type)
7396 int mode = action_arg_options[i].mode;
7398 /* only change if corresponding selectbox has changed */
7399 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
7400 action_arg_modes[mode])
7401 custom_element_change.action_mode = -1;
7403 /* only change if corresponding selectbox has changed */
7404 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
7405 action_arg_options[i].options)
7406 custom_element_change.action_arg = -1;
7413 static void setSelectboxSpecialActionOptions()
7417 /* change action mode and arg selectbox according to action type selectbox */
7418 for (i = 0; action_arg_options[i].value != -1; i++)
7420 if (action_arg_options[i].value == custom_element_change.action_type)
7422 int mode = action_arg_options[i].mode;
7424 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
7425 action_arg_modes[mode]);
7426 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
7427 custom_element_change.action_mode);
7429 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
7430 action_arg_options[i].options);
7431 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
7432 custom_element_change.action_arg);
7438 static void copy_custom_element_settings(int element_from, int element_to)
7440 struct ElementInfo *ei_from = &element_info[element_from];
7441 struct ElementInfo *ei_to = &element_info[element_to];
7443 copyElementInfo(ei_from, ei_to);
7446 static void replace_custom_element_in_settings(int element_from,
7451 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
7453 struct ElementInfo *ei = &element_info[i];
7455 for (y = 0; y < 3; y++)
7456 for (x = 0; x < 3; x++)
7457 if (ei->content.e[x][y] == element_from)
7458 ei->content.e[x][y] = element_to;
7460 for (j = 0; j < ei->num_change_pages; j++)
7462 struct ElementChangeInfo *change = &ei->change_page[j];
7464 if (change->target_element == element_from)
7465 change->target_element = element_to;
7467 if (change->initial_trigger_element == element_from)
7468 change->initial_trigger_element = element_to;
7470 if (change->action_element == element_from)
7471 change->action_element = element_to;
7473 for (y = 0; y < 3; y++)
7474 for (x = 0; x < 3; x++)
7475 if (change->target_content.e[x][y] == element_from)
7476 change->target_content.e[x][y] = element_to;
7479 if (ei->group != NULL) /* group or internal */
7480 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
7481 if (ei->group->element[j] == element_from)
7482 ei->group->element[j] = element_to;
7486 static void replace_custom_element_in_playfield(int element_from,
7491 for (x = 0; x < lev_fieldx; x++)
7492 for (y = 0; y < lev_fieldy; y++)
7493 if (Feld[x][y] == element_from)
7494 Feld[x][y] = element_to;
7497 static boolean CopyCustomElement(int element_old, int element_new,
7500 int copy_mode_orig = copy_mode;
7502 if (copy_mode == GADGET_ID_CUSTOM_COPY)
7504 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
7505 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
7506 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
7508 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
7510 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
7511 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
7512 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
7514 level.changed = TRUE;
7516 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
7518 Request("Please choose custom element!", REQ_CONFIRM);
7522 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
7524 Request("Please choose group element!", REQ_CONFIRM);
7530 level.changed = TRUE;
7533 /* when modifying custom/group element, ask for copying level template */
7534 if (copy_mode_orig != GADGET_ID_CUSTOM_COPY && level.use_custom_template)
7536 if (!AskToCopyAndModifyLevelTemplate())
7540 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
7542 copy_custom_element_settings(element_new, element_old);
7544 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
7546 copy_custom_element_settings(element_old, element_new);
7548 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
7550 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
7551 copy_custom_element_settings(element_new, element_old);
7552 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
7554 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
7555 replace_custom_element_in_settings(element_new, element_old);
7556 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
7558 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
7559 replace_custom_element_in_playfield(element_new, element_old);
7560 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
7563 UpdateCustomElementGraphicGadgets();
7564 DrawPropertiesWindow();
7569 static void CopyCustomElementPropertiesToEditor(int element)
7572 int current_change_page = element_info[element].current_change_page;
7574 /* dynamically (re)build selectbox for selecting change page */
7575 for (i = 0; i < element_info[element].num_change_pages; i++)
7577 sprintf(options_change_page_strings[i], "%d", i + 1);
7579 options_change_page[i].value = i;
7580 options_change_page[i].text = options_change_page_strings[i];
7583 options_change_page[i].value = -1;
7584 options_change_page[i].text = NULL;
7586 /* needed here to initialize combined element properties */
7587 InitElementPropertiesEngine(level.game_version);
7589 element_info[element].change =
7590 &element_info[element].change_page[current_change_page];
7592 custom_element = element_info[element];
7593 custom_element_change = *element_info[element].change;
7595 /* needed to initially set selectbox options for special action options */
7596 setSelectboxSpecialActionOptions();
7598 /* needed to initially set selectbox value variables to reliable defaults */
7599 for (i = 0; i < ED_NUM_SELECTBOX; i++)
7600 setSelectboxValue(i, *selectbox_info[i].value);
7602 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
7603 custom_element_properties[i] = HAS_PROPERTY(element, i);
7605 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
7606 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
7608 /* ---------- element settings: configure (custom elements) ------------- */
7610 /* set accessible layer selectbox help value */
7611 custom_element.access_type =
7612 (IS_WALKABLE(element) ? EP_WALKABLE :
7613 IS_PASSABLE(element) ? EP_PASSABLE :
7614 custom_element.access_type);
7615 custom_element.access_layer =
7616 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
7617 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
7618 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
7619 custom_element.access_layer);
7620 custom_element.access_protected =
7621 (IS_PROTECTED(element) ? 1 : 0);
7622 custom_element_properties[EP_ACCESSIBLE] =
7623 (IS_ACCESSIBLE_OVER(element) ||
7624 IS_ACCESSIBLE_INSIDE(element) ||
7625 IS_ACCESSIBLE_UNDER(element));
7627 /* set walk-to-object action selectbox help value */
7628 custom_element.walk_to_action =
7629 (IS_DIGGABLE(element) ? EP_DIGGABLE :
7630 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
7631 IS_DROPPABLE(element) ? EP_DROPPABLE :
7632 IS_THROWABLE(element) ? EP_THROWABLE :
7633 IS_PUSHABLE(element) ? EP_PUSHABLE :
7634 custom_element.walk_to_action);
7635 custom_element_properties[EP_WALK_TO_OBJECT] =
7636 (IS_DIGGABLE(element) ||
7637 IS_COLLECTIBLE_ONLY(element) ||
7638 IS_DROPPABLE(element) ||
7639 IS_THROWABLE(element) ||
7640 IS_PUSHABLE(element));
7642 /* set smash targets selectbox help value */
7643 custom_element.smash_targets =
7644 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
7645 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
7646 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
7647 custom_element.smash_targets);
7648 custom_element_properties[EP_CAN_SMASH] =
7649 (CAN_SMASH_EVERYTHING(element) ||
7650 CAN_SMASH_ENEMIES(element) ||
7651 CAN_SMASH_PLAYER(element));
7653 /* set deadliness selectbox help value */
7654 custom_element.deadliness =
7655 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
7656 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
7657 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
7658 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
7659 custom_element.deadliness);
7660 custom_element_properties[EP_DEADLY] =
7661 (DONT_TOUCH(element) ||
7662 DONT_GET_HIT_BY(element) ||
7663 DONT_COLLIDE_WITH(element) ||
7664 DONT_RUN_INTO(element));
7666 /* ---------- element settings: advanced (custom elements) --------------- */
7668 /* set "change by direct action" selectbox help value */
7669 custom_element_change.direct_action =
7670 (HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
7671 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
7672 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
7673 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
7674 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
7675 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
7676 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
7677 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
7678 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
7679 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
7680 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
7681 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
7682 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
7683 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
7684 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
7685 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
7686 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
7687 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
7688 custom_element_change.direct_action);
7690 /* set "change by other element action" selectbox help value */
7691 custom_element_change.other_action =
7692 (HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
7693 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
7694 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
7695 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
7696 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
7697 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
7698 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
7699 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
7700 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
7701 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
7702 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
7703 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
7704 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
7705 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
7706 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
7707 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
7708 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
7709 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
7710 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
7711 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
7712 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
7713 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
7714 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
7715 custom_element_change.other_action);
7718 static void CopyGroupElementPropertiesToEditor(int element)
7720 group_element_info = *element_info[element].group;
7721 custom_element = element_info[element]; /* needed for description */
7724 static void CopyClassicElementPropertiesToEditor(int element)
7726 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
7727 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
7728 getMoveIntoAcidProperty(&level, element);
7730 if (MAYBE_DONT_COLLIDE_WITH(element))
7731 custom_element_properties[EP_DONT_COLLIDE_WITH] =
7732 getDontCollideWithProperty(&level, element);
7735 static void CopyElementPropertiesToEditor(int element)
7737 if (IS_CUSTOM_ELEMENT(element))
7738 CopyCustomElementPropertiesToEditor(element);
7739 else if (IS_GROUP_ELEMENT(element))
7740 CopyGroupElementPropertiesToEditor(element);
7742 CopyClassicElementPropertiesToEditor(element);
7745 static boolean AskToCopyAndModifyLevelTemplate()
7747 if (Request("Copy and modify settings from level template?", REQ_ASK))
7749 level.use_custom_template = FALSE;
7751 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_1],
7752 GDI_CHECKED, FALSE, GDI_END);
7753 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_2],
7754 GDI_CHECKED, FALSE, GDI_END);
7760 LoadLevelTemplate(-1); /* this resets all element modifications ... */
7762 DrawEditModeWindow(); /* ... and copies them to 'custom_element' */
7768 static void CopyCustomElementPropertiesToGame(int element)
7771 int access_type_and_layer;
7773 /* mark that this custom element has been modified */
7774 custom_element.modified_settings = TRUE;
7775 level.changed = TRUE;
7777 if (level.use_custom_template)
7778 AskToCopyAndModifyLevelTemplate();
7780 element_info[element] = custom_element;
7781 *element_info[element].change = custom_element_change;
7783 /* ---------- element settings: configure (custom elements) ------------- */
7785 /* set accessible property from checkbox and selectbox */
7786 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
7787 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
7788 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
7789 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
7790 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
7791 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
7792 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
7793 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
7794 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
7795 custom_element_properties[access_type_and_layer] =
7796 custom_element_properties[EP_ACCESSIBLE];
7797 custom_element_properties[EP_PROTECTED] =
7798 (custom_element.access_protected != 0 &&
7799 custom_element_properties[EP_ACCESSIBLE]);
7801 /* set walk-to-object property from checkbox and selectbox */
7802 custom_element_properties[EP_DIGGABLE] = FALSE;
7803 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
7804 custom_element_properties[EP_DROPPABLE] = FALSE;
7805 custom_element_properties[EP_THROWABLE] = FALSE;
7806 custom_element_properties[EP_PUSHABLE] = FALSE;
7807 custom_element_properties[custom_element.walk_to_action] =
7808 custom_element_properties[EP_WALK_TO_OBJECT];
7810 /* set smash property from checkbox and selectbox */
7811 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
7812 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
7813 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
7814 custom_element_properties[custom_element.smash_targets] =
7815 custom_element_properties[EP_CAN_SMASH];
7817 /* set deadliness property from checkbox and selectbox */
7818 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
7819 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
7820 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
7821 custom_element_properties[EP_DONT_TOUCH] = FALSE;
7822 custom_element_properties[custom_element.deadliness] =
7823 custom_element_properties[EP_DEADLY];
7825 /* ---------- element settings: advanced (custom elements) --------------- */
7827 /* set player change event from checkbox and selectbox */
7828 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
7829 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
7830 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
7831 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
7832 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
7833 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
7834 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
7835 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
7836 custom_element_change_events[CE_SWITCHED] = FALSE;
7837 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
7838 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
7839 custom_element_change_events[CE_BLOCKED] = FALSE;
7840 custom_element_change_events[CE_IMPACT] = FALSE;
7841 custom_element_change_events[CE_SMASHED] = FALSE;
7842 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
7843 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
7844 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
7845 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
7846 custom_element_change_events[custom_element_change.direct_action] =
7847 custom_element_change_events[CE_BY_DIRECT_ACTION];
7849 /* set other element action change event from checkbox and selectbox */
7850 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
7851 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
7852 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
7853 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
7854 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
7855 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
7856 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
7857 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
7858 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
7859 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
7860 custom_element_change_events[CE_TOUCHING_X] = FALSE;
7861 custom_element_change_events[CE_HITTING_X] = FALSE;
7862 custom_element_change_events[CE_DIGGING_X] = FALSE;
7863 custom_element_change_events[CE_HIT_BY_X] = FALSE;
7864 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
7865 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
7866 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
7867 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
7868 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
7869 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
7870 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
7871 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
7872 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
7873 custom_element_change_events[custom_element_change.other_action] =
7874 custom_element_change_events[CE_BY_OTHER_ACTION];
7876 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
7877 SET_PROPERTY(element, i, custom_element_properties[i]);
7879 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
7880 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
7882 /* copy change events also to special level editor variable */
7883 custom_element = element_info[element];
7884 custom_element_change = *element_info[element].change;
7887 static void CopyGroupElementPropertiesToGame(int element)
7889 /* mark that this group element has been modified */
7890 custom_element.modified_settings = TRUE;
7891 level.changed = TRUE;
7893 if (level.use_custom_template)
7894 AskToCopyAndModifyLevelTemplate();
7896 element_info[element] = custom_element;
7897 *element_info[element].group = group_element_info;
7900 static void CopyClassicElementPropertiesToGame(int element)
7902 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
7903 setMoveIntoAcidProperty(&level, element,
7904 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
7906 if (MAYBE_DONT_COLLIDE_WITH(element))
7907 setDontCollideWithProperty(&level, element,
7908 custom_element_properties[EP_DONT_COLLIDE_WITH]);
7911 static void CopyElementPropertiesToGame(int element)
7913 if (IS_CUSTOM_ELEMENT(element))
7914 CopyCustomElementPropertiesToGame(element);
7915 else if (IS_GROUP_ELEMENT(element))
7916 CopyGroupElementPropertiesToGame(element);
7918 CopyClassicElementPropertiesToGame(element);
7921 void CheckElementDescriptions()
7925 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
7926 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
7927 Error(ERR_WARN, "no element description file for element '%s'",
7931 static int getMaxEdFieldX(boolean has_scrollbar)
7933 int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
7934 int sxsize = SXSIZE - scrollbar_width;
7935 int max_ed_fieldx = sxsize / ed_tilesize;
7937 return max_ed_fieldx;
7940 static int getMaxEdFieldY(boolean has_scrollbar)
7942 int infotext_height = INFOTEXT_YSIZE_FULL;
7943 int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
7944 int sysize = SYSIZE - scrollbar_height - infotext_height;
7945 int max_ed_fieldy = sysize / ed_tilesize;
7947 return max_ed_fieldy;
7950 void InitZoomLevelSettings()
7952 MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
7953 MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
7958 int fade_mask = REDRAW_FIELD;
7960 FadeSoundsAndMusic();
7962 if (CheckIfGlobalBorderHasChanged())
7963 fade_mask = REDRAW_ALL;
7967 /* needed if different viewport properties defined for editor */
7968 ChangeViewportPropertiesIfNeeded();
7972 InitZoomLevelSettings();
7974 OpenDoor(DOOR_OPEN_1 | DOOR_OPEN_2 | DOOR_NO_DELAY);
7977 CheckElementDescriptions();
7980 if (level_editor_test_game)
7982 CopyPlayfield(level.field, Feld);
7983 CopyPlayfield(FieldBackup, level.field);
7985 level_editor_test_game = FALSE;
7989 edit_mode = ED_MODE_DRAWING;
7990 edit_mode_levelinfo = ED_MODE_LEVELINFO_LEVEL;
7991 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
7999 /* needed for gadgets drawn on background (like palette scrollbar) */
8000 SetDoorBackgroundImage(IMG_UNDEFINED);
8002 /* copy default editor door content to main double buffer */
8003 BlitBitmap(graphic_info[IMG_BACKGROUND_PALETTE].bitmap, drawto,
8004 graphic_info[IMG_BACKGROUND_PALETTE].src_x,
8005 graphic_info[IMG_BACKGROUND_PALETTE].src_y,
8006 MIN(DXSIZE, graphic_info[IMG_BACKGROUND_PALETTE].width),
8007 MIN(DYSIZE, graphic_info[IMG_BACKGROUND_PALETTE].height),
8010 /* draw bigger door */
8011 DrawSpecialEditorDoor();
8013 /* draw new control window */
8014 BlitBitmap(graphic_info[IMG_BACKGROUND_TOOLBOX].bitmap, drawto,
8015 graphic_info[IMG_BACKGROUND_TOOLBOX].src_x,
8016 graphic_info[IMG_BACKGROUND_TOOLBOX].src_y,
8017 MIN(EXSIZE, graphic_info[IMG_BACKGROUND_TOOLBOX].width),
8018 MIN(EYSIZE, graphic_info[IMG_BACKGROUND_TOOLBOX].height),
8021 // redraw_mask |= REDRAW_ALL;
8023 FreeLevelEditorGadgets();
8024 CreateLevelEditorGadgets();
8026 ReinitializeElementList(); /* update dynamic level element list */
8027 ReinitializeElementListButtons(); /* custom element may look different */
8029 InitElementPropertiesGfxElement();
8032 MapControlButtons();
8034 DrawEditModeWindow();
8036 DrawMaskedBorder(fade_mask);
8040 /* copy actual editor door content to door double buffer for OpenDoor() */
8041 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
8044 static void AdjustDrawingAreaGadgets()
8046 int ed_xsize = lev_fieldx + 2;
8047 int ed_ysize = lev_fieldy + 2;
8048 int max_ed_fieldx = MAX_ED_FIELDX;
8049 int max_ed_fieldy = MAX_ED_FIELDY;
8050 boolean horizontal_scrollbar_needed;
8051 boolean vertical_scrollbar_needed;
8052 int x, y, width, height;
8054 /* check if we need any scrollbars */
8055 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
8056 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
8058 /* check if we have a smaller editor field because of scrollbars */
8059 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
8060 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
8062 /* check again if we now need more scrollbars because of less space */
8063 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
8064 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
8066 /* check if editor field gets even smaller after adding new scrollbars */
8067 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
8068 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
8070 ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
8071 ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
8073 x = SX + ed_fieldx * ed_tilesize;
8074 y = SY + ed_fieldy * ed_tilesize;
8076 width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
8077 height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
8079 /* adjust drawing area gadget */
8080 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
8081 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
8082 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
8085 /* adjust horizontal scrollbar gadgets */
8086 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
8089 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
8090 GDI_X, x - ED_SCROLLBUTTON_XSIZE,
8093 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
8096 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
8099 /* adjust vertical scrollbar gadgets */
8100 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
8103 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
8105 GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
8107 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
8110 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
8114 static void AdjustLevelScrollPosition()
8116 if (level_xpos < -1)
8118 if (level_xpos > lev_fieldx - ed_fieldx + 1)
8119 level_xpos = lev_fieldx - ed_fieldx + 1;
8120 if (lev_fieldx < ed_fieldx - 2)
8123 if (level_ypos < -1)
8125 if (level_ypos > lev_fieldy - ed_fieldy + 1)
8126 level_ypos = lev_fieldy - ed_fieldy + 1;
8127 if (lev_fieldy < ed_fieldy - 2)
8131 static void AdjustEditorScrollbar(int id)
8133 struct GadgetInfo *gi = level_editor_gadget[id];
8134 int items_max, items_visible, item_position;
8136 if (id == GADGET_ID_SCROLL_HORIZONTAL)
8138 items_max = MAX(lev_fieldx + 2, ed_fieldx);
8139 items_visible = ed_fieldx;
8140 item_position = level_xpos + 1;
8144 items_max = MAX(lev_fieldy + 2, ed_fieldy);
8145 items_visible = ed_fieldy;
8146 item_position = level_ypos + 1;
8149 if (item_position > items_max - items_visible)
8150 item_position = items_max - items_visible;
8152 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
8153 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
8156 static void AdjustElementListScrollbar()
8158 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
8159 int items_max, items_visible, item_position;
8161 /* correct position of element list scrollbar */
8162 if (element_shift < 0)
8164 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
8165 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
8167 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
8168 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
8169 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
8171 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
8172 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
8173 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
8176 static void ModifyEditorCounterValue(int counter_id, int new_value)
8178 int *counter_value = counterbutton_info[counter_id].value;
8179 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
8180 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8182 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
8184 if (counter_value != NULL)
8185 *counter_value = gi->textinput.number_value;
8188 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
8190 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
8191 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8193 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
8195 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
8196 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
8198 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
8199 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
8201 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
8202 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_SMALL_DISTANCE,
8207 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
8209 int gadget_id = selectbox_info[selectbox_id].gadget_id;
8210 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8211 int new_index_value = setSelectboxValue(selectbox_id, new_value);
8213 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
8216 static void ModifyEditorSelectboxOptions(int selectbox_id,
8217 struct ValueTextInfo *options)
8219 int gadget_id = selectbox_info[selectbox_id].gadget_id;
8220 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8222 selectbox_info[selectbox_id].options = options;
8224 /* set index to zero -- list may be shorter now (correct later, if needed) */
8225 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
8226 GDI_SELECTBOX_OPTIONS, options, GDI_END);
8229 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
8231 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
8232 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8234 drawingarea_info[drawingarea_id].area_xsize = xsize;
8235 drawingarea_info[drawingarea_id].area_ysize = ysize;
8237 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
8240 static void ModifyEditorElementList()
8244 if (!use_permanent_palette && edit_mode != ED_MODE_PALETTE)
8247 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
8249 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
8250 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8251 struct GadgetDesign *gd = &gi->deco.design;
8252 int element = editor_elements[element_shift + i];
8253 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
8257 getEditorGraphicSource(element, tile_size, &gd->bitmap, &gd->x, &gd->y);
8259 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
8265 static void DrawDrawingElementGraphic(int element, struct XYTileSize *pos)
8267 int graphic = el2edimg(element);
8268 int tile_size = BUTTON_TILE_SIZE(pos->tile_size);
8274 DrawSizedGraphicExt(drawto, DX + pos->x, DY + pos->y, graphic, 0, tile_size);
8277 static void ModifyDrawingElementButton(int element, int id)
8279 struct GadgetInfo *gi = level_editor_gadget[id];
8280 Bitmap *deco_bitmap;
8282 int tile_size = gi->deco.width;
8284 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
8286 ModifyGadget(gi, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_END);
8289 static void PickDrawingElement(int button, int element)
8294 struct XYTileSize *pos;
8296 } de, drawing_elements[] =
8298 { &new_element1, &editor.palette.element_left, GADGET_ID_ELEMENT_LEFT },
8299 { &new_element2, &editor.palette.element_middle, GADGET_ID_ELEMENT_MIDDLE },
8300 { &new_element3, &editor.palette.element_right, GADGET_ID_ELEMENT_RIGHT },
8303 if (button < 1 || button > 3)
8306 de = drawing_elements[button - 1];
8308 *de.new_element = element; // update global drawing element variable
8310 DrawDrawingElementGraphic(element, de.pos);
8311 ModifyDrawingElementButton(element, de.id);
8313 redraw_mask |= REDRAW_DOOR_1;
8316 static void RedrawDrawingElements()
8318 PickDrawingElement(1, new_element1);
8319 PickDrawingElement(2, new_element2);
8320 PickDrawingElement(3, new_element3);
8323 static void DrawDrawingWindow()
8325 stick_element_properties_window = FALSE;
8327 SetMainBackgroundImage(IMG_UNDEFINED);
8330 UnmapLevelEditorFieldGadgets();
8331 UnmapLevelEditorToolboxCustomGadgets();
8333 AdjustDrawingAreaGadgets();
8334 AdjustLevelScrollPosition();
8335 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
8336 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
8338 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8340 MapMainDrawingArea();
8341 MapLevelEditorToolboxDrawingGadgets();
8344 static int getTabulatorBarWidth()
8346 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
8347 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
8349 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
8352 static int getTabulatorBarHeight()
8354 return ED_TAB_BAR_HEIGHT;
8357 static void DrawLevelInfoTabulatorGadgets()
8359 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELINFO_LEVEL];
8360 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
8361 int gd_x = gd->x + gd_gi1->border.width / 2;
8362 int gd_y = gd->y + gd_gi1->height - 1;
8363 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
8364 int id_first = ED_TAB_BUTTON_ID_LEVELINFO_FIRST;
8365 int id_last = ED_TAB_BUTTON_ID_LEVELINFO_LAST;
8368 for (i = id_first; i <= id_last; i++)
8370 int gadget_id = textbutton_info[i].gadget_id;
8371 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8372 boolean active = (i != edit_mode_levelinfo);
8374 /* draw background line below tabulator button */
8375 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
8377 /* draw solid line below inactive tabulator buttons */
8378 if (!active && tab_color != BLACK_PIXEL) /* black => transparent */
8379 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
8380 ED_GADGET_TINY_DISTANCE, tab_color);
8382 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
8383 MapTextbuttonGadget(i);
8386 /* draw little border line below tabulator buttons */
8387 if (tab_color != BLACK_PIXEL) /* black => transparent */
8388 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
8389 ED_GADGET_TINY_DISTANCE,
8390 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
8393 static void DrawPropertiesTabulatorGadgets()
8395 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
8396 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
8397 int gd_x = gd->x + gd_gi1->border.width / 2;
8398 int gd_y = gd->y + gd_gi1->height - 1;
8399 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
8400 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
8401 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
8404 /* draw two config tabulators for player elements */
8405 if (ELEM_IS_PLAYER(properties_element))
8406 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
8408 /* draw two config and one "change" tabulator for custom elements */
8409 if (IS_CUSTOM_ELEMENT(properties_element))
8410 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
8412 for (i = id_first; i <= id_last; i++)
8414 int gadget_id = textbutton_info[i].gadget_id;
8415 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8416 boolean active = (i != edit_mode_properties);
8418 /* use "config 1" and "config 2" instead of "config" for players and CEs */
8419 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
8420 (ELEM_IS_PLAYER(properties_element) ||
8421 IS_CUSTOM_ELEMENT(properties_element)))
8424 /* draw background line below tabulator button */
8425 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
8427 /* draw solid line below inactive tabulator buttons */
8428 if (!active && tab_color != BLACK_PIXEL) /* black => transparent */
8429 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
8430 ED_GADGET_TINY_DISTANCE, tab_color);
8432 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
8433 MapTextbuttonGadget(i);
8436 /* draw little border line below tabulator buttons */
8437 if (tab_color != BLACK_PIXEL) /* black => transparent */
8438 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
8439 ED_GADGET_TINY_DISTANCE,
8440 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
8443 static void DrawLevelInfoLevel()
8447 /* draw counter gadgets */
8448 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
8449 MapCounterButtons(i);
8451 /* draw selectbox gadgets */
8452 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
8453 MapSelectboxGadget(i);
8455 /* draw text input gadgets */
8456 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
8457 MapTextInputGadget(i);
8460 static void DrawLevelInfoEditor()
8464 /* draw counter gadgets */
8465 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
8466 MapCounterButtons(i);
8468 /* draw checkbutton gadgets */
8469 for (i=ED_CHECKBUTTON_ID_EDITOR_FIRST; i<= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
8470 MapCheckbuttonGadget(i);
8472 /* draw radiobutton gadgets */
8473 for (i=ED_RADIOBUTTON_ID_EDITOR_FIRST; i<= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
8474 MapRadiobuttonGadget(i);
8476 /* draw drawing area */
8477 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
8479 /* draw textbutton gadgets */
8480 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2);
8483 static void DrawLevelInfoWindow()
8485 char *text = "Global Settings";
8486 int font_nr = FONT_TITLE_1;
8487 struct MenuPosInfo *pos = &editor.settings.headline;
8488 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font_nr), pos->align);
8489 int sy = SY + pos->y;
8491 stick_element_properties_window = FALSE;
8493 UnmapLevelEditorFieldGadgets();
8495 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
8498 DrawText(sx, sy, text, font_nr);
8500 DrawLevelInfoTabulatorGadgets();
8502 if (edit_mode_levelinfo == ED_MODE_LEVELINFO_LEVEL)
8503 DrawLevelInfoLevel();
8504 else /* (edit_mode_levelinfo == ED_MODE_LEVELINFO_EDITOR) */
8505 DrawLevelInfoEditor();
8508 static void DrawCustomContentArea()
8510 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
8511 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
8512 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
8513 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
8514 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
8515 int xoffset = ED_GADGET_SPACE_DISTANCE;
8517 /* add distance for potential left text (without drawing area border) */
8518 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
8520 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
8522 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
8525 static void DrawCustomChangeContentArea()
8527 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
8528 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
8529 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
8530 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
8531 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
8532 int xoffset = ED_GADGET_SPACE_DISTANCE;
8534 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
8539 static void RemoveElementContentArea(int id, int font_height)
8541 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
8543 DrawBackground(SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size,
8544 SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size,
8545 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
8546 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size +
8547 ED_GADGET_TEXT_DISTANCE + font_height);
8550 static void DrawYamYamContentAreas()
8552 int font_nr = FONT_TEXT_1;
8553 int font_height = getFontHeight(font_nr);
8554 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
8555 int yoffset = (tilesize - font_height) / 2;
8556 int x = SX + ED_AREA_YAMYAM_CONTENT_X(3) + 4 * tilesize;
8557 int y = SY + ED_AREA_YAMYAM_CONTENT_Y(3) + yoffset;
8560 /* display counter to choose number of element content areas */
8561 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
8563 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
8565 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
8567 if (i < level.num_yamyam_contents)
8573 UnmapDrawingArea(id);
8575 /* delete content areas in case of reducing number of them */
8576 RemoveElementContentArea(id, font_height);
8580 DrawText(x, y + 0 * tilesize, "content", font_nr);
8581 DrawText(x, y + 1 * tilesize, "when", font_nr);
8582 DrawText(x, y + 2 * tilesize, "smashed", font_nr);
8585 static void DrawMagicBallContentAreas()
8587 int font_nr = FONT_TEXT_1;
8588 int font_height = getFontHeight(font_nr);
8589 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
8590 int yoffset = (tilesize - font_height) / 2;
8591 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_X(3) + 4 * tilesize;
8592 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_Y(3) + yoffset;
8595 /* display counter to choose number of element content areas */
8596 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
8598 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
8600 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
8602 if (i < level.num_ball_contents)
8608 UnmapDrawingArea(id);
8610 /* delete content areas in case of reducing number of them */
8611 RemoveElementContentArea(id, font_height);
8615 DrawText(x, y + 0 * tilesize, "generated", font_nr);
8616 DrawText(x, y + 1 * tilesize, "when", font_nr);
8617 DrawText(x, y + 2 * tilesize, "active", font_nr);
8620 static void DrawAndroidElementArea(int element)
8622 int id = ED_DRAWING_ID_ANDROID_CONTENT;
8623 int num_elements = level.num_android_clone_elements;
8624 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
8625 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
8626 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
8627 int xsize = MAX_ANDROID_ELEMENTS;
8630 /* display counter to choose number of element areas */
8631 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
8633 if (drawingarea_info[id].text_left != NULL)
8634 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
8636 UnmapDrawingArea(id);
8638 ModifyEditorDrawingArea(id, num_elements, 1);
8640 /* delete content areas in case of reducing number of them */
8641 DrawBackground(sx, sy,
8642 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
8643 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
8648 static void DrawGroupElementArea(int element)
8650 int id = ED_DRAWING_ID_GROUP_CONTENT;
8651 int num_elements = group_element_info.num_elements;
8652 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
8653 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
8654 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
8655 int xsize = MAX_ELEMENTS_IN_GROUP;
8658 if (drawingarea_info[id].text_left != NULL)
8659 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
8661 UnmapDrawingArea(id);
8663 ModifyEditorDrawingArea(id, num_elements, 1);
8665 /* delete content areas in case of reducing number of them */
8666 DrawBackground(sx, sy,
8667 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
8668 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
8673 static void DrawPlayerInitialInventoryArea(int element)
8675 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
8676 int player_nr = GET_PLAYER_NR(element);
8677 int num_elements = level.initial_inventory_size[player_nr];
8678 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
8679 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
8680 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
8681 int xsize = MAX_INITIAL_INVENTORY_SIZE;
8684 /* determine horizontal position to the right of specified gadget */
8685 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
8686 sx = (right_gadget_border[drawingarea_info[id].gadget_id_align] +
8687 ED_DRAWINGAREA_TEXT_DISTANCE);
8689 /* determine horizontal offset for leading text */
8690 if (drawingarea_info[id].text_left != NULL)
8691 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
8693 UnmapDrawingArea(id);
8695 ModifyEditorDrawingArea(id, num_elements, 1);
8697 /* delete content areas in case of reducing number of them */
8698 DrawBackground(sx, sy,
8699 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
8700 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
8705 static void DrawEnvelopeTextArea(int envelope_nr)
8707 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
8708 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
8711 DrawBackground(gi->x, gi->y, gi->width, gi->height);
8713 if (envelope_nr != -1)
8714 textarea_info[id].value = level.envelope[envelope_nr].text;
8716 ModifyGadget(gi, GDI_AREA_SIZE,
8717 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
8718 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
8721 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
8724 static void PrintInfoText(char *text, int font_nr, int xpos, int ypos)
8726 DrawText(SX + xpos, SY + ypos, text, font_nr);
8729 static int PrintElementDescriptionFromFile(char *filename, int font_nr,
8732 int font_width = getFontWidth(font_nr);
8733 int font_height = getFontHeight(font_nr);
8734 int max_chars_per_line = (SXSIZE - 2 * xpos) / font_width;
8735 int max_lines_drawable = (SYSIZE - ypos) / font_height - 1;
8737 return DrawTextFile(SX + xpos, SY + ypos, filename, font_nr,
8738 max_chars_per_line, -1, max_lines_drawable, 0, -1,
8739 TRUE, FALSE, FALSE);
8742 static void DrawPropertiesInfo()
8751 /* configurable properties */
8753 { EP_WALKABLE_OVER, "- player can walk over it" },
8754 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
8755 { EP_WALKABLE_UNDER, "- player can walk under it" },
8756 { EP_PASSABLE_OVER, "- player can pass over it" },
8757 { EP_PASSABLE_INSIDE, "- player can pass through it" },
8758 { EP_PASSABLE_UNDER, "- player can pass under it" },
8759 { EP_PROTECTED, "- player is protected by it" },
8761 { EP_DIGGABLE, "- can be digged away" },
8762 { EP_COLLECTIBLE, "- can be collected" },
8763 { EP_DROPPABLE, "- can be dropped after collecting" },
8764 { EP_THROWABLE, "- can be thrown after collecting" },
8765 { EP_PUSHABLE, "- can be pushed" },
8767 { EP_CAN_FALL, "- can fall" },
8768 { EP_CAN_MOVE, "- can move" },
8770 { EP_CAN_SMASH_PLAYER, "- can smash player" },
8772 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
8774 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
8776 { EP_SLIPPERY, "- slippery for falling elements" },
8777 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
8779 { EP_DONT_RUN_INTO, "- deadly when running into" },
8780 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
8781 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
8782 { EP_DONT_TOUCH, "- deadly when touching" },
8784 { EP_INDESTRUCTIBLE, "- indestructible" },
8786 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
8787 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
8788 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
8790 { EP_CAN_CHANGE, "- can change to other element" },
8792 /* pre-defined properties */
8793 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
8794 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
8795 { EP_SWITCHABLE, "- can be switched" },
8797 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
8802 char *filename = getElementDescriptionFilename(properties_element);
8803 char *percentage_text = "In this level: ";
8804 char *properties_text = "Standard properties: ";
8805 char *description_text = "Description:";
8806 char *no_description_text = "No description available.";
8807 char *none_text = "None";
8809 int num_elements_in_level;
8810 int num_standard_properties = 0;
8811 int font1_nr = FONT_TEXT_1;
8812 int font2_nr = FONT_TEXT_2;
8813 int font1_width = getFontWidth(font1_nr);
8814 int font1_height = getFontHeight(font1_nr);
8815 int font2_height = getFontHeight(font2_nr);
8816 int line1_height = font1_height + ED_GADGET_LINE_DISTANCE;
8817 int font2_yoffset = (font1_height - font2_height) / 2;
8818 int percentage_text_len = strlen(percentage_text) * font1_width;
8819 int properties_text_len = strlen(properties_text) * font1_width;
8820 int xpos = ED_ELEMENT_SETTINGS_X(0);
8821 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
8824 if (setup.editor.show_element_token)
8826 int font3_nr = FONT_TEXT_3;
8827 int font3_height = getFontHeight(font3_nr);
8829 DrawTextF(xpos, ypos, font3_nr,
8830 "[%s]", element_info[properties_element].token_name);
8832 ypos += 2 * font3_height;
8835 /* ----- print number of elements / percentage of this element in level */
8837 num_elements_in_level = 0;
8838 for (y = 0; y < lev_fieldy; y++)
8839 for (x = 0; x < lev_fieldx; x++)
8840 if (Feld[x][y] == properties_element)
8841 num_elements_in_level++;
8842 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
8844 DrawTextS(xpos, ypos, font1_nr, percentage_text);
8846 if (num_elements_in_level > 0)
8847 DrawTextF(xpos + percentage_text_len, ypos + font2_yoffset, font2_nr,
8848 "%d (%.2f %%)", num_elements_in_level, percentage);
8850 DrawTextF(xpos + percentage_text_len, ypos + font2_yoffset, font2_nr,
8853 ypos += 2 * MAX(font1_height, font2_height);
8855 /* ----- print standard properties of this element */
8857 DrawTextS(xpos, ypos, font1_nr, properties_text);
8859 ypos += line1_height;
8861 for (i = 0; properties[i].value != -1; i++)
8863 if (!HAS_PROPERTY(properties_element, properties[i].value))
8866 DrawTextS(xpos, ypos, font2_nr, properties[i].text);
8868 ypos += font2_height;
8870 num_standard_properties++;
8873 if (num_standard_properties == 0)
8875 DrawTextS(xpos + properties_text_len, ypos - line1_height + font2_yoffset,
8876 font2_nr, none_text);
8878 ypos -= (line1_height - font1_height);
8881 ypos += MAX(font1_height, font2_height);
8883 /* ----- print special description of this element */
8885 PrintInfoText(description_text, font1_nr, xpos, ypos);
8887 ypos += line1_height;
8889 if (PrintElementDescriptionFromFile(filename, font2_nr, xpos, ypos) == 0)
8890 PrintInfoText(no_description_text, font1_nr, xpos, ypos - line1_height);
8893 #define TEXT_COLLECTING "Score for collecting"
8894 #define TEXT_SMASHING "Score for smashing"
8895 #define TEXT_SLURPING "Score for slurping robot"
8896 #define TEXT_CRACKING "Score for cracking"
8897 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
8898 #define TEXT_DURATION "Duration when activated"
8899 #define TEXT_BALL_DELAY "Element generation delay"
8900 #define TEXT_MOVE_SPEED "Speed of android moving"
8901 #define TEXT_CLONE_SPEED "Speed of android cloning"
8902 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
8903 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
8904 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
8905 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
8906 #define TEXT_TIME_BONUS "Extra time to solve level"
8913 } elements_with_counter[] =
8915 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
8916 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
8917 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
8918 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
8919 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
8920 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
8921 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
8922 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
8923 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
8924 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
8925 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
8926 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
8927 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
8928 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
8929 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
8930 { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
8931 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
8932 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
8933 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
8934 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
8935 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8936 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8937 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8938 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8939 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8940 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8941 { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
8942 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8943 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8944 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8945 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
8946 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
8947 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
8948 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
8949 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
8950 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
8951 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
8952 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
8953 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
8954 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
8955 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
8956 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
8957 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
8958 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
8959 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
8960 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
8961 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE],TEXT_COLLECTING },
8962 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
8963 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
8964 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
8965 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
8966 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
8967 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
8968 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
8969 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
8970 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
8971 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
8972 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
8973 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
8974 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
8975 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
8976 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
8977 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
8978 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
8979 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
8980 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
8981 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
8982 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
8983 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
8984 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
8985 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
8986 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
8987 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
8988 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
8990 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
8991 { EL_DC_TIMEGATE_SWITCH,&level.time_timegate, TEXT_DURATION },
8992 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
8993 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
8994 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
8995 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
8996 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
8997 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
8998 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
8999 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
9000 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
9001 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
9002 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
9003 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
9004 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
9005 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
9007 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
9008 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
9009 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
9010 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
9011 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
9012 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
9013 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
9014 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
9019 static boolean checkPropertiesConfig(int element)
9023 if (IS_GEM(element) ||
9024 IS_CUSTOM_ELEMENT(element) ||
9025 IS_GROUP_ELEMENT(element) ||
9026 IS_ENVELOPE(element) ||
9027 ELEM_IS_PLAYER(element) ||
9028 HAS_EDITOR_CONTENT(element) ||
9029 CAN_GROW(element) ||
9030 COULD_MOVE_INTO_ACID(element) ||
9031 MAYBE_DONT_COLLIDE_WITH(element) ||
9032 element == EL_SOKOBAN_OBJECT ||
9033 element == EL_SOKOBAN_FIELD_EMPTY ||
9034 element == EL_SOKOBAN_FIELD_FULL)
9037 for (i = 0; elements_with_counter[i].element != -1; i++)
9038 if (elements_with_counter[i].element == element)
9044 static void DrawPropertiesConfig()
9046 boolean draw_footer_line = FALSE;
9047 int max_num_element_counters = 4;
9048 int num_element_counters = 0;
9051 if (!checkPropertiesConfig(properties_element))
9053 int xpos = ED_ELEMENT_SETTINGS_X(0);
9054 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
9056 PrintInfoText("No configuration options available.",
9057 FONT_TEXT_1, xpos, ypos);
9062 /* check if there are elements where a value can be chosen for */
9063 for (i = 0; elements_with_counter[i].element != -1; i++)
9065 if (elements_with_counter[i].element == properties_element)
9067 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
9069 counterbutton_info[counter_id].y =
9070 ED_ELEMENT_SETTINGS_YPOS(
9071 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
9072 (CAN_GROW(properties_element) ? 1 : 0) +
9073 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
9074 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
9075 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
9076 num_element_counters);
9078 counterbutton_info[counter_id].value = elements_with_counter[i].value;
9079 counterbutton_info[counter_id].text_right= elements_with_counter[i].text;
9081 if (properties_element == EL_GAME_OF_LIFE ||
9082 properties_element == EL_BIOMAZE)
9084 counterbutton_info[counter_id].min_value = 0; /* min neighbours */
9085 counterbutton_info[counter_id].max_value = 8; /* max neighbours */
9089 /* !!! CHANGE THIS FOR CERTAIN ELEMENTS !!! */
9090 counterbutton_info[counter_id].min_value = MIN_SCORE;
9091 counterbutton_info[counter_id].max_value = MAX_SCORE;
9094 MapCounterButtons(counter_id);
9096 num_element_counters++;
9097 if (num_element_counters >= max_num_element_counters)
9102 if (HAS_EDITOR_CONTENT(properties_element))
9104 /* draw stickybutton gadget */
9105 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
9107 if (IS_AMOEBOID(properties_element))
9108 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
9109 else if (properties_element == EL_YAMYAM ||
9110 properties_element == EL_YAMYAM_LEFT ||
9111 properties_element == EL_YAMYAM_RIGHT ||
9112 properties_element == EL_YAMYAM_UP ||
9113 properties_element == EL_YAMYAM_DOWN)
9114 DrawYamYamContentAreas();
9115 else if (properties_element == EL_EMC_MAGIC_BALL)
9117 DrawMagicBallContentAreas();
9119 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
9120 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_STATE);
9122 else if (properties_element == EL_EMC_ANDROID)
9123 DrawAndroidElementArea(properties_element);
9126 if (ELEM_IS_PLAYER(properties_element))
9128 int player_nr = GET_PLAYER_NR(properties_element);
9130 /* these properties can be set for every player individually */
9132 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
9134 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
9135 &level.start_element[player_nr];
9136 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
9137 &level.artwork_element[player_nr];
9138 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
9139 &level.explosion_element[player_nr];
9141 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
9142 &level.use_start_element[player_nr];
9143 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
9144 &level.use_artwork_element[player_nr];
9145 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
9146 &level.use_explosion_element[player_nr];
9147 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
9148 &level.initial_player_gravity[player_nr];
9150 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
9151 &level.initial_player_stepsize[player_nr];
9153 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
9154 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
9155 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
9156 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
9157 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
9158 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
9159 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
9160 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
9161 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_LAZY_RELOCATION);
9162 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
9163 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
9164 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
9165 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
9166 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
9168 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
9169 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
9170 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
9172 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
9174 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
9176 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
9177 &level.initial_inventory_content[player_nr][0];
9179 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
9180 &level.initial_inventory_size[player_nr];
9182 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
9183 &level.use_initial_inventory[player_nr];
9185 /* draw checkbutton gadgets */
9186 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
9188 /* draw counter gadgets */
9189 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
9191 /* draw drawing area gadgets */
9192 DrawPlayerInitialInventoryArea(properties_element);
9196 if (IS_GEM(properties_element))
9197 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
9199 if (properties_element == EL_EM_DYNAMITE)
9200 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
9202 if (COULD_MOVE_INTO_ACID(properties_element) &&
9203 !ELEM_IS_PLAYER(properties_element) &&
9204 (!IS_CUSTOM_ELEMENT(properties_element) ||
9205 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
9207 /* set position for checkbutton for "can move into acid" */
9208 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
9209 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
9210 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
9211 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 6 :
9212 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
9214 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
9217 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
9218 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
9220 if (properties_element == EL_SPRING)
9221 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
9223 if (properties_element == EL_TIME_ORB_FULL)
9224 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
9226 if (CAN_GROW(properties_element))
9228 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
9229 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
9231 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
9234 if (properties_element == EL_SOKOBAN_OBJECT ||
9235 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
9236 properties_element == EL_SOKOBAN_FIELD_FULL)
9237 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
9239 if (IS_ENVELOPE(properties_element))
9241 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
9242 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
9243 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
9244 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
9245 int envelope_nr = properties_element - EL_ENVELOPE_1;
9247 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
9248 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
9250 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
9251 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
9253 /* display counter to choose size of envelope text area */
9254 MapCounterButtons(counter1_id);
9255 MapCounterButtons(counter2_id);
9257 /* display checkbuttons to choose auto-wrap and alignment properties */
9258 MapCheckbuttonGadget(button1_id);
9259 MapCheckbuttonGadget(button2_id);
9261 DrawEnvelopeTextArea(envelope_nr);
9264 if (IS_CUSTOM_ELEMENT(properties_element))
9266 /* draw stickybutton gadget */
9267 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
9269 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
9271 /* draw checkbutton gadgets */
9272 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
9273 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
9274 MapCheckbuttonGadget(i);
9276 /* draw counter gadgets */
9277 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
9278 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
9279 MapCounterButtons(i);
9281 /* draw selectbox gadgets */
9282 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
9283 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
9284 MapSelectboxGadget(i);
9286 /* draw textbutton gadgets */
9287 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
9289 /* draw text input gadgets */
9290 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
9292 /* draw drawing area gadgets */
9293 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
9295 draw_footer_line = TRUE;
9297 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
9299 /* draw checkbutton gadgets */
9300 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
9301 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
9302 MapCheckbuttonGadget(i);
9304 /* draw counter gadgets */
9305 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
9306 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
9307 MapCounterButtons(i);
9309 /* draw selectbox gadgets */
9310 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
9311 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
9312 MapSelectboxGadget(i);
9314 /* draw drawing area gadgets */
9315 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
9316 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
9317 DrawCustomContentArea();
9320 else if (IS_GROUP_ELEMENT(properties_element))
9322 /* draw stickybutton gadget */
9323 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
9325 /* draw checkbutton gadgets */
9326 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
9327 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
9329 /* draw counter gadgets */
9330 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
9332 /* draw selectbox gadgets */
9333 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
9335 /* draw textbutton gadgets */
9336 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
9338 /* draw drawing area gadgets */
9339 DrawGroupElementArea(properties_element);
9341 /* draw text input gadgets */
9342 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
9344 /* draw drawing area gadgets */
9345 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
9347 draw_footer_line = TRUE;
9350 /* draw little footer border line above CE/GE use/save template gadgets */
9351 if (draw_footer_line)
9353 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9354 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9355 int gd_x = gd->x + gd_gi1->border.width / 2;
9356 int gd_y = gd->y + gd_gi1->height - 1;
9357 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
9359 if (tab_color != BLACK_PIXEL) /* black => transparent */
9360 FillRectangle(drawto,
9361 SX + ED_ELEMENT_SETTINGS_X(0),
9362 SY + ED_ELEMENT_SETTINGS_Y(14) - ED_SETTINGS_TABS_YOFFSET -
9364 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9368 static void DrawPropertiesChangeDrawingAreas()
9370 if (IS_CUSTOM_ELEMENT(properties_element))
9372 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
9373 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
9374 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
9376 DrawCustomChangeContentArea();
9379 redraw_mask |= REDRAW_FIELD;
9382 static void DrawPropertiesChange()
9386 /* needed to initially set selectbox options for special action options */
9387 setSelectboxSpecialActionOptions();
9389 /* draw stickybutton gadget */
9390 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
9392 /* draw checkbutton gadgets */
9393 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
9394 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
9395 MapCheckbuttonGadget(i);
9397 /* draw counter gadgets */
9398 for (i = ED_COUNTER_ID_CHANGE_FIRST;
9399 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
9400 MapCounterButtons(i);
9402 /* draw selectbox gadgets */
9403 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
9404 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
9405 MapSelectboxGadget(i);
9407 /* draw textbutton gadgets */
9408 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
9409 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
9410 MapTextbuttonGadget(i);
9412 /* draw graphicbutton gadgets */
9413 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
9414 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
9415 MapGraphicbuttonGadget(i);
9417 /* draw drawing area gadgets */
9418 DrawPropertiesChangeDrawingAreas();
9421 static void DrawEditorElementAnimation(int x, int y)
9423 int graphic = el2img(properties_element);
9424 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
9425 custom_element.ce_value_fixed_initial :
9426 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
9427 custom_element.collect_score_initial : FrameCounter);
9429 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
9432 static void DrawEditorElementName(int x, int y, int font_nr)
9434 char *element_name = getElementInfoText(properties_element);
9435 int font_width = getFontWidth(font_nr);
9436 int font_height = getFontHeight(font_nr);
9437 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
9438 int max_chars_per_line = max_text_width / font_width;
9439 char buffer[max_chars_per_line + 1];
9441 if (strlen(element_name) <= max_chars_per_line)
9442 DrawTextS(x, y, font_nr, element_name);
9445 int next_pos = max_chars_per_line;
9447 strncpy(buffer, element_name, max_chars_per_line);
9448 buffer[max_chars_per_line] = '\0';
9450 if (element_name[max_chars_per_line] == ' ')
9456 for (i = max_chars_per_line - 1; i >= 0; i--)
9457 if (buffer[i] == ' ')
9460 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
9467 DrawTextS(x, y - font_height / 2, font_nr, buffer);
9469 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
9470 buffer[max_chars_per_line] = '\0';
9472 DrawTextS(x, y + font_height / 2, font_nr, buffer);
9476 static void DrawPropertiesWindow()
9478 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
9479 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
9480 int border_size = gd->border_size;
9481 int font_nr = FONT_TEXT_1;
9482 int font_height = getFontHeight(font_nr);
9483 int xoffset = TILEX + element_border + 3 * border_size;
9484 int yoffset = (TILEY - font_height) / 2;
9485 int x1 = editor.settings.element_graphic.x + element_border;
9486 int y1 = editor.settings.element_graphic.y + element_border;
9487 int x2 = (editor.settings.element_name.x == -1 ? x1 + xoffset :
9488 editor.settings.element_name.x);
9489 int y2 = (editor.settings.element_name.y == -1 ? y1 + yoffset :
9490 editor.settings.element_name.y);
9491 char *text = "Element Settings";
9492 int font2_nr = FONT_TITLE_1;
9493 struct MenuPosInfo *pos = &editor.settings.headline;
9494 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font2_nr), pos->align);
9495 int sy = SY + pos->y;
9497 stick_element_properties_window = FALSE;
9499 /* make sure that previous properties edit mode exists for this element */
9500 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
9501 !IS_CUSTOM_ELEMENT(properties_element))
9502 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
9504 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
9505 !ELEM_IS_PLAYER(properties_element) &&
9506 !IS_CUSTOM_ELEMENT(properties_element))
9507 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
9509 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
9510 (ELEM_IS_PLAYER(properties_element) ||
9511 IS_CUSTOM_ELEMENT(properties_element)))
9512 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
9514 CopyElementPropertiesToEditor(properties_element);
9516 UnmapLevelEditorFieldGadgets();
9517 UnmapLevelEditorToolboxDrawingGadgets();
9518 UnmapLevelEditorToolboxCustomGadgets();
9520 if (IS_CUSTOM_ELEMENT(properties_element) ||
9521 IS_GROUP_ELEMENT(properties_element))
9522 MapLevelEditorToolboxCustomGadgets();
9524 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
9527 DrawText(sx, sy, text, font2_nr);
9529 FrameCounter = 0; /* restart animation frame counter */
9531 DrawElementBorder(SX + x1, SY + y1, TILEX, TILEY, FALSE);
9532 DrawEditorElementAnimation(SX + x1, SY + y1);
9533 DrawEditorElementName(x2, y2, font_nr);
9535 DrawPropertiesTabulatorGadgets();
9537 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
9538 DrawPropertiesInfo();
9539 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
9540 DrawPropertiesChange();
9541 else /* (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2]) */
9542 DrawPropertiesConfig();
9545 static void DrawPaletteWindow()
9549 UnmapLevelEditorFieldGadgets();
9551 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
9554 /* map buttons to select elements */
9555 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
9556 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
9557 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
9558 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
9559 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
9562 static void UpdateCustomElementGraphicGadgets()
9566 InitElementPropertiesGfxElement();
9568 ModifyEditorElementList();
9569 RedrawDrawingElements();
9571 /* force redraw of all mapped drawing area gadgets */
9572 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
9574 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
9581 static int getOpenDirectionFromTube(int element)
9585 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
9586 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
9587 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
9588 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
9589 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
9590 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
9591 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
9592 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
9593 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
9594 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
9595 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
9601 static int getTubeFromOpenDirection(int direction)
9605 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
9606 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
9607 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
9608 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
9609 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
9610 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
9611 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
9612 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
9613 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
9614 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
9615 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
9617 /* if only one direction, fall back to simple tube with that direction */
9618 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
9619 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
9620 case (MV_UP): return EL_TUBE_VERTICAL;
9621 case (MV_DOWN): return EL_TUBE_VERTICAL;
9627 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
9629 int element_new = getTubeFromOpenDirection(direction);
9631 return (element_new != EL_EMPTY ? element_new : element_old);
9634 static int getOpenDirectionFromBelt(int element)
9636 int belt_dir = getBeltDirFromBeltElement(element);
9638 return (belt_dir == MV_LEFT ? MV_RIGHT :
9639 belt_dir == MV_RIGHT ? MV_LEFT :
9640 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
9643 static int getBeltFromNrAndOpenDirection(int nr, int direction)
9645 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
9646 direction == MV_RIGHT ? MV_LEFT :
9647 direction == MV_HORIZONTAL ? MV_NONE : direction);
9649 if (direction == MV_NONE)
9652 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
9655 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
9658 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
9660 return (element_new != EL_EMPTY ? element_new : element_old);
9663 static int getOpenDirectionFromPool(int element)
9667 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
9668 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
9669 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
9670 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
9671 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
9672 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
9678 static int getPoolFromOpenDirection(int direction)
9682 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
9683 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
9684 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
9685 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
9686 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
9687 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
9693 static int getPoolFromOpenDirectionExt(int direction, int help_element)
9695 int element = getPoolFromOpenDirection(direction);
9696 int help_direction = getOpenDirectionFromPool(help_element);
9698 if (element == EL_EMPTY)
9700 int help_direction_vertical = help_direction & MV_VERTICAL;
9702 element = getPoolFromOpenDirection(direction | help_direction_vertical);
9705 if (element == EL_EMPTY)
9707 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
9709 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
9715 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
9717 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
9719 return (element_new != EL_EMPTY ? element_new : element_old);
9722 static int getOpenDirectionFromPillar(int element)
9726 case EL_EMC_WALL_1: return (MV_DOWN);
9727 case EL_EMC_WALL_2: return (MV_VERTICAL);
9728 case EL_EMC_WALL_3: return (MV_UP);
9734 static int getPillarFromOpenDirection(int direction)
9738 case (MV_DOWN): return EL_EMC_WALL_1;
9739 case (MV_VERTICAL): return EL_EMC_WALL_2;
9740 case (MV_UP): return EL_EMC_WALL_3;
9746 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
9748 int element_new = getPillarFromOpenDirection(direction);
9750 return (element_new != EL_EMPTY ? element_new : element_old);
9753 static int getOpenDirectionFromSteel2(int element)
9757 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
9758 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
9759 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
9760 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
9761 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
9762 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
9763 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
9764 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
9770 static int getSteel2FromOpenDirection(int direction)
9774 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
9775 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
9776 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
9777 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
9778 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
9779 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
9780 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
9781 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
9787 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
9789 int element_new = getSteel2FromOpenDirection(direction);
9791 return (element_new != EL_EMPTY ? element_new : element_old);
9794 static int getOpenDirectionFromChip(int element)
9798 case EL_SP_CHIP_SINGLE: return (MV_NONE);
9799 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
9800 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
9801 case EL_SP_CHIP_TOP: return (MV_DOWN);
9802 case EL_SP_CHIP_BOTTOM: return (MV_UP);
9808 static int getChipFromOpenDirection(int direction)
9812 case (MV_NONE): return EL_SP_CHIP_SINGLE;
9813 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
9814 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
9815 case (MV_UP): return EL_SP_CHIP_BOTTOM;
9816 case (MV_DOWN): return EL_SP_CHIP_TOP;
9822 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
9824 int element_new = getChipFromOpenDirection(direction);
9826 return (element_new != EL_EMPTY ? element_new : element_old);
9829 static int getClosedTube(int x, int y)
9831 static int xy[4][2] =
9838 int element_old = IntelliDrawBuffer[x][y];
9839 int direction_old = getOpenDirectionFromTube(element_old);
9840 int direction_new = MV_NONE;
9843 for (i = 0; i < NUM_DIRECTIONS; i++)
9845 int xx = x + xy[i][0];
9846 int yy = y + xy[i][1];
9847 int dir = MV_DIR_FROM_BIT(i);
9848 int dir_opposite = MV_DIR_OPPOSITE(dir);
9850 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
9851 (direction_old & dir) &&
9852 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
9853 direction_new |= dir;
9856 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
9859 static int getClosedBelt(int x, int y)
9861 static int xy[4][2] =
9868 int element_old = IntelliDrawBuffer[x][y];
9869 int nr = getBeltNrFromBeltElement(element_old);
9870 int direction_old = getOpenDirectionFromBelt(element_old);
9871 int direction_new = MV_NONE;
9874 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
9876 int xx = x + xy[i][0];
9877 int yy = y + xy[i][1];
9878 int dir = MV_DIR_FROM_BIT(i);
9879 int dir_opposite = MV_DIR_OPPOSITE(dir);
9881 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
9882 (direction_old & dir) &&
9883 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
9884 direction_new |= dir;
9887 return getBeltFromNrAndOpenDirection(nr, direction_new);
9890 static int getClosedPool(int x, int y)
9892 static int xy[4][2] =
9899 int element_old = IntelliDrawBuffer[x][y];
9900 int direction_old = getOpenDirectionFromPool(element_old);
9901 int direction_new = MV_NONE;
9904 for (i = 0; i < NUM_DIRECTIONS; i++)
9906 int xx = x + xy[i][0];
9907 int yy = y + xy[i][1];
9908 int dir = MV_DIR_FROM_BIT(i);
9909 int dir_opposite = MV_DIR_OPPOSITE(dir);
9911 if (IN_LEV_FIELD(xx, yy) &&
9912 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
9913 (direction_old & dir) &&
9914 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
9915 direction_new |= dir;
9918 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
9921 static int getClosedPillar(int x, int y)
9923 static int xy[4][2] =
9930 int element_old = IntelliDrawBuffer[x][y];
9931 int direction_old = getOpenDirectionFromPillar(element_old);
9932 int direction_new = MV_NONE;
9935 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
9937 int xx = x + xy[i][0];
9938 int yy = y + xy[i][1];
9939 int dir = MV_DIR_FROM_BIT(i);
9940 int dir_opposite = MV_DIR_OPPOSITE(dir);
9942 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
9943 (direction_old & dir) &&
9944 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
9945 direction_new |= dir;
9948 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
9951 static int getClosedSteel2(int x, int y)
9953 static int xy[4][2] =
9960 int element_old = IntelliDrawBuffer[x][y];
9961 int direction_old = getOpenDirectionFromSteel2(element_old);
9962 int direction_new = MV_NONE;
9965 for (i = 0; i < NUM_DIRECTIONS; i++)
9967 int xx = x + xy[i][0];
9968 int yy = y + xy[i][1];
9969 int dir = MV_DIR_FROM_BIT(i);
9970 int dir_opposite = MV_DIR_OPPOSITE(dir);
9972 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
9973 (direction_old & dir) &&
9974 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
9975 direction_new |= dir;
9978 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
9981 static int getClosedChip(int x, int y)
9983 static int xy[4][2] =
9990 int element_old = IntelliDrawBuffer[x][y];
9991 int direction_old = getOpenDirectionFromChip(element_old);
9992 int direction_new = MV_NONE;
9995 for (i = 0; i < NUM_DIRECTIONS; i++)
9997 int xx = x + xy[i][0];
9998 int yy = y + xy[i][1];
9999 int dir = MV_DIR_FROM_BIT(i);
10000 int dir_opposite = MV_DIR_OPPOSITE(dir);
10002 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
10003 (direction_old & dir) &&
10004 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10005 direction_new |= dir;
10008 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
10011 static void SetElementSimple(int x, int y, int element, boolean change_level)
10013 int sx = x - level_xpos;
10014 int sy = y - level_ypos;
10016 IntelliDrawBuffer[x][y] = element;
10019 Feld[x][y] = element;
10021 if (IN_ED_FIELD(sx, sy))
10022 DrawEditorElement(sx, sy, element);
10025 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
10026 int x2, int y2, int *element2,
10027 int (*close_function)(int, int),
10028 boolean change_level)
10030 /* set neighbour elements to newly determined connections */
10031 SetElementSimple(x1, y1, *element1, change_level);
10032 SetElementSimple(x2, y2, *element2, change_level);
10034 /* remove all open connections of neighbour elements */
10035 *element1 = close_function(x1, y1);
10036 *element2 = close_function(x2, y2);
10038 /* set neighbour elements to new, minimized connections */
10039 SetElementSimple(x1, y1, *element1, change_level);
10040 SetElementSimple(x2, y2, *element2, change_level);
10043 static void SetElementIntelliDraw(int x, int y, int new_element,
10044 boolean change_level, int button)
10046 static int xy[4][2] =
10053 static int last_x = -1;
10054 static int last_y = -1;
10055 int old_element = IntelliDrawBuffer[x][y];
10057 if (new_element == EL_UNDEFINED)
10065 if (IS_TUBE(new_element))
10067 int last_element_new = EL_UNDEFINED;
10068 int direction = MV_NONE;
10071 /* if old element is of same kind, keep all existing directions */
10072 if (IS_TUBE(old_element))
10073 direction |= getOpenDirectionFromTube(old_element);
10075 for (i = 0; i < NUM_DIRECTIONS; i++)
10077 int xx = x + xy[i][0];
10078 int yy = y + xy[i][1];
10080 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10081 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
10083 int dir = MV_DIR_FROM_BIT(i);
10084 int dir_opposite = MV_DIR_OPPOSITE(dir);
10085 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10086 int last_direction_old = getOpenDirectionFromTube(last_element_old);
10087 int last_direction_new = last_direction_old | dir_opposite;
10089 last_element_new = getTubeFromOpenDirection(last_direction_new);
10095 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
10097 if (last_element_new != EL_UNDEFINED)
10098 MergeAndCloseNeighbourElements(x, y, &new_element,
10099 last_x, last_y, &last_element_new,
10100 getClosedTube, change_level);
10102 else if (IS_BELT(new_element))
10104 int belt_nr = getBeltNrFromBeltElement(new_element);
10105 int last_element_new = EL_UNDEFINED;
10106 int direction = MV_NONE;
10109 /* if old element is of same kind, keep all existing directions */
10110 if (IS_BELT(old_element))
10111 direction |= getOpenDirectionFromBelt(old_element);
10113 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
10115 int xx = x + xy[i][0];
10116 int yy = y + xy[i][1];
10118 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10119 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
10121 int dir = MV_DIR_FROM_BIT(i);
10122 int dir_opposite = MV_DIR_OPPOSITE(dir);
10123 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10124 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
10125 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
10126 int last_direction_new = last_direction_old | dir_opposite;
10128 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
10129 last_direction_new);
10134 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
10136 if (last_element_new != EL_UNDEFINED)
10137 MergeAndCloseNeighbourElements(x, y, &new_element,
10138 last_x, last_y, &last_element_new,
10139 getClosedBelt, change_level);
10141 else if (IS_ACID_POOL_OR_ACID(new_element))
10143 int last_element_new = EL_UNDEFINED;
10144 int direction = MV_NONE;
10147 /* if old element is of same kind, keep all existing directions */
10148 if (IS_ACID_POOL_OR_ACID(old_element))
10149 direction |= getOpenDirectionFromPool(old_element);
10151 for (i = 0; i < NUM_DIRECTIONS; i++)
10153 int xx = x + xy[i][0];
10154 int yy = y + xy[i][1];
10156 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10157 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
10159 int dir = MV_DIR_FROM_BIT(i);
10160 int dir_opposite = MV_DIR_OPPOSITE(dir);
10161 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10162 int last_direction_old = getOpenDirectionFromPool(last_element_old);
10163 int last_direction_new = last_direction_old | dir_opposite;
10165 last_element_new = getPoolFromOpenDirection(last_direction_new);
10171 /* special corrections needed for intuitively correct acid pool drawing */
10172 if (last_element_new == EL_EMPTY)
10173 last_element_new = new_element;
10174 else if (last_element_new != EL_UNDEFINED)
10175 new_element = last_element_new;
10177 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
10179 if (last_element_new != EL_UNDEFINED)
10180 MergeAndCloseNeighbourElements(x, y, &new_element,
10181 last_x, last_y, &last_element_new,
10182 getClosedPool, change_level);
10184 else if (IS_EMC_PILLAR(new_element))
10186 int last_element_new = EL_UNDEFINED;
10187 int direction = MV_NONE;
10190 /* if old element is of same kind, keep all existing directions */
10191 if (IS_EMC_PILLAR(old_element))
10192 direction |= getOpenDirectionFromPillar(old_element);
10194 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
10196 int xx = x + xy[i][0];
10197 int yy = y + xy[i][1];
10199 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10200 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
10202 int dir = MV_DIR_FROM_BIT(i);
10203 int dir_opposite = MV_DIR_OPPOSITE(dir);
10204 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10205 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
10206 int last_direction_new = last_direction_old | dir_opposite;
10208 last_element_new = getPillarFromOpenDirection(last_direction_new);
10214 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
10216 if (last_element_new != EL_UNDEFINED)
10217 MergeAndCloseNeighbourElements(x, y, &new_element,
10218 last_x, last_y, &last_element_new,
10219 getClosedPillar, change_level);
10221 else if (IS_DC_STEELWALL_2(new_element))
10223 int last_element_new = EL_UNDEFINED;
10224 int direction = MV_NONE;
10227 /* if old element is of same kind, keep all existing directions */
10228 if (IS_DC_STEELWALL_2(old_element))
10229 direction |= getOpenDirectionFromSteel2(old_element);
10231 for (i = 0; i < NUM_DIRECTIONS; i++)
10233 int xx = x + xy[i][0];
10234 int yy = y + xy[i][1];
10236 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10237 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
10239 int dir = MV_DIR_FROM_BIT(i);
10240 int dir_opposite = MV_DIR_OPPOSITE(dir);
10241 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10242 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
10243 int last_direction_new = last_direction_old | dir_opposite;
10245 last_element_new = getSteel2FromOpenDirection(last_direction_new);
10251 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
10253 if (last_element_new != EL_UNDEFINED)
10254 MergeAndCloseNeighbourElements(x, y, &new_element,
10255 last_x, last_y, &last_element_new,
10256 getClosedSteel2, change_level);
10258 else if (IS_SP_CHIP(new_element))
10260 int last_element_new = EL_UNDEFINED;
10261 int direction = MV_NONE;
10264 /* (do not keep existing directions, regardless of kind of old element) */
10266 for (i = 0; i < NUM_DIRECTIONS; i++)
10268 int xx = x + xy[i][0];
10269 int yy = y + xy[i][1];
10271 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10272 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
10274 int dir = MV_DIR_FROM_BIT(i);
10275 int dir_opposite = MV_DIR_OPPOSITE(dir);
10276 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10277 int last_direction_old = getOpenDirectionFromChip(last_element_old);
10278 int last_direction_new = last_direction_old | dir_opposite;
10280 if (last_direction_old == MV_NONE)
10282 last_element_new = getChipFromOpenDirection(last_direction_new);
10285 else if (last_direction_old & (dir | dir_opposite))
10287 direction |= MV_DIR_OPPOSITE(last_direction_old);
10291 direction |= MV_DIR_OPPOSITE(dir);
10296 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
10298 if (last_element_new != EL_UNDEFINED)
10299 MergeAndCloseNeighbourElements(x, y, &new_element,
10300 last_x, last_y, &last_element_new,
10301 getClosedChip, change_level);
10303 else if (IS_SP_HARDWARE_BASE(new_element))
10305 int nr = GetSimpleRandom(6);
10307 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
10308 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
10309 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
10310 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
10311 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
10313 else if (new_element == EL_SP_HARDWARE_GREEN ||
10314 new_element == EL_SP_HARDWARE_BLUE ||
10315 new_element == EL_SP_HARDWARE_RED)
10317 int nr = GetSimpleRandom(3);
10319 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
10320 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
10322 else if (IS_GROUP_ELEMENT(new_element))
10324 boolean connected_drawing = FALSE;
10327 for (i = 0; i < NUM_DIRECTIONS; i++)
10329 int xx = x + xy[i][0];
10330 int yy = y + xy[i][1];
10332 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10333 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
10334 connected_drawing = TRUE;
10337 if (!connected_drawing)
10338 ResolveGroupElement(new_element);
10340 new_element = GetElementFromGroupElement(new_element);
10342 else if (IS_BELT_SWITCH(old_element))
10344 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
10345 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
10347 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
10348 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
10350 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
10354 static int swappable_elements[][2] =
10356 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
10357 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
10358 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
10359 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
10360 { EL_EMERALD, EL_WALL_EMERALD },
10361 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
10362 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
10363 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
10364 { EL_DIAMOND, EL_WALL_DIAMOND },
10365 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
10366 { EL_GATE_1, EL_GATE_1_GRAY },
10367 { EL_GATE_2, EL_GATE_2_GRAY },
10368 { EL_GATE_3, EL_GATE_3_GRAY },
10369 { EL_GATE_4, EL_GATE_4_GRAY },
10370 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
10371 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
10372 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
10373 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
10374 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
10375 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
10376 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
10377 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
10378 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
10379 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
10380 { EL_LAMP, EL_LAMP_ACTIVE },
10381 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
10382 { EL_SP_BASE, EL_SP_BUGGY_BASE },
10383 { EL_PEARL, EL_WALL_PEARL },
10384 { EL_CRYSTAL, EL_WALL_CRYSTAL },
10385 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
10386 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
10387 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
10388 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
10389 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
10390 { EL_LANDMINE, EL_DC_LANDMINE },
10391 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
10392 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
10393 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
10394 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
10395 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
10399 static int rotatable_elements[][4] =
10410 EL_SPACESHIP_RIGHT,
10416 EL_BD_BUTTERFLY_UP,
10417 EL_BD_BUTTERFLY_RIGHT,
10418 EL_BD_BUTTERFLY_DOWN,
10419 EL_BD_BUTTERFLY_LEFT
10424 EL_BD_FIREFLY_RIGHT,
10425 EL_BD_FIREFLY_DOWN,
10458 EL_SP_GRAVITY_PORT_UP,
10459 EL_SP_GRAVITY_PORT_RIGHT,
10460 EL_SP_GRAVITY_PORT_DOWN,
10461 EL_SP_GRAVITY_PORT_LEFT
10465 EL_SP_GRAVITY_ON_PORT_UP,
10466 EL_SP_GRAVITY_ON_PORT_RIGHT,
10467 EL_SP_GRAVITY_ON_PORT_DOWN,
10468 EL_SP_GRAVITY_ON_PORT_LEFT
10472 EL_SP_GRAVITY_OFF_PORT_UP,
10473 EL_SP_GRAVITY_OFF_PORT_RIGHT,
10474 EL_SP_GRAVITY_OFF_PORT_DOWN,
10475 EL_SP_GRAVITY_OFF_PORT_LEFT
10486 EL_BALLOON_SWITCH_UP,
10487 EL_BALLOON_SWITCH_RIGHT,
10488 EL_BALLOON_SWITCH_DOWN,
10489 EL_BALLOON_SWITCH_LEFT
10501 for (i = 0; swappable_elements[i][0] != -1; i++)
10503 int element1 = swappable_elements[i][0];
10504 int element2 = swappable_elements[i][1];
10506 if (old_element == element1 || old_element == element2)
10507 new_element = (old_element == element1 ? element2 : element1);
10510 for (i = 0; rotatable_elements[i][0] != -1; i++)
10512 for (j = 0; j < 4; j++)
10514 int element = rotatable_elements[i][j];
10516 if (old_element == element)
10517 new_element = (button == 1 ? rotatable_elements[i][(j + 3) % 4] :
10518 button == 2 ? rotatable_elements[i][0] :
10519 button == 3 ? rotatable_elements[i][(j + 1) % 4] :
10525 SetElementSimple(x, y, new_element, change_level);
10531 static void ResetIntelliDraw()
10535 for (x = 0; x < lev_fieldx; x++)
10536 for (y = 0; y < lev_fieldy; y++)
10537 IntelliDrawBuffer[x][y] = Feld[x][y];
10539 SetElementIntelliDraw(-1, -1, EL_UNDEFINED, FALSE, -1);
10542 static void SetElementExt(int x, int y, int element, boolean change_level,
10546 SetElementSimple(x, y, Feld[x][y], change_level);
10547 else if (GetKeyModState() & KMOD_Shift)
10548 SetElementIntelliDraw(x, y, element, change_level, button);
10550 SetElementSimple(x, y, element, change_level);
10553 static void SetElement(int x, int y, int element)
10555 SetElementExt(x, y, element, TRUE, -1);
10558 static void SetElementButton(int x, int y, int element, int button)
10560 SetElementExt(x, y, element, TRUE, button);
10563 static void DrawLineElement(int sx, int sy, int element, boolean change_level)
10565 int lx = sx + level_xpos;
10566 int ly = sy + level_ypos;
10568 SetElementExt(lx, ly, element, change_level, -1);
10571 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
10572 int element, boolean change_level)
10574 int xsize = ABS(to_x - from_x);
10575 int ysize = ABS(to_y - from_y);
10576 int dx = (to_x < from_x ? -1 : +1);
10577 int dy = (to_y < from_y ? -1 : +1);
10580 if (from_y == to_y) /* horizontal line */
10582 for (i = 0; i <= xsize; i++)
10583 DrawLineElement(from_x + i * dx, from_y, element, change_level);
10585 else if (from_x == to_x) /* vertical line */
10587 for (i = 0; i <= ysize; i++)
10588 DrawLineElement(from_x, from_y + i * dy, element, change_level);
10590 else /* diagonal line */
10592 if (ysize < xsize) /* a < 1 */
10594 float a = (float)ysize / (float)xsize;
10596 for (i = 0; i <= xsize; i++)
10599 int y = dy * (int)(a * i + 0.5);
10601 DrawLineElement(from_x + x, from_y + y, element, change_level);
10606 float a = (float)xsize / (float)ysize;
10608 for (i = 0; i <= ysize; i++)
10610 int x = dx * (int)(a * i + 0.5);
10613 DrawLineElement(from_x + x, from_y + y, element, change_level);
10619 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
10620 int element, boolean change_level)
10622 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
10623 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
10624 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
10625 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
10628 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
10629 int element, boolean change_level)
10634 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
10636 for (y = from_y; y <= to_y; y++)
10637 DrawLine(from_x, y, to_x, y, element, change_level);
10640 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
10641 int element, boolean change_level)
10643 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
10644 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
10645 int len_x = ABS(to_x - from_x);
10646 int len_y = ABS(to_y - from_y);
10649 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
10651 /* not optimal (some points get drawn twice) but simple,
10652 and fast enough for the few points we are drawing */
10654 for (x = 0; x <= radius; x++)
10656 int sx, sy, lx, ly;
10658 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
10660 sx = from_x + x * (from_x < to_x2 ? +1 : -1);
10661 sy = from_y + y * (from_y < to_y2 ? +1 : -1);
10662 lx = sx + level_xpos;
10663 ly = sy + level_ypos;
10665 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
10666 DrawLineElement(sx, sy, element, change_level);
10669 for (y = 0; y <= radius; y++)
10671 int sx, sy, lx, ly;
10673 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
10675 sx = from_x + x * (from_x < to_x2 ? +1 : -1);
10676 sy = from_y + y * (from_y < to_y2 ? +1 : -1);
10677 lx = sx + level_xpos;
10678 ly = sy + level_ypos;
10680 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
10681 DrawLineElement(sx, sy, element, change_level);
10685 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
10686 int element, boolean change_level)
10688 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
10689 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
10691 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
10694 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
10696 #if DRAW_CIRCLES_BUTTON_AVAILABLE
10697 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
10698 int element, boolean change_level)
10700 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
10701 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
10702 int mirror_to_x2 = from_x - (to_x2 - from_x);
10703 int mirror_to_y2 = from_y - (to_y2 - from_y);
10705 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
10706 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
10707 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
10708 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element,change_level);
10712 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
10714 int from_sx, from_sy;
10718 swap_numbers(&from_x, &to_x);
10721 swap_numbers(&from_y, &to_y);
10723 from_sx = SX + from_x * ed_tilesize;
10724 from_sy = SY + from_y * ed_tilesize;
10725 to_sx = SX + (to_x + 1) * ed_tilesize - 1;
10726 to_sy = SY + (to_y + 1) * ed_tilesize - 1;
10728 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
10729 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
10730 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
10731 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
10733 if (from_x == to_x && from_y == to_y)
10734 MarkTileDirty(from_x/2, from_y/2);
10736 redraw_mask |= REDRAW_FIELD;
10739 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
10740 int element, boolean change_level)
10742 if (element == -1 || change_level)
10743 DrawBox(from_x, from_y, to_x, to_y, -1, FALSE);
10745 DrawAreaBorder(from_x, from_y, to_x, to_y);
10748 /* values for CopyBrushExt() */
10749 #define CB_AREA_TO_BRUSH 0
10750 #define CB_BRUSH_TO_CURSOR 1
10751 #define CB_BRUSH_TO_LEVEL 2
10752 #define CB_DELETE_OLD_CURSOR 3
10753 #define CB_DUMP_BRUSH 4
10754 #define CB_DUMP_BRUSH_SMALL 5
10756 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
10757 int button, int mode)
10759 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
10760 static int brush_width, brush_height;
10761 static int last_cursor_x = -1, last_cursor_y = -1;
10762 static boolean delete_old_brush;
10763 int new_element = BUTTON_ELEMENT(button);
10766 if (mode == CB_DUMP_BRUSH ||
10767 mode == CB_DUMP_BRUSH_SMALL)
10769 if (!draw_with_brush)
10771 Error(ERR_WARN, "no brush selected");
10776 for (y = 0; y < brush_height; y++)
10778 for (x = 0; x < brush_width; x++)
10780 int element = brush_buffer[x][y];
10781 int element_mapped = element;
10783 if (IS_CUSTOM_ELEMENT(element))
10784 element_mapped = EL_CUSTOM_START;
10785 else if (IS_GROUP_ELEMENT(element))
10786 element_mapped = EL_GROUP_START;
10787 else if (element >= NUM_FILE_ELEMENTS)
10788 element_mapped = EL_UNKNOWN;
10790 // dump brush as level sketch text for the R'n'D forum:
10791 // - large tiles: `xxx (0x60 ASCII)
10792 // - small tiles: ¸xxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
10793 printf("%s%03d", (mode == CB_DUMP_BRUSH ? "`" : "¸"), element_mapped);
10802 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
10805 if (mode == CB_AREA_TO_BRUSH)
10807 int from_lx, from_ly;
10810 swap_numbers(&from_x, &to_x);
10813 swap_numbers(&from_y, &to_y);
10815 brush_width = to_x - from_x + 1;
10816 brush_height = to_y - from_y + 1;
10818 from_lx = from_x + level_xpos;
10819 from_ly = from_y + level_ypos;
10821 for (y = 0; y < brush_height; y++)
10823 for (x = 0; x < brush_width; x++)
10825 brush_buffer[x][y] = Feld[from_lx + x][from_ly + y];
10828 DrawLineElement(from_x + x, from_y + y, new_element, TRUE);
10833 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
10835 delete_old_brush = FALSE;
10837 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
10838 mode == CB_BRUSH_TO_LEVEL)
10840 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
10841 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
10842 int cursor_from_x = cursor_x - brush_width / 2;
10843 int cursor_from_y = cursor_y - brush_height / 2;
10844 int border_from_x = cursor_x, border_from_y = cursor_y;
10845 int border_to_x = cursor_x, border_to_y = cursor_y;
10847 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
10848 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
10850 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
10851 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
10853 delete_old_brush = FALSE;
10857 for (y = 0; y < brush_height; y++)
10859 for (x = 0; x < brush_width; x++)
10861 int sx = cursor_from_x + x;
10862 int sy = cursor_from_y + y;
10863 int lx = sx + level_xpos;
10864 int ly = sy + level_ypos;
10865 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
10866 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
10867 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
10868 brush_buffer[x][y] : new_element);
10870 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
10872 if (sx < border_from_x)
10873 border_from_x = sx;
10874 else if (sx > border_to_x)
10876 if (sy < border_from_y)
10877 border_from_y = sy;
10878 else if (sy > border_to_y)
10881 DrawLineElement(sx, sy, element, change_level);
10886 if (mode != CB_DELETE_OLD_CURSOR)
10887 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
10889 last_cursor_x = cursor_x;
10890 last_cursor_y = cursor_y;
10891 delete_old_brush = TRUE;
10895 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
10898 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
10901 static void CopyBrushToLevel(int x, int y, int button)
10903 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
10906 static void CopyBrushToCursor(int x, int y)
10908 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
10911 static void DeleteBrushFromCursor()
10913 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
10918 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
10921 void DumpBrush_Small()
10923 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
10926 static void FloodFill(int from_x, int from_y, int fill_element)
10928 FloodFillLevel(from_x, from_y, fill_element, Feld, lev_fieldx, lev_fieldy);
10931 /* values for DrawLevelText() modes */
10932 #define TEXT_INIT 0
10933 #define TEXT_SETCURSOR 1
10934 #define TEXT_WRITECHAR 2
10935 #define TEXT_BACKSPACE 3
10936 #define TEXT_NEWLINE 4
10938 #define TEXT_QUERY_TYPING 6
10940 static int DrawLevelText(int sx, int sy, char letter, int mode)
10942 static short delete_buffer[MAX_LEV_FIELDX];
10943 static int start_sx;
10944 static int last_sx, last_sy;
10945 static boolean typing = FALSE;
10946 int letter_element = EL_CHAR_ASCII0 + letter;
10947 int lx = 0, ly = 0;
10949 /* map lower case letters to upper case and convert special characters */
10950 if (letter >= 'a' && letter <= 'z')
10951 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
10952 else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
10953 letter_element = EL_CHAR_AUMLAUT;
10954 else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
10955 letter_element = EL_CHAR_OUMLAUT;
10956 else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
10957 letter_element = EL_CHAR_UUMLAUT;
10958 else if (letter == '^')
10959 letter_element = EL_CHAR_COPYRIGHT;
10961 letter_element = EL_CHAR_ASCII0 + letter;
10963 if (mode != TEXT_INIT)
10968 if (mode != TEXT_SETCURSOR)
10974 lx = last_sx + level_xpos;
10975 ly = last_sy + level_ypos;
10982 DrawLevelText(0, 0, 0, TEXT_END);
10988 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
10991 case TEXT_SETCURSOR:
10992 DrawEditorElement(last_sx, last_sy, Feld[lx][ly]);
10993 DrawAreaBorder(sx, sy, sx, sy);
10998 case TEXT_WRITECHAR:
10999 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
11001 if (new_element1 >= EL_STEEL_CHAR_START &&
11002 new_element1 <= EL_STEEL_CHAR_END)
11003 letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
11005 delete_buffer[sx - start_sx] = Feld[lx][ly];
11006 Feld[lx][ly] = letter_element;
11008 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
11009 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
11010 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
11011 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
11013 DrawLevelText(0, 0, 0, TEXT_END);
11015 level.changed = TRUE;
11019 case TEXT_BACKSPACE:
11022 Feld[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
11023 DrawEditorElement(sx - 1, sy, Feld[lx - 1][ly]);
11024 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
11029 if (sy + 1 < ed_fieldy - 1 && ly + 1 < lev_fieldy - 1)
11030 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
11032 DrawLevelText(0, 0, 0, TEXT_END);
11036 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
11037 DrawEditorElement(sx, sy, Feld[lx][ly]);
11041 case TEXT_QUERY_TYPING:
11051 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
11052 int element, boolean change_level)
11054 int lx = sx + level_xpos;
11055 int ly = sy + level_ypos;
11058 DrawEditorElement(sx, sy, Feld[lx][ly]);
11060 DrawAreaBorder(sx, sy, sx, sy);
11063 static void CheckLevelBorderElement(boolean redraw_playfield)
11065 int last_border_element = BorderElement;
11067 SetBorderElement();
11069 if (redraw_playfield && BorderElement != last_border_element)
11070 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11073 static void CopyLevelToUndoBuffer(int mode)
11075 static boolean accumulated_undo = FALSE;
11076 boolean new_undo_buffer_position = TRUE;
11079 if (undo_buffer_steps == 0)
11080 accumulated_undo = FALSE;
11084 case UNDO_IMMEDIATE:
11085 accumulated_undo = FALSE;
11088 case UNDO_ACCUMULATE:
11089 if (accumulated_undo)
11090 new_undo_buffer_position = FALSE;
11091 accumulated_undo = TRUE;
11098 if (new_undo_buffer_position)
11100 /* advance position in undo buffer ring */
11101 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
11103 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
11104 undo_buffer_steps++;
11107 /* always reset redo buffer when storing level change into undo buffer */
11108 redo_buffer_steps = 0;
11110 for (x = 0; x < lev_fieldx; x++)
11111 for (y = 0; y < lev_fieldy; y++)
11112 UndoBuffer[undo_buffer_position][x][y] = Feld[x][y];
11114 /* check if drawing operation forces change of border style */
11115 CheckLevelBorderElement(TRUE);
11117 level.changed = TRUE;
11120 static void RandomPlacement(int new_element)
11122 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
11123 int num_free_positions = 0;
11124 int num_percentage, num_elements;
11127 ResetIntelliDraw();
11129 /* determine number of free positions for randomly placing the new element */
11130 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
11132 free_position[x][y] =
11133 (random_placement_background_restricted ?
11134 Feld[x][y] == random_placement_background_element :
11135 Feld[x][y] != new_element);
11137 if (free_position[x][y])
11138 num_free_positions++;
11141 /* determine number of new elements to place there */
11142 num_percentage = num_free_positions * random_placement_value / 100;
11143 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
11144 num_percentage : random_placement_value);
11146 /* if less free positions than elements to place, fill all these positions */
11147 if (num_free_positions < num_elements)
11149 for (x = 0; x < lev_fieldx; x++)
11150 for (y = 0; y < lev_fieldy; y++)
11151 if (free_position[x][y])
11152 SetElement(x, y, new_element);
11156 while (num_elements > 0)
11158 x = GetSimpleRandom(lev_fieldx);
11159 y = GetSimpleRandom(lev_fieldy);
11161 /* don't place element at the same position twice */
11162 if (free_position[x][y])
11164 free_position[x][y] = FALSE;
11165 SetElement(x, y, new_element);
11171 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11172 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
11175 void WrapLevel(int dx, int dy)
11177 int wrap_dx = lev_fieldx - dx;
11178 int wrap_dy = lev_fieldy - dy;
11181 for (x = 0; x < lev_fieldx; x++)
11182 for (y = 0; y < lev_fieldy; y++)
11183 FieldBackup[x][y] = Feld[x][y];
11185 for (x = 0; x < lev_fieldx; x++)
11186 for (y = 0; y < lev_fieldy; y++)
11188 FieldBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
11190 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11191 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
11194 static void HandleDrawingAreas(struct GadgetInfo *gi)
11196 static boolean started_inside_drawing_area = FALSE;
11197 int id = gi->custom_id;
11198 int type_id = gi->custom_type_id;
11199 boolean button_press_event;
11200 boolean button_release_event;
11201 boolean inside_drawing_area = !gi->event.off_borders;
11202 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
11203 int actual_drawing_function;
11204 int button = gi->event.button;
11205 int new_element = BUTTON_ELEMENT(button);
11206 int sx = gi->event.x, sy = gi->event.y;
11207 int min_sx = 0, min_sy = 0;
11208 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
11209 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
11210 int lx = 0, ly = 0;
11211 int min_lx = 0, min_ly = 0;
11212 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
11215 /* handle info callback for each invocation of action callback */
11216 gi->callback_info(gi);
11218 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
11219 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
11221 /* make sure to stay inside drawing area boundaries */
11222 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
11223 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
11227 /* get positions inside level field */
11228 lx = sx + level_xpos;
11229 ly = sy + level_ypos;
11231 if (!IN_LEV_FIELD(lx, ly))
11232 inside_drawing_area = FALSE;
11234 /* make sure to stay inside level field boundaries */
11235 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
11236 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
11238 /* correct drawing area positions accordingly */
11239 sx = lx - level_xpos;
11240 sy = ly - level_ypos;
11243 if (button_press_event)
11244 started_inside_drawing_area = inside_drawing_area;
11246 if (!started_inside_drawing_area)
11249 if (!IS_VALID_BUTTON(button))
11252 if (!button && !button_release_event)
11255 /* automatically switch to 'single item' drawing mode, if needed */
11256 actual_drawing_function =
11257 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
11258 drawing_function : GADGET_ID_SINGLE_ITEMS);
11260 /* clicking into drawing area with pressed Control key picks element */
11261 if (GetKeyModState() & KMOD_Control)
11263 last_drawing_function = drawing_function;
11264 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
11267 if (GetKeyModState() & KMOD_Shift)
11269 if (button_press_event || button_release_event)
11270 ResetIntelliDraw();
11273 switch (actual_drawing_function)
11275 case GADGET_ID_SINGLE_ITEMS:
11278 if (button_release_event)
11280 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
11282 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
11283 !inside_drawing_area)
11284 DeleteBrushFromCursor();
11287 if (!button || button_release_event)
11290 if (draw_with_brush)
11292 CopyBrushToLevel(sx, sy, button);
11296 if (new_element == EL_PLAYER_1)
11298 /* remove player at old position */
11299 for (y = 0; y < lev_fieldy; y++)
11300 for (x = 0; x < lev_fieldx; x++)
11301 if (Feld[x][y] == EL_PLAYER_1)
11302 SetElement(x, y, EL_EMPTY);
11305 SetElementButton(lx, ly, new_element, button);
11308 else if (!button_release_event)
11310 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
11312 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
11313 DrawMiniGraphicExt(drawto,
11314 gi->x + sx * MINI_TILEX,
11315 gi->y + sy * MINI_TILEY,
11316 el2edimg(new_element));
11318 DrawFixedGraphicExt(drawto,
11319 gi->x + sx * TILEX,
11320 gi->y + sy * TILEY,
11321 el2edimg(new_element), 0);
11323 if (id == GADGET_ID_CUSTOM_GRAPHIC)
11324 new_element = GFX_ELEMENT(new_element);
11326 drawingarea_info[type_id].value[pos] = new_element;
11328 CopyElementPropertiesToGame(properties_element);
11330 if (id == GADGET_ID_CUSTOM_GRAPHIC)
11332 UpdateCustomElementGraphicGadgets();
11334 FrameCounter = 0; /* restart animation frame counter */
11339 case GADGET_ID_CONNECTED_ITEMS:
11341 static int last_sx = -1;
11342 static int last_sy = -1;
11344 if (button_release_event)
11345 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
11349 if (!button_press_event)
11350 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
11358 case GADGET_ID_LINE:
11359 case GADGET_ID_ARC:
11360 case GADGET_ID_RECTANGLE:
11361 case GADGET_ID_FILLED_BOX:
11362 case GADGET_ID_GRAB_BRUSH:
11363 case GADGET_ID_TEXT:
11365 static int last_sx = -1;
11366 static int last_sy = -1;
11367 static int start_sx = -1;
11368 static int start_sy = -1;
11369 void (*draw_func)(int, int, int, int, int, boolean);
11371 if (drawing_function == GADGET_ID_LINE)
11372 draw_func = DrawLine;
11373 else if (drawing_function == GADGET_ID_ARC)
11374 draw_func = DrawArc;
11375 else if (drawing_function == GADGET_ID_RECTANGLE)
11376 draw_func = DrawBox;
11377 else if (drawing_function == GADGET_ID_FILLED_BOX)
11378 draw_func = DrawFilledBox;
11379 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
11380 draw_func = SelectArea;
11381 else /* (drawing_function == GADGET_ID_TEXT) */
11382 draw_func = SetTextCursor;
11384 if (button_press_event)
11386 draw_func(sx, sy, sx, sy, new_element, FALSE);
11387 start_sx = last_sx = sx;
11388 start_sy = last_sy = sy;
11390 if (drawing_function == GADGET_ID_TEXT)
11391 DrawLevelText(0, 0, 0, TEXT_END);
11393 else if (button_release_event)
11395 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
11396 if (drawing_function == GADGET_ID_GRAB_BRUSH)
11398 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
11399 CopyBrushToCursor(sx, sy);
11400 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
11402 draw_with_brush = TRUE;
11404 else if (drawing_function == GADGET_ID_TEXT)
11405 DrawLevelText(sx, sy, 0, TEXT_INIT);
11407 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
11409 else if (last_sx != sx || last_sy != sy)
11411 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
11412 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
11419 case GADGET_ID_FLOOD_FILL:
11420 if (button_press_event && Feld[lx][ly] != new_element)
11422 FloodFill(lx, ly, new_element);
11423 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11424 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
11428 case GADGET_ID_PICK_ELEMENT:
11429 if (button_release_event)
11430 ClickOnGadget(level_editor_gadget[last_drawing_function],
11432 else if (draw_level)
11433 PickDrawingElement(button, Feld[lx][ly]);
11436 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
11438 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
11445 /* do not mark level as modified for certain non-level-changing gadgets */
11446 if ((type_id >= ED_DRAWING_ID_EDITOR_FIRST &&
11447 type_id <= ED_DRAWING_ID_EDITOR_LAST) ||
11448 actual_drawing_function == GADGET_ID_PICK_ELEMENT)
11451 level.changed = TRUE;
11454 static void HandleCounterButtons(struct GadgetInfo *gi)
11456 int gadget_id = gi->custom_id;
11457 int counter_id = gi->custom_type_id;
11458 int button = gi->event.button;
11459 int *counter_value = counterbutton_info[counter_id].value;
11460 int step = BUTTON_STEPSIZE(button) *
11461 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
11463 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
11465 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
11466 boolean released = (gi->event.type == GD_EVENT_RELEASED);
11467 boolean level_changed = LevelChanged();
11469 if ((level_changed && pressed) || (!level_changed && released))
11472 if (level_changed && !Request("Level has changed! Discard changes?",
11475 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
11476 ModifyEditorCounterValue(counter_id, *counter_value);
11482 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
11483 *counter_value = gi->textinput.number_value;
11485 ModifyEditorCounterValue(counter_id, *counter_value + step);
11487 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
11489 LoadLevel(level_nr);
11490 LoadScore(level_nr);
11492 SaveLevelSetup_SeriesInfo();
11497 DrawEditModeWindow();
11502 switch (counter_id)
11504 case ED_COUNTER_ID_YAMYAM_CONTENT:
11505 DrawYamYamContentAreas();
11508 case ED_COUNTER_ID_BALL_CONTENT:
11509 DrawMagicBallContentAreas();
11512 case ED_COUNTER_ID_ANDROID_CONTENT:
11513 DrawAndroidElementArea(properties_element);
11516 case ED_COUNTER_ID_GROUP_CONTENT:
11517 DrawGroupElementArea(properties_element);
11518 CopyGroupElementPropertiesToGame(properties_element);
11521 case ED_COUNTER_ID_INVENTORY_SIZE:
11522 DrawPlayerInitialInventoryArea(properties_element);
11525 case ED_COUNTER_ID_ENVELOPE_XSIZE:
11526 case ED_COUNTER_ID_ENVELOPE_YSIZE:
11527 DrawEnvelopeTextArea(-1);
11530 case ED_COUNTER_ID_LEVEL_XSIZE:
11531 case ED_COUNTER_ID_LEVEL_YSIZE:
11532 lev_fieldx = level.fieldx;
11533 lev_fieldy = level.fieldy;
11535 /* check if resizing of level results in change of border border */
11536 SetBorderElement();
11544 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
11545 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
11546 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
11547 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
11548 CopyElementPropertiesToGame(properties_element);
11550 /* do not mark level as modified for certain non-level-changing gadgets */
11551 if (counter_id >= ED_COUNTER_ID_EDITOR_FIRST &&
11552 counter_id <= ED_COUNTER_ID_EDITOR_LAST)
11555 level.changed = TRUE;
11558 static void HandleTextInputGadgets(struct GadgetInfo *gi)
11560 int type_id = gi->custom_type_id;
11562 strcpy(textinput_info[type_id].value, gi->textinput.value);
11564 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
11566 CopyElementPropertiesToGame(properties_element);
11568 ModifyEditorElementList(); /* update changed button info text */
11571 level.changed = TRUE;
11574 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
11576 int type_id = gi->custom_type_id;
11578 strncpy(textarea_info[type_id].value, gi->textarea.value,
11579 MAX_ENVELOPE_TEXT_LEN);
11580 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
11582 level.changed = TRUE;
11585 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
11587 int type_id = gi->custom_type_id;
11588 int value_old = *selectbox_info[type_id].value;
11589 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
11591 *selectbox_info[type_id].value = value_new;
11593 if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
11595 element_info[properties_element].current_change_page = gi->selectbox.index;
11597 DrawPropertiesWindow();
11599 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
11600 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
11601 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
11602 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
11603 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
11605 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
11607 /* when changing action type, also check action mode and action arg */
11608 if (value_old != value_new)
11609 setSelectboxSpecialActionVariablesIfNeeded();
11611 DrawPropertiesChange();
11614 CopyElementPropertiesToGame(properties_element);
11616 level.changed = TRUE;
11620 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
11622 int type_id = gi->custom_type_id;
11625 if (type_id >= ED_TAB_BUTTON_ID_LEVELINFO_FIRST &&
11626 type_id <= ED_TAB_BUTTON_ID_LEVELINFO_LAST)
11628 edit_mode_levelinfo = gi->custom_type_id;
11630 DrawLevelInfoWindow();
11632 else if (type_id >= ED_TAB_BUTTON_ID_PROPERTIES_FIRST &&
11633 type_id <= ED_TAB_BUTTON_ID_PROPERTIES_LAST)
11635 edit_mode_properties = gi->custom_type_id;
11637 DrawPropertiesWindow();
11639 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 ||
11640 type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2)
11642 boolean new_template = !fileExists(getLocalLevelTemplateFilename());
11644 /* backup original "level.field" (needed to track playfield changes) */
11645 CopyPlayfield(level.field, FieldBackup);
11647 /* "SaveLevelTemplate()" uses "level.field", so copy editor playfield */
11648 CopyPlayfield(Feld, level.field);
11650 if (new_template ||
11651 Request("Save this template and kill the old?", REQ_ASK))
11652 SaveLevelTemplate();
11655 Request("Template saved!", REQ_CONFIRM);
11657 /* restore original "level.field" (needed to track playfield changes) */
11658 CopyPlayfield(FieldBackup, level.field);
11660 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
11661 custom_element.num_change_pages < MAX_CHANGE_PAGES)
11663 struct ElementInfo *ei = &element_info[properties_element];
11665 /* when modifying custom element, ask for copying level template */
11666 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
11669 setElementChangePages(ei, ei->num_change_pages + 1);
11671 /* set new change page to be new current change page */
11672 ei->current_change_page = ei->num_change_pages - 1;
11673 ei->change = &ei->change_page[ei->current_change_page];
11675 setElementChangeInfoToDefaults(ei->change);
11677 DrawPropertiesWindow();
11679 level.changed = TRUE;
11681 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
11682 custom_element.num_change_pages > MIN_CHANGE_PAGES)
11684 struct ElementInfo *ei = &element_info[properties_element];
11686 /* when modifying custom element, ask for copying level template */
11687 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
11690 /* copy all change pages after change page to be deleted */
11691 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
11692 ei->change_page[i] = ei->change_page[i + 1];
11694 setElementChangePages(ei, ei->num_change_pages - 1);
11696 DrawPropertiesWindow();
11698 level.changed = TRUE;
11702 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
11704 int type_id = gi->custom_type_id;
11706 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
11707 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
11709 struct ElementInfo *ei = &element_info[properties_element];
11710 int step = BUTTON_STEPSIZE(gi->event.button);
11712 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
11713 ei->current_change_page += step;
11715 if (ei->current_change_page < 0)
11716 ei->current_change_page = 0;
11717 else if (ei->current_change_page >= ei->num_change_pages)
11718 ei->current_change_page = ei->num_change_pages - 1;
11720 DrawPropertiesWindow();
11722 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
11723 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
11725 struct ElementInfo *ei = &element_info[properties_element];
11726 int current_change_page = ei->current_change_page;
11728 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
11730 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
11731 ei->change_page[current_change_page];
11733 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
11735 /* when modifying custom element, ask for copying level template */
11736 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
11739 ei->change_page[current_change_page] =
11740 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
11742 level.changed = TRUE;
11745 DrawPropertiesWindow();
11749 static void HandleRadiobuttons(struct GadgetInfo *gi)
11751 int type_id = gi->custom_type_id;
11753 *radiobutton_info[type_id].value =
11754 radiobutton_info[type_id].checked_value;
11756 /* do not mark level as modified for certain non-level-changing gadgets */
11757 if (type_id >= ED_RADIOBUTTON_ID_EDITOR_FIRST &&
11758 type_id <= ED_RADIOBUTTON_ID_EDITOR_LAST)
11761 level.changed = TRUE;
11764 static void HandleCheckbuttons(struct GadgetInfo *gi)
11766 int type_id = gi->custom_type_id;
11768 *checkbutton_info[type_id].value ^= TRUE;
11770 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
11771 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
11772 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
11773 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
11774 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
11775 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
11776 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
11777 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1))
11779 CopyElementPropertiesToGame(properties_element);
11782 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
11784 UpdateCustomElementGraphicGadgets();
11786 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 ||
11787 type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2)
11789 boolean template_related_changes_found = FALSE;
11792 /* check if any custom or group elements have been changed */
11793 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
11794 if ((IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)) &&
11795 element_info[i].modified_settings)
11796 template_related_changes_found = TRUE;
11798 if (level.use_custom_template &&
11799 !fileExists(getGlobalLevelTemplateFilename()))
11801 Request("No level template found!", REQ_CONFIRM);
11803 level.use_custom_template = FALSE;
11805 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
11810 if (level.use_custom_template &&
11811 template_related_changes_found &&
11812 !Request("Discard changes and use level template?", REQ_ASK))
11814 level.use_custom_template = FALSE;
11816 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
11821 if (!level.use_custom_template &&
11822 Request("Copy settings from level template?", REQ_ASK))
11827 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
11829 DrawEditModeWindow();
11831 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3)
11833 if (setup.editor.use_template_for_new_levels &&
11834 !fileExists(getGlobalLevelTemplateFilename()))
11836 Request("No level template found!", REQ_CONFIRM);
11841 if (setup.editor.use_template_for_new_levels &&
11843 !Request("Discard level and load template?", REQ_ASK))
11848 if (!setup.editor.use_template_for_new_levels &&
11850 !Request("Discard level and use empty level?", REQ_ASK))
11855 LoadLevel(level_nr);
11856 LoadScore(level_nr);
11861 DrawEditModeWindow();
11864 /* do not mark level as modified for certain non-level-changing gadgets */
11865 if ((type_id >= ED_CHECKBUTTON_ID_EDITOR_FIRST &&
11866 type_id <= ED_CHECKBUTTON_ID_EDITOR_LAST) ||
11867 type_id == ED_CHECKBUTTON_ID_STICK_ELEMENT)
11870 level.changed = TRUE;
11873 static void HandleControlButtons(struct GadgetInfo *gi)
11875 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
11876 static int last_edit_mode = ED_MODE_DRAWING;
11877 static int last_custom_copy_mode = -1;
11878 static int last_button = 0;
11879 int id = gi->custom_id;
11880 int button = gi->event.button;
11881 int step = BUTTON_STEPSIZE(button);
11882 int new_element = BUTTON_ELEMENT(button);
11883 int last_properties_element = properties_element;
11886 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
11887 DrawLevelText(0, 0, 0, TEXT_END);
11889 if (id < ED_NUM_CTRL1_BUTTONS &&
11890 id != GADGET_ID_SINGLE_ITEMS &&
11891 id != GADGET_ID_PICK_ELEMENT &&
11892 edit_mode != ED_MODE_DRAWING &&
11893 drawing_function != GADGET_ID_PICK_ELEMENT &&
11894 !(GetKeyModState() & KMOD_Control))
11895 ChangeEditModeWindow(ED_MODE_DRAWING);
11897 /* element copy mode active, but no element button pressed => deactivate */
11898 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
11899 last_custom_copy_mode = -1;
11901 /* when showing palette on element buttons, change element of button used */
11902 if (editor.palette.show_on_element_buttons &&
11903 id >= GADGET_ID_ELEMENT_LEFT && id <= GADGET_ID_ELEMENT_RIGHT)
11905 last_button = id - GADGET_ID_ELEMENT_LEFT + 1;
11907 id = GADGET_ID_PALETTE;
11912 case GADGET_ID_SCROLL_LEFT:
11913 if (level_xpos >= 0)
11915 if (lev_fieldx < ed_fieldx - 2)
11918 level_xpos -= step;
11919 if (level_xpos < -1)
11922 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
11924 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11926 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
11927 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
11931 case GADGET_ID_SCROLL_RIGHT:
11932 if (level_xpos <= lev_fieldx - ed_fieldx)
11934 if (lev_fieldx < ed_fieldx - 2)
11937 level_xpos += step;
11938 if (level_xpos > lev_fieldx - ed_fieldx + 1)
11939 level_xpos = lev_fieldx - ed_fieldx + 1;
11941 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
11943 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11945 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
11946 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
11950 case GADGET_ID_SCROLL_UP:
11951 if (level_ypos >= 0)
11953 if (lev_fieldy < ed_fieldy - 2)
11956 level_ypos -= step;
11957 if (level_ypos < -1)
11960 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
11962 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11964 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
11965 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
11969 case GADGET_ID_SCROLL_DOWN:
11970 if (level_ypos <= lev_fieldy - ed_fieldy)
11972 if (lev_fieldy < ed_fieldy - 2)
11975 level_ypos += step;
11976 if (level_ypos > lev_fieldy - ed_fieldy + 1)
11977 level_ypos = lev_fieldy - ed_fieldy + 1;
11979 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
11981 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11983 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
11984 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
11988 case GADGET_ID_SCROLL_HORIZONTAL:
11989 level_xpos = gi->event.item_position - 1;
11991 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
11996 case GADGET_ID_SCROLL_VERTICAL:
11997 level_ypos = gi->event.item_position - 1;
11999 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12004 case GADGET_ID_SCROLL_LIST_UP:
12005 case GADGET_ID_SCROLL_LIST_DOWN:
12006 case GADGET_ID_SCROLL_LIST_VERTICAL:
12007 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
12008 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
12011 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
12012 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
12014 if (element_shift < 0)
12016 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
12017 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
12019 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
12020 GDI_SCROLLBAR_ITEM_POSITION,
12021 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
12024 ModifyEditorElementList();
12028 case GADGET_ID_PROPERTIES:
12029 // always switch off element properties when they are already displayed
12030 last_properties_element = new_element;
12031 case GADGET_ID_ELEMENT_LEFT:
12032 case GADGET_ID_ELEMENT_MIDDLE:
12033 case GADGET_ID_ELEMENT_RIGHT:
12034 properties_element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
12035 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
12036 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 :
12039 if (edit_mode != ED_MODE_PROPERTIES)
12041 last_edit_mode = edit_mode;
12043 ChangeEditModeWindow(ED_MODE_PROPERTIES);
12045 last_level_drawing_function = drawing_function;
12046 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
12049 else if (properties_element != last_properties_element)
12051 DrawEditModeWindow();
12055 ChangeEditModeWindow(last_edit_mode);
12057 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
12062 case GADGET_ID_PALETTE:
12063 if (edit_mode != ED_MODE_PALETTE)
12065 last_edit_mode = edit_mode;
12067 ChangeEditModeWindow(ED_MODE_PALETTE);
12071 ChangeEditModeWindow(last_edit_mode);
12075 case GADGET_ID_WRAP_LEFT:
12076 WrapLevel(-step, 0);
12079 case GADGET_ID_WRAP_RIGHT:
12080 WrapLevel(step, 0);
12083 case GADGET_ID_WRAP_UP:
12084 WrapLevel(0, -step);
12087 case GADGET_ID_WRAP_DOWN:
12088 WrapLevel(0, step);
12091 case GADGET_ID_SINGLE_ITEMS:
12092 case GADGET_ID_CONNECTED_ITEMS:
12093 case GADGET_ID_LINE:
12094 case GADGET_ID_ARC:
12095 case GADGET_ID_TEXT:
12096 case GADGET_ID_RECTANGLE:
12097 case GADGET_ID_FILLED_BOX:
12098 case GADGET_ID_FLOOD_FILL:
12099 case GADGET_ID_GRAB_BRUSH:
12100 case GADGET_ID_PICK_ELEMENT:
12101 if (drawing_function != GADGET_ID_PICK_ELEMENT)
12102 last_drawing_function = drawing_function;
12103 drawing_function = id;
12104 draw_with_brush = FALSE;
12107 case GADGET_ID_RANDOM_PLACEMENT:
12108 RandomPlacement(new_element);
12111 case GADGET_ID_ZOOM:
12112 // zoom level editor tile size in or out (or reset to default size)
12113 ed_tilesize = (button == 1 ? ed_tilesize * 2 :
12114 button == 2 ? DEFAULT_EDITOR_TILESIZE :
12115 button == 3 ? ed_tilesize / 2 : ed_tilesize);
12117 // limit zoom level by upper and lower bound
12118 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
12120 InitZoomLevelSettings();
12122 if (edit_mode == ED_MODE_DRAWING)
12123 DrawDrawingWindow();
12127 case GADGET_ID_CUSTOM_COPY_FROM:
12128 case GADGET_ID_CUSTOM_COPY_TO:
12129 case GADGET_ID_CUSTOM_EXCHANGE:
12130 last_custom_copy_mode = id;
12131 last_drawing_function = drawing_function;
12134 case GADGET_ID_CUSTOM_COPY:
12135 CopyCustomElement(properties_element, -1, id);
12138 case GADGET_ID_CUSTOM_PASTE:
12139 CopyCustomElement(-1, properties_element, id);
12142 case GADGET_ID_UNDO:
12143 if (button == 1 && undo_buffer_steps == 0)
12145 Request("Undo buffer empty!", REQ_CONFIRM);
12149 else if (button == 2)
12153 else if (button == 3 && redo_buffer_steps == 0)
12155 Request("Redo buffer empty!", REQ_CONFIRM);
12160 if (edit_mode != ED_MODE_DRAWING)
12161 ChangeEditModeWindow(ED_MODE_DRAWING);
12167 undo_buffer_position =
12168 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
12170 undo_buffer_steps--;
12171 redo_buffer_steps++;
12177 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
12179 undo_buffer_steps++;
12180 redo_buffer_steps--;
12183 for (x = 0; x < lev_fieldx; x++)
12184 for (y = 0; y < lev_fieldy; y++)
12185 Feld[x][y] = UndoBuffer[undo_buffer_position][x][y];
12187 /* check if undo operation forces change of border style */
12188 CheckLevelBorderElement(FALSE);
12190 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12194 case GADGET_ID_INFO:
12195 if (edit_mode != ED_MODE_INFO)
12197 last_edit_mode = edit_mode;
12199 ChangeEditModeWindow(ED_MODE_INFO);
12203 ChangeEditModeWindow(last_edit_mode);
12207 case GADGET_ID_CLEAR:
12208 if (edit_mode != ED_MODE_DRAWING)
12209 ChangeEditModeWindow(ED_MODE_DRAWING);
12211 for (x = 0; x < MAX_LEV_FIELDX; x++)
12212 for (y = 0; y < MAX_LEV_FIELDY; y++)
12213 Feld[x][y] = (button == 1 ? EL_EMPTY : new_element);
12215 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
12217 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12220 case GADGET_ID_SAVE:
12222 /* saving read-only levels into personal level set modifies global vars
12223 "leveldir_current" and "level_nr"; restore them after saving level */
12224 LevelDirTree *leveldir_former = leveldir_current;
12225 int level_nr_former = level_nr;
12226 char *level_filename;
12229 if (leveldir_current->readonly &&
12230 !PrepareSavingIntoPersonalLevelSet())
12233 level_filename = getDefaultLevelFilename(level_nr);
12234 new_level = !fileExists(level_filename);
12237 Request("Save this level and kill the old?", REQ_ASK))
12239 if (leveldir_former->readonly)
12240 ModifyLevelInfoForSavingIntoPersonalLevelSet(leveldir_former->name);
12242 CopyPlayfield(Feld, level.field);
12243 SaveLevel(level_nr);
12245 level.changed = FALSE;
12249 char level_saved_msg[64];
12251 if (leveldir_former->readonly)
12252 sprintf(level_saved_msg,
12253 "Level saved as level %d into personal level set!",
12256 strcpy(level_saved_msg, "Level saved!");
12258 Request(level_saved_msg, REQ_CONFIRM);
12262 /* "cd" back to copied-from levelset (in case of saved read-only level) */
12263 leveldir_current = leveldir_former;
12264 level_nr = level_nr_former;
12269 case GADGET_ID_TEST:
12270 if (LevelChanged())
12271 level.game_version = GAME_VERSION_ACTUAL;
12273 CopyPlayfield(level.field, FieldBackup);
12274 CopyPlayfield(Feld, level.field);
12276 CopyNativeLevel_RND_to_Native(&level);
12278 UnmapLevelEditorGadgets();
12279 UndrawSpecialEditorDoor();
12281 CloseDoor(DOOR_CLOSE_ALL);
12283 /* needed before playing if editor playfield area has different size */
12284 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
12286 // redraw_mask = REDRAW_ALL;
12288 level_editor_test_game = TRUE;
12290 StartGameActions(FALSE, setup.autorecord, level.random_seed);
12294 case GADGET_ID_EXIT:
12295 RequestExitLevelEditor(TRUE, FALSE); /* if level has changed, ask user */
12299 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
12300 id <= GADGET_ID_ELEMENTLIST_LAST)
12302 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
12303 int new_element = editor_elements[element_position + element_shift];
12305 if (IS_EDITOR_CASCADE(new_element))
12309 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
12311 int *cascade_element= &(*editor_elements_info[i].headline_list)[0];
12312 boolean *cascade_value=editor_elements_info[i].setup_cascade_value;
12314 if (*cascade_element == new_element)
12316 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
12317 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
12319 /* update element selection list */
12320 ReinitializeElementList();
12321 ModifyEditorElementList();
12323 /* update cascading gadget info text */
12324 PrintEditorGadgetInfoText(level_editor_gadget[id]);
12326 /* save current editor cascading state */
12327 SaveSetup_EditorCascade();
12336 if (last_custom_copy_mode != -1)
12338 if (CopyCustomElement(properties_element, new_element,
12339 last_custom_copy_mode))
12341 ClickOnGadget(level_editor_gadget[last_drawing_function],
12344 last_custom_copy_mode = -1;
12350 /* change element of button used to show palette */
12351 if (editor.palette.show_on_element_buttons)
12352 button = last_button;
12354 PickDrawingElement(button, new_element);
12356 if (!stick_element_properties_window &&
12357 drawing_function != GADGET_ID_PICK_ELEMENT &&
12358 !(GetKeyModState() & KMOD_Control))
12360 properties_element = new_element;
12361 if (edit_mode == ED_MODE_PROPERTIES)
12362 DrawPropertiesWindow();
12365 if (drawing_function == GADGET_ID_PICK_ELEMENT)
12366 ClickOnGadget(level_editor_gadget[last_drawing_function],
12369 if (!use_permanent_palette)
12370 ChangeEditModeWindow(last_edit_mode);
12373 else if (gi->event.type == GD_EVENT_PRESSED)
12374 printf("default: HandleControlButtons: GD_EVENT_PRESSED(%d)\n", id);
12375 else if (gi->event.type == GD_EVENT_RELEASED)
12376 printf("default: HandleControlButtons: GD_EVENT_RELEASED(%d)\n", id);
12377 else if (gi->event.type == GD_EVENT_MOVING)
12378 printf("default: HandleControlButtons: GD_EVENT_MOVING(%d)\n", id);
12380 printf("default: HandleControlButtons: ? (id == %d)\n", id);
12386 void HandleLevelEditorKeyInput(Key key)
12388 char letter = getCharFromKey(key);
12389 int button = MB_LEFTBUTTON;
12391 if (drawing_function == GADGET_ID_TEXT &&
12392 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
12395 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
12396 else if (key == KSYM_Delete || key == KSYM_BackSpace)
12397 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
12398 else if (key == KSYM_Return)
12399 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
12400 else if (key == KSYM_Escape)
12401 DrawLevelText(0, 0, 0, TEXT_END);
12403 else if (button_status == MB_RELEASED)
12405 int id = GADGET_ID_NONE;
12406 int new_element_shift = element_shift;
12407 int step = ED_ELEMENTLIST_BUTTONS_VERT - 1;
12413 id = GADGET_ID_SCROLL_LEFT;
12416 id = GADGET_ID_SCROLL_RIGHT;
12419 id = GADGET_ID_SCROLL_UP;
12422 id = GADGET_ID_SCROLL_DOWN;
12426 case KSYM_Page_Down:
12427 step *= (key == KSYM_Page_Up ? -1 : +1);
12428 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
12430 if (element_shift < 0)
12432 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
12433 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
12435 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
12436 GDI_SCROLLBAR_ITEM_POSITION,
12437 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
12439 ModifyEditorElementList();
12445 element_shift = (key == KSYM_Home ? 0 :
12446 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
12448 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
12449 GDI_SCROLLBAR_ITEM_POSITION,
12450 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
12452 ModifyEditorElementList();
12459 /* this is needed to prevent interference with running "True X-Mouse" */
12460 if (GetKeyModStateFromEvents() & KMOD_Control)
12463 /* check for last or next editor cascade block in element list */
12464 for (i = 0; i < num_editor_elements; i++)
12466 if ((key == KSYM_Insert && i == element_shift) ||
12467 (key == KSYM_Delete && new_element_shift > element_shift))
12470 /* jump to next cascade block (or to start of element list) */
12471 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
12472 new_element_shift = i;
12475 if (i < num_editor_elements)
12476 element_shift = new_element_shift;
12478 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
12479 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
12481 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
12482 GDI_SCROLLBAR_ITEM_POSITION,
12483 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
12485 ModifyEditorElementList();
12490 if (edit_mode == ED_MODE_DRAWING)
12492 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
12494 else if (edit_mode == ED_MODE_INFO)
12496 HandleControlButtons(level_editor_gadget[GADGET_ID_INFO]);
12498 else if (edit_mode == ED_MODE_PROPERTIES)
12500 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
12502 else if (edit_mode == ED_MODE_PALETTE)
12504 HandleControlButtons(level_editor_gadget[GADGET_ID_PALETTE]);
12506 else /* should never happen */
12508 ChangeEditModeWindow(ED_MODE_DRAWING);
12517 if (id != GADGET_ID_NONE)
12518 ClickOnGadget(level_editor_gadget[id], button);
12519 else if (letter == '1' || letter == '?')
12520 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_LEFT], button);
12521 else if (letter == '2')
12522 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_MIDDLE], button);
12523 else if (letter == '3')
12524 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_RIGHT], button);
12525 else if (letter == '.')
12526 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
12527 else if (letter == 'U')
12528 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
12529 else if (letter == '-' || key == KSYM_KP_Subtract)
12530 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
12531 else if (letter == '0' || key == KSYM_KP_0)
12532 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
12533 else if (letter == '+' || key == KSYM_KP_Add ||
12534 letter == '=') // ("Shift-=" is "+" on US keyboards)
12535 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
12536 else if (key == KSYM_Return ||
12537 key == KSYM_space ||
12538 key == setup.shortcut.toggle_pause)
12539 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
12541 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
12542 if (letter && letter == controlbutton_info[i].shortcut)
12543 if (!anyTextGadgetActive())
12544 ClickOnGadget(level_editor_gadget[i], button);
12548 void HandleLevelEditorIdle()
12550 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
12551 int x = editor.settings.element_graphic.x + element_border;
12552 int y = editor.settings.element_graphic.y + element_border;
12553 static unsigned int action_delay = 0;
12554 unsigned int action_delay_value = GameFrameDelay;
12557 if (edit_mode != ED_MODE_PROPERTIES)
12560 if (!DelayReached(&action_delay, action_delay_value))
12563 for (i = 0; i < ED_NUM_SELECTBOX; i++)
12565 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
12567 if (gi->mapped && gi->active && gi->selectbox.open)
12571 DrawEditorElementAnimation(SX + x, SY + y);
12573 redraw_mask |= REDRAW_FIELD;
12575 FrameCounter++; /* increase animation frame counter */
12578 void ClearEditorGadgetInfoText()
12580 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
12583 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
12585 char infotext[MAX_OUTPUT_LINESIZE + 1];
12586 char shortcut[MAX_OUTPUT_LINESIZE + 1];
12587 int max_infotext_len = getMaxInfoTextLength();
12589 if (gi == NULL || strlen(gi->info_text) == 0)
12592 strncpy(infotext, gi->info_text, max_infotext_len);
12593 infotext[max_infotext_len] = '\0';
12595 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
12597 int key = controlbutton_info[gi->custom_id].shortcut;
12601 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
12602 sprintf(shortcut, " ('.' or '%c')", key);
12603 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
12604 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
12605 else if (gi->custom_id == GADGET_ID_TEST)
12606 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
12607 else if (gi->custom_id == GADGET_ID_UNDO)
12608 sprintf(shortcut, " ('%c/Shift-U')", key);
12609 else if (gi->custom_id == GADGET_ID_ZOOM)
12610 sprintf(shortcut, " ('%c', '0', '+')", key);
12612 sprintf(shortcut, " ('%s%c')",
12613 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
12615 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
12616 strcat(infotext, shortcut);
12620 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, INFOTEXT_FONT);
12623 void HandleEditorGadgetInfoText(void *ptr)
12625 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
12627 if (game_status != GAME_MODE_EDITOR)
12630 ClearEditorGadgetInfoText();
12632 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
12635 /* misuse this function to delete brush cursor, if needed */
12636 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
12637 DeleteBrushFromCursor();
12639 PrintEditorGadgetInfoText(gi);
12642 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
12644 static int start_lx, start_ly;
12645 int id = gi->custom_id;
12646 int type_id = gi->custom_type_id;
12647 int sx = gi->event.x;
12648 int sy = gi->event.y;
12649 int lx = sx + level_xpos;
12650 int ly = sy + level_ypos;
12651 int min_sx = 0, min_sy = 0;
12652 int max_sx = gi->drawing.area_xsize - 1;
12653 int max_sy = gi->drawing.area_ysize - 1;
12654 int actual_drawing_function = drawing_function;
12655 int max_infotext_len = getMaxInfoTextLength();
12656 char infotext[MAX_OUTPUT_LINESIZE + 1];
12659 infotext[0] = '\0'; /* start with empty info text */
12661 /* pressed Control key: simulate picking element */
12662 if (GetKeyModState() & KMOD_Control)
12663 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
12665 ClearEditorGadgetInfoText();
12667 if (gi->event.type == GD_EVENT_INFO_LEAVING)
12670 /* make sure to stay inside drawing area boundaries */
12671 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
12672 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
12674 if (id == GADGET_ID_DRAWING_LEVEL)
12678 int min_lx = 0, min_ly = 0;
12679 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
12681 /* get positions inside level field */
12682 lx = sx + level_xpos;
12683 ly = sy + level_ypos;
12685 /* make sure to stay inside level field boundaries */
12686 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
12687 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
12689 /* correct drawing area positions accordingly */
12690 sx = lx - level_xpos;
12691 sy = ly - level_ypos;
12694 if (IN_ED_FIELD(sx,sy) && IN_LEV_FIELD(lx, ly))
12696 if (button_status) /* if (gi->state == GD_BUTTON_PRESSED) */
12698 if (gi->event.type == GD_EVENT_PRESSED)
12704 switch (actual_drawing_function)
12706 case GADGET_ID_SINGLE_ITEMS:
12707 text = "Drawing single items";
12709 case GADGET_ID_CONNECTED_ITEMS:
12710 text = "Drawing connected items";
12712 case GADGET_ID_LINE:
12713 text = "Drawing line";
12715 case GADGET_ID_ARC:
12716 text = "Drawing arc";
12718 case GADGET_ID_TEXT:
12719 text = "Setting text cursor";
12721 case GADGET_ID_RECTANGLE:
12722 text = "Drawing rectangle";
12724 case GADGET_ID_FILLED_BOX:
12725 text = "Drawing filled box";
12727 case GADGET_ID_FLOOD_FILL:
12728 text = "Flood fill";
12730 case GADGET_ID_GRAB_BRUSH:
12731 text = "Grabbing brush";
12733 case GADGET_ID_PICK_ELEMENT:
12734 text = "Picking element";
12738 text = "Drawing position";
12742 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
12743 sprintf(infotext, "%s: %d, %d", text, lx, ly);
12745 sprintf(infotext, "%s: %d, %d", text,
12746 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
12748 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
12749 strncpy(infotext, getElementInfoText(Feld[lx][ly]), max_infotext_len);
12751 sprintf(infotext, "Level position: %d, %d", lx, ly);
12754 /* misuse this function to draw brush cursor, if needed */
12755 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
12757 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12758 CopyBrushToCursor(sx, sy);
12760 DeleteBrushFromCursor();
12763 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
12765 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
12766 int element = drawingarea_info[type_id].value[pos];
12768 strncpy(infotext, getElementInfoText(element), max_infotext_len);
12772 if (id == GADGET_ID_CUSTOM_CONTENT)
12773 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
12774 else if (id == GADGET_ID_GROUP_CONTENT)
12775 sprintf(infotext, "group element position: %d", sx + 1);
12776 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
12777 id <= GADGET_ID_YAMYAM_CONTENT_7)
12778 sprintf(infotext, "content area %d position: %d, %d",
12779 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
12780 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
12781 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
12782 sprintf(infotext, "content area %d position: %d, %d",
12783 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
12784 else if (id == GADGET_ID_ANDROID_CONTENT)
12785 sprintf(infotext, "android element position: %d", sx + 1);
12786 else if (drawingarea_info[type_id].infotext != NULL)
12787 strcpy(infotext, drawingarea_info[type_id].infotext);
12790 infotext[max_infotext_len] = '\0';
12792 if (strlen(infotext) > 0)
12793 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT, infotext);
12796 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
12797 boolean quick_quit)
12799 if (!ask_if_level_has_changed ||
12801 Request("Level has changed! Exit without saving?",
12802 REQ_ASK | REQ_STAY_OPEN))
12804 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
12805 struct RectWithBorder *vp_door_2 = &viewport.door_2[GAME_MODE_MAIN];
12807 /* draw normal door */
12808 UndrawSpecialEditorDoor();
12810 // close editor doors if viewport definition is the same as in main menu
12811 if (vp_door_1->x == DX &&
12812 vp_door_1->y == DY &&
12813 vp_door_1->width == DXSIZE &&
12814 vp_door_1->height == DYSIZE &&
12815 vp_door_2->x == VX &&
12816 vp_door_2->y == VY &&
12817 vp_door_2->width == VXSIZE &&
12818 vp_door_2->height == VYSIZE)
12819 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
12821 SetDoorState(DOOR_CLOSE_2);
12826 FadeSkipNextFadeIn();
12828 SetGameStatus(GAME_MODE_MAIN);
12834 if (!global.use_envelope_request)
12836 CloseDoor(DOOR_CLOSE_1);
12837 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);