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_BD_CYCLE_DELAY_MS_DOWN,
433 GADGET_ID_BD_CYCLE_DELAY_MS_TEXT,
434 GADGET_ID_BD_CYCLE_DELAY_MS_UP,
435 GADGET_ID_BD_CYCLE_DELAY_C64_DOWN,
436 GADGET_ID_BD_CYCLE_DELAY_C64_TEXT,
437 GADGET_ID_BD_CYCLE_DELAY_C64_UP,
438 GADGET_ID_BD_HATCHING_DELAY_CYCLES_DOWN,
439 GADGET_ID_BD_HATCHING_DELAY_CYCLES_TEXT,
440 GADGET_ID_BD_HATCHING_DELAY_CYCLES_UP,
441 GADGET_ID_BD_HATCHING_DELAY_SECONDS_DOWN,
442 GADGET_ID_BD_HATCHING_DELAY_SECONDS_TEXT,
443 GADGET_ID_BD_HATCHING_DELAY_SECONDS_UP,
444 GADGET_ID_BD_PUSHING_PROB_DOWN,
445 GADGET_ID_BD_PUSHING_PROB_TEXT,
446 GADGET_ID_BD_PUSHING_PROB_UP,
447 GADGET_ID_BD_PUSHING_PROB_WITH_SWEET_DOWN,
448 GADGET_ID_BD_PUSHING_PROB_WITH_SWEET_TEXT,
449 GADGET_ID_BD_PUSHING_PROB_WITH_SWEET_UP,
450 GADGET_ID_ELEMENT_VALUE1_DOWN,
451 GADGET_ID_ELEMENT_VALUE1_TEXT,
452 GADGET_ID_ELEMENT_VALUE1_UP,
453 GADGET_ID_ELEMENT_VALUE2_DOWN,
454 GADGET_ID_ELEMENT_VALUE2_TEXT,
455 GADGET_ID_ELEMENT_VALUE2_UP,
456 GADGET_ID_ELEMENT_VALUE3_DOWN,
457 GADGET_ID_ELEMENT_VALUE3_TEXT,
458 GADGET_ID_ELEMENT_VALUE3_UP,
459 GADGET_ID_ELEMENT_VALUE4_DOWN,
460 GADGET_ID_ELEMENT_VALUE4_TEXT,
461 GADGET_ID_ELEMENT_VALUE4_UP,
462 GADGET_ID_YAMYAM_CONTENT_DOWN,
463 GADGET_ID_YAMYAM_CONTENT_TEXT,
464 GADGET_ID_YAMYAM_CONTENT_UP,
465 GADGET_ID_BALL_CONTENT_DOWN,
466 GADGET_ID_BALL_CONTENT_TEXT,
467 GADGET_ID_BALL_CONTENT_UP,
468 GADGET_ID_ANDROID_CONTENT_DOWN,
469 GADGET_ID_ANDROID_CONTENT_TEXT,
470 GADGET_ID_ANDROID_CONTENT_UP,
471 GADGET_ID_ENVELOPE_XSIZE_DOWN,
472 GADGET_ID_ENVELOPE_XSIZE_TEXT,
473 GADGET_ID_ENVELOPE_XSIZE_UP,
474 GADGET_ID_ENVELOPE_YSIZE_DOWN,
475 GADGET_ID_ENVELOPE_YSIZE_TEXT,
476 GADGET_ID_ENVELOPE_YSIZE_UP,
477 GADGET_ID_INVENTORY_SIZE_DOWN,
478 GADGET_ID_INVENTORY_SIZE_TEXT,
479 GADGET_ID_INVENTORY_SIZE_UP,
480 GADGET_ID_MM_BALL_CONTENT_DOWN,
481 GADGET_ID_MM_BALL_CONTENT_TEXT,
482 GADGET_ID_MM_BALL_CONTENT_UP,
483 GADGET_ID_CUSTOM_SCORE_DOWN,
484 GADGET_ID_CUSTOM_SCORE_TEXT,
485 GADGET_ID_CUSTOM_SCORE_UP,
486 GADGET_ID_CUSTOM_GEMCOUNT_DOWN,
487 GADGET_ID_CUSTOM_GEMCOUNT_TEXT,
488 GADGET_ID_CUSTOM_GEMCOUNT_UP,
489 GADGET_ID_CUSTOM_VALUE_FIX_DOWN,
490 GADGET_ID_CUSTOM_VALUE_FIX_TEXT,
491 GADGET_ID_CUSTOM_VALUE_FIX_UP,
492 GADGET_ID_CUSTOM_VALUE_RND_DOWN,
493 GADGET_ID_CUSTOM_VALUE_RND_TEXT,
494 GADGET_ID_CUSTOM_VALUE_RND_UP,
495 GADGET_ID_PUSH_DELAY_FIX_DOWN,
496 GADGET_ID_PUSH_DELAY_FIX_TEXT,
497 GADGET_ID_PUSH_DELAY_FIX_UP,
498 GADGET_ID_PUSH_DELAY_RND_DOWN,
499 GADGET_ID_PUSH_DELAY_RND_TEXT,
500 GADGET_ID_PUSH_DELAY_RND_UP,
501 GADGET_ID_DROP_DELAY_FIX_DOWN,
502 GADGET_ID_DROP_DELAY_FIX_TEXT,
503 GADGET_ID_DROP_DELAY_FIX_UP,
504 GADGET_ID_DROP_DELAY_RND_DOWN,
505 GADGET_ID_DROP_DELAY_RND_TEXT,
506 GADGET_ID_DROP_DELAY_RND_UP,
507 GADGET_ID_MOVE_DELAY_FIX_DOWN,
508 GADGET_ID_MOVE_DELAY_FIX_TEXT,
509 GADGET_ID_MOVE_DELAY_FIX_UP,
510 GADGET_ID_MOVE_DELAY_RND_DOWN,
511 GADGET_ID_MOVE_DELAY_RND_TEXT,
512 GADGET_ID_MOVE_DELAY_RND_UP,
513 GADGET_ID_STEP_DELAY_FIX_DOWN,
514 GADGET_ID_STEP_DELAY_FIX_TEXT,
515 GADGET_ID_STEP_DELAY_FIX_UP,
516 GADGET_ID_STEP_DELAY_RND_DOWN,
517 GADGET_ID_STEP_DELAY_RND_TEXT,
518 GADGET_ID_STEP_DELAY_RND_UP,
519 GADGET_ID_EXPLOSION_DELAY_DOWN,
520 GADGET_ID_EXPLOSION_DELAY_TEXT,
521 GADGET_ID_EXPLOSION_DELAY_UP,
522 GADGET_ID_IGNITION_DELAY_DOWN,
523 GADGET_ID_IGNITION_DELAY_TEXT,
524 GADGET_ID_IGNITION_DELAY_UP,
525 GADGET_ID_CHANGE_DELAY_FIX_DOWN,
526 GADGET_ID_CHANGE_DELAY_FIX_TEXT,
527 GADGET_ID_CHANGE_DELAY_FIX_UP,
528 GADGET_ID_CHANGE_DELAY_RND_DOWN,
529 GADGET_ID_CHANGE_DELAY_RND_TEXT,
530 GADGET_ID_CHANGE_DELAY_RND_UP,
531 GADGET_ID_CHANGE_CONT_RND_DOWN,
532 GADGET_ID_CHANGE_CONT_RND_TEXT,
533 GADGET_ID_CHANGE_CONT_RND_UP,
534 GADGET_ID_GROUP_CONTENT_DOWN,
535 GADGET_ID_GROUP_CONTENT_TEXT,
536 GADGET_ID_GROUP_CONTENT_UP,
538 // drawing area identifiers
540 GADGET_ID_DRAWING_LEVEL,
541 GADGET_ID_YAMYAM_CONTENT_0,
542 GADGET_ID_YAMYAM_CONTENT_1,
543 GADGET_ID_YAMYAM_CONTENT_2,
544 GADGET_ID_YAMYAM_CONTENT_3,
545 GADGET_ID_YAMYAM_CONTENT_4,
546 GADGET_ID_YAMYAM_CONTENT_5,
547 GADGET_ID_YAMYAM_CONTENT_6,
548 GADGET_ID_YAMYAM_CONTENT_7,
549 GADGET_ID_MAGIC_BALL_CONTENT_0,
550 GADGET_ID_MAGIC_BALL_CONTENT_1,
551 GADGET_ID_MAGIC_BALL_CONTENT_2,
552 GADGET_ID_MAGIC_BALL_CONTENT_3,
553 GADGET_ID_MAGIC_BALL_CONTENT_4,
554 GADGET_ID_MAGIC_BALL_CONTENT_5,
555 GADGET_ID_MAGIC_BALL_CONTENT_6,
556 GADGET_ID_MAGIC_BALL_CONTENT_7,
557 GADGET_ID_ANDROID_CONTENT,
558 GADGET_ID_AMOEBA_CONTENT,
559 GADGET_ID_START_ELEMENT,
560 GADGET_ID_ARTWORK_ELEMENT,
561 GADGET_ID_EXPLOSION_ELEMENT,
562 GADGET_ID_INVENTORY_CONTENT,
563 GADGET_ID_MM_BALL_CONTENT,
564 GADGET_ID_CUSTOM_GRAPHIC,
565 GADGET_ID_CUSTOM_CONTENT,
566 GADGET_ID_CUSTOM_MOVE_ENTER,
567 GADGET_ID_CUSTOM_MOVE_LEAVE,
568 GADGET_ID_CUSTOM_CHANGE_TARGET,
569 GADGET_ID_CUSTOM_CHANGE_CONTENT,
570 GADGET_ID_CUSTOM_CHANGE_TRIGGER,
571 GADGET_ID_CUSTOM_CHANGE_ACTION,
572 GADGET_ID_GROUP_CONTENT,
573 GADGET_ID_RANDOM_BACKGROUND,
575 // text input identifiers
577 GADGET_ID_LEVEL_NAME,
578 GADGET_ID_LEVEL_AUTHOR,
579 GADGET_ID_LEVELSET_NAME,
580 GADGET_ID_LEVELSET_AUTHOR,
581 GADGET_ID_ELEMENT_NAME,
583 // text area identifiers
585 GADGET_ID_ENVELOPE_INFO,
587 // selectbox identifiers
589 GADGET_ID_TIME_OR_STEPS,
590 GADGET_ID_TIME_SCORE_BASE,
591 GADGET_ID_GAME_ENGINE_TYPE,
592 GADGET_ID_BD_SCHEDULING_TYPE,
593 GADGET_ID_LEVELSET_SAVE_MODE,
594 GADGET_ID_WIND_DIRECTION,
595 GADGET_ID_PLAYER_SPEED,
596 GADGET_ID_MM_BALL_CHOICE_MODE,
597 GADGET_ID_CUSTOM_WALK_TO_ACTION,
598 GADGET_ID_CUSTOM_EXPLOSION_TYPE,
599 GADGET_ID_CUSTOM_DEADLINESS,
600 GADGET_ID_CUSTOM_MOVE_PATTERN,
601 GADGET_ID_CUSTOM_MOVE_DIRECTION,
602 GADGET_ID_CUSTOM_MOVE_STEPSIZE,
603 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
604 GADGET_ID_CUSTOM_SMASH_TARGETS,
605 GADGET_ID_CUSTOM_SLIPPERY_TYPE,
606 GADGET_ID_CUSTOM_ACCESS_TYPE,
607 GADGET_ID_CUSTOM_ACCESS_LAYER,
608 GADGET_ID_CUSTOM_ACCESS_PROTECTED,
609 GADGET_ID_CUSTOM_ACCESS_DIRECTION,
610 GADGET_ID_CHANGE_TIME_UNITS,
611 GADGET_ID_CHANGE_DIRECT_ACTION,
612 GADGET_ID_CHANGE_OTHER_ACTION,
613 GADGET_ID_CHANGE_SIDE,
614 GADGET_ID_CHANGE_PLAYER,
615 GADGET_ID_CHANGE_PAGE,
616 GADGET_ID_CHANGE_REPLACE_WHEN,
617 GADGET_ID_ACTION_TYPE,
618 GADGET_ID_ACTION_MODE,
619 GADGET_ID_ACTION_ARG,
620 GADGET_ID_SELECT_CHANGE_PAGE,
621 GADGET_ID_GROUP_CHOICE_MODE,
623 // textbutton identifiers
625 GADGET_ID_LEVELCONFIG_LEVEL,
626 GADGET_ID_LEVELCONFIG_LEVELSET,
627 GADGET_ID_LEVELCONFIG_EDITOR,
628 GADGET_ID_LEVELCONFIG_ENGINE,
629 GADGET_ID_PROPERTIES_INFO,
630 GADGET_ID_PROPERTIES_CONFIG,
631 GADGET_ID_PROPERTIES_CONFIG_1,
632 GADGET_ID_PROPERTIES_CONFIG_2,
633 GADGET_ID_PROPERTIES_CHANGE,
634 GADGET_ID_SAVE_AS_TEMPLATE_1,
635 GADGET_ID_SAVE_AS_TEMPLATE_2,
636 GADGET_ID_SAVE_LEVELSET,
637 GADGET_ID_ADD_CHANGE_PAGE,
638 GADGET_ID_DEL_CHANGE_PAGE,
640 // graphicbutton identifiers
642 GADGET_ID_PREV_CHANGE_PAGE,
643 GADGET_ID_NEXT_CHANGE_PAGE,
644 GADGET_ID_COPY_CHANGE_PAGE,
645 GADGET_ID_PASTE_CHANGE_PAGE,
647 // gadgets for scrolling of drawing area
650 GADGET_ID_SCROLL_DOWN,
651 GADGET_ID_SCROLL_LEFT,
652 GADGET_ID_SCROLL_RIGHT,
653 GADGET_ID_SCROLL_HORIZONTAL,
654 GADGET_ID_SCROLL_VERTICAL,
656 // gadgets for scrolling element list
658 GADGET_ID_SCROLL_LIST_UP,
659 GADGET_ID_SCROLL_LIST_DOWN,
660 GADGET_ID_SCROLL_LIST_VERTICAL,
662 // checkbuttons/radiobuttons for level/element properties
664 GADGET_ID_AUTO_COUNT_GEMS,
665 GADGET_ID_RATE_TIME_OVER_SCORE,
666 GADGET_ID_USE_LEVELSET_ARTWORK,
667 GADGET_ID_COPY_LEVEL_TEMPLATE,
668 GADGET_ID_RANDOM_PERCENTAGE,
669 GADGET_ID_RANDOM_QUANTITY,
670 GADGET_ID_RANDOM_RESTRICTED,
671 GADGET_ID_BD_INTERMISSION,
672 GADGET_ID_BD_PAL_TIMING,
673 GADGET_ID_BD_LINE_SHIFTING_BORDERS,
674 GADGET_ID_BD_SCAN_FIRST_AND_LAST_ROW,
675 GADGET_ID_BD_SHORT_EXPLOSIONS,
676 GADGET_ID_BD_GRAVITY_AFFECTS_ALL,
677 GADGET_ID_STICK_ELEMENT,
678 GADGET_ID_EM_SLIPPERY_GEMS,
679 GADGET_ID_EM_EXPLODES_BY_FIRE,
680 GADGET_ID_USE_SPRING_BUG,
681 GADGET_ID_USE_TIME_ORB_BUG,
682 GADGET_ID_USE_LIFE_BUGS,
683 GADGET_ID_RANDOM_BALL_CONTENT,
684 GADGET_ID_INITIAL_BALL_ACTIVE,
685 GADGET_ID_GROW_INTO_DIGGABLE,
686 GADGET_ID_SB_FIELDS_NEEDED,
687 GADGET_ID_SB_OBJECTS_NEEDED,
688 GADGET_ID_AUTO_EXIT_SOKOBAN,
689 GADGET_ID_SOLVED_BY_ONE_PLAYER,
690 GADGET_ID_FINISH_DIG_COLLECT,
691 GADGET_ID_KEEP_WALKABLE_CE,
692 GADGET_ID_CONTINUOUS_SNAPPING,
693 GADGET_ID_BLOCK_SNAP_FIELD,
694 GADGET_ID_BLOCK_LAST_FIELD,
695 GADGET_ID_SP_BLOCK_LAST_FIELD,
696 GADGET_ID_INSTANT_RELOCATION,
697 GADGET_ID_SHIFTED_RELOCATION,
698 GADGET_ID_LAZY_RELOCATION,
699 GADGET_ID_USE_START_ELEMENT,
700 GADGET_ID_USE_ARTWORK_ELEMENT,
701 GADGET_ID_USE_EXPLOSION_ELEMENT,
702 GADGET_ID_INITIAL_GRAVITY,
703 GADGET_ID_USE_INITIAL_INVENTORY,
704 GADGET_ID_CAN_PASS_TO_WALKABLE,
705 GADGET_ID_CAN_FALL_INTO_ACID,
706 GADGET_ID_CAN_MOVE_INTO_ACID,
707 GADGET_ID_DONT_COLLIDE_WITH,
708 GADGET_ID_BD_DIAGONAL_MOVEMENTS,
709 GADGET_ID_BD_TOPMOST_PLAYER_ACTIVE,
710 GADGET_ID_BD_PUSH_MEGA_ROCK_WITH_SWEET,
711 GADGET_ID_ENVELOPE_AUTOWRAP,
712 GADGET_ID_ENVELOPE_CENTERED,
713 GADGET_ID_MM_LASER_RED,
714 GADGET_ID_MM_LASER_GREEN,
715 GADGET_ID_MM_LASER_BLUE,
716 GADGET_ID_DF_LASER_RED,
717 GADGET_ID_DF_LASER_GREEN,
718 GADGET_ID_DF_LASER_BLUE,
719 GADGET_ID_ROTATE_MM_BALL_CONTENT,
720 GADGET_ID_EXPLODE_MM_BALL,
721 GADGET_ID_CUSTOM_INDESTRUCTIBLE,
722 GADGET_ID_CUSTOM_CAN_EXPLODE,
723 GADGET_ID_CUSTOM_EXPLODE_FIRE,
724 GADGET_ID_CUSTOM_EXPLODE_SMASH,
725 GADGET_ID_CUSTOM_EXPLODE_IMPACT,
726 GADGET_ID_CUSTOM_WALK_TO_OBJECT,
727 GADGET_ID_CUSTOM_DEADLY,
728 GADGET_ID_CUSTOM_CAN_MOVE,
729 GADGET_ID_CUSTOM_CAN_FALL,
730 GADGET_ID_CUSTOM_CAN_SMASH,
731 GADGET_ID_CUSTOM_SLIPPERY,
732 GADGET_ID_CUSTOM_ACCESSIBLE,
733 GADGET_ID_CUSTOM_GRAV_REACHABLE,
734 GADGET_ID_CUSTOM_USE_LAST_VALUE,
735 GADGET_ID_CUSTOM_USE_GRAPHIC,
736 GADGET_ID_CUSTOM_USE_TEMPLATE_1,
737 GADGET_ID_CUSTOM_USE_TEMPLATE_2,
738 GADGET_ID_CUSTOM_USE_TEMPLATE_3,
739 GADGET_ID_CUSTOM_CAN_CHANGE,
740 GADGET_ID_CHANGE_USE_CONTENT,
741 GADGET_ID_CHANGE_USE_EXPLOSION,
742 GADGET_ID_CHANGE_ONLY_COMPLETE,
743 GADGET_ID_CHANGE_USE_RANDOM,
744 GADGET_ID_CHANGE_HAS_ACTION,
745 GADGET_ID_CHANGE_DELAY,
746 GADGET_ID_CHANGE_BY_DIRECT_ACT,
747 GADGET_ID_CHANGE_BY_OTHER_ACT,
749 NUM_STATIC_GADGET_IDS
752 // gadgets for buttons in element list (dynamic)
753 #define GADGET_ID_ELEMENTLIST_FIRST (NUM_STATIC_GADGET_IDS)
754 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
755 ED_NUM_ELEMENTLIST_BUTTONS - 1)
757 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
759 // radio button numbers
763 RADIO_NR_DRAWING_TOOLBOX,
764 RADIO_NR_RANDOM_ELEMENTS
767 // values for counter gadgets
770 ED_COUNTER_ID_SELECT_LEVEL,
771 ED_COUNTER_ID_LEVEL_XSIZE,
772 ED_COUNTER_ID_LEVEL_YSIZE,
773 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
774 ED_COUNTER_ID_LEVEL_TIMELIMIT,
775 ED_COUNTER_ID_LEVEL_TIMESCORE,
776 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
777 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
778 ED_COUNTER_ID_LEVEL_RANDOM,
779 ED_COUNTER_ID_BD_CYCLE_DELAY_MS,
780 ED_COUNTER_ID_BD_CYCLE_DELAY_C64,
781 ED_COUNTER_ID_BD_HATCHING_DELAY_CYCLES,
782 ED_COUNTER_ID_BD_HATCHING_DELAY_SECONDS,
783 ED_COUNTER_ID_BD_PUSHING_PROB,
784 ED_COUNTER_ID_BD_PUSHING_PROB_WITH_SWEET,
785 ED_COUNTER_ID_ELEMENT_VALUE1,
786 ED_COUNTER_ID_ELEMENT_VALUE2,
787 ED_COUNTER_ID_ELEMENT_VALUE3,
788 ED_COUNTER_ID_ELEMENT_VALUE4,
789 ED_COUNTER_ID_YAMYAM_CONTENT,
790 ED_COUNTER_ID_BALL_CONTENT,
791 ED_COUNTER_ID_ANDROID_CONTENT,
792 ED_COUNTER_ID_ENVELOPE_XSIZE,
793 ED_COUNTER_ID_ENVELOPE_YSIZE,
794 ED_COUNTER_ID_INVENTORY_SIZE,
795 ED_COUNTER_ID_MM_BALL_CONTENT,
796 ED_COUNTER_ID_CUSTOM_SCORE,
797 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
798 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
799 ED_COUNTER_ID_CUSTOM_VALUE_RND,
800 ED_COUNTER_ID_PUSH_DELAY_FIX,
801 ED_COUNTER_ID_PUSH_DELAY_RND,
802 ED_COUNTER_ID_DROP_DELAY_FIX,
803 ED_COUNTER_ID_DROP_DELAY_RND,
804 ED_COUNTER_ID_MOVE_DELAY_FIX,
805 ED_COUNTER_ID_MOVE_DELAY_RND,
806 ED_COUNTER_ID_STEP_DELAY_FIX,
807 ED_COUNTER_ID_STEP_DELAY_RND,
808 ED_COUNTER_ID_EXPLOSION_DELAY,
809 ED_COUNTER_ID_IGNITION_DELAY,
810 ED_COUNTER_ID_GROUP_CONTENT,
811 ED_COUNTER_ID_CHANGE_DELAY_FIX,
812 ED_COUNTER_ID_CHANGE_DELAY_RND,
813 ED_COUNTER_ID_CHANGE_CONT_RND,
815 ED_NUM_COUNTERBUTTONS
818 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
819 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
820 #define ED_COUNTER_ID_LEVELSET_FIRST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
821 #define ED_COUNTER_ID_LEVELSET_LAST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
822 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
823 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
825 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
826 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
827 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
828 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
829 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
830 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
832 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
833 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
835 // values for scrollbutton gadgets
838 ED_SCROLLBUTTON_ID_AREA_UP,
839 ED_SCROLLBUTTON_ID_AREA_DOWN,
840 ED_SCROLLBUTTON_ID_AREA_LEFT,
841 ED_SCROLLBUTTON_ID_AREA_RIGHT,
842 ED_SCROLLBUTTON_ID_LIST_UP,
843 ED_SCROLLBUTTON_ID_LIST_DOWN,
848 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
849 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
851 // values for scrollbar gadgets
854 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
855 ED_SCROLLBAR_ID_AREA_VERTICAL,
856 ED_SCROLLBAR_ID_LIST_VERTICAL,
861 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
862 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
864 // values for text input gadgets
867 ED_TEXTINPUT_ID_LEVEL_NAME,
868 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
869 ED_TEXTINPUT_ID_LEVELSET_NAME,
870 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
871 ED_TEXTINPUT_ID_ELEMENT_NAME,
876 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
877 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
879 #define ED_TEXTINPUT_ID_LEVELSET_FIRST ED_TEXTINPUT_ID_LEVELSET_NAME
880 #define ED_TEXTINPUT_ID_LEVELSET_LAST ED_TEXTINPUT_ID_LEVELSET_AUTHOR
882 // values for text area gadgets
885 ED_TEXTAREA_ID_ENVELOPE_INFO,
890 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
891 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
893 // values for selectbox gadgets
896 ED_SELECTBOX_ID_TIME_OR_STEPS,
897 ED_SELECTBOX_ID_TIME_SCORE_BASE,
898 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
899 ED_SELECTBOX_ID_BD_SCHEDULING_TYPE,
900 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
901 ED_SELECTBOX_ID_WIND_DIRECTION,
902 ED_SELECTBOX_ID_PLAYER_SPEED,
903 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
904 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
905 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
906 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
907 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
908 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
909 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
910 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
911 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
912 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
913 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
914 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
915 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
916 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
917 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
918 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
919 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
920 ED_SELECTBOX_ID_CHANGE_SIDE,
921 ED_SELECTBOX_ID_CHANGE_PLAYER,
922 ED_SELECTBOX_ID_CHANGE_PAGE,
923 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
924 ED_SELECTBOX_ID_ACTION_TYPE,
925 ED_SELECTBOX_ID_ACTION_MODE,
926 ED_SELECTBOX_ID_ACTION_ARG,
927 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
928 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
933 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
934 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_GAME_ENGINE_TYPE
936 #define ED_SELECTBOX_ID_LEVELSET_FIRST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
937 #define ED_SELECTBOX_ID_LEVELSET_LAST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
939 #define ED_SELECTBOX_ID_ENGINE_FIRST ED_SELECTBOX_ID_BD_SCHEDULING_TYPE
940 #define ED_SELECTBOX_ID_ENGINE_LAST ED_SELECTBOX_ID_BD_SCHEDULING_TYPE
942 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
943 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
944 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
945 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
946 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
947 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
949 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
950 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
952 // values for textbutton gadgets
955 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL,
956 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET,
957 ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR,
958 ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE,
959 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
960 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
961 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
962 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
963 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
964 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
965 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
966 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
967 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
968 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
973 #define ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
974 #define ED_TAB_BUTTON_ID_LEVELCONFIG_LAST ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE
976 #define ED_TAB_BUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
977 #define ED_TAB_BUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
979 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
980 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
982 // values for graphicbutton gadgets
985 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
986 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
987 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
988 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
990 ED_NUM_GRAPHICBUTTONS
993 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
994 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
996 // values for checkbutton gadgets
999 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
1000 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
1001 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
1002 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
1003 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
1004 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
1005 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
1006 ED_CHECKBUTTON_ID_BD_INTERMISSION,
1007 ED_CHECKBUTTON_ID_BD_PAL_TIMING,
1008 ED_CHECKBUTTON_ID_BD_LINE_SHIFTING_BORDERS,
1009 ED_CHECKBUTTON_ID_BD_SCAN_FIRST_AND_LAST_ROW,
1010 ED_CHECKBUTTON_ID_BD_SHORT_EXPLOSIONS,
1011 ED_CHECKBUTTON_ID_BD_GRAVITY_AFFECTS_ALL,
1012 ED_CHECKBUTTON_ID_STICK_ELEMENT,
1013 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
1014 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
1015 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
1016 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
1017 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
1018 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
1019 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
1020 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
1021 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
1022 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
1023 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
1024 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
1025 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
1026 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
1027 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
1028 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
1029 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
1030 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
1031 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
1032 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
1033 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
1034 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
1035 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
1036 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
1037 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
1038 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
1039 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
1040 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
1041 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
1042 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
1043 ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS,
1044 ED_CHECKBUTTON_ID_BD_TOPMOST_PLAYER_ACTIVE,
1045 ED_CHECKBUTTON_ID_BD_PUSH_MEGA_ROCK_WITH_SWEET,
1046 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
1047 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
1048 ED_CHECKBUTTON_ID_MM_LASER_RED,
1049 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
1050 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
1051 ED_CHECKBUTTON_ID_DF_LASER_RED,
1052 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
1053 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
1054 ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT,
1055 ED_CHECKBUTTON_ID_EXPLODE_MM_BALL,
1056 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
1057 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
1058 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
1059 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
1060 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
1061 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
1062 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
1063 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
1064 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
1065 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
1066 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
1067 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
1068 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
1069 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
1070 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
1071 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
1072 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
1073 ED_CHECKBUTTON_ID_CHANGE_DELAY,
1074 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
1075 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
1076 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
1077 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
1078 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
1079 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
1080 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
1085 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
1086 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE
1088 #define ED_CHECKBUTTON_ID_LEVELSET_FIRST ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK
1089 #define ED_CHECKBUTTON_ID_LEVELSET_LAST ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE
1091 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
1092 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2
1094 #define ED_CHECKBUTTON_ID_ENGINE_FIRST ED_CHECKBUTTON_ID_BD_INTERMISSION
1095 #define ED_CHECKBUTTON_ID_ENGINE_LAST ED_CHECKBUTTON_ID_BD_GRAVITY_AFFECTS_ALL
1097 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
1098 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
1099 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
1100 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
1101 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
1102 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
1104 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
1105 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
1107 // values for radiobutton gadgets
1110 ED_RADIOBUTTON_ID_PERCENTAGE,
1111 ED_RADIOBUTTON_ID_QUANTITY,
1116 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
1117 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
1119 // values for drawing area gadgets
1122 ED_DRAWING_ID_DRAWING_LEVEL,
1123 ED_DRAWING_ID_YAMYAM_CONTENT_0,
1124 ED_DRAWING_ID_YAMYAM_CONTENT_1,
1125 ED_DRAWING_ID_YAMYAM_CONTENT_2,
1126 ED_DRAWING_ID_YAMYAM_CONTENT_3,
1127 ED_DRAWING_ID_YAMYAM_CONTENT_4,
1128 ED_DRAWING_ID_YAMYAM_CONTENT_5,
1129 ED_DRAWING_ID_YAMYAM_CONTENT_6,
1130 ED_DRAWING_ID_YAMYAM_CONTENT_7,
1131 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
1132 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
1133 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
1134 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
1135 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
1136 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
1137 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
1138 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
1139 ED_DRAWING_ID_ANDROID_CONTENT,
1140 ED_DRAWING_ID_AMOEBA_CONTENT,
1141 ED_DRAWING_ID_START_ELEMENT,
1142 ED_DRAWING_ID_ARTWORK_ELEMENT,
1143 ED_DRAWING_ID_EXPLOSION_ELEMENT,
1144 ED_DRAWING_ID_INVENTORY_CONTENT,
1145 ED_DRAWING_ID_MM_BALL_CONTENT,
1146 ED_DRAWING_ID_CUSTOM_GRAPHIC,
1147 ED_DRAWING_ID_CUSTOM_CONTENT,
1148 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
1149 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
1150 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
1151 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
1152 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
1153 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
1154 ED_DRAWING_ID_GROUP_CONTENT,
1155 ED_DRAWING_ID_RANDOM_BACKGROUND,
1157 ED_NUM_DRAWING_AREAS
1160 #define ED_DRAWING_ID_EDITOR_FIRST ED_DRAWING_ID_RANDOM_BACKGROUND
1161 #define ED_DRAWING_ID_EDITOR_LAST ED_DRAWING_ID_RANDOM_BACKGROUND
1164 // ----------------------------------------------------------------------------
1165 // some internally used definitions
1166 // ----------------------------------------------------------------------------
1168 // values for CopyLevelToUndoBuffer()
1169 #define UNDO_IMMEDIATE 0
1170 #define UNDO_ACCUMULATE 1
1172 // values for scrollbars
1173 #define ED_SCROLL_NO 0
1174 #define ED_SCROLL_LEFT 1
1175 #define ED_SCROLL_RIGHT 2
1176 #define ED_SCROLL_UP 4
1177 #define ED_SCROLL_DOWN 8
1179 // screens in the level editor
1180 #define ED_MODE_DRAWING 0
1181 #define ED_MODE_LEVELCONFIG 1
1182 #define ED_MODE_PROPERTIES 2
1183 #define ED_MODE_PALETTE 3
1185 // sub-screens in the global settings section
1186 #define ED_MODE_LEVELCONFIG_LEVEL ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
1187 #define ED_MODE_LEVELCONFIG_LEVELSET ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET
1188 #define ED_MODE_LEVELCONFIG_EDITOR ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR
1189 #define ED_MODE_LEVELCONFIG_ENGINE ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE
1191 // sub-screens in the element properties section
1192 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
1193 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
1194 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
1195 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
1196 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
1198 // how many steps can be cancelled
1199 #define NUM_UNDO_STEPS (64 + 1)
1201 // values for elements with score for certain actions
1203 #define MAX_SCORE 999
1205 // values for elements with count for collecting
1206 #define MIN_COLLECT_COUNT 0
1207 #define MAX_COLLECT_COUNT 999
1209 // values for random placement
1210 #define RANDOM_USE_PERCENTAGE 0
1211 #define RANDOM_USE_QUANTITY 1
1213 // values for level set save mode
1214 #define LEVELSET_SAVE_MODE_UPDATE 0
1215 #define LEVELSET_SAVE_MODE_CREATE 1
1217 // default value for element tile size in drawing area
1218 #define DEFAULT_EDITOR_TILESIZE MINI_TILESIZE
1219 #define DEFAULT_EDITOR_TILESIZE_MM TILESIZE
1222 // ----------------------------------------------------------------------------
1223 // some internally used data structure definitions
1224 // ----------------------------------------------------------------------------
1230 struct XYTileSize *pos;
1234 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
1236 // note: some additional characters are already reserved for "cheat mode"
1237 // shortcuts (":XYZ" style) -- for details, see "events.c"
1239 // ---------- toolbox control buttons ---------------------------------------
1242 IMG_GFX_EDITOR_BUTTON_DRAW_SINGLE, GADGET_ID_SINGLE_ITEMS,
1243 &editor.button.draw_single, GD_TYPE_RADIO_BUTTON,
1244 "draw single items", 's'
1247 IMG_GFX_EDITOR_BUTTON_DRAW_CONNECTED, GADGET_ID_CONNECTED_ITEMS,
1248 &editor.button.draw_connected, GD_TYPE_RADIO_BUTTON,
1249 "draw connected items", 'd'
1252 IMG_GFX_EDITOR_BUTTON_DRAW_LINE, GADGET_ID_LINE,
1253 &editor.button.draw_line, GD_TYPE_RADIO_BUTTON,
1257 IMG_GFX_EDITOR_BUTTON_DRAW_ARC, GADGET_ID_ARC,
1258 &editor.button.draw_arc, GD_TYPE_RADIO_BUTTON,
1262 IMG_GFX_EDITOR_BUTTON_DRAW_RECTANGLE, GADGET_ID_RECTANGLE,
1263 &editor.button.draw_rectangle, GD_TYPE_RADIO_BUTTON,
1264 "draw outline rectangles", 'r'
1267 IMG_GFX_EDITOR_BUTTON_DRAW_FILLED_BOX, GADGET_ID_FILLED_BOX,
1268 &editor.button.draw_filled_box, GD_TYPE_RADIO_BUTTON,
1269 "draw filled rectangles", 'R'
1272 IMG_GFX_EDITOR_BUTTON_ROTATE_UP, GADGET_ID_WRAP_UP,
1273 &editor.button.rotate_up, GD_TYPE_NORMAL_BUTTON,
1274 "wrap (rotate) level up", 0
1277 IMG_GFX_EDITOR_BUTTON_DRAW_TEXT, GADGET_ID_TEXT,
1278 &editor.button.draw_text, GD_TYPE_RADIO_BUTTON,
1279 "enter text elements", 't'
1282 IMG_GFX_EDITOR_BUTTON_FLOOD_FILL, GADGET_ID_FLOOD_FILL,
1283 &editor.button.flood_fill, GD_TYPE_RADIO_BUTTON,
1287 IMG_GFX_EDITOR_BUTTON_ROTATE_LEFT, GADGET_ID_WRAP_LEFT,
1288 &editor.button.rotate_left, GD_TYPE_NORMAL_BUTTON,
1289 "wrap (rotate) level left", 0
1292 IMG_GFX_EDITOR_BUTTON_ZOOM_LEVEL, GADGET_ID_ZOOM,
1293 &editor.button.zoom_level, GD_TYPE_NORMAL_BUTTON,
1294 "zoom level tile size", '+'
1297 IMG_GFX_EDITOR_BUTTON_ROTATE_RIGHT, GADGET_ID_WRAP_RIGHT,
1298 &editor.button.rotate_right, GD_TYPE_NORMAL_BUTTON,
1299 "wrap (rotate) level right", 0
1302 IMG_GFX_EDITOR_BUTTON_DRAW_RANDOM, GADGET_ID_RANDOM_PLACEMENT,
1303 &editor.button.draw_random, GD_TYPE_NORMAL_BUTTON,
1304 "random element placement", 0
1307 IMG_GFX_EDITOR_BUTTON_GRAB_BRUSH, GADGET_ID_GRAB_BRUSH,
1308 &editor.button.grab_brush, GD_TYPE_RADIO_BUTTON,
1312 IMG_GFX_EDITOR_BUTTON_ROTATE_DOWN, GADGET_ID_WRAP_DOWN,
1313 &editor.button.rotate_down, GD_TYPE_NORMAL_BUTTON,
1314 "wrap (rotate) level down", 0
1317 IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT, GADGET_ID_PICK_ELEMENT,
1318 &editor.button.pick_element, GD_TYPE_RADIO_BUTTON,
1319 "pick drawing element", ','
1322 // ---------- level control buttons -----------------------------------------
1325 IMG_GFX_EDITOR_BUTTON_UNDO, GADGET_ID_UNDO,
1326 &editor.button.undo, GD_TYPE_NORMAL_BUTTON,
1327 "undo/redo last operation", 'u'
1330 IMG_GFX_EDITOR_BUTTON_CONF, GADGET_ID_CONF,
1331 &editor.button.conf, GD_TYPE_NORMAL_BUTTON,
1332 "level and editor settings", 'I'
1335 IMG_GFX_EDITOR_BUTTON_SAVE, GADGET_ID_SAVE,
1336 &editor.button.save, GD_TYPE_NORMAL_BUTTON,
1340 IMG_GFX_EDITOR_BUTTON_CLEAR, GADGET_ID_CLEAR,
1341 &editor.button.clear, GD_TYPE_NORMAL_BUTTON,
1345 IMG_GFX_EDITOR_BUTTON_TEST, GADGET_ID_TEST,
1346 &editor.button.test, GD_TYPE_NORMAL_BUTTON,
1350 IMG_GFX_EDITOR_BUTTON_EXIT, GADGET_ID_EXIT,
1351 &editor.button.exit, GD_TYPE_NORMAL_BUTTON,
1352 "exit level editor", 'E'
1355 // ---------- CE and GE control buttons -------------------------------------
1358 IMG_GFX_EDITOR_BUTTON_CE_COPY_FROM, GADGET_ID_CUSTOM_COPY_FROM,
1359 &editor.button.ce_copy_from, GD_TYPE_RADIO_BUTTON,
1360 "copy settings from other element", 0
1363 IMG_GFX_EDITOR_BUTTON_CE_COPY_TO, GADGET_ID_CUSTOM_COPY_TO,
1364 &editor.button.ce_copy_to, GD_TYPE_RADIO_BUTTON,
1365 "copy settings to other element", 0
1368 IMG_GFX_EDITOR_BUTTON_CE_SWAP, GADGET_ID_CUSTOM_EXCHANGE,
1369 &editor.button.ce_swap, GD_TYPE_RADIO_BUTTON,
1370 "exchange element with other element", 0
1373 IMG_GFX_EDITOR_BUTTON_CE_COPY, GADGET_ID_CUSTOM_COPY,
1374 &editor.button.ce_copy, GD_TYPE_NORMAL_BUTTON,
1375 "copy settings from this element", 0
1378 IMG_GFX_EDITOR_BUTTON_CE_PASTE, GADGET_ID_CUSTOM_PASTE,
1379 &editor.button.ce_paste, GD_TYPE_NORMAL_BUTTON,
1380 "paste settings to this element", 0
1383 // ---------- palette control buttons ---------------------------------------
1386 IMG_GFX_EDITOR_BUTTON_PROPERTIES, GADGET_ID_PROPERTIES,
1387 &editor.button.properties, GD_TYPE_NORMAL_BUTTON,
1388 "properties of drawing element", 'p'
1391 IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT, GADGET_ID_ELEMENT_LEFT,
1392 &editor.button.element_left, GD_TYPE_NORMAL_BUTTON,
1393 "properties of drawing element 1", '1'
1396 IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE, GADGET_ID_ELEMENT_MIDDLE,
1397 &editor.button.element_middle, GD_TYPE_NORMAL_BUTTON,
1398 "properties of drawing element 2", '2'
1401 IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT, GADGET_ID_ELEMENT_RIGHT,
1402 &editor.button.element_right, GD_TYPE_NORMAL_BUTTON,
1403 "properties of drawing element 3", '3'
1406 IMG_GFX_EDITOR_BUTTON_PALETTE, GADGET_ID_PALETTE,
1407 &editor.button.palette, GD_TYPE_NORMAL_BUTTON,
1408 "show list of elements", 'e'
1412 static int random_placement_value = 10;
1413 static int random_placement_method = RANDOM_USE_QUANTITY;
1414 static int random_placement_background_element = EL_SAND;
1415 static boolean random_placement_background_restricted = FALSE;
1416 static boolean stick_element_properties_window = FALSE;
1417 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1418 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1419 static struct ElementChangeInfo custom_element_change;
1420 static struct ElementGroupInfo group_element_info;
1421 static struct ElementInfo custom_element;
1423 static char levelset_name[MAX_LEVEL_NAME_LEN + 1];
1424 static char levelset_author[MAX_LEVEL_AUTHOR_LEN + 1];
1425 static int levelset_num_levels = 100;
1426 static boolean levelset_use_levelset_artwork = FALSE;
1427 static boolean levelset_copy_level_template = FALSE;
1428 static int levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
1434 int min_value, max_value;
1435 int gadget_id_down, gadget_id_up;
1437 int gadget_id_align;
1439 char *text_above, *text_left, *text_right;
1440 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1442 // ---------- current level number ------------------------------------------
1445 ED_COUNTER_ID_SELECT_LEVEL,
1446 -1, -1, // these values are not constant, but can change at runtime
1448 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1449 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1454 // ---------- level and editor settings -------------------------------------
1457 ED_COUNTER_ID_LEVEL_XSIZE,
1458 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1459 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1460 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1461 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1463 "playfield size:", NULL, "width",
1466 ED_COUNTER_ID_LEVEL_YSIZE,
1467 -1, ED_LEVEL_SETTINGS_YPOS(4),
1468 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1469 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1470 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1472 NULL, " ", "height",
1475 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
1476 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1478 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1479 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1481 NULL, "number of gems to collect:", NULL
1484 ED_COUNTER_ID_LEVEL_TIMELIMIT,
1485 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
1487 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1488 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1490 "time or step limit to solve level:", NULL, NULL
1493 ED_COUNTER_ID_LEVEL_TIMESCORE,
1494 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
1496 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1497 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1498 &level.score[SC_TIME_BONUS],
1499 "score for time or steps left:", NULL, NULL
1502 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
1503 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(13),
1505 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1506 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1508 NULL, "random seed:", "(0 => random)"
1511 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
1512 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1514 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN, GADGET_ID_LEVELSET_NUM_LEVELS_UP,
1515 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT, GADGET_ID_NONE,
1516 &levelset_num_levels,
1517 "number of levels:", NULL, NULL,
1520 ED_COUNTER_ID_LEVEL_RANDOM,
1521 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1523 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1524 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1525 &random_placement_value,
1526 "random element placement:", NULL, "in"
1529 ED_COUNTER_ID_BD_CYCLE_DELAY_MS,
1530 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(3),
1532 GADGET_ID_BD_CYCLE_DELAY_MS_DOWN, GADGET_ID_BD_CYCLE_DELAY_MS_UP,
1533 GADGET_ID_BD_CYCLE_DELAY_MS_TEXT, GADGET_ID_NONE,
1534 &level.bd_cycle_delay_ms,
1535 NULL, NULL, "game cycle delay (ms)"
1538 ED_COUNTER_ID_BD_CYCLE_DELAY_C64,
1539 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(3),
1541 GADGET_ID_BD_CYCLE_DELAY_C64_DOWN, GADGET_ID_BD_CYCLE_DELAY_C64_UP,
1542 GADGET_ID_BD_CYCLE_DELAY_C64_TEXT, GADGET_ID_NONE,
1543 &level.bd_cycle_delay_c64,
1544 NULL, NULL, "game cycle delay (C64-style)"
1547 ED_COUNTER_ID_BD_HATCHING_DELAY_CYCLES,
1548 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1550 GADGET_ID_BD_HATCHING_DELAY_CYCLES_DOWN, GADGET_ID_BD_HATCHING_DELAY_CYCLES_UP,
1551 GADGET_ID_BD_HATCHING_DELAY_CYCLES_TEXT, GADGET_ID_NONE,
1552 &level.bd_hatching_delay_cycles,
1553 NULL, NULL, "hatching delay (cycles)"
1556 ED_COUNTER_ID_BD_HATCHING_DELAY_SECONDS,
1557 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1559 GADGET_ID_BD_HATCHING_DELAY_SECONDS_DOWN, GADGET_ID_BD_HATCHING_DELAY_SECONDS_UP,
1560 GADGET_ID_BD_HATCHING_DELAY_SECONDS_TEXT, GADGET_ID_NONE,
1561 &level.bd_hatching_delay_seconds,
1562 NULL, NULL, "hatching delay (seconds)"
1565 // ---------- element settings: configure (various elements) ----------------
1568 ED_COUNTER_ID_BD_PUSHING_PROB,
1569 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1571 GADGET_ID_BD_PUSHING_PROB_DOWN, GADGET_ID_BD_PUSHING_PROB_UP,
1572 GADGET_ID_BD_PUSHING_PROB_TEXT, GADGET_ID_NONE,
1573 &level.bd_pushing_prob,
1574 NULL, NULL, "push probability"
1577 ED_COUNTER_ID_BD_PUSHING_PROB_WITH_SWEET,
1578 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1580 GADGET_ID_BD_PUSHING_PROB_WITH_SWEET_DOWN, GADGET_ID_BD_PUSHING_PROB_WITH_SWEET_UP,
1581 GADGET_ID_BD_PUSHING_PROB_WITH_SWEET_TEXT, GADGET_ID_NONE,
1582 &level.bd_pushing_prob_with_sweet,
1583 NULL, NULL, "push probability with sweet"
1586 ED_COUNTER_ID_ELEMENT_VALUE1,
1587 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1588 MIN_SCORE, MAX_SCORE,
1589 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1590 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1591 NULL, // will be set when used
1595 ED_COUNTER_ID_ELEMENT_VALUE2,
1596 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1597 MIN_SCORE, MAX_SCORE,
1598 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1599 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1600 NULL, // will be set when used
1604 ED_COUNTER_ID_ELEMENT_VALUE3,
1605 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1606 MIN_SCORE, MAX_SCORE,
1607 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1608 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1609 NULL, // will be set when used
1613 ED_COUNTER_ID_ELEMENT_VALUE4,
1614 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1615 MIN_SCORE, MAX_SCORE,
1616 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1617 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1618 NULL, // will be set when used
1622 ED_COUNTER_ID_YAMYAM_CONTENT,
1623 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1624 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1625 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1626 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1627 &level.num_yamyam_contents,
1628 NULL, NULL, "number of content areas"
1631 ED_COUNTER_ID_BALL_CONTENT,
1632 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1633 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1634 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1635 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1636 &level.num_ball_contents,
1637 NULL, NULL, "number of content areas"
1640 ED_COUNTER_ID_ANDROID_CONTENT,
1641 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1642 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1643 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1644 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1645 &level.num_android_clone_elements,
1646 NULL, NULL, "number of clonable elements"
1649 ED_COUNTER_ID_ENVELOPE_XSIZE,
1650 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1651 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1652 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1653 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1654 NULL, // will be set when used
1655 NULL, NULL, "width",
1658 ED_COUNTER_ID_ENVELOPE_YSIZE,
1659 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1660 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1661 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1662 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1663 NULL, // will be set when used
1664 NULL, " ", "height",
1667 ED_COUNTER_ID_INVENTORY_SIZE,
1668 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1669 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1670 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1671 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1672 &level.initial_inventory_size[0],
1673 NULL, NULL, "number of inventory elements"
1676 ED_COUNTER_ID_MM_BALL_CONTENT,
1677 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1678 MIN_ELEMENTS_IN_GROUP, MAX_MM_BALL_CONTENTS,
1679 GADGET_ID_MM_BALL_CONTENT_DOWN, GADGET_ID_MM_BALL_CONTENT_UP,
1680 GADGET_ID_MM_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1681 &level.num_mm_ball_contents,
1682 NULL, NULL, "number of content elements"
1685 // ---------- element settings: configure 1 (custom elements) ---------------
1688 ED_COUNTER_ID_CUSTOM_SCORE,
1689 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1690 MIN_SCORE, MAX_SCORE,
1691 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1692 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1693 &custom_element.collect_score_initial,
1694 NULL, "CE score", " "
1697 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
1698 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1699 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1700 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1701 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1702 &custom_element.collect_count_initial,
1703 NULL, "CE count", NULL
1706 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
1707 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1709 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1710 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1711 &custom_element.ce_value_fixed_initial,
1712 NULL, "CE value", NULL
1715 ED_COUNTER_ID_CUSTOM_VALUE_RND,
1716 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1718 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1719 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1720 &custom_element.ce_value_random_initial,
1721 NULL, "+random", NULL
1724 ED_COUNTER_ID_PUSH_DELAY_FIX,
1725 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1727 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1728 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1729 &custom_element.push_delay_fixed,
1730 NULL, "push delay", NULL
1733 ED_COUNTER_ID_PUSH_DELAY_RND,
1734 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1736 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1737 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1738 &custom_element.push_delay_random,
1739 NULL, "+random", NULL
1742 ED_COUNTER_ID_DROP_DELAY_FIX,
1743 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1745 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1746 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1747 &custom_element.drop_delay_fixed,
1748 NULL, "drop delay", NULL
1751 ED_COUNTER_ID_DROP_DELAY_RND,
1752 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1754 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1755 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1756 &custom_element.drop_delay_random,
1757 NULL, "+random", NULL
1760 // ---------- element settings: configure 2 (custom elements) ---------------
1763 ED_COUNTER_ID_MOVE_DELAY_FIX,
1764 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1766 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1767 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1768 &custom_element.move_delay_fixed,
1769 NULL, "move delay", NULL
1772 ED_COUNTER_ID_MOVE_DELAY_RND,
1773 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1775 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1776 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1777 &custom_element.move_delay_random,
1778 NULL, "+random", NULL
1781 ED_COUNTER_ID_STEP_DELAY_FIX,
1782 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1784 GADGET_ID_STEP_DELAY_FIX_DOWN, GADGET_ID_STEP_DELAY_FIX_UP,
1785 GADGET_ID_STEP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1786 &custom_element.step_delay_fixed,
1787 NULL, "step delay", NULL
1790 ED_COUNTER_ID_STEP_DELAY_RND,
1791 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1793 GADGET_ID_STEP_DELAY_RND_DOWN, GADGET_ID_STEP_DELAY_RND_UP,
1794 GADGET_ID_STEP_DELAY_RND_TEXT, GADGET_ID_STEP_DELAY_FIX_UP,
1795 &custom_element.step_delay_random,
1796 NULL, "+random", NULL
1799 ED_COUNTER_ID_EXPLOSION_DELAY,
1800 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1802 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1803 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1804 &custom_element.explosion_delay,
1805 NULL, "explosion delay", NULL
1808 ED_COUNTER_ID_IGNITION_DELAY,
1809 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
1811 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1812 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1813 &custom_element.ignition_delay,
1814 NULL, "ignition delay", "(by fire)"
1817 // ---------- element settings: configure (group elements) ------------------
1820 ED_COUNTER_ID_GROUP_CONTENT,
1821 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1822 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1823 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1824 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1825 &group_element_info.num_elements,
1826 NULL, NULL, "number of elements in group"
1829 // ---------- element settings: advanced (custom elements) ------------------
1832 ED_COUNTER_ID_CHANGE_DELAY_FIX,
1833 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1835 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1836 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1837 &custom_element_change.delay_fixed,
1838 NULL, "CE delay", NULL,
1841 ED_COUNTER_ID_CHANGE_DELAY_RND,
1842 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1844 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1845 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1846 &custom_element_change.delay_random,
1847 NULL, "+random", NULL
1850 ED_COUNTER_ID_CHANGE_CONT_RND,
1851 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1853 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1854 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1855 &custom_element_change.random_percentage,
1856 NULL, "use random replace:", "%"
1867 char *text_above, *infotext;
1868 } textinput_info[ED_NUM_TEXTINPUT] =
1871 ED_TEXTINPUT_ID_LEVEL_NAME,
1872 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1873 GADGET_ID_LEVEL_NAME,
1876 "Title:", "Title for this level"
1879 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
1880 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1881 GADGET_ID_LEVEL_AUTHOR,
1882 MAX_LEVEL_AUTHOR_LEN,
1884 "Author:", "Author for this level"
1887 ED_TEXTINPUT_ID_LEVELSET_NAME,
1888 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1889 GADGET_ID_LEVELSET_NAME,
1892 "Title:", "Title for this or new level set"
1895 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
1896 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1897 GADGET_ID_LEVELSET_AUTHOR,
1898 MAX_LEVEL_AUTHOR_LEN,
1900 "Author:", "Author for this or new level set"
1903 ED_TEXTINPUT_ID_ELEMENT_NAME,
1904 -1, -1, // these values are not constant, but can change at runtime
1905 GADGET_ID_ELEMENT_NAME,
1906 MAX_ELEMENT_NAME_LEN - 2, // currently 2 chars less editable
1907 custom_element.description,
1908 NULL, "Element name"
1919 char *text_above, *text_above_cropped, *infotext;
1920 } textarea_info[ED_NUM_TEXTAREAS] =
1923 ED_TEXTAREA_ID_ENVELOPE_INFO,
1924 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1925 GADGET_ID_ENVELOPE_INFO,
1926 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1928 "Envelope Content:", "Envelope Content (cropped):", "Envelope Content"
1932 static struct ValueTextInfo options_time_or_steps[] =
1940 static struct ValueTextInfo options_time_score_base[] =
1942 { 1, "per second/step" },
1943 { 10, "per 10 seconds/steps" },
1948 static struct ValueTextInfo options_game_engine_type[] =
1950 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1951 { GAME_ENGINE_TYPE_BD, "Boulder Dash" },
1952 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1953 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1954 { GAME_ENGINE_TYPE_MM, "Mirror Magic" },
1959 static struct ValueTextInfo options_levelset_save_mode[] =
1961 { LEVELSET_SAVE_MODE_UPDATE, "Update this level set" },
1962 { LEVELSET_SAVE_MODE_CREATE, "Create new level set" },
1967 static struct ValueTextInfo options_wind_direction[] =
1969 { MV_START_NONE, "none" },
1970 { MV_START_LEFT, "left" },
1971 { MV_START_RIGHT, "right" },
1972 { MV_START_UP, "up" },
1973 { MV_START_DOWN, "down" },
1978 static struct ValueTextInfo options_player_speed[] =
1985 { 16, "very fast" },
1986 { 32, "ultrafast" },
1991 static struct ValueTextInfo options_access_type[] =
1993 { EP_WALKABLE, "walkable" },
1994 { EP_PASSABLE, "passable" },
1999 static struct ValueTextInfo options_access_layer[] =
2001 { EP_ACCESSIBLE_OVER, "over" },
2002 { EP_ACCESSIBLE_INSIDE, "inside" },
2003 { EP_ACCESSIBLE_UNDER, "under" },
2008 static struct ValueTextInfo options_access_protected[] =
2010 { 0, "unprotected" },
2016 static struct ValueTextInfo options_access_direction[] =
2018 { MV_NO_DIRECTION, "no direction" },
2019 { MV_LEFT, "left" },
2020 { MV_RIGHT, "right" },
2022 { MV_DOWN, "down" },
2023 { MV_LEFT | MV_UP, "left + up" },
2024 { MV_LEFT | MV_DOWN, "left + down" },
2025 { MV_RIGHT | MV_UP, "right + up" },
2026 { MV_RIGHT | MV_DOWN, "right + down" },
2027 { MV_HORIZONTAL, "horizontal" },
2028 { MV_VERTICAL, "vertical" },
2029 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
2030 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
2031 { MV_VERTICAL | MV_LEFT, "vertical + left" },
2032 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
2033 { MV_ALL_DIRECTIONS, "all directions" },
2038 static struct ValueTextInfo options_walk_to_action[] =
2040 { EP_DIGGABLE, "diggable" },
2041 { EP_COLLECTIBLE_ONLY, "collectible" },
2042 { EP_DROPPABLE, "collectible & droppable" },
2043 { EP_THROWABLE, "collectible & throwable" },
2044 { EP_PUSHABLE, "pushable" },
2049 static struct ValueTextInfo options_move_pattern[] =
2051 { MV_LEFT, "left" },
2052 { MV_RIGHT, "right" },
2054 { MV_DOWN, "down" },
2055 { MV_HORIZONTAL, "horizontal" },
2056 { MV_VERTICAL, "vertical" },
2057 { MV_ALL_DIRECTIONS, "all directions" },
2058 { MV_WIND_DIRECTION, "wind direction" },
2059 { MV_TOWARDS_PLAYER, "towards player" },
2060 { MV_AWAY_FROM_PLAYER, "away from player" },
2061 { MV_ALONG_LEFT_SIDE, "along left side" },
2062 { MV_ALONG_RIGHT_SIDE, "along right side" },
2063 { MV_TURNING_LEFT, "turning left" },
2064 { MV_TURNING_RIGHT, "turning right" },
2065 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
2066 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
2067 { MV_TURNING_RANDOM, "turning random" },
2068 { MV_MAZE_RUNNER, "maze runner style" },
2069 { MV_MAZE_HUNTER, "maze hunter style" },
2070 { MV_WHEN_PUSHED, "when pushed" },
2071 { MV_WHEN_DROPPED, "when dropped/thrown" },
2076 static struct ValueTextInfo options_move_direction[] =
2078 { MV_START_AUTOMATIC, "automatic" },
2079 { MV_START_LEFT, "left" },
2080 { MV_START_RIGHT, "right" },
2081 { MV_START_UP, "up" },
2082 { MV_START_DOWN, "down" },
2083 { MV_START_RANDOM, "random" },
2084 { MV_START_PREVIOUS, "previous" },
2089 static struct ValueTextInfo options_move_stepsize[] =
2091 { 0, "not moving" },
2096 { 16, "very fast" },
2097 { 32, "even faster" },
2102 static struct ValueTextInfo options_move_leave_type[] =
2104 { LEAVE_TYPE_UNLIMITED, "leave behind" },
2105 { LEAVE_TYPE_LIMITED, "change it to" },
2110 static struct ValueTextInfo options_smash_targets[] =
2112 { EP_CAN_SMASH_PLAYER, "player" },
2114 { EP_CAN_SMASH_ENEMIES, "enemies" },
2116 { EP_CAN_SMASH_EVERYTHING, "everything" },
2121 static struct ValueTextInfo options_slippery_type[] =
2123 { SLIPPERY_ANY_RANDOM, "random" },
2124 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
2125 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
2126 { SLIPPERY_ONLY_LEFT, "only left" },
2127 { SLIPPERY_ONLY_RIGHT, "only right" },
2132 static struct ValueTextInfo options_deadliness[] =
2134 { EP_DONT_RUN_INTO, "running into" },
2135 { EP_DONT_COLLIDE_WITH, "colliding with" },
2136 { EP_DONT_GET_HIT_BY, "getting hit by" },
2137 { EP_DONT_TOUCH, "touching" },
2142 static struct ValueTextInfo options_explosion_type[] =
2144 { EXPLODES_3X3, "3x3" },
2145 { EXPLODES_CROSS, "3+3" },
2146 { EXPLODES_1X1, "1x1" },
2151 static struct ValueTextInfo options_time_units[] =
2154 { FRAMES_PER_SECOND, "seconds" },
2159 static struct ValueTextInfo options_change_direct_action[] =
2161 { CE_TOUCHED_BY_PLAYER, "touched by player" },
2162 { CE_PRESSED_BY_PLAYER, "pressed by player" },
2163 { CE_SWITCHED_BY_PLAYER, "switched by player" },
2164 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
2165 { CE_PUSHED_BY_PLAYER, "pushed by player" },
2166 { CE_ENTERED_BY_PLAYER, "entered by player" },
2167 { CE_LEFT_BY_PLAYER, "left by player" },
2168 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
2169 { CE_SWITCHED, "switched" },
2170 { CE_HITTING_SOMETHING, "hitting something" },
2171 { CE_HIT_BY_SOMETHING, "hit by something" },
2173 { CE_BLOCKED, "blocked" },
2175 { CE_IMPACT, "impact (on something)" },
2176 { CE_SMASHED, "smashed (from above)" },
2178 { CE_VALUE_CHANGES, "CE value changes" },
2179 { CE_SCORE_CHANGES, "CE score changes" },
2181 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
2182 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
2183 { CE_UNDEFINED, " " },
2184 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2185 { CE_CLICKED_BY_MOUSE, "clicked by mouse" },
2186 { CE_PRESSED_BY_MOUSE, "pressed by mouse" },
2187 { CE_UNDEFINED, " " },
2188 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2189 { CE_NEXT_TO_PLAYER, "next to player" },
2194 static struct ValueTextInfo options_change_other_action[] =
2196 { CE_PLAYER_TOUCHES_X, "player touches" },
2197 { CE_PLAYER_PRESSES_X, "player presses" },
2198 { CE_PLAYER_SWITCHES_X, "player switches" },
2199 { CE_PLAYER_SNAPS_X, "player snaps" },
2200 { CE_PLAYER_PUSHES_X, "player pushes" },
2201 { CE_PLAYER_ENTERS_X, "player enters" },
2202 { CE_PLAYER_LEAVES_X, "player leaves" },
2203 { CE_PLAYER_DIGS_X, "player digs" },
2204 { CE_PLAYER_COLLECTS_X, "player collects" },
2205 { CE_PLAYER_DROPS_X, "player drops/throws" },
2206 { CE_TOUCHING_X, "touching" },
2207 { CE_HITTING_X, "hitting" },
2208 { CE_DIGGING_X, "digging" },
2209 { CE_HIT_BY_X, "hit by" },
2210 { CE_SWITCH_OF_X, "switch of" },
2211 { CE_CHANGE_OF_X, "change by page of" },
2212 { CE_EXPLOSION_OF_X, "explosion of" },
2213 { CE_MOVE_OF_X, "move of" },
2214 { CE_CREATION_OF_X, "creation of" },
2215 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
2216 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
2217 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
2218 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
2219 { CE_UNDEFINED, " " },
2220 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2221 { CE_MOUSE_CLICKED_ON_X, "mouse clicked on" },
2222 { CE_MOUSE_PRESSED_ON_X, "mouse pressed on" },
2223 { CE_UNDEFINED, " " },
2224 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2225 { CE_PLAYER_NEXT_TO_X, "player next to" },
2226 { CE_NEXT_TO_X, "next to" },
2231 static struct ValueTextInfo options_change_trigger_side[] =
2233 { CH_SIDE_LEFT, "left" },
2234 { CH_SIDE_RIGHT, "right" },
2235 { CH_SIDE_TOP, "top" },
2236 { CH_SIDE_BOTTOM, "bottom" },
2237 { CH_SIDE_LEFT_RIGHT, "left/right" },
2238 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
2239 { CH_SIDE_ANY, "any" },
2244 static struct ValueTextInfo options_change_trigger_player[] =
2246 { CH_PLAYER_1, "1" },
2247 { CH_PLAYER_2, "2" },
2248 { CH_PLAYER_3, "3" },
2249 { CH_PLAYER_4, "4" },
2250 { CH_PLAYER_ANY, "any" },
2255 static struct ValueTextInfo options_change_trigger_page[] =
2266 { (1u << 9), "10" },
2267 { (1u << 10), "11" },
2268 { (1u << 11), "12" },
2269 { (1u << 12), "13" },
2270 { (1u << 13), "14" },
2271 { (1u << 14), "15" },
2272 { (1u << 15), "16" },
2273 { (1u << 16), "17" },
2274 { (1u << 17), "18" },
2275 { (1u << 18), "19" },
2276 { (1u << 19), "20" },
2277 { (1u << 20), "21" },
2278 { (1u << 21), "22" },
2279 { (1u << 22), "23" },
2280 { (1u << 23), "24" },
2281 { (1u << 24), "25" },
2282 { (1u << 25), "26" },
2283 { (1u << 26), "27" },
2284 { (1u << 27), "28" },
2285 { (1u << 28), "29" },
2286 { (1u << 29), "30" },
2287 { (1u << 30), "31" },
2288 { (1u << 31), "32" },
2289 { CH_PAGE_ANY, "any" },
2294 static struct ValueTextInfo options_change_replace_when[] =
2296 { CP_WHEN_EMPTY, "empty" },
2297 { CP_WHEN_WALKABLE, "walkable" },
2298 { CP_WHEN_DIGGABLE, "diggable" },
2299 { CP_WHEN_COLLECTIBLE, "collectible" },
2300 { CP_WHEN_REMOVABLE, "removable" },
2301 { CP_WHEN_DESTRUCTIBLE, "destructible" },
2306 static struct ValueTextInfo options_action_type[] =
2308 { CA_NO_ACTION, "no action" },
2309 { CA_UNDEFINED, " " },
2310 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
2311 { CA_RESTART_LEVEL, "restart level" },
2312 { CA_SHOW_ENVELOPE, "show envelope" },
2313 { CA_SET_LEVEL_TIME, "set time" },
2314 { CA_SET_LEVEL_SCORE, "set score" },
2315 { CA_SET_LEVEL_GEMS, "set gems" },
2316 { CA_SET_LEVEL_WIND, "set wind dir." },
2317 { CA_SET_LEVEL_RANDOM_SEED, "set random seed" },
2318 { CA_UNDEFINED, " " },
2319 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
2320 { CA_MOVE_PLAYER, "move player" },
2321 { CA_MOVE_PLAYER_NEW, "move player new" },
2322 { CA_EXIT_PLAYER, "exit player" },
2323 { CA_KILL_PLAYER, "kill player" },
2324 { CA_SET_PLAYER_KEYS, "set keys" },
2325 { CA_SET_PLAYER_SPEED, "set speed" },
2326 { CA_SET_PLAYER_SHIELD, "set shield" },
2327 { CA_SET_PLAYER_GRAVITY, "set gravity" },
2328 { CA_SET_PLAYER_ARTWORK, "set artwork" },
2329 { CA_SET_PLAYER_INVENTORY, "set inventory" },
2330 { CA_UNDEFINED, " " },
2331 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
2332 { CA_SET_CE_VALUE, "set CE value" },
2333 { CA_SET_CE_SCORE, "set CE score" },
2334 { CA_SET_CE_ARTWORK, "set CE artwork" },
2335 { CA_UNDEFINED, " " },
2336 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
2337 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
2342 static struct ValueTextInfo options_action_mode_none[] =
2344 { CA_MODE_UNDEFINED, " " },
2349 static struct ValueTextInfo options_action_mode_assign[] =
2351 { CA_MODE_SET, "=" },
2356 static struct ValueTextInfo options_action_mode_add_remove[] =
2358 { CA_MODE_ADD, "+" },
2359 { CA_MODE_SUBTRACT, "-" },
2364 static struct ValueTextInfo options_action_mode_calculate[] =
2366 { CA_MODE_SET, "=" },
2367 { CA_MODE_ADD, "+" },
2368 { CA_MODE_SUBTRACT, "-" },
2369 { CA_MODE_MULTIPLY, "*" },
2370 { CA_MODE_DIVIDE, "/" },
2371 { CA_MODE_MODULO, "%" },
2376 static struct ValueTextInfo options_action_arg_none[] =
2378 { CA_ARG_UNDEFINED, " " },
2383 static struct ValueTextInfo options_action_arg_player[] =
2385 { CA_ARG_PLAYER_HEADLINE, "[player]" },
2386 { CA_ARG_PLAYER_1, "1" },
2387 { CA_ARG_PLAYER_2, "2" },
2388 { CA_ARG_PLAYER_3, "3" },
2389 { CA_ARG_PLAYER_4, "4" },
2390 { CA_ARG_PLAYER_ANY, "any" },
2391 { CA_ARG_PLAYER_TRIGGER, "trigger" },
2392 { CA_ARG_PLAYER_ACTION, "action ->" },
2397 static struct ValueTextInfo options_action_arg_number[] =
2399 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2406 { CA_ARG_10, "10" },
2407 { CA_ARG_100, "100" },
2408 { CA_ARG_1000, "1000" },
2409 { CA_ARG_UNDEFINED, " " },
2410 { CA_ARG_NUMBER_MIN, "min" },
2411 { CA_ARG_NUMBER_MAX, "max" },
2412 { CA_ARG_UNDEFINED, " " },
2413 { CA_ARG_NUMBER_RESET, "reset" },
2414 { CA_ARG_UNDEFINED, " " },
2415 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2416 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2417 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2418 { CA_ARG_UNDEFINED, " " },
2419 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2420 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2421 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2422 { CA_ARG_UNDEFINED, " " },
2423 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2424 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2425 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2426 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2427 { CA_ARG_UNDEFINED, " " },
2428 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2429 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2430 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2431 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2436 static struct ValueTextInfo options_action_arg_value[] =
2438 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2445 { CA_ARG_10, "10" },
2446 { CA_ARG_100, "100" },
2447 { CA_ARG_1000, "1000" },
2448 { CA_ARG_UNDEFINED, " " },
2449 { CA_ARG_NUMBER_MIN, "min" },
2450 { CA_ARG_NUMBER_MAX, "max" },
2451 { CA_ARG_UNDEFINED, " " },
2452 { CA_ARG_NUMBER_RESET, "reset" },
2453 { CA_ARG_UNDEFINED, " " },
2454 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2455 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2456 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2457 { CA_ARG_UNDEFINED, " " },
2458 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2459 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2460 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2461 { CA_ARG_UNDEFINED, " " },
2462 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2463 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2464 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2465 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2466 { CA_ARG_UNDEFINED, " " },
2467 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2468 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2469 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2470 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2471 { CA_ARG_UNDEFINED, " " },
2472 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
2473 { CA_ARG_ELEMENT_NR_TARGET, "target" },
2474 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
2475 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
2480 static struct ValueTextInfo options_action_arg_envelope[] =
2482 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2487 { CA_ARG_UNDEFINED, " " },
2488 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2489 { CA_ARG_ELEMENT_TARGET, "target" },
2490 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2491 { CA_ARG_ELEMENT_ACTION, "action ->" },
2496 static struct ValueTextInfo options_action_arg_key[] =
2498 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2507 { CA_ARG_UNDEFINED, " " },
2508 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2509 { CA_ARG_ELEMENT_TARGET, "target" },
2510 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2511 { CA_ARG_ELEMENT_ACTION, "action ->" },
2516 static struct ValueTextInfo options_action_arg_speed[] =
2518 { CA_ARG_SPEED_HEADLINE, "[speed]" },
2519 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
2520 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
2521 { CA_ARG_SPEED_SLOW, "slow" },
2522 { CA_ARG_SPEED_NORMAL, "normal" },
2523 { CA_ARG_SPEED_FAST, "fast" },
2524 { CA_ARG_SPEED_VERY_FAST, "very fast" },
2525 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
2526 { CA_ARG_UNDEFINED, " " },
2527 { CA_ARG_SPEED_SLOWER, "slower" },
2528 { CA_ARG_SPEED_FASTER, "faster" },
2529 { CA_ARG_UNDEFINED, " " },
2530 { CA_ARG_SPEED_RESET, "reset" },
2535 static struct ValueTextInfo options_action_arg_shield[] =
2537 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
2538 { CA_ARG_SHIELD_OFF, "off" },
2539 { CA_ARG_SHIELD_NORMAL, "normal" },
2540 { CA_ARG_SHIELD_DEADLY, "deadly" },
2545 static struct ValueTextInfo options_action_arg_artwork[] =
2547 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2548 { CA_ARG_ELEMENT_TARGET, "target" },
2549 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2550 { CA_ARG_ELEMENT_ACTION, "action ->" },
2551 { CA_ARG_UNDEFINED, " " },
2552 { CA_ARG_ELEMENT_RESET, "reset" },
2557 static struct ValueTextInfo options_action_arg_gravity[] =
2559 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
2560 { CA_ARG_GRAVITY_ON, "on" },
2561 { CA_ARG_GRAVITY_OFF, "off" },
2562 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2567 static struct ValueTextInfo options_action_arg_direction[] =
2569 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2570 { CA_ARG_DIRECTION_NONE, "none" },
2571 { CA_ARG_DIRECTION_LEFT, "left" },
2572 { CA_ARG_DIRECTION_RIGHT, "right" },
2573 { CA_ARG_DIRECTION_UP, "up" },
2574 { CA_ARG_DIRECTION_DOWN, "down" },
2575 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2576 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2581 static struct ValueTextInfo options_action_arg_scan_mode[] =
2583 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2584 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2585 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2590 static struct ValueTextInfo options_action_arg_inventory[] =
2592 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2593 { CA_ARG_ELEMENT_TARGET, "+ target" },
2594 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2595 { CA_ARG_ELEMENT_ACTION, "+ action" },
2596 { CA_ARG_UNDEFINED, " " },
2597 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2598 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2599 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2600 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2601 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2602 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2603 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2604 { CA_ARG_UNDEFINED, " " },
2605 { CA_ARG_INVENTORY_RESET, "reset" },
2610 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2611 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2616 static struct ValueTextInfo options_group_choice_mode[] =
2618 { ANIM_RANDOM, "random" },
2619 { ANIM_LOOP, "loop" },
2620 { ANIM_LINEAR, "linear" },
2621 { ANIM_PINGPONG, "pingpong" },
2622 { ANIM_PINGPONG2, "pingpong 2" },
2623 { ANIM_LEVEL_NR, "level number" },
2628 static struct ValueTextInfo options_bd_scheduling_type[] =
2630 { GD_SCHEDULING_MILLISECONDS, "Milliseconds" },
2631 { GD_SCHEDULING_BD1, "BD1" },
2632 { GD_SCHEDULING_BD2, "BD2" },
2633 { GD_SCHEDULING_PLCK, "Construction Kit" },
2634 { GD_SCHEDULING_CRDR, "Crazy Dream 7" },
2635 { GD_SCHEDULING_BD1_ATARI, "Atari BD1" },
2636 { GD_SCHEDULING_BD2_PLCK_ATARI, "Atari BD2 / PLCK" },
2641 static struct ValueTextInfo *action_arg_modes[] =
2643 options_action_mode_none,
2644 options_action_mode_assign,
2645 options_action_mode_add_remove,
2646 options_action_mode_calculate,
2653 struct ValueTextInfo *options;
2655 action_arg_options[] =
2657 { CA_NO_ACTION, 0, options_action_arg_none, },
2658 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2659 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2660 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2661 { CA_MOVE_PLAYER_NEW, 0, options_action_arg_direction, },
2662 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2663 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2664 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2665 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2666 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2667 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2668 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2669 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2670 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2671 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2672 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2673 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2674 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2675 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2676 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2677 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2678 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2688 int gadget_id_align;
2689 int size; // char size of selectbox or '-1' (dynamically determined)
2690 struct ValueTextInfo *options;
2692 char *text_above, *text_left, *text_right, *infotext;
2693 } selectbox_info[ED_NUM_SELECTBOX] =
2695 // ---------- level and editor settings -------------------------------------
2698 ED_SELECTBOX_ID_TIME_OR_STEPS,
2699 -1, ED_LEVEL_SETTINGS_YPOS(8),
2700 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2702 options_time_or_steps,
2703 &level.use_step_counter,
2704 NULL, NULL, "(0 => no limit)", "time or step limit"
2707 ED_SELECTBOX_ID_TIME_SCORE_BASE,
2708 -1, ED_LEVEL_SETTINGS_YPOS(10),
2709 GADGET_ID_TIME_SCORE_BASE, GADGET_ID_LEVEL_TIMESCORE_UP,
2711 options_time_score_base,
2712 &level.time_score_base,
2713 NULL, NULL, NULL, "time score for 1 or 10 seconds/steps"
2716 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
2717 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
2718 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2720 options_game_engine_type,
2721 &level.game_engine_type,
2722 NULL, "game engine:", NULL, "game engine"
2725 ED_SELECTBOX_ID_BD_SCHEDULING_TYPE,
2726 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
2727 GADGET_ID_BD_SCHEDULING_TYPE, GADGET_ID_NONE,
2729 options_bd_scheduling_type,
2730 &level.bd_scheduling_type,
2731 NULL, "scheduling type:", NULL, "level timing"
2734 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
2735 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2736 GADGET_ID_LEVELSET_SAVE_MODE, GADGET_ID_NONE,
2738 options_levelset_save_mode,
2739 &levelset_save_mode,
2740 "Action:", NULL, NULL, "action when saving level set"
2743 // ---------- element settings: configure (several elements) ----------------
2746 ED_SELECTBOX_ID_WIND_DIRECTION,
2747 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2748 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2750 options_wind_direction,
2751 &level.wind_direction_initial,
2752 NULL, "initial wind direction:", NULL, "initial wind direction"
2755 ED_SELECTBOX_ID_PLAYER_SPEED,
2756 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2757 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2759 options_player_speed,
2760 &level.initial_player_stepsize[0],
2761 NULL, "initial player speed:", NULL, "initial player speed"
2764 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
2765 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2766 GADGET_ID_MM_BALL_CHOICE_MODE, GADGET_ID_NONE,
2768 options_group_choice_mode,
2769 &level.mm_ball_choice_mode,
2770 NULL, "choice type:", NULL, "type of content choice"
2773 // ---------- element settings: configure 1 (custom elements) ---------------
2776 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
2777 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2778 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2780 options_access_type,
2781 &custom_element.access_type,
2782 NULL, NULL, NULL, "type of access to this field"
2785 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
2786 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2787 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2789 options_access_layer,
2790 &custom_element.access_layer,
2791 NULL, NULL, NULL, "layer of access for this field"
2794 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
2795 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2796 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2798 options_access_protected,
2799 &custom_element.access_protected,
2800 NULL, NULL, NULL, "protected access for this field"
2803 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
2804 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2805 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2807 options_access_direction,
2808 &custom_element.access_direction,
2809 NULL, "from", NULL, "access direction for this field"
2812 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
2813 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2814 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2816 options_walk_to_action,
2817 &custom_element.walk_to_action,
2818 NULL, NULL, NULL, "diggable/collectible/pushable"
2821 // ---------- element settings: configure 2 (custom elements) ---------------
2824 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
2825 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2826 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2828 options_move_pattern,
2829 &custom_element.move_pattern,
2830 NULL, "can move", NULL, "element move pattern"
2833 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
2834 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2835 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2837 options_move_direction,
2838 &custom_element.move_direction_initial,
2839 NULL, "starts moving", NULL, "initial element move direction"
2842 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
2843 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2844 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2846 options_move_stepsize,
2847 &custom_element.move_stepsize,
2848 NULL, "move/fall speed", NULL, "speed of element movement"
2851 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
2852 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2853 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2855 options_move_leave_type,
2856 &custom_element.move_leave_type,
2857 // left text with leading spaces to place gadget next to "can dig" gadget
2858 // (needed because drawing area gadgets created after selectbox gadgets)
2859 // NULL, "can dig: can", ":", "leave behind or change element"
2860 NULL, " can", ":", "leave behind or change element"
2863 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
2864 -1, ED_ELEMENT_SETTINGS_YPOS(8),
2865 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2867 options_smash_targets,
2868 &custom_element.smash_targets,
2869 NULL, "can smash", NULL, "elements that can be smashed"
2872 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
2873 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2874 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2876 options_slippery_type,
2877 &custom_element.slippery_type,
2878 NULL, "slippery", NULL, "where other elements fall down"
2881 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
2882 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2883 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2886 &custom_element.deadliness,
2887 NULL, "deadly when", NULL, "deadliness of element"
2890 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
2891 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
2892 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2894 options_explosion_type,
2895 &custom_element.explosion_type,
2896 NULL, "can explode", NULL, "explosion type"
2899 // ---------- element settings: advanced (custom elements) ------------------
2902 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
2903 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2904 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2907 &custom_element_change.delay_frames,
2908 NULL, "delay time given in", NULL, "delay time units for change"
2911 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
2912 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2913 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2915 options_change_direct_action,
2916 &custom_element_change.direct_action,
2917 NULL, NULL, NULL, "type of direct action"
2920 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
2921 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2922 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2924 options_change_other_action,
2925 &custom_element_change.other_action,
2926 NULL, NULL, "element:", "type of other element action"
2929 ED_SELECTBOX_ID_CHANGE_SIDE,
2930 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2931 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2933 options_change_trigger_side,
2934 &custom_element_change.trigger_side,
2935 NULL, "at", "side", "element side triggering change"
2938 ED_SELECTBOX_ID_CHANGE_PLAYER,
2939 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2940 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2942 options_change_trigger_player,
2943 &custom_element_change.trigger_player,
2944 NULL, "player:", " ", "player that causes change"
2947 ED_SELECTBOX_ID_CHANGE_PAGE,
2948 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2949 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2951 options_change_trigger_page,
2952 &custom_element_change.trigger_page,
2953 NULL, "page:", NULL, "change page that causes change"
2956 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
2957 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2958 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2960 options_change_replace_when,
2961 &custom_element_change.replace_when,
2962 NULL, "replace when", NULL, "which elements can be replaced"
2965 ED_SELECTBOX_ID_ACTION_TYPE,
2966 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2967 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2969 options_action_type,
2970 &custom_element_change.action_type,
2971 NULL, NULL, NULL, "action on specified condition"
2974 ED_SELECTBOX_ID_ACTION_MODE,
2975 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2976 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2978 options_action_mode_none,
2979 &custom_element_change.action_mode,
2980 NULL, NULL, NULL, "action operator"
2983 ED_SELECTBOX_ID_ACTION_ARG,
2984 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2985 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2987 options_action_arg_none,
2988 &custom_element_change.action_arg,
2989 NULL, NULL, NULL, "action parameter"
2992 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
2993 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2994 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2996 options_change_page,
2997 &custom_element.current_change_page,
2998 NULL, NULL, NULL, "element change page"
3001 // ---------- element settings: configure (group elements) ------------------
3004 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
3005 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3006 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
3008 options_group_choice_mode,
3009 &group_element_info.choice_mode,
3010 NULL, "choice type:", NULL, "type of group element choice"
3019 int gadget_id_align;
3022 char *text_above, *text_left, *text_right, *infotext;
3023 } textbutton_info[ED_NUM_TEXTBUTTONS] =
3025 // ---------- level and editor settings (tabs) ------------------------------
3028 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL,
3029 ED_LEVEL_TABS_XPOS(0), ED_LEVEL_TABS_YPOS(0),
3030 GADGET_ID_LEVELCONFIG_LEVEL, GADGET_ID_NONE,
3032 NULL, NULL, NULL, "Configure level settings"
3035 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET,
3037 GADGET_ID_LEVELCONFIG_LEVELSET, GADGET_ID_LEVELCONFIG_LEVEL,
3039 NULL, NULL, NULL, "Update this or create new level set"
3042 ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR,
3044 GADGET_ID_LEVELCONFIG_EDITOR, GADGET_ID_LEVELCONFIG_LEVELSET,
3046 NULL, NULL, NULL, "Configure editor settings"
3049 ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE,
3051 GADGET_ID_LEVELCONFIG_ENGINE, GADGET_ID_LEVELCONFIG_EDITOR,
3053 NULL, NULL, NULL, "Configure engine settings"
3056 // ---------- element settings (tabs) ---------------------------------------
3059 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
3060 ED_ELEMENT_TABS_XPOS(0), ED_ELEMENT_TABS_YPOS(0),
3061 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
3063 NULL, NULL, NULL, "Show information about element"
3066 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
3068 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_PROPERTIES_INFO,
3070 NULL, NULL, NULL, "Configure element properties"
3073 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
3075 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_PROPERTIES_INFO,
3077 NULL, NULL, NULL, "Configure element properties, part 1"
3080 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
3082 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_PROPERTIES_CONFIG_1,
3084 NULL, NULL, NULL, "Configure element properties, part 2"
3087 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
3089 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_PROPERTIES_CONFIG_2,
3091 NULL, NULL, NULL, "Configure custom element change pages"
3094 // ---------- level and editor settings (buttons) ---------------------------
3097 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
3098 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
3099 GADGET_ID_SAVE_LEVELSET, GADGET_ID_LEVELSET_SAVE_MODE,
3101 NULL, NULL, NULL, "Update or create level set"
3104 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
3105 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3106 GADGET_ID_SAVE_AS_TEMPLATE_2, GADGET_ID_NONE,
3108 NULL, NULL, "this level as level template",
3109 "Save current settings as new template"
3112 // ---------- element settings (buttons) ------------------------------------
3115 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
3117 GADGET_ID_SAVE_AS_TEMPLATE_1, GADGET_ID_CUSTOM_USE_TEMPLATE_1,
3119 NULL, " ", "As Template",
3120 "Save current settings as new template"
3123 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
3125 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
3127 NULL, NULL, NULL, "Add new change page"
3130 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
3132 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
3134 NULL, NULL, NULL, "Delete current change page"
3144 int gadget_id_align;
3145 char *text_left, *text_right, *infotext;
3146 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
3149 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
3150 IMG_EDITOR_COUNTER_DOWN,
3151 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3152 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
3153 NULL, NULL, "select previous change page"
3156 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
3157 IMG_EDITOR_COUNTER_UP,
3158 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3159 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
3160 NULL, "change page", "select next change page"
3163 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
3164 IMG_GFX_EDITOR_BUTTON_CP_COPY,
3165 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3166 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
3167 " ", NULL, "copy settings from this change page"
3170 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
3171 IMG_GFX_EDITOR_BUTTON_CP_PASTE,
3172 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3173 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
3174 NULL, NULL, "paste settings to this change page"
3181 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
3189 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
3192 ED_SCROLLBUTTON_ID_AREA_UP,
3193 IMG_EDITOR_PLAYFIELD_SCROLL_UP,
3194 GADGET_ID_SCROLL_UP,
3195 "scroll level editing area up"
3198 ED_SCROLLBUTTON_ID_AREA_DOWN,
3199 IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
3200 GADGET_ID_SCROLL_DOWN,
3201 "scroll level editing area down"
3204 ED_SCROLLBUTTON_ID_AREA_LEFT,
3205 IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
3206 GADGET_ID_SCROLL_LEFT,
3207 "scroll level editing area left"
3210 ED_SCROLLBUTTON_ID_AREA_RIGHT,
3211 IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
3212 GADGET_ID_SCROLL_RIGHT,
3213 "scroll level editing area right"
3216 ED_SCROLLBUTTON_ID_LIST_UP,
3217 IMG_EDITOR_PALETTE_SCROLL_UP,
3218 GADGET_ID_SCROLL_LIST_UP,
3219 "scroll element list up ('Page Up')"
3222 ED_SCROLLBUTTON_ID_LIST_DOWN,
3223 IMG_EDITOR_PALETTE_SCROLL_DOWN,
3224 GADGET_ID_SCROLL_LIST_DOWN,
3225 "scroll element list down ('Page Down')"
3233 int wheel_x, wheel_y;
3234 int wheel_width, wheel_height;
3235 } scrollbar_pos[ED_NUM_SCROLLBARS];
3244 } scrollbar_info[ED_NUM_SCROLLBARS] =
3247 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
3248 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3249 GD_TYPE_SCROLLBAR_HORIZONTAL,
3250 GADGET_ID_SCROLL_HORIZONTAL,
3251 "scroll level editing area horizontally"
3254 ED_SCROLLBAR_ID_AREA_VERTICAL,
3255 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3256 GD_TYPE_SCROLLBAR_VERTICAL,
3257 GADGET_ID_SCROLL_VERTICAL,
3258 "scroll level editing area vertically"
3261 ED_SCROLLBAR_ID_LIST_VERTICAL,
3262 IMG_EDITOR_PALETTE_SCROLLBAR,
3263 GD_TYPE_SCROLLBAR_VERTICAL,
3264 GADGET_ID_SCROLL_LIST_VERTICAL,
3265 "scroll element list vertically"
3275 int gadget_id_align;
3276 int radio_button_nr;
3279 char *text_left, *text_right, *infotext;
3280 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
3283 ED_RADIOBUTTON_ID_PERCENTAGE,
3284 -1, ED_LEVEL_SETTINGS_YPOS(0),
3285 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
3286 RADIO_NR_RANDOM_ELEMENTS,
3287 &random_placement_method, RANDOM_USE_PERCENTAGE,
3288 " ", "percentage", "use percentage for random elements"
3291 ED_RADIOBUTTON_ID_QUANTITY,
3292 -1, ED_LEVEL_SETTINGS_YPOS(0),
3293 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
3294 RADIO_NR_RANDOM_ELEMENTS,
3295 &random_placement_method, RANDOM_USE_QUANTITY,
3296 " ", "quantity", "use quantity for random elements"
3305 int gadget_id_align;
3307 char *text_above, *text_left, *text_right, *infotext;
3308 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
3310 // ---------- level and editor settings -------------------------------------
3313 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
3314 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3315 GADGET_ID_AUTO_COUNT_GEMS, GADGET_ID_NONE,
3316 &level.auto_count_gems,
3318 "automatically count gems needed", "set counter to number of gems"
3321 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
3322 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
3323 GADGET_ID_RATE_TIME_OVER_SCORE, GADGET_ID_NONE,
3324 &level.rate_time_over_score,
3326 "rate time/steps used over score", "sort high scores by playing time/steps"
3329 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
3330 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
3331 GADGET_ID_USE_LEVELSET_ARTWORK, GADGET_ID_NONE,
3332 &levelset_use_levelset_artwork,
3334 "use current custom artwork", "use custom artwork of this level set"
3337 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
3338 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
3339 GADGET_ID_COPY_LEVEL_TEMPLATE, GADGET_ID_NONE,
3340 &levelset_copy_level_template,
3342 "copy current level template", "copy level template of this level set"
3345 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
3346 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
3347 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
3348 &random_placement_background_restricted,
3350 "restrict random placement to:", "set random placement restriction"
3353 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
3354 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
3355 GADGET_ID_CUSTOM_USE_TEMPLATE_3, GADGET_ID_NONE,
3356 &setup.editor.use_template_for_new_levels,
3357 "Template for new levels and CE/GE:", NULL,
3358 "use template for new levels", "use template for level properties"
3361 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
3362 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
3363 GADGET_ID_CUSTOM_USE_TEMPLATE_2, GADGET_ID_NONE,
3364 &level.use_custom_template,
3366 "use template for custom elements", "use template for custom properties"
3369 ED_CHECKBUTTON_ID_BD_INTERMISSION,
3370 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
3371 GADGET_ID_BD_INTERMISSION, GADGET_ID_NONE,
3372 &level.bd_intermission,
3373 "Boulder Dash game engine settings:", NULL,
3374 "intermission", "level is an intermission level"
3377 ED_CHECKBUTTON_ID_BD_PAL_TIMING,
3378 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
3379 GADGET_ID_BD_PAL_TIMING, GADGET_ID_NONE,
3380 &level.bd_pal_timing,
3382 "PAL timing", "use slower timer (like PAL C64)"
3385 ED_CHECKBUTTON_ID_BD_LINE_SHIFTING_BORDERS,
3386 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3387 GADGET_ID_BD_LINE_SHIFTING_BORDERS, GADGET_ID_NONE,
3388 &level.bd_line_shifting_borders,
3389 "Compatibility settings:", NULL,
3390 "line-shifting borders", "use line-shifting wrap-around"
3393 ED_CHECKBUTTON_ID_BD_SCAN_FIRST_AND_LAST_ROW,
3394 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
3395 GADGET_ID_BD_SCAN_FIRST_AND_LAST_ROW, GADGET_ID_NONE,
3396 &level.bd_scan_first_and_last_row,
3398 "scan first and last row", "also process top/bottom border rows"
3401 ED_CHECKBUTTON_ID_BD_SHORT_EXPLOSIONS,
3402 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
3403 GADGET_ID_BD_SHORT_EXPLOSIONS, GADGET_ID_NONE,
3404 &level.bd_short_explosions,
3406 "short explosions", "use four game cycles for explosions"
3409 ED_CHECKBUTTON_ID_BD_GRAVITY_AFFECTS_ALL,
3410 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(9),
3411 GADGET_ID_BD_GRAVITY_AFFECTS_ALL, GADGET_ID_NONE,
3412 &level.bd_gravity_affects_all,
3414 "gravity change affects everything", "gravity affects all falling objects"
3417 // ---------- element settings: configure (various elements) ----------------
3420 ED_CHECKBUTTON_ID_STICK_ELEMENT,
3421 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3422 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
3423 &stick_element_properties_window,
3425 "stick this screen to edit content","stick this screen to edit content"
3428 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
3429 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3430 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
3431 &level.em_slippery_gems,
3433 "slip down from certain flat walls","use EM/DC style slipping behaviour"
3436 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
3437 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3438 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
3439 &level.em_explodes_by_fire,
3441 "explodes with chain reaction", "use R'n'D style explosion behaviour"
3444 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
3445 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3446 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
3447 &level.use_spring_bug,
3449 "use spring pushing bug", "use odd spring pushing behaviour"
3452 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
3453 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3454 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
3455 &level.use_time_orb_bug,
3457 "use time orb bug", "use odd time orb behaviour"
3460 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
3461 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3462 GADGET_ID_USE_LIFE_BUGS, GADGET_ID_NONE,
3463 &level.use_life_bugs,
3465 "use buggy element behaviour", "use odd (historic) element behaviour"
3468 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
3469 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3470 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
3473 "create single random element", "only create one element from content"
3476 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
3477 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3478 GADGET_ID_INITIAL_BALL_ACTIVE, GADGET_ID_NONE,
3479 &level.ball_active_initial,
3481 "magic ball initially activated", "activate magic ball after level start"
3484 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
3485 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3486 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
3487 &level.grow_into_diggable,
3489 "can grow into anything diggable", "grow into more than just sand"
3492 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
3493 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3494 GADGET_ID_SB_FIELDS_NEEDED, GADGET_ID_NONE,
3495 &level.sb_fields_needed,
3497 "all fields need to be filled", "require all SB fields to be solved"
3500 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
3501 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3502 GADGET_ID_SB_OBJECTS_NEEDED, GADGET_ID_NONE,
3503 &level.sb_objects_needed,
3505 "all objects need to be placed", "require all SB objects to be solved"
3508 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
3509 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3510 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
3511 &level.auto_exit_sokoban,
3513 "exit level if all tasks solved", "automatically finish Sokoban levels"
3516 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
3517 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3518 GADGET_ID_SOLVED_BY_ONE_PLAYER, GADGET_ID_NONE,
3519 &level.solved_by_one_player,
3521 "only one player must enter exit", "level solved by first player in exit"
3524 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
3525 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3526 GADGET_ID_FINISH_DIG_COLLECT, GADGET_ID_NONE,
3527 &level.finish_dig_collect,
3529 "CE action on finished dig/collect", "only finished dig/collect triggers CE"
3532 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
3533 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3534 GADGET_ID_KEEP_WALKABLE_CE, GADGET_ID_NONE,
3535 &level.keep_walkable_ce,
3537 "keep walkable CE changed to player", "keep CE changing to player if walkable"
3540 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
3541 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3542 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
3543 &level.continuous_snapping,
3545 "continuous snapping", "use snapping without releasing key"
3548 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
3549 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3550 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
3551 &level.block_snap_field,
3553 "block snapped field when snapping", "use snapping delay to show animation"
3556 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
3557 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3558 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3559 &level.block_last_field,
3561 "block last field when moving", "player blocks last field when moving"
3564 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
3565 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3566 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3567 &level.sp_block_last_field,
3569 "block last field when moving", "player blocks last field when moving"
3572 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
3573 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3574 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
3575 &level.instant_relocation,
3577 "no scrolling when relocating", "player gets relocated without delay"
3580 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
3581 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3582 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
3583 &level.shifted_relocation,
3585 "no centering when relocating", "level not centered after relocation"
3588 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
3589 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3590 GADGET_ID_LAZY_RELOCATION, GADGET_ID_NONE,
3591 &level.lazy_relocation,
3593 "only redraw off-screen relocation","no redraw if relocation target visible"
3596 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
3597 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3598 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
3599 &level.use_start_element[0],
3601 "use level start element:", "start level at this element's position"
3604 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
3605 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3606 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
3607 &level.use_artwork_element[0],
3609 "use artwork from element:", "use player artwork from other element"
3612 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
3613 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
3614 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
3615 &level.use_explosion_element[0],
3617 "use explosion from element:", "use explosion properties from element"
3620 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
3621 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3622 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
3623 &level.initial_player_gravity[0],
3625 "use initial gravity", "set initial player gravity"
3628 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
3629 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3630 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
3631 &level.use_initial_inventory[0],
3633 "use initial inventory:", "use collected elements on level start"
3636 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
3637 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3638 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
3639 &level.can_pass_to_walkable,
3641 "can pass to walkable element", "player can pass to empty or walkable"
3644 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
3645 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3646 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
3647 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3649 "can fall into acid (with gravity)","player can fall into acid pool"
3652 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
3653 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3654 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
3655 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3657 "can move into acid", "element can move into acid pool"
3660 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
3661 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3662 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
3663 &custom_element_properties[EP_DONT_COLLIDE_WITH],
3665 "deadly when colliding with", "element is deadly when hitting player"
3668 ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS,
3669 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3670 GADGET_ID_BD_DIAGONAL_MOVEMENTS, GADGET_ID_NONE,
3671 &level.bd_diagonal_movements,
3673 "can move diagonally", "player can move diagonally"
3676 ED_CHECKBUTTON_ID_BD_TOPMOST_PLAYER_ACTIVE,
3677 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3678 GADGET_ID_BD_TOPMOST_PLAYER_ACTIVE, GADGET_ID_NONE,
3679 &level.bd_topmost_player_active,
3681 "topmost player is active", "use first player found on playfield"
3684 ED_CHECKBUTTON_ID_BD_PUSH_MEGA_ROCK_WITH_SWEET,
3685 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3686 GADGET_ID_BD_PUSH_MEGA_ROCK_WITH_SWEET, GADGET_ID_NONE,
3687 &level.bd_push_mega_rock_with_sweet,
3689 "mega rocks pushable with sweet", "push mega rocks after eating sweet"
3692 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
3693 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3694 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
3695 &level.envelope[0].autowrap,
3697 "auto-wrap", "automatically wrap envelope text"
3700 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
3701 -1, ED_ELEMENT_SETTINGS_YPOS(1),
3702 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
3703 &level.envelope[0].centered,
3705 "centered", "automatically center envelope text"
3708 ED_CHECKBUTTON_ID_MM_LASER_RED,
3709 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3710 GADGET_ID_MM_LASER_RED, GADGET_ID_NONE,
3711 &level.mm_laser_red,
3712 "choose color components for laser:", NULL,
3713 "red", "use red color components in laser"
3716 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
3717 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3718 GADGET_ID_MM_LASER_GREEN, GADGET_ID_NONE,
3719 &level.mm_laser_green,
3721 "green", "use green color components in laser"
3724 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
3725 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3726 GADGET_ID_MM_LASER_BLUE, GADGET_ID_NONE,
3727 &level.mm_laser_blue,
3729 "blue", "use blue color components in laser"
3732 ED_CHECKBUTTON_ID_DF_LASER_RED,
3733 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3734 GADGET_ID_DF_LASER_RED, GADGET_ID_NONE,
3735 &level.df_laser_red,
3736 "choose color components for laser:", NULL,
3737 "red", "use red color components in laser"
3740 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
3741 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3742 GADGET_ID_DF_LASER_GREEN, GADGET_ID_NONE,
3743 &level.df_laser_green,
3745 "green", "use green color components in laser"
3748 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
3749 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3750 GADGET_ID_DF_LASER_BLUE, GADGET_ID_NONE,
3751 &level.df_laser_blue,
3753 "blue", "use blue color components in laser"
3756 ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT,
3757 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3758 GADGET_ID_ROTATE_MM_BALL_CONTENT, GADGET_ID_NONE,
3759 &level.rotate_mm_ball_content,
3761 "randomly rotate created content", "randomly rotate newly created content"
3764 ED_CHECKBUTTON_ID_EXPLODE_MM_BALL,
3765 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3766 GADGET_ID_EXPLODE_MM_BALL, GADGET_ID_NONE,
3767 &level.explode_mm_ball,
3769 "explode ball instead of melting", "use explosion to release ball content"
3772 // ---------- element settings: configure 1 (custom elements) ---------------
3775 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
3776 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3777 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
3778 &custom_element.use_gfx_element,
3780 "use graphic of element:", "use existing element graphic"
3783 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
3784 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3785 GADGET_ID_CUSTOM_USE_TEMPLATE_1, GADGET_ID_NONE,
3786 &level.use_custom_template,
3788 "use template", "use template for custom properties"
3791 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
3792 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3793 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
3794 &custom_element_properties[EP_ACCESSIBLE],
3796 NULL, "player can walk to or pass this field"
3799 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
3800 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3801 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
3802 &custom_element_properties[EP_GRAVITY_REACHABLE],
3804 "reachable despite gravity", "player can walk/dig despite gravity"
3807 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
3808 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3809 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
3810 &custom_element.use_last_ce_value,
3812 "use last CE value after change", "use last CE value after change"
3815 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
3816 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3817 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
3818 &custom_element_properties[EP_WALK_TO_OBJECT],
3820 NULL, "player can dig/collect/push element"
3823 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
3824 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3825 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
3826 &custom_element_properties[EP_INDESTRUCTIBLE],
3828 "indestructible", "element is indestructible"
3831 // ---------- element settings: configure 2 (custom elements) ---------------
3834 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
3835 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3836 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
3837 &custom_element_properties[EP_CAN_MOVE],
3839 NULL, "element can move with some pattern"
3842 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
3843 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3844 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
3845 &custom_element_properties[EP_CAN_FALL],
3847 "can fall", "element can fall down"
3850 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
3851 -1, ED_ELEMENT_SETTINGS_YPOS(8),
3852 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
3853 &custom_element_properties[EP_CAN_SMASH],
3855 NULL, "element can smash other elements"
3858 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
3859 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3860 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
3861 &custom_element_properties[EP_SLIPPERY],
3863 NULL, "other elements can fall down from it"
3866 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
3867 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3868 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
3869 &custom_element_properties[EP_DEADLY],
3871 NULL, "element can kill the player"
3874 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
3875 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3876 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
3877 &custom_element_properties[EP_CAN_EXPLODE],
3879 NULL, "element can explode"
3882 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
3883 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
3884 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
3885 &custom_element_properties[EP_EXPLODES_BY_FIRE],
3887 "by fire", "element can explode by fire/explosion"
3890 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
3891 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3892 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
3893 &custom_element_properties[EP_EXPLODES_SMASHED],
3895 "smashed", "element can explode when smashed"
3898 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
3899 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3900 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
3901 &custom_element_properties[EP_EXPLODES_IMPACT],
3903 "impact", "element can explode on impact"
3906 // ---------- element settings: advanced (custom elements) ------------------
3909 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
3910 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3911 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
3912 &custom_element_change.can_change,
3914 "element changes to:", "change element on specified condition"
3917 ED_CHECKBUTTON_ID_CHANGE_DELAY,
3918 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
3919 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
3920 &custom_element_change_events[CE_DELAY],
3922 NULL, "element changes after delay"
3925 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
3926 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
3927 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
3928 &custom_element_change_events[CE_BY_DIRECT_ACTION],
3930 NULL, "element changes by direct action"
3933 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
3934 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
3935 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
3936 &custom_element_change_events[CE_BY_OTHER_ACTION],
3938 NULL, "element changes by other element"
3941 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
3942 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
3943 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
3944 &custom_element_change.explode,
3946 "explode instead of change", "element explodes instead of change"
3949 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
3950 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
3951 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
3952 &custom_element_change.use_target_content,
3954 "use extended change target:", "element changes to more elements"
3957 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
3958 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3959 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3960 &custom_element_change.only_if_complete,
3962 "replace all or nothing", "only replace when all can be changed"
3965 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
3966 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3967 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3968 &custom_element_change.use_random_replace,
3970 NULL, "use percentage for random replace"
3973 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
3974 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3975 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3976 &custom_element_change.has_action,
3978 NULL, "execute action on specified condition"
3986 int xoffset, yoffset;
3988 int gadget_id_align;
3990 int area_xsize, area_ysize;
3991 char *text_left, *text_right, *text_above, *text_below, *infotext;
3992 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3994 // ---------- level playfield content ---------------------------------------
3997 ED_DRAWING_ID_DRAWING_LEVEL,
4000 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
4002 -1, -1, // these values are not constant, but can change at runtime
4003 NULL, NULL, NULL, NULL, NULL
4006 // ---------- yam yam content -----------------------------------------------
4009 ED_DRAWING_ID_YAMYAM_CONTENT_0,
4010 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4011 ED_AREA_YAMYAM_CONTENT_XOFF(0), ED_AREA_YAMYAM_CONTENT_YOFF(0),
4012 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
4013 &level.yamyam_content[0].e[0][0], 3, 3,
4014 NULL, NULL, NULL, "1", NULL
4017 ED_DRAWING_ID_YAMYAM_CONTENT_1,
4018 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4019 ED_AREA_YAMYAM_CONTENT_XOFF(1), ED_AREA_YAMYAM_CONTENT_YOFF(1),
4020 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
4021 &level.yamyam_content[1].e[0][0], 3, 3,
4022 NULL, NULL, NULL, "2", NULL
4025 ED_DRAWING_ID_YAMYAM_CONTENT_2,
4026 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4027 ED_AREA_YAMYAM_CONTENT_XOFF(2), ED_AREA_YAMYAM_CONTENT_YOFF(2),
4028 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
4029 &level.yamyam_content[2].e[0][0], 3, 3,
4030 NULL, NULL, NULL, "3", NULL
4033 ED_DRAWING_ID_YAMYAM_CONTENT_3,
4034 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4035 ED_AREA_YAMYAM_CONTENT_XOFF(3), ED_AREA_YAMYAM_CONTENT_YOFF(3),
4036 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
4037 &level.yamyam_content[3].e[0][0], 3, 3,
4038 NULL, NULL, NULL, "4", NULL
4041 ED_DRAWING_ID_YAMYAM_CONTENT_4,
4042 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4043 ED_AREA_YAMYAM_CONTENT_XOFF(4), ED_AREA_YAMYAM_CONTENT_YOFF(4),
4044 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
4045 &level.yamyam_content[4].e[0][0], 3, 3,
4046 NULL, NULL, NULL, "5", NULL
4049 ED_DRAWING_ID_YAMYAM_CONTENT_5,
4050 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4051 ED_AREA_YAMYAM_CONTENT_XOFF(5), ED_AREA_YAMYAM_CONTENT_YOFF(5),
4052 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
4053 &level.yamyam_content[5].e[0][0], 3, 3,
4054 NULL, NULL, NULL, "6", NULL
4057 ED_DRAWING_ID_YAMYAM_CONTENT_6,
4058 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4059 ED_AREA_YAMYAM_CONTENT_XOFF(6), ED_AREA_YAMYAM_CONTENT_YOFF(6),
4060 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
4061 &level.yamyam_content[6].e[0][0], 3, 3,
4062 NULL, NULL, NULL, "7", NULL
4065 ED_DRAWING_ID_YAMYAM_CONTENT_7,
4066 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4067 ED_AREA_YAMYAM_CONTENT_XOFF(7), ED_AREA_YAMYAM_CONTENT_YOFF(7),
4068 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
4069 &level.yamyam_content[7].e[0][0], 3, 3,
4070 NULL, NULL, NULL, "8", NULL
4073 // ---------- magic ball content --------------------------------------------
4076 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
4077 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4078 ED_AREA_MAGIC_BALL_CONTENT_XOFF(0), ED_AREA_MAGIC_BALL_CONTENT_YOFF(0),
4079 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
4080 &level.ball_content[0].e[0][0], 3, 3,
4081 NULL, NULL, NULL, "1", NULL
4084 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
4085 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4086 ED_AREA_MAGIC_BALL_CONTENT_XOFF(1), ED_AREA_MAGIC_BALL_CONTENT_YOFF(1),
4087 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
4088 &level.ball_content[1].e[0][0], 3, 3,
4089 NULL, NULL, NULL, "2", NULL
4092 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
4093 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4094 ED_AREA_MAGIC_BALL_CONTENT_XOFF(2), ED_AREA_MAGIC_BALL_CONTENT_YOFF(2),
4095 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
4096 &level.ball_content[2].e[0][0], 3, 3,
4097 NULL, NULL, NULL, "3", NULL
4100 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
4101 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4102 ED_AREA_MAGIC_BALL_CONTENT_XOFF(3), ED_AREA_MAGIC_BALL_CONTENT_YOFF(3),
4103 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
4104 &level.ball_content[3].e[0][0], 3, 3,
4105 NULL, NULL, NULL, "4", NULL
4108 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
4109 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4110 ED_AREA_MAGIC_BALL_CONTENT_XOFF(4), ED_AREA_MAGIC_BALL_CONTENT_YOFF(4),
4111 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
4112 &level.ball_content[4].e[0][0], 3, 3,
4113 NULL, NULL, NULL, "5", NULL
4116 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
4117 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4118 ED_AREA_MAGIC_BALL_CONTENT_XOFF(5), ED_AREA_MAGIC_BALL_CONTENT_YOFF(5),
4119 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
4120 &level.ball_content[5].e[0][0], 3, 3,
4121 NULL, NULL, NULL, "6", NULL
4124 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
4125 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4126 ED_AREA_MAGIC_BALL_CONTENT_XOFF(6), ED_AREA_MAGIC_BALL_CONTENT_YOFF(6),
4127 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
4128 &level.ball_content[6].e[0][0], 3, 3,
4129 NULL, NULL, NULL, "7", NULL
4132 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
4133 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4134 ED_AREA_MAGIC_BALL_CONTENT_XOFF(7), ED_AREA_MAGIC_BALL_CONTENT_YOFF(7),
4135 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
4136 &level.ball_content[7].e[0][0], 3, 3,
4137 NULL, NULL, NULL, "8", NULL
4140 // ---------- android content -----------------------------------------------
4143 ED_DRAWING_ID_ANDROID_CONTENT,
4144 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(6),
4145 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4146 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
4147 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
4148 NULL, NULL, "elements:", NULL, "elements android can clone"
4151 // ---------- amoeba content ------------------------------------------------
4154 ED_DRAWING_ID_AMOEBA_CONTENT,
4155 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
4156 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4157 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
4158 &level.amoeba_content, 1, 1,
4159 "content:", NULL, NULL, NULL, "amoeba content"
4162 // ---------- level start element -------------------------------------------
4165 ED_DRAWING_ID_START_ELEMENT,
4166 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
4167 0, ED_AREA_1X1_SETTINGS_YOFF,
4168 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
4169 &level.start_element[0], 1, 1,
4170 NULL, NULL, NULL, NULL, "level start element"
4173 // ---------- player artwork element ----------------------------------------
4176 ED_DRAWING_ID_ARTWORK_ELEMENT,
4177 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
4178 0, ED_AREA_1X1_SETTINGS_YOFF,
4179 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
4180 &level.artwork_element[0], 1, 1,
4181 NULL, NULL, NULL, NULL, "element for player artwork"
4184 // ---------- player explosion element --------------------------------------
4187 ED_DRAWING_ID_EXPLOSION_ELEMENT,
4188 -1, ED_AREA_1X1_SETTINGS_YPOS(12),
4189 0, ED_AREA_1X1_SETTINGS_YOFF,
4190 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
4191 &level.explosion_element[0], 1, 1,
4192 NULL, NULL, NULL, NULL, "element for player explosion"
4195 // ---------- player initial inventory --------------------------------------
4198 ED_DRAWING_ID_INVENTORY_CONTENT,
4199 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4200 0, ED_AREA_1X1_SETTINGS_YOFF,
4201 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
4202 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
4203 NULL, NULL, NULL, NULL, "content for initial inventory"
4206 // ---------- gray ball content -----------------------------------------
4209 ED_DRAWING_ID_MM_BALL_CONTENT,
4210 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
4211 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4212 GADGET_ID_MM_BALL_CONTENT, GADGET_ID_NONE,
4213 &level.mm_ball_content[0], MAX_MM_BALL_CONTENTS, 1,
4214 "content:", NULL, NULL, NULL, "content for gray ball"
4217 // ---------- element settings: configure 1 (custom elements) ---------------
4219 // ---------- custom graphic ------------------------------------------------
4222 ED_DRAWING_ID_CUSTOM_GRAPHIC,
4223 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4224 0, ED_AREA_1X1_SETTINGS_YOFF,
4225 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
4226 &custom_element.gfx_element_initial, 1, 1,
4227 NULL, NULL, NULL, NULL, "custom graphic element"
4230 // ---------- element settings: configure 2 (custom elements) ---------------
4232 // ---------- custom content (when exploding) -------------------------------
4235 ED_DRAWING_ID_CUSTOM_CONTENT,
4236 -1, ED_AREA_3X3_SETTINGS_YPOS(11),
4237 0, ED_AREA_3X3_SETTINGS_YOFF,
4238 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, // align three rows
4239 &custom_element.content.e[0][0], 3, 3,
4240 "content:", NULL, NULL, NULL, NULL
4243 // ---------- custom enter and leave element (when moving) ------------------
4246 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
4247 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
4248 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4249 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
4250 &custom_element.move_enter_element, 1, 1,
4251 "can dig:", " ", NULL, NULL, "element that can be digged/collected"
4254 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
4255 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
4256 0, ED_AREA_1X1_SETTINGS_YOFF,
4257 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
4258 &custom_element.move_leave_element, 1, 1,
4259 NULL, NULL, NULL, NULL, "element that will be left behind"
4262 // ---------- element settings: advanced (custom elements) ------------------
4264 // ---------- custom change target ------------------------------------------
4267 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
4268 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4269 0, ED_AREA_1X1_SETTINGS_YOFF,
4270 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
4271 &custom_element_change.target_element, 1, 1,
4272 NULL, "after/when:", NULL, NULL, "new target element after change"
4275 // ---------- custom change content (extended change target) ----------------
4278 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
4279 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
4280 0, ED_AREA_3X3_SETTINGS_YOFF,
4281 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, // align three rows
4282 &custom_element_change.target_content.e[0][0], 3, 3,
4283 NULL, NULL, NULL, NULL, "new extended elements after change"
4286 // ---------- custom change trigger (element causing change) ----------------
4289 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
4290 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
4291 0, ED_AREA_1X1_SETTINGS_YOFF,
4292 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
4293 &custom_element_change.initial_trigger_element, 1, 1,
4294 NULL, NULL, NULL, NULL, "other element triggering change"
4297 // ---------- custom change action (element used for action) ----------------
4300 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
4301 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
4302 0, ED_AREA_1X1_SETTINGS_YOFF,
4303 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
4304 &custom_element_change.action_element, 1, 1,
4305 NULL, NULL, NULL, NULL, "element used as action parameter"
4308 // ---------- group element content -----------------------------------------
4311 ED_DRAWING_ID_GROUP_CONTENT,
4312 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
4313 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4314 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
4315 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
4316 "content:", NULL, NULL, NULL, NULL
4319 // ---------- random background (for random painting) -----------------------
4322 ED_DRAWING_ID_RANDOM_BACKGROUND,
4323 -1, ED_AREA_1X1_LSETTINGS_YPOS(1),
4324 0, ED_AREA_1X1_LSETTINGS_YOFF,
4325 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
4326 &random_placement_background_element, 1, 1,
4327 NULL, NULL, NULL, NULL, "random placement background"
4332 // ----------------------------------------------------------------------------
4333 // some internally used variables
4334 // ----------------------------------------------------------------------------
4336 // maximal size of level editor drawing area
4337 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
4339 // actual size of level editor drawing area
4340 static int ed_fieldx, ed_fieldy;
4342 // actual position of level editor drawing area in level playfield
4343 static int level_xpos = -1, level_ypos = -1;
4345 // actual tile size used to display playfield drawing area
4346 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
4347 static int ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
4349 #define IN_ED_FIELD(x, y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
4351 // drawing elements on the three mouse buttons
4352 static int new_element1 = EL_WALL;
4353 static int new_element2 = EL_EMPTY;
4354 static int new_element3 = EL_SAND;
4356 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
4357 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
4358 (button) == 2 ? new_element2 : \
4359 (button) == 3 ? new_element3 : EL_EMPTY)
4361 #define BUTTON_TILE_SIZE(x) ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE)
4363 static int use_permanent_palette = TRUE;
4365 #define PX (use_permanent_palette ? DX : SX)
4366 #define PY (use_permanent_palette ? DY : SY)
4367 #define PXSIZE (use_permanent_palette ? DXSIZE : SXSIZE)
4368 #define PYSIZE (use_permanent_palette ? DYSIZE : SYSIZE)
4370 // forward declaration for internal use
4371 static void CopyBrushToCursor(int, int);
4372 static void DeleteBrushFromCursor(void);
4373 static void ModifyEditorCounterValue(int, int);
4374 static void ModifyEditorCounterLimits(int, int, int);
4375 static void ModifyEditorSelectboxValue(int, int);
4376 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
4377 static void ModifyEditorDrawingArea(int, int, int);
4378 static void ModifyEditorElementList(void);
4379 static void AdjustElementListScrollbar(void);
4380 static void RedrawDrawingElements(void);
4381 static void DrawDrawingWindowExt(boolean);
4382 static void DrawDrawingWindow(void);
4383 static void DrawLevelConfigWindow(void);
4384 static void DrawPropertiesWindow(void);
4385 static void DrawPaletteWindow(void);
4386 static void UpdateCustomElementGraphicGadgets(void);
4387 static boolean checkPropertiesConfig(int);
4388 static void SetAutomaticNumberOfGemsNeeded(void);
4389 static void ClearEditorGadgetInfoText(void);
4390 static void CopyLevelToUndoBuffer(int);
4391 static void HandleDrawingAreas(struct GadgetInfo *);
4392 static void HandleCounterButtons(struct GadgetInfo *);
4393 static void HandleTextInputGadgets(struct GadgetInfo *);
4394 static void HandleTextAreaGadgets(struct GadgetInfo *);
4395 static void HandleSelectboxGadgets(struct GadgetInfo *);
4396 static void HandleTextbuttonGadgets(struct GadgetInfo *);
4397 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
4398 static void HandleRadiobuttons(struct GadgetInfo *);
4399 static void HandleCheckbuttons(struct GadgetInfo *);
4400 static void HandleControlButtons(struct GadgetInfo *);
4401 static void HandleDrawingAreaInfo(struct GadgetInfo *);
4402 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
4403 static boolean AskToCopyAndModifyLevelTemplate(void);
4404 static boolean getDrawModeHiRes(void);
4405 static int getTabulatorBarWidth(void);
4406 static int getTabulatorBarHeight(void);
4407 static Pixel getTabulatorBarColor(void);
4408 static int numHiresTiles(int);
4410 static int num_editor_gadgets = 0; // dynamically determined
4412 static struct GadgetInfo **level_editor_gadget = NULL;
4413 static int *right_gadget_border = NULL;
4415 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
4416 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
4417 static boolean draw_with_brush = FALSE;
4418 static int properties_element = 0;
4420 static short TileBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4421 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4422 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4423 static int undo_buffer_position = 0;
4424 static int undo_buffer_steps = 0;
4425 static int redo_buffer_steps = 0;
4427 static int edit_mode;
4428 static int edit_mode_levelconfig;
4429 static int edit_mode_properties;
4431 static int element_shift = 0;
4433 static int editor_el_players[] =
4440 static int *editor_el_players_ptr = editor_el_players;
4441 static int num_editor_el_players = ARRAY_SIZE(editor_el_players);
4443 static int editor_hl_boulderdash[] =
4445 EL_INTERNAL_CASCADE_BD_ACTIVE,
4451 static int editor_el_boulderdash[] =
4460 EL_BD_EXPANDABLE_WALL,
4468 EL_BD_BUTTERFLY_LEFT,
4470 EL_BD_BUTTERFLY_RIGHT,
4471 EL_BD_FIREFLY_RIGHT,
4474 EL_BD_BUTTERFLY_DOWN,
4478 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
4479 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
4480 static int num_editor_hl_boulderdash = ARRAY_SIZE(editor_hl_boulderdash);
4481 static int num_editor_el_boulderdash = ARRAY_SIZE(editor_el_boulderdash);
4483 static int editor_hl_boulderdash_native[] =
4485 EL_INTERNAL_CASCADE_BD_NATIVE_ACTIVE,
4491 static int editor_el_boulderdash_native[] =
4508 EL_BD_BUTTERFLY_LEFT,
4510 EL_BD_BUTTERFLY_RIGHT,
4511 EL_BD_FIREFLY_RIGHT,
4514 EL_BD_BUTTERFLY_DOWN,
4519 EL_BD_BUTTERFLY_2_UP,
4523 EL_BD_BUTTERFLY_2_LEFT,
4524 EL_BD_FIREFLY_2_LEFT,
4525 EL_BD_BUTTERFLY_2_RIGHT,
4526 EL_BD_FIREFLY_2_RIGHT,
4529 EL_BD_BUTTERFLY_2_DOWN,
4530 EL_BD_FIREFLY_2_DOWN,
4538 EL_BD_DRAGONFLY_LEFT,
4539 EL_BD_STONEFLY_LEFT,
4540 EL_BD_DRAGONFLY_RIGHT,
4541 EL_BD_STONEFLY_RIGHT,
4544 EL_BD_DRAGONFLY_DOWN,
4545 EL_BD_STONEFLY_DOWN,
4568 EL_BD_SAND_SLOPED_UP_LEFT,
4569 EL_BD_SAND_SLOPED_UP_RIGHT,
4570 EL_BD_WALL_SLOPED_UP_LEFT,
4571 EL_BD_WALL_SLOPED_UP_RIGHT,
4573 EL_BD_SAND_SLOPED_DOWN_LEFT,
4574 EL_BD_SAND_SLOPED_DOWN_RIGHT,
4575 EL_BD_WALL_SLOPED_DOWN_LEFT,
4576 EL_BD_WALL_SLOPED_DOWN_RIGHT,
4578 EL_BD_FLYING_DIAMOND,
4580 EL_BD_STEELWALL_SLOPED_UP_LEFT,
4581 EL_BD_STEELWALL_SLOPED_UP_RIGHT,
4585 EL_BD_STEELWALL_SLOPED_DOWN_LEFT,
4586 EL_BD_STEELWALL_SLOPED_DOWN_RIGHT,
4589 EL_BD_WALL_NON_SLOPED,
4595 EL_BD_INVISIBLE_EXIT_CLOSED,
4596 EL_BD_INVISIBLE_EXIT_OPEN,
4599 EL_BD_STEELWALL_EXPLODABLE,
4600 EL_BD_STEELWALL_DIGGABLE,
4601 EL_BD_WALL_DIGGABLE,
4603 EL_BD_EXPANDABLE_WALL_HORIZONTAL,
4604 EL_BD_EXPANDABLE_WALL_VERTICAL,
4605 EL_BD_EXPANDABLE_WALL_ANY,
4606 EL_BD_CREATURE_SWITCH,
4608 EL_BD_EXPANDABLE_STEELWALL_HORIZONTAL,
4609 EL_BD_EXPANDABLE_STEELWALL_VERTICAL,
4610 EL_BD_EXPANDABLE_STEELWALL_ANY,
4611 EL_BD_EXPANDABLE_WALL_SWITCH_HORIZONTAL,
4613 EL_BD_BITER_SWITCH_1,
4614 EL_BD_REPLICATOR_SWITCH,
4615 EL_BD_CONVEYOR_SWITCH,
4616 EL_BD_CONVEYOR_DIR_SWITCH_RIGHT,
4625 EL_BD_DIAMOND_GLUED,
4628 EL_BD_TRAPPED_DIAMOND,
4648 EL_BD_GRAVITY_SWITCH,
4649 EL_BD_PNEUMATIC_HAMMER,
4656 EL_BD_BLADDER_SPENDER,
4658 EL_BD_CONVEYOR_LEFT,
4659 EL_BD_CONVEYOR_RIGHT,
4674 EL_BD_PLAYER_WITH_BOMB,
4676 EL_BD_PLAYER_STIRRING,
4678 static int *editor_hl_boulderdash_native_ptr = editor_hl_boulderdash_native;
4679 static int *editor_el_boulderdash_native_ptr = editor_el_boulderdash_native;
4680 static int num_editor_hl_boulderdash_native = ARRAY_SIZE(editor_hl_boulderdash_native);
4681 static int num_editor_el_boulderdash_native = ARRAY_SIZE(editor_el_boulderdash_native);
4683 static int editor_hl_emerald_mine[] =
4685 EL_INTERNAL_CASCADE_EM_ACTIVE,
4691 static int editor_el_emerald_mine[] =
4709 EL_EM_DYNAMITE_ACTIVE,
4728 EL_ACID_POOL_TOPLEFT,
4730 EL_ACID_POOL_TOPRIGHT,
4733 EL_ACID_POOL_BOTTOMLEFT,
4734 EL_ACID_POOL_BOTTOM,
4735 EL_ACID_POOL_BOTTOMRIGHT,
4753 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
4754 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
4755 static int num_editor_hl_emerald_mine = ARRAY_SIZE(editor_hl_emerald_mine);
4756 static int num_editor_el_emerald_mine = ARRAY_SIZE(editor_el_emerald_mine);
4758 static int editor_hl_emerald_mine_club[] =
4760 EL_INTERNAL_CASCADE_EMC_ACTIVE,
4766 static int editor_el_emerald_mine_club[] =
4793 EL_EMC_WALL_SLIPPERY_1,
4794 EL_EMC_WALL_SLIPPERY_2,
4795 EL_EMC_WALL_SLIPPERY_3,
4796 EL_EMC_WALL_SLIPPERY_4,
4819 EL_EMC_MAGIC_BALL_SWITCH,
4826 EL_EMC_SPRING_BUMPER,
4830 EL_BALLOON_SWITCH_UP,
4831 EL_BALLOON_SWITCH_ANY,
4834 EL_BALLOON_SWITCH_LEFT,
4836 EL_BALLOON_SWITCH_RIGHT,
4840 EL_BALLOON_SWITCH_DOWN,
4841 EL_BALLOON_SWITCH_NONE,
4843 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
4844 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
4845 static int num_editor_hl_emerald_mine_club = ARRAY_SIZE(editor_hl_emerald_mine_club);
4846 static int num_editor_el_emerald_mine_club = ARRAY_SIZE(editor_el_emerald_mine_club);
4848 static int editor_hl_rnd[] =
4850 EL_INTERNAL_CASCADE_RND_ACTIVE,
4856 static int editor_el_rnd[] =
4859 EL_DYNAMITE_ACTIVE, // RND
4893 EL_WALL_EMERALD_YELLOW,
4894 EL_WALL_EMERALD_RED,
4895 EL_WALL_EMERALD_PURPLE,
4913 EL_DYNABOMB_INCREASE_NUMBER,
4914 EL_DYNABOMB_INCREASE_SIZE,
4915 EL_DYNABOMB_INCREASE_POWER,
4935 EL_INVISIBLE_STEELWALL,
4939 EL_EXPANDABLE_WALL_HORIZONTAL,
4940 EL_EXPANDABLE_WALL_VERTICAL,
4941 EL_EXPANDABLE_WALL_ANY,
4943 static int *editor_hl_rnd_ptr = editor_hl_rnd;
4944 static int *editor_el_rnd_ptr = editor_el_rnd;
4945 static int num_editor_hl_rnd = ARRAY_SIZE(editor_hl_rnd);
4946 static int num_editor_el_rnd = ARRAY_SIZE(editor_el_rnd);
4948 static int editor_hl_sokoban[] =
4950 EL_INTERNAL_CASCADE_SB_ACTIVE,
4956 static int editor_el_sokoban[] =
4959 EL_SOKOBAN_FIELD_EMPTY,
4960 EL_SOKOBAN_FIELD_FULL,
4961 EL_SOKOBAN_FIELD_PLAYER,
4963 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
4964 static int *editor_el_sokoban_ptr = editor_el_sokoban;
4965 static int num_editor_hl_sokoban = ARRAY_SIZE(editor_hl_sokoban);
4966 static int num_editor_el_sokoban = ARRAY_SIZE(editor_el_sokoban);
4968 static int editor_hl_supaplex[] =
4970 EL_INTERNAL_CASCADE_SP_ACTIVE,
4976 static int editor_el_supaplex[] =
4994 EL_SP_PORT_HORIZONTAL,
4995 EL_SP_PORT_VERTICAL,
5003 EL_SP_GRAVITY_PORT_LEFT,
5004 EL_SP_GRAVITY_PORT_RIGHT,
5005 EL_SP_GRAVITY_PORT_UP,
5006 EL_SP_GRAVITY_PORT_DOWN,
5008 EL_SP_GRAVITY_ON_PORT_LEFT,
5009 EL_SP_GRAVITY_ON_PORT_RIGHT,
5010 EL_SP_GRAVITY_ON_PORT_UP,
5011 EL_SP_GRAVITY_ON_PORT_DOWN,
5013 EL_SP_GRAVITY_OFF_PORT_LEFT,
5014 EL_SP_GRAVITY_OFF_PORT_RIGHT,
5015 EL_SP_GRAVITY_OFF_PORT_UP,
5016 EL_SP_GRAVITY_OFF_PORT_DOWN,
5018 EL_SP_HARDWARE_GRAY,
5019 EL_SP_HARDWARE_GREEN,
5020 EL_SP_HARDWARE_BLUE,
5023 EL_SP_HARDWARE_BASE_1,
5024 EL_SP_HARDWARE_BASE_2,
5025 EL_SP_HARDWARE_BASE_3,
5026 EL_SP_HARDWARE_BASE_4,
5028 EL_SP_HARDWARE_BASE_5,
5029 EL_SP_HARDWARE_BASE_6,
5030 EL_SP_HARDWARE_YELLOW,
5038 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
5039 static int *editor_el_supaplex_ptr = editor_el_supaplex;
5040 static int num_editor_hl_supaplex = ARRAY_SIZE(editor_hl_supaplex);
5041 static int num_editor_el_supaplex = ARRAY_SIZE(editor_el_supaplex);
5043 static int editor_hl_diamond_caves[] =
5045 EL_INTERNAL_CASCADE_DC_ACTIVE,
5051 static int editor_el_diamond_caves[] =
5053 EL_EM_STEEL_EXIT_CLOSED, // DC2
5054 EL_EM_STEEL_EXIT_OPEN, // DC2
5055 EL_WALL_EMERALD, // DC2
5056 EL_WALL_DIAMOND, // DC2
5063 EL_CONVEYOR_BELT_1_LEFT,
5064 EL_CONVEYOR_BELT_1_MIDDLE,
5065 EL_CONVEYOR_BELT_1_RIGHT,
5066 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
5068 EL_CONVEYOR_BELT_2_LEFT,
5069 EL_CONVEYOR_BELT_2_MIDDLE,
5070 EL_CONVEYOR_BELT_2_RIGHT,
5071 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
5073 EL_CONVEYOR_BELT_3_LEFT,
5074 EL_CONVEYOR_BELT_3_MIDDLE,
5075 EL_CONVEYOR_BELT_3_RIGHT,
5076 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
5078 EL_CONVEYOR_BELT_4_LEFT,
5079 EL_CONVEYOR_BELT_4_MIDDLE,
5080 EL_CONVEYOR_BELT_4_RIGHT,
5081 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
5083 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
5084 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
5085 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
5086 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
5088 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
5089 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
5090 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
5091 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
5096 EL_DC_TIMEGATE_SWITCH,
5098 EL_SWITCHGATE_CLOSED,
5100 EL_SWITCHGATE_SWITCH_UP,
5101 EL_SWITCHGATE_SWITCH_DOWN,
5104 EL_LIGHT_SWITCH_ACTIVE,
5105 EL_DC_SWITCHGATE_SWITCH_UP,
5106 EL_DC_SWITCHGATE_SWITCH_DOWN,
5108 EL_STEEL_EXIT_CLOSED,
5110 EL_STEELWALL_SLIPPERY,
5113 EL_QUICKSAND_FAST_EMPTY,
5114 EL_QUICKSAND_FAST_FULL,
5128 EL_SIGN_RADIOACTIVITY,
5134 EL_SIGN_ENTRY_FORBIDDEN,
5135 EL_SIGN_EMERGENCY_EXIT,
5160 EL_DC_STEELWALL_2_SINGLE,
5161 EL_DC_STEELWALL_2_TOP,
5162 EL_SIGN_EXCLAMATION,
5165 EL_DC_STEELWALL_2_LEFT,
5166 EL_DC_STEELWALL_2_MIDDLE,
5167 EL_DC_STEELWALL_2_HORIZONTAL,
5168 EL_DC_STEELWALL_2_RIGHT,
5170 EL_DC_STEELWALL_1_TOPLEFT,
5171 EL_DC_STEELWALL_2_VERTICAL,
5172 EL_DC_STEELWALL_1_TOPRIGHT,
5175 EL_DC_STEELWALL_1_VERTICAL,
5176 EL_DC_STEELWALL_2_BOTTOM,
5178 EL_DC_GATE_WHITE_GRAY,
5180 EL_DC_STEELWALL_1_BOTTOMLEFT,
5181 EL_DC_STEELWALL_1_HORIZONTAL,
5182 EL_DC_STEELWALL_1_BOTTOMRIGHT,
5183 EL_DC_GATE_FAKE_GRAY,
5185 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
5186 EL_DC_STEELWALL_1_BOTTOM,
5187 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
5188 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
5190 EL_DC_STEELWALL_1_RIGHT,
5192 EL_DC_STEELWALL_1_LEFT,
5193 EL_EXPANDABLE_STEELWALL_VERTICAL,
5195 EL_DC_STEELWALL_1_TOPRIGHT_2,
5196 EL_DC_STEELWALL_1_TOP,
5197 EL_DC_STEELWALL_1_TOPLEFT_2,
5198 EL_EXPANDABLE_STEELWALL_ANY,
5200 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
5201 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
5202 static int num_editor_hl_diamond_caves = ARRAY_SIZE(editor_hl_diamond_caves);
5203 static int num_editor_el_diamond_caves = ARRAY_SIZE(editor_el_diamond_caves);
5205 static int editor_hl_dx_boulderdash[] =
5207 EL_INTERNAL_CASCADE_DX_ACTIVE,
5213 static int editor_el_dx_boulderdash[] =
5217 EL_TUBE_HORIZONTAL_DOWN,
5221 EL_TUBE_VERTICAL_RIGHT,
5223 EL_TUBE_VERTICAL_LEFT,
5227 EL_TUBE_HORIZONTAL_UP,
5235 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
5236 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
5237 static int num_editor_hl_dx_boulderdash = ARRAY_SIZE(editor_hl_dx_boulderdash);
5238 static int num_editor_el_dx_boulderdash = ARRAY_SIZE(editor_el_dx_boulderdash);
5240 static int editor_hl_mirror_magic[] =
5242 EL_INTERNAL_CASCADE_MM_ACTIVE,
5248 static int editor_el_mirror_magic[] =
5250 EL_MM_MCDUFFIN_RIGHT,
5252 EL_MM_MCDUFFIN_LEFT,
5253 EL_MM_MCDUFFIN_DOWN,
5256 EL_MM_MIRROR_FIXED_START,
5257 EL_MM_POLARIZER_START,
5258 EL_MM_POLARIZER_CROSS_START,
5260 EL_MM_TELEPORTER_RED_START,
5261 EL_MM_TELEPORTER_YELLOW_START,
5262 EL_MM_TELEPORTER_GREEN_START,
5263 EL_MM_TELEPORTER_BLUE_START,
5276 EL_MM_LIGHTBULB_ACTIVE,
5290 EL_MM_STEEL_GRID_FIXED_1,
5291 EL_MM_STEEL_GRID_FIXED_2,
5292 EL_MM_STEEL_GRID_FIXED_3,
5293 EL_MM_STEEL_GRID_FIXED_4,
5295 EL_MM_WOODEN_GRID_FIXED_1,
5296 EL_MM_WOODEN_GRID_FIXED_2,
5297 EL_MM_WOODEN_GRID_FIXED_3,
5298 EL_MM_WOODEN_GRID_FIXED_4,
5305 static int *editor_hl_mirror_magic_ptr = editor_hl_mirror_magic;
5306 static int *editor_el_mirror_magic_ptr = editor_el_mirror_magic;
5307 static int num_editor_hl_mirror_magic = ARRAY_SIZE(editor_hl_mirror_magic);
5308 static int num_editor_el_mirror_magic = ARRAY_SIZE(editor_el_mirror_magic);
5310 static int editor_hl_deflektor[] =
5312 EL_INTERNAL_CASCADE_DF_ACTIVE,
5318 static int editor_el_deflektor[] =
5325 EL_DF_RECEIVER_RIGHT,
5327 EL_DF_RECEIVER_LEFT,
5328 EL_DF_RECEIVER_DOWN,
5331 EL_DF_MIRROR_ROTATING_START,
5332 EL_DF_MIRROR_FIXED_START,
5335 EL_DF_FIBRE_OPTIC_RED_1,
5336 EL_DF_FIBRE_OPTIC_YELLOW_1,
5337 EL_DF_FIBRE_OPTIC_GREEN_1,
5338 EL_DF_FIBRE_OPTIC_BLUE_1,
5340 EL_DF_STEEL_GRID_FIXED_START,
5341 EL_DF_STEEL_GRID_ROTATING_START,
5342 EL_DF_WOODEN_GRID_FIXED_START,
5343 EL_DF_WOODEN_GRID_ROTATING_START,
5355 static int *editor_hl_deflektor_ptr = editor_hl_deflektor;
5356 static int *editor_el_deflektor_ptr = editor_el_deflektor;
5357 static int num_editor_hl_deflektor = ARRAY_SIZE(editor_hl_deflektor);
5358 static int num_editor_el_deflektor = ARRAY_SIZE(editor_el_deflektor);
5360 static int editor_hl_chars[] =
5362 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
5368 static int editor_el_chars[] =
5450 EL_CHAR(CHAR_BYTE_COPYRIGHT),
5451 EL_CHAR(CHAR_BYTE_UMLAUT_A),
5452 EL_CHAR(CHAR_BYTE_UMLAUT_O),
5453 EL_CHAR(CHAR_BYTE_UMLAUT_U),
5455 EL_CHAR(CHAR_BYTE_DEGREE),
5456 EL_CHAR(CHAR_BYTE_REGISTERED),
5457 EL_CHAR(FONT_ASCII_CURSOR),
5458 EL_CHAR(FONT_ASCII_BUTTON),
5460 EL_CHAR(FONT_ASCII_UP),
5461 EL_CHAR(FONT_ASCII_DOWN),
5465 static int *editor_hl_chars_ptr = editor_hl_chars;
5466 static int *editor_el_chars_ptr = editor_el_chars;
5467 static int num_editor_hl_chars = ARRAY_SIZE(editor_hl_chars);
5468 static int num_editor_el_chars = ARRAY_SIZE(editor_el_chars);
5470 static int editor_hl_steel_chars[] =
5472 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
5478 static int editor_el_steel_chars[] =
5488 EL_STEEL_CHAR('\''),
5555 EL_STEEL_CHAR('\\'),
5560 EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
5561 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
5562 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
5563 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
5565 EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
5566 EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
5567 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
5568 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
5570 EL_STEEL_CHAR(FONT_ASCII_UP),
5571 EL_STEEL_CHAR(FONT_ASCII_DOWN),
5575 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
5576 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
5577 static int num_editor_hl_steel_chars = ARRAY_SIZE(editor_hl_steel_chars);
5578 static int num_editor_el_steel_chars = ARRAY_SIZE(editor_el_steel_chars);
5580 static int editor_hl_custom[] =
5582 EL_INTERNAL_CASCADE_CE_ACTIVE,
5588 static int editor_el_custom[] =
5590 EL_CUSTOM_START + 0,
5591 EL_CUSTOM_START + 1,
5592 EL_CUSTOM_START + 2,
5593 EL_CUSTOM_START + 3,
5595 EL_CUSTOM_START + 4,
5596 EL_CUSTOM_START + 5,
5597 EL_CUSTOM_START + 6,
5598 EL_CUSTOM_START + 7,
5600 EL_CUSTOM_START + 8,
5601 EL_CUSTOM_START + 9,
5602 EL_CUSTOM_START + 10,
5603 EL_CUSTOM_START + 11,
5605 EL_CUSTOM_START + 12,
5606 EL_CUSTOM_START + 13,
5607 EL_CUSTOM_START + 14,
5608 EL_CUSTOM_START + 15,
5610 EL_CUSTOM_START + 16,
5611 EL_CUSTOM_START + 17,
5612 EL_CUSTOM_START + 18,
5613 EL_CUSTOM_START + 19,
5615 EL_CUSTOM_START + 20,
5616 EL_CUSTOM_START + 21,
5617 EL_CUSTOM_START + 22,
5618 EL_CUSTOM_START + 23,
5620 EL_CUSTOM_START + 24,
5621 EL_CUSTOM_START + 25,
5622 EL_CUSTOM_START + 26,
5623 EL_CUSTOM_START + 27,
5625 EL_CUSTOM_START + 28,
5626 EL_CUSTOM_START + 29,
5627 EL_CUSTOM_START + 30,
5628 EL_CUSTOM_START + 31,
5630 EL_CUSTOM_START + 32,
5631 EL_CUSTOM_START + 33,
5632 EL_CUSTOM_START + 34,
5633 EL_CUSTOM_START + 35,
5635 EL_CUSTOM_START + 36,
5636 EL_CUSTOM_START + 37,
5637 EL_CUSTOM_START + 38,
5638 EL_CUSTOM_START + 39,
5640 EL_CUSTOM_START + 40,
5641 EL_CUSTOM_START + 41,
5642 EL_CUSTOM_START + 42,
5643 EL_CUSTOM_START + 43,
5645 EL_CUSTOM_START + 44,
5646 EL_CUSTOM_START + 45,
5647 EL_CUSTOM_START + 46,
5648 EL_CUSTOM_START + 47,
5650 EL_CUSTOM_START + 48,
5651 EL_CUSTOM_START + 49,
5652 EL_CUSTOM_START + 50,
5653 EL_CUSTOM_START + 51,
5655 EL_CUSTOM_START + 52,
5656 EL_CUSTOM_START + 53,
5657 EL_CUSTOM_START + 54,
5658 EL_CUSTOM_START + 55,
5660 EL_CUSTOM_START + 56,
5661 EL_CUSTOM_START + 57,
5662 EL_CUSTOM_START + 58,
5663 EL_CUSTOM_START + 59,
5665 EL_CUSTOM_START + 60,
5666 EL_CUSTOM_START + 61,
5667 EL_CUSTOM_START + 62,
5668 EL_CUSTOM_START + 63,
5670 EL_CUSTOM_START + 64,
5671 EL_CUSTOM_START + 65,
5672 EL_CUSTOM_START + 66,
5673 EL_CUSTOM_START + 67,
5675 EL_CUSTOM_START + 68,
5676 EL_CUSTOM_START + 69,
5677 EL_CUSTOM_START + 70,
5678 EL_CUSTOM_START + 71,
5680 EL_CUSTOM_START + 72,
5681 EL_CUSTOM_START + 73,
5682 EL_CUSTOM_START + 74,
5683 EL_CUSTOM_START + 75,
5685 EL_CUSTOM_START + 76,
5686 EL_CUSTOM_START + 77,
5687 EL_CUSTOM_START + 78,
5688 EL_CUSTOM_START + 79,
5690 EL_CUSTOM_START + 80,
5691 EL_CUSTOM_START + 81,
5692 EL_CUSTOM_START + 82,
5693 EL_CUSTOM_START + 83,
5695 EL_CUSTOM_START + 84,
5696 EL_CUSTOM_START + 85,
5697 EL_CUSTOM_START + 86,
5698 EL_CUSTOM_START + 87,
5700 EL_CUSTOM_START + 88,
5701 EL_CUSTOM_START + 89,
5702 EL_CUSTOM_START + 90,
5703 EL_CUSTOM_START + 91,
5705 EL_CUSTOM_START + 92,
5706 EL_CUSTOM_START + 93,
5707 EL_CUSTOM_START + 94,
5708 EL_CUSTOM_START + 95,
5710 EL_CUSTOM_START + 96,
5711 EL_CUSTOM_START + 97,
5712 EL_CUSTOM_START + 98,
5713 EL_CUSTOM_START + 99,
5715 EL_CUSTOM_START + 100,
5716 EL_CUSTOM_START + 101,
5717 EL_CUSTOM_START + 102,
5718 EL_CUSTOM_START + 103,
5720 EL_CUSTOM_START + 104,
5721 EL_CUSTOM_START + 105,
5722 EL_CUSTOM_START + 106,
5723 EL_CUSTOM_START + 107,
5725 EL_CUSTOM_START + 108,
5726 EL_CUSTOM_START + 109,
5727 EL_CUSTOM_START + 110,
5728 EL_CUSTOM_START + 111,
5730 EL_CUSTOM_START + 112,
5731 EL_CUSTOM_START + 113,
5732 EL_CUSTOM_START + 114,
5733 EL_CUSTOM_START + 115,
5735 EL_CUSTOM_START + 116,
5736 EL_CUSTOM_START + 117,
5737 EL_CUSTOM_START + 118,
5738 EL_CUSTOM_START + 119,
5740 EL_CUSTOM_START + 120,
5741 EL_CUSTOM_START + 121,
5742 EL_CUSTOM_START + 122,
5743 EL_CUSTOM_START + 123,
5745 EL_CUSTOM_START + 124,
5746 EL_CUSTOM_START + 125,
5747 EL_CUSTOM_START + 126,
5748 EL_CUSTOM_START + 127,
5750 EL_CUSTOM_START + 128,
5751 EL_CUSTOM_START + 129,
5752 EL_CUSTOM_START + 130,
5753 EL_CUSTOM_START + 131,
5755 EL_CUSTOM_START + 132,
5756 EL_CUSTOM_START + 133,
5757 EL_CUSTOM_START + 134,
5758 EL_CUSTOM_START + 135,
5760 EL_CUSTOM_START + 136,
5761 EL_CUSTOM_START + 137,
5762 EL_CUSTOM_START + 138,
5763 EL_CUSTOM_START + 139,
5765 EL_CUSTOM_START + 140,
5766 EL_CUSTOM_START + 141,
5767 EL_CUSTOM_START + 142,
5768 EL_CUSTOM_START + 143,
5770 EL_CUSTOM_START + 144,
5771 EL_CUSTOM_START + 145,
5772 EL_CUSTOM_START + 146,
5773 EL_CUSTOM_START + 147,
5775 EL_CUSTOM_START + 148,
5776 EL_CUSTOM_START + 149,
5777 EL_CUSTOM_START + 150,
5778 EL_CUSTOM_START + 151,
5780 EL_CUSTOM_START + 152,
5781 EL_CUSTOM_START + 153,
5782 EL_CUSTOM_START + 154,
5783 EL_CUSTOM_START + 155,
5785 EL_CUSTOM_START + 156,
5786 EL_CUSTOM_START + 157,
5787 EL_CUSTOM_START + 158,
5788 EL_CUSTOM_START + 159,
5790 EL_CUSTOM_START + 160,
5791 EL_CUSTOM_START + 161,
5792 EL_CUSTOM_START + 162,
5793 EL_CUSTOM_START + 163,
5795 EL_CUSTOM_START + 164,
5796 EL_CUSTOM_START + 165,
5797 EL_CUSTOM_START + 166,
5798 EL_CUSTOM_START + 167,
5800 EL_CUSTOM_START + 168,
5801 EL_CUSTOM_START + 169,
5802 EL_CUSTOM_START + 170,
5803 EL_CUSTOM_START + 171,
5805 EL_CUSTOM_START + 172,
5806 EL_CUSTOM_START + 173,
5807 EL_CUSTOM_START + 174,
5808 EL_CUSTOM_START + 175,
5810 EL_CUSTOM_START + 176,
5811 EL_CUSTOM_START + 177,
5812 EL_CUSTOM_START + 178,
5813 EL_CUSTOM_START + 179,
5815 EL_CUSTOM_START + 180,
5816 EL_CUSTOM_START + 181,
5817 EL_CUSTOM_START + 182,
5818 EL_CUSTOM_START + 183,
5820 EL_CUSTOM_START + 184,
5821 EL_CUSTOM_START + 185,
5822 EL_CUSTOM_START + 186,
5823 EL_CUSTOM_START + 187,
5825 EL_CUSTOM_START + 188,
5826 EL_CUSTOM_START + 189,
5827 EL_CUSTOM_START + 190,
5828 EL_CUSTOM_START + 191,
5830 EL_CUSTOM_START + 192,
5831 EL_CUSTOM_START + 193,
5832 EL_CUSTOM_START + 194,
5833 EL_CUSTOM_START + 195,
5835 EL_CUSTOM_START + 196,
5836 EL_CUSTOM_START + 197,
5837 EL_CUSTOM_START + 198,
5838 EL_CUSTOM_START + 199,
5840 EL_CUSTOM_START + 200,
5841 EL_CUSTOM_START + 201,
5842 EL_CUSTOM_START + 202,
5843 EL_CUSTOM_START + 203,
5845 EL_CUSTOM_START + 204,
5846 EL_CUSTOM_START + 205,
5847 EL_CUSTOM_START + 206,
5848 EL_CUSTOM_START + 207,
5850 EL_CUSTOM_START + 208,
5851 EL_CUSTOM_START + 209,
5852 EL_CUSTOM_START + 210,
5853 EL_CUSTOM_START + 211,
5855 EL_CUSTOM_START + 212,
5856 EL_CUSTOM_START + 213,
5857 EL_CUSTOM_START + 214,
5858 EL_CUSTOM_START + 215,
5860 EL_CUSTOM_START + 216,
5861 EL_CUSTOM_START + 217,
5862 EL_CUSTOM_START + 218,
5863 EL_CUSTOM_START + 219,
5865 EL_CUSTOM_START + 220,
5866 EL_CUSTOM_START + 221,
5867 EL_CUSTOM_START + 222,
5868 EL_CUSTOM_START + 223,
5870 EL_CUSTOM_START + 224,
5871 EL_CUSTOM_START + 225,
5872 EL_CUSTOM_START + 226,
5873 EL_CUSTOM_START + 227,
5875 EL_CUSTOM_START + 228,
5876 EL_CUSTOM_START + 229,
5877 EL_CUSTOM_START + 230,
5878 EL_CUSTOM_START + 231,
5880 EL_CUSTOM_START + 232,
5881 EL_CUSTOM_START + 233,
5882 EL_CUSTOM_START + 234,
5883 EL_CUSTOM_START + 235,
5885 EL_CUSTOM_START + 236,
5886 EL_CUSTOM_START + 237,
5887 EL_CUSTOM_START + 238,
5888 EL_CUSTOM_START + 239,
5890 EL_CUSTOM_START + 240,
5891 EL_CUSTOM_START + 241,
5892 EL_CUSTOM_START + 242,
5893 EL_CUSTOM_START + 243,
5895 EL_CUSTOM_START + 244,
5896 EL_CUSTOM_START + 245,
5897 EL_CUSTOM_START + 246,
5898 EL_CUSTOM_START + 247,
5900 EL_CUSTOM_START + 248,
5901 EL_CUSTOM_START + 249,
5902 EL_CUSTOM_START + 250,
5903 EL_CUSTOM_START + 251,
5905 EL_CUSTOM_START + 252,
5906 EL_CUSTOM_START + 253,
5907 EL_CUSTOM_START + 254,
5908 EL_CUSTOM_START + 255
5910 static int *editor_hl_custom_ptr = editor_hl_custom;
5911 static int *editor_el_custom_ptr = editor_el_custom;
5912 static int num_editor_hl_custom = ARRAY_SIZE(editor_hl_custom);
5913 static int num_editor_el_custom = ARRAY_SIZE(editor_el_custom);
5915 static int editor_hl_group[] =
5917 EL_INTERNAL_CASCADE_GE_ACTIVE,
5923 static int editor_el_group[] =
5937 EL_GROUP_START + 10,
5938 EL_GROUP_START + 11,
5940 EL_GROUP_START + 12,
5941 EL_GROUP_START + 13,
5942 EL_GROUP_START + 14,
5943 EL_GROUP_START + 15,
5945 EL_GROUP_START + 16,
5946 EL_GROUP_START + 17,
5947 EL_GROUP_START + 18,
5948 EL_GROUP_START + 19,
5950 EL_GROUP_START + 20,
5951 EL_GROUP_START + 21,
5952 EL_GROUP_START + 22,
5953 EL_GROUP_START + 23,
5955 EL_GROUP_START + 24,
5956 EL_GROUP_START + 25,
5957 EL_GROUP_START + 26,
5958 EL_GROUP_START + 27,
5960 EL_GROUP_START + 28,
5961 EL_GROUP_START + 29,
5962 EL_GROUP_START + 30,
5965 static int *editor_hl_group_ptr = editor_hl_group;
5966 static int *editor_el_group_ptr = editor_el_group;
5967 static int num_editor_hl_group = ARRAY_SIZE(editor_hl_group);
5968 static int num_editor_el_group = ARRAY_SIZE(editor_el_group);
5970 static int editor_hl_empty_space[] =
5972 EL_INTERNAL_CASCADE_ES_ACTIVE,
5978 static int editor_el_empty_space[] =
6000 static int *editor_hl_empty_space_ptr = editor_hl_empty_space;
6001 static int *editor_el_empty_space_ptr = editor_el_empty_space;
6002 static int num_editor_hl_empty_space = ARRAY_SIZE(editor_hl_empty_space);
6003 static int num_editor_el_empty_space = ARRAY_SIZE(editor_el_empty_space);
6005 static int editor_hl_reference[] =
6007 EL_INTERNAL_CASCADE_REF_ACTIVE,
6013 static int editor_el_reference[] =
6017 EL_TRIGGER_CE_VALUE,
6018 EL_TRIGGER_CE_SCORE,
6022 EL_CURRENT_CE_VALUE,
6023 EL_CURRENT_CE_SCORE,
6045 static int *editor_hl_reference_ptr = editor_hl_reference;
6046 static int *editor_el_reference_ptr = editor_el_reference;
6047 static int num_editor_hl_reference = ARRAY_SIZE(editor_hl_reference);
6048 static int num_editor_el_reference = ARRAY_SIZE(editor_el_reference);
6050 static int editor_hl_user_defined[] =
6052 EL_INTERNAL_CASCADE_USER_ACTIVE,
6058 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
6059 static int *editor_el_user_defined_ptr = NULL;
6060 static int num_editor_hl_user_defined = ARRAY_SIZE(editor_hl_user_defined);
6061 static int num_editor_el_user_defined = 0;
6063 static int editor_hl_dynamic[] =
6065 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
6071 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
6072 static int *editor_el_dynamic_ptr = NULL;
6073 static int num_editor_hl_dynamic = ARRAY_SIZE(editor_hl_dynamic);
6074 static int num_editor_el_dynamic = 0;
6076 static int editor_hl_empty[] = { EL_EMPTY };
6077 static int *editor_el_empty = NULL; // dynamically allocated
6079 static int *editor_hl_empty_ptr = editor_hl_empty;
6080 static int *editor_el_empty_ptr = NULL;
6081 static int num_editor_hl_empty = 0;
6082 static int num_editor_el_empty = 0; // dynamically determined, if needed
6084 static boolean use_el_empty = FALSE;
6086 static int *editor_elements = NULL; // dynamically allocated
6087 static int num_editor_elements = 0; // dynamically determined
6089 static boolean setup_editor_cascade_never = FALSE;
6091 static boolean setup_editor_el_players = TRUE;
6092 static boolean setup_editor_el_boulderdash = TRUE;
6093 static boolean setup_editor_el_boulderdash_native = TRUE;
6094 static boolean setup_editor_el_emerald_mine = TRUE;
6095 static boolean setup_editor_el_emerald_mine_club = TRUE;
6096 static boolean setup_editor_el_more = TRUE;
6097 static boolean setup_editor_el_sokoban = TRUE;
6098 static boolean setup_editor_el_supaplex = TRUE;
6099 static boolean setup_editor_el_diamond_caves = TRUE;
6100 static boolean setup_editor_el_dx_boulderdash = TRUE;
6101 static boolean setup_editor_el_mirror_magic = TRUE;
6102 static boolean setup_editor_el_deflektor = TRUE;
6103 static boolean setup_editor_el_chars = TRUE;
6104 static boolean setup_editor_el_steel_chars = TRUE;
6105 static boolean setup_editor_el_custom = TRUE;
6106 static boolean setup_editor_el_user_defined = TRUE;
6107 static boolean setup_editor_el_dynamic = TRUE;
6109 static int editor_hl_unused[] = { EL_EMPTY };
6110 static int *editor_hl_unused_ptr = editor_hl_unused;
6111 static int num_editor_hl_unused = 0;
6115 boolean *setup_value;
6116 boolean *setup_cascade_value;
6118 int **headline_list;
6119 int *headline_list_size;
6122 int *element_list_size;
6124 boolean last_setup_value;
6126 editor_elements_info[] =
6129 &setup_editor_el_players,
6130 &setup_editor_cascade_never,
6131 &editor_hl_unused_ptr, &num_editor_hl_unused,
6132 &editor_el_players_ptr, &num_editor_el_players
6135 &setup_editor_el_boulderdash,
6136 &setup.editor_cascade.el_bd,
6137 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
6138 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
6141 &setup_editor_el_boulderdash_native,
6142 &setup.editor_cascade.el_bd_native,
6143 &editor_hl_boulderdash_native_ptr, &num_editor_hl_boulderdash_native,
6144 &editor_el_boulderdash_native_ptr, &num_editor_el_boulderdash_native
6147 &setup_editor_el_emerald_mine,
6148 &setup.editor_cascade.el_em,
6149 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
6150 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
6153 &setup_editor_el_emerald_mine_club,
6154 &setup.editor_cascade.el_emc,
6155 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
6156 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
6159 &setup_editor_el_more,
6160 &setup.editor_cascade.el_rnd,
6161 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
6162 &editor_el_rnd_ptr, &num_editor_el_rnd
6165 &setup_editor_el_sokoban,
6166 &setup.editor_cascade.el_sb,
6167 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
6168 &editor_el_sokoban_ptr, &num_editor_el_sokoban
6171 &setup_editor_el_supaplex,
6172 &setup.editor_cascade.el_sp,
6173 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
6174 &editor_el_supaplex_ptr, &num_editor_el_supaplex
6177 &setup_editor_el_diamond_caves,
6178 &setup.editor_cascade.el_dc,
6179 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
6180 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
6183 &setup_editor_el_dx_boulderdash,
6184 &setup.editor_cascade.el_dx,
6185 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
6186 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
6189 &setup_editor_el_mirror_magic,
6190 &setup.editor_cascade.el_mm,
6191 &editor_hl_mirror_magic_ptr, &num_editor_hl_mirror_magic,
6192 &editor_el_mirror_magic_ptr, &num_editor_el_mirror_magic
6195 &setup_editor_el_deflektor,
6196 &setup.editor_cascade.el_df,
6197 &editor_hl_deflektor_ptr, &num_editor_hl_deflektor,
6198 &editor_el_deflektor_ptr, &num_editor_el_deflektor
6201 &setup_editor_el_chars,
6202 &setup.editor_cascade.el_chars,
6203 &editor_hl_chars_ptr, &num_editor_hl_chars,
6204 &editor_el_chars_ptr, &num_editor_el_chars
6207 &setup_editor_el_steel_chars,
6208 &setup.editor_cascade.el_steel_chars,
6209 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
6210 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
6213 &setup_editor_el_custom,
6214 &setup.editor_cascade.el_ce,
6215 &editor_hl_custom_ptr, &num_editor_hl_custom,
6216 &editor_el_custom_ptr, &num_editor_el_custom
6219 &setup_editor_el_custom,
6220 &setup.editor_cascade.el_ge,
6221 &editor_hl_group_ptr, &num_editor_hl_group,
6222 &editor_el_group_ptr, &num_editor_el_group
6225 &setup_editor_el_custom,
6226 &setup.editor_cascade.el_es,
6227 &editor_hl_empty_space_ptr, &num_editor_hl_empty_space,
6228 &editor_el_empty_space_ptr, &num_editor_el_empty_space
6231 &setup_editor_el_custom,
6232 &setup.editor_cascade.el_ref,
6233 &editor_hl_reference_ptr, &num_editor_hl_reference,
6234 &editor_el_reference_ptr, &num_editor_el_reference
6237 &setup_editor_el_user_defined,
6238 &setup.editor_cascade.el_user,
6239 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
6240 &editor_el_user_defined_ptr, &num_editor_el_user_defined
6243 &setup_editor_el_dynamic,
6244 &setup.editor_cascade.el_dynamic,
6245 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
6246 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
6251 &editor_hl_empty_ptr, &num_editor_hl_empty,
6252 &editor_el_empty_ptr, &num_editor_el_empty,
6262 static struct XY xy_directions[] =
6271 // ----------------------------------------------------------------------------
6273 // ----------------------------------------------------------------------------
6275 static int getMaxInfoTextLength(void)
6277 return (SXSIZE / getFontWidth(INFOTEXT_FONT));
6280 static int getTextWidthForGadget(char *text)
6285 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
6288 static int getTextWidthForDrawingArea(char *text)
6293 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
6296 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
6298 return (gi->x + gi->width + getTextWidthForGadget(text));
6301 static char *getElementInfoText(int element)
6303 char *info_text = NULL;
6305 if (element < MAX_NUM_ELEMENTS)
6307 if (strlen(element_info[element].description) > 0)
6308 info_text = element_info[element].description;
6309 else if (element_info[element].custom_description != NULL)
6310 info_text = element_info[element].custom_description;
6311 else if (element_info[element].editor_description != NULL)
6312 info_text = element_info[element].editor_description;
6315 if (info_text == NULL)
6316 info_text = INFOTEXT_UNKNOWN_ELEMENT;
6321 static char *getElementDescriptionFilenameExt(char *basename)
6323 char *elements_subdir = ELEMENTS_DIRECTORY;
6324 static char *elements_subdir2 = NULL;
6325 static char *filename = NULL;
6327 if (elements_subdir2 == NULL)
6328 elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
6330 checked_free(filename);
6332 // 1st try: look for element description in current level set directory
6333 filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
6334 if (fileExists(filename))
6339 // 2nd try: look for element description in the game's base directory
6340 filename = getPath3(options.docs_directory, elements_subdir, basename);
6341 if (fileExists(filename))
6347 static char *getElementDescriptionFilename(int element)
6349 char basename[MAX_FILENAME_LEN];
6352 // 1st try: look for element description file for exactly this element
6353 sprintf(basename, "%s.txt", element_info[element].token_name);
6354 filename = getElementDescriptionFilenameExt(basename);
6355 if (filename != NULL)
6358 // 2nd try: look for element description file for this element's class
6359 sprintf(basename, "%s.txt", element_info[element].class_name);
6360 filename = getElementDescriptionFilenameExt(basename);
6361 if (filename != NULL)
6364 // 3rd try: look for generic fallback text file for any element
6365 filename = getElementDescriptionFilenameExt(FALLBACK_TEXT_FILENAME);
6366 if (filename != NULL)
6372 static boolean suppressBorderElement(void)
6374 return (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
6375 lev_fieldx <= MAX_ED_FIELDX &&
6376 lev_fieldy <= MAX_ED_FIELDY);
6379 static void InitDynamicEditorElementList(int **elements, int *num_elements)
6381 boolean element_found[NUM_FILE_ELEMENTS];
6384 // initialize list of used elements to "not used"
6385 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6386 element_found[i] = FALSE;
6388 // find all elements used in current level
6389 for (y = 0; y < lev_fieldy; y++)
6391 for (x = 0; x < lev_fieldx; x++)
6393 if (Tile[x][y] >= NUM_FILE_ELEMENTS) // should never happen
6396 if (IS_MM_WALL(Tile[x][y]))
6397 element_found[map_mm_wall_element(Tile[x][y])] = TRUE;
6399 element_found[Tile[x][y]] = TRUE;
6405 // count number of elements used in current level
6406 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6407 if (element_found[i])
6410 // add space for up to 3 more elements for padding that may be needed
6413 // free memory for old list of elements, if needed
6414 checked_free(*elements);
6416 // allocate memory for new list of elements
6417 *elements = checked_malloc(*num_elements * sizeof(int));
6421 // add all elements used in current level (non-custom/group/empty elements)
6422 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6423 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) ||
6424 IS_GROUP_ELEMENT(i) ||
6425 IS_EMPTY_ELEMENT(i)))
6426 (*elements)[(*num_elements)++] = i;
6428 // add all elements used in current level (custom/group/empty elements)
6429 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6430 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) ||
6431 IS_GROUP_ELEMENT(i) ||
6432 IS_EMPTY_ELEMENT(i)))
6433 (*elements)[(*num_elements)++] = i;
6435 while (*num_elements % 4) // pad with empty elements, if needed
6436 (*elements)[(*num_elements)++] = EL_EMPTY;
6439 static void ReinitializeElementList_EnableSections(void)
6441 // default: enable all element sections
6443 setup_editor_el_players = TRUE;
6444 setup_editor_el_boulderdash = TRUE;
6445 setup_editor_el_boulderdash_native = TRUE;
6446 setup_editor_el_emerald_mine = TRUE;
6447 setup_editor_el_emerald_mine_club = TRUE;
6448 setup_editor_el_more = TRUE;
6449 setup_editor_el_sokoban = TRUE;
6450 setup_editor_el_supaplex = TRUE;
6451 setup_editor_el_diamond_caves = TRUE;
6452 setup_editor_el_dx_boulderdash = TRUE;
6453 setup_editor_el_mirror_magic = TRUE;
6454 setup_editor_el_deflektor = TRUE;
6455 setup_editor_el_chars = TRUE;
6456 setup_editor_el_steel_chars = TRUE;
6458 setup_editor_el_custom = TRUE;
6459 setup_editor_el_user_defined = TRUE;
6460 setup_editor_el_dynamic = TRUE;
6462 // now disable all element sections not to be displayed
6464 if (!setup.editor.el_classic)
6466 setup_editor_el_players = FALSE;
6467 setup_editor_el_boulderdash = FALSE;
6468 setup_editor_el_boulderdash_native = FALSE;
6469 setup_editor_el_emerald_mine = FALSE;
6470 setup_editor_el_emerald_mine_club = FALSE;
6471 setup_editor_el_more = FALSE;
6472 setup_editor_el_sokoban = FALSE;
6473 setup_editor_el_supaplex = FALSE;
6474 setup_editor_el_diamond_caves = FALSE;
6475 setup_editor_el_dx_boulderdash = FALSE;
6476 setup_editor_el_mirror_magic = FALSE;
6477 setup_editor_el_deflektor = FALSE;
6478 setup_editor_el_chars = FALSE;
6479 setup_editor_el_steel_chars = FALSE;
6482 if (!setup.editor.el_custom)
6484 setup_editor_el_custom = FALSE;
6487 if (!setup.editor.el_user_defined)
6489 setup_editor_el_user_defined = FALSE;
6492 if (!setup.editor.el_dynamic)
6494 setup_editor_el_dynamic = FALSE;
6497 if (level.game_engine_type == GAME_ENGINE_TYPE_RND)
6499 setup_editor_el_boulderdash_native = FALSE;
6500 setup_editor_el_mirror_magic = FALSE;
6501 setup_editor_el_deflektor = FALSE;
6503 else if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
6505 setup_editor_el_players = FALSE;
6506 setup_editor_el_boulderdash = FALSE;
6507 setup_editor_el_emerald_mine = FALSE;
6508 setup_editor_el_emerald_mine_club = FALSE;
6509 setup_editor_el_more = FALSE;
6510 setup_editor_el_sokoban = FALSE;
6511 setup_editor_el_supaplex = FALSE;
6512 setup_editor_el_diamond_caves = FALSE;
6513 setup_editor_el_dx_boulderdash = FALSE;
6514 setup_editor_el_mirror_magic = FALSE;
6515 setup_editor_el_deflektor = FALSE;
6516 setup_editor_el_chars = FALSE;
6517 setup_editor_el_steel_chars = FALSE;
6519 setup_editor_el_custom = FALSE;
6521 else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
6523 setup_editor_el_boulderdash = FALSE;
6524 setup_editor_el_boulderdash_native = FALSE;
6525 setup_editor_el_more = FALSE;
6526 setup_editor_el_sokoban = FALSE;
6527 setup_editor_el_supaplex = FALSE;
6528 setup_editor_el_diamond_caves = FALSE;
6529 setup_editor_el_dx_boulderdash = FALSE;
6530 setup_editor_el_mirror_magic = FALSE;
6531 setup_editor_el_deflektor = FALSE;
6532 setup_editor_el_steel_chars = FALSE;
6534 setup_editor_el_custom = FALSE;
6536 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
6538 setup_editor_el_players = FALSE;
6539 setup_editor_el_boulderdash = FALSE;
6540 setup_editor_el_boulderdash_native = FALSE;
6541 setup_editor_el_emerald_mine = FALSE;
6542 setup_editor_el_emerald_mine_club = FALSE;
6543 setup_editor_el_more = FALSE;
6544 setup_editor_el_sokoban = FALSE;
6545 setup_editor_el_diamond_caves = FALSE;
6546 setup_editor_el_dx_boulderdash = FALSE;
6547 setup_editor_el_mirror_magic = FALSE;
6548 setup_editor_el_deflektor = FALSE;
6549 setup_editor_el_chars = FALSE;
6550 setup_editor_el_steel_chars = FALSE;
6552 setup_editor_el_custom = FALSE;
6554 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
6556 setup_editor_el_players = FALSE;
6557 setup_editor_el_boulderdash = FALSE;
6558 setup_editor_el_boulderdash_native = FALSE;
6559 setup_editor_el_emerald_mine = FALSE;
6560 setup_editor_el_emerald_mine_club = FALSE;
6561 setup_editor_el_more = FALSE;
6562 setup_editor_el_sokoban = FALSE;
6563 setup_editor_el_supaplex = FALSE;
6564 setup_editor_el_diamond_caves = FALSE;
6565 setup_editor_el_dx_boulderdash = FALSE;
6566 setup_editor_el_steel_chars = FALSE;
6568 setup_editor_el_custom = FALSE;
6572 static void ReinitializeElementList(void)
6574 static boolean initialization_needed = TRUE;
6578 ReinitializeElementList_EnableSections();
6580 if (initialization_needed)
6582 LoadSetup_EditorCascade(); // load last editor cascade state
6584 // initialize editor cascade element from saved cascade state
6585 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6587 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
6588 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
6590 if (IS_EDITOR_CASCADE(*cascade_element))
6592 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
6593 EL_CASCADE_INACTIVE(*cascade_element));
6596 initialization_needed = FALSE;
6599 checked_free(editor_elements);
6601 // reload optional user defined element list for each invocation of editor
6602 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
6603 &num_editor_el_user_defined);
6605 // initialize dynamic level element list for each invocation of editor
6606 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
6607 &num_editor_el_dynamic);
6609 // initialize list of empty elements (used for padding, if needed)
6610 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6611 editor_el_empty[i] = EL_EMPTY;
6613 // do some sanity checks for each element from element list
6614 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6616 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6618 int element = (*editor_elements_info[i].element_list)[j];
6620 if (element >= NUM_FILE_ELEMENTS)
6621 Warn("editor element %d is runtime element", element);
6623 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
6624 Warn("no element description text for element %d", element);
6628 num_editor_elements = 0;
6629 use_el_empty = FALSE;
6631 // determine size of element list
6632 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6634 if (*editor_elements_info[i].setup_value)
6636 boolean found_inactive_cascade = FALSE;
6638 if (setup.editor.el_headlines)
6640 // required for correct padding of palette headline buttons
6641 if (*editor_elements_info[i].headline_list_size > 0)
6642 num_editor_elements += ED_ELEMENTLIST_COLS;
6644 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6646 int element = (*editor_elements_info[i].headline_list)[j];
6648 if (IS_EDITOR_CASCADE_INACTIVE(element))
6649 found_inactive_cascade = TRUE;
6653 if (found_inactive_cascade)
6656 // required for correct padding of palette element buttons
6657 int element_list_size = *editor_elements_info[i].element_list_size;
6659 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6660 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6662 num_editor_elements += element_buttons;
6666 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
6668 // offer at least as many elements as element buttons exist
6669 use_el_empty = TRUE;
6670 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
6672 num_editor_elements += num_editor_el_empty;
6676 num_editor_el_empty = 0;
6679 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
6681 // fill element list
6682 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6684 boolean found_inactive_cascade = FALSE;
6686 if (*editor_elements_info[i].setup_value)
6688 if (setup.editor.el_headlines)
6690 // required for correct padding of palette headline buttons
6691 int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
6692 ED_ELEMENTLIST_COLS : 0);
6694 for (j = 0; j < headline_size; j++)
6696 // use empty elements for padding of palette headline buttons
6697 int element = (j < *editor_elements_info[i].headline_list_size ?
6698 (*editor_elements_info[i].headline_list)[j] :
6699 editor_el_empty[0]);
6701 editor_elements[pos++] = element;
6703 if (IS_EDITOR_CASCADE_INACTIVE(element))
6704 found_inactive_cascade = TRUE;
6708 if (found_inactive_cascade)
6711 // required for correct padding of palette element buttons
6712 int element_list_size = *editor_elements_info[i].element_list_size;
6714 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6715 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6717 // copy all elements from element list
6718 for (j = 0; j < element_list_size; j++)
6719 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
6721 // use empty elements for padding of palette element buttons
6722 for (j = 0; j < element_buttons - element_list_size; j++)
6723 editor_elements[pos++] = editor_el_empty[0];
6727 // (this function is also called before editor gadgets are initialized!)
6728 AdjustElementListScrollbar();
6731 void PrintEditorElementList(void)
6733 boolean *stop = &setup_editor_el_user_defined;
6736 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
6738 int cascade_element = (*editor_elements_info[i].headline_list)[0];
6740 if (IS_EDITOR_CASCADE(cascade_element))
6742 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
6743 char *headline = element_info[cascade_element_show].editor_description;
6745 PrintLineWithPrefix("# ", "-", 77);
6746 Print("# %s\n", headline);
6747 PrintLineWithPrefix("# ", "-", 77);
6750 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6752 int element = (*editor_elements_info[i].headline_list)[j];
6754 if (IS_EDITOR_CASCADE(element))
6755 element = EL_CHAR_MINUS;
6757 Print("# %s\n", element_info[element].token_name);
6763 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6765 int element = (*editor_elements_info[i].element_list)[j];
6767 Print("# %s\n", element_info[element].token_name);
6775 static void ReinitializeElementListButtons(void)
6777 static boolean last_setup_value_headlines = FALSE;
6778 static boolean initialization_needed = TRUE;
6781 if (!initialization_needed) // check if editor element setup has changed
6783 if (last_setup_value_headlines != setup.editor.el_headlines)
6784 initialization_needed = TRUE;
6786 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6787 if (editor_elements_info[i].last_setup_value !=
6788 *editor_elements_info[i].setup_value)
6789 initialization_needed = TRUE;
6792 if (!initialization_needed)
6795 FreeLevelEditorGadgets();
6796 CreateLevelEditorGadgets();
6798 // store current setup values for next invocation of this function
6799 last_setup_value_headlines = setup.editor.el_headlines;
6800 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6801 editor_elements_info[i].last_setup_value =
6802 *editor_elements_info[i].setup_value;
6804 initialization_needed = FALSE;
6807 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
6810 int border_graphic =
6811 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
6812 struct GraphicInfo *g = &graphic_info[border_graphic];
6813 Bitmap *src_bitmap = g->bitmap;
6814 int src_x = g->src_x;
6815 int src_y = g->src_y;
6816 int border_size = g->border_size;
6817 int border_xpos = g->width - border_size;
6818 int border_ypos = g->height - border_size;
6819 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6822 BlitBitmap(src_bitmap, drawto, src_x, src_y,
6823 border_size, border_size,
6824 dest_x - border_size, dest_y - border_size);
6825 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y,
6826 border_size, border_size,
6827 dest_x + width, dest_y - border_size);
6828 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_ypos,
6829 border_size, border_size,
6830 dest_x - border_size, dest_y + height);
6831 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_ypos,
6832 border_size, border_size,
6833 dest_x + width, dest_y + height);
6835 for (i = 0; i < width / tilesize; i++)
6837 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y,
6838 tilesize, border_size,
6839 dest_x + i * tilesize, dest_y - border_size);
6840 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y + border_ypos,
6841 tilesize, border_size,
6842 dest_x + i * tilesize, dest_y + height);
6845 for (i = 0; i < height / tilesize; i++)
6847 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_size,
6848 border_size, tilesize,
6849 dest_x - border_size, dest_y + i * tilesize);
6850 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_size,
6851 border_size, tilesize,
6852 dest_x + width, dest_y + i * tilesize);
6855 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
6858 static void DrawEditorLevelBorderLine(int x, int y, int xsize, int ysize)
6860 int xsize_tile = MAX(ed_tilesize, xsize);
6861 int ysize_tile = MAX(ed_tilesize, ysize);
6862 int xsize_full = xsize + 1;
6863 int ysize_full = ysize + 1;
6864 int xsize_thin = (xsize < ed_tilesize ? 1 : xsize);
6865 int ysize_thin = (ysize < ed_tilesize ? 1 : ysize);
6866 Pixel line_color = getTabulatorBarColor();
6868 if (line_color == BLACK_PIXEL) // black => transparent
6871 FillRectangle(drawto, SX + x, SY + y, xsize_tile, ysize_tile, BLACK_PIXEL);
6872 FillRectangle(drawto, SX + x, SY + y, xsize_full, ysize_full, line_color);
6873 FillRectangle(drawto, SX + x, SY + y, xsize_thin, ysize_thin, BLACK_PIXEL);
6876 static void DrawEditorLevelBorderLinesIfNeeded(void)
6878 int xsize = lev_fieldx * ed_tilesize;
6879 int ysize = lev_fieldy * ed_tilesize;
6880 int line_size = getTabulatorBarHeight();
6882 if (!suppressBorderElement())
6885 // draw little border line around editable level playfield
6888 DrawEditorLevelBorderLine(xsize, 0, line_size, ysize);
6891 DrawEditorLevelBorderLine(0, ysize, xsize, line_size);
6893 if (xsize < SXSIZE && ysize < SYSIZE)
6894 DrawEditorLevelBorderLine(xsize, ysize, line_size, line_size);
6897 static void DrawEditorElement(int x, int y, int element)
6899 DrawSizedElement(x, y, element, ed_tilesize);
6902 static void DrawEditorElementThruMask(int x, int y, int element)
6904 DrawSizedElementThruMask(x, y, element, ed_tilesize);
6907 static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
6909 DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
6912 static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
6914 DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
6915 DrawEditorLevelBorderLinesIfNeeded();
6918 static void DrawDrawingArea(int id)
6920 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6923 int *value = drawingarea_info[id].value;
6924 int area_xsize = drawingarea_info[id].area_xsize;
6925 int area_ysize = drawingarea_info[id].area_ysize;
6926 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6928 for (x = 0; x < area_xsize; x++)
6929 for (y = 0; y < area_ysize; y++)
6930 DrawSizedGraphicExt(drawto,
6931 gi->x + x * tilesize,
6932 gi->y + y * tilesize,
6933 el2edimg(value[x * area_ysize + y]), 0, tilesize);
6936 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
6939 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
6940 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
6942 BlitBitmap(drawto, drawto,
6943 SX + (dx == -1 ? ed_tilesize : 0),
6944 SY + (dy == -1 ? ed_tilesize : 0),
6945 (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
6946 (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
6947 SX + (dx == +1 ? ed_tilesize : 0),
6948 SY + (dy == +1 ? ed_tilesize : 0));
6952 x = (dx == 1 ? 0 : ed_fieldx - 1);
6953 for (y = 0; y < ed_fieldy; y++)
6954 DrawEditorElementOrWall(x, y, from_x, from_y);
6958 y = (dy == 1 ? 0 : ed_fieldy - 1);
6959 for (x = 0; x < ed_fieldx; x++)
6960 DrawEditorElementOrWall(x, y, from_x, from_y);
6963 redraw_mask |= REDRAW_FIELD;
6967 static void getEditorGraphicSource(int element, int tile_size, Bitmap **bitmap,
6970 getSizedGraphicSource(el2edimg(element), 0, tile_size, bitmap, x, y);
6973 static void CreateControlButtons(void)
6975 struct GadgetInfo *gi;
6978 // create toolbox buttons
6979 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6981 int type_id = controlbutton_info[i].gadget_id; // same as gadget ID here
6982 int id = controlbutton_info[i].gadget_id;
6983 int type = controlbutton_info[i].gadget_type;
6984 int graphic = controlbutton_info[i].graphic;
6985 struct XYTileSize *pos = controlbutton_info[i].pos;
6986 struct GraphicInfo *gd = &graphic_info[graphic];
6987 Bitmap *deco_bitmap = NULL;
6988 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
6989 int tile_size = 0, deco_shift = 0;
6990 boolean deco_masked = FALSE;
6991 int gd_x1 = gd->src_x;
6992 int gd_y1 = gd->src_y;
6993 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6994 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6995 int gd_x1a = gd->src_x + gd->active_xoffset;
6996 int gd_y1a = gd->src_y + gd->active_yoffset;
6997 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6998 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7001 unsigned int event_mask;
7002 int radio_button_nr = RADIO_NR_NONE;
7003 boolean checked = FALSE;
7006 Fail("'controlbutton_info' structure corrupted at index %d -- please fix", i);
7008 if (type == GD_TYPE_RADIO_BUTTON)
7010 event_mask = GD_EVENT_PRESSED;
7011 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
7013 if (id == drawing_function)
7018 if (id == GADGET_ID_WRAP_LEFT ||
7019 id == GADGET_ID_WRAP_RIGHT ||
7020 id == GADGET_ID_WRAP_UP ||
7021 id == GADGET_ID_WRAP_DOWN)
7022 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7024 event_mask = GD_EVENT_RELEASED;
7027 if (id == GADGET_ID_PROPERTIES ||
7028 id == GADGET_ID_PALETTE)
7033 else if (id == GADGET_ID_ELEMENT_LEFT ||
7034 id == GADGET_ID_ELEMENT_MIDDLE ||
7035 id == GADGET_ID_ELEMENT_RIGHT)
7040 int element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
7041 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
7042 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : EL_EMPTY);
7044 tile_size = BUTTON_TILE_SIZE(id == GADGET_ID_ELEMENT_LEFT ?
7045 editor.button.element_left.tile_size :
7046 id == GADGET_ID_ELEMENT_MIDDLE ?
7047 editor.button.element_middle.tile_size :
7048 id == GADGET_ID_ELEMENT_RIGHT ?
7049 editor.button.element_right.tile_size : 0);
7051 // make sure that decoration does not overlap gadget border
7052 tile_size = MIN(tile_size, MIN(gd->width, gd->height));
7054 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x,&deco_y);
7056 deco_xpos = (gd->width - tile_size) / 2;
7057 deco_ypos = (gd->height - tile_size) / 2;
7059 deco_masked = gd->draw_masked;
7067 gi = CreateGadget(GDI_CUSTOM_ID, id,
7068 GDI_CUSTOM_TYPE_ID, type_id,
7069 GDI_IMAGE_ID, graphic,
7070 GDI_INFO_TEXT, controlbutton_info[i].infotext,
7073 GDI_WIDTH, gd->width,
7074 GDI_HEIGHT, gd->height,
7076 GDI_STATE, GD_BUTTON_UNPRESSED,
7077 GDI_RADIO_NR, radio_button_nr,
7078 GDI_CHECKED, checked,
7079 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7080 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7081 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7082 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7083 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
7084 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
7085 GDI_DECORATION_SIZE, tile_size, tile_size,
7086 GDI_DECORATION_SHIFTING, deco_shift, deco_shift,
7087 GDI_DECORATION_MASKED, deco_masked,
7088 GDI_EVENT_MASK, event_mask,
7089 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7090 GDI_CALLBACK_ACTION, HandleControlButtons,
7094 Fail("cannot create gadget");
7096 level_editor_gadget[id] = gi;
7099 // these values are not constant, but can change at runtime
7100 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
7101 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
7102 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
7103 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
7104 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
7105 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
7106 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
7107 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
7108 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].x = ED_SCROLL2_UP_XPOS;
7109 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y = ED_SCROLL2_UP_YPOS;
7110 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x = ED_SCROLL2_DOWN_XPOS;
7111 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y = ED_SCROLL2_DOWN_YPOS;
7113 // create buttons for scrolling of drawing area and element list
7114 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
7116 int id = scrollbutton_info[i].gadget_id;
7117 int type_id = scrollbutton_info[i].gadget_type_id;
7118 int graphic = scrollbutton_info[i].graphic;
7119 struct GraphicInfo *gd = &graphic_info[graphic];
7120 Bitmap *gd_bitmap = gd->bitmap;
7121 int gd_x1 = gd->src_x;
7122 int gd_y1 = gd->src_y;
7123 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7124 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7125 int width = gd->width;
7126 int height = gd->height;
7127 int x = scrollbutton_pos[i].x;
7128 int y = scrollbutton_pos[i].y;
7129 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7132 Fail("'scrollbutton_info' structure corrupted at index %d -- please fix", i);
7134 if (id == GADGET_ID_SCROLL_LIST_UP ||
7135 id == GADGET_ID_SCROLL_LIST_DOWN)
7146 gi = CreateGadget(GDI_CUSTOM_ID, id,
7147 GDI_CUSTOM_TYPE_ID, type_id,
7148 GDI_IMAGE_ID, graphic,
7149 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
7154 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7155 GDI_STATE, GD_BUTTON_UNPRESSED,
7156 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
7157 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
7158 GDI_EVENT_MASK, event_mask,
7159 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7160 GDI_CALLBACK_ACTION, HandleControlButtons,
7164 Fail("cannot create gadget");
7166 level_editor_gadget[id] = gi;
7169 // create buttons for element list
7170 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7173 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
7174 int graphic = IMG_EDITOR_PALETTE_BUTTON;
7175 struct GraphicInfo *gd = &graphic_info[graphic];
7176 Bitmap *gd_bitmap = gd->bitmap;
7177 Bitmap *deco_bitmap;
7178 int deco_x, deco_y, deco_xpos, deco_ypos;
7179 int gd_x1 = gd->src_x;
7180 int gd_y1 = gd->src_y;
7181 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7182 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7183 int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
7184 int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
7185 int x = PX + ED_ELEMENTLIST_XPOS + xx * gd->width;
7186 int y = PY + ED_ELEMENTLIST_YPOS + yy * gd->height;
7187 int element = editor_elements[i];
7188 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
7189 unsigned int event_mask = GD_EVENT_RELEASED;
7191 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
7193 deco_xpos = (gd->width - tile_size) / 2;
7194 deco_ypos = (gd->height - tile_size) / 2;
7196 gi = CreateGadget(GDI_CUSTOM_ID, id,
7197 GDI_CUSTOM_TYPE_ID, type_id,
7198 GDI_IMAGE_ID, graphic,
7199 GDI_INFO_TEXT, getElementInfoText(element),
7202 GDI_WIDTH, gd->width,
7203 GDI_HEIGHT, gd->height,
7204 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7205 GDI_STATE, GD_BUTTON_UNPRESSED,
7206 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
7207 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
7208 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
7209 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
7210 GDI_DECORATION_SIZE, tile_size, tile_size,
7211 GDI_DECORATION_SHIFTING, 1, 1,
7212 GDI_EVENT_MASK, event_mask,
7213 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7214 GDI_CALLBACK_ACTION, HandleControlButtons,
7218 Fail("cannot create gadget");
7220 level_editor_gadget[id] = gi;
7224 static void CreateCounterButtons(void)
7226 int max_infotext_len = getMaxInfoTextLength();
7229 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
7231 int type_id = counterbutton_info[i].gadget_type_id;
7232 int x = SX + ED_SETTINGS_X(counterbutton_info[i].x); // down count button
7233 int y = SY + ED_SETTINGS_Y(counterbutton_info[i].y);
7237 Fail("'counterbutton_info' structure corrupted at index %d -- please fix", i);
7239 // determine horizontal position to the right of specified gadget
7240 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7241 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
7242 ED_GADGET_TEXT_DISTANCE);
7244 // determine horizontal offset for leading text
7245 if (counterbutton_info[i].text_left != NULL)
7246 x += getTextWidthForGadget(counterbutton_info[i].text_left);
7248 for (j = 0; j < 2; j++)
7250 struct GadgetInfo *gi;
7252 counterbutton_info[i].gadget_id_down :
7253 counterbutton_info[i].gadget_id_up);
7255 struct GraphicInfo *gd;
7256 int gd_x1, gd_x2, gd_y1, gd_y2;
7257 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7258 char infotext[max_infotext_len + 1];
7260 if (i == ED_COUNTER_ID_SELECT_LEVEL)
7263 IMG_GFX_EDITOR_BUTTON_PREV_LEVEL :
7264 IMG_GFX_EDITOR_BUTTON_NEXT_LEVEL);
7266 event_mask |= GD_EVENT_RELEASED;
7270 x = DX + editor.button.prev_level.x;
7271 y = DY + editor.button.prev_level.y;
7275 x = DX + editor.button.next_level.x;
7276 y = DY + editor.button.next_level.y;
7282 IMG_EDITOR_COUNTER_DOWN :
7283 IMG_EDITOR_COUNTER_UP);
7286 gd = &graphic_info[graphic];
7290 gd_x2 = gd->src_x + gd->pressed_xoffset;
7291 gd_y2 = gd->src_y + gd->pressed_yoffset;
7293 sprintf(infotext, "%s counter value by 1, 5 or 10",
7294 (j == 0 ? "decrease" : "increase"));
7296 gi = CreateGadget(GDI_CUSTOM_ID, id,
7297 GDI_CUSTOM_TYPE_ID, type_id,
7298 GDI_IMAGE_ID, graphic,
7299 GDI_INFO_TEXT, infotext,
7302 GDI_WIDTH, gd->width,
7303 GDI_HEIGHT, gd->height,
7304 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7305 GDI_STATE, GD_BUTTON_UNPRESSED,
7306 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7307 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7308 GDI_EVENT_MASK, event_mask,
7309 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7310 GDI_CALLBACK_ACTION, HandleCounterButtons,
7314 Fail("cannot create gadget");
7316 level_editor_gadget[id] = gi;
7317 right_gadget_border[id] =
7318 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
7320 x += gi->width + ED_GADGET_SMALL_DISTANCE; // text count button
7324 int font_type = FONT_INPUT_1;
7325 int font_type_active = FONT_INPUT_1_ACTIVE;
7327 id = counterbutton_info[i].gadget_id_text;
7329 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7331 if (i == ED_COUNTER_ID_SELECT_LEVEL)
7333 graphic = IMG_GFX_EDITOR_INPUT_LEVEL_NUMBER;
7335 font_type = FONT_LEVEL_NUMBER;
7336 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
7338 x = DX + editor.input.level_number.x;
7339 y = DY + editor.input.level_number.y;
7343 graphic = IMG_EDITOR_COUNTER_INPUT;
7346 gd = &graphic_info[graphic];
7350 gd_x2 = gd->src_x + gd->active_xoffset;
7351 gd_y2 = gd->src_y + gd->active_yoffset;
7353 gi = CreateGadget(GDI_CUSTOM_ID, id,
7354 GDI_CUSTOM_TYPE_ID, type_id,
7355 GDI_IMAGE_ID, graphic,
7356 GDI_INFO_TEXT, "enter counter value",
7359 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
7360 GDI_NUMBER_VALUE, 0,
7361 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
7362 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
7363 GDI_TEXT_SIZE, 3, // minimal counter text size
7364 GDI_TEXT_FONT, font_type,
7365 GDI_TEXT_FONT_ACTIVE, font_type_active,
7366 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7367 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7368 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7369 GDI_DESIGN_WIDTH, gd->width,
7370 GDI_EVENT_MASK, event_mask,
7371 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7372 GDI_CALLBACK_ACTION, HandleCounterButtons,
7376 Fail("cannot create gadget");
7378 level_editor_gadget[id] = gi;
7379 right_gadget_border[id] =
7380 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
7382 x += gi->width + ED_GADGET_SMALL_DISTANCE; // up count button
7388 static void CreateDrawingAreas(void)
7392 // these values are not constant, but can change at runtime
7393 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
7394 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
7396 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
7398 struct GadgetInfo *gi;
7399 int id = drawingarea_info[i].gadget_id;
7400 int type_id = drawingarea_info[i].gadget_type_id;
7401 int x = SX + ED_AREA_SETTINGS_X(drawingarea_info[i]);
7402 int y = SY + ED_AREA_SETTINGS_Y(drawingarea_info[i]);
7403 int area_xsize = drawingarea_info[i].area_xsize;
7404 int area_ysize = drawingarea_info[i].area_ysize;
7405 int item_size = (id == GADGET_ID_DRAWING_LEVEL ?
7406 ed_tilesize : ED_DRAWINGAREA_TILE_SIZE);
7407 unsigned int event_mask =
7408 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
7409 GD_EVENT_OFF_BORDERS | GD_EVENT_PIXEL_PRECISE;
7412 Fail("'drawingarea_info' structure corrupted at index %d -- please fix", i);
7414 // determine horizontal position to the right of specified gadget
7415 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
7416 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
7417 ED_DRAWINGAREA_TEXT_DISTANCE);
7419 // determine horizontal offset for leading text
7420 if (drawingarea_info[i].text_left != NULL)
7421 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
7423 gi = CreateGadget(GDI_CUSTOM_ID, id,
7424 GDI_CUSTOM_TYPE_ID, type_id,
7427 GDI_TYPE, GD_TYPE_DRAWING_AREA,
7428 GDI_AREA_SIZE, area_xsize, area_ysize,
7429 GDI_ITEM_SIZE, item_size, item_size,
7430 GDI_EVENT_MASK, event_mask,
7431 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
7432 GDI_CALLBACK_ACTION, HandleDrawingAreas,
7436 Fail("cannot create gadget");
7438 level_editor_gadget[id] = gi;
7439 right_gadget_border[id] =
7440 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
7444 static void CreateTextInputGadgets(void)
7446 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
7447 int max_infotext_len = getMaxInfoTextLength();
7450 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
7452 int gd_x1 = gd->src_x;
7453 int gd_y1 = gd->src_y;
7454 int gd_x2 = gd->src_x + gd->active_xoffset;
7455 int gd_y2 = gd->src_y + gd->active_yoffset;
7456 struct GadgetInfo *gi;
7457 unsigned int event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7458 char infotext[MAX_OUTPUT_LINESIZE + 1];
7459 int id = textinput_info[i].gadget_id;
7460 int type_id = textinput_info[i].gadget_type_id;
7464 Fail("'textinput_info' structure corrupted at index %d -- please fix", i);
7466 if (i == ED_TEXTINPUT_ID_ELEMENT_NAME)
7468 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
7469 int border_size = gd->border_size;
7470 int font_nr = FONT_INPUT_1;
7471 int font_height = getFontHeight(font_nr);
7472 int xoffset = element_border + TILEX + element_border + 3 * border_size;
7473 int yoffset = element_border + (TILEY - font_height) / 2;
7475 x = (editor.settings.element_name.x != -1 ?
7476 editor.settings.element_name.x :
7477 editor.settings.element_graphic.x + xoffset) - border_size;
7478 y = (editor.settings.element_name.y != -1 ?
7479 editor.settings.element_name.y :
7480 editor.settings.element_graphic.y + yoffset) - border_size;
7484 x = ED_SETTINGS_X(textinput_info[i].x);
7485 y = ED_SETTINGS_Y(textinput_info[i].y);
7488 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
7489 infotext[max_infotext_len] = '\0';
7491 gi = CreateGadget(GDI_CUSTOM_ID, id,
7492 GDI_CUSTOM_TYPE_ID, type_id,
7493 GDI_INFO_TEXT, infotext,
7496 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
7497 GDI_TEXT_VALUE, textinput_info[i].value,
7498 GDI_TEXT_SIZE, textinput_info[i].size,
7499 GDI_TEXT_FONT, FONT_INPUT_1,
7500 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7501 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7502 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7503 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7504 GDI_DESIGN_WIDTH, gd->width,
7505 GDI_EVENT_MASK, event_mask,
7506 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7507 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
7511 Fail("cannot create gadget");
7513 level_editor_gadget[id] = gi;
7517 static void CreateTextAreaGadgets(void)
7519 int max_infotext_len = getMaxInfoTextLength();
7522 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
7524 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXTAREA];
7525 int gd_x1 = gd->src_x;
7526 int gd_y1 = gd->src_y;
7527 int gd_x2 = gd->src_x + gd->active_xoffset;
7528 int gd_y2 = gd->src_y + gd->active_yoffset;
7529 struct GadgetInfo *gi;
7530 unsigned int event_mask = GD_EVENT_TEXT_LEAVING;
7531 char infotext[MAX_OUTPUT_LINESIZE + 1];
7532 int id = textarea_info[i].gadget_id;
7533 int type_id = textarea_info[i].gadget_type_id;
7534 int area_xsize = textarea_info[i].xsize;
7535 int area_ysize = textarea_info[i].ysize;
7538 Fail("'textarea_info' structure corrupted at index %d -- please fix", i);
7540 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
7541 infotext[max_infotext_len] = '\0';
7543 gi = CreateGadget(GDI_CUSTOM_ID, id,
7544 GDI_CUSTOM_TYPE_ID, type_id,
7545 GDI_INFO_TEXT, infotext,
7546 GDI_X, SX + ED_SETTINGS_X(textarea_info[i].x),
7547 GDI_Y, SY + ED_SETTINGS_Y(textarea_info[i].y),
7548 GDI_TYPE, GD_TYPE_TEXT_AREA,
7549 GDI_AREA_SIZE, area_xsize, area_ysize,
7550 GDI_TEXT_FONT, FONT_INPUT_1,
7551 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7552 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7553 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7554 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7555 GDI_DESIGN_WIDTH, gd->width,
7556 GDI_EVENT_MASK, event_mask,
7557 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7558 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
7562 Fail("cannot create gadget");
7564 level_editor_gadget[id] = gi;
7568 static void CreateSelectboxGadgets(void)
7570 int max_infotext_len = getMaxInfoTextLength();
7573 for (i = 0; i < ED_NUM_SELECTBOX; i++)
7575 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_SELECTBOX_INPUT];
7576 struct GraphicInfo *gd2 = &graphic_info[IMG_EDITOR_SELECTBOX_BUTTON];
7577 int gd_x1 = gd->src_x;
7578 int gd_y1 = gd->src_y;
7579 int gd_x2 = gd->src_x + gd->active_xoffset;
7580 int gd_y2 = gd->src_y + gd->active_yoffset;
7581 int selectbox_button_xsize = gd2->width;
7582 struct GadgetInfo *gi;
7583 char infotext[MAX_OUTPUT_LINESIZE + 1];
7584 int id = selectbox_info[i].gadget_id;
7585 int type_id = selectbox_info[i].gadget_type_id;
7586 int x = SX + ED_SETTINGS_X(selectbox_info[i].x);
7587 int y = SY + ED_SETTINGS_Y(selectbox_info[i].y);
7588 unsigned int event_mask =
7589 GD_EVENT_RELEASED | GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7592 Fail("'selectbox_info' structure corrupted at index %d -- please fix", i);
7594 if (selectbox_info[i].size == -1) // dynamically determine size
7596 // (we cannot use -1 for uninitialized values if we directly compare
7597 // with results from strlen(), because the '<' and '>' operation will
7598 // implicitely cast -1 to an unsigned integer value!)
7599 selectbox_info[i].size = 0;
7601 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
7602 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
7603 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
7605 selectbox_info[i].size++; // add one character empty space
7608 // determine horizontal position to the right of specified gadget
7609 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
7610 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
7611 ED_GADGET_TEXT_DISTANCE);
7613 // determine horizontal offset for leading text
7614 if (selectbox_info[i].text_left != NULL)
7615 x += getTextWidthForGadget(selectbox_info[i].text_left);
7617 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
7618 infotext[max_infotext_len] = '\0';
7620 gi = CreateGadget(GDI_CUSTOM_ID, id,
7621 GDI_CUSTOM_TYPE_ID, type_id,
7622 GDI_INFO_TEXT, infotext,
7625 GDI_TYPE, GD_TYPE_SELECTBOX,
7626 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
7627 GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
7628 GDI_TEXT_SIZE, selectbox_info[i].size,
7629 GDI_TEXT_FONT, FONT_INPUT_1,
7630 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7631 GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
7632 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7633 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7634 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7635 GDI_BORDER_SIZE_SELECTBUTTON, selectbox_button_xsize,
7636 GDI_DESIGN_WIDTH, gd->width,
7637 GDI_EVENT_MASK, event_mask,
7638 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7639 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
7643 Fail("cannot create gadget");
7645 level_editor_gadget[id] = gi;
7646 right_gadget_border[id] =
7647 getRightGadgetBorder(gi, selectbox_info[i].text_right);
7651 static void CreateTextbuttonGadgets(void)
7653 int max_infotext_len = getMaxInfoTextLength();
7656 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
7658 int id = textbutton_info[i].gadget_id;
7659 int type_id = textbutton_info[i].gadget_type_id;
7661 ((id >= GADGET_ID_LEVELCONFIG_LEVEL && id <= GADGET_ID_LEVELCONFIG_ENGINE) ||
7662 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE));
7664 (is_tab_button ? IMG_EDITOR_TABBUTTON : IMG_EDITOR_TEXTBUTTON);
7665 int gadget_distance =
7666 (is_tab_button ? ED_GADGET_SMALL_DISTANCE : ED_GADGET_TEXT_DISTANCE);
7667 struct GraphicInfo *gd = &graphic_info[graphic];
7668 int gd_x1 = gd->src_x;
7669 int gd_y1 = gd->src_y;
7670 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7671 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7672 int gd_x1a = gd->src_x + gd->active_xoffset;
7673 int gd_y1a = gd->src_y + gd->active_yoffset;
7674 int border_xsize = gd->border_size + gd->draw_xoffset;
7675 int border_ysize = gd->border_size;
7676 struct GadgetInfo *gi;
7677 unsigned int event_mask = GD_EVENT_RELEASED;
7678 char infotext[MAX_OUTPUT_LINESIZE + 1];
7679 int x = SX + ED_SETTINGS_X(textbutton_info[i].x);
7680 int y = SY + ED_SETTINGS_Y(textbutton_info[i].y);
7683 Fail("'textbutton_info' structure corrupted at index %d -- please fix", i);
7685 if (textbutton_info[i].size == -1) // dynamically determine size
7686 textbutton_info[i].size = strlen(textbutton_info[i].text);
7688 sprintf(infotext, "%s", textbutton_info[i].infotext);
7689 infotext[max_infotext_len] = '\0';
7691 // determine horizontal position to the right of specified gadget
7692 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7694 int gadget_id_align = textbutton_info[i].gadget_id_align;
7696 x = right_gadget_border[gadget_id_align] + gadget_distance;
7698 if (textbutton_info[i].y == -1)
7699 y = level_editor_gadget[gadget_id_align]->y;
7702 // determine horizontal offset for leading text
7703 if (textbutton_info[i].text_left != NULL)
7704 x += getTextWidthForGadget(textbutton_info[i].text_left);
7706 gi = CreateGadget(GDI_CUSTOM_ID, id,
7707 GDI_CUSTOM_TYPE_ID, type_id,
7708 GDI_IMAGE_ID, graphic,
7709 GDI_INFO_TEXT, infotext,
7712 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
7713 GDI_TEXT_VALUE, textbutton_info[i].text,
7714 GDI_TEXT_SIZE, textbutton_info[i].size,
7715 GDI_TEXT_FONT, FONT_INPUT_2,
7716 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2_ACTIVE,
7717 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7718 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7719 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7720 GDI_BORDER_SIZE, border_xsize, border_ysize,
7721 GDI_DESIGN_WIDTH, gd->width,
7722 GDI_DECORATION_SHIFTING, 1, 1,
7723 GDI_EVENT_MASK, event_mask,
7724 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7725 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
7729 Fail("cannot create gadget");
7731 level_editor_gadget[id] = gi;
7732 right_gadget_border[id] =
7733 getRightGadgetBorder(gi, textbutton_info[i].text_right);
7737 static void CreateGraphicbuttonGadgets(void)
7739 struct GadgetInfo *gi;
7742 // create buttons for scrolling of drawing area and element list
7743 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
7745 int id = graphicbutton_info[i].gadget_id;
7746 int type_id = graphicbutton_info[i].gadget_type_id;
7747 int x = SX + ED_SETTINGS_X(graphicbutton_info[i].x);
7748 int y = SY + ED_SETTINGS_Y(graphicbutton_info[i].y);
7749 int graphic = graphicbutton_info[i].graphic;
7750 struct GraphicInfo *gd = &graphic_info[graphic];
7751 int gd_x1 = gd->src_x;
7752 int gd_y1 = gd->src_y;
7753 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7754 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7755 unsigned int event_mask = GD_EVENT_RELEASED;
7758 Fail("'graphicbutton_info' structure corrupted at index %d -- please fix", i);
7760 // determine horizontal position to the right of specified gadget
7761 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7762 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
7763 ED_GADGET_TEXT_DISTANCE);
7765 // determine horizontal offset for leading text
7766 if (graphicbutton_info[i].text_left != NULL)
7767 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
7769 gi = CreateGadget(GDI_CUSTOM_ID, id,
7770 GDI_CUSTOM_TYPE_ID, type_id,
7771 GDI_IMAGE_ID, graphic,
7772 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
7775 GDI_WIDTH, gd->width,
7776 GDI_HEIGHT, gd->height,
7777 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7778 GDI_STATE, GD_BUTTON_UNPRESSED,
7779 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7780 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7781 GDI_EVENT_MASK, event_mask,
7782 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7783 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
7787 Fail("cannot create gadget");
7789 level_editor_gadget[id] = gi;
7790 right_gadget_border[id] =
7791 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
7795 static void CreateScrollbarGadgets(void)
7799 // these values are not constant, but can change at runtime
7800 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
7801 SX + ED_SCROLL_HORIZONTAL_XPOS;
7802 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
7803 SY + ED_SCROLL_HORIZONTAL_YPOS;
7804 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
7805 ED_SCROLL_HORIZONTAL_XSIZE;
7806 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
7807 ED_SCROLL_HORIZONTAL_YSIZE;
7808 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
7809 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
7810 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
7811 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
7813 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
7814 SX + ED_SCROLL_VERTICAL_XPOS;
7815 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
7816 SY + ED_SCROLL_VERTICAL_YPOS;
7817 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
7818 ED_SCROLL_VERTICAL_XSIZE;
7819 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
7820 ED_SCROLL_VERTICAL_YSIZE;
7821 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
7822 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
7823 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
7824 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
7826 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
7827 PX + ED_SCROLL2_VERTICAL_XPOS;
7828 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
7829 PY + ED_SCROLL2_VERTICAL_YPOS;
7830 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
7831 ED_SCROLL2_VERTICAL_XSIZE;
7832 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
7833 ED_SCROLL2_VERTICAL_YSIZE;
7834 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = PX;
7835 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = PY;
7836 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width = PXSIZE;
7837 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = PYSIZE;
7839 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
7841 int id = scrollbar_info[i].gadget_id;
7842 int type_id = scrollbar_info[i].gadget_type_id;
7843 int graphic = scrollbar_info[i].graphic;
7844 struct GraphicInfo *gd = &graphic_info[graphic];
7845 int gd_x1 = gd->src_x;
7846 int gd_y1 = gd->src_y;
7847 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7848 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7849 struct GadgetInfo *gi;
7850 int items_max, items_visible, item_position;
7851 unsigned int event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
7854 Fail("'scrollbar_info' structure corrupted at index %d -- please fix", i);
7856 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
7858 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
7859 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
7860 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
7862 else // drawing area scrollbars
7864 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
7866 items_max = MAX(lev_fieldx + 2, ed_fieldx);
7867 items_visible = ed_fieldx;
7872 items_max = MAX(lev_fieldy + 2, ed_fieldy);
7873 items_visible = ed_fieldy;
7878 gi = CreateGadget(GDI_CUSTOM_ID, id,
7879 GDI_CUSTOM_TYPE_ID, type_id,
7880 GDI_IMAGE_ID, graphic,
7881 GDI_INFO_TEXT, scrollbar_info[i].infotext,
7882 GDI_X, scrollbar_pos[i].x,
7883 GDI_Y, scrollbar_pos[i].y,
7884 GDI_WIDTH, scrollbar_pos[i].width,
7885 GDI_HEIGHT, scrollbar_pos[i].height,
7886 GDI_TYPE, scrollbar_info[i].type,
7887 GDI_SCROLLBAR_ITEMS_MAX, items_max,
7888 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7889 GDI_SCROLLBAR_ITEM_POSITION, item_position,
7890 GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
7891 GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
7892 GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
7893 GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
7894 GDI_STATE, GD_BUTTON_UNPRESSED,
7895 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7896 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7897 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7898 GDI_EVENT_MASK, event_mask,
7899 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7900 GDI_CALLBACK_ACTION, HandleControlButtons,
7904 Fail("cannot create gadget");
7906 level_editor_gadget[id] = gi;
7910 static void CreateCheckbuttonGadgets(void)
7912 struct GadgetInfo *gi;
7915 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
7917 int id = checkbutton_info[i].gadget_id;
7918 int type_id = checkbutton_info[i].gadget_type_id;
7919 int graphic = (id == GADGET_ID_STICK_ELEMENT ? IMG_EDITOR_STICKYBUTTON :
7920 IMG_EDITOR_CHECKBOX);
7921 struct GraphicInfo *gd = &graphic_info[graphic];
7922 int gd_x1 = gd->src_x;
7923 int gd_y1 = gd->src_y;
7924 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7925 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7926 int gd_x1a = gd->src_x + gd->active_xoffset;
7927 int gd_y1a = gd->src_y + gd->active_yoffset;
7928 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7929 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7930 int x = SX + ED_SETTINGS_X(checkbutton_info[i].x);
7931 int y = SY + ED_SETTINGS_Y(checkbutton_info[i].y);
7932 unsigned int event_mask = GD_EVENT_PRESSED;
7935 Fail("'checkbutton_info' structure corrupted at index %d -- please fix", i);
7937 // determine horizontal position to the right of specified gadget
7938 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7939 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
7940 ED_GADGET_TEXT_DISTANCE);
7942 // determine horizontal offset for leading text
7943 if (checkbutton_info[i].text_left != NULL)
7944 x += getTextWidthForGadget(checkbutton_info[i].text_left);
7946 gi = CreateGadget(GDI_CUSTOM_ID, id,
7947 GDI_CUSTOM_TYPE_ID, type_id,
7948 GDI_IMAGE_ID, graphic,
7949 GDI_INFO_TEXT, checkbutton_info[i].infotext,
7952 GDI_WIDTH, gd->width,
7953 GDI_HEIGHT, gd->height,
7954 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
7955 GDI_CHECKED, *checkbutton_info[i].value,
7956 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7957 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7958 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7959 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7960 GDI_EVENT_MASK, event_mask,
7961 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7962 GDI_CALLBACK_ACTION, HandleCheckbuttons,
7966 Fail("cannot create gadget");
7968 level_editor_gadget[id] = gi;
7969 right_gadget_border[id] =
7970 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
7974 static void CreateRadiobuttonGadgets(void)
7976 int graphic = IMG_EDITOR_RADIOBUTTON;
7977 struct GraphicInfo *gd = &graphic_info[graphic];
7978 int gd_x1 = gd->src_x;
7979 int gd_y1 = gd->src_y;
7980 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7981 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7982 int gd_x1a = gd->src_x + gd->active_xoffset;
7983 int gd_y1a = gd->src_y + gd->active_yoffset;
7984 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7985 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7986 struct GadgetInfo *gi;
7989 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
7991 int id = radiobutton_info[i].gadget_id;
7992 int type_id = radiobutton_info[i].gadget_type_id;
7993 int x = SX + ED_SETTINGS_X(radiobutton_info[i].x);
7994 int y = SY + ED_SETTINGS_Y(radiobutton_info[i].y);
7995 unsigned int event_mask = GD_EVENT_PRESSED;
7998 Fail("'radiobutton_info' structure corrupted at index %d -- please fix", i);
8001 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
8003 // determine horizontal position to the right of specified gadget
8004 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
8005 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
8006 ED_GADGET_TEXT_DISTANCE);
8008 // determine horizontal offset for leading text
8009 if (radiobutton_info[i].text_left != NULL)
8010 x += getTextWidthForGadget(radiobutton_info[i].text_left);
8012 gi = CreateGadget(GDI_CUSTOM_ID, id,
8013 GDI_CUSTOM_TYPE_ID, type_id,
8014 GDI_IMAGE_ID, graphic,
8015 GDI_INFO_TEXT, radiobutton_info[i].infotext,
8018 GDI_WIDTH, gd->width,
8019 GDI_HEIGHT, gd->height,
8020 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
8021 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
8022 GDI_CHECKED, checked,
8023 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
8024 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
8025 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
8026 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
8027 GDI_EVENT_MASK, event_mask,
8028 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
8029 GDI_CALLBACK_ACTION, HandleRadiobuttons,
8033 Fail("cannot create gadget");
8035 level_editor_gadget[id] = gi;
8036 right_gadget_border[id] =
8037 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
8041 void CreateLevelEditorGadgets(void)
8043 // force EDITOR font inside level editor
8044 SetFontStatus(GAME_MODE_EDITOR);
8046 // these values are not constant, but can change at runtime
8047 ed_fieldx = MAX_ED_FIELDX - 1;
8048 ed_fieldy = MAX_ED_FIELDY - 1;
8050 num_editor_gadgets = NUM_EDITOR_GADGETS;
8052 // Debug("editor", "allocating %d gadgets ...\n", num_editor_gadgets);
8054 level_editor_gadget =
8055 checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *));
8056 right_gadget_border =
8057 checked_calloc(num_editor_gadgets * sizeof(int));
8059 // set number of empty (padding) element buttons to maximum number of buttons
8060 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS;
8062 editor_el_empty = checked_calloc(num_editor_el_empty * sizeof(int));
8063 editor_el_empty_ptr = editor_el_empty;
8065 use_permanent_palette = !editor.palette.show_as_separate_screen;
8067 InitGadgetScreenBorders(-1, INFOTEXT_YPOS);
8069 ReinitializeElementList();
8071 CreateControlButtons();
8072 CreateScrollbarGadgets();
8074 // order of function calls is important because of cross-references
8075 CreateCheckbuttonGadgets();
8076 CreateCounterButtons();
8077 CreateRadiobuttonGadgets();
8078 CreateTextInputGadgets();
8079 CreateTextAreaGadgets();
8080 CreateSelectboxGadgets();
8081 CreateGraphicbuttonGadgets();
8082 CreateTextbuttonGadgets();
8083 CreateDrawingAreas();
8088 void FreeLevelEditorGadgets(void)
8092 // Debug("editor", "freeing %d gadgets ...\n", num_editor_gadgets);
8094 for (i = 0; i < num_editor_gadgets; i++)
8096 FreeGadget(level_editor_gadget[i]);
8098 level_editor_gadget[i] = NULL;
8101 checked_free(level_editor_gadget);
8102 checked_free(right_gadget_border);
8104 checked_free(editor_el_empty);
8107 static void MapCounterButtons(int id)
8109 int font_nr = FONT_TEXT_1;
8110 int font_height = getFontHeight(font_nr);
8111 int gadget_id_down = counterbutton_info[id].gadget_id_down;
8112 int gadget_id_text = counterbutton_info[id].gadget_id_text;
8113 int gadget_id_up = counterbutton_info[id].gadget_id_up;
8114 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
8115 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
8116 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
8117 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
8118 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8119 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8120 int yoffset = (gi_down->height - font_height) / 2;
8121 int x_left = gi_down->x - xoffset_left;
8122 int x_right; // set after gadget position was modified
8123 int y_above = gi_down->y - yoffset_above;
8125 int y; // set after gadget position was modified
8127 // counter limits must be changed first to prevent value truncation
8128 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
8129 counterbutton_info[id].max_value);
8131 // right text position might have changed after setting position above
8132 x_right = gi_up->x + gi_up->width + xoffset_right;
8134 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
8136 // set position for counter gadgets with dynamically determined position
8137 ModifyGadget(gi_down, GDI_Y, SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
8138 ModifyGadget(gi_text, GDI_Y, SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
8139 ModifyGadget(gi_up, GDI_Y, SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
8141 // vertical position might have changed after setting position above
8142 y = gi_up->y + yoffset;
8144 if (counterbutton_info[id].text_above)
8145 DrawText(x, y_above, counterbutton_info[id].text_above, font_nr);
8147 if (counterbutton_info[id].text_left)
8148 DrawText(x_left, y, counterbutton_info[id].text_left, font_nr);
8150 if (counterbutton_info[id].text_right)
8151 DrawText(x_right, y, counterbutton_info[id].text_right, font_nr);
8158 static void MapControlButtons(void)
8163 // map toolbox buttons (excluding special CE toolbox buttons)
8164 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
8165 MapGadget(level_editor_gadget[i]);
8167 // map toolbox buttons (element properties buttons)
8168 for (i = ED_NUM_CTRL1_4_BUTTONS; i < ED_NUM_CTRL1_7_BUTTONS; i++)
8169 MapGadget(level_editor_gadget[i]);
8171 if (use_permanent_palette)
8173 // map buttons to select elements
8174 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
8175 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
8176 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
8177 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
8178 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
8181 // map buttons to select level
8182 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
8183 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
8184 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
8185 MapCounterButtons(counter_id);
8188 static void MapDrawingArea(int id)
8190 int font_nr = FONT_TEXT_1;
8191 int font_height = getFontHeight(font_nr);
8192 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
8193 int area_xsize = gi->drawing.area_xsize;
8194 int area_ysize = gi->drawing.area_ysize;
8195 int xoffset_left = getTextWidthForDrawingArea(drawingarea_info[id].text_left);
8196 int xoffset_below = getTextWidth(drawingarea_info[id].text_below, font_nr);
8197 int x_left = gi->x - xoffset_left;
8198 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
8199 int x_above = gi->x - ED_DRAWINGAREA_BORDER_SIZE;
8200 int x_below = gi->x + (gi->width - xoffset_below) / 2;
8201 int y_side = gi->y + (gi->height - font_height) / 2;
8202 int y_above = gi->y - font_height - ED_DRAWINGAREA_TEXT_DISTANCE;
8203 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
8205 if (drawingarea_info[id].text_left)
8206 DrawText(x_left, y_side, drawingarea_info[id].text_left, font_nr);
8208 if (drawingarea_info[id].text_right)
8209 DrawText(x_right, y_side, drawingarea_info[id].text_right, font_nr);
8211 if (drawingarea_info[id].text_above)
8212 DrawText(x_above, y_above, drawingarea_info[id].text_above, font_nr);
8214 if (drawingarea_info[id].text_below)
8215 DrawText(x_below, y_below, drawingarea_info[id].text_below, font_nr);
8217 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
8219 DrawElementBorder(gi->x, gi->y,
8220 area_xsize * ED_DRAWINGAREA_TILE_SIZE,
8221 area_ysize * ED_DRAWINGAREA_TILE_SIZE, TRUE);
8223 DrawDrawingArea(id);
8229 static void MapTextInputGadget(int id)
8231 int font_nr = FONT_TEXT_1;
8232 int font_height = getFontHeight(font_nr);
8233 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
8234 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8235 int x_above = ED_SETTINGS_X(textinput_info[id].x);
8236 int y_above = ED_SETTINGS_Y(textinput_info[id].y) - yoffset_above;
8238 if (textinput_info[id].text_above)
8239 DrawTextS(x_above, y_above, font_nr, textinput_info[id].text_above);
8241 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
8246 static void MapTextAreaGadget(int id)
8248 int font_nr = FONT_TEXT_1;
8249 int font_height = getFontHeight(font_nr);
8250 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
8251 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8252 int x_above = ED_SETTINGS_X(textarea_info[id].x);
8253 int y_above = ED_SETTINGS_Y(textarea_info[id].y) - yoffset_above;
8254 char *text_above = textarea_info[id].text_above;
8256 if (gi->textarea.cropped && textarea_info[id].text_above_cropped)
8257 text_above = textarea_info[id].text_above_cropped;
8260 DrawTextS(x_above, y_above, font_nr, text_above);
8262 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
8267 static void MapSelectboxGadget(int id)
8269 int font_nr = FONT_TEXT_1;
8270 int font_height = getFontHeight(font_nr);
8271 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
8272 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
8273 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8274 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8275 int yoffset = (gi->height - font_height) / 2;
8276 int x_left = gi->x - xoffset_left;
8277 int x_right = gi->x + gi->width + xoffset_right;
8278 int y_above = gi->y - yoffset_above;
8280 int y = gi->y + yoffset;
8282 if (selectbox_info[id].text_above)
8283 DrawText(x, y_above, selectbox_info[id].text_above, font_nr);
8285 if (selectbox_info[id].text_left)
8286 DrawText(x_left, y, selectbox_info[id].text_left, font_nr);
8288 if (selectbox_info[id].text_right)
8289 DrawText(x_right, y, selectbox_info[id].text_right, font_nr);
8291 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
8296 static void MapTextbuttonGadget(int id)
8298 int font_nr = FONT_TEXT_1;
8299 int font_height = getFontHeight(font_nr);
8300 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
8301 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
8302 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8303 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8304 int yoffset = (gi->height - font_height) / 2;
8305 int x_left = gi->x - xoffset_left;
8306 int x_right = gi->x + gi->width + xoffset_right;
8307 int y_above = gi->y - yoffset_above;
8309 int y = gi->y + yoffset;
8311 // only show button to delete change pages when more than minimum pages
8312 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
8313 custom_element.num_change_pages == MIN_CHANGE_PAGES)
8316 if (textbutton_info[id].text_above)
8317 DrawText(x, y_above, textbutton_info[id].text_above, font_nr);
8319 if (textbutton_info[id].text_left)
8320 DrawText(x_left, y, textbutton_info[id].text_left, font_nr);
8322 if (textbutton_info[id].text_right)
8323 DrawText(x_right, y, textbutton_info[id].text_right, font_nr);
8328 static void MapGraphicbuttonGadget(int id)
8330 int font_nr = FONT_TEXT_1;
8331 int font_height = getFontHeight(font_nr);
8332 struct GadgetInfo *gi = level_editor_gadget[graphicbutton_info[id].gadget_id];
8333 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
8334 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8335 int yoffset = (gi->height - font_height) / 2;
8336 int x_left = gi->x - xoffset_left;
8337 int x_right = gi->x + gi->width + xoffset_right;
8338 int y = gi->y + yoffset;
8340 if (graphicbutton_info[id].text_left)
8341 DrawText(x_left, y, graphicbutton_info[id].text_left, font_nr);
8343 if (graphicbutton_info[id].text_right)
8344 DrawText(x_right, y, graphicbutton_info[id].text_right, font_nr);
8349 static void MapRadiobuttonGadget(int id)
8351 int font_nr = FONT_TEXT_1;
8352 int font_height = getFontHeight(font_nr);
8353 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
8354 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
8355 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8356 int yoffset = (gi->height - font_height) / 2;
8357 int x_left = gi->x - xoffset_left;
8358 int x_right = gi->x + gi->width + xoffset_right;
8359 int y = gi->y + yoffset;
8361 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
8363 if (radiobutton_info[id].text_left)
8364 DrawText(x_left, y, radiobutton_info[id].text_left, font_nr);
8366 if (radiobutton_info[id].text_right)
8367 DrawText(x_right, y, radiobutton_info[id].text_right, font_nr);
8369 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
8374 static void MapCheckbuttonGadget(int id)
8376 int font_nr = FONT_TEXT_1;
8377 int font_height = getFontHeight(font_nr);
8378 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
8379 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
8380 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8381 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8382 int yoffset = (gi->height - font_height) / 2;
8383 int y_above = gi->y - yoffset_above;
8385 int x_left, x_right, y; // set after gadget position was modified
8387 // set position for gadgets with dynamically determined position
8388 if (checkbutton_info[id].x != -1) // do not change dynamic positions
8389 ModifyGadget(gi, GDI_X, SX + ED_SETTINGS_X(checkbutton_info[id].x), GDI_END);
8390 ModifyGadget(gi, GDI_Y, SY + ED_SETTINGS_Y(checkbutton_info[id].y), GDI_END);
8392 x_left = gi->x - xoffset_left;
8393 x_right = gi->x + gi->width + xoffset_right;
8394 y = gi->y + yoffset;
8396 if (checkbutton_info[id].text_above)
8397 DrawText(x, y_above, checkbutton_info[id].text_above, font_nr);
8399 if (checkbutton_info[id].text_left)
8400 DrawText(x_left, y, checkbutton_info[id].text_left, font_nr);
8402 if (checkbutton_info[id].text_right)
8403 DrawText(x_right, y, checkbutton_info[id].text_right, font_nr);
8405 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
8410 static void MapMainDrawingArea(void)
8412 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
8413 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
8416 if (suppressBorderElement())
8418 no_horizontal_scrollbar = (lev_fieldx <= ed_fieldx);
8419 no_vertical_scrollbar = (lev_fieldy <= ed_fieldy);
8422 for (i = ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
8424 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
8425 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
8426 no_horizontal_scrollbar) ||
8427 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
8428 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
8429 no_vertical_scrollbar))
8432 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
8435 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
8437 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
8438 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
8441 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
8444 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
8447 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
8451 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
8453 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
8454 i == GADGET_ID_CUSTOM_COPY_TO ||
8455 i == GADGET_ID_CUSTOM_EXCHANGE ||
8456 i == GADGET_ID_CUSTOM_COPY ||
8457 i == GADGET_ID_CUSTOM_PASTE)
8460 MapGadget(level_editor_gadget[i]);
8462 UnmapGadget(level_editor_gadget[i]);
8467 static void MapLevelEditorToolboxCustomGadgets(void)
8469 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
8472 static void MapLevelEditorToolboxCustomGadgetsIfNeeded(void)
8474 if (IS_CUSTOM_ELEMENT(properties_element) ||
8475 IS_GROUP_ELEMENT(properties_element) ||
8476 IS_EMPTY_ELEMENT(properties_element))
8477 MapLevelEditorToolboxCustomGadgets();
8480 static void UnmapLevelEditorToolboxCustomGadgets(void)
8482 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
8485 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
8489 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
8491 if (i != GADGET_ID_SINGLE_ITEMS &&
8492 i != GADGET_ID_PICK_ELEMENT)
8494 struct GadgetInfo *gi = level_editor_gadget[i];
8502 int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
8503 struct GraphicInfo *gd = &graphic_info[graphic];
8507 BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
8508 gi->width, gi->height, gi->x, gi->y);
8510 redraw_mask |= REDRAW_DOOR_3;
8516 static void MapLevelEditorToolboxDrawingGadgets(void)
8518 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
8521 static void UnmapLevelEditorToolboxDrawingGadgets(void)
8523 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
8526 static void UnmapDrawingArea(int id)
8528 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
8531 static void UnmapLevelEditorFieldGadgets(void)
8535 for (i = 0; i < num_editor_gadgets; i++)
8536 if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
8537 level_editor_gadget[i]->y))
8538 UnmapGadget(level_editor_gadget[i]);
8541 void UnmapLevelEditorGadgets(void)
8545 for (i = 0; i < num_editor_gadgets; i++)
8546 UnmapGadget(level_editor_gadget[i]);
8549 static void ResetUndoBuffer(void)
8551 undo_buffer_position = -1;
8552 undo_buffer_steps = -1;
8553 redo_buffer_steps = 0;
8555 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8557 level.changed = FALSE;
8560 static void DrawEditModeWindowExt(boolean remap_toolbox_gadgets)
8562 if (remap_toolbox_gadgets)
8564 ModifyEditorElementList();
8565 RedrawDrawingElements();
8568 if (edit_mode == ED_MODE_LEVELCONFIG)
8569 DrawLevelConfigWindow();
8570 else if (edit_mode == ED_MODE_PROPERTIES)
8571 DrawPropertiesWindow();
8572 else if (edit_mode == ED_MODE_PALETTE)
8573 DrawPaletteWindow();
8574 else // edit_mode == ED_MODE_DRAWING
8575 DrawDrawingWindowExt(remap_toolbox_gadgets);
8578 static void DrawEditModeWindow(void)
8580 DrawEditModeWindowExt(TRUE);
8583 static void DrawEditModeWindow_PlayfieldOnly(void)
8585 DrawEditModeWindowExt(FALSE);
8588 static void ChangeEditModeWindow(int new_edit_mode)
8590 edit_mode = (new_edit_mode != edit_mode ? new_edit_mode : ED_MODE_DRAWING);
8592 DrawEditModeWindow();
8595 static boolean LevelChanged(void)
8597 boolean field_changed = FALSE;
8600 for (y = 0; y < lev_fieldy; y++)
8601 for (x = 0; x < lev_fieldx; x++)
8602 if (Tile[x][y] != level.field[x][y])
8603 field_changed = TRUE;
8605 return (level.changed || field_changed);
8608 static boolean PrepareSavingIntoPersonalLevelSet(void)
8610 static LevelDirTree *last_copied_leveldir = NULL;
8611 static LevelDirTree *last_written_leveldir = NULL;
8612 static int last_copied_level_nr = -1;
8613 static int last_written_level_nr = -1;
8614 LevelDirTree *leveldir_former = leveldir_current;
8615 int level_nr_former = level_nr;
8618 // remember last mod/save so that for current session, we write
8619 // back to the same personal copy, asking only about overwrite.
8620 if (leveldir_current == last_copied_leveldir &&
8621 level_nr == last_copied_level_nr)
8623 // "cd" to personal level set dir (as used when writing last copy)
8624 leveldir_current = last_written_leveldir;
8625 level_nr = last_written_level_nr;
8630 if (!Request("This level is read-only! "
8631 "Save into personal level set?", REQ_ASK))
8634 // "cd" to personal level set dir (for writing copy the first time)
8636 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
8638 // this may happen if "setup.internal.create_user_levelset" is FALSE
8639 // or if file "levelinfo.conf" is missing in personal user level set
8640 if (leveldir_current == NULL)
8642 Request("Cannot find personal level set?!", REQ_CONFIRM);
8644 leveldir_current = leveldir_former;
8649 // find unused level number
8650 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
8652 static char *level_filename = NULL;
8654 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
8656 if (!fileExists(level_filename))
8660 last_copied_leveldir = leveldir_former;
8661 last_copied_level_nr = level_nr_former;
8663 last_written_leveldir = leveldir_current;
8664 last_written_level_nr = level_nr = new_level_nr;
8669 static void ModifyLevelConfigForSavingIntoPersonalLevelSet(char *former_name)
8671 static char *filename_levelinfo = NULL, *mod_name = NULL;
8674 // annotate this copy-and-mod in personal levelinfo.conf
8675 setString(&filename_levelinfo,
8676 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
8678 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
8680 fprintf(file, "\n");
8681 fprintf(file, "# level %d was modified from:\n", level_nr);
8682 fprintf(file, "# - previous level set name: %s\n",
8684 fprintf(file, "# - level within previous set: %d \"%s\"\n",
8685 level.file_info.nr, level.name);
8686 fprintf(file, "# - previous author: %s\n",
8688 fprintf(file, "# - previous save date: ");
8690 if (level.creation_date.src == DATE_SRC_LEVELFILE)
8692 fprintf(file, "%04d-%02d-%02d\n",
8693 level.creation_date.year,
8694 level.creation_date.month,
8695 level.creation_date.day);
8699 fprintf(file, "not recorded\n");
8705 if (level_nr > leveldir_current->last_level)
8706 UpdateUserLevelSet(getLoginName(), NULL, NULL, level_nr + 9);
8708 // else: allow the save even if annotation failed
8710 // now... spray graffiti on the old level vital statistics
8711 // user can change these; just trying to set a good baseline
8713 // don't truncate names for fear of making offensive or silly:
8714 // long-named original author only recorded in levelinfo.conf.
8715 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
8716 if (!strEqual(level.author, leveldir_current->author))
8718 setString(&mod_name, getStringCat3(leveldir_current->author,
8719 " after ", level.author));
8721 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8722 setString(&mod_name,
8723 getStringCat2(leveldir_current->author, " (ed.)"));
8725 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8726 setString(&mod_name, leveldir_current->author);
8728 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
8730 // less worried about truncation here
8731 setString(&mod_name, getStringCat2("Mod: ", level.name));
8732 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
8736 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
8737 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
8741 for (x = 0; x < lev_fieldx; x++)
8742 for (y = 0; y < lev_fieldy; y++)
8743 dst[x][y] = src[x][y];
8746 static int setSelectboxValue(int selectbox_id, int new_value)
8748 int new_index_value = 0;
8751 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
8752 if (selectbox_info[selectbox_id].options[i].value == new_value)
8753 new_index_value = i;
8755 *selectbox_info[selectbox_id].value =
8756 selectbox_info[selectbox_id].options[new_index_value].value;
8758 return new_index_value;
8761 static void setSelectboxSpecialActionVariablesIfNeeded(void)
8765 // change action mode and arg variables according to action type variable
8766 for (i = 0; action_arg_options[i].value != -1; i++)
8768 if (action_arg_options[i].value == custom_element_change.action_type)
8770 int mode = action_arg_options[i].mode;
8772 // only change if corresponding selectbox has changed
8773 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
8774 action_arg_modes[mode])
8775 custom_element_change.action_mode = -1;
8777 // only change if corresponding selectbox has changed
8778 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
8779 action_arg_options[i].options)
8780 custom_element_change.action_arg = -1;
8787 static void setSelectboxSpecialActionOptions(void)
8791 // change action mode and arg selectbox according to action type selectbox
8792 for (i = 0; action_arg_options[i].value != -1; i++)
8794 if (action_arg_options[i].value == custom_element_change.action_type)
8796 int mode = action_arg_options[i].mode;
8798 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
8799 action_arg_modes[mode]);
8800 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
8801 custom_element_change.action_mode);
8803 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
8804 action_arg_options[i].options);
8805 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
8806 custom_element_change.action_arg);
8812 static void copy_custom_element_settings(int element_from, int element_to)
8814 struct ElementInfo *ei_from = &element_info[element_from];
8815 struct ElementInfo *ei_to = &element_info[element_to];
8817 copyElementInfo(ei_from, ei_to);
8820 static void replace_custom_element_in_settings(int element_from,
8825 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8827 struct ElementInfo *ei = &element_info[i];
8829 for (y = 0; y < 3; y++)
8830 for (x = 0; x < 3; x++)
8831 if (ei->content.e[x][y] == element_from)
8832 ei->content.e[x][y] = element_to;
8834 for (j = 0; j < ei->num_change_pages; j++)
8836 struct ElementChangeInfo *change = &ei->change_page[j];
8838 if (change->target_element == element_from)
8839 change->target_element = element_to;
8841 if (change->initial_trigger_element == element_from)
8842 change->initial_trigger_element = element_to;
8844 if (change->action_element == element_from)
8845 change->action_element = element_to;
8847 for (y = 0; y < 3; y++)
8848 for (x = 0; x < 3; x++)
8849 if (change->target_content.e[x][y] == element_from)
8850 change->target_content.e[x][y] = element_to;
8853 if (ei->group != NULL) // group or internal
8854 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
8855 if (ei->group->element[j] == element_from)
8856 ei->group->element[j] = element_to;
8860 static void replace_custom_element_in_playfield(int element_from,
8865 for (x = 0; x < lev_fieldx; x++)
8866 for (y = 0; y < lev_fieldy; y++)
8867 if (Tile[x][y] == element_from)
8868 Tile[x][y] = element_to;
8871 static boolean CopyCustomElement(int element_old, int element_new,
8874 int copy_mode_orig = copy_mode;
8876 if (copy_mode == GADGET_ID_CUSTOM_COPY)
8878 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
8879 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8880 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8882 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
8884 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
8885 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8886 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8888 level.changed = TRUE;
8890 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
8892 Request("Please choose custom element!", REQ_CONFIRM);
8896 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
8898 Request("Please choose group element!", REQ_CONFIRM);
8902 else if (IS_EMPTY_ELEMENT(element_old) && !IS_EMPTY_ELEMENT(element_new))
8904 Request("Please choose empty element!", REQ_CONFIRM);
8910 level.changed = TRUE;
8913 // when modifying custom/group element, ask for copying level template
8914 if (copy_mode_orig != GADGET_ID_CUSTOM_COPY && level.use_custom_template)
8916 if (!AskToCopyAndModifyLevelTemplate())
8920 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
8922 copy_custom_element_settings(element_new, element_old);
8924 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
8926 copy_custom_element_settings(element_old, element_new);
8928 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
8930 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
8931 copy_custom_element_settings(element_new, element_old);
8932 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
8934 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
8935 replace_custom_element_in_settings(element_new, element_old);
8936 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
8938 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
8939 replace_custom_element_in_playfield(element_new, element_old);
8940 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
8943 UpdateCustomElementGraphicGadgets();
8944 DrawPropertiesWindow();
8949 static void CopyCustomElementPropertiesToEditor(int element)
8952 int current_change_page = element_info[element].current_change_page;
8954 // dynamically (re)build selectbox for selecting change page
8955 for (i = 0; i < element_info[element].num_change_pages; i++)
8957 sprintf(options_change_page_strings[i], "%d", i + 1);
8959 options_change_page[i].value = i;
8960 options_change_page[i].text = options_change_page_strings[i];
8963 options_change_page[i].value = -1;
8964 options_change_page[i].text = NULL;
8966 // needed here to initialize combined element properties
8967 InitElementPropertiesEngine(level.game_version);
8969 element_info[element].change =
8970 &element_info[element].change_page[current_change_page];
8972 custom_element = element_info[element];
8973 custom_element_change = *element_info[element].change;
8975 // needed to initially set selectbox options for special action options
8976 setSelectboxSpecialActionOptions();
8978 // needed to initially set selectbox value variables to reliable defaults
8979 for (i = 0; i < ED_NUM_SELECTBOX; i++)
8980 setSelectboxValue(i, *selectbox_info[i].value);
8982 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8983 custom_element_properties[i] = HAS_PROPERTY(element, i);
8985 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8986 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
8988 // ---------- element settings: configure (custom elements) -----------------
8990 // set accessible layer selectbox help value
8991 custom_element.access_type =
8992 (IS_WALKABLE(element) ? EP_WALKABLE :
8993 IS_PASSABLE(element) ? EP_PASSABLE :
8994 custom_element.access_type);
8995 custom_element.access_layer =
8996 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
8997 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
8998 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
8999 custom_element.access_layer);
9000 custom_element.access_protected =
9001 (IS_PROTECTED(element) ? 1 : 0);
9002 custom_element_properties[EP_ACCESSIBLE] =
9003 (IS_ACCESSIBLE_OVER(element) ||
9004 IS_ACCESSIBLE_INSIDE(element) ||
9005 IS_ACCESSIBLE_UNDER(element));
9007 // set walk-to-object action selectbox help value
9008 custom_element.walk_to_action =
9009 (IS_DIGGABLE(element) ? EP_DIGGABLE :
9010 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
9011 IS_DROPPABLE(element) ? EP_DROPPABLE :
9012 IS_THROWABLE(element) ? EP_THROWABLE :
9013 IS_PUSHABLE(element) ? EP_PUSHABLE :
9014 custom_element.walk_to_action);
9015 custom_element_properties[EP_WALK_TO_OBJECT] =
9016 (IS_DIGGABLE(element) ||
9017 IS_COLLECTIBLE_ONLY(element) ||
9018 IS_DROPPABLE(element) ||
9019 IS_THROWABLE(element) ||
9020 IS_PUSHABLE(element));
9022 // set smash targets selectbox help value
9023 custom_element.smash_targets =
9024 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
9025 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
9026 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
9027 custom_element.smash_targets);
9028 custom_element_properties[EP_CAN_SMASH] =
9029 (CAN_SMASH_EVERYTHING(element) ||
9030 CAN_SMASH_ENEMIES(element) ||
9031 CAN_SMASH_PLAYER(element));
9033 // set deadliness selectbox help value
9034 custom_element.deadliness =
9035 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
9036 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
9037 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
9038 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
9039 custom_element.deadliness);
9040 custom_element_properties[EP_DEADLY] =
9041 (DONT_TOUCH(element) ||
9042 DONT_GET_HIT_BY(element) ||
9043 DONT_COLLIDE_WITH(element) ||
9044 DONT_RUN_INTO(element));
9046 // ---------- element settings: advanced (custom elements) ------------------
9048 // set "change by direct action" selectbox help value
9049 custom_element_change.direct_action =
9050 (HAS_CHANGE_EVENT(element, CE_NEXT_TO_PLAYER) ? CE_NEXT_TO_PLAYER :
9051 HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
9052 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
9053 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
9054 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
9055 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
9056 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
9057 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
9058 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
9059 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
9060 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
9061 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
9062 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
9063 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
9064 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
9065 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
9066 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
9067 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
9068 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
9069 HAS_CHANGE_EVENT(element, CE_CLICKED_BY_MOUSE) ? CE_CLICKED_BY_MOUSE :
9070 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_MOUSE) ? CE_PRESSED_BY_MOUSE :
9071 custom_element_change.direct_action);
9073 // set "change by other element action" selectbox help value
9074 custom_element_change.other_action =
9075 (HAS_CHANGE_EVENT(element, CE_PLAYER_NEXT_TO_X) ? CE_PLAYER_NEXT_TO_X :
9076 HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
9077 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
9078 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
9079 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
9080 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
9081 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
9082 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
9083 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
9084 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
9085 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
9086 HAS_CHANGE_EVENT(element, CE_NEXT_TO_X) ? CE_NEXT_TO_X :
9087 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
9088 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
9089 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
9090 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
9091 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
9092 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
9093 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
9094 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
9095 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
9096 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
9097 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
9098 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
9099 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
9100 HAS_CHANGE_EVENT(element, CE_MOUSE_CLICKED_ON_X) ? CE_MOUSE_CLICKED_ON_X :
9101 HAS_CHANGE_EVENT(element, CE_MOUSE_PRESSED_ON_X) ? CE_MOUSE_PRESSED_ON_X :
9102 custom_element_change.other_action);
9105 static void CopyGroupElementPropertiesToEditor(int element)
9107 group_element_info = *element_info[element].group;
9108 custom_element = element_info[element]; // needed for description
9111 static void CopyEmptyElementPropertiesToEditor(int element)
9113 custom_element = element_info[element];
9116 static void CopyClassicElementPropertiesToEditor(int element)
9118 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
9119 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
9120 getMoveIntoAcidProperty(&level, element);
9122 if (MAYBE_DONT_COLLIDE_WITH(element))
9123 custom_element_properties[EP_DONT_COLLIDE_WITH] =
9124 getDontCollideWithProperty(&level, element);
9127 static void CopyElementPropertiesToEditor(int element)
9129 if (IS_CUSTOM_ELEMENT(element))
9130 CopyCustomElementPropertiesToEditor(element);
9131 else if (IS_GROUP_ELEMENT(element))
9132 CopyGroupElementPropertiesToEditor(element);
9133 else if (IS_EMPTY_ELEMENT(element))
9134 CopyEmptyElementPropertiesToEditor(element);
9136 CopyClassicElementPropertiesToEditor(element);
9139 static boolean AskToCopyAndModifyLevelTemplate(void)
9141 if (Request("Copy and modify settings from level template?", REQ_ASK))
9143 level.use_custom_template = FALSE;
9145 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_1],
9146 GDI_CHECKED, FALSE, GDI_END);
9147 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_2],
9148 GDI_CHECKED, FALSE, GDI_END);
9154 LoadLevelTemplate(-1); // this resets all element modifications ...
9156 DrawEditModeWindow(); // ... and copies them to 'custom_element'
9162 static void CopyCustomElementPropertiesToGame(int element)
9165 int access_type_and_layer;
9167 // mark that this custom element has been modified
9168 custom_element.modified_settings = TRUE;
9169 level.changed = TRUE;
9171 if (level.use_custom_template)
9172 AskToCopyAndModifyLevelTemplate();
9174 element_info[element] = custom_element;
9175 *element_info[element].change = custom_element_change;
9177 // ---------- element settings: configure (custom elements) -----------------
9179 // set accessible property from checkbox and selectbox
9180 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
9181 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
9182 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
9183 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
9184 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
9185 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
9186 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
9187 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
9188 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
9189 custom_element_properties[access_type_and_layer] =
9190 custom_element_properties[EP_ACCESSIBLE];
9191 custom_element_properties[EP_PROTECTED] =
9192 (custom_element.access_protected != 0 &&
9193 custom_element_properties[EP_ACCESSIBLE]);
9195 // set walk-to-object property from checkbox and selectbox
9196 custom_element_properties[EP_DIGGABLE] = FALSE;
9197 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
9198 custom_element_properties[EP_DROPPABLE] = FALSE;
9199 custom_element_properties[EP_THROWABLE] = FALSE;
9200 custom_element_properties[EP_PUSHABLE] = FALSE;
9201 custom_element_properties[custom_element.walk_to_action] =
9202 custom_element_properties[EP_WALK_TO_OBJECT];
9204 // set smash property from checkbox and selectbox
9205 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
9206 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
9207 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
9208 custom_element_properties[custom_element.smash_targets] =
9209 custom_element_properties[EP_CAN_SMASH];
9211 // set deadliness property from checkbox and selectbox
9212 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
9213 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
9214 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
9215 custom_element_properties[EP_DONT_TOUCH] = FALSE;
9216 custom_element_properties[custom_element.deadliness] =
9217 custom_element_properties[EP_DEADLY];
9219 // ---------- element settings: advanced (custom elements) ------------------
9221 // set player change event from checkbox and selectbox
9222 custom_element_change_events[CE_NEXT_TO_PLAYER] = FALSE;
9223 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
9224 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
9225 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
9226 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
9227 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
9228 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
9229 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
9230 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
9231 custom_element_change_events[CE_SWITCHED] = FALSE;
9232 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
9233 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
9234 custom_element_change_events[CE_BLOCKED] = FALSE;
9235 custom_element_change_events[CE_IMPACT] = FALSE;
9236 custom_element_change_events[CE_SMASHED] = FALSE;
9237 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
9238 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
9239 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
9240 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
9241 custom_element_change_events[CE_CLICKED_BY_MOUSE] = FALSE;
9242 custom_element_change_events[CE_PRESSED_BY_MOUSE] = FALSE;
9243 custom_element_change_events[custom_element_change.direct_action] =
9244 custom_element_change_events[CE_BY_DIRECT_ACTION];
9246 // set other element action change event from checkbox and selectbox
9247 custom_element_change_events[CE_PLAYER_NEXT_TO_X] = FALSE;
9248 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
9249 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
9250 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
9251 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
9252 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
9253 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
9254 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
9255 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
9256 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
9257 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
9258 custom_element_change_events[CE_NEXT_TO_X] = FALSE;
9259 custom_element_change_events[CE_TOUCHING_X] = FALSE;
9260 custom_element_change_events[CE_HITTING_X] = FALSE;
9261 custom_element_change_events[CE_DIGGING_X] = FALSE;
9262 custom_element_change_events[CE_HIT_BY_X] = FALSE;
9263 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
9264 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
9265 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
9266 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
9267 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
9268 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
9269 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
9270 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
9271 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
9272 custom_element_change_events[CE_MOUSE_CLICKED_ON_X] = FALSE;
9273 custom_element_change_events[CE_MOUSE_PRESSED_ON_X] = FALSE;
9274 custom_element_change_events[custom_element_change.other_action] =
9275 custom_element_change_events[CE_BY_OTHER_ACTION];
9277 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
9278 SET_PROPERTY(element, i, custom_element_properties[i]);
9280 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
9281 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
9283 // copy change events also to special level editor variable
9284 custom_element = element_info[element];
9285 custom_element_change = *element_info[element].change;
9287 // needed here to restore runtime value "element_info[element].gfx_element"
9288 InitElementPropertiesGfxElement();
9291 static void CopyGroupElementPropertiesToGame(int element)
9293 // mark that this group element has been modified
9294 custom_element.modified_settings = TRUE;
9295 level.changed = TRUE;
9297 if (level.use_custom_template)
9298 AskToCopyAndModifyLevelTemplate();
9300 element_info[element] = custom_element;
9301 *element_info[element].group = group_element_info;
9303 // needed here to restore runtime value "element_info[element].gfx_element"
9304 InitElementPropertiesGfxElement();
9307 static void CopyEmptyElementPropertiesToGame(int element)
9309 // mark that this empty element has been modified
9310 custom_element.modified_settings = TRUE;
9311 level.changed = TRUE;
9313 if (level.use_custom_template)
9314 AskToCopyAndModifyLevelTemplate();
9316 element_info[element] = custom_element;
9318 // needed here to restore runtime value "element_info[element].gfx_element"
9319 InitElementPropertiesGfxElement();
9322 static void CopyClassicElementPropertiesToGame(int element)
9324 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
9325 setMoveIntoAcidProperty(&level, element,
9326 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
9328 if (MAYBE_DONT_COLLIDE_WITH(element))
9329 setDontCollideWithProperty(&level, element,
9330 custom_element_properties[EP_DONT_COLLIDE_WITH]);
9333 static void CopyElementPropertiesToGame(int element)
9335 if (IS_CUSTOM_ELEMENT(element))
9336 CopyCustomElementPropertiesToGame(element);
9337 else if (IS_GROUP_ELEMENT(element))
9338 CopyGroupElementPropertiesToGame(element);
9339 else if (IS_EMPTY_ELEMENT(element))
9340 CopyEmptyElementPropertiesToGame(element);
9342 CopyClassicElementPropertiesToGame(element);
9346 static void CheckElementDescriptions(void)
9350 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
9351 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
9352 Warn("no element description file for element '%s'", EL_NAME(i));
9356 static int getMaxEdFieldX(boolean has_scrollbar)
9358 int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
9359 int sxsize = SXSIZE - scrollbar_width;
9360 int max_ed_fieldx = sxsize / ed_tilesize;
9362 return max_ed_fieldx;
9365 static int getMaxEdFieldY(boolean has_scrollbar)
9367 int infotext_height = (IN_PIX_FIELD(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY) ?
9368 INFOTEXT_YSIZE_FULL : 0);
9369 int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
9370 int sysize = SYSIZE - scrollbar_height - infotext_height;
9371 int max_ed_fieldy = sysize / ed_tilesize;
9373 return max_ed_fieldy;
9376 static void InitZoomLevelSettings(int zoom_tilesize)
9378 static int last_game_engine_type = GAME_ENGINE_TYPE_UNKNOWN;
9380 if (zoom_tilesize == -1 && level.game_engine_type != last_game_engine_type)
9382 ed_tilesize = setup.auto_setup.editor_zoom_tilesize;
9383 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
9385 // make sure that tile size is always a power of 2
9386 ed_tilesize = (1 << log_2(ed_tilesize));
9388 if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
9390 ed_tilesize = DEFAULT_EDITOR_TILESIZE_MM;
9391 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE_MM;
9395 last_game_engine_type = level.game_engine_type;
9397 // limit zoom tilesize by upper and lower bound
9398 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
9400 // store zoom tilesize in auto setup file only if it was manually changed
9401 if (zoom_tilesize != -1)
9402 setup.auto_setup.editor_zoom_tilesize = ed_tilesize;
9404 MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
9405 MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
9408 static void InitDrawingElements(void)
9410 static int game_engine_type_last = GAME_ENGINE_TYPE_UNKNOWN;
9412 if (level.game_engine_type == game_engine_type_last)
9415 if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
9417 new_element1 = EL_BD_WALL;
9418 new_element2 = EL_EMPTY;
9419 new_element3 = EL_BD_SAND;
9421 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
9423 new_element1 = EL_SP_CHIP_SINGLE;
9424 new_element2 = EL_EMPTY;
9425 new_element3 = EL_SP_BASE;
9427 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
9429 new_element1 = EL_MM_MIRROR_START;
9430 new_element2 = EL_EMPTY;
9431 new_element3 = EL_MM_WOODEN_WALL;
9435 new_element1 = EL_WALL;
9436 new_element2 = EL_EMPTY;
9437 new_element3 = EL_SAND;
9440 game_engine_type_last = level.game_engine_type;
9443 static void InitLevelSetInfo(void)
9445 snprintf(levelset_name, MAX_LEVEL_NAME_LEN + 1,
9446 "%s", leveldir_current->name);
9447 snprintf(levelset_author, MAX_LEVEL_AUTHOR_LEN + 1,
9448 "%s", leveldir_current->author);
9450 levelset_num_levels = leveldir_current->levels;
9452 levelset_use_levelset_artwork = FALSE;
9453 levelset_copy_level_template = FALSE;
9455 levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
9458 static void ChangeEditorToLevelSet(char *levelset_subdir)
9460 leveldir_current = getTreeInfoFromIdentifier(leveldir_first, levelset_subdir);
9462 // the previous level set might have used custom artwork
9463 ReloadCustomArtwork(0);
9465 LoadLevelSetup_SeriesInfo();
9467 SaveLevelSetup_LastSeries();
9468 SaveLevelSetup_SeriesInfo();
9472 LoadLevel(level_nr);
9473 LoadScore(level_nr);
9478 static boolean useEditorDoorAnimation(void)
9480 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
9481 boolean door_1_viewport_unchanged =
9482 (vp_door_1->x == DX &&
9483 vp_door_1->y == DY &&
9484 vp_door_1->width == DXSIZE &&
9485 vp_door_1->height == DYSIZE);
9486 boolean door_1_contains_toolbox =
9489 EX + EXSIZE <= DX + DXSIZE &&
9490 EY + EYSIZE <= DY + DYSIZE);
9492 return (door_1_viewport_unchanged && door_1_contains_toolbox);
9495 static void DrawEditorDoorBackground(int graphic, int x, int y,
9496 int width, int height)
9498 struct GraphicInfo *g = &graphic_info[graphic];
9500 if (g->bitmap != NULL)
9501 BlitBitmap(g->bitmap, drawto, g->src_x, g->src_y,
9502 MIN(width, g->width), MIN(height, g->height), x, y);
9504 ClearRectangle(drawto, x, y, width, height);
9507 static void DrawEditorDoorContent(void)
9509 // needed for gadgets drawn on background (like palette scrollbar)
9510 SetDoorBackgroundImage(IMG_UNDEFINED);
9512 // copy default editor door content to main double buffer
9513 DrawEditorDoorBackground(IMG_BACKGROUND_PALETTE, DX, DY, DXSIZE, DYSIZE);
9516 DrawSpecialEditorDoor();
9518 // draw new control window
9519 DrawEditorDoorBackground(IMG_BACKGROUND_TOOLBOX, EX, EY, EXSIZE, EYSIZE);
9521 // draw all toolbox gadgets to editor doors
9522 MapControlButtons();
9524 // when returning from test game to properties page, redraw toolbox gadgets
9525 if (edit_mode == ED_MODE_PROPERTIES)
9527 UnmapLevelEditorToolboxDrawingGadgets();
9528 UnmapLevelEditorToolboxCustomGadgets();
9530 MapLevelEditorToolboxCustomGadgetsIfNeeded();
9533 // draw all palette gadgets to editor doors
9534 ModifyEditorElementList();
9535 RedrawDrawingElements();
9537 // copy actual editor door content to door double buffer for OpenDoor()
9538 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
9541 void DrawLevelEd(void)
9543 int fade_mask = REDRAW_FIELD;
9545 FadeSoundsAndMusic();
9548 fade_mask = REDRAW_ALL;
9552 // needed if different viewport properties defined for editor
9553 ChangeViewportPropertiesIfNeeded();
9557 InitZoomLevelSettings(-1);
9558 InitDrawingElements();
9562 CheckElementDescriptions();
9565 if (level_editor_test_game)
9567 CopyPlayfield(level.field, Tile);
9568 CopyPlayfield(TileBackup, level.field);
9570 level_editor_test_game = FALSE;
9574 edit_mode = ED_MODE_DRAWING;
9575 edit_mode_levelconfig = ED_MODE_LEVELCONFIG_LEVEL;
9576 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
9584 // redraw_mask |= REDRAW_ALL;
9586 FreeLevelEditorGadgets();
9587 CreateLevelEditorGadgets();
9589 ReinitializeElementList(); // update dynamic level element list
9590 ReinitializeElementListButtons(); // custom element may look different
9592 InitElementPropertiesGfxElement();
9596 DrawEditModeWindow_PlayfieldOnly();
9598 DrawMaskedBorder(fade_mask);
9600 // use door animation if door 1 viewport is unchanged and contains toolbox
9601 if (useEditorDoorAnimation())
9605 DrawEditorDoorContent();
9607 OpenDoor(DOOR_OPEN_1 | DOOR_FORCE_ANIM);
9611 DrawEditorDoorContent();
9616 SetDoorState(DOOR_OPEN_1 | DOOR_OPEN_2);
9619 static void AdjustDrawingAreaGadgets(void)
9621 int ed_xsize = lev_fieldx + 2;
9622 int ed_ysize = lev_fieldy + 2;
9623 int max_ed_fieldx = MAX_ED_FIELDX;
9624 int max_ed_fieldy = MAX_ED_FIELDY;
9625 boolean horizontal_scrollbar_needed;
9626 boolean vertical_scrollbar_needed;
9627 int x, y, width, height;
9629 if (suppressBorderElement())
9631 ed_xsize = lev_fieldx;
9632 ed_ysize = lev_fieldy;
9635 // check if we need any scrollbars
9636 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9637 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9639 // check if we have a smaller editor field because of scrollbars
9640 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9641 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9643 // check again if we now need more scrollbars because of less space
9644 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9645 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9647 // check if editor field gets even smaller after adding new scrollbars
9648 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9649 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9651 ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
9652 ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
9654 x = SX + ed_fieldx * ed_tilesize;
9655 y = SY + ed_fieldy * ed_tilesize;
9657 width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
9658 height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
9660 // adjust drawing area gadget
9661 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
9662 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
9663 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
9666 // adjust horizontal scrollbar gadgets
9667 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
9670 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
9671 GDI_X, x - ED_SCROLLBUTTON_XSIZE,
9674 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
9677 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
9680 // adjust vertical scrollbar gadgets
9681 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
9684 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
9686 GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
9688 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
9691 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
9695 static void AdjustLevelScrollPosition(void)
9697 if (level_xpos < -1)
9699 if (level_xpos > lev_fieldx - ed_fieldx + 1)
9700 level_xpos = lev_fieldx - ed_fieldx + 1;
9701 if (lev_fieldx < ed_fieldx - 2)
9704 if (level_ypos < -1)
9706 if (level_ypos > lev_fieldy - ed_fieldy + 1)
9707 level_ypos = lev_fieldy - ed_fieldy + 1;
9708 if (lev_fieldy < ed_fieldy - 2)
9711 if (suppressBorderElement())
9718 static void AdjustEditorScrollbar(int id)
9720 struct GadgetInfo *gi = level_editor_gadget[id];
9721 int items_max, items_visible, item_position;
9723 if (id == GADGET_ID_SCROLL_HORIZONTAL)
9725 items_max = MAX(lev_fieldx + 2, ed_fieldx);
9726 items_visible = ed_fieldx;
9727 item_position = level_xpos + 1;
9731 items_max = MAX(lev_fieldy + 2, ed_fieldy);
9732 items_visible = ed_fieldy;
9733 item_position = level_ypos + 1;
9736 if (item_position > items_max - items_visible)
9737 item_position = items_max - items_visible;
9739 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9740 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9743 static void AdjustElementListScrollbar(void)
9745 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
9746 int items_max, items_visible, item_position;
9748 // correct position of element list scrollbar
9749 if (element_shift < 0)
9751 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
9752 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
9754 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
9755 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
9756 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
9758 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9759 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
9760 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9763 static void ModifyEditorCounterValue(int counter_id, int new_value)
9765 int *counter_value = counterbutton_info[counter_id].value;
9766 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9767 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9769 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
9771 if (counter_value != NULL)
9772 *counter_value = gi->textinput.number_value;
9775 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
9777 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9778 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9780 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
9782 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
9783 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
9785 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
9786 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
9788 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
9789 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_SMALL_DISTANCE,
9794 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
9796 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9797 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9798 int new_index_value = setSelectboxValue(selectbox_id, new_value);
9800 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
9803 static void ModifyEditorSelectboxOptions(int selectbox_id,
9804 struct ValueTextInfo *options)
9806 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9807 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9809 selectbox_info[selectbox_id].options = options;
9811 // set index to zero -- list may be shorter now (correct later, if needed)
9812 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
9813 GDI_SELECTBOX_OPTIONS, options, GDI_END);
9816 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
9818 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
9819 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9821 drawingarea_info[drawingarea_id].area_xsize = xsize;
9822 drawingarea_info[drawingarea_id].area_ysize = ysize;
9824 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
9827 static void ModifyEditorElementList(void)
9831 if (!use_permanent_palette && edit_mode != ED_MODE_PALETTE)
9834 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
9836 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
9837 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9838 struct GadgetDesign *gd = &gi->deco.design;
9839 int element = editor_elements[element_shift + i];
9840 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
9844 getEditorGraphicSource(element, tile_size, &gd->bitmap, &gd->x, &gd->y);
9846 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
9852 static void DrawDrawingElementGraphic(int element, struct XYTileSize *pos)
9854 int graphic = el2edimg(element);
9855 int tile_size = BUTTON_TILE_SIZE(pos->tile_size);
9861 DrawSizedGraphicExt(drawto, DX + pos->x, DY + pos->y, graphic, 0, tile_size);
9864 static void ModifyDrawingElementButton(int element, int id)
9866 struct GadgetInfo *gi = level_editor_gadget[id];
9867 Bitmap *deco_bitmap;
9869 int tile_size = gi->deco.width;
9871 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
9873 ModifyGadget(gi, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_END);
9876 static void PickDrawingElement(int button, int element)
9881 struct XYTileSize *pos;
9883 } de, drawing_elements[] =
9885 { &new_element1, &editor.palette.element_left, GADGET_ID_ELEMENT_LEFT },
9886 { &new_element2, &editor.palette.element_middle, GADGET_ID_ELEMENT_MIDDLE },
9887 { &new_element3, &editor.palette.element_right, GADGET_ID_ELEMENT_RIGHT },
9890 if (button < 1 || button > 3)
9893 if (IS_MM_WALL(element))
9894 element = map_mm_wall_element(element);
9896 de = drawing_elements[button - 1];
9898 *de.new_element = element; // update global drawing element variable
9900 DrawDrawingElementGraphic(element, de.pos);
9901 ModifyDrawingElementButton(element, de.id);
9903 redraw_mask |= REDRAW_DOOR_1;
9906 static void RedrawDrawingElements(void)
9908 PickDrawingElement(1, new_element1);
9909 PickDrawingElement(2, new_element2);
9910 PickDrawingElement(3, new_element3);
9913 static void DrawDrawingWindowExt(boolean remap_toolbox_gadgets)
9915 stick_element_properties_window = FALSE;
9917 SetMainBackgroundImage(IMG_UNDEFINED);
9920 UnmapLevelEditorFieldGadgets();
9922 AdjustDrawingAreaGadgets();
9923 AdjustLevelScrollPosition();
9924 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
9925 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
9927 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9929 MapMainDrawingArea();
9931 if (remap_toolbox_gadgets)
9933 UnmapLevelEditorToolboxCustomGadgets();
9934 MapLevelEditorToolboxDrawingGadgets();
9938 static void DrawDrawingWindow(void)
9940 DrawDrawingWindowExt(TRUE);
9943 static int getTabulatorBarWidth(void)
9945 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9946 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
9948 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
9951 static int getTabulatorBarHeight(void)
9953 return ED_TAB_BAR_HEIGHT;
9956 static Pixel getTabulatorBarColor(void)
9958 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9959 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9960 int gd_x = gd->x + gd_gi1->border.width / 2;
9961 int gd_y = gd->y + gd_gi1->height - 1;
9963 return GetPixel(gd->bitmap, gd_x, gd_y);
9966 static void DrawLevelConfigTabulatorGadgets(void)
9968 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9969 Pixel tab_color = getTabulatorBarColor();
9970 int id_first = ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL;
9971 int id_last = ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR;
9974 // draw additional "engine" tabulator when using native BD engine
9975 if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
9976 id_last = ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE;
9978 for (i = id_first; i <= id_last; i++)
9980 int gadget_id = textbutton_info[i].gadget_id;
9981 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9982 boolean active = (i != edit_mode_levelconfig);
9984 // draw background line below tabulator button
9985 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9987 // draw solid line below inactive tabulator buttons
9988 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9989 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9990 ED_GADGET_TINY_DISTANCE, tab_color);
9992 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9993 MapTextbuttonGadget(i);
9996 // draw little border line below tabulator buttons
9997 if (tab_color != BLACK_PIXEL) // black => transparent
9998 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9999 ED_GADGET_TINY_DISTANCE,
10000 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
10003 static void DrawPropertiesTabulatorGadgets(void)
10005 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
10006 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
10007 int gd_x = gd->x + gd_gi1->border.width / 2;
10008 int gd_y = gd->y + gd_gi1->height - 1;
10009 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
10010 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
10011 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
10014 // draw two config tabulators for player elements
10015 if (IS_PLAYER_ELEMENT(properties_element))
10016 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
10018 // draw two config and one "change" tabulator for custom elements
10019 if (IS_CUSTOM_ELEMENT(properties_element))
10020 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
10022 for (i = id_first; i <= id_last; i++)
10024 int gadget_id = textbutton_info[i].gadget_id;
10025 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
10026 boolean active = (i != edit_mode_properties);
10028 // use "config 1" and "config 2" instead of "config" for players and CEs
10029 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
10030 (IS_PLAYER_ELEMENT(properties_element) ||
10031 IS_CUSTOM_ELEMENT(properties_element)))
10034 // draw background line below tabulator button
10035 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
10037 // draw solid line below inactive tabulator buttons
10038 if (!active && tab_color != BLACK_PIXEL) // black => transparent
10039 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
10040 ED_GADGET_TINY_DISTANCE, tab_color);
10042 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
10043 MapTextbuttonGadget(i);
10046 // draw little border line below tabulator buttons
10047 if (tab_color != BLACK_PIXEL) // black => transparent
10048 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
10049 ED_GADGET_TINY_DISTANCE,
10050 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
10053 static void PrintInfoText(char *text, int font_nr, int xpos, int ypos)
10055 DrawText(SX + xpos, SY + ypos, text, font_nr);
10058 static int PrintElementDescriptionFromFile(char *filename, int font_nr,
10059 int xpos, int ypos)
10061 int font_width = getFontWidth(font_nr);
10062 int font_height = getFontHeight(font_nr);
10063 int max_chars_per_line = (SXSIZE - 2 * xpos) / font_width;
10064 int max_lines_drawable = (SYSIZE - ypos) / font_height - 1;
10066 return DrawTextFile(SX + xpos, SY + ypos, filename, font_nr,
10067 max_chars_per_line, -1, max_lines_drawable, 0, -1,
10068 TRUE, FALSE, FALSE);
10071 static void DrawLevelConfigLevel(void)
10075 // draw counter gadgets
10076 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
10077 MapCounterButtons(i);
10079 // draw checkbutton gadgets
10080 for (i = ED_CHECKBUTTON_ID_LEVEL_FIRST; i<= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
10081 MapCheckbuttonGadget(i);
10083 // draw selectbox gadgets
10084 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
10085 MapSelectboxGadget(i);
10087 // draw text input gadgets
10088 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
10089 MapTextInputGadget(i);
10092 static char *getLevelSubdirFromSaveMode(int save_mode)
10094 if (save_mode == LEVELSET_SAVE_MODE_CREATE)
10095 return getNewUserLevelSubdir();
10097 return leveldir_current->subdir;
10100 static void DrawLevelConfigLevelSet_DirectoryInfo(void)
10102 char *directory_text = "Level set directory:";
10103 char *directory_name = getLevelSubdirFromSaveMode(levelset_save_mode);
10104 int font1_nr = FONT_TEXT_1;
10105 int font2_nr = FONT_TEXT_2;
10106 int font1_height = getFontHeight(font1_nr);
10107 int yoffset_above = font1_height + ED_GADGET_LINE_DISTANCE;
10108 int x = ED_LEVEL_SETTINGS_X(0);
10109 int y = ED_LEVEL_SETTINGS_Y(6);
10111 PrintInfoText(directory_text, font1_nr, x, y - yoffset_above);
10112 PrintInfoText(directory_name, font2_nr, x, y);
10115 static void DrawLevelConfigLevelSet(void)
10117 boolean artwork_exists = checkIfCustomArtworkExistsForCurrentLevelSet();
10118 boolean template_exists = fileExists(getLocalLevelTemplateFilename());
10121 // draw counter gadgets
10122 for (i = ED_COUNTER_ID_LEVELSET_FIRST; i <= ED_COUNTER_ID_LEVELSET_LAST; i++)
10123 MapCounterButtons(i);
10125 // draw checkbutton gadgets
10126 for (i = ED_CHECKBUTTON_ID_LEVELSET_FIRST; i <= ED_CHECKBUTTON_ID_LEVELSET_LAST; i++)
10128 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE ||
10129 (i == ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK && !artwork_exists) ||
10130 (i == ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE && !template_exists))
10133 MapCheckbuttonGadget(i);
10136 // draw selectbox gadgets
10137 for (i = ED_SELECTBOX_ID_LEVELSET_FIRST; i <= ED_SELECTBOX_ID_LEVELSET_LAST; i++)
10138 MapSelectboxGadget(i);
10140 // draw text input gadgets
10141 for (i = ED_TEXTINPUT_ID_LEVELSET_FIRST; i <= ED_TEXTINPUT_ID_LEVELSET_LAST; i++)
10142 MapTextInputGadget(i);
10144 // draw textbutton gadgets
10145 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_LEVELSET);
10148 DrawLevelConfigLevelSet_DirectoryInfo();
10151 static void DrawLevelConfigEditor(void)
10155 // draw counter gadgets
10156 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
10157 MapCounterButtons(i);
10159 // draw checkbutton gadgets
10160 for (i = ED_CHECKBUTTON_ID_EDITOR_FIRST; i <= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
10161 MapCheckbuttonGadget(i);
10163 // draw radiobutton gadgets
10164 for (i = ED_RADIOBUTTON_ID_EDITOR_FIRST; i <= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
10165 MapRadiobuttonGadget(i);
10167 // draw drawing area
10168 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
10170 // draw textbutton gadgets
10171 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2);
10174 static void DrawLevelConfigEngine(void)
10178 // draw counter gadgets
10179 if (level.bd_scheduling_type == GD_SCHEDULING_MILLISECONDS)
10181 MapCounterButtons(ED_COUNTER_ID_BD_CYCLE_DELAY_MS);
10182 MapCounterButtons(ED_COUNTER_ID_BD_HATCHING_DELAY_CYCLES);
10186 MapCounterButtons(ED_COUNTER_ID_BD_CYCLE_DELAY_C64);
10187 MapCounterButtons(ED_COUNTER_ID_BD_HATCHING_DELAY_SECONDS);
10190 // draw checkbutton gadgets
10191 for (i = ED_CHECKBUTTON_ID_ENGINE_FIRST; i <= ED_CHECKBUTTON_ID_ENGINE_LAST; i++)
10192 MapCheckbuttonGadget(i);
10194 // draw selectbox gadgets
10195 for (i = ED_SELECTBOX_ID_ENGINE_FIRST; i <= ED_SELECTBOX_ID_ENGINE_LAST; i++)
10196 MapSelectboxGadget(i);
10199 static void DrawLevelConfigWindow(void)
10201 char *text = "Global Settings";
10202 int font_nr = FONT_TITLE_1;
10203 struct MenuPosInfo *pos = &editor.settings.headline;
10204 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font_nr), pos->align);
10205 int sy = SY + pos->y;
10207 stick_element_properties_window = FALSE;
10209 SetAutomaticNumberOfGemsNeeded();
10211 UnmapLevelEditorFieldGadgets();
10213 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10216 DrawText(sx, sy, text, font_nr);
10218 DrawLevelConfigTabulatorGadgets();
10220 if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVEL)
10221 DrawLevelConfigLevel();
10222 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVELSET)
10223 DrawLevelConfigLevelSet();
10224 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_EDITOR)
10225 DrawLevelConfigEditor();
10226 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_ENGINE)
10227 DrawLevelConfigEngine();
10230 static void DrawCustomContentArea(void)
10232 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
10233 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
10234 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
10235 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
10236 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
10237 int xoffset = ED_GADGET_SPACE_DISTANCE;
10239 // add distance for potential left text (without drawing area border)
10240 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
10242 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
10244 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
10247 static void DrawCustomChangeContentArea(void)
10249 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
10250 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
10251 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
10252 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
10253 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
10254 int xoffset = ED_GADGET_SPACE_DISTANCE;
10256 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
10258 MapDrawingArea(id);
10261 static void RemoveElementContentArea(int id, int font_height)
10263 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10265 DrawBackground(SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size,
10266 SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size,
10267 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10268 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size +
10269 ED_GADGET_TEXT_DISTANCE + font_height);
10272 static void DrawYamYamContentAreas(void)
10274 int font_nr = FONT_TEXT_1;
10275 int font_height = getFontHeight(font_nr);
10276 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
10277 int yoffset = (tilesize - font_height) / 2;
10278 int x = SX + ED_AREA_YAMYAM_CONTENT_X(3) + 4 * tilesize;
10279 int y = SY + ED_AREA_YAMYAM_CONTENT_Y(3) + yoffset;
10282 // display counter to choose number of element content areas
10283 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
10285 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
10287 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
10289 if (i < level.num_yamyam_contents)
10291 MapDrawingArea(id);
10295 UnmapDrawingArea(id);
10297 // delete content areas in case of reducing number of them
10298 RemoveElementContentArea(id, font_height);
10302 DrawText(x, y + 0 * tilesize, "content", font_nr);
10303 DrawText(x, y + 1 * tilesize, "when", font_nr);
10304 DrawText(x, y + 2 * tilesize, "smashed", font_nr);
10307 static void DrawMagicBallContentAreas(void)
10309 int font_nr = FONT_TEXT_1;
10310 int font_height = getFontHeight(font_nr);
10311 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
10312 int yoffset = (tilesize - font_height) / 2;
10313 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_X(3) + 4 * tilesize;
10314 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_Y(3) + yoffset;
10317 // display counter to choose number of element content areas
10318 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
10320 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
10322 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
10324 if (i < level.num_ball_contents)
10326 MapDrawingArea(id);
10330 UnmapDrawingArea(id);
10332 // delete content areas in case of reducing number of them
10333 RemoveElementContentArea(id, font_height);
10337 DrawText(x, y + 0 * tilesize, "generated", font_nr);
10338 DrawText(x, y + 1 * tilesize, "when", font_nr);
10339 DrawText(x, y + 2 * tilesize, "active", font_nr);
10342 static void DrawAndroidElementArea(void)
10344 int id = ED_DRAWING_ID_ANDROID_CONTENT;
10345 int num_elements = level.num_android_clone_elements;
10346 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10347 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10348 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10349 int xsize = MAX_ANDROID_ELEMENTS;
10352 // display counter to choose number of element areas
10353 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
10355 if (drawingarea_info[id].text_left != NULL)
10356 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10358 UnmapDrawingArea(id);
10360 ModifyEditorDrawingArea(id, num_elements, 1);
10362 // delete content areas in case of reducing number of them
10363 DrawBackground(sx, sy,
10364 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10365 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10367 MapDrawingArea(id);
10370 static void DrawGroupElementArea(void)
10372 int id = ED_DRAWING_ID_GROUP_CONTENT;
10373 int num_elements = group_element_info.num_elements;
10374 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10375 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10376 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10377 int xsize = MAX_ELEMENTS_IN_GROUP;
10380 if (drawingarea_info[id].text_left != NULL)
10381 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10383 UnmapDrawingArea(id);
10385 ModifyEditorDrawingArea(id, num_elements, 1);
10387 // delete content areas in case of reducing number of them
10388 DrawBackground(sx, sy,
10389 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10390 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10392 MapDrawingArea(id);
10395 static void DrawPlayerInitialInventoryArea(int element)
10397 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
10398 int player_nr = GET_PLAYER_NR(element);
10399 int num_elements = level.initial_inventory_size[player_nr];
10400 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10401 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10402 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10403 int xsize = MAX_INITIAL_INVENTORY_SIZE;
10406 // determine horizontal position to the right of specified gadget
10407 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
10408 sx = (right_gadget_border[drawingarea_info[id].gadget_id_align] +
10409 ED_DRAWINGAREA_TEXT_DISTANCE);
10411 // determine horizontal offset for leading text
10412 if (drawingarea_info[id].text_left != NULL)
10413 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10415 UnmapDrawingArea(id);
10417 ModifyEditorDrawingArea(id, num_elements, 1);
10419 // delete content areas in case of reducing number of them
10420 DrawBackground(sx, sy,
10421 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10422 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10424 MapDrawingArea(id);
10427 static void DrawMMBallContentArea(void)
10429 int id = ED_DRAWING_ID_MM_BALL_CONTENT;
10430 int num_elements = level.num_mm_ball_contents;
10431 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10432 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10433 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10434 int xsize = MAX_MM_BALL_CONTENTS;
10437 if (drawingarea_info[id].text_left != NULL)
10438 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10440 UnmapDrawingArea(id);
10442 ModifyEditorDrawingArea(id, num_elements, 1);
10444 // delete content areas in case of reducing number of them
10445 DrawBackground(sx, sy,
10446 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10447 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10449 MapDrawingArea(id);
10452 static void DrawEnvelopeTextArea(int envelope_nr)
10454 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
10455 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
10459 DrawBackground(gi->x, gi->y,
10460 gi->textarea.crop_width, gi->textarea.crop_height);
10462 if (envelope_nr != -1)
10463 textarea_info[id].value = level.envelope[envelope_nr].text;
10465 ModifyGadget(gi, GDI_AREA_SIZE,
10466 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
10467 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
10470 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
10473 static void DrawPropertiesInfo(void)
10482 // configurable properties
10484 { EP_WALKABLE_OVER, "- player can walk over it" },
10485 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
10486 { EP_WALKABLE_UNDER, "- player can walk under it" },
10487 { EP_PASSABLE_OVER, "- player can pass over it" },
10488 { EP_PASSABLE_INSIDE, "- player can pass through it" },
10489 { EP_PASSABLE_UNDER, "- player can pass under it" },
10490 { EP_PROTECTED, "- player is protected by it" },
10492 { EP_DIGGABLE, "- can be digged away" },
10493 { EP_COLLECTIBLE, "- can be collected" },
10494 { EP_DROPPABLE, "- can be dropped after collecting" },
10495 { EP_THROWABLE, "- can be thrown after collecting" },
10496 { EP_PUSHABLE, "- can be pushed" },
10498 { EP_CAN_FALL, "- can fall" },
10499 { EP_CAN_MOVE, "- can move" },
10501 { EP_CAN_SMASH_PLAYER, "- can smash player" },
10503 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
10505 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
10507 { EP_SLIPPERY, "- slippery for falling elements" },
10508 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
10510 { EP_DONT_RUN_INTO, "- deadly when running into" },
10511 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
10512 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
10513 { EP_DONT_TOUCH, "- deadly when touching" },
10515 { EP_INDESTRUCTIBLE, "- indestructible" },
10517 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
10518 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
10519 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
10521 { EP_CAN_CHANGE, "- can change to other element" },
10523 // pre-defined properties
10524 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
10525 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
10526 { EP_SWITCHABLE, "- can be switched" },
10528 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
10533 char *filename = getElementDescriptionFilename(properties_element);
10534 char *num_elements_text = "In this level: ";
10535 char *num_similar_text = "Similar tiles: ";
10536 char *properties_text = "Standard properties: ";
10537 char *description_text = "Description:";
10538 char *no_description_text = "No description available.";
10539 char *none_text = "None";
10541 int num_elements_in_level = 0;
10542 int num_similar_in_level = 0;
10543 int num_hires_tiles_in_level = 0;
10544 int num_standard_properties = 0;
10545 int font1_nr = FONT_TEXT_1;
10546 int font2_nr = FONT_TEXT_2;
10547 int font1_width = getFontWidth(font1_nr);
10548 int font1_height = getFontHeight(font1_nr);
10549 int font2_height = getFontHeight(font2_nr);
10550 int line1_height = font1_height + ED_GADGET_LINE_DISTANCE;
10551 int font2_yoffset = (font1_height - font2_height) / 2;
10552 int num_elements_text_len = strlen(num_elements_text) * font1_width;
10553 int num_similar_text_len = strlen(num_similar_text) * font1_width;
10554 int properties_text_len = strlen(properties_text) * font1_width;
10555 int xpos = ED_ELEMENT_SETTINGS_X(0);
10556 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10559 if (setup.editor.show_element_token)
10561 int font3_nr = FONT_TEXT_3;
10562 int font3_height = getFontHeight(font3_nr);
10564 DrawTextF(xpos, ypos, font3_nr,
10565 "[%s]", element_info[properties_element].token_name);
10567 ypos += 2 * font3_height;
10570 // ----- print number of elements / percentage of this element in level
10572 for (y = 0; y < lev_fieldy; y++)
10574 for (x = 0; x < lev_fieldx; x++)
10576 if (Tile[x][y] == properties_element)
10578 num_elements_in_level++;
10580 else if (IS_MM_WALL(Tile[x][y]) &&
10581 map_mm_wall_element(Tile[x][y]) == properties_element)
10583 num_hires_tiles_in_level += numHiresTiles(Tile[x][y]);
10588 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10590 DrawTextS(xpos, ypos, font1_nr, num_elements_text);
10592 if (num_hires_tiles_in_level > 0)
10593 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10594 "%d wall tiles", num_hires_tiles_in_level);
10595 else if (num_elements_in_level > 0)
10596 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10597 "%d (%.2f %%)", num_elements_in_level, percentage);
10599 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10602 // ----- print number of similar elements / percentage of them in level
10604 for (y = 0; y < lev_fieldy; y++)
10606 for (x = 0; x < lev_fieldx; x++)
10608 if (strEqual(element_info[Tile[x][y]].class_name,
10609 element_info[properties_element].class_name))
10611 num_similar_in_level++;
10616 if (num_similar_in_level != num_elements_in_level)
10618 ypos += 1 * MAX(font1_height, font2_height);
10620 percentage = num_similar_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10622 DrawTextS(xpos, ypos, font1_nr, num_similar_text);
10624 if (num_similar_in_level > 0)
10625 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10626 "%d (%.2f %%)", num_similar_in_level, percentage);
10628 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10632 ypos += 2 * MAX(font1_height, font2_height);
10634 // ----- print standard properties of this element
10636 DrawTextS(xpos, ypos, font1_nr, properties_text);
10638 ypos += line1_height;
10640 for (i = 0; properties[i].value != -1; i++)
10642 if (!HAS_PROPERTY(properties_element, properties[i].value))
10645 DrawTextS(xpos, ypos, font2_nr, properties[i].text);
10647 ypos += font2_height;
10649 num_standard_properties++;
10652 if (num_standard_properties == 0)
10654 DrawTextS(xpos + properties_text_len, ypos - line1_height + font2_yoffset,
10655 font2_nr, none_text);
10657 ypos -= (line1_height - font1_height);
10660 ypos += MAX(font1_height, font2_height);
10662 // ----- print special description of this element
10664 PrintInfoText(description_text, font1_nr, xpos, ypos);
10666 ypos += line1_height;
10668 if (PrintElementDescriptionFromFile(filename, font2_nr, xpos, ypos) == 0)
10669 PrintInfoText(no_description_text, font1_nr, xpos, ypos - line1_height);
10672 #define TEXT_COLLECTING "Score for collecting"
10673 #define TEXT_COLLECTING_EXTRA "Score for extra diamonds"
10674 #define TEXT_SMASHING "Score for smashing"
10675 #define TEXT_SLURPING "Score for slurping robot"
10676 #define TEXT_CRACKING "Score for cracking"
10677 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
10678 #define TEXT_DURATION "Duration when activated"
10679 #define TEXT_DELAY_ON "Delay before activating"
10680 #define TEXT_DELAY_OFF "Delay before deactivating"
10681 #define TEXT_DELAY_CHANGING "Delay before changing"
10682 #define TEXT_DELAY_EXPLODING "Delay before exploding"
10683 #define TEXT_DELAY_MOVING "Delay before moving"
10684 #define TEXT_BALL_DELAY "Element generation delay"
10685 #define TEXT_MOVE_SPEED "Speed of android moving"
10686 #define TEXT_CLONE_SPEED "Speed of android cloning"
10687 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
10688 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
10689 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
10690 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
10691 #define TEXT_TIME_BONUS "Extra time to solve level"
10698 } elements_with_counter[] =
10700 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
10701 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
10702 { EL_BD_DIAMOND, &level.score[SC_DIAMOND_EXTRA], TEXT_COLLECTING_EXTRA },
10703 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
10704 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
10705 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10706 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
10707 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
10708 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
10709 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
10710 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
10711 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
10712 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
10713 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10714 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10715 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
10716 { EL_BD_BUTTERFLY_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
10717 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
10718 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10719 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10720 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
10721 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10722 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10723 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10724 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10725 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10726 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10727 { EL_BD_FIREFLY_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10728 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10729 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10730 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10731 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10732 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10733 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10734 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10735 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
10736 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
10737 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10738 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
10739 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10740 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10741 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10742 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10743 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10744 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
10745 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10746 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10747 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE], TEXT_COLLECTING },
10748 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10749 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10750 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
10751 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
10752 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
10753 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10754 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10755 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10756 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10757 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10758 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10759 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10760 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10761 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
10762 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
10763 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
10764 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
10765 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
10766 { EL_MM_KETTLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10767 { EL_DF_CELL, &level.score[SC_EMERALD], TEXT_COLLECTING },
10768 { EL_MM_KEY, &level.score[SC_KEY], TEXT_COLLECTING },
10769 { EL_MM_LIGHTBALL, &level.score[SC_ELEM_BONUS], TEXT_COLLECTING },
10770 { EL_MM_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10771 { EL_MM_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10772 { EL_MM_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10773 { EL_MM_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10774 { EL_MM_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10775 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10776 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10777 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10778 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10779 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10780 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10781 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10782 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10783 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
10784 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
10785 { EL_DC_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
10786 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
10787 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
10788 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
10789 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
10790 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
10791 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
10792 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
10793 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
10794 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
10795 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
10796 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
10797 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
10798 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
10799 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
10800 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
10801 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
10802 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
10803 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
10804 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
10805 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
10806 { EL_SPRING_LEFT, &level.slurp_score, TEXT_SLURPING },
10807 { EL_SPRING_RIGHT, &level.slurp_score, TEXT_SLURPING },
10808 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
10809 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
10810 { EL_MM_FUSE_ACTIVE, &level.mm_time_fuse, TEXT_DELAY_OFF },
10811 { EL_MM_BOMB, &level.mm_time_bomb, TEXT_DELAY_EXPLODING },
10812 { EL_MM_GRAY_BALL, &level.mm_time_ball, TEXT_DELAY_CHANGING },
10813 { EL_MM_STEEL_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10814 { EL_MM_WOODEN_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10819 static boolean checkPropertiesConfig(int element)
10823 // special case: empty space customization only available in R'n'D game engine
10824 if (element == EL_EMPTY_SPACE && level.game_engine_type != GAME_ENGINE_TYPE_RND)
10827 // special case: BD style rock customization only available in BD game engine
10828 if (element == EL_BD_ROCK && level.game_engine_type != GAME_ENGINE_TYPE_BD)
10831 if (IS_GEM(element) ||
10832 IS_CUSTOM_ELEMENT(element) ||
10833 IS_GROUP_ELEMENT(element) ||
10834 IS_EMPTY_ELEMENT(element) ||
10835 IS_BALLOON_ELEMENT(element) ||
10836 IS_ENVELOPE(element) ||
10837 IS_MM_ENVELOPE(element) ||
10838 IS_MM_MCDUFFIN(element) ||
10839 IS_DF_LASER(element) ||
10840 IS_PLAYER_ELEMENT(element) ||
10841 IS_BD_PLAYER_ELEMENT(element) ||
10842 IS_SOKOBAN_OBJECT_OR_FIELD(element) ||
10843 HAS_EDITOR_CONTENT(element) ||
10844 CAN_GROW(element) ||
10845 COULD_MOVE_INTO_ACID(element) ||
10846 MAYBE_DONT_COLLIDE_WITH(element) ||
10847 element == EL_BD_ROCK ||
10848 element == EL_BD_MEGA_ROCK ||
10849 element == EL_BD_SWEET)
10855 for (i = 0; elements_with_counter[i].element != -1; i++)
10856 if (elements_with_counter[i].element == element)
10863 static void SetAutomaticNumberOfGemsNeeded(void)
10867 if (!level.auto_count_gems)
10870 level.gems_needed = 0;
10872 for (x = 0; x < lev_fieldx; x++)
10874 for (y = 0; y < lev_fieldy; y++)
10876 int element = Tile[x][y];
10881 case EL_EMERALD_YELLOW:
10882 case EL_EMERALD_RED:
10883 case EL_EMERALD_PURPLE:
10884 case EL_BD_DIAMOND:
10885 case EL_WALL_EMERALD:
10886 case EL_WALL_EMERALD_YELLOW:
10887 case EL_WALL_EMERALD_RED:
10888 case EL_WALL_EMERALD_PURPLE:
10889 case EL_WALL_BD_DIAMOND:
10891 case EL_SP_INFOTRON:
10894 level.gems_needed++;
10898 case EL_WALL_DIAMOND:
10899 level.gems_needed += 3;
10903 case EL_WALL_PEARL:
10904 level.gems_needed += 5;
10908 case EL_WALL_CRYSTAL:
10909 level.gems_needed += 8;
10918 ModifyEditorCounterValue(ED_COUNTER_ID_LEVEL_GEMSLIMIT, level.gems_needed);
10921 static void DrawPropertiesConfig(void)
10923 boolean draw_footer_line = FALSE;
10924 int max_num_element_counters = 4;
10925 int num_element_counters = 0;
10928 if (!checkPropertiesConfig(properties_element))
10930 int xpos = ED_ELEMENT_SETTINGS_X(0);
10931 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10933 PrintInfoText("No configuration options available.",
10934 FONT_TEXT_1, xpos, ypos);
10939 // check if there are elements where a value can be chosen for
10940 for (i = 0; elements_with_counter[i].element != -1; i++)
10942 if (elements_with_counter[i].element == properties_element)
10944 // special case: score for extra diamonds only available in BD game engine
10945 if (elements_with_counter[i].element == EL_BD_DIAMOND &&
10946 elements_with_counter[i].value == &level.score[SC_DIAMOND_EXTRA] &&
10947 level.game_engine_type != GAME_ENGINE_TYPE_BD)
10950 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
10952 counterbutton_info[counter_id].y =
10953 ED_ELEMENT_SETTINGS_YPOS(
10954 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
10955 (CAN_GROW(properties_element) ? 1 : 0) +
10956 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
10957 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
10958 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
10959 num_element_counters);
10961 counterbutton_info[counter_id].value = elements_with_counter[i].value;
10962 counterbutton_info[counter_id].text_right = elements_with_counter[i].text;
10964 if (properties_element == EL_GAME_OF_LIFE ||
10965 properties_element == EL_BIOMAZE)
10967 counterbutton_info[counter_id].min_value = 0; // min neighbours
10968 counterbutton_info[counter_id].max_value = 8; // max neighbours
10972 // !!! CHANGE THIS FOR CERTAIN ELEMENTS !!!
10973 counterbutton_info[counter_id].min_value = MIN_SCORE;
10974 counterbutton_info[counter_id].max_value = MAX_SCORE;
10977 MapCounterButtons(counter_id);
10979 num_element_counters++;
10980 if (num_element_counters >= max_num_element_counters)
10985 if (HAS_EDITOR_CONTENT(properties_element))
10987 // draw stickybutton gadget
10988 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10990 if (IS_AMOEBOID(properties_element))
10991 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
10992 else if (properties_element == EL_YAMYAM ||
10993 properties_element == EL_YAMYAM_LEFT ||
10994 properties_element == EL_YAMYAM_RIGHT ||
10995 properties_element == EL_YAMYAM_UP ||
10996 properties_element == EL_YAMYAM_DOWN)
10997 DrawYamYamContentAreas();
10998 else if (properties_element == EL_EMC_MAGIC_BALL)
11000 DrawMagicBallContentAreas();
11002 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
11003 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE);
11005 else if (properties_element == EL_EMC_ANDROID)
11006 DrawAndroidElementArea();
11007 else if (properties_element == EL_MM_GRAY_BALL)
11009 MapCounterButtons(ED_COUNTER_ID_MM_BALL_CONTENT);
11010 MapSelectboxGadget(ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE);
11011 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT);
11012 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EXPLODE_MM_BALL);
11014 DrawMMBallContentArea();
11018 if (IS_PLAYER_ELEMENT(properties_element))
11020 int player_nr = GET_PLAYER_NR(properties_element);
11022 // these properties can be set for every player individually
11024 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
11026 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
11027 &level.start_element[player_nr];
11028 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
11029 &level.artwork_element[player_nr];
11030 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
11031 &level.explosion_element[player_nr];
11033 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
11034 &level.use_start_element[player_nr];
11035 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
11036 &level.use_artwork_element[player_nr];
11037 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
11038 &level.use_explosion_element[player_nr];
11039 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
11040 &level.initial_player_gravity[player_nr];
11042 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
11043 &level.initial_player_stepsize[player_nr];
11045 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
11046 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
11047 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
11048 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
11049 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
11050 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
11051 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
11052 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
11053 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_LAZY_RELOCATION);
11054 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
11055 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
11056 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
11057 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
11058 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
11059 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER);
11061 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
11062 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
11063 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
11065 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
11067 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
11069 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
11070 &level.initial_inventory_content[player_nr][0];
11072 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
11073 &level.initial_inventory_size[player_nr];
11075 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
11076 &level.use_initial_inventory[player_nr];
11078 // draw checkbutton gadgets
11079 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
11080 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT);
11081 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE);
11083 // draw counter gadgets
11084 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
11086 // draw drawing area gadgets
11087 DrawPlayerInitialInventoryArea(properties_element);
11091 if (IS_BD_PLAYER_ELEMENT(properties_element))
11093 counterbutton_info[ED_COUNTER_ID_BD_PUSHING_PROB].y =
11094 ED_ELEMENT_SETTINGS_YPOS(2);
11095 counterbutton_info[ED_COUNTER_ID_BD_PUSHING_PROB_WITH_SWEET].y =
11096 ED_ELEMENT_SETTINGS_YPOS(3);
11097 checkbutton_info[ED_CHECKBUTTON_ID_BD_PUSH_MEGA_ROCK_WITH_SWEET].y =
11098 ED_ELEMENT_SETTINGS_YPOS(4);
11100 // draw checkbutton gadgets
11101 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS);
11102 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_TOPMOST_PLAYER_ACTIVE);
11103 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_PUSH_MEGA_ROCK_WITH_SWEET);
11105 // draw counter gadgets
11106 MapCounterButtons(ED_COUNTER_ID_BD_PUSHING_PROB);
11107 MapCounterButtons(ED_COUNTER_ID_BD_PUSHING_PROB_WITH_SWEET);
11110 if (properties_element == EL_BD_ROCK && level.game_engine_type == GAME_ENGINE_TYPE_BD)
11112 counterbutton_info[ED_COUNTER_ID_BD_PUSHING_PROB].y =
11113 ED_ELEMENT_SETTINGS_YPOS(0);
11114 counterbutton_info[ED_COUNTER_ID_BD_PUSHING_PROB_WITH_SWEET].y =
11115 ED_ELEMENT_SETTINGS_YPOS(1);
11117 MapCounterButtons(ED_COUNTER_ID_BD_PUSHING_PROB);
11118 MapCounterButtons(ED_COUNTER_ID_BD_PUSHING_PROB_WITH_SWEET);
11121 if (properties_element == EL_BD_MEGA_ROCK ||
11122 properties_element == EL_BD_SWEET)
11124 counterbutton_info[ED_COUNTER_ID_BD_PUSHING_PROB_WITH_SWEET].y =
11125 ED_ELEMENT_SETTINGS_YPOS(0);
11126 checkbutton_info[ED_CHECKBUTTON_ID_BD_PUSH_MEGA_ROCK_WITH_SWEET].y =
11127 ED_ELEMENT_SETTINGS_YPOS(1);
11129 MapCounterButtons(ED_COUNTER_ID_BD_PUSHING_PROB_WITH_SWEET);
11130 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_PUSH_MEGA_ROCK_WITH_SWEET);
11133 // special case: slippery walls option for gems only available in R'n'D game engine
11134 if (IS_GEM(properties_element) && level.game_engine_type == GAME_ENGINE_TYPE_RND)
11135 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
11137 if (properties_element == EL_EM_DYNAMITE)
11138 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
11140 if (COULD_MOVE_INTO_ACID(properties_element) &&
11141 !IS_PLAYER_ELEMENT(properties_element) &&
11142 (!IS_CUSTOM_ELEMENT(properties_element) ||
11143 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
11145 // set position for checkbutton for "can move into acid"
11146 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
11147 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
11148 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
11149 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 7 :
11150 IS_BALLOON_ELEMENT(properties_element) ||
11151 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
11153 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
11156 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
11157 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
11159 if (properties_element == EL_SPRING ||
11160 properties_element == EL_SPRING_LEFT ||
11161 properties_element == EL_SPRING_RIGHT)
11162 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
11164 if (properties_element == EL_TIME_ORB_FULL)
11165 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
11167 if (properties_element == EL_GAME_OF_LIFE ||
11168 properties_element == EL_BIOMAZE)
11169 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_LIFE_BUGS);
11171 if (CAN_GROW(properties_element))
11173 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
11174 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
11176 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
11179 if (properties_element == EL_SOKOBAN_FIELD_EMPTY)
11180 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED);
11182 if (properties_element == EL_SOKOBAN_OBJECT)
11183 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED);
11185 if (properties_element == EL_SOKOBAN_OBJECT ||
11186 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
11187 properties_element == EL_SOKOBAN_FIELD_FULL)
11189 checkbutton_info[ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN].y =
11190 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_SOKOBAN_FIELD_FULL ?
11193 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
11196 if (IS_BALLOON_ELEMENT(properties_element))
11197 MapSelectboxGadget(ED_SELECTBOX_ID_WIND_DIRECTION);
11199 if (IS_ENVELOPE(properties_element) ||
11200 IS_MM_ENVELOPE(properties_element))
11202 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
11203 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
11204 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
11205 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
11206 int envelope_nr = ENVELOPE_NR(properties_element);
11208 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
11209 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
11211 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
11212 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
11214 // display counter to choose size of envelope text area
11215 MapCounterButtons(counter1_id);
11216 MapCounterButtons(counter2_id);
11218 // display checkbuttons to choose auto-wrap and alignment properties
11219 MapCheckbuttonGadget(button1_id);
11220 MapCheckbuttonGadget(button2_id);
11222 DrawEnvelopeTextArea(envelope_nr);
11225 if (IS_MM_MCDUFFIN(properties_element))
11227 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_RED);
11228 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_GREEN);
11229 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_BLUE);
11232 if (IS_DF_LASER(properties_element))
11234 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_RED);
11235 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_GREEN);
11236 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_BLUE);
11239 if (IS_CUSTOM_ELEMENT(properties_element))
11241 // draw stickybutton gadget
11242 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11244 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
11246 // draw checkbutton gadgets
11247 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
11248 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
11249 MapCheckbuttonGadget(i);
11251 // draw counter gadgets
11252 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
11253 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
11254 MapCounterButtons(i);
11256 // draw selectbox gadgets
11257 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
11258 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
11259 MapSelectboxGadget(i);
11261 // draw textbutton gadgets
11262 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11264 // draw text input gadgets
11265 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
11267 // draw drawing area gadgets
11268 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11270 draw_footer_line = TRUE;
11272 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
11274 // draw checkbutton gadgets
11275 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
11276 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
11277 MapCheckbuttonGadget(i);
11279 // draw counter gadgets
11280 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
11281 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
11282 MapCounterButtons(i);
11284 // draw selectbox gadgets
11285 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
11286 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
11287 MapSelectboxGadget(i);
11289 // draw drawing area gadgets
11290 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
11291 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
11292 DrawCustomContentArea();
11295 else if (IS_GROUP_ELEMENT(properties_element))
11297 // draw stickybutton gadget
11298 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11300 // draw checkbutton gadgets
11301 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
11302 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
11304 // draw counter gadgets
11305 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
11307 // draw selectbox gadgets
11308 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
11310 // draw textbutton gadgets
11311 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11313 // draw drawing area gadgets
11314 DrawGroupElementArea();
11316 // draw text input gadgets
11317 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
11319 // draw drawing area gadgets
11320 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11322 draw_footer_line = TRUE;
11324 else if (IS_EMPTY_ELEMENT(properties_element))
11326 // draw stickybutton gadget
11327 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11329 // draw checkbutton gadgets
11330 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
11331 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
11333 // draw textbutton gadgets
11334 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11336 // draw drawing area gadgets
11337 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11339 draw_footer_line = TRUE;
11342 // draw little footer border line above CE/GE use/save template gadgets
11343 if (draw_footer_line)
11345 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
11346 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
11347 int gd_x = gd->x + gd_gi1->border.width / 2;
11348 int gd_y = gd->y + gd_gi1->height - 1;
11349 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
11351 if (tab_color != BLACK_PIXEL) // black => transparent
11352 FillRectangle(drawto,
11353 SX + ED_ELEMENT_SETTINGS_X(0),
11354 SY + ED_ELEMENT_SETTINGS_Y(14) - ED_SETTINGS_TABS_YOFFSET -
11356 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
11360 static void DrawPropertiesChangeDrawingAreas(void)
11362 if (IS_CUSTOM_ELEMENT(properties_element))
11364 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
11365 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
11366 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
11368 DrawCustomChangeContentArea();
11371 redraw_mask |= REDRAW_FIELD;
11374 static void DrawPropertiesChange(void)
11378 // needed to initially set selectbox options for special action options
11379 setSelectboxSpecialActionOptions();
11381 // draw stickybutton gadget
11382 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11384 // draw checkbutton gadgets
11385 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
11386 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
11387 MapCheckbuttonGadget(i);
11389 // draw counter gadgets
11390 for (i = ED_COUNTER_ID_CHANGE_FIRST;
11391 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
11392 MapCounterButtons(i);
11394 // draw selectbox gadgets
11395 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
11396 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
11397 MapSelectboxGadget(i);
11399 // draw textbutton gadgets
11400 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
11401 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
11402 MapTextbuttonGadget(i);
11404 // draw graphicbutton gadgets
11405 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
11406 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
11407 MapGraphicbuttonGadget(i);
11409 // draw drawing area gadgets
11410 DrawPropertiesChangeDrawingAreas();
11413 static void DrawEditorElementAnimation(int x, int y)
11415 int graphic = el2img(properties_element);
11416 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
11417 custom_element.ce_value_fixed_initial :
11418 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
11419 custom_element.collect_score_initial : FrameCounter);
11421 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
11424 static void DrawEditorElementName(int x, int y, int font_nr)
11426 char *element_name = getElementInfoText(properties_element);
11427 int font_width = getFontWidth(font_nr);
11428 int font_height = getFontHeight(font_nr);
11429 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
11430 int max_chars_per_line = max_text_width / font_width;
11432 if (strlen(element_name) <= max_chars_per_line)
11433 DrawTextS(x, y, font_nr, element_name);
11436 char buffer[max_chars_per_line + 1];
11437 int next_pos = max_chars_per_line;
11439 strncpy(buffer, element_name, max_chars_per_line);
11440 buffer[max_chars_per_line] = '\0';
11442 if (element_name[max_chars_per_line] == ' ')
11448 for (i = max_chars_per_line - 1; i >= 0; i--)
11449 if (buffer[i] == ' ')
11452 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
11459 DrawTextS(x, y - font_height / 2, font_nr, buffer);
11461 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
11462 buffer[max_chars_per_line] = '\0';
11464 DrawTextS(x, y + font_height / 2, font_nr, buffer);
11468 static void DrawPropertiesWindow(void)
11470 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
11471 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
11472 int border_size = gd->border_size;
11473 int font_nr = FONT_TEXT_1;
11474 int font_height = getFontHeight(font_nr);
11475 int xoffset = TILEX + element_border + 3 * border_size;
11476 int yoffset = (TILEY - font_height) / 2;
11477 int x1 = editor.settings.element_graphic.x + element_border;
11478 int y1 = editor.settings.element_graphic.y + element_border;
11479 int x2 = (editor.settings.element_name.x == -1 ? x1 + xoffset :
11480 editor.settings.element_name.x);
11481 int y2 = (editor.settings.element_name.y == -1 ? y1 + yoffset :
11482 editor.settings.element_name.y);
11483 char *text = "Element Settings";
11484 int font2_nr = FONT_TITLE_1;
11485 struct MenuPosInfo *pos = &editor.settings.headline;
11486 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font2_nr), pos->align);
11487 int sy = SY + pos->y;
11489 stick_element_properties_window = FALSE;
11491 // make sure that previous properties edit mode exists for this element
11492 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
11493 !IS_CUSTOM_ELEMENT(properties_element))
11494 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
11496 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
11497 !IS_PLAYER_ELEMENT(properties_element) &&
11498 !IS_CUSTOM_ELEMENT(properties_element))
11499 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
11501 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
11502 (IS_PLAYER_ELEMENT(properties_element) ||
11503 IS_CUSTOM_ELEMENT(properties_element)))
11504 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
11506 CopyElementPropertiesToEditor(properties_element);
11508 UnmapLevelEditorFieldGadgets();
11509 UnmapLevelEditorToolboxDrawingGadgets();
11510 UnmapLevelEditorToolboxCustomGadgets();
11512 MapLevelEditorToolboxCustomGadgetsIfNeeded();
11514 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
11517 DrawText(sx, sy, text, font2_nr);
11519 FrameCounter = 0; // restart animation frame counter
11521 DrawElementBorder(SX + x1, SY + y1, TILEX, TILEY, FALSE);
11522 DrawEditorElementAnimation(SX + x1, SY + y1);
11523 DrawEditorElementName(x2, y2, font_nr);
11525 DrawPropertiesTabulatorGadgets();
11527 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
11528 DrawPropertiesInfo();
11529 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
11530 DrawPropertiesChange();
11531 else // (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2])
11532 DrawPropertiesConfig();
11535 static void DrawPaletteWindow(void)
11539 UnmapLevelEditorFieldGadgets();
11541 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
11544 // map buttons to select elements
11545 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
11546 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
11547 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
11548 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
11549 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
11552 static void UpdateCustomElementGraphicGadgets(void)
11556 InitElementPropertiesGfxElement();
11558 ModifyEditorElementList();
11559 RedrawDrawingElements();
11561 // force redraw of all mapped drawing area gadgets
11562 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
11564 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
11571 static int getOpenDirectionFromTube(int element)
11575 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
11576 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
11577 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
11578 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
11579 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
11580 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
11581 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
11582 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
11583 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
11584 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
11585 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
11591 static int getTubeFromOpenDirection(int direction)
11595 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
11596 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
11597 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
11598 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
11599 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
11600 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
11601 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
11602 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
11603 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
11604 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
11605 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
11607 // if only one direction, fall back to simple tube with that direction
11608 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
11609 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
11610 case (MV_UP): return EL_TUBE_VERTICAL;
11611 case (MV_DOWN): return EL_TUBE_VERTICAL;
11617 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
11619 int element_new = getTubeFromOpenDirection(direction);
11621 return (element_new != EL_EMPTY ? element_new : element_old);
11624 static int getOpenDirectionFromBelt(int element)
11626 int belt_dir = getBeltDirFromBeltElement(element);
11628 return (belt_dir == MV_LEFT ? MV_RIGHT :
11629 belt_dir == MV_RIGHT ? MV_LEFT :
11630 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
11633 static int getBeltFromNrAndOpenDirection(int nr, int direction)
11635 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
11636 direction == MV_RIGHT ? MV_LEFT :
11637 direction == MV_HORIZONTAL ? MV_NONE : direction);
11639 if (direction == MV_NONE)
11642 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
11645 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
11648 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
11650 return (element_new != EL_EMPTY ? element_new : element_old);
11653 static int getOpenDirectionFromPool(int element)
11657 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
11658 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
11659 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
11660 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
11661 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
11662 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
11668 static int getPoolFromOpenDirection(int direction)
11672 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
11673 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
11674 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
11675 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
11676 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
11677 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
11683 static int getPoolFromOpenDirectionExt(int direction, int help_element)
11685 int element = getPoolFromOpenDirection(direction);
11686 int help_direction = getOpenDirectionFromPool(help_element);
11688 if (element == EL_EMPTY)
11690 int help_direction_vertical = help_direction & MV_VERTICAL;
11692 element = getPoolFromOpenDirection(direction | help_direction_vertical);
11695 if (element == EL_EMPTY)
11697 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
11699 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
11705 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
11707 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
11709 return (element_new != EL_EMPTY ? element_new : element_old);
11712 static int getOpenDirectionFromPillar(int element)
11716 case EL_EMC_WALL_1: return (MV_DOWN);
11717 case EL_EMC_WALL_2: return (MV_VERTICAL);
11718 case EL_EMC_WALL_3: return (MV_UP);
11724 static int getPillarFromOpenDirection(int direction)
11728 case (MV_DOWN): return EL_EMC_WALL_1;
11729 case (MV_VERTICAL): return EL_EMC_WALL_2;
11730 case (MV_UP): return EL_EMC_WALL_3;
11736 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
11738 int element_new = getPillarFromOpenDirection(direction);
11740 return (element_new != EL_EMPTY ? element_new : element_old);
11743 static int getOpenDirectionFromSteel2(int element)
11747 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
11748 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
11749 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
11750 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
11751 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
11752 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
11753 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
11754 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
11760 static int getSteel2FromOpenDirection(int direction)
11764 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
11765 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
11766 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
11767 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
11768 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
11769 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
11770 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
11771 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
11777 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
11779 int element_new = getSteel2FromOpenDirection(direction);
11781 return (element_new != EL_EMPTY ? element_new : element_old);
11784 static int getOpenDirectionFromChip(int element)
11788 case EL_SP_CHIP_SINGLE: return (MV_NONE);
11789 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
11790 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
11791 case EL_SP_CHIP_TOP: return (MV_DOWN);
11792 case EL_SP_CHIP_BOTTOM: return (MV_UP);
11798 static int getChipFromOpenDirection(int direction)
11802 case (MV_NONE): return EL_SP_CHIP_SINGLE;
11803 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
11804 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
11805 case (MV_UP): return EL_SP_CHIP_BOTTOM;
11806 case (MV_DOWN): return EL_SP_CHIP_TOP;
11812 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
11814 int element_new = getChipFromOpenDirection(direction);
11816 return (element_new != EL_EMPTY ? element_new : element_old);
11819 static int getClosedTube(int x, int y)
11821 struct XY *xy = xy_directions;
11822 int element_old = IntelliDrawBuffer[x][y];
11823 int direction_old = getOpenDirectionFromTube(element_old);
11824 int direction_new = MV_NONE;
11827 for (i = 0; i < NUM_DIRECTIONS; i++)
11829 int xx = x + xy[i].x;
11830 int yy = y + xy[i].y;
11831 int dir = MV_DIR_FROM_BIT(i);
11832 int dir_opposite = MV_DIR_OPPOSITE(dir);
11834 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
11835 (direction_old & dir) &&
11836 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11837 direction_new |= dir;
11840 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
11843 static int getClosedBelt(int x, int y)
11845 struct XY *xy = xy_directions;
11846 int element_old = IntelliDrawBuffer[x][y];
11847 int nr = getBeltNrFromBeltElement(element_old);
11848 int direction_old = getOpenDirectionFromBelt(element_old);
11849 int direction_new = MV_NONE;
11852 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11854 int xx = x + xy[i].x;
11855 int yy = y + xy[i].y;
11856 int dir = MV_DIR_FROM_BIT(i);
11857 int dir_opposite = MV_DIR_OPPOSITE(dir);
11859 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
11860 (direction_old & dir) &&
11861 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11862 direction_new |= dir;
11865 return getBeltFromNrAndOpenDirection(nr, direction_new);
11868 static int getClosedPool(int x, int y)
11870 struct XY *xy = xy_directions;
11871 int element_old = IntelliDrawBuffer[x][y];
11872 int direction_old = getOpenDirectionFromPool(element_old);
11873 int direction_new = MV_NONE;
11876 for (i = 0; i < NUM_DIRECTIONS; i++)
11878 int xx = x + xy[i].x;
11879 int yy = y + xy[i].y;
11880 int dir = MV_DIR_FROM_BIT(i);
11881 int dir_opposite = MV_DIR_OPPOSITE(dir);
11883 if (IN_LEV_FIELD(xx, yy) &&
11884 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
11885 (direction_old & dir) &&
11886 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11887 direction_new |= dir;
11890 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
11893 static int getClosedPillar(int x, int y)
11895 struct XY *xy = xy_directions;
11896 int element_old = IntelliDrawBuffer[x][y];
11897 int direction_old = getOpenDirectionFromPillar(element_old);
11898 int direction_new = MV_NONE;
11901 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11903 int xx = x + xy[i].x;
11904 int yy = y + xy[i].y;
11905 int dir = MV_DIR_FROM_BIT(i);
11906 int dir_opposite = MV_DIR_OPPOSITE(dir);
11908 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
11909 (direction_old & dir) &&
11910 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11911 direction_new |= dir;
11914 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
11917 static int getClosedSteel2(int x, int y)
11919 struct XY *xy = xy_directions;
11920 int element_old = IntelliDrawBuffer[x][y];
11921 int direction_old = getOpenDirectionFromSteel2(element_old);
11922 int direction_new = MV_NONE;
11925 for (i = 0; i < NUM_DIRECTIONS; i++)
11927 int xx = x + xy[i].x;
11928 int yy = y + xy[i].y;
11929 int dir = MV_DIR_FROM_BIT(i);
11930 int dir_opposite = MV_DIR_OPPOSITE(dir);
11932 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
11933 (direction_old & dir) &&
11934 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11935 direction_new |= dir;
11938 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
11941 static int getClosedChip(int x, int y)
11943 struct XY *xy = xy_directions;
11944 int element_old = IntelliDrawBuffer[x][y];
11945 int direction_old = getOpenDirectionFromChip(element_old);
11946 int direction_new = MV_NONE;
11949 for (i = 0; i < NUM_DIRECTIONS; i++)
11951 int xx = x + xy[i].x;
11952 int yy = y + xy[i].y;
11953 int dir = MV_DIR_FROM_BIT(i);
11954 int dir_opposite = MV_DIR_OPPOSITE(dir);
11956 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
11957 (direction_old & dir) &&
11958 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11959 direction_new |= dir;
11962 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
11965 static void SetElementSimpleExt(int x, int y, int dx, int dy, int element,
11966 boolean change_level)
11968 int sx = x - level_xpos;
11969 int sy = y - level_ypos;
11970 int old_element = Tile[x][y];
11971 int new_element = element;
11972 unsigned int new_bitmask = (getDrawModeHiRes() ? (dx + 1) << (dy * 2) : 0x0f);
11973 boolean draw_masked = FALSE;
11975 if (IS_MM_WALL_EDITOR(element))
11977 element = map_mm_wall_element_editor(element) | new_bitmask;
11979 if (IS_MM_WALL(old_element))
11980 element |= MM_WALL_BITS(old_element);
11983 draw_masked = TRUE;
11985 else if (IS_MM_WALL(old_element) && element == EL_EMPTY)
11987 int element_changed = old_element & ~new_bitmask;
11989 if (MM_WALL_BITS(element_changed) != 0)
11990 element = element_changed;
11993 IntelliDrawBuffer[x][y] = element;
11996 Tile[x][y] = element;
11998 if (IN_ED_FIELD(sx, sy))
12000 if (IS_MM_WALL(old_element) && new_element == EL_EMPTY)
12001 DrawSizedWallParts_MM(sx, sy, EL_EMPTY, ed_tilesize, FALSE, new_bitmask);
12002 else if (draw_masked)
12003 DrawEditorElementThruMask(sx, sy, element);
12005 DrawEditorElement(sx, sy, element);
12009 static void SetElementSimple(int x, int y, int element, boolean change_level)
12011 SetElementSimpleExt(x, y, 0, 0, element, change_level);
12014 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
12015 int x2, int y2, int *element2,
12016 int (*close_function)(int, int),
12017 boolean change_level)
12019 // set neighbour elements to newly determined connections
12020 SetElementSimple(x1, y1, *element1, change_level);
12021 SetElementSimple(x2, y2, *element2, change_level);
12023 // remove all open connections of neighbour elements
12024 *element1 = close_function(x1, y1);
12025 *element2 = close_function(x2, y2);
12027 // set neighbour elements to new, minimized connections
12028 SetElementSimple(x1, y1, *element1, change_level);
12029 SetElementSimple(x2, y2, *element2, change_level);
12032 static void SetElementIntelliDraw(int x, int y, int dx, int dy, int new_element,
12033 boolean change_level, int button)
12035 struct XY *xy = xy_directions;
12036 static int last_x = -1;
12037 static int last_y = -1;
12039 if (new_element == EL_UNDEFINED)
12047 int old_element = IntelliDrawBuffer[x][y];
12049 if (IS_TUBE(new_element))
12051 int last_element_new = EL_UNDEFINED;
12052 int direction = MV_NONE;
12055 // if old element is of same kind, keep all existing directions
12056 if (IS_TUBE(old_element))
12057 direction |= getOpenDirectionFromTube(old_element);
12059 for (i = 0; i < NUM_DIRECTIONS; i++)
12061 int xx = x + xy[i].x;
12062 int yy = y + xy[i].y;
12064 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12065 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
12067 int dir = MV_DIR_FROM_BIT(i);
12068 int dir_opposite = MV_DIR_OPPOSITE(dir);
12069 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12070 int last_direction_old = getOpenDirectionFromTube(last_element_old);
12071 int last_direction_new = last_direction_old | dir_opposite;
12073 last_element_new = getTubeFromOpenDirection(last_direction_new);
12079 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
12081 if (last_element_new != EL_UNDEFINED)
12082 MergeAndCloseNeighbourElements(x, y, &new_element,
12083 last_x, last_y, &last_element_new,
12084 getClosedTube, change_level);
12086 else if (IS_BELT(new_element))
12088 int belt_nr = getBeltNrFromBeltElement(new_element);
12089 int last_element_new = EL_UNDEFINED;
12090 int direction = MV_NONE;
12093 // if old element is of same kind, keep all existing directions
12094 if (IS_BELT(old_element))
12095 direction |= getOpenDirectionFromBelt(old_element);
12097 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
12099 int xx = x + xy[i].x;
12100 int yy = y + xy[i].y;
12102 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12103 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
12105 int dir = MV_DIR_FROM_BIT(i);
12106 int dir_opposite = MV_DIR_OPPOSITE(dir);
12107 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12108 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
12109 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
12110 int last_direction_new = last_direction_old | dir_opposite;
12112 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
12113 last_direction_new);
12118 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
12120 if (last_element_new != EL_UNDEFINED)
12121 MergeAndCloseNeighbourElements(x, y, &new_element,
12122 last_x, last_y, &last_element_new,
12123 getClosedBelt, change_level);
12125 else if (IS_ACID_POOL_OR_ACID(new_element))
12127 int last_element_new = EL_UNDEFINED;
12128 int direction = MV_NONE;
12131 // if old element is of same kind, keep all existing directions
12132 if (IS_ACID_POOL_OR_ACID(old_element))
12133 direction |= getOpenDirectionFromPool(old_element);
12135 for (i = 0; i < NUM_DIRECTIONS; i++)
12137 int xx = x + xy[i].x;
12138 int yy = y + xy[i].y;
12140 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12141 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
12143 int dir = MV_DIR_FROM_BIT(i);
12144 int dir_opposite = MV_DIR_OPPOSITE(dir);
12145 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12146 int last_direction_old = getOpenDirectionFromPool(last_element_old);
12147 int last_direction_new = last_direction_old | dir_opposite;
12149 last_element_new = getPoolFromOpenDirection(last_direction_new);
12155 // special corrections needed for intuitively correct acid pool drawing
12156 if (last_element_new == EL_EMPTY)
12157 last_element_new = new_element;
12158 else if (last_element_new != EL_UNDEFINED)
12159 new_element = last_element_new;
12161 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
12163 if (last_element_new != EL_UNDEFINED)
12164 MergeAndCloseNeighbourElements(x, y, &new_element,
12165 last_x, last_y, &last_element_new,
12166 getClosedPool, change_level);
12168 else if (IS_EMC_PILLAR(new_element))
12170 int last_element_new = EL_UNDEFINED;
12171 int direction = MV_NONE;
12174 // if old element is of same kind, keep all existing directions
12175 if (IS_EMC_PILLAR(old_element))
12176 direction |= getOpenDirectionFromPillar(old_element);
12178 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
12180 int xx = x + xy[i].x;
12181 int yy = y + xy[i].y;
12183 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12184 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
12186 int dir = MV_DIR_FROM_BIT(i);
12187 int dir_opposite = MV_DIR_OPPOSITE(dir);
12188 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12189 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
12190 int last_direction_new = last_direction_old | dir_opposite;
12192 last_element_new = getPillarFromOpenDirection(last_direction_new);
12198 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
12200 if (last_element_new != EL_UNDEFINED)
12201 MergeAndCloseNeighbourElements(x, y, &new_element,
12202 last_x, last_y, &last_element_new,
12203 getClosedPillar, change_level);
12205 else if (IS_DC_STEELWALL_2(new_element))
12207 int last_element_new = EL_UNDEFINED;
12208 int direction = MV_NONE;
12211 // if old element is of same kind, keep all existing directions
12212 if (IS_DC_STEELWALL_2(old_element))
12213 direction |= getOpenDirectionFromSteel2(old_element);
12215 for (i = 0; i < NUM_DIRECTIONS; i++)
12217 int xx = x + xy[i].x;
12218 int yy = y + xy[i].y;
12220 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12221 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
12223 int dir = MV_DIR_FROM_BIT(i);
12224 int dir_opposite = MV_DIR_OPPOSITE(dir);
12225 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12226 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
12227 int last_direction_new = last_direction_old | dir_opposite;
12229 last_element_new = getSteel2FromOpenDirection(last_direction_new);
12235 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
12237 if (last_element_new != EL_UNDEFINED)
12238 MergeAndCloseNeighbourElements(x, y, &new_element,
12239 last_x, last_y, &last_element_new,
12240 getClosedSteel2, change_level);
12242 else if (IS_SP_CHIP(new_element))
12244 int last_element_new = EL_UNDEFINED;
12245 int direction = MV_NONE;
12248 // (do not keep existing directions, regardless of kind of old element)
12250 for (i = 0; i < NUM_DIRECTIONS; i++)
12252 int xx = x + xy[i].x;
12253 int yy = y + xy[i].y;
12255 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12256 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
12258 int dir = MV_DIR_FROM_BIT(i);
12259 int dir_opposite = MV_DIR_OPPOSITE(dir);
12260 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12261 int last_direction_old = getOpenDirectionFromChip(last_element_old);
12262 int last_direction_new = last_direction_old | dir_opposite;
12264 if (last_direction_old == MV_NONE)
12266 last_element_new = getChipFromOpenDirection(last_direction_new);
12269 else if (last_direction_old & (dir | dir_opposite))
12271 direction |= MV_DIR_OPPOSITE(last_direction_old);
12275 direction |= MV_DIR_OPPOSITE(dir);
12280 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
12282 if (last_element_new != EL_UNDEFINED)
12283 MergeAndCloseNeighbourElements(x, y, &new_element,
12284 last_x, last_y, &last_element_new,
12285 getClosedChip, change_level);
12287 else if (IS_SP_HARDWARE_BASE(new_element))
12289 int nr = GetSimpleRandom(6);
12291 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
12292 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
12293 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
12294 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
12295 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
12297 else if (new_element == EL_SP_HARDWARE_GREEN ||
12298 new_element == EL_SP_HARDWARE_BLUE ||
12299 new_element == EL_SP_HARDWARE_RED)
12301 int nr = GetSimpleRandom(3);
12303 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
12304 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
12306 else if (IS_GROUP_ELEMENT(new_element))
12308 boolean connected_drawing = FALSE;
12311 for (i = 0; i < NUM_DIRECTIONS; i++)
12313 int xx = x + xy[i].x;
12314 int yy = y + xy[i].y;
12316 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12317 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
12318 connected_drawing = TRUE;
12321 if (!connected_drawing)
12322 ResolveGroupElement(new_element);
12324 new_element = GetElementFromGroupElement(new_element);
12326 else if (IS_BELT_SWITCH(old_element))
12328 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
12329 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
12331 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
12332 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
12334 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
12338 static int swappable_elements[][2] =
12340 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
12341 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
12342 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
12343 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
12344 { EL_EMERALD, EL_WALL_EMERALD },
12345 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
12346 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
12347 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
12348 { EL_DIAMOND, EL_WALL_DIAMOND },
12349 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
12350 { EL_GATE_1, EL_GATE_1_GRAY },
12351 { EL_GATE_2, EL_GATE_2_GRAY },
12352 { EL_GATE_3, EL_GATE_3_GRAY },
12353 { EL_GATE_4, EL_GATE_4_GRAY },
12354 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
12355 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
12356 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
12357 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
12358 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
12359 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
12360 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
12361 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
12362 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
12363 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
12364 { EL_LAMP, EL_LAMP_ACTIVE },
12365 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
12366 { EL_SP_BASE, EL_SP_BUGGY_BASE },
12367 { EL_PEARL, EL_WALL_PEARL },
12368 { EL_CRYSTAL, EL_WALL_CRYSTAL },
12369 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
12370 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
12371 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
12372 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
12373 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
12374 { EL_LANDMINE, EL_DC_LANDMINE },
12375 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
12376 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
12377 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
12378 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
12379 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
12380 { EL_MM_EXIT_CLOSED, EL_MM_EXIT_OPEN },
12381 { EL_MM_FUSE, EL_MM_FUSE_ACTIVE },
12382 { EL_MM_LIGHTBULB, EL_MM_LIGHTBULB_ACTIVE },
12383 { EL_MM_FUEL_EMPTY, EL_MM_FUEL_FULL },
12387 static int rotatable_elements_4[][4] =
12397 EL_SPACESHIP_RIGHT,
12402 EL_BD_BUTTERFLY_UP,
12403 EL_BD_BUTTERFLY_RIGHT,
12404 EL_BD_BUTTERFLY_DOWN,
12405 EL_BD_BUTTERFLY_LEFT
12409 EL_BD_FIREFLY_RIGHT,
12410 EL_BD_FIREFLY_DOWN,
12438 EL_SP_GRAVITY_PORT_UP,
12439 EL_SP_GRAVITY_PORT_RIGHT,
12440 EL_SP_GRAVITY_PORT_DOWN,
12441 EL_SP_GRAVITY_PORT_LEFT
12444 EL_SP_GRAVITY_ON_PORT_UP,
12445 EL_SP_GRAVITY_ON_PORT_RIGHT,
12446 EL_SP_GRAVITY_ON_PORT_DOWN,
12447 EL_SP_GRAVITY_ON_PORT_LEFT
12450 EL_SP_GRAVITY_OFF_PORT_UP,
12451 EL_SP_GRAVITY_OFF_PORT_RIGHT,
12452 EL_SP_GRAVITY_OFF_PORT_DOWN,
12453 EL_SP_GRAVITY_OFF_PORT_LEFT
12462 EL_BALLOON_SWITCH_UP,
12463 EL_BALLOON_SWITCH_RIGHT,
12464 EL_BALLOON_SWITCH_DOWN,
12465 EL_BALLOON_SWITCH_LEFT
12469 EL_MM_MCDUFFIN_RIGHT,
12470 EL_MM_MCDUFFIN_DOWN,
12471 EL_MM_MCDUFFIN_LEFT
12474 EL_MM_MIRROR_FIXED_1,
12475 EL_MM_MIRROR_FIXED_4,
12476 EL_MM_MIRROR_FIXED_3,
12477 EL_MM_MIRROR_FIXED_2
12480 EL_MM_STEEL_GRID_FIXED_1,
12481 EL_MM_STEEL_GRID_FIXED_4,
12482 EL_MM_STEEL_GRID_FIXED_2,
12483 EL_MM_STEEL_GRID_FIXED_3
12486 EL_MM_WOODEN_GRID_FIXED_1,
12487 EL_MM_WOODEN_GRID_FIXED_4,
12488 EL_MM_WOODEN_GRID_FIXED_2,
12489 EL_MM_WOODEN_GRID_FIXED_3
12492 EL_MM_POLARIZER_CROSS_1,
12493 EL_MM_POLARIZER_CROSS_4,
12494 EL_MM_POLARIZER_CROSS_3,
12495 EL_MM_POLARIZER_CROSS_2
12499 EL_MM_PACMAN_RIGHT,
12511 EL_DF_RECEIVER_RIGHT,
12512 EL_DF_RECEIVER_DOWN,
12513 EL_DF_RECEIVER_LEFT
12526 static int rotatable_elements_8[][8] =
12529 EL_DF_STEEL_GRID_FIXED_1,
12530 EL_DF_STEEL_GRID_FIXED_8,
12531 EL_DF_STEEL_GRID_FIXED_7,
12532 EL_DF_STEEL_GRID_FIXED_6,
12533 EL_DF_STEEL_GRID_FIXED_5,
12534 EL_DF_STEEL_GRID_FIXED_4,
12535 EL_DF_STEEL_GRID_FIXED_3,
12536 EL_DF_STEEL_GRID_FIXED_2
12539 EL_DF_WOODEN_GRID_FIXED_1,
12540 EL_DF_WOODEN_GRID_FIXED_8,
12541 EL_DF_WOODEN_GRID_FIXED_7,
12542 EL_DF_WOODEN_GRID_FIXED_6,
12543 EL_DF_WOODEN_GRID_FIXED_5,
12544 EL_DF_WOODEN_GRID_FIXED_4,
12545 EL_DF_WOODEN_GRID_FIXED_3,
12546 EL_DF_WOODEN_GRID_FIXED_2
12549 EL_DF_STEEL_GRID_ROTATING_1,
12550 EL_DF_STEEL_GRID_ROTATING_8,
12551 EL_DF_STEEL_GRID_ROTATING_7,
12552 EL_DF_STEEL_GRID_ROTATING_6,
12553 EL_DF_STEEL_GRID_ROTATING_5,
12554 EL_DF_STEEL_GRID_ROTATING_4,
12555 EL_DF_STEEL_GRID_ROTATING_3,
12556 EL_DF_STEEL_GRID_ROTATING_2
12559 EL_DF_WOODEN_GRID_ROTATING_1,
12560 EL_DF_WOODEN_GRID_ROTATING_8,
12561 EL_DF_WOODEN_GRID_ROTATING_7,
12562 EL_DF_WOODEN_GRID_ROTATING_6,
12563 EL_DF_WOODEN_GRID_ROTATING_5,
12564 EL_DF_WOODEN_GRID_ROTATING_4,
12565 EL_DF_WOODEN_GRID_ROTATING_3,
12566 EL_DF_WOODEN_GRID_ROTATING_2
12573 static int rotatable_elements_16[][16] =
12594 EL_MM_TELEPORTER_5,
12595 EL_MM_TELEPORTER_4,
12596 EL_MM_TELEPORTER_3,
12597 EL_MM_TELEPORTER_2,
12598 EL_MM_TELEPORTER_1,
12599 EL_MM_TELEPORTER_16,
12600 EL_MM_TELEPORTER_15,
12601 EL_MM_TELEPORTER_14,
12602 EL_MM_TELEPORTER_13,
12603 EL_MM_TELEPORTER_12,
12604 EL_MM_TELEPORTER_11,
12605 EL_MM_TELEPORTER_10,
12606 EL_MM_TELEPORTER_9,
12607 EL_MM_TELEPORTER_8,
12608 EL_MM_TELEPORTER_7,
12612 EL_MM_TELEPORTER_RED_5,
12613 EL_MM_TELEPORTER_RED_4,
12614 EL_MM_TELEPORTER_RED_3,
12615 EL_MM_TELEPORTER_RED_2,
12616 EL_MM_TELEPORTER_RED_1,
12617 EL_MM_TELEPORTER_RED_16,
12618 EL_MM_TELEPORTER_RED_15,
12619 EL_MM_TELEPORTER_RED_14,
12620 EL_MM_TELEPORTER_RED_13,
12621 EL_MM_TELEPORTER_RED_12,
12622 EL_MM_TELEPORTER_RED_11,
12623 EL_MM_TELEPORTER_RED_10,
12624 EL_MM_TELEPORTER_RED_9,
12625 EL_MM_TELEPORTER_RED_8,
12626 EL_MM_TELEPORTER_RED_7,
12627 EL_MM_TELEPORTER_RED_6
12630 EL_MM_TELEPORTER_YELLOW_5,
12631 EL_MM_TELEPORTER_YELLOW_4,
12632 EL_MM_TELEPORTER_YELLOW_3,
12633 EL_MM_TELEPORTER_YELLOW_2,
12634 EL_MM_TELEPORTER_YELLOW_1,
12635 EL_MM_TELEPORTER_YELLOW_16,
12636 EL_MM_TELEPORTER_YELLOW_15,
12637 EL_MM_TELEPORTER_YELLOW_14,
12638 EL_MM_TELEPORTER_YELLOW_13,
12639 EL_MM_TELEPORTER_YELLOW_12,
12640 EL_MM_TELEPORTER_YELLOW_11,
12641 EL_MM_TELEPORTER_YELLOW_10,
12642 EL_MM_TELEPORTER_YELLOW_9,
12643 EL_MM_TELEPORTER_YELLOW_8,
12644 EL_MM_TELEPORTER_YELLOW_7,
12645 EL_MM_TELEPORTER_YELLOW_6
12648 EL_MM_TELEPORTER_GREEN_5,
12649 EL_MM_TELEPORTER_GREEN_4,
12650 EL_MM_TELEPORTER_GREEN_3,
12651 EL_MM_TELEPORTER_GREEN_2,
12652 EL_MM_TELEPORTER_GREEN_1,
12653 EL_MM_TELEPORTER_GREEN_16,
12654 EL_MM_TELEPORTER_GREEN_15,
12655 EL_MM_TELEPORTER_GREEN_14,
12656 EL_MM_TELEPORTER_GREEN_13,
12657 EL_MM_TELEPORTER_GREEN_12,
12658 EL_MM_TELEPORTER_GREEN_11,
12659 EL_MM_TELEPORTER_GREEN_10,
12660 EL_MM_TELEPORTER_GREEN_9,
12661 EL_MM_TELEPORTER_GREEN_8,
12662 EL_MM_TELEPORTER_GREEN_7,
12663 EL_MM_TELEPORTER_GREEN_6
12666 EL_MM_TELEPORTER_BLUE_5,
12667 EL_MM_TELEPORTER_BLUE_4,
12668 EL_MM_TELEPORTER_BLUE_3,
12669 EL_MM_TELEPORTER_BLUE_2,
12670 EL_MM_TELEPORTER_BLUE_1,
12671 EL_MM_TELEPORTER_BLUE_16,
12672 EL_MM_TELEPORTER_BLUE_15,
12673 EL_MM_TELEPORTER_BLUE_14,
12674 EL_MM_TELEPORTER_BLUE_13,
12675 EL_MM_TELEPORTER_BLUE_12,
12676 EL_MM_TELEPORTER_BLUE_11,
12677 EL_MM_TELEPORTER_BLUE_10,
12678 EL_MM_TELEPORTER_BLUE_9,
12679 EL_MM_TELEPORTER_BLUE_8,
12680 EL_MM_TELEPORTER_BLUE_7,
12681 EL_MM_TELEPORTER_BLUE_6
12685 EL_MM_POLARIZER_16,
12686 EL_MM_POLARIZER_15,
12687 EL_MM_POLARIZER_14,
12688 EL_MM_POLARIZER_13,
12689 EL_MM_POLARIZER_12,
12690 EL_MM_POLARIZER_11,
12691 EL_MM_POLARIZER_10,
12720 EL_DF_MIRROR_ROTATING_1,
12721 EL_DF_MIRROR_ROTATING_16,
12722 EL_DF_MIRROR_ROTATING_15,
12723 EL_DF_MIRROR_ROTATING_14,
12724 EL_DF_MIRROR_ROTATING_13,
12725 EL_DF_MIRROR_ROTATING_12,
12726 EL_DF_MIRROR_ROTATING_11,
12727 EL_DF_MIRROR_ROTATING_10,
12728 EL_DF_MIRROR_ROTATING_9,
12729 EL_DF_MIRROR_ROTATING_8,
12730 EL_DF_MIRROR_ROTATING_7,
12731 EL_DF_MIRROR_ROTATING_6,
12732 EL_DF_MIRROR_ROTATING_5,
12733 EL_DF_MIRROR_ROTATING_4,
12734 EL_DF_MIRROR_ROTATING_3,
12735 EL_DF_MIRROR_ROTATING_2
12738 EL_DF_MIRROR_FIXED_1,
12739 EL_DF_MIRROR_FIXED_16,
12740 EL_DF_MIRROR_FIXED_15,
12741 EL_DF_MIRROR_FIXED_14,
12742 EL_DF_MIRROR_FIXED_13,
12743 EL_DF_MIRROR_FIXED_12,
12744 EL_DF_MIRROR_FIXED_11,
12745 EL_DF_MIRROR_FIXED_10,
12746 EL_DF_MIRROR_FIXED_9,
12747 EL_DF_MIRROR_FIXED_8,
12748 EL_DF_MIRROR_FIXED_7,
12749 EL_DF_MIRROR_FIXED_6,
12750 EL_DF_MIRROR_FIXED_5,
12751 EL_DF_MIRROR_FIXED_4,
12752 EL_DF_MIRROR_FIXED_3,
12753 EL_DF_MIRROR_FIXED_2
12762 for (i = 0; swappable_elements[i][0] != -1; i++)
12764 int element1 = swappable_elements[i][0];
12765 int element2 = swappable_elements[i][1];
12767 if (old_element == element1 || old_element == element2)
12768 new_element = (old_element == element1 ? element2 : element1);
12771 for (i = 0; rotatable_elements_4[i][0] != -1; i++)
12773 for (j = 0; j < 4; j++)
12775 int element = rotatable_elements_4[i][j];
12777 if (old_element == element)
12778 new_element = (button == 1 ? rotatable_elements_4[i][(j + 3) % 4] :
12779 button == 2 ? rotatable_elements_4[i][0] :
12780 button == 3 ? rotatable_elements_4[i][(j + 1) % 4] :
12785 for (i = 0; rotatable_elements_8[i][0] != -1; i++)
12787 for (j = 0; j < 8; j++)
12789 int element = rotatable_elements_8[i][j];
12791 if (old_element == element)
12792 new_element = (button == 1 ? rotatable_elements_8[i][(j + 7) % 8] :
12793 button == 2 ? rotatable_elements_8[i][0] :
12794 button == 3 ? rotatable_elements_8[i][(j + 1) % 8] :
12799 for (i = 0; rotatable_elements_16[i][0] != -1; i++)
12801 for (j = 0; j < 16; j++)
12803 int element = rotatable_elements_16[i][j];
12805 if (old_element == element)
12806 new_element = (button == 1 ? rotatable_elements_16[i][(j + 15) % 16] :
12807 button == 2 ? rotatable_elements_16[i][0] :
12808 button == 3 ? rotatable_elements_16[i][(j + 1) % 16] :
12813 if (old_element != new_element)
12815 int max_infotext_len = getMaxInfoTextLength();
12816 char infotext[MAX_OUTPUT_LINESIZE + 1];
12818 strncpy(infotext, getElementInfoText(new_element), max_infotext_len);
12819 infotext[max_infotext_len] = '\0';
12821 ClearEditorGadgetInfoText();
12823 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT,
12828 if (IS_MM_WALL_EDITOR(new_element))
12829 SetElementSimpleExt(x, y, dx, dy, new_element, change_level);
12831 SetElementSimple(x, y, new_element, change_level);
12837 static void ResetIntelliDraw(void)
12841 for (x = 0; x < lev_fieldx; x++)
12842 for (y = 0; y < lev_fieldy; y++)
12843 IntelliDrawBuffer[x][y] = Tile[x][y];
12845 SetElementIntelliDraw(-1, -1, -1, -1, EL_UNDEFINED, FALSE, -1);
12848 static boolean draw_mode_hires = FALSE;
12850 static boolean isHiresTileElement(int element)
12852 return (IS_MM_WALL(element) || element == EL_EMPTY);
12855 static boolean isHiresDrawElement(int element)
12857 return (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY);
12860 static int numHiresTiles(int element)
12862 if (IS_MM_WALL(element))
12863 return get_number_of_bits(MM_WALL_BITS(element));
12868 static void SetDrawModeHiRes(int element)
12871 (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
12872 isHiresDrawElement(element));
12875 static boolean getDrawModeHiRes(void)
12877 return draw_mode_hires;
12880 static int getLoResScreenPos(int pos)
12882 return (getDrawModeHiRes() ? pos / 2 : pos);
12885 static int getLoResScreenMod(int pos)
12887 return (getDrawModeHiRes() ? pos % 2 : 0);
12890 static void SetElementExt(int x, int y, int dx, int dy, int element,
12891 boolean change_level, int button)
12894 SetElementSimple(x, y, Tile[x][y], change_level);
12895 else if (GetKeyModState() & KMOD_Shift)
12896 SetElementIntelliDraw(x, y, dx, dy, element, change_level, button);
12898 SetElementSimpleExt(x, y, dx, dy, element, change_level);
12901 static void SetElement(int x, int y, int element)
12903 SetElementExt(x, y, 0, 0, element, TRUE, -1);
12906 static void SetElementButton(int x, int y, int dx, int dy, int element,
12909 SetElementExt(x, y, dx, dy, element, TRUE, button);
12912 static void SetElementHiRes(int sx2, int sy2, int element, boolean change_level)
12914 int lx = getLoResScreenPos(sx2) + level_xpos;
12915 int ly = getLoResScreenPos(sy2) + level_ypos;
12916 int dx = getLoResScreenMod(sx2);
12917 int dy = getLoResScreenMod(sy2);
12919 SetElementExt(lx, ly, dx, dy, element, change_level, -1);
12922 static void SetLevelElementHiRes(int lx2, int ly2, int element)
12929 SetElementExt(lx, ly, dx, dy, element, TRUE, -1);
12932 static int getLevelElementHiRes(int lx2, int ly2)
12938 int element = Tile[lx][ly];
12939 unsigned int bitmask = (dx + 1) << (dy * 2);
12941 if (IS_MM_WALL(element))
12943 if (element & bitmask)
12944 return map_mm_wall_element(element);
12952 static void DrawLineElement(int x, int y, int element, boolean change_level)
12954 SetElementHiRes(x, y, element, change_level);
12957 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
12958 int element, boolean change_level)
12960 int xsize = ABS(to_x - from_x);
12961 int ysize = ABS(to_y - from_y);
12962 int dx = (to_x < from_x ? -1 : +1);
12963 int dy = (to_y < from_y ? -1 : +1);
12966 if (from_y == to_y) // horizontal line
12968 for (i = 0; i <= xsize; i++)
12969 DrawLineElement(from_x + i * dx, from_y, element, change_level);
12971 else if (from_x == to_x) // vertical line
12973 for (i = 0; i <= ysize; i++)
12974 DrawLineElement(from_x, from_y + i * dy, element, change_level);
12976 else // diagonal line
12978 if (ysize < xsize) // a < 1
12980 float a = (float)ysize / (float)xsize;
12982 for (i = 0; i <= xsize; i++)
12985 int y = dy * (int)(a * i + 0.5);
12987 DrawLineElement(from_x + x, from_y + y, element, change_level);
12992 float a = (float)xsize / (float)ysize;
12994 for (i = 0; i <= ysize; i++)
12996 int x = dx * (int)(a * i + 0.5);
12999 DrawLineElement(from_x + x, from_y + y, element, change_level);
13005 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
13006 int element, boolean change_level)
13008 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
13009 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
13010 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
13011 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
13014 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
13015 int element, boolean change_level)
13020 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
13022 for (y = from_y; y <= to_y; y++)
13023 DrawLine(from_x, y, to_x, y, element, change_level);
13026 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
13027 int element, boolean change_level)
13029 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
13030 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
13031 int len_x = ABS(to_x - from_x);
13032 int len_y = ABS(to_y - from_y);
13035 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
13037 // not optimal (some points get drawn twice) but simple,
13038 // and fast enough for the few points we are drawing
13040 for (x = 0; x <= radius; x++)
13042 int sx, sy, sx2, sy2, lx, ly;
13044 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
13046 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
13047 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
13048 sx = getLoResScreenPos(sx2);
13049 sy = getLoResScreenPos(sy2);
13050 lx = sx + level_xpos;
13051 ly = sy + level_ypos;
13053 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
13054 DrawLineElement(sx2, sy2, element, change_level);
13057 for (y = 0; y <= radius; y++)
13059 int sx, sy, sx2, sy2, lx, ly;
13061 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
13063 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
13064 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
13065 sx = getLoResScreenPos(sx2);
13066 sy = getLoResScreenPos(sy2);
13067 lx = sx + level_xpos;
13068 ly = sy + level_ypos;
13070 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
13071 DrawLineElement(sx2, sy2, element, change_level);
13075 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
13076 int element, boolean change_level)
13078 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
13079 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
13081 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
13084 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
13086 #if DRAW_CIRCLES_BUTTON_AVAILABLE
13087 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
13088 int element, boolean change_level)
13090 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
13091 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
13092 int mirror_to_x2 = from_x - (to_x2 - from_x);
13093 int mirror_to_y2 = from_y - (to_y2 - from_y);
13095 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
13096 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
13097 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
13098 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element, change_level);
13102 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
13104 int from_sx, from_sy;
13108 swap_numbers(&from_x, &to_x);
13111 swap_numbers(&from_y, &to_y);
13113 from_sx = SX + from_x * ed_tilesize;
13114 from_sy = SY + from_y * ed_tilesize;
13115 to_sx = SX + (to_x + 1) * ed_tilesize - 1;
13116 to_sy = SY + (to_y + 1) * ed_tilesize - 1;
13118 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
13119 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
13120 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
13121 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
13123 if (from_x == to_x && from_y == to_y)
13124 MarkTileDirty(from_x/2, from_y/2);
13126 redraw_mask |= REDRAW_FIELD;
13129 static void DrawAreaBox(int from_x, int from_y, int to_x, int to_y,
13130 int element, boolean change_level)
13132 DrawBox(from_x, from_y, to_x, to_y, element, change_level);
13135 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
13136 int element, boolean change_level)
13138 if (element == -1 || change_level)
13139 DrawAreaBox(from_x, from_y, to_x, to_y, -1, FALSE);
13141 DrawAreaBorder(from_x, from_y, to_x, to_y);
13144 // values for CopyBrushExt()
13145 #define CB_AREA_TO_BRUSH 0
13146 #define CB_BRUSH_TO_CURSOR 1
13147 #define CB_BRUSH_TO_LEVEL 2
13148 #define CB_DELETE_OLD_CURSOR 3
13149 #define CB_DUMP_BRUSH 4
13150 #define CB_DUMP_BRUSH_SMALL 5
13151 #define CB_CLIPBOARD_TO_BRUSH 6
13152 #define CB_BRUSH_TO_CLIPBOARD 7
13153 #define CB_BRUSH_TO_CLIPBOARD_SMALL 8
13154 #define CB_UPDATE_BRUSH_POSITION 9
13155 #define CB_FLIP_BRUSH_X 10
13156 #define CB_FLIP_BRUSH_Y 11
13157 #define CB_FLIP_BRUSH_XY 12
13159 #define MAX_CB_PART_SIZE 10
13160 #define MAX_CB_LINE_SIZE (MAX_LEV_FIELDX + 1) // text plus newline
13161 #define MAX_CB_NUM_LINES (MAX_LEV_FIELDY)
13162 #define MAX_CB_TEXT_SIZE (MAX_CB_LINE_SIZE * \
13163 MAX_CB_NUM_LINES * \
13166 static int getFlippedTileExt(int map[], int element)
13170 for (i = 0; map[i] != -1; i++)
13171 if (map[i] == element)
13172 return map[i ^ 1]; // get flipped element by flipping LSB of index
13177 static int getFlippedTileX(int element)
13181 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_RIGHT,
13182 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_RIGHT,
13183 EL_BUG_LEFT, EL_BUG_RIGHT,
13184 EL_SPACESHIP_LEFT, EL_SPACESHIP_RIGHT,
13185 EL_PACMAN_LEFT, EL_PACMAN_RIGHT,
13186 EL_ARROW_LEFT, EL_ARROW_RIGHT,
13187 EL_MOLE_LEFT, EL_MOLE_RIGHT,
13188 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_RIGHT,
13189 EL_YAMYAM_LEFT, EL_YAMYAM_RIGHT,
13190 EL_SP_PORT_LEFT, EL_SP_PORT_RIGHT,
13191 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_RIGHT,
13192 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_RIGHT,
13193 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_RIGHT,
13194 EL_CONVEYOR_BELT_1_LEFT, EL_CONVEYOR_BELT_1_RIGHT,
13195 EL_CONVEYOR_BELT_2_LEFT, EL_CONVEYOR_BELT_2_RIGHT,
13196 EL_CONVEYOR_BELT_3_LEFT, EL_CONVEYOR_BELT_3_RIGHT,
13197 EL_CONVEYOR_BELT_4_LEFT, EL_CONVEYOR_BELT_4_RIGHT,
13198 EL_SPRING_LEFT, EL_SPRING_RIGHT,
13199 EL_SP_CHIP_LEFT, EL_SP_CHIP_RIGHT,
13200 EL_TUBE_VERTICAL_LEFT, EL_TUBE_VERTICAL_RIGHT,
13201 EL_TUBE_LEFT_UP, EL_TUBE_RIGHT_UP,
13202 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_DOWN,
13203 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_RIGHT,
13204 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_TOPRIGHT,
13205 EL_DC_STEELWALL_1_BOTTOMLEFT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
13206 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_TOPRIGHT_2,
13207 EL_DC_STEELWALL_1_BOTTOMLEFT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
13208 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_RIGHT,
13209 EL_ACID_POOL_TOPLEFT, EL_ACID_POOL_TOPRIGHT,
13210 EL_ACID_POOL_BOTTOMLEFT, EL_ACID_POOL_BOTTOMRIGHT,
13215 return getFlippedTileExt(map, element);
13218 static int getFlippedTileY(int element)
13222 EL_BD_BUTTERFLY_UP, EL_BD_BUTTERFLY_DOWN,
13223 EL_BD_FIREFLY_UP, EL_BD_FIREFLY_DOWN,
13224 EL_BUG_UP, EL_BUG_DOWN,
13225 EL_SPACESHIP_UP, EL_SPACESHIP_DOWN,
13226 EL_PACMAN_UP, EL_PACMAN_DOWN,
13227 EL_ARROW_UP, EL_ARROW_DOWN,
13228 EL_MOLE_UP, EL_MOLE_DOWN,
13229 EL_BALLOON_SWITCH_UP, EL_BALLOON_SWITCH_DOWN,
13230 EL_YAMYAM_UP, EL_YAMYAM_DOWN,
13231 EL_SP_PORT_UP, EL_SP_PORT_DOWN,
13232 EL_SP_GRAVITY_PORT_UP, EL_SP_GRAVITY_PORT_DOWN,
13233 EL_SP_GRAVITY_ON_PORT_UP, EL_SP_GRAVITY_ON_PORT_DOWN,
13234 EL_SP_GRAVITY_OFF_PORT_UP, EL_SP_GRAVITY_OFF_PORT_DOWN,
13235 EL_SP_CHIP_TOP, EL_SP_CHIP_BOTTOM,
13236 EL_TUBE_HORIZONTAL_UP, EL_TUBE_HORIZONTAL_DOWN,
13237 EL_TUBE_LEFT_UP, EL_TUBE_LEFT_DOWN,
13238 EL_TUBE_RIGHT_UP, EL_TUBE_RIGHT_DOWN,
13239 EL_DC_STEELWALL_1_TOP, EL_DC_STEELWALL_1_BOTTOM,
13240 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_BOTTOMLEFT,
13241 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
13242 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
13243 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
13244 EL_DC_STEELWALL_2_TOP, EL_DC_STEELWALL_2_BOTTOM,
13245 EL_EMC_WALL_1, EL_EMC_WALL_3,
13250 return getFlippedTileExt(map, element);
13253 static int getFlippedTileXY(int element)
13257 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_UP,
13258 EL_BD_BUTTERFLY_RIGHT, EL_BD_BUTTERFLY_DOWN,
13259 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_UP,
13260 EL_BD_FIREFLY_RIGHT, EL_BD_FIREFLY_DOWN,
13261 EL_BUG_LEFT, EL_BUG_UP,
13262 EL_BUG_RIGHT, EL_BUG_DOWN,
13263 EL_SPACESHIP_LEFT, EL_SPACESHIP_UP,
13264 EL_SPACESHIP_RIGHT, EL_SPACESHIP_DOWN,
13265 EL_PACMAN_LEFT, EL_PACMAN_UP,
13266 EL_PACMAN_RIGHT, EL_PACMAN_DOWN,
13267 EL_ARROW_LEFT, EL_ARROW_UP,
13268 EL_ARROW_RIGHT, EL_ARROW_DOWN,
13269 EL_MOLE_LEFT, EL_MOLE_UP,
13270 EL_MOLE_RIGHT, EL_MOLE_DOWN,
13271 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_UP,
13272 EL_BALLOON_SWITCH_RIGHT, EL_BALLOON_SWITCH_DOWN,
13273 EL_YAMYAM_LEFT, EL_YAMYAM_UP,
13274 EL_YAMYAM_RIGHT, EL_YAMYAM_DOWN,
13275 EL_SP_PORT_LEFT, EL_SP_PORT_UP,
13276 EL_SP_PORT_RIGHT, EL_SP_PORT_DOWN,
13277 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_UP,
13278 EL_SP_GRAVITY_PORT_RIGHT, EL_SP_GRAVITY_PORT_DOWN,
13279 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_UP,
13280 EL_SP_GRAVITY_ON_PORT_RIGHT, EL_SP_GRAVITY_ON_PORT_DOWN,
13281 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_UP,
13282 EL_SP_GRAVITY_OFF_PORT_RIGHT, EL_SP_GRAVITY_OFF_PORT_DOWN,
13283 EL_SP_CHIP_LEFT, EL_SP_CHIP_TOP,
13284 EL_SP_CHIP_RIGHT, EL_SP_CHIP_BOTTOM,
13285 EL_TUBE_VERTICAL, EL_TUBE_HORIZONTAL,
13286 EL_TUBE_VERTICAL_LEFT, EL_TUBE_HORIZONTAL_UP,
13287 EL_TUBE_VERTICAL_RIGHT, EL_TUBE_HORIZONTAL_DOWN,
13288 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_UP,
13289 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_TOP,
13290 EL_DC_STEELWALL_1_RIGHT, EL_DC_STEELWALL_1_BOTTOM,
13291 EL_DC_STEELWALL_1_HORIZONTAL, EL_DC_STEELWALL_1_VERTICAL,
13292 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMLEFT,
13293 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
13294 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_TOP,
13295 EL_DC_STEELWALL_2_RIGHT, EL_DC_STEELWALL_2_BOTTOM,
13296 EL_DC_STEELWALL_2_HORIZONTAL, EL_DC_STEELWALL_2_VERTICAL,
13297 EL_EXPANDABLE_WALL_HORIZONTAL, EL_EXPANDABLE_WALL_VERTICAL,
13298 EL_EXPANDABLE_STEELWALL_HORIZONTAL, EL_EXPANDABLE_STEELWALL_VERTICAL,
13303 return getFlippedTileExt(map, element);
13306 static int getFlippedTile(int element, int mode)
13308 if (IS_MM_ELEMENT(element))
13310 // get MM game element
13311 element = map_element_RND_to_MM(element);
13313 // get flipped game element
13314 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX_MM(element) :
13315 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY_MM(element) :
13316 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY_MM(element) :
13319 // get RND game element again
13320 element = map_element_MM_to_RND(element);
13324 // get flipped game element
13325 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX(element) :
13326 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY(element) :
13327 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY(element) :
13334 static void SwapFlippedTiles(short *tile1, short *tile2, int mode)
13337 short tile1_flipped = getFlippedTile(*tile1, mode);
13338 short tile2_flipped = getFlippedTile(*tile2, mode);
13341 *tile1 = tile2_flipped;
13342 *tile2 = tile1_flipped;
13345 static void DrawBrushElement(int sx, int sy, int element, boolean change_level)
13347 DrawLineElement(sx, sy, element, change_level);
13350 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
13351 int button, int mode)
13353 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
13354 static int brush_width, brush_height;
13355 static int last_cursor_x = -1, last_cursor_y = -1;
13356 static boolean delete_old_brush = FALSE;
13357 int new_element = BUTTON_ELEMENT(button);
13360 if (mode == CB_DUMP_BRUSH ||
13361 mode == CB_DUMP_BRUSH_SMALL ||
13362 mode == CB_BRUSH_TO_CLIPBOARD ||
13363 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
13365 if (edit_mode != ED_MODE_DRAWING)
13368 char part[MAX_CB_PART_SIZE + 1] = "";
13369 char text[MAX_CB_TEXT_SIZE + 1] = "";
13370 int width = (draw_with_brush ? brush_width : lev_fieldx);
13371 int height = (draw_with_brush ? brush_height : lev_fieldy);
13372 char *format = "%s%03d";
13374 for (y = 0; y < height; y++)
13375 for (x = 0; x < width; x++)
13376 if ((draw_with_brush ? brush_buffer[x][y] : Tile[x][y]) > 999)
13379 for (y = 0; y < height; y++)
13381 for (x = 0; x < width; x++)
13383 int element = (draw_with_brush ? brush_buffer[x][y] : Tile[x][y]);
13384 char *prefix = (mode == CB_DUMP_BRUSH ||
13385 mode == CB_BRUSH_TO_CLIPBOARD ? "`" : "¸");
13387 if (element >= NUM_FILE_ELEMENTS)
13388 element = EL_UNKNOWN;
13390 // copy brush to level sketch text buffer for the R'n'D forum:
13391 // - large tiles: `xxx or `xxxx (0x60 ASCII)
13392 // - small tiles: ¸xxx or ¸xxxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
13393 snprintf(part, MAX_CB_PART_SIZE + 1, format, prefix, element);
13394 strcat(text, part);
13397 strcat(text, "\n");
13400 if (mode == CB_BRUSH_TO_CLIPBOARD ||
13401 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
13402 SDL_SetClipboardText(text);
13404 Print("%s", text); // print brush data to console and log file
13409 if (mode == CB_CLIPBOARD_TO_BRUSH)
13411 if (edit_mode != ED_MODE_DRAWING)
13414 if (!SDL_HasClipboardText())
13416 Request("Clipboard is empty!", REQ_CONFIRM);
13421 boolean copy_to_brush = (draw_with_brush ||
13422 drawing_function == GADGET_ID_GRAB_BRUSH);
13424 // this will delete the old brush, if already drawing with a brush
13426 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], MB_LEFTBUTTON);
13428 // initialization is required for "odd" (incomplete) clipboard content
13429 for (x = 0; x < MAX_LEV_FIELDX; x++)
13430 for (y = 0; y < MAX_LEV_FIELDY; y++)
13431 brush_buffer[x][y] = EL_EMPTY;
13438 char *clipboard_text = SDL_GetClipboardText();
13439 char *ptr = clipboard_text;
13440 boolean allow_new_row = FALSE;
13441 boolean stop = FALSE;
13443 while (*ptr && !stop)
13445 boolean prefix_found = FALSE;
13446 boolean start_new_row = FALSE;
13448 // level sketch element number prefixes (may be multi-byte characters)
13449 char *prefix_list[] = { "`", "¸" };
13452 for (i = 0; i < ARRAY_SIZE(prefix_list); i++)
13454 char *prefix = prefix_list[i];
13456 // check if string is large enough for prefix
13457 if (strlen(ptr) < strlen(prefix))
13464 // check if string starts with prefix
13465 if (strPrefix(ptr, prefix))
13467 ptr += strlen(prefix);
13469 prefix_found = TRUE;
13475 // check if prefix found and followed by (at least) three digits
13476 if (prefix_found &&
13477 strlen(ptr) >= 3 &&
13478 ptr[0] >= '0' && ptr[0] <= '9' &&
13479 ptr[1] >= '0' && ptr[1] <= '9' &&
13480 ptr[2] >= '0' && ptr[2] <= '9')
13482 int element = ((ptr[0] - '0') * 100 +
13483 (ptr[1] - '0') * 10 +
13488 // level sketch element number might consist of four digits
13489 if (ptr[0] >= '0' && ptr[0] <= '9')
13491 element = element * 10 + (ptr[0] - '0');
13495 // remap some (historic, now obsolete) elements
13496 element = getMappedElement(element);
13498 if (element >= NUM_FILE_ELEMENTS)
13499 element = EL_UNKNOWN;
13501 brush_buffer[x][y] = element;
13503 brush_width = MAX(x + 1, brush_width);
13504 brush_height = MAX(y + 1, brush_height);
13508 if (x >= MAX_LEV_FIELDX)
13509 start_new_row = TRUE;
13511 allow_new_row = TRUE;
13515 if ((*ptr == '\n' || *ptr == '\r') && allow_new_row)
13516 start_new_row = TRUE;
13518 ptr++; // !!! FIX THIS for real UTF-8 handling !!!
13526 if (y >= MAX_LEV_FIELDY)
13529 allow_new_row = FALSE;
13533 SDL_free(clipboard_text);
13535 if (brush_width == 0 || brush_height == 0)
13537 Request("No level sketch found in clipboard!", REQ_CONFIRM);
13544 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_DRAWING_LEVEL];
13547 SDL_GetMouseState(&mx, &my);
13549 // if inside drawing area, activate and draw brush at last mouse position
13550 if (mx >= gi->x && mx < gi->x + gi->width &&
13551 my >= gi->y && my < gi->y + gi->height)
13552 CopyBrushToCursor(last_cursor_x, last_cursor_y);
13554 draw_with_brush = TRUE;
13560 sprintf(request, "Replace level with %dx%d level sketch from clipboard?",
13561 brush_width, brush_height);
13563 if (!Request(request, REQ_ASK))
13566 for (x = 0; x < MAX_LEV_FIELDX; x++)
13567 for (y = 0; y < MAX_LEV_FIELDY; y++)
13568 Tile[x][y] = brush_buffer[x][y];
13570 lev_fieldx = level.fieldx = brush_width;
13571 lev_fieldy = level.fieldy = brush_height;
13573 boolean use_bd_engine = TRUE;
13574 boolean use_em_engine = TRUE;
13575 boolean use_sp_engine = TRUE;
13576 boolean use_mm_engine = TRUE;
13578 for (x = 0; x < MAX_LEV_FIELDX; x++)
13580 for (y = 0; y < MAX_LEV_FIELDY; y++)
13582 int element = Tile[x][y];
13584 if (!IS_BD_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
13585 use_bd_engine = FALSE;
13587 if (!IS_EM_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
13588 use_em_engine = FALSE;
13590 if (!IS_SP_ELEMENT(element))
13591 use_sp_engine = FALSE;
13593 if (!IS_MM_ELEMENT(element) && element != EL_EMPTY)
13594 use_mm_engine = FALSE;
13598 level.game_engine_type = (use_bd_engine ? GAME_ENGINE_TYPE_BD :
13599 use_em_engine ? GAME_ENGINE_TYPE_EM :
13600 use_sp_engine ? GAME_ENGINE_TYPE_SP :
13601 use_mm_engine ? GAME_ENGINE_TYPE_MM :
13602 GAME_ENGINE_TYPE_RND);
13604 // update element selection list
13605 ReinitializeElementList();
13606 ModifyEditorElementList();
13608 SetBorderElement();
13610 DrawEditModeWindow();
13611 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13617 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
13620 if (mode == CB_AREA_TO_BRUSH)
13622 int from_lx, from_ly;
13625 swap_numbers(&from_x, &to_x);
13628 swap_numbers(&from_y, &to_y);
13630 brush_width = to_x - from_x + 1;
13631 brush_height = to_y - from_y + 1;
13633 from_lx = from_x + level_xpos;
13634 from_ly = from_y + level_ypos;
13636 for (y = 0; y < brush_height; y++)
13638 for (x = 0; x < brush_width; x++)
13640 brush_buffer[x][y] = Tile[from_lx + x][from_ly + y];
13643 DrawBrushElement(from_x + x, from_y + y, new_element, TRUE);
13648 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13650 delete_old_brush = FALSE;
13652 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
13653 mode == CB_BRUSH_TO_LEVEL)
13655 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
13656 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
13657 int cursor_from_x = cursor_x - brush_width / 2;
13658 int cursor_from_y = cursor_y - brush_height / 2;
13659 int border_from_x = cursor_x, border_from_y = cursor_y;
13660 int border_to_x = cursor_x, border_to_y = cursor_y;
13662 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
13663 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13665 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
13666 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
13668 delete_old_brush = FALSE;
13673 for (y = 0; y < brush_height; y++)
13675 for (x = 0; x < brush_width; x++)
13677 int sx = cursor_from_x + x;
13678 int sy = cursor_from_y + y;
13679 int lx = sx + level_xpos;
13680 int ly = sy + level_ypos;
13681 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
13682 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
13683 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
13684 brush_buffer[x][y] : new_element);
13686 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
13688 if (sx < border_from_x)
13689 border_from_x = sx;
13690 else if (sx > border_to_x)
13692 if (sy < border_from_y)
13693 border_from_y = sy;
13694 else if (sy > border_to_y)
13697 DrawBrushElement(sx, sy, element, change_level);
13702 if (mode != CB_DELETE_OLD_CURSOR)
13703 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
13705 last_cursor_x = cursor_x;
13706 last_cursor_y = cursor_y;
13708 delete_old_brush = TRUE;
13710 else if (mode == CB_FLIP_BRUSH_X)
13712 for (y = 0; y < brush_height; y++)
13713 for (x = 0; x < (brush_width + 1) / 2; x++)
13714 SwapFlippedTiles(&brush_buffer[x][y],
13715 &brush_buffer[brush_width - x - 1][y], mode);
13717 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13719 else if (mode == CB_FLIP_BRUSH_Y)
13721 for (y = 0; y < (brush_height + 1) / 2; y++)
13722 for (x = 0; x < brush_width; x++)
13723 SwapFlippedTiles(&brush_buffer[x][y],
13724 &brush_buffer[x][brush_height - y - 1], mode);
13726 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13728 else if (mode == CB_FLIP_BRUSH_XY)
13730 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13732 for (y = 0; y < MAX(brush_width, brush_height); y++)
13733 for (x = 0; x <= y; x++)
13734 SwapFlippedTiles(&brush_buffer[x][y],
13735 &brush_buffer[y][x], mode);
13737 swap_numbers(&brush_width, &brush_height);
13739 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13742 if (mode == CB_UPDATE_BRUSH_POSITION)
13744 last_cursor_x = from_x;
13745 last_cursor_y = from_y;
13749 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
13752 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
13755 static void CopyBrushToLevel(int x, int y, int button)
13757 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
13760 static void CopyBrushToCursor(int x, int y)
13762 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13765 static void UpdateBrushPosition(int x, int y)
13767 CopyBrushExt(x, y, 0, 0, 0, CB_UPDATE_BRUSH_POSITION);
13770 static void DeleteBrushFromCursor(void)
13772 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13775 static void FlipBrushX(void)
13777 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13780 static void FlipBrushY(void)
13782 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_Y);
13785 static void RotateBrush(void)
13787 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_XY);
13788 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13791 void DumpBrush(void)
13793 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
13796 void DumpBrush_Small(void)
13798 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
13801 void CopyClipboardToBrush(void)
13803 CopyBrushExt(0, 0, 0, 0, 0, CB_CLIPBOARD_TO_BRUSH);
13806 void CopyBrushToClipboard(void)
13808 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD);
13811 void CopyBrushToClipboard_Small(void)
13813 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD_SMALL);
13816 void UndoLevelEditorOperation(void)
13818 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], -1);
13821 void RedoLevelEditorOperation(void)
13823 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
13826 static void FloodFill(int from_x, int from_y, int fill_element)
13828 FloodFillLevel(from_x, from_y, fill_element, Tile, lev_fieldx, lev_fieldy);
13831 static void FloodFillWall_MM(int from_sx2, int from_sy2, int fill_element)
13833 int from_x = from_sx2 + 2 * level_xpos;
13834 int from_y = from_sy2 + 2 * level_ypos;
13835 int max_fillx = lev_fieldx * 2;
13836 int max_filly = lev_fieldy * 2;
13837 short Fill[max_fillx][max_filly];
13840 for (x = 0; x < max_fillx; x++)
13841 for (y = 0; y < max_filly; y++)
13842 Fill[x][y] = getLevelElementHiRes(x, y);
13844 FloodFillLevelExt(from_x, from_y, fill_element, max_fillx, max_filly,
13845 Fill, max_fillx, max_filly);
13847 for (x = 0; x < max_fillx; x++)
13848 for (y = 0; y < max_filly; y++)
13849 if (Fill[x][y] == fill_element)
13850 SetLevelElementHiRes(x, y, Fill[x][y]);
13853 // values for DrawLevelText() modes
13854 #define TEXT_INIT 0
13855 #define TEXT_SETCURSOR 1
13856 #define TEXT_WRITECHAR 2
13857 #define TEXT_BACKSPACE 3
13858 #define TEXT_NEWLINE 4
13860 #define TEXT_QUERY_TYPING 6
13862 static int DrawLevelText(int sx, int sy, char letter, int mode)
13864 static short delete_buffer[MAX_LEV_FIELDX];
13865 static int start_sx;
13866 static int last_sx, last_sy;
13867 static boolean typing = FALSE;
13868 int letter_element;
13869 int lx = 0, ly = 0;
13871 // map lower case letters to upper case and convert special characters
13872 if (letter >= 'a' && letter <= 'z')
13873 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
13874 else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
13875 letter_element = EL_CHAR_AUMLAUT;
13876 else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
13877 letter_element = EL_CHAR_OUMLAUT;
13878 else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
13879 letter_element = EL_CHAR_UUMLAUT;
13880 else if (letter == '^')
13881 letter_element = EL_CHAR_COPYRIGHT;
13883 letter_element = EL_CHAR_ASCII0 + letter;
13885 if (mode != TEXT_INIT)
13890 if (mode != TEXT_SETCURSOR)
13896 lx = last_sx + level_xpos;
13897 ly = last_sy + level_ypos;
13904 DrawLevelText(0, 0, 0, TEXT_END);
13910 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
13913 case TEXT_SETCURSOR:
13914 DrawEditorElement(last_sx, last_sy, Tile[lx][ly]);
13915 DrawAreaBorder(sx, sy, sx, sy);
13916 StartTextInput(SX + sx * ed_tilesize, SY + sy * ed_tilesize,
13917 ed_tilesize, ed_tilesize);
13922 case TEXT_WRITECHAR:
13923 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
13925 if (new_element1 >= EL_STEEL_CHAR_START &&
13926 new_element1 <= EL_STEEL_CHAR_END)
13927 letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
13929 delete_buffer[sx - start_sx] = Tile[lx][ly];
13930 Tile[lx][ly] = letter_element;
13932 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
13933 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
13934 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13935 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13937 DrawLevelText(0, 0, 0, TEXT_END);
13939 level.changed = TRUE;
13943 case TEXT_BACKSPACE:
13946 Tile[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
13947 DrawEditorElement(sx - 1, sy, Tile[lx - 1][ly]);
13948 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
13953 if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13954 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13956 DrawLevelText(0, 0, 0, TEXT_END);
13960 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13961 DrawEditorElement(sx, sy, Tile[lx][ly]);
13966 case TEXT_QUERY_TYPING:
13976 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
13977 int element, boolean change_level)
13979 int lx = sx + level_xpos;
13980 int ly = sy + level_ypos;
13983 DrawEditorElement(sx, sy, Tile[lx][ly]);
13985 DrawAreaBorder(sx, sy, sx, sy);
13988 static void CheckLevelBorderElement(boolean redraw_playfield)
13990 int last_border_element = BorderElement;
13992 SetBorderElement();
13994 if (redraw_playfield && BorderElement != last_border_element)
13995 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13998 static void CopyLevelToUndoBuffer(int mode)
14000 static boolean accumulated_undo = FALSE;
14001 boolean new_undo_buffer_position = TRUE;
14004 if (undo_buffer_steps == 0)
14005 accumulated_undo = FALSE;
14009 case UNDO_IMMEDIATE:
14010 accumulated_undo = FALSE;
14013 case UNDO_ACCUMULATE:
14014 if (accumulated_undo)
14015 new_undo_buffer_position = FALSE;
14016 accumulated_undo = TRUE;
14023 if (new_undo_buffer_position)
14025 // advance position in undo buffer ring
14026 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
14028 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
14029 undo_buffer_steps++;
14032 // always reset redo buffer when storing level change into undo buffer
14033 redo_buffer_steps = 0;
14035 for (x = 0; x < lev_fieldx; x++)
14036 for (y = 0; y < lev_fieldy; y++)
14037 UndoBuffer[undo_buffer_position][x][y] = Tile[x][y];
14039 // check if drawing operation forces change of border style
14040 CheckLevelBorderElement(TRUE);
14042 level.changed = TRUE;
14045 static void RandomPlacement(int new_element)
14047 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
14048 int num_free_positions = 0;
14049 int num_percentage, num_elements;
14052 ResetIntelliDraw();
14054 // determine number of free positions for randomly placing the new element
14055 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
14057 free_position[x][y] =
14058 (random_placement_background_restricted ?
14059 Tile[x][y] == random_placement_background_element :
14060 Tile[x][y] != new_element);
14062 if (free_position[x][y])
14063 num_free_positions++;
14066 // determine number of new elements to place there
14067 num_percentage = num_free_positions * random_placement_value / 100;
14068 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
14069 num_percentage : random_placement_value);
14071 // if less free positions than elements to place, fill all these positions
14072 if (num_free_positions < num_elements)
14074 for (x = 0; x < lev_fieldx; x++)
14075 for (y = 0; y < lev_fieldy; y++)
14076 if (free_position[x][y])
14077 SetElement(x, y, new_element);
14081 while (num_elements > 0)
14083 x = GetSimpleRandom(lev_fieldx);
14084 y = GetSimpleRandom(lev_fieldy);
14086 // don't place element at the same position twice
14087 if (free_position[x][y])
14089 free_position[x][y] = FALSE;
14090 SetElement(x, y, new_element);
14096 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14097 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14100 static void WrapLevel(int dx, int dy)
14102 int wrap_dx = lev_fieldx - dx;
14103 int wrap_dy = lev_fieldy - dy;
14106 for (x = 0; x < lev_fieldx; x++)
14107 for (y = 0; y < lev_fieldy; y++)
14108 TileBackup[x][y] = Tile[x][y];
14110 for (x = 0; x < lev_fieldx; x++)
14111 for (y = 0; y < lev_fieldy; y++)
14113 TileBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
14115 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14116 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
14119 static void DrawAreaElementHighlight(boolean highlighted,
14120 boolean highlighted_similar)
14122 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14129 for (x = 0; x < ed_fieldx; x++)
14131 for (y = 0; y < ed_fieldy; y++)
14133 boolean highlight = FALSE;
14134 int lx = x + level_xpos;
14135 int ly = y + level_ypos;
14137 if (!IN_LEV_FIELD(lx, ly))
14140 // check if element is the same
14141 if (Tile[lx][ly] == new_element1)
14144 // check if element is similar
14145 if (highlighted_similar &&
14146 strEqual(element_info[Tile[lx][ly]].class_name,
14147 element_info[new_element1].class_name))
14150 // check if element is matching MM style wall
14151 if (IS_MM_WALL(Tile[lx][ly]) &&
14152 map_mm_wall_element(Tile[lx][ly]) == new_element1)
14158 if (IS_MM_WALL(Tile[lx][ly]) && !highlighted_similar)
14162 for (i = 0; i < 4; i++)
14164 if (!(MM_WALL_BITS(Tile[lx][ly]) & (1 << i)))
14167 int xx = x * 2 + (i % 2);
14168 int yy = y * 2 + (i / 2);
14169 int sx = SX + xx * ed_tilesize / 2;
14170 int sy = SY + yy * ed_tilesize / 2;
14173 int to_sx = sx + ed_tilesize / 2 - 1;
14174 int to_sy = sy + ed_tilesize / 2 - 1;
14176 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
14177 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
14178 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
14179 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
14184 int sx = SX + x * ed_tilesize;
14185 int sy = SY + y * ed_tilesize;
14188 int to_sx = sx + ed_tilesize - 1;
14189 int to_sy = sy + ed_tilesize - 1;
14191 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
14192 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
14193 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
14194 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
14200 static void CopyLevelTemplateToUserLevelSet(char *levelset_subdir)
14202 char *template_filename_old = getLocalLevelTemplateFilename();
14203 char *template_filename_new =
14204 getPath2(getUserLevelDir(levelset_subdir), LEVELTEMPLATE_FILENAME);
14206 if (copyFile(template_filename_old, template_filename_new) != 0)
14207 Request("Cannot copy level template!", REQ_CONFIRM);
14209 free(template_filename_new);
14212 static void HandleDrawingAreas(struct GadgetInfo *gi)
14214 static boolean started_inside_drawing_area = FALSE;
14215 static int last_sx = -1;
14216 static int last_sy = -1;
14217 static int last_sx2 = -1;
14218 static int last_sy2 = -1;
14219 int id = gi->custom_id;
14220 int type_id = gi->custom_type_id;
14221 boolean button_press_event;
14222 boolean button_release_event;
14223 boolean inside_drawing_area = !gi->event.off_borders;
14224 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
14225 int actual_drawing_function;
14226 int button = gi->event.button;
14227 int new_element = BUTTON_ELEMENT(button);
14228 int sx = gi->event.x, sy = gi->event.y;
14229 int min_sx = 0, min_sy = 0;
14230 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
14231 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
14232 int mini_item_xsize = item_xsize / 2, mini_item_ysize = item_ysize / 2;
14233 int sx2 = gi->event.mx / mini_item_xsize;
14234 int sy2 = gi->event.my / mini_item_ysize;
14237 int lx = 0, ly = 0;
14240 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
14241 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
14243 // make sure to stay inside drawing area boundaries
14244 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
14245 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
14249 int min_lx = 0, min_ly = 0;
14250 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
14252 // get positions inside level field
14253 lx = sx + level_xpos;
14254 ly = sy + level_ypos;
14256 if (!IN_LEV_FIELD(lx, ly))
14257 inside_drawing_area = FALSE;
14259 // make sure to stay inside level field boundaries
14260 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
14261 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
14263 // correct drawing area positions accordingly
14264 sx = lx - level_xpos;
14265 sy = ly - level_ypos;
14268 // also correct MM wall-sized (double) drawing area positions accordingly
14269 if (sx2 / 2 < sx || sx2 / 2 > sx)
14271 dx = (sx2 / 2 < sx ? 0 : 1);
14274 if (sy2 / 2 < sy || sy2 / 2 > sy)
14276 dy = (sy2 / 2 < sy ? 0 : 1);
14280 if (!button_press_event && !button_release_event)
14282 int old_element = (IN_LEV_FIELD(lx, ly) ? Tile[lx][ly] : EL_UNDEFINED);
14283 boolean hires_drawing = (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
14284 isHiresTileElement(old_element) &&
14285 isHiresDrawElement(new_element));
14287 // prevent handling events for every pixel position when moving mouse
14288 if ((sx == last_sx && sy == last_sy && !hires_drawing) ||
14289 (sx2 == last_sx2 && sy2 == last_sy2))
14298 if (button_press_event)
14299 started_inside_drawing_area = inside_drawing_area;
14301 if (!started_inside_drawing_area)
14304 if (!IS_VALID_BUTTON(button))
14307 // handle info callback for each invocation of action callback
14308 gi->callback_info(gi);
14310 // automatically switch to 'single item' drawing mode, if needed
14311 actual_drawing_function =
14312 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
14313 drawing_function : GADGET_ID_SINGLE_ITEMS);
14315 // clicking into drawing area with pressed Control key picks element
14316 if (GetKeyModState() & KMOD_Control)
14318 last_drawing_function = drawing_function;
14319 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
14322 if (GetKeyModState() & KMOD_Shift)
14324 if (button_press_event || button_release_event)
14325 ResetIntelliDraw();
14328 SetDrawModeHiRes(-1); // reset to normal draw mode
14330 switch (actual_drawing_function)
14332 case GADGET_ID_SINGLE_ITEMS:
14335 if (button_release_event)
14337 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14339 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
14340 !inside_drawing_area)
14341 DeleteBrushFromCursor();
14346 if (draw_with_brush)
14348 CopyBrushToLevel(sx, sy, button);
14352 SetDrawModeHiRes(new_element);
14354 if (IS_PLAYER_ELEMENT(new_element) || IS_MM_MCDUFFIN(new_element))
14356 // remove player at old position
14357 for (y = 0; y < lev_fieldy; y++)
14359 for (x = 0; x < lev_fieldx; x++)
14361 int old_element = Tile[x][y];
14363 if (IS_PLAYER_ELEMENT(old_element) &&
14364 IS_PLAYER_ELEMENT(new_element))
14366 int replaced_with_element =
14367 (old_element == EL_SOKOBAN_FIELD_PLAYER &&
14368 new_element == EL_PLAYER_1 ? EL_SOKOBAN_FIELD_EMPTY :
14370 old_element == EL_SOKOBAN_FIELD_PLAYER &&
14371 new_element == old_element ? EL_SOKOBAN_FIELD_EMPTY :
14373 new_element == EL_SOKOBAN_FIELD_PLAYER &&
14374 old_element == EL_PLAYER_1 ? EL_EMPTY :
14376 new_element >= EL_PLAYER_1 &&
14377 new_element <= EL_PLAYER_4 &&
14378 new_element == old_element ? EL_EMPTY :
14382 SetElement(x, y, replaced_with_element);
14384 else if (IS_MM_MCDUFFIN(old_element) &&
14385 IS_MM_MCDUFFIN(new_element))
14387 // remove McDuffin at old position
14388 SetElement(x, y, EL_EMPTY);
14394 SetElementButton(lx, ly, dx, dy, new_element, button);
14397 else if (!button_release_event)
14399 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14401 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
14402 DrawMiniGraphicExt(drawto,
14403 gi->x + sx * MINI_TILEX,
14404 gi->y + sy * MINI_TILEY,
14405 el2edimg(new_element));
14407 DrawFixedGraphicExt(drawto,
14408 gi->x + sx * TILEX,
14409 gi->y + sy * TILEY,
14410 el2edimg(new_element), 0);
14412 if (id == GADGET_ID_CUSTOM_GRAPHIC)
14413 new_element = GFX_ELEMENT(new_element);
14415 drawingarea_info[type_id].value[pos] = new_element;
14417 CopyElementPropertiesToGame(properties_element);
14419 if (id == GADGET_ID_CUSTOM_GRAPHIC)
14421 UpdateCustomElementGraphicGadgets();
14423 FrameCounter = 0; // restart animation frame counter
14428 case GADGET_ID_CONNECTED_ITEMS:
14430 static int last_sx = -1;
14431 static int last_sy = -1;
14433 if (button_release_event)
14434 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14436 SetDrawModeHiRes(new_element);
14438 if (getDrawModeHiRes())
14444 if (!button_press_event)
14445 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
14452 case GADGET_ID_LINE:
14453 case GADGET_ID_ARC:
14454 case GADGET_ID_RECTANGLE:
14455 case GADGET_ID_FILLED_BOX:
14456 SetDrawModeHiRes(new_element);
14458 if (getDrawModeHiRes())
14464 case GADGET_ID_GRAB_BRUSH:
14465 case GADGET_ID_TEXT:
14467 static int last_sx = -1;
14468 static int last_sy = -1;
14469 static int start_sx = -1;
14470 static int start_sy = -1;
14471 void (*draw_func)(int, int, int, int, int, boolean);
14473 if (drawing_function == GADGET_ID_LINE)
14474 draw_func = DrawLine;
14475 else if (drawing_function == GADGET_ID_ARC)
14476 draw_func = DrawArc;
14477 else if (drawing_function == GADGET_ID_RECTANGLE)
14478 draw_func = DrawBox;
14479 else if (drawing_function == GADGET_ID_FILLED_BOX)
14480 draw_func = DrawFilledBox;
14481 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
14482 draw_func = SelectArea;
14483 else // (drawing_function == GADGET_ID_TEXT)
14484 draw_func = SetTextCursor;
14486 if (button_press_event)
14488 draw_func(sx, sy, sx, sy, new_element, FALSE);
14489 start_sx = last_sx = sx;
14490 start_sy = last_sy = sy;
14492 if (drawing_function == GADGET_ID_TEXT)
14493 DrawLevelText(0, 0, 0, TEXT_END);
14495 else if (button_release_event)
14497 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
14498 if (drawing_function == GADGET_ID_GRAB_BRUSH)
14500 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
14501 CopyBrushToCursor(sx, sy);
14502 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
14504 draw_with_brush = TRUE;
14506 else if (drawing_function == GADGET_ID_TEXT)
14507 DrawLevelText(sx, sy, 0, TEXT_INIT);
14509 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14511 else if (last_sx != sx || last_sy != sy)
14513 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
14514 if (IS_MM_WALL_EDITOR(new_element)) // clear wall background
14515 draw_func(start_sx, start_sy, sx, sy, EL_EMPTY, FALSE);
14516 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
14523 case GADGET_ID_FLOOD_FILL:
14524 if (button_press_event && Tile[lx][ly] != new_element)
14526 if (IS_MM_WALL_EDITOR(new_element))
14527 FloodFillWall_MM(sx2, sy2, new_element);
14529 FloodFill(lx, ly, new_element);
14531 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14532 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14536 case GADGET_ID_PICK_ELEMENT:
14537 if (button_release_event)
14538 ClickOnGadget(level_editor_gadget[last_drawing_function],
14540 else if (draw_level)
14541 PickDrawingElement(button, Tile[lx][ly]);
14544 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14546 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
14553 // do not mark level as modified for certain non-level-changing gadgets
14554 if ((type_id >= ED_DRAWING_ID_EDITOR_FIRST &&
14555 type_id <= ED_DRAWING_ID_EDITOR_LAST) ||
14556 actual_drawing_function == GADGET_ID_GRAB_BRUSH ||
14557 actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14560 level.changed = TRUE;
14563 static void HandleCounterButtons(struct GadgetInfo *gi)
14565 int gadget_id = gi->custom_id;
14566 int counter_id = gi->custom_type_id;
14567 int button = gi->event.button;
14568 int *counter_value = counterbutton_info[counter_id].value;
14569 int step = BUTTON_STEPSIZE(button) *
14570 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
14572 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
14574 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
14575 boolean released = (gi->event.type == GD_EVENT_RELEASED);
14576 boolean level_changed = LevelChanged();
14578 if ((level_changed && pressed) || (!level_changed && released))
14581 if (level_changed && !Request("Level has changed! Discard changes?",
14584 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
14585 ModifyEditorCounterValue(counter_id, *counter_value);
14591 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
14592 *counter_value = gi->textinput.number_value;
14594 ModifyEditorCounterValue(counter_id, *counter_value + step);
14596 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
14598 int last_game_engine_type = level.game_engine_type;
14600 LoadLevel(level_nr);
14601 LoadScore(level_nr);
14603 SaveLevelSetup_SeriesInfo();
14608 DrawEditModeWindow();
14610 if (level.game_engine_type != last_game_engine_type)
14612 // update element selection list
14613 ReinitializeElementList();
14614 ModifyEditorElementList();
14620 switch (counter_id)
14622 case ED_COUNTER_ID_YAMYAM_CONTENT:
14623 DrawYamYamContentAreas();
14626 case ED_COUNTER_ID_BALL_CONTENT:
14627 DrawMagicBallContentAreas();
14630 case ED_COUNTER_ID_ANDROID_CONTENT:
14631 DrawAndroidElementArea();
14634 case ED_COUNTER_ID_GROUP_CONTENT:
14635 DrawGroupElementArea();
14636 CopyGroupElementPropertiesToGame(properties_element);
14639 case ED_COUNTER_ID_INVENTORY_SIZE:
14640 DrawPlayerInitialInventoryArea(properties_element);
14643 case ED_COUNTER_ID_MM_BALL_CONTENT:
14644 DrawMMBallContentArea();
14647 case ED_COUNTER_ID_ENVELOPE_XSIZE:
14648 case ED_COUNTER_ID_ENVELOPE_YSIZE:
14649 DrawEnvelopeTextArea(-1);
14652 case ED_COUNTER_ID_LEVEL_XSIZE:
14653 case ED_COUNTER_ID_LEVEL_YSIZE:
14654 lev_fieldx = level.fieldx;
14655 lev_fieldy = level.fieldy;
14657 // check if resizing of level results in change of border border
14658 SetBorderElement();
14666 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
14667 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
14668 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
14669 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
14670 CopyElementPropertiesToGame(properties_element);
14672 // do not mark level as modified for certain non-level-changing gadgets
14673 if ((counter_id >= ED_COUNTER_ID_LEVELSET_FIRST &&
14674 counter_id <= ED_COUNTER_ID_LEVELSET_LAST) ||
14675 (counter_id >= ED_COUNTER_ID_EDITOR_FIRST &&
14676 counter_id <= ED_COUNTER_ID_EDITOR_LAST))
14679 level.changed = TRUE;
14682 static void HandleTextInputGadgets(struct GadgetInfo *gi)
14684 int type_id = gi->custom_type_id;
14686 strcpy(textinput_info[type_id].value, gi->textinput.value);
14688 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
14690 CopyElementPropertiesToGame(properties_element);
14692 ModifyEditorElementList(); // update changed button info text
14695 // do not mark level as modified for certain non-level-changing gadgets
14696 if (type_id >= ED_TEXTINPUT_ID_LEVELSET_FIRST &&
14697 type_id <= ED_TEXTINPUT_ID_LEVELSET_LAST)
14700 level.changed = TRUE;
14703 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
14705 int type_id = gi->custom_type_id;
14707 strncpy(textarea_info[type_id].value, gi->textarea.value,
14708 MAX_ENVELOPE_TEXT_LEN);
14709 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
14711 level.changed = TRUE;
14714 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
14716 int type_id = gi->custom_type_id;
14717 int value_old = *selectbox_info[type_id].value;
14718 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
14720 *selectbox_info[type_id].value = value_new;
14722 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE)
14724 DrawLevelConfigWindow();
14726 else if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14728 element_info[properties_element].current_change_page = gi->selectbox.index;
14730 DrawPropertiesWindow();
14732 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
14733 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
14734 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
14735 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
14736 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
14738 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
14740 // when changing action type, also check action mode and action arg
14741 if (value_old != value_new)
14742 setSelectboxSpecialActionVariablesIfNeeded();
14744 DrawPropertiesChange();
14747 CopyElementPropertiesToGame(properties_element);
14749 else if (type_id == ED_SELECTBOX_ID_GAME_ENGINE_TYPE)
14751 // show or hide "engine" tabulator depending on game engine type
14752 DrawLevelConfigWindow();
14754 // update element selection list depending on game engine type
14755 ReinitializeElementList();
14756 ModifyEditorElementList();
14758 else if (type_id == ED_SELECTBOX_ID_BD_SCHEDULING_TYPE)
14760 // update BD cycle delay counter gadgets depending on BD scheduling type
14761 DrawLevelConfigWindow();
14764 // do not mark level as modified for certain non-level-changing gadgets
14765 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE ||
14766 type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14769 level.changed = TRUE;
14772 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
14774 int type_id = gi->custom_type_id;
14777 if (type_id >= ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST &&
14778 type_id <= ED_TAB_BUTTON_ID_LEVELCONFIG_LAST)
14780 edit_mode_levelconfig = gi->custom_type_id;
14782 DrawLevelConfigWindow();
14784 else if (type_id >= ED_TAB_BUTTON_ID_PROPERTIES_FIRST &&
14785 type_id <= ED_TAB_BUTTON_ID_PROPERTIES_LAST)
14787 edit_mode_properties = gi->custom_type_id;
14789 DrawPropertiesWindow();
14791 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 ||
14792 type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2)
14794 boolean new_template = !fileExists(getLocalLevelTemplateFilename());
14796 // backup original "level.field" (needed to track playfield changes)
14797 CopyPlayfield(level.field, TileBackup);
14799 // "SaveLevelTemplate()" uses "level.field", so copy editor playfield
14800 CopyPlayfield(Tile, level.field);
14802 if (new_template ||
14803 Request("Save this template and kill the old?", REQ_ASK))
14804 SaveLevelTemplate();
14807 Request("Template saved!", REQ_CONFIRM);
14809 // restore original "level.field" (needed to track playfield changes)
14810 CopyPlayfield(TileBackup, level.field);
14812 else if (type_id == ED_TEXTBUTTON_ID_SAVE_LEVELSET)
14814 char *levelset_subdir = getLevelSubdirFromSaveMode(levelset_save_mode);
14816 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE &&
14817 leveldir_current->readonly)
14819 Request("This level set is read-only!", REQ_CONFIRM);
14824 if (strEqual(levelset_name, ""))
14826 Request("Please enter level set title!", REQ_CONFIRM);
14831 if (strEqual(levelset_author, ""))
14833 Request("Please enter level set author!", REQ_CONFIRM);
14838 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE)
14840 if (UpdateUserLevelSet(levelset_subdir,
14843 levelset_num_levels))
14845 Request("Level set updated!", REQ_CONFIRM);
14849 Request("Updating level set failed!", REQ_CONFIRM);
14852 else if (levelset_save_mode == LEVELSET_SAVE_MODE_CREATE)
14854 if (level.changed && !Request("Level has changed! Discard changes?",
14858 if (CreateUserLevelSet(levelset_subdir,
14861 levelset_num_levels,
14862 levelset_use_levelset_artwork))
14864 if (levelset_copy_level_template)
14865 CopyLevelTemplateToUserLevelSet(levelset_subdir);
14867 Request("New level set created!", REQ_CONFIRM);
14869 AddUserLevelSetToLevelInfo(levelset_subdir);
14870 ChangeEditorToLevelSet(levelset_subdir);
14874 Request("Creating new level set failed!", REQ_CONFIRM);
14878 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
14879 custom_element.num_change_pages < MAX_CHANGE_PAGES)
14881 struct ElementInfo *ei = &element_info[properties_element];
14883 // when modifying custom element, ask for copying level template
14884 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14887 setElementChangePages(ei, ei->num_change_pages + 1);
14889 // set new change page to be new current change page
14890 ei->current_change_page = ei->num_change_pages - 1;
14891 ei->change = &ei->change_page[ei->current_change_page];
14893 setElementChangeInfoToDefaults(ei->change);
14895 DrawPropertiesWindow();
14897 level.changed = TRUE;
14899 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
14900 custom_element.num_change_pages > MIN_CHANGE_PAGES)
14902 struct ElementInfo *ei = &element_info[properties_element];
14904 // when modifying custom element, ask for copying level template
14905 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14908 // copy all change pages after change page to be deleted
14909 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
14910 ei->change_page[i] = ei->change_page[i + 1];
14912 setElementChangePages(ei, ei->num_change_pages - 1);
14914 DrawPropertiesWindow();
14916 level.changed = TRUE;
14920 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
14922 int type_id = gi->custom_type_id;
14924 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
14925 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
14927 struct ElementInfo *ei = &element_info[properties_element];
14928 int step = BUTTON_STEPSIZE(gi->event.button);
14930 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
14931 ei->current_change_page += step;
14933 if (ei->current_change_page < 0)
14934 ei->current_change_page = 0;
14935 else if (ei->current_change_page >= ei->num_change_pages)
14936 ei->current_change_page = ei->num_change_pages - 1;
14938 DrawPropertiesWindow();
14940 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
14941 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14943 struct ElementInfo *ei = &element_info[properties_element];
14944 int current_change_page = ei->current_change_page;
14946 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
14948 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
14949 ei->change_page[current_change_page];
14951 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14953 // when modifying custom element, ask for copying level template
14954 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14957 ei->change_page[current_change_page] =
14958 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
14960 level.changed = TRUE;
14963 DrawPropertiesWindow();
14967 static void HandleRadiobuttons(struct GadgetInfo *gi)
14969 int type_id = gi->custom_type_id;
14971 *radiobutton_info[type_id].value =
14972 radiobutton_info[type_id].checked_value;
14974 // do not mark level as modified for certain non-level-changing gadgets
14975 if (type_id >= ED_RADIOBUTTON_ID_EDITOR_FIRST &&
14976 type_id <= ED_RADIOBUTTON_ID_EDITOR_LAST)
14979 level.changed = TRUE;
14982 static void HandleCheckbuttons(struct GadgetInfo *gi)
14984 int type_id = gi->custom_type_id;
14986 *checkbutton_info[type_id].value ^= TRUE;
14988 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
14989 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
14990 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
14991 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
14992 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
14993 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
14994 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
14995 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1))
14997 CopyElementPropertiesToGame(properties_element);
15000 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
15002 UpdateCustomElementGraphicGadgets();
15004 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 ||
15005 type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2)
15007 boolean template_related_changes_found = FALSE;
15010 // check if any custom, group or empty elements have been changed
15011 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
15012 if ((IS_CUSTOM_ELEMENT(i) ||
15013 IS_GROUP_ELEMENT(i) ||
15014 IS_EMPTY_ELEMENT(i)) &&
15015 element_info[i].modified_settings)
15016 template_related_changes_found = TRUE;
15018 if (level.use_custom_template &&
15019 !fileExists(getGlobalLevelTemplateFilename()))
15021 Request("No level template found!", REQ_CONFIRM);
15023 level.use_custom_template = FALSE;
15025 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
15030 if (level.use_custom_template &&
15031 template_related_changes_found &&
15032 !Request("Discard changes and use level template?", REQ_ASK))
15034 level.use_custom_template = FALSE;
15036 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
15041 if (!level.use_custom_template &&
15042 Request("Copy settings from level template?", REQ_ASK))
15047 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
15049 DrawEditModeWindow();
15051 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3)
15053 if (setup.editor.use_template_for_new_levels &&
15054 !fileExists(getGlobalLevelTemplateFilename()))
15056 Request("No level template found!", REQ_CONFIRM);
15061 if (setup.editor.use_template_for_new_levels &&
15063 !Request("Discard level and load template?", REQ_ASK))
15068 if (!setup.editor.use_template_for_new_levels &&
15070 !Request("Discard level and use empty level?", REQ_ASK))
15075 LoadLevel(level_nr);
15076 LoadScore(level_nr);
15081 DrawEditModeWindow();
15083 else if (type_id == ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS)
15085 SetAutomaticNumberOfGemsNeeded();
15088 // do not mark level as modified for certain non-level-changing gadgets
15089 if ((type_id >= ED_CHECKBUTTON_ID_LEVELSET_FIRST &&
15090 type_id <= ED_CHECKBUTTON_ID_LEVELSET_LAST) ||
15091 (type_id >= ED_CHECKBUTTON_ID_EDITOR_FIRST &&
15092 type_id <= ED_CHECKBUTTON_ID_EDITOR_LAST &&
15093 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2) ||
15094 type_id == ED_CHECKBUTTON_ID_STICK_ELEMENT)
15097 level.changed = TRUE;
15100 static void HandleControlButtons(struct GadgetInfo *gi)
15102 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
15103 static int last_edit_mode = ED_MODE_DRAWING;
15104 static int last_custom_copy_mode = -1;
15105 static int last_button = 0;
15106 int id = gi->custom_id;
15107 int button = gi->event.button;
15108 int step = BUTTON_STEPSIZE(button);
15109 int new_element = BUTTON_ELEMENT(button);
15110 int last_properties_element = properties_element;
15113 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
15114 DrawLevelText(0, 0, 0, TEXT_END);
15116 if (id < ED_NUM_CTRL1_BUTTONS &&
15117 id != GADGET_ID_SINGLE_ITEMS &&
15118 id != GADGET_ID_PICK_ELEMENT &&
15119 edit_mode != ED_MODE_DRAWING &&
15120 drawing_function != GADGET_ID_PICK_ELEMENT &&
15121 !(GetKeyModState() & KMOD_Control))
15122 ChangeEditModeWindow(ED_MODE_DRAWING);
15124 // element copy mode active, but no element button pressed => deactivate
15125 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
15126 last_custom_copy_mode = -1;
15128 // when showing palette on element buttons, change element of button used
15129 if (editor.palette.show_on_element_buttons &&
15130 id >= GADGET_ID_ELEMENT_LEFT && id <= GADGET_ID_ELEMENT_RIGHT)
15132 last_button = id - GADGET_ID_ELEMENT_LEFT + 1;
15134 id = GADGET_ID_PALETTE;
15139 case GADGET_ID_SCROLL_LEFT:
15140 if (level_xpos >= 0)
15142 if (lev_fieldx < ed_fieldx - 2)
15145 level_xpos -= step;
15146 if (level_xpos < -1)
15149 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
15151 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15153 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
15154 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
15158 case GADGET_ID_SCROLL_RIGHT:
15159 if (level_xpos <= lev_fieldx - ed_fieldx)
15161 if (lev_fieldx < ed_fieldx - 2)
15164 level_xpos += step;
15165 if (level_xpos > lev_fieldx - ed_fieldx + 1)
15166 level_xpos = lev_fieldx - ed_fieldx + 1;
15168 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
15170 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15172 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
15173 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
15177 case GADGET_ID_SCROLL_UP:
15178 if (level_ypos >= 0)
15180 if (lev_fieldy < ed_fieldy - 2)
15183 level_ypos -= step;
15184 if (level_ypos < -1)
15187 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
15189 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15191 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
15192 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
15196 case GADGET_ID_SCROLL_DOWN:
15197 if (level_ypos <= lev_fieldy - ed_fieldy)
15199 if (lev_fieldy < ed_fieldy - 2)
15202 level_ypos += step;
15203 if (level_ypos > lev_fieldy - ed_fieldy + 1)
15204 level_ypos = lev_fieldy - ed_fieldy + 1;
15206 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
15208 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15210 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
15211 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
15215 case GADGET_ID_SCROLL_HORIZONTAL:
15216 level_xpos = gi->event.item_position - 1;
15218 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15223 case GADGET_ID_SCROLL_VERTICAL:
15224 level_ypos = gi->event.item_position - 1;
15226 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15231 case GADGET_ID_SCROLL_LIST_UP:
15232 case GADGET_ID_SCROLL_LIST_DOWN:
15233 case GADGET_ID_SCROLL_LIST_VERTICAL:
15234 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
15235 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
15238 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
15239 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
15241 if (element_shift < 0)
15243 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15244 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15246 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15247 GDI_SCROLLBAR_ITEM_POSITION,
15248 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15251 ModifyEditorElementList();
15255 case GADGET_ID_PROPERTIES:
15256 // always switch off element properties when they are already displayed
15257 last_properties_element = new_element;
15258 case GADGET_ID_ELEMENT_LEFT:
15259 case GADGET_ID_ELEMENT_MIDDLE:
15260 case GADGET_ID_ELEMENT_RIGHT:
15261 properties_element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
15262 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
15263 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 :
15266 if (edit_mode != ED_MODE_PROPERTIES)
15268 last_edit_mode = edit_mode;
15270 ChangeEditModeWindow(ED_MODE_PROPERTIES);
15272 last_level_drawing_function = drawing_function;
15273 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
15276 else if (properties_element != last_properties_element)
15278 DrawEditModeWindow();
15282 ChangeEditModeWindow(ED_MODE_DRAWING);
15284 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
15289 case GADGET_ID_PALETTE:
15290 if (edit_mode != ED_MODE_PALETTE)
15292 last_edit_mode = edit_mode;
15294 ChangeEditModeWindow(ED_MODE_PALETTE);
15298 ChangeEditModeWindow(last_edit_mode);
15302 case GADGET_ID_WRAP_LEFT:
15303 WrapLevel(-step, 0);
15306 case GADGET_ID_WRAP_RIGHT:
15307 WrapLevel(step, 0);
15310 case GADGET_ID_WRAP_UP:
15311 WrapLevel(0, -step);
15314 case GADGET_ID_WRAP_DOWN:
15315 WrapLevel(0, step);
15318 case GADGET_ID_SINGLE_ITEMS:
15319 case GADGET_ID_CONNECTED_ITEMS:
15320 case GADGET_ID_LINE:
15321 case GADGET_ID_ARC:
15322 case GADGET_ID_TEXT:
15323 case GADGET_ID_RECTANGLE:
15324 case GADGET_ID_FILLED_BOX:
15325 case GADGET_ID_FLOOD_FILL:
15326 case GADGET_ID_GRAB_BRUSH:
15327 case GADGET_ID_PICK_ELEMENT:
15328 if (drawing_function != GADGET_ID_PICK_ELEMENT)
15329 last_drawing_function = drawing_function;
15330 drawing_function = id;
15331 draw_with_brush = FALSE;
15334 case GADGET_ID_RANDOM_PLACEMENT:
15335 RandomPlacement(new_element);
15338 case GADGET_ID_ZOOM:
15339 // zoom level editor tile size in or out (or reset to default size)
15340 ed_tilesize = (button == 1 ? ed_tilesize * 2 :
15341 button == 2 ? ed_tilesize_default :
15342 button == 3 ? ed_tilesize / 2 : ed_tilesize);
15344 // when using touch device, cycle through all zoom tilesizes
15345 if (runtime.uses_touch_device && ed_tilesize > TILESIZE)
15346 ed_tilesize = MICRO_TILESIZE;
15348 // limit zoom level by upper and lower bound
15349 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
15351 InitZoomLevelSettings(ed_tilesize);
15353 if (edit_mode == ED_MODE_DRAWING)
15355 DrawDrawingWindow();
15357 // redraw zoom gadget info text
15358 PrintEditorGadgetInfoText(level_editor_gadget[id]);
15361 // save current editor zoom tilesize
15362 SaveSetup_AutoSetup();
15366 case GADGET_ID_CUSTOM_COPY_FROM:
15367 case GADGET_ID_CUSTOM_COPY_TO:
15368 case GADGET_ID_CUSTOM_EXCHANGE:
15369 last_custom_copy_mode = id;
15370 last_drawing_function = drawing_function;
15373 case GADGET_ID_CUSTOM_COPY:
15374 CopyCustomElement(properties_element, -1, id);
15377 case GADGET_ID_CUSTOM_PASTE:
15378 CopyCustomElement(-1, properties_element, id);
15381 case GADGET_ID_UNDO:
15382 if (button < 0) // keep button value (even if modifier keys are pressed)
15384 else if (button == 1 && GetKeyModState() & (KMOD_Shift | KMOD_Control))
15387 if (button == 1 && undo_buffer_steps == 0)
15389 Request("Undo buffer empty!", REQ_CONFIRM);
15393 else if (button == 2)
15397 else if (button == 3 && redo_buffer_steps == 0)
15399 Request("Redo buffer empty!", REQ_CONFIRM);
15404 if (edit_mode != ED_MODE_DRAWING)
15405 ChangeEditModeWindow(ED_MODE_DRAWING);
15411 undo_buffer_position =
15412 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
15414 undo_buffer_steps--;
15415 redo_buffer_steps++;
15421 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
15423 undo_buffer_steps++;
15424 redo_buffer_steps--;
15427 for (x = 0; x < lev_fieldx; x++)
15428 for (y = 0; y < lev_fieldy; y++)
15429 Tile[x][y] = UndoBuffer[undo_buffer_position][x][y];
15431 // check if undo operation forces change of border style
15432 CheckLevelBorderElement(FALSE);
15434 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15438 case GADGET_ID_CONF:
15439 if (edit_mode != ED_MODE_LEVELCONFIG)
15441 last_edit_mode = edit_mode;
15443 ChangeEditModeWindow(ED_MODE_LEVELCONFIG);
15447 ChangeEditModeWindow(ED_MODE_DRAWING);
15451 case GADGET_ID_CLEAR:
15452 if (edit_mode != ED_MODE_DRAWING)
15453 ChangeEditModeWindow(ED_MODE_DRAWING);
15455 for (x = 0; x < MAX_LEV_FIELDX; x++)
15456 for (y = 0; y < MAX_LEV_FIELDY; y++)
15457 Tile[x][y] = (button == 1 ? EL_EMPTY : new_element);
15459 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
15461 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15464 case GADGET_ID_SAVE:
15466 // saving read-only levels into personal level set modifies global vars
15467 // "leveldir_current" and "level_nr"; restore them after saving level
15468 LevelDirTree *leveldir_former = leveldir_current;
15469 int level_nr_former = level_nr;
15470 char *level_filename;
15473 if (leveldir_current->readonly &&
15474 !PrepareSavingIntoPersonalLevelSet())
15477 level_filename = getDefaultLevelFilename(level_nr);
15478 new_level = !fileExists(level_filename);
15481 Request("Save this level and kill the old?", REQ_ASK))
15483 if (leveldir_former->readonly)
15484 ModifyLevelConfigForSavingIntoPersonalLevelSet(leveldir_former->name);
15486 SetAutomaticNumberOfGemsNeeded();
15488 CopyPlayfield(Tile, level.field);
15489 SaveLevel(level_nr);
15491 level.changed = FALSE;
15495 char level_saved_msg[64];
15497 if (leveldir_former->readonly)
15498 sprintf(level_saved_msg,
15499 "Level saved as level %d into personal level set!",
15502 strcpy(level_saved_msg, "Level saved!");
15504 Request(level_saved_msg, REQ_CONFIRM);
15508 // "cd" back to copied-from levelset (in case of saved read-only level)
15509 leveldir_current = leveldir_former;
15510 level_nr = level_nr_former;
15515 case GADGET_ID_TEST:
15516 if (LevelChanged())
15517 level.game_version = GAME_VERSION_ACTUAL;
15519 CopyPlayfield(level.field, TileBackup);
15520 CopyPlayfield(Tile, level.field);
15522 CopyNativeLevel_RND_to_Native(&level);
15524 UnmapLevelEditorGadgets();
15525 UndrawSpecialEditorDoor();
15527 CloseDoor(DOOR_CLOSE_ALL);
15529 // needed before playing if editor playfield area has different size
15530 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
15532 // redraw_mask = REDRAW_ALL;
15534 level_editor_test_game = TRUE;
15536 StartGameActions(FALSE, setup.autorecord, level.random_seed);
15540 case GADGET_ID_EXIT:
15541 RequestExitLevelEditor(TRUE, FALSE); // if level has changed, ask user
15545 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
15546 id <= GADGET_ID_ELEMENTLIST_LAST)
15548 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
15550 new_element = editor_elements[element_position + element_shift];
15552 if (IS_EDITOR_CASCADE(new_element))
15556 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
15558 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
15559 boolean *cascade_value = editor_elements_info[i].setup_cascade_value;
15561 if (*cascade_element == new_element)
15563 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
15564 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
15566 // update element selection list
15567 ReinitializeElementList();
15568 ModifyEditorElementList();
15570 // update cascading gadget info text
15571 PrintEditorGadgetInfoText(level_editor_gadget[id]);
15573 // save current editor cascading state
15574 SaveSetup_EditorCascade();
15583 if (last_custom_copy_mode != -1)
15585 if (CopyCustomElement(properties_element, new_element,
15586 last_custom_copy_mode))
15588 ClickOnGadget(level_editor_gadget[last_drawing_function],
15591 last_custom_copy_mode = -1;
15597 // change element of button used to show palette
15598 if (editor.palette.show_on_element_buttons)
15599 button = last_button;
15601 PickDrawingElement(button, new_element);
15603 if (!stick_element_properties_window &&
15604 drawing_function != GADGET_ID_PICK_ELEMENT &&
15605 !(GetKeyModState() & KMOD_Control))
15607 properties_element = new_element;
15608 if (edit_mode == ED_MODE_PROPERTIES)
15609 DrawPropertiesWindow();
15612 if (drawing_function == GADGET_ID_PICK_ELEMENT)
15613 ClickOnGadget(level_editor_gadget[last_drawing_function],
15616 if (!use_permanent_palette)
15617 ChangeEditModeWindow(last_edit_mode);
15620 else if (gi->event.type == GD_EVENT_PRESSED)
15621 Debug("editor", "default: HandleControlButtons: GD_EVENT_PRESSED(%d)", id);
15622 else if (gi->event.type == GD_EVENT_RELEASED)
15623 Debug("editor", "default: HandleControlButtons: GD_EVENT_RELEASED(%d)", id);
15624 else if (gi->event.type == GD_EVENT_MOVING)
15625 Debug("editor", "default: HandleControlButtons: GD_EVENT_MOVING(%d)", id);
15627 Debug("editor", "default: HandleControlButtons: ? (id == %d)", id);
15633 void HandleLevelEditorKeyInput(Key key)
15635 char letter = getCharFromKey(key);
15637 if (drawing_function == GADGET_ID_TEXT &&
15638 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
15641 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
15642 else if (key == KSYM_Delete || key == KSYM_BackSpace)
15643 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
15644 else if (key == KSYM_Return)
15645 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
15646 else if (key == KSYM_Escape)
15647 DrawLevelText(0, 0, 0, TEXT_END);
15652 int id = GADGET_ID_NONE;
15653 int new_element_shift = element_shift;
15654 int step = ED_ELEMENTLIST_BUTTONS_VERT - 1;
15655 int button = MB_LEFTBUTTON;
15661 id = GADGET_ID_SCROLL_LEFT;
15664 id = GADGET_ID_SCROLL_RIGHT;
15667 id = GADGET_ID_SCROLL_UP;
15670 id = GADGET_ID_SCROLL_DOWN;
15674 case KSYM_Page_Down:
15675 step *= (key == KSYM_Page_Up ? -1 : +1);
15676 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
15678 if (element_shift < 0)
15680 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15681 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15683 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15684 GDI_SCROLLBAR_ITEM_POSITION,
15685 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15687 ModifyEditorElementList();
15693 element_shift = (key == KSYM_Home ? 0 :
15694 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
15696 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15697 GDI_SCROLLBAR_ITEM_POSITION,
15698 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15700 ModifyEditorElementList();
15707 // this is needed to prevent interference with running "True X-Mouse"
15708 if (GetKeyModStateFromEvents() & KMOD_Control)
15711 // check for last or next editor cascade block in element list
15712 for (i = 0; i < num_editor_elements; i++)
15714 if ((key == KSYM_Insert && i == element_shift) ||
15715 (key == KSYM_Delete && new_element_shift > element_shift))
15718 // jump to next cascade block (or to start of element list)
15719 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
15720 new_element_shift = i;
15723 if (i < num_editor_elements)
15724 element_shift = new_element_shift;
15726 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15727 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15729 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15730 GDI_SCROLLBAR_ITEM_POSITION,
15731 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15733 ModifyEditorElementList();
15738 if (edit_mode == ED_MODE_DRAWING)
15739 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
15740 else if (edit_mode == ED_MODE_LEVELCONFIG)
15741 HandleControlButtons(level_editor_gadget[GADGET_ID_CONF]);
15742 else if (edit_mode == ED_MODE_PROPERTIES)
15743 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
15744 else if (edit_mode == ED_MODE_PALETTE)
15745 HandleControlButtons(level_editor_gadget[GADGET_ID_PALETTE]);
15746 else // should never happen
15747 ChangeEditModeWindow(ED_MODE_DRAWING);
15755 if (id != GADGET_ID_NONE)
15756 ClickOnGadget(level_editor_gadget[id], button);
15757 else if (letter == '1' || letter == '?')
15758 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_LEFT], button);
15759 else if (letter == '2')
15760 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_MIDDLE], button);
15761 else if (letter == '3')
15762 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_RIGHT], button);
15763 else if (letter == '.')
15764 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
15765 else if (letter == 'U')
15766 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
15767 else if (letter == '-' || key == KSYM_KP_Subtract)
15768 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
15769 else if (letter == '0' || key == KSYM_KP_0)
15770 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
15771 else if (letter == '+' || key == KSYM_KP_Add ||
15772 letter == '=') // ("Shift-=" is "+" on US keyboards)
15773 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
15774 else if (key == KSYM_Return ||
15775 key == KSYM_space ||
15776 key == setup.shortcut.toggle_pause)
15777 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
15779 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
15780 if (letter && letter == controlbutton_info[i].shortcut)
15781 if (!anyTextGadgetActive())
15782 ClickOnGadget(level_editor_gadget[i], button);
15784 if (draw_with_brush)
15788 else if (letter == 'y')
15790 else if (letter == 'z')
15795 static void HandleLevelEditorIdle_Properties(void)
15797 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
15798 int x = editor.settings.element_graphic.x + element_border;
15799 int y = editor.settings.element_graphic.y + element_border;
15800 static DelayCounter action_delay = { 0 };
15803 action_delay.value = GameFrameDelay;
15805 if (!DelayReached(&action_delay))
15808 for (i = 0; i < ED_NUM_SELECTBOX; i++)
15810 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
15812 if (gi->mapped && gi->active && gi->selectbox.open)
15816 DrawEditorElementAnimation(SX + x, SY + y);
15818 redraw_mask |= REDRAW_FIELD;
15820 FrameCounter++; // increase animation frame counter
15823 static void HandleLevelEditorIdle_Drawing(void)
15825 static boolean last_highlighted = FALSE;
15826 static boolean last_highlighted_similar = FALSE;
15827 boolean highlighted = (GetKeyModState() & KMOD_Alt);
15828 boolean highlighted_similar = (GetKeyModState() & KMOD_Shift);
15830 if (highlighted != last_highlighted ||
15831 (highlighted && highlighted_similar != last_highlighted_similar))
15833 DrawAreaElementHighlight(highlighted, highlighted_similar);
15835 redraw_mask |= REDRAW_FIELD;
15838 last_highlighted = highlighted;
15839 last_highlighted_similar = highlighted_similar;
15842 void HandleLevelEditorIdle(void)
15844 if (edit_mode == ED_MODE_PROPERTIES)
15845 HandleLevelEditorIdle_Properties();
15846 else if (edit_mode == ED_MODE_DRAWING)
15847 HandleLevelEditorIdle_Drawing();
15850 static void ClearEditorGadgetInfoText(void)
15852 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
15855 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
15857 char infotext[MAX_OUTPUT_LINESIZE + 1];
15858 int max_infotext_len = getMaxInfoTextLength();
15860 if (gi == NULL || strlen(gi->info_text) == 0)
15863 strncpy(infotext, gi->info_text, max_infotext_len);
15864 infotext[max_infotext_len] = '\0';
15866 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
15868 int key = controlbutton_info[gi->custom_id].shortcut;
15872 char shortcut[MAX_OUTPUT_LINESIZE + 1];
15874 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
15875 sprintf(shortcut, " ('.' or '%c')", key);
15876 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
15877 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
15878 else if (gi->custom_id == GADGET_ID_TEST)
15879 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
15880 else if (gi->custom_id == GADGET_ID_UNDO)
15881 sprintf(shortcut, " ('%c/Shift-U')", key);
15882 else if (gi->custom_id == GADGET_ID_ZOOM)
15883 sprintf(shortcut, " ('%c', '0', '-')", key);
15885 sprintf(shortcut, " ('%s%c')",
15886 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
15888 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
15889 strcat(infotext, shortcut);
15893 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, INFOTEXT_FONT);
15896 void HandleEditorGadgetInfoText(void *ptr)
15898 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
15900 if (game_status != GAME_MODE_EDITOR)
15903 ClearEditorGadgetInfoText();
15905 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
15908 // misuse this function to delete brush cursor, if needed
15909 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
15910 DeleteBrushFromCursor();
15912 PrintEditorGadgetInfoText(gi);
15915 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
15917 int id = gi->custom_id;
15918 int type_id = gi->custom_type_id;
15919 int sx = gi->event.x;
15920 int sy = gi->event.y;
15921 int lx = sx + level_xpos;
15922 int ly = sy + level_ypos;
15923 int min_sx = 0, min_sy = 0;
15924 int max_sx = gi->drawing.area_xsize - 1;
15925 int max_sy = gi->drawing.area_ysize - 1;
15926 int actual_drawing_function = drawing_function;
15927 int max_infotext_len = getMaxInfoTextLength();
15928 char infotext[MAX_OUTPUT_LINESIZE + 1];
15930 infotext[0] = '\0'; // start with empty info text
15932 // pressed Control key: simulate picking element
15933 if (GetKeyModState() & KMOD_Control)
15934 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
15936 ClearEditorGadgetInfoText();
15938 if (gi->event.type == GD_EVENT_INFO_LEAVING)
15941 // make sure to stay inside drawing area boundaries
15942 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
15943 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
15945 if (id == GADGET_ID_DRAWING_LEVEL)
15949 int min_lx = 0, min_ly = 0;
15950 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
15952 // get positions inside level field
15953 lx = sx + level_xpos;
15954 ly = sy + level_ypos;
15956 // make sure to stay inside level field boundaries
15957 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
15958 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
15960 // correct drawing area positions accordingly
15961 sx = lx - level_xpos;
15962 sy = ly - level_ypos;
15965 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
15967 if (button_status) // if (gi->state == GD_BUTTON_PRESSED)
15969 static int start_lx = 0;
15970 static int start_ly = 0;
15973 if (gi->event.type == GD_EVENT_PRESSED)
15979 switch (actual_drawing_function)
15981 case GADGET_ID_SINGLE_ITEMS:
15982 text = "Drawing single items";
15984 case GADGET_ID_CONNECTED_ITEMS:
15985 text = "Drawing connected items";
15987 case GADGET_ID_LINE:
15988 text = "Drawing line";
15990 case GADGET_ID_ARC:
15991 text = "Drawing arc";
15993 case GADGET_ID_TEXT:
15994 text = "Setting text cursor";
15996 case GADGET_ID_RECTANGLE:
15997 text = "Drawing rectangle";
15999 case GADGET_ID_FILLED_BOX:
16000 text = "Drawing filled box";
16002 case GADGET_ID_FLOOD_FILL:
16003 text = "Flood fill";
16005 case GADGET_ID_GRAB_BRUSH:
16006 text = "Grabbing brush";
16008 case GADGET_ID_PICK_ELEMENT:
16009 text = "Picking element";
16013 text = "Drawing position";
16017 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
16018 sprintf(infotext, "%s: %d, %d", text, lx, ly);
16020 sprintf(infotext, "%s: %d, %d", text,
16021 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
16023 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
16024 strncpy(infotext, getElementInfoText(Tile[lx][ly]), max_infotext_len);
16026 sprintf(infotext, "Level position: %d, %d", lx, ly);
16029 // misuse this function to draw brush cursor, if needed
16030 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
16032 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
16033 CopyBrushToCursor(sx, sy);
16035 DeleteBrushFromCursor();
16038 if (!draw_with_brush)
16039 UpdateBrushPosition(sx, sy);
16041 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
16043 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
16044 int element = drawingarea_info[type_id].value[pos];
16046 strncpy(infotext, getElementInfoText(element), max_infotext_len);
16050 if (id == GADGET_ID_CUSTOM_CONTENT)
16051 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
16052 else if (id == GADGET_ID_GROUP_CONTENT)
16053 sprintf(infotext, "group element position: %d", sx + 1);
16054 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
16055 id <= GADGET_ID_YAMYAM_CONTENT_7)
16056 sprintf(infotext, "content area %d position: %d, %d",
16057 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
16058 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
16059 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
16060 sprintf(infotext, "content area %d position: %d, %d",
16061 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
16062 else if (id == GADGET_ID_ANDROID_CONTENT)
16063 sprintf(infotext, "android element position: %d", sx + 1);
16064 else if (drawingarea_info[type_id].infotext != NULL)
16065 strcpy(infotext, drawingarea_info[type_id].infotext);
16068 infotext[max_infotext_len] = '\0';
16070 if (strlen(infotext) > 0)
16071 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT, infotext);
16074 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
16075 boolean quick_quit)
16077 if (!ask_if_level_has_changed ||
16079 Request("Level has changed! Exit without saving?",
16080 REQ_ASK | REQ_STAY_OPEN))
16082 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
16083 struct RectWithBorder *vp_door_2 = &viewport.door_2[GAME_MODE_MAIN];
16085 // draw normal door
16086 UndrawSpecialEditorDoor();
16088 // use door animation if door 1 viewport is unchanged and contains toolbox
16089 if (useEditorDoorAnimation())
16090 CloseDoor(DOOR_CLOSE_1 | DOOR_FORCE_ANIM);
16092 // close editor doors if viewport definition is the same as in main menu
16093 if (vp_door_1->x == DX &&
16094 vp_door_1->y == DY &&
16095 vp_door_1->width == DXSIZE &&
16096 vp_door_1->height == DYSIZE &&
16097 vp_door_2->x == VX &&
16098 vp_door_2->y == VY &&
16099 vp_door_2->width == VXSIZE &&
16100 vp_door_2->height == VYSIZE)
16101 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
16103 SetDoorState(DOOR_CLOSE_ALL);
16108 FadeSkipNextFadeIn();
16110 SetGameStatus(GAME_MODE_MAIN);
16116 if (!global.use_envelope_request)
16118 CloseDoor(DOOR_CLOSE_1);
16119 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);