1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // https://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
14 #include "libgame/libgame.h"
25 #define INFOTEXT_UNKNOWN_ELEMENT "unknown"
28 // ----------------------------------------------------------------------------
29 // screen and artwork graphic pixel position definitions
30 // ----------------------------------------------------------------------------
32 // values for the control window
33 #define ED_CTRL1_BUTTONS_HORIZ 4 // toolbox
34 #define ED_CTRL1_BUTTONS_VERT 4
35 #define ED_CTRL2_BUTTONS_HORIZ 3 // level
36 #define ED_CTRL2_BUTTONS_VERT 2
37 #define ED_CTRL3_BUTTONS_HORIZ 3 // CE and GE
38 #define ED_CTRL3_BUTTONS_VERT 1
39 #define ED_CTRL4_BUTTONS_HORIZ 2 // CE and GE
40 #define ED_CTRL4_BUTTONS_VERT 1
41 #define ED_CTRL5_BUTTONS_HORIZ 1 // properties
42 #define ED_CTRL5_BUTTONS_VERT 1
43 #define ED_CTRL6_BUTTONS_HORIZ 3 // properties
44 #define ED_CTRL6_BUTTONS_VERT 1
45 #define ED_CTRL7_BUTTONS_HORIZ 1 // palette
46 #define ED_CTRL7_BUTTONS_VERT 1
48 #define ED_NUM_CTRL1_BUTTONS (ED_CTRL1_BUTTONS_HORIZ * ED_CTRL1_BUTTONS_VERT)
49 #define ED_NUM_CTRL2_BUTTONS (ED_CTRL2_BUTTONS_HORIZ * ED_CTRL2_BUTTONS_VERT)
50 #define ED_NUM_CTRL3_BUTTONS (ED_CTRL3_BUTTONS_HORIZ * ED_CTRL3_BUTTONS_VERT)
51 #define ED_NUM_CTRL4_BUTTONS (ED_CTRL4_BUTTONS_HORIZ * ED_CTRL4_BUTTONS_VERT)
52 #define ED_NUM_CTRL5_BUTTONS (ED_CTRL5_BUTTONS_HORIZ * ED_CTRL5_BUTTONS_VERT)
53 #define ED_NUM_CTRL6_BUTTONS (ED_CTRL6_BUTTONS_HORIZ * ED_CTRL6_BUTTONS_VERT)
54 #define ED_NUM_CTRL7_BUTTONS (ED_CTRL7_BUTTONS_HORIZ * ED_CTRL7_BUTTONS_VERT)
55 #define ED_NUM_CTRL1_2_BUTTONS (ED_NUM_CTRL1_BUTTONS + ED_NUM_CTRL2_BUTTONS)
56 #define ED_NUM_CTRL1_3_BUTTONS (ED_NUM_CTRL1_2_BUTTONS + ED_NUM_CTRL3_BUTTONS)
57 #define ED_NUM_CTRL1_4_BUTTONS (ED_NUM_CTRL1_3_BUTTONS + ED_NUM_CTRL4_BUTTONS)
58 #define ED_NUM_CTRL1_5_BUTTONS (ED_NUM_CTRL1_4_BUTTONS + ED_NUM_CTRL5_BUTTONS)
59 #define ED_NUM_CTRL1_6_BUTTONS (ED_NUM_CTRL1_5_BUTTONS + ED_NUM_CTRL6_BUTTONS)
60 #define ED_NUM_CTRL1_7_BUTTONS (ED_NUM_CTRL1_6_BUTTONS + ED_NUM_CTRL7_BUTTONS)
61 #define ED_NUM_CTRL_BUTTONS ED_NUM_CTRL1_7_BUTTONS
63 // values for the element list
64 #define ED_ELEMENTLIST_XPOS (editor.palette.x)
65 #define ED_ELEMENTLIST_YPOS (editor.palette.y)
66 #define ED_ELEMENTLIST_XSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].width)
67 #define ED_ELEMENTLIST_YSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].height)
68 #define ED_ELEMENTLIST_COLS MAX(1, editor.palette.cols)
69 #define ED_ELEMENTLIST_ROWS MAX(1, editor.palette.rows)
70 #define ED_ELEMENTLIST_BUTTONS_HORIZ (ED_ELEMENTLIST_COLS)
71 #define ED_ELEMENTLIST_BUTTONS_VERT (ED_ELEMENTLIST_ROWS)
72 #define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \
73 ED_ELEMENTLIST_BUTTONS_VERT)
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)
269 #define ED_AREA_ELEMENT_CONTENT_XOFF(n) (n)
270 #define ED_AREA_ELEMENT_CONTENT_YOFF(n) (n)
273 #define ED_XPOS_YAM 0
274 #define ED_YPOS_YAM 5
275 #define ED_AREA_YAMYAM_CONTENT_XPOS ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_YAM)
276 #define ED_AREA_YAMYAM_CONTENT_YPOS ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_YAM)
277 #define ED_AREA_YAMYAM_CONTENT_XOFF(n) ED_AREA_ELEMENT_CONTENT_XOFF(n)
278 #define ED_AREA_YAMYAM_CONTENT_YOFF(n) ED_AREA_ELEMENT_CONTENT_YOFF(n)
279 #define ED_AREA_YAMYAM_CONTENT_X(n) (ED_ELEMENT_SETTINGS_X(ED_XPOS_YAM) + \
281 #define ED_AREA_YAMYAM_CONTENT_Y(n) (ED_ELEMENT_SETTINGS_Y(ED_YPOS_YAM) + \
282 ED_SETTINGS_YOFF(n) + \
283 ED_AREA_YOFFSET_1(ED_YPOS_YAM) - \
284 ED_AREA_YOFFSET_2(3))
286 // magic ball content
287 #define ED_XPOS_BALL 0
288 #define ED_YPOS_BALL 6
289 #define ED_AREA_MAGIC_BALL_CONTENT_XPOS ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_BALL)
290 #define ED_AREA_MAGIC_BALL_CONTENT_YPOS ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_BALL)
291 #define ED_AREA_MAGIC_BALL_CONTENT_XOFF(n) ED_AREA_ELEMENT_CONTENT_XOFF(n)
292 #define ED_AREA_MAGIC_BALL_CONTENT_YOFF(n) ED_AREA_ELEMENT_CONTENT_YOFF(n)
293 #define ED_AREA_MAGIC_BALL_CONTENT_X(n) (ED_ELEMENT_SETTINGS_X(ED_XPOS_BALL) + \
295 #define ED_AREA_MAGIC_BALL_CONTENT_Y(n) (ED_ELEMENT_SETTINGS_Y(ED_YPOS_BALL) + \
296 ED_SETTINGS_YOFF(n) + \
297 ED_AREA_YOFFSET_1(ED_YPOS_BALL) - \
298 ED_AREA_YOFFSET_2(3))
300 // values for scrolling gadgets for drawing area
301 #define ED_SCROLLBUTTON_XSIZE (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].width)
302 #define ED_SCROLLBUTTON_YSIZE (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].height)
304 #define ED_SCROLL_UP_XPOS (SXSIZE - ED_SCROLLBUTTON_XSIZE)
305 #define ED_SCROLL_UP_YPOS (0)
306 #define ED_SCROLL_DOWN_XPOS ED_SCROLL_UP_XPOS
307 #define ED_SCROLL_DOWN_YPOS (SYSIZE - 3 * ED_SCROLLBUTTON_YSIZE)
308 #define ED_SCROLL_LEFT_XPOS (0)
309 #define ED_SCROLL_LEFT_YPOS (SYSIZE - 2 * ED_SCROLLBUTTON_YSIZE)
310 #define ED_SCROLL_RIGHT_XPOS (SXSIZE - 2 * ED_SCROLLBUTTON_XSIZE)
311 #define ED_SCROLL_RIGHT_YPOS ED_SCROLL_LEFT_YPOS
312 #define ED_SCROLL_HORIZONTAL_XPOS (ED_SCROLL_LEFT_XPOS + \
313 ED_SCROLLBUTTON_XSIZE)
314 #define ED_SCROLL_HORIZONTAL_YPOS ED_SCROLL_LEFT_YPOS
315 #define ED_SCROLL_HORIZONTAL_XSIZE (SXSIZE - 3 * ED_SCROLLBUTTON_XSIZE)
316 #define ED_SCROLL_HORIZONTAL_YSIZE ED_SCROLLBUTTON_YSIZE
317 #define ED_SCROLL_VERTICAL_XPOS ED_SCROLL_UP_XPOS
318 #define ED_SCROLL_VERTICAL_YPOS (ED_SCROLL_UP_YPOS + \
319 ED_SCROLLBUTTON_YSIZE)
320 #define ED_SCROLL_VERTICAL_XSIZE ED_SCROLLBUTTON_XSIZE
321 #define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - 4 * ED_SCROLLBUTTON_YSIZE)
323 // values for scrolling gadgets for element list
324 #define ED_SCROLLBUTTON2_XSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].width)
325 #define ED_SCROLLBUTTON2_YSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].height)
327 #define ED_SCROLL2_UP_XPOS (ED_ELEMENTLIST_XPOS + \
328 ED_ELEMENTLIST_BUTTONS_HORIZ * \
329 ED_ELEMENTLIST_XSIZE)
330 #define ED_SCROLL2_UP_YPOS ED_ELEMENTLIST_YPOS
331 #define ED_SCROLL2_DOWN_XPOS ED_SCROLL2_UP_XPOS
332 #define ED_SCROLL2_DOWN_YPOS (ED_SCROLL2_UP_YPOS + \
333 ED_ELEMENTLIST_BUTTONS_VERT * \
334 ED_ELEMENTLIST_YSIZE - \
335 ED_SCROLLBUTTON2_YSIZE)
336 #define ED_SCROLL2_VERTICAL_XPOS ED_SCROLL2_UP_XPOS
337 #define ED_SCROLL2_VERTICAL_YPOS (ED_SCROLL2_UP_YPOS + \
338 ED_SCROLLBUTTON2_YSIZE)
339 #define ED_SCROLL2_VERTICAL_XSIZE ED_SCROLLBUTTON2_XSIZE
340 #define ED_SCROLL2_VERTICAL_YSIZE (ED_ELEMENTLIST_BUTTONS_VERT * \
341 ED_ELEMENTLIST_YSIZE - \
342 2 * ED_SCROLLBUTTON2_YSIZE)
344 // values for ClearEditorGadgetInfoText() and HandleEditorGadgetInfoText()
345 #define INFOTEXT_FONT FONT_TEXT_2
346 #define INFOTEXT_XSIZE SXSIZE
347 #define INFOTEXT_YSIZE getFontHeight(INFOTEXT_FONT)
348 #define INFOTEXT_YSIZE_FULL (INFOTEXT_YSIZE + ED_GADGET_SMALL_DISTANCE)
349 #define INFOTEXT_X (editor.settings.tooltip.x)
350 #define INFOTEXT_Y (editor.settings.tooltip.y)
351 #define INFOTEXT_XY_REDEFINED (INFOTEXT_X != -1 || INFOTEXT_Y != -1)
352 #define INFOTEXT_XPOS SX + (INFOTEXT_XY_REDEFINED ? INFOTEXT_X : 0)
353 #define INFOTEXT_YPOS SY + (INFOTEXT_XY_REDEFINED ? INFOTEXT_Y : \
354 SYSIZE - INFOTEXT_YSIZE)
357 // ----------------------------------------------------------------------------
358 // editor gadget definitions
359 // ----------------------------------------------------------------------------
365 // drawing toolbox buttons
367 GADGET_ID_SINGLE_ITEMS,
368 GADGET_ID_CONNECTED_ITEMS,
372 GADGET_ID_FILLED_BOX,
375 GADGET_ID_FLOOD_FILL,
378 GADGET_ID_WRAP_RIGHT,
379 GADGET_ID_RANDOM_PLACEMENT,
380 GADGET_ID_GRAB_BRUSH,
382 GADGET_ID_PICK_ELEMENT,
391 GADGET_ID_CUSTOM_COPY_FROM,
392 GADGET_ID_CUSTOM_COPY_TO,
393 GADGET_ID_CUSTOM_EXCHANGE,
394 GADGET_ID_CUSTOM_COPY,
395 GADGET_ID_CUSTOM_PASTE,
397 GADGET_ID_PROPERTIES,
398 GADGET_ID_ELEMENT_LEFT,
399 GADGET_ID_ELEMENT_MIDDLE,
400 GADGET_ID_ELEMENT_RIGHT,
403 // counter gadget identifiers
405 GADGET_ID_SELECT_LEVEL_DOWN,
406 GADGET_ID_SELECT_LEVEL_TEXT,
407 GADGET_ID_SELECT_LEVEL_UP,
408 GADGET_ID_LEVEL_XSIZE_DOWN,
409 GADGET_ID_LEVEL_XSIZE_TEXT,
410 GADGET_ID_LEVEL_XSIZE_UP,
411 GADGET_ID_LEVEL_YSIZE_DOWN,
412 GADGET_ID_LEVEL_YSIZE_TEXT,
413 GADGET_ID_LEVEL_YSIZE_UP,
414 GADGET_ID_LEVEL_RANDOM_DOWN,
415 GADGET_ID_LEVEL_RANDOM_TEXT,
416 GADGET_ID_LEVEL_RANDOM_UP,
417 GADGET_ID_LEVEL_GEMSLIMIT_DOWN,
418 GADGET_ID_LEVEL_GEMSLIMIT_TEXT,
419 GADGET_ID_LEVEL_GEMSLIMIT_UP,
420 GADGET_ID_LEVEL_TIMELIMIT_DOWN,
421 GADGET_ID_LEVEL_TIMELIMIT_TEXT,
422 GADGET_ID_LEVEL_TIMELIMIT_UP,
423 GADGET_ID_LEVEL_TIMESCORE_DOWN,
424 GADGET_ID_LEVEL_TIMESCORE_TEXT,
425 GADGET_ID_LEVEL_TIMESCORE_UP,
426 GADGET_ID_LEVEL_RANDOM_SEED_DOWN,
427 GADGET_ID_LEVEL_RANDOM_SEED_TEXT,
428 GADGET_ID_LEVEL_RANDOM_SEED_UP,
429 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN,
430 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT,
431 GADGET_ID_LEVELSET_NUM_LEVELS_UP,
432 GADGET_ID_ELEMENT_VALUE1_DOWN,
433 GADGET_ID_ELEMENT_VALUE1_TEXT,
434 GADGET_ID_ELEMENT_VALUE1_UP,
435 GADGET_ID_ELEMENT_VALUE2_DOWN,
436 GADGET_ID_ELEMENT_VALUE2_TEXT,
437 GADGET_ID_ELEMENT_VALUE2_UP,
438 GADGET_ID_ELEMENT_VALUE3_DOWN,
439 GADGET_ID_ELEMENT_VALUE3_TEXT,
440 GADGET_ID_ELEMENT_VALUE3_UP,
441 GADGET_ID_ELEMENT_VALUE4_DOWN,
442 GADGET_ID_ELEMENT_VALUE4_TEXT,
443 GADGET_ID_ELEMENT_VALUE4_UP,
444 GADGET_ID_YAMYAM_CONTENT_DOWN,
445 GADGET_ID_YAMYAM_CONTENT_TEXT,
446 GADGET_ID_YAMYAM_CONTENT_UP,
447 GADGET_ID_BALL_CONTENT_DOWN,
448 GADGET_ID_BALL_CONTENT_TEXT,
449 GADGET_ID_BALL_CONTENT_UP,
450 GADGET_ID_ANDROID_CONTENT_DOWN,
451 GADGET_ID_ANDROID_CONTENT_TEXT,
452 GADGET_ID_ANDROID_CONTENT_UP,
453 GADGET_ID_ENVELOPE_XSIZE_DOWN,
454 GADGET_ID_ENVELOPE_XSIZE_TEXT,
455 GADGET_ID_ENVELOPE_XSIZE_UP,
456 GADGET_ID_ENVELOPE_YSIZE_DOWN,
457 GADGET_ID_ENVELOPE_YSIZE_TEXT,
458 GADGET_ID_ENVELOPE_YSIZE_UP,
459 GADGET_ID_INVENTORY_SIZE_DOWN,
460 GADGET_ID_INVENTORY_SIZE_TEXT,
461 GADGET_ID_INVENTORY_SIZE_UP,
462 GADGET_ID_MM_BALL_CONTENT_DOWN,
463 GADGET_ID_MM_BALL_CONTENT_TEXT,
464 GADGET_ID_MM_BALL_CONTENT_UP,
465 GADGET_ID_CUSTOM_SCORE_DOWN,
466 GADGET_ID_CUSTOM_SCORE_TEXT,
467 GADGET_ID_CUSTOM_SCORE_UP,
468 GADGET_ID_CUSTOM_GEMCOUNT_DOWN,
469 GADGET_ID_CUSTOM_GEMCOUNT_TEXT,
470 GADGET_ID_CUSTOM_GEMCOUNT_UP,
471 GADGET_ID_CUSTOM_VALUE_FIX_DOWN,
472 GADGET_ID_CUSTOM_VALUE_FIX_TEXT,
473 GADGET_ID_CUSTOM_VALUE_FIX_UP,
474 GADGET_ID_CUSTOM_VALUE_RND_DOWN,
475 GADGET_ID_CUSTOM_VALUE_RND_TEXT,
476 GADGET_ID_CUSTOM_VALUE_RND_UP,
477 GADGET_ID_PUSH_DELAY_FIX_DOWN,
478 GADGET_ID_PUSH_DELAY_FIX_TEXT,
479 GADGET_ID_PUSH_DELAY_FIX_UP,
480 GADGET_ID_PUSH_DELAY_RND_DOWN,
481 GADGET_ID_PUSH_DELAY_RND_TEXT,
482 GADGET_ID_PUSH_DELAY_RND_UP,
483 GADGET_ID_DROP_DELAY_FIX_DOWN,
484 GADGET_ID_DROP_DELAY_FIX_TEXT,
485 GADGET_ID_DROP_DELAY_FIX_UP,
486 GADGET_ID_DROP_DELAY_RND_DOWN,
487 GADGET_ID_DROP_DELAY_RND_TEXT,
488 GADGET_ID_DROP_DELAY_RND_UP,
489 GADGET_ID_MOVE_DELAY_FIX_DOWN,
490 GADGET_ID_MOVE_DELAY_FIX_TEXT,
491 GADGET_ID_MOVE_DELAY_FIX_UP,
492 GADGET_ID_MOVE_DELAY_RND_DOWN,
493 GADGET_ID_MOVE_DELAY_RND_TEXT,
494 GADGET_ID_MOVE_DELAY_RND_UP,
495 GADGET_ID_STEP_DELAY_FIX_DOWN,
496 GADGET_ID_STEP_DELAY_FIX_TEXT,
497 GADGET_ID_STEP_DELAY_FIX_UP,
498 GADGET_ID_STEP_DELAY_RND_DOWN,
499 GADGET_ID_STEP_DELAY_RND_TEXT,
500 GADGET_ID_STEP_DELAY_RND_UP,
501 GADGET_ID_EXPLOSION_DELAY_DOWN,
502 GADGET_ID_EXPLOSION_DELAY_TEXT,
503 GADGET_ID_EXPLOSION_DELAY_UP,
504 GADGET_ID_IGNITION_DELAY_DOWN,
505 GADGET_ID_IGNITION_DELAY_TEXT,
506 GADGET_ID_IGNITION_DELAY_UP,
507 GADGET_ID_CHANGE_DELAY_FIX_DOWN,
508 GADGET_ID_CHANGE_DELAY_FIX_TEXT,
509 GADGET_ID_CHANGE_DELAY_FIX_UP,
510 GADGET_ID_CHANGE_DELAY_RND_DOWN,
511 GADGET_ID_CHANGE_DELAY_RND_TEXT,
512 GADGET_ID_CHANGE_DELAY_RND_UP,
513 GADGET_ID_CHANGE_CONT_RND_DOWN,
514 GADGET_ID_CHANGE_CONT_RND_TEXT,
515 GADGET_ID_CHANGE_CONT_RND_UP,
516 GADGET_ID_GROUP_CONTENT_DOWN,
517 GADGET_ID_GROUP_CONTENT_TEXT,
518 GADGET_ID_GROUP_CONTENT_UP,
520 // drawing area identifiers
522 GADGET_ID_DRAWING_LEVEL,
523 GADGET_ID_YAMYAM_CONTENT_0,
524 GADGET_ID_YAMYAM_CONTENT_1,
525 GADGET_ID_YAMYAM_CONTENT_2,
526 GADGET_ID_YAMYAM_CONTENT_3,
527 GADGET_ID_YAMYAM_CONTENT_4,
528 GADGET_ID_YAMYAM_CONTENT_5,
529 GADGET_ID_YAMYAM_CONTENT_6,
530 GADGET_ID_YAMYAM_CONTENT_7,
531 GADGET_ID_MAGIC_BALL_CONTENT_0,
532 GADGET_ID_MAGIC_BALL_CONTENT_1,
533 GADGET_ID_MAGIC_BALL_CONTENT_2,
534 GADGET_ID_MAGIC_BALL_CONTENT_3,
535 GADGET_ID_MAGIC_BALL_CONTENT_4,
536 GADGET_ID_MAGIC_BALL_CONTENT_5,
537 GADGET_ID_MAGIC_BALL_CONTENT_6,
538 GADGET_ID_MAGIC_BALL_CONTENT_7,
539 GADGET_ID_ANDROID_CONTENT,
540 GADGET_ID_AMOEBA_CONTENT,
541 GADGET_ID_START_ELEMENT,
542 GADGET_ID_ARTWORK_ELEMENT,
543 GADGET_ID_EXPLOSION_ELEMENT,
544 GADGET_ID_INVENTORY_CONTENT,
545 GADGET_ID_MM_BALL_CONTENT,
546 GADGET_ID_CUSTOM_GRAPHIC,
547 GADGET_ID_CUSTOM_CONTENT,
548 GADGET_ID_CUSTOM_MOVE_ENTER,
549 GADGET_ID_CUSTOM_MOVE_LEAVE,
550 GADGET_ID_CUSTOM_CHANGE_TARGET,
551 GADGET_ID_CUSTOM_CHANGE_CONTENT,
552 GADGET_ID_CUSTOM_CHANGE_TRIGGER,
553 GADGET_ID_CUSTOM_CHANGE_ACTION,
554 GADGET_ID_GROUP_CONTENT,
555 GADGET_ID_RANDOM_BACKGROUND,
557 // text input identifiers
559 GADGET_ID_LEVEL_NAME,
560 GADGET_ID_LEVEL_AUTHOR,
561 GADGET_ID_LEVELSET_NAME,
562 GADGET_ID_LEVELSET_AUTHOR,
563 GADGET_ID_ELEMENT_NAME,
565 // text area identifiers
567 GADGET_ID_ENVELOPE_INFO,
569 // selectbox identifiers
571 GADGET_ID_TIME_OR_STEPS,
572 GADGET_ID_TIME_SCORE_BASE,
573 GADGET_ID_GAME_ENGINE_TYPE,
574 GADGET_ID_LEVELSET_SAVE_MODE,
575 GADGET_ID_WIND_DIRECTION,
576 GADGET_ID_PLAYER_SPEED,
577 GADGET_ID_MM_BALL_CHOICE_MODE,
578 GADGET_ID_CUSTOM_WALK_TO_ACTION,
579 GADGET_ID_CUSTOM_EXPLOSION_TYPE,
580 GADGET_ID_CUSTOM_DEADLINESS,
581 GADGET_ID_CUSTOM_MOVE_PATTERN,
582 GADGET_ID_CUSTOM_MOVE_DIRECTION,
583 GADGET_ID_CUSTOM_MOVE_STEPSIZE,
584 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
585 GADGET_ID_CUSTOM_SMASH_TARGETS,
586 GADGET_ID_CUSTOM_SLIPPERY_TYPE,
587 GADGET_ID_CUSTOM_ACCESS_TYPE,
588 GADGET_ID_CUSTOM_ACCESS_LAYER,
589 GADGET_ID_CUSTOM_ACCESS_PROTECTED,
590 GADGET_ID_CUSTOM_ACCESS_DIRECTION,
591 GADGET_ID_CHANGE_TIME_UNITS,
592 GADGET_ID_CHANGE_DIRECT_ACTION,
593 GADGET_ID_CHANGE_OTHER_ACTION,
594 GADGET_ID_CHANGE_SIDE,
595 GADGET_ID_CHANGE_PLAYER,
596 GADGET_ID_CHANGE_PAGE,
597 GADGET_ID_CHANGE_REPLACE_WHEN,
598 GADGET_ID_ACTION_TYPE,
599 GADGET_ID_ACTION_MODE,
600 GADGET_ID_ACTION_ARG,
601 GADGET_ID_SELECT_CHANGE_PAGE,
602 GADGET_ID_GROUP_CHOICE_MODE,
604 // textbutton identifiers
606 GADGET_ID_LEVELCONFIG_LEVEL,
607 GADGET_ID_LEVELCONFIG_LEVELSET,
608 GADGET_ID_LEVELCONFIG_EDITOR,
609 GADGET_ID_LEVELCONFIG_ENGINE,
610 GADGET_ID_PROPERTIES_INFO,
611 GADGET_ID_PROPERTIES_CONFIG,
612 GADGET_ID_PROPERTIES_CONFIG_1,
613 GADGET_ID_PROPERTIES_CONFIG_2,
614 GADGET_ID_PROPERTIES_CHANGE,
615 GADGET_ID_SAVE_AS_TEMPLATE_1,
616 GADGET_ID_SAVE_AS_TEMPLATE_2,
617 GADGET_ID_SAVE_LEVELSET,
618 GADGET_ID_ADD_CHANGE_PAGE,
619 GADGET_ID_DEL_CHANGE_PAGE,
621 // graphicbutton identifiers
623 GADGET_ID_PREV_CHANGE_PAGE,
624 GADGET_ID_NEXT_CHANGE_PAGE,
625 GADGET_ID_COPY_CHANGE_PAGE,
626 GADGET_ID_PASTE_CHANGE_PAGE,
628 // gadgets for scrolling of drawing area
631 GADGET_ID_SCROLL_DOWN,
632 GADGET_ID_SCROLL_LEFT,
633 GADGET_ID_SCROLL_RIGHT,
634 GADGET_ID_SCROLL_HORIZONTAL,
635 GADGET_ID_SCROLL_VERTICAL,
637 // gadgets for scrolling element list
639 GADGET_ID_SCROLL_LIST_UP,
640 GADGET_ID_SCROLL_LIST_DOWN,
641 GADGET_ID_SCROLL_LIST_VERTICAL,
643 // checkbuttons/radiobuttons for level/element properties
645 GADGET_ID_AUTO_COUNT_GEMS,
646 GADGET_ID_RATE_TIME_OVER_SCORE,
647 GADGET_ID_USE_LEVELSET_ARTWORK,
648 GADGET_ID_COPY_LEVEL_TEMPLATE,
649 GADGET_ID_RANDOM_PERCENTAGE,
650 GADGET_ID_RANDOM_QUANTITY,
651 GADGET_ID_RANDOM_RESTRICTED,
652 GADGET_ID_BD_INTERMISSION,
653 GADGET_ID_STICK_ELEMENT,
654 GADGET_ID_EM_SLIPPERY_GEMS,
655 GADGET_ID_EM_EXPLODES_BY_FIRE,
656 GADGET_ID_USE_SPRING_BUG,
657 GADGET_ID_USE_TIME_ORB_BUG,
658 GADGET_ID_USE_LIFE_BUGS,
659 GADGET_ID_RANDOM_BALL_CONTENT,
660 GADGET_ID_INITIAL_BALL_ACTIVE,
661 GADGET_ID_GROW_INTO_DIGGABLE,
662 GADGET_ID_SB_FIELDS_NEEDED,
663 GADGET_ID_SB_OBJECTS_NEEDED,
664 GADGET_ID_AUTO_EXIT_SOKOBAN,
665 GADGET_ID_SOLVED_BY_ONE_PLAYER,
666 GADGET_ID_FINISH_DIG_COLLECT,
667 GADGET_ID_KEEP_WALKABLE_CE,
668 GADGET_ID_CONTINUOUS_SNAPPING,
669 GADGET_ID_BLOCK_SNAP_FIELD,
670 GADGET_ID_BLOCK_LAST_FIELD,
671 GADGET_ID_SP_BLOCK_LAST_FIELD,
672 GADGET_ID_INSTANT_RELOCATION,
673 GADGET_ID_SHIFTED_RELOCATION,
674 GADGET_ID_LAZY_RELOCATION,
675 GADGET_ID_USE_START_ELEMENT,
676 GADGET_ID_USE_ARTWORK_ELEMENT,
677 GADGET_ID_USE_EXPLOSION_ELEMENT,
678 GADGET_ID_INITIAL_GRAVITY,
679 GADGET_ID_USE_INITIAL_INVENTORY,
680 GADGET_ID_CAN_PASS_TO_WALKABLE,
681 GADGET_ID_CAN_FALL_INTO_ACID,
682 GADGET_ID_CAN_MOVE_INTO_ACID,
683 GADGET_ID_DONT_COLLIDE_WITH,
684 GADGET_ID_BD_DIAGONAL_MOVEMENTS,
685 GADGET_ID_ENVELOPE_AUTOWRAP,
686 GADGET_ID_ENVELOPE_CENTERED,
687 GADGET_ID_MM_LASER_RED,
688 GADGET_ID_MM_LASER_GREEN,
689 GADGET_ID_MM_LASER_BLUE,
690 GADGET_ID_DF_LASER_RED,
691 GADGET_ID_DF_LASER_GREEN,
692 GADGET_ID_DF_LASER_BLUE,
693 GADGET_ID_ROTATE_MM_BALL_CONTENT,
694 GADGET_ID_EXPLODE_MM_BALL,
695 GADGET_ID_CUSTOM_INDESTRUCTIBLE,
696 GADGET_ID_CUSTOM_CAN_EXPLODE,
697 GADGET_ID_CUSTOM_EXPLODE_FIRE,
698 GADGET_ID_CUSTOM_EXPLODE_SMASH,
699 GADGET_ID_CUSTOM_EXPLODE_IMPACT,
700 GADGET_ID_CUSTOM_WALK_TO_OBJECT,
701 GADGET_ID_CUSTOM_DEADLY,
702 GADGET_ID_CUSTOM_CAN_MOVE,
703 GADGET_ID_CUSTOM_CAN_FALL,
704 GADGET_ID_CUSTOM_CAN_SMASH,
705 GADGET_ID_CUSTOM_SLIPPERY,
706 GADGET_ID_CUSTOM_ACCESSIBLE,
707 GADGET_ID_CUSTOM_GRAV_REACHABLE,
708 GADGET_ID_CUSTOM_USE_LAST_VALUE,
709 GADGET_ID_CUSTOM_USE_GRAPHIC,
710 GADGET_ID_CUSTOM_USE_TEMPLATE_1,
711 GADGET_ID_CUSTOM_USE_TEMPLATE_2,
712 GADGET_ID_CUSTOM_USE_TEMPLATE_3,
713 GADGET_ID_CUSTOM_CAN_CHANGE,
714 GADGET_ID_CHANGE_USE_CONTENT,
715 GADGET_ID_CHANGE_USE_EXPLOSION,
716 GADGET_ID_CHANGE_ONLY_COMPLETE,
717 GADGET_ID_CHANGE_USE_RANDOM,
718 GADGET_ID_CHANGE_HAS_ACTION,
719 GADGET_ID_CHANGE_DELAY,
720 GADGET_ID_CHANGE_BY_DIRECT_ACT,
721 GADGET_ID_CHANGE_BY_OTHER_ACT,
723 NUM_STATIC_GADGET_IDS
726 // gadgets for buttons in element list (dynamic)
727 #define GADGET_ID_ELEMENTLIST_FIRST (NUM_STATIC_GADGET_IDS)
728 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
729 ED_NUM_ELEMENTLIST_BUTTONS - 1)
731 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
733 // radio button numbers
737 RADIO_NR_DRAWING_TOOLBOX,
738 RADIO_NR_RANDOM_ELEMENTS
741 // values for counter gadgets
744 ED_COUNTER_ID_SELECT_LEVEL,
745 ED_COUNTER_ID_LEVEL_XSIZE,
746 ED_COUNTER_ID_LEVEL_YSIZE,
747 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
748 ED_COUNTER_ID_LEVEL_TIMELIMIT,
749 ED_COUNTER_ID_LEVEL_TIMESCORE,
750 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
751 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
752 ED_COUNTER_ID_LEVEL_RANDOM,
753 ED_COUNTER_ID_ELEMENT_VALUE1,
754 ED_COUNTER_ID_ELEMENT_VALUE2,
755 ED_COUNTER_ID_ELEMENT_VALUE3,
756 ED_COUNTER_ID_ELEMENT_VALUE4,
757 ED_COUNTER_ID_YAMYAM_CONTENT,
758 ED_COUNTER_ID_BALL_CONTENT,
759 ED_COUNTER_ID_ANDROID_CONTENT,
760 ED_COUNTER_ID_ENVELOPE_XSIZE,
761 ED_COUNTER_ID_ENVELOPE_YSIZE,
762 ED_COUNTER_ID_INVENTORY_SIZE,
763 ED_COUNTER_ID_MM_BALL_CONTENT,
764 ED_COUNTER_ID_CUSTOM_SCORE,
765 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
766 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
767 ED_COUNTER_ID_CUSTOM_VALUE_RND,
768 ED_COUNTER_ID_PUSH_DELAY_FIX,
769 ED_COUNTER_ID_PUSH_DELAY_RND,
770 ED_COUNTER_ID_DROP_DELAY_FIX,
771 ED_COUNTER_ID_DROP_DELAY_RND,
772 ED_COUNTER_ID_MOVE_DELAY_FIX,
773 ED_COUNTER_ID_MOVE_DELAY_RND,
774 ED_COUNTER_ID_STEP_DELAY_FIX,
775 ED_COUNTER_ID_STEP_DELAY_RND,
776 ED_COUNTER_ID_EXPLOSION_DELAY,
777 ED_COUNTER_ID_IGNITION_DELAY,
778 ED_COUNTER_ID_GROUP_CONTENT,
779 ED_COUNTER_ID_CHANGE_DELAY_FIX,
780 ED_COUNTER_ID_CHANGE_DELAY_RND,
781 ED_COUNTER_ID_CHANGE_CONT_RND,
783 ED_NUM_COUNTERBUTTONS
786 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
787 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
788 #define ED_COUNTER_ID_LEVELSET_FIRST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
789 #define ED_COUNTER_ID_LEVELSET_LAST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
790 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
791 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
793 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
794 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
795 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
796 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
797 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
798 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
800 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
801 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
803 // values for scrollbutton gadgets
806 ED_SCROLLBUTTON_ID_AREA_UP,
807 ED_SCROLLBUTTON_ID_AREA_DOWN,
808 ED_SCROLLBUTTON_ID_AREA_LEFT,
809 ED_SCROLLBUTTON_ID_AREA_RIGHT,
810 ED_SCROLLBUTTON_ID_LIST_UP,
811 ED_SCROLLBUTTON_ID_LIST_DOWN,
816 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
817 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
819 // values for scrollbar gadgets
822 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
823 ED_SCROLLBAR_ID_AREA_VERTICAL,
824 ED_SCROLLBAR_ID_LIST_VERTICAL,
829 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
830 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
832 // values for text input gadgets
835 ED_TEXTINPUT_ID_LEVEL_NAME,
836 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
837 ED_TEXTINPUT_ID_LEVELSET_NAME,
838 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
839 ED_TEXTINPUT_ID_ELEMENT_NAME,
844 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
845 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
847 #define ED_TEXTINPUT_ID_LEVELSET_FIRST ED_TEXTINPUT_ID_LEVELSET_NAME
848 #define ED_TEXTINPUT_ID_LEVELSET_LAST ED_TEXTINPUT_ID_LEVELSET_AUTHOR
850 // values for text area gadgets
853 ED_TEXTAREA_ID_ENVELOPE_INFO,
858 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
859 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
861 // values for selectbox gadgets
864 ED_SELECTBOX_ID_TIME_OR_STEPS,
865 ED_SELECTBOX_ID_TIME_SCORE_BASE,
866 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
867 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
868 ED_SELECTBOX_ID_WIND_DIRECTION,
869 ED_SELECTBOX_ID_PLAYER_SPEED,
870 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
871 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
872 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
873 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
874 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
875 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
876 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
877 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
878 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
879 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
880 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
881 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
882 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
883 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
884 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
885 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
886 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
887 ED_SELECTBOX_ID_CHANGE_SIDE,
888 ED_SELECTBOX_ID_CHANGE_PLAYER,
889 ED_SELECTBOX_ID_CHANGE_PAGE,
890 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
891 ED_SELECTBOX_ID_ACTION_TYPE,
892 ED_SELECTBOX_ID_ACTION_MODE,
893 ED_SELECTBOX_ID_ACTION_ARG,
894 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
895 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
900 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
901 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_GAME_ENGINE_TYPE
903 #define ED_SELECTBOX_ID_LEVELSET_FIRST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
904 #define ED_SELECTBOX_ID_LEVELSET_LAST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
906 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
907 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
908 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
909 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
910 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
911 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
913 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
914 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
916 // values for textbutton gadgets
919 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL,
920 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET,
921 ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR,
922 ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE,
923 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
924 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
925 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
926 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
927 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
928 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
929 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
930 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
931 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
932 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
937 #define ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
938 #define ED_TAB_BUTTON_ID_LEVELCONFIG_LAST ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE
940 #define ED_TAB_BUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
941 #define ED_TAB_BUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
943 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
944 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
946 // values for graphicbutton gadgets
949 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
950 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
951 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
952 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
954 ED_NUM_GRAPHICBUTTONS
957 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
958 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
960 // values for checkbutton gadgets
963 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
964 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
965 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
966 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
967 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
968 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
969 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
970 ED_CHECKBUTTON_ID_BD_INTERMISSION,
971 ED_CHECKBUTTON_ID_STICK_ELEMENT,
972 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
973 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
974 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
975 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
976 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
977 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
978 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
979 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
980 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
981 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
982 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
983 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
984 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
985 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
986 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
987 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
988 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
989 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
990 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
991 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
992 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
993 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
994 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
995 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
996 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
997 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
998 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
999 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
1000 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
1001 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
1002 ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS,
1003 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
1004 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
1005 ED_CHECKBUTTON_ID_MM_LASER_RED,
1006 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
1007 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
1008 ED_CHECKBUTTON_ID_DF_LASER_RED,
1009 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
1010 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
1011 ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT,
1012 ED_CHECKBUTTON_ID_EXPLODE_MM_BALL,
1013 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
1014 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
1015 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
1016 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
1017 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
1018 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
1019 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
1020 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
1021 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
1022 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
1023 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
1024 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
1025 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
1026 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
1027 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
1028 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
1029 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
1030 ED_CHECKBUTTON_ID_CHANGE_DELAY,
1031 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
1032 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
1033 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
1034 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
1035 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
1036 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
1037 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
1042 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
1043 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE
1045 #define ED_CHECKBUTTON_ID_LEVELSET_FIRST ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK
1046 #define ED_CHECKBUTTON_ID_LEVELSET_LAST ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE
1048 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
1049 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2
1051 #define ED_CHECKBUTTON_ID_ENGINE_FIRST ED_CHECKBUTTON_ID_BD_INTERMISSION
1052 #define ED_CHECKBUTTON_ID_ENGINE_LAST ED_CHECKBUTTON_ID_BD_INTERMISSION
1054 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
1055 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
1056 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
1057 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
1058 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
1059 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
1061 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
1062 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
1064 // values for radiobutton gadgets
1067 ED_RADIOBUTTON_ID_PERCENTAGE,
1068 ED_RADIOBUTTON_ID_QUANTITY,
1073 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
1074 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
1076 // values for drawing area gadgets
1079 ED_DRAWING_ID_DRAWING_LEVEL,
1080 ED_DRAWING_ID_YAMYAM_CONTENT_0,
1081 ED_DRAWING_ID_YAMYAM_CONTENT_1,
1082 ED_DRAWING_ID_YAMYAM_CONTENT_2,
1083 ED_DRAWING_ID_YAMYAM_CONTENT_3,
1084 ED_DRAWING_ID_YAMYAM_CONTENT_4,
1085 ED_DRAWING_ID_YAMYAM_CONTENT_5,
1086 ED_DRAWING_ID_YAMYAM_CONTENT_6,
1087 ED_DRAWING_ID_YAMYAM_CONTENT_7,
1088 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
1089 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
1090 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
1091 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
1092 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
1093 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
1094 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
1095 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
1096 ED_DRAWING_ID_ANDROID_CONTENT,
1097 ED_DRAWING_ID_AMOEBA_CONTENT,
1098 ED_DRAWING_ID_START_ELEMENT,
1099 ED_DRAWING_ID_ARTWORK_ELEMENT,
1100 ED_DRAWING_ID_EXPLOSION_ELEMENT,
1101 ED_DRAWING_ID_INVENTORY_CONTENT,
1102 ED_DRAWING_ID_MM_BALL_CONTENT,
1103 ED_DRAWING_ID_CUSTOM_GRAPHIC,
1104 ED_DRAWING_ID_CUSTOM_CONTENT,
1105 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
1106 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
1107 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
1108 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
1109 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
1110 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
1111 ED_DRAWING_ID_GROUP_CONTENT,
1112 ED_DRAWING_ID_RANDOM_BACKGROUND,
1114 ED_NUM_DRAWING_AREAS
1117 #define ED_DRAWING_ID_EDITOR_FIRST ED_DRAWING_ID_RANDOM_BACKGROUND
1118 #define ED_DRAWING_ID_EDITOR_LAST ED_DRAWING_ID_RANDOM_BACKGROUND
1121 // ----------------------------------------------------------------------------
1122 // some internally used definitions
1123 // ----------------------------------------------------------------------------
1125 // values for CopyLevelToUndoBuffer()
1126 #define UNDO_IMMEDIATE 0
1127 #define UNDO_ACCUMULATE 1
1129 // values for scrollbars
1130 #define ED_SCROLL_NO 0
1131 #define ED_SCROLL_LEFT 1
1132 #define ED_SCROLL_RIGHT 2
1133 #define ED_SCROLL_UP 4
1134 #define ED_SCROLL_DOWN 8
1136 // screens in the level editor
1137 #define ED_MODE_DRAWING 0
1138 #define ED_MODE_LEVELCONFIG 1
1139 #define ED_MODE_PROPERTIES 2
1140 #define ED_MODE_PALETTE 3
1142 // sub-screens in the global settings section
1143 #define ED_MODE_LEVELCONFIG_LEVEL ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
1144 #define ED_MODE_LEVELCONFIG_LEVELSET ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET
1145 #define ED_MODE_LEVELCONFIG_EDITOR ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR
1146 #define ED_MODE_LEVELCONFIG_ENGINE ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE
1148 // sub-screens in the element properties section
1149 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
1150 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
1151 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
1152 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
1153 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
1155 // how many steps can be cancelled
1156 #define NUM_UNDO_STEPS (64 + 1)
1158 // values for elements with score for certain actions
1160 #define MAX_SCORE 999
1162 // values for elements with count for collecting
1163 #define MIN_COLLECT_COUNT 0
1164 #define MAX_COLLECT_COUNT 999
1166 // values for random placement
1167 #define RANDOM_USE_PERCENTAGE 0
1168 #define RANDOM_USE_QUANTITY 1
1170 // values for level set save mode
1171 #define LEVELSET_SAVE_MODE_UPDATE 0
1172 #define LEVELSET_SAVE_MODE_CREATE 1
1174 // default value for element tile size in drawing area
1175 #define DEFAULT_EDITOR_TILESIZE MINI_TILESIZE
1176 #define DEFAULT_EDITOR_TILESIZE_MM TILESIZE
1179 // ----------------------------------------------------------------------------
1180 // some internally used data structure definitions
1181 // ----------------------------------------------------------------------------
1187 struct XYTileSize *pos;
1191 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
1193 // note: some additional characters are already reserved for "cheat mode"
1194 // shortcuts (":XYZ" style) -- for details, see "events.c"
1196 // ---------- toolbox control buttons ---------------------------------------
1199 IMG_GFX_EDITOR_BUTTON_DRAW_SINGLE, GADGET_ID_SINGLE_ITEMS,
1200 &editor.button.draw_single, GD_TYPE_RADIO_BUTTON,
1201 "draw single items", 's'
1204 IMG_GFX_EDITOR_BUTTON_DRAW_CONNECTED, GADGET_ID_CONNECTED_ITEMS,
1205 &editor.button.draw_connected, GD_TYPE_RADIO_BUTTON,
1206 "draw connected items", 'd'
1209 IMG_GFX_EDITOR_BUTTON_DRAW_LINE, GADGET_ID_LINE,
1210 &editor.button.draw_line, GD_TYPE_RADIO_BUTTON,
1214 IMG_GFX_EDITOR_BUTTON_DRAW_ARC, GADGET_ID_ARC,
1215 &editor.button.draw_arc, GD_TYPE_RADIO_BUTTON,
1219 IMG_GFX_EDITOR_BUTTON_DRAW_RECTANGLE, GADGET_ID_RECTANGLE,
1220 &editor.button.draw_rectangle, GD_TYPE_RADIO_BUTTON,
1221 "draw outline rectangles", 'r'
1224 IMG_GFX_EDITOR_BUTTON_DRAW_FILLED_BOX, GADGET_ID_FILLED_BOX,
1225 &editor.button.draw_filled_box, GD_TYPE_RADIO_BUTTON,
1226 "draw filled rectangles", 'R'
1229 IMG_GFX_EDITOR_BUTTON_ROTATE_UP, GADGET_ID_WRAP_UP,
1230 &editor.button.rotate_up, GD_TYPE_NORMAL_BUTTON,
1231 "wrap (rotate) level up", 0
1234 IMG_GFX_EDITOR_BUTTON_DRAW_TEXT, GADGET_ID_TEXT,
1235 &editor.button.draw_text, GD_TYPE_RADIO_BUTTON,
1236 "enter text elements", 't'
1239 IMG_GFX_EDITOR_BUTTON_FLOOD_FILL, GADGET_ID_FLOOD_FILL,
1240 &editor.button.flood_fill, GD_TYPE_RADIO_BUTTON,
1244 IMG_GFX_EDITOR_BUTTON_ROTATE_LEFT, GADGET_ID_WRAP_LEFT,
1245 &editor.button.rotate_left, GD_TYPE_NORMAL_BUTTON,
1246 "wrap (rotate) level left", 0
1249 IMG_GFX_EDITOR_BUTTON_ZOOM_LEVEL, GADGET_ID_ZOOM,
1250 &editor.button.zoom_level, GD_TYPE_NORMAL_BUTTON,
1251 "zoom level tile size", '+'
1254 IMG_GFX_EDITOR_BUTTON_ROTATE_RIGHT, GADGET_ID_WRAP_RIGHT,
1255 &editor.button.rotate_right, GD_TYPE_NORMAL_BUTTON,
1256 "wrap (rotate) level right", 0
1259 IMG_GFX_EDITOR_BUTTON_DRAW_RANDOM, GADGET_ID_RANDOM_PLACEMENT,
1260 &editor.button.draw_random, GD_TYPE_NORMAL_BUTTON,
1261 "random element placement", 0
1264 IMG_GFX_EDITOR_BUTTON_GRAB_BRUSH, GADGET_ID_GRAB_BRUSH,
1265 &editor.button.grab_brush, GD_TYPE_RADIO_BUTTON,
1269 IMG_GFX_EDITOR_BUTTON_ROTATE_DOWN, GADGET_ID_WRAP_DOWN,
1270 &editor.button.rotate_down, GD_TYPE_NORMAL_BUTTON,
1271 "wrap (rotate) level down", 0
1274 IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT, GADGET_ID_PICK_ELEMENT,
1275 &editor.button.pick_element, GD_TYPE_RADIO_BUTTON,
1276 "pick drawing element", ','
1279 // ---------- level control buttons -----------------------------------------
1282 IMG_GFX_EDITOR_BUTTON_UNDO, GADGET_ID_UNDO,
1283 &editor.button.undo, GD_TYPE_NORMAL_BUTTON,
1284 "undo/redo last operation", 'u'
1287 IMG_GFX_EDITOR_BUTTON_CONF, GADGET_ID_CONF,
1288 &editor.button.conf, GD_TYPE_NORMAL_BUTTON,
1289 "level and editor settings", 'I'
1292 IMG_GFX_EDITOR_BUTTON_SAVE, GADGET_ID_SAVE,
1293 &editor.button.save, GD_TYPE_NORMAL_BUTTON,
1297 IMG_GFX_EDITOR_BUTTON_CLEAR, GADGET_ID_CLEAR,
1298 &editor.button.clear, GD_TYPE_NORMAL_BUTTON,
1302 IMG_GFX_EDITOR_BUTTON_TEST, GADGET_ID_TEST,
1303 &editor.button.test, GD_TYPE_NORMAL_BUTTON,
1307 IMG_GFX_EDITOR_BUTTON_EXIT, GADGET_ID_EXIT,
1308 &editor.button.exit, GD_TYPE_NORMAL_BUTTON,
1309 "exit level editor", 'E'
1312 // ---------- CE and GE control buttons -------------------------------------
1315 IMG_GFX_EDITOR_BUTTON_CE_COPY_FROM, GADGET_ID_CUSTOM_COPY_FROM,
1316 &editor.button.ce_copy_from, GD_TYPE_RADIO_BUTTON,
1317 "copy settings from other element", 0
1320 IMG_GFX_EDITOR_BUTTON_CE_COPY_TO, GADGET_ID_CUSTOM_COPY_TO,
1321 &editor.button.ce_copy_to, GD_TYPE_RADIO_BUTTON,
1322 "copy settings to other element", 0
1325 IMG_GFX_EDITOR_BUTTON_CE_SWAP, GADGET_ID_CUSTOM_EXCHANGE,
1326 &editor.button.ce_swap, GD_TYPE_RADIO_BUTTON,
1327 "exchange element with other element", 0
1330 IMG_GFX_EDITOR_BUTTON_CE_COPY, GADGET_ID_CUSTOM_COPY,
1331 &editor.button.ce_copy, GD_TYPE_NORMAL_BUTTON,
1332 "copy settings from this element", 0
1335 IMG_GFX_EDITOR_BUTTON_CE_PASTE, GADGET_ID_CUSTOM_PASTE,
1336 &editor.button.ce_paste, GD_TYPE_NORMAL_BUTTON,
1337 "paste settings to this element", 0
1340 // ---------- palette control buttons ---------------------------------------
1343 IMG_GFX_EDITOR_BUTTON_PROPERTIES, GADGET_ID_PROPERTIES,
1344 &editor.button.properties, GD_TYPE_NORMAL_BUTTON,
1345 "properties of drawing element", 'p'
1348 IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT, GADGET_ID_ELEMENT_LEFT,
1349 &editor.button.element_left, GD_TYPE_NORMAL_BUTTON,
1350 "properties of drawing element 1", '1'
1353 IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE, GADGET_ID_ELEMENT_MIDDLE,
1354 &editor.button.element_middle, GD_TYPE_NORMAL_BUTTON,
1355 "properties of drawing element 2", '2'
1358 IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT, GADGET_ID_ELEMENT_RIGHT,
1359 &editor.button.element_right, GD_TYPE_NORMAL_BUTTON,
1360 "properties of drawing element 3", '3'
1363 IMG_GFX_EDITOR_BUTTON_PALETTE, GADGET_ID_PALETTE,
1364 &editor.button.palette, GD_TYPE_NORMAL_BUTTON,
1365 "show list of elements", 'e'
1369 static int random_placement_value = 10;
1370 static int random_placement_method = RANDOM_USE_QUANTITY;
1371 static int random_placement_background_element = EL_SAND;
1372 static boolean random_placement_background_restricted = FALSE;
1373 static boolean stick_element_properties_window = FALSE;
1374 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1375 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1376 static struct ElementChangeInfo custom_element_change;
1377 static struct ElementGroupInfo group_element_info;
1378 static struct ElementInfo custom_element;
1380 static char levelset_name[MAX_LEVEL_NAME_LEN + 1];
1381 static char levelset_author[MAX_LEVEL_AUTHOR_LEN + 1];
1382 static int levelset_num_levels = 100;
1383 static boolean levelset_use_levelset_artwork = FALSE;
1384 static boolean levelset_copy_level_template = FALSE;
1385 static int levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
1391 int min_value, max_value;
1392 int gadget_id_down, gadget_id_up;
1394 int gadget_id_align;
1396 char *text_above, *text_left, *text_right;
1397 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1399 // ---------- current level number ------------------------------------------
1402 ED_COUNTER_ID_SELECT_LEVEL,
1403 -1, -1, // these values are not constant, but can change at runtime
1405 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1406 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1411 // ---------- level and editor settings -------------------------------------
1414 ED_COUNTER_ID_LEVEL_XSIZE,
1415 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1416 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1417 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1418 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1420 "playfield size:", NULL, "width",
1423 ED_COUNTER_ID_LEVEL_YSIZE,
1424 -1, ED_LEVEL_SETTINGS_YPOS(4),
1425 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1426 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1427 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1429 NULL, " ", "height",
1432 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
1433 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1435 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1436 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1438 NULL, "number of gems to collect:", NULL
1441 ED_COUNTER_ID_LEVEL_TIMELIMIT,
1442 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
1444 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1445 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1447 "time or step limit to solve level:", NULL, NULL
1450 ED_COUNTER_ID_LEVEL_TIMESCORE,
1451 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
1453 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1454 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1455 &level.score[SC_TIME_BONUS],
1456 "score for time or steps left:", NULL, NULL
1459 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
1460 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(13),
1462 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1463 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1465 NULL, "random seed:", "(0 => random)"
1468 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
1469 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1471 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN, GADGET_ID_LEVELSET_NUM_LEVELS_UP,
1472 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT, GADGET_ID_NONE,
1473 &levelset_num_levels,
1474 "number of levels:", NULL, NULL,
1477 ED_COUNTER_ID_LEVEL_RANDOM,
1478 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1480 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1481 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1482 &random_placement_value,
1483 "random element placement:", NULL, "in"
1486 // ---------- element settings: configure (various elements) ----------------
1489 ED_COUNTER_ID_ELEMENT_VALUE1,
1490 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1491 MIN_SCORE, MAX_SCORE,
1492 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1493 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1494 NULL, // will be set when used
1498 ED_COUNTER_ID_ELEMENT_VALUE2,
1499 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1500 MIN_SCORE, MAX_SCORE,
1501 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1502 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1503 NULL, // will be set when used
1507 ED_COUNTER_ID_ELEMENT_VALUE3,
1508 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1509 MIN_SCORE, MAX_SCORE,
1510 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1511 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1512 NULL, // will be set when used
1516 ED_COUNTER_ID_ELEMENT_VALUE4,
1517 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1518 MIN_SCORE, MAX_SCORE,
1519 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1520 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1521 NULL, // will be set when used
1525 ED_COUNTER_ID_YAMYAM_CONTENT,
1526 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1527 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1528 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1529 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1530 &level.num_yamyam_contents,
1531 NULL, NULL, "number of content areas"
1534 ED_COUNTER_ID_BALL_CONTENT,
1535 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1536 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1537 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1538 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1539 &level.num_ball_contents,
1540 NULL, NULL, "number of content areas"
1543 ED_COUNTER_ID_ANDROID_CONTENT,
1544 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1545 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1546 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1547 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1548 &level.num_android_clone_elements,
1549 NULL, NULL, "number of clonable elements"
1552 ED_COUNTER_ID_ENVELOPE_XSIZE,
1553 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1554 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1555 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1556 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1557 NULL, // will be set when used
1558 NULL, NULL, "width",
1561 ED_COUNTER_ID_ENVELOPE_YSIZE,
1562 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1563 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1564 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1565 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1566 NULL, // will be set when used
1567 NULL, " ", "height",
1570 ED_COUNTER_ID_INVENTORY_SIZE,
1571 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1572 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1573 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1574 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1575 &level.initial_inventory_size[0],
1576 NULL, NULL, "number of inventory elements"
1579 ED_COUNTER_ID_MM_BALL_CONTENT,
1580 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1581 MIN_ELEMENTS_IN_GROUP, MAX_MM_BALL_CONTENTS,
1582 GADGET_ID_MM_BALL_CONTENT_DOWN, GADGET_ID_MM_BALL_CONTENT_UP,
1583 GADGET_ID_MM_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1584 &level.num_mm_ball_contents,
1585 NULL, NULL, "number of content elements"
1588 // ---------- element settings: configure 1 (custom elements) ---------------
1591 ED_COUNTER_ID_CUSTOM_SCORE,
1592 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1593 MIN_SCORE, MAX_SCORE,
1594 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1595 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1596 &custom_element.collect_score_initial,
1597 NULL, "CE score", " "
1600 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
1601 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1602 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1603 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1604 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1605 &custom_element.collect_count_initial,
1606 NULL, "CE count", NULL
1609 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
1610 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1612 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1613 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1614 &custom_element.ce_value_fixed_initial,
1615 NULL, "CE value", NULL
1618 ED_COUNTER_ID_CUSTOM_VALUE_RND,
1619 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1621 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1622 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1623 &custom_element.ce_value_random_initial,
1624 NULL, "+random", NULL
1627 ED_COUNTER_ID_PUSH_DELAY_FIX,
1628 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1630 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1631 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1632 &custom_element.push_delay_fixed,
1633 NULL, "push delay", NULL
1636 ED_COUNTER_ID_PUSH_DELAY_RND,
1637 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1639 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1640 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1641 &custom_element.push_delay_random,
1642 NULL, "+random", NULL
1645 ED_COUNTER_ID_DROP_DELAY_FIX,
1646 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1648 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1649 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1650 &custom_element.drop_delay_fixed,
1651 NULL, "drop delay", NULL
1654 ED_COUNTER_ID_DROP_DELAY_RND,
1655 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1657 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1658 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1659 &custom_element.drop_delay_random,
1660 NULL, "+random", NULL
1663 // ---------- element settings: configure 2 (custom elements) ---------------
1666 ED_COUNTER_ID_MOVE_DELAY_FIX,
1667 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1669 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1670 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1671 &custom_element.move_delay_fixed,
1672 NULL, "move delay", NULL
1675 ED_COUNTER_ID_MOVE_DELAY_RND,
1676 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1678 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1679 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1680 &custom_element.move_delay_random,
1681 NULL, "+random", NULL
1684 ED_COUNTER_ID_STEP_DELAY_FIX,
1685 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1687 GADGET_ID_STEP_DELAY_FIX_DOWN, GADGET_ID_STEP_DELAY_FIX_UP,
1688 GADGET_ID_STEP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1689 &custom_element.step_delay_fixed,
1690 NULL, "step delay", NULL
1693 ED_COUNTER_ID_STEP_DELAY_RND,
1694 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1696 GADGET_ID_STEP_DELAY_RND_DOWN, GADGET_ID_STEP_DELAY_RND_UP,
1697 GADGET_ID_STEP_DELAY_RND_TEXT, GADGET_ID_STEP_DELAY_FIX_UP,
1698 &custom_element.step_delay_random,
1699 NULL, "+random", NULL
1702 ED_COUNTER_ID_EXPLOSION_DELAY,
1703 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1705 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1706 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1707 &custom_element.explosion_delay,
1708 NULL, "explosion delay", NULL
1711 ED_COUNTER_ID_IGNITION_DELAY,
1712 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
1714 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1715 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1716 &custom_element.ignition_delay,
1717 NULL, "ignition delay", "(by fire)"
1720 // ---------- element settings: configure (group elements) ------------------
1723 ED_COUNTER_ID_GROUP_CONTENT,
1724 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1725 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1726 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1727 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1728 &group_element_info.num_elements,
1729 NULL, NULL, "number of elements in group"
1732 // ---------- element settings: advanced (custom elements) ------------------
1735 ED_COUNTER_ID_CHANGE_DELAY_FIX,
1736 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1738 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1739 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1740 &custom_element_change.delay_fixed,
1741 NULL, "CE delay", NULL,
1744 ED_COUNTER_ID_CHANGE_DELAY_RND,
1745 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1747 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1748 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1749 &custom_element_change.delay_random,
1750 NULL, "+random", NULL
1753 ED_COUNTER_ID_CHANGE_CONT_RND,
1754 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1756 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1757 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1758 &custom_element_change.random_percentage,
1759 NULL, "use random replace:", "%"
1770 char *text_above, *infotext;
1771 } textinput_info[ED_NUM_TEXTINPUT] =
1774 ED_TEXTINPUT_ID_LEVEL_NAME,
1775 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1776 GADGET_ID_LEVEL_NAME,
1779 "Title:", "Title for this level"
1782 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
1783 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1784 GADGET_ID_LEVEL_AUTHOR,
1785 MAX_LEVEL_AUTHOR_LEN,
1787 "Author:", "Author for this level"
1790 ED_TEXTINPUT_ID_LEVELSET_NAME,
1791 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1792 GADGET_ID_LEVELSET_NAME,
1795 "Title:", "Title for this or new level set"
1798 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
1799 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1800 GADGET_ID_LEVELSET_AUTHOR,
1801 MAX_LEVEL_AUTHOR_LEN,
1803 "Author:", "Author for this or new level set"
1806 ED_TEXTINPUT_ID_ELEMENT_NAME,
1807 -1, -1, // these values are not constant, but can change at runtime
1808 GADGET_ID_ELEMENT_NAME,
1809 MAX_ELEMENT_NAME_LEN - 2, // currently 2 chars less editable
1810 custom_element.description,
1811 NULL, "Element name"
1822 char *text_above, *text_above_cropped, *infotext;
1823 } textarea_info[ED_NUM_TEXTAREAS] =
1826 ED_TEXTAREA_ID_ENVELOPE_INFO,
1827 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1828 GADGET_ID_ENVELOPE_INFO,
1829 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1831 "Envelope Content:", "Envelope Content (cropped):", "Envelope Content"
1835 static struct ValueTextInfo options_time_or_steps[] =
1843 static struct ValueTextInfo options_time_score_base[] =
1845 { 1, "per second/step" },
1846 { 10, "per 10 seconds/steps" },
1851 static struct ValueTextInfo options_game_engine_type[] =
1853 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1854 { GAME_ENGINE_TYPE_BD, "Boulder Dash" },
1855 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1856 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1857 { GAME_ENGINE_TYPE_MM, "Mirror Magic" },
1862 static struct ValueTextInfo options_levelset_save_mode[] =
1864 { LEVELSET_SAVE_MODE_UPDATE, "Update this level set" },
1865 { LEVELSET_SAVE_MODE_CREATE, "Create new level set" },
1870 static struct ValueTextInfo options_wind_direction[] =
1872 { MV_START_NONE, "none" },
1873 { MV_START_LEFT, "left" },
1874 { MV_START_RIGHT, "right" },
1875 { MV_START_UP, "up" },
1876 { MV_START_DOWN, "down" },
1881 static struct ValueTextInfo options_player_speed[] =
1888 { 16, "very fast" },
1889 { 32, "ultrafast" },
1894 static struct ValueTextInfo options_access_type[] =
1896 { EP_WALKABLE, "walkable" },
1897 { EP_PASSABLE, "passable" },
1902 static struct ValueTextInfo options_access_layer[] =
1904 { EP_ACCESSIBLE_OVER, "over" },
1905 { EP_ACCESSIBLE_INSIDE, "inside" },
1906 { EP_ACCESSIBLE_UNDER, "under" },
1911 static struct ValueTextInfo options_access_protected[] =
1913 { 0, "unprotected" },
1919 static struct ValueTextInfo options_access_direction[] =
1921 { MV_NO_DIRECTION, "no direction" },
1922 { MV_LEFT, "left" },
1923 { MV_RIGHT, "right" },
1925 { MV_DOWN, "down" },
1926 { MV_LEFT | MV_UP, "left + up" },
1927 { MV_LEFT | MV_DOWN, "left + down" },
1928 { MV_RIGHT | MV_UP, "right + up" },
1929 { MV_RIGHT | MV_DOWN, "right + down" },
1930 { MV_HORIZONTAL, "horizontal" },
1931 { MV_VERTICAL, "vertical" },
1932 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1933 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1934 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1935 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1936 { MV_ALL_DIRECTIONS, "all directions" },
1941 static struct ValueTextInfo options_walk_to_action[] =
1943 { EP_DIGGABLE, "diggable" },
1944 { EP_COLLECTIBLE_ONLY, "collectible" },
1945 { EP_DROPPABLE, "collectible & droppable" },
1946 { EP_THROWABLE, "collectible & throwable" },
1947 { EP_PUSHABLE, "pushable" },
1952 static struct ValueTextInfo options_move_pattern[] =
1954 { MV_LEFT, "left" },
1955 { MV_RIGHT, "right" },
1957 { MV_DOWN, "down" },
1958 { MV_HORIZONTAL, "horizontal" },
1959 { MV_VERTICAL, "vertical" },
1960 { MV_ALL_DIRECTIONS, "all directions" },
1961 { MV_WIND_DIRECTION, "wind direction" },
1962 { MV_TOWARDS_PLAYER, "towards player" },
1963 { MV_AWAY_FROM_PLAYER, "away from player" },
1964 { MV_ALONG_LEFT_SIDE, "along left side" },
1965 { MV_ALONG_RIGHT_SIDE, "along right side" },
1966 { MV_TURNING_LEFT, "turning left" },
1967 { MV_TURNING_RIGHT, "turning right" },
1968 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1969 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1970 { MV_TURNING_RANDOM, "turning random" },
1971 { MV_MAZE_RUNNER, "maze runner style" },
1972 { MV_MAZE_HUNTER, "maze hunter style" },
1973 { MV_WHEN_PUSHED, "when pushed" },
1974 { MV_WHEN_DROPPED, "when dropped/thrown" },
1979 static struct ValueTextInfo options_move_direction[] =
1981 { MV_START_AUTOMATIC, "automatic" },
1982 { MV_START_LEFT, "left" },
1983 { MV_START_RIGHT, "right" },
1984 { MV_START_UP, "up" },
1985 { MV_START_DOWN, "down" },
1986 { MV_START_RANDOM, "random" },
1987 { MV_START_PREVIOUS, "previous" },
1992 static struct ValueTextInfo options_move_stepsize[] =
1994 { 0, "not moving" },
1999 { 16, "very fast" },
2000 { 32, "even faster" },
2005 static struct ValueTextInfo options_move_leave_type[] =
2007 { LEAVE_TYPE_UNLIMITED, "leave behind" },
2008 { LEAVE_TYPE_LIMITED, "change it to" },
2013 static struct ValueTextInfo options_smash_targets[] =
2015 { EP_CAN_SMASH_PLAYER, "player" },
2017 { EP_CAN_SMASH_ENEMIES, "enemies" },
2019 { EP_CAN_SMASH_EVERYTHING, "everything" },
2024 static struct ValueTextInfo options_slippery_type[] =
2026 { SLIPPERY_ANY_RANDOM, "random" },
2027 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
2028 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
2029 { SLIPPERY_ONLY_LEFT, "only left" },
2030 { SLIPPERY_ONLY_RIGHT, "only right" },
2035 static struct ValueTextInfo options_deadliness[] =
2037 { EP_DONT_RUN_INTO, "running into" },
2038 { EP_DONT_COLLIDE_WITH, "colliding with" },
2039 { EP_DONT_GET_HIT_BY, "getting hit by" },
2040 { EP_DONT_TOUCH, "touching" },
2045 static struct ValueTextInfo options_explosion_type[] =
2047 { EXPLODES_3X3, "3x3" },
2048 { EXPLODES_CROSS, "3+3" },
2049 { EXPLODES_1X1, "1x1" },
2054 static struct ValueTextInfo options_time_units[] =
2057 { FRAMES_PER_SECOND, "seconds" },
2062 static struct ValueTextInfo options_change_direct_action[] =
2064 { CE_TOUCHED_BY_PLAYER, "touched by player" },
2065 { CE_PRESSED_BY_PLAYER, "pressed by player" },
2066 { CE_SWITCHED_BY_PLAYER, "switched by player" },
2067 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
2068 { CE_PUSHED_BY_PLAYER, "pushed by player" },
2069 { CE_ENTERED_BY_PLAYER, "entered by player" },
2070 { CE_LEFT_BY_PLAYER, "left by player" },
2071 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
2072 { CE_SWITCHED, "switched" },
2073 { CE_HITTING_SOMETHING, "hitting something" },
2074 { CE_HIT_BY_SOMETHING, "hit by something" },
2076 { CE_BLOCKED, "blocked" },
2078 { CE_IMPACT, "impact (on something)" },
2079 { CE_SMASHED, "smashed (from above)" },
2081 { CE_VALUE_CHANGES, "CE value changes" },
2082 { CE_SCORE_CHANGES, "CE score changes" },
2084 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
2085 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
2086 { CE_UNDEFINED, " " },
2087 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2088 { CE_CLICKED_BY_MOUSE, "clicked by mouse" },
2089 { CE_PRESSED_BY_MOUSE, "pressed by mouse" },
2090 { CE_UNDEFINED, " " },
2091 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2092 { CE_NEXT_TO_PLAYER, "next to player" },
2097 static struct ValueTextInfo options_change_other_action[] =
2099 { CE_PLAYER_TOUCHES_X, "player touches" },
2100 { CE_PLAYER_PRESSES_X, "player presses" },
2101 { CE_PLAYER_SWITCHES_X, "player switches" },
2102 { CE_PLAYER_SNAPS_X, "player snaps" },
2103 { CE_PLAYER_PUSHES_X, "player pushes" },
2104 { CE_PLAYER_ENTERS_X, "player enters" },
2105 { CE_PLAYER_LEAVES_X, "player leaves" },
2106 { CE_PLAYER_DIGS_X, "player digs" },
2107 { CE_PLAYER_COLLECTS_X, "player collects" },
2108 { CE_PLAYER_DROPS_X, "player drops/throws" },
2109 { CE_TOUCHING_X, "touching" },
2110 { CE_HITTING_X, "hitting" },
2111 { CE_DIGGING_X, "digging" },
2112 { CE_HIT_BY_X, "hit by" },
2113 { CE_SWITCH_OF_X, "switch of" },
2114 { CE_CHANGE_OF_X, "change by page of" },
2115 { CE_EXPLOSION_OF_X, "explosion of" },
2116 { CE_MOVE_OF_X, "move of" },
2117 { CE_CREATION_OF_X, "creation of" },
2118 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
2119 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
2120 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
2121 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
2122 { CE_UNDEFINED, " " },
2123 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2124 { CE_MOUSE_CLICKED_ON_X, "mouse clicked on" },
2125 { CE_MOUSE_PRESSED_ON_X, "mouse pressed on" },
2126 { CE_UNDEFINED, " " },
2127 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2128 { CE_PLAYER_NEXT_TO_X, "player next to" },
2129 { CE_NEXT_TO_X, "next to" },
2134 static struct ValueTextInfo options_change_trigger_side[] =
2136 { CH_SIDE_LEFT, "left" },
2137 { CH_SIDE_RIGHT, "right" },
2138 { CH_SIDE_TOP, "top" },
2139 { CH_SIDE_BOTTOM, "bottom" },
2140 { CH_SIDE_LEFT_RIGHT, "left/right" },
2141 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
2142 { CH_SIDE_ANY, "any" },
2147 static struct ValueTextInfo options_change_trigger_player[] =
2149 { CH_PLAYER_1, "1" },
2150 { CH_PLAYER_2, "2" },
2151 { CH_PLAYER_3, "3" },
2152 { CH_PLAYER_4, "4" },
2153 { CH_PLAYER_ANY, "any" },
2158 static struct ValueTextInfo options_change_trigger_page[] =
2169 { (1u << 9), "10" },
2170 { (1u << 10), "11" },
2171 { (1u << 11), "12" },
2172 { (1u << 12), "13" },
2173 { (1u << 13), "14" },
2174 { (1u << 14), "15" },
2175 { (1u << 15), "16" },
2176 { (1u << 16), "17" },
2177 { (1u << 17), "18" },
2178 { (1u << 18), "19" },
2179 { (1u << 19), "20" },
2180 { (1u << 20), "21" },
2181 { (1u << 21), "22" },
2182 { (1u << 22), "23" },
2183 { (1u << 23), "24" },
2184 { (1u << 24), "25" },
2185 { (1u << 25), "26" },
2186 { (1u << 26), "27" },
2187 { (1u << 27), "28" },
2188 { (1u << 28), "29" },
2189 { (1u << 29), "30" },
2190 { (1u << 30), "31" },
2191 { (1u << 31), "32" },
2192 { CH_PAGE_ANY, "any" },
2197 static struct ValueTextInfo options_change_replace_when[] =
2199 { CP_WHEN_EMPTY, "empty" },
2200 { CP_WHEN_WALKABLE, "walkable" },
2201 { CP_WHEN_DIGGABLE, "diggable" },
2202 { CP_WHEN_COLLECTIBLE, "collectible" },
2203 { CP_WHEN_REMOVABLE, "removable" },
2204 { CP_WHEN_DESTRUCTIBLE, "destructible" },
2209 static struct ValueTextInfo options_action_type[] =
2211 { CA_NO_ACTION, "no action" },
2212 { CA_UNDEFINED, " " },
2213 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
2214 { CA_RESTART_LEVEL, "restart level" },
2215 { CA_SHOW_ENVELOPE, "show envelope" },
2216 { CA_SET_LEVEL_TIME, "set time" },
2217 { CA_SET_LEVEL_SCORE, "set score" },
2218 { CA_SET_LEVEL_GEMS, "set gems" },
2219 { CA_SET_LEVEL_WIND, "set wind dir." },
2220 { CA_SET_LEVEL_RANDOM_SEED, "set random seed" },
2221 { CA_UNDEFINED, " " },
2222 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
2223 { CA_MOVE_PLAYER, "move player" },
2224 { CA_MOVE_PLAYER_NEW, "move player new" },
2225 { CA_EXIT_PLAYER, "exit player" },
2226 { CA_KILL_PLAYER, "kill player" },
2227 { CA_SET_PLAYER_KEYS, "set keys" },
2228 { CA_SET_PLAYER_SPEED, "set speed" },
2229 { CA_SET_PLAYER_SHIELD, "set shield" },
2230 { CA_SET_PLAYER_GRAVITY, "set gravity" },
2231 { CA_SET_PLAYER_ARTWORK, "set artwork" },
2232 { CA_SET_PLAYER_INVENTORY, "set inventory" },
2233 { CA_UNDEFINED, " " },
2234 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
2235 { CA_SET_CE_VALUE, "set CE value" },
2236 { CA_SET_CE_SCORE, "set CE score" },
2237 { CA_SET_CE_ARTWORK, "set CE artwork" },
2238 { CA_UNDEFINED, " " },
2239 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
2240 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
2245 static struct ValueTextInfo options_action_mode_none[] =
2247 { CA_MODE_UNDEFINED, " " },
2252 static struct ValueTextInfo options_action_mode_assign[] =
2254 { CA_MODE_SET, "=" },
2259 static struct ValueTextInfo options_action_mode_add_remove[] =
2261 { CA_MODE_ADD, "+" },
2262 { CA_MODE_SUBTRACT, "-" },
2267 static struct ValueTextInfo options_action_mode_calculate[] =
2269 { CA_MODE_SET, "=" },
2270 { CA_MODE_ADD, "+" },
2271 { CA_MODE_SUBTRACT, "-" },
2272 { CA_MODE_MULTIPLY, "*" },
2273 { CA_MODE_DIVIDE, "/" },
2274 { CA_MODE_MODULO, "%" },
2279 static struct ValueTextInfo options_action_arg_none[] =
2281 { CA_ARG_UNDEFINED, " " },
2286 static struct ValueTextInfo options_action_arg_player[] =
2288 { CA_ARG_PLAYER_HEADLINE, "[player]" },
2289 { CA_ARG_PLAYER_1, "1" },
2290 { CA_ARG_PLAYER_2, "2" },
2291 { CA_ARG_PLAYER_3, "3" },
2292 { CA_ARG_PLAYER_4, "4" },
2293 { CA_ARG_PLAYER_ANY, "any" },
2294 { CA_ARG_PLAYER_TRIGGER, "trigger" },
2295 { CA_ARG_PLAYER_ACTION, "action ->" },
2300 static struct ValueTextInfo options_action_arg_number[] =
2302 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2309 { CA_ARG_10, "10" },
2310 { CA_ARG_100, "100" },
2311 { CA_ARG_1000, "1000" },
2312 { CA_ARG_UNDEFINED, " " },
2313 { CA_ARG_NUMBER_MIN, "min" },
2314 { CA_ARG_NUMBER_MAX, "max" },
2315 { CA_ARG_UNDEFINED, " " },
2316 { CA_ARG_NUMBER_RESET, "reset" },
2317 { CA_ARG_UNDEFINED, " " },
2318 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2319 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2320 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2321 { CA_ARG_UNDEFINED, " " },
2322 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2323 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2324 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2325 { CA_ARG_UNDEFINED, " " },
2326 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2327 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2328 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2329 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2330 { CA_ARG_UNDEFINED, " " },
2331 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2332 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2333 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2334 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2339 static struct ValueTextInfo options_action_arg_value[] =
2341 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2348 { CA_ARG_10, "10" },
2349 { CA_ARG_100, "100" },
2350 { CA_ARG_1000, "1000" },
2351 { CA_ARG_UNDEFINED, " " },
2352 { CA_ARG_NUMBER_MIN, "min" },
2353 { CA_ARG_NUMBER_MAX, "max" },
2354 { CA_ARG_UNDEFINED, " " },
2355 { CA_ARG_NUMBER_RESET, "reset" },
2356 { CA_ARG_UNDEFINED, " " },
2357 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2358 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2359 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2360 { CA_ARG_UNDEFINED, " " },
2361 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2362 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2363 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2364 { CA_ARG_UNDEFINED, " " },
2365 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2366 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2367 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2368 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2369 { CA_ARG_UNDEFINED, " " },
2370 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2371 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2372 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2373 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2374 { CA_ARG_UNDEFINED, " " },
2375 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
2376 { CA_ARG_ELEMENT_NR_TARGET, "target" },
2377 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
2378 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
2383 static struct ValueTextInfo options_action_arg_envelope[] =
2385 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2390 { CA_ARG_UNDEFINED, " " },
2391 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2392 { CA_ARG_ELEMENT_TARGET, "target" },
2393 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2394 { CA_ARG_ELEMENT_ACTION, "action ->" },
2399 static struct ValueTextInfo options_action_arg_key[] =
2401 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2410 { CA_ARG_UNDEFINED, " " },
2411 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2412 { CA_ARG_ELEMENT_TARGET, "target" },
2413 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2414 { CA_ARG_ELEMENT_ACTION, "action ->" },
2419 static struct ValueTextInfo options_action_arg_speed[] =
2421 { CA_ARG_SPEED_HEADLINE, "[speed]" },
2422 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
2423 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
2424 { CA_ARG_SPEED_SLOW, "slow" },
2425 { CA_ARG_SPEED_NORMAL, "normal" },
2426 { CA_ARG_SPEED_FAST, "fast" },
2427 { CA_ARG_SPEED_VERY_FAST, "very fast" },
2428 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
2429 { CA_ARG_UNDEFINED, " " },
2430 { CA_ARG_SPEED_SLOWER, "slower" },
2431 { CA_ARG_SPEED_FASTER, "faster" },
2432 { CA_ARG_UNDEFINED, " " },
2433 { CA_ARG_SPEED_RESET, "reset" },
2438 static struct ValueTextInfo options_action_arg_shield[] =
2440 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
2441 { CA_ARG_SHIELD_OFF, "off" },
2442 { CA_ARG_SHIELD_NORMAL, "normal" },
2443 { CA_ARG_SHIELD_DEADLY, "deadly" },
2448 static struct ValueTextInfo options_action_arg_artwork[] =
2450 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2451 { CA_ARG_ELEMENT_TARGET, "target" },
2452 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2453 { CA_ARG_ELEMENT_ACTION, "action ->" },
2454 { CA_ARG_UNDEFINED, " " },
2455 { CA_ARG_ELEMENT_RESET, "reset" },
2460 static struct ValueTextInfo options_action_arg_gravity[] =
2462 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
2463 { CA_ARG_GRAVITY_ON, "on" },
2464 { CA_ARG_GRAVITY_OFF, "off" },
2465 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2470 static struct ValueTextInfo options_action_arg_direction[] =
2472 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2473 { CA_ARG_DIRECTION_NONE, "none" },
2474 { CA_ARG_DIRECTION_LEFT, "left" },
2475 { CA_ARG_DIRECTION_RIGHT, "right" },
2476 { CA_ARG_DIRECTION_UP, "up" },
2477 { CA_ARG_DIRECTION_DOWN, "down" },
2478 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2479 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2484 static struct ValueTextInfo options_action_arg_scan_mode[] =
2486 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2487 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2488 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2493 static struct ValueTextInfo options_action_arg_inventory[] =
2495 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2496 { CA_ARG_ELEMENT_TARGET, "+ target" },
2497 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2498 { CA_ARG_ELEMENT_ACTION, "+ action" },
2499 { CA_ARG_UNDEFINED, " " },
2500 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2501 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2502 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2503 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2504 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2505 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2506 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2507 { CA_ARG_UNDEFINED, " " },
2508 { CA_ARG_INVENTORY_RESET, "reset" },
2513 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2514 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2519 static struct ValueTextInfo options_group_choice_mode[] =
2521 { ANIM_RANDOM, "random" },
2522 { ANIM_LOOP, "loop" },
2523 { ANIM_LINEAR, "linear" },
2524 { ANIM_PINGPONG, "pingpong" },
2525 { ANIM_PINGPONG2, "pingpong 2" },
2526 { ANIM_LEVEL_NR, "level number" },
2531 static struct ValueTextInfo *action_arg_modes[] =
2533 options_action_mode_none,
2534 options_action_mode_assign,
2535 options_action_mode_add_remove,
2536 options_action_mode_calculate,
2543 struct ValueTextInfo *options;
2545 action_arg_options[] =
2547 { CA_NO_ACTION, 0, options_action_arg_none, },
2548 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2549 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2550 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2551 { CA_MOVE_PLAYER_NEW, 0, options_action_arg_direction, },
2552 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2553 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2554 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2555 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2556 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2557 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2558 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2559 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2560 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2561 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2562 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2563 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2564 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2565 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2566 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2567 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2568 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2578 int gadget_id_align;
2579 int size; // char size of selectbox or '-1' (dynamically determined)
2580 struct ValueTextInfo *options;
2582 char *text_above, *text_left, *text_right, *infotext;
2583 } selectbox_info[ED_NUM_SELECTBOX] =
2585 // ---------- level and editor settings -------------------------------------
2588 ED_SELECTBOX_ID_TIME_OR_STEPS,
2589 -1, ED_LEVEL_SETTINGS_YPOS(8),
2590 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2592 options_time_or_steps,
2593 &level.use_step_counter,
2594 NULL, NULL, "(0 => no limit)", "time or step limit"
2597 ED_SELECTBOX_ID_TIME_SCORE_BASE,
2598 -1, ED_LEVEL_SETTINGS_YPOS(10),
2599 GADGET_ID_TIME_SCORE_BASE, GADGET_ID_LEVEL_TIMESCORE_UP,
2601 options_time_score_base,
2602 &level.time_score_base,
2603 NULL, NULL, NULL, "time score for 1 or 10 seconds/steps"
2606 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
2607 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
2608 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2610 options_game_engine_type,
2611 &level.game_engine_type,
2612 NULL, "game engine:", NULL, "game engine"
2615 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
2616 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2617 GADGET_ID_LEVELSET_SAVE_MODE, GADGET_ID_NONE,
2619 options_levelset_save_mode,
2620 &levelset_save_mode,
2621 "Action:", NULL, NULL, "action when saving level set"
2624 // ---------- element settings: configure (several elements) ----------------
2627 ED_SELECTBOX_ID_WIND_DIRECTION,
2628 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2629 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2631 options_wind_direction,
2632 &level.wind_direction_initial,
2633 NULL, "initial wind direction:", NULL, "initial wind direction"
2636 ED_SELECTBOX_ID_PLAYER_SPEED,
2637 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2638 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2640 options_player_speed,
2641 &level.initial_player_stepsize[0],
2642 NULL, "initial player speed:", NULL, "initial player speed"
2645 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
2646 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2647 GADGET_ID_MM_BALL_CHOICE_MODE, GADGET_ID_NONE,
2649 options_group_choice_mode,
2650 &level.mm_ball_choice_mode,
2651 NULL, "choice type:", NULL, "type of content choice"
2654 // ---------- element settings: configure 1 (custom elements) ---------------
2657 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
2658 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2659 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2661 options_access_type,
2662 &custom_element.access_type,
2663 NULL, NULL, NULL, "type of access to this field"
2666 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
2667 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2668 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2670 options_access_layer,
2671 &custom_element.access_layer,
2672 NULL, NULL, NULL, "layer of access for this field"
2675 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
2676 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2677 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2679 options_access_protected,
2680 &custom_element.access_protected,
2681 NULL, NULL, NULL, "protected access for this field"
2684 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
2685 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2686 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2688 options_access_direction,
2689 &custom_element.access_direction,
2690 NULL, "from", NULL, "access direction for this field"
2693 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
2694 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2695 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2697 options_walk_to_action,
2698 &custom_element.walk_to_action,
2699 NULL, NULL, NULL, "diggable/collectible/pushable"
2702 // ---------- element settings: configure 2 (custom elements) ---------------
2705 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
2706 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2707 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2709 options_move_pattern,
2710 &custom_element.move_pattern,
2711 NULL, "can move", NULL, "element move pattern"
2714 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
2715 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2716 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2718 options_move_direction,
2719 &custom_element.move_direction_initial,
2720 NULL, "starts moving", NULL, "initial element move direction"
2723 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
2724 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2725 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2727 options_move_stepsize,
2728 &custom_element.move_stepsize,
2729 NULL, "move/fall speed", NULL, "speed of element movement"
2732 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
2733 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2734 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2736 options_move_leave_type,
2737 &custom_element.move_leave_type,
2738 // left text with leading spaces to place gadget next to "can dig" gadget
2739 // (needed because drawing area gadgets created after selectbox gadgets)
2740 // NULL, "can dig: can", ":", "leave behind or change element"
2741 NULL, " can", ":", "leave behind or change element"
2744 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
2745 -1, ED_ELEMENT_SETTINGS_YPOS(8),
2746 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2748 options_smash_targets,
2749 &custom_element.smash_targets,
2750 NULL, "can smash", NULL, "elements that can be smashed"
2753 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
2754 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2755 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2757 options_slippery_type,
2758 &custom_element.slippery_type,
2759 NULL, "slippery", NULL, "where other elements fall down"
2762 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
2763 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2764 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2767 &custom_element.deadliness,
2768 NULL, "deadly when", NULL, "deadliness of element"
2771 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
2772 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
2773 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2775 options_explosion_type,
2776 &custom_element.explosion_type,
2777 NULL, "can explode", NULL, "explosion type"
2780 // ---------- element settings: advanced (custom elements) ------------------
2783 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
2784 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2785 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2788 &custom_element_change.delay_frames,
2789 NULL, "delay time given in", NULL, "delay time units for change"
2792 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
2793 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2794 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2796 options_change_direct_action,
2797 &custom_element_change.direct_action,
2798 NULL, NULL, NULL, "type of direct action"
2801 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
2802 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2803 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2805 options_change_other_action,
2806 &custom_element_change.other_action,
2807 NULL, NULL, "element:", "type of other element action"
2810 ED_SELECTBOX_ID_CHANGE_SIDE,
2811 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2812 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2814 options_change_trigger_side,
2815 &custom_element_change.trigger_side,
2816 NULL, "at", "side", "element side triggering change"
2819 ED_SELECTBOX_ID_CHANGE_PLAYER,
2820 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2821 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2823 options_change_trigger_player,
2824 &custom_element_change.trigger_player,
2825 NULL, "player:", " ", "player that causes change"
2828 ED_SELECTBOX_ID_CHANGE_PAGE,
2829 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2830 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2832 options_change_trigger_page,
2833 &custom_element_change.trigger_page,
2834 NULL, "page:", NULL, "change page that causes change"
2837 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
2838 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2839 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2841 options_change_replace_when,
2842 &custom_element_change.replace_when,
2843 NULL, "replace when", NULL, "which elements can be replaced"
2846 ED_SELECTBOX_ID_ACTION_TYPE,
2847 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2848 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2850 options_action_type,
2851 &custom_element_change.action_type,
2852 NULL, NULL, NULL, "action on specified condition"
2855 ED_SELECTBOX_ID_ACTION_MODE,
2856 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2857 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2859 options_action_mode_none,
2860 &custom_element_change.action_mode,
2861 NULL, NULL, NULL, "action operator"
2864 ED_SELECTBOX_ID_ACTION_ARG,
2865 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2866 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2868 options_action_arg_none,
2869 &custom_element_change.action_arg,
2870 NULL, NULL, NULL, "action parameter"
2873 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
2874 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2875 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2877 options_change_page,
2878 &custom_element.current_change_page,
2879 NULL, NULL, NULL, "element change page"
2882 // ---------- element settings: configure (group elements) ------------------
2885 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
2886 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2887 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2889 options_group_choice_mode,
2890 &group_element_info.choice_mode,
2891 NULL, "choice type:", NULL, "type of group element choice"
2900 int gadget_id_align;
2903 char *text_above, *text_left, *text_right, *infotext;
2904 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2906 // ---------- level and editor settings (tabs) ------------------------------
2909 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL,
2910 ED_LEVEL_TABS_XPOS(0), ED_LEVEL_TABS_YPOS(0),
2911 GADGET_ID_LEVELCONFIG_LEVEL, GADGET_ID_NONE,
2913 NULL, NULL, NULL, "Configure level settings"
2916 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET,
2918 GADGET_ID_LEVELCONFIG_LEVELSET, GADGET_ID_LEVELCONFIG_LEVEL,
2920 NULL, NULL, NULL, "Update this or create new level set"
2923 ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR,
2925 GADGET_ID_LEVELCONFIG_EDITOR, GADGET_ID_LEVELCONFIG_LEVELSET,
2927 NULL, NULL, NULL, "Configure editor settings"
2930 ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE,
2932 GADGET_ID_LEVELCONFIG_ENGINE, GADGET_ID_LEVELCONFIG_EDITOR,
2934 NULL, NULL, NULL, "Configure engine settings"
2937 // ---------- element settings (tabs) ---------------------------------------
2940 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
2941 ED_ELEMENT_TABS_XPOS(0), ED_ELEMENT_TABS_YPOS(0),
2942 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
2944 NULL, NULL, NULL, "Show information about element"
2947 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
2949 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_PROPERTIES_INFO,
2951 NULL, NULL, NULL, "Configure element properties"
2954 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
2956 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_PROPERTIES_INFO,
2958 NULL, NULL, NULL, "Configure element properties, part 1"
2961 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
2963 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_PROPERTIES_CONFIG_1,
2965 NULL, NULL, NULL, "Configure element properties, part 2"
2968 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
2970 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_PROPERTIES_CONFIG_2,
2972 NULL, NULL, NULL, "Configure custom element change pages"
2975 // ---------- level and editor settings (buttons) ---------------------------
2978 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
2979 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2980 GADGET_ID_SAVE_LEVELSET, GADGET_ID_LEVELSET_SAVE_MODE,
2982 NULL, NULL, NULL, "Update or create level set"
2985 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
2986 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
2987 GADGET_ID_SAVE_AS_TEMPLATE_2, GADGET_ID_NONE,
2989 NULL, NULL, "this level as level template",
2990 "Save current settings as new template"
2993 // ---------- element settings (buttons) ------------------------------------
2996 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
2998 GADGET_ID_SAVE_AS_TEMPLATE_1, GADGET_ID_CUSTOM_USE_TEMPLATE_1,
3000 NULL, " ", "As Template",
3001 "Save current settings as new template"
3004 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
3006 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
3008 NULL, NULL, NULL, "Add new change page"
3011 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
3013 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
3015 NULL, NULL, NULL, "Delete current change page"
3025 int gadget_id_align;
3026 char *text_left, *text_right, *infotext;
3027 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
3030 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
3031 IMG_EDITOR_COUNTER_DOWN,
3032 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3033 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
3034 NULL, NULL, "select previous change page"
3037 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
3038 IMG_EDITOR_COUNTER_UP,
3039 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3040 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
3041 NULL, "change page", "select next change page"
3044 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
3045 IMG_GFX_EDITOR_BUTTON_CP_COPY,
3046 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3047 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
3048 " ", NULL, "copy settings from this change page"
3051 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
3052 IMG_GFX_EDITOR_BUTTON_CP_PASTE,
3053 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3054 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
3055 NULL, NULL, "paste settings to this change page"
3062 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
3070 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
3073 ED_SCROLLBUTTON_ID_AREA_UP,
3074 IMG_EDITOR_PLAYFIELD_SCROLL_UP,
3075 GADGET_ID_SCROLL_UP,
3076 "scroll level editing area up"
3079 ED_SCROLLBUTTON_ID_AREA_DOWN,
3080 IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
3081 GADGET_ID_SCROLL_DOWN,
3082 "scroll level editing area down"
3085 ED_SCROLLBUTTON_ID_AREA_LEFT,
3086 IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
3087 GADGET_ID_SCROLL_LEFT,
3088 "scroll level editing area left"
3091 ED_SCROLLBUTTON_ID_AREA_RIGHT,
3092 IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
3093 GADGET_ID_SCROLL_RIGHT,
3094 "scroll level editing area right"
3097 ED_SCROLLBUTTON_ID_LIST_UP,
3098 IMG_EDITOR_PALETTE_SCROLL_UP,
3099 GADGET_ID_SCROLL_LIST_UP,
3100 "scroll element list up ('Page Up')"
3103 ED_SCROLLBUTTON_ID_LIST_DOWN,
3104 IMG_EDITOR_PALETTE_SCROLL_DOWN,
3105 GADGET_ID_SCROLL_LIST_DOWN,
3106 "scroll element list down ('Page Down')"
3114 int wheel_x, wheel_y;
3115 int wheel_width, wheel_height;
3116 } scrollbar_pos[ED_NUM_SCROLLBARS];
3125 } scrollbar_info[ED_NUM_SCROLLBARS] =
3128 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
3129 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3130 GD_TYPE_SCROLLBAR_HORIZONTAL,
3131 GADGET_ID_SCROLL_HORIZONTAL,
3132 "scroll level editing area horizontally"
3135 ED_SCROLLBAR_ID_AREA_VERTICAL,
3136 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3137 GD_TYPE_SCROLLBAR_VERTICAL,
3138 GADGET_ID_SCROLL_VERTICAL,
3139 "scroll level editing area vertically"
3142 ED_SCROLLBAR_ID_LIST_VERTICAL,
3143 IMG_EDITOR_PALETTE_SCROLLBAR,
3144 GD_TYPE_SCROLLBAR_VERTICAL,
3145 GADGET_ID_SCROLL_LIST_VERTICAL,
3146 "scroll element list vertically"
3156 int gadget_id_align;
3157 int radio_button_nr;
3160 char *text_left, *text_right, *infotext;
3161 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
3164 ED_RADIOBUTTON_ID_PERCENTAGE,
3165 -1, ED_LEVEL_SETTINGS_YPOS(0),
3166 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
3167 RADIO_NR_RANDOM_ELEMENTS,
3168 &random_placement_method, RANDOM_USE_PERCENTAGE,
3169 " ", "percentage", "use percentage for random elements"
3172 ED_RADIOBUTTON_ID_QUANTITY,
3173 -1, ED_LEVEL_SETTINGS_YPOS(0),
3174 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
3175 RADIO_NR_RANDOM_ELEMENTS,
3176 &random_placement_method, RANDOM_USE_QUANTITY,
3177 " ", "quantity", "use quantity for random elements"
3186 int gadget_id_align;
3188 char *text_above, *text_left, *text_right, *infotext;
3189 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
3191 // ---------- level and editor settings -------------------------------------
3194 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
3195 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3196 GADGET_ID_AUTO_COUNT_GEMS, GADGET_ID_NONE,
3197 &level.auto_count_gems,
3199 "automatically count gems needed", "set counter to number of gems"
3202 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
3203 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
3204 GADGET_ID_RATE_TIME_OVER_SCORE, GADGET_ID_NONE,
3205 &level.rate_time_over_score,
3207 "rate time/steps used over score", "sort high scores by playing time/steps"
3210 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
3211 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
3212 GADGET_ID_USE_LEVELSET_ARTWORK, GADGET_ID_NONE,
3213 &levelset_use_levelset_artwork,
3215 "use current custom artwork", "use custom artwork of this level set"
3218 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
3219 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
3220 GADGET_ID_COPY_LEVEL_TEMPLATE, GADGET_ID_NONE,
3221 &levelset_copy_level_template,
3223 "copy current level template", "copy level template of this level set"
3226 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
3227 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
3228 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
3229 &random_placement_background_restricted,
3231 "restrict random placement to:", "set random placement restriction"
3234 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
3235 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
3236 GADGET_ID_CUSTOM_USE_TEMPLATE_3, GADGET_ID_NONE,
3237 &setup.editor.use_template_for_new_levels,
3238 "Template for new levels and CE/GE:", NULL,
3239 "use template for new levels", "use template for level properties"
3242 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
3243 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
3244 GADGET_ID_CUSTOM_USE_TEMPLATE_2, GADGET_ID_NONE,
3245 &level.use_custom_template,
3247 "use template for custom elements", "use template for custom properties"
3250 ED_CHECKBUTTON_ID_BD_INTERMISSION,
3251 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
3252 GADGET_ID_BD_INTERMISSION, GADGET_ID_NONE,
3253 &level.bd_intermission,
3254 "Boulder Dash game engine settings:", NULL,
3255 "intermission", "level is an intermission level"
3258 // ---------- element settings: configure (various elements) ----------------
3261 ED_CHECKBUTTON_ID_STICK_ELEMENT,
3262 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3263 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
3264 &stick_element_properties_window,
3266 "stick this screen to edit content","stick this screen to edit content"
3269 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
3270 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3271 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
3272 &level.em_slippery_gems,
3274 "slip down from certain flat walls","use EM/DC style slipping behaviour"
3277 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
3278 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3279 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
3280 &level.em_explodes_by_fire,
3282 "explodes with chain reaction", "use R'n'D style explosion behaviour"
3285 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
3286 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3287 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
3288 &level.use_spring_bug,
3290 "use spring pushing bug", "use odd spring pushing behaviour"
3293 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
3294 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3295 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
3296 &level.use_time_orb_bug,
3298 "use time orb bug", "use odd time orb behaviour"
3301 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
3302 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3303 GADGET_ID_USE_LIFE_BUGS, GADGET_ID_NONE,
3304 &level.use_life_bugs,
3306 "use buggy element behaviour", "use odd (historic) element behaviour"
3309 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
3310 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3311 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
3314 "create single random element", "only create one element from content"
3317 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
3318 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3319 GADGET_ID_INITIAL_BALL_ACTIVE, GADGET_ID_NONE,
3320 &level.ball_active_initial,
3322 "magic ball initially activated", "activate magic ball after level start"
3325 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
3326 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3327 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
3328 &level.grow_into_diggable,
3330 "can grow into anything diggable", "grow into more than just sand"
3333 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
3334 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3335 GADGET_ID_SB_FIELDS_NEEDED, GADGET_ID_NONE,
3336 &level.sb_fields_needed,
3338 "all fields need to be filled", "require all SB fields to be solved"
3341 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
3342 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3343 GADGET_ID_SB_OBJECTS_NEEDED, GADGET_ID_NONE,
3344 &level.sb_objects_needed,
3346 "all objects need to be placed", "require all SB objects to be solved"
3349 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
3350 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3351 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
3352 &level.auto_exit_sokoban,
3354 "exit level if all tasks solved", "automatically finish Sokoban levels"
3357 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
3358 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3359 GADGET_ID_SOLVED_BY_ONE_PLAYER, GADGET_ID_NONE,
3360 &level.solved_by_one_player,
3362 "only one player must enter exit", "level solved by first player in exit"
3365 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
3366 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3367 GADGET_ID_FINISH_DIG_COLLECT, GADGET_ID_NONE,
3368 &level.finish_dig_collect,
3370 "CE action on finished dig/collect", "only finished dig/collect triggers CE"
3373 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
3374 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3375 GADGET_ID_KEEP_WALKABLE_CE, GADGET_ID_NONE,
3376 &level.keep_walkable_ce,
3378 "keep walkable CE changed to player", "keep CE changing to player if walkable"
3381 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
3382 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3383 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
3384 &level.continuous_snapping,
3386 "continuous snapping", "use snapping without releasing key"
3389 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
3390 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3391 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
3392 &level.block_snap_field,
3394 "block snapped field when snapping", "use snapping delay to show animation"
3397 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
3398 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3399 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3400 &level.block_last_field,
3402 "block last field when moving", "player blocks last field when moving"
3405 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
3406 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3407 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3408 &level.sp_block_last_field,
3410 "block last field when moving", "player blocks last field when moving"
3413 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
3414 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3415 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
3416 &level.instant_relocation,
3418 "no scrolling when relocating", "player gets relocated without delay"
3421 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
3422 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3423 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
3424 &level.shifted_relocation,
3426 "no centering when relocating", "level not centered after relocation"
3429 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
3430 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3431 GADGET_ID_LAZY_RELOCATION, GADGET_ID_NONE,
3432 &level.lazy_relocation,
3434 "only redraw off-screen relocation","no redraw if relocation target visible"
3437 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
3438 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3439 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
3440 &level.use_start_element[0],
3442 "use level start element:", "start level at this element's position"
3445 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
3446 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3447 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
3448 &level.use_artwork_element[0],
3450 "use artwork from element:", "use player artwork from other element"
3453 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
3454 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
3455 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
3456 &level.use_explosion_element[0],
3458 "use explosion from element:", "use explosion properties from element"
3461 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
3462 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3463 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
3464 &level.initial_player_gravity[0],
3466 "use initial gravity", "set initial player gravity"
3469 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
3470 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3471 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
3472 &level.use_initial_inventory[0],
3474 "use initial inventory:", "use collected elements on level start"
3477 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
3478 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3479 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
3480 &level.can_pass_to_walkable,
3482 "can pass to walkable element", "player can pass to empty or walkable"
3485 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
3486 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3487 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
3488 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3490 "can fall into acid (with gravity)","player can fall into acid pool"
3493 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
3494 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3495 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
3496 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3498 "can move into acid", "element can move into acid pool"
3501 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
3502 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3503 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
3504 &custom_element_properties[EP_DONT_COLLIDE_WITH],
3506 "deadly when colliding with", "element is deadly when hitting player"
3509 ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS,
3510 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3511 GADGET_ID_BD_DIAGONAL_MOVEMENTS, GADGET_ID_NONE,
3512 &level.bd_diagonal_movements,
3514 "can move diagonally", "player can move diagonally"
3517 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
3518 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3519 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
3520 &level.envelope[0].autowrap,
3522 "auto-wrap", "automatically wrap envelope text"
3525 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
3526 -1, ED_ELEMENT_SETTINGS_YPOS(1),
3527 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
3528 &level.envelope[0].centered,
3530 "centered", "automatically center envelope text"
3533 ED_CHECKBUTTON_ID_MM_LASER_RED,
3534 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3535 GADGET_ID_MM_LASER_RED, GADGET_ID_NONE,
3536 &level.mm_laser_red,
3537 "choose color components for laser:", NULL,
3538 "red", "use red color components in laser"
3541 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
3542 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3543 GADGET_ID_MM_LASER_GREEN, GADGET_ID_NONE,
3544 &level.mm_laser_green,
3546 "green", "use green color components in laser"
3549 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
3550 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3551 GADGET_ID_MM_LASER_BLUE, GADGET_ID_NONE,
3552 &level.mm_laser_blue,
3554 "blue", "use blue color components in laser"
3557 ED_CHECKBUTTON_ID_DF_LASER_RED,
3558 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3559 GADGET_ID_DF_LASER_RED, GADGET_ID_NONE,
3560 &level.df_laser_red,
3561 "choose color components for laser:", NULL,
3562 "red", "use red color components in laser"
3565 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
3566 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3567 GADGET_ID_DF_LASER_GREEN, GADGET_ID_NONE,
3568 &level.df_laser_green,
3570 "green", "use green color components in laser"
3573 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
3574 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3575 GADGET_ID_DF_LASER_BLUE, GADGET_ID_NONE,
3576 &level.df_laser_blue,
3578 "blue", "use blue color components in laser"
3581 ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT,
3582 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3583 GADGET_ID_ROTATE_MM_BALL_CONTENT, GADGET_ID_NONE,
3584 &level.rotate_mm_ball_content,
3586 "randomly rotate created content", "randomly rotate newly created content"
3589 ED_CHECKBUTTON_ID_EXPLODE_MM_BALL,
3590 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3591 GADGET_ID_EXPLODE_MM_BALL, GADGET_ID_NONE,
3592 &level.explode_mm_ball,
3594 "explode ball instead of melting", "use explosion to release ball content"
3597 // ---------- element settings: configure 1 (custom elements) ---------------
3600 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
3601 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3602 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
3603 &custom_element.use_gfx_element,
3605 "use graphic of element:", "use existing element graphic"
3608 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
3609 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3610 GADGET_ID_CUSTOM_USE_TEMPLATE_1, GADGET_ID_NONE,
3611 &level.use_custom_template,
3613 "use template", "use template for custom properties"
3616 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
3617 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3618 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
3619 &custom_element_properties[EP_ACCESSIBLE],
3621 NULL, "player can walk to or pass this field"
3624 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
3625 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3626 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
3627 &custom_element_properties[EP_GRAVITY_REACHABLE],
3629 "reachable despite gravity", "player can walk/dig despite gravity"
3632 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
3633 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3634 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
3635 &custom_element.use_last_ce_value,
3637 "use last CE value after change", "use last CE value after change"
3640 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
3641 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3642 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
3643 &custom_element_properties[EP_WALK_TO_OBJECT],
3645 NULL, "player can dig/collect/push element"
3648 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
3649 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3650 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
3651 &custom_element_properties[EP_INDESTRUCTIBLE],
3653 "indestructible", "element is indestructible"
3656 // ---------- element settings: configure 2 (custom elements) ---------------
3659 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
3660 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3661 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
3662 &custom_element_properties[EP_CAN_MOVE],
3664 NULL, "element can move with some pattern"
3667 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
3668 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3669 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
3670 &custom_element_properties[EP_CAN_FALL],
3672 "can fall", "element can fall down"
3675 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
3676 -1, ED_ELEMENT_SETTINGS_YPOS(8),
3677 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
3678 &custom_element_properties[EP_CAN_SMASH],
3680 NULL, "element can smash other elements"
3683 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
3684 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3685 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
3686 &custom_element_properties[EP_SLIPPERY],
3688 NULL, "other elements can fall down from it"
3691 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
3692 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3693 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
3694 &custom_element_properties[EP_DEADLY],
3696 NULL, "element can kill the player"
3699 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
3700 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3701 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
3702 &custom_element_properties[EP_CAN_EXPLODE],
3704 NULL, "element can explode"
3707 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
3708 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
3709 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
3710 &custom_element_properties[EP_EXPLODES_BY_FIRE],
3712 "by fire", "element can explode by fire/explosion"
3715 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
3716 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3717 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
3718 &custom_element_properties[EP_EXPLODES_SMASHED],
3720 "smashed", "element can explode when smashed"
3723 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
3724 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3725 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
3726 &custom_element_properties[EP_EXPLODES_IMPACT],
3728 "impact", "element can explode on impact"
3731 // ---------- element settings: advanced (custom elements) ------------------
3734 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
3735 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3736 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
3737 &custom_element_change.can_change,
3739 "element changes to:", "change element on specified condition"
3742 ED_CHECKBUTTON_ID_CHANGE_DELAY,
3743 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
3744 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
3745 &custom_element_change_events[CE_DELAY],
3747 NULL, "element changes after delay"
3750 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
3751 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
3752 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
3753 &custom_element_change_events[CE_BY_DIRECT_ACTION],
3755 NULL, "element changes by direct action"
3758 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
3759 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
3760 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
3761 &custom_element_change_events[CE_BY_OTHER_ACTION],
3763 NULL, "element changes by other element"
3766 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
3767 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
3768 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
3769 &custom_element_change.explode,
3771 "explode instead of change", "element explodes instead of change"
3774 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
3775 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
3776 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
3777 &custom_element_change.use_target_content,
3779 "use extended change target:", "element changes to more elements"
3782 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
3783 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3784 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3785 &custom_element_change.only_if_complete,
3787 "replace all or nothing", "only replace when all can be changed"
3790 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
3791 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3792 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3793 &custom_element_change.use_random_replace,
3795 NULL, "use percentage for random replace"
3798 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
3799 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3800 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3801 &custom_element_change.has_action,
3803 NULL, "execute action on specified condition"
3811 int xoffset, yoffset;
3813 int gadget_id_align;
3815 int area_xsize, area_ysize;
3816 char *text_left, *text_right, *text_above, *text_below, *infotext;
3817 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3819 // ---------- level playfield content ---------------------------------------
3822 ED_DRAWING_ID_DRAWING_LEVEL,
3825 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
3827 -1, -1, // these values are not constant, but can change at runtime
3828 NULL, NULL, NULL, NULL, NULL
3831 // ---------- yam yam content -----------------------------------------------
3834 ED_DRAWING_ID_YAMYAM_CONTENT_0,
3835 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3836 ED_AREA_YAMYAM_CONTENT_XOFF(0), ED_AREA_YAMYAM_CONTENT_YOFF(0),
3837 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
3838 &level.yamyam_content[0].e[0][0], 3, 3,
3839 NULL, NULL, NULL, "1", NULL
3842 ED_DRAWING_ID_YAMYAM_CONTENT_1,
3843 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3844 ED_AREA_YAMYAM_CONTENT_XOFF(1), ED_AREA_YAMYAM_CONTENT_YOFF(1),
3845 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
3846 &level.yamyam_content[1].e[0][0], 3, 3,
3847 NULL, NULL, NULL, "2", NULL
3850 ED_DRAWING_ID_YAMYAM_CONTENT_2,
3851 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3852 ED_AREA_YAMYAM_CONTENT_XOFF(2), ED_AREA_YAMYAM_CONTENT_YOFF(2),
3853 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
3854 &level.yamyam_content[2].e[0][0], 3, 3,
3855 NULL, NULL, NULL, "3", NULL
3858 ED_DRAWING_ID_YAMYAM_CONTENT_3,
3859 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3860 ED_AREA_YAMYAM_CONTENT_XOFF(3), ED_AREA_YAMYAM_CONTENT_YOFF(3),
3861 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
3862 &level.yamyam_content[3].e[0][0], 3, 3,
3863 NULL, NULL, NULL, "4", NULL
3866 ED_DRAWING_ID_YAMYAM_CONTENT_4,
3867 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3868 ED_AREA_YAMYAM_CONTENT_XOFF(4), ED_AREA_YAMYAM_CONTENT_YOFF(4),
3869 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
3870 &level.yamyam_content[4].e[0][0], 3, 3,
3871 NULL, NULL, NULL, "5", NULL
3874 ED_DRAWING_ID_YAMYAM_CONTENT_5,
3875 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3876 ED_AREA_YAMYAM_CONTENT_XOFF(5), ED_AREA_YAMYAM_CONTENT_YOFF(5),
3877 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
3878 &level.yamyam_content[5].e[0][0], 3, 3,
3879 NULL, NULL, NULL, "6", NULL
3882 ED_DRAWING_ID_YAMYAM_CONTENT_6,
3883 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3884 ED_AREA_YAMYAM_CONTENT_XOFF(6), ED_AREA_YAMYAM_CONTENT_YOFF(6),
3885 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
3886 &level.yamyam_content[6].e[0][0], 3, 3,
3887 NULL, NULL, NULL, "7", NULL
3890 ED_DRAWING_ID_YAMYAM_CONTENT_7,
3891 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3892 ED_AREA_YAMYAM_CONTENT_XOFF(7), ED_AREA_YAMYAM_CONTENT_YOFF(7),
3893 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
3894 &level.yamyam_content[7].e[0][0], 3, 3,
3895 NULL, NULL, NULL, "8", NULL
3898 // ---------- magic ball content --------------------------------------------
3901 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
3902 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3903 ED_AREA_MAGIC_BALL_CONTENT_XOFF(0), ED_AREA_MAGIC_BALL_CONTENT_YOFF(0),
3904 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
3905 &level.ball_content[0].e[0][0], 3, 3,
3906 NULL, NULL, NULL, "1", NULL
3909 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
3910 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3911 ED_AREA_MAGIC_BALL_CONTENT_XOFF(1), ED_AREA_MAGIC_BALL_CONTENT_YOFF(1),
3912 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
3913 &level.ball_content[1].e[0][0], 3, 3,
3914 NULL, NULL, NULL, "2", NULL
3917 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
3918 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3919 ED_AREA_MAGIC_BALL_CONTENT_XOFF(2), ED_AREA_MAGIC_BALL_CONTENT_YOFF(2),
3920 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
3921 &level.ball_content[2].e[0][0], 3, 3,
3922 NULL, NULL, NULL, "3", NULL
3925 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
3926 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3927 ED_AREA_MAGIC_BALL_CONTENT_XOFF(3), ED_AREA_MAGIC_BALL_CONTENT_YOFF(3),
3928 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
3929 &level.ball_content[3].e[0][0], 3, 3,
3930 NULL, NULL, NULL, "4", NULL
3933 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
3934 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3935 ED_AREA_MAGIC_BALL_CONTENT_XOFF(4), ED_AREA_MAGIC_BALL_CONTENT_YOFF(4),
3936 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
3937 &level.ball_content[4].e[0][0], 3, 3,
3938 NULL, NULL, NULL, "5", NULL
3941 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
3942 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3943 ED_AREA_MAGIC_BALL_CONTENT_XOFF(5), ED_AREA_MAGIC_BALL_CONTENT_YOFF(5),
3944 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
3945 &level.ball_content[5].e[0][0], 3, 3,
3946 NULL, NULL, NULL, "6", NULL
3949 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
3950 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3951 ED_AREA_MAGIC_BALL_CONTENT_XOFF(6), ED_AREA_MAGIC_BALL_CONTENT_YOFF(6),
3952 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
3953 &level.ball_content[6].e[0][0], 3, 3,
3954 NULL, NULL, NULL, "7", NULL
3957 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
3958 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3959 ED_AREA_MAGIC_BALL_CONTENT_XOFF(7), ED_AREA_MAGIC_BALL_CONTENT_YOFF(7),
3960 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
3961 &level.ball_content[7].e[0][0], 3, 3,
3962 NULL, NULL, NULL, "8", NULL
3965 // ---------- android content -----------------------------------------------
3968 ED_DRAWING_ID_ANDROID_CONTENT,
3969 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(6),
3970 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3971 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
3972 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
3973 NULL, NULL, "elements:", NULL, "elements android can clone"
3976 // ---------- amoeba content ------------------------------------------------
3979 ED_DRAWING_ID_AMOEBA_CONTENT,
3980 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
3981 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3982 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
3983 &level.amoeba_content, 1, 1,
3984 "content:", NULL, NULL, NULL, "amoeba content"
3987 // ---------- level start element -------------------------------------------
3990 ED_DRAWING_ID_START_ELEMENT,
3991 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
3992 0, ED_AREA_1X1_SETTINGS_YOFF,
3993 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
3994 &level.start_element[0], 1, 1,
3995 NULL, NULL, NULL, NULL, "level start element"
3998 // ---------- player artwork element ----------------------------------------
4001 ED_DRAWING_ID_ARTWORK_ELEMENT,
4002 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
4003 0, ED_AREA_1X1_SETTINGS_YOFF,
4004 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
4005 &level.artwork_element[0], 1, 1,
4006 NULL, NULL, NULL, NULL, "element for player artwork"
4009 // ---------- player explosion element --------------------------------------
4012 ED_DRAWING_ID_EXPLOSION_ELEMENT,
4013 -1, ED_AREA_1X1_SETTINGS_YPOS(12),
4014 0, ED_AREA_1X1_SETTINGS_YOFF,
4015 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
4016 &level.explosion_element[0], 1, 1,
4017 NULL, NULL, NULL, NULL, "element for player explosion"
4020 // ---------- player initial inventory --------------------------------------
4023 ED_DRAWING_ID_INVENTORY_CONTENT,
4024 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4025 0, ED_AREA_1X1_SETTINGS_YOFF,
4026 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
4027 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
4028 NULL, NULL, NULL, NULL, "content for initial inventory"
4031 // ---------- gray ball content -----------------------------------------
4034 ED_DRAWING_ID_MM_BALL_CONTENT,
4035 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
4036 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4037 GADGET_ID_MM_BALL_CONTENT, GADGET_ID_NONE,
4038 &level.mm_ball_content[0], MAX_MM_BALL_CONTENTS, 1,
4039 "content:", NULL, NULL, NULL, "content for gray ball"
4042 // ---------- element settings: configure 1 (custom elements) ---------------
4044 // ---------- custom graphic ------------------------------------------------
4047 ED_DRAWING_ID_CUSTOM_GRAPHIC,
4048 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4049 0, ED_AREA_1X1_SETTINGS_YOFF,
4050 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
4051 &custom_element.gfx_element_initial, 1, 1,
4052 NULL, NULL, NULL, NULL, "custom graphic element"
4055 // ---------- element settings: configure 2 (custom elements) ---------------
4057 // ---------- custom content (when exploding) -------------------------------
4060 ED_DRAWING_ID_CUSTOM_CONTENT,
4061 -1, ED_AREA_3X3_SETTINGS_YPOS(11),
4062 0, ED_AREA_3X3_SETTINGS_YOFF,
4063 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, // align three rows
4064 &custom_element.content.e[0][0], 3, 3,
4065 "content:", NULL, NULL, NULL, NULL
4068 // ---------- custom enter and leave element (when moving) ------------------
4071 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
4072 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
4073 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4074 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
4075 &custom_element.move_enter_element, 1, 1,
4076 "can dig:", " ", NULL, NULL, "element that can be digged/collected"
4079 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
4080 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
4081 0, ED_AREA_1X1_SETTINGS_YOFF,
4082 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
4083 &custom_element.move_leave_element, 1, 1,
4084 NULL, NULL, NULL, NULL, "element that will be left behind"
4087 // ---------- element settings: advanced (custom elements) ------------------
4089 // ---------- custom change target ------------------------------------------
4092 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
4093 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4094 0, ED_AREA_1X1_SETTINGS_YOFF,
4095 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
4096 &custom_element_change.target_element, 1, 1,
4097 NULL, "after/when:", NULL, NULL, "new target element after change"
4100 // ---------- custom change content (extended change target) ----------------
4103 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
4104 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
4105 0, ED_AREA_3X3_SETTINGS_YOFF,
4106 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, // align three rows
4107 &custom_element_change.target_content.e[0][0], 3, 3,
4108 NULL, NULL, NULL, NULL, "new extended elements after change"
4111 // ---------- custom change trigger (element causing change) ----------------
4114 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
4115 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
4116 0, ED_AREA_1X1_SETTINGS_YOFF,
4117 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
4118 &custom_element_change.initial_trigger_element, 1, 1,
4119 NULL, NULL, NULL, NULL, "other element triggering change"
4122 // ---------- custom change action (element used for action) ----------------
4125 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
4126 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
4127 0, ED_AREA_1X1_SETTINGS_YOFF,
4128 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
4129 &custom_element_change.action_element, 1, 1,
4130 NULL, NULL, NULL, NULL, "element used as action parameter"
4133 // ---------- group element content -----------------------------------------
4136 ED_DRAWING_ID_GROUP_CONTENT,
4137 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
4138 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4139 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
4140 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
4141 "content:", NULL, NULL, NULL, NULL
4144 // ---------- random background (for random painting) -----------------------
4147 ED_DRAWING_ID_RANDOM_BACKGROUND,
4148 -1, ED_AREA_1X1_LSETTINGS_YPOS(1),
4149 0, ED_AREA_1X1_LSETTINGS_YOFF,
4150 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
4151 &random_placement_background_element, 1, 1,
4152 NULL, NULL, NULL, NULL, "random placement background"
4157 // ----------------------------------------------------------------------------
4158 // some internally used variables
4159 // ----------------------------------------------------------------------------
4161 // maximal size of level editor drawing area
4162 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
4164 // actual size of level editor drawing area
4165 static int ed_fieldx, ed_fieldy;
4167 // actual position of level editor drawing area in level playfield
4168 static int level_xpos = -1, level_ypos = -1;
4170 // actual tile size used to display playfield drawing area
4171 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
4172 static int ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
4174 #define IN_ED_FIELD(x, y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
4176 // drawing elements on the three mouse buttons
4177 static int new_element1 = EL_WALL;
4178 static int new_element2 = EL_EMPTY;
4179 static int new_element3 = EL_SAND;
4181 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
4182 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
4183 (button) == 2 ? new_element2 : \
4184 (button) == 3 ? new_element3 : EL_EMPTY)
4186 #define BUTTON_TILE_SIZE(x) ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE)
4188 static int use_permanent_palette = TRUE;
4190 #define PX (use_permanent_palette ? DX : SX)
4191 #define PY (use_permanent_palette ? DY : SY)
4192 #define PXSIZE (use_permanent_palette ? DXSIZE : SXSIZE)
4193 #define PYSIZE (use_permanent_palette ? DYSIZE : SYSIZE)
4195 // forward declaration for internal use
4196 static void CopyBrushToCursor(int, int);
4197 static void DeleteBrushFromCursor(void);
4198 static void ModifyEditorCounterValue(int, int);
4199 static void ModifyEditorCounterLimits(int, int, int);
4200 static void ModifyEditorSelectboxValue(int, int);
4201 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
4202 static void ModifyEditorDrawingArea(int, int, int);
4203 static void ModifyEditorElementList(void);
4204 static void AdjustElementListScrollbar(void);
4205 static void RedrawDrawingElements(void);
4206 static void DrawDrawingWindowExt(boolean);
4207 static void DrawDrawingWindow(void);
4208 static void DrawLevelConfigWindow(void);
4209 static void DrawPropertiesWindow(void);
4210 static void DrawPaletteWindow(void);
4211 static void UpdateCustomElementGraphicGadgets(void);
4212 static boolean checkPropertiesConfig(int);
4213 static void SetAutomaticNumberOfGemsNeeded(void);
4214 static void ClearEditorGadgetInfoText(void);
4215 static void CopyLevelToUndoBuffer(int);
4216 static void HandleDrawingAreas(struct GadgetInfo *);
4217 static void HandleCounterButtons(struct GadgetInfo *);
4218 static void HandleTextInputGadgets(struct GadgetInfo *);
4219 static void HandleTextAreaGadgets(struct GadgetInfo *);
4220 static void HandleSelectboxGadgets(struct GadgetInfo *);
4221 static void HandleTextbuttonGadgets(struct GadgetInfo *);
4222 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
4223 static void HandleRadiobuttons(struct GadgetInfo *);
4224 static void HandleCheckbuttons(struct GadgetInfo *);
4225 static void HandleControlButtons(struct GadgetInfo *);
4226 static void HandleDrawingAreaInfo(struct GadgetInfo *);
4227 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
4228 static boolean AskToCopyAndModifyLevelTemplate(void);
4229 static boolean getDrawModeHiRes(void);
4230 static int getTabulatorBarWidth(void);
4231 static int getTabulatorBarHeight(void);
4232 static Pixel getTabulatorBarColor(void);
4233 static int numHiresTiles(int);
4235 static int num_editor_gadgets = 0; // dynamically determined
4237 static struct GadgetInfo **level_editor_gadget = NULL;
4238 static int *right_gadget_border = NULL;
4240 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
4241 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
4242 static boolean draw_with_brush = FALSE;
4243 static int properties_element = 0;
4245 static short TileBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4246 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4247 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4248 static int undo_buffer_position = 0;
4249 static int undo_buffer_steps = 0;
4250 static int redo_buffer_steps = 0;
4252 static int edit_mode;
4253 static int edit_mode_levelconfig;
4254 static int edit_mode_properties;
4256 static int element_shift = 0;
4258 static int editor_el_players[] =
4265 static int *editor_el_players_ptr = editor_el_players;
4266 static int num_editor_el_players = ARRAY_SIZE(editor_el_players);
4268 static int editor_hl_boulderdash[] =
4270 EL_INTERNAL_CASCADE_BD_ACTIVE,
4276 static int editor_el_boulderdash[] =
4285 EL_BD_EXPANDABLE_WALL,
4293 EL_BD_BUTTERFLY_LEFT,
4295 EL_BD_BUTTERFLY_RIGHT,
4296 EL_BD_FIREFLY_RIGHT,
4299 EL_BD_BUTTERFLY_DOWN,
4303 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
4304 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
4305 static int num_editor_hl_boulderdash = ARRAY_SIZE(editor_hl_boulderdash);
4306 static int num_editor_el_boulderdash = ARRAY_SIZE(editor_el_boulderdash);
4308 static int editor_hl_boulderdash_native[] =
4310 EL_INTERNAL_CASCADE_BD_NATIVE_ACTIVE,
4316 static int editor_el_boulderdash_native[] =
4333 EL_BD_BUTTERFLY_LEFT,
4335 EL_BD_BUTTERFLY_RIGHT,
4336 EL_BD_FIREFLY_RIGHT,
4339 EL_BD_BUTTERFLY_DOWN,
4344 EL_BD_BUTTERFLY_2_UP,
4348 EL_BD_BUTTERFLY_2_LEFT,
4349 EL_BD_FIREFLY_2_LEFT,
4350 EL_BD_BUTTERFLY_2_RIGHT,
4351 EL_BD_FIREFLY_2_RIGHT,
4354 EL_BD_BUTTERFLY_2_DOWN,
4355 EL_BD_FIREFLY_2_DOWN,
4363 EL_BD_DRAGONFLY_LEFT,
4364 EL_BD_STONEFLY_LEFT,
4365 EL_BD_DRAGONFLY_RIGHT,
4366 EL_BD_STONEFLY_RIGHT,
4369 EL_BD_DRAGONFLY_DOWN,
4370 EL_BD_STONEFLY_DOWN,
4393 EL_BD_SAND_SLOPED_UP_LEFT,
4394 EL_BD_SAND_SLOPED_UP_RIGHT,
4395 EL_BD_WALL_SLOPED_UP_LEFT,
4396 EL_BD_WALL_SLOPED_UP_RIGHT,
4398 EL_BD_SAND_SLOPED_DOWN_LEFT,
4399 EL_BD_SAND_SLOPED_DOWN_RIGHT,
4400 EL_BD_WALL_SLOPED_DOWN_LEFT,
4401 EL_BD_WALL_SLOPED_DOWN_RIGHT,
4403 EL_BD_FLYING_DIAMOND,
4405 EL_BD_STEELWALL_SLOPED_UP_LEFT,
4406 EL_BD_STEELWALL_SLOPED_UP_RIGHT,
4410 EL_BD_STEELWALL_SLOPED_DOWN_LEFT,
4411 EL_BD_STEELWALL_SLOPED_DOWN_RIGHT,
4414 EL_BD_WALL_NON_SLOPED,
4420 EL_BD_INVISIBLE_EXIT_CLOSED,
4421 EL_BD_INVISIBLE_EXIT_OPEN,
4424 EL_BD_STEELWALL_EXPLODABLE,
4425 EL_BD_STEELWALL_DIGGABLE,
4426 EL_BD_WALL_DIGGABLE,
4428 EL_BD_EXPANDABLE_WALL_HORIZONTAL,
4429 EL_BD_EXPANDABLE_WALL_VERTICAL,
4430 EL_BD_EXPANDABLE_WALL_ANY,
4431 EL_BD_CREATURE_SWITCH,
4433 EL_BD_EXPANDABLE_STEELWALL_HORIZONTAL,
4434 EL_BD_EXPANDABLE_STEELWALL_VERTICAL,
4435 EL_BD_EXPANDABLE_STEELWALL_ANY,
4436 EL_BD_EXPANDABLE_WALL_SWITCH_HORIZONTAL,
4438 EL_BD_BITER_SWITCH_1,
4439 EL_BD_REPLICATOR_SWITCH,
4440 EL_BD_CONVEYOR_SWITCH,
4441 EL_BD_CONVEYOR_DIR_SWITCH_RIGHT,
4450 EL_BD_DIAMOND_GLUED,
4453 EL_BD_TRAPPED_DIAMOND,
4473 EL_BD_GRAVITY_SWITCH,
4474 EL_BD_PNEUMATIC_HAMMER,
4481 EL_BD_BLADDER_SPENDER,
4483 EL_BD_CONVEYOR_LEFT,
4484 EL_BD_CONVEYOR_RIGHT,
4499 EL_BD_PLAYER_WITH_BOMB,
4501 EL_BD_PLAYER_STIRRING,
4503 static int *editor_hl_boulderdash_native_ptr = editor_hl_boulderdash_native;
4504 static int *editor_el_boulderdash_native_ptr = editor_el_boulderdash_native;
4505 static int num_editor_hl_boulderdash_native = ARRAY_SIZE(editor_hl_boulderdash_native);
4506 static int num_editor_el_boulderdash_native = ARRAY_SIZE(editor_el_boulderdash_native);
4508 static int editor_hl_emerald_mine[] =
4510 EL_INTERNAL_CASCADE_EM_ACTIVE,
4516 static int editor_el_emerald_mine[] =
4534 EL_EM_DYNAMITE_ACTIVE,
4553 EL_ACID_POOL_TOPLEFT,
4555 EL_ACID_POOL_TOPRIGHT,
4558 EL_ACID_POOL_BOTTOMLEFT,
4559 EL_ACID_POOL_BOTTOM,
4560 EL_ACID_POOL_BOTTOMRIGHT,
4578 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
4579 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
4580 static int num_editor_hl_emerald_mine = ARRAY_SIZE(editor_hl_emerald_mine);
4581 static int num_editor_el_emerald_mine = ARRAY_SIZE(editor_el_emerald_mine);
4583 static int editor_hl_emerald_mine_club[] =
4585 EL_INTERNAL_CASCADE_EMC_ACTIVE,
4591 static int editor_el_emerald_mine_club[] =
4618 EL_EMC_WALL_SLIPPERY_1,
4619 EL_EMC_WALL_SLIPPERY_2,
4620 EL_EMC_WALL_SLIPPERY_3,
4621 EL_EMC_WALL_SLIPPERY_4,
4644 EL_EMC_MAGIC_BALL_SWITCH,
4651 EL_EMC_SPRING_BUMPER,
4655 EL_BALLOON_SWITCH_UP,
4656 EL_BALLOON_SWITCH_ANY,
4659 EL_BALLOON_SWITCH_LEFT,
4661 EL_BALLOON_SWITCH_RIGHT,
4665 EL_BALLOON_SWITCH_DOWN,
4666 EL_BALLOON_SWITCH_NONE,
4668 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
4669 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
4670 static int num_editor_hl_emerald_mine_club = ARRAY_SIZE(editor_hl_emerald_mine_club);
4671 static int num_editor_el_emerald_mine_club = ARRAY_SIZE(editor_el_emerald_mine_club);
4673 static int editor_hl_rnd[] =
4675 EL_INTERNAL_CASCADE_RND_ACTIVE,
4681 static int editor_el_rnd[] =
4684 EL_DYNAMITE_ACTIVE, // RND
4718 EL_WALL_EMERALD_YELLOW,
4719 EL_WALL_EMERALD_RED,
4720 EL_WALL_EMERALD_PURPLE,
4738 EL_DYNABOMB_INCREASE_NUMBER,
4739 EL_DYNABOMB_INCREASE_SIZE,
4740 EL_DYNABOMB_INCREASE_POWER,
4760 EL_INVISIBLE_STEELWALL,
4764 EL_EXPANDABLE_WALL_HORIZONTAL,
4765 EL_EXPANDABLE_WALL_VERTICAL,
4766 EL_EXPANDABLE_WALL_ANY,
4768 static int *editor_hl_rnd_ptr = editor_hl_rnd;
4769 static int *editor_el_rnd_ptr = editor_el_rnd;
4770 static int num_editor_hl_rnd = ARRAY_SIZE(editor_hl_rnd);
4771 static int num_editor_el_rnd = ARRAY_SIZE(editor_el_rnd);
4773 static int editor_hl_sokoban[] =
4775 EL_INTERNAL_CASCADE_SB_ACTIVE,
4781 static int editor_el_sokoban[] =
4784 EL_SOKOBAN_FIELD_EMPTY,
4785 EL_SOKOBAN_FIELD_FULL,
4786 EL_SOKOBAN_FIELD_PLAYER,
4788 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
4789 static int *editor_el_sokoban_ptr = editor_el_sokoban;
4790 static int num_editor_hl_sokoban = ARRAY_SIZE(editor_hl_sokoban);
4791 static int num_editor_el_sokoban = ARRAY_SIZE(editor_el_sokoban);
4793 static int editor_hl_supaplex[] =
4795 EL_INTERNAL_CASCADE_SP_ACTIVE,
4801 static int editor_el_supaplex[] =
4819 EL_SP_PORT_HORIZONTAL,
4820 EL_SP_PORT_VERTICAL,
4828 EL_SP_GRAVITY_PORT_LEFT,
4829 EL_SP_GRAVITY_PORT_RIGHT,
4830 EL_SP_GRAVITY_PORT_UP,
4831 EL_SP_GRAVITY_PORT_DOWN,
4833 EL_SP_GRAVITY_ON_PORT_LEFT,
4834 EL_SP_GRAVITY_ON_PORT_RIGHT,
4835 EL_SP_GRAVITY_ON_PORT_UP,
4836 EL_SP_GRAVITY_ON_PORT_DOWN,
4838 EL_SP_GRAVITY_OFF_PORT_LEFT,
4839 EL_SP_GRAVITY_OFF_PORT_RIGHT,
4840 EL_SP_GRAVITY_OFF_PORT_UP,
4841 EL_SP_GRAVITY_OFF_PORT_DOWN,
4843 EL_SP_HARDWARE_GRAY,
4844 EL_SP_HARDWARE_GREEN,
4845 EL_SP_HARDWARE_BLUE,
4848 EL_SP_HARDWARE_BASE_1,
4849 EL_SP_HARDWARE_BASE_2,
4850 EL_SP_HARDWARE_BASE_3,
4851 EL_SP_HARDWARE_BASE_4,
4853 EL_SP_HARDWARE_BASE_5,
4854 EL_SP_HARDWARE_BASE_6,
4855 EL_SP_HARDWARE_YELLOW,
4863 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
4864 static int *editor_el_supaplex_ptr = editor_el_supaplex;
4865 static int num_editor_hl_supaplex = ARRAY_SIZE(editor_hl_supaplex);
4866 static int num_editor_el_supaplex = ARRAY_SIZE(editor_el_supaplex);
4868 static int editor_hl_diamond_caves[] =
4870 EL_INTERNAL_CASCADE_DC_ACTIVE,
4876 static int editor_el_diamond_caves[] =
4878 EL_EM_STEEL_EXIT_CLOSED, // DC2
4879 EL_EM_STEEL_EXIT_OPEN, // DC2
4880 EL_WALL_EMERALD, // DC2
4881 EL_WALL_DIAMOND, // DC2
4888 EL_CONVEYOR_BELT_1_LEFT,
4889 EL_CONVEYOR_BELT_1_MIDDLE,
4890 EL_CONVEYOR_BELT_1_RIGHT,
4891 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
4893 EL_CONVEYOR_BELT_2_LEFT,
4894 EL_CONVEYOR_BELT_2_MIDDLE,
4895 EL_CONVEYOR_BELT_2_RIGHT,
4896 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
4898 EL_CONVEYOR_BELT_3_LEFT,
4899 EL_CONVEYOR_BELT_3_MIDDLE,
4900 EL_CONVEYOR_BELT_3_RIGHT,
4901 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
4903 EL_CONVEYOR_BELT_4_LEFT,
4904 EL_CONVEYOR_BELT_4_MIDDLE,
4905 EL_CONVEYOR_BELT_4_RIGHT,
4906 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
4908 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
4909 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
4910 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
4911 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
4913 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
4914 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
4915 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
4916 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
4921 EL_DC_TIMEGATE_SWITCH,
4923 EL_SWITCHGATE_CLOSED,
4925 EL_SWITCHGATE_SWITCH_UP,
4926 EL_SWITCHGATE_SWITCH_DOWN,
4929 EL_LIGHT_SWITCH_ACTIVE,
4930 EL_DC_SWITCHGATE_SWITCH_UP,
4931 EL_DC_SWITCHGATE_SWITCH_DOWN,
4933 EL_STEEL_EXIT_CLOSED,
4935 EL_STEELWALL_SLIPPERY,
4938 EL_QUICKSAND_FAST_EMPTY,
4939 EL_QUICKSAND_FAST_FULL,
4953 EL_SIGN_RADIOACTIVITY,
4959 EL_SIGN_ENTRY_FORBIDDEN,
4960 EL_SIGN_EMERGENCY_EXIT,
4985 EL_DC_STEELWALL_2_SINGLE,
4986 EL_DC_STEELWALL_2_TOP,
4987 EL_SIGN_EXCLAMATION,
4990 EL_DC_STEELWALL_2_LEFT,
4991 EL_DC_STEELWALL_2_MIDDLE,
4992 EL_DC_STEELWALL_2_HORIZONTAL,
4993 EL_DC_STEELWALL_2_RIGHT,
4995 EL_DC_STEELWALL_1_TOPLEFT,
4996 EL_DC_STEELWALL_2_VERTICAL,
4997 EL_DC_STEELWALL_1_TOPRIGHT,
5000 EL_DC_STEELWALL_1_VERTICAL,
5001 EL_DC_STEELWALL_2_BOTTOM,
5003 EL_DC_GATE_WHITE_GRAY,
5005 EL_DC_STEELWALL_1_BOTTOMLEFT,
5006 EL_DC_STEELWALL_1_HORIZONTAL,
5007 EL_DC_STEELWALL_1_BOTTOMRIGHT,
5008 EL_DC_GATE_FAKE_GRAY,
5010 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
5011 EL_DC_STEELWALL_1_BOTTOM,
5012 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
5013 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
5015 EL_DC_STEELWALL_1_RIGHT,
5017 EL_DC_STEELWALL_1_LEFT,
5018 EL_EXPANDABLE_STEELWALL_VERTICAL,
5020 EL_DC_STEELWALL_1_TOPRIGHT_2,
5021 EL_DC_STEELWALL_1_TOP,
5022 EL_DC_STEELWALL_1_TOPLEFT_2,
5023 EL_EXPANDABLE_STEELWALL_ANY,
5025 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
5026 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
5027 static int num_editor_hl_diamond_caves = ARRAY_SIZE(editor_hl_diamond_caves);
5028 static int num_editor_el_diamond_caves = ARRAY_SIZE(editor_el_diamond_caves);
5030 static int editor_hl_dx_boulderdash[] =
5032 EL_INTERNAL_CASCADE_DX_ACTIVE,
5038 static int editor_el_dx_boulderdash[] =
5042 EL_TUBE_HORIZONTAL_DOWN,
5046 EL_TUBE_VERTICAL_RIGHT,
5048 EL_TUBE_VERTICAL_LEFT,
5052 EL_TUBE_HORIZONTAL_UP,
5060 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
5061 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
5062 static int num_editor_hl_dx_boulderdash = ARRAY_SIZE(editor_hl_dx_boulderdash);
5063 static int num_editor_el_dx_boulderdash = ARRAY_SIZE(editor_el_dx_boulderdash);
5065 static int editor_hl_mirror_magic[] =
5067 EL_INTERNAL_CASCADE_MM_ACTIVE,
5073 static int editor_el_mirror_magic[] =
5075 EL_MM_MCDUFFIN_RIGHT,
5077 EL_MM_MCDUFFIN_LEFT,
5078 EL_MM_MCDUFFIN_DOWN,
5081 EL_MM_MIRROR_FIXED_START,
5082 EL_MM_POLARIZER_START,
5083 EL_MM_POLARIZER_CROSS_START,
5085 EL_MM_TELEPORTER_RED_START,
5086 EL_MM_TELEPORTER_YELLOW_START,
5087 EL_MM_TELEPORTER_GREEN_START,
5088 EL_MM_TELEPORTER_BLUE_START,
5101 EL_MM_LIGHTBULB_ACTIVE,
5115 EL_MM_STEEL_GRID_FIXED_1,
5116 EL_MM_STEEL_GRID_FIXED_2,
5117 EL_MM_STEEL_GRID_FIXED_3,
5118 EL_MM_STEEL_GRID_FIXED_4,
5120 EL_MM_WOODEN_GRID_FIXED_1,
5121 EL_MM_WOODEN_GRID_FIXED_2,
5122 EL_MM_WOODEN_GRID_FIXED_3,
5123 EL_MM_WOODEN_GRID_FIXED_4,
5130 static int *editor_hl_mirror_magic_ptr = editor_hl_mirror_magic;
5131 static int *editor_el_mirror_magic_ptr = editor_el_mirror_magic;
5132 static int num_editor_hl_mirror_magic = ARRAY_SIZE(editor_hl_mirror_magic);
5133 static int num_editor_el_mirror_magic = ARRAY_SIZE(editor_el_mirror_magic);
5135 static int editor_hl_deflektor[] =
5137 EL_INTERNAL_CASCADE_DF_ACTIVE,
5143 static int editor_el_deflektor[] =
5150 EL_DF_RECEIVER_RIGHT,
5152 EL_DF_RECEIVER_LEFT,
5153 EL_DF_RECEIVER_DOWN,
5156 EL_DF_MIRROR_ROTATING_START,
5157 EL_DF_MIRROR_FIXED_START,
5160 EL_DF_FIBRE_OPTIC_RED_1,
5161 EL_DF_FIBRE_OPTIC_YELLOW_1,
5162 EL_DF_FIBRE_OPTIC_GREEN_1,
5163 EL_DF_FIBRE_OPTIC_BLUE_1,
5165 EL_DF_STEEL_GRID_FIXED_START,
5166 EL_DF_STEEL_GRID_ROTATING_START,
5167 EL_DF_WOODEN_GRID_FIXED_START,
5168 EL_DF_WOODEN_GRID_ROTATING_START,
5180 static int *editor_hl_deflektor_ptr = editor_hl_deflektor;
5181 static int *editor_el_deflektor_ptr = editor_el_deflektor;
5182 static int num_editor_hl_deflektor = ARRAY_SIZE(editor_hl_deflektor);
5183 static int num_editor_el_deflektor = ARRAY_SIZE(editor_el_deflektor);
5185 static int editor_hl_chars[] =
5187 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
5193 static int editor_el_chars[] =
5275 EL_CHAR(CHAR_BYTE_COPYRIGHT),
5276 EL_CHAR(CHAR_BYTE_UMLAUT_A),
5277 EL_CHAR(CHAR_BYTE_UMLAUT_O),
5278 EL_CHAR(CHAR_BYTE_UMLAUT_U),
5280 EL_CHAR(CHAR_BYTE_DEGREE),
5281 EL_CHAR(CHAR_BYTE_REGISTERED),
5282 EL_CHAR(FONT_ASCII_CURSOR),
5283 EL_CHAR(FONT_ASCII_BUTTON),
5285 EL_CHAR(FONT_ASCII_UP),
5286 EL_CHAR(FONT_ASCII_DOWN),
5290 static int *editor_hl_chars_ptr = editor_hl_chars;
5291 static int *editor_el_chars_ptr = editor_el_chars;
5292 static int num_editor_hl_chars = ARRAY_SIZE(editor_hl_chars);
5293 static int num_editor_el_chars = ARRAY_SIZE(editor_el_chars);
5295 static int editor_hl_steel_chars[] =
5297 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
5303 static int editor_el_steel_chars[] =
5313 EL_STEEL_CHAR('\''),
5380 EL_STEEL_CHAR('\\'),
5385 EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
5386 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
5387 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
5388 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
5390 EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
5391 EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
5392 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
5393 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
5395 EL_STEEL_CHAR(FONT_ASCII_UP),
5396 EL_STEEL_CHAR(FONT_ASCII_DOWN),
5400 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
5401 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
5402 static int num_editor_hl_steel_chars = ARRAY_SIZE(editor_hl_steel_chars);
5403 static int num_editor_el_steel_chars = ARRAY_SIZE(editor_el_steel_chars);
5405 static int editor_hl_custom[] =
5407 EL_INTERNAL_CASCADE_CE_ACTIVE,
5413 static int editor_el_custom[] =
5415 EL_CUSTOM_START + 0,
5416 EL_CUSTOM_START + 1,
5417 EL_CUSTOM_START + 2,
5418 EL_CUSTOM_START + 3,
5420 EL_CUSTOM_START + 4,
5421 EL_CUSTOM_START + 5,
5422 EL_CUSTOM_START + 6,
5423 EL_CUSTOM_START + 7,
5425 EL_CUSTOM_START + 8,
5426 EL_CUSTOM_START + 9,
5427 EL_CUSTOM_START + 10,
5428 EL_CUSTOM_START + 11,
5430 EL_CUSTOM_START + 12,
5431 EL_CUSTOM_START + 13,
5432 EL_CUSTOM_START + 14,
5433 EL_CUSTOM_START + 15,
5435 EL_CUSTOM_START + 16,
5436 EL_CUSTOM_START + 17,
5437 EL_CUSTOM_START + 18,
5438 EL_CUSTOM_START + 19,
5440 EL_CUSTOM_START + 20,
5441 EL_CUSTOM_START + 21,
5442 EL_CUSTOM_START + 22,
5443 EL_CUSTOM_START + 23,
5445 EL_CUSTOM_START + 24,
5446 EL_CUSTOM_START + 25,
5447 EL_CUSTOM_START + 26,
5448 EL_CUSTOM_START + 27,
5450 EL_CUSTOM_START + 28,
5451 EL_CUSTOM_START + 29,
5452 EL_CUSTOM_START + 30,
5453 EL_CUSTOM_START + 31,
5455 EL_CUSTOM_START + 32,
5456 EL_CUSTOM_START + 33,
5457 EL_CUSTOM_START + 34,
5458 EL_CUSTOM_START + 35,
5460 EL_CUSTOM_START + 36,
5461 EL_CUSTOM_START + 37,
5462 EL_CUSTOM_START + 38,
5463 EL_CUSTOM_START + 39,
5465 EL_CUSTOM_START + 40,
5466 EL_CUSTOM_START + 41,
5467 EL_CUSTOM_START + 42,
5468 EL_CUSTOM_START + 43,
5470 EL_CUSTOM_START + 44,
5471 EL_CUSTOM_START + 45,
5472 EL_CUSTOM_START + 46,
5473 EL_CUSTOM_START + 47,
5475 EL_CUSTOM_START + 48,
5476 EL_CUSTOM_START + 49,
5477 EL_CUSTOM_START + 50,
5478 EL_CUSTOM_START + 51,
5480 EL_CUSTOM_START + 52,
5481 EL_CUSTOM_START + 53,
5482 EL_CUSTOM_START + 54,
5483 EL_CUSTOM_START + 55,
5485 EL_CUSTOM_START + 56,
5486 EL_CUSTOM_START + 57,
5487 EL_CUSTOM_START + 58,
5488 EL_CUSTOM_START + 59,
5490 EL_CUSTOM_START + 60,
5491 EL_CUSTOM_START + 61,
5492 EL_CUSTOM_START + 62,
5493 EL_CUSTOM_START + 63,
5495 EL_CUSTOM_START + 64,
5496 EL_CUSTOM_START + 65,
5497 EL_CUSTOM_START + 66,
5498 EL_CUSTOM_START + 67,
5500 EL_CUSTOM_START + 68,
5501 EL_CUSTOM_START + 69,
5502 EL_CUSTOM_START + 70,
5503 EL_CUSTOM_START + 71,
5505 EL_CUSTOM_START + 72,
5506 EL_CUSTOM_START + 73,
5507 EL_CUSTOM_START + 74,
5508 EL_CUSTOM_START + 75,
5510 EL_CUSTOM_START + 76,
5511 EL_CUSTOM_START + 77,
5512 EL_CUSTOM_START + 78,
5513 EL_CUSTOM_START + 79,
5515 EL_CUSTOM_START + 80,
5516 EL_CUSTOM_START + 81,
5517 EL_CUSTOM_START + 82,
5518 EL_CUSTOM_START + 83,
5520 EL_CUSTOM_START + 84,
5521 EL_CUSTOM_START + 85,
5522 EL_CUSTOM_START + 86,
5523 EL_CUSTOM_START + 87,
5525 EL_CUSTOM_START + 88,
5526 EL_CUSTOM_START + 89,
5527 EL_CUSTOM_START + 90,
5528 EL_CUSTOM_START + 91,
5530 EL_CUSTOM_START + 92,
5531 EL_CUSTOM_START + 93,
5532 EL_CUSTOM_START + 94,
5533 EL_CUSTOM_START + 95,
5535 EL_CUSTOM_START + 96,
5536 EL_CUSTOM_START + 97,
5537 EL_CUSTOM_START + 98,
5538 EL_CUSTOM_START + 99,
5540 EL_CUSTOM_START + 100,
5541 EL_CUSTOM_START + 101,
5542 EL_CUSTOM_START + 102,
5543 EL_CUSTOM_START + 103,
5545 EL_CUSTOM_START + 104,
5546 EL_CUSTOM_START + 105,
5547 EL_CUSTOM_START + 106,
5548 EL_CUSTOM_START + 107,
5550 EL_CUSTOM_START + 108,
5551 EL_CUSTOM_START + 109,
5552 EL_CUSTOM_START + 110,
5553 EL_CUSTOM_START + 111,
5555 EL_CUSTOM_START + 112,
5556 EL_CUSTOM_START + 113,
5557 EL_CUSTOM_START + 114,
5558 EL_CUSTOM_START + 115,
5560 EL_CUSTOM_START + 116,
5561 EL_CUSTOM_START + 117,
5562 EL_CUSTOM_START + 118,
5563 EL_CUSTOM_START + 119,
5565 EL_CUSTOM_START + 120,
5566 EL_CUSTOM_START + 121,
5567 EL_CUSTOM_START + 122,
5568 EL_CUSTOM_START + 123,
5570 EL_CUSTOM_START + 124,
5571 EL_CUSTOM_START + 125,
5572 EL_CUSTOM_START + 126,
5573 EL_CUSTOM_START + 127,
5575 EL_CUSTOM_START + 128,
5576 EL_CUSTOM_START + 129,
5577 EL_CUSTOM_START + 130,
5578 EL_CUSTOM_START + 131,
5580 EL_CUSTOM_START + 132,
5581 EL_CUSTOM_START + 133,
5582 EL_CUSTOM_START + 134,
5583 EL_CUSTOM_START + 135,
5585 EL_CUSTOM_START + 136,
5586 EL_CUSTOM_START + 137,
5587 EL_CUSTOM_START + 138,
5588 EL_CUSTOM_START + 139,
5590 EL_CUSTOM_START + 140,
5591 EL_CUSTOM_START + 141,
5592 EL_CUSTOM_START + 142,
5593 EL_CUSTOM_START + 143,
5595 EL_CUSTOM_START + 144,
5596 EL_CUSTOM_START + 145,
5597 EL_CUSTOM_START + 146,
5598 EL_CUSTOM_START + 147,
5600 EL_CUSTOM_START + 148,
5601 EL_CUSTOM_START + 149,
5602 EL_CUSTOM_START + 150,
5603 EL_CUSTOM_START + 151,
5605 EL_CUSTOM_START + 152,
5606 EL_CUSTOM_START + 153,
5607 EL_CUSTOM_START + 154,
5608 EL_CUSTOM_START + 155,
5610 EL_CUSTOM_START + 156,
5611 EL_CUSTOM_START + 157,
5612 EL_CUSTOM_START + 158,
5613 EL_CUSTOM_START + 159,
5615 EL_CUSTOM_START + 160,
5616 EL_CUSTOM_START + 161,
5617 EL_CUSTOM_START + 162,
5618 EL_CUSTOM_START + 163,
5620 EL_CUSTOM_START + 164,
5621 EL_CUSTOM_START + 165,
5622 EL_CUSTOM_START + 166,
5623 EL_CUSTOM_START + 167,
5625 EL_CUSTOM_START + 168,
5626 EL_CUSTOM_START + 169,
5627 EL_CUSTOM_START + 170,
5628 EL_CUSTOM_START + 171,
5630 EL_CUSTOM_START + 172,
5631 EL_CUSTOM_START + 173,
5632 EL_CUSTOM_START + 174,
5633 EL_CUSTOM_START + 175,
5635 EL_CUSTOM_START + 176,
5636 EL_CUSTOM_START + 177,
5637 EL_CUSTOM_START + 178,
5638 EL_CUSTOM_START + 179,
5640 EL_CUSTOM_START + 180,
5641 EL_CUSTOM_START + 181,
5642 EL_CUSTOM_START + 182,
5643 EL_CUSTOM_START + 183,
5645 EL_CUSTOM_START + 184,
5646 EL_CUSTOM_START + 185,
5647 EL_CUSTOM_START + 186,
5648 EL_CUSTOM_START + 187,
5650 EL_CUSTOM_START + 188,
5651 EL_CUSTOM_START + 189,
5652 EL_CUSTOM_START + 190,
5653 EL_CUSTOM_START + 191,
5655 EL_CUSTOM_START + 192,
5656 EL_CUSTOM_START + 193,
5657 EL_CUSTOM_START + 194,
5658 EL_CUSTOM_START + 195,
5660 EL_CUSTOM_START + 196,
5661 EL_CUSTOM_START + 197,
5662 EL_CUSTOM_START + 198,
5663 EL_CUSTOM_START + 199,
5665 EL_CUSTOM_START + 200,
5666 EL_CUSTOM_START + 201,
5667 EL_CUSTOM_START + 202,
5668 EL_CUSTOM_START + 203,
5670 EL_CUSTOM_START + 204,
5671 EL_CUSTOM_START + 205,
5672 EL_CUSTOM_START + 206,
5673 EL_CUSTOM_START + 207,
5675 EL_CUSTOM_START + 208,
5676 EL_CUSTOM_START + 209,
5677 EL_CUSTOM_START + 210,
5678 EL_CUSTOM_START + 211,
5680 EL_CUSTOM_START + 212,
5681 EL_CUSTOM_START + 213,
5682 EL_CUSTOM_START + 214,
5683 EL_CUSTOM_START + 215,
5685 EL_CUSTOM_START + 216,
5686 EL_CUSTOM_START + 217,
5687 EL_CUSTOM_START + 218,
5688 EL_CUSTOM_START + 219,
5690 EL_CUSTOM_START + 220,
5691 EL_CUSTOM_START + 221,
5692 EL_CUSTOM_START + 222,
5693 EL_CUSTOM_START + 223,
5695 EL_CUSTOM_START + 224,
5696 EL_CUSTOM_START + 225,
5697 EL_CUSTOM_START + 226,
5698 EL_CUSTOM_START + 227,
5700 EL_CUSTOM_START + 228,
5701 EL_CUSTOM_START + 229,
5702 EL_CUSTOM_START + 230,
5703 EL_CUSTOM_START + 231,
5705 EL_CUSTOM_START + 232,
5706 EL_CUSTOM_START + 233,
5707 EL_CUSTOM_START + 234,
5708 EL_CUSTOM_START + 235,
5710 EL_CUSTOM_START + 236,
5711 EL_CUSTOM_START + 237,
5712 EL_CUSTOM_START + 238,
5713 EL_CUSTOM_START + 239,
5715 EL_CUSTOM_START + 240,
5716 EL_CUSTOM_START + 241,
5717 EL_CUSTOM_START + 242,
5718 EL_CUSTOM_START + 243,
5720 EL_CUSTOM_START + 244,
5721 EL_CUSTOM_START + 245,
5722 EL_CUSTOM_START + 246,
5723 EL_CUSTOM_START + 247,
5725 EL_CUSTOM_START + 248,
5726 EL_CUSTOM_START + 249,
5727 EL_CUSTOM_START + 250,
5728 EL_CUSTOM_START + 251,
5730 EL_CUSTOM_START + 252,
5731 EL_CUSTOM_START + 253,
5732 EL_CUSTOM_START + 254,
5733 EL_CUSTOM_START + 255
5735 static int *editor_hl_custom_ptr = editor_hl_custom;
5736 static int *editor_el_custom_ptr = editor_el_custom;
5737 static int num_editor_hl_custom = ARRAY_SIZE(editor_hl_custom);
5738 static int num_editor_el_custom = ARRAY_SIZE(editor_el_custom);
5740 static int editor_hl_group[] =
5742 EL_INTERNAL_CASCADE_GE_ACTIVE,
5748 static int editor_el_group[] =
5762 EL_GROUP_START + 10,
5763 EL_GROUP_START + 11,
5765 EL_GROUP_START + 12,
5766 EL_GROUP_START + 13,
5767 EL_GROUP_START + 14,
5768 EL_GROUP_START + 15,
5770 EL_GROUP_START + 16,
5771 EL_GROUP_START + 17,
5772 EL_GROUP_START + 18,
5773 EL_GROUP_START + 19,
5775 EL_GROUP_START + 20,
5776 EL_GROUP_START + 21,
5777 EL_GROUP_START + 22,
5778 EL_GROUP_START + 23,
5780 EL_GROUP_START + 24,
5781 EL_GROUP_START + 25,
5782 EL_GROUP_START + 26,
5783 EL_GROUP_START + 27,
5785 EL_GROUP_START + 28,
5786 EL_GROUP_START + 29,
5787 EL_GROUP_START + 30,
5790 static int *editor_hl_group_ptr = editor_hl_group;
5791 static int *editor_el_group_ptr = editor_el_group;
5792 static int num_editor_hl_group = ARRAY_SIZE(editor_hl_group);
5793 static int num_editor_el_group = ARRAY_SIZE(editor_el_group);
5795 static int editor_hl_empty_space[] =
5797 EL_INTERNAL_CASCADE_ES_ACTIVE,
5803 static int editor_el_empty_space[] =
5825 static int *editor_hl_empty_space_ptr = editor_hl_empty_space;
5826 static int *editor_el_empty_space_ptr = editor_el_empty_space;
5827 static int num_editor_hl_empty_space = ARRAY_SIZE(editor_hl_empty_space);
5828 static int num_editor_el_empty_space = ARRAY_SIZE(editor_el_empty_space);
5830 static int editor_hl_reference[] =
5832 EL_INTERNAL_CASCADE_REF_ACTIVE,
5838 static int editor_el_reference[] =
5842 EL_TRIGGER_CE_VALUE,
5843 EL_TRIGGER_CE_SCORE,
5847 EL_CURRENT_CE_VALUE,
5848 EL_CURRENT_CE_SCORE,
5870 static int *editor_hl_reference_ptr = editor_hl_reference;
5871 static int *editor_el_reference_ptr = editor_el_reference;
5872 static int num_editor_hl_reference = ARRAY_SIZE(editor_hl_reference);
5873 static int num_editor_el_reference = ARRAY_SIZE(editor_el_reference);
5875 static int editor_hl_user_defined[] =
5877 EL_INTERNAL_CASCADE_USER_ACTIVE,
5883 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
5884 static int *editor_el_user_defined_ptr = NULL;
5885 static int num_editor_hl_user_defined = ARRAY_SIZE(editor_hl_user_defined);
5886 static int num_editor_el_user_defined = 0;
5888 static int editor_hl_dynamic[] =
5890 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
5896 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
5897 static int *editor_el_dynamic_ptr = NULL;
5898 static int num_editor_hl_dynamic = ARRAY_SIZE(editor_hl_dynamic);
5899 static int num_editor_el_dynamic = 0;
5901 static int editor_hl_empty[] = { EL_EMPTY };
5902 static int *editor_el_empty = NULL; // dynamically allocated
5904 static int *editor_hl_empty_ptr = editor_hl_empty;
5905 static int *editor_el_empty_ptr = NULL;
5906 static int num_editor_hl_empty = 0;
5907 static int num_editor_el_empty = 0; // dynamically determined, if needed
5909 static boolean use_el_empty = FALSE;
5911 static int *editor_elements = NULL; // dynamically allocated
5912 static int num_editor_elements = 0; // dynamically determined
5914 static boolean setup_editor_cascade_never = FALSE;
5916 static boolean setup_editor_el_players = TRUE;
5917 static boolean setup_editor_el_boulderdash = TRUE;
5918 static boolean setup_editor_el_boulderdash_native = TRUE;
5919 static boolean setup_editor_el_emerald_mine = TRUE;
5920 static boolean setup_editor_el_emerald_mine_club = TRUE;
5921 static boolean setup_editor_el_more = TRUE;
5922 static boolean setup_editor_el_sokoban = TRUE;
5923 static boolean setup_editor_el_supaplex = TRUE;
5924 static boolean setup_editor_el_diamond_caves = TRUE;
5925 static boolean setup_editor_el_dx_boulderdash = TRUE;
5926 static boolean setup_editor_el_mirror_magic = TRUE;
5927 static boolean setup_editor_el_deflektor = TRUE;
5928 static boolean setup_editor_el_chars = TRUE;
5929 static boolean setup_editor_el_steel_chars = TRUE;
5930 static boolean setup_editor_el_custom = TRUE;
5931 static boolean setup_editor_el_user_defined = TRUE;
5932 static boolean setup_editor_el_dynamic = TRUE;
5934 static int editor_hl_unused[] = { EL_EMPTY };
5935 static int *editor_hl_unused_ptr = editor_hl_unused;
5936 static int num_editor_hl_unused = 0;
5940 boolean *setup_value;
5941 boolean *setup_cascade_value;
5943 int **headline_list;
5944 int *headline_list_size;
5947 int *element_list_size;
5949 boolean last_setup_value;
5951 editor_elements_info[] =
5954 &setup_editor_el_players,
5955 &setup_editor_cascade_never,
5956 &editor_hl_unused_ptr, &num_editor_hl_unused,
5957 &editor_el_players_ptr, &num_editor_el_players
5960 &setup_editor_el_boulderdash,
5961 &setup.editor_cascade.el_bd,
5962 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
5963 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
5966 &setup_editor_el_boulderdash_native,
5967 &setup.editor_cascade.el_bd_native,
5968 &editor_hl_boulderdash_native_ptr, &num_editor_hl_boulderdash_native,
5969 &editor_el_boulderdash_native_ptr, &num_editor_el_boulderdash_native
5972 &setup_editor_el_emerald_mine,
5973 &setup.editor_cascade.el_em,
5974 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
5975 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
5978 &setup_editor_el_emerald_mine_club,
5979 &setup.editor_cascade.el_emc,
5980 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
5981 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
5984 &setup_editor_el_more,
5985 &setup.editor_cascade.el_rnd,
5986 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
5987 &editor_el_rnd_ptr, &num_editor_el_rnd
5990 &setup_editor_el_sokoban,
5991 &setup.editor_cascade.el_sb,
5992 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
5993 &editor_el_sokoban_ptr, &num_editor_el_sokoban
5996 &setup_editor_el_supaplex,
5997 &setup.editor_cascade.el_sp,
5998 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
5999 &editor_el_supaplex_ptr, &num_editor_el_supaplex
6002 &setup_editor_el_diamond_caves,
6003 &setup.editor_cascade.el_dc,
6004 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
6005 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
6008 &setup_editor_el_dx_boulderdash,
6009 &setup.editor_cascade.el_dx,
6010 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
6011 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
6014 &setup_editor_el_mirror_magic,
6015 &setup.editor_cascade.el_mm,
6016 &editor_hl_mirror_magic_ptr, &num_editor_hl_mirror_magic,
6017 &editor_el_mirror_magic_ptr, &num_editor_el_mirror_magic
6020 &setup_editor_el_deflektor,
6021 &setup.editor_cascade.el_df,
6022 &editor_hl_deflektor_ptr, &num_editor_hl_deflektor,
6023 &editor_el_deflektor_ptr, &num_editor_el_deflektor
6026 &setup_editor_el_chars,
6027 &setup.editor_cascade.el_chars,
6028 &editor_hl_chars_ptr, &num_editor_hl_chars,
6029 &editor_el_chars_ptr, &num_editor_el_chars
6032 &setup_editor_el_steel_chars,
6033 &setup.editor_cascade.el_steel_chars,
6034 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
6035 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
6038 &setup_editor_el_custom,
6039 &setup.editor_cascade.el_ce,
6040 &editor_hl_custom_ptr, &num_editor_hl_custom,
6041 &editor_el_custom_ptr, &num_editor_el_custom
6044 &setup_editor_el_custom,
6045 &setup.editor_cascade.el_ge,
6046 &editor_hl_group_ptr, &num_editor_hl_group,
6047 &editor_el_group_ptr, &num_editor_el_group
6050 &setup_editor_el_custom,
6051 &setup.editor_cascade.el_es,
6052 &editor_hl_empty_space_ptr, &num_editor_hl_empty_space,
6053 &editor_el_empty_space_ptr, &num_editor_el_empty_space
6056 &setup_editor_el_custom,
6057 &setup.editor_cascade.el_ref,
6058 &editor_hl_reference_ptr, &num_editor_hl_reference,
6059 &editor_el_reference_ptr, &num_editor_el_reference
6062 &setup_editor_el_user_defined,
6063 &setup.editor_cascade.el_user,
6064 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
6065 &editor_el_user_defined_ptr, &num_editor_el_user_defined
6068 &setup_editor_el_dynamic,
6069 &setup.editor_cascade.el_dynamic,
6070 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
6071 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
6076 &editor_hl_empty_ptr, &num_editor_hl_empty,
6077 &editor_el_empty_ptr, &num_editor_el_empty,
6087 static struct XY xy_directions[] =
6096 // ----------------------------------------------------------------------------
6098 // ----------------------------------------------------------------------------
6100 static int getMaxInfoTextLength(void)
6102 return (SXSIZE / getFontWidth(INFOTEXT_FONT));
6105 static int getTextWidthForGadget(char *text)
6110 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
6113 static int getTextWidthForDrawingArea(char *text)
6118 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
6121 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
6123 return (gi->x + gi->width + getTextWidthForGadget(text));
6126 static char *getElementInfoText(int element)
6128 char *info_text = NULL;
6130 if (element < MAX_NUM_ELEMENTS)
6132 if (strlen(element_info[element].description) > 0)
6133 info_text = element_info[element].description;
6134 else if (element_info[element].custom_description != NULL)
6135 info_text = element_info[element].custom_description;
6136 else if (element_info[element].editor_description != NULL)
6137 info_text = element_info[element].editor_description;
6140 if (info_text == NULL)
6141 info_text = INFOTEXT_UNKNOWN_ELEMENT;
6146 static char *getElementDescriptionFilenameExt(char *basename)
6148 char *elements_subdir = ELEMENTS_DIRECTORY;
6149 static char *elements_subdir2 = NULL;
6150 static char *filename = NULL;
6152 if (elements_subdir2 == NULL)
6153 elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
6155 checked_free(filename);
6157 // 1st try: look for element description in current level set directory
6158 filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
6159 if (fileExists(filename))
6164 // 2nd try: look for element description in the game's base directory
6165 filename = getPath3(options.docs_directory, elements_subdir, basename);
6166 if (fileExists(filename))
6172 static char *getElementDescriptionFilename(int element)
6174 char basename[MAX_FILENAME_LEN];
6177 // 1st try: look for element description file for exactly this element
6178 sprintf(basename, "%s.txt", element_info[element].token_name);
6179 filename = getElementDescriptionFilenameExt(basename);
6180 if (filename != NULL)
6183 // 2nd try: look for element description file for this element's class
6184 sprintf(basename, "%s.txt", element_info[element].class_name);
6185 filename = getElementDescriptionFilenameExt(basename);
6186 if (filename != NULL)
6189 // 3rd try: look for generic fallback text file for any element
6190 filename = getElementDescriptionFilenameExt(FALLBACK_TEXT_FILENAME);
6191 if (filename != NULL)
6197 static boolean suppressBorderElement(void)
6199 return (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
6200 lev_fieldx <= MAX_ED_FIELDX &&
6201 lev_fieldy <= MAX_ED_FIELDY);
6204 static void InitDynamicEditorElementList(int **elements, int *num_elements)
6206 boolean element_found[NUM_FILE_ELEMENTS];
6209 // initialize list of used elements to "not used"
6210 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6211 element_found[i] = FALSE;
6213 // find all elements used in current level
6214 for (y = 0; y < lev_fieldy; y++)
6216 for (x = 0; x < lev_fieldx; x++)
6218 if (Tile[x][y] >= NUM_FILE_ELEMENTS) // should never happen
6221 if (IS_MM_WALL(Tile[x][y]))
6222 element_found[map_mm_wall_element(Tile[x][y])] = TRUE;
6224 element_found[Tile[x][y]] = TRUE;
6230 // count number of elements used in current level
6231 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6232 if (element_found[i])
6235 // add space for up to 3 more elements for padding that may be needed
6238 // free memory for old list of elements, if needed
6239 checked_free(*elements);
6241 // allocate memory for new list of elements
6242 *elements = checked_malloc(*num_elements * sizeof(int));
6246 // add all elements used in current level (non-custom/group/empty elements)
6247 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6248 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) ||
6249 IS_GROUP_ELEMENT(i) ||
6250 IS_EMPTY_ELEMENT(i)))
6251 (*elements)[(*num_elements)++] = i;
6253 // add all elements used in current level (custom/group/empty elements)
6254 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6255 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) ||
6256 IS_GROUP_ELEMENT(i) ||
6257 IS_EMPTY_ELEMENT(i)))
6258 (*elements)[(*num_elements)++] = i;
6260 while (*num_elements % 4) // pad with empty elements, if needed
6261 (*elements)[(*num_elements)++] = EL_EMPTY;
6264 static void ReinitializeElementList_EnableSections(void)
6266 // default: enable all element sections
6268 setup_editor_el_players = TRUE;
6269 setup_editor_el_boulderdash = TRUE;
6270 setup_editor_el_boulderdash_native = TRUE;
6271 setup_editor_el_emerald_mine = TRUE;
6272 setup_editor_el_emerald_mine_club = TRUE;
6273 setup_editor_el_more = TRUE;
6274 setup_editor_el_sokoban = TRUE;
6275 setup_editor_el_supaplex = TRUE;
6276 setup_editor_el_diamond_caves = TRUE;
6277 setup_editor_el_dx_boulderdash = TRUE;
6278 setup_editor_el_mirror_magic = TRUE;
6279 setup_editor_el_deflektor = TRUE;
6280 setup_editor_el_chars = TRUE;
6281 setup_editor_el_steel_chars = TRUE;
6283 setup_editor_el_custom = TRUE;
6284 setup_editor_el_user_defined = TRUE;
6285 setup_editor_el_dynamic = TRUE;
6287 // now disable all element sections not to be displayed
6289 if (!setup.editor.el_classic)
6291 setup_editor_el_players = FALSE;
6292 setup_editor_el_boulderdash = FALSE;
6293 setup_editor_el_boulderdash_native = FALSE;
6294 setup_editor_el_emerald_mine = FALSE;
6295 setup_editor_el_emerald_mine_club = FALSE;
6296 setup_editor_el_more = FALSE;
6297 setup_editor_el_sokoban = FALSE;
6298 setup_editor_el_supaplex = FALSE;
6299 setup_editor_el_diamond_caves = FALSE;
6300 setup_editor_el_dx_boulderdash = FALSE;
6301 setup_editor_el_mirror_magic = FALSE;
6302 setup_editor_el_deflektor = FALSE;
6303 setup_editor_el_chars = FALSE;
6304 setup_editor_el_steel_chars = FALSE;
6307 if (!setup.editor.el_custom)
6309 setup_editor_el_custom = FALSE;
6312 if (!setup.editor.el_user_defined)
6314 setup_editor_el_user_defined = FALSE;
6317 if (!setup.editor.el_dynamic)
6319 setup_editor_el_dynamic = FALSE;
6322 if (level.game_engine_type == GAME_ENGINE_TYPE_RND)
6324 setup_editor_el_boulderdash_native = FALSE;
6325 setup_editor_el_mirror_magic = FALSE;
6326 setup_editor_el_deflektor = FALSE;
6328 else if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
6330 setup_editor_el_players = FALSE;
6331 setup_editor_el_boulderdash = FALSE;
6332 setup_editor_el_emerald_mine = FALSE;
6333 setup_editor_el_emerald_mine_club = FALSE;
6334 setup_editor_el_more = FALSE;
6335 setup_editor_el_sokoban = FALSE;
6336 setup_editor_el_supaplex = FALSE;
6337 setup_editor_el_diamond_caves = FALSE;
6338 setup_editor_el_dx_boulderdash = FALSE;
6339 setup_editor_el_mirror_magic = FALSE;
6340 setup_editor_el_deflektor = FALSE;
6341 setup_editor_el_chars = FALSE;
6342 setup_editor_el_steel_chars = FALSE;
6344 setup_editor_el_custom = FALSE;
6346 else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
6348 setup_editor_el_boulderdash = FALSE;
6349 setup_editor_el_boulderdash_native = FALSE;
6350 setup_editor_el_more = FALSE;
6351 setup_editor_el_sokoban = FALSE;
6352 setup_editor_el_supaplex = FALSE;
6353 setup_editor_el_diamond_caves = FALSE;
6354 setup_editor_el_dx_boulderdash = FALSE;
6355 setup_editor_el_mirror_magic = FALSE;
6356 setup_editor_el_deflektor = FALSE;
6357 setup_editor_el_steel_chars = FALSE;
6359 setup_editor_el_custom = FALSE;
6361 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
6363 setup_editor_el_players = FALSE;
6364 setup_editor_el_boulderdash = FALSE;
6365 setup_editor_el_boulderdash_native = FALSE;
6366 setup_editor_el_emerald_mine = FALSE;
6367 setup_editor_el_emerald_mine_club = FALSE;
6368 setup_editor_el_more = FALSE;
6369 setup_editor_el_sokoban = FALSE;
6370 setup_editor_el_diamond_caves = FALSE;
6371 setup_editor_el_dx_boulderdash = FALSE;
6372 setup_editor_el_mirror_magic = FALSE;
6373 setup_editor_el_deflektor = FALSE;
6374 setup_editor_el_chars = FALSE;
6375 setup_editor_el_steel_chars = FALSE;
6377 setup_editor_el_custom = FALSE;
6379 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
6381 setup_editor_el_players = FALSE;
6382 setup_editor_el_boulderdash = FALSE;
6383 setup_editor_el_boulderdash_native = FALSE;
6384 setup_editor_el_emerald_mine = FALSE;
6385 setup_editor_el_emerald_mine_club = FALSE;
6386 setup_editor_el_more = FALSE;
6387 setup_editor_el_sokoban = FALSE;
6388 setup_editor_el_supaplex = FALSE;
6389 setup_editor_el_diamond_caves = FALSE;
6390 setup_editor_el_dx_boulderdash = FALSE;
6391 setup_editor_el_steel_chars = FALSE;
6393 setup_editor_el_custom = FALSE;
6397 static void ReinitializeElementList(void)
6399 static boolean initialization_needed = TRUE;
6403 ReinitializeElementList_EnableSections();
6405 if (initialization_needed)
6407 LoadSetup_EditorCascade(); // load last editor cascade state
6409 // initialize editor cascade element from saved cascade state
6410 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6412 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
6413 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
6415 if (IS_EDITOR_CASCADE(*cascade_element))
6417 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
6418 EL_CASCADE_INACTIVE(*cascade_element));
6421 initialization_needed = FALSE;
6424 checked_free(editor_elements);
6426 // reload optional user defined element list for each invocation of editor
6427 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
6428 &num_editor_el_user_defined);
6430 // initialize dynamic level element list for each invocation of editor
6431 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
6432 &num_editor_el_dynamic);
6434 // initialize list of empty elements (used for padding, if needed)
6435 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6436 editor_el_empty[i] = EL_EMPTY;
6438 // do some sanity checks for each element from element list
6439 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6441 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6443 int element = (*editor_elements_info[i].element_list)[j];
6445 if (element >= NUM_FILE_ELEMENTS)
6446 Warn("editor element %d is runtime element", element);
6448 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
6449 Warn("no element description text for element %d", element);
6453 num_editor_elements = 0;
6454 use_el_empty = FALSE;
6456 // determine size of element list
6457 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6459 if (*editor_elements_info[i].setup_value)
6461 boolean found_inactive_cascade = FALSE;
6463 if (setup.editor.el_headlines)
6465 // required for correct padding of palette headline buttons
6466 if (*editor_elements_info[i].headline_list_size > 0)
6467 num_editor_elements += ED_ELEMENTLIST_COLS;
6469 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6471 int element = (*editor_elements_info[i].headline_list)[j];
6473 if (IS_EDITOR_CASCADE_INACTIVE(element))
6474 found_inactive_cascade = TRUE;
6478 if (found_inactive_cascade)
6481 // required for correct padding of palette element buttons
6482 int element_list_size = *editor_elements_info[i].element_list_size;
6484 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6485 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6487 num_editor_elements += element_buttons;
6491 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
6493 // offer at least as many elements as element buttons exist
6494 use_el_empty = TRUE;
6495 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
6497 num_editor_elements += num_editor_el_empty;
6501 num_editor_el_empty = 0;
6504 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
6506 // fill element list
6507 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6509 boolean found_inactive_cascade = FALSE;
6511 if (*editor_elements_info[i].setup_value)
6513 if (setup.editor.el_headlines)
6515 // required for correct padding of palette headline buttons
6516 int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
6517 ED_ELEMENTLIST_COLS : 0);
6519 for (j = 0; j < headline_size; j++)
6521 // use empty elements for padding of palette headline buttons
6522 int element = (j < *editor_elements_info[i].headline_list_size ?
6523 (*editor_elements_info[i].headline_list)[j] :
6524 editor_el_empty[0]);
6526 editor_elements[pos++] = element;
6528 if (IS_EDITOR_CASCADE_INACTIVE(element))
6529 found_inactive_cascade = TRUE;
6533 if (found_inactive_cascade)
6536 // required for correct padding of palette element buttons
6537 int element_list_size = *editor_elements_info[i].element_list_size;
6539 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6540 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6542 // copy all elements from element list
6543 for (j = 0; j < element_list_size; j++)
6544 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
6546 // use empty elements for padding of palette element buttons
6547 for (j = 0; j < element_buttons - element_list_size; j++)
6548 editor_elements[pos++] = editor_el_empty[0];
6552 // (this function is also called before editor gadgets are initialized!)
6553 AdjustElementListScrollbar();
6556 void PrintEditorElementList(void)
6558 boolean *stop = &setup_editor_el_user_defined;
6561 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
6563 int cascade_element = (*editor_elements_info[i].headline_list)[0];
6565 if (IS_EDITOR_CASCADE(cascade_element))
6567 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
6568 char *headline = element_info[cascade_element_show].editor_description;
6570 PrintLineWithPrefix("# ", "-", 77);
6571 Print("# %s\n", headline);
6572 PrintLineWithPrefix("# ", "-", 77);
6575 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6577 int element = (*editor_elements_info[i].headline_list)[j];
6579 if (IS_EDITOR_CASCADE(element))
6580 element = EL_CHAR_MINUS;
6582 Print("# %s\n", element_info[element].token_name);
6588 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6590 int element = (*editor_elements_info[i].element_list)[j];
6592 Print("# %s\n", element_info[element].token_name);
6600 static void ReinitializeElementListButtons(void)
6602 static boolean last_setup_value_headlines = FALSE;
6603 static boolean initialization_needed = TRUE;
6606 if (!initialization_needed) // check if editor element setup has changed
6608 if (last_setup_value_headlines != setup.editor.el_headlines)
6609 initialization_needed = TRUE;
6611 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6612 if (editor_elements_info[i].last_setup_value !=
6613 *editor_elements_info[i].setup_value)
6614 initialization_needed = TRUE;
6617 if (!initialization_needed)
6620 FreeLevelEditorGadgets();
6621 CreateLevelEditorGadgets();
6623 // store current setup values for next invocation of this function
6624 last_setup_value_headlines = setup.editor.el_headlines;
6625 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6626 editor_elements_info[i].last_setup_value =
6627 *editor_elements_info[i].setup_value;
6629 initialization_needed = FALSE;
6632 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
6635 int border_graphic =
6636 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
6637 struct GraphicInfo *g = &graphic_info[border_graphic];
6638 Bitmap *src_bitmap = g->bitmap;
6639 int src_x = g->src_x;
6640 int src_y = g->src_y;
6641 int border_size = g->border_size;
6642 int border_xpos = g->width - border_size;
6643 int border_ypos = g->height - border_size;
6644 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6647 BlitBitmap(src_bitmap, drawto, src_x, src_y,
6648 border_size, border_size,
6649 dest_x - border_size, dest_y - border_size);
6650 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y,
6651 border_size, border_size,
6652 dest_x + width, dest_y - border_size);
6653 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_ypos,
6654 border_size, border_size,
6655 dest_x - border_size, dest_y + height);
6656 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_ypos,
6657 border_size, border_size,
6658 dest_x + width, dest_y + height);
6660 for (i = 0; i < width / tilesize; i++)
6662 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y,
6663 tilesize, border_size,
6664 dest_x + i * tilesize, dest_y - border_size);
6665 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y + border_ypos,
6666 tilesize, border_size,
6667 dest_x + i * tilesize, dest_y + height);
6670 for (i = 0; i < height / tilesize; i++)
6672 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_size,
6673 border_size, tilesize,
6674 dest_x - border_size, dest_y + i * tilesize);
6675 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_size,
6676 border_size, tilesize,
6677 dest_x + width, dest_y + i * tilesize);
6680 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
6683 static void DrawEditorLevelBorderLine(int x, int y, int xsize, int ysize)
6685 int xsize_tile = MAX(ed_tilesize, xsize);
6686 int ysize_tile = MAX(ed_tilesize, ysize);
6687 int xsize_full = xsize + 1;
6688 int ysize_full = ysize + 1;
6689 int xsize_thin = (xsize < ed_tilesize ? 1 : xsize);
6690 int ysize_thin = (ysize < ed_tilesize ? 1 : ysize);
6691 Pixel line_color = getTabulatorBarColor();
6693 if (line_color == BLACK_PIXEL) // black => transparent
6696 FillRectangle(drawto, SX + x, SY + y, xsize_tile, ysize_tile, BLACK_PIXEL);
6697 FillRectangle(drawto, SX + x, SY + y, xsize_full, ysize_full, line_color);
6698 FillRectangle(drawto, SX + x, SY + y, xsize_thin, ysize_thin, BLACK_PIXEL);
6701 static void DrawEditorLevelBorderLinesIfNeeded(void)
6703 int xsize = lev_fieldx * ed_tilesize;
6704 int ysize = lev_fieldy * ed_tilesize;
6705 int line_size = getTabulatorBarHeight();
6707 if (!suppressBorderElement())
6710 // draw little border line around editable level playfield
6713 DrawEditorLevelBorderLine(xsize, 0, line_size, ysize);
6716 DrawEditorLevelBorderLine(0, ysize, xsize, line_size);
6718 if (xsize < SXSIZE && ysize < SYSIZE)
6719 DrawEditorLevelBorderLine(xsize, ysize, line_size, line_size);
6722 static void DrawEditorElement(int x, int y, int element)
6724 DrawSizedElement(x, y, element, ed_tilesize);
6727 static void DrawEditorElementThruMask(int x, int y, int element)
6729 DrawSizedElementThruMask(x, y, element, ed_tilesize);
6732 static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
6734 DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
6737 static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
6739 DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
6740 DrawEditorLevelBorderLinesIfNeeded();
6743 static void DrawDrawingArea(int id)
6745 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6748 int *value = drawingarea_info[id].value;
6749 int area_xsize = drawingarea_info[id].area_xsize;
6750 int area_ysize = drawingarea_info[id].area_ysize;
6751 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6753 for (x = 0; x < area_xsize; x++)
6754 for (y = 0; y < area_ysize; y++)
6755 DrawSizedGraphicExt(drawto,
6756 gi->x + x * tilesize,
6757 gi->y + y * tilesize,
6758 el2edimg(value[x * area_ysize + y]), 0, tilesize);
6761 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
6764 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
6765 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
6767 BlitBitmap(drawto, drawto,
6768 SX + (dx == -1 ? ed_tilesize : 0),
6769 SY + (dy == -1 ? ed_tilesize : 0),
6770 (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
6771 (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
6772 SX + (dx == +1 ? ed_tilesize : 0),
6773 SY + (dy == +1 ? ed_tilesize : 0));
6777 x = (dx == 1 ? 0 : ed_fieldx - 1);
6778 for (y = 0; y < ed_fieldy; y++)
6779 DrawEditorElementOrWall(x, y, from_x, from_y);
6783 y = (dy == 1 ? 0 : ed_fieldy - 1);
6784 for (x = 0; x < ed_fieldx; x++)
6785 DrawEditorElementOrWall(x, y, from_x, from_y);
6788 redraw_mask |= REDRAW_FIELD;
6792 static void getEditorGraphicSource(int element, int tile_size, Bitmap **bitmap,
6795 getSizedGraphicSource(el2edimg(element), 0, tile_size, bitmap, x, y);
6798 static void CreateControlButtons(void)
6800 struct GadgetInfo *gi;
6803 // create toolbox buttons
6804 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6806 int type_id = controlbutton_info[i].gadget_id; // same as gadget ID here
6807 int id = controlbutton_info[i].gadget_id;
6808 int type = controlbutton_info[i].gadget_type;
6809 int graphic = controlbutton_info[i].graphic;
6810 struct XYTileSize *pos = controlbutton_info[i].pos;
6811 struct GraphicInfo *gd = &graphic_info[graphic];
6812 Bitmap *deco_bitmap = NULL;
6813 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
6814 int tile_size = 0, deco_shift = 0;
6815 boolean deco_masked = FALSE;
6816 int gd_x1 = gd->src_x;
6817 int gd_y1 = gd->src_y;
6818 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6819 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6820 int gd_x1a = gd->src_x + gd->active_xoffset;
6821 int gd_y1a = gd->src_y + gd->active_yoffset;
6822 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6823 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
6826 unsigned int event_mask;
6827 int radio_button_nr = RADIO_NR_NONE;
6828 boolean checked = FALSE;
6831 Fail("'controlbutton_info' structure corrupted at index %d -- please fix", i);
6833 if (type == GD_TYPE_RADIO_BUTTON)
6835 event_mask = GD_EVENT_PRESSED;
6836 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
6838 if (id == drawing_function)
6843 if (id == GADGET_ID_WRAP_LEFT ||
6844 id == GADGET_ID_WRAP_RIGHT ||
6845 id == GADGET_ID_WRAP_UP ||
6846 id == GADGET_ID_WRAP_DOWN)
6847 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6849 event_mask = GD_EVENT_RELEASED;
6852 if (id == GADGET_ID_PROPERTIES ||
6853 id == GADGET_ID_PALETTE)
6858 else if (id == GADGET_ID_ELEMENT_LEFT ||
6859 id == GADGET_ID_ELEMENT_MIDDLE ||
6860 id == GADGET_ID_ELEMENT_RIGHT)
6865 int element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
6866 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
6867 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : EL_EMPTY);
6869 tile_size = BUTTON_TILE_SIZE(id == GADGET_ID_ELEMENT_LEFT ?
6870 editor.button.element_left.tile_size :
6871 id == GADGET_ID_ELEMENT_MIDDLE ?
6872 editor.button.element_middle.tile_size :
6873 id == GADGET_ID_ELEMENT_RIGHT ?
6874 editor.button.element_right.tile_size : 0);
6876 // make sure that decoration does not overlap gadget border
6877 tile_size = MIN(tile_size, MIN(gd->width, gd->height));
6879 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x,&deco_y);
6881 deco_xpos = (gd->width - tile_size) / 2;
6882 deco_ypos = (gd->height - tile_size) / 2;
6884 deco_masked = gd->draw_masked;
6892 gi = CreateGadget(GDI_CUSTOM_ID, id,
6893 GDI_CUSTOM_TYPE_ID, type_id,
6894 GDI_IMAGE_ID, graphic,
6895 GDI_INFO_TEXT, controlbutton_info[i].infotext,
6898 GDI_WIDTH, gd->width,
6899 GDI_HEIGHT, gd->height,
6901 GDI_STATE, GD_BUTTON_UNPRESSED,
6902 GDI_RADIO_NR, radio_button_nr,
6903 GDI_CHECKED, checked,
6904 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6905 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6906 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6907 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
6908 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6909 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6910 GDI_DECORATION_SIZE, tile_size, tile_size,
6911 GDI_DECORATION_SHIFTING, deco_shift, deco_shift,
6912 GDI_DECORATION_MASKED, deco_masked,
6913 GDI_EVENT_MASK, event_mask,
6914 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6915 GDI_CALLBACK_ACTION, HandleControlButtons,
6919 Fail("cannot create gadget");
6921 level_editor_gadget[id] = gi;
6924 // these values are not constant, but can change at runtime
6925 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
6926 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
6927 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
6928 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
6929 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
6930 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
6931 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
6932 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
6933 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].x = ED_SCROLL2_UP_XPOS;
6934 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y = ED_SCROLL2_UP_YPOS;
6935 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x = ED_SCROLL2_DOWN_XPOS;
6936 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y = ED_SCROLL2_DOWN_YPOS;
6938 // create buttons for scrolling of drawing area and element list
6939 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
6941 int id = scrollbutton_info[i].gadget_id;
6942 int type_id = scrollbutton_info[i].gadget_type_id;
6943 int graphic = scrollbutton_info[i].graphic;
6944 struct GraphicInfo *gd = &graphic_info[graphic];
6945 Bitmap *gd_bitmap = gd->bitmap;
6946 int gd_x1 = gd->src_x;
6947 int gd_y1 = gd->src_y;
6948 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6949 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6950 int width = gd->width;
6951 int height = gd->height;
6952 int x = scrollbutton_pos[i].x;
6953 int y = scrollbutton_pos[i].y;
6954 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6957 Fail("'scrollbutton_info' structure corrupted at index %d -- please fix", i);
6959 if (id == GADGET_ID_SCROLL_LIST_UP ||
6960 id == GADGET_ID_SCROLL_LIST_DOWN)
6971 gi = CreateGadget(GDI_CUSTOM_ID, id,
6972 GDI_CUSTOM_TYPE_ID, type_id,
6973 GDI_IMAGE_ID, graphic,
6974 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6979 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6980 GDI_STATE, GD_BUTTON_UNPRESSED,
6981 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6982 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6983 GDI_EVENT_MASK, event_mask,
6984 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6985 GDI_CALLBACK_ACTION, HandleControlButtons,
6989 Fail("cannot create gadget");
6991 level_editor_gadget[id] = gi;
6994 // create buttons for element list
6995 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6998 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
6999 int graphic = IMG_EDITOR_PALETTE_BUTTON;
7000 struct GraphicInfo *gd = &graphic_info[graphic];
7001 Bitmap *gd_bitmap = gd->bitmap;
7002 Bitmap *deco_bitmap;
7003 int deco_x, deco_y, deco_xpos, deco_ypos;
7004 int gd_x1 = gd->src_x;
7005 int gd_y1 = gd->src_y;
7006 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7007 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7008 int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
7009 int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
7010 int x = PX + ED_ELEMENTLIST_XPOS + xx * gd->width;
7011 int y = PY + ED_ELEMENTLIST_YPOS + yy * gd->height;
7012 int element = editor_elements[i];
7013 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
7014 unsigned int event_mask = GD_EVENT_RELEASED;
7016 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
7018 deco_xpos = (gd->width - tile_size) / 2;
7019 deco_ypos = (gd->height - tile_size) / 2;
7021 gi = CreateGadget(GDI_CUSTOM_ID, id,
7022 GDI_CUSTOM_TYPE_ID, type_id,
7023 GDI_IMAGE_ID, graphic,
7024 GDI_INFO_TEXT, getElementInfoText(element),
7027 GDI_WIDTH, gd->width,
7028 GDI_HEIGHT, gd->height,
7029 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7030 GDI_STATE, GD_BUTTON_UNPRESSED,
7031 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
7032 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
7033 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
7034 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
7035 GDI_DECORATION_SIZE, tile_size, tile_size,
7036 GDI_DECORATION_SHIFTING, 1, 1,
7037 GDI_EVENT_MASK, event_mask,
7038 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7039 GDI_CALLBACK_ACTION, HandleControlButtons,
7043 Fail("cannot create gadget");
7045 level_editor_gadget[id] = gi;
7049 static void CreateCounterButtons(void)
7051 int max_infotext_len = getMaxInfoTextLength();
7054 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
7056 int type_id = counterbutton_info[i].gadget_type_id;
7057 int x = SX + ED_SETTINGS_X(counterbutton_info[i].x); // down count button
7058 int y = SY + ED_SETTINGS_Y(counterbutton_info[i].y);
7062 Fail("'counterbutton_info' structure corrupted at index %d -- please fix", i);
7064 // determine horizontal position to the right of specified gadget
7065 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7066 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
7067 ED_GADGET_TEXT_DISTANCE);
7069 // determine horizontal offset for leading text
7070 if (counterbutton_info[i].text_left != NULL)
7071 x += getTextWidthForGadget(counterbutton_info[i].text_left);
7073 for (j = 0; j < 2; j++)
7075 struct GadgetInfo *gi;
7077 counterbutton_info[i].gadget_id_down :
7078 counterbutton_info[i].gadget_id_up);
7080 struct GraphicInfo *gd;
7081 int gd_x1, gd_x2, gd_y1, gd_y2;
7082 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7083 char infotext[max_infotext_len + 1];
7085 if (i == ED_COUNTER_ID_SELECT_LEVEL)
7088 IMG_GFX_EDITOR_BUTTON_PREV_LEVEL :
7089 IMG_GFX_EDITOR_BUTTON_NEXT_LEVEL);
7091 event_mask |= GD_EVENT_RELEASED;
7095 x = DX + editor.button.prev_level.x;
7096 y = DY + editor.button.prev_level.y;
7100 x = DX + editor.button.next_level.x;
7101 y = DY + editor.button.next_level.y;
7107 IMG_EDITOR_COUNTER_DOWN :
7108 IMG_EDITOR_COUNTER_UP);
7111 gd = &graphic_info[graphic];
7115 gd_x2 = gd->src_x + gd->pressed_xoffset;
7116 gd_y2 = gd->src_y + gd->pressed_yoffset;
7118 sprintf(infotext, "%s counter value by 1, 5 or 10",
7119 (j == 0 ? "decrease" : "increase"));
7121 gi = CreateGadget(GDI_CUSTOM_ID, id,
7122 GDI_CUSTOM_TYPE_ID, type_id,
7123 GDI_IMAGE_ID, graphic,
7124 GDI_INFO_TEXT, infotext,
7127 GDI_WIDTH, gd->width,
7128 GDI_HEIGHT, gd->height,
7129 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7130 GDI_STATE, GD_BUTTON_UNPRESSED,
7131 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7132 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7133 GDI_EVENT_MASK, event_mask,
7134 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7135 GDI_CALLBACK_ACTION, HandleCounterButtons,
7139 Fail("cannot create gadget");
7141 level_editor_gadget[id] = gi;
7142 right_gadget_border[id] =
7143 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
7145 x += gi->width + ED_GADGET_SMALL_DISTANCE; // text count button
7149 int font_type = FONT_INPUT_1;
7150 int font_type_active = FONT_INPUT_1_ACTIVE;
7152 id = counterbutton_info[i].gadget_id_text;
7154 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7156 if (i == ED_COUNTER_ID_SELECT_LEVEL)
7158 graphic = IMG_GFX_EDITOR_INPUT_LEVEL_NUMBER;
7160 font_type = FONT_LEVEL_NUMBER;
7161 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
7163 x = DX + editor.input.level_number.x;
7164 y = DY + editor.input.level_number.y;
7168 graphic = IMG_EDITOR_COUNTER_INPUT;
7171 gd = &graphic_info[graphic];
7175 gd_x2 = gd->src_x + gd->active_xoffset;
7176 gd_y2 = gd->src_y + gd->active_yoffset;
7178 gi = CreateGadget(GDI_CUSTOM_ID, id,
7179 GDI_CUSTOM_TYPE_ID, type_id,
7180 GDI_IMAGE_ID, graphic,
7181 GDI_INFO_TEXT, "enter counter value",
7184 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
7185 GDI_NUMBER_VALUE, 0,
7186 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
7187 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
7188 GDI_TEXT_SIZE, 3, // minimal counter text size
7189 GDI_TEXT_FONT, font_type,
7190 GDI_TEXT_FONT_ACTIVE, font_type_active,
7191 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7192 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7193 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7194 GDI_DESIGN_WIDTH, gd->width,
7195 GDI_EVENT_MASK, event_mask,
7196 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7197 GDI_CALLBACK_ACTION, HandleCounterButtons,
7201 Fail("cannot create gadget");
7203 level_editor_gadget[id] = gi;
7204 right_gadget_border[id] =
7205 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
7207 x += gi->width + ED_GADGET_SMALL_DISTANCE; // up count button
7213 static void CreateDrawingAreas(void)
7217 // these values are not constant, but can change at runtime
7218 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
7219 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
7221 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
7223 struct GadgetInfo *gi;
7224 int id = drawingarea_info[i].gadget_id;
7225 int type_id = drawingarea_info[i].gadget_type_id;
7226 int x = SX + ED_AREA_SETTINGS_X(drawingarea_info[i]);
7227 int y = SY + ED_AREA_SETTINGS_Y(drawingarea_info[i]);
7228 int area_xsize = drawingarea_info[i].area_xsize;
7229 int area_ysize = drawingarea_info[i].area_ysize;
7230 int item_size = (id == GADGET_ID_DRAWING_LEVEL ?
7231 ed_tilesize : ED_DRAWINGAREA_TILE_SIZE);
7232 unsigned int event_mask =
7233 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
7234 GD_EVENT_OFF_BORDERS | GD_EVENT_PIXEL_PRECISE;
7237 Fail("'drawingarea_info' structure corrupted at index %d -- please fix", i);
7239 // determine horizontal position to the right of specified gadget
7240 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
7241 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
7242 ED_DRAWINGAREA_TEXT_DISTANCE);
7244 // determine horizontal offset for leading text
7245 if (drawingarea_info[i].text_left != NULL)
7246 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
7248 gi = CreateGadget(GDI_CUSTOM_ID, id,
7249 GDI_CUSTOM_TYPE_ID, type_id,
7252 GDI_TYPE, GD_TYPE_DRAWING_AREA,
7253 GDI_AREA_SIZE, area_xsize, area_ysize,
7254 GDI_ITEM_SIZE, item_size, item_size,
7255 GDI_EVENT_MASK, event_mask,
7256 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
7257 GDI_CALLBACK_ACTION, HandleDrawingAreas,
7261 Fail("cannot create gadget");
7263 level_editor_gadget[id] = gi;
7264 right_gadget_border[id] =
7265 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
7269 static void CreateTextInputGadgets(void)
7271 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
7272 int max_infotext_len = getMaxInfoTextLength();
7275 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
7277 int gd_x1 = gd->src_x;
7278 int gd_y1 = gd->src_y;
7279 int gd_x2 = gd->src_x + gd->active_xoffset;
7280 int gd_y2 = gd->src_y + gd->active_yoffset;
7281 struct GadgetInfo *gi;
7282 unsigned int event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7283 char infotext[MAX_OUTPUT_LINESIZE + 1];
7284 int id = textinput_info[i].gadget_id;
7285 int type_id = textinput_info[i].gadget_type_id;
7289 Fail("'textinput_info' structure corrupted at index %d -- please fix", i);
7291 if (i == ED_TEXTINPUT_ID_ELEMENT_NAME)
7293 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
7294 int border_size = gd->border_size;
7295 int font_nr = FONT_INPUT_1;
7296 int font_height = getFontHeight(font_nr);
7297 int xoffset = element_border + TILEX + element_border + 3 * border_size;
7298 int yoffset = element_border + (TILEY - font_height) / 2;
7300 x = (editor.settings.element_name.x != -1 ?
7301 editor.settings.element_name.x :
7302 editor.settings.element_graphic.x + xoffset) - border_size;
7303 y = (editor.settings.element_name.y != -1 ?
7304 editor.settings.element_name.y :
7305 editor.settings.element_graphic.y + yoffset) - border_size;
7309 x = ED_SETTINGS_X(textinput_info[i].x);
7310 y = ED_SETTINGS_Y(textinput_info[i].y);
7313 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
7314 infotext[max_infotext_len] = '\0';
7316 gi = CreateGadget(GDI_CUSTOM_ID, id,
7317 GDI_CUSTOM_TYPE_ID, type_id,
7318 GDI_INFO_TEXT, infotext,
7321 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
7322 GDI_TEXT_VALUE, textinput_info[i].value,
7323 GDI_TEXT_SIZE, textinput_info[i].size,
7324 GDI_TEXT_FONT, FONT_INPUT_1,
7325 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7326 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7327 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7328 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7329 GDI_DESIGN_WIDTH, gd->width,
7330 GDI_EVENT_MASK, event_mask,
7331 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7332 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
7336 Fail("cannot create gadget");
7338 level_editor_gadget[id] = gi;
7342 static void CreateTextAreaGadgets(void)
7344 int max_infotext_len = getMaxInfoTextLength();
7347 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
7349 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXTAREA];
7350 int gd_x1 = gd->src_x;
7351 int gd_y1 = gd->src_y;
7352 int gd_x2 = gd->src_x + gd->active_xoffset;
7353 int gd_y2 = gd->src_y + gd->active_yoffset;
7354 struct GadgetInfo *gi;
7355 unsigned int event_mask = GD_EVENT_TEXT_LEAVING;
7356 char infotext[MAX_OUTPUT_LINESIZE + 1];
7357 int id = textarea_info[i].gadget_id;
7358 int type_id = textarea_info[i].gadget_type_id;
7359 int area_xsize = textarea_info[i].xsize;
7360 int area_ysize = textarea_info[i].ysize;
7363 Fail("'textarea_info' structure corrupted at index %d -- please fix", i);
7365 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
7366 infotext[max_infotext_len] = '\0';
7368 gi = CreateGadget(GDI_CUSTOM_ID, id,
7369 GDI_CUSTOM_TYPE_ID, type_id,
7370 GDI_INFO_TEXT, infotext,
7371 GDI_X, SX + ED_SETTINGS_X(textarea_info[i].x),
7372 GDI_Y, SY + ED_SETTINGS_Y(textarea_info[i].y),
7373 GDI_TYPE, GD_TYPE_TEXT_AREA,
7374 GDI_AREA_SIZE, area_xsize, area_ysize,
7375 GDI_TEXT_FONT, FONT_INPUT_1,
7376 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7377 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7378 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7379 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7380 GDI_DESIGN_WIDTH, gd->width,
7381 GDI_EVENT_MASK, event_mask,
7382 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7383 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
7387 Fail("cannot create gadget");
7389 level_editor_gadget[id] = gi;
7393 static void CreateSelectboxGadgets(void)
7395 int max_infotext_len = getMaxInfoTextLength();
7398 for (i = 0; i < ED_NUM_SELECTBOX; i++)
7400 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_SELECTBOX_INPUT];
7401 struct GraphicInfo *gd2 = &graphic_info[IMG_EDITOR_SELECTBOX_BUTTON];
7402 int gd_x1 = gd->src_x;
7403 int gd_y1 = gd->src_y;
7404 int gd_x2 = gd->src_x + gd->active_xoffset;
7405 int gd_y2 = gd->src_y + gd->active_yoffset;
7406 int selectbox_button_xsize = gd2->width;
7407 struct GadgetInfo *gi;
7408 char infotext[MAX_OUTPUT_LINESIZE + 1];
7409 int id = selectbox_info[i].gadget_id;
7410 int type_id = selectbox_info[i].gadget_type_id;
7411 int x = SX + ED_SETTINGS_X(selectbox_info[i].x);
7412 int y = SY + ED_SETTINGS_Y(selectbox_info[i].y);
7413 unsigned int event_mask =
7414 GD_EVENT_RELEASED | GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7417 Fail("'selectbox_info' structure corrupted at index %d -- please fix", i);
7419 if (selectbox_info[i].size == -1) // dynamically determine size
7421 // (we cannot use -1 for uninitialized values if we directly compare
7422 // with results from strlen(), because the '<' and '>' operation will
7423 // implicitely cast -1 to an unsigned integer value!)
7424 selectbox_info[i].size = 0;
7426 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
7427 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
7428 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
7430 selectbox_info[i].size++; // add one character empty space
7433 // determine horizontal position to the right of specified gadget
7434 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
7435 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
7436 ED_GADGET_TEXT_DISTANCE);
7438 // determine horizontal offset for leading text
7439 if (selectbox_info[i].text_left != NULL)
7440 x += getTextWidthForGadget(selectbox_info[i].text_left);
7442 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
7443 infotext[max_infotext_len] = '\0';
7445 gi = CreateGadget(GDI_CUSTOM_ID, id,
7446 GDI_CUSTOM_TYPE_ID, type_id,
7447 GDI_INFO_TEXT, infotext,
7450 GDI_TYPE, GD_TYPE_SELECTBOX,
7451 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
7452 GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
7453 GDI_TEXT_SIZE, selectbox_info[i].size,
7454 GDI_TEXT_FONT, FONT_INPUT_1,
7455 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7456 GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
7457 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7458 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7459 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7460 GDI_BORDER_SIZE_SELECTBUTTON, selectbox_button_xsize,
7461 GDI_DESIGN_WIDTH, gd->width,
7462 GDI_EVENT_MASK, event_mask,
7463 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7464 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
7468 Fail("cannot create gadget");
7470 level_editor_gadget[id] = gi;
7471 right_gadget_border[id] =
7472 getRightGadgetBorder(gi, selectbox_info[i].text_right);
7476 static void CreateTextbuttonGadgets(void)
7478 int max_infotext_len = getMaxInfoTextLength();
7481 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
7483 int id = textbutton_info[i].gadget_id;
7484 int type_id = textbutton_info[i].gadget_type_id;
7486 ((id >= GADGET_ID_LEVELCONFIG_LEVEL && id <= GADGET_ID_LEVELCONFIG_ENGINE) ||
7487 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE));
7489 (is_tab_button ? IMG_EDITOR_TABBUTTON : IMG_EDITOR_TEXTBUTTON);
7490 int gadget_distance =
7491 (is_tab_button ? ED_GADGET_SMALL_DISTANCE : ED_GADGET_TEXT_DISTANCE);
7492 struct GraphicInfo *gd = &graphic_info[graphic];
7493 int gd_x1 = gd->src_x;
7494 int gd_y1 = gd->src_y;
7495 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7496 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7497 int gd_x1a = gd->src_x + gd->active_xoffset;
7498 int gd_y1a = gd->src_y + gd->active_yoffset;
7499 int border_xsize = gd->border_size + gd->draw_xoffset;
7500 int border_ysize = gd->border_size;
7501 struct GadgetInfo *gi;
7502 unsigned int event_mask = GD_EVENT_RELEASED;
7503 char infotext[MAX_OUTPUT_LINESIZE + 1];
7504 int x = SX + ED_SETTINGS_X(textbutton_info[i].x);
7505 int y = SY + ED_SETTINGS_Y(textbutton_info[i].y);
7508 Fail("'textbutton_info' structure corrupted at index %d -- please fix", i);
7510 if (textbutton_info[i].size == -1) // dynamically determine size
7511 textbutton_info[i].size = strlen(textbutton_info[i].text);
7513 sprintf(infotext, "%s", textbutton_info[i].infotext);
7514 infotext[max_infotext_len] = '\0';
7516 // determine horizontal position to the right of specified gadget
7517 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7519 int gadget_id_align = textbutton_info[i].gadget_id_align;
7521 x = right_gadget_border[gadget_id_align] + gadget_distance;
7523 if (textbutton_info[i].y == -1)
7524 y = level_editor_gadget[gadget_id_align]->y;
7527 // determine horizontal offset for leading text
7528 if (textbutton_info[i].text_left != NULL)
7529 x += getTextWidthForGadget(textbutton_info[i].text_left);
7531 gi = CreateGadget(GDI_CUSTOM_ID, id,
7532 GDI_CUSTOM_TYPE_ID, type_id,
7533 GDI_IMAGE_ID, graphic,
7534 GDI_INFO_TEXT, infotext,
7537 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
7538 GDI_TEXT_VALUE, textbutton_info[i].text,
7539 GDI_TEXT_SIZE, textbutton_info[i].size,
7540 GDI_TEXT_FONT, FONT_INPUT_2,
7541 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2_ACTIVE,
7542 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7543 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7544 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7545 GDI_BORDER_SIZE, border_xsize, border_ysize,
7546 GDI_DESIGN_WIDTH, gd->width,
7547 GDI_DECORATION_SHIFTING, 1, 1,
7548 GDI_EVENT_MASK, event_mask,
7549 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7550 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
7554 Fail("cannot create gadget");
7556 level_editor_gadget[id] = gi;
7557 right_gadget_border[id] =
7558 getRightGadgetBorder(gi, textbutton_info[i].text_right);
7562 static void CreateGraphicbuttonGadgets(void)
7564 struct GadgetInfo *gi;
7567 // create buttons for scrolling of drawing area and element list
7568 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
7570 int id = graphicbutton_info[i].gadget_id;
7571 int type_id = graphicbutton_info[i].gadget_type_id;
7572 int x = SX + ED_SETTINGS_X(graphicbutton_info[i].x);
7573 int y = SY + ED_SETTINGS_Y(graphicbutton_info[i].y);
7574 int graphic = graphicbutton_info[i].graphic;
7575 struct GraphicInfo *gd = &graphic_info[graphic];
7576 int gd_x1 = gd->src_x;
7577 int gd_y1 = gd->src_y;
7578 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7579 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7580 unsigned int event_mask = GD_EVENT_RELEASED;
7583 Fail("'graphicbutton_info' structure corrupted at index %d -- please fix", i);
7585 // determine horizontal position to the right of specified gadget
7586 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7587 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
7588 ED_GADGET_TEXT_DISTANCE);
7590 // determine horizontal offset for leading text
7591 if (graphicbutton_info[i].text_left != NULL)
7592 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
7594 gi = CreateGadget(GDI_CUSTOM_ID, id,
7595 GDI_CUSTOM_TYPE_ID, type_id,
7596 GDI_IMAGE_ID, graphic,
7597 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
7600 GDI_WIDTH, gd->width,
7601 GDI_HEIGHT, gd->height,
7602 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7603 GDI_STATE, GD_BUTTON_UNPRESSED,
7604 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7605 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7606 GDI_EVENT_MASK, event_mask,
7607 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7608 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
7612 Fail("cannot create gadget");
7614 level_editor_gadget[id] = gi;
7615 right_gadget_border[id] =
7616 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
7620 static void CreateScrollbarGadgets(void)
7624 // these values are not constant, but can change at runtime
7625 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
7626 SX + ED_SCROLL_HORIZONTAL_XPOS;
7627 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
7628 SY + ED_SCROLL_HORIZONTAL_YPOS;
7629 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
7630 ED_SCROLL_HORIZONTAL_XSIZE;
7631 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
7632 ED_SCROLL_HORIZONTAL_YSIZE;
7633 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
7634 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
7635 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
7636 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
7638 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
7639 SX + ED_SCROLL_VERTICAL_XPOS;
7640 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
7641 SY + ED_SCROLL_VERTICAL_YPOS;
7642 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
7643 ED_SCROLL_VERTICAL_XSIZE;
7644 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
7645 ED_SCROLL_VERTICAL_YSIZE;
7646 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
7647 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
7648 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
7649 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
7651 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
7652 PX + ED_SCROLL2_VERTICAL_XPOS;
7653 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
7654 PY + ED_SCROLL2_VERTICAL_YPOS;
7655 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
7656 ED_SCROLL2_VERTICAL_XSIZE;
7657 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
7658 ED_SCROLL2_VERTICAL_YSIZE;
7659 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = PX;
7660 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = PY;
7661 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width = PXSIZE;
7662 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = PYSIZE;
7664 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
7666 int id = scrollbar_info[i].gadget_id;
7667 int type_id = scrollbar_info[i].gadget_type_id;
7668 int graphic = scrollbar_info[i].graphic;
7669 struct GraphicInfo *gd = &graphic_info[graphic];
7670 int gd_x1 = gd->src_x;
7671 int gd_y1 = gd->src_y;
7672 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7673 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7674 struct GadgetInfo *gi;
7675 int items_max, items_visible, item_position;
7676 unsigned int event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
7679 Fail("'scrollbar_info' structure corrupted at index %d -- please fix", i);
7681 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
7683 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
7684 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
7685 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
7687 else // drawing area scrollbars
7689 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
7691 items_max = MAX(lev_fieldx + 2, ed_fieldx);
7692 items_visible = ed_fieldx;
7697 items_max = MAX(lev_fieldy + 2, ed_fieldy);
7698 items_visible = ed_fieldy;
7703 gi = CreateGadget(GDI_CUSTOM_ID, id,
7704 GDI_CUSTOM_TYPE_ID, type_id,
7705 GDI_IMAGE_ID, graphic,
7706 GDI_INFO_TEXT, scrollbar_info[i].infotext,
7707 GDI_X, scrollbar_pos[i].x,
7708 GDI_Y, scrollbar_pos[i].y,
7709 GDI_WIDTH, scrollbar_pos[i].width,
7710 GDI_HEIGHT, scrollbar_pos[i].height,
7711 GDI_TYPE, scrollbar_info[i].type,
7712 GDI_SCROLLBAR_ITEMS_MAX, items_max,
7713 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7714 GDI_SCROLLBAR_ITEM_POSITION, item_position,
7715 GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
7716 GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
7717 GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
7718 GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
7719 GDI_STATE, GD_BUTTON_UNPRESSED,
7720 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7721 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7722 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7723 GDI_EVENT_MASK, event_mask,
7724 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7725 GDI_CALLBACK_ACTION, HandleControlButtons,
7729 Fail("cannot create gadget");
7731 level_editor_gadget[id] = gi;
7735 static void CreateCheckbuttonGadgets(void)
7737 struct GadgetInfo *gi;
7740 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
7742 int id = checkbutton_info[i].gadget_id;
7743 int type_id = checkbutton_info[i].gadget_type_id;
7744 int graphic = (id == GADGET_ID_STICK_ELEMENT ? IMG_EDITOR_STICKYBUTTON :
7745 IMG_EDITOR_CHECKBOX);
7746 struct GraphicInfo *gd = &graphic_info[graphic];
7747 int gd_x1 = gd->src_x;
7748 int gd_y1 = gd->src_y;
7749 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7750 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7751 int gd_x1a = gd->src_x + gd->active_xoffset;
7752 int gd_y1a = gd->src_y + gd->active_yoffset;
7753 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7754 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7755 int x = SX + ED_SETTINGS_X(checkbutton_info[i].x);
7756 int y = SY + ED_SETTINGS_Y(checkbutton_info[i].y);
7757 unsigned int event_mask = GD_EVENT_PRESSED;
7760 Fail("'checkbutton_info' structure corrupted at index %d -- please fix", i);
7762 // determine horizontal position to the right of specified gadget
7763 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7764 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
7765 ED_GADGET_TEXT_DISTANCE);
7767 // determine horizontal offset for leading text
7768 if (checkbutton_info[i].text_left != NULL)
7769 x += getTextWidthForGadget(checkbutton_info[i].text_left);
7771 gi = CreateGadget(GDI_CUSTOM_ID, id,
7772 GDI_CUSTOM_TYPE_ID, type_id,
7773 GDI_IMAGE_ID, graphic,
7774 GDI_INFO_TEXT, checkbutton_info[i].infotext,
7777 GDI_WIDTH, gd->width,
7778 GDI_HEIGHT, gd->height,
7779 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
7780 GDI_CHECKED, *checkbutton_info[i].value,
7781 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7782 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7783 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7784 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7785 GDI_EVENT_MASK, event_mask,
7786 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7787 GDI_CALLBACK_ACTION, HandleCheckbuttons,
7791 Fail("cannot create gadget");
7793 level_editor_gadget[id] = gi;
7794 right_gadget_border[id] =
7795 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
7799 static void CreateRadiobuttonGadgets(void)
7801 int graphic = IMG_EDITOR_RADIOBUTTON;
7802 struct GraphicInfo *gd = &graphic_info[graphic];
7803 int gd_x1 = gd->src_x;
7804 int gd_y1 = gd->src_y;
7805 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7806 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7807 int gd_x1a = gd->src_x + gd->active_xoffset;
7808 int gd_y1a = gd->src_y + gd->active_yoffset;
7809 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7810 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7811 struct GadgetInfo *gi;
7814 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
7816 int id = radiobutton_info[i].gadget_id;
7817 int type_id = radiobutton_info[i].gadget_type_id;
7818 int x = SX + ED_SETTINGS_X(radiobutton_info[i].x);
7819 int y = SY + ED_SETTINGS_Y(radiobutton_info[i].y);
7820 unsigned int event_mask = GD_EVENT_PRESSED;
7823 Fail("'radiobutton_info' structure corrupted at index %d -- please fix", i);
7826 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
7828 // determine horizontal position to the right of specified gadget
7829 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
7830 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
7831 ED_GADGET_TEXT_DISTANCE);
7833 // determine horizontal offset for leading text
7834 if (radiobutton_info[i].text_left != NULL)
7835 x += getTextWidthForGadget(radiobutton_info[i].text_left);
7837 gi = CreateGadget(GDI_CUSTOM_ID, id,
7838 GDI_CUSTOM_TYPE_ID, type_id,
7839 GDI_IMAGE_ID, graphic,
7840 GDI_INFO_TEXT, radiobutton_info[i].infotext,
7843 GDI_WIDTH, gd->width,
7844 GDI_HEIGHT, gd->height,
7845 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
7846 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
7847 GDI_CHECKED, checked,
7848 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7849 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7850 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7851 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7852 GDI_EVENT_MASK, event_mask,
7853 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7854 GDI_CALLBACK_ACTION, HandleRadiobuttons,
7858 Fail("cannot create gadget");
7860 level_editor_gadget[id] = gi;
7861 right_gadget_border[id] =
7862 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
7866 void CreateLevelEditorGadgets(void)
7868 // force EDITOR font inside level editor
7869 SetFontStatus(GAME_MODE_EDITOR);
7871 // these values are not constant, but can change at runtime
7872 ed_fieldx = MAX_ED_FIELDX - 1;
7873 ed_fieldy = MAX_ED_FIELDY - 1;
7875 num_editor_gadgets = NUM_EDITOR_GADGETS;
7877 // Debug("editor", "allocating %d gadgets ...\n", num_editor_gadgets);
7879 level_editor_gadget =
7880 checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *));
7881 right_gadget_border =
7882 checked_calloc(num_editor_gadgets * sizeof(int));
7884 // set number of empty (padding) element buttons to maximum number of buttons
7885 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS;
7887 editor_el_empty = checked_calloc(num_editor_el_empty * sizeof(int));
7888 editor_el_empty_ptr = editor_el_empty;
7890 use_permanent_palette = !editor.palette.show_as_separate_screen;
7892 InitGadgetScreenBorders(-1, INFOTEXT_YPOS);
7894 ReinitializeElementList();
7896 CreateControlButtons();
7897 CreateScrollbarGadgets();
7899 // order of function calls is important because of cross-references
7900 CreateCheckbuttonGadgets();
7901 CreateCounterButtons();
7902 CreateRadiobuttonGadgets();
7903 CreateTextInputGadgets();
7904 CreateTextAreaGadgets();
7905 CreateSelectboxGadgets();
7906 CreateGraphicbuttonGadgets();
7907 CreateTextbuttonGadgets();
7908 CreateDrawingAreas();
7913 void FreeLevelEditorGadgets(void)
7917 // Debug("editor", "freeing %d gadgets ...\n", num_editor_gadgets);
7919 for (i = 0; i < num_editor_gadgets; i++)
7921 FreeGadget(level_editor_gadget[i]);
7923 level_editor_gadget[i] = NULL;
7926 checked_free(level_editor_gadget);
7927 checked_free(right_gadget_border);
7929 checked_free(editor_el_empty);
7932 static void MapCounterButtons(int id)
7934 int font_nr = FONT_TEXT_1;
7935 int font_height = getFontHeight(font_nr);
7936 int gadget_id_down = counterbutton_info[id].gadget_id_down;
7937 int gadget_id_text = counterbutton_info[id].gadget_id_text;
7938 int gadget_id_up = counterbutton_info[id].gadget_id_up;
7939 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
7940 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
7941 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
7942 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
7943 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7944 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7945 int yoffset = (gi_down->height - font_height) / 2;
7946 int x_left = gi_down->x - xoffset_left;
7947 int x_right; // set after gadget position was modified
7948 int y_above = gi_down->y - yoffset_above;
7950 int y; // set after gadget position was modified
7952 // counter limits must be changed first to prevent value truncation
7953 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
7954 counterbutton_info[id].max_value);
7956 // right text position might have changed after setting position above
7957 x_right = gi_up->x + gi_up->width + xoffset_right;
7959 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
7961 // set position for "value[1,2,3,4]" counter gadgets (score in most cases)
7962 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
7963 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
7965 ModifyGadget(gi_down, GDI_Y,
7966 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7967 ModifyGadget(gi_text, GDI_Y,
7968 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7969 ModifyGadget(gi_up, GDI_Y,
7970 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7973 // vertical position might have changed after setting position above
7974 y = gi_up->y + yoffset;
7976 if (counterbutton_info[id].text_above)
7977 DrawText(x, y_above, counterbutton_info[id].text_above, font_nr);
7979 if (counterbutton_info[id].text_left)
7980 DrawText(x_left, y, counterbutton_info[id].text_left, font_nr);
7982 if (counterbutton_info[id].text_right)
7983 DrawText(x_right, y, counterbutton_info[id].text_right, font_nr);
7990 static void MapControlButtons(void)
7995 // map toolbox buttons (excluding special CE toolbox buttons)
7996 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
7997 MapGadget(level_editor_gadget[i]);
7999 // map toolbox buttons (element properties buttons)
8000 for (i = ED_NUM_CTRL1_4_BUTTONS; i < ED_NUM_CTRL1_7_BUTTONS; i++)
8001 MapGadget(level_editor_gadget[i]);
8003 if (use_permanent_palette)
8005 // map buttons to select elements
8006 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
8007 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
8008 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
8009 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
8010 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
8013 // map buttons to select level
8014 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
8015 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
8016 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
8017 MapCounterButtons(counter_id);
8020 static void MapDrawingArea(int id)
8022 int font_nr = FONT_TEXT_1;
8023 int font_height = getFontHeight(font_nr);
8024 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
8025 int area_xsize = gi->drawing.area_xsize;
8026 int area_ysize = gi->drawing.area_ysize;
8027 int xoffset_left = getTextWidthForDrawingArea(drawingarea_info[id].text_left);
8028 int xoffset_below = getTextWidth(drawingarea_info[id].text_below, font_nr);
8029 int x_left = gi->x - xoffset_left;
8030 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
8031 int x_above = gi->x - ED_DRAWINGAREA_BORDER_SIZE;
8032 int x_below = gi->x + (gi->width - xoffset_below) / 2;
8033 int y_side = gi->y + (gi->height - font_height) / 2;
8034 int y_above = gi->y - font_height - ED_DRAWINGAREA_TEXT_DISTANCE;
8035 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
8037 if (drawingarea_info[id].text_left)
8038 DrawText(x_left, y_side, drawingarea_info[id].text_left, font_nr);
8040 if (drawingarea_info[id].text_right)
8041 DrawText(x_right, y_side, drawingarea_info[id].text_right, font_nr);
8043 if (drawingarea_info[id].text_above)
8044 DrawText(x_above, y_above, drawingarea_info[id].text_above, font_nr);
8046 if (drawingarea_info[id].text_below)
8047 DrawText(x_below, y_below, drawingarea_info[id].text_below, font_nr);
8049 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
8051 DrawElementBorder(gi->x, gi->y,
8052 area_xsize * ED_DRAWINGAREA_TILE_SIZE,
8053 area_ysize * ED_DRAWINGAREA_TILE_SIZE, TRUE);
8055 DrawDrawingArea(id);
8061 static void MapTextInputGadget(int id)
8063 int font_nr = FONT_TEXT_1;
8064 int font_height = getFontHeight(font_nr);
8065 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
8066 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8067 int x_above = ED_SETTINGS_X(textinput_info[id].x);
8068 int y_above = ED_SETTINGS_Y(textinput_info[id].y) - yoffset_above;
8070 if (textinput_info[id].text_above)
8071 DrawTextS(x_above, y_above, font_nr, textinput_info[id].text_above);
8073 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
8078 static void MapTextAreaGadget(int id)
8080 int font_nr = FONT_TEXT_1;
8081 int font_height = getFontHeight(font_nr);
8082 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
8083 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8084 int x_above = ED_SETTINGS_X(textarea_info[id].x);
8085 int y_above = ED_SETTINGS_Y(textarea_info[id].y) - yoffset_above;
8086 char *text_above = textarea_info[id].text_above;
8088 if (gi->textarea.cropped && textarea_info[id].text_above_cropped)
8089 text_above = textarea_info[id].text_above_cropped;
8092 DrawTextS(x_above, y_above, font_nr, text_above);
8094 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
8099 static void MapSelectboxGadget(int id)
8101 int font_nr = FONT_TEXT_1;
8102 int font_height = getFontHeight(font_nr);
8103 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
8104 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
8105 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8106 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8107 int yoffset = (gi->height - font_height) / 2;
8108 int x_left = gi->x - xoffset_left;
8109 int x_right = gi->x + gi->width + xoffset_right;
8110 int y_above = gi->y - yoffset_above;
8112 int y = gi->y + yoffset;
8114 if (selectbox_info[id].text_above)
8115 DrawText(x, y_above, selectbox_info[id].text_above, font_nr);
8117 if (selectbox_info[id].text_left)
8118 DrawText(x_left, y, selectbox_info[id].text_left, font_nr);
8120 if (selectbox_info[id].text_right)
8121 DrawText(x_right, y, selectbox_info[id].text_right, font_nr);
8123 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
8128 static void MapTextbuttonGadget(int id)
8130 int font_nr = FONT_TEXT_1;
8131 int font_height = getFontHeight(font_nr);
8132 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
8133 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
8134 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8135 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8136 int yoffset = (gi->height - font_height) / 2;
8137 int x_left = gi->x - xoffset_left;
8138 int x_right = gi->x + gi->width + xoffset_right;
8139 int y_above = gi->y - yoffset_above;
8141 int y = gi->y + yoffset;
8143 // only show button to delete change pages when more than minimum pages
8144 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
8145 custom_element.num_change_pages == MIN_CHANGE_PAGES)
8148 if (textbutton_info[id].text_above)
8149 DrawText(x, y_above, textbutton_info[id].text_above, font_nr);
8151 if (textbutton_info[id].text_left)
8152 DrawText(x_left, y, textbutton_info[id].text_left, font_nr);
8154 if (textbutton_info[id].text_right)
8155 DrawText(x_right, y, textbutton_info[id].text_right, font_nr);
8160 static void MapGraphicbuttonGadget(int id)
8162 int font_nr = FONT_TEXT_1;
8163 int font_height = getFontHeight(font_nr);
8164 struct GadgetInfo *gi = level_editor_gadget[graphicbutton_info[id].gadget_id];
8165 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
8166 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8167 int yoffset = (gi->height - font_height) / 2;
8168 int x_left = gi->x - xoffset_left;
8169 int x_right = gi->x + gi->width + xoffset_right;
8170 int y = gi->y + yoffset;
8172 if (graphicbutton_info[id].text_left)
8173 DrawText(x_left, y, graphicbutton_info[id].text_left, font_nr);
8175 if (graphicbutton_info[id].text_right)
8176 DrawText(x_right, y, graphicbutton_info[id].text_right, font_nr);
8181 static void MapRadiobuttonGadget(int id)
8183 int font_nr = FONT_TEXT_1;
8184 int font_height = getFontHeight(font_nr);
8185 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
8186 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
8187 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8188 int yoffset = (gi->height - font_height) / 2;
8189 int x_left = gi->x - xoffset_left;
8190 int x_right = gi->x + gi->width + xoffset_right;
8191 int y = gi->y + yoffset;
8193 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
8195 if (radiobutton_info[id].text_left)
8196 DrawText(x_left, y, radiobutton_info[id].text_left, font_nr);
8198 if (radiobutton_info[id].text_right)
8199 DrawText(x_right, y, radiobutton_info[id].text_right, font_nr);
8201 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
8206 static void MapCheckbuttonGadget(int id)
8208 int font_nr = FONT_TEXT_1;
8209 int font_height = getFontHeight(font_nr);
8210 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
8211 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
8212 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8213 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8214 int yoffset = (gi->height - font_height) / 2;
8215 int y_above = gi->y - yoffset_above;
8217 int x_left, x_right, y; // set after gadget position was modified
8219 // set position for gadgets with dynamically determined position
8220 if (checkbutton_info[id].x != -1) // do not change dynamic positions
8221 ModifyGadget(gi, GDI_X, SX + ED_SETTINGS_X(checkbutton_info[id].x), GDI_END);
8222 ModifyGadget(gi, GDI_Y, SY + ED_SETTINGS_Y(checkbutton_info[id].y), GDI_END);
8224 x_left = gi->x - xoffset_left;
8225 x_right = gi->x + gi->width + xoffset_right;
8226 y = gi->y + yoffset;
8228 if (checkbutton_info[id].text_above)
8229 DrawText(x, y_above, checkbutton_info[id].text_above, font_nr);
8231 if (checkbutton_info[id].text_left)
8232 DrawText(x_left, y, checkbutton_info[id].text_left, font_nr);
8234 if (checkbutton_info[id].text_right)
8235 DrawText(x_right, y, checkbutton_info[id].text_right, font_nr);
8237 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
8242 static void MapMainDrawingArea(void)
8244 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
8245 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
8248 if (suppressBorderElement())
8250 no_horizontal_scrollbar = (lev_fieldx <= ed_fieldx);
8251 no_vertical_scrollbar = (lev_fieldy <= ed_fieldy);
8254 for (i = ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
8256 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
8257 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
8258 no_horizontal_scrollbar) ||
8259 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
8260 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
8261 no_vertical_scrollbar))
8264 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
8267 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
8269 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
8270 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
8273 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
8276 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
8279 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
8283 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
8285 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
8286 i == GADGET_ID_CUSTOM_COPY_TO ||
8287 i == GADGET_ID_CUSTOM_EXCHANGE ||
8288 i == GADGET_ID_CUSTOM_COPY ||
8289 i == GADGET_ID_CUSTOM_PASTE)
8292 MapGadget(level_editor_gadget[i]);
8294 UnmapGadget(level_editor_gadget[i]);
8299 static void MapLevelEditorToolboxCustomGadgets(void)
8301 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
8304 static void MapLevelEditorToolboxCustomGadgetsIfNeeded(void)
8306 if (IS_CUSTOM_ELEMENT(properties_element) ||
8307 IS_GROUP_ELEMENT(properties_element) ||
8308 IS_EMPTY_ELEMENT(properties_element))
8309 MapLevelEditorToolboxCustomGadgets();
8312 static void UnmapLevelEditorToolboxCustomGadgets(void)
8314 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
8317 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
8321 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
8323 if (i != GADGET_ID_SINGLE_ITEMS &&
8324 i != GADGET_ID_PICK_ELEMENT)
8326 struct GadgetInfo *gi = level_editor_gadget[i];
8334 int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
8335 struct GraphicInfo *gd = &graphic_info[graphic];
8339 BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
8340 gi->width, gi->height, gi->x, gi->y);
8342 redraw_mask |= REDRAW_DOOR_3;
8348 static void MapLevelEditorToolboxDrawingGadgets(void)
8350 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
8353 static void UnmapLevelEditorToolboxDrawingGadgets(void)
8355 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
8358 static void UnmapDrawingArea(int id)
8360 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
8363 static void UnmapLevelEditorFieldGadgets(void)
8367 for (i = 0; i < num_editor_gadgets; i++)
8368 if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
8369 level_editor_gadget[i]->y))
8370 UnmapGadget(level_editor_gadget[i]);
8373 void UnmapLevelEditorGadgets(void)
8377 for (i = 0; i < num_editor_gadgets; i++)
8378 UnmapGadget(level_editor_gadget[i]);
8381 static void ResetUndoBuffer(void)
8383 undo_buffer_position = -1;
8384 undo_buffer_steps = -1;
8385 redo_buffer_steps = 0;
8387 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8389 level.changed = FALSE;
8392 static void DrawEditModeWindowExt(boolean remap_toolbox_gadgets)
8394 if (remap_toolbox_gadgets)
8396 ModifyEditorElementList();
8397 RedrawDrawingElements();
8400 if (edit_mode == ED_MODE_LEVELCONFIG)
8401 DrawLevelConfigWindow();
8402 else if (edit_mode == ED_MODE_PROPERTIES)
8403 DrawPropertiesWindow();
8404 else if (edit_mode == ED_MODE_PALETTE)
8405 DrawPaletteWindow();
8406 else // edit_mode == ED_MODE_DRAWING
8407 DrawDrawingWindowExt(remap_toolbox_gadgets);
8410 static void DrawEditModeWindow(void)
8412 DrawEditModeWindowExt(TRUE);
8415 static void DrawEditModeWindow_PlayfieldOnly(void)
8417 DrawEditModeWindowExt(FALSE);
8420 static void ChangeEditModeWindow(int new_edit_mode)
8422 edit_mode = (new_edit_mode != edit_mode ? new_edit_mode : ED_MODE_DRAWING);
8424 DrawEditModeWindow();
8427 static boolean LevelChanged(void)
8429 boolean field_changed = FALSE;
8432 for (y = 0; y < lev_fieldy; y++)
8433 for (x = 0; x < lev_fieldx; x++)
8434 if (Tile[x][y] != level.field[x][y])
8435 field_changed = TRUE;
8437 return (level.changed || field_changed);
8440 static boolean PrepareSavingIntoPersonalLevelSet(void)
8442 static LevelDirTree *last_copied_leveldir = NULL;
8443 static LevelDirTree *last_written_leveldir = NULL;
8444 static int last_copied_level_nr = -1;
8445 static int last_written_level_nr = -1;
8446 LevelDirTree *leveldir_former = leveldir_current;
8447 int level_nr_former = level_nr;
8450 // remember last mod/save so that for current session, we write
8451 // back to the same personal copy, asking only about overwrite.
8452 if (leveldir_current == last_copied_leveldir &&
8453 level_nr == last_copied_level_nr)
8455 // "cd" to personal level set dir (as used when writing last copy)
8456 leveldir_current = last_written_leveldir;
8457 level_nr = last_written_level_nr;
8462 if (!Request("This level is read-only! "
8463 "Save into personal level set?", REQ_ASK))
8466 // "cd" to personal level set dir (for writing copy the first time)
8468 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
8470 // this may happen if "setup.internal.create_user_levelset" is FALSE
8471 // or if file "levelinfo.conf" is missing in personal user level set
8472 if (leveldir_current == NULL)
8474 Request("Cannot find personal level set?!", REQ_CONFIRM);
8476 leveldir_current = leveldir_former;
8481 // find unused level number
8482 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
8484 static char *level_filename = NULL;
8486 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
8488 if (!fileExists(level_filename))
8492 last_copied_leveldir = leveldir_former;
8493 last_copied_level_nr = level_nr_former;
8495 last_written_leveldir = leveldir_current;
8496 last_written_level_nr = level_nr = new_level_nr;
8501 static void ModifyLevelConfigForSavingIntoPersonalLevelSet(char *former_name)
8503 static char *filename_levelinfo = NULL, *mod_name = NULL;
8506 // annotate this copy-and-mod in personal levelinfo.conf
8507 setString(&filename_levelinfo,
8508 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
8510 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
8512 fprintf(file, "\n");
8513 fprintf(file, "# level %d was modified from:\n", level_nr);
8514 fprintf(file, "# - previous level set name: %s\n",
8516 fprintf(file, "# - level within previous set: %d \"%s\"\n",
8517 level.file_info.nr, level.name);
8518 fprintf(file, "# - previous author: %s\n",
8520 fprintf(file, "# - previous save date: ");
8522 if (level.creation_date.src == DATE_SRC_LEVELFILE)
8524 fprintf(file, "%04d-%02d-%02d\n",
8525 level.creation_date.year,
8526 level.creation_date.month,
8527 level.creation_date.day);
8531 fprintf(file, "not recorded\n");
8537 if (level_nr > leveldir_current->last_level)
8538 UpdateUserLevelSet(getLoginName(), NULL, NULL, level_nr + 9);
8540 // else: allow the save even if annotation failed
8542 // now... spray graffiti on the old level vital statistics
8543 // user can change these; just trying to set a good baseline
8545 // don't truncate names for fear of making offensive or silly:
8546 // long-named original author only recorded in levelinfo.conf.
8547 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
8548 if (!strEqual(level.author, leveldir_current->author))
8550 setString(&mod_name, getStringCat3(leveldir_current->author,
8551 " after ", level.author));
8553 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8554 setString(&mod_name,
8555 getStringCat2(leveldir_current->author, " (ed.)"));
8557 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8558 setString(&mod_name, leveldir_current->author);
8560 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
8562 // less worried about truncation here
8563 setString(&mod_name, getStringCat2("Mod: ", level.name));
8564 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
8568 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
8569 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
8573 for (x = 0; x < lev_fieldx; x++)
8574 for (y = 0; y < lev_fieldy; y++)
8575 dst[x][y] = src[x][y];
8578 static int setSelectboxValue(int selectbox_id, int new_value)
8580 int new_index_value = 0;
8583 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
8584 if (selectbox_info[selectbox_id].options[i].value == new_value)
8585 new_index_value = i;
8587 *selectbox_info[selectbox_id].value =
8588 selectbox_info[selectbox_id].options[new_index_value].value;
8590 return new_index_value;
8593 static void setSelectboxSpecialActionVariablesIfNeeded(void)
8597 // change action mode and arg variables according to action type variable
8598 for (i = 0; action_arg_options[i].value != -1; i++)
8600 if (action_arg_options[i].value == custom_element_change.action_type)
8602 int mode = action_arg_options[i].mode;
8604 // only change if corresponding selectbox has changed
8605 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
8606 action_arg_modes[mode])
8607 custom_element_change.action_mode = -1;
8609 // only change if corresponding selectbox has changed
8610 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
8611 action_arg_options[i].options)
8612 custom_element_change.action_arg = -1;
8619 static void setSelectboxSpecialActionOptions(void)
8623 // change action mode and arg selectbox according to action type selectbox
8624 for (i = 0; action_arg_options[i].value != -1; i++)
8626 if (action_arg_options[i].value == custom_element_change.action_type)
8628 int mode = action_arg_options[i].mode;
8630 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
8631 action_arg_modes[mode]);
8632 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
8633 custom_element_change.action_mode);
8635 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
8636 action_arg_options[i].options);
8637 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
8638 custom_element_change.action_arg);
8644 static void copy_custom_element_settings(int element_from, int element_to)
8646 struct ElementInfo *ei_from = &element_info[element_from];
8647 struct ElementInfo *ei_to = &element_info[element_to];
8649 copyElementInfo(ei_from, ei_to);
8652 static void replace_custom_element_in_settings(int element_from,
8657 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8659 struct ElementInfo *ei = &element_info[i];
8661 for (y = 0; y < 3; y++)
8662 for (x = 0; x < 3; x++)
8663 if (ei->content.e[x][y] == element_from)
8664 ei->content.e[x][y] = element_to;
8666 for (j = 0; j < ei->num_change_pages; j++)
8668 struct ElementChangeInfo *change = &ei->change_page[j];
8670 if (change->target_element == element_from)
8671 change->target_element = element_to;
8673 if (change->initial_trigger_element == element_from)
8674 change->initial_trigger_element = element_to;
8676 if (change->action_element == element_from)
8677 change->action_element = element_to;
8679 for (y = 0; y < 3; y++)
8680 for (x = 0; x < 3; x++)
8681 if (change->target_content.e[x][y] == element_from)
8682 change->target_content.e[x][y] = element_to;
8685 if (ei->group != NULL) // group or internal
8686 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
8687 if (ei->group->element[j] == element_from)
8688 ei->group->element[j] = element_to;
8692 static void replace_custom_element_in_playfield(int element_from,
8697 for (x = 0; x < lev_fieldx; x++)
8698 for (y = 0; y < lev_fieldy; y++)
8699 if (Tile[x][y] == element_from)
8700 Tile[x][y] = element_to;
8703 static boolean CopyCustomElement(int element_old, int element_new,
8706 int copy_mode_orig = copy_mode;
8708 if (copy_mode == GADGET_ID_CUSTOM_COPY)
8710 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
8711 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8712 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8714 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
8716 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
8717 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8718 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8720 level.changed = TRUE;
8722 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
8724 Request("Please choose custom element!", REQ_CONFIRM);
8728 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
8730 Request("Please choose group element!", REQ_CONFIRM);
8734 else if (IS_EMPTY_ELEMENT(element_old) && !IS_EMPTY_ELEMENT(element_new))
8736 Request("Please choose empty element!", REQ_CONFIRM);
8742 level.changed = TRUE;
8745 // when modifying custom/group element, ask for copying level template
8746 if (copy_mode_orig != GADGET_ID_CUSTOM_COPY && level.use_custom_template)
8748 if (!AskToCopyAndModifyLevelTemplate())
8752 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
8754 copy_custom_element_settings(element_new, element_old);
8756 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
8758 copy_custom_element_settings(element_old, element_new);
8760 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
8762 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
8763 copy_custom_element_settings(element_new, element_old);
8764 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
8766 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
8767 replace_custom_element_in_settings(element_new, element_old);
8768 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
8770 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
8771 replace_custom_element_in_playfield(element_new, element_old);
8772 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
8775 UpdateCustomElementGraphicGadgets();
8776 DrawPropertiesWindow();
8781 static void CopyCustomElementPropertiesToEditor(int element)
8784 int current_change_page = element_info[element].current_change_page;
8786 // dynamically (re)build selectbox for selecting change page
8787 for (i = 0; i < element_info[element].num_change_pages; i++)
8789 sprintf(options_change_page_strings[i], "%d", i + 1);
8791 options_change_page[i].value = i;
8792 options_change_page[i].text = options_change_page_strings[i];
8795 options_change_page[i].value = -1;
8796 options_change_page[i].text = NULL;
8798 // needed here to initialize combined element properties
8799 InitElementPropertiesEngine(level.game_version);
8801 element_info[element].change =
8802 &element_info[element].change_page[current_change_page];
8804 custom_element = element_info[element];
8805 custom_element_change = *element_info[element].change;
8807 // needed to initially set selectbox options for special action options
8808 setSelectboxSpecialActionOptions();
8810 // needed to initially set selectbox value variables to reliable defaults
8811 for (i = 0; i < ED_NUM_SELECTBOX; i++)
8812 setSelectboxValue(i, *selectbox_info[i].value);
8814 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8815 custom_element_properties[i] = HAS_PROPERTY(element, i);
8817 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8818 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
8820 // ---------- element settings: configure (custom elements) -----------------
8822 // set accessible layer selectbox help value
8823 custom_element.access_type =
8824 (IS_WALKABLE(element) ? EP_WALKABLE :
8825 IS_PASSABLE(element) ? EP_PASSABLE :
8826 custom_element.access_type);
8827 custom_element.access_layer =
8828 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
8829 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
8830 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
8831 custom_element.access_layer);
8832 custom_element.access_protected =
8833 (IS_PROTECTED(element) ? 1 : 0);
8834 custom_element_properties[EP_ACCESSIBLE] =
8835 (IS_ACCESSIBLE_OVER(element) ||
8836 IS_ACCESSIBLE_INSIDE(element) ||
8837 IS_ACCESSIBLE_UNDER(element));
8839 // set walk-to-object action selectbox help value
8840 custom_element.walk_to_action =
8841 (IS_DIGGABLE(element) ? EP_DIGGABLE :
8842 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
8843 IS_DROPPABLE(element) ? EP_DROPPABLE :
8844 IS_THROWABLE(element) ? EP_THROWABLE :
8845 IS_PUSHABLE(element) ? EP_PUSHABLE :
8846 custom_element.walk_to_action);
8847 custom_element_properties[EP_WALK_TO_OBJECT] =
8848 (IS_DIGGABLE(element) ||
8849 IS_COLLECTIBLE_ONLY(element) ||
8850 IS_DROPPABLE(element) ||
8851 IS_THROWABLE(element) ||
8852 IS_PUSHABLE(element));
8854 // set smash targets selectbox help value
8855 custom_element.smash_targets =
8856 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
8857 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
8858 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
8859 custom_element.smash_targets);
8860 custom_element_properties[EP_CAN_SMASH] =
8861 (CAN_SMASH_EVERYTHING(element) ||
8862 CAN_SMASH_ENEMIES(element) ||
8863 CAN_SMASH_PLAYER(element));
8865 // set deadliness selectbox help value
8866 custom_element.deadliness =
8867 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
8868 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
8869 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
8870 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
8871 custom_element.deadliness);
8872 custom_element_properties[EP_DEADLY] =
8873 (DONT_TOUCH(element) ||
8874 DONT_GET_HIT_BY(element) ||
8875 DONT_COLLIDE_WITH(element) ||
8876 DONT_RUN_INTO(element));
8878 // ---------- element settings: advanced (custom elements) ------------------
8880 // set "change by direct action" selectbox help value
8881 custom_element_change.direct_action =
8882 (HAS_CHANGE_EVENT(element, CE_NEXT_TO_PLAYER) ? CE_NEXT_TO_PLAYER :
8883 HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
8884 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
8885 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
8886 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
8887 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
8888 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
8889 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
8890 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
8891 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
8892 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
8893 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
8894 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
8895 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
8896 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
8897 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
8898 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
8899 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
8900 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
8901 HAS_CHANGE_EVENT(element, CE_CLICKED_BY_MOUSE) ? CE_CLICKED_BY_MOUSE :
8902 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_MOUSE) ? CE_PRESSED_BY_MOUSE :
8903 custom_element_change.direct_action);
8905 // set "change by other element action" selectbox help value
8906 custom_element_change.other_action =
8907 (HAS_CHANGE_EVENT(element, CE_PLAYER_NEXT_TO_X) ? CE_PLAYER_NEXT_TO_X :
8908 HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
8909 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
8910 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
8911 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
8912 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
8913 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
8914 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
8915 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
8916 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
8917 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
8918 HAS_CHANGE_EVENT(element, CE_NEXT_TO_X) ? CE_NEXT_TO_X :
8919 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
8920 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
8921 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
8922 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
8923 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
8924 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
8925 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
8926 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
8927 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
8928 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
8929 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
8930 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
8931 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
8932 HAS_CHANGE_EVENT(element, CE_MOUSE_CLICKED_ON_X) ? CE_MOUSE_CLICKED_ON_X :
8933 HAS_CHANGE_EVENT(element, CE_MOUSE_PRESSED_ON_X) ? CE_MOUSE_PRESSED_ON_X :
8934 custom_element_change.other_action);
8937 static void CopyGroupElementPropertiesToEditor(int element)
8939 group_element_info = *element_info[element].group;
8940 custom_element = element_info[element]; // needed for description
8943 static void CopyEmptyElementPropertiesToEditor(int element)
8945 custom_element = element_info[element];
8948 static void CopyClassicElementPropertiesToEditor(int element)
8950 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
8951 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
8952 getMoveIntoAcidProperty(&level, element);
8954 if (MAYBE_DONT_COLLIDE_WITH(element))
8955 custom_element_properties[EP_DONT_COLLIDE_WITH] =
8956 getDontCollideWithProperty(&level, element);
8959 static void CopyElementPropertiesToEditor(int element)
8961 if (IS_CUSTOM_ELEMENT(element))
8962 CopyCustomElementPropertiesToEditor(element);
8963 else if (IS_GROUP_ELEMENT(element))
8964 CopyGroupElementPropertiesToEditor(element);
8965 else if (IS_EMPTY_ELEMENT(element))
8966 CopyEmptyElementPropertiesToEditor(element);
8968 CopyClassicElementPropertiesToEditor(element);
8971 static boolean AskToCopyAndModifyLevelTemplate(void)
8973 if (Request("Copy and modify settings from level template?", REQ_ASK))
8975 level.use_custom_template = FALSE;
8977 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_1],
8978 GDI_CHECKED, FALSE, GDI_END);
8979 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_2],
8980 GDI_CHECKED, FALSE, GDI_END);
8986 LoadLevelTemplate(-1); // this resets all element modifications ...
8988 DrawEditModeWindow(); // ... and copies them to 'custom_element'
8994 static void CopyCustomElementPropertiesToGame(int element)
8997 int access_type_and_layer;
8999 // mark that this custom element has been modified
9000 custom_element.modified_settings = TRUE;
9001 level.changed = TRUE;
9003 if (level.use_custom_template)
9004 AskToCopyAndModifyLevelTemplate();
9006 element_info[element] = custom_element;
9007 *element_info[element].change = custom_element_change;
9009 // ---------- element settings: configure (custom elements) -----------------
9011 // set accessible property from checkbox and selectbox
9012 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
9013 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
9014 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
9015 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
9016 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
9017 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
9018 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
9019 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
9020 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
9021 custom_element_properties[access_type_and_layer] =
9022 custom_element_properties[EP_ACCESSIBLE];
9023 custom_element_properties[EP_PROTECTED] =
9024 (custom_element.access_protected != 0 &&
9025 custom_element_properties[EP_ACCESSIBLE]);
9027 // set walk-to-object property from checkbox and selectbox
9028 custom_element_properties[EP_DIGGABLE] = FALSE;
9029 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
9030 custom_element_properties[EP_DROPPABLE] = FALSE;
9031 custom_element_properties[EP_THROWABLE] = FALSE;
9032 custom_element_properties[EP_PUSHABLE] = FALSE;
9033 custom_element_properties[custom_element.walk_to_action] =
9034 custom_element_properties[EP_WALK_TO_OBJECT];
9036 // set smash property from checkbox and selectbox
9037 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
9038 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
9039 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
9040 custom_element_properties[custom_element.smash_targets] =
9041 custom_element_properties[EP_CAN_SMASH];
9043 // set deadliness property from checkbox and selectbox
9044 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
9045 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
9046 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
9047 custom_element_properties[EP_DONT_TOUCH] = FALSE;
9048 custom_element_properties[custom_element.deadliness] =
9049 custom_element_properties[EP_DEADLY];
9051 // ---------- element settings: advanced (custom elements) ------------------
9053 // set player change event from checkbox and selectbox
9054 custom_element_change_events[CE_NEXT_TO_PLAYER] = FALSE;
9055 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
9056 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
9057 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
9058 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
9059 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
9060 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
9061 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
9062 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
9063 custom_element_change_events[CE_SWITCHED] = FALSE;
9064 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
9065 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
9066 custom_element_change_events[CE_BLOCKED] = FALSE;
9067 custom_element_change_events[CE_IMPACT] = FALSE;
9068 custom_element_change_events[CE_SMASHED] = FALSE;
9069 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
9070 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
9071 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
9072 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
9073 custom_element_change_events[CE_CLICKED_BY_MOUSE] = FALSE;
9074 custom_element_change_events[CE_PRESSED_BY_MOUSE] = FALSE;
9075 custom_element_change_events[custom_element_change.direct_action] =
9076 custom_element_change_events[CE_BY_DIRECT_ACTION];
9078 // set other element action change event from checkbox and selectbox
9079 custom_element_change_events[CE_PLAYER_NEXT_TO_X] = FALSE;
9080 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
9081 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
9082 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
9083 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
9084 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
9085 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
9086 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
9087 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
9088 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
9089 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
9090 custom_element_change_events[CE_NEXT_TO_X] = FALSE;
9091 custom_element_change_events[CE_TOUCHING_X] = FALSE;
9092 custom_element_change_events[CE_HITTING_X] = FALSE;
9093 custom_element_change_events[CE_DIGGING_X] = FALSE;
9094 custom_element_change_events[CE_HIT_BY_X] = FALSE;
9095 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
9096 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
9097 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
9098 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
9099 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
9100 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
9101 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
9102 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
9103 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
9104 custom_element_change_events[CE_MOUSE_CLICKED_ON_X] = FALSE;
9105 custom_element_change_events[CE_MOUSE_PRESSED_ON_X] = FALSE;
9106 custom_element_change_events[custom_element_change.other_action] =
9107 custom_element_change_events[CE_BY_OTHER_ACTION];
9109 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
9110 SET_PROPERTY(element, i, custom_element_properties[i]);
9112 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
9113 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
9115 // copy change events also to special level editor variable
9116 custom_element = element_info[element];
9117 custom_element_change = *element_info[element].change;
9119 // needed here to restore runtime value "element_info[element].gfx_element"
9120 InitElementPropertiesGfxElement();
9123 static void CopyGroupElementPropertiesToGame(int element)
9125 // mark that this group element has been modified
9126 custom_element.modified_settings = TRUE;
9127 level.changed = TRUE;
9129 if (level.use_custom_template)
9130 AskToCopyAndModifyLevelTemplate();
9132 element_info[element] = custom_element;
9133 *element_info[element].group = group_element_info;
9135 // needed here to restore runtime value "element_info[element].gfx_element"
9136 InitElementPropertiesGfxElement();
9139 static void CopyEmptyElementPropertiesToGame(int element)
9141 // mark that this empty element has been modified
9142 custom_element.modified_settings = TRUE;
9143 level.changed = TRUE;
9145 if (level.use_custom_template)
9146 AskToCopyAndModifyLevelTemplate();
9148 element_info[element] = custom_element;
9150 // needed here to restore runtime value "element_info[element].gfx_element"
9151 InitElementPropertiesGfxElement();
9154 static void CopyClassicElementPropertiesToGame(int element)
9156 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
9157 setMoveIntoAcidProperty(&level, element,
9158 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
9160 if (MAYBE_DONT_COLLIDE_WITH(element))
9161 setDontCollideWithProperty(&level, element,
9162 custom_element_properties[EP_DONT_COLLIDE_WITH]);
9165 static void CopyElementPropertiesToGame(int element)
9167 if (IS_CUSTOM_ELEMENT(element))
9168 CopyCustomElementPropertiesToGame(element);
9169 else if (IS_GROUP_ELEMENT(element))
9170 CopyGroupElementPropertiesToGame(element);
9171 else if (IS_EMPTY_ELEMENT(element))
9172 CopyEmptyElementPropertiesToGame(element);
9174 CopyClassicElementPropertiesToGame(element);
9178 static void CheckElementDescriptions(void)
9182 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
9183 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
9184 Warn("no element description file for element '%s'", EL_NAME(i));
9188 static int getMaxEdFieldX(boolean has_scrollbar)
9190 int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
9191 int sxsize = SXSIZE - scrollbar_width;
9192 int max_ed_fieldx = sxsize / ed_tilesize;
9194 return max_ed_fieldx;
9197 static int getMaxEdFieldY(boolean has_scrollbar)
9199 int infotext_height = (IN_PIX_FIELD(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY) ?
9200 INFOTEXT_YSIZE_FULL : 0);
9201 int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
9202 int sysize = SYSIZE - scrollbar_height - infotext_height;
9203 int max_ed_fieldy = sysize / ed_tilesize;
9205 return max_ed_fieldy;
9208 static void InitZoomLevelSettings(int zoom_tilesize)
9210 static int last_game_engine_type = GAME_ENGINE_TYPE_UNKNOWN;
9212 if (zoom_tilesize == -1 && level.game_engine_type != last_game_engine_type)
9214 ed_tilesize = setup.auto_setup.editor_zoom_tilesize;
9215 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
9217 // make sure that tile size is always a power of 2
9218 ed_tilesize = (1 << log_2(ed_tilesize));
9220 if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
9222 ed_tilesize = DEFAULT_EDITOR_TILESIZE_MM;
9223 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE_MM;
9227 last_game_engine_type = level.game_engine_type;
9229 // limit zoom tilesize by upper and lower bound
9230 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
9232 // store zoom tilesize in auto setup file only if it was manually changed
9233 if (zoom_tilesize != -1)
9234 setup.auto_setup.editor_zoom_tilesize = ed_tilesize;
9236 MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
9237 MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
9240 static void InitDrawingElements(void)
9242 static int game_engine_type_last = GAME_ENGINE_TYPE_UNKNOWN;
9244 if (level.game_engine_type == game_engine_type_last)
9247 if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
9249 new_element1 = EL_BD_WALL;
9250 new_element2 = EL_EMPTY;
9251 new_element3 = EL_BD_SAND;
9253 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
9255 new_element1 = EL_SP_CHIP_SINGLE;
9256 new_element2 = EL_EMPTY;
9257 new_element3 = EL_SP_BASE;
9259 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
9261 new_element1 = EL_MM_MIRROR_START;
9262 new_element2 = EL_EMPTY;
9263 new_element3 = EL_MM_WOODEN_WALL;
9267 new_element1 = EL_WALL;
9268 new_element2 = EL_EMPTY;
9269 new_element3 = EL_SAND;
9272 game_engine_type_last = level.game_engine_type;
9275 static void InitLevelSetInfo(void)
9277 snprintf(levelset_name, MAX_LEVEL_NAME_LEN + 1,
9278 "%s", leveldir_current->name);
9279 snprintf(levelset_author, MAX_LEVEL_AUTHOR_LEN + 1,
9280 "%s", leveldir_current->author);
9282 levelset_num_levels = leveldir_current->levels;
9284 levelset_use_levelset_artwork = FALSE;
9285 levelset_copy_level_template = FALSE;
9287 levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
9290 static void ChangeEditorToLevelSet(char *levelset_subdir)
9292 leveldir_current = getTreeInfoFromIdentifier(leveldir_first, levelset_subdir);
9294 // the previous level set might have used custom artwork
9295 ReloadCustomArtwork(0);
9297 LoadLevelSetup_SeriesInfo();
9299 SaveLevelSetup_LastSeries();
9300 SaveLevelSetup_SeriesInfo();
9304 LoadLevel(level_nr);
9305 LoadScore(level_nr);
9310 static boolean useEditorDoorAnimation(void)
9312 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
9313 boolean door_1_viewport_unchanged =
9314 (vp_door_1->x == DX &&
9315 vp_door_1->y == DY &&
9316 vp_door_1->width == DXSIZE &&
9317 vp_door_1->height == DYSIZE);
9318 boolean door_1_contains_toolbox =
9321 EX + EXSIZE <= DX + DXSIZE &&
9322 EY + EYSIZE <= DY + DYSIZE);
9324 return (door_1_viewport_unchanged && door_1_contains_toolbox);
9327 static void DrawEditorDoorBackground(int graphic, int x, int y,
9328 int width, int height)
9330 struct GraphicInfo *g = &graphic_info[graphic];
9332 if (g->bitmap != NULL)
9333 BlitBitmap(g->bitmap, drawto, g->src_x, g->src_y,
9334 MIN(width, g->width), MIN(height, g->height), x, y);
9336 ClearRectangle(drawto, x, y, width, height);
9339 static void DrawEditorDoorContent(void)
9341 // needed for gadgets drawn on background (like palette scrollbar)
9342 SetDoorBackgroundImage(IMG_UNDEFINED);
9344 // copy default editor door content to main double buffer
9345 DrawEditorDoorBackground(IMG_BACKGROUND_PALETTE, DX, DY, DXSIZE, DYSIZE);
9348 DrawSpecialEditorDoor();
9350 // draw new control window
9351 DrawEditorDoorBackground(IMG_BACKGROUND_TOOLBOX, EX, EY, EXSIZE, EYSIZE);
9353 // draw all toolbox gadgets to editor doors
9354 MapControlButtons();
9356 // when returning from test game to properties page, redraw toolbox gadgets
9357 if (edit_mode == ED_MODE_PROPERTIES)
9359 UnmapLevelEditorToolboxDrawingGadgets();
9360 UnmapLevelEditorToolboxCustomGadgets();
9362 MapLevelEditorToolboxCustomGadgetsIfNeeded();
9365 // draw all palette gadgets to editor doors
9366 ModifyEditorElementList();
9367 RedrawDrawingElements();
9369 // copy actual editor door content to door double buffer for OpenDoor()
9370 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
9373 void DrawLevelEd(void)
9375 int fade_mask = REDRAW_FIELD;
9377 FadeSoundsAndMusic();
9380 fade_mask = REDRAW_ALL;
9384 // needed if different viewport properties defined for editor
9385 ChangeViewportPropertiesIfNeeded();
9389 InitZoomLevelSettings(-1);
9390 InitDrawingElements();
9394 CheckElementDescriptions();
9397 if (level_editor_test_game)
9399 CopyPlayfield(level.field, Tile);
9400 CopyPlayfield(TileBackup, level.field);
9402 level_editor_test_game = FALSE;
9406 edit_mode = ED_MODE_DRAWING;
9407 edit_mode_levelconfig = ED_MODE_LEVELCONFIG_LEVEL;
9408 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
9416 // redraw_mask |= REDRAW_ALL;
9418 FreeLevelEditorGadgets();
9419 CreateLevelEditorGadgets();
9421 ReinitializeElementList(); // update dynamic level element list
9422 ReinitializeElementListButtons(); // custom element may look different
9424 InitElementPropertiesGfxElement();
9428 DrawEditModeWindow_PlayfieldOnly();
9430 DrawMaskedBorder(fade_mask);
9432 // use door animation if door 1 viewport is unchanged and contains toolbox
9433 if (useEditorDoorAnimation())
9437 DrawEditorDoorContent();
9439 OpenDoor(DOOR_OPEN_1 | DOOR_FORCE_ANIM);
9443 DrawEditorDoorContent();
9448 SetDoorState(DOOR_OPEN_1 | DOOR_OPEN_2);
9451 static void AdjustDrawingAreaGadgets(void)
9453 int ed_xsize = lev_fieldx + 2;
9454 int ed_ysize = lev_fieldy + 2;
9455 int max_ed_fieldx = MAX_ED_FIELDX;
9456 int max_ed_fieldy = MAX_ED_FIELDY;
9457 boolean horizontal_scrollbar_needed;
9458 boolean vertical_scrollbar_needed;
9459 int x, y, width, height;
9461 if (suppressBorderElement())
9463 ed_xsize = lev_fieldx;
9464 ed_ysize = lev_fieldy;
9467 // check if we need any scrollbars
9468 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9469 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9471 // check if we have a smaller editor field because of scrollbars
9472 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9473 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9475 // check again if we now need more scrollbars because of less space
9476 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9477 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9479 // check if editor field gets even smaller after adding new scrollbars
9480 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9481 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9483 ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
9484 ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
9486 x = SX + ed_fieldx * ed_tilesize;
9487 y = SY + ed_fieldy * ed_tilesize;
9489 width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
9490 height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
9492 // adjust drawing area gadget
9493 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
9494 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
9495 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
9498 // adjust horizontal scrollbar gadgets
9499 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
9502 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
9503 GDI_X, x - ED_SCROLLBUTTON_XSIZE,
9506 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
9509 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
9512 // adjust vertical scrollbar gadgets
9513 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
9516 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
9518 GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
9520 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
9523 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
9527 static void AdjustLevelScrollPosition(void)
9529 if (level_xpos < -1)
9531 if (level_xpos > lev_fieldx - ed_fieldx + 1)
9532 level_xpos = lev_fieldx - ed_fieldx + 1;
9533 if (lev_fieldx < ed_fieldx - 2)
9536 if (level_ypos < -1)
9538 if (level_ypos > lev_fieldy - ed_fieldy + 1)
9539 level_ypos = lev_fieldy - ed_fieldy + 1;
9540 if (lev_fieldy < ed_fieldy - 2)
9543 if (suppressBorderElement())
9550 static void AdjustEditorScrollbar(int id)
9552 struct GadgetInfo *gi = level_editor_gadget[id];
9553 int items_max, items_visible, item_position;
9555 if (id == GADGET_ID_SCROLL_HORIZONTAL)
9557 items_max = MAX(lev_fieldx + 2, ed_fieldx);
9558 items_visible = ed_fieldx;
9559 item_position = level_xpos + 1;
9563 items_max = MAX(lev_fieldy + 2, ed_fieldy);
9564 items_visible = ed_fieldy;
9565 item_position = level_ypos + 1;
9568 if (item_position > items_max - items_visible)
9569 item_position = items_max - items_visible;
9571 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9572 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9575 static void AdjustElementListScrollbar(void)
9577 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
9578 int items_max, items_visible, item_position;
9580 // correct position of element list scrollbar
9581 if (element_shift < 0)
9583 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
9584 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
9586 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
9587 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
9588 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
9590 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9591 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
9592 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9595 static void ModifyEditorCounterValue(int counter_id, int new_value)
9597 int *counter_value = counterbutton_info[counter_id].value;
9598 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9599 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9601 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
9603 if (counter_value != NULL)
9604 *counter_value = gi->textinput.number_value;
9607 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
9609 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9610 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9612 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
9614 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
9615 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
9617 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
9618 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
9620 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
9621 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_SMALL_DISTANCE,
9626 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
9628 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9629 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9630 int new_index_value = setSelectboxValue(selectbox_id, new_value);
9632 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
9635 static void ModifyEditorSelectboxOptions(int selectbox_id,
9636 struct ValueTextInfo *options)
9638 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9639 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9641 selectbox_info[selectbox_id].options = options;
9643 // set index to zero -- list may be shorter now (correct later, if needed)
9644 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
9645 GDI_SELECTBOX_OPTIONS, options, GDI_END);
9648 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
9650 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
9651 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9653 drawingarea_info[drawingarea_id].area_xsize = xsize;
9654 drawingarea_info[drawingarea_id].area_ysize = ysize;
9656 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
9659 static void ModifyEditorElementList(void)
9663 if (!use_permanent_palette && edit_mode != ED_MODE_PALETTE)
9666 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
9668 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
9669 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9670 struct GadgetDesign *gd = &gi->deco.design;
9671 int element = editor_elements[element_shift + i];
9672 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
9676 getEditorGraphicSource(element, tile_size, &gd->bitmap, &gd->x, &gd->y);
9678 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
9684 static void DrawDrawingElementGraphic(int element, struct XYTileSize *pos)
9686 int graphic = el2edimg(element);
9687 int tile_size = BUTTON_TILE_SIZE(pos->tile_size);
9693 DrawSizedGraphicExt(drawto, DX + pos->x, DY + pos->y, graphic, 0, tile_size);
9696 static void ModifyDrawingElementButton(int element, int id)
9698 struct GadgetInfo *gi = level_editor_gadget[id];
9699 Bitmap *deco_bitmap;
9701 int tile_size = gi->deco.width;
9703 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
9705 ModifyGadget(gi, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_END);
9708 static void PickDrawingElement(int button, int element)
9713 struct XYTileSize *pos;
9715 } de, drawing_elements[] =
9717 { &new_element1, &editor.palette.element_left, GADGET_ID_ELEMENT_LEFT },
9718 { &new_element2, &editor.palette.element_middle, GADGET_ID_ELEMENT_MIDDLE },
9719 { &new_element3, &editor.palette.element_right, GADGET_ID_ELEMENT_RIGHT },
9722 if (button < 1 || button > 3)
9725 if (IS_MM_WALL(element))
9726 element = map_mm_wall_element(element);
9728 de = drawing_elements[button - 1];
9730 *de.new_element = element; // update global drawing element variable
9732 DrawDrawingElementGraphic(element, de.pos);
9733 ModifyDrawingElementButton(element, de.id);
9735 redraw_mask |= REDRAW_DOOR_1;
9738 static void RedrawDrawingElements(void)
9740 PickDrawingElement(1, new_element1);
9741 PickDrawingElement(2, new_element2);
9742 PickDrawingElement(3, new_element3);
9745 static void DrawDrawingWindowExt(boolean remap_toolbox_gadgets)
9747 stick_element_properties_window = FALSE;
9749 SetMainBackgroundImage(IMG_UNDEFINED);
9752 UnmapLevelEditorFieldGadgets();
9754 AdjustDrawingAreaGadgets();
9755 AdjustLevelScrollPosition();
9756 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
9757 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
9759 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9761 MapMainDrawingArea();
9763 if (remap_toolbox_gadgets)
9765 UnmapLevelEditorToolboxCustomGadgets();
9766 MapLevelEditorToolboxDrawingGadgets();
9770 static void DrawDrawingWindow(void)
9772 DrawDrawingWindowExt(TRUE);
9775 static int getTabulatorBarWidth(void)
9777 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9778 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
9780 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
9783 static int getTabulatorBarHeight(void)
9785 return ED_TAB_BAR_HEIGHT;
9788 static Pixel getTabulatorBarColor(void)
9790 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9791 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9792 int gd_x = gd->x + gd_gi1->border.width / 2;
9793 int gd_y = gd->y + gd_gi1->height - 1;
9795 return GetPixel(gd->bitmap, gd_x, gd_y);
9798 static void DrawLevelConfigTabulatorGadgets(void)
9800 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9801 Pixel tab_color = getTabulatorBarColor();
9802 int id_first = ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL;
9803 int id_last = ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR;
9806 // draw additional "engine" tabulator when using native BD engine
9807 if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
9808 id_last = ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE;
9810 for (i = id_first; i <= id_last; i++)
9812 int gadget_id = textbutton_info[i].gadget_id;
9813 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9814 boolean active = (i != edit_mode_levelconfig);
9816 // draw background line below tabulator button
9817 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9819 // draw solid line below inactive tabulator buttons
9820 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9821 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9822 ED_GADGET_TINY_DISTANCE, tab_color);
9824 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9825 MapTextbuttonGadget(i);
9828 // draw little border line below tabulator buttons
9829 if (tab_color != BLACK_PIXEL) // black => transparent
9830 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9831 ED_GADGET_TINY_DISTANCE,
9832 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9835 static void DrawPropertiesTabulatorGadgets(void)
9837 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9838 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9839 int gd_x = gd->x + gd_gi1->border.width / 2;
9840 int gd_y = gd->y + gd_gi1->height - 1;
9841 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
9842 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
9843 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
9846 // draw two config tabulators for player elements
9847 if (IS_PLAYER_ELEMENT(properties_element))
9848 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
9850 // draw two config and one "change" tabulator for custom elements
9851 if (IS_CUSTOM_ELEMENT(properties_element))
9852 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
9854 for (i = id_first; i <= id_last; i++)
9856 int gadget_id = textbutton_info[i].gadget_id;
9857 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9858 boolean active = (i != edit_mode_properties);
9860 // use "config 1" and "config 2" instead of "config" for players and CEs
9861 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
9862 (IS_PLAYER_ELEMENT(properties_element) ||
9863 IS_CUSTOM_ELEMENT(properties_element)))
9866 // draw background line below tabulator button
9867 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9869 // draw solid line below inactive tabulator buttons
9870 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9871 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9872 ED_GADGET_TINY_DISTANCE, tab_color);
9874 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9875 MapTextbuttonGadget(i);
9878 // draw little border line below tabulator buttons
9879 if (tab_color != BLACK_PIXEL) // black => transparent
9880 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9881 ED_GADGET_TINY_DISTANCE,
9882 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9885 static void PrintInfoText(char *text, int font_nr, int xpos, int ypos)
9887 DrawText(SX + xpos, SY + ypos, text, font_nr);
9890 static int PrintElementDescriptionFromFile(char *filename, int font_nr,
9893 int font_width = getFontWidth(font_nr);
9894 int font_height = getFontHeight(font_nr);
9895 int max_chars_per_line = (SXSIZE - 2 * xpos) / font_width;
9896 int max_lines_drawable = (SYSIZE - ypos) / font_height - 1;
9898 return DrawTextFile(SX + xpos, SY + ypos, filename, font_nr,
9899 max_chars_per_line, -1, max_lines_drawable, 0, -1,
9900 TRUE, FALSE, FALSE);
9903 static void DrawLevelConfigLevel(void)
9907 // draw counter gadgets
9908 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
9909 MapCounterButtons(i);
9911 // draw checkbutton gadgets
9912 for (i = ED_CHECKBUTTON_ID_LEVEL_FIRST; i<= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
9913 MapCheckbuttonGadget(i);
9915 // draw selectbox gadgets
9916 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
9917 MapSelectboxGadget(i);
9919 // draw text input gadgets
9920 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
9921 MapTextInputGadget(i);
9924 static char *getLevelSubdirFromSaveMode(int save_mode)
9926 if (save_mode == LEVELSET_SAVE_MODE_CREATE)
9927 return getNewUserLevelSubdir();
9929 return leveldir_current->subdir;
9932 static void DrawLevelConfigLevelSet_DirectoryInfo(void)
9934 char *directory_text = "Level set directory:";
9935 char *directory_name = getLevelSubdirFromSaveMode(levelset_save_mode);
9936 int font1_nr = FONT_TEXT_1;
9937 int font2_nr = FONT_TEXT_2;
9938 int font1_height = getFontHeight(font1_nr);
9939 int yoffset_above = font1_height + ED_GADGET_LINE_DISTANCE;
9940 int x = ED_LEVEL_SETTINGS_X(0);
9941 int y = ED_LEVEL_SETTINGS_Y(6);
9943 PrintInfoText(directory_text, font1_nr, x, y - yoffset_above);
9944 PrintInfoText(directory_name, font2_nr, x, y);
9947 static void DrawLevelConfigLevelSet(void)
9949 boolean artwork_exists = checkIfCustomArtworkExistsForCurrentLevelSet();
9950 boolean template_exists = fileExists(getLocalLevelTemplateFilename());
9953 // draw counter gadgets
9954 for (i = ED_COUNTER_ID_LEVELSET_FIRST; i <= ED_COUNTER_ID_LEVELSET_LAST; i++)
9955 MapCounterButtons(i);
9957 // draw checkbutton gadgets
9958 for (i = ED_CHECKBUTTON_ID_LEVELSET_FIRST; i <= ED_CHECKBUTTON_ID_LEVELSET_LAST; i++)
9960 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE ||
9961 (i == ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK && !artwork_exists) ||
9962 (i == ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE && !template_exists))
9965 MapCheckbuttonGadget(i);
9968 // draw selectbox gadgets
9969 for (i = ED_SELECTBOX_ID_LEVELSET_FIRST; i <= ED_SELECTBOX_ID_LEVELSET_LAST; i++)
9970 MapSelectboxGadget(i);
9972 // draw text input gadgets
9973 for (i = ED_TEXTINPUT_ID_LEVELSET_FIRST; i <= ED_TEXTINPUT_ID_LEVELSET_LAST; i++)
9974 MapTextInputGadget(i);
9976 // draw textbutton gadgets
9977 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_LEVELSET);
9980 DrawLevelConfigLevelSet_DirectoryInfo();
9983 static void DrawLevelConfigEditor(void)
9987 // draw counter gadgets
9988 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
9989 MapCounterButtons(i);
9991 // draw checkbutton gadgets
9992 for (i = ED_CHECKBUTTON_ID_EDITOR_FIRST; i <= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
9993 MapCheckbuttonGadget(i);
9995 // draw radiobutton gadgets
9996 for (i = ED_RADIOBUTTON_ID_EDITOR_FIRST; i <= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
9997 MapRadiobuttonGadget(i);
9999 // draw drawing area
10000 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
10002 // draw textbutton gadgets
10003 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2);
10006 static void DrawLevelConfigEngine(void)
10010 // draw checkbutton gadgets
10011 for (i = ED_CHECKBUTTON_ID_ENGINE_FIRST; i <= ED_CHECKBUTTON_ID_ENGINE_LAST; i++)
10012 MapCheckbuttonGadget(i);
10015 static void DrawLevelConfigWindow(void)
10017 char *text = "Global Settings";
10018 int font_nr = FONT_TITLE_1;
10019 struct MenuPosInfo *pos = &editor.settings.headline;
10020 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font_nr), pos->align);
10021 int sy = SY + pos->y;
10023 stick_element_properties_window = FALSE;
10025 SetAutomaticNumberOfGemsNeeded();
10027 UnmapLevelEditorFieldGadgets();
10029 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10032 DrawText(sx, sy, text, font_nr);
10034 DrawLevelConfigTabulatorGadgets();
10036 if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVEL)
10037 DrawLevelConfigLevel();
10038 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVELSET)
10039 DrawLevelConfigLevelSet();
10040 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_EDITOR)
10041 DrawLevelConfigEditor();
10042 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_ENGINE)
10043 DrawLevelConfigEngine();
10046 static void DrawCustomContentArea(void)
10048 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
10049 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
10050 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
10051 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
10052 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
10053 int xoffset = ED_GADGET_SPACE_DISTANCE;
10055 // add distance for potential left text (without drawing area border)
10056 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
10058 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
10060 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
10063 static void DrawCustomChangeContentArea(void)
10065 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
10066 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
10067 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
10068 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
10069 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
10070 int xoffset = ED_GADGET_SPACE_DISTANCE;
10072 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
10074 MapDrawingArea(id);
10077 static void RemoveElementContentArea(int id, int font_height)
10079 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10081 DrawBackground(SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size,
10082 SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size,
10083 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10084 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size +
10085 ED_GADGET_TEXT_DISTANCE + font_height);
10088 static void DrawYamYamContentAreas(void)
10090 int font_nr = FONT_TEXT_1;
10091 int font_height = getFontHeight(font_nr);
10092 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
10093 int yoffset = (tilesize - font_height) / 2;
10094 int x = SX + ED_AREA_YAMYAM_CONTENT_X(3) + 4 * tilesize;
10095 int y = SY + ED_AREA_YAMYAM_CONTENT_Y(3) + yoffset;
10098 // display counter to choose number of element content areas
10099 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
10101 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
10103 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
10105 if (i < level.num_yamyam_contents)
10107 MapDrawingArea(id);
10111 UnmapDrawingArea(id);
10113 // delete content areas in case of reducing number of them
10114 RemoveElementContentArea(id, font_height);
10118 DrawText(x, y + 0 * tilesize, "content", font_nr);
10119 DrawText(x, y + 1 * tilesize, "when", font_nr);
10120 DrawText(x, y + 2 * tilesize, "smashed", font_nr);
10123 static void DrawMagicBallContentAreas(void)
10125 int font_nr = FONT_TEXT_1;
10126 int font_height = getFontHeight(font_nr);
10127 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
10128 int yoffset = (tilesize - font_height) / 2;
10129 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_X(3) + 4 * tilesize;
10130 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_Y(3) + yoffset;
10133 // display counter to choose number of element content areas
10134 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
10136 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
10138 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
10140 if (i < level.num_ball_contents)
10142 MapDrawingArea(id);
10146 UnmapDrawingArea(id);
10148 // delete content areas in case of reducing number of them
10149 RemoveElementContentArea(id, font_height);
10153 DrawText(x, y + 0 * tilesize, "generated", font_nr);
10154 DrawText(x, y + 1 * tilesize, "when", font_nr);
10155 DrawText(x, y + 2 * tilesize, "active", font_nr);
10158 static void DrawAndroidElementArea(void)
10160 int id = ED_DRAWING_ID_ANDROID_CONTENT;
10161 int num_elements = level.num_android_clone_elements;
10162 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10163 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10164 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10165 int xsize = MAX_ANDROID_ELEMENTS;
10168 // display counter to choose number of element areas
10169 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
10171 if (drawingarea_info[id].text_left != NULL)
10172 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10174 UnmapDrawingArea(id);
10176 ModifyEditorDrawingArea(id, num_elements, 1);
10178 // delete content areas in case of reducing number of them
10179 DrawBackground(sx, sy,
10180 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10181 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10183 MapDrawingArea(id);
10186 static void DrawGroupElementArea(void)
10188 int id = ED_DRAWING_ID_GROUP_CONTENT;
10189 int num_elements = group_element_info.num_elements;
10190 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10191 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10192 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10193 int xsize = MAX_ELEMENTS_IN_GROUP;
10196 if (drawingarea_info[id].text_left != NULL)
10197 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10199 UnmapDrawingArea(id);
10201 ModifyEditorDrawingArea(id, num_elements, 1);
10203 // delete content areas in case of reducing number of them
10204 DrawBackground(sx, sy,
10205 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10206 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10208 MapDrawingArea(id);
10211 static void DrawPlayerInitialInventoryArea(int element)
10213 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
10214 int player_nr = GET_PLAYER_NR(element);
10215 int num_elements = level.initial_inventory_size[player_nr];
10216 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10217 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10218 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10219 int xsize = MAX_INITIAL_INVENTORY_SIZE;
10222 // determine horizontal position to the right of specified gadget
10223 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
10224 sx = (right_gadget_border[drawingarea_info[id].gadget_id_align] +
10225 ED_DRAWINGAREA_TEXT_DISTANCE);
10227 // determine horizontal offset for leading text
10228 if (drawingarea_info[id].text_left != NULL)
10229 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10231 UnmapDrawingArea(id);
10233 ModifyEditorDrawingArea(id, num_elements, 1);
10235 // delete content areas in case of reducing number of them
10236 DrawBackground(sx, sy,
10237 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10238 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10240 MapDrawingArea(id);
10243 static void DrawMMBallContentArea(void)
10245 int id = ED_DRAWING_ID_MM_BALL_CONTENT;
10246 int num_elements = level.num_mm_ball_contents;
10247 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10248 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10249 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10250 int xsize = MAX_MM_BALL_CONTENTS;
10253 if (drawingarea_info[id].text_left != NULL)
10254 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10256 UnmapDrawingArea(id);
10258 ModifyEditorDrawingArea(id, num_elements, 1);
10260 // delete content areas in case of reducing number of them
10261 DrawBackground(sx, sy,
10262 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10263 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10265 MapDrawingArea(id);
10268 static void DrawEnvelopeTextArea(int envelope_nr)
10270 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
10271 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
10275 DrawBackground(gi->x, gi->y,
10276 gi->textarea.crop_width, gi->textarea.crop_height);
10278 if (envelope_nr != -1)
10279 textarea_info[id].value = level.envelope[envelope_nr].text;
10281 ModifyGadget(gi, GDI_AREA_SIZE,
10282 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
10283 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
10286 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
10289 static void DrawPropertiesInfo(void)
10298 // configurable properties
10300 { EP_WALKABLE_OVER, "- player can walk over it" },
10301 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
10302 { EP_WALKABLE_UNDER, "- player can walk under it" },
10303 { EP_PASSABLE_OVER, "- player can pass over it" },
10304 { EP_PASSABLE_INSIDE, "- player can pass through it" },
10305 { EP_PASSABLE_UNDER, "- player can pass under it" },
10306 { EP_PROTECTED, "- player is protected by it" },
10308 { EP_DIGGABLE, "- can be digged away" },
10309 { EP_COLLECTIBLE, "- can be collected" },
10310 { EP_DROPPABLE, "- can be dropped after collecting" },
10311 { EP_THROWABLE, "- can be thrown after collecting" },
10312 { EP_PUSHABLE, "- can be pushed" },
10314 { EP_CAN_FALL, "- can fall" },
10315 { EP_CAN_MOVE, "- can move" },
10317 { EP_CAN_SMASH_PLAYER, "- can smash player" },
10319 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
10321 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
10323 { EP_SLIPPERY, "- slippery for falling elements" },
10324 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
10326 { EP_DONT_RUN_INTO, "- deadly when running into" },
10327 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
10328 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
10329 { EP_DONT_TOUCH, "- deadly when touching" },
10331 { EP_INDESTRUCTIBLE, "- indestructible" },
10333 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
10334 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
10335 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
10337 { EP_CAN_CHANGE, "- can change to other element" },
10339 // pre-defined properties
10340 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
10341 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
10342 { EP_SWITCHABLE, "- can be switched" },
10344 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
10349 char *filename = getElementDescriptionFilename(properties_element);
10350 char *num_elements_text = "In this level: ";
10351 char *num_similar_text = "Similar tiles: ";
10352 char *properties_text = "Standard properties: ";
10353 char *description_text = "Description:";
10354 char *no_description_text = "No description available.";
10355 char *none_text = "None";
10357 int num_elements_in_level = 0;
10358 int num_similar_in_level = 0;
10359 int num_hires_tiles_in_level = 0;
10360 int num_standard_properties = 0;
10361 int font1_nr = FONT_TEXT_1;
10362 int font2_nr = FONT_TEXT_2;
10363 int font1_width = getFontWidth(font1_nr);
10364 int font1_height = getFontHeight(font1_nr);
10365 int font2_height = getFontHeight(font2_nr);
10366 int line1_height = font1_height + ED_GADGET_LINE_DISTANCE;
10367 int font2_yoffset = (font1_height - font2_height) / 2;
10368 int num_elements_text_len = strlen(num_elements_text) * font1_width;
10369 int num_similar_text_len = strlen(num_similar_text) * font1_width;
10370 int properties_text_len = strlen(properties_text) * font1_width;
10371 int xpos = ED_ELEMENT_SETTINGS_X(0);
10372 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10375 if (setup.editor.show_element_token)
10377 int font3_nr = FONT_TEXT_3;
10378 int font3_height = getFontHeight(font3_nr);
10380 DrawTextF(xpos, ypos, font3_nr,
10381 "[%s]", element_info[properties_element].token_name);
10383 ypos += 2 * font3_height;
10386 // ----- print number of elements / percentage of this element in level
10388 for (y = 0; y < lev_fieldy; y++)
10390 for (x = 0; x < lev_fieldx; x++)
10392 if (Tile[x][y] == properties_element)
10394 num_elements_in_level++;
10396 else if (IS_MM_WALL(Tile[x][y]) &&
10397 map_mm_wall_element(Tile[x][y]) == properties_element)
10399 num_hires_tiles_in_level += numHiresTiles(Tile[x][y]);
10404 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10406 DrawTextS(xpos, ypos, font1_nr, num_elements_text);
10408 if (num_hires_tiles_in_level > 0)
10409 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10410 "%d wall tiles", num_hires_tiles_in_level);
10411 else if (num_elements_in_level > 0)
10412 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10413 "%d (%.2f %%)", num_elements_in_level, percentage);
10415 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10418 // ----- print number of similar elements / percentage of them in level
10420 for (y = 0; y < lev_fieldy; y++)
10422 for (x = 0; x < lev_fieldx; x++)
10424 if (strEqual(element_info[Tile[x][y]].class_name,
10425 element_info[properties_element].class_name))
10427 num_similar_in_level++;
10432 if (num_similar_in_level != num_elements_in_level)
10434 ypos += 1 * MAX(font1_height, font2_height);
10436 percentage = num_similar_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10438 DrawTextS(xpos, ypos, font1_nr, num_similar_text);
10440 if (num_similar_in_level > 0)
10441 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10442 "%d (%.2f %%)", num_similar_in_level, percentage);
10444 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10448 ypos += 2 * MAX(font1_height, font2_height);
10450 // ----- print standard properties of this element
10452 DrawTextS(xpos, ypos, font1_nr, properties_text);
10454 ypos += line1_height;
10456 for (i = 0; properties[i].value != -1; i++)
10458 if (!HAS_PROPERTY(properties_element, properties[i].value))
10461 DrawTextS(xpos, ypos, font2_nr, properties[i].text);
10463 ypos += font2_height;
10465 num_standard_properties++;
10468 if (num_standard_properties == 0)
10470 DrawTextS(xpos + properties_text_len, ypos - line1_height + font2_yoffset,
10471 font2_nr, none_text);
10473 ypos -= (line1_height - font1_height);
10476 ypos += MAX(font1_height, font2_height);
10478 // ----- print special description of this element
10480 PrintInfoText(description_text, font1_nr, xpos, ypos);
10482 ypos += line1_height;
10484 if (PrintElementDescriptionFromFile(filename, font2_nr, xpos, ypos) == 0)
10485 PrintInfoText(no_description_text, font1_nr, xpos, ypos - line1_height);
10488 #define TEXT_COLLECTING "Score for collecting"
10489 #define TEXT_COLLECTING_EXTRA "Score for extra diamonds"
10490 #define TEXT_SMASHING "Score for smashing"
10491 #define TEXT_SLURPING "Score for slurping robot"
10492 #define TEXT_CRACKING "Score for cracking"
10493 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
10494 #define TEXT_DURATION "Duration when activated"
10495 #define TEXT_DELAY_ON "Delay before activating"
10496 #define TEXT_DELAY_OFF "Delay before deactivating"
10497 #define TEXT_DELAY_CHANGING "Delay before changing"
10498 #define TEXT_DELAY_EXPLODING "Delay before exploding"
10499 #define TEXT_DELAY_MOVING "Delay before moving"
10500 #define TEXT_BALL_DELAY "Element generation delay"
10501 #define TEXT_MOVE_SPEED "Speed of android moving"
10502 #define TEXT_CLONE_SPEED "Speed of android cloning"
10503 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
10504 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
10505 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
10506 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
10507 #define TEXT_TIME_BONUS "Extra time to solve level"
10514 } elements_with_counter[] =
10516 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
10517 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
10518 { EL_BD_DIAMOND, &level.score[SC_DIAMOND_EXTRA], TEXT_COLLECTING_EXTRA },
10519 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
10520 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
10521 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10522 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
10523 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
10524 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
10525 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
10526 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
10527 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
10528 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
10529 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10530 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10531 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
10532 { EL_BD_BUTTERFLY_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
10533 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
10534 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10535 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10536 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
10537 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10538 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10539 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10540 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10541 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10542 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10543 { EL_BD_FIREFLY_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10544 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10545 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10546 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10547 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10548 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10549 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10550 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10551 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
10552 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
10553 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10554 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
10555 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10556 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10557 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10558 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10559 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10560 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
10561 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10562 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10563 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE], TEXT_COLLECTING },
10564 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10565 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10566 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
10567 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
10568 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
10569 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10570 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10571 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10572 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10573 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10574 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10575 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10576 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10577 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
10578 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
10579 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
10580 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
10581 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
10582 { EL_MM_KETTLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10583 { EL_DF_CELL, &level.score[SC_EMERALD], TEXT_COLLECTING },
10584 { EL_MM_KEY, &level.score[SC_KEY], TEXT_COLLECTING },
10585 { EL_MM_LIGHTBALL, &level.score[SC_ELEM_BONUS], TEXT_COLLECTING },
10586 { EL_MM_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10587 { EL_MM_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10588 { EL_MM_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10589 { EL_MM_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10590 { EL_MM_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10591 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10592 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10593 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10594 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10595 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10596 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10597 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10598 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10599 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
10600 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
10601 { EL_DC_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
10602 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
10603 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
10604 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
10605 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
10606 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
10607 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
10608 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
10609 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
10610 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
10611 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
10612 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
10613 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
10614 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
10615 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
10616 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
10617 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
10618 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
10619 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
10620 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
10621 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
10622 { EL_SPRING_LEFT, &level.slurp_score, TEXT_SLURPING },
10623 { EL_SPRING_RIGHT, &level.slurp_score, TEXT_SLURPING },
10624 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
10625 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
10626 { EL_MM_FUSE_ACTIVE, &level.mm_time_fuse, TEXT_DELAY_OFF },
10627 { EL_MM_BOMB, &level.mm_time_bomb, TEXT_DELAY_EXPLODING },
10628 { EL_MM_GRAY_BALL, &level.mm_time_ball, TEXT_DELAY_CHANGING },
10629 { EL_MM_STEEL_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10630 { EL_MM_WOODEN_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10635 static boolean checkPropertiesConfig(int element)
10639 // special case: empty space customization only available in R'n'D game engine
10640 if (element == EL_EMPTY_SPACE && level.game_engine_type != GAME_ENGINE_TYPE_RND)
10643 if (IS_GEM(element) ||
10644 IS_CUSTOM_ELEMENT(element) ||
10645 IS_GROUP_ELEMENT(element) ||
10646 IS_EMPTY_ELEMENT(element) ||
10647 IS_BALLOON_ELEMENT(element) ||
10648 IS_ENVELOPE(element) ||
10649 IS_MM_ENVELOPE(element) ||
10650 IS_MM_MCDUFFIN(element) ||
10651 IS_DF_LASER(element) ||
10652 IS_PLAYER_ELEMENT(element) ||
10653 IS_BD_PLAYER_ELEMENT(element) ||
10654 IS_SOKOBAN_OBJECT_OR_FIELD(element) ||
10655 HAS_EDITOR_CONTENT(element) ||
10656 CAN_GROW(element) ||
10657 COULD_MOVE_INTO_ACID(element) ||
10658 MAYBE_DONT_COLLIDE_WITH(element))
10661 for (i = 0; elements_with_counter[i].element != -1; i++)
10662 if (elements_with_counter[i].element == element)
10668 static void SetAutomaticNumberOfGemsNeeded(void)
10672 if (!level.auto_count_gems)
10675 level.gems_needed = 0;
10677 for (x = 0; x < lev_fieldx; x++)
10679 for (y = 0; y < lev_fieldy; y++)
10681 int element = Tile[x][y];
10686 case EL_EMERALD_YELLOW:
10687 case EL_EMERALD_RED:
10688 case EL_EMERALD_PURPLE:
10689 case EL_BD_DIAMOND:
10690 case EL_WALL_EMERALD:
10691 case EL_WALL_EMERALD_YELLOW:
10692 case EL_WALL_EMERALD_RED:
10693 case EL_WALL_EMERALD_PURPLE:
10694 case EL_WALL_BD_DIAMOND:
10696 case EL_SP_INFOTRON:
10699 level.gems_needed++;
10703 case EL_WALL_DIAMOND:
10704 level.gems_needed += 3;
10708 case EL_WALL_PEARL:
10709 level.gems_needed += 5;
10713 case EL_WALL_CRYSTAL:
10714 level.gems_needed += 8;
10723 ModifyEditorCounterValue(ED_COUNTER_ID_LEVEL_GEMSLIMIT, level.gems_needed);
10726 static void DrawPropertiesConfig(void)
10728 boolean draw_footer_line = FALSE;
10729 int max_num_element_counters = 4;
10730 int num_element_counters = 0;
10733 if (!checkPropertiesConfig(properties_element))
10735 int xpos = ED_ELEMENT_SETTINGS_X(0);
10736 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10738 PrintInfoText("No configuration options available.",
10739 FONT_TEXT_1, xpos, ypos);
10744 // check if there are elements where a value can be chosen for
10745 for (i = 0; elements_with_counter[i].element != -1; i++)
10747 if (elements_with_counter[i].element == properties_element)
10749 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
10751 counterbutton_info[counter_id].y =
10752 ED_ELEMENT_SETTINGS_YPOS(
10753 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
10754 (CAN_GROW(properties_element) ? 1 : 0) +
10755 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
10756 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
10757 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
10758 num_element_counters);
10760 counterbutton_info[counter_id].value = elements_with_counter[i].value;
10761 counterbutton_info[counter_id].text_right = elements_with_counter[i].text;
10763 if (properties_element == EL_GAME_OF_LIFE ||
10764 properties_element == EL_BIOMAZE)
10766 counterbutton_info[counter_id].min_value = 0; // min neighbours
10767 counterbutton_info[counter_id].max_value = 8; // max neighbours
10771 // !!! CHANGE THIS FOR CERTAIN ELEMENTS !!!
10772 counterbutton_info[counter_id].min_value = MIN_SCORE;
10773 counterbutton_info[counter_id].max_value = MAX_SCORE;
10776 MapCounterButtons(counter_id);
10778 num_element_counters++;
10779 if (num_element_counters >= max_num_element_counters)
10784 if (HAS_EDITOR_CONTENT(properties_element))
10786 // draw stickybutton gadget
10787 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10789 if (IS_AMOEBOID(properties_element))
10790 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
10791 else if (properties_element == EL_YAMYAM ||
10792 properties_element == EL_YAMYAM_LEFT ||
10793 properties_element == EL_YAMYAM_RIGHT ||
10794 properties_element == EL_YAMYAM_UP ||
10795 properties_element == EL_YAMYAM_DOWN)
10796 DrawYamYamContentAreas();
10797 else if (properties_element == EL_EMC_MAGIC_BALL)
10799 DrawMagicBallContentAreas();
10801 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
10802 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE);
10804 else if (properties_element == EL_EMC_ANDROID)
10805 DrawAndroidElementArea();
10806 else if (properties_element == EL_MM_GRAY_BALL)
10808 MapCounterButtons(ED_COUNTER_ID_MM_BALL_CONTENT);
10809 MapSelectboxGadget(ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE);
10810 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT);
10811 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EXPLODE_MM_BALL);
10813 DrawMMBallContentArea();
10817 if (IS_PLAYER_ELEMENT(properties_element))
10819 int player_nr = GET_PLAYER_NR(properties_element);
10821 // these properties can be set for every player individually
10823 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
10825 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
10826 &level.start_element[player_nr];
10827 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
10828 &level.artwork_element[player_nr];
10829 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
10830 &level.explosion_element[player_nr];
10832 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
10833 &level.use_start_element[player_nr];
10834 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
10835 &level.use_artwork_element[player_nr];
10836 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
10837 &level.use_explosion_element[player_nr];
10838 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
10839 &level.initial_player_gravity[player_nr];
10841 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
10842 &level.initial_player_stepsize[player_nr];
10844 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
10845 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
10846 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
10847 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
10848 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
10849 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
10850 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
10851 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
10852 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_LAZY_RELOCATION);
10853 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
10854 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
10855 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
10856 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
10857 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
10858 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER);
10860 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
10861 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
10862 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
10864 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
10866 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
10868 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
10869 &level.initial_inventory_content[player_nr][0];
10871 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
10872 &level.initial_inventory_size[player_nr];
10874 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
10875 &level.use_initial_inventory[player_nr];
10877 // draw checkbutton gadgets
10878 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
10879 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT);
10880 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE);
10882 // draw counter gadgets
10883 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
10885 // draw drawing area gadgets
10886 DrawPlayerInitialInventoryArea(properties_element);
10890 if (IS_BD_PLAYER_ELEMENT(properties_element))
10891 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS);
10893 // special case: slippery walls option for gems only available in R'n'D game engine
10894 if (IS_GEM(properties_element) && level.game_engine_type == GAME_ENGINE_TYPE_RND)
10896 checkbutton_info[ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS].y =
10897 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_BD_DIAMOND ? 2 : 1);
10899 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
10902 if (properties_element == EL_EM_DYNAMITE)
10903 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
10905 if (COULD_MOVE_INTO_ACID(properties_element) &&
10906 !IS_PLAYER_ELEMENT(properties_element) &&
10907 (!IS_CUSTOM_ELEMENT(properties_element) ||
10908 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
10910 // set position for checkbutton for "can move into acid"
10911 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
10912 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
10913 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
10914 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 7 :
10915 IS_BALLOON_ELEMENT(properties_element) ||
10916 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
10918 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
10921 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
10922 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
10924 if (properties_element == EL_SPRING ||
10925 properties_element == EL_SPRING_LEFT ||
10926 properties_element == EL_SPRING_RIGHT)
10927 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
10929 if (properties_element == EL_TIME_ORB_FULL)
10930 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
10932 if (properties_element == EL_GAME_OF_LIFE ||
10933 properties_element == EL_BIOMAZE)
10934 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_LIFE_BUGS);
10936 if (CAN_GROW(properties_element))
10938 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
10939 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
10941 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
10944 if (properties_element == EL_SOKOBAN_FIELD_EMPTY)
10945 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED);
10947 if (properties_element == EL_SOKOBAN_OBJECT)
10948 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED);
10950 if (properties_element == EL_SOKOBAN_OBJECT ||
10951 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
10952 properties_element == EL_SOKOBAN_FIELD_FULL)
10954 checkbutton_info[ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN].y =
10955 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_SOKOBAN_FIELD_FULL ?
10958 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
10961 if (IS_BALLOON_ELEMENT(properties_element))
10962 MapSelectboxGadget(ED_SELECTBOX_ID_WIND_DIRECTION);
10964 if (IS_ENVELOPE(properties_element) ||
10965 IS_MM_ENVELOPE(properties_element))
10967 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
10968 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
10969 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
10970 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
10971 int envelope_nr = ENVELOPE_NR(properties_element);
10973 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
10974 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
10976 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
10977 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
10979 // display counter to choose size of envelope text area
10980 MapCounterButtons(counter1_id);
10981 MapCounterButtons(counter2_id);
10983 // display checkbuttons to choose auto-wrap and alignment properties
10984 MapCheckbuttonGadget(button1_id);
10985 MapCheckbuttonGadget(button2_id);
10987 DrawEnvelopeTextArea(envelope_nr);
10990 if (IS_MM_MCDUFFIN(properties_element))
10992 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_RED);
10993 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_GREEN);
10994 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_BLUE);
10997 if (IS_DF_LASER(properties_element))
10999 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_RED);
11000 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_GREEN);
11001 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_BLUE);
11004 if (IS_CUSTOM_ELEMENT(properties_element))
11006 // draw stickybutton gadget
11007 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11009 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
11011 // draw checkbutton gadgets
11012 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
11013 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
11014 MapCheckbuttonGadget(i);
11016 // draw counter gadgets
11017 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
11018 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
11019 MapCounterButtons(i);
11021 // draw selectbox gadgets
11022 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
11023 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
11024 MapSelectboxGadget(i);
11026 // draw textbutton gadgets
11027 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11029 // draw text input gadgets
11030 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
11032 // draw drawing area gadgets
11033 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11035 draw_footer_line = TRUE;
11037 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
11039 // draw checkbutton gadgets
11040 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
11041 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
11042 MapCheckbuttonGadget(i);
11044 // draw counter gadgets
11045 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
11046 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
11047 MapCounterButtons(i);
11049 // draw selectbox gadgets
11050 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
11051 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
11052 MapSelectboxGadget(i);
11054 // draw drawing area gadgets
11055 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
11056 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
11057 DrawCustomContentArea();
11060 else if (IS_GROUP_ELEMENT(properties_element))
11062 // draw stickybutton gadget
11063 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11065 // draw checkbutton gadgets
11066 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
11067 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
11069 // draw counter gadgets
11070 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
11072 // draw selectbox gadgets
11073 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
11075 // draw textbutton gadgets
11076 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11078 // draw drawing area gadgets
11079 DrawGroupElementArea();
11081 // draw text input gadgets
11082 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
11084 // draw drawing area gadgets
11085 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11087 draw_footer_line = TRUE;
11089 else if (IS_EMPTY_ELEMENT(properties_element))
11091 // draw stickybutton gadget
11092 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11094 // draw checkbutton gadgets
11095 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
11096 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
11098 // draw textbutton gadgets
11099 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11101 // draw drawing area gadgets
11102 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11104 draw_footer_line = TRUE;
11107 // draw little footer border line above CE/GE use/save template gadgets
11108 if (draw_footer_line)
11110 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
11111 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
11112 int gd_x = gd->x + gd_gi1->border.width / 2;
11113 int gd_y = gd->y + gd_gi1->height - 1;
11114 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
11116 if (tab_color != BLACK_PIXEL) // black => transparent
11117 FillRectangle(drawto,
11118 SX + ED_ELEMENT_SETTINGS_X(0),
11119 SY + ED_ELEMENT_SETTINGS_Y(14) - ED_SETTINGS_TABS_YOFFSET -
11121 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
11125 static void DrawPropertiesChangeDrawingAreas(void)
11127 if (IS_CUSTOM_ELEMENT(properties_element))
11129 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
11130 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
11131 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
11133 DrawCustomChangeContentArea();
11136 redraw_mask |= REDRAW_FIELD;
11139 static void DrawPropertiesChange(void)
11143 // needed to initially set selectbox options for special action options
11144 setSelectboxSpecialActionOptions();
11146 // draw stickybutton gadget
11147 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11149 // draw checkbutton gadgets
11150 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
11151 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
11152 MapCheckbuttonGadget(i);
11154 // draw counter gadgets
11155 for (i = ED_COUNTER_ID_CHANGE_FIRST;
11156 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
11157 MapCounterButtons(i);
11159 // draw selectbox gadgets
11160 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
11161 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
11162 MapSelectboxGadget(i);
11164 // draw textbutton gadgets
11165 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
11166 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
11167 MapTextbuttonGadget(i);
11169 // draw graphicbutton gadgets
11170 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
11171 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
11172 MapGraphicbuttonGadget(i);
11174 // draw drawing area gadgets
11175 DrawPropertiesChangeDrawingAreas();
11178 static void DrawEditorElementAnimation(int x, int y)
11180 int graphic = el2img(properties_element);
11181 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
11182 custom_element.ce_value_fixed_initial :
11183 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
11184 custom_element.collect_score_initial : FrameCounter);
11186 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
11189 static void DrawEditorElementName(int x, int y, int font_nr)
11191 char *element_name = getElementInfoText(properties_element);
11192 int font_width = getFontWidth(font_nr);
11193 int font_height = getFontHeight(font_nr);
11194 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
11195 int max_chars_per_line = max_text_width / font_width;
11197 if (strlen(element_name) <= max_chars_per_line)
11198 DrawTextS(x, y, font_nr, element_name);
11201 char buffer[max_chars_per_line + 1];
11202 int next_pos = max_chars_per_line;
11204 strncpy(buffer, element_name, max_chars_per_line);
11205 buffer[max_chars_per_line] = '\0';
11207 if (element_name[max_chars_per_line] == ' ')
11213 for (i = max_chars_per_line - 1; i >= 0; i--)
11214 if (buffer[i] == ' ')
11217 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
11224 DrawTextS(x, y - font_height / 2, font_nr, buffer);
11226 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
11227 buffer[max_chars_per_line] = '\0';
11229 DrawTextS(x, y + font_height / 2, font_nr, buffer);
11233 static void DrawPropertiesWindow(void)
11235 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
11236 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
11237 int border_size = gd->border_size;
11238 int font_nr = FONT_TEXT_1;
11239 int font_height = getFontHeight(font_nr);
11240 int xoffset = TILEX + element_border + 3 * border_size;
11241 int yoffset = (TILEY - font_height) / 2;
11242 int x1 = editor.settings.element_graphic.x + element_border;
11243 int y1 = editor.settings.element_graphic.y + element_border;
11244 int x2 = (editor.settings.element_name.x == -1 ? x1 + xoffset :
11245 editor.settings.element_name.x);
11246 int y2 = (editor.settings.element_name.y == -1 ? y1 + yoffset :
11247 editor.settings.element_name.y);
11248 char *text = "Element Settings";
11249 int font2_nr = FONT_TITLE_1;
11250 struct MenuPosInfo *pos = &editor.settings.headline;
11251 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font2_nr), pos->align);
11252 int sy = SY + pos->y;
11254 stick_element_properties_window = FALSE;
11256 // make sure that previous properties edit mode exists for this element
11257 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
11258 !IS_CUSTOM_ELEMENT(properties_element))
11259 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
11261 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
11262 !IS_PLAYER_ELEMENT(properties_element) &&
11263 !IS_CUSTOM_ELEMENT(properties_element))
11264 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
11266 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
11267 (IS_PLAYER_ELEMENT(properties_element) ||
11268 IS_CUSTOM_ELEMENT(properties_element)))
11269 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
11271 CopyElementPropertiesToEditor(properties_element);
11273 UnmapLevelEditorFieldGadgets();
11274 UnmapLevelEditorToolboxDrawingGadgets();
11275 UnmapLevelEditorToolboxCustomGadgets();
11277 MapLevelEditorToolboxCustomGadgetsIfNeeded();
11279 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
11282 DrawText(sx, sy, text, font2_nr);
11284 FrameCounter = 0; // restart animation frame counter
11286 DrawElementBorder(SX + x1, SY + y1, TILEX, TILEY, FALSE);
11287 DrawEditorElementAnimation(SX + x1, SY + y1);
11288 DrawEditorElementName(x2, y2, font_nr);
11290 DrawPropertiesTabulatorGadgets();
11292 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
11293 DrawPropertiesInfo();
11294 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
11295 DrawPropertiesChange();
11296 else // (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2])
11297 DrawPropertiesConfig();
11300 static void DrawPaletteWindow(void)
11304 UnmapLevelEditorFieldGadgets();
11306 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
11309 // map buttons to select elements
11310 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
11311 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
11312 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
11313 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
11314 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
11317 static void UpdateCustomElementGraphicGadgets(void)
11321 InitElementPropertiesGfxElement();
11323 ModifyEditorElementList();
11324 RedrawDrawingElements();
11326 // force redraw of all mapped drawing area gadgets
11327 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
11329 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
11336 static int getOpenDirectionFromTube(int element)
11340 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
11341 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
11342 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
11343 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
11344 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
11345 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
11346 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
11347 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
11348 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
11349 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
11350 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
11356 static int getTubeFromOpenDirection(int direction)
11360 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
11361 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
11362 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
11363 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
11364 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
11365 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
11366 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
11367 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
11368 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
11369 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
11370 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
11372 // if only one direction, fall back to simple tube with that direction
11373 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
11374 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
11375 case (MV_UP): return EL_TUBE_VERTICAL;
11376 case (MV_DOWN): return EL_TUBE_VERTICAL;
11382 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
11384 int element_new = getTubeFromOpenDirection(direction);
11386 return (element_new != EL_EMPTY ? element_new : element_old);
11389 static int getOpenDirectionFromBelt(int element)
11391 int belt_dir = getBeltDirFromBeltElement(element);
11393 return (belt_dir == MV_LEFT ? MV_RIGHT :
11394 belt_dir == MV_RIGHT ? MV_LEFT :
11395 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
11398 static int getBeltFromNrAndOpenDirection(int nr, int direction)
11400 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
11401 direction == MV_RIGHT ? MV_LEFT :
11402 direction == MV_HORIZONTAL ? MV_NONE : direction);
11404 if (direction == MV_NONE)
11407 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
11410 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
11413 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
11415 return (element_new != EL_EMPTY ? element_new : element_old);
11418 static int getOpenDirectionFromPool(int element)
11422 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
11423 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
11424 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
11425 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
11426 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
11427 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
11433 static int getPoolFromOpenDirection(int direction)
11437 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
11438 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
11439 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
11440 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
11441 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
11442 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
11448 static int getPoolFromOpenDirectionExt(int direction, int help_element)
11450 int element = getPoolFromOpenDirection(direction);
11451 int help_direction = getOpenDirectionFromPool(help_element);
11453 if (element == EL_EMPTY)
11455 int help_direction_vertical = help_direction & MV_VERTICAL;
11457 element = getPoolFromOpenDirection(direction | help_direction_vertical);
11460 if (element == EL_EMPTY)
11462 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
11464 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
11470 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
11472 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
11474 return (element_new != EL_EMPTY ? element_new : element_old);
11477 static int getOpenDirectionFromPillar(int element)
11481 case EL_EMC_WALL_1: return (MV_DOWN);
11482 case EL_EMC_WALL_2: return (MV_VERTICAL);
11483 case EL_EMC_WALL_3: return (MV_UP);
11489 static int getPillarFromOpenDirection(int direction)
11493 case (MV_DOWN): return EL_EMC_WALL_1;
11494 case (MV_VERTICAL): return EL_EMC_WALL_2;
11495 case (MV_UP): return EL_EMC_WALL_3;
11501 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
11503 int element_new = getPillarFromOpenDirection(direction);
11505 return (element_new != EL_EMPTY ? element_new : element_old);
11508 static int getOpenDirectionFromSteel2(int element)
11512 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
11513 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
11514 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
11515 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
11516 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
11517 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
11518 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
11519 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
11525 static int getSteel2FromOpenDirection(int direction)
11529 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
11530 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
11531 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
11532 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
11533 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
11534 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
11535 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
11536 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
11542 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
11544 int element_new = getSteel2FromOpenDirection(direction);
11546 return (element_new != EL_EMPTY ? element_new : element_old);
11549 static int getOpenDirectionFromChip(int element)
11553 case EL_SP_CHIP_SINGLE: return (MV_NONE);
11554 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
11555 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
11556 case EL_SP_CHIP_TOP: return (MV_DOWN);
11557 case EL_SP_CHIP_BOTTOM: return (MV_UP);
11563 static int getChipFromOpenDirection(int direction)
11567 case (MV_NONE): return EL_SP_CHIP_SINGLE;
11568 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
11569 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
11570 case (MV_UP): return EL_SP_CHIP_BOTTOM;
11571 case (MV_DOWN): return EL_SP_CHIP_TOP;
11577 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
11579 int element_new = getChipFromOpenDirection(direction);
11581 return (element_new != EL_EMPTY ? element_new : element_old);
11584 static int getClosedTube(int x, int y)
11586 struct XY *xy = xy_directions;
11587 int element_old = IntelliDrawBuffer[x][y];
11588 int direction_old = getOpenDirectionFromTube(element_old);
11589 int direction_new = MV_NONE;
11592 for (i = 0; i < NUM_DIRECTIONS; i++)
11594 int xx = x + xy[i].x;
11595 int yy = y + xy[i].y;
11596 int dir = MV_DIR_FROM_BIT(i);
11597 int dir_opposite = MV_DIR_OPPOSITE(dir);
11599 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
11600 (direction_old & dir) &&
11601 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11602 direction_new |= dir;
11605 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
11608 static int getClosedBelt(int x, int y)
11610 struct XY *xy = xy_directions;
11611 int element_old = IntelliDrawBuffer[x][y];
11612 int nr = getBeltNrFromBeltElement(element_old);
11613 int direction_old = getOpenDirectionFromBelt(element_old);
11614 int direction_new = MV_NONE;
11617 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11619 int xx = x + xy[i].x;
11620 int yy = y + xy[i].y;
11621 int dir = MV_DIR_FROM_BIT(i);
11622 int dir_opposite = MV_DIR_OPPOSITE(dir);
11624 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
11625 (direction_old & dir) &&
11626 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11627 direction_new |= dir;
11630 return getBeltFromNrAndOpenDirection(nr, direction_new);
11633 static int getClosedPool(int x, int y)
11635 struct XY *xy = xy_directions;
11636 int element_old = IntelliDrawBuffer[x][y];
11637 int direction_old = getOpenDirectionFromPool(element_old);
11638 int direction_new = MV_NONE;
11641 for (i = 0; i < NUM_DIRECTIONS; i++)
11643 int xx = x + xy[i].x;
11644 int yy = y + xy[i].y;
11645 int dir = MV_DIR_FROM_BIT(i);
11646 int dir_opposite = MV_DIR_OPPOSITE(dir);
11648 if (IN_LEV_FIELD(xx, yy) &&
11649 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
11650 (direction_old & dir) &&
11651 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11652 direction_new |= dir;
11655 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
11658 static int getClosedPillar(int x, int y)
11660 struct XY *xy = xy_directions;
11661 int element_old = IntelliDrawBuffer[x][y];
11662 int direction_old = getOpenDirectionFromPillar(element_old);
11663 int direction_new = MV_NONE;
11666 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11668 int xx = x + xy[i].x;
11669 int yy = y + xy[i].y;
11670 int dir = MV_DIR_FROM_BIT(i);
11671 int dir_opposite = MV_DIR_OPPOSITE(dir);
11673 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
11674 (direction_old & dir) &&
11675 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11676 direction_new |= dir;
11679 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
11682 static int getClosedSteel2(int x, int y)
11684 struct XY *xy = xy_directions;
11685 int element_old = IntelliDrawBuffer[x][y];
11686 int direction_old = getOpenDirectionFromSteel2(element_old);
11687 int direction_new = MV_NONE;
11690 for (i = 0; i < NUM_DIRECTIONS; i++)
11692 int xx = x + xy[i].x;
11693 int yy = y + xy[i].y;
11694 int dir = MV_DIR_FROM_BIT(i);
11695 int dir_opposite = MV_DIR_OPPOSITE(dir);
11697 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
11698 (direction_old & dir) &&
11699 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11700 direction_new |= dir;
11703 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
11706 static int getClosedChip(int x, int y)
11708 struct XY *xy = xy_directions;
11709 int element_old = IntelliDrawBuffer[x][y];
11710 int direction_old = getOpenDirectionFromChip(element_old);
11711 int direction_new = MV_NONE;
11714 for (i = 0; i < NUM_DIRECTIONS; i++)
11716 int xx = x + xy[i].x;
11717 int yy = y + xy[i].y;
11718 int dir = MV_DIR_FROM_BIT(i);
11719 int dir_opposite = MV_DIR_OPPOSITE(dir);
11721 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
11722 (direction_old & dir) &&
11723 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11724 direction_new |= dir;
11727 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
11730 static void SetElementSimpleExt(int x, int y, int dx, int dy, int element,
11731 boolean change_level)
11733 int sx = x - level_xpos;
11734 int sy = y - level_ypos;
11735 int old_element = Tile[x][y];
11736 int new_element = element;
11737 unsigned int new_bitmask = (getDrawModeHiRes() ? (dx + 1) << (dy * 2) : 0x0f);
11738 boolean draw_masked = FALSE;
11740 if (IS_MM_WALL_EDITOR(element))
11742 element = map_mm_wall_element_editor(element) | new_bitmask;
11744 if (IS_MM_WALL(old_element))
11745 element |= MM_WALL_BITS(old_element);
11748 draw_masked = TRUE;
11750 else if (IS_MM_WALL(old_element) && element == EL_EMPTY)
11752 int element_changed = old_element & ~new_bitmask;
11754 if (MM_WALL_BITS(element_changed) != 0)
11755 element = element_changed;
11758 IntelliDrawBuffer[x][y] = element;
11761 Tile[x][y] = element;
11763 if (IN_ED_FIELD(sx, sy))
11765 if (IS_MM_WALL(old_element) && new_element == EL_EMPTY)
11766 DrawSizedWallParts_MM(sx, sy, EL_EMPTY, ed_tilesize, FALSE, new_bitmask);
11767 else if (draw_masked)
11768 DrawEditorElementThruMask(sx, sy, element);
11770 DrawEditorElement(sx, sy, element);
11774 static void SetElementSimple(int x, int y, int element, boolean change_level)
11776 SetElementSimpleExt(x, y, 0, 0, element, change_level);
11779 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
11780 int x2, int y2, int *element2,
11781 int (*close_function)(int, int),
11782 boolean change_level)
11784 // set neighbour elements to newly determined connections
11785 SetElementSimple(x1, y1, *element1, change_level);
11786 SetElementSimple(x2, y2, *element2, change_level);
11788 // remove all open connections of neighbour elements
11789 *element1 = close_function(x1, y1);
11790 *element2 = close_function(x2, y2);
11792 // set neighbour elements to new, minimized connections
11793 SetElementSimple(x1, y1, *element1, change_level);
11794 SetElementSimple(x2, y2, *element2, change_level);
11797 static void SetElementIntelliDraw(int x, int y, int dx, int dy, int new_element,
11798 boolean change_level, int button)
11800 struct XY *xy = xy_directions;
11801 static int last_x = -1;
11802 static int last_y = -1;
11804 if (new_element == EL_UNDEFINED)
11812 int old_element = IntelliDrawBuffer[x][y];
11814 if (IS_TUBE(new_element))
11816 int last_element_new = EL_UNDEFINED;
11817 int direction = MV_NONE;
11820 // if old element is of same kind, keep all existing directions
11821 if (IS_TUBE(old_element))
11822 direction |= getOpenDirectionFromTube(old_element);
11824 for (i = 0; i < NUM_DIRECTIONS; i++)
11826 int xx = x + xy[i].x;
11827 int yy = y + xy[i].y;
11829 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11830 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
11832 int dir = MV_DIR_FROM_BIT(i);
11833 int dir_opposite = MV_DIR_OPPOSITE(dir);
11834 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11835 int last_direction_old = getOpenDirectionFromTube(last_element_old);
11836 int last_direction_new = last_direction_old | dir_opposite;
11838 last_element_new = getTubeFromOpenDirection(last_direction_new);
11844 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
11846 if (last_element_new != EL_UNDEFINED)
11847 MergeAndCloseNeighbourElements(x, y, &new_element,
11848 last_x, last_y, &last_element_new,
11849 getClosedTube, change_level);
11851 else if (IS_BELT(new_element))
11853 int belt_nr = getBeltNrFromBeltElement(new_element);
11854 int last_element_new = EL_UNDEFINED;
11855 int direction = MV_NONE;
11858 // if old element is of same kind, keep all existing directions
11859 if (IS_BELT(old_element))
11860 direction |= getOpenDirectionFromBelt(old_element);
11862 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11864 int xx = x + xy[i].x;
11865 int yy = y + xy[i].y;
11867 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11868 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
11870 int dir = MV_DIR_FROM_BIT(i);
11871 int dir_opposite = MV_DIR_OPPOSITE(dir);
11872 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11873 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
11874 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
11875 int last_direction_new = last_direction_old | dir_opposite;
11877 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
11878 last_direction_new);
11883 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
11885 if (last_element_new != EL_UNDEFINED)
11886 MergeAndCloseNeighbourElements(x, y, &new_element,
11887 last_x, last_y, &last_element_new,
11888 getClosedBelt, change_level);
11890 else if (IS_ACID_POOL_OR_ACID(new_element))
11892 int last_element_new = EL_UNDEFINED;
11893 int direction = MV_NONE;
11896 // if old element is of same kind, keep all existing directions
11897 if (IS_ACID_POOL_OR_ACID(old_element))
11898 direction |= getOpenDirectionFromPool(old_element);
11900 for (i = 0; i < NUM_DIRECTIONS; i++)
11902 int xx = x + xy[i].x;
11903 int yy = y + xy[i].y;
11905 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11906 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
11908 int dir = MV_DIR_FROM_BIT(i);
11909 int dir_opposite = MV_DIR_OPPOSITE(dir);
11910 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11911 int last_direction_old = getOpenDirectionFromPool(last_element_old);
11912 int last_direction_new = last_direction_old | dir_opposite;
11914 last_element_new = getPoolFromOpenDirection(last_direction_new);
11920 // special corrections needed for intuitively correct acid pool drawing
11921 if (last_element_new == EL_EMPTY)
11922 last_element_new = new_element;
11923 else if (last_element_new != EL_UNDEFINED)
11924 new_element = last_element_new;
11926 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
11928 if (last_element_new != EL_UNDEFINED)
11929 MergeAndCloseNeighbourElements(x, y, &new_element,
11930 last_x, last_y, &last_element_new,
11931 getClosedPool, change_level);
11933 else if (IS_EMC_PILLAR(new_element))
11935 int last_element_new = EL_UNDEFINED;
11936 int direction = MV_NONE;
11939 // if old element is of same kind, keep all existing directions
11940 if (IS_EMC_PILLAR(old_element))
11941 direction |= getOpenDirectionFromPillar(old_element);
11943 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11945 int xx = x + xy[i].x;
11946 int yy = y + xy[i].y;
11948 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11949 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
11951 int dir = MV_DIR_FROM_BIT(i);
11952 int dir_opposite = MV_DIR_OPPOSITE(dir);
11953 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11954 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
11955 int last_direction_new = last_direction_old | dir_opposite;
11957 last_element_new = getPillarFromOpenDirection(last_direction_new);
11963 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
11965 if (last_element_new != EL_UNDEFINED)
11966 MergeAndCloseNeighbourElements(x, y, &new_element,
11967 last_x, last_y, &last_element_new,
11968 getClosedPillar, change_level);
11970 else if (IS_DC_STEELWALL_2(new_element))
11972 int last_element_new = EL_UNDEFINED;
11973 int direction = MV_NONE;
11976 // if old element is of same kind, keep all existing directions
11977 if (IS_DC_STEELWALL_2(old_element))
11978 direction |= getOpenDirectionFromSteel2(old_element);
11980 for (i = 0; i < NUM_DIRECTIONS; i++)
11982 int xx = x + xy[i].x;
11983 int yy = y + xy[i].y;
11985 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11986 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
11988 int dir = MV_DIR_FROM_BIT(i);
11989 int dir_opposite = MV_DIR_OPPOSITE(dir);
11990 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11991 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
11992 int last_direction_new = last_direction_old | dir_opposite;
11994 last_element_new = getSteel2FromOpenDirection(last_direction_new);
12000 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
12002 if (last_element_new != EL_UNDEFINED)
12003 MergeAndCloseNeighbourElements(x, y, &new_element,
12004 last_x, last_y, &last_element_new,
12005 getClosedSteel2, change_level);
12007 else if (IS_SP_CHIP(new_element))
12009 int last_element_new = EL_UNDEFINED;
12010 int direction = MV_NONE;
12013 // (do not keep existing directions, regardless of kind of old element)
12015 for (i = 0; i < NUM_DIRECTIONS; i++)
12017 int xx = x + xy[i].x;
12018 int yy = y + xy[i].y;
12020 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12021 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
12023 int dir = MV_DIR_FROM_BIT(i);
12024 int dir_opposite = MV_DIR_OPPOSITE(dir);
12025 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12026 int last_direction_old = getOpenDirectionFromChip(last_element_old);
12027 int last_direction_new = last_direction_old | dir_opposite;
12029 if (last_direction_old == MV_NONE)
12031 last_element_new = getChipFromOpenDirection(last_direction_new);
12034 else if (last_direction_old & (dir | dir_opposite))
12036 direction |= MV_DIR_OPPOSITE(last_direction_old);
12040 direction |= MV_DIR_OPPOSITE(dir);
12045 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
12047 if (last_element_new != EL_UNDEFINED)
12048 MergeAndCloseNeighbourElements(x, y, &new_element,
12049 last_x, last_y, &last_element_new,
12050 getClosedChip, change_level);
12052 else if (IS_SP_HARDWARE_BASE(new_element))
12054 int nr = GetSimpleRandom(6);
12056 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
12057 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
12058 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
12059 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
12060 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
12062 else if (new_element == EL_SP_HARDWARE_GREEN ||
12063 new_element == EL_SP_HARDWARE_BLUE ||
12064 new_element == EL_SP_HARDWARE_RED)
12066 int nr = GetSimpleRandom(3);
12068 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
12069 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
12071 else if (IS_GROUP_ELEMENT(new_element))
12073 boolean connected_drawing = FALSE;
12076 for (i = 0; i < NUM_DIRECTIONS; i++)
12078 int xx = x + xy[i].x;
12079 int yy = y + xy[i].y;
12081 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12082 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
12083 connected_drawing = TRUE;
12086 if (!connected_drawing)
12087 ResolveGroupElement(new_element);
12089 new_element = GetElementFromGroupElement(new_element);
12091 else if (IS_BELT_SWITCH(old_element))
12093 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
12094 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
12096 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
12097 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
12099 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
12103 static int swappable_elements[][2] =
12105 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
12106 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
12107 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
12108 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
12109 { EL_EMERALD, EL_WALL_EMERALD },
12110 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
12111 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
12112 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
12113 { EL_DIAMOND, EL_WALL_DIAMOND },
12114 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
12115 { EL_GATE_1, EL_GATE_1_GRAY },
12116 { EL_GATE_2, EL_GATE_2_GRAY },
12117 { EL_GATE_3, EL_GATE_3_GRAY },
12118 { EL_GATE_4, EL_GATE_4_GRAY },
12119 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
12120 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
12121 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
12122 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
12123 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
12124 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
12125 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
12126 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
12127 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
12128 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
12129 { EL_LAMP, EL_LAMP_ACTIVE },
12130 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
12131 { EL_SP_BASE, EL_SP_BUGGY_BASE },
12132 { EL_PEARL, EL_WALL_PEARL },
12133 { EL_CRYSTAL, EL_WALL_CRYSTAL },
12134 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
12135 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
12136 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
12137 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
12138 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
12139 { EL_LANDMINE, EL_DC_LANDMINE },
12140 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
12141 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
12142 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
12143 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
12144 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
12145 { EL_MM_EXIT_CLOSED, EL_MM_EXIT_OPEN },
12146 { EL_MM_FUSE, EL_MM_FUSE_ACTIVE },
12147 { EL_MM_LIGHTBULB, EL_MM_LIGHTBULB_ACTIVE },
12148 { EL_MM_FUEL_EMPTY, EL_MM_FUEL_FULL },
12152 static int rotatable_elements_4[][4] =
12162 EL_SPACESHIP_RIGHT,
12167 EL_BD_BUTTERFLY_UP,
12168 EL_BD_BUTTERFLY_RIGHT,
12169 EL_BD_BUTTERFLY_DOWN,
12170 EL_BD_BUTTERFLY_LEFT
12174 EL_BD_FIREFLY_RIGHT,
12175 EL_BD_FIREFLY_DOWN,
12203 EL_SP_GRAVITY_PORT_UP,
12204 EL_SP_GRAVITY_PORT_RIGHT,
12205 EL_SP_GRAVITY_PORT_DOWN,
12206 EL_SP_GRAVITY_PORT_LEFT
12209 EL_SP_GRAVITY_ON_PORT_UP,
12210 EL_SP_GRAVITY_ON_PORT_RIGHT,
12211 EL_SP_GRAVITY_ON_PORT_DOWN,
12212 EL_SP_GRAVITY_ON_PORT_LEFT
12215 EL_SP_GRAVITY_OFF_PORT_UP,
12216 EL_SP_GRAVITY_OFF_PORT_RIGHT,
12217 EL_SP_GRAVITY_OFF_PORT_DOWN,
12218 EL_SP_GRAVITY_OFF_PORT_LEFT
12227 EL_BALLOON_SWITCH_UP,
12228 EL_BALLOON_SWITCH_RIGHT,
12229 EL_BALLOON_SWITCH_DOWN,
12230 EL_BALLOON_SWITCH_LEFT
12234 EL_MM_MCDUFFIN_RIGHT,
12235 EL_MM_MCDUFFIN_DOWN,
12236 EL_MM_MCDUFFIN_LEFT
12239 EL_MM_MIRROR_FIXED_1,
12240 EL_MM_MIRROR_FIXED_4,
12241 EL_MM_MIRROR_FIXED_3,
12242 EL_MM_MIRROR_FIXED_2
12245 EL_MM_STEEL_GRID_FIXED_1,
12246 EL_MM_STEEL_GRID_FIXED_4,
12247 EL_MM_STEEL_GRID_FIXED_2,
12248 EL_MM_STEEL_GRID_FIXED_3
12251 EL_MM_WOODEN_GRID_FIXED_1,
12252 EL_MM_WOODEN_GRID_FIXED_4,
12253 EL_MM_WOODEN_GRID_FIXED_2,
12254 EL_MM_WOODEN_GRID_FIXED_3
12257 EL_MM_POLARIZER_CROSS_1,
12258 EL_MM_POLARIZER_CROSS_4,
12259 EL_MM_POLARIZER_CROSS_3,
12260 EL_MM_POLARIZER_CROSS_2
12264 EL_MM_PACMAN_RIGHT,
12276 EL_DF_RECEIVER_RIGHT,
12277 EL_DF_RECEIVER_DOWN,
12278 EL_DF_RECEIVER_LEFT
12291 static int rotatable_elements_8[][8] =
12294 EL_DF_STEEL_GRID_FIXED_1,
12295 EL_DF_STEEL_GRID_FIXED_8,
12296 EL_DF_STEEL_GRID_FIXED_7,
12297 EL_DF_STEEL_GRID_FIXED_6,
12298 EL_DF_STEEL_GRID_FIXED_5,
12299 EL_DF_STEEL_GRID_FIXED_4,
12300 EL_DF_STEEL_GRID_FIXED_3,
12301 EL_DF_STEEL_GRID_FIXED_2
12304 EL_DF_WOODEN_GRID_FIXED_1,
12305 EL_DF_WOODEN_GRID_FIXED_8,
12306 EL_DF_WOODEN_GRID_FIXED_7,
12307 EL_DF_WOODEN_GRID_FIXED_6,
12308 EL_DF_WOODEN_GRID_FIXED_5,
12309 EL_DF_WOODEN_GRID_FIXED_4,
12310 EL_DF_WOODEN_GRID_FIXED_3,
12311 EL_DF_WOODEN_GRID_FIXED_2
12314 EL_DF_STEEL_GRID_ROTATING_1,
12315 EL_DF_STEEL_GRID_ROTATING_8,
12316 EL_DF_STEEL_GRID_ROTATING_7,
12317 EL_DF_STEEL_GRID_ROTATING_6,
12318 EL_DF_STEEL_GRID_ROTATING_5,
12319 EL_DF_STEEL_GRID_ROTATING_4,
12320 EL_DF_STEEL_GRID_ROTATING_3,
12321 EL_DF_STEEL_GRID_ROTATING_2
12324 EL_DF_WOODEN_GRID_ROTATING_1,
12325 EL_DF_WOODEN_GRID_ROTATING_8,
12326 EL_DF_WOODEN_GRID_ROTATING_7,
12327 EL_DF_WOODEN_GRID_ROTATING_6,
12328 EL_DF_WOODEN_GRID_ROTATING_5,
12329 EL_DF_WOODEN_GRID_ROTATING_4,
12330 EL_DF_WOODEN_GRID_ROTATING_3,
12331 EL_DF_WOODEN_GRID_ROTATING_2
12338 static int rotatable_elements_16[][16] =
12359 EL_MM_TELEPORTER_5,
12360 EL_MM_TELEPORTER_4,
12361 EL_MM_TELEPORTER_3,
12362 EL_MM_TELEPORTER_2,
12363 EL_MM_TELEPORTER_1,
12364 EL_MM_TELEPORTER_16,
12365 EL_MM_TELEPORTER_15,
12366 EL_MM_TELEPORTER_14,
12367 EL_MM_TELEPORTER_13,
12368 EL_MM_TELEPORTER_12,
12369 EL_MM_TELEPORTER_11,
12370 EL_MM_TELEPORTER_10,
12371 EL_MM_TELEPORTER_9,
12372 EL_MM_TELEPORTER_8,
12373 EL_MM_TELEPORTER_7,
12377 EL_MM_TELEPORTER_RED_5,
12378 EL_MM_TELEPORTER_RED_4,
12379 EL_MM_TELEPORTER_RED_3,
12380 EL_MM_TELEPORTER_RED_2,
12381 EL_MM_TELEPORTER_RED_1,
12382 EL_MM_TELEPORTER_RED_16,
12383 EL_MM_TELEPORTER_RED_15,
12384 EL_MM_TELEPORTER_RED_14,
12385 EL_MM_TELEPORTER_RED_13,
12386 EL_MM_TELEPORTER_RED_12,
12387 EL_MM_TELEPORTER_RED_11,
12388 EL_MM_TELEPORTER_RED_10,
12389 EL_MM_TELEPORTER_RED_9,
12390 EL_MM_TELEPORTER_RED_8,
12391 EL_MM_TELEPORTER_RED_7,
12392 EL_MM_TELEPORTER_RED_6
12395 EL_MM_TELEPORTER_YELLOW_5,
12396 EL_MM_TELEPORTER_YELLOW_4,
12397 EL_MM_TELEPORTER_YELLOW_3,
12398 EL_MM_TELEPORTER_YELLOW_2,
12399 EL_MM_TELEPORTER_YELLOW_1,
12400 EL_MM_TELEPORTER_YELLOW_16,
12401 EL_MM_TELEPORTER_YELLOW_15,
12402 EL_MM_TELEPORTER_YELLOW_14,
12403 EL_MM_TELEPORTER_YELLOW_13,
12404 EL_MM_TELEPORTER_YELLOW_12,
12405 EL_MM_TELEPORTER_YELLOW_11,
12406 EL_MM_TELEPORTER_YELLOW_10,
12407 EL_MM_TELEPORTER_YELLOW_9,
12408 EL_MM_TELEPORTER_YELLOW_8,
12409 EL_MM_TELEPORTER_YELLOW_7,
12410 EL_MM_TELEPORTER_YELLOW_6
12413 EL_MM_TELEPORTER_GREEN_5,
12414 EL_MM_TELEPORTER_GREEN_4,
12415 EL_MM_TELEPORTER_GREEN_3,
12416 EL_MM_TELEPORTER_GREEN_2,
12417 EL_MM_TELEPORTER_GREEN_1,
12418 EL_MM_TELEPORTER_GREEN_16,
12419 EL_MM_TELEPORTER_GREEN_15,
12420 EL_MM_TELEPORTER_GREEN_14,
12421 EL_MM_TELEPORTER_GREEN_13,
12422 EL_MM_TELEPORTER_GREEN_12,
12423 EL_MM_TELEPORTER_GREEN_11,
12424 EL_MM_TELEPORTER_GREEN_10,
12425 EL_MM_TELEPORTER_GREEN_9,
12426 EL_MM_TELEPORTER_GREEN_8,
12427 EL_MM_TELEPORTER_GREEN_7,
12428 EL_MM_TELEPORTER_GREEN_6
12431 EL_MM_TELEPORTER_BLUE_5,
12432 EL_MM_TELEPORTER_BLUE_4,
12433 EL_MM_TELEPORTER_BLUE_3,
12434 EL_MM_TELEPORTER_BLUE_2,
12435 EL_MM_TELEPORTER_BLUE_1,
12436 EL_MM_TELEPORTER_BLUE_16,
12437 EL_MM_TELEPORTER_BLUE_15,
12438 EL_MM_TELEPORTER_BLUE_14,
12439 EL_MM_TELEPORTER_BLUE_13,
12440 EL_MM_TELEPORTER_BLUE_12,
12441 EL_MM_TELEPORTER_BLUE_11,
12442 EL_MM_TELEPORTER_BLUE_10,
12443 EL_MM_TELEPORTER_BLUE_9,
12444 EL_MM_TELEPORTER_BLUE_8,
12445 EL_MM_TELEPORTER_BLUE_7,
12446 EL_MM_TELEPORTER_BLUE_6
12450 EL_MM_POLARIZER_16,
12451 EL_MM_POLARIZER_15,
12452 EL_MM_POLARIZER_14,
12453 EL_MM_POLARIZER_13,
12454 EL_MM_POLARIZER_12,
12455 EL_MM_POLARIZER_11,
12456 EL_MM_POLARIZER_10,
12485 EL_DF_MIRROR_ROTATING_1,
12486 EL_DF_MIRROR_ROTATING_16,
12487 EL_DF_MIRROR_ROTATING_15,
12488 EL_DF_MIRROR_ROTATING_14,
12489 EL_DF_MIRROR_ROTATING_13,
12490 EL_DF_MIRROR_ROTATING_12,
12491 EL_DF_MIRROR_ROTATING_11,
12492 EL_DF_MIRROR_ROTATING_10,
12493 EL_DF_MIRROR_ROTATING_9,
12494 EL_DF_MIRROR_ROTATING_8,
12495 EL_DF_MIRROR_ROTATING_7,
12496 EL_DF_MIRROR_ROTATING_6,
12497 EL_DF_MIRROR_ROTATING_5,
12498 EL_DF_MIRROR_ROTATING_4,
12499 EL_DF_MIRROR_ROTATING_3,
12500 EL_DF_MIRROR_ROTATING_2
12503 EL_DF_MIRROR_FIXED_1,
12504 EL_DF_MIRROR_FIXED_16,
12505 EL_DF_MIRROR_FIXED_15,
12506 EL_DF_MIRROR_FIXED_14,
12507 EL_DF_MIRROR_FIXED_13,
12508 EL_DF_MIRROR_FIXED_12,
12509 EL_DF_MIRROR_FIXED_11,
12510 EL_DF_MIRROR_FIXED_10,
12511 EL_DF_MIRROR_FIXED_9,
12512 EL_DF_MIRROR_FIXED_8,
12513 EL_DF_MIRROR_FIXED_7,
12514 EL_DF_MIRROR_FIXED_6,
12515 EL_DF_MIRROR_FIXED_5,
12516 EL_DF_MIRROR_FIXED_4,
12517 EL_DF_MIRROR_FIXED_3,
12518 EL_DF_MIRROR_FIXED_2
12527 for (i = 0; swappable_elements[i][0] != -1; i++)
12529 int element1 = swappable_elements[i][0];
12530 int element2 = swappable_elements[i][1];
12532 if (old_element == element1 || old_element == element2)
12533 new_element = (old_element == element1 ? element2 : element1);
12536 for (i = 0; rotatable_elements_4[i][0] != -1; i++)
12538 for (j = 0; j < 4; j++)
12540 int element = rotatable_elements_4[i][j];
12542 if (old_element == element)
12543 new_element = (button == 1 ? rotatable_elements_4[i][(j + 3) % 4] :
12544 button == 2 ? rotatable_elements_4[i][0] :
12545 button == 3 ? rotatable_elements_4[i][(j + 1) % 4] :
12550 for (i = 0; rotatable_elements_8[i][0] != -1; i++)
12552 for (j = 0; j < 8; j++)
12554 int element = rotatable_elements_8[i][j];
12556 if (old_element == element)
12557 new_element = (button == 1 ? rotatable_elements_8[i][(j + 7) % 8] :
12558 button == 2 ? rotatable_elements_8[i][0] :
12559 button == 3 ? rotatable_elements_8[i][(j + 1) % 8] :
12564 for (i = 0; rotatable_elements_16[i][0] != -1; i++)
12566 for (j = 0; j < 16; j++)
12568 int element = rotatable_elements_16[i][j];
12570 if (old_element == element)
12571 new_element = (button == 1 ? rotatable_elements_16[i][(j + 15) % 16] :
12572 button == 2 ? rotatable_elements_16[i][0] :
12573 button == 3 ? rotatable_elements_16[i][(j + 1) % 16] :
12578 if (old_element != new_element)
12580 int max_infotext_len = getMaxInfoTextLength();
12581 char infotext[MAX_OUTPUT_LINESIZE + 1];
12583 strncpy(infotext, getElementInfoText(new_element), max_infotext_len);
12584 infotext[max_infotext_len] = '\0';
12586 ClearEditorGadgetInfoText();
12588 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT,
12593 if (IS_MM_WALL_EDITOR(new_element))
12594 SetElementSimpleExt(x, y, dx, dy, new_element, change_level);
12596 SetElementSimple(x, y, new_element, change_level);
12602 static void ResetIntelliDraw(void)
12606 for (x = 0; x < lev_fieldx; x++)
12607 for (y = 0; y < lev_fieldy; y++)
12608 IntelliDrawBuffer[x][y] = Tile[x][y];
12610 SetElementIntelliDraw(-1, -1, -1, -1, EL_UNDEFINED, FALSE, -1);
12613 static boolean draw_mode_hires = FALSE;
12615 static boolean isHiresTileElement(int element)
12617 return (IS_MM_WALL(element) || element == EL_EMPTY);
12620 static boolean isHiresDrawElement(int element)
12622 return (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY);
12625 static int numHiresTiles(int element)
12627 if (IS_MM_WALL(element))
12628 return get_number_of_bits(MM_WALL_BITS(element));
12633 static void SetDrawModeHiRes(int element)
12636 (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
12637 isHiresDrawElement(element));
12640 static boolean getDrawModeHiRes(void)
12642 return draw_mode_hires;
12645 static int getLoResScreenPos(int pos)
12647 return (getDrawModeHiRes() ? pos / 2 : pos);
12650 static int getLoResScreenMod(int pos)
12652 return (getDrawModeHiRes() ? pos % 2 : 0);
12655 static void SetElementExt(int x, int y, int dx, int dy, int element,
12656 boolean change_level, int button)
12659 SetElementSimple(x, y, Tile[x][y], change_level);
12660 else if (GetKeyModState() & KMOD_Shift)
12661 SetElementIntelliDraw(x, y, dx, dy, element, change_level, button);
12663 SetElementSimpleExt(x, y, dx, dy, element, change_level);
12666 static void SetElement(int x, int y, int element)
12668 SetElementExt(x, y, 0, 0, element, TRUE, -1);
12671 static void SetElementButton(int x, int y, int dx, int dy, int element,
12674 SetElementExt(x, y, dx, dy, element, TRUE, button);
12677 static void SetElementHiRes(int sx2, int sy2, int element, boolean change_level)
12679 int lx = getLoResScreenPos(sx2) + level_xpos;
12680 int ly = getLoResScreenPos(sy2) + level_ypos;
12681 int dx = getLoResScreenMod(sx2);
12682 int dy = getLoResScreenMod(sy2);
12684 SetElementExt(lx, ly, dx, dy, element, change_level, -1);
12687 static void SetLevelElementHiRes(int lx2, int ly2, int element)
12694 SetElementExt(lx, ly, dx, dy, element, TRUE, -1);
12697 static int getLevelElementHiRes(int lx2, int ly2)
12703 int element = Tile[lx][ly];
12704 unsigned int bitmask = (dx + 1) << (dy * 2);
12706 if (IS_MM_WALL(element))
12708 if (element & bitmask)
12709 return map_mm_wall_element(element);
12717 static void DrawLineElement(int x, int y, int element, boolean change_level)
12719 SetElementHiRes(x, y, element, change_level);
12722 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
12723 int element, boolean change_level)
12725 int xsize = ABS(to_x - from_x);
12726 int ysize = ABS(to_y - from_y);
12727 int dx = (to_x < from_x ? -1 : +1);
12728 int dy = (to_y < from_y ? -1 : +1);
12731 if (from_y == to_y) // horizontal line
12733 for (i = 0; i <= xsize; i++)
12734 DrawLineElement(from_x + i * dx, from_y, element, change_level);
12736 else if (from_x == to_x) // vertical line
12738 for (i = 0; i <= ysize; i++)
12739 DrawLineElement(from_x, from_y + i * dy, element, change_level);
12741 else // diagonal line
12743 if (ysize < xsize) // a < 1
12745 float a = (float)ysize / (float)xsize;
12747 for (i = 0; i <= xsize; i++)
12750 int y = dy * (int)(a * i + 0.5);
12752 DrawLineElement(from_x + x, from_y + y, element, change_level);
12757 float a = (float)xsize / (float)ysize;
12759 for (i = 0; i <= ysize; i++)
12761 int x = dx * (int)(a * i + 0.5);
12764 DrawLineElement(from_x + x, from_y + y, element, change_level);
12770 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
12771 int element, boolean change_level)
12773 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
12774 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
12775 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
12776 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
12779 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
12780 int element, boolean change_level)
12785 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
12787 for (y = from_y; y <= to_y; y++)
12788 DrawLine(from_x, y, to_x, y, element, change_level);
12791 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
12792 int element, boolean change_level)
12794 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
12795 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
12796 int len_x = ABS(to_x - from_x);
12797 int len_y = ABS(to_y - from_y);
12800 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
12802 // not optimal (some points get drawn twice) but simple,
12803 // and fast enough for the few points we are drawing
12805 for (x = 0; x <= radius; x++)
12807 int sx, sy, sx2, sy2, lx, ly;
12809 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
12811 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12812 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12813 sx = getLoResScreenPos(sx2);
12814 sy = getLoResScreenPos(sy2);
12815 lx = sx + level_xpos;
12816 ly = sy + level_ypos;
12818 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12819 DrawLineElement(sx2, sy2, element, change_level);
12822 for (y = 0; y <= radius; y++)
12824 int sx, sy, sx2, sy2, lx, ly;
12826 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
12828 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12829 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12830 sx = getLoResScreenPos(sx2);
12831 sy = getLoResScreenPos(sy2);
12832 lx = sx + level_xpos;
12833 ly = sy + level_ypos;
12835 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12836 DrawLineElement(sx2, sy2, element, change_level);
12840 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
12841 int element, boolean change_level)
12843 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12844 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12846 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12849 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
12851 #if DRAW_CIRCLES_BUTTON_AVAILABLE
12852 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
12853 int element, boolean change_level)
12855 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12856 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12857 int mirror_to_x2 = from_x - (to_x2 - from_x);
12858 int mirror_to_y2 = from_y - (to_y2 - from_y);
12860 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12861 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
12862 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
12863 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element, change_level);
12867 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
12869 int from_sx, from_sy;
12873 swap_numbers(&from_x, &to_x);
12876 swap_numbers(&from_y, &to_y);
12878 from_sx = SX + from_x * ed_tilesize;
12879 from_sy = SY + from_y * ed_tilesize;
12880 to_sx = SX + (to_x + 1) * ed_tilesize - 1;
12881 to_sy = SY + (to_y + 1) * ed_tilesize - 1;
12883 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
12884 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
12885 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
12886 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
12888 if (from_x == to_x && from_y == to_y)
12889 MarkTileDirty(from_x/2, from_y/2);
12891 redraw_mask |= REDRAW_FIELD;
12894 static void DrawAreaBox(int from_x, int from_y, int to_x, int to_y,
12895 int element, boolean change_level)
12897 DrawBox(from_x, from_y, to_x, to_y, element, change_level);
12900 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
12901 int element, boolean change_level)
12903 if (element == -1 || change_level)
12904 DrawAreaBox(from_x, from_y, to_x, to_y, -1, FALSE);
12906 DrawAreaBorder(from_x, from_y, to_x, to_y);
12909 // values for CopyBrushExt()
12910 #define CB_AREA_TO_BRUSH 0
12911 #define CB_BRUSH_TO_CURSOR 1
12912 #define CB_BRUSH_TO_LEVEL 2
12913 #define CB_DELETE_OLD_CURSOR 3
12914 #define CB_DUMP_BRUSH 4
12915 #define CB_DUMP_BRUSH_SMALL 5
12916 #define CB_CLIPBOARD_TO_BRUSH 6
12917 #define CB_BRUSH_TO_CLIPBOARD 7
12918 #define CB_BRUSH_TO_CLIPBOARD_SMALL 8
12919 #define CB_UPDATE_BRUSH_POSITION 9
12920 #define CB_FLIP_BRUSH_X 10
12921 #define CB_FLIP_BRUSH_Y 11
12922 #define CB_FLIP_BRUSH_XY 12
12924 #define MAX_CB_PART_SIZE 10
12925 #define MAX_CB_LINE_SIZE (MAX_LEV_FIELDX + 1) // text plus newline
12926 #define MAX_CB_NUM_LINES (MAX_LEV_FIELDY)
12927 #define MAX_CB_TEXT_SIZE (MAX_CB_LINE_SIZE * \
12928 MAX_CB_NUM_LINES * \
12931 static int getFlippedTileExt(int map[], int element)
12935 for (i = 0; map[i] != -1; i++)
12936 if (map[i] == element)
12937 return map[i ^ 1]; // get flipped element by flipping LSB of index
12942 static int getFlippedTileX(int element)
12946 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_RIGHT,
12947 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_RIGHT,
12948 EL_BUG_LEFT, EL_BUG_RIGHT,
12949 EL_SPACESHIP_LEFT, EL_SPACESHIP_RIGHT,
12950 EL_PACMAN_LEFT, EL_PACMAN_RIGHT,
12951 EL_ARROW_LEFT, EL_ARROW_RIGHT,
12952 EL_MOLE_LEFT, EL_MOLE_RIGHT,
12953 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_RIGHT,
12954 EL_YAMYAM_LEFT, EL_YAMYAM_RIGHT,
12955 EL_SP_PORT_LEFT, EL_SP_PORT_RIGHT,
12956 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_RIGHT,
12957 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_RIGHT,
12958 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_RIGHT,
12959 EL_CONVEYOR_BELT_1_LEFT, EL_CONVEYOR_BELT_1_RIGHT,
12960 EL_CONVEYOR_BELT_2_LEFT, EL_CONVEYOR_BELT_2_RIGHT,
12961 EL_CONVEYOR_BELT_3_LEFT, EL_CONVEYOR_BELT_3_RIGHT,
12962 EL_CONVEYOR_BELT_4_LEFT, EL_CONVEYOR_BELT_4_RIGHT,
12963 EL_SPRING_LEFT, EL_SPRING_RIGHT,
12964 EL_SP_CHIP_LEFT, EL_SP_CHIP_RIGHT,
12965 EL_TUBE_VERTICAL_LEFT, EL_TUBE_VERTICAL_RIGHT,
12966 EL_TUBE_LEFT_UP, EL_TUBE_RIGHT_UP,
12967 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_DOWN,
12968 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_RIGHT,
12969 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_TOPRIGHT,
12970 EL_DC_STEELWALL_1_BOTTOMLEFT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
12971 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_TOPRIGHT_2,
12972 EL_DC_STEELWALL_1_BOTTOMLEFT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
12973 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_RIGHT,
12974 EL_ACID_POOL_TOPLEFT, EL_ACID_POOL_TOPRIGHT,
12975 EL_ACID_POOL_BOTTOMLEFT, EL_ACID_POOL_BOTTOMRIGHT,
12980 return getFlippedTileExt(map, element);
12983 static int getFlippedTileY(int element)
12987 EL_BD_BUTTERFLY_UP, EL_BD_BUTTERFLY_DOWN,
12988 EL_BD_FIREFLY_UP, EL_BD_FIREFLY_DOWN,
12989 EL_BUG_UP, EL_BUG_DOWN,
12990 EL_SPACESHIP_UP, EL_SPACESHIP_DOWN,
12991 EL_PACMAN_UP, EL_PACMAN_DOWN,
12992 EL_ARROW_UP, EL_ARROW_DOWN,
12993 EL_MOLE_UP, EL_MOLE_DOWN,
12994 EL_BALLOON_SWITCH_UP, EL_BALLOON_SWITCH_DOWN,
12995 EL_YAMYAM_UP, EL_YAMYAM_DOWN,
12996 EL_SP_PORT_UP, EL_SP_PORT_DOWN,
12997 EL_SP_GRAVITY_PORT_UP, EL_SP_GRAVITY_PORT_DOWN,
12998 EL_SP_GRAVITY_ON_PORT_UP, EL_SP_GRAVITY_ON_PORT_DOWN,
12999 EL_SP_GRAVITY_OFF_PORT_UP, EL_SP_GRAVITY_OFF_PORT_DOWN,
13000 EL_SP_CHIP_TOP, EL_SP_CHIP_BOTTOM,
13001 EL_TUBE_HORIZONTAL_UP, EL_TUBE_HORIZONTAL_DOWN,
13002 EL_TUBE_LEFT_UP, EL_TUBE_LEFT_DOWN,
13003 EL_TUBE_RIGHT_UP, EL_TUBE_RIGHT_DOWN,
13004 EL_DC_STEELWALL_1_TOP, EL_DC_STEELWALL_1_BOTTOM,
13005 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_BOTTOMLEFT,
13006 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
13007 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
13008 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
13009 EL_DC_STEELWALL_2_TOP, EL_DC_STEELWALL_2_BOTTOM,
13010 EL_EMC_WALL_1, EL_EMC_WALL_3,
13015 return getFlippedTileExt(map, element);
13018 static int getFlippedTileXY(int element)
13022 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_UP,
13023 EL_BD_BUTTERFLY_RIGHT, EL_BD_BUTTERFLY_DOWN,
13024 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_UP,
13025 EL_BD_FIREFLY_RIGHT, EL_BD_FIREFLY_DOWN,
13026 EL_BUG_LEFT, EL_BUG_UP,
13027 EL_BUG_RIGHT, EL_BUG_DOWN,
13028 EL_SPACESHIP_LEFT, EL_SPACESHIP_UP,
13029 EL_SPACESHIP_RIGHT, EL_SPACESHIP_DOWN,
13030 EL_PACMAN_LEFT, EL_PACMAN_UP,
13031 EL_PACMAN_RIGHT, EL_PACMAN_DOWN,
13032 EL_ARROW_LEFT, EL_ARROW_UP,
13033 EL_ARROW_RIGHT, EL_ARROW_DOWN,
13034 EL_MOLE_LEFT, EL_MOLE_UP,
13035 EL_MOLE_RIGHT, EL_MOLE_DOWN,
13036 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_UP,
13037 EL_BALLOON_SWITCH_RIGHT, EL_BALLOON_SWITCH_DOWN,
13038 EL_YAMYAM_LEFT, EL_YAMYAM_UP,
13039 EL_YAMYAM_RIGHT, EL_YAMYAM_DOWN,
13040 EL_SP_PORT_LEFT, EL_SP_PORT_UP,
13041 EL_SP_PORT_RIGHT, EL_SP_PORT_DOWN,
13042 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_UP,
13043 EL_SP_GRAVITY_PORT_RIGHT, EL_SP_GRAVITY_PORT_DOWN,
13044 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_UP,
13045 EL_SP_GRAVITY_ON_PORT_RIGHT, EL_SP_GRAVITY_ON_PORT_DOWN,
13046 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_UP,
13047 EL_SP_GRAVITY_OFF_PORT_RIGHT, EL_SP_GRAVITY_OFF_PORT_DOWN,
13048 EL_SP_CHIP_LEFT, EL_SP_CHIP_TOP,
13049 EL_SP_CHIP_RIGHT, EL_SP_CHIP_BOTTOM,
13050 EL_TUBE_VERTICAL, EL_TUBE_HORIZONTAL,
13051 EL_TUBE_VERTICAL_LEFT, EL_TUBE_HORIZONTAL_UP,
13052 EL_TUBE_VERTICAL_RIGHT, EL_TUBE_HORIZONTAL_DOWN,
13053 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_UP,
13054 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_TOP,
13055 EL_DC_STEELWALL_1_RIGHT, EL_DC_STEELWALL_1_BOTTOM,
13056 EL_DC_STEELWALL_1_HORIZONTAL, EL_DC_STEELWALL_1_VERTICAL,
13057 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMLEFT,
13058 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
13059 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_TOP,
13060 EL_DC_STEELWALL_2_RIGHT, EL_DC_STEELWALL_2_BOTTOM,
13061 EL_DC_STEELWALL_2_HORIZONTAL, EL_DC_STEELWALL_2_VERTICAL,
13062 EL_EXPANDABLE_WALL_HORIZONTAL, EL_EXPANDABLE_WALL_VERTICAL,
13063 EL_EXPANDABLE_STEELWALL_HORIZONTAL, EL_EXPANDABLE_STEELWALL_VERTICAL,
13068 return getFlippedTileExt(map, element);
13071 static int getFlippedTile(int element, int mode)
13073 if (IS_MM_ELEMENT(element))
13075 // get MM game element
13076 element = map_element_RND_to_MM(element);
13078 // get flipped game element
13079 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX_MM(element) :
13080 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY_MM(element) :
13081 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY_MM(element) :
13084 // get RND game element again
13085 element = map_element_MM_to_RND(element);
13089 // get flipped game element
13090 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX(element) :
13091 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY(element) :
13092 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY(element) :
13099 static void SwapFlippedTiles(short *tile1, short *tile2, int mode)
13102 short tile1_flipped = getFlippedTile(*tile1, mode);
13103 short tile2_flipped = getFlippedTile(*tile2, mode);
13106 *tile1 = tile2_flipped;
13107 *tile2 = tile1_flipped;
13110 static void DrawBrushElement(int sx, int sy, int element, boolean change_level)
13112 DrawLineElement(sx, sy, element, change_level);
13115 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
13116 int button, int mode)
13118 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
13119 static int brush_width, brush_height;
13120 static int last_cursor_x = -1, last_cursor_y = -1;
13121 static boolean delete_old_brush = FALSE;
13122 int new_element = BUTTON_ELEMENT(button);
13125 if (mode == CB_DUMP_BRUSH ||
13126 mode == CB_DUMP_BRUSH_SMALL ||
13127 mode == CB_BRUSH_TO_CLIPBOARD ||
13128 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
13130 if (edit_mode != ED_MODE_DRAWING)
13133 char part[MAX_CB_PART_SIZE + 1] = "";
13134 char text[MAX_CB_TEXT_SIZE + 1] = "";
13135 int width = (draw_with_brush ? brush_width : lev_fieldx);
13136 int height = (draw_with_brush ? brush_height : lev_fieldy);
13137 char *format = "%s%03d";
13139 for (y = 0; y < height; y++)
13140 for (x = 0; x < width; x++)
13141 if ((draw_with_brush ? brush_buffer[x][y] : Tile[x][y]) > 999)
13144 for (y = 0; y < height; y++)
13146 for (x = 0; x < width; x++)
13148 int element = (draw_with_brush ? brush_buffer[x][y] : Tile[x][y]);
13149 char *prefix = (mode == CB_DUMP_BRUSH ||
13150 mode == CB_BRUSH_TO_CLIPBOARD ? "`" : "¸");
13152 if (element >= NUM_FILE_ELEMENTS)
13153 element = EL_UNKNOWN;
13155 // copy brush to level sketch text buffer for the R'n'D forum:
13156 // - large tiles: `xxx or `xxxx (0x60 ASCII)
13157 // - small tiles: ¸xxx or ¸xxxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
13158 snprintf(part, MAX_CB_PART_SIZE + 1, format, prefix, element);
13159 strcat(text, part);
13162 strcat(text, "\n");
13165 if (mode == CB_BRUSH_TO_CLIPBOARD ||
13166 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
13167 SDL_SetClipboardText(text);
13169 Print("%s", text); // print brush data to console and log file
13174 if (mode == CB_CLIPBOARD_TO_BRUSH)
13176 if (edit_mode != ED_MODE_DRAWING)
13179 if (!SDL_HasClipboardText())
13181 Request("Clipboard is empty!", REQ_CONFIRM);
13186 boolean copy_to_brush = (draw_with_brush ||
13187 drawing_function == GADGET_ID_GRAB_BRUSH);
13189 // this will delete the old brush, if already drawing with a brush
13191 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], MB_LEFTBUTTON);
13193 // initialization is required for "odd" (incomplete) clipboard content
13194 for (x = 0; x < MAX_LEV_FIELDX; x++)
13195 for (y = 0; y < MAX_LEV_FIELDY; y++)
13196 brush_buffer[x][y] = EL_EMPTY;
13203 char *clipboard_text = SDL_GetClipboardText();
13204 char *ptr = clipboard_text;
13205 boolean allow_new_row = FALSE;
13206 boolean stop = FALSE;
13208 while (*ptr && !stop)
13210 boolean prefix_found = FALSE;
13211 boolean start_new_row = FALSE;
13213 // level sketch element number prefixes (may be multi-byte characters)
13214 char *prefix_list[] = { "`", "¸" };
13217 for (i = 0; i < ARRAY_SIZE(prefix_list); i++)
13219 char *prefix = prefix_list[i];
13221 // check if string is large enough for prefix
13222 if (strlen(ptr) < strlen(prefix))
13229 // check if string starts with prefix
13230 if (strPrefix(ptr, prefix))
13232 ptr += strlen(prefix);
13234 prefix_found = TRUE;
13240 // check if prefix found and followed by (at least) three digits
13241 if (prefix_found &&
13242 strlen(ptr) >= 3 &&
13243 ptr[0] >= '0' && ptr[0] <= '9' &&
13244 ptr[1] >= '0' && ptr[1] <= '9' &&
13245 ptr[2] >= '0' && ptr[2] <= '9')
13247 int element = ((ptr[0] - '0') * 100 +
13248 (ptr[1] - '0') * 10 +
13253 // level sketch element number might consist of four digits
13254 if (ptr[0] >= '0' && ptr[0] <= '9')
13256 element = element * 10 + (ptr[0] - '0');
13260 // remap some (historic, now obsolete) elements
13261 element = getMappedElement(element);
13263 if (element >= NUM_FILE_ELEMENTS)
13264 element = EL_UNKNOWN;
13266 brush_buffer[x][y] = element;
13268 brush_width = MAX(x + 1, brush_width);
13269 brush_height = MAX(y + 1, brush_height);
13273 if (x >= MAX_LEV_FIELDX)
13274 start_new_row = TRUE;
13276 allow_new_row = TRUE;
13280 if ((*ptr == '\n' || *ptr == '\r') && allow_new_row)
13281 start_new_row = TRUE;
13283 ptr++; // !!! FIX THIS for real UTF-8 handling !!!
13291 if (y >= MAX_LEV_FIELDY)
13294 allow_new_row = FALSE;
13298 SDL_free(clipboard_text);
13300 if (brush_width == 0 || brush_height == 0)
13302 Request("No level sketch found in clipboard!", REQ_CONFIRM);
13309 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_DRAWING_LEVEL];
13312 SDL_GetMouseState(&mx, &my);
13314 // if inside drawing area, activate and draw brush at last mouse position
13315 if (mx >= gi->x && mx < gi->x + gi->width &&
13316 my >= gi->y && my < gi->y + gi->height)
13317 CopyBrushToCursor(last_cursor_x, last_cursor_y);
13319 draw_with_brush = TRUE;
13325 sprintf(request, "Replace level with %dx%d level sketch from clipboard?",
13326 brush_width, brush_height);
13328 if (!Request(request, REQ_ASK))
13331 for (x = 0; x < MAX_LEV_FIELDX; x++)
13332 for (y = 0; y < MAX_LEV_FIELDY; y++)
13333 Tile[x][y] = brush_buffer[x][y];
13335 lev_fieldx = level.fieldx = brush_width;
13336 lev_fieldy = level.fieldy = brush_height;
13338 boolean use_bd_engine = TRUE;
13339 boolean use_em_engine = TRUE;
13340 boolean use_sp_engine = TRUE;
13341 boolean use_mm_engine = TRUE;
13343 for (x = 0; x < MAX_LEV_FIELDX; x++)
13345 for (y = 0; y < MAX_LEV_FIELDY; y++)
13347 int element = Tile[x][y];
13349 if (!IS_BD_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
13350 use_bd_engine = FALSE;
13352 if (!IS_EM_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
13353 use_em_engine = FALSE;
13355 if (!IS_SP_ELEMENT(element))
13356 use_sp_engine = FALSE;
13358 if (!IS_MM_ELEMENT(element) && element != EL_EMPTY)
13359 use_mm_engine = FALSE;
13363 level.game_engine_type = (use_bd_engine ? GAME_ENGINE_TYPE_BD :
13364 use_em_engine ? GAME_ENGINE_TYPE_EM :
13365 use_sp_engine ? GAME_ENGINE_TYPE_SP :
13366 use_mm_engine ? GAME_ENGINE_TYPE_MM :
13367 GAME_ENGINE_TYPE_RND);
13369 // update element selection list
13370 ReinitializeElementList();
13371 ModifyEditorElementList();
13373 SetBorderElement();
13375 DrawEditModeWindow();
13376 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13382 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
13385 if (mode == CB_AREA_TO_BRUSH)
13387 int from_lx, from_ly;
13390 swap_numbers(&from_x, &to_x);
13393 swap_numbers(&from_y, &to_y);
13395 brush_width = to_x - from_x + 1;
13396 brush_height = to_y - from_y + 1;
13398 from_lx = from_x + level_xpos;
13399 from_ly = from_y + level_ypos;
13401 for (y = 0; y < brush_height; y++)
13403 for (x = 0; x < brush_width; x++)
13405 brush_buffer[x][y] = Tile[from_lx + x][from_ly + y];
13408 DrawBrushElement(from_x + x, from_y + y, new_element, TRUE);
13413 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13415 delete_old_brush = FALSE;
13417 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
13418 mode == CB_BRUSH_TO_LEVEL)
13420 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
13421 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
13422 int cursor_from_x = cursor_x - brush_width / 2;
13423 int cursor_from_y = cursor_y - brush_height / 2;
13424 int border_from_x = cursor_x, border_from_y = cursor_y;
13425 int border_to_x = cursor_x, border_to_y = cursor_y;
13427 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
13428 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13430 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
13431 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
13433 delete_old_brush = FALSE;
13438 for (y = 0; y < brush_height; y++)
13440 for (x = 0; x < brush_width; x++)
13442 int sx = cursor_from_x + x;
13443 int sy = cursor_from_y + y;
13444 int lx = sx + level_xpos;
13445 int ly = sy + level_ypos;
13446 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
13447 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
13448 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
13449 brush_buffer[x][y] : new_element);
13451 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
13453 if (sx < border_from_x)
13454 border_from_x = sx;
13455 else if (sx > border_to_x)
13457 if (sy < border_from_y)
13458 border_from_y = sy;
13459 else if (sy > border_to_y)
13462 DrawBrushElement(sx, sy, element, change_level);
13467 if (mode != CB_DELETE_OLD_CURSOR)
13468 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
13470 last_cursor_x = cursor_x;
13471 last_cursor_y = cursor_y;
13473 delete_old_brush = TRUE;
13475 else if (mode == CB_FLIP_BRUSH_X)
13477 for (y = 0; y < brush_height; y++)
13478 for (x = 0; x < (brush_width + 1) / 2; x++)
13479 SwapFlippedTiles(&brush_buffer[x][y],
13480 &brush_buffer[brush_width - x - 1][y], mode);
13482 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13484 else if (mode == CB_FLIP_BRUSH_Y)
13486 for (y = 0; y < (brush_height + 1) / 2; y++)
13487 for (x = 0; x < brush_width; x++)
13488 SwapFlippedTiles(&brush_buffer[x][y],
13489 &brush_buffer[x][brush_height - y - 1], mode);
13491 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13493 else if (mode == CB_FLIP_BRUSH_XY)
13495 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13497 for (y = 0; y < MAX(brush_width, brush_height); y++)
13498 for (x = 0; x <= y; x++)
13499 SwapFlippedTiles(&brush_buffer[x][y],
13500 &brush_buffer[y][x], mode);
13502 swap_numbers(&brush_width, &brush_height);
13504 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13507 if (mode == CB_UPDATE_BRUSH_POSITION)
13509 last_cursor_x = from_x;
13510 last_cursor_y = from_y;
13514 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
13517 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
13520 static void CopyBrushToLevel(int x, int y, int button)
13522 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
13525 static void CopyBrushToCursor(int x, int y)
13527 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13530 static void UpdateBrushPosition(int x, int y)
13532 CopyBrushExt(x, y, 0, 0, 0, CB_UPDATE_BRUSH_POSITION);
13535 static void DeleteBrushFromCursor(void)
13537 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13540 static void FlipBrushX(void)
13542 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13545 static void FlipBrushY(void)
13547 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_Y);
13550 static void RotateBrush(void)
13552 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_XY);
13553 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13556 void DumpBrush(void)
13558 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
13561 void DumpBrush_Small(void)
13563 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
13566 void CopyClipboardToBrush(void)
13568 CopyBrushExt(0, 0, 0, 0, 0, CB_CLIPBOARD_TO_BRUSH);
13571 void CopyBrushToClipboard(void)
13573 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD);
13576 void CopyBrushToClipboard_Small(void)
13578 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD_SMALL);
13581 void UndoLevelEditorOperation(void)
13583 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], -1);
13586 void RedoLevelEditorOperation(void)
13588 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
13591 static void FloodFill(int from_x, int from_y, int fill_element)
13593 FloodFillLevel(from_x, from_y, fill_element, Tile, lev_fieldx, lev_fieldy);
13596 static void FloodFillWall_MM(int from_sx2, int from_sy2, int fill_element)
13598 int from_x = from_sx2 + 2 * level_xpos;
13599 int from_y = from_sy2 + 2 * level_ypos;
13600 int max_fillx = lev_fieldx * 2;
13601 int max_filly = lev_fieldy * 2;
13602 short Fill[max_fillx][max_filly];
13605 for (x = 0; x < max_fillx; x++)
13606 for (y = 0; y < max_filly; y++)
13607 Fill[x][y] = getLevelElementHiRes(x, y);
13609 FloodFillLevelExt(from_x, from_y, fill_element, max_fillx, max_filly,
13610 Fill, max_fillx, max_filly);
13612 for (x = 0; x < max_fillx; x++)
13613 for (y = 0; y < max_filly; y++)
13614 if (Fill[x][y] == fill_element)
13615 SetLevelElementHiRes(x, y, Fill[x][y]);
13618 // values for DrawLevelText() modes
13619 #define TEXT_INIT 0
13620 #define TEXT_SETCURSOR 1
13621 #define TEXT_WRITECHAR 2
13622 #define TEXT_BACKSPACE 3
13623 #define TEXT_NEWLINE 4
13625 #define TEXT_QUERY_TYPING 6
13627 static int DrawLevelText(int sx, int sy, char letter, int mode)
13629 static short delete_buffer[MAX_LEV_FIELDX];
13630 static int start_sx;
13631 static int last_sx, last_sy;
13632 static boolean typing = FALSE;
13633 int letter_element;
13634 int lx = 0, ly = 0;
13636 // map lower case letters to upper case and convert special characters
13637 if (letter >= 'a' && letter <= 'z')
13638 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
13639 else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
13640 letter_element = EL_CHAR_AUMLAUT;
13641 else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
13642 letter_element = EL_CHAR_OUMLAUT;
13643 else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
13644 letter_element = EL_CHAR_UUMLAUT;
13645 else if (letter == '^')
13646 letter_element = EL_CHAR_COPYRIGHT;
13648 letter_element = EL_CHAR_ASCII0 + letter;
13650 if (mode != TEXT_INIT)
13655 if (mode != TEXT_SETCURSOR)
13661 lx = last_sx + level_xpos;
13662 ly = last_sy + level_ypos;
13669 DrawLevelText(0, 0, 0, TEXT_END);
13675 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
13678 case TEXT_SETCURSOR:
13679 DrawEditorElement(last_sx, last_sy, Tile[lx][ly]);
13680 DrawAreaBorder(sx, sy, sx, sy);
13681 StartTextInput(SX + sx * ed_tilesize, SY + sy * ed_tilesize,
13682 ed_tilesize, ed_tilesize);
13687 case TEXT_WRITECHAR:
13688 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
13690 if (new_element1 >= EL_STEEL_CHAR_START &&
13691 new_element1 <= EL_STEEL_CHAR_END)
13692 letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
13694 delete_buffer[sx - start_sx] = Tile[lx][ly];
13695 Tile[lx][ly] = letter_element;
13697 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
13698 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
13699 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13700 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13702 DrawLevelText(0, 0, 0, TEXT_END);
13704 level.changed = TRUE;
13708 case TEXT_BACKSPACE:
13711 Tile[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
13712 DrawEditorElement(sx - 1, sy, Tile[lx - 1][ly]);
13713 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
13718 if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13719 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13721 DrawLevelText(0, 0, 0, TEXT_END);
13725 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13726 DrawEditorElement(sx, sy, Tile[lx][ly]);
13731 case TEXT_QUERY_TYPING:
13741 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
13742 int element, boolean change_level)
13744 int lx = sx + level_xpos;
13745 int ly = sy + level_ypos;
13748 DrawEditorElement(sx, sy, Tile[lx][ly]);
13750 DrawAreaBorder(sx, sy, sx, sy);
13753 static void CheckLevelBorderElement(boolean redraw_playfield)
13755 int last_border_element = BorderElement;
13757 SetBorderElement();
13759 if (redraw_playfield && BorderElement != last_border_element)
13760 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13763 static void CopyLevelToUndoBuffer(int mode)
13765 static boolean accumulated_undo = FALSE;
13766 boolean new_undo_buffer_position = TRUE;
13769 if (undo_buffer_steps == 0)
13770 accumulated_undo = FALSE;
13774 case UNDO_IMMEDIATE:
13775 accumulated_undo = FALSE;
13778 case UNDO_ACCUMULATE:
13779 if (accumulated_undo)
13780 new_undo_buffer_position = FALSE;
13781 accumulated_undo = TRUE;
13788 if (new_undo_buffer_position)
13790 // advance position in undo buffer ring
13791 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
13793 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
13794 undo_buffer_steps++;
13797 // always reset redo buffer when storing level change into undo buffer
13798 redo_buffer_steps = 0;
13800 for (x = 0; x < lev_fieldx; x++)
13801 for (y = 0; y < lev_fieldy; y++)
13802 UndoBuffer[undo_buffer_position][x][y] = Tile[x][y];
13804 // check if drawing operation forces change of border style
13805 CheckLevelBorderElement(TRUE);
13807 level.changed = TRUE;
13810 static void RandomPlacement(int new_element)
13812 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
13813 int num_free_positions = 0;
13814 int num_percentage, num_elements;
13817 ResetIntelliDraw();
13819 // determine number of free positions for randomly placing the new element
13820 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
13822 free_position[x][y] =
13823 (random_placement_background_restricted ?
13824 Tile[x][y] == random_placement_background_element :
13825 Tile[x][y] != new_element);
13827 if (free_position[x][y])
13828 num_free_positions++;
13831 // determine number of new elements to place there
13832 num_percentage = num_free_positions * random_placement_value / 100;
13833 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
13834 num_percentage : random_placement_value);
13836 // if less free positions than elements to place, fill all these positions
13837 if (num_free_positions < num_elements)
13839 for (x = 0; x < lev_fieldx; x++)
13840 for (y = 0; y < lev_fieldy; y++)
13841 if (free_position[x][y])
13842 SetElement(x, y, new_element);
13846 while (num_elements > 0)
13848 x = GetSimpleRandom(lev_fieldx);
13849 y = GetSimpleRandom(lev_fieldy);
13851 // don't place element at the same position twice
13852 if (free_position[x][y])
13854 free_position[x][y] = FALSE;
13855 SetElement(x, y, new_element);
13861 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13862 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13865 static void WrapLevel(int dx, int dy)
13867 int wrap_dx = lev_fieldx - dx;
13868 int wrap_dy = lev_fieldy - dy;
13871 for (x = 0; x < lev_fieldx; x++)
13872 for (y = 0; y < lev_fieldy; y++)
13873 TileBackup[x][y] = Tile[x][y];
13875 for (x = 0; x < lev_fieldx; x++)
13876 for (y = 0; y < lev_fieldy; y++)
13878 TileBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
13880 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13881 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
13884 static void DrawAreaElementHighlight(boolean highlighted,
13885 boolean highlighted_similar)
13887 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13894 for (x = 0; x < ed_fieldx; x++)
13896 for (y = 0; y < ed_fieldy; y++)
13898 boolean highlight = FALSE;
13899 int lx = x + level_xpos;
13900 int ly = y + level_ypos;
13902 if (!IN_LEV_FIELD(lx, ly))
13905 // check if element is the same
13906 if (Tile[lx][ly] == new_element1)
13909 // check if element is similar
13910 if (highlighted_similar &&
13911 strEqual(element_info[Tile[lx][ly]].class_name,
13912 element_info[new_element1].class_name))
13915 // check if element is matching MM style wall
13916 if (IS_MM_WALL(Tile[lx][ly]) &&
13917 map_mm_wall_element(Tile[lx][ly]) == new_element1)
13923 if (IS_MM_WALL(Tile[lx][ly]) && !highlighted_similar)
13927 for (i = 0; i < 4; i++)
13929 if (!(MM_WALL_BITS(Tile[lx][ly]) & (1 << i)))
13932 int xx = x * 2 + (i % 2);
13933 int yy = y * 2 + (i / 2);
13934 int sx = SX + xx * ed_tilesize / 2;
13935 int sy = SY + yy * ed_tilesize / 2;
13938 int to_sx = sx + ed_tilesize / 2 - 1;
13939 int to_sy = sy + ed_tilesize / 2 - 1;
13941 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
13942 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
13943 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
13944 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
13949 int sx = SX + x * ed_tilesize;
13950 int sy = SY + y * ed_tilesize;
13953 int to_sx = sx + ed_tilesize - 1;
13954 int to_sy = sy + ed_tilesize - 1;
13956 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
13957 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
13958 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
13959 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
13965 static void CopyLevelTemplateToUserLevelSet(char *levelset_subdir)
13967 char *template_filename_old = getLocalLevelTemplateFilename();
13968 char *template_filename_new =
13969 getPath2(getUserLevelDir(levelset_subdir), LEVELTEMPLATE_FILENAME);
13971 if (copyFile(template_filename_old, template_filename_new) != 0)
13972 Request("Cannot copy level template!", REQ_CONFIRM);
13974 free(template_filename_new);
13977 static void HandleDrawingAreas(struct GadgetInfo *gi)
13979 static boolean started_inside_drawing_area = FALSE;
13980 static int last_sx = -1;
13981 static int last_sy = -1;
13982 static int last_sx2 = -1;
13983 static int last_sy2 = -1;
13984 int id = gi->custom_id;
13985 int type_id = gi->custom_type_id;
13986 boolean button_press_event;
13987 boolean button_release_event;
13988 boolean inside_drawing_area = !gi->event.off_borders;
13989 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
13990 int actual_drawing_function;
13991 int button = gi->event.button;
13992 int new_element = BUTTON_ELEMENT(button);
13993 int sx = gi->event.x, sy = gi->event.y;
13994 int min_sx = 0, min_sy = 0;
13995 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
13996 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
13997 int mini_item_xsize = item_xsize / 2, mini_item_ysize = item_ysize / 2;
13998 int sx2 = gi->event.mx / mini_item_xsize;
13999 int sy2 = gi->event.my / mini_item_ysize;
14002 int lx = 0, ly = 0;
14005 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
14006 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
14008 // make sure to stay inside drawing area boundaries
14009 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
14010 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
14014 int min_lx = 0, min_ly = 0;
14015 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
14017 // get positions inside level field
14018 lx = sx + level_xpos;
14019 ly = sy + level_ypos;
14021 if (!IN_LEV_FIELD(lx, ly))
14022 inside_drawing_area = FALSE;
14024 // make sure to stay inside level field boundaries
14025 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
14026 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
14028 // correct drawing area positions accordingly
14029 sx = lx - level_xpos;
14030 sy = ly - level_ypos;
14033 // also correct MM wall-sized (double) drawing area positions accordingly
14034 if (sx2 / 2 < sx || sx2 / 2 > sx)
14036 dx = (sx2 / 2 < sx ? 0 : 1);
14039 if (sy2 / 2 < sy || sy2 / 2 > sy)
14041 dy = (sy2 / 2 < sy ? 0 : 1);
14045 if (!button_press_event && !button_release_event)
14047 int old_element = (IN_LEV_FIELD(lx, ly) ? Tile[lx][ly] : EL_UNDEFINED);
14048 boolean hires_drawing = (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
14049 isHiresTileElement(old_element) &&
14050 isHiresDrawElement(new_element));
14052 // prevent handling events for every pixel position when moving mouse
14053 if ((sx == last_sx && sy == last_sy && !hires_drawing) ||
14054 (sx2 == last_sx2 && sy2 == last_sy2))
14063 if (button_press_event)
14064 started_inside_drawing_area = inside_drawing_area;
14066 if (!started_inside_drawing_area)
14069 if (!IS_VALID_BUTTON(button))
14072 // handle info callback for each invocation of action callback
14073 gi->callback_info(gi);
14075 // automatically switch to 'single item' drawing mode, if needed
14076 actual_drawing_function =
14077 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
14078 drawing_function : GADGET_ID_SINGLE_ITEMS);
14080 // clicking into drawing area with pressed Control key picks element
14081 if (GetKeyModState() & KMOD_Control)
14083 last_drawing_function = drawing_function;
14084 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
14087 if (GetKeyModState() & KMOD_Shift)
14089 if (button_press_event || button_release_event)
14090 ResetIntelliDraw();
14093 SetDrawModeHiRes(-1); // reset to normal draw mode
14095 switch (actual_drawing_function)
14097 case GADGET_ID_SINGLE_ITEMS:
14100 if (button_release_event)
14102 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14104 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
14105 !inside_drawing_area)
14106 DeleteBrushFromCursor();
14111 if (draw_with_brush)
14113 CopyBrushToLevel(sx, sy, button);
14117 SetDrawModeHiRes(new_element);
14119 if (IS_PLAYER_ELEMENT(new_element) || IS_MM_MCDUFFIN(new_element))
14121 // remove player at old position
14122 for (y = 0; y < lev_fieldy; y++)
14124 for (x = 0; x < lev_fieldx; x++)
14126 int old_element = Tile[x][y];
14128 if (IS_PLAYER_ELEMENT(old_element) &&
14129 IS_PLAYER_ELEMENT(new_element))
14131 int replaced_with_element =
14132 (old_element == EL_SOKOBAN_FIELD_PLAYER &&
14133 new_element == EL_PLAYER_1 ? EL_SOKOBAN_FIELD_EMPTY :
14135 old_element == EL_SOKOBAN_FIELD_PLAYER &&
14136 new_element == old_element ? EL_SOKOBAN_FIELD_EMPTY :
14138 new_element == EL_SOKOBAN_FIELD_PLAYER &&
14139 old_element == EL_PLAYER_1 ? EL_EMPTY :
14141 new_element >= EL_PLAYER_1 &&
14142 new_element <= EL_PLAYER_4 &&
14143 new_element == old_element ? EL_EMPTY :
14147 SetElement(x, y, replaced_with_element);
14149 else if (IS_MM_MCDUFFIN(old_element) &&
14150 IS_MM_MCDUFFIN(new_element))
14152 // remove McDuffin at old position
14153 SetElement(x, y, EL_EMPTY);
14159 SetElementButton(lx, ly, dx, dy, new_element, button);
14162 else if (!button_release_event)
14164 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14166 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
14167 DrawMiniGraphicExt(drawto,
14168 gi->x + sx * MINI_TILEX,
14169 gi->y + sy * MINI_TILEY,
14170 el2edimg(new_element));
14172 DrawFixedGraphicExt(drawto,
14173 gi->x + sx * TILEX,
14174 gi->y + sy * TILEY,
14175 el2edimg(new_element), 0);
14177 if (id == GADGET_ID_CUSTOM_GRAPHIC)
14178 new_element = GFX_ELEMENT(new_element);
14180 drawingarea_info[type_id].value[pos] = new_element;
14182 CopyElementPropertiesToGame(properties_element);
14184 if (id == GADGET_ID_CUSTOM_GRAPHIC)
14186 UpdateCustomElementGraphicGadgets();
14188 FrameCounter = 0; // restart animation frame counter
14193 case GADGET_ID_CONNECTED_ITEMS:
14195 static int last_sx = -1;
14196 static int last_sy = -1;
14198 if (button_release_event)
14199 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14201 SetDrawModeHiRes(new_element);
14203 if (getDrawModeHiRes())
14209 if (!button_press_event)
14210 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
14217 case GADGET_ID_LINE:
14218 case GADGET_ID_ARC:
14219 case GADGET_ID_RECTANGLE:
14220 case GADGET_ID_FILLED_BOX:
14221 SetDrawModeHiRes(new_element);
14223 if (getDrawModeHiRes())
14229 case GADGET_ID_GRAB_BRUSH:
14230 case GADGET_ID_TEXT:
14232 static int last_sx = -1;
14233 static int last_sy = -1;
14234 static int start_sx = -1;
14235 static int start_sy = -1;
14236 void (*draw_func)(int, int, int, int, int, boolean);
14238 if (drawing_function == GADGET_ID_LINE)
14239 draw_func = DrawLine;
14240 else if (drawing_function == GADGET_ID_ARC)
14241 draw_func = DrawArc;
14242 else if (drawing_function == GADGET_ID_RECTANGLE)
14243 draw_func = DrawBox;
14244 else if (drawing_function == GADGET_ID_FILLED_BOX)
14245 draw_func = DrawFilledBox;
14246 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
14247 draw_func = SelectArea;
14248 else // (drawing_function == GADGET_ID_TEXT)
14249 draw_func = SetTextCursor;
14251 if (button_press_event)
14253 draw_func(sx, sy, sx, sy, new_element, FALSE);
14254 start_sx = last_sx = sx;
14255 start_sy = last_sy = sy;
14257 if (drawing_function == GADGET_ID_TEXT)
14258 DrawLevelText(0, 0, 0, TEXT_END);
14260 else if (button_release_event)
14262 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
14263 if (drawing_function == GADGET_ID_GRAB_BRUSH)
14265 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
14266 CopyBrushToCursor(sx, sy);
14267 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
14269 draw_with_brush = TRUE;
14271 else if (drawing_function == GADGET_ID_TEXT)
14272 DrawLevelText(sx, sy, 0, TEXT_INIT);
14274 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14276 else if (last_sx != sx || last_sy != sy)
14278 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
14279 if (IS_MM_WALL_EDITOR(new_element)) // clear wall background
14280 draw_func(start_sx, start_sy, sx, sy, EL_EMPTY, FALSE);
14281 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
14288 case GADGET_ID_FLOOD_FILL:
14289 if (button_press_event && Tile[lx][ly] != new_element)
14291 if (IS_MM_WALL_EDITOR(new_element))
14292 FloodFillWall_MM(sx2, sy2, new_element);
14294 FloodFill(lx, ly, new_element);
14296 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14297 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14301 case GADGET_ID_PICK_ELEMENT:
14302 if (button_release_event)
14303 ClickOnGadget(level_editor_gadget[last_drawing_function],
14305 else if (draw_level)
14306 PickDrawingElement(button, Tile[lx][ly]);
14309 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14311 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
14318 // do not mark level as modified for certain non-level-changing gadgets
14319 if ((type_id >= ED_DRAWING_ID_EDITOR_FIRST &&
14320 type_id <= ED_DRAWING_ID_EDITOR_LAST) ||
14321 actual_drawing_function == GADGET_ID_GRAB_BRUSH ||
14322 actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14325 level.changed = TRUE;
14328 static void HandleCounterButtons(struct GadgetInfo *gi)
14330 int gadget_id = gi->custom_id;
14331 int counter_id = gi->custom_type_id;
14332 int button = gi->event.button;
14333 int *counter_value = counterbutton_info[counter_id].value;
14334 int step = BUTTON_STEPSIZE(button) *
14335 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
14337 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
14339 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
14340 boolean released = (gi->event.type == GD_EVENT_RELEASED);
14341 boolean level_changed = LevelChanged();
14343 if ((level_changed && pressed) || (!level_changed && released))
14346 if (level_changed && !Request("Level has changed! Discard changes?",
14349 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
14350 ModifyEditorCounterValue(counter_id, *counter_value);
14356 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
14357 *counter_value = gi->textinput.number_value;
14359 ModifyEditorCounterValue(counter_id, *counter_value + step);
14361 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
14363 int last_game_engine_type = level.game_engine_type;
14365 LoadLevel(level_nr);
14366 LoadScore(level_nr);
14368 SaveLevelSetup_SeriesInfo();
14373 DrawEditModeWindow();
14375 if (level.game_engine_type != last_game_engine_type)
14377 // update element selection list
14378 ReinitializeElementList();
14379 ModifyEditorElementList();
14385 switch (counter_id)
14387 case ED_COUNTER_ID_YAMYAM_CONTENT:
14388 DrawYamYamContentAreas();
14391 case ED_COUNTER_ID_BALL_CONTENT:
14392 DrawMagicBallContentAreas();
14395 case ED_COUNTER_ID_ANDROID_CONTENT:
14396 DrawAndroidElementArea();
14399 case ED_COUNTER_ID_GROUP_CONTENT:
14400 DrawGroupElementArea();
14401 CopyGroupElementPropertiesToGame(properties_element);
14404 case ED_COUNTER_ID_INVENTORY_SIZE:
14405 DrawPlayerInitialInventoryArea(properties_element);
14408 case ED_COUNTER_ID_MM_BALL_CONTENT:
14409 DrawMMBallContentArea();
14412 case ED_COUNTER_ID_ENVELOPE_XSIZE:
14413 case ED_COUNTER_ID_ENVELOPE_YSIZE:
14414 DrawEnvelopeTextArea(-1);
14417 case ED_COUNTER_ID_LEVEL_XSIZE:
14418 case ED_COUNTER_ID_LEVEL_YSIZE:
14419 lev_fieldx = level.fieldx;
14420 lev_fieldy = level.fieldy;
14422 // check if resizing of level results in change of border border
14423 SetBorderElement();
14431 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
14432 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
14433 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
14434 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
14435 CopyElementPropertiesToGame(properties_element);
14437 // do not mark level as modified for certain non-level-changing gadgets
14438 if ((counter_id >= ED_COUNTER_ID_LEVELSET_FIRST &&
14439 counter_id <= ED_COUNTER_ID_LEVELSET_LAST) ||
14440 (counter_id >= ED_COUNTER_ID_EDITOR_FIRST &&
14441 counter_id <= ED_COUNTER_ID_EDITOR_LAST))
14444 level.changed = TRUE;
14447 static void HandleTextInputGadgets(struct GadgetInfo *gi)
14449 int type_id = gi->custom_type_id;
14451 strcpy(textinput_info[type_id].value, gi->textinput.value);
14453 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
14455 CopyElementPropertiesToGame(properties_element);
14457 ModifyEditorElementList(); // update changed button info text
14460 // do not mark level as modified for certain non-level-changing gadgets
14461 if (type_id >= ED_TEXTINPUT_ID_LEVELSET_FIRST &&
14462 type_id <= ED_TEXTINPUT_ID_LEVELSET_LAST)
14465 level.changed = TRUE;
14468 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
14470 int type_id = gi->custom_type_id;
14472 strncpy(textarea_info[type_id].value, gi->textarea.value,
14473 MAX_ENVELOPE_TEXT_LEN);
14474 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
14476 level.changed = TRUE;
14479 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
14481 int type_id = gi->custom_type_id;
14482 int value_old = *selectbox_info[type_id].value;
14483 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
14485 *selectbox_info[type_id].value = value_new;
14487 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE)
14489 DrawLevelConfigWindow();
14491 else if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14493 element_info[properties_element].current_change_page = gi->selectbox.index;
14495 DrawPropertiesWindow();
14497 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
14498 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
14499 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
14500 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
14501 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
14503 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
14505 // when changing action type, also check action mode and action arg
14506 if (value_old != value_new)
14507 setSelectboxSpecialActionVariablesIfNeeded();
14509 DrawPropertiesChange();
14512 CopyElementPropertiesToGame(properties_element);
14514 else if (type_id == ED_SELECTBOX_ID_GAME_ENGINE_TYPE)
14516 // show or hide "engine" tabulator depending on game engine type
14517 DrawLevelConfigWindow();
14519 // update element selection list depending on game engine type
14520 ReinitializeElementList();
14521 ModifyEditorElementList();
14524 // do not mark level as modified for certain non-level-changing gadgets
14525 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE ||
14526 type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14529 level.changed = TRUE;
14532 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
14534 int type_id = gi->custom_type_id;
14537 if (type_id >= ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST &&
14538 type_id <= ED_TAB_BUTTON_ID_LEVELCONFIG_LAST)
14540 edit_mode_levelconfig = gi->custom_type_id;
14542 DrawLevelConfigWindow();
14544 else if (type_id >= ED_TAB_BUTTON_ID_PROPERTIES_FIRST &&
14545 type_id <= ED_TAB_BUTTON_ID_PROPERTIES_LAST)
14547 edit_mode_properties = gi->custom_type_id;
14549 DrawPropertiesWindow();
14551 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 ||
14552 type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2)
14554 boolean new_template = !fileExists(getLocalLevelTemplateFilename());
14556 // backup original "level.field" (needed to track playfield changes)
14557 CopyPlayfield(level.field, TileBackup);
14559 // "SaveLevelTemplate()" uses "level.field", so copy editor playfield
14560 CopyPlayfield(Tile, level.field);
14562 if (new_template ||
14563 Request("Save this template and kill the old?", REQ_ASK))
14564 SaveLevelTemplate();
14567 Request("Template saved!", REQ_CONFIRM);
14569 // restore original "level.field" (needed to track playfield changes)
14570 CopyPlayfield(TileBackup, level.field);
14572 else if (type_id == ED_TEXTBUTTON_ID_SAVE_LEVELSET)
14574 char *levelset_subdir = getLevelSubdirFromSaveMode(levelset_save_mode);
14576 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE &&
14577 leveldir_current->readonly)
14579 Request("This level set is read-only!", REQ_CONFIRM);
14584 if (strEqual(levelset_name, ""))
14586 Request("Please enter level set title!", REQ_CONFIRM);
14591 if (strEqual(levelset_author, ""))
14593 Request("Please enter level set author!", REQ_CONFIRM);
14598 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE)
14600 if (UpdateUserLevelSet(levelset_subdir,
14603 levelset_num_levels))
14605 Request("Level set updated!", REQ_CONFIRM);
14609 Request("Updating level set failed!", REQ_CONFIRM);
14612 else if (levelset_save_mode == LEVELSET_SAVE_MODE_CREATE)
14614 if (level.changed && !Request("Level has changed! Discard changes?",
14618 if (CreateUserLevelSet(levelset_subdir,
14621 levelset_num_levels,
14622 levelset_use_levelset_artwork))
14624 if (levelset_copy_level_template)
14625 CopyLevelTemplateToUserLevelSet(levelset_subdir);
14627 Request("New level set created!", REQ_CONFIRM);
14629 AddUserLevelSetToLevelInfo(levelset_subdir);
14630 ChangeEditorToLevelSet(levelset_subdir);
14634 Request("Creating new level set failed!", REQ_CONFIRM);
14638 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
14639 custom_element.num_change_pages < MAX_CHANGE_PAGES)
14641 struct ElementInfo *ei = &element_info[properties_element];
14643 // when modifying custom element, ask for copying level template
14644 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14647 setElementChangePages(ei, ei->num_change_pages + 1);
14649 // set new change page to be new current change page
14650 ei->current_change_page = ei->num_change_pages - 1;
14651 ei->change = &ei->change_page[ei->current_change_page];
14653 setElementChangeInfoToDefaults(ei->change);
14655 DrawPropertiesWindow();
14657 level.changed = TRUE;
14659 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
14660 custom_element.num_change_pages > MIN_CHANGE_PAGES)
14662 struct ElementInfo *ei = &element_info[properties_element];
14664 // when modifying custom element, ask for copying level template
14665 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14668 // copy all change pages after change page to be deleted
14669 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
14670 ei->change_page[i] = ei->change_page[i + 1];
14672 setElementChangePages(ei, ei->num_change_pages - 1);
14674 DrawPropertiesWindow();
14676 level.changed = TRUE;
14680 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
14682 int type_id = gi->custom_type_id;
14684 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
14685 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
14687 struct ElementInfo *ei = &element_info[properties_element];
14688 int step = BUTTON_STEPSIZE(gi->event.button);
14690 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
14691 ei->current_change_page += step;
14693 if (ei->current_change_page < 0)
14694 ei->current_change_page = 0;
14695 else if (ei->current_change_page >= ei->num_change_pages)
14696 ei->current_change_page = ei->num_change_pages - 1;
14698 DrawPropertiesWindow();
14700 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
14701 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14703 struct ElementInfo *ei = &element_info[properties_element];
14704 int current_change_page = ei->current_change_page;
14706 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
14708 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
14709 ei->change_page[current_change_page];
14711 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14713 // when modifying custom element, ask for copying level template
14714 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14717 ei->change_page[current_change_page] =
14718 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
14720 level.changed = TRUE;
14723 DrawPropertiesWindow();
14727 static void HandleRadiobuttons(struct GadgetInfo *gi)
14729 int type_id = gi->custom_type_id;
14731 *radiobutton_info[type_id].value =
14732 radiobutton_info[type_id].checked_value;
14734 // do not mark level as modified for certain non-level-changing gadgets
14735 if (type_id >= ED_RADIOBUTTON_ID_EDITOR_FIRST &&
14736 type_id <= ED_RADIOBUTTON_ID_EDITOR_LAST)
14739 level.changed = TRUE;
14742 static void HandleCheckbuttons(struct GadgetInfo *gi)
14744 int type_id = gi->custom_type_id;
14746 *checkbutton_info[type_id].value ^= TRUE;
14748 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
14749 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
14750 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
14751 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
14752 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
14753 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
14754 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
14755 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1))
14757 CopyElementPropertiesToGame(properties_element);
14760 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
14762 UpdateCustomElementGraphicGadgets();
14764 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 ||
14765 type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2)
14767 boolean template_related_changes_found = FALSE;
14770 // check if any custom, group or empty elements have been changed
14771 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
14772 if ((IS_CUSTOM_ELEMENT(i) ||
14773 IS_GROUP_ELEMENT(i) ||
14774 IS_EMPTY_ELEMENT(i)) &&
14775 element_info[i].modified_settings)
14776 template_related_changes_found = TRUE;
14778 if (level.use_custom_template &&
14779 !fileExists(getGlobalLevelTemplateFilename()))
14781 Request("No level template found!", REQ_CONFIRM);
14783 level.use_custom_template = FALSE;
14785 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
14790 if (level.use_custom_template &&
14791 template_related_changes_found &&
14792 !Request("Discard changes and use level template?", REQ_ASK))
14794 level.use_custom_template = FALSE;
14796 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
14801 if (!level.use_custom_template &&
14802 Request("Copy settings from level template?", REQ_ASK))
14807 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
14809 DrawEditModeWindow();
14811 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3)
14813 if (setup.editor.use_template_for_new_levels &&
14814 !fileExists(getGlobalLevelTemplateFilename()))
14816 Request("No level template found!", REQ_CONFIRM);
14821 if (setup.editor.use_template_for_new_levels &&
14823 !Request("Discard level and load template?", REQ_ASK))
14828 if (!setup.editor.use_template_for_new_levels &&
14830 !Request("Discard level and use empty level?", REQ_ASK))
14835 LoadLevel(level_nr);
14836 LoadScore(level_nr);
14841 DrawEditModeWindow();
14843 else if (type_id == ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS)
14845 SetAutomaticNumberOfGemsNeeded();
14848 // do not mark level as modified for certain non-level-changing gadgets
14849 if ((type_id >= ED_CHECKBUTTON_ID_LEVELSET_FIRST &&
14850 type_id <= ED_CHECKBUTTON_ID_LEVELSET_LAST) ||
14851 (type_id >= ED_CHECKBUTTON_ID_EDITOR_FIRST &&
14852 type_id <= ED_CHECKBUTTON_ID_EDITOR_LAST &&
14853 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2) ||
14854 type_id == ED_CHECKBUTTON_ID_STICK_ELEMENT)
14857 level.changed = TRUE;
14860 static void HandleControlButtons(struct GadgetInfo *gi)
14862 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
14863 static int last_edit_mode = ED_MODE_DRAWING;
14864 static int last_custom_copy_mode = -1;
14865 static int last_button = 0;
14866 int id = gi->custom_id;
14867 int button = gi->event.button;
14868 int step = BUTTON_STEPSIZE(button);
14869 int new_element = BUTTON_ELEMENT(button);
14870 int last_properties_element = properties_element;
14873 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
14874 DrawLevelText(0, 0, 0, TEXT_END);
14876 if (id < ED_NUM_CTRL1_BUTTONS &&
14877 id != GADGET_ID_SINGLE_ITEMS &&
14878 id != GADGET_ID_PICK_ELEMENT &&
14879 edit_mode != ED_MODE_DRAWING &&
14880 drawing_function != GADGET_ID_PICK_ELEMENT &&
14881 !(GetKeyModState() & KMOD_Control))
14882 ChangeEditModeWindow(ED_MODE_DRAWING);
14884 // element copy mode active, but no element button pressed => deactivate
14885 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
14886 last_custom_copy_mode = -1;
14888 // when showing palette on element buttons, change element of button used
14889 if (editor.palette.show_on_element_buttons &&
14890 id >= GADGET_ID_ELEMENT_LEFT && id <= GADGET_ID_ELEMENT_RIGHT)
14892 last_button = id - GADGET_ID_ELEMENT_LEFT + 1;
14894 id = GADGET_ID_PALETTE;
14899 case GADGET_ID_SCROLL_LEFT:
14900 if (level_xpos >= 0)
14902 if (lev_fieldx < ed_fieldx - 2)
14905 level_xpos -= step;
14906 if (level_xpos < -1)
14909 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
14911 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14913 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
14914 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
14918 case GADGET_ID_SCROLL_RIGHT:
14919 if (level_xpos <= lev_fieldx - ed_fieldx)
14921 if (lev_fieldx < ed_fieldx - 2)
14924 level_xpos += step;
14925 if (level_xpos > lev_fieldx - ed_fieldx + 1)
14926 level_xpos = lev_fieldx - ed_fieldx + 1;
14928 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
14930 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14932 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
14933 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
14937 case GADGET_ID_SCROLL_UP:
14938 if (level_ypos >= 0)
14940 if (lev_fieldy < ed_fieldy - 2)
14943 level_ypos -= step;
14944 if (level_ypos < -1)
14947 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
14949 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14951 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
14952 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
14956 case GADGET_ID_SCROLL_DOWN:
14957 if (level_ypos <= lev_fieldy - ed_fieldy)
14959 if (lev_fieldy < ed_fieldy - 2)
14962 level_ypos += step;
14963 if (level_ypos > lev_fieldy - ed_fieldy + 1)
14964 level_ypos = lev_fieldy - ed_fieldy + 1;
14966 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
14968 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14970 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
14971 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
14975 case GADGET_ID_SCROLL_HORIZONTAL:
14976 level_xpos = gi->event.item_position - 1;
14978 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14983 case GADGET_ID_SCROLL_VERTICAL:
14984 level_ypos = gi->event.item_position - 1;
14986 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14991 case GADGET_ID_SCROLL_LIST_UP:
14992 case GADGET_ID_SCROLL_LIST_DOWN:
14993 case GADGET_ID_SCROLL_LIST_VERTICAL:
14994 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
14995 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
14998 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
14999 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
15001 if (element_shift < 0)
15003 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15004 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15006 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15007 GDI_SCROLLBAR_ITEM_POSITION,
15008 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15011 ModifyEditorElementList();
15015 case GADGET_ID_PROPERTIES:
15016 // always switch off element properties when they are already displayed
15017 last_properties_element = new_element;
15018 case GADGET_ID_ELEMENT_LEFT:
15019 case GADGET_ID_ELEMENT_MIDDLE:
15020 case GADGET_ID_ELEMENT_RIGHT:
15021 properties_element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
15022 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
15023 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 :
15026 if (edit_mode != ED_MODE_PROPERTIES)
15028 last_edit_mode = edit_mode;
15030 ChangeEditModeWindow(ED_MODE_PROPERTIES);
15032 last_level_drawing_function = drawing_function;
15033 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
15036 else if (properties_element != last_properties_element)
15038 DrawEditModeWindow();
15042 ChangeEditModeWindow(ED_MODE_DRAWING);
15044 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
15049 case GADGET_ID_PALETTE:
15050 if (edit_mode != ED_MODE_PALETTE)
15052 last_edit_mode = edit_mode;
15054 ChangeEditModeWindow(ED_MODE_PALETTE);
15058 ChangeEditModeWindow(last_edit_mode);
15062 case GADGET_ID_WRAP_LEFT:
15063 WrapLevel(-step, 0);
15066 case GADGET_ID_WRAP_RIGHT:
15067 WrapLevel(step, 0);
15070 case GADGET_ID_WRAP_UP:
15071 WrapLevel(0, -step);
15074 case GADGET_ID_WRAP_DOWN:
15075 WrapLevel(0, step);
15078 case GADGET_ID_SINGLE_ITEMS:
15079 case GADGET_ID_CONNECTED_ITEMS:
15080 case GADGET_ID_LINE:
15081 case GADGET_ID_ARC:
15082 case GADGET_ID_TEXT:
15083 case GADGET_ID_RECTANGLE:
15084 case GADGET_ID_FILLED_BOX:
15085 case GADGET_ID_FLOOD_FILL:
15086 case GADGET_ID_GRAB_BRUSH:
15087 case GADGET_ID_PICK_ELEMENT:
15088 if (drawing_function != GADGET_ID_PICK_ELEMENT)
15089 last_drawing_function = drawing_function;
15090 drawing_function = id;
15091 draw_with_brush = FALSE;
15094 case GADGET_ID_RANDOM_PLACEMENT:
15095 RandomPlacement(new_element);
15098 case GADGET_ID_ZOOM:
15099 // zoom level editor tile size in or out (or reset to default size)
15100 ed_tilesize = (button == 1 ? ed_tilesize * 2 :
15101 button == 2 ? ed_tilesize_default :
15102 button == 3 ? ed_tilesize / 2 : ed_tilesize);
15104 // when using touch device, cycle through all zoom tilesizes
15105 if (runtime.uses_touch_device && ed_tilesize > TILESIZE)
15106 ed_tilesize = MICRO_TILESIZE;
15108 // limit zoom level by upper and lower bound
15109 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
15111 InitZoomLevelSettings(ed_tilesize);
15113 if (edit_mode == ED_MODE_DRAWING)
15115 DrawDrawingWindow();
15117 // redraw zoom gadget info text
15118 PrintEditorGadgetInfoText(level_editor_gadget[id]);
15121 // save current editor zoom tilesize
15122 SaveSetup_AutoSetup();
15126 case GADGET_ID_CUSTOM_COPY_FROM:
15127 case GADGET_ID_CUSTOM_COPY_TO:
15128 case GADGET_ID_CUSTOM_EXCHANGE:
15129 last_custom_copy_mode = id;
15130 last_drawing_function = drawing_function;
15133 case GADGET_ID_CUSTOM_COPY:
15134 CopyCustomElement(properties_element, -1, id);
15137 case GADGET_ID_CUSTOM_PASTE:
15138 CopyCustomElement(-1, properties_element, id);
15141 case GADGET_ID_UNDO:
15142 if (button < 0) // keep button value (even if modifier keys are pressed)
15144 else if (button == 1 && GetKeyModState() & (KMOD_Shift | KMOD_Control))
15147 if (button == 1 && undo_buffer_steps == 0)
15149 Request("Undo buffer empty!", REQ_CONFIRM);
15153 else if (button == 2)
15157 else if (button == 3 && redo_buffer_steps == 0)
15159 Request("Redo buffer empty!", REQ_CONFIRM);
15164 if (edit_mode != ED_MODE_DRAWING)
15165 ChangeEditModeWindow(ED_MODE_DRAWING);
15171 undo_buffer_position =
15172 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
15174 undo_buffer_steps--;
15175 redo_buffer_steps++;
15181 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
15183 undo_buffer_steps++;
15184 redo_buffer_steps--;
15187 for (x = 0; x < lev_fieldx; x++)
15188 for (y = 0; y < lev_fieldy; y++)
15189 Tile[x][y] = UndoBuffer[undo_buffer_position][x][y];
15191 // check if undo operation forces change of border style
15192 CheckLevelBorderElement(FALSE);
15194 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15198 case GADGET_ID_CONF:
15199 if (edit_mode != ED_MODE_LEVELCONFIG)
15201 last_edit_mode = edit_mode;
15203 ChangeEditModeWindow(ED_MODE_LEVELCONFIG);
15207 ChangeEditModeWindow(ED_MODE_DRAWING);
15211 case GADGET_ID_CLEAR:
15212 if (edit_mode != ED_MODE_DRAWING)
15213 ChangeEditModeWindow(ED_MODE_DRAWING);
15215 for (x = 0; x < MAX_LEV_FIELDX; x++)
15216 for (y = 0; y < MAX_LEV_FIELDY; y++)
15217 Tile[x][y] = (button == 1 ? EL_EMPTY : new_element);
15219 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
15221 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15224 case GADGET_ID_SAVE:
15226 // saving read-only levels into personal level set modifies global vars
15227 // "leveldir_current" and "level_nr"; restore them after saving level
15228 LevelDirTree *leveldir_former = leveldir_current;
15229 int level_nr_former = level_nr;
15230 char *level_filename;
15233 if (leveldir_current->readonly &&
15234 !PrepareSavingIntoPersonalLevelSet())
15237 level_filename = getDefaultLevelFilename(level_nr);
15238 new_level = !fileExists(level_filename);
15241 Request("Save this level and kill the old?", REQ_ASK))
15243 if (leveldir_former->readonly)
15244 ModifyLevelConfigForSavingIntoPersonalLevelSet(leveldir_former->name);
15246 SetAutomaticNumberOfGemsNeeded();
15248 CopyPlayfield(Tile, level.field);
15249 SaveLevel(level_nr);
15251 level.changed = FALSE;
15255 char level_saved_msg[64];
15257 if (leveldir_former->readonly)
15258 sprintf(level_saved_msg,
15259 "Level saved as level %d into personal level set!",
15262 strcpy(level_saved_msg, "Level saved!");
15264 Request(level_saved_msg, REQ_CONFIRM);
15268 // "cd" back to copied-from levelset (in case of saved read-only level)
15269 leveldir_current = leveldir_former;
15270 level_nr = level_nr_former;
15275 case GADGET_ID_TEST:
15276 if (LevelChanged())
15277 level.game_version = GAME_VERSION_ACTUAL;
15279 CopyPlayfield(level.field, TileBackup);
15280 CopyPlayfield(Tile, level.field);
15282 CopyNativeLevel_RND_to_Native(&level);
15284 UnmapLevelEditorGadgets();
15285 UndrawSpecialEditorDoor();
15287 CloseDoor(DOOR_CLOSE_ALL);
15289 // needed before playing if editor playfield area has different size
15290 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
15292 // redraw_mask = REDRAW_ALL;
15294 level_editor_test_game = TRUE;
15296 StartGameActions(FALSE, setup.autorecord, level.random_seed);
15300 case GADGET_ID_EXIT:
15301 RequestExitLevelEditor(TRUE, FALSE); // if level has changed, ask user
15305 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
15306 id <= GADGET_ID_ELEMENTLIST_LAST)
15308 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
15310 new_element = editor_elements[element_position + element_shift];
15312 if (IS_EDITOR_CASCADE(new_element))
15316 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
15318 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
15319 boolean *cascade_value = editor_elements_info[i].setup_cascade_value;
15321 if (*cascade_element == new_element)
15323 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
15324 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
15326 // update element selection list
15327 ReinitializeElementList();
15328 ModifyEditorElementList();
15330 // update cascading gadget info text
15331 PrintEditorGadgetInfoText(level_editor_gadget[id]);
15333 // save current editor cascading state
15334 SaveSetup_EditorCascade();
15343 if (last_custom_copy_mode != -1)
15345 if (CopyCustomElement(properties_element, new_element,
15346 last_custom_copy_mode))
15348 ClickOnGadget(level_editor_gadget[last_drawing_function],
15351 last_custom_copy_mode = -1;
15357 // change element of button used to show palette
15358 if (editor.palette.show_on_element_buttons)
15359 button = last_button;
15361 PickDrawingElement(button, new_element);
15363 if (!stick_element_properties_window &&
15364 drawing_function != GADGET_ID_PICK_ELEMENT &&
15365 !(GetKeyModState() & KMOD_Control))
15367 properties_element = new_element;
15368 if (edit_mode == ED_MODE_PROPERTIES)
15369 DrawPropertiesWindow();
15372 if (drawing_function == GADGET_ID_PICK_ELEMENT)
15373 ClickOnGadget(level_editor_gadget[last_drawing_function],
15376 if (!use_permanent_palette)
15377 ChangeEditModeWindow(last_edit_mode);
15380 else if (gi->event.type == GD_EVENT_PRESSED)
15381 Debug("editor", "default: HandleControlButtons: GD_EVENT_PRESSED(%d)", id);
15382 else if (gi->event.type == GD_EVENT_RELEASED)
15383 Debug("editor", "default: HandleControlButtons: GD_EVENT_RELEASED(%d)", id);
15384 else if (gi->event.type == GD_EVENT_MOVING)
15385 Debug("editor", "default: HandleControlButtons: GD_EVENT_MOVING(%d)", id);
15387 Debug("editor", "default: HandleControlButtons: ? (id == %d)", id);
15393 void HandleLevelEditorKeyInput(Key key)
15395 char letter = getCharFromKey(key);
15397 if (drawing_function == GADGET_ID_TEXT &&
15398 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
15401 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
15402 else if (key == KSYM_Delete || key == KSYM_BackSpace)
15403 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
15404 else if (key == KSYM_Return)
15405 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
15406 else if (key == KSYM_Escape)
15407 DrawLevelText(0, 0, 0, TEXT_END);
15412 int id = GADGET_ID_NONE;
15413 int new_element_shift = element_shift;
15414 int step = ED_ELEMENTLIST_BUTTONS_VERT - 1;
15415 int button = MB_LEFTBUTTON;
15421 id = GADGET_ID_SCROLL_LEFT;
15424 id = GADGET_ID_SCROLL_RIGHT;
15427 id = GADGET_ID_SCROLL_UP;
15430 id = GADGET_ID_SCROLL_DOWN;
15434 case KSYM_Page_Down:
15435 step *= (key == KSYM_Page_Up ? -1 : +1);
15436 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
15438 if (element_shift < 0)
15440 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15441 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15443 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15444 GDI_SCROLLBAR_ITEM_POSITION,
15445 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15447 ModifyEditorElementList();
15453 element_shift = (key == KSYM_Home ? 0 :
15454 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
15456 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15457 GDI_SCROLLBAR_ITEM_POSITION,
15458 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15460 ModifyEditorElementList();
15467 // this is needed to prevent interference with running "True X-Mouse"
15468 if (GetKeyModStateFromEvents() & KMOD_Control)
15471 // check for last or next editor cascade block in element list
15472 for (i = 0; i < num_editor_elements; i++)
15474 if ((key == KSYM_Insert && i == element_shift) ||
15475 (key == KSYM_Delete && new_element_shift > element_shift))
15478 // jump to next cascade block (or to start of element list)
15479 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
15480 new_element_shift = i;
15483 if (i < num_editor_elements)
15484 element_shift = new_element_shift;
15486 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15487 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15489 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15490 GDI_SCROLLBAR_ITEM_POSITION,
15491 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15493 ModifyEditorElementList();
15498 if (edit_mode == ED_MODE_DRAWING)
15499 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
15500 else if (edit_mode == ED_MODE_LEVELCONFIG)
15501 HandleControlButtons(level_editor_gadget[GADGET_ID_CONF]);
15502 else if (edit_mode == ED_MODE_PROPERTIES)
15503 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
15504 else if (edit_mode == ED_MODE_PALETTE)
15505 HandleControlButtons(level_editor_gadget[GADGET_ID_PALETTE]);
15506 else // should never happen
15507 ChangeEditModeWindow(ED_MODE_DRAWING);
15515 if (id != GADGET_ID_NONE)
15516 ClickOnGadget(level_editor_gadget[id], button);
15517 else if (letter == '1' || letter == '?')
15518 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_LEFT], button);
15519 else if (letter == '2')
15520 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_MIDDLE], button);
15521 else if (letter == '3')
15522 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_RIGHT], button);
15523 else if (letter == '.')
15524 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
15525 else if (letter == 'U')
15526 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
15527 else if (letter == '-' || key == KSYM_KP_Subtract)
15528 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
15529 else if (letter == '0' || key == KSYM_KP_0)
15530 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
15531 else if (letter == '+' || key == KSYM_KP_Add ||
15532 letter == '=') // ("Shift-=" is "+" on US keyboards)
15533 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
15534 else if (key == KSYM_Return ||
15535 key == KSYM_space ||
15536 key == setup.shortcut.toggle_pause)
15537 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
15539 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
15540 if (letter && letter == controlbutton_info[i].shortcut)
15541 if (!anyTextGadgetActive())
15542 ClickOnGadget(level_editor_gadget[i], button);
15544 if (draw_with_brush)
15548 else if (letter == 'y')
15550 else if (letter == 'z')
15555 static void HandleLevelEditorIdle_Properties(void)
15557 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
15558 int x = editor.settings.element_graphic.x + element_border;
15559 int y = editor.settings.element_graphic.y + element_border;
15560 static DelayCounter action_delay = { 0 };
15563 action_delay.value = GameFrameDelay;
15565 if (!DelayReached(&action_delay))
15568 for (i = 0; i < ED_NUM_SELECTBOX; i++)
15570 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
15572 if (gi->mapped && gi->active && gi->selectbox.open)
15576 DrawEditorElementAnimation(SX + x, SY + y);
15578 redraw_mask |= REDRAW_FIELD;
15580 FrameCounter++; // increase animation frame counter
15583 static void HandleLevelEditorIdle_Drawing(void)
15585 static boolean last_highlighted = FALSE;
15586 static boolean last_highlighted_similar = FALSE;
15587 boolean highlighted = (GetKeyModState() & KMOD_Alt);
15588 boolean highlighted_similar = (GetKeyModState() & KMOD_Shift);
15590 if (highlighted != last_highlighted ||
15591 (highlighted && highlighted_similar != last_highlighted_similar))
15593 DrawAreaElementHighlight(highlighted, highlighted_similar);
15595 redraw_mask |= REDRAW_FIELD;
15598 last_highlighted = highlighted;
15599 last_highlighted_similar = highlighted_similar;
15602 void HandleLevelEditorIdle(void)
15604 if (edit_mode == ED_MODE_PROPERTIES)
15605 HandleLevelEditorIdle_Properties();
15606 else if (edit_mode == ED_MODE_DRAWING)
15607 HandleLevelEditorIdle_Drawing();
15610 static void ClearEditorGadgetInfoText(void)
15612 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
15615 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
15617 char infotext[MAX_OUTPUT_LINESIZE + 1];
15618 int max_infotext_len = getMaxInfoTextLength();
15620 if (gi == NULL || strlen(gi->info_text) == 0)
15623 strncpy(infotext, gi->info_text, max_infotext_len);
15624 infotext[max_infotext_len] = '\0';
15626 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
15628 int key = controlbutton_info[gi->custom_id].shortcut;
15632 char shortcut[MAX_OUTPUT_LINESIZE + 1];
15634 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
15635 sprintf(shortcut, " ('.' or '%c')", key);
15636 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
15637 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
15638 else if (gi->custom_id == GADGET_ID_TEST)
15639 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
15640 else if (gi->custom_id == GADGET_ID_UNDO)
15641 sprintf(shortcut, " ('%c/Shift-U')", key);
15642 else if (gi->custom_id == GADGET_ID_ZOOM)
15643 sprintf(shortcut, " ('%c', '0', '-')", key);
15645 sprintf(shortcut, " ('%s%c')",
15646 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
15648 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
15649 strcat(infotext, shortcut);
15653 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, INFOTEXT_FONT);
15656 void HandleEditorGadgetInfoText(void *ptr)
15658 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
15660 if (game_status != GAME_MODE_EDITOR)
15663 ClearEditorGadgetInfoText();
15665 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
15668 // misuse this function to delete brush cursor, if needed
15669 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
15670 DeleteBrushFromCursor();
15672 PrintEditorGadgetInfoText(gi);
15675 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
15677 int id = gi->custom_id;
15678 int type_id = gi->custom_type_id;
15679 int sx = gi->event.x;
15680 int sy = gi->event.y;
15681 int lx = sx + level_xpos;
15682 int ly = sy + level_ypos;
15683 int min_sx = 0, min_sy = 0;
15684 int max_sx = gi->drawing.area_xsize - 1;
15685 int max_sy = gi->drawing.area_ysize - 1;
15686 int actual_drawing_function = drawing_function;
15687 int max_infotext_len = getMaxInfoTextLength();
15688 char infotext[MAX_OUTPUT_LINESIZE + 1];
15690 infotext[0] = '\0'; // start with empty info text
15692 // pressed Control key: simulate picking element
15693 if (GetKeyModState() & KMOD_Control)
15694 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
15696 ClearEditorGadgetInfoText();
15698 if (gi->event.type == GD_EVENT_INFO_LEAVING)
15701 // make sure to stay inside drawing area boundaries
15702 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
15703 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
15705 if (id == GADGET_ID_DRAWING_LEVEL)
15709 int min_lx = 0, min_ly = 0;
15710 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
15712 // get positions inside level field
15713 lx = sx + level_xpos;
15714 ly = sy + level_ypos;
15716 // make sure to stay inside level field boundaries
15717 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
15718 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
15720 // correct drawing area positions accordingly
15721 sx = lx - level_xpos;
15722 sy = ly - level_ypos;
15725 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
15727 if (button_status) // if (gi->state == GD_BUTTON_PRESSED)
15729 static int start_lx = 0;
15730 static int start_ly = 0;
15733 if (gi->event.type == GD_EVENT_PRESSED)
15739 switch (actual_drawing_function)
15741 case GADGET_ID_SINGLE_ITEMS:
15742 text = "Drawing single items";
15744 case GADGET_ID_CONNECTED_ITEMS:
15745 text = "Drawing connected items";
15747 case GADGET_ID_LINE:
15748 text = "Drawing line";
15750 case GADGET_ID_ARC:
15751 text = "Drawing arc";
15753 case GADGET_ID_TEXT:
15754 text = "Setting text cursor";
15756 case GADGET_ID_RECTANGLE:
15757 text = "Drawing rectangle";
15759 case GADGET_ID_FILLED_BOX:
15760 text = "Drawing filled box";
15762 case GADGET_ID_FLOOD_FILL:
15763 text = "Flood fill";
15765 case GADGET_ID_GRAB_BRUSH:
15766 text = "Grabbing brush";
15768 case GADGET_ID_PICK_ELEMENT:
15769 text = "Picking element";
15773 text = "Drawing position";
15777 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15778 sprintf(infotext, "%s: %d, %d", text, lx, ly);
15780 sprintf(infotext, "%s: %d, %d", text,
15781 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
15783 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15784 strncpy(infotext, getElementInfoText(Tile[lx][ly]), max_infotext_len);
15786 sprintf(infotext, "Level position: %d, %d", lx, ly);
15789 // misuse this function to draw brush cursor, if needed
15790 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
15792 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
15793 CopyBrushToCursor(sx, sy);
15795 DeleteBrushFromCursor();
15798 if (!draw_with_brush)
15799 UpdateBrushPosition(sx, sy);
15801 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15803 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
15804 int element = drawingarea_info[type_id].value[pos];
15806 strncpy(infotext, getElementInfoText(element), max_infotext_len);
15810 if (id == GADGET_ID_CUSTOM_CONTENT)
15811 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
15812 else if (id == GADGET_ID_GROUP_CONTENT)
15813 sprintf(infotext, "group element position: %d", sx + 1);
15814 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
15815 id <= GADGET_ID_YAMYAM_CONTENT_7)
15816 sprintf(infotext, "content area %d position: %d, %d",
15817 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
15818 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
15819 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
15820 sprintf(infotext, "content area %d position: %d, %d",
15821 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
15822 else if (id == GADGET_ID_ANDROID_CONTENT)
15823 sprintf(infotext, "android element position: %d", sx + 1);
15824 else if (drawingarea_info[type_id].infotext != NULL)
15825 strcpy(infotext, drawingarea_info[type_id].infotext);
15828 infotext[max_infotext_len] = '\0';
15830 if (strlen(infotext) > 0)
15831 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT, infotext);
15834 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
15835 boolean quick_quit)
15837 if (!ask_if_level_has_changed ||
15839 Request("Level has changed! Exit without saving?",
15840 REQ_ASK | REQ_STAY_OPEN))
15842 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
15843 struct RectWithBorder *vp_door_2 = &viewport.door_2[GAME_MODE_MAIN];
15845 // draw normal door
15846 UndrawSpecialEditorDoor();
15848 // use door animation if door 1 viewport is unchanged and contains toolbox
15849 if (useEditorDoorAnimation())
15850 CloseDoor(DOOR_CLOSE_1 | DOOR_FORCE_ANIM);
15852 // close editor doors if viewport definition is the same as in main menu
15853 if (vp_door_1->x == DX &&
15854 vp_door_1->y == DY &&
15855 vp_door_1->width == DXSIZE &&
15856 vp_door_1->height == DYSIZE &&
15857 vp_door_2->x == VX &&
15858 vp_door_2->y == VY &&
15859 vp_door_2->width == VXSIZE &&
15860 vp_door_2->height == VYSIZE)
15861 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
15863 SetDoorState(DOOR_CLOSE_ALL);
15868 FadeSkipNextFadeIn();
15870 SetGameStatus(GAME_MODE_MAIN);
15876 if (!global.use_envelope_request)
15878 CloseDoor(DOOR_CLOSE_1);
15879 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);